@@ -1741,7 +1741,7 @@ static AffineExpr createDimSizeExprForTiledLayout(AffineExpr oldMapOutput,
1741
1741
template <typename AllocLikeOp>
1742
1742
static void createNewDynamicSizes (MemRefType oldMemRefType,
1743
1743
MemRefType newMemRefType, AffineMap map,
1744
- AllocLikeOp * allocOp, OpBuilder b,
1744
+ AllocLikeOp allocOp, OpBuilder b,
1745
1745
SmallVectorImpl<Value> &newDynamicSizes) {
1746
1746
// Create new input for AffineApplyOp.
1747
1747
SmallVector<Value, 4 > inAffineApply;
@@ -1750,13 +1750,13 @@ static void createNewDynamicSizes(MemRefType oldMemRefType,
1750
1750
for (unsigned d = 0 ; d < oldMemRefType.getRank (); ++d) {
1751
1751
if (oldMemRefShape[d] < 0 ) {
1752
1752
// Use dynamicSizes of allocOp for dynamic dimension.
1753
- inAffineApply.emplace_back (allocOp-> getDynamicSizes ()[dynIdx]);
1753
+ inAffineApply.emplace_back (allocOp. getDynamicSizes ()[dynIdx]);
1754
1754
dynIdx++;
1755
1755
} else {
1756
1756
// Create ConstantOp for static dimension.
1757
1757
auto constantAttr = b.getIntegerAttr (b.getIndexType (), oldMemRefShape[d]);
1758
1758
inAffineApply.emplace_back (
1759
- b.create <arith::ConstantOp>(allocOp-> getLoc (), constantAttr));
1759
+ b.create <arith::ConstantOp>(allocOp. getLoc (), constantAttr));
1760
1760
}
1761
1761
}
1762
1762
@@ -1780,18 +1780,17 @@ static void createNewDynamicSizes(MemRefType oldMemRefType,
1780
1780
AffineMap newMap =
1781
1781
AffineMap::get (map.getNumInputs (), map.getNumSymbols (), newMapOutput);
1782
1782
Value affineApp =
1783
- b.create <AffineApplyOp>(allocOp-> getLoc (), newMap, inAffineApply);
1783
+ b.create <AffineApplyOp>(allocOp. getLoc (), newMap, inAffineApply);
1784
1784
newDynamicSizes.emplace_back (affineApp);
1785
1785
}
1786
1786
newDimIdx++;
1787
1787
}
1788
1788
}
1789
1789
1790
- // TODO: Currently works for static memrefs with a single layout map.
1791
1790
template <typename AllocLikeOp>
1792
- LogicalResult mlir::affine::normalizeMemRef (AllocLikeOp * allocOp) {
1793
- MemRefType memrefType = allocOp-> getType ();
1794
- OpBuilder b (* allocOp);
1791
+ LogicalResult mlir::affine::normalizeMemRef (AllocLikeOp allocOp) {
1792
+ MemRefType memrefType = allocOp. getType ();
1793
+ OpBuilder b (allocOp);
1795
1794
1796
1795
// Fetch a new memref type after normalizing the old memref to have an
1797
1796
// identity map layout.
@@ -1801,27 +1800,27 @@ LogicalResult mlir::affine::normalizeMemRef(AllocLikeOp *allocOp) {
1801
1800
// transformed to an identity map.
1802
1801
return failure ();
1803
1802
1804
- Value oldMemRef = allocOp-> getResult ();
1803
+ Value oldMemRef = allocOp. getResult ();
1805
1804
1806
- SmallVector<Value, 4 > symbolOperands (allocOp-> getSymbolOperands ());
1805
+ SmallVector<Value, 4 > symbolOperands (allocOp. getSymbolOperands ());
1807
1806
AffineMap layoutMap = memrefType.getLayout ().getAffineMap ();
1808
1807
AllocLikeOp newAlloc;
1809
1808
// Check if `layoutMap` is a tiled layout. Only single layout map is
1810
1809
// supported for normalizing dynamic memrefs.
1811
1810
SmallVector<std::tuple<AffineExpr, unsigned , unsigned >> tileSizePos;
1812
1811
(void )getTileSizePos (layoutMap, tileSizePos);
1813
1812
if (newMemRefType.getNumDynamicDims () > 0 && !tileSizePos.empty ()) {
1814
- MemRefType oldMemRefType = cast<MemRefType>(oldMemRef.getType ());
1813
+ auto oldMemRefType = cast<MemRefType>(oldMemRef.getType ());
1815
1814
SmallVector<Value, 4 > newDynamicSizes;
1816
1815
createNewDynamicSizes (oldMemRefType, newMemRefType, layoutMap, allocOp, b,
1817
1816
newDynamicSizes);
1818
1817
// Add the new dynamic sizes in new AllocOp.
1819
1818
newAlloc =
1820
- b.create <AllocLikeOp>(allocOp-> getLoc (), newMemRefType, newDynamicSizes,
1821
- allocOp-> getAlignmentAttr ());
1819
+ b.create <AllocLikeOp>(allocOp. getLoc (), newMemRefType, newDynamicSizes,
1820
+ allocOp. getAlignmentAttr ());
1822
1821
} else {
1823
- newAlloc = b.create <AllocLikeOp>(allocOp-> getLoc (), newMemRefType,
1824
- allocOp-> getAlignmentAttr ());
1822
+ newAlloc = b.create <AllocLikeOp>(allocOp. getLoc (), newMemRefType,
1823
+ allocOp. getAlignmentAttr ());
1825
1824
}
1826
1825
// Replace all uses of the old memref.
1827
1826
if (failed (replaceAllMemRefUsesWith (oldMemRef, /* newMemRef=*/ newAlloc,
@@ -1842,14 +1841,14 @@ LogicalResult mlir::affine::normalizeMemRef(AllocLikeOp *allocOp) {
1842
1841
return hasSingleEffect<MemoryEffects::Free>(op, oldMemRef);
1843
1842
}));
1844
1843
oldMemRef.replaceAllUsesWith (newAlloc);
1845
- allocOp-> erase ();
1844
+ allocOp. erase ();
1846
1845
return success ();
1847
1846
}
1848
1847
1849
1848
template LogicalResult
1850
- mlir::affine::normalizeMemRef<memref::AllocaOp>(memref::AllocaOp * op);
1849
+ mlir::affine::normalizeMemRef<memref::AllocaOp>(memref::AllocaOp op);
1851
1850
template LogicalResult
1852
- mlir::affine::normalizeMemRef<memref::AllocOp>(memref::AllocOp * op);
1851
+ mlir::affine::normalizeMemRef<memref::AllocOp>(memref::AllocOp op);
1853
1852
1854
1853
MemRefType mlir::affine::normalizeMemRefType (MemRefType memrefType) {
1855
1854
unsigned rank = memrefType.getRank ();
0 commit comments