[clang] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 11 16:46:12 PDT 2023


Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+MaheshRavishankar at users.noreply.github.com>,Fangrui Song
 <i at maskray.me>,Razvan Lupusoru <razvan.lupusoru at gmail.com>,Walter Erquinigo
 <a20012251 at gmail.com>,"Yaxun (Sam) Liu" <yaxun.liu at amd.com>,Nico Weber
 <thakis at chromium.org>,Stella Laurenzo <stellaraccident at gmail.com>,Lang Hames
 <lhames at gmail.com>,Matthias Braun <matze at braunis.de>,Arthur Eubanks
 <aeubanks at google.com>,Nico Weber <thakis at chromium.org>,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 <vitalybuka at google.com>,Vitaly Buka <vitalybuka at google.com>,Fangrui Song
 <i at maskray.me>,Fangrui Song <i at maskray.me>,Fangrui Song <i at maskray.me>,Fangrui
 Song <i at maskray.me>,erichkeane <ekeane at nvidia.com>,Amir Ayupov
 <aaupov at fb.com>,Amir Ayupov <aaupov at meta.com>,yinying-lisa-li
 <107574043+yinying-lisa-li at users.noreply.github.com>,Christopher Di Bella
 <cjdb.ns at gmail.com>,Konstantin Varlamov <varconsteq at gmail.com>,Alexey Bader
 <alexey.bader at intel.com>,Vitaly Buka <vitalybuka at google.com>


llvmbot wrote:

@llvm/pr-subscribers-backend-amdgpu

<details>
<summary>Changes</summary>

There are a number of mathematical functions where no target-agnostic implementations exist, and the compiler built-ins are not correctly lowered on all GPU targets. This patch adds inlined wrappers for those functions to the GPU version of `libm` for AMDGPU and NVPTX targets.
--

Patch is 52.08 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/66031.diff

50 Files Affected:

- (modified) libc/config/gpu/entrypoints.txt (+34-3) 
- (modified) libc/src/math/CMakeLists.txt (+15) 
- (added) libc/src/math/acos.h (+18) 
- (added) libc/src/math/acosh.h (+18) 
- (added) libc/src/math/asin.h (+18) 
- (added) libc/src/math/asinh.h (+18) 
- (added) libc/src/math/atan.h (+18) 
- (added) libc/src/math/atan2.h (+18) 
- (added) libc/src/math/atan2f.h (+18) 
- (added) libc/src/math/atanh.h (+18) 
- (added) libc/src/math/erf.h (+18) 
- (added) libc/src/math/expm1.h (+18) 
- (modified) libc/src/math/gpu/vendor/CMakeLists.txt (+143) 
- (added) libc/src/math/gpu/vendor/acos.cpp (+18) 
- (added) libc/src/math/gpu/vendor/acosh.cpp (+18) 
- (modified) libc/src/math/gpu/vendor/amdgpu/amdgpu.h (+25) 
- (modified) libc/src/math/gpu/vendor/amdgpu/declarations.h (+31-3) 
- (added) libc/src/math/gpu/vendor/asin.cpp (+18) 
- (added) libc/src/math/gpu/vendor/asinh.cpp (+18) 
- (added) libc/src/math/gpu/vendor/atan.cpp (+18) 
- (added) libc/src/math/gpu/vendor/atan2.cpp (+20) 
- (added) libc/src/math/gpu/vendor/atan2f.cpp (+21) 
- (added) libc/src/math/gpu/vendor/atanh.cpp (+18) 
- (added) libc/src/math/gpu/vendor/erf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/erff.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp10.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp2.cpp (+18) 
- (added) libc/src/math/gpu/vendor/expm1.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log10.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log10f.cpp (+19) 
- (added) libc/src/math/gpu/vendor/log1p.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log1pf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log2.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log2f.cpp (+18) 
- (added) libc/src/math/gpu/vendor/logb.cpp (+18) 
- (added) libc/src/math/gpu/vendor/logbf.cpp (+19) 
- (added) libc/src/math/gpu/vendor/logf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lrint.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lrintf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lround.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lroundf.cpp (+20) 
- (modified) libc/src/math/gpu/vendor/nvptx/declarations.h (+25) 
- (modified) libc/src/math/gpu/vendor/nvptx/nvptx.h (+25) 
- (added) libc/src/math/gpu/vendor/tgamma.cpp (+18) 
- (added) libc/src/math/gpu/vendor/tgammaf.cpp (+18) 
- (added) libc/src/math/sincos.h (+18) 
- (added) libc/src/math/tgamma.h (+18) 
- (added) libc/src/math/tgammaf.h (+18) 


