diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td --- a/mlir/include/mlir/Conversion/Passes.td +++ b/mlir/include/mlir/Conversion/Passes.td @@ -15,7 +15,7 @@ // AffineToStandard //===----------------------------------------------------------------------===// -def ConvertAffineToStandard : Pass<"lower-affine"> { +def ConvertAffineToStandard : FunctionPass<"lower-affine"> { let summary = "Lower Affine operations to a combination of Standard and Loop " "operations"; let description = [{ @@ -72,7 +72,7 @@ // AVX512ToLLVM //===----------------------------------------------------------------------===// -def ConvertAVX512ToLLVM : Pass<"convert-avx512-to-llvm"> { +def ConvertAVX512ToLLVM : Pass<"convert-avx512-to-llvm", "ModuleOp"> { let summary = "Convert the operations from the avx512 dialect into the LLVM " "dialect"; let constructor = "mlir::createConvertAVX512ToLLVMPass()"; @@ -82,7 +82,7 @@ // GPUToCUDA //===----------------------------------------------------------------------===// -def ConvertGpuLaunchFuncToCudaCalls : Pass<"launch-func-to-cuda"> { +def ConvertGpuLaunchFuncToCudaCalls : Pass<"launch-func-to-cuda", "ModuleOp"> { let summary = "Convert all launch_func ops to CUDA runtime calls"; let constructor = "mlir::createConvertGpuLaunchFuncToCudaCallsPass()"; } @@ -91,7 +91,7 @@ // GPUToNVVM //===----------------------------------------------------------------------===// -def ConvertGpuOpsToNVVMOps : Pass<"convert-gpu-to-nvvm"> { +def ConvertGpuOpsToNVVMOps : Pass<"convert-gpu-to-nvvm", "gpu::GPUModuleOp"> { let summary = "Generate NVVM operations for gpu operations"; let constructor = "mlir::createLowerGpuOpsToNVVMOpsPass()"; } @@ -100,7 +100,7 @@ // GPUToROCDL //===----------------------------------------------------------------------===// -def ConvertGpuOpsToROCDLOps : Pass<"convert-gpu-to-rocdl"> { +def ConvertGpuOpsToROCDLOps : Pass<"convert-gpu-to-rocdl", "gpu::GPUModuleOp"> { let summary = "Generate ROCDL operations for gpu operations"; let constructor = "mlir::createLowerGpuOpsToROCDLOpsPass()"; } @@ -109,7 +109,7 @@ // GPUToSPIRV //===----------------------------------------------------------------------===// -def ConvertGPUToSPIRV : Pass<"convert-gpu-to-spirv"> { +def ConvertGPUToSPIRV : Pass<"convert-gpu-to-spirv", "ModuleOp"> { let summary = "Convert GPU dialect to SPIR-V dialect"; let constructor = "mlir::createConvertGPUToSPIRVPass()"; } @@ -119,12 +119,13 @@ //===----------------------------------------------------------------------===// def ConvertGpuLaunchFuncToVulkanLaunchFunc - : Pass<"convert-gpu-launch-to-vulkan-launch"> { + : Pass<"convert-gpu-launch-to-vulkan-launch", "ModuleOp"> { let summary = "Convert gpu.launch_func to vulkanLaunch external call"; let constructor = "mlir::createConvertGpuLaunchFuncToVulkanLaunchFuncPass()"; } -def ConvertVulkanLaunchFuncToVulkanCalls : Pass<"launch-func-to-vulkan"> { +def ConvertVulkanLaunchFuncToVulkanCalls + : Pass<"launch-func-to-vulkan", "ModuleOp"> { let summary = "Convert vulkanLaunch external call to Vulkan runtime external " "calls"; let constructor = "mlir::createConvertVulkanLaunchFuncToVulkanCallsPass()"; @@ -134,7 +135,7 @@ // LinalgToLLVM //===----------------------------------------------------------------------===// -def ConvertLinalgToLLVM : Pass<"convert-linalg-to-llvm"> { +def ConvertLinalgToLLVM : Pass<"convert-linalg-to-llvm", "ModuleOp"> { let summary = "Convert the operations from the linalg dialect into the LLVM " "dialect"; let constructor = "mlir::createConvertLinalgToLLVMPass()"; @@ -144,7 +145,7 @@ // LinalgToSPIRV //===----------------------------------------------------------------------===// -def ConvertLinalgToSPIRV : Pass<"convert-linalg-to-spirv"> { +def ConvertLinalgToSPIRV : Pass<"convert-linalg-to-spirv", "ModuleOp"> { let summary = "Convert Linalg ops to SPIR-V ops"; let constructor = "mlir::createLinalgToSPIRVPass()"; } @@ -163,7 +164,7 @@ // LoopsToGPU //===----------------------------------------------------------------------===// -def ConvertSimpleLoopsToGPU : Pass<"convert-loops-to-gpu"> { +def ConvertSimpleLoopsToGPU : FunctionPass<"convert-loops-to-gpu"> { let summary = "Convert top-level loops to GPU kernels"; let constructor = "mlir::createSimpleLoopsToGPUPass()"; let options = [ @@ -174,7 +175,7 @@ ]; } -def ConvertLoopsToGPU : Pass<"convert-loop-op-to-gpu"> { +def ConvertLoopsToGPU : FunctionPass<"convert-loop-op-to-gpu"> { let summary = "Convert top-level loop::ForOp to GPU kernels"; let constructor = "mlir::createLoopToGPUPass()"; let options = [ @@ -196,7 +197,7 @@ // StandardToLLVM //===----------------------------------------------------------------------===// -def ConvertStandardToLLVM : Pass<"convert-std-to-llvm"> { +def ConvertStandardToLLVM : Pass<"convert-std-to-llvm", "ModuleOp"> { let summary = "Convert scalar and vector operations from the Standard to the " "LLVM dialect"; let description = [{ @@ -235,7 +236,7 @@ "Emit wrappers for C-compatible pointer-to-struct memref " "descriptors">, Option<"indexBitwidth", "index-bitwidth", "unsigned", - /*default=*/"kDeriveIndexBitwidthFromDataLayout", + /*default=kDeriveIndexBitwidthFromDataLayout*/"0", "Bitwidth of the index type, 0 to use size of machine word">, ]; } @@ -249,7 +250,7 @@ let constructor = "mlir::createLegalizeStdOpsForSPIRVLoweringPass()"; } -def ConvertStandardToSPIRV : Pass<"convert-std-to-spirv"> { +def ConvertStandardToSPIRV : Pass<"convert-std-to-spirv", "ModuleOp"> { let summary = "Convert Standard Ops to SPIR-V dialect"; let constructor = "mlir::createConvertStandardToSPIRVPass()"; } @@ -258,7 +259,7 @@ // VectorToLLVM //===----------------------------------------------------------------------===// -def ConvertVectorToLLVM : Pass<"convert-vector-to-llvm"> { +def ConvertVectorToLLVM : Pass<"convert-vector-to-llvm", "ModuleOp"> { let summary = "Lower the operations from the vector dialect into the LLVM " "dialect"; let constructor = "mlir::createConvertVectorToLLVMPass()"; diff --git a/mlir/include/mlir/Dialect/Affine/Passes.td b/mlir/include/mlir/Dialect/Affine/Passes.td --- a/mlir/include/mlir/Dialect/Affine/Passes.td +++ b/mlir/include/mlir/Dialect/Affine/Passes.td @@ -15,32 +15,33 @@ include "mlir/Pass/PassBase.td" -def AffineDataCopyGeneration : Pass<"affine-data-copy-generate"> { +def AffineDataCopyGeneration : FunctionPass<"affine-data-copy-generate"> { let summary = "Generate explicit copying for affine memory operations"; let constructor = "mlir::createAffineDataCopyGenerationPass()"; } -def AffineLoopInvariantCodeMotion : Pass<"affine-loop-invariant-code-motion"> { +def AffineLoopInvariantCodeMotion + : FunctionPass<"affine-loop-invariant-code-motion"> { let summary = "Hoist loop invariant instructions outside of affine loops"; let constructor = "mlir::createAffineLoopInvariantCodeMotionPass()"; } -def AffineLoopTiling : Pass<"affine-loop-tile"> { +def AffineLoopTiling : FunctionPass<"affine-loop-tile"> { let summary = "Tile affine loop nests"; let constructor = "mlir::createLoopTilingPass()"; } -def AffineLoopUnroll : Pass<"affine-loop-unroll"> { +def AffineLoopUnroll : FunctionPass<"affine-loop-unroll"> { let summary = "Unroll affine loops"; let constructor = "mlir::createLoopUnrollPass()"; } -def AffineLoopUnrollAndJam : Pass<"affine-loop-unroll-jam"> { +def AffineLoopUnrollAndJam : FunctionPass<"affine-loop-unroll-jam"> { let summary = "Unroll and jam affine loops"; let constructor = "mlir::createLoopUnrollAndJamPass()"; } -def AffineVectorize : Pass<"affine-super-vectorize"> { +def AffineVectorize : FunctionPass<"affine-super-vectorize"> { let summary = "Vectorize to a target independent n-D vector abstraction"; let constructor = "mlir::createSuperVectorizePass()"; let options = [ @@ -61,7 +62,7 @@ ]; } -def SimplifyAffineStructures : Pass<"simplify-affine-structures"> { +def SimplifyAffineStructures : FunctionPass<"simplify-affine-structures"> { let summary = "Simplify affine expressions in maps/sets and normalize " "memrefs"; let constructor = "mlir::createSimplifyAffineStructuresPass()"; diff --git a/mlir/include/mlir/Dialect/FxpMathOps/Passes.td b/mlir/include/mlir/Dialect/FxpMathOps/Passes.td --- a/mlir/include/mlir/Dialect/FxpMathOps/Passes.td +++ b/mlir/include/mlir/Dialect/FxpMathOps/Passes.td @@ -11,12 +11,13 @@ include "mlir/Pass/PassBase.td" -def FxpMathLowerUniformCasts : Pass<"fxpmath-lower-uniform-casts"> { +def FxpMathLowerUniformCasts : FunctionPass<"fxpmath-lower-uniform-casts"> { let summary = "Lowers uniform-quantized casts"; let constructor = "mlir::fxpmath::createLowerUniformCastsPass()"; } -def FxpMathLowerUniformRealMath : Pass<"fxpmath-lower-uniform-real-math"> { +def FxpMathLowerUniformRealMath + : FunctionPass<"fxpmath-lower-uniform-real-math"> { let summary = "Lowers uniform-quantized real math ops to integer arithmetic"; let constructor = "mlir::fxpmath::createLowerUniformRealMathPass()"; } diff --git a/mlir/include/mlir/Dialect/GPU/Passes.td b/mlir/include/mlir/Dialect/GPU/Passes.td --- a/mlir/include/mlir/Dialect/GPU/Passes.td +++ b/mlir/include/mlir/Dialect/GPU/Passes.td @@ -11,7 +11,7 @@ include "mlir/Pass/PassBase.td" -def GpuKernelOutlining : Pass<"gpu-kernel-outlining"> { +def GpuKernelOutlining : Pass<"gpu-kernel-outlining", "ModuleOp"> { let summary = "Outline gpu.launch bodies to kernel functions"; let constructor = "mlir::createGpuKernelOutliningPass()"; } diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.td b/mlir/include/mlir/Dialect/Linalg/Passes.td --- a/mlir/include/mlir/Dialect/Linalg/Passes.td +++ b/mlir/include/mlir/Dialect/Linalg/Passes.td @@ -11,7 +11,7 @@ include "mlir/Pass/PassBase.td" -def LinalgFusion : Pass<"linalg-fusion"> { +def LinalgFusion : FunctionPass<"linalg-fusion"> { let summary = "Fuse operations in the linalg dialect"; let constructor = "mlir::createLinalgFusionPass()"; } @@ -21,24 +21,25 @@ let constructor = "mlir::createLinalgFusionOfTensorOpsPass()"; } -def LinalgLowerToAffineLoops : Pass<"convert-linalg-to-affine-loops"> { +def LinalgLowerToAffineLoops : FunctionPass<"convert-linalg-to-affine-loops"> { let summary = "Lower the operations from the linalg dialect into affine " "loops"; let constructor = "mlir::createConvertLinalgToAffineLoopsPass()"; } -def LinalgLowerToLoops : Pass<"convert-linalg-to-loops"> { +def LinalgLowerToLoops : FunctionPass<"convert-linalg-to-loops"> { let summary = "Lower the operations from the linalg dialect into loops"; let constructor = "mlir::createConvertLinalgToLoopsPass()"; } -def LinalgLowerToParallelLoops : Pass<"convert-linalg-to-parallel-loops"> { +def LinalgLowerToParallelLoops + : FunctionPass<"convert-linalg-to-parallel-loops"> { let summary = "Lower the operations from the linalg dialect into parallel " "loops"; let constructor = "mlir::createConvertLinalgToParallelLoopsPass()"; } -def LinalgPromotion : Pass<"linalg-promote-subviews"> { +def LinalgPromotion : FunctionPass<"linalg-promote-subviews"> { let summary = "Promote subview ops to local buffers"; let constructor = "mlir::createLinalgPromotionPass()"; let options = [ @@ -47,7 +48,7 @@ ]; } -def LinalgTiling : Pass<"linalg-tile"> { +def LinalgTiling : FunctionPass<"linalg-tile"> { let summary = "Tile operations in the linalg dialect"; let constructor = "mlir::createLinalgTilingPass()"; let options = [ @@ -57,7 +58,8 @@ ]; } -def LinalgTilingToParallelLoops : Pass<"linalg-tile-to-parallel-loops"> { +def LinalgTilingToParallelLoops + : FunctionPass<"linalg-tile-to-parallel-loops"> { let summary = "Tile operations in the linalg dialect to parallel loops"; let constructor = "mlir::createLinalgTilingToParallelLoopsPass()"; let options = [ diff --git a/mlir/include/mlir/Dialect/LoopOps/Passes.td b/mlir/include/mlir/Dialect/LoopOps/Passes.td --- a/mlir/include/mlir/Dialect/LoopOps/Passes.td +++ b/mlir/include/mlir/Dialect/LoopOps/Passes.td @@ -16,12 +16,13 @@ let constructor = "mlir::createParallelLoopFusionPass()"; } -def LoopParallelLoopSpecialization : Pass<"parallel-loop-specialization"> { +def LoopParallelLoopSpecialization + : FunctionPass<"parallel-loop-specialization"> { let summary = "Specialize parallel loops for vectorization"; let constructor = "mlir::createParallelLoopSpecializationPass()"; } -def LoopParallelLoopTiling : Pass<"parallel-loop-tiling"> { +def LoopParallelLoopTiling : FunctionPass<"parallel-loop-tiling"> { let summary = "Tile parallel loops"; let constructor = "mlir::createParallelLoopTilingPass()"; let options = [ diff --git a/mlir/include/mlir/Dialect/Quant/Passes.td b/mlir/include/mlir/Dialect/Quant/Passes.td --- a/mlir/include/mlir/Dialect/Quant/Passes.td +++ b/mlir/include/mlir/Dialect/Quant/Passes.td @@ -11,13 +11,14 @@ include "mlir/Pass/PassBase.td" -def QuantConvertConst : Pass<"quant-convert-const"> { +def QuantConvertConst : FunctionPass<"quant-convert-const"> { let summary = "Converts constants followed by qbarrier to actual quantized " "values"; let constructor = "mlir::quant::createConvertConstPass()"; } -def QuantConvertSimulatedQuant : Pass<"quant-convert-simulated-quantization"> { +def QuantConvertSimulatedQuant + : FunctionPass<"quant-convert-simulated-quantization"> { let summary = "Converts training-time simulated quantization ops to " "corresponding quantize/dequantize casts"; let constructor = "mlir::quant::createConvertSimulatedQuantPass()"; diff --git a/mlir/include/mlir/Dialect/SPIRV/Passes.td b/mlir/include/mlir/Dialect/SPIRV/Passes.td --- a/mlir/include/mlir/Dialect/SPIRV/Passes.td +++ b/mlir/include/mlir/Dialect/SPIRV/Passes.td @@ -11,17 +11,18 @@ include "mlir/Pass/PassBase.td" -def SPIRVCompositeTypeLayout : Pass<"decorate-spirv-composite-type-layout"> { +def SPIRVCompositeTypeLayout + : Pass<"decorate-spirv-composite-type-layout", "ModuleOp"> { let summary = "Decorate SPIR-V composite type with layout info"; let constructor = "mlir::spirv::createDecorateSPIRVCompositeTypeLayoutPass()"; } -def SPIRVLowerABIAttributes : Pass<"spirv-lower-abi-attrs"> { +def SPIRVLowerABIAttributes : Pass<"spirv-lower-abi-attrs", "spirv::ModuleOp"> { let summary = "Decorate SPIR-V composite type with layout info"; let constructor = "mlir::spirv::createLowerABIAttributesPass()"; } -def SPIRVUpdateVCE : Pass<"spirv-update-vce"> { +def SPIRVUpdateVCE : Pass<"spirv-update-vce", "spirv::ModuleOp"> { let summary = "Deduce and attach minimal (version, capabilities, extensions) " "requirements to spv.module ops"; let constructor = "mlir::spirv::createUpdateVersionCapabilityExtensionPass()"; diff --git a/mlir/include/mlir/Pass/PassBase.td b/mlir/include/mlir/Pass/PassBase.td --- a/mlir/include/mlir/Pass/PassBase.td +++ b/mlir/include/mlir/Pass/PassBase.td @@ -62,10 +62,13 @@ // Pass //===----------------------------------------------------------------------===// -class Pass { +class PassBase { // The command line argument of the pass. string argument = passArg; + // The C++ base class for the pass. + string baseClass = base; + // A short 1-line summary of the pass. string summary = ""; @@ -82,4 +85,11 @@ list statistics = []; } +// This class represents an mlir::OperationPass. +class Pass + : PassBase">; + +// This class represents an mlir::FunctionPass. +class FunctionPass : PassBase; + #endif // MLIR_PASS_PASSBASE diff --git a/mlir/include/mlir/Quantizer/Transforms/Passes.td b/mlir/include/mlir/Quantizer/Transforms/Passes.td --- a/mlir/include/mlir/Quantizer/Transforms/Passes.td +++ b/mlir/include/mlir/Quantizer/Transforms/Passes.td @@ -11,18 +11,21 @@ include "mlir/Pass/PassBase.td" -def QuantizerAddDefaultStats : Pass<"quantizer-add-default-stats-test"> { +def QuantizerAddDefaultStats + : FunctionPass<"quantizer-add-default-stats-test"> { let summary = "Add default (dummy) statistics to all ops that can benefit " "from runtime statistics"; let constructor = "mlir::quantizer::createAddDefaultStatsPass()"; } -def QuantizerInferQuantizedTypes : Pass<"quantizer-infer-quantized-types"> { +def QuantizerInferQuantizedTypes + : Pass<"quantizer-infer-quantized-types", "ModuleOp"> { let summary = "Infer quantized types for a module"; let constructor = "mlir::quantizer::createInferQuantizedTypesPass()"; } -def QuantizerRemoveInstrumentation : Pass<"quantizer-remove-instrumentation"> { +def QuantizerRemoveInstrumentation + : FunctionPass<"quantizer-remove-instrumentation"> { let summary = "Remove instrumentation and hints which have no effect on " "final execution"; let constructor = "mlir::quantizer::createRemoveInstrumentationPass()"; diff --git a/mlir/include/mlir/TableGen/Pass.h b/mlir/include/mlir/TableGen/Pass.h --- a/mlir/include/mlir/TableGen/Pass.h +++ b/mlir/include/mlir/TableGen/Pass.h @@ -82,6 +82,9 @@ /// Return the command line argument of the pass. StringRef getArgument() const; + /// Return the name for the C++ base class. + StringRef getBaseClass() const; + /// Return the short 1-line summary of the pass. StringRef getSummary() const; diff --git a/mlir/include/mlir/Transforms/Passes.td b/mlir/include/mlir/Transforms/Passes.td --- a/mlir/include/mlir/Transforms/Passes.td +++ b/mlir/include/mlir/Transforms/Passes.td @@ -15,8 +15,8 @@ include "mlir/Pass/PassBase.td" -def AffinePipelineDataTransfer : Pass< - "affine-pipeline-data-transfer"> { +def AffinePipelineDataTransfer + : FunctionPass<"affine-pipeline-data-transfer"> { let summary = "Pipeline non-blocking data transfers between explicitly " "managed levels of the memory hierarchy"; let description = [{ @@ -84,7 +84,7 @@ let constructor = "mlir::createPipelineDataTransferPass()"; } -def AffineLoopFusion : Pass<"affine-loop-fusion"> { +def AffineLoopFusion : FunctionPass<"affine-loop-fusion"> { let summary = "Fuse affine loop nests"; let constructor = "mlir::createLoopFusionPass()"; } @@ -120,7 +120,7 @@ ]; } -def LoopCoalescing : Pass<"loop-coalescing"> { +def LoopCoalescing : FunctionPass<"loop-coalescing"> { let summary = "Coalesce nested loops with independent bounds into a single " "loop"; let constructor = "mlir::createLoopCoalescingPass()"; @@ -131,7 +131,7 @@ let constructor = "mlir::createLoopInvariantCodeMotionPass()"; } -def MemRefDataFlowOpt : Pass<"memref-dataflow-opt"> { +def MemRefDataFlowOpt : FunctionPass<"memref-dataflow-opt"> { let summary = "Perform store/load forwarding for memrefs"; let description = [{ This pass performs store to load forwarding for memref's to eliminate memory @@ -192,17 +192,17 @@ ]; } -def PrintCFG : Pass<"print-cfg-graph"> { +def PrintCFG : FunctionPass<"print-cfg-graph"> { let summary = "Print CFG graph per-Region"; let constructor = "mlir::createPrintCFGGraphPass()"; } -def PrintOpStats : Pass<"print-op-stats"> { +def PrintOpStats : Pass<"print-op-stats", "ModuleOp"> { let summary = "Print statistics of operations"; let constructor = "mlir::createPrintOpStatsPass()"; } -def PrintOp : Pass<"print-op-graph"> { +def PrintOp : Pass<"print-op-graph", "ModuleOp"> { let summary = "Print op graph per-Region"; let constructor = "mlir::createPrintOpGraphPass()"; } 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 @@ -8,6 +8,7 @@ #include "mlir/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.h" +#include "../PassDetail.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h" @@ -164,11 +165,7 @@ namespace { struct ConvertAVX512ToLLVMPass - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_ConvertAVX512ToLLVM -#include "mlir/Conversion/Passes.h.inc" - + : public ConvertAVX512ToLLVMBase { void runOnOperation() override; }; } // namespace 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 @@ -13,6 +13,7 @@ #include "mlir/Conversion/AffineToStandard/AffineToStandard.h" +#include "../PassDetail.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" @@ -577,11 +578,7 @@ } namespace { -class LowerAffinePass : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_ConvertAffineToStandard -#include "mlir/Conversion/Passes.h.inc" - +class LowerAffinePass : public ConvertAffineToStandardBase { void runOnFunction() override { OwningRewritePatternList patterns; populateAffineToStdConversionPatterns(patterns, &getContext()); 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 @@ -15,6 +15,7 @@ #include "mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h" +#include "../PassDetail.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/IR/Attributes.h" @@ -22,7 +23,6 @@ #include "mlir/IR/Function.h" #include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" -#include "mlir/Pass/Pass.h" #include "llvm/ADT/STLExtras.h" #include "llvm/IR/DataLayout.h" @@ -61,13 +61,8 @@ /// /// Intermediate data structures are allocated on the stack. class GpuLaunchFuncToCudaCallsPass - : public PassWrapper> { + : public ConvertGpuLaunchFuncToCudaCallsBase { private: -/// Include the generated pass utilities. -#define GEN_PASS_ConvertGpuLaunchFuncToCudaCalls -#include "mlir/Conversion/Passes.h.inc" - LLVM::LLVMDialect *getLLVMDialect() { return llvmDialect; } llvm::LLVMContext &getLLVMContext() { 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 @@ -18,12 +18,12 @@ #include "mlir/Dialect/GPU/Passes.h" #include "mlir/Dialect/LLVMIR/NVVMDialect.h" #include "mlir/IR/BlockAndValueMapping.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" #include "llvm/Support/FormatVariadic.h" #include "../GPUCommon/IndexIntrinsicsOpLowering.h" #include "../GPUCommon/OpToFuncCallLowering.h" +#include "../PassDetail.h" using namespace mlir; @@ -246,13 +246,8 @@ /// This pass only handles device code and is not meant to be run on GPU host /// code. class LowerGpuOpsToNVVMOpsPass - : public PassWrapper> { + : public ConvertGpuOpsToNVVMOpsBase { public: -/// Include the generated pass utilities. -#define GEN_PASS_ConvertGpuOpsToNVVMOps -#include "mlir/Conversion/Passes.h.inc" - void runOnOperation() override { gpu::GPUModuleOp m = getOperation(); 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 @@ -21,6 +21,7 @@ #include "../GPUCommon/IndexIntrinsicsOpLowering.h" #include "../GPUCommon/OpToFuncCallLowering.h" +#include "../PassDetail.h" using namespace mlir; @@ -32,13 +33,8 @@ // This pass only handles device code and is not meant to be run on GPU host // code. class LowerGpuOpsToROCDLOpsPass - : public PassWrapper> { + : public ConvertGpuOpsToROCDLOpsBase { public: -/// Include the generated pass utilities. -#define GEN_PASS_ConvertGpuOpsToROCDLOps -#include "mlir/Conversion/Passes.h.inc" - void runOnOperation() override { gpu::GPUModuleOp m = getOperation(); 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 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h" +#include "../PassDetail.h" #include "mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h" #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h" #include "mlir/Dialect/GPU/GPUDialect.h" @@ -19,7 +20,6 @@ #include "mlir/Dialect/SPIRV/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/SPIRVLowering.h" #include "mlir/Dialect/SPIRV/SPIRVOps.h" -#include "mlir/Pass/Pass.h" using namespace mlir; @@ -33,12 +33,7 @@ /// replace it). /// /// 2) Lower the body of the spirv::ModuleOp. -struct GPUToSPIRVPass - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_ConvertGpuToSPIRV -#include "mlir/Conversion/Passes.h.inc" - +struct GPUToSPIRVPass : public ConvertGPUToSPIRVBase { void runOnOperation() override; }; } // namespace 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 @@ -13,6 +13,7 @@ // //===----------------------------------------------------------------------===// +#include "../PassDetail.h" #include "mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/SPIRV/SPIRVOps.h" @@ -23,7 +24,6 @@ #include "mlir/IR/Function.h" #include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" -#include "mlir/Pass/Pass.h" using namespace mlir; @@ -38,13 +38,9 @@ /// function and attaching binary data and entry point name as an attributes to /// created vulkan launch call op. class ConvertGpuLaunchFuncToVulkanLaunchFunc - : public PassWrapper> { + : public ConvertGpuLaunchFuncToVulkanLaunchFuncBase< + ConvertGpuLaunchFuncToVulkanLaunchFunc> { public: -/// Include the generated pass utilities. -#define GEN_PASS_ConvertGpuLaunchFuncToVulkanLaunchFunc -#include "mlir/Conversion/Passes.h.inc" - void runOnOperation() override; private: 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 @@ -14,6 +14,7 @@ // //===----------------------------------------------------------------------===// +#include "../PassDetail.h" #include "mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" @@ -21,7 +22,6 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/Function.h" #include "mlir/IR/Module.h" -#include "mlir/Pass/Pass.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/FormatVariadic.h" @@ -57,13 +57,9 @@ /// * deinitVulkan -- deinitializes vulkan runtime /// class VulkanLaunchFuncToVulkanCallsPass - : public PassWrapper> { + : public ConvertVulkanLaunchFuncToVulkanCallsBase< + VulkanLaunchFuncToVulkanCallsPass> { private: -/// Include the generated pass utilities. -#define GEN_PASS_ConvertVulkanLaunchFuncToVulkanCalls -#include "mlir/Conversion/Passes.h.inc" - LLVM::LLVMDialect *getLLVMDialect() { return llvmDialect; } llvm::LLVMContext &getLLVMContext() { 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 @@ -8,6 +8,7 @@ #include "mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h" +#include "../PassDetail.h" #include "mlir/Conversion/AffineToStandard/AffineToStandard.h" #include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" @@ -28,8 +29,6 @@ #include "mlir/IR/PatternMatch.h" #include "mlir/IR/StandardTypes.h" #include "mlir/IR/Types.h" -#include "mlir/Pass/Pass.h" -#include "mlir/Pass/PassManager.h" #include "mlir/Support/LogicalResult.h" #include "mlir/Transforms/DialectConversion.h" #include "mlir/Transforms/Passes.h" @@ -557,11 +556,7 @@ namespace { struct ConvertLinalgToLLVMPass - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_ConvertLinalgToLLVM -#include "mlir/Conversion/Passes.h.inc" - + : public ConvertLinalgToLLVMBase { void runOnOperation() override; }; } // namespace 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 @@ -7,21 +7,16 @@ //===----------------------------------------------------------------------===// #include "mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h" +#include "../PassDetail.h" #include "mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h" #include "mlir/Dialect/SPIRV/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/SPIRVLowering.h" -#include "mlir/Pass/Pass.h" using namespace mlir; namespace { /// A pass converting MLIR Linalg ops into SPIR-V ops. -class LinalgToSPIRVPass - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_ConvertLinalgToSPIRV -#include "mlir/Conversion/Passes.h.inc" - +class LinalgToSPIRVPass : public ConvertLinalgToSPIRVBase { void runOnOperation() override; }; } // namespace 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 @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "../PassDetail.h" #include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" @@ -19,7 +20,6 @@ #include "mlir/IR/MLIRContext.h" #include "mlir/IR/Module.h" #include "mlir/IR/PatternMatch.h" -#include "mlir/Pass/Pass.h" #include "mlir/Support/Functional.h" #include "mlir/Transforms/DialectConversion.h" #include "mlir/Transforms/Passes.h" @@ -31,11 +31,7 @@ namespace { struct LoopToStandardPass - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_ConvertLoopToStandard -#include "mlir/Conversion/Passes.h.inc" - + : public ConvertLoopToStandardBase { void runOnOperation() override; }; 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 @@ -7,12 +7,12 @@ //===----------------------------------------------------------------------===// #include "mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h" +#include "../PassDetail.h" #include "mlir/Conversion/LoopsToGPU/LoopsToGPU.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" #include "llvm/ADT/ArrayRef.h" @@ -28,13 +28,8 @@ // 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 PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_ConvertSimpleLoopsToGPU -#include "mlir/Conversion/Passes.h.inc" - +struct ForLoopMapper : public ConvertSimpleLoopsToGPUBase { ForLoopMapper() = default; - ForLoopMapper(const ForLoopMapper &) {} ForLoopMapper(unsigned numBlockDims, unsigned numThreadDims) { this->numBlockDims = numBlockDims; this->numThreadDims = numThreadDims; @@ -62,13 +57,8 @@ // 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 PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_ConvertLoopsToGPU -#include "mlir/Conversion/Passes.h.inc" - + : public ConvertLoopsToGPUBase { ImperfectlyNestedForLoopMapper() = default; - ImperfectlyNestedForLoopMapper(const ImperfectlyNestedForLoopMapper &) {} ImperfectlyNestedForLoopMapper(ArrayRef numWorkGroups, ArrayRef workGroupSize) { this->numWorkGroups->assign(numWorkGroups.begin(), numWorkGroups.end()); @@ -105,11 +95,7 @@ }; struct ParallelLoopToGpuPass - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_ConvertParallelLoopToGpu -#include "mlir/Conversion/Passes.h.inc" - + : public ConvertParallelLoopToGpuBase { void runOnOperation() override { OwningRewritePatternList patterns; populateParallelLoopToGPUPatterns(patterns, &getContext()); diff --git a/mlir/lib/Conversion/PassDetail.h b/mlir/lib/Conversion/PassDetail.h new file mode 100644 --- /dev/null +++ b/mlir/lib/Conversion/PassDetail.h @@ -0,0 +1,25 @@ +//===- PassDetail.h - Conversion Pass class details -------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef CONVERSION_PASSDETAIL_H_ +#define CONVERSION_PASSDETAIL_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { + +namespace gpu { +class GPUModuleOp; +} // end namespace gpu + +#define GEN_PASS_CLASSES +#include "mlir/Conversion/Passes.h.inc" + +} // end namespace mlir + +#endif // CONVERSION_PASSDETAIL_H_ 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 @@ -11,8 +11,9 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" +#include "../PassDetail.h" #include "mlir/ADT/TypeSwitch.h" +#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" @@ -22,7 +23,6 @@ #include "mlir/IR/Module.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/TypeUtilities.h" -#include "mlir/Pass/Pass.h" #include "mlir/Support/Functional.h" #include "mlir/Support/LogicalResult.h" #include "mlir/Transforms/DialectConversion.h" @@ -2776,13 +2776,8 @@ namespace { /// A pass converting MLIR operations into the LLVM IR dialect. -struct LLVMLoweringPass - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_ConvertStandardToLLVM -#include "mlir/Conversion/Passes.h.inc" - - /// Creates an LLVM lowering pass. +struct LLVMLoweringPass : public ConvertStandardToLLVMBase { + LLVMLoweringPass() = default; LLVMLoweringPass(bool useAlloca, bool useBarePtrCallConv, bool emitCWrappers, unsigned indexBitwidth) { this->useAlloca = useAlloca; @@ -2790,8 +2785,6 @@ this->emitCWrappers = emitCWrappers; this->indexBitwidth = indexBitwidth; } - explicit LLVMLoweringPass() {} - LLVMLoweringPass(const LLVMLoweringPass &pass) {} /// Run the dialect converter on the module. void runOnOperation() override { 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 @@ -12,21 +12,17 @@ //===----------------------------------------------------------------------===// #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h" +#include "../PassDetail.h" #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h" #include "mlir/Dialect/SPIRV/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/SPIRVLowering.h" -#include "mlir/Pass/Pass.h" using namespace mlir; namespace { /// A pass converting MLIR Standard operations into the SPIR-V dialect. class ConvertStandardToSPIRVPass - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_ConvertStandardToSPIRV -#include "mlir/Conversion/Passes.h.inc" - + : public ConvertStandardToSPIRVBase { void runOnOperation() override; }; } // namespace 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 @@ -11,12 +11,12 @@ // //===----------------------------------------------------------------------===// +#include "../PassDetail.h" #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h" #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/StandardTypes.h" -#include "mlir/Pass/Pass.h" using namespace mlir; @@ -161,11 +161,7 @@ namespace { struct SPIRVLegalization final - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_LegalizeStandardForSPIRV -#include "mlir/Conversion/Passes.h.inc" - + : public LegalizeStandardForSPIRVBase { void runOnOperation() override; }; } // namespace 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 @@ -8,6 +8,7 @@ #include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h" +#include "../PassDetail.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" @@ -21,8 +22,6 @@ #include "mlir/IR/PatternMatch.h" #include "mlir/IR/StandardTypes.h" #include "mlir/IR/Types.h" -#include "mlir/Pass/Pass.h" -#include "mlir/Pass/PassManager.h" #include "mlir/Transforms/DialectConversion.h" #include "mlir/Transforms/Passes.h" #include "llvm/IR/DerivedTypes.h" @@ -1119,11 +1118,7 @@ namespace { struct LowerVectorToLLVMPass - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_ConvertVectorToLLVM -#include "mlir/Conversion/Passes.h.inc" - + : public ConvertVectorToLLVMBase { void runOnOperation() override; }; } // namespace 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 @@ -19,11 +19,11 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Analysis/Utils.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Affine/Passes.h" -#include "mlir/Pass/Pass.h" +#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Transforms/LoopUtils.h" #include "llvm/ADT/MapVector.h" #include "llvm/Support/CommandLine.h" @@ -74,11 +74,7 @@ // TODO(bondhugula): We currently can't generate copies correctly when stores // are strided. Check for strided stores. struct AffineDataCopyGeneration - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_AffineDataCopyGeneration -#include "mlir/Dialect/Affine/Passes.h.inc" - + : public AffineDataCopyGenerationBase { explicit AffineDataCopyGeneration( unsigned slowMemorySpace = 0, unsigned fastMemorySpace = clFastMemorySpace, unsigned tagMemorySpace = 0, diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp --- a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Analysis/AffineAnalysis.h" #include "mlir/Analysis/AffineStructures.h" #include "mlir/Analysis/LoopAnalysis.h" @@ -20,7 +21,6 @@ #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/Builders.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/LoopUtils.h" #include "mlir/Transforms/Utils.h" #include "llvm/ADT/DenseMap.h" @@ -42,11 +42,7 @@ /// TODO: This code should be removed once the new LICM pass can handle its /// uses. struct LoopInvariantCodeMotion - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_AffineLoopInvariantCodeMotion -#include "mlir/Dialect/Affine/Passes.h.inc" - + : public AffineLoopInvariantCodeMotionBase { void runOnFunction() override; void runOnAffineForOp(AffineForOp forOp); }; 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 @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Analysis/AffineAnalysis.h" #include "mlir/Analysis/AffineStructures.h" #include "mlir/Analysis/LoopAnalysis.h" @@ -19,7 +20,6 @@ #include "mlir/Dialect/Affine/Passes.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/LoopUtils.h" #include "mlir/Transforms/Utils.h" #include "llvm/Support/CommandLine.h" @@ -58,11 +58,7 @@ namespace { /// A pass to perform loop tiling on all suitable loop nests of a Function. -struct LoopTiling : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_AffineLoopTiling -#include "mlir/Dialect/Affine/Passes.h.inc" - +struct LoopTiling : public AffineLoopTilingBase { explicit LoopTiling(uint64_t cacheSizeBytes = kDefaultCacheMemCapacity, bool avoidMaxMinBounds = true) : cacheSizeBytes(cacheSizeBytes), avoidMaxMinBounds(avoidMaxMinBounds) {} 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 @@ -10,13 +10,13 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Analysis/LoopAnalysis.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/Passes.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/Builders.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/LoopUtils.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/CommandLine.h" @@ -58,11 +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 PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_AffineUnroll -#include "mlir/Dialect/Affine/Passes.h.inc" - +struct LoopUnroll : public AffineLoopUnrollBase { const Optional unrollFactor; const Optional unrollFull; // Callback to obtain unroll factors; if this has a callable target, takes 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 @@ -32,6 +32,8 @@ // Note: 'if/else' blocks are not jammed. So, if there are loops inside if // op's, bodies of those loops will not be jammed. //===----------------------------------------------------------------------===// + +#include "PassDetail.h" #include "mlir/Analysis/LoopAnalysis.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/Passes.h" @@ -39,7 +41,6 @@ #include "mlir/IR/AffineMap.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/LoopUtils.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/CommandLine.h" @@ -60,11 +61,7 @@ namespace { /// Loop unroll jam pass. Currently, this just unroll jams the first /// outer loop in a Function. -struct LoopUnrollAndJam : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_AffineLoopUnrollAndJam -#include "mlir/Dialect/Affine/Passes.h.inc" - +struct LoopUnrollAndJam : public AffineLoopUnrollAndJamBase { Optional unrollJamFactor; static const unsigned kDefaultUnrollJamFactor = 4; diff --git a/mlir/lib/Dialect/Affine/Transforms/PassDetail.h b/mlir/lib/Dialect/Affine/Transforms/PassDetail.h new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/Affine/Transforms/PassDetail.h @@ -0,0 +1,21 @@ +//===- PassDetail.h - Affine Pass class details -----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef DIALECT_AFFINE_TRANSFORMS_PASSDETAIL_H_ +#define DIALECT_AFFINE_TRANSFORMS_PASSDETAIL_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { + +#define GEN_PASS_CLASSES +#include "mlir/Dialect/Affine/Passes.h.inc" + +} // end namespace mlir + +#endif // DIALECT_AFFINE_TRANSFORMS_PASSDETAIL_H_ 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 @@ -10,10 +10,10 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Analysis/Utils.h" #include "mlir/Dialect/Affine/Passes.h" #include "mlir/IR/IntegerSet.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/Utils.h" #define DEBUG_TYPE "simplify-affine-structure" @@ -27,11 +27,7 @@ /// all memrefs with non-trivial layout maps are converted to ones with trivial /// identity layout ones. struct SimplifyAffineStructures - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_SimplifyAffineStructures -#include "mlir/Dialect/Affine/Passes.h.inc" - + : public SimplifyAffineStructuresBase { void runOnFunction() override; /// Utility to simplify an affine attribute and update its entry in the parent 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 @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Analysis/LoopAnalysis.h" #include "mlir/Analysis/NestedMatcher.h" #include "mlir/Analysis/SliceAnalysis.h" @@ -24,7 +25,6 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/Location.h" #include "mlir/IR/Types.h" -#include "mlir/Pass/Pass.h" #include "mlir/Support/Functional.h" #include "mlir/Support/LLVM.h" #include "mlir/Transforms/FoldUtils.h" @@ -573,13 +573,8 @@ /// Base state for the vectorize pass. /// Command line arguments are preempted by non-empty pass arguments. -struct Vectorize : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_AffineVectorize -#include "mlir/Dialect/Affine/Passes.h.inc" - +struct Vectorize : public AffineVectorizeBase { Vectorize() = default; - Vectorize(const Vectorize &) {} Vectorize(ArrayRef virtualVectorSize); void runOnFunction() override; }; 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 @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "UniformKernelUtils.h" #include "mlir/Dialect/FxpMathOps/FxpMathOps.h" @@ -22,20 +23,12 @@ namespace { struct LowerUniformRealMathPass - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_FxpMathLowerUniformRealMath -#include "mlir/Dialect/FxpMathOps/Passes.h.inc" - + : public FxpMathLowerUniformRealMathBase { void runOnFunction() override; }; struct LowerUniformCastsPass - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_FxpMathLowerUniformCasts -#include "mlir/Dialect/FxpMathOps/Passes.h.inc" - + : public FxpMathLowerUniformCastsBase { void runOnFunction() override; }; diff --git a/mlir/lib/Dialect/FxpMathOps/Transforms/PassDetail.h b/mlir/lib/Dialect/FxpMathOps/Transforms/PassDetail.h new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/FxpMathOps/Transforms/PassDetail.h @@ -0,0 +1,21 @@ +//===- PassDetail.h - FxpMath Pass class details ----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef DIALECT_FXPMATHOPS_TRANSFORMS_PASSDETAIL_H_ +#define DIALECT_FXPMATHOPS_TRANSFORMS_PASSDETAIL_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { + +#define GEN_PASS_CLASSES +#include "mlir/Dialect/FxpMathOps/Passes.h.inc" + +} // end namespace mlir + +#endif // DIALECT_FXPMATHOPS_TRANSFORMS_PASSDETAIL_H_ 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 @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/GPU/Passes.h" #include "mlir/Dialect/GPU/Utils.h" @@ -17,7 +18,6 @@ #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" #include "mlir/IR/SymbolTable.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/RegionUtils.h" using namespace mlir; @@ -215,12 +215,8 @@ /// a separate pass. The external functions can then be annotated with the /// symbol of the cubin accessor function. class GpuKernelOutliningPass - : public PassWrapper> { + : public GpuKernelOutliningBase { public: -/// Include the generated pass utilities. -#define GEN_PASS_GpuKernelOutlining -#include "mlir/Dialect/GPU/Passes.h.inc" - void runOnOperation() override { SymbolTable symbolTable(getOperation()); bool modified = false; diff --git a/mlir/lib/Dialect/GPU/Transforms/PassDetail.h b/mlir/lib/Dialect/GPU/Transforms/PassDetail.h new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/GPU/Transforms/PassDetail.h @@ -0,0 +1,21 @@ +//===- PassDetail.h - GPU Pass class details --------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef DIALECT_GPU_TRANSFORMS_PASSDETAIL_H_ +#define DIALECT_GPU_TRANSFORMS_PASSDETAIL_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { + +#define GEN_PASS_CLASSES +#include "mlir/Dialect/GPU/Passes.h.inc" + +} // end namespace mlir + +#endif // DIALECT_GPU_TRANSFORMS_PASSDETAIL_H_ 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 @@ -7,11 +7,11 @@ //===----------------------------------------------------------------------===// #include "mlir/Dialect/LLVMIR/Transforms/LegalizeForExport.h" +#include "PassDetail.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/IR/Block.h" #include "mlir/IR/Builders.h" #include "mlir/IR/Module.h" -#include "mlir/Pass/Pass.h" using namespace mlir; @@ -58,11 +58,7 @@ namespace { struct LegalizeForExportPass - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_LLVMLegalizeForExport -#include "mlir/Dialect/LLVMIR/Transforms/Passes.h.inc" - + : public LLVMLegalizeForExportBase { void runOnOperation() override { LLVM::ensureDistinctSuccessors(getOperation()); } diff --git a/mlir/lib/Dialect/LLVMIR/Transforms/PassDetail.h b/mlir/lib/Dialect/LLVMIR/Transforms/PassDetail.h new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/LLVMIR/Transforms/PassDetail.h @@ -0,0 +1,21 @@ +//===- PassDetail.h - LLVM Pass class details -------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef DIALECT_LLVMIR_TRANSFORMS_PASSDETAIL_H_ +#define DIALECT_LLVMIR_TRANSFORMS_PASSDETAIL_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { + +#define GEN_PASS_CLASSES +#include "mlir/Dialect/LLVMIR/Transforms/Passes.h.inc" + +} // end namespace mlir + +#endif // DIALECT_LLVMIR_TRANSFORMS_PASSDETAIL_H_ 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 @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Analysis/Dominance.h" #include "mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h" #include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" @@ -20,9 +21,7 @@ #include "mlir/Dialect/StandardOps/EDSC/Intrinsics.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" -#include "mlir/IR/OpImplementation.h" #include "mlir/IR/PatternMatch.h" -#include "mlir/Pass/Pass.h" #include "mlir/Support/LLVM.h" #include "mlir/Support/STLExtras.h" #include "mlir/Transforms/FoldUtils.h" @@ -568,11 +567,7 @@ /// Pass that fuses generic ops on tensors. Used only for testing. struct FusionOfTensorOpsPass - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_LinalgFusionOfTensorOps -#include "mlir/Dialect/Linalg/Passes.h.inc" - + : public LinalgFusionOfTensorOpsBase { void runOnOperation() override { OwningRewritePatternList patterns; Operation *op = getOperation(); @@ -581,11 +576,7 @@ }; }; -struct LinalgFusionPass : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_LinalgFusion -#include "mlir/Dialect/Linalg/Passes.h.inc" - +struct LinalgFusionPass : public LinalgFusionBase { void runOnFunction() override { fuseLinalgOpsGreedily(getFunction()); } }; } // namespace 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 @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/Affine/EDSC/Intrinsics.h" #include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" @@ -18,8 +19,6 @@ #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/BlockAndValueMapping.h" -#include "mlir/IR/OpImplementation.h" -#include "mlir/Pass/Pass.h" #include "mlir/Support/Functional.h" #include "mlir/Support/LLVM.h" #include "mlir/Support/STLExtras.h" @@ -694,32 +693,20 @@ namespace { struct LowerToAffineLoops - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_LinalgLowerToAffineLoops -#include "mlir/Dialect/Linalg/Passes.h.inc" - + : public LinalgLowerToAffineLoopsBase { void runOnFunction() override { lowerLinalgToLoopsImpl(getFunction(), &getContext()); } }; -struct LowerToLoops : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_LinalgLowerToLoops -#include "mlir/Dialect/Linalg/Passes.h.inc" - +struct LowerToLoops : public LinalgLowerToLoopsBase { void runOnFunction() override { lowerLinalgToLoopsImpl(getFunction(), &getContext()); } }; struct LowerToParallelLoops - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_LinalgLowerToParallelLoops -#include "mlir/Dialect/Linalg/Passes.h.inc" - + : public LinalgLowerToParallelLoopsBase { void runOnFunction() override { lowerLinalgToLoopsImpl(getFunction(), &getContext()); diff --git a/mlir/lib/Dialect/Linalg/Transforms/PassDetail.h b/mlir/lib/Dialect/Linalg/Transforms/PassDetail.h new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/Linalg/Transforms/PassDetail.h @@ -0,0 +1,21 @@ +//===- PassDetail.h - Linalg Pass class details -----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef DIALECT_LINALG_TRANSFORMS_PASSDETAIL_H_ +#define DIALECT_LINALG_TRANSFORMS_PASSDETAIL_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { + +#define GEN_PASS_CLASSES +#include "mlir/Dialect/Linalg/Passes.h.inc" + +} // end namespace mlir + +#endif // DIALECT_LINALG_TRANSFORMS_PASSDETAIL_H_ 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 @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/Affine/EDSC/Intrinsics.h" #include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" @@ -21,8 +22,6 @@ #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineExprVisitor.h" #include "mlir/IR/AffineMap.h" -#include "mlir/IR/OpImplementation.h" -#include "mlir/Pass/Pass.h" #include "mlir/Support/LLVM.h" #include "mlir/Support/STLExtras.h" #include "mlir/Transforms/FoldUtils.h" @@ -230,14 +229,8 @@ } namespace { -struct LinalgPromotionPass - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_LinalgPromotion -#include "mlir/Dialect/Linalg/Passes.h.inc" - +struct LinalgPromotionPass : public LinalgPromotionBase { LinalgPromotionPass() = default; - LinalgPromotionPass(const LinalgPromotionPass &) {} LinalgPromotionPass(bool dynamicBuffers) { this->dynamicBuffers = dynamicBuffers; } 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 @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/Affine/EDSC/Intrinsics.h" #include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" #include "mlir/Dialect/Linalg/IR/LinalgTypes.h" @@ -20,8 +21,6 @@ #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineExprVisitor.h" #include "mlir/IR/AffineMap.h" -#include "mlir/IR/OpImplementation.h" -#include "mlir/Pass/Pass.h" #include "mlir/Support/Functional.h" #include "mlir/Support/LLVM.h" #include "mlir/Support/STLExtras.h" @@ -507,13 +506,8 @@ } namespace { -struct LinalgTilingPass : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_LinalgTiling -#include "mlir/Dialect/Linalg/Passes.h.inc" - +struct LinalgTilingPass : public LinalgTilingBase { LinalgTilingPass() = default; - LinalgTilingPass(const LinalgTilingPass &) {} LinalgTilingPass(ArrayRef sizes) { tileSizes->assign(sizes.begin(), sizes.end()); } @@ -524,13 +518,8 @@ }; struct LinalgTilingToParallelLoopsPass - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_LinalgTilingToParallelLoops -#include "mlir/Dialect/Linalg/Passes.h.inc" - + : public LinalgTilingToParallelLoopsBase { LinalgTilingToParallelLoopsPass() = default; - LinalgTilingToParallelLoopsPass(const LinalgTilingToParallelLoopsPass &) {} LinalgTilingToParallelLoopsPass(ArrayRef sizes) { tileSizes->assign(sizes.begin(), sizes.end()); } 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 @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/LoopOps/Passes.h" #include "mlir/Dialect/LoopOps/Transforms.h" @@ -17,8 +18,6 @@ #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" #include "mlir/IR/OpDefinition.h" -#include "mlir/Pass/Pass.h" -#include "mlir/Transforms/Passes.h" using namespace mlir; using namespace mlir::loop; @@ -161,11 +160,7 @@ namespace { struct ParallelLoopFusion - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_LoopParallelLoopFusion -#include "mlir/Dialect/LoopOps/Passes.h.inc" - + : public LoopParallelLoopFusionBase { void runOnOperation() override { for (Region ®ion : getOperation()->getRegions()) naivelyFuseParallelOps(region); 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 @@ -10,13 +10,13 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/LoopOps/Passes.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/BlockAndValueMapping.h" -#include "mlir/Pass/Pass.h" using namespace mlir; using loop::ParallelOp; @@ -60,11 +60,7 @@ namespace { struct ParallelLoopSpecialization - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_LoopParallelLoopSpecialization -#include "mlir/Dialect/LoopOps/Passes.h.inc" - + : public LoopParallelLoopSpecializationBase { void runOnFunction() override { getFunction().walk([](ParallelOp op) { specializeLoopForUnrolling(op); }); } 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 @@ -10,12 +10,12 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/LoopOps/Passes.h" #include "mlir/Dialect/LoopOps/Transforms.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/RegionUtils.h" #include "llvm/Support/CommandLine.h" @@ -102,13 +102,8 @@ namespace { struct ParallelLoopTiling - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_LoopParallelLoopTiling -#include "mlir/Dialect/LoopOps/Passes.h.inc" - + : public LoopParallelLoopTilingBase { ParallelLoopTiling() = default; - ParallelLoopTiling(const ParallelLoopTiling &) {} explicit ParallelLoopTiling(ArrayRef tileSizes) { this->tileSizes = tileSizes; } diff --git a/mlir/lib/Dialect/LoopOps/Transforms/PassDetail.h b/mlir/lib/Dialect/LoopOps/Transforms/PassDetail.h new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/LoopOps/Transforms/PassDetail.h @@ -0,0 +1,21 @@ +//===- PassDetail.h - Loop Pass class details -------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef DIALECT_LOOPOPS_TRANSFORMS_PASSDETAIL_H_ +#define DIALECT_LOOPOPS_TRANSFORMS_PASSDETAIL_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { + +#define GEN_PASS_CLASSES +#include "mlir/Dialect/LoopOps/Passes.h.inc" + +} // end namespace mlir + +#endif // DIALECT_LOOPOPS_TRANSFORMS_PASSDETAIL_H_ 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 @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/Quant/Passes.h" #include "mlir/Dialect/Quant/QuantOps.h" #include "mlir/Dialect/Quant/QuantizeUtils.h" @@ -15,17 +16,12 @@ #include "mlir/IR/Matchers.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/StandardTypes.h" -#include "mlir/Pass/Pass.h" using namespace mlir; using namespace mlir::quant; namespace { -struct ConvertConstPass : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_QuantConvertConst -#include "mlir/Dialect/Quant/Passes.h.inc" - +struct ConvertConstPass : public QuantConvertConstBase { void runOnFunction() override; }; 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 @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/Quant/FakeQuantSupport.h" #include "mlir/Dialect/Quant/Passes.h" #include "mlir/Dialect/Quant/QuantOps.h" @@ -13,18 +14,13 @@ #include "mlir/IR/Attributes.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/StandardTypes.h" -#include "mlir/Pass/Pass.h" using namespace mlir; using namespace mlir::quant; namespace { struct ConvertSimulatedQuantPass - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_QuantConvertSimulatedQuant -#include "mlir/Dialect/Quant/Passes.h.inc" - + : public QuantConvertSimulatedQuantBase { void runOnFunction() override; }; diff --git a/mlir/lib/Dialect/Quant/Transforms/PassDetail.h b/mlir/lib/Dialect/Quant/Transforms/PassDetail.h new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/Quant/Transforms/PassDetail.h @@ -0,0 +1,21 @@ +//===- PassDetail.h - Quant Pass class details ------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef DIALECT_QUANT_TRANSFORMS_PASSDETAIL_H_ +#define DIALECT_QUANT_TRANSFORMS_PASSDETAIL_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { + +#define GEN_PASS_CLASSES +#include "mlir/Dialect/Quant/Passes.h.inc" + +} // end namespace mlir + +#endif // DIALECT_QUANT_TRANSFORMS_PASSDETAIL_H_ 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 @@ -13,6 +13,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/SPIRV/LayoutUtils.h" #include "mlir/Dialect/SPIRV/Passes.h" #include "mlir/Dialect/SPIRV/SPIRVDialect.h" @@ -80,9 +81,8 @@ namespace { class DecorateSPIRVCompositeTypeLayoutPass - : public PassWrapper> { -private: + : public SPIRVCompositeTypeLayoutBase< + DecorateSPIRVCompositeTypeLayoutPass> { void runOnOperation() override; }; } // namespace 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 @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/SPIRV/LayoutUtils.h" #include "mlir/Dialect/SPIRV/Passes.h" #include "mlir/Dialect/SPIRV/SPIRVDialect.h" @@ -148,9 +149,7 @@ /// Pass to implement the ABI information specified as attributes. class LowerABIAttributesPass final - : public PassWrapper> { -private: + : public SPIRVLowerABIAttributesBase { void runOnOperation() override; }; } // namespace diff --git a/mlir/lib/Dialect/SPIRV/Transforms/PassDetail.h b/mlir/lib/Dialect/SPIRV/Transforms/PassDetail.h new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/SPIRV/Transforms/PassDetail.h @@ -0,0 +1,25 @@ +//===- PassDetail.h - SPIRV Pass class details ------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef DIALECT_SPIRV_TRANSFORMS_PASSDETAIL_H_ +#define DIALECT_SPIRV_TRANSFORMS_PASSDETAIL_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { + +namespace spirv { +class ModuleOp; +} // end namespace spirv + +#define GEN_PASS_CLASSES +#include "mlir/Dialect/SPIRV/Passes.h.inc" + +} // end namespace mlir + +#endif // DIALECT_SPIRV_TRANSFORMS_PASSDETAIL_H_ 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 @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/SPIRV/Passes.h" #include "mlir/Dialect/SPIRV/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/SPIRVOps.h" @@ -26,9 +27,7 @@ namespace { /// Pass to deduce minimal version/extension/capability requirements for a /// spirv::ModuleOp. -class UpdateVCEPass final - : public PassWrapper> { -private: +class UpdateVCEPass final : public SPIRVUpdateVCEBase { void runOnOperation() override; }; } // namespace 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 @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/Quant/QuantOps.h" #include "mlir/Dialect/Quant/QuantTypes.h" #include "mlir/IR/Attributes.h" @@ -30,12 +31,8 @@ namespace { class AddDefaultStatsPass - : public PassWrapper { + : public QuantizerAddDefaultStatsBase { public: -/// Include the generated pass utilities. -#define GEN_PASS_QuantizerAddDefaultStats -#include "mlir/Quantizer/Transforms/Passes.h.inc" - AddDefaultStatsPass() = default; AddDefaultStatsPass(SolverContext &solverContext, const TargetConfiguration &config) 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 @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/Quant/QuantOps.h" #include "mlir/Dialect/Quant/QuantTypes.h" #include "mlir/IR/Builders.h" @@ -72,12 +73,8 @@ namespace { class InferQuantizedTypesPass - : public PassWrapper> { + : public QuantizerInferQuantizedTypesBase { public: -/// Include the generated pass utilities. -#define GEN_PASS_QuantizerInferQuantizedTypes -#include "mlir/Quantizer/Transforms/Passes.h.inc" - InferQuantizedTypesPass() = default; InferQuantizedTypesPass(SolverContext &solverContext, const TargetConfiguration &config) diff --git a/mlir/lib/Quantizer/Transforms/PassDetail.h b/mlir/lib/Quantizer/Transforms/PassDetail.h new file mode 100644 --- /dev/null +++ b/mlir/lib/Quantizer/Transforms/PassDetail.h @@ -0,0 +1,21 @@ +//===- PassDetail.h - Quantizer Pass class details --------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef QUANTIZER_TRANSFORMS_PASSDETAIL_H_ +#define QUANTIZER_TRANSFORMS_PASSDETAIL_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { + +#define GEN_PASS_CLASSES +#include "mlir/Quantizer/Transforms/Passes.h.inc" + +} // end namespace mlir + +#endif // QUANTIZER_TRANSFORMS_PASSDETAIL_H_ 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 @@ -12,10 +12,10 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/Quant/QuantOps.h" #include "mlir/IR/MLIRContext.h" #include "mlir/IR/PatternMatch.h" -#include "mlir/Pass/Pass.h" #include "mlir/Quantizer/Transforms/Passes.h" using namespace mlir; @@ -24,11 +24,7 @@ namespace { class RemoveInstrumentationPass - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_QuantizerRemoveInstrumentation -#include "mlir/Quantizer/Transforms/Passes.h.inc" - + : public QuantizerRemoveInstrumentationBase { void runOnFunction() override; }; diff --git a/mlir/lib/TableGen/Pass.cpp b/mlir/lib/TableGen/Pass.cpp --- a/mlir/lib/TableGen/Pass.cpp +++ b/mlir/lib/TableGen/Pass.cpp @@ -75,6 +75,10 @@ return def->getValueAsString("argument"); } +StringRef Pass::getBaseClass() const { + return def->getValueAsString("baseClass"); +} + StringRef Pass::getSummary() const { return def->getValueAsString("summary"); } StringRef Pass::getDescription() const { 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 @@ -7,16 +7,13 @@ //===----------------------------------------------------------------------===// // // This transformation pass performs a simple common sub-expression elimination -// algorithm on operations within a function. +// algorithm on operations within a region. // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Analysis/Dominance.h" -#include "mlir/IR/Attributes.h" -#include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" #include "mlir/Pass/Pass.h" -#include "mlir/Support/Functional.h" #include "mlir/Transforms/Passes.h" #include "mlir/Transforms/Utils.h" #include "llvm/ADT/DenseMapInfo.h" @@ -25,6 +22,7 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/RecyclingAllocator.h" #include + using namespace mlir; namespace { @@ -73,14 +71,7 @@ namespace { /// Simple common sub-expression elimination. -struct CSE : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_CSE -#include "mlir/Transforms/Passes.h.inc" - - CSE() = default; - CSE(const CSE &) {} - +struct CSE : public CSEBase { /// Shared implementation of operation elimination and scoped map definitions. using AllocatorTy = llvm::RecyclingAllocator< llvm::BumpPtrAllocator, 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 @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/Passes.h" @@ -19,11 +20,7 @@ namespace { /// Canonicalize operations in nested regions. -struct Canonicalizer : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_Canonicalizer -#include "mlir/Transforms/Passes.h.inc" - +struct Canonicalizer : public CanonicalizerBase { void runOnOperation() override { OwningRewritePatternList patterns; 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 @@ -13,10 +13,10 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Analysis/CallGraph.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Interfaces/SideEffects.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/InliningUtils.h" #include "mlir/Transforms/Passes.h" #include "llvm/ADT/SCCIterator.h" @@ -589,11 +589,7 @@ //===----------------------------------------------------------------------===// namespace { -struct InlinerPass : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_Inliner -#include "mlir/Transforms/Passes.h.inc" - +struct InlinerPass : public InlinerBase { void runOnOperation() override { CallGraph &cg = getAnalysis(); auto *context = &getContext(); 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 @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include "mlir/Transforms/LocationSnapshot.h" +#include "PassDetail.h" #include "mlir/IR/AsmState.h" #include "mlir/IR/Builders.h" -#include "mlir/Pass/Pass.h" #include "mlir/Support/FileUtilities.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/ToolOutputFile.h" @@ -124,13 +124,8 @@ namespace { struct LocationSnapshotPass - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_LocationSnapshot -#include "mlir/Transforms/Passes.h.inc" - + : public LocationSnapshotBase { LocationSnapshotPass() = default; - LocationSnapshotPass(const LocationSnapshotPass &) {} LocationSnapshotPass(OpPrintingFlags flags, StringRef fileName, StringRef tag) : flags(flags) { this->fileName = fileName.str(); 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 @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/LoopOps/LoopOps.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/LoopUtils.h" #include "mlir/Transforms/Passes.h" #include "mlir/Transforms/RegionUtils.h" @@ -19,12 +19,7 @@ using namespace mlir; namespace { -struct LoopCoalescingPass - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_LoopCoalescing -#include "mlir/Transforms/Passes.h.inc" - +struct LoopCoalescingPass : public LoopCoalescingBase { void runOnFunction() override { FuncOp func = getFunction(); 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 @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Analysis/AffineAnalysis.h" #include "mlir/Analysis/AffineStructures.h" #include "mlir/Analysis/LoopAnalysis.h" @@ -18,7 +19,6 @@ #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/Builders.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/LoopFusionUtils.h" #include "mlir/Transforms/LoopUtils.h" #include "mlir/Transforms/Passes.h" @@ -77,11 +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 PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_AffineLoopFusion -#include "mlir/Transforms/Passes.h.inc" - +struct LoopFusion : public AffineLoopFusionBase { LoopFusion(unsigned fastMemorySpace = 0, uint64_t localBufSizeThreshold = 0, bool maximalFusion = false) : localBufSizeThreshold(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 @@ -10,13 +10,13 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Transforms/Passes.h" #include "mlir/IR/Builders.h" #include "mlir/IR/Function.h" #include "mlir/Interfaces/LoopLikeInterface.h" #include "mlir/Interfaces/SideEffects.h" -#include "mlir/Pass/Pass.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" @@ -28,11 +28,7 @@ namespace { /// Loop invariant code motion (LICM) pass. struct LoopInvariantCodeMotion - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_LoopInvariantCodeMotion -#include "mlir/Transforms/Passes.h.inc" - + : public LoopInvariantCodeMotionBase { void runOnOperation() override; }; } // end anonymous namespace 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 @@ -13,12 +13,12 @@ // SSA scalars live out of 'affine.for'/'affine.if' statements is available. //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Analysis/AffineAnalysis.h" #include "mlir/Analysis/Dominance.h" #include "mlir/Analysis/Utils.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/Passes.h" #include "llvm/ADT/SmallPtrSet.h" #include @@ -60,11 +60,7 @@ // currently only eliminates the stores only if no other loads/uses (other // than dealloc) remain. // -struct MemRefDataFlowOpt : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_MemRefDataFlowOpt -#include "mlir/Transforms/Passes.h.inc" - +struct MemRefDataFlowOpt : public MemRefDataFlowOptBase { void runOnFunction() override; void forwardStoreToLoad(AffineLoadOp loadOp); 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 @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/IR/Module.h" #include "mlir/IR/Operation.h" #include "mlir/IR/OperationSupport.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/Passes.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Format.h" @@ -18,12 +18,7 @@ using namespace mlir; namespace { -struct PrintOpStatsPass - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_PrintOpStats -#include "mlir/Transforms/Passes.h.inc" - +struct PrintOpStatsPass : public PrintOpStatsBase { explicit PrintOpStatsPass(raw_ostream &os = llvm::errs()) : os(os) {} // Prints the resultant operation statistics post iterating over the module. 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 @@ -6,9 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Dialect/LoopOps/LoopOps.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/LoopUtils.h" #include "mlir/Transforms/Passes.h" #include "mlir/Transforms/RegionUtils.h" @@ -21,13 +20,7 @@ namespace { struct ParallelLoopCollapsing - : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_ParallelLoopCollapsing -#include "mlir/Transforms/Passes.h.inc" - - ParallelLoopCollapsing() = default; - ParallelLoopCollapsing(const ParallelLoopCollapsing &) {} + : public ParallelLoopCollapsingBase { void runOnOperation() override { Operation *module = getOperation(); @@ -45,7 +38,6 @@ }); } }; - } // namespace std::unique_ptr mlir::createParallelLoopCollapsingPass() { diff --git a/mlir/lib/Transforms/PassDetail.h b/mlir/lib/Transforms/PassDetail.h new file mode 100644 --- /dev/null +++ b/mlir/lib/Transforms/PassDetail.h @@ -0,0 +1,21 @@ +//===- PassDetail.h - Transforms Pass class details -------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef TRANSFORMS_PASSDETAIL_H_ +#define TRANSFORMS_PASSDETAIL_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { + +#define GEN_PASS_CLASSES +#include "mlir/Transforms/Passes.h.inc" + +} // end namespace mlir + +#endif // TRANSFORMS_PASSDETAIL_H_ 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 @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/Transforms/Passes.h" #include "mlir/Analysis/AffineAnalysis.h" @@ -17,7 +18,6 @@ #include "mlir/Analysis/Utils.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/IR/Builders.h" -#include "mlir/Pass/Pass.h" #include "mlir/Transforms/LoopUtils.h" #include "mlir/Transforms/Utils.h" #include "llvm/ADT/DenseMap.h" @@ -29,11 +29,7 @@ namespace { struct PipelineDataTransfer - : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_AffinePipelineDataTransfer -#include "mlir/Transforms/Passes.h.inc" - + : public AffinePipelineDataTransferBase { void runOnFunction() override; void runOnAffineForOp(AffineForOp forOp); 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 @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "PassDetail.h" #include "mlir/IR/Function.h" #include "mlir/IR/Operation.h" #include "mlir/Pass/Pass.h" @@ -14,11 +15,7 @@ using namespace mlir; namespace { -struct StripDebugInfo : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_StripDebugInfo -#include "mlir/Transforms/Passes.h.inc" - +struct StripDebugInfo : public StripDebugInfoBase { void runOnOperation() override; }; } // end anonymous namespace 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 @@ -11,17 +11,13 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Pass/Pass.h" +#include "PassDetail.h" #include "mlir/Transforms/Passes.h" using namespace mlir; namespace { -struct SymbolDCE : public PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_SymbolDCE -#include "mlir/Transforms/Passes.h.inc" - +struct SymbolDCE : public SymbolDCEBase { void runOnOperation() override; /// Compute the liveness of the symbols within the given symbol table. 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 @@ -7,10 +7,10 @@ //===----------------------------------------------------------------------===// #include "mlir/Transforms/ViewOpGraph.h" +#include "PassDetail.h" #include "mlir/IR/Block.h" #include "mlir/IR/Operation.h" #include "mlir/IR/StandardTypes.h" -#include "mlir/Pass/Pass.h" #include "mlir/Support/STLExtras.h" #include "llvm/Support/CommandLine.h" @@ -100,11 +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 PassWrapper> { -/// Include the generated pass utilities. -#define GEN_PASS_PrintOpGraph -#include "mlir/Transforms/Passes.h.inc" - +struct PrintOpPass : public PrintOpBase { explicit PrintOpPass(raw_ostream &os = llvm::errs(), bool short_names = false, const Twine &title = "") : os(os), title(title.str()), short_names(short_names) {} 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 @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #include "mlir/Transforms/ViewRegionGraph.h" +#include "PassDetail.h" #include "mlir/IR/RegionGraphTraits.h" -#include "mlir/Pass/Pass.h" using namespace mlir; @@ -60,11 +60,7 @@ void mlir::Region::viewGraph() { viewGraph("region"); } namespace { -struct PrintCFGPass : public PassWrapper { -/// Include the generated pass utilities. -#define GEN_PASS_PrintCFG -#include "mlir/Transforms/Passes.h.inc" - +struct PrintCFGPass : public PrintCFGBase { PrintCFGPass(raw_ostream &os = llvm::errs(), bool shortNames = false, const Twine &title = "") : os(os), shortNames(shortNames), title(title.str()) {} diff --git a/mlir/tools/mlir-tblgen/PassDocGen.cpp b/mlir/tools/mlir-tblgen/PassDocGen.cpp --- a/mlir/tools/mlir-tblgen/PassDocGen.cpp +++ b/mlir/tools/mlir-tblgen/PassDocGen.cpp @@ -58,7 +58,7 @@ static void emitDocs(const llvm::RecordKeeper &recordKeeper, raw_ostream &os) { os << "\n"; - auto passDefs = recordKeeper.getAllDerivedDefinitions("Pass"); + auto passDefs = recordKeeper.getAllDerivedDefinitions("PassBase"); // Collect the registered passes, sorted by argument name. SmallVector passes(passDefs.begin(), passDefs.end()); diff --git a/mlir/tools/mlir-tblgen/PassGen.cpp b/mlir/tools/mlir-tblgen/PassGen.cpp --- a/mlir/tools/mlir-tblgen/PassGen.cpp +++ b/mlir/tools/mlir-tblgen/PassGen.cpp @@ -28,22 +28,36 @@ /// The code snippet used to generate the start of a pass base class. /// /// {0}: The def name of the pass record. -/// {1}: The command line argument for the pass. +/// {1}: The base class for the pass. +/// {2): The command line argument for the pass. const char *const passDeclBegin = R"( //===----------------------------------------------------------------------===// // {0} //===----------------------------------------------------------------------===// -#ifdef GEN_PASS_{0} + +template +class {0}Base : public {1} { +public: + {0}Base() : {1}(PassID::getID()) {{} + {0}Base(const {0}Base &) : {1}(PassID::getID()) {{} + /// Returns the command-line argument attached to this pass. - static StringRef getPassArgument() { return "{1}"; } -)"; + static llvm::StringRef getPassArgument() { return "{2}"; } -/// The code snippet used to generate the end of a pass base class. -/// -/// {0}: The def name of the pass record. -const char *const passDeclEnd = R"( -#undef GEN_PASS_{0} -#endif // GEN_PASS_{0} + /// Returns the derived pass name. + llvm::StringRef getName() override { return "{0}"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) {{ + return pass->getPassID() == ::mlir::PassID::getID(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr clonePass() const override {{ + return std::make_unique(*static_cast(this)); + } + +protected: )"; /// Emit the declarations for each of the pass options. @@ -73,10 +87,21 @@ static void emitPassDecl(const Pass &pass, raw_ostream &os) { StringRef defName = pass.getDef()->getName(); - os << llvm::formatv(passDeclBegin, defName, pass.getArgument()); + os << llvm::formatv(passDeclBegin, defName, pass.getBaseClass(), + pass.getArgument()); emitPassOptionDecls(pass, os); emitPassStatisticDecls(pass, os); - os << llvm::formatv(passDeclEnd, defName); + os << "};\n"; +} + +/// Emit the code for registering each of the given passes with the global +/// PassRegistry. +static void emitPassDecls(ArrayRef passes, raw_ostream &os) { + os << "#ifdef GEN_PASS_CLASSES\n"; + for (const Pass &pass : passes) + emitPassDecl(pass, os); + os << "#undef GEN_PASS_CLASSES\n"; + os << "#endif // GEN_PASS_CLASSES\n"; } //===----------------------------------------------------------------------===// @@ -121,13 +146,11 @@ static void emitDecls(const llvm::RecordKeeper &recordKeeper, raw_ostream &os) { os << "/* Autogenerated by mlir-tblgen; don't manually edit */\n"; - std::vector passes; - for (const auto *def : recordKeeper.getAllDerivedDefinitions("Pass")) { - Pass pass(def); - passes.push_back(pass); - emitPassDecl(pass, os); - } + for (const auto *def : recordKeeper.getAllDerivedDefinitions("PassBase")) + passes.push_back(Pass(def)); + + emitPassDecls(passes, os); emitRegistration(passes, os); }