diff mbox

[fortran] IEEE intrinsic modules (ping)

Message ID ydd38edim3a.fsf@lokon.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth July 7, 2014, 8:56 a.m. UTC
Hi FX,

>> while the i386/amd64 values are the usual ones.  Unfortunately,
>> gcc/fortran/libgfortran.h hardcodes the more common values for
>> GFC_FPE_*, and libgfortran/Makefile.am extracts them from there into
>> fpu-target.inc.  I'm unsure what's the best way to handle this.
>
> No, we don’t hardcode any values (unless I misunderstand what you are
> saying). Look at libgfortran/config/fpu-sysv.h get_fpu_rounding_mode() and
> set_fpu_rounding_mode(): we have two switches, to translate between the
> GFC_FPE_* values and the FP_R* values. So this should work, really.

you're right, of course.

> The only thing I can see is that libgfortran/config/fpu-sysv.h assumes that
> FP_RM and others are macros, checking them with "#ifdef FP_RM”. Is that the
> reason?

It is.

> If so, we might just want to use them unconditionally… unless it creates a
> mess on some other SysV target!

FWIW, those FP_* values are also enum values in IRIX 6.5 <ieeefp.h>, the
only other SysV target I have around.  Seems this file is common between
all of them, so the risk should be manageable.

The following patch does away with the #ifdef stuff and lets all
gfortran.dg/ieee tests PASS on sparc-sun-solaris2.11.

Ok for mainline?

	Rainer


2014-07-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* config/fpu-sysv.h (get_fpu_rounding_mode): Use FP_RN, FP_RP,
	FP_RM, FP_RZ unconditionally.
	(set_fpu_rounding_mode): Likewise.

Comments

FX Coudert July 7, 2014, 9 a.m. UTC | #1
> FWIW, those FP_* values are also enum values in IRIX 6.5 <ieeefp.h>, the
> only other SysV target I have around.  Seems this file is common between
> all of them, so the risk should be manageable.
> 
> The following patch does away with the #ifdef stuff and lets all
> gfortran.dg/ieee tests PASS on sparc-sun-solaris2.11.

Google for a few more targets (BSD, cygwin, etc.) confirms that there is little variation in this part of the file.

Given that your patch fixes a target, and sounds good to both you and me, I suggest you commit it in 24 hours unless someone objects (or you get an actual review).

Also, related to that: could you also confirm that FP_X_INV (and others) are indeed macros, on solaris?


FX
Rainer Orth July 7, 2014, 9:03 a.m. UTC | #2
FX <fxcoudert@gmail.com> writes:

>> FWIW, those FP_* values are also enum values in IRIX 6.5 <ieeefp.h>, the
>> only other SysV target I have around.  Seems this file is common between
>> all of them, so the risk should be manageable.
>> 
>> The following patch does away with the #ifdef stuff and lets all
>> gfortran.dg/ieee tests PASS on sparc-sun-solaris2.11.
>
> Google for a few more targets (BSD, cygwin, etc.) confirms that there is
> little variation in this part of the file.
>
> Given that your patch fixes a target, and sounds good to both you and me, I
> suggest you commit it in 24 hours unless someone objects (or you get an
> actual review).

ok, thanks.

> Also, related to that: could you also confirm that FP_X_INV (and others)
> are indeed macros, on solaris?

I already did, and the rounding mode related ones are the only enums
currently used.  There's also fpclass_t, but that's not used right now.

	Rainer
diff mbox

Patch

diff --git a/libgfortran/config/fpu-sysv.h b/libgfortran/config/fpu-sysv.h
--- a/libgfortran/config/fpu-sysv.h
+++ b/libgfortran/config/fpu-sysv.h
@@ -333,25 +335,14 @@  get_fpu_rounding_mode (void)
 {
   switch (fpgetround ())
     {
-#ifdef FP_RN
       case FP_RN:
 	return GFC_FPE_TONEAREST;
-#endif
-
-#ifdef FP_RP
       case FP_RP:
 	return GFC_FPE_UPWARD;
-#endif
-
-#ifdef FP_RM
       case FP_RM:
 	return GFC_FPE_DOWNWARD;
-#endif
-
-#ifdef FP_RZ
       case FP_RZ:
 	return GFC_FPE_TOWARDZERO;
-#endif
       default:
 	return GFC_FPE_INVALID;
     }
@@ -365,29 +356,18 @@  set_fpu_rounding_mode (int mode)
 
   switch (mode)
     {
-#ifdef FP_RN
       case GFC_FPE_TONEAREST:
 	rnd_mode = FP_RN;
         break;
-#endif
-
-#ifdef FP_RP
       case GFC_FPE_UPWARD:
 	rnd_mode = FP_RP;
         break;
-#endif
-
-#ifdef FP_RM
       case GFC_FPE_DOWNWARD:
 	rnd_mode = FP_RM;
         break;
-#endif
-
-#ifdef FP_RZ
       case GFC_FPE_TOWARDZERO:
 	rnd_mode = FP_RZ;
         break;
-#endif
       default:
 	return;
     }
@@ -401,33 +381,13 @@  support_fpu_rounding_mode (int mode)
   switch (mode)
     {
       case GFC_FPE_TONEAREST:
-#ifdef FP_RN
 	return 1;
-#else
-	return 0;
-#endif
-
       case GFC_FPE_UPWARD:
-#ifdef FP_RP
 	return 1;
-#else
-	return 0;
-#endif
-
       case GFC_FPE_DOWNWARD:
-#ifdef FP_RM
 	return 1;
-#else
-	return 0;
-#endif
-
       case GFC_FPE_TOWARDZERO:
-#ifdef FP_RZ
 	return 1;
-#else
-	return 0;
-#endif
-
       default:
 	return 0;
     }