2002-04-19 Bill Siegmund

* libc/machine/xscale/memchr.c: Don't use multi-line strings.
        * libc/machine/xscale/memcmp.c: Ditto.
        * libc/machine/xscale/memcpy.c: Ditto.
        * libc/machine/xscale/memmove.c: Ditto.
        * libc/machine/xscale/memset.c: Ditto.
        * libc/machine/xscale/strchr.c: Ditto.
        * libc/machine/xscale/strcmp.c: Ditto.
        * libc/machine/xscale/strcpy.c: Ditto.
        * libc/machine/xscale/strlen.c: Ditto.
This commit is contained in:
Jeff Johnston 2002-04-20 00:29:51 +00:00
parent 2dd4c4dc18
commit 59be22909b
10 changed files with 464 additions and 452 deletions

View File

@ -1,3 +1,15 @@
2002-04-19 Bill Siegmund
* libc/machine/xscale/memchr.c: Don't use multi-line strings.
* libc/machine/xscale/memcmp.c: Ditto.
* libc/machine/xscale/memcpy.c: Ditto.
* libc/machine/xscale/memmove.c: Ditto.
* libc/machine/xscale/memset.c: Ditto.
* libc/machine/xscale/strchr.c: Ditto.
* libc/machine/xscale/strcmp.c: Ditto.
* libc/machine/xscale/strcpy.c: Ditto.
* libc/machine/xscale/strlen.c: Ditto.
2002-04-19 Alexandre Oliva <aoliva@redhat.com> 2002-04-19 Alexandre Oliva <aoliva@redhat.com>
* libc/include/sys/config.h: Remove include of <limits.h>. * libc/include/sys/config.h: Remove include of <limits.h>.

View File

