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