diff options
author | Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2022-08-31 15:22:50 +0200 |
---|---|---|
committer | Francois-Xavier Coudert <fxcoudert@gmail.com> | 2022-09-10 12:11:37 +0200 |
commit | 7c4c65d11469d29403d5a88316445ec95cd3c3f8 (patch) | |
tree | 550c3386757612d2dd7a7f5ec15086f7c7c3c92d /libgfortran | |
parent | 861d1a11c0a052ddb3851950d3c0db86b320646d (diff) | |
download | gcc-7c4c65d11469d29403d5a88316445ec95cd3c3f8.zip gcc-7c4c65d11469d29403d5a88316445ec95cd3c3f8.tar.gz gcc-7c4c65d11469d29403d5a88316445ec95cd3c3f8.tar.bz2 |
fortran: Add IEEE_SIGNBIT and IEEE_FMA functions
The functions are added to the IEEE_ARITHMETIC module, but
are entirely expanded in the front-end, using GCC built-ins.
2022-08-31 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/95644
gcc/fortran/
* f95-lang.cc (gfc_init_builtin_functions): Declare FMA
built-ins.
* mathbuiltins.def: Declare FMA built-ins.
* trans-intrinsic.cc (conv_intrinsic_ieee_fma): New function.
(conv_intrinsic_ieee_signbit): New function.
(gfc_build_intrinsic_lib_fndecls): Add cases for FMA and
SIGNBIT.
gcc/testsuite/
* gfortran.dg/ieee/fma_1.f90: New test.
* gfortran.dg/ieee/signbit_1.f90: New test.
libgfortran/
* ieee/ieee_arithmetic.F90: Add IEEE_SIGNBIT and IEEE_FMA.
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ieee/ieee_arithmetic.F90 | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/libgfortran/ieee/ieee_arithmetic.F90 b/libgfortran/ieee/ieee_arithmetic.F90 index c8ef3e2..4e01aa5 100644 --- a/libgfortran/ieee/ieee_arithmetic.F90 +++ b/libgfortran/ieee/ieee_arithmetic.F90 @@ -343,6 +343,39 @@ UNORDERED_MACRO(4,4) end interface public :: IEEE_UNORDERED + ! IEEE_FMA + + interface + elemental real(kind=4) function _gfortran_ieee_fma_4 (A, B, C) + real(kind=4), intent(in) :: A, B, C + end function + elemental real(kind=8) function _gfortran_ieee_fma_8 (A, B, C) + real(kind=8), intent(in) :: A, B, C + end function +#ifdef HAVE_GFC_REAL_10 + elemental real(kind=10) function _gfortran_ieee_fma_10 (A, B, C) + real(kind=10), intent(in) :: A, B, C + end function +#endif +#ifdef HAVE_GFC_REAL_16 + elemental real(kind=16) function _gfortran_ieee_fma_16 (A, B, C) + real(kind=16), intent(in) :: A, B, C + end function +#endif + end interface + + interface IEEE_FMA + procedure & +#ifdef HAVE_GFC_REAL_16 + _gfortran_ieee_fma_16, & +#endif +#ifdef HAVE_GFC_REAL_10 + _gfortran_ieee_fma_10, & +#endif + _gfortran_ieee_fma_8, _gfortran_ieee_fma_4 + end interface + public :: IEEE_FMA + ! IEEE_LOGB interface @@ -702,6 +735,39 @@ REM_MACRO(4,4,4) end interface public :: IEEE_SCALB + ! IEEE_SIGNBIT + + interface + elemental logical function _gfortran_ieee_signbit_4 (X) + real(kind=4), intent(in) :: X + end function + elemental logical function _gfortran_ieee_signbit_8 (X) + real(kind=8), intent(in) :: X + end function +#ifdef HAVE_GFC_REAL_10 + elemental logical function _gfortran_ieee_signbit_10 (X) + real(kind=10), intent(in) :: X + end function +#endif +#ifdef HAVE_GFC_REAL_16 + elemental logical function _gfortran_ieee_signbit_16 (X) + real(kind=16), intent(in) :: X + end function +#endif + end interface + + interface IEEE_SIGNBIT + procedure & +#ifdef HAVE_GFC_REAL_16 + _gfortran_ieee_signbit_16, & +#endif +#ifdef HAVE_GFC_REAL_10 + _gfortran_ieee_signbit_10, & +#endif + _gfortran_ieee_signbit_8, _gfortran_ieee_signbit_4 + end interface + public :: IEEE_SIGNBIT + ! IEEE_VALUE interface IEEE_VALUE |