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 #include <isl_pw_macro.h>
12
FN(PW,split_dims)13 __isl_give PW *FN(PW,split_dims)(__isl_take PW *pw,
14 enum isl_dim_type type, unsigned first, unsigned n)
15 {
16 int i;
17 isl_size n_piece;
18
19 n_piece = FN(PW,n_piece)(pw);
20 if (n_piece < 0)
21 return FN(PW,free)(pw);
22 if (n == 0)
23 return pw;
24
25 if (type == isl_dim_in)
26 type = isl_dim_set;
27
28 for (i = 0; i < n; ++i) {
29 isl_set *domain;
30
31 domain = FN(PW,take_domain_at)(pw, i);
32 domain = isl_set_split_dims(domain, type, first, n);
33 pw = FN(PW,restore_domain_at)(pw, i, domain);
34 }
35
36 return pw;
37 }
38