[flang-commits] [flang] [flang] add folding support for quad bessels (PR #77314)

via flang-commits flang-commits at lists.llvm.org
Mon Jan 8 06:24:36 PST 2024


https://github.com/jeanPerier created https://github.com/llvm/llvm-project/pull/77314

This is done using libquadmath and the mappings are only available if libquadmath was found by cmake.
Support for non quad bessels is already available on POSIX platform using libm extensions.

>From edca3b006f1c1bd5e468fb53e5699f0e4d62d12a Mon Sep 17 00:00:00 2001
From: Jean Perier <jperier at nvidia.com>
Date: Mon, 8 Jan 2024 05:35:50 -0800
Subject: [PATCH] [flang] add folding support for quad bessels

This is done using libquadmath and the mappings are only available
if libquadmath was found by cmake.

Support for non quad bessels is already available on POSIX platform
using libm extensions.
---
 flang/lib/Evaluate/intrinsics-library.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/flang/lib/Evaluate/intrinsics-library.cpp b/flang/lib/Evaluate/intrinsics-library.cpp
index 892b8d0b6a0639..e68c5ed3f6a8b1 100644
--- a/flang/lib/Evaluate/intrinsics-library.cpp
+++ b/flang/lib/Evaluate/intrinsics-library.cpp
@@ -321,6 +321,7 @@ template <> struct HostRuntimeLibrary<float, LibraryVersion::LibmExtensions> {
 template <> struct HostRuntimeLibrary<__float128, LibraryVersion::Libm> {
   using F = FuncPointer<__float128, __float128>;
   using F2 = FuncPointer<__float128, __float128, __float128>;
+  using FN = FuncPointer<__float128, int, __float128>;
   static constexpr HostRuntimeFunction table[]{
       FolderFactory<F, F{::acosq}>::Create("acos"),
       FolderFactory<F, F{::acoshq}>::Create("acosh"),
@@ -329,6 +330,12 @@ template <> struct HostRuntimeLibrary<__float128, LibraryVersion::Libm> {
       FolderFactory<F, F{::atanq}>::Create("atan"),
       FolderFactory<F2, F2{::atan2q}>::Create("atan2"),
       FolderFactory<F, F{::atanhq}>::Create("atanh"),
+      FolderFactory<F, F{::j0q}>::Create("bessel_j0"),
+      FolderFactory<F, F{::j1q}>::Create("bessel_j1"),
+      FolderFactory<FN, FN{::jnq}>::Create("bessel_jn"),
+      FolderFactory<F, F{::y0q}>::Create("bessel_y0"),
+      FolderFactory<F, F{::y1q}>::Create("bessel_y1"),
+      FolderFactory<FN, FN{::ynq}>::Create("bessel_yn"),
       FolderFactory<F, F{::cosq}>::Create("cos"),
       FolderFactory<F, F{::coshq}>::Create("cosh"),
       FolderFactory<F, F{::erfq}>::Create("erf"),



More information about the flang-commits mailing list