[polly] r288924 - Add more ISL foreachElt functions. NFC.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 09:47:57 PST 2016


Author: meinersbur
Date: Wed Dec  7 11:47:57 2016
New Revision: 288924

URL: http://llvm.org/viewvc/llvm-project?rev=288924&view=rev
Log:
Add more ISL foreachElt functions. NFC.

Add and implement foreachElt for isl_map, isl_set and isl_union_set. These are
used by an out-of-tree patch which is in process of being upstreamed.

Modified:
    polly/trunk/include/polly/Support/GICHelper.h
    polly/trunk/lib/Support/GICHelper.cpp

Modified: polly/trunk/include/polly/Support/GICHelper.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Support/GICHelper.h?rev=288924&r1=288923&r2=288924&view=diff
==============================================================================
--- polly/trunk/include/polly/Support/GICHelper.h (original)
+++ polly/trunk/include/polly/Support/GICHelper.h Wed Dec  7 11:47:57 2016
@@ -365,6 +365,20 @@ static llvm::raw_ostream &operator<<(llv
   return OS;
 }
 
+/// Enumerate all isl_basic_maps of an isl_map.
+///
+/// This basically wraps isl_map_foreach_basic_map() and allows to call back
+/// C++11 closures.
+void foreachElt(NonowningIslPtr<isl_map> Map,
+                const std::function<void(IslPtr<isl_basic_map>)> &F);
+
+/// Enumerate all isl_basic_sets of an isl_set.
+///
+/// This basically wraps isl_set_foreach_basic_set() and allows to call back
+/// C++11 closures.
+void foreachElt(NonowningIslPtr<isl_set> Set,
+                const std::function<void(IslPtr<isl_basic_set>)> &F);
+
 /// Enumerate all isl_maps of an isl_union_map.
 ///
 /// This basically wraps isl_union_map_foreach_map() and allows to call back
@@ -372,6 +386,13 @@ static llvm::raw_ostream &operator<<(llv
 void foreachElt(NonowningIslPtr<isl_union_map> UMap,
                 const std::function<void(IslPtr<isl_map> Map)> &F);
 
+/// Enumerate all isl_sets of an isl_union_set.
+///
+/// This basically wraps isl_union_set_foreach_set() and allows to call back
+/// C++11 closures.
+void foreachElt(NonowningIslPtr<isl_union_set> USet,
+                const std::function<void(IslPtr<isl_set> Set)> &F);
+
 /// Enumerate all isl_pw_aff of an isl_union_pw_aff.
 ///
 /// This basically wraps isl_union_pw_aff(), but also allows to call back C++11

Modified: polly/trunk/lib/Support/GICHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/GICHelper.cpp?rev=288924&r1=288923&r2=288924&view=diff
==============================================================================
--- polly/trunk/lib/Support/GICHelper.cpp (original)
+++ polly/trunk/lib/Support/GICHelper.cpp Wed Dec  7 11:47:57 2016
@@ -225,6 +225,34 @@ DEFINE_ISLPTR(multi_union_pw_aff)
 DEFINE_ISLPTR(union_pw_multi_aff)
 }
 
+void polly::foreachElt(NonowningIslPtr<isl_map> Map,
+                       const std::function<void(IslPtr<isl_basic_map>)> &F) {
+  isl_map_foreach_basic_map(
+      Map.keep(),
+      [](__isl_take isl_basic_map *BMap, void *User) -> isl_stat {
+        auto &F =
+            *static_cast<const std::function<void(IslPtr<isl_basic_map>)> *>(
+                User);
+        F(give(BMap));
+        return isl_stat_ok;
+      },
+      const_cast<void *>(static_cast<const void *>(&F)));
+}
+
+void polly::foreachElt(NonowningIslPtr<isl_set> Set,
+                       const std::function<void(IslPtr<isl_basic_set>)> &F) {
+  isl_set_foreach_basic_set(
+      Set.keep(),
+      [](__isl_take isl_basic_set *BSet, void *User) -> isl_stat {
+        auto &F =
+            *static_cast<const std::function<void(IslPtr<isl_basic_set>)> *>(
+                User);
+        F(give(BSet));
+        return isl_stat_ok;
+      },
+      const_cast<void *>(static_cast<const void *>(&F)));
+}
+
 void polly::foreachElt(NonowningIslPtr<isl_union_map> UMap,
                        const std::function<void(IslPtr<isl_map> Map)> &F) {
   isl_union_map_foreach_map(
@@ -236,6 +264,19 @@ void polly::foreachElt(NonowningIslPtr<i
         return isl_stat_ok;
       },
       const_cast<void *>(static_cast<const void *>(&F)));
+}
+
+void polly::foreachElt(NonowningIslPtr<isl_union_set> USet,
+                       const std::function<void(IslPtr<isl_set> Set)> &F) {
+  isl_union_set_foreach_set(
+      USet.keep(),
+      [](__isl_take isl_set *Set, void *User) -> isl_stat {
+        auto &F =
+            *static_cast<const std::function<void(IslPtr<isl_set>)> *>(User);
+        F(give(Set));
+        return isl_stat_ok;
+      },
+      const_cast<void *>(static_cast<const void *>(&F)));
 }
 
 void polly::foreachElt(NonowningIslPtr<isl_union_pw_aff> UPwAff,




More information about the llvm-commits mailing list