This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add support for "promised" interfaces

Authored by springerm on Mar 20 2023, 4:20 AM.



Promised interfaces allow for a dialect to "promise" the implementation of an interface, i.e., declare that it supports an interface, but have the interface defined in an extension in a library separate from the dialect itself. A promised interface is powerful in that it alerts the user when the interface is attempted to be used (e.g. via cast/dyn_cast/etc.) and the implementation has not yet been provided. This makes the system much more robust against misconfiguration, and ensures that we do not lose the benefit we currently have of defining the interface in the dialect library.

All external model registrations in InitAllDialects.h are marked as "promised" in the respective dialects. An exception is BufferizableOpInterface: this interface cannot be marked as promised because it is in the Bufferization dialect and has dependencies on other dialects. Only interfaces located in mlir/Interfaces can be marked as "promised".

Note: This revision was copied and is a subset of D120368.

Diff Detail

Event Timeline

springerm created this revision.Mar 20 2023, 4:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 20 2023, 4:20 AM
springerm requested review of this revision.Mar 20 2023, 4:20 AM

This is a re-upload of River's revision. Trying address a comment mentioned by @mehdi_amini in So that I can use this revision as a diffbase for my stack.

springerm abandoned this revision.May 31 2023, 4:55 AM

This patch will also not be enough I believe to handle OpInterfaces? The end-goal from the beginning was that all of the registerXXXXXOpInterfaceExternalModels() here: should be forbidden unless they have been promised in the first place.