github.com/primecitizens/pcz/std@v0.2.1/core/bytealg/indexbyte_riscv64.s (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Copyright 2019 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 //go:build pcz && riscv64 9 10 #include "textflag.h" 11 12 TEXT ·IndexSliceByte<ABIInternal>(SB),NOSPLIT,$0-40 13 // X10 = b_base 14 // X11 = b_len 15 // X12 = b_cap (unused) 16 // X13 = byte to find 17 AND $0xff, X13 18 MOV X10, X12 // store base for later 19 ADD X10, X11 // end 20 ADD $-1, X10 21 22 loop: 23 ADD $1, X10 24 BEQ X10, X11, notfound 25 MOVBU (X10), X14 26 BNE X13, X14, loop 27 28 SUB X12, X10 // remove base 29 RET 30 31 notfound: 32 MOV $-1, X10 33 RET 34 35 TEXT ·IndexByte<ABIInternal>(SB),NOSPLIT,$0-32 36 // X10 = b_base 37 // X11 = b_len 38 // X12 = byte to find 39 AND $0xff, X12 40 MOV X10, X13 // store base for later 41 ADD X10, X11 // end 42 ADD $-1, X10 43 44 loop: 45 ADD $1, X10 46 BEQ X10, X11, notfound 47 MOVBU (X10), X14 48 BNE X12, X14, loop 49 50 SUB X13, X10 // remove base 51 RET 52 53 notfound: 54 MOV $-1, X10 55 RET