TypedTuple: Add support for tuples with type constraints on the elements.
--
PiperOrigin-RevId: 243685631
diff --git a/include/mlir/IR/OpBase.td b/include/mlir/IR/OpBase.td
index 0295e37..42c16ed 100644
--- a/include/mlir/IR/OpBase.td
+++ b/include/mlir/IR/OpBase.td
@@ -352,6 +352,24 @@
// there is not only a single elemental type.
def Tuple : Type<IsTupleTypePred, "tuple">;
+
+// A Tuple that only holds elements of a certain type. This cannot inherit from
+// ContainerType because tuples do not always have a single element type that
+// could be retrieved with elementTypeCall.
+class TypedTuple<Type t> :
+ Type<AllOf<[
+ Tuple.predicate,
+ Concat<
+ [{
+ llvm::all_of(
+ $_self.cast<TupleType>().getTypes(),
+ [](Type t) {
+ return
+ }],
+ SubstLeaves<"$_self", "t", t.predicate>,
+ "; })">
+ ]>, "tuple">;
+
// Memref type.
// Memrefs are blocks of data with fixed type and rank.