aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_linux_arm64.s
diff options
context:
space:
mode:
authoreric fang <eric.fang@arm.com>2021-12-23 06:53:50 +0000
committerEric Fang <eric.fang@arm.com>2022-03-30 01:28:43 +0000
commiteee6f9f825596a769ff163e098d2656cbed09d4f (patch)
treec29366047ae3a2e380580ae2513042cf1eac7e08 /src/runtime/sys_linux_arm64.s
parent63169c8bdf3e7ac5006c8976b0631b281eb49394 (diff)
downloadgo-eee6f9f825596a769ff163e098d2656cbed09d4f.tar.xz
runtime: unify C->Go ABI transitions on arm64
There are several of places that save and restore the C callee-saved registers, the operation is the same everywhere, so this CL defines several macros to do this, which will help reduce code redundancy and unify the operation. This CL also replaced consecutive MOVD instructions with STP and LDP instructions in several places where these macros do not apply. Change-Id: I815f39fe484a9ab9b6bd157dfcbc8ad99c1420fe Reviewed-on: https://go-review.googlesource.com/c/go/+/374397 Trust: Eric Fang <eric.fang@arm.com> Run-TryBot: Eric Fang <eric.fang@arm.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/runtime/sys_linux_arm64.s')
-rw-r--r--src/runtime/sys_linux_arm64.s91
1 files changed, 11 insertions, 80 deletions
diff --git a/src/runtime/sys_linux_arm64.s b/src/runtime/sys_linux_arm64.s
index ca362ed552..36ac014f03 100644
--- a/src/runtime/sys_linux_arm64.s
+++ b/src/runtime/sys_linux_arm64.s
@@ -9,6 +9,7 @@
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
+#include "cgo/abi_arm64.h"
#define AT_FDCWD -100
@@ -444,28 +445,11 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
RET
// Called from c-abi, R0: sig, R1: info, R2: cxt
-TEXT runtime·sigtramp(SB),NOSPLIT,$192
+TEXT runtime·sigtramp(SB),NOSPLIT,$176
// Save callee-save registers in the case of signal forwarding.
// Please refer to https://golang.org/issue/31827 .
- MOVD R19, 8*4(RSP)
- MOVD R20, 8*5(RSP)
- MOVD R21, 8*6(RSP)
- MOVD R22, 8*7(RSP)
- MOVD R23, 8*8(RSP)
- MOVD R24, 8*9(RSP)
- MOVD R25, 8*10(RSP)
- MOVD R26, 8*11(RSP)
- MOVD R27, 8*12(RSP)
- MOVD g, 8*13(RSP)
- MOVD R29, 8*14(RSP)
- FMOVD F8, 8*15(RSP)
- FMOVD F9, 8*16(RSP)
- FMOVD F10, 8*17(RSP)
- FMOVD F11, 8*18(RSP)
- FMOVD F12, 8*19(RSP)
- FMOVD F13, 8*20(RSP)
- FMOVD F14, 8*21(RSP)
- FMOVD F15, 8*22(RSP)
+ SAVE_R19_TO_R28(8*4)
+ SAVE_F8_TO_F15(8*14)
// this might be called in external code context,
// where g is not set.
@@ -481,52 +465,16 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$192
BL (R0)
// Restore callee-save registers.
- MOVD 8*4(RSP), R19
- MOVD 8*5(RSP), R20
- MOVD 8*6(RSP), R21
- MOVD 8*7(RSP), R22
- MOVD 8*8(RSP), R23
- MOVD 8*9(RSP), R24
- MOVD 8*10(RSP), R25
- MOVD 8*11(RSP), R26
- MOVD 8*12(RSP), R27
- MOVD 8*13(RSP), g
- MOVD 8*14(RSP), R29
- FMOVD 8*15(RSP), F8
- FMOVD 8*16(RSP), F9
- FMOVD 8*17(RSP), F10
- FMOVD 8*18(RSP), F11
- FMOVD 8*19(RSP), F12
- FMOVD 8*20(RSP), F13
- FMOVD 8*21(RSP), F14
- FMOVD 8*22(RSP), F15
+ RESTORE_R19_TO_R28(8*4)
+ RESTORE_F8_TO_F15(8*14)
RET
// Called from c-abi, R0: sig, R1: info, R2: cxt
-TEXT runtime·sigprofNonGoWrapper<>(SB),NOSPLIT,$192
- // TODO(eric): In multiple places we need to save and restore the
- // callee-saved registers, we can define a macro for this.
+TEXT runtime·sigprofNonGoWrapper<>(SB),NOSPLIT,$176
// Save callee-save registers because it's a callback from c code.
- MOVD R19, 8*4(RSP)
- MOVD R20, 8*5(RSP)
- MOVD R21, 8*6(RSP)
- MOVD R22, 8*7(RSP)
- MOVD R23, 8*8(RSP)
- MOVD R24, 8*9(RSP)
- MOVD R25, 8*10(RSP)
- MOVD R26, 8*11(RSP)
- MOVD R27, 8*12(RSP)
- MOVD g, 8*13(RSP)
- MOVD R29, 8*14(RSP)
- FMOVD F8, 8*15(RSP)
- FMOVD F9, 8*16(RSP)
- FMOVD F10, 8*17(RSP)
- FMOVD F11, 8*18(RSP)
- FMOVD F12, 8*19(RSP)
- FMOVD F13, 8*20(RSP)
- FMOVD F14, 8*21(RSP)
- FMOVD F15, 8*22(RSP)
+ SAVE_R19_TO_R28(8*4)
+ SAVE_F8_TO_F15(8*14)
MOVW R0, 8(RSP) // sig
MOVD R1, 16(RSP) // info
@@ -534,25 +482,8 @@ TEXT runtime·sigprofNonGoWrapper<>(SB),NOSPLIT,$192
CALL runtime·sigprofNonGo(SB)
// Restore callee-save registers.
- MOVD 8*4(RSP), R19
- MOVD 8*5(RSP), R20
- MOVD 8*6(RSP), R21
- MOVD 8*7(RSP), R22
- MOVD 8*8(RSP), R23
- MOVD 8*9(RSP), R24
- MOVD 8*10(RSP), R25
- MOVD 8*11(RSP), R26
- MOVD 8*12(RSP), R27
- MOVD 8*13(RSP), g
- MOVD 8*14(RSP), R29
- FMOVD 8*15(RSP), F8
- FMOVD 8*16(RSP), F9
- FMOVD 8*17(RSP), F10
- FMOVD 8*18(RSP), F11
- FMOVD 8*19(RSP), F12
- FMOVD 8*20(RSP), F13
- FMOVD 8*21(RSP), F14
- FMOVD 8*22(RSP), F15
+ RESTORE_R19_TO_R28(8*4)
+ RESTORE_F8_TO_F15(8*14)
RET
// Called from c-abi, R0: sig, R1: info, R2: cxt