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
21 #include <isl_printer.h>
23 #if defined(__cplusplus)
29 * All structures are reference counted to allow reuse without duplication.
30 * A *_copy operation will increase the reference count, while a *_free
31 * operation will decrease the reference count and only actually release
32 * the structures when the reference count drops to zero.
34 * Functions that return an isa structure will in general _destroy_
35 * all argument isa structures (the obvious execption begin the _copy
36 * functions). A pointer passed to such a function may therefore
37 * never be used after the function call. If you want to keep a
38 * reference to the old structure(s), use the appropriate _copy function.
41 /* A "basic map" is a relation between two sets of variables,
42 * called the "in" and "out" variables.
44 * It is implemented as a set with two extra fields:
45 * n_in is the number of in variables
46 * n_out is the number of out variables
47 * n_in + n_out should be equal to set.dim
50 struct isl_basic_map {
52 #define ISL_BASIC_MAP_FINAL (1 << 0)
53 #define ISL_BASIC_MAP_EMPTY (1 << 1)
54 #define ISL_BASIC_MAP_NO_IMPLICIT (1 << 2)
55 #define ISL_BASIC_MAP_NO_REDUNDANT (1 << 3)
56 #define ISL_BASIC_MAP_RATIONAL (1 << 4)
57 #define ISL_BASIC_MAP_NORMALIZED (1 << 5)
58 #define ISL_BASIC_MAP_NORMALIZED_DIVS (1 << 6)
59 #define ISL_BASIC_MAP_ALL_EQUALITIES (1 << 7)
78 struct isl_vec *sample;
81 struct isl_blk block2;
83 typedef struct isl_basic_map isl_basic_map;
85 typedef struct isl_basic_set isl_basic_set;
87 /* A "map" is a (disjoint) union of basic maps.
89 * Currently, the isl_set structure is identical to the isl_map structure
90 * and the library depends on this correspondence internally.
91 * However, users should not depend on this correspondence.
95 #define ISL_MAP_DISJOINT (1 << 0)
96 #define ISL_MAP_NORMALIZED (1 << 1)
106 struct isl_basic_map *p[1];
108 typedef struct isl_map isl_map;
110 typedef struct isl_set isl_set;
112 unsigned isl_basic_map_n_in(const struct isl_basic_map *bmap);
113 unsigned isl_basic_map_n_out(const struct isl_basic_map *bmap);
114 unsigned isl_basic_map_n_param(const struct isl_basic_map *bmap);
115 unsigned isl_basic_map_n_div(const struct isl_basic_map *bmap);
116 unsigned isl_basic_map_total_dim(const struct isl_basic_map *bmap);
117 unsigned isl_basic_map_dim(const struct isl_basic_map *bmap,
118 enum isl_dim_type type);
120 unsigned isl_map_n_in(const struct isl_map *map);
121 unsigned isl_map_n_out(const struct isl_map *map);
122 unsigned isl_map_n_param(const struct isl_map *map);
123 unsigned isl_map_dim(const struct isl_map *map, enum isl_dim_type type);
125 __isl_give isl_dim *isl_basic_map_get_dim(__isl_keep isl_basic_map *bmap);
126 __isl_give isl_dim *isl_map_get_dim(__isl_keep isl_map *map);
128 __isl_give isl_basic_map *isl_basic_map_set_dim_name(
129 __isl_take isl_basic_map *bmap,
130 enum isl_dim_type type, unsigned pos, const char *s);
131 __isl_give isl_map *isl_map_set_dim_name(__isl_take isl_map *map,
132 enum isl_dim_type type, unsigned pos, const char *s);
134 int isl_basic_map_is_rational(__isl_keep isl_basic_map *bmap);
136 struct isl_basic_map *isl_basic_map_alloc(struct isl_ctx *ctx,
137 unsigned nparam, unsigned in, unsigned out, unsigned extra,
138 unsigned n_eq, unsigned n_ineq);
139 __isl_give isl_basic_map *isl_basic_map_identity(__isl_take isl_dim *set_dim);
140 struct isl_basic_map *isl_basic_map_identity_like(struct isl_basic_map *model);
141 struct isl_basic_map *isl_basic_map_finalize(struct isl_basic_map *bmap);
142 void isl_basic_map_free(__isl_take isl_basic_map *bmap);
143 __isl_give isl_basic_map *isl_basic_map_copy(__isl_keep isl_basic_map *bmap);
144 struct isl_basic_map *isl_basic_map_extend(struct isl_basic_map *base,
145 unsigned nparam, unsigned n_in, unsigned n_out, unsigned extra,
146 unsigned n_eq, unsigned n_ineq);
147 struct isl_basic_map *isl_basic_map_extend_constraints(
148 struct isl_basic_map *base, unsigned n_eq, unsigned n_ineq);
149 struct isl_basic_map *isl_basic_map_equal(
150 struct isl_dim *dim, unsigned n_equal);
151 struct isl_basic_map *isl_basic_map_less_at(struct isl_dim *dim, unsigned pos);
152 struct isl_basic_map *isl_basic_map_more_at(struct isl_dim *dim, unsigned pos);
153 __isl_give isl_basic_map *isl_basic_map_empty(__isl_take isl_dim *dim);
154 struct isl_basic_map *isl_basic_map_empty_like(struct isl_basic_map *model);
155 struct isl_basic_map *isl_basic_map_empty_like_map(struct isl_map *model);
156 __isl_give isl_basic_map *isl_basic_map_universe(__isl_take isl_dim *dim);
157 __isl_give isl_basic_map *isl_basic_map_universe_like(
158 __isl_keep isl_basic_map *bmap);
159 struct isl_basic_map *isl_basic_map_convex_hull(struct isl_basic_map *bmap);
160 __isl_give isl_basic_map *isl_map_simple_hull(__isl_take isl_map *map);
162 __isl_give isl_basic_map *isl_basic_map_intersect_domain(
163 __isl_take isl_basic_map *bmap,
164 __isl_take isl_basic_set *bset);
165 __isl_give isl_basic_map *isl_basic_map_intersect_range(
166 __isl_take isl_basic_map *bmap,
167 __isl_take isl_basic_set *bset);
168 __isl_give isl_basic_map *isl_basic_map_intersect(
169 __isl_take isl_basic_map *bmap1,
170 __isl_take isl_basic_map *bmap2);
171 __isl_give isl_map *isl_basic_map_union(
172 __isl_take isl_basic_map *bmap1,
173 __isl_take isl_basic_map *bmap2);
174 __isl_give isl_basic_map *isl_basic_map_apply_domain(
175 __isl_take isl_basic_map *bmap1,
176 __isl_take isl_basic_map *bmap2);
177 __isl_give isl_basic_map *isl_basic_map_apply_range(
178 __isl_take isl_basic_map *bmap1,
179 __isl_take isl_basic_map *bmap2);
180 __isl_give isl_basic_map *isl_basic_map_affine_hull(
181 __isl_take isl_basic_map *bmap);
182 __isl_give isl_basic_map *isl_basic_map_reverse(__isl_take isl_basic_map *bmap);
183 __isl_give isl_basic_set *isl_basic_map_domain(__isl_take isl_basic_map *bmap);
184 __isl_give isl_basic_set *isl_basic_map_range(__isl_take isl_basic_map *bmap);
185 struct isl_basic_map *isl_basic_map_remove(struct isl_basic_map *bmap,
186 enum isl_dim_type type, unsigned first, unsigned n);
187 struct isl_basic_map *isl_basic_map_from_basic_set(struct isl_basic_set *bset,
188 struct isl_dim *dim);
189 struct isl_basic_set *isl_basic_set_from_basic_map(struct isl_basic_map *bmap);
190 __isl_give isl_basic_map *isl_basic_map_sample(__isl_take isl_basic_map *bmap);
191 struct isl_basic_map *isl_basic_map_simplify(struct isl_basic_map *bmap);
192 struct isl_basic_map *isl_basic_map_detect_equalities(
193 struct isl_basic_map *bmap);
194 __isl_give isl_basic_map *isl_basic_map_read_from_file(isl_ctx *ctx,
195 FILE *input, int nparam);
196 __isl_give isl_basic_map *isl_basic_map_read_from_str(isl_ctx *ctx,
197 const char *str, int nparam);
198 __isl_give isl_map *isl_map_read_from_file(struct isl_ctx *ctx,
199 FILE *input, int nparam);
200 __isl_give isl_map *isl_map_read_from_str(isl_ctx *ctx,
201 const char *str, int nparam);
202 void isl_basic_map_print(__isl_keep isl_basic_map *bmap, FILE *out, int indent,
203 const char *prefix, const char *suffix, unsigned output_format);
204 void isl_map_print(__isl_keep isl_map *map, FILE *out, int indent,
205 unsigned output_format);
206 __isl_give isl_printer *isl_printer_print_basic_map(
207 __isl_take isl_printer *printer, __isl_keep isl_basic_map *bmap);
208 __isl_give isl_printer *isl_printer_print_map(__isl_take isl_printer *printer,
209 __isl_keep isl_map *map);
210 struct isl_basic_map *isl_basic_map_fix_si(struct isl_basic_map *bmap,
211 enum isl_dim_type type, unsigned pos, int value);
212 __isl_give isl_basic_map *isl_basic_map_lower_bound_si(
213 __isl_take isl_basic_map *bmap,
214 enum isl_dim_type type, unsigned pos, int value);
216 struct isl_basic_map *isl_basic_map_sum(
217 struct isl_basic_map *bmap1, struct isl_basic_map *bmap2);
218 struct isl_basic_map *isl_basic_map_neg(struct isl_basic_map *bmap);
219 struct isl_basic_map *isl_basic_map_floordiv(struct isl_basic_map *bmap,
222 struct isl_map *isl_map_sum(struct isl_map *map1, struct isl_map *map2);
223 struct isl_map *isl_map_neg(struct isl_map *map);
224 struct isl_map *isl_map_floordiv(struct isl_map *map, isl_int d);
226 int isl_basic_map_is_equal(
227 __isl_keep isl_basic_map *bmap1,
228 __isl_keep isl_basic_map *bmap2);
230 __isl_give isl_map *isl_basic_map_partial_lexmax(
231 __isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
232 __isl_give isl_set **empty);
233 __isl_give isl_map *isl_basic_map_partial_lexmin(
234 __isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
235 __isl_give isl_set **empty);
236 __isl_give isl_map *isl_map_partial_lexmax(
237 __isl_take isl_map *map, __isl_take isl_set *dom,
238 __isl_give isl_set **empty);
239 __isl_give isl_map *isl_map_partial_lexmin(
240 __isl_take isl_map *map, __isl_take isl_set *dom,
241 __isl_give isl_set **empty);
242 __isl_give isl_map *isl_basic_map_lexmin(__isl_take isl_basic_map *bmap);
243 __isl_give isl_map *isl_basic_map_lexmax(__isl_take isl_basic_map *bmap);
244 __isl_give isl_map *isl_map_lexmin(__isl_take isl_map *map);
245 __isl_give isl_map *isl_map_lexmax(__isl_take isl_map *map);
246 int isl_basic_map_foreach_lexmin(__isl_keep isl_basic_map *bmap,
247 int (*fn)(__isl_take isl_basic_set *dom, __isl_take isl_mat *map,
251 void isl_basic_map_dump(__isl_keep isl_basic_map *bmap, FILE *out, int indent);
253 struct isl_basic_map *isl_map_copy_basic_map(struct isl_map *map);
254 __isl_give isl_map *isl_map_drop_basic_map(__isl_take isl_map *map,
255 __isl_keep isl_basic_map *bmap);
257 int isl_basic_map_fast_is_fixed(struct isl_basic_map *bmap,
258 enum isl_dim_type type, unsigned pos, isl_int *val);
260 int isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
261 int isl_basic_map_fast_is_empty(__isl_keep isl_basic_map *bmap);
262 int isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap);
263 int isl_basic_map_is_subset(__isl_keep isl_basic_map *bmap1,
264 __isl_keep isl_basic_map *bmap2);
265 int isl_basic_map_is_strict_subset(__isl_keep isl_basic_map *bmap1,
266 __isl_keep isl_basic_map *bmap2);
268 struct isl_map *isl_map_alloc(struct isl_ctx *ctx,
269 unsigned nparam, unsigned in, unsigned out, int n,
271 __isl_give isl_map *isl_map_universe(__isl_take isl_dim *dim);
272 __isl_give isl_map *isl_map_empty(__isl_take isl_dim *dim);
273 struct isl_map *isl_map_empty_like(struct isl_map *model);
274 struct isl_map *isl_map_empty_like_basic_map(struct isl_basic_map *model);
275 struct isl_map *isl_map_dup(struct isl_map *map);
276 __isl_give isl_map *isl_map_add_basic_map(__isl_take isl_map *map,
277 __isl_take isl_basic_map *bmap);
278 __isl_give isl_map *isl_map_identity(__isl_take isl_dim *set_dim);
279 struct isl_map *isl_map_identity_like(struct isl_map *model);
280 struct isl_map *isl_map_identity_like_basic_map(struct isl_basic_map *model);
281 __isl_give isl_map *isl_map_lex_lt_first(__isl_take isl_dim *dim, unsigned n);
282 __isl_give isl_map *isl_map_lex_le_first(__isl_take isl_dim *dim, unsigned n);
283 __isl_give isl_map *isl_map_lex_lt(__isl_take isl_dim *set_dim);
284 __isl_give isl_map *isl_map_lex_le(__isl_take isl_dim *set_dim);
285 __isl_give isl_map *isl_map_lex_gt_first(__isl_take isl_dim *dim, unsigned n);
286 __isl_give isl_map *isl_map_lex_ge_first(__isl_take isl_dim *dim, unsigned n);
287 __isl_give isl_map *isl_map_lex_gt(__isl_take isl_dim *set_dim);
288 __isl_give isl_map *isl_map_lex_ge(__isl_take isl_dim *set_dim);
289 struct isl_map *isl_map_finalize(struct isl_map *map);
290 void isl_map_free(__isl_take isl_map *map);
291 __isl_give isl_map *isl_map_copy(__isl_keep isl_map *map);
292 struct isl_map *isl_map_extend(struct isl_map *base,
293 unsigned nparam, unsigned n_in, unsigned n_out);
294 __isl_give isl_map *isl_map_reverse(__isl_take isl_map *map);
295 __isl_give isl_map *isl_map_union(
296 __isl_take isl_map *map1,
297 __isl_take isl_map *map2);
298 struct isl_map *isl_map_union_disjoint(
299 struct isl_map *map1, struct isl_map *map2);
300 __isl_give isl_map *isl_map_intersect_domain(
301 __isl_take isl_map *map,
302 __isl_take isl_set *set);
303 __isl_give isl_map *isl_map_intersect_range(
304 __isl_take isl_map *map,
305 __isl_take isl_set *set);
306 __isl_give isl_map *isl_map_apply_domain(
307 __isl_take isl_map *map1,
308 __isl_take isl_map *map2);
309 __isl_give isl_map *isl_map_apply_range(
310 __isl_take isl_map *map1,
311 __isl_take isl_map *map2);
312 struct isl_map *isl_map_product(struct isl_map *map1, struct isl_map *map2);
313 __isl_give isl_map *isl_map_intersect(__isl_take isl_map *map1,
314 __isl_take isl_map *map2);
315 __isl_give isl_map *isl_map_subtract(
316 __isl_take isl_map *map1,
317 __isl_take isl_map *map2);
318 struct isl_map *isl_map_fix_input_si(struct isl_map *map,
319 unsigned input, int value);
320 struct isl_map *isl_map_fix_si(struct isl_map *map,
321 enum isl_dim_type type, unsigned pos, int value);
322 __isl_give isl_map *isl_map_lower_bound_si(__isl_take isl_map *map,
323 enum isl_dim_type type, unsigned pos, int value);
324 __isl_give isl_basic_set *isl_basic_map_deltas(__isl_take isl_basic_map *bmap);
325 __isl_give isl_set *isl_map_deltas(__isl_take isl_map *map);
326 struct isl_map *isl_map_detect_equalities(struct isl_map *map);
327 __isl_give isl_basic_map *isl_map_affine_hull(__isl_take isl_map *map);
328 __isl_give isl_basic_map *isl_map_convex_hull(__isl_take isl_map *map);
329 __isl_give isl_basic_map *isl_basic_map_add(__isl_take isl_basic_map *bmap,
330 enum isl_dim_type type, unsigned n);
331 __isl_give isl_map *isl_map_add(__isl_take isl_map *map,
332 enum isl_dim_type type, unsigned n);
333 __isl_give isl_map *isl_map_insert(__isl_take isl_map *map,
334 enum isl_dim_type type, unsigned pos, unsigned n);
335 __isl_give isl_map *isl_map_move_dims(__isl_take isl_map *map,
336 enum isl_dim_type dst_type, unsigned dst_pos,
337 enum isl_dim_type src_type, unsigned src_pos, unsigned n);
338 __isl_give isl_basic_map *isl_basic_map_project_out(
339 __isl_take isl_basic_map *bmap,
340 enum isl_dim_type type, unsigned first, unsigned n);
341 __isl_give isl_map *isl_map_project_out(__isl_take isl_map *map,
342 enum isl_dim_type type, unsigned first, unsigned n);
343 struct isl_map *isl_map_remove(struct isl_map *map,
344 enum isl_dim_type type, unsigned first, unsigned n);
345 struct isl_map *isl_map_remove_inputs(struct isl_map *map,
346 unsigned first, unsigned n);
348 __isl_give isl_set *isl_map_domain(__isl_take isl_map *bmap);
349 __isl_give isl_set *isl_map_range(__isl_take isl_map *map);
350 __isl_give isl_map *isl_map_from_basic_map(__isl_take isl_basic_map *bmap);
351 __isl_give isl_map *isl_map_from_domain(__isl_take isl_set *set);
352 struct isl_map *isl_map_from_range(struct isl_set *set);
353 __isl_give isl_map *isl_map_from_domain_and_range(__isl_take isl_set *domain,
354 __isl_take isl_set *range);
355 struct isl_map *isl_map_from_set(struct isl_set *set, struct isl_dim *dim);
356 struct isl_set *isl_set_from_map(struct isl_map *map);
357 __isl_give isl_basic_map *isl_map_sample(__isl_take isl_map *map);
359 int isl_map_fast_is_empty(__isl_keep isl_map *map);
360 int isl_map_fast_is_universe(__isl_keep isl_map *map);
361 int isl_map_is_empty(__isl_keep isl_map *map);
362 int isl_map_is_subset(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
363 int isl_map_is_strict_subset(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
364 int isl_map_is_equal(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
365 int isl_map_is_single_valued(__isl_keep isl_map *map);
367 __isl_give isl_map *isl_map_make_disjoint(__isl_take isl_map *map);
368 __isl_give isl_map *isl_basic_map_compute_divs(__isl_take isl_basic_map *bmap);
369 __isl_give isl_map *isl_map_compute_divs(__isl_take isl_map *map);
370 __isl_give isl_map *isl_map_align_divs(__isl_take isl_map *map);
372 void isl_map_dump(__isl_keep isl_map *map, FILE *out, int indent);
374 int isl_map_fast_input_is_fixed(struct isl_map *map,
375 unsigned in, isl_int *val);
376 int isl_map_fast_is_fixed(struct isl_map *map,
377 enum isl_dim_type type, unsigned pos, isl_int *val);
379 __isl_give isl_basic_map *isl_basic_map_gist(__isl_take isl_basic_map *bmap,
380 __isl_take isl_basic_map *context);
381 __isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
382 __isl_take isl_map *context);
383 __isl_give isl_map *isl_map_gist_basic_map(__isl_take isl_map *map,
384 __isl_take isl_basic_map *context);
386 __isl_give isl_map *isl_map_coalesce(__isl_take isl_map *map);
388 int isl_map_fast_is_equal(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
390 int isl_map_foreach_basic_map(__isl_keep isl_map *map,
391 int (*fn)(__isl_take isl_basic_map *bmap, void *user), void *user);
393 __isl_give isl_map *isl_set_lifting(__isl_take isl_set *set);
395 __isl_give isl_map *isl_map_power(__isl_take isl_map *map, unsigned param,
397 __isl_give isl_map *isl_map_transitive_closure(__isl_take isl_map *map,
400 #if defined(__cplusplus)