asm_arm.s 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2012 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. // Called by C code generated by cmd/cgo.
  6. // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
  7. // Saves C callee-saved registers and calls cgocallback with three arguments.
  8. // fn is the PC of a func(a unsafe.Pointer) function.
  9. TEXT crosscall2(SB), NOSPLIT|NOFRAME, $0
  10. SUB $(8*9), R13 // Reserve space for the floating point registers.
  11. // The C arguments arrive in R0, R1, R2, and R3. We want to
  12. // pass R0, R1, and R3 to Go, so we push those on the stack.
  13. // Also, save C callee-save registers R4-R12.
  14. MOVM.WP [R0, R1, R3, R4, R5, R6, R7, R8, R9, g, R11, R12], (R13)
  15. // Finally, save the link register R14. This also puts the
  16. // arguments we pushed for cgocallback where they need to be,
  17. // starting at 4(R13).
  18. MOVW.W R14, -4(R13)
  19. // Save VFP callee-saved registers D8-D15 (same as S16-S31).
  20. // Note: We always save these since we target hard-float ABI.
  21. MOVD F8, (13*4+8*1)(R13)
  22. MOVD F9, (13*4+8*2)(R13)
  23. MOVD F10, (13*4+8*3)(R13)
  24. MOVD F11, (13*4+8*4)(R13)
  25. MOVD F12, (13*4+8*5)(R13)
  26. MOVD F13, (13*4+8*6)(R13)
  27. MOVD F14, (13*4+8*7)(R13)
  28. MOVD F15, (13*4+8*8)(R13)
  29. BL runtime·load_g(SB)
  30. // We set up the arguments to cgocallback when saving registers above.
  31. BL runtime·cgocallback(SB)
  32. MOVD (13*4+8*1)(R13), F8
  33. MOVD (13*4+8*2)(R13), F9
  34. MOVD (13*4+8*3)(R13), F10
  35. MOVD (13*4+8*4)(R13), F11
  36. MOVD (13*4+8*5)(R13), F12
  37. MOVD (13*4+8*6)(R13), F13
  38. MOVD (13*4+8*7)(R13), F14
  39. MOVD (13*4+8*8)(R13), F15
  40. MOVW.P 4(R13), R14
  41. MOVM.IAW (R13), [R0, R1, R3, R4, R5, R6, R7, R8, R9, g, R11, R12]
  42. ADD $(8*9), R13
  43. MOVW R14, R15