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

View as plain text