]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
PowerPC: Add 32-bit multilib implementation of strlen
authorTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Thu, 7 Mar 2013 19:18:29 +0000 (16:18 -0300)
committerTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Tue, 12 Mar 2013 20:51:21 +0000 (17:51 -0300)
Move and rename specialized strlen implementation to multilib folder and
add IFUNC strlen source.

ChangeLog
sysdeps/powerpc/powerpc32/multiarch/Makefile
sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c
sysdeps/powerpc/powerpc32/multiarch/strlen-power7.S [moved from sysdeps/powerpc/powerpc32/power7/strlen.S with 98% similarity]
sysdeps/powerpc/powerpc32/multiarch/strlen.S [new file with mode: 0644]
sysdeps/powerpc/powerpc32/strlen.S

index d441895323e00f1df84c0862e0e1d84ff3d2e2d2..d4cb6786384ede876e56bb737d117db0568b7c30 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-03-07  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
+
+       * sysdeps/powerpc/powerpc32/multiarch/Makefile (sysdep_routines):
+       Add strlen implementations.
+       * sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c: Add strlen.
+       * sysdeps/powerpc/powerpc32/power7/strlen.S: Moved to...
+       * sysdeps/powerpc/powerpc32/multiarch/strlen-power7.S: ... here.
+       * sysdeps/powerpc/powerpc32/strlen.S: New file.
+
 2013-03-07  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
 
        * sysdeps/powerpc/powerpc32/multiarch/Makefile (sysdep_routines):
index 42c39b215ea775ecc51240566b210e89157f17ca..4d935fecffa383dae6ea727d05b31fb4db6abdf5 100644 (file)
@@ -2,5 +2,5 @@ ifeq ($(subdir),string)
 sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
                   memcmp-power7 memset-power4 memset-power6 memset-power7 \
                   bzero-power4 bzero-power6 bzero-power7 \
-                  strncmp-power7 strncmp-power4
+                  strncmp-power7 strncmp-power4 strlen-power7
 endif
index e5c6354663c191d86c6c9d734e09c94c7068bd3c..aae8d99c744d3f1cc59432288150512e6aa2ea4c 100644 (file)
@@ -78,6 +78,11 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
                              __memcpy_cell)
              IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_ppc32))
 
+  IFUNC_IMPL (i, name, strlen,
+             IFUNC_IMPL_ADD (array, i, strlen, hwcap & PPC_FEATURE_HAS_VSX,
+                               __strlen_power7)
+             IFUNC_IMPL_ADD (array, i, strlen, 1, __strlen_ppc32))
+
   IFUNC_IMPL (i, name, strncmp,
              IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_HAS_VSX,
                              __strncmp_power7)
similarity index 98%
rename from sysdeps/powerpc/powerpc32/power7/strlen.S
rename to sysdeps/powerpc/powerpc32/multiarch/strlen-power7.S
index b71a10f5c7a3fc2e826ca01d469b2ae9f138f884..0a5ed8d2ed1ee6a8c3d5146c076c759efa3e1130 100644 (file)
@@ -21,7 +21,7 @@
 
 /* int [r3] strlen (char *s [r3])  */
        .machine  power7
-ENTRY (strlen)
+EALIGN (__strlen_power7, 5, 0)
        CALL_MCOUNT
        dcbt    0,r3
        clrrwi  r4,r3,2       /* Align the address to word boundary.  */
@@ -91,5 +91,4 @@ L(done):
        srwi    r0,r0,3       /* Convert leading zeroes to bytes.  */
        add     r3,r5,r0      /* Compute final length.  */
        blr
-END (strlen)
-libc_hidden_builtin_def (strlen)
+END (__strlen_power7)
diff --git a/sysdeps/powerpc/powerpc32/multiarch/strlen.S b/sysdeps/powerpc/powerpc32/multiarch/strlen.S
new file mode 100644 (file)
index 0000000..13cf8cd
--- /dev/null
@@ -0,0 +1,82 @@
+/* Optimized strlen implementation for PowerPC32.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+#include <rtld-global-offsets.h>
+
+/* Define multiple versions only for the definition in libc.  */
+#if defined SHARED && !defined NOT_IN_libc
+       .text
+ENTRY(strlen)
+       .type   strlen, @gnu_indirect_function
+# ifdef PIC
+       mflr    r11
+       cfi_register (lr,r11)
+       bcl     20,31,1f
+1:     mflr    r5
+       addis   r5,r5,_GLOBAL_OFFSET_TABLE_-1b@ha
+       addi    r5,r5,_GLOBAL_OFFSET_TABLE_-1b@l
+       lwz     r6,_rtld_global_ro@got(r5)
+       mtlr    r11
+       cfi_same_value (lr)
+       lwz     r6,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET+4(r6)
+# else
+       lis     r6,(_dl_hwcap+4)@ha
+       lwz     r6,(_dl_hwcap+4)@l(r6)
+# endif
+       /* r5 - got pointer | r6 - _dl_hwcap */
+       andi.   r7,r6,PPC_FEATURE_HAS_VSX
+       bne-    L(power7)
+# ifdef PIC
+       lwz     r3,__strlen_ppc32@got(r5)
+# else
+       lis     r3,__strlen_ppc32@ha
+       lwz     r3,__strlen_ppc32@l(r3)
+# endif
+       blr
+L(power7):
+# ifdef PIC
+       lwz     r3,__strlen_power7@got(r5)
+# else
+       lis     r3,__strlen_power7@ha
+       lwz     r3,__strlen_power7@l(r3)
+# endif
+       blr
+END(strlen)
+
+# undef EALIGN
+# define EALIGN(name, alignt, words)                           \
+  .globl C_SYMBOL_NAME(__strlen_ppc32);                        \
+  .type C_SYMBOL_NAME(__strlen_ppc32),@function ;              \
+  .align ALIGNARG(alignt);                                     \
+  EALIGN_W_##words;                                            \
+  C_LABEL(__strlen_ppc32)                                      \
+  cfi_startproc;
+
+# undef END
+# define END(name)                                             \
+  cfi_endproc;                                                 \
+  ASM_SIZE_DIRECTIVE(__strlen_ppc32)
+
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name)                         \
+  .globl __GI_strlen; __GI_strlen = __strlen_ppc32
+
+#endif
+
+#include "../strlen.S"
index 9a6eafc38255028445451373b058b0e5c9e0217e..58b875f2ac7a7075a1b6fad3d5820dcb9a68dfdf 100644 (file)
@@ -70,7 +70,7 @@
 
 /* int [r3] strlen (char *s [r3])  */
 
-ENTRY (strlen)
+EALIGN (strlen, 5, 0)
 
 #define rTMP1  r0
 #define rRTN   r3      /* incoming STR arg, outgoing result */