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