This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Allow for using interface class name in ODS interface definitions
ClosedPublic

Authored by ftynse on Nov 15 2020, 8:50 AM.

Details

Summary

It may be necessary for interface methods to process or return variables with
the interface class type, in particular for attribute and type interfaces that
can return modified attributes and types that implement the same interface.
However, the code generated by ODS in this case would not compile because the
signature (and the body if provided) appear in the definition of the Model
class and before the interface class, which derives from the Model. Change the ODS
interface method generator to emit only method declarations in the Model class
itself, and emit method definitions after the interface class. Mark as "inline"
since their definitions are still emitted in the header and are no longer
implicitly inline. Add a forward declaration of the interface class before the
Concept+Model classes to make the class name usable in declarations.

Diff Detail

Event Timeline

ftynse created this revision.Nov 15 2020, 8:50 AM
ftynse requested review of this revision.Nov 15 2020, 8:50 AM
rriddle accepted this revision.Nov 16 2020, 11:24 AM
rriddle added inline comments.
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
361

This deserves a comment.

This revision is now accepted and ready to land.Nov 16 2020, 11:24 AM
This revision was landed with ongoing or failed builds.Nov 17 2020, 5:29 AM
This revision was automatically updated to reflect the committed changes.