Use isl C++ foreach implementation
commitfd4d10466aba897b4a938053e96d2d2d5479c243
authorTobias Grosser <tobias@grosser.es>
Fri, 14 Apr 2017 13:39:40 +0000 (14 13:39 +0000)
committerTobias Grosser <tobias@grosser.es>
Fri, 14 Apr 2017 13:39:40 +0000 (14 13:39 +0000)
tree3e1dae990c4714f54ce34cdf91024da2195209b3
parentb78ade14248e5fb48bd40d7a1b16e0efcae4e6e3
Use isl C++ foreach implementation

This commit switches Polly over to the isl::obj::foreach_* implementation, which
is part of the new isl bindings and follows the foreach pattern established in
Polly by Michael Kruse.

The original isl C function:

  isl_stat isl_union_set_foreach_set(__isl_keep isl_union_set *uset,
      isl_stat (*fn)(__isl_take isl_set *set, void *user), void *user);

which required the user to define a static callback function to which all
interesting parameters are passed via a 'void *' user-pointer, is on the
C++ side available as a function that takes a std::function<>, which can
carry any additional arguments without the need for a user pointer:

  stat UnionSet::foreach_set(const std::function<stat(set)> &fn) const;

The following code illustrates the use of the new C++ interface:

  auto Lambda = [=, &Result](isl::set Set) -> isl::stat {
    auto Shifted = shiftDimension(Set, Pos, Amount);
    Result = Result.add(Shifted);
    return isl::stat::ok;
  }

  UnionSet.foreach_set(Lambda);

Polly had some specialized foreach functions which did not require the lambdas
to return a status flag. We remove these functions in this commit to move Polly
completely over to the new isl interface. We may in the future discuss if
functors without return values can be supported easily.

Another extension proposed by Michael Kruse is the use of C++ iterators to allow
the use of normal for loops to iterate over these sets. Such an extension would
allow us to further simplify the code.

Reviewed-by: Michael Kruse <llvm@meinersbur.de>
Differential Revision: https://reviews.llvm.org/D30620

git-svn-id: https://llvm.org/svn/llvm-project/polly/trunk@300323 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Support/GICHelper.cpp
lib/Support/ISLTools.cpp
lib/Transform/FlattenAlgo.cpp
lib/Transform/FlattenSchedule.cpp
unittests/DeLICM/DeLICMTest.cpp
unittests/Isl/IslTest.cpp