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<ABIInternal>(SB),NOSPLIT,$0-40
9 // R4 = b_base
10 // R5 = b_len
11 // R6 = b_cap (unused)
12 // R7 = byte to find
13 AND $0xff, R7
14 MOVV R4, R6 // store base for later
15 ADDV R4, R5 // end
16 ADDV $-1, R4
17
18 PCALIGN $16
19 loop:
20 ADDV $1, R4
21 BEQ R4, R5, notfound
22 MOVBU (R4), R8
23 BNE R7, R8, loop
24
25 SUBV R6, R4 // remove base
26 RET
27
28 notfound:
29 MOVV $-1, R4
30 RET
31
32 TEXT ·IndexByteString<ABIInternal>(SB),NOSPLIT,$0-32
33 // R4 = s_base
34 // R5 = s_len
35 // R6 = byte to find
36 MOVV R4, R7 // store base for later
37 ADDV R4, R5 // end
38 ADDV $-1, R4
39
40 PCALIGN $16
41 loop:
42 ADDV $1, R4
43 BEQ R4, R5, notfound
44 MOVBU (R4), R8
45 BNE R6, R8, loop
46
47 SUBV R7, R4 // remove base
48 RET
49
50 notfound:
51 MOVV $-1, R4
52 RET
53
View as plain text