diff --git a/mlir/docs/Tutorials/Toy/Ch-4.md b/mlir/docs/Tutorials/Toy/Ch-4.md index c9a5d8188f9dd..dcdf8d83840d2 100644 --- a/mlir/docs/Tutorials/Toy/Ch-4.md +++ b/mlir/docs/Tutorials/Toy/Ch-4.md @@ -318,7 +318,8 @@ Implementing such a pass is done by creating a class inheriting from `mlir::FunctionPass` and overriding the `runOnFunction()` method. ```c++ -class ShapeInferencePass : public mlir::FunctionPass { +class ShapeInferencePass + : public mlir::PassWrapper { void runOnFunction() override { FuncOp function = getFunction(); ... diff --git a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp index 296bec094624b..f9f32c22f8d4d 100644 --- a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp @@ -44,7 +44,8 @@ namespace { /// d) infer the shape of its output from the argument types. /// 3) If the worklist is empty, the algorithm succeeded. /// -class ShapeInferencePass : public mlir::FunctionPass { +class ShapeInferencePass + : public mlir::PassWrapper { public: void runOnFunction() override { auto f = getFunction(); diff --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp index 0614f3ac043b3..0988f5fe0c41b 100644 --- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp @@ -260,7 +260,8 @@ struct TransposeOpLowering : public ConversionPattern { /// computationally intensive (like matmul for example...) while keeping the /// rest of the code in the Toy dialect. namespace { -struct ToyToAffineLoweringPass : public FunctionPass { +struct ToyToAffineLoweringPass + : public PassWrapper { void runOnFunction() final; }; } // end anonymous namespace. diff --git a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp index 296bec094624b..f9f32c22f8d4d 100644 --- a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp @@ -44,7 +44,8 @@ namespace { /// d) infer the shape of its output from the argument types. /// 3) If the worklist is empty, the algorithm succeeded. /// -class ShapeInferencePass : public mlir::FunctionPass { +class ShapeInferencePass + : public mlir::PassWrapper { public: void runOnFunction() override { auto f = getFunction(); diff --git a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp index 4292d14ec3ed2..56629d7ae217e 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp @@ -259,7 +259,8 @@ struct TransposeOpLowering : public ConversionPattern { /// computationally intensive (like matmul for example...) while keeping the /// rest of the code in the Toy dialect. namespace { -struct ToyToAffineLoweringPass : public FunctionPass { +struct ToyToAffineLoweringPass + : public PassWrapper { void runOnFunction() final; }; } // end anonymous namespace. diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp index 99465d3201e5d..9c36f11c52c4b 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -154,7 +154,7 @@ class PrintOpLowering : public ConversionPattern { namespace { struct ToyToLLVMLoweringPass - : public OperationPass { + : public PassWrapper> { void runOnOperation() final; }; } // end anonymous namespace diff --git a/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp index 296bec094624b..f9f32c22f8d4d 100644 --- a/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp @@ -44,7 +44,8 @@ namespace { /// d) infer the shape of its output from the argument types. /// 3) If the worklist is empty, the algorithm succeeded. /// -class ShapeInferencePass : public mlir::FunctionPass { +class ShapeInferencePass + : public mlir::PassWrapper { public: void runOnFunction() override { auto f = getFunction(); diff --git a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp index 0614f3ac043b3..0988f5fe0c41b 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp @@ -260,7 +260,8 @@ struct TransposeOpLowering : public ConversionPattern { /// computationally intensive (like matmul for example...) while keeping the /// rest of the code in the Toy dialect. namespace { -struct ToyToAffineLoweringPass : public FunctionPass { +struct ToyToAffineLoweringPass + : public PassWrapper { void runOnFunction() final; }; } // end anonymous namespace. diff --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp index 99465d3201e5d..9c36f11c52c4b 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -154,7 +154,7 @@ class PrintOpLowering : public ConversionPattern { namespace { struct ToyToLLVMLoweringPass - : public OperationPass { + : public PassWrapper> { void runOnOperation() final; }; } // end anonymous namespace diff --git a/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp index 296bec094624b..f9f32c22f8d4d 100644 --- a/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp @@ -44,7 +44,8 @@ namespace { /// d) infer the shape of its output from the argument types. /// 3) If the worklist is empty, the algorithm succeeded. /// -class ShapeInferencePass : public mlir::FunctionPass { +class ShapeInferencePass + : public mlir::PassWrapper { public: void runOnFunction() override { auto f = getFunction(); diff --git a/mlir/include/mlir/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.h b/mlir/include/mlir/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.h index bd65970d5bf77..fdd203a6f6ef1 100644 --- a/mlir/include/mlir/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.h +++ b/mlir/include/mlir/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.h @@ -14,7 +14,7 @@ namespace mlir { class LLVMTypeConverter; class ModuleOp; -template class OpPassBase; +template class OperationPass; class OwningRewritePatternList; /// Collect a set of patterns to convert from the AVX512 dialect to LLVM. @@ -22,7 +22,7 @@ void populateAVX512ToLLVMConversionPatterns(LLVMTypeConverter &converter, OwningRewritePatternList &patterns); /// Create a pass to convert AVX512 operations to the LLVMIR dialect. -std::unique_ptr> createConvertAVX512ToLLVMPass(); +std::unique_ptr> createConvertAVX512ToLLVMPass(); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h b/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h index 35794bfab6dd2..6e21483c67280 100644 --- a/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h +++ b/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h @@ -19,7 +19,7 @@ namespace mlir { class Location; class ModuleOp; -template class OpPassBase; +template class OperationPass; namespace gpu { class GPUModuleOp; @@ -42,7 +42,7 @@ using CubinGenerator = /// attached as a string attribute named 'nvvm.cubin' to the kernel function. /// After the transformation, the body of the kernel function is removed (i.e., /// it is turned into a declaration). -std::unique_ptr> +std::unique_ptr> createConvertGPUKernelToCubinPass(CubinGenerator cubinGenerator); /// Creates a pass to convert a gpu.launch_func operation into a sequence of @@ -51,7 +51,7 @@ createConvertGPUKernelToCubinPass(CubinGenerator cubinGenerator); /// This pass does not generate code to call CUDA directly but instead uses a /// small wrapper library that exports a stable and conveniently typed ABI /// on top of CUDA. -std::unique_ptr> +std::unique_ptr> createConvertGpuLaunchFuncToCudaCallsPass(); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h index 4a6698cfb50cc..5dbfce9bd00ff 100644 --- a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h +++ b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h @@ -14,7 +14,7 @@ namespace mlir { class LLVMTypeConverter; class OwningRewritePatternList; -template class OpPassBase; +template class OperationPass; namespace gpu { class GPUModuleOp; @@ -25,7 +25,8 @@ void populateGpuToNVVMConversionPatterns(LLVMTypeConverter &converter, OwningRewritePatternList &patterns); /// Creates a pass that lowers GPU dialect operations to NVVM counterparts. -std::unique_ptr> createLowerGpuOpsToNVVMOpsPass(); +std::unique_ptr> +createLowerGpuOpsToNVVMOpsPass(); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h index 64fa40c026221..341526fc99645 100644 --- a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h +++ b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h @@ -15,10 +15,11 @@ namespace mlir { namespace gpu { class GPUModuleOp; } // namespace gpu -template class OpPassBase; +template class OperationPass; /// Creates a pass that lowers GPU dialect operations to ROCDL counterparts. -std::unique_ptr> createLowerGpuOpsToROCDLOpsPass(); +std::unique_ptr> +createLowerGpuOpsToROCDLOpsPass(); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h b/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h index cf3246a55114d..f22db8477d848 100644 --- a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h +++ b/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h @@ -20,11 +20,11 @@ namespace mlir { class ModuleOp; -template class OpPassBase; +template class OperationPass; /// Pass to convert GPU Ops to SPIR-V ops. For a gpu.func to be converted, it /// should have a spv.entry_point_abi attribute. -std::unique_ptr> createConvertGPUToSPIRVPass(); +std::unique_ptr> createConvertGPUToSPIRVPass(); } // namespace mlir #endif // MLIR_CONVERSION_GPUTOSPIRV_CONVERTGPUTOSPIRVPASS_H diff --git a/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h b/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h index 9a02860bfc1af..92e3f80b2be35 100644 --- a/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h +++ b/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h @@ -21,12 +21,12 @@ namespace mlir { class ModuleOp; -template class OpPassBase; +template class OperationPass; -std::unique_ptr> +std::unique_ptr> createConvertVulkanLaunchFuncToVulkanCallsPass(); -std::unique_ptr> +std::unique_ptr> createConvertGpuLaunchFuncToVulkanLaunchFuncPass(); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h index 4124f3f0e3b2d..b7c9d0016d65c 100644 --- a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h +++ b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h @@ -14,7 +14,7 @@ namespace mlir { class MLIRContext; class ModuleOp; -template class OpPassBase; +template class OperationPass; /// Populate the given list with patterns that convert from Linalg to LLVM. void populateLinalgToLLVMConversionPatterns(LLVMTypeConverter &converter, @@ -22,7 +22,7 @@ void populateLinalgToLLVMConversionPatterns(LLVMTypeConverter &converter, MLIRContext *ctx); /// Create a pass to convert Linalg operations to the LLVMIR dialect. -std::unique_ptr> createConvertLinalgToLLVMPass(); +std::unique_ptr> createConvertLinalgToLLVMPass(); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h b/mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h index 4ed2bddac5756..9b10b4b705d5d 100644 --- a/mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h +++ b/mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h @@ -18,7 +18,7 @@ namespace mlir { /// Creates and returns a pass to convert Linalg ops to SPIR-V ops. -std::unique_ptr> createLinalgToSPIRVPass(); +std::unique_ptr> createLinalgToSPIRVPass(); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h index 049e8538d746c..4488b071ea43b 100644 --- a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h +++ b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h @@ -14,7 +14,7 @@ namespace mlir { class FuncOp; -template class OpPassBase; +template class OperationPass; class Pass; /// Create a pass that converts loop nests into GPU kernels. It considers @@ -25,9 +25,9 @@ class Pass; /// parallelization is performed, it is under the responsibility of the caller /// to strip-mine the loops and to perform the dependence analysis before /// calling the conversion. -std::unique_ptr> +std::unique_ptr> createSimpleLoopsToGPUPass(unsigned numBlockDims, unsigned numThreadDims); -std::unique_ptr> createSimpleLoopsToGPUPass(); +std::unique_ptr> createSimpleLoopsToGPUPass(); /// Create a pass that converts every loop operation within the body of the /// FuncOp into a GPU launch. The number of workgroups and workgroup size for @@ -35,10 +35,10 @@ std::unique_ptr> createSimpleLoopsToGPUPass(); /// method. For testing, the values are set as constants obtained from a command /// line flag. See convertLoopToGPULaunch for a description of the required /// semantics of the converted loop operation. -std::unique_ptr> +std::unique_ptr> createLoopToGPUPass(ArrayRef numWorkGroups, ArrayRef workGroupSize); -std::unique_ptr> createLoopToGPUPass(); +std::unique_ptr> createLoopToGPUPass(); /// Creates a pass that converts loop.parallel operations into a gpu.launch /// operation. The mapping of loop dimensions to launch dimensions is derived diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h index c4aab9f867f6b..72f852e571878 100644 --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h @@ -14,7 +14,7 @@ namespace mlir { class LLVMTypeConverter; class ModuleOp; -template class OpPassBase; +template class OperationPass; class OwningRewritePatternList; /// Collect a set of patterns to convert memory-related operations from the @@ -61,7 +61,7 @@ struct LowerToLLVMOptions { /// Creates a pass to convert the Standard dialect into the LLVMIR dialect. /// stdlib malloc/free is used for allocating memrefs allocated with std.alloc, /// while LLVM's alloca is used for those allocated with std.alloca. -std::unique_ptr> createLowerToLLVMPass( +std::unique_ptr> createLowerToLLVMPass( const LowerToLLVMOptions &options = { /*useBarePtrCallConv=*/false, /*emitCWrappers=*/false, /*indexBitwidth=*/kDeriveIndexBitwidthFromDataLayout}); diff --git a/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h b/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h index e5436d4203f01..29e1d635a00f2 100644 --- a/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h +++ b/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h @@ -18,7 +18,7 @@ namespace mlir { /// Pass to convert StandardOps to SPIR-V ops. -std::unique_ptr> createConvertStandardToSPIRVPass(); +std::unique_ptr> createConvertStandardToSPIRVPass(); /// Pass to legalize ops that are not directly lowered to SPIR-V. std::unique_ptr createLegalizeStdOpsForSPIRVLoweringPass(); diff --git a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h index a92906d0c2c3a..0ef6df5c34b3b 100644 --- a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h +++ b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h @@ -13,7 +13,7 @@ namespace mlir { class LLVMTypeConverter; class ModuleOp; -template class OpPassBase; +template class OperationPass; /// Collect a set of patterns to convert from Vector contractions to LLVM Matrix /// Intrinsics. To lower to assembly, the LLVM flag -lower-matrix-intrinsics @@ -26,7 +26,7 @@ void populateVectorToLLVMConversionPatterns(LLVMTypeConverter &converter, OwningRewritePatternList &patterns); /// Create a pass to convert vector operations to the LLVMIR dialect. -std::unique_ptr> createConvertVectorToLLVMPass(); +std::unique_ptr> createConvertVectorToLLVMPass(); } // namespace mlir diff --git a/mlir/include/mlir/Dialect/Affine/Passes.h b/mlir/include/mlir/Dialect/Affine/Passes.h index 75ff4a33649d6..5d3b997b9b585 100644 --- a/mlir/include/mlir/Dialect/Affine/Passes.h +++ b/mlir/include/mlir/Dialect/Affine/Passes.h @@ -24,32 +24,33 @@ class AffineForOp; class FuncOp; class ModuleOp; class Pass; -template class OpPassBase; +template class OperationPass; /// Creates a simplification pass for affine structures (maps and sets). In /// addition, this pass also normalizes memrefs to have the trivial (identity) /// layout map. -std::unique_ptr> createSimplifyAffineStructuresPass(); +std::unique_ptr> createSimplifyAffineStructuresPass(); /// Creates a loop invariant code motion pass that hoists loop invariant /// operations out of affine loops. -std::unique_ptr> createAffineLoopInvariantCodeMotionPass(); +std::unique_ptr> +createAffineLoopInvariantCodeMotionPass(); /// Performs packing (or explicit copying) of accessed memref regions into /// buffers in the specified faster memory space through either pointwise copies /// or DMA operations. -std::unique_ptr> createAffineDataCopyGenerationPass( +std::unique_ptr> createAffineDataCopyGenerationPass( unsigned slowMemorySpace, unsigned fastMemorySpace, unsigned tagMemorySpace = 0, int minDmaTransferSize = 1024, uint64_t fastMemCapacityBytes = std::numeric_limits::max()); /// Overload relying on pass options for initialization. -std::unique_ptr> createAffineDataCopyGenerationPass(); +std::unique_ptr> createAffineDataCopyGenerationPass(); /// Creates a pass to perform tiling on loop nests. -std::unique_ptr> +std::unique_ptr> createLoopTilingPass(uint64_t cacheSizeBytes); /// Overload relying on pass options for initialization. -std::unique_ptr> createLoopTilingPass(); +std::unique_ptr> createLoopTilingPass(); /// Creates a loop unrolling pass with the provided parameters. /// 'getUnrollFactor' is a function callback for clients to supply a function @@ -57,22 +58,22 @@ std::unique_ptr> createLoopTilingPass(); /// factors supplied through other means. If -1 is passed as the unrollFactor /// and no callback is provided, anything passed from the command-line (if at /// all) or the default unroll factor is used (LoopUnroll:kDefaultUnrollFactor). -std::unique_ptr> createLoopUnrollPass( +std::unique_ptr> createLoopUnrollPass( int unrollFactor = -1, int unrollFull = -1, const std::function &getUnrollFactor = nullptr); /// Creates a loop unroll jam pass to unroll jam by the specified factor. A /// factor of -1 lets the pass use the default factor or the one on the command /// line if provided. -std::unique_ptr> +std::unique_ptr> createLoopUnrollAndJamPass(int unrollJamFactor = -1); /// Creates a pass to vectorize loops, operations and data types using a /// target-independent, n-D super-vector abstraction. -std::unique_ptr> +std::unique_ptr> createSuperVectorizePass(ArrayRef virtualVectorSize); /// Overload relying on pass options for initialization. -std::unique_ptr> createSuperVectorizePass(); +std::unique_ptr> createSuperVectorizePass(); } // end namespace mlir diff --git a/mlir/include/mlir/Dialect/GPU/Passes.h b/mlir/include/mlir/Dialect/GPU/Passes.h index 51536c4dc4110..bc349061f39f0 100644 --- a/mlir/include/mlir/Dialect/GPU/Passes.h +++ b/mlir/include/mlir/Dialect/GPU/Passes.h @@ -19,10 +19,10 @@ namespace mlir { class MLIRContext; class ModuleOp; -template class OpPassBase; +template class OperationPass; class OwningRewritePatternList; -std::unique_ptr> createGpuKernelOutliningPass(); +std::unique_ptr> createGpuKernelOutliningPass(); /// Collect a set of patterns to rewrite ops within the GPU dialect. void populateGpuRewritePatterns(MLIRContext *context, diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.h b/mlir/include/mlir/Dialect/Linalg/Passes.h index 9f52e360c7fb6..d8886acc59924 100644 --- a/mlir/include/mlir/Dialect/Linalg/Passes.h +++ b/mlir/include/mlir/Dialect/Linalg/Passes.h @@ -19,34 +19,34 @@ namespace mlir { class FuncOp; class ModuleOp; -template class OpPassBase; +template class OperationPass; class Pass; -std::unique_ptr> createLinalgFusionPass(); +std::unique_ptr> createLinalgFusionPass(); std::unique_ptr createLinalgFusionOfTensorOpsPass(); -std::unique_ptr> +std::unique_ptr> createLinalgTilingPass(ArrayRef tileSizes = {}); -std::unique_ptr> +std::unique_ptr> createLinalgTilingToParallelLoopsPass(ArrayRef tileSizes = {}); -std::unique_ptr> +std::unique_ptr> createLinalgPromotionPass(bool dynamicBuffers); -std::unique_ptr> createLinalgPromotionPass(); +std::unique_ptr> createLinalgPromotionPass(); /// Create a pass to convert Linalg operations to loop.for loops and /// std.load/std.store accesses. -std::unique_ptr> createConvertLinalgToLoopsPass(); +std::unique_ptr> createConvertLinalgToLoopsPass(); /// Create a pass to convert Linalg operations to loop.parallel loops and /// std.load/std.store accesses. -std::unique_ptr> createConvertLinalgToParallelLoopsPass(); +std::unique_ptr> createConvertLinalgToParallelLoopsPass(); /// Create a pass to convert Linalg operations to affine.for loops and /// affine_load/affine_store accesses. /// Placeholder for now, this is NYI. -std::unique_ptr> createConvertLinalgToAffineLoopsPass(); +std::unique_ptr> createConvertLinalgToAffineLoopsPass(); } // namespace mlir diff --git a/mlir/include/mlir/Dialect/Quant/Passes.h b/mlir/include/mlir/Dialect/Quant/Passes.h index 34c7c1f011a74..b938c9a86b722 100644 --- a/mlir/include/mlir/Dialect/Quant/Passes.h +++ b/mlir/include/mlir/Dialect/Quant/Passes.h @@ -20,20 +20,20 @@ namespace mlir { class FuncOp; -template class OpPassBase; +template class OperationPass; namespace quant { /// Creates a pass that converts quantization simulation operations (i.e. /// FakeQuant and those like it) to casts into/out of supported QuantizedTypes. -std::unique_ptr> createConvertSimulatedQuantPass(); +std::unique_ptr> createConvertSimulatedQuantPass(); /// Creates a pass that converts constants followed by a qbarrier to a /// constant whose value is quantized. This is typically one of the last /// passes done when lowering to express actual quantized arithmetic in a /// low level representation. Because it modifies the constant, it is /// destructive and cannot be undone. -std::unique_ptr> createConvertConstPass(); +std::unique_ptr> createConvertConstPass(); } // namespace quant } // namespace mlir diff --git a/mlir/include/mlir/Dialect/SPIRV/Passes.h b/mlir/include/mlir/Dialect/SPIRV/Passes.h index fc13460b797bd..afc60805f75e8 100644 --- a/mlir/include/mlir/Dialect/SPIRV/Passes.h +++ b/mlir/include/mlir/Dialect/SPIRV/Passes.h @@ -23,7 +23,7 @@ class ModuleOp; /// StorageBuffer, PhysicalStorageBuffer, Uniform, and PushConstant storage /// classes with layout information. /// Right now this pass only supports Vulkan layout rules. -std::unique_ptr> +std::unique_ptr> createDecorateSPIRVCompositeTypeLayoutPass(); /// Creates an operation pass that deduces and attaches the minimal version/ @@ -34,7 +34,7 @@ createDecorateSPIRVCompositeTypeLayoutPass(); /// to know which one to pick. `spv.target_env` gives the hard limit as for /// what the target environment can support; this pass deduces what are /// actually needed for a specific spv.module op. -std::unique_ptr> +std::unique_ptr> createUpdateVersionCapabilityExtensionPass(); /// Creates an operation pass that lowers the ABI attributes specified during @@ -44,7 +44,7 @@ createUpdateVersionCapabilityExtensionPass(); /// argument. /// 2. Inserts the EntryPointOp and the ExecutionModeOp for entry point /// functions using the specification in the `spv.entry_point_abi` attribute. -std::unique_ptr> createLowerABIAttributesPass(); +std::unique_ptr> createLowerABIAttributesPass(); } // namespace spirv } // namespace mlir diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h index c1eec4f4706af..6d6226f83335c 100644 --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -139,161 +139,119 @@ class Pass { virtual void runOnOperation() = 0; /// A clone method to create a copy of this pass. - virtual std::unique_ptr clone() const = 0; + std::unique_ptr clone() const { + auto newInst = clonePass(); + newInst->copyOptionValuesFrom(this); + return newInst; + } /// Return the current operation being transformed. Operation *getOperation() { return getPassState().irAndPassFailed.getPointer(); } - /// Returns the current analysis manager. - AnalysisManager getAnalysisManager() { - return getPassState().analysisManager; - } - - /// Copy the option values from 'other', which is another instance of this - /// pass. - void copyOptionValuesFrom(const Pass *other); - -private: - /// Forwarding function to execute this pass on the given operation. - LLVM_NODISCARD - LogicalResult run(Operation *op, AnalysisManager am); - - /// Out of line virtual method to ensure vtables and metadata are emitted to a - /// single .o file. - virtual void anchor(); - - /// Represents a unique identifier for the pass. - const PassID *passID; - - /// The name of the operation that this pass operates on, or None if this is a - /// generic OperationPass. - Optional opName; - - /// The current execution state for the pass. - Optional passState; - - /// The set of statistics held by this pass. - std::vector statistics; - - /// The pass options registered to this pass instance. - detail::PassOptions passOptions; - - /// Allow access to 'clone' and 'run'. - friend class OpPassManager; - - /// Allow access to 'passOptions'. - friend class PassInfo; -}; - -//===----------------------------------------------------------------------===// -// Pass Model Definitions -//===----------------------------------------------------------------------===// -namespace detail { -/// The opaque CRTP model of a pass. This class provides utilities for derived -/// pass execution and handles all of the necessary polymorphic API. -template -class PassModel : public BasePassT { -public: - /// Support isa/dyn_cast functionality for the derived pass class. - static bool classof(const Pass *pass) { - return pass->getPassID() == PassID::getID(); - } - -protected: - explicit PassModel(Optional opName = llvm::None) - : BasePassT(PassID::getID(), opName) {} - /// Signal that some invariant was broken when running. The IR is allowed to /// be in an invalid state. - void signalPassFailure() { - this->getPassState().irAndPassFailed.setInt(true); - } + void signalPassFailure() { getPassState().irAndPassFailed.setInt(true); } /// Query an analysis for the current ir unit. template AnalysisT &getAnalysis() { - return this->getAnalysisManager().template getAnalysis(); + return getAnalysisManager().getAnalysis(); } /// Query a cached instance of an analysis for the current ir unit if one /// exists. template Optional> getCachedAnalysis() { - return this->getAnalysisManager().template getCachedAnalysis(); + return getAnalysisManager().getCachedAnalysis(); } /// Mark all analyses as preserved. void markAllAnalysesPreserved() { - this->getPassState().preservedAnalyses.preserveAll(); + getPassState().preservedAnalyses.preserveAll(); } /// Mark the provided analyses as preserved. template void markAnalysesPreserved() { - this->getPassState().preservedAnalyses.template preserve(); + getPassState().preservedAnalyses.preserve(); } void markAnalysesPreserved(const AnalysisID *id) { - this->getPassState().preservedAnalyses.preserve(id); - } - - /// Returns the derived pass name. - StringRef getName() override { - StringRef name = llvm::getTypeName(); - if (!name.consume_front("mlir::")) - name.consume_front("(anonymous namespace)::"); - return name; - } - - /// A clone method to create a copy of this pass. - std::unique_ptr clone() const override { - auto newInst = std::make_unique(*static_cast(this)); - newInst->copyOptionValuesFrom(this); - return newInst; + getPassState().preservedAnalyses.preserve(id); } /// Returns the analysis for the parent operation if it exists. template Optional> getCachedParentAnalysis(Operation *parent) { - return this->getAnalysisManager() - .template getCachedParentAnalysis(parent); + return getAnalysisManager().getCachedParentAnalysis(parent); } template Optional> getCachedParentAnalysis() { - return this->getAnalysisManager() - .template getCachedParentAnalysis( - this->getOperation()->getParentOp()); + return getAnalysisManager().getCachedParentAnalysis( + getOperation()->getParentOp()); } /// Returns the analysis for the given child operation if it exists. template Optional> getCachedChildAnalysis(Operation *child) { - return this->getAnalysisManager() - .template getCachedChildAnalysis(child); + return getAnalysisManager().getCachedChildAnalysis(child); } /// Returns the analysis for the given child operation, or creates it if it /// doesn't exist. template AnalysisT &getChildAnalysis(Operation *child) { - return this->getAnalysisManager().template getChildAnalysis( - child); + return getAnalysisManager().getChildAnalysis(child); } -}; -} // end namespace detail -/// Utility base class for OpPass below to denote an opaque pass operating on a -/// specific operation type. -template class OpPassBase : public Pass { -public: - using Pass::Pass; - - /// Support isa/dyn_cast functionality. - static bool classof(const Pass *pass) { - return pass->getOpName() == OpT::getOperationName(); + /// Returns the current analysis manager. + AnalysisManager getAnalysisManager() { + return getPassState().analysisManager; } + + /// Create a copy of this pass, ignoring statistics and options. + virtual std::unique_ptr clonePass() const = 0; + + /// Copy the option values from 'other', which is another instance of this + /// pass. + void copyOptionValuesFrom(const Pass *other); + +private: + /// Forwarding function to execute this pass on the given operation. + LLVM_NODISCARD + LogicalResult run(Operation *op, AnalysisManager am); + + /// Out of line virtual method to ensure vtables and metadata are emitted to a + /// single .o file. + virtual void anchor(); + + /// Represents a unique identifier for the pass. + const PassID *passID; + + /// The name of the operation that this pass operates on, or None if this is a + /// generic OperationPass. + Optional opName; + + /// The current execution state for the pass. + Optional passState; + + /// The set of statistics held by this pass. + std::vector statistics; + + /// The pass options registered to this pass instance. + detail::PassOptions passOptions; + + /// Allow access to 'clone' and 'run'. + friend class OpPassManager; + + /// Allow access to 'passOptions'. + friend class PassInfo; }; +//===----------------------------------------------------------------------===// +// Pass Model Definitions +//===----------------------------------------------------------------------===// + /// Pass to transform an operation of a specific type. /// /// Operation passes must not: @@ -304,11 +262,16 @@ template class OpPassBase : public Pass { /// /// Derived function passes are expected to provide the following: /// - A 'void runOnOperation()' method. -template -class OperationPass : public detail::PassModel> { +/// - A 'StringRef getName() const' method. +/// - A 'std::unique_ptr clonePass() const' method. +template class OperationPass : public Pass { protected: - OperationPass() - : detail::PassModel>(OpT::getOperationName()) {} + OperationPass(const PassID *passID) : Pass(passID, OpT::getOperationName()) {} + + /// Support isa/dyn_cast functionality. + static bool classof(const Pass *pass) { + return pass->getOpName() == OpT::getOperationName(); + } /// Return the current operation being transformed. OpT getOperation() { return cast(Pass::getOperation()); } @@ -324,14 +287,23 @@ class OperationPass : public detail::PassModel> { /// /// Derived function passes are expected to provide the following: /// - A 'void runOnOperation()' method. -template -struct OperationPass : public detail::PassModel {}; +/// - A 'StringRef getName() const' method. +/// - A 'std::unique_ptr clonePass() const' method. +template <> class OperationPass : public Pass { +protected: + OperationPass(const PassID *passID) : Pass(passID) {} +}; /// A model for providing function pass specific utilities. /// /// Derived function passes are expected to provide the following: /// - A 'void runOnFunction()' method. -template struct FunctionPass : public OperationPass { +/// - A 'StringRef getName() const' method. +/// - A 'std::unique_ptr clonePass() const' method. +class FunctionPass : public OperationPass { +public: + using OperationPass::OperationPass; + /// The polymorphic API that runs the pass over the currently held function. virtual void runOnFunction() = 0; @@ -344,6 +316,35 @@ template struct FunctionPass : public OperationPass { /// Return the current function being transformed. FuncOp getFunction() { return this->getOperation(); } }; + +/// This class provides a CRTP wrapper around a base pass class to define +/// several necessary utility methods. This should only be used for passes that +/// are not suitably represented using the declarative pass specification(i.e. +/// tablegen backend). +template class PassWrapper : public BaseT { +public: + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const Pass *pass) { + return pass->getPassID() == PassID::getID(); + } + +protected: + PassWrapper() : BaseT(PassID::getID()) {} + + /// Returns the derived pass name. + StringRef getName() override { + StringRef name = llvm::getTypeName(); + if (!name.consume_front("mlir::")) + name.consume_front("(anonymous namespace)::"); + return name; + } + + /// A clone method to create a copy of this pass. + std::unique_ptr clonePass() const override { + return std::make_unique(*static_cast(this)); + } +}; + } // end namespace mlir #endif // MLIR_PASS_PASS_H diff --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h index d9aee6e1f2c21..6f5601f3006bd 100644 --- a/mlir/include/mlir/Transforms/Passes.h +++ b/mlir/include/mlir/Transforms/Passes.h @@ -24,7 +24,7 @@ class AffineForOp; class FuncOp; class ModuleOp; class Pass; -template class OpPassBase; +template class OperationPass; /// Creates an instance of the Canonicalizer pass. std::unique_ptr createCanonicalizerPass(); @@ -35,7 +35,7 @@ std::unique_ptr createCSEPass(); /// Creates a loop fusion pass which fuses loops. Buffers of size less than or /// equal to `localBufSizeThreshold` are promoted to memory space /// `fastMemorySpace'. -std::unique_ptr> +std::unique_ptr> createLoopFusionPass(unsigned fastMemorySpace = 0, uint64_t localBufSizeThreshold = 0, bool maximalFusion = false); @@ -46,16 +46,16 @@ std::unique_ptr createLoopInvariantCodeMotionPass(); /// Creates a pass to pipeline explicit movement of data across levels of the /// memory hierarchy. -std::unique_ptr> createPipelineDataTransferPass(); +std::unique_ptr> createPipelineDataTransferPass(); /// Lowers affine control flow operations (ForStmt, IfStmt and AffineApplyOp) /// to equivalent lower-level constructs (flow of basic blocks and arithmetic /// primitives). -std::unique_ptr> createLowerAffinePass(); +std::unique_ptr> createLowerAffinePass(); /// Creates a pass that transforms perfectly nested loops with independent /// bounds into a single loop. -std::unique_ptr> createLoopCoalescingPass(); +std::unique_ptr> createLoopCoalescingPass(); /// Creates a pass that transforms a single ParallelLoop over N induction /// variables into another ParallelLoop over less than N induction variables. @@ -63,14 +63,14 @@ std::unique_ptr createParallelLoopCollapsingPass(); /// Creates a pass to perform optimizations relying on memref dataflow such as /// store to load forwarding, elimination of dead stores, and dead allocs. -std::unique_ptr> createMemRefDataFlowOptPass(); +std::unique_ptr> createMemRefDataFlowOptPass(); /// Creates a pass to strip debug information from a function. std::unique_ptr createStripDebugInfoPass(); /// Creates a pass which prints the list of ops and the number of occurrences in /// the module. -std::unique_ptr> createPrintOpStatsPass(); +std::unique_ptr> createPrintOpStatsPass(); /// Creates a pass which inlines calls and callable operations as defined by /// the CallGraph. diff --git a/mlir/include/mlir/Transforms/ViewOpGraph.h b/mlir/include/mlir/Transforms/ViewOpGraph.h index 7b4a7a4c4ecd1..61f40358fec21 100644 --- a/mlir/include/mlir/Transforms/ViewOpGraph.h +++ b/mlir/include/mlir/Transforms/ViewOpGraph.h @@ -20,7 +20,7 @@ namespace mlir { class Block; class ModuleOp; -template class OpPassBase; +template class OperationPass; /// Displays the graph in a window. This is for use from the debugger and /// depends on Graphviz to generate the graph. @@ -32,7 +32,7 @@ raw_ostream &writeGraph(raw_ostream &os, Block &block, bool shortNames = false, const Twine &title = ""); /// Creates a pass to print op graphs. -std::unique_ptr> +std::unique_ptr> createPrintOpGraphPass(raw_ostream &os = llvm::errs(), bool shortNames = false, const Twine &title = ""); diff --git a/mlir/include/mlir/Transforms/ViewRegionGraph.h b/mlir/include/mlir/Transforms/ViewRegionGraph.h index e8233f022ec1b..950f4c349bbf3 100644 --- a/mlir/include/mlir/Transforms/ViewRegionGraph.h +++ b/mlir/include/mlir/Transforms/ViewRegionGraph.h @@ -19,7 +19,7 @@ namespace mlir { class FuncOp; -template class OpPassBase; +template class OperationPass; class Region; /// Displays the CFG in a window. This is for use from the debugger and @@ -32,7 +32,7 @@ raw_ostream &writeGraph(raw_ostream &os, Region ®ion, bool shortNames = false, const Twine &title = ""); /// Creates a pass to print CFG graphs. -std::unique_ptr> +std::unique_ptr> createPrintCFGGraphPass(raw_ostream &os = llvm::errs(), bool shortNames = false, const Twine &title = ""); diff --git a/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp b/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp index 08b187fc835eb..6117100fec98b 100644 --- a/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp +++ b/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp @@ -164,7 +164,7 @@ void mlir::populateAVX512ToLLVMConversionPatterns( namespace { struct ConvertAVX512ToLLVMPass - : public OperationPass { + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_ConvertAVX512ToLLVM #include "mlir/Conversion/Passes.h.inc" @@ -193,6 +193,6 @@ void ConvertAVX512ToLLVMPass::runOnOperation() { } } -std::unique_ptr> mlir::createConvertAVX512ToLLVMPass() { +std::unique_ptr> mlir::createConvertAVX512ToLLVMPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp index 56928da2c633d..c45444948e647 100644 --- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp +++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp @@ -577,7 +577,7 @@ void mlir::populateAffineToStdConversionPatterns( } namespace { -class LowerAffinePass : public FunctionPass { +class LowerAffinePass : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_ConvertAffineToStandard #include "mlir/Conversion/Passes.h.inc" @@ -595,6 +595,6 @@ class LowerAffinePass : public FunctionPass { /// Lowers If and For operations within a function into their lower level CFG /// equivalent blocks. -std::unique_ptr> mlir::createLowerAffinePass() { +std::unique_ptr> mlir::createLowerAffinePass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp index 1640978b3a18c..38820f174d98a 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp @@ -47,7 +47,8 @@ static constexpr const char *kCubinAnnotation = "nvvm.cubin"; /// GPU binary code, which is then attached as an attribute to the function. The /// function body is erased. class GpuKernelToCubinPass - : public OperationPass { + : public PassWrapper> { public: GpuKernelToCubinPass(CubinGenerator cubinGenerator) : cubinGenerator(cubinGenerator) {} @@ -143,7 +144,7 @@ StringAttr GpuKernelToCubinPass::translateGPUModuleToCubinAnnotation( return StringAttr::get({cubin->data(), cubin->size()}, loc->getContext()); } -std::unique_ptr> +std::unique_ptr> mlir::createConvertGPUKernelToCubinPass(CubinGenerator cubinGenerator) { return std::make_unique(cubinGenerator); } diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp index 71fe129d3875e..9a71ef56e3090 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp @@ -61,7 +61,8 @@ namespace { /// /// Intermediate data structures are allocated on the stack. class GpuLaunchFuncToCudaCallsPass - : public OperationPass { + : public PassWrapper> { private: /// Include the generated pass utilities. #define GEN_PASS_ConvertGpuLaunchFuncToCudaCalls @@ -464,7 +465,7 @@ void GpuLaunchFuncToCudaCallsPass::translateGpuLaunchCalls( launchOp.erase(); } -std::unique_ptr> +std::unique_ptr> mlir::createConvertGpuLaunchFuncToCudaCallsPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp index d8297c76ba9a4..f4161a77c6c1d 100644 --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -246,7 +246,8 @@ struct GPUReturnOpLowering : public ConvertToLLVMPattern { /// This pass only handles device code and is not meant to be run on GPU host /// code. class LowerGpuOpsToNVVMOpsPass - : public OperationPass { + : public PassWrapper> { public: /// Include the generated pass utilities. #define GEN_PASS_ConvertGpuOpsToNVVMOps @@ -324,7 +325,7 @@ void mlir::populateGpuToNVVMConversionPatterns( "__nv_tanh"); } -std::unique_ptr> +std::unique_ptr> mlir::createLowerGpuOpsToNVVMOpsPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp index b89a1704e9f58..36e1b85fd39c3 100644 --- a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp +++ b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp @@ -32,7 +32,8 @@ namespace { // This pass only handles device code and is not meant to be run on GPU host // code. class LowerGpuOpsToROCDLOpsPass - : public OperationPass { + : public PassWrapper> { public: /// Include the generated pass utilities. #define GEN_PASS_ConvertGpuOpsToROCDLOps @@ -83,8 +84,7 @@ class LowerGpuOpsToROCDLOpsPass } // anonymous namespace -std::unique_ptr> +std::unique_ptr> mlir::createLowerGpuOpsToROCDLOpsPass() { return std::make_unique(); } - diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp index edee5025ded91..173c6d0f58262 100644 --- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp @@ -33,7 +33,8 @@ namespace { /// replace it). /// /// 2) Lower the body of the spirv::ModuleOp. -struct GPUToSPIRVPass : public OperationPass { +struct GPUToSPIRVPass + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_ConvertGpuToSPIRV #include "mlir/Conversion/Passes.h.inc" @@ -71,6 +72,6 @@ void GPUToSPIRVPass::runOnOperation() { } } -std::unique_ptr> mlir::createConvertGPUToSPIRVPass() { +std::unique_ptr> mlir::createConvertGPUToSPIRVPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp index cbcfd741d9f8d..bf2c15f68ae5c 100644 --- a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp +++ b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp @@ -38,7 +38,8 @@ namespace { /// function and attaching binary data and entry point name as an attributes to /// created vulkan launch call op. class ConvertGpuLaunchFuncToVulkanLaunchFunc - : public OperationPass { + : public PassWrapper> { public: /// Include the generated pass utilities. #define GEN_PASS_ConvertGpuLaunchFuncToVulkanLaunchFunc @@ -168,7 +169,7 @@ void ConvertGpuLaunchFuncToVulkanLaunchFunc::convertGpuLaunchFunc( launchOp.erase(); } -std::unique_ptr> +std::unique_ptr> mlir::createConvertGpuLaunchFuncToVulkanLaunchFuncPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp index 2daa13085bcbc..03d924d74f564 100644 --- a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp +++ b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp @@ -58,7 +58,8 @@ namespace { /// * deinitVulkan -- deinitializes vulkan runtime /// class VulkanLaunchFuncToVulkanCallsPass - : public OperationPass { + : public PassWrapper> { private: /// Include the generated pass utilities. #define GEN_PASS_ConvertVulkanLaunchFuncToVulkanCalls @@ -436,7 +437,7 @@ void VulkanLaunchFuncToVulkanCallsPass::translateVulkanLaunchCall( cInterfaceVulkanLaunchCallOp.erase(); } -std::unique_ptr> +std::unique_ptr> mlir::createConvertVulkanLaunchFuncToVulkanCallsPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp index 99f106e29de7f..05aab300e6227 100644 --- a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp +++ b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp @@ -562,7 +562,7 @@ void mlir::populateLinalgToLLVMConversionPatterns( namespace { struct ConvertLinalgToLLVMPass - : public OperationPass { + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_ConvertLinalgToLLVM #include "mlir/Conversion/Passes.h.inc" @@ -593,6 +593,6 @@ void ConvertLinalgToLLVMPass::runOnOperation() { signalPassFailure(); } -std::unique_ptr> mlir::createConvertLinalgToLLVMPass() { +std::unique_ptr> mlir::createConvertLinalgToLLVMPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp index 4b66063b88eb1..acb87b72c3c6c 100644 --- a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp +++ b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp @@ -16,7 +16,8 @@ using namespace mlir; namespace { /// A pass converting MLIR Linalg ops into SPIR-V ops. -class LinalgToSPIRVPass : public OperationPass { +class LinalgToSPIRVPass + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_ConvertLinalgToSPIRV #include "mlir/Conversion/Passes.h.inc" @@ -47,6 +48,6 @@ void LinalgToSPIRVPass::runOnOperation() { return signalPassFailure(); } -std::unique_ptr> mlir::createLinalgToSPIRVPass() { +std::unique_ptr> mlir::createLinalgToSPIRVPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp b/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp index 7d20561ab6cfe..9929b8e816f67 100644 --- a/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp +++ b/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp @@ -30,7 +30,8 @@ using namespace mlir::loop; namespace { -struct LoopToStandardPass : public OperationPass { +struct LoopToStandardPass + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_ConvertLoopToStandard #include "mlir/Conversion/Passes.h.inc" diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp index 98a855c105c35..679d0b339691e 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp @@ -28,7 +28,7 @@ namespace { // A pass that traverses top-level loops in the function and converts them to // GPU launch operations. Nested launches are not allowed, so this does not // walk the function recursively to avoid considering nested loops. -struct ForLoopMapper : public FunctionPass { +struct ForLoopMapper : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_ConvertSimpleLoopsToGPU #include "mlir/Conversion/Passes.h.inc" @@ -62,7 +62,7 @@ struct ForLoopMapper : public FunctionPass { // nested loops as the size of `numWorkGroups`. Within these any loop nest has // to be perfectly nested upto depth equal to size of `workGroupSize`. struct ImperfectlyNestedForLoopMapper - : public FunctionPass { + : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_ConvertLoopsToGPU #include "mlir/Conversion/Passes.h.inc" @@ -104,7 +104,8 @@ struct ImperfectlyNestedForLoopMapper } }; -struct ParallelLoopToGpuPass : public OperationPass { +struct ParallelLoopToGpuPass + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_ConvertParallelLoopToGpu #include "mlir/Conversion/Passes.h.inc" @@ -125,22 +126,22 @@ struct ParallelLoopToGpuPass : public OperationPass { } // namespace -std::unique_ptr> +std::unique_ptr> mlir::createSimpleLoopsToGPUPass(unsigned numBlockDims, unsigned numThreadDims) { return std::make_unique(numBlockDims, numThreadDims); } -std::unique_ptr> mlir::createSimpleLoopsToGPUPass() { +std::unique_ptr> mlir::createSimpleLoopsToGPUPass() { return std::make_unique(); } -std::unique_ptr> +std::unique_ptr> mlir::createLoopToGPUPass(ArrayRef numWorkGroups, ArrayRef workGroupSize) { return std::make_unique(numWorkGroups, workGroupSize); } -std::unique_ptr> mlir::createLoopToGPUPass() { +std::unique_ptr> mlir::createLoopToGPUPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp index ef5dabf2ff885..d23883f6d624c 100644 --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -2847,7 +2847,8 @@ LLVMTypeConverter::promoteMemRefDescriptors(Location loc, ValueRange opOperands, namespace { /// A pass converting MLIR operations into the LLVM IR dialect. -struct LLVMLoweringPass : public OperationPass { +struct LLVMLoweringPass + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_ConvertStandardToLLVM #include "mlir/Conversion/Passes.h.inc" @@ -2901,7 +2902,7 @@ mlir::LLVMConversionTarget::LLVMConversionTarget(MLIRContext &ctx) this->addIllegalOp(); } -std::unique_ptr> +std::unique_ptr> mlir::createLowerToLLVMPass(const LowerToLLVMOptions &options) { return std::make_unique( options.useBarePtrCallConv, options.emitCWrappers, options.indexBitwidth); diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp index 86c8cd17433ca..b0ce99fa837f8 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp @@ -22,7 +22,7 @@ using namespace mlir; namespace { /// A pass converting MLIR Standard operations into the SPIR-V dialect. class ConvertStandardToSPIRVPass - : public OperationPass { + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_ConvertStandardToSPIRV #include "mlir/Conversion/Passes.h.inc" @@ -49,6 +49,7 @@ void ConvertStandardToSPIRVPass::runOnOperation() { } } -std::unique_ptr> mlir::createConvertStandardToSPIRVPass() { +std::unique_ptr> +mlir::createConvertStandardToSPIRVPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp index 381087fbdf762..9dbb76174201d 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp @@ -160,7 +160,8 @@ void mlir::populateStdLegalizationPatternsForSPIRVLowering( //===----------------------------------------------------------------------===// namespace { -struct SPIRVLegalization final : public OperationPass { +struct SPIRVLegalization final + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_LegalizeStandardForSPIRV #include "mlir/Conversion/Passes.h.inc" diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp index b2a1c443f5187..03cbb67bc5d7a 100644 --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp @@ -1119,7 +1119,7 @@ void mlir::populateVectorToLLVMMatrixConversionPatterns( namespace { struct LowerVectorToLLVMPass - : public OperationPass { + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_ConvertVectorToLLVM #include "mlir/Conversion/Passes.h.inc" @@ -1155,6 +1155,6 @@ void LowerVectorToLLVMPass::runOnOperation() { } } -std::unique_ptr> mlir::createConvertVectorToLLVMPass() { +std::unique_ptr> mlir::createConvertVectorToLLVMPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp index 3ba61bcc022df..1f7d670ce4739 100644 --- a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp @@ -75,7 +75,7 @@ namespace { // TODO(bondhugula): We currently can't generate copies correctly when stores // are strided. Check for strided stores. struct AffineDataCopyGeneration - : public FunctionPass { + : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_AffineDataCopyGeneration #include "mlir/Dialect/Affine/Passes.h.inc" @@ -134,14 +134,15 @@ struct AffineDataCopyGeneration /// buffers in 'fastMemorySpace', and replaces memory operations to the former /// by the latter. Only load op's handled for now. /// TODO(bondhugula): extend this to store op's. -std::unique_ptr> mlir::createAffineDataCopyGenerationPass( +std::unique_ptr> mlir::createAffineDataCopyGenerationPass( unsigned slowMemorySpace, unsigned fastMemorySpace, unsigned tagMemorySpace, int minDmaTransferSize, uint64_t fastMemCapacityBytes) { return std::make_unique( slowMemorySpace, fastMemorySpace, tagMemorySpace, minDmaTransferSize, fastMemCapacityBytes); } -std::unique_ptr> mlir::createAffineDataCopyGenerationPass() { +std::unique_ptr> +mlir::createAffineDataCopyGenerationPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp index 12fdb37bf8417..066a53d14e23a 100644 --- a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp @@ -41,7 +41,8 @@ namespace { /// TODO(asabne) : Check for the presence of side effects before hoisting. /// TODO: This code should be removed once the new LICM pass can handle its /// uses. -struct LoopInvariantCodeMotion : public FunctionPass { +struct LoopInvariantCodeMotion + : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_AffineLoopInvariantCodeMotion #include "mlir/Dialect/Affine/Passes.h.inc" @@ -232,7 +233,7 @@ void LoopInvariantCodeMotion::runOnFunction() { }); } -std::unique_ptr> +std::unique_ptr> mlir::createAffineLoopInvariantCodeMotionPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp index 2f5eea7606a9f..1cfb31045c66f 100644 --- a/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp @@ -58,7 +58,7 @@ static llvm::cl::list clTileSizes( namespace { /// A pass to perform loop tiling on all suitable loop nests of a Function. -struct LoopTiling : public FunctionPass { +struct LoopTiling : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_AffineLoopTiling #include "mlir/Dialect/Affine/Passes.h.inc" @@ -85,11 +85,11 @@ struct LoopTiling : public FunctionPass { /// Creates a pass to perform loop tiling on all suitable loop nests of a /// Function. -std::unique_ptr> +std::unique_ptr> mlir::createLoopTilingPass(uint64_t cacheSizeBytes) { return std::make_unique(cacheSizeBytes); } -std::unique_ptr> mlir::createLoopTilingPass() { +std::unique_ptr> mlir::createLoopTilingPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp index 7f33630d3b8ab..d9a6b1cd26909 100644 --- a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp @@ -58,7 +58,7 @@ namespace { /// full unroll threshold was specified, in which case, fully unrolls all loops /// with trip count less than the specified threshold. The latter is for testing /// purposes, especially for testing outer loop unrolling. -struct LoopUnroll : public FunctionPass { +struct LoopUnroll : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_AffineUnroll #include "mlir/Dialect/Affine/Passes.h.inc" @@ -166,7 +166,7 @@ LogicalResult LoopUnroll::runOnAffineForOp(AffineForOp forOp) { return loopUnrollByFactor(forOp, kDefaultUnrollFactor); } -std::unique_ptr> mlir::createLoopUnrollPass( +std::unique_ptr> mlir::createLoopUnrollPass( int unrollFactor, int unrollFull, const std::function &getUnrollFactor) { return std::make_unique( diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp index 5f419a83d6cfd..1a25677967959 100644 --- a/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp @@ -60,7 +60,7 @@ static llvm::cl::opt namespace { /// Loop unroll jam pass. Currently, this just unroll jams the first /// outer loop in a Function. -struct LoopUnrollAndJam : public FunctionPass { +struct LoopUnrollAndJam : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_AffineLoopUnrollAndJam #include "mlir/Dialect/Affine/Passes.h.inc" @@ -76,7 +76,7 @@ struct LoopUnrollAndJam : public FunctionPass { }; } // end anonymous namespace -std::unique_ptr> +std::unique_ptr> mlir::createLoopUnrollAndJamPass(int unrollJamFactor) { return std::make_unique( unrollJamFactor == -1 ? None : Optional(unrollJamFactor)); diff --git a/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp b/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp index fc58b19656fe9..af11d4e8d1142 100644 --- a/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp @@ -27,7 +27,7 @@ namespace { /// all memrefs with non-trivial layout maps are converted to ones with trivial /// identity layout ones. struct SimplifyAffineStructures - : public FunctionPass { + : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_SimplifyAffineStructures #include "mlir/Dialect/Affine/Passes.h.inc" @@ -73,7 +73,8 @@ struct SimplifyAffineStructures } // end anonymous namespace -std::unique_ptr> mlir::createSimplifyAffineStructuresPass() { +std::unique_ptr> +mlir::createSimplifyAffineStructuresPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp index 3959459822251..06de9a2c9da51 100644 --- a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp @@ -573,7 +573,7 @@ namespace { /// Base state for the vectorize pass. /// Command line arguments are preempted by non-empty pass arguments. -struct Vectorize : public FunctionPass { +struct Vectorize : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_AffineVectorize #include "mlir/Dialect/Affine/Passes.h.inc" @@ -1252,10 +1252,10 @@ void Vectorize::runOnFunction() { LLVM_DEBUG(dbgs() << "\n"); } -std::unique_ptr> +std::unique_ptr> mlir::createSuperVectorizePass(ArrayRef virtualVectorSize) { return std::make_unique(virtualVectorSize); } -std::unique_ptr> mlir::createSuperVectorizePass() { +std::unique_ptr> mlir::createSuperVectorizePass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp index daf9169d242c2..70ace0f1f45f7 100644 --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -215,7 +215,7 @@ namespace { /// a separate pass. The external functions can then be annotated with the /// symbol of the cubin accessor function. class GpuKernelOutliningPass - : public OperationPass { + : public PassWrapper> { public: /// Include the generated pass utilities. #define GEN_PASS_GpuKernelOutlining @@ -301,6 +301,6 @@ class GpuKernelOutliningPass } // namespace -std::unique_ptr> mlir::createGpuKernelOutliningPass() { +std::unique_ptr> mlir::createGpuKernelOutliningPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/LLVMIR/Transforms/LegalizeForExport.cpp b/mlir/lib/Dialect/LLVMIR/Transforms/LegalizeForExport.cpp index 663f0c11432b3..88f06d7ed18f6 100644 --- a/mlir/lib/Dialect/LLVMIR/Transforms/LegalizeForExport.cpp +++ b/mlir/lib/Dialect/LLVMIR/Transforms/LegalizeForExport.cpp @@ -57,7 +57,8 @@ void mlir::LLVM::ensureDistinctSuccessors(Operation *op) { } namespace { -struct LegalizeForExportPass : public OperationPass { +struct LegalizeForExportPass + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_LLVMLegalizeForExport #include "mlir/Dialect/LLVMIR/Transforms/Passes.h.inc" diff --git a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp index d3c56851a3851..07b4d9788a80e 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp @@ -567,7 +567,8 @@ struct FuseGenericTensorOps : public OpRewritePattern { }; /// Pass that fuses generic ops on tensors. Used only for testing. -struct FusionOfTensorOpsPass : public OperationPass { +struct FusionOfTensorOpsPass + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_LinalgFusionOfTensorOps #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -580,7 +581,7 @@ struct FusionOfTensorOpsPass : public OperationPass { }; }; -struct LinalgFusionPass : public FunctionPass { +struct LinalgFusionPass : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_LinalgFusion #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -589,7 +590,7 @@ struct LinalgFusionPass : public FunctionPass { }; } // namespace -std::unique_ptr> mlir::createLinalgFusionPass() { +std::unique_ptr> mlir::createLinalgFusionPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp index 4e26080eec536..8a4df64148336 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp @@ -693,7 +693,8 @@ static void lowerLinalgToLoopsImpl(Operation *op, MLIRContext *context) { } namespace { -struct LowerToAffineLoops : public FunctionPass { +struct LowerToAffineLoops + : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_LinalgLowerToAffineLoops #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -703,7 +704,7 @@ struct LowerToAffineLoops : public FunctionPass { &getContext()); } }; -struct LowerToLoops : public FunctionPass { +struct LowerToLoops : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_LinalgLowerToLoops #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -713,7 +714,8 @@ struct LowerToLoops : public FunctionPass { &getContext()); } }; -struct LowerToParallelLoops : public FunctionPass { +struct LowerToParallelLoops + : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_LinalgLowerToParallelLoops #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -725,16 +727,16 @@ struct LowerToParallelLoops : public FunctionPass { }; } // namespace -std::unique_ptr> mlir::createConvertLinalgToLoopsPass() { +std::unique_ptr> mlir::createConvertLinalgToLoopsPass() { return std::make_unique(); } -std::unique_ptr> +std::unique_ptr> mlir::createConvertLinalgToParallelLoopsPass() { return std::make_unique(); } -std::unique_ptr> +std::unique_ptr> mlir::createConvertLinalgToAffineLoopsPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp index 6603507a1cdff..6eea97f954ff8 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp @@ -230,7 +230,8 @@ static void promoteSubViews(FuncOp f, bool dynamicBuffers) { } namespace { -struct LinalgPromotionPass : public FunctionPass { +struct LinalgPromotionPass + : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_LinalgPromotion #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -247,10 +248,10 @@ struct LinalgPromotionPass : public FunctionPass { }; } // namespace -std::unique_ptr> +std::unique_ptr> mlir::createLinalgPromotionPass(bool dynamicBuffers) { return std::make_unique(dynamicBuffers); } -std::unique_ptr> mlir::createLinalgPromotionPass() { +std::unique_ptr> mlir::createLinalgPromotionPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp index 919a7d53f479b..1e528aa9a201e 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -507,7 +507,7 @@ static void tileLinalgOps(FuncOp f, ArrayRef tileSizes) { } namespace { -struct LinalgTilingPass : public FunctionPass { +struct LinalgTilingPass : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_LinalgTiling #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -524,7 +524,7 @@ struct LinalgTilingPass : public FunctionPass { }; struct LinalgTilingToParallelLoopsPass - : public FunctionPass { + : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_LinalgTilingToParallelLoops #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -542,12 +542,12 @@ struct LinalgTilingToParallelLoopsPass } // namespace -std::unique_ptr> +std::unique_ptr> mlir::createLinalgTilingPass(ArrayRef tileSizes) { return std::make_unique(tileSizes); } -std::unique_ptr> +std::unique_ptr> mlir::createLinalgTilingToParallelLoopsPass(ArrayRef tileSizes) { return std::make_unique(tileSizes); } diff --git a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopFusion.cpp b/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopFusion.cpp index b59f1fc3c8c91..b031f81076cd9 100644 --- a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopFusion.cpp +++ b/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopFusion.cpp @@ -160,7 +160,8 @@ void mlir::loop::naivelyFuseParallelOps(Region ®ion) { } namespace { -struct ParallelLoopFusion : public OperationPass { +struct ParallelLoopFusion + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_LoopParallelLoopFusion #include "mlir/Dialect/LoopOps/Passes.h.inc" diff --git a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopSpecialization.cpp b/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopSpecialization.cpp index 63afa50595098..98776abdb06c3 100644 --- a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopSpecialization.cpp +++ b/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopSpecialization.cpp @@ -60,7 +60,7 @@ static void specializeLoopForUnrolling(ParallelOp op) { namespace { struct ParallelLoopSpecialization - : public FunctionPass { + : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_LoopParallelLoopSpecialization #include "mlir/Dialect/LoopOps/Passes.h.inc" diff --git a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopTiling.cpp b/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopTiling.cpp index 8b63d00902911..c10872ece9f9c 100644 --- a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopTiling.cpp +++ b/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopTiling.cpp @@ -101,7 +101,8 @@ static bool getInnermostNestedLoops(Block *block, } namespace { -struct ParallelLoopTiling : public FunctionPass { +struct ParallelLoopTiling + : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_LoopParallelLoopTiling #include "mlir/Dialect/LoopOps/Passes.h.inc" diff --git a/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp b/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp index 3017346a9acc4..d892f67a23d74 100644 --- a/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp +++ b/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp @@ -21,7 +21,7 @@ using namespace mlir; using namespace mlir::quant; namespace { -struct ConvertConstPass : public FunctionPass { +struct ConvertConstPass : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_QuantConvertConst #include "mlir/Dialect/Quant/Passes.h.inc" @@ -105,6 +105,6 @@ void ConvertConstPass::runOnFunction() { applyPatternsGreedily(func, patterns); } -std::unique_ptr> mlir::quant::createConvertConstPass() { +std::unique_ptr> mlir::quant::createConvertConstPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp index b76cee6a412c9..079c3ff96ad14 100644 --- a/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp +++ b/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp @@ -20,7 +20,7 @@ using namespace mlir::quant; namespace { struct ConvertSimulatedQuantPass - : public FunctionPass { + : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_QuantConvertSimulatedQuant #include "mlir/Dialect/Quant/Passes.h.inc" @@ -140,7 +140,7 @@ void ConvertSimulatedQuantPass::runOnFunction() { signalPassFailure(); } -std::unique_ptr> +std::unique_ptr> mlir::quant::createConvertSimulatedQuantPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp index e4622741536e0..a0b2c168985f1 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp @@ -80,7 +80,8 @@ static void populateSPIRVLayoutInfoPatterns(OwningRewritePatternList &patterns, namespace { class DecorateSPIRVCompositeTypeLayoutPass - : public OperationPass { + : public PassWrapper> { private: void runOnOperation() override; }; @@ -113,7 +114,7 @@ void DecorateSPIRVCompositeTypeLayoutPass::runOnOperation() { } } -std::unique_ptr> +std::unique_ptr> mlir::spirv::createDecorateSPIRVCompositeTypeLayoutPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp index 9cb2bfe1e1fc5..d666f9697374b 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp @@ -148,7 +148,8 @@ class ProcessInterfaceVarABI final : public SPIRVOpLowering { /// Pass to implement the ABI information specified as attributes. class LowerABIAttributesPass final - : public OperationPass { + : public PassWrapper> { private: void runOnOperation() override; }; @@ -260,7 +261,7 @@ void LowerABIAttributesPass::runOnOperation() { } } -std::unique_ptr> +std::unique_ptr> mlir::spirv::createLowerABIAttributesPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp index ebb5b6eda83ac..415535b6da970 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp @@ -27,7 +27,7 @@ namespace { /// Pass to deduce minimal version/extension/capability requirements for a /// spirv::ModuleOp. class UpdateVCEPass final - : public OperationPass { + : public PassWrapper> { private: void runOnOperation() override; }; @@ -173,7 +173,7 @@ void UpdateVCEPass::runOnOperation() { module.setAttr(spirv::ModuleOp::getVCETripleAttrName(), triple); } -std::unique_ptr> +std::unique_ptr> mlir::spirv::createUpdateVersionCapabilityExtensionPass() { return std::make_unique(); } diff --git a/mlir/lib/Pass/PassDetail.h b/mlir/lib/Pass/PassDetail.h index bcd71ce4e2f63..59d9a7a0576ff 100644 --- a/mlir/lib/Pass/PassDetail.h +++ b/mlir/lib/Pass/PassDetail.h @@ -19,7 +19,7 @@ namespace detail { //===----------------------------------------------------------------------===// /// Pass to verify an operation and signal failure if necessary. -class VerifierPass : public OperationPass { +class VerifierPass : public PassWrapper> { void runOnOperation() override; }; @@ -49,8 +49,9 @@ class OpToOpPassAdaptorBase { /// An adaptor pass used to run operation passes over nested operations /// synchronously on a single thread. -class OpToOpPassAdaptor : public OperationPass, - public OpToOpPassAdaptorBase { +class OpToOpPassAdaptor + : public PassWrapper>, + public OpToOpPassAdaptorBase { public: OpToOpPassAdaptor(OpPassManager &&mgr); @@ -61,7 +62,7 @@ class OpToOpPassAdaptor : public OperationPass, /// An adaptor pass used to run operation passes over nested operations /// asynchronously across multiple threads. class OpToOpPassAdaptorParallel - : public OperationPass, + : public PassWrapper>, public OpToOpPassAdaptorBase { public: OpToOpPassAdaptorParallel(OpPassManager &&mgr); diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp index 67890f63dcd97..919c957f3d9d2 100644 --- a/mlir/lib/Transforms/CSE.cpp +++ b/mlir/lib/Transforms/CSE.cpp @@ -73,7 +73,7 @@ struct SimpleOperationInfo : public llvm::DenseMapInfo { namespace { /// Simple common sub-expression elimination. -struct CSE : public OperationPass { +struct CSE : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_CSE #include "mlir/Transforms/Passes.h.inc" diff --git a/mlir/lib/Transforms/Canonicalizer.cpp b/mlir/lib/Transforms/Canonicalizer.cpp index 964fc7f665005..3f3d302967856 100644 --- a/mlir/lib/Transforms/Canonicalizer.cpp +++ b/mlir/lib/Transforms/Canonicalizer.cpp @@ -19,7 +19,7 @@ using namespace mlir; namespace { /// Canonicalize operations in nested regions. -struct Canonicalizer : public OperationPass { +struct Canonicalizer : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_Canonicalizer #include "mlir/Transforms/Passes.h.inc" diff --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp index 04ae30faf2aa3..60382ea64f760 100644 --- a/mlir/lib/Transforms/Inliner.cpp +++ b/mlir/lib/Transforms/Inliner.cpp @@ -589,7 +589,7 @@ static void inlineSCC(Inliner &inliner, CGUseList &useList, //===----------------------------------------------------------------------===// namespace { -struct InlinerPass : public OperationPass { +struct InlinerPass : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_Inliner #include "mlir/Transforms/Passes.h.inc" diff --git a/mlir/lib/Transforms/LocationSnapshot.cpp b/mlir/lib/Transforms/LocationSnapshot.cpp index 4f54e13e76fd8..e9858bc142e87 100644 --- a/mlir/lib/Transforms/LocationSnapshot.cpp +++ b/mlir/lib/Transforms/LocationSnapshot.cpp @@ -123,7 +123,8 @@ LogicalResult mlir::generateLocationsFromIR(StringRef fileName, StringRef tag, } namespace { -struct LocationSnapshotPass : public OperationPass { +struct LocationSnapshotPass + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_LocationSnapshot #include "mlir/Transforms/Passes.h.inc" diff --git a/mlir/lib/Transforms/LoopCoalescing.cpp b/mlir/lib/Transforms/LoopCoalescing.cpp index 322b3b92c52c6..57d8e2a26d67d 100644 --- a/mlir/lib/Transforms/LoopCoalescing.cpp +++ b/mlir/lib/Transforms/LoopCoalescing.cpp @@ -19,7 +19,8 @@ using namespace mlir; namespace { -struct LoopCoalescingPass : public FunctionPass { +struct LoopCoalescingPass + : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_LoopCoalescing #include "mlir/Transforms/Passes.h.inc" @@ -89,6 +90,6 @@ struct LoopCoalescingPass : public FunctionPass { } // namespace -std::unique_ptr> mlir::createLoopCoalescingPass() { +std::unique_ptr> mlir::createLoopCoalescingPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index 55b45c0595a63..f802ba526b25d 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -77,7 +77,7 @@ namespace { // TODO(andydavis) Extend this pass to check for fusion preventing dependences, // and add support for more general loop fusion algorithms. -struct LoopFusion : public FunctionPass { +struct LoopFusion : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_AffineLoopFusion #include "mlir/Transforms/Passes.h.inc" @@ -104,7 +104,7 @@ struct LoopFusion : public FunctionPass { } // end anonymous namespace -std::unique_ptr> +std::unique_ptr> mlir::createLoopFusionPass(unsigned fastMemorySpace, uint64_t localBufSizeThreshold, bool maximalFusion) { return std::make_unique(fastMemorySpace, localBufSizeThreshold, diff --git a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp index 7407676d58771..e7e48ac40714b 100644 --- a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp @@ -27,7 +27,8 @@ using namespace mlir; namespace { /// Loop invariant code motion (LICM) pass. -struct LoopInvariantCodeMotion : public OperationPass { +struct LoopInvariantCodeMotion + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_LoopInvariantCodeMotion #include "mlir/Transforms/Passes.h.inc" diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp index e251edaf38cba..5b03de9239916 100644 --- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp +++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp @@ -60,7 +60,7 @@ namespace { // currently only eliminates the stores only if no other loads/uses (other // than dealloc) remain. // -struct MemRefDataFlowOpt : public FunctionPass { +struct MemRefDataFlowOpt : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_MemRefDataFlowOpt #include "mlir/Transforms/Passes.h.inc" @@ -82,7 +82,7 @@ struct MemRefDataFlowOpt : public FunctionPass { /// Creates a pass to perform optimizations relying on memref dataflow such as /// store to load forwarding, elimination of dead stores, and dead allocs. -std::unique_ptr> mlir::createMemRefDataFlowOptPass() { +std::unique_ptr> mlir::createMemRefDataFlowOptPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/OpStats.cpp b/mlir/lib/Transforms/OpStats.cpp index 2b519d6970205..667a0b4f4f571 100644 --- a/mlir/lib/Transforms/OpStats.cpp +++ b/mlir/lib/Transforms/OpStats.cpp @@ -18,7 +18,8 @@ using namespace mlir; namespace { -struct PrintOpStatsPass : public OperationPass { +struct PrintOpStatsPass + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_PrintOpStats #include "mlir/Transforms/Passes.h.inc" @@ -85,6 +86,6 @@ void PrintOpStatsPass::printSummary() { } } -std::unique_ptr> mlir::createPrintOpStatsPass() { +std::unique_ptr> mlir::createPrintOpStatsPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/ParallelLoopCollapsing.cpp b/mlir/lib/Transforms/ParallelLoopCollapsing.cpp index 29aded6465c77..4380fe30d089d 100644 --- a/mlir/lib/Transforms/ParallelLoopCollapsing.cpp +++ b/mlir/lib/Transforms/ParallelLoopCollapsing.cpp @@ -20,7 +20,8 @@ using namespace mlir; namespace { -struct ParallelLoopCollapsing : public OperationPass { +struct ParallelLoopCollapsing + : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_ParallelLoopCollapsing #include "mlir/Transforms/Passes.h.inc" diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp index 4c10303365400..8eeea89d73f65 100644 --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -28,7 +28,8 @@ using namespace mlir; namespace { -struct PipelineDataTransfer : public FunctionPass { +struct PipelineDataTransfer + : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_AffinePipelineDataTransfer #include "mlir/Transforms/Passes.h.inc" @@ -43,7 +44,7 @@ struct PipelineDataTransfer : public FunctionPass { /// Creates a pass to pipeline explicit movement of data across levels of the /// memory hierarchy. -std::unique_ptr> mlir::createPipelineDataTransferPass() { +std::unique_ptr> mlir::createPipelineDataTransferPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp index d3420cfc35a13..e5ba144025157 100644 --- a/mlir/lib/Transforms/StripDebugInfo.cpp +++ b/mlir/lib/Transforms/StripDebugInfo.cpp @@ -14,7 +14,7 @@ using namespace mlir; namespace { -struct StripDebugInfo : public OperationPass { +struct StripDebugInfo : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_StripDebugInfo #include "mlir/Transforms/Passes.h.inc" diff --git a/mlir/lib/Transforms/SymbolDCE.cpp b/mlir/lib/Transforms/SymbolDCE.cpp index 7513e34af388a..251a956be75d7 100644 --- a/mlir/lib/Transforms/SymbolDCE.cpp +++ b/mlir/lib/Transforms/SymbolDCE.cpp @@ -17,7 +17,7 @@ using namespace mlir; namespace { -struct SymbolDCE : public OperationPass { +struct SymbolDCE : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_SymbolDCE #include "mlir/Transforms/Passes.h.inc" diff --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp index c5d921db059e7..8ac61fc4b815c 100644 --- a/mlir/lib/Transforms/ViewOpGraph.cpp +++ b/mlir/lib/Transforms/ViewOpGraph.cpp @@ -100,7 +100,7 @@ namespace { // PrintOpPass is simple pass to write graph per function. // Note: this is a module pass only to avoid interleaving on the same ostream // due to multi-threading over functions. -struct PrintOpPass : public OperationPass { +struct PrintOpPass : public PassWrapper> { /// Include the generated pass utilities. #define GEN_PASS_PrintOpGraph #include "mlir/Transforms/Passes.h.inc" @@ -160,7 +160,7 @@ raw_ostream &mlir::writeGraph(raw_ostream &os, Block &block, bool shortNames, return llvm::WriteGraph(os, &block, shortNames, title); } -std::unique_ptr> +std::unique_ptr> mlir::createPrintOpGraphPass(raw_ostream &os, bool shortNames, const Twine &title) { return std::make_unique(os, shortNames, title); diff --git a/mlir/lib/Transforms/ViewRegionGraph.cpp b/mlir/lib/Transforms/ViewRegionGraph.cpp index cf9ff6d8077e4..4f31a79cd9d31 100644 --- a/mlir/lib/Transforms/ViewRegionGraph.cpp +++ b/mlir/lib/Transforms/ViewRegionGraph.cpp @@ -60,7 +60,7 @@ void mlir::Region::viewGraph(const Twine ®ionName) { void mlir::Region::viewGraph() { viewGraph("region"); } namespace { -struct PrintCFGPass : public FunctionPass { +struct PrintCFGPass : public PassWrapper { /// Include the generated pass utilities. #define GEN_PASS_PrintCFG #include "mlir/Transforms/Passes.h.inc" @@ -79,7 +79,7 @@ struct PrintCFGPass : public FunctionPass { }; } // namespace -std::unique_ptr> +std::unique_ptr> mlir::createPrintCFGGraphPass(raw_ostream &os, bool shortNames, const Twine &title) { return std::make_unique(os, shortNames, title); diff --git a/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp b/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp index 9e3b3434104a0..7c0052dd9e688 100644 --- a/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp +++ b/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp @@ -26,7 +26,8 @@ static llvm::cl::OptionCategory clOptionsCategory(PASS_NAME " options"); namespace { -struct TestAffineDataCopy : public FunctionPass { +struct TestAffineDataCopy + : public PassWrapper { TestAffineDataCopy() = default; TestAffineDataCopy(const TestAffineDataCopy &pass){}; diff --git a/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp b/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp index 87b2e620f7d6a..a349016851595 100644 --- a/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp +++ b/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp @@ -25,7 +25,8 @@ static llvm::cl::OptionCategory clOptionsCategory(PASS_NAME " options"); namespace { /// This pass applies the permutation on the first maximal perfect nest. -struct TestLoopPermutation : public FunctionPass { +struct TestLoopPermutation + : public PassWrapper { TestLoopPermutation() = default; TestLoopPermutation(const TestLoopPermutation &pass){}; diff --git a/mlir/test/lib/Dialect/Affine/TestParallelismDetection.cpp b/mlir/test/lib/Dialect/Affine/TestParallelismDetection.cpp index 1140dab92dbb7..b19e260316939 100644 --- a/mlir/test/lib/Dialect/Affine/TestParallelismDetection.cpp +++ b/mlir/test/lib/Dialect/Affine/TestParallelismDetection.cpp @@ -20,7 +20,7 @@ using namespace mlir; namespace { struct TestParallelismDetection - : public FunctionPass { + : public PassWrapper { void runOnFunction() override; }; diff --git a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp index 01382530fa397..ca738fde6103d 100644 --- a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp +++ b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp @@ -72,7 +72,8 @@ static llvm::cl::opt clTestNormalizeMaps( llvm::cl::cat(clOptionsCategory)); namespace { -struct VectorizerTestPass : public FunctionPass { +struct VectorizerTestPass + : public PassWrapper { static constexpr auto kTestAffineMapOpName = "test_affine_map"; static constexpr auto kTestAffineMapAttrName = "affine_map"; diff --git a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp index ad77e7d05f42f..8c6ca60dabaad 100644 --- a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp +++ b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp @@ -20,7 +20,8 @@ using namespace mlir; namespace { /// A pass for testing SPIR-V op availability. -struct PrintOpAvailability : public FunctionPass { +struct PrintOpAvailability + : public PassWrapper { void runOnFunction() override; }; } // end anonymous namespace @@ -88,7 +89,8 @@ void registerPrintOpAvailabilityPass() { namespace { /// A pass for testing SPIR-V op availability. -struct ConvertToTargetEnv : public FunctionPass { +struct ConvertToTargetEnv + : public PassWrapper { void runOnFunction() override; }; diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp index 6ccfa04a81945..39b3fc1e5f4bf 100644 --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -38,7 +38,7 @@ namespace { //===----------------------------------------------------------------------===// namespace { -struct TestPatternDriver : public FunctionPass { +struct TestPatternDriver : public PassWrapper { void runOnFunction() override { mlir::OwningRewritePatternList patterns; populateWithGenerated(&getContext(), &patterns); @@ -96,7 +96,8 @@ static void reifyReturnShape(Operation *op) { << it.value().getDefiningOp(); } -struct TestReturnTypeDriver : public FunctionPass { +struct TestReturnTypeDriver + : public PassWrapper { void runOnFunction() override { if (getFunction().getName() == "testCreateFunctions") { std::vector ops; @@ -398,7 +399,7 @@ struct TestTypeConverter : public TypeConverter { }; struct TestLegalizePatternDriver - : public OperationPass { + : public PassWrapper> { /// The mode of conversion to use with the driver. enum class ConversionMode { Analysis, Full, Partial }; @@ -534,7 +535,8 @@ struct OneVResOneVOperandOp1Converter } }; -struct TestRemappedValue : public mlir::FunctionPass { +struct TestRemappedValue + : public mlir::PassWrapper { void runOnFunction() override { mlir::OwningRewritePatternList patterns; patterns.insert(&getContext()); diff --git a/mlir/test/lib/IR/TestFunc.cpp b/mlir/test/lib/IR/TestFunc.cpp index c1b90397ec441..637864e049fde 100644 --- a/mlir/test/lib/IR/TestFunc.cpp +++ b/mlir/test/lib/IR/TestFunc.cpp @@ -13,7 +13,8 @@ using namespace mlir; namespace { /// This is a test pass for verifying FuncOp's eraseArgument method. -struct TestFuncEraseArg : public OperationPass { +struct TestFuncEraseArg + : public PassWrapper> { void runOnOperation() override { auto module = getOperation(); @@ -36,7 +37,8 @@ struct TestFuncEraseArg : public OperationPass { }; /// This is a test pass for verifying FuncOp's setType method. -struct TestFuncSetType : public OperationPass { +struct TestFuncSetType + : public PassWrapper> { void runOnOperation() override { auto module = getOperation(); SymbolTable symbolTable(module); diff --git a/mlir/test/lib/IR/TestMatchers.cpp b/mlir/test/lib/IR/TestMatchers.cpp index a5db0684c0b59..8af91506f6394 100644 --- a/mlir/test/lib/IR/TestMatchers.cpp +++ b/mlir/test/lib/IR/TestMatchers.cpp @@ -15,7 +15,7 @@ using namespace mlir; namespace { /// This is a test pass for verifying matchers. -struct TestMatchers : public FunctionPass { +struct TestMatchers : public PassWrapper { void runOnFunction() override; }; } // end anonymous namespace diff --git a/mlir/test/lib/IR/TestSideEffects.cpp b/mlir/test/lib/IR/TestSideEffects.cpp index a99348537e25b..1ac9e82a7f7e1 100644 --- a/mlir/test/lib/IR/TestSideEffects.cpp +++ b/mlir/test/lib/IR/TestSideEffects.cpp @@ -12,7 +12,8 @@ using namespace mlir; namespace { -struct SideEffectsPass : public OperationPass { +struct SideEffectsPass + : public PassWrapper> { void runOnOperation() override { auto module = getOperation(); diff --git a/mlir/test/lib/IR/TestSymbolUses.cpp b/mlir/test/lib/IR/TestSymbolUses.cpp index c39615ef13521..13188485ec418 100644 --- a/mlir/test/lib/IR/TestSymbolUses.cpp +++ b/mlir/test/lib/IR/TestSymbolUses.cpp @@ -15,7 +15,8 @@ using namespace mlir; namespace { /// This is a symbol test pass that tests the symbol uselist functionality /// provided by the symbol table along with erasing from the symbol table. -struct SymbolUsesPass : public OperationPass { +struct SymbolUsesPass + : public PassWrapper> { WalkResult operateOnSymbol(Operation *symbol, ModuleOp module, SmallVectorImpl &deadFunctions) { // Test computing uses on a non symboltable op. @@ -87,7 +88,7 @@ struct SymbolUsesPass : public OperationPass { /// This is a symbol test pass that tests the symbol use replacement /// functionality provided by the symbol table. struct SymbolReplacementPass - : public OperationPass { + : public PassWrapper> { void runOnOperation() override { auto module = getOperation(); diff --git a/mlir/test/lib/Pass/TestPassManager.cpp b/mlir/test/lib/Pass/TestPassManager.cpp index be8a7479200cc..ffac1b18be460 100644 --- a/mlir/test/lib/Pass/TestPassManager.cpp +++ b/mlir/test/lib/Pass/TestPassManager.cpp @@ -13,13 +13,14 @@ using namespace mlir; namespace { -struct TestModulePass : public OperationPass { +struct TestModulePass + : public PassWrapper> { void runOnOperation() final {} }; -struct TestFunctionPass : public FunctionPass { +struct TestFunctionPass : public PassWrapper { void runOnFunction() final {} }; -class TestOptionsPass : public FunctionPass { +class TestOptionsPass : public PassWrapper { public: struct Options : public PassPipelineOptions { ListOption listOption{*this, "list", @@ -53,12 +54,14 @@ class TestOptionsPass : public FunctionPass { /// A test pass that always aborts to enable testing the crash recovery /// mechanism of the pass manager. -class TestCrashRecoveryPass : public OperationPass { +class TestCrashRecoveryPass + : public PassWrapper> { void runOnOperation() final { abort(); } }; /// A test pass that contains a statistic. -struct TestStatisticPass : public OperationPass { +struct TestStatisticPass + : public PassWrapper> { TestStatisticPass() = default; TestStatisticPass(const TestStatisticPass &) {} diff --git a/mlir/test/lib/Transforms/TestAllReduceLowering.cpp b/mlir/test/lib/Transforms/TestAllReduceLowering.cpp index 6455dab70f456..9a2bcc2923799 100644 --- a/mlir/test/lib/Transforms/TestAllReduceLowering.cpp +++ b/mlir/test/lib/Transforms/TestAllReduceLowering.cpp @@ -18,7 +18,7 @@ using namespace mlir; namespace { struct TestAllReduceLoweringPass - : public OperationPass { + : public PassWrapper> { void runOnOperation() override { OwningRewritePatternList patterns; populateGpuRewritePatterns(&getContext(), patterns); diff --git a/mlir/test/lib/Transforms/TestCallGraph.cpp b/mlir/test/lib/Transforms/TestCallGraph.cpp index a181d645f2af4..bd651a5dfe2cd 100644 --- a/mlir/test/lib/Transforms/TestCallGraph.cpp +++ b/mlir/test/lib/Transforms/TestCallGraph.cpp @@ -17,7 +17,8 @@ using namespace mlir; namespace { -struct TestCallGraphPass : public OperationPass { +struct TestCallGraphPass + : public PassWrapper> { void runOnOperation() override { llvm::errs() << "Testing : " << getOperation().getAttr("test.name") << "\n"; getAnalysis().print(llvm::errs()); diff --git a/mlir/test/lib/Transforms/TestConstantFold.cpp b/mlir/test/lib/Transforms/TestConstantFold.cpp index cc6ece7f7c466..089d450aaf376 100644 --- a/mlir/test/lib/Transforms/TestConstantFold.cpp +++ b/mlir/test/lib/Transforms/TestConstantFold.cpp @@ -19,7 +19,7 @@ using namespace mlir; namespace { /// Simple constant folding pass. -struct TestConstantFold : public FunctionPass { +struct TestConstantFold : public PassWrapper { // All constants in the function post folding. SmallVector existingConstants; diff --git a/mlir/test/lib/Transforms/TestDominance.cpp b/mlir/test/lib/Transforms/TestDominance.cpp index 784bb1f405647..97674c400f814 100644 --- a/mlir/test/lib/Transforms/TestDominance.cpp +++ b/mlir/test/lib/Transforms/TestDominance.cpp @@ -64,7 +64,7 @@ class DominanceTest { DenseMap blockIds; }; -struct TestDominancePass : public FunctionPass { +struct TestDominancePass : public PassWrapper { void runOnFunction() override { llvm::errs() << "Testing : " << getFunction().getName() << "\n"; diff --git a/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp b/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp index 72304244d8fc4..08862dd061402 100644 --- a/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp +++ b/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp @@ -24,7 +24,8 @@ namespace { /// does not check whether the promotion is legal (e.g., amount of memory used) /// or beneficial (e.g., makes previously uncoalesced loads coalesced). class TestGpuMemoryPromotionPass - : public OperationPass { + : public PassWrapper> { void runOnOperation() override { gpu::GPUFuncOp op = getOperation(); for (unsigned i = 0, e = op.getNumArguments(); i < e; ++i) { diff --git a/mlir/test/lib/Transforms/TestGpuParallelLoopMapping.cpp b/mlir/test/lib/Transforms/TestGpuParallelLoopMapping.cpp index d7bbdbb94cba5..d877001bedd5e 100644 --- a/mlir/test/lib/Transforms/TestGpuParallelLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestGpuParallelLoopMapping.cpp @@ -20,7 +20,8 @@ namespace { /// Simple pass for testing the mapping of parallel loops to hardware ids using /// a greedy mapping strategy. class TestGpuGreedyParallelLoopMappingPass - : public OperationPass { + : public PassWrapper> { void runOnOperation() override { Operation *op = getOperation(); for (Region ®ion : op->getRegions()) diff --git a/mlir/test/lib/Transforms/TestInlining.cpp b/mlir/test/lib/Transforms/TestInlining.cpp index d6f7776ba5d2a..21e0b76cf5cbc 100644 --- a/mlir/test/lib/Transforms/TestInlining.cpp +++ b/mlir/test/lib/Transforms/TestInlining.cpp @@ -23,7 +23,7 @@ using namespace mlir; namespace { -struct Inliner : public FunctionPass { +struct Inliner : public PassWrapper { void runOnFunction() override { auto function = getFunction(); diff --git a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp index 645ce887135d7..85300f981f1e1 100644 --- a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp +++ b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp @@ -27,7 +27,8 @@ namespace { } // end namespace mlir namespace { -struct TestLinalgTransforms : public FunctionPass { +struct TestLinalgTransforms + : public PassWrapper { void runOnFunction() override; }; } // end anonymous namespace diff --git a/mlir/test/lib/Transforms/TestLiveness.cpp b/mlir/test/lib/Transforms/TestLiveness.cpp index 9b98ebd49a9c5..e51ee1b5f1547 100644 --- a/mlir/test/lib/Transforms/TestLiveness.cpp +++ b/mlir/test/lib/Transforms/TestLiveness.cpp @@ -19,7 +19,7 @@ using namespace mlir; namespace { -struct TestLivenessPass : public FunctionPass { +struct TestLivenessPass : public PassWrapper { void runOnFunction() override { llvm::errs() << "Testing : " << getFunction().getName() << "\n"; getAnalysis().print(llvm::errs()); diff --git a/mlir/test/lib/Transforms/TestLoopFusion.cpp b/mlir/test/lib/Transforms/TestLoopFusion.cpp index 4d63e412aab69..cf33ec307718a 100644 --- a/mlir/test/lib/Transforms/TestLoopFusion.cpp +++ b/mlir/test/lib/Transforms/TestLoopFusion.cpp @@ -48,7 +48,7 @@ static llvm::cl::opt clTestLoopFusionTransformation( namespace { -struct TestLoopFusion : public FunctionPass { +struct TestLoopFusion : public PassWrapper { void runOnFunction() override; }; diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp index ee96d630ae0e8..1842348071306 100644 --- a/mlir/test/lib/Transforms/TestLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp @@ -22,7 +22,8 @@ using namespace mlir; namespace { -class TestLoopMappingPass : public FunctionPass { +class TestLoopMappingPass + : public PassWrapper { public: explicit TestLoopMappingPass() {} diff --git a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp index f82ea3aed284a..61d34bcfcd371 100644 --- a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp +++ b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp @@ -23,7 +23,7 @@ namespace { // Extracts fixed-range loops for top-level loop nests with ranges defined in // the pass constructor. Assumes loops are permutable. class SimpleParametricLoopTilingPass - : public FunctionPass { + : public PassWrapper { public: SimpleParametricLoopTilingPass() = default; SimpleParametricLoopTilingPass(const SimpleParametricLoopTilingPass &) {} diff --git a/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp b/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp index ef566de1391e4..51339be67e681 100644 --- a/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp +++ b/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp @@ -28,7 +28,8 @@ using namespace mlir; namespace { /// Checks for out of bound memef access subscripts.. -struct TestMemRefBoundCheck : public FunctionPass { +struct TestMemRefBoundCheck + : public PassWrapper { void runOnFunction() override; }; diff --git a/mlir/test/lib/Transforms/TestMemRefDependenceCheck.cpp b/mlir/test/lib/Transforms/TestMemRefDependenceCheck.cpp index 2803c1d9dccc0..34db53b6ce1e8 100644 --- a/mlir/test/lib/Transforms/TestMemRefDependenceCheck.cpp +++ b/mlir/test/lib/Transforms/TestMemRefDependenceCheck.cpp @@ -28,7 +28,7 @@ namespace { // TODO(andydavis) Add common surrounding loop depth-wise dependence checks. /// Checks dependences between all pairs of memref accesses in a Function. struct TestMemRefDependenceCheck - : public FunctionPass { + : public PassWrapper { SmallVector loadsAndStores; void runOnFunction() override; }; diff --git a/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp b/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp index 9e60b8da99dc2..f2715bfb8e93e 100644 --- a/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp +++ b/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp @@ -14,14 +14,13 @@ using namespace mlir; namespace { -/// Simple constant folding pass. struct TestMemRefStrideCalculation - : public FunctionPass { + : public PassWrapper { void runOnFunction() override; }; } // end anonymous namespace -// Traverse AllocOp and compute strides of each MemRefType independently. +/// Traverse AllocOp and compute strides of each MemRefType independently. void TestMemRefStrideCalculation::runOnFunction() { llvm::outs() << "Testing: " << getFunction().getName() << "\n"; getFunction().walk([&](AllocOp allocOp) { diff --git a/mlir/test/lib/Transforms/TestOpaqueLoc.cpp b/mlir/test/lib/Transforms/TestOpaqueLoc.cpp index 47152c4598052..55b181cc9697a 100644 --- a/mlir/test/lib/Transforms/TestOpaqueLoc.cpp +++ b/mlir/test/lib/Transforms/TestOpaqueLoc.cpp @@ -17,7 +17,8 @@ namespace { /// It also takes all operations that are not function operations or /// terminators and clones them with opaque locations which store the initial /// locations. -struct TestOpaqueLoc : public OperationPass { +struct TestOpaqueLoc + : public PassWrapper> { /// A simple structure which is used for testing as an underlying location in /// OpaqueLoc. diff --git a/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp b/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp index 88d08ce631194..b1c02bdd0adf1 100644 --- a/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp +++ b/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp @@ -18,7 +18,7 @@ using namespace mlir; namespace { struct TestVectorToLoopsPass - : public FunctionPass { + : public PassWrapper { void runOnFunction() override { OwningRewritePatternList patterns; auto *context = &getContext(); diff --git a/mlir/test/lib/Transforms/TestVectorTransforms.cpp b/mlir/test/lib/Transforms/TestVectorTransforms.cpp index 8f2f64e5f60a5..808fcd21d3316 100644 --- a/mlir/test/lib/Transforms/TestVectorTransforms.cpp +++ b/mlir/test/lib/Transforms/TestVectorTransforms.cpp @@ -21,7 +21,7 @@ namespace { #include "TestVectorTransformPatterns.h.inc" struct TestVectorToVectorConversion - : public FunctionPass { + : public PassWrapper { void runOnFunction() override { OwningRewritePatternList patterns; auto *context = &getContext(); @@ -33,7 +33,7 @@ struct TestVectorToVectorConversion }; struct TestVectorSlicesConversion - : public FunctionPass { + : public PassWrapper { void runOnFunction() override { OwningRewritePatternList patterns; populateVectorSlicesLoweringPatterns(patterns, &getContext()); @@ -42,7 +42,7 @@ struct TestVectorSlicesConversion }; struct TestVectorContractionConversion - : public FunctionPass { + : public PassWrapper { TestVectorContractionConversion() = default; TestVectorContractionConversion(const TestVectorContractionConversion &pass) { }