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 /gcc | |
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 'gcc')
-rw-r--r-- | gcc/fortran/libgfortran.h | 1 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/ieee/rounding_2.f90 | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/fortran/libgfortran.h b/gcc/fortran/libgfortran.h index ef06194..79a8c2f 100644 --- a/gcc/fortran/libgfortran.h +++ b/gcc/fortran/libgfortran.h @@ -60,6 +60,7 @@ along with GCC; see the file COPYING3. If not see #define GFC_FPE_TONEAREST 2 #define GFC_FPE_TOWARDZERO 3 #define GFC_FPE_UPWARD 4 +#define GFC_FPE_AWAY 5 /* Size of the buffer required to store FPU state for any target. In particular, this has to be larger than fenv_t on all glibc targets. diff --git a/gcc/testsuite/gfortran.dg/ieee/rounding_2.f90 b/gcc/testsuite/gfortran.dg/ieee/rounding_2.f90 new file mode 100644 index 0000000..8af6c91 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/ieee/rounding_2.f90 @@ -0,0 +1,20 @@ +! { dg-do run } + + use, intrinsic :: ieee_arithmetic + implicit none + + real :: sx1, sx2, sx3 + double precision :: dx1, dx2, dx3 + + ! IEEE_AWAY was added in Fortran 2018 and not supported by any target + ! at the moment. Just check we can query for its support. + + ! We should support at least C float and C double types + if (ieee_support_rounding(ieee_away) & + .or. ieee_support_rounding(ieee_away, 0.) & + .or. ieee_support_rounding(ieee_away, 0.d0)) then + print *, "If a target / libc now supports this, we need to add a proper check!" + stop 1 + end if + +end |