16 changes: 16 additions & 0 deletions libc/src/math/gpu/floorf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//===-- Implementation of the floorf 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/floorf.h"
#include "src/__support/common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, floorf, (float x)) { return __builtin_floorf(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/fma.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the fma 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/fma.h"
#include "src/__support/common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(double, fma, (double x, double y, double z)) {
return __builtin_fma(x, y, z);
}

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/fmaf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the fmaf 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/fmaf.h"
#include "src/__support/common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, fmaf, (float x, float y, float z)) {
return __builtin_fmaf(x, y, z);
}

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/fmax.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the fmax 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/fmax.h"
#include "src/__support/common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(double, fmax, (double x, double y)) {
return __builtin_fmax(x, y);
}

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/fmaxf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the fmaxf 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/fmaxf.h"
#include "src/__support/common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, fmaxf, (float x, float y)) {
return __builtin_fmaxf(x, y);
}

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/fmin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the fmin 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/fmin.h"
#include "src/__support/common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(double, fmin, (double x, double y)) {
return __builtin_fmin(x, y);
}

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/fminf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the fminf 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/fminf.h"
#include "src/__support/common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, fminf, (float x, float y)) {
return __builtin_fminf(x, y);
}

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/fmod.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the fmod 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/fmod.h"
#include "src/__support/common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(double, fmod, (double x, double y)) {
return __builtin_fmod(x, y);
}

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/fmodf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the fmodf 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/fmodf.h"
#include "src/__support/common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, fmodf, (float x, float y)) {
return __builtin_fmodf(x, y);
}

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/frexp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the frexp 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/frexp.h"
#include "src/__support/common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(double, frexp, (double x, int *p)) {
return __builtin_frexp(x, p);
}

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/frexpf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the frexpf 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/frexpf.h"
#include "src/__support/common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, frexpf, (float x, int *p)) {
return __builtin_frexpf(x, p);
}

} // namespace __llvm_libc
298 changes: 298 additions & 0 deletions libc/src/math/gpu/vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,304 @@ endif()
# will link in identity metadata from both libraries. This silences the warning.
list(APPEND bitcode_link_flags "-Wno-linker-warnings")

add_entrypoint_object(
acosf
SRCS
acosf.cpp
HDRS
../../acosf.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
acoshf
SRCS
acoshf.cpp
HDRS
../../acoshf.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
asinf
SRCS
asinf.cpp
HDRS
../../asinf.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
asinhf
SRCS
asinhf.cpp
HDRS
../../asinhf.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
atanf
SRCS
atanf.cpp
HDRS
../../atanf.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
atanhf
SRCS
atanhf.cpp
HDRS
../../atanhf.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
cos
SRCS
cos.cpp
HDRS
../../cos.h
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
cosf
SRCS
cosf.cpp
HDRS
../../cosf.h
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
cosh
SRCS
cosh.cpp
HDRS
../../cosh.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
coshf
SRCS
coshf.cpp
HDRS
../../coshf.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
exp10f
SRCS
exp10f.cpp
HDRS
../../exp10f.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
exp2f
SRCS
exp2f.cpp
HDRS
../../exp2f.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
expf
SRCS
expf.cpp
HDRS
../../expf.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
expm1f
SRCS
expm1f.cpp
HDRS
../../expm1f.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
fdim
SRCS
fdim.cpp
HDRS
../../fdim.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
fdimf
SRCS
fdimf.cpp
HDRS
../../fdimf.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
hypot
SRCS
hypot.cpp
HDRS
../../hypot.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
hypotf
SRCS
hypotf.cpp
HDRS
../../hypotf.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
ilogb
SRCS
ilogb.cpp
HDRS
../../ilogb.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
ilogbf
SRCS
ilogbf.cpp
HDRS
../../ilogbf.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)

add_entrypoint_object(
ldexp
SRCS
ldexp.cpp
HDRS
../../ldexp.h
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
ldexpf
SRCS
ldexpf.cpp
HDRS
../../ldexpf.h
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
llrint
SRCS
llrint.cpp
HDRS
../../llrint.h
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
llrintf
SRCS
llrintf.cpp
HDRS
../../llrintf.h
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
llround
SRCS
llround.cpp
HDRS
../../llround.h
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
llroundf
SRCS
llroundf.cpp
HDRS
../../llroundf.h
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
pow
SRCS
pow.cpp
HDRS
../../pow.h
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
powf
SRCS
powf.cpp
HDRS
../../powf.h
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
sin
SRCS
Expand Down
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/acosf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the acosf 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/acosf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, acosf, (float x)) { return internal::acosf(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/acoshf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the acoshf 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/acoshf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, acoshf, (float x)) { return internal::acoshf(x); }

} // namespace __llvm_libc
29 changes: 28 additions & 1 deletion libc/src/math/gpu/vendor/amdgpu/amdgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,34 @@

