Add support to disable the generation of getter/setter functions for attribute of Op defined in .td files

I defined some ops in td files and use TableGen to generate the defination of those Op Class. I do not want the getter/setter functions of some special attribute to apper in the OpClass define files (because I write my own getter/setter functions of those attribute and do some Customized Check there).

My solution to achive this goal is to add a new Attribute class, which named HiddenAttr. Any Op attribute defined in td file with HiddenAttr will not generate there getter/setter functions in the OpClass define file.

I have implement this solution in my local version, and I think it will be useful if the tablegen in mlir could support this feature.

What kind of checks? And why are they in the accessors/checked every time queried rather than in the verifiers? That also forms part of a question on what’s the usage pattern?

In our scenario, a group of ops may have a same attribute. For example, PoolOp and ConvOp both have the padding attribute. We use trait to provide a unified interface to get/set the padding attribute, instead of using the ops’ getter/setter function.

We could disable setter/getter in TableGen based on a flag, but I’d be wary of a flag explosion and it may be reasonable to have it all or nothing (all operands/results or none).

Alternatively maybe there could be an annotation in ODS directly, to make it a per-op thing (like we skip verifier, etc.).

What do you mean to make it a per-op thing? Do you mean disable the setter/getter of all attr of an Operation? I think it will be much more flexible if we could disable some attrs’ setter/getter function.

Hi Mehdi Amini,
I have commited a revision here with my solution. This is my first attempt at committing code. Please let me know if there is anything goes wrong.