abi_arm64.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2021 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Macros for transitioning from the host ABI to Go ABI0.
  5. //
  6. // These macros save and restore the callee-saved registers
  7. // from the stack, but they don't adjust stack pointer, so
  8. // the user should prepare stack space in advance.
  9. // SAVE_R19_TO_R28(offset) saves R19 ~ R28 to the stack space
  10. // of ((offset)+0*8)(RSP) ~ ((offset)+9*8)(RSP).
  11. //
  12. // SAVE_F8_TO_F15(offset) saves F8 ~ F15 to the stack space
  13. // of ((offset)+0*8)(RSP) ~ ((offset)+7*8)(RSP).
  14. //
  15. // R29 is not saved because Go will save and restore it.
  16. #define SAVE_R19_TO_R28(offset) \
  17. STP (R19, R20), ((offset)+0*8)(RSP) \
  18. STP (R21, R22), ((offset)+2*8)(RSP) \
  19. STP (R23, R24), ((offset)+4*8)(RSP) \
  20. STP (R25, R26), ((offset)+6*8)(RSP) \
  21. STP (R27, g), ((offset)+8*8)(RSP)
  22. #define RESTORE_R19_TO_R28(offset) \
  23. LDP ((offset)+0*8)(RSP), (R19, R20) \
  24. LDP ((offset)+2*8)(RSP), (R21, R22) \
  25. LDP ((offset)+4*8)(RSP), (R23, R24) \
  26. LDP ((offset)+6*8)(RSP), (R25, R26) \
  27. LDP ((offset)+8*8)(RSP), (R27, g) /* R28 */
  28. #define SAVE_F8_TO_F15(offset) \
  29. FSTPD (F8, F9), ((offset)+0*8)(RSP) \
  30. FSTPD (F10, F11), ((offset)+2*8)(RSP) \
  31. FSTPD (F12, F13), ((offset)+4*8)(RSP) \
  32. FSTPD (F14, F15), ((offset)+6*8)(RSP)
  33. #define RESTORE_F8_TO_F15(offset) \
  34. FLDPD ((offset)+0*8)(RSP), (F8, F9) \
  35. FLDPD ((offset)+2*8)(RSP), (F10, F11) \
  36. FLDPD ((offset)+4*8)(RSP), (F12, F13) \
  37. FLDPD ((offset)+6*8)(RSP), (F14, F15)