arm: implement arm.ReadRegister
This pseudo-function reads the contents of the specified register, for example "sp".
Этот коммит содержится в:
родитель
8cb7b583d8
коммит
27fc397e21
2 изменённых файлов: 12 добавлений и 0 удалений
|
@ -1964,6 +1964,14 @@ func (c *Compiler) parseCall(frame *Frame, instr *ssa.CallCommon, parentHandle l
|
||||||
return c.builder.CreateCall(target, nil, ""), nil
|
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" {
|
if fn.RelString(nil) == "device/arm.AsmFull" || fn.RelString(nil) == "device/avr.AsmFull" {
|
||||||
asmString := constant.StringVal(instr.Args[0].(*ssa.Const).Value)
|
asmString := constant.StringVal(instr.Args[0].(*ssa.Const).Value)
|
||||||
registers := map[string]llvm.Value{}
|
registers := map[string]llvm.Value{}
|
||||||
|
|
|
@ -50,6 +50,10 @@ func Asm(asm string)
|
||||||
// })
|
// })
|
||||||
func AsmFull(asm string, regs map[string]interface{})
|
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
|
//go:volatile
|
||||||
type RegValue uint32
|
type RegValue uint32
|
||||||
|
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче