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.
This commit is contained in:
rearnsha 2002-11-16 18:27:40 +00:00
parent c1058540a3
commit 6576c49b48
4 changed files with 96 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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