diff options
author | Roland McGrath <roland@hack.frob.com> | 2013-03-15 09:31:56 -0700 |
---|---|---|
committer | Roland McGrath <roland@hack.frob.com> | 2013-03-15 09:31:56 -0700 |
commit | a7ac752299cb61f3140ab76c6f0a4ed46f52df55 (patch) | |
tree | 52798d8cb03569a69f00b7950dfdbf226415ca09 /ports/sysdeps/arm/armv6 | |
parent | ef26eece6331a1f6d959818e37c438cc7ce68e53 (diff) | |
download | glibc-a7ac752299cb61f3140ab76c6f0a4ed46f52df55.tar.gz glibc-a7ac752299cb61f3140ab76c6f0a4ed46f52df55.tar.xz glibc-a7ac752299cb61f3140ab76c6f0a4ed46f52df55.zip |
ARM: sfi_breg assembler macro
Diffstat (limited to 'ports/sysdeps/arm/armv6')
-rw-r--r-- | ports/sysdeps/arm/armv6/rawmemchr.S | 18 | ||||
-rw-r--r-- | ports/sysdeps/arm/armv6/strchr.S | 18 | ||||
-rw-r--r-- | ports/sysdeps/arm/armv6/strcpy.S | 55 | ||||
-rw-r--r-- | ports/sysdeps/arm/armv6/strlen.S | 18 | ||||
-rw-r--r-- | ports/sysdeps/arm/armv6/strrchr.S | 6 |
5 files changed, 71 insertions, 44 deletions
diff --git a/ports/sysdeps/arm/armv6/rawmemchr.S b/ports/sysdeps/arm/armv6/rawmemchr.S index 7877bcf6d6..b5e4a16f03 100644 --- a/ports/sysdeps/arm/armv6/rawmemchr.S +++ b/ports/sysdeps/arm/armv6/rawmemchr.S @@ -25,7 +25,8 @@ ENTRY (__rawmemchr) @ r0 = start of string @ r1 = character to match @ returns a pointer to the match, which must be present. - ldrb r2, [r0] @ load first byte asap + sfi_breg r0, \ + ldrb r2, [\B] @ load first byte asap @ To cater to long strings, we want to search through a few @ characters until we reach an aligned pointer. To cater to @@ -41,7 +42,8 @@ ENTRY (__rawmemchr) bxeq lr @ Loop until we find ... -1: ldrb r2, [r0, #1]! +1: sfi_breg r0, \ + ldrb r2, [\B, #1]! subs r3, r3, #1 @ ... the alignment point it ne cmpne r2, r1 @ ... or C @@ -54,15 +56,16 @@ ENTRY (__rawmemchr) add r0, r0, #1 @ So now we're aligned. - ldrd r2, r3, [r0], #8 + sfi_breg r0, \ + ldrd r2, r3, [\B], #8 orr r1, r1, r1, lsl #8 @ Replicate C to all bytes #ifdef ARCH_HAS_T2 movw ip, #0x0101 - pld [r0, #64] + sfi_pld r0, #64 movt ip, #0x0101 #else ldr ip, =0x01010101 - pld [r0, #64] + sfi_pld r0, #64 #endif orr r1, r1, r1, lsl #16 @@ -74,10 +77,11 @@ ENTRY (__rawmemchr) eor r3, r3, r1 uqsub8 r2, ip, r2 @ Find C uqsub8 r3, ip, r3 - pld [r0, #128] + sfi_pld r0, #128 orrs r3, r3, r2 @ Test both words for found it eq - ldrdeq r2, r3, [r0], #8 + sfi_breg r0, \ + ldrdeq r2, r3, [\B], #8 beq 2b @ Found something. Disambiguate between first and second words. diff --git a/ports/sysdeps/arm/armv6/strchr.S b/ports/sysdeps/arm/armv6/strchr.S index c856283d53..936c2be666 100644 --- a/ports/sysdeps/arm/armv6/strchr.S +++ b/ports/sysdeps/arm/armv6/strchr.S @@ -25,7 +25,8 @@ ENTRY (strchr) @ r0 = start of string @ r1 = character to match @ returns NULL for no match, or a pointer to the match - ldrb r2, [r0] @ load the first byte asap + sfi_breg r0, \ + ldrb r2, [\B] @ load the first byte asap uxtb r1, r1 @ To cater to long strings, we want to search through a few @@ -42,7 +43,8 @@ ENTRY (strchr) beq 99f @ Loop until we find ... -1: ldrb r2, [r0, #1]! +1: sfi_breg r0, \ + ldrb r2, [\B, #1]! subs r3, r3, #1 @ ... the aligment point it ne cmpne r2, r1 @ ... or the character @@ -65,15 +67,16 @@ ENTRY (strchr) cfi_rel_offset (r6, 8) cfi_rel_offset (r7, 12) - ldrd r2, r3, [r0], #8 + sfi_breg r0, \ + ldrd r2, r3, [\B], #8 orr r1, r1, r1, lsl #8 @ Replicate C to all bytes #ifdef ARCH_HAS_T2 movw ip, #0x0101 - pld [r0, #64] + sfi_pld r0, #64 movt ip, #0x0101 #else ldr ip, =0x01010101 - pld [r0, #64] + sfi_pld r0, #64 #endif orr r1, r1, r1, lsl #16 @@ -87,13 +90,14 @@ ENTRY (strchr) uqsub8 r5, ip, r3 eor r7, r3, r1 uqsub8 r6, ip, r6 @ Find C - pld [r0, #128] @ Prefetch 2 lines ahead + sfi_pld r0, #128 @ Prefetch 2 lines ahead uqsub8 r7, ip, r7 orr r4, r4, r6 @ Combine found for EOS and C orr r5, r5, r7 orrs r6, r4, r5 @ Combine the two words it eq - ldrdeq r2, r3, [r0], #8 + sfi_breg r0, \ + ldrdeq r2, r3, [\B], #8 beq 2b @ Found something. Disambiguate between first and second words. diff --git a/ports/sysdeps/arm/armv6/strcpy.S b/ports/sysdeps/arm/armv6/strcpy.S index 41f6443319..cd13ff7ecf 100644 --- a/ports/sysdeps/arm/armv6/strcpy.S +++ b/ports/sysdeps/arm/armv6/strcpy.S @@ -44,8 +44,8 @@ ENTRY (strcpy) @ Signal strcpy with DEST in IP. mov ip, r0 0: - pld [r0] - pld [r1] + sfi_pld r0 + sfi_pld r1 @ To cater to long strings, we want 8 byte alignment in the source. @ To cater to small strings, we don't want to start that right away. @@ -54,9 +54,11 @@ ENTRY (strcpy) rsb r3, r3, #16 @ Loop until we find ... -1: ldrb r2, [r1], #1 +1: sfi_breg r1, \ + ldrb r2, [\B], #1 subs r3, r3, #1 @ ... the alignment point - strb r2, [r0], #1 + sfi_breg r0, \ + strb r2, [\B], #1 it ne cmpne r2, #0 @ ... or EOS bne 1b @@ -66,9 +68,10 @@ ENTRY (strcpy) beq .Lreturn @ Load the next two words asap - ldrd r2, r3, [r1], #8 - pld [r0, #64] - pld [r1, #64] + sfi_breg r1, \ + ldrd r2, r3, [\B], #8 + sfi_pld r0, #64 + sfi_pld r1, #64 @ For longer strings, we actaully need a stack frame. push { r4, r5, r6, r7 } @@ -96,15 +99,18 @@ ENTRY (strcpy) .balign 16 2: uqsub8 r4, r7, r2 @ Find EOS uqsub8 r5, r7, r3 - pld [r1, #128] + sfi_pld r1, #128 cmp r4, #0 @ EOS in first word? - pld [r0, #128] + sfi_pld r0, #128 bne 3f - str r2, [r0], #4 + sfi_breg r0, \ + str r2, [\B], #4 cmp r5, #0 @ EOS in second word? bne 4f - str r3, [r0], #4 - ldrd r2, r3, [r1], #8 + sfi_breg r0, \ + str r3, [\B], #4 + sfi_breg r1, \ + ldrd r2, r3, [\B], #8 b 2b 3: sub r1, r1, #4 @ backup to first word @@ -114,9 +120,11 @@ ENTRY (strcpy) @ Note that we generally back up and re-read source bytes, @ but we'll not re-write dest bytes. .Lbyte_loop: - ldrb r2, [r1], #1 + sfi_breg r1, \ + ldrb r2, [\B], #1 cmp r2, #0 - strb r2, [r0], #1 + sfi_breg r0, \ + strb r2, [\B], #1 bne .Lbyte_loop pop { r4, r5, r6, r7 } @@ -161,7 +169,8 @@ ENTRY (strcpy) @ Store a few bytes from the first word. @ At the same time we align r0 and shift out bytes from r2. .rept 4-\unalign - strb r2, [r0], #1 + sfi_breg r0, \ + strb r2, [\B], #1 lsr r2, r2, #8 .endr #ifdef __ARMEB__ @@ -176,20 +185,23 @@ ENTRY (strcpy) orr r2, r2, r3, lsh_gt #(\unalign*8) @ Save leftover bytes from the two words lsh_ls r6, r3, #((4-\unalign)*8) - str r2, [r0], #4 + sfi_breg r0, \ + str r2, [\B], #4 @ The "real" start of the unaligned copy loop. - ldrd r2, r3, [r1], #8 @ Load 8 more bytes + sfi_breg r1, \ + ldrd r2, r3, [\B], #8 @ Load 8 more bytes uqsub8 r4, r7, r2 @ Find EOS - pld [r1, #128] + sfi_pld r1, #128 uqsub8 r5, r7, r3 - pld [r0, #128] + sfi_pld r0, #128 mvns r4, r4 @ EOS in first word? bne 3f @ Combine the leftover and the first word orr r6, r6, r2, lsh_gt #(\unalign*8) @ Discard used bytes from the first word. lsh_ls r2, r2, #((4-\unalign)*8) - str r6, [r0], #4 + sfi_breg r0, \ + str r6, [\B], #4 b 1b @ Found EOS in one of the words; adjust backward 3: sub r1, r1, #4 @@ -200,7 +212,8 @@ ENTRY (strcpy) rev r2, r2 #endif .rept \unalign - strb r2, [r0], #1 + sfi_breg r0, \ + strb r2, [\B], #1 lsr r2, r2, #8 .endr b .Lbyte_loop diff --git a/ports/sysdeps/arm/armv6/strlen.S b/ports/sysdeps/arm/armv6/strlen.S index a53d41418a..59ff6b5d93 100644 --- a/ports/sysdeps/arm/armv6/strlen.S +++ b/ports/sysdeps/arm/armv6/strlen.S @@ -23,7 +23,8 @@ ENTRY (strlen) @ r0 = start of string - ldrb r2, [r0] @ load the first byte asap + sfi_breg r0, \ + ldrb r2, [\B] @ load the first byte asap @ To cater to long strings, we want to search through a few @ characters until we reach an aligned pointer. To cater to @@ -38,7 +39,8 @@ ENTRY (strlen) beq 99f @ Loop until we find ... -1: ldrb r2, [r0, #1]! +1: sfi_breg r0, \ + ldrb r2, [\B, #1]! subs r3, r3, #1 @ ... the aligment point it ne cmpne r2, #0 @ ... or EOS @@ -50,14 +52,15 @@ ENTRY (strlen) add r0, r0, #1 @ So now we're aligned. - ldrd r2, r3, [r0], #8 + sfi_breg r0, \ + ldrd r2, r3, [\B], #8 #ifdef ARCH_HAS_T2 movw ip, #0x0101 - pld [r0, #64] + sfi_pld r0, #64 movt ip, #0x0101 #else ldr ip, =0x01010101 - pld [r0, #64] + sfi_pld r0, #64 #endif @ Loop searching for EOS, 8 bytes at a time. @@ -67,10 +70,11 @@ ENTRY (strlen) .balign 16 2: uqsub8 r2, ip, r2 @ Find EOS uqsub8 r3, ip, r3 - pld [r0, #128] @ Prefetch 2 lines ahead + sfi_pld r0, #128 @ Prefetch 2 lines ahead orrs r3, r3, r2 @ Combine the two words it eq - ldrdeq r2, r3, [r0], #8 + sfi_breg r0, \ + ldrdeq r2, r3, [\B], #8 beq 2b @ Found something. Disambiguate between first and second words. diff --git a/ports/sysdeps/arm/armv6/strrchr.S b/ports/sysdeps/arm/armv6/strrchr.S index ddd4f7fc06..e40df90a72 100644 --- a/ports/sysdeps/arm/armv6/strrchr.S +++ b/ports/sysdeps/arm/armv6/strrchr.S @@ -33,7 +33,8 @@ ENTRY (strrchr) @ Loop a few times until we're aligned. tst r3, #7 beq 2f -1: ldrb r2, [r3], #1 +1: sfi_breg r3, \ + ldrb r2, [\B], #1 cmp r2, r1 @ Find the character it eq subeq r0, r3, #1 @@ -64,7 +65,8 @@ ENTRY (strrchr) @ Loop searching for EOS and C, 8 bytes at a time. @ Any time we find a match in a word, we copy the address of @ the word to r0, and the found bits to r2. -3: ldrd r4, r5, [r3], #8 +3: sfi_breg r3, \ + ldrd r4, r5, [\B], #8 @ Subtracting (unsigned saturating) from 1 means result of 1 for @ any byte that was originally zero and 0 otherwise. Therefore @ we consider the lsb of each byte the "found" bit. |