Add more ISL foreachElt functions. NFC.
authorMichael Kruse <llvm@meinersbur.de>
Wed, 7 Dec 2016 17:47:57 +0000 (17:47 +0000)
committerMichael Kruse <llvm@meinersbur.de>
Wed, 7 Dec 2016 17:47:57 +0000 (17:47 +0000)
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.

llvm-svn: 288924

polly/include/polly/Support/GICHelper.h
polly/lib/Support/GICHelper.cpp

index dc9a01c..29b7b54 100644 (file)
@@ -365,6 +365,20 @@ static llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
   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<<(llvm::raw_ostream &OS,
 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
index 833cb03..5b3fe30 100644 (file)
@@ -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(
@@ -238,6 +266,19 @@ void polly::foreachElt(NonowningIslPtr<isl_union_map> UMap,
       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,
                        const std::function<void(IslPtr<isl_pw_aff>)> &F) {
   isl_union_pw_aff_foreach_pw_aff(