123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- #include <sysdep.h>
- #undef ret
- #define saved_lc r18
- #define poschr r19
- #define pos0 r20
- #define val1 r21
- #define val2 r22
- #define tmp r24
- #define chrx8 r25
- #define loopcnt r30
- #define str in0
- #define chr in1
- ENTRY(strchr)
- .prologue
- alloc r2 = ar.pfs, 2, 0, 0, 0
- .save ar.lc, saved_lc
- mov saved_lc = ar.lc
- .body
- mov ret0 = str
- and tmp = 7, str
- mux1 chrx8 = chr,
- extr.u chr = chr, 0, 8
- cmp.ne p8, p0 = r0, r0
-
- sub loopcnt = 8, tmp
- cmp.eq p6, p0 = tmp, r0
- (p6) br.cond.sptk .str_aligned;;
- adds loopcnt = -1, loopcnt
- mov ar.lc = loopcnt
- .l1:
- ld1 val2 = [ret0], 1
-
- cmp.eq p6, p0 = val2, chr
- cmp.eq p7, p0 = val2, r0
- (p6) br.cond.spnt .restore_and_exit
- (p7) br.cond.spnt .notfound
- br.cloop.sptk .l1
- .str_aligned:
- ld8 val1 = [ret0], 8
- nop.b 0
- nop.b 0
- .l2:
- ld8.s val2 = [ret0], 8
- czx1.r pos0 = val1
- xor tmp = val1, chrx8
-
- czx1.r poschr = tmp
- cmp.ne p6, p0 = 8, pos0
-
- cmp.ne p7, p0 = 8, poschr
- (p7) br.cond.spnt .foundit
- (p6) br.cond.spnt .notfound
- chk.s val2, .recovery
- .back:
- mov val1 = val2
- br.cond.dptk .l2
- .foundit:
- (p6) cmp.lt p8, p0 = pos0, poschr
- (p8) br.cond.spnt .notfound
- add ret0 = ret0, poschr
- adds ret0 = -15, ret0
- .restore_and_exit:
- adds ret0 = -1, ret0
- mov ar.lc = saved_lc
- br.ret.sptk.many b0
- .notfound:
- mov ret0 = r0
- mov ar.lc = saved_lc
- br.ret.sptk.many b0
- .recovery:
- adds ret0 = -8, ret0
- ld8 val2 = [ret0], 8
- br.cond.sptk .back
- END(strchr)
- libc_hidden_def (strchr)
- #ifdef __UCLIBC_SUSV3_LEGACY__
- strong_alias (strchr, index)
- #endif
|