[clang] [CIR] Implement 'simple' atomic inc/dec. (PR #222730)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 11 11:58:57 PDT 2026


================
@@ -628,10 +628,88 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
     mlir::Value value;
     mlir::Value input;
 
-    if (type->getAs<AtomicType>()) {
+    if (const AtomicType *atomicTy = type->getAs<AtomicType>()) {
+      QualType valType = atomicTy->getValueType();
+      mlir::Location loc = cgf.getLoc(e->getSourceRange());
+      bool isInc = e->isIncrementOp();
+      bool isPre = e->isPrefix();
+
+      // Bools are always set-to-true, as decrement isn't legal on bools.
+      if (valType->isBooleanType()) {
+        assert(isInc);
+        // Atomic operations require an integer type; reinterpret the bool
+        // pointer as a pointer to its underlying storage integer type.
+        cir::IntType intTy = builder.getUInt8Ty();
----------------
erichkeane wrote:

On one hand, we always know what the answer is going to be... on the other, it is easy enough to introduce a function here.  I probably wont go through and replace all the uses, but perhaps we should some day.

So incoming :) 

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


More information about the cfe-commits mailing list