hanchenye-llvm-project/polly/lib
Tobias Grosser 3e618c33fe [DeadCodeElimination] Translate to C++ bindings
This pass is a small and self-contained example of a piece of code that was
written with the isl C interface. The diff of this change nicely shows how the
C++ bindings can improve the readability of the code by avoiding the long C
function names and by avoiding any need for memory management.

As you will see, no calls to isl_*_copy or isl_*_free are needed anymore.
Instead the C++ interface takes care of automatically managing the objects.
This may introduce internally additional copies, but due to the isl reference
counting, such copies are expected to be cheap. For performance critical
operations, we will later exploit move semantics to eliminate unnecessary
copies that have shown to be costly.

Below we give a set of examples that shows the benefit of the C++ interface vs.
the pure C interface.

Check properties
----------------

Before:

  if (isl_aff_is_zero(aff) ||  isl_aff_is_one(aff))
    return true;

After:

  if (Aff.is_zero() || Aff.is_one())
    return true;

Type conversion
---------------

Before:

  isl_union_pw_multi_aff *UPMA = isl_union_pw_multi_aff_from_union_map(umap);

After:

  isl::union_pw_multi_aff UPMA = UMap;

Type construction
-----------------

Before:

  auto *Empty = isl_union_map_empty(space);

After:

  auto Empty = isl::union_map::empty(Space);

Operations
----------

Before:

  set = isl_union_set_intersect(set, set2);

After:

  Set = Set.intersect(Set2);

The use of isl::boolean in return types also adds an increases the robustness
of Polly, as on conversion to true or false, we verify that no isl_bool_error
has been returned and assert in case an error was returned. Before this change
we would have just ignored the error and proceeded with (some) exection path.

Tags: #polly

Reviewed By: Meinersbur

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

llvm-svn: 297466
2017-03-10 15:05:38 +00:00
..
Analysis [ScopDetect/Info] Allow unconditional hoisting of loads from dereferenceable ptrs 2017-03-09 11:36:00 +00:00
CodeGen Fix namespaces after clang-format update 2017-03-01 15:54:27 +00:00
Exchange Perform copying to created arrays according to the packing transformation 2016-09-14 06:26:09 +00:00
External Add method interface to isl C++ bindings 2017-03-10 14:53:00 +00:00
Support Introduce isl C++ bindings, Part 1: value_ptr style interface 2017-03-10 11:41:03 +00:00
Transform [DeadCodeElimination] Translate to C++ bindings 2017-03-10 15:05:38 +00:00
CMakeLists.txt [Support] Add -polly-dump-module pass. 2017-03-09 22:29:58 +00:00
Polly.cpp Drop '@brief' from doxygen comments 2016-09-02 06:33:33 +00:00