| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * Copyright 2013 Ecole Normale Superieure | ||
| * | ||
| * Use of this software is governed by the MIT license | ||
| * | ||
| * Written by Sven Verdoolaege, | ||
| * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France | ||
| */ | ||
|
|
||
| /* Apply "fn" to each of the elements of "multi" with as second argument "v". | ||
| */ | ||
| static __isl_give MULTI(BASE) *FN(MULTI(BASE),fn_val)( | ||
| __isl_take MULTI(BASE) *multi, | ||
| __isl_give EL *(*fn)(__isl_take EL *el, __isl_take isl_val *v), | ||
| __isl_take isl_val *v) | ||
| { | ||
| isl_size n; | ||
| int i; | ||
|
|
||
| n = FN(MULTI(BASE),size)(multi); | ||
| if (n < 0 || !v) | ||
| goto error; | ||
|
|
||
| for (i = 0; i < n; ++i) { | ||
| EL *el; | ||
|
|
||
| el = FN(MULTI(BASE),take_at)(multi, i); | ||
| el = fn(el, isl_val_copy(v)); | ||
| multi = FN(MULTI(BASE),restore_at)(multi, i, el); | ||
| } | ||
|
|
||
| isl_val_free(v); | ||
| return multi; | ||
| error: | ||
| isl_val_free(v); | ||
| FN(MULTI(BASE),free)(multi); | ||
| return NULL; | ||
| } | ||
|
|
||
| #undef TYPE | ||
| #define TYPE MULTI(BASE) | ||
| #include "isl_type_check_match_range_multi_val.c" | ||
|
|
||
| /* Elementwise apply "fn" to "multi" and "mv". | ||
| */ | ||
| static __isl_give MULTI(BASE) *FN(MULTI(BASE),fn_multi_val)( | ||
| __isl_take MULTI(BASE) *multi, | ||
| __isl_give EL *(*fn)(__isl_take EL *el, __isl_take isl_val *v), | ||
| __isl_take isl_multi_val *mv) | ||
| { | ||
| isl_size n; | ||
| int i; | ||
|
|
||
| n = FN(MULTI(BASE),size)(multi); | ||
| if (n < 0 || FN(MULTI(BASE),check_match_range_multi_val)(multi, mv) < 0) | ||
| goto error; | ||
|
|
||
| for (i = 0; i < n; ++i) { | ||
| isl_val *v; | ||
| EL *el; | ||
|
|
||
| v = isl_multi_val_get_val(mv, i); | ||
| el = FN(MULTI(BASE),take_at)(multi, i); | ||
| el = fn(el, v); | ||
| multi = FN(MULTI(BASE),restore_at)(multi, i, el); | ||
| } | ||
|
|
||
| isl_multi_val_free(mv); | ||
| return multi; | ||
| error: | ||
| isl_multi_val_free(mv); | ||
| return FN(MULTI(BASE),free)(multi); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Copyright 2011 Sven Verdoolaege | ||
| * Copyright 2012 Ecole Normale Superieure | ||
| * | ||
| * Use of this software is governed by the MIT license | ||
| * | ||
| * Written by Sven Verdoolaege, | ||
| * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France | ||
| */ | ||
|
|
||
| #include <isl_multi_macro.h> | ||
|
|
||
| /* Extract a multi expression with domain space "dom_space" | ||
| * from a tuple "tuple" that was read by read_tuple. | ||
| * | ||
| * Check that none of the expressions depend on any other output/set dimensions. | ||
| */ | ||
| static MULTI(BASE) *FN(MULTI(BASE),from_tuple)( | ||
| __isl_take isl_space *dom_space, __isl_take isl_multi_pw_aff *tuple) | ||
| { | ||
| int i; | ||
| isl_size dim, n; | ||
| isl_space *space; | ||
| MULTI(BASE) *multi; | ||
|
|
||
| n = isl_multi_pw_aff_dim(tuple, isl_dim_out); | ||
| dim = isl_space_dim(dom_space, isl_dim_all); | ||
| if (n < 0 || dim < 0) | ||
| dom_space = isl_space_free(dom_space); | ||
| space = isl_space_range(isl_multi_pw_aff_get_space(tuple)); | ||
| space = isl_space_align_params(space, isl_space_copy(dom_space)); | ||
| if (!isl_space_is_params(dom_space)) | ||
| space = isl_space_map_from_domain_and_range( | ||
| isl_space_copy(dom_space), space); | ||
| isl_space_free(dom_space); | ||
| multi = FN(MULTI(BASE),alloc)(space); | ||
|
|
||
| for (i = 0; i < n; ++i) { | ||
| isl_pw_aff *pa; | ||
| pa = isl_multi_pw_aff_get_pw_aff(tuple, i); | ||
| multi = FN(MULTI(BASE),set_tuple_entry)(multi, pa, i, dim, n); | ||
| } | ||
|
|
||
| isl_multi_pw_aff_free(tuple); | ||
| return multi; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * Copyright 2013 Ecole Normale Superieure | ||
| * | ||
| * Use of this software is governed by the MIT license | ||
| * | ||
| * Written by Sven Verdoolaege, | ||
| * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France | ||
| */ | ||
|
|
||
| #define xCAT(A,B) A ## B | ||
| #define CAT(A,B) xCAT(A,B) | ||
| #undef TYPE | ||
| #define TYPE CAT(isl_,BASE) | ||
| #define xFN(TYPE,NAME) TYPE ## _ ## NAME | ||
| #define FN(TYPE,NAME) xFN(TYPE,NAME) | ||
|
|
||
| #undef SUFFIX | ||
| #define SUFFIX BASE | ||
| #undef ARG1 | ||
| #define ARG1 isl_multi_pw_aff | ||
| #undef ARG2 | ||
| #define ARG2 TYPE | ||
|
|
||
| static | ||
| #include "isl_align_params_templ.c" | ||
|
|
||
| /* Compute the pullback of "mpa" by the function represented by "fn". | ||
| * In other words, plug in "fn" in "mpa". | ||
| * | ||
| * If "mpa" has an explicit domain, then it is this domain | ||
| * that needs to undergo a pullback, i.e., a preimage. | ||
| */ | ||
| __isl_give isl_multi_pw_aff *FN(isl_multi_pw_aff_pullback,BASE)( | ||
| __isl_take isl_multi_pw_aff *mpa, __isl_take TYPE *fn) | ||
| { | ||
| int i; | ||
| isl_size n; | ||
| isl_space *space = NULL; | ||
|
|
||
| FN(isl_multi_pw_aff_align_params,BASE)(&mpa, &fn); | ||
| mpa = isl_multi_pw_aff_cow(mpa); | ||
| n = isl_multi_pw_aff_size(mpa); | ||
| if (n < 0 || !fn) | ||
| goto error; | ||
|
|
||
| space = isl_space_join(FN(TYPE,get_space)(fn), | ||
| isl_multi_pw_aff_get_space(mpa)); | ||
|
|
||
| for (i = 0; i < n; ++i) { | ||
| isl_pw_aff *pa; | ||
|
|
||
| pa = isl_multi_pw_aff_take_at(mpa, i); | ||
| pa = FN(isl_pw_aff_pullback,BASE)(pa, FN(TYPE,copy)(fn)); | ||
| mpa = isl_multi_pw_aff_restore_at(mpa, i, pa); | ||
| if (!mpa) | ||
| goto error; | ||
| } | ||
| if (isl_multi_pw_aff_has_explicit_domain(mpa)) { | ||
| mpa->u.dom = FN(isl_set_preimage,BASE)(mpa->u.dom, | ||
| FN(TYPE,copy)(fn)); | ||
| if (!mpa->u.dom) | ||
| goto error; | ||
| } | ||
|
|
||
| FN(TYPE,free)(fn); | ||
| isl_multi_pw_aff_restore_space(mpa, space); | ||
| return mpa; | ||
| error: | ||
| isl_space_free(space); | ||
| isl_multi_pw_aff_free(mpa); | ||
| FN(TYPE,free)(fn); | ||
| return NULL; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Copyright 2014 Ecole Normale Superieure | ||
| * | ||
| * Use of this software is governed by the MIT license | ||
| * | ||
| * Written by Sven Verdoolaege, | ||
| * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France | ||
| */ | ||
|
|
||
| #include <isl_multi_macro.h> | ||
|
|
||
| /* Apply "fn" to each of the base expressions of "multi". | ||
| */ | ||
| static __isl_give MULTI(BASE) *FN(MULTI(BASE),un_op)( | ||
| __isl_take MULTI(BASE) *multi, __isl_give EL *(*fn)(__isl_take EL *el)) | ||
| { | ||
| int i; | ||
| isl_size n; | ||
|
|
||
| n = FN(MULTI(BASE),size)(multi); | ||
| if (n < 0) | ||
| return FN(MULTI(BASE),free)(multi); | ||
|
|
||
| for (i = 0; i < n; ++i) { | ||
| EL *el; | ||
|
|
||
| el = FN(MULTI(BASE),take_at)(multi, i); | ||
| el = fn(el); | ||
| multi = FN(MULTI(BASE),restore_at)(multi, i, el); | ||
| } | ||
|
|
||
| return multi; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Copyright 2019 Cerebras Systems | ||
| * | ||
| * Use of this software is governed by the MIT license | ||
| * | ||
| * Written by Sven Verdoolaege, | ||
| * Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA | ||
| */ | ||
|
|
||
| #define xFN(TYPE,NAME) TYPE ## _ ## NAME | ||
| #define FN(TYPE,NAME) xFN(TYPE,NAME) | ||
|
|
||
| /* If "obj" involves a parameter with identifier "id", | ||
| * then turn it into an existentially quantified variable. | ||
| */ | ||
| __isl_give TYPE *FN(TYPE,project_out_param_id)(__isl_take TYPE *obj, | ||
| __isl_take isl_id *id) | ||
| { | ||
| int pos; | ||
|
|
||
| if (!obj || !id) | ||
| goto error; | ||
| pos = FN(TYPE,find_dim_by_id)(obj, isl_dim_param, id); | ||
| isl_id_free(id); | ||
| if (pos < 0) | ||
| return obj; | ||
| return FN(TYPE,project_out)(obj, isl_dim_param, pos, 1); | ||
| error: | ||
| FN(TYPE,free)(obj); | ||
| isl_id_free(id); | ||
| return NULL; | ||
| } | ||
|
|
||
| /* If "obj" involves any of the parameters with identifiers in "list", | ||
| * then turn them into existentially quantified variables. | ||
| */ | ||
| __isl_give TYPE *FN(TYPE,project_out_param_id_list)(__isl_take TYPE *obj, | ||
| __isl_take isl_id_list *list) | ||
| { | ||
| int i; | ||
| isl_size n; | ||
|
|
||
| n = isl_id_list_size(list); | ||
| if (n < 0) | ||
| goto error; | ||
| for (i = 0; i < n; ++i) { | ||
| isl_id *id; | ||
|
|
||
| id = isl_id_list_get_at(list, i); | ||
| obj = FN(TYPE,project_out_param_id)(obj, id); | ||
| } | ||
|
|
||
| isl_id_list_free(list); | ||
| return obj; | ||
| error: | ||
| isl_id_list_free(list); | ||
| FN(TYPE,free)(obj); | ||
| return NULL; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /* | ||
| * Copyright 2010 INRIA Saclay | ||
| * Copyright 2011 Sven Verdoolaege | ||
| * | ||
| * Use of this software is governed by the MIT license | ||
| * | ||
| * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, | ||
| * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, | ||
| * 91893 Orsay, France | ||
| */ | ||
|
|
||
| #include <isl_pw_macro.h> | ||
|
|
||
| /* 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; | ||
| } | ||
| res = FN(PW,alloc_size)(isl_space_copy(pw->dim) OPT_TYPE_ARG(pw->), n); | ||
| 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; | ||
| } | ||
|
|
||
| __isl_give PW *FN(PW,add_disjoint)(__isl_take PW *pw1, __isl_take PW *pw2) | ||
| { | ||
| int i; | ||
| isl_ctx *ctx; | ||
|
|
||
| if (FN(PW,align_params_bin)(&pw1, &pw2) < 0) | ||
| goto error; | ||
|
|
||
| if (pw1->size < pw1->n + pw2->n && pw1->n < pw2->n) | ||
| return FN(PW,add_disjoint)(pw2, pw1); | ||
|
|
||
| ctx = isl_space_get_ctx(pw1->dim); | ||
| if (!OPT_EQUAL_TYPES(pw1->, pw2->)) | ||
| isl_die(ctx, isl_error_invalid, | ||
| "fold types don't match", goto error); | ||
| if (FN(PW,check_equal_space)(pw1, pw2) < 0) | ||
| goto error; | ||
|
|
||
| if (FN(PW,IS_ZERO)(pw1)) { | ||
| FN(PW,free)(pw1); | ||
| return pw2; | ||
| } | ||
|
|
||
| if (FN(PW,IS_ZERO)(pw2)) { | ||
| FN(PW,free)(pw2); | ||
| return pw1; | ||
| } | ||
|
|
||
| pw1 = FN(PW,grow)(pw1, pw2->n); | ||
| if (!pw1) | ||
| goto error; | ||
|
|
||
| for (i = 0; i < pw2->n; ++i) | ||
| pw1 = FN(PW,add_piece)(pw1, | ||
| isl_set_copy(pw2->p[i].set), | ||
| FN(EL,copy)(pw2->p[i].FIELD)); | ||
|
|
||
| FN(PW,free)(pw2); | ||
|
|
||
| return pw1; | ||
| error: | ||
| FN(PW,free)(pw1); | ||
| FN(PW,free)(pw2); | ||
| return NULL; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #include <isl_pw_macro.h> | ||
|
|
||
| /* Fix the value of the given parameter or domain dimension of "pw" | ||
| * to be equal to "value". | ||
| */ | ||
| __isl_give PW *FN(PW,fix_si)(__isl_take PW *pw, enum isl_dim_type type, | ||
| unsigned pos, int value) | ||
| { | ||
| int i; | ||
| isl_size n; | ||
|
|
||
| n = FN(PW,n_piece)(pw); | ||
| if (n < 0) | ||
| return FN(PW,free)(pw); | ||
|
|
||
| if (type == isl_dim_out) | ||
| isl_die(FN(PW,get_ctx)(pw), isl_error_invalid, | ||
| "cannot fix output dimension", return FN(PW,free)(pw)); | ||
|
|
||
| if (type == isl_dim_in) | ||
| type = isl_dim_set; | ||
|
|
||
| for (i = n - 1; i >= 0; --i) { | ||
| isl_set *domain; | ||
|
|
||
| domain = FN(PW,take_domain_at)(pw, i); | ||
| domain = isl_set_fix_si(domain, type, pos, value); | ||
| pw = FN(PW,restore_domain_at)(pw, i, domain); | ||
| pw = FN(PW,exploit_equalities_and_remove_if_empty)(pw, i); | ||
| } | ||
|
|
||
| return pw; | ||
| } | ||
|
|
||
| /* Fix the value of the variable at position "pos" of type "type" of "pw" | ||
| * to be equal to "v". | ||
| */ | ||
| __isl_give PW *FN(PW,fix_val)(__isl_take PW *pw, | ||
| enum isl_dim_type type, unsigned pos, __isl_take isl_val *v) | ||
| { | ||
| int i; | ||
| isl_size n; | ||
|
|
||
| if (!v) | ||
| return FN(PW,free)(pw); | ||
| if (!isl_val_is_int(v)) | ||
| isl_die(FN(PW,get_ctx)(pw), isl_error_invalid, | ||
| "expecting integer value", goto error); | ||
|
|
||
| n = FN(PW,n_piece)(pw); | ||
| if (n < 0) | ||
| goto error; | ||
|
|
||
| if (type == isl_dim_in) | ||
| type = isl_dim_set; | ||
|
|
||
| for (i = 0; i < n; ++i) { | ||
| isl_set *domain; | ||
|
|
||
| domain = FN(PW,take_domain_at)(pw, i); | ||
| domain = isl_set_fix(domain, type, pos, v->n); | ||
| pw = FN(PW,restore_domain_at)(pw, i, domain); | ||
| pw = FN(PW,exploit_equalities_and_remove_if_empty)(pw, i); | ||
| } | ||
|
|
||
| isl_val_free(v); | ||
| return pw; | ||
| error: | ||
| isl_val_free(v); | ||
| return FN(PW,free)(pw); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* | ||
| * Copyright 2013 Ecole Normale Superieure | ||
| * | ||
| * Use of this software is governed by the MIT license | ||
| * | ||
| * Written by Sven Verdoolaege, | ||
| * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France | ||
| */ | ||
|
|
||
| #include <isl_pw_macro.h> | ||
|
|
||
| #undef TYPE | ||
| #define TYPE PW | ||
| #include "isl_from_range_templ.c" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,23 +12,5 @@ | |
|
|
||
| __isl_give PW *FN(PW,neg)(__isl_take PW *pw) | ||
| { | ||
| return FN(PW,un_op)(pw, &FN(EL,neg)); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * Copyright 2011 Sven Verdoolaege | ||
| * | ||
| * Use of this software is governed by the MIT license | ||
| * | ||
| * Written by Sven Verdoolaege. | ||
| */ | ||
|
|
||
| #undef EL | ||
| #define EL CAT(isl_,BASE) | ||
| #undef PW | ||
| #define PW CAT(isl_pw_,BASE) | ||
|
|
||
| /* Print the body of a piecewise expression, i.e., a semicolon delimited | ||
| * sequence of expressions, each followed by constraints. | ||
| */ | ||
| static __isl_give isl_printer *FN(print_body_pw,BASE)( | ||
| __isl_take isl_printer *p, __isl_keep PW *pw) | ||
| { | ||
| int i; | ||
|
|
||
| if (!pw) | ||
| return isl_printer_free(p); | ||
|
|
||
| for (i = 0; i < pw->n; ++i) { | ||
| EL *el; | ||
| isl_space *space; | ||
|
|
||
| if (i) | ||
| p = isl_printer_print_str(p, "; "); | ||
| el = FN(PW,peek_base_at)(pw, i); | ||
| p = FN(print_body,BASE)(p, el); | ||
| space = FN(EL,get_domain_space)(el); | ||
| p = print_disjuncts(set_to_map(pw->p[i].set), space, p, 0); | ||
| isl_space_free(space); | ||
| } | ||
| return p; | ||
| } | ||
|
|
||
| /* Print a piecewise expression in isl format. | ||
| */ | ||
| static __isl_give isl_printer *FN(FN(print_pw,BASE),isl)( | ||
| __isl_take isl_printer *p, __isl_keep PW *pw) | ||
| { | ||
| struct isl_print_space_data data = { 0 }; | ||
|
|
||
| if (!pw) | ||
| return isl_printer_free(p); | ||
|
|
||
| p = print_param_tuple(p, pw->dim, &data); | ||
| p = isl_printer_print_str(p, "{ "); | ||
| p = FN(print_body_pw,BASE)(p, pw); | ||
| p = isl_printer_print_str(p, " }"); | ||
| return p; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * Copyright 2010 INRIA Saclay | ||
| * | ||
| * Use of this software is governed by the MIT license | ||
| * | ||
| * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, | ||
| * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, | ||
| * 91893 Orsay, France | ||
| */ | ||
|
|
||
| #include <isl_pw_macro.h> | ||
|
|
||
| __isl_give PW *FN(PW,scale)(__isl_take PW *pw, isl_int v) | ||
| { | ||
| int i; | ||
| isl_size n; | ||
|
|
||
| if (isl_int_is_one(v)) | ||
| return pw; | ||
| if (pw && DEFAULT_IS_ZERO && isl_int_is_zero(v)) { | ||
| PW *zero; | ||
| isl_space *space = FN(PW,get_space)(pw); | ||
| zero = FN(PW,ZERO)(space OPT_TYPE_ARG(pw->)); | ||
| FN(PW,free)(pw); | ||
| return zero; | ||
| } | ||
| if (isl_int_is_neg(v)) | ||
| pw = FN(PW,negate_type)(pw); | ||
|
|
||
| n = FN(PW,n_piece)(pw); | ||
| if (n < 0) | ||
| return FN(PW,free)(pw); | ||
| for (i = 0; i < n; ++i) { | ||
| EL *el; | ||
|
|
||
| el = FN(PW,take_base_at)(pw, i); | ||
| el = FN(EL,scale)(el, v); | ||
| pw = FN(PW,restore_base_at)(pw, i, el); | ||
| } | ||
|
|
||
| return pw; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * Copyright 2010 INRIA Saclay | ||
| * | ||
| * Use of this software is governed by the MIT license | ||
| * | ||
| * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, | ||
| * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, | ||
| * 91893 Orsay, France | ||
| */ | ||
|
|
||
| #include <isl_pw_macro.h> | ||
|
|
||
| __isl_give PW *FN(PW,split_dims)(__isl_take PW *pw, | ||
| enum isl_dim_type type, unsigned first, unsigned n) | ||
| { | ||
| int i; | ||
| isl_size n_piece; | ||
|
|
||
| n_piece = FN(PW,n_piece)(pw); | ||
| if (n_piece < 0) | ||
| return FN(PW,free)(pw); | ||
| if (n == 0) | ||
| return pw; | ||
|
|
||
| if (type == isl_dim_in) | ||
| type = isl_dim_set; | ||
|
|
||
| for (i = 0; i < n; ++i) { | ||
| isl_set *domain; | ||
|
|
||
| domain = FN(PW,take_domain_at)(pw, i); | ||
| domain = isl_set_split_dims(domain, type, first, n); | ||
| pw = FN(PW,restore_domain_at)(pw, i, domain); | ||
| } | ||
|
|
||
| return pw; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * Copyright 2010 INRIA Saclay | ||
| * | ||
| * Use of this software is governed by the MIT license | ||
| * | ||
| * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, | ||
| * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, | ||
| * 91893 Orsay, France | ||
| */ | ||
|
|
||
| #include <isl_pw_macro.h> | ||
|
|
||
| /* Apply "fn" to each of the base expressions of "pw". | ||
| * The function is assumed to have no effect on the default value | ||
| * (i.e., zero for those objects with a default value). | ||
| */ | ||
| static __isl_give PW *FN(PW,un_op)(__isl_take PW *pw, | ||
| __isl_give EL *(*fn)(__isl_take EL *el)) | ||
| { | ||
| isl_size n; | ||
| int i; | ||
|
|
||
| n = FN(PW,n_piece)(pw); | ||
| if (n < 0) | ||
| return FN(PW,free)(pw); | ||
|
|
||
| for (i = 0; i < n; ++i) { | ||
| EL *el; | ||
|
|
||
| el = FN(PW,take_base_at)(pw, i); | ||
| el = fn(el); | ||
| pw = FN(PW,restore_base_at)(pw, i, el); | ||
| } | ||
|
|
||
| return pw; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * Copyright 2008 Katholieke Universiteit Leuven | ||
| * | ||
| * Use of this software is governed by the MIT license | ||
| * | ||
| * Written by Sven Verdoolaege, K.U.Leuven, Departement | ||
| * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium | ||
| */ | ||
|
|
||
| #define xCAT(A,B) A ## B | ||
| #define CAT(A,B) xCAT(A,B) | ||
| #undef TYPE | ||
| #define TYPE CAT(isl_,TYPE_BASE) | ||
|
|
||
| /* Read an object of type TYPE from "str" (using an isl_stream). | ||
| */ | ||
| __isl_give TYPE *FN(isl,FN(TYPE_BASE,read_from_str))(isl_ctx *ctx, | ||
| const char *str) | ||
| { | ||
| TYPE *obj; | ||
| isl_stream *s = isl_stream_new_str(ctx, str); | ||
| if (!s) | ||
| return NULL; | ||
| obj = FN(isl_stream_read,TYPE_BASE)(s); | ||
| isl_stream_free(s); | ||
| return obj; | ||
| } |