Text file src/internal/bytealg/count_riscv64.s

     1  // Copyright 2020 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 ¬∑Count<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), X12	// byte to count
    13  #else
    14  	// X10 = b_base
    15  	// X11 = b_len
    16  	// X12 = b_cap (unused)
    17  	// X13 = byte to count (want in X12)
    18  	AND	$0xff, X13, X12
    19  #endif
    20  	MOV	ZERO, X14	// count
    21  	ADD	X10, X11	// end
    22  
    23  loop:
    24  	BEQ	X10, X11, done
    25  	MOVBU	(X10), X15
    26  	ADD	$1, X10
    27  	BNE	X12, X15, loop
    28  	ADD	$1, X14
    29  	JMP	loop
    30  
    31  done:
    32  #ifndef GOEXPERIMENT_regabiargs
    33  	MOV	X14, ret+32(FP)
    34  #else
    35  	MOV	X14, X10
    36  #endif
    37  	RET
    38  
    39  TEXT ¬∑CountString<ABIInternal>(SB),NOSPLIT,$0-32
    40  #ifndef GOEXPERIMENT_regabiargs
    41  	MOV	s_base+0(FP), X10
    42  	MOV	s_len+8(FP), X11
    43  	MOVBU	c+16(FP), X12	// byte to count
    44  #endif
    45  	// X10 = s_base
    46  	// X11 = s_len
    47  	// X12 = byte to count
    48  	AND	$0xff, X12
    49  	MOV	ZERO, X14	// count
    50  	ADD	X10, X11	// end
    51  
    52  loop:
    53  	BEQ	X10, X11, done
    54  	MOVBU	(X10), X15
    55  	ADD	$1, X10
    56  	BNE	X12, X15, loop
    57  	ADD	$1, X14
    58  	JMP	loop
    59  
    60  done:
    61  #ifndef GOEXPERIMENT_regabiargs
    62  	MOV	X14, ret+24(FP)
    63  #else
    64  	MOV	X14, X10
    65  #endif
    66  	RET
    67  

View as plain text