Module Name: src
Committed By: matt
Date: Mon Aug 19 17:02:25 UTC 2013
Modified Files:
src/common/lib/libc/arch/arm/string: strcat_naive.S strchr_naive.S
strlen_naive.S strrchr_naive.S
Log Message:
cbnz/cbz can not branch backwards so nuke 'em.
Use the same register usage in strlen as in strnlen
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/arm/string/strcat_naive.S
cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/arm/string/strchr_naive.S \
src/common/lib/libc/arch/arm/string/strrchr_naive.S
cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/arch/arm/string/strlen_naive.S
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/common/lib/libc/arch/arm/string/strcat_naive.S
diff -u src/common/lib/libc/arch/arm/string/strcat_naive.S:1.2 src/common/lib/libc/arch/arm/string/strcat_naive.S:1.3
--- src/common/lib/libc/arch/arm/string/strcat_naive.S:1.2 Mon Aug 19 02:54:02 2013
+++ src/common/lib/libc/arch/arm/string/strcat_naive.S Mon Aug 19 17:02:25 2013
@@ -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__ */
Index: src/common/lib/libc/arch/arm/string/strchr_naive.S
diff -u src/common/lib/libc/arch/arm/string/strchr_naive.S:1.3 src/common/lib/libc/arch/arm/string/strchr_naive.S:1.4
--- src/common/lib/libc/arch/arm/string/strchr_naive.S:1.3 Mon Aug 19 02:22:25 2013
+++ src/common/lib/libc/arch/arm/string/strchr_naive.S Mon Aug 19 17:02:25 2013
@@ -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 @@ ENTRY(strchr)
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
Index: src/common/lib/libc/arch/arm/string/strrchr_naive.S
diff -u src/common/lib/libc/arch/arm/string/strrchr_naive.S:1.3 src/common/lib/libc/arch/arm/string/strrchr_naive.S:1.4
--- src/common/lib/libc/arch/arm/string/strrchr_naive.S:1.3 Mon Aug 19 02:36:27 2013
+++ src/common/lib/libc/arch/arm/string/strrchr_naive.S Mon Aug 19 17:02:25 2013
@@ -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 @@ ENTRY(strrchr)
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 */
Index: src/common/lib/libc/arch/arm/string/strlen_naive.S
diff -u src/common/lib/libc/arch/arm/string/strlen_naive.S:1.7 src/common/lib/libc/arch/arm/string/strlen_naive.S:1.8
--- src/common/lib/libc/arch/arm/string/strlen_naive.S:1.7 Mon Aug 19 02:13:13 2013
+++ src/common/lib/libc/arch/arm/string/strlen_naive.S Mon Aug 19 17:02:25 2013
@@ -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 @@ END(strnlen)
#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 */