@@ -684,14 +684,15 @@ createLoopOp(Fortran::lower::AbstractConverter &converter,
684
684
Fortran::semantics::SemanticsContext &semanticsContext,
685
685
Fortran::lower::StatementContext &stmtCtx,
686
686
const Fortran::parser::AccClauseList &accClauseList) {
687
- fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder ();
687
+ fir::FirOpBuilder &builder = converter.getFirOpBuilder ();
688
688
689
689
mlir::Value workerNum;
690
690
mlir::Value vectorNum;
691
691
mlir::Value gangNum;
692
692
mlir::Value gangStatic;
693
693
llvm::SmallVector<mlir::Value, 2 > tileOperands, privateOperands,
694
694
reductionOperands;
695
+ llvm::SmallVector<mlir::Attribute> privatizations;
695
696
bool hasGang = false , hasVector = false , hasWorker = false ;
696
697
697
698
for (const Fortran::parser::AccClause &clause : accClauseList.v ) {
@@ -716,8 +717,8 @@ createLoopOp(Fortran::lower::AbstractConverter &converter,
716
717
} else {
717
718
// * was passed as value and will be represented as a special
718
719
// constant.
719
- gangStatic = firOpBuilder .createIntegerConstant (
720
- clauseLocation, firOpBuilder .getIndexType (), starCst);
720
+ gangStatic = builder .createIntegerConstant (
721
+ clauseLocation, builder .getIndexType (), starCst);
721
722
}
722
723
}
723
724
}
@@ -749,17 +750,17 @@ createLoopOp(Fortran::lower::AbstractConverter &converter,
749
750
} else {
750
751
// * was passed as value and will be represented as a -1 constant
751
752
// integer.
752
- mlir::Value tileStar = firOpBuilder .createIntegerConstant (
753
- clauseLocation, firOpBuilder .getIntegerType (32 ),
753
+ mlir::Value tileStar = builder .createIntegerConstant (
754
+ clauseLocation, builder .getIntegerType (32 ),
754
755
/* STAR */ -1 );
755
756
tileOperands.push_back (tileStar);
756
757
}
757
758
}
758
759
} else if (const auto *privateClause =
759
760
std::get_if<Fortran::parser::AccClause::Private>(
760
761
&clause.u )) {
761
- genObjectList (privateClause->v , converter, semanticsContext, stmtCtx,
762
- privateOperands);
762
+ genPrivatizations (privateClause->v , converter, semanticsContext, stmtCtx,
763
+ privateOperands, privatizations );
763
764
} else if (std::get_if<Fortran::parser::AccClause::Reduction>(&clause.u )) {
764
765
// Reduction clause is left out for the moment as the clause will probably
765
766
// end up having its own operation.
@@ -779,14 +780,18 @@ createLoopOp(Fortran::lower::AbstractConverter &converter,
779
780
addOperands (operands, operandSegments, reductionOperands);
780
781
781
782
auto loopOp = createRegionOp<mlir::acc::LoopOp, mlir::acc::YieldOp>(
782
- firOpBuilder , currentLocation, operands, operandSegments);
783
+ builder , currentLocation, operands, operandSegments);
783
784
784
785
if (hasGang)
785
- loopOp.setHasGangAttr (firOpBuilder .getUnitAttr ());
786
+ loopOp.setHasGangAttr (builder .getUnitAttr ());
786
787
if (hasWorker)
787
- loopOp.setHasWorkerAttr (firOpBuilder .getUnitAttr ());
788
+ loopOp.setHasWorkerAttr (builder .getUnitAttr ());
788
789
if (hasVector)
789
- loopOp.setHasVectorAttr (firOpBuilder.getUnitAttr ());
790
+ loopOp.setHasVectorAttr (builder.getUnitAttr ());
791
+
792
+ if (!privatizations.empty ())
793
+ loopOp.setPrivatizationsAttr (
794
+ mlir::ArrayAttr::get (builder.getContext (), privatizations));
790
795
791
796
// Lower clauses mapped to attributes
792
797
for (const Fortran::parser::AccClause &clause : accClauseList.v ) {
@@ -796,16 +801,16 @@ createLoopOp(Fortran::lower::AbstractConverter &converter,
796
801
const std::optional<int64_t > collapseValue =
797
802
Fortran::evaluate::ToInt64 (*expr);
798
803
if (collapseValue) {
799
- loopOp.setCollapseAttr (firOpBuilder .getI64IntegerAttr (*collapseValue));
804
+ loopOp.setCollapseAttr (builder .getI64IntegerAttr (*collapseValue));
800
805
}
801
806
} else if (std::get_if<Fortran::parser::AccClause::Seq>(&clause.u )) {
802
- loopOp.setSeqAttr (firOpBuilder .getUnitAttr ());
807
+ loopOp.setSeqAttr (builder .getUnitAttr ());
803
808
} else if (std::get_if<Fortran::parser::AccClause::Independent>(
804
809
&clause.u )) {
805
- loopOp.setIndependentAttr (firOpBuilder .getUnitAttr ());
810
+ loopOp.setIndependentAttr (builder .getUnitAttr ());
806
811
} else if (std::get_if<Fortran::parser::AccClause::Auto>(&clause.u )) {
807
812
loopOp->setAttr (mlir::acc::LoopOp::getAutoAttrStrName (),
808
- firOpBuilder .getUnitAttr ());
813
+ builder .getUnitAttr ());
809
814
}
810
815
}
811
816
return loopOp;
0 commit comments