[clang] [CIR] Add support for storing into _Atomic variables (PR #165872)

Sirui Mu via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 4 08:13:01 PST 2025


================
@@ -215,6 +229,34 @@ bool AtomicInfo::emitMemSetZeroIfNecessary() const {
   return false;
 }
 
+/// Return true if \param valueTy is a type that should be casted to integer
+/// around the atomic memory operation. If \param cmpxchg is true, then the
+/// cast of a floating point type is made as that instruction can not have
+/// floating point operands.  TODO: Allow compare-and-exchange and FP - see
+/// comment in CIRGenAtomicExpandPass.cpp.
+static bool shouldCastToInt(mlir::Type valueTy, bool cmpxchg) {
+  if (cir::isAnyFloatingPointType(valueTy))
+    return isa<cir::FP80Type>(valueTy) || cmpxchg;
----------------
Lancern wrote:

Added a test case that covers this branch, but it seems like we cannot make a return value of `true` for now. I think I'll leave it as-is.

https://github.com/llvm/llvm-project/pull/165872


More information about the cfe-commits mailing list