================
@@ -211,8 +211,26 @@ CIRGenFunction::emitOMPMasterDirective(const
OMPMasterDirective &s) {
}
mlir::LogicalResult
CIRGenFunction::emitOMPCriticalDirective(const OMPCriticalDirective &s) {
- getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP
OMPCriticalDirective");
- return mlir::failure();
+ if (s.getDirectiveName().getName()) {
+ getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP named critical");
+ return mlir::failure();
+ }
+ assert(s.clauses().empty() && "Sema rejects hint without a name");
+
+ mlir::Location begin = getLoc(s.getBeginLoc());
+ auto criticalOp =
+ mlir::omp::CriticalOp::create(builder, begin, mlir::FlatSymbolRefAttr());
+
+ mlir::Block &block = criticalOp.getRegion().emplaceBlock();
----------------
andykaylor wrote:
Rather than creating the operation and having to reset the insertion point,
would it be possible to add a builder to `omp::CriticalOp` that takes a builder
argument, so you get something more like this:
```
auto criticalOp = mlir::omp::CriticalOp::create(builder, begin,
mlir::FlatSymboRefAttr(),
[&](mlir::OpBuilder &b,
mlir::Location loc) {
LexicalScope ls{*this, loc,
builder.getInsertionBlock()};
res =
emitStmt(s.getAssociatedStmt(), /*useCurrentScope=*/true);
ls.forceCleanup();
mlir::omp::TerminatorOp::create(builder, getLoc(s.getEndLoc()));
});
```
https://github.com/llvm/llvm-project/pull/236140
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits