asm_loong64.s 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include "textflag.h"
  5. #include "abi_loong64.h"
  6. // Called by C code generated by cmd/cgo.
  7. // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
  8. // Saves C callee-saved registers and calls cgocallback with three arguments.
  9. // fn is the PC of a func(a unsafe.Pointer) function.
  10. TEXT crosscall2(SB), NOSPLIT|NOFRAME, $0
  11. /*
  12. * We still need to save all callee save register as before, and then
  13. * push 3 args for fn (R4, R5, R7), skipping R6.
  14. * Also note that at procedure entry in gc world, 8(R29) will be the
  15. * first arg.
  16. */
  17. ADDV $(-23*8), R3
  18. MOVV R4, (1*8)(R3) // fn unsafe.Pointer
  19. MOVV R5, (2*8)(R3) // a unsafe.Pointer
  20. MOVV R7, (3*8)(R3) // ctxt uintptr
  21. SAVE_R22_TO_R31((4*8))
  22. SAVE_F24_TO_F31((14*8))
  23. MOVV R1, (22*8)(R3)
  24. // Initialize Go ABI environment
  25. JAL runtime·load_g(SB)
  26. JAL runtime·cgocallback(SB)
  27. RESTORE_R22_TO_R31((4*8))
  28. RESTORE_F24_TO_F31((14*8))
  29. MOVV (22*8)(R3), R1
  30. ADDV $(23*8), R3
  31. RET