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 .file "gcc_loong64.S"
6
7 /*
8 * void crosscall1(void (*fn)(void), void (*setg_gcc)(void *g), void *g)
9 *
10 * Calling into the gc tool chain, where all registers are caller save.
11 * Called from standard lp64d ABI, where $r1, $r3, $r23-$r30, and $f24-$f31
12 * are callee-save, so they must be saved explicitly, along with $r1 (LR).
13 */
14 .globl crosscall1
15 crosscall1:
16 addi.d $r3, $r3, -160
17 st.d $r1, $r3, 0
18 st.d $r23, $r3, 8
19 st.d $r24, $r3, 16
20 st.d $r25, $r3, 24
21 st.d $r26, $r3, 32
22 st.d $r27, $r3, 40
23 st.d $r28, $r3, 48
24 st.d $r29, $r3, 56
25 st.d $r30, $r3, 64
26 st.d $r2, $r3, 72
27 st.d $r22, $r3, 80
28 fst.d $f24, $r3, 88
29 fst.d $f25, $r3, 96
30 fst.d $f26, $r3, 104
31 fst.d $f27, $r3, 112
32 fst.d $f28, $r3, 120
33 fst.d $f29, $r3, 128
34 fst.d $f30, $r3, 136
35 fst.d $f31, $r3, 144
36
37 move $r18, $r4 // save R4
38 move $r19, $r6
39 jirl $r1, $r5, 0 // call setg_gcc (clobbers R4)
40 jirl $r1, $r18, 0 // call fn
41
42 ld.d $r23, $r3, 8
43 ld.d $r24, $r3, 16
44 ld.d $r25, $r3, 24
45 ld.d $r26, $r3, 32
46 ld.d $r27, $r3, 40
47 ld.d $r28, $r3, 48
48 ld.d $r29, $r3, 56
49 ld.d $r30, $r3, 64
50 ld.d $r2, $r3, 72
51 ld.d $r22, $r3, 80
52 fld.d $f24, $r3, 88
53 fld.d $f25, $r3, 96
54 fld.d $f26, $r3, 104
55 fld.d $f27, $r3, 112
56 fld.d $f28, $r3, 120
57 fld.d $f29, $r3, 128
58 fld.d $f30, $r3, 136
59 fld.d $f31, $r3, 144
60 ld.d $r1, $r3, 0
61 addi.d $r3, $r3, 160
62 jirl $r0, $r1, 0
63
64
65 #ifdef __ELF__
66 .section .note.GNU-stack,"",%progbits
67 #endif
68
View as plain text