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
10 #ifndef ISL_MAP_PRIVATE_H
11 #define ISL_MAP_PRIVATE_H
15 #include <isl_reordering.h>
18 /* A "basic map" is a relation between two sets of variables,
19 * called the "in" and "out" variables.
21 * It is implemented as a set with two extra fields:
22 * n_in is the number of in variables
23 * n_out is the number of out variables
24 * n_in + n_out should be equal to set.dim
26 struct isl_basic_map {
28 #define ISL_BASIC_MAP_FINAL (1 << 0)
29 #define ISL_BASIC_MAP_EMPTY (1 << 1)
30 #define ISL_BASIC_MAP_NO_IMPLICIT (1 << 2)
31 #define ISL_BASIC_MAP_NO_REDUNDANT (1 << 3)
32 #define ISL_BASIC_MAP_RATIONAL (1 << 4)
33 #define ISL_BASIC_MAP_NORMALIZED (1 << 5)
34 #define ISL_BASIC_MAP_NORMALIZED_DIVS (1 << 6)
35 #define ISL_BASIC_MAP_ALL_EQUALITIES (1 << 7)
54 struct isl_vec *sample;
57 struct isl_blk block2;
60 /* A "basic set" is a basic map with a zero-dimensional
63 struct isl_basic_set {
65 #define ISL_BASIC_SET_FINAL (1 << 0)
66 #define ISL_BASIC_SET_EMPTY (1 << 1)
67 #define ISL_BASIC_SET_NO_IMPLICIT (1 << 2)
68 #define ISL_BASIC_SET_NO_REDUNDANT (1 << 3)
69 #define ISL_BASIC_SET_RATIONAL (1 << 4)
70 #define ISL_BASIC_SET_NORMALIZED (1 << 5)
71 #define ISL_BASIC_SET_NORMALIZED_DIVS (1 << 6)
72 #define ISL_BASIC_SET_ALL_EQUALITIES (1 << 7)
91 struct isl_vec *sample;
94 struct isl_blk block2;
97 /* A "set" is a (possibly disjoint) union of basic sets.
99 * See the documentation of isl_map.
103 #define ISL_SET_DISJOINT (1 << 0)
104 #define ISL_SET_NORMALIZED (1 << 1)
114 struct isl_basic_set *p[1];
117 __isl_give isl_map *isl_map_realign(__isl_take isl_map *map,
118 __isl_take isl_reordering *r);
119 __isl_give isl_set *isl_set_realign(__isl_take isl_set *set,
120 __isl_take isl_reordering *r);
122 __isl_give isl_map *isl_map_reset(__isl_take isl_map *map,
123 enum isl_dim_type type);
125 __isl_give isl_basic_map *isl_basic_map_reset_dim(
126 __isl_take isl_basic_map *bmap, __isl_take isl_dim *dim);
127 __isl_give isl_map *isl_map_reset_dim(__isl_take isl_map *map,
128 __isl_take isl_dim *dim);
130 unsigned isl_basic_map_offset(struct isl_basic_map *bmap,
131 enum isl_dim_type type);
133 int isl_map_compatible_domain(struct isl_map *map, struct isl_set *set);
134 int isl_basic_map_compatible_domain(struct isl_basic_map *bmap,
135 struct isl_basic_set *bset);
136 int isl_basic_map_compatible_range(struct isl_basic_map *bmap,
137 struct isl_basic_set *bset);
139 struct isl_basic_map *isl_basic_map_extend_dim(struct isl_basic_map *base,
140 struct isl_dim *dim, unsigned extra,
141 unsigned n_eq, unsigned n_ineq);
142 struct isl_basic_set *isl_basic_set_extend_dim(struct isl_basic_set *base,
143 struct isl_dim *dim, unsigned extra,
144 unsigned n_eq, unsigned n_ineq);
145 struct isl_basic_set *isl_basic_set_add_constraints(struct isl_basic_set *bset1,
146 struct isl_basic_set *bset2, unsigned pos);
148 struct isl_map *isl_map_grow(struct isl_map *map, int n);
149 struct isl_set *isl_set_grow(struct isl_set *set, int n);
151 int isl_basic_set_contains(struct isl_basic_set *bset, struct isl_vec *vec);
152 int isl_basic_map_contains(struct isl_basic_map *bmap, struct isl_vec *vec);
154 struct isl_basic_set *isl_basic_set_alloc_dim(struct isl_dim *dim,
155 unsigned extra, unsigned n_eq, unsigned n_ineq);
156 struct isl_set *isl_set_alloc_dim(struct isl_dim *dim, int n, unsigned flags);
157 struct isl_basic_map *isl_basic_map_alloc_dim(struct isl_dim *dim,
158 unsigned extra, unsigned n_eq, unsigned n_ineq);
159 struct isl_map *isl_map_alloc_dim(struct isl_dim *dim, int n, unsigned flags);
161 unsigned isl_basic_map_total_dim(const struct isl_basic_map *bmap);
163 int isl_basic_map_alloc_equality(struct isl_basic_map *bmap);
164 int isl_basic_set_alloc_equality(struct isl_basic_set *bset);
165 int isl_basic_set_free_inequality(struct isl_basic_set *bset, unsigned n);
166 int isl_basic_map_free_equality(struct isl_basic_map *bmap, unsigned n);
167 int isl_basic_set_free_equality(struct isl_basic_set *bset, unsigned n);
168 int isl_basic_set_alloc_inequality(struct isl_basic_set *bset);
169 int isl_basic_map_alloc_inequality(struct isl_basic_map *bmap);
170 int isl_basic_map_free_inequality(struct isl_basic_map *bmap, unsigned n);
171 int isl_basic_map_alloc_div(struct isl_basic_map *bmap);
172 int isl_basic_set_alloc_div(struct isl_basic_set *bset);
173 int isl_basic_map_free_div(struct isl_basic_map *bmap, unsigned n);
174 int isl_basic_set_free_div(struct isl_basic_set *bset, unsigned n);
175 void isl_basic_map_inequality_to_equality(
176 struct isl_basic_map *bmap, unsigned pos);
177 int isl_basic_map_drop_equality(struct isl_basic_map *bmap, unsigned pos);
178 int isl_basic_set_drop_equality(struct isl_basic_set *bset, unsigned pos);
179 int isl_basic_set_drop_inequality(struct isl_basic_set *bset, unsigned pos);
180 int isl_basic_map_drop_inequality(struct isl_basic_map *bmap, unsigned pos);
181 __isl_give isl_basic_set *isl_basic_set_add_eq(__isl_take isl_basic_set *bset,
183 __isl_give isl_basic_map *isl_basic_map_add_eq(__isl_take isl_basic_map *bmap,
185 __isl_give isl_basic_set *isl_basic_set_add_ineq(__isl_take isl_basic_set *bset,
187 __isl_give isl_basic_map *isl_basic_map_add_ineq(__isl_take isl_basic_map *bmap,
190 int isl_inequality_negate(struct isl_basic_map *bmap, unsigned pos);
192 struct isl_basic_set *isl_basic_set_cow(struct isl_basic_set *bset);
193 struct isl_basic_map *isl_basic_map_cow(struct isl_basic_map *bmap);
194 struct isl_set *isl_set_cow(struct isl_set *set);
195 struct isl_map *isl_map_cow(struct isl_map *map);
197 struct isl_basic_map *isl_basic_map_set_to_empty(struct isl_basic_map *bmap);
198 struct isl_basic_set *isl_basic_set_set_to_empty(struct isl_basic_set *bset);
199 struct isl_basic_set *isl_basic_set_order_divs(struct isl_basic_set *bset);
200 void isl_basic_map_swap_div(struct isl_basic_map *bmap, int a, int b);
201 struct isl_basic_map *isl_basic_map_order_divs(struct isl_basic_map *bmap);
202 __isl_give isl_map *isl_map_order_divs(__isl_take isl_map *map);
203 struct isl_basic_map *isl_basic_map_align_divs(
204 struct isl_basic_map *dst, struct isl_basic_map *src);
205 struct isl_basic_set *isl_basic_set_align_divs(
206 struct isl_basic_set *dst, struct isl_basic_set *src);
207 struct isl_basic_map *isl_basic_map_gauss(
208 struct isl_basic_map *bmap, int *progress);
209 struct isl_basic_set *isl_basic_set_gauss(
210 struct isl_basic_set *bset, int *progress);
211 __isl_give isl_basic_set *isl_basic_set_sort_constraints(
212 __isl_take isl_basic_set *bset);
213 int isl_basic_map_fast_cmp(const __isl_keep isl_basic_map *bmap1,
214 const __isl_keep isl_basic_map *bmap2);
215 int isl_basic_set_fast_is_equal(__isl_keep isl_basic_set *bset1,
216 __isl_keep isl_basic_set *bset2);
217 int isl_basic_map_fast_is_equal(__isl_keep isl_basic_map *bmap1,
218 __isl_keep isl_basic_map *bmap2);
219 struct isl_basic_map *isl_basic_map_normalize_constraints(
220 struct isl_basic_map *bmap);
221 struct isl_basic_set *isl_basic_set_normalize_constraints(
222 struct isl_basic_set *bset);
223 struct isl_basic_map *isl_basic_map_implicit_equalities(
224 struct isl_basic_map *bmap);
225 struct isl_basic_set *isl_basic_map_underlying_set(struct isl_basic_map *bmap);
226 __isl_give isl_basic_set *isl_basic_set_underlying_set(
227 __isl_take isl_basic_set *bset);
228 struct isl_set *isl_map_underlying_set(struct isl_map *map);
229 struct isl_basic_map *isl_basic_map_overlying_set(struct isl_basic_set *bset,
230 struct isl_basic_map *like);
231 __isl_give isl_basic_set *isl_basic_set_drop_constraints_involving(
232 __isl_take isl_basic_set *bset, unsigned first, unsigned n);
233 __isl_give isl_basic_set *isl_basic_set_drop(__isl_take isl_basic_set *bset,
234 enum isl_dim_type type, unsigned first, unsigned n);
235 struct isl_basic_map *isl_basic_map_drop(struct isl_basic_map *bmap,
236 enum isl_dim_type type, unsigned first, unsigned n);
237 struct isl_set *isl_set_drop(struct isl_set *set,
238 enum isl_dim_type type, unsigned first, unsigned n);
239 struct isl_basic_set *isl_basic_set_drop_dims(
240 struct isl_basic_set *bset, unsigned first, unsigned n);
241 struct isl_set *isl_set_drop_dims(
242 struct isl_set *set, unsigned first, unsigned n);
243 struct isl_map *isl_map_drop_inputs(
244 struct isl_map *map, unsigned first, unsigned n);
245 struct isl_map *isl_map_drop(struct isl_map *map,
246 enum isl_dim_type type, unsigned first, unsigned n);
248 struct isl_map *isl_map_remove_empty_parts(struct isl_map *map);
249 struct isl_set *isl_set_remove_empty_parts(struct isl_set *set);
251 struct isl_set *isl_set_normalize(struct isl_set *set);
253 struct isl_set *isl_set_drop_vars(
254 struct isl_set *set, unsigned first, unsigned n);
256 struct isl_basic_map *isl_basic_map_eliminate_vars(
257 struct isl_basic_map *bmap, unsigned pos, unsigned n);
258 struct isl_basic_set *isl_basic_set_eliminate_vars(
259 struct isl_basic_set *bset, unsigned pos, unsigned n);
261 __isl_give isl_map *isl_map_eliminate(__isl_take isl_map *map,
262 enum isl_dim_type type, unsigned first, unsigned n);
263 __isl_give isl_set *isl_set_eliminate(__isl_take isl_set *set,
264 enum isl_dim_type type, unsigned first, unsigned n);
266 int isl_basic_set_constraint_is_redundant(struct isl_basic_set **bset,
267 isl_int *c, isl_int *opt_n, isl_int *opt_d);
269 int isl_basic_map_add_div_constraints(struct isl_basic_map *bmap, unsigned div);
270 struct isl_basic_map *isl_basic_map_drop_redundant_divs(
271 struct isl_basic_map *bmap);
272 struct isl_basic_set *isl_basic_set_drop_redundant_divs(
273 struct isl_basic_set *bset);
275 struct isl_basic_set *isl_basic_set_recession_cone(struct isl_basic_set *bset);
276 struct isl_basic_set *isl_basic_set_lineality_space(struct isl_basic_set *bset);
278 struct isl_basic_set *isl_basic_set_set_rational(struct isl_basic_set *bset);
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_int *isl_set_wrap_facet(__isl_keep isl_set *set,
287 isl_int *facet, isl_int *ridge);
289 int isl_basic_map_contains_point(__isl_keep isl_basic_map *bmap,
290 __isl_keep isl_point *point);
291 int isl_set_contains_point(__isl_keep isl_set *set, __isl_keep isl_point *point);
293 int isl_basic_set_vars_get_sign(__isl_keep isl_basic_set *bset,
294 unsigned first, unsigned n, int *signs);
295 int isl_set_foreach_orthant(__isl_keep isl_set *set,
296 int (*fn)(__isl_take isl_set *orthant, int *signs, void *user),
299 int isl_basic_set_add_div_constraints_var(__isl_keep isl_basic_set *bset,
300 unsigned pos, isl_int *div);
301 int isl_basic_map_is_div_constraint(__isl_keep isl_basic_map *bmap,
302 isl_int *constraint, unsigned div);