[Mlir-commits] [mlir] [MLIR][Presburger] Use Identifiers outside Presburger library (PR #77316)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jan 8 06:40:04 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff fd1c156e5d6584684ce58c0536dca96cedcc41f0 18cd4531da7246a818cab08d02c4f057f2e6e9d0 -- mlir/include/mlir/Analysis/FlatLinearValueConstraints.h mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h mlir/lib/Analysis/FlatLinearValueConstraints.cpp mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp mlir/lib/Dialect/Affine/Utils/Utils.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/include/mlir/Analysis/FlatLinearValueConstraints.h b/mlir/include/mlir/Analysis/FlatLinearValueConstraints.h
index 3cfc435310..f4b1166ea6 100644
--- a/mlir/include/mlir/Analysis/FlatLinearValueConstraints.h
+++ b/mlir/include/mlir/Analysis/FlatLinearValueConstraints.h
@@ -338,18 +338,18 @@ public:
   }
 
   inline SmallVector<std::optional<Value>>
-    getMaybeValues(presburger::VarKind kind) const {
-      SmallVector<std::optional<Value>> maybeValues;
-      maybeValues.reserve(getNumVarKind(kind));
-      for (unsigned i = 0, e = getNumVarKind(kind); i < e; i++) {
-        Identifier id = space.getId(kind, i);
-        if (id.hasValue())
-          maybeValues.push_back(space.getId(kind, i).getValue<Value>());
-        else
-          maybeValues.push_back(std::nullopt);
-      }
-      return maybeValues;
+  getMaybeValues(presburger::VarKind kind) const {
+    SmallVector<std::optional<Value>> maybeValues;
+    maybeValues.reserve(getNumVarKind(kind));
+    for (unsigned i = 0, e = getNumVarKind(kind); i < e; i++) {
+      Identifier id = space.getId(kind, i);
+      if (id.hasValue())
+        maybeValues.push_back(space.getId(kind, i).getValue<Value>());
+      else
+        maybeValues.push_back(std::nullopt);
     }
+    return maybeValues;
+  }
 
   /// Returns true if the pos^th variable has an associated Value.
   inline bool hasValue(unsigned pos) const {
@@ -359,9 +359,7 @@ public:
     return space.getId(kind, relativePos).hasValue();
   }
 
-  void resetValues() {
-    space.resetIds();
-  }
+  void resetValues() { space.resetIds(); }
 
   unsigned appendDimVar(ValueRange vals);
   using FlatLinearConstraints::appendDimVar;
diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h b/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
index efd28a88e9..c932792fbe 100644
--- a/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
+++ b/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
@@ -251,7 +251,8 @@ protected:
 /// For AffineValueMap, the domain and symbols have Value set corresponding to
 /// the Value in `map`. Returns failure if the AffineMap could not be flattened
 /// (i.e., semi-affine is not yet handled).
-LogicalResult getRelationFromMap(AffineMap &map, presburger::IntegerRelation &rel);
+LogicalResult getRelationFromMap(AffineMap &map,
+                                 presburger::IntegerRelation &rel);
 LogicalResult getRelationFromMap(const AffineValueMap &map,
                                  presburger::IntegerRelation &rel);
 
diff --git a/mlir/lib/Analysis/FlatLinearValueConstraints.cpp b/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
index 8414ca4b8b..144ce8f7e0 100644
--- a/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
+++ b/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
@@ -823,7 +823,6 @@ FlatLinearValueConstraints::FlatLinearValueConstraints(IntegerSet set,
   for (unsigned i = 0, e = operands.size(); i < e; ++i)
     setValue(i, operands[i]);
 
-
   // Flatten expressions and add them to the constraint system.
   std::vector<SmallVector<int64_t, 8>> flatExprs;
   FlatLinearConstraints localVarCst;
@@ -1078,7 +1077,6 @@ FlatLinearValueConstraints::computeAlignedMap(AffineMap map,
     syms.push_back(id.hasValue() ? Value(id.getValue<Value>()) : Value());
   }
 
-
   AffineMap alignedMap =
       alignAffineMapWithValues(map, operands, dims, syms, newSymsPtr);
   // All symbols are already part of this FlatAffineValueConstraints.
@@ -1168,7 +1166,8 @@ void FlatLinearValueConstraints::projectOut(Value val) {
 
 LogicalResult FlatLinearValueConstraints::unionBoundingBox(
     const FlatLinearValueConstraints &otherCst) {
-  assert(otherCst.getSpace().isAligned(getSpace(), VarKind::SetDim) && "dims mismatch");
+  assert(otherCst.getSpace().isAligned(getSpace(), VarKind::SetDim) &&
+         "dims mismatch");
   assert(otherCst.getNumLocalVars() == 0 && "local vars not supported here");
   assert(getNumLocalVars() == 0 && "local vars not supported yet here");
 
diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp
index 20a8282ee7..49841a2e45 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp
@@ -383,11 +383,10 @@ static bool srcAppearsBeforeDstInAncestralBlock(const MemRefAccess &srcAccess,
 // *) If 'loopDepth == 1' then one constraint is added: i' >= i + 1
 // *) If 'loopDepth == 2' then two constraints are added: i == i' and j' > j + 1
 // *) If 'loopDepth == 3' then two constraints are added: i == i' and j == j'
-static void
-addOrderingConstraints(const FlatAffineValueConstraints &srcDomain,
-                       const FlatAffineValueConstraints &dstDomain,
-                       unsigned loopDepth,
-                       IntegerRelation *dependenceDomain) {
+static void addOrderingConstraints(const FlatAffineValueConstraints &srcDomain,
+                                   const FlatAffineValueConstraints &dstDomain,
+                                   unsigned loopDepth,
+                                   IntegerRelation *dependenceDomain) {
   unsigned numCols = dependenceDomain->getNumCols();
   SmallVector<int64_t, 4> eq(numCols);
   unsigned numSrcDims = srcDomain.getNumDimVars();
@@ -425,7 +424,8 @@ static void computeDirectionVector(
   unsigned numIdsToEliminate = dependenceDomain->getNumVars();
   // Add new variables to 'dependenceDomain' to represent the direction
   // constraints for each shared loop.
-  dependenceDomain->insertVar(VarKind::Domain, /*pos=*/0, /*num=*/numCommonLoops);
+  dependenceDomain->insertVar(VarKind::Domain, /*pos=*/0,
+                              /*num=*/numCommonLoops);
 
   // Add equality constraints for each common loop, setting newly introduced
   // variable at column 'j' to the 'dst' IV minus the 'src IV.
@@ -472,7 +472,7 @@ LogicalResult MemRefAccess::getAccessRelation(IntegerRelation &rel) const {
     return failure();
 
   IntegerRelation domainRel = FlatAffineRelation(rel.getNumDomainVars(),
-                                                /*numRangeDims=*/0, domain);
+                                                 /*numRangeDims=*/0, domain);
 
   // Merge and align domain ids of `rel` and ids of `domain`. Since the domain
   // of the access map is a subset of the domain of access, the domain ids of
diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
index b01f40db7f..26d618dfac 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
@@ -375,7 +375,7 @@ void FlatAffineRelation::compose(const FlatAffineRelation &other) {
   assert(getNumDomainDims() == other.getNumRangeDims() &&
          "Domain of this and range of other do not match");
   assert(space.getDomainSpace().isAligned(other.getSpace().getRangeSpace()) &&
-      "Values of domain of this and range of other do not match");
+         "Values of domain of this and range of other do not match");
 
   FlatAffineRelation rel = other;
 
@@ -511,7 +511,7 @@ LogicalResult mlir::affine::getRelationFromMap(AffineMap &map,
   localVarCst.appendDimVar(numRangeVars);
 
   localVarCst.resetValues();
-  for(unsigned i = 0, e = localVarCst.getNumDimAndSymbolVars(); i < e; ++i)
+  for (unsigned i = 0, e = localVarCst.getNumDimAndSymbolVars(); i < e; ++i)
     localVarCst.setValue(i, Value());
 
   // Add equalities between source and range.
@@ -544,8 +544,9 @@ LogicalResult mlir::affine::getRelationFromMap(const AffineValueMap &map,
   // Set symbol values for domain dimensions and symbols.
   for (unsigned i = 0, e = rel.getNumDomainVars(); i < e; ++i)
     rel.getSpace().getId(VarKind::Domain, i) = Identifier(map.getOperand(i));
-  for(unsigned i = 0, e = rel.getNumSymbolVars(); i < e; ++i)
-    rel.getSpace().getId(VarKind::Symbol, i) = Identifier(map.getOperand(i - rel.getNumRangeVars()));
+  for (unsigned i = 0, e = rel.getNumSymbolVars(); i < e; ++i)
+    rel.getSpace().getId(VarKind::Symbol, i) =
+        Identifier(map.getOperand(i - rel.getNumRangeVars()));
 
   return success();
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/77316


More information about the Mlir-commits mailing list