From 33afea548892b2e7f0f7636ab17367da59f42c4a Mon Sep 17 00:00:00 2001 From: Arjun P Date: Sat, 18 Sep 2021 21:40:59 +0530 Subject: [PATCH] [MLIR] Simplex: rename num{Variables,Constraints} to getNum{Variables,Constraints} As per the LLVM Coding Standards, function names should be verb phrases. --- mlir/include/mlir/Analysis/Presburger/Simplex.h | 4 ++-- mlir/lib/Analysis/Presburger/Simplex.cpp | 18 +++++++++--------- mlir/lib/Analysis/PresburgerSet.cpp | 2 +- mlir/unittests/Analysis/Presburger/SimplexTest.cpp | 16 ++++++++-------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/mlir/include/mlir/Analysis/Presburger/Simplex.h b/mlir/include/mlir/Analysis/Presburger/Simplex.h index ed60da6..e400f70 100644 --- a/mlir/include/mlir/Analysis/Presburger/Simplex.h +++ b/mlir/include/mlir/Analysis/Presburger/Simplex.h @@ -152,10 +152,10 @@ public: void addInequality(ArrayRef 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 d33a986..d97a46f 100644 --- a/mlir/lib/Analysis/Presburger/Simplex.cpp +++ b/mlir/lib/Analysis/Presburger/Simplex.cpp @@ -391,8 +391,8 @@ void Simplex::addEquality(ArrayRef 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 @@ private: /// - dir_1 * y_1 - dir_2 * y_2 - ... - dir_n * y_n, /// where n is the dimension of the original polytope. SmallVector getCoeffsForDirection(ArrayRef dir) { - assert(2 * dir.size() == simplex.numVariables() && + assert(2 * dir.size() == simplex.getNumVariables() && "Direction vector has wrong dimensionality"); SmallVector 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 14b718f..81fc8cc 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 160f0ad..d1bb649 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 -- 2.7.4