[Mlir-commits] [mlir] [mlir][spirv] Make ConvertToSPIRVPass into a test pass (non-public) (PR #124301)

Jakub Kuderski llvmlistbot at llvm.org
Fri Jan 24 08:49:48 PST 2025


================
@@ -71,9 +66,44 @@ void populateConvertToSPIRVPatterns(const SPIRVTypeConverter &typeConverter,
 }
 
 /// A pass to perform the SPIR-V conversion.
-struct ConvertToSPIRVPass final
-    : impl::ConvertToSPIRVPassBase<ConvertToSPIRVPass> {
-  using ConvertToSPIRVPassBase::ConvertToSPIRVPassBase;
+struct TestConvertToSPIRVPass final
+    : PassWrapper<TestConvertToSPIRVPass, OperationPass<>> {
+  Option<bool> runSignatureConversion{
+      *this, "run-signature-conversion",
+      llvm::cl::desc(
+          "Run function signature conversion to convert vector types"),
+      llvm::cl::init(true)};
+  Option<bool> runVectorUnrolling{
+      *this, "run-vector-unrolling",
+      llvm::cl::desc(
+          "Run vector unrolling to convert vector types in function bodies"),
+      llvm::cl::init(true)};
+  Option<bool> convertGPUModules{
+      *this, "convert-gpu-modules",
+      llvm::cl::desc("Clone and convert GPU modules"), llvm::cl::init(false)};
+  Option<bool> nestInGPUModule{
+      *this, "nest-in-gpu-module",
+      llvm::cl::desc("Put converted SPIR-V module inside the gpu.module "
+                     "instead of alongside it."),
+      llvm::cl::init(false)};
+
+  MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestConvertToSPIRVPass)
+
+  StringRef getArgument() const final { return "test-convert-to-spirv"; }
+  StringRef getDescription() const final {
+    return "Conversion to SPIR-V pass only used for internal tests.";
+  }
+  void getDependentDialects(DialectRegistry &registry) const override {
+    registry.insert<spirv::SPIRVDialect>();
+    registry.insert<vector::VectorDialect>();
+  }
+
+  TestConvertToSPIRVPass() = default;
+  TestConvertToSPIRVPass(bool convertGPUModules, bool nestInGPUModule) {
+    this->convertGPUModules = std::move(convertGPUModules);
+    this->nestInGPUModule = std::move(nestInGPUModule);
+  };
+  TestConvertToSPIRVPass(const TestConvertToSPIRVPass &) {}
----------------
kuhar wrote:

```suggestion
  TestConvertToSPIRVPass(const TestConvertToSPIRVPass &) = default;
```
to be consistent with the other constructor above

https://github.com/llvm/llvm-project/pull/124301


More information about the Mlir-commits mailing list