This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 1/2] PR 92463 MPFR modernization in GFortran
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Cc: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Date: Mon, 18 Nov 2019 22:34:49 +0200
- Subject: [PATCH 1/2] PR 92463 MPFR modernization in GFortran
Now that we require a minimum of MPFR 3.1.0+ to build GCC, we can do
some modernization of the MPFR usage in the GFortran frontend.
This patch replaces
1) GMP_RND* with MPFR_RND*
2) mp_exp_t with mpfr_exp_t
3) mp_prec_t with mpfr_prec_t
4) mp_rnd_t with mpfr_rnd_t
gcc/fortran/ChangeLog:
2019-11-18 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/92463
* arith.c (gfc_mpfr_to_mpz): Change mp_exp_t to mpfr_exp_t.
(gfc_check_real_range): Likewise.
* gfortran.h (GFC_RND_MODE): Change GMP_RNDN to MPFR_RNDN.
* module.c (mio_gmp_real): Change mp_exp_t to mpfr_exp_t.
* simplify.c (degrees_f): Change mp_rnd_t to mpfr_rnd_t.
(radians_f): Likewise.
(fullprec_erfc_scaled): Change mp_prec_t to mpfr_prec_t.
(asympt_erfc_scaled): Likewise.
(gfc_simplify_nearest): Change mp_exp_t to mpfr_exp_t, and
GMP_RND* to MPFR_RND*.
---
gcc/fortran/arith.c | 8 ++++----
gcc/fortran/gfortran.h | 2 +-
gcc/fortran/module.c | 2 +-
gcc/fortran/simplify.c | 20 ++++++++++----------
4 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c
index a40163e8a2d..cf480779709 100644
--- a/gcc/fortran/arith.c
+++ b/gcc/fortran/arith.c
@@ -38,7 +38,7 @@ along with GCC; see the file COPYING3. If not see
void
gfc_mpfr_to_mpz (mpz_t z, mpfr_t x, locus *where)
{
- mp_exp_t e;
+ mpfr_exp_t e;
if (mpfr_inf_p (x) || mpfr_nan_p (x))
{
@@ -376,7 +376,7 @@ gfc_check_real_range (mpfr_t p, int kind)
}
else if (mpfr_cmp (q, gfc_real_kinds[i].tiny) < 0)
{
- mp_exp_t emin, emax;
+ mpfr_exp_t emin, emax;
int en;
/* Save current values of emin and emax. */
@@ -396,9 +396,9 @@ gfc_check_real_range (mpfr_t p, int kind)
/* Copy sign if needed. */
if (mpfr_sgn (p) < 0)
- mpfr_neg (p, q, GMP_RNDN);
+ mpfr_neg (p, q, MPFR_RNDN);
else
- mpfr_set (p, q, GMP_RNDN);
+ mpfr_set (p, q, MPFR_RNDN);
}
mpfr_clear (q);
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index e962db59bc5..f4a2b99bdc4 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2130,7 +2130,7 @@ gfc_intrinsic_sym;
#include <mpfr.h>
#include <mpc.h>
-#define GFC_RND_MODE GMP_RNDN
+#define GFC_RND_MODE MPFR_RNDN
#define GFC_MPC_RND_MODE MPC_RNDNN
typedef splay_tree gfc_constructor_base;
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 755f237a0e7..b11a30bea73 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -3343,7 +3343,7 @@ mio_gmp_integer (mpz_t *integer)
static void
mio_gmp_real (mpfr_t *real)
{
- mp_exp_t exponent;
+ mpfr_exp_t exponent;
char *p;
if (iomode == IO_INPUT)
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 0461d31cd88..a5c940ca2d5 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -1768,7 +1768,7 @@ simplify_trig_call (gfc_expr *icall)
/* Convert a floating-point number from radians to degrees. */
static void
-degrees_f (mpfr_t x, mp_rnd_t rnd_mode)
+degrees_f (mpfr_t x, mpfr_rnd_t rnd_mode)
{
mpfr_t tmp;
mpfr_init (tmp);
@@ -1791,7 +1791,7 @@ degrees_f (mpfr_t x, mp_rnd_t rnd_mode)
/* Convert a floating-point number from degrees to radians. */
static void
-radians_f (mpfr_t x, mp_rnd_t rnd_mode)
+radians_f (mpfr_t x, mpfr_rnd_t rnd_mode)
{
mpfr_t tmp;
mpfr_init (tmp);
@@ -2681,7 +2681,7 @@ gfc_simplify_erfc (gfc_expr *x)
static void
fullprec_erfc_scaled (mpfr_t res, mpfr_t arg)
{
- mp_prec_t prec;
+ mpfr_prec_t prec;
mpfr_t a, b;
prec = mpfr_get_default_prec ();
@@ -2718,7 +2718,7 @@ asympt_erfc_scaled (mpfr_t res, mpfr_t arg)
{
mpfr_t sum, x, u, v, w, oldsum, sumtrunc;
mpz_t num;
- mp_prec_t prec;
+ mpfr_prec_t prec;
unsigned i;
prec = mpfr_get_default_prec ();
@@ -5914,7 +5914,7 @@ gfc_expr *
gfc_simplify_nearest (gfc_expr *x, gfc_expr *s)
{
gfc_expr *result;
- mp_exp_t emin, emax;
+ mpfr_exp_t emin, emax;
int kind;
if (x->expr_type != EXPR_CONSTANT || s->expr_type != EXPR_CONSTANT)
@@ -5928,20 +5928,20 @@ gfc_simplify_nearest (gfc_expr *x, gfc_expr *s)
/* Set emin and emax for the current model number. */
kind = gfc_validate_kind (BT_REAL, x->ts.kind, 0);
- mpfr_set_emin ((mp_exp_t) gfc_real_kinds[kind].min_exponent -
+ mpfr_set_emin ((mpfr_exp_t) gfc_real_kinds[kind].min_exponent -
mpfr_get_prec(result->value.real) + 1);
- mpfr_set_emax ((mp_exp_t) gfc_real_kinds[kind].max_exponent - 1);
- mpfr_check_range (result->value.real, 0, GMP_RNDU);
+ mpfr_set_emax ((mpfr_exp_t) gfc_real_kinds[kind].max_exponent - 1);
+ mpfr_check_range (result->value.real, 0, MPFR_RNDU);
if (mpfr_sgn (s->value.real) > 0)
{
mpfr_nextabove (result->value.real);
- mpfr_subnormalize (result->value.real, 0, GMP_RNDU);
+ mpfr_subnormalize (result->value.real, 0, MPFR_RNDU);
}
else
{
mpfr_nextbelow (result->value.real);
- mpfr_subnormalize (result->value.real, 0, GMP_RNDD);
+ mpfr_subnormalize (result->value.real, 0, MPFR_RNDD);
}
mpfr_set_emin (emin);
--
2.17.1