Use type alias for large tuples
authorJacques Pienaar <jpienaar@google.com>
Sat, 30 Jan 2021 01:42:23 +0000 (17:42 -0800)
committerJacques Pienaar <jpienaar@google.com>
Sat, 30 Jan 2021 01:42:23 +0000 (17:42 -0800)
Tuples can occupy quite a lot of space, instead of printing out tuple type
everywhere, just use the type alias if larger (arbitrarily chose a bound for
now).

Differential Revision: https://reviews.llvm.org/D95707

mlir/lib/IR/BuiltinDialect.cpp

index 138321e..469aa31 100644 (file)
@@ -46,6 +46,16 @@ struct BuiltinOpAsmDialectInterface : public OpAsmDialectInterface {
     }
     return failure();
   }
+
+  LogicalResult getAlias(Type type, raw_ostream &os) const final {
+    if (auto tupleType = type.dyn_cast<TupleType>()) {
+      if (tupleType.size() > 16) {
+        os << "tuple";
+        return success();
+      }
+    }
+    return failure();
+  }
 };
 } // end anonymous namespace.