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//go:build mips64 || mips64le
6
7#include "go_asm.h"
8#include "textflag.h"
9
10TEXT ·IndexByte(SB),NOSPLIT,$0-40
11	MOVV	b_base+0(FP), R1
12	MOVV	b_len+8(FP), R2
13	MOVBU	c+24(FP), R3	// byte to find
14	MOVV	R1, R4		// store base for later
15	ADDV	R1, R2		// end
16	ADDV	$-1, R1
17
18loop:
19	ADDV	$1, R1
20	BEQ	R1, R2, notfound
21	MOVBU	(R1), R5
22	BNE	R3, R5, loop
23
24	SUBV	R4, R1		// remove base
25	MOVV	R1, ret+32(FP)
26	RET
27
28notfound:
29	MOVV	$-1, R1
30	MOVV	R1, ret+32(FP)
31	RET
32
33TEXT ·IndexByteString(SB),NOSPLIT,$0-32
34	MOVV	s_base+0(FP), R1
35	MOVV	s_len+8(FP), R2
36	MOVBU	c+16(FP), R3	// byte to find
37	MOVV	R1, R4		// store base for later
38	ADDV	R1, R2		// end
39	ADDV	$-1, R1
40
41loop:
42	ADDV	$1, R1
43	BEQ	R1, R2, notfound
44	MOVBU	(R1), R5
45	BNE	R3, R5, loop
46
47	SUBV	R4, R1		// remove base
48	MOVV	R1, ret+24(FP)
49	RET
50
51notfound:
52	MOVV	$-1, R1
53	MOVV	R1, ret+24(FP)
54	RET
55