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 cbnz/cbz can not branch back...
details: https://anonhg.NetBSD.org/src/rev/c5012783cd23
branches: trunk
changeset: 789462:c5012783cd23
user: matt <matt%NetBSD.org@localhost>
date: Mon Aug 19 17:02:25 2013 +0000
description:
cbnz/cbz can not branch backwards so nuke 'em.
Use the same register usage in strlen as in strnlen
diffstat:
common/lib/libc/arch/arm/string/strcat_naive.S | 10 +---------
common/lib/libc/arch/arm/string/strchr_naive.S | 6 +-----
common/lib/libc/arch/arm/string/strlen_naive.S | 12 ++++++------
common/lib/libc/arch/arm/string/strrchr_naive.S | 6 +-----
4 files changed, 9 insertions(+), 25 deletions(-)
diffs (120 lines):
diff -r ec59d24b341e -r c5012783cd23 common/lib/libc/arch/arm/string/strcat_naive.S
--- a/common/lib/libc/arch/arm/string/strcat_naive.S Mon Aug 19 16:34:29 2013 +0000
+++ b/common/lib/libc/arch/arm/string/strcat_naive.S Mon Aug 19 17:02:25 2013 +0000
@@ -29,30 +29,22 @@
#include <machine/asm.h>
-RCSID("$NetBSD: strcat_naive.S,v 1.2 2013/08/19 02:54:02 matt Exp $")
+RCSID("$NetBSD: strcat_naive.S,v 1.3 2013/08/19 17:02:25 matt Exp $")
ENTRY(strcat)
mov ip, r0 /* need to preserve r0 */
#if defined(__thumb__)
1: ldrb r2, [r0] /* load next byte */
adds r0, r0, #1 /* advance */
-#if defined(_ARM_ARCH_T2)
- cbnz r2, 1b /* was it a NUL? no, get next byte */
-#else
cmp r2, #0 /* was it a NUL? */
bne 1b /* no, get next byte */
-#endif
subs r0, r0, #1 /* back up one to the NUL */
subs r1, r1, r0 /* save one increment */
2: ldrb r2, [r1, r0] /* load next byte from append */
strb r2, [r0] /* store it */
adds r0, r0, #1 /* advance */
-#if defined(_ARM_ARCH_T2)
- cbnz r2, 1b /* was it a NUL? no, get next byte */
-#else
cmp r2, #0 /* was it a NUL? */
bne 2b /* no, get next byte */
-#endif
mov r0, ip /* restore dst address */
RET /* return */
#else /* !__thumb__ */
diff -r ec59d24b341e -r c5012783cd23 common/lib/libc/arch/arm/string/strchr_naive.S
--- a/common/lib/libc/arch/arm/string/strchr_naive.S Mon Aug 19 16:34:29 2013 +0000
+++ b/common/lib/libc/arch/arm/string/strchr_naive.S Mon Aug 19 17:02:25 2013 +0000
@@ -28,7 +28,7 @@
*/
#include <machine/asm.h>
-RCSID("$NetBSD: strchr_naive.S,v 1.3 2013/08/19 02:22:25 matt Exp $")
+RCSID("$NetBSD: strchr_naive.S,v 1.4 2013/08/19 17:02:25 matt Exp $")
/* LINTSTUB: char * strchr(const char *, int) */
ENTRY(strchr)
@@ -39,12 +39,8 @@
cmp r3, r1 /* does it match? */
beq 2f /* yes, set return value */
adds r0, r0, #1 /* advance to next byte */
-#ifdef _ARM_ARCH_T2
- cbnz r3, 1b /* was it a NUL? no, get next byte */
-#else
cmp r3, #0 /* was it a NUL? */
bne 1b /* no, get next byte */
-#endif
movs r0, #0 /* set return to NULL */
2: RET /* return */
#else
diff -r ec59d24b341e -r c5012783cd23 common/lib/libc/arch/arm/string/strlen_naive.S
--- a/common/lib/libc/arch/arm/string/strlen_naive.S Mon Aug 19 16:34:29 2013 +0000
+++ b/common/lib/libc/arch/arm/string/strlen_naive.S Mon Aug 19 17:02:25 2013 +0000
@@ -28,7 +28,7 @@
*/
#include <machine/asm.h>
-RCSID("$NetBSD: strlen_naive.S,v 1.7 2013/08/19 02:13:13 matt Exp $")
+RCSID("$NetBSD: strlen_naive.S,v 1.8 2013/08/19 17:02:25 matt Exp $")
#ifdef STRNLEN
/* LINTSTUB: size_t strnlen(const char *, size_t) */
@@ -58,17 +58,17 @@
#else /* STRNLEN */
/* LINTSTUB: size_t strlen(const char *) */
ENTRY(strlen)
- adds r2, r0, #1 /* start of src + NUL */
+ adds r3, r0, #1 /* start of src + NUL */
1:
#ifdef __thumb__
- ldrb r3, [r0] /* read a byte */
+ ldrb r2, [r0] /* read a byte */
adds r0, r0, #1
#else
- ldrb r3, [r0], #1 /* read a byte */
+ ldrb r2, [r0], #1 /* read a byte */
#endif
- cmp r3, #0 /* is it a NUL? */
+ cmp r2, #0 /* is it a NUL? */
bne 1b /* no, get next byte */
- subs r0, r0, r2 /* return difference between start and end */
+ subs r0, r0, r3 /* return difference between start and end */
RET
END(strlen)
#endif /* !STRNLEN */
diff -r ec59d24b341e -r c5012783cd23 common/lib/libc/arch/arm/string/strrchr_naive.S
--- a/common/lib/libc/arch/arm/string/strrchr_naive.S Mon Aug 19 16:34:29 2013 +0000
+++ b/common/lib/libc/arch/arm/string/strrchr_naive.S Mon Aug 19 17:02:25 2013 +0000
@@ -28,7 +28,7 @@
*/
#include <machine/asm.h>
-RCSID("$NetBSD: strrchr_naive.S,v 1.3 2013/08/19 02:36:27 matt Exp $")
+RCSID("$NetBSD: strrchr_naive.S,v 1.4 2013/08/19 17:02:25 matt Exp $")
/* LINTSTUB: char * strrchr(const char *, int) */
ENTRY(strrchr)
@@ -42,12 +42,8 @@
bne 2f /* no, go and advance */
mov r0, r2 /* yes, set return value to point to it */
2: adds r2, r2, #1 /* advance to next byte */
-#ifdef _ARM_ARCH_T2
- cbnz r3, 1b /* was it a NUL? no, get next byte */
-#else
cmp r3, #0 /* was it a NUL? */
bne 1b /* no, get next byte */
-#endif
#else
and r1, r1, #0xff /* restrict to a byte value */
1: ldrb r3, [r2], #1 /* read a byte */
Home |
Main Index |
Thread Index |
Old Index