[flang-commits] [flang] [flang] Fold double bessel functions on Windows. (PR #130253)
مهدي شينون via flang-commits
flang-commits at lists.llvm.org
Thu Mar 6 22:27:01 PST 2025
https://github.com/MehdiChinoune created https://github.com/llvm/llvm-project/pull/130253
There are no functions for `float`.
see: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/bessel-functions-j0-j1-jn-y0-y1-yn
>From 3b0f0afe3fdcedc5979e9bf5e17f7919a3477eef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?=
=?UTF-8?q?=20=28Mehdi=20Chinoune=29?=
<79349457+MehdiChinoune at users.noreply.github.com>
Date: Fri, 7 Mar 2025 07:24:43 +0100
Subject: [PATCH] [flang] Fold double bessel functions on Windows.
There are no functions for `float`.
see: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/bessel-functions-j0-j1-jn-y0-y1-yn
---
flang/lib/Evaluate/intrinsics-library.cpp | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/flang/lib/Evaluate/intrinsics-library.cpp b/flang/lib/Evaluate/intrinsics-library.cpp
index d2c1be65dca44..971c8d2b67e9b 100644
--- a/flang/lib/Evaluate/intrinsics-library.cpp
+++ b/flang/lib/Evaluate/intrinsics-library.cpp
@@ -559,6 +559,23 @@ struct HostRuntimeLibrary<long double, LibraryVersion::LibmExtensions> {
#endif // HAS_FLOAT80 || HAS_LDBL128
#endif //_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
+#ifdef _WIN32
+template <> struct HostRuntimeLibrary<double, LibraryVersion::LibmExtensions> {
+ using F = FuncPointer<double, double>;
+ using FN = FuncPointer<double, int, double>;
+ static constexpr HostRuntimeFunction table[]{
+ FolderFactory<F, F{::_j0}>::Create("bessel_j0"),
+ FolderFactory<F, F{::_j1}>::Create("bessel_j1"),
+ FolderFactory<FN, FN{::_jn}>::Create("bessel_jn"),
+ FolderFactory<F, F{::_y0}>::Create("bessel_y0"),
+ FolderFactory<F, F{::_y1}>::Create("bessel_y1"),
+ FolderFactory<FN, FN{::_yn}>::Create("bessel_yn"),
+ };
+ static constexpr HostRuntimeMap map{table};
+ static_assert(map.Verify(), "map must be sorted");
+};
+#endif
+
/// Define pgmath description
#if LINK_WITH_LIBPGMATH
// Only use libpgmath for folding if it is available.
More information about the flang-commits
mailing list