glibc/sysdeps/alpha/fpu/s_rintf.c

53 lines
1.6 KiB
C
Raw Normal View History

/* Copyright (C) 2000-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Richard Henderson.
The GNU C Library is free software; you can redistribute it and/or
2001-07-06 06:56:23 +02:00
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
2001-07-06 06:56:23 +02:00
Lesser General Public License for more details.
2001-07-06 06:56:23 +02:00
You should have received a copy of the GNU Lesser General Public
2012-03-10 00:56:38 +01:00
License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */
Use rint functions not __rint functions in glibc libm. Continuing the move to use, within libm, public names for libm functions that can be inlined as built-in functions on many architectures, this patch moves calls to __rint functions to call the corresponding rint names instead, with asm redirection to __rint when the calls are not inlined. The x86_64 math_private.h is removed as no longer useful after this patch. This patch is relative to a tree with my floor patch <https://sourceware.org/ml/libc-alpha/2018-09/msg00148.html> applied, and much the same considerations arise regarding possibly replacing an IFUNC call with a direct inline expansion. Tested for x86_64, and with build-many-glibcs.py. * include/math.h [!_ISOMAC && !(__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0) && !NO_MATH_REDIRECT] (rint): Redirect using MATH_REDIRECT. * sysdeps/aarch64/fpu/s_rint.c: Define NO_MATH_REDIRECT before header inclusion. * sysdeps/aarch64/fpu/s_rintf.c: Likewise. * sysdeps/alpha/fpu/s_rint.c: Likewise. * sysdeps/alpha/fpu/s_rintf.c: Likewise. * sysdeps/i386/fpu/s_rintl.c: Likewise. * sysdeps/ieee754/dbl-64/s_rint.c: Likewise. * sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c: Likewise. * sysdeps/ieee754/float128/s_rintf128.c: Likewise. * sysdeps/ieee754/flt-32/s_rintf.c: Likewise. * sysdeps/ieee754/ldbl-128/s_rintl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_rintl.c: Likewise. * sysdeps/m68k/coldfire/fpu/s_rint.c: Likewise. * sysdeps/m68k/coldfire/fpu/s_rintf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_rint.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_rintf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_rintl.c: Likewise. * sysdeps/powerpc/fpu/s_rint.c: Likewise. * sysdeps/powerpc/fpu/s_rintf.c: Likewise. * sysdeps/riscv/rv64/rvd/s_rint.c: Likewise. * sysdeps/riscv/rvf/s_rintf.c: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_rint.c: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_rintf.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_rint.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_rintf.c: Likewise. * sysdeps/x86_64/fpu/multiarch/s_rint.c: Likewise. * sysdeps/x86_64/fpu/multiarch/s_rintf.c: Likewise. * sysdeps/x86_64/fpu/math_private.h: Remove file. * math/e_scalb.c (invalid_fn): Use rint functions instead of __rint variants. * math/e_scalbf.c (invalid_fn): Likewise. * math/e_scalbl.c (invalid_fn): Likewise. * sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r): Likewise. * sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r): Likewise. * sysdeps/ieee754/k_standard.c (__kernel_standard): Likewise. * sysdeps/ieee754/k_standardl.c (__kernel_standard_l): Likewise. * sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r): Likewise. * sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r): Likewise. * sysdeps/powerpc/powerpc32/fpu/s_llrint.c (__llrint): Likewise. * sysdeps/powerpc/powerpc32/fpu/s_llrintf.c (__llrintf): Likewise.
2018-09-14 15:10:39 +02:00
#define NO_MATH_REDIRECT
#include <math.h>
Use libm_alias_float for alpha. Continuing the preparation for additional _FloatN / _FloatNx function aliases, this patch makes alpha libm function implementations use libm_alias_float macros to define function aliases. In the case of the ABI compatibility for complex functions, libm_alias_float_other is used, with the cfloat_versions macro adjusted to take a function name argument without the trailing 'f' to facilitate this, and cfloat_versions dealing with calling libm_alias_float_other (except for clog10f, which doesn't use that macro because of the complexity associated with __clog10f also being exported). Tested with build-many-glibcs.py for alpha-linux-gnu that installed stripped shared libraries are unchanged by the patch. * sysdeps/alpha/fpu/cfloat-compat.h: Include <libm-alias-float.h>. (cfloat_versions): Take function argument without trailing 'f'. Call libm_alias_float_other. * sysdeps/alpha/fpu/cabsf.c: Update call to cfloat_versions. * sysdeps/alpha/fpu/cargf.c: Likewise. * sysdeps/alpha/fpu/cimagf.c: Likewise. * sysdeps/alpha/fpu/conjf.c: Likewise. * sysdeps/alpha/fpu/crealf.c: Likewise. * sysdeps/alpha/fpu/s_cacosf.c: Likewise. * sysdeps/alpha/fpu/s_cacoshf.c: Likewise. * sysdeps/alpha/fpu/s_casinf.c: Likewise. * sysdeps/alpha/fpu/s_casinhf.c: Likewise. * sysdeps/alpha/fpu/s_catanf.c: Likewise. * sysdeps/alpha/fpu/s_catanhf.c: Likewise. * sysdeps/alpha/fpu/s_ccosf.c: Likewise. * sysdeps/alpha/fpu/s_ccoshf.c: Likewise. * sysdeps/alpha/fpu/s_cexpf.c: Likewise. * sysdeps/alpha/fpu/s_clogf.c: Likewise. * sysdeps/alpha/fpu/s_cpowf.c: Likewise. * sysdeps/alpha/fpu/s_cprojf.c: Likewise. * sysdeps/alpha/fpu/s_csinf.c: Likewise. * sysdeps/alpha/fpu/s_csinhf.c: Likewise. * sysdeps/alpha/fpu/s_csqrtf.c: Likewise. * sysdeps/alpha/fpu/s_ctanf.c: Likewise. * sysdeps/alpha/fpu/s_ctanhf.c: Likewise. * sysdeps/alpha/fpu/s_clog10f.c: Include <libm-alias-float.h>. (clog10f): Use libm_alias_float_other. * sysdeps/alpha/fpu/s_ceilf.c: Include <libm-alias-float.h>. (ceilf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_copysignf.c: Include <libm-alias-float.h>. (copysignf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_fabsf.c: Include <libm-alias-float.h>. (fabsf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_floorf.c: Include <libm-alias-float.h>. (floorf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_fmax.S: Include <libm-alias-float.h>. (fmaxf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_fmin.S: Include <libm-alias-float.h>. (fminf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_lrintf.c: Include <libm-alias-float.h>. (lrintf): Define using libm_alias_float. (llrintf): Likewise. * sysdeps/alpha/fpu/s_lroundf.c: Include <libm-alias-float.h>. (lroundf): Define using libm_alias_float. (llroundf): Likewise. * sysdeps/alpha/fpu/s_rintf.c: Include <libm-alias-float.h>. (rintf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_truncf.c: Include <libm-alias-float.h>. (truncf): Define using libm_alias_float.
2017-11-28 02:19:03 +01:00
#include <libm-alias-float.h>
float
__rintf (float x)
{
if (isnanf (x))
return x + x;
if (isless (fabsf (x), 16777216.0f)) /* 1 << FLT_MANT_DIG */
{
/* Note that Alpha S_Floating is stored in registers in a
restricted T_Floating format, so we don't even need to
convert back to S_Floating in the end. The initial
conversion to T_Floating is needed to handle denormals. */
float tmp1, tmp2, new_x;
__asm ("cvtst/s %3,%2\n\t"
"cvttq/svid %2,%1\n\t"
"cvtqt/d %1,%0\n\t"
: "=f"(new_x), "=&f"(tmp1), "=&f"(tmp2)
: "f"(x));
/* rint(-0.1) == -0, and in general we'll always have the same
sign as our input. */
x = copysignf(new_x, x);
}
return x;
}
Use libm_alias_float for alpha. Continuing the preparation for additional _FloatN / _FloatNx function aliases, this patch makes alpha libm function implementations use libm_alias_float macros to define function aliases. In the case of the ABI compatibility for complex functions, libm_alias_float_other is used, with the cfloat_versions macro adjusted to take a function name argument without the trailing 'f' to facilitate this, and cfloat_versions dealing with calling libm_alias_float_other (except for clog10f, which doesn't use that macro because of the complexity associated with __clog10f also being exported). Tested with build-many-glibcs.py for alpha-linux-gnu that installed stripped shared libraries are unchanged by the patch. * sysdeps/alpha/fpu/cfloat-compat.h: Include <libm-alias-float.h>. (cfloat_versions): Take function argument without trailing 'f'. Call libm_alias_float_other. * sysdeps/alpha/fpu/cabsf.c: Update call to cfloat_versions. * sysdeps/alpha/fpu/cargf.c: Likewise. * sysdeps/alpha/fpu/cimagf.c: Likewise. * sysdeps/alpha/fpu/conjf.c: Likewise. * sysdeps/alpha/fpu/crealf.c: Likewise. * sysdeps/alpha/fpu/s_cacosf.c: Likewise. * sysdeps/alpha/fpu/s_cacoshf.c: Likewise. * sysdeps/alpha/fpu/s_casinf.c: Likewise. * sysdeps/alpha/fpu/s_casinhf.c: Likewise. * sysdeps/alpha/fpu/s_catanf.c: Likewise. * sysdeps/alpha/fpu/s_catanhf.c: Likewise. * sysdeps/alpha/fpu/s_ccosf.c: Likewise. * sysdeps/alpha/fpu/s_ccoshf.c: Likewise. * sysdeps/alpha/fpu/s_cexpf.c: Likewise. * sysdeps/alpha/fpu/s_clogf.c: Likewise. * sysdeps/alpha/fpu/s_cpowf.c: Likewise. * sysdeps/alpha/fpu/s_cprojf.c: Likewise. * sysdeps/alpha/fpu/s_csinf.c: Likewise. * sysdeps/alpha/fpu/s_csinhf.c: Likewise. * sysdeps/alpha/fpu/s_csqrtf.c: Likewise. * sysdeps/alpha/fpu/s_ctanf.c: Likewise. * sysdeps/alpha/fpu/s_ctanhf.c: Likewise. * sysdeps/alpha/fpu/s_clog10f.c: Include <libm-alias-float.h>. (clog10f): Use libm_alias_float_other. * sysdeps/alpha/fpu/s_ceilf.c: Include <libm-alias-float.h>. (ceilf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_copysignf.c: Include <libm-alias-float.h>. (copysignf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_fabsf.c: Include <libm-alias-float.h>. (fabsf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_floorf.c: Include <libm-alias-float.h>. (floorf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_fmax.S: Include <libm-alias-float.h>. (fmaxf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_fmin.S: Include <libm-alias-float.h>. (fminf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_lrintf.c: Include <libm-alias-float.h>. (lrintf): Define using libm_alias_float. (llrintf): Likewise. * sysdeps/alpha/fpu/s_lroundf.c: Include <libm-alias-float.h>. (lroundf): Define using libm_alias_float. (llroundf): Likewise. * sysdeps/alpha/fpu/s_rintf.c: Include <libm-alias-float.h>. (rintf): Define using libm_alias_float. * sysdeps/alpha/fpu/s_truncf.c: Include <libm-alias-float.h>. (truncf): Define using libm_alias_float.
2017-11-28 02:19:03 +01:00
libm_alias_float (__rint, rint)