5de29b
From 46450f90b70326319f8dc7f0e447e14f0cbd95e6 Mon Sep 17 00:00:00 2001
5de29b
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
5de29b
Date: Wed, 30 Jul 2014 05:01:14 -0500
5de29b
Subject: [PATCH] PowerPC: multiarch memcpy for PowerPC64
5de29b
5de29b
commit b5beafbceec80b5a33d3383dde88196afc966e67 Author:
5de29b
 Adhemerval Zanella <azanella@linux.vnet.ibm.com> Date:   Fri Dec 13 14:31:41
5de29b
 2013 -0500
5de29b
5de29b
    PowerPC: multiarch memcpy for PowerPC64
5de29b
5de29b
Added sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h which was not part
5de29b
of original commit
5de29b
---
5de29b
 .../powerpc/powerpc32/power4/multiarch/init-arch.h | 52 +++++++++++++++++
5de29b
 sysdeps/powerpc/powerpc64/multiarch/Makefile       |  4 ++
5de29b
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  | 66 ++++++++++++++++++++++
5de29b
 sysdeps/powerpc/powerpc64/multiarch/init-arch.h    | 18 ++++++
5de29b
 sysdeps/powerpc/powerpc64/multiarch/memcpy-a2.S    | 39 +++++++++++++
5de29b
 sysdeps/powerpc/powerpc64/multiarch/memcpy-cell.S  | 39 +++++++++++++
5de29b
 .../powerpc/powerpc64/multiarch/memcpy-power4.S    | 39 +++++++++++++
5de29b
 .../powerpc/powerpc64/multiarch/memcpy-power6.S    | 39 +++++++++++++
5de29b
 .../powerpc/powerpc64/multiarch/memcpy-power7.S    | 39 +++++++++++++
5de29b
 sysdeps/powerpc/powerpc64/multiarch/memcpy-ppc64.S | 41 ++++++++++++++
5de29b
 sysdeps/powerpc/powerpc64/multiarch/memcpy.c       | 55 ++++++++++++++++++
5de29b
 11 files changed, 431 insertions(+)
