diff options
Diffstat (limited to 'gcc/c-family/c-cppbuiltin.c')
-rw-r--r-- | gcc/c-family/c-cppbuiltin.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index 82ed19d..1f7d013 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -125,7 +125,7 @@ builtin_define_float_constants (const char *name_prefix, const double log10_2 = .30102999566398119521; double log10_b; const struct real_format *fmt; - const struct real_format *ldfmt; + const struct real_format *widefmt; char name[64], buf[128]; int dig, min_10_exp, max_10_exp; @@ -134,8 +134,20 @@ builtin_define_float_constants (const char *name_prefix, fmt = REAL_MODE_FORMAT (TYPE_MODE (type)); gcc_assert (fmt->b != 10); - ldfmt = REAL_MODE_FORMAT (TYPE_MODE (long_double_type_node)); - gcc_assert (ldfmt->b != 10); + widefmt = REAL_MODE_FORMAT (TYPE_MODE (long_double_type_node)); + gcc_assert (widefmt->b != 10); + for (int i = 0; i < NUM_FLOATN_NX_TYPES; i++) + { + tree wtype = FLOATN_NX_TYPE_NODE (i); + if (wtype != NULL_TREE) + { + const struct real_format *wfmt + = REAL_MODE_FORMAT (TYPE_MODE (wtype)); + gcc_assert (wfmt->b != 10); + if (wfmt->p > widefmt->p) + widefmt = wfmt; + } + } /* The radix of the exponent representation. */ if (type == float_type_node) @@ -219,7 +231,7 @@ builtin_define_float_constants (const char *name_prefix, floating type, but we want this value for rendering constants below. */ { double d_decimal_dig - = 1 + (fmt->p < ldfmt->p ? ldfmt->p : fmt->p) * log10_b; + = 1 + (fmt->p < widefmt->p ? widefmt->p : fmt->p) * log10_b; decimal_dig = d_decimal_dig; if (decimal_dig < d_decimal_dig) decimal_dig++; @@ -231,13 +243,13 @@ builtin_define_float_constants (const char *name_prefix, if (type_decimal_dig < type_d_decimal_dig) type_decimal_dig++; } + /* Arbitrarily, define __DECIMAL_DIG__ when defining macros for long + double, although it may be greater than the value for long + double. */ if (type == long_double_type_node) builtin_define_with_int_value ("__DECIMAL_DIG__", decimal_dig); - else - { - sprintf (name, "__%s_DECIMAL_DIG__", name_prefix); - builtin_define_with_int_value (name, type_decimal_dig); - } + sprintf (name, "__%s_DECIMAL_DIG__", name_prefix); + builtin_define_with_int_value (name, type_decimal_dig); /* Since, for the supported formats, B is always a power of 2, we construct the following numbers directly as a hexadecimal @@ -289,7 +301,7 @@ builtin_define_float_constants (const char *name_prefix, builtin_define_with_int_value (name, MODE_HAS_NANS (TYPE_MODE (type))); /* Note whether we have fast FMA. */ - if (mode_has_fma (TYPE_MODE (type))) + if (mode_has_fma (TYPE_MODE (type)) && fma_suffix != NULL) { sprintf (name, "__FP_FAST_FMA%s", fma_suffix); builtin_define_with_int_value (name, 1); @@ -984,6 +996,19 @@ c_cpp_builtins (cpp_reader *pfile) builtin_define_float_constants ("LDBL", "L", "%s", "L", long_double_type_node); + for (int i = 0; i < NUM_FLOATN_NX_TYPES; i++) + { + if (FLOATN_NX_TYPE_NODE (i) == NULL_TREE) + continue; + char prefix[20], csuffix[20]; + sprintf (prefix, "FLT%d%s", floatn_nx_types[i].n, + floatn_nx_types[i].extended ? "X" : ""); + sprintf (csuffix, "F%d%s", floatn_nx_types[i].n, + floatn_nx_types[i].extended ? "x" : ""); + builtin_define_float_constants (prefix, csuffix, "%s", NULL, + FLOATN_NX_TYPE_NODE (i)); + } + /* For decfloat.h. */ builtin_define_decimal_float_constants ("DEC32", "DF", dfloat32_type_node); builtin_define_decimal_float_constants ("DEC64", "DD", dfloat64_type_node); |