[ARM] Adding strlen.S

The patch adds strlen.S to contain the complementary preprocessor
logic to strlen-stub.c intended to provide #inclusion of alternative
.S implementations.

Initially we just include the existing strlen-armv7.S implementation.

We rewrite _ISA_ARMV7 in both strlen.S and strlen-stub.c to use the
underlying existing underlying defintion from arm_asm.h in order to
avoide including that file, this is in effect the first step towards a
move to ACLE predefines only.

Tested by building newlib and comparing libc.a binaries before and
after for all permutations of:

      Architectures:
        armv4 armv4t armv5 armv5t armv5te armv6 armv6j armv6k
        armv6z armv6kz armv6t2 armv6-m armv6s-m armv7 armv7-a
        armv7ve armv7-r armv7-m armv7e-m armv8-a iwmmxt iwmmxt2

      ISAs:
        thumb arm

      Optimization Levels:
        Os O2

      Excluding:
        armv6s-m -mthumb
        armv6-m -mthumb

        armv6zk -mthumb
        armv6z -mthumb
        armv6k -mthumb
        armv6j -mthumb
This commit is contained in:
Marcus Shawcroft 2015-11-10 14:08:42 +00:00
parent 42de6f5085
commit bcd5e8e3f9
6 changed files with 78 additions and 29 deletions

View File

@ -1,3 +1,11 @@
2015-11-13 Marcus Shawcroft <marcus.shawcroft@arm.com>
* libc/machine/arm/Makefile.am: Adding strlen.S.
* libc/machine/arm/Makefile.in: Regenerate.
* libc/machine/arm/strlen.S: New.
* libc/machine/arm/strlen-stub.c: Rewrite #if condition.
* libc/machine/arm/strlen-armv7.S: Remove surrounding #if.
2015-11-13 Marcus Shawcroft <marcus.shawcroft@arm.com> 2015-11-13 Marcus Shawcroft <marcus.shawcroft@arm.com>
* libc/machine/arm/Makefile.am: Rename strlen.c to strlen-stub.c * libc/machine/arm/Makefile.am: Rename strlen.c to strlen-stub.c

View File

@ -9,7 +9,7 @@ AM_CCASFLAGS = $(INCLUDES)
noinst_LIBRARIES = lib.a noinst_LIBRARIES = lib.a
lib_a_SOURCES = setjmp.S access.c strcmp.S strcpy.c \ lib_a_SOURCES = setjmp.S access.c strcmp.S strcpy.c \
strlen-armv7.S aeabi_memcpy.c aeabi_memcpy-armv7a.S \ aeabi_memcpy.c aeabi_memcpy-armv7a.S \
aeabi_memmove.c aeabi_memmove-soft.S \ aeabi_memmove.c aeabi_memmove-soft.S \
aeabi_memset.c aeabi_memset-soft.S aeabi_memclr.c aeabi_memset.c aeabi_memset-soft.S aeabi_memclr.c
lib_a_SOURCES += memchr-stub.c lib_a_SOURCES += memchr-stub.c
@ -17,6 +17,7 @@ lib_a_SOURCES += memchr.S
lib_a_SOURCES += memcpy-stub.c lib_a_SOURCES += memcpy-stub.c
lib_a_SOURCES += memcpy.S lib_a_SOURCES += memcpy.S
lib_a_SOURCES += strlen-stub.c lib_a_SOURCES += strlen-stub.c
lib_a_SOURCES += strlen.S
lib_a_CCASFLAGS=$(AM_CCASFLAGS) lib_a_CCASFLAGS=$(AM_CCASFLAGS)
lib_a_CFLAGS = $(AM_CFLAGS) lib_a_CFLAGS = $(AM_CFLAGS)

View File

