Skip to content

Commit e8126bc

Browse files
committed
runtime/cgo: save and restore R31 for crosscall1 on loong64
According to the Loong64 procedure call standard [1], R31 is a static register and therefore needs to be saved and restored. Also, the R2 (thread pointer) register has been removed here, as it is not involved in allocation. [1]: https://github.com/loongson/la-abi-specs/blob/release/lapcs.adoc Change-Id: I02e5d4bedf131e491f1a262aa3cbc0896cbc9488 Reviewed-on: https://go-review.googlesource.com/c/go/+/700817 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: sophie zhao <[email protected]> Reviewed-by: Meidan Li <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent d767064 commit e8126bc

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/runtime/cgo/gcc_loong64.S

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88
* void crosscall1(void (*fn)(void), void (*setg_gcc)(void *g), void *g)
99
*
1010
* 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
11+
* Called from standard lp64d ABI, where $r1, $r3, $r22-$r31, and $f24-$f31
1212
* are callee-save, so they must be saved explicitly, along with $r1 (LR).
1313
*/
1414
.globl crosscall1
1515
crosscall1:
1616
addi.d $r3, $r3, -160
1717
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
18+
st.d $r22, $r3, 8
19+
st.d $r23, $r3, 16
20+
st.d $r24, $r3, 24
21+
st.d $r25, $r3, 32
22+
st.d $r26, $r3, 40
23+
st.d $r27, $r3, 48
24+
st.d $r28, $r3, 56
25+
st.d $r29, $r3, 64
26+
st.d $r30, $r3, 72
27+
st.d $r31, $r3, 80
2828
fst.d $f24, $r3, 88
2929
fst.d $f25, $r3, 96
3030
fst.d $f26, $r3, 104
@@ -40,16 +40,16 @@ crosscall1:
4040
jirl $r1, $r5, 0 // call setg_gcc (clobbers R4)
4141
jirl $r1, $r23, 0 // call fn
4242

43-
ld.d $r23, $r3, 8
44-
ld.d $r24, $r3, 16
45-
ld.d $r25, $r3, 24
46-
ld.d $r26, $r3, 32
47-
ld.d $r27, $r3, 40
48-
ld.d $r28, $r3, 48
49-
ld.d $r29, $r3, 56
50-
ld.d $r30, $r3, 64
51-
ld.d $r2, $r3, 72
52-
ld.d $r22, $r3, 80
43+
ld.d $r22, $r3, 8
44+
ld.d $r23, $r3, 16
45+
ld.d $r24, $r3, 24
46+
ld.d $r25, $r3, 32
47+
ld.d $r26, $r3, 40
48+
ld.d $r27, $r3, 48
49+
ld.d $r28, $r3, 56
50+
ld.d $r29, $r3, 64
51+
ld.d $r30, $r3, 72
52+
ld.d $r31, $r3, 80
5353
fld.d $f24, $r3, 88
5454
fld.d $f25, $r3, 96
5555
fld.d $f26, $r3, 104

0 commit comments

Comments
 (0)