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