github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/internal/bytealg/indexbyte_mipsx.s (about)

     1  // Copyright 2018 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  //go:build mips || mipsle
     6  // +build mips mipsle
     7  
     8  #include "go_asm.h"
     9  #include "textflag.h"
    10  
    11  TEXT ·IndexByte(SB),NOSPLIT,$0-20
    12  	MOVW	b_base+0(FP), R1
    13  	MOVW	b_len+4(FP), R2
    14  	MOVBU	c+12(FP), R3	// byte to find
    15  	ADDU	$1, R1, R4	// store base+1 for later
    16  	ADDU	R1, R2	// end
    17  
    18  loop:
    19  	BEQ	R1, R2, notfound
    20  	MOVBU	(R1), R5
    21  	ADDU	$1, R1
    22  	BNE	R3, R5, loop
    23  
    24  	SUBU	R4, R1	// R1 will be one beyond the position we want so remove (base+1)
    25  	MOVW	R1, ret+16(FP)
    26  	RET
    27  
    28  notfound:
    29  	MOVW	$-1, R1
    30  	MOVW	R1, ret+16(FP)
    31  	RET
    32  
    33  TEXT ·IndexByteString(SB),NOSPLIT,$0-16
    34  	MOVW	s_base+0(FP), R1
    35  	MOVW	s_len+4(FP), R2
    36  	MOVBU	c+8(FP), R3	// byte to find
    37  	ADDU	$1, R1, R4	// store base+1 for later
    38  	ADDU	R1, R2	// end
    39  
    40  loop:
    41  	BEQ	R1, R2, notfound
    42  	MOVBU	(R1), R5
    43  	ADDU	$1, R1
    44  	BNE	R3, R5, loop
    45  
    46  	SUBU	R4, R1	// remove (base+1)
    47  	MOVW	R1, ret+12(FP)
    48  	RET
    49  
    50  notfound:
    51  	MOVW	$-1, R1
    52  	MOVW	R1, ret+12(FP)
    53  	RET