@@ -89,6 +89,9 @@ def HasStaticShapePred :
89
89
// Whether a type is a TupleType.
90
90
def IsTupleTypePred : CPred<"::llvm::isa<::mlir::TupleType>($_self)">;
91
91
92
+ // Whether a type has a ValueSemantics trait.
93
+ def HasValueSemanticsPred : CPred<"$_self.hasTrait<::mlir::ValueSemantics>()">;
94
+
92
95
//===----------------------------------------------------------------------===//
93
96
// Type definitions
94
97
//===----------------------------------------------------------------------===//
@@ -403,6 +406,11 @@ class HasRankGreaterOrEqualPred<int rank> : And<[
403
406
CPred<[{::llvm::cast<::mlir::ShapedType>($_self).getRank() >= }] # rank>
404
407
]>;
405
408
409
+ // Container with value semantics.
410
+ class ValueSemanticsContainerOf<list<Type> allowedTypes> :
411
+ ShapedContainerType<allowedTypes, HasValueSemanticsPred,
412
+ "container with value semantics">;
413
+
406
414
// Vector types.
407
415
408
416
class VectorOf<list<Type> allowedTypes> :
@@ -842,10 +850,18 @@ class NestedTupleOf<list<Type> allowedTypes> :
842
850
// Common type constraints
843
851
//===----------------------------------------------------------------------===//
844
852
// Type constraint for types that are "like" some type or set of types T, that is
845
- // they're either a T, a vector of Ts, or a tensor of Ts
853
+ // they're either a T, a vector of Ts, or a tensor of Ts.
846
854
class TypeOrContainer<Type allowedType, string name> : TypeConstraint<Or<[
847
- allowedType.predicate, VectorOf<[allowedType]>.predicate,
848
- TensorOf<[allowedType]>.predicate]>,
855
+ allowedType.predicate,
856
+ ValueSemanticsContainerOf<[allowedType]>.predicate]>,
857
+ name>;
858
+
859
+ // Type constraint for types that are "like" some type or set of types T, that is
860
+ // they're either a T or a mapable container of Ts.
861
+ class TypeOrValueSemanticsContainer<Type allowedType, string name>
862
+ : TypeConstraint<Or<[
863
+ allowedType.predicate,
864
+ ValueSemanticsContainerOf<[allowedType]>.predicate]>,
849
865
name>;
850
866
851
867
// Temporary constraint to allow gradual transition to supporting 0-D vectors.
@@ -864,8 +880,8 @@ def BoolLikeOfAnyRank : TypeOrContainerOfAnyRank<I1, "bool-like">;
864
880
865
881
// Type constraint for signless-integer-like types: signless integers, indices,
866
882
// vectors of signless integers or indices, tensors of signless integers.
867
- def SignlessIntegerLike : TypeOrContainer<AnySignlessIntegerOrIndex,
868
- "signless-integer-like">;
883
+ def SignlessIntegerLike : TypeOrValueSemanticsContainer<
884
+ AnySignlessIntegerOrIndex, "signless-integer-like">;
869
885
870
886
def SignlessIntegerLikeOfAnyRank : TypeOrContainerOfAnyRank<
871
887
AnySignlessIntegerOrIndex,
0 commit comments