]> Cypherpunks.ru repositories - gostls13.git/blob - src/runtime/cgo/asm_mipsx.s
a57ae97d7e96a19f0db77ffa026a43ad0fab773b
[gostls13.git] / src / runtime / cgo / asm_mipsx.s
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 mips || mipsle
6
7 #include "textflag.h"
8
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
14         MOVW    R6, (R5)
15         RET
16
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
22         /*
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
26          *  first arg.
27          */
28
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
33 #else
34         SUBU    $(4*14-16), R29 // For soft-float, no FPR.
35 #endif
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
39         MOVW    R16, (4*4)(R29)
40         MOVW    R17, (4*5)(R29)
41         MOVW    R18, (4*6)(R29)
42         MOVW    R19, (4*7)(R29)
43         MOVW    R20, (4*8)(R29)
44         MOVW    R21, (4*9)(R29)
45         MOVW    R22, (4*10)(R29)
46         MOVW    R23, (4*11)(R29)
47         MOVW    g, (4*12)(R29)
48         MOVW    R31, (4*13)(R29)
49 #ifndef GOMIPS_softfloat
50         MOVD    F20, (4*14)(R29)
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)
56 #endif
57         JAL     runtime·load_g(SB)
58
59         JAL     runtime·cgocallback(SB)
60
61         MOVW    (4*4)(R29), R16
62         MOVW    (4*5)(R29), R17
63         MOVW    (4*6)(R29), R18
64         MOVW    (4*7)(R29), R19
65         MOVW    (4*8)(R29), R20
66         MOVW    (4*9)(R29), R21
67         MOVW    (4*10)(R29), R22
68         MOVW    (4*11)(R29), R23
69         MOVW    (4*12)(R29), g
70         MOVW    (4*13)(R29), R31
71 #ifndef GOMIPS_softfloat
72         MOVD    (4*14)(R29), F20
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
78
79         ADDU    $(4*14+8*6-16), R29
80 #else
81         ADDU    $(4*14-16), R29
82 #endif
83         RET