]> Cypherpunks.ru repositories - gostls13.git/blob - src/runtime/cgo/asm_mips64x.s
runtime/cgo: store M for C-created thread in pthread key
[gostls13.git] / src / runtime / cgo / asm_mips64x.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 mips64 || mips64le
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         MOVV    _crosscall2_ptr(SB), R5
13         MOVV    $crosscall2(SB), R6
14         MOVV    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, 8(R29) will be the
26          *  first arg.
27          */
28 #ifndef GOMIPS64_softfloat
29         ADDV    $(-8*23), R29
30 #else
31         ADDV    $(-8*15), R29
32 #endif
33         MOVV    R4, (8*1)(R29) // fn unsafe.Pointer
34         MOVV    R5, (8*2)(R29) // a unsafe.Pointer
35         MOVV    R7, (8*3)(R29) // ctxt uintptr
36         MOVV    R16, (8*4)(R29)
37         MOVV    R17, (8*5)(R29)
38         MOVV    R18, (8*6)(R29)
39         MOVV    R19, (8*7)(R29)
40         MOVV    R20, (8*8)(R29)
41         MOVV    R21, (8*9)(R29)
42         MOVV    R22, (8*10)(R29)
43         MOVV    R23, (8*11)(R29)
44         MOVV    RSB, (8*12)(R29)
45         MOVV    g, (8*13)(R29)
46         MOVV    R31, (8*14)(R29)
47 #ifndef GOMIPS64_softfloat
48         MOVD    F24, (8*15)(R29)
49         MOVD    F25, (8*16)(R29)
50         MOVD    F26, (8*17)(R29)
51         MOVD    F27, (8*18)(R29)
52         MOVD    F28, (8*19)(R29)
53         MOVD    F29, (8*20)(R29)
54         MOVD    F30, (8*21)(R29)
55         MOVD    F31, (8*22)(R29)
56 #endif
57         // Initialize Go ABI environment
58         // prepare SB register = PC & 0xffffffff00000000
59         BGEZAL  R0, 1(PC)
60         SRLV    $32, R31, RSB
61         SLLV    $32, RSB
62         JAL     runtime·load_g(SB)
63
64         JAL     runtime·cgocallback(SB)
65
66         MOVV    (8*4)(R29), R16
67         MOVV    (8*5)(R29), R17
68         MOVV    (8*6)(R29), R18
69         MOVV    (8*7)(R29), R19
70         MOVV    (8*8)(R29), R20
71         MOVV    (8*9)(R29), R21
72         MOVV    (8*10)(R29), R22
73         MOVV    (8*11)(R29), R23
74         MOVV    (8*12)(R29), RSB
75         MOVV    (8*13)(R29), g
76         MOVV    (8*14)(R29), R31
77 #ifndef GOMIPS64_softfloat
78         MOVD    (8*15)(R29), F24
79         MOVD    (8*16)(R29), F25
80         MOVD    (8*17)(R29), F26
81         MOVD    (8*18)(R29), F27
82         MOVD    (8*19)(R29), F28
83         MOVD    (8*20)(R29), F29
84         MOVD    (8*21)(R29), F30
85         MOVD    (8*22)(R29), F31
86         ADDV    $(8*23), R29
87 #else
88         ADDV    $(8*15), R29
89 #endif
90         RET