================
@@ -754,8 +765,50 @@ static void emitAtomicOp(CIRGenFunction &cgf, AtomicExpr
*expr, Address dest,
return;
}
- assert(!cir::MissingFeatures::atomicSyncScopeID());
- cgf.cgm.errorNYI(expr->getSourceRange(), "emitAtomicOp: dynamic sync scope");
+ // The sync scope is not a compile-time constant. Emit a switch statement to
+ // handle each possible value of the sync scope.
+ CIRGenBuilderTy &builder = cgf.getBuilder();
+ mlir::Location loc = cgf.getLoc(expr->getSourceRange());
+ llvm::ArrayRef<unsigned> allScopes = scopeModel->getRuntimeValues();
+ unsigned fallback = scopeModel->getFallBackValue();
+
+ cir::SwitchOp::create(
+ builder, loc, scopeValue,
+ [&](mlir::OpBuilder &, mlir::Location loc, mlir::OperationState &) {
+ mlir::Block *switchBlock = builder.getBlock();
+
+ // Default case -- use fallback scope
+ cir::SyncScopeKind fallbackScope = convertSyncScopeToCIR(
+ cgf, expr->getScope()->getSourceRange(),
scopeModel->map(fallback));
+ emitMemOrderDefaultCaseLabel(builder, loc);
----------------
Lancern wrote:
I just happen to catch this which I missed when reviewing claude's changes
before committing. We should rename this function to a more general name like
`emitDefaultCaseLabel`.
https://github.com/llvm/llvm-project/pull/189699
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits