|
|
d8307d |
commit cdd927d98cc38acf55e1c6594b5c9451df8f239f
|
|
|
d8307d |
Author: Stefan Liebler <stli@linux.ibm.com>
|
|
|
d8307d |
Date: Tue Dec 18 13:57:08 2018 +0100
|
|
|
d8307d |
|
|
|
d8307d |
S390: Add z13 memmove ifunc variant.
|
|
|
d8307d |
|
|
|
d8307d |
This patch introduces a z13 specific ifunc variant for memmove.
|
|
|
d8307d |
As the common code implementation, it checks if we can copy from
|
|
|
d8307d |
the beginning to the end - with z196 memcpy implementation - or
|
|
|
d8307d |
if we have to copy from the end to the beginning.
|
|
|
d8307d |
The latter case is done by using vector load/store instructions.
|
|
|
d8307d |
|
|
|
d8307d |
If vector instructions are not available, the common-code is
|
|
|
d8307d |
used as fallback. Therefore it is implemented in memmove-c with
|
|
|
d8307d |
a different name.
|
|
|
d8307d |
Furthermore the ifunc logic decides if we need the common-code
|
|
|
d8307d |
implementation at all. If vector instructions are supported
|
|
|
d8307d |
due to the minimum architecture level set we can skip the
|
|
|
d8307d |
common-code ifunc variant.
|
|
|
d8307d |
|
|
|
d8307d |
ChangeLog:
|
|
|
d8307d |
|
|
|
d8307d |
* sysdeps/s390/Makefile (sysdep_routines): Add memmove-c.
|
|
|
d8307d |
* sysdeps/s390/ifunc-memcpy.h (HAVE_MEMMOVE_IFUNC,
|
|
|
d8307d |
HAVE_MEMMOVE_IFUNC_AND_VX_SUPPORT, MEMMOVE_DEFAULT,
|
|
|
d8307d |
HAVE_MEMMOVE_C, MEMMOVE_C, HAVE_MEMMOVE_Z13, MEMMOVE_Z13):
|
|
|
d8307d |
New defines.
|
|
|
d8307d |
* sysdeps/s390/memcpy-z900.S: Add z13 memmove implementation.
|
|
|
d8307d |
* sysdeps/s390/memmove-c.c: New file.
|
|
|
d8307d |
* sysdeps/s390/memmove.c: Likewise.
|
|
|
d8307d |
* sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
d8307d |
(__libc_ifunc_impl_list): Add ifunc variants for memmove.
|
|
|
d8307d |
|
|
|
d8307d |
diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile
|
|
|
d8307d |
index 838950a5ab958e31..3a7cccdf8f147398 100644
|
|
|
d8307d |
--- a/sysdeps/s390/Makefile
|
|
|
d8307d |
+++ b/sysdeps/s390/Makefile
|
|
|
d8307d |
@@ -33,5 +33,6 @@ endif
|
|
|
d8307d |
ifeq ($(subdir),string)
|
|
|
d8307d |
sysdep_routines += bzero memset memset-z900 \
|
|
|
d8307d |
memcmp memcmp-z900 \
|
|
|
d8307d |
- mempcpy memcpy memcpy-z900
|
|
|
d8307d |
+ mempcpy memcpy memcpy-z900 \
|
|
|
d8307d |
+ memmove memmove-c
|
|
|
d8307d |
endif
|
|
|
d8307d |
diff --git a/sysdeps/s390/ifunc-memcpy.h b/sysdeps/s390/ifunc-memcpy.h
|
|
|
d8307d |
index 51c71baa2c0b0452..0e701968c8f39014 100644
|
|
|
d8307d |
--- a/sysdeps/s390/ifunc-memcpy.h
|
|
|
d8307d |
+++ b/sysdeps/s390/ifunc-memcpy.h
|
|
|
d8307d |
@@ -43,6 +43,29 @@
|
|
|
d8307d |
# define HAVE_MEMCPY_Z196 HAVE_MEMCPY_IFUNC
|
|
|
d8307d |
#endif
|
|
|
d8307d |
|
|
|
d8307d |
+#if defined SHARED && defined USE_MULTIARCH && IS_IN (libc) \
|
|
|
d8307d |
+ && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT
|
|
|
d8307d |
+# define HAVE_MEMMOVE_IFUNC 1
|
|
|
d8307d |
+#else
|
|
|
d8307d |
+# define HAVE_MEMMOVE_IFUNC 0
|
|
|
d8307d |
+#endif
|
|
|
d8307d |
+
|
|
|
d8307d |
+#ifdef HAVE_S390_VX_ASM_SUPPORT
|
|
|
d8307d |
+# define HAVE_MEMMOVE_IFUNC_AND_VX_SUPPORT HAVE_MEMMOVE_IFUNC
|
|
|
d8307d |
+#else
|
|
|
d8307d |
+# define HAVE_MEMMOVE_IFUNC_AND_VX_SUPPORT 0
|
|
|
d8307d |
+#endif
|
|
|
d8307d |
+
|
|
|
d8307d |
+#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT
|
|
|
d8307d |
+# define MEMMOVE_DEFAULT MEMMOVE_Z13
|
|
|
d8307d |
+# define HAVE_MEMMOVE_C 0
|
|
|
d8307d |
+# define HAVE_MEMMOVE_Z13 1
|
|
|
d8307d |
+#else
|
|
|
d8307d |
+# define MEMMOVE_DEFAULT MEMMOVE_C
|
|
|
d8307d |
+# define HAVE_MEMMOVE_C 1
|
|
|
d8307d |
+# define HAVE_MEMMOVE_Z13 HAVE_MEMMOVE_IFUNC_AND_VX_SUPPORT
|
|
|
d8307d |
+#endif
|
|
|
d8307d |
+
|
|
|
d8307d |
#if HAVE_MEMCPY_Z900_G5
|
|
|
d8307d |
# define MEMCPY_Z900_G5 __memcpy_default
|
|
|
d8307d |
# define MEMPCPY_Z900_G5 __mempcpy_default
|
|
|
d8307d |
@@ -66,3 +89,15 @@
|
|
|
d8307d |
# define MEMCPY_Z196 NULL
|
|
|
d8307d |
# define MEMPCPY_Z196 NULL
|
|
|
d8307d |
#endif
|
|
|
d8307d |
+
|
|
|
d8307d |
+#if HAVE_MEMMOVE_C
|
|
|
d8307d |
+# define MEMMOVE_C __memmove_c
|
|
|
d8307d |
+#else
|
|
|
d8307d |
+# define MEMMOVE_C NULL
|
|
|
d8307d |
+#endif
|
|
|
d8307d |
+
|
|
|
d8307d |
+#if HAVE_MEMMOVE_Z13
|
|
|
d8307d |
+# define MEMMOVE_Z13 __memmove_z13
|
|
|
d8307d |
+#else
|
|
|
d8307d |
+# define MEMMOVE_Z13 NULL
|
|
|
d8307d |
+#endif
|
|
|
d8307d |
diff --git a/sysdeps/s390/memcpy-z900.S b/sysdeps/s390/memcpy-z900.S
|
|
|
d8307d |
index 3a50cf44d85d2417..bd3b1950ee442c0c 100644
|
|
|
d8307d |
--- a/sysdeps/s390/memcpy-z900.S
|
|
|
d8307d |
+++ b/sysdeps/s390/memcpy-z900.S
|
|
|
d8307d |
@@ -182,6 +182,7 @@ ENTRY(MEMCPY_Z196)
|
|
|
d8307d |
# endif /* !defined __s390x__ */
|
|
|
d8307d |
ltgr %r4,%r4
|
|
|
d8307d |
je .L_Z196_4
|
|
|
d8307d |
+.L_Z196_start2:
|
|
|
d8307d |
aghi %r4,-1
|
|
|
d8307d |
srlg %r5,%r4,8
|
|
|
d8307d |
ltgr %r5,%r5
|
|
|
d8307d |
@@ -207,6 +208,75 @@ ENTRY(MEMCPY_Z196)
|
|
|
d8307d |
END(MEMCPY_Z196)
|
|
|
d8307d |
#endif /* HAVE_MEMCPY_Z196 */
|
|
|
d8307d |
|
|
|
d8307d |
+#if HAVE_MEMMOVE_Z13
|
|
|
d8307d |
+ENTRY(MEMMOVE_Z13)
|
|
|
d8307d |
+ .machine "z13"
|
|
|
d8307d |
+ .machinemode "zarch_nohighgprs"
|
|
|
d8307d |
+# if !defined __s390x__
|
|
|
d8307d |
+ /* Note: The 31bit dst and src pointers are prefixed with zeroes. */
|
|
|
d8307d |
+ llgfr %r4,%r4
|
|
|
d8307d |
+ llgfr %r3,%r3
|
|
|
d8307d |
+ llgfr %r2,%r2
|
|
|
d8307d |
+# endif /* !defined __s390x__ */
|
|
|
d8307d |
+ sgrk %r0,%r2,%r3
|
|
|
d8307d |
+ clgijh %r4,16,.L_MEMMOVE_Z13_LARGE
|
|
|
d8307d |
+ aghik %r5,%r4,-1
|
|
|
d8307d |
+.L_MEMMOVE_Z13_SMALL:
|
|
|
d8307d |
+ jl .L_MEMMOVE_Z13_END /* Jump away if len was zero. */
|
|
|
d8307d |
+ /* Store up to 16 bytes with vll/vstl which needs the index
|
|
|
d8307d |
+ instead of lengths. */
|
|
|
d8307d |
+ vll %v16,%r5,0(%r3)
|
|
|
d8307d |
+ vstl %v16,%r5,0(%r2)
|
|
|
d8307d |
+.L_MEMMOVE_Z13_END:
|
|
|
d8307d |
+ br %r14
|
|
|
d8307d |
+.L_MEMMOVE_Z13_LARGE:
|
|
|
d8307d |
+ lgr %r1,%r2 /* For memcpy: r1: Use as dest ;
|
|
|
d8307d |
+ r2: Return dest */
|
|
|
d8307d |
+ /* The unsigned comparison (dst - src >= len) determines if we can
|
|
|
d8307d |
+ execute the forward case with memcpy. */
|
|
|
d8307d |
+#if ! HAVE_MEMCPY_Z196
|
|
|
d8307d |
+# error The z13 variant of memmove needs the z196 variant of memcpy!
|
|
|
d8307d |
+#endif
|
|
|
d8307d |
+ clgrjhe %r0,%r4,.L_Z196_start2
|
|
|
d8307d |
+ risbgn %r5,%r4,4,128+63,60 /* r5 = r4 / 16 */
|
|
|
d8307d |
+ aghi %r4,-16
|
|
|
d8307d |
+ clgijhe %r5,8,.L_MEMMOVE_Z13_LARGE_64B
|
|
|
d8307d |
+.L_MEMMOVE_Z13_LARGE_16B_LOOP:
|
|
|
d8307d |
+ /* Store at least 16 bytes with vl/vst. The number of 16byte blocks
|
|
|
d8307d |
+ is stored in r5. */
|
|
|
d8307d |
+ vl %v16,0(%r4,%r3)
|
|
|
d8307d |
+ vst %v16,0(%r4,%r2)
|
|
|
d8307d |
+ aghi %r4,-16
|
|
|
d8307d |
+ brctg %r5,.L_MEMMOVE_Z13_LARGE_16B_LOOP
|
|
|
d8307d |
+ aghik %r5,%r4,15
|
|
|
d8307d |
+ j .L_MEMMOVE_Z13_SMALL
|
|
|
d8307d |
+.L_MEMMOVE_Z13_LARGE_64B:
|
|
|
d8307d |
+ /* Store at least 128 bytes with 4x vl/vst. The number of 64byte blocks
|
|
|
d8307d |
+ will be stored in r0. */
|
|
|
d8307d |
+ aghi %r4,-48
|
|
|
d8307d |
+ srlg %r0,%r5,2 /* r5 = %r0 / 4
|
|
|
d8307d |
+ => Number of 64byte blocks. */
|
|
|
d8307d |
+.L_MEMMOVE_Z13_LARGE_64B_LOOP:
|
|
|
d8307d |
+ vl %v20,48(%r4,%r3)
|
|
|
d8307d |
+ vl %v19,32(%r4,%r3)
|
|
|
d8307d |
+ vl %v18,16(%r4,%r3)
|
|
|
d8307d |
+ vl %v17,0(%r4,%r3)
|
|
|
d8307d |
+ vst %v20,48(%r4,%r2)
|
|
|
d8307d |
+ vst %v19,32(%r4,%r2)
|
|
|
d8307d |
+ vst %v18,16(%r4,%r2)
|
|
|
d8307d |
+ vst %v17,0(%r4,%r2)
|
|
|
d8307d |
+ aghi %r4,-64
|
|
|
d8307d |
+ brctg %r0,.L_MEMMOVE_Z13_LARGE_64B_LOOP
|
|
|
d8307d |
+ aghi %r4,48
|
|
|
d8307d |
+ /* Recalculate the number of 16byte blocks. */
|
|
|
d8307d |
+ risbg %r5,%r5,62,128+63,0 /* r5 = r5 & 3
|
|
|
d8307d |
+ => Remaining 16byte blocks. */
|
|
|
d8307d |
+ jne .L_MEMMOVE_Z13_LARGE_16B_LOOP
|
|
|
d8307d |
+ aghik %r5,%r4,15
|
|
|
d8307d |
+ j .L_MEMMOVE_Z13_SMALL
|
|
|
d8307d |
+END(MEMMOVE_Z13)
|
|
|
d8307d |
+#endif /* HAVE_MEMMOVE_Z13 */
|
|
|
d8307d |
+
|
|
|
d8307d |
#if ! HAVE_MEMCPY_IFUNC
|
|
|
d8307d |
/* If we don't use ifunc, define an alias for mem[p]cpy here.
|
|
|
d8307d |
Otherwise see sysdeps/s390/mem[p]cpy.c. */
|
|
|
d8307d |
@@ -215,10 +285,27 @@ strong_alias (MEMPCPY_DEFAULT, __mempcpy)
|
|
|
d8307d |
weak_alias (__mempcpy, mempcpy)
|
|
|
d8307d |
#endif
|
|
|
d8307d |
|
|
|
d8307d |
+#if ! HAVE_MEMMOVE_IFUNC
|
|
|
d8307d |
+/* If we don't use ifunc, define an alias for memmove here.
|
|
|
d8307d |
+ Otherwise see sysdeps/s390/memmove.c. */
|
|
|
d8307d |
+# if ! HAVE_MEMMOVE_C
|
|
|
d8307d |
+/* If the c variant is needed, then sysdeps/s390/memmove-c.c
|
|
|
d8307d |
+ defines memmove.
|
|
|
d8307d |
+ Otherwise MEMMOVE_DEFAULT is implemented here and we have to define it. */
|
|
|
d8307d |
+strong_alias (MEMMOVE_DEFAULT, memmove)
|
|
|
d8307d |
+# endif
|
|
|
d8307d |
+#endif
|
|
|
d8307d |
+
|
|
|
d8307d |
#if defined SHARED && IS_IN (libc)
|
|
|
d8307d |
/* Defines the internal symbols.
|
|
|
d8307d |
Compare to libc_hidden_[builtin_]def (mem[p]cpy) in string/mem[p]cpy.c. */
|
|
|
d8307d |
strong_alias (MEMCPY_DEFAULT, __GI_memcpy)
|
|
|
d8307d |
strong_alias (MEMPCPY_DEFAULT, __GI_mempcpy)
|
|
|
d8307d |
strong_alias (MEMPCPY_DEFAULT, __GI___mempcpy)
|
|
|
d8307d |
+# if ! HAVE_MEMMOVE_C
|
|
|
d8307d |
+/* If the c variant is needed, then sysdeps/s390/memmove-c.c
|
|
|
d8307d |
+ defines the internal symbol.
|
|
|
d8307d |
+ Otherwise MEMMOVE_DEFAULT is implemented here and we have to define it. */
|
|
|
d8307d |
+strong_alias (MEMMOVE_DEFAULT, __GI_memmove)
|
|
|
d8307d |
+# endif
|
|
|
d8307d |
#endif
|
|
|
d8307d |
diff --git a/sysdeps/s390/memmove-c.c b/sysdeps/s390/memmove-c.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000000000..be571093e019a38d
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/s390/memmove-c.c
|
|
|
d8307d |
@@ -0,0 +1,37 @@
|
|
|
d8307d |
+/* Fallback C version of memmove.
|
|
|
d8307d |
+ Copyright (C) 2018 Free Software Foundation, Inc.
|
|
|
d8307d |
+ This file is part of the GNU C Library.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
d8307d |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
d8307d |
+ License as published by the Free Software Foundation; either
|
|
|
d8307d |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
d8307d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
d8307d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
d8307d |
+ Lesser General Public License for more details.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
d8307d |
+ License along with the GNU C Library; if not, see
|
|
|
d8307d |
+ <http://www.gnu.org/licenses/>. */
|
|
|
d8307d |
+
|
|
|
d8307d |
+#include <ifunc-memcpy.h>
|
|
|
d8307d |
+
|
|
|
d8307d |
+#if HAVE_MEMMOVE_C
|
|
|
d8307d |
+# if HAVE_MEMMOVE_IFUNC
|
|
|
d8307d |
+/* If we use ifunc, then the memmove symbol is defined
|
|
|
d8307d |
+ in sysdeps/s390/memmove.c and we use a different name here.
|
|
|
d8307d |
+ Otherwise, we have to define memmove here or in
|
|
|
d8307d |
+ sysdeps/s390/memcpy.S depending on the used default implementation. */
|
|
|
d8307d |
+# define MEMMOVE MEMMOVE_C
|
|
|
d8307d |
+# if defined SHARED && IS_IN (libc)
|
|
|
d8307d |
+/* Define the internal symbol. */
|
|
|
d8307d |
+# undef libc_hidden_builtin_def
|
|
|
d8307d |
+# define libc_hidden_builtin_def(name) \
|
|
|
d8307d |
+ __hidden_ver1 (__memmove_c, __GI_memmove, __memmove_c);
|
|
|
d8307d |
+# endif
|
|
|
d8307d |
+# endif
|
|
|
d8307d |
+
|
|
|
d8307d |
+# include <string/memmove.c>
|
|
|
d8307d |
+#endif
|
|
|
d8307d |
diff --git a/sysdeps/s390/memmove.c b/sysdeps/s390/memmove.c
|
|
|
d8307d |
new file mode 100644
|
|
|
d8307d |
index 0000000000000000..ac34edf80f2678cd
|
|
|
d8307d |
--- /dev/null
|
|
|
d8307d |
+++ b/sysdeps/s390/memmove.c
|
|
|
d8307d |
@@ -0,0 +1,44 @@
|
|
|
d8307d |
+/* Multiple versions of memmove.
|
|
|
d8307d |
+ Copyright (C) 2016-2018 Free Software Foundation, Inc.
|
|
|
d8307d |
+ This file is part of the GNU C Library.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
d8307d |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
d8307d |
+ License as published by the Free Software Foundation; either
|
|
|
d8307d |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
d8307d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
d8307d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
d8307d |
+ Lesser General Public License for more details.
|
|
|
d8307d |
+
|
|
|
d8307d |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
d8307d |
+ License along with the GNU C Library; if not, see
|
|
|
d8307d |
+ <http://www.gnu.org/licenses/>. */
|
|
|
d8307d |
+
|
|
|
d8307d |
+#include <ifunc-memcpy.h>
|
|
|
d8307d |
+
|
|
|
d8307d |
+#if HAVE_MEMMOVE_IFUNC
|
|
|
d8307d |
+/* If we don't use ifunc, an alias is defined for memmove
|
|
|
d8307d |
+ in sysdeps/s390/memmove-c.c or sysdeps/s390/memcpy.S
|
|
|
d8307d |
+ depending on the used default implementation. */
|
|
|
d8307d |
+# undef memmove
|
|
|
d8307d |
+# define memmove __redirect_memmove
|
|
|
d8307d |
+# include <string.h>
|
|
|
d8307d |
+# include <ifunc-resolve.h>
|
|
|
d8307d |
+# undef memmove
|
|
|
d8307d |
+
|
|
|
d8307d |
+# if HAVE_MEMMOVE_C
|
|
|
d8307d |
+extern __typeof (__redirect_memmove) MEMMOVE_C attribute_hidden;
|
|
|
d8307d |
+# endif
|
|
|
d8307d |
+
|
|
|
d8307d |
+# if HAVE_MEMMOVE_Z13
|
|
|
d8307d |
+extern __typeof (__redirect_memmove) MEMMOVE_Z13 attribute_hidden;
|
|
|
d8307d |
+# endif
|
|
|
d8307d |
+
|
|
|
d8307d |
+s390_libc_ifunc_expr (__redirect_memmove, memmove,
|
|
|
d8307d |
+ (HAVE_MEMMOVE_Z13 && (hwcap & HWCAP_S390_VX))
|
|
|
d8307d |
+ ? MEMMOVE_Z13
|
|
|
d8307d |
+ : MEMMOVE_DEFAULT
|
|
|
d8307d |
+ )
|
|
|
d8307d |
+#endif
|
|
|
d8307d |
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
d8307d |
index 6969c480cc40e0e2..c05c63e00608dcd7 100644
|
|
|
d8307d |
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
d8307d |
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
d8307d |
@@ -126,6 +126,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
d8307d |
)
|
|
|
d8307d |
#endif /* HAVE_MEMCPY_IFUNC */
|
|
|
d8307d |
|
|
|
d8307d |
+#if HAVE_MEMMOVE_IFUNC
|
|
|
d8307d |
+ IFUNC_IMPL (i, name, memmove,
|
|
|
d8307d |
+# if HAVE_MEMMOVE_Z13
|
|
|
d8307d |
+ IFUNC_IMPL_ADD (array, i, memmove,
|
|
|
d8307d |
+ dl_hwcap & HWCAP_S390_VX, MEMMOVE_Z13)
|
|
|
d8307d |
+# endif
|
|
|
d8307d |
+# if HAVE_MEMMOVE_C
|
|
|
d8307d |
+ IFUNC_IMPL_ADD (array, i, memmove, 1, MEMMOVE_C)
|
|
|
d8307d |
+# endif
|
|
|
d8307d |
+ )
|
|
|
d8307d |
+#endif /* HAVE_MEMMOVE_IFUNC */
|
|
|
d8307d |
+
|
|
|
d8307d |
#ifdef HAVE_S390_VX_ASM_SUPPORT
|
|
|
d8307d |
|
|
|
d8307d |
# define IFUNC_VX_IMPL(FUNC) \
|