summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/lib/Transforms')
-rw-r--r--mlir/lib/Transforms/CSE.cpp4
-rw-r--r--mlir/lib/Transforms/ComposeAffineMaps.cpp8
-rw-r--r--mlir/lib/Transforms/ConvertToCFG.cpp38
-rw-r--r--mlir/lib/Transforms/DmaGeneration.cpp4
-rw-r--r--mlir/lib/Transforms/LoopFusion.cpp2
-rw-r--r--mlir/lib/Transforms/LoopTiling.cpp17
-rw-r--r--mlir/lib/Transforms/LoopUnroll.cpp6
-rw-r--r--mlir/lib/Transforms/LoopUnrollAndJam.cpp8
-rw-r--r--mlir/lib/Transforms/LowerAffineApply.cpp2
-rw-r--r--mlir/lib/Transforms/LowerVectorTransfers.cpp2
-rw-r--r--mlir/lib/Transforms/PipelineDataTransfer.cpp2
-rw-r--r--mlir/lib/Transforms/Utils/LoopUtils.cpp14
-rw-r--r--mlir/lib/Transforms/ViewFunctionGraph.cpp10
13 files changed, 59 insertions, 58 deletions
diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp
index 04f7cfdc3e9..a5b45ba4098 100644
--- a/mlir/lib/Transforms/CSE.cpp
+++ b/mlir/lib/Transforms/CSE.cpp
@@ -182,7 +182,7 @@ struct CFGCSE : public CSEImpl {
// Check to see if we need to process this node.
if (!currentNode->processed) {
currentNode->processed = true;
- simplifyBasicBlock(currentNode->node->getBlock());
+ simplifyBlock(currentNode->node->getBlock());
// Otherwise, check to see if we need to process a child node.
} else if (currentNode->childIterator != currentNode->node->end()) {
auto *childNode = *(currentNode->childIterator++);
@@ -199,7 +199,7 @@ struct CFGCSE : public CSEImpl {
eraseDeadOperations();
}
- void simplifyBasicBlock(BasicBlock *bb) {
+ void simplifyBlock(Block *bb) {
for (auto &i : *bb)
if (auto *opInst = dyn_cast<OperationInst>(&i))
simplifyOperation(opInst);
diff --git a/mlir/lib/Transforms/ComposeAffineMaps.cpp b/mlir/lib/Transforms/ComposeAffineMaps.cpp
index 8c69fa61578..c97b83f8485 100644
--- a/mlir/lib/Transforms/ComposeAffineMaps.cpp
+++ b/mlir/lib/Transforms/ComposeAffineMaps.cpp
@@ -45,8 +45,8 @@ struct ComposeAffineMaps : public FunctionPass, StmtWalker<ComposeAffineMaps> {
std::vector<OperationInst *> affineApplyOpsToErase;
explicit ComposeAffineMaps() : FunctionPass(&ComposeAffineMaps::passID) {}
- using StmtListType = llvm::iplist<Statement>;
- void walk(StmtListType::iterator Start, StmtListType::iterator End);
+ using InstListType = llvm::iplist<Statement>;
+ void walk(InstListType::iterator Start, InstListType::iterator End);
void visitOperationInst(OperationInst *stmt);
PassResult runOnMLFunction(Function *f) override;
using StmtWalker<ComposeAffineMaps>::walk;
@@ -62,8 +62,8 @@ FunctionPass *mlir::createComposeAffineMapsPass() {
return new ComposeAffineMaps();
}
-void ComposeAffineMaps::walk(StmtListType::iterator Start,
- StmtListType::iterator End) {
+void ComposeAffineMaps::walk(InstListType::iterator Start,
+ InstListType::iterator End) {
while (Start != End) {
walk(&(*Start));
// Increment iterator after walk as visit function can mutate stmt list
diff --git a/mlir/lib/Transforms/ConvertToCFG.cpp b/mlir/lib/Transforms/ConvertToCFG.cpp
index 270a25dd339..821f35ca539 100644
--- a/mlir/lib/Transforms/ConvertToCFG.cpp
+++ b/mlir/lib/Transforms/ConvertToCFG.cpp
@@ -50,7 +50,7 @@ public:
private:
Value *getConstantIndexValue(int64_t value);
- void visitStmtBlock(StmtBlock *stmtBlock);
+ void visitBlock(Block *Block);
Value *buildMinMaxReductionSeq(
Location loc, CmpIPredicate predicate,
llvm::iterator_range<OperationInst::result_iterator> values);
@@ -117,8 +117,8 @@ Value *FunctionConverter::getConstantIndexValue(int64_t value) {
}
// Visit all statements in the given statement block.
-void FunctionConverter::visitStmtBlock(StmtBlock *stmtBlock) {
- for (auto &stmt : *stmtBlock)
+void FunctionConverter::visitBlock(Block *Block) {
+ for (auto &stmt : *Block)
this->visit(&stmt);
}
@@ -214,13 +214,13 @@ Value *FunctionConverter::buildMinMaxReductionSeq(
void FunctionConverter::visitForStmt(ForStmt *forStmt) {
// First, store the loop insertion location so that we can go back to it after
// creating the new blocks (block creation updates the insertion point).
- BasicBlock *loopInsertionPoint = builder.getInsertionBlock();
+ Block *loopInsertionPoint = builder.getInsertionBlock();
// Create blocks so that they appear in more human-readable order in the
// output.
- BasicBlock *loopInitBlock = builder.createBlock();
- BasicBlock *loopConditionBlock = builder.createBlock();
- BasicBlock *loopBodyFirstBlock = builder.createBlock();
+ Block *loopInitBlock = builder.createBlock();
+ Block *loopConditionBlock = builder.createBlock();
+ Block *loopBodyFirstBlock = builder.createBlock();
// At the loop insertion location, branch immediately to the loop init block.
builder.setInsertionPointToEnd(loopInsertionPoint);
@@ -238,7 +238,7 @@ void FunctionConverter::visitForStmt(ForStmt *forStmt) {
// Walking manually because we need custom logic before and after traversing
// the list of children.
builder.setInsertionPointToEnd(loopBodyFirstBlock);
- visitStmtBlock(forStmt->getBody());
+ visitBlock(forStmt->getBody());
// Builder point is currently at the last block of the loop body. Append the
// induction variable stepping to this block and branch back to the exit
@@ -254,7 +254,7 @@ void FunctionConverter::visitForStmt(ForStmt *forStmt) {
nextIvValue);
// Create post-loop block here so that it appears after all loop body blocks.
- BasicBlock *postLoopBlock = builder.createBlock();
+ Block *postLoopBlock = builder.createBlock();
builder.setInsertionPointToEnd(loopInitBlock);
// Compute loop bounds using affine_apply after remapping its operands.
@@ -378,15 +378,15 @@ void FunctionConverter::visitIfStmt(IfStmt *ifStmt) {
// the false branch as soon as one condition fails. `cond_br` requires
// another block as a target when the condition is true, and that block will
// contain the next condition.
- BasicBlock *ifInsertionBlock = builder.getInsertionBlock();
- SmallVector<BasicBlock *, 4> ifConditionExtraBlocks;
+ Block *ifInsertionBlock = builder.getInsertionBlock();
+ SmallVector<Block *, 4> ifConditionExtraBlocks;
unsigned numConstraints = integerSet.getNumConstraints();
ifConditionExtraBlocks.reserve(numConstraints - 1);
for (unsigned i = 0, e = numConstraints - 1; i < e; ++i) {
ifConditionExtraBlocks.push_back(builder.createBlock());
}
- BasicBlock *thenBlock = builder.createBlock();
- BasicBlock *elseBlock = builder.createBlock();
+ Block *thenBlock = builder.createBlock();
+ Block *elseBlock = builder.createBlock();
builder.setInsertionPointToEnd(ifInsertionBlock);
// Implement short-circuit logic. For each affine expression in the 'if'
@@ -405,7 +405,7 @@ void FunctionConverter::visitIfStmt(IfStmt *ifStmt) {
ifConditionExtraBlocks)) {
AffineExpr constraintExpr = std::get<0>(tuple);
bool isEquality = std::get<1>(tuple);
- BasicBlock *nextBlock = std::get<2>(tuple);
+ Block *nextBlock = std::get<2>(tuple);
// Build and apply an affine map.
auto affineMap =
@@ -429,19 +429,19 @@ void FunctionConverter::visitIfStmt(IfStmt *ifStmt) {
// Recursively traverse the 'then' block.
builder.setInsertionPointToEnd(thenBlock);
- visitStmtBlock(ifStmt->getThen());
- BasicBlock *lastThenBlock = builder.getInsertionBlock();
+ visitBlock(ifStmt->getThen());
+ Block *lastThenBlock = builder.getInsertionBlock();
// Recursively traverse the 'else' block if present.
builder.setInsertionPointToEnd(elseBlock);
if (ifStmt->hasElse())
- visitStmtBlock(ifStmt->getElse());
- BasicBlock *lastElseBlock = builder.getInsertionBlock();
+ visitBlock(ifStmt->getElse());
+ Block *lastElseBlock = builder.getInsertionBlock();
// Create the continuation block here so that it appears lexically after the
// 'then' and 'else' blocks, branch from end of 'then' and 'else' SESE regions
// to the continuation block.
- BasicBlock *continuationBlock = builder.createBlock();
+ Block *continuationBlock = builder.createBlock();
builder.setInsertionPointToEnd(lastThenBlock);
builder.create<BranchOp>(ifStmt->getLoc(), continuationBlock);
builder.setInsertionPointToEnd(lastElseBlock);
diff --git a/mlir/lib/Transforms/DmaGeneration.cpp b/mlir/lib/Transforms/DmaGeneration.cpp
index 925c50abfec..69344819ed8 100644
--- a/mlir/lib/Transforms/DmaGeneration.cpp
+++ b/mlir/lib/Transforms/DmaGeneration.cpp
@@ -176,7 +176,7 @@ bool DmaGeneration::generateDma(const MemRefRegion &region, ForStmt *forStmt,
FuncBuilder prologue(forStmt);
// DMAs for write regions are going to be inserted just after the for loop.
FuncBuilder epilogue(forStmt->getBlock(),
- std::next(StmtBlock::iterator(forStmt)));
+ std::next(Block::iterator(forStmt)));
FuncBuilder *b = region.isWrite() ? &epilogue : &prologue;
// Builder to create constants at the top level.
@@ -382,7 +382,7 @@ static unsigned getNestingDepth(const Statement &stmt) {
return depth;
}
-// TODO(bondhugula): make this run on a StmtBlock instead of a 'for' stmt.
+// TODO(bondhugula): make this run on a Block instead of a 'for' stmt.
void DmaGeneration::runOnForStmt(ForStmt *forStmt) {
// For now (for testing purposes), we'll run this on the outermost among 'for'
// stmt's with unit stride, i.e., right at the top of the tile if tiling has
diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp
index 2ddd613d6af..d31337437ad 100644
--- a/mlir/lib/Transforms/LoopFusion.cpp
+++ b/mlir/lib/Transforms/LoopFusion.cpp
@@ -343,7 +343,7 @@ public:
// Intializes the data dependence graph by walking statements in 'f'.
// Assigns each node in the graph a node id based on program order in 'f'.
-// TODO(andydavis) Add support for taking a StmtBlock arg to construct the
+// TODO(andydavis) Add support for taking a Block arg to construct the
// dependence graph at a different depth.
bool MemRefDependenceGraph::init(Function *f) {
unsigned id = 0;
diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp
index d6c1eed3a0c..109953f2296 100644
--- a/mlir/lib/Transforms/LoopTiling.cpp
+++ b/mlir/lib/Transforms/LoopTiling.cpp
@@ -58,8 +58,9 @@ FunctionPass *mlir::createLoopTilingPass() { return new LoopTiling(); }
// Move the loop body of ForStmt 'src' from 'src' into the specified location in
// destination's body.
static inline void moveLoopBody(ForStmt *src, ForStmt *dest,
- StmtBlock::iterator loc) {
- dest->getBody()->getStatements().splice(loc, src->getBody()->getStatements());
+ Block::iterator loc) {
+ dest->getBody()->getInstructions().splice(loc,
+ src->getBody()->getInstructions());
}
// Move the loop body of ForStmt 'src' from 'src' to the start of dest's body.
@@ -164,8 +165,8 @@ UtilResult mlir::tileCodeGen(ArrayRef<ForStmt *> band,
FuncBuilder b(topLoop);
// Loop bounds will be set later.
auto *pointLoop = b.createFor(loc, 0, 0);
- pointLoop->getBody()->getStatements().splice(
- pointLoop->getBody()->begin(), topLoop->getBlock()->getStatements(),
+ pointLoop->getBody()->getInstructions().splice(
+ pointLoop->getBody()->begin(), topLoop->getBlock()->getInstructions(),
topLoop);
newLoops[2 * width - 1 - i] = pointLoop;
topLoop = pointLoop;
@@ -178,9 +179,9 @@ UtilResult mlir::tileCodeGen(ArrayRef<ForStmt *> band,
FuncBuilder b(topLoop);
// Loop bounds will be set later.
auto *tileSpaceLoop = b.createFor(loc, 0, 0);
- tileSpaceLoop->getBody()->getStatements().splice(
- tileSpaceLoop->getBody()->begin(), topLoop->getBlock()->getStatements(),
- topLoop);
+ tileSpaceLoop->getBody()->getInstructions().splice(
+ tileSpaceLoop->getBody()->begin(),
+ topLoop->getBlock()->getInstructions(), topLoop);
newLoops[2 * width - i - 1] = tileSpaceLoop;
topLoop = tileSpaceLoop;
}
@@ -222,7 +223,7 @@ static void getTileableBands(Function *f,
ForStmt *currStmt = root;
do {
band.push_back(currStmt);
- } while (currStmt->getBody()->getStatements().size() == 1 &&
+ } while (currStmt->getBody()->getInstructions().size() == 1 &&
(currStmt = dyn_cast<ForStmt>(&*currStmt->getBody()->begin())));
bands->push_back(band);
};
diff --git a/mlir/lib/Transforms/LoopUnroll.cpp b/mlir/lib/Transforms/LoopUnroll.cpp
index c3651e53593..15ea0f841cc 100644
--- a/mlir/lib/Transforms/LoopUnroll.cpp
+++ b/mlir/lib/Transforms/LoopUnroll.cpp
@@ -91,9 +91,9 @@ PassResult LoopUnroll::runOnMLFunction(Function *f) {
std::vector<ForStmt *> loops;
// This method specialized to encode custom return logic.
- using StmtListType = llvm::iplist<Statement>;
- bool walkPostOrder(StmtListType::iterator Start,
- StmtListType::iterator End) {
+ using InstListType = llvm::iplist<Statement>;
+ bool walkPostOrder(InstListType::iterator Start,
+ InstListType::iterator End) {
bool hasInnerLoops = false;
// We need to walk all elements since all innermost loops need to be
// gathered as opposed to determining whether this list has any inner
diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp
index 7ed9be19644..60e8d154f98 100644
--- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp
+++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp
@@ -130,13 +130,13 @@ bool mlir::loopUnrollJamByFactor(ForStmt *forStmt, uint64_t unrollJamFactor) {
// tree).
class JamBlockGatherer : public StmtWalker<JamBlockGatherer> {
public:
- using StmtListType = llvm::iplist<Statement>;
+ using InstListType = llvm::iplist<Statement>;
// Store iterators to the first and last stmt of each sub-block found.
- std::vector<std::pair<StmtBlock::iterator, StmtBlock::iterator>> subBlocks;
+ std::vector<std::pair<Block::iterator, Block::iterator>> subBlocks;
// This is a linear time walk.
- void walk(StmtListType::iterator Start, StmtListType::iterator End) {
+ void walk(InstListType::iterator Start, InstListType::iterator End) {
for (auto it = Start; it != End;) {
auto subBlockStart = it;
while (it != End && !isa<ForStmt>(it))
@@ -194,7 +194,7 @@ bool mlir::loopUnrollJamByFactor(ForStmt *forStmt, uint64_t unrollJamFactor) {
DenseMap<const Value *, Value *> operandMap;
// Insert the cleanup loop right after 'forStmt'.
FuncBuilder builder(forStmt->getBlock(),
- std::next(StmtBlock::iterator(forStmt)));
+ std::next(Block::iterator(forStmt)));
auto *cleanupForStmt = cast<ForStmt>(builder.clone(*forStmt, operandMap));
cleanupForStmt->setLowerBoundMap(
getCleanupLoopLowerBound(*forStmt, unrollJamFactor, &builder));
diff --git a/mlir/lib/Transforms/LowerAffineApply.cpp b/mlir/lib/Transforms/LowerAffineApply.cpp
index 52146fdb5b7..747733de41e 100644
--- a/mlir/lib/Transforms/LowerAffineApply.cpp
+++ b/mlir/lib/Transforms/LowerAffineApply.cpp
@@ -52,7 +52,7 @@ PassResult LowerAffineApply::runOnMLFunction(Function *f) {
}
PassResult LowerAffineApply::runOnCFGFunction(Function *f) {
- for (BasicBlock &bb : *f) {
+ for (Block &bb : *f) {
// Handle iterators with care because we erase in the same loop.
// In particular, step to the next element before erasing the current one.
for (auto it = bb.begin(); it != bb.end();) {
diff --git a/mlir/lib/Transforms/LowerVectorTransfers.cpp b/mlir/lib/Transforms/LowerVectorTransfers.cpp
index 4d24191dcb2..51577009abb 100644
--- a/mlir/lib/Transforms/LowerVectorTransfers.cpp
+++ b/mlir/lib/Transforms/LowerVectorTransfers.cpp
@@ -110,7 +110,7 @@ static void rewriteAsLoops(VectorTransferOpTy *transfer,
// Get the ML function builder.
// We need access to the Function builder stored internally in the
// MLFunctionLoweringRewriter general rewriting API does not provide
- // ML-specific functions (ForStmt and StmtBlock manipulation). While we could
+ // ML-specific functions (ForStmt and Block manipulation). While we could
// forward them or define a whole rewriting chain based on MLFunctionBuilder
// instead of Builer, the code for it would be duplicate boilerplate. As we
// go towards unifying ML and CFG functions, this separation will disappear.
diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp
index a0964a67fa6..c8a6ced4ed1 100644
--- a/mlir/lib/Transforms/PipelineDataTransfer.cpp
+++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp
@@ -345,7 +345,7 @@ PassResult PipelineDataTransfer::runOnForStmt(ForStmt *forStmt) {
}
// Get shifts stored in map.
- std::vector<uint64_t> shifts(forStmt->getBody()->getStatements().size());
+ std::vector<uint64_t> shifts(forStmt->getBody()->getInstructions().size());
unsigned s = 0;
for (auto &stmt : *forStmt->getBody()) {
assert(stmtShiftMap.find(&stmt) != stmtShiftMap.end());
diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp
index 7def4fe2f09..03b4bb29e19 100644
--- a/mlir/lib/Transforms/Utils/LoopUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp
@@ -108,7 +108,7 @@ bool mlir::promoteIfSingleIteration(ForStmt *forStmt) {
} else {
const AffineBound lb = forStmt->getLowerBound();
SmallVector<Value *, 4> lbOperands(lb.operand_begin(), lb.operand_end());
- FuncBuilder builder(forStmt->getBlock(), StmtBlock::iterator(forStmt));
+ FuncBuilder builder(forStmt->getBlock(), Block::iterator(forStmt));
auto affineApplyOp = builder.create<AffineApplyOp>(
forStmt->getLoc(), lb.getMap(), lbOperands);
forStmt->replaceAllUsesWith(affineApplyOp->getResult(0));
@@ -116,14 +116,14 @@ bool mlir::promoteIfSingleIteration(ForStmt *forStmt) {
}
// Move the loop body statements to the loop's containing block.
auto *block = forStmt->getBlock();
- block->getStatements().splice(StmtBlock::iterator(forStmt),
- forStmt->getBody()->getStatements());
+ block->getInstructions().splice(Block::iterator(forStmt),
+ forStmt->getBody()->getInstructions());
forStmt->erase();
return true;
}
/// Promotes all single iteration for stmt's in the Function, i.e., moves
-/// their body into the containing StmtBlock.
+/// their body into the containing Block.
void mlir::promoteSingleIterationLoops(Function *f) {
// Gathers all innermost loops through a post order pruned walk.
class LoopBodyPromoter : public StmtWalker<LoopBodyPromoter> {
@@ -223,7 +223,7 @@ UtilResult mlir::stmtBodySkew(ForStmt *forStmt, ArrayRef<uint64_t> shifts,
int64_t step = forStmt->getStep();
- unsigned numChildStmts = forStmt->getBody()->getStatements().size();
+ unsigned numChildStmts = forStmt->getBody()->getInstructions().size();
// Do a linear time (counting) sort for the shifts.
uint64_t maxShift = 0;
@@ -379,7 +379,7 @@ bool mlir::loopUnrollByFactor(ForStmt *forStmt, uint64_t unrollFactor) {
// Generate the cleanup loop if trip count isn't a multiple of unrollFactor.
if (getLargestDivisorOfTripCount(*forStmt) % unrollFactor != 0) {
DenseMap<const Value *, Value *> operandMap;
- FuncBuilder builder(forStmt->getBlock(), ++StmtBlock::iterator(forStmt));
+ FuncBuilder builder(forStmt->getBlock(), ++Block::iterator(forStmt));
auto *cleanupForStmt = cast<ForStmt>(builder.clone(*forStmt, operandMap));
auto clLbMap = getCleanupLoopLowerBound(*forStmt, unrollFactor, &builder);
assert(clLbMap &&
@@ -408,7 +408,7 @@ bool mlir::loopUnrollByFactor(ForStmt *forStmt, uint64_t unrollFactor) {
// Keep a pointer to the last statement in the original block so that we know
// what to clone (since we are doing this in-place).
- StmtBlock::iterator srcBlockEnd = std::prev(forStmt->getBody()->end());
+ Block::iterator srcBlockEnd = std::prev(forStmt->getBody()->end());
// Unroll the contents of 'forStmt' (append unrollFactor-1 additional copies).
for (unsigned i = 1; i < unrollFactor; i++) {
diff --git a/mlir/lib/Transforms/ViewFunctionGraph.cpp b/mlir/lib/Transforms/ViewFunctionGraph.cpp
index 2ce8af3613a..50a3cf5a595 100644
--- a/mlir/lib/Transforms/ViewFunctionGraph.cpp
+++ b/mlir/lib/Transforms/ViewFunctionGraph.cpp
@@ -28,16 +28,16 @@ template <>
struct llvm::DOTGraphTraits<const Function *> : public DefaultDOTGraphTraits {
using DefaultDOTGraphTraits::DefaultDOTGraphTraits;
- static std::string getNodeLabel(const BasicBlock *basicBlock,
- const Function *);
+ static std::string getNodeLabel(const Block *Block, const Function *);
};
-std::string llvm::DOTGraphTraits<const Function *>::getNodeLabel(
- const BasicBlock *basicBlock, const Function *) {
+std::string
+llvm::DOTGraphTraits<const Function *>::getNodeLabel(const Block *Block,
+ const Function *) {
// Reuse the print output for the node labels.
std::string outStreamStr;
raw_string_ostream os(outStreamStr);
- basicBlock->print(os);
+ Block->print(os);
std::string &outStr = os.str();
if (outStr[0] == '\n')
OpenPOWER on IntegriCloud