e354a5
commit 7793ad7a2c00434398aa8bb3f5932e2fdf43536a
e354a5
Author: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
e354a5
Date:   Thu Aug 16 12:12:02 2018 +0530
e354a5
e354a5
    powerpc: Rearrange little endian specific files
e354a5
    
e354a5
    This patch moves little endian specific POWER9 optimization files to
e354a5
    sysdeps/powerpc/powerpc64/le and creates POWER9 ifunc functions
e354a5
    only for little endian.
e354a5
e354a5
diff --git a/sysdeps/powerpc/powerpc64/power9/strcmp.S b/sysdeps/powerpc/powerpc64/le/power9/strcmp.S
e354a5
similarity index 93%
e354a5
rename from sysdeps/powerpc/powerpc64/power9/strcmp.S
e354a5
rename to sysdeps/powerpc/powerpc64/le/power9/strcmp.S
e354a5
index 98243a9d51e1577f..bf057f598ef2aa55 100644
e354a5
--- a/sysdeps/powerpc/powerpc64/power9/strcmp.S
e354a5
+++ b/sysdeps/powerpc/powerpc64/le/power9/strcmp.S
e354a5
@@ -15,7 +15,6 @@
e354a5
    You should have received a copy of the GNU Lesser General Public
e354a5
    License along with the GNU C Library; if not, see
e354a5
    <http://www.gnu.org/licenses/>.  */
e354a5
-#ifdef __LITTLE_ENDIAN__
e354a5
 #include <sysdep.h>
e354a5
 
e354a5
 #ifndef STRCMP
e354a5
@@ -30,16 +29,16 @@
e354a5
    as in POWER8 patch and uses vectorised loops after that.  */
e354a5
 
e354a5
 /* TODO: Change this to actual instructions when minimum binutils is upgraded
e354a5
-   to 2.27. Macros are defined below for these newer instructions in order
e354a5
+   to 2.27.  Macros are defined below for these newer instructions in order
e354a5
    to maintain compatibility.  */
e354a5
-# define VCTZLSBB(r,v) .long (0x10010602 | ((r)<<(32-11)) | ((v)<<(32-21)))
e354a5
+#define VCTZLSBB(r,v) .long (0x10010602 | ((r)<<(32-11)) | ((v)<<(32-21)))
e354a5
 
e354a5
-# define VEXTUBRX(t,a,b) .long (0x1000070d \
e354a5
+#define VEXTUBRX(t,a,b) .long (0x1000070d \
e354a5
 				| ((t)<<(32-11))  \
e354a5
 				| ((a)<<(32-16))  \
e354a5
 				| ((b)<<(32-21)) )
e354a5
 
e354a5
-# define VCMPNEZB(t,a,b) .long (0x10000507 \
e354a5
+#define VCMPNEZB(t,a,b) .long (0x10000507 \
e354a5
 				| ((t)<<(32-11))  \
e354a5
 				| ((a)<<(32-16))  \
e354a5
 				| ((b)<<(32-21)) )
e354a5
@@ -48,7 +47,7 @@
e354a5
    reg1: Vector to hold next 16 bytes.
e354a5
    reg2: Address to read from.
e354a5
    reg3: Permute control vector.  */
e354a5
-# define GET16BYTES(reg1, reg2, reg3) \
e354a5
+#define GET16BYTES(reg1, reg2, reg3) \
e354a5
 	lvx	reg1, 0, reg2; \
e354a5
 	vperm	v8, v2, reg1, reg3; \
e354a5
 	vcmpequb.	v8, v0, v8; \
e354a5
@@ -263,6 +262,3 @@ L(pagecross_nullfound):
e354a5
 	b	L(pagecross_retdiff)
e354a5
 END (STRCMP)
e354a5
 libc_hidden_builtin_def (strcmp)
