2 * Copyright 2008-2009 Katholieke Universiteit Leuven
4 * Use of this software is governed by the GNU LGPLv2.1 license
6 * Written by Sven Verdoolaege, K.U.Leuven, Departement
7 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
10 #ifndef ISL_MAP_PRIVATE_H
11 #define ISL_MAP_PRIVATE_H
15 #include <isl_reordering.h>
18 /* A "basic map" is a relation between two sets of variables,
19 * called the "in" and "out" variables.
21 * It is implemented as a set with two extra fields:
22 * n_in is the number of in variables
23 * n_out is the number of out variables
24 * n_in + n_out should be equal to set.dim
26 struct isl_basic_map {
28 #define ISL_BASIC_MAP_FINAL (1 << 0)
29 #define ISL_BASIC_MAP_EMPTY (1 << 1)
30 #define ISL_BASIC_MAP_NO_IMPLICIT (1 << 2)
31 #define ISL_BASIC_MAP_NO_REDUNDANT (1 << 3)
32 #define ISL_BASIC_MAP_RATIONAL (1 << 4)
33 #define ISL_BASIC_MAP_NORMALIZED (1 << 5)
34 #define ISL_BASIC_MAP_NORMALIZED_DIVS (1 << 6)
35 #define ISL_BASIC_MAP_ALL_EQUALITIES (1 << 7)
54 struct isl_vec *sample;
57 struct isl_blk block2;
60 /* A "basic set" is a basic map with a zero-dimensional
63 struct isl_basic_set {
65 #define ISL_BASIC_SET_FINAL (1 << 0)
66 #define ISL_BASIC_SET_EMPTY (1 << 1)
67 #define ISL_BASIC_SET_NO_IMPLICIT (1 << 2)
68 #define ISL_BASIC_SET_NO_REDUNDANT (1 << 3)
69 #define ISL_BASIC_SET_RATIONAL (1 << 4)
70 #define ISL_BASIC_SET_NORMALIZED (1 << 5)
71 #define ISL_BASIC_SET_NORMALIZED_DIVS (1 << 6)
72 #define ISL_BASIC_SET_ALL_EQUALITIES (1 << 7)
91 struct isl_vec *sample;
94 struct isl_blk block2;
97 __isl_give isl_map *isl_map_realign(__isl_take isl_map *map,
98 __isl_take isl_reordering *r);
99 __isl_give isl_set *isl_set_realign(__isl_take isl_set *set,
100 __isl_take isl_reordering *r);
102 __isl_give isl_map *isl_map_reset(__isl_take isl_map *map,
103 enum isl_dim_type type);
105 __isl_give isl_basic_map *isl_basic_map_reset_dim(
106 __isl_take isl_basic_map *bmap, __isl_take isl_dim *dim);
107 __isl_give isl_map *isl_map_reset_dim(__isl_take isl_map *map,
108 __isl_take isl_dim *dim);
110 unsigned isl_basic_map_offset(struct isl_basic_map *bmap,
111 enum isl_dim_type type);
113 int isl_map_compatible_domain(struct isl_map *map, struct isl_set *set);
114 int isl_basic_map_compatible_domain(struct isl_basic_map *bmap,
115 struct isl_basic_set *bset);
116 int isl_basic_map_compatible_range(struct isl_basic_map *bmap,
117 struct isl_basic_set *bset);
119 struct isl_basic_map *isl_basic_map_extend_dim(struct isl_basic_map *base,
120 struct isl_dim *dim, unsigned extra,
121 unsigned n_eq, unsigned n_ineq);
122 struct isl_basic_set *isl_basic_set_extend_dim(struct isl_basic_set *base,
123 struct isl_dim *dim, unsigned extra,
124 unsigned n_eq, unsigned n_ineq);
125 struct isl_basic_set *isl_basic_set_add_constraints(struct isl_basic_set *bset1,
126 struct isl_basic_set *bset2, unsigned pos);
128 struct isl_map *isl_map_grow(struct isl_map *map, int n);
129 struct isl_set *isl_set_grow(struct isl_set *set, int n);
131 int isl_basic_set_contains(struct isl_basic_set *bset, struct isl_vec *vec);
132 int isl_basic_map_contains(struct isl_basic_map *bmap, struct isl_vec *vec);
134 struct isl_basic_set *isl_basic_set_alloc_dim(struct isl_dim *dim,
135 unsigned extra, unsigned n_eq, unsigned n_ineq);
136 struct isl_set *isl_set_alloc_dim(struct isl_dim *dim, int n, unsigned flags);
137 struct isl_basic_map *isl_basic_map_alloc_dim(struct isl_dim *dim,
138 unsigned extra, unsigned n_eq, unsigned n_ineq);
139 struct isl_map *isl_map_alloc_dim(struct isl_dim *dim, int n, unsigned flags);
141 unsigned isl_basic_map_total_dim(const struct isl_basic_map *bmap);
143 int isl_basic_map_alloc_equality(struct isl_basic_map *bmap);
144 int isl_basic_set_alloc_equality(struct isl_basic_set *bset);
145 int isl_basic_set_free_inequality(struct isl_basic_set *bset, unsigned n);
146 int isl_basic_map_free_equality(struct isl_basic_map *bmap, unsigned n);
147 int isl_basic_set_free_equality(struct isl_basic_set *bset, unsigned n);
148 int isl_basic_set_alloc_inequality(struct isl_basic_set *bset);
149 int isl_basic_map_alloc_inequality(struct isl_basic_map *bmap);
150 int isl_basic_map_free_inequality(struct isl_basic_map *bmap, unsigned n);
151 int isl_basic_map_alloc_div(struct isl_basic_map *bmap);
152 int isl_basic_set_alloc_div(struct isl_basic_set *bset);
153 int isl_basic_map_free_div(struct isl_basic_map *bmap, unsigned n);
154 int isl_basic_set_free_div(struct isl_basic_set *bset, unsigned n);
155 void isl_basic_map_inequality_to_equality(
156 struct isl_basic_map *bmap, unsigned pos);
157 int isl_basic_map_drop_equality(struct isl_basic_map *bmap, unsigned pos);
158 int isl_basic_set_drop_equality(struct isl_basic_set *bset, unsigned pos);
159 int isl_basic_set_drop_inequality(struct isl_basic_set *bset, unsigned pos);
160 int isl_basic_map_drop_inequality(struct isl_basic_map *bmap, unsigned pos);
161 __isl_give isl_basic_set *isl_basic_set_add_eq(__isl_take isl_basic_set *bset,
163 __isl_give isl_basic_map *isl_basic_map_add_eq(__isl_take isl_basic_map *bmap,
165 __isl_give isl_basic_set *isl_basic_set_add_ineq(__isl_take isl_basic_set *bset,
167 __isl_give isl_basic_map *isl_basic_map_add_ineq(__isl_take isl_basic_map *bmap,
170 int isl_inequality_negate(struct isl_basic_map *bmap, unsigned pos);
172 struct isl_basic_set *isl_basic_set_cow(struct isl_basic_set *bset);
173 struct isl_basic_map *isl_basic_map_cow(struct isl_basic_map *bmap);
174 struct isl_set *isl_set_cow(struct isl_set *set);
175 struct isl_map *isl_map_cow(struct isl_map *map);
177 struct isl_basic_map *isl_basic_map_set_to_empty(struct isl_basic_map *bmap);
178 struct isl_basic_set *isl_basic_set_set_to_empty(struct isl_basic_set *bset);
179 struct isl_basic_set *isl_basic_set_order_divs(struct isl_basic_set *bset);
180 void isl_basic_map_swap_div(struct isl_basic_map *bmap, int a, int b);
181 struct isl_basic_map *isl_basic_map_order_divs(struct isl_basic_map *bmap);
182 __isl_give isl_map *isl_map_order_divs(__isl_take isl_map *map);
183 struct isl_basic_map *isl_basic_map_align_divs(
184 struct isl_basic_map *dst, struct isl_basic_map *src);
185 struct isl_basic_set *isl_basic_set_align_divs(
186 struct isl_basic_set *dst, struct isl_basic_set *src);
187 struct isl_basic_map *isl_basic_map_gauss(
188 struct isl_basic_map *bmap, int *progress);
189 struct isl_basic_set *isl_basic_set_gauss(
190 struct isl_basic_set *bset, int *progress);
191 __isl_give isl_basic_set *isl_basic_set_sort_constraints(
192 __isl_take isl_basic_set *bset);
193 int isl_basic_map_fast_cmp(const __isl_keep isl_basic_map *bmap1,
194 const __isl_keep isl_basic_map *bmap2);
195 int isl_basic_set_fast_is_equal(__isl_keep isl_basic_set *bset1,
196 __isl_keep isl_basic_set *bset2);
197 int isl_basic_map_fast_is_equal(__isl_keep isl_basic_map *bmap1,
198 __isl_keep isl_basic_map *bmap2);
199 struct isl_basic_map *isl_basic_map_normalize_constraints(
200 struct isl_basic_map *bmap);
201 struct isl_basic_set *isl_basic_set_normalize_constraints(
202 struct isl_basic_set *bset);
203 struct isl_basic_map *isl_basic_map_implicit_equalities(
204 struct isl_basic_map *bmap);
205 struct isl_basic_set *isl_basic_map_underlying_set(struct isl_basic_map *bmap);
206 __isl_give isl_basic_set *isl_basic_set_underlying_set(
207 __isl_take isl_basic_set *bset);
208 struct isl_set *isl_map_underlying_set(struct isl_map *map);
209 struct isl_basic_map *isl_basic_map_overlying_set(struct isl_basic_set *bset,
210 struct isl_basic_map *like);
211 __isl_give isl_basic_set *isl_basic_set_drop_constraints_involving(
212 __isl_take isl_basic_set *bset, unsigned first, unsigned n);
213 __isl_give isl_basic_set *isl_basic_set_drop(__isl_take isl_basic_set *bset,
214 enum isl_dim_type type, unsigned first, unsigned n);
215 struct isl_basic_map *isl_basic_map_drop(struct isl_basic_map *bmap,
216 enum isl_dim_type type, unsigned first, unsigned n);
217 struct isl_set *isl_set_drop(struct isl_set *set,
218 enum isl_dim_type type, unsigned first, unsigned n);
219 struct isl_basic_set *isl_basic_set_drop_dims(
220 struct isl_basic_set *bset, unsigned first, unsigned n);
221 struct isl_set *isl_set_drop_dims(
222 struct isl_set *set, unsigned first, unsigned n);
223 struct isl_map *isl_map_drop_inputs(
224 struct isl_map *map, unsigned first, unsigned n);
225 struct isl_map *isl_map_drop(struct isl_map *map,
226 enum isl_dim_type type, unsigned first, unsigned n);
228 struct isl_map *isl_map_remove_empty_parts(struct isl_map *map);
229 struct isl_set *isl_set_remove_empty_parts(struct isl_set *set);
231 struct isl_set *isl_set_normalize(struct isl_set *set);
233 struct isl_set *isl_set_drop_vars(
234 struct isl_set *set, unsigned first, unsigned n);
236 struct isl_basic_map *isl_basic_map_eliminate_vars(
237 struct isl_basic_map *bmap, unsigned pos, unsigned n);
238 struct isl_basic_set *isl_basic_set_eliminate_vars(
239 struct isl_basic_set *bset, unsigned pos, unsigned n);
241 __isl_give isl_map *isl_map_eliminate(__isl_take isl_map *map,
242 enum isl_dim_type type, unsigned first, unsigned n);
243 __isl_give isl_set *isl_set_eliminate(__isl_take isl_set *set,
244 enum isl_dim_type type, unsigned first, unsigned n);
246 int isl_basic_set_constraint_is_redundant(struct isl_basic_set **bset,
247 isl_int *c, isl_int *opt_n, isl_int *opt_d);
249 int isl_basic_map_add_div_constraints(struct isl_basic_map *bmap, unsigned div);
250 struct isl_basic_map *isl_basic_map_drop_redundant_divs(
251 struct isl_basic_map *bmap);
252 struct isl_basic_set *isl_basic_set_drop_redundant_divs(
253 struct isl_basic_set *bset);
255 struct isl_basic_set *isl_basic_set_recession_cone(struct isl_basic_set *bset);
256 struct isl_basic_set *isl_basic_set_lineality_space(struct isl_basic_set *bset);
258 struct isl_basic_set *isl_basic_set_set_rational(struct isl_basic_set *bset);
262 struct isl_basic_set *isl_basic_set_preimage(struct isl_basic_set *bset,
263 struct isl_mat *mat);
264 struct isl_set *isl_set_preimage(struct isl_set *set, struct isl_mat *mat);
266 isl_int *isl_set_wrap_facet(__isl_keep isl_set *set,
267 isl_int *facet, isl_int *ridge);
269 int isl_basic_map_contains_point(__isl_keep isl_basic_map *bmap,
270 __isl_keep isl_point *point);
271 int isl_set_contains_point(__isl_keep isl_set *set, __isl_keep isl_point *point);
273 int isl_basic_set_vars_get_sign(__isl_keep isl_basic_set *bset,
274 unsigned first, unsigned n, int *signs);
275 int isl_set_foreach_orthant(__isl_keep isl_set *set,
276 int (*fn)(__isl_take isl_set *orthant, int *signs, void *user),
279 int isl_basic_set_add_div_constraints_var(__isl_keep isl_basic_set *bset,
280 unsigned pos, isl_int *div);
281 int isl_basic_map_is_div_constraint(__isl_keep isl_basic_map *bmap,
282 isl_int *constraint, unsigned div);