diff --git a/flang/test/Fir/affine-promotion.fir b/flang/test/Fir/affine-promotion.fir --- a/flang/test/Fir/affine-promotion.fir +++ b/flang/test/Fir/affine-promotion.fir @@ -1,6 +1,6 @@ // Test affine promotion pass -// RUN: fir-opt --split-input-file --promote-to-affine --affine-loop-invariant-code-motion --cse %s | FileCheck %s +// RUN: fir-opt --split-input-file -pass-pipeline="promote-to-affine,func.func(affine-loop-invariant-code-motion),cse" %s | FileCheck %s !arr_d1 = !fir.ref> #arr_len = affine_map<()[j1,k1] -> (k1 - j1 + 1)> diff --git a/mlir/include/mlir/Dialect/Affine/LoopUtils.h b/mlir/include/mlir/Dialect/Affine/LoopUtils.h --- a/mlir/include/mlir/Dialect/Affine/LoopUtils.h +++ b/mlir/include/mlir/Dialect/Affine/LoopUtils.h @@ -22,16 +22,13 @@ namespace mlir { class AffineForOp; class AffineMap; +class FunctionOpInterface; class LoopLikeOpInterface; struct MemRefRegion; class OpBuilder; class Value; class ValueRange; -namespace func { -class FuncOp; -} // namespace func - namespace scf { class ForOp; class ParallelOp; @@ -82,7 +79,7 @@ /// Promotes all single iteration AffineForOp's in the Function, i.e., moves /// their body into the containing Block. -void promoteSingleIterationLoops(func::FuncOp f); +void promoteSingleIterationLoops(FunctionOpInterface f); /// Skew the operations in an affine.for's body with the specified /// operation-wise shifts. The shifts are with respect to the original execution @@ -95,7 +92,7 @@ /// 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. -void getTileableBands(func::FuncOp f, +void getTileableBands(FunctionOpInterface f, std::vector> *bands); /// Tiles the specified band of perfectly nested loops creating tile-space loops @@ -263,7 +260,7 @@ ArrayRef numProcessors); /// Gathers all AffineForOps in 'func.func' grouped by loop depth. -void gatherLoops(func::FuncOp func, +void gatherLoops(FunctionOpInterface func, std::vector> &depthToLoops); /// Creates an AffineForOp while ensuring that the lower and upper bounds are diff --git a/mlir/include/mlir/Dialect/Affine/Passes.h b/mlir/include/mlir/Dialect/Affine/Passes.h --- a/mlir/include/mlir/Dialect/Affine/Passes.h +++ b/mlir/include/mlir/Dialect/Affine/Passes.h @@ -18,11 +18,8 @@ #include namespace mlir { -namespace func { -class FuncOp; -} // namespace func - class AffineForOp; +class FunctionOpInterface; /// Fusion mode to attempt. The default mode `Greedy` does both /// producer-consumer and sibling fusion. @@ -31,56 +28,59 @@ /// Creates a simplification pass for affine structures (maps and sets). In /// addition, this pass also normalizes memrefs to have the trivial (identity) /// layout map. -std::unique_ptr> +std::unique_ptr> createSimplifyAffineStructuresPass(); /// Creates a loop invariant code motion pass that hoists loop invariant /// operations out of affine loops. -std::unique_ptr> +std::unique_ptr> createAffineLoopInvariantCodeMotionPass(); /// Creates a pass to convert all parallel affine.for's into 1-d affine.parallel /// ops. -std::unique_ptr> createAffineParallelizePass(); +std::unique_ptr> +createAffineParallelizePass(); /// Apply normalization transformations to affine loop-like ops. -std::unique_ptr> createAffineLoopNormalizePass(); +std::unique_ptr> +createAffineLoopNormalizePass(); /// Performs packing (or explicit copying) of accessed memref regions into /// buffers in the specified faster memory space through either pointwise copies /// or DMA operations. -std::unique_ptr> createAffineDataCopyGenerationPass( +std::unique_ptr> +createAffineDataCopyGenerationPass( unsigned slowMemorySpace, unsigned fastMemorySpace, unsigned tagMemorySpace = 0, int minDmaTransferSize = 1024, uint64_t fastMemCapacityBytes = std::numeric_limits::max()); /// Overload relying on pass options for initialization. -std::unique_ptr> +std::unique_ptr> createAffineDataCopyGenerationPass(); /// Creates a pass to replace affine memref accesses by scalars using store to /// load forwarding and redundant load elimination; consequently also eliminate /// dead allocs. -std::unique_ptr> +std::unique_ptr> createAffineScalarReplacementPass(); /// Creates a pass that transforms perfectly nested loops with independent /// bounds into a single loop. -std::unique_ptr> createLoopCoalescingPass(); +std::unique_ptr> createLoopCoalescingPass(); /// Creates a loop fusion pass which fuses loops according to type of fusion /// specified in `fusionMode`. Buffers of size less than or equal to /// `localBufSizeThreshold` are promoted to memory space `fastMemorySpace`. -std::unique_ptr> +std::unique_ptr> createLoopFusionPass(unsigned fastMemorySpace = 0, uint64_t localBufSizeThreshold = 0, bool maximalFusion = false, enum FusionMode fusionMode = FusionMode::Greedy); /// Creates a pass to perform tiling on loop nests. -std::unique_ptr> +std::unique_ptr> createLoopTilingPass(uint64_t cacheSizeBytes); /// Overload relying on pass options for initialization. -std::unique_ptr> createLoopTilingPass(); +std::unique_ptr> createLoopTilingPass(); /// Creates a loop unrolling pass with the provided parameters. /// 'getUnrollFactor' is a function callback for clients to supply a function @@ -88,7 +88,7 @@ /// factors supplied through other means. If -1 is passed as the unrollFactor /// and no callback is provided, anything passed from the command-line (if at /// all) or the default unroll factor is used (LoopUnroll:kDefaultUnrollFactor). -std::unique_ptr> createLoopUnrollPass( +std::unique_ptr> createLoopUnrollPass( int unrollFactor = -1, bool unrollUpToFactor = false, bool unrollFull = false, const std::function &getUnrollFactor = nullptr); @@ -96,19 +96,20 @@ /// Creates a loop unroll jam pass to unroll jam by the specified factor. A /// factor of -1 lets the pass use the default factor or the one on the command /// line if provided. -std::unique_ptr> +std::unique_ptr> createLoopUnrollAndJamPass(int unrollJamFactor = -1); /// Creates a pass to pipeline explicit movement of data across levels of the /// memory hierarchy. -std::unique_ptr> createPipelineDataTransferPass(); +std::unique_ptr> +createPipelineDataTransferPass(); /// Creates a pass to vectorize loops, operations and data types using a /// target-independent, n-D super-vector abstraction. -std::unique_ptr> +std::unique_ptr> createSuperVectorizePass(ArrayRef virtualVectorSize); /// Overload relying on pass options for initialization. -std::unique_ptr> createSuperVectorizePass(); +std::unique_ptr> createSuperVectorizePass(); //===----------------------------------------------------------------------===// // Registration diff --git a/mlir/include/mlir/Dialect/Affine/Passes.td b/mlir/include/mlir/Dialect/Affine/Passes.td --- a/mlir/include/mlir/Dialect/Affine/Passes.td +++ b/mlir/include/mlir/Dialect/Affine/Passes.td @@ -15,7 +15,8 @@ include "mlir/Pass/PassBase.td" -def AffineDataCopyGeneration : Pass<"affine-data-copy-generate", "func::FuncOp"> { +def AffineDataCopyGeneration : InterfacePass< + "affine-data-copy-generate", "FunctionOpInterface"> { let summary = "Generate explicit copying for affine memory operations"; let constructor = "mlir::createAffineDataCopyGenerationPass()"; let dependentDialects = ["memref::MemRefDialect"]; @@ -43,7 +44,8 @@ ]; } -def AffineLoopFusion : Pass<"affine-loop-fusion", "func::FuncOp"> { +def AffineLoopFusion : InterfacePass< + "affine-loop-fusion", "FunctionOpInterface"> { let summary = "Fuse affine loop nests"; let description = [{ This pass performs fusion of loop nests using a slicing-based approach. It @@ -175,13 +177,14 @@ let dependentDialects = ["memref::MemRefDialect"]; } -def AffineLoopInvariantCodeMotion - : Pass<"affine-loop-invariant-code-motion", "func::FuncOp"> { +def AffineLoopInvariantCodeMotion : InterfacePass< + "affine-loop-invariant-code-motion", "FunctionOpInterface"> { let summary = "Hoist loop invariant instructions outside of affine loops"; let constructor = "mlir::createAffineLoopInvariantCodeMotionPass()"; } -def AffineLoopTiling : Pass<"affine-loop-tile", "func::FuncOp"> { +def AffineLoopTiling : InterfacePass< + "affine-loop-tile", "FunctionOpInterface"> { let summary = "Tile affine loop nests"; let constructor = "mlir::createLoopTilingPass()"; let options = [ @@ -198,7 +201,8 @@ ]; } -def AffineLoopUnroll : Pass<"affine-loop-unroll", "func::FuncOp"> { +def AffineLoopUnroll : InterfacePass< + "affine-loop-unroll", "FunctionOpInterface"> { let summary = "Unroll affine loops"; let constructor = "mlir::createLoopUnrollPass()"; let options = [ @@ -216,7 +220,8 @@ ]; } -def AffineLoopUnrollAndJam : Pass<"affine-loop-unroll-jam", "func::FuncOp"> { +def AffineLoopUnrollAndJam : InterfacePass< + "affine-loop-unroll-jam", "FunctionOpInterface"> { let summary = "Unroll and jam affine loops"; let constructor = "mlir::createLoopUnrollAndJamPass()"; let options = [ @@ -227,7 +232,7 @@ } def AffinePipelineDataTransfer - : Pass<"affine-pipeline-data-transfer", "func::FuncOp"> { + : InterfacePass<"affine-pipeline-data-transfer", "FunctionOpInterface"> { let summary = "Pipeline non-blocking data transfers between explicitly " "managed levels of the memory hierarchy"; let description = [{ @@ -295,7 +300,8 @@ let constructor = "mlir::createPipelineDataTransferPass()"; } -def AffineScalarReplacement : Pass<"affine-scalrep", "func::FuncOp"> { +def AffineScalarReplacement : InterfacePass< + "affine-scalrep", "FunctionOpInterface"> { let summary = "Replace affine memref acceses by scalars by forwarding stores " "to loads and eliminating redundant loads"; let description = [{ @@ -341,7 +347,8 @@ let constructor = "mlir::createAffineScalarReplacementPass()"; } -def AffineVectorize : Pass<"affine-super-vectorize", "func::FuncOp"> { +def AffineVectorize : InterfacePass< + "affine-super-vectorize", "FunctionOpInterface"> { let summary = "Vectorize to a target independent n-D vector abstraction"; let constructor = "mlir::createSuperVectorizePass()"; let dependentDialects = ["vector::VectorDialect"]; @@ -367,7 +374,8 @@ ]; } -def AffineParallelize : Pass<"affine-parallelize", "func::FuncOp"> { +def AffineParallelize : InterfacePass< + "affine-parallelize", "FunctionOpInterface"> { let summary = "Convert affine.for ops into 1-D affine.parallel"; let constructor = "mlir::createAffineParallelizePass()"; let options = [ @@ -380,19 +388,22 @@ ]; } -def AffineLoopNormalize : Pass<"affine-loop-normalize", "func::FuncOp"> { +def AffineLoopNormalize : InterfacePass< + "affine-loop-normalize", "FunctionOpInterface"> { let summary = "Apply normalization transformations to affine loop-like ops"; let constructor = "mlir::createAffineLoopNormalizePass()"; } -def LoopCoalescing : Pass<"affine-loop-coalescing", "func::FuncOp"> { +def LoopCoalescing : InterfacePass< + "affine-loop-coalescing", "FunctionOpInterface"> { let summary = "Coalesce nested loops with independent bounds into a single " "loop"; let constructor = "mlir::createLoopCoalescingPass()"; let dependentDialects = ["arith::ArithmeticDialect"]; } -def SimplifyAffineStructures : Pass<"affine-simplify-structures", "func::FuncOp"> { +def SimplifyAffineStructures : InterfacePass< + "affine-simplify-structures", "FunctionOpInterface"> { let summary = "Simplify affine expressions in maps/sets and normalize " "memrefs"; let constructor = "mlir::createSimplifyAffineStructuresPass()"; diff --git a/mlir/include/mlir/Dialect/Affine/Utils.h b/mlir/include/mlir/Dialect/Affine/Utils.h --- a/mlir/include/mlir/Dialect/Affine/Utils.h +++ b/mlir/include/mlir/Dialect/Affine/Utils.h @@ -24,10 +24,6 @@ class Operation; class PostDominanceInfo; -namespace func { -class FuncOp; -} // namespace func - namespace memref { class AllocOp; } // namespace memref @@ -99,7 +95,7 @@ /// Replace affine store and load accesses by scalars by forwarding stores to /// loads and eliminate invariant affine loads; consequently, eliminate dead /// allocs. -void affineScalarReplace(func::FuncOp f, DominanceInfo &domInfo, +void affineScalarReplace(Operation *parentOp, DominanceInfo &domInfo, PostDominanceInfo &postDomInfo); /// Vectorizes affine loops in 'loops' using the n-D vectorization factors in diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp --- a/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp +++ b/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp @@ -17,9 +17,9 @@ #include "mlir/Dialect/Affine/Analysis/Utils.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/IR/AffineValueMap.h" -#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/AffineExprVisitor.h" #include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/IntegerSet.h" #include "mlir/Interfaces/ViewLikeInterface.h" #include "llvm/ADT/TypeSwitch.h" @@ -326,7 +326,7 @@ if (numCommonLoops == 0) { Block *block = srcAccess.opInst->getBlock(); - while (!llvm::isa(block->getParentOp())) { + while (!llvm::isa(block->getParentOp())) { block = block->getParentOp()->getBlock(); } return block; diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp --- a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp @@ -77,7 +77,7 @@ /// buffers in 'fastMemorySpace', and replaces memory operations to the former /// by the latter. Only load op's handled for now. /// TODO: extend this to store op's. -std::unique_ptr> +std::unique_ptr> mlir::createAffineDataCopyGenerationPass(unsigned slowMemorySpace, unsigned fastMemorySpace, unsigned tagMemorySpace, @@ -87,7 +87,7 @@ slowMemorySpace, fastMemorySpace, tagMemorySpace, minDmaTransferSize, fastMemCapacityBytes); } -std::unique_ptr> +std::unique_ptr> mlir::createAffineDataCopyGenerationPass() { return std::make_unique(); } @@ -199,7 +199,7 @@ } void AffineDataCopyGeneration::runOnOperation() { - func::FuncOp f = getOperation(); + FunctionOpInterface f = getOperation(); OpBuilder topBuilder(f.getBody()); zeroIndex = topBuilder.create(f.getLoc(), 0); diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp --- a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp @@ -238,7 +238,7 @@ }); } -std::unique_ptr> +std::unique_ptr> mlir::createAffineLoopInvariantCodeMotionPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineLoopNormalize.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineLoopNormalize.cpp --- a/mlir/lib/Dialect/Affine/Transforms/AffineLoopNormalize.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineLoopNormalize.cpp @@ -37,7 +37,7 @@ } // namespace -std::unique_ptr> +std::unique_ptr> mlir::createAffineLoopNormalizePass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp --- a/mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp @@ -48,7 +48,7 @@ } // namespace void AffineParallelize::runOnOperation() { - func::FuncOp f = getOperation(); + FunctionOpInterface f = getOperation(); // The walker proceeds in pre-order to process the outer loops first // and control the number of outer parallel loops. @@ -81,7 +81,7 @@ } } -std::unique_ptr> +std::unique_ptr> mlir::createAffineParallelizePass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineScalarReplacement.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineScalarReplacement.cpp --- a/mlir/lib/Dialect/Affine/Transforms/AffineScalarReplacement.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineScalarReplacement.cpp @@ -34,7 +34,7 @@ } // namespace -std::unique_ptr> +std::unique_ptr> mlir::createAffineScalarReplacementPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp --- a/mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp @@ -85,7 +85,7 @@ } void runOnOperation() override { - func::FuncOp func = getOperation(); + FunctionOpInterface func = getOperation(); func.walk([&](Operation *op) { if (auto scfForOp = dyn_cast(op)) walkLoop(scfForOp); @@ -97,6 +97,7 @@ } // namespace -std::unique_ptr> mlir::createLoopCoalescingPass() { +std::unique_ptr> +mlir::createLoopCoalescingPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp --- a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp @@ -61,7 +61,7 @@ } // namespace -std::unique_ptr> +std::unique_ptr> mlir::createLoopFusionPass(unsigned fastMemorySpace, uint64_t localBufSizeThreshold, bool maximalFusion, enum FusionMode affineFusionMode) { @@ -95,8 +95,8 @@ }; // MemRefDependenceGraph is a graph data structure where graph nodes are -// top-level operations in a FuncOp which contain load/store ops, and edges -// are memref dependences between the nodes. +// top-level operations in a FuncOpInterface which contain load/store ops, and +// edges are memref dependences between the nodes. // TODO: Add a more flexible dependence graph representation. // TODO: Add a depth parameter to dependence graph construction. struct MemRefDependenceGraph { @@ -202,7 +202,7 @@ // Initializes the dependence graph based on operations in 'f'. // Returns true on success, false otherwise. - bool init(func::FuncOp f); + bool init(FunctionOpInterface f); // Returns the graph node for 'id'. Node *getNode(unsigned id) { @@ -731,7 +731,7 @@ // Assigns each node in the graph a node id based on program order in 'f'. // TODO: Add support for taking a Block arg to construct the // dependence graph at a different depth. -bool MemRefDependenceGraph::init(func::FuncOp f) { +bool MemRefDependenceGraph::init(FunctionOpInterface f) { LLVM_DEBUG(llvm::dbgs() << "--- Initializing MDG ---\n"); DenseMap> memrefAccesses; @@ -895,7 +895,7 @@ // Create builder to insert alloc op just before 'forOp'. OpBuilder b(forInst); // Builder to create constants at the top level. - OpBuilder top(forInst->getParentOfType().getBody()); + OpBuilder top(forInst->getParentOfType().getBody()); // Create new memref type based on slice bounds. auto oldMemRef = cast(srcStoreOpInst).getMemRef(); auto oldMemRefType = oldMemRef.getType().cast(); @@ -1850,7 +1850,7 @@ }; // Search for siblings which load the same memref function argument. - auto fn = dstNode->op->getParentOfType(); + auto fn = dstNode->op->getParentOfType(); for (unsigned i = 0, e = fn.getNumArguments(); i != e; ++i) { for (auto *user : fn.getArgument(i).getUsers()) { if (auto loadOp = dyn_cast(user)) { diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp --- a/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp @@ -53,11 +53,12 @@ /// Creates a pass to perform loop tiling on all suitable loop nests of a /// Function. -std::unique_ptr> +std::unique_ptr> mlir::createLoopTilingPass(uint64_t cacheSizeBytes) { return std::make_unique(cacheSizeBytes); } -std::unique_ptr> mlir::createLoopTilingPass() { +std::unique_ptr> +mlir::createLoopTilingPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp --- a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp @@ -71,7 +71,7 @@ } /// Gathers loops that have no affine.for's nested within. -static void gatherInnermostLoops(func::FuncOp f, +static void gatherInnermostLoops(FunctionOpInterface f, SmallVectorImpl &loops) { f.walk([&](AffineForOp forOp) { if (isInnermostAffineForOp(forOp)) @@ -80,7 +80,7 @@ } void LoopUnroll::runOnOperation() { - func::FuncOp func = getOperation(); + FunctionOpInterface func = getOperation(); if (func.isExternal()) return; @@ -132,7 +132,7 @@ return loopUnrollByFactor(forOp, unrollFactor); } -std::unique_ptr> mlir::createLoopUnrollPass( +std::unique_ptr> mlir::createLoopUnrollPass( int unrollFactor, bool unrollUpToFactor, bool unrollFull, const std::function &getUnrollFactor) { return std::make_unique( diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp --- a/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp @@ -63,7 +63,7 @@ }; } // namespace -std::unique_ptr> +std::unique_ptr> mlir::createLoopUnrollAndJamPass(int unrollJamFactor) { return std::make_unique( unrollJamFactor == -1 ? None : Optional(unrollJamFactor)); diff --git a/mlir/lib/Dialect/Affine/Transforms/PassDetail.h b/mlir/lib/Dialect/Affine/Transforms/PassDetail.h --- a/mlir/lib/Dialect/Affine/Transforms/PassDetail.h +++ b/mlir/lib/Dialect/Affine/Transforms/PassDetail.h @@ -10,7 +10,8 @@ #define DIALECT_AFFINE_TRANSFORMS_PASSDETAIL_H_ #include "mlir/Dialect/Affine/Passes.h" -#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "mlir/IR/DialectRegistry.h" +#include "mlir/IR/FunctionInterfaces.h" #include "mlir/Pass/Pass.h" namespace mlir { diff --git a/mlir/lib/Dialect/Affine/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Dialect/Affine/Transforms/PipelineDataTransfer.cpp --- a/mlir/lib/Dialect/Affine/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/PipelineDataTransfer.cpp @@ -41,7 +41,7 @@ /// Creates a pass to pipeline explicit movement of data across levels of the /// memory hierarchy. -std::unique_ptr> +std::unique_ptr> mlir::createPipelineDataTransferPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp b/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp --- a/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp @@ -71,24 +71,24 @@ } // namespace -std::unique_ptr> +std::unique_ptr> mlir::createSimplifyAffineStructuresPass() { return std::make_unique(); } void SimplifyAffineStructures::runOnOperation() { - auto func = getOperation(); + FunctionOpInterface f = getOperation(); simplifiedAttributes.clear(); - RewritePatternSet patterns(func.getContext()); - AffineApplyOp::getCanonicalizationPatterns(patterns, func.getContext()); - AffineForOp::getCanonicalizationPatterns(patterns, func.getContext()); - AffineIfOp::getCanonicalizationPatterns(patterns, func.getContext()); + RewritePatternSet patterns(f.getContext()); + AffineApplyOp::getCanonicalizationPatterns(patterns, f.getContext()); + AffineForOp::getCanonicalizationPatterns(patterns, f.getContext()); + AffineIfOp::getCanonicalizationPatterns(patterns, f.getContext()); FrozenRewritePatternSet frozenPatterns(std::move(patterns)); // The simplification of affine attributes will likely simplify the op. Try to // fold/apply canonicalization patterns when we have affine dialect ops. SmallVector opsToSimplify; - func.walk([&](Operation *op) { + f.walk([&](Operation *op) { for (auto attr : op->getAttrs()) { if (auto mapAttr = attr.getValue().dyn_cast()) simplifyAndUpdateAttribute(op, attr.getName(), mapAttr); diff --git a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp --- a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp @@ -1709,18 +1709,18 @@ LLVM_DEBUG(dbgs() << "\n"); } -std::unique_ptr> +std::unique_ptr> createSuperVectorizePass(ArrayRef virtualVectorSize) { return std::make_unique(virtualVectorSize); } -std::unique_ptr> createSuperVectorizePass() { +std::unique_ptr> createSuperVectorizePass() { return std::make_unique(); } /// Applies vectorization to the current function by searching over a bunch of /// predetermined patterns. void Vectorize::runOnOperation() { - func::FuncOp f = getOperation(); + FunctionOpInterface f = getOperation(); if (!fastestVaryingPattern.empty() && fastestVaryingPattern.size() != vectorSizes.size()) { f.emitRemark("Fastest varying pattern specified with different size than " @@ -1864,11 +1864,11 @@ return vectorizeLoopNest(loops, strategy); } -std::unique_ptr> +std::unique_ptr> createSuperVectorizePass(ArrayRef virtualVectorSize) { return std::make_unique(virtualVectorSize); } -std::unique_ptr> createSuperVectorizePass() { +std::unique_ptr> createSuperVectorizePass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp b/mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp --- a/mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp +++ b/mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp @@ -18,12 +18,12 @@ #include "mlir/Dialect/Affine/Analysis/Utils.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/LoopUtils.h" -#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/Operation.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" @@ -482,7 +482,7 @@ auto walkResult = forOpRoot.walk([&](AffineForOp forOp) { auto *childForOp = forOp.getOperation(); auto *parentForOp = forOp->getParentOp(); - if (!llvm::isa(parentForOp)) { + if (!llvm::isa(parentForOp)) { if (!isa(parentForOp)) { LLVM_DEBUG(llvm::dbgs() << "Expected parent AffineForOp\n"); return WalkResult::interrupt(); diff --git a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp --- a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp +++ b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp @@ -18,10 +18,10 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/IR/AffineValueMap.h" #include "mlir/Dialect/Affine/Utils.h" -#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/IR/SCF.h" #include "mlir/IR/BlockAndValueMapping.h" +#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/IntegerSet.h" #include "mlir/Support/MathExtras.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" @@ -141,7 +141,8 @@ auto *parentBlock = forOp->getBlock(); if (!iv.use_empty()) { if (forOp.hasConstantLowerBound()) { - OpBuilder topBuilder(forOp->getParentOfType().getBody()); + OpBuilder topBuilder( + forOp->getParentOfType().getBody()); auto constOp = topBuilder.create( forOp.getLoc(), forOp.getConstantLowerBound()); iv.replaceAllUsesWith(constOp); @@ -960,11 +961,11 @@ /// 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. -void mlir::getTileableBands(func::FuncOp f, +void mlir::getTileableBands(FunctionOpInterface f, std::vector> *bands) { // Get maximal perfect nest of 'affine.for' insts starting from root // (inclusive). - for (AffineForOp forOp : f.getOps()) { + for (AffineForOp forOp : f.getBody().getOps()) { SmallVector band; getPerfectlyNestedLoops(band, forOp); bands->push_back(band); @@ -2045,7 +2046,7 @@ *nBegin = begin; *nEnd = end; - func::FuncOp f = begin->getParentOfType(); + auto f = begin->getParentOfType(); OpBuilder topBuilder(f.getBody()); Value zeroIndex = topBuilder.create(f.getLoc(), 0); @@ -2063,7 +2064,8 @@ OpBuilder &b = region.isWrite() ? epilogue : prologue; // Builder to create constants at the top level. - auto func = copyPlacementBlock->getParent()->getParentOfType(); + auto func = + copyPlacementBlock->getParent()->getParentOfType(); OpBuilder top(func.getBody()); auto loc = region.loc; @@ -2609,7 +2611,7 @@ } /// Gathers all AffineForOps in 'func.func' grouped by loop depth. -void mlir::gatherLoops(func::FuncOp func, +void mlir::gatherLoops(FunctionOpInterface func, std::vector> &depthToLoops) { for (auto &block : func) gatherLoopsInBlock(&block, /*currLoopDepth=*/0, depthToLoops); diff --git a/mlir/lib/Dialect/Affine/Utils/Utils.cpp b/mlir/lib/Dialect/Affine/Utils/Utils.cpp --- a/mlir/lib/Dialect/Affine/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Affine/Utils/Utils.cpp @@ -17,11 +17,11 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/IR/AffineValueMap.h" #include "mlir/Dialect/Affine/LoopUtils.h" -#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/IR/AffineExprVisitor.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Dominance.h" +#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/IntegerSet.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" @@ -260,7 +260,7 @@ // Walk up the parents past all for op that this conditional is invariant on. auto ifOperands = ifOp.getOperands(); auto *res = ifOp.getOperation(); - while (!isa(res->getParentOp())) { + while (!isa(res->getParentOp())) { auto *parentOp = res->getParentOp(); if (auto forOp = dyn_cast(parentOp)) { if (llvm::is_contained(ifOperands, forOp.getInductionVar())) @@ -1021,7 +1021,7 @@ // currently only eliminates the stores only if no other loads/uses (other // than dealloc) remain. // -void mlir::affineScalarReplace(func::FuncOp f, DominanceInfo &domInfo, +void mlir::affineScalarReplace(Operation *parentOp, DominanceInfo &domInfo, PostDominanceInfo &postDomInfo) { // Load op's whose results were replaced by those forwarded from stores. SmallVector opsToErase; @@ -1030,7 +1030,7 @@ SmallPtrSet memrefsToErase; // Walk all load's and perform store to load forwarding. - f.walk([&](AffineReadOpInterface loadOp) { + parentOp->walk([&](AffineReadOpInterface loadOp) { if (failed( forwardStoreToLoad(loadOp, opsToErase, memrefsToErase, domInfo))) { loadCSE(loadOp, opsToErase, domInfo); @@ -1043,7 +1043,7 @@ opsToErase.clear(); // Walk all store's and perform unused store elimination - f.walk([&](AffineWriteOpInterface storeOp) { + parentOp->walk([&](AffineWriteOpInterface storeOp) { findUnusedStore(storeOp, opsToErase, postDomInfo); }); // Erase all store op's which don't impact the program @@ -1279,11 +1279,11 @@ std::unique_ptr postDomInfo; if (domOpFilter) domInfo = std::make_unique( - domOpFilter->getParentOfType()); + domOpFilter->getParentOfType()); if (postDomOpFilter) postDomInfo = std::make_unique( - postDomOpFilter->getParentOfType()); + postDomOpFilter->getParentOfType()); // Walk all uses of old memref; collect ops to perform replacement. We use a // DenseSet since an operation could potentially have multiple uses of a diff --git a/mlir/test/Dialect/Affine/SuperVectorize/uniform_divergent.mlir b/mlir/test/Dialect/Affine/SuperVectorize/uniform_divergent.mlir --- a/mlir/test/Dialect/Affine/SuperVectorize/uniform_divergent.mlir +++ b/mlir/test/Dialect/Affine/SuperVectorize/uniform_divergent.mlir @@ -1,4 +1,5 @@ -// RUN: mlir-opt %s -affine-super-vectorize="virtual-vector-size=128" -split-input-file | FileCheck %s +// RUN: mlir-opt %s -pass-pipeline="func.func(affine-super-vectorize{virtual-vector-size=128})" \ +// RUN: -split-input-file | FileCheck %s // Specific tests to check vectorization of uniform/divergent values. diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir --- a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir +++ b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir @@ -1,4 +1,5 @@ -// RUN: mlir-opt %s -affine-super-vectorize="virtual-vector-size=128 test-fastest-varying=0" -split-input-file | FileCheck %s +// RUN: mlir-opt %s -pass-pipeline="func.func(affine-super-vectorize{virtual-vector-size=128 test-fastest-varying=0})" \ +// RUN: -split-input-file | FileCheck %s // CHECK-DAG: #[[$map_id1:map[0-9]+]] = affine_map<(d0) -> (d0)> // CHECK-DAG: #[[$map_proj_d0d1_0:map[0-9]+]] = affine_map<(d0, d1) -> (0)> diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_2d.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_2d.mlir --- a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_2d.mlir +++ b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_2d.mlir @@ -1,5 +1,5 @@ -// RUN: mlir-opt %s -affine-super-vectorize="virtual-vector-size=4,8" | FileCheck %s -check-prefix=VECT -// RUN: mlir-opt %s -affine-super-vectorize="virtual-vector-size=32,256 test-fastest-varying=1,0" | FileCheck %s +// RUN: mlir-opt %s -pass-pipeline="func.func(affine-super-vectorize{virtual-vector-size=4,8})" | FileCheck %s -check-prefix=VECT +// RUN: mlir-opt %s -pass-pipeline="func.func(affine-super-vectorize{virtual-vector-size=32,256 test-fastest-varying=1,0})" | FileCheck %s // Permutation maps used in vectorization. // CHECK-DAG: #[[$map_id1:map[0-9]+]] = affine_map<(d0) -> (d0)> diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_3d.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_3d.mlir --- a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_3d.mlir +++ b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_3d.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt %s -affine-super-vectorize="virtual-vector-size=32,64,256 test-fastest-varying=2,1,0" | FileCheck %s +// RUN: mlir-opt %s -pass-pipeline="func.func(affine-super-vectorize{virtual-vector-size=32,64,256 test-fastest-varying=2,1,0})" | FileCheck %s func.func @vec3d(%A : memref) { %c0 = arith.constant 0 : index diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_outer_loop_2d.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_outer_loop_2d.mlir --- a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_outer_loop_2d.mlir +++ b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_outer_loop_2d.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt %s -affine-super-vectorize="virtual-vector-size=32,256 test-fastest-varying=2,0" | FileCheck %s +// RUN: mlir-opt %s -pass-pipeline="func.func(affine-super-vectorize{virtual-vector-size=32,256 test-fastest-varying=2,0})" | FileCheck %s // Permutation maps used in vectorization. // CHECK: #[[map_proj_d0d1d2_d0d2:map[0-9]*]] = affine_map<(d0, d1, d2) -> (d0, d2)> diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_outer_loop_transpose_2d.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_outer_loop_transpose_2d.mlir --- a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_outer_loop_transpose_2d.mlir +++ b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_outer_loop_transpose_2d.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt %s -affine-super-vectorize="virtual-vector-size=32,256 test-fastest-varying=0,2" | FileCheck %s +// RUN: mlir-opt %s -pass-pipeline="func.func(affine-super-vectorize{virtual-vector-size=32,256 test-fastest-varying=0,2})" | FileCheck %s // Permutation maps used in vectorization. // CHECK: #[[map_proj_d0d1d2_d2d0:map[0-9]*]] = affine_map<(d0, d1, d2) -> (d2, d0)> diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_reduction.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_reduction.mlir --- a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_reduction.mlir +++ b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_reduction.mlir @@ -1,4 +1,5 @@ -// RUN: mlir-opt %s -affine-super-vectorize="virtual-vector-size=128 test-fastest-varying=0 vectorize-reductions=true" -split-input-file | FileCheck %s +// RUN: mlir-opt %s -pass-pipeline="func.func(affine-super-vectorize{virtual-vector-size=128 test-fastest-varying=0 vectorize-reductions=true})" \ +// RUN: -split-input-file | FileCheck %s // The inner reduction loop '%j' is vectorized. diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_reduction_2d.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_reduction_2d.mlir --- a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_reduction_2d.mlir +++ b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_reduction_2d.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt %s -affine-super-vectorize="virtual-vector-size=32,256 test-fastest-varying=1,0 vectorize-reductions=true" -verify-diagnostics +// RUN: mlir-opt %s -verify-diagnostics -pass-pipeline="func.func(affine-super-vectorize{virtual-vector-size=32,256 test-fastest-varying=1,0 vectorize-reductions=true})" // TODO: Vectorization of reduction loops along the reduction dimension is not // supported for higher-rank vectors yet, so we are just checking that an diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_transpose_2d.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_transpose_2d.mlir --- a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_transpose_2d.mlir +++ b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_transpose_2d.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt %s -affine-super-vectorize="virtual-vector-size=32,256 test-fastest-varying=0,1" | FileCheck %s +// RUN: mlir-opt %s -pass-pipeline="func.func(affine-super-vectorize{virtual-vector-size=32,256 test-fastest-varying=0,1})" | FileCheck %s // Permutation maps used in vectorization. // CHECK-DAG: #[[map_proj_d0d1d2_d2d1:map[0-9]*]] = affine_map<(d0, d1, d2) -> (d2, d1)> diff --git a/mlir/test/Dialect/Affine/affine-data-copy.mlir b/mlir/test/Dialect/Affine/affine-data-copy.mlir --- a/mlir/test/Dialect/Affine/affine-data-copy.mlir +++ b/mlir/test/Dialect/Affine/affine-data-copy.mlir @@ -1,6 +1,6 @@ -// RUN: mlir-opt %s -split-input-file -affine-data-copy-generate="generate-dma=false fast-mem-space=0 skip-non-unit-stride-loops" | FileCheck %s +// RUN: mlir-opt %s -split-input-file -pass-pipeline="func.func(affine-data-copy-generate{generate-dma=false fast-mem-space=0 skip-non-unit-stride-loops})" | FileCheck %s // Small buffer size to trigger fine copies. -// RUN: mlir-opt %s -split-input-file -affine-data-copy-generate="generate-dma=false fast-mem-space=0 fast-mem-capacity=1" | FileCheck --check-prefix=CHECK-SMALL %s +// RUN: mlir-opt %s -split-input-file -pass-pipeline="func.func(affine-data-copy-generate{generate-dma=false fast-mem-space=0 fast-mem-capacity=1})" | FileCheck --check-prefix=CHECK-SMALL %s // Test affine data copy with a memref filter. We use a test pass that invokes // affine data copy utility on the input loop nest. diff --git a/mlir/test/Dialect/Affine/affine-loop-invariant-code-motion.mlir b/mlir/test/Dialect/Affine/affine-loop-invariant-code-motion.mlir --- a/mlir/test/Dialect/Affine/affine-loop-invariant-code-motion.mlir +++ b/mlir/test/Dialect/Affine/affine-loop-invariant-code-motion.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt %s -affine-loop-invariant-code-motion -split-input-file | FileCheck %s +// RUN: mlir-opt %s -pass-pipeline="func.func(affine-loop-invariant-code-motion)" -split-input-file | FileCheck %s func.func @nested_loops_both_having_invariant_code() { %m = memref.alloc() : memref<10xf32> diff --git a/mlir/test/Dialect/Affine/affine-loop-normalize.mlir b/mlir/test/Dialect/Affine/affine-loop-normalize.mlir --- a/mlir/test/Dialect/Affine/affine-loop-normalize.mlir +++ b/mlir/test/Dialect/Affine/affine-loop-normalize.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt %s -affine-loop-normalize -split-input-file | FileCheck %s +// RUN: mlir-opt %s -pass-pipeline="func.func(affine-loop-normalize)" -split-input-file | FileCheck %s // Normalize steps to 1 and lower bounds to 0. diff --git a/mlir/test/Dialect/Affine/dma-generate.mlir b/mlir/test/Dialect/Affine/dma-generate.mlir --- a/mlir/test/Dialect/Affine/dma-generate.mlir +++ b/mlir/test/Dialect/Affine/dma-generate.mlir @@ -1,5 +1,7 @@ -// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-data-copy-generate="generate-dma fast-mem-space=2 skip-non-unit-stride-loops" -verify-diagnostics | FileCheck %s -// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-data-copy-generate="generate-dma fast-mem-capacity=16 fast-mem-space=2" | FileCheck %s --check-prefix FAST-MEM-16KB +// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics \ +// RUN: -pass-pipeline="func.func(affine-data-copy-generate{generate-dma fast-mem-space=2 skip-non-unit-stride-loops})" | FileCheck %s +// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file \ +// RUN: -pass-pipeline="func.func(affine-data-copy-generate{generate-dma fast-mem-capacity=16 fast-mem-space=2})" | FileCheck %s --check-prefix FAST-MEM-16KB // We run most test cases with -copy-skip-non-unit-stride-loops to allow testing // DMA generation at inner levels easily - since the DMA generation would diff --git a/mlir/test/Dialect/Affine/loop-coalescing.mlir b/mlir/test/Dialect/Affine/loop-coalescing.mlir --- a/mlir/test/Dialect/Affine/loop-coalescing.mlir +++ b/mlir/test/Dialect/Affine/loop-coalescing.mlir @@ -1,4 +1,5 @@ -// RUN: mlir-opt -split-input-file -allow-unregistered-dialect -affine-loop-coalescing %s | FileCheck %s +// RUN: mlir-opt -split-input-file -allow-unregistered-dialect \ +// RUN: -pass-pipeline="func.func(affine-loop-coalescing)" %s | FileCheck %s // CHECK-LABEL: @one_3d_nest func.func @one_3d_nest() { diff --git a/mlir/test/Dialect/Affine/loop-tiling-validity.mlir b/mlir/test/Dialect/Affine/loop-tiling-validity.mlir --- a/mlir/test/Dialect/Affine/loop-tiling-validity.mlir +++ b/mlir/test/Dialect/Affine/loop-tiling-validity.mlir @@ -1,4 +1,5 @@ -// RUN: mlir-opt %s -split-input-file -affine-loop-tile="tile-size=32" -verify-diagnostics | FileCheck %s +// RUN: mlir-opt %s -split-input-file -pass-pipeline="func.func(affine-loop-tile{tile-size=32})" \ +// RUN: -verify-diagnostics | FileCheck %s // ----- diff --git a/mlir/test/Dialect/Affine/loop-tiling.mlir b/mlir/test/Dialect/Affine/loop-tiling.mlir --- a/mlir/test/Dialect/Affine/loop-tiling.mlir +++ b/mlir/test/Dialect/Affine/loop-tiling.mlir @@ -1,6 +1,6 @@ -// RUN: mlir-opt %s -split-input-file -affine-loop-tile="tile-size=32" | FileCheck %s -// RUN: mlir-opt %s -split-input-file -affine-loop-tile="cache-size=512" | FileCheck %s --check-prefix=MODEL -// RUN: mlir-opt %s -split-input-file -affine-loop-tile="tile-size=32 separate" | FileCheck %s --check-prefix=SEPARATE +// RUN: mlir-opt %s -split-input-file -pass-pipeline="func.func(affine-loop-tile{tile-size=32})" | FileCheck %s +// RUN: mlir-opt %s -split-input-file -pass-pipeline="func.func(affine-loop-tile{cache-size=512})" | FileCheck %s --check-prefix=MODEL +// RUN: mlir-opt %s -split-input-file -pass-pipeline="func.func(affine-loop-tile{tile-size=32 separate})" | FileCheck %s --check-prefix=SEPARATE // ----- diff --git a/mlir/test/Dialect/Affine/parallelize.mlir b/mlir/test/Dialect/Affine/parallelize.mlir --- a/mlir/test/Dialect/Affine/parallelize.mlir +++ b/mlir/test/Dialect/Affine/parallelize.mlir @@ -1,6 +1,6 @@ -// RUN: mlir-opt %s -allow-unregistered-dialect -affine-parallelize | FileCheck %s -// RUN: mlir-opt %s -allow-unregistered-dialect -affine-parallelize='max-nested=1' | FileCheck --check-prefix=MAX-NESTED %s -// RUN: mlir-opt %s -allow-unregistered-dialect -affine-parallelize='parallel-reductions=1' | FileCheck --check-prefix=REDUCE %s +// RUN: mlir-opt %s -allow-unregistered-dialect -pass-pipeline="func.func(affine-parallelize)" | FileCheck %s +// RUN: mlir-opt %s -allow-unregistered-dialect -pass-pipeline="func.func(affine-parallelize{max-nested=1})" | FileCheck --check-prefix=MAX-NESTED %s +// RUN: mlir-opt %s -allow-unregistered-dialect -pass-pipeline="func.func(affine-parallelize{parallel-reductions=1})" | FileCheck --check-prefix=REDUCE %s // CHECK-LABEL: func @reduce_window_max() { func.func @reduce_window_max() { diff --git a/mlir/test/Dialect/Affine/scalrep.mlir b/mlir/test/Dialect/Affine/scalrep.mlir --- a/mlir/test/Dialect/Affine/scalrep.mlir +++ b/mlir/test/Dialect/Affine/scalrep.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-scalrep | FileCheck %s +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-scalrep)" | FileCheck %s // CHECK-DAG: [[$MAP0:#map[0-9]+]] = affine_map<(d0, d1) -> (d1 + 1)> // CHECK-DAG: [[$MAP1:#map[0-9]+]] = affine_map<(d0, d1) -> (d0)> diff --git a/mlir/test/Dialect/Affine/simplify-structures.mlir b/mlir/test/Dialect/Affine/simplify-structures.mlir --- a/mlir/test/Dialect/Affine/simplify-structures.mlir +++ b/mlir/test/Dialect/Affine/simplify-structures.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-simplify-structures | FileCheck %s +// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -pass-pipeline="func.func(affine-simplify-structures)" | FileCheck %s // CHECK-DAG: #[[$SET_2D:.*]] = affine_set<(d0, d1) : (d0 - 100 == 0, d1 - 10 == 0, -d0 + 100 >= 0, d1 >= 0)> // CHECK-DAG: #[[$SET_7_11:.*]] = affine_set<(d0, d1) : (d0 * 7 + d1 * 5 + 88 == 0, d0 * 5 - d1 * 11 + 60 == 0, d0 * 11 + d1 * 7 - 24 == 0, d0 * 7 + d1 * 5 + 88 == 0)> diff --git a/mlir/test/Dialect/Affine/unroll-jam.mlir b/mlir/test/Dialect/Affine/unroll-jam.mlir --- a/mlir/test/Dialect/Affine/unroll-jam.mlir +++ b/mlir/test/Dialect/Affine/unroll-jam.mlir @@ -1,5 +1,5 @@ -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-unroll-jam="unroll-jam-factor=2" | FileCheck %s -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-unroll-jam="unroll-jam-factor=4" | FileCheck --check-prefix=UJAM-FOUR %s +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-loop-unroll-jam{unroll-jam-factor=2})" | FileCheck %s +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-loop-unroll-jam{unroll-jam-factor=4})" | FileCheck --check-prefix=UJAM-FOUR %s // CHECK-DAG: [[$MAP_PLUS_1:#map[0-9]+]] = affine_map<(d0) -> (d0 + 1)> // CHECK-DAG: [[$MAP_DIV_OFFSET:#map[0-9]+]] = affine_map<()[s0] -> (((s0 - 1) floordiv 2) * 2 + 1)> diff --git a/mlir/test/Dialect/Affine/unroll.mlir b/mlir/test/Dialect/Affine/unroll.mlir --- a/mlir/test/Dialect/Affine/unroll.mlir +++ b/mlir/test/Dialect/Affine/unroll.mlir @@ -1,7 +1,7 @@ -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-unroll="unroll-full" | FileCheck %s --check-prefix UNROLL-FULL -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-unroll="unroll-full unroll-full-threshold=2" | FileCheck %s --check-prefix SHORT -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-unroll="unroll-factor=4" | FileCheck %s --check-prefix UNROLL-BY-4 -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-unroll="unroll-factor=1" | FileCheck %s --check-prefix UNROLL-BY-1 +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-loop-unroll{unroll-full})" | FileCheck %s --check-prefix UNROLL-FULL +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-loop-unroll{unroll-full unroll-full-threshold=2})" | FileCheck %s --check-prefix SHORT +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-loop-unroll{unroll-factor=4})" | FileCheck %s --check-prefix UNROLL-BY-4 +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-loop-unroll{unroll-factor=1})" | FileCheck %s --check-prefix UNROLL-BY-1 // UNROLL-FULL-DAG: [[$MAP0:#map[0-9]+]] = affine_map<(d0) -> (d0 + 1)> // UNROLL-FULL-DAG: [[$MAP1:#map[0-9]+]] = affine_map<(d0) -> (d0 + 2)> diff --git a/mlir/test/Dialect/SCF/loop-unroll.mlir b/mlir/test/Dialect/SCF/loop-unroll.mlir --- a/mlir/test/Dialect/SCF/loop-unroll.mlir +++ b/mlir/test/Dialect/SCF/loop-unroll.mlir @@ -3,7 +3,7 @@ // RUN: mlir-opt %s -test-loop-unrolling='unroll-factor=2 loop-depth=0' | FileCheck %s --check-prefix UNROLL-OUTER-BY-2 // RUN: mlir-opt %s -test-loop-unrolling='unroll-factor=2 loop-depth=1' | FileCheck %s --check-prefix UNROLL-INNER-BY-2 // RUN: mlir-opt %s -test-loop-unrolling='unroll-factor=2 annotate=true' | FileCheck %s --check-prefix UNROLL-BY-2-ANNOTATE -// RUN: mlir-opt %s --affine-loop-unroll='unroll-factor=6 unroll-up-to-factor=true' | FileCheck %s --check-prefix UNROLL-UP-TO +// RUN: mlir-opt %s -pass-pipeline="func.func(affine-loop-unroll{unroll-factor=6 unroll-up-to-factor=true})" | FileCheck %s --check-prefix UNROLL-UP-TO func.func @dynamic_loop_unroll(%arg0 : index, %arg1 : index, %arg2 : index, %arg3: memref) { diff --git a/mlir/test/Transforms/loop-fusion-2.mlir b/mlir/test/Transforms/loop-fusion-2.mlir --- a/mlir/test/Transforms/loop-fusion-2.mlir +++ b/mlir/test/Transforms/loop-fusion-2.mlir @@ -1,5 +1,5 @@ -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-fusion -split-input-file | FileCheck %s -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-fusion="fusion-maximal" -split-input-file | FileCheck %s --check-prefix=MAXIMAL +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-loop-fusion)" -split-input-file | FileCheck %s +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-loop-fusion{fusion-maximal})" -split-input-file | FileCheck %s --check-prefix=MAXIMAL // Part I of fusion tests in mlir/test/Transforms/loop-fusion.mlir. // Part III of fusion tests in mlir/test/Transforms/loop-fusion-3.mlir diff --git a/mlir/test/Transforms/loop-fusion-3.mlir b/mlir/test/Transforms/loop-fusion-3.mlir --- a/mlir/test/Transforms/loop-fusion-3.mlir +++ b/mlir/test/Transforms/loop-fusion-3.mlir @@ -1,7 +1,7 @@ -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-fusion -split-input-file | FileCheck %s -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-fusion="fusion-maximal" -split-input-file | FileCheck %s --check-prefix=MAXIMAL +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-loop-fusion)" -split-input-file | FileCheck %s +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-loop-fusion{fusion-maximal})" -split-input-file | FileCheck %s --check-prefix=MAXIMAL -// Part I of fusion tests in mlir/test/Transforms/loop-fusion.mlir. +// Part I of fusion tests in mlir/test/Transforms/loop-fusion.mlir. // Part II of fusion tests in mlir/test/Transforms/loop-fusion-2.mlir // Part IV of fusion tests in mlir/test/Transforms/loop-fusion-4.mlir diff --git a/mlir/test/Transforms/loop-fusion-4.mlir b/mlir/test/Transforms/loop-fusion-4.mlir --- a/mlir/test/Transforms/loop-fusion-4.mlir +++ b/mlir/test/Transforms/loop-fusion-4.mlir @@ -1,5 +1,5 @@ -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-fusion="mode=producer" -split-input-file | FileCheck %s --check-prefix=PRODUCER-CONSUMER -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-fusion="fusion-maximal mode=sibling" -split-input-file | FileCheck %s --check-prefix=SIBLING-MAXIMAL +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-loop-fusion{mode=producer})" -split-input-file | FileCheck %s --check-prefix=PRODUCER-CONSUMER +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-loop-fusion{fusion-maximal mode=sibling})" -split-input-file | FileCheck %s --check-prefix=SIBLING-MAXIMAL // Part I of fusion tests in mlir/test/Transforms/loop-fusion.mlir. // Part II of fusion tests in mlir/test/Transforms/loop-fusion-2.mlir diff --git a/mlir/test/Transforms/loop-fusion.mlir b/mlir/test/Transforms/loop-fusion.mlir --- a/mlir/test/Transforms/loop-fusion.mlir +++ b/mlir/test/Transforms/loop-fusion.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt -allow-unregistered-dialect %s -affine-loop-fusion -split-input-file | FileCheck %s +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="func.func(affine-loop-fusion)" -split-input-file | FileCheck %s // Part II of fusion tests in mlir/test/Transforms/loop-fusion=2.mlir. // Part III of fusion tests in mlir/test/Transforms/loop-fusion-3.mlir diff --git a/mlir/test/Transforms/pipeline-data-transfer.mlir b/mlir/test/Transforms/pipeline-data-transfer.mlir --- a/mlir/test/Transforms/pipeline-data-transfer.mlir +++ b/mlir/test/Transforms/pipeline-data-transfer.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-pipeline-data-transfer | FileCheck %s +// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -pass-pipeline="func.func(affine-pipeline-data-transfer)" | FileCheck %s // ----- diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel @@ -2436,7 +2436,6 @@ ":AffineDialect", ":Analysis", ":ArithmeticDialect", - ":FuncDialect", ":IR", ":Support", ":ViewLikeInterface", @@ -2462,7 +2461,6 @@ ":AffineAnalysis", ":AffineDialect", ":Analysis", - ":FuncDialect", ":IR", ":MemRefDialect", ":SCFDialect", @@ -2505,7 +2503,6 @@ ":Analysis", ":ArithmeticDialect", ":ArithmeticUtils", - ":FuncDialect", ":IR", ":MemRefDialect", ":Pass", @@ -2647,7 +2644,6 @@ ":AffineUtils", ":ArithmeticDialect", ":ConversionPassIncGen", - ":FuncDialect", ":IR", ":MemRefDialect", ":Pass",