isl_coalesce.c: fix typos in comments
[isl.git] / isl_pw_insert_dims_templ.c
blobc451dcac11324afd65dda4255604f4dd1246c9d5
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;
49 __isl_give PW *FN(PW,add_dims)(__isl_take PW *pw, enum isl_dim_type type,
50 unsigned n)
52 isl_size pos;
54 pos = FN(PW,dim)(pw, type);
55 if (pos < 0)
56 return FN(PW,free)(pw);
58 return FN(PW,insert_dims)(pw, type, pos, n);