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

12 files changed:
ChangeLog
sysdeps/powerpc/powerpc32/bzero.S
sysdeps/powerpc/powerpc32/multiarch/Makefile
sysdeps/powerpc/powerpc32/multiarch/bzero-power4.S [new file with mode: 0644]
sysdeps/powerpc/powerpc32/multiarch/bzero-power6.S [new file with mode: 0644]
sysdeps/powerpc/powerpc32/multiarch/bzero-power7.S [new file with mode: 0644]
sysdeps/powerpc/powerpc32/multiarch/bzero.S [new file with mode: 0644]
sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c
sysdeps/powerpc/powerpc32/multiarch/memset-power4.S [moved from sysdeps/powerpc/powerpc32/power4/memset.S with 98% similarity]
sysdeps/powerpc/powerpc32/multiarch/memset-power6.S [moved from sysdeps/powerpc/powerpc32/power6/memset.S with 99% similarity]
sysdeps/powerpc/powerpc32/multiarch/memset-power7.S [moved from sysdeps/powerpc/powerpc32/power7/memset.S with 99% similarity]
sysdeps/powerpc/powerpc32/multiarch/memset.S [new file with mode: 0644]

index e09de03594d80a2148c16fa775a486315d4a12ec..7969bc294fdd0077db0822106c51ce5309419ed5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2013-03-07  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
+
+       * sysdeps/powerpc/powerpc32/bzero.S: Port to multilib.
+       * sysdeps/powerpc/powerpc32/multiarch/Makefile (sysdep_routines):
+       Add memset and bzero implementations.
+       * sysdeps/powerpc/powerpc32/multiarch/memset.S: New file.
+       * sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c: Add bzero
+       and memset.
+       * sysdeps/powerpc/powerpc32/power4/memset.S: Moved to...
+       * sysdeps/powerpc/powerpc32/multiarch/memset-power4.S: ... here.
+       * sysdeps/powerpc/powerpc32/power6/memset.S:  Moved to...
+       * sysdeps/powerpc/powerpc32/multiarch/memset-power6.S:  ... here.
+       * sysdeps/powerpc/powerpc32/power7/memset.S: Moved to...
+       * sysdeps/powerpc/powerpc32/multiarch/memset-power7.S: ... here.
+       * sysdeps/powerpc/powerpc32/multiarch/bzero-power4.S: New file.
+       * sysdeps/powerpc/powerpc32/multiarch/bzero-power6.S: Likewise.
+       * sysdeps/powerpc/powerpc32/multiarch/bzero-power7.S: Likewise.
+
 2013-03-07  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
 
        * sysdeps/powerpc/powerpc32/multiarch/Makefile (sysdep_routines):
index b5699243f42f04ccef28fec6cc83315001eec57f..642d04682eb2a2a3950d18161765b158aded686c 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+/* Let other functions reuse the code of this file.  */
+#ifdef BZERO
+# define __bzero BZERO
+#endif
+
 #include <sysdep.h>
 
-ENTRY (__bzero)
+EALIGN (__bzero, 5, 0)
 
        mr      r5,r4
        li      r4,0
+#ifdef MEMSET_FCNT
+       b       MEMSET_FCNT@local
+#else
        b       memset@local
+#endif
 END (__bzero)
+
+#ifdef BZERO
+libc_hidden_builtin_def (__bzero)
+#else
+# ifndef MEMSET_FCNT
+/* When BZERO and MEMSET_FCTN aren't defined, it means that this is the
+   default definition of bzero.  */
 weak_alias (__bzero, bzero)
+# endif
+#endif
index fb0e53a393fba01b5a40373c749eaf44325c8d75..28d74f172ebb9ce5f8422f974969d28c8160061f 100644 (file)
@@ -1,4 +1,5 @@
 ifeq ($(subdir),string)
 sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
-                  memcmp-power7
+                  memcmp-power7 memset-power4 memset-power6 memset-power7 \
+                  bzero-power4 bzero-power6 bzero-power7
 endif
