summaryrefslogtreecommitdiffstats
path: root/src/internal/bytealg/equal_riscv64.s
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 13:16:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 13:16:40 +0000
commit47ab3d4a42e9ab51c465c4322d2ec233f6324e6b (patch)
treea61a0ffd83f4a3def4b36e5c8e99630c559aa723 /src/internal/bytealg/equal_riscv64.s
parentInitial commit. (diff)
downloadgolang-1.18-47ab3d4a42e9ab51c465c4322d2ec233f6324e6b.tar.xz
golang-1.18-47ab3d4a42e9ab51c465c4322d2ec233f6324e6b.zip
Adding upstream version 1.18.10.upstream/1.18.10upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/internal/bytealg/equal_riscv64.s')
-rw-r--r--src/internal/bytealg/equal_riscv64.s49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/internal/bytealg/equal_riscv64.s b/src/internal/bytealg/equal_riscv64.s
new file mode 100644
index 0000000..22cb4fa
--- /dev/null
+++ b/src/internal/bytealg/equal_riscv64.s
@@ -0,0 +1,49 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "go_asm.h"
+#include "textflag.h"
+
+#define CTXT S4
+
+// func memequal(a, b unsafe.Pointer, size uintptr) bool
+TEXT runtime·memequal(SB),NOSPLIT|NOFRAME,$0-25
+ MOV a+0(FP), A1
+ MOV b+8(FP), A2
+ BEQ A1, A2, eq
+ MOV size+16(FP), A3
+ ADD A1, A3, A4
+loop:
+ BEQ A1, A4, eq
+
+ MOVBU (A1), A6
+ ADD $1, A1
+ MOVBU (A2), A7
+ ADD $1, A2
+ BEQ A6, A7, loop
+
+ MOVB ZERO, ret+24(FP)
+ RET
+eq:
+ MOV $1, A1
+ MOVB A1, ret+24(FP)
+ RET
+
+// func memequal_varlen(a, b unsafe.Pointer) bool
+TEXT runtime·memequal_varlen(SB),NOSPLIT,$40-17
+ MOV a+0(FP), A1
+ MOV b+8(FP), A2
+ BEQ A1, A2, eq
+ MOV 8(CTXT), A3 // compiler stores size at offset 8 in the closure
+ MOV A1, 8(X2)
+ MOV A2, 16(X2)
+ MOV A3, 24(X2)
+ CALL runtime·memequal(SB)
+ MOVBU 32(X2), A1
+ MOVB A1, ret+16(FP)
+ RET
+eq:
+ MOV $1, A1
+ MOVB A1, ret+16(FP)
+ RET