1*71db0c75SAndroid Build Coastguard Worker //===-- AMDGPU specific platform definitions for math support -------------===// 2*71db0c75SAndroid Build Coastguard Worker // 3*71db0c75SAndroid Build Coastguard Worker // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*71db0c75SAndroid Build Coastguard Worker // See https://llvm.org/LICENSE.txt for license information. 5*71db0c75SAndroid Build Coastguard Worker // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*71db0c75SAndroid Build Coastguard Worker // 7*71db0c75SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 8*71db0c75SAndroid Build Coastguard Worker 9*71db0c75SAndroid Build Coastguard Worker #ifndef LLVM_LIBC_SRC_MATH_AMDGPU_PLATFORM_H 10*71db0c75SAndroid Build Coastguard Worker #define LLVM_LIBC_SRC_MATH_AMDGPU_PLATFORM_H 11*71db0c75SAndroid Build Coastguard Worker 12*71db0c75SAndroid Build Coastguard Worker #include "src/__support/macros/attributes.h" 13*71db0c75SAndroid Build Coastguard Worker #include "src/__support/macros/config.h" 14*71db0c75SAndroid Build Coastguard Worker 15*71db0c75SAndroid Build Coastguard Worker #include <stdint.h> 16*71db0c75SAndroid Build Coastguard Worker 17*71db0c75SAndroid Build Coastguard Worker namespace LIBC_NAMESPACE_DECL { 18*71db0c75SAndroid Build Coastguard Worker 19*71db0c75SAndroid Build Coastguard Worker // The ROCm device library uses control globals to alter codegen for the 20*71db0c75SAndroid Build Coastguard Worker // different targets. To avoid needing to link them in manually we simply 21*71db0c75SAndroid Build Coastguard Worker // define them here. 22*71db0c75SAndroid Build Coastguard Worker extern "C" { 23*71db0c75SAndroid Build Coastguard Worker 24*71db0c75SAndroid Build Coastguard Worker // Disable unsafe math optimizations in the implementation. 25*71db0c75SAndroid Build Coastguard Worker extern const LIBC_INLINE_VAR uint8_t __oclc_unsafe_math_opt = 0; 26*71db0c75SAndroid Build Coastguard Worker 27*71db0c75SAndroid Build Coastguard Worker // Disable denormalization at zero optimizations in the implementation. 28*71db0c75SAndroid Build Coastguard Worker extern const LIBC_INLINE_VAR uint8_t __oclc_daz_opt = 0; 29*71db0c75SAndroid Build Coastguard Worker 30*71db0c75SAndroid Build Coastguard Worker // Disable rounding optimizations for 32-bit square roots. 31*71db0c75SAndroid Build Coastguard Worker extern const LIBC_INLINE_VAR uint8_t __oclc_correctly_rounded_sqrt32 = 1; 32*71db0c75SAndroid Build Coastguard Worker 33*71db0c75SAndroid Build Coastguard Worker // Disable finite math optimizations. 34*71db0c75SAndroid Build Coastguard Worker extern const LIBC_INLINE_VAR uint8_t __oclc_finite_only_opt = 0; 35*71db0c75SAndroid Build Coastguard Worker 36*71db0c75SAndroid Build Coastguard Worker // Set the ISA value to a high enough value that the ROCm device library math 37*71db0c75SAndroid Build Coastguard Worker // functions will assume we have fast FMA operations among other features. This 38*71db0c75SAndroid Build Coastguard Worker // is determined to be safe on all targets by looking at the source code. 39*71db0c75SAndroid Build Coastguard Worker // https://github.com/ROCm/ROCm-Device-Libs/blob/amd-stg-open/ocml/src/opts.h 40*71db0c75SAndroid Build Coastguard Worker extern const LIBC_INLINE_VAR uint32_t __oclc_ISA_version = 9000; 41*71db0c75SAndroid Build Coastguard Worker } 42*71db0c75SAndroid Build Coastguard Worker 43*71db0c75SAndroid Build Coastguard Worker // These aliases cause clang to emit the control constants with ODR linkage. 44*71db0c75SAndroid Build Coastguard Worker // This allows us to link against the symbols without preventing them from being 45*71db0c75SAndroid Build Coastguard Worker // optimized out or causing symbol collisions. 46*71db0c75SAndroid Build Coastguard Worker [[gnu::alias("__oclc_unsafe_math_opt")]] const uint8_t __oclc_unsafe_math_opt__; 47*71db0c75SAndroid Build Coastguard Worker [[gnu::alias("__oclc_daz_opt")]] const uint8_t __oclc_daz_opt__; 48*71db0c75SAndroid Build Coastguard Worker [[gnu::alias("__oclc_correctly_rounded_sqrt32")]] const uint8_t 49*71db0c75SAndroid Build Coastguard Worker __oclc_correctly_rounded_sqrt32__; 50*71db0c75SAndroid Build Coastguard Worker [[gnu::alias("__oclc_finite_only_opt")]] const uint8_t __oclc_finite_only_opt__; 51*71db0c75SAndroid Build Coastguard Worker [[gnu::alias("__oclc_ISA_version")]] const uint32_t __oclc_ISA_version__; 52*71db0c75SAndroid Build Coastguard Worker 53*71db0c75SAndroid Build Coastguard Worker } // namespace LIBC_NAMESPACE_DECL 54*71db0c75SAndroid Build Coastguard Worker 55*71db0c75SAndroid Build Coastguard Worker #endif // LLVM_LIBC_SRC_MATH_AMDGPU_PLATFORM_H 56