5de29b
 create mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/Makefile
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/init-arch.h
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/memcpy-a2.S
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/memcpy-cell.S
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/memcpy-power4.S
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/memcpy-power6.S
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/memcpy-power7.S
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/memcpy-ppc64.S
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/memcpy.c
5de29b
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h
5de29b
new file mode 100644
5de29b
index 0000000..51a34f2
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h
5de29b
@@ -0,0 +1,52 @@
5de29b
+/* This file is part of the GNU C Library.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <ldsodefs.h>
5de29b
+
5de29b
+/* The code checks if _rtld_global_ro was realocated before trying to access
5de29b
+   the dl_hwcap field. The assembly is to make the compiler not optimize the
5de29b
+   test (&_rtld_global_ro != NULL), which is always true in ISO C (but not
5de29b
+   in that case since _rtld_global_ro might not been realocated yet).  */
5de29b
+#if defined(SHARED) && !defined(IS_IN_rtld)
5de29b
+# define __GLRO(value) \
5de29b
+  ({ volatile void **__p = (volatile void**)(&_rtld_global_ro);	\
5de29b
+    unsigned long int __ret;					\
5de29b
+     asm ("# x in %0" : "+r" (__p));				\
5de29b
+     __ret = (__p) ? GLRO(value) : 0;				\
5de29b
+     __ret; })
5de29b
+#else
5de29b
+# define __GLRO(value)  GLRO(value)
5de29b
+#endif
5de29b
+
5de29b
+/* dl_hwcap contains only the latest supported ISA, the macro checks which is
5de29b
+   and fills the previous ones.  */
5de29b
+#define INIT_ARCH() \
5de29b
+  unsigned long int hwcap = __GLRO(dl_hwcap); 			\
5de29b
+  if (hwcap & PPC_FEATURE_ARCH_2_06)				\
5de29b
+    hwcap |= PPC_FEATURE_ARCH_2_05 |				\
5de29b
+	     PPC_FEATURE_POWER5_PLUS |				\
5de29b
+	     PPC_FEATURE_POWER5 |				\
5de29b
+	     PPC_FEATURE_POWER4;				\
5de29b
+  else if (hwcap & PPC_FEATURE_ARCH_2_05)			\
5de29b
+    hwcap |= PPC_FEATURE_POWER5_PLUS |				\
5de29b
+	     PPC_FEATURE_POWER5 |				\
5de29b
+	     PPC_FEATURE_POWER4;				\
5de29b
+  else if (hwcap & PPC_FEATURE_POWER5_PLUS)			\
5de29b
+    hwcap |= PPC_FEATURE_POWER5 |				\
5de29b
+	     PPC_FEATURE_POWER4;				\
5de29b
+  else if (hwcap & PPC_FEATURE_POWER5)				\
5de29b
+    hwcap |= PPC_FEATURE_POWER4;
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
5de29b
new file mode 100644
5de29b
index 0000000..638c102
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
5de29b
@@ -0,0 +1,4 @@
5de29b
+ifeq ($(subdir),string)
5de29b
+sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
5de29b
+                  memcpy-power4 memcpy-ppc64
5de29b
+endif
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
5de29b
new file mode 100644
5de29b
index 0000000..5090af4
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
5de29b
@@ -0,0 +1,66 @@
5de29b
+/* Enumerate available IFUNC implementations of a function.  PowerPC64 version.
5de29b
+   Copyright (C) 2013 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <assert.h>
5de29b
+#include <string.h>
5de29b
+#include <wchar.h>
5de29b
+#include <ldsodefs.h>
5de29b
+#include <ifunc-impl-list.h>
5de29b
+
5de29b
+/* Maximum number of IFUNC implementations.  */
5de29b
+#define MAX_IFUNC      6
5de29b
+
5de29b
+size_t
5de29b
+__libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
5de29b
+                       size_t max)
5de29b
+{
5de29b
+  assert (max >= MAX_IFUNC);
5de29b
+
5de29b
+  size_t i = 0;
5de29b
+
5de29b
+  unsigned long int hwcap = GLRO(dl_hwcap);
5de29b
+  /* hwcap contains only the latest supported ISA, the code checks which is
5de29b
+     and fills the previous supported ones.  */
5de29b
+  if (hwcap & PPC_FEATURE_ARCH_2_06)
5de29b
+    hwcap |= PPC_FEATURE_ARCH_2_05 | PPC_FEATURE_POWER5_PLUS |
5de29b
+             PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
5de29b
+  else if (hwcap & PPC_FEATURE_ARCH_2_05)
5de29b
+    hwcap |= PPC_FEATURE_POWER5_PLUS | PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
5de29b
+  else if (hwcap & PPC_FEATURE_POWER5_PLUS)
5de29b
+    hwcap |= PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
5de29b
+  else if (hwcap & PPC_FEATURE_POWER5)
5de29b
+    hwcap |= PPC_FEATURE_POWER4;
5de29b
+
5de29b
+#ifdef SHARED
5de29b
+  /* Support sysdeps/powerpc/powerpc64/multiarch/memcpy.c.  */
5de29b
+  IFUNC_IMPL (i, name, memcpy,
5de29b
+             IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_HAS_VSX,
5de29b
+                             __memcpy_power7)
5de29b
+             IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_06,
5de29b
+                             __memcpy_a2)
5de29b
+             IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_05,
5de29b
+                             __memcpy_power6)
5de29b
+             IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_CELL_BE,
5de29b
+                             __memcpy_cell)
5de29b
+             IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_POWER4,
5de29b
+                             __memcpy_power4)
5de29b
+             IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_ppc))
5de29b
+#endif
5de29b
+
5de29b
+  return i;
5de29b
+}
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/init-arch.h glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/init-arch.h
5de29b
new file mode 100644
5de29b
index 0000000..b7d238c
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/init-arch.h
5de29b
@@ -0,0 +1,18 @@
5de29b
+/* This file is part of the GNU C Library.
5de29b
+   Copyright (C) 2013 Free Software Foundation, Inc.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-a2.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-a2.S
5de29b
new file mode 100644
5de29b
index 0000000..2d5bfa9
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-a2.S
5de29b
@@ -0,0 +1,39 @@
5de29b
+/* Optimized memcpy implementation for PowerPC A2.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <sysdep.h>
5de29b
+
5de29b
+#undef EALIGN
5de29b
+#define EALIGN(name, alignt, words)				\
5de29b
+  .section ".text";						\
5de29b
+  ENTRY_2(__memcpy_a2)						\
5de29b
+  .align ALIGNARG(alignt);					\
5de29b
+  EALIGN_W_##words;						\
5de29b
+  BODY_LABEL(__memcpy_a2):					\
5de29b
+  cfi_startproc;
5de29b
+
5de29b
+#undef END_GEN_TB
5de29b
+#define END_GEN_TB(name, mask)					\
5de29b
+  cfi_endproc;							\
5de29b
+  TRACEBACK_MASK(__memcpy_a2,mask)				\
5de29b
+  END_2(__memcpy_a2)
5de29b
+
5de29b
+#undef libc_hidden_builtin_def
5de29b
+#define libc_hidden_builtin_def(name)
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc64/a2/memcpy.S>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-cell.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-cell.S
5de29b
new file mode 100644
5de29b
index 0000000..92c06be
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-cell.S
5de29b
@@ -0,0 +1,39 @@
5de29b
+/* Optimized memcpy implementation for PowerPC/CELL.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <sysdep.h>
5de29b
+
5de29b
+#undef EALIGN
5de29b
+#define EALIGN(name, alignt, words)				\
5de29b
+  .section ".text";						\
5de29b
+  ENTRY_2(__memcpy_cell)					\
5de29b
+  .align ALIGNARG(alignt);					\
5de29b
+  EALIGN_W_##words;						\
5de29b
+  BODY_LABEL(__memcpy_cell):					\
5de29b
+  cfi_startproc;
5de29b
+
5de29b
+#undef END_GEN_TB
5de29b
+#define END_GEN_TB(name, mask)					\
5de29b
+  cfi_endproc;							\
5de29b
+  TRACEBACK_MASK(__memcpy_cell,mask)				\
5de29b
+  END_2(__memcpy_cell)
5de29b
+
5de29b
+#undef libc_hidden_builtin_def
5de29b
+#define libc_hidden_builtin_def(name)
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc64/cell/memcpy.S>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-power4.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-power4.S
5de29b
new file mode 100644
5de29b
index 0000000..eb01d67
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-power4.S
5de29b
@@ -0,0 +1,39 @@
5de29b
+/* Optimized memcpy implementation for PowerPC64/POWER4.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <sysdep.h>
5de29b
+
5de29b
+#undef EALIGN
5de29b
+#define EALIGN(name, alignt, words)				\
5de29b
+  .section ".text";						\
5de29b
+  ENTRY_2(__memcpy_power4)					\
5de29b
+  .align ALIGNARG(alignt);					\
5de29b
+  EALIGN_W_##words;						\
5de29b
+  BODY_LABEL(__memcpy_power4):					\
5de29b
+  cfi_startproc;
5de29b
+
5de29b
+#undef END_GEN_TB
5de29b
+#define END_GEN_TB(name, mask)					\
5de29b
+  cfi_endproc;							\
5de29b
+  TRACEBACK_MASK(__memcpy_power4,mask)				\
5de29b
+  END_2(__memcpy_power4)
5de29b
+
5de29b
+#undef libc_hidden_builtin_def
5de29b
+#define libc_hidden_builtin_def(name)
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc64/power4/memcpy.S>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-power6.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-power6.S
5de29b
new file mode 100644
5de29b
index 0000000..13b514d
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-power6.S
5de29b
@@ -0,0 +1,39 @@
5de29b
+/* Optimized memcpy implementation for PowerPC/POWER6.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <sysdep.h>
5de29b
+
5de29b
+#undef EALIGN
5de29b
+#define EALIGN(name, alignt, words)				\
5de29b
+  .section ".text";						\
5de29b
+  ENTRY_2(__memcpy_power6)					\
5de29b
+  .align ALIGNARG(alignt);					\
5de29b
+  EALIGN_W_##words;						\
5de29b
+  BODY_LABEL(__memcpy_power6):					\
5de29b
+  cfi_startproc;
5de29b
+
5de29b
+#undef END_GEN_TB
5de29b
+#define END_GEN_TB(name, mask)					\
5de29b
+  cfi_endproc;							\
5de29b
+  TRACEBACK_MASK(__memcpy_power6,mask)				\
5de29b
+  END_2(__memcpy_power6)
5de29b
+
5de29b
+#undef libc_hidden_builtin_def
5de29b
+#define libc_hidden_builtin_def(name)
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc64/power6/memcpy.S>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-power7.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-power7.S
5de29b
new file mode 100644
5de29b
index 0000000..2aea73d
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-power7.S
5de29b
@@ -0,0 +1,39 @@
5de29b
+/* Optimized memcpy implementation for PowerPC/POWER7.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <sysdep.h>
5de29b
+
5de29b
+#undef EALIGN
5de29b
+#define EALIGN(name, alignt, words)				\
5de29b
+  .section ".text";						\
5de29b
+  ENTRY_2(__memcpy_power7)					\
5de29b
+  .align ALIGNARG(alignt);					\
5de29b
+  EALIGN_W_##words;						\
5de29b
+  BODY_LABEL(__memcpy_power7):					\
5de29b
+  cfi_startproc;
5de29b
+
5de29b
+#undef END_GEN_TB
5de29b
+#define END_GEN_TB(name, mask)					\
5de29b
+  cfi_endproc;							\
5de29b
+  TRACEBACK_MASK(__memcpy_power7,mask)				\
5de29b
+  END_2(__memcpy_power7)
5de29b
+
5de29b
+#undef libc_hidden_builtin_def
5de29b
+#define libc_hidden_builtin_def(name)
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc64/power7/memcpy.S>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-ppc64.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-ppc64.S
5de29b
new file mode 100644
5de29b
index 0000000..b828915
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy-ppc64.S
5de29b
@@ -0,0 +1,41 @@
5de29b
+/* Default memcpy implementation for PowerPC64.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <sysdep.h>
5de29b
+
5de29b
+#if defined SHARED && !defined NOT_IN_libc
5de29b
+# undef EALIGN
5de29b
+# define EALIGN(name, alignt, words)				\
5de29b
+  .section ".text";						\
5de29b
+  ENTRY_2(__memcpy_ppc)						\
5de29b
+  .align ALIGNARG(alignt);					\
5de29b
+  EALIGN_W_##words;						\
5de29b
+  BODY_LABEL(__memcpy_ppc):					\
5de29b
+  cfi_startproc;
5de29b
+
5de29b
+# undef END_GEN_TB
5de29b
+# define END_GEN_TB(name, mask)					\
5de29b
+   cfi_endproc;							\
5de29b
+   TRACEBACK_MASK(__memcpy_ppc,mask)				\
5de29b
+   END_2(__memcpy_ppc)
5de29b
+
5de29b
+# undef libc_hidden_builtin_def
5de29b
+# define libc_hidden_builtin_def(name)
5de29b
+#endif
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc64/memcpy.S>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy.c
5de29b
new file mode 100644
5de29b
index 0000000..305e963
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/memcpy.c
5de29b
@@ -0,0 +1,55 @@
5de29b
+/* Multiple versions of memcpy. PowerPC64 version.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+/* Define multiple versions only for the definition in lib and for
5de29b
+   DSO.  In static binaries we need memcpy before the initialization
5de29b
+   happened.  */
5de29b
+#if defined SHARED && !defined NOT_IN_libc
5de29b
+/* Redefine memcpy so that the compiler won't complain about the type
5de29b
+   mismatch with the IFUNC selector in strong_alias, below.  */
5de29b
+# undef memcpy
5de29b
+# define memcpy __redirect_memcpy
5de29b
+# include <string.h>
5de29b
+# include "init-arch.h"
5de29b
+
5de29b
+extern __typeof (__redirect_memcpy) __libc_memcpy;
5de29b
+
5de29b
+extern __typeof (__redirect_memcpy) __memcpy_ppc attribute_hidden;
5de29b
+extern __typeof (__redirect_memcpy) __memcpy_power4 attribute_hidden;
5de29b
+extern __typeof (__redirect_memcpy) __memcpy_cell attribute_hidden;
5de29b
+extern __typeof (__redirect_memcpy) __memcpy_power6 attribute_hidden;
5de29b
+extern __typeof (__redirect_memcpy) __memcpy_a2 attribute_hidden;
5de29b
+extern __typeof (__redirect_memcpy) __memcpy_power7 attribute_hidden;
5de29b
+
5de29b
+libc_ifunc (__libc_memcpy,
5de29b
+            (hwcap & PPC_FEATURE_HAS_VSX)
5de29b
+            ? __memcpy_power7 :
5de29b
+	      (hwcap & PPC_FEATURE_ARCH_2_06)
5de29b
+	      ? __memcpy_a2 :
5de29b
+		(hwcap & PPC_FEATURE_ARCH_2_05)
5de29b
+		? __memcpy_power6 :
5de29b
+		  (hwcap & PPC_FEATURE_CELL_BE)
5de29b
+		  ? __memcpy_cell :
5de29b
+		    (hwcap & PPC_FEATURE_POWER4)
5de29b
+		    ? __memcpy_power4
5de29b
+            : __memcpy_ppc);
5de29b
+
5de29b
+#undef memcpy
5de29b
+strong_alias (__libc_memcpy, memcpy);
5de29b
+libc_hidden_ver (__libc_memcpy, memcpy);
5de29b
+#endif
5de29b
-- 
5de29b
1.8.3.1
5de29b