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.
Этот коммит содержится в:
Ayke van Laethem 2022-04-20 14:20:03 +02:00 коммит произвёл Ron Evans
родитель 52233790cc
коммит cad6a57077
2 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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)
}