[polly] r311123 - [GPGPU] Move getExtend to C++ [NFC]
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 17 14:20:28 PDT 2017
Author: grosser
Date: Thu Aug 17 14:20:28 2017
New Revision: 311123
URL: http://llvm.org/viewvc/llvm-project?rev=311123&view=rev
Log:
[GPGPU] Move getExtend to C++ [NFC]
Modified:
polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
Modified: polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp?rev=311123&r1=311122&r2=311123&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp Thu Aug 17 14:20:28 2017
@@ -2760,77 +2760,58 @@ public:
/// @param Array The array to derive the extent for.
///
/// @returns An isl_set describing the extent of the array.
- __isl_give isl_set *getExtent(ScopArrayInfo *Array) {
+ isl::set getExtent(ScopArrayInfo *Array) {
unsigned NumDims = Array->getNumberOfDimensions();
- isl_union_map *Accesses = S->getAccesses().release();
- Accesses =
- isl_union_map_intersect_domain(Accesses, S->getDomains().release());
- Accesses = isl_union_map_detect_equalities(Accesses);
- isl_union_set *AccessUSet = isl_union_map_range(Accesses);
- AccessUSet = isl_union_set_coalesce(AccessUSet);
- AccessUSet = isl_union_set_detect_equalities(AccessUSet);
- AccessUSet = isl_union_set_coalesce(AccessUSet);
-
- if (isl_union_set_is_empty(AccessUSet)) {
- isl_union_set_free(AccessUSet);
- return isl_set_empty(Array->getSpace().release());
- }
-
- if (Array->getNumberOfDimensions() == 0) {
- isl_union_set_free(AccessUSet);
- return isl_set_universe(Array->getSpace().release());
- }
+ isl::union_map Accesses = S->getAccesses();
+ Accesses = Accesses.intersect_domain(S->getDomains());
+ Accesses = Accesses.detect_equalities();
+ isl::union_set AccessUSet = Accesses.range();
+ AccessUSet = AccessUSet.coalesce();
+ AccessUSet = AccessUSet.detect_equalities();
+ AccessUSet = AccessUSet.coalesce();
+
+ if (AccessUSet.is_empty())
+ return isl::set::empty(Array->getSpace());
+
+ if (Array->getNumberOfDimensions() == 0)
+ return isl::set::universe(Array->getSpace());
+
+ isl::set AccessSet = AccessUSet.extract_set(Array->getSpace());
+
+ isl::local_space LS = isl::local_space(Array->getSpace());
+
+ isl::pw_aff Val = isl::aff::var_on_domain(LS, isl::dim::set, 0);
+ isl::pw_aff OuterMin = AccessSet.dim_min(0);
+ isl::pw_aff OuterMax = AccessSet.dim_max(0);
+ OuterMin = OuterMin.add_dims(isl::dim::in, Val.dim(isl::dim::in));
+ OuterMax = OuterMax.add_dims(isl::dim::in, Val.dim(isl::dim::in));
+ OuterMin = OuterMin.set_tuple_id(isl::dim::in, Array->getBasePtrId());
+ OuterMax = OuterMax.set_tuple_id(isl::dim::in, Array->getBasePtrId());
- isl_set *AccessSet =
- isl_union_set_extract_set(AccessUSet, Array->getSpace().release());
+ isl::set Extent = isl::set::universe(Array->getSpace());
- isl_union_set_free(AccessUSet);
- isl_local_space *LS =
- isl_local_space_from_space(Array->getSpace().release());
-
- isl_pw_aff *Val =
- isl_pw_aff_from_aff(isl_aff_var_on_domain(LS, isl_dim_set, 0));
-
- isl_pw_aff *OuterMin = isl_set_dim_min(isl_set_copy(AccessSet), 0);
- isl_pw_aff *OuterMax = isl_set_dim_max(AccessSet, 0);
- OuterMin = isl_pw_aff_add_dims(OuterMin, isl_dim_in,
- isl_pw_aff_dim(Val, isl_dim_in));
- OuterMax = isl_pw_aff_add_dims(OuterMax, isl_dim_in,
- isl_pw_aff_dim(Val, isl_dim_in));
- OuterMin = isl_pw_aff_set_tuple_id(OuterMin, isl_dim_in,
- Array->getBasePtrId().release());
- OuterMax = isl_pw_aff_set_tuple_id(OuterMax, isl_dim_in,
- Array->getBasePtrId().release());
-
- isl_set *Extent = isl_set_universe(Array->getSpace().release());
-
- Extent = isl_set_intersect(
- Extent, isl_pw_aff_le_set(OuterMin, isl_pw_aff_copy(Val)));
- Extent = isl_set_intersect(Extent, isl_pw_aff_ge_set(OuterMax, Val));
+ Extent = Extent.intersect(OuterMin.le_set(Val));
+ Extent = Extent.intersect(OuterMax.ge_set(Val));
for (unsigned i = 1; i < NumDims; ++i)
- Extent = isl_set_lower_bound_si(Extent, isl_dim_set, i, 0);
+ Extent = Extent.lower_bound_si(isl::dim::set, i, 0);
for (unsigned i = 0; i < NumDims; ++i) {
- isl_pw_aff *PwAff =
- const_cast<isl_pw_aff *>(Array->getDimensionSizePw(i).release());
+ isl::pw_aff PwAff = Array->getDimensionSizePw(i);
// isl_pw_aff can be NULL for zero dimension. Only in the case of a
// Fortran array will we have a legitimate dimension.
- if (!PwAff) {
+ if (PwAff.is_null()) {
assert(i == 0 && "invalid dimension isl_pw_aff for nonzero dimension");
continue;
}
- isl_pw_aff *Val = isl_pw_aff_from_aff(isl_aff_var_on_domain(
- isl_local_space_from_space(Array->getSpace().release()), isl_dim_set,
- i));
- PwAff = isl_pw_aff_add_dims(PwAff, isl_dim_in,
- isl_pw_aff_dim(Val, isl_dim_in));
- PwAff = isl_pw_aff_set_tuple_id(PwAff, isl_dim_in,
- isl_pw_aff_get_tuple_id(Val, isl_dim_in));
- auto *Set = isl_pw_aff_gt_set(PwAff, Val);
- Extent = isl_set_intersect(Set, Extent);
+ isl::pw_aff Val = isl::aff::var_on_domain(
+ isl::local_space(Array->getSpace()), isl::dim::set, i);
+ PwAff = PwAff.add_dims(isl::dim::in, Val.dim(isl::dim::in));
+ PwAff = PwAff.set_tuple_id(isl::dim::in, Val.get_tuple_id(isl::dim::in));
+ isl::set Set = PwAff.gt_set(Val);
+ Extent = Set.intersect(Extent);
}
return Extent;
@@ -2931,7 +2912,7 @@ public:
PPCGArray.name = strdup(Array->getName().c_str());
PPCGArray.extent = nullptr;
PPCGArray.n_index = Array->getNumberOfDimensions();
- PPCGArray.extent = getExtent(Array);
+ PPCGArray.extent = getExtent(Array).release();
PPCGArray.n_ref = 0;
PPCGArray.refs = nullptr;
PPCGArray.accessed = true;
@@ -3008,7 +2989,7 @@ public:
// 2. Arrays with statically known zero size.
auto ValidSAIsRange =
make_filter_range(S->arrays(), [this](ScopArrayInfo *SAI) -> bool {
- return !isl::manage(getExtent(SAI)).is_empty();
+ return !getExtent(SAI).is_empty();
});
SmallVector<ScopArrayInfo *, 4> ValidSAIs(ValidSAIsRange.begin(),
ValidSAIsRange.end());
More information about the llvm-commits
mailing list