From 1cbd7bfe65e4fafdf77cccccf67950d2b5570d4a Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 13 Oct 2017 09:56:49 -0300 Subject: sparc: refactor sparc64 signbit{f} selector to C This patch refactors the sparc64 ifunc selector to a C implementation. Also, the generic symbol is moved to its own implementation file (s_signbit{f}-generic.S). It also simplifies the multiarch Makefile by moving the common objects from libm-sysdeps_routines and sysdeps_routines to a new sysdeps_call rule and including it where required with the correct prefix. Checked on sparc64-linux-gnu and sparcv9-linux-gnu. * sysdeps/sparc/sparc-ifunc.h (sparc_libm_ifunc_redirected): New macro. * sysdeps/sparc/sparc64/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_signbit-generic and s_signbitf-generic objects. * sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.c: New file. * sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_signbit-generic.S: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf-generic.S: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S: Remove file. * sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S: Likewise. Signed-off-by: Adhemerval Zanella --- sysdeps/sparc/sparc64/fpu/multiarch/Makefile | 20 +++++++----- .../sparc64/fpu/multiarch/s_signbit-generic.S | 6 ++++ sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S | 20 ------------ sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.c | 37 ++++++++++++++++++++++ .../sparc64/fpu/multiarch/s_signbitf-generic.S | 2 ++ sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S | 10 ------ sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.c | 28 ++++++++++++++++ 7 files changed, 85 insertions(+), 38 deletions(-) create mode 100644 sysdeps/sparc/sparc64/fpu/multiarch/s_signbit-generic.S delete mode 100644 sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S create mode 100644 sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.c create mode 100644 sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf-generic.S delete mode 100644 sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S create mode 100644 sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.c (limited to 'sysdeps/sparc/sparc64') diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/Makefile b/sysdeps/sparc/sparc64/fpu/multiarch/Makefile index 2ac449672a..702452cbde 100644 --- a/sysdeps/sparc/sparc64/fpu/multiarch/Makefile +++ b/sysdeps/sparc/sparc64/fpu/multiarch/Makefile @@ -1,17 +1,21 @@ ifeq ($(subdir),math) -libm-sysdep_routines += m_signbitf-vis3 m_signbit-vis3 m_finitef-vis3 \ - m_finite-vis3 m_isinff-vis3 m_isinf-vis3 \ - m_isnanf-vis3 m_isnan-vis3 s_lrintf-vis3 \ - s_lrint-vis3 s_rintf-vis3 s_rint-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_signbitf-vis3 s_signbit-vis3 s_signbitf-generic \ + s_signbit-generic s_finitef-vis3 \ + s_finite-vis3 s_isinff-vis3 s_isinf-vis3 \ + s_isnanf-vis3 s_isnan-vis3 + +sysdep_routines += $(sysdep_calls) +libm-sysdep_routines += s_lrintf-vis3 s_lrint-vis3 s_rintf-vis3 s_rint-vis3 \ s_fmaf-vis3 s_fma-vis3 s_fmaf-generic s_fma-generic \ s_nearbyint-vis3 s_nearbyintf-vis3 \ s_ceilf-vis3 s_ceil-vis3 s_ceilf-generic \ s_ceil-generic s_floorf-vis3 s_floor-vis3 \ s_floorf-generic s_floor-generic s_truncf-vis3 \ - s_trunc-vis3 s_truncf-generic s_trunc-generic -sysdep_routines += s_signbitf-vis3 s_signbit-vis3 s_finitef-vis3 \ - s_finite-vis3 s_isinff-vis3 s_isinf-vis3 \ - s_isnanf-vis3 s_isnan-vis3 + s_trunc-vis3 s_truncf-generic s_trunc-generic \ + $(sysdep_calls:s_%=m_%) CFLAGS-s_ceilf-vis3.c += -Wa,-Av9d -mvis3 CFLAGS-s_ceil-vis3.c += -Wa,-Av9d -mvis3 diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit-generic.S b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit-generic.S new file mode 100644 index 0000000000..dfa40aca8f --- /dev/null +++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit-generic.S @@ -0,0 +1,6 @@ +#define __signbit __signbit_generic +#undef strong_alias +#define strong_alias(a, b) +#undef hidden_def +#define hidden_def(a) +#include diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S deleted file mode 100644 index b8ff64a547..0000000000 --- a/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S +++ /dev/null @@ -1,20 +0,0 @@ -#include - -SPARC_ASM_VIS3_IFUNC(signbit) - -/* On 64-bit the double version will also always work for - long-double-precision since in both cases the word with the - sign bit in it is passed always in register %f0. */ -strong_alias (__signbit, __signbitl) -hidden_def (__signbitl) - -# undef weak_alias -# define weak_alias(a, b) -# undef strong_alias -# define strong_alias(a, b) -# undef hidden_def -# define hidden_def(a) - -#define __signbit __signbit_generic - -#include "../s_signbit.S" diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.c b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.c new file mode 100644 index 0000000000..47596bc601 --- /dev/null +++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.c @@ -0,0 +1,37 @@ +/* signbit ifunc resolver, Linux/sparc64 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 __signbit __redirect_signbit +#include +#undef __signbit + +#include + +extern __typeof (__redirect_signbit) __signbit_vis3 attribute_hidden; +extern __typeof (__redirect_signbit) __signbit_generic attribute_hidden; + +sparc_libm_ifunc_redirected (__redirect_signbit, __signbit, + hwcap & HWCAP_SPARC_VIS3 + ? __signbit_vis3 + : __signbit_generic); + +/* On 64-bit the double version will also always work for + long-double-precision since in both cases the word with the + sign bit in it is passed always in register %f0. */ +strong_alias (__signbit, __signbitl) +sparc_ifunc_redirected_hidden_def (__redirect_signbit, __signbitl) diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf-generic.S b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf-generic.S new file mode 100644 index 0000000000..851ff350d1 --- /dev/null +++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf-generic.S @@ -0,0 +1,2 @@ +#define __signbitf __signbitf_generic +#include diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S deleted file mode 100644 index d57e999b90..0000000000 --- a/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S +++ /dev/null @@ -1,10 +0,0 @@ -#include - -SPARC_ASM_VIS3_IFUNC(signbitf) - -# undef weak_alias -# define weak_alias(a, b) - -#define __signbitf __signbitf_generic - -#include "../s_signbitf.S" diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.c b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.c new file mode 100644 index 0000000000..85a97ce9ef --- /dev/null +++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.c @@ -0,0 +1,28 @@ +/* signbit ifunc resolver, Linux/sparc64 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 + +extern int __signbitf_vis3 (float) attribute_hidden; +extern int __signbitf_generic (float) attribute_hidden; + +sparc_libm_ifunc(__signbitf, + hwcap & HWCAP_SPARC_VIS3 + ? __signbitf_vis3 + : __signbitf_generic); -- cgit 1.4.1