Ops that use TypesMatchWith to constrain result types for verification
and to infer result types during parser generation should also be able
to have the inferReturnTypes method auto generated. This patch
upgrades the logic for generating inferReturnTypes to handle the
TypesMatchWith trait by building a type inference graph where each edge
corresponds to "type of A can be inferred from type of B", supporting
transformers other than "$_self".
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I like all the red :)
mlir/lib/TableGen/Operator.cpp | ||
---|---|---|
394 | Comments? (esp what does each element of the vector correspond to if any). Esp. given the name o fthe struct is quite general. | |
405–415 | This comment feels out of place here. | |
436 | I recall there was some uncertainty with variadics, but I also seem to recall there was a proposal to address it. What does this do with variadic operands & results? | |
475 | known type vs already inferred confuses me here. E.g., an inferred type is known. Could we use other phrases? | |
509 | Why do we need this here in condition slot vs in increment one? (also not sure why post-incrementing here) | |
512 | Can we add a little static helper that would be more self-documenting than checking for negative or not? | |
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | ||
2525–2530 | Topological order for result types feel weird :) This is in order to create valid computation structure so that inferred types can be functions of other inferred types correct? | |
2526 | Document convention used here (I think it is just sentinel or known) |
mlir/lib/TableGen/Operator.cpp | ||
---|---|---|
436 | If the op has variadic results, type inference is not generated (this is checked at the start of the function). It's not generally valid to have TypesMatchWith or AllTypesMatch mix variadic and non-variadic types anyways, so I didn't bother checking that. | |
509 | This is an llvm::make_early_inc_range except I still need the iterator object itself to call std::list::erase. | |
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | ||
2525–2530 | Yes. I'll clarify what this means: topological wrt the type inference (directed acyclic) graph. |
This is so great Jeff, thank you for driving this forward, I love the boilerplate destruction!
mlir/lib/TableGen/Operator.cpp | ||
---|---|---|
436 | This is a pre-existing restriction. I can make another pass and see if I can add variadic result support. |
mlir/include/mlir/TableGen/Operator.h | ||
---|---|---|
49 | Can you document this? This is referring to the index we use to transform right? |
mlir/include/mlir/TableGen/Operator.h | ||
---|---|---|
49 | Yes. I'll add a doc |
Can you document this? This is referring to the index we use to transform right?