| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| //===-- printf_fixed_conv_fuzz.cpp ----------------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| /// | ||
| /// Fuzzing test for llvm-libc printf %f/e/g/a implementations. | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
| #include "src/stdio/snprintf.h" | ||
|
|
||
| #include "include/llvm-libc-macros/stdfix-macros.h" | ||
| #include "src/__support/fixed_point/fx_bits.h" | ||
| #include "src/__support/fixed_point/fx_rep.h" | ||
|
|
||
| #include <stddef.h> | ||
| #include <stdint.h> | ||
|
|
||
| #include "utils/MPFRWrapper/mpfr_inc.h" | ||
|
|
||
| constexpr int MAX_SIZE = 10000; | ||
|
|
||
| inline bool simple_streq(char *first, char *second, int length) { | ||
| for (int i = 0; i < length; ++i) | ||
| if (first[i] != second[i]) | ||
| return false; | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| inline int clamp(int num, int max) { | ||
| if (num > max) | ||
| return max; | ||
| if (num < -max) | ||
| return -max; | ||
| return num; | ||
| } | ||
|
|
||
| enum class TestResult { | ||
| Success, | ||
| BufferSizeFailed, | ||
| LengthsDiffer, | ||
| StringsNotEqual, | ||
| }; | ||
|
|
||
| template <typename F> | ||
| inline TestResult test_vals(const char *fmt, uint64_t num, int prec, | ||
| int width) { | ||
| typename LIBC_NAMESPACE::fixed_point::FXRep<F>::StorageType raw_num = num; | ||
|
|
||
| auto raw_num_bits = LIBC_NAMESPACE::fixed_point::FXBits<F>(raw_num); | ||
|
|
||
| // This needs to be a float with enough bits of precision to hold the fixed | ||
| // point number. | ||
| static_assert(sizeof(long double) > sizeof(long accum)); | ||
|
|
||
| // build a long double that is equivalent to the fixed point number. | ||
| long double ld_num = | ||
| static_cast<long double>(raw_num_bits.get_integral()) + | ||
| (static_cast<long double>(raw_num_bits.get_fraction()) / | ||
| static_cast<long double>(1ll << raw_num_bits.get_exponent())); | ||
|
|
||
| if (raw_num_bits.get_sign()) | ||
| ld_num = -ld_num; | ||
|
|
||
| // Call snprintf on a nullptr to get the buffer size. | ||
| int buffer_size = LIBC_NAMESPACE::snprintf(nullptr, 0, fmt, width, prec, num); | ||
|
|
||
| if (buffer_size < 0) | ||
| return TestResult::BufferSizeFailed; | ||
|
|
||
| char *test_buff = new char[buffer_size + 1]; | ||
| char *reference_buff = new char[buffer_size + 1]; | ||
|
|
||
| int test_result = 0; | ||
| int reference_result = 0; | ||
|
|
||
| test_result = LIBC_NAMESPACE::snprintf(test_buff, buffer_size + 1, fmt, width, | ||
| prec, num); | ||
|
|
||
| // The fixed point format is defined to be %f equivalent. | ||
| reference_result = mpfr_snprintf(reference_buff, buffer_size + 1, "%*.*Lf", | ||
| width, prec, ld_num); | ||
|
|
||
| // All of these calls should return that they wrote the same amount. | ||
| if (test_result != reference_result || test_result != buffer_size) | ||
| return TestResult::LengthsDiffer; | ||
|
|
||
| if (!simple_streq(test_buff, reference_buff, buffer_size)) | ||
| return TestResult::StringsNotEqual; | ||
|
|
||
| delete[] test_buff; | ||
| delete[] reference_buff; | ||
| return TestResult::Success; | ||
| } | ||
|
|
||
| extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | ||
| // const uint8_t raw_data[] = {0x8d,0x43,0x40,0x0,0x0,0x0,}; | ||
| // data = raw_data; | ||
| // size = sizeof(raw_data); | ||
| int prec = 0; | ||
| int width = 0; | ||
|
|
||
| LIBC_NAMESPACE::fixed_point::FXRep<long accum>::StorageType raw_num = 0; | ||
|
|
||
| // Copy as many bytes of data as will fit into num, prec, and with. Any extras | ||
| // are ignored. | ||
| for (size_t cur = 0; cur < size; ++cur) { | ||
| if (cur < sizeof(raw_num)) { | ||
| raw_num = (raw_num << 8) + data[cur]; | ||
| } else if (cur < sizeof(raw_num) + sizeof(prec)) { | ||
| prec = (prec << 8) + data[cur]; | ||
| } else if (cur < sizeof(raw_num) + sizeof(prec) + sizeof(width)) { | ||
| width = (width << 8) + data[cur]; | ||
| } | ||
| } | ||
|
|
||
| width = clamp(width, MAX_SIZE); | ||
| prec = clamp(prec, MAX_SIZE); | ||
|
|
||
| TestResult result; | ||
| result = test_vals<long accum>("%*.*lk", raw_num, prec, width); | ||
| if (result != TestResult::Success) | ||
| __builtin_trap(); | ||
|
|
||
| result = test_vals<unsigned long accum>("%*.*lK", raw_num, prec, width); | ||
| if (result != TestResult::Success) | ||
| __builtin_trap(); | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,6 +83,8 @@ add_macro_header( | |
| math_macros | ||
| HDR | ||
| math-macros.h | ||
| DEPENDS | ||
| .limits_macros | ||
| ) | ||
|
|
||
| add_macro_header( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| //===-- Calculate square root of fixed point numbers. -----*- 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___SUPPORT_FIXEDPOINT_SQRT_H | ||
| #define LLVM_LIBC_SRC___SUPPORT_FIXEDPOINT_SQRT_H | ||
|
|
||
| #include "include/llvm-libc-macros/stdfix-macros.h" | ||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/CPP/type_traits.h" | ||
| #include "src/__support/macros/attributes.h" // LIBC_INLINE | ||
| #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY | ||
|
|
||
| #include "fx_rep.h" | ||
|
|
||
| #ifdef LIBC_COMPILER_HAS_FIXED_POINT | ||
|
|
||
| namespace LIBC_NAMESPACE::fixed_point { | ||
|
|
||
| namespace internal { | ||
|
|
||
| template <typename T> struct SqrtConfig; | ||
|
|
||
| template <> struct SqrtConfig<unsigned short fract> { | ||
| using Type = unsigned short fract; | ||
| static constexpr int EXTRA_STEPS = 0; | ||
| }; | ||
|
|
||
| template <> struct SqrtConfig<unsigned fract> { | ||
| using Type = unsigned fract; | ||
| static constexpr int EXTRA_STEPS = 1; | ||
| }; | ||
|
|
||
| template <> struct SqrtConfig<unsigned long fract> { | ||
| using Type = unsigned long fract; | ||
| static constexpr int EXTRA_STEPS = 2; | ||
| }; | ||
|
|
||
| template <> | ||
| struct SqrtConfig<unsigned short accum> : SqrtConfig<unsigned fract> {}; | ||
|
|
||
| template <> | ||
| struct SqrtConfig<unsigned accum> : SqrtConfig<unsigned long fract> {}; | ||
|
|
||
| // TODO: unsigned long accum type is 64-bit, and will need 64-bit fract type. | ||
| // Probably we will use DyadicFloat<64> for intermediate computations instead. | ||
|
|
||
| // Linear approximation for the initial values, with errors bounded by: | ||
| // max(1.5 * 2^-11, eps) | ||
| // Generated with Sollya: | ||
| // > for i from 4 to 15 do { | ||
| // P = fpminimax(sqrt(x), 1, [|8, 8|], [i * 2^-4, (i + 1)*2^-4], | ||
| // fixed, absolute); | ||
| // print("{", coeff(P, 1), "uhr,", coeff(P, 0), "uhr},"); | ||
| // }; | ||
| static constexpr unsigned short fract SQRT_FIRST_APPROX[12][2] = { | ||
| {0x1.e8p-1uhr, 0x1.0cp-2uhr}, {0x1.bap-1uhr, 0x1.28p-2uhr}, | ||
| {0x1.94p-1uhr, 0x1.44p-2uhr}, {0x1.74p-1uhr, 0x1.6p-2uhr}, | ||
| {0x1.6p-1uhr, 0x1.74p-2uhr}, {0x1.4ep-1uhr, 0x1.88p-2uhr}, | ||
| {0x1.3ep-1uhr, 0x1.9cp-2uhr}, {0x1.32p-1uhr, 0x1.acp-2uhr}, | ||
| {0x1.22p-1uhr, 0x1.c4p-2uhr}, {0x1.18p-1uhr, 0x1.d4p-2uhr}, | ||
| {0x1.08p-1uhr, 0x1.fp-2uhr}, {0x1.04p-1uhr, 0x1.f8p-2uhr}, | ||
| }; | ||
|
|
||
| } // namespace internal | ||
|
|
||
| template <typename T> | ||
| LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_fixed_point_v<T>, T> sqrt(T x) { | ||
| using BitType = typename FXRep<T>::StorageType; | ||
| BitType x_bit = cpp::bit_cast<BitType>(x); | ||
|
|
||
| if (LIBC_UNLIKELY(x_bit == 0)) | ||
| return FXRep<T>::ZERO(); | ||
|
|
||
| int leading_zeros = cpp::countl_zero(x_bit); | ||
| constexpr int STORAGE_LENGTH = sizeof(BitType) * CHAR_BIT; | ||
| constexpr int EXP_ADJUSTMENT = STORAGE_LENGTH - FXRep<T>::FRACTION_LEN - 1; | ||
| // x_exp is the real exponent of the leading bit of x. | ||
| int x_exp = EXP_ADJUSTMENT - leading_zeros; | ||
| int shift = EXP_ADJUSTMENT - 1 - (x_exp & (~1)); | ||
| // Normalize. | ||
| x_bit <<= shift; | ||
| using FracType = typename internal::SqrtConfig<T>::Type; | ||
| FracType x_frac = cpp::bit_cast<FracType>(x_bit); | ||
|
|
||
| // Use use Newton method to approximate sqrt(a): | ||
| // x_{n + 1} = 1/2 (x_n + a / x_n) | ||
| // For the initial values, we choose x_0 | ||
|
|
||
| // Use the leading 4 bits to do look up for sqrt(x). | ||
| // After normalization, 0.25 <= x_frac < 1, so the leading 4 bits of x_frac | ||
| // are between 0b0100 and 0b1111. Hence the lookup table only needs 12 | ||
| // entries, and we can get the index by subtracting the leading 4 bits of | ||
| // x_frac by 4 = 0b0100. | ||
| int index = (x_bit >> (STORAGE_LENGTH - 4)) - 4; | ||
| FracType a = static_cast<FracType>(internal::SQRT_FIRST_APPROX[index][0]); | ||
| FracType b = static_cast<FracType>(internal::SQRT_FIRST_APPROX[index][1]); | ||
|
|
||
| // Initial approximation step. | ||
| // Estimated error bounds: | r - sqrt(x_frac) | < max(1.5 * 2^-11, eps). | ||
| FracType r = a * x_frac + b; | ||
|
|
||
| // Further Newton-method iterations for square-root: | ||
| // x_{n + 1} = 0.5 * (x_n + a / x_n) | ||
| // We distribute and do the multiplication by 0.5 first to avoid overflow. | ||
| // TODO: Investigate the performance and accuracy of using division-free | ||
| // iterations from: | ||
| // Blanchard, J. D. and Chamberland, M., "Newton's Method Without Division", | ||
| // The American Mathematical Monthly (2023). | ||
| // https://chamberland.math.grinnell.edu/papers/newton.pdf | ||
| for (int i = 0; i < internal::SqrtConfig<T>::EXTRA_STEPS; ++i) | ||
| r = (r >> 1) + (x_frac >> 1) / r; | ||
|
|
||
| // Re-scaling | ||
| r >>= EXP_ADJUSTMENT - (x_exp >> 1); | ||
|
|
||
| // Return result. | ||
| return cpp::bit_cast<T>(r); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE::fixed_point | ||
|
|
||
| #endif // LIBC_COMPILER_HAS_FIXED_POINT | ||
|
|
||
| #endif // LLVM_LIBC_SRC___SUPPORT_FIXEDPOINT_SQRT_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU acos function ---------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/acos.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, acos, (double x)) { return __ocml_acos_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, acosf, (float x)) { return __ocml_acos_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU acosh function --------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/acosh.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, acosh, (double x)) { return __ocml_acosh_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, acoshf, (float x)) { return __ocml_acosh_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU asin function ---------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/asin.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, asin, (double x)) { return __ocml_asin_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, asinf, (float x)) { return __ocml_asin_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU asinh function --------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/asinh.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, asinh, (double x)) { return __ocml_asinh_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, asinhf, (float x)) { return __ocml_asinh_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU atan function ---------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/atan.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, atan, (double x)) { return __ocml_atan_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation of the GPU atan2 function --------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/atan2.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, atan2, (double x, double y)) { | ||
| return __ocml_atan2_f64(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation of the GPU atan2f function -------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/atan2f.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, atan2f, (float x, float y)) { | ||
| return __ocml_atan2_f32(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, atanf, (float x)) { return __ocml_atan_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU atanh function --------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/atanh.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, atanh, (double x)) { return __ocml_atanh_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, atanhf, (float x)) { return __ocml_atanh_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, cos, (double x)) { return __ocml_cos_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, cosf, (float x)) { return __ocml_cos_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, cosh, (double x)) { return __ocml_cosh_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, coshf, (float x)) { return __ocml_cosh_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU erf function ----------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/erf.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, erf, (double x)) { return __ocml_erf_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU erff function ---------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/erff.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, erff, (float x)) { return __ocml_erf_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU exp10 function --------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/exp10.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, exp10, (double x)) { return __ocml_exp10_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, exp10f, (float x)) { return __ocml_exp10_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU exp2 function ---------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/exp2.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, exp2, (double x)) { return __ocml_exp2_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, exp2f, (float x)) { return __ocml_exp2_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU expm1 function --------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/expm1.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, expm1, (double x)) { return __ocml_expm1_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, expm1f, (float x)) { return __ocml_expm1_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, fdim, (double x, double y)) { | ||
| return __ocml_fdim_f64(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, fdimf, (float x, float y)) { | ||
| return __ocml_fdim_f32(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //===-- 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/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/macros/optimization.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, fmax, (double x, double y)) { | ||
| // FIXME: The builtin function does not correctly handle the +/-0.0 case. | ||
| if (LIBC_UNLIKELY(x == y)) | ||
| return cpp::bit_cast<double>(cpp::bit_cast<uint64_t>(x) & | ||
| cpp::bit_cast<uint64_t>(y)); | ||
| return __builtin_fmax(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //===-- 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/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/macros/optimization.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, fmaxf, (float x, float y)) { | ||
| // FIXME: The builtin function does not correctly handle the +/-0.0 case. | ||
| if (LIBC_UNLIKELY(x == y)) | ||
| return cpp::bit_cast<float>(cpp::bit_cast<uint32_t>(x) & | ||
| cpp::bit_cast<uint32_t>(y)); | ||
| return __builtin_fmaxf(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //===-- 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/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/macros/optimization.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, fmin, (double x, double y)) { | ||
| // FIXME: The builtin function does not correctly handle the +/-0.0 case. | ||
| if (LIBC_UNLIKELY(x == y)) | ||
| return cpp::bit_cast<double>(cpp::bit_cast<uint64_t>(x) | | ||
| cpp::bit_cast<uint64_t>(y)); | ||
| return __builtin_fmin(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //===-- 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/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/macros/optimization.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, fminf, (float x, float y)) { | ||
| // FIXME: The builtin function does not correctly handle the +/-0.0 case. | ||
| if (LIBC_UNLIKELY(x == y)) | ||
| return cpp::bit_cast<float>(cpp::bit_cast<uint32_t>(x) | | ||
| cpp::bit_cast<uint32_t>(y)); | ||
| return __builtin_fminf(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- 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" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, frexp, (double x, int *p)) { | ||
| return __builtin_frexp(x, p); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- 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" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, frexpf, (float x, int *p)) { | ||
| return __builtin_frexpf(x, p); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, hypot, (double x, double y)) { | ||
| return __ocml_hypot_f64(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, hypotf, (float x, float y)) { | ||
| return __ocml_hypot_f32(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(int, ilogb, (double x)) { return __ocml_ilogb_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(int, ilogbf, (float x)) { return __ocml_ilogb_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, ldexp, (double x, int y)) { | ||
| return __builtin_ldexp(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| 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 "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, ldexpf, (float x, int y)) { | ||
| return __builtin_ldexpf(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU log function ----------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/log.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, log, (double x)) { return __ocml_log_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU log10 function --------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/log10.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, log10, (double x)) { return __ocml_log10_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU log10f function -------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/log10f.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, log10f, (float x)) { return __ocml_log10_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU log1p function --------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/log1p.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, log1p, (double x)) { return __ocml_log1p_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU log1pf function -------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/log1pf.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, log1pf, (float x)) { return __ocml_log1p_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU log2 function ---------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/log2.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, log2, (double x)) { return __ocml_log2_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU log2f function --------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/log2f.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, log2f, (float x)) { return __ocml_log2_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU logb function ---------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/logb.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, logb, (double x)) { return __ocml_logb_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU logbf function --------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/logbf.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, logbf, (float x)) { return __ocml_logb_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU logf function ---------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/logf.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, logf, (float x)) { return __ocml_log_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation of the lrint function for GPU ----------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/lrint.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(long, lrint, (double x)) { | ||
| return static_cast<long>(__builtin_rint(x)); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation of the lrintf function for GPU ---------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/lrintf.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(long, lrintf, (float x)) { | ||
| return static_cast<long>(__builtin_rintf(x)); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- 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. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/nextafter.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, nextafter, (double x, double y)) { | ||
| return __ocml_nextafter_f64(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- 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. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/nextafterf.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, nextafterf, (float x, float y)) { | ||
| return __ocml_nextafter_f32(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| //===-- 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. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/remquo.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, remquo, (double x, double y, int *quo)) { | ||
| int tmp; | ||
| double r = __ocml_remquo_f64(x, y, (gpu::Private<int> *)&tmp); | ||
| *quo = tmp; | ||
| return r; | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| //===-- 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. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/remquof.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, remquof, (float x, float y, int *quo)) { | ||
| int tmp; | ||
| float r = __ocml_remquo_f32(x, y, (gpu::Private<int> *)&tmp); | ||
| *quo = tmp; | ||
| return r; | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- 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. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/scalbn.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, scalbn, (double x, int y)) { | ||
| return __builtin_amdgcn_ldexp(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- 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. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/scalbnf.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, scalbnf, (float x, int y)) { | ||
| return __builtin_amdgcn_ldexpf(x, y); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the sin 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/sin.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, sin, (double x)) { return __ocml_sin_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- 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. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/sincos.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(void, sincos, (double x, double *sinptr, double *cosptr)) { | ||
| *sinptr = __ocml_sincos_f64(x, cosptr); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- 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. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/sinf.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, sinf, (float x)) { return __ocml_sin_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the sinhf 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/sinhf.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, sinhf, (float x)) { return __ocml_sinh_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the tanf 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/tanf.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, tanf, (float x)) { return __ocml_tan_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the tanhf 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/tanhf.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, tanhf, (float x)) { return __ocml_tanh_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU tgamma function -------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/tgamma.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, tgamma, (double x)) { return __ocml_tgamma_f64(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation of the GPU tgammaf function ------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/tgammaf.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| #include "declarations.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, tgammaf, (float x)) { return __ocml_tgamma_f32(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| //===-- Implementation of ilogbf128 function ------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/ilogbf128.h" | ||
| #include "src/__support/FPUtil/ManipulationFunctions.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(int, ilogbf128, (float128 x)) { | ||
| return fputil::intlogb<int>(x); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| //===-- Implementation of llogb function ----------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/llogb.h" | ||
| #include "src/__support/FPUtil/ManipulationFunctions.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(long, llogb, (double x)) { return fputil::intlogb<long>(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| //===-- Implementation of llogbf function ---------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/llogbf.h" | ||
| #include "src/__support/FPUtil/ManipulationFunctions.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(long, llogbf, (float x)) { return fputil::intlogb<long>(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| //===-- Implementation of llogbf128 function ------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/llogbf128.h" | ||
| #include "src/__support/FPUtil/ManipulationFunctions.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(long, llogbf128, (float128 x)) { | ||
| return fputil::intlogb<long>(x); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| //===-- Implementation of llogbl function ---------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/llogbl.h" | ||
| #include "src/__support/FPUtil/ManipulationFunctions.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(long, llogbl, (long double x)) { | ||
| return fputil::intlogb<long>(x); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| //===-- Implementation of logbf128 function -------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/logbf128.h" | ||
| #include "src/__support/FPUtil/ManipulationFunctions.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float128, logbf128, (float128 x)) { return fputil::logb(x); } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |