Attached is an updated patch, where I'm adding -fdefault-real-10
according to Steve's suggestion. As with -fdefault-real-8 and
-fdefault-real-16, I'm choosing to set the double kind to 16 in this
case. Also I'm renaming flag_default_real to flag_default_real_8 (for
symmetry reasons and to make the code more readable). Finally I'm
removing the restriction that -fdefault-double-8 must occur together
with -fdefault-real-8. It may be useful on its own and should be
combinable with the new flags.

Ok for trunk?

Cheers,
Janus



2017-09-18 19:57 GMT+02:00 Janus Weil <ja...@gcc.gnu.org>:
> 2017-09-18 16:08 GMT+02:00 Steve Kargl <s...@troutmask.apl.washington.edu>:
>> On Mon, Sep 18, 2017 at 09:02:22AM +0200, Janus Weil wrote:
>>> Hi Steve,
>>>
>>> >> attached is a (technically) simple patch that implements the compiler
>>> >> flag "-fdefault-real-16" for gfortran.
>>> >
>>> > What about -fdefault-real-10?  If you're going to add bloat to the
>>> > compiler, then you might as well to it right.
>>>
>>> well, yeah. If my only aim was to add bloat to the compiler out of
>>> plain boredom and nastiness, then I might as well add
>>> -fdefault-real-37. But I don't think that would be very useful.
>>
>> Why?  One gets 11-bits of additional precision (on most platforms)
>> and a significant increase in the exponent range (+- ~1024 to
>> +- ~16384).  REAL(10) maps to hardware floating point, which is
>> faster than software quad precision.
>
> Well, ok. If adding -fdefault-real-10 was a serious suggestion from
> your side (which was not so easy to tell through all the sarcasm), I
> can surely add that as well.
>
> Cheers,
> Janus
Index: gcc/fortran/invoke.texi
===================================================================
--- gcc/fortran/invoke.texi     (revision 252892)
+++ gcc/fortran/invoke.texi     (working copy)
@@ -119,8 +119,8 @@ by type.  Explanations are in the following sectio
 @gccoptlist{-fall-intrinsics -fbackslash -fcray-pointer -fd-lines-as-code @gol
 -fd-lines-as-comments @gol
 -fdec -fdec-structure -fdec-intrinsic-ints -fdec-static -fdec-math @gol
--fdefault-double-8 -fdefault-integer-8 @gol
--fdefault-real-8 -fdollar-ok -ffixed-line-length-@var{n} @gol
+-fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 @gol
+-fdefault-real-10 -fdefault-real-16 -fdollar-ok -ffixed-line-length-@var{n} 
@gol
 -ffixed-line-length-none -ffree-form -ffree-line-length-@var{n} @gol
 -ffree-line-length-none -fimplicit-none -finteger-4-integer-8 @gol
 -fmax-identifier-length -fmodule-private -ffixed-form -fno-range-check @gol
@@ -404,6 +404,22 @@ the default width of @code{DOUBLE PRECISION} to 16
 @code{-fdefault-double-8} is given, too. Unlike @option{-freal-4-real-8},
 it does not promote variables with explicit kind declaration.
 
+@item -fdefault-real-10
+@opindex @code{fdefault-real-10}
+Set the default real type to a 10 byte wide type. This option also affects
+the kind of non-double real constants like @code{1.0}, and does promote
+the default width of @code{DOUBLE PRECISION} to 16 bytes if possible, unless
+@code{-fdefault-double-8} is given. Unlike @option{-freal-4-real-10},
+it does not promote variables with explicit kind declaration.
+
+@item -fdefault-real-16
+@opindex @code{fdefault-real-16}
+Set the default real type to a 16 byte wide type. This option also affects
+the kind of non-double real constants like @code{1.0}, and does promote
+the default width of @code{DOUBLE PRECISION} to 16 bytes if possible, unless
+@code{-fdefault-double-8} is given. Unlike @option{-freal-4-real-16},
+it does not promote variables with explicit kind declaration.
+
 @item -fdefault-double-8
 @opindex @code{fdefault-double-8}
 Set the @code{DOUBLE PRECISION} type to an 8 byte wide type.  Do nothing if 
this
Index: gcc/fortran/lang.opt
===================================================================
--- gcc/fortran/lang.opt        (revision 252892)
+++ gcc/fortran/lang.opt        (working copy)
@@ -457,9 +457,17 @@ Fortran Var(flag_default_integer)
 Set the default integer kind to an 8 byte wide type.
 
 fdefault-real-8
-Fortran Var(flag_default_real)
+Fortran Var(flag_default_real_8)
 Set the default real kind to an 8 byte wide type.
 
+fdefault-real-10
+Fortran Var(flag_default_real_10)
+Set the default real kind to an 10 byte wide type.
+
+fdefault-real-16
+Fortran Var(flag_default_real_16)
+Set the default real kind to an 16 byte wide type.
+
 fdollar-ok
 Fortran Var(flag_dollar_ok)
 Allow dollar signs in entity names.
Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c        (revision 252892)
+++ gcc/fortran/module.c        (working copy)
@@ -6741,7 +6741,7 @@ use_iso_fortran_env_module (void)
                                   "standard", symbol[i].name, &u->where))
                continue;
 