diff --git a/sysdeps/powerpc/powerpc32/multiarch/bzero-power4.S b/sysdeps/powerpc/powerpc32/multiarch/bzero-power4.S
new file mode 100644 (file)
index 0000000..7b25c77
--- /dev/null
@@ -0,0 +1,22 @@
+/* Optimized bzero implementation for Power4 on 32 bits.
+   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/>.  */
+
+#define BZERO __bzero_power4
+#define MEMSET_FCNT __memset_power4
+
+#include "../bzero.S"
diff --git a/sysdeps/powerpc/powerpc32/multiarch/bzero-power6.S b/sysdeps/powerpc/powerpc32/multiarch/bzero-power6.S
new file mode 100644 (file)
index 0000000..b9ac6ae
--- /dev/null
@@ -0,0 +1,22 @@
+/* Optimized bzero implementation for Power6 on 32 bits.
+   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/>.  */
+
+#define BZERO __bzero_power6
+#define MEMSET_FCNT __memset_power6
+
+#include "../bzero.S"
diff --git a/sysdeps/powerpc/powerpc32/multiarch/bzero-power7.S b/sysdeps/powerpc/powerpc32/multiarch/bzero-power7.S
new file mode 100644 (file)
index 0000000..b41d60c
--- /dev/null
@@ -0,0 +1,22 @@
+/* Optimized bzero implementation for Power7 on 32 bits.
+   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/>.  */
+
+#define BZERO __bzero_power7
+#define MEMSET_FCNT __memset_power7
+
+#include "../bzero.S"
diff --git a/sysdeps/powerpc/powerpc32/multiarch/bzero.S b/sysdeps/powerpc/powerpc32/multiarch/bzero.S
new file mode 100644 (file)
index 0000000..51dbec3
--- /dev/null
@@ -0,0 +1,28 @@
+/* Optimized bzero 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/>.  */
+
+
+#define MEMSET bzero
+#define INTERNAL_MEMSET __bzero
+
+#include "memset.S"
+
+weak_alias (__bzero, bzero)
+
+#define MEMSET_FCNT __memset_ppc32
+#include "../bzero.S"
index ca371beecde47f031a1ca284cfbbc7be0a865597..42b372a4e2a031601b5e838760f4abd14b6489be 100644 (file)
 /* Maximum number of IFUNC implementations.  */
 #define MAX_IFUNC      5
 
+/* Some of the .  */
+#define PPC_POWER4 (PPC_FEATURE_POWER4|PPC_FEATURE_ARCH_2_05|       \
+                   PPC_FEATURE_ARCH_2_06)
+#define PPC_POWER6 (PPC_FEATURE_ARCH_2_05|PPC_FEATURE_ARCH_2_06)
+
 size_t
 __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
                        size_t max)
@@ -37,6 +42,24 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 
   hwcap = GLRO(dl_hwcap);
 
+  IFUNC_IMPL (i, name, bzero,
+             IFUNC_IMPL_ADD (array, i, bzero, hwcap & PPC_FEATURE_HAS_VSX,
+                             __bzero_power7)
+             IFUNC_IMPL_ADD (array, i, bzero, hwcap & PPC_POWER6,
+                             __bzero_power6)
+             IFUNC_IMPL_ADD (array, i, bzero, hwcap & PPC_POWER4,
+                             __bzero_power4)
+             IFUNC_IMPL_ADD (array, i, bzero, 1, __bzero_ppc32))
+
+  IFUNC_IMPL (i, name, memset,
+             IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_HAS_VSX,
+                             __memset_power7)
+             IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_POWER6,
+                             __memset_power6)
+             IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_POWER4,
+                             __memset_power4)
+             IFUNC_IMPL_ADD (array, i, memset, 1, __memset_ppc32))
+
 #ifdef SHARED
   IFUNC_IMPL (i, name, memcmp,
              IFUNC_IMPL_ADD (array, i, memcmp, hwcap & PPC_FEATURE_HAS_VSX,
@@ -48,7 +71,7 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
                              __memcpy_power7)
              IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_06,
                              __memcpy_a2)
