12 #if defined(__cplusplus)
18 * All structures are reference counted to allow reuse without duplication.
19 * A *_copy operation will increase the reference count, while a *_free
20 * operation will decrease the reference count and only actually release
21 * the structures when the reference count drops to zero.
23 * Functions that return an isa structure will in general _destroy_
24 * all argument isa structures (the obvious execption begin the _copy
25 * functions). A pointer passed to such a function may therefore
26 * never be used after the function call. If you want to keep a
27 * reference to the old structure(s), use the appropriate _copy function.
30 /* A "basic map" is a relation between two sets of variables,
31 * called the "in" and "out" variables.
33 * It is implemented as a set with two extra fields:
34 * n_in is the number of in variables
35 * n_out is the number of out variables
36 * n_in + n_out should be equal to set.dim
39 struct isl_basic_map {
41 #define ISL_BASIC_MAP_FINAL (1 << 0)
42 #define ISL_BASIC_MAP_EMPTY (1 << 1)
43 #define ISL_BASIC_MAP_NO_IMPLICIT (1 << 2)
44 #define ISL_BASIC_MAP_NO_REDUNDANT (1 << 3)
45 #define ISL_BASIC_MAP_RATIONAL (1 << 4)
46 #define ISL_BASIC_MAP_NORMALIZED (1 << 5)
47 #define ISL_BASIC_MAP_NORMALIZED_DIVS (1 << 6)
48 #define ISL_BASIC_MAP_ALL_EQUALITIES (1 << 7)
67 struct isl_vec *sample;
70 struct isl_blk block2;
72 typedef struct isl_basic_map isl_basic_map;
74 typedef struct isl_basic_set isl_basic_set;
76 /* A "map" is a (disjoint) union of basic maps.
78 * Currently, the isl_set structure is identical to the isl_map structure
79 * and the library depends on this correspondence internally.
80 * However, users should not depend on this correspondence.
84 #define ISL_MAP_DISJOINT (1 << 0)
85 #define ISL_MAP_NORMALIZED (1 << 1)
95 struct isl_basic_map *p[1];
97 typedef struct isl_map isl_map;
99 typedef struct isl_set isl_set;
101 unsigned isl_basic_map_n_in(const struct isl_basic_map *bmap);
102 unsigned isl_basic_map_n_out(const struct isl_basic_map *bmap);
103 unsigned isl_basic_map_n_param(const struct isl_basic_map *bmap);
104 unsigned isl_basic_map_n_div(const struct isl_basic_map *bmap);
105 unsigned isl_basic_map_total_dim(const struct isl_basic_map *bmap);
106 unsigned isl_basic_map_dim(const struct isl_basic_map *bmap,
107 enum isl_dim_type type);
109 unsigned isl_map_n_in(const struct isl_map *map);
110 unsigned isl_map_n_out(const struct isl_map *map);
111 unsigned isl_map_n_param(const struct isl_map *map);
112 unsigned isl_map_dim(const struct isl_map *map, enum isl_dim_type type);
114 struct isl_dim *isl_basic_map_get_dim(struct isl_basic_map *bmap);
115 struct isl_dim *isl_map_get_dim(struct isl_map *map);
117 struct isl_basic_map *isl_basic_map_alloc(struct isl_ctx *ctx,
118 unsigned nparam, unsigned in, unsigned out, unsigned extra,
119 unsigned n_eq, unsigned n_ineq);
120 __isl_give isl_basic_map *isl_basic_map_identity(__isl_take isl_dim *set_dim);
121 struct isl_basic_map *isl_basic_map_identity_like(struct isl_basic_map *model);
122 struct isl_basic_map *isl_basic_map_finalize(struct isl_basic_map *bmap);
123 void isl_basic_map_free(__isl_take isl_basic_map *bmap);
124 __isl_give isl_basic_map *isl_basic_map_copy(__isl_keep isl_basic_map *bmap);
125 struct isl_basic_map *isl_basic_map_extend(struct isl_basic_map *base,
126 unsigned nparam, unsigned n_in, unsigned n_out, unsigned extra,
127 unsigned n_eq, unsigned n_ineq);
128 struct isl_basic_map *isl_basic_map_extend_constraints(
129 struct isl_basic_map *base, unsigned n_eq, unsigned n_ineq);
130 struct isl_basic_map *isl_basic_map_equal(
131 struct isl_dim *dim, unsigned n_equal);
132 struct isl_basic_map *isl_basic_map_less_at(struct isl_dim *dim, unsigned pos);
133 struct isl_basic_map *isl_basic_map_more_at(struct isl_dim *dim, unsigned pos);
134 __isl_give isl_basic_map *isl_basic_map_empty(__isl_take isl_dim *dim);
135 struct isl_basic_map *isl_basic_map_empty_like(struct isl_basic_map *model);
136 struct isl_basic_map *isl_basic_map_empty_like_map(struct isl_map *model);
137 __isl_give isl_basic_map *isl_basic_map_universe(__isl_take isl_dim *dim);
138 __isl_give isl_basic_map *isl_basic_map_universe_like(
139 __isl_keep isl_basic_map *bmap);
140 struct isl_basic_map *isl_basic_map_convex_hull(struct isl_basic_map *bmap);
142 __isl_give isl_basic_map *isl_basic_map_intersect_domain(
143 __isl_take isl_basic_map *bmap,
144 __isl_take isl_basic_set *bset);
145 __isl_give isl_basic_map *isl_basic_map_intersect_range(
146 __isl_take isl_basic_map *bmap,
147 __isl_take isl_basic_set *bset);
148 __isl_give isl_basic_map *isl_basic_map_intersect(
149 __isl_take isl_basic_map *bmap1,
150 __isl_take isl_basic_map *bmap2);
151 __isl_give isl_map *isl_basic_map_union(
152 __isl_take isl_basic_map *bmap1,
153 __isl_take isl_basic_map *bmap2);
154 __isl_give isl_basic_map *isl_basic_map_apply_domain(
155 __isl_take isl_basic_map *bmap1,
156 __isl_take isl_basic_map *bmap2);
157 __isl_give isl_basic_map *isl_basic_map_apply_range(
158 __isl_take isl_basic_map *bmap1,
159 __isl_take isl_basic_map *bmap2);
160 __isl_give isl_basic_map *isl_basic_map_affine_hull(
161 __isl_take isl_basic_map *bmap);
162 struct isl_basic_map *isl_basic_map_reverse(struct isl_basic_map *bmap);
163 __isl_give isl_basic_set *isl_basic_map_domain(__isl_take isl_basic_map *bmap);
164 __isl_give isl_basic_set *isl_basic_map_range(__isl_take isl_basic_map *bmap);
165 struct isl_basic_map *isl_basic_map_remove(struct isl_basic_map *bmap,
166 enum isl_dim_type type, unsigned first, unsigned n);
167 struct isl_basic_map *isl_basic_map_from_basic_set(struct isl_basic_set *bset,
168 struct isl_dim *dim);
169 struct isl_basic_set *isl_basic_set_from_basic_map(struct isl_basic_map *bmap);
170 __isl_give isl_basic_map *isl_basic_map_sample(__isl_take isl_basic_map *bmap);
171 struct isl_basic_map *isl_basic_map_simplify(struct isl_basic_map *bmap);
172 struct isl_basic_map *isl_basic_map_detect_equalities(
173 struct isl_basic_map *bmap);
174 #define ISL_FORMAT_POLYLIB 1
175 #define ISL_FORMAT_OMEGA 2
176 __isl_give isl_basic_map *isl_basic_map_read_from_file(isl_ctx *ctx,
177 FILE *input, unsigned nparam, unsigned input_format);
178 struct isl_basic_map *isl_basic_map_fix_si(struct isl_basic_map *bmap,
179 enum isl_dim_type type, unsigned pos, int value);
181 struct isl_basic_map *isl_basic_map_sum(
182 struct isl_basic_map *bmap1, struct isl_basic_map *bmap2);
183 struct isl_basic_map *isl_basic_map_neg(struct isl_basic_map *bmap);
184 struct isl_basic_map *isl_basic_map_floordiv(struct isl_basic_map *bmap,
187 struct isl_map *isl_map_sum(struct isl_map *map1, struct isl_map *map2);
188 struct isl_map *isl_map_neg(struct isl_map *map);
189 struct isl_map *isl_map_floordiv(struct isl_map *map, isl_int d);
191 int isl_basic_map_is_equal(
192 __isl_keep isl_basic_map *bmap1,
193 __isl_keep isl_basic_map *bmap2);
195 __isl_give isl_map *isl_basic_map_partial_lexmax(
196 __isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
197 __isl_give isl_set **empty);
198 __isl_give isl_map *isl_basic_map_partial_lexmin(
199 __isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
200 __isl_give isl_set **empty);
202 void isl_basic_map_dump(__isl_keep isl_basic_map *bmap, FILE *out, int indent);
204 struct isl_basic_map *isl_map_copy_basic_map(struct isl_map *map);
205 struct isl_map *isl_map_drop_basic_map(struct isl_map *map,
206 struct isl_basic_map *bmap);
208 int isl_basic_map_fast_is_fixed(struct isl_basic_map *bmap,
209 enum isl_dim_type type, unsigned pos, isl_int *val);
211 int isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
212 int isl_basic_map_fast_is_empty(__isl_keep isl_basic_map *bmap);
213 int isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap);
214 int isl_basic_map_is_subset(__isl_keep isl_basic_map *bmap1,
215 __isl_keep isl_basic_map *bmap2);
216 int isl_basic_map_is_strict_subset(__isl_keep isl_basic_map *bmap1,
217 __isl_keep isl_basic_map *bmap2);
219 struct isl_map *isl_map_alloc(struct isl_ctx *ctx,
220 unsigned nparam, unsigned in, unsigned out, int n,
222 __isl_give isl_map *isl_map_universe(__isl_take isl_dim *dim);
223 __isl_give isl_map *isl_map_empty(__isl_take isl_dim *dim);
224 struct isl_map *isl_map_empty_like(struct isl_map *model);
225 struct isl_map *isl_map_empty_like_basic_map(struct isl_basic_map *model);
226 struct isl_map *isl_map_dup(struct isl_map *map);
227 struct isl_map *isl_map_add(struct isl_map *map, struct isl_basic_map *bmap);
228 __isl_give isl_map *isl_map_identity(__isl_take isl_dim *set_dim);
229 struct isl_map *isl_map_identity_like(struct isl_map *model);
230 struct isl_map *isl_map_identity_like_basic_map(struct isl_basic_map *model);
231 __isl_give isl_map *isl_map_lex_lt(__isl_take isl_dim *set_dim);
232 __isl_give isl_map *isl_map_lex_le(__isl_take isl_dim *set_dim);
233 __isl_give isl_map *isl_map_lex_gt(__isl_take isl_dim *set_dim);
234 __isl_give isl_map *isl_map_lex_ge(__isl_take isl_dim *set_dim);
235 struct isl_map *isl_map_finalize(struct isl_map *map);
236 void isl_map_free(__isl_take isl_map *map);
237 __isl_give isl_map *isl_map_copy(__isl_keep isl_map *map);
238 struct isl_map *isl_map_extend(struct isl_map *base,
239 unsigned nparam, unsigned n_in, unsigned n_out);
240 struct isl_map *isl_map_reverse(struct isl_map *map);
241 __isl_give isl_map *isl_map_union(
242 __isl_take isl_map *map1,
243 __isl_take isl_map *map2);
244 struct isl_map *isl_map_union_disjoint(
245 struct isl_map *map1, struct isl_map *map2);
246 __isl_give isl_map *isl_map_intersect_domain(
247 __isl_take isl_map *map,
248 __isl_take isl_set *set);
249 __isl_give isl_map *isl_map_intersect_range(
250 __isl_take isl_map *map,
251 __isl_take isl_set *set);
252 __isl_give isl_map *isl_map_apply_domain(
253 __isl_take isl_map *map1,
254 __isl_take isl_map *map2);
255 __isl_give isl_map *isl_map_apply_range(
256 __isl_take isl_map *map1,
257 __isl_take isl_map *map2);
258 struct isl_map *isl_map_product(struct isl_map *map1, struct isl_map *map2);
259 __isl_give isl_map *isl_map_intersect(__isl_take isl_map *map1,
260 __isl_take isl_map *map2);
261 __isl_give isl_map *isl_map_subtract(
262 __isl_take isl_map *map1,
263 __isl_take isl_map *map2);
264 struct isl_map *isl_map_fix_input_si(struct isl_map *map,
265 unsigned input, int value);
266 struct isl_map *isl_map_fix_si(struct isl_map *map,
267 enum isl_dim_type type, unsigned pos, int value);
268 struct isl_basic_set *isl_basic_map_deltas(struct isl_basic_map *bmap);
269 struct isl_set *isl_map_deltas(struct isl_map *map);
270 struct isl_map *isl_map_detect_equalities(struct isl_map *map);
271 __isl_give isl_basic_map *isl_map_affine_hull(__isl_take isl_map *map);
272 __isl_give isl_basic_map *isl_map_convex_hull(__isl_take isl_map *map);
273 struct isl_map *isl_map_remove(struct isl_map *map,
274 enum isl_dim_type type, unsigned first, unsigned n);
275 struct isl_map *isl_map_remove_inputs(struct isl_map *map,
276 unsigned first, unsigned n);
278 __isl_give isl_set *isl_map_domain(__isl_take isl_map *bmap);
279 __isl_give isl_set *isl_map_range(__isl_take isl_map *map);
280 __isl_give isl_map *isl_map_from_basic_map(__isl_take isl_basic_map *bmap);
281 struct isl_map *isl_map_from_range(struct isl_set *set);
282 struct isl_map *isl_map_from_set(struct isl_set *set, struct isl_dim *dim);
283 struct isl_set *isl_set_from_map(struct isl_map *map);
284 __isl_give isl_basic_map *isl_map_sample(__isl_take isl_map *map);
286 int isl_map_fast_is_empty(__isl_keep isl_map *map);
287 int isl_map_is_empty(__isl_keep isl_map *map);
288 int isl_map_is_subset(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
289 int isl_map_is_strict_subset(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
290 int isl_map_is_equal(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
292 void isl_map_dump(__isl_keep isl_map *map, FILE *out, int indent);
294 int isl_map_fast_input_is_fixed(struct isl_map *map,
295 unsigned in, isl_int *val);
296 int isl_map_fast_is_fixed(struct isl_map *map,
297 enum isl_dim_type type, unsigned pos, isl_int *val);
299 __isl_give isl_basic_map *isl_basic_map_gist(__isl_take isl_basic_map *bmap,
300 __isl_take isl_basic_map *context);
302 __isl_give isl_map *isl_map_coalesce(__isl_take isl_map *map);
304 int isl_map_fast_is_equal(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
306 #if defined(__cplusplus)