summaryrefslogtreecommitdiffstats
path: root/polly/lib/External/isl/isl_space.c
diff options
context:
space:
mode:
Diffstat (limited to 'polly/lib/External/isl/isl_space.c')
-rw-r--r--polly/lib/External/isl/isl_space.c135
1 files changed, 93 insertions, 42 deletions
diff --git a/polly/lib/External/isl/isl_space.c b/polly/lib/External/isl/isl_space.c
index 0ddacc23b34..53beee660da 100644
--- a/polly/lib/External/isl/isl_space.c
+++ b/polly/lib/External/isl/isl_space.c
@@ -821,15 +821,6 @@ isl_bool isl_space_tuple_is_equal(__isl_keep isl_space *space1,
return isl_bool_true;
}
-/* This is the old, undocumented, name for isl_space_tuple_is_equal.
- * It will be removed at some point.
- */
-int isl_space_tuple_match(__isl_keep isl_space *space1, enum isl_dim_type type1,
- __isl_keep isl_space *space2, enum isl_dim_type type2)
-{
- return isl_space_tuple_is_equal(space1, type1, space2, type2);
-}
-
static isl_bool match(__isl_keep isl_space *space1, enum isl_dim_type type1,
__isl_keep isl_space *space2, enum isl_dim_type type2)
{
@@ -985,6 +976,33 @@ error:
return NULL;
}
+/* Add a parameter with identifier "id" to "space", provided
+ * it does not already appear in "space".
+ */
+__isl_give isl_space *isl_space_add_param_id(__isl_take isl_space *space,
+ __isl_take isl_id *id)
+{
+ int pos;
+
+ if (!space || !id)
+ goto error;
+
+ if (isl_space_find_dim_by_id(space, isl_dim_param, id) >= 0) {
+ isl_id_free(id);
+ return space;
+ }
+
+ pos = isl_space_dim(space, isl_dim_param);
+ space = isl_space_add_dims(space, isl_dim_param, 1);
+ space = isl_space_set_dim_id(space, isl_dim_param, pos, id);
+
+ return space;
+error:
+ isl_space_free(space);
+ isl_id_free(id);
+ return NULL;
+}
+
static int valid_dim_type(enum isl_dim_type type)
{
switch (type) {
@@ -1157,8 +1175,8 @@ __isl_give isl_space *isl_space_move_dims(__isl_take isl_space *space,
for (i = 0; i < 2; ++i) {
if (!space->nested[i])
continue;
- space->nested[i] = isl_space_replace(space->nested[i],
- isl_dim_param, space);
+ space->nested[i] = isl_space_replace_params(space->nested[i],
+ space);
if (!space->nested[i])
goto error;
}
@@ -1321,15 +1339,6 @@ error:
return NULL;
}
-/* Given a space of the form [A -> B] -> [C -> D], return the space A -> C.
- */
-__isl_give isl_space *isl_space_factor_domain(__isl_take isl_space *space)
-{
- space = isl_space_domain_factor_domain(space);
- space = isl_space_range_factor_domain(space);
- return space;
-}
-
/* Given a space of the form [A -> B] -> C, return the space A -> C.
*/
__isl_give isl_space *isl_space_domain_factor_domain(
@@ -1407,19 +1416,18 @@ error:
return NULL;
}
-/* Given a space of the form A -> [B -> C], return the space A -> B.
+/* Internal function that selects the domain of the map that is
+ * embedded in either a set space or the range of a map space.
+ * In particular, given a space of the form [A -> B], return the space A.
+ * Given a space of the form A -> [B -> C], return the space A -> B.
*/
-__isl_give isl_space *isl_space_range_factor_domain(
- __isl_take isl_space *space)
+static __isl_give isl_space *range_factor_domain(__isl_take isl_space *space)
{
isl_space *nested;
isl_space *domain;
if (!space)
return NULL;
- if (!isl_space_range_is_wrapping(space))
- isl_die(isl_space_get_ctx(space), isl_error_invalid,
- "range not a product", return isl_space_free(space));
nested = space->nested[1];
domain = isl_space_copy(space);
@@ -1446,6 +1454,47 @@ error:
return NULL;
}
+/* Given a space of the form A -> [B -> C], return the space A -> B.
+ */
+__isl_give isl_space *isl_space_range_factor_domain(
+ __isl_take isl_space *space)
+{
+ if (!space)
+ return NULL;
+ if (!isl_space_range_is_wrapping(space))
+ isl_die(isl_space_get_ctx(space), isl_error_invalid,
+ "range not a product", return isl_space_free(space));
+
+ return range_factor_domain(space);
+}
+
+/* Given a space of the form [A -> B], return the space A.
+ */
+static __isl_give isl_space *set_factor_domain(__isl_take isl_space *space)
+{
+ if (!space)
+ return NULL;
+ if (!isl_space_is_wrapping(space))
+ isl_die(isl_space_get_ctx(space), isl_error_invalid,
+ "not a product", return isl_space_free(space));
+
+ return range_factor_domain(space);
+}
+
+/* Given a space of the form [A -> B] -> [C -> D], return the space A -> C.
+ * Given a space of the form [A -> B], return the space A.
+ */
+__isl_give isl_space *isl_space_factor_domain(__isl_take isl_space *space)
+{
+ if (!space)
+ return NULL;
+ if (isl_space_is_set(space))
+ return set_factor_domain(space);
+ space = isl_space_domain_factor_domain(space);
+ space = isl_space_range_factor_domain(space);
+ return space;
+}
+
/* Internal function that selects the range of the map that is
* embedded in either a set space or the range of a map space.
* In particular, given a space of the form [A -> B], return the space B.
@@ -2212,31 +2261,33 @@ __isl_give isl_space *isl_space_flatten(__isl_take isl_space *dim)
return dim;
}
-__isl_give isl_space *isl_space_flatten_domain(__isl_take isl_space *dim)
+__isl_give isl_space *isl_space_flatten_domain(__isl_take isl_space *space)
{
- if (!dim)
+ if (!space)
return NULL;
- if (!dim->nested[0])
- return dim;
+ if (!space->nested[0])
+ return space;
- return isl_space_reset(dim, isl_dim_in);
+ return isl_space_reset(space, isl_dim_in);
}
-__isl_give isl_space *isl_space_flatten_range(__isl_take isl_space *dim)
+__isl_give isl_space *isl_space_flatten_range(__isl_take isl_space *space)
{
- if (!dim)
+ if (!space)
return NULL;
- if (!dim->nested[1])
- return dim;
+ if (!space->nested[1])
+ return space;
- return isl_space_reset(dim, isl_dim_out);
+ return isl_space_reset(space, isl_dim_out);
}
-/* Replace the dimensions of the given type of dst by those of src.
+/* Replace the parameters of dst by those of src.
*/
-__isl_give isl_space *isl_space_replace(__isl_take isl_space *dst,
- enum isl_dim_type type, __isl_keep isl_space *src)
+__isl_give isl_space *isl_space_replace_params(__isl_take isl_space *dst,
+ __isl_keep isl_space *src)
{
+ enum isl_dim_type type = isl_dim_param;
+
dst = isl_space_cow(dst);
if (!dst || !src)
@@ -2246,13 +2297,13 @@ __isl_give isl_space *isl_space_replace(__isl_take isl_space *dst,
dst = isl_space_add_dims(dst, type, isl_space_dim(src, type));
dst = copy_ids(dst, type, 0, src, type);
- if (dst && type == isl_dim_param) {
+ if (dst) {
int i;
for (i = 0; i <= 1; ++i) {
if (!dst->nested[i])
continue;
- dst->nested[i] = isl_space_replace(dst->nested[i],
- type, src);
+ dst->nested[i] = isl_space_replace_params(
+ dst->nested[i], src);
if (!dst->nested[i])
goto error;
}
OpenPOWER on IntegriCloud