================
@@ -249,38 +278,58 @@ emitOMPTargetImplicitCaptures(CIRGenFunction &cgf, const
OMPTargetDirective &s,
}
}
-/// Emit the body of an omp.target region, remapping mapped variables to the
-/// block arguments of the target op's region.
+template <typename DirectiveTy>
static mlir::LogicalResult
-emitOMPTargetBody(CIRGenFunction &cgf, const OMPTargetDirective &s,
- mlir::omp::TargetOp targetOp,
- llvm::ArrayRef<mlir::Value> mapVars,
- llvm::ArrayRef<const VarDecl *> mappedVarDecls,
- mlir::Location begin, mlir::Location end) {
- mlir::Block &block = targetOp.getRegion().emplaceBlock();
+emitTargetOp(CIRGenFunction &cgf, const DirectiveTy &s, mlir::Location begin,
+ mlir::Location end,
+ llvm::function_ref<mlir::LogicalResult()> emitBody) {
+ CIRGenBuilderTy &builder = cgf.getBuilder();
+ CIRGenModule &cgm = cgf.getCIRGenModule();
+
+ llvm::SmallVector<const OMPClause *> clauses =
+ getLeafClauses(cgf, s, llvm::omp::OMPD_target);
+
+ mlir::omp::TargetExtOperands clauseOps;
+ llvm::SmallVector<const VarDecl *> mapSyms;
+
+ OpenMPClauseEmitter ce(cgf, cgm, builder, begin, clauses);
+ ce.emitMap(clauseOps, &mapSyms);
+ ce.emitNYI</*supported=*/OMPMapClause>(
+ /*nyi=*/OpenMPNYIClauseList<
+ OMPAllocateClause, OMPDefaultClause, OMPDefaultmapClause,
+ OMPDependClause, OMPDeviceClause, OMPFirstprivateClause,
+ OMPHasDeviceAddrClause, OMPIfClause, OMPInReductionClause,
+ OMPIsDevicePtrClause, OMPNowaitClause, OMPPrivateClause,
+ OMPThreadLimitClause, OMPUsesAllocatorsClause, OMPXBareClause>{},
+ llvm::omp::Directive::OMPD_target);
+
+ emitOMPTargetImplicitCaptures(cgf, s, mapSyms);
+
+ // Use generic for now.
+ clauseOps.kernelType = mlir::omp::TargetExecModeAttr::get(
+ &cgf.getMLIRContext(), mlir::omp::TargetExecMode::generic);
----------------
jsjodin wrote:
Added the pass. Thanks!
https://github.com/llvm/llvm-project/pull/207019
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits