[Mlir-commits] [mlir] 1834ad4 - [mlir][Pass] Update the PassGen to generate base classes instead of utilities

River Riddle llvmlistbot at llvm.org
Tue Apr 7 14:10:15 PDT 2020


Author: River Riddle
Date: 2020-04-07T14:08:52-07:00
New Revision: 1834ad4a69701d338da1c5e2272e5523e0bbcb49

URL: https://github.com/llvm/llvm-project/commit/1834ad4a69701d338da1c5e2272e5523e0bbcb49
DIFF: https://github.com/llvm/llvm-project/commit/1834ad4a69701d338da1c5e2272e5523e0bbcb49.diff

LOG: [mlir][Pass] Update the PassGen to generate base classes instead of utilities

Summary:
This is much cleaner, and fits the same structure as many other tablegen backends. This was not done originally as the CRTP in the pass classes made it overly verbose/complex.

Differential Revision: https://reviews.llvm.org/D77367

Added: 
    mlir/lib/Conversion/PassDetail.h
    mlir/lib/Dialect/Affine/Transforms/PassDetail.h
    mlir/lib/Dialect/GPU/Transforms/PassDetail.h
    mlir/lib/Dialect/LLVMIR/Transforms/PassDetail.h
    mlir/lib/Dialect/Linalg/Transforms/PassDetail.h
    mlir/lib/Dialect/LoopOps/Transforms/PassDetail.h
    mlir/lib/Dialect/Quant/Transforms/PassDetail.h
    mlir/lib/Dialect/SPIRV/Transforms/PassDetail.h
    mlir/lib/Transforms/PassDetail.h

Modified: 
    mlir/include/mlir/Conversion/Passes.td
    mlir/include/mlir/Dialect/Affine/Passes.td
    mlir/include/mlir/Dialect/GPU/Passes.td
    mlir/include/mlir/Dialect/Linalg/Passes.td
    mlir/include/mlir/Dialect/LoopOps/Passes.td
    mlir/include/mlir/Dialect/Quant/Passes.td
    mlir/include/mlir/Dialect/SPIRV/Passes.td
    mlir/include/mlir/Pass/PassBase.td
    mlir/include/mlir/TableGen/Pass.h
    mlir/include/mlir/Transforms/Passes.td
    mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
    mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
    mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp
    mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
    mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
    mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp
    mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
    mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp
    mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
    mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp
    mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp
    mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp
    mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
    mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp
    mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
    mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
    mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp
    mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp
    mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp
    mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
    mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp
    mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp
    mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
    mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
    mlir/lib/Dialect/LLVMIR/Transforms/LegalizeForExport.cpp
    mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
    mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
    mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
    mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
    mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopFusion.cpp
    mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopSpecialization.cpp
    mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopTiling.cpp
    mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp
    mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp
    mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp
    mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
    mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
    mlir/lib/TableGen/Pass.cpp
    mlir/lib/Transforms/CSE.cpp
    mlir/lib/Transforms/Canonicalizer.cpp
    mlir/lib/Transforms/Inliner.cpp
    mlir/lib/Transforms/LocationSnapshot.cpp
    mlir/lib/Transforms/LoopCoalescing.cpp
    mlir/lib/Transforms/LoopFusion.cpp
    mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
    mlir/lib/Transforms/MemRefDataFlowOpt.cpp
    mlir/lib/Transforms/OpStats.cpp
    mlir/lib/Transforms/ParallelLoopCollapsing.cpp
    mlir/lib/Transforms/PipelineDataTransfer.cpp
    mlir/lib/Transforms/StripDebugInfo.cpp
    mlir/lib/Transforms/SymbolDCE.cpp
    mlir/lib/Transforms/ViewOpGraph.cpp
    mlir/lib/Transforms/ViewRegionGraph.cpp
    mlir/tools/mlir-tblgen/PassDocGen.cpp
    mlir/tools/mlir-tblgen/PassGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td
index f990460ed347..078d978b59af 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -15,7 +15,7 @@ include "mlir/Pass/PassBase.td"
 // 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 @@ def ConvertAffineToStandard : Pass<"lower-affine"> {
 // 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 @@ def ConvertAVX512ToLLVM : Pass<"convert-avx512-to-llvm"> {
 // 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 @@ def ConvertGpuLaunchFuncToCudaCalls : Pass<"launch-func-to-cuda"> {
 // 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 @@ def ConvertGpuOpsToNVVMOps : Pass<"convert-gpu-to-nvvm"> {
 // 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 @@ def ConvertGpuOpsToROCDLOps : Pass<"convert-gpu-to-rocdl"> {
 // 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 ConvertGPUToSPIRV : Pass<"convert-gpu-to-spirv"> {
 //===----------------------------------------------------------------------===//
 
 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 @@ def ConvertVulkanLaunchFuncToVulkanCalls : Pass<"launch-func-to-vulkan"> {
 // 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 @@ def ConvertLinalgToLLVM : Pass<"convert-linalg-to-llvm"> {
 // 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 @@ def ConvertLoopToStandard : Pass<"convert-loop-to-std"> {
 // 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 ConvertSimpleLoopsToGPU : Pass<"convert-loops-to-gpu"> {
   ];
 }
 
-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 @@ def ConvertParallelLoopToGpu : Pass<"convert-parallel-loops-to-gpu"> {
 // 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 = [{
@@ -233,7 +234,7 @@ def ConvertStandardToLLVM : Pass<"convert-std-to-llvm"> {
            "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">,
   ];
 }
@@ -247,7 +248,7 @@ def LegalizeStandardForSPIRV : Pass<"legalize-std-for-spirv"> {
   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()";
 }
