diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt index 731508088cb6f..b20008e2784c4 100644 --- a/libc/config/gpu/entrypoints.txt +++ b/libc/config/gpu/entrypoints.txt @@ -125,11 +125,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 @@ -139,9 +147,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 @@ -169,15 +183,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 @@ -188,6 +213,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 @@ -196,6 +225,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 00e0e4e6a5839..f1f72714981a9 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) @@ -199,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) @@ -217,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 0000000000000..da89a9dd3d9d4 --- /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 LIBC_NAMESPACE { + +double acos(double x); + +} // namespace LIBC_NAMESPACE + +#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 0000000000000..a5bbd82c120b8 --- /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 LIBC_NAMESPACE { + +double acosh(double x); + +} // namespace LIBC_NAMESPACE + +#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 0000000000000..e443776e507d9 --- /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 LIBC_NAMESPACE { + +double asin(double x); + +} // namespace LIBC_NAMESPACE + +#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 0000000000000..418bf96179841 --- /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 LIBC_NAMESPACE { + +double asinh(double x); + +} // namespace LIBC_NAMESPACE + +#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 0000000000000..bcbc97a52ee6d --- /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 LIBC_NAMESPACE { + +double atan(double x); + +} // namespace LIBC_NAMESPACE + +#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 0000000000000..024bbfb5fe9cb --- /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 LIBC_NAMESPACE { + +double atan2(double x, double y); + +} // namespace LIBC_NAMESPACE + +#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 0000000000000..25d2de09342fa --- /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 LIBC_NAMESPACE { + +float atan2f(float x, float y); + +} // namespace LIBC_NAMESPACE + +#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 0000000000000..dc84d07c02a0a --- /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 LIBC_NAMESPACE { + +double atanh(double x); + +} // namespace LIBC_NAMESPACE + +#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 0000000000000..a38c92410de13 --- /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 LIBC_NAMESPACE { + +double erf(double x); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_ERF_H diff --git a/libc/src/math/gpu/CMakeLists.txt b/libc/src/math/gpu/CMakeLists.txt index cee7b7d9db476..75a916e2a0112 100644 --- a/libc/src/math/gpu/CMakeLists.txt +++ b/libc/src/math/gpu/CMakeLists.txt @@ -183,6 +183,46 @@ add_math_entrypoint_gpu_object( -O2 ) +add_math_entrypoint_gpu_object( + lround + SRCS + lround.cpp + HDRS + ../lround.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + lroundf + SRCS + lroundf.cpp + HDRS + ../lroundf.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + llround + SRCS + llround.cpp + HDRS + ../llround.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + llroundf + SRCS + llroundf.cpp + HDRS + ../llroundf.h + COMPILE_OPTIONS + -O2 +) + add_math_entrypoint_gpu_object( modf SRCS @@ -283,16 +323,6 @@ add_math_entrypoint_gpu_object( -O2 ) -add_math_entrypoint_gpu_object( - sinhf - SRCS - sinhf.cpp - HDRS - ../sinhf.h - COMPILE_OPTIONS - -O2 -) - add_math_entrypoint_gpu_object( sqrt SRCS @@ -323,16 +353,6 @@ add_math_entrypoint_gpu_object( -O2 ) -add_math_entrypoint_gpu_object( - tanf - SRCS - tanf.cpp - HDRS - ../tanf.h - COMPILE_OPTIONS - -O2 -) - add_math_entrypoint_gpu_object( tanh SRCS @@ -343,16 +363,6 @@ add_math_entrypoint_gpu_object( -O2 ) -add_math_entrypoint_gpu_object( - tanhf - SRCS - tanhf.cpp - HDRS - ../tanhf.h - COMPILE_OPTIONS - -O2 -) - add_math_entrypoint_gpu_object( trunc SRCS diff --git a/libc/src/math/gpu/vendor/llround.cpp b/libc/src/math/gpu/llround.cpp similarity index 80% rename from libc/src/math/gpu/vendor/llround.cpp rename to libc/src/math/gpu/llround.cpp index e53701bda75cf..afd98308730a6 100644 --- a/libc/src/math/gpu/vendor/llround.cpp +++ b/libc/src/math/gpu/llround.cpp @@ -1,4 +1,4 @@ -//===-- Implementation of the llround function for GPU --------------------===// +//===-- Implementation of the GPU llround function ------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -9,12 +9,10 @@ #include "src/math/llround.h" #include "src/__support/common.h" -#include "common.h" - namespace LIBC_NAMESPACE { LLVM_LIBC_FUNCTION(long long, llround, (double x)) { - return internal::llround(x); + return __builtin_llround(x); } } // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/llroundf.cpp b/libc/src/math/gpu/llroundf.cpp similarity index 80% rename from libc/src/math/gpu/vendor/llroundf.cpp rename to libc/src/math/gpu/llroundf.cpp index ddb5ec00a036f..897ed15b69284 100644 --- a/libc/src/math/gpu/vendor/llroundf.cpp +++ b/libc/src/math/gpu/llroundf.cpp @@ -1,4 +1,4 @@ -//===-- Implementation of the llroundf function for GPU -------------------===// +//===-- Implementation of the GPU llroundf function -----------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -9,12 +9,10 @@ #include "src/math/llroundf.h" #include "src/__support/common.h" -#include "common.h" - namespace LIBC_NAMESPACE { LLVM_LIBC_FUNCTION(long long, llroundf, (float x)) { - return internal::llroundf(x); + return __builtin_lroundf(x); } } // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/sinhf.cpp b/libc/src/math/gpu/lround.cpp similarity index 70% rename from libc/src/math/gpu/sinhf.cpp rename to libc/src/math/gpu/lround.cpp index ed69dffe3ea83..51e8f2245af8e 100644 --- a/libc/src/math/gpu/sinhf.cpp +++ b/libc/src/math/gpu/lround.cpp @@ -1,4 +1,4 @@ -//===-- Implementation of the GPU sinhf function --------------------------===// +//===-- Implementation of the GPU lround function -------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,11 +6,11 @@ // //===----------------------------------------------------------------------===// -#include "src/math/sinhf.h" +#include "src/math/lround.h" #include "src/__support/common.h" namespace LIBC_NAMESPACE { -LLVM_LIBC_FUNCTION(float, sinhf, (float x)) { return __builtin_sinhf(x); } +LLVM_LIBC_FUNCTION(long, lround, (double x)) { return __builtin_lround(x); } } // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/tanf.cpp b/libc/src/math/gpu/lroundf.cpp similarity index 69% rename from libc/src/math/gpu/tanf.cpp rename to libc/src/math/gpu/lroundf.cpp index da7bd54ab08ae..2a6fe7200d8cb 100644 --- a/libc/src/math/gpu/tanf.cpp +++ b/libc/src/math/gpu/lroundf.cpp @@ -1,4 +1,4 @@ -//===-- Implementation of the GPU tanf function ---------------------------===// +//===-- Implementation of the GPU lroundf function ------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,11 +6,11 @@ // //===----------------------------------------------------------------------===// -#include "src/math/tanf.h" +#include "src/math/lroundf.h" #include "src/__support/common.h" namespace LIBC_NAMESPACE { -LLVM_LIBC_FUNCTION(float, tanf, (float x)) { return __builtin_tanf(x); } +LLVM_LIBC_FUNCTION(long, lroundf, (float x)) { return __builtin_lroundf(x); } } // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/CMakeLists.txt b/libc/src/math/gpu/vendor/CMakeLists.txt index 2ee74a06a02d4..a154c94a7009a 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 @@ -63,11 +96,22 @@ add_entrypoint_object( ) add_entrypoint_object( - asinhf + asinh SRCS - asinhf.cpp + asinh.cpp HDRS - ../../asinhf.h + ../../asinh.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + atan + SRCS + atan.cpp + HDRS + ../../atan.h COMPILE_OPTIONS ${bitcode_link_flags} -O2 @@ -84,6 +128,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 +216,50 @@ 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( + exp + SRCS + exp.cpp + HDRS + ../../exp.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + exp10 + SRCS + exp10.cpp + HDRS + ../../exp10.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + add_entrypoint_object( exp10f SRCS @@ -150,6 +271,17 @@ add_entrypoint_object( -O2 ) +add_entrypoint_object( + exp2 + SRCS + exp2.cpp + HDRS + ../../exp2.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + add_entrypoint_object( exp2f SRCS @@ -172,6 +304,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 @@ -249,6 +392,94 @@ add_entrypoint_object( -O2 ) +add_entrypoint_object( + log10 + SRCS + log10.cpp + HDRS + ../../log10.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + log10f + SRCS + log10f.cpp + HDRS + ../../log10f.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + log2 + SRCS + log2.cpp + HDRS + ../../log2.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + log2f + SRCS + log2f.cpp + HDRS + ../../log2f.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + log + SRCS + log.cpp + HDRS + ../../log.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + logf + SRCS + logf.cpp + HDRS + ../../logf.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + lrint + SRCS + lrint.cpp + HDRS + ../../lrint.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + lrintf + SRCS + lrintf.cpp + HDRS + ../../lrintf.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + add_entrypoint_object( ldexp SRCS @@ -272,67 +503,66 @@ add_entrypoint_object( ) add_entrypoint_object( - llrint + log1p SRCS - llrint.cpp + log1p.cpp HDRS - ../../llrint.h + ../../log1p.h COMPILE_OPTIONS ${bitcode_link_flags} -O2 ) add_entrypoint_object( - llrintf + log1pf SRCS - llrintf.cpp + log1pf.cpp HDRS - ../../llrintf.h + ../../log1pf.h COMPILE_OPTIONS ${bitcode_link_flags} -O2 ) add_entrypoint_object( - remquo + llrint SRCS - remquo.cpp + llrint.cpp HDRS - ../../remquo.h + ../../llrint.h COMPILE_OPTIONS ${bitcode_link_flags} -O2 ) add_entrypoint_object( - remquof + llrintf SRCS - remquof.cpp + llrintf.cpp HDRS - ../../remquof.h + ../../llrintf.h COMPILE_OPTIONS ${bitcode_link_flags} -O2 ) - add_entrypoint_object( - llround + remquo SRCS - llround.cpp + remquo.cpp HDRS - ../../llround.h + ../../remquo.h COMPILE_OPTIONS ${bitcode_link_flags} -O2 ) add_entrypoint_object( - llroundf + remquof SRCS - llroundf.cpp + remquof.cpp HDRS - ../../llroundf.h + ../../remquof.h COMPILE_OPTIONS ${bitcode_link_flags} -O2 @@ -515,6 +745,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 0000000000000..83b674fa6ae3b --- /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 LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, acos, (double x)) { return internal::acos(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/acosh.cpp b/libc/src/math/gpu/vendor/acosh.cpp new file mode 100644 index 0000000000000..cc1b8b572b3db --- /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 LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, acosh, (double x)) { return internal::acosh(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h index 280ae49989f94..43961fc75982a 100644 --- a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h +++ b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h @@ -16,19 +16,33 @@ namespace LIBC_NAMESPACE { 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(float x) { return __ocml_cosh_f32(x); } +LIBC_INLINE double erf(double x) { return __ocml_erf_f64(x); } +LIBC_INLINE float erff(float x) { return __ocml_erf_f32(x); } +LIBC_INLINE double exp(double x) { return __builtin_exp(x); } LIBC_INLINE float expf(float x) { return __builtin_expf(x); } -LIBC_INLINE float exp2f(float x) { return __builtin_exp2f(x); } +LIBC_INLINE double exp2(double x) { return __ocml_exp2_f64(x); } +LIBC_INLINE float exp2f(float x) { return __ocml_exp2_f32(x); } +LIBC_INLINE double exp10(double x) { return __ocml_exp10_f64(x); } LIBC_INLINE float exp10f(float x) { return __ocml_exp10_f32(x); } +LIBC_INLINE double expm1(double x) { return __ocml_expm1_f64(x); } LIBC_INLINE float expm1f(float x) { return __ocml_expm1_f32(x); } LIBC_INLINE double fdim(double x, double y) { return __ocml_fdim_f64(x, y); } LIBC_INLINE float fdimf(float x, float y) { return __ocml_fdim_f32(x, y); } @@ -44,11 +58,19 @@ LIBC_INLINE long long llrint(double x) { LIBC_INLINE long long llrintf(float x) { return static_cast(__builtin_rintf(x)); } -LIBC_INLINE long long llround(double x) { - return static_cast(__builtin_round(x)); +LIBC_INLINE double log10(double x) { return __ocml_log10_f64(x); } +LIBC_INLINE float log10f(float x) { return __ocml_log10_f32(x); } +LIBC_INLINE double log1p(double x) { return __ocml_log1p_f64(x); } +LIBC_INLINE float log1pf(float x) { return __ocml_log1p_f32(x); } +LIBC_INLINE double log2(double x) { return __ocml_log2_f64(x); } +LIBC_INLINE float log2f(float x) { return __ocml_log2_f32(x); } +LIBC_INLINE double log(double x) { return __ocml_log_f64(x); } +LIBC_INLINE float logf(float x) { return __ocml_log_f32(x); } +LIBC_INLINE long lrint(double x) { + return static_cast(__builtin_rint(x)); } -LIBC_INLINE long long llroundf(float x) { - return static_cast(__builtin_roundf(x)); +LIBC_INLINE long lrintf(float x) { + return static_cast(__builtin_rintf(x)); } LIBC_INLINE double nextafter(double x, double y) { return __ocml_nextafter_f64(x, y); @@ -96,6 +118,8 @@ LIBC_INLINE float remquof(float x, float y, int *q) { *q = tmp; return r; } +LIBC_INLINE double tgamma(double x) { return __ocml_tgamma_f64(x); } +LIBC_INLINE float tgammaf(float x) { return __ocml_tgamma_f32(x); } } // namespace internal } // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/amdgpu/declarations.h b/libc/src/math/gpu/vendor/amdgpu/declarations.h index b07c079682580..7a01cbc6ab19d 100644 --- a/libc/src/math/gpu/vendor/amdgpu/declarations.h +++ b/libc/src/math/gpu/vendor/amdgpu/declarations.h @@ -15,35 +15,54 @@ namespace LIBC_NAMESPACE { extern "C" { float __ocml_acos_f32(float); +double __ocml_acos_f64(double); float __ocml_acosh_f32(float); +double __ocml_acosh_f64(double); float __ocml_asin_f32(float); +double __ocml_asin_f64(double); float __ocml_asinh_f32(float); +double __ocml_asinh_f64(double); float __ocml_atan_f32(float); +double __ocml_atan_f64(double); +float __ocml_atan2_f32(float, float); +double __ocml_atan2_f64(double, double); float __ocml_atanh_f32(float); +double __ocml_atanh_f64(double); float __ocml_cos_f32(float); double __ocml_cos_f64(double); float __ocml_cosh_f32(float); double __ocml_cosh_f64(double); +float __ocml_erf_f32(float); +double __ocml_erf_f64(double); float __ocml_exp_f32(float); +double __ocml_exp_f64(double); float __ocml_exp2_f32(float); +double __ocml_exp2_f64(double); float __ocml_exp10_f32(float); +double __ocml_exp10_f64(double); +double __ocml_exp2_f64(double); float __ocml_expm1_f32(float); +double __ocml_expm1_f64(double); float __ocml_fdim_f32(float, float); double __ocml_fdim_f64(double, double); -double __ocml_hypot_f64(double, double); float __ocml_hypot_f32(float, float); +double __ocml_hypot_f64(double, double); int __ocml_ilogb_f64(double); int __ocml_ilogb_f32(float); float __ocml_ldexp_f32(float, int); double __ocml_ldexp_f64(double, int); +float __ocml_log10_f32(float); +double __ocml_log10_f64(double); +float __ocml_log1p_f32(float); +double __ocml_log1p_f64(double); +float __ocml_log2_f32(float); +double __ocml_log2_f64(double); +float __ocml_log_f32(float); +double __ocml_log_f64(double); float __ocml_nextafter_f32(float, float); double __ocml_nextafter_f64(double, double); float __ocml_pow_f32(float, float); double __ocml_pow_f64(double, double); -double __ocml_rint_f64(double); -float __ocml_rint_f32(float); -double __ocml_round_f64(double); -float __ocml_round_f32(float); float __ocml_sin_f32(float); double __ocml_sin_f64(double); float __ocml_sincos_f32(float, float *); @@ -56,6 +75,8 @@ float __ocml_tanh_f32(float); double __ocml_tanh_f64(double); float __ocml_remquo_f32(float, float, gpu::Private *); double __ocml_remquo_f64(double, double, gpu::Private *); +double __ocml_tgamma_f64(double); +float __ocml_tgamma_f32(float); } } // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/asin.cpp b/libc/src/math/gpu/vendor/asin.cpp new file mode 100644 index 0000000000000..24a8a136e88eb --- /dev/null +++ b/libc/src/math/gpu/vendor/asin.cpp @@ -0,0 +1,18 @@ +//===-- 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/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, asin, (double x)) { return internal::asin(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/asinh.cpp b/libc/src/math/gpu/vendor/asinh.cpp new file mode 100644 index 0000000000000..f417d9fd8c1f7 --- /dev/null +++ b/libc/src/math/gpu/vendor/asinh.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU asinh 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/asinh.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, asinh, (double x)) { return internal::asinh(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/atan.cpp b/libc/src/math/gpu/vendor/atan.cpp new file mode 100644 index 0000000000000..45d7f02c02cd6 --- /dev/null +++ b/libc/src/math/gpu/vendor/atan.cpp @@ -0,0 +1,18 @@ +//===-- 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/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, atan, (double x)) { return internal::atan(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/atan2.cpp b/libc/src/math/gpu/vendor/atan2.cpp new file mode 100644 index 0000000000000..94e215e52ca60 --- /dev/null +++ b/libc/src/math/gpu/vendor/atan2.cpp @@ -0,0 +1,20 @@ +//===-- 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/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, atan2, (double x, double y)) { + return internal::atan2(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/atan2f.cpp b/libc/src/math/gpu/vendor/atan2f.cpp new file mode 100644 index 0000000000000..70caa568e32d9 --- /dev/null +++ b/libc/src/math/gpu/vendor/atan2f.cpp @@ -0,0 +1,20 @@ +//===-- 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/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float, atan2f, (float x, float y)) { + return internal::atan2f(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/atanh.cpp b/libc/src/math/gpu/vendor/atanh.cpp new file mode 100644 index 0000000000000..07a75fcbbfc7c --- /dev/null +++ b/libc/src/math/gpu/vendor/atanh.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU atanh 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/atanh.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, atanh, (double x)) { return internal::atanh(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/tanhf.cpp b/libc/src/math/gpu/vendor/erf.cpp similarity index 68% rename from libc/src/math/gpu/tanhf.cpp rename to libc/src/math/gpu/vendor/erf.cpp index be666fd9f8740..190321ca25992 100644 --- a/libc/src/math/gpu/tanhf.cpp +++ b/libc/src/math/gpu/vendor/erf.cpp @@ -1,4 +1,4 @@ -//===-- Implementation of the GPU tanhf function --------------------------===// +//===-- Implementation of the GPU erf function ----------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,11 +6,13 @@ // //===----------------------------------------------------------------------===// -#include "src/math/tanhf.h" +#include "src/math/erf.h" #include "src/__support/common.h" +#include "common.h" + namespace LIBC_NAMESPACE { -LLVM_LIBC_FUNCTION(float, tanhf, (float x)) { return __builtin_tanhf(x); } +LLVM_LIBC_FUNCTION(double, erf, (double x)) { return internal::erf(x); } } // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/erff.cpp b/libc/src/math/gpu/vendor/erff.cpp new file mode 100644 index 0000000000000..a5a08be54b075 --- /dev/null +++ b/libc/src/math/gpu/vendor/erff.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU erff 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/erff.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float, erff, (float x)) { return internal::erff(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/exp.cpp b/libc/src/math/gpu/vendor/exp.cpp new file mode 100644 index 0000000000000..ee5a22019f6a5 --- /dev/null +++ b/libc/src/math/gpu/vendor/exp.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU exp 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/exp.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, exp, (double x)) { return internal::exp(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/exp10.cpp b/libc/src/math/gpu/vendor/exp10.cpp new file mode 100644 index 0000000000000..8557a33f01884 --- /dev/null +++ b/libc/src/math/gpu/vendor/exp10.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU exp10 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/exp10.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, exp10, (double x)) { return internal::exp10(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/exp2.cpp b/libc/src/math/gpu/vendor/exp2.cpp new file mode 100644 index 0000000000000..ffa23d810a9b1 --- /dev/null +++ b/libc/src/math/gpu/vendor/exp2.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU exp2 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/exp2.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, exp2, (double x)) { return internal::exp2(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/expm1.cpp b/libc/src/math/gpu/vendor/expm1.cpp new file mode 100644 index 0000000000000..6ac5f753b9e4d --- /dev/null +++ b/libc/src/math/gpu/vendor/expm1.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU expm1 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/expm1.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, expm1, (double x)) { return internal::expm1(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/log.cpp b/libc/src/math/gpu/vendor/log.cpp new file mode 100644 index 0000000000000..a97689abcc217 --- /dev/null +++ b/libc/src/math/gpu/vendor/log.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU log 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/log.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, log, (double x)) { return internal::log(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/log10.cpp b/libc/src/math/gpu/vendor/log10.cpp new file mode 100644 index 0000000000000..c7a917a75cc96 --- /dev/null +++ b/libc/src/math/gpu/vendor/log10.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU log10 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/log10.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, log10, (double x)) { return internal::log10(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/log10f.cpp b/libc/src/math/gpu/vendor/log10f.cpp new file mode 100644 index 0000000000000..489f5f558be1f --- /dev/null +++ b/libc/src/math/gpu/vendor/log10f.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU log10f 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/log10f.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float, log10f, (float x)) { return internal::log10f(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/log1p.cpp b/libc/src/math/gpu/vendor/log1p.cpp new file mode 100644 index 0000000000000..720d23e2f952b --- /dev/null +++ b/libc/src/math/gpu/vendor/log1p.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU log1p 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/log1p.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, log1p, (double x)) { return internal::log1p(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/log1pf.cpp b/libc/src/math/gpu/vendor/log1pf.cpp new file mode 100644 index 0000000000000..96ad48b529cf6 --- /dev/null +++ b/libc/src/math/gpu/vendor/log1pf.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU log1pf 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/log1pf.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float, log1pf, (float x)) { return internal::log1pf(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/log2.cpp b/libc/src/math/gpu/vendor/log2.cpp new file mode 100644 index 0000000000000..9fc8a81e7e757 --- /dev/null +++ b/libc/src/math/gpu/vendor/log2.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU log2 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/log2.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, log2, (double x)) { return internal::log2(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/log2f.cpp b/libc/src/math/gpu/vendor/log2f.cpp new file mode 100644 index 0000000000000..62df41b69b0bd --- /dev/null +++ b/libc/src/math/gpu/vendor/log2f.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU log2f 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/log2f.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float, log2f, (float x)) { return internal::log2f(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/logb.cpp b/libc/src/math/gpu/vendor/logb.cpp new file mode 100644 index 0000000000000..5dea57d41b08b --- /dev/null +++ b/libc/src/math/gpu/vendor/logb.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU logb 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/logb.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, logb, (double x)) { return internal::logb(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/logbf.cpp b/libc/src/math/gpu/vendor/logbf.cpp new file mode 100644 index 0000000000000..1a59df3e09a89 --- /dev/null +++ b/libc/src/math/gpu/vendor/logbf.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU logbf 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/logbf.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float, logbf, (float x)) { return internal::logbf(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/logf.cpp b/libc/src/math/gpu/vendor/logf.cpp new file mode 100644 index 0000000000000..527b028e100d5 --- /dev/null +++ b/libc/src/math/gpu/vendor/logf.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU logf 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/logf.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float, logf, (float x)) { return internal::logf(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/lrint.cpp b/libc/src/math/gpu/vendor/lrint.cpp new file mode 100644 index 0000000000000..a08996b755b52 --- /dev/null +++ b/libc/src/math/gpu/vendor/lrint.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the lrint 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/lrint.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(long, lrint, (double x)) { return internal::lrint(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/lrintf.cpp b/libc/src/math/gpu/vendor/lrintf.cpp new file mode 100644 index 0000000000000..695a9b8202cf4 --- /dev/null +++ b/libc/src/math/gpu/vendor/lrintf.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the lrintf 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/lrintf.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(long, lrintf, (float x)) { return internal::lrintf(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/vendor/nvptx/declarations.h index 003a9a8a5dfa5..9cb2be67b85b1 100644 --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/nvptx/declarations.h @@ -12,19 +12,33 @@ namespace LIBC_NAMESPACE { extern "C" { +double __nv_acos(double); float __nv_acosf(float); +double __nv_acosh(double); float __nv_acoshf(float); +double __nv_asin(double); float __nv_asinf(float); +double __nv_asinh(double); float __nv_asinhf(float); +double __nv_atan(double); float __nv_atanf(float); +double __nv_atan2(double, double); +float __nv_atan2f(float, float); +double __nv_atanh(double); float __nv_atanhf(float); double __nv_cos(double); float __nv_cosf(float); double __nv_cosh(double); float __nv_coshf(float); +double __nv_erf(double); +float __nv_erff(float); +double __nv_exp(double); float __nv_expf(float); +double __nv_exp2(double); float __nv_exp2f(float); +double __nv_exp10(double); float __nv_exp10f(float); +double __nv_expm1(double); float __nv_expm1f(float); double __nv_fdim(double, double); float __nv_fdimf(float, float); @@ -36,8 +50,16 @@ double __nv_ldexp(double, int); float __nv_ldexpf(float, int); long long __nv_llrint(double); long long __nv_llrintf(float); -long long __nv_llround(double); -long long __nv_llroundf(float); +long __nv_lrint(double); +long __nv_lrintf(float); +double __nv_log10(double); +float __nv_log10f(float); +double __nv_log1p(double); +float __nv_log1pf(float); +double __nv_log2(double); +float __nv_log2f(float); +double __nv_log(double); +float __nv_logf(float); double __nv_nextafter(double, double); float __nv_nextafterf(float, float); double __nv_pow(double, double); @@ -58,6 +80,8 @@ double __nv_scalbn(double, int); float __nv_scalbnf(float, int); double __nv_remquo(double, double, int *); float __nv_remquof(float, float, int *); +double __nv_tgamma(double); +float __nv_tgammaf(float); } } // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/nvptx/nvptx.h b/libc/src/math/gpu/vendor/nvptx/nvptx.h index 4298d56db6a02..110d570a84a39 100644 --- a/libc/src/math/gpu/vendor/nvptx/nvptx.h +++ b/libc/src/math/gpu/vendor/nvptx/nvptx.h @@ -15,19 +15,33 @@ namespace LIBC_NAMESPACE { namespace internal { +LIBC_INLINE double acos(double x) { return __nv_acos(x); } LIBC_INLINE float acosf(float x) { return __nv_acosf(x); } +LIBC_INLINE double acosh(double x) { return __nv_acosh(x); } LIBC_INLINE float acoshf(float x) { return __nv_acoshf(x); } +LIBC_INLINE double asin(double x) { return __nv_asin(x); } LIBC_INLINE float asinf(float x) { return __nv_asinf(x); } +LIBC_INLINE double asinh(double x) { return __nv_asinh(x); } LIBC_INLINE float asinhf(float x) { return __nv_asinhf(x); } +LIBC_INLINE double atan2(double x, double y) { return __nv_atan2(x, y); } +LIBC_INLINE float atan2f(float x, float y) { return __nv_atan2f(x, y); } +LIBC_INLINE double atan(double x) { return __nv_atan(x); } LIBC_INLINE float atanf(float x) { return __nv_atanf(x); } +LIBC_INLINE double atanh(double x) { return __nv_atanh(x); } LIBC_INLINE float atanhf(float x) { return __nv_atanhf(x); } LIBC_INLINE double cos(double x) { return __nv_cos(x); } LIBC_INLINE float cosf(float x) { return __nv_cosf(x); } LIBC_INLINE double cosh(double x) { return __nv_cosh(x); } LIBC_INLINE float coshf(float x) { return __nv_coshf(x); } +LIBC_INLINE double erf(double x) { return __nv_erf(x); } +LIBC_INLINE float erff(float x) { return __nv_erff(x); } +LIBC_INLINE double exp(double x) { return __nv_exp(x); } LIBC_INLINE float expf(float x) { return __nv_expf(x); } +LIBC_INLINE double exp2(double x) { return __nv_exp2(x); } LIBC_INLINE float exp2f(float x) { return __nv_exp2f(x); } +LIBC_INLINE double exp10(double x) { return __nv_exp10(x); } LIBC_INLINE float exp10f(float x) { return __nv_exp10f(x); } +LIBC_INLINE double expm1(double x) { return __nv_expm1(x); } LIBC_INLINE float expm1f(float x) { return __nv_expm1f(x); } LIBC_INLINE double fdim(double x, double y) { return __nv_fdim(x, y); } LIBC_INLINE float fdimf(float x, float y) { return __nv_fdimf(x, y); } @@ -39,8 +53,16 @@ LIBC_INLINE double ldexp(double x, int i) { return __nv_ldexp(x, i); } LIBC_INLINE float ldexpf(float x, int i) { return __nv_ldexpf(x, i); } LIBC_INLINE long long llrint(double x) { return __nv_llrint(x); } LIBC_INLINE long long llrintf(float x) { return __nv_llrintf(x); } -LIBC_INLINE long long llround(double x) { return __nv_llround(x); } -LIBC_INLINE long long llroundf(float x) { return __nv_llroundf(x); } +LIBC_INLINE double log10(double x) { return __nv_log10(x); } +LIBC_INLINE float log10f(float x) { return __nv_log10f(x); } +LIBC_INLINE double log1p(double x) { return __nv_log1p(x); } +LIBC_INLINE float log1pf(float x) { return __nv_log1pf(x); } +LIBC_INLINE double log2(double x) { return __nv_log2(x); } +LIBC_INLINE float log2f(float x) { return __nv_log2f(x); } +LIBC_INLINE double log(double x) { return __nv_log(x); } +LIBC_INLINE float logf(float x) { return __nv_logf(x); } +LIBC_INLINE long lrint(double x) { return __nv_lrint(x); } +LIBC_INLINE long lrintf(float x) { return __nv_lrintf(x); } LIBC_INLINE double nextafter(double x, double y) { return __nv_nextafter(x, y); } @@ -71,6 +93,8 @@ LIBC_INLINE double remquo(double x, double y, int *i) { LIBC_INLINE float remquof(float x, float y, int *i) { return __nv_remquof(x, y, i); } +LIBC_INLINE double tgamma(double x) { return __nv_tgamma(x); } +LIBC_INLINE float tgammaf(float x) { return __nv_tgammaf(x); } } // namespace internal } // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/tgamma.cpp b/libc/src/math/gpu/vendor/tgamma.cpp new file mode 100644 index 0000000000000..e86116a2b0abe --- /dev/null +++ b/libc/src/math/gpu/vendor/tgamma.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU tgamma 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/tgamma.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(double, tgamma, (double x)) { return internal::tgamma(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/gpu/vendor/tgammaf.cpp b/libc/src/math/gpu/vendor/tgammaf.cpp new file mode 100644 index 0000000000000..552919bae4469 --- /dev/null +++ b/libc/src/math/gpu/vendor/tgammaf.cpp @@ -0,0 +1,18 @@ +//===-- Implementation of the GPU tgammaf 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/tgammaf.h" +#include "src/__support/common.h" + +#include "common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float, tgammaf, (float x)) { return internal::tgammaf(x); } + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/sincos.h b/libc/src/math/sincos.h new file mode 100644 index 0000000000000..6235a7c5c0454 --- /dev/null +++ b/libc/src/math/sincos.h @@ -0,0 +1,18 @@ +//===-- Implementation header for sincos ------------------------*- 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_SINCOS_H +#define LLVM_LIBC_SRC_MATH_SINCOS_H + +namespace LIBC_NAMESPACE { + +void sincos(double x, double *sinx, double *cosx); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_SINCOS_H diff --git a/libc/src/math/tgamma.h b/libc/src/math/tgamma.h new file mode 100644 index 0000000000000..24590ed1a4676 --- /dev/null +++ b/libc/src/math/tgamma.h @@ -0,0 +1,18 @@ +//===-- Implementation header for tgamma ------------------------*- 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_TGAMMA_H +#define LLVM_LIBC_SRC_MATH_TGAMMA_H + +namespace LIBC_NAMESPACE { + +double tgamma(double x); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_TGAMMA_H diff --git a/libc/src/math/tgammaf.h b/libc/src/math/tgammaf.h new file mode 100644 index 0000000000000..d28e4c325152a --- /dev/null +++ b/libc/src/math/tgammaf.h @@ -0,0 +1,18 @@ +//===-- Implementation header for tgammaf -----------------------*- 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_TGAMMAF_H +#define LLVM_LIBC_SRC_MATH_TGAMMAF_H + +namespace LIBC_NAMESPACE { + +float tgammaf(float x); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_TGAMMAF_H