-             IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_05,
+             IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_POWER6,
                              __memcpy_power6)
              IFUNC_IMPL_ADD (array, i, memcpy,
                              hwcap & (PPC_FEATURE_CELL_BE >> 16),
similarity index 98%
rename from sysdeps/powerpc/powerpc32/power4/memset.S
rename to sysdeps/powerpc/powerpc32/multiarch/memset-power4.S
index 1e8785cb4a273ff20524be9a12b08951cea6cb7f..6a46e9d1b1c28b6020b1acec639201055455f0f2 100644 (file)
@@ -26,7 +26,7 @@
    to 0, to take advantage of the dcbz instruction.  */
 
        .machine power4
-EALIGN (memset, 5, 0)
+EALIGN (__memset_power4, 5, 0)
        CALL_MCOUNT
 
 #define rTMP   r0
@@ -222,5 +222,4 @@ L(medium_28t):
         stw     rCHR, -4(rMEMP)
        stw     rCHR, -8(rMEMP)
        blr
-END (memset)
-libc_hidden_builtin_def (memset)
+END (__memset_power4)
similarity index 99%
rename from sysdeps/powerpc/powerpc32/power6/memset.S
rename to sysdeps/powerpc/powerpc32/multiarch/memset-power6.S
index ce066300148c0d7f93e0a2e7e035083aaa8de3ec..493c1ef95fe9f60f9b3581ceef5a496844ea8d6b 100644 (file)
@@ -26,7 +26,7 @@
    to 0, to take advantage of the dcbz instruction.  */
 
        .machine power6
-EALIGN (memset, 7, 0)
+EALIGN (__memset_power6, 7, 0)
        CALL_MCOUNT
 
 #define rTMP   r0
@@ -535,5 +535,4 @@ L(medium_28t):
         stw     rCHR, -4(rMEMP)
        stw     rCHR, -8(rMEMP)
        blr
-END (memset)
-libc_hidden_builtin_def (memset)
+END (__memset_power6)
similarity index 99%
rename from sysdeps/powerpc/powerpc32/power7/memset.S
rename to sysdeps/powerpc/powerpc32/multiarch/memset-power7.S
index 360ea717f4e3cad03456f1601907e1526b1e6d72..baa741c11281189283a2762eafa6c31a8b5ca50e 100644 (file)
@@ -23,7 +23,7 @@
    Returns 's'.  */
 
        .machine  power7
-EALIGN (memset, 5, 0)
+EALIGN (__memset_power7, 5, 0)
        CALL_MCOUNT
 
        .align  4
@@ -427,5 +427,4 @@ L(small):
        stw     4,4(10)
        blr
 
-END (memset)
-libc_hidden_builtin_def (memset)
+END (__memset_power7)
diff --git a/sysdeps/powerpc/powerpc32/multiarch/memset.S b/sysdeps/powerpc/powerpc32/multiarch/memset.S
new file mode 100644 (file)
index 0000000..bc95595
--- /dev/null
@@ -0,0 +1,117 @@
+/* Optimized memset 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/>.  */
+
+/* Let other functions reuse the code of this file.  */
+#ifdef MEMSET
+# define memset MEMSET
+#endif
+
+#ifndef INTERNAL_MEMSET
+# define INTERNAL_MEMSET memset
+#endif
+
+#define CONCAT(x, y) __ ## x ## _ ## y
+#define EVALUATE(x, y) CONCAT(x, y)
+#define OPTIM(NAME) EVALUATE(memset, NAME)
+
+#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(INTERNAL_MEMSET)
+       .type   memset, @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)
+       andi.   r7,r6,PPC_FEATURE_ARCH_2_05
+       bne-    L(power6)
+       andis.  r7,r6,(PPC_FEATURE_POWER4>>16)
+       bne-    L(power4)
+# ifdef PIC
+       lwz     r3,OPTIM(ppc32)@got(r5)
+# else
+       lis     r3,OPTIM(ppc32)@ha
+       lwz     r3,OPTIM(ppc32)@l(r3)
+# endif
+       blr
+L(power7):
+# ifdef PIC
+       lwz     r3,OPTIM(power7)@got(r5)
+# else
+       lis     r3,OPTIM(power7)@ha
+       lwz     r3,OPTIM(power7)@l(r3)
+# endif
+       blr
+L(power6):
+# ifdef PIC
+       lwz     r3,OPTIM(power6)@got(r5)
+# else
+       lis     r3,OPTIM(power6)@ha
+       lwz     r3,OPTIM(power6)@l(r3)
+# endif
+       blr
+L(power4):
+# ifdef PIC
+       lwz     r3,OPTIM(power4)@got(r5)
+# else
+       lis     r3,OPTIM(power4)@ha
+       lwz     r3,OPTIM(power4)@l(r3)
+# endif
+       blr
+END(INTERNAL_MEMSET)
+
+# undef EALIGN
+# define EALIGN(name, alignt, words)                           \
+  .globl C_SYMBOL_NAME(OPTIM(ppc32));                          \
+  .type C_SYMBOL_NAME(OPTIM(ppc32)),@function ;                \
+  .align ALIGNARG(alignt);                                     \
+  EALIGN_W_##words;                                            \
+  C_LABEL(OPTIM(ppc32))                                        \
+  cfi_startproc;
+
+# undef END
+# define END(name)                                             \
+  cfi_endproc;                                                 \
+  ASM_SIZE_DIRECTIVE(OPTIM(ppc32))
+
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name)                         \
+  .globl EVALUATE(GI, memset);         EVALUATE(GI, memset) = OPTIM(ppc32)
+
+#endif
+
+#ifndef MEMSET
+# include "../memset.S"
+#endif