brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · e675d1e Raw
70 lines · c
1//===-- AMDGPU specific platform definitions for math support -------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8#ifndef LLVM_LIBC_SRC_MATH_AMDGPU_PLATFORM_H9#define LLVM_LIBC_SRC_MATH_AMDGPU_PLATFORM_H10 11#include "hdr/stdint_proxy.h"12#include "src/__support/macros/attributes.h"13#include "src/__support/macros/config.h"14#include "src/__support/macros/properties/types.h"15 16namespace LIBC_NAMESPACE_DECL {17 18#ifdef LIBC_TARGET_ARCH_IS_AMDGPU19// The ROCm device library uses control globals to alter codegen for the20// different targets. To avoid needing to link them in manually we simply21// define them here.22extern "C" {23extern const LIBC_INLINE_VAR uint8_t __oclc_unsafe_math_opt = 0;24extern const LIBC_INLINE_VAR uint8_t __oclc_daz_opt = 0;25extern const LIBC_INLINE_VAR uint8_t __oclc_correctly_rounded_sqrt32 = 1;26extern const LIBC_INLINE_VAR uint8_t __oclc_finite_only_opt = 0;27extern const LIBC_INLINE_VAR uint32_t __oclc_ISA_version = 9000;28}29 30// These aliases cause clang to emit the control constants with ODR linkage.31// This allows us to link against the symbols without preventing them from being32// optimized out or causing symbol collisions.33[[gnu::alias("__oclc_unsafe_math_opt")]] const uint8_t __oclc_unsafe_math_opt__;34[[gnu::alias("__oclc_daz_opt")]] const uint8_t __oclc_daz_opt__;35[[gnu::alias("__oclc_correctly_rounded_sqrt32")]] const uint8_t36    __oclc_correctly_rounded_sqrt32__;37[[gnu::alias("__oclc_finite_only_opt")]] const uint8_t __oclc_finite_only_opt__;38[[gnu::alias("__oclc_ISA_version")]] const uint32_t __oclc_ISA_version__;39#endif40} // namespace LIBC_NAMESPACE_DECL41 42// Forward declarations for the vendor math libraries.43extern "C" {44#ifdef AMDGPU_MATH_FOUND45double __ocml_atan2_f64(double, double);46float __ocml_atan2_f32(float, float);47double __ocml_exp_f64(double);48float __ocml_exp_f32(float);49float16 __ocml_exp_f16(float16);50double __ocml_log_f64(double);51float __ocml_log_f32(float);52float16 __ocml_log_f16(float16);53double __ocml_sin_f64(double);54float __ocml_sin_f32(float);55#endif56 57#ifdef NVPTX_MATH_FOUND58double __nv_atan2(double, double);59float __nv_atan2f(float, float);60double __nv_exp(double);61float __nv_expf(float);62double __nv_log(double);63float __nv_logf(float);64double __nv_sin(double);65float __nv_sinf(float);66#endif67}68 69#endif // LLVM_LIBC_SRC_MATH_AMDGPU_PLATFORM_H70