@@ -521,7 +521,7 @@ struct OpWithBodyGenInfo {
521
521
// / \param [in] op - the operation the body belongs to.
522
522
// / \param [in] info - options controlling code-gen for the construction.
523
523
template <typename Op>
524
- static void createBodyOfOp (Op &op, OpWithBodyGenInfo &info) {
524
+ static void createBodyOfOp (mlir::Operation &op, OpWithBodyGenInfo &info) {
525
525
fir::FirOpBuilder &firOpBuilder = info.converter .getFirOpBuilder ();
526
526
527
527
auto insertMarker = [](fir::FirOpBuilder &builder) {
@@ -537,10 +537,10 @@ static void createBodyOfOp(Op &op, OpWithBodyGenInfo &info) {
537
537
auto regionArgs =
538
538
[&]() -> llvm::SmallVector<const Fortran::semantics::Symbol *> {
539
539
if (info.genRegionEntryCB != nullptr ) {
540
- return info.genRegionEntryCB (op);
540
+ return info.genRegionEntryCB (& op);
541
541
}
542
542
543
- firOpBuilder.createBlock (&op.getRegion ());
543
+ firOpBuilder.createBlock (&op.getRegion (0 ));
544
544
return {};
545
545
}();
546
546
// Mark the earliest insertion point.
@@ -556,7 +556,7 @@ static void createBodyOfOp(Op &op, OpWithBodyGenInfo &info) {
556
556
// Start with privatization, so that the lowering of the nested
557
557
// code will use the right symbols.
558
558
constexpr bool isLoop = std::is_same_v<Op, mlir::omp::WsloopOp> ||
559
- std::is_same_v<Op, mlir::omp::SimdLoopOp >;
559
+ std::is_same_v<Op, mlir::omp::SimdOp >;
560
560
bool privatize = info.clauses && !info.outerCombined ;
561
561
562
562
firOpBuilder.setInsertionPoint (marker);
@@ -582,9 +582,9 @@ static void createBodyOfOp(Op &op, OpWithBodyGenInfo &info) {
582
582
// a lot of complications for our approach if the terminator generation
583
583
// is delayed past this point. Insert a temporary terminator here, then
584
584
// delete it.
585
- firOpBuilder.setInsertionPointToEnd (&op.getRegion ().back ());
586
- auto *temp = Fortran::lower::genOpenMPTerminator (
587
- firOpBuilder, op. getOperation () , info.loc );
585
+ firOpBuilder.setInsertionPointToEnd (&op.getRegion (0 ).back ());
586
+ auto *temp =
587
+ Fortran::lower::genOpenMPTerminator ( firOpBuilder, &op , info.loc );
588
588
firOpBuilder.setInsertionPointAfter (marker);
589
589
genNestedEvaluations (info.converter , info.eval );
590
590
temp->erase ();
@@ -626,10 +626,10 @@ static void createBodyOfOp(Op &op, OpWithBodyGenInfo &info) {
626
626
return exit;
627
627
};
628
628
629
- if (auto *exitBlock = getUniqueExit (op.getRegion ())) {
629
+ if (auto *exitBlock = getUniqueExit (op.getRegion (0 ))) {
630
630
firOpBuilder.setInsertionPointToEnd (exitBlock);
631
- auto *term = Fortran::lower::genOpenMPTerminator (
632
- firOpBuilder, op. getOperation () , info.loc );
631
+ auto *term =
632
+ Fortran::lower::genOpenMPTerminator ( firOpBuilder, &op , info.loc );
633
633
// Only insert lastprivate code when there actually is an exit block.
634
634
// Such a block may not exist if the nested code produced an infinite
635
635
// loop (this may not make sense in production code, but a user could
@@ -638,11 +638,11 @@ static void createBodyOfOp(Op &op, OpWithBodyGenInfo &info) {
638
638
if (privatize) {
639
639
if (!info.dsp ) {
640
640
assert (tempDsp.has_value ());
641
- tempDsp->processStep2 (op, isLoop);
641
+ tempDsp->processStep2 (& op, isLoop);
642
642
} else {
643
643
if (isLoop && regionArgs.size () > 0 )
644
644
info.dsp ->setLoopIV (info.converter .getSymbolAddress (*regionArgs[0 ]));
645
- info.dsp ->processStep2 (op, isLoop);
645
+ info.dsp ->processStep2 (& op, isLoop);
646
646
}
647
647
}
648
648
}
@@ -719,7 +719,7 @@ template <typename OpTy, typename... Args>
719
719
static OpTy genOpWithBody (OpWithBodyGenInfo &info, Args &&...args) {
720
720
auto op = info.converter .getFirOpBuilder ().create <OpTy>(
721
721
info.loc , std::forward<Args>(args)...);
722
- createBodyOfOp<OpTy>(op, info);
722
+ createBodyOfOp<OpTy>(* op, info);
723
723
return op;
724
724
}
725
725
@@ -1720,11 +1720,20 @@ createSimdLoop(Fortran::lower::AbstractConverter &converter,
1720
1720
cp.processTODO <clause::Aligned, clause::Allocate, clause::Linear,
1721
1721
clause::Nontemporal, clause::Order>(loc, ompDirective);
1722
1722
1723
+ // Create omp.simd wrapper.
1723
1724
mlir::TypeRange resultType;
1724
- auto simdLoopOp = firOpBuilder.create <mlir::omp::SimdLoopOp>(
1725
- loc, resultType, lowerBound, upperBound, step, alignedVars,
1726
- /* alignment_values=*/ nullptr , ifClauseOperand, nontemporalVars,
1727
- orderClauseOperand, simdlenClauseOperand, safelenClauseOperand,
1725
+ auto simdOp = firOpBuilder.create <mlir::omp::SimdOp>(
1726
+ loc, resultType, alignedVars, /* alignment_values=*/ nullptr ,
1727
+ ifClauseOperand, nontemporalVars, orderClauseOperand,
1728
+ simdlenClauseOperand, safelenClauseOperand);
1729
+
1730
+ firOpBuilder.createBlock (&simdOp.getRegion ());
1731
+ firOpBuilder.setInsertionPoint (
1732
+ Fortran::lower::genOpenMPTerminator (firOpBuilder, simdOp, loc));
1733
+
1734
+ // Create nested omp.loop_nest and fill body with loop contents.
1735
+ auto loopOp = firOpBuilder.create <mlir::omp::LoopNestOp>(
1736
+ loc, lowerBound, upperBound, step,
1728
1737
/* inclusive=*/ firOpBuilder.getUnitAttr ());
1729
1738
1730
1739
auto *nestedEval = getCollapsedLoopEval (
@@ -1734,11 +1743,11 @@ createSimdLoop(Fortran::lower::AbstractConverter &converter,
1734
1743
return genLoopVars (op, converter, loc, iv);
1735
1744
};
1736
1745
1737
- createBodyOfOp<mlir::omp::SimdLoopOp >(
1738
- simdLoopOp , OpWithBodyGenInfo (converter, semaCtx, loc, *nestedEval)
1739
- .setClauses (&loopOpClauseList)
1740
- .setDataSharingProcessor (&dsp)
1741
- .setGenRegionEntryCb (ivCallback));
1746
+ createBodyOfOp<mlir::omp::SimdOp >(
1747
+ *loopOp , OpWithBodyGenInfo (converter, semaCtx, loc, *nestedEval)
1748
+ .setClauses (&loopOpClauseList)
1749
+ .setDataSharingProcessor (&dsp)
1750
+ .setGenRegionEntryCb (ivCallback));
1742
1751
}
1743
1752
1744
1753
static void createWsloop (Fortran::lower::AbstractConverter &converter,
@@ -1819,11 +1828,11 @@ static void createWsloop(Fortran::lower::AbstractConverter &converter,
1819
1828
};
1820
1829
1821
1830
createBodyOfOp<mlir::omp::WsloopOp>(
1822
- wsLoopOp, OpWithBodyGenInfo (converter, semaCtx, loc, *nestedEval)
1823
- .setClauses (&beginClauseList)
1824
- .setDataSharingProcessor (&dsp)
1825
- .setReductions (&reductionSymbols, &reductionTypes)
1826
- .setGenRegionEntryCb (ivCallback));
1831
+ * wsLoopOp, OpWithBodyGenInfo (converter, semaCtx, loc, *nestedEval)
1832
+ .setClauses (&beginClauseList)
1833
+ .setDataSharingProcessor (&dsp)
1834
+ .setReductions (&reductionSymbols, &reductionTypes)
1835
+ .setGenRegionEntryCb (ivCallback));
1827
1836
}
1828
1837
1829
1838
static void createSimdWsloop (
@@ -2200,7 +2209,7 @@ genOMP(Fortran::lower::AbstractConverter &converter,
2200
2209
global.getSymName ()));
2201
2210
}();
2202
2211
auto genInfo = OpWithBodyGenInfo (converter, semaCtx, currentLocation, eval);
2203
- createBodyOfOp<mlir::omp::CriticalOp>(criticalOp, genInfo);
2212
+ createBodyOfOp<mlir::omp::CriticalOp>(* criticalOp, genInfo);
2204
2213
}
2205
2214
2206
2215
static void
@@ -2410,10 +2419,9 @@ mlir::Operation *Fortran::lower::genOpenMPTerminator(fir::FirOpBuilder &builder,
2410
2419
mlir::Operation *op,
2411
2420
mlir::Location loc) {
2412
2421
if (mlir::isa<mlir::omp::WsloopOp, mlir::omp::DeclareReductionOp,
2413
- mlir::omp::AtomicUpdateOp, mlir::omp::SimdLoopOp >(op))
2422
+ mlir::omp::AtomicUpdateOp>(op))
2414
2423
return builder.create <mlir::omp::YieldOp>(loc);
2415
- else
2416
- return builder.create <mlir::omp::TerminatorOp>(loc);
2424
+ return builder.create <mlir::omp::TerminatorOp>(loc);
2417
2425
}
2418
2426
2419
2427
void Fortran::lower::genOpenMPConstruct (
0 commit comments