]>
Commit | Line | Data |
---|---|---|
c6bb733d | 1 | /* Graphite polyhedral representation. |
f1717362 | 2 | Copyright (C) 2009-2016 Free Software Foundation, Inc. |
c6bb733d | 3 | Contributed by Sebastian Pop <sebastian.pop@amd.com> and |
4 | Tobias Grosser <grosser@fim.uni-passau.de>. | |
5 | ||
6 | This file is part of GCC. | |
7 | ||
8 | GCC is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 3, or (at your option) | |
11 | any later version. | |
12 | ||
13 | GCC is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GCC; see the file COPYING3. If not see | |
20 | <http://www.gnu.org/licenses/>. */ | |
87e20041 | 21 | |
d8a2c81e | 22 | #define USES_ISL |
23 | ||
c6bb733d | 24 | #include "config.h" |
87e20041 | 25 | |
429cca51 | 26 | #ifdef HAVE_isl |
d8a2c81e | 27 | |
28 | #include "system.h" | |
29 | #include "coretypes.h" | |
30 | #include "backend.h" | |
31 | #include "tree.h" | |
32 | #include "gimple.h" | |
33 | #include "cfghooks.h" | |
d8a2c81e | 34 | #include "diagnostic-core.h" |
35 | #include "fold-const.h" | |
36 | #include "gimple-iterator.h" | |
37 | #include "tree-ssa-loop.h" | |
38 | #include "cfgloop.h" | |
39 | #include "tree-data-ref.h" | |
6fb10557 | 40 | #include "pretty-print.h" |
41 | #include "gimple-pretty-print.h" | |
42 | #include "tree-dump.h" | |
39b8c5f3 | 43 | #include "graphite.h" |
c6bb733d | 44 | |
87e20041 | 45 | /* Print to STDERR the GMP value VAL. */ |
46 | ||
47 | DEBUG_FUNCTION void | |
48 | debug_gmp_value (mpz_t val) | |
49 | { | |
de2e6b8a | 50 | gmp_fprintf (stderr, "%Zd", val); |
87e20041 | 51 | } |
52 | ||
a765cde0 | 53 | /* Prints to FILE the iteration domain of PBB. */ |
c6bb733d | 54 | |
55 | void | |
a765cde0 | 56 | print_iteration_domain (FILE *file, poly_bb_p pbb) |
c6bb733d | 57 | { |
a765cde0 | 58 | print_pbb_domain (file, pbb); |
c6bb733d | 59 | } |
60 | ||
a765cde0 | 61 | /* Prints to FILE the iteration domains of every PBB of SCOP. */ |
c6bb733d | 62 | |
63 | void | |
a765cde0 | 64 | print_iteration_domains (FILE *file, scop_p scop) |
c6bb733d | 65 | { |
66 | int i; | |
67 | poly_bb_p pbb; | |
68 | ||
0e526381 | 69 | FOR_EACH_VEC_ELT (scop->pbbs, i, pbb) |
a765cde0 | 70 | print_iteration_domain (file, pbb); |
c6bb733d | 71 | } |
72 | ||
a765cde0 | 73 | /* Prints to STDERR the iteration domain of PBB. */ |
c6bb733d | 74 | |
4b987fac | 75 | DEBUG_FUNCTION void |
a765cde0 | 76 | debug_iteration_domain (poly_bb_p pbb) |
c6bb733d | 77 | { |
a765cde0 | 78 | print_iteration_domain (stderr, pbb); |
c6bb733d | 79 | } |
80 | ||
a765cde0 | 81 | /* Prints to STDERR the iteration domains of every PBB of SCOP. */ |
c6bb733d | 82 | |
4b987fac | 83 | DEBUG_FUNCTION void |
a765cde0 | 84 | debug_iteration_domains (scop_p scop) |
c6bb733d | 85 | { |
a765cde0 | 86 | print_iteration_domains (stderr, scop); |
c6bb733d | 87 | } |
88 | ||
89 | /* Apply graphite transformations to all the basic blocks of SCOP. */ | |
90 | ||
91 | bool | |
92 | apply_poly_transforms (scop_p scop) | |
93 | { | |
94 | bool transform_done = false; | |
63b03ccf | 95 | |
c6bb733d | 96 | /* Generate code even if we did not apply any real transformation. |
97 | This also allows to check the performance for the identity | |
4cc0f4e2 | 98 | transformation: GIMPLE -> GRAPHITE -> GIMPLE. */ |
c6bb733d | 99 | if (flag_graphite_identity) |
100 | transform_done = true; | |
101 | ||
16848556 | 102 | if (flag_loop_parallelize_all) |
c6bb733d | 103 | transform_done = true; |
104 | ||
b3de8ca0 | 105 | if (flag_loop_nest_optimize) |
89049f25 | 106 | transform_done |= optimize_isl (scop); |
107 | ||
c6bb733d | 108 | return transform_done; |
109 | } | |
110 | ||
85f74b79 | 111 | /* Create a new polyhedral data reference and add it to PBB. It is |
112 | defined by its ACCESSES, its TYPE, and the number of subscripts | |
113 | NB_SUBSCRIPTS. */ | |
c6bb733d | 114 | |
115 | void | |
30162daa | 116 | new_poly_dr (poly_bb_p pbb, gimple *stmt, enum poly_dr_type type, |
fc25c670 | 117 | isl_map *acc, isl_set *subscript_sizes) |
c6bb733d | 118 | { |
96b6d5d7 | 119 | static int id = 0; |
9e3531b5 | 120 | poly_dr_p pdr = XNEW (struct poly_dr); |
c6bb733d | 121 | |
30162daa | 122 | pdr->stmt = stmt; |
96b6d5d7 | 123 | PDR_ID (pdr) = id++; |
11b2102e | 124 | PDR_NB_REFS (pdr) = 1; |
c6bb733d | 125 | PDR_PBB (pdr) = pbb; |
87e20041 | 126 | pdr->accesses = acc; |
fc25c670 | 127 | pdr->subscript_sizes = subscript_sizes; |
c6bb733d | 128 | PDR_TYPE (pdr) = type; |
f1f41a6c | 129 | PBB_DRS (pbb).safe_push (pdr); |
6fb10557 | 130 | |
131 | if (dump_file) | |
132 | { | |
133 | fprintf (dump_file, "Converting dr: "); | |
134 | print_pdr (dump_file, pdr); | |
135 | fprintf (dump_file, "To polyhedral representation:\n"); | |
136 | fprintf (dump_file, " - access functions: "); | |
137 | print_isl_map (dump_file, acc); | |
138 | fprintf (dump_file, " - subscripts: "); | |
139 | print_isl_set (dump_file, subscript_sizes); | |
140 | } | |
c6bb733d | 141 | } |
142 | ||
143 | /* Free polyhedral data reference PDR. */ | |
144 | ||
145 | void | |
146 | free_poly_dr (poly_dr_p pdr) | |
147 | { | |
87e20041 | 148 | isl_map_free (pdr->accesses); |
fc25c670 | 149 | isl_set_free (pdr->subscript_sizes); |
c6bb733d | 150 | XDELETE (pdr); |
151 | } | |
152 | ||
153 | /* Create a new polyhedral black box. */ | |
154 | ||
8c6b3774 | 155 | poly_bb_p |
3b9ce1aa | 156 | new_poly_bb (scop_p scop, gimple_poly_bb_p black_box) |
c6bb733d | 157 | { |
158 | poly_bb_p pbb = XNEW (struct poly_bb); | |
159 | ||
87e20041 | 160 | pbb->domain = NULL; |
161 | pbb->schedule = NULL; | |
162 | pbb->transformed = NULL; | |
163 | pbb->saved = NULL; | |
c6bb733d | 164 | PBB_SCOP (pbb) = scop; |
165 | pbb_set_black_box (pbb, black_box); | |
f1f41a6c | 166 | PBB_DRS (pbb).create (3); |
8c6b3774 | 167 | PBB_IS_REDUCTION (pbb) = false; |
e0c0be18 | 168 | GBB_PBB ((gimple_poly_bb_p) black_box) = pbb; |
8c6b3774 | 169 | |
170 | return pbb; | |
c6bb733d | 171 | } |
172 | ||
173 | /* Free polyhedral black box. */ | |
174 | ||
175 | void | |
176 | free_poly_bb (poly_bb_p pbb) | |
177 | { | |
178 | int i; | |
179 | poly_dr_p pdr; | |
180 | ||
87e20041 | 181 | isl_set_free (pbb->domain); |
182 | isl_map_free (pbb->schedule); | |
183 | isl_map_free (pbb->transformed); | |
184 | isl_map_free (pbb->saved); | |
c6bb733d | 185 | |
f1f41a6c | 186 | if (PBB_DRS (pbb).exists ()) |
187 | FOR_EACH_VEC_ELT (PBB_DRS (pbb), i, pdr) | |
c6bb733d | 188 | free_poly_dr (pdr); |
189 | ||
f1f41a6c | 190 | PBB_DRS (pbb).release (); |
c6bb733d | 191 | XDELETE (pbb); |
192 | } | |
193 | ||
a765cde0 | 194 | /* Prints to FILE the polyhedral data reference PDR. */ |
c6bb733d | 195 | |
196 | void | |
a765cde0 | 197 | print_pdr (FILE *file, poly_dr_p pdr) |
c6bb733d | 198 | { |
a765cde0 | 199 | fprintf (file, "pdr_%d (", PDR_ID (pdr)); |
c6bb733d | 200 | |
a765cde0 | 201 | switch (PDR_TYPE (pdr)) |
202 | { | |
203 | case PDR_READ: | |
204 | fprintf (file, "read \n"); | |
205 | break; | |
c6bb733d | 206 | |
a765cde0 | 207 | case PDR_WRITE: |
208 | fprintf (file, "write \n"); | |
209 | break; | |
c6bb733d | 210 | |
a765cde0 | 211 | case PDR_MAY_WRITE: |
212 | fprintf (file, "may_write \n"); | |
213 | break; | |
ff4c7a5a | 214 | |
a765cde0 | 215 | default: |
216 | gcc_unreachable (); | |
c6bb733d | 217 | } |
218 | ||
30162daa | 219 | fprintf (file, "in gimple stmt: "); |
220 | print_gimple_stmt (file, pdr->stmt, 0, 0); | |
a765cde0 | 221 | fprintf (file, "data accesses: "); |
222 | print_isl_map (file, pdr->accesses); | |
223 | fprintf (file, "subscript sizes: "); | |
224 | print_isl_set (file, pdr->subscript_sizes); | |
225 | fprintf (file, ")\n"); | |
c6bb733d | 226 | } |
227 | ||
a765cde0 | 228 | /* Prints to STDERR the polyhedral data reference PDR. */ |
c6bb733d | 229 | |
4b987fac | 230 | DEBUG_FUNCTION void |
a765cde0 | 231 | debug_pdr (poly_dr_p pdr) |
c6bb733d | 232 | { |
a765cde0 | 233 | print_pdr (stderr, pdr); |
c6bb733d | 234 | } |
235 | ||
118a202b | 236 | /* Store the GRAPHITE representation of BB. */ |
237 | ||
238 | gimple_poly_bb_p | |
30162daa | 239 | new_gimple_poly_bb (basic_block bb, vec<data_reference_p> drs, |
240 | vec<scalar_use> reads, vec<tree> writes) | |
118a202b | 241 | { |
30162daa | 242 | gimple_poly_bb_p gbb = XNEW (struct gimple_poly_bb); |
118a202b | 243 | GBB_BB (gbb) = bb; |
244 | GBB_DATA_REFS (gbb) = drs; | |
30162daa | 245 | gbb->read_scalar_refs = reads; |
246 | gbb->write_scalar_refs = writes; | |
118a202b | 247 | GBB_CONDITIONS (gbb).create (0); |
248 | GBB_CONDITION_CASES (gbb).create (0); | |
249 | ||
250 | return gbb; | |
251 | } | |
252 | ||
118a202b | 253 | /* Frees GBB. */ |
254 | ||
255 | void | |
256 | free_gimple_poly_bb (gimple_poly_bb_p gbb) | |
257 | { | |
118a202b | 258 | free_data_refs (GBB_DATA_REFS (gbb)); |
118a202b | 259 | GBB_CONDITIONS (gbb).release (); |
260 | GBB_CONDITION_CASES (gbb).release (); | |
30162daa | 261 | gbb->read_scalar_refs.release (); |
262 | gbb->write_scalar_refs.release (); | |
118a202b | 263 | XDELETE (gbb); |
264 | } | |
265 | ||
266 | /* Deletes all gimple bbs in SCOP. */ | |
267 | ||
268 | static void | |
269 | remove_gbbs_in_scop (scop_p scop) | |
270 | { | |
271 | int i; | |
272 | poly_bb_p pbb; | |
273 | ||
0e526381 | 274 | FOR_EACH_VEC_ELT (scop->pbbs, i, pbb) |
118a202b | 275 | free_gimple_poly_bb (PBB_BLACK_BOX (pbb)); |
276 | } | |
277 | ||
278 | /* Creates a new SCOP containing the region (ENTRY, EXIT). */ | |
c6bb733d | 279 | |
280 | scop_p | |
118a202b | 281 | new_scop (edge entry, edge exit) |
c6bb733d | 282 | { |
f032380c | 283 | sese_info_p region = new_sese_info (entry, exit); |
289af222 | 284 | scop_p s = XNEW (struct scop); |
18d73d6f | 285 | |
289af222 | 286 | s->schedule = NULL; |
18d73d6f | 287 | s->param_context = NULL; |
288 | scop_set_region (s, region); | |
289 | s->pbbs.create (3); | |
290 | s->drs.create (3); | |
291 | s->dependence = NULL; | |
292 | return s; | |
c6bb733d | 293 | } |
294 | ||
295 | /* Deletes SCOP. */ | |
296 | ||
297 | void | |
298 | free_scop (scop_p scop) | |
299 | { | |
300 | int i; | |
301 | poly_bb_p pbb; | |
302 | ||
118a202b | 303 | remove_gbbs_in_scop (scop); |
5828c94d | 304 | free_sese_info (scop->scop_info); |
118a202b | 305 | |
0e526381 | 306 | FOR_EACH_VEC_ELT (scop->pbbs, i, pbb) |
c6bb733d | 307 | free_poly_bb (pbb); |
308 | ||
0e526381 | 309 | scop->pbbs.release (); |
5e6359b9 | 310 | scop->drs.release (); |
c6bb733d | 311 | |
3b9ce1aa | 312 | isl_set_free (scop->param_context); |
18d73d6f | 313 | isl_union_map_free (scop->dependence); |
314 | scop->dependence = NULL; | |
c6bb733d | 315 | XDELETE (scop); |
316 | } | |
317 | ||
a765cde0 | 318 | /* Print to FILE the domain of PBB. */ |
c6bb733d | 319 | |
320 | void | |
a765cde0 | 321 | print_pbb_domain (FILE *file, poly_bb_p pbb) |
c6bb733d | 322 | { |
87e20041 | 323 | print_isl_set (file, pbb->domain); |
c6bb733d | 324 | } |
325 | ||
326 | /* Dump the cases of a graphite basic block GBB on FILE. */ | |
327 | ||
328 | static void | |
e0c0be18 | 329 | dump_gbb_cases (FILE *file, gimple_poly_bb_p gbb) |
c6bb733d | 330 | { |
331 | int i; | |
42acab1c | 332 | gimple *stmt; |
333 | vec<gimple *> cases; | |
c6bb733d | 334 | |
335 | if (!gbb) | |
336 | return; | |
337 | ||
338 | cases = GBB_CONDITION_CASES (gbb); | |
f1f41a6c | 339 | if (cases.is_empty ()) |
c6bb733d | 340 | return; |
341 | ||
a765cde0 | 342 | fprintf (file, "cases bb_%d (\n", GBB_BB (gbb)->index); |
c6bb733d | 343 | |
f1f41a6c | 344 | FOR_EACH_VEC_ELT (cases, i, stmt) |
a765cde0 | 345 | print_gimple_stmt (file, stmt, 0, 0); |
c6bb733d | 346 | |
a765cde0 | 347 | fprintf (file, ")\n"); |
c6bb733d | 348 | } |
349 | ||
350 | /* Dump conditions of a graphite basic block GBB on FILE. */ | |
351 | ||
352 | static void | |
e0c0be18 | 353 | dump_gbb_conditions (FILE *file, gimple_poly_bb_p gbb) |
c6bb733d | 354 | { |
355 | int i; | |
42acab1c | 356 | gimple *stmt; |
357 | vec<gimple *> conditions; | |
c6bb733d | 358 | |
359 | if (!gbb) | |
360 | return; | |
361 | ||
362 | conditions = GBB_CONDITIONS (gbb); | |
f1f41a6c | 363 | if (conditions.is_empty ()) |
c6bb733d | 364 | return; |
365 | ||
a765cde0 | 366 | fprintf (file, "conditions bb_%d (\n", GBB_BB (gbb)->index); |
c6bb733d | 367 | |
f1f41a6c | 368 | FOR_EACH_VEC_ELT (conditions, i, stmt) |
a765cde0 | 369 | print_gimple_stmt (file, stmt, 0, 0); |
c6bb733d | 370 | |
a765cde0 | 371 | fprintf (file, ")\n"); |
c6bb733d | 372 | } |
373 | ||
a765cde0 | 374 | /* Print to FILE all the data references of PBB. */ |
c6bb733d | 375 | |
376 | void | |
a765cde0 | 377 | print_pdrs (FILE *file, poly_bb_p pbb) |
c6bb733d | 378 | { |
379 | int i; | |
380 | poly_dr_p pdr; | |
5dc5fe13 | 381 | int nb_reads = 0; |
382 | int nb_writes = 0; | |
c6bb733d | 383 | |
a765cde0 | 384 | if (PBB_DRS (pbb).is_empty ()) |
385 | return; | |
ff4c7a5a | 386 | |
a765cde0 | 387 | fprintf (file, "Data references (\n"); |
5dc5fe13 | 388 | |
f1f41a6c | 389 | FOR_EACH_VEC_ELT (PBB_DRS (pbb), i, pdr) |
5dc5fe13 | 390 | if (PDR_TYPE (pdr) == PDR_READ) |
391 | nb_reads++; | |
392 | else | |
393 | nb_writes++; | |
394 | ||
a765cde0 | 395 | fprintf (file, "Read data references (\n"); |
ff4c7a5a | 396 | |
f1f41a6c | 397 | FOR_EACH_VEC_ELT (PBB_DRS (pbb), i, pdr) |
5dc5fe13 | 398 | if (PDR_TYPE (pdr) == PDR_READ) |
a765cde0 | 399 | print_pdr (file, pdr); |
5dc5fe13 | 400 | |
a765cde0 | 401 | fprintf (file, ")\n"); |
402 | fprintf (file, "Write data references (\n"); | |
f1f41a6c | 403 | FOR_EACH_VEC_ELT (PBB_DRS (pbb), i, pdr) |
5dc5fe13 | 404 | if (PDR_TYPE (pdr) != PDR_READ) |
a765cde0 | 405 | print_pdr (file, pdr); |
406 | fprintf (file, ")\n"); | |
407 | fprintf (file, ")\n"); | |
c6bb733d | 408 | } |
409 | ||
410 | /* Print to STDERR all the data references of PBB. */ | |
411 | ||
4b987fac | 412 | DEBUG_FUNCTION void |
a765cde0 | 413 | debug_pdrs (poly_bb_p pbb) |
c6bb733d | 414 | { |
a765cde0 | 415 | print_pdrs (stderr, pbb); |
c6bb733d | 416 | } |
417 | ||
a765cde0 | 418 | /* Print to FILE the body of PBB. */ |
5dc5fe13 | 419 | |
420 | static void | |
a765cde0 | 421 | print_pbb_body (FILE *file, poly_bb_p pbb) |
5dc5fe13 | 422 | { |
a765cde0 | 423 | fprintf (file, "Body (\n"); |
35e5655c | 424 | dump_bb (file, pbb_bb (pbb), 0, 0); |
a765cde0 | 425 | fprintf (file, ")\n"); |
5dc5fe13 | 426 | } |
427 | ||
a765cde0 | 428 | /* Print to FILE the domain and scattering function of PBB. */ |
c6bb733d | 429 | |
430 | void | |
a765cde0 | 431 | print_pbb (FILE *file, poly_bb_p pbb) |
ff4c7a5a | 432 | { |
a765cde0 | 433 | fprintf (file, "pbb_%d (\n", pbb_index (pbb)); |
434 | dump_gbb_conditions (file, PBB_BLACK_BOX (pbb)); | |
435 | dump_gbb_cases (file, PBB_BLACK_BOX (pbb)); | |
ff4c7a5a | 436 | |
a765cde0 | 437 | print_pbb_domain (file, pbb); |
438 | print_pdrs (file, pbb); | |
439 | print_pbb_body (file, pbb); | |
ff4c7a5a | 440 | |
a765cde0 | 441 | fprintf (file, ")\n"); |
c6bb733d | 442 | } |
443 | ||
a765cde0 | 444 | /* Print to FILE the parameters of SCOP. */ |
c6bb733d | 445 | |
446 | void | |
a765cde0 | 447 | print_scop_params (FILE *file, scop_p scop) |
c6bb733d | 448 | { |
30162daa | 449 | if (scop->scop_info->params.is_empty ()) |
a765cde0 | 450 | return; |
451 | ||
c6bb733d | 452 | int i; |
453 | tree t; | |
a765cde0 | 454 | fprintf (file, "parameters ("); |
30162daa | 455 | FOR_EACH_VEC_ELT (scop->scop_info->params, i, t) |
c6bb733d | 456 | { |
c6bb733d | 457 | print_generic_expr (file, t, 0); |
a765cde0 | 458 | fprintf (file, ", "); |
c6bb733d | 459 | } |
a765cde0 | 460 | fprintf (file, ")\n"); |
c6bb733d | 461 | } |
462 | ||
a765cde0 | 463 | /* Print to FILE the context of SCoP. */ |
ff4c7a5a | 464 | |
c6bb733d | 465 | void |
a765cde0 | 466 | print_scop_context (FILE *file, scop_p scop) |
c6bb733d | 467 | { |
a765cde0 | 468 | if (!scop->param_context) |
469 | return; | |
c6bb733d | 470 | |
a765cde0 | 471 | fprintf (file, "Context (\n"); |
472 | print_isl_set (file, scop->param_context); | |
473 | fprintf (file, ")\n"); | |
c6bb733d | 474 | } |
475 | ||
a765cde0 | 476 | /* Print to FILE the SCOP. */ |
c6bb733d | 477 | |
d2cd543b | 478 | void |
a765cde0 | 479 | print_scop (FILE *file, scop_p scop) |
c6bb733d | 480 | { |
d2cd543b | 481 | int i; |
482 | poly_bb_p pbb; | |
483 | ||
a765cde0 | 484 | fprintf (file, "SCoP (\n"); |
485 | print_scop_context (file, scop); | |
486 | print_scop_params (file, scop); | |
ff4c7a5a | 487 | |
a765cde0 | 488 | fprintf (file, "Number of statements: "); |
0e526381 | 489 | fprintf (file, "%d\n", scop->pbbs.length ()); |
c6bb733d | 490 | |
0e526381 | 491 | FOR_EACH_VEC_ELT (scop->pbbs, i, pbb) |
a765cde0 | 492 | print_pbb (file, pbb); |
95b2e0d3 | 493 | |
a765cde0 | 494 | fprintf (file, ")\n"); |
c6bb733d | 495 | } |
496 | ||
a765cde0 | 497 | /* Print to STDERR the domain of PBB. */ |
c6bb733d | 498 | |
4b987fac | 499 | DEBUG_FUNCTION void |
a765cde0 | 500 | debug_pbb_domain (poly_bb_p pbb) |
c6bb733d | 501 | { |
a765cde0 | 502 | print_pbb_domain (stderr, pbb); |
c6bb733d | 503 | } |
504 | ||
a765cde0 | 505 | /* Print to FILE the domain and scattering function of PBB. */ |
c6bb733d | 506 | |
4b987fac | 507 | DEBUG_FUNCTION void |
a765cde0 | 508 | debug_pbb (poly_bb_p pbb) |
c6bb733d | 509 | { |
a765cde0 | 510 | print_pbb (stderr, pbb); |
c6bb733d | 511 | } |
512 | ||
a765cde0 | 513 | /* Print to STDERR the context of SCOP. */ |
c6bb733d | 514 | |
4b987fac | 515 | DEBUG_FUNCTION void |
a765cde0 | 516 | debug_scop_context (scop_p scop) |
c6bb733d | 517 | { |
a765cde0 | 518 | print_scop_context (stderr, scop); |
c6bb733d | 519 | } |
520 | ||
a765cde0 | 521 | /* Print to STDERR the SCOP. */ |
c6bb733d | 522 | |
4b987fac | 523 | DEBUG_FUNCTION void |
a765cde0 | 524 | debug_scop (scop_p scop) |
c6bb733d | 525 | { |
a765cde0 | 526 | print_scop (stderr, scop); |
c6bb733d | 527 | } |
528 | ||
a765cde0 | 529 | /* Print to STDERR the parameters of SCOP. */ |
c6bb733d | 530 | |
4b987fac | 531 | DEBUG_FUNCTION void |
a765cde0 | 532 | debug_scop_params (scop_p scop) |
c6bb733d | 533 | { |
a765cde0 | 534 | print_scop_params (stderr, scop); |
c6bb733d | 535 | } |
536 | ||
87e20041 | 537 | extern isl_ctx *the_isl_ctx; |
538 | void | |
539 | print_isl_set (FILE *f, isl_set *set) | |
c6bb733d | 540 | { |
87e20041 | 541 | isl_printer *p = isl_printer_to_file (the_isl_ctx, f); |
542 | p = isl_printer_print_set (p, set); | |
4cc0f4e2 | 543 | p = isl_printer_print_str (p, "\n"); |
87e20041 | 544 | isl_printer_free (p); |
545 | } | |
c6bb733d | 546 | |
87e20041 | 547 | DEBUG_FUNCTION void |
548 | debug_isl_set (isl_set *set) | |
549 | { | |
550 | print_isl_set (stderr, set); | |
551 | } | |
c6bb733d | 552 | |
87e20041 | 553 | void |
554 | print_isl_map (FILE *f, isl_map *map) | |
555 | { | |
556 | isl_printer *p = isl_printer_to_file (the_isl_ctx, f); | |
557 | p = isl_printer_print_map (p, map); | |
4cc0f4e2 | 558 | p = isl_printer_print_str (p, "\n"); |
87e20041 | 559 | isl_printer_free (p); |
560 | } | |
c6bb733d | 561 | |
87e20041 | 562 | DEBUG_FUNCTION void |
563 | debug_isl_map (isl_map *map) | |
564 | { | |
565 | print_isl_map (stderr, map); | |
566 | } | |
c6bb733d | 567 | |
d9ac4c34 | 568 | void |
569 | print_isl_union_map (FILE *f, isl_union_map *map) | |
570 | { | |
571 | isl_printer *p = isl_printer_to_file (the_isl_ctx, f); | |
572 | p = isl_printer_print_union_map (p, map); | |
573 | p = isl_printer_print_str (p, "\n"); | |
574 | isl_printer_free (p); | |
575 | } | |
576 | ||
577 | DEBUG_FUNCTION void | |
578 | debug_isl_union_map (isl_union_map *map) | |
579 | { | |
580 | print_isl_union_map (stderr, map); | |
581 | } | |
582 | ||
583 | ||
87e20041 | 584 | void |
585 | print_isl_aff (FILE *f, isl_aff *aff) | |
586 | { | |
587 | isl_printer *p = isl_printer_to_file (the_isl_ctx, f); | |
588 | p = isl_printer_print_aff (p, aff); | |
4cc0f4e2 | 589 | p = isl_printer_print_str (p, "\n"); |
87e20041 | 590 | isl_printer_free (p); |
591 | } | |
c6bb733d | 592 | |
87e20041 | 593 | DEBUG_FUNCTION void |
594 | debug_isl_aff (isl_aff *aff) | |
595 | { | |
596 | print_isl_aff (stderr, aff); | |
597 | } | |
c6bb733d | 598 | |
87e20041 | 599 | void |
600 | print_isl_constraint (FILE *f, isl_constraint *c) | |
601 | { | |
602 | isl_printer *p = isl_printer_to_file (the_isl_ctx, f); | |
603 | p = isl_printer_print_constraint (p, c); | |
4cc0f4e2 | 604 | p = isl_printer_print_str (p, "\n"); |
87e20041 | 605 | isl_printer_free (p); |
606 | } | |
c6bb733d | 607 | |
87e20041 | 608 | DEBUG_FUNCTION void |
609 | debug_isl_constraint (isl_constraint *c) | |
610 | { | |
611 | print_isl_constraint (stderr, c); | |
c6bb733d | 612 | } |
613 | ||
bd432164 | 614 | /* Returns the number of iterations RES of the loop around PBB at |
ee0d08ad | 615 | time(scattering) dimension TIME_DEPTH. */ |
616 | ||
617 | void | |
618 | pbb_number_of_iterations_at_time (poly_bb_p pbb, | |
619 | graphite_dim_t time_depth, | |
bd432164 | 620 | mpz_t res) |
ee0d08ad | 621 | { |
87e20041 | 622 | isl_set *transdomain; |
623 | isl_space *dc; | |
624 | isl_aff *aff; | |
ea48ac01 | 625 | isl_val *isllb, *islub; |
d9e94834 | 626 | |
87e20041 | 627 | /* Map the iteration domain through the current scatter, and work |
628 | on the resulting set. */ | |
629 | transdomain = isl_set_apply (isl_set_copy (pbb->domain), | |
630 | isl_map_copy (pbb->transformed)); | |
d9e94834 | 631 | |
87e20041 | 632 | /* Select the time_depth' dimension via an affine expression. */ |
633 | dc = isl_set_get_space (transdomain); | |
634 | aff = isl_aff_zero_on_domain (isl_local_space_from_space (dc)); | |
635 | aff = isl_aff_set_coefficient_si (aff, isl_dim_in, time_depth, 1); | |
dd37d9f7 | 636 | |
87e20041 | 637 | /* And find the min/max for that function. */ |
638 | /* XXX isl check results? */ | |
ea48ac01 | 639 | isllb = isl_set_min_val (transdomain, aff); |
640 | islub = isl_set_max_val (transdomain, aff); | |
d9e94834 | 641 | |
ea48ac01 | 642 | islub = isl_val_sub (islub, isllb); |
643 | islub = isl_val_add_ui (islub, 1); | |
644 | isl_val_get_num_gmp (islub, res); | |
ee0d08ad | 645 | |
ea48ac01 | 646 | isl_val_free (islub); |
87e20041 | 647 | isl_aff_free (aff); |
648 | isl_set_free (transdomain); | |
ee0d08ad | 649 | } |
650 | ||
26bd1f19 | 651 | #endif /* HAVE_isl */ |
c6bb733d | 652 |