|
|
147e83 |
From 4c98816d5248bed13b1d8388efc0c47fe869300f Mon Sep 17 00:00:00 2001
|
|
|
147e83 |
From: Stefan Liebler <stli@linux.vnet.ibm.com>
|
|
|
147e83 |
Date: Thu, 8 Oct 2015 11:02:10 +0200
|
|
|
147e83 |
Subject: [PATCH 12/30] S390: Optimize strcpy and wcscpy.
|
|
|
147e83 |
|
|
|
147e83 |
upstream-commit-id: 680df122ab8a07806cb38d044292896334f76c01
|
|
|
147e83 |
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00157.html
|
|
|
147e83 |
|
|
|
147e83 |
This patch provides optimized versions of strcpy and wcscpy with the z13
|
|
|
147e83 |
vector instructions.
|
|
|
147e83 |
|
|
|
147e83 |
ChangeLog:
|
|
|
147e83 |
|
|
|
147e83 |
* sysdeps/s390/multiarch/strcpy-vx.S: New File.
|
|
|
147e83 |
* sysdeps/s390/multiarch/strcpy.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/wcscpy-c.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/wcscpy-vx.S: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/wcscpy.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/s390-32/multiarch/strcpy.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/s390-64/multiarch/strcpy.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add strcpy and
|
|
|
147e83 |
wcscpy functions.
|
|
|
147e83 |
* sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
(__libc_ifunc_impl_list): Add ifunc test for strcpy, wcscpy.
|
|
|
147e83 |
* benchtests/bench-wcscpy.c: New File.
|
|
|
147e83 |
* benchtests/Makefile (wcsmbs-bench): Add wcscpy.
|
|
|
147e83 |
---
|
|
|
147e83 |
benchtests/Makefile | 2 +-
|
|
|
147e83 |
benchtests/bench-wcscpy.c | 20 ++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/Makefile | 6 +-
|
|
|
147e83 |
sysdeps/s390/multiarch/ifunc-impl-list.c | 3 +
|
|
|
147e83 |
sysdeps/s390/multiarch/strcpy-vx.S | 109 ++++++++++++++++++++++++++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/strcpy.c | 24 +++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/wcscpy-c.c | 25 +++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/wcscpy-vx.S | 111 +++++++++++++++++++++++++++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/wcscpy.c | 27 ++++++++
|
|
|
147e83 |
sysdeps/s390/s390-32/multiarch/strcpy.c | 21 ++++++
|
|
|
147e83 |
sysdeps/s390/s390-64/multiarch/strcpy.c | 21 ++++++
|
|
|
147e83 |
11 files changed, 366 insertions(+), 3 deletions(-)
|
|
|
147e83 |
create mode 100644 benchtests/bench-wcscpy.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/strcpy-vx.S
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/strcpy.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/wcscpy-c.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/wcscpy-vx.S
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/wcscpy.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/s390-32/multiarch/strcpy.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/s390-64/multiarch/strcpy.c
|
|
|
147e83 |
|
|
|
147e83 |
diff --git a/benchtests/Makefile b/benchtests/Makefile
|
|
|
147e83 |
index 7bb2eef..1dda844 100644
|
|
|
147e83 |
--- a/benchtests/Makefile
|
|
|
147e83 |
+++ b/benchtests/Makefile
|
|
|
147e83 |
@@ -38,7 +38,7 @@ string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
|
|
|
147e83 |
strcat strchr strchrnul strcmp strcpy strcspn strlen \
|
|
|
147e83 |
strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
|
|
|
147e83 |
strspn strstr strcpy_chk stpcpy_chk memrchr strsep strtok
|
|
|
147e83 |
-wcsmbs-bench := wcslen wcsnlen
|
|
|
147e83 |
+wcsmbs-bench := wcslen wcsnlen wcscpy
|
|
|
147e83 |
string-bench-all := $(string-bench) ${wcsmbs-bench}
|
|
|
147e83 |
|
|
|
147e83 |
stdlib-bench := strtod
|
|
|
147e83 |
diff --git a/benchtests/bench-wcscpy.c b/benchtests/bench-wcscpy.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..62c5825
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/benchtests/bench-wcscpy.c
|
|
|
147e83 |
@@ -0,0 +1,20 @@
|
|
|
147e83 |
+/* Measure wcscpy functions.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#define WIDE 1
|
|
|
147e83 |
+#include "bench-strcpy.c"
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
|
|
|
147e83 |
index 3397f24..e2202b7 100644
|
|
|
147e83 |
--- a/sysdeps/s390/multiarch/Makefile
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/Makefile
|
|
|
147e83 |
@@ -1,9 +1,11 @@
|
|
|
147e83 |
ifeq ($(subdir),string)
|
|
|
147e83 |
sysdep_routines += strlen strlen-vx strlen-c \
|
|
|
147e83 |
- strnlen strnlen-vx strnlen-c
|
|
|
147e83 |
+ strnlen strnlen-vx strnlen-c \
|
|
|
147e83 |
+ strcpy strcpy-vx
|
|
|
147e83 |
endif
|
|
|
147e83 |
|
|
|
147e83 |
ifeq ($(subdir),wcsmbs)
|
|
|
147e83 |
sysdep_routines += wcslen wcslen-vx wcslen-c \
|
|
|
147e83 |
- wcsnlen wcsnlen-vx wcsnlen-c
|
|
|
147e83 |
+ wcsnlen wcsnlen-vx wcsnlen-c \
|
|
|
147e83 |
+ wcscpy wcscpy-vx wcscpy-c
|
|
|
147e83 |
endif
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
index bc17c59..c9228d6 100644
|
|
|
147e83 |
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
@@ -85,6 +85,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
147e83 |
IFUNC_VX_IMPL (strnlen);
|
|
|
147e83 |
IFUNC_VX_IMPL (wcsnlen);
|
|
|
147e83 |
|
|
|
147e83 |
+ IFUNC_VX_IMPL (strcpy);
|
|
|
147e83 |
+ IFUNC_VX_IMPL (wcscpy);
|
|
|
147e83 |
+
|
|
|
147e83 |
#endif /* HAVE_S390_VX_ASM_SUPPORT */
|
|
|
147e83 |
|
|
|
147e83 |
return i;
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/strcpy-vx.S b/sysdeps/s390/multiarch/strcpy-vx.S
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..a8243b0
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/strcpy-vx.S
|
|
|
147e83 |
@@ -0,0 +1,109 @@
|
|
|
147e83 |
+/* Vector optimized 32/64 bit S/390 version of strcpy.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
147e83 |
+
|
|
|
147e83 |
+# include "sysdep.h"
|
|
|
147e83 |
+# include "asm-syntax.h"
|
|
|
147e83 |
+
|
|
|
147e83 |
+ .text
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* char * strcpy (const char *dest, const char *src)
|
|
|
147e83 |
+ Copy string src to dest.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ Register usage:
|
|
|
147e83 |
+ -r1=tmp
|
|
|
147e83 |
+ -r2=dest and return_value
|
|
|
147e83 |
+ -r3=src
|
|
|
147e83 |
+ -r4=tmp
|
|
|
147e83 |
+ -r5=current_len
|
|
|
147e83 |
+ -v16=part of src
|
|
|
147e83 |
+ -v17=index of zero
|
|
|
147e83 |
+ -v18=part of src
|
|
|
147e83 |
+*/
|
|
|
147e83 |
+ENTRY(__strcpy_vx)
|
|
|
147e83 |
+ .machine "z13"
|
|
|
147e83 |
+ .machinemode "zarch_nohighgprs"
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vlbb %v16,0(%r3),6 /* Load s until next 4k-byte boundary. */
|
|
|
147e83 |
+ lcbb %r1,0(%r3),6 /* Get bytes to 4k-byte boundary or 16. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vfenezb %v17,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
147e83 |
+ vlgvb %r5,%v17,7 /* Load zero index or 16 if not found. */
|
|
|
147e83 |
+ clrjl %r5,%r1,.Lfound_align /* If found zero within loaded bytes,
|
|
|
147e83 |
+ copy bytes before and return. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Align s to 16 byte. */
|
|
|
147e83 |
+ risbgn %r4,%r3,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
|
|
|
147e83 |
+ lghi %r5,15 /* current_len = 15. */
|
|
|
147e83 |
+ slr %r5,%r4 /* Compute highest index to 16byte boundary. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vstl %v16,%r5,0(%r2) /* Copy loaded characters - no zero. */
|
|
|
147e83 |
+ ahi %r5,1 /* Start loop at next character. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Find zero in 16byte aligned loop. */
|
|
|
147e83 |
+.Lloop:
|
|
|
147e83 |
+ vl %v16,0(%r5,%r3) /* Load s. */
|
|
|
147e83 |
+ vfenezbs %v17,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
147e83 |
+ je .Lfound_v16_0 /* Jump away if zero was found. */
|
|
|
147e83 |
+ vl %v18,16(%r5,%r3)/* Load next part of s. */
|
|
|
147e83 |
+ vst %v16,0(%r5,%r2) /* Store previous part without zero to dst. */
|
|
|
147e83 |
+ vfenezbs %v17,%v18,%v18
|
|
|
147e83 |
+ je .Lfound_v18_16
|
|
|
147e83 |
+ vl %v16,32(%r5,%r3)
|
|
|
147e83 |
+ vst %v18,16(%r5,%r2)
|
|
|
147e83 |
+ vfenezbs %v17,%v16,%v16
|
|
|
147e83 |
+ je .Lfound_v16_32
|
|
|
147e83 |
+ vl %v18,48(%r5,%r3)
|
|
|
147e83 |
+ vst %v16,32(%r5,%r2)
|
|
|
147e83 |
+ vfenezbs %v17,%v18,%v18
|
|
|
147e83 |
+ je .Lfound_v18_48
|
|
|
147e83 |
+ vst %v18,48(%r5,%r2)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ aghi %r5,64
|
|
|
147e83 |
+ j .Lloop /* No zero found -> loop. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lfound_v16_32:
|
|
|
147e83 |
+ aghi %r5,32
|
|
|
147e83 |
+.Lfound_v16_0:
|
|
|
147e83 |
+ la %r3,0(%r5,%r2)
|
|
|
147e83 |
+ vlgvb %r4,%v17,7 /* Load byte index of zero. */
|
|
|
147e83 |
+ vstl %v16,%r4,0(%r3) /* Store characters including zero. */
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lfound_v18_48:
|
|
|
147e83 |
+ aghi %r5,32
|
|
|
147e83 |
+.Lfound_v18_16:
|
|
|
147e83 |
+ la %r3,16(%r5,%r2)
|
|
|
147e83 |
+ vlgvb %r4,%v17,7 /* Load byte index of zero. */
|
|
|
147e83 |
+ vstl %v18,%r4,0(%r3) /* Store characters including zero. */
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lfound_align:
|
|
|
147e83 |
+ vstl %v16,%r5,0(%r2) /* Copy characters including zero. */
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+END(__strcpy_vx)
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* Use mvst-strcpy-implementation as default implementation. */
|
|
|
147e83 |
+# define strcpy __strcpy_c
|
|
|
147e83 |
+# undef libc_hidden_builtin_def
|
|
|
147e83 |
+# define libc_hidden_builtin_def(name) strong_alias(__strcpy_c, __GI_strcpy)
|
|
|
147e83 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* Include mvst-strcpy-implementation in s390-32/s390-64 subdirectory. */
|
|
|
147e83 |
+#include <strcpy.S>
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/strcpy.c b/sysdeps/s390/multiarch/strcpy.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..2e00ddf
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/strcpy.c
|
|
|
147e83 |
@@ -0,0 +1,24 @@
|
|
|
147e83 |
+/* Multiple versions of strcpy.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
147e83 |
+# include <string.h>
|
|
|
147e83 |
+# include <ifunc-resolve.h>
|
|
|
147e83 |
+
|
|
|
147e83 |
+s390_vx_libc_ifunc2 (__strcpy, strcpy)
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/wcscpy-c.c b/sysdeps/s390/multiarch/wcscpy-c.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..ca219dd
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/wcscpy-c.c
|
|
|
147e83 |
@@ -0,0 +1,25 @@
|
|
|
147e83 |
+/* Default wcscpy implementation for S/390.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
147e83 |
+# define WCSCPY __wcscpy_c
|
|
|
147e83 |
+
|
|
|
147e83 |
+# include <wchar.h>
|
|
|
147e83 |
+extern __typeof (wcscpy) __wcscpy_c;
|
|
|
147e83 |
+# include <wcsmbs/wcscpy.c>
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/wcscpy-vx.S b/sysdeps/s390/multiarch/wcscpy-vx.S
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..6ec10bf
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/wcscpy-vx.S
|
|
|
147e83 |
@@ -0,0 +1,111 @@
|
|
|
147e83 |
+/* Vector optimized 32/64 bit S/390 version of wcscpy.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
147e83 |
+
|
|
|
147e83 |
+# include "sysdep.h"
|
|
|
147e83 |
+# include "asm-syntax.h"
|
|
|
147e83 |
+
|
|
|
147e83 |
+ .text
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* char * wcscpy (const wchar_t *dest, const wchar_t *src)
|
|
|
147e83 |
+ Copy string src to dest.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ Register usage:
|
|
|
147e83 |
+ -r0=border-len for switching to vector-instructions
|
|
|
147e83 |
+ -r1=tmp
|
|
|
147e83 |
+ -r2=dest and return value
|
|
|
147e83 |
+ -r3=src
|
|
|
147e83 |
+ -r4=tmp
|
|
|
147e83 |
+ -r5=current_len
|
|
|
147e83 |
+ -v16=part of src
|
|
|
147e83 |
+ -v17=index of zero
|
|
|
147e83 |
+ -v18=part of src
|
|
|
147e83 |
+*/
|
|
|
147e83 |
+ENTRY(__wcscpy_vx)
|
|
|
147e83 |
+ .machine "z13"
|
|
|
147e83 |
+ .machinemode "zarch_nohighgprs"
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vlbb %v16,0(%r3),6 /* Load s until next 4k-byte boundary. */
|
|
|
147e83 |
+ lcbb %r1,0(%r3),6 /* Get bytes to 4k-byte boundary or 16. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ tmll %r3,3 /* Test if s is 4-byte aligned? */
|
|
|
147e83 |
+ jne .Lfallback /* And use common-code variant if not. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vfenezf %v17,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
147e83 |
+ vlgvb %r5,%v17,7 /* Load zero index or 16 if not found. */
|
|
|
147e83 |
+ clrjl %r5,%r1,.Lfound_align /* If found zero within loaded bytes,
|
|
|
147e83 |
+ copy bytes before and return. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Align s to 16 byte. */
|
|
|
147e83 |
+ risbgn %r4,%r3,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
|
|
|
147e83 |
+ lghi %r5,15 /* current_len = 15. */
|
|
|
147e83 |
+ slr %r5,%r4 /* Compute highest index to 16byte boundary. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vstl %v16,%r5,0(%r2) /* Copy loaded characters - no zero. */
|
|
|
147e83 |
+ ahi %r5,1 /* Start loop at next character. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Find zero in 16byte aligned loop. */
|
|
|
147e83 |
+.Lloop:
|
|
|
147e83 |
+ vl %v16,0(%r5,%r3) /* Load s. */
|
|
|
147e83 |
+ vfenezfs %v17,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
147e83 |
+ je .Lfound_v16_0 /* Jump away if zero was found. */
|
|
|
147e83 |
+ vl %v18,16(%r5,%r3) /* Load next part of s. */
|
|
|
147e83 |
+ vst %v16,0(%r5,%r2) /* Store previous part without zero to dst. */
|
|
|
147e83 |
+ vfenezfs %v17,%v18,%v18
|
|
|
147e83 |
+ je .Lfound_v18_16
|
|
|
147e83 |
+ vl %v16,32(%r5,%r3)
|
|
|
147e83 |
+ vst %v18,16(%r5,%r2)
|
|
|
147e83 |
+ vfenezfs %v17,%v16,%v16
|
|
|
147e83 |
+ je .Lfound_v16_32
|
|
|
147e83 |
+ vl %v18,48(%r5,%r3)
|
|
|
147e83 |
+ vst %v16,32(%r5,%r2)
|
|
|
147e83 |
+ vfenezfs %v17,%v18,%v18
|
|
|
147e83 |
+ je .Lfound_v18_48
|
|
|
147e83 |
+ vst %v18,48(%r5,%r2)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ aghi %r5,64
|
|
|
147e83 |
+ j .Lloop /* No zero found -> loop. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lfound_v16_32:
|
|
|
147e83 |
+ aghi %r5,32
|
|
|
147e83 |
+.Lfound_v16_0:
|
|
|
147e83 |
+ la %r3,0(%r5,%r2)
|
|
|
147e83 |
+ vlgvb %r1,%v17,7 /* Load byte index of zero. */
|
|
|
147e83 |
+ aghi %r1,3 /* Also copy remaining bytes of zero. */
|
|
|
147e83 |
+ vstl %v16,%r1,0(%r3) /* Copy characters including zero. */
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lfound_v18_48:
|
|
|
147e83 |
+ aghi %r5,32
|
|
|
147e83 |
+.Lfound_v18_16:
|
|
|
147e83 |
+ la %r3,16(%r5,%r2)
|
|
|
147e83 |
+ vlgvb %r1,%v17,7 /* Load byte index of zero. */
|
|
|
147e83 |
+ aghi %r1,3 /* Also copy remaining bytes of zero. */
|
|
|
147e83 |
+ vstl %v18,%r1,0(%r3) /* Copy characters including zero. */
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lfound_align:
|
|
|
147e83 |
+ aghi %r5,3 /* Also copy remaining bytes of zero. */
|
|
|
147e83 |
+ vstl %v16,%r5,0(%r2) /* Copy characters including zero. */
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lfallback:
|
|
|
147e83 |
+ jg __wcscpy_c
|
|
|
147e83 |
+END(__wcscpy_vx)
|
|
|
147e83 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/wcscpy.c b/sysdeps/s390/multiarch/wcscpy.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..b3a057a
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/wcscpy.c
|
|
|
147e83 |
@@ -0,0 +1,27 @@
|
|
|
147e83 |
+/* Multiple versions of wcscpy.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
147e83 |
+# include <wchar.h>
|
|
|
147e83 |
+# include <ifunc-resolve.h>
|
|
|
147e83 |
+
|
|
|
147e83 |
+s390_vx_libc_ifunc2 (__wcscpy, wcscpy)
|
|
|
147e83 |
+
|
|
|
147e83 |
+#else
|
|
|
147e83 |
+# include <wcsmbs/wcscpy.c>
|
|
|
147e83 |
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
|
|
|
147e83 |
diff --git a/sysdeps/s390/s390-32/multiarch/strcpy.c b/sysdeps/s390/s390-32/multiarch/strcpy.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..b02c392
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/s390-32/multiarch/strcpy.c
|
|
|
147e83 |
@@ -0,0 +1,21 @@
|
|
|
147e83 |
+/* Multiple versions of strcpy.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* This wrapper-file is needed, because otherwise file
|
|
|
147e83 |
+ sysdeps/s390/s390-[32|64]/strcpy.S will be used. */
|
|
|
147e83 |
+#include <sysdeps/s390/multiarch/strcpy.c>
|
|
|
147e83 |
diff --git a/sysdeps/s390/s390-64/multiarch/strcpy.c b/sysdeps/s390/s390-64/multiarch/strcpy.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..b02c392
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/s390-64/multiarch/strcpy.c
|
|
|
147e83 |
@@ -0,0 +1,21 @@
|
|
|
147e83 |
+/* Multiple versions of strcpy.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* This wrapper-file is needed, because otherwise file
|
|
|
147e83 |
+ sysdeps/s390/s390-[32|64]/strcpy.S will be used. */
|
|
|
147e83 |
+#include <sysdeps/s390/multiarch/strcpy.c>
|
|
|
147e83 |
--
|
|
|
147e83 |
2.3.0
|
|
|
147e83 |
|