aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSteven Bosscher <steven@gcc.gnu.org>2010-05-21 18:13:54 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2010-05-21 18:13:54 +0000
commitd49b6e1e33707adeb972ade7cec09acc0b178d02 (patch)
treed44cc1a6330da7188cdd65b1bfce6a8b5b0818dc /gcc
parent759149fbf3c844c39b283e487190eed9377b594e (diff)
downloadgcc-d49b6e1e33707adeb972ade7cec09acc0b178d02.zip
gcc-d49b6e1e33707adeb972ade7cec09acc0b178d02.tar.gz
gcc-d49b6e1e33707adeb972ade7cec09acc0b178d02.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog28
-rw-r--r--gcc/Makefile.in10
-rw-r--r--gcc/builtins.c1
-rw-r--r--gcc/config/arm/arm.c6
-rw-r--r--gcc/fixed-value.c2
-rw-r--r--gcc/fold-const.c7
-rw-r--r--gcc/fortran/ChangeLog5
-rw-r--r--gcc/fortran/Make-lang.in2
-rw-r--r--gcc/fortran/trans-const.c1
-rw-r--r--gcc/real.c90
-rw-r--r--gcc/real.h24
-rw-r--r--gcc/realmpfr.c101
-rw-r--r--gcc/realmpfr.h40
-rw-r--r--gcc/simplify-rtx.c4
-rw-r--r--gcc/toplev.c1
15 files changed, 206 insertions, 116 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cdea224..ee78f23 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,31 @@
+2010-05-21 Steven Bosscher <steven@gcc.gnu.org>
+
+ * 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.
+
2010-05-21 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* config/s390/s390.c (override_options): Increase the default
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index fa1ee38..2af5803 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1285,6 +1285,7 @@ OBJS-common = \
print-tree.o \
profile.o \
real.o \
+ realmpfr.o \
recog.o \
reg-stack.o \
regcprop.o \
@@ -2694,7 +2695,7 @@ tree-pretty-print.o : tree-pretty-print.c $(CONFIG_H) $(SYSTEM_H) \
fold-const.o : fold-const.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) $(FLAGS_H) $(TOPLEV_H) $(HASHTAB_H) $(EXPR_H) $(RTL_H) \
$(GGC_H) $(TM_P_H) langhooks.h $(MD5_H) intl.h $(TARGET_H) \
- $(GIMPLE_H)
+ $(GIMPLE_H) realmpfr.h
diagnostic.o : diagnostic.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) version.h $(TM_P_H) $(FLAGS_H) $(INPUT_H) $(TOPLEV_H) intl.h \
$(DIAGNOSTIC_H) langhooks.h $(LANGHOOKS_DEF_H) diagnostic.def opts.h \
@@ -2728,7 +2729,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
langhooks.h insn-flags.h $(CFGLAYOUT_H) $(CFGLOOP_H) hosthooks.h \
$(CGRAPH_H) $(COVERAGE_H) alloc-pool.h $(GGC_H) $(INTEGRATE_H) \
opts.h params.def tree-mudflap.h $(TREE_PASS_H) $(GIMPLE_H) \
- tree-ssa-alias.h $(PLUGIN_H)
+ tree-ssa-alias.h $(PLUGIN_H) realmpfr.h
$(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
-DTARGET_NAME=\"$(target_noncanonical)\" \
-c $(srcdir)/toplev.c $(OUTPUT_OPTION)
@@ -2807,7 +2808,7 @@ builtins.o : builtins.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(TREE_H) $(GIMPLE_H) $(FLAGS_H) $(TARGET_H) $(FUNCTION_H) $(REGS_H) \
$(EXPR_H) $(OPTABS_H) insn-config.h $(RECOG_H) output.h typeclass.h \
hard-reg-set.h $(TOPLEV_H) hard-reg-set.h $(EXCEPT_H) $(TM_P_H) $(PREDICT_H) \
- libfuncs.h langhooks.h $(BASIC_BLOCK_H) tree-mudflap.h \
+ libfuncs.h langhooks.h $(BASIC_BLOCK_H) tree-mudflap.h realmpfr.h \
$(BUILTINS_DEF) $(MACHMODE_H) $(DIAGNOSTIC_H) $(TREE_FLOW_H) value-prof.h
calls.o : calls.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(TREE_H) $(FLAGS_H) $(EXPR_H) $(OPTABS_H) langhooks.h $(TARGET_H) \
@@ -2853,7 +2854,8 @@ emit-rtl.o : emit-rtl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(HASHTAB_H) $(TM_P_H) debug.h langhooks.h $(TREE_PASS_H) gt-emit-rtl.h \
$(DF_H) $(PARAMS_H) $(TARGET_H)
real.o : real.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
- $(TOPLEV_H) $(TM_P_H) $(REAL_H) dfp.h
+ $(TOPLEV_H) $(TM_P_H) $(REAL_H) dfp.h realmpfr.h
+realmpfr.o : realmpfr.c realmpfr.h $(CONFIG_H) $(SYSTEM_H) $(REAL_H)
dfp.o : dfp.c dfp.h $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(TOPLEV_H) $(TM_P_H) $(REAL_H) $(DECNUM_H)
fixed-value.o: fixed-value.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
diff --git a/gcc/builtins.c b/gcc/builtins.c
index b7be275..871d670 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see
#include "machmode.h"
#include "rtl.h"
#include "tree.h"
+#include "realmpfr.h"
#include "gimple.h"
#include "flags.h"
#include "regs.h"
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 7a7dea4..88f21bc 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -7799,7 +7799,7 @@ neg_const_double_rtx_ok_for_fpa (rtx x)
init_fp_table ();
REAL_VALUE_FROM_CONST_DOUBLE (r, x);
- r = REAL_VALUE_NEGATE (r);
+ r = real_value_negate (&r);
if (REAL_VALUE_MINUS_ZERO (r))
return 0;
@@ -7850,7 +7850,7 @@ vfp3_const_double_index (rtx x)
/* Extract sign, exponent and mantissa. */
sign = REAL_VALUE_NEGATIVE (r) ? 1 : 0;
- r = REAL_VALUE_ABS (r);
+ r = real_value_abs (&r);
exponent = REAL_EXP (&r);
/* For the mantissa, we expand into two HOST_WIDE_INTS, apart from the
highest (sign) bit, with a fixed binary point at bit point_pos.
@@ -15133,7 +15133,7 @@ arm_print_operand (FILE *stream, rtx x, int code)
{
REAL_VALUE_TYPE r;
REAL_VALUE_FROM_CONST_DOUBLE (r, x);
- r = REAL_VALUE_NEGATE (r);
+ r = real_value_negate (&r);
fprintf (stream, "%s", fp_const_from_val (&r));
}
return;
diff --git a/gcc/fixed-value.c b/gcc/fixed-value.c
index 8c23bf0..9af431c 100644
--- a/gcc/fixed-value.c
+++ b/gcc/fixed-value.c
@@ -67,7 +67,7 @@ check_real_for_fixed_mode (REAL_VALUE_TYPE *real_value, enum machine_mode mode)
real_2expN (&epsilon_value, -GET_MODE_FBIT (mode), mode);
if (SIGNED_FIXED_POINT_MODE_P (mode))
- min_value = REAL_VALUE_NEGATE (max_value);
+ min_value = real_value_negate (&max_value);
else
real_from_string (&min_value, "0.0");
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 65ded14..17672ad 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -53,6 +53,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm.h"
#include "flags.h"
#include "tree.h"
+#include "realmpfr.h"
#include "rtl.h"
#include "expr.h"
#include "tm_p.h"
@@ -8977,7 +8978,7 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
return fold_build2_loc (loc, swap_tree_comparison (code), type,
TREE_OPERAND (arg0, 0),
build_real (TREE_TYPE (arg1),
- REAL_VALUE_NEGATE (cst)));
+ real_value_negate (&cst)));
/* IEEE doesn't distinguish +0 and -0 in comparisons. */
/* a CMP (-0) -> a CMP 0 */
@@ -15166,7 +15167,7 @@ fold_negate_const (tree arg0, tree type)
}
case REAL_CST:
- t = build_real (type, REAL_VALUE_NEGATE (TREE_REAL_CST (arg0)));
+ t = build_real (type, real_value_negate (&TREE_REAL_CST (arg0)));
break;
case FIXED_CST:
@@ -15225,7 +15226,7 @@ fold_abs_const (tree arg0, tree type)
case REAL_CST:
if (REAL_VALUE_NEGATIVE (TREE_REAL_CST (arg0)))
- t = build_real (type, REAL_VALUE_NEGATE (TREE_REAL_CST (arg0)));
+ t = build_real (type, real_value_negate (&TREE_REAL_CST (arg0)));
else
t = arg0;
break;
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index cce9484..fc99619 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,10 @@
2010-05-21 Steven Bosscher <steven@gcc.gnu.org>
+ * trans-const.c: Include realmpfr.h.
+ * Make-lang.in: Update dependencies.
+
+2010-05-21 Steven Bosscher <steven@gcc.gnu.org>
+
* trans-const.c, trans-types.c, trans-intrinsic.c:
Clean up redundant includes.
diff --git a/gcc/fortran/Make-lang.in b/gcc/fortran/Make-lang.in
index 49ffdf9..b74f9e99 100644
--- a/gcc/fortran/Make-lang.in
+++ b/gcc/fortran/Make-lang.in
@@ -345,7 +345,7 @@ fortran/trans-decl.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-decl.h \
$(TREE_DUMP_H) debug.h pointer-set.h
fortran/trans-types.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-types.h \
$(REAL_H) toplev.h $(TARGET_H) $(FLAGS_H) dwarf2out.h
-fortran/trans-const.o: $(GFORTRAN_TRANS_DEPS)
+fortran/trans-const.o: $(GFORTRAN_TRANS_DEPS) realmpfr.h
fortran/trans-expr.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h
fortran/trans-stmt.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h
fortran/trans-openmp.o: $(GFORTRAN_TRANS_DEPS)
diff --git a/gcc/fortran/trans-const.c b/gcc/fortran/trans-const.c
index 9570da0..7ced6f4 100644
--- a/gcc/fortran/trans-const.c
+++ b/gcc/fortran/trans-const.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see
#include "system.h"
#include "coretypes.h"
#include "tree.h"
+#include "realmpfr.h"
#include "toplev.h"
#include "double-int.h"
#include "gfortran.h"
diff --git a/gcc/real.c b/gcc/real.c
index 25e599d..8a5799e 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
diff --git a/gcc/real.h b/gcc/real.h
index 980bf96..d16dc249 100644
--- a/gcc/real.h
+++ b/gcc/real.h
@@ -22,12 +22,6 @@
#ifndef GCC_REAL_H
#define GCC_REAL_H
-#ifndef GENERATOR_FILE
-#include <gmp.h>
-#include <mpfr.h>
-#include <mpc.h>
-extern tree do_mpc_arg2 (tree, tree, tree, int, int (*)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t));
-#endif
#include "machmode.h"
/* An expanded form of the represented number. */
@@ -394,14 +388,8 @@ extern REAL_VALUE_TYPE real_value_truncate (enum machine_mode,
#define REAL_VALUE_TO_INT(plow, phigh, r) \
real_to_integer2 (plow, phigh, &(r))
-extern REAL_VALUE_TYPE real_arithmetic2 (int, const REAL_VALUE_TYPE *,
- const REAL_VALUE_TYPE *);
-
-#define REAL_VALUE_NEGATE(X) \
- real_arithmetic2 (NEGATE_EXPR, &(X), NULL)
-
-#define REAL_VALUE_ABS(X) \
- real_arithmetic2 (ABS_EXPR, &(X), NULL)
+extern REAL_VALUE_TYPE real_value_negate (const REAL_VALUE_TYPE *);
+extern REAL_VALUE_TYPE real_value_abs (const REAL_VALUE_TYPE *);
extern int significand_size (enum machine_mode);
@@ -496,14 +484,6 @@ extern void real_round (REAL_VALUE_TYPE *, enum machine_mode,
/* Set the sign of R to the sign of X. */
extern void real_copysign (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *);
-#ifndef GENERATOR_FILE
-/* Convert between MPFR and REAL_VALUE_TYPE. The caller is
- responsible for initializing and clearing the MPFR parameter. */
-
-extern void real_from_mpfr (REAL_VALUE_TYPE *, mpfr_srcptr, tree, mp_rnd_t);
-extern void mpfr_from_real (mpfr_ptr, const REAL_VALUE_TYPE *, mp_rnd_t);
-#endif
-
/* Check whether the real constant value given is an integer. */
extern bool real_isinteger (const REAL_VALUE_TYPE *c, enum machine_mode mode);
diff --git a/gcc/realmpfr.c b/gcc/realmpfr.c
new file mode 100644
index 0000000..2836338
--- /dev/null
+++ b/gcc/realmpfr.c
@@ -0,0 +1,101 @@
+/* Conversion routines from GCC internal float representation to MPFR.
+ Copyright (C) 2010
+
+ This file is part of GCC.
+
+ GCC is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 3, or (at your option) any later
+ version.
+
+ GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "realmpfr.h"
+#include "tree.h" /* For TYPE_MODE in real_from_mpfr. */
+
+/* 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);
+}
+
diff --git a/gcc/realmpfr.h b/gcc/realmpfr.h
new file mode 100644
index 0000000..ab234e9
--- /dev/null
+++ b/gcc/realmpfr.h
@@ -0,0 +1,40 @@
+/* Definitions of floating-point conversion from compiler
+ internal format to MPFR.
+ Copyright (C) 2010
+ Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ GCC is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 3, or (at your option) any later
+ version.
+
+ GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_REALGMP_H
+#define GCC_REALGMP_H
+
+#include <gmp.h>
+#include <mpfr.h>
+#include <mpc.h>
+#include "real.h"
+
+/* In builtins.c. */
+extern tree do_mpc_arg2 (tree, tree, tree, int, int (*)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t));
+
+/* Convert between MPFR and REAL_VALUE_TYPE. The caller is
+ responsible for initializing and clearing the MPFR parameter. */
+
+extern void real_from_mpfr (REAL_VALUE_TYPE *, mpfr_srcptr, tree, mp_rnd_t);
+extern void mpfr_from_real (mpfr_ptr, const REAL_VALUE_TYPE *, mp_rnd_t);
+
+#endif /* ! GCC_REALGMP_H */
+
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 323633e..b38ab2e 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -1481,10 +1481,10 @@ simplify_const_unary_operation (enum rtx_code code, enum machine_mode mode,
d = t;
break;
case ABS:
- d = REAL_VALUE_ABS (d);
+ d = real_value_abs (&d);
break;
case NEG:
- d = REAL_VALUE_NEGATE (d);
+ d = real_value_negate (&d);
break;
case FLOAT_TRUNCATE:
d = real_value_truncate (mode, d);
diff --git a/gcc/toplev.c b/gcc/toplev.c
index c328719..364a2aa 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see
#include "line-map.h"
#include "input.h"
#include "tree.h"
+#include "realmpfr.h" /* For GMP/MPFR/MPC versions, in print_version. */
#include "version.h"
#include "rtl.h"
#include "tm_p.h"