Skip to content

Commit 2e77b51

Browse files
abner-chencsophie-zhao
authored andcommitted
runtime/internal/syscall: use ABIInternal for Syscall6 on loong64
Updates #40724 Co-authored-by: Xiaolin Zhao <[email protected]> Change-Id: Ifcc2de35a797fd987a10f564206b14b54d736d1d Reviewed-on: https://go-review.googlesource.com/c/go/+/521789 Auto-Submit: David Chase <[email protected]> Reviewed-by: Meidan Li <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Run-TryBot: David Chase <[email protected]> Reviewed-by: David Chase <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent b3b4424 commit 2e77b51

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

src/runtime/internal/syscall/asm_linux_loong64.s

+40-1
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,64 @@
55
#include "textflag.h"
66

77
// func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr)
8-
TEXT ·Syscall6(SB),NOSPLIT,$0-80
8+
//
9+
// We need to convert to the syscall ABI.
10+
//
11+
// arg | ABIInternal | Syscall
12+
// ---------------------------
13+
// num | R4 | R11
14+
// a1 | R5 | R4
15+
// a2 | R6 | R5
16+
// a3 | R7 | R6
17+
// a4 | R8 | R7
18+
// a5 | R9 | R8
19+
// a6 | R10 | R9
20+
//
21+
// r1 | R4 | R4
22+
// r2 | R5 | R5
23+
// err | R6 | part of R4
24+
TEXT ·Syscall6<ABIInternal>(SB),NOSPLIT,$0-80
25+
#ifdef GOEXPERIMENT_regabiargs
26+
MOVV R4, R11 // syscall entry
27+
MOVV R5, R4
28+
MOVV R6, R5
29+
MOVV R7, R6
30+
MOVV R8, R7
31+
MOVV R9, R8
32+
MOVV R10, R9
33+
#else
934
MOVV num+0(FP), R11 // syscall entry
1035
MOVV a1+8(FP), R4
1136
MOVV a2+16(FP), R5
1237
MOVV a3+24(FP), R6
1338
MOVV a4+32(FP), R7
1439
MOVV a5+40(FP), R8
1540
MOVV a6+48(FP), R9
41+
#endif
1642
SYSCALL
43+
#ifdef GOEXPERIMENT_regabiargs
44+
MOVV R0, R5 // r2 is not used. Always set to 0.
45+
MOVW $-4096, R12
46+
BGEU R12, R4, ok
47+
SUBVU R4, R0, R6 // errno
48+
MOVV $-1, R4 // r1
49+
#else
1750
MOVW $-4096, R12
1851
BGEU R12, R4, ok
1952
MOVV $-1, R12
2053
MOVV R12, r1+56(FP)
2154
MOVV R0, r2+64(FP)
2255
SUBVU R4, R0, R4
2356
MOVV R4, errno+72(FP)
57+
#endif
2458
RET
2559
ok:
60+
#ifdef GOEXPERIMENT_regabiargs
61+
// r1 already in R4
62+
MOVV R0, R6 // errno
63+
#else
2664
MOVV R4, r1+56(FP)
2765
MOVV R0, r2+64(FP) // r2 is not used. Always set to 0.
2866
MOVV R0, errno+72(FP)
67+
#endif
2968
RET

0 commit comments

Comments
 (0)