| Issue |
53145
|
| Summary |
Auto-generate a struct that allows pipelines to control pass options.
|
| Labels |
mlir:core
|
| Assignees |
|
| Reporter |
MaheshRavishankar
|
MLIR passes can define [`PassOptions`](https://mlir.llvm.org/docs/PassManagement/#declarative-pass-specification) in tablegen. These options are controllable through command line. The same control though is not available to pass pipelines that add passes using the `create*` methods. For example a pass can be defined in Tablegen as follows
```
struct FooPass : ... {
...
Option<bool> option1 {..};
Option<int> option2 {..};
}
```
The only way to control this is to have the following code in C++
```
struct FooPass : public FooPassBase<...> {
FooPass(bool v1, int v2) {
this->option1.assign(v1);
this->option2.assign(v2);
}
}
...
std::unqiue_ptr<Pass> createFooPass(bool v1, int v2) {
return std::make_unique<FooPass>(v1, v2);
}
```
This is a manual process and each pass needs to explicitly declare the require pass constructor methods and `create*` method to allows pass pipelines to control the options as well. Apart from a lot of boiler plate, each time a new option is added, the constructor and `create*` method signature changes.
A way around this is to have Tablegen automatically generate a `struct` that mirrors all the options specified. So for the above example you would have the following struct generated.
```
struct FooPassOptions {
bool option1;
int option2;
};
```
Then you could modify the pass constructors and `create*` methods to use this generated struct.
Note: Ideally the constructor and the `create*` methods could also be auto-generated, but chatting offline about this with @joker-eph seems like thats not very straight-forward. So having the `struct` auto-generated will at least let passes define constructors and `create*` methods that allow easily manipulation of options from a pass pipeline.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs