PowerPC: multiarch memcpy for PowerPC32
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Mon, 14 Oct 2013 12:24:12 +0000 (07:24 -0500)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 6 Dec 2013 11:46:59 +0000 (05:46 -0600)
ChangeLog
sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-a2.S [new file with mode: 0644]
sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-cell.S [new file with mode: 0644]
sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-power6.S [new file with mode: 0644]
sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-power7.S [new file with mode: 0644]
sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-ppc32.S [new file with mode: 0644]
sysdeps/powerpc/powerpc32/power4/multiarch/memcpy.c [new file with mode: 0644]

index 1eb914b743cebbaee4626d796daa6e4ee259cc7a..75b6c9df51add6e8b2c75b47fbfaf14a7e883c17 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2013-12-06  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
+
+       * sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-a2.S: New file.
+       * sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-cell.S: New file.
+       * sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-power6.S: New
+       file.
+       * sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-power7.S: New
+       file.
+       * sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-ppc32.S: New
+       file.
+       * sysdeps/powerpc/powerpc32/power4/multiarch/memcpy.c: New file:
+       multiarch memcpy for PPC32.
+       * sysdeps/powerpc/powerpc32/power4/multiarch/Makefile: Add memcpy
+       multiarch objects.
+       * sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
+       (__libc_ifunc_impl_list): Likewise.
+
 2013-12-06  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
 
        * sysdeps/powerpc/powerpc32/power4/multiarch/Makefile: New file to
index af8d49667e93caa1fe6ddba4fc9b119d8f7acd70..79ef7c76f2d38da33cf753ac09ca9c3623c69ef9 100644 (file)
@@ -1,3 +1,4 @@
 ifeq ($(subdir),string)
-sysdep_routines +=
+sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
+                  memcpy-ppc32
 endif
index f4e55aedfa3a053ebe70d41e7c8064664a6c19a2..470439f5aedd1ef27d7d3862fdc31a770a025ec6 100644 (file)
@@ -46,5 +46,19 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
   else if (hwcap & PPC_FEATURE_POWER5)
     hwcap |= PPC_FEATURE_POWER4;
 
