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
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
18 #include <isl_reordering.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
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
{
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)
67 struct isl_vec
*sample
;
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.
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)
95 struct isl_basic_map
*p
[1];
98 __isl_give isl_map
*isl_map_realign(__isl_take isl_map
*map
,
99 __isl_take isl_reordering
*r
);
100 __isl_give isl_set
*isl_set_realign(__isl_take isl_set
*set
,
101 __isl_take isl_reordering
*r
);
103 __isl_give isl_map
*isl_map_reset(__isl_take isl_map
*map
,
104 enum isl_dim_type type
);
106 __isl_give isl_basic_set
*isl_basic_set_reset_space(
107 __isl_take isl_basic_set
*bset
, __isl_take isl_space
*dim
);
108 __isl_give isl_basic_map
*isl_basic_map_reset_space(
109 __isl_take isl_basic_map
*bmap
, __isl_take isl_space
*dim
);
110 __isl_give isl_map
*isl_map_reset_space(__isl_take isl_map
*map
,
111 __isl_take isl_space
*dim
);
113 unsigned isl_basic_map_offset(struct isl_basic_map
*bmap
,
114 enum isl_dim_type type
);
115 unsigned isl_basic_set_offset(struct isl_basic_set
*bset
,
116 enum isl_dim_type type
);
118 int isl_basic_map_may_be_set(__isl_keep isl_basic_map
*bmap
);
119 int isl_map_may_be_set(__isl_keep isl_map
*map
);
120 int isl_map_compatible_domain(struct isl_map
*map
, struct isl_set
*set
);
121 int isl_basic_map_compatible_domain(struct isl_basic_map
*bmap
,
122 struct isl_basic_set
*bset
);
123 int isl_basic_map_compatible_range(struct isl_basic_map
*bmap
,
124 struct isl_basic_set
*bset
);
126 struct isl_basic_map
*isl_basic_map_extend_space(struct isl_basic_map
*base
,
127 __isl_take isl_space
*dim
, unsigned extra
,
128 unsigned n_eq
, unsigned n_ineq
);
129 struct isl_basic_set
*isl_basic_set_extend_space(struct isl_basic_set
*base
,
130 __isl_take isl_space
*dim
, unsigned extra
,
131 unsigned n_eq
, unsigned n_ineq
);
132 struct isl_basic_set
*isl_basic_set_add_constraints(struct isl_basic_set
*bset1
,
133 struct isl_basic_set
*bset2
, unsigned pos
);
135 struct isl_map
*isl_map_grow(struct isl_map
*map
, int n
);
136 struct isl_set
*isl_set_grow(struct isl_set
*set
, int n
);
138 int isl_basic_set_contains(struct isl_basic_set
*bset
, struct isl_vec
*vec
);
139 int isl_basic_map_contains(struct isl_basic_map
*bmap
, struct isl_vec
*vec
);
141 __isl_give isl_basic_set
*isl_basic_set_alloc_space(__isl_take isl_space
*dim
,
142 unsigned extra
, unsigned n_eq
, unsigned n_ineq
);
143 __isl_give isl_set
*isl_set_alloc_space(__isl_take isl_space
*dim
, int n
,
145 __isl_give isl_basic_map
*isl_basic_map_alloc_space(__isl_take isl_space
*dim
,
146 unsigned extra
, unsigned n_eq
, unsigned n_ineq
);
147 __isl_give isl_map
*isl_map_alloc_space(__isl_take isl_space
*dim
, int n
,
150 unsigned isl_basic_map_total_dim(const struct isl_basic_map
*bmap
);
152 int isl_basic_map_alloc_equality(struct isl_basic_map
*bmap
);
153 int isl_basic_set_alloc_equality(struct isl_basic_set
*bset
);
154 int isl_basic_set_free_inequality(struct isl_basic_set
*bset
, unsigned n
);
155 int isl_basic_map_free_equality(struct isl_basic_map
*bmap
, unsigned n
);
156 int isl_basic_set_free_equality(struct isl_basic_set
*bset
, unsigned n
);
157 int isl_basic_set_alloc_inequality(struct isl_basic_set
*bset
);
158 int isl_basic_map_alloc_inequality(struct isl_basic_map
*bmap
);
159 int isl_basic_map_free_inequality(struct isl_basic_map
*bmap
, unsigned n
);
160 int isl_basic_map_alloc_div(struct isl_basic_map
*bmap
);
161 int isl_basic_set_alloc_div(struct isl_basic_set
*bset
);
162 int isl_basic_map_free_div(struct isl_basic_map
*bmap
, unsigned n
);
163 int isl_basic_set_free_div(struct isl_basic_set
*bset
, unsigned n
);
164 void isl_basic_map_inequality_to_equality(
165 struct isl_basic_map
*bmap
, unsigned pos
);
166 int isl_basic_map_drop_equality(struct isl_basic_map
*bmap
, unsigned pos
);
167 int isl_basic_set_drop_equality(struct isl_basic_set
*bset
, unsigned pos
);
168 int isl_basic_set_drop_inequality(struct isl_basic_set
*bset
, unsigned pos
);
169 int isl_basic_map_drop_inequality(struct isl_basic_map
*bmap
, unsigned pos
);
170 __isl_give isl_basic_set
*isl_basic_set_add_eq(__isl_take isl_basic_set
*bset
,
172 __isl_give isl_basic_map
*isl_basic_map_add_eq(__isl_take isl_basic_map
*bmap
,
174 __isl_give isl_basic_set
*isl_basic_set_add_ineq(__isl_take isl_basic_set
*bset
,
176 __isl_give isl_basic_map
*isl_basic_map_add_ineq(__isl_take isl_basic_map
*bmap
,
179 int isl_inequality_negate(struct isl_basic_map
*bmap
, unsigned pos
);
181 struct isl_basic_set
*isl_basic_set_cow(struct isl_basic_set
*bset
);
182 struct isl_basic_map
*isl_basic_map_cow(struct isl_basic_map
*bmap
);
183 struct isl_set
*isl_set_cow(struct isl_set
*set
);
184 struct isl_map
*isl_map_cow(struct isl_map
*map
);
186 struct isl_basic_map
*isl_basic_map_set_to_empty(struct isl_basic_map
*bmap
);
187 struct isl_basic_set
*isl_basic_set_set_to_empty(struct isl_basic_set
*bset
);
188 struct isl_basic_set
*isl_basic_set_order_divs(struct isl_basic_set
*bset
);
189 void isl_basic_map_swap_div(struct isl_basic_map
*bmap
, int a
, int b
);
190 struct isl_basic_map
*isl_basic_map_order_divs(struct isl_basic_map
*bmap
);
191 __isl_give isl_map
*isl_map_order_divs(__isl_take isl_map
*map
);
192 struct isl_basic_map
*isl_basic_map_align_divs(
193 struct isl_basic_map
*dst
, struct isl_basic_map
*src
);
194 struct isl_basic_set
*isl_basic_set_align_divs(
195 struct isl_basic_set
*dst
, struct isl_basic_set
*src
);
196 __isl_give isl_basic_map
*isl_basic_map_sort_divs(
197 __isl_take isl_basic_map
*bmap
);
198 __isl_give isl_map
*isl_map_sort_divs(__isl_take isl_map
*map
);
199 struct isl_basic_map
*isl_basic_map_gauss(
200 struct isl_basic_map
*bmap
, int *progress
);
201 struct isl_basic_set
*isl_basic_set_gauss(
202 struct isl_basic_set
*bset
, int *progress
);
203 __isl_give isl_basic_set
*isl_basic_set_sort_constraints(
204 __isl_take isl_basic_set
*bset
);
205 int isl_basic_map_plain_cmp(const __isl_keep isl_basic_map
*bmap1
,
206 const __isl_keep isl_basic_map
*bmap2
);
207 int isl_basic_set_plain_is_equal(__isl_keep isl_basic_set
*bset1
,
208 __isl_keep isl_basic_set
*bset2
);
209 int isl_basic_map_plain_is_equal(__isl_keep isl_basic_map
*bmap1
,
210 __isl_keep isl_basic_map
*bmap2
);
211 struct isl_basic_map
*isl_basic_map_normalize_constraints(
212 struct isl_basic_map
*bmap
);
213 struct isl_basic_set
*isl_basic_set_normalize_constraints(
214 struct isl_basic_set
*bset
);
215 struct isl_basic_map
*isl_basic_map_implicit_equalities(
216 struct isl_basic_map
*bmap
);
217 struct isl_basic_set
*isl_basic_map_underlying_set(struct isl_basic_map
*bmap
);
218 __isl_give isl_basic_set
*isl_basic_set_underlying_set(
219 __isl_take isl_basic_set
*bset
);
220 struct isl_set
*isl_map_underlying_set(struct isl_map
*map
);
221 struct isl_basic_map
*isl_basic_map_overlying_set(struct isl_basic_set
*bset
,
222 struct isl_basic_map
*like
);
223 __isl_give isl_basic_set
*isl_basic_set_drop_constraints_involving(
224 __isl_take isl_basic_set
*bset
, unsigned first
, unsigned n
);
225 __isl_give isl_basic_set
*isl_basic_set_drop(__isl_take isl_basic_set
*bset
,
226 enum isl_dim_type type
, unsigned first
, unsigned n
);
227 struct isl_basic_map
*isl_basic_map_drop(struct isl_basic_map
*bmap
,
228 enum isl_dim_type type
, unsigned first
, unsigned n
);
229 struct isl_set
*isl_set_drop(struct isl_set
*set
,
230 enum isl_dim_type type
, unsigned first
, unsigned n
);
231 struct isl_basic_set
*isl_basic_set_drop_dims(
232 struct isl_basic_set
*bset
, unsigned first
, unsigned n
);
233 struct isl_set
*isl_set_drop_dims(
234 struct isl_set
*set
, unsigned first
, unsigned n
);
235 struct isl_map
*isl_map_drop_inputs(
236 struct isl_map
*map
, unsigned first
, unsigned n
);
237 struct isl_map
*isl_map_drop(struct isl_map
*map
,
238 enum isl_dim_type type
, unsigned first
, unsigned n
);
240 struct isl_map
*isl_map_remove_empty_parts(struct isl_map
*map
);
241 struct isl_set
*isl_set_remove_empty_parts(struct isl_set
*set
);
243 struct isl_set
*isl_set_normalize(struct isl_set
*set
);
245 struct isl_set
*isl_set_drop_vars(
246 struct isl_set
*set
, unsigned first
, unsigned n
);
248 struct isl_basic_map
*isl_basic_map_eliminate_vars(
249 struct isl_basic_map
*bmap
, unsigned pos
, unsigned n
);
250 struct isl_basic_set
*isl_basic_set_eliminate_vars(
251 struct isl_basic_set
*bset
, unsigned pos
, unsigned n
);
253 __isl_give isl_map
*isl_map_eliminate(__isl_take isl_map
*map
,
254 enum isl_dim_type type
, unsigned first
, unsigned n
);
255 __isl_give isl_set
*isl_set_eliminate(__isl_take isl_set
*set
,
256 enum isl_dim_type type
, unsigned first
, unsigned n
);
258 int isl_basic_set_constraint_is_redundant(struct isl_basic_set
**bset
,
259 isl_int
*c
, isl_int
*opt_n
, isl_int
*opt_d
);
261 int isl_basic_map_add_div_constraints(struct isl_basic_map
*bmap
, unsigned div
);
262 struct isl_basic_map
*isl_basic_map_drop_redundant_divs(
263 struct isl_basic_map
*bmap
);
264 struct isl_basic_set
*isl_basic_set_drop_redundant_divs(
265 struct isl_basic_set
*bset
);
267 struct isl_basic_set
*isl_basic_set_recession_cone(struct isl_basic_set
*bset
);
268 struct isl_basic_set
*isl_basic_set_lineality_space(struct isl_basic_set
*bset
);
270 struct isl_basic_set
*isl_basic_set_set_rational(struct isl_basic_set
*bset
);
271 __isl_give isl_set
*isl_set_set_rational(__isl_take isl_set
*set
);
272 __isl_give isl_basic_map
*isl_basic_map_set_rational(
273 __isl_take isl_basic_map
*bmap
);
274 __isl_give isl_map
*isl_map_set_rational(__isl_take isl_map
*map
);
276 int isl_map_has_rational(__isl_keep isl_map
*map
);
277 int isl_set_has_rational(__isl_keep isl_set
*set
);
281 struct isl_basic_set
*isl_basic_set_preimage(struct isl_basic_set
*bset
,
282 struct isl_mat
*mat
);
283 struct isl_set
*isl_set_preimage(struct isl_set
*set
, struct isl_mat
*mat
);
285 __isl_give isl_basic_set
*isl_basic_set_transform_dims(
286 __isl_take isl_basic_set
*bset
, enum isl_dim_type type
, unsigned first
,
287 __isl_take isl_mat
*trans
);
289 isl_int
*isl_set_wrap_facet(__isl_keep isl_set
*set
,
290 isl_int
*facet
, isl_int
*ridge
);
292 int isl_basic_map_contains_point(__isl_keep isl_basic_map
*bmap
,
293 __isl_keep isl_point
*point
);
294 int isl_set_contains_point(__isl_keep isl_set
*set
, __isl_keep isl_point
*point
);
296 int isl_basic_set_vars_get_sign(__isl_keep isl_basic_set
*bset
,
297 unsigned first
, unsigned n
, int *signs
);
298 int isl_set_foreach_orthant(__isl_keep isl_set
*set
,
299 int (*fn
)(__isl_take isl_set
*orthant
, int *signs
, void *user
),
302 int isl_basic_map_add_div_constraints_var(__isl_keep isl_basic_map
*bmap
,
303 unsigned pos
, isl_int
*div
);
304 int isl_basic_set_add_div_constraints_var(__isl_keep isl_basic_set
*bset
,
305 unsigned pos
, isl_int
*div
);
306 int isl_basic_map_is_div_constraint(__isl_keep isl_basic_map
*bmap
,
307 isl_int
*constraint
, unsigned div
);
308 int isl_basic_set_is_div_constraint(__isl_keep isl_basic_set
*bset
,
309 isl_int
*constraint
, unsigned div
);
311 __isl_give isl_basic_set
*isl_basic_set_from_local_space(
312 __isl_take isl_local_space
*ls
);
313 __isl_give isl_basic_map
*isl_basic_map_from_local_space(
314 __isl_take isl_local_space
*ls
);
315 __isl_give isl_basic_set
*isl_basic_set_expand_divs(
316 __isl_take isl_basic_set
*bset
, __isl_take isl_mat
*div
, int *exp
);
318 int isl_basic_map_divs_known(__isl_keep isl_basic_map
*bmap
);
319 __isl_give isl_mat
*isl_basic_map_get_divs(__isl_keep isl_basic_map
*bmap
);
321 __isl_give isl_map
*isl_map_inline_foreach_basic_map(__isl_take isl_map
*map
,
322 __isl_give isl_basic_map
*(*fn
)(__isl_take isl_basic_map
*bmap
));
324 __isl_give isl_map
*isl_map_align_params_map_map_and(
325 __isl_take isl_map
*map1
, __isl_take isl_map
*map2
,
326 __isl_give isl_map
*(*fn
)(__isl_take isl_map
*map1
,
327 __isl_take isl_map
*map2
));
328 int isl_map_align_params_map_map_and_test(__isl_keep isl_map
*map1
,
329 __isl_keep isl_map
*map2
,
330 int (*fn
)(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
));
332 int isl_basic_map_foreach_lexopt(__isl_keep isl_basic_map
*bmap
, int max
,
333 int (*fn
)(__isl_take isl_basic_set
*dom
, __isl_take isl_aff_list
*list
,
336 int isl_basic_set_foreach_lexopt(__isl_keep isl_basic_set
*bset
, int max
,
337 int (*fn
)(__isl_take isl_basic_set
*dom
, __isl_take isl_aff_list
*list
,
341 __isl_give isl_set
*isl_set_substitute(__isl_take isl_set
*set
,
342 enum isl_dim_type type
, unsigned pos
, __isl_keep isl_aff
*subs
);
344 __isl_give isl_set
*isl_set_gist_params_basic_set(__isl_take isl_set
*set
,
345 __isl_take isl_basic_set
*context
);
347 int isl_map_compatible_range(__isl_keep isl_map
*map
, __isl_keep isl_set
*set
);
349 int isl_basic_map_plain_is_single_valued(__isl_keep isl_basic_map
*bmap
);
351 int isl_map_is_set(__isl_keep isl_map
*map
);