Skip to content

[flang][runtime] Use fallback bessel functions when not available in libm #101437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions flang/runtime/Float128Math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,26 @@ elseif (HAVE_LDBL_MANT_DIG_113)
# We can use 'long double' versions from libc.
check_library_exists(m sinl "" FOUND_LIBM)
if (FOUND_LIBM)
check_cxx_source_compiles(
"#include <cmath>
int main() {
int n = 0;
long double x = 1;
long double Y0 = y0l(x);
long double Y1 = y1l(x);
long double Yn = ynl(n,x);
long double J0 = j0l(x);
long double J1 = j1l(x);
long double Jn = jnl(n,x);
return 0;
}
"
FOUND_LIBM_BESSEL)
if (FOUND_LIBM_BESSEL)
target_compile_definitions(FortranFloat128MathILib INTERFACE
HAS_LIBM_BESSEL
)
endif()
target_compile_definitions(FortranFloat128MathILib INTERFACE
HAS_LIBM
)
Expand Down
4 changes: 4 additions & 0 deletions flang/runtime/Float128Math/math-entries.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,11 @@ DEFINE_SIMPLE_ALIAS(Hypot, std::hypot)
DEFINE_SIMPLE_ALIAS(Ilogb, std::ilogb)
DEFINE_SIMPLE_ALIAS(Isinf, std::isinf)
DEFINE_SIMPLE_ALIAS(Isnan, std::isnan)
#ifdef HAS_LIBM_BESSEL
DEFINE_SIMPLE_ALIAS(J0, j0l)
DEFINE_SIMPLE_ALIAS(J1, j1l)
DEFINE_SIMPLE_ALIAS(Jn, jnl)
#endif
DEFINE_SIMPLE_ALIAS(Ldexp, std::ldexp)
DEFINE_SIMPLE_ALIAS(Lgamma, std::lgamma)
DEFINE_SIMPLE_ALIAS(Llround, std::llround)
Expand All @@ -204,9 +206,11 @@ DEFINE_SIMPLE_ALIAS(Tan, std::tan)
DEFINE_SIMPLE_ALIAS(Tanh, std::tanh)
DEFINE_SIMPLE_ALIAS(Tgamma, std::tgamma)
DEFINE_SIMPLE_ALIAS(Trunc, std::trunc)
#ifdef HAS_LIBM_BESSEL
DEFINE_SIMPLE_ALIAS(Y0, y0l)
DEFINE_SIMPLE_ALIAS(Y1, y1l)
DEFINE_SIMPLE_ALIAS(Yn, ynl)
#endif

// Use numeric_limits to produce infinity of the right type.
#define F128_RT_INFINITY \
Expand Down
Loading