+#ifdef SHARED
+  /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memcpy.c.  */
+  IFUNC_IMPL (i, name, memcpy,
+             IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_HAS_VSX,
+                             __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,
+                             __memcpy_power6)
+             IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_CELL_BE,
+                             __memcpy_cell)
+             IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_ppc))
+#endif
+
   return i;
 }
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-a2.S b/sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-a2.S
new file mode 100644 (file)
index 0000000..d5970ad
--- /dev/null
@@ -0,0 +1,38 @@
+/* Optimized memcpy implementation for PowerPC A2.
+   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>
+
+#undef EALIGN
+#define EALIGN(name, alignt, words)                            \
+ .globl C_SYMBOL_NAME(__memcpy_a2);                            \
+ .type C_SYMBOL_NAME(__memcpy_a2),@function;                   \
+ .align ALIGNARG(alignt);                                      \
+ EALIGN_W_##words;                                             \
+ C_LABEL(__memcpy_a2)                                          \
+ cfi_startproc;
+
+#undef END
+#define END(name)                                              \
+ cfi_endproc;                                                  \
+ ASM_SIZE_DIRECTIVE(__memcpy_a2)
+
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(name)
+
+#include <sysdeps/powerpc/powerpc32/a2/memcpy.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-cell.S b/sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-cell.S
new file mode 100644 (file)
index 0000000..9177d25
--- /dev/null
@@ -0,0 +1,38 @@
+/* Optimized memcpy implementation for CELL BE PowerPC.
+   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>
+
+#undef EALIGN
+#define EALIGN(name, alignt, words)                            \
+ .globl C_SYMBOL_NAME(__memcpy_cell);                          \
+ .type C_SYMBOL_NAME(__memcpy_cell),@function;                 \
+ .align ALIGNARG(alignt);                                      \
+ EALIGN_W_##words;                                             \
+ C_LABEL(__memcpy_cell)                                                \
+ cfi_startproc;
+
+#undef END
+#define END(name)                                              \
+ cfi_endproc;                                                  \
+ ASM_SIZE_DIRECTIVE(__memcpy_cell)
+
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(name)
+
+#include <sysdeps/powerpc/powerpc32/cell/memcpy.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-power6.S b/sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-power6.S
new file mode 100644 (file)
index 0000000..a5b243c
--- /dev/null
@@ -0,0 +1,38 @@
+/* Optimized memcpy implementation for PowerPC32 on POWER6.
+   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>
+
+#undef EALIGN
+#define EALIGN(name, alignt, words)                            \
+ .globl C_SYMBOL_NAME(__memcpy_power6);                                \
+ .type C_SYMBOL_NAME(__memcpy_power6),@function;               \
+ .align ALIGNARG(alignt);                                      \
+ EALIGN_W_##words;                                             \
+ C_LABEL(__memcpy_power6)                                      \
+ cfi_startproc;
+
+#undef END
+#define END(name)                                              \
+ cfi_endproc;                                                  \
+ ASM_SIZE_DIRECTIVE(__memcpy_power6)
+
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(name)
+
+#include <sysdeps/powerpc/powerpc32/power6/memcpy.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-power7.S b/sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-power7.S
new file mode 100644 (file)
index 0000000..3605116
--- /dev/null
@@ -0,0 +1,38 @@
+/* Optimized memcpy implementation for PowerPC32/POWER7.
+   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>
+
+#undef EALIGN
+#define EALIGN(name, alignt, words)                            \
+ .globl C_SYMBOL_NAME(__memcpy_power7);                                \
+ .type C_SYMBOL_NAME(__memcpy_power7),@function;               \
+ .align ALIGNARG(alignt);                                      \
+ EALIGN_W_##words;                                             \
+ C_LABEL(__memcpy_power7)                                      \
+ cfi_startproc;
+
+#undef END
+#define END(name)                                              \
+ cfi_endproc;                                                  \
+ ASM_SIZE_DIRECTIVE(__memcpy_power7)
+
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(name)
+
+#include <sysdeps/powerpc/powerpc32/power7/memcpy.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-ppc32.S b/sysdeps/powerpc/powerpc32/power4/multiarch/memcpy-ppc32.S
new file mode 100644 (file)
index 0000000..8fe1121
--- /dev/null
@@ -0,0 +1,41 @@
+/* Default memcpy 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>
+
+#if defined SHARED && !defined NOT_IN_libc
+# undef EALIGN
+# define EALIGN(name, alignt, words)                           \
+  .globl C_SYMBOL_NAME(__memcpy_ppc);                          \
+  .type C_SYMBOL_NAME(__memcpy_ppc),@function;         \
+  .align ALIGNARG(alignt);                                     \
+  EALIGN_W_##words;                                            \
+  C_LABEL(__memcpy_ppc)                                        \
+  cfi_startproc;
+
+# undef END
+# define END(name)                                             \
+  cfi_endproc;                                                 \
+  ASM_SIZE_DIRECTIVE(__memcpy_ppc)
+
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name)                         \
+    .globl __GI_memcpy; __GI_memcpy = __memcpy_ppc
+#endif
+
+#include <sysdeps/powerpc/powerpc32/power4/memcpy.S>
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/memcpy.c b/sysdeps/powerpc/powerpc32/power4/multiarch/memcpy.c
new file mode 100644 (file)
index 0000000..d9c36ad
--- /dev/null
@@ -0,0 +1,45 @@
+/* Multiple versions of memcpy.
+   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 multiple versions only for the definition in lib and for
+   DSO.  In static binaries we need memcpy before the initialization
+   happened.  */
+#if defined SHARED && !defined NOT_IN_libc
+# include <string.h>
+# include <shlib-compat.h>
+# include "init-arch.h"
+
+extern __typeof (memcpy) __memcpy_ppc attribute_hidden;
+extern __typeof (memcpy) __memcpy_cell attribute_hidden;
+extern __typeof (memcpy) __memcpy_power6 attribute_hidden;
+extern __typeof (memcpy) __memcpy_a2 attribute_hidden;
+extern __typeof (memcpy) __memcpy_power7 attribute_hidden;
+
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
+   ifunc symbol properly.  */
+libc_ifunc (memcpy,
+            (hwcap & PPC_FEATURE_HAS_VSX)
+            ? __memcpy_power7 :
+             (hwcap & PPC_FEATURE_ARCH_2_06)
+             ? __memcpy_a2 :
+               (hwcap & PPC_FEATURE_ARCH_2_05)
+               ? __memcpy_power6 :
+                 (hwcap & PPC_FEATURE_CELL_BE)
+                 ? __memcpy_cell
+            : __memcpy_ppc);
+#endif