[Question] When is customed parser and print necessary?


Sorry I am a beginner to MLIR, but I guess this question may confuse other rookies as well.

Some documents told me the tablegen of ODS can directly generate a default parses and print function for a new operation. But we can also write a custom parser and print by ourselves. So my question is when should we leave the parser/printer generated automatically, and when should we write on our own? Thanks!

You should use the declarative assembly as much as possible, it isn’t entirely as flexible as a custom written parser though, and sometimes we drop to write native code to work around it.
For example an operation with regions may include native code to customize the handling of the region parsing (shadowing the region arguments for example).

1 Like