[MLIR][Presburger][NFC] Use "disjunct" to refer to disjuncts in PresburgerRelation
authorGroverkss <groverkss@gmail.com>
Fri, 1 Apr 2022 12:08:27 +0000 (17:38 +0530)
committerGroverkss <groverkss@gmail.com>
Fri, 1 Apr 2022 12:08:30 +0000 (17:38 +0530)
This patch modifies the name "integerRelations" and "relation" to refer to the
disjuncts in PresburgerRelation to "disjunct(s)".  This is done to be
consistent with the rest of the interface.

Reviewed By: arjunp

Differential Revision: https://reviews.llvm.org/D122892

mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
mlir/lib/Analysis/Presburger/PresburgerRelation.cpp

index 8093a710c5512b035c4b4f88f385bb34e84b174e..bc64fbef44dbcbbc7b99c7d7020d5de04e66c3e3 100644 (file)
@@ -27,11 +27,11 @@ class SetCoalescer;
 /// the same PresburgerSpace with support for union, intersection, subtraction,
 /// and complement operations, as well as sampling.
 ///
-/// The IntegerRelations (relations) are stored in a vector, and the set
+/// The IntegerRelations (disjuncts) are stored in a vector, and the set
 /// represents the union of these relations. An empty list corresponds to
 /// the empty set.
 ///
-/// Note that there are no invariants guaranteed on the list of relations
+/// Note that there are no invariants guaranteed on the list of disjuncts
 /// other than that they are all in the same PresburgerSpace. For example, the
 /// relations may overlap with each other.
 class PresburgerRelation : public PresburgerSpace {
@@ -44,17 +44,17 @@ public:
 
   explicit PresburgerRelation(const IntegerRelation &disjunct);
 
-  /// Return the number of Disjuncts in the union.
+  /// Return the number of disjuncts in the union.
   unsigned getNumDisjuncts() const;
 
-  /// Return a reference to the list of IntegerRelations.
+  /// Return a reference to the list of disjuncts.
   ArrayRef<IntegerRelation> getAllDisjuncts() const;
 
-  /// Return the IntegerRelation at the specified index.
+  /// Return the disjunct at the specified index.
   const IntegerRelation &getDisjunct(unsigned index) const;
 
   /// Mutate this set, turning it into the union of this set and the given
-  /// IntegerRelation.
+  /// disjunct.
   void unionInPlace(const IntegerRelation &disjunct);
 
   /// Mutate this set, turning it into the union of this set and the given set.
@@ -122,7 +122,7 @@ protected:
   }
 
   /// The list of disjuncts that this set is the union of.
-  SmallVector<IntegerRelation, 2> integerRelations;
+  SmallVector<IntegerRelation, 2> disjuncts;
 
   friend class SetCoalescer;
 };
index 21d242b90765a085f1f3c1ed6b2856fd07b2318a..e917907f1770d4815e602a92238cc55a0a38d687 100644 (file)
@@ -22,23 +22,23 @@ PresburgerRelation::PresburgerRelation(const IntegerRelation &disjunct)
 }
 
 unsigned PresburgerRelation::getNumDisjuncts() const {
-  return integerRelations.size();
+  return disjuncts.size();
 }
 
 ArrayRef<IntegerRelation> PresburgerRelation::getAllDisjuncts() const {
-  return integerRelations;
+  return disjuncts;
 }
 
 const IntegerRelation &PresburgerRelation::getDisjunct(unsigned index) const {
-  assert(index < integerRelations.size() && "index out of bounds!");
-  return integerRelations[index];
+  assert(index < disjuncts.size() && "index out of bounds!");
+  return disjuncts[index];
 }
 
 /// Mutate this set, turning it into the union of this set and the given
 /// IntegerRelation.
 void PresburgerRelation::unionInPlace(const IntegerRelation &disjunct) {
   assert(isSpaceCompatible(disjunct) && "Spaces should match");
-  integerRelations.push_back(disjunct);
+  disjuncts.push_back(disjunct);
 }
 
 /// Mutate this set, turning it into the union of this set and the given set.