namespace __llvm_libc {
namespace internal {

LIBC_INLINE float acosf(float x) { return __ocml_acos_f32(x); }
LIBC_INLINE float acoshf(float x) { return __ocml_acosh_f32(x); }
LIBC_INLINE float asinf(float x) { return __ocml_asin_f32(x); }
LIBC_INLINE float asinhf(float x) { return __ocml_asinh_f32(x); }
LIBC_INLINE float atanf(float x) { return __ocml_atan_f32(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 float expf(float x) { return __builtin_expf(x); }
LIBC_INLINE float exp2f(float x) { return __builtin_exp2f(x); }
LIBC_INLINE float exp10f(float x) { return __ocml_exp10_f32(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); }
LIBC_INLINE double hypot(double x, double y) { return __ocml_hypot_f64(x, y); }
LIBC_INLINE float hypotf(float x, float y) { return __ocml_hypot_f32(x, y); }
LIBC_INLINE int ilogb(double x) { return __ocml_ilogb_f64(x); }
LIBC_INLINE int ilogbf(float x) { return __ocml_ilogb_f32(x); }
LIBC_INLINE double ldexp(double x, int i) { return __builtin_ldexp(x, i); }
LIBC_INLINE float ldexpf(float x, int i) { return __builtin_ldexpf(x, i); }
LIBC_INLINE long long llrint(double x) { return __builtin_rint(x); }
LIBC_INLINE long long llrintf(float x) { return __builtin_rintf(x); }
LIBC_INLINE long long llround(double x) { return __builtin_round(x); }
LIBC_INLINE long long llroundf(float x) { return __builtin_roundf(x); }
LIBC_INLINE double pow(double x, double y) { return __ocml_pow_f64(x, y); }
LIBC_INLINE float powf(float x, float y) { return __ocml_pow_f32(x, y); }
LIBC_INLINE double sin(double x) { return __ocml_sin_f64(x); }

} // namespace internal
Expand Down
28 changes: 28 additions & 0 deletions libc/src/math/gpu/vendor/amdgpu/declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,34 @@
namespace __llvm_libc {

extern "C" {
float __ocml_acos_f32(float);
float __ocml_acosh_f32(float);
float __ocml_asin_f32(float);
float __ocml_asinh_f32(float);
float __ocml_atan_f32(float);
float __ocml_atanh_f32(float);
float __ocml_cos_f32(float);
double __ocml_cos_f64(double);
float __ocml_cosh_f32(float);
double __ocml_cosh_f64(double);
float __ocml_exp_f32(float);
float __ocml_exp2_f32(float);
float __ocml_exp10_f32(float);
float __ocml_expm1_f32(float);
float __ocml_fdim_f32(float, float);
double __ocml_fdim_f64(double, double);
double __ocml_hypot_f64(double, double);
float __ocml_hypot_f32(float, float);
int __ocml_ilogb_f64(double);
int __ocml_ilogb_f32(float);
float __ocml_ldexp_f32(float, int);
double __ocml_ldexp_f64(double, int);
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);
double __ocml_sin_f64(double);
}

Expand Down
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/asinf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the asinf 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/asinf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, asinf, (float x)) { return internal::asinf(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/asinhf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the asinhf 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/asinhf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, asinhf, (float x)) { return internal::asinhf(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/atanf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the atanf 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/atanf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, atanf, (float x)) { return internal::atanf(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/atanhf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the atanhf 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/atanhf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, atanhf, (float x)) { return internal::atanhf(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/cos.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the cos 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/cos.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(double, cos, (double x)) { return internal::cos(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/cosf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the cosf 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/cosf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, cosf, (float x)) { return internal::cosf(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/cosh.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the cosh 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/cosh.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(double, cosh, (double x)) { return internal::cosh(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/coshf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the coshf 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/coshf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, coshf, (float x)) { return internal::coshf(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/exp10f.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the exp10f 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/exp10f.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, exp10f, (float x)) { return internal::exp10f(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/exp2f.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the exp2f 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/exp2f.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, exp2f, (float x)) { return internal::exp2f(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/expf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the expf 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/expf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, expf, (float x)) { return internal::expf(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/expm1f.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the expm1f 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/expm1f.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, expm1f, (float x)) { return internal::expm1f(x); }

} // namespace __llvm_libc
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/fdim.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of the fdim 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/fdim.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(double, fdim, (double x, double y)) {
return internal::fdim(x, y);
}

} // namespace __llvm_libc
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/fdimf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of the fdimf 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/fdimf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, fdimf, (float x, float y)) {
return internal::fdimf(x, y);
}

} // namespace __llvm_libc
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/hypot.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of the hypot 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/hypot.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(double, hypot, (double x, double y)) {
return internal::hypot(x, y);
}

} // namespace __llvm_libc
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/hypotf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of the hypotf 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/hypotf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, hypotf, (float x, float y)) {
return internal::hypotf(x, y);
}

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/ilogb.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the ilogb 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/ilogb.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(int, ilogb, (double x)) { return internal::ilogb(x); }

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/ilogbf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation of the ilogbf 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/ilogbf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(int, ilogbf, (float x)) { return internal::ilogbf(x); }

} // namespace __llvm_libc
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/ldexp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of the ldexp 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/ldexp.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(double, ldexp, (double x, int y)) {
return internal::ldexp(x, y);
}

} // namespace __llvm_libc
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/ldexpf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of the ldexpf 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/ldexpf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, ldexpf, (float x, int y)) {
return internal::ldexpf(x, y);
}

} // namespace __llvm_libc
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/llrint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of the llrint 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/llrint.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(long long, llrint, (double x)) {
return internal::llrint(x);
}

} // namespace __llvm_libc
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/llrintf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of the llrintf 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/llrintf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(long long, llrintf, (float x)) {
return internal::llrintf(x);
}

} // namespace __llvm_libc
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/llround.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of the llround 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/llround.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(long long, llround, (double x)) {
return internal::llround(x);
}

} // namespace __llvm_libc
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/llroundf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of the llroundf 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/llroundf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(long long, llroundf, (float x)) {
return internal::llroundf(x);
}

} // namespace __llvm_libc
28 changes: 28 additions & 0 deletions libc/src/math/gpu/vendor/nvptx/declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,34 @@
namespace __llvm_libc {

extern "C" {
float __nv_acosf(float);
float __nv_acoshf(float);
float __nv_asinf(float);
float __nv_asinhf(float);
float __nv_atanf(float);
float __nv_atanhf(float);
double __nv_cos(double);
float __nv_cosf(float);
double __nv_cosh(double);
float __nv_coshf(float);
float __nv_expf(float);
float __nv_exp2f(float);
float __nv_exp10f(float);
float __nv_expm1f(float);
double __nv_fdim(double, double);
float __nv_fdimf(float, float);
double __nv_hypot(double, double);
float __nv_hypotf(float, float);
int __nv_ilogb(double);
int __nv_ilogbf(float);
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);
double __nv_pow(double, double);
float __nv_powf(float, float);
double __nv_sin(double);
}

Expand Down
29 changes: 28 additions & 1 deletion libc/src/math/gpu/vendor/nvptx/nvptx.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,34 @@

namespace __llvm_libc {
namespace internal {

LIBC_INLINE float acosf(float x) { return __nv_acosf(x); }
LIBC_INLINE float acoshf(float x) { return __nv_acoshf(x); }
LIBC_INLINE float asinf(float x) { return __nv_asinf(x); }
LIBC_INLINE float asinhf(float x) { return __nv_asinhf(x); }
LIBC_INLINE float atanf(float x) { return __nv_atanf(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 float expf(float x) { return __nv_expf(x); }
LIBC_INLINE float exp2f(float x) { return __nv_exp2f(x); }
LIBC_INLINE float exp10f(float x) { return __nv_exp10f(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); }
LIBC_INLINE double hypot(double x, double y) { return __nv_hypot(x, y); }
LIBC_INLINE float hypotf(float x, float y) { return __nv_hypotf(x, y); }
LIBC_INLINE int ilogb(double x) { return __nv_ilogb(x); }
LIBC_INLINE int ilogbf(float x) { return __nv_ilogbf(x); }
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 pow(double x, double y) { return __nv_pow(x, y); }
LIBC_INLINE float powf(float x, float y) { return __nv_powf(x, y); }
LIBC_INLINE double sin(double x) { return __nv_sin(x); }

} // namespace internal
Expand Down
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/pow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of the pow 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/pow.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(double, pow, (double x, double y)) {
return internal::pow(x, y);
}

} // namespace __llvm_libc
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/powf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of the powf 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/powf.h"
#include "src/__support/common.h"

#include "common.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(float, powf, (float x, float y)) {
return internal::powf(x, y);
}

} // namespace __llvm_libc
18 changes: 18 additions & 0 deletions libc/src/math/pow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation header for pow ---------------------------*- 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_POW_H
#define LLVM_LIBC_SRC_MATH_POW_H

namespace __llvm_libc {

double pow(double x, double y);

} // namespace __llvm_libc

#endif // LLVM_LIBC_SRC_MATH_POW_H
18 changes: 18 additions & 0 deletions libc/src/math/powf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Implementation header for powf --------------------------*- 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_POWF_H
#define LLVM_LIBC_SRC_MATH_POWF_H

namespace __llvm_libc {

float powf(float x, float y);

} // namespace __llvm_libc

#endif // LLVM_LIBC_SRC_MATH_POWF_H