From 5b4e5e78690c4938de312a8b176f4b14eb7bea4a Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 13 Oct 2017 15:34:33 -0300 Subject: [PATCH] sparc: refactor sparc32 copysign selector to C This patch refactors the sparc32 ifunc selector to a C implementation. Also, the generic symbol is moved to its own implementation file s_copysign{f}-generic.S). Checked on sparc64-linux-gnu and sparcv9-linux-gnu. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile (sysdep_calls): New rule. (sysdep_routines): Use sysdep_calls as base. (libm-sysdep_routines): Add generic rule for symbols shared with libc. Add s_copysign-generic and s_copysign-generic objects. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign-generic.S: New file. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.c: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf-generic.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.c: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.S: Remove file. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.S: Likewise. Signed-off-by: Adhemerval Zanella --- ChangeLog | 16 ++++++++ .../sparc32/sparcv9/fpu/multiarch/Makefile | 15 ++++++-- .../fpu/multiarch/s_copysign-generic.S | 8 ++++ .../sparcv9/fpu/multiarch/s_copysign.S | 19 ---------- .../sparcv9/fpu/multiarch/s_copysign.c | 37 +++++++++++++++++++ .../fpu/multiarch/s_copysignf-generic.S | 5 +++ .../sparcv9/fpu/multiarch/s_copysignf.S | 13 ------- .../sparcv9/fpu/multiarch/s_copysignf.c | 30 +++++++++++++++ 8 files changed, 107 insertions(+), 36 deletions(-) create mode 100644 sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign-generic.S delete mode 100644 sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.S create mode 100644 sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.c create mode 100644 sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf-generic.S delete mode 100644 sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.S create mode 100644 sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.c diff --git a/ChangeLog b/ChangeLog index 7764ab20d7..39e8bcb581 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2017-12-01 Adhemerval Zanella + + * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile + (sysdep_calls): New rule. + (sysdep_routines): Use sysdep_calls as base. + (libm-sysdep_routines): Add generic rule for symbols shared with + libc. Add s_copysign-generic and s_copysign-generic objects. + * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign-generic.S: + New file. + * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.c: Likewise. + * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf-generic.S: + Likewise. + * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.c: Likewise. + * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.S: Remove file. + * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.S: Likewise. + 2017-12-01 Mike FABIAN [BZ #22519] diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile index 62bf6f1431..b8d1126104 100644 --- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile +++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile @@ -1,12 +1,19 @@ ifeq ($(subdir),math) -libm-sysdep_routines += m_copysignf-vis3 m_copysign-vis3 s_fabs-vis3 \ - s_fabsf-vis3 s_llrintf-vis3 s_llrint-vis3 \ + +# These functions are built both for libc and libm because they're required +# by printf. While the libc objects have the prefix s_, the libm ones are +# prefixed with m_. +sysdep_calls := s_copysignf-vis3 s_copysign-vis3 s_copysignf-generic \ + s_copysign-generic + +sysdep_routines += $(sysdep_calls) +libm-sysdep_routines += s_fabs-vis3 s_fabsf-vis3 s_llrintf-vis3 s_llrint-vis3 \ s_rintf-vis3 s_rint-vis3 \ s_fmaf-vis3 s_fma-vis3 s_fma-generic s_fmaf-generic \ s_nearbyint-vis3 s_nearbyintf-vis3 \ s_fdimf-vis3 s_fdim-vis3 s_fdim-generic \ - s_fdimf-generic -sysdep_routines += s_copysignf-vis3 s_copysign-vis3 + s_fdimf-generic \ + $(sysdep_calls:s_%=m_%) CFLAGS-s_fdimf-vis3.c += -Wa,-Av9d -mvis3 CFLAGS-s_fdim-vis3.c += -Wa,-Av9d -mvis3 diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign-generic.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign-generic.S new file mode 100644 index 0000000000..9aa3486277 --- /dev/null +++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign-generic.S @@ -0,0 +1,8 @@ +#include +#include +#define __copysign __copysign_generic +#undef libm_alias_double +#define libm_alias_double(a, b) +#undef compat_symbol +#define compat_symbol(a, b, c, d) +#include diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.S deleted file mode 100644 index affe541fae..0000000000 --- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.S +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include - -SPARC_ASM_VIS3_IFUNC(copysign) - -libm_alias_double (__copysign, copysign) -#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) -compat_symbol (libc, __copysign, copysignl, GLIBC_2_0); -#endif - -# undef weak_alias -# define weak_alias(a, b) -# undef compat_symbol -# define compat_symbol(a, b, c, d) - -#define __copysign __copysign_generic - -#include "../../../fpu/s_copysign.S" diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.c b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.c new file mode 100644 index 0000000000..947ecc5e52 --- /dev/null +++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.c @@ -0,0 +1,37 @@ +/* copysign ifunc resolver, Linux/sparc32 version. + 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 + . */ + +#define __copysign __redirect_copysign +#include +#undef __copysign +#include +#include +#include + +extern __typeof (__redirect_copysign) __copysign_vis3 attribute_hidden; +extern __typeof (__redirect_copysign) __copysign_generic attribute_hidden; + +sparc_libm_ifunc_redirected (__redirect_copysign, __copysign, + hwcap & HWCAP_SPARC_VIS3 + ? __copysign_vis3 + : __copysign_generic); +libm_alias_double (__copysign, copysign) + +#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) +compat_symbol (libc, __copysign, copysignl, GLIBC_2_0); +#endif diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf-generic.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf-generic.S new file mode 100644 index 0000000000..685027500a --- /dev/null +++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf-generic.S @@ -0,0 +1,5 @@ +#include +#define __copysignf __copysignf_generic +#undef libm_alias_float +#define libm_alias_float(a, b) +#include diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.S deleted file mode 100644 index ebb32c7726..0000000000 --- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.S +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -SPARC_ASM_VIS3_IFUNC(copysignf) - -libm_alias_float (__copysign, copysign) - -# undef weak_alias -# define weak_alias(a, b) - -#define __copysignf __copysignf_generic - -#include "../../../fpu/s_copysignf.S" diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.c b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.c new file mode 100644 index 0000000000..26cad3106a --- /dev/null +++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.c @@ -0,0 +1,30 @@ +/* copysign ifunc resolver, Linux/sparc32 version. + 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 + . */ + +#include +#include +#include + +extern __typeof (copysignf) __copysignf_vis3 attribute_hidden; +extern __typeof (copysignf) __copysignf_generic attribute_hidden; + +sparc_libm_ifunc (__copysignf, + hwcap & HWCAP_SPARC_VIS3 + ? __copysignf_vis3 + : __copysignf_generic); +libm_alias_float (__copysign, copysign) -- 2.43.5