github.com/mtsmfm/go/src@v0.0.0-20221020090648-44bdcb9f8fde/internal/bytealg/indexbyte_loong64.s (about) 1 // Copyright 2022 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include "go_asm.h" 6 #include "textflag.h" 7 8 TEXT ·IndexByte(SB),NOSPLIT,$0-40 9 MOVV b_base+0(FP), R4 10 MOVV b_len+8(FP), R5 11 MOVBU c+24(FP), R6 // byte to find 12 MOVV R4, R7 // store base for later 13 ADDV R4, R5 // end 14 ADDV $-1, R4 15 16 loop: 17 ADDV $1, R4 18 BEQ R4, R5, notfound 19 MOVBU (R4), R8 20 BNE R6, R8, loop 21 22 SUBV R7, R4 // remove base 23 MOVV R4, ret+32(FP) 24 RET 25 26 notfound: 27 MOVV $-1, R4 28 MOVV R4, ret+32(FP) 29 RET 30 31 TEXT ·IndexByteString(SB),NOSPLIT,$0-32 32 MOVV s_base+0(FP), R4 33 MOVV s_len+8(FP), R5 34 MOVBU c+16(FP), R6 // byte to find 35 MOVV R4, R7 // store base for later 36 ADDV R4, R5 // end 37 ADDV $-1, R4 38 39 loop: 40 ADDV $1, R4 41 BEQ R4, R5, notfound 42 MOVBU (R4), R8 43 BNE R6, R8, loop 44 45 SUBV R7, R4 // remove base 46 MOVV R4, ret+24(FP) 47 RET 48 49 notfound: 50 MOVV $-1, R4 51 MOVV R4, ret+24(FP) 52 RET