<pre>
diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index 0e314c60870c6ae..730f76cbd6fbb9c 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -113,11 +113,19 @@ set(TARGET_LIBC_ENTRYPOINTS
 
 set(TARGET_LIBM_ENTRYPOINTS
     # math.h entrypoints
+    libc.src.math.acos
     libc.src.math.acosf
+    libc.src.math.acosh
     libc.src.math.acoshf
+    libc.src.math.asin
     libc.src.math.asinf
+    libc.src.math.asinh
     libc.src.math.asinhf
+    libc.src.math.atan
     libc.src.math.atanf
+    libc.src.math.atan2
+    libc.src.math.atan2f
+    libc.src.math.atanh
     libc.src.math.atanhf
     libc.src.math.ceil
     libc.src.math.ceilf
@@ -127,9 +135,15 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.cosf
     libc.src.math.cosh
     libc.src.math.coshf
+    libc.src.math.erf
+    libc.src.math.erff
+    libc.src.math.exp10
     libc.src.math.exp10f
+    libc.src.math.exp2
     libc.src.math.exp2f
+    libc.src.math.exp
     libc.src.math.expf
+    libc.src.math.expm1
     libc.src.math.expm1f
     libc.src.math.fabs
     libc.src.math.fabsf
@@ -157,15 +171,26 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.llrintf
     libc.src.math.llround
     libc.src.math.llroundf
-    libc.src.math.pow
-    libc.src.math.powf
-    libc.src.math.sin
+    libc.src.math.log10
+    libc.src.math.log10f
+    libc.src.math.log1p
+    libc.src.math.log1pf
+    libc.src.math.log2
+    libc.src.math.log2f
+    libc.src.math.log
+    libc.src.math.logf
+    libc.src.math.lrint
+    libc.src.math.lrintf
+    libc.src.math.lround
+    libc.src.math.lroundf
     libc.src.math.modf
     libc.src.math.modff
     libc.src.math.nearbyint
     libc.src.math.nearbyintf
     libc.src.math.nextafter
     libc.src.math.nextafterf
+    libc.src.math.pow
+    libc.src.math.powf
     libc.src.math.remainder
     libc.src.math.remainderf
     libc.src.math.remquo
@@ -176,6 +201,10 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.roundf
     libc.src.math.scalbn
     libc.src.math.scalbnf
+    libc.src.math.sin
+    libc.src.math.sinf
+    libc.src.math.sincos
+    libc.src.math.sincosf
     libc.src.math.sinh
     libc.src.math.sinhf
     libc.src.math.sqrt
@@ -184,6 +213,8 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.tanf
     libc.src.math.tanh
     libc.src.math.tanhf
+    libc.src.math.tgamma
+    libc.src.math.tgammaf
     libc.src.math.trunc
     libc.src.math.truncf
 )
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 8b2021cac8239fe..f1f72714981a9e5 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -54,14 +54,23 @@ function(add_math_entrypoint_object name)
   )
 endfunction()
 
+add_math_entrypoint_object(acos)
 add_math_entrypoint_object(acosf)
+add_math_entrypoint_object(acosh)
 add_math_entrypoint_object(acoshf)
 
+add_math_entrypoint_object(asin)
 add_math_entrypoint_object(asinf)
