PowerPC: multirach memcmp for PowerPC64
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 13 Dec 2013 19:32:31 +0000 (14:32 -0500)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 13 Dec 2013 19:32:31 +0000 (14:32 -0500)
ChangeLog
string/memcmp.c
sysdeps/powerpc/powerpc64/multiarch/Makefile
sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
sysdeps/powerpc/powerpc64/multiarch/memcmp-power4.S [new file with mode: 0644]
sysdeps/powerpc/powerpc64/multiarch/memcmp-power7.S [new file with mode: 0644]
sysdeps/powerpc/powerpc64/multiarch/memcmp-ppc64.c [new file with mode: 0644]
sysdeps/powerpc/powerpc64/multiarch/memcmp.c [new file with mode: 0644]

index 2ac4555..3a62a69 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2013-12-13  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
 
+       * string/memcmp.c (memcmp): Using macro to redefine symbol name.
+       * sysdeps/powerpc/powerpc64/multiarch/Makefile: Add memcpy multiarch
+       implementations.
+       * sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+       (__libc_ifunc_impl_list): Likewise.
+       * sysdeps/powerpc/powerpc64/multiarch/memcmp-power4.S: New file.
+       * sysdeps/powerpc/powerpc64/multiarch/memcmp-power7.S: New file.
+       * sysdeps/powerpc/powerpc64/multiarch/memcmp-ppc64.c: New file.
+       * sysdeps/powerpc/powerpc64/multiarch/memcmp.c: New file: multiarch
+       memcmp for PPC64.
+
+2013-12-13  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
+
        * sysdeps/powerpc/powerpc64/multiarch/Makefile: New file to support
        multiarch for POWER/PPC64.
        * sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c: Likewise.
index dd76145..d7c57db 100644 (file)
 
 #undef memcmp
 
+#ifndef MEMCMP
+# define MEMCMP memcmp
+#endif
+
 #ifdef _LIBC
 
 # include <memcopy.h>
@@ -304,7 +308,7 @@ memcmp_not_common_alignment (srcp1, srcp2, len)
 }
 
 int
-memcmp (s1, s2, len)
+MEMCMP (s1, s2, len)
      const __ptr_t s1;
      const __ptr_t s2;
      size_t len;
index 7467021..4dd2f38 100644 (file)
@@ -1,4 +1,5 @@
 ifeq ($(subdir),string)
 sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
-                  memcpy-power4 memcpy-ppc64
+                  memcpy-power4 memcpy-ppc64 memcmp-power7 memcmp-power4 \
+                  memcmp-ppc64
 endif
index 034e551..338a71c 100644 (file)
@@ -62,5 +62,13 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
              IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_ppc))
 #endif
 
+  /* Support sysdeps/powerpc/powerpc64/multiarch/memcmp.c.  */
+  IFUNC_IMPL (i, name, memcmp,
+             IFUNC_IMPL_ADD (array, i, memcmp, hwcap & PPC_FEATURE_HAS_VSX,
+                             __memcmp_power7)
+             IFUNC_IMPL_ADD (array, i, memcmp, hwcap & PPC_FEATURE_POWER4,
+                             __memcmp_power4)
+             IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_ppc))
+
   return i;
 }
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memcmp-power4.S b/sysdeps/powerpc/powerpc64/multiarch/memcmp-power4.S
new file mode 100644 (file)
index 0000000..d98857d
--- /dev/null
@@ -0,0 +1,42 @@
+/* Optimized memcmp implementation for PowerPC64/POWER4.
+   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)                            \
+  .section ".text";                                            \
+  ENTRY_2(__memcmp_power4)                                     \
+  .align ALIGNARG(alignt);                                     \
+  EALIGN_W_##words;                                            \
+  BODY_LABEL(__memcmp_power4):                                 \
+  cfi_startproc;                                               \
+  LOCALENTRY(__memcmp_power4)
+
+#undef END
+#define END(name)                                              \
+  cfi_endproc;                                                 \
+  TRACEBACK(__memcmp_power4)                                   \
+  END_2(__memcmp_power4)
+
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(name)
+#undef weak_alias
+#define weak_alias(name,alias)
+
+#include <sysdeps/powerpc/powerpc64/power4/memcmp.S>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memcmp-power7.S b/sysdeps/powerpc/powerpc64/multiarch/memcmp-power7.S
new file mode 100644 (file)
index 0000000..9e027d4
--- /dev/null
@@ -0,0 +1,42 @@
+/* Optimized memcmp implementation for PowerPC64/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)                            \
+  .section ".text";                                            \
+  ENTRY_2(__memcmp_power7)                                     \
+  .align ALIGNARG(alignt);                                     \
+  EALIGN_W_##words;                                            \
+  BODY_LABEL(__memcmp_power7):                                 \
+  cfi_startproc;                                               \
+  LOCALENTRY(__memcmp_power7)
+
+#undef END
+#define END(name)                                              \
+  cfi_endproc;                                                 \
+  TRACEBACK(__memcmp_power7)                                   \
+  END_2(__memcmp_power7)
+
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(name)
+#undef weak_alias
+#define weak_alias(name,alias)
+
+#include <sysdeps/powerpc/powerpc64/power7/memcmp.S>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memcmp-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/memcmp-ppc64.c
new file mode 100644 (file)
index 0000000..685e530
--- /dev/null
@@ -0,0 +1,33 @@
+/* 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 <string.h>
+
+#define MEMCMP __memcmp_ppc
+#undef weak_alias
+#define weak_alias(name, aliasname) \
+  extern __typeof (__memcmp_ppc) aliasname \
+    __attribute__ ((weak, alias ("__memcmp_ppc")));
+#if !defined(NOT_IN_libc) && defined(SHARED)
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name) \
+  __hidden_ver1(__memcmp_ppc, __GI_memcmp, __memcmp_ppc);
+#endif
+
+extern __typeof (memcmp) __memcmp_ppc attribute_hidden;
+
+#include <string/memcmp.c>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memcmp.c b/sysdeps/powerpc/powerpc64/multiarch/memcmp.c
new file mode 100644 (file)
index 0000000..b63c8e1
--- /dev/null
@@ -0,0 +1,39 @@
+/* Multiple versions of memcmp. PowerPC64 version.
+   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 definition in libc.  */
+#ifndef NOT_IN_libc
+# include <string.h>
+# include <shlib-compat.h>
+# include "init-arch.h"
+
+extern __typeof (memcmp) __memcmp_ppc attribute_hidden;
+extern __typeof (memcmp) __memcmp_power4 attribute_hidden;
+extern __typeof (memcmp) __memcmp_power7 attribute_hidden;
+
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
+   ifunc symbol properly.  */
+libc_ifunc (memcmp,
+            (hwcap & PPC_FEATURE_HAS_VSX)
+            ? __memcmp_power7 :
+             (hwcap & PPC_FEATURE_POWER4)
+               ? __memcmp_power4
+            : __memcmp_ppc);
+#else
+#include <string/memcmp.c>
+#endif