1 // Copyright 2016 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.
5 //go:build mips || mipsle
9 // Set the x_crosscall2_ptr C function pointer variable point to crosscall2.
10 // It's such a pointer chain: _crosscall2_ptr -> x_crosscall2_ptr -> crosscall2
11 TEXT ·set_crosscall2(SB),NOSPLIT,$0-0
12 MOVW _crosscall2_ptr(SB), R5
13 MOVW $crosscall2(SB), R6
17 // Called by C code generated by cmd/cgo.
18 // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
19 // Saves C callee-saved registers and calls cgocallback with three arguments.
20 // fn is the PC of a func(a unsafe.Pointer) function.
21 TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
23 * We still need to save all callee save register as before, and then
24 * push 3 args for fn (R4, R5, R7), skipping R6.
25 * Also note that at procedure entry in gc world, 4(R29) will be the
29 // Space for 9 caller-saved GPR + LR + 6 caller-saved FPR.
30 // O32 ABI allows us to smash 16 bytes argument area of caller frame.
31 #ifndef GOMIPS_softfloat
32 SUBU $(4*14+8*6-16), R29
34 SUBU $(4*14-16), R29 // For soft-float, no FPR.
36 MOVW R4, (4*1)(R29) // fn unsafe.Pointer
37 MOVW R5, (4*2)(R29) // a unsafe.Pointer
38 MOVW R7, (4*3)(R29) // ctxt uintptr
49 #ifndef GOMIPS_softfloat
51 MOVD F22, (4*14+8*1)(R29)
52 MOVD F24, (4*14+8*2)(R29)
53 MOVD F26, (4*14+8*3)(R29)
54 MOVD F28, (4*14+8*4)(R29)
55 MOVD F30, (4*14+8*5)(R29)
57 JAL runtime·load_g(SB)
59 JAL runtime·cgocallback(SB)
71 #ifndef GOMIPS_softfloat
73 MOVD (4*14+8*1)(R29), F22
74 MOVD (4*14+8*2)(R29), F24
75 MOVD (4*14+8*3)(R29), F26
76 MOVD (4*14+8*4)(R29), F28
77 MOVD (4*14+8*5)(R29), F30
79 ADDU $(4*14+8*6-16), R29