Line 0
Link Here
|
|
|
1 |
$NetBSD: patch-include_cloog_isl_constraintset.h,v 1.1 2014/04/25 21:01:27 wiz Exp $ |
2 |
$NetBSD: patch-source_isl_constraints.c,v 1.1 2014/04/25 21:01:27 wiz Exp $ |
3 |
$NetBSD: patch-source_isl_domain.c,v 1.1 2014/04/25 21:01:27 wiz Exp $ |
4 |
|
5 |
From: Taj Muhammad Khan <taj.khan@lri.fr> |
6 |
Date: Thu, 5 Dec 2013 02:25:16 +0000 (+0530) |
7 |
Subject: Use isl_val instead of isl_int |
8 |
X-Git-Url: http://repo.or.cz/w/cloog.git/commitdiff_plain/2d8b7c6 |
9 |
|
10 |
Use isl_val instead of isl_int |
11 |
|
12 |
isl is moving from the macro-based isl_int to a more generic |
13 |
integer type isl_val, so CLooG does with this patch. |
14 |
Authors are Uday Bondhugula, Taj Muhammad Khan and Cedric Bastoul. |
15 |
|
16 |
--- include/cloog/isl/constraintset.h.orig 2013-10-11 07:27:03.000000000 +0000 |
17 |
+++ include/cloog/isl/constraintset.h |
18 |
@@ -27,6 +27,12 @@ CloogConstraintSet *cloog_constraint_set |
19 |
CloogConstraint *cloog_constraint_from_isl_constraint(struct isl_constraint *constraint); |
20 |
isl_constraint *cloog_constraint_to_isl(CloogConstraint *constraint); |
21 |
|
22 |
+__isl_give isl_val *cloog_int_to_isl_val(isl_ctx* ctx, cloog_int_t c); |
23 |
+void isl_val_to_cloog_int(__isl_keep isl_val *val, cloog_int_t *cint); |
24 |
+ |
25 |
+__isl_give isl_val *cloog_constraint_coefficient_get_val(CloogConstraint *constraint, |
26 |
+ int var); |
27 |
+ |
28 |
#if defined(__cplusplus) |
29 |
} |
30 |
#endif |
31 |
--- source/isl/constraints.c.orig 2013-10-11 07:27:03.000000000 +0000 |
32 |
+++ source/isl/constraints.c |
33 |
@@ -5,11 +5,51 @@ |
34 |
#include <cloog/isl/backend.h> |
35 |
#include <isl/aff.h> |
36 |
#include <isl/set.h> |
37 |
+#include <isl/val.h> |
38 |
+#include <isl/val_gmp.h> |
39 |
|
40 |
|
41 |
#define ALLOC(type) (type*)malloc(sizeof(type)) |
42 |
#define ALLOCN(type,n) (type*)malloc((n)*sizeof(type)) |
43 |
|
44 |
+__isl_give isl_val *cloog_int_to_isl_val(isl_ctx* ctx, cloog_int_t c) |
45 |
+{ |
46 |
+ isl_val *v; |
47 |
+#if defined(CLOOG_INT_INT) |
48 |
+ v = isl_val_int_from_si(ctx, c); |
49 |
+#elif defined(CLOOG_INT_LONG) |
50 |
+ v = isl_val_int_from_si(ctx, c); |
51 |
+#elif defined(CLOOG_INT_LONG_LONG) |
52 |
+ v = isl_val_int_from_si(ctx, c); |
53 |
+#elif defined(CLOOG_INT_GMP) |
54 |
+ v = isl_val_int_from_gmp(ctx, c); |
55 |
+#else |
56 |
+#error "No integer type defined" |
57 |
+#endif |
58 |
+ return v; |
59 |
+} |
60 |
+ |
61 |
+/* |
62 |
+ * CLooG'll be dealing in integers so we expect numerator/1 form |
63 |
+ * from isl_val. Thus get numerator to assign to cloog_int |
64 |
+ */ |
65 |
+void isl_val_to_cloog_int(__isl_keep isl_val *val, cloog_int_t *cint) |
66 |
+{ |
67 |
+ assert(isl_val_is_int(val)); |
68 |
+#if defined(CLOOG_INT_INT) |
69 |
+ *cint = isl_val_get_num_si(val); |
70 |
+#elif defined(CLOOG_INT_LONG) |
71 |
+ *cint = isl_val_get_num_si(val); |
72 |
+#elif defined(CLOOG_INT_LONG_LONG) |
73 |
+ *cint = isl_val_get_num_si(val); |
74 |
+#elif defined(CLOOG_INT_GMP) |
75 |
+ isl_val_get_num_gmp(val, *cint); |
76 |
+#else |
77 |
+#error "No integer type defined" |
78 |
+#endif |
79 |
+} |
80 |
+ |
81 |
+ |
82 |
CloogConstraintSet *cloog_constraint_set_from_isl_basic_set(struct isl_basic_set *bset) |
83 |
{ |
84 |
return (CloogConstraintSet *)bset; |
85 |
@@ -266,53 +306,65 @@ int cloog_equal_count(CloogEqualities *e |
86 |
static int cloog_constraint_equal_type(CloogConstraint *cc, int level) |
87 |
{ |
88 |
int i; |
89 |
- isl_int c; |
90 |
+ isl_val *c; |
91 |
int type = EQTYPE_NONE; |
92 |
struct isl_constraint *constraint = cloog_constraint_to_isl(cc); |
93 |
|
94 |
- isl_int_init(c); |
95 |
- isl_constraint_get_constant(constraint, &c); |
96 |
- if (!isl_int_is_zero(c)) |
97 |
+ c = isl_constraint_get_constant_val(constraint); |
98 |
+ if (!isl_val_is_zero(c)) |
99 |
type = EQTYPE_CONSTANT; |
100 |
- isl_constraint_get_coefficient(constraint, isl_dim_set, level - 1, &c); |
101 |
- if (!isl_int_is_one(c) && !isl_int_is_negone(c)) |
102 |
+ isl_val_free(c); |
103 |
+ c = isl_constraint_get_coefficient_val(constraint, isl_dim_set, level - 1); |
104 |
+ if (!isl_val_is_one(c) && !isl_val_is_negone(c)) |
105 |
type = EQTYPE_EXAFFINE; |
106 |
+ isl_val_free(c); |
107 |
for (i = 0; i < isl_constraint_dim(constraint, isl_dim_param); ++i) { |
108 |
- isl_constraint_get_coefficient(constraint, isl_dim_param, i, &c); |
109 |
- if (isl_int_is_zero(c)) |
110 |
+ c = isl_constraint_get_coefficient_val(constraint, isl_dim_param, i); |
111 |
+ if (isl_val_is_zero(c)){ |
112 |
+ isl_val_free(c); |
113 |
continue; |
114 |
- if ((!isl_int_is_one(c) && !isl_int_is_negone(c)) || |
115 |
+ } |
116 |
+ if ((!isl_val_is_one(c) && !isl_val_is_negone(c)) || |
117 |
type != EQTYPE_NONE) { |
118 |
type = EQTYPE_EXAFFINE; |
119 |
+ isl_val_free(c); |
120 |
break; |
121 |
} |
122 |
type = EQTYPE_PUREITEM; |
123 |
+ isl_val_free(c); |
124 |
} |
125 |
for (i = 0; i < isl_constraint_dim(constraint, isl_dim_set); ++i) { |
126 |
if (i == level - 1) |
127 |
continue; |
128 |
- isl_constraint_get_coefficient(constraint, isl_dim_set, i, &c); |
129 |
- if (isl_int_is_zero(c)) |
130 |
+ c = isl_constraint_get_coefficient_val(constraint, isl_dim_set, i); |
131 |
+ if (isl_val_is_zero(c)){ |
132 |
+ isl_val_free(c); |
133 |
continue; |
134 |
- if ((!isl_int_is_one(c) && !isl_int_is_negone(c)) || |
135 |
+ } |
136 |
+ if ((!isl_val_is_one(c) && !isl_val_is_negone(c)) || |
137 |
type != EQTYPE_NONE) { |
138 |
type = EQTYPE_EXAFFINE; |
139 |
+ isl_val_free(c); |
140 |
break; |
141 |
} |
142 |
type = EQTYPE_PUREITEM; |
143 |
+ isl_val_free(c); |
144 |
} |
145 |
for (i = 0; i < isl_constraint_dim(constraint, isl_dim_div); ++i) { |
146 |
- isl_constraint_get_coefficient(constraint, isl_dim_div, i, &c); |
147 |
- if (isl_int_is_zero(c)) |
148 |
+ c = isl_constraint_get_coefficient_val(constraint, isl_dim_div, i); |
149 |
+ if (isl_val_is_zero(c)){ |
150 |
+ isl_val_free(c); |
151 |
continue; |
152 |
- if ((!isl_int_is_one(c) && !isl_int_is_negone(c)) || |
153 |
+ } |
154 |
+ if ((!isl_val_is_one(c) && !isl_val_is_negone(c)) || |
155 |
type != EQTYPE_NONE) { |
156 |
type = EQTYPE_EXAFFINE; |
157 |
+ isl_val_free(c); |
158 |
break; |
159 |
} |
160 |
type = EQTYPE_PUREITEM; |
161 |
+ isl_val_free(c); |
162 |
} |
163 |
- isl_int_clear(c); |
164 |
|
165 |
if (type == EQTYPE_NONE) |
166 |
type = EQTYPE_CONSTANT; |
167 |
@@ -447,27 +499,31 @@ static struct clast_expr *div_expr(Cloog |
168 |
{ |
169 |
int i, nb_elts; |
170 |
unsigned dim = cloog_constraint_total_dimension(constraint); |
171 |
- cloog_int_t c; |
172 |
+ isl_val *c; |
173 |
struct clast_reduction *r; |
174 |
struct clast_expr *e = NULL; |
175 |
isl_aff *div; |
176 |
+ cloog_int_t cint; |
177 |
|
178 |
+ cloog_int_init(cint); |
179 |
div = isl_constraint_get_div(cloog_constraint_to_isl(constraint), pos); |
180 |
|
181 |
- cloog_int_init(c); |
182 |
for (i = 0, nb_elts = 0; i < dim; ++i) { |
183 |
struct cloog_isl_dim dim; |
184 |
|
185 |
dim = constraint_cloog_dim_to_isl_dim(constraint, i); |
186 |
if (dim.type == isl_dim_set) |
187 |
dim.type = isl_dim_in; |
188 |
- isl_aff_get_coefficient(div, dim.type, dim.pos, &c); |
189 |
- if (!cloog_int_is_zero(c)) |
190 |
+ c = isl_aff_get_coefficient_val(div, dim.type, dim.pos); |
191 |
+ if (!isl_val_is_zero(c)) |
192 |
++nb_elts; |
193 |
+ |
194 |
+ isl_val_free(c); |
195 |
} |
196 |
- isl_aff_get_constant(div, &c); |
197 |
- if (!cloog_int_is_zero(c)) |
198 |
+ c = isl_aff_get_constant_val(div); |
199 |
+ if (!isl_val_is_zero(c)) |
200 |
++nb_elts; |
201 |
+ isl_val_free(c); |
202 |
|
203 |
r = new_clast_reduction(clast_red_sum, nb_elts); |
204 |
for (i = 0, nb_elts = 0; i < dim; ++i) { |
205 |
@@ -477,22 +533,35 @@ static struct clast_expr *div_expr(Cloog |
206 |
dim = constraint_cloog_dim_to_isl_dim(constraint, i); |
207 |
if (dim.type == isl_dim_set) |
208 |
dim.type = isl_dim_in; |
209 |
- isl_aff_get_coefficient(div, dim.type, dim.pos, &c); |
210 |
- if (cloog_int_is_zero(c)) |
211 |
+ c = isl_aff_get_coefficient_val(div, dim.type, dim.pos); |
212 |
+ if (isl_val_is_zero(c)){ |
213 |
+ isl_val_free(c); |
214 |
continue; |
215 |
+ } |
216 |
|
217 |
v = cloog_constraint_variable_expr(constraint, 1 + i, names); |
218 |
|
219 |
- r->elts[nb_elts++] = &new_clast_term(c, v)->expr; |
220 |
+ /* We are interested only in the numerator */ |
221 |
+ cloog_int_set_si(cint, isl_val_get_num_si(c)); |
222 |
+ r->elts[nb_elts++] = &new_clast_term(cint, v)->expr; |
223 |
+ |
224 |
+ isl_val_free(c); |
225 |
} |
226 |
- isl_aff_get_constant(div, &c); |
227 |
- if (!cloog_int_is_zero(c)) |
228 |
- r->elts[nb_elts++] = &new_clast_term(c, NULL)->expr; |
229 |
|
230 |
- isl_aff_get_denominator(div, &c); |
231 |
- e = &new_clast_binary(clast_bin_fdiv, &r->expr, c)->expr; |
232 |
+ c = isl_aff_get_constant_val(div); |
233 |
+ if (!isl_val_is_zero(c)) { |
234 |
+ /* We are interested only in the numerator */ |
235 |
+ cloog_int_set_si(cint, isl_val_get_num_si(c)); |
236 |
+ r->elts[nb_elts++] = &new_clast_term(cint, NULL)->expr; |
237 |
+ } |
238 |
+ isl_val_free(c); |
239 |
|
240 |
- cloog_int_clear(c); |
241 |
+ c = isl_aff_get_denominator_val(div); |
242 |
+ isl_val_to_cloog_int(c, &cint); |
243 |
+ isl_val_free(c); |
244 |
+ e = &new_clast_binary(clast_bin_fdiv, &r->expr, cint)->expr; |
245 |
+ |
246 |
+ cloog_int_clear(cint); |
247 |
|
248 |
isl_aff_free(div); |
249 |
|
250 |
@@ -529,37 +598,34 @@ struct clast_expr *cloog_constraint_vari |
251 |
*/ |
252 |
int cloog_constraint_involves(CloogConstraint *constraint, int v) |
253 |
{ |
254 |
- isl_int c; |
255 |
+ isl_val *c; |
256 |
int res; |
257 |
|
258 |
- isl_int_init(c); |
259 |
- cloog_constraint_coefficient_get(constraint, v, &c); |
260 |
- res = !isl_int_is_zero(c); |
261 |
- isl_int_clear(c); |
262 |
+ c = cloog_constraint_coefficient_get_val(constraint, v); |
263 |
+ res = !isl_val_is_zero(c); |
264 |
+ isl_val_free(c); |
265 |
return res; |
266 |
} |
267 |
|
268 |
int cloog_constraint_is_lower_bound(CloogConstraint *constraint, int v) |
269 |
{ |
270 |
- isl_int c; |
271 |
+ isl_val *c; |
272 |
int res; |
273 |
|
274 |
- isl_int_init(c); |
275 |
- cloog_constraint_coefficient_get(constraint, v, &c); |
276 |
- res = isl_int_is_pos(c); |
277 |
- isl_int_clear(c); |
278 |
+ c = cloog_constraint_coefficient_get_val(constraint, v); |
279 |
+ res = isl_val_is_pos(c); |
280 |
+ isl_val_free(c); |
281 |
return res; |
282 |
} |
283 |
|
284 |
int cloog_constraint_is_upper_bound(CloogConstraint *constraint, int v) |
285 |
{ |
286 |
- isl_int c; |
287 |
+ isl_val *c; |
288 |
int res; |
289 |
|
290 |
- isl_int_init(c); |
291 |
- cloog_constraint_coefficient_get(constraint, v, &c); |
292 |
- res = isl_int_is_neg(c); |
293 |
- isl_int_clear(c); |
294 |
+ c = cloog_constraint_coefficient_get_val(constraint, v); |
295 |
+ res = isl_val_is_neg(c); |
296 |
+ isl_val_free(c); |
297 |
return res; |
298 |
} |
299 |
|
300 |
@@ -585,15 +651,37 @@ void cloog_constraint_coefficient_get(Cl |
301 |
{ |
302 |
struct cloog_isl_dim dim; |
303 |
isl_constraint *c; |
304 |
+ isl_val *ival; |
305 |
|
306 |
if (!constraint) |
307 |
- return; |
308 |
+ val = NULL; |
309 |
|
310 |
dim = constraint_cloog_dim_to_isl_dim(constraint, var); |
311 |
c = cloog_constraint_to_isl(constraint); |
312 |
- isl_constraint_get_coefficient(c, dim.type, dim.pos, val); |
313 |
+ ival = isl_constraint_get_coefficient_val(c, dim.type, dim.pos); |
314 |
+ |
315 |
+ isl_val_to_cloog_int(ival, val); |
316 |
+ isl_val_free(ival); |
317 |
} |
318 |
|
319 |
+isl_val *cloog_constraint_coefficient_get_val(CloogConstraint *constraint, |
320 |
+ int var) |
321 |
+{ |
322 |
+ struct cloog_isl_dim dim; |
323 |
+ isl_constraint *c; |
324 |
+ isl_val *val; |
325 |
+ |
326 |
+ if (!constraint) |
327 |
+ return NULL; |
328 |
+ |
329 |
+ dim = constraint_cloog_dim_to_isl_dim(constraint, var); |
330 |
+ c = cloog_constraint_to_isl(constraint); |
331 |
+ val = isl_constraint_get_coefficient_val(c, dim.type, dim.pos); |
332 |
+ return val; |
333 |
+} |
334 |
+ |
335 |
+ |
336 |
+ |
337 |
void cloog_constraint_coefficient_set(CloogConstraint *constraint, |
338 |
int var, cloog_int_t val) |
339 |
{ |
340 |
@@ -604,14 +692,26 @@ void cloog_constraint_coefficient_set(Cl |
341 |
|
342 |
dim = constraint_cloog_dim_to_isl_dim(constraint, var); |
343 |
c = cloog_constraint_to_isl(constraint); |
344 |
- isl_constraint_set_coefficient(c, dim.type, dim.pos, val); |
345 |
+ isl_constraint_set_coefficient_val(c, dim.type, dim.pos, |
346 |
+ cloog_int_to_isl_val(isl_constraint_get_ctx(c), val)); |
347 |
} |
348 |
|
349 |
void cloog_constraint_constant_get(CloogConstraint *constraint, cloog_int_t *val) |
350 |
{ |
351 |
- isl_constraint_get_constant(cloog_constraint_to_isl(constraint), val); |
352 |
+ isl_val *ival; |
353 |
+ ival = isl_constraint_get_constant_val(cloog_constraint_to_isl(constraint)); |
354 |
+ isl_val_to_cloog_int(ival, val); |
355 |
+ isl_val_free(ival); |
356 |
} |
357 |
|
358 |
+ |
359 |
+__isl_give isl_val *cloog_constraint_constant_get_val(CloogConstraint *constraint) |
360 |
+{ |
361 |
+ return isl_constraint_get_constant_val(cloog_constraint_to_isl(constraint)); |
362 |
+} |
363 |
+ |
364 |
+ |
365 |
+ |
366 |
/** |
367 |
* Copy the coefficient of constraint c into dst in PolyLib order, |
368 |
* i.e., first the coefficients of the variables, then the coefficients |
369 |
@@ -700,15 +800,11 @@ CloogConstraintSet *cloog_constraint_set |
370 |
|
371 |
static int add_constant_term(CloogConstraint *c, void *user) |
372 |
{ |
373 |
- isl_int *bound = (isl_int *)user; |
374 |
- isl_int v; |
375 |
- |
376 |
- isl_int_init(v); |
377 |
+ isl_val **bound = (isl_val **)user; |
378 |
+ isl_val *v; |
379 |
|
380 |
- cloog_constraint_constant_get(c, &v); |
381 |
- isl_int_add(*bound, *bound, v); |
382 |
- |
383 |
- isl_int_clear(v); |
384 |
+ v = cloog_constraint_constant_get_val(c); |
385 |
+ *bound = isl_val_add(*bound, v); |
386 |
|
387 |
return 0; |
388 |
} |
389 |
@@ -822,11 +918,14 @@ CloogConstraintSet *cloog_constraint_set |
390 |
c = isl_constraint_set_coefficient_si(c, isl_dim_set, dim.pos, -1); |
391 |
bset = isl_basic_set_add_constraint(bset, c); |
392 |
|
393 |
- isl_int_set_si(*bound, 0); |
394 |
+ cloog_int_set_si(*bound, 0); |
395 |
+ isl_val *v = cloog_int_to_isl_val(isl_basic_set_get_ctx(bset), *bound); |
396 |
constraints = cloog_constraint_set_from_isl_basic_set(bset); |
397 |
cloog_constraint_set_foreach_constraint(constraints, |
398 |
- add_constant_term, bound); |
399 |
+ add_constant_term, &v); |
400 |
+ isl_val_to_cloog_int(v, bound); //return the value to bound |
401 |
|
402 |
+ isl_val_free(v); |
403 |
isl_basic_set_free(orig); |
404 |
return cloog_constraint_set_from_isl_basic_set(bset); |
405 |
} |
406 |
@@ -896,31 +995,27 @@ static isl_aff *extract_stride_offset(__ |
407 |
isl_space *dim = isl_constraint_get_space(c); |
408 |
isl_local_space *ls = isl_local_space_from_space(dim); |
409 |
isl_aff *offset = isl_aff_zero_on_domain(ls); |
410 |
- isl_int u; |
411 |
+ isl_val *u; |
412 |
unsigned nparam, nvar; |
413 |
|
414 |
- isl_int_init(u); |
415 |
- |
416 |
nparam = isl_constraint_dim(c, isl_dim_param); |
417 |
nvar = isl_constraint_dim(c, isl_dim_set); |
418 |
|
419 |
for (i = 0; i < nparam; ++i) { |
420 |
- isl_constraint_get_coefficient(c, isl_dim_param, i, &u); |
421 |
- isl_int_mul(u, u, stride->factor); |
422 |
- offset = isl_aff_set_coefficient(offset, isl_dim_param, i, u); |
423 |
+ u = isl_constraint_get_coefficient_val(c, isl_dim_param, i); |
424 |
+ u = isl_val_mul(u, cloog_int_to_isl_val(isl_constraint_get_ctx(c), stride->factor)); |
425 |
+ offset = isl_aff_set_coefficient_val(offset, isl_dim_param, i, u); |
426 |
} |
427 |
for (i = 0; i < nvar; ++i) { |
428 |
if (i == level - 1) |
429 |
continue; |
430 |
- isl_constraint_get_coefficient(c, isl_dim_set, i, &u); |
431 |
- isl_int_mul(u, u, stride->factor); |
432 |
- offset = isl_aff_set_coefficient(offset, isl_dim_in, i, u); |
433 |
- } |
434 |
- isl_constraint_get_constant(c, &u); |
435 |
- isl_int_mul(u, u, stride->factor); |
436 |
- offset = isl_aff_set_constant(offset, u); |
437 |
- |
438 |
- isl_int_clear(u); |
439 |
+ u = isl_constraint_get_coefficient_val(c, isl_dim_set, i); |
440 |
+ u = isl_val_mul(u, cloog_int_to_isl_val(isl_constraint_get_ctx(c), stride->factor)); |
441 |
+ offset = isl_aff_set_coefficient_val(offset, isl_dim_in, i, u); |
442 |
+ } |
443 |
+ u = isl_constraint_get_constant_val(c); |
444 |
+ u = isl_val_mul(u, cloog_int_to_isl_val(isl_constraint_get_ctx(c), stride->factor)); |
445 |
+ offset = isl_aff_set_constant_val(offset, u); |
446 |
|
447 |
return offset; |
448 |
} |
449 |
@@ -953,9 +1048,9 @@ CloogConstraint *cloog_constraint_stride |
450 |
offset = extract_stride_offset(stride_c, level, stride); |
451 |
|
452 |
lower = isl_aff_sub(lower, isl_aff_copy(offset)); |
453 |
- lower = isl_aff_scale_down(lower, stride->stride); |
454 |
+ lower = isl_aff_scale_down_val(lower, cloog_int_to_isl_val(isl_constraint_get_ctx(stride_c), stride->stride)); |
455 |
lower = isl_aff_ceil(lower); |
456 |
- lower = isl_aff_scale(lower, stride->stride); |
457 |
+ lower = isl_aff_scale_val(lower, cloog_int_to_isl_val(isl_constraint_get_ctx(stride_c), stride->stride)); |
458 |
lower = isl_aff_add(lower, offset); |
459 |
lower = isl_aff_neg(lower); |
460 |
lower = isl_aff_add_coefficient_si(lower, isl_dim_in, level - 1, 1); |
461 |
--- source/isl/domain.c.orig 2013-10-11 07:27:03.000000000 +0000 |
462 |
+++ source/isl/domain.c |
463 |
@@ -7,7 +7,11 @@ |
464 |
#include <isl/list.h> |
465 |
#include <isl/constraint.h> |
466 |
#include <isl/ilp.h> |
467 |
+#include <isl/lp.h> |
468 |
#include <isl/aff.h> |
469 |
+#include <isl/map.h> |
470 |
+#include <isl/val.h> |
471 |
+#include <isl/val_gmp.h> |
472 |
|
473 |
#ifdef OSL_SUPPORT |
474 |
#include <osl/macros.h> |
475 |
@@ -510,15 +514,18 @@ static struct isl_constraint *isl_constr |
476 |
else |
477 |
constraint = isl_inequality_alloc(ls); |
478 |
|
479 |
- for (j = 0; j < nvariables; ++j) |
480 |
- isl_constraint_set_coefficient(constraint, isl_dim_out, j, |
481 |
- row[1 + j]); |
482 |
- |
483 |
- for (j = 0; j < nparam; ++j) |
484 |
- isl_constraint_set_coefficient(constraint, isl_dim_param, j, |
485 |
- row[1 + nvariables + j]); |
486 |
+ for (j = 0; j < nvariables; ++j) { |
487 |
+ isl_val *val = cloog_int_to_isl_val(isl_constraint_get_ctx(constraint), row[1 + j]); |
488 |
+ isl_constraint_set_coefficient_val(constraint, isl_dim_out, j, val); |
489 |
+ } |
490 |
+ |
491 |
+ for (j = 0; j < nparam; ++j) { |
492 |
+ isl_val *val = cloog_int_to_isl_val(isl_constraint_get_ctx(constraint), row[1 + nvariables + j]); |
493 |
+ isl_constraint_set_coefficient_val(constraint, isl_dim_param, j, val); |
494 |
+ } |
495 |
|
496 |
- isl_constraint_set_constant(constraint, row[1 + nvariables + nparam]); |
497 |
+ isl_val *val = cloog_int_to_isl_val(isl_constraint_get_ctx(constraint), row[1 + nvariables + nparam]); |
498 |
+ isl_constraint_set_constant_val(constraint, val); |
499 |
|
500 |
return constraint; |
501 |
} |
502 |
@@ -631,7 +638,6 @@ CloogDomain *cloog_domain_from_osl_relat |
503 |
return domain; |
504 |
} |
505 |
|
506 |
- |
507 |
/** |
508 |
* Converts an openscop scattering relation to a CLooG scattering. |
509 |
* \param[in,out] state CLooG state. |
510 |
@@ -779,10 +785,22 @@ int cloog_domain_is_otl(CloogDomain *dom |
511 |
void cloog_domain_stride(CloogDomain *domain, int strided_level, |
512 |
cloog_int_t *stride, cloog_int_t *offset) |
513 |
{ |
514 |
+ int ret = -1; |
515 |
isl_set *set = isl_set_from_cloog_domain(domain); |
516 |
- isl_set_dim_residue_class(set, strided_level - 1, stride, offset); |
517 |
- if (!isl_int_is_zero(*offset)) |
518 |
- isl_int_sub(*offset, *stride, *offset); |
519 |
+ isl_val *stride_val = NULL; |
520 |
+ isl_val *offset_val = NULL; |
521 |
+ ret = isl_set_dim_residue_class_val(set, strided_level - 1, &stride_val, &offset_val); |
522 |
+ if (ret != 0) |
523 |
+ cloog_die("failure to compute stride.\n"); |
524 |
+ isl_val_to_cloog_int(stride_val, stride); |
525 |
+ isl_val_to_cloog_int(offset_val, offset); |
526 |
+ |
527 |
+ if (!cloog_int_is_zero(*offset)) |
528 |
+ cloog_int_sub(*offset, *stride, *offset); |
529 |
+ |
530 |
+ isl_val_free(stride_val); |
531 |
+ isl_val_free(offset_val); |
532 |
+ |
533 |
return; |
534 |
} |
535 |
|
536 |
@@ -796,7 +814,7 @@ static int constraint_can_stride(__isl_t |
537 |
{ |
538 |
struct cloog_can_stride *ccs = (struct cloog_can_stride *)user; |
539 |
int i; |
540 |
- isl_int v; |
541 |
+ isl_val *v; |
542 |
unsigned n_div; |
543 |
|
544 |
if (isl_constraint_is_equality(c)) { |
545 |
@@ -804,21 +822,22 @@ static int constraint_can_stride(__isl_t |
546 |
return 0; |
547 |
} |
548 |
|
549 |
- isl_int_init(v); |
550 |
- isl_constraint_get_coefficient(c, isl_dim_set, ccs->level - 1, &v); |
551 |
- if (isl_int_is_pos(v)) { |
552 |
+ v = isl_constraint_get_coefficient_val(c, isl_dim_set, ccs->level - 1); |
553 |
+ if (isl_val_is_pos(v)) { |
554 |
n_div = isl_constraint_dim(c, isl_dim_div); |
555 |
+ |
556 |
for (i = 0; i < n_div; ++i) { |
557 |
- isl_constraint_get_coefficient(c, isl_dim_div, i, &v); |
558 |
- if (!isl_int_is_zero(v)) |
559 |
+ isl_val_free(v); |
560 |
+ v = isl_constraint_get_coefficient_val(c, isl_dim_div, i); |
561 |
+ if (!isl_val_is_zero(v)) |
562 |
break; |
563 |
} |
564 |
if (i < n_div) |
565 |
ccs->can_stride = 0; |
566 |
} |
567 |
- isl_int_clear(v); |
568 |
- isl_constraint_free(c); |
569 |
+ isl_val_free(v); |
570 |
|
571 |
+ isl_constraint_free(c); |
572 |
return 0; |
573 |
} |
574 |
|
575 |
@@ -903,7 +922,7 @@ struct cloog_stride_lower { |
576 |
static int constraint_stride_lower(__isl_take isl_constraint *c, void *user) |
577 |
{ |
578 |
struct cloog_stride_lower *csl = (struct cloog_stride_lower *)user; |
579 |
- isl_int v; |
580 |
+ isl_val *v; |
581 |
isl_constraint *bound; |
582 |
isl_aff *b; |
583 |
|
584 |
@@ -912,31 +931,31 @@ static int constraint_stride_lower(__isl |
585 |
return 0; |
586 |
} |
587 |
|
588 |
- isl_int_init(v); |
589 |
- isl_constraint_get_coefficient(c, isl_dim_set, csl->level - 1, &v); |
590 |
- if (!isl_int_is_pos(v)) { |
591 |
- isl_int_clear(v); |
592 |
+ v = isl_constraint_get_coefficient_val(c, isl_dim_set, csl->level - 1); |
593 |
+ if (!isl_val_is_pos(v)) { |
594 |
+ isl_val_free(v); |
595 |
isl_constraint_free(c); |
596 |
|
597 |
return 0; |
598 |
} |
599 |
+ isl_val_free(v); |
600 |
|
601 |
b = isl_constraint_get_bound(c, isl_dim_set, csl->level - 1); |
602 |
|
603 |
b = isl_aff_neg(b); |
604 |
- b = isl_aff_add_constant(b, csl->stride->offset); |
605 |
- b = isl_aff_scale_down(b, csl->stride->stride); |
606 |
+ b = isl_aff_add_constant_val(b, cloog_int_to_isl_val(isl_constraint_get_ctx(c), csl->stride->offset)); |
607 |
+ b = isl_aff_scale_down_val(b, cloog_int_to_isl_val(isl_constraint_get_ctx(c), csl->stride->stride)); |
608 |
b = isl_aff_floor(b); |
609 |
- b = isl_aff_scale(b, csl->stride->stride); |
610 |
- isl_int_neg(v, csl->stride->offset); |
611 |
- b = isl_aff_add_constant(b, v); |
612 |
+ b = isl_aff_scale_val(b, cloog_int_to_isl_val(isl_constraint_get_ctx(c), csl->stride->stride)); |
613 |
+ v = cloog_int_to_isl_val(isl_constraint_get_ctx(c), csl->stride->offset); |
614 |
+ v = isl_val_neg(v); |
615 |
+ b = isl_aff_add_constant_val(b, v); |
616 |
b = isl_aff_add_coefficient_si(b, isl_dim_in, csl->level - 1, 1); |
617 |
|
618 |
bound = isl_inequality_from_aff(b); |
619 |
|
620 |
csl->bounds = isl_basic_set_add_constraint(csl->bounds, bound); |
621 |
|
622 |
- isl_int_clear(v); |
623 |
isl_constraint_free(c); |
624 |
|
625 |
return 0; |
626 |
@@ -960,7 +979,7 @@ static int constraint_stride_lower(__isl |
627 |
static int constraint_stride_lower_c(__isl_take isl_constraint *c, void *user) |
628 |
{ |
629 |
struct cloog_stride_lower *csl = (struct cloog_stride_lower *)user; |
630 |
- isl_int v; |
631 |
+ isl_val *v; |
632 |
isl_constraint *bound; |
633 |
isl_constraint *csl_c; |
634 |
isl_aff *d, *b; |
635 |
@@ -970,10 +989,9 @@ static int constraint_stride_lower_c(__i |
636 |
return 0; |
637 |
} |
638 |
|
639 |
- isl_int_init(v); |
640 |
- isl_constraint_get_coefficient(c, isl_dim_set, csl->level - 1, &v); |
641 |
- if (!isl_int_is_pos(v)) { |
642 |
- isl_int_clear(v); |
643 |
+ v = isl_constraint_get_coefficient_val(c, isl_dim_set, csl->level - 1); |
644 |
+ if (!isl_val_is_pos(v)) { |
645 |
+ isl_val_free(v); |
646 |
isl_constraint_free(c); |
647 |
|
648 |
return 0; |
649 |
@@ -984,15 +1002,15 @@ static int constraint_stride_lower_c(__i |
650 |
d = isl_constraint_get_aff(csl_c); |
651 |
d = isl_aff_drop_dims(d, isl_dim_div, 0, isl_aff_dim(d, isl_dim_div)); |
652 |
d = isl_aff_set_coefficient_si(d, isl_dim_in, csl->level - 1, 0); |
653 |
- d = isl_aff_scale(d, csl->stride->factor); |
654 |
+ d = isl_aff_scale_val(d, cloog_int_to_isl_val(isl_constraint_get_ctx(csl_c), csl->stride->factor)); |
655 |
|
656 |
b = isl_constraint_get_bound(c, isl_dim_set, csl->level - 1); |
657 |
|
658 |
b = isl_aff_neg(b); |
659 |
b = isl_aff_add(b, isl_aff_copy(d)); |
660 |
- b = isl_aff_scale_down(b, csl->stride->stride); |
661 |
+ b = isl_aff_scale_down_val(b, cloog_int_to_isl_val(isl_constraint_get_ctx(csl_c), csl->stride->stride)); |
662 |
b = isl_aff_floor(b); |
663 |
- b = isl_aff_scale(b, csl->stride->stride); |
664 |
+ b = isl_aff_scale_val(b, cloog_int_to_isl_val(isl_constraint_get_ctx(csl_c), csl->stride->stride)); |
665 |
b = isl_aff_sub(b, d); |
666 |
b = isl_aff_add_coefficient_si(b, isl_dim_in, csl->level - 1, 1); |
667 |
|
668 |
@@ -1000,7 +1018,7 @@ static int constraint_stride_lower_c(__i |
669 |
|
670 |
csl->bounds = isl_basic_set_add_constraint(csl->bounds, bound); |
671 |
|
672 |
- isl_int_clear(v); |
673 |
+ isl_val_free(v); |
674 |
isl_constraint_free(c); |
675 |
|
676 |
return 0; |
677 |
@@ -1090,28 +1108,30 @@ struct cloog_bound_split { |
678 |
static int constraint_bound_split(__isl_take isl_constraint *c, void *user) |
679 |
{ |
680 |
struct cloog_bound_split *cbs = (struct cloog_bound_split *)user; |
681 |
- isl_int v; |
682 |
+ isl_val *v; |
683 |
int i; |
684 |
int handle = 0; |
685 |
|
686 |
- isl_int_init(v); |
687 |
- isl_constraint_get_coefficient(c, isl_dim_set, cbs->level - 1, &v); |
688 |
- if (!cbs->lower && isl_int_is_pos(v)) |
689 |
+ v = isl_constraint_get_coefficient_val(c, isl_dim_set, cbs->level - 1); |
690 |
+ if (!cbs->lower && isl_val_is_pos(v)) |
691 |
cbs->lower = handle = 1; |
692 |
- else if (!cbs->upper && isl_int_is_neg(v)) |
693 |
+ else if (!cbs->upper && isl_val_is_neg(v)) |
694 |
cbs->upper = handle = 1; |
695 |
+ |
696 |
if (handle) { |
697 |
for (i = 0; i < isl_set_dim(cbs->set, isl_dim_param); ++i) { |
698 |
- isl_constraint_get_coefficient(c, isl_dim_param, i, &v); |
699 |
- if (isl_int_is_zero(v)) |
700 |
+ isl_val_free(v); |
701 |
+ v = isl_constraint_get_coefficient_val(c, isl_dim_param, i); |
702 |
+ if (isl_val_is_zero(v)) |
703 |
continue; |
704 |
+ |
705 |
cbs->set = isl_set_split_dims(cbs->set, |
706 |
isl_dim_param, i, 1); |
707 |
} |
708 |
} |
709 |
- isl_int_clear(v); |
710 |
- isl_constraint_free(c); |
711 |
+ isl_val_free(v); |
712 |
|
713 |
+ isl_constraint_free(c); |
714 |
return (cbs->lower && cbs->upper) ? -1 : 0; |
715 |
} |
716 |
|
717 |
@@ -1203,7 +1223,7 @@ static int injective_scattering(CloogSca |
718 |
* - scattdims is the total number of scattering dimentions. |
719 |
*/ |
720 |
int cloog_scattering_lazy_block(CloogScattering *s1, CloogScattering *s2, |
721 |
- CloogScatteringList *scattering, int scattdims) |
722 |
+ CloogScatteringList *scattering, int scattdims) |
723 |
{ |
724 |
int i; |
725 |
struct isl_space *dim; |
726 |
@@ -1211,8 +1231,8 @@ int cloog_scattering_lazy_block(CloogSca |
727 |
struct isl_set *delta; |
728 |
isl_map *map1 = isl_map_from_cloog_scattering(s1); |
729 |
isl_map *map2 = isl_map_from_cloog_scattering(s2); |
730 |
- int fixed, block; |
731 |
- isl_int cst; |
732 |
+ int block; |
733 |
+ isl_val *cst; |
734 |
unsigned n_scat; |
735 |
|
736 |
n_scat = isl_map_dim(map1, isl_dim_out); |
737 |
@@ -1225,22 +1245,33 @@ int cloog_scattering_lazy_block(CloogSca |
738 |
rel = isl_map_apply_domain(rel, isl_map_copy(map1)); |
739 |
rel = isl_map_apply_range(rel, isl_map_copy(map2)); |
740 |
delta = isl_map_deltas(rel); |
741 |
- isl_int_init(cst); |
742 |
+ cst = NULL; |
743 |
for (i = 0; i < n_scat; ++i) { |
744 |
- fixed = isl_set_fast_dim_is_fixed(delta, i, &cst); |
745 |
- if (fixed != 1) |
746 |
+ cst = isl_set_plain_get_val_if_fixed(delta, isl_dim_set, i); |
747 |
+ if (!cst){ |
748 |
+ isl_val_free(cst); |
749 |
break; |
750 |
- if (isl_int_is_zero(cst)) |
751 |
+ } |
752 |
+ if (isl_val_is_zero(cst)){ |
753 |
+ isl_val_free(cst); |
754 |
continue; |
755 |
- if (i + 1 < n_scat) |
756 |
+ } |
757 |
+ if (i + 1 < n_scat){ |
758 |
+ isl_val_free(cst); |
759 |
break; |
760 |
- if (!isl_int_is_one(cst)) |
761 |
+ } |
762 |
+ if (!isl_val_is_one(cst)){ |
763 |
+ isl_val_free(cst); |
764 |
break; |
765 |
- if (!injective_scattering(scattering)) |
766 |
+ } |
767 |
+ if (!injective_scattering(scattering)){ |
768 |
+ isl_val_free(cst); |
769 |
break; |
770 |
+ } |
771 |
+ |
772 |
+ isl_val_free(cst); |
773 |
} |
774 |
block = i >= n_scat; |
775 |
- isl_int_clear(cst); |
776 |
isl_set_free(delta); |
777 |
return block; |
778 |
} |
779 |
@@ -1345,10 +1376,25 @@ CloogDomain *cloog_domain_simplify_union |
780 |
* If value is not NULL, then it is set to the constant value of dimension. |
781 |
*/ |
782 |
int cloog_scattering_lazy_isscalar(CloogScattering *scatt, int dimension, |
783 |
- cloog_int_t *value) |
784 |
+ cloog_int_t *value) |
785 |
{ |
786 |
isl_map *map = isl_map_from_cloog_scattering(scatt); |
787 |
- return isl_map_fast_is_fixed(map, isl_dim_out, dimension, value); |
788 |
+ isl_val *v = isl_map_plain_get_val_if_fixed(map, isl_dim_out, dimension); |
789 |
+ if (v != NULL) { |
790 |
+ if (!isl_val_is_nan(v)){ |
791 |
+ if (value != NULL) |
792 |
+ isl_val_to_cloog_int(v, value); |
793 |
+ |
794 |
+ isl_val_free(v); |
795 |
+ return 1; |
796 |
+ } |
797 |
+ else { |
798 |
+ isl_val_free(v); |
799 |
+ return 0; |
800 |
+ } |
801 |
+ } |
802 |
+ |
803 |
+ return 0; |
804 |
} |
805 |
|
806 |
|
807 |
@@ -1362,7 +1408,22 @@ int cloog_domain_lazy_isconstant(CloogDo |
808 |
cloog_int_t *value) |
809 |
{ |
810 |
isl_set *set = isl_set_from_cloog_domain(domain); |
811 |
- return isl_set_fast_dim_is_fixed(set, dimension, value); |
812 |
+ isl_val *cst = isl_set_plain_get_val_if_fixed(set, isl_dim_set, dimension); |
813 |
+ if (cst != NULL) { |
814 |
+ if (!isl_val_is_nan(cst)){ |
815 |
+ if (value != NULL) |
816 |
+ isl_val_to_cloog_int(cst, value); |
817 |
+ |
818 |
+ isl_val_free(cst); |
819 |
+ return 1; |
820 |
+ } |
821 |
+ else { |
822 |
+ isl_val_free(cst); |
823 |
+ return 0; |
824 |
+ } |
825 |
+ } |
826 |
+ |
827 |
+ return 0; |
828 |
} |
829 |
|
830 |
|
831 |
@@ -1595,7 +1656,7 @@ static void Euclid(cloog_int_t a, cloog_ |
832 |
cloog_int_mul(tmp, tmp, d); |
833 |
cloog_int_sub(c, c, tmp); |
834 |
cloog_int_swap(c, d); |
835 |
- cloog_int_swap(e, f); |
836 |
+ cloog_int_swap(e, f); |
837 |
} |
838 |
cloog_int_set(*g, c); |
839 |
if (cloog_int_is_zero(a)) |
840 |
@@ -1631,49 +1692,70 @@ static void Euclid(cloog_int_t a, cloog_ |
841 |
static CloogStride *construct_stride(isl_constraint *c, int level) |
842 |
{ |
843 |
int i, n, sign; |
844 |
- isl_int v, m, gcd, stride, factor; |
845 |
+ isl_val *v, *m, *gcd, *stride; |
846 |
+ isl_val *v_copy, *m_copy, *gcd_copy; |
847 |
+ cloog_int_t c_v, c_m, c_gcd, c_stride, c_factor; |
848 |
CloogStride *s; |
849 |
+ isl_ctx *ctx = isl_constraint_get_ctx(c);; |
850 |
|
851 |
if (!c) |
852 |
return NULL; |
853 |
|
854 |
- isl_int_init(v); |
855 |
- isl_int_init(m); |
856 |
- isl_int_init(gcd); |
857 |
- isl_int_init(factor); |
858 |
- isl_int_init(stride); |
859 |
- |
860 |
- isl_constraint_get_coefficient(c, isl_dim_set, level - 1, &v); |
861 |
- sign = isl_int_sgn(v); |
862 |
- isl_int_abs(m, v); |
863 |
+ v = isl_constraint_get_coefficient_val(c, isl_dim_set, level - 1); |
864 |
|
865 |
- isl_int_set_si(gcd, 0); |
866 |
+ sign = isl_val_sgn(v); |
867 |
+ m = isl_val_abs(v); /* *takes* v. */ |
868 |
+ |
869 |
+ gcd = isl_val_int_from_si(ctx, 0); |
870 |
n = isl_constraint_dim(c, isl_dim_div); |
871 |
for (i = 0; i < n; ++i) { |
872 |
- isl_constraint_get_coefficient(c, isl_dim_div, i, &v); |
873 |
- isl_int_gcd(gcd, gcd, v); |
874 |
+ v = isl_constraint_get_coefficient_val(c, isl_dim_div, i); |
875 |
+ gcd = isl_val_gcd(gcd, v); |
876 |
} |
877 |
|
878 |
- isl_int_gcd(v, m, gcd); |
879 |
- isl_int_divexact(stride, gcd, v); |
880 |
+ m_copy = isl_val_copy(m); |
881 |
+ gcd_copy = isl_val_copy(gcd); |
882 |
+ |
883 |
+ v = isl_val_gcd(m, gcd); |
884 |
+ |
885 |
+ v_copy = isl_val_copy(v); |
886 |
+ gcd = isl_val_copy(gcd_copy); |
887 |
+ stride = isl_val_div(gcd, v); |
888 |
|
889 |
- if (isl_int_is_zero(stride) || isl_int_is_one(stride)) |
890 |
+ if (isl_val_is_zero(stride) || isl_val_is_one(stride)) |
891 |
s = NULL; |
892 |
else { |
893 |
- Euclid(m, stride, &factor, &v, &gcd); |
894 |
+ cloog_int_init(c_m); |
895 |
+ cloog_int_init(c_stride); |
896 |
+ cloog_int_init(c_v); |
897 |
+ cloog_int_init(c_gcd); |
898 |
+ cloog_int_init(c_factor); |
899 |
+ |
900 |
+ isl_val_to_cloog_int(m_copy, &c_m); |
901 |
+ isl_val_to_cloog_int(stride, &c_stride); |
902 |
+ isl_val_to_cloog_int(v_copy, &c_v); |
903 |
+ isl_val_to_cloog_int(gcd_copy, &c_gcd); |
904 |
+ |
905 |
+ Euclid(c_m, c_stride, &c_factor, &c_v, &c_gcd); |
906 |
if (sign > 0) |
907 |
- isl_int_neg(factor, factor); |
908 |
+ cloog_int_neg(c_factor, c_factor); |
909 |
|
910 |
c = isl_constraint_copy(c); |
911 |
- s = cloog_stride_alloc_from_constraint(stride, |
912 |
- cloog_constraint_from_isl_constraint(c), factor); |
913 |
+ s = cloog_stride_alloc_from_constraint(c_stride, |
914 |
+ cloog_constraint_from_isl_constraint(c), c_factor); |
915 |
+ |
916 |
+ |
917 |
+ cloog_int_clear(c_m); |
918 |
+ cloog_int_clear(c_stride); |
919 |
+ cloog_int_clear(c_v); |
920 |
+ cloog_int_clear(c_gcd); |
921 |
+ cloog_int_clear(c_factor); |
922 |
} |
923 |
|
924 |
- isl_int_clear(stride); |
925 |
- isl_int_clear(factor); |
926 |
- isl_int_clear(gcd); |
927 |
- isl_int_clear(m); |
928 |
- isl_int_clear(v); |
929 |
+ isl_val_free(stride); |
930 |
+ isl_val_free(gcd_copy); |
931 |
+ isl_val_free(m_copy); |
932 |
+ isl_val_free(v_copy); |
933 |
|
934 |
return s; |
935 |
} |
936 |
@@ -1694,7 +1776,7 @@ static int find_stride(__isl_take isl_co |
937 |
{ |
938 |
struct cloog_isl_find_stride_data *data; |
939 |
int n; |
940 |
- isl_int v; |
941 |
+ isl_val *v; |
942 |
|
943 |
if (!isl_constraint_is_equality(c)) { |
944 |
isl_constraint_free(c); |
945 |
@@ -1714,13 +1796,11 @@ static int find_stride(__isl_take isl_co |
946 |
return 0; |
947 |
} |
948 |
|
949 |
- isl_int_init(v); |
950 |
- |
951 |
- isl_constraint_get_coefficient(c, isl_dim_set, data->level - 1, &v); |
952 |
- if (!isl_int_is_zero(v)) |
953 |
+ v = isl_constraint_get_coefficient_val(c, isl_dim_set, data->level - 1); |
954 |
+ if (!isl_val_is_zero(v)) |
955 |
data->stride = construct_stride(c, data->level); |
956 |
|
957 |
- isl_int_clear(v); |
958 |
+ isl_val_free(v); |
959 |
|
960 |
isl_constraint_free(c); |
961 |
|
962 |
@@ -1769,7 +1849,7 @@ struct cloog_can_unroll { |
963 |
int level; |
964 |
isl_constraint *c; |
965 |
isl_set *set; |
966 |
- isl_int *n; |
967 |
+ isl_val *n; |
968 |
}; |
969 |
|
970 |
|
971 |
@@ -1782,11 +1862,11 @@ struct cloog_can_unroll { |
972 |
* with l the given lower bound and i the iterator identified by level. |
973 |
*/ |
974 |
static int is_valid_unrolling_lower_bound(struct cloog_can_unroll *ccu, |
975 |
- __isl_keep isl_constraint *c, isl_int *v) |
976 |
+ __isl_keep isl_constraint *c, isl_val **v) |
977 |
{ |
978 |
unsigned n_div; |
979 |
isl_aff *aff; |
980 |
- enum isl_lp_result res; |
981 |
+ enum isl_lp_result; |
982 |
|
983 |
n_div = isl_constraint_dim(c, isl_dim_div); |
984 |
if (isl_constraint_involves_dims(c, isl_dim_div, 0, n_div)) |
985 |
@@ -1796,15 +1876,19 @@ static int is_valid_unrolling_lower_boun |
986 |
aff = isl_aff_ceil(aff); |
987 |
aff = isl_aff_neg(aff); |
988 |
aff = isl_aff_add_coefficient_si(aff, isl_dim_in, ccu->level - 1, 1); |
989 |
- res = isl_set_max(ccu->set, aff, v); |
990 |
+ *v = isl_set_max_val(ccu->set, aff); |
991 |
isl_aff_free(aff); |
992 |
|
993 |
- if (res == isl_lp_unbounded) |
994 |
- return 0; |
995 |
+ if (!*v || isl_val_is_nan(*v)) |
996 |
+ cloog_die("Fail to decide about unrolling (cannot find max)"); |
997 |
|
998 |
- assert(res == isl_lp_ok); |
999 |
+ if (isl_val_is_infty(*v) || isl_val_is_neginfty(*v)){ |
1000 |
+ isl_val_free(*v); |
1001 |
+ *v = NULL; |
1002 |
+ return 0; |
1003 |
+ } |
1004 |
|
1005 |
- cloog_int_add_ui(*v, *v, 1); |
1006 |
+ *v = isl_val_add_ui(*v, 1); |
1007 |
|
1008 |
return 1; |
1009 |
} |
1010 |
@@ -1818,21 +1902,21 @@ static int is_valid_unrolling_lower_boun |
1011 |
static int constraint_can_unroll(__isl_take isl_constraint *c, void *user) |
1012 |
{ |
1013 |
struct cloog_can_unroll *ccu = (struct cloog_can_unroll *)user; |
1014 |
- isl_int v; |
1015 |
- isl_int count; |
1016 |
+ isl_val *v; |
1017 |
+ isl_val *count = NULL; |
1018 |
|
1019 |
- isl_int_init(v); |
1020 |
- isl_int_init(count); |
1021 |
- isl_constraint_get_coefficient(c, isl_dim_set, ccu->level - 1, &v); |
1022 |
- if (isl_int_is_pos(v) && |
1023 |
- is_valid_unrolling_lower_bound(ccu, c, &count) && |
1024 |
- (!ccu->c || isl_int_lt(count, *ccu->n))) { |
1025 |
+ v = isl_constraint_get_coefficient_val(c, isl_dim_set, ccu->level - 1); |
1026 |
+ if (isl_val_is_pos(v) && |
1027 |
+ is_valid_unrolling_lower_bound(ccu, c, &count) && |
1028 |
+ (!ccu->c || (isl_val_lt(count, ccu->n))) ) { |
1029 |
isl_constraint_free(ccu->c); |
1030 |
ccu->c = isl_constraint_copy(c); |
1031 |
- isl_int_set(*ccu->n, count); |
1032 |
+ if (ccu->n) |
1033 |
+ isl_val_free(ccu->n); |
1034 |
+ ccu->n = isl_val_copy(count); |
1035 |
} |
1036 |
- isl_int_clear(count); |
1037 |
- isl_int_clear(v); |
1038 |
+ isl_val_free(count); |
1039 |
+ isl_val_free(v); |
1040 |
isl_constraint_free(c); |
1041 |
|
1042 |
return 0; |
1043 |
@@ -1872,7 +1956,8 @@ int cloog_domain_can_unroll(CloogDomain |
1044 |
CloogConstraint **lb) |
1045 |
{ |
1046 |
isl_set *set = isl_set_from_cloog_domain(domain); |
1047 |
- struct cloog_can_unroll ccu = { 1, level, NULL, set, n }; |
1048 |
+ isl_val *v = cloog_int_to_isl_val(isl_set_get_ctx(set), *n); |
1049 |
+ struct cloog_can_unroll ccu = { 1, level, NULL, set, v }; |
1050 |
int r; |
1051 |
|
1052 |
*lb = NULL; |
1053 |
@@ -1887,6 +1972,11 @@ int cloog_domain_can_unroll(CloogDomain |
1054 |
|
1055 |
*lb = cloog_constraint_from_isl_constraint(ccu.c); |
1056 |
|
1057 |
+ isl_val_to_cloog_int(ccu.n, n); |
1058 |
+ /* Note: we have to free ccu.n and not v because v has been |
1059 |
+ * freed and replaced in ccu during isl_set_foreach_basic_set |
1060 |
+ */ |
1061 |
+ isl_val_free(ccu.n); |
1062 |
return ccu.can_unroll; |
1063 |
} |
1064 |
|
1065 |
@@ -1904,6 +1994,7 @@ CloogDomain *cloog_domain_fixed_offset(C |
1066 |
{ |
1067 |
isl_aff *aff; |
1068 |
isl_set *set = isl_set_from_cloog_domain(domain); |
1069 |
+ isl_ctx *ctx = isl_set_get_ctx(set); |
1070 |
isl_constraint *c; |
1071 |
isl_constraint *eq; |
1072 |
|
1073 |
@@ -1911,7 +2002,7 @@ CloogDomain *cloog_domain_fixed_offset(C |
1074 |
aff = isl_constraint_get_bound(c, isl_dim_set, level - 1); |
1075 |
aff = isl_aff_ceil(aff); |
1076 |
aff = isl_aff_add_coefficient_si(aff, isl_dim_in, level - 1, -1); |
1077 |
- aff = isl_aff_add_constant(aff, offset); |
1078 |
+ aff = isl_aff_add_constant_val(aff, cloog_int_to_isl_val(ctx, offset)); |
1079 |
eq = isl_equality_from_aff(aff); |
1080 |
set = isl_set_add_constraint(set, eq); |
1081 |
|