#define S(TYPE,NAME) xS(TYPE,NAME)
#ifdef HAS_TYPE
-static __isl_give PW *FN(PW,alloc_)(__isl_take isl_dim *dim,
+__isl_give PW *FN(PW,alloc_size)(__isl_take isl_space *dim,
enum isl_fold type, int n)
#else
-static __isl_give PW *FN(PW,alloc_)(__isl_take isl_dim *dim, int n)
+__isl_give PW *FN(PW,alloc_size)(__isl_take isl_space *dim, int n)
#endif
{
isl_ctx *ctx;
if (!dim)
return NULL;
- ctx = isl_dim_get_ctx(dim);
+ ctx = isl_space_get_ctx(dim);
isl_assert(ctx, n >= 0, goto error);
pw = isl_alloc(ctx, struct PW,
sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
pw->dim = dim;
return pw;
error:
- isl_dim_free(dim);
+ isl_space_free(dim);
return NULL;
}
#ifdef HAS_TYPE
-__isl_give PW *FN(PW,ZERO)(__isl_take isl_dim *dim, enum isl_fold type)
+__isl_give PW *FN(PW,ZERO)(__isl_take isl_space *dim, enum isl_fold type)
{
- return FN(PW,alloc_)(dim, type, 0);
+ return FN(PW,alloc_size)(dim, type, 0);
}
#else
-__isl_give PW *FN(PW,ZERO)(__isl_take isl_dim *dim)
+__isl_give PW *FN(PW,ZERO)(__isl_take isl_space *dim)
{
- return FN(PW,alloc_)(dim, 0);
+ return FN(PW,alloc_size)(dim, 0);
}
#endif
__isl_take isl_set *set, __isl_take EL *el)
{
isl_ctx *ctx;
- isl_dim *el_dim = NULL;
+ isl_space *el_dim = NULL;
if (!pw || !set || !el)
goto error;
isl_die(ctx, isl_error_invalid, "fold types don't match",
goto error);
#endif
- el_dim = FN(EL,get_dim(el));
- isl_assert(ctx, isl_dim_equal(pw->dim, el_dim), goto error);
+ el_dim = FN(EL,get_space(el));
+ isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
isl_assert(ctx, pw->n < pw->size, goto error);
pw->p[pw->n].set = set;
pw->p[pw->n].FIELD = el;
pw->n++;
- isl_dim_free(el_dim);
+ isl_space_free(el_dim);
return pw;
error:
- isl_dim_free(el_dim);
+ isl_space_free(el_dim);
FN(PW,free)(pw);
isl_set_free(set);
FN(EL,free)(el);
goto error;
#ifdef HAS_TYPE
- pw = FN(PW,alloc_)(isl_set_get_dim(set), type, 1);
+ pw = FN(PW,alloc_size)(isl_set_get_space(set), type, 1);
#else
- pw = FN(PW,alloc_)(isl_set_get_dim(set), 1);
+ pw = FN(PW,alloc_size)(isl_set_get_space(set), 1);
#endif
return FN(PW,add_piece)(pw, set, el);
return NULL;
#ifdef HAS_TYPE
- dup = FN(PW,alloc_)(isl_dim_copy(pw->dim), pw->type, pw->n);
+ dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
#else
- dup = FN(PW,alloc_)(isl_dim_copy(pw->dim), pw->n);
+ dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
#endif
if (!dup)
return NULL;
isl_set_free(pw->p[i].set);
FN(EL,free)(pw->p[i].FIELD);
}
- isl_dim_free(pw->dim);
+ isl_space_free(pw->dim);
free(pw);
return NULL;
return pw->n == 0;
}
-__isl_give PW *FN(PW,add)(__isl_take PW *pw1, __isl_take PW *pw2)
+#ifndef NO_REALIGN
+__isl_give PW *FN(PW,realign)(__isl_take PW *pw, __isl_take isl_reordering *exp)
+{
+ int i;
+
+ pw = FN(PW,cow)(pw);
+ if (!pw || !exp)
+ return NULL;
+
+ for (i = 0; i < pw->n; ++i) {
+ pw->p[i].set = isl_set_realign(pw->p[i].set,
+ isl_reordering_copy(exp));
+ if (!pw->p[i].set)
+ goto error;
+ pw->p[i].FIELD = FN(EL,realign)(pw->p[i].FIELD,
+ isl_reordering_copy(exp));
+ if (!pw->p[i].FIELD)
+ goto error;
+ }
+
+ pw = FN(PW,reset_space)(pw, isl_space_copy(exp->dim));
+
+ isl_reordering_free(exp);
+ return pw;
+error:
+ isl_reordering_free(exp);
+ FN(PW,free)(pw);
+ return NULL;
+}
+
+/* Align the parameters of "pw" to those of "model".
+ */
+__isl_give PW *FN(PW,align_params)(__isl_take PW *pw, __isl_take isl_space *model)
+{
+ isl_ctx *ctx;
+
+ if (!pw || !model)
+ goto error;
+
+ ctx = isl_space_get_ctx(model);
+ if (!isl_space_has_named_params(model))
+ isl_die(ctx, isl_error_invalid,
+ "model has unnamed parameters", goto error);
+ if (!isl_space_has_named_params(pw->dim))
+ isl_die(ctx, isl_error_invalid,
+ "input has unnamed parameters", goto error);
+ if (!isl_space_match(pw->dim, isl_dim_param, model, isl_dim_param)) {
+ isl_reordering *exp;
+
+ model = isl_space_drop_dims(model, isl_dim_in,
+ 0, isl_space_dim(model, isl_dim_in));
+ model = isl_space_drop_dims(model, isl_dim_out,
+ 0, isl_space_dim(model, isl_dim_out));
+ exp = isl_parameter_alignment_reordering(pw->dim, model);
+ exp = isl_reordering_extend_space(exp, FN(PW,get_space)(pw));
+ pw = FN(PW,realign)(pw, exp);
+ }
+
+ isl_space_free(model);
+ return pw;
+error:
+ isl_space_free(model);
+ FN(PW,free)(pw);
+ return NULL;
+}
+
+static __isl_give PW *align_params_pw_pw_and(__isl_take PW *pw1,
+ __isl_take PW *pw2,
+ __isl_give PW *(*fn)(__isl_take PW *pw1, __isl_take PW *pw2))
+{
+ isl_ctx *ctx;
+
+ if (!pw1 || !pw2)
+ goto error;
+ if (isl_space_match(pw1->dim, isl_dim_param, pw2->dim, isl_dim_param))
+ return fn(pw1, pw2);
+ ctx = FN(PW,get_ctx)(pw1);
+ if (!isl_space_has_named_params(pw1->dim) ||
+ !isl_space_has_named_params(pw2->dim))
+ isl_die(ctx, isl_error_invalid,
+ "unaligned unnamed parameters", goto error);
+ pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
+ pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
+ return fn(pw1, pw2);
+error:
+ FN(PW,free)(pw1);
+ FN(PW,free)(pw2);
+ return NULL;
+}
+
+static __isl_give PW *align_params_pw_set_and(__isl_take PW *pw,
+ __isl_take isl_set *set,
+ __isl_give PW *(*fn)(__isl_take PW *pw, __isl_take isl_set *set))
+{
+ isl_ctx *ctx;
+
+ if (!pw || !set)
+ goto error;
+ if (isl_space_match(pw->dim, isl_dim_param, set->dim, isl_dim_param))
+ return fn(pw, set);
+ ctx = FN(PW,get_ctx)(pw);
+ if (!isl_space_has_named_params(pw->dim) ||
+ !isl_space_has_named_params(set->dim))
+ isl_die(ctx, isl_error_invalid,
+ "unaligned unnamed parameters", goto error);
+ pw = FN(PW,align_params)(pw, isl_set_get_space(set));
+ set = isl_set_align_params(set, FN(PW,get_space)(pw));
+ return fn(pw, set);
+error:
+ FN(PW,free)(pw);
+ isl_set_free(set);
+ return NULL;
+}
+#endif
+
+static __isl_give PW *FN(PW,add_aligned)(__isl_take PW *pw1, __isl_take PW *pw2)
{
int i, j, n;
struct PW *res;
if (!pw1 || !pw2)
goto error;
- ctx = isl_dim_get_ctx(pw1->dim);
+ ctx = isl_space_get_ctx(pw1->dim);
#ifdef HAS_TYPE
if (pw1->type != pw2->type)
isl_die(ctx, isl_error_invalid,
"fold types don't match", goto error);
#endif
- isl_assert(ctx, isl_dim_equal(pw1->dim, pw2->dim), goto error);
+ isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
if (FN(PW,IS_ZERO)(pw1)) {
FN(PW,free)(pw1);
n = (pw1->n + 1) * (pw2->n + 1);
#ifdef HAS_TYPE
- res = FN(PW,alloc_)(isl_dim_copy(pw1->dim), pw1->type, n);
+ res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
#else
- res = FN(PW,alloc_)(isl_dim_copy(pw1->dim), n);
+ res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
#endif
for (i = 0; i < pw1->n; ++i) {
return NULL;
}
-__isl_give PW *FN(PW,add_disjoint)(__isl_take PW *pw1, __isl_take PW *pw2)
+__isl_give PW *FN(PW,add)(__isl_take PW *pw1, __isl_take PW *pw2)
+{
+ return align_params_pw_pw_and(pw1, pw2, &FN(PW,add_aligned));
+}
+
+/* Make sure "pw" has room for at least "n" more pieces.
+ *
+ * If there is only one reference to pw, we extend it in place.
+ * Otherwise, we create a new PW and copy the pieces.
+ */
+static __isl_give PW *FN(PW,grow)(__isl_take PW *pw, int n)
{
int i;
isl_ctx *ctx;
PW *res;
+ if (!pw)
+ return NULL;
+ if (pw->n + n <= pw->size)
+ return pw;
+ ctx = FN(PW,get_ctx)(pw);
+ n += pw->n;
+ if (pw->ref == 1) {
+ res = isl_realloc(ctx, pw, struct PW,
+ sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
+ if (!res)
+ return FN(PW,free)(pw);
+ res->size = n;
+ return res;
+ }
+#ifdef HAS_TYPE
+ res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
+#else
+ res = FN(PW,alloc_size)(isl_space_copy(pw->dim), n);
+#endif
+ if (!res)
+ return FN(PW,free)(pw);
+ for (i = 0; i < pw->n; ++i)
+ res = FN(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
+ FN(EL,copy)(pw->p[i].FIELD));
+ FN(PW,free)(pw);
+ return res;
+}
+
+static __isl_give PW *FN(PW,add_disjoint_aligned)(__isl_take PW *pw1,
+ __isl_take PW *pw2)
+{
+ int i;
+ isl_ctx *ctx;
+
if (!pw1 || !pw2)
goto error;
- ctx = isl_dim_get_ctx(pw1->dim);
+ if (pw1->size < pw1->n + pw2->n && pw1->n < pw2->n)
+ return FN(PW,add_disjoint_aligned)(pw2, pw1);
+
+ ctx = isl_space_get_ctx(pw1->dim);
#ifdef HAS_TYPE
if (pw1->type != pw2->type)
isl_die(ctx, isl_error_invalid,
"fold types don't match", goto error);
#endif
- isl_assert(ctx, isl_dim_equal(pw1->dim, pw2->dim), goto error);
+ isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
if (FN(PW,IS_ZERO)(pw1)) {
FN(PW,free)(pw1);
return pw1;
}
-#ifdef HAS_TYPE
- res = FN(PW,alloc_)(isl_dim_copy(pw1->dim), pw1->type, pw1->n + pw2->n);
-#else
- res = FN(PW,alloc_)(isl_dim_copy(pw1->dim), pw1->n + pw2->n);
-#endif
-
- for (i = 0; i < pw1->n; ++i)
- res = FN(PW,add_piece)(res,
- isl_set_copy(pw1->p[i].set),
- FN(EL,copy)(pw1->p[i].FIELD));
+ pw1 = FN(PW,grow)(pw1, pw2->n);
+ if (!pw1)
+ goto error;
for (i = 0; i < pw2->n; ++i)
- res = FN(PW,add_piece)(res,
+ pw1 = FN(PW,add_piece)(pw1,
isl_set_copy(pw2->p[i].set),
FN(EL,copy)(pw2->p[i].FIELD));
- FN(PW,free)(pw1);
FN(PW,free)(pw2);
- return res;
+ return pw1;
error:
FN(PW,free)(pw1);
FN(PW,free)(pw2);
return NULL;
}
+__isl_give PW *FN(PW,add_disjoint)(__isl_take PW *pw1, __isl_take PW *pw2)
+{
+ return align_params_pw_pw_and(pw1, pw2, &FN(PW,add_disjoint_aligned));
+}
+
#ifndef NO_NEG
__isl_give PW *FN(PW,neg)(__isl_take PW *pw)
{
return pw;
}
+
+__isl_give PW *FN(PW,sub)(__isl_take PW *pw1, __isl_take PW *pw2)
+{
+ return FN(PW,add)(pw1, FN(PW,neg)(pw2));
+}
#endif
#ifndef NO_EVAL
int i;
int found = 0;
isl_ctx *ctx;
- isl_dim *pnt_dim = NULL;
+ isl_space *pnt_dim = NULL;
isl_qpolynomial *qp;
if (!pw || !pnt)
goto error;
ctx = isl_point_get_ctx(pnt);
- pnt_dim = isl_point_get_dim(pnt);
- isl_assert(ctx, isl_dim_equal(pnt_dim, pw->dim), goto error);
+ pnt_dim = isl_point_get_space(pnt);
+ isl_assert(ctx, isl_space_is_equal(pnt_dim, pw->dim), goto error);
for (i = 0; i < pw->n; ++i) {
found = isl_set_contains_point(pw->p[i].set, pnt);
qp = FN(EL,eval)(FN(EL,copy)(pw->p[i].FIELD),
isl_point_copy(pnt));
else
- qp = isl_qpolynomial_zero(isl_dim_copy(pw->dim));
+ qp = isl_qpolynomial_zero(isl_space_copy(pw->dim));
FN(PW,free)(pw);
- isl_dim_free(pnt_dim);
+ isl_space_free(pnt_dim);
isl_point_free(pnt);
return qp;
error:
FN(PW,free)(pw);
- isl_dim_free(pnt_dim);
+ isl_space_free(pnt_dim);
isl_point_free(pnt);
return NULL;
}
if (!pw)
return NULL;
- dom = isl_set_empty(isl_dim_copy(pw->dim));
+ dom = isl_set_empty(isl_space_copy(pw->dim));
for (i = 0; i < pw->n; ++i)
dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
return dom;
}
-__isl_give PW *FN(PW,intersect_domain)(__isl_take PW *pw, __isl_take isl_set *set)
+static __isl_give PW *FN(PW,intersect_domain_aligned)(__isl_take PW *pw,
+ __isl_take isl_set *set)
{
int i;
return NULL;
}
-__isl_give PW *FN(PW,gist)(__isl_take PW *pw, __isl_take isl_set *context)
+__isl_give PW *FN(PW,intersect_domain)(__isl_take PW *pw,
+ __isl_take isl_set *context)
+{
+ return align_params_pw_set_and(pw, context,
+ &FN(PW,intersect_domain_aligned));
+}
+
+static __isl_give PW *FN(PW,gist_aligned)(__isl_take PW *pw,
+ __isl_take isl_set *context)
{
int i;
isl_basic_set *hull = NULL;
return pw;
}
+ if (!isl_space_match(pw->dim, isl_dim_param,
+ context->dim, isl_dim_param)) {
+ pw = FN(PW,align_params)(pw, isl_set_get_space(context));
+ context = isl_set_align_params(context, FN(PW,get_space)(pw));
+ }
+
context = isl_set_compute_divs(context);
hull = isl_set_simple_hull(isl_set_copy(context));
return NULL;
}
+__isl_give PW *FN(PW,gist)(__isl_take PW *pw, __isl_take isl_set *context)
+{
+ return align_params_pw_set_and(pw, context, &FN(PW,gist_aligned));
+}
+
__isl_give PW *FN(PW,coalesce)(__isl_take PW *pw)
{
int i, j;
isl_ctx *FN(PW,get_ctx)(__isl_keep PW *pw)
{
- return pw ? isl_dim_get_ctx(pw->dim) : NULL;
+ return pw ? isl_space_get_ctx(pw->dim) : NULL;
}
#ifndef NO_INVOLVES_DIMS
if (!pw)
return NULL;
- pw->dim = isl_dim_set_name(pw->dim, type, pos, s);
+ pw->dim = isl_space_set_dim_name(pw->dim, type, pos, s);
if (!pw->dim)
goto error;
if (!pw)
return NULL;
- if (n == 0 && !isl_dim_get_tuple_name(pw->dim, type))
+ if (n == 0 && !isl_space_get_tuple_name(pw->dim, type))
return pw;
pw = FN(PW,cow)(pw);
if (!pw)
return NULL;
- pw->dim = isl_dim_drop(pw->dim, type, first, n);
+ pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
if (!pw->dim)
goto error;
for (i = 0; i < pw->n; ++i) {
FN(PW,free)(pw);
return NULL;
}
+
+/* This function is very similar to drop_dims.
+ * The only difference is that the cells may still involve
+ * the specified dimensions. They are removed using
+ * isl_set_project_out instead of isl_set_drop.
+ */
+__isl_give PW *FN(PW,project_out)(__isl_take PW *pw,
+ enum isl_dim_type type, unsigned first, unsigned n)
+{
+ int i;
+
+ if (!pw)
+ return NULL;
+ if (n == 0 && !isl_space_get_tuple_name(pw->dim, type))
+ return pw;
+
+ pw = FN(PW,cow)(pw);
+ if (!pw)
+ return NULL;
+ pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
+ if (!pw->dim)
+ goto error;
+ for (i = 0; i < pw->n; ++i) {
+ pw->p[i].set = isl_set_project_out(pw->p[i].set, type, first, n);
+ if (!pw->p[i].set)
+ goto error;
+ pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
+ if (!pw->p[i].FIELD)
+ goto error;
+ }
+
+ return pw;
+error:
+ FN(PW,free)(pw);
+ return NULL;
+}
+
+/* Project the domain of pw onto its parameter space.
+ */
+__isl_give PW *FN(PW,project_domain_on_params)(__isl_take PW *pw)
+{
+ isl_space *space;
+ unsigned n;
+
+ n = FN(PW,dim)(pw, isl_dim_set);
+ pw = FN(PW,project_out)(pw, isl_dim_set, 0, n);
+ space = FN(PW,get_space)(pw);
+ space = isl_space_params(space);
+ pw = FN(PW,reset_space)(pw, space);
+ return pw;
+}
#endif
#ifndef NO_INSERT_DIMS
if (!pw)
return NULL;
- if (n == 0 && !isl_dim_is_named_or_nested(pw->dim, type))
+ if (n == 0 && !isl_space_is_named_or_nested(pw->dim, type))
return pw;
pw = FN(PW,cow)(pw);
if (!pw)
return NULL;
- pw->dim = isl_dim_insert(pw->dim, type, first, n);
+ pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
if (!pw->dim)
goto error;
for (i = 0; i < pw->n; ++i) {
- pw->p[i].set = isl_set_insert(pw->p[i].set, type, first, n);
+ pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
+ type, first, n);
if (!pw->p[i].set)
goto error;
pw->p[i].FIELD = FN(EL,insert_dims)(pw->p[i].FIELD,
unsigned FN(PW,dim)(__isl_keep PW *pw, enum isl_dim_type type)
{
- return pw ? isl_dim_size(pw->dim, type) : 0;
+ return pw ? isl_space_dim(pw->dim, type) : 0;
}
__isl_give PW *FN(PW,split_dims)(__isl_take PW *pw,
return NULL;
if (pw->n == 0) {
- isl_dim *dim = isl_dim_copy(pw->dim);
+ isl_space *dim = isl_space_copy(pw->dim);
FN(PW,free)(pw);
return isl_qpolynomial_zero(dim);
}
}
#endif
-__isl_give isl_dim *FN(PW,get_dim)(__isl_keep PW *pw)
+__isl_give isl_space *FN(PW,get_space)(__isl_keep PW *pw)
{
- return pw ? isl_dim_copy(pw->dim) : NULL;
+ return pw ? isl_space_copy(pw->dim) : NULL;
}
#ifndef NO_RESET_DIM
-__isl_give PW *FN(PW,reset_dim)(__isl_take PW *pw, __isl_take isl_dim *dim)
+__isl_give PW *FN(PW,reset_space)(__isl_take PW *pw, __isl_take isl_space *dim)
{
int i;
goto error;
for (i = 0; i < pw->n; ++i) {
- pw->p[i].set = isl_set_reset_dim(pw->p[i].set,
- isl_dim_copy(dim));
+ pw->p[i].set = isl_set_reset_space(pw->p[i].set,
+ isl_space_copy(dim));
if (!pw->p[i].set)
goto error;
- pw->p[i].FIELD = FN(EL,reset_dim)(pw->p[i].FIELD,
- isl_dim_copy(dim));
+ pw->p[i].FIELD = FN(EL,reset_space)(pw->p[i].FIELD,
+ isl_space_copy(dim));
if (!pw->p[i].FIELD)
goto error;
}
- isl_dim_free(pw->dim);
+ isl_space_free(pw->dim);
pw->dim = dim;
return pw;
error:
- isl_dim_free(dim);
+ isl_space_free(dim);
FN(PW,free)(pw);
return NULL;
}
#endif
-int FN(PW,has_equal_dim)(__isl_keep PW *pw1, __isl_keep PW *pw2)
+int FN(PW,has_equal_space)(__isl_keep PW *pw1, __isl_keep PW *pw2)
{
if (!pw1 || !pw2)
return -1;
- return isl_dim_equal(pw1->dim, pw2->dim);
+ return isl_space_is_equal(pw1->dim, pw2->dim);
}
#ifndef NO_MORPH
if (!pw || !morph)
goto error;
- ctx = isl_dim_get_ctx(pw->dim);
- isl_assert(ctx, isl_dim_equal(pw->dim, morph->dom->dim),
+ ctx = isl_space_get_ctx(pw->dim);
+ isl_assert(ctx, isl_space_is_equal(pw->dim, morph->dom->dim),
goto error);
pw = FN(PW,cow)(pw);
if (!pw)
goto error;
- isl_dim_free(pw->dim);
- pw->dim = isl_dim_copy(morph->ran->dim);
+ isl_space_free(pw->dim);
+ pw->dim = isl_space_copy(morph->ran->dim);
if (!pw->dim)
goto error;
lift = isl_set_lift(lift);
copy = FN(EL,copy)(el);
- copy = FN(EL,lift)(copy, isl_set_get_dim(lift));
+ copy = FN(EL,lift)(copy, isl_set_get_space(lift));
if (fn(lift, copy, user) < 0)
goto error;
if (!pw)
return NULL;
- pw->dim = isl_dim_move(pw->dim, dst_type, dst_pos, src_type, src_pos, n);
+ pw->dim = isl_space_move_dims(pw->dim, dst_type, dst_pos, src_type, src_pos, n);
if (!pw->dim)
goto error;
}
#endif
-#ifndef NO_REALIGN
-__isl_give PW *FN(PW,realign)(__isl_take PW *pw, __isl_take isl_reordering *exp)
-{
- int i;
-
- pw = FN(PW,cow)(pw);
- if (!pw || !exp)
- return NULL;
-
- for (i = 0; i < pw->n; ++i) {
- pw->p[i].set = isl_set_realign(pw->p[i].set,
- isl_reordering_copy(exp));
- if (!pw->p[i].set)
- goto error;
- pw->p[i].FIELD = FN(EL,realign)(pw->p[i].FIELD,
- isl_reordering_copy(exp));
- if (!pw->p[i].FIELD)
- goto error;
- }
-
- pw = FN(PW,reset_dim)(pw, isl_dim_copy(exp->dim));
-
- isl_reordering_free(exp);
- return pw;
-error:
- isl_reordering_free(exp);
- FN(PW,free)(pw);
- return NULL;
-}
-
-/* Align the parameters of "pw" to those of "model".
- */
-__isl_give PW *FN(PW,align_params)(__isl_take PW *pw, __isl_take isl_dim *model)
-{
- isl_ctx *ctx;
-
- if (!pw || !model)
- goto error;
-
- ctx = isl_dim_get_ctx(model);
- if (!isl_dim_has_named_params(model))
- isl_die(ctx, isl_error_invalid,
- "model has unnamed parameters", goto error);
- if (!isl_dim_has_named_params(pw->dim))
- isl_die(ctx, isl_error_invalid,
- "input has unnamed parameters", goto error);
- if (!isl_dim_match(pw->dim, isl_dim_param, model, isl_dim_param)) {
- isl_reordering *exp;
-
- model = isl_dim_drop(model, isl_dim_in,
- 0, isl_dim_size(model, isl_dim_in));
- model = isl_dim_drop(model, isl_dim_out,
- 0, isl_dim_size(model, isl_dim_out));
- exp = isl_parameter_alignment_reordering(pw->dim, model);
- exp = isl_reordering_extend_dim(exp, FN(PW,get_dim)(pw));
- pw = FN(PW,realign)(pw, exp);
- }
-
- isl_dim_free(model);
- return pw;
-error:
- isl_dim_free(model);
- FN(PW,free)(pw);
- return NULL;
-}
-#endif
-
__isl_give PW *FN(PW,mul_isl_int)(__isl_take PW *pw, isl_int v)
{
int i;
return pw;
if (pw && isl_int_is_zero(v)) {
PW *zero;
- isl_dim *dim = FN(PW,get_dim)(pw);
+ isl_space *dim = FN(PW,get_space)(pw);
#ifdef HAS_TYPE
zero = FN(PW,ZERO)(dim, pw->type);
#else
FN(PW,free)(pw);
return NULL;
}
+
+__isl_give PW *FN(PW,scale)(__isl_take PW *pw, isl_int v)
+{
+ return FN(PW,mul_isl_int)(pw, v);
+}