Previously, ODS interface generator was placing implementations of the
interface's internal "Model" class template immediately after the class
definitions in the header. This doesn't allow this implementation, and
consequently the interface itself, to return an instance of another
interface if its class definition is emitted below. This creates
undesired ordering effects and makes it impossible for two or more
interfaces to return instances of each other. Change the interface
generator to place the implementations of these methods after all
interface classes.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp | ||
---|---|---|
293 | We no longer need to split post C++ version bump |
Seems like a bit of an ad-hoc solution for multiple interfaces defined in the same file?
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp | ||
---|---|---|
459 | Should we print all the fw-decls at the beginning of the file before any interface declaration so that an interface declaration can refer to another interface? |
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp | ||
---|---|---|
519 | I've been looking at the implementation of this file to try to make it work for my use case but I get lost into the details of the autogen engine. InterfaceA Fw-Decls InterfaceA Decls (using InterfaceB, InterfaceB fw-decls are needed) InterfaceA Defs (using InterfaceB, InterfaceB decls are needed) InterfaceB Fw-Decls InterfaceB Decls (using InterfaceA, InterfaceA fw-decls are needed) InterfaceB Defs (using InterfaceA, InterfaceA decls are needed) The main issue here is not the fw-decl dependency (that has an easy fix by adding the fw-decls by hand to the interface's .h file) but the decl dependency. InterfaceA needs a full declaration of InterfaceB for its definitions and vice versa. That means we would need to generate something like: InterfaceA Fw-Decls InterfaceB Fw-Decls InterfaceA Decls (using InterfaceB, InterfaceB fw-decls are needed) InterfaceB Decls (using InterfaceA, InterfaceA fw-decls are needed) InterfaceA Defs (using InterfaceB, InterfaceB decls are needed) InterfaceB Defs (using InterfaceA, InterfaceA decls are needed) I don't see a simple way to generate the code in this order as it looks like each interface is processed independently? I'm missing context here but perhaps there is a way to process/register all the interfaces and only once they are all processed then generate all the code? As a workaround I guess I can copy paste the generated code to the interface .h file and reorder it by hand. Hopefully we find a way to address this limitation. |
Sorry, I accidentally committed this diff! I had it in my local branch. Should I revert it? I think it's a step in the right direction and I was able to workaround the cyclic dependency that had so this should be good enough for now if we don't want to address the more complex cases right now.
We no longer need to split post C++ version bump