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 @@ -83,8 +83,23 @@ set(TARGET_LIBM_ENTRYPOINTS # math.h entrypoints - libc.src.math.sin + 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.remainder + libc.src.math.remainderf + libc.src.math.remquo + libc.src.math.remquof + libc.src.math.rint + libc.src.math.rintf libc.src.math.round + libc.src.math.scalbn + libc.src.math.scalbnf + libc.src.math.sin + libc.src.math.sincosf ) set(TARGET_LLVMLIBC_ENTRYPOINTS 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 @@ -27,6 +27,171 @@ # will link in identity metadata from both libraries. This silences the warning. list(APPEND bitcode_link_flags "-Wno-linker-warnings") +add_entrypoint_object( + modf + SRCS + modf.cpp + HDRS + ../../modf.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + modff + SRCS + modff.cpp + HDRS + ../../modff.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + nearbyint + SRCS + nearbyint.cpp + HDRS + ../../nearbyint.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + nearbyintf + SRCS + nearbyintf.cpp + HDRS + ../../nearbyintf.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + nextafter + SRCS + nextafter.cpp + HDRS + ../../nextafter.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + nextafterf + SRCS + nextafterf.cpp + HDRS + ../../nextafterf.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + remainder + SRCS + remainder.cpp + HDRS + ../../remainder.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + remainderf + SRCS + remainderf.cpp + HDRS + ../../remainderf.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + remquo + SRCS + remquo.cpp + HDRS + ../../remquo.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + remquof + SRCS + remquof.cpp + HDRS + ../../remquof.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + rint + SRCS + rint.cpp + HDRS + ../../rint.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + rintf + SRCS + rintf.cpp + HDRS + ../../rintf.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + scalbn + SRCS + scalbn.cpp + HDRS + ../../scalbn.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + scalbnf + SRCS + scalbnf.cpp + HDRS + ../../scalbnf.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + sincosf + SRCS + sincosf.cpp + HDRS + ../../sincosf.h + COMPILE_OPTIONS + ${bitcode_link_flags} + -O2 +) + add_entrypoint_object( sin SRCS 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 @@ -17,7 +17,40 @@ namespace __llvm_libc { namespace internal { +LIBC_INLINE double modf(double x, double *iptr) { + return __ocml_modf_f64(x, iptr); +} +LIBC_INLINE float modff(float x, float *iptr) { + return __ocml_modf_f32(x, iptr); +} +LIBC_INLINE double nearbyint(double x) { return __ocml_nearbyint_f64(x); } +LIBC_INLINE float nearbyintf(float x) { return __ocml_nearbyint_f32(x); } +LIBC_INLINE double nextafter(double x, double y) { + return __ocml_nextafter_f64(x, y); +} +LIBC_INLINE float nextafterf(float x, float y) { + return __ocml_nextafter_f32(x, y); +} +LIBC_INLINE double remainder(double x, double y) { + return __ocml_remainder_f64(x, y); +} +LIBC_INLINE float remainderf(float x, float y) { + return __ocml_remainder_f32(x, y); +} +LIBC_INLINE double remquo(double x, double y, int *quo) { + return __ocml_remquo_f64(x, y, quo); +} +LIBC_INLINE float remquof(float x, float y, int *quo) { + return __ocml_remquo_f32(x, y, quo); +} +LIBC_INLINE double rint(double x) { return __ocml_rint_f64(x); } +LIBC_INLINE float rintf(float x) { return __ocml_rint_f32(x); } +LIBC_INLINE double scalbn(double x, int n) { return __ocml_scalbn_f64(x, n); } +LIBC_INLINE float scalbnf(float x, int n) { return __ocml_scalbn_f32(x, n); } LIBC_INLINE double sin(double x) { return __ocml_sin_f64(x); } +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,22 @@ namespace __llvm_libc { extern "C" { +double __ocml_modf_f64(double, double *); +float __ocml_modf_f32(float, float *); +double __ocml_nearbyint_f64(double); +float __ocml_nearbyint_f32(float); +double __ocml_nextafter_f64(double, double); +float __ocml_nextafter_f32(float, float); +double __ocml_remainder_f64(double, double); +float __ocml_remainder_f32(float, float); +double __ocml_remquo_f64(double, double, int *); +float __ocml_remquo_f32(float, float, int *); +double __ocml_rint_f64(double); +float __ocml_rint_f32(float); +double __ocml_scalbn_f64(double, int); +float __ocml_scalbn_f32(float, int); double __ocml_sin_f64(double); +float __ocml_sincos_f32(float, float *); } } // namespace __llvm_libc diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/vendor/modf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/modf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/modf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the modf 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_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/modf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(double, modf, (double x, double *iptr)) { + return internal::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/vendor/modff.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/modff.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/modff.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the modff 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_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/modff.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(float, modff, (float x, float *iptr)) { + return internal::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/vendor/nearbyint.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/nearbyint.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/nearbyint.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the nearbyint 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_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/nearbyint.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(double, nearbyint, (double x)) { + return internal::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/vendor/nearbyintf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/nearbyintf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/nearbyintf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the nearbyintf 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_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/nearbyintf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(float, nearbyintf, (float x)) { + return internal::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/vendor/nextafter.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/nextafter.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/nextafter.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the nextafter 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_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/nextafter.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(double, nextafter, (double x, double y)) { + return internal::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/vendor/nextafterf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/nextafterf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/nextafterf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the nextafterf 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_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/nextafterf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(double, nextafterf, (double x, double y)) { + return internal::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/vendor/nvptx/declarations.h --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/nvptx/declarations.h @@ -12,7 +12,22 @@ namespace __llvm_libc { extern "C" { +double __nv_modf(double, double *); +float __nv_modff(float, float *); +double __builtin_nearbyint(double); +float __builtin_nearbyintf(float); +double __nv_nextafter(float, float); +float __nv_nextafterf(float, float); +double __nv_remainder(double, double); +float __nv_remainderf(float, float); +double __nv_remquo(double, double, int *); +float __nv_remquof(float, float, int *); +double __builtin_rint(double); +float __builtin_rintf(float); +double __nv_scalbn(double, int); +float __nv_scalbnf(float, int); double __nv_sin(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 @@ -16,8 +16,32 @@ namespace __llvm_libc { namespace internal { +LIBC_INLINE double modf(double x, double *iptr) { return __nv_modf(x, iptr); } +LIBC_INLINE float modff(float x, float *iptr) { return __nv_modff(x, iptr); } +LIBC_INLINE double nearbyint(double x) { return __builtin_nearbyint(x); } +LIBC_INLINE float nearbyintf(float x) { return __builtin_nearbyintf(x); } +LIBC_INLINE double nextafter(double x, double y) { + return __nv_nextafter(x, y); +} +LIBC_INLINE float nextafterf(float x, float y) { return __nv_nextafterf(x, y); } +LIBC_INLINE double remainder(double x, double y) { + return __nv_remainder(x, y); +} +LIBC_INLINE float remainderf(float x, float y) { return __nv_remainderf(x, y); } +LIBC_INLINE double remquo(double x, double y, int *quo) { + return __nv_remquo(x, y, quo); +} +LIBC_INLINE float remquof(float x, float y, int *quo) { + return __nv_remquof(x, y, quo); +} +LIBC_INLINE double rint(double x) { return __builtin_rint(x); } +LIBC_INLINE float rintf(float x) { return __builtin_rintf(x); } +LIBC_INLINE double scalbn(double x, int n) { return __nv_scalbn(x, n); } +LIBC_INLINE float scalbnf(float x, int n) { return __nv_scalbnf(x, n); } LIBC_INLINE double sin(double x) { return __nv_sin(x); } - +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/nvptx/declarations.h b/libc/src/math/gpu/vendor/remainder.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/remainder.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/remainder.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the remainder 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_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/remainder.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(double, remainder, (double x, double y)) { + return internal::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/vendor/remainderf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/remainderf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/remainderf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the remainderf 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_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/remainderf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(float, remainderf, (float x, float y)) { + return internal::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/vendor/remquo.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/remquo.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/remquo.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the remquo 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_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/remquo.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(double, remquo, (double x, double y, int *quo)) { + return internal::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/vendor/remquof.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/remquof.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/remquof.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the remquof 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_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/remquof.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(float, remquof, (float x, float y, int *quo)) { + return internal::remquof(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/vendor/rint.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/rint.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/rint.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the rint 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/rint.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(double, rint, (double x)) { return internal::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/vendor/rintf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/rintf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/rintf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the rintf 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/rintf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(float, rintf, (float x)) { return internal::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/vendor/scalbn.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/scalbn.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/scalbn.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the scalbn 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_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/scalbn.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(double, scalbn, (double x, int n)) { + return internal::scalbn(x, n); } } // 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/vendor/scalbnf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/scalbnf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/scalbnf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the scalbnf 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_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/scalbnf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); +LLVM_LIBC_FUNCTION(float, scalbnf, (float x, int n)) { + return internal::scalbnf(x, n); } } // 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/vendor/sincosf.cpp copy from libc/src/math/gpu/vendor/nvptx/declarations.h copy to libc/src/math/gpu/vendor/sincosf.cpp --- a/libc/src/math/gpu/vendor/nvptx/declarations.h +++ b/libc/src/math/gpu/vendor/sincosf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX 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_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/sincosf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(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_NVPTX_DECLARATIONS_H