isl_ast_codegen.c: create_node_scaled: hoist inclusion of stride guard
[isl.git] / isl_map_private.h
blobff71b2ca8751a18858ef9b4ca1d5bef43a45ce40
1 /*
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
8 */
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
17 #include <isl/list.h>
18 ISL_DECLARE_LIST(basic_map)
19 ISL_DECLARE_LIST(map)
20 #include <isl/set.h>
21 #include <isl/map.h>
22 #include <isl_reordering.h>
23 #include <isl/vec.h>
24 #include <isl_blk.h>
26 /* A "basic map" is a relation between two sets of variables,
27 * called the "in" and "out" variables.
28 * A "basic set" is a basic map with a zero-dimensional
29 * domain.
31 * It is implemented as a set with two extra fields:
32 * n_in is the number of in variables
33 * n_out is the number of out variables
34 * n_in + n_out should be equal to set.dim
36 struct isl_basic_map {
37 int ref;
38 #define ISL_BASIC_MAP_FINAL (1 << 0)
39 #define ISL_BASIC_MAP_EMPTY (1 << 1)
40 #define ISL_BASIC_MAP_NO_IMPLICIT (1 << 2)
41 #define ISL_BASIC_MAP_NO_REDUNDANT (1 << 3)
42 #define ISL_BASIC_MAP_RATIONAL (1 << 4)
43 #define ISL_BASIC_MAP_NORMALIZED (1 << 5)
44 #define ISL_BASIC_MAP_NORMALIZED_DIVS (1 << 6)
45 #define ISL_BASIC_MAP_ALL_EQUALITIES (1 << 7)
46 #define ISL_BASIC_SET_FINAL (1 << 0)
47 #define ISL_BASIC_SET_EMPTY (1 << 1)
48 #define ISL_BASIC_SET_NO_IMPLICIT (1 << 2)
49 #define ISL_BASIC_SET_NO_REDUNDANT (1 << 3)
50 #define ISL_BASIC_SET_RATIONAL (1 << 4)
51 #define ISL_BASIC_SET_NORMALIZED (1 << 5)
52 #define ISL_BASIC_SET_NORMALIZED_DIVS (1 << 6)
53 #define ISL_BASIC_SET_ALL_EQUALITIES (1 << 7)
54 unsigned flags;
56 struct isl_ctx *ctx;
58 isl_space *dim;
59 unsigned extra;
61 unsigned n_eq;
62 unsigned n_ineq;
64 size_t c_size;
65 isl_int **eq;
66 isl_int **ineq;
68 unsigned n_div;
70 isl_int **div;
72 struct isl_vec *sample;
74 struct isl_blk block;
75 struct isl_blk block2;
78 #undef EL
79 #define EL isl_basic_set
81 #include <isl_list_templ.h>
83 /* A "map" is a (possibly disjoint) union of basic maps.
84 * A "set" is a (possibly disjoint) union of basic sets.
86 * Currently, the isl_set structure is identical to the isl_map structure
87 * and the library depends on this correspondence internally.
88 * However, users should not depend on this correspondence.
90 struct isl_map {
91 int ref;
92 #define ISL_MAP_DISJOINT (1 << 0)
93 #define ISL_MAP_NORMALIZED (1 << 1)
94 #define ISL_SET_DISJOINT (1 << 0)
95 #define ISL_SET_NORMALIZED (1 << 1)
96 unsigned flags;
98 struct isl_ctx *ctx;
100 isl_space *dim;
102 int n;
104 size_t size;
105 struct isl_basic_map *p[1];
108 #undef EL
109 #define EL isl_set
111 #include <isl_list_templ.h>
113 __isl_give isl_map *isl_map_realign(__isl_take isl_map *map,
114 __isl_take isl_reordering *r);
115 __isl_give isl_set *isl_set_realign(__isl_take isl_set *set,
116 __isl_take isl_reordering *r);
118 __isl_give isl_map *isl_map_reset(__isl_take isl_map *map,
119 enum isl_dim_type type);
121 __isl_give isl_basic_set *isl_basic_set_reset_space(
122 __isl_take isl_basic_set *bset, __isl_take isl_space *dim);
123 __isl_give isl_basic_map *isl_basic_map_reset_space(
124 __isl_take isl_basic_map *bmap, __isl_take isl_space *dim);
125 __isl_give isl_map *isl_map_reset_space(__isl_take isl_map *map,
126 __isl_take isl_space *dim);
128 unsigned isl_basic_map_offset(struct isl_basic_map *bmap,
129 enum isl_dim_type type);
130 unsigned isl_basic_set_offset(struct isl_basic_set *bset,
131 enum isl_dim_type type);
133 int isl_basic_map_may_be_set(__isl_keep isl_basic_map *bmap);
134 int isl_map_may_be_set(__isl_keep isl_map *map);
135 int isl_map_compatible_domain(struct isl_map *map, struct isl_set *set);
136 int isl_basic_map_compatible_domain(struct isl_basic_map *bmap,
137 struct isl_basic_set *bset);
138 int isl_basic_map_compatible_range(struct isl_basic_map *bmap,
139 struct isl_basic_set *bset);
141 struct isl_basic_map *isl_basic_map_extend_space(struct isl_basic_map *base,
142 __isl_take isl_space *dim, unsigned extra,
143 unsigned n_eq, unsigned n_ineq);
144 struct isl_basic_set *isl_basic_set_extend_space(struct isl_basic_set *base,
145 __isl_take isl_space *dim, unsigned extra,
146 unsigned n_eq, unsigned n_ineq);
147 struct isl_basic_set *isl_basic_set_add_constraints(struct isl_basic_set *bset1,
148 struct isl_basic_set *bset2, unsigned pos);
150 struct isl_map *isl_map_grow(struct isl_map *map, int n);
151 struct isl_set *isl_set_grow(struct isl_set *set, int n);
153 int isl_basic_set_contains(struct isl_basic_set *bset, struct isl_vec *vec);
154 int isl_basic_map_contains(struct isl_basic_map *bmap, struct isl_vec *vec);
156 __isl_give isl_basic_set *isl_basic_set_alloc_space(__isl_take isl_space *dim,
157 unsigned extra, unsigned n_eq, unsigned n_ineq);
158 __isl_give isl_set *isl_set_alloc_space(__isl_take isl_space *dim, int n,
159 unsigned flags);
160 __isl_give isl_basic_map *isl_basic_map_alloc_space(__isl_take isl_space *dim,
161 unsigned extra, unsigned n_eq, unsigned n_ineq);
162 __isl_give isl_map *isl_map_alloc_space(__isl_take isl_space *dim, int n,
163 unsigned flags);
165 unsigned isl_basic_map_total_dim(const struct isl_basic_map *bmap);
167 int isl_basic_map_alloc_equality(struct isl_basic_map *bmap);
168 int isl_basic_set_alloc_equality(struct isl_basic_set *bset);
169 int isl_basic_set_free_inequality(struct isl_basic_set *bset, unsigned n);
170 int isl_basic_map_free_equality(struct isl_basic_map *bmap, unsigned n);
171 int isl_basic_set_free_equality(struct isl_basic_set *bset, unsigned n);
172 int isl_basic_set_alloc_inequality(struct isl_basic_set *bset);
173 int isl_basic_map_alloc_inequality(struct isl_basic_map *bmap);
174 int isl_basic_map_free_inequality(struct isl_basic_map *bmap, unsigned n);
175 int isl_basic_map_alloc_div(struct isl_basic_map *bmap);
176 int isl_basic_set_alloc_div(struct isl_basic_set *bset);
177 int isl_basic_map_free_div(struct isl_basic_map *bmap, unsigned n);
178 int isl_basic_set_free_div(struct isl_basic_set *bset, unsigned n);
179 void isl_basic_map_inequality_to_equality(
180 struct isl_basic_map *bmap, unsigned pos);
181 int isl_basic_map_drop_equality(struct isl_basic_map *bmap, unsigned pos);
182 int isl_basic_set_drop_equality(struct isl_basic_set *bset, unsigned pos);
183 int isl_basic_set_drop_inequality(struct isl_basic_set *bset, unsigned pos);
184 int isl_basic_map_drop_inequality(struct isl_basic_map *bmap, unsigned pos);
185 __isl_give isl_basic_set *isl_basic_set_add_eq(__isl_take isl_basic_set *bset,
186 isl_int *eq);
187 __isl_give isl_basic_map *isl_basic_map_add_eq(__isl_take isl_basic_map *bmap,
188 isl_int *eq);
189 __isl_give isl_basic_set *isl_basic_set_add_ineq(__isl_take isl_basic_set *bset,
190 isl_int *ineq);
191 __isl_give isl_basic_map *isl_basic_map_add_ineq(__isl_take isl_basic_map *bmap,
192 isl_int *ineq);
194 int isl_inequality_negate(struct isl_basic_map *bmap, unsigned pos);
196 struct isl_basic_set *isl_basic_set_cow(struct isl_basic_set *bset);
197 struct isl_basic_map *isl_basic_map_cow(struct isl_basic_map *bmap);
198 struct isl_set *isl_set_cow(struct isl_set *set);
199 struct isl_map *isl_map_cow(struct isl_map *map);
201 struct isl_basic_map *isl_basic_map_set_to_empty(struct isl_basic_map *bmap);
202 struct isl_basic_set *isl_basic_set_set_to_empty(struct isl_basic_set *bset);
203 struct isl_basic_set *isl_basic_set_order_divs(struct isl_basic_set *bset);
204 void isl_basic_map_swap_div(struct isl_basic_map *bmap, int a, int b);
205 struct isl_basic_map *isl_basic_map_order_divs(struct isl_basic_map *bmap);
206 __isl_give isl_map *isl_map_order_divs(__isl_take isl_map *map);
207 struct isl_basic_map *isl_basic_map_align_divs(
208 struct isl_basic_map *dst, struct isl_basic_map *src);
209 struct isl_basic_set *isl_basic_set_align_divs(
210 struct isl_basic_set *dst, struct isl_basic_set *src);
211 __isl_give isl_set *isl_set_align_divs_to_basic_set_list(
212 __isl_take isl_set *set, __isl_keep isl_basic_set_list *list);
213 __isl_give isl_basic_set_list *isl_basic_set_list_align_divs_to_basic_set(
214 __isl_take isl_basic_set_list *list, __isl_keep isl_basic_set *bset);
215 __isl_give isl_basic_map *isl_basic_map_sort_divs(
216 __isl_take isl_basic_map *bmap);
217 __isl_give isl_map *isl_map_sort_divs(__isl_take isl_map *map);
218 struct isl_basic_map *isl_basic_map_gauss(
219 struct isl_basic_map *bmap, int *progress);
220 struct isl_basic_set *isl_basic_set_gauss(
221 struct isl_basic_set *bset, int *progress);
222 __isl_give isl_basic_set *isl_basic_set_sort_constraints(
223 __isl_take isl_basic_set *bset);
224 int isl_basic_map_plain_cmp(const __isl_keep isl_basic_map *bmap1,
225 const __isl_keep isl_basic_map *bmap2);
226 int isl_basic_map_plain_is_equal(__isl_keep isl_basic_map *bmap1,
227 __isl_keep isl_basic_map *bmap2);
228 struct isl_basic_map *isl_basic_map_normalize_constraints(
229 struct isl_basic_map *bmap);
230 struct isl_basic_set *isl_basic_set_normalize_constraints(
231 struct isl_basic_set *bset);
232 struct isl_basic_map *isl_basic_map_implicit_equalities(
233 struct isl_basic_map *bmap);
234 struct isl_basic_set *isl_basic_map_underlying_set(struct isl_basic_map *bmap);
235 __isl_give isl_basic_set *isl_basic_set_underlying_set(
236 __isl_take isl_basic_set *bset);
237 __isl_give isl_basic_set_list *isl_basic_set_list_underlying_set(
238 __isl_take isl_basic_set_list *list);
239 struct isl_set *isl_map_underlying_set(struct isl_map *map);
240 struct isl_basic_map *isl_basic_map_overlying_set(struct isl_basic_set *bset,
241 struct isl_basic_map *like);
242 __isl_give isl_basic_set *isl_basic_set_drop_constraints_involving(
243 __isl_take isl_basic_set *bset, unsigned first, unsigned n);
244 __isl_give isl_basic_set *isl_basic_set_drop(__isl_take isl_basic_set *bset,
245 enum isl_dim_type type, unsigned first, unsigned n);
246 struct isl_basic_map *isl_basic_map_drop(struct isl_basic_map *bmap,
247 enum isl_dim_type type, unsigned first, unsigned n);
248 struct isl_set *isl_set_drop(struct isl_set *set,
249 enum isl_dim_type type, unsigned first, unsigned n);
250 struct isl_basic_set *isl_basic_set_drop_dims(
251 struct isl_basic_set *bset, unsigned first, unsigned n);
252 struct isl_set *isl_set_drop_dims(
253 struct isl_set *set, unsigned first, unsigned n);
254 struct isl_map *isl_map_drop_inputs(
255 struct isl_map *map, unsigned first, unsigned n);
256 struct isl_map *isl_map_drop(struct isl_map *map,
257 enum isl_dim_type type, unsigned first, unsigned n);
259 __isl_give isl_basic_map *isl_basic_map_remove_duplicate_constraints(
260 __isl_take isl_basic_map *bmap, int *progress, int detect_divs);
262 struct isl_map *isl_map_remove_empty_parts(struct isl_map *map);
263 struct isl_set *isl_set_remove_empty_parts(struct isl_set *set);
265 struct isl_set *isl_set_normalize(struct isl_set *set);
267 struct isl_set *isl_set_drop_vars(
268 struct isl_set *set, unsigned first, unsigned n);
270 struct isl_basic_map *isl_basic_map_eliminate_vars(
271 struct isl_basic_map *bmap, unsigned pos, unsigned n);
272 struct isl_basic_set *isl_basic_set_eliminate_vars(
273 struct isl_basic_set *bset, unsigned pos, unsigned n);
275 __isl_give isl_map *isl_map_eliminate(__isl_take isl_map *map,
276 enum isl_dim_type type, unsigned first, unsigned n);
277 __isl_give isl_set *isl_set_eliminate(__isl_take isl_set *set,
278 enum isl_dim_type type, unsigned first, unsigned n);
280 int isl_basic_set_constraint_is_redundant(struct isl_basic_set **bset,
281 isl_int *c, isl_int *opt_n, isl_int *opt_d);
283 int isl_basic_map_add_div_constraint(__isl_keep isl_basic_map *bmap,
284 unsigned div, int sign);
285 int isl_basic_map_add_div_constraints(struct isl_basic_map *bmap, unsigned div);
286 __isl_give isl_basic_map *isl_basic_map_add_known_div_constraints(
287 __isl_take isl_basic_map *bmap);
288 struct isl_basic_map *isl_basic_map_drop_redundant_divs(
289 struct isl_basic_map *bmap);
290 struct isl_basic_set *isl_basic_set_drop_redundant_divs(
291 struct isl_basic_set *bset);
293 struct isl_basic_set *isl_basic_set_recession_cone(struct isl_basic_set *bset);
294 struct isl_basic_set *isl_basic_set_lineality_space(struct isl_basic_set *bset);
296 struct isl_basic_set *isl_basic_set_set_rational(struct isl_basic_set *bset);
297 __isl_give isl_set *isl_set_set_rational(__isl_take isl_set *set);
298 __isl_give isl_basic_map *isl_basic_map_set_rational(
299 __isl_take isl_basic_map *bmap);
300 __isl_give isl_map *isl_map_set_rational(__isl_take isl_map *map);
302 int isl_map_has_rational(__isl_keep isl_map *map);
303 int isl_set_has_rational(__isl_keep isl_set *set);
305 struct isl_mat;
307 struct isl_basic_set *isl_basic_set_preimage(struct isl_basic_set *bset,
308 struct isl_mat *mat);
309 struct isl_set *isl_set_preimage(struct isl_set *set, struct isl_mat *mat);
311 __isl_give isl_basic_set *isl_basic_set_transform_dims(
312 __isl_take isl_basic_set *bset, enum isl_dim_type type, unsigned first,
313 __isl_take isl_mat *trans);
315 isl_int *isl_set_wrap_facet(__isl_keep isl_set *set,
316 isl_int *facet, isl_int *ridge);
318 int isl_basic_map_contains_point(__isl_keep isl_basic_map *bmap,
319 __isl_keep isl_point *point);
320 int isl_set_contains_point(__isl_keep isl_set *set, __isl_keep isl_point *point);
322 int isl_basic_set_vars_get_sign(__isl_keep isl_basic_set *bset,
323 unsigned first, unsigned n, int *signs);
324 int isl_set_foreach_orthant(__isl_keep isl_set *set,
325 int (*fn)(__isl_take isl_set *orthant, int *signs, void *user),
326 void *user);
328 int isl_basic_map_add_div_constraints_var(__isl_keep isl_basic_map *bmap,
329 unsigned pos, isl_int *div);
330 int isl_basic_set_add_div_constraints_var(__isl_keep isl_basic_set *bset,
331 unsigned pos, isl_int *div);
332 int isl_basic_map_is_div_constraint(__isl_keep isl_basic_map *bmap,
333 isl_int *constraint, unsigned div);
334 int isl_basic_set_is_div_constraint(__isl_keep isl_basic_set *bset,
335 isl_int *constraint, unsigned div);
337 __isl_give isl_basic_set *isl_basic_set_from_local_space(
338 __isl_take isl_local_space *ls);
339 __isl_give isl_basic_map *isl_basic_map_from_local_space(
340 __isl_take isl_local_space *ls);
341 __isl_give isl_basic_set *isl_basic_set_expand_divs(
342 __isl_take isl_basic_set *bset, __isl_take isl_mat *div, int *exp);
344 int isl_basic_map_divs_known(__isl_keep isl_basic_map *bmap);
345 __isl_give isl_mat *isl_basic_set_get_divs(__isl_keep isl_basic_set *bset);
346 __isl_give isl_mat *isl_basic_map_get_divs(__isl_keep isl_basic_map *bmap);
348 __isl_give isl_map *isl_map_inline_foreach_basic_map(__isl_take isl_map *map,
349 __isl_give isl_basic_map *(*fn)(__isl_take isl_basic_map *bmap));
351 __isl_give isl_map *isl_map_align_params_map_map_and(
352 __isl_take isl_map *map1, __isl_take isl_map *map2,
353 __isl_give isl_map *(*fn)(__isl_take isl_map *map1,
354 __isl_take isl_map *map2));
355 int isl_map_align_params_map_map_and_test(__isl_keep isl_map *map1,
356 __isl_keep isl_map *map2,
357 int (*fn)(__isl_keep isl_map *map1, __isl_keep isl_map *map2));
359 int isl_basic_map_foreach_lexopt(__isl_keep isl_basic_map *bmap, int max,
360 int (*fn)(__isl_take isl_basic_set *dom, __isl_take isl_aff_list *list,
361 void *user),
362 void *user);
363 int isl_basic_set_foreach_lexopt(__isl_keep isl_basic_set *bset, int max,
364 int (*fn)(__isl_take isl_basic_set *dom, __isl_take isl_aff_list *list,
365 void *user),
366 void *user);
368 __isl_give isl_set *isl_set_substitute(__isl_take isl_set *set,
369 enum isl_dim_type type, unsigned pos, __isl_keep isl_aff *subs);
371 __isl_give isl_set *isl_set_gist_params_basic_set(__isl_take isl_set *set,
372 __isl_take isl_basic_set *context);
374 int isl_map_compatible_range(__isl_keep isl_map *map, __isl_keep isl_set *set);
376 int isl_basic_map_plain_is_single_valued(__isl_keep isl_basic_map *bmap);
378 int isl_map_is_set(__isl_keep isl_map *map);
380 int isl_basic_set_plain_dim_is_fixed(__isl_keep isl_basic_set *bset,
381 unsigned dim, isl_int *val);
383 int isl_basic_set_dim_residue_class(struct isl_basic_set *bset,
384 int pos, isl_int *modulo, isl_int *residue);
385 int isl_set_dim_residue_class(struct isl_set *set,
386 int pos, isl_int *modulo, isl_int *residue);
388 __isl_give isl_basic_set *isl_basic_set_fix(__isl_take isl_basic_set *bset,
389 enum isl_dim_type type, unsigned pos, isl_int value);
390 __isl_give isl_set *isl_set_fix(__isl_take isl_set *set,
391 enum isl_dim_type type, unsigned pos, isl_int value);
392 int isl_map_plain_is_fixed(__isl_keep isl_map *map,
393 enum isl_dim_type type, unsigned pos, isl_int *val);
395 __isl_give isl_basic_set_list *isl_set_get_basic_set_list(
396 __isl_keep isl_set *set);
398 __isl_give isl_map *isl_map_fixed_power(__isl_take isl_map *map, isl_int exp);
400 int isl_basic_set_count_upto(__isl_keep isl_basic_set *bset,
401 isl_int max, isl_int *count);
402 int isl_set_count_upto(__isl_keep isl_set *set, isl_int max, isl_int *count);
404 #endif