5de29b
From 09f1f5cc860480fd09383bca00eb71e0f71aae79 Mon Sep 17 00:00:00 2001
5de29b
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
5de29b
Date: Wed, 30 Jul 2014 05:17:26 -0500
5de29b
Subject: [PATCH] PowerPC: multiarch mempcpy for PowerPC64
5de29b
5de29b
commit f00be62b08c1440800898339f74fb4db20b19eef
5de29b
Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
5de29b
Date:   Fri Dec 13 14:34:06 2013 -0500
5de29b
5de29b
Added sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c  and
5de29b
string/mempcpy.c apart from original commit.
5de29b
---
5de29b
 string/mempcpy.c                                   |  9 ++---
5de29b
 .../powerpc32/power4/multiarch/mempcpy-ppc32.c     | 32 +++++++++++++++++
5de29b
 sysdeps/powerpc/powerpc64/multiarch/Makefile       |  3 +-
5de29b
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |  8 +++++
5de29b
 .../powerpc/powerpc64/multiarch/mempcpy-power7.S   | 41 ++++++++++++++++++++++
5de29b
 .../powerpc/powerpc64/multiarch/mempcpy-ppc64.c    | 19 ++++++++++
5de29b
 sysdeps/powerpc/powerpc64/multiarch/mempcpy.c      | 38 ++++++++++++++++++++
5de29b
 7 files changed, 145 insertions(+), 5 deletions(-)
5de29b
 create mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/mempcpy-power7.S
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/mempcpy-ppc64.c
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
5de29b
5de29b
diff --git a/string/mempcpy.c b/string/mempcpy.c
5de29b
index 2a542e3..7509c24 100644
5de29b
--- a/string/mempcpy.c
5de29b
+++ b/string/mempcpy.c
5de29b
@@ -26,11 +26,12 @@
5de29b
 #undef mempcpy
5de29b
 #undef __mempcpy
5de29b
 
5de29b
+#ifndef MEMPCPY
5de29b
+# define MEMPCPY __mempcpy
5de29b
+#endif
5de29b
+
5de29b
 void *
5de29b
-__mempcpy (dstpp, srcpp, len)
5de29b
-     void *dstpp;
5de29b
-     const void *srcpp;
5de29b
-     size_t len;
5de29b
+MEMPCPY (void *dstpp, const void *srcpp, size_t len)
5de29b
 {
5de29b
   unsigned long int dstp = (long int) dstpp;
5de29b
   unsigned long int srcp = (long int) srcpp;
5de29b
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c b/sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c
5de29b
new file mode 100644
5de29b
index 0000000..8dc77e9
5de29b
--- /dev/null
5de29b
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c
5de29b
@@ -0,0 +1,32 @@
5de29b
+/* PowerPC32 default implementation of mempcpy.
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 MEMPCPY  __mempcpy_ppc
5de29b
+
5de29b
+#undef libc_hidden_def
5de29b
+#define libc_hidden_def(name)
5de29b
+#undef weak_alias
5de29b
+#define weak_alias(a, b)
5de29b
+
5de29b
+#if defined SHARED
5de29b
+# undef libc_hidden_builtin_def
5de29b
+# define libc_hidden_builtin_def(name)  \
5de29b
+  __hidden_ver1 (__mempcpy_ppc, __GI_mempcpy, __mempcpy_ppc);
5de29b
+#endif
5de29b
+
5de29b
+#include <string/mempcpy.c>
5de29b
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
5de29b
index 424d2cd..22560e8 100644
5de29b
--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
5de29b
+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
5de29b
@@ -2,5 +2,6 @@ ifeq ($(subdir),string)
5de29b
 sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
5de29b
                   memcpy-power4 memcpy-ppc64 memcmp-power7 memcmp-power4 \
5de29b
                   memcmp-ppc64 memset-power7 memset-power6 memset-power4 \
5de29b
-                  memset-ppc64 bzero-power4 bzero-power6 bzero-power7
5de29b
+                  memset-ppc64 bzero-power4 bzero-power6 bzero-power7 \
5de29b
+                  mempcpy-power7 mempcpy-ppc64
5de29b
 endif
5de29b
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
5de29b
index 11e7063..c72c229 100644
5de29b
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
5de29b
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
5de29b
@@ -90,5 +90,13 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
5de29b
                              __bzero_power4)
5de29b
              IFUNC_IMPL_ADD (array, i, bzero, 1, __bzero_ppc))
5de29b
 
5de29b
+  /* Support sysdeps/powerpc/powerpc64/multiarch/mempcpy.c.  */
5de29b
+  IFUNC_IMPL (i, name, mempcpy,
5de29b
+             IFUNC_IMPL_ADD (array, i, mempcpy,
5de29b
+                             hwcap & PPC_FEATURE_HAS_VSX,
5de29b
+                             __mempcpy_power7)
5de29b
+             IFUNC_IMPL_ADD (array, i, mempcpy, 1,
5de29b
+                             __mempcpy_ppc))
5de29b
+
5de29b
   return i;
5de29b
 }
