From patchwork Tue Jun 12 22:19:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 27765 Received: (qmail 92417 invoked by alias); 12 Jun 2018 22:19:54 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 92218 invoked by uid 89); 12 Jun 2018 22:19:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, KAM_STOCKGEN, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy= X-HELO: mga01.intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH 08/20] libcpu-rt-c/x86-64: Add memset and wmemset Date: Tue, 12 Jun 2018 15:19:27 -0700 Message-Id: <20180612221939.19545-9-hjl.tools@gmail.com> In-Reply-To: <20180612221939.19545-1-hjl.tools@gmail.com> References: <20180612221939.19545-1-hjl.tools@gmail.com> * sysdeps/x86_64/Makefile (cpu-rt-c-routines): Add memset and wmemset. * sysdeps/x86_64/memset.S: Support libcpu-rt-c. * sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms.S: Likewise. * sysdeps/x86_64/multiarch/memset-avx512-no-vzeroupper.S: Likewise. * sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S: Likewise. * sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S: Likewise. * sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S: Likewise. * sysdeps/x86_64/multiarch/memset.c: Likewise. * sysdeps/x86_64/multiarch/wmemset.c: Likewise. * sysdeps/x86_64/multiarch/Makefile (libcpu-rt-c-sysdep_routines): Add memset-sse2-unaligned-erms, memset-avx2-unaligned-erms, memset-avx512-unaligned-erms and memset-avx512-no-vzeroupper. --- sysdeps/x86_64/Makefile | 6 ++++-- sysdeps/x86_64/memset.S | 6 +++++- sysdeps/x86_64/multiarch/Makefile | 6 +++++- .../multiarch/memset-avx2-unaligned-erms.S | 2 +- .../multiarch/memset-avx512-no-vzeroupper.S | 4 ++-- .../multiarch/memset-avx512-unaligned-erms.S | 2 +- .../multiarch/memset-sse2-unaligned-erms.S | 8 +++++--- .../multiarch/memset-vec-unaligned-erms.S | 17 ++++++++++++----- sysdeps/x86_64/multiarch/memset.c | 4 ++-- sysdeps/x86_64/multiarch/wmemset.c | 10 ++++++++-- 10 files changed, 45 insertions(+), 20 deletions(-) diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile index da3264f27f..d5e4912074 100644 --- a/sysdeps/x86_64/Makefile +++ b/sysdeps/x86_64/Makefile @@ -147,10 +147,12 @@ endif endif ifeq ($(subdir),cpu-rt-c) -cpu-rt-c-routines += memchr memcmp memcpy memmove mempcpy memrchr +cpu-rt-c-routines += memchr memcmp memcpy memmove mempcpy memrchr \ + memset \ + wmemset # For the CPU run-time tests. -vpath %.c $(..)string +vpath %.c $(..)string $(..)wcsmbs endif ifeq ($(subdir),csu) diff --git a/sysdeps/x86_64/memset.S b/sysdeps/x86_64/memset.S index b342679576..4036de674d 100644 --- a/sysdeps/x86_64/memset.S +++ b/sysdeps/x86_64/memset.S @@ -47,7 +47,11 @@ #ifndef WMEMSET_SYMBOL # define WMEMSET_CHK_SYMBOL(p,s) p -# define WMEMSET_SYMBOL(p,s) __wmemset +# if IS_IN (libcpu_rt_c) +# define WMEMSET_SYMBOL(p,s) wmemset +# else +# define WMEMSET_SYMBOL(p,s) __wmemset +# endif #endif #include "multiarch/memset-vec-unaligned-erms.S" diff --git a/sysdeps/x86_64/multiarch/Makefile b/sysdeps/x86_64/multiarch/Makefile index 582ca629d0..9262251b2c 100644 --- a/sysdeps/x86_64/multiarch/Makefile +++ b/sysdeps/x86_64/multiarch/Makefile @@ -76,5 +76,9 @@ libcpu-rt-c-sysdep_routines += memchr-sse2 memchr-avx2 \ memmove-avx-unaligned-erms \ memmove-avx512-unaligned-erms \ memmove-avx512-no-vzeroupper \ - memrchr-sse2 memrchr-avx2 + memrchr-sse2 memrchr-avx2 \ + memset-sse2-unaligned-erms \ + memset-avx2-unaligned-erms \ + memset-avx512-unaligned-erms \ + memset-avx512-no-vzeroupper endif diff --git a/sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms.S b/sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms.S index 7ab3d89849..3943970235 100644 --- a/sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms.S +++ b/sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms.S @@ -1,4 +1,4 @@ -#if IS_IN (libc) +#if IS_IN (libc) || IS_IN (libcpu_rt_c) # define VEC_SIZE 32 # define VEC(i) ymm##i # define VMOVU vmovdqu diff --git a/sysdeps/x86_64/multiarch/memset-avx512-no-vzeroupper.S b/sysdeps/x86_64/multiarch/memset-avx512-no-vzeroupper.S index 689cc1199c..d1bf841c56 100644 --- a/sysdeps/x86_64/multiarch/memset-avx512-no-vzeroupper.S +++ b/sysdeps/x86_64/multiarch/memset-avx512-no-vzeroupper.S @@ -18,7 +18,7 @@ #include -#if IS_IN (libc) +#if IS_IN (libc) || IS_IN (libcpu_rt_c) #include "asm-syntax.h" #ifndef MEMSET @@ -27,7 +27,7 @@ #endif .section .text.avx512,"ax",@progbits -#if defined PIC +#if defined PIC && IS_IN (libc) ENTRY (MEMSET_CHK) cmpq %rdx, %rcx jb HIDDEN_JUMPTARGET (__chk_fail) diff --git a/sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S b/sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S index 0783979ca5..dcddf27573 100644 --- a/sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S +++ b/sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S @@ -1,4 +1,4 @@ -#if IS_IN (libc) +#if IS_IN (libc) || IS_IN (libcpu_rt_c) # define VEC_SIZE 64 # define VEC(i) zmm##i # define VMOVU vmovdqu64 diff --git a/sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S b/sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S index be6671759b..359cfb63e3 100644 --- a/sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S +++ b/sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S @@ -21,7 +21,7 @@ #include #include -#if IS_IN (libc) +#if IS_IN (libc) || IS_IN (libcpu_rt_c) # define MEMSET_SYMBOL(p,s) p##_sse2_##s # define WMEMSET_SYMBOL(p,s) p##_sse2_##s @@ -30,9 +30,11 @@ # define libc_hidden_builtin_def(name) # endif -# undef weak_alias -# define weak_alias(original, alias) \ +# if !IS_IN (libcpu_rt_c) +# undef weak_alias +# define weak_alias(original, alias) \ .weak bzero; bzero = __bzero +# endif # undef strong_alias # define strong_alias(ignored1, ignored2) diff --git a/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S index dc9cb88b37..08a831aad2 100644 --- a/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S +++ b/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S @@ -73,18 +73,23 @@ #endif .section SECTION(.text),"ax",@progbits -#if VEC_SIZE == 16 && IS_IN (libc) +#if VEC_SIZE == 16 && (IS_IN (libc) || IS_IN (libcpu_rt_c)) +# if IS_IN (libcpu_rt_c) +# define __bzero bzero +# endif ENTRY (__bzero) movq %rdi, %rax /* Set return value. */ movq %rsi, %rdx /* Set n. */ pxor %xmm0, %xmm0 jmp L(entry_from_bzero) END (__bzero) +# if !IS_IN (libcpu_rt_c) weak_alias (__bzero, bzero) +# endif #endif -#if IS_IN (libc) -# if defined SHARED +#if IS_IN (libc) || IS_IN (libcpu_rt_c) +# if defined SHARED && IS_IN (libc) ENTRY_CHK (WMEMSET_CHK_SYMBOL (__wmemset_chk, unaligned)) cmpq %rdx, %rcx jb HIDDEN_JUMPTARGET (__chk_fail) @@ -117,14 +122,16 @@ L(entry_from_bzero): VMOVU %VEC(0), (%rdi) VZEROUPPER ret -#if defined USE_MULTIARCH && IS_IN (libc) +#if defined USE_MULTIARCH && (IS_IN (libc) || IS_IN (libcpu_rt_c)) END (MEMSET_SYMBOL (__memset, unaligned)) -# if VEC_SIZE == 16 +# if VEC_SIZE == 16 && (IS_IN (libc) || IS_IN (libcpu_rt_c)) +# if IS_IN (libc) ENTRY (__memset_chk_erms) cmpq %rdx, %rcx jb HIDDEN_JUMPTARGET (__chk_fail) END (__memset_chk_erms) +# endif /* Only used to measure performance of REP STOSB. */ ENTRY (__memset_erms) diff --git a/sysdeps/x86_64/multiarch/memset.c b/sysdeps/x86_64/multiarch/memset.c index 064841d5fc..8a17a76006 100644 --- a/sysdeps/x86_64/multiarch/memset.c +++ b/sysdeps/x86_64/multiarch/memset.c @@ -18,7 +18,7 @@ . */ /* Define multiple versions only for the definition in libc. */ -#if IS_IN (libc) +#if IS_IN (libc) || IS_IN (libcpu_rt_c) # define memset __redirect_memset # include # undef memset @@ -28,7 +28,7 @@ libc_ifunc_redirected (__redirect_memset, memset, IFUNC_SELECTOR ()); -# ifdef SHARED +# if defined SHARED && !IS_IN (libcpu_rt_c) __hidden_ver1 (memset, __GI_memset, __redirect_memset) __attribute__ ((visibility ("hidden"))); # endif diff --git a/sysdeps/x86_64/multiarch/wmemset.c b/sysdeps/x86_64/multiarch/wmemset.c index 9fee77ea81..a382bdbad1 100644 --- a/sysdeps/x86_64/multiarch/wmemset.c +++ b/sysdeps/x86_64/multiarch/wmemset.c @@ -18,7 +18,7 @@ . */ /* Define multiple versions only for the definition in libc. */ -#if IS_IN (libc) +#if IS_IN (libc) || IS_IN (libcpu_rt_c) # define wmemset __redirect_wmemset # define __wmemset __redirect___wmemset # include @@ -28,13 +28,19 @@ # define SYMBOL_NAME wmemset # include "ifunc-wmemset.h" +# if IS_IN (libcpu_rt_c) +# define __wmemset wmemset +# endif + libc_ifunc_redirected (__redirect_wmemset, __wmemset, IFUNC_SELECTOR ()); +# if !IS_IN (libcpu_rt_c) weak_alias (__wmemset, wmemset) -# ifdef SHARED +# ifdef SHARED __hidden_ver1 (__wmemset, __GI___wmemset, __redirect___wmemset) __attribute__ ((visibility ("hidden"))); __hidden_ver1 (wmemset, __GI_wmemset, __redirect_wmemset) __attribute__ ((visibility ("hidden"))); +# endif # endif #endif