diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -903,41 +903,38 @@ //===----------------------------------------------------------------------===// // Common type constraints //===----------------------------------------------------------------------===// +// Type constraint for types that are "like" some type or set of types T, that is +// they're either a T, a vector of Ts, or a tensor of Ts +class TypesLike : TypeConstraint.predicate, + TensorOf<[allowedType]>.predicate]>, + name>; + +// Temporary constraint to allow gradual transition to supporting 0-D vectors. +// TODO: Remove this when all ops support 0-D vectors. +class TypesLikeOfAnyRank : TypeConstraint.predicate, + TensorOf<[allowedType]>.predicate]>, + name>; + // Type constraint for bool-like types: bools, vectors of bools, tensors of // bools. -def BoolLike : TypeConstraint.predicate, - TensorOf<[I1]>.predicate]>, - "bool-like">; +def BoolLike : TypesLike; -// Temporary constraint to allow gradual transition to supporting 0-D vectors. -// TODO: Remove this when all ops support 0-D vectors. -def BoolLikeOfAnyRank : TypeConstraint.predicate, - TensorOf<[I1]>.predicate]>, - "bool-like">; +def BoolLikeOfAnyRank : TypesLikeOfAnyRank; // Type constraint for signless-integer-like types: signless integers, indices, // vectors of signless integers or indices, tensors of signless integers. -def SignlessIntegerLike : TypeConstraint.predicate, - TensorOf<[AnySignlessIntegerOrIndex]>.predicate]>, +def SignlessIntegerLike : TypesLike; -// Temporary constraint to allow gradual transition to supporting 0-D vectors. -// TODO: Remove this when all ops support 0-D vectors. -def SignlessIntegerLikeOfAnyRank : TypeConstraint.predicate, - TensorOf<[AnySignlessIntegerOrIndex]>.predicate]>, +def SignlessIntegerLikeOfAnyRank : TypesLikeOfAnyRank< + AnySignlessIntegerOrIndex, "signless-integer-like">; // Type constraint for float-like types: floats, vectors or tensors thereof. -def FloatLike : TypeConstraint.predicate, TensorOf<[AnyFloat]>.predicate]>, - "floating-point-like">; +def FloatLike : TypesLike; // Type constraint for signless-integer-like or float-like types. def SignlessIntegerOrFloatLike : TypeConstraint