Added an underlying matcher for generic constant ops. This
included a rewriter of RewriterGen to make variable use more
clear.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/IR/Matchers.h | ||
---|---|---|
274 ↗ | (On Diff #297332) | Is this necessary? Seems like this is just success(m_Constant(&attribute).match(op)) which is something that could be written inline in DRR and not here. |
mlir/include/mlir/IR/OpBase.td | ||
2354 | I'd prefer that this has something like "Matcher" in the name so that it is obvious this is just for DRR, given that there is a ConstantLike trait. |
I think you may need to rebase this on head, seems like you were working of an old version here.
mlir/lib/TableGen/Pattern.cpp | ||
---|---|---|
224 | Would we need to here similarly consider the type as above? | |
629–630 | New error helper functions were added to TableGen, so one can now say PrintFatalError(&def, ...) | |
657 | nested? | |
662 | Maybe phab is confusing me here, but this looks like same then and else bodies. | |
666 | You might see the other change allowing this, where these become constraints to check for equality. | |
mlir/test/lib/Dialect/Test/TestOps.td | ||
817 | You can skip this if empty. | |
mlir/tools/mlir-tblgen/RewriterGen.cpp | ||
261 | os is a raw_indented_ostream here, so you should just need to use a DelimitedScope here [did you check how this looks? I would expect this to have more indenting than expected] |
mlir/lib/TableGen/Pattern.cpp | ||
---|---|---|
224 | We would if it were possible :/. NativeCodeCall doesn't specify types so I need to assume the result (I went with attribute). Long term we need a better solution but I couldn't think of one. | |
662 | The else body statement is the same with the exception of what type of binding is being done. Note bindAttr vs bindValue. | |
666 | I think I implemented as you hoped by adding a verification on the constraint as well. Should be good enough anyway, I am not certain value matching is going to work well for the pattern matcher with native code calls. | |
mlir/tools/mlir-tblgen/RewriterGen.cpp | ||
261 | Indenting is good until the match checks (over indented). I tweaked a little more to decrease the indenting however emitMatchCheck has weird indenting mechanics. |
mlir/lib/TableGen/Pattern.cpp | ||
---|---|---|
224 | Yes I think we need to add support for this ODS side (I don't think it would be too hard). Could you add a TODO here to use a more exact type if available? | |
628 | Could we do an early exist instead with positive logic? | |
657 | Could you test with ASAN too? (you might actually need to add some failing test cases too to verify here and below, a TD while where these are invoked from the run should enable covering these). | |
659 | Lets be consistent with all these we now add and use the new helper methods. | |
678 | Could flipping logic + using continues etc be used to reduce this nesting? | |
mlir/tools/mlir-tblgen/RewriterGen.cpp | ||
247 | You should not need to be doing these manual indent calculations here. These are structured, so you should simply be able to have the scope handle that for you. I see it is still below in the other one too at head used in one call, I think it could be an oversight there too, but I'm not sure why it should not be needed. | |
450 | These should not be needed. As mentioned in previous comments, this appears like you based this on a old revision. |
mlir/lib/TableGen/Pattern.cpp | ||
---|---|---|
657 | Invoked with ASAN. Added tests look good (excluding already failing tests). | |
657 | ASAN marks things as good. Could you give me a better feeling on what a TD failure case looks like? Most of the tablegen failures are a bit bewildering. | |
mlir/tools/mlir-tblgen/RewriterGen.cpp | ||
247 | Yeah, I missed some of the merge issues when updating. Should be good now. |
mlir/lib/TableGen/Pattern.cpp | ||
---|---|---|
657 | Sure, adding a test/tests where we hit these fatal error cases. Given it fatals, one would have to combine something like // RUN: not ... 2>&1 | FileCheck (look at llvm/test/TableGen/defvar.td test for a failure testing case approach that could work well here too) |
Looks good thanks!
mlir/lib/TableGen/Pattern.cpp | ||
---|---|---|
629–630 | I think you might have missed this one (or uploaded other version) |
I'd prefer that this has something like "Matcher" in the name so that it is obvious this is just for DRR, given that there is a ConstantLike trait.