aboutsummaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authorGuoqi Chen <chenguoqi@loongson.cn>2023-08-16 08:55:13 +0800
committerGopher Robot <gobot@golang.org>2023-11-21 19:21:41 +0000
commit1052d09dd768d658bda2aa99d13ce4c032f09dc0 (patch)
tree2bc6796757c714a72fa911ee3a3a0b2515abebaa /src/internal
parent4e6bbbe61f554dbd9ed78fcd55ff46fe59736785 (diff)
downloadgo-1052d09dd768d658bda2aa99d13ce4c032f09dc0.tar.xz
internal/bytealg: add regABI support in bytealg functions on loong64
Update #40724 Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn> Change-Id: I4a7392afd7238d44e7d09aaca7e0d733649926ac Reviewed-on: https://go-review.googlesource.com/c/go/+/521785 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Meidan Li <limeidan@loongson.cn> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: David Chase <drchase@google.com>
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/bytealg/compare_loong64.s95
-rw-r--r--src/internal/bytealg/equal_loong64.s21
-rw-r--r--src/internal/bytealg/indexbyte_loong64.s32
3 files changed, 101 insertions, 47 deletions
diff --git a/src/internal/bytealg/compare_loong64.s b/src/internal/bytealg/compare_loong64.s
index c89c5a9256..311449ab18 100644
--- a/src/internal/bytealg/compare_loong64.s
+++ b/src/internal/bytealg/compare_loong64.s
@@ -5,83 +5,102 @@
#include "go_asm.h"
#include "textflag.h"
-TEXT ·Compare(SB),NOSPLIT,$0-56
- MOVV a_base+0(FP), R6
- MOVV b_base+24(FP), R7
- MOVV a_len+8(FP), R4
- MOVV b_len+32(FP), R5
+TEXT ·Compare<ABIInternal>(SB),NOSPLIT,$0-56
+#ifndef GOEXPERIMENT_regabiargs
+ MOVV a_base+0(FP), R4
+ MOVV a_len+8(FP), R5
+ MOVV b_base+24(FP), R6
+ MOVV b_len+32(FP), R7
MOVV $ret+48(FP), R13
+#else
+ // R4 = a_base
+ // R5 = a_len
+ // R6 = a_cap (unused)
+ // R7 = b_base (want in R6)
+ // R8 = b_len (want in R7)
+ // R9 = b_cap (unused)
+ MOVV R7, R6
+ MOVV R8, R7
+#endif
JMP cmpbody<>(SB)
-TEXT runtime·cmpstring(SB),NOSPLIT,$0-40
- MOVV a_base+0(FP), R6
- MOVV b_base+16(FP), R7
- MOVV a_len+8(FP), R4
- MOVV b_len+24(FP), R5
+TEXT runtime·cmpstring<ABIInternal>(SB),NOSPLIT,$0-40
+#ifndef GOEXPERIMENT_regabiargs
+ MOVV a_base+0(FP), R4
+ MOVV b_base+16(FP), R6
+ MOVV a_len+8(FP), R5
+ MOVV b_len+24(FP), R7
MOVV $ret+32(FP), R13
+#endif
+ // R4 = a_base
+ // R5 = a_len
+ // R6 = b_base
+ // R7 = b_len
JMP cmpbody<>(SB)
// On entry:
-// R4 length of a
-// R5 length of b
-// R6 points to the start of a
-// R7 points to the start of b
+// R5 length of a
+// R7 length of b
+// R4 points to the start of a
+// R6 points to the start of b
// R13 points to the return value (-1/0/1)
TEXT cmpbody<>(SB),NOSPLIT|NOFRAME,$0
- BEQ R6, R7, samebytes // same start of a and b
+ BEQ R4, R6, samebytes // same start of a and b
- SGTU R4, R5, R9
+ SGTU R5, R7, R9
BNE R0, R9, r2_lt_r1
- MOVV R4, R14
+ MOVV R5, R14
JMP entry
r2_lt_r1:
- MOVV R5, R14 // R14 is min(R4, R5)
+ MOVV R7, R14 // R14 is min(R4, R5)
entry:
- ADDV R6, R14, R12 // R6 start of a, R14 end of a
- BEQ R6, R12, samebytes // length is 0
+ ADDV R4, R14, R12 // R6 start of a, R14 end of a
+ BEQ R4, R12, samebytes // length is 0
SRLV $4, R14 // R14 is number of chunks
BEQ R0, R14, byte_loop
// make sure both a and b are aligned.
- OR R6, R7, R15
+ OR R4, R6, R15
AND $7, R15
BNE R0, R15, byte_loop
PCALIGN $16
chunk16_loop:
BEQ R0, R14, byte_loop
- MOVV (R6), R8
- MOVV (R7), R9
+ MOVV (R4), R8
+ MOVV (R6), R9
BNE R8, R9, byte_loop
- MOVV 8(R6), R16
- MOVV 8(R7), R17
+ MOVV 8(R4), R16
+ MOVV 8(R6), R17
+ ADDV $16, R4
ADDV $16, R6
- ADDV $16, R7
SUBVU $1, R14
BEQ R16, R17, chunk16_loop
+ SUBV $8, R4
SUBV $8, R6
- SUBV $8, R7
byte_loop:
- BEQ R6, R12, samebytes
- MOVBU (R6), R8
+ BEQ R4, R12, samebytes
+ MOVBU (R4), R8
+ ADDVU $1, R4
+ MOVBU (R6), R9
ADDVU $1, R6
- MOVBU (R7), R9
- ADDVU $1, R7
BEQ R8, R9, byte_loop
byte_cmp:
- SGTU R8, R9, R12 // R12 = 1 if (R8 > R9)
- BNE R0, R12, ret
- MOVV $-1, R12
+ SGTU R8, R9, R4 // R12 = 1 if (R8 > R9)
+ BNE R0, R4, ret
+ MOVV $-1, R4
JMP ret
samebytes:
- SGTU R4, R5, R8
- SGTU R5, R4, R9
- SUBV R9, R8, R12
+ SGTU R5, R7, R8
+ SGTU R7, R5, R9
+ SUBV R9, R8, R4
ret:
- MOVV R12, (R13)
+#ifndef GOEXPERIMENT_regabiargs
+ MOVV R4, (R13)
+#endif
RET
diff --git a/src/internal/bytealg/equal_loong64.s b/src/internal/bytealg/equal_loong64.s
index ba2a5578c3..a3ad5c1b35 100644
--- a/src/internal/bytealg/equal_loong64.s
+++ b/src/internal/bytealg/equal_loong64.s
@@ -8,17 +8,21 @@
#define REGCTXT R29
// memequal(a, b unsafe.Pointer, size uintptr) bool
-TEXT runtime·memequal(SB),NOSPLIT|NOFRAME,$0-25
+TEXT runtime·memequal<ABIInternal>(SB),NOSPLIT|NOFRAME,$0-25
+#ifndef GOEXPERIMENT_regabiargs
MOVV a+0(FP), R4
MOVV b+8(FP), R5
- BEQ R4, R5, eq
MOVV size+16(FP), R6
+#endif
+ BEQ R4, R5, eq
ADDV R4, R6, R7
PCALIGN $16
loop:
BNE R4, R7, test
MOVV $1, R4
+#ifndef GOEXPERIMENT_regabiargs
MOVB R4, ret+24(FP)
+#endif
RET
test:
MOVBU (R4), R9
@@ -27,17 +31,24 @@ test:
ADDV $1, R5
BEQ R9, R10, loop
+ MOVB R0, R4
+#ifndef GOEXPERIMENT_regabiargs
MOVB R0, ret+24(FP)
+#endif
RET
eq:
MOVV $1, R4
+#ifndef GOEXPERIMENT_regabiargs
MOVB R4, ret+24(FP)
+#endif
RET
// memequal_varlen(a, b unsafe.Pointer) bool
-TEXT runtime·memequal_varlen(SB),NOSPLIT,$40-17
+TEXT runtime·memequal_varlen<ABIInternal>(SB),NOSPLIT,$40-17
+#ifndef GOEXPERIMENT_regabiargs
MOVV a+0(FP), R4
MOVV b+8(FP), R5
+#endif
BEQ R4, R5, eq
MOVV 8(REGCTXT), R6 // compiler stores size at offset 8 in the closure
MOVV R4, 8(R3)
@@ -45,9 +56,13 @@ TEXT runtime·memequal_varlen(SB),NOSPLIT,$40-17
MOVV R6, 24(R3)
JAL runtime·memequal(SB)
MOVBU 32(R3), R4
+#ifndef GOEXPERIMENT_regabiargs
MOVB R4, ret+16(FP)
+#endif
RET
eq:
MOVV $1, R4
+#ifndef GOEXPERIMENT_regabiargs
MOVB R4, ret+16(FP)
+#endif
RET
diff --git a/src/internal/bytealg/indexbyte_loong64.s b/src/internal/bytealg/indexbyte_loong64.s
index 604970549f..03e0660973 100644
--- a/src/internal/bytealg/indexbyte_loong64.s
+++ b/src/internal/bytealg/indexbyte_loong64.s
@@ -5,11 +5,18 @@
#include "go_asm.h"
#include "textflag.h"
-TEXT ·IndexByte(SB),NOSPLIT,$0-40
+TEXT ·IndexByte<ABIInternal>(SB),NOSPLIT,$0-40
+#ifndef GOEXPERIMENT_regabiargs
MOVV b_base+0(FP), R4
MOVV b_len+8(FP), R5
- MOVBU c+24(FP), R6 // byte to find
- MOVV R4, R7 // store base for later
+ MOVBU c+24(FP), R7 // byte to find
+#endif
+ // R4 = b_base
+ // R5 = b_len
+ // R6 = b_cap (unused)
+ // R7 = byte to find
+ AND $0xff, R7
+ MOVV R4, R6 // store base for later
ADDV R4, R5 // end
ADDV $-1, R4
@@ -18,21 +25,30 @@ loop:
ADDV $1, R4
BEQ R4, R5, notfound
MOVBU (R4), R8
- BNE R6, R8, loop
+ BNE R7, R8, loop
- SUBV R7, R4 // remove base
+ SUBV R6, R4 // remove base
+#ifndef GOEXPERIMENT_regabiargs
MOVV R4, ret+32(FP)
+#endif
RET
notfound:
MOVV $-1, R4
+#ifndef GOEXPERIMENT_regabiargs
MOVV R4, ret+32(FP)
+#endif
RET
-TEXT ·IndexByteString(SB),NOSPLIT,$0-32
+TEXT ·IndexByteString<ABIInternal>(SB),NOSPLIT,$0-32
+#ifndef GOEXPERIMENT_regabiargs
MOVV s_base+0(FP), R4
MOVV s_len+8(FP), R5
MOVBU c+16(FP), R6 // byte to find
+#endif
+ // R4 = s_base
+ // R5 = s_len
+ // R6 = byte to find
MOVV R4, R7 // store base for later
ADDV R4, R5 // end
ADDV $-1, R4
@@ -45,10 +61,14 @@ loop:
BNE R6, R8, loop
SUBV R7, R4 // remove base
+#ifndef GOEXPERIMENT_regabiargs
MOVV R4, ret+24(FP)
+#endif
RET
notfound:
MOVV $-1, R4
+#ifndef GOEXPERIMENT_regabiargs
MOVV R4, ret+24(FP)
+#endif
RET