This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch to restrict floating point types in Fortran


I was wondering what the Fortran maintainers think about this patch.  On
IA64 HP-UX (in C) we support 5 floating point types; float, double, long
double (aka __float128), __float80, and __fpreg.  The Fortran library
is really only set up to handle the fortran equivelents of float, double,
and long double.  This patch restricts the Fortran compiler to only
recognizing those floating point types.

I thought about using scalar_mode_supported_p to do this, saying that on
HP-UX, XFmode (__float80) and RFmode (__fpreg) are not supported if the
current language is Fortran but I have plans to use RFmode in the
backend in the future (even in cases where the user did not specify an
RFmode variables) so I don't want to say that RFmode is not available at
all in Fortran, it is just not available to users and since the
scalar_mode_supported_p function is used in other contexts, I didn't
really want to change it.

Anyway, since the Fortran library is written in a way that only float,
double, and long double are supported it seemed reasonable to hardcode
that check in.

I have tested it on IA64 HP-UX and Linux and on HPPA HP-UX, it caused no
regressions and fixed some testsuite failures on IA64 HP-UX.

Comments?  OK to checkin?

Steve Ellcey
sje@cup.hp.com

2005-09-28  Steve Ellcey  <sje@cup.hp.com>

	* fortran/trans-types.c (gfc_init_kinds): Only pass float, double,
	and long double floating point types through to Fortran compiler.

*** gcc.orig/gcc/fortran/trans-types.c	Wed Sep 28 12:10:18 2005
--- gcc/gcc/fortran/trans-types.c	Wed Sep 28 12:10:02 2005
*************** gfc_init_kinds (void)
*** 152,157 ****
--- 152,165 ----
        if (!targetm.scalar_mode_supported_p (mode))
  	continue;
  
+       /* Only let float/double/long double go through because the fortran
+ 	 library assumes these are the only floating point types.  */
+ 
+       if (mode != TYPE_MODE (float_type_node)
+ 	  && (mode != TYPE_MODE (double_type_node))
+           && (mode != TYPE_MODE (long_double_type_node)))
+ 	continue;
+ 
        /* Let the kind equal the precision divided by 8, rounding up.  Again,
  	 this insulates the programmer from the underlying byte size.
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]