isl_access_info_add_source: plug memory leak on error path
[isl.git] / isl_map_private.h
blob6d07dd0b89cad7bde2ddbef2039a3cc4727d27bf
1 /*
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
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 #include <isl/set.h>
17 #include <isl/map.h>
18 #include <isl_reordering.h>
19 #include <isl/vec.h>
21 /* A "basic map" is a relation between two sets of variables,
22 * called the "in" and "out" variables.
23 * A "basic set" is a basic map with a zero-dimensional
24 * domain.
26 * It is implemented as a set with two extra fields:
27 * n_in is the number of in variables
28 * n_out is the number of out variables
29 * n_in + n_out should be equal to set.dim
31 struct isl_basic_map {
32 int ref;
33 #define ISL_BASIC_MAP_FINAL (1 << 0)
34 #define ISL_BASIC_MAP_EMPTY (1 << 1)
35 #define ISL_BASIC_MAP_NO_IMPLICIT (1 << 2)
36 #define ISL_BASIC_MAP_NO_REDUNDANT (1 << 3)
37 #define ISL_BASIC_MAP_RATIONAL (1 << 4)
38 #define ISL_BASIC_MAP_NORMALIZED (1 << 5)
39 #define ISL_BASIC_MAP_NORMALIZED_DIVS (1 << 6)
40 #define ISL_BASIC_MAP_ALL_EQUALITIES (1 << 7)
41 #define ISL_BASIC_SET_FINAL (1 << 0)
42 #define ISL_BASIC_SET_EMPTY (1 << 1)
43 #define ISL_BASIC_SET_NO_IMPLICIT (1 << 2)
44 #define ISL_BASIC_SET_NO_REDUNDANT (1 << 3)
45 #define ISL_BASIC_SET_RATIONAL (1 << 4)
46 #define ISL_BASIC_SET_NORMALIZED (1 << 5)
47 #define ISL_BASIC_SET_NORMALIZED_DIVS (1 << 6)
48 #define ISL_BASIC_SET_ALL_EQUALITIES (1 << 7)
49 unsigned flags;
51 struct isl_ctx *ctx;
53 isl_space *dim;
54 unsigned extra;
56 unsigned n_eq;
57 unsigned n_ineq;
59 size_t c_size;
60 isl_int **eq;
61 isl_int **ineq;
63 unsigned n_div;
65 isl_int **div;
67 struct isl_vec *sample;
69 struct isl_blk block;
70 struct isl_blk block2;
73 /* A "map" is a (possibly disjoint) union of basic maps.
74 * A "set" is a (possibly disjoint) union of basic sets.
76 * Currently, the isl_set structure is identical to the isl_map structure
77 * and the library depends on this correspondence internally.
78 * However, users should not depend on this correspondence.
80 struct isl_map {
81 int ref;
82 #define ISL_MAP_DISJOINT (1 << 0)
83 #define ISL_MAP_NORMALIZED (1 << 1)
84 #define ISL_SET_DISJOINT (1 << 0)
85 #define ISL_SET_NORMALIZED (1 << 1)
86 unsigned flags;
88 struct isl_ctx *ctx;
90 isl_space *dim;
92 int n;
94 size_t size;
95 struct isl_basic_map *p[1];
98 __isl_give isl_basic_map *isl_basic_map_insert(__isl_take isl_basic_map *bmap,
99 enum isl_dim_type type, unsigned pos, unsigned n);
101 __isl_give isl_map *isl_map_realign(__isl_take isl_map *map,
102 __isl_take isl_reordering *r);
103 __isl_give isl_set *isl_set_realign(__isl_take isl_set *set,
104 __isl_take isl_reordering *r);
106 __isl_give isl_map *isl_map_reset(__isl_take isl_map *map,
107 enum isl_dim_type type);
109 __isl_give isl_basic_set *isl_basic_set_reset_space(
110 __isl_take isl_basic_set *bset, __isl_take isl_space *dim);
111 __isl_give isl_basic_map *isl_basic_map_reset_space(
112 __isl_take isl_basic_map *bmap, __isl_take isl_space *dim);
113 __isl_give isl_map *isl_map_reset_space(__isl_take isl_map *map,
114 __isl_take isl_space *dim);
116 unsigned isl_basic_map_offset(struct isl_basic_map *bmap,
117 enum isl_dim_type type);
118 unsigned isl_basic_set_offset(struct isl_basic_set *bset,
119 enum isl_dim_type type);
121 int isl_basic_map_may_be_set(__isl_keep isl_basic_map *bmap);
122 int isl_map_may_be_set(__isl_keep isl_map *map);
123 int isl_map_compatible_domain(struct isl_map *map, struct isl_set *set);
124 int isl_basic_map_compatible_domain(struct isl_basic_map *bmap,
125 struct isl_basic_set *bset);
126 int isl_basic_map_compatible_range(struct isl_basic_map *bmap,
127 struct isl_basic_set *bset);
129 struct isl_basic_map *isl_basic_map_extend_space(struct isl_basic_map *base,
130 __isl_take isl_space *dim, unsigned extra,
131 unsigned n_eq, unsigned n_ineq);
132 struct isl_basic_set *isl_basic_set_extend_space(struct isl_basic_set *base,
133 __isl_take isl_space *dim, unsigned extra,
134 unsigned n_eq, unsigned n_ineq);
135 struct isl_basic_set *isl_basic_set_add_constraints(struct isl_basic_set *bset1,
136 struct isl_basic_set *bset2, unsigned pos);
138 struct isl_map *isl_map_grow(struct isl_map *map, int n);
139 struct isl_set *isl_set_grow(struct isl_set *set, int n);
141 int isl_basic_set_contains(struct isl_basic_set *bset, struct isl_vec *vec);
142 int isl_basic_map_contains(struct isl_basic_map *bmap, struct isl_vec *vec);
144 __isl_give isl_basic_set *isl_basic_set_alloc_space(__isl_take isl_space *dim,
145 unsigned extra, unsigned n_eq, unsigned n_ineq);
146 __isl_give isl_set *isl_set_alloc_space(__isl_take isl_space *dim, int n,
147 unsigned flags);
148 __isl_give isl_basic_map *isl_basic_map_alloc_space(__isl_take isl_space *dim,
149 unsigned extra, unsigned n_eq, unsigned n_ineq);
150 __isl_give isl_map *isl_map_alloc_space(__isl_take isl_space *dim, int n,
151 unsigned flags);
153 unsigned isl_basic_map_total_dim(const struct isl_basic_map *bmap);
155 int isl_basic_map_alloc_equality(struct isl_basic_map *bmap);
156 int isl_basic_set_alloc_equality(struct isl_basic_set *bset);
157 int isl_basic_set_free_inequality(struct isl_basic_set *bset, unsigned n);
158 int isl_basic_map_free_equality(struct isl_basic_map *bmap, unsigned n);
159 int isl_basic_set_free_equality(struct isl_basic_set *bset, unsigned n);
160 int isl_basic_set_alloc_inequality(struct isl_basic_set *bset);
161 int isl_basic_map_alloc_inequality(struct isl_basic_map *bmap);
162 int isl_basic_map_free_inequality(struct isl_basic_map *bmap, unsigned n);
163 int isl_basic_map_alloc_div(struct isl_basic_map *bmap);
164 int isl_basic_set_alloc_div(struct isl_basic_set *bset);
165 int isl_basic_map_free_div(struct isl_basic_map *bmap, unsigned n);
166 int isl_basic_set_free_div(struct isl_basic_set *bset, unsigned n);
167 void isl_basic_map_inequality_to_equality(
168 struct isl_basic_map *bmap, unsigned pos);
169 int isl_basic_map_drop_equality(struct isl_basic_map *bmap, unsigned pos);
170 int isl_basic_set_drop_equality(struct isl_basic_set *bset, unsigned pos);
171 int isl_basic_set_drop_inequality(struct isl_basic_set *bset, unsigned pos);
172 int isl_basic_map_drop_inequality(struct isl_basic_map *bmap, unsigned pos);
173 __isl_give isl_basic_set *isl_basic_set_add_eq(__isl_take isl_basic_set *bset,
174 isl_int *eq);
175 __isl_give isl_basic_map *isl_basic_map_add_eq(__isl_take isl_basic_map *bmap,
176 isl_int *eq);
177 __isl_give isl_basic_set *isl_basic_set_add_ineq(__isl_take isl_basic_set *bset,
178 isl_int *ineq);
179 __isl_give isl_basic_map *isl_basic_map_add_ineq(__isl_take isl_basic_map *bmap,
180 isl_int *ineq);
182 int isl_inequality_negate(struct isl_basic_map *bmap, unsigned pos);
184 struct isl_basic_set *isl_basic_set_cow(struct isl_basic_set *bset);
185 struct isl_basic_map *isl_basic_map_cow(struct isl_basic_map *bmap);
186 struct isl_set *isl_set_cow(struct isl_set *set);
187 struct isl_map *isl_map_cow(struct isl_map *map);
189 struct isl_basic_map *isl_basic_map_set_to_empty(struct isl_basic_map *bmap);
190 struct isl_basic_set *isl_basic_set_set_to_empty(struct isl_basic_set *bset);
191 struct isl_basic_set *isl_basic_set_order_divs(struct isl_basic_set *bset);
192 void isl_basic_map_swap_div(struct isl_basic_map *bmap, int a, int b);
193 struct isl_basic_map *isl_basic_map_order_divs(struct isl_basic_map *bmap);
194 __isl_give isl_map *isl_map_order_divs(__isl_take isl_map *map);
195 struct isl_basic_map *isl_basic_map_align_divs(
196 struct isl_basic_map *dst, struct isl_basic_map *src);
197 struct isl_basic_set *isl_basic_set_align_divs(
198 struct isl_basic_set *dst, struct isl_basic_set *src);
199 __isl_give isl_basic_map *isl_basic_map_sort_divs(
200 __isl_take isl_basic_map *bmap);
201 __isl_give isl_map *isl_map_sort_divs(__isl_take isl_map *map);
202 struct isl_basic_map *isl_basic_map_gauss(
203 struct isl_basic_map *bmap, int *progress);
204 struct isl_basic_set *isl_basic_set_gauss(
205 struct isl_basic_set *bset, int *progress);
206 __isl_give isl_basic_set *isl_basic_set_sort_constraints(
207 __isl_take isl_basic_set *bset);
208 int isl_basic_map_plain_cmp(const __isl_keep isl_basic_map *bmap1,
209 const __isl_keep isl_basic_map *bmap2);
210 int isl_set_plain_cmp(const __isl_keep isl_set *set1,
211 const __isl_keep isl_set *set2);
212 int isl_basic_set_plain_is_equal(__isl_keep isl_basic_set *bset1,
213 __isl_keep isl_basic_set *bset2);
214 int isl_basic_map_plain_is_equal(__isl_keep isl_basic_map *bmap1,
215 __isl_keep isl_basic_map *bmap2);
216 struct isl_basic_map *isl_basic_map_normalize_constraints(
217 struct isl_basic_map *bmap);
218 struct isl_basic_set *isl_basic_set_normalize_constraints(
219 struct isl_basic_set *bset);
220 struct isl_basic_map *isl_basic_map_implicit_equalities(
221 struct isl_basic_map *bmap);
222 struct isl_basic_set *isl_basic_map_underlying_set(struct isl_basic_map *bmap);
223 __isl_give isl_basic_set *isl_basic_set_underlying_set(
224 __isl_take isl_basic_set *bset);
225 struct isl_set *isl_map_underlying_set(struct isl_map *map);
226 struct isl_basic_map *isl_basic_map_overlying_set(struct isl_basic_set *bset,
227 struct isl_basic_map *like);
228 __isl_give isl_basic_set *isl_basic_set_drop_constraints_involving(
229 __isl_take isl_basic_set *bset, unsigned first, unsigned n);
230 __isl_give isl_basic_set *isl_basic_set_drop(__isl_take isl_basic_set *bset,
231 enum isl_dim_type type, unsigned first, unsigned n);
232 struct isl_basic_map *isl_basic_map_drop(struct isl_basic_map *bmap,
233 enum isl_dim_type type, unsigned first, unsigned n);
234 struct isl_set *isl_set_drop(struct isl_set *set,
235 enum isl_dim_type type, unsigned first, unsigned n);
236 struct isl_basic_set *isl_basic_set_drop_dims(
237 struct isl_basic_set *bset, unsigned first, unsigned n);
238 struct isl_set *isl_set_drop_dims(
239 struct isl_set *set, unsigned first, unsigned n);
240 struct isl_map *isl_map_drop_inputs(
241 struct isl_map *map, unsigned first, unsigned n);
242 struct isl_map *isl_map_drop(struct isl_map *map,
243 enum isl_dim_type type, unsigned first, unsigned n);
245 struct isl_map *isl_map_remove_empty_parts(struct isl_map *map);
246 struct isl_set *isl_set_remove_empty_parts(struct isl_set *set);
248 struct isl_set *isl_set_normalize(struct isl_set *set);
250 struct isl_set *isl_set_drop_vars(
251 struct isl_set *set, unsigned first, unsigned n);
253 struct isl_basic_map *isl_basic_map_eliminate_vars(
254 struct isl_basic_map *bmap, unsigned pos, unsigned n);
255 struct isl_basic_set *isl_basic_set_eliminate_vars(
256 struct isl_basic_set *bset, unsigned pos, unsigned n);
258 __isl_give isl_map *isl_map_eliminate(__isl_take isl_map *map,
259 enum isl_dim_type type, unsigned first, unsigned n);
260 __isl_give isl_set *isl_set_eliminate(__isl_take isl_set *set,
261 enum isl_dim_type type, unsigned first, unsigned n);
263 int isl_basic_set_constraint_is_redundant(struct isl_basic_set **bset,
264 isl_int *c, isl_int *opt_n, isl_int *opt_d);
266 int isl_basic_map_add_div_constraints(struct isl_basic_map *bmap, unsigned div);
267 struct isl_basic_map *isl_basic_map_drop_redundant_divs(
268 struct isl_basic_map *bmap);
269 struct isl_basic_set *isl_basic_set_drop_redundant_divs(
270 struct isl_basic_set *bset);
272 struct isl_basic_set *isl_basic_set_recession_cone(struct isl_basic_set *bset);
273 struct isl_basic_set *isl_basic_set_lineality_space(struct isl_basic_set *bset);
275 struct isl_basic_set *isl_basic_set_set_rational(struct isl_basic_set *bset);
276 __isl_give isl_basic_map *isl_basic_map_set_rational(
277 __isl_take isl_basic_map *bmap);
278 __isl_give isl_map *isl_map_set_rational(__isl_take isl_map *map);
280 struct isl_mat;
282 struct isl_basic_set *isl_basic_set_preimage(struct isl_basic_set *bset,
283 struct isl_mat *mat);
284 struct isl_set *isl_set_preimage(struct isl_set *set, struct isl_mat *mat);
286 __isl_give isl_basic_set *isl_basic_set_transform_dims(
287 __isl_take isl_basic_set *bset, enum isl_dim_type type, unsigned first,
288 __isl_take isl_mat *trans);
290 isl_int *isl_set_wrap_facet(__isl_keep isl_set *set,
291 isl_int *facet, isl_int *ridge);
293 int isl_basic_map_contains_point(__isl_keep isl_basic_map *bmap,
294 __isl_keep isl_point *point);
295 int isl_set_contains_point(__isl_keep isl_set *set, __isl_keep isl_point *point);
297 int isl_basic_set_vars_get_sign(__isl_keep isl_basic_set *bset,
298 unsigned first, unsigned n, int *signs);
299 int isl_set_foreach_orthant(__isl_keep isl_set *set,
300 int (*fn)(__isl_take isl_set *orthant, int *signs, void *user),
301 void *user);
303 int isl_basic_map_add_div_constraints_var(__isl_keep isl_basic_map *bmap,
304 unsigned pos, isl_int *div);
305 int isl_basic_set_add_div_constraints_var(__isl_keep isl_basic_set *bset,
306 unsigned pos, isl_int *div);
307 int isl_basic_map_is_div_constraint(__isl_keep isl_basic_map *bmap,
308 isl_int *constraint, unsigned div);
309 int isl_basic_set_is_div_constraint(__isl_keep isl_basic_set *bset,
310 isl_int *constraint, unsigned div);
312 __isl_give isl_basic_set *isl_basic_set_from_local_space(
313 __isl_take isl_local_space *ls);
314 __isl_give isl_basic_map *isl_basic_map_from_local_space(
315 __isl_take isl_local_space *ls);
316 __isl_give isl_basic_set *isl_basic_set_expand_divs(
317 __isl_take isl_basic_set *bset, __isl_take isl_mat *div, int *exp);
319 int isl_basic_map_divs_known(__isl_keep isl_basic_map *bmap);
320 __isl_give isl_mat *isl_basic_map_get_divs(__isl_keep isl_basic_map *bmap);
322 __isl_give isl_map *isl_map_inline_foreach_basic_map(__isl_take isl_map *map,
323 __isl_give isl_basic_map *(*fn)(__isl_take isl_basic_map *bmap));
325 __isl_give isl_map *isl_map_align_params_map_map_and(
326 __isl_take isl_map *map1, __isl_take isl_map *map2,
327 __isl_give isl_map *(*fn)(__isl_take isl_map *map1,
328 __isl_take isl_map *map2));
329 int isl_map_align_params_map_map_and_test(__isl_keep isl_map *map1,
330 __isl_keep isl_map *map2,
331 int (*fn)(__isl_keep isl_map *map1, __isl_keep isl_map *map2));
333 int isl_basic_map_foreach_lexopt(__isl_keep isl_basic_map *bmap, int max,
334 int (*fn)(__isl_take isl_basic_set *dom, __isl_take isl_aff_list *list,
335 void *user),
336 void *user);
337 int isl_basic_set_foreach_lexopt(__isl_keep isl_basic_set *bset, int max,
338 int (*fn)(__isl_take isl_basic_set *dom, __isl_take isl_aff_list *list,
339 void *user),
340 void *user);
342 __isl_give isl_set *isl_set_substitute(__isl_take isl_set *set,
343 enum isl_dim_type type, unsigned pos, __isl_keep isl_aff *subs);
345 __isl_give isl_set *isl_set_gist_params_basic_set(__isl_take isl_set *set,
346 __isl_take isl_basic_set *context);
348 int isl_map_compatible_range(__isl_keep isl_map *map, __isl_keep isl_set *set);
350 int isl_basic_map_plain_is_single_valued(__isl_keep isl_basic_map *bmap);
352 #endif