]>
Commit | Line | Data |
---|---|---|
726a989a | 1 | /* Pretty formatting of GIMPLE statements and expressions. |
23a5b65a | 2 | Copyright (C) 2001-2014 Free Software Foundation, Inc. |
726a989a RB |
3 | Contributed by Aldy Hernandez <aldyh@redhat.com> and |
4 | Diego Novillo <dnovillo@google.com> | |
5 | ||
6 | This file is part of GCC. | |
7 | ||
8 | GCC is free software; you can redistribute it and/or modify it under | |
9 | the terms of the GNU General Public License as published by the Free | |
10 | Software Foundation; either version 3, or (at your option) any later | |
11 | version. | |
12 | ||
13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | 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/>. */ | |
21 | ||
22 | #include "config.h" | |
23 | #include "system.h" | |
24 | #include "coretypes.h" | |
25 | #include "tm.h" | |
26 | #include "tree.h" | |
d8a2d370 | 27 | #include "stringpool.h" |
726a989a | 28 | #include "diagnostic.h" |
cf835838 | 29 | #include "gimple-pretty-print.h" |
726a989a | 30 | #include "hashtab.h" |
442b4905 | 31 | #include "bitmap.h" |
2fb9a547 AM |
32 | #include "basic-block.h" |
33 | #include "tree-ssa-alias.h" | |
34 | #include "internal-fn.h" | |
35 | #include "tree-eh.h" | |
36 | #include "gimple-expr.h" | |
37 | #include "is-a.h" | |
726a989a | 38 | #include "gimple.h" |
5be5c238 | 39 | #include "gimple-iterator.h" |
442b4905 AM |
40 | #include "gimple-ssa.h" |
41 | #include "cgraph.h" | |
42 | #include "tree-cfg.h" | |
43 | #include "tree-ssanames.h" | |
44 | #include "dumpfile.h" /* for dump_flags */ | |
726a989a | 45 | #include "value-prof.h" |
0a35513e | 46 | #include "trans-mem.h" |
726a989a RB |
47 | |
48 | #define INDENT(SPACE) \ | |
49 | do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0) | |
50 | ||
726a989a RB |
51 | #define GIMPLE_NIY do_niy (buffer,gs) |
52 | ||
53 | /* Try to print on BUFFER a default message for the unrecognized | |
54 | gimple statement GS. */ | |
55 | ||
56 | static void | |
57 | do_niy (pretty_printer *buffer, gimple gs) | |
58 | { | |
59 | pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n", | |
60 | gimple_code_name[(int) gimple_code (gs)]); | |
61 | } | |
62 | ||
63 | ||
b5f47924 | 64 | /* Emit a newline and SPC indentation spaces to BUFFER. */ |
726a989a RB |
65 | |
66 | static void | |
67 | newline_and_indent (pretty_printer *buffer, int spc) | |
68 | { | |
69 | pp_newline (buffer); | |
70 | INDENT (spc); | |
71 | } | |
72 | ||
73 | ||
74 | /* Print the GIMPLE statement GS on stderr. */ | |
75 | ||
24e47c76 | 76 | DEBUG_FUNCTION void |
726a989a RB |
77 | debug_gimple_stmt (gimple gs) |
78 | { | |
79 | print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS); | |
726a989a RB |
80 | } |
81 | ||
82 | ||
b5f47924 SS |
83 | /* Print GIMPLE statement G to FILE using SPC indentation spaces and |
84 | FLAGS as in pp_gimple_stmt_1. */ | |
726a989a RB |
85 | |
86 | void | |
87 | print_gimple_stmt (FILE *file, gimple g, int spc, int flags) | |
88 | { | |
b3f80694 | 89 | pretty_printer buffer; |
b3f80694 GDR |
90 | pp_needs_newline (&buffer) = true; |
91 | buffer.buffer->stream = file; | |
b5f47924 | 92 | pp_gimple_stmt_1 (&buffer, g, spc, flags); |
f8923f7e | 93 | pp_newline_and_flush (&buffer); |
726a989a RB |
94 | } |
95 | ||
7b3b6ae4 | 96 | DEBUG_FUNCTION void |
daa6e488 | 97 | debug (gimple_statement_base &ref) |
7b3b6ae4 LC |
98 | { |
99 | print_gimple_stmt (stderr, &ref, 0, 0); | |
100 | } | |
101 | ||
102 | DEBUG_FUNCTION void | |
daa6e488 | 103 | debug (gimple_statement_base *ptr) |
7b3b6ae4 LC |
104 | { |
105 | if (ptr) | |
106 | debug (*ptr); | |
107 | else | |
108 | fprintf (stderr, "<nil>\n"); | |
109 | } | |
110 | ||
726a989a | 111 | |
b5f47924 SS |
112 | /* Print GIMPLE statement G to FILE using SPC indentation spaces and |
113 | FLAGS as in pp_gimple_stmt_1. Print only the right-hand side | |
726a989a RB |
114 | of the statement. */ |
115 | ||
116 | void | |
117 | print_gimple_expr (FILE *file, gimple g, int spc, int flags) | |
118 | { | |
119 | flags |= TDF_RHS_ONLY; | |
b3f80694 | 120 | pretty_printer buffer; |
b3f80694 GDR |
121 | pp_needs_newline (&buffer) = true; |
122 | buffer.buffer->stream = file; | |
b5f47924 | 123 | pp_gimple_stmt_1 (&buffer, g, spc, flags); |
41222ddf | 124 | pp_flush (&buffer); |
726a989a RB |
125 | } |
126 | ||
127 | ||
b5f47924 SS |
128 | /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation |
129 | spaces and FLAGS as in pp_gimple_stmt_1. | |
c4669594 SB |
130 | The caller is responsible for calling pp_flush on BUFFER to finalize |
131 | the pretty printer. */ | |
726a989a RB |
132 | |
133 | static void | |
134 | dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags) | |
135 | { | |
136 | gimple_stmt_iterator i; | |
137 | ||
138 | for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i)) | |
139 | { | |
140 | gimple gs = gsi_stmt (i); | |
141 | INDENT (spc); | |
b5f47924 | 142 | pp_gimple_stmt_1 (buffer, gs, spc, flags); |
726a989a RB |
143 | if (!gsi_one_before_end_p (i)) |
144 | pp_newline (buffer); | |
145 | } | |
146 | } | |
147 | ||
148 | ||
b5f47924 SS |
149 | /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and |
150 | FLAGS as in pp_gimple_stmt_1. */ | |
726a989a RB |
151 | |
152 | void | |
153 | print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags) | |
154 | { | |
b3f80694 | 155 | pretty_printer buffer; |
b3f80694 GDR |
156 | pp_needs_newline (&buffer) = true; |
157 | buffer.buffer->stream = file; | |
726a989a | 158 | dump_gimple_seq (&buffer, seq, spc, flags); |
f8923f7e | 159 | pp_newline_and_flush (&buffer); |
726a989a RB |
160 | } |
161 | ||
162 | ||
163 | /* Print the GIMPLE sequence SEQ on stderr. */ | |
164 | ||
24e47c76 | 165 | DEBUG_FUNCTION void |
726a989a RB |
166 | debug_gimple_seq (gimple_seq seq) |
167 | { | |
168 | print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS); | |
169 | } | |
170 | ||
171 | ||
172 | /* A simple helper to pretty-print some of the gimple tuples in the printf | |
073a8998 | 173 | style. The format modifiers are preceded by '%' and are: |
726a989a RB |
174 | 'G' - outputs a string corresponding to the code of the given gimple, |
175 | 'S' - outputs a gimple_seq with indent of spc + 2, | |
176 | 'T' - outputs the tree t, | |
177 | 'd' - outputs an int as a decimal, | |
178 | 's' - outputs a string, | |
179 | 'n' - outputs a newline, | |
0a35513e | 180 | 'x' - outputs an int as hexadecimal, |
726a989a RB |
181 | '+' - increases indent by 2 then outputs a newline, |
182 | '-' - decreases indent by 2 then outputs a newline. */ | |
183 | ||
184 | static void | |
185 | dump_gimple_fmt (pretty_printer *buffer, int spc, int flags, | |
186 | const char *fmt, ...) | |
187 | { | |
188 | va_list args; | |
189 | const char *c; | |
190 | const char *tmp; | |
191 | ||
192 | va_start (args, fmt); | |
193 | for (c = fmt; *c; c++) | |
194 | { | |
195 | if (*c == '%') | |
196 | { | |
197 | gimple_seq seq; | |
198 | tree t; | |
199 | gimple g; | |
200 | switch (*++c) | |
201 | { | |
202 | case 'G': | |
203 | g = va_arg (args, gimple); | |
204 | tmp = gimple_code_name[gimple_code (g)]; | |
205 | pp_string (buffer, tmp); | |
206 | break; | |
207 | ||
208 | case 'S': | |
209 | seq = va_arg (args, gimple_seq); | |
210 | pp_newline (buffer); | |
211 | dump_gimple_seq (buffer, seq, spc + 2, flags); | |
212 | newline_and_indent (buffer, spc); | |
213 | break; | |
214 | ||
215 | case 'T': | |
216 | t = va_arg (args, tree); | |
217 | if (t == NULL_TREE) | |
218 | pp_string (buffer, "NULL"); | |
219 | else | |
220 | dump_generic_node (buffer, t, spc, flags, false); | |
221 | break; | |
222 | ||
223 | case 'd': | |
224 | pp_decimal_int (buffer, va_arg (args, int)); | |
225 | break; | |
226 | ||
227 | case 's': | |
228 | pp_string (buffer, va_arg (args, char *)); | |
229 | break; | |
230 | ||
231 | case 'n': | |
232 | newline_and_indent (buffer, spc); | |
233 | break; | |
234 | ||
0a35513e AH |
235 | case 'x': |
236 | pp_scalar (buffer, "%x", va_arg (args, int)); | |
237 | break; | |
238 | ||
726a989a RB |
239 | case '+': |
240 | spc += 2; | |
241 | newline_and_indent (buffer, spc); | |
242 | break; | |
243 | ||
244 | case '-': | |
245 | spc -= 2; | |
246 | newline_and_indent (buffer, spc); | |
247 | break; | |
248 | ||
249 | default: | |
250 | gcc_unreachable (); | |
251 | } | |
b8698a0f | 252 | } |
726a989a RB |
253 | else |
254 | pp_character (buffer, *c); | |
255 | } | |
256 | va_end (args); | |
257 | } | |
258 | ||
259 | ||
260 | /* Helper for dump_gimple_assign. Print the unary RHS of the | |
b5f47924 | 261 | assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */ |
726a989a RB |
262 | |
263 | static void | |
264 | dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags) | |
265 | { | |
266 | enum tree_code rhs_code = gimple_assign_rhs_code (gs); | |
267 | tree lhs = gimple_assign_lhs (gs); | |
268 | tree rhs = gimple_assign_rhs1 (gs); | |
269 | ||
270 | switch (rhs_code) | |
271 | { | |
272 | case VIEW_CONVERT_EXPR: | |
273 | case ASSERT_EXPR: | |
274 | dump_generic_node (buffer, rhs, spc, flags, false); | |
275 | break; | |
276 | ||
277 | case FIXED_CONVERT_EXPR: | |
09e881c9 | 278 | case ADDR_SPACE_CONVERT_EXPR: |
726a989a RB |
279 | case FIX_TRUNC_EXPR: |
280 | case FLOAT_EXPR: | |
281 | CASE_CONVERT: | |
07838b13 | 282 | pp_left_paren (buffer); |
726a989a RB |
283 | dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false); |
284 | pp_string (buffer, ") "); | |
0cf0d02b JJ |
285 | if (op_prio (rhs) < op_code_prio (rhs_code)) |
286 | { | |
07838b13 | 287 | pp_left_paren (buffer); |
0cf0d02b | 288 | dump_generic_node (buffer, rhs, spc, flags, false); |
07838b13 | 289 | pp_right_paren (buffer); |
0cf0d02b JJ |
290 | } |
291 | else | |
292 | dump_generic_node (buffer, rhs, spc, flags, false); | |
726a989a | 293 | break; |
b8698a0f | 294 | |
726a989a RB |
295 | case PAREN_EXPR: |
296 | pp_string (buffer, "(("); | |
297 | dump_generic_node (buffer, rhs, spc, flags, false); | |
298 | pp_string (buffer, "))"); | |
299 | break; | |
b8698a0f | 300 | |
726a989a RB |
301 | case ABS_EXPR: |
302 | pp_string (buffer, "ABS_EXPR <"); | |
303 | dump_generic_node (buffer, rhs, spc, flags, false); | |
07838b13 | 304 | pp_greater (buffer); |
726a989a RB |
305 | break; |
306 | ||
307 | default: | |
308 | if (TREE_CODE_CLASS (rhs_code) == tcc_declaration | |
309 | || TREE_CODE_CLASS (rhs_code) == tcc_constant | |
310 | || TREE_CODE_CLASS (rhs_code) == tcc_reference | |
311 | || rhs_code == SSA_NAME | |
312 | || rhs_code == ADDR_EXPR | |
313 | || rhs_code == CONSTRUCTOR) | |
0cf0d02b JJ |
314 | { |
315 | dump_generic_node (buffer, rhs, spc, flags, false); | |
316 | break; | |
317 | } | |
726a989a | 318 | else if (rhs_code == BIT_NOT_EXPR) |
07838b13 | 319 | pp_complement (buffer); |
726a989a | 320 | else if (rhs_code == TRUTH_NOT_EXPR) |
07838b13 | 321 | pp_exclamation (buffer); |
726a989a | 322 | else if (rhs_code == NEGATE_EXPR) |
07838b13 | 323 | pp_minus (buffer); |
726a989a RB |
324 | else |
325 | { | |
07838b13 | 326 | pp_left_bracket (buffer); |
5806f481 | 327 | pp_string (buffer, get_tree_code_name (rhs_code)); |
726a989a RB |
328 | pp_string (buffer, "] "); |
329 | } | |
330 | ||
0cf0d02b JJ |
331 | if (op_prio (rhs) < op_code_prio (rhs_code)) |
332 | { | |
07838b13 | 333 | pp_left_paren (buffer); |
0cf0d02b | 334 | dump_generic_node (buffer, rhs, spc, flags, false); |
07838b13 | 335 | pp_right_paren (buffer); |
0cf0d02b JJ |
336 | } |
337 | else | |
338 | dump_generic_node (buffer, rhs, spc, flags, false); | |
726a989a RB |
339 | break; |
340 | } | |
341 | } | |
342 | ||
343 | ||
344 | /* Helper for dump_gimple_assign. Print the binary RHS of the | |
b5f47924 | 345 | assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */ |
726a989a RB |
346 | |
347 | static void | |
348 | dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags) | |
349 | { | |
2603276e JJ |
350 | const char *p; |
351 | enum tree_code code = gimple_assign_rhs_code (gs); | |
352 | switch (code) | |
726a989a RB |
353 | { |
354 | case COMPLEX_EXPR: | |
726a989a | 355 | case MIN_EXPR: |
726a989a | 356 | case MAX_EXPR: |
2603276e JJ |
357 | case VEC_WIDEN_MULT_HI_EXPR: |
358 | case VEC_WIDEN_MULT_LO_EXPR: | |
3f30a9a6 RH |
359 | case VEC_WIDEN_MULT_EVEN_EXPR: |
360 | case VEC_WIDEN_MULT_ODD_EXPR: | |
2603276e JJ |
361 | case VEC_PACK_TRUNC_EXPR: |
362 | case VEC_PACK_SAT_EXPR: | |
363 | case VEC_PACK_FIX_TRUNC_EXPR: | |
36ba4aae IR |
364 | case VEC_WIDEN_LSHIFT_HI_EXPR: |
365 | case VEC_WIDEN_LSHIFT_LO_EXPR: | |
5806f481 | 366 | for (p = get_tree_code_name (code); *p; p++) |
2603276e JJ |
367 | pp_character (buffer, TOUPPER (*p)); |
368 | pp_string (buffer, " <"); | |
726a989a RB |
369 | dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); |
370 | pp_string (buffer, ", "); | |
371 | dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); | |
07838b13 | 372 | pp_greater (buffer); |
726a989a RB |
373 | break; |
374 | ||
375 | default: | |
0cf0d02b JJ |
376 | if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code)) |
377 | { | |
07838b13 | 378 | pp_left_paren (buffer); |
0cf0d02b JJ |
379 | dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, |
380 | false); | |
07838b13 | 381 | pp_right_paren (buffer); |
0cf0d02b JJ |
382 | } |
383 | else | |
384 | dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); | |
726a989a RB |
385 | pp_space (buffer); |
386 | pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs))); | |
387 | pp_space (buffer); | |
0cf0d02b JJ |
388 | if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code)) |
389 | { | |
07838b13 | 390 | pp_left_paren (buffer); |
0cf0d02b JJ |
391 | dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, |
392 | false); | |
07838b13 | 393 | pp_right_paren (buffer); |
0cf0d02b JJ |
394 | } |
395 | else | |
396 | dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); | |
726a989a RB |
397 | } |
398 | } | |
399 | ||
0354c0c7 | 400 | /* Helper for dump_gimple_assign. Print the ternary RHS of the |
b5f47924 | 401 | assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */ |
0354c0c7 BS |
402 | |
403 | static void | |
404 | dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags) | |
405 | { | |
406 | const char *p; | |
407 | enum tree_code code = gimple_assign_rhs_code (gs); | |
408 | switch (code) | |
409 | { | |
410 | case WIDEN_MULT_PLUS_EXPR: | |
411 | case WIDEN_MULT_MINUS_EXPR: | |
5806f481 | 412 | for (p = get_tree_code_name (code); *p; p++) |
0354c0c7 BS |
413 | pp_character (buffer, TOUPPER (*p)); |
414 | pp_string (buffer, " <"); | |
415 | dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); | |
416 | pp_string (buffer, ", "); | |
417 | dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); | |
418 | pp_string (buffer, ", "); | |
419 | dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); | |
07838b13 | 420 | pp_greater (buffer); |
0354c0c7 BS |
421 | break; |
422 | ||
16949072 RG |
423 | case FMA_EXPR: |
424 | dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); | |
425 | pp_string (buffer, " * "); | |
426 | dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); | |
427 | pp_string (buffer, " + "); | |
428 | dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); | |
429 | break; | |
430 | ||
f471fe72 RG |
431 | case DOT_PROD_EXPR: |
432 | pp_string (buffer, "DOT_PROD_EXPR <"); | |
433 | dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); | |
434 | pp_string (buffer, ", "); | |
435 | dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); | |
436 | pp_string (buffer, ", "); | |
437 | dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); | |
79d652a5 CH |
438 | pp_greater (buffer); |
439 | break; | |
440 | ||
441 | case SAD_EXPR: | |
442 | pp_string (buffer, "SAD_EXPR <"); | |
443 | dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); | |
444 | pp_string (buffer, ", "); | |
445 | dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); | |
446 | pp_string (buffer, ", "); | |
447 | dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); | |
137a1a27 | 448 | pp_greater (buffer); |
f471fe72 | 449 | break; |
f90e8e2e | 450 | |
2205ed25 RH |
451 | case VEC_PERM_EXPR: |
452 | pp_string (buffer, "VEC_PERM_EXPR <"); | |
f90e8e2e AS |
453 | dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); |
454 | pp_string (buffer, ", "); | |
455 | dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); | |
456 | pp_string (buffer, ", "); | |
457 | dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); | |
137a1a27 | 458 | pp_greater (buffer); |
f90e8e2e | 459 | break; |
f471fe72 RG |
460 | |
461 | case REALIGN_LOAD_EXPR: | |
462 | pp_string (buffer, "REALIGN_LOAD <"); | |
463 | dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); | |
464 | pp_string (buffer, ", "); | |
465 | dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); | |
466 | pp_string (buffer, ", "); | |
467 | dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); | |
137a1a27 | 468 | pp_greater (buffer); |
4e71066d RG |
469 | break; |
470 | ||
471 | case COND_EXPR: | |
472 | dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); | |
473 | pp_string (buffer, " ? "); | |
474 | dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); | |
475 | pp_string (buffer, " : "); | |
476 | dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); | |
477 | break; | |
478 | ||
479 | case VEC_COND_EXPR: | |
480 | pp_string (buffer, "VEC_COND_EXPR <"); | |
481 | dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); | |
482 | pp_string (buffer, ", "); | |
483 | dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); | |
484 | pp_string (buffer, ", "); | |
485 | dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); | |
137a1a27 | 486 | pp_greater (buffer); |
f471fe72 RG |
487 | break; |
488 | ||
0354c0c7 BS |
489 | default: |
490 | gcc_unreachable (); | |
491 | } | |
492 | } | |
493 | ||
726a989a RB |
494 | |
495 | /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in | |
b5f47924 | 496 | pp_gimple_stmt_1. */ |
726a989a RB |
497 | |
498 | static void | |
499 | dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags) | |
500 | { | |
501 | if (flags & TDF_RAW) | |
502 | { | |
874a3756 MG |
503 | tree arg1 = NULL; |
504 | tree arg2 = NULL; | |
505 | tree arg3 = NULL; | |
506 | switch (gimple_num_ops (gs)) | |
507 | { | |
508 | case 4: | |
509 | arg3 = gimple_assign_rhs3 (gs); | |
510 | case 3: | |
511 | arg2 = gimple_assign_rhs2 (gs); | |
512 | case 2: | |
513 | arg1 = gimple_assign_rhs1 (gs); | |
514 | break; | |
515 | default: | |
516 | gcc_unreachable (); | |
517 | } | |
726a989a | 518 | |
874a3756 | 519 | dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs, |
5806f481 | 520 | get_tree_code_name (gimple_assign_rhs_code (gs)), |
874a3756 | 521 | gimple_assign_lhs (gs), arg1, arg2, arg3); |
726a989a RB |
522 | } |
523 | else | |
524 | { | |
525 | if (!(flags & TDF_RHS_ONLY)) | |
526 | { | |
527 | dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false); | |
528 | pp_space (buffer); | |
07838b13 | 529 | pp_equal (buffer); |
726a989a RB |
530 | |
531 | if (gimple_assign_nontemporal_move_p (gs)) | |
532 | pp_string (buffer, "{nt}"); | |
533 | ||
534 | if (gimple_has_volatile_ops (gs)) | |
535 | pp_string (buffer, "{v}"); | |
536 | ||
537 | pp_space (buffer); | |
538 | } | |
539 | ||
540 | if (gimple_num_ops (gs) == 2) | |
541 | dump_unary_rhs (buffer, gs, spc, flags); | |
542 | else if (gimple_num_ops (gs) == 3) | |
543 | dump_binary_rhs (buffer, gs, spc, flags); | |
0354c0c7 BS |
544 | else if (gimple_num_ops (gs) == 4) |
545 | dump_ternary_rhs (buffer, gs, spc, flags); | |
726a989a RB |
546 | else |
547 | gcc_unreachable (); | |
548 | if (!(flags & TDF_RHS_ONLY)) | |
c3284718 | 549 | pp_semicolon (buffer); |
726a989a RB |
550 | } |
551 | } | |
552 | ||
553 | ||
554 | /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in | |
b5f47924 | 555 | pp_gimple_stmt_1. */ |
726a989a RB |
556 | |
557 | static void | |
558 | dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags) | |
559 | { | |
089d1227 | 560 | tree t; |
726a989a RB |
561 | |
562 | t = gimple_return_retval (gs); | |
563 | if (flags & TDF_RAW) | |
089d1227 | 564 | dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t); |
726a989a RB |
565 | else |
566 | { | |
567 | pp_string (buffer, "return"); | |
568 | if (t) | |
569 | { | |
570 | pp_space (buffer); | |
571 | dump_generic_node (buffer, t, spc, flags, false); | |
572 | } | |
573 | pp_semicolon (buffer); | |
574 | } | |
575 | } | |
576 | ||
577 | ||
578 | /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in | |
579 | dump_gimple_call. */ | |
580 | ||
581 | static void | |
582 | dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags) | |
583 | { | |
584 | size_t i; | |
585 | ||
586 | for (i = 0; i < gimple_call_num_args (gs); i++) | |
587 | { | |
588 | dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false); | |
589 | if (i < gimple_call_num_args (gs) - 1) | |
590 | pp_string (buffer, ", "); | |
591 | } | |
592 | ||
593 | if (gimple_call_va_arg_pack_p (gs)) | |
594 | { | |
595 | if (gimple_call_num_args (gs) > 0) | |
596 | { | |
07838b13 | 597 | pp_comma (buffer); |
726a989a RB |
598 | pp_space (buffer); |
599 | } | |
600 | ||
601 | pp_string (buffer, "__builtin_va_arg_pack ()"); | |
602 | } | |
603 | } | |
604 | ||
25a6a873 RG |
605 | /* Dump the points-to solution *PT to BUFFER. */ |
606 | ||
607 | static void | |
608 | pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt) | |
609 | { | |
610 | if (pt->anything) | |
611 | { | |
612 | pp_string (buffer, "anything "); | |
613 | return; | |
614 | } | |
615 | if (pt->nonlocal) | |
616 | pp_string (buffer, "nonlocal "); | |
617 | if (pt->escaped) | |
618 | pp_string (buffer, "escaped "); | |
619 | if (pt->ipa_escaped) | |
620 | pp_string (buffer, "unit-escaped "); | |
621 | if (pt->null) | |
622 | pp_string (buffer, "null "); | |
623 | if (pt->vars | |
624 | && !bitmap_empty_p (pt->vars)) | |
625 | { | |
626 | bitmap_iterator bi; | |
627 | unsigned i; | |
628 | pp_string (buffer, "{ "); | |
629 | EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi) | |
630 | { | |
46eb666a RG |
631 | pp_string (buffer, "D."); |
632 | pp_decimal_int (buffer, i); | |
07838b13 | 633 | pp_space (buffer); |
25a6a873 | 634 | } |
07838b13 | 635 | pp_right_brace (buffer); |
11924f8b RB |
636 | if (pt->vars_contains_nonlocal |
637 | && pt->vars_contains_escaped_heap) | |
638 | pp_string (buffer, " (nonlocal, escaped heap)"); | |
639 | else if (pt->vars_contains_nonlocal | |
640 | && pt->vars_contains_escaped) | |
641 | pp_string (buffer, " (nonlocal, escaped)"); | |
642 | else if (pt->vars_contains_nonlocal) | |
643 | pp_string (buffer, " (nonlocal)"); | |
644 | else if (pt->vars_contains_escaped_heap) | |
645 | pp_string (buffer, " (escaped heap)"); | |
646 | else if (pt->vars_contains_escaped) | |
647 | pp_string (buffer, " (escaped)"); | |
25a6a873 RG |
648 | } |
649 | } | |
726a989a RB |
650 | |
651 | /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in | |
b5f47924 | 652 | pp_gimple_stmt_1. */ |
726a989a RB |
653 | |
654 | static void | |
655 | dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags) | |
656 | { | |
657 | tree lhs = gimple_call_lhs (gs); | |
0a35513e | 658 | tree fn = gimple_call_fn (gs); |
726a989a | 659 | |
25a6a873 RG |
660 | if (flags & TDF_ALIAS) |
661 | { | |
662 | struct pt_solution *pt; | |
663 | pt = gimple_call_use_set (gs); | |
664 | if (!pt_solution_empty_p (pt)) | |
665 | { | |
666 | pp_string (buffer, "# USE = "); | |
667 | pp_points_to_solution (buffer, pt); | |
668 | newline_and_indent (buffer, spc); | |
669 | } | |
670 | pt = gimple_call_clobber_set (gs); | |
671 | if (!pt_solution_empty_p (pt)) | |
672 | { | |
673 | pp_string (buffer, "# CLB = "); | |
674 | pp_points_to_solution (buffer, pt); | |
675 | newline_and_indent (buffer, spc); | |
676 | } | |
677 | } | |
678 | ||
726a989a RB |
679 | if (flags & TDF_RAW) |
680 | { | |
25583c4f RS |
681 | if (gimple_call_internal_p (gs)) |
682 | dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs, | |
683 | internal_fn_name (gimple_call_internal_fn (gs)), lhs); | |
684 | else | |
0a35513e | 685 | dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs); |
726a989a RB |
686 | if (gimple_call_num_args (gs) > 0) |
687 | { | |
688 | pp_string (buffer, ", "); | |
689 | dump_gimple_call_args (buffer, gs, flags); | |
690 | } | |
07838b13 | 691 | pp_greater (buffer); |
726a989a RB |
692 | } |
693 | else | |
694 | { | |
695 | if (lhs && !(flags & TDF_RHS_ONLY)) | |
696 | { | |
697 | dump_generic_node (buffer, lhs, spc, flags, false); | |
698 | pp_string (buffer, " ="); | |
699 | ||
700 | if (gimple_has_volatile_ops (gs)) | |
701 | pp_string (buffer, "{v}"); | |
702 | ||
703 | pp_space (buffer); | |
704 | } | |
25583c4f RS |
705 | if (gimple_call_internal_p (gs)) |
706 | pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs))); | |
707 | else | |
0a35513e | 708 | print_call_name (buffer, fn, flags); |
726a989a RB |
709 | pp_string (buffer, " ("); |
710 | dump_gimple_call_args (buffer, gs, flags); | |
07838b13 | 711 | pp_right_paren (buffer); |
726a989a RB |
712 | if (!(flags & TDF_RHS_ONLY)) |
713 | pp_semicolon (buffer); | |
714 | } | |
715 | ||
716 | if (gimple_call_chain (gs)) | |
717 | { | |
718 | pp_string (buffer, " [static-chain: "); | |
719 | dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false); | |
07838b13 | 720 | pp_right_bracket (buffer); |
726a989a RB |
721 | } |
722 | ||
723 | if (gimple_call_return_slot_opt_p (gs)) | |
724 | pp_string (buffer, " [return slot optimization]"); | |
726a989a RB |
725 | if (gimple_call_tail_p (gs)) |
726 | pp_string (buffer, " [tail call]"); | |
0a35513e | 727 | |
cbe9d630 SD |
728 | if (fn == NULL) |
729 | return; | |
730 | ||
0a35513e AH |
731 | /* Dump the arguments of _ITM_beginTransaction sanely. */ |
732 | if (TREE_CODE (fn) == ADDR_EXPR) | |
733 | fn = TREE_OPERAND (fn, 0); | |
734 | if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn)) | |
735 | pp_string (buffer, " [tm-clone]"); | |
736 | if (TREE_CODE (fn) == FUNCTION_DECL | |
737 | && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL | |
738 | && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START | |
739 | && gimple_call_num_args (gs) > 0) | |
740 | { | |
741 | tree t = gimple_call_arg (gs, 0); | |
742 | unsigned HOST_WIDE_INT props; | |
743 | gcc_assert (TREE_CODE (t) == INTEGER_CST); | |
744 | ||
745 | pp_string (buffer, " [ "); | |
746 | ||
747 | /* Get the transaction code properties. */ | |
748 | props = TREE_INT_CST_LOW (t); | |
749 | ||
750 | if (props & PR_INSTRUMENTEDCODE) | |
751 | pp_string (buffer, "instrumentedCode "); | |
752 | if (props & PR_UNINSTRUMENTEDCODE) | |
753 | pp_string (buffer, "uninstrumentedCode "); | |
754 | if (props & PR_HASNOXMMUPDATE) | |
755 | pp_string (buffer, "hasNoXMMUpdate "); | |
756 | if (props & PR_HASNOABORT) | |
757 | pp_string (buffer, "hasNoAbort "); | |
758 | if (props & PR_HASNOIRREVOCABLE) | |
759 | pp_string (buffer, "hasNoIrrevocable "); | |
760 | if (props & PR_DOESGOIRREVOCABLE) | |
761 | pp_string (buffer, "doesGoIrrevocable "); | |
762 | if (props & PR_HASNOSIMPLEREADS) | |
763 | pp_string (buffer, "hasNoSimpleReads "); | |
764 | if (props & PR_AWBARRIERSOMITTED) | |
765 | pp_string (buffer, "awBarriersOmitted "); | |
766 | if (props & PR_RARBARRIERSOMITTED) | |
767 | pp_string (buffer, "RaRBarriersOmitted "); | |
768 | if (props & PR_UNDOLOGCODE) | |
769 | pp_string (buffer, "undoLogCode "); | |
770 | if (props & PR_PREFERUNINSTRUMENTED) | |
771 | pp_string (buffer, "preferUninstrumented "); | |
772 | if (props & PR_EXCEPTIONBLOCK) | |
773 | pp_string (buffer, "exceptionBlock "); | |
774 | if (props & PR_HASELSE) | |
775 | pp_string (buffer, "hasElse "); | |
776 | if (props & PR_READONLY) | |
777 | pp_string (buffer, "readOnly "); | |
778 | ||
137a1a27 | 779 | pp_right_bracket (buffer); |
0a35513e | 780 | } |
726a989a RB |
781 | } |
782 | ||
783 | ||
784 | /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in | |
b5f47924 | 785 | pp_gimple_stmt_1. */ |
726a989a RB |
786 | |
787 | static void | |
788 | dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags) | |
789 | { | |
790 | unsigned int i; | |
791 | ||
792 | GIMPLE_CHECK (gs, GIMPLE_SWITCH); | |
793 | if (flags & TDF_RAW) | |
794 | dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs, | |
795 | gimple_switch_index (gs)); | |
796 | else | |
797 | { | |
798 | pp_string (buffer, "switch ("); | |
799 | dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true); | |
800 | pp_string (buffer, ") <"); | |
801 | } | |
802 | ||
803 | for (i = 0; i < gimple_switch_num_labels (gs); i++) | |
804 | { | |
805 | tree case_label = gimple_switch_label (gs, i); | |
fd8d363e | 806 | gcc_checking_assert (case_label != NULL_TREE); |
726a989a | 807 | dump_generic_node (buffer, case_label, spc, flags, false); |
07838b13 | 808 | pp_space (buffer); |
726a989a RB |
809 | dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false); |
810 | if (i < gimple_switch_num_labels (gs) - 1) | |
811 | pp_string (buffer, ", "); | |
812 | } | |
07838b13 | 813 | pp_greater (buffer); |
726a989a RB |
814 | } |
815 | ||
816 | ||
817 | /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in | |
b5f47924 | 818 | pp_gimple_stmt_1. */ |
726a989a RB |
819 | |
820 | static void | |
821 | dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags) | |
822 | { | |
823 | if (flags & TDF_RAW) | |
824 | dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs, | |
5806f481 PM |
825 | get_tree_code_name (gimple_cond_code (gs)), |
826 | gimple_cond_lhs (gs), gimple_cond_rhs (gs), | |
827 | gimple_cond_true_label (gs), gimple_cond_false_label (gs)); | |
726a989a RB |
828 | else |
829 | { | |
830 | if (!(flags & TDF_RHS_ONLY)) | |
831 | pp_string (buffer, "if ("); | |
832 | dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false); | |
833 | pp_space (buffer); | |
834 | pp_string (buffer, op_symbol_code (gimple_cond_code (gs))); | |
835 | pp_space (buffer); | |
836 | dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false); | |
837 | if (!(flags & TDF_RHS_ONLY)) | |
838 | { | |
07838b13 | 839 | pp_right_paren (buffer); |
726a989a RB |
840 | |
841 | if (gimple_cond_true_label (gs)) | |
842 | { | |
843 | pp_string (buffer, " goto "); | |
844 | dump_generic_node (buffer, gimple_cond_true_label (gs), | |
845 | spc, flags, false); | |
846 | pp_semicolon (buffer); | |
847 | } | |
848 | if (gimple_cond_false_label (gs)) | |
849 | { | |
850 | pp_string (buffer, " else goto "); | |
851 | dump_generic_node (buffer, gimple_cond_false_label (gs), | |
852 | spc, flags, false); | |
853 | pp_semicolon (buffer); | |
854 | } | |
855 | } | |
856 | } | |
857 | } | |
858 | ||
859 | ||
860 | /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC | |
861 | spaces of indent. FLAGS specifies details to show in the dump (see | |
7ee2468b | 862 | TDF_* in dumpfils.h). */ |
726a989a RB |
863 | |
864 | static void | |
865 | dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags) | |
866 | { | |
867 | tree label = gimple_label_label (gs); | |
868 | if (flags & TDF_RAW) | |
869 | dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label); | |
870 | else | |
871 | { | |
872 | dump_generic_node (buffer, label, spc, flags, false); | |
07838b13 | 873 | pp_colon (buffer); |
726a989a RB |
874 | } |
875 | if (DECL_NONLOCAL (label)) | |
876 | pp_string (buffer, " [non-local]"); | |
1d65f45c RH |
877 | if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label)) |
878 | pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label)); | |
726a989a RB |
879 | } |
880 | ||
881 | /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC | |
882 | spaces of indent. FLAGS specifies details to show in the dump (see | |
7ee2468b | 883 | TDF_* in dumpfile.h). */ |
726a989a RB |
884 | |
885 | static void | |
886 | dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags) | |
887 | { | |
888 | tree label = gimple_goto_dest (gs); | |
889 | if (flags & TDF_RAW) | |
890 | dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label); | |
891 | else | |
892 | dump_gimple_fmt (buffer, spc, flags, "goto %T;", label); | |
893 | } | |
894 | ||
895 | ||
896 | /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC | |
897 | spaces of indent. FLAGS specifies details to show in the dump (see | |
7ee2468b | 898 | TDF_* in dumpfile.h). */ |
726a989a RB |
899 | |
900 | static void | |
901 | dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags) | |
902 | { | |
903 | if (flags & TDF_RAW) | |
904 | dump_gimple_fmt (buffer, spc, flags, "%G <", gs); | |
905 | else | |
07838b13 | 906 | pp_left_brace (buffer); |
726a989a RB |
907 | if (!(flags & TDF_SLIM)) |
908 | { | |
909 | tree var; | |
910 | ||
910ad8de | 911 | for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var)) |
726a989a RB |
912 | { |
913 | newline_and_indent (buffer, 2); | |
914 | print_declaration (buffer, var, spc, flags); | |
915 | } | |
916 | if (gimple_bind_vars (gs)) | |
917 | pp_newline (buffer); | |
918 | } | |
919 | pp_newline (buffer); | |
920 | dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags); | |
921 | newline_and_indent (buffer, spc); | |
922 | if (flags & TDF_RAW) | |
07838b13 | 923 | pp_greater (buffer); |
726a989a | 924 | else |
07838b13 | 925 | pp_right_brace (buffer); |
726a989a RB |
926 | } |
927 | ||
928 | ||
929 | /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of | |
930 | indent. FLAGS specifies details to show in the dump (see TDF_* in | |
7ee2468b | 931 | dumpfile.h). */ |
726a989a RB |
932 | |
933 | static void | |
934 | dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags) | |
935 | { | |
936 | if (flags & TDF_RAW) | |
937 | { | |
938 | const char *type; | |
939 | if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH) | |
940 | type = "GIMPLE_TRY_CATCH"; | |
941 | else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY) | |
942 | type = "GIMPLE_TRY_FINALLY"; | |
943 | else | |
944 | type = "UNKNOWN GIMPLE_TRY"; | |
945 | dump_gimple_fmt (buffer, spc, flags, | |
946 | "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type, | |
947 | gimple_try_eval (gs), gimple_try_cleanup (gs)); | |
948 | } | |
949 | else | |
950 | { | |
951 | pp_string (buffer, "try"); | |
952 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 953 | pp_left_brace (buffer); |
726a989a RB |
954 | pp_newline (buffer); |
955 | ||
956 | dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags); | |
957 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 958 | pp_right_brace (buffer); |
726a989a RB |
959 | |
960 | if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH) | |
961 | { | |
962 | newline_and_indent (buffer, spc); | |
963 | pp_string (buffer, "catch"); | |
964 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 965 | pp_left_brace (buffer); |
726a989a RB |
966 | } |
967 | else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY) | |
968 | { | |
969 | newline_and_indent (buffer, spc); | |
970 | pp_string (buffer, "finally"); | |
971 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 972 | pp_left_brace (buffer); |
726a989a RB |
973 | } |
974 | else | |
975 | pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {"); | |
976 | ||
977 | pp_newline (buffer); | |
978 | dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags); | |
979 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 980 | pp_right_brace (buffer); |
726a989a RB |
981 | } |
982 | } | |
983 | ||
984 | ||
985 | /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of | |
986 | indent. FLAGS specifies details to show in the dump (see TDF_* in | |
7ee2468b | 987 | dumpfile.h). */ |
726a989a RB |
988 | |
989 | static void | |
990 | dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags) | |
991 | { | |
992 | if (flags & TDF_RAW) | |
993 | dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs, | |
994 | gimple_catch_types (gs), gimple_catch_handler (gs)); | |
995 | else | |
996 | dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}", | |
997 | gimple_catch_types (gs), gimple_catch_handler (gs)); | |
998 | } | |
999 | ||
1000 | ||
1001 | /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of | |
1002 | indent. FLAGS specifies details to show in the dump (see TDF_* in | |
7ee2468b | 1003 | dumpfile.h). */ |
726a989a RB |
1004 | |
1005 | static void | |
1006 | dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1007 | { | |
1008 | if (flags & TDF_RAW) | |
1009 | dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs, | |
1010 | gimple_eh_filter_types (gs), | |
1011 | gimple_eh_filter_failure (gs)); | |
1012 | else | |
1013 | dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}", | |
1014 | gimple_eh_filter_types (gs), | |
1015 | gimple_eh_filter_failure (gs)); | |
1016 | } | |
1017 | ||
1018 | ||
1d65f45c RH |
1019 | /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */ |
1020 | ||
1021 | static void | |
1022 | dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs, | |
1023 | int spc, int flags) | |
1024 | { | |
1025 | if (flags & TDF_RAW) | |
1026 | dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, | |
1027 | gimple_eh_must_not_throw_fndecl (gs)); | |
1028 | else | |
1029 | dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>", | |
1030 | gimple_eh_must_not_throw_fndecl (gs)); | |
1031 | } | |
1032 | ||
1033 | ||
0a35513e AH |
1034 | /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of |
1035 | indent. FLAGS specifies details to show in the dump (see TDF_* in | |
7ee2468b | 1036 | dumpfile.h). */ |
0a35513e AH |
1037 | |
1038 | static void | |
1039 | dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1040 | { | |
1041 | if (flags & TDF_RAW) | |
1042 | dump_gimple_fmt (buffer, spc, flags, | |
1043 | "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs, | |
1044 | gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs)); | |
1045 | else | |
1046 | dump_gimple_fmt (buffer, spc, flags, | |
1047 | "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}", | |
1048 | gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs)); | |
1049 | } | |
1050 | ||
1051 | ||
726a989a RB |
1052 | /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of |
1053 | indent. FLAGS specifies details to show in the dump (see TDF_* in | |
7ee2468b | 1054 | dumpfile.h). */ |
726a989a RB |
1055 | |
1056 | static void | |
1057 | dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1058 | { | |
1059 | if (flags & TDF_RAW) | |
1060 | dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs, | |
1d65f45c | 1061 | gimple_resx_region (gs)); |
726a989a RB |
1062 | else |
1063 | dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs)); | |
1064 | } | |
1065 | ||
1d65f45c RH |
1066 | /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */ |
1067 | ||
1068 | static void | |
1069 | dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1070 | { | |
1071 | if (flags & TDF_RAW) | |
1072 | dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs, | |
1073 | gimple_eh_dispatch_region (gs)); | |
1074 | else | |
1075 | dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d", | |
1076 | gimple_eh_dispatch_region (gs)); | |
1077 | } | |
1078 | ||
b5b8b0ac AO |
1079 | /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces |
1080 | of indent. FLAGS specifies details to show in the dump (see TDF_* | |
7ee2468b | 1081 | in dumpfile.h). */ |
b5b8b0ac AO |
1082 | |
1083 | static void | |
1084 | dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1085 | { | |
daa6e488 | 1086 | switch (gs->subcode) |
b5b8b0ac AO |
1087 | { |
1088 | case GIMPLE_DEBUG_BIND: | |
1089 | if (flags & TDF_RAW) | |
1090 | dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs, | |
1091 | gimple_debug_bind_get_var (gs), | |
1092 | gimple_debug_bind_get_value (gs)); | |
1093 | else | |
1094 | dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T", | |
1095 | gimple_debug_bind_get_var (gs), | |
1096 | gimple_debug_bind_get_value (gs)); | |
1097 | break; | |
1098 | ||
ddb555ed JJ |
1099 | case GIMPLE_DEBUG_SOURCE_BIND: |
1100 | if (flags & TDF_RAW) | |
1101 | dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs, | |
1102 | gimple_debug_source_bind_get_var (gs), | |
1103 | gimple_debug_source_bind_get_value (gs)); | |
1104 | else | |
1105 | dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T", | |
1106 | gimple_debug_source_bind_get_var (gs), | |
1107 | gimple_debug_source_bind_get_value (gs)); | |
1108 | break; | |
1109 | ||
b5b8b0ac AO |
1110 | default: |
1111 | gcc_unreachable (); | |
1112 | } | |
1113 | } | |
1114 | ||
726a989a RB |
1115 | /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */ |
1116 | static void | |
1117 | dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1118 | { | |
1119 | size_t i; | |
1120 | ||
1121 | if (flags & TDF_RAW) | |
1122 | { | |
74bf76ed JJ |
1123 | const char *kind; |
1124 | switch (gimple_omp_for_kind (gs)) | |
1125 | { | |
1126 | case GF_OMP_FOR_KIND_FOR: | |
1127 | kind = ""; | |
1128 | break; | |
1129 | case GF_OMP_FOR_KIND_SIMD: | |
1130 | kind = " simd"; | |
1131 | break; | |
c02065fc AH |
1132 | case GF_OMP_FOR_KIND_CILKSIMD: |
1133 | kind = " cilksimd"; | |
aa6ef874 | 1134 | break; |
acf0174b JJ |
1135 | case GF_OMP_FOR_KIND_DISTRIBUTE: |
1136 | kind = " distribute"; | |
1137 | break; | |
9a771876 JJ |
1138 | case GF_OMP_FOR_KIND_CILKFOR: |
1139 | kind = " _Cilk_for"; | |
1140 | break; | |
74bf76ed JJ |
1141 | default: |
1142 | gcc_unreachable (); | |
1143 | } | |
1144 | dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs, | |
1145 | kind, gimple_omp_body (gs)); | |
726a989a RB |
1146 | dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags); |
1147 | dump_gimple_fmt (buffer, spc, flags, " >,"); | |
1148 | for (i = 0; i < gimple_omp_for_collapse (gs); i++) | |
1149 | dump_gimple_fmt (buffer, spc, flags, | |
1150 | "%+%T, %T, %T, %s, %T,%n", | |
1151 | gimple_omp_for_index (gs, i), | |
1152 | gimple_omp_for_initial (gs, i), | |
1153 | gimple_omp_for_final (gs, i), | |
5806f481 | 1154 | get_tree_code_name (gimple_omp_for_cond (gs, i)), |
726a989a RB |
1155 | gimple_omp_for_incr (gs, i)); |
1156 | dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->", | |
1157 | gimple_omp_for_pre_body (gs)); | |
1158 | } | |
1159 | else | |
1160 | { | |
74bf76ed JJ |
1161 | switch (gimple_omp_for_kind (gs)) |
1162 | { | |
1163 | case GF_OMP_FOR_KIND_FOR: | |
1164 | pp_string (buffer, "#pragma omp for"); | |
1165 | break; | |
1166 | case GF_OMP_FOR_KIND_SIMD: | |
1167 | pp_string (buffer, "#pragma omp simd"); | |
1168 | break; | |
c02065fc AH |
1169 | case GF_OMP_FOR_KIND_CILKSIMD: |
1170 | pp_string (buffer, "#pragma simd"); | |
1171 | break; | |
acf0174b JJ |
1172 | case GF_OMP_FOR_KIND_DISTRIBUTE: |
1173 | pp_string (buffer, "#pragma omp distribute"); | |
1174 | break; | |
9a771876 JJ |
1175 | case GF_OMP_FOR_KIND_CILKFOR: |
1176 | break; | |
74bf76ed JJ |
1177 | default: |
1178 | gcc_unreachable (); | |
1179 | } | |
9a771876 JJ |
1180 | if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR) |
1181 | dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags); | |
726a989a RB |
1182 | for (i = 0; i < gimple_omp_for_collapse (gs); i++) |
1183 | { | |
1184 | if (i) | |
1185 | spc += 2; | |
9a771876 JJ |
1186 | if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR) |
1187 | pp_string (buffer, "_Cilk_for ("); | |
1188 | else | |
1189 | { | |
1190 | newline_and_indent (buffer, spc); | |
1191 | pp_string (buffer, "for ("); | |
1192 | } | |
726a989a RB |
1193 | dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc, |
1194 | flags, false); | |
1195 | pp_string (buffer, " = "); | |
1196 | dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc, | |
1197 | flags, false); | |
1198 | pp_string (buffer, "; "); | |
1199 | ||
1200 | dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc, | |
1201 | flags, false); | |
1202 | pp_space (buffer); | |
1203 | switch (gimple_omp_for_cond (gs, i)) | |
1204 | { | |
1205 | case LT_EXPR: | |
07838b13 | 1206 | pp_less (buffer); |
726a989a RB |
1207 | break; |
1208 | case GT_EXPR: | |
07838b13 | 1209 | pp_greater (buffer); |
726a989a RB |
1210 | break; |
1211 | case LE_EXPR: | |
137a1a27 | 1212 | pp_less_equal (buffer); |
726a989a RB |
1213 | break; |
1214 | case GE_EXPR: | |
137a1a27 | 1215 | pp_greater_equal (buffer); |
726a989a | 1216 | break; |
9a771876 JJ |
1217 | case NE_EXPR: |
1218 | pp_string (buffer, "!="); | |
1219 | break; | |
726a989a RB |
1220 | default: |
1221 | gcc_unreachable (); | |
1222 | } | |
1223 | pp_space (buffer); | |
1224 | dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc, | |
1225 | flags, false); | |
1226 | pp_string (buffer, "; "); | |
1227 | ||
1228 | dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc, | |
1229 | flags, false); | |
1230 | pp_string (buffer, " = "); | |
1231 | dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc, | |
1232 | flags, false); | |
07838b13 | 1233 | pp_right_paren (buffer); |
726a989a RB |
1234 | } |
1235 | ||
1236 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) | |
1237 | { | |
9a771876 JJ |
1238 | if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR) |
1239 | dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags); | |
726a989a | 1240 | newline_and_indent (buffer, spc + 2); |
07838b13 | 1241 | pp_left_brace (buffer); |
726a989a RB |
1242 | pp_newline (buffer); |
1243 | dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); | |
1244 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1245 | pp_right_brace (buffer); |
726a989a RB |
1246 | } |
1247 | } | |
1248 | } | |
1249 | ||
1250 | /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */ | |
1251 | ||
1252 | static void | |
1253 | dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1254 | { | |
1255 | if (flags & TDF_RAW) | |
1256 | { | |
1257 | dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs, | |
1258 | gimple_omp_continue_control_def (gs), | |
1259 | gimple_omp_continue_control_use (gs)); | |
1260 | } | |
1261 | else | |
1262 | { | |
1263 | pp_string (buffer, "#pragma omp continue ("); | |
1264 | dump_generic_node (buffer, gimple_omp_continue_control_def (gs), | |
1265 | spc, flags, false); | |
07838b13 | 1266 | pp_comma (buffer); |
726a989a RB |
1267 | pp_space (buffer); |
1268 | dump_generic_node (buffer, gimple_omp_continue_control_use (gs), | |
1269 | spc, flags, false); | |
07838b13 | 1270 | pp_right_paren (buffer); |
726a989a RB |
1271 | } |
1272 | } | |
1273 | ||
1274 | /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */ | |
1275 | ||
1276 | static void | |
1277 | dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1278 | { | |
1279 | if (flags & TDF_RAW) | |
1280 | { | |
1281 | dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, | |
1282 | gimple_omp_body (gs)); | |
1283 | dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags); | |
1284 | dump_gimple_fmt (buffer, spc, flags, " >"); | |
1285 | } | |
1286 | else | |
1287 | { | |
1288 | pp_string (buffer, "#pragma omp single"); | |
1289 | dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags); | |
1290 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) | |
1291 | { | |
1292 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1293 | pp_left_brace (buffer); |
726a989a RB |
1294 | pp_newline (buffer); |
1295 | dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); | |
1296 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1297 | pp_right_brace (buffer); |
726a989a RB |
1298 | } |
1299 | } | |
1300 | } | |
1301 | ||
acf0174b JJ |
1302 | /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */ |
1303 | ||
1304 | static void | |
1305 | dump_gimple_omp_target (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1306 | { | |
1307 | const char *kind; | |
1308 | switch (gimple_omp_target_kind (gs)) | |
1309 | { | |
1310 | case GF_OMP_TARGET_KIND_REGION: | |
1311 | kind = ""; | |
1312 | break; | |
1313 | case GF_OMP_TARGET_KIND_DATA: | |
1314 | kind = " data"; | |
1315 | break; | |
1316 | case GF_OMP_TARGET_KIND_UPDATE: | |
1317 | kind = " update"; | |
1318 | break; | |
1319 | default: | |
1320 | gcc_unreachable (); | |
1321 | } | |
1322 | if (flags & TDF_RAW) | |
1323 | { | |
1324 | dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs, | |
1325 | kind, gimple_omp_body (gs)); | |
1326 | dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags); | |
1327 | dump_gimple_fmt (buffer, spc, flags, " >"); | |
1328 | } | |
1329 | else | |
1330 | { | |
1331 | pp_string (buffer, "#pragma omp target"); | |
1332 | pp_string (buffer, kind); | |
1333 | dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags); | |
1334 | if (gimple_omp_target_child_fn (gs)) | |
1335 | { | |
1336 | pp_string (buffer, " [child fn: "); | |
1337 | dump_generic_node (buffer, gimple_omp_target_child_fn (gs), | |
1338 | spc, flags, false); | |
1339 | pp_right_bracket (buffer); | |
1340 | } | |
1341 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) | |
1342 | { | |
1343 | newline_and_indent (buffer, spc + 2); | |
1344 | pp_character (buffer, '{'); | |
1345 | pp_newline (buffer); | |
1346 | dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); | |
1347 | newline_and_indent (buffer, spc + 2); | |
1348 | pp_character (buffer, '}'); | |
1349 | } | |
1350 | } | |
1351 | } | |
1352 | ||
1353 | /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */ | |
1354 | ||
1355 | static void | |
1356 | dump_gimple_omp_teams (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1357 | { | |
1358 | if (flags & TDF_RAW) | |
1359 | { | |
1360 | dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, | |
1361 | gimple_omp_body (gs)); | |
1362 | dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags); | |
1363 | dump_gimple_fmt (buffer, spc, flags, " >"); | |
1364 | } | |
1365 | else | |
1366 | { | |
1367 | pp_string (buffer, "#pragma omp teams"); | |
1368 | dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags); | |
1369 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) | |
1370 | { | |
1371 | newline_and_indent (buffer, spc + 2); | |
1372 | pp_character (buffer, '{'); | |
1373 | pp_newline (buffer); | |
1374 | dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); | |
1375 | newline_and_indent (buffer, spc + 2); | |
1376 | pp_character (buffer, '}'); | |
1377 | } | |
1378 | } | |
1379 | } | |
1380 | ||
726a989a RB |
1381 | /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */ |
1382 | ||
1383 | static void | |
1384 | dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc, | |
1385 | int flags) | |
1386 | { | |
1387 | if (flags & TDF_RAW) | |
1388 | { | |
1389 | dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, | |
1390 | gimple_omp_body (gs)); | |
1391 | dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags); | |
1392 | dump_gimple_fmt (buffer, spc, flags, " >"); | |
1393 | } | |
1394 | else | |
1395 | { | |
1396 | pp_string (buffer, "#pragma omp sections"); | |
1397 | if (gimple_omp_sections_control (gs)) | |
1398 | { | |
1399 | pp_string (buffer, " <"); | |
1400 | dump_generic_node (buffer, gimple_omp_sections_control (gs), spc, | |
1401 | flags, false); | |
07838b13 | 1402 | pp_greater (buffer); |
726a989a RB |
1403 | } |
1404 | dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags); | |
1405 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) | |
1406 | { | |
1407 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1408 | pp_left_brace (buffer); |
726a989a RB |
1409 | pp_newline (buffer); |
1410 | dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); | |
1411 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1412 | pp_right_brace (buffer); |
726a989a RB |
1413 | } |
1414 | } | |
1415 | } | |
1416 | ||
acf0174b JJ |
1417 | /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the |
1418 | pretty_printer BUFFER. */ | |
726a989a RB |
1419 | |
1420 | static void | |
1421 | dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1422 | { | |
1423 | if (flags & TDF_RAW) | |
1424 | dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs, | |
1425 | gimple_omp_body (gs)); | |
1426 | else | |
1427 | { | |
1428 | switch (gimple_code (gs)) | |
1429 | { | |
1430 | case GIMPLE_OMP_MASTER: | |
1431 | pp_string (buffer, "#pragma omp master"); | |
1432 | break; | |
acf0174b JJ |
1433 | case GIMPLE_OMP_TASKGROUP: |
1434 | pp_string (buffer, "#pragma omp taskgroup"); | |
1435 | break; | |
726a989a RB |
1436 | case GIMPLE_OMP_ORDERED: |
1437 | pp_string (buffer, "#pragma omp ordered"); | |
1438 | break; | |
1439 | case GIMPLE_OMP_SECTION: | |
1440 | pp_string (buffer, "#pragma omp section"); | |
1441 | break; | |
1442 | default: | |
1443 | gcc_unreachable (); | |
1444 | } | |
1445 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) | |
1446 | { | |
1447 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1448 | pp_left_brace (buffer); |
726a989a RB |
1449 | pp_newline (buffer); |
1450 | dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); | |
1451 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1452 | pp_right_brace (buffer); |
726a989a RB |
1453 | } |
1454 | } | |
1455 | } | |
1456 | ||
1457 | /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */ | |
1458 | ||
1459 | static void | |
1460 | dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc, | |
1461 | int flags) | |
1462 | { | |
1463 | if (flags & TDF_RAW) | |
1464 | dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs, | |
1465 | gimple_omp_body (gs)); | |
1466 | else | |
1467 | { | |
1468 | pp_string (buffer, "#pragma omp critical"); | |
1469 | if (gimple_omp_critical_name (gs)) | |
1470 | { | |
1471 | pp_string (buffer, " ("); | |
1472 | dump_generic_node (buffer, gimple_omp_critical_name (gs), spc, | |
1473 | flags, false); | |
07838b13 | 1474 | pp_right_paren (buffer); |
726a989a RB |
1475 | } |
1476 | if (!gimple_seq_empty_p (gimple_omp_body (gs))) | |
1477 | { | |
1478 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1479 | pp_left_brace (buffer); |
726a989a RB |
1480 | pp_newline (buffer); |
1481 | dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); | |
1482 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1483 | pp_right_brace (buffer); |
726a989a RB |
1484 | } |
1485 | } | |
1486 | } | |
1487 | ||
1488 | /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */ | |
1489 | ||
1490 | static void | |
1491 | dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1492 | { | |
1493 | if (flags & TDF_RAW) | |
1494 | { | |
acf0174b | 1495 | dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs, |
726a989a | 1496 | (int) gimple_omp_return_nowait_p (gs)); |
acf0174b JJ |
1497 | if (gimple_omp_return_lhs (gs)) |
1498 | dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>", | |
1499 | gimple_omp_return_lhs (gs)); | |
1500 | else | |
1501 | dump_gimple_fmt (buffer, spc, flags, ">"); | |
726a989a RB |
1502 | } |
1503 | else | |
1504 | { | |
1505 | pp_string (buffer, "#pragma omp return"); | |
1506 | if (gimple_omp_return_nowait_p (gs)) | |
1507 | pp_string (buffer, "(nowait)"); | |
acf0174b JJ |
1508 | if (gimple_omp_return_lhs (gs)) |
1509 | { | |
1510 | pp_string (buffer, " (set "); | |
1511 | dump_generic_node (buffer, gimple_omp_return_lhs (gs), | |
1512 | spc, flags, false); | |
1513 | pp_character (buffer, ')'); | |
1514 | } | |
726a989a RB |
1515 | } |
1516 | } | |
1517 | ||
0a35513e AH |
1518 | /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */ |
1519 | ||
1520 | static void | |
1521 | dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1522 | { | |
1523 | unsigned subcode = gimple_transaction_subcode (gs); | |
1524 | ||
1525 | if (flags & TDF_RAW) | |
1526 | { | |
1527 | dump_gimple_fmt (buffer, spc, flags, | |
1528 | "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >", | |
1529 | gs, subcode, gimple_transaction_label (gs), | |
1530 | gimple_transaction_body (gs)); | |
1531 | } | |
1532 | else | |
1533 | { | |
1534 | if (subcode & GTMA_IS_OUTER) | |
1535 | pp_string (buffer, "__transaction_atomic [[outer]]"); | |
1536 | else if (subcode & GTMA_IS_RELAXED) | |
1537 | pp_string (buffer, "__transaction_relaxed"); | |
1538 | else | |
1539 | pp_string (buffer, "__transaction_atomic"); | |
1540 | subcode &= ~GTMA_DECLARATION_MASK; | |
1541 | ||
1542 | if (subcode || gimple_transaction_label (gs)) | |
1543 | { | |
1544 | pp_string (buffer, " //"); | |
1545 | if (gimple_transaction_label (gs)) | |
1546 | { | |
1547 | pp_string (buffer, " LABEL="); | |
1548 | dump_generic_node (buffer, gimple_transaction_label (gs), | |
1549 | spc, flags, false); | |
1550 | } | |
1551 | if (subcode) | |
1552 | { | |
1553 | pp_string (buffer, " SUBCODE=[ "); | |
1554 | if (subcode & GTMA_HAVE_ABORT) | |
1555 | { | |
1556 | pp_string (buffer, "GTMA_HAVE_ABORT "); | |
1557 | subcode &= ~GTMA_HAVE_ABORT; | |
1558 | } | |
1559 | if (subcode & GTMA_HAVE_LOAD) | |
1560 | { | |
1561 | pp_string (buffer, "GTMA_HAVE_LOAD "); | |
1562 | subcode &= ~GTMA_HAVE_LOAD; | |
1563 | } | |
1564 | if (subcode & GTMA_HAVE_STORE) | |
1565 | { | |
1566 | pp_string (buffer, "GTMA_HAVE_STORE "); | |
1567 | subcode &= ~GTMA_HAVE_STORE; | |
1568 | } | |
1569 | if (subcode & GTMA_MAY_ENTER_IRREVOCABLE) | |
1570 | { | |
1571 | pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE "); | |
1572 | subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE; | |
1573 | } | |
1574 | if (subcode & GTMA_DOES_GO_IRREVOCABLE) | |
1575 | { | |
1576 | pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE "); | |
1577 | subcode &= ~GTMA_DOES_GO_IRREVOCABLE; | |
1578 | } | |
b7a78683 AH |
1579 | if (subcode & GTMA_HAS_NO_INSTRUMENTATION) |
1580 | { | |
1581 | pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION "); | |
1582 | subcode &= ~GTMA_HAS_NO_INSTRUMENTATION; | |
1583 | } | |
0a35513e AH |
1584 | if (subcode) |
1585 | pp_printf (buffer, "0x%x ", subcode); | |
137a1a27 | 1586 | pp_right_bracket (buffer); |
0a35513e AH |
1587 | } |
1588 | } | |
1589 | ||
1590 | if (!gimple_seq_empty_p (gimple_transaction_body (gs))) | |
1591 | { | |
1592 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1593 | pp_left_brace (buffer); |
0a35513e AH |
1594 | pp_newline (buffer); |
1595 | dump_gimple_seq (buffer, gimple_transaction_body (gs), | |
1596 | spc + 4, flags); | |
1597 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1598 | pp_right_brace (buffer); |
0a35513e AH |
1599 | } |
1600 | } | |
1601 | } | |
1602 | ||
726a989a RB |
1603 | /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of |
1604 | indent. FLAGS specifies details to show in the dump (see TDF_* in | |
7ee2468b | 1605 | dumpfile.h). */ |
726a989a RB |
1606 | |
1607 | static void | |
1608 | dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags) | |
1609 | { | |
1c384bf1 | 1610 | unsigned int i, n, f, fields; |
726a989a RB |
1611 | |
1612 | if (flags & TDF_RAW) | |
1c384bf1 RH |
1613 | { |
1614 | dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs, | |
1615 | gimple_asm_string (gs)); | |
1616 | ||
1617 | n = gimple_asm_noutputs (gs); | |
1618 | if (n) | |
1619 | { | |
1620 | newline_and_indent (buffer, spc + 2); | |
1621 | pp_string (buffer, "OUTPUT: "); | |
1622 | for (i = 0; i < n; i++) | |
1623 | { | |
1624 | dump_generic_node (buffer, gimple_asm_output_op (gs, i), | |
1625 | spc, flags, false); | |
1626 | if (i < n - 1) | |
1627 | pp_string (buffer, ", "); | |
1628 | } | |
1629 | } | |
1630 | ||
1631 | n = gimple_asm_ninputs (gs); | |
1632 | if (n) | |
1633 | { | |
1634 | newline_and_indent (buffer, spc + 2); | |
1635 | pp_string (buffer, "INPUT: "); | |
1636 | for (i = 0; i < n; i++) | |
1637 | { | |
1638 | dump_generic_node (buffer, gimple_asm_input_op (gs, i), | |
1639 | spc, flags, false); | |
1640 | if (i < n - 1) | |
1641 | pp_string (buffer, ", "); | |
1642 | } | |
1643 | } | |
1644 | ||
1645 | n = gimple_asm_nclobbers (gs); | |
1646 | if (n) | |
1647 | { | |
1648 | newline_and_indent (buffer, spc + 2); | |
1649 | pp_string (buffer, "CLOBBER: "); | |
1650 | for (i = 0; i < n; i++) | |
1651 | { | |
1652 | dump_generic_node (buffer, gimple_asm_clobber_op (gs, i), | |
1653 | spc, flags, false); | |
1654 | if (i < n - 1) | |
1655 | pp_string (buffer, ", "); | |
1656 | } | |
1657 | } | |
1658 | ||
1659 | n = gimple_asm_nlabels (gs); | |
1660 | if (n) | |
1661 | { | |
1662 | newline_and_indent (buffer, spc + 2); | |
1663 | pp_string (buffer, "LABEL: "); | |
1664 | for (i = 0; i < n; i++) | |
1665 | { | |
1666 | dump_generic_node (buffer, gimple_asm_label_op (gs, i), | |
1667 | spc, flags, false); | |
1668 | if (i < n - 1) | |
1669 | pp_string (buffer, ", "); | |
1670 | } | |
1671 | } | |
1672 | ||
1673 | newline_and_indent (buffer, spc); | |
07838b13 | 1674 | pp_greater (buffer); |
1c384bf1 | 1675 | } |
726a989a RB |
1676 | else |
1677 | { | |
1678 | pp_string (buffer, "__asm__"); | |
1679 | if (gimple_asm_volatile_p (gs)) | |
1680 | pp_string (buffer, " __volatile__"); | |
1c384bf1 RH |
1681 | if (gimple_asm_nlabels (gs)) |
1682 | pp_string (buffer, " goto"); | |
726a989a RB |
1683 | pp_string (buffer, "(\""); |
1684 | pp_string (buffer, gimple_asm_string (gs)); | |
1685 | pp_string (buffer, "\""); | |
726a989a | 1686 | |
1c384bf1 RH |
1687 | if (gimple_asm_nlabels (gs)) |
1688 | fields = 4; | |
1689 | else if (gimple_asm_nclobbers (gs)) | |
1690 | fields = 3; | |
1691 | else if (gimple_asm_ninputs (gs)) | |
1692 | fields = 2; | |
1693 | else if (gimple_asm_noutputs (gs)) | |
1694 | fields = 1; | |
1695 | else | |
1696 | fields = 0; | |
726a989a | 1697 | |
1c384bf1 RH |
1698 | for (f = 0; f < fields; ++f) |
1699 | { | |
1700 | pp_string (buffer, " : "); | |
726a989a | 1701 | |
1c384bf1 RH |
1702 | switch (f) |
1703 | { | |
1704 | case 0: | |
1705 | n = gimple_asm_noutputs (gs); | |
1706 | for (i = 0; i < n; i++) | |
1707 | { | |
1708 | dump_generic_node (buffer, gimple_asm_output_op (gs, i), | |
1709 | spc, flags, false); | |
1710 | if (i < n - 1) | |
1711 | pp_string (buffer, ", "); | |
1712 | } | |
1713 | break; | |
726a989a | 1714 | |
1c384bf1 RH |
1715 | case 1: |
1716 | n = gimple_asm_ninputs (gs); | |
1717 | for (i = 0; i < n; i++) | |
1718 | { | |
1719 | dump_generic_node (buffer, gimple_asm_input_op (gs, i), | |
1720 | spc, flags, false); | |
1721 | if (i < n - 1) | |
1722 | pp_string (buffer, ", "); | |
1723 | } | |
1724 | break; | |
726a989a | 1725 | |
1c384bf1 RH |
1726 | case 2: |
1727 | n = gimple_asm_nclobbers (gs); | |
1728 | for (i = 0; i < n; i++) | |
1729 | { | |
1730 | dump_generic_node (buffer, gimple_asm_clobber_op (gs, i), | |
1731 | spc, flags, false); | |
1732 | if (i < n - 1) | |
1733 | pp_string (buffer, ", "); | |
1734 | } | |
1735 | break; | |
726a989a | 1736 | |
1c384bf1 RH |
1737 | case 3: |
1738 | n = gimple_asm_nlabels (gs); | |
1739 | for (i = 0; i < n; i++) | |
1740 | { | |
1741 | dump_generic_node (buffer, gimple_asm_label_op (gs, i), | |
1742 | spc, flags, false); | |
1743 | if (i < n - 1) | |
1744 | pp_string (buffer, ", "); | |
1745 | } | |
1746 | break; | |
1747 | ||
1748 | default: | |
1749 | gcc_unreachable (); | |
1750 | } | |
1751 | } | |
1752 | ||
1753 | pp_string (buffer, ");"); | |
726a989a | 1754 | } |
726a989a RB |
1755 | } |
1756 | ||
a895a2b8 KV |
1757 | /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with |
1758 | SPC spaces of indent. */ | |
726a989a RB |
1759 | |
1760 | static void | |
a895a2b8 | 1761 | dump_ssaname_info (pretty_printer *buffer, tree node, int spc) |
726a989a | 1762 | { |
a895a2b8 KV |
1763 | if (TREE_CODE (node) != SSA_NAME) |
1764 | return; | |
f0107145 | 1765 | |
a895a2b8 KV |
1766 | if (POINTER_TYPE_P (TREE_TYPE (node)) |
1767 | && SSA_NAME_PTR_INFO (node)) | |
f0107145 | 1768 | { |
644ffefd | 1769 | unsigned int align, misalign; |
a895a2b8 | 1770 | struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node); |
d09c0e9b | 1771 | pp_string (buffer, "# PT = "); |
1be38ccb RG |
1772 | pp_points_to_solution (buffer, &pi->pt); |
1773 | newline_and_indent (buffer, spc); | |
644ffefd | 1774 | if (get_ptr_info_alignment (pi, &align, &misalign)) |
b1edf2bc | 1775 | { |
644ffefd | 1776 | pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign); |
b1edf2bc RG |
1777 | newline_and_indent (buffer, spc); |
1778 | } | |
f0107145 | 1779 | } |
726a989a | 1780 | |
a895a2b8 KV |
1781 | if (!POINTER_TYPE_P (TREE_TYPE (node)) |
1782 | && SSA_NAME_RANGE_INFO (node)) | |
1783 | { | |
807e902e | 1784 | wide_int min, max, nonzero_bits; |
a895a2b8 KV |
1785 | value_range_type range_type = get_range_info (node, &min, &max); |
1786 | ||
1787 | if (range_type == VR_VARYING) | |
d09c0e9b | 1788 | pp_printf (buffer, "# RANGE VR_VARYING"); |
a895a2b8 | 1789 | else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE) |
0498471b CL |
1790 | { |
1791 | pp_printf (buffer, "# RANGE "); | |
1792 | pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~"); | |
807e902e | 1793 | pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node))); |
0498471b | 1794 | pp_printf (buffer, ", "); |
807e902e | 1795 | pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node))); |
0498471b | 1796 | pp_printf (buffer, "]"); |
0498471b | 1797 | } |
c853f62a | 1798 | nonzero_bits = get_nonzero_bits (node); |
807e902e | 1799 | if (nonzero_bits != -1) |
c853f62a JJ |
1800 | { |
1801 | pp_string (buffer, " NONZERO "); | |
807e902e | 1802 | pp_wide_int (buffer, nonzero_bits, UNSIGNED); |
c853f62a JJ |
1803 | } |
1804 | newline_and_indent (buffer, spc); | |
a895a2b8 KV |
1805 | } |
1806 | } | |
1807 | ||
1808 | ||
1809 | /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. | |
1810 | The caller is responsible for calling pp_flush on BUFFER to finalize | |
d09c0e9b | 1811 | pretty printer. If COMMENT is true, print this after #. */ |
a895a2b8 KV |
1812 | |
1813 | static void | |
d09c0e9b JJ |
1814 | dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, bool comment, |
1815 | int flags) | |
a895a2b8 KV |
1816 | { |
1817 | size_t i; | |
1818 | tree lhs = gimple_phi_result (phi); | |
1819 | ||
1820 | if (flags & TDF_ALIAS) | |
1821 | dump_ssaname_info (buffer, lhs, spc); | |
1822 | ||
d09c0e9b JJ |
1823 | if (comment) |
1824 | pp_string (buffer, "# "); | |
1825 | ||
726a989a | 1826 | if (flags & TDF_RAW) |
0498471b CL |
1827 | dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi, |
1828 | gimple_phi_result (phi)); | |
726a989a RB |
1829 | else |
1830 | { | |
f0107145 | 1831 | dump_generic_node (buffer, lhs, spc, flags, false); |
726a989a RB |
1832 | pp_string (buffer, " = PHI <"); |
1833 | } | |
1834 | for (i = 0; i < gimple_phi_num_args (phi); i++) | |
1835 | { | |
f5045c96 AM |
1836 | if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i)) |
1837 | { | |
1838 | expanded_location xloc; | |
1839 | ||
1840 | xloc = expand_location (gimple_phi_arg_location (phi, i)); | |
07838b13 | 1841 | pp_left_bracket (buffer); |
f5045c96 AM |
1842 | if (xloc.file) |
1843 | { | |
1844 | pp_string (buffer, xloc.file); | |
1845 | pp_string (buffer, " : "); | |
1846 | } | |
1847 | pp_decimal_int (buffer, xloc.line); | |
137a1a27 | 1848 | pp_colon (buffer); |
f5045c96 AM |
1849 | pp_decimal_int (buffer, xloc.column); |
1850 | pp_string (buffer, "] "); | |
1851 | } | |
726a989a RB |
1852 | dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags, |
1853 | false); | |
07838b13 | 1854 | pp_left_paren (buffer); |
726a989a | 1855 | pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index); |
07838b13 | 1856 | pp_right_paren (buffer); |
726a989a RB |
1857 | if (i < gimple_phi_num_args (phi) - 1) |
1858 | pp_string (buffer, ", "); | |
1859 | } | |
07838b13 | 1860 | pp_greater (buffer); |
726a989a RB |
1861 | } |
1862 | ||
1863 | ||
1864 | /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces | |
1865 | of indent. FLAGS specifies details to show in the dump (see TDF_* in | |
7ee2468b | 1866 | dumpfile.h). */ |
726a989a RB |
1867 | |
1868 | static void | |
1869 | dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc, | |
1870 | int flags) | |
1871 | { | |
1872 | if (flags & TDF_RAW) | |
1873 | { | |
1874 | dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, | |
1875 | gimple_omp_body (gs)); | |
1876 | dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags); | |
1877 | dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>", | |
1878 | gimple_omp_parallel_child_fn (gs), | |
1879 | gimple_omp_parallel_data_arg (gs)); | |
1880 | } | |
1881 | else | |
1882 | { | |
1883 | gimple_seq body; | |
1884 | pp_string (buffer, "#pragma omp parallel"); | |
1885 | dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags); | |
1886 | if (gimple_omp_parallel_child_fn (gs)) | |
1887 | { | |
1888 | pp_string (buffer, " [child fn: "); | |
1889 | dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs), | |
1890 | spc, flags, false); | |
1891 | pp_string (buffer, " ("); | |
1892 | if (gimple_omp_parallel_data_arg (gs)) | |
1893 | dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs), | |
1894 | spc, flags, false); | |
1895 | else | |
1896 | pp_string (buffer, "???"); | |
1897 | pp_string (buffer, ")]"); | |
1898 | } | |
1899 | body = gimple_omp_body (gs); | |
1900 | if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND) | |
1901 | { | |
1902 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1903 | pp_left_brace (buffer); |
726a989a RB |
1904 | pp_newline (buffer); |
1905 | dump_gimple_seq (buffer, body, spc + 4, flags); | |
1906 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1907 | pp_right_brace (buffer); |
726a989a RB |
1908 | } |
1909 | else if (body) | |
1910 | { | |
1911 | pp_newline (buffer); | |
1912 | dump_gimple_seq (buffer, body, spc + 2, flags); | |
1913 | } | |
1914 | } | |
1915 | } | |
1916 | ||
1917 | ||
1918 | /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces | |
1919 | of indent. FLAGS specifies details to show in the dump (see TDF_* in | |
7ee2468b | 1920 | dumpfile.h). */ |
726a989a RB |
1921 | |
1922 | static void | |
1923 | dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc, | |
1924 | int flags) | |
1925 | { | |
1926 | if (flags & TDF_RAW) | |
1927 | { | |
1928 | dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, | |
1929 | gimple_omp_body (gs)); | |
1930 | dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags); | |
1931 | dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>", | |
1932 | gimple_omp_task_child_fn (gs), | |
1933 | gimple_omp_task_data_arg (gs), | |
1934 | gimple_omp_task_copy_fn (gs), | |
1935 | gimple_omp_task_arg_size (gs), | |
1936 | gimple_omp_task_arg_size (gs)); | |
1937 | } | |
1938 | else | |
1939 | { | |
1940 | gimple_seq body; | |
1941 | pp_string (buffer, "#pragma omp task"); | |
1942 | dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags); | |
1943 | if (gimple_omp_task_child_fn (gs)) | |
1944 | { | |
1945 | pp_string (buffer, " [child fn: "); | |
1946 | dump_generic_node (buffer, gimple_omp_task_child_fn (gs), | |
1947 | spc, flags, false); | |
1948 | pp_string (buffer, " ("); | |
1949 | if (gimple_omp_task_data_arg (gs)) | |
1950 | dump_generic_node (buffer, gimple_omp_task_data_arg (gs), | |
1951 | spc, flags, false); | |
1952 | else | |
1953 | pp_string (buffer, "???"); | |
1954 | pp_string (buffer, ")]"); | |
1955 | } | |
1956 | body = gimple_omp_body (gs); | |
1957 | if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND) | |
1958 | { | |
1959 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1960 | pp_left_brace (buffer); |
726a989a RB |
1961 | pp_newline (buffer); |
1962 | dump_gimple_seq (buffer, body, spc + 4, flags); | |
1963 | newline_and_indent (buffer, spc + 2); | |
07838b13 | 1964 | pp_right_brace (buffer); |
726a989a RB |
1965 | } |
1966 | else if (body) | |
1967 | { | |
1968 | pp_newline (buffer); | |
1969 | dump_gimple_seq (buffer, body, spc + 2, flags); | |
1970 | } | |
1971 | } | |
1972 | } | |
1973 | ||
1974 | ||
1975 | /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC | |
1976 | spaces of indent. FLAGS specifies details to show in the dump (see TDF_* | |
7ee2468b | 1977 | in dumpfile.h). */ |
726a989a RB |
1978 | |
1979 | static void | |
1980 | dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc, | |
1981 | int flags) | |
1982 | { | |
1983 | if (flags & TDF_RAW) | |
1984 | { | |
1985 | dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs, | |
1986 | gimple_omp_atomic_load_lhs (gs), | |
1987 | gimple_omp_atomic_load_rhs (gs)); | |
1988 | } | |
1989 | else | |
1990 | { | |
1991 | pp_string (buffer, "#pragma omp atomic_load"); | |
acf0174b JJ |
1992 | if (gimple_omp_atomic_seq_cst_p (gs)) |
1993 | pp_string (buffer, " seq_cst"); | |
05409788 RH |
1994 | if (gimple_omp_atomic_need_value_p (gs)) |
1995 | pp_string (buffer, " [needed]"); | |
726a989a RB |
1996 | newline_and_indent (buffer, spc + 2); |
1997 | dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs), | |
1998 | spc, flags, false); | |
1999 | pp_space (buffer); | |
07838b13 | 2000 | pp_equal (buffer); |
726a989a | 2001 | pp_space (buffer); |
07838b13 | 2002 | pp_star (buffer); |
726a989a RB |
2003 | dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs), |
2004 | spc, flags, false); | |
2005 | } | |
2006 | } | |
2007 | ||
2008 | /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC | |
2009 | spaces of indent. FLAGS specifies details to show in the dump (see TDF_* | |
7ee2468b | 2010 | in dumpfile.h). */ |
726a989a RB |
2011 | |
2012 | static void | |
2013 | dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc, | |
2014 | int flags) | |
2015 | { | |
2016 | if (flags & TDF_RAW) | |
2017 | { | |
2018 | dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, | |
2019 | gimple_omp_atomic_store_val (gs)); | |
2020 | } | |
2021 | else | |
2022 | { | |
05409788 | 2023 | pp_string (buffer, "#pragma omp atomic_store "); |
acf0174b JJ |
2024 | if (gimple_omp_atomic_seq_cst_p (gs)) |
2025 | pp_string (buffer, "seq_cst "); | |
05409788 RH |
2026 | if (gimple_omp_atomic_need_value_p (gs)) |
2027 | pp_string (buffer, "[needed] "); | |
07838b13 | 2028 | pp_left_paren (buffer); |
726a989a RB |
2029 | dump_generic_node (buffer, gimple_omp_atomic_store_val (gs), |
2030 | spc, flags, false); | |
07838b13 | 2031 | pp_right_paren (buffer); |
726a989a RB |
2032 | } |
2033 | } | |
2034 | ||
726a989a RB |
2035 | |
2036 | /* Dump all the memory operands for statement GS. BUFFER, SPC and | |
b5f47924 | 2037 | FLAGS are as in pp_gimple_stmt_1. */ |
726a989a RB |
2038 | |
2039 | static void | |
2040 | dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags) | |
2041 | { | |
5006671f RG |
2042 | tree vdef = gimple_vdef (gs); |
2043 | tree vuse = gimple_vuse (gs); | |
726a989a | 2044 | |
5006671f | 2045 | if (vdef != NULL_TREE) |
726a989a | 2046 | { |
5006671f RG |
2047 | pp_string (buffer, "# "); |
2048 | dump_generic_node (buffer, vdef, spc + 2, flags, false); | |
2049 | pp_string (buffer, " = VDEF <"); | |
2050 | dump_generic_node (buffer, vuse, spc + 2, flags, false); | |
07838b13 | 2051 | pp_greater (buffer); |
726a989a | 2052 | newline_and_indent (buffer, spc); |
726a989a | 2053 | } |
5006671f | 2054 | else if (vuse != NULL_TREE) |
726a989a | 2055 | { |
5006671f RG |
2056 | pp_string (buffer, "# VUSE <"); |
2057 | dump_generic_node (buffer, vuse, spc + 2, flags, false); | |
07838b13 | 2058 | pp_greater (buffer); |
726a989a | 2059 | newline_and_indent (buffer, spc); |
726a989a RB |
2060 | } |
2061 | } | |
2062 | ||
2063 | ||
b5f47924 | 2064 | /* Print the gimple statement GS on the pretty printer BUFFER, SPC |
726a989a | 2065 | spaces of indent. FLAGS specifies details to show in the dump (see |
c4669594 SB |
2066 | TDF_* in dumpfile.h). The caller is responsible for calling |
2067 | pp_flush on BUFFER to finalize the pretty printer. */ | |
726a989a RB |
2068 | |
2069 | void | |
b5f47924 | 2070 | pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags) |
726a989a RB |
2071 | { |
2072 | if (!gs) | |
2073 | return; | |
2074 | ||
2075 | if (flags & TDF_STMTADDR) | |
2076 | pp_printf (buffer, "<&%p> ", (void *) gs); | |
2077 | ||
2078 | if ((flags & TDF_LINENO) && gimple_has_location (gs)) | |
2079 | { | |
2080 | expanded_location xloc = expand_location (gimple_location (gs)); | |
07838b13 | 2081 | pp_left_bracket (buffer); |
726a989a RB |
2082 | if (xloc.file) |
2083 | { | |
2084 | pp_string (buffer, xloc.file); | |
2085 | pp_string (buffer, " : "); | |
2086 | } | |
2087 | pp_decimal_int (buffer, xloc.line); | |
137a1a27 | 2088 | pp_colon (buffer); |
c2255bc4 | 2089 | pp_decimal_int (buffer, xloc.column); |
726a989a RB |
2090 | pp_string (buffer, "] "); |
2091 | } | |
2092 | ||
cae63f88 DN |
2093 | if (flags & TDF_EH) |
2094 | { | |
1d65f45c RH |
2095 | int lp_nr = lookup_stmt_eh_lp (gs); |
2096 | if (lp_nr > 0) | |
2097 | pp_printf (buffer, "[LP %d] ", lp_nr); | |
2098 | else if (lp_nr < 0) | |
2099 | pp_printf (buffer, "[MNT %d] ", -lp_nr); | |
cae63f88 DN |
2100 | } |
2101 | ||
726a989a RB |
2102 | if ((flags & (TDF_VOPS|TDF_MEMSYMS)) |
2103 | && gimple_has_mem_ops (gs)) | |
2104 | dump_gimple_mem_ops (buffer, gs, spc, flags); | |
2105 | ||
a895a2b8 KV |
2106 | if (gimple_has_lhs (gs) |
2107 | && (flags & TDF_ALIAS)) | |
2108 | dump_ssaname_info (buffer, gimple_get_lhs (gs), spc); | |
f0107145 | 2109 | |
726a989a RB |
2110 | switch (gimple_code (gs)) |
2111 | { | |
2112 | case GIMPLE_ASM: | |
2113 | dump_gimple_asm (buffer, gs, spc, flags); | |
2114 | break; | |
2115 | ||
2116 | case GIMPLE_ASSIGN: | |
2117 | dump_gimple_assign (buffer, gs, spc, flags); | |
2118 | break; | |
2119 | ||
2120 | case GIMPLE_BIND: | |
2121 | dump_gimple_bind (buffer, gs, spc, flags); | |
2122 | break; | |
2123 | ||
2124 | case GIMPLE_CALL: | |
2125 | dump_gimple_call (buffer, gs, spc, flags); | |
2126 | break; | |
2127 | ||
2128 | case GIMPLE_COND: | |
2129 | dump_gimple_cond (buffer, gs, spc, flags); | |
2130 | break; | |
2131 | ||
2132 | case GIMPLE_LABEL: | |
2133 | dump_gimple_label (buffer, gs, spc, flags); | |
2134 | break; | |
2135 | ||
2136 | case GIMPLE_GOTO: | |
2137 | dump_gimple_goto (buffer, gs, spc, flags); | |
2138 | break; | |
2139 | ||
2140 | case GIMPLE_NOP: | |
2141 | pp_string (buffer, "GIMPLE_NOP"); | |
2142 | break; | |
2143 | ||
2144 | case GIMPLE_RETURN: | |
2145 | dump_gimple_return (buffer, gs, spc, flags); | |
2146 | break; | |
2147 | ||
2148 | case GIMPLE_SWITCH: | |
2149 | dump_gimple_switch (buffer, gs, spc, flags); | |
2150 | break; | |
2151 | ||
2152 | case GIMPLE_TRY: | |
2153 | dump_gimple_try (buffer, gs, spc, flags); | |
2154 | break; | |
2155 | ||
2156 | case GIMPLE_PHI: | |
d09c0e9b | 2157 | dump_gimple_phi (buffer, gs, spc, false, flags); |
726a989a RB |
2158 | break; |
2159 | ||
2160 | case GIMPLE_OMP_PARALLEL: | |
2161 | dump_gimple_omp_parallel (buffer, gs, spc, flags); | |
2162 | break; | |
2163 | ||
2164 | case GIMPLE_OMP_TASK: | |
2165 | dump_gimple_omp_task (buffer, gs, spc, flags); | |
2166 | break; | |
2167 | ||
2168 | case GIMPLE_OMP_ATOMIC_LOAD: | |
2169 | dump_gimple_omp_atomic_load (buffer, gs, spc, flags); | |
2170 | ||
2171 | break; | |
2172 | ||
2173 | case GIMPLE_OMP_ATOMIC_STORE: | |
2174 | dump_gimple_omp_atomic_store (buffer, gs, spc, flags); | |
2175 | break; | |
2176 | ||
2177 | case GIMPLE_OMP_FOR: | |
2178 | dump_gimple_omp_for (buffer, gs, spc, flags); | |
2179 | break; | |
2180 | ||
2181 | case GIMPLE_OMP_CONTINUE: | |
2182 | dump_gimple_omp_continue (buffer, gs, spc, flags); | |
2183 | break; | |
2184 | ||
2185 | case GIMPLE_OMP_SINGLE: | |
2186 | dump_gimple_omp_single (buffer, gs, spc, flags); | |
2187 | break; | |
2188 | ||
acf0174b JJ |
2189 | case GIMPLE_OMP_TARGET: |
2190 | dump_gimple_omp_target (buffer, gs, spc, flags); | |
2191 | break; | |
2192 | ||
2193 | case GIMPLE_OMP_TEAMS: | |
2194 | dump_gimple_omp_teams (buffer, gs, spc, flags); | |
2195 | break; | |
2196 | ||
726a989a RB |
2197 | case GIMPLE_OMP_RETURN: |
2198 | dump_gimple_omp_return (buffer, gs, spc, flags); | |
2199 | break; | |
2200 | ||
2201 | case GIMPLE_OMP_SECTIONS: | |
2202 | dump_gimple_omp_sections (buffer, gs, spc, flags); | |
2203 | break; | |
2204 | ||
2205 | case GIMPLE_OMP_SECTIONS_SWITCH: | |
2206 | pp_string (buffer, "GIMPLE_SECTIONS_SWITCH"); | |
2207 | break; | |
2208 | ||
2209 | case GIMPLE_OMP_MASTER: | |
acf0174b | 2210 | case GIMPLE_OMP_TASKGROUP: |
726a989a RB |
2211 | case GIMPLE_OMP_ORDERED: |
2212 | case GIMPLE_OMP_SECTION: | |
2213 | dump_gimple_omp_block (buffer, gs, spc, flags); | |
2214 | break; | |
2215 | ||
2216 | case GIMPLE_OMP_CRITICAL: | |
2217 | dump_gimple_omp_critical (buffer, gs, spc, flags); | |
2218 | break; | |
2219 | ||
726a989a RB |
2220 | case GIMPLE_CATCH: |
2221 | dump_gimple_catch (buffer, gs, spc, flags); | |
2222 | break; | |
2223 | ||
2224 | case GIMPLE_EH_FILTER: | |
2225 | dump_gimple_eh_filter (buffer, gs, spc, flags); | |
2226 | break; | |
2227 | ||
1d65f45c RH |
2228 | case GIMPLE_EH_MUST_NOT_THROW: |
2229 | dump_gimple_eh_must_not_throw (buffer, gs, spc, flags); | |
2230 | break; | |
2231 | ||
0a35513e AH |
2232 | case GIMPLE_EH_ELSE: |
2233 | dump_gimple_eh_else (buffer, gs, spc, flags); | |
2234 | break; | |
2235 | ||
726a989a RB |
2236 | case GIMPLE_RESX: |
2237 | dump_gimple_resx (buffer, gs, spc, flags); | |
2238 | break; | |
2239 | ||
1d65f45c RH |
2240 | case GIMPLE_EH_DISPATCH: |
2241 | dump_gimple_eh_dispatch (buffer, gs, spc, flags); | |
2242 | break; | |
2243 | ||
b5b8b0ac AO |
2244 | case GIMPLE_DEBUG: |
2245 | dump_gimple_debug (buffer, gs, spc, flags); | |
2246 | break; | |
2247 | ||
726a989a RB |
2248 | case GIMPLE_PREDICT: |
2249 | pp_string (buffer, "// predicted "); | |
2250 | if (gimple_predict_outcome (gs)) | |
2251 | pp_string (buffer, "likely by "); | |
2252 | else | |
2253 | pp_string (buffer, "unlikely by "); | |
2254 | pp_string (buffer, predictor_name (gimple_predict_predictor (gs))); | |
2255 | pp_string (buffer, " predictor."); | |
2256 | break; | |
2257 | ||
0a35513e AH |
2258 | case GIMPLE_TRANSACTION: |
2259 | dump_gimple_transaction (buffer, gs, spc, flags); | |
2260 | break; | |
2261 | ||
726a989a RB |
2262 | default: |
2263 | GIMPLE_NIY; | |
2264 | } | |
726a989a RB |
2265 | } |
2266 | ||
2267 | ||
a315c44c | 2268 | /* Dumps header of basic block BB to OUTF indented by INDENT |
726a989a RB |
2269 | spaces and details described by flags. */ |
2270 | ||
2271 | static void | |
a315c44c | 2272 | dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags) |
726a989a | 2273 | { |
726a989a RB |
2274 | if (flags & TDF_BLOCKS) |
2275 | { | |
726a989a RB |
2276 | if (flags & TDF_LINENO) |
2277 | { | |
2278 | gimple_stmt_iterator gsi; | |
a315c44c SB |
2279 | |
2280 | if (flags & TDF_COMMENT) | |
2281 | fputs (";; ", outf); | |
726a989a RB |
2282 | |
2283 | for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) | |
b5b8b0ac AO |
2284 | if (!is_gimple_debug (gsi_stmt (gsi)) |
2285 | && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION) | |
726a989a | 2286 | { |
3a8ebb92 L |
2287 | fprintf (outf, "%*sstarting at line %d", |
2288 | indent, "", get_lineno (gsi_stmt (gsi))); | |
726a989a RB |
2289 | break; |
2290 | } | |
a315c44c SB |
2291 | if (bb->discriminator) |
2292 | fprintf (outf, ", discriminator %i", bb->discriminator); | |
2293 | fputc ('\n', outf); | |
726a989a | 2294 | } |
726a989a RB |
2295 | } |
2296 | else | |
2297 | { | |
a315c44c | 2298 | gimple stmt = first_stmt (bb); |
726a989a | 2299 | if (!stmt || gimple_code (stmt) != GIMPLE_LABEL) |
3a8ebb92 | 2300 | fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index); |
726a989a | 2301 | } |
726a989a RB |
2302 | } |
2303 | ||
2304 | ||
2305 | /* Dumps end of basic block BB to buffer BUFFER indented by INDENT | |
2306 | spaces. */ | |
2307 | ||
2308 | static void | |
c4669594 SB |
2309 | dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED, |
2310 | basic_block bb ATTRIBUTE_UNUSED, | |
2311 | int indent ATTRIBUTE_UNUSED, | |
2312 | int flags ATTRIBUTE_UNUSED) | |
726a989a | 2313 | { |
c4669594 SB |
2314 | /* There is currently no GIMPLE-specific basic block info to dump. */ |
2315 | return; | |
726a989a RB |
2316 | } |
2317 | ||
2318 | ||
2319 | /* Dump PHI nodes of basic block BB to BUFFER with details described | |
2320 | by FLAGS and indented by INDENT spaces. */ | |
2321 | ||
2322 | static void | |
2323 | dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags) | |
2324 | { | |
2325 | gimple_stmt_iterator i; | |
2326 | ||
2327 | for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i)) | |
2328 | { | |
2329 | gimple phi = gsi_stmt (i); | |
ea057359 | 2330 | if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS)) |
726a989a RB |
2331 | { |
2332 | INDENT (indent); | |
d09c0e9b | 2333 | dump_gimple_phi (buffer, phi, indent, true, flags); |
726a989a RB |
2334 | pp_newline (buffer); |
2335 | } | |
2336 | } | |
2337 | } | |
2338 | ||
2339 | ||
2340 | /* Dump jump to basic block BB that is represented implicitly in the cfg | |
2341 | to BUFFER. */ | |
2342 | ||
2343 | static void | |
2344 | pp_cfg_jump (pretty_printer *buffer, basic_block bb) | |
2345 | { | |
2346 | gimple stmt; | |
2347 | ||
2348 | stmt = first_stmt (bb); | |
2349 | ||
2350 | pp_string (buffer, "goto <bb "); | |
2351 | pp_decimal_int (buffer, bb->index); | |
07838b13 | 2352 | pp_greater (buffer); |
726a989a RB |
2353 | if (stmt && gimple_code (stmt) == GIMPLE_LABEL) |
2354 | { | |
2355 | pp_string (buffer, " ("); | |
2356 | dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false); | |
07838b13 | 2357 | pp_right_paren (buffer); |
726a989a RB |
2358 | pp_semicolon (buffer); |
2359 | } | |
2360 | else | |
2361 | pp_semicolon (buffer); | |
2362 | } | |
2363 | ||
2364 | ||
2365 | /* Dump edges represented implicitly in basic block BB to BUFFER, indented | |
2366 | by INDENT spaces, with details given by FLAGS. */ | |
2367 | ||
2368 | static void | |
2369 | dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent, | |
2370 | int flags) | |
2371 | { | |
2372 | edge e; | |
726a989a RB |
2373 | gimple stmt; |
2374 | ||
2375 | stmt = last_stmt (bb); | |
2376 | ||
2377 | if (stmt && gimple_code (stmt) == GIMPLE_COND) | |
2378 | { | |
2379 | edge true_edge, false_edge; | |
2380 | ||
2381 | /* When we are emitting the code or changing CFG, it is possible that | |
2382 | the edges are not yet created. When we are using debug_bb in such | |
2383 | a situation, we do not want it to crash. */ | |
2384 | if (EDGE_COUNT (bb->succs) != 2) | |
2385 | return; | |
2386 | extract_true_false_edges_from_block (bb, &true_edge, &false_edge); | |
2387 | ||
2388 | INDENT (indent + 2); | |
2389 | pp_cfg_jump (buffer, true_edge->dest); | |
2390 | newline_and_indent (buffer, indent); | |
2391 | pp_string (buffer, "else"); | |
2392 | newline_and_indent (buffer, indent + 2); | |
2393 | pp_cfg_jump (buffer, false_edge->dest); | |
2394 | pp_newline (buffer); | |
2395 | return; | |
2396 | } | |
2397 | ||
2398 | /* If there is a fallthru edge, we may need to add an artificial | |
2399 | goto to the dump. */ | |
0fd4b31d | 2400 | e = find_fallthru_edge (bb->succs); |
726a989a RB |
2401 | |
2402 | if (e && e->dest != bb->next_bb) | |
2403 | { | |
2404 | INDENT (indent); | |
2405 | ||
2406 | if ((flags & TDF_LINENO) | |
2407 | && e->goto_locus != UNKNOWN_LOCATION | |
2408 | ) | |
2409 | { | |
2410 | expanded_location goto_xloc; | |
2411 | goto_xloc = expand_location (e->goto_locus); | |
07838b13 | 2412 | pp_left_bracket (buffer); |
726a989a RB |
2413 | if (goto_xloc.file) |
2414 | { | |
2415 | pp_string (buffer, goto_xloc.file); | |
2416 | pp_string (buffer, " : "); | |
2417 | } | |
2418 | pp_decimal_int (buffer, goto_xloc.line); | |
c2255bc4 AH |
2419 | pp_string (buffer, " : "); |
2420 | pp_decimal_int (buffer, goto_xloc.column); | |
726a989a RB |
2421 | pp_string (buffer, "] "); |
2422 | } | |
2423 | ||
2424 | pp_cfg_jump (buffer, e->dest); | |
2425 | pp_newline (buffer); | |
2426 | } | |
2427 | } | |
2428 | ||
2429 | ||
2430 | /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and | |
2431 | indented by INDENT spaces. */ | |
2432 | ||
2433 | static void | |
2434 | gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent, | |
2435 | int flags) | |
2436 | { | |
2437 | gimple_stmt_iterator gsi; | |
2438 | gimple stmt; | |
2439 | int label_indent = indent - 2; | |
2440 | ||
2441 | if (label_indent < 0) | |
2442 | label_indent = 0; | |
2443 | ||
726a989a RB |
2444 | dump_phi_nodes (buffer, bb, indent, flags); |
2445 | ||
2446 | for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) | |
2447 | { | |
2448 | int curr_indent; | |
2449 | ||
2450 | stmt = gsi_stmt (gsi); | |
2451 | ||
2452 | curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent; | |
2453 | ||
2454 | INDENT (curr_indent); | |
b5f47924 | 2455 | pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags); |
f8923f7e | 2456 | pp_newline_and_flush (buffer); |
2eb712b4 MJ |
2457 | gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl)); |
2458 | dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl), | |
c3284718 | 2459 | pp_buffer (buffer)->stream, stmt); |
726a989a RB |
2460 | } |
2461 | ||
2462 | dump_implicit_edges (buffer, bb, indent, flags); | |
3e31cf28 | 2463 | pp_flush (buffer); |
726a989a RB |
2464 | } |
2465 | ||
2466 | ||
2467 | /* Dumps basic block BB to FILE with details described by FLAGS and | |
2468 | indented by INDENT spaces. */ | |
2469 | ||
2470 | void | |
a315c44c | 2471 | gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags) |
726a989a | 2472 | { |
a315c44c | 2473 | dump_gimple_bb_header (file, bb, indent, flags); |
c4669594 SB |
2474 | if (bb->index >= NUM_FIXED_BLOCKS) |
2475 | { | |
b3f80694 | 2476 | pretty_printer buffer; |
b3f80694 GDR |
2477 | pp_needs_newline (&buffer) = true; |
2478 | buffer.buffer->stream = file; | |
c4669594 SB |
2479 | gimple_dump_bb_buff (&buffer, bb, indent, flags); |
2480 | } | |
a315c44c | 2481 | dump_gimple_bb_footer (file, bb, indent, flags); |
726a989a | 2482 | } |
41222ddf SB |
2483 | |
2484 | /* Dumps basic block BB to pretty-printer PP with default dump flags and | |
2485 | no indentation, for use as a label of a DOT graph record-node. | |
2486 | ??? Should just use gimple_dump_bb_buff here, except that value profiling | |
2487 | histogram dumping doesn't know about pretty-printers. */ | |
2488 | ||
2489 | void | |
2490 | gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb) | |
2491 | { | |
2492 | gimple_stmt_iterator gsi; | |
2493 | ||
2494 | pp_printf (pp, "<bb %d>:\n", bb->index); | |
2495 | pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true); | |
2496 | ||
2497 | for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) | |
2498 | { | |
2499 | gimple phi = gsi_stmt (gsi); | |
2500 | if (!virtual_operand_p (gimple_phi_result (phi)) | |
2501 | || (dump_flags & TDF_VOPS)) | |
2502 | { | |
07838b13 | 2503 | pp_bar (pp); |
41222ddf SB |
2504 | pp_write_text_to_stream (pp); |
2505 | pp_string (pp, "# "); | |
2506 | pp_gimple_stmt_1 (pp, phi, 0, dump_flags); | |
2507 | pp_newline (pp); | |
2508 | pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true); | |
2509 | } | |
2510 | } | |
2511 | ||
2512 | for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) | |
2513 | { | |
2514 | gimple stmt = gsi_stmt (gsi); | |
07838b13 | 2515 | pp_bar (pp); |
41222ddf SB |
2516 | pp_write_text_to_stream (pp); |
2517 | pp_gimple_stmt_1 (pp, stmt, 0, dump_flags); | |
2518 | pp_newline (pp); | |
2519 | pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true); | |
2520 | } | |
2521 | dump_implicit_edges (pp, bb, 0, dump_flags); | |
2522 | pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true); | |
2523 | } | |
2524 |