@@ -133,6 +133,51 @@ struct TestOptionsSuperPass
133133 llvm::cl::desc (" Example list of PassPipelineOptions option" )};
134134};
135135
136+ struct TestOptionsPassA
137+ : public PassWrapper<TestOptionsPassA, OperationPass<func::FuncOp>> {
138+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID (TestOptionsPass)
139+
140+ struct Options : public PassPipelineOptions <Options> {
141+ Option<bool > foo{*this , " foo" , llvm::cl::desc (" Example boolean option" )};
142+ };
143+
144+ TestOptionsPassA () = default ;
145+ TestOptionsPassA (const TestOptionsPassA &) : PassWrapper() {}
146+ TestOptionsPassA (const Options &options) { this ->options .foo = options.foo ; }
147+
148+ void runOnOperation () final {}
149+ StringRef getArgument () const final { return " test-options-pass-a" ; }
150+ StringRef getDescription () const final {
151+ return " Test superset options parsing capabilities - subset A" ;
152+ }
153+
154+ Options options;
155+ };
156+
157+ struct TestOptionsPassB
158+ : public PassWrapper<TestOptionsPassB, OperationPass<func::FuncOp>> {
159+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID (TestOptionsPass)
160+
161+ struct Options : public PassPipelineOptions <Options> {
162+ Option<bool > bar{*this , " bar" , llvm::cl::desc (" Example boolean option" )};
163+ };
164+
165+ TestOptionsPassB () = default ;
166+ TestOptionsPassB (const TestOptionsPassB &) : PassWrapper() {}
167+ TestOptionsPassB (const Options &options) { this ->options .bar = options.bar ; }
168+
169+ void runOnOperation () final {}
170+ StringRef getArgument () const final { return " test-options-pass-b" ; }
171+ StringRef getDescription () const final {
172+ return " Test superset options parsing capabilities - subset B" ;
173+ }
174+
175+ Options options;
176+ };
177+
178+ struct TestPipelineOptionsSuperSetAB : TestOptionsPassA::Options,
179+ TestOptionsPassB::Options {};
180+
136181// / A test pass that always aborts to enable testing the crash recovery
137182// / mechanism of the pass manager.
138183struct TestCrashRecoveryPass
@@ -270,6 +315,9 @@ void registerPassManagerTestPass() {
270315 PassRegistration<TestOptionsPass>();
271316 PassRegistration<TestOptionsSuperPass>();
272317
318+ PassRegistration<TestOptionsPassA>();
319+ PassRegistration<TestOptionsPassB>();
320+
273321 PassRegistration<TestModulePass>();
274322
275323 PassRegistration<TestFunctionPass>();
@@ -306,5 +354,16 @@ void registerPassManagerTestPass() {
306354 [](OpPassManager &pm, const TestOptionsSuperPass::Options &options) {
307355 pm.addPass (std::make_unique<TestOptionsSuperPass>(options));
308356 });
357+
358+ PassPipelineRegistration<TestPipelineOptionsSuperSetAB>
359+ registerPipelineOptionsSuperSetABPipeline (
360+ " test-options-super-set-ab-pipeline" ,
361+ " Parses options of PassPipelineOptions using pass pipeline "
362+ " registration" ,
363+ [](OpPassManager &pm, const TestPipelineOptionsSuperSetAB &options) {
364+ // Pass superset AB options to subset options A and B
365+ pm.addPass (std::make_unique<TestOptionsPassA>(options));
366+ pm.addPass (std::make_unique<TestOptionsPassB>(options));
367+ });
309368}
310369} // namespace mlir
0 commit comments