diff --git a/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h b/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h --- a/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h +++ b/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h @@ -31,43 +31,6 @@ #define GEN_PASS_DECL #include "mlir/Dialect/SPIRV/Transforms/Passes.h.inc" -/// Creates a pass to run canoncalization patterns that involve GL ops. -/// These patterns cannot be run in default canonicalization because GL ops -/// aren't always available. So they should be involed specifically when needed. -std::unique_ptr> createCanonicalizeGLPass(); - -/// Creates a module pass that converts composite types used by objects in the -/// StorageBuffer, PhysicalStorageBuffer, Uniform, and PushConstant storage -/// classes with layout information. -/// Right now this pass only supports Vulkan layout rules. -std::unique_ptr> -createDecorateSPIRVCompositeTypeLayoutPass(); - -/// Creates an operation pass that deduces and attaches the minimal version/ -/// capabilities/extensions requirements for spirv.module ops. -/// For each spirv.module op, this pass requires a `spirv.target_env` attribute -/// on it or an enclosing module-like op to drive the deduction. The reason is -/// that an op can be enabled by multiple extensions/capabilities. So we need -/// to know which one to pick. `spirv.target_env` gives the hard limit as for -/// what the target environment can support; this pass deduces what are -/// actually needed for a specific spirv.module op. -std::unique_ptr> -createUpdateVersionCapabilityExtensionPass(); - -/// Creates an operation pass that lowers the ABI attributes specified during -/// SPIR-V Lowering. Specifically, -/// 1. Creates the global variables for arguments of entry point function using -/// the specification in the `spirv.interface_var_abi` attribute for each -/// argument. -/// 2. Inserts the EntryPointOp and the ExecutionModeOp for entry point -/// functions using the specification in the `spirv.entry_point_abi` -/// attribute. -std::unique_ptr> createLowerABIAttributesPass(); - -/// Creates an operation pass that rewrites sequential chains of -/// spirv.CompositeInsert into spirv.CompositeConstruct. -std::unique_ptr> createRewriteInsertsPass(); - /// Creates an operation pass that unifies access of multiple aliased resources /// into access of one single resource. using GetTargetEnvFn = std::function; diff --git a/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td b/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td @@ -11,26 +11,43 @@ include "mlir/Pass/PassBase.td" -def SPIRVCompositeTypeLayout - : Pass<"decorate-spirv-composite-type-layout", "mlir::ModuleOp"> { - let summary = "Decorate SPIR-V composite type with layout info"; - let constructor = "mlir::spirv::createDecorateSPIRVCompositeTypeLayoutPass()"; +def SPIRVCanonicalizeGLPass : Pass<"spirv-canonicalize-gl", ""> { + let summary = "Canonicalize GLSL ops"; + let description = [{ + Pass to run canoncalization patterns that involve GL ops. + These patterns cannot be run in default canonicalization because GL ops + aren't always available. So they should be involed specifically when needed. + }]; } -def SPIRVCanonicalizeGL : Pass<"spirv-canonicalize-gl", ""> { - let summary = "Run canonicalization involving GLSL ops"; - let constructor = "mlir::spirv::createCanonicalizeGLPass()"; +def SPIRVCompositeTypeLayoutPass + : Pass<"decorate-spirv-composite-type-layout", "mlir::ModuleOp"> { + let summary = "Decorate SPIR-V composite type with layout info"; + let description = [{ + Module pass that converts composite types used by objects in the + StorageBuffer, PhysicalStorageBuffer, Uniform, and PushConstant storage + classes to attatch layout information. + Right now this pass only supports Vulkan layout rules. + }]; } -def SPIRVLowerABIAttributes : Pass<"spirv-lower-abi-attrs", "spirv::ModuleOp"> { +def SPIRVLowerABIAttributesPass : Pass<"spirv-lower-abi-attrs", "spirv::ModuleOp"> { let summary = "Decorate SPIR-V composite type with layout info"; - let constructor = "mlir::spirv::createLowerABIAttributesPass()"; + let description = [{ + Operation pass that lowers the ABI attributes specified during + SPIR-V Lowering. Specifically: + 1. Creates the global variables for arguments of entry point function using + the specification in the `spirv.interface_var_abi` attribute for each + argument. + 2. Inserts the EntryPointOp and the ExecutionModeOp for entry point + functions using the specification in the `spirv.entry_point_abi` + attribute. + }]; } def SPIRVRewriteInsertsPass : Pass<"spirv-rewrite-inserts", "spirv::ModuleOp"> { - let summary = "Rewrite sequential chains of spirv.CompositeInsert operations into " - "spirv.CompositeConstruct operations"; - let constructor = "mlir::spirv::createRewriteInsertsPass()"; + let summary = "Rewrite sequential chains of `spirv.CompositeInsert` operations " + "into `spirv.CompositeConstruct` operations"; } def SPIRVUnifyAliasedResourcePass @@ -40,10 +57,19 @@ let constructor = "mlir::spirv::createUnifyAliasedResourcePass()"; } -def SPIRVUpdateVCE : Pass<"spirv-update-vce", "spirv::ModuleOp"> { +def SPIRVUpdateVCEPass : Pass<"spirv-update-vce", "spirv::ModuleOp"> { let summary = "Deduce and attach minimal (version, capabilities, extensions) " "requirements to spirv.module ops"; - let constructor = "mlir::spirv::createUpdateVersionCapabilityExtensionPass()"; + let description = [{ + Operation pass that deduces and attaches the minimal version/ + capabilities/extensions requirements for spirv.module ops. + For each spirv.module op, this pass requires a `spirv.target_env` attribute + on it or an enclosing module-like op to drive the deduction. The reason is + that an op can be enabled by multiple extensions/capabilities. So we need + to know which one to pick. `spirv.target_env` gives the hard limit as for + what the target environment can support; this pass deduces what are + actually needed for a specific spirv.module op. + }]; } def SPIRVWebGPUPreparePass : Pass<"spirv-webgpu-prepare", "spirv::ModuleOp"> { diff --git a/mlir/lib/Dialect/SPIRV/Transforms/CanonicalizeGLPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/CanonicalizeGLPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/CanonicalizeGLPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/CanonicalizeGLPass.cpp @@ -15,7 +15,7 @@ namespace mlir { namespace spirv { -#define GEN_PASS_DEF_SPIRVCANONICALIZEGL +#define GEN_PASS_DEF_SPIRVCANONICALIZEGLPASS #include "mlir/Dialect/SPIRV/Transforms/Passes.h.inc" } // namespace spirv } // namespace mlir @@ -24,7 +24,7 @@ namespace { class CanonicalizeGLPass final - : public spirv::impl::SPIRVCanonicalizeGLBase { + : public spirv::impl::SPIRVCanonicalizeGLPassBase { public: void runOnOperation() override { RewritePatternSet patterns(&getContext()); @@ -35,7 +35,3 @@ } }; } // namespace - -std::unique_ptr> spirv::createCanonicalizeGLPass() { - return std::make_unique(); -} diff --git a/mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp @@ -25,7 +25,7 @@ namespace mlir { namespace spirv { -#define GEN_PASS_DEF_SPIRVCOMPOSITETYPELAYOUT +#define GEN_PASS_DEF_SPIRVCOMPOSITETYPELAYOUTPASS #include "mlir/Dialect/SPIRV/Transforms/Passes.h.inc" } // namespace spirv } // namespace mlir @@ -106,7 +106,7 @@ namespace { class DecorateSPIRVCompositeTypeLayoutPass - : public spirv::impl::SPIRVCompositeTypeLayoutBase< + : public spirv::impl::SPIRVCompositeTypeLayoutPassBase< DecorateSPIRVCompositeTypeLayoutPass> { void runOnOperation() override; }; @@ -146,8 +146,3 @@ if (failed(applyFullConversion(spirvModule, target, frozenPatterns))) signalPassFailure(); } - -std::unique_ptr> -mlir::spirv::createDecorateSPIRVCompositeTypeLayoutPass() { - return std::make_unique(); -} diff --git a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp @@ -26,7 +26,7 @@ namespace mlir { namespace spirv { -#define GEN_PASS_DEF_SPIRVLOWERABIATTRIBUTES +#define GEN_PASS_DEF_SPIRVLOWERABIATTRIBUTESPASS #include "mlir/Dialect/SPIRV/Transforms/Passes.h.inc" } // namespace spirv } // namespace mlir @@ -199,7 +199,8 @@ /// Pass to implement the ABI information specified as attributes. class LowerABIAttributesPass final - : public spirv::impl::SPIRVLowerABIAttributesBase { + : public spirv::impl::SPIRVLowerABIAttributesPassBase< + LowerABIAttributesPass> { void runOnOperation() override; }; } // namespace @@ -322,8 +323,3 @@ } } } - -std::unique_ptr> -mlir::spirv::createLowerABIAttributesPass() { - return std::make_unique(); -} diff --git a/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp @@ -117,8 +117,3 @@ } return failure(); } - -std::unique_ptr> -mlir::spirv::createRewriteInsertsPass() { - return std::make_unique(); -} diff --git a/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp @@ -25,7 +25,7 @@ namespace mlir { namespace spirv { -#define GEN_PASS_DEF_SPIRVUPDATEVCE +#define GEN_PASS_DEF_SPIRVUPDATEVCEPASS #include "mlir/Dialect/SPIRV/Transforms/Passes.h.inc" } // namespace spirv } // namespace mlir @@ -36,7 +36,7 @@ /// Pass to deduce minimal version/extension/capability requirements for a /// spirv::ModuleOp. class UpdateVCEPass final - : public spirv::impl::SPIRVUpdateVCEBase { + : public spirv::impl::SPIRVUpdateVCEPassBase { void runOnOperation() override; }; } // namespace @@ -184,8 +184,3 @@ deducedExtensions.getArrayRef(), &getContext()); module->setAttr(spirv::ModuleOp::getVCETripleAttrName(), triple); } - -std::unique_ptr> -mlir::spirv::createUpdateVersionCapabilityExtensionPass() { - return std::make_unique(); -} diff --git a/mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp b/mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp --- a/mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp +++ b/mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp @@ -83,8 +83,8 @@ passManager.addPass(createConvertGPUToSPIRVPass(/*mapMemorySpace=*/true)); OpPassManager &nestedPM = passManager.nest(); - nestedPM.addPass(spirv::createLowerABIAttributesPass()); - nestedPM.addPass(spirv::createUpdateVersionCapabilityExtensionPass()); + nestedPM.addPass(spirv::createSPIRVLowerABIAttributesPass()); + nestedPM.addPass(spirv::createSPIRVUpdateVCEPass()); passManager.addPass(createLowerHostCodeToLLVMPass()); passManager.addPass(createConvertSPIRVToLLVMPass()); return passManager.run(module); diff --git a/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp b/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp --- a/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp +++ b/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp @@ -63,8 +63,8 @@ passManager.addPass(createConvertGPUToSPIRVPass(/*mapMemorySpace=*/true)); OpPassManager &modulePM = passManager.nest(); - modulePM.addPass(spirv::createLowerABIAttributesPass()); - modulePM.addPass(spirv::createUpdateVersionCapabilityExtensionPass()); + modulePM.addPass(spirv::createSPIRVLowerABIAttributesPass()); + modulePM.addPass(spirv::createSPIRVUpdateVCEPass()); if (options.spirvWebGPUPrepare) modulePM.addPass(spirv::createSPIRVWebGPUPreparePass());