diff --git a/mlir/include/mlir/IR/CommonTypeConstraints.td b/mlir/include/mlir/IR/CommonTypeConstraints.td index 4fc14e30b8a10..8e5f2b065d6bb 100644 --- a/mlir/include/mlir/IR/CommonTypeConstraints.td +++ b/mlir/include/mlir/IR/CommonTypeConstraints.td @@ -546,6 +546,76 @@ class ScalableVectorOfRankAndLengthAndType allowedRanks, ScalableVectorOfLength.summary, "::mlir::VectorType">; +// Whether the number of elements of a vector is from the given +// `allowedRanges` list, the list has two values, start and end +// of the range (inclusive). +class IsVectorOfLengthRangePred allowedRanges> + : And<[IsVectorTypePred, + And<[CPred<[{$_self.cast<::mlir::VectorType>().getNumElements()>= }] # allowedRanges[0]>, + CPred<[{$_self.cast<::mlir::VectorType>().getNumElements() <= }] # allowedRanges[1]>]>]>; + +// Whether the number of elements of a fixed-length vector is from the given +// `allowedRanges` list, the list has two values, start and end of the range (inclusive). +class IsFixedVectorOfLengthRangePred allowedRanges> + : And<[IsFixedVectorTypePred, + And<[CPred<[{$_self.cast<::mlir::VectorType>().getNumElements() >= }] # allowedRanges[0]>, + CPred<[{$_self.cast<::mlir::VectorType>().getNumElements() <= }] # allowedRanges[1]>]>]>; + +// Whether the minimum number of elements of a scalable vector is from the given +// `allowedRanges` list, the list has two values, start and end of the range (inclusive). +class IsScalableVectorOfMinLengthRangePred allowedRanges> + : And<[IsScalableVectorTypePred, + And<[CPred<[{$_self.cast<::mlir::VectorType>().getNumElements() >= }] # allowedRanges[0]>, + CPred<[{$_self.cast<::mlir::VectorType>().getNumElements() <= }] # allowedRanges[1]>]>]>; + +// Any vector where the number of elements is from the given +// `allowedRanges` list. +class VectorOfLengthRange allowedRanges> + : Type, + " of length " # !interleave(allowedRanges, "-"), + "::mlir::VectorType">; + +// Any fixed-length vector where the number of elements is from the given +// `allowedRanges` list. +class FixedVectorOfLengthRange allowedRanges> + : Type, + " of length " # !interleave(allowedRanges, "-"), + "::mlir::VectorType">; + +// Any scalable vector where the minimum number of elements is from the given +// `allowedRanges` list. +class ScalableVectorOfMinLengthRange allowedRanges> + : Type, + " of length " # !interleave(allowedRanges, "-"), + "::mlir::VectorType">; + +// Any vector where the number of elements is from the given +// `allowedRanges` list and the type is from the given `allowedTypes` +// list. +class VectorOfLengthRangeAndType allowedRanges, list allowedTypes> + : Type.predicate, VectorOfLengthRange.predicate]>, + VectorOf.summary # VectorOfLengthRange.summary, + "::mlir::VectorType">; + +// Any fixed-length vector where the number of elements is from the given +// `allowedRanges` list and the type is from the given `allowedTypes` +// list. +class FixedVectorOfLengthRangeAndType allowedRanges, list allowedTypes> + : Type< + And<[FixedVectorOf.predicate, FixedVectorOfLengthRange.predicate]>, + FixedVectorOf.summary # FixedVectorOfLengthRange.summary, + "::mlir::VectorType">; + +// Any scalable vector where the minimum number of elements is from the given +// `allowedRanges` list and the type is from the given `allowedTypes` +// list. +class ScalableVectorOfMinLengthRangeAndType allowedRanges, list allowedTypes> + : Type< + And<[ScalableVectorOf.predicate, ScalableVectorOfMinLengthRange.predicate]>, + ScalableVectorOf.summary # ScalableVectorOfMinLengthRange.summary, + "::mlir::VectorType">; + + def AnyVector : VectorOf<[AnyType]>; // Temporary vector type clone that allows gradual transition to 0-D vectors. def AnyVectorOfAnyRank : VectorOfAnyRankOf<[AnyType]>;