56 lines · c
1//===----------------------------------------------------------------------===//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 9#ifndef _LIBCPP___ATOMIC_FLOATING_POINT_HELPER_H10#define _LIBCPP___ATOMIC_FLOATING_POINT_HELPER_H11 12#include <__config>13#include <__type_traits/is_floating_point.h>14#include <__type_traits/is_same.h>15 16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17# pragma GCC system_header18#endif19 20_LIBCPP_BEGIN_NAMESPACE_STD21 22#if _LIBCPP_STD_VER >= 2023 24template <class _Tp>25_LIBCPP_HIDE_FROM_ABI constexpr bool __is_fp80_long_double() {26 // Only x87-fp80 long double has 64-bit mantissa27 return __LDBL_MANT_DIG__ == 64 && std::is_same_v<_Tp, long double>;28}29 30template <class _Tp>31_LIBCPP_HIDE_FROM_ABI constexpr bool __has_rmw_builtin() {32 static_assert(std::is_floating_point_v<_Tp>);33# ifndef _LIBCPP_COMPILER_CLANG_BASED34 return false;35# else36 // The builtin __cxx_atomic_fetch_add errors during compilation for37 // long double on platforms with fp80 format.38 // For more details, see39 // lib/Sema/SemaChecking.cpp function IsAllowedValueType40 // LLVM Parser does not allow atomicrmw with x86_fp80 type.41 // if (ValType->isSpecificBuiltinType(BuiltinType::LongDouble) &&42 // &Context.getTargetInfo().getLongDoubleFormat() ==43 // &llvm::APFloat::x87DoubleExtended())44 // For more info45 // https://llvm.org/PR6860246 // https://reviews.llvm.org/D5396547 return !std::__is_fp80_long_double<_Tp>();48# endif49}50 51#endif52 53_LIBCPP_END_NAMESPACE_STD54 55#endif // _LIBCPP___ATOMIC_FLOATING_POINT_HELPER_H56