diff --git a/flang/lib/Evaluate/fold-real.cpp b/flang/lib/Evaluate/fold-real.cpp index 93b3ce20a75b..f73b733dce6e 100644 --- a/flang/lib/Evaluate/fold-real.cpp +++ b/flang/lib/Evaluate/fold-real.cpp @@ -144,6 +144,7 @@ Expr> FoldIntrinsicFunction( } // TODO: dim, dot_product, fraction, matmul, // modulo, nearest, norm2, rrspacing, scale, + // __builtin_next_after/down/up, // set_exponent, spacing, transfer, // bessel_jn (transformational) and bessel_yn (transformational) return Expr{std::move(funcRef)}; diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp index 99329ff795fc..2324b780f8e5 100644 --- a/flang/lib/Evaluate/intrinsics.cpp +++ b/flang/lib/Evaluate/intrinsics.cpp @@ -690,7 +690,7 @@ static const IntrinsicInterface genericIntrinsicFunction[]{ {{"a", ExtensibleDerived, Rank::anyOrAssumedRank}, {"b", ExtensibleDerived, Rank::anyOrAssumedRank}}, DefaultLogical, Rank::scalar, IntrinsicClass::inquiryFunction}, - {"scale", {{"x", SameReal}, {"i", AnyInt}}, SameReal}, + {"scale", {{"x", SameReal}, {"i", AnyInt}}, SameReal}, // == IEEE_SCALB() {"scan", {{"string", SameChar}, {"set", SameChar}, {"back", AnyLogical, Rank::elemental, Optionality::optional}, @@ -791,6 +791,9 @@ static const IntrinsicInterface genericIntrinsicFunction[]{ DefaultingKIND}, KINDInt}, {"__builtin_ieee_is_nan", {{"a", AnyFloating}}, DefaultLogical}, + {"__builtin_ieee_next_after", {{"x", SameReal}, {"y", AnyReal}}, SameReal}, + {"__builtin_ieee_next_down", {{"x", SameReal}}, SameReal}, + {"__builtin_ieee_next_up", {{"x", SameReal}}, SameReal}, {"__builtin_ieee_selected_real_kind", // alias for selected_real_kind {{"p", AnyInt, Rank::scalar}, {"r", AnyInt, Rank::scalar, Optionality::optional}, diff --git a/flang/module/__fortran_builtins.f90 b/flang/module/__fortran_builtins.f90 index f76e648dc2a8..5d7a0008ec36 100644 --- a/flang/module/__fortran_builtins.f90 +++ b/flang/module/__fortran_builtins.f90 @@ -42,6 +42,9 @@ module __Fortran_builtins procedure(type(__builtin_c_ptr)) :: __builtin_c_loc intrinsic :: __builtin_ieee_is_nan + intrinsic :: __builtin_ieee_next_after, __builtin_ieee_next_down, & + __builtin_ieee_next_up + intrinsic :: scale ! for ieee_scalb intrinsic :: __builtin_ieee_selected_real_kind intrinsic :: __builtin_ieee_support_datatype, & __builtin_ieee_support_denormal, __builtin_ieee_support_divide, & diff --git a/flang/module/ieee_arithmetic.f90 b/flang/module/ieee_arithmetic.f90 index 21fc907ec88b..1d7c32e7e116 100644 --- a/flang/module/ieee_arithmetic.f90 +++ b/flang/module/ieee_arithmetic.f90 @@ -11,6 +11,10 @@ module ieee_arithmetic use __Fortran_builtins, only: & ieee_is_nan => __builtin_ieee_is_nan, & + ieee_next_after => __builtin_ieee_next_after, & + ieee_next_down => __builtin_ieee_next_down, & + ieee_next_up => __builtin_ieee_next_up, & + ieee_scalb => scale, & ieee_selected_real_kind => __builtin_ieee_selected_real_kind, & ieee_support_datatype => __builtin_ieee_support_datatype, & ieee_support_denormal => __builtin_ieee_support_denormal, &