github.com/JimmyHuang454/JLS-go@v0.0.0-20230831150107-90d536585ba0/internal/bytealg/indexbyte_riscv64.s (about) 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 // X10 = b_base 10 // X11 = b_len 11 // X12 = b_cap (unused) 12 // X13 = byte to find 13 AND $0xff, X13 14 MOV X10, X12 // store base for later 15 ADD X10, X11 // end 16 ADD $-1, X10 17 18 loop: 19 ADD $1, X10 20 BEQ X10, X11, notfound 21 MOVBU (X10), X14 22 BNE X13, X14, loop 23 24 SUB X12, X10 // remove base 25 RET 26 27 notfound: 28 MOV $-1, X10 29 RET 30 31 TEXT ·IndexByteString<ABIInternal>(SB),NOSPLIT,$0-32 32 // X10 = b_base 33 // X11 = b_len 34 // X12 = byte to find 35 AND $0xff, X12 36 MOV X10, X13 // store base for later 37 ADD X10, X11 // end 38 ADD $-1, X10 39 40 loop: 41 ADD $1, X10 42 BEQ X10, X11, notfound 43 MOVBU (X10), X14 44 BNE X12, X14, loop 45 46 SUB X13, X10 // remove base 47 RET 48 49 notfound: 50 MOV $-1, X10 51 RET