[libc-commits] [libc] Enable LLVM libc math functions for SPIRV64 target (PR #199495)
via libc-commits
libc-commits at lists.llvm.org
Mon May 25 00:40:52 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: jinge90
<details>
<summary>Changes</summary>
---
Patch is 56.50 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/199495.diff
63 Files Affected:
- (modified) libc/config/gpu/spirv/entrypoints.txt (+80)
- (modified) libc/config/gpu/spirv/headers.txt (+1)
- (added) libc/src/math/spirv/CMakeLists.txt (+479)
- (added) libc/src/math/spirv/acos.cpp (+16)
- (added) libc/src/math/spirv/acosf.cpp (+16)
- (added) libc/src/math/spirv/asin.cpp (+16)
- (added) libc/src/math/spirv/asinf.cpp (+16)
- (added) libc/src/math/spirv/atan.cpp (+16)
- (added) libc/src/math/spirv/atan2.cpp (+18)
- (added) libc/src/math/spirv/atan2f.cpp (+18)
- (added) libc/src/math/spirv/atanf.cpp (+16)
- (added) libc/src/math/spirv/ceil.cpp (+17)
- (added) libc/src/math/spirv/ceilf.cpp (+17)
- (added) libc/src/math/spirv/copysign.cpp (+19)
- (added) libc/src/math/spirv/copysignf.cpp (+19)
- (added) libc/src/math/spirv/cos.cpp (+17)
- (added) libc/src/math/spirv/cosf.cpp (+17)
- (added) libc/src/math/spirv/coshf.cpp (+16)
- (added) libc/src/math/spirv/exp.cpp (+17)
- (added) libc/src/math/spirv/exp10.cpp (+17)
- (added) libc/src/math/spirv/exp10f.cpp (+17)
- (added) libc/src/math/spirv/exp2.cpp (+17)
- (added) libc/src/math/spirv/exp2f.cpp (+17)
- (added) libc/src/math/spirv/expf.cpp (+17)
- (added) libc/src/math/spirv/fabs.cpp (+17)
- (added) libc/src/math/spirv/fabsf.cpp (+17)
- (added) libc/src/math/spirv/floor.cpp (+17)
- (added) libc/src/math/spirv/floorf.cpp (+17)
- (added) libc/src/math/spirv/fma.cpp (+19)
- (added) libc/src/math/spirv/fmaf.cpp (+19)
- (added) libc/src/math/spirv/fmax.cpp (+20)
- (added) libc/src/math/spirv/fmaxf.cpp (+20)
- (added) libc/src/math/spirv/fmin.cpp (+20)
- (added) libc/src/math/spirv/fminf.cpp (+20)
- (added) libc/src/math/spirv/frexp.cpp (+20)
- (added) libc/src/math/spirv/frexpf.cpp (+20)
- (added) libc/src/math/spirv/ldexp.cpp (+20)
- (added) libc/src/math/spirv/ldexpf.cpp (+20)
- (added) libc/src/math/spirv/log.cpp (+17)
- (added) libc/src/math/spirv/log10.cpp (+17)
- (added) libc/src/math/spirv/log10f.cpp (+17)
- (added) libc/src/math/spirv/log2.cpp (+17)
- (added) libc/src/math/spirv/log2f.cpp (+17)
- (added) libc/src/math/spirv/logf.cpp (+17)
- (added) libc/src/math/spirv/pow.cpp (+18)
- (added) libc/src/math/spirv/powf.cpp (+18)
- (added) libc/src/math/spirv/rint.cpp (+17)
- (added) libc/src/math/spirv/rintf.cpp (+17)
- (added) libc/src/math/spirv/round.cpp (+17)
- (added) libc/src/math/spirv/roundf.cpp (+17)
- (added) libc/src/math/spirv/scalbn.cpp (+20)
- (added) libc/src/math/spirv/scalbnf.cpp (+20)
- (added) libc/src/math/spirv/sin.cpp (+16)
- (added) libc/src/math/spirv/sinf.cpp (+16)
- (added) libc/src/math/spirv/sinhf.cpp (+17)
- (added) libc/src/math/spirv/sqrt.cpp (+17)
- (added) libc/src/math/spirv/sqrtf.cpp (+17)
- (added) libc/src/math/spirv/tan.cpp (+17)
- (added) libc/src/math/spirv/tanf.cpp (+17)
- (added) libc/src/math/spirv/tanh.cpp (+17)
- (added) libc/src/math/spirv/tanhf.cpp (+17)
- (added) libc/src/math/spirv/trunc.cpp (+17)
- (added) libc/src/math/spirv/truncf.cpp (+17)
``````````diff
diff --git a/libc/config/gpu/spirv/entrypoints.txt b/libc/config/gpu/spirv/entrypoints.txt
index 36c98339582cd..6487941c32921 100644
--- a/libc/config/gpu/spirv/entrypoints.txt
+++ b/libc/config/gpu/spirv/entrypoints.txt
@@ -88,6 +88,86 @@ set(TARGET_LIBC_ENTRYPOINTS
)
set(TARGET_LIBM_ENTRYPOINTS
+ # math.h entrypoints
+ libc.src.math.acos
+ libc.src.math.acosf
+ libc.src.math.asin
+ libc.src.math.asinf
+ libc.src.math.atan2
+ libc.src.math.atan2f
+ libc.src.math.atan
+ libc.src.math.atanf
+ libc.src.math.cbrt
+ libc.src.math.ceil
+ libc.src.math.ceilf
+ libc.src.math.copysign
+ libc.src.math.copysignf
+ libc.src.math.cos
+ libc.src.math.cosf
+ libc.src.math.coshf
+ libc.src.math.cospif
+ 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.fabs
+ libc.src.math.fabsf
+ libc.src.math.fdim
+ libc.src.math.fdimf
+ libc.src.math.floor
+ libc.src.math.floorf
+ libc.src.math.fma
+ libc.src.math.fmaf
+ libc.src.math.fmax
+ libc.src.math.fmaxf
+ libc.src.math.fmin
+ libc.src.math.fminf
+ libc.src.math.fmod
+ libc.src.math.frexp
+ libc.src.math.frexpf
+ libc.src.math.ilogb
+ libc.src.math.ilogbf
+ libc.src.math.ldexp
+ libc.src.math.ldexpf
+ libc.src.math.log
+ libc.src.math.logf
+ libc.src.math.log10
+ libc.src.math.log10f
+ libc.src.math.log2
+ libc.src.math.log2f
+ libc.src.math.logb
+ libc.src.math.logbf
+ libc.src.math.modf
+ libc.src.math.modff
+ 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
+ libc.src.math.remquof
+ libc.src.math.rint
+ libc.src.math.rintf
+ libc.src.math.round
+ libc.src.math.roundf
+ libc.src.math.rsqrtf
+ libc.src.math.scalbn
+ libc.src.math.scalbnf
+ libc.src.math.sin
+ libc.src.math.sinf
+ libc.src.math.sinhf
+ libc.src.math.sinpif
+ libc.src.math.sqrt
+ libc.src.math.sqrtf
+ libc.src.math.tan
+ libc.src.math.tanf
+ libc.src.math.tanh
+ libc.src.math.tanhf
+ libc.src.math.trunc
+ libc.src.math.truncf
)
if(LIBC_TYPES_HAS_FLOAT16)
diff --git a/libc/config/gpu/spirv/headers.txt b/libc/config/gpu/spirv/headers.txt
index ae5e0de66c7a2..6c89d5d5578b0 100644
--- a/libc/config/gpu/spirv/headers.txt
+++ b/libc/config/gpu/spirv/headers.txt
@@ -2,4 +2,5 @@ set(TARGET_PUBLIC_HEADERS
libc.include.ctype
libc.include.string
libc.include.strings
+ libc.include.math
)
diff --git a/libc/src/math/spirv/CMakeLists.txt b/libc/src/math/spirv/CMakeLists.txt
new file mode 100644
index 0000000000000..ae44cd1ed92c7
--- /dev/null
+++ b/libc/src/math/spirv/CMakeLists.txt
@@ -0,0 +1,479 @@
+add_entrypoint_object(
+ acos
+ SRCS
+ acos.cpp
+ HDRS
+ ../acos.h
+)
+
+add_entrypoint_object(
+ acosf
+ SRCS
+ acosf.cpp
+ HDRS
+ ../acosf.h
+)
+
+add_entrypoint_object(
+ asin
+ SRCS
+ asin.cpp
+ HDRS
+ ../asin.h
+)
+
+add_entrypoint_object(
+ asinf
+ SRCS
+ asinf.cpp
+ HDRS
+ ../asinf.h
+)
+
+add_entrypoint_object(
+ atan2
+ SRCS
+ atan2.cpp
+ HDRS
+ ../atan2.h
+)
+
+add_entrypoint_object(
+ atan2f
+ SRCS
+ atan2f.cpp
+ HDRS
+ ../atan2f.h
+)
+
+add_entrypoint_object(
+ atan
+ SRCS
+ atan.cpp
+ HDRS
+ ../atan.h
+)
+
+add_entrypoint_object(
+ atanf
+ SRCS
+ atanf.cpp
+ HDRS
+ ../atanf.h
+)
+
+add_entrypoint_object(
+ ceil
+ SRCS
+ ceil.cpp
+ HDRS
+ ../ceil.h
+)
+
+add_entrypoint_object(
+ ceilf
+ SRCS
+ ceilf.cpp
+ HDRS
+ ../ceilf.h
+)
+
+add_entrypoint_object(
+ copysign
+ SRCS
+ copysign.cpp
+ HDRS
+ ../copysign.h
+)
+
+add_entrypoint_object(
+ copysignf
+ SRCS
+ copysignf.cpp
+ HDRS
+ ../copysignf.h
+)
+
+add_entrypoint_object(
+ cos
+ SRCS
+ cos.cpp
+ HDRS
+ ../cos.h
+)
+
+add_entrypoint_object(
+ cosf
+ SRCS
+ cosf.cpp
+ HDRS
+ ../cosf.h
+)
+
+add_entrypoint_object(
+ coshf
+ SRCS
+ coshf.cpp
+ HDRS
+ ../coshf.h
+)
+
+add_entrypoint_object(
+ exp10
+ SRCS
+ exp10.cpp
+ HDRS
+ ../exp10.h
+)
+
+add_entrypoint_object(
+ exp10f
+ SRCS
+ exp10f.cpp
+ HDRS
+ ../exp10f.h
+)
+
+add_entrypoint_object(
+ exp2
+ SRCS
+ exp2.cpp
+ HDRS
+ ../exp2.h
+)
+
+add_entrypoint_object(
+ exp2f
+ SRCS
+ exp2f.cpp
+ HDRS
+ ../exp2f.h
+)
+
+add_entrypoint_object(
+ exp
+ SRCS
+ exp.cpp
+ HDRS
+ ../exp.h
+)
+
+add_entrypoint_object(
+ expf
+ SRCS
+ expf.cpp
+ HDRS
+ ../expf.h
+)
+
+add_entrypoint_object(
+ fabs
+ SRCS
+ fabs.cpp
+ HDRS
+ ../fabs.h
+)
+
+add_entrypoint_object(
+ fabsf
+ SRCS
+ fabsf.cpp
+ HDRS
+ ../fabsf.h
+)
+
+add_entrypoint_object(
+ floor
+ SRCS
+ floor.cpp
+ HDRS
+ ../floor.h
+)
+
+add_entrypoint_object(
+ floorf
+ SRCS
+ floorf.cpp
+ HDRS
+ ../floorf.h
+)
+
+add_entrypoint_object(
+ fma
+ SRCS
+ fma.cpp
+ HDRS
+ ../fma.h
+)
+
+add_entrypoint_object(
+ fmaf
+ SRCS
+ fmaf.cpp
+ HDRS
+ ../fmaf.h
+)
+
+add_entrypoint_object(
+ fmax
+ SRCS
+ fmax.cpp
+ HDRS
+ ../fmax.h
+)
+
+add_entrypoint_object(
+ fmaxf
+ SRCS
+ fmaxf.cpp
+ HDRS
+ ../fmaxf.h
+)
+
+add_entrypoint_object(
+ fmin
+ SRCS
+ fmin.cpp
+ HDRS
+ ../fmin.h
+)
+
+add_entrypoint_object(
+ fminf
+ SRCS
+ fminf.cpp
+ HDRS
+ ../fminf.h
+)
+
+add_entrypoint_object(
+ frexp
+ SRCS
+ frexp.cpp
+ HDRS
+ ../frexp.h
+)
+
+add_entrypoint_object(
+ frexpf
+ SRCS
+ frexpf.cpp
+ HDRS
+ ../frexpf.h
+)
+
+add_entrypoint_object(
+ ldexp
+ SRCS
+ ldexp.cpp
+ HDRS
+ ../ldexp.h
+)
+
+add_entrypoint_object(
+ ldexpf
+ SRCS
+ ldexpf.cpp
+ HDRS
+ ../ldexpf.h
+)
+
+add_entrypoint_object(
+ log10
+ SRCS
+ log10.cpp
+ HDRS
+ ../log10.h
+)
+
+add_entrypoint_object(
+ log10f
+ SRCS
+ log10f.cpp
+ HDRS
+ ../log10f.h
+)
+
+add_entrypoint_object(
+ log2
+ SRCS
+ log2.cpp
+ HDRS
+ ../log2.h
+)
+
+add_entrypoint_object(
+ log2f
+ SRCS
+ log2f.cpp
+ HDRS
+ ../log2f.h
+)
+
+add_entrypoint_object(
+ log
+ SRCS
+ log.cpp
+ HDRS
+ ../log.h
+)
+
+add_entrypoint_object(
+ logf
+ SRCS
+ logf.cpp
+ HDRS
+ ../logf.h
+)
+
+add_entrypoint_object(
+ pow
+ SRCS
+ pow.cpp
+ HDRS
+ ../pow.h
+)
+
+add_entrypoint_object(
+ powf
+ SRCS
+ powf.cpp
+ HDRS
+ ../powf.h
+)
+
+add_entrypoint_object(
+ rint
+ SRCS
+ rint.cpp
+ HDRS
+ ../rint.h
+)
+
+add_entrypoint_object(
+ rintf
+ SRCS
+ rintf.cpp
+ HDRS
+ ../rintf.h
+)
+
+add_entrypoint_object(
+ round
+ SRCS
+ round.cpp
+ HDRS
+ ../round.h
+)
+
+add_entrypoint_object(
+ roundf
+ SRCS
+ roundf.cpp
+ HDRS
+ ../roundf.h
+)
+
+add_entrypoint_object(
+ scalbn
+ SRCS
+ scalbn.cpp
+ HDRS
+ ../scalbn.h
+)
+
+add_entrypoint_object(
+ scalbnf
+ SRCS
+ scalbnf.cpp
+ HDRS
+ ../scalbnf.h
+)
+
+add_entrypoint_object(
+ sin
+ SRCS
+ sin.cpp
+ HDRS
+ ../sin.h
+)
+
+add_entrypoint_object(
+ sinf
+ SRCS
+ sinf.cpp
+ HDRS
+ ../sinf.h
+)
+
+add_entrypoint_object(
+ sinhf
+ SRCS
+ sinhf.cpp
+ HDRS
+ ../sinhf.h
+)
+
+add_entrypoint_object(
+ sqrt
+ SRCS
+ sqrt.cpp
+ HDRS
+ ../sqrt.h
+)
+
+add_entrypoint_object(
+ sqrtf
+ SRCS
+ sqrtf.cpp
+ HDRS
+ ../sqrtf.h
+)
+
+add_entrypoint_object(
+ tan
+ SRCS
+ tan.cpp
+ HDRS
+ ../tan.h
+)
+
+add_entrypoint_object(
+ tanf
+ SRCS
+ tanf.cpp
+ HDRS
+ ../tanf.h
+)
+
+add_entrypoint_object(
+ tanh
+ SRCS
+ tanh.cpp
+ HDRS
+ ../tanh.h
+)
+
+add_entrypoint_object(
+ tanhf
+ SRCS
+ tanhf.cpp
+ HDRS
+ ../tanhf.h
+)
+
+add_entrypoint_object(
+ trunc
+ SRCS
+ trunc.cpp
+ HDRS
+ ../trunc.h
+)
+
+add_entrypoint_object(
+ truncf
+ SRCS
+ truncf.cpp
+ HDRS
+ ../truncf.h
+)
diff --git a/libc/src/math/spirv/acos.cpp b/libc/src/math/spirv/acos.cpp
new file mode 100644
index 0000000000000..2c5cdd1428319
--- /dev/null
+++ b/libc/src/math/spirv/acos.cpp
@@ -0,0 +1,16 @@
+//===-- 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/math/acos.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, acos, (double x)) { return __builtin_acos(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/acosf.cpp b/libc/src/math/spirv/acosf.cpp
new file mode 100644
index 0000000000000..de34130101c17
--- /dev/null
+++ b/libc/src/math/spirv/acosf.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation of the GPU acosf 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/acosf.h"
+#include "src/__support/math/acosf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, acosf, (float x)) { return __builtin_acosf(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/asin.cpp b/libc/src/math/spirv/asin.cpp
new file mode 100644
index 0000000000000..7e533b81a4681
--- /dev/null
+++ b/libc/src/math/spirv/asin.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation of the GPU asin 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/asin.h"
+#include "src/__support/math/asin.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, asin, (double x)) { return __builtin_asin(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/asinf.cpp b/libc/src/math/spirv/asinf.cpp
new file mode 100644
index 0000000000000..8e5d4396107aa
--- /dev/null
+++ b/libc/src/math/spirv/asinf.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation of the GPU asinf 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/asinf.h"
+#include "src/__support/math/asinf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, asinf, (float x)) { return __builtin_asinf(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/atan.cpp b/libc/src/math/spirv/atan.cpp
new file mode 100644
index 0000000000000..c01c89c7d0e0b
--- /dev/null
+++ b/libc/src/math/spirv/atan.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation of the GPU atan 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/atan.h"
+#include "src/__support/math/atan.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, atan, (double x)) { return __builtin_atan(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/atan2.cpp b/libc/src/math/spirv/atan2.cpp
new file mode 100644
index 0000000000000..e8620f9f8f438
--- /dev/null
+++ b/libc/src/math/spirv/atan2.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU atan2 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/atan2.h"
+#include "src/__support/math/atan2.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, atan2, (double y, double x)) {
+ return __builtin_atan2(y, x);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/atan2f.cpp b/libc/src/math/spirv/atan2f.cpp
new file mode 100644
index 0000000000000..ff4183c5eb05a
--- /dev/null
+++ b/libc/src/math/spirv/atan2f.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU atan2f 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/atan2f.h"
+#include "src/__support/math/atan2f.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, atan2f, (float y, float x)) {
+ return __builtin_atan2f(y, x);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/atanf.cpp b/libc/src/math/spirv/atanf.cpp
new file mode 100644
index 0000000000000..e16dc05e4ca2a
--- /dev/null
+++ b/libc/src/math/spirv/atanf.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation of the GPU atanf 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/atanf.h"
+#include "src/__support/math/atanf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, atanf, (float x)) { return __builtin_atanf(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/ceil.cpp b/libc/src/math/spirv/ceil.cpp
new file mode 100644
index 0000000000000..8834c7b560a1b
--- /dev/null
+++ b/libc/src/math/spirv/ceil.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the ceil function for GPU -----------------------===//
+//
+// 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/ceil.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, ceil, (double x)) { return __builtin_ceil(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/ceilf.cpp b/libc/src/math/spirv/ceilf.cpp
new file mode 100644
index 0000000000000..5d26a30c849cd
--- /dev/null
+++ b/libc/src/math/spirv/ceilf.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the ceilf function for GPU ----------------------===//
+//
+// 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/ceilf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, ceilf, (float x)) { return __builtin_ceilf(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/copysign.cpp b/libc/src/math/spirv/copysign.cpp
new file mode 100644
index 0000000000000..06ef36fb3595f
--- /dev/null
+++ b/libc/src/math/spirv/copysign.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the copysign function for GPU -------------------===//
+//
+// 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/copysign.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, copysign, (double x, double y)) {
+ return __builtin_copysign(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/copysignf.cpp b/libc/src/math/spirv/copysignf.cpp
new file mode 100644
index 0000000000000..aea94f3577d8f
--- /dev/null
+++ b/libc/src/math/spirv/copysignf.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the copysignf function for GPU ------------------===//
+//
+// 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/copysignf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, copysignf, (float x, float y)) {
+ return __builtin_copysignf(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/cos.cpp b/libc/src/math/spirv/cos.cpp
new file mode 100644
index 0000000000000..46e68cdc2d953
--- /dev/null
+++ b/libc/src/math/spirv/cos.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the GPU cos 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/cos.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(double, cos, (double x)) { return __builtin_cos(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/cosf.cpp b/libc/src/math/spirv/cosf.cpp
new file mode 100644
index 0000000000000..56d8ddd138a6c
--- /dev/null
+++ b/libc/src/math/spirv/cosf.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the GPU cosf 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/cosf.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, cosf, (float x)) { return __builtin_cosf(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/coshf.cpp b/libc/src/math/spirv/coshf.cpp
new file mode 100644
index 0000000000000..5e881c2f59d54
--- /dev/null
+++ b/libc/src/math/spirv/coshf.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation of the GPU coshf 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/coshf.h"
+#include "src/__support/math/coshf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, coshf, (float x)) { return __builtin_coshf(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/spirv/exp.cpp b/libc/src/math/spirv/exp.cpp
new file mode 100644
index 0000000000000..cc3a6906fe980
--- /dev/null
+++ b/libc/src/math/spirv/exp.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of the GPU exp function ----------------------------===//
+//
+// Par...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/199495
More information about the libc-commits
mailing list