windows: add ARM64 support

This was actually surprising once I got TinyGo to build on Windows 11
ARM64. All the changes are exactly what you'd expect for a new
architecture, there was no special weirdness just for arm64.

Actually getting TinyGo to build was kind of involved though. The very
short summary is: install arm64 versions of some pieces of software
(like golang, cmake) instead of installing them though choco. In
particular, use the llvm-mingw[1] toolchain instead of using standard
mingw.

[1]: https://github.com/mstorsjo/llvm-mingw/releases
This commit is contained in:
Ayke van Laethem
2023-01-29 03:33:37 -08:00
committed by Ron Evans
parent 45c8817ddd
commit df0f5ae1da
11 changed files with 206 additions and 10 deletions
+36
View File
@@ -0,0 +1,36 @@
.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