github.com/icodeface/tls@v0.0.0-20230910023335-34df9250cd12/internal/bytealg/indexbyte_arm.s (about) 1 // Copyright 2018 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-20 9 MOVW b_base+0(FP), R0 10 MOVW b_len+4(FP), R1 11 MOVBU c+12(FP), R2 // byte to find 12 MOVW R0, R4 // store base for later 13 ADD R0, R1 // end 14 15 _loop: 16 CMP R0, R1 17 B.EQ _notfound 18 MOVBU.P 1(R0), R3 19 CMP R2, R3 20 B.NE _loop 21 22 SUB $1, R0 // R0 will be one beyond the position we want 23 SUB R4, R0 // remove base 24 MOVW R0, ret+16(FP) 25 RET 26 27 _notfound: 28 MOVW $-1, R0 29 MOVW R0, ret+16(FP) 30 RET 31 32 TEXT ·IndexByteString(SB),NOSPLIT,$0-16 33 MOVW s_base+0(FP), R0 34 MOVW s_len+4(FP), R1 35 MOVBU c+8(FP), R2 // byte to find 36 MOVW R0, R4 // store base for later 37 ADD R0, R1 // end 38 39 _sib_loop: 40 CMP R0, R1 41 B.EQ _sib_notfound 42 MOVBU.P 1(R0), R3 43 CMP R2, R3 44 B.NE _sib_loop 45 46 SUB $1, R0 // R0 will be one beyond the position we want 47 SUB R4, R0 // remove base 48 MOVW R0, ret+12(FP) 49 RET 50 51 _sib_notfound: 52 MOVW $-1, R0 53 MOVW R0, ret+12(FP) 54 RET