abi_loong64.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2022 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_R22_TO_R31(offset) saves R22 ~ R31 to the stack space
  10. // of ((offset)+0*8)(R3) ~ ((offset)+9*8)(R3).
  11. //
  12. // SAVE_F24_TO_F31(offset) saves F24 ~ F31 to the stack space
  13. // of ((offset)+0*8)(R3) ~ ((offset)+7*8)(R3).
  14. //
  15. // Note: g is R22
  16. #define SAVE_R22_TO_R31(offset) \
  17. MOVV g, ((offset)+(0*8))(R3) \
  18. MOVV R23, ((offset)+(1*8))(R3) \
  19. MOVV R24, ((offset)+(2*8))(R3) \
  20. MOVV R25, ((offset)+(3*8))(R3) \
  21. MOVV R26, ((offset)+(4*8))(R3) \
  22. MOVV R27, ((offset)+(5*8))(R3) \
  23. MOVV R28, ((offset)+(6*8))(R3) \
  24. MOVV R29, ((offset)+(7*8))(R3) \
  25. MOVV R30, ((offset)+(8*8))(R3) \
  26. MOVV R31, ((offset)+(9*8))(R3)
  27. #define SAVE_F24_TO_F31(offset) \
  28. MOVD F24, ((offset)+(0*8))(R3) \
  29. MOVD F25, ((offset)+(1*8))(R3) \
  30. MOVD F26, ((offset)+(2*8))(R3) \
  31. MOVD F27, ((offset)+(3*8))(R3) \
  32. MOVD F28, ((offset)+(4*8))(R3) \
  33. MOVD F29, ((offset)+(5*8))(R3) \
  34. MOVD F30, ((offset)+(6*8))(R3) \
  35. MOVD F31, ((offset)+(7*8))(R3)
  36. #define RESTORE_R22_TO_R31(offset) \
  37. MOVV ((offset)+(0*8))(R3), g \
  38. MOVV ((offset)+(1*8))(R3), R23 \
  39. MOVV ((offset)+(2*8))(R3), R24 \
  40. MOVV ((offset)+(3*8))(R3), R25 \
  41. MOVV ((offset)+(4*8))(R3), R26 \
  42. MOVV ((offset)+(5*8))(R3), R27 \
  43. MOVV ((offset)+(6*8))(R3), R28 \
  44. MOVV ((offset)+(7*8))(R3), R29 \
  45. MOVV ((offset)+(8*8))(R3), R30 \
  46. MOVV ((offset)+(9*8))(R3), R31
  47. #define RESTORE_F24_TO_F31(offset) \
  48. MOVD ((offset)+(0*8))(R3), F24 \
  49. MOVD ((offset)+(1*8))(R3), F25 \
  50. MOVD ((offset)+(2*8))(R3), F26 \
  51. MOVD ((offset)+(3*8))(R3), F27 \
  52. MOVD ((offset)+(4*8))(R3), F28 \
  53. MOVD ((offset)+(5*8))(R3), F29 \
  54. MOVD ((offset)+(6*8))(R3), F30 \
  55. MOVD ((offset)+(7*8))(R3), F31