1 /*
2 * Copyright 2010 INRIA Saclay
3 *
4 * Use of this software is governed by the MIT license
5 *
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 */
10
FN(PW,move_dims)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)
14 {
15 int i;
16
17 pw = FN(PW,cow)(pw);
18 if (!pw)
19 return NULL;
20
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;
24
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;
30 }
31
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;
36
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;
43 }
44
45 return pw;
46 error:
47 FN(PW,free)(pw);
48 return NULL;
49 }
50