github.com/primecitizens/pcz/std@v0.2.1/core/bytealg/indexbyte_mips64x.s (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Copyright 2018 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 //go:build pcz && (mips64 || mips64le) 9 10 #include "textflag.h" 11 12 TEXT ·IndexSliceByte(SB),NOSPLIT,$0-40 13 MOVV b_base+0(FP), R1 14 MOVV b_len+8(FP), R2 15 MOVBU c+24(FP), R3 // byte to find 16 MOVV R1, R4 // store base for later 17 ADDV R1, R2 // end 18 ADDV $-1, R1 19 20 loop: 21 ADDV $1, R1 22 BEQ R1, R2, notfound 23 MOVBU (R1), R5 24 BNE R3, R5, loop 25 26 SUBV R4, R1 // remove base 27 MOVV R1, ret+32(FP) 28 RET 29 30 notfound: 31 MOVV $-1, R1 32 MOVV R1, ret+32(FP) 33 RET 34 35 TEXT ·IndexByte(SB),NOSPLIT,$0-32 36 MOVV s_base+0(FP), R1 37 MOVV s_len+8(FP), R2 38 MOVBU c+16(FP), R3 // byte to find 39 MOVV R1, R4 // store base for later 40 ADDV R1, R2 // end 41 ADDV $-1, R1 42 43 loop: 44 ADDV $1, R1 45 BEQ R1, R2, notfound 46 MOVBU (R1), R5 47 BNE R3, R5, loop 48 49 SUBV R4, R1 // remove base 50 MOVV R1, ret+24(FP) 51 RET 52 53 notfound: 54 MOVV $-1, R1 55 MOVV R1, ret+24(FP) 56 RET