This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Interfaces] Add a extraSharedClassDeclaration field
ClosedPublic

Authored by rriddle on Jan 10 2022, 10:56 AM.

Details

Summary

This field allows for defining a code block that is placed in both the interface
and trait declarations. This is very useful when defining a set of utilities to
expose on both the Interface class and the derived attribute/operation/type.

In non-static methods, $_attr/$_op/$_type (depending on the type of
interface) may be used to refer to an instance of the IR entity. In the interface
declaration, this is an instance of the interface class. In the trait declaration,
this is an instance of the concrete entity class (e.g. IntegerAttr, FuncOp, etc.).

Fixes #53000

Diff Detail

Event Timeline

rriddle created this revision.Jan 10 2022, 10:56 AM
rriddle requested review of this revision.Jan 10 2022, 10:56 AM

Do you have in-tree example of uses of this?

mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
478

Did you get a warning about this when running arc?

Do you have in-tree example of uses of this?

Actually: I'll look at the new ShapedType interface.

mehdi_amini accepted this revision.Jan 11 2022, 1:43 PM
mehdi_amini added inline comments.
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
478

Ping here?

This revision is now accepted and ready to land.Jan 11 2022, 1:43 PM
rriddle added inline comments.Jan 11 2022, 1:44 PM
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
478

No I didn't, but I think my local setup is a bit wonky. Thanks for pointing this out.

jpienaar accepted this revision.Jan 11 2022, 1:58 PM
jpienaar added a subscriber: jpienaar.
jpienaar added inline comments.
mlir/docs/Interfaces.md
397

injected?

404

I read this and wonder if it is "this" or this :)

mlir/include/mlir/TableGen/Interfaces.h
94

Could you add what it is shared between?

rriddle updated this revision to Diff 399434.Jan 12 2022, 1:38 PM
rriddle marked 5 inline comments as done.
rriddle edited the summary of this revision. (Show Details)Jan 12 2022, 1:45 PM