forked from OSchip/llvm-project
[MLIR][Presburger] factor out duplicated function `parsePoly` into a Utils.h
Reviewed By: Groverkss Differential Revision: https://reviews.llvm.org/D119194
This commit is contained in:
parent
1468202748
commit
6472546fb7
|
@ -7,7 +7,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mlir/Analysis/Presburger/IntegerPolyhedron.h"
|
||||
#include "../../Dialect/Affine/Analysis/AffineStructuresParser.h"
|
||||
#include "./Utils.h"
|
||||
#include "mlir/IR/MLIRContext.h"
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
|
@ -98,17 +98,6 @@ static void checkPermutationsSample(bool hasSample, unsigned nDim,
|
|||
} while (std::next_permutation(perm.begin(), perm.end()));
|
||||
}
|
||||
|
||||
/// Parses a IntegerPolyhedron from a StringRef. It is expected that the
|
||||
/// string represents a valid IntegerSet, otherwise it will violate a gtest
|
||||
/// assertion.
|
||||
static IntegerPolyhedron parsePoly(StringRef str, MLIRContext *context) {
|
||||
FailureOr<IntegerPolyhedron> poly = parseIntegerSetToFAC(str, context);
|
||||
|
||||
EXPECT_TRUE(succeeded(poly));
|
||||
|
||||
return *poly;
|
||||
}
|
||||
|
||||
TEST(IntegerPolyhedronTest, removeInequality) {
|
||||
IntegerPolyhedron set =
|
||||
makeSetFromConstraints(1, {{0, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 4}}, {});
|
||||
|
|
|
@ -10,9 +10,11 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "./Utils.h"
|
||||
|
||||
#include "mlir/Analysis/Presburger/PWMAFunction.h"
|
||||
#include "../../Dialect/Affine/Analysis/AffineStructuresParser.h"
|
||||
#include "mlir/Analysis/Presburger/PresburgerSet.h"
|
||||
#include "mlir/IR/MLIRContext.h"
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
@ -20,15 +22,6 @@
|
|||
namespace mlir {
|
||||
using testing::ElementsAre;
|
||||
|
||||
/// Parses an IntegerPolyhedron from a StringRef. It is expected that the
|
||||
/// string represents a valid IntegerSet, otherwise it will violate a gtest
|
||||
/// assertion.
|
||||
static IntegerPolyhedron parsePoly(StringRef str, MLIRContext *context) {
|
||||
FailureOr<IntegerPolyhedron> poly = parseIntegerSetToFAC(str, context);
|
||||
EXPECT_TRUE(succeeded(poly));
|
||||
return *poly;
|
||||
}
|
||||
|
||||
static Matrix makeMatrix(unsigned numRow, unsigned numColumns,
|
||||
ArrayRef<SmallVector<int64_t, 8>> matrix) {
|
||||
Matrix results(numRow, numColumns);
|
||||
|
|
|
@ -15,24 +15,14 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mlir/Analysis/Presburger/PresburgerSet.h"
|
||||
#include "../../Dialect/Affine/Analysis/AffineStructuresParser.h"
|
||||
#include "./Utils.h"
|
||||
#include "mlir/IR/MLIRContext.h"
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace mlir {
|
||||
|
||||
/// Parses an IntegerPolyhedron from a StringRef. It is expected that the
|
||||
/// string represents a valid IntegerSet, otherwise it will violate a gtest
|
||||
/// assertion.
|
||||
static IntegerPolyhedron parsePoly(StringRef str, MLIRContext *context) {
|
||||
FailureOr<IntegerPolyhedron> poly = parseIntegerSetToFAC(str, context);
|
||||
|
||||
EXPECT_TRUE(succeeded(poly));
|
||||
|
||||
return *poly;
|
||||
}
|
||||
|
||||
/// Parse a list of StringRefs to IntegerPolyhedron and combine them into a
|
||||
/// PresburgerSet be using the union operation. It is expected that the strings
|
||||
/// are all valid IntegerSet representation and that all of them have the same
|
||||
|
|
|
@ -6,8 +6,10 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "./Utils.h"
|
||||
|
||||
#include "mlir/Analysis/Presburger/Simplex.h"
|
||||
#include "../../Dialect/Affine/Analysis/AffineStructuresParser.h"
|
||||
#include "mlir/IR/MLIRContext.h"
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
@ -476,18 +478,8 @@ TEST(SimplexTest, isRedundantEquality) {
|
|||
EXPECT_TRUE(simplex.isRedundantEquality({-1, 0, 2})); // x = 2.
|
||||
}
|
||||
|
||||
static IntegerPolyhedron parsePoly(StringRef str, MLIRContext *context) {
|
||||
FailureOr<IntegerPolyhedron> poly = parseIntegerSetToFAC(str, context);
|
||||
|
||||
EXPECT_TRUE(succeeded(poly));
|
||||
|
||||
return *poly;
|
||||
}
|
||||
|
||||
TEST(SimplexTest, IsRationalSubsetOf) {
|
||||
|
||||
MLIRContext context;
|
||||
|
||||
IntegerPolyhedron univ = parsePoly("(x) : ()", &context);
|
||||
IntegerPolyhedron empty =
|
||||
parsePoly("(x) : (x + 0 >= 0, -x - 1 >= 0)", &context);
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
//===- Utils.h - Utils for Presburger Tests ---------------------*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines helper functions for Presburger unittests.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef MLIR_UNITTESTS_ANALYSIS_PRESBURGER_UTILS_H
|
||||
#define MLIR_UNITTESTS_ANALYSIS_PRESBURGER_UTILS_H
|
||||
|
||||
#include "../../Dialect/Affine/Analysis/AffineStructuresParser.h"
|
||||
#include "mlir/IR/MLIRContext.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace mlir {
|
||||
/// Parses a IntegerPolyhedron from a StringRef. It is expected that the
|
||||
/// string represents a valid IntegerSet, otherwise it will violate a gtest
|
||||
/// assertion.
|
||||
static IntegerPolyhedron parsePoly(StringRef str, MLIRContext *context) {
|
||||
FailureOr<IntegerPolyhedron> poly = parseIntegerSetToFAC(str, context);
|
||||
EXPECT_TRUE(succeeded(poly));
|
||||
return *poly;
|
||||
}
|
||||
} // namespace mlir
|
||||
|
||||
#endif // MLIR_UNITTESTS_ANALYSIS_PRESBURGER_UTILS_H
|
Loading…
Reference in New Issue