[mlir][memref] Introduce UnrankedMemRefOf to tablegen definitions

This enables specifying operations that only support some element types for
unranked memrefs.

Differential Revision: https://reviews.llvm.org/D104906
This commit is contained in:
Stephan Herhut 2021-06-25 12:44:22 +02:00
parent e15e1417b9
commit fb0dbc5481
1 changed files with 13 additions and 3 deletions

View File

@ -211,10 +211,14 @@ def IsTensorTypePred : CPred<"$_self.isa<::mlir::TensorType>()">;
// Whether a type is a MemRefType.
def IsMemRefTypePred : CPred<"$_self.isa<::mlir::MemRefType>()">;
// Whether a type is an IsUnrankedMemRefType
// Whether a type is an UnrankedMemRefType
def IsUnrankedMemRefTypePred
: CPred<"$_self.isa<::mlir::UnrankedMemRefType>()">;
// Whether a type is a BaseMemRefType
def IsBaseMemRefTypePred
: CPred<"$_self.isa<::mlir::BaseMemRefType>()">;
// Whether a type is a ShapedType.
def IsShapedTypePred : CPred<"$_self.isa<::mlir::ShapedType>()">;
@ -651,10 +655,13 @@ class 3DTensorOf<list<Type> allowedTypes> : TensorRankOf<allowedTypes, [3]>;
class 4DTensorOf<list<Type> allowedTypes> : TensorRankOf<allowedTypes, [4]>;
// Unranked Memref type
def AnyUnrankedMemRef :
ShapedContainerType<[AnyType],
class UnrankedMemRefOf<list<Type> allowedTypes> :
ShapedContainerType<allowedTypes,
IsUnrankedMemRefTypePred, "unranked.memref",
"::mlir::UnrankedMemRefType">;
def AnyUnrankedMemRef : UnrankedMemRefOf<[AnyType]>;
// Memref type.
// Memrefs are blocks of data with fixed type and rank.
@ -664,6 +671,9 @@ class MemRefOf<list<Type> allowedTypes> :
def AnyMemRef : MemRefOf<[AnyType]>;
class RankedOrUnrankedMemRefOf<list<Type> allowedTypes>:
AnyTypeOf<[UnrankedMemRefOf<allowedTypes>, MemRefOf<allowedTypes>]>;
def AnyRankedOrUnrankedMemRef: AnyTypeOf<[AnyUnrankedMemRef, AnyMemRef]>;
// Memref declarations handle any memref, independent of rank, size, (static or