From d49b6e1e33707adeb972ade7cec09acc0b178d02 Mon Sep 17 00:00:00 2001 From: Steven Bosscher Date: Fri, 21 May 2010 18:13:54 +0000 Subject: real: Do not include gmp.h, mpfr.h, and mpc.h. gcc/ChangeLog: * real: Do not include gmp.h, mpfr.h, and mpc.h. (REAL_VALUE_NEGATE, REAL_VALUE_ABS, real_arithmetic2): Remove. (real_value_negate, real_value_abs): New prototypes. (do_mpc_arg2, real_from_mpfr, mpfr_from_real): Move from here... * realmpfr.h (do_mpc_arg2, real_from_mpfr, mpfr_from_real): ...to here, new include file for interface between MPFR and REAL_VALUE_TYPE. * real.c: Include realmpfr.h. (real_arithmetic2): Remove legacy function. (real_value_negate): New. (real_value_abs): New. (mfpr_from_real, real_from_mpfr): Move from here... * realmpfr.c (mpfr_from_real, real_from_mpfr): ...to here, new file. * builtins.c: Include realmpfr.h. * fold-const.c: Include realmpfr.h. (fold_comparison): Use real_value_negate instead of REAL_VALUE_NEGATE. (fold_negate_const): Likewise. (fold_abs_const): Use real_value_abs instead of REAL_VALUE_ABS. * toplev.c: Include realmpfr.h. * simplify-rtx.c (simplify_const_unary_operation): Use real_value_abs and real_value_negate. * fixed-value.c (check_real_for_fixed_mode): Likewise. * config/arm/arm.c (neg_const_double_rtx_ok_for_fpa): Likewise. (vfp3_const_double_index): Likewise. (arm_print_operand): Likewise. * Makefile.in: Update dependencies. fortran/ChangeLog: * trans-const.c: Include realmpfr.h. * Make-lang.in: Update dependencies. From-SVN: r159679 --- gcc/real.c | 90 +++++++------------------------------------------------------- 1 file changed, 10 insertions(+), 80 deletions(-) (limited to 'gcc/real.c') diff --git a/gcc/real.c b/gcc/real.c index 25e599dfe35..8a5799e5d94 100644 --- a/gcc/real.c +++ b/gcc/real.c @@ -27,6 +27,7 @@ #include "tree.h" #include "toplev.h" #include "real.h" +#include "realmpfr.h" #include "tm_p.h" #include "dfp.h" @@ -1057,14 +1058,19 @@ real_arithmetic (REAL_VALUE_TYPE *r, int icode, const REAL_VALUE_TYPE *op0, return false; } -/* Legacy. Similar, but return the result directly. */ +REAL_VALUE_TYPE +real_value_negate (const REAL_VALUE_TYPE *op0) +{ + REAL_VALUE_TYPE r; + real_arithmetic (&r, NEGATE_EXPR, op0, NULL); + return r; +} REAL_VALUE_TYPE -real_arithmetic2 (int icode, const REAL_VALUE_TYPE *op0, - const REAL_VALUE_TYPE *op1) +real_value_abs (const REAL_VALUE_TYPE *op0) { REAL_VALUE_TYPE r; - real_arithmetic (&r, icode, op0, op1); + real_arithmetic (&r, ABS_EXPR, op0, NULL); return r; } @@ -4982,82 +4988,6 @@ real_copysign (REAL_VALUE_TYPE *r, const REAL_VALUE_TYPE *x) r->sign = x->sign; } -/* Convert from REAL_VALUE_TYPE to MPFR. The caller is responsible - for initializing and clearing the MPFR parameter. */ - -void -mpfr_from_real (mpfr_ptr m, const REAL_VALUE_TYPE *r, mp_rnd_t rndmode) -{ - /* We use a string as an intermediate type. */ - char buf[128]; - int ret; - - /* Take care of Infinity and NaN. */ - if (r->cl == rvc_inf) - { - mpfr_set_inf (m, r->sign == 1 ? -1 : 1); - return; - } - - if (r->cl == rvc_nan) - { - mpfr_set_nan (m); - return; - } - - real_to_hexadecimal (buf, r, sizeof (buf), 0, 1); - /* mpfr_set_str() parses hexadecimal floats from strings in the same - format that GCC will output them. Nothing extra is needed. */ - ret = mpfr_set_str (m, buf, 16, rndmode); - gcc_assert (ret == 0); -} - -/* Convert from MPFR to REAL_VALUE_TYPE, for a given type TYPE and rounding - mode RNDMODE. TYPE is only relevant if M is a NaN. */ - -void -real_from_mpfr (REAL_VALUE_TYPE *r, mpfr_srcptr m, tree type, mp_rnd_t rndmode) -{ - /* We use a string as an intermediate type. */ - char buf[128], *rstr; - mp_exp_t exp; - - /* Take care of Infinity and NaN. */ - if (mpfr_inf_p (m)) - { - real_inf (r); - if (mpfr_sgn (m) < 0) - *r = REAL_VALUE_NEGATE (*r); - return; - } - - if (mpfr_nan_p (m)) - { - real_nan (r, "", 1, TYPE_MODE (type)); - return; - } - - rstr = mpfr_get_str (NULL, &exp, 16, 0, m, rndmode); - - /* The additional 12 chars add space for the sprintf below. This - leaves 6 digits for the exponent which is supposedly enough. */ - gcc_assert (rstr != NULL && strlen (rstr) < sizeof (buf) - 12); - - /* REAL_VALUE_ATOF expects the exponent for mantissa * 2**exp, - mpfr_get_str returns the exponent for mantissa * 16**exp, adjust - for that. */ - exp *= 4; - - if (rstr[0] == '-') - sprintf (buf, "-0x.%sp%d", &rstr[1], (int) exp); - else - sprintf (buf, "0x.%sp%d", rstr, (int) exp); - - mpfr_free_str (rstr); - - real_from_string (r, buf); -} - /* Check whether the real constant value given is an integer. */ bool -- cgit v1.2.1