Skip to content

Commit 644dfba

Browse files
committed
Revert "[MLIR][Presburger] Improve unittest parsing"
This reverts commit 84d07d0. Reverted to fix a compilation issue on gcc8.
1 parent a53b56e commit 644dfba

File tree

17 files changed

+1026
-899
lines changed

17 files changed

+1026
-899
lines changed

mlir/include/mlir/AsmParser/AsmParser.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,14 @@ Type parseType(llvm::StringRef typeStr, MLIRContext *context);
7676
/// returned in `numRead`.
7777
Type parseType(llvm::StringRef typeStr, MLIRContext *context, size_t &numRead);
7878

79-
/// This parses a single IntegerSet/AffineMap to an MLIR context if it was
80-
/// valid. If not, an error message is emitted through a new
81-
/// SourceMgrDiagnosticHandler constructed from a new SourceMgr with a single
82-
/// MemoryBuffer wrapping `str`. If the passed `str` has additional tokens that
83-
/// were not part of the IntegerSet/AffineMap, a failure is returned.
84-
AffineMap parseAffineMap(llvm::StringRef str, MLIRContext *context);
85-
IntegerSet parseIntegerSet(llvm::StringRef str, MLIRContext *context);
79+
/// This parses a single IntegerSet to an MLIR context if it was valid. If not,
80+
/// an error message is emitted through a new SourceMgrDiagnosticHandler
81+
/// constructed from a new SourceMgr with a single MemoryBuffer wrapping
82+
/// `str`. If the passed `str` has additional tokens that were not part of the
83+
/// IntegerSet, a failure is returned. Diagnostics are printed on failure if
84+
/// `printDiagnosticInfo` is true.
85+
IntegerSet parseIntegerSet(llvm::StringRef str, MLIRContext *context,
86+
bool printDiagnosticInfo = true);
8687

8788
} // namespace mlir
8889

mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ class Value;
3232
class MemRefType;
3333
struct MutableAffineMap;
3434

35-
namespace presburger {
36-
class MultiAffineFunction;
37-
} // namespace presburger
38-
3935
/// FlatAffineValueConstraints represents an extension of IntegerPolyhedron
4036
/// where each non-local variable can have an SSA Value attached to it.
4137
class FlatAffineValueConstraints : public presburger::IntegerPolyhedron {
@@ -619,10 +615,6 @@ getFlattenedAffineExprs(IntegerSet set,
619615
std::vector<SmallVector<int64_t, 8>> *flattenedExprs,
620616
FlatAffineValueConstraints *cst = nullptr);
621617

622-
LogicalResult
623-
getMultiAffineFunctionFromMap(AffineMap map,
624-
presburger::MultiAffineFunction &multiAff);
625-
626618
/// Re-indexes the dimensions and symbols of an affine map with given `operands`
627619
/// values to align with `dims` and `syms` values.
628620
///

mlir/lib/AsmParser/AffineParser.cpp

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,8 @@ Parser::parseAffineExprOfSSAIds(AffineExpr &expr,
734734
.parseAffineExprOfSSAIds(expr);
735735
}
736736

737-
static void parseAffineMapOrIntegerSet(StringRef inputStr, MLIRContext *context,
738-
AffineMap &map, IntegerSet &set) {
737+
IntegerSet mlir::parseIntegerSet(StringRef inputStr, MLIRContext *context,
738+
bool printDiagnosticInfo) {
739739
llvm::SourceMgr sourceMgr;
740740
auto memBuffer = llvm::MemoryBuffer::getMemBuffer(
741741
inputStr, /*BufferName=*/"<mlir_parser_buffer>",
@@ -747,31 +747,17 @@ static void parseAffineMapOrIntegerSet(StringRef inputStr, MLIRContext *context,
747747
/*codeCompleteContext=*/nullptr);
748748
Parser parser(state);
749749

750-
SourceMgrDiagnosticHandler handler(sourceMgr, context, llvm::errs());
751-
if (parser.parseAffineMapOrIntegerSetReference(map, set))
752-
return;
750+
raw_ostream &os = printDiagnosticInfo ? llvm::errs() : llvm::nulls();
751+
SourceMgrDiagnosticHandler handler(sourceMgr, context, os);
752+
IntegerSet set;
753+
if (parser.parseIntegerSetReference(set))
754+
return IntegerSet();
753755

754756
Token endTok = parser.getToken();
755757
if (endTok.isNot(Token::eof)) {
756758
parser.emitError(endTok.getLoc(), "encountered unexpected token");
757-
return;
759+
return IntegerSet();
758760
}
759-
}
760-
761-
AffineMap mlir::parseAffineMap(StringRef inputStr, MLIRContext *context) {
762-
AffineMap map;
763-
IntegerSet set;
764-
parseAffineMapOrIntegerSet(inputStr, context, map, set);
765-
assert(!set &&
766-
"expected string to represent AffineMap, but got IntegerSet instead");
767-
return map;
768-
}
769761

770-
IntegerSet mlir::parseIntegerSet(StringRef inputStr, MLIRContext *context) {
771-
AffineMap map;
772-
IntegerSet set;
773-
parseAffineMapOrIntegerSet(inputStr, context, map, set);
774-
assert(!map &&
775-
"expected string to represent IntegerSet, but got AffineMap instead");
776762
return set;
777763
}

mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,31 +1801,3 @@ LogicalResult mlir::getRelationFromMap(const AffineValueMap &map,
18011801

18021802
return success();
18031803
}
1804-
1805-
LogicalResult
1806-
mlir::getMultiAffineFunctionFromMap(AffineMap map,
1807-
MultiAffineFunction &multiAff) {
1808-
FlatAffineValueConstraints cst;
1809-
std::vector<SmallVector<int64_t, 8>> flattenedExprs;
1810-
LogicalResult result = getFlattenedAffineExprs(map, &flattenedExprs, &cst);
1811-
1812-
if (result.failed())
1813-
return failure();
1814-
1815-
DivisionRepr divs = cst.getLocalReprs();
1816-
assert(divs.hasAllReprs() &&
1817-
"AffineMap cannot produce divs without local representation");
1818-
1819-
// TODO: We shouldn't have to do this conversion.
1820-
Matrix mat(map.getNumResults(), map.getNumInputs() + divs.getNumDivs() + 1);
1821-
for (unsigned i = 0, e = flattenedExprs.size(); i < e; ++i)
1822-
for (unsigned j = 0, f = flattenedExprs[i].size(); j < f; ++j)
1823-
mat(i, j) = flattenedExprs[i][j];
1824-
1825-
multiAff = MultiAffineFunction(
1826-
PresburgerSpace::getRelationSpace(map.getNumDims(), map.getNumResults(),
1827-
map.getNumSymbols(), divs.getNumDivs()),
1828-
mat, divs);
1829-
1830-
return success();
1831-
}

mlir/unittests/Analysis/Presburger/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ add_mlir_unittest(MLIRPresburgerTests
44
LinearTransformTest.cpp
55
MatrixTest.cpp
66
MPIntTest.cpp
7-
Parser.h
8-
ParserTest.cpp
97
PresburgerSetTest.cpp
108
PresburgerSpaceTest.cpp
119
PWMAFunctionTest.cpp
1210
SimplexTest.cpp
11+
../../Dialect/Affine/Analysis/AffineStructuresParser.cpp
1312
)
1413

1514
target_link_libraries(MLIRPresburgerTests

0 commit comments

Comments
 (0)