1 /* SPDX-License-Identifier: GPL-2.0 */ << 2 /* 1 /* 3 * arch/alpha/lib/strchr.S 2 * arch/alpha/lib/strchr.S 4 * Contributed by Richard Henderson (rth@tamu. 3 * Contributed by Richard Henderson (rth@tamu.edu) 5 * 4 * 6 * Return the address of a given character wit 5 * Return the address of a given character within a null-terminated 7 * string, or null if it is not found. 6 * string, or null if it is not found. 8 */ 7 */ 9 #include <linux/export.h> !! 8 #include <asm/export.h> 10 #include <asm/regdef.h> 9 #include <asm/regdef.h> 11 10 12 .set noreorder 11 .set noreorder 13 .set noat 12 .set noat 14 13 15 .align 3 14 .align 3 16 .globl strchr 15 .globl strchr 17 .ent strchr 16 .ent strchr 18 strchr: 17 strchr: 19 .frame sp, 0, ra 18 .frame sp, 0, ra 20 .prologue 0 19 .prologue 0 21 20 22 zapnot a1, 1, a1 # e0 : zero 21 zapnot a1, 1, a1 # e0 : zero extend the search character 23 ldq_u t0, 0(a0) # .. e1 : load 22 ldq_u t0, 0(a0) # .. e1 : load first quadword 24 sll a1, 8, t5 # e0 : repl 23 sll a1, 8, t5 # e0 : replicate the search character 25 andnot a0, 7, v0 # .. e1 : alig 24 andnot a0, 7, v0 # .. e1 : align our loop pointer 26 or t5, a1, a1 # e0 : 25 or t5, a1, a1 # e0 : 27 lda t4, -1 # .. e1 : buil 26 lda t4, -1 # .. e1 : build garbage mask 28 sll a1, 16, t5 # e0 : 27 sll a1, 16, t5 # e0 : 29 cmpbge zero, t0, t2 # .. e1 : bits 28 cmpbge zero, t0, t2 # .. e1 : bits set iff byte == zero 30 mskqh t4, a0, t4 # e0 : 29 mskqh t4, a0, t4 # e0 : 31 or t5, a1, a1 # .. e1 : 30 or t5, a1, a1 # .. e1 : 32 sll a1, 32, t5 # e0 : 31 sll a1, 32, t5 # e0 : 33 cmpbge zero, t4, t4 # .. e1 : bits 32 cmpbge zero, t4, t4 # .. e1 : bits set iff byte is garbage 34 or t5, a1, a1 # e0 : 33 or t5, a1, a1 # e0 : 35 xor t0, a1, t1 # .. e1 : make 34 xor t0, a1, t1 # .. e1 : make bytes == c zero 36 cmpbge zero, t1, t3 # e0 : bits 35 cmpbge zero, t1, t3 # e0 : bits set iff byte == c 37 or t2, t3, t0 # e1 : bits 36 or t2, t3, t0 # e1 : bits set iff char match or zero match 38 andnot t0, t4, t0 # e0 : clea 37 andnot t0, t4, t0 # e0 : clear garbage bits 39 bne t0, $found # .. e1 (zdb) 38 bne t0, $found # .. e1 (zdb) 40 39 41 $loop: ldq t0, 8(v0) # e0 : 40 $loop: ldq t0, 8(v0) # e0 : 42 addq v0, 8, v0 # .. e1 : 41 addq v0, 8, v0 # .. e1 : 43 nop # e0 : 42 nop # e0 : 44 xor t0, a1, t1 # .. e1 (ev5 d 43 xor t0, a1, t1 # .. e1 (ev5 data stall) 45 cmpbge zero, t0, t2 # e0 : bits 44 cmpbge zero, t0, t2 # e0 : bits set iff byte == 0 46 cmpbge zero, t1, t3 # .. e1 : bits 45 cmpbge zero, t1, t3 # .. e1 : bits set iff byte == c 47 or t2, t3, t0 # e0 : 46 or t2, t3, t0 # e0 : 48 beq t0, $loop # .. e1 (zdb) 47 beq t0, $loop # .. e1 (zdb) 49 48 50 $found: negq t0, t1 # e0 : clea 49 $found: negq t0, t1 # e0 : clear all but least set bit 51 and t0, t1, t0 # e1 (stall) 50 and t0, t1, t0 # e1 (stall) 52 51 53 and t0, t3, t1 # e0 : bit 52 and t0, t3, t1 # e0 : bit set iff byte was the char 54 beq t1, $retnull # .. e1 (zdb) 53 beq t1, $retnull # .. e1 (zdb) 55 54 56 and t0, 0xf0, t2 # e0 : bina 55 and t0, 0xf0, t2 # e0 : binary search for that set bit 57 and t0, 0xcc, t3 # .. e1 : 56 and t0, 0xcc, t3 # .. e1 : 58 and t0, 0xaa, t4 # e0 : 57 and t0, 0xaa, t4 # e0 : 59 cmovne t2, 4, t2 # .. e1 : 58 cmovne t2, 4, t2 # .. e1 : 60 cmovne t3, 2, t3 # e0 : 59 cmovne t3, 2, t3 # e0 : 61 cmovne t4, 1, t4 # .. e1 : 60 cmovne t4, 1, t4 # .. e1 : 62 addq t2, t3, t2 # e0 : 61 addq t2, t3, t2 # e0 : 63 addq v0, t4, v0 # .. e1 : 62 addq v0, t4, v0 # .. e1 : 64 addq v0, t2, v0 # e0 : 63 addq v0, t2, v0 # e0 : 65 ret # .. e1 : 64 ret # .. e1 : 66 65 67 $retnull: 66 $retnull: 68 mov zero, v0 # e0 : 67 mov zero, v0 # e0 : 69 ret # .. e1 : 68 ret # .. e1 : 70 69 71 .end strchr 70 .end strchr 72 EXPORT_SYMBOL(strchr) 71 EXPORT_SYMBOL(strchr)
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.