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.isZero() || Aff.isOne()) return true;
Type conversion
Before:
isl_union_pw_multi_aff *UPMA = isl_union_pw_multi_aff_from_union_map(umap);
After:
isl::UnionPwMultiAff UPMA = UMap;
Type construction
Before:
auto *Empty = isl_union_map_empty(space);
After:
auto Empty = isl::UnionMap::empty(Space);
Operations
Before:
set = isl_union_set_intersect(set, set2);
After:
Set = Set.intersect(Set2);