This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: REAL(16) (was Re: [Patch, Fortran] Two minor tweaks for type-bound procedure parsing)
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Dominique Dhumieres <dominiq at lps dot ens dot fr>
- Cc: fortran at gcc dot gnu dot org
- Date: Mon, 25 Aug 2008 15:15:42 -0700
- Subject: Re: REAL(16) (was Re: [Patch, Fortran] Two minor tweaks for type-bound procedure parsing)
- References: <20080825215016.A4A8C3BE85@mailhost.lps.ens.fr>
On Mon, Aug 25, 2008 at 11:50:16PM +0200, Dominique Dhumieres wrote:
> > REAL(16) needs to be done in software -- on x86, x86-64 -- as it is not
> > supported in hardware; if you want to use more than REAL(8) on x86,
> > x86-64 you can use REAL(10). Or you use a system such as PowerPC which
> > supports REAL(16) in silicon.
>
> As far as I can tell, the ifc implementation is a "real" one where the
> full 128 bits are used to code the real number. So far i did not have the
> time to play with it.
>
> Now concerning gfortran and since gcc requires gmp and mpfr, how difficult
> (efficient) would it be to use these libraries to implement REAL(xxx)?
>
Getting +, -, *, and / working is almost trivial. The hard part is
getting REAL(16) working in all the fun corners of the standard
as well as getting IO working. Here's a start where one may need
to distinguish between hardware FP and software emulation.
Index: gfortran.h
===================================================================
--- gfortran.h (revision 139565)
+++ gfortran.h (working copy)
@@ -1592,6 +1592,7 @@ typedef struct
unsigned int c_float : 1;
unsigned int c_double : 1;
unsigned int c_long_double : 1;
+ unsigned int emulated : 1;
}
gfc_real_info;
Index: trans-types.c
===================================================================
--- trans-types.c (revision 139565)
+++ trans-types.c (working copy)
@@ -78,7 +78,7 @@ gfc_logical_info gfc_logical_kinds[MAX_I
static GTY(()) tree gfc_integer_types[MAX_INT_KINDS + 1];
static GTY(()) tree gfc_logical_types[MAX_INT_KINDS + 1];
-#define MAX_REAL_KINDS 5
+#define MAX_REAL_KINDS 6
gfc_real_info gfc_real_kinds[MAX_REAL_KINDS + 1];
static GTY(()) tree gfc_real_types[MAX_REAL_KINDS + 1];
static GTY(()) tree gfc_complex_types[MAX_REAL_KINDS + 1];
@@ -371,6 +371,7 @@ gfc_init_kinds (void)
gfc_real_kinds[r_index].digits = fmt->p;
gfc_real_kinds[r_index].min_exponent = fmt->emin;
gfc_real_kinds[r_index].max_exponent = fmt->emax;
+ gfc_real_kinds[r_index].emulated = 0;
if (fmt->pnan < fmt->p)
/* This is an IBM extended double format (or the MIPS variant)
made up of two IEEE doubles. The value of the long double is
@@ -384,6 +385,17 @@ gfc_init_kinds (void)
r_index += 1;
}
+ /* Set up emulation of REAL(16). */
+ if (saw_r16 == false)
+ {
+ gfc_real_kinds[r_index].kind = 16;
+ gfc_real_kinds[r_index].radix = 2;
+ gfc_real_kinds[r_index].digits = 113;
+ gfc_real_kinds[r_index].min_exponent = -16382;
+ gfc_real_kinds[r_index].max_exponent = 16383;
+ gfc_real_kinds[r_index].emulated = 1;
+ }
+
/* Choose the default integer kind. We choose 4 unless the user
directs us otherwise. */
if (gfc_option.flag_default_integer)
--
Steve