- Change OpClass new method addition to find and eliminate any existing methods that are made redundant by the newly added method, as well as detect if the newly added method will be redundant and return nullptr in that case.
- To facilitate that, add the notion of resolved and unresolved parameters, where resolved parameters have each parameter type known, so that redundancy checks on methods with same name but different parameter types can be done.
- Eliminate existing code to avoid adding conflicting/redundant build methods and rely on this new mechanism to eliminate conflicting build methods.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Nice, looks like good reduction
mlir/include/mlir/TableGen/OpClass.h | ||
---|---|---|
56 | Nit: Start with capital letter as start of a sentence. | |
56 | Nit: either to the given raw_ostream, or to os (the latter already indicates an explicit parameter and so the given is redundant) | |
79 | Prefer comment on line before parameter for uniformity. | |
83 | Nit: K -> kind to avoid clang-tidy warning (especially if we move these again). | |
89 | Same as above here and below. | |
108 | update this too to follow naming convention (https://mlir.llvm.org/getting_started/DeveloperGuide/#style-guide) | |
187 | Why is this one in the header file? | |
200 | Doesn't cast assert too if not true? | |
246 | I feel these top comments don't add anything to the enum name really and I'd be pro eliding them. | |
249 | What does only provide here? E.g., if we had MP_Declaration instead is their ambiguity? | |
326 | Does it get pruned or does it just not get added? Pruning for me implies it was already added. | |
330 | So this adds if not redundant and prunes if this makes an existing one redundant? Struggling to capture that all in one name ... addIfNonRedundantAndMaybePrune doesn't roll off the tongue :) This is fine, unless you have a better idea. | |
384 | Why not use setvector if the insertion ordering is required? | |
mlir/lib/TableGen/OpClass.cpp | ||
84 | How about using interleave method here? | |
mlir/test/mlir-tblgen/op-attribute.td | ||
110 | Is this change related? |
Review feedback
mlir/include/mlir/TableGen/OpClass.h | ||
---|---|---|
187 | Moved it to cpp. | |
200 | I think it does. | |
326 | It could be implemented that way as well (just add and then prune all redundant). But I have clarified the comment to indicate that its either not added or added. | |
330 | Yes, it's a one shot to preserve the invariant that there are no redundant methods at any point. To perfectly explain the functionality its addIfNotRedundant_Else_AddAndPruneRedundant(). I don't have a better idea. I was thinking addMethoAndPruneRedundant() but I don't think the extra redundant adds anything. I am open to suggestions if others have it. | |
384 | SetVector of unique_ptr<>'s is not supported (results in compile time errors due to copy constructors used). | |
mlir/lib/TableGen/OpClass.cpp | ||
84 | interleave() operates on a container of items, so I saved the tokens into a vector so that I can use the interleave here. | |
mlir/test/mlir-tblgen/op-attribute.td | ||
110 | Yes. There is already another $type_attr here below, so the functions for this one were getting removed as the newly added code thinks they are redundant. |
mlir/include/mlir/TableGen/OpClass.h | ||
---|---|---|
384 | I looked into this a bit more. SetVector maintains 2 copies of the elements in the set, one in a set and one in a vector for the insertion order. As a result unique_ptr<> cannot be held in a SetVector. |
Nit: Start with capital letter as start of a sentence.