From cad6a57077c7887025ba532a03f41d6ad78daa72 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 20 Apr 2022 14:20:03 +0200 Subject: 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. --- compiler/inlineasm.go | 5 ++++- 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) } -- cgit v1.2.3