e354a5
-#else
e354a5
-#include <sysdeps/powerpc/powerpc64/power8/strcmp.S>
e354a5
-#endif
e354a5
diff --git a/sysdeps/powerpc/powerpc64/power9/strncmp.S b/sysdeps/powerpc/powerpc64/le/power9/strncmp.S
e354a5
similarity index 95%
e354a5
rename from sysdeps/powerpc/powerpc64/power9/strncmp.S
e354a5
rename to sysdeps/powerpc/powerpc64/le/power9/strncmp.S
e354a5
index 40be98ff45c9f485..93a79343c6be1099 100644
e354a5
--- a/sysdeps/powerpc/powerpc64/power9/strncmp.S
e354a5
+++ b/sysdeps/powerpc/powerpc64/le/power9/strncmp.S
e354a5
@@ -15,7 +15,6 @@
e354a5
    You should have received a copy of the GNU Lesser General Public
e354a5
    License along with the GNU C Library; if not, see
e354a5
    <http://www.gnu.org/licenses/>.  */
e354a5
-#ifdef __LITTLE_ENDIAN__
e354a5
 #include <sysdep.h>
e354a5
 
e354a5
 /* Implements the function
e354a5
@@ -31,16 +30,16 @@
e354a5
 #endif
e354a5
 
e354a5
 /* TODO: Change this to actual instructions when minimum binutils is upgraded
e354a5
-   to 2.27. Macros are defined below for these newer instructions in order
e354a5
+   to 2.27.  Macros are defined below for these newer instructions in order
e354a5
    to maintain compatibility.  */
e354a5
-# define VCTZLSBB(r,v) .long (0x10010602 | ((r)<<(32-11)) | ((v)<<(32-21)))
e354a5
+#define VCTZLSBB(r,v) .long (0x10010602 | ((r)<<(32-11)) | ((v)<<(32-21)))
e354a5
 
e354a5
-# define VEXTUBRX(t,a,b) .long (0x1000070d \
e354a5
+#define VEXTUBRX(t,a,b) .long (0x1000070d \
e354a5
 				| ((t)<<(32-11))  \
e354a5
 				| ((a)<<(32-16))  \
e354a5
 				| ((b)<<(32-21)) )
e354a5
 
e354a5
-# define VCMPNEZB(t,a,b) .long (0x10000507 \
e354a5
+#define VCMPNEZB(t,a,b) .long (0x10000507 \
e354a5
 				| ((t)<<(32-11))  \
e354a5
 				| ((a)<<(32-16))  \
e354a5
 				| ((b)<<(32-21)) )
e354a5
@@ -49,7 +48,7 @@
e354a5
    reg1: Vector to hold next 16 bytes.
e354a5
    reg2: Address to read from.
e354a5
    reg3: Permute control vector.  */
e354a5
-# define GET16BYTES(reg1, reg2, reg3) \
e354a5
+#define GET16BYTES(reg1, reg2, reg3) \
e354a5
 	lvx	reg1, 0, reg2; \
e354a5
 	vperm	v8, v2, reg1, reg3; \
e354a5
 	vcmpequb.	v8, v0, v8; \
e354a5
@@ -374,6 +373,3 @@ L(byte_ne_3):
e354a5
 	b	L(byte_ne_1)
e354a5
 END(STRNCMP)
e354a5
 libc_hidden_builtin_def(strncmp)
e354a5
-#else
e354a5
-#include <sysdeps/powerpc/powerpc64/power8/strncmp.S>
e354a5
-#endif
e354a5
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
e354a5
index 4df6b45c4c1c495a..963ea84dbfa98c74 100644
e354a5
--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
e354a5
+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
e354a5
@@ -12,7 +12,7 @@ sysdep_routines += memcpy-power8-cached memcpy-power7 memcpy-a2 memcpy-power6 \
e354a5
 		   strnlen-power8 strnlen-power7 strnlen-ppc64 \
e354a5
 		   strcasecmp-power7 strcasecmp_l-power7 \
e354a5
 		   strncase-power7 strncase_l-power7 \
e354a5
-		   strncmp-power9 strncmp-power8 strncmp-power7 \
e354a5
+		   strncmp-power8 strncmp-power7 \
e354a5
 		   strncmp-power4 strncmp-ppc64 \
e354a5
 		   strchr-power8 strchr-power7 strchr-ppc64 \
e354a5
 		   strchrnul-power8 strchrnul-power7 strchrnul-ppc64 \
