[Mlir-commits] [mlir] [mlir][OpenMP] Convert omp.cancel parallel to LLVMIR (PR #137192)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Apr 28 00:28:05 PDT 2025
================
@@ -2991,6 +3010,47 @@ convertOmpAtomicCapture(omp::AtomicCaptureOp atomicCaptureOp,
return success();
}
+static llvm::omp::Directive convertCancellationConstructType(
+ omp::ClauseCancellationConstructType directive) {
+ switch (directive) {
+ case omp::ClauseCancellationConstructType::Loop:
+ return llvm::omp::Directive::OMPD_for;
+ case omp::ClauseCancellationConstructType::Parallel:
+ return llvm::omp::Directive::OMPD_parallel;
+ case omp::ClauseCancellationConstructType::Sections:
+ return llvm::omp::Directive::OMPD_sections;
+ case omp::ClauseCancellationConstructType::Taskgroup:
+ return llvm::omp::Directive::OMPD_taskgroup;
+ }
+}
+
+static LogicalResult
+convertOmpCancel(omp::CancelOp op, llvm::IRBuilderBase &builder,
+ LLVM::ModuleTranslation &moduleTranslation) {
+ llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
+ llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
+
+ if (failed(checkImplementationStatus(*op.getOperation())))
+ return failure();
+
+ llvm::Value *ifCond = nullptr;
+ if (Value ifVar = op.getIfExpr())
+ ifCond = moduleTranslation.lookupValue(ifVar);
+
+ llvm::omp::Directive cancelledDirective =
+ convertCancellationConstructType(op.getCancelDirective());
+
+ llvm::OpenMPIRBuilder::InsertPointOrErrorTy afterIP =
----------------
NimishMishra wrote:
`ifCond` is a `nullptr` and then is assigned through a `lookupValue`. Do we need an assert before using it in `createCancel`?
https://github.com/llvm/llvm-project/pull/137192
More information about the Mlir-commits
mailing list