[mlir] Allows to query traits from types and attributes
authorMathieu Fehr <mathieu.fehr@gmail.com>
Mon, 13 Sep 2021 06:22:19 +0000 (06:22 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Mon, 13 Sep 2021 06:26:45 +0000 (06:26 +0000)
commit802bf02a738e091d5bf22c03e83204a38d2c7950
treeb6c771263d713182187857511a312feb33f928cb
parent7fb2394a4f362aff4282af8486b7352e720c32ab
[mlir] Allows to query traits from types and attributes

Types and attributes now have a `hasTrait` function that allow users to check
if a type defines a trait.
Also, AbstractType and AbstractAttribute has now a `hasTraitFn` field to carry
the implementation of the `hasTrait` function of the concrete type or attribute.
This patch also adds the remaining functions to access type and attribute traits
in TableGen.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D105202
13 files changed:
mlir/include/mlir/IR/AttributeSupport.h
mlir/include/mlir/IR/Attributes.h
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/IR/StorageUniquerSupport.h
mlir/include/mlir/IR/TypeSupport.h
mlir/include/mlir/IR/Types.h
mlir/test/IR/traits.mlir
mlir/test/lib/Dialect/Test/TestAttrDefs.td
mlir/test/lib/Dialect/Test/TestAttributes.h
mlir/test/lib/Dialect/Test/TestOps.td
mlir/test/lib/Dialect/Test/TestTraits.h [new file with mode: 0644]
mlir/test/lib/Dialect/Test/TestTypeDefs.td
mlir/test/lib/Dialect/Test/TestTypes.h