diff options
-rw-r--r-- | sysdeps/i386/i686/multiarch/Makefile | 3 | ||||
-rw-r--r-- | sysdeps/i386/i686/multiarch/ifunc-impl-list.c | 4 | ||||
-rw-r--r-- | sysdeps/i386/i686/multiarch/stpcpy-i386.S | 31 | ||||
-rw-r--r-- | sysdeps/i386/i686/multiarch/stpcpy-stosb.S | 23 | ||||
-rw-r--r-- | sysdeps/i386/i686/multiarch/strcpy-i386.S | 25 | ||||
-rw-r--r-- | sysdeps/i386/i686/multiarch/strcpy-stosb.S | 66 |
6 files changed, 151 insertions, 1 deletions
diff --git a/sysdeps/i386/i686/multiarch/Makefile b/sysdeps/i386/i686/multiarch/Makefile index bf75a9947f..52e0e73a2d 100644 --- a/sysdeps/i386/i686/multiarch/Makefile +++ b/sysdeps/i386/i686/multiarch/Makefile @@ -30,7 +30,8 @@ sysdep_routines += bzero-sse2 memset-sse2 memcpy-ssse3 mempcpy-ssse3 \ mempcpy-ia32 memset-ia32 strcat-ia32 strchr-ia32 \ strrchr-ia32 strcpy-ia32 strcmp-ia32 strcspn-ia32 \ strpbrk-ia32 strspn-ia32 strlen-ia32 stpcpy-ia32 \ - stpncpy-ia32 + stpncpy-ia32 \ + stpcpy-i386 strcpy-i386 stpcpy-stosb strcpy-stosb CFLAGS-varshift.c += -msse4 CFLAGS-strcspn-c.c += -msse4 CFLAGS-strpbrk-c.c += -msse4 diff --git a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c index 6e20cffb04..0d8169147f 100644 --- a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c +++ b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c @@ -147,6 +147,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __stpcpy_ssse3) IFUNC_IMPL_ADD (array, i, stpcpy, HAS_CPU_FEATURE (SSE2), __stpcpy_sse2) + IFUNC_IMPL_ADD (array, i, stpcpy, 1, __stpcpy_i386) + IFUNC_IMPL_ADD (array, i, stpcpy, 1, __stpcpy_stosb) IFUNC_IMPL_ADD (array, i, stpcpy, 1, __stpcpy_ia32)) /* Support sysdeps/i386/i686/multiarch/strcasecmp.S. */ @@ -200,6 +202,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __strcpy_ssse3) IFUNC_IMPL_ADD (array, i, strcpy, HAS_CPU_FEATURE (SSE2), __strcpy_sse2) + IFUNC_IMPL_ADD (array, i, strcpy, 1, __strcpy_i386) + IFUNC_IMPL_ADD (array, i, strcpy, 1, __strcpy_stosb) IFUNC_IMPL_ADD (array, i, strcpy, 1, __strcpy_ia32)) /* Support sysdeps/i386/i686/multiarch/strcspn.S. */ diff --git a/sysdeps/i386/i686/multiarch/stpcpy-i386.S b/sysdeps/i386/i686/multiarch/stpcpy-i386.S new file mode 100644 index 0000000000..2a25959375 --- /dev/null +++ b/sysdeps/i386/i686/multiarch/stpcpy-i386.S @@ -0,0 +1,31 @@ +/* stpcpy optimized for i386. + All versions must be listed in ifunc-impl-list.c. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#define __stpcpy __stpcpy_i386 + +#undef libc_hidden_def +#define libc_hidden_def(ignored) + +#undef libc_hidden_builtin_def +#define libc_hidden_builtin_def(ignored) + +#undef weak_alias +#define weak_alias(original, alias) + +#include <sysdeps/i386/stpcpy.S> diff --git a/sysdeps/i386/i686/multiarch/stpcpy-stosb.S b/sysdeps/i386/i686/multiarch/stpcpy-stosb.S new file mode 100644 index 0000000000..2063ff89da --- /dev/null +++ b/sysdeps/i386/i686/multiarch/stpcpy-stosb.S @@ -0,0 +1,23 @@ +/* stpcpy optimized with stosb. + All versions must be listed in ifunc-impl-list.c. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#define USE_AS_STPCPY +#define STRCPY __stpcpy_stosb + +#include <sysdeps/i386/i686/multiarch/strcpy-stosb.S> diff --git a/sysdeps/i386/i686/multiarch/strcpy-i386.S b/sysdeps/i386/i686/multiarch/strcpy-i386.S new file mode 100644 index 0000000000..3c0b1d902d --- /dev/null +++ b/sysdeps/i386/i686/multiarch/strcpy-i386.S @@ -0,0 +1,25 @@ +/* strcpy optimized for i386. + All versions must be listed in ifunc-impl-list.c. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#define strcpy __strcpy_i386 + +#undef libc_hidden_builtin_def +#define libc_hidden_builtin_def(ignored) + +#include <sysdeps/i386/strcpy.S> diff --git a/sysdeps/i386/i686/multiarch/strcpy-stosb.S b/sysdeps/i386/i686/multiarch/strcpy-stosb.S new file mode 100644 index 0000000000..36e4412fad --- /dev/null +++ b/sysdeps/i386/i686/multiarch/strcpy-stosb.S @@ -0,0 +1,66 @@ +/* strcpy/strcpy optimized with stosb. + All versions must be listed in ifunc-impl-list.c. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> + +#define PARMS 4+8 /* space for 2 saved regs */ +#define DEST PARMS +#define SRC DEST+4 + +#ifndef USE_AS_STPCPY +# define STRCPY __strcpy_stosb +#endif + + .text +ENTRY (STRCPY) + pushl %edi + cfi_adjust_cfa_offset (4) + cfi_rel_offset (%edi, 4) + pushl %esi + cfi_adjust_cfa_offset (4) + cfi_rel_offset (%esi, 0) + + movl DEST(%esp), %edi + movl SRC(%esp), %esi + +#ifndef USE_AS_STPCPY + movl %edi, %edx +#endif + +L(repeat): + lodsb + stosb + testb %al,%al + jne L(repeat) + +#ifdef USE_AS_STPCPY + leal -1(%edi), %eax +#else + movl %edx, %eax +#endif + + popl %esi + cfi_adjust_cfa_offset (-4) + cfi_restore (%esi) + popl %edi + cfi_adjust_cfa_offset (-4) + cfi_restore (%edi) + + ret +END (STRCPY) |