|
|
147e83 |
From 111012ea9031349ebbd7cc992b71662bdd10397c Mon Sep 17 00:00:00 2001
|
|
|
147e83 |
From: Stefan Liebler <stli@linux.vnet.ibm.com>
|
|
|
147e83 |
Date: Thu, 8 Oct 2015 11:18:25 +0200
|
|
|
147e83 |
Subject: [PATCH 18/30] S390: Optimize strcmp and wcscmp.
|
|
|
147e83 |
|
|
|
147e83 |
upstream-commit-id: 63724a6db60f98e91da474d11d83a19aa10fc54e
|
|
|
147e83 |
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00084.html
|
|
|
147e83 |
|
|
|
147e83 |
This patch provides optimized versions of strcmp and wcscmp with the z13
|
|
|
147e83 |
vector instructions.
|
|
|
147e83 |
|
|
|
147e83 |
The architecture specific string.h had a typo, which leads to ommiting the
|
|
|
147e83 |
inline version in this file if __USE_STRING_INLINES is defined.
|
|
|
147e83 |
Tested this inline version by tweaking test-strcmp.c.
|
|
|
147e83 |
|
|
|
147e83 |
ChangeLog:
|
|
|
147e83 |
|
|
|
147e83 |
* sysdeps/s390/multiarch/strcmp-vx.S: New File.
|
|
|
147e83 |
* sysdeps/s390/multiarch/strcmp.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/wcscmp-c.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/wcscmp-vx.S: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/wcscmp.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/s390-32/multiarch/strcmp.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/s390-64/multiarch/strcmp.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add strcmp and
|
|
|
147e83 |
wcscmp functions.
|
|
|
147e83 |
* sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
(__libc_ifunc_impl_list): Add ifunc test for strcmp, wcscmp.
|
|
|
147e83 |
* string/strcmp.c (STRCMP): Define and use macro.
|
|
|
147e83 |
* benchtests/bench-wcscmp.c: New File.
|
|
|
147e83 |
* benchtests/Makefile (wcsmbs-bench): Add wcscmp.
|
|
|
147e83 |
* sysdeps/s390/bits/string.h: Fix typo: _HAVE_STRING_ARCH_strcmp
|
|
|
147e83 |
instead of _HAVE_STRING_ARCH_memchr.
|
|
|
147e83 |
---
|
|
|
147e83 |
benchtests/Makefile | 3 +-
|
|
|
147e83 |
benchtests/bench-wcscmp.c | 20 +++++
|
|
|
147e83 |
string/strcmp.c | 6 +-
|
|
|
147e83 |
sysdeps/s390/bits/string.h | 4 +-
|
|
|
147e83 |
sysdeps/s390/multiarch/Makefile | 6 +-
|
|
|
147e83 |
sysdeps/s390/multiarch/ifunc-impl-list.c | 3 +
|
|
|
147e83 |
sysdeps/s390/multiarch/strcmp-vx.S | 116 +++++++++++++++++++++++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/strcmp.c | 26 ++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/wcscmp-c.c | 30 +++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/wcscmp-vx.S | 131 +++++++++++++++++++++++++++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/wcscmp.c | 27 +++++++
|
|
|
147e83 |
sysdeps/s390/s390-32/multiarch/strcmp.c | 21 +++++
|
|
|
147e83 |
sysdeps/s390/s390-64/multiarch/strcmp.c | 21 +++++
|
|
|
147e83 |
13 files changed, 408 insertions(+), 6 deletions(-)
|
|
|
147e83 |
create mode 100644 benchtests/bench-wcscmp.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/strcmp-vx.S
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/strcmp.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/wcscmp-c.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/wcscmp-vx.S
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/wcscmp.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/s390-32/multiarch/strcmp.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/s390-64/multiarch/strcmp.c
|
|
|
147e83 |
|
|
|
147e83 |
diff --git a/benchtests/Makefile b/benchtests/Makefile
|
|
|
147e83 |
index fd8b7ee..f6333eb 100644
|
|
|
147e83 |
--- a/benchtests/Makefile
|
|
|
147e83 |
+++ b/benchtests/Makefile
|
|
|
147e83 |
@@ -38,7 +38,8 @@ string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
|
|
|
147e83 |
strcat strchr strchrnul strcmp strcpy strcspn strlen \
|
|
|
147e83 |
strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
|
|
|
147e83 |
strspn strstr strcpy_chk stpcpy_chk memrchr strsep strtok
|
|
|
147e83 |
-wcsmbs-bench := wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat
|
|
|
147e83 |
+wcsmbs-bench := wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat \
|
|
|
147e83 |
+ wcsncmp
|
|
|
147e83 |
string-bench-all := $(string-bench) ${wcsmbs-bench}
|
|
|
147e83 |
|
|
|
147e83 |
stdlib-bench := strtod
|
|
|
147e83 |
diff --git a/benchtests/bench-wcscmp.c b/benchtests/bench-wcscmp.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..bd483a2
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/benchtests/bench-wcscmp.c
|
|
|
147e83 |
@@ -0,0 +1,20 @@
|
|
|
147e83 |
+/* Measure wcscmp functions.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#define WIDE 1
|
|
|
147e83 |
+#include "bench-strcmp.c"
|
|
|
147e83 |
diff --git a/string/strcmp.c b/string/strcmp.c
|
|
|
147e83 |
index 8229d7c..5384db9 100644
|
|
|
147e83 |
--- a/string/strcmp.c
|
|
|
147e83 |
+++ b/string/strcmp.c
|
|
|
147e83 |
@@ -20,11 +20,15 @@
|
|
|
147e83 |
|
|
|
147e83 |
#undef strcmp
|
|
|
147e83 |
|
|
|
147e83 |
+#ifndef STRCMP
|
|
|
147e83 |
+# define STRCMP strcmp
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
+
|
|
|
147e83 |
/* Compare S1 and S2, returning less than, equal to or
|
|
|
147e83 |
greater than zero if S1 is lexicographically less than,
|
|
|
147e83 |
equal to or greater than S2. */
|
|
|
147e83 |
int
|
|
|
147e83 |
-strcmp (p1, p2)
|
|
|
147e83 |
+STRCMP (p1, p2)
|
|
|
147e83 |
const char *p1;
|
|
|
147e83 |
const char *p2;
|
|
|
147e83 |
{
|
|
|
147e83 |
diff --git a/sysdeps/s390/bits/string.h b/sysdeps/s390/bits/string.h
|
|
|
147e83 |
index f3070f1..037aa71 100644
|
|
|
147e83 |
--- a/sysdeps/s390/bits/string.h
|
|
|
147e83 |
+++ b/sysdeps/s390/bits/string.h
|
|
|
147e83 |
@@ -226,8 +226,8 @@ memchr (const void *__str, int __c, size_t __n)
|
|
|
147e83 |
}
|
|
|
147e83 |
#endif
|
|
|
147e83 |
|
|
|
147e83 |
-/* Search N bytes of S for C. */
|
|
|
147e83 |
-#define _HAVE_STRING_ARCH_memchr 1
|
|
|
147e83 |
+/* Compare S1 and S2. */
|
|
|
147e83 |
+#define _HAVE_STRING_ARCH_strchr 1
|
|
|
147e83 |
#ifndef _FORCE_INLINES
|
|
|
147e83 |
__STRING_INLINE int
|
|
|
147e83 |
strcmp (const char *__s1, const char *__s2)
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
|
|
|
147e83 |
index 33c1398..d8fbd55 100644
|
|
|
147e83 |
--- a/sysdeps/s390/multiarch/Makefile
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/Makefile
|
|
|
147e83 |
@@ -6,7 +6,8 @@ sysdep_routines += strlen strlen-vx strlen-c \
|
|
|
147e83 |
strncpy strncpy-vx \
|
|
|
147e83 |
stpncpy stpncpy-vx stpncpy-c \
|
|
|
147e83 |
strcat strcat-vx strcat-c \
|
|
|
147e83 |
- strncat strncat-vx strncat-c
|
|
|
147e83 |
+ strncat strncat-vx strncat-c \
|
|
|
147e83 |
+ strcmp strcmp-vx
|
|
|
147e83 |
endif
|
|
|
147e83 |
|
|
|
147e83 |
ifeq ($(subdir),wcsmbs)
|
|
|
147e83 |
@@ -17,5 +18,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \
|
|
|
147e83 |
wcsncpy wcsncpy-vx wcsncpy-c \
|
|
|
147e83 |
wcpncpy wcpncpy-vx wcpncpy-c \
|
|
|
147e83 |
wcscat wcscat-vx wcscat-c \
|
|
|
147e83 |
- wcsncat wcsncat-vx wcsncat-c
|
|
|
147e83 |
+ wcsncat wcsncat-vx wcsncat-c \
|
|
|
147e83 |
+ wcscmp wcscmp-vx wcscmp-c
|
|
|
147e83 |
endif
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
index 1e57c0e..196d3ec 100644
|
|
|
147e83 |
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
@@ -103,6 +103,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
147e83 |
IFUNC_VX_IMPL (strncat);
|
|
|
147e83 |
IFUNC_VX_IMPL (wcsncat);
|
|
|
147e83 |
|
|
|
147e83 |
+ IFUNC_VX_IMPL (strcmp);
|
|
|
147e83 |
+ IFUNC_VX_IMPL (wcscmp);
|
|
|
147e83 |
+
|
|
|
147e83 |
#endif /* HAVE_S390_VX_ASM_SUPPORT */
|
|
|
147e83 |
|
|
|
147e83 |
return i;
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/strcmp-vx.S b/sysdeps/s390/multiarch/strcmp-vx.S
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..57fce75
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/strcmp-vx.S
|
|
|
147e83 |
@@ -0,0 +1,116 @@
|
|
|
147e83 |
+/* Vector optimized 32/64 bit S/390 version of strcmp.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
147e83 |
+
|
|
|
147e83 |
+# include "sysdep.h"
|
|
|
147e83 |
+# include "asm-syntax.h"
|
|
|
147e83 |
+
|
|
|
147e83 |
+ .text
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* int strcmp (const char *s1, const char *s2)
|
|
|
147e83 |
+ Compare two strings
|
|
|
147e83 |
+
|
|
|
147e83 |
+ Register usage:
|
|
|
147e83 |
+ -r1=loaded byte count s1
|
|
|
147e83 |
+ -r2=s1
|
|
|
147e83 |
+ -r3=s2
|
|
|
147e83 |
+ -r4=loaded byte coutn s2, tmp
|
|
|
147e83 |
+ -r5=current_len
|
|
|
147e83 |
+ -v16=part of s1
|
|
|
147e83 |
+ -v17=part of s2
|
|
|
147e83 |
+ -v18=index of unequal
|
|
|
147e83 |
+*/
|
|
|
147e83 |
+ENTRY(__strcmp_vx)
|
|
|
147e83 |
+ .machine "z13"
|
|
|
147e83 |
+ .machinemode "zarch_nohighgprs"
|
|
|
147e83 |
+
|
|
|
147e83 |
+ lghi %r5,0 /* current_len = 0. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lloop:
|
|
|
147e83 |
+ vlbb %v16,0(%r5,%r2),6 /* Load s1 to block boundary. */
|
|
|
147e83 |
+ vlbb %v17,0(%r5,%r3),6 /* Load s2 to block boundary. */
|
|
|
147e83 |
+ lcbb %r1,0(%r5,%r2),6 /* Get loaded byte count of s1. */
|
|
|
147e83 |
+ jo .Llt16_1 /* Jump away if vr is not fully loaded. */
|
|
|
147e83 |
+ lcbb %r4,0(%r5,%r3),6
|
|
|
147e83 |
+ jo .Llt16_2 /* Jump away if vr is not fully loaded. */
|
|
|
147e83 |
+ /* Both vrs are fully loaded. */
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ vfenezbs %v18,%v16,%v17 /* Compare not equal with zero search. */
|
|
|
147e83 |
+ jno .Lfound
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vlbb %v16,0(%r5,%r2),6
|
|
|
147e83 |
+ vlbb %v17,0(%r5,%r3),6
|
|
|
147e83 |
+ lcbb %r1,0(%r5,%r2),6
|
|
|
147e83 |
+ jo .Llt16_1
|
|
|
147e83 |
+ lcbb %r4,0(%r5,%r3),6
|
|
|
147e83 |
+ jo .Llt16_2
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ vfenezbs %v18,%v16,%v17
|
|
|
147e83 |
+ jno .Lfound
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vlbb %v16,0(%r5,%r2),6
|
|
|
147e83 |
+ vlbb %v17,0(%r5,%r3),6
|
|
|
147e83 |
+ lcbb %r1,0(%r5,%r2),6
|
|
|
147e83 |
+ jo .Llt16_1
|
|
|
147e83 |
+ lcbb %r4,0(%r5,%r3),6
|
|
|
147e83 |
+ jo .Llt16_2
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ vfenezbs %v18,%v16,%v17
|
|
|
147e83 |
+ jno .Lfound
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vlbb %v16,0(%r5,%r2),6
|
|
|
147e83 |
+ vlbb %v17,0(%r5,%r3),6
|
|
|
147e83 |
+ lcbb %r1,0(%r5,%r2),6
|
|
|
147e83 |
+ jo .Llt16_1
|
|
|
147e83 |
+ lcbb %r4,0(%r5,%r3),6
|
|
|
147e83 |
+ jo .Llt16_2
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ vfenezbs %v18,%v16,%v17
|
|
|
147e83 |
+ jno .Lfound
|
|
|
147e83 |
+ j .Lloop
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Llt16_1:
|
|
|
147e83 |
+ lcbb %r4,0(%r5,%r3),6 /* Get loaded byte count of s2. */
|
|
|
147e83 |
+.Llt16_2:
|
|
|
147e83 |
+ clr %r1,%r4
|
|
|
147e83 |
+ locrh %r1,%r4 /* Get minimum of bytes loaded in s1/2. */
|
|
|
147e83 |
+ algfr %r5,%r1 /* Add smallest loaded bytes to current_len. */
|
|
|
147e83 |
+ vfenezbs %v18,%v16,%v17 /* Compare not equal with zero search. */
|
|
|
147e83 |
+ vlgvb %r4,%v18,7 /* Get not equal index or 16 if all equal. */
|
|
|
147e83 |
+ clrjl %r4,%r1,.Lfound /* Jump away if miscompare is within loaded
|
|
|
147e83 |
+ bytes. */
|
|
|
147e83 |
+ j .Lloop
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lfound:
|
|
|
147e83 |
+ je .Lend_equal
|
|
|
147e83 |
+ lghi %r2,1
|
|
|
147e83 |
+ lghi %r1,-1
|
|
|
147e83 |
+ locgrl %r2,%r1
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+.Lend_equal:
|
|
|
147e83 |
+ lghi %r2,0
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+END(__strcmp_vx)
|
|
|
147e83 |
+
|
|
|
147e83 |
+# define strcmp __strcmp_c
|
|
|
147e83 |
+# undef libc_hidden_builtin_def
|
|
|
147e83 |
+# define libc_hidden_builtin_def(name) strong_alias(__strcmp_c, __GI_strcmp)
|
|
|
147e83 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#include <strcmp.S>
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/strcmp.c b/sysdeps/s390/multiarch/strcmp.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..dd462a2
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/strcmp.c
|
|
|
147e83 |
@@ -0,0 +1,26 @@
|
|
|
147e83 |
+/* Multiple versions of strcmp.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
147e83 |
+# include <string.h>
|
|
|
147e83 |
+# include <ifunc-resolve.h>
|
|
|
147e83 |
+
|
|
|
147e83 |
+
|
|
|
147e83 |
+# undef strcmp
|
|
|
147e83 |
+s390_vx_libc_ifunc2 (__strcmp, strcmp)
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/wcscmp-c.c b/sysdeps/s390/multiarch/wcscmp-c.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..8358e1f
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/wcscmp-c.c
|
|
|
147e83 |
@@ -0,0 +1,30 @@
|
|
|
147e83 |
+/* Default wcscmp implementation for S/390.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
147e83 |
+# define WCSCMP __wcscmp_c
|
|
|
147e83 |
+
|
|
|
147e83 |
+# include <wchar.h>
|
|
|
147e83 |
+extern __typeof (wcscmp) __wcscmp_c;
|
|
|
147e83 |
+# ifdef SHARED
|
|
|
147e83 |
+# undef libc_hidden_def
|
|
|
147e83 |
+# define libc_hidden_def(name) \
|
|
|
147e83 |
+ __hidden_ver1 (__wcscmp_c, __GI_wcscmp, __wcscmp_c);
|
|
|
147e83 |
+# endif /* SHARED */
|
|
|
147e83 |
+# include <wcsmbs/wcscmp.c>
|
|
|
147e83 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/wcscmp-vx.S b/sysdeps/s390/multiarch/wcscmp-vx.S
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..2c9e610
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/wcscmp-vx.S
|
|
|
147e83 |
@@ -0,0 +1,131 @@
|
|
|
147e83 |
+/* Vector optimized 32/64 bit S/390 version of wcscmp.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
147e83 |
+
|
|
|
147e83 |
+# include "sysdep.h"
|
|
|
147e83 |
+# include "asm-syntax.h"
|
|
|
147e83 |
+
|
|
|
147e83 |
+ .text
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* int wcscmp (const wchar_t *s1, const wchar_t *s2)
|
|
|
147e83 |
+ Compare two strings
|
|
|
147e83 |
+
|
|
|
147e83 |
+ Register usage:
|
|
|
147e83 |
+ -r1=loaded byte count s1
|
|
|
147e83 |
+ -r2=s1
|
|
|
147e83 |
+ -r3=s2
|
|
|
147e83 |
+ -r4=loaded byte coutn s2, tmp
|
|
|
147e83 |
+ -r5=current_len
|
|
|
147e83 |
+ -v16=part of s1
|
|
|
147e83 |
+ -v17=part of s2
|
|
|
147e83 |
+ -v18=index of unequal
|
|
|
147e83 |
+*/
|
|
|
147e83 |
+ENTRY(__wcscmp_vx)
|
|
|
147e83 |
+ .machine "z13"
|
|
|
147e83 |
+ .machinemode "zarch_nohighgprs"
|
|
|
147e83 |
+
|
|
|
147e83 |
+ lghi %r5,0 /* current_len = 0. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lloop:
|
|
|
147e83 |
+ vlbb %v16,0(%r5,%r2),6 /* Load s1 to block boundary. */
|
|
|
147e83 |
+ vlbb %v17,0(%r5,%r3),6 /* Load s2 to block boundary. */
|
|
|
147e83 |
+ lcbb %r1,0(%r5,%r2),6 /* Get loaded byte count of s1. */
|
|
|
147e83 |
+ jo .Llt16_1 /* Jump away if vr is not fully loaded. */
|
|
|
147e83 |
+ lcbb %r4,0(%r5,%r3),6
|
|
|
147e83 |
+ jo .Llt16_2 /* Jump away if vr is not fully loaded. */
|
|
|
147e83 |
+ /* Both vrs are fully loaded. */
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ vfenezfs %v18,%v16,%v17 /* Compare not equal with zero search. */
|
|
|
147e83 |
+ jno .Lfound
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vlbb %v16,0(%r5,%r2),6
|
|
|
147e83 |
+ vlbb %v17,0(%r5,%r3),6
|
|
|
147e83 |
+ lcbb %r1,0(%r5,%r2),6
|
|
|
147e83 |
+ jo .Llt16_1
|
|
|
147e83 |
+ lcbb %r4,0(%r5,%r3),6
|
|
|
147e83 |
+ jo .Llt16_2
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ vfenezfs %v18,%v16,%v17
|
|
|
147e83 |
+ jno .Lfound
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vlbb %v16,0(%r5,%r2),6
|
|
|
147e83 |
+ vlbb %v17,0(%r5,%r3),6
|
|
|
147e83 |
+ lcbb %r1,0(%r5,%r2),6
|
|
|
147e83 |
+ jo .Llt16_1
|
|
|
147e83 |
+ lcbb %r4,0(%r5,%r3),6
|
|
|
147e83 |
+ jo .Llt16_2
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ vfenezfs %v18,%v16,%v17
|
|
|
147e83 |
+ jno .Lfound
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vlbb %v16,0(%r5,%r2),6
|
|
|
147e83 |
+ vlbb %v17,0(%r5,%r3),6
|
|
|
147e83 |
+ lcbb %r1,0(%r5,%r2),6
|
|
|
147e83 |
+ jo .Llt16_1
|
|
|
147e83 |
+ lcbb %r4,0(%r5,%r3),6
|
|
|
147e83 |
+ jo .Llt16_2
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ vfenezfs %v18,%v16,%v17
|
|
|
147e83 |
+ jno .Lfound
|
|
|
147e83 |
+ j .Lloop
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lcmp_one_char:
|
|
|
147e83 |
+ /* At least one of both strings is not 4-byte aligned
|
|
|
147e83 |
+ and there is no full character before next block-boundary.
|
|
|
147e83 |
+ Compare one character to get over the boundary and
|
|
|
147e83 |
+ proceed with normal loop! */
|
|
|
147e83 |
+ vlef %v16,0(%r5,%r2),0 /* Load one character. */
|
|
|
147e83 |
+ vlef %v17,0(%r5,%r3),0
|
|
|
147e83 |
+ lghi %r1,4 /* Loaded byte count is 4. */
|
|
|
147e83 |
+ j .Llt_cmp /* Proceed with comparision. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Llt16_1:
|
|
|
147e83 |
+ lcbb %r4,0(%r5,%r3),6 /* Get loaded byte count of s2. */
|
|
|
147e83 |
+.Llt16_2:
|
|
|
147e83 |
+ clr %r1,%r4
|
|
|
147e83 |
+ locrh %r1,%r4 /* Get minimum of bytes loaded in s1/2. */
|
|
|
147e83 |
+ nill %r1,65532 /* Align bytes loaded to full characters. */
|
|
|
147e83 |
+ jz .Lcmp_one_char /* Jump away if no full char is available. */
|
|
|
147e83 |
+.Llt_cmp:
|
|
|
147e83 |
+ algfr %r5,%r1 /* Add smallest loaded bytes to current_len. */
|
|
|
147e83 |
+ vfenezfs %v18,%v16,%v17 /* Compare not equal with zero search. */
|
|
|
147e83 |
+ vlgvb %r4,%v18,7 /* Get not equal index or 16 if all equal. */
|
|
|
147e83 |
+ clrjl %r4,%r1,.Lfound /* Jump away if miscompare is within loaded
|
|
|
147e83 |
+ bytes. */
|
|
|
147e83 |
+ j .Lloop
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lfound:
|
|
|
147e83 |
+ /* vfenezf found an unequal element or zero.
|
|
|
147e83 |
+ This instruction compares unsigned words, but wchar_t is signed.
|
|
|
147e83 |
+ Thus we have to compare the found element again. */
|
|
|
147e83 |
+ vlgvb %r4,%v18,7 /* Extract not equal byte-index, */
|
|
|
147e83 |
+ srl %r4,2 /* Convert it to character-index. */
|
|
|
147e83 |
+ vlgvf %r3,%v16,0(%r4) /* Load character-values. */
|
|
|
147e83 |
+ vlgvf %r4,%v17,0(%r4)
|
|
|
147e83 |
+ cr %r3,%r4
|
|
|
147e83 |
+ je .Lend_equal
|
|
|
147e83 |
+ lghi %r2,1
|
|
|
147e83 |
+ lghi %r1,-1
|
|
|
147e83 |
+ locgrl %r2,%r1
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+.Lend_equal:
|
|
|
147e83 |
+ lghi %r2,0
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+END(__wcscmp_vx)
|
|
|
147e83 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/wcscmp.c b/sysdeps/s390/multiarch/wcscmp.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..99bae4f
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/wcscmp.c
|
|
|
147e83 |
@@ -0,0 +1,27 @@
|
|
|
147e83 |
+/* Multiple versions of wcscmp.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
147e83 |
+# include <wchar.h>
|
|
|
147e83 |
+# include <ifunc-resolve.h>
|
|
|
147e83 |
+
|
|
|
147e83 |
+s390_vx_libc_ifunc2 (__wcscmp, wcscmp)
|
|
|
147e83 |
+
|
|
|
147e83 |
+#else
|
|
|
147e83 |
+# include <wcsmbs/wcscmp.c>
|
|
|
147e83 |
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
|
|
|
147e83 |
diff --git a/sysdeps/s390/s390-32/multiarch/strcmp.c b/sysdeps/s390/s390-32/multiarch/strcmp.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..1598bbc
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/s390-32/multiarch/strcmp.c
|
|
|
147e83 |
@@ -0,0 +1,21 @@
|
|
|
147e83 |
+/* Multiple versions of strcmp.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* This wrapper-file is needed, because otherwise file
|
|
|
147e83 |
+ sysdeps/s390/s390-[32|64]/strcmp.S will be used. */
|
|
|
147e83 |
+#include <sysdeps/s390/multiarch/strcmp.c>
|
|
|
147e83 |
diff --git a/sysdeps/s390/s390-64/multiarch/strcmp.c b/sysdeps/s390/s390-64/multiarch/strcmp.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..1598bbc
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/s390-64/multiarch/strcmp.c
|
|
|
147e83 |
@@ -0,0 +1,21 @@
|
|
|
147e83 |
+/* Multiple versions of strcmp.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* This wrapper-file is needed, because otherwise file
|
|
|
147e83 |
+ sysdeps/s390/s390-[32|64]/strcmp.S will be used. */
|
|
|
147e83 |
+#include <sysdeps/s390/multiarch/strcmp.c>
|
|
|
147e83 |
--
|
|
|
147e83 |
2.3.0
|
|
|
147e83 |
|