@@ -47,7 +47,7 @@ void PresburgerRelation::unionInPlace(const IntegerRelation &disjunct) {
 /// to this set.
 void PresburgerRelation::unionInPlace(const PresburgerRelation &set) {
   assert(isSpaceCompatible(set) && "Spaces should match");
-  for (const IntegerRelation &disjunct : set.integerRelations)
+  for (const IntegerRelation &disjunct : set.disjuncts)
     unionInPlace(disjunct);
 }
 
@@ -62,7 +62,7 @@ PresburgerRelation::unionSet(const PresburgerRelation &set) const {
 
 /// A point is contained in the union iff any of the parts contain the point.
 bool PresburgerRelation::containsPoint(ArrayRef<int64_t> point) const {
-  return llvm::any_of(integerRelations, [&](const IntegerRelation &disjunct) {
+  return llvm::any_of(disjuncts, [&](const IntegerRelation &disjunct) {
     return (disjunct.containsPoint(point));
   });
 }
@@ -90,8 +90,8 @@ PresburgerRelation::intersect(const PresburgerRelation &set) const {
   assert(isSpaceCompatible(set) && "Spaces should match");
 
   PresburgerRelation result(getSpace());
-  for (const IntegerRelation &csA : integerRelations) {
-    for (const IntegerRelation &csB : set.integerRelations) {
+  for (const IntegerRelation &csA : disjuncts) {
+    for (const IntegerRelation &csB : set.disjuncts) {
       IntegerRelation intersection = csA.intersect(csB);
       if (!intersection.isEmpty())
         result.unionInPlace(intersection);
@@ -311,7 +311,7 @@ PresburgerRelation::subtract(const PresburgerRelation &set) const {
   assert(isSpaceCompatible(set) && "Spaces should match");
   PresburgerRelation result(getSpace());
   // We compute (U_i t_i) \ (U_i set_i) as U_i (t_i \ V_i set_i).
-  for (const IntegerRelation &disjunct : integerRelations)
+  for (const IntegerRelation &disjunct : disjuncts)
     result.unionInPlace(getSetDifference(disjunct, set));
   return result;
 }
@@ -333,13 +333,12 @@ bool PresburgerRelation::isEqual(const PresburgerRelation &set) const {
 /// false otherwise.
 bool PresburgerRelation::isIntegerEmpty() const {
   // The set is empty iff all of the disjuncts are empty.
-  return llvm::all_of(integerRelations,
-                      std::mem_fn(&IntegerRelation::isIntegerEmpty));
+  return llvm::all_of(disjuncts, std::mem_fn(&IntegerRelation::isIntegerEmpty));
 }
 
 bool PresburgerRelation::findIntegerSample(SmallVectorImpl<int64_t> &sample) {
   // A sample exists iff any of the disjuncts contains a sample.
-  for (const IntegerRelation &disjunct : integerRelations) {
+  for (const IntegerRelation &disjunct : disjuncts) {
     if (Optional<SmallVector<int64_t, 8>> opt = disjunct.findIntegerSample()) {
       sample = std::move(*opt);
       return true;
@@ -353,7 +352,7 @@ Optional<uint64_t> PresburgerRelation::computeVolume() const {
   // The sum of the volumes of the disjuncts is a valid overapproximation of the
   // volume of their union, even if they overlap.
   uint64_t result = 0;
-  for (const IntegerRelation &disjunct : integerRelations) {
+  for (const IntegerRelation &disjunct : disjuncts) {
     Optional<uint64_t> volume = disjunct.computeVolume();
     if (!volume)
       return {};
@@ -452,7 +451,7 @@ private:
 /// `IntegerRelation`s to the `disjuncts` vector.
 SetCoalescer::SetCoalescer(const PresburgerRelation &s) {
 
-  disjuncts = s.integerRelations;
+  disjuncts = s.disjuncts;
 
   simplices.reserve(s.getNumDisjuncts());
   // Note that disjuncts.size() changes during the loop.
@@ -699,7 +698,7 @@ PresburgerRelation PresburgerRelation::coalesce() const {
 
 void PresburgerRelation::print(raw_ostream &os) const {
   os << "Number of Disjuncts: " << getNumDisjuncts() << "\n";
-  for (const IntegerRelation &disjunct : integerRelations) {
+  for (const IntegerRelation &disjunct : disjuncts) {
     disjunct.print(os);
     os << '\n';
   }