mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 12:03:41 +00:00
interp: support GEP on fixed (MMIO) addresses
GetElementPtr would not work on values that weren't pointers. Because fixed addresses (often used in memory-mapped I/O) are integers rather than pointers in interp, it would return an error. This resulted in the teensy40 target not compiling correctly since the interp package rewrite. This commit should fix that.
This commit is contained in:
+16
-1
@@ -550,7 +550,22 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent
|
||||
}
|
||||
ptr, err := operands[0].asPointer(r)
|
||||
if err != nil {
|
||||
return nil, mem, r.errorAt(inst, err)
|
||||
if err != errIntegerAsPointer {
|
||||
return nil, mem, r.errorAt(inst, err)
|
||||
}
|
||||
// GEP on fixed pointer value (for example, memory-mapped I/O).
|
||||
ptrValue := operands[0].Uint() + offset
|
||||
switch operands[0].len(r) {
|
||||
case 8:
|
||||
locals[inst.localIndex] = literalValue{uint64(ptrValue)}
|
||||
case 4:
|
||||
locals[inst.localIndex] = literalValue{uint32(ptrValue)}
|
||||
case 2:
|
||||
locals[inst.localIndex] = literalValue{uint16(ptrValue)}
|
||||
default:
|
||||
panic("pointer operand is not of a known pointer size")
|
||||
}
|
||||
continue
|
||||
}
|
||||
ptr = ptr.addOffset(uint32(offset))
|
||||
locals[inst.localIndex] = ptr
|
||||
|
||||
Reference in New Issue
Block a user