+add_math_entrypoint_object(asinh)
 add_math_entrypoint_object(asinhf)
 
+add_math_entrypoint_object(atan)
 add_math_entrypoint_object(atanf)
 
+add_math_entrypoint_object(atan2)
+add_math_entrypoint_object(atan2f)
+
+add_math_entrypoint_object(atanh)
 add_math_entrypoint_object(atanhf)
 
 add_math_entrypoint_object(ceil)
@@ -77,6 +86,7 @@ add_math_entrypoint_object(cosf)
 add_math_entrypoint_object(cosh)
 add_math_entrypoint_object(coshf)
 
+add_math_entrypoint_object(erf)
 add_math_entrypoint_object(erff)
 
 add_math_entrypoint_object(exp)
@@ -88,6 +98,7 @@ add_math_entrypoint_object(exp2f)
 add_math_entrypoint_object(exp10)
 add_math_entrypoint_object(exp10f)
 
+add_math_entrypoint_object(expm1)
 add_math_entrypoint_object(expm1f)
 
 add_math_entrypoint_object(fabs)
@@ -198,6 +209,7 @@ add_math_entrypoint_object(scalbn)
 add_math_entrypoint_object(scalbnf)
 add_math_entrypoint_object(scalbnl)
 
+add_math_entrypoint_object(sincos)
 add_math_entrypoint_object(sincosf)
 
 add_math_entrypoint_object(sin)
@@ -216,6 +228,9 @@ add_math_entrypoint_object(tanf)
 add_math_entrypoint_object(tanh)
 add_math_entrypoint_object(tanhf)
 
+add_math_entrypoint_object(tgamma)
+add_math_entrypoint_object(tgammaf)
+
 add_math_entrypoint_object(trunc)
 add_math_entrypoint_object(truncf)
 add_math_entrypoint_object(truncl)
