__isl_give isl_pw_aff *isl_pw_aff_coalesce(
__isl_take isl_pw_aff *pwqp);
+ __isl_give isl_pw_aff *isl_pw_aff_align_params(
+ __isl_take isl_pw_aff *pwaff,
+ __isl_take isl_dim *model);
+
__isl_give isl_aff *isl_aff_gist(__isl_take isl_aff *aff,
__isl_take isl_set *context);
__isl_give isl_pw_aff *isl_pw_aff_gist(
int isl_pw_aff_involves_dims(__isl_keep isl_pw_aff *pwaff,
enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_pw_aff *isl_pw_aff_align_params(__isl_take isl_pw_aff *pwaff,
+ __isl_take isl_dim *model);
+
__isl_give isl_set *isl_pw_aff_domain(__isl_take isl_pw_aff *pwaff);
__isl_give isl_pw_aff *isl_pw_aff_add(__isl_take isl_pw_aff *pwaff1,
return aff ? isl_local_space_get_dim_name(aff->ls, type, pos) : 0;
}
+__isl_give isl_aff *isl_aff_reset_dim(__isl_take isl_aff *aff,
+ __isl_take isl_dim *dim)
+{
+ aff = isl_aff_cow(aff);
+ if (!aff || !dim)
+ goto error;
+
+ aff->ls = isl_local_space_reset_dim(aff->ls, dim);
+ if (!aff->ls)
+ return isl_aff_free(aff);
+
+ return aff;
+error:
+ isl_aff_free(aff);
+ isl_dim_free(dim);
+ return NULL;
+}
+
+/* Reorder the coefficients of the affine expression based
+ * on the given reodering.
+ * The reordering r is assumed to have been extended with the local
+ * variables.
+ */
+static __isl_give isl_vec *vec_reorder(__isl_take isl_vec *vec,
+ __isl_take isl_reordering *r, int n_div)
+{
+ isl_vec *res;
+ int i;
+
+ if (!vec || !r)
+ goto error;
+
+ res = isl_vec_alloc(vec->ctx, 2 + isl_dim_total(r->dim) + n_div);
+ isl_seq_cpy(res->el, vec->el, 2);
+ isl_seq_clr(res->el + 2, res->size - 2);
+ for (i = 0; i < r->len; ++i)
+ isl_int_set(res->el[2 + r->pos[i]], vec->el[2 + i]);
+
+ isl_reordering_free(r);
+ isl_vec_free(vec);
+ return res;
+error:
+ isl_vec_free(vec);
+ isl_reordering_free(r);
+ return NULL;
+}
+
+/* Reorder the dimensions of "aff" according to the given reordering.
+ */
+__isl_give isl_aff *isl_aff_realign(__isl_take isl_aff *aff,
+ __isl_take isl_reordering *r)
+{
+ aff = isl_aff_cow(aff);
+ if (!aff)
+ goto error;
+
+ r = isl_reordering_extend(r, aff->ls->div->n_row);
+ aff->v = vec_reorder(aff->v, isl_reordering_copy(r),
+ aff->ls->div->n_row);
+ aff->ls = isl_local_space_realign(aff->ls, r);
+
+ if (!aff->v || !aff->ls)
+ return isl_aff_free(aff);
+
+ return aff;
+error:
+ isl_aff_free(aff);
+ isl_reordering_free(r);
+ return NULL;
+}
+
int isl_aff_plain_is_zero(__isl_keep isl_aff *aff)
{
if (!aff)
#define NO_EVAL
#define NO_OPT
#define NO_MOVE_DIMS
-#define NO_REALIGN
#define NO_LIFT
#define NO_MORPH
-#define NO_RESET_DIM
#include <isl_pw_templ.c>
__isl_give isl_aff *isl_aff_alloc(__isl_take isl_local_space *ls);
+__isl_give isl_aff *isl_aff_reset_dim(__isl_take isl_aff *aff,
+ __isl_take isl_dim *dim);
+__isl_give isl_aff *isl_aff_realign(__isl_take isl_aff *aff,
+ __isl_take isl_reordering *r);
+
__isl_give isl_aff *isl_aff_expand_divs( __isl_take isl_aff *aff,
__isl_take isl_mat *div, int *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)