[Mlir-commits] [mlir] [mlir] Declare promised interfaces for all dialects (PR #78368)

Stella Laurenzo llvmlistbot at llvm.org
Fri Feb 23 08:13:31 PST 2024


stellaraccident wrote:

> > I feel like in prior lives, this would have been the job of some common registry of names and ids, at least for some definition of built-in things vs having the declarations organized into the directory structure of the "provider". That could just be a convention that upstream takes to keep the dependency graph sane, and downstreams could play a little looser if they want.
> 
> I've been thinking about some sort of project-level initialization (`initMlirCore`, `initEnzyme`, etc.) that would list such promises, but have hard time seeing how it wouldn't end up `#include`ing every single dialect and interface. Which could be acceptable given that `lib/IR` is clear of this and we only need headers. Adding string identifiers for interfaces and having a string/string map hardcoded or generated from tablegen feels too stringly.

I don't think it needs to be more "stringly" than a header file with a bunch of declarations is (in comparison -- not recommending this mechanism).

I was thinking of a project level "InterfaceDeclarations.h.inc" backed by an `InterfaceDeclarations.td`. I haven't looked at how we represent this in TD now, but it feels like there should be some kind of `InterfaceID` record explicitly, giving it a name and type id binding. Then the dialect (or whatever) implementation of the interface includes this TD file, using the globally defined `InterfaceID` record vs defining it locally. The "promising" dialect would only include the global `InterfaceDeclarations`.

Something like that.

I'd really love the dependency graph to be "solidly" a DAG, not kind of halfway balancing into having cycles. It is really hard to reason about without that property.

https://github.com/llvm/llvm-project/pull/78368


More information about the Mlir-commits mailing list