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