This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 11/36] PowerPC: strncmp multilib for PowerPC32
- From: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- To: "GNU C. Library" <libc-alpha at sourceware dot org>
- Date: Mon, 19 Aug 2013 18:28:14 -0300
- Subject: [PATCH 11/36] PowerPC: strncmp multilib for PowerPC32
- References: <52127ABC dot 40008 at linux dot vnet dot ibm dot com>
2013-08-19 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
* sysdeps/powerpc/powerpc32/power4/strncmp.S: Move to ...
* sysdeps/powerpc/powerpc32/multiarch/strncmp-power4.S: ... here.
(strncmp): Rename symbol name to __strncmp_power4 and remove the
libc_hidden_builtin_def definitions.
* sysdeps/powerpc/powerpc32/power7/strncmp.S: Move to ...
* sysdeps/powerpc/powerpc32/multiarch/strncmp-power7.S: ... here.
(strncmp): Rename symbol name to __strncmp_power7 and remove the
libc_hidden_builtin_def definitions.
* sysdeps/powerpc/powerpc32/multiarch/strncmp-ppc32.S: New file:
default strncmp PPC32 implementation.
* sysdeps/powerpc/powerpc32/multiarch/strncmp.c: New file:
multiarch strncmp for PPC32.
* sysdeps/powerpc/powerpc32/multiarch/Makefile: Added strncmp
multiarch objects.
* sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list
(__libc_ifunc_impl_list): Likewise.
--
diff --git a/sysdeps/powerpc/powerpc32/multiarch/Makefile b/sysdeps/powerpc/powerpc32/multiarch/Makefile
index 5ccd8ff..1c2add3 100644
--- a/sysdeps/powerpc/powerpc32/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/multiarch/Makefile
@@ -5,5 +5,6 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
memset-ppc32 mempcpy-power7 mempcpy-ppc32 memchr-power7 \
memchr-ppc32 memrchr-power7 memrchr-ppc32 rawmemchr-power7 \
rawmemchr-ppc32 strnlen-power7 strlen-power7 strlen-ppc32 \
- strnlen-power7 strnlen-ppc32
+ strnlen-power7 strnlen-ppc32 strncmp-power7 strncmp-power4 \
+ strncmp-ppc32
endif
diff --git a/sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c
index 5d0080e..72d2784 100644
--- a/sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c
@@ -132,6 +132,13 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
__strnlen_power7)
IFUNC_IMPL_ADD (array, i, strnlen, 1,
__strnlen_ppc32))
+
+ /* Support sysdeps/powerpc/powerpc32/multiarch/strncmp.c. */
+ IFUNC_IMPL (i, name, strncmp,
+ IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_HAS_VSX,
+ __strncmp_power7)
+ IFUNC_IMPL_ADD (array, i, strncmp, 1,
+ __strncmp_ppc32))
#endif
return i;
diff --git a/sysdeps/powerpc/powerpc32/multiarch/strncmp-power4.S b/sysdeps/powerpc/powerpc32/multiarch/strncmp-power4.S
new file mode 100644
index 0000000..ffbd11e
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/multiarch/strncmp-power4.S
@@ -0,0 +1,170 @@
+/* Optimized strcmp implementation for PowerPC32.
+ Copyright (C) 2003-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>
+
+/* See strlen.s for comments on how the end-of-string testing works. */
+
+/* int [r3] strncmp (const char *s1 [r3], const char *s2 [r4], size_t size [r5]) */
+
+ .machine power4
+EALIGN (__strncmp_power4, 4, 0)
+
+#define rTMP r0
+#define rRTN r3
+#define rSTR1 r3 /* first string arg */
+#define rSTR2 r4 /* second string arg */
+#define rN r5 /* max string length */
+#define rWORD1 r6 /* current word in s1 */
+#define rWORD2 r7 /* current word in s2 */
+#define rWORD3 r10
+#define rWORD4 r11
+#define rFEFE r8 /* constant 0xfefefeff (-0x01010101) */
+#define r7F7F r9 /* constant 0x7f7f7f7f */
+#define rNEG r10 /* ~(word in s1 | 0x7f7f7f7f) */
+#define rBITDIF r11 /* bits that differ in s1 & s2 words */
+
+ dcbt 0,rSTR1
+ or rTMP, rSTR2, rSTR1
+ lis r7F7F, 0x7f7f
+ dcbt 0,rSTR2
+ clrlwi. rTMP, rTMP, 30
+ cmplwi cr1, rN, 0
+ lis rFEFE, -0x101
+ bne L(unaligned)
+/* We are word aligned so set up for two loops. first a word
+ loop, then fall into the byte loop if any residual. */
+ srwi. rTMP, rN, 2
+ clrlwi rN, rN, 30
+ addi rFEFE, rFEFE, -0x101
+ addi r7F7F, r7F7F, 0x7f7f
+ cmplwi cr1, rN, 0
+ beq L(unaligned)
+
+ mtctr rTMP /* Power4 wants mtctr 1st in dispatch group. */
+ lwz rWORD1, 0(rSTR1)
+ lwz rWORD2, 0(rSTR2)
+ b L(g1)
+
+L(g0):
+ lwzu rWORD1, 4(rSTR1)
+ bne- cr1, L(different)
+ lwzu rWORD2, 4(rSTR2)
+L(g1): add rTMP, rFEFE, rWORD1
+ nor rNEG, r7F7F, rWORD1
+ bdz L(tail)
+ and. rTMP, rTMP, rNEG
+ cmpw cr1, rWORD1, rWORD2
+ beq+ L(g0)
+
+/* OK. We've hit the end of the string. We need to be careful that
+ we don't compare two strings as different because of gunk beyond
+ the end of the strings... */
+
+L(endstring):
+ and rTMP, r7F7F, rWORD1
+ beq cr1, L(equal)
+ add rTMP, rTMP, r7F7F
+ xor. rBITDIF, rWORD1, rWORD2
+
+ andc rNEG, rNEG, rTMP
+ blt- L(highbit)
+ cntlzw rBITDIF, rBITDIF
+ cntlzw rNEG, rNEG
+ addi rNEG, rNEG, 7
+ cmpw cr1, rNEG, rBITDIF
+ sub rRTN, rWORD1, rWORD2
+ blt- cr1, L(equal)
+ srawi rRTN, rRTN, 31
+ ori rRTN, rRTN, 1
+ blr
+L(equal):
+ li rRTN, 0
+ blr
+
+L(different):
+ lwzu rWORD1, -4(rSTR1)
+ xor. rBITDIF, rWORD1, rWORD2
+ sub rRTN, rWORD1, rWORD2
+ blt- L(highbit)
+ srawi rRTN, rRTN, 31
+ ori rRTN, rRTN, 1
+ blr
+L(highbit):
+ srwi rWORD2, rWORD2, 24
+ srwi rWORD1, rWORD1, 24
+ sub rRTN, rWORD1, rWORD2
+ blr
+
+
+/* Oh well. In this case, we just do a byte-by-byte comparison. */
+ .align 4
+L(tail):
+ and. rTMP, rTMP, rNEG
+ cmpw cr1, rWORD1, rWORD2
+ bne- L(endstring)
+ addi rSTR1, rSTR1, 4
+ bne- cr1, L(different)
+ addi rSTR2, rSTR2, 4
+ cmplwi cr1, rN, 0
+L(unaligned):
+ mtctr rN /* Power4 wants mtctr 1st in dispatch group */
+ ble cr1, L(ux)
+L(uz):
+ lbz rWORD1, 0(rSTR1)
+ lbz rWORD2, 0(rSTR2)
+ .align 4
+L(u1):
+ cmpwi cr1, rWORD1, 0
+ bdz L(u4)
+ cmpw rWORD1, rWORD2
+ beq- cr1, L(u4)
+ bne- L(u4)
+ lbzu rWORD3, 1(rSTR1)
+ lbzu rWORD4, 1(rSTR2)
+ cmpwi cr1, rWORD3, 0
+ bdz L(u3)
+ cmpw rWORD3, rWORD4
+ beq- cr1, L(u3)
+ bne- L(u3)
+ lbzu rWORD1, 1(rSTR1)
+ lbzu rWORD2, 1(rSTR2)
+ cmpwi cr1, rWORD1, 0
+ bdz L(u4)
+ cmpw rWORD1, rWORD2
+ beq- cr1, L(u4)
+ bne- L(u4)
+ lbzu rWORD3, 1(rSTR1)
+ lbzu rWORD4, 1(rSTR2)
+ cmpwi cr1, rWORD3, 0
+ bdz L(u3)
+ cmpw rWORD3, rWORD4
+ beq- cr1, L(u3)
+ bne- L(u3)
+ lbzu rWORD1, 1(rSTR1)
+ lbzu rWORD2, 1(rSTR2)
+ b L(u1)
+
+L(u3): sub rRTN, rWORD3, rWORD4
+ blr
+L(u4): sub rRTN, rWORD1, rWORD2
+ blr
+L(ux):
+ li rRTN, 0
+ blr
+END (__strncmp_power4)
diff --git a/sysdeps/powerpc/powerpc32/multiarch/strncmp-power7.S b/sysdeps/powerpc/powerpc32/multiarch/strncmp-power7.S
new file mode 100644
index 0000000..c2cb8cd
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/multiarch/strncmp-power7.S
@@ -0,0 +1,174 @@
+/* Optimized strcmp implementation for POWER7/PowerPC32.
+ Copyright (C) 2010-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>
+
+/* See strlen.s for comments on how the end-of-string testing works. */
+
+/* int [r3] strncmp (const char *s1 [r3],
+ const char *s2 [r4],
+ size_t size [r5]) */
+
+ .machine power7
+EALIGN (__strncmp_power7,5,0)
+
+#define rTMP r0
+#define rRTN r3
+#define rSTR1 r3 /* first string arg */
+#define rSTR2 r4 /* second string arg */
+#define rN r5 /* max string length */
+#define rWORD1 r6 /* current word in s1 */
+#define rWORD2 r7 /* current word in s2 */
+#define rWORD3 r10
+#define rWORD4 r11
+#define rFEFE r8 /* constant 0xfefefeff (-0x01010101) */
+#define r7F7F r9 /* constant 0x7f7f7f7f */
+#define rNEG r10 /* ~(word in s1 | 0x7f7f7f7f) */
+#define rBITDIF r11 /* bits that differ in s1 & s2 words */
+
+ dcbt 0,rSTR1
+ nop
+ or rTMP,rSTR2,rSTR1
+ lis r7F7F,0x7f7f
+ dcbt 0,rSTR2
+ nop
+ clrlwi. rTMP,rTMP,30
+ cmplwi cr1,rN,0
+ lis rFEFE,-0x101
+ bne L(unaligned)
+/* We are word aligned so set up for two loops. first a word
+ loop, then fall into the byte loop if any residual. */
+ srwi. rTMP,rN,2
+ clrlwi rN,rN,30
+ addi rFEFE,rFEFE,-0x101
+ addi r7F7F,r7F7F,0x7f7f
+ cmplwi cr1,rN,0
+ beq L(unaligned)
+
+ mtctr rTMP
+ lwz rWORD1,0(rSTR1)
+ lwz rWORD2,0(rSTR2)
+ b L(g1)
+
+L(g0):
+ lwzu rWORD1,4(rSTR1)
+ bne cr1,L(different)
+ lwzu rWORD2,4(rSTR2)
+L(g1): add rTMP,rFEFE,rWORD1
+ nor rNEG,r7F7F,rWORD1
+ bdz L(tail)
+ and. rTMP,rTMP,rNEG
+ cmpw cr1,rWORD1,rWORD2
+ beq L(g0)
+
+/* OK. We've hit the end of the string. We need to be careful that
+ we don't compare two strings as different because of gunk beyond
+ the end of the strings... */
+
+L(endstring):
+ and rTMP,r7F7F,rWORD1
+ beq cr1,L(equal)
+ add rTMP,rTMP,r7F7F
+ xor. rBITDIF,rWORD1,rWORD2
+
+ andc rNEG,rNEG,rTMP
+ blt L(highbit)
+ cntlzw rBITDIF,rBITDIF
+ cntlzw rNEG,rNEG
+ addi rNEG,rNEG,7
+ cmpw cr1,rNEG,rBITDIF
+ sub rRTN,rWORD1,rWORD2
+ blt cr1,L(equal)
+ srawi rRTN,rRTN,31
+ ori rRTN,rRTN,1
+ blr
+L(equal):
+ li rRTN,0
+ blr
+
+L(different):
+ lwzu rWORD1,-4(rSTR1)
+ xor. rBITDIF,rWORD1,rWORD2
+ sub rRTN,rWORD1,rWORD2
+ blt L(highbit)
+ srawi rRTN,rRTN,31
+ ori rRTN,rRTN,1
+ blr
+L(highbit):
+ srwi rWORD2,rWORD2,24
+ srwi rWORD1,rWORD1,24
+ sub rRTN,rWORD1,rWORD2
+ blr
+
+
+/* Oh well. In this case, we just do a byte-by-byte comparison. */
+ .align 4
+L(tail):
+ and. rTMP,rTMP,rNEG
+ cmpw cr1,rWORD1,rWORD2
+ bne L(endstring)
+ addi rSTR1,rSTR1,4
+ bne cr1,L(different)
+ addi rSTR2,rSTR2,4
+ cmplwi cr1,rN,0
+L(unaligned):
+ mtctr rN
+ ble cr1,L(ux)
+L(uz):
+ lbz rWORD1,0(rSTR1)
+ lbz rWORD2,0(rSTR2)
+ .align 4
+L(u1):
+ cmpwi cr1,rWORD1,0
+ bdz L(u4)
+ cmpw rWORD1,rWORD2
+ beq cr1,L(u4)
+ bne L(u4)
+ lbzu rWORD3,1(rSTR1)
+ lbzu rWORD4,1(rSTR2)
+ cmpwi cr1,rWORD3,0
+ bdz L(u3)
+ cmpw rWORD3,rWORD4
+ beq cr1,L(u3)
+ bne L(u3)
+ lbzu rWORD1,1(rSTR1)
+ lbzu rWORD2,1(rSTR2)
+ cmpwi cr1,rWORD1,0
+ bdz L(u4)
+ cmpw rWORD1,rWORD2
+ beq cr1,L(u4)
+ bne L(u4)
+ lbzu rWORD3,1(rSTR1)
+ lbzu rWORD4,1(rSTR2)
+ cmpwi cr1,rWORD3,0
+ bdz L(u3)
+ cmpw rWORD3,rWORD4
+ beq cr1,L(u3)
+ bne L(u3)
+ lbzu rWORD1,1(rSTR1)
+ lbzu rWORD2,1(rSTR2)
+ b L(u1)
+
+L(u3): sub rRTN,rWORD3,rWORD4
+ blr
+L(u4): sub rRTN,rWORD1,rWORD2
+ blr
+L(ux):
+ li rRTN,0
+ blr
+END (__strncmp_power7)
diff --git a/sysdeps/powerpc/powerpc32/multiarch/strncmp-ppc32.S b/sysdeps/powerpc/powerpc32/multiarch/strncmp-ppc32.S
new file mode 100644
index 0000000..0fc6df6
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/multiarch/strncmp-ppc32.S
@@ -0,0 +1,40 @@
+/* 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>
+
+#if defined SHARED && !defined NOT_IN_libc
+# undef EALIGN
+# define EALIGN(name, alignt, words) \
+ .globl C_SYMBOL_NAME(__strncmp_ppc32); \
+ .type C_SYMBOL_NAME(__strncmp_ppc32),@function; \
+ .align ALIGNARG(alignt); \
+ EALIGN_W_##words; \
+ C_LABEL(__strncmp_ppc32) \
+ cfi_startproc;
+
+# undef END
+# define END(name) \
+ cfi_endproc; \
+ ASM_SIZE_DIRECTIVE(__strncmp_ppc32)
+
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name) \
+ .globl __GI_strncmp; __GI_strncmp = __strncmp_ppc32
+#endif
+
+#include <sysdeps/powerpc/powerpc32/strncmp.S>
diff --git a/sysdeps/powerpc/powerpc32/multiarch/strncmp.c b/sysdeps/powerpc/powerpc32/multiarch/strncmp.c
new file mode 100644
index 0000000..32b96dc
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/multiarch/strncmp.c
@@ -0,0 +1,37 @@
+/* Multiple versions of strncmp.
+ 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. */
+#if defined SHARED && !defined NOT_IN_libc
+# include <string.h>
+# include <shlib-compat.h>
+# include "init-arch.h"
+
+extern __typeof (strncmp) __strncmp_ppc32 attribute_hidden;
+extern __typeof (strncmp) __strncmp_power4 attribute_hidden;
+extern __typeof (strncmp) __strncmp_power7 attribute_hidden;
+
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
+ ifunc symbol properly. */
+libc_ifunc (strncmp,
+ (hwcap & PPC_FEATURE_HAS_VSX)
+ ? __strncmp_power7 :
+ (hwcap & PPC_FEATURE_POWER4)
+ ? __strncmp_power4
+ : __strncmp_ppc32);
+#endif
diff --git a/sysdeps/powerpc/powerpc32/power4/strncmp.S b/sysdeps/powerpc/powerpc32/power4/strncmp.S
deleted file mode 100644
index 724d908..0000000
--- a/sysdeps/powerpc/powerpc32/power4/strncmp.S
+++ /dev/null
@@ -1,170 +0,0 @@
-/* Optimized strcmp implementation for PowerPC32.
- Copyright (C) 2003-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>
-
-/* See strlen.s for comments on how the end-of-string testing works. */
-
-/* int [r3] strncmp (const char *s1 [r3], const char *s2 [r4], size_t size [r5]) */
-
-EALIGN (strncmp, 4, 0)
-
-#define rTMP r0
-#define rRTN r3
-#define rSTR1 r3 /* first string arg */
-#define rSTR2 r4 /* second string arg */
-#define rN r5 /* max string length */
-#define rWORD1 r6 /* current word in s1 */
-#define rWORD2 r7 /* current word in s2 */
-#define rWORD3 r10
-#define rWORD4 r11
-#define rFEFE r8 /* constant 0xfefefeff (-0x01010101) */
-#define r7F7F r9 /* constant 0x7f7f7f7f */
-#define rNEG r10 /* ~(word in s1 | 0x7f7f7f7f) */
-#define rBITDIF r11 /* bits that differ in s1 & s2 words */
-
- dcbt 0,rSTR1
- or rTMP, rSTR2, rSTR1
- lis r7F7F, 0x7f7f
- dcbt 0,rSTR2
- clrlwi. rTMP, rTMP, 30
- cmplwi cr1, rN, 0
- lis rFEFE, -0x101
- bne L(unaligned)
-/* We are word aligned so set up for two loops. first a word
- loop, then fall into the byte loop if any residual. */
- srwi. rTMP, rN, 2
- clrlwi rN, rN, 30
- addi rFEFE, rFEFE, -0x101
- addi r7F7F, r7F7F, 0x7f7f
- cmplwi cr1, rN, 0
- beq L(unaligned)
-
- mtctr rTMP /* Power4 wants mtctr 1st in dispatch group. */
- lwz rWORD1, 0(rSTR1)
- lwz rWORD2, 0(rSTR2)
- b L(g1)
-
-L(g0):
- lwzu rWORD1, 4(rSTR1)
- bne- cr1, L(different)
- lwzu rWORD2, 4(rSTR2)
-L(g1): add rTMP, rFEFE, rWORD1
- nor rNEG, r7F7F, rWORD1
- bdz L(tail)
- and. rTMP, rTMP, rNEG
- cmpw cr1, rWORD1, rWORD2
- beq+ L(g0)
-
-/* OK. We've hit the end of the string. We need to be careful that
- we don't compare two strings as different because of gunk beyond
- the end of the strings... */
-
-L(endstring):
- and rTMP, r7F7F, rWORD1
- beq cr1, L(equal)
- add rTMP, rTMP, r7F7F
- xor. rBITDIF, rWORD1, rWORD2
-
- andc rNEG, rNEG, rTMP
- blt- L(highbit)
- cntlzw rBITDIF, rBITDIF
- cntlzw rNEG, rNEG
- addi rNEG, rNEG, 7
- cmpw cr1, rNEG, rBITDIF
- sub rRTN, rWORD1, rWORD2
- blt- cr1, L(equal)
- srawi rRTN, rRTN, 31
- ori rRTN, rRTN, 1
- blr
-L(equal):
- li rRTN, 0
- blr
-
-L(different):
- lwzu rWORD1, -4(rSTR1)
- xor. rBITDIF, rWORD1, rWORD2
- sub rRTN, rWORD1, rWORD2
- blt- L(highbit)
- srawi rRTN, rRTN, 31
- ori rRTN, rRTN, 1
- blr
-L(highbit):
- srwi rWORD2, rWORD2, 24
- srwi rWORD1, rWORD1, 24
- sub rRTN, rWORD1, rWORD2
- blr
-
-
-/* Oh well. In this case, we just do a byte-by-byte comparison. */
- .align 4
-L(tail):
- and. rTMP, rTMP, rNEG
- cmpw cr1, rWORD1, rWORD2
- bne- L(endstring)
- addi rSTR1, rSTR1, 4
- bne- cr1, L(different)
- addi rSTR2, rSTR2, 4
- cmplwi cr1, rN, 0
-L(unaligned):
- mtctr rN /* Power4 wants mtctr 1st in dispatch group */
- ble cr1, L(ux)
-L(uz):
- lbz rWORD1, 0(rSTR1)
- lbz rWORD2, 0(rSTR2)
- .align 4
-L(u1):
- cmpwi cr1, rWORD1, 0
- bdz L(u4)
- cmpw rWORD1, rWORD2
- beq- cr1, L(u4)
- bne- L(u4)
- lbzu rWORD3, 1(rSTR1)
- lbzu rWORD4, 1(rSTR2)
- cmpwi cr1, rWORD3, 0
- bdz L(u3)
- cmpw rWORD3, rWORD4
- beq- cr1, L(u3)
- bne- L(u3)
- lbzu rWORD1, 1(rSTR1)
- lbzu rWORD2, 1(rSTR2)
- cmpwi cr1, rWORD1, 0
- bdz L(u4)
- cmpw rWORD1, rWORD2
- beq- cr1, L(u4)
- bne- L(u4)
- lbzu rWORD3, 1(rSTR1)
- lbzu rWORD4, 1(rSTR2)
- cmpwi cr1, rWORD3, 0
- bdz L(u3)
- cmpw rWORD3, rWORD4
- beq- cr1, L(u3)
- bne- L(u3)
- lbzu rWORD1, 1(rSTR1)
- lbzu rWORD2, 1(rSTR2)
- b L(u1)
-
-L(u3): sub rRTN, rWORD3, rWORD4
- blr
-L(u4): sub rRTN, rWORD1, rWORD2
- blr
-L(ux):
- li rRTN, 0
- blr
-END (strncmp)
-libc_hidden_builtin_def (strncmp)
diff --git a/sysdeps/powerpc/powerpc32/power7/strncmp.S b/sysdeps/powerpc/powerpc32/power7/strncmp.S
deleted file mode 100644
index fdae44d..0000000
--- a/sysdeps/powerpc/powerpc32/power7/strncmp.S
+++ /dev/null
@@ -1,174 +0,0 @@
-/* Optimized strcmp implementation for POWER7/PowerPC32.
- Copyright (C) 2010-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>
-
-/* See strlen.s for comments on how the end-of-string testing works. */
-
-/* int [r3] strncmp (const char *s1 [r3],
- const char *s2 [r4],
- size_t size [r5]) */
-
-EALIGN (strncmp,5,0)
-
-#define rTMP r0
-#define rRTN r3
-#define rSTR1 r3 /* first string arg */
-#define rSTR2 r4 /* second string arg */
-#define rN r5 /* max string length */
-#define rWORD1 r6 /* current word in s1 */
-#define rWORD2 r7 /* current word in s2 */
-#define rWORD3 r10
-#define rWORD4 r11
-#define rFEFE r8 /* constant 0xfefefeff (-0x01010101) */
-#define r7F7F r9 /* constant 0x7f7f7f7f */
-#define rNEG r10 /* ~(word in s1 | 0x7f7f7f7f) */
-#define rBITDIF r11 /* bits that differ in s1 & s2 words */
-
- dcbt 0,rSTR1
- nop
- or rTMP,rSTR2,rSTR1
- lis r7F7F,0x7f7f
- dcbt 0,rSTR2
- nop
- clrlwi. rTMP,rTMP,30
- cmplwi cr1,rN,0
- lis rFEFE,-0x101
- bne L(unaligned)
-/* We are word aligned so set up for two loops. first a word
- loop, then fall into the byte loop if any residual. */
- srwi. rTMP,rN,2
- clrlwi rN,rN,30
- addi rFEFE,rFEFE,-0x101
- addi r7F7F,r7F7F,0x7f7f
- cmplwi cr1,rN,0
- beq L(unaligned)
-
- mtctr rTMP
- lwz rWORD1,0(rSTR1)
- lwz rWORD2,0(rSTR2)
- b L(g1)
-
-L(g0):
- lwzu rWORD1,4(rSTR1)
- bne cr1,L(different)
- lwzu rWORD2,4(rSTR2)
-L(g1): add rTMP,rFEFE,rWORD1
- nor rNEG,r7F7F,rWORD1
- bdz L(tail)
- and. rTMP,rTMP,rNEG
- cmpw cr1,rWORD1,rWORD2
- beq L(g0)
-
-/* OK. We've hit the end of the string. We need to be careful that
- we don't compare two strings as different because of gunk beyond
- the end of the strings... */
-
-L(endstring):
- and rTMP,r7F7F,rWORD1
- beq cr1,L(equal)
- add rTMP,rTMP,r7F7F
- xor. rBITDIF,rWORD1,rWORD2
-
- andc rNEG,rNEG,rTMP
- blt L(highbit)
- cntlzw rBITDIF,rBITDIF
- cntlzw rNEG,rNEG
- addi rNEG,rNEG,7
- cmpw cr1,rNEG,rBITDIF
- sub rRTN,rWORD1,rWORD2
- blt cr1,L(equal)
- srawi rRTN,rRTN,31
- ori rRTN,rRTN,1
- blr
-L(equal):
- li rRTN,0
- blr
-
-L(different):
- lwzu rWORD1,-4(rSTR1)
- xor. rBITDIF,rWORD1,rWORD2
- sub rRTN,rWORD1,rWORD2
- blt L(highbit)
- srawi rRTN,rRTN,31
- ori rRTN,rRTN,1
- blr
-L(highbit):
- srwi rWORD2,rWORD2,24
- srwi rWORD1,rWORD1,24
- sub rRTN,rWORD1,rWORD2
- blr
-
-
-/* Oh well. In this case, we just do a byte-by-byte comparison. */
- .align 4
-L(tail):
- and. rTMP,rTMP,rNEG
- cmpw cr1,rWORD1,rWORD2
- bne L(endstring)
- addi rSTR1,rSTR1,4
- bne cr1,L(different)
- addi rSTR2,rSTR2,4
- cmplwi cr1,rN,0
-L(unaligned):
- mtctr rN
- ble cr1,L(ux)
-L(uz):
- lbz rWORD1,0(rSTR1)
- lbz rWORD2,0(rSTR2)
- .align 4
-L(u1):
- cmpwi cr1,rWORD1,0
- bdz L(u4)
- cmpw rWORD1,rWORD2
- beq cr1,L(u4)
- bne L(u4)
- lbzu rWORD3,1(rSTR1)
- lbzu rWORD4,1(rSTR2)
- cmpwi cr1,rWORD3,0
- bdz L(u3)
- cmpw rWORD3,rWORD4
- beq cr1,L(u3)
- bne L(u3)
- lbzu rWORD1,1(rSTR1)
- lbzu rWORD2,1(rSTR2)
- cmpwi cr1,rWORD1,0
- bdz L(u4)
- cmpw rWORD1,rWORD2
- beq cr1,L(u4)
- bne L(u4)
- lbzu rWORD3,1(rSTR1)
- lbzu rWORD4,1(rSTR2)
- cmpwi cr1,rWORD3,0
- bdz L(u3)
- cmpw rWORD3,rWORD4
- beq cr1,L(u3)
- bne L(u3)
- lbzu rWORD1,1(rSTR1)
- lbzu rWORD2,1(rSTR2)
- b L(u1)
-
-L(u3): sub rRTN,rWORD3,rWORD4
- blr
-L(u4): sub rRTN,rWORD1,rWORD2
- blr
-L(ux):
- li rRTN,0
- blr
-END (strncmp)
-libc_hidden_builtin_def (strncmp)