@@ -956,30 +956,46 @@ class OMPLoopBasedDirective : public OMPExecutableDirective {
956
956
}
957
957
};
958
958
959
+ // / Common class of data shared between
960
+ // / OMPCanonicalLoopNestTransformationDirective and transformations over
961
+ // / canonical loop sequences.
962
+ class OMPLoopTransformationDirective {
963
+ // / Number of (top-level) generated loops.
964
+ // / This value is 1 for most transformations as they only map one loop nest
965
+ // / into another.
966
+ // / Some loop transformations (like a non-partial 'unroll') may not generate
967
+ // / a loop nest, so this would be 0.
968
+ // / Some loop transformations (like 'fuse' with looprange and 'split') may
969
+ // / generate more than one loop nest, so the value would be >= 1.
970
+ unsigned NumGeneratedTopLevelLoops = 1 ;
971
+
972
+ protected:
973
+ void setNumGeneratedTopLevelLoops (unsigned N) {
974
+ NumGeneratedTopLevelLoops = N;
975
+ }
976
+
977
+ public:
978
+ unsigned getNumGeneratedTopLevelLoops () const {
979
+ return NumGeneratedTopLevelLoops;
980
+ }
981
+ };
982
+
959
983
// / The base class for all transformation directives of canonical loop nests.
960
984
class OMPCanonicalLoopNestTransformationDirective
961
- : public OMPLoopBasedDirective {
985
+ : public OMPLoopBasedDirective,
986
+ public OMPLoopTransformationDirective {
962
987
friend class ASTStmtReader ;
963
988
964
- // / Number of loops generated by this loop transformation.
965
- unsigned NumGeneratedLoops = 0 ;
966
-
967
989
protected:
968
990
explicit OMPCanonicalLoopNestTransformationDirective (
969
991
StmtClass SC, OpenMPDirectiveKind Kind, SourceLocation StartLoc,
970
992
SourceLocation EndLoc, unsigned NumAssociatedLoops)
971
993
: OMPLoopBasedDirective(SC, Kind, StartLoc, EndLoc, NumAssociatedLoops) {}
972
994
973
- // / Set the number of loops generated by this loop transformation.
974
- void setNumGeneratedLoops (unsigned Num) { NumGeneratedLoops = Num; }
975
-
976
995
public:
977
996
// / Return the number of associated (consumed) loops.
978
997
unsigned getNumAssociatedLoops () const { return getLoopsNumber (); }
979
998
980
- // / Return the number of loops generated by this loop transformation.
981
- unsigned getNumGeneratedLoops () const { return NumGeneratedLoops; }
982
-
983
999
// / Get the de-sugared statements after the loop transformation.
984
1000
// /
985
1001
// / Might be nullptr if either the directive generates no loops and is handled
@@ -5560,9 +5576,7 @@ class OMPTileDirective final
5560
5576
unsigned NumLoops)
5561
5577
: OMPCanonicalLoopNestTransformationDirective(
5562
5578
OMPTileDirectiveClass, llvm::omp::OMPD_tile, StartLoc, EndLoc,
5563
- NumLoops) {
5564
- setNumGeneratedLoops (2 * NumLoops);
5565
- }
5579
+ NumLoops) {}
5566
5580
5567
5581
void setPreInits (Stmt *PreInits) {
5568
5582
Data->getChildren ()[PreInitsOffset] = PreInits;
@@ -5638,9 +5652,7 @@ class OMPStripeDirective final
5638
5652
unsigned NumLoops)
5639
5653
: OMPCanonicalLoopNestTransformationDirective(
5640
5654
OMPStripeDirectiveClass, llvm::omp::OMPD_stripe, StartLoc, EndLoc,
5641
- NumLoops) {
5642
- setNumGeneratedLoops (2 * NumLoops);
5643
- }
5655
+ NumLoops) {}
5644
5656
5645
5657
void setPreInits (Stmt *PreInits) {
5646
5658
Data->getChildren ()[PreInitsOffset] = PreInits;
@@ -5744,7 +5756,8 @@ class OMPUnrollDirective final
5744
5756
static OMPUnrollDirective *
5745
5757
Create (const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5746
5758
ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
5747
- unsigned NumGeneratedLoops, Stmt *TransformedStmt, Stmt *PreInits);
5759
+ unsigned NumGeneratedTopLevelLoops, Stmt *TransformedStmt,
5760
+ Stmt *PreInits);
5748
5761
5749
5762
// / Build an empty '#pragma omp unroll' AST node for deserialization.
5750
5763
// /
@@ -5794,9 +5807,7 @@ class OMPReverseDirective final
5794
5807
unsigned NumLoops)
5795
5808
: OMPCanonicalLoopNestTransformationDirective(
5796
5809
OMPReverseDirectiveClass, llvm::omp::OMPD_reverse, StartLoc, EndLoc,
5797
- NumLoops) {
5798
- setNumGeneratedLoops (NumLoops);
5799
- }
5810
+ NumLoops) {}
5800
5811
5801
5812
void setPreInits (Stmt *PreInits) {
5802
5813
Data->getChildren ()[PreInitsOffset] = PreInits;
@@ -5867,9 +5878,7 @@ class OMPInterchangeDirective final
5867
5878
SourceLocation EndLoc, unsigned NumLoops)
5868
5879
: OMPCanonicalLoopNestTransformationDirective(
5869
5880
OMPInterchangeDirectiveClass, llvm::omp::OMPD_interchange, StartLoc,
5870
- EndLoc, NumLoops) {
5871
- setNumGeneratedLoops (NumLoops);
5872
- }
5881
+ EndLoc, NumLoops) {}
5873
5882
5874
5883
void setPreInits (Stmt *PreInits) {
5875
5884
Data->getChildren ()[PreInitsOffset] = PreInits;
0 commit comments