[Mlir-commits] [mlir] [MLIR][Presburger] Make printing aligned to assist in debugging (PR #107648)

Amy Wang llvmlistbot at llvm.org
Wed Sep 11 15:11:37 PDT 2024


kaitingwang wrote:

```
Assume we'd like to print the following three numbers:
.12
3.4
56.7

 prealign = "."
minSpacing = 1

 First we iterate over all vals and compute the maxPreIndent and maxPostIndent:

String  PreIndent              PostIndent          Actual PreIndent              Actual PostIndent

.12     1                       2                        3 - (1 - 1) = 3              2 - (2) = 0

3.4     2                       1                        3 - (2 - 1) = 2              2 - (1) = 1

56.7    3                       1                        3 - (3 - 1) = 1              2 - (1) = 1
------------------------------------------------------------
max     3                       2

 
Then we perform the actual print where number of spaces printed are the Actual PreIndent and PostIndent caculated above.
 

Actual_PreIndent = maxPreIndent - (preIndent - minSpacing)
Actual_PosIndent = maxPostIndent - (postIndent)

 To illustrate:
` = Actual_PreIndent
~ = Actual_PostIndent

```.12```.12
``3.4~``3.4~
`56.7~`56.7~
```




https://github.com/llvm/llvm-project/pull/107648


More information about the Mlir-commits mailing list