[mlir] Add support for interface inheritance
authorRiver Riddle <riddleriver@gmail.com>
Thu, 12 Jan 2023 21:35:15 +0000 (13:35 -0800)
committerRiver Riddle <riddleriver@gmail.com>
Thu, 19 Jan 2023 03:16:30 +0000 (19:16 -0800)
commit83a635c0d4759bd77bbbb21ff8d202cb8c3ea57b
treef112422f41b764dbe94b9c8e73e469542406ad84
parent5cdc2bbc7588e7b046ac5c7f79a84ef18978a83a
[mlir] Add support for interface inheritance

This allows for interfaces to define a set of "base classes",
which are interfaces whose methods/extra class decls/etc.
should be inherited by the derived interface. This more
easily enables combining interfaces and their dependencies,
without lots of awkard casting. Additional implicit conversion
operators also greatly simplify the conversion process.

One other aspect of this "inheritance" is that we also implicitly
add the base interfaces to the attr/op/type. The user can still
add them manually if desired, but this should help remove some
of the boiler plate when an interface has dependencies.

See https://discourse.llvm.org/t/interface-inheritance-and-dependencies-interface-method-visibility-interface-composition

Differential Revision: https://reviews.llvm.org/D140198
16 files changed:
mlir/docs/Interfaces.md
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/IR/OperationSupport.h
mlir/include/mlir/IR/StorageUniquerSupport.h
mlir/include/mlir/Support/InterfaceSupport.h
mlir/include/mlir/TableGen/Interfaces.h
mlir/lib/IR/ExtensibleDialect.cpp
mlir/lib/IR/MLIRContext.cpp
mlir/lib/Support/InterfaceSupport.cpp
mlir/lib/TableGen/AttrOrTypeDef.cpp
mlir/lib/TableGen/Interfaces.cpp
mlir/lib/TableGen/Operator.cpp
mlir/test/lib/Dialect/Test/TestInterfaces.td
mlir/test/mlir-tblgen/op-interface.td
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp