Skip to content

Commit cad6a57

Browse files
aykevldeadprogram
authored andcommitted
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.
1 parent 5223379 commit cad6a57

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

compiler/inlineasm.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ func (b *builder) createInlineAsmFull(instr *ssa.CallCommon) (llvm.Value, error)
9898
case llvm.IntegerTypeKind:
9999
constraints = append(constraints, "r")
100100
case llvm.PointerTypeKind:
101-
constraints = append(constraints, "*m")
101+
// Memory references require a type in LLVM 14, probably as a
102+
// preparation for opaque pointers.
103+
err = b.makeError(instr.Pos(), "support for pointer operands was dropped in TinyGo 0.23")
104+
return s
102105
default:
103106
err = b.makeError(instr.Pos(), "unknown type in inline assembly for value: "+name)
104107
return s

src/machine/machine_k210.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@ func (p Pin) SetInterrupt(change PinChange, callback func(Pin)) error {
236236
kendryte.GPIOHS.RISE_IE.ClearBits(1 << pin)
237237
// Acknowledge interrupt atomically.
238238
riscv.AsmFull(
239-
"amoor.w {}, {mask}, {reg}",
239+
"amoor.w {}, {mask}, ({reg})",
240240
map[string]interface{}{
241241
"mask": uint32(1 << pin),
242-
"reg": &kendryte.GPIOHS.RISE_IP.Reg,
242+
"reg": uintptr(unsafe.Pointer(&kendryte.GPIOHS.RISE_IP.Reg)),
243243
})
244244
kendryte.GPIOHS.RISE_IE.SetBits(1 << pin)
245245
}
@@ -248,10 +248,10 @@ func (p Pin) SetInterrupt(change PinChange, callback func(Pin)) error {
248248
kendryte.GPIOHS.FALL_IE.ClearBits(1 << pin)
249249
// Acknowledge interrupt atomically.
250250
riscv.AsmFull(
251-
"amoor.w {}, {mask}, {reg}",
251+
"amoor.w {}, {mask}, ({reg})",
252252
map[string]interface{}{
253253
"mask": uint32(1 << pin),
254-
"reg": &kendryte.GPIOHS.FALL_IP.Reg,
254+
"reg": uintptr(unsafe.Pointer(&kendryte.GPIOHS.FALL_IP.Reg)),
255255
})
256256
kendryte.GPIOHS.FALL_IE.SetBits(1 << pin)
257257
}

0 commit comments

Comments
 (0)