Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add an assembler version of strcmp, based on example code fr...



details:   https://anonhg.NetBSD.org/src/rev/f9434389c2a9
branches:  trunk
changeset: 539411:f9434389c2a9
user:      rearnsha <rearnsha%NetBSD.org@localhost>
date:      Sat Nov 16 18:27:40 2002 +0000

description:
Add an assembler version of strcmp, based on example code from the ARM
ARM.  As an example of the performance difference that this provides
a Dhrystone score on my Shark goes from 213k to 261k.

diffstat:

 lib/libc/arch/arm/string/Makefile.inc |   6 ++--
 lib/libc/arch/arm/string/strcmp.S     |  45 +++++++++++++++++++++++++++++++++++
 sys/lib/libkern/arch/arm/Makefile.inc |   6 ++--
 sys/lib/libkern/arch/arm/strcmp.S     |  45 +++++++++++++++++++++++++++++++++++
 4 files changed, 96 insertions(+), 6 deletions(-)

diffs (130 lines):

diff -r 4ca3e45b3dd4 -r f9434389c2a9 lib/libc/arch/arm/string/Makefile.inc
--- a/lib/libc/arch/arm/string/Makefile.inc     Sat Nov 16 17:22:36 2002 +0000
+++ b/lib/libc/arch/arm/string/Makefile.inc     Sat Nov 16 18:27:40 2002 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile.inc,v 1.2 2001/11/11 22:05:18 chris Exp $
+# $NetBSD: Makefile.inc,v 1.3 2002/11/16 18:28:52 rearnsha Exp $
 
-SRCS+=  memcpy.S _memcpy.S bcopy.S memmove.S memset.S bzero.S ffs.S
+SRCS+=  memcpy.S _memcpy.S bcopy.S memmove.S memset.S bzero.S ffs.S strcmp.S
 SRCS+= bcmp.c index.c memchr.c memcmp.c \
-       rindex.c strcat.c strcmp.c strcpy.c strcspn.c strlen.c \
+       rindex.c strcat.c strcpy.c strcspn.c strlen.c \
        strncat.c strncmp.c strncpy.c strpbrk.c strsep.c \
        strspn.c strstr.c swab.c
 
diff -r 4ca3e45b3dd4 -r f9434389c2a9 lib/libc/arch/arm/string/strcmp.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/arm/string/strcmp.S Sat Nov 16 18:27:40 2002 +0000
@@ -0,0 +1,45 @@
+/*      $NetBSD: strcmp.S,v 1.1 2002/11/16 18:28:52 rearnsha Exp $ */
+
+/*
+ * Copyright (c) 2002 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(strcmp)
+.Loop:
+       ldrb    r2, [r0], #1
+       ldrb    r3, [r1], #1
+       cmp     r2, #1
+       cmpcs   r2, r3
+       beq     .Loop
+       sub     r0, r2, r3
+#ifdef __APCS_26__
+        movs   pc, lr
+#else
+       mov     pc, lr
+#endif
diff -r 4ca3e45b3dd4 -r f9434389c2a9 sys/lib/libkern/arch/arm/Makefile.inc
--- a/sys/lib/libkern/arch/arm/Makefile.inc     Sat Nov 16 17:22:36 2002 +0000
+++ b/sys/lib/libkern/arch/arm/Makefile.inc     Sat Nov 16 18:27:40 2002 +0000
@@ -1,10 +1,10 @@
-#      $NetBSD: Makefile.inc,v 1.4 2002/08/17 01:22:33 chris Exp $
+#      $NetBSD: Makefile.inc,v 1.5 2002/11/16 18:27:40 rearnsha Exp $
 
 SRCS+= __assert.c __main.c bswap64.c byte_swap_2.S byte_swap_4.S \
        ffs.S imax.c imin.c lmax.c lmin.c max.c min.c random.c scanc.c \
-       skpc.c strcat.c strcmp.c strcasecmp.c \
+       skpc.c strcat.c strcasecmp.c \
        strcpy.c strlen.c strncasecmp.c strncmp.c \
        strncpy.c strtoul.c ulmax.c ulmin.c
 
 SRCS+= divsi3.S
-SRCS+= memchr.c memcmp.c memcpy.S memset.S memmove.S
+SRCS+= memchr.c memcmp.c memcpy.S memset.S memmove.S strcmp.S
diff -r 4ca3e45b3dd4 -r f9434389c2a9 sys/lib/libkern/arch/arm/strcmp.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/lib/libkern/arch/arm/strcmp.S Sat Nov 16 18:27:40 2002 +0000
@@ -0,0 +1,45 @@
+/*      $NetBSD: strcmp.S,v 1.1 2002/11/16 18:27:40 rearnsha Exp $ */
+
+/*
+ * Copyright (c) 2002 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(strcmp)
+.Loop:
+       ldrb    r2, [r0], #1
+       ldrb    r3, [r1], #1
+       cmp     r2, #1
+       cmpcs   r2, r3
+       beq     .Loop
+       sub     r0, r2, r3
+#ifdef __APCS_26__
+        movs   pc, lr
+#else
+       mov     pc, lr
+#endif



Home | Main Index | Thread Index | Old Index