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