Polly 19.0.0git
isl_multi_dims.c
Go to the documentation of this file.
1/*
2 * Copyright 2011 Sven Verdoolaege
3 * Copyright 2012-2013 Ecole Normale Superieure
4 *
5 * Use of this software is governed by the MIT license
6 *
7 * Written by Sven Verdoolaege,
8 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
9 */
10
11#include <isl_space_private.h>
12
13#include <isl_multi_macro.h>
14
15/* Check whether "multi" has non-zero coefficients for any dimension
16 * in the given range or if any of these dimensions appear
17 * with non-zero coefficients in any of the integer divisions involved.
18 */
19isl_bool FN(MULTI(BASE),involves_dims)(__isl_keep MULTI(BASE) *multi,
20 enum isl_dim_type type, unsigned first, unsigned n)
21{
22 int i;
23
24 if (!multi)
25 return isl_bool_error;
26 if (n == 0)
27 return isl_bool_false;
28
29 for (i = 0; i < multi->n; ++i) {
30 isl_bool involves;
31
32 involves = FN(EL,involves_dims)(multi->u.p[i], type, first, n);
33 if (involves < 0 || involves)
34 return involves;
35 }
36
37 if (FN(MULTI(BASE),has_explicit_domain)(multi))
38 return FN(MULTI(BASE),involves_explicit_domain_dims)(multi,
39 type, first, n);
40
41 return isl_bool_false;
42}
43
45 __isl_take MULTI(BASE) *multi,
46 enum isl_dim_type type, unsigned first, unsigned n)
47{
48 isl_space *space;
50 int i;
51
52 size = FN(MULTI(BASE),size)(multi);
53 if (size < 0)
54 return FN(MULTI(BASE),free)(multi);
55 if (type == isl_dim_out)
56 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
57 "cannot insert output/set dimensions",
58 return FN(MULTI(BASE),free)(multi));
59 if (n == 0 && !isl_space_is_named_or_nested(multi->space, type))
60 return multi;
61
62 space = FN(MULTI(BASE),take_space)(multi);
63 space = isl_space_insert_dims(space, type, first, n);
64 multi = FN(MULTI(BASE),restore_space)(multi, space);
65
66 if (FN(MULTI(BASE),has_explicit_domain)(multi))
67 multi = FN(MULTI(BASE),insert_explicit_domain_dims)(multi,
68 type, first, n);
69
70 for (i = 0; i < size; ++i) {
71 EL *el;
72
73 el = FN(MULTI(BASE),take_at)(multi, i);
74 el = FN(EL,insert_dims)(el, type, first, n);
75 multi = FN(MULTI(BASE),restore_at)(multi, i, el);
76 }
77
78 return multi;
79}
80
81__isl_give MULTI(BASE) *FN(MULTI(BASE),add_dims)(__isl_take MULTI(BASE) *multi,
82 enum isl_dim_type type, unsigned n)
83{
85
86 pos = FN(MULTI(BASE),dim)(multi, type);
87 if (pos < 0)
88 return FN(MULTI(BASE),free)(multi);
89
90 return FN(MULTI(BASE),insert_dims)(multi, type, pos, n);
91}
92
93/* Project the domain of "multi" onto its parameter space.
94 * "multi" may not involve any of the domain dimensions.
95 */
96__isl_give MULTI(BASE) *FN(MULTI(BASE),project_domain_on_params)(
97 __isl_take MULTI(BASE) *multi)
98{
99 isl_size n;
100 isl_bool involves;
101 isl_space *space;
102
103 n = FN(MULTI(BASE),dim)(multi, isl_dim_in);
104 if (n < 0)
105 return FN(MULTI(BASE),free)(multi);
106 involves = FN(MULTI(BASE),involves_dims)(multi, isl_dim_in, 0, n);
107 if (involves < 0)
108 return FN(MULTI(BASE),free)(multi);
109 if (involves)
110 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
111 "expression involves some of the domain dimensions",
112 return FN(MULTI(BASE),free)(multi));
113 multi = FN(MULTI(BASE),drop_dims)(multi, isl_dim_in, 0, n);
114 space = FN(MULTI(BASE),get_domain_space)(multi);
115 space = isl_space_params(space);
116 multi = FN(MULTI(BASE),reset_domain_space)(multi, space);
117 return multi;
118}
#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_invalid
Definition: ctx.h:80
#define __isl_keep
Definition: ctx.h:25
int isl_size
Definition: ctx.h:96
isl_bool
Definition: ctx.h:89
@ isl_bool_false
Definition: ctx.h:91
@ isl_bool_error
Definition: ctx.h:90
#define BASE
Definition: flow_cmp.c:49
#define EL
static __isl_give isl_qpolynomial * reset_domain_space(__isl_take isl_qpolynomial *qp, void *user)
Definition: isl_fold.c:232
static __isl_give isl_qpolynomial * drop_dims(__isl_take isl_qpolynomial *qp, void *user)
Definition: isl_fold.c:373
static __isl_give isl_qpolynomial * insert_dims(__isl_take isl_qpolynomial *qp, void *user)
Definition: isl_fold.c:412
static unsigned pos(__isl_keep isl_space *space, enum isl_dim_type type)
Definition: isl_map.c:70
#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
enum isl_fold type
Definition: isl_test.c:4017
const char * size
Definition: isl_test.c:1570
__isl_export __isl_give isl_space * isl_space_params(__isl_take isl_space *space)
Definition: isl_space.c:2211
__isl_give isl_space * isl_space_insert_dims(__isl_take isl_space *space, enum isl_dim_type type, unsigned pos, unsigned n)
Definition: isl_space.c:1312
isl_dim_type
Definition: space_type.h:13
@ isl_dim_in
Definition: space_type.h:16
@ isl_dim_out
Definition: space_type.h:17
n
Definition: youcefn.c:8