@ -71,14 +71,15 @@ lib_a_AR = $(AR) $(ARFLAGS)
lib_a_LIBADD = lib_a_LIBADD =
am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-access.$(OBJEXT) \ am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-access.$(OBJEXT) \
lib_a-strcmp.$(OBJEXT) lib_a-strcpy.$(OBJEXT) \ lib_a-strcmp.$(OBJEXT) lib_a-strcpy.$(OBJEXT) \
lib_a-strlen-armv7.$(OBJEXT) lib_a-aeabi_memcpy.$(OBJEXT) \ lib_a-aeabi_memcpy.$(OBJEXT) \
lib_a-aeabi_memcpy-armv7a.$(OBJEXT) \ lib_a-aeabi_memcpy-armv7a.$(OBJEXT) \
lib_a-aeabi_memmove.$(OBJEXT) \ lib_a-aeabi_memmove.$(OBJEXT) \
lib_a-aeabi_memmove-soft.$(OBJEXT) \ lib_a-aeabi_memmove-soft.$(OBJEXT) \
lib_a-aeabi_memset.$(OBJEXT) lib_a-aeabi_memset-soft.$(OBJEXT) \ lib_a-aeabi_memset.$(OBJEXT) lib_a-aeabi_memset-soft.$(OBJEXT) \
lib_a-aeabi_memclr.$(OBJEXT) lib_a-memchr-stub.$(OBJEXT) \ lib_a-aeabi_memclr.$(OBJEXT) lib_a-memchr-stub.$(OBJEXT) \
lib_a-memchr.$(OBJEXT) lib_a-memcpy-stub.$(OBJEXT) \ lib_a-memchr.$(OBJEXT) lib_a-memcpy-stub.$(OBJEXT) \
lib_a-memcpy.$(OBJEXT) lib_a-strlen-stub.$(OBJEXT) lib_a-memcpy.$(OBJEXT) lib_a-strlen-stub.$(OBJEXT) \
lib_a-strlen.$(OBJEXT)
lib_a_OBJECTS = $(am_lib_a_OBJECTS) lib_a_OBJECTS = $(am_lib_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = depcomp =
@ -205,11 +206,11 @@ AUTOMAKE_OPTIONS = cygnus
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
AM_CCASFLAGS = $(INCLUDES) AM_CCASFLAGS = $(INCLUDES)
noinst_LIBRARIES = lib.a noinst_LIBRARIES = lib.a
lib_a_SOURCES = setjmp.S access.c strcmp.S strcpy.c strlen-armv7.S \ lib_a_SOURCES = setjmp.S access.c strcmp.S strcpy.c aeabi_memcpy.c \
aeabi_memcpy.c aeabi_memcpy-armv7a.S aeabi_memmove.c \ aeabi_memcpy-armv7a.S aeabi_memmove.c aeabi_memmove-soft.S \
aeabi_memmove-soft.S aeabi_memset.c aeabi_memset-soft.S \ aeabi_memset.c aeabi_memset-soft.S aeabi_memclr.c \
aeabi_memclr.c memchr-stub.c memchr.S memcpy-stub.c memcpy.S \ memchr-stub.c memchr.S memcpy-stub.c memcpy.S strlen-stub.c \
strlen-stub.c strlen.S
lib_a_CCASFLAGS = $(AM_CCASFLAGS) lib_a_CCASFLAGS = $(AM_CCASFLAGS)
lib_a_CFLAGS = $(AM_CFLAGS) lib_a_CFLAGS = $(AM_CFLAGS)
ACLOCAL_AMFLAGS = -I ../../.. -I ../../../.. ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
@ -295,12 +296,6 @@ lib_a-strcmp.o: strcmp.S
lib_a-strcmp.obj: strcmp.S lib_a-strcmp.obj: strcmp.S
$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-strcmp.obj `if test -f 'strcmp.S'; then $(CYGPATH_W) 'strcmp.S'; else $(CYGPATH_W) '$(srcdir)/strcmp.S'; fi` $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-strcmp.obj `if test -f 'strcmp.S'; then $(CYGPATH_W) 'strcmp.S'; else $(CYGPATH_W) '$(srcdir)/strcmp.S'; fi`
lib_a-strlen-armv7.o: strlen-armv7.S
$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-strlen-armv7.o `test -f 'strlen-armv7.S' || echo '$(srcdir)/'`strlen-armv7.S
lib_a-strlen-armv7.obj: strlen-armv7.S
$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-strlen-armv7.obj `if test -f 'strlen-armv7.S'; then $(CYGPATH_W) 'strlen-armv7.S'; else $(CYGPATH_W) '$(srcdir)/strlen-armv7.S'; fi`
lib_a-aeabi_memcpy-armv7a.o: aeabi_memcpy-armv7a.S lib_a-aeabi_memcpy-armv7a.o: aeabi_memcpy-armv7a.S
$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-aeabi_memcpy-armv7a.o `test -f 'aeabi_memcpy-armv7a.S' || echo '$(srcdir)/'`aeabi_memcpy-armv7a.S $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-aeabi_memcpy-armv7a.o `test -f 'aeabi_memcpy-armv7a.S' || echo '$(srcdir)/'`aeabi_memcpy-armv7a.S
@ -331,6 +326,12 @@ lib_a-memcpy.o: memcpy.S
lib_a-memcpy.obj: memcpy.S lib_a-memcpy.obj: memcpy.S
$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-memcpy.obj `if test -f 'memcpy.S'; then $(CYGPATH_W) 'memcpy.S'; else $(CYGPATH_W) '$(srcdir)/memcpy.S'; fi` $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-memcpy.obj `if test -f 'memcpy.S'; then $(CYGPATH_W) 'memcpy.S'; else $(CYGPATH_W) '$(srcdir)/memcpy.S'; fi`
lib_a-strlen.o: strlen.S
$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-strlen.o `test -f 'strlen.S' || echo '$(srcdir)/'`strlen.S
lib_a-strlen.obj: strlen.S
$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-strlen.obj `if test -f 'strlen.S'; then $(CYGPATH_W) 'strlen.S'; else $(CYGPATH_W) '$(srcdir)/strlen.S'; fi`
.c.o: .c.o:
$(COMPILE) -c $< $(COMPILE) -c $<
@ -385,11 +386,11 @@ lib_a-memcpy-stub.o: memcpy-stub.c
lib_a-memcpy-stub.obj: memcpy-stub.c lib_a-memcpy-stub.obj: memcpy-stub.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memcpy-stub.obj `if test -f 'memcpy-stub.c'; then $(CYGPATH_W) 'memcpy-stub.c'; else $(CYGPATH_W) '$(srcdir)/memcpy-stub.c'; fi` $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memcpy-stub.obj `if test -f 'memcpy-stub.c'; then $(CYGPATH_W) 'memcpy-stub.c'; else $(CYGPATH_W) '$(srcdir)/memcpy-stub.c'; fi`
lib_a-strlen.o: strlen.c lib_a-strlen-stub.o: strlen-stub.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strlen.o `test -f 'strlen.c' || echo '$(srcdir)/'`strlen.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strlen-stub.o `test -f 'strlen-stub.c' || echo '$(srcdir)/'`strlen-stub.c
lib_a-strlen.obj: strlen.c lib_a-strlen-stub.obj: strlen-stub.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strlen.obj `if test -f 'strlen.c'; then $(CYGPATH_W) 'strlen.c'; else $(CYGPATH_W) '$(srcdir)/strlen.c'; fi` $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strlen-stub.obj `if test -f 'strlen-stub.c'; then $(CYGPATH_W) 'strlen-stub.c'; else $(CYGPATH_W) '$(srcdir)/strlen-stub.c'; fi`
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \

View File

@ -34,13 +34,6 @@
#include "arm_asm.h" #include "arm_asm.h"
/* NOTE: This ifdef MUST match the ones in arm/strlen.c
We fallback to the one in arm/strlen.c for size optimised or
for older architectures. */
#if (defined(_ISA_ARM_7) || defined(__ARM_ARCH_6T2__)) && \
!(defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) || \
(defined (__thumb__) && !defined (__thumb2__)))
.macro def_fn f p2align=0 .macro def_fn f p2align=0
.text .text
.p2align \p2align .p2align \p2align
@ -153,5 +146,3 @@ def_fn strlen p2align=6
mov const_0, #0 mov const_0, #0
b .Lstart_realigned b .Lstart_realigned
.size strlen, . - strlen .size strlen, . - strlen
#endif

