|
|
ce426f |
From 67611d45bb5e464f2e80782ec37ce3548459cf57 Mon Sep 17 00:00:00 2001
|
|
|
ce426f |
From: Stefan Liebler <stli@linux.vnet.ibm.com>
|
|
|
ce426f |
Date: Thu, 8 Oct 2015 12:56:03 +0200
|
|
|
ce426f |
Subject: [PATCH 23/30] S390: Optimize strspn and wcsspn.
|
|
|
ce426f |
|
|
|
ce426f |
upstream-commit-id: f1ffad98be7ec4111fbd1cd1f58f3e3343257519
|
|
|
ce426f |
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00095.html
|
|
|
ce426f |
|
|
|
ce426f |
This patch provides optimized versions of strspn and wcsspn with the z13
|
|
|
ce426f |
vector instructions.
|
|
|
ce426f |
|
|
|
ce426f |
ChangeLog:
|
|
|
ce426f |
|
|
|
ce426f |
* sysdeps/s390/multiarch/strspn-c.c: New File.
|
|
|
ce426f |
* sysdeps/s390/multiarch/strspn-vx.S: Likewise.
|
|
|
ce426f |
* sysdeps/s390/multiarch/strspn.c: Likewise.
|
|
|
ce426f |
* sysdeps/s390/multiarch/wcsspn-c.c: Likewise.
|
|
|
ce426f |
* sysdeps/s390/multiarch/wcsspn-vx.S: Likewise.
|
|
|
ce426f |
* sysdeps/s390/multiarch/wcsspn.c: Likewise.
|
|
|
ce426f |
* wcsmbs/wcsspn.c: Use WCSSPN if defined.
|
|
|
ce426f |
* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add strspn and
|
|
|
ce426f |
wcsspn functions.
|
|
|
ce426f |
* sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
ce426f |
(__libc_ifunc_impl_list): Add ifunc test for strspn, wcsspn.
|
|
|
ce426f |
* string/test-strspn.c: Add wcsspn support.
|
|
|
ce426f |
* wcsmbs/test-wcsspn.c: New File.
|
|
|
ce426f |
* wcsmbs/Makefile (strop-tests): Add wcsspn.
|
|
|
ce426f |
* benchtests/bench-strspn.c: Add wcsspn support.
|
|
|
ce426f |
* benchtests/bench-wcsspn.c: New File.
|
|
|
ce426f |
* benchtests/Makefile (wcsmbs-bench): Add wcsspn.
|
|
|
ce426f |
---
|
|
|
ce426f |
benchtests/Makefile | 2 +-
|
|
|
ce426f |
benchtests/bench-strspn.c | 71 +++++---
|
|
|
ce426f |
benchtests/bench-wcsspn.c | 20 +++
|
|
|
ce426f |
string/strspn.c | 7 +-
|
|
|
ce426f |
string/test-strspn.c | 100 +++++++-----
|
|
|
ce426f |
sysdeps/s390/multiarch/Makefile | 6 +-
|
|
|
ce426f |
sysdeps/s390/multiarch/ifunc-impl-list.c | 3 +
|
|
|
ce426f |
sysdeps/s390/multiarch/strspn-c.c | 28 ++++
|
|
|
ce426f |
sysdeps/s390/multiarch/strspn-vx.S | 256 +++++++++++++++++++++++++++++
|
|
|
ce426f |
sysdeps/s390/multiarch/strspn.c | 27 ++++
|
|
|
ce426f |
sysdeps/s390/multiarch/wcsspn-c.c | 31 ++++
|
|
|
ce426f |
sysdeps/s390/multiarch/wcsspn-vx.S | 270 +++++++++++++++++++++++++++++++
|
|
|
ce426f |
sysdeps/s390/multiarch/wcsspn.c | 27 ++++
|
|
|
ce426f |
wcsmbs/Makefile | 2 +-
|
|
|
ce426f |
wcsmbs/test-wcsspn-ifunc.c | 20 +++
|
|
|
ce426f |
wcsmbs/test-wcsspn.c | 20 +++
|
|
|
ce426f |
wcsmbs/wcsspn.c | 3 +
|
|
|
ce426f |
17 files changed, 827 insertions(+), 66 deletions(-)
|
|
|
ce426f |
create mode 100644 benchtests/bench-wcsspn.c
|
|
|
ce426f |
create mode 100644 sysdeps/s390/multiarch/strspn-c.c
|
|
|
ce426f |
create mode 100644 sysdeps/s390/multiarch/strspn-vx.S
|
|
|
ce426f |
create mode 100644 sysdeps/s390/multiarch/strspn.c
|
|
|
ce426f |
create mode 100644 sysdeps/s390/multiarch/wcsspn-c.c
|
|
|
ce426f |
create mode 100644 sysdeps/s390/multiarch/wcsspn-vx.S
|
|
|
ce426f |
create mode 100644 sysdeps/s390/multiarch/wcsspn.c
|
|
|
ce426f |
create mode 100644 wcsmbs/test-wcsspn-ifunc.c
|
|
|
ce426f |
create mode 100644 wcsmbs/test-wcsspn.c
|
|
|
ce426f |
|
|
|
ce426f |
diff --git a/benchtests/Makefile b/benchtests/Makefile
|
|
|
ce426f |
index 6444394..337b2a1 100644
|
|
|
ce426f |
--- a/benchtests/Makefile
|
|
|
ce426f |
+++ b/benchtests/Makefile
|
|
|
ce426f |
@@ -39,7 +39,7 @@ string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
|
|
|
ce426f |
strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
|
|
|
ce426f |
strspn strstr strcpy_chk stpcpy_chk memrchr strsep strtok
|
|
|
ce426f |
wcsmbs-bench := wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat \
|
|
|
ce426f |
- wcsncmp wcsncmp wcschr wcschrnul wcsrchr
|
|
|
ce426f |
+ wcsncmp wcsncmp wcschr wcschrnul wcsrchr wcsspn
|
|
|
ce426f |
string-bench-all := $(string-bench) ${wcsmbs-bench}
|
|
|
ce426f |
|
|
|
ce426f |
stdlib-bench := strtod
|
|
|
ce426f |
diff --git a/benchtests/bench-strspn.c b/benchtests/bench-strspn.c
|
|
|
ce426f |
index 634bca1..e1f2272 100644
|
|
|
ce426f |
--- a/benchtests/bench-strspn.c
|
|
|
ce426f |
+++ b/benchtests/bench-strspn.c
|
|
|
ce426f |
@@ -17,22 +17,47 @@
|
|
|
ce426f |
<http://www.gnu.org/licenses/>. */
|
|
|
ce426f |
|
|
|
ce426f |
#define TEST_MAIN
|
|
|
ce426f |
-#define TEST_NAME "strspn"
|
|
|
ce426f |
+#ifndef WIDE
|
|
|
ce426f |
+# define TEST_NAME "strspn"
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+# define TEST_NAME "wcsspn"
|
|
|
ce426f |
+#endif /* WIDE */
|
|
|
ce426f |
#include "bench-string.h"
|
|
|
ce426f |
|
|
|
ce426f |
-typedef size_t (*proto_t) (const char *, const char *);
|
|
|
ce426f |
-size_t simple_strspn (const char *, const char *);
|
|
|
ce426f |
-size_t stupid_strspn (const char *, const char *);
|
|
|
ce426f |
-
|
|
|
ce426f |
-IMPL (stupid_strspn, 0)
|
|
|
ce426f |
-IMPL (simple_strspn, 0)
|
|
|
ce426f |
-IMPL (strspn, 1)
|
|
|
ce426f |
+#ifndef WIDE
|
|
|
ce426f |
+# define STRSPN strspn
|
|
|
ce426f |
+# define CHAR char
|
|
|
ce426f |
+# define SIMPLE_STRSPN simple_strspn
|
|
|
ce426f |
+# define STUPID_STRSPN stupid_strspn
|
|
|
ce426f |
+# define STRLEN strlen
|
|
|
ce426f |
+# define STRCHR strchr
|
|
|
ce426f |
+# define BIG_CHAR CHAR_MAX
|
|
|
ce426f |
+# define SMALL_CHAR 127
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+# include <wchar.h>
|
|
|
ce426f |
+# define STRSPN wcsspn
|
|
|
ce426f |
+# define CHAR wchar_t
|
|
|
ce426f |
+# define SIMPLE_STRSPN simple_wcsspn
|
|
|
ce426f |
+# define STUPID_STRSPN stupid_wcsspn
|
|
|
ce426f |
+# define STRLEN wcslen
|
|
|
ce426f |
+# define STRCHR wcschr
|
|
|
ce426f |
+# define BIG_CHAR WCHAR_MAX
|
|
|
ce426f |
+# define SMALL_CHAR 1273
|
|
|
ce426f |
+#endif /* WIDE */
|
|
|
ce426f |
+
|
|
|
ce426f |
+typedef size_t (*proto_t) (const CHAR *, const CHAR *);
|
|
|
ce426f |
+size_t SIMPLE_STRSPN (const CHAR *, const CHAR *);
|
|
|
ce426f |
+size_t STUPID_STRSPN (const CHAR *, const CHAR *);
|
|
|
ce426f |
+
|
|
|
ce426f |
+IMPL (STUPID_STRSPN, 0)
|
|
|
ce426f |
+IMPL (SIMPLE_STRSPN, 0)
|
|
|
ce426f |
+IMPL (STRSPN, 1)
|
|
|
ce426f |
|
|
|
ce426f |
size_t
|
|
|
ce426f |
-simple_strspn (const char *s, const char *acc)
|
|
|
ce426f |
+SIMPLE_STRSPN (const CHAR *s, const CHAR *acc)
|
|
|
ce426f |
{
|
|
|
ce426f |
- const char *r, *str = s;
|
|
|
ce426f |
- char c;
|
|
|
ce426f |
+ const CHAR *r, *str = s;
|
|
|
ce426f |
+ CHAR c;
|
|
|
ce426f |
|
|
|
ce426f |
while ((c = *s++) != '\0')
|
|
|
ce426f |
{
|
|
|
ce426f |
@@ -46,9 +71,9 @@ simple_strspn (const char *s, const char *acc)
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
size_t
|
|
|
ce426f |
-stupid_strspn (const char *s, const char *acc)
|
|
|
ce426f |
+STUPID_STRSPN (const CHAR *s, const CHAR *acc)
|
|
|
ce426f |
{
|
|
|
ce426f |
- size_t ns = strlen (s), nacc = strlen (acc);
|
|
|
ce426f |
+ size_t ns = STRLEN (s), nacc = STRLEN (acc);
|
|
|
ce426f |
size_t i, j;
|
|
|
ce426f |
|
|
|
ce426f |
for (i = 0; i < ns; ++i)
|
|
|
ce426f |
@@ -63,7 +88,7 @@ stupid_strspn (const char *s, const char *acc)
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
static void
|
|
|
ce426f |
-do_one_test (impl_t *impl, const char *s, const char *acc, size_t exp_res)
|
|
|
ce426f |
+do_one_test (impl_t *impl, const CHAR *s, const CHAR *acc, size_t exp_res)
|
|
|
ce426f |
{
|
|
|
ce426f |
size_t res = CALL (impl, s, acc), i, iters = INNER_LOOP_ITERS;
|
|
|
ce426f |
timing_t start, stop, cur;
|
|
|
ce426f |
@@ -92,34 +117,34 @@ static void
|
|
|
ce426f |
do_test (size_t align, size_t pos, size_t len)
|
|
|
ce426f |
{
|
|
|
ce426f |
size_t i;
|
|
|
ce426f |
- char *acc, *s;
|
|
|
ce426f |
+ CHAR *acc, *s;
|
|
|
ce426f |
|
|
|
ce426f |
align &= 7;
|
|
|
ce426f |
- if (align + pos + 10 >= page_size || len > 240 || ! len)
|
|
|
ce426f |
+ if ((align + pos + 10) * sizeof (CHAR) >= page_size || len > 240 || ! len)
|
|
|
ce426f |
return;
|
|
|
ce426f |
|
|
|
ce426f |
- acc = (char *) (buf2 + (random () & 255));
|
|
|
ce426f |
- s = (char *) (buf1 + align);
|
|
|
ce426f |
+ acc = (CHAR *) (buf2) + (random () & BIG_CHAR);
|
|
|
ce426f |
+ s = (CHAR *) (buf1) + align;
|
|
|
ce426f |
|
|
|
ce426f |
for (i = 0; i < len; ++i)
|
|
|
ce426f |
{
|
|
|
ce426f |
- acc[i] = random () & 255;
|
|
|
ce426f |
+ acc[i] = random () & BIG_CHAR;
|
|
|
ce426f |
if (!acc[i])
|
|
|
ce426f |
- acc[i] = random () & 255;
|
|
|
ce426f |
+ acc[i] = random () & BIG_CHAR;
|
|
|
ce426f |
if (!acc[i])
|
|
|
ce426f |
- acc[i] = 1 + (random () & 127);
|
|
|
ce426f |
+ acc[i] = 1 + (random () & SMALL_CHAR);
|
|
|
ce426f |
}
|
|
|
ce426f |
acc[len] = '\0';
|
|
|
ce426f |
|
|
|
ce426f |
for (i = 0; i < pos; ++i)
|
|
|
ce426f |
s[i] = acc[random () % len];
|
|
|
ce426f |
- s[pos] = random () & 255;
|
|
|
ce426f |
+ s[pos] = random () & BIG_CHAR;
|
|
|
ce426f |
if (strchr (acc, s[pos]))
|
|
|
ce426f |
s[pos] = '\0';
|
|
|
ce426f |
else
|
|
|
ce426f |
{
|
|
|
ce426f |
for (i = pos + 1; i < pos + 10; ++i)
|
|
|
ce426f |
- s[i] = random () & 255;
|
|
|
ce426f |
+ s[i] = random () & BIG_CHAR;
|
|
|
ce426f |
s[i] = '\0';
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
diff --git a/benchtests/bench-wcsspn.c b/benchtests/bench-wcsspn.c
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..7bdef50
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/benchtests/bench-wcsspn.c
|
|
|
ce426f |
@@ -0,0 +1,20 @@
|
|
|
ce426f |
+/* Measure wcsspn 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-strspn.c"
|
|
|
ce426f |
diff --git a/string/strspn.c b/string/strspn.c
|
|
|
ce426f |
index 48624aa..f0ac9db 100644
|
|
|
ce426f |
--- a/string/strspn.c
|
|
|
ce426f |
+++ b/string/strspn.c
|
|
|
ce426f |
@@ -18,13 +18,14 @@
|
|
|
ce426f |
#include <string.h>
|
|
|
ce426f |
|
|
|
ce426f |
#undef strspn
|
|
|
ce426f |
+#ifndef STRSPN
|
|
|
ce426f |
+#define STRSPN strspn
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
|
|
|
ce426f |
/* Return the length of the maximum initial segment
|
|
|
ce426f |
of S which contains only characters in ACCEPT. */
|
|
|
ce426f |
size_t
|
|
|
ce426f |
-strspn (s, accept)
|
|
|
ce426f |
- const char *s;
|
|
|
ce426f |
- const char *accept;
|
|
|
ce426f |
+STRSPN (const char *s, const char *accept)
|
|
|
ce426f |
{
|
|
|
ce426f |
const char *p;
|
|
|
ce426f |
const char *a;
|
|
|
ce426f |
diff --git a/string/test-strspn.c b/string/test-strspn.c
|
|
|
ce426f |
index 0d6cd19..306958e 100644
|
|
|
ce426f |
--- a/string/test-strspn.c
|
|
|
ce426f |
+++ b/string/test-strspn.c
|
|
|
ce426f |
@@ -18,22 +18,49 @@
|
|
|
ce426f |
<http://www.gnu.org/licenses/>. */
|
|
|
ce426f |
|
|
|
ce426f |
#define TEST_MAIN
|
|
|
ce426f |
-#define TEST_NAME "strspn"
|
|
|
ce426f |
+#ifndef WIDE
|
|
|
ce426f |
+# define TEST_NAME "strspn"
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+# define TEST_NAME "wcsspn"
|
|
|
ce426f |
+#endif /* WIDE */
|
|
|
ce426f |
#include "test-string.h"
|
|
|
ce426f |
|
|
|
ce426f |
-typedef size_t (*proto_t) (const char *, const char *);
|
|
|
ce426f |
-size_t simple_strspn (const char *, const char *);
|
|
|
ce426f |
-size_t stupid_strspn (const char *, const char *);
|
|
|
ce426f |
-
|
|
|
ce426f |
-IMPL (stupid_strspn, 0)
|
|
|
ce426f |
-IMPL (simple_strspn, 0)
|
|
|
ce426f |
-IMPL (strspn, 1)
|
|
|
ce426f |
+#ifndef WIDE
|
|
|
ce426f |
+# define STRSPN strspn
|
|
|
ce426f |
+# define CHAR char
|
|
|
ce426f |
+# define UCHAR unsigned char
|
|
|
ce426f |
+# define SIMPLE_STRSPN simple_strspn
|
|
|
ce426f |
+# define STUPID_STRSPN stupid_strspn
|
|
|
ce426f |
+# define STRLEN strlen
|
|
|
ce426f |
+# define STRCHR strchr
|
|
|
ce426f |
+# define BIG_CHAR CHAR_MAX
|
|
|
ce426f |
+# define SMALL_CHAR 127
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+# include <wchar.h>
|
|
|
ce426f |
+# define STRSPN wcsspn
|
|
|
ce426f |
+# define CHAR wchar_t
|
|
|
ce426f |
+# define UCHAR wchar_t
|
|
|
ce426f |
+# define SIMPLE_STRSPN simple_wcsspn
|
|
|
ce426f |
+# define STUPID_STRSPN stupid_wcsspn
|
|
|
ce426f |
+# define STRLEN wcslen
|
|
|
ce426f |
+# define STRCHR wcschr
|
|
|
ce426f |
+# define BIG_CHAR WCHAR_MAX
|
|
|
ce426f |
+# define SMALL_CHAR 1273
|
|
|
ce426f |
+#endif /* WIDE */
|
|
|
ce426f |
+
|
|
|
ce426f |
+typedef size_t (*proto_t) (const CHAR *, const CHAR *);
|
|
|
ce426f |
+size_t SIMPLE_STRSPN (const CHAR *, const CHAR *);
|
|
|
ce426f |
+size_t STUPID_STRSPN (const CHAR *, const CHAR *);
|
|
|
ce426f |
+
|
|
|
ce426f |
+IMPL (STUPID_STRSPN, 0)
|
|
|
ce426f |
+IMPL (SIMPLE_STRSPN, 0)
|
|
|
ce426f |
+IMPL (STRSPN, 1)
|
|
|
ce426f |
|
|
|
ce426f |
size_t
|
|
|
ce426f |
-simple_strspn (const char *s, const char *acc)
|
|
|
ce426f |
+SIMPLE_STRSPN (const CHAR *s, const CHAR *acc)
|
|
|
ce426f |
{
|
|
|
ce426f |
- const char *r, *str = s;
|
|
|
ce426f |
- char c;
|
|
|
ce426f |
+ const CHAR *r, *str = s;
|
|
|
ce426f |
+ CHAR c;
|
|
|
ce426f |
|
|
|
ce426f |
while ((c = *s++) != '\0')
|
|
|
ce426f |
{
|
|
|
ce426f |
@@ -47,9 +74,9 @@ simple_strspn (const char *s, const char *acc)
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
size_t
|
|
|
ce426f |
-stupid_strspn (const char *s, const char *acc)
|
|
|
ce426f |
+STUPID_STRSPN (const CHAR *s, const CHAR *acc)
|
|
|
ce426f |
{
|
|
|
ce426f |
- size_t ns = strlen (s), nacc = strlen (acc);
|
|
|
ce426f |
+ size_t ns = STRLEN (s), nacc = STRLEN (acc);
|
|
|
ce426f |
size_t i, j;
|
|
|
ce426f |
|
|
|
ce426f |
for (i = 0; i < ns; ++i)
|
|
|
ce426f |
@@ -64,7 +91,7 @@ stupid_strspn (const char *s, const char *acc)
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
static void
|
|
|
ce426f |
-do_one_test (impl_t *impl, const char *s, const char *acc, size_t exp_res)
|
|
|
ce426f |
+do_one_test (impl_t *impl, const CHAR *s, const CHAR *acc, size_t exp_res)
|
|
|
ce426f |
{
|
|
|
ce426f |
size_t res = CALL (impl, s, acc);
|
|
|
ce426f |
if (res != exp_res)
|
|
|
ce426f |
@@ -80,34 +107,34 @@ static void
|
|
|
ce426f |
do_test (size_t align, size_t pos, size_t len)
|
|
|
ce426f |
{
|
|
|
ce426f |
size_t i;
|
|
|
ce426f |
- char *acc, *s;
|
|
|
ce426f |
+ CHAR *acc, *s;
|
|
|
ce426f |
|
|
|
ce426f |
align &= 7;
|
|
|
ce426f |
- if (align + pos + 10 >= page_size || len > 240 || ! len)
|
|
|
ce426f |
+ if ((align + pos + 10) * sizeof (CHAR) >= page_size || len > 240 || ! len)
|
|
|
ce426f |
return;
|
|
|
ce426f |
|
|
|
ce426f |
- acc = (char *) (buf2 + (random () & 255));
|
|
|
ce426f |
- s = (char *) (buf1 + align);
|
|
|
ce426f |
+ acc = (CHAR *) (buf2) + (random () & 255);
|
|
|
ce426f |
+ s = (CHAR *) (buf1) + align;
|
|
|
ce426f |
|
|
|
ce426f |
for (i = 0; i < len; ++i)
|
|
|
ce426f |
{
|
|
|
ce426f |
- acc[i] = random () & 255;
|
|
|
ce426f |
+ acc[i] = random () & BIG_CHAR;
|
|
|
ce426f |
if (!acc[i])
|
|
|
ce426f |
- acc[i] = random () & 255;
|
|
|
ce426f |
+ acc[i] = random () & BIG_CHAR;
|
|
|
ce426f |
if (!acc[i])
|
|
|
ce426f |
- acc[i] = 1 + (random () & 127);
|
|
|
ce426f |
+ acc[i] = 1 + (random () & SMALL_CHAR);
|
|
|
ce426f |
}
|
|
|
ce426f |
acc[len] = '\0';
|
|
|
ce426f |
|
|
|
ce426f |
for (i = 0; i < pos; ++i)
|
|
|
ce426f |
s[i] = acc[random () % len];
|
|
|
ce426f |
- s[pos] = random () & 255;
|
|
|
ce426f |
- if (strchr (acc, s[pos]))
|
|
|
ce426f |
+ s[pos] = random () & BIG_CHAR;
|
|
|
ce426f |
+ if (STRCHR (acc, s[pos]))
|
|
|
ce426f |
s[pos] = '\0';
|
|
|
ce426f |
else
|
|
|
ce426f |
{
|
|
|
ce426f |
for (i = pos + 1; i < pos + 10; ++i)
|
|
|
ce426f |
- s[i] = random () & 255;
|
|
|
ce426f |
+ s[i] = random () & BIG_CHAR;
|
|
|
ce426f |
s[i] = '\0';
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
@@ -119,8 +146,8 @@ static void
|
|
|
ce426f |
do_random_tests (void)
|
|
|
ce426f |
{
|
|
|
ce426f |
size_t i, j, n, align, pos, alen, len;
|
|
|
ce426f |
- unsigned char *p = buf1 + page_size - 512;
|
|
|
ce426f |
- unsigned char *acc;
|
|
|
ce426f |
+ UCHAR *p = (UCHAR *) (buf1 + page_size) - 512;
|
|
|
ce426f |
+ UCHAR *acc;
|
|
|
ce426f |
|
|
|
ce426f |
for (n = 0; n < ITERATIONS; n++)
|
|
|
ce426f |
{
|
|
|
ce426f |
@@ -138,14 +165,14 @@ do_random_tests (void)
|
|
|
ce426f |
len = random () & 511;
|
|
|
ce426f |
if (len + align >= 512)
|
|
|
ce426f |
len = 511 - align - (random () & 7);
|
|
|
ce426f |
- acc = buf2 + page_size - alen - 1 - (random () & 7);
|
|
|
ce426f |
+ acc = (UCHAR *) (buf2 + page_size) - alen - 1 - (random () & 7);
|
|
|
ce426f |
for (i = 0; i < alen; ++i)
|
|
|
ce426f |
{
|
|
|
ce426f |
- acc[i] = random () & 255;
|
|
|
ce426f |
+ acc[i] = random () & BIG_CHAR;
|
|
|
ce426f |
if (!acc[i])
|
|
|
ce426f |
- acc[i] = random () & 255;
|
|
|
ce426f |
+ acc[i] = random () & BIG_CHAR;
|
|
|
ce426f |
if (!acc[i])
|
|
|
ce426f |
- acc[i] = 1 + (random () & 127);
|
|
|
ce426f |
+ acc[i] = 1 + (random () & SMALL_CHAR);
|
|
|
ce426f |
}
|
|
|
ce426f |
acc[i] = '\0';
|
|
|
ce426f |
j = (pos > len ? pos : len) + align + 64;
|
|
|
ce426f |
@@ -158,26 +185,27 @@ do_random_tests (void)
|
|
|
ce426f |
p[i] = '\0';
|
|
|
ce426f |
else if (i == pos + align)
|
|
|
ce426f |
{
|
|
|
ce426f |
- p[i] = random () & 255;
|
|
|
ce426f |
- if (strchr ((char *) acc, p[i]))
|
|
|
ce426f |
+ p[i] = random () & BIG_CHAR;
|
|
|
ce426f |
+ if (STRCHR ((CHAR *) acc, p[i]))
|
|
|
ce426f |
p[i] = '\0';
|
|
|
ce426f |
}
|
|
|
ce426f |
else if (i < align || i > pos + align)
|
|
|
ce426f |
- p[i] = random () & 255;
|
|
|
ce426f |
+ p[i] = random () & BIG_CHAR;
|
|
|
ce426f |
else
|
|
|
ce426f |
p[i] = acc [random () % alen];
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
FOR_EACH_IMPL (impl, 1)
|
|
|
ce426f |
- if (CALL (impl, (char *) (p + align),
|
|
|
ce426f |
- (char *) acc) != (pos < len ? pos : len))
|
|
|
ce426f |
+ if (CALL (impl, (CHAR *) (p + align),
|
|
|
ce426f |
+ (CHAR *) acc) != (pos < len ? pos : len))
|
|
|
ce426f |
{
|
|
|
ce426f |
error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %p, %zd, %zd, %zd) %zd != %zd",
|
|
|
ce426f |
n, impl->name, align, acc, alen, pos, len,
|
|
|
ce426f |
- CALL (impl, (char *) (p + align), (char *) acc),
|
|
|
ce426f |
+ CALL (impl, (CHAR *) (p + align), (CHAR *) acc),
|
|
|
ce426f |
(pos < len ? pos : len));
|
|
|
ce426f |
ret = 1;
|
|
|
ce426f |
}
|
|
|
ce426f |
+
|
|
|
ce426f |
}
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
|
|
|
ce426f |
index b8b141e..9403169 100644
|
|
|
ce426f |
--- a/sysdeps/s390/multiarch/Makefile
|
|
|
ce426f |
+++ b/sysdeps/s390/multiarch/Makefile
|
|
|
ce426f |
@@ -11,7 +11,8 @@ sysdep_routines += strlen strlen-vx strlen-c \
|
|
|
ce426f |
strncmp strncmp-vx strncmp-c \
|
|
|
ce426f |
strchr strchr-vx strchr-c \
|
|
|
ce426f |
strchrnul strchrnul-vx strchrnul-c \
|
|
|
ce426f |
- strrchr strrchr-vx strrchr-c
|
|
|
ce426f |
+ strrchr strrchr-vx strrchr-c \
|
|
|
ce426f |
+ strspn strspn-vx strspn-c
|
|
|
ce426f |
endif
|
|
|
ce426f |
|
|
|
ce426f |
ifeq ($(subdir),wcsmbs)
|
|
|
ce426f |
@@ -27,5 +28,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \
|
|
|
ce426f |
wcsncmp wcsncmp-vx wcsncmp-c \
|
|
|
ce426f |
wcschr wcschr-vx wcschr-c \
|
|
|
ce426f |
wcschrnul wcschrnul-vx wcschrnul-c \
|
|
|
ce426f |
- wcsrchr wcsrchr-vx wcsrchr-c
|
|
|
ce426f |
+ wcsrchr wcsrchr-vx wcsrchr-c \
|
|
|
ce426f |
+ wcsspn wcsspn-vx wcsspn-c
|
|
|
ce426f |
endif
|
|
|
ce426f |
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
ce426f |
index ee84d80..cbedf64 100644
|
|
|
ce426f |
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
ce426f |
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
ce426f |
@@ -118,6 +118,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
ce426f |
IFUNC_VX_IMPL (strrchr);
|
|
|
ce426f |
IFUNC_VX_IMPL (wcsrchr);
|
|
|
ce426f |
|
|
|
ce426f |
+ IFUNC_VX_IMPL (strspn);
|
|
|
ce426f |
+ IFUNC_VX_IMPL (wcsspn);
|
|
|
ce426f |
+
|
|
|
ce426f |
#endif /* HAVE_S390_VX_ASM_SUPPORT */
|
|
|
ce426f |
|
|
|
ce426f |
return i;
|
|
|
ce426f |
diff --git a/sysdeps/s390/multiarch/strspn-c.c b/sysdeps/s390/multiarch/strspn-c.c
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..8a7d342
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/sysdeps/s390/multiarch/strspn-c.c
|
|
|
ce426f |
@@ -0,0 +1,28 @@
|
|
|
ce426f |
+/* Default strspn 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 STRSPN __strspn_c
|
|
|
ce426f |
+# ifdef SHARED
|
|
|
ce426f |
+# undef libc_hidden_builtin_def
|
|
|
ce426f |
+# define libc_hidden_builtin_def(name) \
|
|
|
ce426f |
+ __hidden_ver1 (__strspn_c, __GI_strspn, __strspn_c);
|
|
|
ce426f |
+# endif /* SHARED */
|
|
|
ce426f |
+
|
|
|
ce426f |
+# include <string/strspn.c>
|
|
|
ce426f |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
ce426f |
diff --git a/sysdeps/s390/multiarch/strspn-vx.S b/sysdeps/s390/multiarch/strspn-vx.S
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..df22347
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/sysdeps/s390/multiarch/strspn-vx.S
|
|
|
ce426f |
@@ -0,0 +1,256 @@
|
|
|
ce426f |
+/* Vector optimized 32/64 bit S/390 version of strspn.
|
|
|
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 strspn (const char *s, const char * accept)
|
|
|
ce426f |
+ The strspn() function calculates the length of the initial segment
|
|
|
ce426f |
+ of s which consists entirely of characters in accept.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ This method checks the length of accept string. If it fits entirely
|
|
|
ce426f |
+ in one vector register, a fast algorithm is used, which does not need
|
|
|
ce426f |
+ to check multiple parts of accept-string. Otherwise a slower full
|
|
|
ce426f |
+ check of accept-string is used.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ register overview:
|
|
|
ce426f |
+ r3: pointer to start of accept-string
|
|
|
ce426f |
+ r2: pointer to start of search-string
|
|
|
ce426f |
+ r4: loaded byte count of vl search-string
|
|
|
ce426f |
+ r0: found byte index
|
|
|
ce426f |
+ r1: current return len of s
|
|
|
ce426f |
+ v16: search-string
|
|
|
ce426f |
+ v17: accept-string
|
|
|
ce426f |
+ v18: temp-vreg
|
|
|
ce426f |
+
|
|
|
ce426f |
+ ONLY FOR SLOW:
|
|
|
ce426f |
+ v19: first accept-string
|
|
|
ce426f |
+ v20: zero for preparing acc-vector
|
|
|
ce426f |
+ v21: global mask; 1 indicates a match between
|
|
|
ce426f |
+ search-string-vreg and any accept-character
|
|
|
ce426f |
+ v22: current mask; 1 indicates a match between
|
|
|
ce426f |
+ search-string-vreg and any accept-character in current acc-vreg
|
|
|
ce426f |
+ v30, v31: for re-/storing registers r6, r8, r9
|
|
|
ce426f |
+ r5: current len of accept-string
|
|
|
ce426f |
+ r6: zero-index in search-string or 16 if no zero
|
|
|
ce426f |
+ or min(zero-index, loaded byte count)
|
|
|
ce426f |
+ r8: >0, if former accept-string-part contains a zero,
|
|
|
ce426f |
+ otherwise =0;
|
|
|
ce426f |
+ r9: loaded byte count of vlbb accept-string
|
|
|
ce426f |
+*/
|
|
|
ce426f |
+ENTRY(__strspn_vx)
|
|
|
ce426f |
+ .machine "z13"
|
|
|
ce426f |
+ .machinemode "zarch_nohighgprs"
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /*
|
|
|
ce426f |
+ Check if accept-string fits in one vreg:
|
|
|
ce426f |
+ ----------------------------------------
|
|
|
ce426f |
+ */
|
|
|
ce426f |
+ vlbb %v17,0(%r3),6 /* Load accept. */
|
|
|
ce426f |
+ lcbb %r4,0(%r3),6
|
|
|
ce426f |
+ jo .Lcheck_onbb /* Special case if accept lays
|
|
|
ce426f |
+ on block-boundary. */
|
|
|
ce426f |
+.Lcheck_notonbb:
|
|
|
ce426f |
+ vistrbs %v17,%v17 /* Fill with zeros after first zero. */
|
|
|
ce426f |
+ je .Lfast /* Zero found -> accept fits in one vreg. */
|
|
|
ce426f |
+ j .Lslow /* No zero -> accept exceeds one vreg. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+.Lcheck_onbb:
|
|
|
ce426f |
+ /* Accept lays on block-boundary. */
|
|
|
ce426f |
+ vfenezb %v18,%v17,%v17 /* Search zero in loaded accept bytes. */
|
|
|
ce426f |
+ vlgvb %r0,%v18,7 /* Get index of zero or 16 if not found. */
|
|
|
ce426f |
+ clrjl %r0,%r4,.Lcheck_notonbb /* Zero index < loaded bytes count ->
|
|
|
ce426f |
+ Accept fits in one vreg;
|
|
|
ce426f |
+ Fill with zeros and proceed
|
|
|
ce426f |
+ with FAST. */
|
|
|
ce426f |
+ vl %v17,0(%r3) /* Load accept, which exceeds loaded bytes. */
|
|
|
ce426f |
+ j .Lcheck_notonbb /* Check if accept fits in one vreg. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /*
|
|
|
ce426f |
+ Search s for accept in one vreg
|
|
|
ce426f |
+ -------------------------------
|
|
|
ce426f |
+ */
|
|
|
ce426f |
+.Lfast:
|
|
|
ce426f |
+ /* Complete accept-string is in v17 and remaining bytes are zero. */
|
|
|
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 |
+ vfaezbs %v16,%v16,%v17,8 /* Find first element in v16
|
|
|
ce426f |
+ unequal to any in v17
|
|
|
ce426f |
+ or first zero element. */
|
|
|
ce426f |
+ vlgvb %r0,%v16,7 /* Load byte index of found element. */
|
|
|
ce426f |
+ /* If found index is within loaded bytes (%r0 < %r1),
|
|
|
ce426f |
+ return with found element index (=equal count). */
|
|
|
ce426f |
+ clr %r0,%r1
|
|
|
ce426f |
+ locgrl %r2,%r0
|
|
|
ce426f |
+ blr %r14
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* Align s to 16 byte. */
|
|
|
ce426f |
+ risbgn %r4,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
|
|
|
ce426f |
+ lghi %r1,16 /* current_len = 16. */
|
|
|
ce426f |
+ slr %r1,%r4 /* Compute bytes to 16bytes boundary. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+.Lfast_loop:
|
|
|
ce426f |
+ vl %v16,0(%r1,%r2) /* Load search-string. */
|
|
|
ce426f |
+ vfaezbs %v16,%v16,%v17,8 /* Find first element in v16
|
|
|
ce426f |
+ unequal to any in v17
|
|
|
ce426f |
+ or first zero element. */
|
|
|
ce426f |
+ jno .Lfast_loop_found
|
|
|
ce426f |
+ vl %v16,16(%r1,%r2)
|
|
|
ce426f |
+ vfaezbs %v16,%v16,%v17,8
|
|
|
ce426f |
+ jno .Lfast_loop_found16
|
|
|
ce426f |
+ vl %v16,32(%r1,%r2)
|
|
|
ce426f |
+ vfaezbs %v16,%v16,%v17,8
|
|
|
ce426f |
+ jno .Lfast_loop_found32
|
|
|
ce426f |
+ vl %v16,48(%r1,%r2)
|
|
|
ce426f |
+ vfaezbs %v16,%v16,%v17,8
|
|
|
ce426f |
+ jno .Lfast_loop_found48
|
|
|
ce426f |
+
|
|
|
ce426f |
+ aghi %r1,64
|
|
|
ce426f |
+ j .Lfast_loop /* Loop if no element was unequal to accept
|
|
|
ce426f |
+ and not zero. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* Found unequal or zero element. */
|
|
|
ce426f |
+.Lfast_loop_found48:
|
|
|
ce426f |
+ aghi %r1,16
|
|
|
ce426f |
+.Lfast_loop_found32:
|
|
|
ce426f |
+ aghi %r1,16
|
|
|
ce426f |
+.Lfast_loop_found16:
|
|
|
ce426f |
+ aghi %r1,16
|
|
|
ce426f |
+.Lfast_loop_found:
|
|
|
ce426f |
+ vlgvb %r0,%v16,7 /* Load byte index of found element. */
|
|
|
ce426f |
+ algrk %r2,%r1,%r0 /* And add it to current len. */
|
|
|
ce426f |
+ br %r14
|
|
|
ce426f |
+
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /*
|
|
|
ce426f |
+ Search s for accept in multiple vregs
|
|
|
ce426f |
+ -------------------------------------
|
|
|
ce426f |
+ */
|
|
|
ce426f |
+.Lslow:
|
|
|
ce426f |
+ /* Save registers. */
|
|
|
ce426f |
+ vlvgg %v30,%r6,0
|
|
|
ce426f |
+ vlvgp %v31,%r8,%r9
|
|
|
ce426f |
+ lghi %r1,0 /* current_len = 0. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* Accept in v17 without zero. */
|
|
|
ce426f |
+ vlr %v19,%v17 /* Save first acc-part for a fast reload. */
|
|
|
ce426f |
+ vzero %v20 /* Zero for preparing acc-vector. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* Align s to 16 byte. */
|
|
|
ce426f |
+ risbg %r0,%r2,60,128+63,0 /* Test if s is aligned and
|
|
|
ce426f |
+ %r0 = bits 60-63 'and' 15 */
|
|
|
ce426f |
+ je .Lslow_loop_str /* If s is aligned, loop aligned */
|
|
|
ce426f |
+ lghi %r4,15
|
|
|
ce426f |
+ slr %r4,%r0 /* Compute highest index to load (15-x). */
|
|
|
ce426f |
+ vll %v16,%r4,0(%r2) /* Load up to 16byte boundary (vll needs
|
|
|
ce426f |
+ highest index, left bytes are 0). */
|
|
|
ce426f |
+ ahi %r4,1 /* Work with loaded byte count. */
|
|
|
ce426f |
+ vzero %v21 /* Zero out global mask. */
|
|
|
ce426f |
+ lghi %r5,0 /* Set current len of accept-string to zero. */
|
|
|
ce426f |
+ vfenezb %v18,%v16,%v16 /* Find zero in current string-part. */
|
|
|
ce426f |
+ lghi %r8,0 /* There is no zero in first accept-part. */
|
|
|
ce426f |
+ vlgvb %r6,%v18,7 /* Load byte index of zero or 16
|
|
|
ce426f |
+ if there is no zero. */
|
|
|
ce426f |
+ clr %r4,%r6 /* cc==1 if loaded byte count < zero-index. */
|
|
|
ce426f |
+ locrl %r6,%r4 /* Load on cc==1. */
|
|
|
ce426f |
+ j .Lslow_loop_acc
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* Process s in 16byte aligned loop. */
|
|
|
ce426f |
+.Lslow_next_str:
|
|
|
ce426f |
+ vlr %v17,%v19 /* Load first part of accept (no zero). */
|
|
|
ce426f |
+ algfr %r1,%r4 /* Add loaded byte count to current len. */
|
|
|
ce426f |
+.Lslow_loop_str:
|
|
|
ce426f |
+ vl %v16,0(%r1,%r2) /* Load search-string. */
|
|
|
ce426f |
+ lghi %r4,16 /* Loaded byte count is 16. */
|
|
|
ce426f |
+ vzero %v21 /* Zero out global mask. */
|
|
|
ce426f |
+ lghi %r5,0 /* Set current len of accept-string to zero. */
|
|
|
ce426f |
+ vfenezb %v18,%v16,%v16 /* Find zero in current string-part. */
|
|
|
ce426f |
+ lghi %r8,0 /* There is no zero in first accept-part. */
|
|
|
ce426f |
+ vlgvb %r6,%v18,7 /* Load byte index of zero or 16 if no zero. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+.Lslow_loop_acc:
|
|
|
ce426f |
+ vfaeb %v22,%v16,%v17,4 /* Create matching-mask (1 in mask ->
|
|
|
ce426f |
+ character matches any accepted character in
|
|
|
ce426f |
+ this accept-string-part) IN=0, RT=1. */
|
|
|
ce426f |
+ vo %v21,%v21,%v22 /* global-mask = global- | matching-mask. */
|
|
|
ce426f |
+ vfenezb %v18,%v21,%v21 /* Find first zero in global-mask. */
|
|
|
ce426f |
+ vlgvb %r0,%v18,7 /* Get first found zero-index
|
|
|
ce426f |
+ (= first mismatch). */
|
|
|
ce426f |
+ clrjl %r0,%r6,.Lslow_next_acc /* Mismatch-index < min(lbc,zero-index)
|
|
|
ce426f |
+ -> Process this string-part
|
|
|
ce426f |
+ with next acc-part. */
|
|
|
ce426f |
+ clrjhe %r0,%r4,.Lslow_next_str /* Found-index >= loaded byte count
|
|
|
ce426f |
+ -> All loaded bytes are matching
|
|
|
ce426f |
+ any accept-character
|
|
|
ce426f |
+ and are not zero. */
|
|
|
ce426f |
+ /* All bytes are matching any characters in accept-string
|
|
|
ce426f |
+ and search-string is fully processed (found-index == zero-index) */
|
|
|
ce426f |
+.Lslow_add_lbc_end:
|
|
|
ce426f |
+ algrk %r2,%r1,%r0 /* Add matching characters to current_len. */
|
|
|
ce426f |
+ /* Restore registers. */
|
|
|
ce426f |
+ vlgvg %r6,%v30,0
|
|
|
ce426f |
+ vlgvg %r8,%v31,0
|
|
|
ce426f |
+ vlgvg %r9,%v31,1
|
|
|
ce426f |
+ br %r14
|
|
|
ce426f |
+
|
|
|
ce426f |
+
|
|
|
ce426f |
+
|
|
|
ce426f |
+.Lslow_next_acc:
|
|
|
ce426f |
+ clijh %r8,0,.Lslow_add_lbc_end /* There was a zero in last acc-part
|
|
|
ce426f |
+ -> Add found index to current len
|
|
|
ce426f |
+ and end. */
|
|
|
ce426f |
+ vlbb %v17,16(%r5,%r3),6 /* Load next accept part. */
|
|
|
ce426f |
+ aghi %r5,16 /* Add current_len of accept-string. */
|
|
|
ce426f |
+ lcbb %r9,0(%r5,%r3),6 /* Get loaded byte count of accept-string. */
|
|
|
ce426f |
+ jo .Lslow_next_acc_onbb /* Jump away if accept-string is
|
|
|
ce426f |
+ on block-boundary. */
|
|
|
ce426f |
+.Lslow_next_acc_notonbb:
|
|
|
ce426f |
+ vistrbs %v17,%v17 /* Fill with zeros after first zero. */
|
|
|
ce426f |
+ jo .Lslow_loop_acc /* No zero found -> no preparation needed. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+.Lslow_next_acc_prepare_zero:
|
|
|
ce426f |
+ /* Zero in accept-part: fill zeros with first-accept-character. */
|
|
|
ce426f |
+ vlgvb %r8,%v17,0 /* Load first element of acc-part. */
|
|
|
ce426f |
+ clije %r8,0,.Lslow_add_lbc_end /* End if zero is first character
|
|
|
ce426f |
+ in this part of accept-string. */
|
|
|
ce426f |
+ /* r8>0 -> zero found in this acc-part. */
|
|
|
ce426f |
+ vrepb %v18,%v17,0 /* Replicate first char accross all chars. */
|
|
|
ce426f |
+ vceqb %v22,%v20,%v17 /* Create a mask (v22) of null chars
|
|
|
ce426f |
+ by comparing with 0 (v20). */
|
|
|
ce426f |
+ vsel %v17,%v18,%v17,%v22 /* Replace null chars with first char. */
|
|
|
ce426f |
+ j .Lslow_loop_acc /* Accept part is prepared -> process. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+.Lslow_next_acc_onbb:
|
|
|
ce426f |
+ vfenezb %v18,%v17,%v17 /* Find zero in loaded bytes of accept part. */
|
|
|
ce426f |
+ vlgvb %r8,%v18,7 /* Load byte index of zero. */
|
|
|
ce426f |
+ clrjl %r8,%r9,.Lslow_next_acc_notonbb /* Found a zero in loaded bytes
|
|
|
ce426f |
+ -> Prepare vr. */
|
|
|
ce426f |
+ vl %v17,0(%r5,%r3) /* Load over boundary ... */
|
|
|
ce426f |
+ lghi %r8,0 /* r8=0 -> no zero in this part of acc,
|
|
|
ce426f |
+ Check for zero is in jump-target. */
|
|
|
ce426f |
+ j .Lslow_next_acc_notonbb /* ... and search for zero in
|
|
|
ce426f |
+ fully loaded vreg again. */
|
|
|
ce426f |
+END(__strspn_vx)
|
|
|
ce426f |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
ce426f |
diff --git a/sysdeps/s390/multiarch/strspn.c b/sysdeps/s390/multiarch/strspn.c
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..48dd77b
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/sysdeps/s390/multiarch/strspn.c
|
|
|
ce426f |
@@ -0,0 +1,27 @@
|
|
|
ce426f |
+/* Multiple versions of strspn.
|
|
|
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 (__strspn, strspn)
|
|
|
ce426f |
+
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+# include <string/strspn.c>
|
|
|
ce426f |
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
|
|
|
ce426f |
diff --git a/sysdeps/s390/multiarch/wcsspn-c.c b/sysdeps/s390/multiarch/wcsspn-c.c
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..93af16c
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/sysdeps/s390/multiarch/wcsspn-c.c
|
|
|
ce426f |
@@ -0,0 +1,31 @@
|
|
|
ce426f |
+/* Default wcsspn 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 WCSSPN __wcsspn_c
|
|
|
ce426f |
+
|
|
|
ce426f |
+# include <wchar.h>
|
|
|
ce426f |
+extern __typeof (wcsspn) __wcsspn_c;
|
|
|
ce426f |
+# ifdef SHARED
|
|
|
ce426f |
+# undef libc_hidden_def
|
|
|
ce426f |
+# define libc_hidden_def(name) \
|
|
|
ce426f |
+ __hidden_ver1 (__wcsspn_c, __GI_wcsspn, __wcsspn_c);
|
|
|
ce426f |
+# endif /* SHARED */
|
|
|
ce426f |
+
|
|
|
ce426f |
+# include <wcsmbs/wcsspn.c>
|
|
|
ce426f |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
ce426f |
diff --git a/sysdeps/s390/multiarch/wcsspn-vx.S b/sysdeps/s390/multiarch/wcsspn-vx.S
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..4ed8e84
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/sysdeps/s390/multiarch/wcsspn-vx.S
|
|
|
ce426f |
@@ -0,0 +1,270 @@
|
|
|
ce426f |
+/* Vector optimized 32/64 bit S/390 version of wcsspn.
|
|
|
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 wcsspn (const wchar_t *s, const wchar_t * accept)
|
|
|
ce426f |
+ The wcsspn() function calculates the length of the initial segment
|
|
|
ce426f |
+ of s which consists entirely of characters in accept.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ This method checks the length of accept string. If it fits entirely
|
|
|
ce426f |
+ in one vector register, a fast algorithm is used, which does not need
|
|
|
ce426f |
+ to check multiple parts of accept-string. Otherwise a slower full
|
|
|
ce426f |
+ check of accept-string is used.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ register overview:
|
|
|
ce426f |
+ r3: pointer to start of accept-string
|
|
|
ce426f |
+ r2: pointer to start of search-string
|
|
|
ce426f |
+ r4: loaded byte count of vl search-string
|
|
|
ce426f |
+ r0: found byte index
|
|
|
ce426f |
+ r1: current return len of s
|
|
|
ce426f |
+ v16: search-string
|
|
|
ce426f |
+ v17: accept-string
|
|
|
ce426f |
+ v18: temp-vreg
|
|
|
ce426f |
+
|
|
|
ce426f |
+ ONLY FOR SLOW:
|
|
|
ce426f |
+ v19: first accept-string
|
|
|
ce426f |
+ v20: zero for preparing acc-vector
|
|
|
ce426f |
+ v21: global mask; 1 indicates a match between
|
|
|
ce426f |
+ search-string-vreg and any accept-character
|
|
|
ce426f |
+ v22: current mask; 1 indicates a match between
|
|
|
ce426f |
+ search-string-vreg and any accept-character in current acc-vreg
|
|
|
ce426f |
+ v30, v31: for re-/storing registers r6, r8, r9
|
|
|
ce426f |
+ r5: current len of accept-string
|
|
|
ce426f |
+ r6: zero-index in search-string or 16 if no zero
|
|
|
ce426f |
+ or min(zero-index, loaded byte count)
|
|
|
ce426f |
+ r8: >0, if former accept-string-part contains a zero,
|
|
|
ce426f |
+ otherwise =0;
|
|
|
ce426f |
+ r9: loaded byte count of vlbb accept-string
|
|
|
ce426f |
+*/
|
|
|
ce426f |
+ENTRY(__wcsspn_vx)
|
|
|
ce426f |
+ .machine "z13"
|
|
|
ce426f |
+ .machinemode "zarch_nohighgprs"
|
|
|
ce426f |
+
|
|
|
ce426f |
+ tmll %r2,3 /* Test if s is 4-byte aligned? */
|
|
|
ce426f |
+ jne .Lfallback /* And use common-code variant if not. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /*
|
|
|
ce426f |
+ Check if accept-string fits in one vreg:
|
|
|
ce426f |
+ ----------------------------------------
|
|
|
ce426f |
+ */
|
|
|
ce426f |
+ vlbb %v17,0(%r3),6 /* Load accept. */
|
|
|
ce426f |
+ lcbb %r4,0(%r3),6
|
|
|
ce426f |
+ jo .Lcheck_onbb /* Special case if accept lays
|
|
|
ce426f |
+ on block-boundary. */
|
|
|
ce426f |
+.Lcheck_notonbb:
|
|
|
ce426f |
+ vistrfs %v17,%v17 /* Fill with zeros after first zero. */
|
|
|
ce426f |
+ je .Lfast /* Zero found -> accept fits in one vreg. */
|
|
|
ce426f |
+ j .Lslow /* No zero -> accept exceeds one vreg. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+.Lcheck_onbb:
|
|
|
ce426f |
+ /* Accept lays on block-boundary. */
|
|
|
ce426f |
+ nill %r4,65532 /* Recognize only fully loaded characters. */
|
|
|
ce426f |
+ je .Lcheck_onbb2 /* Reload vr if no full wchar_t. */
|
|
|
ce426f |
+ vfenezf %v18,%v17,%v17 /* Search zero in loaded accept bytes. */
|
|
|
ce426f |
+ vlgvb %r0,%v18,7 /* Get index of zero or 16 if not found. */
|
|
|
ce426f |
+ clrjl %r0,%r4,.Lcheck_notonbb /* Zero index < loaded bytes count ->
|
|
|
ce426f |
+ Accept fits in one vreg;
|
|
|
ce426f |
+ Fill with zeros and proceed
|
|
|
ce426f |
+ with FAST. */
|
|
|
ce426f |
+.Lcheck_onbb2:
|
|
|
ce426f |
+ vl %v17,0(%r3) /* Load accept, which exceeds loaded bytes. */
|
|
|
ce426f |
+ j .Lcheck_notonbb /* Check if accept fits in one vreg. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /*
|
|
|
ce426f |
+ Search s for accept in one vreg
|
|
|
ce426f |
+ -------------------------------
|
|
|
ce426f |
+ */
|
|
|
ce426f |
+.Lfast:
|
|
|
ce426f |
+ /* Complete accept-string in v17 and remaining bytes are zero. */
|
|
|
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 |
+ vfaezfs %v16,%v16,%v17,8 /* Find first element in v16
|
|
|
ce426f |
+ unequal to any in v17
|
|
|
ce426f |
+ or first zero element. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+ vlgvb %r0,%v16,7 /* Load byte index of found element. */
|
|
|
ce426f |
+ /* If found index is within loaded bytes (%r0 < %r1),
|
|
|
ce426f |
+ return with found element index (=equal count). */
|
|
|
ce426f |
+ clr %r0,%r1
|
|
|
ce426f |
+ srlg %r0,%r0,2 /* Convert byte-count to character-count. */
|
|
|
ce426f |
+ locgrl %r2,%r0
|
|
|
ce426f |
+ blr %r14
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* Align s to 16 byte. */
|
|
|
ce426f |
+ risbgn %r4,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
|
|
|
ce426f |
+ lghi %r1,16 /* current_len = 16. */
|
|
|
ce426f |
+ slr %r1,%r4 /* Compute bytes to 16bytes boundary. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+.Lfast_loop:
|
|
|
ce426f |
+ vl %v16,0(%r1,%r2) /* Load search-string. */
|
|
|
ce426f |
+ vfaezfs %v16,%v16,%v17,8 /* Find first element in v16
|
|
|
ce426f |
+ unequal to any in v17
|
|
|
ce426f |
+ or first zero element. */
|
|
|
ce426f |
+ jno .Lfast_loop_found
|
|
|
ce426f |
+ vl %v16,16(%r1,%r2)
|
|
|
ce426f |
+ vfaezfs %v16,%v16,%v17,8
|
|
|
ce426f |
+ jno .Lfast_loop_found16
|
|
|
ce426f |
+ vl %v16,32(%r1,%r2)
|
|
|
ce426f |
+ vfaezfs %v16,%v16,%v17,8
|
|
|
ce426f |
+ jno .Lfast_loop_found32
|
|
|
ce426f |
+ vl %v16,48(%r1,%r2)
|
|
|
ce426f |
+ vfaezfs %v16,%v16,%v17,8
|
|
|
ce426f |
+ jno .Lfast_loop_found48
|
|
|
ce426f |
+
|
|
|
ce426f |
+ aghi %r1,64
|
|
|
ce426f |
+ j .Lfast_loop /* Loop if no element was unequal to accept
|
|
|
ce426f |
+ and not zero. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* Found unequal or zero element. */
|
|
|
ce426f |
+.Lfast_loop_found48:
|
|
|
ce426f |
+ aghi %r1,16
|
|
|
ce426f |
+.Lfast_loop_found32:
|
|
|
ce426f |
+ aghi %r1,16
|
|
|
ce426f |
+.Lfast_loop_found16:
|
|
|
ce426f |
+ aghi %r1,16
|
|
|
ce426f |
+.Lfast_loop_found:
|
|
|
ce426f |
+ vlgvb %r0,%v16,7 /* Load byte index of found element. */
|
|
|
ce426f |
+ algrk %r2,%r1,%r0 /* And add it to current len. */
|
|
|
ce426f |
+ srlg %r2,%r2,2 /* Convert byte-count to character-count. */
|
|
|
ce426f |
+ br %r14
|
|
|
ce426f |
+
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /*
|
|
|
ce426f |
+ Search s for accept in multiple vregs
|
|
|
ce426f |
+ -------------------------------------
|
|
|
ce426f |
+ */
|
|
|
ce426f |
+.Lslow:
|
|
|
ce426f |
+ /* Save registers. */
|
|
|
ce426f |
+ vlvgg %v30,%r6,0
|
|
|
ce426f |
+ vlvgp %v31,%r8,%r9
|
|
|
ce426f |
+ lghi %r1,0 /* Zero out current len. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* accept in v17 without zero. */
|
|
|
ce426f |
+ vlr %v19,%v17 /* Save first acc-part for a fast reload. */
|
|
|
ce426f |
+ vzero %v20 /* Zero for preparing acc-vector. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* Align s to 16 byte. */
|
|
|
ce426f |
+ risbg %r0,%r2,60,128+63,0 /* Test if s is aligned and
|
|
|
ce426f |
+ %r0 = bits 60-63 'and' 15. */
|
|
|
ce426f |
+ je .Lslow_loop_str /* If s is aligned, loop aligned */
|
|
|
ce426f |
+ lghi %r4,15
|
|
|
ce426f |
+ slr %r4,%r0 /* Compute highest index to load (15-x). */
|
|
|
ce426f |
+ vll %v16,%r4,0(%r2) /* Load up to 16byte boundary (vll needs
|
|
|
ce426f |
+ highest index, remaining bytes are 0). */
|
|
|
ce426f |
+ aghi %r4,1 /* Work with loaded byte count. */
|
|
|
ce426f |
+ vzero %v21 /* Zero out global mask. */
|
|
|
ce426f |
+ lghi %r5,0 /* Set current len of accept-string to zero. */
|
|
|
ce426f |
+ vfenezf %v18,%v16,%v16 /* Find zero in current string-part. */
|
|
|
ce426f |
+ lghi %r8,0 /* There is no zero in first accept-part. */
|
|
|
ce426f |
+ vlgvb %r6,%v18,7 /* Load byte index of zero or 16
|
|
|
ce426f |
+ if there is no zero. */
|
|
|
ce426f |
+ clr %r4,%r6 /* cc==1 if loaded byte count < zero-index. */
|
|
|
ce426f |
+ locrl %r6,%r4 /* Load on cc==1. */
|
|
|
ce426f |
+ j .Lslow_loop_acc
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* Process s in 16byte aligned loop. */
|
|
|
ce426f |
+.Lslow_next_str:
|
|
|
ce426f |
+ vlr %v17,%v19 /* Load first part of accept (no zero). */
|
|
|
ce426f |
+ algfr %r1,%r4 /* Add loaded byte count to current len. */
|
|
|
ce426f |
+.Lslow_loop_str:
|
|
|
ce426f |
+ vl %v16,0(%r1,%r2) /* Load search-string. */
|
|
|
ce426f |
+ lghi %r4,16 /* Loaded byte count is 16. */
|
|
|
ce426f |
+ vzero %v21 /* Zero out global mask. */
|
|
|
ce426f |
+ lghi %r5,0 /* Set current len of accept-string to zero. */
|
|
|
ce426f |
+ vfenezf %v18,%v16,%v16 /* Find zero in current string-part. */
|
|
|
ce426f |
+ lghi %r8,0 /* There is no zero in first accept-part. */
|
|
|
ce426f |
+ vlgvb %r6,%v18,7 /* Load byte index of zero or 16 if no zero. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+.Lslow_loop_acc:
|
|
|
ce426f |
+ vfaef %v22,%v16,%v17,4 /* Create matching-mask (1 in mask ->
|
|
|
ce426f |
+ character matches any accepted character in
|
|
|
ce426f |
+ this accept-string-part) IN=0, RT=1. */
|
|
|
ce426f |
+ vo %v21,%v21,%v22 /* global-mask = global- | matching-mask. */
|
|
|
ce426f |
+ vfenezf %v18,%v21,%v21 /* Find first zero in global-mask. */
|
|
|
ce426f |
+ vlgvb %r0,%v18,7 /* Get first found zero-index
|
|
|
ce426f |
+ (= first mismatch). */
|
|
|
ce426f |
+ clrjl %r0,%r6,.Lslow_next_acc /* Mismatch-index < min(lbc,zero-index)
|
|
|
ce426f |
+ -> Process this string-part
|
|
|
ce426f |
+ with next acc-part. */
|
|
|
ce426f |
+ clrjhe %r0,%r4,.Lslow_next_str /* Found-index >= loaded byte count
|
|
|
ce426f |
+ -> All loaded bytes are matching
|
|
|
ce426f |
+ any accept-character
|
|
|
ce426f |
+ and are not zero. */
|
|
|
ce426f |
+ /* All bytes are matching any characters in accept-string
|
|
|
ce426f |
+ and search-string is fully processed (found-index == zero-index). */
|
|
|
ce426f |
+.Lslow_add_lbc_end:
|
|
|
ce426f |
+ algrk %r2,%r1,%r0 /* Add matching characters to current len. */
|
|
|
ce426f |
+ srlg %r2,%r2,2 /* Convert byte-count to character-count. */
|
|
|
ce426f |
+ /* Restore registers. */
|
|
|
ce426f |
+ vlgvg %r6,%v30,0
|
|
|
ce426f |
+ vlgvg %r8,%v31,0
|
|
|
ce426f |
+ vlgvg %r9,%v31,1
|
|
|
ce426f |
+ br %r14
|
|
|
ce426f |
+
|
|
|
ce426f |
+.Lslow_next_acc:
|
|
|
ce426f |
+ clijh %r8,0,.Lslow_add_lbc_end /* There was a zero in last acc-part
|
|
|
ce426f |
+ -> Add found index to current len
|
|
|
ce426f |
+ and end. */
|
|
|
ce426f |
+ vlbb %v17,16(%r5,%r3),6 /* Load next accept part. */
|
|
|
ce426f |
+ aghi %r5,16 /* Increment current len of accept-string. */
|
|
|
ce426f |
+ lcbb %r9,0(%r5,%r3),6 /* Get loaded byte count of accept-string. */
|
|
|
ce426f |
+ jo .Lslow_next_acc_onbb /* Jump away if accept-string is
|
|
|
ce426f |
+ on block-boundary. */
|
|
|
ce426f |
+.Lslow_next_acc_notonbb:
|
|
|
ce426f |
+ vistrfs %v17,%v17 /* Fill with zeros after first zero. */
|
|
|
ce426f |
+ jo .Lslow_loop_acc /* No zero found -> no preparation needed. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+.Lslow_next_acc_prepare_zero:
|
|
|
ce426f |
+ /* Zero in accept-part: fill zeros with first-accept-character. */
|
|
|
ce426f |
+ vlgvf %r8,%v17,0 /* Load first element of acc-part. */
|
|
|
ce426f |
+ clije %r8,0,.Lslow_add_lbc_end /* End if zero is first character
|
|
|
ce426f |
+ in this part of accept-string. */
|
|
|
ce426f |
+ /* r8>0 -> zero found in this acc-part. */
|
|
|
ce426f |
+ vrepf %v18,%v17,0 /* Replicate first char accross all chars. */
|
|
|
ce426f |
+ vceqf %v22,%v20,%v17 /* Create a mask (v22) of null chars
|
|
|
ce426f |
+ by comparing with 0 (v20). */
|
|
|
ce426f |
+ vsel %v17,%v18,%v17,%v22 /* Replace null chars with first char. */
|
|
|
ce426f |
+ j .Lslow_loop_acc /* Accept part is prepared -> process. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+.Lslow_next_acc_onbb:
|
|
|
ce426f |
+ nill %r9,65532 /* Recognize only fully loaded characters. */
|
|
|
ce426f |
+ je .Lslow_next_acc_onbb2 /* Reload vr, if we loaded no full
|
|
|
ce426f |
+ wchar_t. */
|
|
|
ce426f |
+ vfenezf %v18,%v17,%v17 /* Find zero in loaded bytes of accept part. */
|
|
|
ce426f |
+ vlgvb %r8,%v18,7 /* Load byte index of zero. */
|
|
|
ce426f |
+ clrjl %r8,%r9,.Lslow_next_acc_notonbb /* Found a zero in loaded bytes
|
|
|
ce426f |
+ -> Prepare vreg. */
|
|
|
ce426f |
+.Lslow_next_acc_onbb2:
|
|
|
ce426f |
+ vl %v17,0(%r5,%r3) /* Load over boundary ... */
|
|
|
ce426f |
+ lghi %r8,0 /* r8=0 -> no zero in this part of acc,
|
|
|
ce426f |
+ check for zero is in jump-target. */
|
|
|
ce426f |
+ j .Lslow_next_acc_notonbb /* ... and search for zero in
|
|
|
ce426f |
+ fully loaded vreg again. */
|
|
|
ce426f |
+.Lfallback:
|
|
|
ce426f |
+ jg __wcsspn_c
|
|
|
ce426f |
+END(__wcsspn_vx)
|
|
|
ce426f |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
ce426f |
diff --git a/sysdeps/s390/multiarch/wcsspn.c b/sysdeps/s390/multiarch/wcsspn.c
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..3b3041c
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/sysdeps/s390/multiarch/wcsspn.c
|
|
|
ce426f |
@@ -0,0 +1,27 @@
|
|
|
ce426f |
+/* Multiple versions of wcsspn.
|
|
|
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_ifunc2 (__wcsspn, wcsspn)
|
|
|
ce426f |
+
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+# include <wcsmbs/wcsspn.c>
|
|
|
ce426f |
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
|
|
|
ce426f |
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
|
|
|
ce426f |
index de3635d..843a23c 100644
|
|
|
ce426f |
--- a/wcsmbs/Makefile
|
|
|
ce426f |
+++ b/wcsmbs/Makefile
|
|
|
ce426f |
@@ -42,7 +42,7 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
|
|
|
ce426f |
mbrtoc16 c16rtomb
|
|
|
ce426f |
|
|
|
ce426f |
strop-tests := wcscmp wcsncmp wmemcmp wcslen wcschr wcsrchr wcscpy wcsnlen \
|
|
|
ce426f |
- wcpcpy wcsncpy wcpncpy wcscat wcsncat wcschrnul
|
|
|
ce426f |
+ wcpcpy wcsncpy wcpncpy wcscat wcsncat wcschrnul wcsspn
|
|
|
ce426f |
tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \
|
|
|
ce426f |
tst-wcrtomb tst-wcpncpy tst-mbsrtowcs tst-wchar-h tst-mbrtowc2 \
|
|
|
ce426f |
tst-c16c32-1 wcsatcliff $(addprefix test-,$(strop-tests))
|
|
|
ce426f |
diff --git a/wcsmbs/test-wcsspn-ifunc.c b/wcsmbs/test-wcsspn-ifunc.c
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..73f288f
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/wcsmbs/test-wcsspn-ifunc.c
|
|
|
ce426f |
@@ -0,0 +1,20 @@
|
|
|
ce426f |
+/* Test and measure IFUNC implementations of wcsspn function.
|
|
|
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 TEST_IFUNC 1
|
|
|
ce426f |
+#include "test-wcsspn.c"
|
|
|
ce426f |
diff --git a/wcsmbs/test-wcsspn.c b/wcsmbs/test-wcsspn.c
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..171043c
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/wcsmbs/test-wcsspn.c
|
|
|
ce426f |
@@ -0,0 +1,20 @@
|
|
|
ce426f |
+/* Test wcsspn 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 "../string/test-strspn.c"
|
|
|
ce426f |
diff --git a/wcsmbs/wcsspn.c b/wcsmbs/wcsspn.c
|
|
|
ce426f |
index dad72b4..3e84726 100644
|
|
|
ce426f |
--- a/wcsmbs/wcsspn.c
|
|
|
ce426f |
+++ b/wcsmbs/wcsspn.c
|
|
|
ce426f |
@@ -18,6 +18,9 @@
|
|
|
ce426f |
|
|
|
ce426f |
#include <wchar.h>
|
|
|
ce426f |
|
|
|
ce426f |
+#ifdef WCSSPN
|
|
|
ce426f |
+# define wcsspn WCSSPN
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
|
|
|
ce426f |
/* Return the length of the maximum initial segment
|
|
|
ce426f |
of WCS which contains only wide-characters in ACCEPT. */
|
|
|
ce426f |
--
|
|
|
ce426f |
2.3.0
|
|
|
ce426f |
|