diff options
| author | Chris Lattner <clattner@google.com> | 2018-12-28 08:48:09 -0800 |
|---|---|---|
| committer | jpienaar <jpienaar@google.com> | 2019-03-29 14:43:13 -0700 |
| commit | 69d9e990facf4d07c31b96e47e98cde07228f229 (patch) | |
| tree | cf76ee03ebef0e449412063a04fd773dcf9c5115 /mlir/lib/Transforms | |
| parent | f845bc4542719878d9d21d94eef96fb05a254913 (diff) | |
| download | bcm5719-llvm-69d9e990facf4d07c31b96e47e98cde07228f229.tar.gz bcm5719-llvm-69d9e990facf4d07c31b96e47e98cde07228f229.zip | |
Eliminate the using decls for MLFunction and CFGFunction standardizing on
Function.
This is step 18/n towards merging instructions and statements, NFC.
PiperOrigin-RevId: 227139399
Diffstat (limited to 'mlir/lib/Transforms')
20 files changed, 104 insertions, 106 deletions
diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp index 4b198589e2c..04f7cfdc3e9 100644 --- a/mlir/lib/Transforms/CSE.cpp +++ b/mlir/lib/Transforms/CSE.cpp @@ -43,8 +43,8 @@ namespace { struct CSE : public FunctionPass { CSE() : FunctionPass(&CSE::passID) {} - PassResult runOnCFGFunction(CFGFunction *f) override; - PassResult runOnMLFunction(MLFunction *f) override; + PassResult runOnCFGFunction(Function *f) override; + PassResult runOnMLFunction(Function *f) override; static char passID; }; @@ -162,7 +162,7 @@ struct CFGCSE : public CSEImpl { bool processed; }; - void run(CFGFunction *f) { + void run(Function *f) { // Note, deque is being used here because there was significant performance // gains over vector when the container becomes very large due to the // specific access patterns. If/when these performance issues are no @@ -210,7 +210,7 @@ struct CFGCSE : public CSEImpl { struct MLCSE : public CSEImpl, StmtWalker<MLCSE> { using StmtWalker<MLCSE>::walk; - void run(MLFunction *f) { + void run(Function *f) { // Walk the function statements. walk(f); @@ -231,12 +231,12 @@ struct MLCSE : public CSEImpl, StmtWalker<MLCSE> { char CSE::passID = 0; -PassResult CSE::runOnCFGFunction(CFGFunction *f) { +PassResult CSE::runOnCFGFunction(Function *f) { CFGCSE().run(f); return success(); } -PassResult CSE::runOnMLFunction(MLFunction *f) { +PassResult CSE::runOnMLFunction(Function *f) { MLCSE().run(f); return success(); } diff --git a/mlir/lib/Transforms/ComposeAffineMaps.cpp b/mlir/lib/Transforms/ComposeAffineMaps.cpp index a1ecf38dabd..8c69fa61578 100644 --- a/mlir/lib/Transforms/ComposeAffineMaps.cpp +++ b/mlir/lib/Transforms/ComposeAffineMaps.cpp @@ -16,7 +16,7 @@ // ============================================================================= // // This file implements a testing pass which composes affine maps from -// AffineApplyOps in an MLFunction, by forward subtituting results from an +// AffineApplyOps in a Function, by forward subtituting results from an // AffineApplyOp into any of its users which are also AffineApplyOps. // //===----------------------------------------------------------------------===// @@ -36,7 +36,7 @@ using namespace mlir; namespace { -// ComposeAffineMaps walks stmt blocks in an MLFunction, and for each +// ComposeAffineMaps walks stmt blocks in a Function, and for each // AffineApplyOp, forward substitutes its results into any users which are // also AffineApplyOps. After forward subtituting its results, AffineApplyOps // with no remaining uses are collected and erased after the walk. @@ -48,7 +48,7 @@ struct ComposeAffineMaps : public FunctionPass, StmtWalker<ComposeAffineMaps> { using StmtListType = llvm::iplist<Statement>; void walk(StmtListType::iterator Start, StmtListType::iterator End); void visitOperationInst(OperationInst *stmt); - PassResult runOnMLFunction(MLFunction *f) override; + PassResult runOnMLFunction(Function *f) override; using StmtWalker<ComposeAffineMaps>::walk; static char passID; @@ -88,7 +88,7 @@ void ComposeAffineMaps::visitOperationInst(OperationInst *opStmt) { } } -PassResult ComposeAffineMaps::runOnMLFunction(MLFunction *f) { +PassResult ComposeAffineMaps::runOnMLFunction(Function *f) { affineApplyOpsToErase.clear(); walk(f); for (auto *opStmt : affineApplyOpsToErase) { diff --git a/mlir/lib/Transforms/ConstantFold.cpp b/mlir/lib/Transforms/ConstantFold.cpp index a83e625c240..08087777e72 100644 --- a/mlir/lib/Transforms/ConstantFold.cpp +++ b/mlir/lib/Transforms/ConstantFold.cpp @@ -40,8 +40,8 @@ struct ConstantFold : public FunctionPass, StmtWalker<ConstantFold> { ConstantFactoryType constantFactory); void visitOperationInst(OperationInst *stmt); void visitForStmt(ForStmt *stmt); - PassResult runOnCFGFunction(CFGFunction *f) override; - PassResult runOnMLFunction(MLFunction *f) override; + PassResult runOnCFGFunction(Function *f) override; + PassResult runOnMLFunction(Function *f) override; static char passID; }; @@ -103,7 +103,7 @@ bool ConstantFold::foldOperation(OperationInst *op, // For now, we do a simple top-down pass over a function folding constants. We // don't handle conditional control flow, constant PHI nodes, folding // conditional branches, or anything else fancy. -PassResult ConstantFold::runOnCFGFunction(CFGFunction *f) { +PassResult ConstantFold::runOnCFGFunction(Function *f) { existingConstants.clear(); FuncBuilder builder(f); @@ -155,7 +155,7 @@ void ConstantFold::visitForStmt(ForStmt *forStmt) { constantFoldBounds(forStmt); } -PassResult ConstantFold::runOnMLFunction(MLFunction *f) { +PassResult ConstantFold::runOnMLFunction(Function *f) { existingConstants.clear(); opStmtsToErase.clear(); diff --git a/mlir/lib/Transforms/ConvertToCFG.cpp b/mlir/lib/Transforms/ConvertToCFG.cpp index ca158a17e92..270a25dd339 100644 --- a/mlir/lib/Transforms/ConvertToCFG.cpp +++ b/mlir/lib/Transforms/ConvertToCFG.cpp @@ -41,9 +41,8 @@ namespace { // Generates CFG function equivalent to the given ML function. class FunctionConverter : public StmtVisitor<FunctionConverter> { public: - FunctionConverter(CFGFunction *cfgFunc) - : cfgFunc(cfgFunc), builder(cfgFunc) {} - CFGFunction *convert(MLFunction *mlFunc); + FunctionConverter(Function *cfgFunc) : cfgFunc(cfgFunc), builder(cfgFunc) {} + Function *convert(Function *mlFunc); void visitForStmt(ForStmt *forStmt); void visitIfStmt(IfStmt *ifStmt); @@ -56,7 +55,7 @@ private: Location loc, CmpIPredicate predicate, llvm::iterator_range<OperationInst::result_iterator> values); - CFGFunction *cfgFunc; + Function *cfgFunc; FuncBuilder builder; // Mapping between original Values and lowered Values. @@ -455,7 +454,7 @@ void FunctionConverter::visitIfStmt(IfStmt *ifStmt) { // Entry point of the function convertor. // -// Conversion is performed by recursively visiting statements of an MLFunction. +// Conversion is performed by recursively visiting statements of a Function. // It reasons in terms of single-entry single-exit (SESE) regions that are not // materialized in the code. Instead, the pointer to the last block of the // region is maintained throughout the conversion as the insertion point of the @@ -471,11 +470,11 @@ void FunctionConverter::visitIfStmt(IfStmt *ifStmt) { // construction. When an Value is used, it gets replaced with the // corresponding Value that has been defined previously. The value flow // starts with function arguments converted to basic block arguments. -CFGFunction *FunctionConverter::convert(MLFunction *mlFunc) { +Function *FunctionConverter::convert(Function *mlFunc) { auto outerBlock = builder.createBlock(); // CFGFunctions do not have explicit arguments but use the arguments to the - // first basic block instead. Create those from the MLFunction arguments and + // first basic block instead. Create those from the Function arguments and // set up the value remapping. outerBlock->addArguments(mlFunc->getType().getInputs()); assert(mlFunc->getNumArguments() == outerBlock->getNumArguments()); @@ -511,17 +510,17 @@ private: // Generates CFG functions for all ML functions in the module. void convertMLFunctions(); // Generates CFG function for the given ML function. - CFGFunction *convert(MLFunction *mlFunc); + Function *convert(Function *mlFunc); // Replaces all ML function references in the module // with references to the generated CFG functions. void replaceReferences(); // Replaces function references in the given function. - void replaceReferences(CFGFunction *cfgFunc); + void replaceReferences(Function *cfgFunc); // Replaces MLFunctions with their CFG counterparts in the module. void replaceFunctions(); // Map from ML functions to generated CFG functions. - llvm::DenseMap<MLFunction *, CFGFunction *> generatedFuncs; + llvm::DenseMap<Function *, Function *> generatedFuncs; Module *module = nullptr; }; } // end anonymous namespace @@ -554,7 +553,7 @@ void ModuleConverter::convertMLFunctions() { } // Creates CFG function equivalent to the given ML function. -CFGFunction *ModuleConverter::convert(MLFunction *mlFunc) { +Function *ModuleConverter::convert(Function *mlFunc) { // Use the same name as for ML function; do not add the converted function to // the module yet to avoid collision. auto name = mlFunc->getName().str(); @@ -578,7 +577,7 @@ void ModuleConverter::replaceReferences() { for (const Function &fn : *module) { if (!fn.isML()) continue; - CFGFunction *convertedFunc = generatedFuncs.lookup(&fn); + Function *convertedFunc = generatedFuncs.lookup(&fn); assert(convertedFunc && "ML function was not converted"); MLIRContext *context = module->getContext(); @@ -597,11 +596,11 @@ void ModuleConverter::replaceReferences() { } // Replace the value of a function attribute named "name" attached to the -// operation "op" and containing an MLFunction-typed value with the result of -// converting "func" to a CFGFunction. +// operation "op" and containing a Function-typed value with the result of +// converting "func" to a Function. static inline void replaceMLFunctionAttr( OperationInst &op, Identifier name, const Function *func, - const llvm::DenseMap<MLFunction *, CFGFunction *> &generatedFuncs) { + const llvm::DenseMap<Function *, Function *> &generatedFuncs) { if (!func->isML()) return; @@ -610,8 +609,8 @@ static inline void replaceMLFunctionAttr( op.setAttr(name, b.getFunctionAttr(cfgFunc)); } -// The CFG and ML functions have the same name. First, erase the MLFunction. -// Then insert the CFGFunction at the same place. +// The CFG and ML functions have the same name. First, erase the Function. +// Then insert the Function at the same place. void ModuleConverter::replaceFunctions() { for (auto pair : generatedFuncs) { auto &functions = module->getFunctions(); diff --git a/mlir/lib/Transforms/DmaGeneration.cpp b/mlir/lib/Transforms/DmaGeneration.cpp index ed184dc9421..925c50abfec 100644 --- a/mlir/lib/Transforms/DmaGeneration.cpp +++ b/mlir/lib/Transforms/DmaGeneration.cpp @@ -63,8 +63,8 @@ struct DmaGeneration : public FunctionPass, StmtWalker<DmaGeneration> { } // Not applicable to CFG functions. - PassResult runOnCFGFunction(CFGFunction *f) override { return success(); } - PassResult runOnMLFunction(MLFunction *f) override; + PassResult runOnCFGFunction(Function *f) override { return success(); } + PassResult runOnMLFunction(Function *f) override; void runOnForStmt(ForStmt *forStmt); void visitOperationInst(OperationInst *opStmt); @@ -425,7 +425,7 @@ void DmaGeneration::runOnForStmt(ForStmt *forStmt) { << " KiB of DMA buffers in fast memory space\n";); } -PassResult DmaGeneration::runOnMLFunction(MLFunction *f) { +PassResult DmaGeneration::runOnMLFunction(Function *f) { for (auto &stmt : *f->getBody()) { if (auto *forStmt = dyn_cast<ForStmt>(&stmt)) { runOnForStmt(forStmt); diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index 67b36cfda30..2ddd613d6af 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -70,7 +70,7 @@ namespace { struct LoopFusion : public FunctionPass { LoopFusion() : FunctionPass(&LoopFusion::passID) {} - PassResult runOnMLFunction(MLFunction *f) override; + PassResult runOnMLFunction(Function *f) override; static char passID; }; @@ -158,7 +158,7 @@ public: }; // MemRefDependenceGraph is a graph data structure where graph nodes are -// top-level statements in an MLFunction which contain load/store ops, and edges +// top-level statements in a Function which contain load/store ops, and edges // are memref dependences between the nodes. // TODO(andydavis) Add a depth parameter to dependence graph construction. struct MemRefDependenceGraph { @@ -217,7 +217,7 @@ public: // Initializes the dependence graph based on operations in 'f'. // Returns true on success, false otherwise. - bool init(MLFunction *f); + bool init(Function *f); // Returns the graph node for 'id'. Node *getNode(unsigned id) { @@ -345,7 +345,7 @@ public: // 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 // dependence graph at a different depth. -bool MemRefDependenceGraph::init(MLFunction *f) { +bool MemRefDependenceGraph::init(Function *f) { unsigned id = 0; DenseMap<Value *, SetVector<unsigned>> memrefAccesses; for (auto &stmt : *f->getBody()) { @@ -415,7 +415,7 @@ bool MemRefDependenceGraph::init(MLFunction *f) { // GreedyFusion greedily fuses loop nests which have a producer/consumer // relationship on a memref, with the goal of improving locality. Currently, // this the producer/consumer relationship is required to be unique in the -// MLFunction (there are TODOs to relax this constraint in the future). +// Function (there are TODOs to relax this constraint in the future). // // The steps of the algorithm are as follows: // @@ -425,7 +425,7 @@ bool MemRefDependenceGraph::init(MLFunction *f) { // destination ForStmt into which fusion will be attempted. // *) Add each LoadOp currently in 'dstForStmt' into list 'dstLoadOps'. // *) For each LoadOp in 'dstLoadOps' do: -// *) Lookup dependent loop nests at earlier positions in the MLFunction +// *) Lookup dependent loop nests at earlier positions in the Function // which have a single store op to the same memref. // *) Check if dependences would be violated by the fusion. For example, // the src loop nest may load from memrefs which are different than @@ -549,7 +549,7 @@ public: } // end anonymous namespace -PassResult LoopFusion::runOnMLFunction(MLFunction *f) { +PassResult LoopFusion::runOnMLFunction(Function *f) { MemRefDependenceGraph g; if (g.init(f)) GreedyFusion(&g).run(); diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp index 9e365567b17..d6c1eed3a0c 100644 --- a/mlir/lib/Transforms/LoopTiling.cpp +++ b/mlir/lib/Transforms/LoopTiling.cpp @@ -38,10 +38,10 @@ static llvm::cl::opt<unsigned> namespace { -/// A pass to perform loop tiling on all suitable loop nests of an MLFunction. +/// A pass to perform loop tiling on all suitable loop nests of a Function. struct LoopTiling : public FunctionPass { LoopTiling() : FunctionPass(&LoopTiling::passID) {} - PassResult runOnMLFunction(MLFunction *f) override; + PassResult runOnMLFunction(Function *f) override; constexpr static unsigned kDefaultTileSize = 4; static char passID; @@ -52,7 +52,7 @@ struct LoopTiling : public FunctionPass { char LoopTiling::passID = 0; /// Creates a pass to perform loop tiling on all suitable loop nests of an -/// MLFunction. +/// Function. FunctionPass *mlir::createLoopTilingPass() { return new LoopTiling(); } // Move the loop body of ForStmt 'src' from 'src' into the specified location in @@ -214,7 +214,7 @@ UtilResult mlir::tileCodeGen(ArrayRef<ForStmt *> band, // Identify valid and profitable bands of loops to tile. This is currently just // a temporary placeholder to test the mechanics of tiled code generation. // Returns all maximal outermost perfect loop nests to tile. -static void getTileableBands(MLFunction *f, +static void getTileableBands(Function *f, std::vector<SmallVector<ForStmt *, 6>> *bands) { // Get maximal perfect nest of 'for' stmts starting from root (inclusive). auto getMaximalPerfectLoopNest = [&](ForStmt *root) { @@ -235,7 +235,7 @@ static void getTileableBands(MLFunction *f, } } -PassResult LoopTiling::runOnMLFunction(MLFunction *f) { +PassResult LoopTiling::runOnMLFunction(Function *f) { std::vector<SmallVector<ForStmt *, 6>> bands; getTileableBands(f, &bands); diff --git a/mlir/lib/Transforms/LoopUnroll.cpp b/mlir/lib/Transforms/LoopUnroll.cpp index 0a3dd65d1f4..c3651e53593 100644 --- a/mlir/lib/Transforms/LoopUnroll.cpp +++ b/mlir/lib/Transforms/LoopUnroll.cpp @@ -70,7 +70,7 @@ struct LoopUnroll : public FunctionPass { : FunctionPass(&LoopUnroll::passID), unrollFactor(unrollFactor), unrollFull(unrollFull), getUnrollFactor(getUnrollFactor) {} - PassResult runOnMLFunction(MLFunction *f) override; + PassResult runOnMLFunction(Function *f) override; /// Unroll this for stmt. Returns false if nothing was done. bool runOnForStmt(ForStmt *forStmt); @@ -83,7 +83,7 @@ struct LoopUnroll : public FunctionPass { char LoopUnroll::passID = 0; -PassResult LoopUnroll::runOnMLFunction(MLFunction *f) { +PassResult LoopUnroll::runOnMLFunction(Function *f) { // Gathers all innermost loops through a post order pruned walk. class InnermostLoopGatherer : public StmtWalker<InnermostLoopGatherer, bool> { public: diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp index 179216d243e..7ed9be19644 100644 --- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp @@ -65,7 +65,7 @@ static llvm::cl::opt<unsigned> namespace { /// Loop unroll jam pass. Currently, this just unroll jams the first -/// outer loop in an MLFunction. +/// outer loop in a Function. struct LoopUnrollAndJam : public FunctionPass { Optional<unsigned> unrollJamFactor; static const unsigned kDefaultUnrollJamFactor = 4; @@ -74,7 +74,7 @@ struct LoopUnrollAndJam : public FunctionPass { : FunctionPass(&LoopUnrollAndJam::passID), unrollJamFactor(unrollJamFactor) {} - PassResult runOnMLFunction(MLFunction *f) override; + PassResult runOnMLFunction(Function *f) override; bool runOnForStmt(ForStmt *forStmt); static char passID; @@ -88,7 +88,7 @@ FunctionPass *mlir::createLoopUnrollAndJamPass(int unrollJamFactor) { unrollJamFactor == -1 ? None : Optional<unsigned>(unrollJamFactor)); } -PassResult LoopUnrollAndJam::runOnMLFunction(MLFunction *f) { +PassResult LoopUnrollAndJam::runOnMLFunction(Function *f) { // Currently, just the outermost loop from the first loop nest is // unroll-and-jammed by this pass. However, runOnForStmt can be called on any // for Stmt. @@ -165,8 +165,8 @@ bool mlir::loopUnrollJamByFactor(ForStmt *forStmt, uint64_t unrollJamFactor) { auto ubMap = forStmt->getUpperBoundMap(); // Loops with max/min expressions won't be unrolled here (the output can't be - // expressed as an MLFunction in the general case). However, the right way to - // do such unrolling for an MLFunction would be to specialize the loop for the + // expressed as a Function in the general case). However, the right way to + // do such unrolling for a Function would be to specialize the loop for the // 'hotspot' case and unroll that hotspot. if (lbMap.getNumResults() != 1 || ubMap.getNumResults() != 1) return false; diff --git a/mlir/lib/Transforms/LowerAffineApply.cpp b/mlir/lib/Transforms/LowerAffineApply.cpp index e8a2af54b8e..52146fdb5b7 100644 --- a/mlir/lib/Transforms/LowerAffineApply.cpp +++ b/mlir/lib/Transforms/LowerAffineApply.cpp @@ -35,8 +35,8 @@ struct LowerAffineApply : public FunctionPass { explicit LowerAffineApply() : FunctionPass(&LowerAffineApply::passID) {} - PassResult runOnMLFunction(MLFunction *f) override; - PassResult runOnCFGFunction(CFGFunction *f) override; + PassResult runOnMLFunction(Function *f) override; + PassResult runOnCFGFunction(Function *f) override; static char passID; }; @@ -45,13 +45,13 @@ struct LowerAffineApply : public FunctionPass { char LowerAffineApply::passID = 0; -PassResult LowerAffineApply::runOnMLFunction(MLFunction *f) { +PassResult LowerAffineApply::runOnMLFunction(Function *f) { f->emitError("ML Functions contain syntactically hidden affine_apply's that " "cannot be expanded"); return failure(); } -PassResult LowerAffineApply::runOnCFGFunction(CFGFunction *f) { +PassResult LowerAffineApply::runOnCFGFunction(Function *f) { for (BasicBlock &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. diff --git a/mlir/lib/Transforms/LowerVectorTransfers.cpp b/mlir/lib/Transforms/LowerVectorTransfers.cpp index 6907c322856..4d24191dcb2 100644 --- a/mlir/lib/Transforms/LowerVectorTransfers.cpp +++ b/mlir/lib/Transforms/LowerVectorTransfers.cpp @@ -108,7 +108,7 @@ static void rewriteAsLoops(VectorTransferOpTy *transfer, auto vectorMemRefType = MemRefType::get({1}, vectorType, {}, 0); // Get the ML function builder. - // We need access to the MLFunction builder stored internally in the + // 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 // forward them or define a whole rewriting chain based on MLFunctionBuilder @@ -233,7 +233,7 @@ struct LowerVectorTransfersPass : MLPatternLoweringPass(&LowerVectorTransfersPass::passID) {} std::unique_ptr<MLFuncGlobalLoweringState> - makeFuncWiseState(MLFunction *f) const override { + makeFuncWiseState(Function *f) const override { auto state = llvm::make_unique<LowerVectorTransfersState>(); auto builder = FuncBuilder(f); builder.setInsertionPointToStart(f->getBody()); diff --git a/mlir/lib/Transforms/MaterializeVectors.cpp b/mlir/lib/Transforms/MaterializeVectors.cpp index 93fec70b8a7..a30e8164760 100644 --- a/mlir/lib/Transforms/MaterializeVectors.cpp +++ b/mlir/lib/Transforms/MaterializeVectors.cpp @@ -77,7 +77,7 @@ /// words, this pass operates on a scoped program slice. Furthermore, since we /// do not vectorize in the presence of conditionals for now, sliced chains are /// guaranteed not to escape the innermost scope, which has to be either the top -/// MLFunction scope of the innermost loop scope, by construction. As a +/// Function scope of the innermost loop scope, by construction. As a /// consequence, the implementation just starts from vector_transfer_write /// operations and builds the slice scoped the innermost loop enclosing the /// current vector_transfer_write. These assumptions and the implementation @@ -196,7 +196,7 @@ struct MaterializationState { struct MaterializeVectorsPass : public FunctionPass { MaterializeVectorsPass() : FunctionPass(&MaterializeVectorsPass::passID) {} - PassResult runOnMLFunction(MLFunction *f) override; + PassResult runOnMLFunction(Function *f) override; // Thread-safe RAII contexts local to pass, BumpPtrAllocator freed on exit. MLFunctionMatcherContext mlContext; @@ -650,7 +650,7 @@ static bool emitSlice(MaterializationState *state, /// Additionally, this set is limited to statements in the same lexical scope /// because we currently disallow vectorization of defs that come from another /// scope. -static bool materialize(MLFunction *f, +static bool materialize(Function *f, const SetVector<OperationInst *> &terminators, MaterializationState *state) { DenseSet<Statement *> seen; @@ -709,9 +709,9 @@ static bool materialize(MLFunction *f, return false; } -PassResult MaterializeVectorsPass::runOnMLFunction(MLFunction *f) { +PassResult MaterializeVectorsPass::runOnMLFunction(Function *f) { using matcher::Op; - LLVM_DEBUG(dbgs() << "\nMaterializeVectors on MLFunction\n"); + LLVM_DEBUG(dbgs() << "\nMaterializeVectors on Function\n"); LLVM_DEBUG(f->print(dbgs())); MaterializationState state; diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp index 9798225f90b..a0964a67fa6 100644 --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -41,7 +41,7 @@ namespace { struct PipelineDataTransfer : public FunctionPass, StmtWalker<PipelineDataTransfer> { PipelineDataTransfer() : FunctionPass(&PipelineDataTransfer::passID) {} - PassResult runOnMLFunction(MLFunction *f) override; + PassResult runOnMLFunction(Function *f) override; PassResult runOnForStmt(ForStmt *forStmt); // Collect all 'for' statements. @@ -137,7 +137,7 @@ static bool doubleBuffer(Value *oldMemRef, ForStmt *forStmt) { } /// Returns success if the IR is in a valid state. -PassResult PipelineDataTransfer::runOnMLFunction(MLFunction *f) { +PassResult PipelineDataTransfer::runOnMLFunction(Function *f) { // Do a post order walk so that inner loop DMAs are processed first. This is // necessary since 'for' statements nested within would otherwise become // invalid (erased) when the outer loop is pipelined (the pipelined one gets diff --git a/mlir/lib/Transforms/SimplifyAffineExpr.cpp b/mlir/lib/Transforms/SimplifyAffineExpr.cpp index b0b31e01175..853a814e516 100644 --- a/mlir/lib/Transforms/SimplifyAffineExpr.cpp +++ b/mlir/lib/Transforms/SimplifyAffineExpr.cpp @@ -33,7 +33,7 @@ using llvm::report_fatal_error; namespace { /// Simplifies all affine expressions appearing in the operation statements of -/// the MLFunction. This is mainly to test the simplifyAffineExpr method. +/// the Function. This is mainly to test the simplifyAffineExpr method. // TODO(someone): Gradually, extend this to all affine map references found in // ML functions and CFG functions. struct SimplifyAffineStructures : public FunctionPass, @@ -41,10 +41,10 @@ struct SimplifyAffineStructures : public FunctionPass, explicit SimplifyAffineStructures() : FunctionPass(&SimplifyAffineStructures::passID) {} - PassResult runOnMLFunction(MLFunction *f) override; + PassResult runOnMLFunction(Function *f) override; // Does nothing on CFG functions for now. No reusable walkers/visitors exist // for this yet? TODO(someone). - PassResult runOnCFGFunction(CFGFunction *f) override { return success(); } + PassResult runOnCFGFunction(Function *f) override { return success(); } void visitIfStmt(IfStmt *ifStmt); void visitOperationInst(OperationInst *opStmt); @@ -86,7 +86,7 @@ void SimplifyAffineStructures::visitOperationInst(OperationInst *opStmt) { } } -PassResult SimplifyAffineStructures::runOnMLFunction(MLFunction *f) { +PassResult SimplifyAffineStructures::runOnMLFunction(Function *f) { walk(f); return success(); } diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp index f493e4b090b..a4116667794 100644 --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -255,7 +255,7 @@ void GreedyPatternRewriteDriver::simplifyFunction(Function *currentFunction, uniquedConstants.clear(); } -static void processMLFunction(MLFunction *fn, +static void processMLFunction(Function *fn, OwningRewritePatternList &&patterns) { class MLFuncRewriter : public WorklistRewriter { public: @@ -287,7 +287,7 @@ static void processMLFunction(MLFunction *fn, driver.simplifyFunction(fn, rewriter); } -static void processCFGFunction(CFGFunction *fn, +static void processCFGFunction(Function *fn, OwningRewritePatternList &&patterns) { class CFGFuncRewriter : public WorklistRewriter { public: diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index 4a2831c0a83..7def4fe2f09 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -122,9 +122,9 @@ bool mlir::promoteIfSingleIteration(ForStmt *forStmt) { return true; } -/// Promotes all single iteration for stmt's in the MLFunction, i.e., moves +/// Promotes all single iteration for stmt's in the Function, i.e., moves /// their body into the containing StmtBlock. -void mlir::promoteSingleIterationLoops(MLFunction *f) { +void mlir::promoteSingleIterationLoops(Function *f) { // Gathers all innermost loops through a post order pruned walk. class LoopBodyPromoter : public StmtWalker<LoopBodyPromoter> { public: @@ -357,8 +357,8 @@ bool mlir::loopUnrollByFactor(ForStmt *forStmt, uint64_t unrollFactor) { auto ubMap = forStmt->getUpperBoundMap(); // Loops with max/min expressions won't be unrolled here (the output can't be - // expressed as an MLFunction in the general case). However, the right way to - // do such unrolling for an MLFunction would be to specialize the loop for the + // expressed as a Function in the general case). However, the right way to + // do such unrolling for a Function would be to specialize the loop for the // 'hotspot' case and unroll that hotspot. if (lbMap.getNumResults() != 1 || ubMap.getNumResults() != 1) return false; diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp index a0556c43c7f..3661c1bdbbc 100644 --- a/mlir/lib/Transforms/Utils/Utils.cpp +++ b/mlir/lib/Transforms/Utils/Utils.cpp @@ -434,7 +434,7 @@ void mlir::remapFunctionAttrs( void mlir::remapFunctionAttrs( Function &fn, const DenseMap<Attribute, FunctionAttr> &remappingTable) { - // Look at all instructions in a CFGFunction. + // Look at all instructions in a Function. if (fn.isCFG()) { for (auto &bb : fn.getBlockList()) { for (auto &inst : bb) { diff --git a/mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp b/mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp index 5abd3a3cfcc..78d048b4778 100644 --- a/mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp +++ b/mlir/lib/Transforms/Vectorization/VectorizerTestPass.cpp @@ -73,12 +73,12 @@ struct VectorizerTestPass : public FunctionPass { static constexpr auto kTestAffineMapAttrName = "affine_map"; VectorizerTestPass() : FunctionPass(&VectorizerTestPass::passID) {} - PassResult runOnMLFunction(MLFunction *f) override; - void testVectorShapeRatio(MLFunction *f); - void testForwardSlicing(MLFunction *f); - void testBackwardSlicing(MLFunction *f); - void testSlicing(MLFunction *f); - void testComposeMaps(MLFunction *f); + PassResult runOnMLFunction(Function *f) override; + void testVectorShapeRatio(Function *f); + void testForwardSlicing(Function *f); + void testBackwardSlicing(Function *f); + void testSlicing(Function *f); + void testComposeMaps(Function *f); // Thread-safe RAII contexts local to pass, BumpPtrAllocator freed on exit. MLFunctionMatcherContext MLContext; @@ -90,7 +90,7 @@ struct VectorizerTestPass : public FunctionPass { char VectorizerTestPass::passID = 0; -void VectorizerTestPass::testVectorShapeRatio(MLFunction *f) { +void VectorizerTestPass::testVectorShapeRatio(Function *f) { using matcher::Op; SmallVector<int, 8> shape(clTestVectorShapeRatio.begin(), clTestVectorShapeRatio.end()); @@ -139,7 +139,7 @@ static std::string toString(Statement *stmt) { return res; } -static MLFunctionMatches matchTestSlicingOps(MLFunction *f) { +static MLFunctionMatches matchTestSlicingOps(Function *f) { // Just use a custom op name for this test, it makes life easier. constexpr auto kTestSlicingOpName = "slicing-test-op"; using functional::map; @@ -153,7 +153,7 @@ static MLFunctionMatches matchTestSlicingOps(MLFunction *f) { return pat.match(f); } -void VectorizerTestPass::testBackwardSlicing(MLFunction *f) { +void VectorizerTestPass::testBackwardSlicing(Function *f) { auto matches = matchTestSlicingOps(f); for (auto m : matches) { SetVector<Statement *> backwardSlice; @@ -166,7 +166,7 @@ void VectorizerTestPass::testBackwardSlicing(MLFunction *f) { } } -void VectorizerTestPass::testForwardSlicing(MLFunction *f) { +void VectorizerTestPass::testForwardSlicing(Function *f) { auto matches = matchTestSlicingOps(f); for (auto m : matches) { SetVector<Statement *> forwardSlice; @@ -179,7 +179,7 @@ void VectorizerTestPass::testForwardSlicing(MLFunction *f) { } } -void VectorizerTestPass::testSlicing(MLFunction *f) { +void VectorizerTestPass::testSlicing(Function *f) { auto matches = matchTestSlicingOps(f); for (auto m : matches) { SetVector<Statement *> staticSlice = getSlice(m.first); @@ -197,7 +197,7 @@ bool customOpWithAffineMapAttribute(const Statement &stmt) { VectorizerTestPass::kTestAffineMapOpName; } -void VectorizerTestPass::testComposeMaps(MLFunction *f) { +void VectorizerTestPass::testComposeMaps(Function *f) { using matcher::Op; auto pattern = Op(customOpWithAffineMapAttribute); auto matches = pattern.match(f); @@ -218,7 +218,7 @@ void VectorizerTestPass::testComposeMaps(MLFunction *f) { res.print(outs() << "\nComposed map: "); } -PassResult VectorizerTestPass::runOnMLFunction(MLFunction *f) { +PassResult VectorizerTestPass::runOnMLFunction(Function *f) { if (!clTestVectorShapeRatio.empty()) { testVectorShapeRatio(f); } diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index 762a09ea048..ddbd6256782 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -47,7 +47,7 @@ using namespace mlir; /// -/// Implements a high-level vectorization strategy on an MLFunction. +/// Implements a high-level vectorization strategy on a Function. /// The abstraction used is that of super-vectors, which provide a single, /// compact, representation in the vector types, information that is expected /// to reduce the impact of the phase ordering problem @@ -382,7 +382,7 @@ using namespace mlir; /// /// Examples: /// ========= -/// Consider the following MLFunction: +/// Consider the following Function: /// ```mlir /// mlfunc @vector_add_2d(%M : index, %N : index) -> f32 { /// %A = alloc (%M, %N) : memref<?x?xf32, 0> @@ -651,7 +651,7 @@ namespace { struct Vectorize : public FunctionPass { Vectorize() : FunctionPass(&Vectorize::passID) {} - PassResult runOnMLFunction(MLFunction *f) override; + PassResult runOnMLFunction(Function *f) override; // Thread-safe RAII contexts local to pass, BumpPtrAllocator freed on exit. MLFunctionMatcherContext MLContext; @@ -1264,13 +1264,13 @@ static bool vectorizeRootMatches(MLFunctionMatches matches, return false; } -/// Applies vectorization to the current MLFunction by searching over a bunch of +/// Applies vectorization to the current Function by searching over a bunch of /// predetermined patterns. -PassResult Vectorize::runOnMLFunction(MLFunction *f) { +PassResult Vectorize::runOnMLFunction(Function *f) { for (auto pat : makePatterns()) { LLVM_DEBUG(dbgs() << "\n******************************************"); LLVM_DEBUG(dbgs() << "\n******************************************"); - LLVM_DEBUG(dbgs() << "\n[early-vect] new pattern on MLFunction\n"); + LLVM_DEBUG(dbgs() << "\n[early-vect] new pattern on Function\n"); LLVM_DEBUG(f->print(dbgs())); unsigned patternDepth = pat.getDepth(); auto matches = pat.match(f); diff --git a/mlir/lib/Transforms/ViewFunctionGraph.cpp b/mlir/lib/Transforms/ViewFunctionGraph.cpp index 9c1614acb95..2ce8af3613a 100644 --- a/mlir/lib/Transforms/ViewFunctionGraph.cpp +++ b/mlir/lib/Transforms/ViewFunctionGraph.cpp @@ -25,16 +25,15 @@ namespace llvm { // Specialize DOTGraphTraits to produce more readable output. template <> -struct llvm::DOTGraphTraits<const CFGFunction *> - : public DefaultDOTGraphTraits { +struct llvm::DOTGraphTraits<const Function *> : public DefaultDOTGraphTraits { using DefaultDOTGraphTraits::DefaultDOTGraphTraits; static std::string getNodeLabel(const BasicBlock *basicBlock, - const CFGFunction *); + const Function *); }; -std::string llvm::DOTGraphTraits<const CFGFunction *>::getNodeLabel( - const BasicBlock *basicBlock, const CFGFunction *) { +std::string llvm::DOTGraphTraits<const Function *>::getNodeLabel( + const BasicBlock *basicBlock, const Function *) { // Reuse the print output for the node labels. std::string outStreamStr; raw_string_ostream os(outStreamStr); @@ -57,19 +56,19 @@ std::string llvm::DOTGraphTraits<const CFGFunction *>::getNodeLabel( } // end namespace llvm -void mlir::viewGraph(const CFGFunction &function, const llvm::Twine &name, +void mlir::viewGraph(const Function &function, const llvm::Twine &name, bool shortNames, const llvm::Twine &title, llvm::GraphProgram::Name program) { llvm::ViewGraph(&function, name, shortNames, title, program); } llvm::raw_ostream &mlir::writeGraph(llvm::raw_ostream &os, - const CFGFunction *function, - bool shortNames, const llvm::Twine &title) { + const Function *function, bool shortNames, + const llvm::Twine &title) { return llvm::WriteGraph(os, function, shortNames, title); } -void mlir::CFGFunction::viewGraph() const { +void mlir::Function::viewGraph() const { ::mlir::viewGraph(*this, llvm::Twine("cfgfunc ") + getName().str()); } @@ -79,7 +78,7 @@ struct PrintCFGPass : public FunctionPass { const llvm::Twine &title = "") : FunctionPass(&PrintCFGPass::passID), os(os), shortNames(shortNames), title(title) {} - PassResult runOnCFGFunction(CFGFunction *function) override { + PassResult runOnCFGFunction(Function *function) override { mlir::writeGraph(os, function, shortNames, title); return success(); } |

