This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [fortran, patch] IEEE intrinsic modules (ping)
- From: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- To: FX <fxcoudert at gmail dot com>
- Cc: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>, Tobias Burnus <burnus at net-b dot de>, "gcc-patches\ at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Fortran List <fortran at gcc dot gnu dot org>
- Date: Mon, 07 Jul 2014 10:56:09 +0200
- Subject: Re: [fortran, patch] IEEE intrinsic modules (ping)
- Authentication-results: sourceware.org; auth=none
- References: <20140623192339 dot GA25679 at troutmask dot apl dot washington dot edu> <20140623202005 dot GA31501 at troutmask dot apl dot washington dot edu> <6CA4B0CC-09B5-439C-A766-B27664B2DB12 at gmail dot com> <20140624164936 dot GA38820 at troutmask dot apl dot washington dot edu> <20140624174601 dot GA39016 at troutmask dot apl dot washington dot edu> <53A9C4AF dot 6020700 at net-b dot de> <20140624191947 dot GA70297 at troutmask dot apl dot washington dot edu> <DB1AFC53-68AF-495C-9083-135F73FBD0AC at gmail dot com> <20140624202327 dot GA81301 at troutmask dot apl dot washington dot edu> <4006CA91-3464-4A9A-A228-66FA6C02673B at gmail dot com> <20140624203658 dot GA81560 at troutmask dot apl dot washington dot edu> <yddegxzk05e dot fsf at CeBiTec dot Uni-Bielefeld dot DE> <AB6EFD49-7F94-4652-9B60-E27C47FDB2FD at gmail dot com> <ydd7g3pinal dot fsf at lokon dot CeBiTec dot Uni-Bielefeld dot DE> <98E798A9-5DD5-40ED-B487-E1A6B77B66A9 at gmail dot com>
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.
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