diff --git a/compiler/compiler.go b/compiler/compiler.go index f31e9481..bb6ffbbf 100644 --- a/compiler/compiler.go +++ b/compiler/compiler.go @@ -1964,6 +1964,14 @@ func (c *Compiler) parseCall(frame *Frame, instr *ssa.CallCommon, parentHandle l return c.builder.CreateCall(target, nil, ""), nil } + if fn.RelString(nil) == "device/arm.ReadRegister" { + // Magic function: return the given register. + fnType := llvm.FunctionType(c.uintptrType, []llvm.Type{}, false) + regname := constant.StringVal(instr.Args[0].(*ssa.Const).Value) + target := llvm.InlineAsm(fnType, "mov $0, "+regname, "=r", false, false, 0) + return c.builder.CreateCall(target, nil, ""), nil + } + if fn.RelString(nil) == "device/arm.AsmFull" || fn.RelString(nil) == "device/avr.AsmFull" { asmString := constant.StringVal(instr.Args[0].(*ssa.Const).Value) registers := map[string]llvm.Value{} diff --git a/src/device/arm/arm.go b/src/device/arm/arm.go index d351348b..5ff7d074 100644 --- a/src/device/arm/arm.go +++ b/src/device/arm/arm.go @@ -50,6 +50,10 @@ func Asm(asm string) // }) func AsmFull(asm string, regs map[string]interface{}) +// ReadRegister returns the contents of the specified register. The register +// must be a processor register, reachable with the "mov" instruction. +func ReadRegister(name string) uintptr + //go:volatile type RegValue uint32