isl_basic_map_make_strides_explicit: move down isl_basic_map_get_ctx call
[isl.git] / isl_pw_insert_dims_templ.c
blob8e61fd9beca7f80c63f6806a3cb49de083724138
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,insert_dims)(__isl_take PW *pw, enum isl_dim_type type,
12 unsigned first, unsigned n)
14 int i;
15 enum isl_dim_type set_type;
17 if (!pw)
18 return NULL;
19 if (n == 0 && !isl_space_is_named_or_nested(pw->dim, type))
20 return pw;
22 set_type = type == isl_dim_in ? isl_dim_set : type;
24 pw = FN(PW,cow)(pw);
25 if (!pw)
26 return NULL;
28 pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
29 if (!pw->dim)
30 goto error;
32 for (i = 0; i < pw->n; ++i) {
33 pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
34 set_type, first, n);
35 if (!pw->p[i].set)
36 goto error;
37 pw->p[i].FIELD = FN(EL,insert_dims)(pw->p[i].FIELD,
38 type, first, n);
39 if (!pw->p[i].FIELD)
40 goto error;
43 return pw;
44 error:
45 FN(PW,free)(pw);
46 return NULL;