-             if ((flag_default_integer || flag_default_real)
+             if ((flag_default_integer || flag_default_real_8)
                  && symbol[i].id == ISOFORTRANENV_NUMERIC_STORAGE_SIZE)
                gfc_warning_now (0, "Use of the NUMERIC_STORAGE_SIZE named "
                                 "constant from intrinsic module "
@@ -6808,7 +6808,7 @@ use_iso_fortran_env_module (void)
          if ((gfc_option.allow_std & symbol[i].standard) == 0)
            continue;
 
-         if ((flag_default_integer || flag_default_real)
+         if ((flag_default_integer || flag_default_real_8)
              && symbol[i].id == ISOFORTRANENV_NUMERIC_STORAGE_SIZE)
            gfc_warning_now (0,
                             "Use of the NUMERIC_STORAGE_SIZE named constant "
Index: gcc/fortran/trans-types.c
===================================================================
--- gcc/fortran/trans-types.c   (revision 252892)
+++ gcc/fortran/trans-types.c   (working copy)
@@ -530,7 +530,7 @@ gfc_init_kinds (void)
     }
 
   /* Choose the default real kind.  Again, we choose 4 when possible.  */
-  if (flag_default_real)
+  if (flag_default_real_8)
     {
       if (!saw_r8)
        gfc_fatal_error ("REAL(KIND=8) is not available for "
@@ -538,6 +538,22 @@ gfc_init_kinds (void)
 
       gfc_default_real_kind = 8;
     }
+  else if (flag_default_real_10)
+  {
+    if (!saw_r10)
+      gfc_fatal_error ("REAL(KIND=10) is not available for "
+                       "%<-fdefault-real-10%> option");
+
+    gfc_default_real_kind = 10;
+  }
+  else if (flag_default_real_16)
+  {
+    if (!saw_r16)
+      gfc_fatal_error ("REAL(KIND=16) is not available for "
+                       "%<-fdefault-real-16%> option");
+
+    gfc_default_real_kind = 16;
+  }
   else if (flag_real4_kind == 8)
   {
     if (!saw_r8)
@@ -571,13 +587,10 @@ gfc_init_kinds (void)
      are specified, we use kind=8, if it's available.  If -fdefault-real is
      specified without -fdefault-double, we use kind=16, if it's available.
      Otherwise we do not change anything.  */
-  if (flag_default_double && !flag_default_real)
-    gfc_fatal_error ("Use of %<-fdefault-double-8%> requires "
-                    "%<-fdefault-real-8%>");
-
-  if (flag_default_real && flag_default_double && saw_r8)
+  if (flag_default_double && saw_r8)
     gfc_default_double_kind = 8;
-  else if (flag_default_real && saw_r16)
+  else if ((flag_default_real_8 || flag_default_real_10 || 
flag_default_real_16)
+          && saw_r16)
     gfc_default_double_kind = 16;
   else if (flag_real8_kind == 4)
     {

Reply via email to