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.
4
5 //go:build mips64 || mips64le
6 // +build mips64 mips64le
7
8 #include "textflag.h"
9
10 // Called by C code generated by cmd/cgo.
11 // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
12 // Saves C callee-saved registers and calls cgocallback with three arguments.
13 // fn is the PC of a func(a unsafe.Pointer) function.
14 TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
15 /*
16 * We still need to save all callee save register as before, and then
17 * push 3 args for fn (R4, R5, R7), skipping R6.
18 * Also note that at procedure entry in gc world, 8(R29) will be the
19 * first arg.
20 */
21 #ifndef GOMIPS64_softfloat
22 ADDV $(-8*23), R29
23 #else
24 ADDV $(-8*15), R29
25 #endif
26 MOVV R4, (8*1)(R29) // fn unsafe.Pointer
27 MOVV R5, (8*2)(R29) // a unsafe.Pointer
28 MOVV R7, (8*3)(R29) // ctxt uintptr
29 MOVV R16, (8*4)(R29)
30 MOVV R17, (8*5)(R29)
31 MOVV R18, (8*6)(R29)
32 MOVV R19, (8*7)(R29)
33 MOVV R20, (8*8)(R29)
34 MOVV R21, (8*9)(R29)
35 MOVV R22, (8*10)(R29)
36 MOVV R23, (8*11)(R29)
37 MOVV RSB, (8*12)(R29)
38 MOVV g, (8*13)(R29)
39 MOVV R31, (8*14)(R29)
40 #ifndef GOMIPS64_softfloat
41 MOVD F24, (8*15)(R29)
42 MOVD F25, (8*16)(R29)
43 MOVD F26, (8*17)(R29)
44 MOVD F27, (8*18)(R29)
45 MOVD F28, (8*19)(R29)
46 MOVD F29, (8*20)(R29)
47 MOVD F30, (8*21)(R29)
48 MOVD F31, (8*22)(R29)
49 #endif
50 // Initialize Go ABI environment
51 // prepare SB register = PC & 0xffffffff00000000
52 BGEZAL R0, 1(PC)
53 SRLV $32, R31, RSB
54 SLLV $32, RSB
55 JAL runtime·load_g(SB)
56
57 JAL runtime·cgocallback(SB)
58
59 MOVV (8*4)(R29), R16
60 MOVV (8*5)(R29), R17
61 MOVV (8*6)(R29), R18
62 MOVV (8*7)(R29), R19
63 MOVV (8*8)(R29), R20
64 MOVV (8*9)(R29), R21
65 MOVV (8*10)(R29), R22
66 MOVV (8*11)(R29), R23
67 MOVV (8*12)(R29), RSB
68 MOVV (8*13)(R29), g
69 MOVV (8*14)(R29), R31
70 #ifndef GOMIPS64_softfloat
71 MOVD (8*15)(R29), F24
72 MOVD (8*16)(R29), F25
73 MOVD (8*17)(R29), F26
74 MOVD (8*18)(R29), F27
75 MOVD (8*19)(R29), F28
76 MOVD (8*20)(R29), F29
77 MOVD (8*21)(R29), F30
78 MOVD (8*22)(R29), F31
79 ADDV $(8*23), R29
80 #else
81 ADDV $(8*15), R29
82 #endif
83 RET
84
View as plain text