diff options
author | Ayke van Laethem <[email protected]> | 2022-04-20 14:20:03 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-04-21 15:18:18 +0200 |
commit | cad6a57077c7887025ba532a03f41d6ad78daa72 (patch) | |
tree | 602e6043cc26ba3b58373ad3ade48e2813378178 | |
parent | 52233790ccd6fc4f8a9b3edeeaa90b5d7ec03f6b (diff) | |
download | tinygo-cad6a57077c7887025ba532a03f41d6ad78daa72.tar.gz tinygo-cad6a57077c7887025ba532a03f41d6ad78daa72.zip |
compiler: remove support for memory references in AsmFull
Memory references (`*m` in LLVM IR inline assembly) need a pointer type
starting in LLVM 14. This is a bit inconvenient and requires a new API
in the go-llvm package.
Instead of doing that, I'd like to remove support for memory references
from AsmFull (and possibly AsmFull entirely if possible: it's hard to
use correctly).
This breaks tinygo.org/x/drivers/ws2812 for AVR, ARM, and RISC-V which
need to be updated. Probably using CGo.
-rw-r--r-- | compiler/inlineasm.go | 5 | ||||
-rw-r--r-- | src/machine/machine_k210.go | 8 |
2 files changed, 8 insertions, 5 deletions
diff --git a/compiler/inlineasm.go b/compiler/inlineasm.go index 635aed987..01725a274 100644 --- a/compiler/inlineasm.go +++ b/compiler/inlineasm.go @@ -98,7 +98,10 @@ func (b *builder) createInlineAsmFull(instr *ssa.CallCommon) (llvm.Value, error) case llvm.IntegerTypeKind: constraints = append(constraints, "r") case llvm.PointerTypeKind: - constraints = append(constraints, "*m") + // Memory references require a type in LLVM 14, probably as a + // preparation for opaque pointers. + err = b.makeError(instr.Pos(), "support for pointer operands was dropped in TinyGo 0.23") + return s default: err = b.makeError(instr.Pos(), "unknown type in inline assembly for value: "+name) return s diff --git a/src/machine/machine_k210.go b/src/machine/machine_k210.go index 364406001..1a622f0cf 100644 --- a/src/machine/machine_k210.go +++ b/src/machine/machine_k210.go @@ -236,10 +236,10 @@ func (p Pin) SetInterrupt(change PinChange, callback func(Pin)) error { kendryte.GPIOHS.RISE_IE.ClearBits(1 << pin) // Acknowledge interrupt atomically. riscv.AsmFull( - "amoor.w {}, {mask}, {reg}", + "amoor.w {}, {mask}, ({reg})", map[string]interface{}{ "mask": uint32(1 << pin), - "reg": &kendryte.GPIOHS.RISE_IP.Reg, + "reg": uintptr(unsafe.Pointer(&kendryte.GPIOHS.RISE_IP.Reg)), }) kendryte.GPIOHS.RISE_IE.SetBits(1 << pin) } @@ -248,10 +248,10 @@ func (p Pin) SetInterrupt(change PinChange, callback func(Pin)) error { kendryte.GPIOHS.FALL_IE.ClearBits(1 << pin) // Acknowledge interrupt atomically. riscv.AsmFull( - "amoor.w {}, {mask}, {reg}", + "amoor.w {}, {mask}, ({reg})", map[string]interface{}{ "mask": uint32(1 << pin), - "reg": &kendryte.GPIOHS.FALL_IP.Reg, + "reg": uintptr(unsafe.Pointer(&kendryte.GPIOHS.FALL_IP.Reg)), }) kendryte.GPIOHS.FALL_IE.SetBits(1 << pin) } |