34 sizeof(
struct PW) + (
n - 1) *
sizeof(
S(
PW,piece)));
66 if (!pw || !
set || !el)
73 el_dim =
FN(
EL,get_space(el));
77 pw->p[pw->n].set =
set;
78 pw->p[pw->n].FIELD = el;
102 if (skip >= 0 && !skip)
104 if (skip >= 0 && !skip)
105 return FN(
PW,add_dup_piece)(pw,
set, el);
110 return FN(
PW,free)(pw);
125 el_space =
FN(
EL,get_space)(el);
139 ok =
FN(
PW,compatible_domain)(el,
set);
154 if (
FN(
PW,check_compatible_domain)(el,
set) < 0)
159 return FN(
PW,add_piece)(pw,
set, el);
179 for (i = 0; i < pw->n; ++i)
181 FN(
EL,copy)(pw->p[i].FIELD));
215 for (i = 0; i < pw->n; ++i) {
217 FN(
EL,free)(pw->p[i].FIELD);
229 return pw ? pw->dim : NULL;
253 return FN(
PW,get_space)(pw);
270 if (pw->dim == space) {
294 if (pos < 0 || pos >= pw->n)
304 if (
FN(
PW,check_pos)(pw,
pos) < 0)
306 return pw->p[
pos].set;
333 return FN(
PW,get_domain_at)(pw,
pos);
334 if (
FN(
PW,check_pos)(pw,
pos) < 0)
337 pw->p[
pos].set = NULL;
376 if (
FN(
PW,check_pos)(pw,
pos) < 0)
378 return pw->p[
pos].FIELD;
407 return FN(
PW,get_base_at)(pw,
pos);
408 if (
FN(
PW,check_pos)(pw,
pos) < 0)
410 el = pw->p[
pos].FIELD;
411 pw->p[
pos].FIELD = NULL;
428 if (
FN(
PW,check_pos)(pw,
pos) < 0 || !el)
431 if (pw->p[
pos].FIELD == el) {
441 pw->p[
pos].FIELD = el;
458 return FN(
PW,restore_base_at_)(pw,
pos, el, 0);
471 return FN(
PW,restore_base_at_)(pw,
pos, el, 1);
506 space =
FN(
EL,get_space)(el);
585 n =
FN(
PW,n_piece)(pw);
589 for (i = 0; i <
n; ++i) {
597 el =
FN(
PW,take_base_at)(pw, i);
599 pw =
FN(
PW,restore_base_at)(pw, i, el);
630 "model has unnamed parameters",
goto error);
631 if (
FN(
PW,check_named_params)(pw) < 0)
634 if (equal_params < 0)
640 space =
FN(
PW,get_domain_space)(pw);
686 if (
FN(
PW,align_params_bin)(&pw1, &pw2) < 0)
692 "fold types don't match",
goto error);
693 if (
FN(
PW,check_equal_space)(pw1, pw2) < 0)
706 n = (pw1->n + 1) * (pw2->n + 1);
710 for (i = 0; i < pw1->n; ++i) {
712 for (j = 0; j < pw2->n; ++j) {
724 sum =
FN(
EL,add_on_domain)(common,
725 FN(
EL,copy)(pw1->p[i].FIELD),
726 FN(
EL,copy)(pw2->p[j].FIELD));
733 for (j = 0; j < pw2->n; ++j) {
735 for (i = 0; i < pw1->n; ++i)
763 return FN(
PW,union_add_)(pw1, pw2);
791 for (i = 0; i < pw1->n; ++i) {
792 for (j = 0; j < pw2->n; ++j) {
801 if (empty < 0 || empty) {
808 res_ij =
fn(
FN(
EL,copy)(pw1->p[i].FIELD),
809 FN(
EL,copy)(pw2->p[j].FIELD));
844 if (
FN(
PW,check_equal_space)(pw1, pw2) < 0)
848 return FN(
PW,on_shared_domain_in)(pw1, pw2, space,
fn);
871 for (i = 0; i < pw->n; ++i)
895 return FN(
PW,free)(pw);
898 FN(
EL,free)(pw->p[i].FIELD);
900 pw->p[i] = pw->p[pw->n - 1];
907 el =
FN(
PW,take_base_at)(pw, i);
909 pw =
FN(
PW,restore_base_at_inplace)(pw, i, el);
927 FN(
PW,align_params_set)(&pw, &
set);
928 n =
FN(
PW,n_piece)(pw);
932 for (i =
n - 1; i >= 0; --i) {
938 pw =
FN(
PW,exploit_equalities_and_remove_if_empty)(pw, i);
969 return FN(
PW,restrict_domain)(pw,
set,
996static int FN(
PW,sort_field_cmp)(
const void *p1,
const void *p2,
void *
arg)
998 struct FN(
PW,piece) const *pc1 = p1;
999 struct FN(
PW,piece) const *pc2 = p2;
1001 return FN(
EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1022 if (
isl_sort(pw->p, pw->n,
sizeof(pw->p[0]),
1023 &
FN(
PW,sort_field_cmp), NULL) < 0)
1024 return FN(
PW,free)(pw);
1025 for (i = pw->n - 1; i >= 1; --i) {
1030 el =
FN(
PW,peek_base_at)(pw, i);
1031 el_prev =
FN(
PW,peek_base_at)(pw, i - 1);
1032 equal =
FN(
EL,plain_is_equal)(el, el_prev);
1034 return FN(
PW,free)(pw);
1037 set =
FN(
PW,get_domain_at)(pw, i);
1038 set_prev =
FN(
PW,get_domain_at)(pw, i - 1);
1041 return FN(
PW,free)(pw);
1043 FN(
EL,free)(pw->p[i].FIELD);
1045 pw->p[i - 1].set =
set;
1046 for (j = i + 1; j < pw->n; ++j)
1047 pw->p[j - 1] = pw->p[j];
1068 for (i = 0; i < pw->n - 1; ++i) {
1070 FN(
EL,free)(pw->p[i].FIELD);
1072 pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
1073 pw->p[0].set = pw->p[pw->n - 1].set;
1077 el =
FN(
PW,take_base_at)(pw, 0);
1079 pw =
FN(
PW,restore_base_at)(pw, 0, el);
1109 pw =
FN(
PW,sort_unique)(pw);
1119 if (is_universe < 0)
1128 pw =
FN(
PW,cow)(pw);
1145 for (i = pw->n - 1; i >= 0; --i) {
1150 if (i == pw->n - 1) {
1160 set_i =
FN(
PW,get_domain_at)(pw, i);
1163 el =
FN(
PW,take_base_at)(pw, i);
1165 pw =
FN(
PW,restore_base_at)(pw, i, el);
1166 set_i =
FN(
PW,take_domain_at)(pw, i);
1168 pw =
FN(
PW,restore_domain_at)(pw, i, set_i);
1169 if (empty < 0 || !pw)
1173 FN(
EL,free)(pw->p[i].FIELD);
1175 pw->p[i] = pw->p[pw->n - 1];
1216 pw =
FN(
PW,sort_unique)(pw);
1217 n =
FN(
PW,n_piece)(pw);
1219 return FN(
PW,free)(pw);
1221 for (i = 0; i <
n; ++i) {
1239 unsigned first,
unsigned n)
1246 if (pw->n == 0 ||
n == 0)
1251 for (i = 0; i < pw->n; ++i) {
1252 isl_bool involves =
FN(
EL,involves_dims)(pw->p[i].FIELD,
1254 if (involves < 0 || involves)
1258 if (involves < 0 || involves)
1269 space =
FN(
PW,get_space)(pw);
1271 return FN(
PW,reset_space)(pw, space);
1282 n_piece =
FN(
PW,n_piece)(pw);
1284 return FN(
PW,free)(pw);
1290 space =
FN(
PW,take_space)(pw);
1292 pw =
FN(
PW,restore_space)(pw, space);
1293 for (i = 0; i < n_piece; ++i) {
1297 el =
FN(
PW,take_base_at)(pw, i);
1299 pw =
FN(
PW,restore_base_at)(pw, i, el);
1304 pw =
FN(
PW,restore_domain_at)(pw, i,
domain);
1323 n_piece =
FN(
PW,n_piece)(pw);
1325 return FN(
PW,free)(pw);
1331 space =
FN(
PW,take_space)(pw);
1333 pw =
FN(
PW,restore_space)(pw, space);
1334 for (i = 0; i < n_piece; ++i) {
1340 pw =
FN(
PW,restore_domain_at)(pw, i,
domain);
1341 el =
FN(
PW,take_base_at)(pw, i);
1343 pw =
FN(
PW,restore_base_at)(pw, i, el);
1358 return FN(
PW,free)(pw);
1360 space =
FN(
PW,get_domain_space)(pw);
1373 if (
FN(
PW,check_named_params)(pw) < 0)
1374 return FN(
PW,free)(pw);
1378 return FN(
PW,free)(pw);
1379 for (i =
n - 1; i >= 0; i--) {
1384 return FN(
PW,free)(pw);
1423 space =
FN(
PW,peek_space)(pw);
1455 n =
FN(
PW,n_piece)(pw);
1456 if (
n < 0 || !space || !
domain)
1459 for (i = 0; i <
n; ++i) {
1463 set =
FN(
PW,take_domain_at)(pw, i);
1465 pw =
FN(
PW,restore_domain_at)(pw, i,
set);
1466 el =
FN(
PW,take_base_at)(pw, i);
1467 el =
FN(
EL,reset_space_and_domain)(el,
1469 pw =
FN(
PW,restore_base_at)(pw, i, el);
1474 pw =
FN(
PW,restore_space)(pw, space);
1490 FN(
PW,get_space)(pw));
1491 return FN(
PW,reset_space_and_domain)(pw, space,
domain);
1500 return FN(
PW,reset_space_and_domain)(pw, space,
domain);
1508 pw =
FN(
PW,cow)(pw);
1512 space =
FN(
PW,get_space)(pw);
1515 return FN(
PW,reset_space)(pw, space);
1518 return FN(
PW,free)(pw);
1529 if (!
FN(
PW,has_tuple_id)(pw,
type))
1532 pw =
FN(
PW,cow)(pw);
1536 space =
FN(
PW,get_space)(pw);
1539 return FN(
PW,reset_space)(pw, space);
1547 space =
FN(
PW,get_space)(pw);
1549 return FN(
PW,reset_space)(pw, space);
1559 space =
FN(
PW,get_space)(pw);
1562 return FN(
PW,reset_space)(pw, space);
1579 for (i = 0; i < pw->n; ++i)
1581 FN(
EL,copy)(pw->p[i].FIELD),
user) < 0)
1598 for (i = 0; i < pw->n; ++i) {
1601 r =
test(pw->p[i].set, pw->p[i].FIELD,
user);
1619 n =
FN(
PW,n_piece)(pw);
1636 space =
FN(
PW,get_space)(pw);
1646 return FN(
EL,zero_like_type)(pw);
1662 return FN(
EL,zero_like_type)(pw,
type);
1689 "expecting single total function",
goto error);
1690 n =
FN(
PW,n_piece)(pw);
1694 return FN(
EL,zero_like)(pw);
1695 el =
FN(
PW,take_base_at)(pw, 0);
1708 pw =
FN(
PW,cow)(pw);
1747 pw =
FN(
PW,negate_type)(pw);
1748 n =
FN(
PW,n_piece)(pw);
1752 for (i = 0; i <
n; ++i) {
1755 el =
FN(
PW,take_base_at)(pw, i);
1757 pw =
FN(
PW,restore_base_at)(pw, i, el);
1785 "expecting rational factor",
goto error);
1788 "cannot scale down by zero",
goto error);
1791 pw =
FN(
PW,negate_type)(pw);
1792 n =
FN(
PW,n_piece)(pw);
1796 for (i = 0; i <
n; ++i) {
1799 el =
FN(
PW,take_base_at)(pw, i);
1801 pw =
FN(
PW,restore_base_at)(pw, i, el);
1826 pw =
FN(
PW,sort_unique)(pw);
1829 for (i = 0; i < pw->n; ++i) {
1832 return FN(
PW,free)(pw);
1856 has_nan =
FN(
PW,involves_nan)(pw1);
1857 if (has_nan >= 0 && !has_nan)
1858 has_nan =
FN(
PW,involves_nan)(pw2);
1859 if (has_nan < 0 || has_nan)
1864 equal =
FN(
PW,has_equal_space)(pw1, pw2);
1868 pw1 =
FN(
PW,copy)(pw1);
1869 pw2 =
FN(
PW,copy)(pw2);
1870 pw1 =
FN(
PW,normalize)(pw1);
1871 pw2 =
FN(
PW,normalize)(pw2);
1876 for (i = 0;
equal && i < pw1->n; ++i) {
1882 equal =
FN(
EL,plain_is_equal)(pw1->p[i].FIELD, pw2->p[i].FIELD);
1907 for (i = 0; i < pw->n; ++i) {
1908 isl_bool has_nan =
FN(
EL,involves_nan)(pw->p[i].FIELD);
1909 if (has_nan < 0 || has_nan)
#define isl_die(ctx, errno, msg, code)
#define isl_assert(ctx, test, code)
isl_bool isl_bool_ok(int b)
#define isl_alloc(ctx, type, size)
isl_bool isl_bool_not(isl_bool b)
isl_stat isl_stat(* fn)(__isl_take ISL_KEY *key, __isl_take ISL_VAL *val, void *user)
isl_stat isl_stat(*) void user)
isl_bool isl_bool(* test)(__isl_keep ISL_KEY *key, __isl_keep ISL_VAL *val, void *user)
__isl_null isl_id * isl_id_free(__isl_take isl_id *id)
static int coalesce(isl_ctx *ctx, int n, struct isl_coalesce_info *info)
static __isl_give isl_qpolynomial * reset_domain_space(__isl_take isl_qpolynomial *qp, void *user)
static __isl_give isl_qpolynomial * substitute_equalities(__isl_take isl_qpolynomial *qp, void *user)
static __isl_give isl_qpolynomial * realign_domain(__isl_take isl_qpolynomial *qp, void *user)
static __isl_give isl_qpolynomial * drop_dims(__isl_take isl_qpolynomial *qp, void *user)
static __isl_give isl_qpolynomial * scale_val(__isl_take isl_qpolynomial *qp, void *user)
enum isl_fold isl_fold_type_negate(enum isl_fold type)
static __isl_give isl_qpolynomial * set_dim_name(__isl_take isl_qpolynomial *qp, void *user)
__isl_give dup(__isl_keep LIST(EL) *list)
__isl_give isl_set * isl_set_normalize(__isl_take isl_set *set)
static unsigned pos(__isl_keep isl_space *space, enum isl_dim_type type)
__isl_give isl_set * isl_set_drop(__isl_take isl_set *set, enum isl_dim_type type, unsigned first, unsigned n)
__isl_give isl_set * isl_set_realign(__isl_take isl_set *set, __isl_take isl_reordering *r)
__isl_give isl_set * isl_set_gist_params_basic_set(__isl_take isl_set *set, __isl_take isl_basic_set *context)
__isl_null isl_reordering * isl_reordering_free(__isl_take isl_reordering *exp)
__isl_give isl_reordering * isl_parameter_alignment_reordering(__isl_keep isl_space *alignee, __isl_keep isl_space *aligner)
__isl_give isl_space * isl_reordering_get_space(__isl_keep isl_reordering *r)
__isl_give isl_reordering * isl_reordering_copy(__isl_keep isl_reordering *exp)
static __isl_give isl_schedule_node * align_params(__isl_take isl_schedule_node *node, void *user)
static __isl_give isl_schedule_node * reset_user(__isl_take isl_schedule_node *node, void *user)
int isl_sort(void *const pbase, size_t total_elems, size_t size, int(*cmp)(const void *, const void *, void *arg), void *arg)
__isl_give isl_space * isl_space_extend_domain_with_range(__isl_take isl_space *space, __isl_take isl_space *model)
isl_bool isl_space_has_named_params(__isl_keep isl_space *space)
isl_bool isl_space_is_domain_internal(__isl_keep isl_space *space1, __isl_keep isl_space *space2)
static __isl_give isl_union_map * inplace(__isl_take isl_union_map *umap, __isl_give isl_map *(*fn)(__isl_take isl_map *))
static isl_stat project_out(__isl_take isl_map *map, void *user)
struct isl_basic_set isl_basic_set
#define OPT_TYPE_ARG(loc)
#define OPT_TYPE_ARG_FIRST(loc)
#define OPT_EQUAL_TYPES(loc1, loc2)
#define OPT_TYPE_PARAM_FIRST
#define OPT_SET_TYPE(loc, val)
__isl_export __isl_give isl_set * isl_set_universe(__isl_take isl_space *space)
__isl_export __isl_give isl_set * isl_set_coalesce(__isl_take isl_set *set)
__isl_export __isl_give isl_set * isl_set_subtract(__isl_take isl_set *set1, __isl_take isl_set *set2)
isl_ctx * isl_set_get_ctx(__isl_keep isl_set *set)
__isl_export __isl_give isl_space * isl_set_get_space(__isl_keep isl_set *set)
isl_bool isl_set_plain_is_empty(__isl_keep isl_set *set)
__isl_give isl_set * isl_set_reset_space(__isl_take isl_set *set, __isl_take isl_space *space)
__isl_export __isl_give isl_set * isl_set_union(__isl_take isl_set *set1, __isl_take isl_set *set2)
__isl_export __isl_give isl_set * isl_set_intersect_params(__isl_take isl_set *set, __isl_take isl_set *params)
__isl_null isl_basic_set * isl_basic_set_free(__isl_take isl_basic_set *bset)
__isl_give isl_basic_set * isl_set_simple_hull(__isl_take isl_set *set)
__isl_null isl_set * isl_set_free(__isl_take isl_set *set)
__isl_give isl_set * isl_set_intersect_factor_range(__isl_take isl_set *set, __isl_take isl_set *range)
__isl_give isl_set * isl_set_copy(__isl_keep isl_set *set)
__isl_give isl_set * isl_set_intersect_factor_domain(__isl_take isl_set *set, __isl_take isl_set *domain)
__isl_give isl_set * isl_set_project_out(__isl_take isl_set *set, enum isl_dim_type type, unsigned first, unsigned n)
isl_bool isl_set_involves_dims(__isl_keep isl_set *set, enum isl_dim_type type, unsigned first, unsigned n)
__isl_give isl_set * isl_set_compute_divs(__isl_take isl_set *set)
isl_bool isl_set_plain_is_equal(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
__isl_give isl_set * isl_set_gist_basic_set(__isl_take isl_set *set, __isl_take isl_basic_set *context)
isl_bool isl_set_plain_is_universe(__isl_keep isl_set *set)
__isl_export __isl_give isl_set * isl_set_intersect(__isl_take isl_set *set1, __isl_take isl_set *set2)
__isl_export __isl_give isl_set * isl_set_empty(__isl_take isl_space *space)
__isl_give isl_set * isl_set_union_disjoint(__isl_take isl_set *set1, __isl_take isl_set *set2)
__isl_give isl_basic_set * isl_basic_set_copy(__isl_keep isl_basic_set *bset)
__isl_export __isl_give isl_basic_set * isl_set_affine_hull(__isl_take isl_set *set)
__isl_export __isl_give isl_set * isl_set_params(__isl_take isl_set *set)
isl_bool isl_space_has_equal_params(__isl_keep isl_space *space1, __isl_keep isl_space *space2)
__isl_give isl_space * isl_space_set_tuple_id(__isl_take isl_space *space, enum isl_dim_type type, __isl_take isl_id *id)
__isl_null isl_space * isl_space_free(__isl_take isl_space *space)
__isl_export __isl_give isl_space * isl_space_params(__isl_take isl_space *space)
isl_bool isl_space_has_tuple_id(__isl_keep isl_space *space, enum isl_dim_type type)
isl_ctx * isl_space_get_ctx(__isl_keep isl_space *space)
__isl_give isl_id * isl_space_get_tuple_id(__isl_keep isl_space *space, enum isl_dim_type type)
__isl_give isl_space * isl_space_copy(__isl_keep isl_space *space)
__isl_give isl_space * isl_space_set_dim_id(__isl_take isl_space *space, enum isl_dim_type type, unsigned pos, __isl_take isl_id *id)
__isl_keep const char * isl_space_get_dim_name(__isl_keep isl_space *space, enum isl_dim_type type, unsigned pos)
__isl_keep const char * isl_space_get_tuple_name(__isl_keep isl_space *space, enum isl_dim_type type)
isl_bool isl_space_has_tuple_name(__isl_keep isl_space *space, enum isl_dim_type type)
int isl_space_find_dim_by_id(__isl_keep isl_space *space, enum isl_dim_type type, __isl_keep isl_id *id)
__isl_give isl_space * isl_space_set_dim_name(__isl_take isl_space *space, enum isl_dim_type type, unsigned pos, __isl_keep const char *name)
isl_bool isl_space_has_dim_id(__isl_keep isl_space *space, enum isl_dim_type type, unsigned pos)
__isl_export isl_bool isl_space_is_equal(__isl_keep isl_space *space1, __isl_keep isl_space *space2)
__isl_give isl_space * isl_space_drop_dims(__isl_take isl_space *space, enum isl_dim_type type, unsigned first, unsigned num)
__isl_give isl_id * isl_space_get_dim_id(__isl_keep isl_space *space, enum isl_dim_type type, unsigned pos)
isl_size isl_space_dim(__isl_keep isl_space *space, enum isl_dim_type type)
__isl_give isl_space * isl_space_reset_tuple_id(__isl_take isl_space *space, enum isl_dim_type type)
__isl_give isl_space * isl_space_reset_user(__isl_take isl_space *space)
int isl_space_find_dim_by_name(__isl_keep isl_space *space, enum isl_dim_type type, const char *name)
__isl_export __isl_give isl_space * isl_space_domain(__isl_take isl_space *space)
__isl_give isl_val * isl_val_copy(__isl_keep isl_val *v)
isl_ctx * isl_val_get_ctx(__isl_keep isl_val *val)
__isl_export isl_bool isl_val_is_neg(__isl_keep isl_val *v)
__isl_null isl_val * isl_val_free(__isl_take isl_val *v)
__isl_export isl_bool isl_val_is_zero(__isl_keep isl_val *v)
__isl_export isl_bool isl_val_is_one(__isl_keep isl_val *v)
__isl_export isl_bool isl_val_is_rat(__isl_keep isl_val *v)