|
6 | 6 | // |
7 | 7 | //===----------------------------------------------------------------------===// |
8 | 8 |
|
| 9 | +#include "mlir/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.h" |
9 | 10 | #include "mlir/Conversion/ArithToSPIRV/ArithToSPIRV.h" |
10 | 11 | #include "mlir/Conversion/FuncToSPIRV/FuncToSPIRV.h" |
11 | 12 | #include "mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h" |
|
24 | 25 | #include "mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h" |
25 | 26 | #include "mlir/IR/PatternMatch.h" |
26 | 27 | #include "mlir/Pass/Pass.h" |
27 | | -#include "mlir/Pass/PassOptions.h" |
28 | 28 | #include "mlir/Rewrite/FrozenRewritePatternSet.h" |
29 | 29 | #include "mlir/Transforms/DialectConversion.h" |
30 | 30 | #include "mlir/Transforms/GreedyPatternRewriteDriver.h" |
31 | 31 | #include <memory> |
32 | 32 |
|
33 | | -#define DEBUG_TYPE "test-convert-to-spirv" |
| 33 | +#define DEBUG_TYPE "convert-to-spirv" |
| 34 | + |
| 35 | +namespace mlir { |
| 36 | +#define GEN_PASS_DEF_CONVERTTOSPIRVPASS |
| 37 | +#include "mlir/Conversion/Passes.h.inc" |
| 38 | +} // namespace mlir |
34 | 39 |
|
35 | 40 | using namespace mlir; |
36 | 41 |
|
@@ -66,44 +71,9 @@ void populateConvertToSPIRVPatterns(const SPIRVTypeConverter &typeConverter, |
66 | 71 | } |
67 | 72 |
|
68 | 73 | /// A pass to perform the SPIR-V conversion. |
69 | | -struct TestConvertToSPIRVPass final |
70 | | - : PassWrapper<TestConvertToSPIRVPass, OperationPass<>> { |
71 | | - Option<bool> runSignatureConversion{ |
72 | | - *this, "run-signature-conversion", |
73 | | - llvm::cl::desc( |
74 | | - "Run function signature conversion to convert vector types"), |
75 | | - llvm::cl::init(true)}; |
76 | | - Option<bool> runVectorUnrolling{ |
77 | | - *this, "run-vector-unrolling", |
78 | | - llvm::cl::desc( |
79 | | - "Run vector unrolling to convert vector types in function bodies"), |
80 | | - llvm::cl::init(true)}; |
81 | | - Option<bool> convertGPUModules{ |
82 | | - *this, "convert-gpu-modules", |
83 | | - llvm::cl::desc("Clone and convert GPU modules"), llvm::cl::init(false)}; |
84 | | - Option<bool> nestInGPUModule{ |
85 | | - *this, "nest-in-gpu-module", |
86 | | - llvm::cl::desc("Put converted SPIR-V module inside the gpu.module " |
87 | | - "instead of alongside it."), |
88 | | - llvm::cl::init(false)}; |
89 | | - |
90 | | - MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestConvertToSPIRVPass) |
91 | | - |
92 | | - StringRef getArgument() const final { return "test-convert-to-spirv"; } |
93 | | - StringRef getDescription() const final { |
94 | | - return "Conversion to SPIR-V pass only used for internal tests."; |
95 | | - } |
96 | | - void getDependentDialects(DialectRegistry ®istry) const override { |
97 | | - registry.insert<spirv::SPIRVDialect>(); |
98 | | - registry.insert<vector::VectorDialect>(); |
99 | | - } |
100 | | - |
101 | | - TestConvertToSPIRVPass() = default; |
102 | | - TestConvertToSPIRVPass(bool convertGPUModules, bool nestInGPUModule) { |
103 | | - this->convertGPUModules = convertGPUModules; |
104 | | - this->nestInGPUModule = nestInGPUModule; |
105 | | - }; |
106 | | - TestConvertToSPIRVPass(const TestConvertToSPIRVPass &) {} |
| 74 | +struct ConvertToSPIRVPass final |
| 75 | + : impl::ConvertToSPIRVPassBase<ConvertToSPIRVPass> { |
| 76 | + using ConvertToSPIRVPassBase::ConvertToSPIRVPassBase; |
107 | 77 |
|
108 | 78 | void runOnOperation() override { |
109 | 79 | Operation *op = getOperation(); |
@@ -164,14 +134,3 @@ struct TestConvertToSPIRVPass final |
164 | 134 | }; |
165 | 135 |
|
166 | 136 | } // namespace |
167 | | - |
168 | | -namespace mlir::test { |
169 | | -void registerTestConvertToSPIRVPass() { |
170 | | - PassRegistration<TestConvertToSPIRVPass>(); |
171 | | -} |
172 | | -std::unique_ptr<Pass> createTestConvertToSPIRVPass(bool convertGPUModules, |
173 | | - bool nestInGPUModule) { |
174 | | - return std::make_unique<TestConvertToSPIRVPass>(convertGPUModules, |
175 | | - nestInGPUModule); |
176 | | -} |
177 | | -} // namespace mlir::test |
0 commit comments