View File

@ -67,8 +67,8 @@ strlen (const char* str)
#if defined __thumb__ && ! defined __thumb2__ #if defined __thumb__ && ! defined __thumb2__
#include "../../string/strlen.c" #include "../../string/strlen.c"
#elif defined _ISA_ARM_7 || defined __ARM_ARCH_6T2__ #elif (__ARM_ARCH >= 7 && defined __ARM_ARCH_ISA_ARM) || defined __ARM_ARCH_6T2__
/* Implemented in strlen-armv7.S. */ /* Implemented in strlen.S. */
#else #else
size_t __attribute__((naked)) size_t __attribute__((naked))

View File

@ -0,0 +1,48 @@
/* Copyright (c) 2015 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:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Linaro nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"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 THE COPYRIGHT
HOLDER OR CONTRIBUTORS 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 "acle-compat.h"
#if defined __OPTIMIZE_SIZE__ || defined PREFER_SIZE_OVER_SPEED
#if defined __thumb__ && !defined __thumb2__
/* Implemented in strlen-stub.c. */
#else
/* Implemented in strlen-stub.c. */
#endif
#else /* defined __OPTIMIZE_SIZE__ || defined PREFER_SIZE_OVER_SPEED */
#if defined __thumb__ && ! defined __thumb2__
/* Implemented in strlen-stub.c. */
#elif (__ARM_ARCH >= 7 && defined __ARM_ARCH_ISA_ARM) || defined __ARM_ARCH_6T2__
#include "strlen-armv7.S"
#else
/* Implemented in strlen-stub.c. */
#endif
#endif