5de29b
# commit 43b84013714c46e6dcae4a5564c5527777ad5e08
5de29b
# Author: Alan Modra <amodra@gmail.com>
5de29b
# Date:   Sat Aug 17 18:45:31 2013 +0930
5de29b
# 
5de29b
#     PowerPC LE strcpy
5de29b
#     http://sourceware.org/ml/libc-alpha/2013-08/msg00100.html
5de29b
#     
5de29b
#     The strcpy changes for little-endian are quite straight-forward, just
5de29b
#     a matter of rotating the last word differently.
5de29b
#     
5de29b
#     I'll note that the powerpc64 version of stpcpy is just begging to be
5de29b
#     converted to use 64-bit loads and stores..
5de29b
#     
5de29b
#         * sysdeps/powerpc/powerpc64/strcpy.S: Add little-endian support:
5de29b
#         * sysdeps/powerpc/powerpc32/strcpy.S: Likewise.
5de29b
#         * sysdeps/powerpc/powerpc64/stpcpy.S: Likewise.
5de29b
#         * sysdeps/powerpc/powerpc32/stpcpy.S: Likewise.
5de29b
# 
12745e
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/stpcpy.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/stpcpy.S
12745e
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/stpcpy.S	2014-05-28 13:40:01.000000000 -0500
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/stpcpy.S	2014-05-28 13:40:01.000000000 -0500
5de29b
@@ -74,7 +74,22 @@
5de29b
 
5de29b
 	mr	rALT, rWORD
5de29b
 /* We've hit the end of the string.  Do the rest byte-by-byte.  */
5de29b
-L(g1):	rlwinm.	rTMP, rALT, 8, 24, 31
5de29b
+L(g1):
5de29b
+#ifdef __LITTLE_ENDIAN__
5de29b
+	rlwinm.	rTMP, rALT, 0, 24, 31
5de29b
+	stbu	rALT, 4(rDEST)
5de29b
+	beqlr-
5de29b
+	rlwinm.	rTMP, rALT, 24, 24, 31
5de29b
+	stbu	rTMP, 1(rDEST)
5de29b
+	beqlr-
5de29b
+	rlwinm.	rTMP, rALT, 16, 24, 31
5de29b
+	stbu	rTMP, 1(rDEST)
5de29b
+	beqlr-
5de29b
+	rlwinm	rTMP, rALT, 8, 24, 31
5de29b
+	stbu	rTMP, 1(rDEST)
5de29b
+	blr
5de29b
+#else
5de29b
+	rlwinm.	rTMP, rALT, 8, 24, 31
5de29b
 	stbu	rTMP, 4(rDEST)
5de29b
 	beqlr-
5de29b
 	rlwinm.	rTMP, rALT, 16, 24, 31
5de29b
@@ -87,6 +102,7 @@
5de29b
 	CHECK_BOUNDS_HIGH (rDEST, rHIGH, twlgt)
5de29b
 	STORE_RETURN_VALUE (rDEST)
5de29b
 	blr
5de29b
+#endif
5de29b
 
5de29b
 /* Oh well.  In this case, we just do a byte-by-byte copy.  */
5de29b
 	.align 4
12745e
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/strcpy.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/strcpy.S
12745e
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/strcpy.S	2014-05-28 13:40:01.000000000 -0500
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/strcpy.S	2014-05-28 13:40:01.000000000 -0500
5de29b
@@ -78,7 +78,22 @@
5de29b
 
5de29b
 	mr	rALT, rWORD
5de29b
 /* We've hit the end of the string.  Do the rest byte-by-byte.  */
5de29b
-L(g1):	rlwinm.	rTMP, rALT, 8, 24, 31
5de29b
+L(g1):
5de29b
+#ifdef __LITTLE_ENDIAN__
5de29b
+	rlwinm.	rTMP, rALT, 0, 24, 31
5de29b
+	stb	rALT, 4(rDEST)
5de29b
+	beqlr-
5de29b
+	rlwinm.	rTMP, rALT, 24, 24, 31
5de29b
+	stb	rTMP, 5(rDEST)
5de29b
+	beqlr-
5de29b
+	rlwinm.	rTMP, rALT, 16, 24, 31
5de29b
+	stb	rTMP, 6(rDEST)
5de29b
+	beqlr-
5de29b
+	rlwinm	rTMP, rALT, 8, 24, 31
5de29b
+	stb	rTMP, 7(rDEST)
5de29b
+	blr
5de29b
+#else
5de29b
+	rlwinm.	rTMP, rALT, 8, 24, 31
5de29b
 	stb	rTMP, 4(rDEST)
5de29b
 	beqlr-
5de29b
 	rlwinm.	rTMP, rALT, 16, 24, 31
