summaryrefslogtreecommitdiffstats
path: root/src/internal/bytealg/indexbyte_loong64.s
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:25:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:25:22 +0000
commitf6ad4dcef54c5ce997a4bad5a6d86de229015700 (patch)
tree7cfa4e31ace5c2bd95c72b154d15af494b2bcbef /src/internal/bytealg/indexbyte_loong64.s
parentInitial commit. (diff)
downloadgolang-1.22-f6ad4dcef54c5ce997a4bad5a6d86de229015700.tar.xz
golang-1.22-f6ad4dcef54c5ce997a4bad5a6d86de229015700.zip
Adding upstream version 1.22.1.upstream/1.22.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/internal/bytealg/indexbyte_loong64.s')
-rw-r--r--src/internal/bytealg/indexbyte_loong64.s74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/internal/bytealg/indexbyte_loong64.s b/src/internal/bytealg/indexbyte_loong64.s
new file mode 100644
index 0000000..03e0660
--- /dev/null
+++ b/src/internal/bytealg/indexbyte_loong64.s
@@ -0,0 +1,74 @@
+// Copyright 2022 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"
+
+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), 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
+
+ PCALIGN $16
+loop:
+ ADDV $1, R4
+ BEQ R4, R5, notfound
+ MOVBU (R4), R8
+ BNE R7, R8, loop
+
+ 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<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
+
+ PCALIGN $16
+loop:
+ ADDV $1, R4
+ BEQ R4, R5, notfound
+ MOVBU (R4), R8
+ 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