Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/common/lib/libc/arch/arm/string Swap use of r1 and ip
details: https://anonhg.NetBSD.org/src/rev/e18d8393453a
branches: trunk
changeset: 789463:e18d8393453a
user: matt <matt%NetBSD.org@localhost>
date: Mon Aug 19 17:38:47 2013 +0000
description:
Swap use of r1 and ip
teq -> cmp.
add s to few instructions
(thumbify part 1)
diffstat:
common/lib/libc/arch/arm/string/strchr_arm.S | 62 ++++++++++++++-------------
1 files changed, 32 insertions(+), 30 deletions(-)
diffs (153 lines):
diff -r c5012783cd23 -r e18d8393453a common/lib/libc/arch/arm/string/strchr_arm.S
--- a/common/lib/libc/arch/arm/string/strchr_arm.S Mon Aug 19 17:02:25 2013 +0000
+++ b/common/lib/libc/arch/arm/string/strchr_arm.S Mon Aug 19 17:38:47 2013 +0000
@@ -29,7 +29,7 @@
#include <machine/asm.h>
-RCSID("$NetBSD: strchr_arm.S,v 1.5 2013/02/08 02:19:35 matt Exp $")
+RCSID("$NetBSD: strchr_arm.S,v 1.6 2013/08/19 17:38:47 matt Exp $")
#ifdef __ARMEL__
#define BYTE0 0x000000ff
@@ -37,12 +37,14 @@
#define BYTE2 0x00ff0000
#define BYTE3 0xff000000
#define lshi lsl
+#define lshis lsls
#else
#define BYTE0 0xff000000
#define BYTE1 0x00ff0000
#define BYTE2 0x0000ff00
#define BYTE3 0x000000ff
#define lshi lsr
+#define lshis lsrs
#endif
.text
@@ -53,20 +55,20 @@
ldrb r3, [r0], #1 /* load a byte */
cmp r3, r2 /* is it a match? */
beq 2f /* yes, return current ptr - 1 */
- teq r3, #0 /* no, was it 0? */
+ cmp r3, #0 /* no, was it 0? */
bne 1b /* no, try next byte */
- mov r0, #0 /* yes, set return value to NULL */
+ movs r0, #0 /* yes, set return value to NULL */
RET /* return */
-2: sub r0, r0, #1 /* back up by one */
+2: subs r0, r0, #1 /* back up by one */
RET /* return */
.Lpre_main_loop:
#if defined(_ARM_ARCH_7)
- movw r1, #0xfefe /* magic constant; 254 in each byte */
- movt r1, #0xfefe /* magic constant; 254 in each byte */
+ movw ip, #0xfefe /* magic constant; 254 in each byte */
+ movt ip, #0xfefe /* magic constant; 254 in each byte */
#elif defined(_ARM_ARCH_6)
- mov r1, #0xfe /* put 254 in low byte */
- orr r1, r1, r1, lsl #8 /* move to next byte */
- orr r1, r1, r1, lsl #16 /* move to next halfword */
+ mov ip, #0xfe /* put 254 in low byte */
+ orr ip, ip, ip, lsl #8 /* move to next byte */
+ orr ip, ip, ip, lsl #16 /* move to next halfword */
#endif /* _ARM_ARCH_6 */
orr r2, r2, r2, lsl #8 /* move to next byte */
orr r2, r2, r2, lsl #16 /* move to next halfword */
@@ -79,10 +81,10 @@
* become 255. For NUL, it will be 254. When we complement the
* result, if the result is non-0 then we must have encountered a NUL.
*/
- uqadd8 ip, r3, r1 /* NUL detection happens here */
- eor r3, r3, r2 /* xor to clear each lane */
- uqadd8 r3, r3, r1 /* char detection happens here */
- and r3, r3, ip /* merge results */
+ uqadd8 r1, r3, ip /* NUL detection happens here */
+ eors r3, r3, r2 /* xor to clear each lane */
+ uqadd8 r3, r3, ip /* char detection happens here */
+ ands r3, r3, r1 /* merge results */
mvns r3, r3 /* is the complement non-0? */
beq .Lmain_loop /* no, then keep going */
@@ -92,14 +94,14 @@
*/
teq r2, #0 /* searching for NUL? */
beq .Lfind_match /* yes, find the match */
- mvns ip, ip /* did we encounter a NUL? */
+ mvns r1, r1 /* did we encounter a NUL? */
beq .Lfind_match /* no, find the match */
- bics r3, r3, ip /* clear match for the NUL(s) */
+ bics r3, r3, r1 /* clear match for the NUL(s) */
beq .Lnomatch /* any left set? if not, no match */
- movs ip, ip, lshi #8 /* replicate NUL bit to other bytes */
- orrne ip, ip, ip, lshi #8 /* replicate NUL bit to other bytes */
- orrne ip, ip, ip, lshi #8 /* replicate NUL bit to other bytes */
- bics r3, r3, ip /* clear any match bits after the NUL */
+ lshis r1, r1, #8 /* replicate NUL bit to other bytes */
+ orrne r1, r1, r1, lshi #8 /* replicate NUL bit to other bytes */
+ orrne r1, r1, r1, lshi #8 /* replicate NUL bit to other bytes */
+ bics r3, r3, r1 /* clear any match bits after the NUL */
beq .Lnomatch /* any left set? if not, no match */
.Lfind_match:
#ifdef __ARMEL__
@@ -107,49 +109,49 @@
#endif
clz r3, r3 /* count how many leading zeros */
add r0, r0, r3, lsr #3 /* divide that by 8 and add to count */
- sub r0, r0, #4 /* compensate for the post-inc */
+ subs r0, r0, #4 /* compensate for the post-inc */
RET
.Lnomatch:
- mov r0, #0
+ movs r0, #0
RET
#else
/*
* No fancy shortcuts so just test each byte lane for a NUL.
* (other tests for NULs in a word take more instructions/cycles).
*/
- eor ip, r3, r2 /* xor .. */
+ eor r1, r3, r2 /* xor .. */
tst r3, #BYTE0 /* is this byte NUL? */
- tstne ip, #BYTE0 /* no, does this byte match? */
+ tstne r1, #BYTE0 /* no, does this byte match? */
tstne r3, #BYTE1 /* no, is this byte NUL? */
- tstne ip, #BYTE1 /* no, does this byte match? */
+ tstne r1, #BYTE1 /* no, does this byte match? */
tstne r3, #BYTE2 /* no, is this byte NUL? */
- tstne ip, #BYTE2 /* no, does this byte match? */
+ tstne r1, #BYTE2 /* no, does this byte match? */
tstne r3, #BYTE3 /* no, is this byte NUL? */
- tstne ip, #BYTE3 /* no, does this byte match? */
+ tstne r1, #BYTE3 /* no, does this byte match? */
bne .Lmain_loop
sub r2, r0, #4 /* un post-inc */
mov r0, #0 /* assume no match */
- tst ip, #BYTE0 /* does this byte match? */
+ tst r1, #BYTE0 /* does this byte match? */
moveq r0, r2 /* yes, point to it */
RETc(eq) /* and return */
tst r3, #BYTE0 /* is this byte NUL? */
RETc(eq) /* yes, return NULL */
- tst ip, #BYTE1 /* does this byte match? */
+ tst r1, #BYTE1 /* does this byte match? */
addeq r0, r2, #1 /* yes, point to it */
RETc(eq) /* and return */
tst r3, #BYTE1 /* is this byte NUL? */
RETc(eq) /* yes, return NULL */
- tst ip, #BYTE2 /* does this byte match? */
+ tst r1, #BYTE2 /* does this byte match? */
addeq r0, r2, #2 /* yes, point to it */
RETc(eq) /* and return */
tst r3, #BYTE2 /* is this byte NUL? */
RETc(eq) /* yes, return NULL */
- tst ip, #BYTE3 /* does this byte match? */
+ tst r1, #BYTE3 /* does this byte match? */
addeq r0, r2, #3 /* yes, point to it */
/*
* Since no NULs and no matches this must be the only case left.
Home |
Main Index |
Thread Index |
Old Index