diff options
author | Joseph Myers <joseph@codesourcery.com> | 2019-11-13 15:25:15 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2019-11-13 15:25:15 +0000 |
commit | 00be2a5f394119085c72aee8d18adefd8ec3ec22 (patch) | |
tree | 71659c0262824c7ba87b2a92d37b1025348f0dd0 /gcc/ginclude/float.h | |
parent | 5024c8bb463fe7bfd20972cff37e3c917001172e (diff) | |
download | gcc-00be2a5f394119085c72aee8d18adefd8ec3ec22.zip gcc-00be2a5f394119085c72aee8d18adefd8ec3ec22.tar.gz gcc-00be2a5f394119085c72aee8d18adefd8ec3ec22.tar.bz2 |
Add C2x *_NORM_MAX constants to <float.h>.
C2x adds <float.h> constants FLT_NORM_MAX, DBL_NORM_MAX and
LDBL_NORM_MAX. These are for the maximum "normalized" finite
floating-point number, where the given definition of normalized is
that all possible values with MANT_DIG significand digits (leading one
not zero) can be represented with that exponent. The effect of that
definition is that these macros are the same as the corresponding MAX
macros for all formats except IBM long double, where the NORM_MAX
value has exponent 1 smaller than the MAX one so that all 106 digits
can be 1.
This patch adds those macros to GCC. They are only defined for float,
double and long double; C2x does not include such macros for DFP
types, and while the integration of TS 18661-3 into C2x has not yet
occurred, the draft proposed text does not add them for the _FloatN /
_FloatNx types (where they would always be the same as the MAX
macros).
Bootstrapped with no regressions on x86_64-pc-linux-gnu. Also tested
compilation of the new test for powerpc-linux-gnu to confirm the check
of LDBL_NORM_MAX in the IBM long double case does get properly
optimized out.
gcc:
* ginclude/float.c [__STDC_VERSION__ > 201710L] (FLT_NORM_MAX,
DBL_NORM_MAX, LDBL_NORM_MAX): Define.
* real.c (get_max_float): Add norm_max argument.
* real.h (get_max_float): Update prototype.
* builtins.c (fold_builtin_interclass_mathfn): Update calls to
get_max_float.
gcc/c-family:
* c-cppbuiltin.c (builtin_define_float_constants): Also define
NORM_MAX constants. Update call to get_max_float.
(LAZY_HEX_FP_VALUES_CNT): Update value to include NORM_MAX
constants.
gcc/d:
* d-target.cc (define_float_constants): Update call to
get_max_float.
gcc/testsuite:
* gcc.dg/c11-float-3.c, gcc.dg/c2x-float-1.c: New tests.
From-SVN: r278145
Diffstat (limited to 'gcc/ginclude/float.h')
-rw-r--r-- | gcc/ginclude/float.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/ginclude/float.h b/gcc/ginclude/float.h index dc91c75..cafedc1 100644 --- a/gcc/ginclude/float.h +++ b/gcc/ginclude/float.h @@ -238,6 +238,18 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif /* C11 */ +#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L +/* Maximum finite positive value with MANT_DIG digits in the + significand taking their maximum value. */ +#undef FLT_NORM_MAX +#undef DBL_NORM_MAX +#undef LDBL_NORM_MAX +#define FLT_NORM_MAX __FLT_NORM_MAX__ +#define DBL_NORM_MAX __DBL_NORM_MAX__ +#define LDBL_NORM_MAX __LDBL_NORM_MAX__ + +#endif /* C2X */ + #ifdef __STDC_WANT_IEC_60559_BFP_EXT__ /* Number of decimal digits for which conversions between decimal character strings and binary formats, in both directions, are |