diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 13:14:23 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 13:14:23 +0000 |
commit | 73df946d56c74384511a194dd01dbe099584fd1a (patch) | |
tree | fd0bcea490dd81327ddfbb31e215439672c9a068 /src/internal/bytealg/indexbyte_riscv64.s | |
parent | Initial commit. (diff) | |
download | golang-1.16-73df946d56c74384511a194dd01dbe099584fd1a.tar.xz golang-1.16-73df946d56c74384511a194dd01dbe099584fd1a.zip |
Adding upstream version 1.16.10.upstream/1.16.10upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/internal/bytealg/indexbyte_riscv64.s | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/internal/bytealg/indexbyte_riscv64.s b/src/internal/bytealg/indexbyte_riscv64.s new file mode 100644 index 0000000..156c303 --- /dev/null +++ b/src/internal/bytealg/indexbyte_riscv64.s @@ -0,0 +1,52 @@ +// 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" + +TEXT ·IndexByte(SB),NOSPLIT,$0-40 + MOV b_base+0(FP), A1 + MOV b_len+8(FP), A2 + MOVBU c+24(FP), A3 // byte to find + MOV A1, A4 // store base for later + ADD A1, A2 // end + ADD $-1, A1 + +loop: + ADD $1, A1 + BEQ A1, A2, notfound + MOVBU (A1), A5 + BNE A3, A5, loop + + SUB A4, A1 // remove base + MOV A1, ret+32(FP) + RET + +notfound: + MOV $-1, A1 + MOV A1, ret+32(FP) + RET + +TEXT ·IndexByteString(SB),NOSPLIT,$0-32 + MOV s_base+0(FP), A1 + MOV s_len+8(FP), A2 + MOVBU c+16(FP), A3 // byte to find + MOV A1, A4 // store base for later + ADD A1, A2 // end + ADD $-1, A1 + +loop: + ADD $1, A1 + BEQ A1, A2, notfound + MOVBU (A1), A5 + BNE A3, A5, loop + + SUB A4, A1 // remove base + MOV A1, ret+24(FP) + RET + +notfound: + MOV $-1, A1 + MOV A1, ret+24(FP) + RET |