e354a5
@@ -22,7 +22,7 @@ sysdep_routines += memcpy-power8-cached memcpy-power7 memcpy-a2 memcpy-power6 \
e354a5
 		   strncat-power8 strncat-power7 strncat-ppc64 \
e354a5
 		   strncpy-power7 strncpy-ppc64 \
e354a5
 		   stpncpy-power8 stpncpy-power7 stpncpy-ppc64 \
e354a5
-		   strcmp-power9 strcmp-power8 strcmp-power7 strcmp-ppc64 \
e354a5
+		   strcmp-power8 strcmp-power7 strcmp-ppc64 \
e354a5
 		   strcat-power8 strcat-power7 strcat-ppc64 \
e354a5
 		   memmove-power7 memmove-ppc64 wordcopy-ppc64 bcopy-ppc64 \
e354a5
 		   strncpy-power8 strstr-power7 strstr-ppc64 \
e354a5
@@ -31,6 +31,9 @@ sysdep_routines += memcpy-power8-cached memcpy-power7 memcpy-a2 memcpy-power6 \
e354a5
 		   strcasecmp-ppc64 strcasecmp-power8 strncase-ppc64 \
e354a5
 		   strncase-power8
e354a5
 
e354a5
+ifneq (,$(filter %le,$(config-machine)))
e354a5
+sysdep_routines += strcmp-power9 strncmp-power9
e354a5
+endif
e354a5
 CFLAGS-strncase-power7.c += -mcpu=power7 -funroll-loops
e354a5
 CFLAGS-strncase_l-power7.c += -mcpu=power7 -funroll-loops
e354a5
 endif
e354a5
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
e354a5
index 38a21e478e2527f5..1d374f2ae48165bd 100644
e354a5
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
e354a5
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
e354a5
@@ -112,8 +112,10 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
e354a5
 
e354a5
   /* Support sysdeps/powerpc/powerpc64/multiarch/strncmp.c.  */
