summaryrefslogtreecommitdiffstats
path: root/mlir/lib
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/lib')
-rw-r--r--mlir/lib/AffineOps/AffineOps.cpp9
-rw-r--r--mlir/lib/Analysis/MemRefDependenceCheck.cpp2
-rw-r--r--mlir/lib/EDSC/LowerEDSCTestPass.cpp2
-rw-r--r--mlir/lib/IR/AsmPrinter.cpp2
-rw-r--r--mlir/lib/IR/Block.cpp34
-rw-r--r--mlir/lib/IR/Function.cpp32
-rw-r--r--mlir/lib/Transforms/ComposeAffineMaps.cpp4
-rw-r--r--mlir/lib/Transforms/ConstantFold.cpp4
-rw-r--r--mlir/lib/Transforms/LoopFusion.cpp4
-rw-r--r--mlir/lib/Transforms/LoopUnroll.cpp4
-rw-r--r--mlir/lib/Transforms/LoopUnrollAndJam.cpp2
-rw-r--r--mlir/lib/Transforms/LowerAffine.cpp2
-rw-r--r--mlir/lib/Transforms/MemRefDataFlowOpt.cpp4
-rw-r--r--mlir/lib/Transforms/PipelineDataTransfer.cpp2
-rw-r--r--mlir/lib/Transforms/SimplifyAffineStructures.cpp2
-rw-r--r--mlir/lib/Transforms/StripDebugInfo.cpp2
-rw-r--r--mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp2
-rw-r--r--mlir/lib/Transforms/Utils/LoopUtils.cpp2
-rw-r--r--mlir/lib/Transforms/Utils/Utils.cpp4
19 files changed, 44 insertions, 75 deletions
diff --git a/mlir/lib/AffineOps/AffineOps.cpp b/mlir/lib/AffineOps/AffineOps.cpp
index 682a8e4f1ed..2e657cf7e17 100644
--- a/mlir/lib/AffineOps/AffineOps.cpp
+++ b/mlir/lib/AffineOps/AffineOps.cpp
@@ -410,27 +410,26 @@ bool AffineForOp::matchingBoundOperandList() const {
return true;
}
-void AffineForOp::walkOps(std::function<void(Instruction *)> callback) {
+void AffineForOp::walk(std::function<void(Instruction *)> callback) {
struct Walker : public InstWalker<Walker> {
std::function<void(Instruction *)> const &callback;
Walker(std::function<void(Instruction *)> const &callback)
: callback(callback) {}
- void visitOperationInst(Instruction *opInst) { callback(opInst); }
+ void visitInstruction(Instruction *opInst) { callback(opInst); }
};
Walker w(callback);
w.walk(getInstruction());
}
-void AffineForOp::walkOpsPostOrder(
- std::function<void(Instruction *)> callback) {
+void AffineForOp::walkPostOrder(std::function<void(Instruction *)> callback) {
struct Walker : public InstWalker<Walker> {
std::function<void(Instruction *)> const &callback;
Walker(std::function<void(Instruction *)> const &callback)
: callback(callback) {}
- void visitOperationInst(Instruction *opInst) { callback(opInst); }
+ void visitInstruction(Instruction *opInst) { callback(opInst); }
};
Walker v(callback);
diff --git a/mlir/lib/Analysis/MemRefDependenceCheck.cpp b/mlir/lib/Analysis/MemRefDependenceCheck.cpp
index b2549910a17..6ea47a20f60 100644
--- a/mlir/lib/Analysis/MemRefDependenceCheck.cpp
+++ b/mlir/lib/Analysis/MemRefDependenceCheck.cpp
@@ -46,7 +46,7 @@ struct MemRefDependenceCheck : public FunctionPass,
PassResult runOnFunction(Function *f) override;
- void visitOperationInst(Instruction *opInst) {
+ void visitInstruction(Instruction *opInst) {
if (opInst->isa<LoadOp>() || opInst->isa<StoreOp>()) {
loadsAndStores.push_back(opInst);
}
diff --git a/mlir/lib/EDSC/LowerEDSCTestPass.cpp b/mlir/lib/EDSC/LowerEDSCTestPass.cpp
index e891be68fd3..1be6b90985f 100644
--- a/mlir/lib/EDSC/LowerEDSCTestPass.cpp
+++ b/mlir/lib/EDSC/LowerEDSCTestPass.cpp
@@ -45,7 +45,7 @@ char LowerEDSCTestPass::passID = 0;
#include "mlir/EDSC/reference-impl.inc"
PassResult LowerEDSCTestPass::runOnFunction(Function *f) {
- f->walkOps([](OperationInst *op) {
+ f->walk([](OperationInst *op) {
if (op->getName().getStringRef() == "print") {
auto opName = op->getAttrOfType<StringAttr>("op");
if (!opName) {
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 36a4b8e3b5e..7b59321c815 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -263,7 +263,7 @@ void ModuleState::initialize(const Module *module) {
for (auto &fn : *module) {
visitType(fn.getType());
- const_cast<Function &>(fn).walkInsts(
+ const_cast<Function &>(fn).walk(
[&](Instruction *op) { ModuleState::visitInstruction(op); });
}
diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp
index 698494144ce..0e1d21ffed8 100644
--- a/mlir/lib/IR/Block.cpp
+++ b/mlir/lib/IR/Block.cpp
@@ -256,31 +256,31 @@ Block *Block::splitBlock(iterator splitBefore) {
return newBB;
}
-void Block::walk(std::function<void(OperationInst *)> callback) {
+void Block::walk(std::function<void(Instruction *)> callback) {
walk(begin(), end(), callback);
}
void Block::walk(Block::iterator begin, Block::iterator end,
- std::function<void(OperationInst *)> callback) {
+ std::function<void(Instruction *)> callback) {
struct Walker : public InstWalker<Walker> {
- std::function<void(OperationInst *)> const &callback;
- Walker(std::function<void(OperationInst *)> const &callback)
+ std::function<void(Instruction *)> const &callback;
+ Walker(std::function<void(Instruction *)> const &callback)
: callback(callback) {}
- void visitOperationInst(OperationInst *opInst) { callback(opInst); }
+ void visitInstruction(Instruction *opInst) { callback(opInst); }
};
Walker w(callback);
w.walk(begin, end);
}
-void Block::walkPostOrder(std::function<void(OperationInst *)> callback) {
+void Block::walkPostOrder(std::function<void(Instruction *)> callback) {
struct Walker : public InstWalker<Walker> {
- std::function<void(OperationInst *)> const &callback;
- Walker(std::function<void(OperationInst *)> const &callback)
+ std::function<void(Instruction *)> const &callback;
+ Walker(std::function<void(Instruction *)> const &callback)
: callback(callback) {}
- void visitOperationInst(OperationInst *opInst) { callback(opInst); }
+ void visitInstruction(Instruction *opInst) { callback(opInst); }
};
Walker v(callback);
@@ -338,19 +338,15 @@ void BlockList::cloneInto(BlockList *dest, BlockAndValueMapping &mapper,
BlockAndValueMapping &mapper;
Walker(BlockAndValueMapping &mapper) : mapper(mapper) {}
- /// Remap the instruction operands.
- void visitInstruction(Instruction *inst) {
+ /// Remap the instruction and successor block operands.
+ void visitInstruction(OperationInst *inst) {
for (auto &instOp : inst->getInstOperands())
if (auto *mappedOp = mapper.lookupOrNull(instOp.get()))
instOp.set(mappedOp);
- }
- // Remap the successor block operands.
- void visitOperationInst(OperationInst *opInst) {
- if (!opInst->isTerminator())
- return;
- for (auto &succOp : opInst->getBlockOperands())
- if (auto *mappedOp = mapper.lookupOrNull(succOp.get()))
- succOp.set(mappedOp);
+ if (inst->isTerminator())
+ for (auto &succOp : inst->getBlockOperands())
+ if (auto *mappedOp = mapper.lookupOrNull(succOp.get()))
+ succOp.set(mappedOp);
}
};
diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp
index 35ac5459ad6..3a263fb13f9 100644
--- a/mlir/lib/IR/Function.cpp
+++ b/mlir/lib/IR/Function.cpp
@@ -214,7 +214,7 @@ void Function::addEntryBlock() {
entry->addArguments(type.getInputs());
}
-void Function::walkInsts(std::function<void(Instruction *)> callback) {
+void Function::walk(std::function<void(Instruction *)> callback) {
struct Walker : public InstWalker<Walker> {
std::function<void(Instruction *)> const &callback;
Walker(std::function<void(Instruction *)> const &callback)
@@ -227,39 +227,13 @@ void Function::walkInsts(std::function<void(Instruction *)> callback) {
v.walk(this);
}
-void Function::walkOps(std::function<void(OperationInst *)> callback) {
- struct Walker : public InstWalker<Walker> {
- std::function<void(OperationInst *)> const &callback;
- Walker(std::function<void(OperationInst *)> const &callback)
- : callback(callback) {}
-
- void visitOperationInst(OperationInst *opInst) { callback(opInst); }
- };
-
- Walker v(callback);
- v.walk(this);
-}
-
-void Function::walkInstsPostOrder(std::function<void(Instruction *)> callback) {
+void Function::walkPostOrder(std::function<void(Instruction *)> callback) {
struct Walker : public InstWalker<Walker> {
std::function<void(Instruction *)> const &callback;
Walker(std::function<void(Instruction *)> const &callback)
: callback(callback) {}
- void visitOperationInst(Instruction *inst) { callback(inst); }
- };
-
- Walker v(callback);
- v.walkPostOrder(this);
-}
-
-void Function::walkOpsPostOrder(std::function<void(OperationInst *)> callback) {
- struct Walker : public InstWalker<Walker> {
- std::function<void(OperationInst *)> const &callback;
- Walker(std::function<void(OperationInst *)> const &callback)
- : callback(callback) {}
-
- void visitOperationInst(OperationInst *opInst) { callback(opInst); }
+ void visitInstruction(Instruction *inst) { callback(inst); }
};
Walker v(callback);
diff --git a/mlir/lib/Transforms/ComposeAffineMaps.cpp b/mlir/lib/Transforms/ComposeAffineMaps.cpp
index d7327d997c2..4f960ea73af 100644
--- a/mlir/lib/Transforms/ComposeAffineMaps.cpp
+++ b/mlir/lib/Transforms/ComposeAffineMaps.cpp
@@ -48,7 +48,7 @@ namespace {
struct ComposeAffineMaps : public FunctionPass, InstWalker<ComposeAffineMaps> {
explicit ComposeAffineMaps() : FunctionPass(&ComposeAffineMaps::passID) {}
PassResult runOnFunction(Function *f) override;
- void visitOperationInst(OperationInst *opInst);
+ void visitInstruction(OperationInst *opInst);
SmallVector<OpPointer<AffineApplyOp>, 8> affineApplyOps;
@@ -68,7 +68,7 @@ static bool affineApplyOp(const Instruction &inst) {
return opInst.isa<AffineApplyOp>();
}
-void ComposeAffineMaps::visitOperationInst(OperationInst *opInst) {
+void ComposeAffineMaps::visitInstruction(OperationInst *opInst) {
if (auto afOp = opInst->dyn_cast<AffineApplyOp>()) {
affineApplyOps.push_back(afOp);
}
diff --git a/mlir/lib/Transforms/ConstantFold.cpp b/mlir/lib/Transforms/ConstantFold.cpp
index 9c20e79180a..859d0012fac 100644
--- a/mlir/lib/Transforms/ConstantFold.cpp
+++ b/mlir/lib/Transforms/ConstantFold.cpp
@@ -37,7 +37,7 @@ struct ConstantFold : public FunctionPass, InstWalker<ConstantFold> {
bool foldOperation(OperationInst *op,
SmallVectorImpl<Value *> &existingConstants);
- void visitOperationInst(OperationInst *inst);
+ void visitInstruction(OperationInst *op);
PassResult runOnFunction(Function *f) override;
static char passID;
@@ -49,7 +49,7 @@ char ConstantFold::passID = 0;
/// Attempt to fold the specified operation, updating the IR to match. If
/// constants are found, we keep track of them in the existingConstants list.
///
-void ConstantFold::visitOperationInst(OperationInst *op) {
+void ConstantFold::visitInstruction(OperationInst *op) {
// If this operation is an AffineForOp, then fold the bounds.
if (auto forOp = op->dyn_cast<AffineForOp>()) {
constantFoldBounds(forOp);
diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp
index 162e0e3b7f6..304331320ac 100644
--- a/mlir/lib/Transforms/LoopFusion.cpp
+++ b/mlir/lib/Transforms/LoopFusion.cpp
@@ -118,7 +118,7 @@ public:
SmallVector<OperationInst *, 4> storeOpInsts;
bool hasNonForRegion = false;
- void visitOperationInst(OperationInst *opInst) {
+ void visitInstruction(OperationInst *opInst) {
if (opInst->isa<AffineForOp>())
forOps.push_back(opInst->cast<AffineForOp>());
else if (opInst->getNumBlockLists() != 0)
@@ -619,7 +619,7 @@ public:
LoopNestStatsCollector(LoopNestStats *stats) : stats(stats) {}
- void visitOperationInst(OperationInst *opInst) {
+ void visitInstruction(OperationInst *opInst) {
auto forOp = opInst->dyn_cast<AffineForOp>();
if (!forOp)
return;
diff --git a/mlir/lib/Transforms/LoopUnroll.cpp b/mlir/lib/Transforms/LoopUnroll.cpp
index 86e913bd71f..9c9952d31ca 100644
--- a/mlir/lib/Transforms/LoopUnroll.cpp
+++ b/mlir/lib/Transforms/LoopUnroll.cpp
@@ -113,7 +113,7 @@ PassResult LoopUnroll::runOnFunction(Function *f) {
return hasInnerLoops;
}
- bool walkOpInstPostOrder(OperationInst *opInst) {
+ bool walkPostOrder(OperationInst *opInst) {
bool hasInnerLoops = false;
for (auto &blockList : opInst->getBlockLists())
for (auto &block : blockList)
@@ -140,7 +140,7 @@ PassResult LoopUnroll::runOnFunction(Function *f) {
const unsigned minTripCount;
ShortLoopGatherer(unsigned minTripCount) : minTripCount(minTripCount) {}
- void visitOperationInst(OperationInst *opInst) {
+ void visitInstruction(OperationInst *opInst) {
auto forOp = opInst->dyn_cast<AffineForOp>();
if (!forOp)
return;
diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp
index 7327a37ee3a..d87f9d5dc14 100644
--- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp
+++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp
@@ -196,7 +196,7 @@ bool mlir::loopUnrollJamByFactor(OpPointer<AffineForOp> forOp,
// Gather all sub-blocks to jam upon the loop being unrolled.
JamBlockGatherer jbg;
- jbg.walkOpInst(forInst);
+ jbg.walk(forInst);
auto &subBlocks = jbg.subBlocks;
// Generate the cleanup loop if trip count isn't a multiple of
diff --git a/mlir/lib/Transforms/LowerAffine.cpp b/mlir/lib/Transforms/LowerAffine.cpp
index 24ca4e95082..08c8188fada 100644
--- a/mlir/lib/Transforms/LowerAffine.cpp
+++ b/mlir/lib/Transforms/LowerAffine.cpp
@@ -615,7 +615,7 @@ PassResult LowerAffinePass::runOnFunction(Function *function) {
// Collect all the For instructions as well as AffineIfOps and AffineApplyOps.
// We do this as a prepass to avoid invalidating the walker with our rewrite.
- function->walkInsts([&](Instruction *inst) {
+ function->walk([&](Instruction *inst) {
auto op = cast<OperationInst>(inst);
if (op->isa<AffineApplyOp>() || op->isa<AffineForOp>() ||
op->isa<AffineIfOp>())
diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
index e6ce273b532..b9386c384dd 100644
--- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
+++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
@@ -75,7 +75,7 @@ struct MemRefDataFlowOpt : public FunctionPass, InstWalker<MemRefDataFlowOpt> {
PassResult runOnFunction(Function *f) override;
- void visitOperationInst(OperationInst *opInst);
+ void visitInstruction(OperationInst *opInst);
// A list of memref's that are potentially dead / could be eliminated.
SmallPtrSet<Value *, 4> memrefsToErase;
@@ -100,7 +100,7 @@ FunctionPass *mlir::createMemRefDataFlowOptPass() {
// This is a straightforward implementation not optimized for speed. Optimize
// this in the future if needed.
-void MemRefDataFlowOpt::visitOperationInst(OperationInst *opInst) {
+void MemRefDataFlowOpt::visitInstruction(OperationInst *opInst) {
OperationInst *lastWriteStoreOp = nullptr;
auto loadOp = opInst->dyn_cast<LoadOp>();
diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp
index 2e083bbfd79..8d13800160d 100644
--- a/mlir/lib/Transforms/PipelineDataTransfer.cpp
+++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp
@@ -142,7 +142,7 @@ PassResult PipelineDataTransfer::runOnFunction(Function *f) {
// deleted and replaced by a prologue, a new steady-state loop and an
// epilogue).
forOps.clear();
- f->walkOpsPostOrder([&](OperationInst *opInst) {
+ f->walkPostOrder([&](OperationInst *opInst) {
if (auto forOp = opInst->dyn_cast<AffineForOp>())
forOps.push_back(forOp);
});
diff --git a/mlir/lib/Transforms/SimplifyAffineStructures.cpp b/mlir/lib/Transforms/SimplifyAffineStructures.cpp
index 80b2de130e7..a9fcfc5bd11 100644
--- a/mlir/lib/Transforms/SimplifyAffineStructures.cpp
+++ b/mlir/lib/Transforms/SimplifyAffineStructures.cpp
@@ -64,7 +64,7 @@ static IntegerSet simplifyIntegerSet(IntegerSet set) {
}
PassResult SimplifyAffineStructures::runOnFunction(Function *f) {
- f->walkOps([&](OperationInst *opInst) {
+ f->walk([&](OperationInst *opInst) {
for (auto attr : opInst->getAttrs()) {
if (auto mapAttr = attr.second.dyn_cast<AffineMapAttr>()) {
MutableAffineMap mMap(mapAttr.getValue());
diff --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp
index 6e1d5ff2d11..c5e42b622ed 100644
--- a/mlir/lib/Transforms/StripDebugInfo.cpp
+++ b/mlir/lib/Transforms/StripDebugInfo.cpp
@@ -39,7 +39,7 @@ PassResult StripDebugInfo::runOnFunction(Function *f) {
// Strip the debug info from the function and its instructions.
f->setLoc(unknownLoc);
- f->walkInsts([&](Instruction *inst) { inst->setLoc(unknownLoc); });
+ f->walk([&](Instruction *inst) { inst->setLoc(unknownLoc); });
return success();
}
diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
index 019cbbae063..790f971bb58 100644
--- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
+++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
@@ -38,7 +38,7 @@ public:
worklist.reserve(64);
// Add all operations to the worklist.
- fn->walkOps([&](OperationInst *inst) { addToWorklist(inst); });
+ fn->walk([&](OperationInst *inst) { addToWorklist(inst); });
}
/// Perform the rewrites.
diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp
index 99079119dab..153557de04a 100644
--- a/mlir/lib/Transforms/Utils/LoopUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp
@@ -135,7 +135,7 @@ bool mlir::promoteIfSingleIteration(OpPointer<AffineForOp> forOp) {
/// their body into the containing Block.
void mlir::promoteSingleIterationLoops(Function *f) {
// Gathers all innermost loops through a post order pruned walk.
- f->walkOpsPostOrder([](OperationInst *inst) {
+ f->walkPostOrder([](OperationInst *inst) {
if (auto forOp = inst->dyn_cast<AffineForOp>())
promoteIfSingleIteration(forOp);
});
diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp
index 732062a8b97..879a4f4b585 100644
--- a/mlir/lib/Transforms/Utils/Utils.cpp
+++ b/mlir/lib/Transforms/Utils/Utils.cpp
@@ -362,8 +362,8 @@ void mlir::remapFunctionAttrs(
Function &fn, const DenseMap<Attribute, FunctionAttr> &remappingTable) {
// Look at all instructions in a Function.
- fn.walkOps(
- [&](OperationInst *inst) { remapFunctionAttrs(*inst, remappingTable); });
+ fn.walk(
+ [&](Instruction *inst) { remapFunctionAttrs(*inst, remappingTable); });
}
void mlir::remapFunctionAttrs(
OpenPOWER on IntegriCloud