diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt --- a/libc/config/gpu/entrypoints.txt +++ b/libc/config/gpu/entrypoints.txt @@ -100,9 +100,45 @@ libc.src.math.fma libc.src.math.fmaf libc.src.math.sin + libc.src.math.modf + libc.src.math.modff + libc.src.math.modfl + libc.src.math.nearbyint + libc.src.math.nearbyintf + libc.src.math.nearbyintl + libc.src.math.nextafter + libc.src.math.nextafterf + libc.src.math.nextafterl + libc.src.math.remainder + libc.src.math.remainderf + libc.src.math.remainderl + libc.src.math.remquo + libc.src.math.remquof + libc.src.math.remquol + libc.src.math.rint + libc.src.math.rintf + libc.src.math.rintl libc.src.math.round libc.src.math.roundf libc.src.math.roundl + libc.src.math.scalbn + libc.src.math.scalbnf + libc.src.math.scalbnl + libc.src.math.sinh + libc.src.math.sinhf + libc.src.math.sinhl + libc.src.math.sqrt + libc.src.math.sqrtf + libc.src.math.sqrtl + libc.src.math.tan + libc.src.math.tanf + libc.src.math.tanl + libc.src.math.tanh + libc.src.math.tanhf + libc.src.math.tanhl + libc.src.math.trunc + libc.src.math.truncf + libc.src.math.truncl ) set(TARGET_LLVMLIBC_ENTRYPOINTS diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt --- a/libc/src/math/CMakeLists.txt +++ b/libc/src/math/CMakeLists.txt @@ -192,7 +192,10 @@ add_math_entrypoint_object(sin) add_math_entrypoint_object(sinf) + +add_math_entrypoint_object(sinh) add_math_entrypoint_object(sinhf) +add_math_entrypoint_object(sinhl) add_math_entrypoint_object(sqrt) add_math_entrypoint_object(sqrtf) @@ -200,7 +203,11 @@ add_math_entrypoint_object(tan) add_math_entrypoint_object(tanf) +add_math_entrypoint_object(tanl) + +add_math_entrypoint_object(tanh) add_math_entrypoint_object(tanhf) +add_math_entrypoint_object(tanhl) add_math_entrypoint_object(trunc) add_math_entrypoint_object(truncf) diff --git a/libc/src/math/gpu/CMakeLists.txt b/libc/src/math/gpu/CMakeLists.txt --- a/libc/src/math/gpu/CMakeLists.txt +++ b/libc/src/math/gpu/CMakeLists.txt @@ -23,6 +23,186 @@ ) endfunction() +add_math_entrypoint_gpu_object( + modf + SRCS + modf.cpp + HDRS + ../modf.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + modff + SRCS + modff.cpp + HDRS + ../modff.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + modfl + SRCS + modfl.cpp + HDRS + ../modfl.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + nearbyint + SRCS + nearbyint.cpp + HDRS + ../nearbyint.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + nearbyintf + SRCS + nearbyintf.cpp + HDRS + ../nearbyintf.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + nearbyintl + SRCS + nearbyintl.cpp + HDRS + ../nearbyintl.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + nextafter + SRCS + nextafter.cpp + HDRS + ../nextafter.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + nextafterf + SRCS + nextafterf.cpp + HDRS + ../nextafterf.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + nextafterl + SRCS + nextafterl.cpp + HDRS + ../nextafterl.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + remainder + SRCS + remainder.cpp + HDRS + ../remainder.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + remainderf + SRCS + remainderf.cpp + HDRS + ../remainderf.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + remainderl + SRCS + remainderl.cpp + HDRS + ../remainderl.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + remquo + SRCS + remquo.cpp + HDRS + ../remquo.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + remquof + SRCS + remquof.cpp + HDRS + ../remquof.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + remquol + SRCS + remquol.cpp + HDRS + ../remquol.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + rint + SRCS + rint.cpp + HDRS + ../rint.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + rintf + SRCS + rintf.cpp + HDRS + ../rintf.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + rintl + SRCS + rintl.cpp + HDRS + ../rintl.h + COMPILE_OPTIONS + -O2 +) + add_math_entrypoint_gpu_object( round SRCS @@ -32,3 +212,183 @@ COMPILE_OPTIONS -O2 ) + +add_math_entrypoint_gpu_object( + scalbn + SRCS + scalbn.cpp + HDRS + ../scalbn.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + scalbnf + SRCS + scalbnf.cpp + HDRS + ../scalbnf.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + scalbnl + SRCS + scalbnl.cpp + HDRS + ../scalbnl.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + sinh + SRCS + sinh.cpp + HDRS + ../sinh.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + sinhf + SRCS + sinhf.cpp + HDRS + ../sinhf.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + sinhl + SRCS + sinhl.cpp + HDRS + ../sinhl.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + sqrt + SRCS + sqrt.cpp + HDRS + ../sqrt.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + sqrtf + SRCS + sqrtf.cpp + HDRS + ../sqrtf.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + sqrtl + SRCS + sqrtl.cpp + HDRS + ../sqrtl.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + tan + SRCS + tan.cpp + HDRS + ../tan.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + tanf + SRCS + tanf.cpp + HDRS + ../tanf.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + tanl + SRCS + tanl.cpp + HDRS + ../tanl.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + tanh + SRCS + tanh.cpp + HDRS + ../tanh.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + tanhf + SRCS + tanhf.cpp + HDRS + ../tanhf.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + tanhl + SRCS + tanhl.cpp + HDRS + ../tanhl.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + trunc + SRCS + trunc.cpp + HDRS + ../trunc.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + truncf + SRCS + truncf.cpp + HDRS + ../truncf.h + COMPILE_OPTIONS + -O2 +) + +add_math_entrypoint_gpu_object( + truncl + SRCS + truncl.cpp + HDRS + ../truncl.h + COMPILE_OPTIONS + -O2 +) \ No newline at end of file diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/modf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/modf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/modf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU modf 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/modf.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(double, modf, (double x, double *iptr)) { + return __builtin_modf(x, iptr); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/modff.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/modff.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/modff.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU modff 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/modff.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(float, modff, (float x, float *iptr)) { + return __builtin_modff(x, iptr); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/modfl.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/modfl.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/modfl.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU modfl 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/modfl.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(long double, modfl, (long double x, long double *iptr)) { + return __builtin_modfl(x, iptr); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/nearbyint.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/nearbyint.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/nearbyint.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU nearbyint 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/nearbyint.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(double, nearbyint, (double x)) { + return __builtin_nearbyint(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/nearbyintf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/nearbyintf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/nearbyintf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU nearbyintf 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/nearbyintf.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(float, nearbyintf, (float x)) { + return __builtin_nearbyintf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/nearbyintl.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/nearbyintl.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/nearbyintl.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU nearbyintl 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/nearbyintl.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(long double, nearbyintl, (long double x)) { + return __builtin_nearbyintl(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/nextafter.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/nextafter.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/nextafter.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU nextafter 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/nextafter.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(double, nextafter, (double x, double y)) { + return __builtin_nextafter(x, y); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/nextafterf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/nextafterf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/nextafterf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU nextafterf 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/nextafterf.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(float, nextafterf, (float x, float y)) { + return __builtin_nextafterf(x, y); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/nextafterl.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/nextafterl.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/nextafterl.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU nextafterl 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/nextafterl.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(long double, nextafterl, (long double x, long double y)) { + return __builtin_nextafterl(x, y); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/remainder.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/remainder.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/remainder.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU remainder 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/remainder.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(double, remainder, (double x, double y)) { + return __builtin_remainder(x, y); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/remainderf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/remainderf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/remainderf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU remainderf 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/remainderf.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(float, remainderf, (float x, float y)) { + return __builtin_remainderf(x, y); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/remainderl.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/remainderl.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/remainderl.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU remainderl 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/remainderl.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(long double, remainderl, (long double x, long double y)) { + return __builtin_remainderl(x, y); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/remquo.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/remquo.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/remquo.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU remquo 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/remquo.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(double, remquo, (double x, double y, int *quo)) { + return __builtin_remquo(x, y, quo); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/remquof.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/remquof.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/remquof.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU remquof 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/remquof.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(float, remquof, (float x, float y, int *quo)) { + return __builtin_remquof(x, y, quo); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/amdgpu/declarations.h b/libc/src/math/gpu/remquol.cpp copy from libc/src/math/gpu/vendor/amdgpu/declarations.h copy to libc/src/math/gpu/remquol.cpp --- a/libc/src/math/gpu/vendor/amdgpu/declarations.h +++ b/libc/src/math/gpu/remquol.cpp @@ -1,4 +1,4 @@ -//===-- AMDGPU specific declarations for math support ---------------------===// +//===-- Implementation of the GPU remquol 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,15 +6,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_AMDGPU_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_AMDGPU_DECLARATIONS_H +#include "src/math/remquol.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __ocml_sin_f64(double); +LLVM_LIBC_FUNCTION(long double, remquol, + (long double x, long double y, int *quo)) { + return __builtin_remquol(x, y, quo); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_AMDGPU_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/rint.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/rint.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/rint.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU rint 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,15 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/rint.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(double, rint, (double x)) { return __builtin_rint(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/rintf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/rintf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/rintf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU rintf 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,15 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/rintf.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(float, rintf, (float x)) { return __builtin_rintf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/rintl.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/rintl.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/rintl.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU rintl 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/rintl.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(long double, rintl, (long double x)) { + return __builtin_rintl(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/scalbn.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/scalbn.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/scalbn.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU scalbn 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/scalbn.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(double, scalbn, (double x, int y)) { + return __builtin_scalbn(x, y); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/scalbnf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/scalbnf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/scalbnf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU scalbnf 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/scalbnf.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(float, scalbnf, (float x, int y)) { + return __builtin_scalbnf(x, y); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/scalbnl.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/scalbnl.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/scalbnl.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU scalbnl 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/__support/common.h" +#include "src/math/scalbn.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(long double, scalbn, (long double x, int y)) { + return __builtin_scalbnl(x, y); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/sinh.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/sinh.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/sinh.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU sinh 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,15 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/sinh.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(double, sinh, (double x)) { return __builtin_sinh(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/sinhf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/sinhf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/sinhf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU sinhf 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,15 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/sinhf.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(float, sinhf, (float x)) { return __builtin_sinhf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/sinhl.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/sinhl.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/sinhl.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU sinhl 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/sinhl.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(long double, sinhl, (long double x)) { + return __builtin_sinhl(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/sqrt.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/sqrt.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/sqrt.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU sqrt 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,15 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/sqrt.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(double, sqrt, (double x)) { return __builtin_sqrt(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/sqrtf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/sqrtf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/sqrtf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU sqrtf 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,15 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/sqrtf.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(float, sqrtf, (float x)) { return __builtin_sqrtf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/sqrtl.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/sqrtl.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/sqrtl.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU sqrtl 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/sqrtl.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(long double, sqrtl, (long double x)) { + return __builtin_sqrtl(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/tan.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/tan.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/tan.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU tan 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,15 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/tan.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(double, tan, (double x)) { return __builtin_tan(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/tanf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/tanf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/tanf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU tanf 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,15 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/tanf.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(float, tanf, (float x)) { return __builtin_tanf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/tanh.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/tanh.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/tanh.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU tanh 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,15 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/tanh.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(double, tanh, (double x)) { return __builtin_tanh(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/tanhf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/tanhf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/tanhf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU tanhf 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,15 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/tanhf.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(float, tanhf, (float x)) { return __builtin_tanhf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/tanhl.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/tanhl.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/tanhl.cpp @@ -1,4 +1,5 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU tanhl 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,15 +7,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/tanhl.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(long double, tanhl, (long double x)) { + return __builtin_tanhl(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/tanl.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/tanl.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/tanl.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU tanl 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,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/tanl.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(long double, tanl, (long double x)) { + return __builtin_tanl(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/trunc.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/trunc.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/trunc.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU trunc 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,15 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/trunc.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(double, trunc, (double x)) { return __builtin_trunc(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/truncf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/truncf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/truncf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU truncf 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,15 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/truncf.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(double, truncf, (double x)) { return __builtin_truncf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/truncl.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/truncl.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/truncl.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the GPU truncl 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,15 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/truncl.h" +#include "src/__support/common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(double, truncl, (double x)) { return __builtin_truncl(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/CMakeLists.txt b/libc/src/math/gpu/vendor/CMakeLists.txt --- a/libc/src/math/gpu/vendor/CMakeLists.txt +++ b/libc/src/math/gpu/vendor/CMakeLists.txt @@ -39,3 +39,36 @@ ${bitcode_link_flags} -O2 ) + +add_entrypoint_object( + sinf + SRCS + sinf.cpp + HDRS + ../../sinf.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + sincos + SRCS + sincos.cpp + HDRS + ../../sincos.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + sincosf + SRCS + sincosf.cpp + HDRS + ../../sincosf.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) \ No newline at end of file diff --git a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h --- a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h +++ b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h @@ -18,6 +18,13 @@ namespace internal { LIBC_INLINE double sin(double x) { return __ocml_sin_f64(x); } +LIBC_INLINE float sinf(float x) { return __ocml_sin_f32(x); } +LIBC_INLINE void sincos(double x, double *sinptr, double *cosptr) { + *sinptr = __ocml_sincos_f64(x, cosptr); +} +LIBC_INLINE void sincosf(float x, float *sinptr, float *cosptr) { + *sinptr = __ocml_sincos_f32(x, cosptr); +} } // namespace internal } // namespace __llvm_libc diff --git a/libc/src/math/gpu/vendor/amdgpu/declarations.h b/libc/src/math/gpu/vendor/amdgpu/declarations.h --- a/libc/src/math/gpu/vendor/amdgpu/declarations.h +++ b/libc/src/math/gpu/vendor/amdgpu/declarations.h @@ -12,7 +12,11 @@ namespace __llvm_libc { extern "C" { + +float __ocml_sin_f32(float); double __ocml_sin_f64(double); +float __ocml_sincos_f32(float, float *); +double __ocml_sincos_f64(double, double *); } } // namespace __llvm_libc diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/vendor/nvptx/declarations.h --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/nvptx/declarations.h @@ -13,6 +13,9 @@ extern "C" { double __nv_sin(double); +float __nv_sinf(float); +void __nv_sincos(double, double *, double *); +void __nv_sincosf(float, float *, float *); } } // namespace __llvm_libc diff --git a/libc/src/math/gpu/vendor/nvptx/nvptx.h b/libc/src/math/gpu/vendor/nvptx/nvptx.h --- a/libc/src/math/gpu/vendor/nvptx/nvptx.h +++ b/libc/src/math/gpu/vendor/nvptx/nvptx.h @@ -17,6 +17,13 @@ namespace internal { LIBC_INLINE double sin(double x) { return __nv_sin(x); } +LIBC_INLINE float sinf(float x) { return __nv_sinf(x); } +LIBC_INLINE void sincos(double x, double *sinptr, double *cosptr) { + return __nv_sincos(x, sinptr, cosptr); +} +LIBC_INLINE void sincosf(float x, float *sinptr, float *cosptr) { + return __nv_sincosf(x, sinptr, cosptr); +} } // namespace internal } // namespace __llvm_libc diff --git a/libc/src/math/gpu/vendor/amdgpu/declarations.h b/libc/src/math/gpu/vendor/sincos.cpp copy from libc/src/math/gpu/vendor/amdgpu/declarations.h copy to libc/src/math/gpu/vendor/sincos.cpp --- a/libc/src/math/gpu/vendor/amdgpu/declarations.h +++ b/libc/src/math/gpu/vendor/sincos.cpp @@ -1,4 +1,4 @@ -//===-- AMDGPU specific declarations for math support ---------------------===// +//===-- Implementation of the sincos 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. @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_AMDGPU_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_AMDGPU_DECLARATIONS_H +#include "src/math/sincos.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __ocml_sin_f64(double); +LLVM_LIBC_FUNCTION(void, sincos, (double x, double *sinptr, double *cosptr)) { + return internal::sincos(x, sinptr, cosptr); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_AMDGPU_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/amdgpu/declarations.h b/libc/src/math/gpu/vendor/sincosf.cpp copy from libc/src/math/gpu/vendor/amdgpu/declarations.h copy to libc/src/math/gpu/vendor/sincosf.cpp --- a/libc/src/math/gpu/vendor/amdgpu/declarations.h +++ b/libc/src/math/gpu/vendor/sincosf.cpp @@ -1,4 +1,4 @@ -//===-- AMDGPU specific declarations for math support ---------------------===// +//===-- Implementation of the sincosf 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. @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_AMDGPU_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_AMDGPU_DECLARATIONS_H +#include "src/math/sincosf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __ocml_sin_f64(double); +LLVM_LIBC_FUNCTION(void, sincosf, (float x, float *sinptr, float *cosptr)) { + return internal::sincosf(x, sinptr, cosptr); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_AMDGPU_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/vendor/sinf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/sinf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/sinf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the sinf 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. @@ -6,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/sinf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(float, sinf, (float x)) { return internal::sinf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/sinh.h copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/sinh.h --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/sinh.h @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation header for sinh --------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#ifndef LLVM_LIBC_SRC_MATH_SINH_H +#define LLVM_LIBC_SRC_MATH_SINH_H namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +double sinh(double x); } // namespace __llvm_libc -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#endif // LLVM_LIBC_SRC_MATH_SINH_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/sinhl.h copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/sinhl.h --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/sinhl.h @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation header for sinhl -------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#ifndef LLVM_LIBC_SRC_MATH_SINHL_H +#define LLVM_LIBC_SRC_MATH_SINHL_H namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +long double sinhl(long double x); } // namespace __llvm_libc -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#endif // LLVM_LIBC_SRC_MATH_SINFL_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/tanh.h copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/tanh.h --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/tanh.h @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation header for tanh --------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#ifndef LLVM_LIBC_SRC_MATH_TANH_H +#define LLVM_LIBC_SRC_MATH_TANH_H namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +double tanh(double x); } // namespace __llvm_libc -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#endif // LLVM_LIBC_SRC_MATH_TANH_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/tanhl.h copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/tanhl.h --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/tanhl.h @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation header for tanhl -------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#ifndef LLVM_LIBC_SRC_MATH_TANHL_H +#define LLVM_LIBC_SRC_MATH_TANHL_H namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +long double tanhl(long double x); } // namespace __llvm_libc -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#endif // LLVM_LIBC_SRC_MATH_TANHL_H diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/tanl.h copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/tanl.h --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/tanl.h @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation header for tanl --------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#ifndef LLVM_LIBC_SRC_MATH_TANL_H +#define LLVM_LIBC_SRC_MATH_TANL_H namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +long double tanl(long double x); } // namespace __llvm_libc -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#endif // LLVM_LIBC_SRC_MATH_TANL_H