e354a5
   IFUNC_IMPL (i, name, strncmp,
e354a5
+#ifdef __LITTLE_ENDIAN__
e354a5
 	      IFUNC_IMPL_ADD (array, i, strncmp, hwcap2 & PPC_FEATURE2_ARCH_3_00,
e354a5
 			      __strncmp_power9)
e354a5
+#endif
e354a5
 	      IFUNC_IMPL_ADD (array, i, strncmp, hwcap2 & PPC_FEATURE2_ARCH_2_07,
e354a5
 			      __strncmp_power8)
e354a5
 	      IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_HAS_VSX,
e354a5
@@ -337,9 +339,11 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
e354a5
 
e354a5
   /* Support sysdeps/powerpc/powerpc64/multiarch/strcmp.c.  */
e354a5
   IFUNC_IMPL (i, name, strcmp,
e354a5
+#ifdef __LITTLE_ENDIAN__
e354a5
 	      IFUNC_IMPL_ADD (array, i, strcmp,
e354a5
 			      hwcap2 & PPC_FEATURE2_ARCH_3_00,
e354a5
 			      __strcmp_power9)
e354a5
+#endif
e354a5
 	      IFUNC_IMPL_ADD (array, i, strcmp,
e354a5
 			      hwcap2 & PPC_FEATURE2_ARCH_2_07,
e354a5
 			      __strcmp_power8)
e354a5
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcmp-power9.S b/sysdeps/powerpc/powerpc64/multiarch/strcmp-power9.S
e354a5
index 8b569d38be783316..545e6cee91e61311 100644
e354a5
--- a/sysdeps/powerpc/powerpc64/multiarch/strcmp-power9.S
e354a5
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcmp-power9.S
e354a5
@@ -16,11 +16,11 @@
e354a5
    License along with the GNU C Library; if not, see
e354a5
    <http://www.gnu.org/licenses/>.  */
e354a5
 
e354a5
-#if IS_IN (libc)
e354a5
+#if defined __LITTLE_ENDIAN__ && IS_IN (libc)
e354a5
 #define STRCMP __strcmp_power9
e354a5
 
e354a5
 #undef libc_hidden_builtin_def
e354a5
 #define libc_hidden_builtin_def(name)
e354a5
 
e354a5
-#include <sysdeps/powerpc/powerpc64/power9/strcmp.S>
e354a5
+#include <sysdeps/powerpc/powerpc64/le/power9/strcmp.S>
e354a5
 #endif
e354a5
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcmp.c b/sysdeps/powerpc/powerpc64/multiarch/strcmp.c
e354a5
index b669053166771cae..2422c8d72cfdec83 100644
e354a5
--- a/sysdeps/powerpc/powerpc64/multiarch/strcmp.c
e354a5
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcmp.c
e354a5
@@ -27,13 +27,17 @@
e354a5
 extern __typeof (strcmp) __strcmp_ppc attribute_hidden;
e354a5
 extern __typeof (strcmp) __strcmp_power7 attribute_hidden;
e354a5
 extern __typeof (strcmp) __strcmp_power8 attribute_hidden;
e354a5
+# ifdef __LITTLE_ENDIAN__
e354a5
 extern __typeof (strcmp) __strcmp_power9 attribute_hidden;
e354a5
+# endif
e354a5
 
e354a5
 # undef strcmp
e354a5
 
e354a5
 libc_ifunc_redirected (__redirect_strcmp, strcmp,
e354a5
+# ifdef __LITTLE_ENDIAN__
e354a5
 			(hwcap2 & PPC_FEATURE2_ARCH_3_00)
e354a5
 			? __strcmp_power9 :
e354a5
+# endif
e354a5
 		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
e354a5
 		       ? __strcmp_power8
e354a5
 		       : (hwcap & PPC_FEATURE_HAS_VSX)
e354a5
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp-power9.S b/sysdeps/powerpc/powerpc64/multiarch/strncmp-power9.S
e354a5
index 3356f7252771a043..c6f0128379c497b4 100644
e354a5
--- a/sysdeps/powerpc/powerpc64/multiarch/strncmp-power9.S
e354a5
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp-power9.S
e354a5
@@ -15,11 +15,11 @@
e354a5
    License along with the GNU C Library; if not, see
e354a5
    <http://www.gnu.org/licenses/>.  */
e354a5
 
e354a5
-#if IS_IN (libc)
e354a5
+#if defined __LITTLE_ENDIAN__ && IS_IN (libc)
e354a5
 #define STRNCMP __strncmp_power9
e354a5
 
e354a5
 #undef libc_hidden_builtin_def
e354a5
 #define libc_hidden_builtin_def(name)
e354a5
 
e354a5
-#include <sysdeps/powerpc/powerpc64/power9/strncmp.S>
e354a5
+#include <sysdeps/powerpc/powerpc64/le/power9/strncmp.S>
e354a5
 #endif
e354a5
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp.c b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
e354a5
index c4a40d1ec7245a3b..9c887ee18186f070 100644
e354a5
--- a/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
e354a5
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
e354a5
@@ -29,14 +29,18 @@ extern __typeof (strncmp) __strncmp_ppc attribute_hidden;
e354a5
 extern __typeof (strncmp) __strncmp_power4 attribute_hidden;
e354a5
 extern __typeof (strncmp) __strncmp_power7 attribute_hidden;
e354a5
 extern __typeof (strncmp) __strncmp_power8 attribute_hidden;
e354a5
+# ifdef __LITTLE_ENDIAN__
e354a5
 extern __typeof (strncmp) __strncmp_power9 attribute_hidden;
e354a5
+# endif
e354a5
 # undef strncmp
e354a5
 
e354a5
 /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
e354a5
    ifunc symbol properly.  */
e354a5
 libc_ifunc_redirected (__redirect_strncmp, strncmp,
e354a5
+# ifdef __LITTLE_ENDIAN_
e354a5
 			(hwcap2 & PPC_FEATURE2_ARCH_3_00)
e354a5
 			? __strncmp_power9 :
e354a5
+# endif
e354a5
 		       (hwcap2 & PPC_FEATURE2_ARCH_2_07)
e354a5
 		       ? __strncmp_power8
e354a5
 		       : (hwcap & PPC_FEATURE_HAS_VSX)