runtime: add regABI support in memclr and memmove functions on loong64

Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: I55c78bab5c697ea6c30f9d81f5f8fb75abb3987c
Reviewed-on: https://go-review.googlesource.com/c/go/+/521786
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Run-TryBot: David Chase <drchase@google.com>
Auto-Submit: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
diff --git a/src/runtime/memclr_loong64.s b/src/runtime/memclr_loong64.s
index 7bb6f3d..313e4d4 100644
--- a/src/runtime/memclr_loong64.s
+++ b/src/runtime/memclr_loong64.s
@@ -6,37 +6,39 @@
 #include "textflag.h"
 
 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
-TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16
-	MOVV	ptr+0(FP), R6
-	MOVV	n+8(FP), R7
-	ADDV	R6, R7, R4
+TEXT runtime·memclrNoHeapPointers<ABIInternal>(SB),NOSPLIT,$0-16
+#ifndef GOEXPERIMENT_regabiargs
+	MOVV	ptr+0(FP), R4
+	MOVV	n+8(FP), R5
+#endif
+	ADDV	R4, R5, R6
 
 	// if less than 8 bytes, do one byte at a time
-	SGTU	$8, R7, R8
+	SGTU	$8, R5, R8
 	BNE	R8, out
 
 	// do one byte at a time until 8-aligned
-	AND	$7, R6, R8
+	AND	$7, R4, R8
 	BEQ	R8, words
-	MOVB	R0, (R6)
-	ADDV	$1, R6
+	MOVB	R0, (R4)
+	ADDV	$1, R4
 	JMP	-4(PC)
 
 words:
 	// do 8 bytes at a time if there is room
-	ADDV	$-7, R4, R7
+	ADDV	$-7, R6, R5
 
 	PCALIGN	$16
-	SGTU	R7, R6, R8
+	SGTU	R5, R4, R8
 	BEQ	R8, out
-	MOVV	R0, (R6)
-	ADDV	$8, R6
+	MOVV	R0, (R4)
+	ADDV	$8, R4
 	JMP	-4(PC)
 
 out:
-	BEQ	R6, R4, done
-	MOVB	R0, (R6)
-	ADDV	$1, R6
+	BEQ	R4, R6, done
+	MOVB	R0, (R4)
+	ADDV	$1, R4
 	JMP	-3(PC)
 done:
 	RET
diff --git a/src/runtime/memmove_loong64.s b/src/runtime/memmove_loong64.s
index 0f139bc..5b7aeba 100644
--- a/src/runtime/memmove_loong64.s
+++ b/src/runtime/memmove_loong64.s
@@ -7,10 +7,12 @@
 // See memmove Go doc for important implementation constraints.
 
 // func memmove(to, from unsafe.Pointer, n uintptr)
-TEXT runtime·memmove(SB), NOSPLIT|NOFRAME, $0-24
+TEXT runtime·memmove<ABIInternal>(SB), NOSPLIT|NOFRAME, $0-24
+#ifndef GOEXPERIMENT_regabiargs
 	MOVV	to+0(FP), R4
 	MOVV	from+8(FP), R5
 	MOVV	n+16(FP), R6
+#endif
 	BNE	R6, check
 	RET