mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-07 20:43:40 +00:00
arm64: fix register save/restore to include vector registers
Some vector registers must be preserved across calls, but this wasn't happening on Linux and MacOS. When I added support for windows/arm64, I saw that it required these vector registers to be preserved and assumed this was Windows deviating from the standard calling convention. But actually, Windows was just implementing the standard calling convention and the bug was on Linux and MacOS. This commit fixes the bug on Linux and MacOS and at the same time merges the Go and assembly files as they no longer need to be separate.
This commit is contained in:
committed by
Ron Evans
parent
f41b6a3b96
commit
cce9c6d5a1
@@ -4,7 +4,6 @@ _tinygo_scanCurrentStack:
|
||||
#else
|
||||
.section .text.tinygo_scanCurrentStack
|
||||
.global tinygo_scanCurrentStack
|
||||
.type tinygo_scanCurrentStack, %function
|
||||
tinygo_scanCurrentStack:
|
||||
#endif
|
||||
// Sources:
|
||||
@@ -12,12 +11,16 @@ tinygo_scanCurrentStack:
|
||||
// * https://godbolt.org/z/qrvrEh
|
||||
|
||||
// Save callee-saved registers.
|
||||
stp x29, x30, [sp, #-96]!
|
||||
stp x29, x30, [sp, #-160]!
|
||||
stp x28, x27, [sp, #16]
|
||||
stp x26, x25, [sp, #32]
|
||||
stp x24, x23, [sp, #48]
|
||||
stp x22, x21, [sp, #64]
|
||||
stp x20, x19, [sp, #80]
|
||||
stp d8, d9, [sp, #96]
|
||||
stp d10, d11, [sp, #112]
|
||||
stp d12, d13, [sp, #128]
|
||||
stp d14, d15, [sp, #144]
|
||||
|
||||
// Scan the stack.
|
||||
mov x0, sp
|
||||
@@ -28,7 +31,7 @@ tinygo_scanCurrentStack:
|
||||
#endif
|
||||
|
||||
// Restore stack state and return.
|
||||
ldp x29, x30, [sp], #96
|
||||
ldp x29, x30, [sp], #160
|
||||
ret
|
||||
|
||||
|
||||
@@ -38,7 +41,6 @@ _tinygo_longjmp:
|
||||
#else
|
||||
.section .text.tinygo_longjmp
|
||||
.global tinygo_longjmp
|
||||
.type tinygo_longjmp, %function
|
||||
tinygo_longjmp:
|
||||
#endif
|
||||
// Note: the code we jump to assumes x0 is set to a non-zero value if we
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
.section .text.tinygo_scanCurrentStack,"ax"
|
||||
.global tinygo_scanCurrentStack
|
||||
tinygo_scanCurrentStack:
|
||||
// Sources:
|
||||
// * https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170
|
||||
// * https://godbolt.org/z/foc1xncvb
|
||||
|
||||
// Save callee-saved registers.
|
||||
stp x29, x30, [sp, #-160]!
|
||||
stp x28, x27, [sp, #16]
|
||||
stp x26, x25, [sp, #32]
|
||||
stp x24, x23, [sp, #48]
|
||||
stp x22, x21, [sp, #64]
|
||||
stp x20, x19, [sp, #80]
|
||||
stp d8, d9, [sp, #96]
|
||||
stp d10, d11, [sp, #112]
|
||||
stp d12, d13, [sp, #128]
|
||||
stp d14, d15, [sp, #144]
|
||||
|
||||
// Scan the stack.
|
||||
mov x0, sp
|
||||
bl tinygo_scanstack
|
||||
|
||||
// Restore stack state and return.
|
||||
ldp x29, x30, [sp], #160
|
||||
ret
|
||||
|
||||
|
||||
.section .text.tinygo_longjmp,"ax"
|
||||
.global tinygo_longjmp
|
||||
tinygo_longjmp:
|
||||
// Note: the code we jump to assumes x0 is set to a non-zero value if we
|
||||
// jump from here (which is conveniently already the case).
|
||||
ldp x1, x2, [x0] // jumpSP, jumpPC
|
||||
mov sp, x1
|
||||
br x2
|
||||
Reference in New Issue
Block a user