|
|
bca718 |
From cca51a74315c37614042113b004505b150d305d7 Mon Sep 17 00:00:00 2001
|
|
|
bca718 |
From: Stefan Liebler <stli@linux.vnet.ibm.com>
|
|
|
bca718 |
Date: Thu, 8 Oct 2015 10:54:21 +0200
|
|
|
bca718 |
Subject: [PATCH 10/30] S390: Optimize strlen and wcslen.
|
|
|
bca718 |
|
|
|
bca718 |
upstream-commit-id: 9472f35a0a6dbbda82ce103aaf0f5013f5d46e34
|
|
|
bca718 |
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00089.html
|
|
|
bca718 |
|
|
|
bca718 |
This patch provides optimized versions of strlen and wcslen with the z13 vector
|
|
|
bca718 |
instructions.
|
|
|
bca718 |
The helper macro IFUNC_VX_IMPL is introduced and is used to register all
|
|
|
bca718 |
__<func>_c() and __<func>_vx() functions within __libc_ifunc_impl_list()
|
|
|
bca718 |
to the ifunc test framework.
|
|
|
bca718 |
|
|
|
bca718 |
ChangeLog:
|
|
|
bca718 |
|
|
|
bca718 |
* sysdeps/s390/multiarch/Makefile: New File.
|
|
|
bca718 |
* sysdeps/s390/multiarch/strlen-c.c: Likewise.
|
|
|
bca718 |
* sysdeps/s390/multiarch/strlen-vx.S: Likewise.
|
|
|
bca718 |
* sysdeps/s390/multiarch/strlen.c: Likewise.
|
|
|
bca718 |
* sysdeps/s390/multiarch/wcslen-c.c: Likewise.
|
|
|
bca718 |
* sysdeps/s390/multiarch/wcslen-vx.S: Likewise.
|
|
|
bca718 |
* sysdeps/s390/multiarch/wcslen.c: Likewise.
|
|
|
bca718 |
* string/strlen.c (STRLEN): Define and use macro.
|
|
|
bca718 |
* sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bca718 |
(IFUNC_VX_IMPL): New macro function.
|
|
|
bca718 |
(__libc_ifunc_impl_list): Add ifunc test for strlen, wcslen.
|
|
|
bca718 |
* benchtests/Makefile (wcsmbs-bench): New variable.
|
|
|
bca718 |
(string-bench-all): Added wcsmbs-bench.
|
|
|
bca718 |
* benchtests/bench-wcslen.c: New File.
|
|
|
bca718 |
---
|
|
|
bca718 |
benchtests/Makefile | 3 +-
|
|
|
bca718 |
benchtests/bench-wcslen.c | 20 +++++++
|
|
|
bca718 |
string/strlen.c | 7 ++-
|
|
|
bca718 |
sysdeps/s390/multiarch/Makefile | 7 +++
|
|
|
bca718 |
sysdeps/s390/multiarch/ifunc-impl-list.c | 14 +++++
|
|
|
bca718 |
sysdeps/s390/multiarch/strlen-c.c | 28 ++++++++++
|
|
|
bca718 |
sysdeps/s390/multiarch/strlen-vx.S | 84 +++++++++++++++++++++++++++++
|
|
|
bca718 |
sysdeps/s390/multiarch/strlen.c | 27 ++++++++++
|
|
|
bca718 |
sysdeps/s390/multiarch/wcslen-c.c | 25 +++++++++
|
|
|
bca718 |
sysdeps/s390/multiarch/wcslen-vx.S | 91 ++++++++++++++++++++++++++++++++
|
|
|
bca718 |
sysdeps/s390/multiarch/wcslen.c | 28 ++++++++++
|
|
|
bca718 |
11 files changed, 331 insertions(+), 3 deletions(-)
|
|
|
bca718 |
create mode 100644 benchtests/bench-wcslen.c
|
|
|
bca718 |
create mode 100644 sysdeps/s390/multiarch/Makefile
|
|
|
bca718 |
create mode 100644 sysdeps/s390/multiarch/strlen-c.c
|
|
|
bca718 |
create mode 100644 sysdeps/s390/multiarch/strlen-vx.S
|
|
|
bca718 |
create mode 100644 sysdeps/s390/multiarch/strlen.c
|
|
|
bca718 |
create mode 100644 sysdeps/s390/multiarch/wcslen-c.c
|
|
|
bca718 |
create mode 100644 sysdeps/s390/multiarch/wcslen-vx.S
|
|
|
bca718 |
create mode 100644 sysdeps/s390/multiarch/wcslen.c
|
|
|
bca718 |
|
|
|
bca718 |
diff --git a/benchtests/Makefile b/benchtests/Makefile
|
|
|
bca718 |
index 9b02bc7..09ab87f 100644
|
|
|
bca718 |
--- a/benchtests/Makefile
|
|
|
bca718 |
+++ b/benchtests/Makefile
|
|
|
bca718 |
@@ -38,7 +38,8 @@ string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
|
|
|
bca718 |
strcat strchr strchrnul strcmp strcpy strcspn strlen \
|
|
|
bca718 |
strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
|
|
|
bca718 |
strspn strstr strcpy_chk stpcpy_chk memrchr strsep strtok
|
|
|
bca718 |
-string-bench-all := $(string-bench)
|
|
|
bca718 |
+wcsmbs-bench := wcslen
|
|
|
bca718 |
+string-bench-all := $(string-bench) ${wcsmbs-bench}
|
|
|
bca718 |
|
|
|
bca718 |
stdlib-bench := strtod
|
|
|
bca718 |
|
|
|
bca718 |
diff --git a/benchtests/bench-wcslen.c b/benchtests/bench-wcslen.c
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..4e9d085
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/benchtests/bench-wcslen.c
|
|
|
bca718 |
@@ -0,0 +1,20 @@
|
|
|
bca718 |
+/* Measure wcslen functions.
|
|
|
bca718 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
bca718 |
+ This file is part of the GNU C Library.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
bca718 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
bca718 |
+ License as published by the Free Software Foundation; either
|
|
|
bca718 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
bca718 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
bca718 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
bca718 |
+ Lesser General Public License for more details.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
bca718 |
+ License along with the GNU C Library; if not, see
|
|
|
bca718 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+#define WIDE 1
|
|
|
bca718 |
+#include "bench-strlen.c"
|
|
|
bca718 |
diff --git a/string/strlen.c b/string/strlen.c
|
|
|
bca718 |
index 5c1efda..d682693 100644
|
|
|
bca718 |
--- a/string/strlen.c
|
|
|
bca718 |
+++ b/string/strlen.c
|
|
|
bca718 |
@@ -23,11 +23,14 @@
|
|
|
bca718 |
|
|
|
bca718 |
#undef strlen
|
|
|
bca718 |
|
|
|
bca718 |
+#ifndef STRLEN
|
|
|
bca718 |
+# define STRLEN strlen
|
|
|
bca718 |
+#endif
|
|
|
bca718 |
+
|
|
|
bca718 |
/* Return the length of the null-terminated string STR. Scan for
|
|
|
bca718 |
the null terminator quickly by testing four bytes at a time. */
|
|
|
bca718 |
size_t
|
|
|
bca718 |
-strlen (str)
|
|
|
bca718 |
- const char *str;
|
|
|
bca718 |
+STRLEN (const char *str)
|
|
|
bca718 |
{
|
|
|
bca718 |
const char *char_ptr;
|
|
|
bca718 |
const unsigned long int *longword_ptr;
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..3a98098
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/Makefile
|
|
|
bca718 |
@@ -0,0 +1,7 @@
|
|
|
bca718 |
+ifeq ($(subdir),string)
|
|
|
bca718 |
+sysdep_routines += strlen strlen-vx strlen-c
|
|
|
bca718 |
+endif
|
|
|
bca718 |
+
|
|
|
bca718 |
+ifeq ($(subdir),wcsmbs)
|
|
|
bca718 |
+sysdep_routines += wcslen wcslen-vx wcslen-c
|
|
|
bca718 |
+endif
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bca718 |
index c330904..e9639ef 100644
|
|
|
bca718 |
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bca718 |
@@ -18,6 +18,7 @@
|
|
|
bca718 |
|
|
|
bca718 |
#include <assert.h>
|
|
|
bca718 |
#include <string.h>
|
|
|
bca718 |
+#include <wchar.h>
|
|
|
bca718 |
#include <ifunc-impl-list.h>
|
|
|
bca718 |
#include <ifunc-resolve.h>
|
|
|
bca718 |
|
|
|
bca718 |
@@ -70,5 +71,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
bca718 |
|
|
|
bca718 |
#endif /* SHARED */
|
|
|
bca718 |
|
|
|
bca718 |
+#ifdef HAVE_S390_VX_ASM_SUPPORT
|
|
|
bca718 |
+
|
|
|
bca718 |
+# define IFUNC_VX_IMPL(FUNC) \
|
|
|
bca718 |
+ IFUNC_IMPL (i, name, FUNC, \
|
|
|
bca718 |
+ IFUNC_IMPL_ADD (array, i, FUNC, dl_hwcap & HWCAP_S390_VX, \
|
|
|
bca718 |
+ __##FUNC##_vx) \
|
|
|
bca718 |
+ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c))
|
|
|
bca718 |
+
|
|
|
bca718 |
+ IFUNC_VX_IMPL (strlen);
|
|
|
bca718 |
+ IFUNC_VX_IMPL (wcslen);
|
|
|
bca718 |
+
|
|
|
bca718 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT */
|
|
|
bca718 |
+
|
|
|
bca718 |
return i;
|
|
|
bca718 |
}
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/strlen-c.c b/sysdeps/s390/multiarch/strlen-c.c
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..1cbe959
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/strlen-c.c
|
|
|
bca718 |
@@ -0,0 +1,28 @@
|
|
|
bca718 |
+/* Default strlen implementation for S/390.
|
|
|
bca718 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
bca718 |
+ This file is part of the GNU C Library.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
bca718 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
bca718 |
+ License as published by the Free Software Foundation; either
|
|
|
bca718 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
bca718 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
bca718 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
bca718 |
+ Lesser General Public License for more details.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
bca718 |
+ License along with the GNU C Library; if not, see
|
|
|
bca718 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
bca718 |
+# define STRLEN __strlen_c
|
|
|
bca718 |
+# ifdef SHARED
|
|
|
bca718 |
+# undef libc_hidden_builtin_def
|
|
|
bca718 |
+# define libc_hidden_builtin_def(name) \
|
|
|
bca718 |
+ __hidden_ver1 (__strlen_c, __GI_strlen, __strlen_c);
|
|
|
bca718 |
+# endif /* SHARED */
|
|
|
bca718 |
+
|
|
|
bca718 |
+# include <string/strlen.c>
|
|
|
bca718 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/strlen-vx.S b/sysdeps/s390/multiarch/strlen-vx.S
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..1a5cb23
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/strlen-vx.S
|
|
|
bca718 |
@@ -0,0 +1,84 @@
|
|
|
bca718 |
+/* Vector optimized 32/64 bit S/390 version of strlen.
|
|
|
bca718 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
bca718 |
+ This file is part of the GNU C Library.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
bca718 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
bca718 |
+ License as published by the Free Software Foundation; either
|
|
|
bca718 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
bca718 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
bca718 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
bca718 |
+ Lesser General Public License for more details.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
bca718 |
+ License along with the GNU C Library; if not, see
|
|
|
bca718 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
bca718 |
+
|
|
|
bca718 |
+# include "sysdep.h"
|
|
|
bca718 |
+# include "asm-syntax.h"
|
|
|
bca718 |
+
|
|
|
bca718 |
+ .text
|
|
|
bca718 |
+
|
|
|
bca718 |
+/* size_t strlen (const char *s)
|
|
|
bca718 |
+ Returns length of string s.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ Register usage:
|
|
|
bca718 |
+ -r1=bytes to 4k-byte boundary
|
|
|
bca718 |
+ -r2=s
|
|
|
bca718 |
+ -r3=tmp
|
|
|
bca718 |
+ -r4=tmp
|
|
|
bca718 |
+ -r5=current_len and return_value
|
|
|
bca718 |
+ -v16=part of s
|
|
|
bca718 |
+*/
|
|
|
bca718 |
+ENTRY(__strlen_vx)
|
|
|
bca718 |
+ .machine "z13"
|
|
|
bca718 |
+ .machinemode "zarch_nohighgprs"
|
|
|
bca718 |
+
|
|
|
bca718 |
+ vlbb %v16,0(%r2),6 /* Load s until next 4k-byte boundary. */
|
|
|
bca718 |
+ lcbb %r1,0(%r2),6 /* Get bytes to 4k-byte boundary or 16. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ vfenezb %v16,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ vlgvb %r4,%v16,7 /* Load zero index or 16 if not found. */
|
|
|
bca718 |
+ clr %r4,%r1 /* If found zero within loaded bytes? */
|
|
|
bca718 |
+ locgrl %r2,%r4 /* Then copy return value. */
|
|
|
bca718 |
+ blr %r14 /* And return. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* Align s to 16 byte. */
|
|
|
bca718 |
+ risbgn %r3,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
|
|
|
bca718 |
+ lghi %r5,16 /* current_len = 16. */
|
|
|
bca718 |
+ slr %r5,%r3 /* Compute bytes to 16bytes boundary. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* Find zero in 16 byte aligned loop. */
|
|
|
bca718 |
+.Lloop:
|
|
|
bca718 |
+ vl %v16,0(%r5,%r2) /* Load s. */
|
|
|
bca718 |
+ vfenezbs %v16,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ je .Lfound /* Jump away if zero was found. */
|
|
|
bca718 |
+ vl %v16,16(%r5,%r2)
|
|
|
bca718 |
+ vfenezbs %v16,%v16,%v16
|
|
|
bca718 |
+ je .Lfound16
|
|
|
bca718 |
+ vl %v16,32(%r5,%r2)
|
|
|
bca718 |
+ vfenezbs %v16,%v16,%v16
|
|
|
bca718 |
+ je .Lfound32
|
|
|
bca718 |
+ vl %v16,48(%r5,%r2)
|
|
|
bca718 |
+ vfenezbs %v16,%v16,%v16
|
|
|
bca718 |
+ je .Lfound48
|
|
|
bca718 |
+
|
|
|
bca718 |
+ aghi %r5,64
|
|
|
bca718 |
+ j .Lloop /* No zero found -> loop. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+.Lfound48:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Lfound32:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Lfound16:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Lfound:
|
|
|
bca718 |
+ vlgvb %r2,%v16,7 /* Load byte index of zero. */
|
|
|
bca718 |
+ algr %r2,%r5
|
|
|
bca718 |
+ br %r14
|
|
|
bca718 |
+END(__strlen_vx)
|
|
|
bca718 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/strlen.c b/sysdeps/s390/multiarch/strlen.c
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..ba5863f
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/strlen.c
|
|
|
bca718 |
@@ -0,0 +1,27 @@
|
|
|
bca718 |
+/* Multiple versions of strlen.
|
|
|
bca718 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
bca718 |
+ This file is part of the GNU C Library.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
bca718 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
bca718 |
+ License as published by the Free Software Foundation; either
|
|
|
bca718 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
bca718 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
bca718 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
bca718 |
+ Lesser General Public License for more details.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
bca718 |
+ License along with the GNU C Library; if not, see
|
|
|
bca718 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
bca718 |
+# include <string.h>
|
|
|
bca718 |
+# include <ifunc-resolve.h>
|
|
|
bca718 |
+
|
|
|
bca718 |
+s390_vx_libc_ifunc2 (__strlen, strlen)
|
|
|
bca718 |
+
|
|
|
bca718 |
+#else
|
|
|
bca718 |
+# include <string/strlen.c>
|
|
|
bca718 |
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/wcslen-c.c b/sysdeps/s390/multiarch/wcslen-c.c
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..6dd011e
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/wcslen-c.c
|
|
|
bca718 |
@@ -0,0 +1,25 @@
|
|
|
bca718 |
+/* Default wcslen implementation for S/390.
|
|
|
bca718 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
bca718 |
+ This file is part of the GNU C Library.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
bca718 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
bca718 |
+ License as published by the Free Software Foundation; either
|
|
|
bca718 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
bca718 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
bca718 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
bca718 |
+ Lesser General Public License for more details.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
bca718 |
+ License along with the GNU C Library; if not, see
|
|
|
bca718 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
bca718 |
+# define WCSLEN __wcslen_c
|
|
|
bca718 |
+
|
|
|
bca718 |
+# include <wchar.h>
|
|
|
bca718 |
+extern __typeof (__wcslen) __wcslen_c;
|
|
|
bca718 |
+# include <wcsmbs/wcslen.c>
|
|
|
bca718 |
+#endif
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/wcslen-vx.S b/sysdeps/s390/multiarch/wcslen-vx.S
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..579e66b
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/wcslen-vx.S
|
|
|
bca718 |
@@ -0,0 +1,91 @@
|
|
|
bca718 |
+/* Vector optimized 32/64 bit S/390 version of wcslen.
|
|
|
bca718 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
bca718 |
+ This file is part of the GNU C Library.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
bca718 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
bca718 |
+ License as published by the Free Software Foundation; either
|
|
|
bca718 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
bca718 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
bca718 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
bca718 |
+ Lesser General Public License for more details.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
bca718 |
+ License along with the GNU C Library; if not, see
|
|
|
bca718 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
bca718 |
+
|
|
|
bca718 |
+# include "sysdep.h"
|
|
|
bca718 |
+# include "asm-syntax.h"
|
|
|
bca718 |
+
|
|
|
bca718 |
+ .text
|
|
|
bca718 |
+
|
|
|
bca718 |
+/* size_t wcslen (const wchar_t *s)
|
|
|
bca718 |
+ Returns length of string s.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ Register usage:
|
|
|
bca718 |
+ -r1=bytes to 4k-byte boundary
|
|
|
bca718 |
+ -r2=s
|
|
|
bca718 |
+ -r3=tmp
|
|
|
bca718 |
+ -r4=tmp
|
|
|
bca718 |
+ -r5=current_len and return_value
|
|
|
bca718 |
+ -v16=part of s
|
|
|
bca718 |
+*/
|
|
|
bca718 |
+ENTRY(__wcslen_vx)
|
|
|
bca718 |
+ .machine "z13"
|
|
|
bca718 |
+ .machinemode "zarch_nohighgprs"
|
|
|
bca718 |
+
|
|
|
bca718 |
+ vlbb %v16,0(%r2),6 /* Load s until next 4k-byte boundary. */
|
|
|
bca718 |
+ lcbb %r1,0(%r2),6 /* Get bytes to 4k-byte boundary or 16. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ tmll %r2,3 /* Test if s is 4-byte aligned? */
|
|
|
bca718 |
+ jne .Lfallback /* And use common-code variant if not. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ vfenezf %v16,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ vlgvb %r4,%v16,7 /* Load zero index or 16 if not found. */
|
|
|
bca718 |
+ clr %r4,%r1 /* If found zero within loaded bytes? */
|
|
|
bca718 |
+ locgrl %r2,%r4 /* Then copy return value. */
|
|
|
bca718 |
+ jl .Lend /* And return. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* Align s to 16 byte. */
|
|
|
bca718 |
+ risbgn %r3,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
|
|
|
bca718 |
+ lghi %r5,16 /* current_len = 16. */
|
|
|
bca718 |
+ slr %r5,%r3 /* Compute bytes to 16bytes boundary. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* Find zero in 16byte aligned loop. */
|
|
|
bca718 |
+.Lloop:
|
|
|
bca718 |
+ vl %v16,0(%r5,%r2) /* Load s. */
|
|
|
bca718 |
+ vfenezfs %v16,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ je .Lfound /* Jump away if zero was found. */
|
|
|
bca718 |
+ vl %v16,16(%r5,%r2)
|
|
|
bca718 |
+ vfenezfs %v16,%v16,%v16
|
|
|
bca718 |
+ je .Lfound16
|
|
|
bca718 |
+ vl %v16,32(%r5,%r2)
|
|
|
bca718 |
+ vfenezfs %v16,%v16,%v16
|
|
|
bca718 |
+ je .Lfound32
|
|
|
bca718 |
+ vl %v16,48(%r5,%r2)
|
|
|
bca718 |
+ vfenezfs %v16,%v16,%v16
|
|
|
bca718 |
+ je .Lfound48
|
|
|
bca718 |
+
|
|
|
bca718 |
+ aghi %r5,64
|
|
|
bca718 |
+ j .Lloop /* No zero found -> loop. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+.Lfound48:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Lfound32:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Lfound16:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Lfound:
|
|
|
bca718 |
+ vlgvb %r2,%v16,7 /* Load byte index of zero. */
|
|
|
bca718 |
+ algr %r2,%r5
|
|
|
bca718 |
+.Lend:
|
|
|
bca718 |
+ srlg %r2,%r2,2 /* Convert byte-count to character-count. */
|
|
|
bca718 |
+ br %r14
|
|
|
bca718 |
+.Lfallback:
|
|
|
bca718 |
+ jg __wcslen_c
|
|
|
bca718 |
+END(__wcslen_vx)
|
|
|
bca718 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/wcslen.c b/sysdeps/s390/multiarch/wcslen.c
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..a7be73e
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/wcslen.c
|
|
|
bca718 |
@@ -0,0 +1,28 @@
|
|
|
bca718 |
+/* Multiple versions of wcslen.
|
|
|
bca718 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
bca718 |
+ This file is part of the GNU C Library.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
bca718 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
bca718 |
+ License as published by the Free Software Foundation; either
|
|
|
bca718 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
bca718 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
bca718 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
bca718 |
+ Lesser General Public License for more details.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
bca718 |
+ License along with the GNU C Library; if not, see
|
|
|
bca718 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
bca718 |
+# include <wchar.h>
|
|
|
bca718 |
+# include <ifunc-resolve.h>
|
|
|
bca718 |
+
|
|
|
bca718 |
+s390_vx_libc_ifunc (__wcslen)
|
|
|
bca718 |
+weak_alias (__wcslen, wcslen)
|
|
|
bca718 |
+
|
|
|
bca718 |
+#else
|
|
|
bca718 |
+# include <wcsmbs/wcslen.c>
|
|
|
bca718 |
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
|
|
|
bca718 |
--
|
|
|
bca718 |
2.3.0
|
|
|
bca718 |
|