mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 03:53:42 +00:00
all: replace ReadRegister with AsmFull inline assembly
This makes AsmFull more powerful (by supporting return values) and avoids a compiler builtin.
This commit is contained in:
committed by
Ron Evans
parent
9342e73ae1
commit
6389e45d99
@@ -52,11 +52,10 @@ func Asm(asm string)
|
||||
// "value": 1
|
||||
// "result": &dest,
|
||||
// })
|
||||
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
|
||||
//
|
||||
// You can use {} in the asm string (which expands to a register) to set the
|
||||
// return value.
|
||||
func AsmFull(asm string, regs map[string]interface{}) uintptr
|
||||
|
||||
// Run the following system call (SVCall) with 0 arguments.
|
||||
func SVCall0(num uintptr) uintptr
|
||||
|
||||
@@ -15,4 +15,7 @@ func Asm(asm string)
|
||||
// "value": 1
|
||||
// "result": &dest,
|
||||
// })
|
||||
func AsmFull(asm string, regs map[string]interface{})
|
||||
//
|
||||
// You can use {} in the asm string (which expands to a register) to set the
|
||||
// return value.
|
||||
func AsmFull(asm string, regs map[string]interface{}) uintptr
|
||||
|
||||
@@ -5,6 +5,17 @@ package riscv
|
||||
// optimizer.
|
||||
func Asm(asm string)
|
||||
|
||||
// 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
|
||||
// Run the given inline assembly. The code will be marked as having side
|
||||
// effects, as it would otherwise be optimized away. The inline assembly string
|
||||
// recognizes template values in the form {name}, like so:
|
||||
//
|
||||
// arm.AsmFull(
|
||||
// "st {value}, {result}",
|
||||
// map[string]interface{}{
|
||||
// "value": 1
|
||||
// "result": &dest,
|
||||
// })
|
||||
//
|
||||
// You can use {} in the asm string (which expands to a register) to set the
|
||||
// return value.
|
||||
func AsmFull(asm string, regs map[string]interface{}) uintptr
|
||||
|
||||
@@ -15,5 +15,5 @@ func align(ptr uintptr) uintptr {
|
||||
}
|
||||
|
||||
func getCurrentStackPointer() uintptr {
|
||||
return arm.ReadRegister("sp")
|
||||
return arm.AsmFull("mov {}, sp", nil)
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@ func align(ptr uintptr) uintptr {
|
||||
}
|
||||
|
||||
func getCurrentStackPointer() uintptr {
|
||||
return arm.ReadRegister("sp")
|
||||
return arm.AsmFull("mov {}, sp", nil)
|
||||
}
|
||||
|
||||
@@ -15,5 +15,5 @@ func align(ptr uintptr) uintptr {
|
||||
}
|
||||
|
||||
func getCurrentStackPointer() uintptr {
|
||||
return riscv.ReadRegister("sp")
|
||||
return riscv.AsmFull("mv {}, sp", nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user