[Mlir-commits] [mlir] 33afea5 - [MLIR] Simplex: rename num{Variables, Constraints} to getNum{Variables, Constraints}
Arjun P
llvmlistbot at llvm.org
Sat Sep 18 10:10:22 PDT 2021
Author: Arjun P
Date: 2021-09-18T22:39:35+05:30
New Revision: 33afea548892b2e7f0f7636ab17367da59f42c4a
URL: https://github.com/llvm/llvm-project/commit/33afea548892b2e7f0f7636ab17367da59f42c4a
DIFF: https://github.com/llvm/llvm-project/commit/33afea548892b2e7f0f7636ab17367da59f42c4a.diff
LOG: [MLIR] Simplex: rename num{Variables,Constraints} to getNum{Variables,Constraints}
As per the LLVM Coding Standards, function names should be verb phrases.
Added:
Modified:
mlir/include/mlir/Analysis/Presburger/Simplex.h
mlir/lib/Analysis/Presburger/Simplex.cpp
mlir/lib/Analysis/PresburgerSet.cpp
mlir/unittests/Analysis/Presburger/SimplexTest.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Analysis/Presburger/Simplex.h b/mlir/include/mlir/Analysis/Presburger/Simplex.h
index ed60da6c6d273..e400f700ec1af 100644
--- a/mlir/include/mlir/Analysis/Presburger/Simplex.h
+++ b/mlir/include/mlir/Analysis/Presburger/Simplex.h
@@ -152,10 +152,10 @@ class Simplex {
void addInequality(ArrayRef<int64_t> coeffs);
/// Returns the number of variables in the tableau.
- unsigned numVariables() const;
+ unsigned getNumVariables() const;
/// Returns the number of constraints in the tableau.
- unsigned numConstraints() const;
+ unsigned getNumConstraints() const;
/// Add an equality to the tableau. If coeffs is c_0, c_1, ... c_n, where n
/// is the current number of variables, then the corresponding equality is
diff --git a/mlir/lib/Analysis/Presburger/Simplex.cpp b/mlir/lib/Analysis/Presburger/Simplex.cpp
index d33a986087415..d97a46f2b811e 100644
--- a/mlir/lib/Analysis/Presburger/Simplex.cpp
+++ b/mlir/lib/Analysis/Presburger/Simplex.cpp
@@ -391,8 +391,8 @@ void Simplex::addEquality(ArrayRef<int64_t> coeffs) {
addInequality(negatedCoeffs);
}
-unsigned Simplex::numVariables() const { return var.size(); }
-unsigned Simplex::numConstraints() const { return con.size(); }
+unsigned Simplex::getNumVariables() const { return var.size(); }
+unsigned Simplex::getNumConstraints() const { return con.size(); }
/// Return a snapshot of the current state. This is just the current size of the
/// undo log.
@@ -497,7 +497,7 @@ void Simplex::appendVariable(unsigned count) {
/// Add all the constraints from the given FlatAffineConstraints.
void Simplex::intersectFlatAffineConstraints(const FlatAffineConstraints &fac) {
- assert(fac.getNumIds() == numVariables() &&
+ assert(fac.getNumIds() == getNumVariables() &&
"FlatAffineConstraints must have same dimensionality as simplex");
for (unsigned i = 0, e = fac.getNumInequalities(); i < e; ++i)
addInequality(fac.getInequality(i));
@@ -654,8 +654,8 @@ bool Simplex::isUnbounded() {
/// It has column layout:
/// denominator, constant, A's columns, B's columns.
Simplex Simplex::makeProduct(const Simplex &a, const Simplex &b) {
- unsigned numVar = a.numVariables() + b.numVariables();
- unsigned numCon = a.numConstraints() + b.numConstraints();
+ unsigned numVar = a.getNumVariables() + b.getNumVariables();
+ unsigned numCon = a.getNumConstraints() + b.getNumConstraints();
Simplex result(numVar);
result.tableau.resizeVertically(numCon);
@@ -672,8 +672,8 @@ Simplex Simplex::makeProduct(const Simplex &a, const Simplex &b) {
result.var = concat(a.var, b.var);
auto indexFromBIndex = [&](int index) {
- return index >= 0 ? a.numVariables() + index
- : ~(a.numConstraints() + ~index);
+ return index >= 0 ? a.getNumVariables() + index
+ : ~(a.getNumConstraints() + ~index);
};
result.colUnknown.assign(2, nullIndex);
@@ -777,7 +777,7 @@ class GBRSimplex {
public:
GBRSimplex(const Simplex &originalSimplex)
: simplex(Simplex::makeProduct(originalSimplex, originalSimplex)),
- simplexConstraintOffset(simplex.numConstraints()) {}
+ simplexConstraintOffset(simplex.getNumConstraints()) {}
/// Add an equality dotProduct(dir, x - y) == 0.
/// First pushes a snapshot for the current simplex state to the stack so
@@ -869,7 +869,7 @@ class GBRSimplex {
/// - dir_1 * y_1 - dir_2 * y_2 - ... - dir_n * y_n,
/// where n is the dimension of the original polytope.
SmallVector<int64_t, 8> getCoeffsForDirection(ArrayRef<int64_t> dir) {
- assert(2 * dir.size() == simplex.numVariables() &&
+ assert(2 * dir.size() == simplex.getNumVariables() &&
"Direction vector has wrong dimensionality");
SmallVector<int64_t, 8> coeffs(dir.begin(), dir.end());
coeffs.reserve(2 * dir.size());
diff --git a/mlir/lib/Analysis/PresburgerSet.cpp b/mlir/lib/Analysis/PresburgerSet.cpp
index 14b718f8f328c..81fc8cc1eafd2 100644
--- a/mlir/lib/Analysis/PresburgerSet.cpp
+++ b/mlir/lib/Analysis/PresburgerSet.cpp
@@ -178,7 +178,7 @@ static void subtractRecursively(FlatAffineConstraints &b, Simplex &simplex,
assert(sI.getNumLocalIds() == 0 &&
"Subtracting sets with divisions is not yet supported!");
unsigned initialSnapshot = simplex.getSnapshot();
- unsigned offset = simplex.numConstraints();
+ unsigned offset = simplex.getNumConstraints();
simplex.intersectFlatAffineConstraints(sI);
if (simplex.isEmpty()) {
diff --git a/mlir/unittests/Analysis/Presburger/SimplexTest.cpp b/mlir/unittests/Analysis/Presburger/SimplexTest.cpp
index 160f0ad43717c..d1bb6499c3153 100644
--- a/mlir/unittests/Analysis/Presburger/SimplexTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/SimplexTest.cpp
@@ -72,7 +72,7 @@ TEST(SimplexTest, addInequality_rollback) {
expectInequalityMakesSetEmpty(simplex, checkCoeffs[1], true);
simplex.rollback(snapshot);
- EXPECT_EQ(simplex.numConstraints(), 0u);
+ EXPECT_EQ(simplex.getNumConstraints(), 0u);
expectInequalityMakesSetEmpty(simplex, checkCoeffs[0], false);
expectInequalityMakesSetEmpty(simplex, checkCoeffs[1], false);
@@ -295,7 +295,7 @@ TEST(SimplexTest, isMarkedRedundant_no_redundant) {
simplex.detectRedundant();
ASSERT_FALSE(simplex.isEmpty());
- for (unsigned i = 0; i < simplex.numConstraints(); ++i)
+ for (unsigned i = 0; i < simplex.getNumConstraints(); ++i)
EXPECT_FALSE(simplex.isMarkedRedundant(i)) << "i = " << i << "\n";
}
@@ -388,7 +388,7 @@ TEST(SimplexTest, appendVariable) {
unsigned snapshot1 = simplex.getSnapshot();
simplex.appendVariable();
- EXPECT_EQ(simplex.numVariables(), 2u);
+ EXPECT_EQ(simplex.getNumVariables(), 2u);
int64_t yMin = 2, yMax = 5;
simplex.addInequality({0, 1, -yMin}); // y >= 2.
@@ -396,17 +396,17 @@ TEST(SimplexTest, appendVariable) {
unsigned snapshot2 = simplex.getSnapshot();
simplex.appendVariable(2);
- EXPECT_EQ(simplex.numVariables(), 4u);
+ EXPECT_EQ(simplex.getNumVariables(), 4u);
simplex.rollback(snapshot2);
- EXPECT_EQ(simplex.numVariables(), 2u);
- EXPECT_EQ(simplex.numConstraints(), 2u);
+ EXPECT_EQ(simplex.getNumVariables(), 2u);
+ EXPECT_EQ(simplex.getNumConstraints(), 2u);
EXPECT_EQ(simplex.computeIntegerBounds({0, 1, 0}),
std::make_pair(yMin, yMax));
simplex.rollback(snapshot1);
- EXPECT_EQ(simplex.numVariables(), 1u);
- EXPECT_EQ(simplex.numConstraints(), 0u);
+ EXPECT_EQ(simplex.getNumVariables(), 1u);
+ EXPECT_EQ(simplex.getNumConstraints(), 0u);
}
} // namespace mlir
More information about the Mlir-commits
mailing list