Polly 19.0.0git
isl_multi_move_dims_templ.c
Go to the documentation of this file.
1/*
2 * Copyright 2013 Ecole Normale Superieure
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
8 */
9
10#include <isl/space.h>
11
12#include <isl_multi_macro.h>
13
14/* Move the "n" dimensions of "src_type" starting at "src_pos" of "multi"
15 * to dimensions of "dst_type" at "dst_pos".
16 *
17 * We only support moving input dimensions to parameters and vice versa.
18 */
20 enum isl_dim_type dst_type, unsigned dst_pos,
21 enum isl_dim_type src_type, unsigned src_pos, unsigned n)
22{
23 isl_space *space;
25 int i;
26
27 size = FN(MULTI(BASE),size)(multi);
28 if (size < 0)
29 return FN(MULTI(BASE),free)(multi);
30
31 if (n == 0 &&
32 !isl_space_is_named_or_nested(multi->space, src_type) &&
33 !isl_space_is_named_or_nested(multi->space, dst_type))
34 return multi;
35
36 if (dst_type == isl_dim_out || src_type == isl_dim_out)
37 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
38 "cannot move output/set dimension",
39 return FN(MULTI(BASE),free)(multi));
40 if (dst_type == isl_dim_div || src_type == isl_dim_div)
41 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
42 "cannot move divs",
43 return FN(MULTI(BASE),free)(multi));
44 if (FN(MULTI(BASE),check_range)(multi, src_type, src_pos, n) < 0)
45 return FN(MULTI(BASE),free)(multi);
46 if (dst_type == src_type)
47 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_unsupported,
48 "moving dims within the same type not supported",
49 return FN(MULTI(BASE),free)(multi));
50
51 space = FN(MULTI(BASE),take_space)(multi);
52 space = isl_space_move_dims(space, dst_type, dst_pos,
53 src_type, src_pos, n);
54 multi = FN(MULTI(BASE),restore_space)(multi, space);
55
56 if (FN(MULTI(BASE),has_explicit_domain)(multi))
57 multi = FN(MULTI(BASE),move_explicit_domain_dims)(multi,
58 dst_type, dst_pos, src_type, src_pos, n);
59
60 for (i = 0; i < size; ++i) {
61 EL *el;
62
63 el = FN(MULTI(BASE),take_at)(multi, i);
64 el = FN(EL,move_dims)(el, dst_type, dst_pos,
65 src_type, src_pos, n);
66 multi = FN(MULTI(BASE),restore_at)(multi, i, el);
67 }
68
69 return multi;
70}
#define FN(TYPE, NAME)
#define __isl_take
Definition: ctx.h:22
#define __isl_give
Definition: ctx.h:19
#define isl_die(ctx, errno, msg, code)
Definition: ctx.h:137
@ isl_error_unsupported
Definition: ctx.h:82
@ isl_error_invalid
Definition: ctx.h:80
int isl_size
Definition: ctx.h:96
#define BASE
Definition: flow_cmp.c:49
#define EL
static __isl_give isl_qpolynomial * move_dims(__isl_take isl_qpolynomial *qp, void *user)
Definition: isl_fold.c:1719
#define MULTI(BASE)
isl_bool isl_space_is_named_or_nested(__isl_keep isl_space *space, enum isl_dim_type type)
Definition: isl_space.c:2877
const char * size
Definition: isl_test.c:1570
__isl_give isl_space * isl_space_move_dims(__isl_take isl_space *space, enum isl_dim_type dst_type, unsigned dst_pos, enum isl_dim_type src_type, unsigned src_pos, unsigned n)
Definition: isl_space.c:1389
isl_dim_type
Definition: space_type.h:13
@ isl_dim_div
Definition: space_type.h:19
@ isl_dim_out
Definition: space_type.h:17
n
Definition: youcefn.c:8