<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJylVt9v2zgM_mucFyJGYjdt-pCHJN2AAevusNv7IFt0rFW2XElOlv_-SFlJnLYrejjASGSZ4o-P_CgWRh5Xj1-_fIdOOIcOStGCxEq1CMlik9zO_qb9vzqvTOvoLVk8JNmy9r5zSb5Oss_0NFrZVOt9kxq7o3dpSkd_fPBRtGKHDbY-iOYSSy2s8GqPUzY4dR2WqlKlYANJdg-qBS8KjTtsU_hRo0Mwg3UQFqE0rbdGaxYBX1vT72rabBrRStDkdTgETjRnWRILUspBazyIvVDxuAlBQ6c65KOOJAUJSHkCo3eq3dEuYXE7Ky0Kj0m2pjU0SFqlS-GzsYC_RdORQjHoYwgLjChKjuhHjAiEg4q8NweXzB6S2Tr-Eq7DE16dt33pSbNhCIFwhjRNIbnbDN8B-P28HpKT5NvCGJ3knyJecz5AYncPSb55LawoJWfZ7LUsr99ybvhljE2rj3AQR8bxAjWhTA9t1WKPAbohYAayNBIZjm2Sbfj5TxB0faFVedraCIcUBeNAUYygid-pSBkO2M-TbEs2PewzLq8xiBDcnZKCiFhKB9WOynDJx-7HuL2UzUay2bXsBbnT4pwt5yWzJl_37bPq8WfnLQUR_KUohgL7eAAWfW9bOCttxBP-7Fv13DM0Jz35pxjPFq49Jffg3RQPqRRA3OqFhs6aEikZzDQUZT0Ue4soQ77xd0f5UZ6KYmD5kH2Lz72i9cAMonHILJEmMiioe5tdrFUEsrzi6bjiRg3CwQG1TmHdCeuhsqYh9zWR3lRQGKXRQqeDme0QglcN07bFQ1QSIpYSJYuw7rHL77jKtSAoHXSgFu0OXTrGch14IqhbkYaXHLk0h96bhhphSUEfgXaQOiW7R3YGH9hg6FGNstZYx_BcIRDbKcoU_jHEPBu-isKQnVOXOpoeDqbX8i2KRuKdjMv0wySNd8S4QEMBR26NCMLFHFl01W7O6z90nDa4XgbXGyNVdQzOv6ys90oqoN47HJJwjjKGncLY4jdDh6nxfJEYEvJWNbxzNURHhXaGbwNO7vRskKur6D0Xi_eMu6kqLm1OFW0H7w7K15DczH6ZJ7RT7GpwiI2jW-4JQxUM99ke7ZH9F2pX-yml_CDskH5K7-j6ulTQtStkh4qIakqjcPzrT7dfHAM-Dm24PbmSiFxOEWTUOVTX63C5MwdPZRqZecXqq0qbyFUu7_N7MSFna2NXj4JGgfo7ReSIX0_CTnqrV9dzyI4A64uUpgF64Xkk_k2pc_3CkkcQ5VyPPJws8vnNYlKvisVCLO9m1TzL8uWyrLC6vV0sbxZyKcTdTV5NaFRA7VY8C2UZTzpkrjSWYs9oFpr8fx_UKptl2Ww-JxdoJ08XWSZnVSXysqjwrqioBLChmeU8Yk3sKqgs-p2jj1o57y4fh3sJMbhMHnpqybhaj3NO0EfuXlL2h_YaUhTTlk6C66vg979EVVOp>53145</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Auto-generate a struct that allows pipelines to control pass options.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir:core
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MaheshRavishankar
</td>
</tr>
</table>
<pre>
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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVt9v2zgM_mucFyJGYi9p-pCHJN2AAde7w27vg2zRsVbZciU5Wf77I2Ulcdqu6AAjkWWKPz5-pFgYeVo__vX1G3TCOXRQihYkVqpFSBbbZDn7l_b_6bwyraO3ZPGQZKva-84l-SbJvtDTaGVTrQ9Nauye3qUpHf3xwUfRij022PogmksstbDCqwNO2eDUdViqSpWCDSTZPagWvCg07rFN4XuNDsEM1kFYhNK03hqtWQR8bU2_r2mzaUQrQZPX4RA40VxkSSxIKQet8SAOQsXjJgQNneqQjzqSFCQg5RmM3ql2T7uExXJWWhQek2xDa2iQtEqXwhdjAX-JpiOFYtDHEBYYUZQc0fcYEQgHFXlvji6ZPSSzTfwlXIcnvDpv-9KTZsMQAuEMaZpCcrcdvgPw-2U9JCfJd4UxOsk_R7zmfIDE7h6SfPtaWFFKLrLZa1lev-Xc8MsYm1af4ChOjOMVakKZHtqqxQEDdEPADGRpJDIcuyTb8vNHEHR9oVV53toKhxQF40BRjKCJ34mkDAcc5km2I5seDhnTawwiBHenpCAiltJBtScarvjY_Ri3l7LZSDa7lb0id15csuW85KrJN337rHr80XlLQQR_KYqBYB8PwKLvbQsXpY14wh99q557huasJ_8c49nBrafkHryb4iGVAqi2eqGhs6ZESgZXGoqyHsjeIsqQb_zVUX6UJ1IMVT5k3-Jzr2g9VAaVccgsFU2soKDu7epirSIUy6s6HTNu1CAcHFHrFDadsB4qaxpyX1PRmwoKozRa6HQwsxtC8Krhsm3xGJWEiKVEySKse-zyO64yFwSlgw7Uot2jS8dYbkKdCOpWpOFljVybQ-9NQ42wpKBPQDtInZLd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