Commit c9d4cc5d by Janne Blomqvist

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-20  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*.

From-SVN: r278523
parent 64eb1c82
2019-11-20 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*.
2019-11-15 Paul Thomas <pault@gcc.gnu.org>
PR fortran/69654
......
......@@ -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);
......
......@@ -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;
......
......@@ -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)
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment