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/real.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/real.h')
-rw-r--r-- | gcc/real.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -524,7 +524,7 @@ extern bool real_nextafter (REAL_VALUE_TYPE *, format_helper, /* Write into BUF the maximum representable finite floating-point number, (1 - b**-p) * b**emax for a given FP format FMT as a hex float string. BUF must be large enough to contain the result. */ -extern void get_max_float (const struct real_format *, char *, size_t); +extern void get_max_float (const struct real_format *, char *, size_t, bool); #ifndef GENERATOR_FILE /* real related routines. */ |