diff options
author | Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2022-08-31 19:15:20 +0200 |
---|---|---|
committer | Francois-Xavier Coudert <fxcoudert@gmail.com> | 2022-09-19 13:03:28 +0200 |
commit | 4637a1d293c978816ad622ba33e3a32a78640edd (patch) | |
tree | f7ab4b7bcfe646712d86ef182fa888f5783c65ff /libgfortran/config | |
parent | 0b5b8ac5cb7fe92dd17ae8bd7de84640daa59e84 (diff) | |
download | gcc-4637a1d293c978816ad622ba33e3a32a78640edd.zip gcc-4637a1d293c978816ad622ba33e3a32a78640edd.tar.gz gcc-4637a1d293c978816ad622ba33e3a32a78640edd.tar.bz2 |
Fortran: F2018 rounding modes changes
Add the new IEEE_AWAY rounding mode. It is unsupported on all known
targets, but could be supported by glibc and AIX as part of the C2x
proposal. Testing for now is minimal.
Add the optional RADIX argument to IEEE_SET_ROUNDING_MODE and
IEEE_GET_ROUNDING_MODE. It is unused for now, because we do not
support radices other than 2.
2022-08-31 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
gcc/fortran/
* libgfortran.h: Declare GFC_FPE_AWAY.
gcc/testsuite/
* gfortran.dg/ieee/rounding_2.f90: New test.
libgfortran/
* ieee/ieee_arithmetic.F90: Add RADIX argument to
IEEE_SET_ROUNDING_MODE and IEEE_GET_ROUNDING_MODE.
* config/fpu-387.h: Add IEEE_AWAY mode.
* config/fpu-aarch64.h: Add IEEE_AWAY mode.
* config/fpu-aix.h: Add IEEE_AWAY mode.
* config/fpu-generic.h: Add IEEE_AWAY mode.
* config/fpu-glibc.h: Add IEEE_AWAY mode.
* config/fpu-sysv.h: Add IEEE_AWAY mode.
Diffstat (limited to 'libgfortran/config')
-rw-r--r-- | libgfortran/config/fpu-387.h | 7 | ||||
-rw-r--r-- | libgfortran/config/fpu-aarch64.h | 7 | ||||
-rw-r--r-- | libgfortran/config/fpu-aix.h | 22 | ||||
-rw-r--r-- | libgfortran/config/fpu-generic.h | 11 | ||||
-rw-r--r-- | libgfortran/config/fpu-glibc.h | 18 | ||||
-rw-r--r-- | libgfortran/config/fpu-sysv.h | 7 |
6 files changed, 62 insertions, 10 deletions
diff --git a/libgfortran/config/fpu-387.h b/libgfortran/config/fpu-387.h index fd00dab..e2f4a7d 100644 --- a/libgfortran/config/fpu-387.h +++ b/libgfortran/config/fpu-387.h @@ -418,9 +418,12 @@ get_fpu_rounding_mode (void) } int -support_fpu_rounding_mode (int mode __attribute__((unused))) +support_fpu_rounding_mode (int mode) { - return 1; + if (mode == GFC_FPE_AWAY) + return 0; + else + return 1; } void diff --git a/libgfortran/config/fpu-aarch64.h b/libgfortran/config/fpu-aarch64.h index 3a2e4ba..4789390 100644 --- a/libgfortran/config/fpu-aarch64.h +++ b/libgfortran/config/fpu-aarch64.h @@ -293,9 +293,12 @@ set_fpu_rounding_mode (int round) int -support_fpu_rounding_mode (int mode __attribute__((unused))) +support_fpu_rounding_mode (int mode) { - return 1; + if (mode == GFC_FPE_AWAY) + return 0; + else + return 1; } diff --git a/libgfortran/config/fpu-aix.h b/libgfortran/config/fpu-aix.h index c643874..fb1ac80 100644 --- a/libgfortran/config/fpu-aix.h +++ b/libgfortran/config/fpu-aix.h @@ -320,6 +320,11 @@ get_fpu_rounding_mode (void) return GFC_FPE_TOWARDZERO; #endif +#ifdef FE_TONEARESTFROMZERO + case FE_TONEARESTFROMZERO: + return GFC_FPE_AWAY; +#endif + default: return 0; /* Should be unreachable. */ } @@ -357,8 +362,14 @@ set_fpu_rounding_mode (int mode) break; #endif +#ifdef FE_TONEARESTFROMZERO + case GFC_FPE_AWAY: + rnd_mode = FE_TONEARESTFROMZERO; + break; +#endif + default: - return; /* Should be unreachable. */ + return; } fesetround (rnd_mode); @@ -398,8 +409,15 @@ support_fpu_rounding_mode (int mode) return 0; #endif + case GFC_FPE_AWAY: +#ifdef FE_TONEARESTFROMZERO + return 1; +#else + return 0; +#endif + default: - return 0; /* Should be unreachable. */ + return 0; } } diff --git a/libgfortran/config/fpu-generic.h b/libgfortran/config/fpu-generic.h index 3b62228..9e976a8 100644 --- a/libgfortran/config/fpu-generic.h +++ b/libgfortran/config/fpu-generic.h @@ -66,9 +66,16 @@ get_fpu_except_flags (void) int get_fpu_rounding_mode (void) -{ +{ + return 0; +} + + +int +support_fpu_rounding_mode (int mode __attribute__((unused))) +{ return 0; -} +} void diff --git a/libgfortran/config/fpu-glibc.h b/libgfortran/config/fpu-glibc.h index 265ef69..f34b696 100644 --- a/libgfortran/config/fpu-glibc.h +++ b/libgfortran/config/fpu-glibc.h @@ -342,6 +342,11 @@ get_fpu_rounding_mode (void) return GFC_FPE_TOWARDZERO; #endif +#ifdef FE_TONEARESTFROMZERO + case FE_TONEARESTFROMZERO: + return GFC_FPE_AWAY; +#endif + default: return 0; /* Should be unreachable. */ } @@ -379,6 +384,12 @@ set_fpu_rounding_mode (int mode) break; #endif +#ifdef FE_TONEARESTFROMZERO + case GFC_FPE_AWAY: + rnd_mode = FE_TONEARESTFROMZERO; + break; +#endif + default: return; /* Should be unreachable. */ } @@ -420,6 +431,13 @@ support_fpu_rounding_mode (int mode) return 0; #endif + case GFC_FPE_AWAY: +#ifdef FE_TONEARESTFROMZERO + return 1; +#else + return 0; +#endif + default: return 0; /* Should be unreachable. */ } diff --git a/libgfortran/config/fpu-sysv.h b/libgfortran/config/fpu-sysv.h index 4de3852..4681322 100644 --- a/libgfortran/config/fpu-sysv.h +++ b/libgfortran/config/fpu-sysv.h @@ -374,9 +374,12 @@ set_fpu_rounding_mode (int mode) int -support_fpu_rounding_mode (int mode __attribute__((unused))) +support_fpu_rounding_mode (int mode) { - return 1; + if (mode == GFC_FPE_AWAY) + return 0; + else + return 1; } |