5de29b
@@ -90,6 +105,7 @@
5de29b
 	stb	rALT, 7(rDEST)
5de29b
 	/* GKM FIXME: check high bound.  */
5de29b
 	blr
5de29b
+#endif
5de29b
 
5de29b
 /* Oh well.  In this case, we just do a byte-by-byte copy.  */
5de29b
 	.align 4
12745e
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/stpcpy.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/stpcpy.S
12745e
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/stpcpy.S	2014-05-28 13:40:01.000000000 -0500
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/stpcpy.S	2014-05-28 13:40:01.000000000 -0500
5de29b
@@ -75,7 +75,22 @@
5de29b
 
5de29b
 	mr	rALT, rWORD
5de29b
 /* We've hit the end of the string.  Do the rest byte-by-byte.  */
5de29b
-L(g1):	rlwinm.	rTMP, rALT, 8, 24, 31
5de29b
+L(g1):
5de29b
+#ifdef __LITTLE_ENDIAN__
5de29b
+	rlwinm.	rTMP, rALT, 0, 24, 31
5de29b
+	stbu	rALT, 4(rDEST)
5de29b
+	beqlr-
5de29b
+	rlwinm.	rTMP, rALT, 24, 24, 31
5de29b
+	stbu	rTMP, 1(rDEST)
5de29b
+	beqlr-
5de29b
+	rlwinm.	rTMP, rALT, 16, 24, 31
5de29b
+	stbu	rTMP, 1(rDEST)
5de29b
+	beqlr-
5de29b
+	rlwinm	rTMP, rALT, 8, 24, 31
5de29b
+	stbu	rTMP, 1(rDEST)
5de29b
+	blr
5de29b
+#else
5de29b
+	rlwinm.	rTMP, rALT, 8, 24, 31
5de29b
 	stbu	rTMP, 4(rDEST)
5de29b
 	beqlr-
5de29b
 	rlwinm.	rTMP, rALT, 16, 24, 31
5de29b
@@ -88,6 +103,7 @@
5de29b
 	CHECK_BOUNDS_HIGH (rDEST, rHIGH, twlgt)
5de29b
 	STORE_RETURN_VALUE (rDEST)
5de29b
 	blr
5de29b
+#endif
5de29b
 
5de29b
 /* Oh well.  In this case, we just do a byte-by-byte copy.  */
5de29b
 	.align 4
12745e
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/strcpy.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/strcpy.S
12745e
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/strcpy.S	2014-05-28 13:40:01.000000000 -0500
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/strcpy.S	2014-05-28 13:40:01.000000000 -0500
5de29b
@@ -90,6 +90,32 @@
5de29b
 	mr	rALT, rWORD
5de29b
 /* We've hit the end of the string.  Do the rest byte-by-byte.  */
5de29b
 L(g1):
5de29b
+#ifdef __LITTLE_ENDIAN__
5de29b
+	extrdi.	rTMP, rALT, 8, 56
5de29b
+	stb	rALT, 8(rDEST)
5de29b
+	beqlr-
5de29b
+	extrdi.	rTMP, rALT, 8, 48
5de29b
+	stb	rTMP, 9(rDEST)
5de29b
+	beqlr-
5de29b
+	extrdi.	rTMP, rALT, 8, 40
5de29b
+	stb	rTMP, 10(rDEST)
5de29b
+	beqlr-
5de29b
+	extrdi.	rTMP, rALT, 8, 32
5de29b
+	stb	rTMP, 11(rDEST)
5de29b
+	beqlr-
5de29b
+	extrdi.	rTMP, rALT, 8, 24
5de29b
+	stb	rTMP, 12(rDEST)
5de29b
+	beqlr-
5de29b
+	extrdi.	rTMP, rALT, 8, 16
5de29b
+	stb	rTMP, 13(rDEST)
5de29b
+	beqlr-
5de29b
+	extrdi.	rTMP, rALT, 8, 8
5de29b
+	stb	rTMP, 14(rDEST)
5de29b
+	beqlr-
5de29b
+	extrdi	rTMP, rALT, 8, 0
5de29b
+	stb	rTMP, 15(rDEST)
5de29b
+	blr
5de29b
+#else
5de29b
 	extrdi.	rTMP, rALT, 8, 0
5de29b
 	stb	rTMP, 8(rDEST)
5de29b
 	beqlr-
5de29b
@@ -114,6 +140,7 @@
5de29b
 	stb	rALT, 15(rDEST)
5de29b
 	/* GKM FIXME: check high bound.  */
5de29b
 	blr
5de29b
+#endif
5de29b
 
5de29b
 /* Oh well.  In this case, we just do a byte-by-byte copy.  */
5de29b
 	.align 4