diff --git a/mlir/docs/Bufferization.md b/mlir/docs/Bufferization.md --- a/mlir/docs/Bufferization.md +++ b/mlir/docs/Bufferization.md @@ -163,7 +163,7 @@ } struct TensorBufferizePass : public TensorBufferizeBase { - void runOnFunction() override { + void runOnOperation() override { auto *context = &getContext(); BufferizeTypeConverter typeConverter; RewritePatternSet patterns(context); @@ -174,7 +174,7 @@ target.addLegalDialect(); if (failed( - applyPartialConversion(getFunction(), target, std::move(patterns)))) + applyPartialConversion(getOperation(), target, std::move(patterns)))) signalPassFailure(); } }; diff --git a/mlir/docs/Rationale/Rationale.md b/mlir/docs/Rationale/Rationale.md --- a/mlir/docs/Rationale/Rationale.md +++ b/mlir/docs/Rationale/Rationale.md @@ -1054,12 +1054,12 @@ 1. MLIR makes use of extensive uniqued immutable data structures (affine expressions, types, etc are all immutable, uniqued, and immortal). -2. Constants are defined in per-function pools, instead of being globally +2. Constants are defined in per-operation pools, instead of being globally uniqued. -3. Functions themselves are not SSA values either, so they don't have the same - problem as constants. -4. FunctionPasses are copied (through their copy ctor) into one instance per +3. Functions, and other global-like operations, themselves are not SSA values + either, so they don't have the same problem as constants. +4. Passes are copied (through their copy ctor) into one instance per thread, avoiding sharing of local state across threads. -This allows MLIR function passes to support efficient multithreaded compilation +This allows MLIR passes to support efficient multithreaded compilation and code generation. diff --git a/mlir/docs/Tutorials/Toy/Ch-4.md b/mlir/docs/Tutorials/Toy/Ch-4.md --- a/mlir/docs/Tutorials/Toy/Ch-4.md +++ b/mlir/docs/Tutorials/Toy/Ch-4.md @@ -356,20 +356,20 @@ ``` At this point, each of the necessary Toy operations provide a mechanism by which -to infer their output shapes. The ShapeInferencePass is a FunctionPass: it will -run on each Function in isolation. MLIR also supports general -[OperationPasses](../../PassManagement.md/#operation-pass) that run on any isolated -operation (i.e. other function-like operations), but here our module only -contains functions, so there is no need to generalize to all operations. +to infer their output shapes. The ShapeInferencePass will operate on functions: +it will run on each Function in isolation. MLIR also supports general +[OperationPasses](../../PassManagement.md#operation-pass) that run on any +isolated operation (i.e. other function-like operations), but here our module +only contains functions, so there is no need to generalize to all operations. Implementing such a pass is done by creating a class inheriting from -`mlir::FunctionPass` and overriding the `runOnFunction()` method. +`mlir::OperationPass` and overriding the `runOnOperation()` method. ```c++ class ShapeInferencePass - : public mlir::PassWrapper { - void runOnFunction() override { - FuncOp function = getFunction(); + : public mlir::PassWrapper> { + void runOnOperation() override { + FuncOp function = getOperation(); ... } }; diff --git a/mlir/docs/Tutorials/Toy/Ch-5.md b/mlir/docs/Tutorials/Toy/Ch-5.md --- a/mlir/docs/Tutorials/Toy/Ch-5.md +++ b/mlir/docs/Tutorials/Toy/Ch-5.md @@ -56,7 +56,7 @@ conversion target: ```c++ -void ToyToAffineLoweringPass::runOnFunction() { +void ToyToAffineLoweringPass::runOnOperation() { // The first thing to define is the conversion target. This will define the // final target for this lowering. mlir::ConversionTarget target(getContext()); @@ -147,7 +147,7 @@ Now we can prepare the list of patterns to use during the lowering process: ```c++ -void ToyToAffineLoweringPass::runOnFunction() { +void ToyToAffineLoweringPass::runOnOperation() { ... // Now that the conversion target has been defined, we just need to provide @@ -166,13 +166,13 @@ `toy.print` at this time. ```c++ -void ToyToAffineLoweringPass::runOnFunction() { +void ToyToAffineLoweringPass::runOnOperation() { ... // With the target and rewrite patterns defined, we can now attempt the // conversion. The conversion will signal failure if any of our *illegal* // operations were not converted successfully. - auto function = getFunction(); + mlir::FuncOp function = getOperation(); if (mlir::failed(mlir::applyPartialConversion(function, target, patterns))) signalPassFailure(); } diff --git a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp --- a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp @@ -28,7 +28,7 @@ #include "toy/ShapeInferenceOpInterfaces.cpp.inc" namespace { -/// The ShapeInferencePass is a FunctionPass that performs intra-procedural +/// The ShapeInferencePass is a pass that performs intra-procedural /// shape inference. /// /// Algorithm: @@ -45,10 +45,10 @@ /// 3) If the worklist is empty, the algorithm succeeded. /// class ShapeInferencePass - : public mlir::PassWrapper { + : public mlir::PassWrapper> { public: - void runOnFunction() override { - auto f = getFunction(); + void runOnOperation() override { + auto f = getOperation(); // Populate the worklist with the operations that need shape inference: // these are operations that return a dynamic shape. diff --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp @@ -277,16 +277,16 @@ /// rest of the code in the Toy dialect. namespace { struct ToyToAffineLoweringPass - : public PassWrapper { + : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); } - void runOnFunction() final; + void runOnOperation() final; }; } // namespace -void ToyToAffineLoweringPass::runOnFunction() { - auto function = getFunction(); +void ToyToAffineLoweringPass::runOnOperation() { + FuncOp function = getOperation(); // We only lower the main function as we expect that all other functions have // been inlined. @@ -332,7 +332,7 @@ // conversion. The conversion will signal failure if any of our `illegal` // operations were not converted successfully. if (failed( - applyPartialConversion(getFunction(), target, std::move(patterns)))) + applyPartialConversion(getOperation(), target, std::move(patterns)))) signalPassFailure(); } diff --git a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp --- a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp @@ -28,7 +28,7 @@ #include "toy/ShapeInferenceOpInterfaces.cpp.inc" namespace { -/// The ShapeInferencePass is a FunctionPass that performs intra-procedural +/// The ShapeInferencePass is a pass that performs intra-procedural /// shape inference. /// /// Algorithm: @@ -45,10 +45,10 @@ /// 3) If the worklist is empty, the algorithm succeeded. /// class ShapeInferencePass - : public mlir::PassWrapper { + : public mlir::PassWrapper> { public: - void runOnFunction() override { - auto f = getFunction(); + void runOnOperation() override { + auto f = getOperation(); // Populate the worklist with the operations that need shape inference: // these are operations that return a dynamic shape. diff --git a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp @@ -277,16 +277,16 @@ /// rest of the code in the Toy dialect. namespace { struct ToyToAffineLoweringPass - : public PassWrapper { + : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); } - void runOnFunction() final; + void runOnOperation() final; }; } // namespace -void ToyToAffineLoweringPass::runOnFunction() { - auto function = getFunction(); +void ToyToAffineLoweringPass::runOnOperation() { + auto function = getOperation(); // We only lower the main function as we expect that all other functions have // been inlined. @@ -332,7 +332,7 @@ // conversion. The conversion will signal failure if any of our `illegal` // operations were not converted successfully. if (failed( - applyPartialConversion(getFunction(), target, std::move(patterns)))) + applyPartialConversion(getOperation(), target, std::move(patterns)))) signalPassFailure(); } diff --git a/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp --- a/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp @@ -28,7 +28,7 @@ #include "toy/ShapeInferenceOpInterfaces.cpp.inc" namespace { -/// The ShapeInferencePass is a FunctionPass that performs intra-procedural +/// The ShapeInferencePass is a pass that performs intra-procedural /// shape inference. /// /// Algorithm: @@ -45,10 +45,10 @@ /// 3) If the worklist is empty, the algorithm succeeded. /// class ShapeInferencePass - : public mlir::PassWrapper { + : public mlir::PassWrapper> { public: - void runOnFunction() override { - auto f = getFunction(); + void runOnOperation() override { + auto f = getOperation(); // Populate the worklist with the operations that need shape inference: // these are operations that return a dynamic shape. diff --git a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp @@ -277,16 +277,16 @@ /// rest of the code in the Toy dialect. namespace { struct ToyToAffineLoweringPass - : public PassWrapper { + : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); } - void runOnFunction() final; + void runOnOperation() final; }; } // namespace -void ToyToAffineLoweringPass::runOnFunction() { - auto function = getFunction(); +void ToyToAffineLoweringPass::runOnOperation() { + auto function = getOperation(); // We only lower the main function as we expect that all other functions have // been inlined. @@ -332,7 +332,7 @@ // conversion. The conversion will signal failure if any of our `illegal` // operations were not converted successfully. if (failed( - applyPartialConversion(getFunction(), target, std::move(patterns)))) + applyPartialConversion(getOperation(), target, std::move(patterns)))) signalPassFailure(); } diff --git a/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp --- a/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp @@ -28,7 +28,7 @@ #include "toy/ShapeInferenceOpInterfaces.cpp.inc" namespace { -/// The ShapeInferencePass is a FunctionPass that performs intra-procedural +/// The ShapeInferencePass is a pass that performs intra-procedural /// shape inference. /// /// Algorithm: @@ -45,10 +45,10 @@ /// 3) If the worklist is empty, the algorithm succeeded. /// class ShapeInferencePass - : public mlir::PassWrapper { + : public mlir::PassWrapper> { public: - void runOnFunction() override { - auto f = getFunction(); + void runOnOperation() override { + auto f = getOperation(); // Populate the worklist with the operations that need shape inference: // these are operations that return a dynamic shape. diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td --- a/mlir/include/mlir/Conversion/Passes.td +++ b/mlir/include/mlir/Conversion/Passes.td @@ -78,7 +78,7 @@ // ArithmeticToLLVM //===----------------------------------------------------------------------===// -def ConvertArithmeticToLLVM : FunctionPass<"convert-arith-to-llvm"> { +def ConvertArithmeticToLLVM : Pass<"convert-arith-to-llvm", "FuncOp"> { let summary = "Convert Arithmetic dialect to LLVM dialect"; let description = [{ This pass converts supported Arithmetic ops to LLVM dialect instructions. @@ -96,7 +96,7 @@ // ArithmeticToSPIRV //===----------------------------------------------------------------------===// -def ConvertArithmeticToSPIRV : FunctionPass<"convert-arith-to-spirv"> { +def ConvertArithmeticToSPIRV : Pass<"convert-arith-to-spirv", "FuncOp"> { let summary = "Convert Arithmetic dialect to SPIR-V dialect"; let constructor = "mlir::arith::createConvertArithmeticToSPIRVPass()"; let dependentDialects = ["spirv::SPIRVDialect"]; @@ -175,7 +175,7 @@ // ComplexToStandard //===----------------------------------------------------------------------===// -def ConvertComplexToStandard : FunctionPass<"convert-complex-to-standard"> { +def ConvertComplexToStandard : Pass<"convert-complex-to-standard", "FuncOp"> { let summary = "Convert Complex dialect to standard dialect"; let constructor = "mlir::createConvertComplexToStandardPass()"; let dependentDialects = ["math::MathDialect"]; @@ -343,7 +343,7 @@ // MathToLLVM //===----------------------------------------------------------------------===// -def ConvertMathToLLVM : FunctionPass<"convert-math-to-llvm"> { +def ConvertMathToLLVM : Pass<"convert-math-to-llvm", "FuncOp"> { let summary = "Convert Math dialect to LLVM dialect"; let description = [{ This pass converts supported Math ops to LLVM dialect intrinsics. @@ -503,7 +503,7 @@ // SCFToGPU //===----------------------------------------------------------------------===// -def ConvertAffineForToGPU : FunctionPass<"convert-affine-for-to-gpu"> { +def ConvertAffineForToGPU : Pass<"convert-affine-for-to-gpu", "FuncOp"> { let summary = "Convert top-level AffineFor Ops to GPU kernels"; let constructor = "mlir::createAffineForToGPUPass()"; let dependentDialects = ["gpu::GPUDialect"]; @@ -635,7 +635,7 @@ // TosaToLinalg //===----------------------------------------------------------------------===// -def TosaToLinalg : FunctionPass<"tosa-to-linalg"> { +def TosaToLinalg : Pass<"tosa-to-linalg", "FuncOp"> { let summary = "Lower TOSA to LinAlg on tensors"; let description = [{ Pass that converts TOSA operations to the equivalent operations using the @@ -649,7 +649,7 @@ // TosaToLinalgNamed //===----------------------------------------------------------------------===// -def TosaToLinalgNamed : FunctionPass<"tosa-to-linalg-named"> { +def TosaToLinalgNamed : Pass<"tosa-to-linalg-named", "FuncOp"> { let summary = "Lower TOSA to LinAlg named operations"; let description = [{ Pass that converts TOSA operations to the equivalent operations using the @@ -697,7 +697,7 @@ // VectorToGPU //===----------------------------------------------------------------------===// -def ConvertVectorToGPU : FunctionPass<"convert-vector-to-gpu"> { +def ConvertVectorToGPU : Pass<"convert-vector-to-gpu", "FuncOp"> { let summary = "Lower the operations from the vector dialect into the GPU " "dialect"; let constructor = "mlir::createConvertVectorToGPUPass()"; @@ -711,7 +711,7 @@ // VectorToSCF //===----------------------------------------------------------------------===// -def ConvertVectorToSCF : FunctionPass<"convert-vector-to-scf"> { +def ConvertVectorToSCF : Pass<"convert-vector-to-scf", "FuncOp"> { let summary = "Lower the operations from the vector dialect into the SCF " "dialect"; let constructor = "mlir::createConvertVectorToSCFPass()"; 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 @@ -51,7 +51,7 @@ /// 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 createAffineScalarReplacementPass(); +std::unique_ptr> createAffineScalarReplacementPass(); /// Creates a pass to perform tiling on loop nests. std::unique_ptr> 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,7 @@ include "mlir/Pass/PassBase.td" -def AffineDataCopyGeneration : FunctionPass<"affine-data-copy-generate"> { +def AffineDataCopyGeneration : Pass<"affine-data-copy-generate", "FuncOp"> { let summary = "Generate explicit copying for affine memory operations"; let constructor = "mlir::createAffineDataCopyGenerationPass()"; let dependentDialects = ["memref::MemRefDialect"]; @@ -44,12 +44,12 @@ } def AffineLoopInvariantCodeMotion - : FunctionPass<"affine-loop-invariant-code-motion"> { + : Pass<"affine-loop-invariant-code-motion", "FuncOp"> { let summary = "Hoist loop invariant instructions outside of affine loops"; let constructor = "mlir::createAffineLoopInvariantCodeMotionPass()"; } -def AffineLoopTiling : FunctionPass<"affine-loop-tile"> { +def AffineLoopTiling : Pass<"affine-loop-tile", "FuncOp"> { let summary = "Tile affine loop nests"; let constructor = "mlir::createLoopTilingPass()"; let options = [ @@ -66,7 +66,7 @@ ]; } -def AffineLoopUnroll : FunctionPass<"affine-loop-unroll"> { +def AffineLoopUnroll : Pass<"affine-loop-unroll", "FuncOp"> { let summary = "Unroll affine loops"; let constructor = "mlir::createLoopUnrollPass()"; let options = [ @@ -84,7 +84,7 @@ ]; } -def AffineLoopUnrollAndJam : FunctionPass<"affine-loop-unroll-jam"> { +def AffineLoopUnrollAndJam : Pass<"affine-loop-unroll-jam", "FuncOp"> { let summary = "Unroll and jam affine loops"; let constructor = "mlir::createLoopUnrollAndJamPass()"; let options = [ @@ -94,7 +94,7 @@ ]; } -def AffineScalarReplacement : FunctionPass<"affine-scalrep"> { +def AffineScalarReplacement : Pass<"affine-scalrep", "FuncOp"> { let summary = "Replace affine memref acceses by scalars by forwarding stores " "to loads and eliminating redundant loads"; let description = [{ @@ -140,7 +140,7 @@ let constructor = "mlir::createAffineScalarReplacementPass()"; } -def AffineVectorize : FunctionPass<"affine-super-vectorize"> { +def AffineVectorize : Pass<"affine-super-vectorize", "FuncOp"> { let summary = "Vectorize to a target independent n-D vector abstraction"; let constructor = "mlir::createSuperVectorizePass()"; let dependentDialects = ["vector::VectorDialect"]; @@ -166,7 +166,7 @@ ]; } -def AffineParallelize : FunctionPass<"affine-parallelize"> { +def AffineParallelize : Pass<"affine-parallelize", "FuncOp"> { let summary = "Convert affine.for ops into 1-D affine.parallel"; let constructor = "mlir::createAffineParallelizePass()"; let options = [ @@ -179,12 +179,12 @@ ]; } -def AffineLoopNormalize : FunctionPass<"affine-loop-normalize"> { +def AffineLoopNormalize : Pass<"affine-loop-normalize", "FuncOp"> { let summary = "Apply normalization transformations to affine loop-like ops"; let constructor = "mlir::createAffineLoopNormalizePass()"; } -def SimplifyAffineStructures : FunctionPass<"simplify-affine-structures"> { +def SimplifyAffineStructures : Pass<"simplify-affine-structures", "FuncOp"> { let summary = "Simplify affine expressions in maps/sets and normalize " "memrefs"; let constructor = "mlir::createSimplifyAffineStructuresPass()"; diff --git a/mlir/include/mlir/Dialect/Arithmetic/Transforms/Passes.td b/mlir/include/mlir/Dialect/Arithmetic/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/Arithmetic/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/Arithmetic/Transforms/Passes.td @@ -11,14 +11,14 @@ include "mlir/Pass/PassBase.td" -def ArithmeticBufferize : FunctionPass<"arith-bufferize"> { +def ArithmeticBufferize : Pass<"arith-bufferize", "FuncOp"> { let summary = "Bufferize Arithmetic dialect ops."; let constructor = "mlir::arith::createArithmeticBufferizePass()"; let dependentDialects = ["bufferization::BufferizationDialect", "memref::MemRefDialect"]; } -def ArithmeticExpandOps : FunctionPass<"arith-expand"> { +def ArithmeticExpandOps : Pass<"arith-expand", "FuncOp"> { let summary = "Legalize Arithmetic ops to be convertible to LLVM."; let constructor = "mlir::arith::createArithmeticExpandOpsPass()"; let dependentDialects = ["StandardOpsDialect"]; diff --git a/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h b/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h --- a/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h +++ b/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h @@ -16,7 +16,7 @@ /// Creates a pass that finalizes a partial bufferization by removing remaining /// bufferization.to_tensor and bufferization.to_memref operations. -std::unique_ptr createFinalizingBufferizePass(); +std::unique_ptr> createFinalizingBufferizePass(); //===----------------------------------------------------------------------===// // Registration diff --git a/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td b/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td @@ -11,7 +11,7 @@ include "mlir/Pass/PassBase.td" -def BufferDeallocation : FunctionPass<"buffer-deallocation"> { +def BufferDeallocation : Pass<"buffer-deallocation", "FuncOp"> { let summary = "Adds all required dealloc operations for all allocations in " "the input program"; let description = [{ @@ -88,7 +88,7 @@ let constructor = "mlir::bufferization::createBufferDeallocationPass()"; } -def FinalizingBufferize : FunctionPass<"finalizing-bufferize"> { +def FinalizingBufferize : Pass<"finalizing-bufferize", "FuncOp"> { let summary = "Finalize a partial bufferization"; let description = [{ A bufferize pass that finalizes a partial bufferization by removing diff --git a/mlir/include/mlir/Dialect/GPU/Passes.td b/mlir/include/mlir/Dialect/GPU/Passes.td --- a/mlir/include/mlir/Dialect/GPU/Passes.td +++ b/mlir/include/mlir/Dialect/GPU/Passes.td @@ -17,7 +17,7 @@ let dependentDialects = ["mlir::DLTIDialect"]; } -def GpuAsyncRegionPass : FunctionPass<"gpu-async-region"> { +def GpuAsyncRegionPass : Pass<"gpu-async-region", "FuncOp"> { let summary = "Make GPU ops async"; let constructor = "mlir::createGpuAsyncRegionPass()"; let dependentDialects = ["async::AsyncDialect"]; diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.td b/mlir/include/mlir/Dialect/Linalg/Passes.td --- a/mlir/include/mlir/Dialect/Linalg/Passes.td +++ b/mlir/include/mlir/Dialect/Linalg/Passes.td @@ -114,7 +114,7 @@ } def LinalgLowerTiledLoopsToSCF - : FunctionPass<"convert-linalg-tiled-loops-to-scf"> { + : Pass<"convert-linalg-tiled-loops-to-scf", "FuncOp"> { let summary = "Lower linalg tiled loops to SCF loops and parallel loops"; let constructor = "mlir::createConvertLinalgTiledLoopsToSCFPass()"; let dependentDialects = [ @@ -124,7 +124,7 @@ ]; } -def LinalgInlineScalarOperands : FunctionPass<"linalg-inline-scalar-operands"> { +def LinalgInlineScalarOperands : Pass<"linalg-inline-scalar-operands", "FuncOp"> { let summary = "Inline scalar operands into linalg generic ops"; let constructor = "mlir::createLinalgInlineScalarOperandsPass()"; let dependentDialects = [ @@ -132,7 +132,7 @@ ]; } -def LinalgLowerToAffineLoops : FunctionPass<"convert-linalg-to-affine-loops"> { +def LinalgLowerToAffineLoops : Pass<"convert-linalg-to-affine-loops", "FuncOp"> { let summary = "Lower the operations from the linalg dialect into affine " "loops"; let constructor = "mlir::createConvertLinalgToAffineLoopsPass()"; @@ -140,7 +140,7 @@ "AffineDialect", "linalg::LinalgDialect", "memref::MemRefDialect"]; } -def LinalgLowerToLoops : FunctionPass<"convert-linalg-to-loops"> { +def LinalgLowerToLoops : Pass<"convert-linalg-to-loops", "FuncOp"> { let summary = "Lower the operations from the linalg dialect into loops"; let constructor = "mlir::createConvertLinalgToLoopsPass()"; let dependentDialects = [ @@ -151,7 +151,7 @@ } def LinalgLowerToParallelLoops - : FunctionPass<"convert-linalg-to-parallel-loops"> { + : Pass<"convert-linalg-to-parallel-loops", "FuncOp"> { let summary = "Lower the operations from the linalg dialect into parallel " "loops"; let constructor = "mlir::createConvertLinalgToParallelLoopsPass()"; @@ -174,7 +174,7 @@ ]; } -def LinalgPromotion : FunctionPass<"linalg-promote-subviews"> { +def LinalgPromotion : Pass<"linalg-promote-subviews", "FuncOp"> { let summary = "Promote subview ops to local buffers"; let constructor = "mlir::createLinalgPromotionPass()"; let options = [ @@ -186,7 +186,7 @@ let dependentDialects = ["linalg::LinalgDialect"]; } -def LinalgTiling : FunctionPass<"linalg-tile"> { +def LinalgTiling : Pass<"linalg-tile", "FuncOp"> { let summary = "Tile operations in the linalg dialect"; let constructor = "mlir::createLinalgTilingPass()"; let dependentDialects = [ @@ -208,7 +208,7 @@ ]; } -def LinalgGeneralization : FunctionPass<"linalg-generalize-named-ops"> { +def LinalgGeneralization : Pass<"linalg-generalize-named-ops", "FuncOp"> { let summary = "Convert named ops into generic ops"; let constructor = "mlir::createLinalgGeneralizationPass()"; let dependentDialects = ["linalg::LinalgDialect"]; @@ -253,7 +253,7 @@ } def LinalgStrategyTileAndFusePass - : FunctionPass<"linalg-strategy-tile-and-fuse-pass"> { + : Pass<"linalg-strategy-tile-and-fuse-pass", "FuncOp"> { let summary = "Configurable pass to apply pattern-based tiling and fusion."; let constructor = "mlir::createLinalgStrategyTileAndFusePass()"; let options = [ @@ -265,7 +265,7 @@ } def LinalgStrategyTilePass - : FunctionPass<"linalg-strategy-tile-pass"> { + : Pass<"linalg-strategy-tile-pass", "FuncOp"> { let summary = "Configurable pass to apply pattern-based linalg tiling."; let constructor = "mlir::createLinalgStrategyTilePass()"; let dependentDialects = ["linalg::LinalgDialect"]; @@ -278,7 +278,7 @@ } def LinalgStrategyPadPass - : FunctionPass<"linalg-strategy-pad-pass"> { + : Pass<"linalg-strategy-pad-pass", "FuncOp"> { let summary = "Configurable pass to apply padding and hoisting."; let constructor = "mlir::createLinalgStrategyPadPass()"; let dependentDialects = ["linalg::LinalgDialect"]; @@ -291,7 +291,7 @@ } def LinalgStrategyPromotePass - : FunctionPass<"linalg-strategy-promote-pass"> { + : Pass<"linalg-strategy-promote-pass", "FuncOp"> { let summary = "Configurable pass to apply pattern-based linalg promotion."; let constructor = "mlir::createLinalgStrategyPromotePass()"; let dependentDialects = ["linalg::LinalgDialect"]; @@ -304,7 +304,7 @@ } def LinalgStrategyGeneralizePass - : FunctionPass<"linalg-strategy-generalize-pass"> { + : Pass<"linalg-strategy-generalize-pass", "FuncOp"> { let summary = "Configurable pass to apply pattern-based generalization."; let constructor = "mlir::createLinalgStrategyGeneralizePass()"; let dependentDialects = ["linalg::LinalgDialect"]; @@ -318,7 +318,7 @@ // TODO: if/when we need finer control add an anchorOp option. def LinalgStrategyDecomposePass - : FunctionPass<"linalg-strategy-decompose-pass"> { + : Pass<"linalg-strategy-decompose-pass", "FuncOp"> { let summary = "Configurable pass to apply pattern-based generalization."; let constructor = "mlir::createLinalgStrategyDecomposePass()"; let dependentDialects = ["linalg::LinalgDialect"]; @@ -329,7 +329,7 @@ } def LinalgStrategyInterchangePass - : FunctionPass<"linalg-strategy-interchange-pass"> { + : Pass<"linalg-strategy-interchange-pass", "FuncOp"> { let summary = "Configurable pass to apply pattern-based iterator interchange."; let constructor = "mlir::createLinalgStrategyInterchangePass()"; let dependentDialects = ["linalg::LinalgDialect"]; @@ -340,7 +340,7 @@ } def LinalgStrategyVectorizePass - : FunctionPass<"linalg-strategy-vectorize-pass"> { + : Pass<"linalg-strategy-vectorize-pass", "FuncOp"> { let summary = "Configurable pass to apply pattern-based linalg vectorization."; let constructor = "mlir::createLinalgStrategyVectorizePass()"; let dependentDialects = ["linalg::LinalgDialect"]; @@ -355,7 +355,7 @@ } def LinalgStrategyEnablePass - : FunctionPass<"linalg-strategy-enable-pass"> { + : Pass<"linalg-strategy-enable-pass", "FuncOp"> { let summary = "Configurable pass to enable the application of other " "pattern-based linalg passes."; let constructor = "mlir::createLinalgStrategyEnablePass()"; @@ -367,7 +367,7 @@ } def LinalgStrategyLowerVectorsPass - : FunctionPass<"linalg-strategy-lower-vectors-pass"> { + : Pass<"linalg-strategy-lower-vectors-pass", "FuncOp"> { let summary = "Configurable pass to lower vector operations."; let constructor = "mlir::createLinalgStrategyLowerVectorsPass()"; let dependentDialects = ["linalg::LinalgDialect"]; @@ -378,7 +378,7 @@ } def LinalgStrategyRemoveMarkersPass - : FunctionPass<"linalg-strategy-remove-markers-pass"> { + : Pass<"linalg-strategy-remove-markers-pass", "FuncOp"> { let summary = "Cleanup pass that drops markers."; let constructor = "mlir::createLinalgStrategyRemoveMarkersPass()"; let dependentDialects = ["linalg::LinalgDialect"]; diff --git a/mlir/include/mlir/Dialect/Quant/Passes.td b/mlir/include/mlir/Dialect/Quant/Passes.td --- a/mlir/include/mlir/Dialect/Quant/Passes.td +++ b/mlir/include/mlir/Dialect/Quant/Passes.td @@ -11,14 +11,14 @@ include "mlir/Pass/PassBase.td" -def QuantConvertConst : FunctionPass<"quant-convert-const"> { +def QuantConvertConst : Pass<"quant-convert-const", "FuncOp"> { let summary = "Converts constants followed by qbarrier to actual quantized " "values"; let constructor = "mlir::quant::createConvertConstPass()"; } def QuantConvertSimulatedQuant - : FunctionPass<"quant-convert-simulated-quantization"> { + : Pass<"quant-convert-simulated-quantization", "FuncOp"> { let summary = "Converts training-time simulated quantization ops to " "corresponding quantize/dequantize casts"; let constructor = "mlir::quant::createConvertSimulatedQuantPass()"; diff --git a/mlir/include/mlir/Dialect/SCF/Passes.td b/mlir/include/mlir/Dialect/SCF/Passes.td --- a/mlir/include/mlir/Dialect/SCF/Passes.td +++ b/mlir/include/mlir/Dialect/SCF/Passes.td @@ -11,7 +11,7 @@ include "mlir/Pass/PassBase.td" -def SCFBufferize : FunctionPass<"scf-bufferize"> { +def SCFBufferize : Pass<"scf-bufferize", "FuncOp"> { let summary = "Bufferize the scf dialect."; let constructor = "mlir::createSCFBufferizePass()"; let dependentDialects = ["bufferization::BufferizationDialect", @@ -21,7 +21,7 @@ // Note: Making these canonicalization patterns would require a dependency // of the SCF dialect on the Affine/Tensor/MemRef dialects or vice versa. def SCFForLoopCanonicalization - : FunctionPass<"for-loop-canonicalization"> { + : Pass<"for-loop-canonicalization", "FuncOp"> { let summary = "Canonicalize operations within scf.for loop bodies"; let constructor = "mlir::createSCFForLoopCanonicalizationPass()"; let dependentDialects = ["AffineDialect", "tensor::TensorDialect", @@ -29,7 +29,7 @@ } def SCFForLoopPeeling - : FunctionPass<"for-loop-peeling"> { + : Pass<"for-loop-peeling", "FuncOp"> { let summary = "Peel `for` loops at their upper bounds."; let constructor = "mlir::createForLoopPeelingPass()"; let options = [ @@ -42,7 +42,7 @@ } def SCFForLoopSpecialization - : FunctionPass<"for-loop-specialization"> { + : Pass<"for-loop-specialization", "FuncOp"> { let summary = "Specialize `for` loops for vectorization"; let constructor = "mlir::createForLoopSpecializationPass()"; } @@ -53,12 +53,12 @@ } def SCFParallelLoopSpecialization - : FunctionPass<"parallel-loop-specialization"> { + : Pass<"parallel-loop-specialization", "FuncOp"> { let summary = "Specialize parallel loops for vectorization"; let constructor = "mlir::createParallelLoopSpecializationPass()"; } -def SCFParallelLoopTiling : FunctionPass<"parallel-loop-tiling"> { +def SCFParallelLoopTiling : Pass<"parallel-loop-tiling", "FuncOp"> { let summary = "Tile parallel loops"; let constructor = "mlir::createParallelLoopTilingPass()"; let options = [ @@ -80,7 +80,7 @@ } def SCFForToWhileLoop - : FunctionPass<"scf-for-to-while"> { + : Pass<"scf-for-to-while", "FuncOp"> { let summary = "Convert SCF for loops to SCF while loops"; let constructor = "mlir::createForToWhileLoopPass()"; let description = [{ diff --git a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h --- a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h +++ b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h @@ -37,7 +37,7 @@ // // After this pass, no cstr_ operations exist. void populateRemoveShapeConstraintsPatterns(RewritePatternSet &patterns); -std::unique_ptr createRemoveShapeConstraintsPass(); +std::unique_ptr> createRemoveShapeConstraintsPass(); /// Populates patterns for shape dialect structural type conversions and sets up /// the provided ConversionTarget with the appropriate legality configuration @@ -59,7 +59,7 @@ // Note that most shape dialect ops must be converted to std before // bufferization happens, as they are intended to be bufferized at the std // level. -std::unique_ptr createShapeBufferizePass(); +std::unique_ptr> createShapeBufferizePass(); //===----------------------------------------------------------------------===// // Registration diff --git a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td @@ -11,18 +11,18 @@ include "mlir/Pass/PassBase.td" -def RemoveShapeConstraints : FunctionPass<"remove-shape-constraints"> { +def RemoveShapeConstraints : Pass<"remove-shape-constraints", "FuncOp"> { let summary = "Replace all cstr_ ops with a true witness"; let constructor = "mlir::createRemoveShapeConstraintsPass()"; } -def ShapeToShapeLowering : FunctionPass<"shape-to-shape-lowering"> { +def ShapeToShapeLowering : Pass<"shape-to-shape-lowering", "FuncOp"> { let summary = "Legalize Shape dialect to be convertible to Standard"; let constructor = "mlir::createShapeToShapeLowering()"; } // TODO: Generalize this to allow any type conversions desired. -def ShapeBufferize : FunctionPass<"shape-bufferize"> { +def ShapeBufferize : Pass<"shape-bufferize", "FuncOp"> { let summary = "Bufferize the shape dialect."; let constructor = "mlir::createShapeBufferizePass()"; let dependentDialects = ["bufferization::BufferizationDialect", diff --git a/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.td b/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.td @@ -11,14 +11,14 @@ include "mlir/Pass/PassBase.td" -def StdBufferize : FunctionPass<"std-bufferize"> { +def StdBufferize : Pass<"std-bufferize", "FuncOp"> { let summary = "Bufferize the std dialect"; let constructor = "mlir::createStdBufferizePass()"; let dependentDialects = ["bufferization::BufferizationDialect", "memref::MemRefDialect", "scf::SCFDialect"]; } -def StdExpandOps : FunctionPass<"std-expand"> { +def StdExpandOps : Pass<"std-expand", "FuncOp"> { let summary = "Legalize std operations to be convertible to LLVM."; let constructor = "mlir::createStdExpandOpsPass()"; } diff --git a/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.td b/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.td @@ -11,7 +11,7 @@ include "mlir/Pass/PassBase.td" -def TensorBufferize : FunctionPass<"tensor-bufferize"> { +def TensorBufferize : Pass<"tensor-bufferize", "FuncOp"> { let summary = "Bufferize the `tensor` dialect"; let constructor = "mlir::createTensorBufferizePass()"; let dependentDialects = [ diff --git a/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td b/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td @@ -15,7 +15,7 @@ include "mlir/Pass/PassBase.td" -def TosaInferShapes : FunctionPass<"tosa-infer-shapes"> { +def TosaInferShapes : Pass<"tosa-infer-shapes", "FuncOp"> { let summary = "Propagate shapes across TOSA operations"; let description = [{ Pass that uses operand types and propagates shapes to TOSA operations. @@ -30,7 +30,7 @@ ]; } -def TosaMakeBroadcastable : FunctionPass<"tosa-make-broadcastable"> { +def TosaMakeBroadcastable : Pass<"tosa-make-broadcastable", "FuncOp"> { let summary = "TOSA rank Reshape to enable Broadcasting"; let description = [{ Pass that enables broadcast by making all input arrays have the same @@ -43,7 +43,8 @@ let constructor = "createTosaMakeBroadcastablePass()"; } -def TosaOptionalDecompositions : FunctionPass<"tosa-optional-decompositions"> { +def TosaOptionalDecompositions + : Pass<"tosa-optional-decompositions", "FuncOp"> { let summary = "Applies Tosa operations optional decompositions"; let description = [{ Pass to apply the Tosa operations decompositions diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -170,7 +170,7 @@ return *passState; } - /// Return the MLIR context for the current function being transformed. + /// Return the MLIR context for the current operation being transformed. MLIRContext &getContext() { return *getOperation()->getContext(); } /// The polymorphic API that runs the pass over the currently held operation. @@ -332,7 +332,7 @@ /// - modify any state within the parent operation, this includes adding /// additional operations. /// -/// Derived function passes are expected to provide the following: +/// Derived operation passes are expected to provide the following: /// - A 'void runOnOperation()' method. /// - A 'StringRef getName() const' method. /// - A 'std::unique_ptr clonePass() const' method. @@ -365,7 +365,7 @@ /// - modify any state within the parent operation, this includes adding /// additional operations. /// -/// Derived function passes are expected to provide the following: +/// Derived operation passes are expected to provide the following: /// - A 'void runOnOperation()' method. /// - A 'StringRef getName() const' method. /// - A 'std::unique_ptr clonePass() const' method. @@ -375,6 +375,8 @@ OperationPass(const OperationPass &) = default; }; +/// NOTICE: This class is deprecated in favor of `OperationPass` +/// and will be removed soon. /// A model for providing function pass specific utilities. /// /// Derived function passes are expected to provide the following: diff --git a/mlir/include/mlir/Pass/PassBase.td b/mlir/include/mlir/Pass/PassBase.td --- a/mlir/include/mlir/Pass/PassBase.td +++ b/mlir/include/mlir/Pass/PassBase.td @@ -92,6 +92,8 @@ class Pass : PassBase">; +/// NOTICE: This class is deprecated in favor of `Pass<..., "mlir::FuncOp">` +/// and will be removed soon. // This class represents an mlir::FunctionPass. class FunctionPass : PassBase; diff --git a/mlir/include/mlir/Transforms/Passes.td b/mlir/include/mlir/Transforms/Passes.td --- a/mlir/include/mlir/Transforms/Passes.td +++ b/mlir/include/mlir/Transforms/Passes.td @@ -16,7 +16,7 @@ include "mlir/Pass/PassBase.td" include "mlir/Rewrite/PassUtil.td" -def AffineLoopFusion : FunctionPass<"affine-loop-fusion"> { +def AffineLoopFusion : Pass<"affine-loop-fusion", "FuncOp"> { let summary = "Fuse affine loop nests"; let description = [{ This pass performs fusion of loop nests using a slicing-based approach. It @@ -149,7 +149,7 @@ } def AffinePipelineDataTransfer - : FunctionPass<"affine-pipeline-data-transfer"> { + : Pass<"affine-pipeline-data-transfer", "FuncOp"> { let summary = "Pipeline non-blocking data transfers between explicitly " "managed levels of the memory hierarchy"; let description = [{ @@ -217,7 +217,7 @@ let constructor = "mlir::createPipelineDataTransferPass()"; } -def BufferHoisting : FunctionPass<"buffer-hoisting"> { +def BufferHoisting : Pass<"buffer-hoisting", "FuncOp"> { let summary = "Optimizes placement of allocation operations by moving them " "into common dominators and out of nested regions"; let description = [{ @@ -227,7 +227,7 @@ let constructor = "mlir::createBufferHoistingPass()"; } -def BufferLoopHoisting : FunctionPass<"buffer-loop-hoisting"> { +def BufferLoopHoisting : Pass<"buffer-loop-hoisting", "FuncOp"> { let summary = "Optimizes placement of allocation operations by moving them " "out of loop nests"; let description = [{ @@ -237,7 +237,7 @@ let constructor = "mlir::createBufferLoopHoistingPass()"; } -def PromoteBuffersToStack : FunctionPass<"promote-buffers-to-stack"> { +def PromoteBuffersToStack : Pass<"promote-buffers-to-stack", "FuncOp"> { let summary = "Promotes heap-based allocations to automatically managed " "stack-based allocations"; let description = [{ @@ -384,7 +384,7 @@ ]; } -def LoopCoalescing : FunctionPass<"loop-coalescing"> { +def LoopCoalescing : Pass<"loop-coalescing", "FuncOp"> { let summary = "Coalesce nested loops with independent bounds into a single " "loop"; let constructor = "mlir::createLoopCoalescingPass()"; diff --git a/mlir/lib/Conversion/ArithmeticToLLVM/ArithmeticToLLVM.cpp b/mlir/lib/Conversion/ArithmeticToLLVM/ArithmeticToLLVM.cpp --- a/mlir/lib/Conversion/ArithmeticToLLVM/ArithmeticToLLVM.cpp +++ b/mlir/lib/Conversion/ArithmeticToLLVM/ArithmeticToLLVM.cpp @@ -233,7 +233,7 @@ : public ConvertArithmeticToLLVMBase { ConvertArithmeticToLLVMPass() = default; - void runOnFunction() override { + void runOnOperation() override { LLVMConversionTarget target(getContext()); RewritePatternSet patterns(&getContext()); @@ -245,8 +245,8 @@ mlir::arith::populateArithmeticToLLVMConversionPatterns(converter, patterns); - if (failed( - applyPartialConversion(getFunction(), target, std::move(patterns)))) + if (failed(applyPartialConversion(getOperation(), target, + std::move(patterns)))) signalPassFailure(); } }; diff --git a/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp b/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp --- a/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp +++ b/mlir/lib/Conversion/ArithmeticToSPIRV/ArithmeticToSPIRV.cpp @@ -837,7 +837,7 @@ namespace { struct ConvertArithmeticToSPIRVPass : public ConvertArithmeticToSPIRVBase { - void runOnFunction() override { + void runOnOperation() override { auto module = getOperation()->getParentOfType(); auto targetAttr = spirv::lookupTargetEnvOrDefault(module); auto target = SPIRVConversionTarget::get(targetAttr); diff --git a/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp b/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp --- a/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp +++ b/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp @@ -637,11 +637,11 @@ namespace { struct ConvertComplexToStandardPass : public ConvertComplexToStandardBase { - void runOnFunction() override; + void runOnOperation() override; }; -void ConvertComplexToStandardPass::runOnFunction() { - auto function = getFunction(); +void ConvertComplexToStandardPass::runOnOperation() { + auto function = getOperation(); // Convert to the Standard dialect using the converter defined above. RewritePatternSet patterns(&getContext()); diff --git a/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp b/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp --- a/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp +++ b/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp @@ -250,13 +250,13 @@ : public ConvertMathToLLVMBase { ConvertMathToLLVMPass() = default; - void runOnFunction() override { + void runOnOperation() override { RewritePatternSet patterns(&getContext()); LLVMTypeConverter converter(&getContext()); populateMathToLLVMConversionPatterns(converter, patterns); LLVMConversionTarget target(getContext()); - if (failed( - applyPartialConversion(getFunction(), target, std::move(patterns)))) + if (failed(applyPartialConversion(getOperation(), target, + std::move(patterns)))) signalPassFailure(); } }; diff --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp --- a/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp +++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp @@ -34,8 +34,8 @@ this->numThreadDims = numThreadDims; } - void runOnFunction() override { - for (Operation &op : llvm::make_early_inc_range(getFunction().getOps())) { + void runOnOperation() override { + for (Operation &op : llvm::make_early_inc_range(getOperation().getOps())) { if (auto forOp = dyn_cast(&op)) { if (failed(convertAffineLoopNestToGPULaunch(forOp, numBlockDims, numThreadDims))) diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamedPass.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamedPass.cpp --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamedPass.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamedPass.cpp @@ -38,7 +38,7 @@ tensor::TensorDialect, scf::SCFDialect>(); } - void runOnFunction() override { + void runOnOperation() override { RewritePatternSet patterns(&getContext()); ConversionTarget target(getContext()); target.addLegalDialect(); } - void runOnFunction() override { + void runOnOperation() override { RewritePatternSet patterns(&getContext()); ConversionTarget target(getContext()); target.addLegalDialect { - void runOnFunction() override { - RewritePatternSet patterns(getFunction().getContext()); + void runOnOperation() override { + RewritePatternSet patterns(getOperation().getContext()); populatePrepareVectorToMMAPatterns(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); - convertVectorToMMAOps(getFunction()); + convertVectorToMMAOps(getOperation()); } }; diff --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp --- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp +++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp @@ -1284,7 +1284,7 @@ this->lowerTensors = options.lowerTensors; } - void runOnFunction() override { + void runOnOperation() override { VectorTransferToSCFOptions options; options.unroll = fullUnroll; options.targetRank = targetRank; @@ -1293,16 +1293,16 @@ // Lower permutation maps first. if (lowerPermutationMaps) { - RewritePatternSet lowerTransferPatterns(getFunction().getContext()); + RewritePatternSet lowerTransferPatterns(getOperation().getContext()); mlir::vector::populateVectorTransferPermutationMapLoweringPatterns( lowerTransferPatterns); - (void)applyPatternsAndFoldGreedily(getFunction(), + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(lowerTransferPatterns)); } - RewritePatternSet patterns(getFunction().getContext()); + RewritePatternSet patterns(getOperation().getContext()); populateVectorToSCFConversionPatterns(patterns, options); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; 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 @@ -65,7 +65,7 @@ this->fastMemoryCapacity = fastMemCapacityBytes / 1024; } - void runOnFunction() override; + void runOnOperation() override; void runOnBlock(Block *block, DenseSet ©Nests); // Constant zero index to avoid too many duplicates. @@ -196,8 +196,8 @@ } } -void AffineDataCopyGeneration::runOnFunction() { - FuncOp f = getFunction(); +void AffineDataCopyGeneration::runOnOperation() { + FuncOp 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 @@ -44,7 +44,7 @@ /// uses. struct LoopInvariantCodeMotion : public AffineLoopInvariantCodeMotionBase { - void runOnFunction() override; + void runOnOperation() override; void runOnAffineForOp(AffineForOp forOp); }; } // namespace @@ -227,11 +227,11 @@ LLVM_DEBUG(forOp->print(llvm::dbgs() << "Modified loop\n")); } -void LoopInvariantCodeMotion::runOnFunction() { +void LoopInvariantCodeMotion::runOnOperation() { // Walk through all loops in a function in innermost-loop-first order. This // way, we first LICM from the inner loop, and place the ops in // the outer loop, which in turn can be further LICM'ed. - getFunction().walk([&](AffineForOp op) { + getOperation().walk([&](AffineForOp op) { LLVM_DEBUG(op->print(llvm::dbgs() << "\nOriginal loop\n")); runOnAffineForOp(op); }); 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 @@ -25,8 +25,8 @@ struct AffineLoopNormalizePass : public AffineLoopNormalizeBase { - void runOnFunction() override { - getFunction().walk([](Operation *op) { + void runOnOperation() override { + getOperation().walk([](Operation *op) { if (auto affineParallel = dyn_cast(op)) normalizeAffineParallel(affineParallel); else if (auto affineFor = dyn_cast(op)) 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 @@ -32,7 +32,7 @@ namespace { /// Convert all parallel affine.for op into 1-D affine.parallel op. struct AffineParallelize : public AffineParallelizeBase { - void runOnFunction() override; + void runOnOperation() override; }; /// Descriptor of a potentially parallelizable loop. @@ -47,8 +47,8 @@ }; } // namespace -void AffineParallelize::runOnFunction() { - FuncOp f = getFunction(); +void AffineParallelize::runOnOperation() { + FuncOp f = getOperation(); // The walker proceeds in pre-order to process the outer loops first // and control the number of outer parallel loops. 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 @@ -29,16 +29,17 @@ namespace { struct AffineScalarReplacement : public AffineScalarReplacementBase { - void runOnFunction() override; + void runOnOperation() override; }; } // namespace -std::unique_ptr mlir::createAffineScalarReplacementPass() { +std::unique_ptr> +mlir::createAffineScalarReplacementPass() { return std::make_unique(); } -void AffineScalarReplacement::runOnFunction() { - affineScalarReplace(getFunction(), getAnalysis(), +void AffineScalarReplacement::runOnOperation() { + affineScalarReplace(getOperation(), getAnalysis(), getAnalysis()); } 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 @@ -38,7 +38,7 @@ this->cacheSizeInKiB = cacheSizeBytes / 1024; } - void runOnFunction() override; + void runOnOperation() override; void getTileSizes(ArrayRef band, SmallVectorImpl *tileSizes); @@ -160,10 +160,10 @@ adjustToDivisorsOfTripCounts(band, tileSizes); } -void LoopTiling::runOnFunction() { +void LoopTiling::runOnOperation() { // Bands of loops to tile. std::vector> bands; - getTileableBands(getFunction(), &bands); + getTileableBands(getOperation(), &bands); // Tile each band. for (auto &band : bands) { 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 @@ -54,7 +54,7 @@ this->unrollFull = unrollFull; } - void runOnFunction() override; + void runOnOperation() override; /// Unroll this for op. Returns failure if nothing was done. LogicalResult runOnAffineForOp(AffineForOp forOp); @@ -82,7 +82,11 @@ }); } -void LoopUnroll::runOnFunction() { +void LoopUnroll::runOnOperation() { + FuncOp func = getOperation(); + if (func.isExternal()) + return; + if (unrollFull && unrollFullThreshold.hasValue()) { // Store short loops as we walk. SmallVector loops; @@ -90,7 +94,7 @@ // Gathers all loops with trip count <= minTripCount. Do a post order walk // so that loops are gathered from innermost to outermost (or else unrolling // an outer one may delete gathered inner ones). - getFunction().walk([&](AffineForOp forOp) { + getOperation().walk([&](AffineForOp forOp) { Optional tripCount = getConstantTripCount(forOp); if (tripCount.hasValue() && tripCount.getValue() <= unrollFullThreshold) loops.push_back(forOp); @@ -101,7 +105,6 @@ } // If the call back is provided, we will recurse until no loops are found. - FuncOp func = getFunction(); SmallVector loops; for (unsigned i = 0; i < numRepetitions || getUnrollFactor; i++) { loops.clear(); 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 @@ -59,7 +59,7 @@ this->unrollJamFactor = *unrollJamFactor; } - void runOnFunction() override; + void runOnOperation() override; }; } // namespace @@ -69,11 +69,14 @@ unrollJamFactor == -1 ? None : Optional(unrollJamFactor)); } -void LoopUnrollAndJam::runOnFunction() { +void LoopUnrollAndJam::runOnOperation() { + if (getOperation().isExternal()) + return; + // Currently, just the outermost loop from the first loop nest is // unroll-and-jammed by this pass. However, runOnAffineForOp can be called on // any for operation. - auto &entryBlock = getFunction().front(); + auto &entryBlock = getOperation().front(); if (auto forOp = dyn_cast(entryBlock.front())) (void)loopUnrollJamByFactor(forOp, unrollJamFactor); } 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 @@ -30,7 +30,7 @@ /// identity layout ones. struct SimplifyAffineStructures : public SimplifyAffineStructuresBase { - void runOnFunction() override; + void runOnOperation() override; /// Utility to simplify an affine attribute and update its entry in the parent /// operation if necessary. @@ -76,8 +76,8 @@ return std::make_unique(); } -void SimplifyAffineStructures::runOnFunction() { - auto func = getFunction(); +void SimplifyAffineStructures::runOnOperation() { + auto func = getOperation(); simplifiedAttributes.clear(); RewritePatternSet patterns(func.getContext()); AffineApplyOp::getCanonicalizationPatterns(patterns, func.getContext()); 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 @@ -608,7 +608,7 @@ struct Vectorize : public AffineVectorizeBase { Vectorize() = default; Vectorize(ArrayRef virtualVectorSize); - void runOnFunction() override; + void runOnOperation() override; }; } // namespace @@ -1709,8 +1709,8 @@ /// Applies vectorization to the current function by searching over a bunch of /// predetermined patterns. -void Vectorize::runOnFunction() { - FuncOp f = getFunction(); +void Vectorize::runOnOperation() { + FuncOp f = getOperation(); if (!fastestVaryingPattern.empty() && fastestVaryingPattern.size() != vectorSizes.size()) { f.emitRemark("Fastest varying pattern specified with different size than " diff --git a/mlir/lib/Dialect/Arithmetic/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Arithmetic/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/Arithmetic/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Arithmetic/Transforms/Bufferize.cpp @@ -35,7 +35,7 @@ /// Pass to bufferize Arithmetic ops. struct ArithmeticBufferizePass : public ArithmeticBufferizeBase { - void runOnFunction() override { + void runOnOperation() override { bufferization::BufferizeTypeConverter typeConverter; RewritePatternSet patterns(&getContext()); ConversionTarget target(getContext()); @@ -49,8 +49,8 @@ return typeConverter.isLegal(op.getType()); }); - if (failed( - applyPartialConversion(getFunction(), target, std::move(patterns)))) + if (failed(applyPartialConversion(getOperation(), target, + std::move(patterns)))) signalPassFailure(); } }; diff --git a/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp b/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp --- a/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp +++ b/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp @@ -189,7 +189,7 @@ struct ArithmeticExpandOpsPass : public ArithmeticExpandOpsBase { - void runOnFunction() override { + void runOnOperation() override { RewritePatternSet patterns(&getContext()); ConversionTarget target(getContext()); @@ -209,8 +209,8 @@ arith::MinUIOp >(); // clang-format on - if (failed( - applyPartialConversion(getFunction(), target, std::move(patterns)))) + if (failed(applyPartialConversion(getOperation(), target, + std::move(patterns)))) signalPassFailure(); } }; diff --git a/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp b/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp --- a/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp @@ -638,9 +638,12 @@ registry.addOpInterface(); } - void runOnFunction() override { + void runOnOperation() override { + FuncOp func = getOperation(); + if (func.isExternal()) + return; + // Ensure that there are supported loops only. - FuncOp func = getFunction(); Backedges backedges(func); if (backedges.size()) { func.emitError("Only structured control-flow loops are supported."); diff --git a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp @@ -98,8 +98,8 @@ using FinalizingBufferizeBase< FinalizingBufferizePass>::FinalizingBufferizeBase; - void runOnFunction() override { - auto func = getFunction(); + void runOnOperation() override { + auto func = getOperation(); auto *context = &getContext(); BufferizeTypeConverter typeConverter; @@ -125,7 +125,7 @@ }; } // namespace -std::unique_ptr +std::unique_ptr> mlir::bufferization::createFinalizingBufferizePass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp b/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp --- a/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp @@ -31,7 +31,7 @@ struct ThreadTokenCallback; struct DeferWaitCallback; struct SingleTokenUseCallback; - void runOnFunction() override; + void runOnOperation() override; }; } // namespace @@ -327,14 +327,14 @@ // Replaces synchronous GPU ops in the op's region with asynchronous ones and // inserts the necessary synchronization (as gpu.wait ops). Assumes sequential // execution semantics and that no GPU ops are asynchronous yet. -void GpuAsyncRegionPass::runOnFunction() { - if (getFunction()->walk(ThreadTokenCallback(getContext())).wasInterrupted()) +void GpuAsyncRegionPass::runOnOperation() { + if (getOperation()->walk(ThreadTokenCallback(getContext())).wasInterrupted()) return signalPassFailure(); // Collect gpu.wait ops that we can move out of async.execute regions. - getFunction().getRegion().walk(DeferWaitCallback()); + getOperation().getRegion().walk(DeferWaitCallback()); // Makes each !gpu.async.token returned from async.execute op have single use. - getFunction().getRegion().walk(SingleTokenUseCallback()); + getOperation().getRegion().walk(SingleTokenUseCallback()); } std::unique_ptr> mlir::createGpuAsyncRegionPass() { diff --git a/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp @@ -68,13 +68,13 @@ struct LinalgGeneralizationPass : public LinalgGeneralizationBase { - void runOnFunction() override; + void runOnOperation() override; }; } // namespace -void LinalgGeneralizationPass::runOnFunction() { - FuncOp func = getFunction(); +void LinalgGeneralizationPass::runOnOperation() { + FuncOp func = getOperation(); RewritePatternSet patterns(&getContext()); populateLinalgNamedOpsGeneralizationPatterns(patterns); (void)applyPatternsAndFoldGreedily(func.getBody(), std::move(patterns)); diff --git a/mlir/lib/Dialect/Linalg/Transforms/InlineScalarOperands.cpp b/mlir/lib/Dialect/Linalg/Transforms/InlineScalarOperands.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/InlineScalarOperands.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/InlineScalarOperands.cpp @@ -97,8 +97,8 @@ /// Pass that removes unit-extent dims within generic ops. struct LinalgInlineScalarOperandsPass : public LinalgInlineScalarOperandsBase { - void runOnFunction() override { - FuncOp funcOp = getFunction(); + void runOnOperation() override { + FuncOp funcOp = getOperation(); MLIRContext *context = funcOp.getContext(); RewritePatternSet patterns(context); diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp @@ -52,8 +52,8 @@ this->anchorOpName.setValue(opName.str()); } - void runOnFunction() override { - auto funcOp = getFunction(); + void runOnOperation() override { + auto funcOp = getOperation(); if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName) return; @@ -88,8 +88,8 @@ this->anchorOpName.setValue(opName.str()); } - void runOnFunction() override { - auto funcOp = getFunction(); + void runOnOperation() override { + auto funcOp = getOperation(); if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName) return; @@ -121,8 +121,8 @@ this->anchorOpName.setValue(opName.str()); } - void runOnFunction() override { - auto funcOp = getFunction(); + void runOnOperation() override { + auto funcOp = getOperation(); if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName) return; @@ -153,8 +153,8 @@ this->anchorOpName.setValue(opName.str()); } - void runOnFunction() override { - auto funcOp = getFunction(); + void runOnOperation() override { + auto funcOp = getOperation(); if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName) return; @@ -184,8 +184,8 @@ LinalgStrategyDecomposePass(LinalgTransformationFilter filter) : filter(std::move(filter)) {} - void runOnFunction() override { - auto funcOp = getFunction(); + void runOnOperation() override { + auto funcOp = getOperation(); if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName) return; RewritePatternSet decompositionPattern(funcOp.getContext()); @@ -210,8 +210,8 @@ iteratorInterchange.end()), filter(std::move(filter)) {} - void runOnFunction() override { - auto funcOp = getFunction(); + void runOnOperation() override { + auto funcOp = getOperation(); if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName) return; @@ -241,8 +241,8 @@ this->anchorOpName.setValue(opName.str()); } - void runOnFunction() override { - auto funcOp = getFunction(); + void runOnOperation() override { + auto funcOp = getOperation(); if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName) return; @@ -275,8 +275,8 @@ this->vectorizePadding.setValue(padVectorize); } - void runOnFunction() override { - auto funcOp = getFunction(); + void runOnOperation() override { + auto funcOp = getOperation(); if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName) return; @@ -325,8 +325,8 @@ LinalgTransformationFilter filt) : options(opt), filter(std::move(filt)) {} - void runOnFunction() override { - auto funcOp = getFunction(); + void runOnOperation() override { + auto funcOp = getOperation(); if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName) return; @@ -375,8 +375,8 @@ LinalgTransformationFilter filt) : options(opt), filter(std::move(filt)) {} - void runOnFunction() override { - auto funcOp = getFunction(); + void runOnOperation() override { + auto funcOp = getOperation(); if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName) return; @@ -436,8 +436,8 @@ : public LinalgStrategyRemoveMarkersPassBase< LinalgStrategyRemoveMarkersPass> { - void runOnFunction() override { - auto funcOp = getFunction(); + void runOnOperation() override { + auto funcOp = getOperation(); if (!anchorFuncName.empty() && funcOp.getName() != anchorFuncName) return; funcOp.walk([](LinalgOp op) { diff --git a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp @@ -381,8 +381,8 @@ void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); } - void runOnFunction() override { - lowerLinalgToLoopsImpl(getFunction()); + void runOnOperation() override { + lowerLinalgToLoopsImpl(getOperation()); } }; @@ -390,25 +390,25 @@ void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); } - void runOnFunction() override { - lowerLinalgToLoopsImpl(getFunction()); + void runOnOperation() override { + lowerLinalgToLoopsImpl(getOperation()); } }; struct LowerToParallelLoops : public LinalgLowerToParallelLoopsBase { - void runOnFunction() override { - lowerLinalgToLoopsImpl(getFunction()); + void runOnOperation() override { + lowerLinalgToLoopsImpl(getOperation()); } }; struct LowerTiledLoopsToSCF : public LinalgLowerTiledLoopsToSCFBase { - void runOnFunction() override { + void runOnOperation() override { MLIRContext *context = &getContext(); RewritePatternSet patterns(context); populateTiledLoopToSCFPattern(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; } // namespace diff --git a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp @@ -397,8 +397,8 @@ this->useAlloca = useAlloca; } - void runOnFunction() override { - getFunction().walk([&](LinalgOp op) { + void runOnOperation() override { + getOperation().walk([&](LinalgOp op) { auto options = LinalgPromotionOptions() .setDynamicBuffers(dynamicBuffers) .setUseAlloca(useAlloca); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -519,8 +519,8 @@ distributionTypes, [](StringRef ref) { return ref.str(); })); } - void runOnFunction() override { - FuncOp funcOp = getFunction(); + void runOnOperation() override { + FuncOp funcOp = getOperation(); LinalgTilingLoopType type = llvm::StringSwitch(loopType) .Case("for", LinalgTilingLoopType::Loops) diff --git a/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp b/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp --- a/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp +++ b/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp @@ -22,7 +22,7 @@ namespace { struct ConvertConstPass : public QuantConvertConstBase { - void runOnFunction() override; + void runOnOperation() override; }; struct QuantizedConstRewrite : public OpRewritePattern { @@ -91,9 +91,9 @@ return success(); } -void ConvertConstPass::runOnFunction() { +void ConvertConstPass::runOnOperation() { RewritePatternSet patterns(&getContext()); - auto func = getFunction(); + auto func = getOperation(); auto *context = &getContext(); patterns.add(context); (void)applyPatternsAndFoldGreedily(func, std::move(patterns)); diff --git a/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp --- a/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp +++ b/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp @@ -20,7 +20,7 @@ namespace { struct ConvertSimulatedQuantPass : public QuantConvertSimulatedQuantBase { - void runOnFunction() override; + void runOnOperation() override; }; /// Base class rewrites ConstFakeQuant into a qbarrier/dbarrier pair. @@ -122,9 +122,9 @@ } // namespace -void ConvertSimulatedQuantPass::runOnFunction() { +void ConvertSimulatedQuantPass::runOnOperation() { bool hadFailure = false; - auto func = getFunction(); + auto func = getOperation(); RewritePatternSet patterns(func.getContext()); auto *ctx = func.getContext(); patterns.add( diff --git a/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp b/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp @@ -21,7 +21,7 @@ namespace { struct SCFBufferizePass : public SCFBufferizeBase { - void runOnFunction() override { + void runOnOperation() override { auto func = getOperation(); auto *context = &getContext(); diff --git a/mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp b/mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp --- a/mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp @@ -96,8 +96,8 @@ }; struct ForToWhileLoop : public SCFForToWhileLoopBase { - void runOnFunction() override { - FuncOp funcOp = getFunction(); + void runOnOperation() override { + FuncOp funcOp = getOperation(); MLIRContext *ctx = funcOp.getContext(); RewritePatternSet patterns(ctx); patterns.add(ctx); diff --git a/mlir/lib/Dialect/SCF/Transforms/LoopCanonicalization.cpp b/mlir/lib/Dialect/SCF/Transforms/LoopCanonicalization.cpp --- a/mlir/lib/Dialect/SCF/Transforms/LoopCanonicalization.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/LoopCanonicalization.cpp @@ -181,8 +181,8 @@ struct SCFForLoopCanonicalization : public SCFForLoopCanonicalizationBase { - void runOnFunction() override { - FuncOp funcOp = getFunction(); + void runOnOperation() override { + FuncOp funcOp = getOperation(); MLIRContext *ctx = funcOp.getContext(); RewritePatternSet patterns(ctx); scf::populateSCFForLoopCanonicalizationPatterns(patterns); diff --git a/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp b/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp --- a/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp @@ -237,22 +237,22 @@ namespace { struct ParallelLoopSpecialization : public SCFParallelLoopSpecializationBase { - void runOnFunction() override { - getFunction().walk( + void runOnOperation() override { + getOperation().walk( [](ParallelOp op) { specializeParallelLoopForUnrolling(op); }); } }; struct ForLoopSpecialization : public SCFForLoopSpecializationBase { - void runOnFunction() override { - getFunction().walk([](ForOp op) { specializeForLoopForUnrolling(op); }); + void runOnOperation() override { + getOperation().walk([](ForOp op) { specializeForLoopForUnrolling(op); }); } }; struct ForLoopPeeling : public SCFForLoopPeelingBase { - void runOnFunction() override { - FuncOp funcOp = getFunction(); + void runOnOperation() override { + FuncOp funcOp = getOperation(); MLIRContext *ctx = funcOp.getContext(); RewritePatternSet patterns(ctx); patterns.add(ctx, skipPartial); diff --git a/mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp --- a/mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp @@ -195,9 +195,9 @@ this->noMinMaxBounds = noMinMaxBounds; } - void runOnFunction() override { + void runOnOperation() override { SmallVector innermostPloops; - getInnermostParallelLoops(getFunction().getOperation(), innermostPloops); + getInnermostParallelLoops(getOperation().getOperation(), innermostPloops); for (ParallelOp ploop : innermostPloops) { // FIXME: Add reduction support. if (ploop.getNumReductions() == 0) diff --git a/mlir/lib/Dialect/Shape/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Shape/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/Shape/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Shape/Transforms/Bufferize.cpp @@ -17,7 +17,7 @@ namespace { struct ShapeBufferizePass : public ShapeBufferizeBase { - void runOnFunction() override { + void runOnOperation() override { MLIRContext &ctx = getContext(); RewritePatternSet patterns(&ctx); @@ -28,13 +28,13 @@ populateShapeStructuralTypeConversionsAndLegality(typeConverter, patterns, target); - if (failed( - applyPartialConversion(getFunction(), target, std::move(patterns)))) + if (failed(applyPartialConversion(getOperation(), target, + std::move(patterns)))) signalPassFailure(); } }; } // namespace -std::unique_ptr mlir::createShapeBufferizePass() { +std::unique_ptr> mlir::createShapeBufferizePass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp b/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp --- a/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp +++ b/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp @@ -43,13 +43,13 @@ class RemoveShapeConstraintsPass : public RemoveShapeConstraintsBase { - void runOnFunction() override { + void runOnOperation() override { MLIRContext &ctx = getContext(); RewritePatternSet patterns(&ctx); populateRemoveShapeConstraintsPatterns(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; @@ -60,6 +60,7 @@ patterns.getContext()); } -std::unique_ptr mlir::createRemoveShapeConstraintsPass() { +std::unique_ptr> +mlir::createRemoveShapeConstraintsPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp b/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp --- a/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp +++ b/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp @@ -55,11 +55,11 @@ namespace { struct ShapeToShapeLowering : public ShapeToShapeLoweringBase { - void runOnFunction() override; + void runOnOperation() override; }; } // namespace -void ShapeToShapeLowering::runOnFunction() { +void ShapeToShapeLowering::runOnOperation() { MLIRContext &ctx = getContext(); RewritePatternSet patterns(&ctx); @@ -69,7 +69,7 @@ target.addLegalDialect(); target.addIllegalOp(); - if (failed(mlir::applyPartialConversion(getFunction(), target, + if (failed(mlir::applyPartialConversion(getOperation(), target, std::move(patterns)))) signalPassFailure(); } diff --git a/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp b/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp @@ -49,7 +49,7 @@ namespace { struct StdBufferizePass : public StdBufferizeBase { - void runOnFunction() override { + void runOnOperation() override { auto *context = &getContext(); bufferization::BufferizeTypeConverter typeConverter; RewritePatternSet patterns(context); @@ -66,8 +66,8 @@ return typeConverter.isLegal(op.getType()) || !op.getCondition().getType().isa(); }); - if (failed( - applyPartialConversion(getFunction(), target, std::move(patterns)))) + if (failed(applyPartialConversion(getOperation(), target, + std::move(patterns)))) signalPassFailure(); } }; diff --git a/mlir/lib/Dialect/StandardOps/Transforms/ExpandOps.cpp b/mlir/lib/Dialect/StandardOps/Transforms/ExpandOps.cpp --- a/mlir/lib/Dialect/StandardOps/Transforms/ExpandOps.cpp +++ b/mlir/lib/Dialect/StandardOps/Transforms/ExpandOps.cpp @@ -121,7 +121,7 @@ }; struct StdExpandOpsPass : public StdExpandOpsBase { - void runOnFunction() override { + void runOnOperation() override { MLIRContext &ctx = getContext(); RewritePatternSet patterns(&ctx); @@ -138,8 +138,8 @@ target.addDynamicallyLegalOp([](memref::ReshapeOp op) { return !op.shape().getType().cast().hasStaticShape(); }); - if (failed( - applyPartialConversion(getFunction(), target, std::move(patterns)))) + if (failed(applyPartialConversion(getOperation(), target, + std::move(patterns)))) signalPassFailure(); } }; diff --git a/mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp @@ -198,7 +198,7 @@ }; struct TensorBufferizePass : public TensorBufferizeBase { - void runOnFunction() override { + void runOnOperation() override { auto *context = &getContext(); bufferization::BufferizeTypeConverter typeConverter; @@ -214,8 +214,8 @@ RewritePatternSet patterns(context); populateTensorBufferizePatterns(typeConverter, patterns); - if (failed( - applyPartialConversion(getFunction(), target, std::move(patterns)))) + if (failed(applyPartialConversion(getOperation(), target, + std::move(patterns)))) signalPassFailure(); } }; diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp --- a/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp +++ b/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp @@ -278,7 +278,7 @@ /// migrating to within the regions of if/while operations. struct TosaInferShapes : public TosaInferShapesBase { public: - void runOnFunction() override { + void runOnOperation() override { FuncOp func = getOperation(); IRRewriter rewriter(func.getContext()); diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp --- a/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp +++ b/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp @@ -235,8 +235,8 @@ struct TosaMakeBroadcastable : public TosaMakeBroadcastableBase { public: - void runOnFunction() override { - auto func = getFunction(); + void runOnOperation() override { + auto func = getOperation(); RewritePatternSet patterns(func.getContext()); MLIRContext *ctx = func.getContext(); // Add the generated patterns to the list. diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaOptionalDecompositions.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaOptionalDecompositions.cpp --- a/mlir/lib/Dialect/Tosa/Transforms/TosaOptionalDecompositions.cpp +++ b/mlir/lib/Dialect/Tosa/Transforms/TosaOptionalDecompositions.cpp @@ -25,10 +25,10 @@ struct TosaOptionalDecompositions : public TosaOptionalDecompositionsBase { - void runOnFunction() override { + void runOnOperation() override { auto *ctx = &getContext(); RewritePatternSet patterns(ctx); - auto func = getFunction(); + auto func = getOperation(); mlir::tosa::populateTosaDecomposeConv2D(ctx, patterns); mlir::tosa::populateTosaDecomposeTransposeConv(ctx, patterns); diff --git a/mlir/lib/Transforms/BufferOptimizations.cpp b/mlir/lib/Transforms/BufferOptimizations.cpp --- a/mlir/lib/Transforms/BufferOptimizations.cpp +++ b/mlir/lib/Transforms/BufferOptimizations.cpp @@ -364,10 +364,10 @@ /// blocks. struct BufferHoistingPass : BufferHoistingBase { - void runOnFunction() override { + void runOnOperation() override { // Hoist all allocations into dominator blocks. BufferAllocationHoisting optimizer( - getFunction()); + getOperation()); optimizer.hoist(); } }; @@ -375,10 +375,10 @@ /// The buffer loop hoisting pass that hoists allocation nodes out of loops. struct BufferLoopHoistingPass : BufferLoopHoistingBase { - void runOnFunction() override { + void runOnOperation() override { // Hoist all allocations out of loops. BufferAllocationHoisting optimizer( - getFunction()); + getOperation()); optimizer.hoist(); } }; @@ -410,9 +410,9 @@ return success(); } - void runOnFunction() override { + void runOnOperation() override { // Move all allocation nodes and convert candidates into allocas. - BufferPlacementPromotion optimizer(getFunction()); + BufferPlacementPromotion optimizer(getOperation()); optimizer.promote(isSmallAlloc); } diff --git a/mlir/lib/Transforms/LoopCoalescing.cpp b/mlir/lib/Transforms/LoopCoalescing.cpp --- a/mlir/lib/Transforms/LoopCoalescing.cpp +++ b/mlir/lib/Transforms/LoopCoalescing.cpp @@ -83,8 +83,8 @@ } } - void runOnFunction() override { - FuncOp func = getFunction(); + void runOnOperation() override { + FuncOp func = getOperation(); func.walk([&](Operation *op) { if (auto scfForOp = dyn_cast(op)) walkLoop(scfForOp); diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -56,7 +56,7 @@ this->affineFusionMode = affineFusionMode; } - void runOnFunction() override; + void runOnOperation() override; }; } // namespace @@ -1975,9 +1975,9 @@ } // namespace -void LoopFusion::runOnFunction() { +void LoopFusion::runOnOperation() { MemRefDependenceGraph g; - if (!g.init(getFunction())) + if (!g.init(getOperation())) return; Optional fastMemorySpaceOpt; diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -32,7 +32,7 @@ namespace { struct PipelineDataTransfer : public AffinePipelineDataTransferBase { - void runOnFunction() override; + void runOnOperation() override; void runOnAffineForOp(AffineForOp forOp); std::vector forOps; @@ -124,14 +124,14 @@ } /// Returns success if the IR is in a valid state. -void PipelineDataTransfer::runOnFunction() { +void PipelineDataTransfer::runOnOperation() { // Do a post order walk so that inner loop DMAs are processed first. This is // necessary since 'affine.for' operations nested within would otherwise // become invalid (erased) when the outer loop is pipelined (the pipelined one // gets deleted and replaced by a prologue, a new steady-state loop and an // epilogue). forOps.clear(); - getFunction().walk([&](AffineForOp forOp) { forOps.push_back(forOp); }); + getOperation().walk([&](AffineForOp forOp) { forOps.push_back(forOp); }); for (auto forOp : forOps) runOnAffineForOp(forOp); } diff --git a/mlir/test/lib/Analysis/TestLiveness.cpp b/mlir/test/lib/Analysis/TestLiveness.cpp --- a/mlir/test/lib/Analysis/TestLiveness.cpp +++ b/mlir/test/lib/Analysis/TestLiveness.cpp @@ -19,13 +19,14 @@ namespace { -struct TestLivenessPass : public PassWrapper { +struct TestLivenessPass + : public PassWrapper> { StringRef getArgument() const final { return "test-print-liveness"; } StringRef getDescription() const final { return "Print the contents of a constructed liveness information."; } - void runOnFunction() override { - llvm::errs() << "Testing : " << getFunction().getName() << "\n"; + void runOnOperation() override { + llvm::errs() << "Testing : " << getOperation().getName() << "\n"; getAnalysis().print(llvm::errs()); } }; diff --git a/mlir/test/lib/Analysis/TestMatchReduction.cpp b/mlir/test/lib/Analysis/TestMatchReduction.cpp --- a/mlir/test/lib/Analysis/TestMatchReduction.cpp +++ b/mlir/test/lib/Analysis/TestMatchReduction.cpp @@ -34,14 +34,14 @@ } struct TestMatchReductionPass - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-match-reduction"; } StringRef getDescription() const final { return "Test the match reduction utility."; } - void runOnFunction() override { - FuncOp func = getFunction(); + void runOnOperation() override { + FuncOp func = getOperation(); func->emitRemark("Testing function"); func.walk([](Operation *op) { diff --git a/mlir/test/lib/Analysis/TestMemRefBoundCheck.cpp b/mlir/test/lib/Analysis/TestMemRefBoundCheck.cpp --- a/mlir/test/lib/Analysis/TestMemRefBoundCheck.cpp +++ b/mlir/test/lib/Analysis/TestMemRefBoundCheck.cpp @@ -28,18 +28,18 @@ /// Checks for out of bound memref access subscripts.. struct TestMemRefBoundCheck - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-memref-bound-check"; } StringRef getDescription() const final { return "Check memref access bounds in a Function"; } - void runOnFunction() override; + void runOnOperation() override; }; } // namespace -void TestMemRefBoundCheck::runOnFunction() { - getFunction().walk([](Operation *opInst) { +void TestMemRefBoundCheck::runOnOperation() { + getOperation().walk([](Operation *opInst) { TypeSwitch(opInst) .Case( [](auto op) { (void)boundCheckLoadOrStoreOp(op); }); diff --git a/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp b/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp --- a/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp +++ b/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp @@ -27,13 +27,13 @@ // TODO: Add common surrounding loop depth-wise dependence checks. /// Checks dependences between all pairs of memref accesses in a Function. struct TestMemRefDependenceCheck - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-memref-dependence-check"; } StringRef getDescription() const final { return "Checks dependences between all pairs of memref accesses."; } SmallVector loadsAndStores; - void runOnFunction() override; + void runOnOperation() override; }; } // namespace @@ -102,10 +102,10 @@ // Walks the Function 'f' adding load and store ops to 'loadsAndStores'. // Runs pair-wise dependence checks. -void TestMemRefDependenceCheck::runOnFunction() { +void TestMemRefDependenceCheck::runOnOperation() { // Collect the loads and stores within the function. loadsAndStores.clear(); - getFunction().walk([&](Operation *op) { + getOperation().walk([&](Operation *op) { if (isa(op)) loadsAndStores.push_back(op); }); diff --git a/mlir/test/lib/Analysis/TestMemRefStrideCalculation.cpp b/mlir/test/lib/Analysis/TestMemRefStrideCalculation.cpp --- a/mlir/test/lib/Analysis/TestMemRefStrideCalculation.cpp +++ b/mlir/test/lib/Analysis/TestMemRefStrideCalculation.cpp @@ -14,21 +14,21 @@ namespace { struct TestMemRefStrideCalculation - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-memref-stride-calculation"; } StringRef getDescription() const final { return "Test operation constant folding"; } - void runOnFunction() override; + void runOnOperation() override; }; } // namespace /// Traverse AllocOp and compute strides of each MemRefType independently. -void TestMemRefStrideCalculation::runOnFunction() { - llvm::outs() << "Testing: " << getFunction().getName() << "\n"; - getFunction().walk([&](memref::AllocOp allocOp) { +void TestMemRefStrideCalculation::runOnOperation() { + llvm::outs() << "Testing: " << getOperation().getName() << "\n"; + getOperation().walk([&](memref::AllocOp allocOp) { auto memrefType = allocOp.getResult().getType().cast(); int64_t offset; SmallVector strides; diff --git a/mlir/test/lib/Analysis/TestSlice.cpp b/mlir/test/lib/Analysis/TestSlice.cpp --- a/mlir/test/lib/Analysis/TestSlice.cpp +++ b/mlir/test/lib/Analysis/TestSlice.cpp @@ -16,14 +16,14 @@ namespace { struct TestTopologicalSortPass - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-print-topological-sort"; } StringRef getDescription() const final { return "Print operations in topological order"; } - void runOnFunction() override { + void runOnOperation() override { std::map ops; - getFunction().walk([&ops](Operation *op) { + getOperation().walk([&ops](Operation *op) { if (auto originalOrderAttr = op->getAttrOfType(kOrderMarker)) ops[originalOrderAttr.getInt()] = op; }); @@ -31,7 +31,7 @@ for (auto op : ops) sortedOp.insert(op.second); sortedOp = topologicalSort(sortedOp); - llvm::errs() << "Testing : " << getFunction().getName() << "\n"; + llvm::errs() << "Testing : " << getOperation().getName() << "\n"; for (Operation *op : sortedOp) { op->print(llvm::errs()); llvm::errs() << "\n"; diff --git a/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp b/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp --- a/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp +++ b/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp @@ -28,7 +28,7 @@ namespace { struct TestAffineDataCopy - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return PASS_NAME; } StringRef getDescription() const final { return "Tests affine data copy utility functions."; @@ -39,7 +39,7 @@ void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); } - void runOnFunction() override; + void runOnOperation() override; private: Option clMemRefFilter{ @@ -55,10 +55,10 @@ } // namespace -void TestAffineDataCopy::runOnFunction() { +void TestAffineDataCopy::runOnOperation() { // Gather all AffineForOps by loop depth. std::vector> depthToLoops; - gatherLoops(getFunction(), depthToLoops); + gatherLoops(getOperation(), depthToLoops); assert(!depthToLoops.empty() && "Loop nest not found"); // Only support tests with a single loop nest and a single innermost loop diff --git a/mlir/test/lib/Dialect/Affine/TestAffineLoopParametricTiling.cpp b/mlir/test/lib/Dialect/Affine/TestAffineLoopParametricTiling.cpp --- a/mlir/test/lib/Dialect/Affine/TestAffineLoopParametricTiling.cpp +++ b/mlir/test/lib/Dialect/Affine/TestAffineLoopParametricTiling.cpp @@ -21,12 +21,13 @@ namespace { struct TestAffineLoopParametricTiling - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-affine-parametric-tile"; } StringRef getDescription() const final { return "Tile affine loops using SSA values as tile sizes"; } - void runOnFunction() override; + void runOnOperation() override; }; } // namespace @@ -61,10 +62,10 @@ } } -void TestAffineLoopParametricTiling::runOnFunction() { +void TestAffineLoopParametricTiling::runOnOperation() { // Bands of loops to tile. std::vector> bands; - getTileableBands(getFunction(), &bands); + getTileableBands(getOperation(), &bands); // Tile each band. for (MutableArrayRef band : bands) { diff --git a/mlir/test/lib/Dialect/Affine/TestAffineLoopUnswitching.cpp b/mlir/test/lib/Dialect/Affine/TestAffineLoopUnswitching.cpp --- a/mlir/test/lib/Dialect/Affine/TestAffineLoopUnswitching.cpp +++ b/mlir/test/lib/Dialect/Affine/TestAffineLoopUnswitching.cpp @@ -24,7 +24,7 @@ /// This pass applies the permutation on the first maximal perfect nest. struct TestAffineLoopUnswitching - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return PASS_NAME; } StringRef getDescription() const final { return "Tests affine loop unswitching / if/else hoisting"; @@ -32,7 +32,7 @@ TestAffineLoopUnswitching() = default; TestAffineLoopUnswitching(const TestAffineLoopUnswitching &pass) = default; - void runOnFunction() override; + void runOnOperation() override; /// The maximum number of iterations to run this for. constexpr static unsigned kMaxIterations = 5; @@ -40,11 +40,11 @@ } // namespace -void TestAffineLoopUnswitching::runOnFunction() { +void TestAffineLoopUnswitching::runOnOperation() { // Each hoisting invalidates a lot of IR around. Just stop the walk after the // first if/else hoisting, and repeat until no more hoisting can be done, or // the maximum number of iterations have been run. - auto func = getFunction(); + auto func = getOperation(); unsigned i = 0; do { auto walkFn = [](AffineIfOp op) { diff --git a/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp b/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp --- a/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp +++ b/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp @@ -26,7 +26,7 @@ /// This pass applies the permutation on the first maximal perfect nest. struct TestLoopPermutation - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return PASS_NAME; } StringRef getDescription() const final { return "Tests affine loop permutation utility"; @@ -34,7 +34,7 @@ TestLoopPermutation() = default; TestLoopPermutation(const TestLoopPermutation &pass) : PassWrapper(pass){}; - void runOnFunction() override; + void runOnOperation() override; private: /// Permutation specifying loop i is mapped to permList[i] in @@ -46,12 +46,12 @@ } // namespace -void TestLoopPermutation::runOnFunction() { +void TestLoopPermutation::runOnOperation() { SmallVector permMap(permList.begin(), permList.end()); SmallVector forOps; - getFunction().walk([&](AffineForOp forOp) { forOps.push_back(forOp); }); + getOperation().walk([&](AffineForOp forOp) { forOps.push_back(forOp); }); for (auto forOp : forOps) { SmallVector nest; diff --git a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp --- a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp +++ b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp @@ -69,7 +69,7 @@ namespace { struct VectorizerTestPass - : public PassWrapper { + : public PassWrapper> { static constexpr auto kTestAffineMapOpName = "test_affine_map"; static constexpr auto kTestAffineMapAttrName = "affine_map"; void getDependentDialects(DialectRegistry ®istry) const override { @@ -80,7 +80,7 @@ return "Tests vectorizer standalone functionality."; } - void runOnFunction() override; + void runOnOperation() override; void testVectorShapeRatio(llvm::raw_ostream &outs); void testForwardSlicing(llvm::raw_ostream &outs); void testBackwardSlicing(llvm::raw_ostream &outs); @@ -94,7 +94,7 @@ } // namespace void VectorizerTestPass::testVectorShapeRatio(llvm::raw_ostream &outs) { - auto f = getFunction(); + auto f = getOperation(); using matcher::Op; SmallVector shape(clTestVectorShapeRatio.begin(), clTestVectorShapeRatio.end()); @@ -144,7 +144,7 @@ } void VectorizerTestPass::testBackwardSlicing(llvm::raw_ostream &outs) { - auto f = getFunction(); + auto f = getOperation(); outs << "\n" << f.getName(); SmallVector matches; @@ -160,7 +160,7 @@ } void VectorizerTestPass::testForwardSlicing(llvm::raw_ostream &outs) { - auto f = getFunction(); + auto f = getOperation(); outs << "\n" << f.getName(); SmallVector matches; @@ -176,7 +176,7 @@ } void VectorizerTestPass::testSlicing(llvm::raw_ostream &outs) { - auto f = getFunction(); + auto f = getOperation(); outs << "\n" << f.getName(); SmallVector matches; @@ -195,7 +195,7 @@ } void VectorizerTestPass::testComposeMaps(llvm::raw_ostream &outs) { - auto f = getFunction(); + auto f = getOperation(); using matcher::Op; auto pattern = Op(customOpWithAffineMapAttribute); @@ -220,7 +220,7 @@ /// Test for 'vectorizeAffineLoopNest' utility. void VectorizerTestPass::testVecAffineLoopNest() { std::vector> loops; - gatherLoops(getFunction(), loops); + gatherLoops(getOperation(), loops); // Expected only one loop nest. if (loops.empty() || loops[0].size() != 1) @@ -236,9 +236,9 @@ (void)vectorizeAffineLoopNest(loopsToVectorize, strategy); } -void VectorizerTestPass::runOnFunction() { +void VectorizerTestPass::runOnOperation() { // Only support single block functions at this point. - FuncOp f = getFunction(); + FuncOp f = getOperation(); if (!llvm::hasSingleElement(f)) return; diff --git a/mlir/test/lib/Dialect/DLTI/TestDataLayoutQuery.cpp b/mlir/test/lib/Dialect/DLTI/TestDataLayoutQuery.cpp --- a/mlir/test/lib/Dialect/DLTI/TestDataLayoutQuery.cpp +++ b/mlir/test/lib/Dialect/DLTI/TestDataLayoutQuery.cpp @@ -20,11 +20,11 @@ /// attributes containing the results of data layout queries for operation /// result types. struct TestDataLayoutQuery - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-data-layout-query"; } StringRef getDescription() const final { return "Test data layout queries"; } - void runOnFunction() override { - FuncOp func = getFunction(); + void runOnOperation() override { + FuncOp func = getOperation(); Builder builder(func.getContext()); const DataLayoutAnalysis &layouts = getAnalysis(); diff --git a/mlir/test/lib/Dialect/Linalg/TestComprehensiveBufferize.cpp b/mlir/test/lib/Dialect/Linalg/TestComprehensiveBufferize.cpp --- a/mlir/test/lib/Dialect/Linalg/TestComprehensiveBufferize.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestComprehensiveBufferize.cpp @@ -39,7 +39,8 @@ /// A helper struct for FunctionBufferize and ModuleBufferize. Both passes are /// mostly identical. struct TestComprehensiveFunctionBufferize - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-comprehensive-function-bufferize"; } @@ -68,7 +69,7 @@ vector_ext::registerBufferizableOpInterfaceExternalModels(registry); } - void runOnFunction() override; + void runOnOperation() override; Option allowReturnMemref{ *this, "allow-return-memref", @@ -99,7 +100,7 @@ }; } // namespace -void TestComprehensiveFunctionBufferize::runOnFunction() { +void TestComprehensiveFunctionBufferize::runOnOperation() { auto options = std::make_unique(); if (!allowReturnMemref) @@ -117,7 +118,7 @@ options->dialectFilter->insert(dialectNamespace); } - Operation *op = getFunction().getOperation(); + Operation *op = getOperation().getOperation(); if (failed(runComprehensiveBufferize(op, std::move(options)))) return; diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp --- a/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp @@ -29,7 +29,7 @@ namespace { struct TestLinalgCodegenStrategy - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-linalg-codegen-strategy"; } StringRef getDescription() const final { return "Test Linalg Codegen Strategy."; @@ -53,7 +53,7 @@ template void applyStrategyToNamedLinalgOp(); - void runOnFunction() override; + void runOnOperation() override; void runStrategy(const LinalgTilingAndFusionOptions &tilingAndFusionOptions, const LinalgTilingOptions &tilingOptions, @@ -208,7 +208,7 @@ .enableContractionLowering() .enableTransferToSCFConversion()); // Created a nested OpPassManager and run. - FuncOp funcOp = getFunction(); + FuncOp funcOp = getOperation(); OpPassManager dynamicPM("builtin.func"); strategy.configurePassPipeline(dynamicPM, funcOp.getContext(), runEnablePass); if (failed(runPipeline(dynamicPM, funcOp))) @@ -225,8 +225,8 @@ } /// Apply transformations specified as patterns. -void TestLinalgCodegenStrategy::runOnFunction() { - if (!anchorFuncOpName.empty() && anchorFuncOpName != getFunction().getName()) +void TestLinalgCodegenStrategy::runOnOperation() { + if (!anchorFuncOpName.empty() && anchorFuncOpName != getOperation().getName()) return; LinalgTilingAndFusionOptions tilingAndFusionOptions; diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgDistribution.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgDistribution.cpp --- a/mlir/test/lib/Dialect/Linalg/TestLinalgDistribution.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgDistribution.cpp @@ -38,7 +38,7 @@ namespace { struct TestLinalgDistribution - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-linalg-distribution"; } StringRef getDescription() const final { return "Test Linalg distribution."; } TestLinalgDistribution() = default; @@ -47,12 +47,12 @@ registry.insert(); } - void runOnFunction() override; + void runOnOperation() override; }; } // namespace -void TestLinalgDistribution::runOnFunction() { - auto funcOp = getFunction(); +void TestLinalgDistribution::runOnOperation() { + auto funcOp = getOperation(); OwningRewritePatternList distributeTiledLoopsPatterns(&getContext()); populateLinalgDistributeTiledLoopPattern( distributeTiledLoopsPatterns, getDistributionOptions(), diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgElementwiseFusion.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgElementwiseFusion.cpp --- a/mlir/test/lib/Dialect/Linalg/TestLinalgElementwiseFusion.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgElementwiseFusion.cpp @@ -46,7 +46,7 @@ namespace { struct TestLinalgElementwiseFusion - : public PassWrapper { + : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); @@ -58,9 +58,9 @@ return "Test Linalg element wise operation fusion patterns"; } - void runOnFunction() override { + void runOnOperation() override { MLIRContext *context = &this->getContext(); - FuncOp funcOp = this->getFunction(); + FuncOp funcOp = this->getOperation(); RewritePatternSet fusionPatterns(context); linalg::populateElementwiseOpsFusionPatterns( @@ -74,7 +74,8 @@ }; struct TestLinalgControlFuseByExpansion - : public PassWrapper { + : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { registry .insert(); @@ -87,9 +88,9 @@ "expansion"; } - void runOnFunction() override { + void runOnOperation() override { MLIRContext *context = &this->getContext(); - FuncOp funcOp = this->getFunction(); + FuncOp funcOp = this->getOperation(); RewritePatternSet fusionPatterns(context); linalg::ControlElementwiseOpsFusionFn controlReshapeFusionFn = @@ -120,7 +121,7 @@ }; struct TestPushExpandingReshape - : public PassWrapper { + : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { registry .insert(); @@ -130,9 +131,9 @@ return "Test Linalg reshape push patterns"; } - void runOnFunction() override { + void runOnOperation() override { MLIRContext *context = &this->getContext(); - FuncOp funcOp = this->getFunction(); + FuncOp funcOp = this->getOperation(); RewritePatternSet patterns(context); linalg::populatePushReshapeOpsPatterns(patterns); (void)applyPatternsAndFoldGreedily(funcOp.getBody(), std::move(patterns)); diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp --- a/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp @@ -111,7 +111,8 @@ namespace { template struct TestLinalgFusionTransforms - : public PassWrapper, FunctionPass> { + : public PassWrapper, + OperationPass> { void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); @@ -119,9 +120,9 @@ TestLinalgFusionTransforms() = default; TestLinalgFusionTransforms(const TestLinalgFusionTransforms &pass) {} - void runOnFunction() override { + void runOnOperation() override { MLIRContext *context = &this->getContext(); - FuncOp funcOp = this->getFunction(); + FuncOp funcOp = this->getOperation(); RewritePatternSet fusionPatterns(context); Aliases alias; LinalgDependenceGraph dependenceGraph = @@ -225,7 +226,7 @@ namespace { struct TestLinalgGreedyFusion - : public PassWrapper { + : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); @@ -234,7 +235,7 @@ StringRef getDescription() const final { return "Test Linalg fusion by applying a greedy test transformation."; } - void runOnFunction() override { + void runOnOperation() override { MLIRContext *context = &getContext(); RewritePatternSet patterns = linalg::getLinalgTilingCanonicalizationPatterns(context); @@ -242,22 +243,23 @@ scf::populateSCFForLoopCanonicalizationPatterns(patterns); FrozenRewritePatternSet frozenPatterns(std::move(patterns)); do { - (void)applyPatternsAndFoldGreedily(getFunction(), frozenPatterns); + (void)applyPatternsAndFoldGreedily(getOperation(), frozenPatterns); PassManager pm(context); pm.addPass(createLoopInvariantCodeMotionPass()); pm.addPass(createCanonicalizerPass()); pm.addPass(createCSEPass()); - LogicalResult res = pm.run(getFunction()->getParentOfType()); + LogicalResult res = pm.run(getOperation()->getParentOfType()); if (failed(res)) this->signalPassFailure(); - } while (succeeded(fuseLinalgOpsGreedily(getFunction()))); + } while (succeeded(fuseLinalgOpsGreedily(getOperation()))); } }; /// Pass to test tile and fuse of sequence of operations. Intended only for /// testing. struct TestLinalgTileAndFuseSequencePass - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-linalg-tile-and-fuse"; } StringRef getDescription() const final { return "Test Linalg tiling and fusion of a sequence of Linalg operations."; @@ -276,7 +278,7 @@ scf::SCFDialect>(); } - void runOnFunction() override { + void runOnOperation() override { FuncOp funcOp = getOperation(); auto &blocks = funcOp.getBody().getBlocks(); if (!llvm::hasSingleElement(blocks)) { diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgHoisting.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgHoisting.cpp --- a/mlir/test/lib/Dialect/Linalg/TestLinalgHoisting.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgHoisting.cpp @@ -20,7 +20,7 @@ namespace { struct TestLinalgHoisting - : public PassWrapper { + : public PassWrapper> { TestLinalgHoisting() = default; TestLinalgHoisting(const TestLinalgHoisting &pass) : PassWrapper(pass) {} void getDependentDialects(DialectRegistry ®istry) const override { @@ -31,7 +31,7 @@ return "Test Linalg hoisting functions."; } - void runOnFunction() override; + void runOnOperation() override; Option testHoistRedundantTransfers{ *this, "test-hoist-redundant-transfers", @@ -40,10 +40,10 @@ }; } // namespace -void TestLinalgHoisting::runOnFunction() { +void TestLinalgHoisting::runOnOperation() { if (testHoistRedundantTransfers) { - hoistRedundantVectorTransfers(getFunction()); - hoistRedundantVectorTransfersOnTensor(getFunction()); + hoistRedundantVectorTransfers(getOperation()); + hoistRedundantVectorTransfersOnTensor(getOperation()); return; } } diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp --- a/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp @@ -32,7 +32,7 @@ namespace { struct TestLinalgTransforms - : public PassWrapper { + : public PassWrapper> { TestLinalgTransforms() = default; TestLinalgTransforms(const TestLinalgTransforms &pass) : PassWrapper(pass) {} @@ -53,7 +53,7 @@ return "Test Linalg transformation patterns by applying them greedily."; } - void runOnFunction() override; + void runOnOperation() override; Option testPatterns{*this, "test-patterns", llvm::cl::desc("Test a mixed set of patterns"), @@ -674,9 +674,9 @@ } /// Apply transformations specified as patterns. -void TestLinalgTransforms::runOnFunction() { +void TestLinalgTransforms::runOnOperation() { auto lambda = [&](void *) { - getFunction().walk([](LinalgOp op) { + getOperation().walk([](LinalgOp op) { op->removeAttr(LinalgTransforms::kLinalgTransformMarker); }); }; @@ -685,39 +685,39 @@ if (testPromotionOptions) { RewritePatternSet patterns(&getContext()); fillPromotionCallBackPatterns(&getContext(), patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); return; } if (testTileAndDistributionOptions) { RewritePatternSet patterns(&getContext()); fillTileAndDistributePatterns(&getContext(), patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); return; } if (testPatterns) - return applyPatterns(getFunction()); + return applyPatterns(getOperation()); if (testMatmulToVectorPatterns1dTiling || testMatmulToVectorPatterns2dTiling) - return applyMatmulToVectorPatterns(getFunction(), + return applyMatmulToVectorPatterns(getOperation(), testMatmulToVectorPatterns1dTiling, testMatmulToVectorPatterns2dTiling); if (testVectorTransferForwardingPatterns) - return applyVectorTransferForwardingPatterns(getFunction()); + return applyVectorTransferForwardingPatterns(getOperation()); if (testGenericToVectorPattern) - return applyLinalgToVectorPatterns(getFunction()); + return applyLinalgToVectorPatterns(getOperation()); if (testTransformPadTensor) - return applyPadTensorToGenericPatterns(getFunction()); + return applyPadTensorToGenericPatterns(getOperation()); if (testGeneralizePadTensor) - return applyGeneralizePadTensorPatterns(getFunction()); + return applyGeneralizePadTensorPatterns(getOperation()); if (testSwapSubTensorPadTensor) - return applyExtractSliceOfPadTensorSwapPattern(getFunction()); + return applyExtractSliceOfPadTensorSwapPattern(getOperation()); if (testTiledLoopPeeling.hasValue()) - return applyTiledLoopPeelingPattern(getFunction(), testTiledLoopPeeling, + return applyTiledLoopPeelingPattern(getOperation(), testTiledLoopPeeling, skipPartial); if (testTilePattern) - return applyTilePattern(getFunction(), loopType, tileSizes, peeledLoops, + return applyTilePattern(getOperation(), loopType, tileSizes, peeledLoops, /*scalarizeDynamicDims=*/false); if (testTileScalarizeDynamicDims) - return applyTilePattern(getFunction(), loopType, tileSizes, + return applyTilePattern(getOperation(), loopType, tileSizes, /*peeledLoops=*/{}, /*scalarizeDynamicDims=*/true); } diff --git a/mlir/test/lib/Dialect/Linalg/TestPadFusion.cpp b/mlir/test/lib/Dialect/Linalg/TestPadFusion.cpp --- a/mlir/test/lib/Dialect/Linalg/TestPadFusion.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestPadFusion.cpp @@ -19,7 +19,8 @@ namespace mlir { namespace { -struct TestPadFusionPass : public PassWrapper { +struct TestPadFusionPass + : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { registry @@ -29,9 +30,9 @@ StringRef getArgument() const final { return "test-linalg-pad-fusion"; } StringRef getDescription() const final { return "Test PadOp fusion"; } - void runOnFunction() override { + void runOnOperation() override { MLIRContext *context = &getContext(); - FuncOp funcOp = getFunction(); + FuncOp funcOp = getOperation(); RewritePatternSet patterns(context); linalg::populateFusePadTensorWithProducerLinalgOpPatterns(patterns); if (failed(applyPatternsAndFoldGreedily(funcOp.getBody(), diff --git a/mlir/test/lib/Dialect/Math/TestAlgebraicSimplification.cpp b/mlir/test/lib/Dialect/Math/TestAlgebraicSimplification.cpp --- a/mlir/test/lib/Dialect/Math/TestAlgebraicSimplification.cpp +++ b/mlir/test/lib/Dialect/Math/TestAlgebraicSimplification.cpp @@ -20,8 +20,9 @@ namespace { struct TestMathAlgebraicSimplificationPass - : public PassWrapper { - void runOnFunction() override; + : public PassWrapper> { + void runOnOperation() override; void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); } @@ -34,7 +35,7 @@ }; } // namespace -void TestMathAlgebraicSimplificationPass::runOnFunction() { +void TestMathAlgebraicSimplificationPass::runOnOperation() { RewritePatternSet patterns(&getContext()); populateMathAlgebraicSimplificationPatterns(patterns); (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); diff --git a/mlir/test/lib/Dialect/Math/TestExpandTanh.cpp b/mlir/test/lib/Dialect/Math/TestExpandTanh.cpp --- a/mlir/test/lib/Dialect/Math/TestExpandTanh.cpp +++ b/mlir/test/lib/Dialect/Math/TestExpandTanh.cpp @@ -18,14 +18,14 @@ namespace { struct TestExpandTanhPass - : public PassWrapper { - void runOnFunction() override; + : public PassWrapper> { + void runOnOperation() override; StringRef getArgument() const final { return "test-expand-tanh"; } StringRef getDescription() const final { return "Test expanding tanh"; } }; } // namespace -void TestExpandTanhPass::runOnFunction() { +void TestExpandTanhPass::runOnOperation() { RewritePatternSet patterns(&getContext()); populateExpandTanhPattern(patterns); (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); diff --git a/mlir/test/lib/Dialect/Math/TestPolynomialApproximation.cpp b/mlir/test/lib/Dialect/Math/TestPolynomialApproximation.cpp --- a/mlir/test/lib/Dialect/Math/TestPolynomialApproximation.cpp +++ b/mlir/test/lib/Dialect/Math/TestPolynomialApproximation.cpp @@ -23,13 +23,14 @@ namespace { struct TestMathPolynomialApproximationPass - : public PassWrapper { + : public PassWrapper> { TestMathPolynomialApproximationPass() = default; TestMathPolynomialApproximationPass( const TestMathPolynomialApproximationPass &pass) : PassWrapper(pass) {} - void runOnFunction() override; + void runOnOperation() override; void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); @@ -51,7 +52,7 @@ }; } // namespace -void TestMathPolynomialApproximationPass::runOnFunction() { +void TestMathPolynomialApproximationPass::runOnOperation() { RewritePatternSet patterns(&getContext()); MathPolynomialApproximationOptions approxOptions; approxOptions.enableAvx2 = enableAvx2; diff --git a/mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp b/mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp --- a/mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp +++ b/mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp @@ -27,14 +27,14 @@ namespace { class TestSCFForUtilsPass - : public PassWrapper { + : public PassWrapper> { public: StringRef getArgument() const final { return "test-scf-for-utils"; } StringRef getDescription() const final { return "test scf.for utils"; } explicit TestSCFForUtilsPass() = default; - void runOnFunction() override { - FuncOp func = getFunction(); + void runOnOperation() override { + FuncOp func = getOperation(); SmallVector toErase; func.walk([&](Operation *fakeRead) { @@ -92,7 +92,7 @@ "__test_pipelining_op_order__"; class TestSCFPipeliningPass - : public PassWrapper { + : public PassWrapper> { public: StringRef getArgument() const final { return "test-scf-pipelining"; } StringRef getDescription() const final { return "test scf.forOp pipelining"; } @@ -120,14 +120,14 @@ registry.insert(); } - void runOnFunction() override { + void runOnOperation() override { RewritePatternSet patterns(&getContext()); mlir::scf::PipeliningOption options; options.getScheduleFn = getSchedule; scf::populateSCFLoopPipeliningPatterns(patterns, options); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); - getFunction().walk([](Operation *op) { + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + getOperation().walk([](Operation *op) { // Clean up the markers. op->removeAttr(kTestPipeliningStageMarker); op->removeAttr(kTestPipeliningOpOrderMarker); diff --git a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp --- a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp +++ b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp @@ -21,8 +21,8 @@ namespace { /// A pass for testing SPIR-V op availability. struct PrintOpAvailability - : public PassWrapper { - void runOnFunction() override; + : public PassWrapper> { + void runOnOperation() override; StringRef getArgument() const final { return "test-spirv-op-availability"; } StringRef getDescription() const final { return "Test SPIR-V op availability"; @@ -30,8 +30,8 @@ }; } // namespace -void PrintOpAvailability::runOnFunction() { - auto f = getFunction(); +void PrintOpAvailability::runOnOperation() { + auto f = getOperation(); llvm::outs() << f.getName() << "\n"; Dialect *spvDialect = getContext().getLoadedDialect("spv"); @@ -103,12 +103,12 @@ namespace { /// A pass for testing SPIR-V op availability. struct ConvertToTargetEnv - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const override { return "test-spirv-target-env"; } StringRef getDescription() const override { return "Test SPIR-V target environment"; } - void runOnFunction() override; + void runOnOperation() override; }; struct ConvertToAtomCmpExchangeWeak : public RewritePattern { @@ -142,9 +142,9 @@ }; } // namespace -void ConvertToTargetEnv::runOnFunction() { +void ConvertToTargetEnv::runOnOperation() { MLIRContext *context = &getContext(); - FuncOp fn = getFunction(); + FuncOp fn = getOperation(); auto targetEnv = fn.getOperation() ->getAttr(spirv::getTargetEnvAttrName()) diff --git a/mlir/test/lib/Dialect/StandardOps/TestComposeSubView.cpp b/mlir/test/lib/Dialect/StandardOps/TestComposeSubView.cpp --- a/mlir/test/lib/Dialect/StandardOps/TestComposeSubView.cpp +++ b/mlir/test/lib/Dialect/StandardOps/TestComposeSubView.cpp @@ -19,12 +19,12 @@ namespace { struct TestComposeSubViewPass - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-compose-subview"; } StringRef getDescription() const final { return "Test combining composed subviews"; } - void runOnFunction() override; + void runOnOperation() override; void getDependentDialects(DialectRegistry ®istry) const override; }; @@ -33,7 +33,7 @@ registry.insert(); } -void TestComposeSubViewPass::runOnFunction() { +void TestComposeSubViewPass::runOnOperation() { OwningRewritePatternList patterns(&getContext()); populateComposeSubViewPatterns(patterns, &getContext()); (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -124,10 +124,11 @@ } }; -struct TestPatternDriver : public PassWrapper { +struct TestPatternDriver + : public PassWrapper> { StringRef getArgument() const final { return "test-patterns"; } StringRef getDescription() const final { return "Run test dialect patterns"; } - void runOnFunction() override { + void runOnOperation() override { mlir::RewritePatternSet patterns(&getContext()); populateWithGenerated(patterns); @@ -136,7 +137,7 @@ FolderInsertBeforePreviouslyFoldedConstantPattern>( &getContext()); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; } // namespace @@ -189,18 +190,18 @@ } struct TestReturnTypeDriver - : public PassWrapper { + : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); } StringRef getArgument() const final { return "test-return-type"; } StringRef getDescription() const final { return "Run return type functions"; } - void runOnFunction() override { - if (getFunction().getName() == "testCreateFunctions") { + void runOnOperation() override { + if (getOperation().getName() == "testCreateFunctions") { std::vector ops; // Collect ops to avoid triggering on inserted ops. - for (auto &op : getFunction().getBody().front()) + for (auto &op : getOperation().getBody().front()) ops.push_back(&op); // Generate test patterns for each, but skip terminator. for (auto *op : llvm::makeArrayRef(ops).drop_back()) { @@ -213,10 +214,10 @@ }; return; } - if (getFunction().getName() == "testReifyFunctions") { + if (getOperation().getName() == "testReifyFunctions") { std::vector ops; // Collect ops to avoid triggering on inserted ops. - for (auto &op : getFunction().getBody().front()) + for (auto &op : getOperation().getBody().front()) if (isa(op)) ops.push_back(&op); // Generate test patterns for each, but skip terminator. @@ -229,17 +230,17 @@ namespace { struct TestDerivedAttributeDriver - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-derived-attr"; } StringRef getDescription() const final { return "Run test derived attributes"; } - void runOnFunction() override; + void runOnOperation() override; }; } // namespace -void TestDerivedAttributeDriver::runOnFunction() { - getFunction().walk([](DerivedAttributeOpInterface dOp) { +void TestDerivedAttributeDriver::runOnOperation() { + getOperation().walk([](DerivedAttributeOpInterface dOp) { auto dAttr = dOp.materializeDerivedAttributes(); if (!dAttr) return; @@ -835,12 +836,12 @@ }; struct TestRemappedValue - : public mlir::PassWrapper { + : public mlir::PassWrapper> { StringRef getArgument() const final { return "test-remapped-value"; } StringRef getDescription() const final { return "Test public remapped value mechanism in ConversionPatternRewriter"; } - void runOnFunction() override { + void runOnOperation() override { TestRemapValueTypeConverter typeConverter; mlir::RewritePatternSet patterns(&getContext()); @@ -865,7 +866,7 @@ target.addDynamicallyLegalOp( [](Operation *op) { return op->getNumOperands() > 1; }); - if (failed(mlir::applyFullConversion(getFunction(), target, + if (failed(mlir::applyFullConversion(getOperation(), target, std::move(patterns)))) { signalPassFailure(); } @@ -893,21 +894,21 @@ }; struct TestUnknownRootOpDriver - : public mlir::PassWrapper { + : public mlir::PassWrapper> { StringRef getArgument() const final { return "test-legalize-unknown-root-patterns"; } StringRef getDescription() const final { return "Test public remapped value mechanism in ConversionPatternRewriter"; } - void runOnFunction() override { + void runOnOperation() override { mlir::RewritePatternSet patterns(&getContext()); patterns.add(&getContext()); mlir::ConversionTarget target(getContext()); target.addIllegalDialect(); - if (failed( - applyPartialConversion(getFunction(), target, std::move(patterns)))) + if (failed(applyPartialConversion(getOperation(), target, + std::move(patterns)))) signalPassFailure(); } }; diff --git a/mlir/test/lib/Dialect/Test/TestTraits.cpp b/mlir/test/lib/Dialect/Test/TestTraits.cpp --- a/mlir/test/lib/Dialect/Test/TestTraits.cpp +++ b/mlir/test/lib/Dialect/Test/TestTraits.cpp @@ -31,11 +31,12 @@ } namespace { -struct TestTraitFolder : public PassWrapper { +struct TestTraitFolder + : public PassWrapper> { StringRef getArgument() const final { return "test-trait-folder"; } StringRef getDescription() const final { return "Run trait folding"; } - void runOnFunction() override { - (void)applyPatternsAndFoldGreedily(getFunction(), + void runOnOperation() override { + (void)applyPatternsAndFoldGreedily(getOperation(), RewritePatternSet(&getContext())); } }; diff --git a/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp b/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp --- a/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp +++ b/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp @@ -179,18 +179,18 @@ namespace { struct TosaTestQuantUtilAPI - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return PASS_NAME; } StringRef getDescription() const final { return "TOSA Test: Exercise the APIs in QuantUtils.cpp."; } - void runOnFunction() override; + void runOnOperation() override; }; -void TosaTestQuantUtilAPI::runOnFunction() { +void TosaTestQuantUtilAPI::runOnOperation() { auto *ctx = &getContext(); RewritePatternSet patterns(ctx); - auto func = getFunction(); + auto func = getOperation(); patterns.add(ctx); patterns.add(ctx); diff --git a/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp b/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp --- a/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp +++ b/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp @@ -29,7 +29,7 @@ namespace { struct TestVectorToVectorLowering - : public PassWrapper { + : public PassWrapper> { TestVectorToVectorLowering() = default; TestVectorToVectorLowering(const TestVectorToVectorLowering &pass) : PassWrapper(pass) {} @@ -47,7 +47,7 @@ Option unroll{*this, "unroll", llvm::cl::desc("Include unrolling"), llvm::cl::init(false)}; - void runOnFunction() override { + void runOnOperation() override { auto *ctx = &getContext(); RewritePatternSet patterns(ctx); if (unroll) { @@ -59,7 +59,7 @@ populateVectorToVectorCanonicalizationPatterns(patterns); populateBubbleVectorBitCastOpPatterns(patterns); populateCastAwayVectorLeadingOneDimPatterns(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } private: @@ -102,7 +102,7 @@ }; struct TestVectorContractionLowering - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-vector-contraction-lowering"; } @@ -128,7 +128,7 @@ "vectors of size 4."), llvm::cl::init(false)}; - void runOnFunction() override { + void runOnOperation() override { RewritePatternSet patterns(&getContext()); // Test on one pattern in isolation. @@ -137,7 +137,7 @@ VectorTransformsOptions options{lowering}; patterns.add(options, &getContext()); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); return; } @@ -153,7 +153,7 @@ return failure(); return success(); }); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); return; } @@ -170,12 +170,12 @@ populateVectorContractLoweringPatterns(patterns, options); populateVectorMaskOpLoweringPatterns(patterns); populateVectorShapeCastLoweringPatterns(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; struct TestVectorTransposeLowering - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-vector-transpose-lowering"; } @@ -208,7 +208,7 @@ registry.insert(); } - void runOnFunction() override { + void runOnOperation() override { RewritePatternSet patterns(&getContext()); // Test on one pattern in isolation. @@ -241,13 +241,13 @@ OpPassManager dynamicPM("builtin.func"); dynamicPM.addPass(createLinalgStrategyLowerVectorsPass(options)); - if (failed(runPipeline(dynamicPM, getFunction()))) + if (failed(runPipeline(dynamicPM, getOperation()))) return signalPassFailure(); } }; struct TestVectorUnrollingPatterns - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-vector-unrolling-patterns"; } @@ -258,7 +258,7 @@ TestVectorUnrollingPatterns() = default; TestVectorUnrollingPatterns(const TestVectorUnrollingPatterns &pass) : PassWrapper(pass) {} - void runOnFunction() override { + void runOnOperation() override { MLIRContext *ctx = &getContext(); RewritePatternSet patterns(ctx); populateVectorUnrollPatterns( @@ -297,7 +297,7 @@ })); } populateVectorToVectorCanonicalizationPatterns(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } Option unrollBasedOnType{ @@ -307,7 +307,7 @@ }; struct TestVectorDistributePatterns - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-vector-distribute-patterns"; } @@ -326,10 +326,10 @@ *this, "distribution-multiplicity", llvm::cl::MiscFlags::CommaSeparated, llvm::cl::desc("Set the multiplicity used for distributing vector")}; - void runOnFunction() override { + void runOnOperation() override { MLIRContext *ctx = &getContext(); RewritePatternSet patterns(ctx); - FuncOp func = getFunction(); + FuncOp func = getOperation(); func.walk([&](arith::AddFOp op) { OpBuilder builder(op); if (auto vecType = op.getType().dyn_cast()) { @@ -359,12 +359,12 @@ } }); populatePropagateVectorDistributionPatterns(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; struct TestVectorToLoopPatterns - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-vector-to-forloop"; } StringRef getDescription() const final { return "Test lowering patterns to break up a vector op into a for loop"; @@ -380,10 +380,10 @@ *this, "distribution-multiplicity", llvm::cl::desc("Set the multiplicity used for distributing vector"), llvm::cl::init(32)}; - void runOnFunction() override { + void runOnOperation() override { MLIRContext *ctx = &getContext(); RewritePatternSet patterns(ctx); - FuncOp func = getFunction(); + FuncOp func = getOperation(); func.walk([&](arith::AddFOp op) { // Check that the operation type can be broken down into a loop. VectorType type = op.getType().dyn_cast(); @@ -416,12 +416,13 @@ return mlir::WalkResult::interrupt(); }); populatePropagateVectorDistributionPatterns(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; struct TestVectorTransferUnrollingPatterns - : public PassWrapper { + : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); } @@ -432,7 +433,7 @@ return "Test lowering patterns to unroll transfer ops in the vector " "dialect"; } - void runOnFunction() override { + void runOnOperation() override { MLIRContext *ctx = &getContext(); RewritePatternSet patterns(ctx); populateVectorUnrollPatterns( @@ -444,13 +445,13 @@ isa(op)); })); populateVectorToVectorCanonicalizationPatterns(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; struct TestVectorTransferFullPartialSplitPatterns : public PassWrapper { + OperationPass> { StringRef getArgument() const final { return "test-vector-transfer-full-partial-split"; } @@ -473,7 +474,7 @@ llvm::cl::desc("Split using a unmasked vector.transfer + linalg.fill + " "linalg.copy operations."), llvm::cl::init(false)}; - void runOnFunction() override { + void runOnOperation() override { MLIRContext *ctx = &getContext(); RewritePatternSet patterns(ctx); VectorTransformsOptions options; @@ -482,21 +483,22 @@ else options.setVectorTransferSplit(VectorTransferSplit::VectorTransfer); patterns.add(ctx, options); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; struct TestVectorTransferOpt - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-vector-transferop-opt"; } StringRef getDescription() const final { return "Test optimization transformations for transfer ops"; } - void runOnFunction() override { transferOpflowOpt(getFunction()); } + void runOnOperation() override { transferOpflowOpt(getOperation()); } }; struct TestVectorTransferLoweringPatterns - : public PassWrapper { + : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); } @@ -506,17 +508,17 @@ StringRef getDescription() const final { return "Test lowering patterns to lower transfer ops to other vector ops"; } - void runOnFunction() override { + void runOnOperation() override { RewritePatternSet patterns(&getContext()); populateVectorTransferLoweringPatterns(patterns); populateVectorTransferPermutationMapLoweringPatterns(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; struct TestVectorMultiReductionLoweringPatterns : public PassWrapper { + OperationPass> { TestVectorMultiReductionLoweringPatterns() = default; TestVectorMultiReductionLoweringPatterns( const TestVectorMultiReductionLoweringPatterns &pass) @@ -535,19 +537,19 @@ *this, "use-outer-reductions", llvm::cl::desc("Move reductions to outer most dimensions"), llvm::cl::init(false)}; - void runOnFunction() override { + void runOnOperation() override { RewritePatternSet patterns(&getContext()); populateVectorMultiReductionLoweringPatterns( patterns, useOuterReductions ? vector::VectorMultiReductionLowering::InnerParallel : vector::VectorMultiReductionLowering::InnerReduction); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; struct TestVectorTransferCollapseInnerMostContiguousDims : public PassWrapper { + OperationPass> { TestVectorTransferCollapseInnerMostContiguousDims() = default; TestVectorTransferCollapseInnerMostContiguousDims( const TestVectorTransferCollapseInnerMostContiguousDims &pass) = default; @@ -565,16 +567,16 @@ "transfer memory and vector operands."; } - void runOnFunction() override { + void runOnOperation() override { RewritePatternSet patterns(&getContext()); populateVectorTransferCollapseInnerMostContiguousDimsPatterns(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; struct TestVectorReduceToContractPatternsPatterns : public PassWrapper { + OperationPass> { StringRef getArgument() const final { return "test-vector-reduction-to-contract-patterns"; } @@ -582,30 +584,32 @@ return "Test patterns to convert multireduce op to contract and combine " "broadcast/transpose to contract"; } - void runOnFunction() override { + void runOnOperation() override { RewritePatternSet patterns(&getContext()); populateVectorReductionToContractPatterns(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; struct TestVectorTransferDropUnitDimsPatterns - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-vector-transfer-drop-unit-dims-patterns"; } void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); } - void runOnFunction() override { + void runOnOperation() override { RewritePatternSet patterns(&getContext()); populateVectorTransferDropUnitDimsPatterns(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; struct TestFlattenVectorTransferPatterns - : public PassWrapper { + : public PassWrapper> { StringRef getArgument() const final { return "test-vector-transfer-flatten-patterns"; } @@ -616,10 +620,10 @@ void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); } - void runOnFunction() override { + void runOnOperation() override { RewritePatternSet patterns(&getContext()); populateFlattenVectorTransferPatterns(patterns); - (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); + (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); } }; diff --git a/mlir/test/lib/IR/TestDominance.cpp b/mlir/test/lib/IR/TestDominance.cpp --- a/mlir/test/lib/IR/TestDominance.cpp +++ b/mlir/test/lib/IR/TestDominance.cpp @@ -90,15 +90,16 @@ DenseMap blockIds; }; -struct TestDominancePass : public PassWrapper { +struct TestDominancePass + : public PassWrapper> { StringRef getArgument() const final { return "test-print-dominance"; } StringRef getDescription() const final { return "Print the dominance information for multiple regions."; } - void runOnFunction() override { - llvm::errs() << "Testing : " << getFunction().getName() << "\n"; - DominanceTest dominanceTest(getFunction()); + void runOnOperation() override { + llvm::errs() << "Testing : " << getOperation().getName() << "\n"; + DominanceTest dominanceTest(getOperation()); // Print dominance information. llvm::errs() << "--- DominanceInfo ---\n"; diff --git a/mlir/test/lib/IR/TestMatchers.cpp b/mlir/test/lib/IR/TestMatchers.cpp --- a/mlir/test/lib/IR/TestMatchers.cpp +++ b/mlir/test/lib/IR/TestMatchers.cpp @@ -15,8 +15,8 @@ namespace { /// This is a test pass for verifying matchers. -struct TestMatchers : public PassWrapper { - void runOnFunction() override; +struct TestMatchers : public PassWrapper> { + void runOnOperation() override; StringRef getArgument() const final { return "test-matchers"; } StringRef getDescription() const final { return "Test C++ pattern matchers."; @@ -144,8 +144,8 @@ llvm::outs() << "Pattern add(add(a, constant), a) matched\n"; } -void TestMatchers::runOnFunction() { - auto f = getFunction(); +void TestMatchers::runOnOperation() { + auto f = getOperation(); llvm::outs() << f.getName() << "\n"; if (f.getName() == "test1") test1(f); diff --git a/mlir/test/lib/IR/TestTypes.cpp b/mlir/test/lib/IR/TestTypes.cpp --- a/mlir/test/lib/IR/TestTypes.cpp +++ b/mlir/test/lib/IR/TestTypes.cpp @@ -15,15 +15,15 @@ namespace { struct TestRecursiveTypesPass - : public PassWrapper { + : public PassWrapper> { LogicalResult createIRWithTypes(); StringRef getArgument() const final { return "test-recursive-types"; } StringRef getDescription() const final { return "Test support for recursive types"; } - void runOnFunction() override { - FuncOp func = getFunction(); + void runOnOperation() override { + FuncOp func = getOperation(); // Just make sure recursive types are printed and parsed. if (func.getName() == "roundtrip") @@ -45,7 +45,7 @@ LogicalResult TestRecursiveTypesPass::createIRWithTypes() { MLIRContext *ctx = &getContext(); - FuncOp func = getFunction(); + FuncOp func = getOperation(); auto type = TestRecursiveType::get(ctx, "some_long_and_unique_name"); if (failed(type.setBody(type))) return func.emitError("expected to be able to set the type body"); diff --git a/mlir/test/lib/Pass/TestPassManager.cpp b/mlir/test/lib/Pass/TestPassManager.cpp --- a/mlir/test/lib/Pass/TestPassManager.cpp +++ b/mlir/test/lib/Pass/TestPassManager.cpp @@ -21,14 +21,16 @@ return "Test a module pass in the pass manager"; } }; -struct TestFunctionPass : public PassWrapper { - void runOnFunction() final {} +struct TestFunctionPass + : public PassWrapper> { + void runOnOperation() final {} StringRef getArgument() const final { return "test-function-pass"; } StringRef getDescription() const final { return "Test a function pass in the pass manager"; } }; -class TestOptionsPass : public PassWrapper { +class TestOptionsPass + : public PassWrapper> { public: struct Options : public PassPipelineOptions { ListOption listOption{*this, "list", @@ -48,7 +50,7 @@ stringListOption = options.stringListOption; } - void runOnFunction() final {} + void runOnOperation() final {} StringRef getArgument() const final { return "test-options-pass"; } StringRef getDescription() const final { return "Test options parsing capabilities"; diff --git a/mlir/test/lib/Transforms/TestConstantFold.cpp b/mlir/test/lib/Transforms/TestConstantFold.cpp --- a/mlir/test/lib/Transforms/TestConstantFold.cpp +++ b/mlir/test/lib/Transforms/TestConstantFold.cpp @@ -15,7 +15,8 @@ namespace { /// Simple constant folding pass. -struct TestConstantFold : public PassWrapper { +struct TestConstantFold + : public PassWrapper> { StringRef getArgument() const final { return "test-constant-fold"; } StringRef getDescription() const final { return "Test operation constant folding"; @@ -24,7 +25,7 @@ SmallVector existingConstants; void foldOperation(Operation *op, OperationFolder &helper); - void runOnFunction() override; + void runOnOperation() override; }; } // namespace @@ -41,12 +42,12 @@ // For now, we do a simple top-down pass over a function folding constants. We // don't handle conditional control flow, block arguments, folding conditional // branches, or anything else fancy. -void TestConstantFold::runOnFunction() { +void TestConstantFold::runOnOperation() { existingConstants.clear(); // Collect and fold the operations within the function. SmallVector ops; - getFunction().walk([&](Operation *op) { ops.push_back(op); }); + getOperation().walk([&](Operation *op) { ops.push_back(op); }); // Fold the constants in reverse so that the last generated constants from // folding are at the beginning. This creates somewhat of a linear ordering to diff --git a/mlir/test/lib/Transforms/TestInlining.cpp b/mlir/test/lib/Transforms/TestInlining.cpp --- a/mlir/test/lib/Transforms/TestInlining.cpp +++ b/mlir/test/lib/Transforms/TestInlining.cpp @@ -25,14 +25,14 @@ using namespace test; namespace { -struct Inliner : public PassWrapper { +struct Inliner : public PassWrapper> { StringRef getArgument() const final { return "test-inline"; } StringRef getDescription() const final { return "Test inlining region calls"; } - void runOnFunction() override { - auto function = getFunction(); + void runOnOperation() override { + auto function = getOperation(); // Collect each of the direct function calls within the module. SmallVector callers; diff --git a/mlir/test/lib/Transforms/TestLoopFusion.cpp b/mlir/test/lib/Transforms/TestLoopFusion.cpp --- a/mlir/test/lib/Transforms/TestLoopFusion.cpp +++ b/mlir/test/lib/Transforms/TestLoopFusion.cpp @@ -41,12 +41,13 @@ namespace { -struct TestLoopFusion : public PassWrapper { +struct TestLoopFusion + : public PassWrapper> { StringRef getArgument() const final { return "test-loop-fusion"; } StringRef getDescription() const final { return "Tests loop fusion utility functions."; } - void runOnFunction() override; + void runOnOperation() override; }; } // namespace @@ -175,14 +176,14 @@ return changed; } -void TestLoopFusion::runOnFunction() { +void TestLoopFusion::runOnOperation() { std::vector> depthToLoops; if (clTestLoopFusionTransformation) { // Run loop fusion until a fixed point is reached. do { depthToLoops.clear(); // Gather all AffineForOps by loop depth. - gatherLoops(getFunction(), depthToLoops); + gatherLoops(getOperation(), depthToLoops); // Try to fuse all combinations of src/dst loop nests in 'depthToLoops'. } while (iterateLoops(depthToLoops, testLoopFusionTransformation, @@ -191,7 +192,7 @@ } // Gather all AffineForOps by loop depth. - gatherLoops(getFunction(), depthToLoops); + gatherLoops(getOperation(), depthToLoops); // Run tests on all combinations of src/dst loop nests in 'depthToLoops'. if (clTestDependenceCheck) diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp --- a/mlir/test/lib/Transforms/TestLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp @@ -24,7 +24,7 @@ namespace { class TestLoopMappingPass - : public PassWrapper { + : public PassWrapper> { public: StringRef getArgument() const final { return "test-mapping-to-processing-elements"; @@ -38,8 +38,8 @@ registry.insert(); } - void runOnFunction() override { - FuncOp func = getFunction(); + void runOnOperation() override { + FuncOp func = getOperation(); // SSA values for the transformation are created out of thin air by // unregistered "new_processor_id_and_range" operations. This is enough to diff --git a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp --- a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp +++ b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp @@ -23,7 +23,8 @@ // Extracts fixed-range loops for top-level loop nests with ranges defined in // the pass constructor. Assumes loops are permutable. class SimpleParametricLoopTilingPass - : public PassWrapper { + : public PassWrapper> { public: StringRef getArgument() const final { return "test-extract-fixed-outer-loops"; @@ -39,8 +40,8 @@ sizes = outerLoopSizes; } - void runOnFunction() override { - FuncOp func = getFunction(); + void runOnOperation() override { + FuncOp func = getOperation(); func.walk([this](scf::ForOp op) { // Ignore nested loops. if (op->getParentRegion()->getParentOfType()) diff --git a/mlir/test/lib/Transforms/TestLoopUnrolling.cpp b/mlir/test/lib/Transforms/TestLoopUnrolling.cpp --- a/mlir/test/lib/Transforms/TestLoopUnrolling.cpp +++ b/mlir/test/lib/Transforms/TestLoopUnrolling.cpp @@ -33,7 +33,7 @@ } class TestLoopUnrollingPass - : public PassWrapper { + : public PassWrapper> { public: StringRef getArgument() const final { return "test-loop-unrolling"; } StringRef getDescription() const final { @@ -53,8 +53,8 @@ registry.insert(); } - void runOnFunction() override { - FuncOp func = getFunction(); + void runOnOperation() override { + FuncOp func = getOperation(); SmallVector loops; func.walk([&](scf::ForOp forOp) { if (getNestingDepth(forOp) == loopDepth) diff --git a/mlir/unittests/Pass/PassManagerTest.cpp b/mlir/unittests/Pass/PassManagerTest.cpp --- a/mlir/unittests/Pass/PassManagerTest.cpp +++ b/mlir/unittests/Pass/PassManagerTest.cpp @@ -31,7 +31,6 @@ }; /// Simple pass to annotate a FuncOp with the results of analysis. -/// Note: not using FunctionPass as it skip external functions. struct AnnotateFunctionPass : public PassWrapper> { void runOnOperation() override {