@@ -1541,26 +1541,25 @@ static LogicalResult verifyPrivateVarList(OpType &op) {
1541
1541
}
1542
1542
1543
1543
LogicalResult ParallelOp::verify () {
1544
- // Check that it is a valid loop wrapper if it's taking that role.
1545
- if (isa<DistributeOp>((*this )->getParentOp ())) {
1546
- if (!isWrapper ())
1547
- return emitOpError () << " must take a loop wrapper role if nested inside "
1548
- " of 'omp.distribute'" ;
1544
+ auto distributeChildOps = getOps<DistributeOp>();
1545
+ if (!distributeChildOps.empty ()) {
1549
1546
if (!isComposite ())
1550
1547
return emitError ()
1551
- << " 'omp.composite' attribute missing from composite wrapper " ;
1548
+ << " 'omp.composite' attribute missing from composite operation " ;
1552
1549
1553
- if (LoopWrapperInterface nested = getNestedWrapper ()) {
1554
- // Check for the allowed leaf constructs that may appear in a composite
1555
- // construct directly after PARALLEL.
1556
- if (!isa<WsloopOp>(nested))
1557
- return emitError () << " only supported nested wrapper is 'omp.wsloop'" ;
1558
- } else {
1559
- return emitOpError () << " must not wrap an 'omp.loop_nest' directly" ;
1550
+ auto *ompDialect = getContext ()->getLoadedDialect <OpenMPDialect>();
1551
+ Operation &distributeOp = **distributeChildOps.begin ();
1552
+ for (Operation &childOp : getOps ()) {
1553
+ if (&childOp == &distributeOp || ompDialect != childOp.getDialect ())
1554
+ continue ;
1555
+
1556
+ if (!childOp.hasTrait <OpTrait::IsTerminator>())
1557
+ return emitError () << " unexpected OpenMP operation inside of composite "
1558
+ " 'omp.parallel'" ;
1560
1559
}
1561
1560
} else if (isComposite ()) {
1562
1561
return emitError ()
1563
- << " 'omp.composite' attribute present in non-composite wrapper " ;
1562
+ << " 'omp.composite' attribute present in non-composite operation " ;
1564
1563
}
1565
1564
1566
1565
if (getAllocateVars ().size () != getAllocatorVars ().size ())
@@ -1751,15 +1750,12 @@ void WsloopOp::build(OpBuilder &builder, OperationState &state,
1751
1750
}
1752
1751
1753
1752
LogicalResult WsloopOp::verify () {
1754
- if (!isWrapper ())
1755
- return emitOpError () << " must be a loop wrapper" ;
1753
+ if (!isValidWrapper ())
1754
+ return emitOpError () << " must be a valid loop wrapper" ;
1756
1755
1757
- auto wrapper =
1758
- llvm::dyn_cast_if_present<LoopWrapperInterface>((*this )->getParentOp ());
1759
1756
bool isCompositeChildLeaf =
1760
- wrapper && wrapper.isWrapper () &&
1761
- (!llvm::isa<ParallelOp>(wrapper) ||
1762
- llvm::isa_and_present<DistributeOp>(wrapper->getParentOp ()));
1757
+ llvm::dyn_cast_if_present<LoopWrapperInterface>((*this )->getParentOp ());
1758
+
1763
1759
if (LoopWrapperInterface nested = getNestedWrapper ()) {
1764
1760
if (!isComposite ())
1765
1761
return emitError ()
@@ -1813,18 +1809,14 @@ LogicalResult SimdOp::verify() {
1813
1809
if (verifyNontemporalClause (*this , getNontemporalVars ()).failed ())
1814
1810
return failure ();
1815
1811
1816
- if (!isWrapper ())
1817
- return emitOpError () << " must be a loop wrapper" ;
1812
+ if (!isValidWrapper ())
1813
+ return emitOpError () << " must be a valid loop wrapper" ;
1818
1814
1819
1815
if (getNestedWrapper ())
1820
1816
return emitOpError () << " must wrap an 'omp.loop_nest' directly" ;
1821
1817
1822
- auto wrapper =
1823
- llvm::dyn_cast_if_present<LoopWrapperInterface>((*this )->getParentOp ());
1824
1818
bool isCompositeChildLeaf =
1825
- wrapper && wrapper.isWrapper () &&
1826
- (!llvm::isa<ParallelOp>(wrapper) ||
1827
- llvm::isa_and_present<DistributeOp>(wrapper->getParentOp ()));
1819
+ llvm::dyn_cast_if_present<LoopWrapperInterface>((*this )->getParentOp ());
1828
1820
1829
1821
if (!isComposite () && isCompositeChildLeaf)
1830
1822
return emitError ()
@@ -1859,18 +1851,22 @@ LogicalResult DistributeOp::verify() {
1859
1851
return emitError (
1860
1852
" expected equal sizes for allocate and allocator variables" );
1861
1853
1862
- if (!isWrapper ())
1863
- return emitOpError () << " must be a loop wrapper" ;
1854
+ if (!isValidWrapper ())
1855
+ return emitOpError () << " must be a valid loop wrapper" ;
1864
1856
1865
1857
if (LoopWrapperInterface nested = getNestedWrapper ()) {
1866
1858
if (!isComposite ())
1867
1859
return emitError ()
1868
1860
<< " 'omp.composite' attribute missing from composite wrapper" ;
1869
1861
// Check for the allowed leaf constructs that may appear in a composite
1870
1862
// construct directly after DISTRIBUTE.
1871
- if (!isa<ParallelOp, SimdOp>(nested))
1872
- return emitError () << " only supported nested wrappers are 'omp.parallel' "
1873
- " and 'omp.simd'" ;
1863
+ if (isa<WsloopOp>(nested)) {
1864
+ if (!llvm::dyn_cast_if_present<ParallelOp>((*this )->getParentOp ()))
1865
+ return emitError () << " an 'omp.wsloop' nested wrapper is only allowed "
1866
+ " when 'omp.parallel' is the direct parent" ;
1867
+ } else if (!isa<SimdOp>(nested))
1868
+ return emitError () << " only supported nested wrappers are 'omp.simd' and "
1869
+ " 'omp.wsloop'" ;
1874
1870
} else if (isComposite ()) {
1875
1871
return emitError ()
1876
1872
<< " 'omp.composite' attribute present in non-composite wrapper" ;
@@ -2063,8 +2059,8 @@ LogicalResult TaskloopOp::verify() {
2063
2059
" may not appear on the same taskloop directive" );
2064
2060
}
2065
2061
2066
- if (!isWrapper ())
2067
- return emitOpError () << " must be a loop wrapper" ;
2062
+ if (!isValidWrapper ())
2063
+ return emitOpError () << " must be a valid loop wrapper" ;
2068
2064
2069
2065
if (LoopWrapperInterface nested = getNestedWrapper ()) {
2070
2066
if (!isComposite ())
@@ -2161,11 +2157,8 @@ LogicalResult LoopNestOp::verify() {
2161
2157
<< " range argument type does not match corresponding IV type" ;
2162
2158
}
2163
2159
2164
- auto wrapper =
2165
- llvm::dyn_cast_if_present<LoopWrapperInterface>((*this )->getParentOp ());
2166
-
2167
- if (!wrapper || !wrapper.isWrapper ())
2168
- return emitOpError () << " expects parent op to be a valid loop wrapper" ;
2160
+ if (!llvm::dyn_cast_if_present<LoopWrapperInterface>((*this )->getParentOp ()))
2161
+ return emitOpError () << " expects parent op to be a loop wrapper" ;
2169
2162
2170
2163
return success ();
2171
2164
}
@@ -2175,8 +2168,6 @@ void LoopNestOp::gatherWrappers(
2175
2168
Operation *parent = (*this )->getParentOp ();
2176
2169
while (auto wrapper =
2177
2170
llvm::dyn_cast_if_present<LoopWrapperInterface>(parent)) {
2178
- if (!wrapper.isWrapper ())
2179
- break ;
2180
2171
wrappers.push_back (wrapper);
2181
2172
parent = parent->getParentOp ();
2182
2173
}
0 commit comments