2 * Copyright 2008-2009 Katholieke Universiteit Leuven
4 * Use of this software is governed by the MIT 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
13 #define isl_basic_set isl_basic_map
14 #define isl_set isl_map
15 #define isl_basic_set_list isl_basic_map_list
16 #define isl_set_list isl_map_list
18 ISL_DECLARE_LIST(basic_map)
22 #include <isl_reordering.h>
25 /* A "basic map" is a relation between two sets of variables,
26 * called the "in" and "out" variables.
27 * A "basic set" is a basic map with a zero-dimensional
30 * It is implemented as a set with two extra fields:
31 * n_in is the number of in variables
32 * n_out is the number of out variables
33 * n_in + n_out should be equal to set.dim
35 struct isl_basic_map {
37 #define ISL_BASIC_MAP_FINAL (1 << 0)
38 #define ISL_BASIC_MAP_EMPTY (1 << 1)
39 #define ISL_BASIC_MAP_NO_IMPLICIT (1 << 2)
40 #define ISL_BASIC_MAP_NO_REDUNDANT (1 << 3)
41 #define ISL_BASIC_MAP_RATIONAL (1 << 4)
42 #define ISL_BASIC_MAP_NORMALIZED (1 << 5)
43 #define ISL_BASIC_MAP_NORMALIZED_DIVS (1 << 6)
44 #define ISL_BASIC_MAP_ALL_EQUALITIES (1 << 7)
45 #define ISL_BASIC_SET_FINAL (1 << 0)
46 #define ISL_BASIC_SET_EMPTY (1 << 1)
47 #define ISL_BASIC_SET_NO_IMPLICIT (1 << 2)
48 #define ISL_BASIC_SET_NO_REDUNDANT (1 << 3)
49 #define ISL_BASIC_SET_RATIONAL (1 << 4)
50 #define ISL_BASIC_SET_NORMALIZED (1 << 5)
51 #define ISL_BASIC_SET_NORMALIZED_DIVS (1 << 6)
52 #define ISL_BASIC_SET_ALL_EQUALITIES (1 << 7)
71 struct isl_vec *sample;
74 struct isl_blk block2;
78 #define EL isl_basic_set
80 #include <isl_list_templ.h>
82 /* A "map" is a (possibly disjoint) union of basic maps.
83 * A "set" is a (possibly disjoint) union of basic sets.
85 * Currently, the isl_set structure is identical to the isl_map structure
86 * and the library depends on this correspondence internally.
87 * However, users should not depend on this correspondence.
91 #define ISL_MAP_DISJOINT (1 << 0)
92 #define ISL_MAP_NORMALIZED (1 << 1)
93 #define ISL_SET_DISJOINT (1 << 0)
94 #define ISL_SET_NORMALIZED (1 << 1)
104 struct isl_basic_map *p[1];
110 #include <isl_list_templ.h>
112 __isl_give isl_map *isl_map_realign(__isl_take isl_map *map,
113 __isl_take isl_reordering *r);
114 __isl_give isl_set *isl_set_realign(__isl_take isl_set *set,
115 __isl_take isl_reordering *r);
117 __isl_give isl_map *isl_map_reset(__isl_take isl_map *map,
118 enum isl_dim_type type);
120 __isl_give isl_basic_set *isl_basic_set_reset_space(
121 __isl_take isl_basic_set *bset, __isl_take isl_space *dim);
122 __isl_give isl_basic_map *isl_basic_map_reset_space(
123 __isl_take isl_basic_map *bmap, __isl_take isl_space *dim);
124 __isl_give isl_map *isl_map_reset_space(__isl_take isl_map *map,
125 __isl_take isl_space *dim);
127 unsigned isl_basic_map_offset(struct isl_basic_map *bmap,
128 enum isl_dim_type type);
129 unsigned isl_basic_set_offset(struct isl_basic_set *bset,
130 enum isl_dim_type type);
132 int isl_basic_map_may_be_set(__isl_keep isl_basic_map *bmap);
133 int isl_map_may_be_set(__isl_keep isl_map *map);
134 int isl_map_compatible_domain(struct isl_map *map, struct isl_set *set);
135 int isl_basic_map_compatible_domain(struct isl_basic_map *bmap,
136 struct isl_basic_set *bset);
137 int isl_basic_map_compatible_range(struct isl_basic_map *bmap,
138 struct isl_basic_set *bset);
140 struct isl_basic_map *isl_basic_map_extend_space(struct isl_basic_map *base,
141 __isl_take isl_space *dim, unsigned extra,
142 unsigned n_eq, unsigned n_ineq);
143 struct isl_basic_set *isl_basic_set_extend_space(struct isl_basic_set *base,
144 __isl_take isl_space *dim, unsigned extra,
145 unsigned n_eq, unsigned n_ineq);
146 struct isl_basic_set *isl_basic_set_add_constraints(struct isl_basic_set *bset1,
147 struct isl_basic_set *bset2, unsigned pos);
149 struct isl_map *isl_map_grow(struct isl_map *map, int n);
150 struct isl_set *isl_set_grow(struct isl_set *set, int n);
152 int isl_basic_set_contains(struct isl_basic_set *bset, struct isl_vec *vec);
153 int isl_basic_map_contains(struct isl_basic_map *bmap, struct isl_vec *vec);
155 __isl_give isl_basic_set *isl_basic_set_alloc_space(__isl_take isl_space *dim,
156 unsigned extra, unsigned n_eq, unsigned n_ineq);
157 __isl_give isl_set *isl_set_alloc_space(__isl_take isl_space *dim, int n,
159 __isl_give isl_basic_map *isl_basic_map_alloc_space(__isl_take isl_space *dim,
160 unsigned extra, unsigned n_eq, unsigned n_ineq);
161 __isl_give isl_map *isl_map_alloc_space(__isl_take isl_space *dim, int n,
164 unsigned isl_basic_map_total_dim(const struct isl_basic_map *bmap);
166 int isl_basic_map_alloc_equality(struct isl_basic_map *bmap);
167 int isl_basic_set_alloc_equality(struct isl_basic_set *bset);
168 int isl_basic_set_free_inequality(struct isl_basic_set *bset, unsigned n);
169 int isl_basic_map_free_equality(struct isl_basic_map *bmap, unsigned n);
170 int isl_basic_set_free_equality(struct isl_basic_set *bset, unsigned n);
171 int isl_basic_set_alloc_inequality(struct isl_basic_set *bset);
172 int isl_basic_map_alloc_inequality(struct isl_basic_map *bmap);
173 int isl_basic_map_free_inequality(struct isl_basic_map *bmap, unsigned n);
174 int isl_basic_map_alloc_div(struct isl_basic_map *bmap);
175 int isl_basic_set_alloc_div(struct isl_basic_set *bset);
176 int isl_basic_map_free_div(struct isl_basic_map *bmap, unsigned n);
177 int isl_basic_set_free_div(struct isl_basic_set *bset, unsigned n);
178 void isl_basic_map_inequality_to_equality(
179 struct isl_basic_map *bmap, unsigned pos);
180 int isl_basic_map_drop_equality(struct isl_basic_map *bmap, unsigned pos);
181 int isl_basic_set_drop_equality(struct isl_basic_set *bset, unsigned pos);
182 int isl_basic_set_drop_inequality(struct isl_basic_set *bset, unsigned pos);
183 int isl_basic_map_drop_inequality(struct isl_basic_map *bmap, unsigned pos);
184 __isl_give isl_basic_set *isl_basic_set_add_eq(__isl_take isl_basic_set *bset,
186 __isl_give isl_basic_map *isl_basic_map_add_eq(__isl_take isl_basic_map *bmap,
188 __isl_give isl_basic_set *isl_basic_set_add_ineq(__isl_take isl_basic_set *bset,
190 __isl_give isl_basic_map *isl_basic_map_add_ineq(__isl_take isl_basic_map *bmap,
193 int isl_inequality_negate(struct isl_basic_map *bmap, unsigned pos);
195 struct isl_basic_set *isl_basic_set_cow(struct isl_basic_set *bset);
196 struct isl_basic_map *isl_basic_map_cow(struct isl_basic_map *bmap);
197 struct isl_set *isl_set_cow(struct isl_set *set);
198 struct isl_map *isl_map_cow(struct isl_map *map);
200 struct isl_basic_map *isl_basic_map_set_to_empty(struct isl_basic_map *bmap);
201 struct isl_basic_set *isl_basic_set_set_to_empty(struct isl_basic_set *bset);
202 struct isl_basic_set *isl_basic_set_order_divs(struct isl_basic_set *bset);
203 void isl_basic_map_swap_div(struct isl_basic_map *bmap, int a, int b);
204 struct isl_basic_map *isl_basic_map_order_divs(struct isl_basic_map *bmap);
205 __isl_give isl_map *isl_map_order_divs(__isl_take isl_map *map);
206 struct isl_basic_map *isl_basic_map_align_divs(
207 struct isl_basic_map *dst, struct isl_basic_map *src);
208 struct isl_basic_set *isl_basic_set_align_divs(
209 struct isl_basic_set *dst, struct isl_basic_set *src);
210 __isl_give isl_basic_map *isl_basic_map_sort_divs(
211 __isl_take isl_basic_map *bmap);
212 __isl_give isl_map *isl_map_sort_divs(__isl_take isl_map *map);
213 struct isl_basic_map *isl_basic_map_gauss(
214 struct isl_basic_map *bmap, int *progress);
215 struct isl_basic_set *isl_basic_set_gauss(
216 struct isl_basic_set *bset, int *progress);
217 __isl_give isl_basic_set *isl_basic_set_sort_constraints(
218 __isl_take isl_basic_set *bset);
219 int isl_basic_map_plain_cmp(const __isl_keep isl_basic_map *bmap1,
220 const __isl_keep isl_basic_map *bmap2);
221 int isl_basic_set_plain_is_equal(__isl_keep isl_basic_set *bset1,
222 __isl_keep isl_basic_set *bset2);
223 int isl_basic_map_plain_is_equal(__isl_keep isl_basic_map *bmap1,
224 __isl_keep isl_basic_map *bmap2);
225 struct isl_basic_map *isl_basic_map_normalize_constraints(
226 struct isl_basic_map *bmap);
227 struct isl_basic_set *isl_basic_set_normalize_constraints(
228 struct isl_basic_set *bset);
229 struct isl_basic_map *isl_basic_map_implicit_equalities(
230 struct isl_basic_map *bmap);
231 struct isl_basic_set *isl_basic_map_underlying_set(struct isl_basic_map *bmap);
232 __isl_give isl_basic_set *isl_basic_set_underlying_set(
233 __isl_take isl_basic_set *bset);
234 struct isl_set *isl_map_underlying_set(struct isl_map *map);
235 struct isl_basic_map *isl_basic_map_overlying_set(struct isl_basic_set *bset,
236 struct isl_basic_map *like);
237 __isl_give isl_basic_set *isl_basic_set_drop_constraints_involving(
238 __isl_take isl_basic_set *bset, unsigned first, unsigned n);
239 __isl_give isl_basic_set *isl_basic_set_drop(__isl_take isl_basic_set *bset,
240 enum isl_dim_type type, unsigned first, unsigned n);
241 struct isl_basic_map *isl_basic_map_drop(struct isl_basic_map *bmap,
242 enum isl_dim_type type, unsigned first, unsigned n);
243 struct isl_set *isl_set_drop(struct isl_set *set,
244 enum isl_dim_type type, unsigned first, unsigned n);
245 struct isl_basic_set *isl_basic_set_drop_dims(
246 struct isl_basic_set *bset, unsigned first, unsigned n);
247 struct isl_set *isl_set_drop_dims(
248 struct isl_set *set, unsigned first, unsigned n);
249 struct isl_map *isl_map_drop_inputs(
250 struct isl_map *map, unsigned first, unsigned n);
251 struct isl_map *isl_map_drop(struct isl_map *map,
252 enum isl_dim_type type, unsigned first, unsigned n);
254 struct isl_map *isl_map_remove_empty_parts(struct isl_map *map);
255 struct isl_set *isl_set_remove_empty_parts(struct isl_set *set);
257 struct isl_set *isl_set_normalize(struct isl_set *set);
259 struct isl_set *isl_set_drop_vars(
260 struct isl_set *set, unsigned first, unsigned n);
262 struct isl_basic_map *isl_basic_map_eliminate_vars(
263 struct isl_basic_map *bmap, unsigned pos, unsigned n);
264 struct isl_basic_set *isl_basic_set_eliminate_vars(
265 struct isl_basic_set *bset, unsigned pos, unsigned n);
267 __isl_give isl_map *isl_map_eliminate(__isl_take isl_map *map,
268 enum isl_dim_type type, unsigned first, unsigned n);
269 __isl_give isl_set *isl_set_eliminate(__isl_take isl_set *set,
270 enum isl_dim_type type, unsigned first, unsigned n);
272 int isl_basic_set_constraint_is_redundant(struct isl_basic_set **bset,
273 isl_int *c, isl_int *opt_n, isl_int *opt_d);
275 int isl_basic_map_add_div_constraints(struct isl_basic_map *bmap, unsigned div);
276 struct isl_basic_map *isl_basic_map_drop_redundant_divs(
277 struct isl_basic_map *bmap);
278 struct isl_basic_set *isl_basic_set_drop_redundant_divs(
279 struct isl_basic_set *bset);
281 struct isl_basic_set *isl_basic_set_recession_cone(struct isl_basic_set *bset);
282 struct isl_basic_set *isl_basic_set_lineality_space(struct isl_basic_set *bset);
284 struct isl_basic_set *isl_basic_set_set_rational(struct isl_basic_set *bset);
285 __isl_give isl_set *isl_set_set_rational(__isl_take isl_set *set);
286 __isl_give isl_basic_map *isl_basic_map_set_rational(
287 __isl_take isl_basic_map *bmap);
288 __isl_give isl_map *isl_map_set_rational(__isl_take isl_map *map);
290 int isl_map_has_rational(__isl_keep isl_map *map);
291 int isl_set_has_rational(__isl_keep isl_set *set);
295 struct isl_basic_set *isl_basic_set_preimage(struct isl_basic_set *bset,
296 struct isl_mat *mat);
297 struct isl_set *isl_set_preimage(struct isl_set *set, struct isl_mat *mat);
299 __isl_give isl_basic_set *isl_basic_set_transform_dims(
300 __isl_take isl_basic_set *bset, enum isl_dim_type type, unsigned first,
301 __isl_take isl_mat *trans);
303 isl_int *isl_set_wrap_facet(__isl_keep isl_set *set,
304 isl_int *facet, isl_int *ridge);
306 int isl_basic_map_contains_point(__isl_keep isl_basic_map *bmap,
307 __isl_keep isl_point *point);
308 int isl_set_contains_point(__isl_keep isl_set *set, __isl_keep isl_point *point);
310 int isl_basic_set_vars_get_sign(__isl_keep isl_basic_set *bset,
311 unsigned first, unsigned n, int *signs);
312 int isl_set_foreach_orthant(__isl_keep isl_set *set,
313 int (*fn)(__isl_take isl_set *orthant, int *signs, void *user),
316 int isl_basic_map_add_div_constraints_var(__isl_keep isl_basic_map *bmap,
317 unsigned pos, isl_int *div);
318 int isl_basic_set_add_div_constraints_var(__isl_keep isl_basic_set *bset,
319 unsigned pos, isl_int *div);
320 int isl_basic_map_is_div_constraint(__isl_keep isl_basic_map *bmap,
321 isl_int *constraint, unsigned div);
322 int isl_basic_set_is_div_constraint(__isl_keep isl_basic_set *bset,
323 isl_int *constraint, unsigned div);
325 __isl_give isl_basic_set *isl_basic_set_from_local_space(
326 __isl_take isl_local_space *ls);
327 __isl_give isl_basic_map *isl_basic_map_from_local_space(
328 __isl_take isl_local_space *ls);
329 __isl_give isl_basic_set *isl_basic_set_expand_divs(
330 __isl_take isl_basic_set *bset, __isl_take isl_mat *div, int *exp);
332 int isl_basic_map_divs_known(__isl_keep isl_basic_map *bmap);
333 __isl_give isl_mat *isl_basic_set_get_divs(__isl_keep isl_basic_set *bset);
334 __isl_give isl_mat *isl_basic_map_get_divs(__isl_keep isl_basic_map *bmap);
336 __isl_give isl_map *isl_map_inline_foreach_basic_map(__isl_take isl_map *map,
337 __isl_give isl_basic_map *(*fn)(__isl_take isl_basic_map *bmap));
339 __isl_give isl_map *isl_map_align_params_map_map_and(
340 __isl_take isl_map *map1, __isl_take isl_map *map2,
341 __isl_give isl_map *(*fn)(__isl_take isl_map *map1,
342 __isl_take isl_map *map2));
343 int isl_map_align_params_map_map_and_test(__isl_keep isl_map *map1,
344 __isl_keep isl_map *map2,
345 int (*fn)(__isl_keep isl_map *map1, __isl_keep isl_map *map2));
347 int isl_basic_map_foreach_lexopt(__isl_keep isl_basic_map *bmap, int max,
348 int (*fn)(__isl_take isl_basic_set *dom, __isl_take isl_aff_list *list,
351 int isl_basic_set_foreach_lexopt(__isl_keep isl_basic_set *bset, int max,
352 int (*fn)(__isl_take isl_basic_set *dom, __isl_take isl_aff_list *list,
356 __isl_give isl_set *isl_set_substitute(__isl_take isl_set *set,
357 enum isl_dim_type type, unsigned pos, __isl_keep isl_aff *subs);
359 __isl_give isl_set *isl_set_gist_params_basic_set(__isl_take isl_set *set,
360 __isl_take isl_basic_set *context);
362 int isl_map_compatible_range(__isl_keep isl_map *map, __isl_keep isl_set *set);
364 int isl_basic_map_plain_is_single_valued(__isl_keep isl_basic_map *bmap);
366 int isl_map_is_set(__isl_keep isl_map *map);