-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change copies `abi_*.h` files and adjusts `#include` compilier directives for Bazel builds. The files `abi_*.h` and `internal/fakecgo/abi_*.h` are the same because Bazel does not support cross-package use of `#include` so we need each one once per package. See also bazel-contrib/rules_go#3636. Closes #144 Signed-off-by: Eliott Bouhana <eliott.bouhana@datadoghq.com>
- Loading branch information
1 parent
f7e63e2
commit 813050e
Showing
12 changed files
with
147 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Copyright 2021 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// Macros for transitioning from the host ABI to Go ABI0. | ||
// | ||
// These save the frame pointer, so in general, functions that use | ||
// these should have zero frame size to suppress the automatic frame | ||
// pointer, though it's harmless to not do this. | ||
|
||
#ifdef GOOS_windows | ||
|
||
// REGS_HOST_TO_ABI0_STACK is the stack bytes used by | ||
// PUSH_REGS_HOST_TO_ABI0. | ||
#define REGS_HOST_TO_ABI0_STACK (28*8 + 8) | ||
|
||
// PUSH_REGS_HOST_TO_ABI0 prepares for transitioning from | ||
// the host ABI to Go ABI0 code. It saves all registers that are | ||
// callee-save in the host ABI and caller-save in Go ABI0 and prepares | ||
// for entry to Go. | ||
// | ||
// Save DI SI BP BX R12 R13 R14 R15 X6-X15 registers and the DF flag. | ||
// Clear the DF flag for the Go ABI. | ||
// MXCSR matches the Go ABI, so we don't have to set that, | ||
// and Go doesn't modify it, so we don't have to save it. | ||
#define PUSH_REGS_HOST_TO_ABI0() \ | ||
PUSHFQ \ | ||
CLD \ | ||
ADJSP $(REGS_HOST_TO_ABI0_STACK - 8) \ | ||
MOVQ DI, (0*0)(SP) \ | ||
MOVQ SI, (1*8)(SP) \ | ||
MOVQ BP, (2*8)(SP) \ | ||
MOVQ BX, (3*8)(SP) \ | ||
MOVQ R12, (4*8)(SP) \ | ||
MOVQ R13, (5*8)(SP) \ | ||
MOVQ R14, (6*8)(SP) \ | ||
MOVQ R15, (7*8)(SP) \ | ||
MOVUPS X6, (8*8)(SP) \ | ||
MOVUPS X7, (10*8)(SP) \ | ||
MOVUPS X8, (12*8)(SP) \ | ||
MOVUPS X9, (14*8)(SP) \ | ||
MOVUPS X10, (16*8)(SP) \ | ||
MOVUPS X11, (18*8)(SP) \ | ||
MOVUPS X12, (20*8)(SP) \ | ||
MOVUPS X13, (22*8)(SP) \ | ||
MOVUPS X14, (24*8)(SP) \ | ||
MOVUPS X15, (26*8)(SP) | ||
|
||
#define POP_REGS_HOST_TO_ABI0() \ | ||
MOVQ (0*0)(SP), DI \ | ||
MOVQ (1*8)(SP), SI \ | ||
MOVQ (2*8)(SP), BP \ | ||
MOVQ (3*8)(SP), BX \ | ||
MOVQ (4*8)(SP), R12 \ | ||
MOVQ (5*8)(SP), R13 \ | ||
MOVQ (6*8)(SP), R14 \ | ||
MOVQ (7*8)(SP), R15 \ | ||
MOVUPS (8*8)(SP), X6 \ | ||
MOVUPS (10*8)(SP), X7 \ | ||
MOVUPS (12*8)(SP), X8 \ | ||
MOVUPS (14*8)(SP), X9 \ | ||
MOVUPS (16*8)(SP), X10 \ | ||
MOVUPS (18*8)(SP), X11 \ | ||
MOVUPS (20*8)(SP), X12 \ | ||
MOVUPS (22*8)(SP), X13 \ | ||
MOVUPS (24*8)(SP), X14 \ | ||
MOVUPS (26*8)(SP), X15 \ | ||
ADJSP $-(REGS_HOST_TO_ABI0_STACK - 8) \ | ||
POPFQ | ||
|
||
#else | ||
// SysV ABI | ||
|
||
#define REGS_HOST_TO_ABI0_STACK (6*8) | ||
|
||
// SysV MXCSR matches the Go ABI, so we don't have to set that, | ||
// and Go doesn't modify it, so we don't have to save it. | ||
// Both SysV and Go require DF to be cleared, so that's already clear. | ||
// The SysV and Go frame pointer conventions are compatible. | ||
#define PUSH_REGS_HOST_TO_ABI0() \ | ||
ADJSP $(REGS_HOST_TO_ABI0_STACK) \ | ||
MOVQ BP, (5*8)(SP) \ | ||
LEAQ (5*8)(SP), BP \ | ||
MOVQ BX, (0*8)(SP) \ | ||
MOVQ R12, (1*8)(SP) \ | ||
MOVQ R13, (2*8)(SP) \ | ||
MOVQ R14, (3*8)(SP) \ | ||
MOVQ R15, (4*8)(SP) | ||
|
||
#define POP_REGS_HOST_TO_ABI0() \ | ||
MOVQ (0*8)(SP), BX \ | ||
MOVQ (1*8)(SP), R12 \ | ||
MOVQ (2*8)(SP), R13 \ | ||
MOVQ (3*8)(SP), R14 \ | ||
MOVQ (4*8)(SP), R15 \ | ||
MOVQ (5*8)(SP), BP \ | ||
ADJSP $-(REGS_HOST_TO_ABI0_STACK) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2021 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// Macros for transitioning from the host ABI to Go ABI0. | ||
// | ||
// These macros save and restore the callee-saved registers | ||
// from the stack, but they don't adjust stack pointer, so | ||
// the user should prepare stack space in advance. | ||
// SAVE_R19_TO_R28(offset) saves R19 ~ R28 to the stack space | ||
// of ((offset)+0*8)(RSP) ~ ((offset)+9*8)(RSP). | ||
// | ||
// SAVE_F8_TO_F15(offset) saves F8 ~ F15 to the stack space | ||
// of ((offset)+0*8)(RSP) ~ ((offset)+7*8)(RSP). | ||
// | ||
// R29 is not saved because Go will save and restore it. | ||
|
||
#define SAVE_R19_TO_R28(offset) \ | ||
STP (R19, R20), ((offset)+0*8)(RSP) \ | ||
STP (R21, R22), ((offset)+2*8)(RSP) \ | ||
STP (R23, R24), ((offset)+4*8)(RSP) \ | ||
STP (R25, R26), ((offset)+6*8)(RSP) \ | ||
STP (R27, g), ((offset)+8*8)(RSP) | ||
#define RESTORE_R19_TO_R28(offset) \ | ||
LDP ((offset)+0*8)(RSP), (R19, R20) \ | ||
LDP ((offset)+2*8)(RSP), (R21, R22) \ | ||
LDP ((offset)+4*8)(RSP), (R23, R24) \ | ||
LDP ((offset)+6*8)(RSP), (R25, R26) \ | ||
LDP ((offset)+8*8)(RSP), (R27, g) /* R28 */ | ||
#define SAVE_F8_TO_F15(offset) \ | ||
FSTPD (F8, F9), ((offset)+0*8)(RSP) \ | ||
FSTPD (F10, F11), ((offset)+2*8)(RSP) \ | ||
FSTPD (F12, F13), ((offset)+4*8)(RSP) \ | ||
FSTPD (F14, F15), ((offset)+6*8)(RSP) | ||
#define RESTORE_F8_TO_F15(offset) \ | ||
FLDPD ((offset)+0*8)(RSP), (F8, F9) \ | ||
FLDPD ((offset)+2*8)(RSP), (F10, F11) \ | ||
FLDPD ((offset)+4*8)(RSP), (F12, F13) \ | ||
FLDPD ((offset)+6*8)(RSP), (F14, F15) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters