summaryrefslogtreecommitdiffstats
path: root/contrib/go/_std_1.23/src/internal/bytealg/indexbyte_loong64.s
blob: c9591b3cdaa569006726398088ffcde0e4fa8c99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "go_asm.h"
#include "textflag.h"

TEXT ·IndexByte<ABIInternal>(SB),NOSPLIT,$0-40
	// R4 = b_base
	// R5 = b_len
	// R6 = b_cap (unused)
	// R7 = byte to find
	AND	$0xff, R7
	MOVV	R4, R6		// store base for later
	ADDV	R4, R5		// end
	ADDV	$-1, R4

	PCALIGN	$16
loop:
	ADDV	$1, R4
	BEQ	R4, R5, notfound
	MOVBU	(R4), R8
	BNE	R7, R8, loop

	SUBV	R6, R4		// remove base
	RET

notfound:
	MOVV	$-1, R4
	RET

TEXT ·IndexByteString<ABIInternal>(SB),NOSPLIT,$0-32
	// R4 = s_base
	// R5 = s_len
	// R6 = byte to find
	MOVV	R4, R7		// store base for later
	ADDV	R4, R5		// end
	ADDV	$-1, R4

	PCALIGN	$16
loop:
	ADDV	$1, R4
	BEQ	R4, R5, notfound
	MOVBU	(R4), R8
	BNE	R6, R8, loop

	SUBV	R7, R4		// remove base
	RET

notfound:
	MOVV	$-1, R4
	RET