]> Cypherpunks.ru repositories - gostls13.git/blob - src/runtime/cgo/asm_loong64.s
runtime/cgo: store M for C-created thread in pthread key
[gostls13.git] / src / runtime / cgo / asm_loong64.s
1 // Copyright 2022 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 #include "textflag.h"
6
7 // Set the x_crosscall2_ptr C function pointer variable point to crosscall2.
8 // It's such a pointer chain: _crosscall2_ptr -> x_crosscall2_ptr -> crosscall2
9 TEXT ·set_crosscall2(SB),NOSPLIT,$0-0
10         MOVV    _crosscall2_ptr(SB), R5
11         MOVV    $crosscall2(SB), R6
12         MOVV    R6, (R5)
13         RET
14
15 // Called by C code generated by cmd/cgo.
16 // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
17 // Saves C callee-saved registers and calls cgocallback with three arguments.
18 // fn is the PC of a func(a unsafe.Pointer) function.
19 TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
20         /*
21          * We still need to save all callee save register as before, and then
22          * push 3 args for fn (R4, R5, R7), skipping R6.
23          * Also note that at procedure entry in gc world, 8(R29) will be the
24          *  first arg.
25          */
26
27         ADDV    $(-8*22), R3
28         MOVV    R4, (8*1)(R3) // fn unsafe.Pointer
29         MOVV    R5, (8*2)(R3) // a unsafe.Pointer
30         MOVV    R7, (8*3)(R3) // ctxt uintptr
31         MOVV    R23, (8*4)(R3)
32         MOVV    R24, (8*5)(R3)
33         MOVV    R25, (8*6)(R3)
34         MOVV    R26, (8*7)(R3)
35         MOVV    R27, (8*8)(R3)
36         MOVV    R28, (8*9)(R3)
37         MOVV    R29, (8*10)(R3)
38         MOVV    R30, (8*11)(R3)
39         MOVV    g, (8*12)(R3)
40         MOVV    R1, (8*13)(R3)
41         MOVD    F24, (8*14)(R3)
42         MOVD    F25, (8*15)(R3)
43         MOVD    F26, (8*16)(R3)
44         MOVD    F27, (8*17)(R3)
45         MOVD    F28, (8*18)(R3)
46         MOVD    F29, (8*19)(R3)
47         MOVD    F30, (8*20)(R3)
48         MOVD    F31, (8*21)(R3)
49
50         // Initialize Go ABI environment
51         JAL     runtime·load_g(SB)
52
53         JAL     runtime·cgocallback(SB)
54
55         MOVV    (8*4)(R3), R23
56         MOVV    (8*5)(R3), R24
57         MOVV    (8*6)(R3), R25
58         MOVV    (8*7)(R3), R26
59         MOVV    (8*8)(R3), R27
60         MOVV    (8*9)(R3), R28
61         MOVV    (8*10)(R3), R29
62         MOVV    (8*11)(R3), R30
63         MOVV    (8*12)(R3), g
64         MOVV    (8*13)(R3), R1
65         MOVD    (8*14)(R3), F24
66         MOVD    (8*15)(R3), F25
67         MOVD    (8*16)(R3), F26
68         MOVD    (8*17)(R3), F27
69         MOVD    (8*18)(R3), F28
70         MOVD    (8*19)(R3), F29
71         MOVD    (8*20)(R3), F30
72         MOVD    (8*21)(R3), F31
73         ADDV    $(8*22), R3
74
75         RET