Black Lives Matter. Support the Equal Justice Initiative.

Text file src/internal/bytealg/indexbyte_riscv64.s

Documentation: internal/bytealg

     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(SB),NOSPLIT,$0-40
     9  	MOV	b_base+0(FP), A1
    10  	MOV	b_len+8(FP), A2
    11  	MOVBU	c+24(FP), A3	// byte to find
    12  	MOV	A1, A4		// store base for later
    13  	ADD	A1, A2		// end
    14  	ADD	$-1, A1
    15  
    16  loop:
    17  	ADD	$1, A1
    18  	BEQ	A1, A2, notfound
    19  	MOVBU	(A1), A5
    20  	BNE	A3, A5, loop
    21  
    22  	SUB	A4, A1		// remove base
    23  	MOV	A1, ret+32(FP)
    24  	RET
    25  
    26  notfound:
    27  	MOV	$-1, A1
    28  	MOV	A1, ret+32(FP)
    29  	RET
    30  
    31  TEXT ·IndexByteString(SB),NOSPLIT,$0-32
    32  	MOV	s_base+0(FP), A1
    33  	MOV	s_len+8(FP), A2
    34  	MOVBU	c+16(FP), A3	// byte to find
    35  	MOV	A1, A4		// store base for later
    36  	ADD	A1, A2		// end
    37  	ADD	$-1, A1
    38  
    39  loop:
    40  	ADD	$1, A1
    41  	BEQ	A1, A2, notfound
    42  	MOVBU	(A1), A5
    43  	BNE	A3, A5, loop
    44  
    45  	SUB	A4, A1		// remove base
    46  	MOV	A1, ret+24(FP)
    47  	RET
    48  
    49  notfound:
    50  	MOV	$-1, A1
    51  	MOV	A1, ret+24(FP)
    52  	RET
    53  

View as plain text