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
11__isl_give PW *FN(PW,insert_dims)(__isl_take PW *pw, enum isl_dim_type type,
12 unsigned first, unsigned n)
13{
14 int i;
15 isl_size n_piece;
16 enum isl_dim_type set_type;
17 isl_space *space;
18
19 n_piece = FN(PW,n_piece)(pw);
20 if (n_piece < 0)
21 return FN(PW,free)(pw);
22 if (n == 0 && !isl_space_is_named_or_nested(space: pw->dim, type))
23 return pw;
24
25 set_type = type == isl_dim_in ? isl_dim_set : type;
26
27 space = FN(PW,take_space)(pw);
28 space = isl_space_insert_dims(space, type, pos: first, n);
29 pw = FN(PW,restore_space)(pw, space);
30
31 for (i = 0; i < n_piece; ++i) {
32 isl_set *domain;
33 EL *el;
34
35 domain = FN(PW,take_domain_at)(pw, pos: i);
36 domain = isl_set_insert_dims(set: domain, type: set_type, pos: first, n);
37 pw = FN(PW,restore_domain_at)(pw, pos: i, domain);
38 el = FN(PW,take_base_at)(pw, pos: i);
39 el = FN(EL,insert_dims)(aff: el, type, first, n);
40 pw = FN(PW,restore_base_at)(pw, pos: i, el);
41 }
42
43 return pw;
44}
45
46__isl_give PW *FN(PW,add_dims)(__isl_take PW *pw, enum isl_dim_type type,
47 unsigned n)
48{
49 isl_size pos;
50
51 pos = FN(PW,dim)(pw, type);
52 if (pos < 0)
53 return FN(PW,free)(pw);
54
55 return FN(PW,insert_dims)(pw, type, first: pos, n);
56}
57

source code of polly/lib/External/isl/isl_pw_insert_dims_templ.c