@@ -256,7 +257,7 @@ def ConvertStandardToSPIRV : Pass<"convert-std-to-spirv"> {
 // 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
index 4ae53571d1f4..8fef9961510a 100644
--- 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 AffineVectorize : Pass<"affine-super-vectorize"> {
   ];
 }
 
-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/GPU/Passes.td b/mlir/include/mlir/Dialect/GPU/Passes.td
index 563624308297..ed2c8054e1fd 100644
--- 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
index 210ad1092c66..9f60b274817e 100644
--- 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 @@ def LinalgFusionOfTensorOps : Pass<"linalg-fusion-for-tensor-ops"> {
   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 LinalgPromotion : Pass<"linalg-promote-subviews"> {
   ];
 }
 
-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 LinalgTiling : Pass<"linalg-tile"> {
   ];
 }
 
-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
index 444dcfe22201..41001381ab94 100644
--- a/mlir/include/mlir/Dialect/LoopOps/Passes.td
+++ b/mlir/include/mlir/Dialect/LoopOps/Passes.td
@@ -16,12 +16,13 @@ def LoopParallelLoopFusion : Pass<"parallel-loop-fusion"> {
   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
index f55a43006977..d0ca17ce41bb 100644
--- 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
index a03849955797..e8972f519917 100644
--- 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
index 29478047f757..54b44031559e 100644
--- a/mlir/include/mlir/Pass/PassBase.td
+++ b/mlir/include/mlir/Pass/PassBase.td
@@ -62,10 +62,13 @@ class Statistic<string varName, string statName, string desc> {
 // Pass
 //===----------------------------------------------------------------------===//
 
-class Pass<string passArg> {
+class PassBase<string passArg, string base> {
   // 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 @@ class Pass<string passArg> {
   list<Statistic> statistics = [];
 }
 
+// This class represents an mlir::OperationPass.
+class Pass<string passArg, string operation = "">
+  : PassBase<passArg, "::mlir::OperationPass<" # operation # ">">;
+
+// This class represents an mlir::FunctionPass.
+class FunctionPass<string passArg> : PassBase<passArg, "::mlir::FunctionPass">;
+
 #endif // MLIR_PASS_PASSBASE

diff  --git a/mlir/include/mlir/TableGen/Pass.h b/mlir/include/mlir/TableGen/Pass.h
index d8b5eaa04313..02427e42a525 100644
--- a/mlir/include/mlir/TableGen/Pass.h
+++ b/mlir/include/mlir/TableGen/Pass.h
@@ -82,6 +82,9 @@ class Pass {
   /// 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
index 087300453280..04cf0877c338 100644
--- 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 @@ def AffinePipelineDataTransfer : Pass<
   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 LocationSnapshot : Pass<"snapshot-op-locations"> {
   ];
 }
 
-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 @@ def LoopInvariantCodeMotion : Pass<"loop-invariant-code-motion"> {
   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 ParallelLoopCollapsing : Pass<"parallel-loop-collapsing"> {
   ];
 }
 
-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
index 6117100fec98..33fd169c6fda 100644
--- 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 @@ void mlir::populateAVX512ToLLVMConversionPatterns(
 
 namespace {
 struct ConvertAVX512ToLLVMPass
-    : public PassWrapper<ConvertAVX512ToLLVMPass, OperationPass<ModuleOp>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_ConvertAVX512ToLLVM
-#include "mlir/Conversion/Passes.h.inc"
-
+    : public ConvertAVX512ToLLVMBase<ConvertAVX512ToLLVMPass> {
   void runOnOperation() override;
 };
 } // namespace

diff  --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
index c45444948e64..54520b28c158 100644
--- 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 @@ void mlir::populateAffineToStdConversionPatterns(
 }
 
 namespace {
-class LowerAffinePass : public PassWrapper<LowerAffinePass, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_ConvertAffineToStandard
-#include "mlir/Conversion/Passes.h.inc"
-
+class LowerAffinePass : public ConvertAffineToStandardBase<LowerAffinePass> {
   void runOnFunction() override {
     OwningRewritePatternList patterns;
     populateAffineToStdConversionPatterns(patterns, &getContext());

diff  --git a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp
index 9a71ef56e309..134ca5d6c6e7 100644
--- 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 @@ namespace {
 ///
 /// Intermediate data structures are allocated on the stack.
 class GpuLaunchFuncToCudaCallsPass
-    : public PassWrapper<GpuLaunchFuncToCudaCallsPass,
-                         OperationPass<ModuleOp>> {
+    : public ConvertGpuLaunchFuncToCudaCallsBase<GpuLaunchFuncToCudaCallsPass> {
 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
index f4161a77c6c1..c3f3c04d9196 100644
--- 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 @@ struct GPUReturnOpLowering : public ConvertToLLVMPattern {
 /// This pass only handles device code and is not meant to be run on GPU host
 /// code.
 class LowerGpuOpsToNVVMOpsPass
-    : public PassWrapper<LowerGpuOpsToNVVMOpsPass,
-                         OperationPass<gpu::GPUModuleOp>> {
+    : public ConvertGpuOpsToNVVMOpsBase<LowerGpuOpsToNVVMOpsPass> {
 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
index 36e1b85fd39c..ed78bcfb1e76 100644
--- 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 @@ namespace {
 // This pass only handles device code and is not meant to be run on GPU host
 // code.
 class LowerGpuOpsToROCDLOpsPass
-    : public PassWrapper<LowerGpuOpsToROCDLOpsPass,
-                         OperationPass<gpu::GPUModuleOp>> {
+    : public ConvertGpuOpsToROCDLOpsBase<LowerGpuOpsToROCDLOpsPass> {
 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
index 173c6d0f5826..687a32a98054 100644
--- 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 @@ namespace {
 /// replace it).
 ///
 /// 2) Lower the body of the spirv::ModuleOp.
-struct GPUToSPIRVPass
-    : public PassWrapper<GPUToSPIRVPass, OperationPass<ModuleOp>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_ConvertGpuToSPIRV
-#include "mlir/Conversion/Passes.h.inc"
-
+struct GPUToSPIRVPass : public ConvertGPUToSPIRVBase<GPUToSPIRVPass> {
   void runOnOperation() override;
 };
 } // namespace

diff  --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
index bf2c15f68ae5..95133ac19664 100644
--- 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 @@ namespace {
 /// function and attaching binary data and entry point name as an attributes to
 /// created vulkan launch call op.
 class ConvertGpuLaunchFuncToVulkanLaunchFunc
-    : public PassWrapper<ConvertGpuLaunchFuncToVulkanLaunchFunc,
-                         OperationPass<ModuleOp>> {
+    : 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
index 03d924d74f56..3182a5d323ef 100644
--- 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"
@@ -58,13 +58,9 @@ namespace {
 /// * deinitVulkan         -- deinitializes vulkan runtime
 ///
 class VulkanLaunchFuncToVulkanCallsPass
-    : public PassWrapper<VulkanLaunchFuncToVulkanCallsPass,
-                         OperationPass<ModuleOp>> {
+    : 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
index 05aab300e622..1ffe548ae919 100644
--- 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"
@@ -562,11 +561,7 @@ void mlir::populateLinalgToLLVMConversionPatterns(
 
 namespace {
 struct ConvertLinalgToLLVMPass
-    : public PassWrapper<ConvertLinalgToLLVMPass, OperationPass<ModuleOp>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_ConvertLinalgToLLVM
-#include "mlir/Conversion/Passes.h.inc"
-
+    : public ConvertLinalgToLLVMBase<ConvertLinalgToLLVMPass> {
   void runOnOperation() override;
 };
 } // namespace

diff  --git a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp
index acb87b72c3c6..d81e269c778b 100644
--- 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<LinalgToSPIRVPass, OperationPass<ModuleOp>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_ConvertLinalgToSPIRV
-#include "mlir/Conversion/Passes.h.inc"
-
+class LinalgToSPIRVPass : public ConvertLinalgToSPIRVBase<LinalgToSPIRVPass> {
   void runOnOperation() override;
 };
 } // namespace

diff  --git a/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp b/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp
index 9929b8e816f6..bb00639ed964 100644
--- 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 @@ using namespace mlir::loop;
 namespace {
 
 struct LoopToStandardPass
-    : public PassWrapper<LoopToStandardPass, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_ConvertLoopToStandard
-#include "mlir/Conversion/Passes.h.inc"
-
+    : public ConvertLoopToStandardBase<LoopToStandardPass> {
   void runOnOperation() override;
 };
 

diff  --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp
index 679d0b339691..9ea64d9384c6 100644
--- 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 @@ namespace {
 // A pass that traverses top-level loops in the function and converts them to
 // GPU launch operations.  Nested launches are not allowed, so this does not
 // walk the function recursively to avoid considering nested loops.
-struct ForLoopMapper : public PassWrapper<ForLoopMapper, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_ConvertSimpleLoopsToGPU
-#include "mlir/Conversion/Passes.h.inc"
-
+struct ForLoopMapper : public ConvertSimpleLoopsToGPUBase<ForLoopMapper> {
   ForLoopMapper() = default;
-  ForLoopMapper(const ForLoopMapper &) {}
   ForLoopMapper(unsigned numBlockDims, unsigned numThreadDims) {
     this->numBlockDims = numBlockDims;
     this->numThreadDims = numThreadDims;
@@ -62,13 +57,8 @@ struct ForLoopMapper : public PassWrapper<ForLoopMapper, FunctionPass> {
 // nested loops as the size of `numWorkGroups`. Within these any loop nest has
 // to be perfectly nested upto depth equal to size of `workGroupSize`.
 struct ImperfectlyNestedForLoopMapper
-    : public PassWrapper<ImperfectlyNestedForLoopMapper, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_ConvertLoopsToGPU
-#include "mlir/Conversion/Passes.h.inc"
-
+    : public ConvertLoopsToGPUBase<ImperfectlyNestedForLoopMapper> {
   ImperfectlyNestedForLoopMapper() = default;
-  ImperfectlyNestedForLoopMapper(const ImperfectlyNestedForLoopMapper &) {}
   ImperfectlyNestedForLoopMapper(ArrayRef<int64_t> numWorkGroups,
                                  ArrayRef<int64_t> workGroupSize) {
     this->numWorkGroups->assign(numWorkGroups.begin(), numWorkGroups.end());
@@ -105,11 +95,7 @@ struct ImperfectlyNestedForLoopMapper
 };
 
 struct ParallelLoopToGpuPass
-    : public PassWrapper<ParallelLoopToGpuPass, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_ConvertParallelLoopToGpu
-#include "mlir/Conversion/Passes.h.inc"
-
+    : public ConvertParallelLoopToGpuBase<ParallelLoopToGpuPass> {
   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
index 000000000000..6da0bc81e7af
--- /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
index d23883f6d624..92b02704e015 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "../PassDetail.h"
 #include "mlir/ADT/TypeSwitch.h"
 #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
 #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.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"
@@ -2847,21 +2847,14 @@ LLVMTypeConverter::promoteMemRefDescriptors(Location loc, ValueRange opOperands,
 
 namespace {
 /// A pass converting MLIR operations into the LLVM IR dialect.
-struct LLVMLoweringPass
-    : public PassWrapper<LLVMLoweringPass, OperationPass<ModuleOp>> {
-/// 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> {
+  LLVMLoweringPass() = default;
   LLVMLoweringPass(bool useBarePtrCallConv, bool emitCWrappers,
                    unsigned indexBitwidth) {
     this->useBarePtrCallConv = useBarePtrCallConv;
     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
index b0ce99fa837f..71208c719a19 100644
--- 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<ConvertStandardToSPIRVPass, OperationPass<ModuleOp>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_ConvertStandardToSPIRV
-#include "mlir/Conversion/Passes.h.inc"
-
+    : public ConvertStandardToSPIRVBase<ConvertStandardToSPIRVPass> {
   void runOnOperation() override;
 };
 } // namespace

diff  --git a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
index 9dbb76174201..1312e0c36f80 100644
--- 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 @@ void mlir::populateStdLegalizationPatternsForSPIRVLowering(
 
 namespace {
 struct SPIRVLegalization final
-    : public PassWrapper<SPIRVLegalization, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LegalizeStandardForSPIRV
-#include "mlir/Conversion/Passes.h.inc"
-
+    : public LegalizeStandardForSPIRVBase<SPIRVLegalization> {
   void runOnOperation() override;
 };
 } // namespace

diff  --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
index 03cbb67bc5d7..2fc9b223a57c 100644
--- 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 @@ void mlir::populateVectorToLLVMMatrixConversionPatterns(
 
 namespace {
 struct LowerVectorToLLVMPass
-    : public PassWrapper<LowerVectorToLLVMPass, OperationPass<ModuleOp>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_ConvertVectorToLLVM
-#include "mlir/Conversion/Passes.h.inc"
-
+    : public ConvertVectorToLLVMBase<LowerVectorToLLVMPass> {
   void runOnOperation() override;
 };
 } // namespace

diff  --git a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp
index 1f7d670ce473..a0525470d9ed 100644
--- a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp
@@ -19,12 +19,12 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "PassDetail.h"
 #include "mlir/Analysis/Utils.h"
 #include "mlir/Dialect/Affine/IR/AffineOps.h"
 #include "mlir/Dialect/Affine/Passes.h"
 #include "mlir/Dialect/StandardOps/IR/Ops.h"
 #include "mlir/IR/PatternMatch.h"
-#include "mlir/Pass/Pass.h"
 #include "mlir/Transforms/LoopUtils.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/Support/CommandLine.h"
@@ -75,11 +75,7 @@ namespace {
 // TODO(bondhugula): We currently can't generate copies correctly when stores
 // are strided. Check for strided stores.
 struct AffineDataCopyGeneration
-    : public PassWrapper<AffineDataCopyGeneration, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_AffineDataCopyGeneration
-#include "mlir/Dialect/Affine/Passes.h.inc"
-
+    : public AffineDataCopyGenerationBase<AffineDataCopyGeneration> {
   explicit AffineDataCopyGeneration(
       unsigned slowMemorySpace = 0,
       unsigned fastMemorySpace = clFastMemorySpace, unsigned tagMemorySpace = 0,
@@ -96,7 +92,8 @@ struct AffineDataCopyGeneration
         skipNonUnitStrideLoops(skipNonUnitStrideLoops) {}
 
   explicit AffineDataCopyGeneration(const AffineDataCopyGeneration &other)
-      : slowMemorySpace(other.slowMemorySpace),
+      : AffineDataCopyGenerationBase<AffineDataCopyGeneration>(other),
+        slowMemorySpace(other.slowMemorySpace),
         fastMemorySpace(other.fastMemorySpace),
         tagMemorySpace(other.tagMemorySpace),
         minDmaTransferSize(other.minDmaTransferSize),

diff  --git a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp
index 066a53d14e23..72e99cc735c4 100644
--- 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 @@ namespace {
 /// TODO: This code should be removed once the new LICM pass can handle its
 ///       uses.
 struct LoopInvariantCodeMotion
-    : public PassWrapper<LoopInvariantCodeMotion, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_AffineLoopInvariantCodeMotion
-#include "mlir/Dialect/Affine/Passes.h.inc"
-
+    : public AffineLoopInvariantCodeMotionBase<LoopInvariantCodeMotion> {
   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
index 1cfb31045c66..0e8e10983151 100644
--- 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 @@ static llvm::cl::list<unsigned> clTileSizes(
 namespace {
 
 /// A pass to perform loop tiling on all suitable loop nests of a Function.
-struct LoopTiling : public PassWrapper<LoopTiling, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_AffineLoopTiling
-#include "mlir/Dialect/Affine/Passes.h.inc"
-
+struct LoopTiling : public AffineLoopTilingBase<LoopTiling> {
   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
index d9a6b1cd2690..f02cf36ee5a7 100644
--- 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 @@ namespace {
 /// full unroll threshold was specified, in which case, fully unrolls all loops
 /// with trip count less than the specified threshold. The latter is for testing
 /// purposes, especially for testing outer loop unrolling.
-struct LoopUnroll : public PassWrapper<LoopUnroll, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_AffineUnroll
-#include "mlir/Dialect/Affine/Passes.h.inc"
-
+struct LoopUnroll : public AffineLoopUnrollBase<LoopUnroll> {
   const Optional<unsigned> unrollFactor;
   const Optional<bool> 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
index 1a2567796795..dffc7c0932e9 100644
--- 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 @@ static llvm::cl::opt<unsigned>
 namespace {
 /// Loop unroll jam pass. Currently, this just unroll jams the first
 /// outer loop in a Function.
-struct LoopUnrollAndJam : public PassWrapper<LoopUnrollAndJam, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_AffineLoopUnrollAndJam
-#include "mlir/Dialect/Affine/Passes.h.inc"
-
+struct LoopUnrollAndJam : public AffineLoopUnrollAndJamBase<LoopUnrollAndJam> {
   Optional<unsigned> 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
index 000000000000..3bae0592b3d4
--- /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
index af11d4e8d114..0df4ea0d3f87 100644
--- 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 @@ namespace {
 /// all memrefs with non-trivial layout maps are converted to ones with trivial
 /// identity layout ones.
 struct SimplifyAffineStructures
-    : public PassWrapper<SimplifyAffineStructures, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_SimplifyAffineStructures
-#include "mlir/Dialect/Affine/Passes.h.inc"
-
+    : public SimplifyAffineStructuresBase<SimplifyAffineStructures> {
   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
index 06de9a2c9da5..d6b2bd11f931 100644
--- 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 @@ namespace {
 
 /// Base state for the vectorize pass.
 /// Command line arguments are preempted by non-empty pass arguments.
-struct Vectorize : public PassWrapper<Vectorize, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_AffineVectorize
-#include "mlir/Dialect/Affine/Passes.h.inc"
-
+struct Vectorize : public AffineVectorizeBase<Vectorize> {
   Vectorize() = default;
-  Vectorize(const Vectorize &) {}
   Vectorize(ArrayRef<int64_t> virtualVectorSize);
   void runOnFunction() override;
 };

diff  --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
index 70ace0f1f45f..0f4c4103b2a7 100644
--- 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 @@ namespace {
 /// a separate pass. The external functions can then be annotated with the
 /// symbol of the cubin accessor function.
 class GpuKernelOutliningPass
-    : public PassWrapper<GpuKernelOutliningPass, OperationPass<ModuleOp>> {
+    : public GpuKernelOutliningBase<GpuKernelOutliningPass> {
 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
index 000000000000..2e6fb9217189
--- /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
index 88f06d7ed18f..ad40017208b5 100644
--- 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 @@ void mlir::LLVM::ensureDistinctSuccessors(Operation *op) {
 
 namespace {
 struct LegalizeForExportPass
-    : public PassWrapper<LegalizeForExportPass, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LLVMLegalizeForExport
-#include "mlir/Dialect/LLVMIR/Transforms/Passes.h.inc"
-
+    : public LLVMLegalizeForExportBase<LegalizeForExportPass> {
   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
index 000000000000..2a46e1208bc4
--- /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
index 07b4d9788a80..ee9996b28708 100644
--- 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 @@ struct FuseGenericTensorOps : public OpRewritePattern<GenericOp> {
 
 /// Pass that fuses generic ops on tensors. Used only for testing.
 struct FusionOfTensorOpsPass
-    : public PassWrapper<FusionOfTensorOpsPass, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LinalgFusionOfTensorOps
-#include "mlir/Dialect/Linalg/Passes.h.inc"
-
+    : public LinalgFusionOfTensorOpsBase<FusionOfTensorOpsPass> {
   void runOnOperation() override {
     OwningRewritePatternList patterns;
     Operation *op = getOperation();
@@ -581,11 +576,7 @@ struct FusionOfTensorOpsPass
   };
 };
 
-struct LinalgFusionPass : public PassWrapper<LinalgFusionPass, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LinalgFusion
-#include "mlir/Dialect/Linalg/Passes.h.inc"
-
+struct LinalgFusionPass : public LinalgFusionBase<LinalgFusionPass> {
   void runOnFunction() override { fuseLinalgOpsGreedily(getFunction()); }
 };
 } // namespace

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
index 8a4df6414833..e85a67a9f7eb 100644
--- 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 @@ static void lowerLinalgToLoopsImpl(Operation *op, MLIRContext *context) {
 
 namespace {
 struct LowerToAffineLoops
-    : public PassWrapper<LowerToAffineLoops, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LinalgLowerToAffineLoops
-#include "mlir/Dialect/Linalg/Passes.h.inc"
-
+    : public LinalgLowerToAffineLoopsBase<LowerToAffineLoops> {
   void runOnFunction() override {
     lowerLinalgToLoopsImpl<AffineForOp, AffineIndexedValue>(getFunction(),
                                                             &getContext());
   }
 };
-struct LowerToLoops : public PassWrapper<LowerToLoops, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LinalgLowerToLoops
-#include "mlir/Dialect/Linalg/Passes.h.inc"
-
+struct LowerToLoops : public LinalgLowerToLoopsBase<LowerToLoops> {
   void runOnFunction() override {
     lowerLinalgToLoopsImpl<loop::ForOp, StdIndexedValue>(getFunction(),
                                                          &getContext());
   }
 };
 struct LowerToParallelLoops
-    : public PassWrapper<LowerToParallelLoops, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LinalgLowerToParallelLoops
-#include "mlir/Dialect/Linalg/Passes.h.inc"
-
+    : public LinalgLowerToParallelLoopsBase<LowerToParallelLoops> {
   void runOnFunction() override {
     lowerLinalgToLoopsImpl<loop::ParallelOp, StdIndexedValue>(getFunction(),
                                                               &getContext());

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/PassDetail.h b/mlir/lib/Dialect/Linalg/Transforms/PassDetail.h
new file mode 100644
index 000000000000..7fa05ff12120
--- /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
index 6eea97f954ff..f393ca2f12f9 100644
--- 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 @@ static void promoteSubViews(FuncOp f, bool dynamicBuffers) {
 }
 
 namespace {
-struct LinalgPromotionPass
-    : public PassWrapper<LinalgPromotionPass, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LinalgPromotion
-#include "mlir/Dialect/Linalg/Passes.h.inc"
-
+struct LinalgPromotionPass : public LinalgPromotionBase<LinalgPromotionPass> {
   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
index 1e528aa9a201..cda2d0860e81 100644
--- 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 @@ static void tileLinalgOps(FuncOp f, ArrayRef<int64_t> tileSizes) {
 }
 
 namespace {
-struct LinalgTilingPass : public PassWrapper<LinalgTilingPass, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LinalgTiling
-#include "mlir/Dialect/Linalg/Passes.h.inc"
-
+struct LinalgTilingPass : public LinalgTilingBase<LinalgTilingPass> {
   LinalgTilingPass() = default;
-  LinalgTilingPass(const LinalgTilingPass &) {}
   LinalgTilingPass(ArrayRef<int64_t> sizes) {
     tileSizes->assign(sizes.begin(), sizes.end());
   }
@@ -524,13 +518,8 @@ struct LinalgTilingPass : public PassWrapper<LinalgTilingPass, FunctionPass> {
 };
 
 struct LinalgTilingToParallelLoopsPass
-    : public PassWrapper<LinalgTilingToParallelLoopsPass, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LinalgTilingToParallelLoops
-#include "mlir/Dialect/Linalg/Passes.h.inc"
-
+    : public LinalgTilingToParallelLoopsBase<LinalgTilingToParallelLoopsPass> {
   LinalgTilingToParallelLoopsPass() = default;
-  LinalgTilingToParallelLoopsPass(const LinalgTilingToParallelLoopsPass &) {}
   LinalgTilingToParallelLoopsPass(ArrayRef<int64_t> 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
index b031f81076cd..afd32b2069a8 100644
--- 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 @@ void mlir::loop::naivelyFuseParallelOps(Region &region) {
 
 namespace {
 struct ParallelLoopFusion
-    : public PassWrapper<ParallelLoopFusion, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LoopParallelLoopFusion
-#include "mlir/Dialect/LoopOps/Passes.h.inc"
-
+    : public LoopParallelLoopFusionBase<ParallelLoopFusion> {
   void runOnOperation() override {
     for (Region &region : getOperation()->getRegions())
       naivelyFuseParallelOps(region);

diff  --git a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopSpecialization.cpp b/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopSpecialization.cpp
index 98776abdb06c..76c0be2feb4f 100644
--- 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 @@ static void specializeLoopForUnrolling(ParallelOp op) {
 
 namespace {
 struct ParallelLoopSpecialization
-    : public PassWrapper<ParallelLoopSpecialization, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LoopParallelLoopSpecialization
-#include "mlir/Dialect/LoopOps/Passes.h.inc"
-
+    : public LoopParallelLoopSpecializationBase<ParallelLoopSpecialization> {
   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
index c10872ece9f9..16b9b223f2eb 100644
--- 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 @@ static bool getInnermostNestedLoops(Block *block,
 
 namespace {
 struct ParallelLoopTiling
-    : public PassWrapper<ParallelLoopTiling, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LoopParallelLoopTiling
-#include "mlir/Dialect/LoopOps/Passes.h.inc"
-
+    : public LoopParallelLoopTilingBase<ParallelLoopTiling> {
   ParallelLoopTiling() = default;
-  ParallelLoopTiling(const ParallelLoopTiling &) {}
   explicit ParallelLoopTiling(ArrayRef<int64_t> 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
index 000000000000..9fa8a350d004
--- /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
index d892f67a23d7..8f9f55d175a9 100644
--- 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<ConvertConstPass, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_QuantConvertConst
-#include "mlir/Dialect/Quant/Passes.h.inc"
-
+struct ConvertConstPass : public QuantConvertConstBase<ConvertConstPass> {
   void runOnFunction() override;
 };
 

diff  --git a/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp
index 079c3ff96ad1..2cb077a25bb1 100644
--- 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<ConvertSimulatedQuantPass, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_QuantConvertSimulatedQuant
-#include "mlir/Dialect/Quant/Passes.h.inc"
-
+    : public QuantConvertSimulatedQuantBase<ConvertSimulatedQuantPass> {
   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
index 000000000000..8727bfc8b2aa
--- /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
index a0b2c168985f..b4674afbd980 100644
--- 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 @@ static void populateSPIRVLayoutInfoPatterns(OwningRewritePatternList &patterns,
 
 namespace {
 class DecorateSPIRVCompositeTypeLayoutPass
-    : public PassWrapper<DecorateSPIRVCompositeTypeLayoutPass,
-                         OperationPass<ModuleOp>> {
-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
index d666f9697374..101536d1afe9 100644
--- 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 @@ class ProcessInterfaceVarABI final : public SPIRVOpLowering<spirv::FuncOp> {
 
 /// Pass to implement the ABI information specified as attributes.
 class LowerABIAttributesPass final
-    : public PassWrapper<LowerABIAttributesPass,
-                         OperationPass<spirv::ModuleOp>> {
-private:
+    : public SPIRVLowerABIAttributesBase<LowerABIAttributesPass> {
   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
index 000000000000..3c56f21e9360
--- /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
index 415535b6da97..8adbc76a3a03 100644
--- 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 @@ using namespace mlir;
 namespace {
 /// Pass to deduce minimal version/extension/capability requirements for a
 /// spirv::ModuleOp.
-class UpdateVCEPass final
-    : public PassWrapper<UpdateVCEPass, OperationPass<spirv::ModuleOp>> {
-private:
+class UpdateVCEPass final : public SPIRVUpdateVCEBase<UpdateVCEPass> {
   void runOnOperation() override;
 };
 } // namespace

diff  --git a/mlir/lib/TableGen/Pass.cpp b/mlir/lib/TableGen/Pass.cpp
index 63f31c99bc90..4bc46b622c2b 100644
--- a/mlir/lib/TableGen/Pass.cpp
+++ b/mlir/lib/TableGen/Pass.cpp
@@ -75,6 +75,10 @@ StringRef Pass::getArgument() const {
   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
index 919c957f3d9d..8309099e92a7 100644
--- 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 <deque>
+
 using namespace mlir;
 
 namespace {
@@ -73,14 +71,7 @@ struct SimpleOperationInfo : public llvm::DenseMapInfo<Operation *> {
 
 namespace {
 /// Simple common sub-expression elimination.
-struct CSE : public PassWrapper<CSE, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_CSE
-#include "mlir/Transforms/Passes.h.inc"
-
-  CSE() = default;
-  CSE(const CSE &) {}
-
+struct CSE : public CSEBase<CSE> {
   /// 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
index 3f3d30296785..c46a8b9fa31e 100644
--- 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 @@ using namespace mlir;
 
 namespace {
 /// Canonicalize operations in nested regions.
-struct Canonicalizer : public PassWrapper<Canonicalizer, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_Canonicalizer
-#include "mlir/Transforms/Passes.h.inc"
-
+struct Canonicalizer : public CanonicalizerBase<Canonicalizer> {
   void runOnOperation() override {
     OwningRewritePatternList patterns;
 

diff  --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp
index 60382ea64f76..582f720a4841 100644
--- 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 @@ static void inlineSCC(Inliner &inliner, CGUseList &useList,
 //===----------------------------------------------------------------------===//
 
 namespace {
-struct InlinerPass : public PassWrapper<InlinerPass, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_Inliner
-#include "mlir/Transforms/Passes.h.inc"
-
+struct InlinerPass : public InlinerBase<InlinerPass> {
   void runOnOperation() override {
     CallGraph &cg = getAnalysis<CallGraph>();
     auto *context = &getContext();

diff  --git a/mlir/lib/Transforms/LocationSnapshot.cpp b/mlir/lib/Transforms/LocationSnapshot.cpp
index e9858bc142e8..0b1d929db98a 100644
--- 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 @@ LogicalResult mlir::generateLocationsFromIR(StringRef fileName, StringRef tag,
 
 namespace {
 struct LocationSnapshotPass
-    : public PassWrapper<LocationSnapshotPass, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LocationSnapshot
-#include "mlir/Transforms/Passes.h.inc"
-
+    : public LocationSnapshotBase<LocationSnapshotPass> {
   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
index 57d8e2a26d67..d47b37742f62 100644
--- 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<LoopCoalescingPass, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LoopCoalescing
-#include "mlir/Transforms/Passes.h.inc"
-
+struct LoopCoalescingPass : public LoopCoalescingBase<LoopCoalescingPass> {
   void runOnFunction() override {
     FuncOp func = getFunction();
 

diff  --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp
index f802ba526b25..47ee502b41fb 100644
--- 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 @@ namespace {
 // TODO(andydavis) Extend this pass to check for fusion preventing dependences,
 // and add support for more general loop fusion algorithms.
 
-struct LoopFusion : public PassWrapper<LoopFusion, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_AffineLoopFusion
-#include "mlir/Transforms/Passes.h.inc"
-
+struct LoopFusion : public AffineLoopFusionBase<LoopFusion> {
   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
index e7e48ac40714..dacd688a7f36 100644
--- 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 @@ using namespace mlir;
 namespace {
 /// Loop invariant code motion (LICM) pass.
 struct LoopInvariantCodeMotion
-    : public PassWrapper<LoopInvariantCodeMotion, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_LoopInvariantCodeMotion
-#include "mlir/Transforms/Passes.h.inc"
-
+    : public LoopInvariantCodeMotionBase<LoopInvariantCodeMotion> {
   void runOnOperation() override;
 };
 } // end anonymous namespace

diff  --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
index 5b03de923991..a0a41758e1a8 100644
--- 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 <algorithm>
@@ -60,11 +60,7 @@ namespace {
 // currently only eliminates the stores only if no other loads/uses (other
 // than dealloc) remain.
 //
-struct MemRefDataFlowOpt : public PassWrapper<MemRefDataFlowOpt, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_MemRefDataFlowOpt
-#include "mlir/Transforms/Passes.h.inc"
-
+struct MemRefDataFlowOpt : public MemRefDataFlowOptBase<MemRefDataFlowOpt> {
   void runOnFunction() override;
 
   void forwardStoreToLoad(AffineLoadOp loadOp);

diff  --git a/mlir/lib/Transforms/OpStats.cpp b/mlir/lib/Transforms/OpStats.cpp
index 667a0b4f4f57..7d6491085119 100644
--- 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<PrintOpStatsPass, OperationPass<ModuleOp>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_PrintOpStats
-#include "mlir/Transforms/Passes.h.inc"
-
+struct PrintOpStatsPass : public PrintOpStatsBase<PrintOpStatsPass> {
   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
index 4380fe30d089..16ecb8475cfb 100644
--- 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 @@ using namespace mlir;
 
 namespace {
 struct ParallelLoopCollapsing
-    : public PassWrapper<ParallelLoopCollapsing, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_ParallelLoopCollapsing
-#include "mlir/Transforms/Passes.h.inc"
-
-  ParallelLoopCollapsing() = default;
-  ParallelLoopCollapsing(const ParallelLoopCollapsing &) {}
+    : public ParallelLoopCollapsingBase<ParallelLoopCollapsing> {
   void runOnOperation() override {
     Operation *module = getOperation();
 
@@ -45,7 +38,6 @@ struct ParallelLoopCollapsing
     });
   }
 };
-
 } // namespace
 
 std::unique_ptr<Pass> mlir::createParallelLoopCollapsingPass() {

diff  --git a/mlir/lib/Transforms/PassDetail.h b/mlir/lib/Transforms/PassDetail.h
new file mode 100644
index 000000000000..c6f7e225d71a
--- /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
index 8eeea89d73f6..01aa25ab0a5c 100644
--- 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 @@ using namespace mlir;
 
 namespace {
 struct PipelineDataTransfer
-    : public PassWrapper<PipelineDataTransfer, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_AffinePipelineDataTransfer
-#include "mlir/Transforms/Passes.h.inc"
-
+    : public AffinePipelineDataTransferBase<PipelineDataTransfer> {
   void runOnFunction() override;
   void runOnAffineForOp(AffineForOp forOp);
 

diff  --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp
index e5ba14402515..15ce1c200c8a 100644
--- 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<StripDebugInfo, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_StripDebugInfo
-#include "mlir/Transforms/Passes.h.inc"
-
+struct StripDebugInfo : public StripDebugInfoBase<StripDebugInfo> {
   void runOnOperation() override;
 };
 } // end anonymous namespace

diff  --git a/mlir/lib/Transforms/SymbolDCE.cpp b/mlir/lib/Transforms/SymbolDCE.cpp
index 251a956be75d..581857a6a92e 100644
--- 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<SymbolDCE, OperationPass<>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_SymbolDCE
-#include "mlir/Transforms/Passes.h.inc"
-
+struct SymbolDCE : public SymbolDCEBase<SymbolDCE> {
   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
index 8ac61fc4b815..41e33e8a178c 100644
--- 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 @@ namespace {
 // PrintOpPass is simple pass to write graph per function.
 // Note: this is a module pass only to avoid interleaving on the same ostream
 // due to multi-threading over functions.
-struct PrintOpPass : public PassWrapper<PrintOpPass, OperationPass<ModuleOp>> {
-/// Include the generated pass utilities.
-#define GEN_PASS_PrintOpGraph
-#include "mlir/Transforms/Passes.h.inc"
-
+struct PrintOpPass : public PrintOpBase<PrintOpPass> {
   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
index 4f31a79cd9d3..0c67f30c19cb 100644
--- 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(const Twine &regionName) {
 void mlir::Region::viewGraph() { viewGraph("region"); }
 
 namespace {
-struct PrintCFGPass : public PassWrapper<PrintCFGPass, FunctionPass> {
-/// Include the generated pass utilities.
-#define GEN_PASS_PrintCFG
-#include "mlir/Transforms/Passes.h.inc"
-
+struct PrintCFGPass : public PrintCFGBase<PrintCFGPass> {
   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
index d55468a0f386..c4ebafc4893e 100644
--- a/mlir/tools/mlir-tblgen/PassDocGen.cpp
+++ b/mlir/tools/mlir-tblgen/PassDocGen.cpp
@@ -58,7 +58,7 @@ static void emitDoc(const Pass &pass, raw_ostream &os) {
 
 static void emitDocs(const llvm::RecordKeeper &recordKeeper, raw_ostream &os) {
   os << "<!-- Autogenerated by mlir-tblgen; don't manually edit -->\n";
-  auto passDefs = recordKeeper.getAllDerivedDefinitions("Pass");
+  auto passDefs = recordKeeper.getAllDerivedDefinitions("PassBase");
 
   // Collect the registered passes, sorted by argument name.
   SmallVector<Pass, 16> passes(passDefs.begin(), passDefs.end());

diff  --git a/mlir/tools/mlir-tblgen/PassGen.cpp b/mlir/tools/mlir-tblgen/PassGen.cpp
index 4cda353953ad..487bea6afa7b 100644
--- a/mlir/tools/mlir-tblgen/PassGen.cpp
+++ b/mlir/tools/mlir-tblgen/PassGen.cpp
@@ -28,22 +28,36 @@ using namespace mlir::tblgen;
 /// 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 <typename DerivedT>
+class {0}Base : public {1} {
+public:
+  {0}Base() : {1}(PassID::getID<DerivedT>()) {{}
+  {0}Base(const {0}Base &) : {1}(PassID::getID<DerivedT>()) {{}
+
   /// 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<DerivedT>();
+  }
+
+  /// A clone method to create a copy of this pass.
+  std::unique_ptr<Pass> clonePass() const override {{
+    return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
+  }
+
+protected:
 )";
 
 /// Emit the declarations for each of the pass options.
@@ -73,10 +87,21 @@ static void emitPassStatisticDecls(const Pass &pass, raw_ostream &os) {
 
 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<Pass> 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 emitRegistration(ArrayRef<Pass> passes, raw_ostream &os) {
 
 static void emitDecls(const llvm::RecordKeeper &recordKeeper, raw_ostream &os) {
   os << "/* Autogenerated by mlir-tblgen; don't manually edit */\n";
-
   std::vector<Pass> 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);
 }
 


        


More information about the Mlir-commits mailing list