[MLIR][Presburger] Improve unittest parsing
authorGroverkss <groverkss@gmail.com>
Thu, 15 Sep 2022 11:09:00 +0000 (12:09 +0100)
committerGroverkss <groverkss@gmail.com>
Thu, 15 Sep 2022 11:09:00 +0000 (12:09 +0100)
commit84d07d021333f7b5716f0444d5c09105557272e0
tree67fa44dc3d25531bde0c900d0201a3e768d9f625
parent6e0e926c2f12f4897c91a90af61e06f410e528ef
[MLIR][Presburger] Improve unittest parsing

This patch adds better functions for parsing MultiAffineFunctions and
PWMAFunctions in Presburger unittests.

A PWMAFunction can now be parsed as:

```
PWMAFunction result = parsePWMAF({
    {"(x, y) : (x >= 10, x <= 20, y >= 1)", "(x, y) -> (x + y)"},
    {"(x, y) : (x >= 21)", "(x, y) -> (x + y)"},
    {"(x, y) : (x <= 9)", "(x, y) -> (x - y)"},
    {"(x, y) : (x >= 10, x <= 20, y <= 0)", "(x, y) -> (x - y)"},
});
```

which is much more readable than the old format since the output can be
described as an AffineMap, instead of coefficients.

This patch also adds support for parsing divisions in MultiAffineFunctions
and PWMAFunctions which was previously not possible.

Reviewed By: arjunp

Differential Revision: https://reviews.llvm.org/D133654
17 files changed:
mlir/include/mlir/AsmParser/AsmParser.h
mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
mlir/lib/AsmParser/AffineParser.cpp
mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
mlir/unittests/Analysis/Presburger/CMakeLists.txt
mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp
mlir/unittests/Analysis/Presburger/IntegerRelationTest.cpp
mlir/unittests/Analysis/Presburger/PWMAFunctionTest.cpp
mlir/unittests/Analysis/Presburger/Parser.h [new file with mode: 0644]
mlir/unittests/Analysis/Presburger/ParserTest.cpp [moved from mlir/unittests/Dialect/Affine/Analysis/AffineStructuresParserTest.cpp with 56% similarity]
mlir/unittests/Analysis/Presburger/PresburgerSetTest.cpp
mlir/unittests/Analysis/Presburger/SimplexTest.cpp
mlir/unittests/Analysis/Presburger/Utils.h
mlir/unittests/Dialect/Affine/Analysis/AffineStructuresParser.h [deleted file]
mlir/unittests/Dialect/Affine/Analysis/CMakeLists.txt [deleted file]
mlir/unittests/Dialect/Affine/CMakeLists.txt [deleted file]
mlir/unittests/Dialect/CMakeLists.txt