[polly] r333780 - partitionSetParts from C to C++ interface.

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 1 12:12:01 PDT 2018


Author: grosser
Date: Fri Jun  1 12:12:00 2018
New Revision: 333780

URL: http://llvm.org/viewvc/llvm-project?rev=333780&view=rev
Log:
partitionSetParts from C to C++ interface.

Summary: partitionSetParts from C to new C++ interface.

Reviewers: grosser, Meinersbur, jdoerfert, bollu, cs15btech11044

Reviewed By: grosser, Meinersbur

Subscribers: llvm-commits, pollydev

Tags: #polly

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

Modified:
    polly/trunk/lib/Analysis/ScopInfo.cpp

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=333780&r1=333779&r2=333780&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Fri Jun  1 12:12:00 2018
@@ -1312,22 +1312,15 @@ void ScopStmt::realignParams() {
   Domain = Domain.gist_params(Ctx);
 }
 
-/// Add @p BSet to the set @p User if @p BSet is bounded.
-static isl_stat collectBoundedParts(__isl_take isl_basic_set *BSet,
-                                    void *User) {
-  isl_set **BoundedParts = static_cast<isl_set **>(User);
-  if (isl_basic_set_is_bounded(BSet))
-    *BoundedParts = isl_set_union(*BoundedParts, isl_set_from_basic_set(BSet));
-  else
-    isl_basic_set_free(BSet);
-  return isl_stat_ok;
-}
-
-/// Return the bounded parts of @p S.
-static __isl_give isl_set *collectBoundedParts(__isl_take isl_set *S) {
-  isl_set *BoundedParts = isl_set_empty(isl_set_get_space(S));
-  isl_set_foreach_basic_set(S, collectBoundedParts, &BoundedParts);
-  isl_set_free(S);
+/// Add @p BSet to set @p BoundedParts if @p BSet is bounded.
+static isl::set collectBoundedParts(isl::set S) {
+  isl::set BoundedParts = isl::set::empty(S.get_space());
+  S.foreach_basic_set([&BoundedParts](isl::basic_set BSet) -> isl::stat {
+    if (BSet.is_bounded()) {
+      BoundedParts = BoundedParts.unite(isl::set(BSet));
+    }
+    return isl::stat::ok;
+  });
   return BoundedParts;
 }
 
@@ -1335,41 +1328,41 @@ static __isl_give isl_set *collectBounde
 ///
 /// @returns A separation of @p S into first an unbounded then a bounded subset,
 ///          both with regards to the dimension @p Dim.
-static std::pair<__isl_give isl_set *, __isl_give isl_set *>
-partitionSetParts(__isl_take isl_set *S, unsigned Dim) {
-  for (unsigned u = 0, e = isl_set_n_dim(S); u < e; u++)
-    S = isl_set_lower_bound_si(S, isl_dim_set, u, 0);
+static std::pair<isl::set, isl::set> partitionSetParts(isl::set S,
+                                                       unsigned Dim) {
+  for (unsigned u = 0, e = S.n_dim(); u < e; u++)
+    S = S.lower_bound_si(isl::dim::set, u, 0);
 
-  unsigned NumDimsS = isl_set_n_dim(S);
-  isl_set *OnlyDimS = isl_set_copy(S);
+  unsigned NumDimsS = S.n_dim();
+  isl::set OnlyDimS = S;
 
   // Remove dimensions that are greater than Dim as they are not interesting.
   assert(NumDimsS >= Dim + 1);
-  OnlyDimS =
-      isl_set_project_out(OnlyDimS, isl_dim_set, Dim + 1, NumDimsS - Dim - 1);
+  OnlyDimS = OnlyDimS.project_out(isl::dim::set, Dim + 1, NumDimsS - Dim - 1);
 
   // Create artificial parametric upper bounds for dimensions smaller than Dim
   // as we are not interested in them.
-  OnlyDimS = isl_set_insert_dims(OnlyDimS, isl_dim_param, 0, Dim);
+  OnlyDimS = OnlyDimS.insert_dims(isl::dim::param, 0, Dim);
+
   for (unsigned u = 0; u < Dim; u++) {
-    isl_constraint *C = isl_inequality_alloc(
-        isl_local_space_from_space(isl_set_get_space(OnlyDimS)));
-    C = isl_constraint_set_coefficient_si(C, isl_dim_param, u, 1);
-    C = isl_constraint_set_coefficient_si(C, isl_dim_set, u, -1);
-    OnlyDimS = isl_set_add_constraint(OnlyDimS, C);
+    isl::constraint C = isl::constraint::alloc_inequality(
+        isl::local_space(OnlyDimS.get_space()));
+    C = C.set_coefficient_si(isl::dim::param, u, 1);
+    C = C.set_coefficient_si(isl::dim::set, u, -1);
+    OnlyDimS = OnlyDimS.add_constraint(C);
   }
 
   // Collect all bounded parts of OnlyDimS.
-  isl_set *BoundedParts = collectBoundedParts(OnlyDimS);
+  isl::set BoundedParts = collectBoundedParts(OnlyDimS);
 
   // Create the dimensions greater than Dim again.
-  BoundedParts = isl_set_insert_dims(BoundedParts, isl_dim_set, Dim + 1,
-                                     NumDimsS - Dim - 1);
+  BoundedParts =
+      BoundedParts.insert_dims(isl::dim::set, Dim + 1, NumDimsS - Dim - 1);
 
   // Remove the artificial upper bound parameters again.
-  BoundedParts = isl_set_remove_dims(BoundedParts, isl_dim_param, 0, Dim);
+  BoundedParts = BoundedParts.remove_dims(isl::dim::param, 0, Dim);
 
-  isl_set *UnboundedParts = isl_set_subtract(S, isl_set_copy(BoundedParts));
+  isl::set UnboundedParts = S.subtract(BoundedParts);
   return std::make_pair(UnboundedParts, BoundedParts);
 }
 
@@ -3027,18 +3020,16 @@ bool Scop::addLoopBoundsToHeaderDomain(
   HeaderBBDom = HeaderBBDom.subtract(UnionBackedgeConditionComplement);
   HeaderBBDom = HeaderBBDom.apply(NextIterationMap);
 
-  auto Parts = partitionSetParts(HeaderBBDom.copy(), LoopDepth);
-  HeaderBBDom = isl::manage(Parts.second);
+  auto Parts = partitionSetParts(HeaderBBDom, LoopDepth);
+  HeaderBBDom = Parts.second;
 
   // Check if there is a <nsw> tagged AddRec for this loop and if so do not add
   // the bounded assumptions to the context as they are already implied by the
   // <nsw> tag.
-  if (Affinator.hasNSWAddRecForLoop(L)) {
-    isl_set_free(Parts.first);
+  if (Affinator.hasNSWAddRecForLoop(L))
     return true;
-  }
 
-  isl::set UnboundedCtx = isl::manage(Parts.first).params();
+  isl::set UnboundedCtx = Parts.first.params();
   recordAssumption(INFINITELOOP, UnboundedCtx,
                    HeaderBB->getTerminator()->getDebugLoc(), AS_RESTRICTION);
   return true;




More information about the llvm-commits mailing list