|
|
ce426f |
From f4f918430b6b74f1801ebe39a8824cc5437ba9d4 Mon Sep 17 00:00:00 2001
|
|
|
ce426f |
From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>
|
|
|
ce426f |
Date: Mon, 25 Apr 2016 09:11:02 -0500
|
|
|
ce426f |
Subject: [PATCH] powerpc: Add optimized strcspn for P8
|
|
|
ce426f |
|
|
|
ce426f |
A few minor adjustments to the P8 strspn gives us
|
|
|
ce426f |
an almost equally optimized P8 strcspn.
|
|
|
ce426f |
|
|
|
ce426f |
(cherry picked from commit 8f1b841e452dbb083112fd036033b7f4af506ba0)
|
|
|
ce426f |
---
|
|
|
ce426f |
ChangeLog | 25 ++++++++++++
|
|
|
ce426f |
sysdeps/powerpc/powerpc64/multiarch/Makefile | 4 +-
|
|
|
ce426f |
.../powerpc/powerpc64/multiarch/ifunc-impl-list.c | 8 ++++
|
|
|
ce426f |
.../powerpc/powerpc64/multiarch/strcspn-power8.S | 25 ++++++++++++
|
|
|
ce426f |
.../powerpc/powerpc64/multiarch/strcspn-ppc64.c | 26 +++++++++++++
|
|
|
ce426f |
sysdeps/powerpc/powerpc64/multiarch/strcspn.c | 35 +++++++++++++++++
|
|
|
ce426f |
.../powerpc/powerpc64/multiarch/strspn-power8.S | 17 +-------
|
|
|
ce426f |
sysdeps/powerpc/powerpc64/power8/strcspn.S | 20 ++++++++++
|
|
|
ce426f |
sysdeps/powerpc/powerpc64/power8/strspn.S | 45 ++++++++++++++++------
|
|
|
ce426f |
9 files changed, 176 insertions(+), 29 deletions(-)
|
|
|
ce426f |
create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strcspn-power8.S
|
|
|
ce426f |
create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strcspn-ppc64.c
|
|
|
ce426f |
create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strcspn.c
|
|
|
ce426f |
create mode 100644 sysdeps/powerpc/powerpc64/power8/strcspn.S
|
|
|
ce426f |
|
|
|
ce426f |
diff --git a/ChangeLog b/ChangeLog
|
|
|
ce426f |
index 6677ea2..5537fc6 100644
|
|
|
ce426f |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
|
|
|
ce426f |
index 7f70ceb..9ee9bc2 100644
|
|
|
ce426f |
--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
|
|
|
ce426f |
+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
|
|
|
ce426f |
@@ -20,6 +20,7 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
|
|
|
ce426f |
strcat-power8 strcat-power7 strcat-ppc64 \
|
|
|
ce426f |
strcmp-power8 strcmp-power7 strcmp-ppc64 \
|
|
|
ce426f |
strcpy-power8 strcpy-power7 strcpy-ppc64 \
|
|
|
ce426f |
+ strcspn-power8 strcspn-ppc64 \
|
|
|
ce426f |
stpncpy-power8 stpncpy-power7 stpncpy-ppc64 \
|
|
|
ce426f |
strncpy-power8 strncpy-power7 strncpy-ppc64 \
|
|
|
ce426f |
strncat-power7 \
|
|
|
ce426f |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
|
|
|
ce426f |
index 994e852..228891f 100644
|
|
|
ce426f |
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
|
|
|
ce426f |
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
|
|
|
ce426f |
@@ -332,6 +332,14 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
ce426f |
IFUNC_IMPL_ADD (array, i, strspn, 1,
|
|
|
ce426f |
__strspn_ppc))
|
|
|
ce426f |
|
|
|
ce426f |
+ /* Support sysdeps/powerpc/powerpc64/multiarch/strcspn.c. */
|
|
|
ce426f |
+ IFUNC_IMPL (i, name, strcspn,
|
|
|
ce426f |
+ IFUNC_IMPL_ADD (array, i, strcspn,
|
|
|
ce426f |
+ hwcap2 & PPC_FEATURE2_ARCH_2_07,
|
|
|
ce426f |
+ __strcspn_power8)
|
|
|
ce426f |
+ IFUNC_IMPL_ADD (array, i, strcspn, 1,
|
|
|
ce426f |
+ __strcspn_ppc))
|
|
|
ce426f |
+
|
|
|
ce426f |
/* Support sysdeps/powerpc/powerpc64/multiarch/strstr.c. */
|
|
|
ce426f |
IFUNC_IMPL (i, name, strstr,
|
|
|
ce426f |
IFUNC_IMPL_ADD (array, i, strstr,
|
|
|
ce426f |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcspn-power8.S b/sysdeps/powerpc/powerpc64/multiarch/strcspn-power8.S
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..25545f8
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcspn-power8.S
|
|
|
ce426f |
@@ -0,0 +1,25 @@
|
|
|
ce426f |
+/* Optimized strcspn implementation for POWER8.
|
|
|
ce426f |
+ Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
ce426f |
+ This file is part of the GNU C Library.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
ce426f |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
ce426f |
+ License as published by the Free Software Foundation; either
|
|
|
ce426f |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
ce426f |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ce426f |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
ce426f |
+ Lesser General Public License for more details.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
ce426f |
+ License along with the GNU C Library; if not, see
|
|
|
ce426f |
+ <http://www.gnu.org/licenses/>. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+#include <sysdep.h>
|
|
|
ce426f |
+
|
|
|
ce426f |
+#define STRSPN __strcspn_power8
|
|
|
ce426f |
+#undef libc_hidden_builtin_def
|
|
|
ce426f |
+#define libc_hidden_builtin_def(name)
|
|
|
ce426f |
+
|
|
|
ce426f |
+#include <sysdeps/powerpc/powerpc64/power8/strcspn.S>
|
|
|
ce426f |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcspn-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/strcspn-ppc64.c
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..4c16386
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcspn-ppc64.c
|
|
|
ce426f |
@@ -0,0 +1,26 @@
|
|
|
ce426f |
+/* Default strcspn implementation for PowerPC64.
|
|
|
ce426f |
+ Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
ce426f |
+ This file is part of the GNU C Library.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
ce426f |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
ce426f |
+ License as published by the Free Software Foundation; either
|
|
|
ce426f |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
ce426f |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ce426f |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
ce426f |
+ Lesser General Public License for more details.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
ce426f |
+ License along with the GNU C Library; if not, see
|
|
|
ce426f |
+ <http://www.gnu.org/licenses/>. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+#define STRCSPN __strcspn_ppc
|
|
|
ce426f |
+
|
|
|
ce426f |
+#ifdef SHARED
|
|
|
ce426f |
+# undef libc_hidden_def
|
|
|
ce426f |
+# define libc_hidden_def(name)
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+
|
|
|
ce426f |
+#include <string/strcspn.c>
|
|
|
ce426f |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcspn.c b/sysdeps/powerpc/powerpc64/multiarch/strcspn.c
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..e7343ee
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcspn.c
|
|
|
ce426f |
@@ -0,0 +1,35 @@
|
|
|
ce426f |
+/* Multiple versions of strcspn. PowerPC64 version.
|
|
|
ce426f |
+ Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
ce426f |
+ This file is part of the GNU C Library.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
ce426f |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
ce426f |
+ License as published by the Free Software Foundation; either
|
|
|
ce426f |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
ce426f |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ce426f |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
ce426f |
+ Lesser General Public License for more details.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
ce426f |
+ License along with the GNU C Library; if not, see
|
|
|
ce426f |
+ <http://www.gnu.org/licenses/>. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+#include <string.h>
|
|
|
ce426f |
+#include <shlib-compat.h>
|
|
|
ce426f |
+#include "init-arch.h"
|
|
|
ce426f |
+
|
|
|
ce426f |
+#undef strcspn
|
|
|
ce426f |
+extern __typeof (strcspn) __libc_strcspn;
|
|
|
ce426f |
+
|
|
|
ce426f |
+extern __typeof (strcspn) __strcspn_ppc attribute_hidden;
|
|
|
ce426f |
+extern __typeof (strcspn) __strcspn_power8 attribute_hidden;
|
|
|
ce426f |
+
|
|
|
ce426f |
+libc_ifunc (__libc_strcspn,
|
|
|
ce426f |
+ (hwcap2 & PPC_FEATURE2_ARCH_2_07)
|
|
|
ce426f |
+ ? __strcspn_power8
|
|
|
ce426f |
+ : __strcspn_ppc);
|
|
|
ce426f |
+
|
|
|
ce426f |
+weak_alias (__libc_strcspn, strcspn)
|
|
|
ce426f |
+libc_hidden_builtin_def (strcspn)
|
|
|
ce426f |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strspn-power8.S b/sysdeps/powerpc/powerpc64/multiarch/strspn-power8.S
|
|
|
ce426f |
index 86a4e09..27d25e0 100644
|
|
|
ce426f |
--- a/sysdeps/powerpc/powerpc64/multiarch/strspn-power8.S
|
|
|
ce426f |
+++ b/sysdeps/powerpc/powerpc64/multiarch/strspn-power8.S
|
|
|
ce426f |
@@ -18,22 +18,7 @@
|
|
|
ce426f |
|
|
|
ce426f |
#include <sysdep.h>
|
|
|
ce426f |
|
|
|
ce426f |
-#undef EALIGN
|
|
|
ce426f |
-#define EALIGN(name, alignt, words) \
|
|
|
ce426f |
- .section ".text"; \
|
|
|
ce426f |
- ENTRY_2(__strspn_power8) \
|
|
|
ce426f |
- .align ALIGNARG(alignt); \
|
|
|
ce426f |
- EALIGN_W_##words; \
|
|
|
ce426f |
- BODY_LABEL(__strspn_power8): \
|
|
|
ce426f |
- cfi_startproc; \
|
|
|
ce426f |
- LOCALENTRY(__strspn_power8)
|
|
|
ce426f |
-
|
|
|
ce426f |
-#undef END
|
|
|
ce426f |
-#define END(name) \
|
|
|
ce426f |
- cfi_endproc; \
|
|
|
ce426f |
- TRACEBACK(__strspn_power8) \
|
|
|
ce426f |
- END_2(__strspn_power8)
|
|
|
ce426f |
-
|
|
|
ce426f |
+#define STRSPN __strspn_power8
|
|
|
ce426f |
#undef libc_hidden_builtin_def
|
|
|
ce426f |
#define libc_hidden_builtin_def(name)
|
|
|
ce426f |
|
|
|
ce426f |
diff --git a/sysdeps/powerpc/powerpc64/power8/strcspn.S b/sysdeps/powerpc/powerpc64/power8/strcspn.S
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..bfc58a8
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/sysdeps/powerpc/powerpc64/power8/strcspn.S
|
|
|
ce426f |
@@ -0,0 +1,20 @@
|
|
|
ce426f |
+/* Optimized strcspn implementation for PowerPC64/POWER8.
|
|
|
ce426f |
+ Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
ce426f |
+ This file is part of the GNU C Library.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
ce426f |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
ce426f |
+ License as published by the Free Software Foundation; either
|
|
|
ce426f |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
ce426f |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ce426f |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
ce426f |
+ Lesser General Public License for more details.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
ce426f |
+ License along with the GNU C Library; if not, see
|
|
|
ce426f |
+ <http://www.gnu.org/licenses/>. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+#define USE_AS_STRCSPN 1
|
|
|
ce426f |
+#include <sysdeps/powerpc/powerpc64/power8/strspn.S>
|
|
|
ce426f |
diff --git a/sysdeps/powerpc/powerpc64/power8/strspn.S b/sysdeps/powerpc/powerpc64/power8/strspn.S
|
|
|
ce426f |
index 0dda437..011081d 100644
|
|
|
ce426f |
--- a/sysdeps/powerpc/powerpc64/power8/strspn.S
|
|
|
ce426f |
+++ b/sysdeps/powerpc/powerpc64/power8/strspn.S
|
|
|
ce426f |
@@ -33,6 +33,21 @@
|
|
|
ce426f |
|
|
|
ce426f |
#include "sysdep.h"
|
|
|
ce426f |
|
|
|
ce426f |
+#ifndef USE_AS_STRCSPN
|
|
|
ce426f |
+# define USE_AS_STRCSPN 0
|
|
|
ce426f |
+# ifndef STRSPN
|
|
|
ce426f |
+# define STRSPN strspn
|
|
|
ce426f |
+# endif
|
|
|
ce426f |
+# define INITIAL_MASK 0
|
|
|
ce426f |
+# define UPDATE_MASK(RA, RS, RB) or RA, RS, RB
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+# ifndef STRSPN
|
|
|
ce426f |
+# define STRSPN strcspn
|
|
|
ce426f |
+# endif
|
|
|
ce426f |
+# define INITIAL_MASK -1
|
|
|
ce426f |
+# define UPDATE_MASK(RA, RS, RB) andc RA, RS, RB
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+
|
|
|
ce426f |
/* Simple macro to use VSX instructions in overlapping VR's. */
|
|
|
ce426f |
#define XXVR(insn, vrt, vra, vrb) \
|
|
|
ce426f |
insn 32+vrt, 32+vra, 32+vrb
|
|
|
ce426f |
@@ -53,7 +68,7 @@
|
|
|
ce426f |
/* This can be updated to power8 once the minimum version of
|
|
|
ce426f |
binutils supports power8 and the above instructions. */
|
|
|
ce426f |
.machine power7
|
|
|
ce426f |
-EALIGN(strspn, 4, 0)
|
|
|
ce426f |
+EALIGN(STRSPN, 4, 0)
|
|
|
ce426f |
CALL_MCOUNT 2
|
|
|
ce426f |
|
|
|
ce426f |
/* Generate useful constants for later on. */
|
|
|
ce426f |
@@ -66,10 +81,18 @@ EALIGN(strspn, 4, 0)
|
|
|
ce426f |
|
|
|
ce426f |
/* Prepare to compute 256b mask. */
|
|
|
ce426f |
addi r4, r4, -1
|
|
|
ce426f |
- li r5, 0
|
|
|
ce426f |
- li r6, 0
|
|
|
ce426f |
- li r7, 0
|
|
|
ce426f |
- li r8, 0
|
|
|
ce426f |
+ li r5, INITIAL_MASK
|
|
|
ce426f |
+ li r6, INITIAL_MASK
|
|
|
ce426f |
+ li r7, INITIAL_MASK
|
|
|
ce426f |
+ li r8, INITIAL_MASK
|
|
|
ce426f |
+
|
|
|
ce426f |
+#if USE_AS_STRCSPN
|
|
|
ce426f |
+ /* Ensure the null character never matches by clearing ISA bit 0 in
|
|
|
ce426f |
+ in r5 which is the bit which will check for it in the later usage
|
|
|
ce426f |
+ of vbpermq. */
|
|
|
ce426f |
+ srdi r5, r5, 1
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+
|
|
|
ce426f |
li r11, 1
|
|
|
ce426f |
sldi r11, r11, 63
|
|
|
ce426f |
|
|
|
ce426f |
@@ -97,14 +120,14 @@ L(next_needle):
|
|
|
ce426f |
|
|
|
ce426f |
/* Now, or the value into the correct GPR. */
|
|
|
ce426f |
bge cr1,L(needle_gt128)
|
|
|
ce426f |
- or r5, r5, r10 /* 0 - 63. */
|
|
|
ce426f |
- or r6, r6, r12 /* 64 - 127. */
|
|
|
ce426f |
+ UPDATE_MASK (r5, r5, r10) /* 0 - 63. */
|
|
|
ce426f |
+ UPDATE_MASK (r6, r6, r12) /* 64 - 127. */
|
|
|
ce426f |
b L(next_needle)
|
|
|
ce426f |
|
|
|
ce426f |
.align 4
|
|
|
ce426f |
L(needle_gt128):
|
|
|
ce426f |
- or r7, r7, r10 /* 128 - 191. */
|
|
|
ce426f |
- or r8, r8, r12 /* 192 - 255. */
|
|
|
ce426f |
+ UPDATE_MASK (r7, r7, r10) /* 128 - 191. */
|
|
|
ce426f |
+ UPDATE_MASK (r8, r8, r12) /* 192 - 255. */
|
|
|
ce426f |
b L(next_needle)
|
|
|
ce426f |
|
|
|
ce426f |
|
|
|
ce426f |
@@ -175,5 +198,5 @@ L(done):
|
|
|
ce426f |
add r3, r3, r10
|
|
|
ce426f |
blr
|
|
|
ce426f |
|
|
|
ce426f |
-END(strspn)
|
|
|
ce426f |
-libc_hidden_builtin_def (strspn)
|
|
|
ce426f |
+END(STRSPN)
|
|
|
ce426f |
+libc_hidden_builtin_def (STRSPN)
|
|
|
ce426f |
--
|
|
|
ce426f |
2.1.0
|
|
|
ce426f |
|