@ -42,47 +42,47 @@ memchr (const void *start, int c, size_t len)
R6 = 0x80808080 */ R6 = 0x80808080 */
asm ( asm (
"mov r6, #0x80 "mov r6, #0x80\n\
add r6, r6, #0x8000 add r6, r6, #0x8000\n\
add r6, r6, r6, lsl #16 add r6, r6, r6, lsl #16\n\
mvn r7, r6, lsl #1 mvn r7, r6, lsl #1\n\
\n\
0: 0:\n\
cmp %1, #0x7 cmp %1, #0x7\n\
bls 1f bls 1f\n\
\n\
ldmia %0!, { r3, r9 } ldmia %0!, { r3, r9 }\n\
" PRELOADSTR ("%0") " " PRELOADSTR ("%0") "\n\
sub %1, %1, #8 sub %1, %1, #8\n\
eor r3, r3, %2 eor r3, r3, %2\n\
eor r9, r9, %2 eor r9, r9, %2\n\
add r2, r3, r7 add r2, r3, r7\n\
add r8, r9, r7 add r8, r9, r7\n\
bic r2, r2, r3 bic r2, r2, r3\n\
bic r8, r8, r9 bic r8, r8, r9\n\
and r1, r2, r6 and r1, r2, r6\n\
and r9, r8, r6 and r9, r8, r6\n\
orrs r1, r1, r9 orrs r1, r1, r9\n\
beq 0b beq 0b\n\
\n\
add %1, %1, #8 add %1, %1, #8\n\
sub %0, %0, #8 sub %0, %0, #8\n\
1: 1:\n\
cmp %1, #0x3 cmp %1, #0x3\n\
bls 2f bls 2f\n\
\n\
ldr r3, [%0], #4 ldr r3, [%0], #4\n\
" PRELOADSTR ("%0") " " PRELOADSTR ("%0") "\n\
sub %1, %1, #4 sub %1, %1, #4\n\
eor r3, r3, %2 eor r3, r3, %2\n\
add r2, r3, r7 add r2, r3, r7\n\
bic r2, r2, r3 bic r2, r2, r3\n\
ands r1, r2, r6 ands r1, r2, r6\n\
beq 1b beq 1b\n\
\n\
sub %0, %0, #4 sub %0, %0, #4\n\
add %1, %1, #4 add %1, %1, #4\n\
2: 2:\n\
" "
: "=&r" (str), "=&r" (len) : "=&r" (str), "=&r" (len)
: "r" (c2), "0" (str), "1" (len) : "r" (c2), "0" (str), "1" (len)

View File

@ -13,96 +13,96 @@ memcmp (const void * s1, const void * s2, size_t len)
int result; int result;
asm ( asm (
#ifndef __OPTIMIZE_SIZE__ #ifndef __OPTIMIZE_SIZE__
" "\n\
cmp %2, #0x3 @ Is the length a multiple of four ? cmp %2, #0x3 @ Is the length a multiple of four ?\n\
bls 6f @ no = goto SLOW CHECK bls 6f @ no = goto SLOW CHECK\n\
and r2, %0, #0x3 @ get alignment of first pointer and r2, %0, #0x3 @ get alignment of first pointer\n\
and r3, %1, #0x3 @ get alignment of second pointer and r3, %1, #0x3 @ get alignment of second pointer\n\
cmp r2, r3 @ Do the two pointers share the same alignment ? cmp r2, r3 @ Do the two pointers share the same alignment ?\n\
bne 6f @ no = goto SLOW CHECK bne 6f @ no = goto SLOW CHECK\n\
mov lr, %0 @ copy first pointer into LR mov lr, %0 @ copy first pointer into LR\n\
mov r4, %1 @ copy second pointer into R4 mov r4, %1 @ copy second pointer into R4\n\
cmp r2, #0x0 @ Are we comparing word aligned pointers ? cmp r2, #0x0 @ Are we comparing word aligned pointers ?\n\
beq 3f @ yes = goto START WORD CHECK LOOP beq 3f @ yes = goto START WORD CHECK LOOP\n\
b 1f @ jump to LOOP TEST b 1f @ jump to LOOP TEST\n\
0: @ LOOP START 0: @ LOOP START\n\
ldrb r2, [lr], #1 @ load byte from LR, post inc. ldrb r2, [lr], #1 @ load byte from LR, post inc.\n\
" PRELOADSTR("lr") " @ preload " PRELOADSTR("lr") " @ preload\n\
ldrb r3, [r4], #1 @ load byte from R4, post inc. ldrb r3, [r4], #1 @ load byte from R4, post inc.\n\
" PRELOADSTR("r4") " @ preload " PRELOADSTR("r4") " @ preload\n\
cmp r2, r3 @ are the two bytes the same ? cmp r2, r3 @ are the two bytes the same ?\n\
bne 5f @ no = goto EXIT bne 5f @ no = goto EXIT\n\
tst lr, #0x3 @ has the LR become word aligned ? tst lr, #0x3 @ has the LR become word aligned ?\n\
bne 1f @ no = skip the next test bne 1f @ no = skip the next test\n\
cmp %2, #4 @ is the count >= 4 ? cmp %2, #4 @ is the count >= 4 ?\n\
bhs 3f @ yes = goto START WORD CHECK LOOP bhs 3f @ yes = goto START WORD CHECK LOOP\n\
1: @ LOOP TEST 1: @ LOOP TEST\n\
sub %2, %2, #1 @ decrement count by one sub %2, %2, #1 @ decrement count by one\n\
cmn %2, #0x1 @ has the count reached -1 ? cmn %2, #0x1 @ has the count reached -1 ?\n\
bne 0b @ no = loop back to LOOP START bne 0b @ no = loop back to LOOP START\n\
b 4f @ goto PASS END b 4f @ goto PASS END\n\
\n\
0: @ ?? 0: @ ??\n\
cmp %2, #0x7 @ Is the count a multiple of 8 ? cmp %2, #0x7 @ Is the count a multiple of 8 ?\n\
bls 3f @ no = goto ??? bls 3f @ no = goto ???\n\
ldmia lr,{r2, r3} @ get two words from first pointer, post inc ldmia lr,{r2, r3} @ get two words from first pointer, post inc\n\
ldmia r4,{r5, r6} @ get two words from second pointer, post inc ldmia r4,{r5, r6} @ get two words from second pointer, post inc\n\
sub %2, %2, #0x4 @ decrement count by 4 sub %2, %2, #0x4 @ decrement count by 4\n\
cmp r2, r5 @ has the count reached ???? cmp r2, r5 @ has the count reached ????\n\
bne 1f @ no = goto bne 1f @ no = goto\n\
sub %2, %2, #0x4 @ decrement the count by 4 sub %2, %2, #0x4 @ decrement the count by 4\n\
add lr, lr, #0x4 @ add 4 to first pointer add lr, lr, #0x4 @ add 4 to first pointer\n\
add r4, r4, #0x4 @ add 4 to second pointer add r4, r4, #0x4 @ add 4 to second pointer\n\
cmp r3, r6 @ ??? cmp r3, r6 @ ???\n\
beq 0b @ goto ??? beq 0b @ goto ???\n\
1: @ ?? 1: @ ??\n\
add %2, %2, #0x4 @ Add four to count add %2, %2, #0x4 @ Add four to count\n\
sub %0, lr, #0x4 @ decrement first pointer by 4 sub %0, lr, #0x4 @ decrement first pointer by 4\n\
sub %1, r4, #0x4 @ decrement second pointer by 4 sub %1, r4, #0x4 @ decrement second pointer by 4\n\
b 6f @ goto SLOW CHECK b 6f @ goto SLOW CHECK\n\
\n\
3: @ START WORD CHECK LOOP 3: @ START WORD CHECK LOOP\n\
cmp %2, #0x3 @ is the count <= 3 ? cmp %2, #0x3 @ is the count <= 3 ?\n\
bls 1f @ yes = goto CHECK BYTES BY HAND bls 1f @ yes = goto CHECK BYTES BY HAND\n\
ldr r2, [lr], #4 @ get word from LR, post inc ldr r2, [lr], #4 @ get word from LR, post inc\n\
ldr r3, [r4], #4 @ get word from R4, post inc ldr r3, [r4], #4 @ get word from R4, post inc\n\
sub %2, %2, #4 @ decrement count by 4 sub %2, %2, #4 @ decrement count by 4\n\
cmp r2, r3 @ are the two words the same ? cmp r2, r3 @ are the two words the same ?\n\
bne 1f @ no = goto CHECK WORD CONTENTS bne 1f @ no = goto CHECK WORD CONTENTS\n\
0: @ WORD CHECK LOOP 0: @ WORD CHECK LOOP\n\
cmp %2, #0x3 @ is the count <= 3 ? cmp %2, #0x3 @ is the count <= 3 ?\n\
bls 1f @ yes = goto CHECK BYTES BY HAND bls 1f @ yes = goto CHECK BYTES BY HAND\n\
ldr r2, [lr], #4 @ load word from LR, post inc ldr r2, [lr], #4 @ load word from LR, post inc\n\
" PRELOADSTR("lr") " @ preload " PRELOADSTR("lr") " @ preload\n\
ldr r3, [r4], #4 @ load word from R4, post inc ldr r3, [r4], #4 @ load word from R4, post inc\n\
" PRELOADSTR("r4") " @ preload " PRELOADSTR("r4") " @ preload\n\
sub %2, %2, #4 @ decrement count by 4 sub %2, %2, #4 @ decrement count by 4\n\
cmp r2, r3 @ are the two words the same ? cmp r2, r3 @ are the two words the same ?\n\
beq 0b @ yes = goto WORD CHECK LOOP beq 0b @ yes = goto WORD CHECK LOOP\n\
1: @ CHECK BYTES BY HAND 1: @ CHECK BYTES BY HAND\n\
sub %0, lr, #0x4 @ move LR back a word and put into first pointer sub %0, lr, #0x4 @ move LR back a word and put into first pointer\n\
sub %1, r4, #0x4 @ move R4 back a word and put into second pointer sub %1, r4, #0x4 @ move R4 back a word and put into second pointer\n\
add %2, %2, #4 @ increment the count by 4 add %2, %2, #4 @ increment the count by 4\n\
@ fall through into SLOW CHECK" @ fall through into SLOW CHECK"
#endif /* !__OPTIMIZE_SIZE__ */ #endif /* !__OPTIMIZE_SIZE__ */
" "\n\
6: @ SLOW CHECK 6: @ SLOW CHECK\n\
sub %2, %2, #1 @ Decrement the count by one sub %2, %2, #1 @ Decrement the count by one\n\
cmn %2, #0x1 @ Has the count reached -1 ? cmn %2, #0x1 @ Has the count reached -1 ?\n\
beq 4f @ Yes - we are finished, goto PASS END beq 4f @ Yes - we are finished, goto PASS END\n\
0: @ LOOP1 0: @ LOOP1\n\
ldrb r2, [%0], #1 @ get byte from first pointer ldrb r2, [%0], #1 @ get byte from first pointer\n\
" PRELOADSTR("%0") " @ preload first pointer " PRELOADSTR("%0") " @ preload first pointer\n\
ldrb r3, [%1], #1 @ get byte from second pointer ldrb r3, [%1], #1 @ get byte from second pointer\n\
" PRELOADSTR("%1") " @ preload second pointer " PRELOADSTR("%1") " @ preload second pointer\n\
cmp r2, r3 @ compare the two loaded bytes cmp r2, r3 @ compare the two loaded bytes\n\
bne 5f @ if they are not equal goto EXIT bne 5f @ if they are not equal goto EXIT\n\
sub %2, %2, #1 @ decremented count by 1 sub %2, %2, #1 @ decremented count by 1\n\
cmn %2, #0x1 @ has the count reached -1 ? cmn %2, #0x1 @ has the count reached -1 ?\n\
bne 0b @ no = then go back to LOOP1 bne 0b @ no = then go back to LOOP1\n\
4: @ PASS END 4: @ PASS END\n\
mov r3, r2 @ Default return value is 0 mov r3, r2 @ Default return value is 0\n\
5: @ EXIT 5: @ EXIT\n\
rsb %0, r3, r2 @ return difference between last two bytes loaded" rsb %0, r3, r2 @ return difference between last two bytes loaded"
: "=r" (result), "=&r" (s2), "=&r" (len) : "=r" (result), "=&r" (s2), "=&r" (len)
: "0" (s1), "1" (s2), "2" (len) : "0" (s1), "1" (s2), "2" (len)

View File

@ -13,85 +13,85 @@ memcpy (void *dst0, const void *src0, size_t len)
int dummy; int dummy;
asm volatile ( asm volatile (
#ifndef __OPTIMIZE_SIZE__ #ifndef __OPTIMIZE_SIZE__
"cmp %2, #0x3 "cmp %2, #0x3\n\
bls 3f bls 3f\n\
and lr, %1, #0x3 and lr, %1, #0x3\n\
and r3, %0, #0x3 and r3, %0, #0x3\n\
cmp lr, r3 cmp lr, r3\n\
bne 3f bne 3f\n\
cmp lr, #0x0 cmp lr, #0x0\n\
beq 2f beq 2f\n\
b 1f b 1f\n\
0: 0:\n\
ldrb r3, [%1], #1 ldrb r3, [%1], #1\n\
" "
PRELOADSTR ("%1") PRELOADSTR ("%1")
" "\n\
tst %1, #0x3 tst %1, #0x3\n\
strb r3, [%0], #1 strb r3, [%0], #1\n\
beq 3f beq 3f\n\
1: 1:\n\
sub %2, %2, #1 sub %2, %2, #1\n\
cmn %2, #1 cmn %2, #1\n\
bne 0b bne 0b\n\
2: 2:\n\
cmp %2, #0xf cmp %2, #0xf\n\
bls 1f bls 1f\n\
0: 0:\n\
ldmia %1!, { r3, r4, r5, lr } ldmia %1!, { r3, r4, r5, lr }\n\
" "
PRELOADSTR ("%1") PRELOADSTR ("%1")
" "\n\
\n\
sub %2, %2, #16 sub %2, %2, #16\n\
cmp %2, #0xf cmp %2, #0xf\n\
stmia %0!, { r3, r4, r5, lr } stmia %0!, { r3, r4, r5, lr }\n\
bhi 0b bhi 0b\n\
1: 1:\n\
cmp %2, #0x7 cmp %2, #0x7\n\
bls 1f bls 1f\n\
0: 0:\n\
ldmia %1!, { r3, r4 } ldmia %1!, { r3, r4 }\n\
" "
PRELOADSTR ("%1") PRELOADSTR ("%1")
" "\n\
\n\
sub %2, %2, #8 sub %2, %2, #8\n\
cmp %2, #0x7 cmp %2, #0x7\n\
stmia %0!, { r3, r4 } stmia %0!, { r3, r4 }\n\
bhi 0b bhi 0b\n\
1: 1:\n\
cmp %2, #0x3 cmp %2, #0x3\n\
bls 3f bls 3f\n\
0: 0:\n\
sub %2, %2, #4 sub %2, %2, #4\n\
ldr r3, [%1], #4 ldr r3, [%1], #4\n\
" "
PRELOADSTR ("%1") PRELOADSTR ("%1")
" "\n\
\n\
cmp %2, #0x3 cmp %2, #0x3\n\
str r3, [%0], #4 str r3, [%0], #4\n\
bhi 0b bhi 0b\n\
" "
#endif /* !__OPTIMIZE_SIZE__ */ #endif /* !__OPTIMIZE_SIZE__ */
" "\n\
3: 3:\n\
" "
PRELOADSTR ("%1") PRELOADSTR ("%1")
" "\n\
sub %2, %2, #1 sub %2, %2, #1\n\
cmn %2, #1 cmn %2, #1\n\
beq 1f beq 1f\n\
0: 0:\n\
sub %2, %2, #1 sub %2, %2, #1\n\
ldrb r3, [%1], #1 ldrb r3, [%1], #1\n\
" "
PRELOADSTR ("%1") PRELOADSTR ("%1")
" "\n\
cmn %2, #1 cmn %2, #1\n\
strb r3, [%0], #1 strb r3, [%0], #1\n\
bne 0b bne 0b\n\
1:" 1:"
: "=&r" (dummy), "=&r" (src0), "=&r" (len) : "=&r" (dummy), "=&r" (src0), "=&r" (len)
: "0" (dst0), "1" (src0), "2" (len) : "0" (dst0), "1" (src0), "2" (len)

View File

@ -13,85 +13,85 @@ do_memcpy (void *dst0, const void *src0, size_t len)
int dummy; int dummy;
asm volatile ( asm volatile (
#ifndef __OPTIMIZE_SIZE__ #ifndef __OPTIMIZE_SIZE__
"cmp %2, #0x3 "cmp %2, #0x3\n\
bls 3f bls 3f\n\
and lr, %1, #0x3 and lr, %1, #0x3\n\
and r3, %0, #0x3 and r3, %0, #0x3\n\
cmp lr, r3 cmp lr, r3\n\
bne 3f bne 3f\n\
cmp lr, #0x0 cmp lr, #0x0\n\
beq 2f beq 2f\n\
b 1f b 1f\n\
0: 0:\n\
ldrb r3, [%1], #1 ldrb r3, [%1], #1\n\
" "
PRELOADSTR ("%1") PRELOADSTR ("%1")
" "\n\
tst %1, #0x3 tst %1, #0x3\n\
strb r3, [%0], #1 strb r3, [%0], #1\n\
beq 3f beq 3f\n\
1: 1:\n\
sub %2, %2, #1 sub %2, %2, #1\n\
cmn %2, #1 cmn %2, #1\n\
bne 0b bne 0b\n\
2: 2:\n\
cmp %2, #0xf cmp %2, #0xf\n\
bls 1f bls 1f\n\
0: 0:\n\
ldmia %1!, { r3, r4, r5, lr } ldmia %1!, { r3, r4, r5, lr }\n\
" "
PRELOADSTR ("%1") PRELOADSTR ("%1")
" "\n\
\n\
sub %2, %2, #16 sub %2, %2, #16\n\
cmp %2, #0xf cmp %2, #0xf\n\
stmia %0!, { r3, r4, r5, lr } stmia %0!, { r3, r4, r5, lr }\n\
bhi 0b bhi 0b\n\
1: 1:\n\
cmp %2, #0x7 cmp %2, #0x7\n\
bls 1f bls 1f\n\
0: 0:\n\
ldmia %1!, { r3, r4 } ldmia %1!, { r3, r4 }\n\
" "
PRELOADSTR ("%1") PRELOADSTR ("%1")
" "\n\
\n\
sub %2, %2, #8 sub %2, %2, #8\n\
cmp %2, #0x7 cmp %2, #0x7\n\
stmia %0!, { r3, r4 } stmia %0!, { r3, r4 }\n\
bhi 0b bhi 0b\n\
1: 1:\n\
cmp %2, #0x3 cmp %2, #0x3\n\
bls 3f bls 3f\n\
0: 0:\n\
sub %2, %2, #4 sub %2, %2, #4\n\
ldr r3, [%1], #4 ldr r3, [%1], #4\n\
" "
PRELOADSTR ("%1") PRELOADSTR ("%1")
" "\n\
\n\
cmp %2, #0x3 cmp %2, #0x3\n\
str r3, [%0], #4 str r3, [%0], #4\n\
bhi 0b bhi 0b\n\
" "
#endif /* !__OPTIMIZE_SIZE__ */ #endif /* !__OPTIMIZE_SIZE__ */
" "\n\
3: 3:\n\
" "
PRELOADSTR ("%1") PRELOADSTR ("%1")
" "\n\
sub %2, %2, #1 sub %2, %2, #1\n\
cmn %2, #1 cmn %2, #1\n\
beq 1f beq 1f\n\
0: 0:\n\
sub %2, %2, #1 sub %2, %2, #1\n\
ldrb r3, [%1], #1 ldrb r3, [%1], #1\n\
" "
PRELOADSTR ("%1") PRELOADSTR ("%1")
" "\n\
cmn %2, #1 cmn %2, #1\n\
strb r3, [%0], #1 strb r3, [%0], #1\n\
bne 0b bne 0b\n\
1:" 1:"
: "=&r" (dummy), "=&r" (src0), "=&r" (len) : "=&r" (dummy), "=&r" (src0), "=&r" (len)
: "0" (dst0), "1" (src0), "2" (len) : "0" (dst0), "1" (src0), "2" (len)

View File

@ -14,69 +14,69 @@ memset (void *dst, int c, size_t len)
asm volatile ("tst %0, #0x3" asm volatile ("tst %0, #0x3"
#ifndef __OPTIMIZE_SIZE__ #ifndef __OPTIMIZE_SIZE__
" "\n\
beq 1f beq 1f\n\
b 2f b 2f\n\
0: 0:\n\
strb %1, [%0], #1 strb %1, [%0], #1\n\
tst %0, #0x3 tst %0, #0x3\n\
beq 1f beq 1f\n\
2: 2:\n\
movs r3, %2 movs r3, %2\n\
sub %2, %2, #1 sub %2, %2, #1\n\
bne 0b bne 0b\n\
# At this point we know that %2 == len == -1 (since the SUB has already taken # At this point we know that %2 == len == -1 (since the SUB has already taken\n\
# place). If we fall through to the 1: label (as the code used to do), the # place). If we fall through to the 1: label (as the code used to do), the\n\
# CMP will detect this negative value and branch to the 2: label. This will # CMP will detect this negative value and branch to the 2: label. This will\n\
# test %2 again, but this time against 0. The test will fail and the loop # test %2 again, but this time against 0. The test will fail and the loop\n\
# at 2: will go on for (almost) ever. Hence the explicit branch to the end # at 2: will go on for (almost) ever. Hence the explicit branch to the end\n\
# of the hand written assembly code. # of the hand written assembly code.\n\
b 4f b 4f\n\
1: 1:\n\
cmp %2, #0x3 cmp %2, #0x3\n\
bls 2f bls 2f\n\
and %1, %1, #0xff and %1, %1, #0xff\n\
orr lr, %1, %1, asl #8 orr lr, %1, %1, asl #8\n\
cmp %2, #0xf cmp %2, #0xf\n\
orr lr, lr, lr, asl #16 orr lr, lr, lr, asl #16\n\
bls 1f bls 1f\n\
mov r3, lr mov r3, lr\n\
mov r4, lr mov r4, lr\n\
mov r5, lr mov r5, lr\n\
0: 0:\n\
sub %2, %2, #16 sub %2, %2, #16\n\
stmia %0!, { r3, r4, r5, lr } stmia %0!, { r3, r4, r5, lr }\n\
cmp %2, #0xf cmp %2, #0xf\n\
bhi 0b bhi 0b\n\
1: 1:\n\
cmp %2, #0x7 cmp %2, #0x7\n\
bls 1f bls 1f\n\
mov r3, lr mov r3, lr\n\
0: 0:\n\
sub %2, %2, #8 sub %2, %2, #8\n\
stmia %0!, { r3, lr } stmia %0!, { r3, lr }\n\
cmp %2, #0x7 cmp %2, #0x7\n\
bhi 0b bhi 0b\n\
1: 1:\n\
cmp %2, #0x3 cmp %2, #0x3\n\
bls 2f bls 2f\n\
0: 0:\n\
sub %2, %2, #4 sub %2, %2, #4\n\
str lr, [%0], #4 str lr, [%0], #4\n\
cmp %2, #0x3 cmp %2, #0x3\n\
bhi 0b bhi 0b\n\
" "
#endif /* !__OPTIMIZE_SIZE__ */ #endif /* !__OPTIMIZE_SIZE__ */
" "\n\
2: 2:\n\
movs r3, %2 movs r3, %2\n\
sub %2, %2, #1 sub %2, %2, #1\n\
beq 4f beq 4f\n\
0: 0:\n\
movs r3, %2 movs r3, %2\n\
sub %2, %2, #1 sub %2, %2, #1\n\
strb %1, [%0], #1 strb %1, [%0], #1\n\
bne 0b bne 0b\n\
4:" 4:"
: "=&r" (dummy), "=&r" (c), "=&r" (len) : "=&r" (dummy), "=&r" (c), "=&r" (len)

View File

@ -38,25 +38,25 @@ strchr (const char *s, int c)
R6 = 0xfefefeff [ == ~(0x80808080 << 1) ] R6 = 0xfefefeff [ == ~(0x80808080 << 1) ]
R5 = 0x80808080 */ R5 = 0x80808080 */
asm (PRELOADSTR ("%0") " asm (PRELOADSTR ("%0") "\n\
mov r5, #0x80 mov r5, #0x80\n\
add r5, r5, #0x8000 add r5, r5, #0x8000\n\
add r5, r5, r5, lsl #16 add r5, r5, r5, lsl #16\n\
mvn r6, r5, lsl #1 mvn r6, r5, lsl #1\n\
\n\
sub %0, %0, #4 sub %0, %0, #4\n\
0: 0:\n\
ldr r1, [%0, #4]! ldr r1, [%0, #4]!\n\
" PRELOADSTR ("%0") " " PRELOADSTR ("%0") "\n\
add r3, r1, r6 add r3, r1, r6\n\
bic r3, r3, r1 bic r3, r3, r1\n\
ands r2, r3, r5 ands r2, r3, r5\n\
bne 1f bne 1f\n\
eor r2, r1, %1 eor r2, r1, %1\n\
add r3, r2, r6 add r3, r2, r6\n\
bic r3, r3, r2 bic r3, r3, r2\n\
ands r1, r3, r5 ands r1, r3, r5\n\
beq 0b beq 0b\n\
1:" 1:"
: "=&r" (s) : "=&r" (s)
: "r" (c2), "0" (s) : "r" (c2), "0" (s)

View File

@ -32,58 +32,58 @@ strcmp (const char *s1, const char *s2)
ip = 0x80808080 */ ip = 0x80808080 */
asm ( asm (
"ldr r2, [%1, #0] "ldr r2, [%1, #0]\n\
ldr r3, [%2, #0] ldr r3, [%2, #0]\n\
cmp r2, r3 cmp r2, r3\n\
bne 2f bne 2f\n\
\n\
mov ip, #0x80 mov ip, #0x80\n\
add ip, ip, #0x8000 add ip, ip, #0x8000\n\
add ip, ip, ip, lsl #16 add ip, ip, ip, lsl #16\n\
mvn lr, ip, lsl #1 mvn lr, ip, lsl #1\n\
\n\
0: 0:\n\
ldr r2, [%1, #0] ldr r2, [%1, #0]\n\
add r3, r2, lr add r3, r2, lr\n\
bic r3, r3, r2 bic r3, r3, r2\n\
tst r3, ip tst r3, ip\n\
beq 1f beq 1f\n\
mov %0, #0x0 mov %0, #0x0\n\
b 3f b 3f\n\
1: 1:\n\
ldr r2, [%1, #4]! ldr r2, [%1, #4]!\n\
ldr r3, [%2, #4]! ldr r3, [%2, #4]!\n\
" PRELOADSTR("%1") " " PRELOADSTR("%1") "\n\
" PRELOADSTR("%2") " " PRELOADSTR("%2") "\n\
cmp r2, r3 cmp r2, r3\n\
beq 0b" beq 0b"
/* The following part could be done in a C loop as well, but it needs /* The following part could be done in a C loop as well, but it needs
to be assembler to save some cycles in the case where the optimized to be assembler to save some cycles in the case where the optimized
loop above finds the strings to be equal. */ loop above finds the strings to be equal. */
" "\n\
2: 2:\n\
ldrb r2, [%1, #0] ldrb r2, [%1, #0]\n\
" PRELOADSTR("%1") " " PRELOADSTR("%1") "\n\
" PRELOADSTR("%2") " " PRELOADSTR("%2") "\n\
cmp r2, #0x0 cmp r2, #0x0\n\
beq 1f beq 1f\n\
ldrb r3, [%2, #0] ldrb r3, [%2, #0]\n\
cmp r2, r3 cmp r2, r3\n\
bne 1f bne 1f\n\
0: 0:\n\
ldrb r3, [%1, #1]! ldrb r3, [%1, #1]!\n\
add %2, %2, #1 add %2, %2, #1\n\
ands ip, r3, #0xff ands ip, r3, #0xff\n\
beq 1f beq 1f\n\
ldrb r3, [%2] ldrb r3, [%2]\n\
cmp ip, r3 cmp ip, r3\n\
beq 0b beq 0b\n\
1: 1:\n\
ldrb lr, [%1, #0] ldrb lr, [%1, #0]\n\
ldrb ip, [%2, #0] ldrb ip, [%2, #0]\n\
rsb %0, ip, lr rsb %0, ip, lr\n\
3: 3:\n\
" "
: "=r" (result), "=&r" (s1), "=&r" (s2) : "=r" (result), "=&r" (s1), "=&r" (s2)

View File

@ -28,25 +28,25 @@ strcpy (char *dest, const char *src)
R4 = 0xfefefeff [ == ~(0x80808080 << 1) ] R4 = 0xfefefeff [ == ~(0x80808080 << 1) ]
R5 = 0x80808080 */ R5 = 0x80808080 */
asm ("mov r5, #0x80 asm ("mov r5, #0x80\n\
ldr r1, [%1, #0] ldr r1, [%1, #0]\n\
add r5, r5, #0x8000 add r5, r5, #0x8000\n\
add r5, r5, r5, lsl #16 add r5, r5, r5, lsl #16\n\
mvn r4, r5, lsl #1 mvn r4, r5, lsl #1\n\
\n\
add r3, r1, r5 add r3, r1, r5\n\
bic r3, r3, r1 bic r3, r3, r1\n\
ands r2, r3, r4 ands r2, r3, r4\n\
bne 1f bne 1f\n\
0: 0:\n\
ldr r3, [%1, #0] ldr r3, [%1, #0]\n\
ldr r1, [%1, #4]! ldr r1, [%1, #4]!\n\
" PRELOADSTR("%1") " " PRELOADSTR("%1") "\n\
str r3, [%0], #4 str r3, [%0], #4\n\
add r2, r1, r4 add r2, r1, r4\n\
bic r2, r2, r1 bic r2, r2, r1\n\
ands r3, r2, r5 ands r3, r2, r5\n\
beq 0b beq 0b\n\
1:" 1:"
: "=&r" (dest), "=&r" (src) : "=&r" (dest), "=&r" (src)
: "0" (dest), "1" (src) : "0" (dest), "1" (src)

View File

@ -28,68 +28,68 @@ strlen (const char *str)
R4 = 0xfefefeff [ == ~(0x80808080 << 1) ] R4 = 0xfefefeff [ == ~(0x80808080 << 1) ]
R5 = 0x80808080 */ R5 = 0x80808080 */
asm ("mov r5, #0x80 asm ("mov r5, #0x80\n\
add r5, r5, #0x8000 add r5, r5, #0x8000\n\
add r5, r5, r5, lsl #16 add r5, r5, r5, lsl #16\n\
mvn r4, r5, lsl #1 mvn r4, r5, lsl #1\n\
" "
#if defined __ARM_ARCH_5__ || defined __ARM_ARCH_5T__ || defined __ARM_ARCH_5E__ || defined __ARM_ARCH_5TE__ #if defined __ARM_ARCH_5__ || defined __ARM_ARCH_5T__ || defined __ARM_ARCH_5E__ || defined __ARM_ARCH_5TE__
" tst %0, #0x7 " tst %0, #0x7\n\
ldreqd r6, [%0] ldreqd r6, [%0]\n\
beq 1f beq 1f\n\
ldr r2, [%0] ldr r2, [%0]\n\
add r3, r2, r4 add r3, r2, r4\n\
bic r3, r3, r2 bic r3, r3, r2\n\
ands r2, r3, r5 ands r2, r3, r5\n\
bne 2f bne 2f\n\
sub %0, %0, #4 sub %0, %0, #4\n\
\n\
0: 0:\n\
ldrd r6, [%0, #8]! ldrd r6, [%0, #8]!\n\
" "
PRELOADSTR ("%0") PRELOADSTR ("%0")
" "\n\
1: 1:\n\
add r3, r6, r4 add r3, r6, r4\n\
add r2, r7, r4 add r2, r7, r4\n\
bic r3, r3, r6 bic r3, r3, r6\n\
bic r2, r2, r7 bic r2, r2, r7\n\
and r3, r3, r5 and r3, r3, r5\n\
and r2, r2, r5 and r2, r2, r5\n\
orrs r3, r2, r3 orrs r3, r2, r3\n\
beq 0b beq 0b\n\
" "
#else #else
" sub %0, %0, #4 " sub %0, %0, #4\n\
\n\
0: 0:\n\
ldr r6, [%0, #4]! ldr r6, [%0, #4]!\n\
" "
PRELOADSTR ("%0") PRELOADSTR ("%0")
" "\n\
add r3, r6, r4 add r3, r6, r4\n\
bic r3, r3, r6 bic r3, r3, r6\n\
ands r3, r3, r5 ands r3, r3, r5\n\
beq 0b beq 0b\n\
" "
#endif /* __ARM_ARCH_5[T][E]__ */ #endif /* __ARM_ARCH_5[T][E]__ */
" "\n\
2: 2:\n\
ldrb r3, [%0] ldrb r3, [%0]\n\
cmp r3, #0x0 cmp r3, #0x0\n\
beq 1f beq 1f\n\
\n\
0: 0:\n\
ldrb r3, [%0, #1]! ldrb r3, [%0, #1]!\n\
" "
PRELOADSTR ("%0") PRELOADSTR ("%0")
" "\n\
cmp r3, #0x0 cmp r3, #0x0\n\
bne 0b bne 0b\n\
1: 1:\n\
" "
: "=r" (str) : "0" (str) : "r2", "r3", "r4", "r5", "r6", "r7"); : "=r" (str) : "0" (str) : "r2", "r3", "r4", "r5", "r6", "r7");