[Mlir-commits] [mlir] [MLIR][Presburger] Make printing aligned to assist in debugging (PR #107648)
Kunwar Grover
llvmlistbot at llvm.org
Tue Sep 10 04:03:46 PDT 2024
================
@@ -292,6 +294,48 @@ std::vector<Fraction> multiplyPolynomials(ArrayRef<Fraction> a,
bool isRangeZero(ArrayRef<Fraction> arr);
+struct PrintTableMetrics {
+ // If unknown, set to 0 and pass the struct into updatePrintMetrics.
+ unsigned maxPreIndent;
+ unsigned maxPostIndent;
+ // The substring expected prior to alignment.
+ std::string preAlign;
+};
+
+// Updates 'm' given a table entry val. Iterate over each val in the table
+// with .maxPreIndent and .maxPostIndent initialized to 0.
+// class T is any type that can be handled by llvm::raw_string_ostream.
+template <class T>
+void updatePrintMetrics(T val, PrintTableMetrics &m) {
+ std::string str;
+ llvm::raw_string_ostream(str) << val;
+ if (str.length() == 0)
+ return;
+ unsigned int preIndent = str.find(m.preAlign);
----------------
Groverkss wrote:
nit: unsigned int -> unsigned
https://github.com/llvm/llvm-project/pull/107648
More information about the Mlir-commits
mailing list