diff --git a/libc/src/math/acos.h b/libc/src/math/acos.h
new file mode 100644
index 000000000000000..53b299f1da8902e
--- /dev/null
+++ b/libc/src/math/acos.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for acos --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ACOS_H
+#define LLVM_LIBC_SRC_MATH_ACOS_H
+
+namespace __llvm_libc {
+
+double acos(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ACOS_H
diff --git a/libc/src/math/acosh.h b/libc/src/math/acosh.h
new file mode 100644
index 000000000000000..851c619fdb9f799
--- /dev/null
+++ b/libc/src/math/acosh.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for acosh -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ACOSH_H
+#define LLVM_LIBC_SRC_MATH_ACOSH_H
+
+namespace __llvm_libc {
+
+double acosh(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ACOSH_H
diff --git a/libc/src/math/asin.h b/libc/src/math/asin.h
new file mode 100644
index 000000000000000..d8f3f191a357856
--- /dev/null
+++ b/libc/src/math/asin.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for asin --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ASIN_H
+#define LLVM_LIBC_SRC_MATH_ASIN_H
+
+namespace __llvm_libc {
+
+double asin(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ASIN_H
diff --git a/libc/src/math/asinh.h b/libc/src/math/asinh.h
new file mode 100644
index 000000000000000..098880f26ecc80c
--- /dev/null
+++ b/libc/src/math/asinh.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for asinh -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ASINH_H
+#define LLVM_LIBC_SRC_MATH_ASINH_H
+
+namespace __llvm_libc {
+
+double asinh(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ASINH_H
diff --git a/libc/src/math/atan.h b/libc/src/math/atan.h
new file mode 100644
index 000000000000000..73d67e526d7d5a5
--- /dev/null
+++ b/libc/src/math/atan.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for atan --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ATAN_H
+#define LLVM_LIBC_SRC_MATH_ATAN_H
+
+namespace __llvm_libc {
+
+double atan(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ATAN_H
diff --git a/libc/src/math/atan2.h b/libc/src/math/atan2.h
new file mode 100644
index 000000000000000..cac5b7ddfbb62c1
--- /dev/null
+++ b/libc/src/math/atan2.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for atan2 -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ATAN2_H
+#define LLVM_LIBC_SRC_MATH_ATAN2_H
+
+namespace __llvm_libc {
+
+double atan2(double x, double y);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ATAN2_H
diff --git a/libc/src/math/atan2f.h b/libc/src/math/atan2f.h
new file mode 100644
index 000000000000000..d3e81a2b8d5f2d4
--- /dev/null
+++ b/libc/src/math/atan2f.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for atan2f ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ATAN2F_H
+#define LLVM_LIBC_SRC_MATH_ATAN2F_H
+
+namespace __llvm_libc {
+
+float atan2f(float x, float y);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ATAN2F_H
diff --git a/libc/src/math/atanh.h b/libc/src/math/atanh.h
new file mode 100644
index 000000000000000..de854451e7a281f
--- /dev/null
+++ b/libc/src/math/atanh.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for atanh -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ATANH_H
+#define LLVM_LIBC_SRC_MATH_ATANH_H
+
+namespace __llvm_libc {
+
+double atanh(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ATANH_H
diff --git a/libc/src/math/erf.h b/libc/src/math/erf.h
new file mode 100644
index 000000000000000..86a146182b4f729
--- /dev/null
+++ b/libc/src/math/erf.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for erf ---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ERF_H
+#define LLVM_LIBC_SRC_MATH_ERF_H
+
+namespace __llvm_libc {
+
+double erf(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ERF_H
diff --git a/libc/src/math/expm1.h b/libc/src/math/expm1.h
new file mode 100644
index 000000000000000..7ae354e459feb1f
--- /dev/null
+++ b/libc/src/math/expm1.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for expm1 -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_EXPM1_H
+#define LLVM_LIBC_SRC_MATH_EXPM1_H
+
+namespace __llvm_libc {
+
+double expm1(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_EXPM1_H
diff --git a/libc/src/math/gpu/vendor/CMakeLists.txt b/libc/src/math/gpu/vendor/CMakeLists.txt
index 2ee74a06a02d461..58910ac517bdc97 100644
--- a/libc/src/math/gpu/vendor/CMakeLists.txt
+++ b/libc/src/math/gpu/vendor/CMakeLists.txt
@@ -29,6 +29,17 @@ endif()
 # will link in identity metadata from both libraries. This silences the warning.
 list(APPEND bitcode_link_flags "-Wno-linker-warnings")
 
+add_entrypoint_object(
+  acos
+  SRCS
+    acos.cpp
+  HDRS
+    ../../acos.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
 add_entrypoint_object(
   acosf
   SRCS
@@ -40,6 +51,17 @@ add_entrypoint_object(
     -O2
 )
 
+add_entrypoint_object(
+  acosh
+  SRCS
+    acosh.cpp
+  HDRS
+    ../../acosh.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
 add_entrypoint_object(
   acoshf
   SRCS
@@ -51,6 +73,17 @@ add_entrypoint_object(
     -O2
 )
 
+add_entrypoint_object(
+  asin
+  SRCS
+    asin.cpp
+  HDRS
+    ../../asin.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
 add_entrypoint_object(
   asinf
   SRCS
@@ -62,6 +95,17 @@ add_entrypoint_object(
     -O2
 )
 
+add_entrypoint_object(
+  asinh
+  SRCS
+    asinh.cpp
+  HDRS
+    ../../asinh.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
 add_entrypoint_object(
   asinhf
   SRCS
@@ -73,6 +117,17 @@ add_entrypoint_object(
     -O2
 )
 
+add_entrypoint_object(
+  atan
+  SRCS
+    atan.cpp
+  HDRS
+    ../../atan.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
 add_entrypoint_object(
   atanf
   SRCS
@@ -84,6 +139,39 @@ add_entrypoint_object(
     -O2
 )
 
+add_entrypoint_object(
+  atan2
+  SRCS
+    atan2.cpp
+  HDRS
+    ../../atan2.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  atan2f
+  SRCS
+    atan2f.cpp
+  HDRS
+    ../../atan2f.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  atanh
+  SRCS
+    atanh.cpp
+  HDRS
+    ../../atanh.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
 add_entrypoint_object(
   atanhf
   SRCS
@@ -139,6 +227,28 @@ add_entrypoint_object(
     -O2
 )
 
+add_entrypoint_object(
+  erf
+  SRCS
+    erf.cpp
+  HDRS
+    ../../erf.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  erff
+  SRCS
+    erff.cpp
+  HDRS
+    ../../erff.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
 add_entrypoint_object(
   exp10f
   SRCS
@@ -172,6 +282,17 @@ add_entrypoint_object(
     -O2
 )
 
+add_entrypoint_object(
+  expm1
+  SRCS
+    expm1.cpp
+  HDRS
+    ../../expm1.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
 add_entrypoint_object(
   expm1f
   SRCS
@@ -515,6 +636,28 @@ add_entrypoint_object(
     -O2
 )
 
+add_entrypoint_object(
+  tgamma
+  SRCS
+    tgamma.cpp
+  HDRS
+    ../../tgamma.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  tgammaf
+  SRCS
+    tgammaf.cpp
+  HDRS
+    ../../tgammaf.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
 add_entrypoint_object(
   frexp
   SRCS
diff --git a/libc/src/math/gpu/vendor/acos.cpp b/libc/src/math/gpu/vendor/acos.cpp
new file mode 100644
index 000000000000000..7e6d00be3c3e589
--- /dev/null
+++ b/libc/src/math/gpu/vendor/acos.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU acos function ---------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/acos.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, acos, (double x)) { return internal::acos(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/acosh.cpp b/libc/src/math/gpu/vendor/acosh.cpp
new file mode 100644
index 000000000000000..2ea150dcf78e03a
--- /dev/null
+++ b/libc/src/math/gpu/vendor/acosh.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU acosh function --------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/acosh.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, acosh, (double x)) { return internal::acosh(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
index 7755174e445b222..a763f2e3d0f53f1 100644
--- a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
+++ b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
@@ -16,19 +16,30 @@
 
 namespace __llvm_libc {
 namespace internal {
+LIBC_INLINE double acos(double x) { return __ocml_acos_f64(x); }
 LIBC_INLINE float acosf(float x) { return __ocml_acos_f32(x); }
+LIBC_INLINE double acosh(double x) { return __ocml_acosh_f64(x); }
 LIBC_INLINE float acoshf(float x) { return __ocml_acosh_f32(x); }
+LIBC_INLINE double asin(double x) { return __ocml_asin_f64(x); }
 LIBC_INLINE float asinf(float x) { return __ocml_asin_f32(x); }
+LIBC_INLINE double asinh(double x) { return __ocml_asinh_f64(x); }
 LIBC_INLINE float asinhf(float x) { return __ocml_asinh_f32(x); }
+LIBC_INLINE double atan(double x) { return __ocml_atan_f64(x); }
 LIBC_INLINE float atanf(float x) { return __ocml_atan_f32(x); }
+LIBC_INLINE double atan2(double x, double y) { return __ocml_atan2_f64(x, y); }
+LIBC_INLINE float atan2f(float x, float y) { return __ocml_atan2_f32(x, y); }
+LIBC_INLINE double atanh(double x) { return __ocml_atanh_f64(x); }
 LIBC_INLINE float atanhf(float x) { return __ocml_atanh_f32(x); }
 LIBC_INLINE double cos(double x) { return __ocml_cos_f64(x); }
 LIBC_INLINE float cosf(float x) { return __ocml_cos_f32(x); }
 LIBC_INLINE double cosh(double x) { return __ocml_cosh_f64(x); }
 LIBC_INLINE float coshf...
<truncated>
</pre>

</details>

https://github.com/llvm/llvm-project/pull/66031


More information about the cfe-commits mailing list