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 <[email protected]>
* config/fpu-sysv.h (get_fpu_rounding_mode): Use FP_RN, FP_RP,
FP_RM, FP_RZ unconditionally.
(set_fpu_rounding_mode): Likewise.
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;
}
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University