export isl_union_pw_multi_aff_get_pw_multi_aff_list
[isl.git] / isl_pw_move_dims_templ.c
blob31788d79a7f736d7835a6f703e4c15829c7f868c
1 /*
2 * Copyright 2010 INRIA Saclay
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
8 * 91893 Orsay, France
9 */
11 __isl_give PW *FN(PW,move_dims)(__isl_take PW *pw,
12 enum isl_dim_type dst_type, unsigned dst_pos,
13 enum isl_dim_type src_type, unsigned src_pos, unsigned n)
15 int i;
17 pw = FN(PW,cow)(pw);
18 if (!pw)
19 return NULL;
21 pw->dim = isl_space_move_dims(pw->dim, dst_type, dst_pos, src_type, src_pos, n);
22 if (!pw->dim)
23 goto error;
25 for (i = 0; i < pw->n; ++i) {
26 pw->p[i].FIELD = FN(EL,move_dims)(pw->p[i].FIELD,
27 dst_type, dst_pos, src_type, src_pos, n);
28 if (!pw->p[i].FIELD)
29 goto error;
32 if (dst_type == isl_dim_in)
33 dst_type = isl_dim_set;
34 if (src_type == isl_dim_in)
35 src_type = isl_dim_set;
37 for (i = 0; i < pw->n; ++i) {
38 pw->p[i].set = isl_set_move_dims(pw->p[i].set,
39 dst_type, dst_pos,
40 src_type, src_pos, n);
41 if (!pw->p[i].set)
42 goto error;
45 return pw;
46 error:
47 FN(PW,free)(pw);
48 return NULL;