diff --git a/mlir/docs/Tutorials/Toy/Ch-4.md b/mlir/docs/Tutorials/Toy/Ch-4.md --- a/mlir/docs/Tutorials/Toy/Ch-4.md +++ b/mlir/docs/Tutorials/Toy/Ch-4.md @@ -318,7 +318,8 @@ `mlir::FunctionPass` and overriding the `runOnFunction()` method. ```c++ -class ShapeInferencePass : public mlir::FunctionPass { +class ShapeInferencePass + : public mlir::CRTPPass { void runOnFunction() override { FuncOp function = getFunction(); ... diff --git a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp --- a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp @@ -44,7 +44,8 @@ /// 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::CRTPPass { 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 --- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp @@ -254,7 +254,8 @@ /// 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 CRTPPass { void runOnFunction() final; }; } // end anonymous namespace. diff --git a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp --- a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp @@ -44,7 +44,8 @@ /// 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::CRTPPass { 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 --- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp @@ -254,7 +254,8 @@ /// 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 CRTPPass { void runOnFunction() final; }; } // end anonymous namespace. diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -154,7 +154,7 @@ namespace { struct ToyToLLVMLoweringPass - : public OperationPass { + : public CRTPPass> { void runOnOperation() final; }; } // end anonymous namespace diff --git a/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp --- a/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp @@ -44,7 +44,8 @@ /// 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::CRTPPass { 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 --- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp @@ -254,7 +254,8 @@ /// 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 CRTPPass { void runOnFunction() final; }; } // end anonymous namespace. diff --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -154,7 +154,7 @@ namespace { struct ToyToLLVMLoweringPass - : public OperationPass { + : public CRTPPass> { void runOnOperation() final; }; } // end anonymous namespace diff --git a/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp --- a/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp @@ -44,7 +44,8 @@ /// 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::CRTPPass { 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 --- 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 @@ 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 --- a/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h +++ b/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h @@ -19,7 +19,7 @@ class Location; class ModuleOp; -template class OpPassBase; +template class OperationPass; namespace gpu { class GPUModuleOp; @@ -42,7 +42,7 @@ /// 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 @@ /// 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 --- a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h +++ b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h @@ -14,7 +14,7 @@ class LLVMTypeConverter; class OwningRewritePatternList; -template class OpPassBase; +template class OperationPass; namespace gpu { class GPUModuleOp; @@ -25,7 +25,8 @@ 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 --- a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h +++ b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h @@ -15,10 +15,11 @@ 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 --- 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 --- 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 --- 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 @@ 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 --- 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 --- 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 @@ /// 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 @@ /// 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 --- 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 @@ /// By default stdlib malloc/free are used for allocating MemRef payloads. /// Specifying `useAlloca-true` emits stack allocations instead. In the future /// this may become an enum when we have concrete uses for other options. -std::unique_ptr> createLowerToLLVMPass( +std::unique_ptr> createLowerToLLVMPass( bool useAlloca = false, bool useBarePtrCallConv = false, bool emitCWrappers = false, unsigned indexBitwidth = kDeriveIndexBitwidthFromDataLayout); diff --git a/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h b/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h --- 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 --- 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 @@ 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 --- a/mlir/include/mlir/Dialect/Affine/Passes.h +++ b/mlir/include/mlir/Dialect/Affine/Passes.h @@ -24,32 +24,33 @@ 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 @@ /// 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/FxpMathOps/Passes.h b/mlir/include/mlir/Dialect/FxpMathOps/Passes.h --- a/mlir/include/mlir/Dialect/FxpMathOps/Passes.h +++ b/mlir/include/mlir/Dialect/FxpMathOps/Passes.h @@ -17,7 +17,7 @@ namespace mlir { class FuncOp; -template class OpPassBase; +template class OperationPass; namespace fxpmath { @@ -25,11 +25,11 @@ /// arithmetic. This will leave unrecognized real math ops as-is and is /// typically followed by a pass that lowers any unrecognized ops to a pure /// floating point form. -std::unique_ptr> createLowerUniformRealMathPass(); +std::unique_ptr> createLowerUniformRealMathPass(); /// Creates a pass that lowers uniform-quantized qcast/dcast ops to equivalent /// operations that perform quantize/dequantize. -std::unique_ptr> createLowerUniformCastsPass(); +std::unique_ptr> createLowerUniformCastsPass(); } // namespace fxpmath } // namespace mlir diff --git a/mlir/include/mlir/Dialect/GPU/Passes.h b/mlir/include/mlir/Dialect/GPU/Passes.h --- a/mlir/include/mlir/Dialect/GPU/Passes.h +++ b/mlir/include/mlir/Dialect/GPU/Passes.h @@ -19,10 +19,10 @@ 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 --- 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 --- 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 --- a/mlir/include/mlir/Dialect/SPIRV/Passes.h +++ b/mlir/include/mlir/Dialect/SPIRV/Passes.h @@ -23,7 +23,7 @@ /// 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 @@ /// 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 @@ /// 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 --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -139,161 +139,119 @@ 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 @@ /// /// 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 @@ /// /// 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 @@ /// 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 CRTPPass : 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: + CRTPPass() : 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/Quantizer/Transforms/Passes.h b/mlir/include/mlir/Quantizer/Transforms/Passes.h --- a/mlir/include/mlir/Quantizer/Transforms/Passes.h +++ b/mlir/include/mlir/Quantizer/Transforms/Passes.h @@ -24,18 +24,18 @@ /// Creates a pass that infers quantized types based on metadata discovered /// in the computation. -std::unique_ptr> +std::unique_ptr> createInferQuantizedTypesPass(SolverContext &solverContext, const TargetConfiguration &config); -std::unique_ptr> createInferQuantizedTypesPass(); +std::unique_ptr> createInferQuantizedTypesPass(); /// Creates a pass which removes any instrumentation and hint ops which have /// no effect on final runtime. -std::unique_ptr> createRemoveInstrumentationPass(); +std::unique_ptr> createRemoveInstrumentationPass(); /// Adds default (dummy) statistics to ops that can benefit from runtime stats. /// Meant for testing. -std::unique_ptr> createAddDefaultStatsPass(); +std::unique_ptr> createAddDefaultStatsPass(); } // namespace quantizer } // namespace mlir diff --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h --- a/mlir/include/mlir/Transforms/Passes.h +++ b/mlir/include/mlir/Transforms/Passes.h @@ -24,7 +24,7 @@ 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 @@ /// 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 @@ /// 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 @@ /// 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 --- 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 @@ 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 --- 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 @@ 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 --- a/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp +++ b/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp @@ -164,7 +164,7 @@ namespace { struct ConvertAVX512ToLLVMPass - : public OperationPass { + : public CRTPPass> { /// Include the generated pass utilities. #define GEN_PASS_ConvertAVX512ToLLVM #include "mlir/Conversion/Passes.h.inc" @@ -193,6 +193,6 @@ } } -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 --- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp +++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp @@ -577,7 +577,7 @@ } namespace { -class LowerAffinePass : public FunctionPass { +class LowerAffinePass : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_ConvertAffineToStandard #include "mlir/Conversion/Passes.h.inc" @@ -595,6 +595,6 @@ /// 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 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp @@ -47,7 +47,7 @@ /// GPU binary code, which is then attached as an attribute to the function. The /// function body is erased. class GpuKernelToCubinPass - : public OperationPass { + : public CRTPPass> { public: GpuKernelToCubinPass(CubinGenerator cubinGenerator) : cubinGenerator(cubinGenerator) {} @@ -143,7 +143,7 @@ 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 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp @@ -61,7 +61,7 @@ /// /// Intermediate data structures are allocated on the stack. class GpuLaunchFuncToCudaCallsPass - : public OperationPass { + : public CRTPPass> { private: /// Include the generated pass utilities. #define GEN_PASS_ConvertGpuLaunchFuncToCudaCalls @@ -464,7 +464,7 @@ 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 --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -246,7 +246,8 @@ /// This pass only handles device code and is not meant to be run on GPU host /// code. class LowerGpuOpsToNVVMOpsPass - : public OperationPass { + : public CRTPPass> { public: /// Include the generated pass utilities. #define GEN_PASS_ConvertGpuOpsToNVVMOps @@ -324,7 +325,7 @@ "__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 --- a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp +++ b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp @@ -32,7 +32,8 @@ // This pass only handles device code and is not meant to be run on GPU host // code. class LowerGpuOpsToROCDLOpsPass - : public OperationPass { + : public CRTPPass> { public: /// Include the generated pass utilities. #define GEN_PASS_ConvertGpuOpsToROCDLOps @@ -83,8 +84,7 @@ } // 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 --- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp @@ -33,7 +33,8 @@ /// replace it). /// /// 2) Lower the body of the spirv::ModuleOp. -struct GPUToSPIRVPass : public OperationPass { +struct GPUToSPIRVPass + : public CRTPPass> { /// Include the generated pass utilities. #define GEN_PASS_ConvertGpuToSPIRV #include "mlir/Conversion/Passes.h.inc" @@ -71,6 +72,6 @@ } } -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 --- a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp +++ b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp @@ -38,7 +38,8 @@ /// function and attaching binary data and entry point name as an attributes to /// created vulkan launch call op. class ConvertGpuLaunchFuncToVulkanLaunchFunc - : public OperationPass { + : public CRTPPass> { public: /// Include the generated pass utilities. #define GEN_PASS_ConvertGpuLaunchFuncToVulkanLaunchFunc @@ -168,7 +169,7 @@ 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 --- a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp +++ b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp @@ -57,7 +57,8 @@ /// * deinitVulkan -- deinitializes vulkan runtime /// class VulkanLaunchFuncToVulkanCallsPass - : public OperationPass { + : public CRTPPass> { private: /// Include the generated pass utilities. #define GEN_PASS_ConvertVulkanLaunchFuncToVulkanCalls @@ -428,7 +429,7 @@ 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 --- a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp +++ b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp @@ -557,7 +557,7 @@ namespace { struct ConvertLinalgToLLVMPass - : public OperationPass { + : public CRTPPass> { /// Include the generated pass utilities. #define GEN_PASS_ConvertLinalgToLLVM #include "mlir/Conversion/Passes.h.inc" @@ -589,6 +589,6 @@ 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 --- a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp +++ b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp @@ -16,7 +16,8 @@ namespace { /// A pass converting MLIR Linalg ops into SPIR-V ops. -class LinalgToSPIRVPass : public OperationPass { +class LinalgToSPIRVPass + : public CRTPPass> { /// Include the generated pass utilities. #define GEN_PASS_ConvertLinalgToSPIRV #include "mlir/Conversion/Passes.h.inc" @@ -47,6 +48,6 @@ 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 --- a/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp +++ b/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp @@ -30,7 +30,8 @@ namespace { -struct LoopToStandardPass : public OperationPass { +struct LoopToStandardPass + : public CRTPPass> { /// 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 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp @@ -28,7 +28,7 @@ // 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 CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_ConvertSimpleLoopsToGPU #include "mlir/Conversion/Passes.h.inc" @@ -62,7 +62,7 @@ // 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 CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_ConvertLoopsToGPU #include "mlir/Conversion/Passes.h.inc" @@ -104,7 +104,8 @@ } }; -struct ParallelLoopToGpuPass : public OperationPass { +struct ParallelLoopToGpuPass + : public CRTPPass> { /// Include the generated pass utilities. #define GEN_PASS_ConvertParallelLoopToGpu #include "mlir/Conversion/Passes.h.inc" @@ -125,22 +126,22 @@ } // 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 --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -2797,7 +2797,8 @@ namespace { /// A pass converting MLIR operations into the LLVM IR dialect. -struct LLVMLoweringPass : public OperationPass { +struct LLVMLoweringPass + : public CRTPPass> { /// Include the generated pass utilities. #define GEN_PASS_ConvertStandardToLLVM #include "mlir/Conversion/Passes.h.inc" @@ -2853,7 +2854,7 @@ this->addIllegalOp(); } -std::unique_ptr> +std::unique_ptr> mlir::createLowerToLLVMPass(bool useAlloca, bool useBarePtrCallConv, bool emitCWrappers, unsigned indexBitwidth) { return std::make_unique(useAlloca, useBarePtrCallConv, diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp @@ -22,7 +22,7 @@ namespace { /// A pass converting MLIR Standard operations into the SPIR-V dialect. class ConvertStandardToSPIRVPass - : public OperationPass { + : public CRTPPass> { /// Include the generated pass utilities. #define GEN_PASS_ConvertStandardToSPIRV #include "mlir/Conversion/Passes.h.inc" @@ -49,6 +49,7 @@ } } -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 --- a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp @@ -160,7 +160,8 @@ //===----------------------------------------------------------------------===// namespace { -struct SPIRVLegalization final : public OperationPass { +struct SPIRVLegalization final + : public CRTPPass> { /// 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 --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp @@ -1119,7 +1119,7 @@ namespace { struct LowerVectorToLLVMPass - : public OperationPass { + : public CRTPPass> { /// Include the generated pass utilities. #define GEN_PASS_ConvertVectorToLLVM #include "mlir/Conversion/Passes.h.inc" @@ -1155,6 +1155,6 @@ } } -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 --- a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp @@ -74,7 +74,7 @@ // TODO(bondhugula): We currently can't generate copies correctly when stores // are strided. Check for strided stores. struct AffineDataCopyGeneration - : public FunctionPass { + : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_AffineDataCopyGeneration #include "mlir/Dialect/Affine/Passes.h.inc" @@ -133,14 +133,15 @@ /// 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 --- a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp @@ -41,7 +41,8 @@ /// 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 CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_AffineLoopInvariantCodeMotion #include "mlir/Dialect/Affine/Passes.h.inc" @@ -232,7 +233,7 @@ }); } -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 --- a/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp @@ -58,7 +58,7 @@ namespace { /// A pass to perform loop tiling on all suitable loop nests of a Function. -struct LoopTiling : public FunctionPass { +struct LoopTiling : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_AffineLoopTiling #include "mlir/Dialect/Affine/Passes.h.inc" @@ -85,11 +85,11 @@ /// Creates a pass to perform loop tiling on all suitable loop nests of a /// Function. -std::unique_ptr> +std::unique_ptr> mlir::createLoopTilingPass(uint64_t cacheSizeBytes) { return std::make_unique(cacheSizeBytes); } -std::unique_ptr> mlir::createLoopTilingPass() { +std::unique_ptr> mlir::createLoopTilingPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp --- a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp @@ -58,7 +58,7 @@ /// 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 CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_AffineUnroll #include "mlir/Dialect/Affine/Passes.h.inc" @@ -166,7 +166,7 @@ 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 --- a/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp @@ -60,7 +60,7 @@ namespace { /// Loop unroll jam pass. Currently, this just unroll jams the first /// outer loop in a Function. -struct LoopUnrollAndJam : public FunctionPass { +struct LoopUnrollAndJam : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_AffineLoopUnrollAndJam #include "mlir/Dialect/Affine/Passes.h.inc" @@ -76,7 +76,7 @@ }; } // 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 --- a/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp @@ -27,7 +27,7 @@ /// all memrefs with non-trivial layout maps are converted to ones with trivial /// identity layout ones. struct SimplifyAffineStructures - : public FunctionPass { + : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_SimplifyAffineStructures #include "mlir/Dialect/Affine/Passes.h.inc" @@ -73,7 +73,8 @@ } // 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 --- a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp @@ -573,7 +573,7 @@ /// Base state for the vectorize pass. /// Command line arguments are preempted by non-empty pass arguments. -struct Vectorize : public FunctionPass { +struct Vectorize : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_AffineVectorize #include "mlir/Dialect/Affine/Passes.h.inc" @@ -1252,10 +1252,10 @@ 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/FxpMathOps/Transforms/LowerUniformRealMath.cpp b/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp --- a/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp +++ b/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp @@ -22,7 +22,7 @@ namespace { struct LowerUniformRealMathPass - : public FunctionPass { + : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_FxpMathLowerUniformRealMath #include "mlir/Dialect/FxpMathOps/Passes.h.inc" @@ -30,7 +30,8 @@ void runOnFunction() override; }; -struct LowerUniformCastsPass : public FunctionPass { +struct LowerUniformCastsPass + : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_FxpMathLowerUniformCasts #include "mlir/Dialect/FxpMathOps/Passes.h.inc" @@ -371,7 +372,7 @@ applyPatternsGreedily(fn, patterns); } -std::unique_ptr> +std::unique_ptr> mlir::fxpmath::createLowerUniformRealMathPass() { return std::make_unique(); } @@ -388,7 +389,7 @@ applyPatternsGreedily(fn, patterns); } -std::unique_ptr> +std::unique_ptr> mlir::fxpmath::createLowerUniformCastsPass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -215,7 +215,7 @@ /// a separate pass. The external functions can then be annotated with the /// symbol of the cubin accessor function. class GpuKernelOutliningPass - : public OperationPass { + : public CRTPPass> { public: /// Include the generated pass utilities. #define GEN_PASS_GpuKernelOutlining @@ -301,6 +301,6 @@ } // 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 --- a/mlir/lib/Dialect/LLVMIR/Transforms/LegalizeForExport.cpp +++ b/mlir/lib/Dialect/LLVMIR/Transforms/LegalizeForExport.cpp @@ -57,7 +57,8 @@ } namespace { -struct LegalizeForExportPass : public OperationPass { +struct LegalizeForExportPass + : public CRTPPass> { /// 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 --- a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp @@ -567,7 +567,8 @@ }; /// Pass that fuses generic ops on tensors. Used only for testing. -struct FusionOfTensorOpsPass : public OperationPass { +struct FusionOfTensorOpsPass + : public CRTPPass> { /// Include the generated pass utilities. #define GEN_PASS_LinalgFusionOfTensorOps #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -580,7 +581,7 @@ }; }; -struct LinalgFusionPass : public FunctionPass { +struct LinalgFusionPass : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_LinalgFusion #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -589,7 +590,7 @@ }; } // 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 --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp @@ -693,7 +693,7 @@ } namespace { -struct LowerToAffineLoops : public FunctionPass { +struct LowerToAffineLoops : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_LinalgLowerToAffineLoops #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -703,7 +703,7 @@ &getContext()); } }; -struct LowerToLoops : public FunctionPass { +struct LowerToLoops : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_LinalgLowerToLoops #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -713,7 +713,8 @@ &getContext()); } }; -struct LowerToParallelLoops : public FunctionPass { +struct LowerToParallelLoops + : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_LinalgLowerToParallelLoops #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -725,16 +726,16 @@ }; } // 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 --- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp @@ -230,7 +230,8 @@ } namespace { -struct LinalgPromotionPass : public FunctionPass { +struct LinalgPromotionPass + : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_LinalgPromotion #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -247,10 +248,10 @@ }; } // 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 --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -507,7 +507,7 @@ } namespace { -struct LinalgTilingPass : public FunctionPass { +struct LinalgTilingPass : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_LinalgTiling #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -524,7 +524,7 @@ }; struct LinalgTilingToParallelLoopsPass - : public FunctionPass { + : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_LinalgTilingToParallelLoops #include "mlir/Dialect/Linalg/Passes.h.inc" @@ -542,12 +542,12 @@ } // 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 --- a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopFusion.cpp +++ b/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopFusion.cpp @@ -160,7 +160,8 @@ } namespace { -struct ParallelLoopFusion : public OperationPass { +struct ParallelLoopFusion + : public CRTPPass> { /// 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 --- a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopSpecialization.cpp +++ b/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopSpecialization.cpp @@ -60,7 +60,7 @@ namespace { struct ParallelLoopSpecialization - : public FunctionPass { + : public CRTPPass { /// 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 --- a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopTiling.cpp +++ b/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopTiling.cpp @@ -101,7 +101,7 @@ } namespace { -struct ParallelLoopTiling : public FunctionPass { +struct ParallelLoopTiling : public CRTPPass { /// 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 --- a/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp +++ b/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp @@ -21,7 +21,7 @@ using namespace mlir::quant; namespace { -struct ConvertConstPass : public FunctionPass { +struct ConvertConstPass : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_QuantConvertConst #include "mlir/Dialect/Quant/Passes.h.inc" @@ -105,6 +105,6 @@ 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 --- a/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp +++ b/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp @@ -20,7 +20,7 @@ namespace { struct ConvertSimulatedQuantPass - : public FunctionPass { + : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_QuantConvertSimulatedQuant #include "mlir/Dialect/Quant/Passes.h.inc" @@ -140,7 +140,7 @@ 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 --- a/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp @@ -80,7 +80,8 @@ namespace { class DecorateSPIRVCompositeTypeLayoutPass - : public OperationPass { + : public CRTPPass> { private: void runOnOperation() override; }; @@ -113,7 +114,7 @@ } } -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 --- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp @@ -148,7 +148,7 @@ /// Pass to implement the ABI information specified as attributes. class LowerABIAttributesPass final - : public OperationPass { + : public CRTPPass> { private: void runOnOperation() override; }; @@ -260,7 +260,7 @@ } } -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 --- a/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp @@ -27,7 +27,7 @@ /// Pass to deduce minimal version/extension/capability requirements for a /// spirv::ModuleOp. class UpdateVCEPass final - : public OperationPass { + : public CRTPPass> { private: void runOnOperation() override; }; @@ -173,7 +173,7 @@ 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 --- a/mlir/lib/Pass/PassDetail.h +++ b/mlir/lib/Pass/PassDetail.h @@ -19,7 +19,7 @@ //===----------------------------------------------------------------------===// /// Pass to verify an operation and signal failure if necessary. -class VerifierPass : public OperationPass { +class VerifierPass : public CRTPPass> { void runOnOperation() override; }; @@ -49,7 +49,7 @@ /// An adaptor pass used to run operation passes over nested operations /// synchronously on a single thread. -class OpToOpPassAdaptor : public OperationPass, +class OpToOpPassAdaptor : public CRTPPass>, public OpToOpPassAdaptorBase { public: OpToOpPassAdaptor(OpPassManager &&mgr); @@ -61,7 +61,7 @@ /// An adaptor pass used to run operation passes over nested operations /// asynchronously across multiple threads. class OpToOpPassAdaptorParallel - : public OperationPass, + : public CRTPPass>, public OpToOpPassAdaptorBase { public: OpToOpPassAdaptorParallel(OpPassManager &&mgr); diff --git a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp --- a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp +++ b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp @@ -29,7 +29,7 @@ using namespace mlir::quant; namespace { -class AddDefaultStatsPass : public FunctionPass { +class AddDefaultStatsPass : public CRTPPass { public: /// Include the generated pass utilities. #define GEN_PASS_QuantizerAddDefaultStats @@ -112,7 +112,7 @@ }); } -std::unique_ptr> +std::unique_ptr> mlir::quantizer::createAddDefaultStatsPass() { return std::make_unique(); } diff --git a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp --- a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp +++ b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp @@ -72,7 +72,7 @@ namespace { class InferQuantizedTypesPass - : public OperationPass { + : public CRTPPass> { public: /// Include the generated pass utilities. #define GEN_PASS_QuantizerInferQuantizedTypes @@ -282,12 +282,12 @@ } } -std::unique_ptr> +std::unique_ptr> mlir::quantizer::createInferQuantizedTypesPass( SolverContext &solverContext, const TargetConfiguration &config) { return std::make_unique(solverContext, config); } -std::unique_ptr> +std::unique_ptr> mlir::quantizer::createInferQuantizedTypesPass() { return std::make_unique(); } diff --git a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp --- a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp +++ b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp @@ -24,7 +24,7 @@ namespace { class RemoveInstrumentationPass - : public FunctionPass { + : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_QuantizerRemoveInstrumentation #include "mlir/Quantizer/Transforms/Passes.h.inc" @@ -60,7 +60,7 @@ applyPatternsGreedily(func, patterns); } -std::unique_ptr> +std::unique_ptr> mlir::quantizer::createRemoveInstrumentationPass() { return std::make_unique(); } diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp --- a/mlir/lib/Transforms/CSE.cpp +++ b/mlir/lib/Transforms/CSE.cpp @@ -73,7 +73,7 @@ namespace { /// Simple common sub-expression elimination. -struct CSE : public OperationPass { +struct CSE : public CRTPPass> { /// 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 --- a/mlir/lib/Transforms/Canonicalizer.cpp +++ b/mlir/lib/Transforms/Canonicalizer.cpp @@ -19,7 +19,7 @@ namespace { /// Canonicalize operations in nested regions. -struct Canonicalizer : public OperationPass { +struct Canonicalizer : public CRTPPass> { /// 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 --- a/mlir/lib/Transforms/Inliner.cpp +++ b/mlir/lib/Transforms/Inliner.cpp @@ -589,7 +589,7 @@ //===----------------------------------------------------------------------===// namespace { -struct InlinerPass : public OperationPass { +struct InlinerPass : public CRTPPass> { /// 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 --- a/mlir/lib/Transforms/LocationSnapshot.cpp +++ b/mlir/lib/Transforms/LocationSnapshot.cpp @@ -123,7 +123,8 @@ } namespace { -struct LocationSnapshotPass : public OperationPass { +struct LocationSnapshotPass + : public CRTPPass> { /// 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 --- a/mlir/lib/Transforms/LoopCoalescing.cpp +++ b/mlir/lib/Transforms/LoopCoalescing.cpp @@ -19,7 +19,7 @@ using namespace mlir; namespace { -struct LoopCoalescingPass : public FunctionPass { +struct LoopCoalescingPass : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_LoopCoalescing #include "mlir/Transforms/Passes.h.inc" @@ -89,6 +89,6 @@ } // 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 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -77,7 +77,7 @@ // 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 CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_AffineLoopFusion #include "mlir/Transforms/Passes.h.inc" @@ -104,7 +104,7 @@ } // 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 --- a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp @@ -27,7 +27,8 @@ namespace { /// Loop invariant code motion (LICM) pass. -struct LoopInvariantCodeMotion : public OperationPass { +struct LoopInvariantCodeMotion + : public CRTPPass> { /// 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 --- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp +++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp @@ -60,7 +60,7 @@ // currently only eliminates the stores only if no other loads/uses (other // than dealloc) remain. // -struct MemRefDataFlowOpt : public FunctionPass { +struct MemRefDataFlowOpt : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_MemRefDataFlowOpt #include "mlir/Transforms/Passes.h.inc" @@ -82,7 +82,7 @@ /// 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 --- 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 CRTPPass> { /// Include the generated pass utilities. #define GEN_PASS_PrintOpStats #include "mlir/Transforms/Passes.h.inc" @@ -85,6 +86,6 @@ } } -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 --- 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 CRTPPass> { /// 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 --- 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 CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_AffinePipelineDataTransfer #include "mlir/Transforms/Passes.h.inc" @@ -43,7 +44,7 @@ /// 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 --- 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 CRTPPass> { /// 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 --- 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 CRTPPass> { /// 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 --- a/mlir/lib/Transforms/ViewOpGraph.cpp +++ b/mlir/lib/Transforms/ViewOpGraph.cpp @@ -100,7 +100,7 @@ // 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 CRTPPass> { /// Include the generated pass utilities. #define GEN_PASS_PrintOpGraph #include "mlir/Transforms/Passes.h.inc" @@ -160,7 +160,7 @@ 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 --- a/mlir/lib/Transforms/ViewRegionGraph.cpp +++ b/mlir/lib/Transforms/ViewRegionGraph.cpp @@ -60,7 +60,7 @@ void mlir::Region::viewGraph() { viewGraph("region"); } namespace { -struct PrintCFGPass : public FunctionPass { +struct PrintCFGPass : public CRTPPass { /// Include the generated pass utilities. #define GEN_PASS_PrintCFG #include "mlir/Transforms/Passes.h.inc" @@ -79,7 +79,7 @@ }; } // 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 --- a/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp +++ b/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp @@ -25,7 +25,7 @@ namespace { -struct TestAffineDataCopy : public FunctionPass { +struct TestAffineDataCopy : public CRTPPass { TestAffineDataCopy() = default; TestAffineDataCopy(const TestAffineDataCopy &pass){}; diff --git a/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp b/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp --- a/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp +++ b/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp @@ -25,7 +25,8 @@ namespace { /// This pass applies the permutation on the first maximal perfect nest. -struct TestLoopPermutation : public FunctionPass { +struct TestLoopPermutation + : public CRTPPass { TestLoopPermutation() = default; TestLoopPermutation(const TestLoopPermutation &pass){}; diff --git a/mlir/test/lib/Dialect/Affine/TestParallelismDetection.cpp b/mlir/test/lib/Dialect/Affine/TestParallelismDetection.cpp --- a/mlir/test/lib/Dialect/Affine/TestParallelismDetection.cpp +++ b/mlir/test/lib/Dialect/Affine/TestParallelismDetection.cpp @@ -20,7 +20,7 @@ namespace { struct TestParallelismDetection - : public FunctionPass { + : public CRTPPass { void runOnFunction() override; }; diff --git a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp --- a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp +++ b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp @@ -72,7 +72,7 @@ llvm::cl::cat(clOptionsCategory)); namespace { -struct VectorizerTestPass : public FunctionPass { +struct VectorizerTestPass : public CRTPPass { 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 --- a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp +++ b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp @@ -20,7 +20,8 @@ namespace { /// A pass for testing SPIR-V op availability. -struct PrintOpAvailability : public FunctionPass { +struct PrintOpAvailability + : public CRTPPass { void runOnFunction() override; }; } // end anonymous namespace @@ -88,7 +89,7 @@ namespace { /// A pass for testing SPIR-V op availability. -struct ConvertToTargetEnv : public FunctionPass { +struct ConvertToTargetEnv : public CRTPPass { void runOnFunction() override; }; diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -38,7 +38,7 @@ //===----------------------------------------------------------------------===// namespace { -struct TestPatternDriver : public FunctionPass { +struct TestPatternDriver : public CRTPPass { void runOnFunction() override { mlir::OwningRewritePatternList patterns; populateWithGenerated(&getContext(), &patterns); @@ -96,7 +96,8 @@ << it.value().getDefiningOp(); } -struct TestReturnTypeDriver : public FunctionPass { +struct TestReturnTypeDriver + : public CRTPPass { void runOnFunction() override { if (getFunction().getName() == "testCreateFunctions") { std::vector ops; @@ -363,7 +364,7 @@ }; struct TestLegalizePatternDriver - : public OperationPass { + : public CRTPPass> { /// The mode of conversion to use with the driver. enum class ConversionMode { Analysis, Full, Partial }; @@ -498,7 +499,8 @@ } }; -struct TestRemappedValue : public mlir::FunctionPass { +struct TestRemappedValue + : public mlir::CRTPPass { 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 --- a/mlir/test/lib/IR/TestFunc.cpp +++ b/mlir/test/lib/IR/TestFunc.cpp @@ -13,7 +13,8 @@ namespace { /// This is a test pass for verifying FuncOp's eraseArgument method. -struct TestFuncEraseArg : public OperationPass { +struct TestFuncEraseArg + : public CRTPPass> { void runOnOperation() override { auto module = getOperation(); @@ -36,7 +37,8 @@ }; /// This is a test pass for verifying FuncOp's setType method. -struct TestFuncSetType : public OperationPass { +struct TestFuncSetType + : public CRTPPass> { 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 --- a/mlir/test/lib/IR/TestMatchers.cpp +++ b/mlir/test/lib/IR/TestMatchers.cpp @@ -15,7 +15,7 @@ namespace { /// This is a test pass for verifying matchers. -struct TestMatchers : public FunctionPass { +struct TestMatchers : public CRTPPass { void runOnFunction() override; }; } // end anonymous namespace diff --git a/mlir/test/lib/IR/TestSideEffects.cpp b/mlir/test/lib/IR/TestSideEffects.cpp --- 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 CRTPPass> { void runOnOperation() override { auto module = getOperation(); diff --git a/mlir/test/lib/IR/TestSymbolUses.cpp b/mlir/test/lib/IR/TestSymbolUses.cpp --- a/mlir/test/lib/IR/TestSymbolUses.cpp +++ b/mlir/test/lib/IR/TestSymbolUses.cpp @@ -15,7 +15,8 @@ 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 CRTPPass> { WalkResult operateOnSymbol(Operation *symbol, ModuleOp module, SmallVectorImpl &deadFunctions) { // Test computing uses on a non symboltable op. @@ -87,7 +88,7 @@ /// This is a symbol test pass that tests the symbol use replacement /// functionality provided by the symbol table. struct SymbolReplacementPass - : public OperationPass { + : public CRTPPass> { void runOnOperation() override { auto module = getOperation(); diff --git a/mlir/test/lib/Pass/TestPassManager.cpp b/mlir/test/lib/Pass/TestPassManager.cpp --- a/mlir/test/lib/Pass/TestPassManager.cpp +++ b/mlir/test/lib/Pass/TestPassManager.cpp @@ -13,13 +13,14 @@ using namespace mlir; namespace { -struct TestModulePass : public OperationPass { +struct TestModulePass + : public CRTPPass> { void runOnOperation() final {} }; -struct TestFunctionPass : public FunctionPass { +struct TestFunctionPass : public CRTPPass { void runOnFunction() final {} }; -class TestOptionsPass : public FunctionPass { +class TestOptionsPass : public CRTPPass { public: struct Options : public PassPipelineOptions { ListOption listOption{*this, "list", @@ -53,12 +54,13 @@ /// A test pass that always aborts to enable testing the crash recovery /// mechanism of the pass manager. -class TestCrashRecoveryPass : public OperationPass { +class TestCrashRecoveryPass + : public CRTPPass> { void runOnOperation() final { abort(); } }; /// A test pass that contains a statistic. -struct TestStatisticPass : public OperationPass { +struct TestStatisticPass : public CRTPPass> { TestStatisticPass() = default; TestStatisticPass(const TestStatisticPass &) {} diff --git a/mlir/test/lib/Transforms/TestAllReduceLowering.cpp b/mlir/test/lib/Transforms/TestAllReduceLowering.cpp --- a/mlir/test/lib/Transforms/TestAllReduceLowering.cpp +++ b/mlir/test/lib/Transforms/TestAllReduceLowering.cpp @@ -18,7 +18,7 @@ namespace { struct TestAllReduceLoweringPass - : public OperationPass { + : public CRTPPass> { void runOnOperation() override { OwningRewritePatternList patterns; populateGpuRewritePatterns(&getContext(), patterns); diff --git a/mlir/test/lib/Transforms/TestCallGraph.cpp b/mlir/test/lib/Transforms/TestCallGraph.cpp --- 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 CRTPPass> { 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 --- a/mlir/test/lib/Transforms/TestConstantFold.cpp +++ b/mlir/test/lib/Transforms/TestConstantFold.cpp @@ -19,7 +19,7 @@ namespace { /// Simple constant folding pass. -struct TestConstantFold : public FunctionPass { +struct TestConstantFold : public CRTPPass { // 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 --- a/mlir/test/lib/Transforms/TestDominance.cpp +++ b/mlir/test/lib/Transforms/TestDominance.cpp @@ -64,7 +64,7 @@ DenseMap blockIds; }; -struct TestDominancePass : public FunctionPass { +struct TestDominancePass : public CRTPPass { 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 --- a/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp +++ b/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp @@ -24,7 +24,8 @@ /// 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 CRTPPass> { 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 --- a/mlir/test/lib/Transforms/TestGpuParallelLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestGpuParallelLoopMapping.cpp @@ -20,7 +20,8 @@ /// Simple pass for testing the mapping of parallel loops to hardware ids using /// a greedy mapping strategy. class TestGpuGreedyParallelLoopMappingPass - : public OperationPass { + : public CRTPPass> { 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 --- 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 CRTPPass { void runOnFunction() override { auto function = getFunction(); diff --git a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp --- a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp +++ b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp @@ -27,7 +27,8 @@ } // end namespace mlir namespace { -struct TestLinalgTransforms : public FunctionPass { +struct TestLinalgTransforms + : public CRTPPass { void runOnFunction() override; }; } // end anonymous namespace diff --git a/mlir/test/lib/Transforms/TestLiveness.cpp b/mlir/test/lib/Transforms/TestLiveness.cpp --- a/mlir/test/lib/Transforms/TestLiveness.cpp +++ b/mlir/test/lib/Transforms/TestLiveness.cpp @@ -19,7 +19,7 @@ namespace { -struct TestLivenessPass : public FunctionPass { +struct TestLivenessPass : public CRTPPass { 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 --- a/mlir/test/lib/Transforms/TestLoopFusion.cpp +++ b/mlir/test/lib/Transforms/TestLoopFusion.cpp @@ -48,7 +48,7 @@ namespace { -struct TestLoopFusion : public FunctionPass { +struct TestLoopFusion : public CRTPPass { void runOnFunction() override; }; diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp --- a/mlir/test/lib/Transforms/TestLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp @@ -22,7 +22,7 @@ using namespace mlir; namespace { -class TestLoopMappingPass : public FunctionPass { +class TestLoopMappingPass : public CRTPPass { public: explicit TestLoopMappingPass() {} diff --git a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp --- a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp +++ b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp @@ -23,7 +23,7 @@ // 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 CRTPPass { public: SimpleParametricLoopTilingPass() = default; SimpleParametricLoopTilingPass(const SimpleParametricLoopTilingPass &) {} diff --git a/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp b/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp --- a/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp +++ b/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp @@ -28,7 +28,8 @@ namespace { /// Checks for out of bound memef access subscripts.. -struct TestMemRefBoundCheck : public FunctionPass { +struct TestMemRefBoundCheck + : public CRTPPass { void runOnFunction() override; }; diff --git a/mlir/test/lib/Transforms/TestMemRefDependenceCheck.cpp b/mlir/test/lib/Transforms/TestMemRefDependenceCheck.cpp --- a/mlir/test/lib/Transforms/TestMemRefDependenceCheck.cpp +++ b/mlir/test/lib/Transforms/TestMemRefDependenceCheck.cpp @@ -28,7 +28,7 @@ // 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 CRTPPass { SmallVector loadsAndStores; void runOnFunction() override; }; diff --git a/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp b/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp --- 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 CRTPPass { 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 --- a/mlir/test/lib/Transforms/TestOpaqueLoc.cpp +++ b/mlir/test/lib/Transforms/TestOpaqueLoc.cpp @@ -17,7 +17,7 @@ /// 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 CRTPPass> { /// 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 --- a/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp +++ b/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp @@ -18,7 +18,7 @@ namespace { struct TestVectorToLoopsPass - : public FunctionPass { + : public CRTPPass { void runOnFunction() override { OwningRewritePatternList patterns; auto *context = &getContext(); diff --git a/mlir/test/lib/Transforms/TestVectorTransforms.cpp b/mlir/test/lib/Transforms/TestVectorTransforms.cpp --- a/mlir/test/lib/Transforms/TestVectorTransforms.cpp +++ b/mlir/test/lib/Transforms/TestVectorTransforms.cpp @@ -21,7 +21,7 @@ #include "TestVectorTransformPatterns.h.inc" struct TestVectorToVectorConversion - : public FunctionPass { + : public CRTPPass { void runOnFunction() override { OwningRewritePatternList patterns; auto *context = &getContext(); @@ -33,7 +33,7 @@ }; struct TestVectorSlicesConversion - : public FunctionPass { + : public CRTPPass { void runOnFunction() override { OwningRewritePatternList patterns; populateVectorSlicesLoweringPatterns(patterns, &getContext()); @@ -42,7 +42,7 @@ }; struct TestVectorContractionConversion - : public FunctionPass { + : public CRTPPass { TestVectorContractionConversion() = default; TestVectorContractionConversion(const TestVectorContractionConversion &pass) { }