Text file src/internal/bytealg/indexbyte_loong64.s

     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  #ifndef GOEXPERIMENT_regabiargs
    10  	MOVV	b_base+0(FP), R4
    11  	MOVV	b_len+8(FP), R5
    12  	MOVBU	c+24(FP), R7	// byte to find
    13  #endif
    14  	// R4 = b_base
    15  	// R5 = b_len
    16  	// R6 = b_cap (unused)
    17  	// R7 = byte to find
    18  	AND	$0xff, R7
    19  	MOVV	R4, R6		// store base for later
    20  	ADDV	R4, R5		// end
    21  	ADDV	$-1, R4
    22  
    23  	PCALIGN	$16
    24  loop:
    25  	ADDV	$1, R4
    26  	BEQ	R4, R5, notfound
    27  	MOVBU	(R4), R8
    28  	BNE	R7, R8, loop
    29  
    30  	SUBV	R6, R4		// remove base
    31  #ifndef GOEXPERIMENT_regabiargs
    32  	MOVV	R4, ret+32(FP)
    33  #endif
    34  	RET
    35  
    36  notfound:
    37  	MOVV	$-1, R4
    38  #ifndef GOEXPERIMENT_regabiargs
    39  	MOVV	R4, ret+32(FP)
    40  #endif
    41  	RET
    42  
    43  TEXT ¬∑IndexByteString<ABIInternal>(SB),NOSPLIT,$0-32
    44  #ifndef GOEXPERIMENT_regabiargs
    45  	MOVV	s_base+0(FP), R4
    46  	MOVV	s_len+8(FP), R5
    47  	MOVBU	c+16(FP), R6	// byte to find
    48  #endif
    49  	// R4 = s_base
    50  	// R5 = s_len
    51  	// R6 = byte to find
    52  	MOVV	R4, R7		// store base for later
    53  	ADDV	R4, R5		// end
    54  	ADDV	$-1, R4
    55  
    56  	PCALIGN	$16
    57  loop:
    58  	ADDV	$1, R4
    59  	BEQ	R4, R5, notfound
    60  	MOVBU	(R4), R8
    61  	BNE	R6, R8, loop
    62  
    63  	SUBV	R7, R4		// remove base
    64  #ifndef GOEXPERIMENT_regabiargs
    65  	MOVV	R4, ret+24(FP)
    66  #endif
    67  	RET
    68  
    69  notfound:
    70  	MOVV	$-1, R4
    71  #ifndef GOEXPERIMENT_regabiargs
    72  	MOVV	R4, ret+24(FP)
    73  #endif
    74  	RET
    75  

View as plain text