[clang] [CIR] Implement 'simple' atomic inc/dec. (PR #222730)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 11 11:48:32 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();
----------------
andykaylor wrote:
Classic codegen seems to be using `EmitToMemory` to get this type. I know we defer any conversion to memory for boolean types, but is there some other mechanism we should be using (or introducing) to get this from a central source of truth? Will we need to get the memory type for atomic bools in other places?
https://github.com/llvm/llvm-project/pull/222730
More information about the cfe-commits
mailing list