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  	// X10 = b_base
    10  	// X11 = b_len
    11  	// X12 = b_cap (unused)
    12  	// X13 = byte to count (want in X12)
    13  	AND	$0xff, X13, X12
    14  	MOV	ZERO, X14	// count
    15  	ADD	X10, X11	// end
    16  
    17  	PCALIGN	$16
    18  loop:
    19  	BEQ	X10, X11, done
    20  	MOVBU	(X10), X15
    21  	ADD	$1, X10
    22  	BNE	X12, X15, loop
    23  	ADD	$1, X14
    24  	JMP	loop
    25  
    26  done:
    27  	MOV	X14, X10
    28  	RET
    29  
    30  TEXT ¬∑CountString<ABIInternal>(SB),NOSPLIT,$0-32
    31  	// X10 = s_base
    32  	// X11 = s_len
    33  	// X12 = byte to count
    34  	AND	$0xff, X12
    35  	MOV	ZERO, X14	// count
    36  	ADD	X10, X11	// end
    37  
    38  	PCALIGN	$16
    39  loop:
    40  	BEQ	X10, X11, done
    41  	MOVBU	(X10), X15
    42  	ADD	$1, X10
    43  	BNE	X12, X15, loop
    44  	ADD	$1, X14
    45  	JMP	loop
    46  
    47  done:
    48  	MOV	X14, X10
    49  	RET
    50  

View as plain text