Mercurial > hg > CbC > CbC_gcc
comparison gcc/graphite-poly.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | b7f97abdc517 |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
19 along with GCC; see the file COPYING3. If not see | 19 along with GCC; see the file COPYING3. If not see |
20 <http://www.gnu.org/licenses/>. */ | 20 <http://www.gnu.org/licenses/>. */ |
21 #include "config.h" | 21 #include "config.h" |
22 #include "system.h" | 22 #include "system.h" |
23 #include "coretypes.h" | 23 #include "coretypes.h" |
24 #include "tm.h" | 24 #include "diagnostic-core.h" |
25 #include "ggc.h" | 25 #include "tree-flow.h" |
26 #include "tree.h" | 26 #include "tree-dump.h" |
27 #include "rtl.h" | |
28 #include "output.h" | |
29 #include "basic-block.h" | |
30 #include "diagnostic.h" | |
31 #include "tree-pretty-print.h" | |
32 #include "gimple-pretty-print.h" | 27 #include "gimple-pretty-print.h" |
33 #include "tree-flow.h" | |
34 #include "toplev.h" | |
35 #include "tree-dump.h" | |
36 #include "timevar.h" | |
37 #include "cfgloop.h" | 28 #include "cfgloop.h" |
38 #include "tree-chrec.h" | 29 #include "tree-chrec.h" |
39 #include "tree-data-ref.h" | 30 #include "tree-data-ref.h" |
40 #include "tree-scalar-evolution.h" | 31 #include "tree-scalar-evolution.h" |
41 #include "tree-pass.h" | 32 #include "sese.h" |
42 #include "domwalk.h" | |
43 #include "value-prof.h" | |
44 #include "pointer-set.h" | |
45 #include "gimple.h" | |
46 #include "params.h" | |
47 | 33 |
48 #ifdef HAVE_cloog | 34 #ifdef HAVE_cloog |
49 #include "cloog/cloog.h" | |
50 #include "ppl_c.h" | 35 #include "ppl_c.h" |
51 #include "sese.h" | |
52 #include "graphite-ppl.h" | 36 #include "graphite-ppl.h" |
53 #include "graphite.h" | |
54 #include "graphite-poly.h" | 37 #include "graphite-poly.h" |
55 #include "graphite-dependences.h" | 38 #include "graphite-dependences.h" |
39 #include "graphite-cloog-util.h" | |
40 | |
41 #define OPENSCOP_MAX_STRING 256 | |
56 | 42 |
57 /* Return the maximal loop depth in SCOP. */ | 43 /* Return the maximal loop depth in SCOP. */ |
58 | 44 |
59 int | 45 int |
60 scop_max_loop_depth (scop_p scop) | 46 scop_max_loop_depth (scop_p scop) |
61 { | 47 { |
62 int i; | 48 int i; |
63 poly_bb_p pbb; | 49 poly_bb_p pbb; |
64 int max_nb_loops = 0; | 50 int max_nb_loops = 0; |
65 | 51 |
66 for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++) | 52 FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb) |
67 { | 53 { |
68 int nb_loops = pbb_dim_iter_domain (pbb); | 54 int nb_loops = pbb_dim_iter_domain (pbb); |
69 if (max_nb_loops < nb_loops) | 55 if (max_nb_loops < nb_loops) |
70 max_nb_loops = nb_loops; | 56 max_nb_loops = nb_loops; |
71 } | 57 } |
126 { | 112 { |
127 int i; | 113 int i; |
128 poly_bb_p pbb; | 114 poly_bb_p pbb; |
129 graphite_dim_t max_scattering = 0; | 115 graphite_dim_t max_scattering = 0; |
130 | 116 |
131 for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++) | 117 FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb) |
132 max_scattering = MAX (pbb_nb_scattering_transform (pbb), max_scattering); | 118 max_scattering = MAX (pbb_nb_scattering_transform (pbb), max_scattering); |
133 | 119 |
134 for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++) | 120 FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb) |
135 extend_scattering (pbb, max_scattering); | 121 extend_scattering (pbb, max_scattering); |
136 | 122 |
137 return max_scattering; | 123 return max_scattering; |
124 } | |
125 | |
126 /* Print to FILE the pdr PH in OpenScop format. NB_SUBSCRIPTS is the number | |
127 of subscripts in PH, ALIAS_SET_DIM is the dimension of the alias set and | |
128 NB_PARAMS is the number of parameters in PH. */ | |
129 | |
130 static void | |
131 openscop_print_pdr_polyhedron (FILE *file, ppl_const_Polyhedron_t ph, | |
132 int nb_subscripts, int alias_set_dimension, | |
133 int nb_params) | |
134 { | |
135 int input, locals, output; | |
136 ppl_dimension_type alias_set_dim = (ppl_dimension_type) alias_set_dimension; | |
137 ppl_dimension_type sub_dim_last = alias_set_dim + nb_subscripts; | |
138 ppl_dimension_type *map, i, ph_space_dim = sub_dim_last + 1; | |
139 ppl_Polyhedron_t pph; | |
140 | |
141 ppl_new_C_Polyhedron_from_C_Polyhedron (&pph, ph); | |
142 | |
143 map = (ppl_dimension_type *) XNEWVEC (ppl_dimension_type, ph_space_dim); | |
144 | |
145 for (i = 0; i < alias_set_dim - 1; i++) | |
146 map[i] = nb_subscripts + 1 + i; | |
147 | |
148 for (i = alias_set_dim - 1; i < sub_dim_last; i++) | |
149 map[i] = i - alias_set_dim + 1; | |
150 | |
151 ppl_Polyhedron_map_space_dimensions (pph, map, ph_space_dim - 1); | |
152 | |
153 locals = 0; | |
154 input = alias_set_dim - nb_params - 1; | |
155 | |
156 /* According to OpenScop specification, the alias set column is a part of | |
157 the output columns. */ | |
158 output = nb_subscripts + 1; | |
159 | |
160 openscop_print_polyhedron_matrix (file, pph, output, input, locals, nb_params); | |
161 } | |
162 | |
163 /* Print to FILE the powerset PDR. NB_SUBSCRIPTS is the number of subscripts | |
164 in PDR, ALIAS_SET_DIM is the dimension of the alias set in PDR and | |
165 NB_PARAMS is the number of parameters in PDR. */ | |
166 | |
167 static void | |
168 openscop_print_pdr_powerset (FILE *file, | |
169 ppl_Pointset_Powerset_C_Polyhedron_t ps, | |
170 int nb_subscripts, | |
171 int alias_set_dim, | |
172 int nb_params) | |
173 { | |
174 size_t nb_disjuncts; | |
175 ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end; | |
176 | |
177 ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&it); | |
178 ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&end); | |
179 | |
180 ppl_Pointset_Powerset_C_Polyhedron_size (ps, &nb_disjuncts); | |
181 fprintf (file, "%d\n", (int) nb_disjuncts); | |
182 | |
183 for (ppl_Pointset_Powerset_C_Polyhedron_iterator_begin (ps, it), | |
184 ppl_Pointset_Powerset_C_Polyhedron_iterator_end (ps, end); | |
185 !ppl_Pointset_Powerset_C_Polyhedron_iterator_equal_test (it, end); | |
186 ppl_Pointset_Powerset_C_Polyhedron_iterator_increment (it)) | |
187 { | |
188 ppl_const_Polyhedron_t ph; | |
189 | |
190 ppl_Pointset_Powerset_C_Polyhedron_iterator_dereference (it, &ph); | |
191 openscop_print_pdr_polyhedron (file, ph, nb_subscripts, alias_set_dim, | |
192 nb_params); | |
193 } | |
194 | |
195 ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (it); | |
196 ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (end); | |
197 } | |
198 | |
199 /* Print to FILE the powerset PS in its OpenScop matrix form. */ | |
200 | |
201 static void | |
202 openscop_print_powerset_matrix (FILE *file, | |
203 ppl_Pointset_Powerset_C_Polyhedron_t ps, | |
204 int output, int input, int locals, | |
205 int params) | |
206 { | |
207 size_t nb_disjuncts; | |
208 ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end; | |
209 | |
210 ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&it); | |
211 ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&end); | |
212 | |
213 ppl_Pointset_Powerset_C_Polyhedron_size (ps, &nb_disjuncts); | |
214 fprintf (file, "%d\n", (int) nb_disjuncts); | |
215 | |
216 for (ppl_Pointset_Powerset_C_Polyhedron_iterator_begin (ps, it), | |
217 ppl_Pointset_Powerset_C_Polyhedron_iterator_end (ps, end); | |
218 !ppl_Pointset_Powerset_C_Polyhedron_iterator_equal_test (it, end); | |
219 ppl_Pointset_Powerset_C_Polyhedron_iterator_increment (it)) | |
220 { | |
221 ppl_const_Polyhedron_t ph; | |
222 | |
223 ppl_Pointset_Powerset_C_Polyhedron_iterator_dereference (it, &ph); | |
224 openscop_print_polyhedron_matrix (file, ph, output, input, locals, | |
225 params); | |
226 } | |
227 | |
228 ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (it); | |
229 ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (end); | |
230 } | |
231 | |
232 /* Prints to FILE the scattering function of PBB in OpenScop format, at some | |
233 VERBOSITY level. */ | |
234 | |
235 static void | |
236 openscop_print_scattering_function_1 (FILE *file, poly_bb_p pbb, int verbosity) | |
237 { | |
238 graphite_dim_t i; | |
239 ppl_const_Polyhedron_t ph; | |
240 | |
241 if (verbosity > 0) | |
242 { | |
243 fprintf (file, "# scattering bb_%d (\n", pbb_index (pbb)); | |
244 fprintf (file, "#eq"); | |
245 | |
246 for (i = 0; i < pbb_nb_scattering_transform (pbb); i++) | |
247 fprintf (file, " s%d", (int) i); | |
248 | |
249 for (i = 0; i < pbb_nb_local_vars (pbb); i++) | |
250 fprintf (file, " lv%d", (int) i); | |
251 | |
252 for (i = 0; i < pbb_dim_iter_domain (pbb); i++) | |
253 fprintf (file, " i%d", (int) i); | |
254 | |
255 for (i = 0; i < pbb_nb_params (pbb); i++) | |
256 fprintf (file, " p%d", (int) i); | |
257 | |
258 fprintf (file, " cst\n"); | |
259 } | |
260 | |
261 /* Number of disjunct components. Remove this when | |
262 PBB_TRANSFORMED_SCATTERING will be a pointset_powerset. */ | |
263 fprintf (file, "1\n"); | |
264 | |
265 ph = PBB_TRANSFORMED_SCATTERING (pbb) | |
266 ? PBB_TRANSFORMED_SCATTERING (pbb) | |
267 : PBB_ORIGINAL_SCATTERING (pbb); | |
268 | |
269 openscop_print_polyhedron_matrix (file, ph, | |
270 pbb_nb_scattering_transform (pbb), | |
271 pbb_dim_iter_domain (pbb), | |
272 pbb_nb_local_vars (pbb), | |
273 pbb_nb_params (pbb)); | |
274 | |
275 if (verbosity > 0) | |
276 fprintf (file, "#)\n"); | |
138 } | 277 } |
139 | 278 |
140 /* Prints to FILE the scattering function of PBB, at some VERBOSITY | 279 /* Prints to FILE the scattering function of PBB, at some VERBOSITY |
141 level. */ | 280 level. */ |
142 | 281 |
146 graphite_dim_t i; | 285 graphite_dim_t i; |
147 | 286 |
148 if (verbosity > 0) | 287 if (verbosity > 0) |
149 { | 288 { |
150 fprintf (file, "# scattering bb_%d (\n", pbb_index (pbb)); | 289 fprintf (file, "# scattering bb_%d (\n", pbb_index (pbb)); |
151 fprintf (file, "# eq"); | 290 fprintf (file, "#eq"); |
152 | 291 |
153 for (i = 0; i < pbb_nb_scattering_transform (pbb); i++) | 292 for (i = 0; i < pbb_nb_scattering_transform (pbb); i++) |
154 fprintf (file, " s%d", (int) i); | 293 fprintf (file, " s%d", (int) i); |
155 | 294 |
156 for (i = 0; i < pbb_nb_local_vars (pbb); i++) | 295 for (i = 0; i < pbb_nb_local_vars (pbb); i++) |
200 | 339 |
201 fprintf (file, "0\n"); | 340 fprintf (file, "0\n"); |
202 return; | 341 return; |
203 } | 342 } |
204 | 343 |
205 print_scattering_function_1 (file, pbb, verbosity); | 344 openscop_print_scattering_function_1 (file, pbb, verbosity); |
345 | |
346 if (verbosity > 0) | |
347 fprintf (file, "# Scattering names are not provided\n"); | |
348 | |
349 fprintf (file, "0\n"); | |
350 | |
206 } | 351 } |
207 | 352 |
208 /* Prints to FILE the iteration domain of PBB, at some VERBOSITY | 353 /* Prints to FILE the iteration domain of PBB, at some VERBOSITY |
209 level. */ | 354 level. */ |
210 | 355 |
220 print_scattering_functions (FILE *file, scop_p scop, int verbosity) | 365 print_scattering_functions (FILE *file, scop_p scop, int verbosity) |
221 { | 366 { |
222 int i; | 367 int i; |
223 poly_bb_p pbb; | 368 poly_bb_p pbb; |
224 | 369 |
225 for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++) | 370 FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb) |
226 print_scattering_function (file, pbb, verbosity); | 371 print_scattering_function (file, pbb, verbosity); |
227 } | 372 } |
228 | 373 |
229 /* Prints to FILE the iteration domains of every PBB of SCOP, at some | 374 /* Prints to FILE the iteration domains of every PBB of SCOP, at some |
230 VERBOSITY level. */ | 375 VERBOSITY level. */ |
233 print_iteration_domains (FILE *file, scop_p scop, int verbosity) | 378 print_iteration_domains (FILE *file, scop_p scop, int verbosity) |
234 { | 379 { |
235 int i; | 380 int i; |
236 poly_bb_p pbb; | 381 poly_bb_p pbb; |
237 | 382 |
238 for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++) | 383 FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb) |
239 print_iteration_domain (file, pbb, verbosity); | 384 print_iteration_domain (file, pbb, verbosity); |
240 } | 385 } |
241 | 386 |
242 /* Prints to STDERR the scattering function of PBB, at some VERBOSITY | 387 /* Prints to STDERR the scattering function of PBB, at some VERBOSITY |
243 level. */ | 388 level. */ |
244 | 389 |
245 void | 390 DEBUG_FUNCTION void |
246 debug_scattering_function (poly_bb_p pbb, int verbosity) | 391 debug_scattering_function (poly_bb_p pbb, int verbosity) |
247 { | 392 { |
248 print_scattering_function (stderr, pbb, verbosity); | 393 print_scattering_function (stderr, pbb, verbosity); |
249 } | 394 } |
250 | 395 |
251 /* Prints to STDERR the iteration domain of PBB, at some VERBOSITY | 396 /* Prints to STDERR the iteration domain of PBB, at some VERBOSITY |
252 level. */ | 397 level. */ |
253 | 398 |
254 void | 399 DEBUG_FUNCTION void |
255 debug_iteration_domain (poly_bb_p pbb, int verbosity) | 400 debug_iteration_domain (poly_bb_p pbb, int verbosity) |
256 { | 401 { |
257 print_iteration_domain (stderr, pbb, verbosity); | 402 print_iteration_domain (stderr, pbb, verbosity); |
258 } | 403 } |
259 | 404 |
260 /* Prints to STDERR the scattering functions of every PBB of SCOP, at | 405 /* Prints to STDERR the scattering functions of every PBB of SCOP, at |
261 some VERBOSITY level. */ | 406 some VERBOSITY level. */ |
262 | 407 |
263 void | 408 DEBUG_FUNCTION void |
264 debug_scattering_functions (scop_p scop, int verbosity) | 409 debug_scattering_functions (scop_p scop, int verbosity) |
265 { | 410 { |
266 print_scattering_functions (stderr, scop, verbosity); | 411 print_scattering_functions (stderr, scop, verbosity); |
267 } | 412 } |
268 | 413 |
269 /* Prints to STDERR the iteration domains of every PBB of SCOP, at | 414 /* Prints to STDERR the iteration domains of every PBB of SCOP, at |
270 some VERBOSITY level. */ | 415 some VERBOSITY level. */ |
271 | 416 |
272 void | 417 DEBUG_FUNCTION void |
273 debug_iteration_domains (scop_p scop, int verbosity) | 418 debug_iteration_domains (scop_p scop, int verbosity) |
274 { | 419 { |
275 print_iteration_domains (stderr, scop, verbosity); | 420 print_iteration_domains (stderr, scop, verbosity); |
276 } | 421 } |
277 | 422 |
423 /* Read N integer from FILE. */ | |
424 | |
425 int * | |
426 openscop_read_N_int (FILE *file, int N) | |
427 { | |
428 char s[OPENSCOP_MAX_STRING]; | |
429 char *str; | |
430 int i, *res = (int *) xmalloc (OPENSCOP_MAX_STRING * sizeof (int)); | |
431 | |
432 /* Skip blank and commented lines. */ | |
433 while (fgets (s, sizeof s, file) == (char *) 0 | |
434 || s[0] == '#' | |
435 || ISSPACE (s[0])) | |
436 ; | |
437 | |
438 str = s; | |
439 | |
440 for (i = 0; i < N; i++) | |
441 { | |
442 sscanf (str, "%d", &res[i]); | |
443 | |
444 /* Jump the integer that was read. */ | |
445 while ((*str) && !ISSPACE (*str) && (*str != '#')) | |
446 str++; | |
447 | |
448 /* Jump spaces. */ | |
449 while ((*str) && ISSPACE (*str) && (*str != '#')) | |
450 str++; | |
451 } | |
452 | |
453 return res; | |
454 } | |
455 | |
456 /* Read one integer from FILE. */ | |
457 | |
458 static int | |
459 openscop_read_one_int (FILE *file) | |
460 { | |
461 int *x = openscop_read_N_int (file, 1); | |
462 int res = *x; | |
463 | |
464 free (x); | |
465 return res; | |
466 } | |
467 | |
468 /* Read N string from FILE. */ | |
469 | |
470 static char * | |
471 openscop_read_N_string (FILE *file, int N) | |
472 { | |
473 int count, i; | |
474 char str[OPENSCOP_MAX_STRING]; | |
475 char *tmp = (char *) xmalloc (sizeof (char) * OPENSCOP_MAX_STRING); | |
476 char *s = NULL; | |
477 | |
478 /* Skip blank and commented lines. */ | |
479 while (fgets (str, sizeof str, file) == (char *) 0 | |
480 || str[0] == '#' | |
481 || ISSPACE (str[0])) | |
482 ; | |
483 | |
484 s = str; | |
485 count = 0; | |
486 | |
487 for (i = 0; i < N; i++) | |
488 { | |
489 /* Read the first word. */ | |
490 for (; (*s) && (!ISSPACE (*s)) && (*s != '#'); ++count) | |
491 tmp[count] = *(s++); | |
492 | |
493 tmp[count] = ' '; | |
494 count++; | |
495 | |
496 /* Jump spaces. */ | |
497 while ((*s) && ISSPACE (*s) && (*s != '#')) | |
498 s++; | |
499 } | |
500 | |
501 tmp[count-1] = '\0'; | |
502 | |
503 return tmp; | |
504 } | |
505 | |
506 /* Read one string from FILE. */ | |
507 | |
508 static char * | |
509 openscop_read_one_string (FILE *file) | |
510 { | |
511 return openscop_read_N_string (file, 1); | |
512 } | |
513 | |
514 /* Read from FILE the powerset PS in its OpenScop matrix form. OUTPUT is the | |
515 number of output dimensions, INPUT is the number of input dimensions, | |
516 LOCALS is the number of existentially quantified variables and PARAMS is | |
517 the number of parameters. */ | |
518 | |
519 static void | |
520 openscop_read_powerset_matrix (FILE *file, | |
521 ppl_Pointset_Powerset_C_Polyhedron_t *ps, | |
522 int *output, int *input, int *locals, | |
523 int *params) | |
524 { | |
525 int nb_disjuncts, i; | |
526 | |
527 nb_disjuncts = openscop_read_one_int (file); | |
528 | |
529 for (i = 0; i < nb_disjuncts; i++) | |
530 { | |
531 ppl_Polyhedron_t ph; | |
532 | |
533 openscop_read_polyhedron_matrix (file, &ph, output, input, locals, | |
534 params); | |
535 if (!ph) | |
536 *ps = NULL; | |
537 else if (i == 0) | |
538 ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (ps, ph); | |
539 else | |
540 ppl_Pointset_Powerset_C_Polyhedron_add_disjunct (*ps, ph); | |
541 } | |
542 } | |
543 | |
544 /* Read a scattering function from FILE and save it to PBB. Return whether | |
545 the scattering function was provided or not. */ | |
546 | |
547 static bool | |
548 graphite_read_scatt (FILE *file, poly_bb_p pbb) | |
549 { | |
550 bool scattering_provided = false; | |
551 int output, input, locals, params; | |
552 ppl_Polyhedron_t newp; | |
553 | |
554 if (openscop_read_one_int (file) > 0) | |
555 { | |
556 /* Read number of disjunct components. */ | |
557 openscop_read_one_int (file); | |
558 | |
559 /* Read scattering function. */ | |
560 openscop_read_polyhedron_matrix (file, &newp, &output, &input, | |
561 &locals, ¶ms); | |
562 store_scattering (PBB_SCOP (pbb)); | |
563 PBB_TRANSFORMED (pbb) = poly_scattering_new (); | |
564 PBB_TRANSFORMED_SCATTERING (pbb) = newp; | |
565 PBB_NB_LOCAL_VARIABLES (pbb) = locals; | |
566 | |
567 /* New scattering dimension. */ | |
568 PBB_NB_SCATTERING_TRANSFORM (pbb) = output; | |
569 | |
570 scattering_provided = true; | |
571 } | |
572 | |
573 return scattering_provided; | |
574 } | |
575 | |
576 /* Read a scop file. Return true if the scop is transformed. */ | |
577 | |
578 static bool | |
579 graphite_read_scop_file (FILE *file, scop_p scop) | |
580 { | |
581 char *tmp, *language; | |
582 size_t i, j, nb_statements, nbr, nbw; | |
583 int input, output, locals, params; | |
584 ppl_Pointset_Powerset_C_Polyhedron_t ps; | |
585 poly_bb_p pbb; | |
586 bool transform_done = false; | |
587 | |
588 /* Ensure that the file is in OpenScop format. */ | |
589 tmp = openscop_read_N_string (file, 2); | |
590 | |
591 if (strcmp (tmp, "SCoP 1")) | |
592 { | |
593 error ("the file is not in OpenScop format"); | |
594 return false; | |
595 } | |
596 | |
597 free (tmp); | |
598 | |
599 /* Read the language. */ | |
600 language = openscop_read_one_string (file); | |
601 | |
602 if (strcmp (language, "Gimple")) | |
603 { | |
604 error ("the language is not recognized"); | |
605 return false; | |
606 } | |
607 | |
608 free (language); | |
609 | |
610 /* Read the context but do not use it. */ | |
611 openscop_read_powerset_matrix (file, &ps, &input, &output, &locals, ¶ms); | |
612 | |
613 if ((size_t) params != scop->nb_params) | |
614 { | |
615 error ("parameters number in the scop file is different from the" | |
616 " internal scop parameter number"); | |
617 return false; | |
618 } | |
619 | |
620 /* Read parameter names if provided. */ | |
621 if (openscop_read_one_int (file)) | |
622 openscop_read_N_string (file, scop->nb_params); | |
623 | |
624 nb_statements = openscop_read_one_int (file); | |
625 | |
626 if (nb_statements != VEC_length (poly_bb_p, SCOP_BBS (scop))) | |
627 { | |
628 error ("number of statements in the OpenScop file does not match" | |
629 " the graphite internal statements number"); | |
630 return false; | |
631 } | |
632 | |
633 for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++) | |
634 { | |
635 /* Read iteration domain. */ | |
636 openscop_read_powerset_matrix (file, &ps, &input, &output, &locals, | |
637 ¶ms); | |
638 | |
639 /* Read scattering. */ | |
640 transform_done = graphite_read_scatt (file, pbb); | |
641 | |
642 /* Scattering names. */ | |
643 openscop_read_one_int (file); | |
644 | |
645 /* Read access functions. */ | |
646 if (openscop_read_one_int (file) > 0) | |
647 { | |
648 nbr = openscop_read_one_int (file); | |
649 | |
650 /* Read access functions. */ | |
651 for (j = 0; j < nbr; j++) | |
652 openscop_read_powerset_matrix (file, &ps, &input, &output, &locals, | |
653 ¶ms); | |
654 | |
655 nbw = openscop_read_one_int (file); | |
656 | |
657 /* Write access functions. */ | |
658 for (j = 0; j < nbw; j++) | |
659 openscop_read_powerset_matrix (file, &ps, &input, &output, &locals, | |
660 ¶ms); | |
661 } | |
662 | |
663 /* Statement body. */ | |
664 openscop_read_one_int (file); | |
665 } | |
666 | |
667 return transform_done; | |
668 } | |
669 | |
670 /* Initialize and return a file that will be used to write a scop. SCOP_NUMBER | |
671 is a sequential number (identifier) used to differentiate scop files. | |
672 Examples of the generated file names: dump_base_name.0.graphite, | |
673 dump_base_name.1.graphite, dump_base_name.2.graphite, etc. */ | |
674 | |
675 static FILE * | |
676 init_graphite_out_file (int scop_number) | |
677 { | |
678 FILE *graphite_out_file; | |
679 int len = strlen (dump_base_name); | |
680 char *dumpname = XNEWVEC (char, len + 25); | |
681 char *s_scop_number = XNEWVEC (char, 15); | |
682 | |
683 memcpy (dumpname, dump_base_name, len + 1); | |
684 strip_off_ending (dumpname, len); | |
685 sprintf (s_scop_number, ".%d", scop_number); | |
686 strcat (dumpname, s_scop_number); | |
687 strcat (dumpname, ".graphite"); | |
688 graphite_out_file = fopen (dumpname, "w+b"); | |
689 | |
690 if (graphite_out_file == 0) | |
691 fatal_error ("can%'t open %s for writing: %m", dumpname); | |
692 | |
693 free (dumpname); | |
694 | |
695 return graphite_out_file; | |
696 } | |
697 | |
698 /* Open and return a file used for scop reading. SCOP_NUMBER is a sequential | |
699 number (identifier) used to differentiate scop files. Examples of the | |
700 generated file names: dump_base_name.0.graphite, dump_base_name.1.graphite, | |
701 dump_base_name.2.graphite, etc. */ | |
702 | |
703 static FILE * | |
704 init_graphite_in_file (int scop_number) | |
705 { | |
706 FILE *graphite_in_file; | |
707 int len = strlen (dump_base_name); | |
708 char *dumpname = XNEWVEC (char, len + 25); | |
709 char *s_scop_number = XNEWVEC (char, 15); | |
710 | |
711 memcpy (dumpname, dump_base_name, len + 1); | |
712 strip_off_ending (dumpname, len); | |
713 sprintf (s_scop_number, ".%d", scop_number); | |
714 strcat (dumpname, s_scop_number); | |
715 strcat (dumpname, ".graphite"); | |
716 graphite_in_file = fopen (dumpname, "r+b"); | |
717 | |
718 if (graphite_in_file == 0) | |
719 fatal_error ("can%'t open %s for reading: %m", dumpname); | |
720 | |
721 free (dumpname); | |
722 | |
723 return graphite_in_file; | |
724 } | |
278 | 725 |
279 /* Apply graphite transformations to all the basic blocks of SCOP. */ | 726 /* Apply graphite transformations to all the basic blocks of SCOP. */ |
280 | 727 |
281 bool | 728 bool |
282 apply_poly_transforms (scop_p scop) | 729 apply_poly_transforms (scop_p scop) |
283 { | 730 { |
284 bool transform_done = false; | 731 bool transform_done = false; |
732 FILE *graphite_file; | |
733 static size_t file_scop_number = 0; | |
734 | |
735 /* This feature is only enabled in the Graphite branch. */ | |
736 if (0) | |
737 { | |
738 graphite_file = init_graphite_in_file (file_scop_number); | |
739 transform_done |= graphite_read_scop_file (graphite_file, scop); | |
740 | |
741 if (!graphite_legal_transform (scop)) | |
742 fatal_error ("the graphite file read for scop %d does not contain a legal transform", | |
743 (int) file_scop_number); | |
744 | |
745 file_scop_number++; | |
746 } | |
285 | 747 |
286 /* Generate code even if we did not apply any real transformation. | 748 /* Generate code even if we did not apply any real transformation. |
287 This also allows to check the performance for the identity | 749 This also allows to check the performance for the identity |
288 transformation: GIMPLE -> GRAPHITE -> GIMPLE | 750 transformation: GIMPLE -> GRAPHITE -> GIMPLE |
289 Keep in mind that CLooG optimizes in control, so the loop structure | 751 Keep in mind that CLooG optimizes in control, so the loop structure |
297 if (flag_loop_block) | 759 if (flag_loop_block) |
298 transform_done |= scop_do_block (scop); | 760 transform_done |= scop_do_block (scop); |
299 else | 761 else |
300 { | 762 { |
301 if (flag_loop_strip_mine) | 763 if (flag_loop_strip_mine) |
302 transform_done |= scop_do_strip_mine (scop); | 764 transform_done |= scop_do_strip_mine (scop, 0); |
303 | 765 |
304 if (flag_loop_interchange) | 766 if (flag_loop_interchange) |
305 transform_done |= scop_do_interchange (scop); | 767 transform_done |= scop_do_interchange (scop); |
768 } | |
769 | |
770 if (flag_loop_flatten) | |
771 transform_done |= flatten_all_loops (scop); | |
772 | |
773 /* This feature is only enabled in the Graphite branch. */ | |
774 if (0) | |
775 { | |
776 graphite_file = init_graphite_out_file (file_scop_number); | |
777 print_scop (graphite_file, scop, 1); | |
778 file_scop_number++; | |
306 } | 779 } |
307 | 780 |
308 return transform_done; | 781 return transform_done; |
309 } | 782 } |
310 | 783 |
338 void | 811 void |
339 pbb_remove_duplicate_pdrs (poly_bb_p pbb) | 812 pbb_remove_duplicate_pdrs (poly_bb_p pbb) |
340 { | 813 { |
341 int i, j; | 814 int i, j; |
342 poly_dr_p pdr1, pdr2; | 815 poly_dr_p pdr1, pdr2; |
343 unsigned n = VEC_length (poly_dr_p, PBB_DRS (pbb)); | 816 |
344 VEC (poly_dr_p, heap) *collapsed = VEC_alloc (poly_dr_p, heap, n); | 817 FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb), i, pdr1) |
345 | 818 for (j = i + 1; VEC_iterate (poly_dr_p, PBB_DRS (pbb), j, pdr2); j++) |
346 for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb), i, pdr1); i++) | 819 if (can_collapse_pdrs (pdr1, pdr2)) |
347 for (j = 0; VEC_iterate (poly_dr_p, collapsed, j, pdr2); j++) | 820 { |
348 if (!can_collapse_pdrs (pdr1, pdr2)) | 821 PDR_NB_REFS (pdr1) += PDR_NB_REFS (pdr2); |
349 VEC_quick_push (poly_dr_p, collapsed, pdr1); | 822 free_poly_dr (pdr2); |
350 | 823 VEC_ordered_remove (poly_dr_p, PBB_DRS (pbb), j); |
351 VEC_free (poly_dr_p, heap, collapsed); | 824 } |
825 | |
352 PBB_PDR_DUPLICATES_REMOVED (pbb) = true; | 826 PBB_PDR_DUPLICATES_REMOVED (pbb) = true; |
353 } | 827 } |
354 | 828 |
355 /* Create a new polyhedral data reference and add it to PBB. It is | 829 /* Create a new polyhedral data reference and add it to PBB. It is |
356 defined by its ACCESSES, its TYPE, and the number of subscripts | 830 defined by its ACCESSES, its TYPE, and the number of subscripts |
384 XDELETE (pdr); | 858 XDELETE (pdr); |
385 } | 859 } |
386 | 860 |
387 /* Create a new polyhedral black box. */ | 861 /* Create a new polyhedral black box. */ |
388 | 862 |
389 void | 863 poly_bb_p |
390 new_poly_bb (scop_p scop, void *black_box, bool reduction) | 864 new_poly_bb (scop_p scop, void *black_box) |
391 { | 865 { |
392 poly_bb_p pbb = XNEW (struct poly_bb); | 866 poly_bb_p pbb = XNEW (struct poly_bb); |
393 | 867 |
394 PBB_DOMAIN (pbb) = NULL; | 868 PBB_DOMAIN (pbb) = NULL; |
395 PBB_SCOP (pbb) = scop; | 869 PBB_SCOP (pbb) = scop; |
396 pbb_set_black_box (pbb, black_box); | 870 pbb_set_black_box (pbb, black_box); |
397 PBB_TRANSFORMED (pbb) = NULL; | 871 PBB_TRANSFORMED (pbb) = NULL; |
398 PBB_SAVED (pbb) = NULL; | 872 PBB_SAVED (pbb) = NULL; |
399 PBB_ORIGINAL (pbb) = NULL; | 873 PBB_ORIGINAL (pbb) = NULL; |
400 PBB_DRS (pbb) = VEC_alloc (poly_dr_p, heap, 3); | 874 PBB_DRS (pbb) = VEC_alloc (poly_dr_p, heap, 3); |
401 PBB_IS_REDUCTION (pbb) = reduction; | 875 PBB_IS_REDUCTION (pbb) = false; |
402 PBB_PDR_DUPLICATES_REMOVED (pbb) = false; | 876 PBB_PDR_DUPLICATES_REMOVED (pbb) = false; |
403 VEC_safe_push (poly_bb_p, heap, SCOP_BBS (scop), pbb); | 877 GBB_PBB ((gimple_bb_p) black_box) = pbb; |
878 | |
879 return pbb; | |
404 } | 880 } |
405 | 881 |
406 /* Free polyhedral black box. */ | 882 /* Free polyhedral black box. */ |
407 | 883 |
408 void | 884 void |
421 | 897 |
422 if (PBB_ORIGINAL (pbb)) | 898 if (PBB_ORIGINAL (pbb)) |
423 poly_scattering_free (PBB_ORIGINAL (pbb)); | 899 poly_scattering_free (PBB_ORIGINAL (pbb)); |
424 | 900 |
425 if (PBB_DRS (pbb)) | 901 if (PBB_DRS (pbb)) |
426 for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb), i, pdr); i++) | 902 FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb), i, pdr) |
427 free_poly_dr (pdr); | 903 free_poly_dr (pdr); |
428 | 904 |
429 VEC_free (poly_dr_p, heap, PBB_DRS (pbb)); | 905 VEC_free (poly_dr_p, heap, PBB_DRS (pbb)); |
430 XDELETE (pbb); | 906 XDELETE (pbb); |
431 } | 907 } |
432 | 908 |
433 static void | 909 static void |
434 print_pdr_access_layout (FILE *file, poly_dr_p pdr) | 910 print_pdr_access_layout (FILE *file, poly_bb_p pbb, poly_dr_p pdr) |
435 { | 911 { |
436 graphite_dim_t i; | 912 graphite_dim_t i; |
437 | 913 |
438 fprintf (file, "# eq"); | 914 fprintf (file, "# eq"); |
439 | 915 |
440 for (i = 0; i < pdr_dim_iter_domain (pdr); i++) | 916 fprintf (file, " alias"); |
441 fprintf (file, " i%d", (int) i); | |
442 | |
443 for (i = 0; i < pdr_nb_params (pdr); i++) | |
444 fprintf (file, " p%d", (int) i); | |
445 | |
446 fprintf (file, " alias"); | |
447 | 917 |
448 for (i = 0; i < PDR_NB_SUBSCRIPTS (pdr); i++) | 918 for (i = 0; i < PDR_NB_SUBSCRIPTS (pdr); i++) |
449 fprintf (file, " sub%d", (int) i); | 919 fprintf (file, " sub%d", (int) i); |
450 | 920 |
921 for (i = 0; i < pbb_dim_iter_domain (pbb); i++) | |
922 fprintf (file, " i%d", (int) i); | |
923 | |
924 for (i = 0; i < pbb_nb_params (pbb); i++) | |
925 fprintf (file, " p%d", (int) i); | |
926 | |
451 fprintf (file, " cst\n"); | 927 fprintf (file, " cst\n"); |
452 } | 928 } |
453 | 929 |
454 /* Prints to FILE the polyhedral data reference PDR, at some VERBOSITY | 930 /* Prints to FILE the polyhedral data reference PDR, at some VERBOSITY |
455 level. */ | 931 level. */ |
456 | 932 |
457 void | 933 void |
458 print_pdr (FILE *file, poly_dr_p pdr, int verbosity) | 934 print_pdr (FILE *file, poly_dr_p pdr, int verbosity) |
459 { | 935 { |
936 int alias_set_dim; | |
937 | |
460 if (verbosity > 1) | 938 if (verbosity > 1) |
461 { | 939 { |
462 fprintf (file, "# pdr_%d (", PDR_ID (pdr)); | 940 fprintf (file, "# pdr_%d (", PDR_ID (pdr)); |
463 | 941 |
464 switch (PDR_TYPE (pdr)) | 942 switch (PDR_TYPE (pdr)) |
483 } | 961 } |
484 | 962 |
485 if (verbosity > 0) | 963 if (verbosity > 0) |
486 { | 964 { |
487 fprintf (file, "# data accesses (\n"); | 965 fprintf (file, "# data accesses (\n"); |
488 print_pdr_access_layout (file, pdr); | 966 print_pdr_access_layout (file, PDR_PBB (pdr), pdr); |
489 } | 967 } |
490 | 968 |
491 ppl_print_powerset_matrix (file, PDR_ACCESSES (pdr)); | 969 alias_set_dim = pdr_alias_set_dim (pdr) + 1; |
970 | |
971 openscop_print_pdr_powerset (file, | |
972 PDR_ACCESSES (pdr), | |
973 PDR_NB_SUBSCRIPTS (pdr), | |
974 alias_set_dim, | |
975 pbb_nb_params (PDR_PBB (pdr))); | |
492 | 976 |
493 if (verbosity > 0) | 977 if (verbosity > 0) |
494 fprintf (file, "#)\n"); | 978 fprintf (file, "#)\n"); |
495 | 979 |
496 if (verbosity > 1) | 980 if (verbosity > 1) |
498 } | 982 } |
499 | 983 |
500 /* Prints to STDERR the polyhedral data reference PDR, at some | 984 /* Prints to STDERR the polyhedral data reference PDR, at some |
501 VERBOSITY level. */ | 985 VERBOSITY level. */ |
502 | 986 |
503 void | 987 DEBUG_FUNCTION void |
504 debug_pdr (poly_dr_p pdr, int verbosity) | 988 debug_pdr (poly_dr_p pdr, int verbosity) |
505 { | 989 { |
506 print_pdr (stderr, pdr, verbosity); | 990 print_pdr (stderr, pdr, verbosity); |
507 } | 991 } |
508 | 992 |
532 free_scop (scop_p scop) | 1016 free_scop (scop_p scop) |
533 { | 1017 { |
534 int i; | 1018 int i; |
535 poly_bb_p pbb; | 1019 poly_bb_p pbb; |
536 | 1020 |
537 for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++) | 1021 FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb) |
538 free_poly_bb (pbb); | 1022 free_poly_bb (pbb); |
539 | 1023 |
540 VEC_free (poly_bb_p, heap, SCOP_BBS (scop)); | 1024 VEC_free (poly_bb_p, heap, SCOP_BBS (scop)); |
541 | 1025 |
542 if (SCOP_CONTEXT (scop)) | 1026 if (SCOP_CONTEXT (scop)) |
547 free_lst (SCOP_TRANSFORMED_SCHEDULE (scop)); | 1031 free_lst (SCOP_TRANSFORMED_SCHEDULE (scop)); |
548 free_lst (SCOP_SAVED_SCHEDULE (scop)); | 1032 free_lst (SCOP_SAVED_SCHEDULE (scop)); |
549 XDELETE (scop); | 1033 XDELETE (scop); |
550 } | 1034 } |
551 | 1035 |
1036 /* Print to FILE the domain of PBB in OpenScop format, at some VERBOSITY | |
1037 level. */ | |
1038 | |
1039 static void | |
1040 openscop_print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity) | |
1041 { | |
1042 graphite_dim_t i; | |
1043 gimple_bb_p gbb = PBB_BLACK_BOX (pbb); | |
1044 | |
1045 if (!PBB_DOMAIN (pbb)) | |
1046 return; | |
1047 | |
1048 if (verbosity > 0) | |
1049 { | |
1050 fprintf (file, "\n# Iteration domain of bb_%d (\n", GBB_BB (gbb)->index); | |
1051 fprintf (file, "#eq"); | |
1052 | |
1053 for (i = 0; i < pbb_dim_iter_domain (pbb); i++) | |
1054 fprintf (file, " i%d", (int) i); | |
1055 | |
1056 for (i = 0; i < pbb_nb_params (pbb); i++) | |
1057 fprintf (file, " p%d", (int) i); | |
1058 | |
1059 fprintf (file, " cst\n"); | |
1060 } | |
1061 | |
1062 if (PBB_DOMAIN (pbb)) | |
1063 openscop_print_powerset_matrix (file, PBB_DOMAIN (pbb), | |
1064 pbb_dim_iter_domain (pbb), | |
1065 0, | |
1066 0, | |
1067 pbb_nb_params (pbb)); | |
1068 else | |
1069 fprintf (file, "0\n"); | |
1070 | |
1071 if (verbosity > 0) | |
1072 fprintf (file, "#)\n"); | |
1073 } | |
1074 | |
552 /* Print to FILE the domain of PBB, at some VERBOSITY level. */ | 1075 /* Print to FILE the domain of PBB, at some VERBOSITY level. */ |
553 | 1076 |
554 void | 1077 void |
555 print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity) | 1078 print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity) |
556 { | 1079 { |
599 if (VEC_empty (gimple, cases)) | 1122 if (VEC_empty (gimple, cases)) |
600 return; | 1123 return; |
601 | 1124 |
602 fprintf (file, "# cases bb_%d (\n", GBB_BB (gbb)->index); | 1125 fprintf (file, "# cases bb_%d (\n", GBB_BB (gbb)->index); |
603 | 1126 |
604 for (i = 0; VEC_iterate (gimple, cases, i, stmt); i++) | 1127 FOR_EACH_VEC_ELT (gimple, cases, i, stmt) |
605 { | 1128 { |
606 fprintf (file, "# "); | 1129 fprintf (file, "# "); |
607 print_gimple_stmt (file, stmt, 0, 0); | 1130 print_gimple_stmt (file, stmt, 0, 0); |
608 } | 1131 } |
609 | 1132 |
626 if (VEC_empty (gimple, conditions)) | 1149 if (VEC_empty (gimple, conditions)) |
627 return; | 1150 return; |
628 | 1151 |
629 fprintf (file, "# conditions bb_%d (\n", GBB_BB (gbb)->index); | 1152 fprintf (file, "# conditions bb_%d (\n", GBB_BB (gbb)->index); |
630 | 1153 |
631 for (i = 0; VEC_iterate (gimple, conditions, i, stmt); i++) | 1154 FOR_EACH_VEC_ELT (gimple, conditions, i, stmt) |
632 { | 1155 { |
633 fprintf (file, "# "); | 1156 fprintf (file, "# "); |
634 print_gimple_stmt (file, stmt, 0, 0); | 1157 print_gimple_stmt (file, stmt, 0, 0); |
635 } | 1158 } |
636 | 1159 |
661 | 1184 |
662 if (verbosity > 0) | 1185 if (verbosity > 0) |
663 fprintf (file, "# Access informations are provided\n"); | 1186 fprintf (file, "# Access informations are provided\n"); |
664 fprintf (file, "1\n"); | 1187 fprintf (file, "1\n"); |
665 | 1188 |
666 for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb), i, pdr); i++) | 1189 FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb), i, pdr) |
667 if (PDR_TYPE (pdr) == PDR_READ) | 1190 if (PDR_TYPE (pdr) == PDR_READ) |
668 nb_reads++; | 1191 nb_reads++; |
669 else | 1192 else |
670 nb_writes++; | 1193 nb_writes++; |
671 | 1194 |
674 | 1197 |
675 if (verbosity > 0) | 1198 if (verbosity > 0) |
676 fprintf (file, "# Read access informations\n"); | 1199 fprintf (file, "# Read access informations\n"); |
677 fprintf (file, "%d\n", nb_reads); | 1200 fprintf (file, "%d\n", nb_reads); |
678 | 1201 |
679 for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb), i, pdr); i++) | 1202 FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb), i, pdr) |
680 if (PDR_TYPE (pdr) == PDR_READ) | 1203 if (PDR_TYPE (pdr) == PDR_READ) |
681 print_pdr (file, pdr, verbosity); | 1204 print_pdr (file, pdr, verbosity); |
682 | 1205 |
683 if (verbosity > 1) | 1206 if (verbosity > 1) |
684 fprintf (file, "#)\n"); | 1207 fprintf (file, "#)\n"); |
688 | 1211 |
689 if (verbosity > 0) | 1212 if (verbosity > 0) |
690 fprintf (file, "# Write access informations\n"); | 1213 fprintf (file, "# Write access informations\n"); |
691 fprintf (file, "%d\n", nb_writes); | 1214 fprintf (file, "%d\n", nb_writes); |
692 | 1215 |
693 for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb), i, pdr); i++) | 1216 FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb), i, pdr) |
694 if (PDR_TYPE (pdr) != PDR_READ) | 1217 if (PDR_TYPE (pdr) != PDR_READ) |
695 print_pdr (file, pdr, verbosity); | 1218 print_pdr (file, pdr, verbosity); |
696 | 1219 |
697 if (verbosity > 1) | 1220 if (verbosity > 1) |
698 fprintf (file, "#)\n"); | 1221 fprintf (file, "#)\n"); |
701 fprintf (file, "#)\n"); | 1224 fprintf (file, "#)\n"); |
702 } | 1225 } |
703 | 1226 |
704 /* Print to STDERR all the data references of PBB. */ | 1227 /* Print to STDERR all the data references of PBB. */ |
705 | 1228 |
706 void | 1229 DEBUG_FUNCTION void |
707 debug_pdrs (poly_bb_p pbb, int verbosity) | 1230 debug_pdrs (poly_bb_p pbb, int verbosity) |
708 { | 1231 { |
709 print_pdrs (stderr, pbb, verbosity); | 1232 print_pdrs (stderr, pbb, verbosity); |
710 } | 1233 } |
711 | 1234 |
712 /* Print to FILE the body of PBB, at some VERBOSITY level. */ | 1235 /* Print to FILE the body of PBB, at some VERBOSITY level. |
1236 If statement_body_provided is false statement body is not printed. */ | |
713 | 1237 |
714 static void | 1238 static void |
715 print_pbb_body (FILE *file, poly_bb_p pbb, int verbosity) | 1239 print_pbb_body (FILE *file, poly_bb_p pbb, int verbosity, |
1240 bool statement_body_provided) | |
716 { | 1241 { |
717 if (verbosity > 1) | 1242 if (verbosity > 1) |
718 fprintf (file, "# Body (\n"); | 1243 fprintf (file, "# Body (\n"); |
1244 | |
1245 if (!statement_body_provided) | |
1246 { | |
1247 if (verbosity > 0) | |
1248 fprintf (file, "# Statement body is not provided\n"); | |
1249 | |
1250 fprintf (file, "0\n"); | |
1251 | |
1252 if (verbosity > 1) | |
1253 fprintf (file, "#)\n"); | |
1254 return; | |
1255 } | |
719 | 1256 |
720 if (verbosity > 0) | 1257 if (verbosity > 0) |
721 fprintf (file, "# Statement body is provided\n"); | 1258 fprintf (file, "# Statement body is provided\n"); |
722 fprintf (file, "1\n"); | 1259 fprintf (file, "1\n"); |
723 | 1260 |
746 fprintf (file, "# pbb_%d (\n", pbb_index (pbb)); | 1283 fprintf (file, "# pbb_%d (\n", pbb_index (pbb)); |
747 dump_gbb_conditions (file, PBB_BLACK_BOX (pbb)); | 1284 dump_gbb_conditions (file, PBB_BLACK_BOX (pbb)); |
748 dump_gbb_cases (file, PBB_BLACK_BOX (pbb)); | 1285 dump_gbb_cases (file, PBB_BLACK_BOX (pbb)); |
749 } | 1286 } |
750 | 1287 |
751 print_pbb_domain (file, pbb, verbosity); | 1288 openscop_print_pbb_domain (file, pbb, verbosity); |
752 print_scattering_function (file, pbb, verbosity); | 1289 print_scattering_function (file, pbb, verbosity); |
753 print_pdrs (file, pbb, verbosity); | 1290 print_pdrs (file, pbb, verbosity); |
754 print_pbb_body (file, pbb, verbosity); | 1291 print_pbb_body (file, pbb, verbosity, false); |
755 | 1292 |
756 if (verbosity > 1) | 1293 if (verbosity > 1) |
757 fprintf (file, "#)\n"); | 1294 fprintf (file, "#)\n"); |
758 } | 1295 } |
759 | 1296 |
783 if (verbosity > 0) | 1320 if (verbosity > 0) |
784 fprintf (file, "# Parameter names are not provided\n"); | 1321 fprintf (file, "# Parameter names are not provided\n"); |
785 fprintf (file, "0\n"); | 1322 fprintf (file, "0\n"); |
786 } | 1323 } |
787 | 1324 |
788 for (i = 0; VEC_iterate (tree, SESE_PARAMS (SCOP_REGION (scop)), i, t); i++) | 1325 FOR_EACH_VEC_ELT (tree, SESE_PARAMS (SCOP_REGION (scop)), i, t) |
789 { | 1326 { |
790 print_generic_expr (file, t, 0); | 1327 print_generic_expr (file, t, 0); |
791 fprintf (file, " "); | 1328 fprintf (file, " "); |
792 } | 1329 } |
793 | 1330 |
795 | 1332 |
796 if (verbosity > 1) | 1333 if (verbosity > 1) |
797 fprintf (file, "#)\n"); | 1334 fprintf (file, "#)\n"); |
798 } | 1335 } |
799 | 1336 |
1337 /* Print to FILE the context of SCoP in OpenScop format, at some VERBOSITY | |
1338 level. */ | |
1339 | |
1340 static void | |
1341 openscop_print_scop_context (FILE *file, scop_p scop, int verbosity) | |
1342 { | |
1343 graphite_dim_t i; | |
1344 | |
1345 if (verbosity > 0) | |
1346 { | |
1347 fprintf (file, "# Context (\n"); | |
1348 fprintf (file, "#eq"); | |
1349 | |
1350 for (i = 0; i < scop_nb_params (scop); i++) | |
1351 fprintf (file, " p%d", (int) i); | |
1352 | |
1353 fprintf (file, " cst\n"); | |
1354 } | |
1355 | |
1356 if (SCOP_CONTEXT (scop)) | |
1357 openscop_print_powerset_matrix (file, SCOP_CONTEXT (scop), 0, 0, 0, | |
1358 scop_nb_params (scop)); | |
1359 else | |
1360 fprintf (file, "0 %d 0 0 0 %d\n", (int) scop_nb_params (scop) + 2, | |
1361 (int) scop_nb_params (scop)); | |
1362 | |
1363 if (verbosity > 0) | |
1364 fprintf (file, "# )\n"); | |
1365 } | |
1366 | |
800 /* Print to FILE the context of SCoP, at some VERBOSITY level. */ | 1367 /* Print to FILE the context of SCoP, at some VERBOSITY level. */ |
801 | 1368 |
802 void | 1369 void |
803 print_scop_context (FILE *file, scop_p scop, int verbosity) | 1370 print_scop_context (FILE *file, scop_p scop, int verbosity) |
804 { | 1371 { |
805 graphite_dim_t i; | 1372 graphite_dim_t i; |
806 | 1373 |
807 if (verbosity > 0) | 1374 if (verbosity > 0) |
808 { | 1375 { |
809 fprintf (file, "# Context (\n"); | 1376 fprintf (file, "# Context (\n"); |
810 fprintf (file, "# eq"); | 1377 fprintf (file, "#eq"); |
811 | 1378 |
812 for (i = 0; i < scop_nb_params (scop); i++) | 1379 for (i = 0; i < scop_nb_params (scop); i++) |
813 fprintf (file, " p%d", (int) i); | 1380 fprintf (file, " p%d", (int) i); |
814 | 1381 |
815 fprintf (file, " cst\n"); | 1382 fprintf (file, " cst\n"); |
830 print_scop (FILE *file, scop_p scop, int verbosity) | 1397 print_scop (FILE *file, scop_p scop, int verbosity) |
831 { | 1398 { |
832 int i; | 1399 int i; |
833 poly_bb_p pbb; | 1400 poly_bb_p pbb; |
834 | 1401 |
835 fprintf (file, "SCoP #(\n"); | 1402 fprintf (file, "SCoP 1\n#(\n"); |
836 fprintf (file, "# Language\nGimple\n"); | 1403 fprintf (file, "# Language\nGimple\n"); |
837 print_scop_context (file, scop, verbosity); | 1404 openscop_print_scop_context (file, scop, verbosity); |
838 print_scop_params (file, scop, verbosity); | 1405 print_scop_params (file, scop, verbosity); |
839 | 1406 |
840 if (verbosity > 0) | 1407 if (verbosity > 0) |
841 fprintf (file, "# Number of statements\n"); | 1408 fprintf (file, "# Number of statements\n"); |
842 | 1409 |
843 fprintf (file, "%d\n",VEC_length (poly_bb_p, SCOP_BBS (scop))); | 1410 fprintf (file, "%d\n",VEC_length (poly_bb_p, SCOP_BBS (scop))); |
844 | 1411 |
845 for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++) | 1412 FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb) |
846 print_pbb (file, pbb, verbosity); | 1413 print_pbb (file, pbb, verbosity); |
847 | 1414 |
848 if (verbosity > 1) | 1415 if (verbosity > 1) |
849 { | 1416 { |
850 fprintf (file, "# original_lst (\n"); | 1417 fprintf (file, "# original_lst (\n"); |
879 if (verbosity > 0) | 1446 if (verbosity > 0) |
880 fprintf (file, "# Number of statements\n"); | 1447 fprintf (file, "# Number of statements\n"); |
881 | 1448 |
882 fprintf (file, "%d\n", VEC_length (poly_bb_p, SCOP_BBS (scop))); | 1449 fprintf (file, "%d\n", VEC_length (poly_bb_p, SCOP_BBS (scop))); |
883 | 1450 |
884 for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++) | 1451 FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb) |
885 { | 1452 { |
886 if (verbosity > 1) | 1453 if (verbosity > 1) |
887 fprintf (file, "# pbb_%d (\n", pbb_index (pbb)); | 1454 fprintf (file, "# pbb_%d (\n", pbb_index (pbb)); |
888 | 1455 |
889 print_pbb_domain (file, pbb, verbosity); | 1456 print_pbb_domain (file, pbb, verbosity); |
908 fprintf (file, "# Number of scattering functions\n"); | 1475 fprintf (file, "# Number of scattering functions\n"); |
909 | 1476 |
910 fprintf (file, "%d\n", VEC_length (poly_bb_p, SCOP_BBS (scop))); | 1477 fprintf (file, "%d\n", VEC_length (poly_bb_p, SCOP_BBS (scop))); |
911 unify_scattering_dimensions (scop); | 1478 unify_scattering_dimensions (scop); |
912 | 1479 |
913 for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++) | 1480 FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb) |
914 { | 1481 { |
915 if (!PBB_TRANSFORMED (pbb) | 1482 if (!PBB_TRANSFORMED (pbb) |
916 || !(PBB_TRANSFORMED_SCATTERING (pbb) | 1483 || !(PBB_TRANSFORMED_SCATTERING (pbb) |
917 || PBB_ORIGINAL_SCATTERING (pbb))) | 1484 || PBB_ORIGINAL_SCATTERING (pbb))) |
918 continue; | 1485 continue; |
935 fprintf (file, "#)\n"); | 1502 fprintf (file, "#)\n"); |
936 } | 1503 } |
937 | 1504 |
938 /* Print to STDERR the domain of PBB, at some VERBOSITY level. */ | 1505 /* Print to STDERR the domain of PBB, at some VERBOSITY level. */ |
939 | 1506 |
940 void | 1507 DEBUG_FUNCTION void |
941 debug_pbb_domain (poly_bb_p pbb, int verbosity) | 1508 debug_pbb_domain (poly_bb_p pbb, int verbosity) |
942 { | 1509 { |
943 print_pbb_domain (stderr, pbb, verbosity); | 1510 print_pbb_domain (stderr, pbb, verbosity); |
944 } | 1511 } |
945 | 1512 |
946 /* Print to FILE the domain and scattering function of PBB, at some | 1513 /* Print to FILE the domain and scattering function of PBB, at some |
947 VERBOSITY level. */ | 1514 VERBOSITY level. */ |
948 | 1515 |
949 void | 1516 DEBUG_FUNCTION void |
950 debug_pbb (poly_bb_p pbb, int verbosity) | 1517 debug_pbb (poly_bb_p pbb, int verbosity) |
951 { | 1518 { |
952 print_pbb (stderr, pbb, verbosity); | 1519 print_pbb (stderr, pbb, verbosity); |
953 } | 1520 } |
954 | 1521 |
955 /* Print to STDERR the context of SCOP, at some VERBOSITY level. */ | 1522 /* Print to STDERR the context of SCOP, at some VERBOSITY level. */ |
956 | 1523 |
957 void | 1524 DEBUG_FUNCTION void |
958 debug_scop_context (scop_p scop, int verbosity) | 1525 debug_scop_context (scop_p scop, int verbosity) |
959 { | 1526 { |
960 print_scop_context (stderr, scop, verbosity); | 1527 print_scop_context (stderr, scop, verbosity); |
961 } | 1528 } |
962 | 1529 |
963 /* Print to STDERR the SCOP, at some VERBOSITY level. */ | 1530 /* Print to STDERR the SCOP, at some VERBOSITY level. */ |
964 | 1531 |
965 void | 1532 DEBUG_FUNCTION void |
966 debug_scop (scop_p scop, int verbosity) | 1533 debug_scop (scop_p scop, int verbosity) |
967 { | 1534 { |
968 print_scop (stderr, scop, verbosity); | 1535 print_scop (stderr, scop, verbosity); |
969 } | 1536 } |
970 | 1537 |
971 /* Print to STDERR the SCOP under CLooG format, at some VERBOSITY | 1538 /* Print to STDERR the SCOP under CLooG format, at some VERBOSITY |
972 level. */ | 1539 level. */ |
973 | 1540 |
974 void | 1541 DEBUG_FUNCTION void |
975 debug_cloog (scop_p scop, int verbosity) | 1542 debug_cloog (scop_p scop, int verbosity) |
976 { | 1543 { |
977 print_cloog (stderr, scop, verbosity); | 1544 print_cloog (stderr, scop, verbosity); |
978 } | 1545 } |
979 | 1546 |
980 /* Print to STDERR the parameters of SCOP, at some VERBOSITY | 1547 /* Print to STDERR the parameters of SCOP, at some VERBOSITY |
981 level. */ | 1548 level. */ |
982 | 1549 |
983 void | 1550 DEBUG_FUNCTION void |
984 debug_scop_params (scop_p scop, int verbosity) | 1551 debug_scop_params (scop_p scop, int verbosity) |
985 { | 1552 { |
986 print_scop_params (stderr, scop, verbosity); | 1553 print_scop_params (stderr, scop, verbosity); |
987 } | 1554 } |
988 | 1555 |
1017 ppl_Constraint_System_const_iterator_dereference (cit, &cstr); | 1584 ppl_Constraint_System_const_iterator_dereference (cit, &cstr); |
1018 ppl_new_Linear_Expression_from_Constraint (&expr, cstr); | 1585 ppl_new_Linear_Expression_from_Constraint (&expr, cstr); |
1019 ppl_Linear_Expression_coefficient (expr, iter, coef); | 1586 ppl_Linear_Expression_coefficient (expr, iter, coef); |
1020 ppl_Coefficient_to_mpz_t (coef, val); | 1587 ppl_Coefficient_to_mpz_t (coef, val); |
1021 | 1588 |
1022 if (mpz_sgn (val)) | 1589 if (mpz_sgn (val) == 0) |
1023 { | 1590 { |
1024 ppl_delete_Linear_Expression (expr); | 1591 ppl_delete_Linear_Expression (expr); |
1025 continue; | 1592 continue; |
1026 } | 1593 } |
1027 | 1594 |
1030 ppl_dimension_type scatter = psct_scattering_dim (pbb, i); | 1597 ppl_dimension_type scatter = psct_scattering_dim (pbb, i); |
1031 | 1598 |
1032 ppl_Linear_Expression_coefficient (expr, scatter, coef); | 1599 ppl_Linear_Expression_coefficient (expr, scatter, coef); |
1033 ppl_Coefficient_to_mpz_t (coef, val); | 1600 ppl_Coefficient_to_mpz_t (coef, val); |
1034 | 1601 |
1035 if (value_notzero_p (val)) | 1602 if (mpz_sgn (val) != 0) |
1036 { | 1603 { |
1037 mpz_clear (val); | 1604 mpz_clear (val); |
1038 ppl_delete_Linear_Expression (expr); | 1605 ppl_delete_Linear_Expression (expr); |
1039 ppl_delete_Coefficient (coef); | 1606 ppl_delete_Coefficient (coef); |
1040 ppl_delete_Constraint_System_const_iterator (cit); | 1607 ppl_delete_Constraint_System_const_iterator (cit); |
1046 } | 1613 } |
1047 | 1614 |
1048 gcc_unreachable (); | 1615 gcc_unreachable (); |
1049 } | 1616 } |
1050 | 1617 |
1051 /* Returns the number of iterations NITER of the loop around PBB at | 1618 /* Returns the number of iterations RES of the loop around PBB at |
1052 depth LOOP_DEPTH. */ | |
1053 | |
1054 void | |
1055 pbb_number_of_iterations (poly_bb_p pbb, | |
1056 graphite_dim_t loop_depth, | |
1057 mpz_t niter) | |
1058 { | |
1059 ppl_Linear_Expression_t le; | |
1060 ppl_dimension_type dim; | |
1061 | |
1062 ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PBB_DOMAIN (pbb), &dim); | |
1063 ppl_new_Linear_Expression_with_dimension (&le, dim); | |
1064 ppl_set_coef (le, pbb_iterator_dim (pbb, loop_depth), 1); | |
1065 mpz_set_si (niter, -1); | |
1066 ppl_max_for_le_pointset (PBB_DOMAIN (pbb), le, niter); | |
1067 ppl_delete_Linear_Expression (le); | |
1068 } | |
1069 | |
1070 /* Returns the number of iterations NITER of the loop around PBB at | |
1071 time(scattering) dimension TIME_DEPTH. */ | 1619 time(scattering) dimension TIME_DEPTH. */ |
1072 | 1620 |
1073 void | 1621 void |
1074 pbb_number_of_iterations_at_time (poly_bb_p pbb, | 1622 pbb_number_of_iterations_at_time (poly_bb_p pbb, |
1075 graphite_dim_t time_depth, | 1623 graphite_dim_t time_depth, |
1076 mpz_t niter) | 1624 mpz_t res) |
1077 { | 1625 { |
1078 ppl_Pointset_Powerset_C_Polyhedron_t ext_domain, sctr; | 1626 ppl_Pointset_Powerset_C_Polyhedron_t domain, sctr_lb, sctr_ub; |
1627 ppl_dimension_type domain_dim, sctr_dim; | |
1628 graphite_dim_t dim_iter_domain = pbb_dim_iter_domain (pbb); | |
1079 ppl_Linear_Expression_t le; | 1629 ppl_Linear_Expression_t le; |
1080 ppl_dimension_type dim; | 1630 mpz_t lb, ub, diff, one; |
1081 | 1631 int i; |
1082 /* Takes together domain and scattering polyhedrons, and composes | 1632 |
1083 them into the bigger polyhedron that has the following format: | 1633 ppl_Polyhedron_space_dimension (PBB_TRANSFORMED_SCATTERING (pbb), &sctr_dim); |
1084 | 1634 |
1085 t0..t_{n-1} | l0..l_{nlcl-1} | i0..i_{niter-1} | g0..g_{nparm-1} | |
1086 | |
1087 where | |
1088 | t0..t_{n-1} are time dimensions (scattering dimensions) | |
1089 | l0..l_{nclc-1} are local variables in scattering function | |
1090 | i0..i_{niter-1} are original iteration variables | |
1091 | g0..g_{nparam-1} are global parameters. */ | |
1092 | |
1093 ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&sctr, | |
1094 PBB_TRANSFORMED_SCATTERING (pbb)); | |
1095 | |
1096 /* Extend the iteration domain with the scattering dimensions: | |
1097 0..0 | 0..0 | i0..i_{niter-1} | g0..g_{nparm-1}. */ | |
1098 ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron | 1635 ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron |
1099 (&ext_domain, PBB_DOMAIN (pbb)); | 1636 (&domain, PBB_DOMAIN (pbb)); |
1100 ppl_insert_dimensions_pointset (ext_domain, 0, | 1637 |
1101 pbb_nb_scattering_transform (pbb) | 1638 ppl_Pointset_Powerset_C_Polyhedron_space_dimension (domain, &domain_dim); |
1102 + pbb_nb_local_vars (pbb)); | 1639 |
1103 | 1640 mpz_init (diff); |
1104 /* Add to sctr the extended domain. */ | 1641 mpz_init (lb); |
1105 ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (sctr, ext_domain); | 1642 mpz_init (ub); |
1643 mpz_init (one); | |
1644 mpz_set_si (one, 1); | |
1645 | |
1646 /* Compute the upper bound on the original iteration domain and add | |
1647 that upper bound to the scattering. */ | |
1648 ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron | |
1649 (&sctr_ub, PBB_TRANSFORMED_SCATTERING (pbb)); | |
1650 for (i = 0; i < (int) dim_iter_domain; i++) | |
1651 { | |
1652 ppl_Linear_Expression_t eq; | |
1653 ppl_Constraint_t pc; | |
1654 ppl_Constraint_System_t cs; | |
1655 ppl_Polyhedron_t ph; | |
1656 ppl_Pointset_Powerset_C_Polyhedron_t pph; | |
1657 | |
1658 ppl_new_Linear_Expression_with_dimension (&le, domain_dim); | |
1659 ppl_set_coef (le, i, 1); | |
1660 ppl_min_for_le_pointset (domain, le, lb); | |
1661 ppl_max_for_le_pointset (domain, le, ub); | |
1662 mpz_sub (diff, ub, lb); | |
1663 mpz_add (diff, diff, one); | |
1664 | |
1665 ppl_new_Linear_Expression_with_dimension (&eq, sctr_dim); | |
1666 ppl_set_coef (eq, psct_iterator_dim (pbb, i), -1); | |
1667 ppl_set_inhomogeneous_gmp (eq, diff); | |
1668 | |
1669 ppl_new_Constraint (&pc, eq, PPL_CONSTRAINT_TYPE_EQUAL); | |
1670 ppl_new_Constraint_System_from_Constraint (&cs, pc); | |
1671 ppl_new_C_Polyhedron_from_Constraint_System (&ph, cs); | |
1672 ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&pph, ph); | |
1673 ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (sctr_ub, pph); | |
1674 | |
1675 ppl_delete_Linear_Expression (le); | |
1676 ppl_delete_Linear_Expression (eq); | |
1677 ppl_delete_Polyhedron (ph); | |
1678 ppl_delete_Pointset_Powerset_C_Polyhedron (pph); | |
1679 ppl_delete_Constraint (pc); | |
1680 ppl_delete_Constraint_System (cs); | |
1681 } | |
1682 | |
1683 /* Compute the lower bound on the original iteration domain and add | |
1684 it to the scattering. */ | |
1685 ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron | |
1686 (&sctr_lb, PBB_TRANSFORMED_SCATTERING (pbb)); | |
1687 for (i = 0; i < (int) dim_iter_domain; i++) | |
1688 { | |
1689 ppl_Linear_Expression_t eq; | |
1690 ppl_Constraint_t pc; | |
1691 ppl_Constraint_System_t cs; | |
1692 ppl_Polyhedron_t ph; | |
1693 ppl_Pointset_Powerset_C_Polyhedron_t pph; | |
1694 | |
1695 ppl_new_Linear_Expression_with_dimension (&le, domain_dim); | |
1696 ppl_set_coef (le, i, 1); | |
1697 ppl_min_for_le_pointset (domain, le, lb); | |
1698 | |
1699 ppl_new_Linear_Expression_with_dimension (&eq, sctr_dim); | |
1700 ppl_set_coef (eq, psct_iterator_dim (pbb, i), -1); | |
1701 ppl_set_inhomogeneous_gmp (eq, lb); | |
1702 | |
1703 ppl_new_Constraint (&pc, eq, PPL_CONSTRAINT_TYPE_EQUAL); | |
1704 ppl_new_Constraint_System_from_Constraint (&cs, pc); | |
1705 ppl_new_C_Polyhedron_from_Constraint_System (&ph, cs); | |
1706 ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&pph, ph); | |
1707 ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (sctr_lb, pph); | |
1708 | |
1709 ppl_delete_Linear_Expression (le); | |
1710 ppl_delete_Linear_Expression (eq); | |
1711 ppl_delete_Polyhedron (ph); | |
1712 ppl_delete_Pointset_Powerset_C_Polyhedron (pph); | |
1713 ppl_delete_Constraint (pc); | |
1714 ppl_delete_Constraint_System (cs); | |
1715 } | |
1106 | 1716 |
1107 /* Extract the number of iterations. */ | 1717 /* Extract the number of iterations. */ |
1108 ppl_Pointset_Powerset_C_Polyhedron_space_dimension (sctr, &dim); | 1718 ppl_new_Linear_Expression_with_dimension (&le, sctr_dim); |
1109 ppl_new_Linear_Expression_with_dimension (&le, dim); | |
1110 ppl_set_coef (le, time_depth, 1); | 1719 ppl_set_coef (le, time_depth, 1); |
1111 mpz_set_si (niter, -1); | 1720 ppl_min_for_le_pointset (sctr_lb, le, lb); |
1112 ppl_max_for_le_pointset (sctr, le, niter); | 1721 ppl_max_for_le_pointset (sctr_ub, le, ub); |
1113 | 1722 mpz_sub (res, ub, lb); |
1723 | |
1724 mpz_clear (one); | |
1725 mpz_clear (diff); | |
1726 mpz_clear (lb); | |
1727 mpz_clear (ub); | |
1114 ppl_delete_Linear_Expression (le); | 1728 ppl_delete_Linear_Expression (le); |
1115 ppl_delete_Pointset_Powerset_C_Polyhedron (sctr); | 1729 ppl_delete_Pointset_Powerset_C_Polyhedron (sctr_ub); |
1116 ppl_delete_Pointset_Powerset_C_Polyhedron (ext_domain); | 1730 ppl_delete_Pointset_Powerset_C_Polyhedron (sctr_lb); |
1731 ppl_delete_Pointset_Powerset_C_Polyhedron (domain); | |
1117 } | 1732 } |
1118 | 1733 |
1119 /* Translates LOOP to LST. */ | 1734 /* Translates LOOP to LST. */ |
1120 | 1735 |
1121 static lst_p | 1736 static lst_p |
1213 if (LST_LOOP_FATHER (lst)) | 1828 if (LST_LOOP_FATHER (lst)) |
1214 fprintf (file, "%d (loop", lst_dewey_number (lst)); | 1829 fprintf (file, "%d (loop", lst_dewey_number (lst)); |
1215 else | 1830 else |
1216 fprintf (file, "#(root"); | 1831 fprintf (file, "#(root"); |
1217 | 1832 |
1218 for (i = 0; VEC_iterate (lst_p, LST_SEQ (lst), i, l); i++) | 1833 FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l) |
1219 print_lst (file, l, indent + 2); | 1834 print_lst (file, l, indent + 2); |
1220 | 1835 |
1221 fprintf (file, ")"); | 1836 fprintf (file, ")"); |
1222 } | 1837 } |
1223 else | 1838 else |
1224 fprintf (file, "%d stmt_%d", lst_dewey_number (lst), pbb_index (LST_PBB (lst))); | 1839 fprintf (file, "%d stmt_%d", lst_dewey_number (lst), pbb_index (LST_PBB (lst))); |
1225 } | 1840 } |
1226 | 1841 |
1227 /* Print LST to STDERR. */ | 1842 /* Print LST to STDERR. */ |
1228 | 1843 |
1229 void | 1844 DEBUG_FUNCTION void |
1230 debug_lst (lst_p lst) | 1845 debug_lst (lst_p lst) |
1231 { | 1846 { |
1232 print_lst (stderr, lst, 0); | 1847 print_lst (stderr, lst, 0); |
1233 } | 1848 } |
1234 | 1849 |
1254 lst_depth (LST_LOOP_FATHER (lst)), | 1869 lst_depth (LST_LOOP_FATHER (lst)), |
1255 lst_dewey_number (LST_LOOP_FATHER (lst)), | 1870 lst_dewey_number (LST_LOOP_FATHER (lst)), |
1256 lst_depth (lst), | 1871 lst_depth (lst), |
1257 lst_dewey_number (lst)); | 1872 lst_dewey_number (lst)); |
1258 | 1873 |
1259 for (i = 0; VEC_iterate (lst_p, LST_SEQ (lst), i, l); i++) | 1874 FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l) |
1260 dot_lst_1 (file, l); | 1875 dot_lst_1 (file, l); |
1261 } | 1876 } |
1262 | 1877 |
1263 else | 1878 else |
1264 fprintf (file, "L_%d_%d -> S_%d\n", | 1879 fprintf (file, "L_%d_%d -> S_%d\n", |
1268 | 1883 |
1269 } | 1884 } |
1270 | 1885 |
1271 /* Display the LST using dotty. */ | 1886 /* Display the LST using dotty. */ |
1272 | 1887 |
1273 void | 1888 DEBUG_FUNCTION void |
1274 dot_lst (lst_p lst) | 1889 dot_lst (lst_p lst) |
1275 { | 1890 { |
1276 /* When debugging, enable the following code. This cannot be used | 1891 /* When debugging, enable the following code. This cannot be used |
1277 in production compilers because it calls "system". */ | 1892 in production compilers because it calls "system". */ |
1278 #if 0 | 1893 #if 0 |
1279 int x; | |
1280 FILE *stream = fopen ("/tmp/lst.dot", "w"); | 1894 FILE *stream = fopen ("/tmp/lst.dot", "w"); |
1281 gcc_assert (stream); | 1895 gcc_assert (stream); |
1282 | 1896 |
1283 fputs ("digraph all {\n", stream); | 1897 fputs ("digraph all {\n", stream); |
1284 dot_lst_1 (stream, lst); | 1898 dot_lst_1 (stream, lst); |
1285 fputs ("}\n\n", stream); | 1899 fputs ("}\n\n", stream); |
1286 fclose (stream); | 1900 fclose (stream); |
1287 | 1901 |
1288 x = system ("dotty /tmp/lst.dot"); | 1902 system ("dotty /tmp/lst.dot &"); |
1289 #else | 1903 #else |
1290 fputs ("digraph all {\n", stderr); | 1904 fputs ("digraph all {\n", stderr); |
1291 dot_lst_1 (stderr, lst); | 1905 dot_lst_1 (stderr, lst); |
1292 fputs ("}\n\n", stderr); | 1906 fputs ("}\n\n", stderr); |
1293 | 1907 |
1294 #endif | 1908 #endif |
1295 } | 1909 } |
1296 | 1910 |
1911 /* Computes a checksum for the code generated by CLooG for SCOP. */ | |
1912 | |
1913 DEBUG_FUNCTION void | |
1914 cloog_checksum (scop_p scop ATTRIBUTE_UNUSED) | |
1915 { | |
1916 /* When debugging, enable the following code. This cannot be used | |
1917 in production compilers because it calls "system". */ | |
1918 #if 0 | |
1919 FILE *stream = fopen ("/tmp/scop.cloog", "w"); | |
1920 gcc_assert (stream); | |
1921 print_cloog (stream, scop, 0); | |
1922 fclose (stream); | |
1923 | |
1924 fputs ("\n", stdout); | |
1925 system ("cloog -compilable 1 /tmp/scop.cloog > /tmp/scop.c ; gcc -O0 -g /tmp/scop.c -lm -o /tmp/scop; /tmp/scop | md5sum "); | |
1297 #endif | 1926 #endif |
1298 | 1927 } |
1928 | |
1929 #endif | |
1930 |