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 struct isl_basic_map
*isl_basic_map_alloc(struct isl_ctx
*ctx
,
129 unsigned nparam
, unsigned in
, unsigned out
, unsigned extra
,
130 unsigned n_eq
, unsigned n_ineq
);
131 __isl_give isl_basic_map
*isl_basic_map_identity(__isl_take isl_dim
*set_dim
);
132 struct isl_basic_map
*isl_basic_map_identity_like(struct isl_basic_map
*model
);
133 struct isl_basic_map
*isl_basic_map_finalize(struct isl_basic_map
*bmap
);
134 void isl_basic_map_free(__isl_take isl_basic_map
*bmap
);
135 __isl_give isl_basic_map
*isl_basic_map_copy(__isl_keep isl_basic_map
*bmap
);
136 struct isl_basic_map
*isl_basic_map_extend(struct isl_basic_map
*base
,
137 unsigned nparam
, unsigned n_in
, unsigned n_out
, unsigned extra
,
138 unsigned n_eq
, unsigned n_ineq
);
139 struct isl_basic_map
*isl_basic_map_extend_constraints(
140 struct isl_basic_map
*base
, unsigned n_eq
, unsigned n_ineq
);
141 struct isl_basic_map
*isl_basic_map_equal(
142 struct isl_dim
*dim
, unsigned n_equal
);
143 struct isl_basic_map
*isl_basic_map_less_at(struct isl_dim
*dim
, unsigned pos
);
144 struct isl_basic_map
*isl_basic_map_more_at(struct isl_dim
*dim
, unsigned pos
);
145 __isl_give isl_basic_map
*isl_basic_map_empty(__isl_take isl_dim
*dim
);
146 struct isl_basic_map
*isl_basic_map_empty_like(struct isl_basic_map
*model
);
147 struct isl_basic_map
*isl_basic_map_empty_like_map(struct isl_map
*model
);
148 __isl_give isl_basic_map
*isl_basic_map_universe(__isl_take isl_dim
*dim
);
149 __isl_give isl_basic_map
*isl_basic_map_universe_like(
150 __isl_keep isl_basic_map
*bmap
);
151 struct isl_basic_map
*isl_basic_map_convex_hull(struct isl_basic_map
*bmap
);
152 __isl_give isl_basic_map
*isl_map_simple_hull(__isl_take isl_map
*map
);
154 __isl_give isl_basic_map
*isl_basic_map_intersect_domain(
155 __isl_take isl_basic_map
*bmap
,
156 __isl_take isl_basic_set
*bset
);
157 __isl_give isl_basic_map
*isl_basic_map_intersect_range(
158 __isl_take isl_basic_map
*bmap
,
159 __isl_take isl_basic_set
*bset
);
160 __isl_give isl_basic_map
*isl_basic_map_intersect(
161 __isl_take isl_basic_map
*bmap1
,
162 __isl_take isl_basic_map
*bmap2
);
163 __isl_give isl_map
*isl_basic_map_union(
164 __isl_take isl_basic_map
*bmap1
,
165 __isl_take isl_basic_map
*bmap2
);
166 __isl_give isl_basic_map
*isl_basic_map_apply_domain(
167 __isl_take isl_basic_map
*bmap1
,
168 __isl_take isl_basic_map
*bmap2
);
169 __isl_give isl_basic_map
*isl_basic_map_apply_range(
170 __isl_take isl_basic_map
*bmap1
,
171 __isl_take isl_basic_map
*bmap2
);
172 __isl_give isl_basic_map
*isl_basic_map_affine_hull(
173 __isl_take isl_basic_map
*bmap
);
174 __isl_give isl_basic_map
*isl_basic_map_reverse(__isl_take isl_basic_map
*bmap
);
175 __isl_give isl_basic_set
*isl_basic_map_domain(__isl_take isl_basic_map
*bmap
);
176 __isl_give isl_basic_set
*isl_basic_map_range(__isl_take isl_basic_map
*bmap
);
177 struct isl_basic_map
*isl_basic_map_remove(struct isl_basic_map
*bmap
,
178 enum isl_dim_type type
, unsigned first
, unsigned n
);
179 struct isl_basic_map
*isl_basic_map_from_basic_set(struct isl_basic_set
*bset
,
180 struct isl_dim
*dim
);
181 struct isl_basic_set
*isl_basic_set_from_basic_map(struct isl_basic_map
*bmap
);
182 __isl_give isl_basic_map
*isl_basic_map_sample(__isl_take isl_basic_map
*bmap
);
183 struct isl_basic_map
*isl_basic_map_simplify(struct isl_basic_map
*bmap
);
184 struct isl_basic_map
*isl_basic_map_detect_equalities(
185 struct isl_basic_map
*bmap
);
186 __isl_give isl_basic_map
*isl_basic_map_read_from_file(isl_ctx
*ctx
,
187 FILE *input
, int nparam
);
188 __isl_give isl_basic_map
*isl_basic_map_read_from_str(isl_ctx
*ctx
,
189 const char *str
, int nparam
);
190 __isl_give isl_map
*isl_map_read_from_file(struct isl_ctx
*ctx
,
191 FILE *input
, int nparam
);
192 __isl_give isl_map
*isl_map_read_from_str(isl_ctx
*ctx
,
193 const char *str
, int nparam
);
194 void isl_basic_map_print(__isl_keep isl_basic_map
*bmap
, FILE *out
, int indent
,
195 const char *prefix
, const char *suffix
, unsigned output_format
);
196 void isl_map_print(__isl_keep isl_map
*map
, FILE *out
, int indent
,
197 unsigned output_format
);
198 __isl_give isl_printer
*isl_printer_print_basic_map(
199 __isl_take isl_printer
*printer
, __isl_keep isl_basic_map
*bmap
);
200 __isl_give isl_printer
*isl_printer_print_map(__isl_take isl_printer
*printer
,
201 __isl_keep isl_map
*map
);
202 struct isl_basic_map
*isl_basic_map_fix_si(struct isl_basic_map
*bmap
,
203 enum isl_dim_type type
, unsigned pos
, int value
);
204 __isl_give isl_basic_map
*isl_basic_map_lower_bound_si(
205 __isl_take isl_basic_map
*bmap
,
206 enum isl_dim_type type
, unsigned pos
, int value
);
208 struct isl_basic_map
*isl_basic_map_sum(
209 struct isl_basic_map
*bmap1
, struct isl_basic_map
*bmap2
);
210 struct isl_basic_map
*isl_basic_map_neg(struct isl_basic_map
*bmap
);
211 struct isl_basic_map
*isl_basic_map_floordiv(struct isl_basic_map
*bmap
,
214 struct isl_map
*isl_map_sum(struct isl_map
*map1
, struct isl_map
*map2
);
215 struct isl_map
*isl_map_neg(struct isl_map
*map
);
216 struct isl_map
*isl_map_floordiv(struct isl_map
*map
, isl_int d
);
218 int isl_basic_map_is_equal(
219 __isl_keep isl_basic_map
*bmap1
,
220 __isl_keep isl_basic_map
*bmap2
);
222 __isl_give isl_map
*isl_basic_map_partial_lexmax(
223 __isl_take isl_basic_map
*bmap
, __isl_take isl_basic_set
*dom
,
224 __isl_give isl_set
**empty
);
225 __isl_give isl_map
*isl_basic_map_partial_lexmin(
226 __isl_take isl_basic_map
*bmap
, __isl_take isl_basic_set
*dom
,
227 __isl_give isl_set
**empty
);
228 __isl_give isl_map
*isl_map_partial_lexmax(
229 __isl_take isl_map
*map
, __isl_take isl_set
*dom
,
230 __isl_give isl_set
**empty
);
231 __isl_give isl_map
*isl_map_partial_lexmin(
232 __isl_take isl_map
*map
, __isl_take isl_set
*dom
,
233 __isl_give isl_set
**empty
);
234 __isl_give isl_map
*isl_basic_map_lexmin(__isl_take isl_basic_map
*bmap
);
235 __isl_give isl_map
*isl_basic_map_lexmax(__isl_take isl_basic_map
*bmap
);
236 __isl_give isl_map
*isl_map_lexmin(__isl_take isl_map
*map
);
237 __isl_give isl_map
*isl_map_lexmax(__isl_take isl_map
*map
);
238 int isl_basic_map_foreach_lexmin(__isl_keep isl_basic_map
*bmap
,
239 int (*fn
)(__isl_take isl_basic_set
*dom
, __isl_take isl_mat
*map
,
243 void isl_basic_map_dump(__isl_keep isl_basic_map
*bmap
, FILE *out
, int indent
);
245 struct isl_basic_map
*isl_map_copy_basic_map(struct isl_map
*map
);
246 __isl_give isl_map
*isl_map_drop_basic_map(__isl_take isl_map
*map
,
247 __isl_keep isl_basic_map
*bmap
);
249 int isl_basic_map_fast_is_fixed(struct isl_basic_map
*bmap
,
250 enum isl_dim_type type
, unsigned pos
, isl_int
*val
);
252 int isl_basic_map_is_universe(__isl_keep isl_basic_map
*bmap
);
253 int isl_basic_map_fast_is_empty(__isl_keep isl_basic_map
*bmap
);
254 int isl_basic_map_is_empty(__isl_keep isl_basic_map
*bmap
);
255 int isl_basic_map_is_subset(__isl_keep isl_basic_map
*bmap1
,
256 __isl_keep isl_basic_map
*bmap2
);
257 int isl_basic_map_is_strict_subset(__isl_keep isl_basic_map
*bmap1
,
258 __isl_keep isl_basic_map
*bmap2
);
260 struct isl_map
*isl_map_alloc(struct isl_ctx
*ctx
,
261 unsigned nparam
, unsigned in
, unsigned out
, int n
,
263 __isl_give isl_map
*isl_map_universe(__isl_take isl_dim
*dim
);
264 __isl_give isl_map
*isl_map_empty(__isl_take isl_dim
*dim
);
265 struct isl_map
*isl_map_empty_like(struct isl_map
*model
);
266 struct isl_map
*isl_map_empty_like_basic_map(struct isl_basic_map
*model
);
267 struct isl_map
*isl_map_dup(struct isl_map
*map
);
268 __isl_give isl_map
*isl_map_add_basic_map(__isl_take isl_map
*map
,
269 __isl_take isl_basic_map
*bmap
);
270 __isl_give isl_map
*isl_map_identity(__isl_take isl_dim
*set_dim
);
271 struct isl_map
*isl_map_identity_like(struct isl_map
*model
);
272 struct isl_map
*isl_map_identity_like_basic_map(struct isl_basic_map
*model
);
273 __isl_give isl_map
*isl_map_lex_lt_first(__isl_take isl_dim
*dim
, unsigned n
);
274 __isl_give isl_map
*isl_map_lex_le_first(__isl_take isl_dim
*dim
, unsigned n
);
275 __isl_give isl_map
*isl_map_lex_lt(__isl_take isl_dim
*set_dim
);
276 __isl_give isl_map
*isl_map_lex_le(__isl_take isl_dim
*set_dim
);
277 __isl_give isl_map
*isl_map_lex_gt_first(__isl_take isl_dim
*dim
, unsigned n
);
278 __isl_give isl_map
*isl_map_lex_ge_first(__isl_take isl_dim
*dim
, unsigned n
);
279 __isl_give isl_map
*isl_map_lex_gt(__isl_take isl_dim
*set_dim
);
280 __isl_give isl_map
*isl_map_lex_ge(__isl_take isl_dim
*set_dim
);
281 struct isl_map
*isl_map_finalize(struct isl_map
*map
);
282 void isl_map_free(__isl_take isl_map
*map
);
283 __isl_give isl_map
*isl_map_copy(__isl_keep isl_map
*map
);
284 struct isl_map
*isl_map_extend(struct isl_map
*base
,
285 unsigned nparam
, unsigned n_in
, unsigned n_out
);
286 __isl_give isl_map
*isl_map_reverse(__isl_take isl_map
*map
);
287 __isl_give isl_map
*isl_map_union(
288 __isl_take isl_map
*map1
,
289 __isl_take isl_map
*map2
);
290 struct isl_map
*isl_map_union_disjoint(
291 struct isl_map
*map1
, struct isl_map
*map2
);
292 __isl_give isl_map
*isl_map_intersect_domain(
293 __isl_take isl_map
*map
,
294 __isl_take isl_set
*set
);
295 __isl_give isl_map
*isl_map_intersect_range(
296 __isl_take isl_map
*map
,
297 __isl_take isl_set
*set
);
298 __isl_give isl_map
*isl_map_apply_domain(
299 __isl_take isl_map
*map1
,
300 __isl_take isl_map
*map2
);
301 __isl_give isl_map
*isl_map_apply_range(
302 __isl_take isl_map
*map1
,
303 __isl_take isl_map
*map2
);
304 struct isl_map
*isl_map_product(struct isl_map
*map1
, struct isl_map
*map2
);
305 __isl_give isl_map
*isl_map_intersect(__isl_take isl_map
*map1
,
306 __isl_take isl_map
*map2
);
307 __isl_give isl_map
*isl_map_subtract(
308 __isl_take isl_map
*map1
,
309 __isl_take isl_map
*map2
);
310 struct isl_map
*isl_map_fix_input_si(struct isl_map
*map
,
311 unsigned input
, int value
);
312 struct isl_map
*isl_map_fix_si(struct isl_map
*map
,
313 enum isl_dim_type type
, unsigned pos
, int value
);
314 __isl_give isl_map
*isl_map_lower_bound_si(__isl_take isl_map
*map
,
315 enum isl_dim_type type
, unsigned pos
, int value
);
316 struct isl_basic_set
*isl_basic_map_deltas(struct isl_basic_map
*bmap
);
317 struct isl_set
*isl_map_deltas(struct isl_map
*map
);
318 struct isl_map
*isl_map_detect_equalities(struct isl_map
*map
);
319 __isl_give isl_basic_map
*isl_map_affine_hull(__isl_take isl_map
*map
);
320 __isl_give isl_basic_map
*isl_map_convex_hull(__isl_take isl_map
*map
);
321 __isl_give isl_basic_map
*isl_basic_map_add(__isl_take isl_basic_map
*bmap
,
322 enum isl_dim_type type
, unsigned n
);
323 __isl_give isl_map
*isl_map_add(__isl_take isl_map
*map
,
324 enum isl_dim_type type
, unsigned n
);
325 __isl_give isl_map
*isl_map_insert(__isl_take isl_map
*map
,
326 enum isl_dim_type type
, unsigned pos
, unsigned n
);
327 __isl_give isl_map
*isl_map_move_dims(__isl_take isl_map
*map
,
328 enum isl_dim_type dst_type
, unsigned dst_pos
,
329 enum isl_dim_type src_type
, unsigned src_pos
, unsigned n
);
330 __isl_give isl_basic_map
*isl_basic_map_project_out(
331 __isl_take isl_basic_map
*bmap
,
332 enum isl_dim_type type
, unsigned first
, unsigned n
);
333 __isl_give isl_map
*isl_map_project_out(__isl_take isl_map
*map
,
334 enum isl_dim_type type
, unsigned first
, unsigned n
);
335 struct isl_map
*isl_map_remove(struct isl_map
*map
,
336 enum isl_dim_type type
, unsigned first
, unsigned n
);
337 struct isl_map
*isl_map_remove_inputs(struct isl_map
*map
,
338 unsigned first
, unsigned n
);
340 __isl_give isl_set
*isl_map_domain(__isl_take isl_map
*bmap
);
341 __isl_give isl_set
*isl_map_range(__isl_take isl_map
*map
);
342 __isl_give isl_map
*isl_map_from_basic_map(__isl_take isl_basic_map
*bmap
);
343 __isl_give isl_map
*isl_map_from_domain(__isl_take isl_set
*set
);
344 struct isl_map
*isl_map_from_range(struct isl_set
*set
);
345 __isl_give isl_map
*isl_map_from_domain_and_range(__isl_take isl_set
*domain
,
346 __isl_take isl_set
*range
);
347 struct isl_map
*isl_map_from_set(struct isl_set
*set
, struct isl_dim
*dim
);
348 struct isl_set
*isl_set_from_map(struct isl_map
*map
);
349 __isl_give isl_basic_map
*isl_map_sample(__isl_take isl_map
*map
);
351 int isl_map_fast_is_empty(__isl_keep isl_map
*map
);
352 int isl_map_fast_is_universe(__isl_keep isl_map
*map
);
353 int isl_map_is_empty(__isl_keep isl_map
*map
);
354 int isl_map_is_subset(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
355 int isl_map_is_strict_subset(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
356 int isl_map_is_equal(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
357 int isl_map_is_single_valued(__isl_keep isl_map
*map
);
359 __isl_give isl_map
*isl_map_make_disjoint(__isl_take isl_map
*map
);
360 __isl_give isl_map
*isl_basic_map_compute_divs(__isl_take isl_basic_map
*bmap
);
361 __isl_give isl_map
*isl_map_compute_divs(__isl_take isl_map
*map
);
362 __isl_give isl_map
*isl_map_align_divs(__isl_take isl_map
*map
);
364 void isl_map_dump(__isl_keep isl_map
*map
, FILE *out
, int indent
);
366 int isl_map_fast_input_is_fixed(struct isl_map
*map
,
367 unsigned in
, isl_int
*val
);
368 int isl_map_fast_is_fixed(struct isl_map
*map
,
369 enum isl_dim_type type
, unsigned pos
, isl_int
*val
);
371 __isl_give isl_basic_map
*isl_basic_map_gist(__isl_take isl_basic_map
*bmap
,
372 __isl_take isl_basic_map
*context
);
373 __isl_give isl_map
*isl_map_gist(__isl_take isl_map
*map
,
374 __isl_take isl_map
*context
);
375 __isl_give isl_map
*isl_map_gist_basic_map(__isl_take isl_map
*map
,
376 __isl_take isl_basic_map
*context
);
378 __isl_give isl_map
*isl_map_coalesce(__isl_take isl_map
*map
);
380 int isl_map_fast_is_equal(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
382 int isl_map_foreach_basic_map(__isl_keep isl_map
*map
,
383 int (*fn
)(__isl_take isl_basic_map
*bmap
, void *user
), void *user
);
385 __isl_give isl_map
*isl_set_lifting(__isl_take isl_set
*set
);
387 __isl_give isl_map
*isl_map_power(__isl_take isl_map
*map
, unsigned param
,
389 __isl_give isl_map
*isl_map_transitive_closure(__isl_take isl_map
*map
,
392 #if defined(__cplusplus)