]> Cypherpunks.ru repositories - gostls13.git/blob - src/internal/bytealg/indexbyte_riscv64.s
all: clean up addition of constants in riscv64 assembly
[gostls13.git] / src / internal / bytealg / indexbyte_riscv64.s
1 // Copyright 2019 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         // X10 = b_base
10         // X11 = b_len
11         // X12 = b_cap (unused)
12         // X13 = byte to find
13         AND     $0xff, X13
14         MOV     X10, X12                // store base for later
15         ADD     X10, X11                // end
16         SUB     $1, X10
17
18 loop:
19         ADD     $1, X10
20         BEQ     X10, X11, notfound
21         MOVBU   (X10), X14
22         BNE     X13, X14, loop
23
24         SUB     X12, X10                // remove base
25         RET
26
27 notfound:
28         MOV     $-1, X10
29         RET
30
31 TEXT ·IndexByteString<ABIInternal>(SB),NOSPLIT,$0-32
32         // X10 = b_base
33         // X11 = b_len
34         // X12 = byte to find
35         AND     $0xff, X12
36         MOV     X10, X13                // store base for later
37         ADD     X10, X11                // end
38         SUB     $1, X10
39
40 loop:
41         ADD     $1, X10
42         BEQ     X10, X11, notfound
43         MOVBU   (X10), X14
44         BNE     X12, X14, loop
45
46         SUB     X13, X10                // remove base
47         RET
48
49 notfound:
50         MOV     $-1, X10
51         RET