Mercurial > hg > CbC > CbC_gcc
comparison gcc/graphite-poly.h @ 63:b7f97abdc517 gcc-4.6-20100522
update gcc from gcc-4.5.0 to gcc-4.6
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 24 May 2010 12:47:05 +0900 |
parents | 77e2b8dfacca |
children | f6334be47118 |
comparison
equal
deleted
inserted
replaced
56:3c8a44c06a95 | 63:b7f97abdc517 |
---|---|
1 /* Graphite polyhedral representation. | 1 /* Graphite polyhedral representation. |
2 Copyright (C) 2009 Free Software Foundation, Inc. | 2 Copyright (C) 2009, 2010 Free Software Foundation, Inc. |
3 Contributed by Sebastian Pop <sebastian.pop@amd.com> and | 3 Contributed by Sebastian Pop <sebastian.pop@amd.com> and |
4 Tobias Grosser <grosser@fim.uni-passau.de>. | 4 Tobias Grosser <grosser@fim.uni-passau.de>. |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
153 #define PDR_NB_SUBSCRIPTS(PDR) (PDR->nb_subscripts) | 153 #define PDR_NB_SUBSCRIPTS(PDR) (PDR->nb_subscripts) |
154 | 154 |
155 void new_poly_dr (poly_bb_p, int, ppl_Pointset_Powerset_C_Polyhedron_t, | 155 void new_poly_dr (poly_bb_p, int, ppl_Pointset_Powerset_C_Polyhedron_t, |
156 enum poly_dr_type, void *, graphite_dim_t); | 156 enum poly_dr_type, void *, graphite_dim_t); |
157 void free_poly_dr (poly_dr_p); | 157 void free_poly_dr (poly_dr_p); |
158 void debug_pdr (poly_dr_p); | 158 void debug_pdr (poly_dr_p, int); |
159 void print_pdr (FILE *, poly_dr_p); | 159 void print_pdr (FILE *, poly_dr_p, int); |
160 static inline scop_p pdr_scop (poly_dr_p pdr); | 160 static inline scop_p pdr_scop (poly_dr_p pdr); |
161 | 161 |
162 /* The dimension of the PDR_ACCESSES polyhedron of PDR. */ | 162 /* The dimension of the PDR_ACCESSES polyhedron of PDR. */ |
163 | 163 |
164 static inline ppl_dimension_type | 164 static inline ppl_dimension_type |
261 | 261 |
262 typedef struct poly_scattering *poly_scattering_p; | 262 typedef struct poly_scattering *poly_scattering_p; |
263 | 263 |
264 struct poly_scattering | 264 struct poly_scattering |
265 { | 265 { |
266 /* The scattering function containing the transformations. */ | 266 /* The scattering function containing the transformations: the |
267 layout of this polyhedron is: T|I|G with T the transform | |
268 scattering, I the iteration domain, G the context parameters. */ | |
267 ppl_Polyhedron_t scattering; | 269 ppl_Polyhedron_t scattering; |
268 | 270 |
269 /* The number of local variables. */ | 271 /* The number of local variables. */ |
270 int nb_local_variables; | 272 int nb_local_variables; |
271 | 273 |
275 | 277 |
276 /* POLY_BB represents a blackbox in the polyhedral model. */ | 278 /* POLY_BB represents a blackbox in the polyhedral model. */ |
277 | 279 |
278 struct poly_bb | 280 struct poly_bb |
279 { | 281 { |
282 /* Pointer to a basic block or a statement in the compiler. */ | |
280 void *black_box; | 283 void *black_box; |
281 | 284 |
285 /* Pointer to the SCOP containing this PBB. */ | |
282 scop_p scop; | 286 scop_p scop; |
283 | 287 |
284 /* The iteration domain of this bb. | 288 /* The iteration domain of this bb. The layout of this polyhedron |
289 is I|G with I the iteration domain, G the context parameters. | |
290 | |
285 Example: | 291 Example: |
286 | 292 |
287 for (i = a - 7*b + 8; i <= 3*a + 13*b + 20; i++) | 293 for (i = a - 7*b + 8; i <= 3*a + 13*b + 20; i++) |
288 for (j = 2; j <= 2*i + 5; j++) | 294 for (j = 2; j <= 2*i + 5; j++) |
289 for (k = 0; k <= 5; k++) | 295 for (k = 0; k <= 5; k++) |
338 | 344 |
339 extern void new_poly_bb (scop_p, void *, bool); | 345 extern void new_poly_bb (scop_p, void *, bool); |
340 extern void free_poly_bb (poly_bb_p); | 346 extern void free_poly_bb (poly_bb_p); |
341 extern void debug_loop_vec (poly_bb_p); | 347 extern void debug_loop_vec (poly_bb_p); |
342 extern void schedule_to_scattering (poly_bb_p, int); | 348 extern void schedule_to_scattering (poly_bb_p, int); |
343 extern void print_pbb_domain (FILE *, poly_bb_p); | 349 extern void print_pbb_domain (FILE *, poly_bb_p, int); |
344 extern void print_pbb (FILE *, poly_bb_p); | 350 extern void print_pbb (FILE *, poly_bb_p, int); |
345 extern void print_scop_context (FILE *, scop_p); | 351 extern void print_scop_context (FILE *, scop_p, int); |
346 extern void print_scop (FILE *, scop_p); | 352 extern void print_scop (FILE *, scop_p, int); |
347 extern void debug_pbb_domain (poly_bb_p); | 353 extern void print_cloog (FILE *, scop_p, int); |
348 extern void debug_pbb (poly_bb_p); | 354 extern void debug_pbb_domain (poly_bb_p, int); |
349 extern void print_pdrs (FILE *, poly_bb_p); | 355 extern void debug_pbb (poly_bb_p, int); |
350 extern void debug_pdrs (poly_bb_p); | 356 extern void print_pdrs (FILE *, poly_bb_p, int); |
351 extern void debug_scop_context (scop_p); | 357 extern void debug_pdrs (poly_bb_p, int); |
352 extern void debug_scop (scop_p); | 358 extern void debug_scop_context (scop_p, int); |
353 extern void print_scop_params (FILE *, scop_p); | 359 extern void debug_scop (scop_p, int); |
354 extern void debug_scop_params (scop_p); | 360 extern void debug_cloog (scop_p, int); |
355 extern void print_iteration_domain (FILE *, poly_bb_p); | 361 extern void print_scop_params (FILE *, scop_p, int); |
356 extern void print_iteration_domains (FILE *, scop_p); | 362 extern void debug_scop_params (scop_p, int); |
357 extern void debug_iteration_domain (poly_bb_p); | 363 extern void print_iteration_domain (FILE *, poly_bb_p, int); |
358 extern void debug_iteration_domains (scop_p); | 364 extern void print_iteration_domains (FILE *, scop_p, int); |
365 extern void debug_iteration_domain (poly_bb_p, int); | |
366 extern void debug_iteration_domains (scop_p, int); | |
359 extern bool scop_do_interchange (scop_p); | 367 extern bool scop_do_interchange (scop_p); |
360 extern bool scop_do_strip_mine (scop_p); | 368 extern bool scop_do_strip_mine (scop_p); |
361 extern bool scop_do_block (scop_p); | 369 extern bool scop_do_block (scop_p); |
362 extern void pbb_number_of_iterations (poly_bb_p, graphite_dim_t, Value); | 370 extern void pbb_number_of_iterations (poly_bb_p, graphite_dim_t, mpz_t); |
363 extern void pbb_number_of_iterations_at_time (poly_bb_p, graphite_dim_t, Value); | 371 extern void pbb_number_of_iterations_at_time (poly_bb_p, graphite_dim_t, mpz_t); |
364 extern void pbb_remove_duplicate_pdrs (poly_bb_p); | 372 extern void pbb_remove_duplicate_pdrs (poly_bb_p); |
365 | 373 |
366 /* Return the number of write data references in PBB. */ | 374 /* Return the number of write data references in PBB. */ |
367 | 375 |
368 static inline int | 376 static inline int |
377 res++; | 385 res++; |
378 | 386 |
379 return res; | 387 return res; |
380 } | 388 } |
381 | 389 |
390 /* The basic block of the PBB. */ | |
391 static inline basic_block | |
392 pbb_bb (poly_bb_p pbb) | |
393 { | |
394 return GBB_BB (PBB_BLACK_BOX (pbb)); | |
395 } | |
396 | |
382 /* The index of the PBB. */ | 397 /* The index of the PBB. */ |
383 | 398 |
384 static inline int | 399 static inline int |
385 pbb_index (poly_bb_p pbb) | 400 pbb_index (poly_bb_p pbb) |
386 { | 401 { |
387 return GBB_BB (PBB_BLACK_BOX (pbb))->index; | 402 return pbb_bb (pbb)->index; |
388 } | 403 } |
389 | 404 |
390 /* The loop of the PBB. */ | 405 /* The loop of the PBB. */ |
391 | 406 |
392 static inline loop_p | 407 static inline loop_p |
629 /* LOOP_P is true when an LST node is a loop. */ | 644 /* LOOP_P is true when an LST node is a loop. */ |
630 bool loop_p; | 645 bool loop_p; |
631 | 646 |
632 /* A pointer to the loop that contains this node. */ | 647 /* A pointer to the loop that contains this node. */ |
633 lst_p loop_father; | 648 lst_p loop_father; |
649 | |
650 /* The sum of all the memory strides for an LST loop. */ | |
651 mpz_t memory_strides; | |
634 | 652 |
635 /* Loop nodes contain a sequence SEQ of LST nodes, statements | 653 /* Loop nodes contain a sequence SEQ of LST nodes, statements |
636 contain a pointer to their polyhedral representation PBB. */ | 654 contain a pointer to their polyhedral representation PBB. */ |
637 union { | 655 union { |
638 poly_bb_p pbb; | 656 poly_bb_p pbb; |
642 | 660 |
643 #define LST_LOOP_P(LST) ((LST)->loop_p) | 661 #define LST_LOOP_P(LST) ((LST)->loop_p) |
644 #define LST_LOOP_FATHER(LST) ((LST)->loop_father) | 662 #define LST_LOOP_FATHER(LST) ((LST)->loop_father) |
645 #define LST_PBB(LST) ((LST)->node.pbb) | 663 #define LST_PBB(LST) ((LST)->node.pbb) |
646 #define LST_SEQ(LST) ((LST)->node.seq) | 664 #define LST_SEQ(LST) ((LST)->node.seq) |
665 #define LST_LOOP_MEMORY_STRIDES(LST) ((LST)->memory_strides) | |
647 | 666 |
648 void scop_to_lst (scop_p); | 667 void scop_to_lst (scop_p); |
649 void print_lst (FILE *, lst_p, int); | 668 void print_lst (FILE *, lst_p, int); |
650 void debug_lst (lst_p); | 669 void debug_lst (lst_p); |
651 void dot_lst (lst_p); | 670 void dot_lst (lst_p); |
660 lst_p l; | 679 lst_p l; |
661 | 680 |
662 LST_LOOP_P (lst) = true; | 681 LST_LOOP_P (lst) = true; |
663 LST_SEQ (lst) = seq; | 682 LST_SEQ (lst) = seq; |
664 LST_LOOP_FATHER (lst) = NULL; | 683 LST_LOOP_FATHER (lst) = NULL; |
684 mpz_init (LST_LOOP_MEMORY_STRIDES (lst)); | |
685 mpz_set_si (LST_LOOP_MEMORY_STRIDES (lst), -1); | |
665 | 686 |
666 for (i = 0; VEC_iterate (lst_p, seq, i, l); i++) | 687 for (i = 0; VEC_iterate (lst_p, seq, i, l); i++) |
667 LST_LOOP_FATHER (l) = lst; | 688 LST_LOOP_FATHER (l) = lst; |
668 | 689 |
669 return lst; | 690 return lst; |
696 lst_p l; | 717 lst_p l; |
697 | 718 |
698 for (i = 0; VEC_iterate (lst_p, LST_SEQ (lst), i, l); i++) | 719 for (i = 0; VEC_iterate (lst_p, LST_SEQ (lst), i, l); i++) |
699 free_lst (l); | 720 free_lst (l); |
700 | 721 |
722 mpz_clear (LST_LOOP_MEMORY_STRIDES (lst)); | |
701 VEC_free (lst_p, heap, LST_SEQ (lst)); | 723 VEC_free (lst_p, heap, LST_SEQ (lst)); |
702 } | 724 } |
703 | 725 |
704 free (lst); | 726 free (lst); |
705 } | 727 } |
1294 ppl_Pointset_Powerset_C_Polyhedron_t context; | 1316 ppl_Pointset_Powerset_C_Polyhedron_t context; |
1295 | 1317 |
1296 /* A hashtable of the data dependence relations for the original | 1318 /* A hashtable of the data dependence relations for the original |
1297 scattering. */ | 1319 scattering. */ |
1298 htab_t original_pddrs; | 1320 htab_t original_pddrs; |
1321 | |
1322 /* True when the scop has been converted to its polyhedral | |
1323 representation. */ | |
1324 bool poly_scop_p; | |
1299 }; | 1325 }; |
1300 | 1326 |
1301 #define SCOP_BBS(S) (S->bbs) | 1327 #define SCOP_BBS(S) (S->bbs) |
1302 #define SCOP_REGION(S) ((sese) S->region) | 1328 #define SCOP_REGION(S) ((sese) S->region) |
1303 #define SCOP_CONTEXT(S) (S->context) | 1329 #define SCOP_CONTEXT(S) (S->context) |
1304 #define SCOP_ORIGINAL_PDDRS(S) (S->original_pddrs) | 1330 #define SCOP_ORIGINAL_PDDRS(S) (S->original_pddrs) |
1305 #define SCOP_ORIGINAL_SCHEDULE(S) (S->original_schedule) | 1331 #define SCOP_ORIGINAL_SCHEDULE(S) (S->original_schedule) |
1306 #define SCOP_TRANSFORMED_SCHEDULE(S) (S->transformed_schedule) | 1332 #define SCOP_TRANSFORMED_SCHEDULE(S) (S->transformed_schedule) |
1307 #define SCOP_SAVED_SCHEDULE(S) (S->saved_schedule) | 1333 #define SCOP_SAVED_SCHEDULE(S) (S->saved_schedule) |
1334 #define POLY_SCOP_P(S) (S->poly_scop_p) | |
1308 | 1335 |
1309 extern scop_p new_scop (void *); | 1336 extern scop_p new_scop (void *); |
1310 extern void free_scop (scop_p); | 1337 extern void free_scop (scop_p); |
1311 extern void free_scops (VEC (scop_p, heap) *); | 1338 extern void free_scops (VEC (scop_p, heap) *); |
1312 extern void print_generated_program (FILE *, scop_p); | 1339 extern void print_generated_program (FILE *, scop_p); |
1313 extern void debug_generated_program (scop_p); | 1340 extern void debug_generated_program (scop_p); |
1314 extern void print_scattering_function (FILE *, poly_bb_p); | 1341 extern void print_scattering_function (FILE *, poly_bb_p, int); |
1315 extern void print_scattering_functions (FILE *, scop_p); | 1342 extern void print_scattering_functions (FILE *, scop_p, int); |
1316 extern void debug_scattering_function (poly_bb_p); | 1343 extern void debug_scattering_function (poly_bb_p, int); |
1317 extern void debug_scattering_functions (scop_p); | 1344 extern void debug_scattering_functions (scop_p, int); |
1318 extern int scop_max_loop_depth (scop_p); | 1345 extern int scop_max_loop_depth (scop_p); |
1319 extern int unify_scattering_dimensions (scop_p); | 1346 extern int unify_scattering_dimensions (scop_p); |
1320 extern bool apply_poly_transforms (scop_p); | 1347 extern bool apply_poly_transforms (scop_p); |
1321 extern bool graphite_legal_transform (scop_p); | 1348 extern bool graphite_legal_transform (scop_p); |
1322 | 1349 |
1451 restore_scattering_pbb (pbb); | 1478 restore_scattering_pbb (pbb); |
1452 | 1479 |
1453 restore_lst_schedule (scop); | 1480 restore_lst_schedule (scop); |
1454 } | 1481 } |
1455 | 1482 |
1483 /* For a given PBB, add to RES the scop context, the iteration domain, | |
1484 the original scattering when ORIGINAL_P is true, otherwise add the | |
1485 transformed scattering. */ | |
1486 | |
1487 static inline void | |
1488 combine_context_id_scat (ppl_Pointset_Powerset_C_Polyhedron_t *res, | |
1489 poly_bb_p pbb, bool original_p) | |
1490 { | |
1491 ppl_Pointset_Powerset_C_Polyhedron_t context; | |
1492 ppl_Pointset_Powerset_C_Polyhedron_t id; | |
1493 | |
1494 ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron | |
1495 (res, original_p ? | |
1496 PBB_ORIGINAL_SCATTERING (pbb) : PBB_TRANSFORMED_SCATTERING (pbb)); | |
1497 | |
1498 ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron | |
1499 (&context, SCOP_CONTEXT (PBB_SCOP (pbb))); | |
1500 | |
1501 ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron | |
1502 (&id, PBB_DOMAIN (pbb)); | |
1503 | |
1504 /* Extend the context and the iteration domain to the dimension of | |
1505 the scattering: T|I|G. */ | |
1506 { | |
1507 ppl_dimension_type gdim, tdim, idim; | |
1508 | |
1509 ppl_Pointset_Powerset_C_Polyhedron_space_dimension (*res, &tdim); | |
1510 ppl_Pointset_Powerset_C_Polyhedron_space_dimension (context, &gdim); | |
1511 ppl_Pointset_Powerset_C_Polyhedron_space_dimension (id, &idim); | |
1512 | |
1513 if (tdim > gdim) | |
1514 ppl_insert_dimensions_pointset (context, 0, tdim - gdim); | |
1515 | |
1516 if (tdim > idim) | |
1517 ppl_insert_dimensions_pointset (id, 0, tdim - idim); | |
1518 } | |
1519 | |
1520 /* Add the context and the iteration domain to the result. */ | |
1521 ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (*res, context); | |
1522 ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (*res, id); | |
1523 | |
1524 ppl_delete_Pointset_Powerset_C_Polyhedron (context); | |
1525 ppl_delete_Pointset_Powerset_C_Polyhedron (id); | |
1526 } | |
1527 | |
1456 #endif | 1528 #endif |