[flang] Define IEEE_SCALB, IEEE_NEXT_AFTER, IEEE_NEXT_DOWN, IEEE_NEXT_UP

These functions were missing from the standard intrinsic module
IEEE_ARITHMETIC.  IEEE_SCALB is an alias for the standard intrinsic
function SCALE(), and the others are defined as new builtin intrinsic
functions.

Differential Revision: https://reviews.llvm.org/D111253
This commit is contained in:
peter klausler 2021-10-01 14:40:40 -07:00
parent 9ed6b1cd97
commit f5ab4bfb5b
4 changed files with 12 additions and 1 deletions

View File

@ -144,6 +144,7 @@ Expr<Type<TypeCategory::Real, KIND>> 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<T>{std::move(funcRef)};

View File

@ -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},

View File

@ -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, &

View File

@ -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, &