github.com/twelsh-aw/go/src@v0.0.0-20230516233729-a56fe86a7c81/internal/bytealg/indexbyte_loong64.s (about)

     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(SB),NOSPLIT,$0-40
     9  	MOVV	b_base+0(FP), R4
    10  	MOVV	b_len+8(FP), R5
    11  	MOVBU	c+24(FP), R6	// byte to find
    12  	MOVV	R4, R7		// store base for later
    13  	ADDV	R4, R5		// end
    14  	ADDV	$-1, R4
    15  
    16  	PCALIGN	$16
    17  loop:
    18  	ADDV	$1, R4
    19  	BEQ	R4, R5, notfound
    20  	MOVBU	(R4), R8
    21  	BNE	R6, R8, loop
    22  
    23  	SUBV	R7, R4		// remove base
    24  	MOVV	R4, ret+32(FP)
    25  	RET
    26  
    27  notfound:
    28  	MOVV	$-1, R4
    29  	MOVV	R4, ret+32(FP)
    30  	RET
    31  
    32  TEXT ·IndexByteString(SB),NOSPLIT,$0-32
    33  	MOVV	s_base+0(FP), R4
    34  	MOVV	s_len+8(FP), R5
    35  	MOVBU	c+16(FP), 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  	MOVV	R4, ret+24(FP)
    49  	RET
    50  
    51  notfound:
    52  	MOVV	$-1, R4
    53  	MOVV	R4, ret+24(FP)
    54  	RET