[all-commits] [llvm/llvm-project] a60e83: [mlir][Interfaces] Add a extraSharedClassDeclarati...

River Riddle via All-commits all-commits at lists.llvm.org
Wed Jan 12 14:13:07 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a60e83fe7cebbfb9f0a6a3ad7504c034f5d0e40f
      https://github.com/llvm/llvm-project/commit/a60e83fe7cebbfb9f0a6a3ad7504c034f5d0e40f
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2022-01-12 (Wed, 12 Jan 2022)

  Changed paths:
    M mlir/docs/Interfaces.md
    M mlir/include/mlir/IR/OpBase.td
    M mlir/include/mlir/TableGen/Interfaces.h
    M mlir/lib/TableGen/Interfaces.cpp
    M mlir/test/mlir-tblgen/op-interface.td
    M mlir/tools/mlir-tblgen/OpInterfacesGen.cpp

  Log Message:
  -----------
  [mlir][Interfaces] Add a extraSharedClassDeclaration field

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.).

Differential Revision: https://reviews.llvm.org/D116961


  Commit: 676bfb2a226e705d801016bb433b68a1e09a1e10
      https://github.com/llvm/llvm-project/commit/676bfb2a226e705d801016bb433b68a1e09a1e10
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2022-01-12 (Wed, 12 Jan 2022)

  Changed paths:
    M mlir/include/mlir/IR/BuiltinTypeInterfaces.td
    M mlir/include/mlir/IR/BuiltinTypes.h
    M mlir/include/mlir/IR/BuiltinTypes.td
    M mlir/lib/Conversion/LLVMCommon/MemRefBuilder.cpp
    M mlir/lib/Conversion/LLVMCommon/Pattern.cpp
    M mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
    M mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
    M mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
    M mlir/lib/Dialect/Vector/VectorTransferSplitRewritePatterns.cpp
    A mlir/lib/IR/BuiltinTypeInterfaces.cpp
    M mlir/lib/IR/BuiltinTypes.cpp
    M mlir/lib/IR/CMakeLists.txt
    M mlir/unittests/IR/ShapedTypeTest.cpp

  Log Message:
  -----------
  [mlir] Refactor ShapedType into an interface

ShapedType was created in a time before interfaces, and is one of the earliest
type base classes in the ecosystem. This commit refactors ShapedType into
an interface, which is what it would have been if interfaces had existed at that
time. The API of ShapedType and it's derived classes are essentially untouched
by this refactor, with the exception being the API surrounding kDynamicIndex
(which requires a sole home).

For now, the API of ShapedType and its name have been kept as consistent to
the current state of the world as possible (to help with potential migration churn,
among other reasons). Moving forward though, we should look into potentially
restructuring its API and possible its name as well (it should really have "Interface"
at the end like other interfaces at the very least).

One other potentially interesting note is that I've attached the ShapedType::Trait
to TensorType/BaseMemRefType to act as mixins for the ShapedType API. This
is kind of weird, but allows for sharing the same API (i.e. preventing API loss from
the transition from base class -> Interface). This inheritance doesn't affect any
of the derived classes, it is just for API mixin.

Differential Revision: https://reviews.llvm.org/D116962


Compare: https://github.com/llvm/llvm-project/compare/aa1c533a4e44...676bfb2a226e


More information about the All-commits mailing list