@@ -1502,7 +1502,6 @@ class SemaOpenMP : public SemaBase {
1502
1502
// / This categorization helps differentiate between original source loops
1503
1503
// / and the structures resulting from applying OpenMP loop transformations.
1504
1504
enum class OMPLoopCategory {
1505
-
1506
1505
// / @var OMPLoopCategory::RegularLoop
1507
1506
// / Represents a standard canonical loop nest found in the
1508
1507
// / original source code or an intact loop after transformations
@@ -1513,12 +1512,34 @@ class SemaOpenMP : public SemaBase {
1513
1512
// / Represents the resulting loop structure when an OpenMP loop
1514
1513
// transformation, generates a single, top-level loop
1515
1514
TransformSingleLoop,
1515
+ };
1516
1516
1517
- // / @var OMPLoopCategory::TransformLoopSequence
1518
- // / Represents the resulting loop structure when an OpenMP loop
1519
- // / transformation
1520
- // / generates a sequence of two or more canonical loop nests
1521
- TransformLoopSequence
1517
+ // / Holds the result of the analysis of a (possibly canonical) loop.
1518
+ struct LoopAnalysis {
1519
+ // / Category of the analyzed loop.
1520
+ OMPLoopCategory Category;
1521
+ // / Loop analyses results.
1522
+ OMPLoopBasedDirective::HelperExprs HelperExprs;
1523
+ // / The for-statement of the loop.
1524
+ Stmt *ForStmt;
1525
+ // / Initialization statements before transformations.
1526
+ SmallVector<Stmt *> OriginalInits;
1527
+ // / Initialization statements required after transformation of this loop.
1528
+ SmallVector<Stmt *> TransformsPreInits;
1529
+
1530
+ explicit LoopAnalysis (OMPLoopCategory Category) : Category(Category) {}
1531
+ };
1532
+
1533
+ // / Holds the result of the analysis of a (possibly canonical) loop sequence.
1534
+ struct LoopSequenceAnalysis {
1535
+ // / Number of top level canonical loops.
1536
+ unsigned LoopSeqSize = 0 ;
1537
+ // / Number of canonical loops, including nested.
1538
+ unsigned NumLoops = 0 ;
1539
+ // / For each loop results of the analysis.
1540
+ std::vector<LoopAnalysis> Loops;
1541
+ // / Additional code required before entering the transformed loop sequence.
1542
+ SmallVector<Stmt *> LoopSequencePreInits;
1522
1543
};
1523
1544
1524
1545
// / The main recursive process of `checkTransformableLoopSequence` that
@@ -1529,72 +1550,27 @@ class SemaOpenMP : public SemaBase {
1529
1550
// / Loop Sequences
1530
1551
// /
1531
1552
// / \param LoopSeqStmt The AST of the original statement.
1532
- // / \param LoopSeqSize [out] Number of top level canonical loops.
1533
- // / \param NumLoops [out] Number of total canonical loops (nested too).
1534
- // / \param LoopHelpers [out] The multiple loop analyses results.
1535
- // / \param ForStmts [out] The multiple Stmt of each For loop.
1536
- // / \param OriginalInits [out] The raw original initialization statements
1537
- // / of each belonging to a loop of the loop sequence
1538
- // / \param TransformPreInits [out] The multiple collection of statements and
1539
- // / declarations that must have been executed/declared
1540
- // / before entering the loop (each belonging to a
1541
- // / particular loop transformation, nullptr otherwise)
1542
- // / \param LoopSequencePreInits [out] Additional general collection of loop
1543
- // / transformation related statements and declarations
1544
- // / not bounded to a particular loop that must be
1545
- // / executed before entering the loop transformation
1546
- // / \param LoopCategories [out] A sequence of OMPLoopCategory values,
1547
- // / one for each loop or loop transformation node
1548
- // / successfully analyzed.
1553
+ // / \param SeqAnalysis [out] Result of the analysis of \p LoopSeqStmt
1549
1554
// / \param Context
1550
1555
// / \param Kind The loop transformation directive kind.
1551
1556
// / \return Whether the original statement is both syntactically and
1552
1557
// / semantically correct according to OpenMP 6.0 canonical loop
1553
1558
// / sequence definition.
1554
- bool analyzeLoopSequence (
1555
- Stmt *LoopSeqStmt, unsigned &LoopSeqSize, unsigned &NumLoops,
1556
- SmallVectorImpl<OMPLoopBasedDirective::HelperExprs> &LoopHelpers,
1557
- SmallVectorImpl<Stmt *> &ForStmts,
1558
- SmallVectorImpl<SmallVector<Stmt *>> &OriginalInits,
1559
- SmallVectorImpl<SmallVector<Stmt *>> &TransformsPreInits,
1560
- SmallVectorImpl<SmallVector<Stmt *>> &LoopSequencePreInits,
1561
- SmallVectorImpl<OMPLoopCategory> &LoopCategories, ASTContext &Context,
1562
- OpenMPDirectiveKind Kind);
1559
+ bool analyzeLoopSequence (Stmt *LoopSeqStmt, LoopSequenceAnalysis &SeqAnalysis,
1560
+ ASTContext &Context, OpenMPDirectiveKind Kind);
1563
1561
1564
1562
// / Validates and checks whether a loop sequence can be transformed according
1565
1563
// / to the given directive, providing necessary setup and initialization
1566
1564
// / (Driver function) before recursion using `analyzeLoopSequence`.
1567
1565
// /
1568
1566
// / \param Kind The loop transformation directive kind.
1569
1567
// / \param AStmt The AST of the original statement
1570
- // / \param LoopSeqSize [out] Number of top level canonical loops.
1571
- // / \param NumLoops [out] Number of total canonical loops (nested too)
1572
- // / \param LoopHelpers [out] The multiple loop analyses results.
1573
- // / \param ForStmts [out] The multiple Stmt of each For loop.
1574
- // / \param OriginalInits [out] The raw original initialization statements
1575
- // / of each belonging to a loop of the loop sequence
1576
- // / \param TransformsPreInits [out] The multiple collection of statements and
1577
- // / declarations that must have been executed/declared
1578
- // / before entering the loop (each belonging to a
1579
- // / particular loop transformation, nullptr otherwise)
1580
- // / \param LoopSequencePreInits [out] Additional general collection of loop
1581
- // / transformation related statements and declarations
1582
- // / not bounded to a particular loop that must be
1583
- // / executed before entering the loop transformation
1584
- // / \param LoopCategories [out] A sequence of OMPLoopCategory values,
1585
- // / one for each loop or loop transformation node
1586
- // / successfully analyzed.
1568
+ // / \param SeqAnalysis [out] Result of the analysis of \p LoopSeqStmt
1587
1569
// / \param Context
1588
1570
// / \return Whether there was an absence of errors or not
1589
- bool checkTransformableLoopSequence (
1590
- OpenMPDirectiveKind Kind, Stmt *AStmt, unsigned &LoopSeqSize,
1591
- unsigned &NumLoops,
1592
- SmallVectorImpl<OMPLoopBasedDirective::HelperExprs> &LoopHelpers,
1593
- SmallVectorImpl<Stmt *> &ForStmts,
1594
- SmallVectorImpl<SmallVector<Stmt *>> &OriginalInits,
1595
- SmallVectorImpl<SmallVector<Stmt *>> &TransformsPreInits,
1596
- SmallVectorImpl<SmallVector<Stmt *>> &LoopSequencePreInits,
1597
- SmallVectorImpl<OMPLoopCategory> &LoopCategories, ASTContext &Context);
1571
+ bool checkTransformableLoopSequence (OpenMPDirectiveKind Kind, Stmt *AStmt,
1572
+ LoopSequenceAnalysis &SeqAnalysis,
1573
+ ASTContext &Context);
1598
1574
1599
1575
// / Helper to keep information about the current `omp begin/end declare
1600
1576
// / variant` nesting.
0 commit comments