static bool fold_const_pow (real_value *result, const real_value *arg0, const real_value *arg1, const real_format *format) { if (do_mpfr_arg2 (result, mpfr_pow, arg0, arg1, format)) return true; /* Check for an integer exponent. */ REAL_VALUE_TYPE cint1; HOST_WIDE_INT n1 = real_to_integer (arg1); real_from_integer (&cint1, VOIDmode, n1, SIGNED); /* Attempt to evaluate pow at compile-time, unless this should raise an exception. */ if (real_identical (arg1, &cint1) && (n1 > 0 || (!flag_trapping_math && !flag_errno_math) || !real_equal (arg0, &dconst0))) { bool inexact = real_powi (result, format, arg0, n1); if (flag_unsafe_math_optimizations || !inexact) return true; } return false; }
static bool fold_const_conversion (wide_int *result, void (*fn) (real_value *, format_helper, const real_value *), const real_value *arg, unsigned int precision, const real_format *format) { if (!real_isfinite (arg)) return false; real_value rounded; fn (&rounded, format, arg); bool fail = false; *result = real_to_integer (&rounded, &fail, precision); return !fail; }
void fixed_from_string (FIXED_VALUE_TYPE *f, const char *str, machine_mode mode) { REAL_VALUE_TYPE real_value, fixed_value, base_value; unsigned int fbit; enum fixed_value_range_code temp; bool fail; f->mode = mode; fbit = GET_MODE_FBIT (mode); real_from_string (&real_value, str); temp = check_real_for_fixed_mode (&real_value, f->mode); /* We don't want to warn the case when the _Fract value is 1.0. */ if (temp == FIXED_UNDERFLOW || temp == FIXED_GT_MAX_EPS || (temp == FIXED_MAX_EPS && ALL_ACCUM_MODE_P (f->mode))) warning (OPT_Woverflow, "large fixed-point constant implicitly truncated to fixed-point type"); real_2expN (&base_value, fbit, VOIDmode); real_arithmetic (&fixed_value, MULT_EXPR, &real_value, &base_value); wide_int w = real_to_integer (&fixed_value, &fail, GET_MODE_PRECISION (mode)); f->data.low = w.ulow (); f->data.high = w.elt (1); if (temp == FIXED_MAX_EPS && ALL_FRACT_MODE_P (f->mode)) { /* From the spec, we need to evaluate 1 to the maximal value. */ f->data.low = -1; f->data.high = -1; f->data = f->data.zext (GET_MODE_FBIT (f->mode) + GET_MODE_IBIT (f->mode)); } else f->data = f->data.ext (SIGNED_FIXED_POINT_MODE_P (f->mode) + GET_MODE_FBIT (f->mode) + GET_MODE_IBIT (f->mode), UNSIGNED_FIXED_POINT_MODE_P (f->mode)); }