5de29b
diff --git a/sysdeps/powerpc/powerpc64/multiarch/mempcpy-power7.S b/sysdeps/powerpc/powerpc64/multiarch/mempcpy-power7.S
5de29b
new file mode 100644
5de29b
index 0000000..6a79847
5de29b
--- /dev/null
5de29b
+++ b/sysdeps/powerpc/powerpc64/multiarch/mempcpy-power7.S
5de29b
@@ -0,0 +1,41 @@
5de29b
+/* Optimized mempcpy 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(__mempcpy_power7)					\
5de29b
+  .align ALIGNARG(alignt);					\
5de29b
+  EALIGN_W_##words;						\
5de29b
+  BODY_LABEL(__mempcpy_power7):					\
5de29b
+  cfi_startproc;
5de29b
+
5de29b
+#undef END_GEN_TB
5de29b
+#define END_GEN_TB(name, mask)					\
5de29b
+  cfi_endproc;							\
5de29b
+  TRACEBACK_MASK(__mempcpy_power7,mask)				\
5de29b
+  END_2(__mempcpy_power7)
5de29b
+
5de29b
+#undef libc_hidden_builtin_def
5de29b
+#define libc_hidden_builtin_def(name)
5de29b
+#undef weak_alias
5de29b
+#define weak_alias(name, alias)
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc64/power7/mempcpy.S>
5de29b
diff --git a/sysdeps/powerpc/powerpc64/multiarch/mempcpy-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/mempcpy-ppc64.c
5de29b
new file mode 100644
5de29b
index 0000000..78260bb
5de29b
--- /dev/null
5de29b
+++ b/sysdeps/powerpc/powerpc64/multiarch/mempcpy-ppc64.c
5de29b
@@ -0,0 +1,19 @@
5de29b
+/* PowerPC64 default implementation of mempcpy.
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 <sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c>
5de29b
diff --git a/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c b/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
5de29b
new file mode 100644
5de29b
index 0000000..38fbcc3
5de29b
--- /dev/null
5de29b
+++ b/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
5de29b
@@ -0,0 +1,38 @@
5de29b
+/* Multiple versions of mempcpy.
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
+#ifndef NOT_IN_libc
5de29b
+# include <string.h>
5de29b
+# include <shlib-compat.h>
5de29b
+# include "init-arch.h"
5de29b
+
5de29b
+extern __typeof (__mempcpy) __mempcpy_ppc attribute_hidden;
5de29b
+extern __typeof (__mempcpy) __mempcpy_power7 attribute_hidden;
5de29b
+
5de29b
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
5de29b
+   ifunc symbol properly.  */
5de29b
+libc_ifunc (__mempcpy,
5de29b
+	    (hwcap & PPC_FEATURE_HAS_VSX)
5de29b
+            ? __mempcpy_power7
5de29b
+            : __mempcpy_ppc);
5de29b
+
5de29b
+weak_alias (__mempcpy, mempcpy)
5de29b
+libc_hidden_def (mempcpy)
5de29b
+#else
5de29b
+# include <string/mempcpy.c>
5de29b
+#endif
5de29b
-- 
5de29b
1.8.3.1
5de29b