[libcxx-commits] [libcxx] [libc++][In progress] Floating Point Atomic (PR #67799)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Oct 2 08:59:19 PDT 2023
================
@@ -136,6 +140,114 @@ struct atomic<_Tp*>
atomic& operator=(const atomic&) volatile = delete;
};
+#if _LIBCPP_STD_VER >= 20
+template <class _Tp> requires is_floating_point_v<_Tp>
+struct atomic<_Tp>
+ : public __atomic_base<_Tp>
+{
+ private:
+ // The builtin __cxx_atomic_fetch_add does not work for
+ // long double on some platforms with fp80 type
+ // There is no way on the libc++ side to test whether it is
+ // ok to use the builtin for a certain type.
+ // Therefore, we do not use the builtin here
+ // For more details, see
+ // lib/Sema/SemaChecking.cpp function IsAllowedValueType
+ // LLVM Parser does not allow atomicrmw with x86_fp80 type.
+ // if (ValType->isSpecificBuiltinType(BuiltinType::LongDouble) &&
+ // &Context.getTargetInfo().getLongDoubleFormat() ==
+ // &llvm::APFloat::x87DoubleExtended())
+ // For more info
+ // https://reviews.llvm.org/D53965
----------------
ldionne wrote:
We should file an issue against LLVM to request that the builtin works for `long double` regardless of the underlying representation, and link it here.
https://github.com/llvm/llvm-project/pull/67799
More information about the libcxx-commits
mailing list