2 * Copyright 2011 Sven Verdoolaege
3 * Copyright 2012-2013 Ecole Normale Superieure
5 * Use of this software is governed by the MIT license
7 * Written by Sven Verdoolaege,
8 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
11 #include <isl_space_private.h>
13 #include <isl_multi_macro.h>
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.
19 isl_bool
FN(MULTI(BASE
),involves_dims
)(__isl_keep
MULTI(BASE
) *multi
,
20 enum isl_dim_type type
, unsigned first
, unsigned n
)
25 return isl_bool_error
;
27 return isl_bool_false
;
29 for (i
= 0; i
< multi
->n
; ++i
) {
32 involves
= FN(EL
,involves_dims
)(multi
->u
.p
[i
], type
, first
, n
);
33 if (involves
< 0 || involves
)
37 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
))
38 return FN(MULTI(BASE
),involves_explicit_domain_dims
)(multi
,
41 return isl_bool_false
;
44 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),insert_dims
)(
45 __isl_take
MULTI(BASE
) *multi
,
46 enum isl_dim_type type
, unsigned first
, unsigned n
)
52 size
= FN(MULTI(BASE
),size
)(multi
);
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
))
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
);
66 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
))
67 multi
= FN(MULTI(BASE
),insert_explicit_domain_dims
)(multi
,
70 for (i
= 0; i
< size
; ++i
) {
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
);
81 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),add_dims
)(__isl_take
MULTI(BASE
) *multi
,
82 enum isl_dim_type type
, unsigned n
)
86 pos
= FN(MULTI(BASE
),dim
)(multi
, type
);
88 return FN(MULTI(BASE
),free
)(multi
);
90 return FN(MULTI(BASE
),insert_dims
)(multi
, type
, pos
, n
);
93 /* Project the domain of "multi" onto its parameter space.
94 * "multi" may not involve any of the domain dimensions.
96 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),project_domain_on_params
)(
97 __isl_take
MULTI(BASE
) *multi
)
103 n
= FN(MULTI(BASE
),dim
)(multi
, isl_dim_in
);
105 return FN(MULTI(BASE
),free
)(multi
);
106 involves
= FN(MULTI(BASE
),involves_dims
)(multi
, isl_dim_in
, 0, n
);
108 return FN(MULTI(BASE
),free
)(multi
);
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
);