1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com> and
5 Diego Novillo <dnovillo@google.com>
7 This file is part of GCC.
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
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
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/>. */
25 #include "coretypes.h"
28 #include "diagnostic.h"
29 #include "tree-pretty-print.h"
30 #include "gimple-pretty-print.h"
32 #include "tree-flow.h"
33 #include "tree-pass.h"
35 #include "value-prof.h"
37 #define INDENT(SPACE) \
38 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
40 static pretty_printer buffer;
41 static bool initialized = false;
43 #define GIMPLE_NIY do_niy (buffer,gs)
45 /* Try to print on BUFFER a default message for the unrecognized
46 gimple statement GS. */
49 do_niy (pretty_printer *buffer, gimple gs)
51 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
52 gimple_code_name[(int) gimple_code (gs)]);
56 /* Initialize the pretty printer on FILE if needed. */
59 maybe_init_pretty_print (FILE *file)
63 pp_construct (&buffer, NULL, 0);
64 pp_needs_newline (&buffer) = true;
68 buffer.buffer->stream = file;
72 /* Emit a newline and SPC indentantion spaces to BUFFER. */
75 newline_and_indent (pretty_printer *buffer, int spc)
82 /* Print the GIMPLE statement GS on stderr. */
85 debug_gimple_stmt (gimple gs)
87 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
88 fprintf (stderr, "\n");
92 /* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
93 FLAGS as in dump_gimple_stmt. */
96 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
98 maybe_init_pretty_print (file);
99 dump_gimple_stmt (&buffer, g, spc, flags);
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
109 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
111 flags |= TDF_RHS_ONLY;
112 maybe_init_pretty_print (file);
113 dump_gimple_stmt (&buffer, g, spc, flags);
117 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion
118 spaces and FLAGS as in dump_gimple_stmt. */
121 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
123 gimple_stmt_iterator i;
125 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
127 gimple gs = gsi_stmt (i);
129 dump_gimple_stmt (buffer, gs, spc, flags);
130 if (!gsi_one_before_end_p (i))
136 /* Dump GIMPLE sequence SEQ to FILE using SPC indentantion spaces and
137 FLAGS as in dump_gimple_stmt. */
140 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
142 maybe_init_pretty_print (file);
143 dump_gimple_seq (&buffer, seq, spc, flags);
148 /* Print the GIMPLE sequence SEQ on stderr. */
151 debug_gimple_seq (gimple_seq seq)
153 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
157 /* A simple helper to pretty-print some of the gimple tuples in the printf
158 style. The format modifiers are preceeded by '%' and are:
159 'G' - outputs a string corresponding to the code of the given gimple,
160 'S' - outputs a gimple_seq with indent of spc + 2,
161 'T' - outputs the tree t,
162 'd' - outputs an int as a decimal,
163 's' - outputs a string,
164 'n' - outputs a newline,
165 '+' - increases indent by 2 then outputs a newline,
166 '-' - decreases indent by 2 then outputs a newline. */
169 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
170 const char *fmt, ...)
176 va_start (args, fmt);
177 for (c = fmt; *c; c++)
187 g = va_arg (args, gimple);
188 tmp = gimple_code_name[gimple_code (g)];
189 pp_string (buffer, tmp);
193 seq = va_arg (args, gimple_seq);
195 dump_gimple_seq (buffer, seq, spc + 2, flags);
196 newline_and_indent (buffer, spc);
200 t = va_arg (args, tree);
202 pp_string (buffer, "NULL");
204 dump_generic_node (buffer, t, spc, flags, false);
208 pp_decimal_int (buffer, va_arg (args, int));
212 pp_string (buffer, va_arg (args, char *));
216 newline_and_indent (buffer, spc);
221 newline_and_indent (buffer, spc);
226 newline_and_indent (buffer, spc);
234 pp_character (buffer, *c);
240 /* Helper for dump_gimple_assign. Print the unary RHS of the
241 assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */
244 dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
246 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
247 tree lhs = gimple_assign_lhs (gs);
248 tree rhs = gimple_assign_rhs1 (gs);
252 case VIEW_CONVERT_EXPR:
254 dump_generic_node (buffer, rhs, spc, flags, false);
257 case FIXED_CONVERT_EXPR:
258 case ADDR_SPACE_CONVERT_EXPR:
262 pp_character (buffer, '(');
263 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
264 pp_string (buffer, ") ");
265 if (op_prio (rhs) < op_code_prio (rhs_code))
267 pp_character (buffer, '(');
268 dump_generic_node (buffer, rhs, spc, flags, false);
269 pp_character (buffer, ')');
272 dump_generic_node (buffer, rhs, spc, flags, false);
276 pp_string (buffer, "((");
277 dump_generic_node (buffer, rhs, spc, flags, false);
278 pp_string (buffer, "))");
282 pp_string (buffer, "ABS_EXPR <");
283 dump_generic_node (buffer, rhs, spc, flags, false);
284 pp_character (buffer, '>');
288 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
289 || TREE_CODE_CLASS (rhs_code) == tcc_constant
290 || TREE_CODE_CLASS (rhs_code) == tcc_reference
291 || rhs_code == SSA_NAME
292 || rhs_code == ADDR_EXPR
293 || rhs_code == CONSTRUCTOR)
295 dump_generic_node (buffer, rhs, spc, flags, false);
298 else if (rhs_code == BIT_NOT_EXPR)
299 pp_character (buffer, '~');
300 else if (rhs_code == TRUTH_NOT_EXPR)
301 pp_character (buffer, '!');
302 else if (rhs_code == NEGATE_EXPR)
303 pp_character (buffer, '-');
306 pp_character (buffer, '[');
307 pp_string (buffer, tree_code_name [rhs_code]);
308 pp_string (buffer, "] ");
311 if (op_prio (rhs) < op_code_prio (rhs_code))
313 pp_character (buffer, '(');
314 dump_generic_node (buffer, rhs, spc, flags, false);
315 pp_character (buffer, ')');
318 dump_generic_node (buffer, rhs, spc, flags, false);
324 /* Helper for dump_gimple_assign. Print the binary RHS of the
325 assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */
328 dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
331 enum tree_code code = gimple_assign_rhs_code (gs);
337 case VEC_WIDEN_MULT_HI_EXPR:
338 case VEC_WIDEN_MULT_LO_EXPR:
339 case VEC_PACK_TRUNC_EXPR:
340 case VEC_PACK_SAT_EXPR:
341 case VEC_PACK_FIX_TRUNC_EXPR:
342 case VEC_EXTRACT_EVEN_EXPR:
343 case VEC_EXTRACT_ODD_EXPR:
344 case VEC_INTERLEAVE_HIGH_EXPR:
345 case VEC_INTERLEAVE_LOW_EXPR:
346 for (p = tree_code_name [(int) code]; *p; p++)
347 pp_character (buffer, TOUPPER (*p));
348 pp_string (buffer, " <");
349 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
350 pp_string (buffer, ", ");
351 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
352 pp_character (buffer, '>');
356 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
358 pp_character (buffer, '(');
359 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
361 pp_character (buffer, ')');
364 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
366 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
368 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
370 pp_character (buffer, '(');
371 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
373 pp_character (buffer, ')');
376 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
380 /* Helper for dump_gimple_assign. Print the ternary RHS of the
381 assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */
384 dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
387 enum tree_code code = gimple_assign_rhs_code (gs);
390 case WIDEN_MULT_PLUS_EXPR:
391 case WIDEN_MULT_MINUS_EXPR:
392 for (p = tree_code_name [(int) code]; *p; p++)
393 pp_character (buffer, TOUPPER (*p));
394 pp_string (buffer, " <");
395 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
396 pp_string (buffer, ", ");
397 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
398 pp_string (buffer, ", ");
399 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
400 pp_character (buffer, '>');
404 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
405 pp_string (buffer, " * ");
406 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
407 pp_string (buffer, " + ");
408 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
412 pp_string (buffer, "DOT_PROD_EXPR <");
413 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
414 pp_string (buffer, ", ");
415 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
416 pp_string (buffer, ", ");
417 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
418 pp_string (buffer, ">");
421 case REALIGN_LOAD_EXPR:
422 pp_string (buffer, "REALIGN_LOAD <");
423 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
424 pp_string (buffer, ", ");
425 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
426 pp_string (buffer, ", ");
427 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
428 pp_string (buffer, ">");
437 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
441 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
446 if (gimple_num_ops (gs) == 2)
448 else if (gimple_num_ops (gs) == 3)
449 last = gimple_assign_rhs2 (gs);
453 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T>", gs,
454 tree_code_name[gimple_assign_rhs_code (gs)],
455 gimple_assign_lhs (gs), gimple_assign_rhs1 (gs), last);
459 if (!(flags & TDF_RHS_ONLY))
461 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
463 pp_character (buffer, '=');
465 if (gimple_assign_nontemporal_move_p (gs))
466 pp_string (buffer, "{nt}");
468 if (gimple_has_volatile_ops (gs))
469 pp_string (buffer, "{v}");
474 if (gimple_num_ops (gs) == 2)
475 dump_unary_rhs (buffer, gs, spc, flags);
476 else if (gimple_num_ops (gs) == 3)
477 dump_binary_rhs (buffer, gs, spc, flags);
478 else if (gimple_num_ops (gs) == 4)
479 dump_ternary_rhs (buffer, gs, spc, flags);
482 if (!(flags & TDF_RHS_ONLY))
483 pp_semicolon(buffer);
488 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
492 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
496 t = gimple_return_retval (gs);
498 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
501 pp_string (buffer, "return");
505 dump_generic_node (buffer, t, spc, flags, false);
507 pp_semicolon (buffer);
512 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
516 dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags)
520 for (i = 0; i < gimple_call_num_args (gs); i++)
522 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
523 if (i < gimple_call_num_args (gs) - 1)
524 pp_string (buffer, ", ");
527 if (gimple_call_va_arg_pack_p (gs))
529 if (gimple_call_num_args (gs) > 0)
531 pp_character (buffer, ',');
535 pp_string (buffer, "__builtin_va_arg_pack ()");
539 /* Dump the points-to solution *PT to BUFFER. */
542 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
546 pp_string (buffer, "anything ");
550 pp_string (buffer, "nonlocal ");
552 pp_string (buffer, "escaped ");
554 pp_string (buffer, "unit-escaped ");
556 pp_string (buffer, "null ");
558 && !bitmap_empty_p (pt->vars))
562 pp_string (buffer, "{ ");
563 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
565 tree var = referenced_var_lookup (cfun, i);
568 dump_generic_node (buffer, var, 0, dump_flags, false);
569 if (DECL_PT_UID (var) != DECL_UID (var))
571 pp_string (buffer, "ptD.");
572 pp_decimal_int (buffer, DECL_PT_UID (var));
577 pp_string (buffer, "D.");
578 pp_decimal_int (buffer, i);
580 pp_character (buffer, ' ');
582 pp_character (buffer, '}');
583 if (pt->vars_contains_global)
584 pp_string (buffer, " (glob)");
585 if (pt->vars_contains_restrict)
586 pp_string (buffer, " (restr)");
590 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
594 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
596 tree lhs = gimple_call_lhs (gs);
598 if (flags & TDF_ALIAS)
600 struct pt_solution *pt;
601 pt = gimple_call_use_set (gs);
602 if (!pt_solution_empty_p (pt))
604 pp_string (buffer, "# USE = ");
605 pp_points_to_solution (buffer, pt);
606 newline_and_indent (buffer, spc);
608 pt = gimple_call_clobber_set (gs);
609 if (!pt_solution_empty_p (pt))
611 pp_string (buffer, "# CLB = ");
612 pp_points_to_solution (buffer, pt);
613 newline_and_indent (buffer, spc);
619 if (gimple_call_internal_p (gs))
620 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
621 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
623 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T",
624 gs, gimple_call_fn (gs), lhs);
625 if (gimple_call_num_args (gs) > 0)
627 pp_string (buffer, ", ");
628 dump_gimple_call_args (buffer, gs, flags);
630 pp_character (buffer, '>');
634 if (lhs && !(flags & TDF_RHS_ONLY))
636 dump_generic_node (buffer, lhs, spc, flags, false);
637 pp_string (buffer, " =");
639 if (gimple_has_volatile_ops (gs))
640 pp_string (buffer, "{v}");
644 if (gimple_call_internal_p (gs))
645 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
647 print_call_name (buffer, gimple_call_fn (gs), flags);
648 pp_string (buffer, " (");
649 dump_gimple_call_args (buffer, gs, flags);
650 pp_character (buffer, ')');
651 if (!(flags & TDF_RHS_ONLY))
652 pp_semicolon (buffer);
655 if (gimple_call_chain (gs))
657 pp_string (buffer, " [static-chain: ");
658 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
659 pp_character (buffer, ']');
662 if (gimple_call_return_slot_opt_p (gs))
663 pp_string (buffer, " [return slot optimization]");
665 if (gimple_call_tail_p (gs))
666 pp_string (buffer, " [tail call]");
670 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
674 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
678 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
680 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
681 gimple_switch_index (gs));
684 pp_string (buffer, "switch (");
685 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
686 pp_string (buffer, ") <");
689 for (i = 0; i < gimple_switch_num_labels (gs); i++)
691 tree case_label = gimple_switch_label (gs, i);
692 if (case_label == NULL_TREE)
695 dump_generic_node (buffer, case_label, spc, flags, false);
696 pp_character (buffer, ' ');
697 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
698 if (i < gimple_switch_num_labels (gs) - 1)
699 pp_string (buffer, ", ");
701 pp_character (buffer, '>');
705 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
709 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
712 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
713 tree_code_name [gimple_cond_code (gs)],
714 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
715 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
718 if (!(flags & TDF_RHS_ONLY))
719 pp_string (buffer, "if (");
720 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
722 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
724 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
725 if (!(flags & TDF_RHS_ONLY))
727 pp_character (buffer, ')');
729 if (gimple_cond_true_label (gs))
731 pp_string (buffer, " goto ");
732 dump_generic_node (buffer, gimple_cond_true_label (gs),
734 pp_semicolon (buffer);
736 if (gimple_cond_false_label (gs))
738 pp_string (buffer, " else goto ");
739 dump_generic_node (buffer, gimple_cond_false_label (gs),
741 pp_semicolon (buffer);
748 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
749 spaces of indent. FLAGS specifies details to show in the dump (see
750 TDF_* in tree-pass.h). */
753 dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
755 tree label = gimple_label_label (gs);
757 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
760 dump_generic_node (buffer, label, spc, flags, false);
761 pp_character (buffer, ':');
763 if (DECL_NONLOCAL (label))
764 pp_string (buffer, " [non-local]");
765 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
766 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
769 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
770 spaces of indent. FLAGS specifies details to show in the dump (see
771 TDF_* in tree-pass.h). */
774 dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
776 tree label = gimple_goto_dest (gs);
778 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
780 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
784 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
785 spaces of indent. FLAGS specifies details to show in the dump (see
786 TDF_* in tree-pass.h). */
789 dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
792 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
794 pp_character (buffer, '{');
795 if (!(flags & TDF_SLIM))
799 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
801 newline_and_indent (buffer, 2);
802 print_declaration (buffer, var, spc, flags);
804 if (gimple_bind_vars (gs))
808 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
809 newline_and_indent (buffer, spc);
811 pp_character (buffer, '>');
813 pp_character (buffer, '}');
817 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
818 indent. FLAGS specifies details to show in the dump (see TDF_* in
822 dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
827 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
828 type = "GIMPLE_TRY_CATCH";
829 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
830 type = "GIMPLE_TRY_FINALLY";
832 type = "UNKNOWN GIMPLE_TRY";
833 dump_gimple_fmt (buffer, spc, flags,
834 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
835 gimple_try_eval (gs), gimple_try_cleanup (gs));
839 pp_string (buffer, "try");
840 newline_and_indent (buffer, spc + 2);
841 pp_character (buffer, '{');
844 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
845 newline_and_indent (buffer, spc + 2);
846 pp_character (buffer, '}');
848 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
850 newline_and_indent (buffer, spc);
851 pp_string (buffer, "catch");
852 newline_and_indent (buffer, spc + 2);
853 pp_character (buffer, '{');
855 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
857 newline_and_indent (buffer, spc);
858 pp_string (buffer, "finally");
859 newline_and_indent (buffer, spc + 2);
860 pp_character (buffer, '{');
863 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
866 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
867 newline_and_indent (buffer, spc + 2);
868 pp_character (buffer, '}');
873 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
874 indent. FLAGS specifies details to show in the dump (see TDF_* in
878 dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
881 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
882 gimple_catch_types (gs), gimple_catch_handler (gs));
884 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
885 gimple_catch_types (gs), gimple_catch_handler (gs));
889 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
890 indent. FLAGS specifies details to show in the dump (see TDF_* in
894 dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
897 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
898 gimple_eh_filter_types (gs),
899 gimple_eh_filter_failure (gs));
901 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
902 gimple_eh_filter_types (gs),
903 gimple_eh_filter_failure (gs));
907 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
910 dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
914 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
915 gimple_eh_must_not_throw_fndecl (gs));
917 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
918 gimple_eh_must_not_throw_fndecl (gs));
922 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
923 indent. FLAGS specifies details to show in the dump (see TDF_* in
927 dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
930 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
931 gimple_resx_region (gs));
933 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
936 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
939 dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
942 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
943 gimple_eh_dispatch_region (gs));
945 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
946 gimple_eh_dispatch_region (gs));
949 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
950 of indent. FLAGS specifies details to show in the dump (see TDF_*
954 dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
956 switch (gs->gsbase.subcode)
958 case GIMPLE_DEBUG_BIND:
960 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
961 gimple_debug_bind_get_var (gs),
962 gimple_debug_bind_get_value (gs));
964 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
965 gimple_debug_bind_get_var (gs),
966 gimple_debug_bind_get_value (gs));
974 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
976 dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
982 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
983 gimple_omp_body (gs));
984 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
985 dump_gimple_fmt (buffer, spc, flags, " >,");
986 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
987 dump_gimple_fmt (buffer, spc, flags,
988 "%+%T, %T, %T, %s, %T,%n",
989 gimple_omp_for_index (gs, i),
990 gimple_omp_for_initial (gs, i),
991 gimple_omp_for_final (gs, i),
992 tree_code_name[gimple_omp_for_cond (gs, i)],
993 gimple_omp_for_incr (gs, i));
994 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
995 gimple_omp_for_pre_body (gs));
999 pp_string (buffer, "#pragma omp for");
1000 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1001 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1005 newline_and_indent (buffer, spc);
1006 pp_string (buffer, "for (");
1007 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1009 pp_string (buffer, " = ");
1010 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1012 pp_string (buffer, "; ");
1014 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1017 switch (gimple_omp_for_cond (gs, i))
1020 pp_character (buffer, '<');
1023 pp_character (buffer, '>');
1026 pp_string (buffer, "<=");
1029 pp_string (buffer, ">=");
1035 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1037 pp_string (buffer, "; ");
1039 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1041 pp_string (buffer, " = ");
1042 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1044 pp_character (buffer, ')');
1047 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1049 newline_and_indent (buffer, spc + 2);
1050 pp_character (buffer, '{');
1051 pp_newline (buffer);
1052 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1053 newline_and_indent (buffer, spc + 2);
1054 pp_character (buffer, '}');
1059 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1062 dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags)
1064 if (flags & TDF_RAW)
1066 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1067 gimple_omp_continue_control_def (gs),
1068 gimple_omp_continue_control_use (gs));
1072 pp_string (buffer, "#pragma omp continue (");
1073 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1075 pp_character (buffer, ',');
1077 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1079 pp_character (buffer, ')');
1083 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1086 dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, int flags)
1088 if (flags & TDF_RAW)
1090 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1091 gimple_omp_body (gs));
1092 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1093 dump_gimple_fmt (buffer, spc, flags, " >");
1097 pp_string (buffer, "#pragma omp single");
1098 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1099 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1101 newline_and_indent (buffer, spc + 2);
1102 pp_character (buffer, '{');
1103 pp_newline (buffer);
1104 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1105 newline_and_indent (buffer, spc + 2);
1106 pp_character (buffer, '}');
1111 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1114 dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
1117 if (flags & TDF_RAW)
1119 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1120 gimple_omp_body (gs));
1121 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1122 dump_gimple_fmt (buffer, spc, flags, " >");
1126 pp_string (buffer, "#pragma omp sections");
1127 if (gimple_omp_sections_control (gs))
1129 pp_string (buffer, " <");
1130 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1132 pp_character (buffer, '>');
1134 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1135 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1137 newline_and_indent (buffer, spc + 2);
1138 pp_character (buffer, '{');
1139 pp_newline (buffer);
1140 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1141 newline_and_indent (buffer, spc + 2);
1142 pp_character (buffer, '}');
1147 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the pretty_printer
1151 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1153 if (flags & TDF_RAW)
1154 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1155 gimple_omp_body (gs));
1158 switch (gimple_code (gs))
1160 case GIMPLE_OMP_MASTER:
1161 pp_string (buffer, "#pragma omp master");
1163 case GIMPLE_OMP_ORDERED:
1164 pp_string (buffer, "#pragma omp ordered");
1166 case GIMPLE_OMP_SECTION:
1167 pp_string (buffer, "#pragma omp section");
1172 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1174 newline_and_indent (buffer, spc + 2);
1175 pp_character (buffer, '{');
1176 pp_newline (buffer);
1177 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1178 newline_and_indent (buffer, spc + 2);
1179 pp_character (buffer, '}');
1184 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1187 dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
1190 if (flags & TDF_RAW)
1191 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1192 gimple_omp_body (gs));
1195 pp_string (buffer, "#pragma omp critical");
1196 if (gimple_omp_critical_name (gs))
1198 pp_string (buffer, " (");
1199 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1201 pp_character (buffer, ')');
1203 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1205 newline_and_indent (buffer, spc + 2);
1206 pp_character (buffer, '{');
1207 pp_newline (buffer);
1208 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1209 newline_and_indent (buffer, spc + 2);
1210 pp_character (buffer, '}');
1215 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1218 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1220 if (flags & TDF_RAW)
1222 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d>", gs,
1223 (int) gimple_omp_return_nowait_p (gs));
1227 pp_string (buffer, "#pragma omp return");
1228 if (gimple_omp_return_nowait_p (gs))
1229 pp_string (buffer, "(nowait)");
1233 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1234 indent. FLAGS specifies details to show in the dump (see TDF_* in
1238 dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
1240 unsigned int i, n, f, fields;
1242 if (flags & TDF_RAW)
1244 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1245 gimple_asm_string (gs));
1247 n = gimple_asm_noutputs (gs);
1250 newline_and_indent (buffer, spc + 2);
1251 pp_string (buffer, "OUTPUT: ");
1252 for (i = 0; i < n; i++)
1254 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1257 pp_string (buffer, ", ");
1261 n = gimple_asm_ninputs (gs);
1264 newline_and_indent (buffer, spc + 2);
1265 pp_string (buffer, "INPUT: ");
1266 for (i = 0; i < n; i++)
1268 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1271 pp_string (buffer, ", ");
1275 n = gimple_asm_nclobbers (gs);
1278 newline_and_indent (buffer, spc + 2);
1279 pp_string (buffer, "CLOBBER: ");
1280 for (i = 0; i < n; i++)
1282 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1285 pp_string (buffer, ", ");
1289 n = gimple_asm_nlabels (gs);
1292 newline_and_indent (buffer, spc + 2);
1293 pp_string (buffer, "LABEL: ");
1294 for (i = 0; i < n; i++)
1296 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1299 pp_string (buffer, ", ");
1303 newline_and_indent (buffer, spc);
1304 pp_character (buffer, '>');
1308 pp_string (buffer, "__asm__");
1309 if (gimple_asm_volatile_p (gs))
1310 pp_string (buffer, " __volatile__");
1311 if (gimple_asm_nlabels (gs))
1312 pp_string (buffer, " goto");
1313 pp_string (buffer, "(\"");
1314 pp_string (buffer, gimple_asm_string (gs));
1315 pp_string (buffer, "\"");
1317 if (gimple_asm_nlabels (gs))
1319 else if (gimple_asm_nclobbers (gs))
1321 else if (gimple_asm_ninputs (gs))
1323 else if (gimple_asm_noutputs (gs))
1328 for (f = 0; f < fields; ++f)
1330 pp_string (buffer, " : ");
1335 n = gimple_asm_noutputs (gs);
1336 for (i = 0; i < n; i++)
1338 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1341 pp_string (buffer, ", ");
1346 n = gimple_asm_ninputs (gs);
1347 for (i = 0; i < n; i++)
1349 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1352 pp_string (buffer, ", ");
1357 n = gimple_asm_nclobbers (gs);
1358 for (i = 0; i < n; i++)
1360 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1363 pp_string (buffer, ", ");
1368 n = gimple_asm_nlabels (gs);
1369 for (i = 0; i < n; i++)
1371 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1374 pp_string (buffer, ", ");
1383 pp_string (buffer, ");");
1388 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in
1389 dump_gimple_stmt. */
1392 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags)
1395 tree lhs = gimple_phi_result (phi);
1397 if (flags & TDF_ALIAS
1398 && POINTER_TYPE_P (TREE_TYPE (lhs))
1399 && SSA_NAME_PTR_INFO (lhs))
1401 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
1402 pp_string (buffer, "PT = ");
1403 pp_points_to_solution (buffer, &pi->pt);
1404 newline_and_indent (buffer, spc);
1406 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u",
1407 pi->align, pi->misalign);
1408 newline_and_indent (buffer, spc);
1409 pp_string (buffer, "# ");
1412 if (flags & TDF_RAW)
1413 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1414 gimple_phi_result (phi));
1417 dump_generic_node (buffer, lhs, spc, flags, false);
1418 pp_string (buffer, " = PHI <");
1420 for (i = 0; i < gimple_phi_num_args (phi); i++)
1422 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1424 expanded_location xloc;
1426 xloc = expand_location (gimple_phi_arg_location (phi, i));
1427 pp_character (buffer, '[');
1430 pp_string (buffer, xloc.file);
1431 pp_string (buffer, " : ");
1433 pp_decimal_int (buffer, xloc.line);
1434 pp_string (buffer, ":");
1435 pp_decimal_int (buffer, xloc.column);
1436 pp_string (buffer, "] ");
1438 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1440 pp_character (buffer, '(');
1441 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1442 pp_character (buffer, ')');
1443 if (i < gimple_phi_num_args (phi) - 1)
1444 pp_string (buffer, ", ");
1446 pp_character (buffer, '>');
1450 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1451 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1455 dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1458 if (flags & TDF_RAW)
1460 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1461 gimple_omp_body (gs));
1462 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1463 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1464 gimple_omp_parallel_child_fn (gs),
1465 gimple_omp_parallel_data_arg (gs));
1470 pp_string (buffer, "#pragma omp parallel");
1471 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1472 if (gimple_omp_parallel_child_fn (gs))
1474 pp_string (buffer, " [child fn: ");
1475 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1477 pp_string (buffer, " (");
1478 if (gimple_omp_parallel_data_arg (gs))
1479 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1482 pp_string (buffer, "???");
1483 pp_string (buffer, ")]");
1485 body = gimple_omp_body (gs);
1486 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1488 newline_and_indent (buffer, spc + 2);
1489 pp_character (buffer, '{');
1490 pp_newline (buffer);
1491 dump_gimple_seq (buffer, body, spc + 4, flags);
1492 newline_and_indent (buffer, spc + 2);
1493 pp_character (buffer, '}');
1497 pp_newline (buffer);
1498 dump_gimple_seq (buffer, body, spc + 2, flags);
1504 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1505 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1509 dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
1512 if (flags & TDF_RAW)
1514 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1515 gimple_omp_body (gs));
1516 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1517 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1518 gimple_omp_task_child_fn (gs),
1519 gimple_omp_task_data_arg (gs),
1520 gimple_omp_task_copy_fn (gs),
1521 gimple_omp_task_arg_size (gs),
1522 gimple_omp_task_arg_size (gs));
1527 pp_string (buffer, "#pragma omp task");
1528 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1529 if (gimple_omp_task_child_fn (gs))
1531 pp_string (buffer, " [child fn: ");
1532 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1534 pp_string (buffer, " (");
1535 if (gimple_omp_task_data_arg (gs))
1536 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1539 pp_string (buffer, "???");
1540 pp_string (buffer, ")]");
1542 body = gimple_omp_body (gs);
1543 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1545 newline_and_indent (buffer, spc + 2);
1546 pp_character (buffer, '{');
1547 pp_newline (buffer);
1548 dump_gimple_seq (buffer, body, spc + 4, flags);
1549 newline_and_indent (buffer, spc + 2);
1550 pp_character (buffer, '}');
1554 pp_newline (buffer);
1555 dump_gimple_seq (buffer, body, spc + 2, flags);
1561 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1562 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1566 dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
1569 if (flags & TDF_RAW)
1571 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1572 gimple_omp_atomic_load_lhs (gs),
1573 gimple_omp_atomic_load_rhs (gs));
1577 pp_string (buffer, "#pragma omp atomic_load");
1578 newline_and_indent (buffer, spc + 2);
1579 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
1582 pp_character (buffer, '=');
1584 pp_character (buffer, '*');
1585 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
1590 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1591 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1595 dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
1598 if (flags & TDF_RAW)
1600 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1601 gimple_omp_atomic_store_val (gs));
1605 pp_string (buffer, "#pragma omp atomic_store (");
1606 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
1608 pp_character (buffer, ')');
1613 /* Dump all the memory operands for statement GS. BUFFER, SPC and
1614 FLAGS are as in dump_gimple_stmt. */
1617 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
1619 tree vdef = gimple_vdef (gs);
1620 tree vuse = gimple_vuse (gs);
1622 if (!ssa_operands_active () || !gimple_references_memory_p (gs))
1625 if (vdef != NULL_TREE)
1627 pp_string (buffer, "# ");
1628 dump_generic_node (buffer, vdef, spc + 2, flags, false);
1629 pp_string (buffer, " = VDEF <");
1630 dump_generic_node (buffer, vuse, spc + 2, flags, false);
1631 pp_character (buffer, '>');
1632 newline_and_indent (buffer, spc);
1634 else if (vuse != NULL_TREE)
1636 pp_string (buffer, "# VUSE <");
1637 dump_generic_node (buffer, vuse, spc + 2, flags, false);
1638 pp_character (buffer, '>');
1639 newline_and_indent (buffer, spc);
1644 /* Dump the gimple statement GS on the pretty printer BUFFER, SPC
1645 spaces of indent. FLAGS specifies details to show in the dump (see
1646 TDF_* in tree-pass.h). */
1649 dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
1654 if (flags & TDF_STMTADDR)
1655 pp_printf (buffer, "<&%p> ", (void *) gs);
1657 if ((flags & TDF_LINENO) && gimple_has_location (gs))
1659 expanded_location xloc = expand_location (gimple_location (gs));
1660 pp_character (buffer, '[');
1663 pp_string (buffer, xloc.file);
1664 pp_string (buffer, " : ");
1666 pp_decimal_int (buffer, xloc.line);
1667 pp_string (buffer, ":");
1668 pp_decimal_int (buffer, xloc.column);
1669 pp_string (buffer, "] ");
1674 int lp_nr = lookup_stmt_eh_lp (gs);
1676 pp_printf (buffer, "[LP %d] ", lp_nr);
1678 pp_printf (buffer, "[MNT %d] ", -lp_nr);
1681 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
1682 && gimple_has_mem_ops (gs))
1683 dump_gimple_mem_ops (buffer, gs, spc, flags);
1685 if ((flags & TDF_ALIAS)
1686 && gimple_has_lhs (gs))
1688 tree lhs = gimple_get_lhs (gs);
1689 if (TREE_CODE (lhs) == SSA_NAME
1690 && POINTER_TYPE_P (TREE_TYPE (lhs))
1691 && SSA_NAME_PTR_INFO (lhs))
1693 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
1694 pp_string (buffer, "# PT = ");
1695 pp_points_to_solution (buffer, &pi->pt);
1696 newline_and_indent (buffer, spc);
1699 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u",
1700 pi->align, pi->misalign);
1701 newline_and_indent (buffer, spc);
1706 switch (gimple_code (gs))
1709 dump_gimple_asm (buffer, gs, spc, flags);
1713 dump_gimple_assign (buffer, gs, spc, flags);
1717 dump_gimple_bind (buffer, gs, spc, flags);
1721 dump_gimple_call (buffer, gs, spc, flags);
1725 dump_gimple_cond (buffer, gs, spc, flags);
1729 dump_gimple_label (buffer, gs, spc, flags);
1733 dump_gimple_goto (buffer, gs, spc, flags);
1737 pp_string (buffer, "GIMPLE_NOP");
1741 dump_gimple_return (buffer, gs, spc, flags);
1745 dump_gimple_switch (buffer, gs, spc, flags);
1749 dump_gimple_try (buffer, gs, spc, flags);
1753 dump_gimple_phi (buffer, gs, spc, flags);
1756 case GIMPLE_OMP_PARALLEL:
1757 dump_gimple_omp_parallel (buffer, gs, spc, flags);
1760 case GIMPLE_OMP_TASK:
1761 dump_gimple_omp_task (buffer, gs, spc, flags);
1764 case GIMPLE_OMP_ATOMIC_LOAD:
1765 dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
1769 case GIMPLE_OMP_ATOMIC_STORE:
1770 dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
1773 case GIMPLE_OMP_FOR:
1774 dump_gimple_omp_for (buffer, gs, spc, flags);
1777 case GIMPLE_OMP_CONTINUE:
1778 dump_gimple_omp_continue (buffer, gs, spc, flags);
1781 case GIMPLE_OMP_SINGLE:
1782 dump_gimple_omp_single (buffer, gs, spc, flags);
1785 case GIMPLE_OMP_RETURN:
1786 dump_gimple_omp_return (buffer, gs, spc, flags);
1789 case GIMPLE_OMP_SECTIONS:
1790 dump_gimple_omp_sections (buffer, gs, spc, flags);
1793 case GIMPLE_OMP_SECTIONS_SWITCH:
1794 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
1797 case GIMPLE_OMP_MASTER:
1798 case GIMPLE_OMP_ORDERED:
1799 case GIMPLE_OMP_SECTION:
1800 dump_gimple_omp_block (buffer, gs, spc, flags);
1803 case GIMPLE_OMP_CRITICAL:
1804 dump_gimple_omp_critical (buffer, gs, spc, flags);
1808 dump_gimple_catch (buffer, gs, spc, flags);
1811 case GIMPLE_EH_FILTER:
1812 dump_gimple_eh_filter (buffer, gs, spc, flags);
1815 case GIMPLE_EH_MUST_NOT_THROW:
1816 dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
1820 dump_gimple_resx (buffer, gs, spc, flags);
1823 case GIMPLE_EH_DISPATCH:
1824 dump_gimple_eh_dispatch (buffer, gs, spc, flags);
1828 dump_gimple_debug (buffer, gs, spc, flags);
1831 case GIMPLE_PREDICT:
1832 pp_string (buffer, "// predicted ");
1833 if (gimple_predict_outcome (gs))
1834 pp_string (buffer, "likely by ");
1836 pp_string (buffer, "unlikely by ");
1837 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
1838 pp_string (buffer, " predictor.");
1845 /* If we're building a diagnostic, the formatted text will be
1846 written into BUFFER's stream by the caller; otherwise, write it
1848 if (!(flags & TDF_DIAGNOSTIC))
1849 pp_write_text_to_stream (buffer);
1853 /* Dumps header of basic block BB to buffer BUFFER indented by INDENT
1854 spaces and details described by flags. */
1857 dump_bb_header (pretty_printer *buffer, basic_block bb, int indent, int flags)
1863 if (flags & TDF_BLOCKS)
1866 pp_string (buffer, "# BLOCK ");
1867 pp_decimal_int (buffer, bb->index);
1870 pp_string (buffer, " freq:");
1871 pp_decimal_int (buffer, bb->frequency);
1875 pp_string (buffer, " count:");
1876 pp_widest_integer (buffer, bb->count);
1879 if (flags & TDF_LINENO)
1881 gimple_stmt_iterator gsi;
1883 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
1884 if (!is_gimple_debug (gsi_stmt (gsi))
1885 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
1887 pp_string (buffer, ", starting at line ");
1888 pp_decimal_int (buffer, get_lineno (gsi_stmt (gsi)));
1892 if (bb->discriminator)
1894 pp_string (buffer, ", discriminator ");
1895 pp_decimal_int (buffer, bb->discriminator);
1898 newline_and_indent (buffer, indent);
1900 pp_string (buffer, "# PRED:");
1901 pp_write_text_to_stream (buffer);
1902 FOR_EACH_EDGE (e, ei, bb->preds)
1903 if (flags & TDF_SLIM)
1905 pp_character (buffer, ' ');
1906 if (e->src == ENTRY_BLOCK_PTR)
1907 pp_string (buffer, "ENTRY");
1909 pp_decimal_int (buffer, e->src->index);
1912 dump_edge_info (buffer->buffer->stream, e, 0);
1913 pp_newline (buffer);
1917 stmt = first_stmt (bb);
1918 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
1920 INDENT (indent - 2);
1921 pp_string (buffer, "<bb ");
1922 pp_decimal_int (buffer, bb->index);
1923 pp_string (buffer, ">:");
1924 pp_newline (buffer);
1927 pp_write_text_to_stream (buffer);
1929 check_bb_profile (bb, buffer->buffer->stream);
1933 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
1937 dump_bb_end (pretty_printer *buffer, basic_block bb, int indent, int flags)
1943 pp_string (buffer, "# SUCC:");
1944 pp_write_text_to_stream (buffer);
1945 FOR_EACH_EDGE (e, ei, bb->succs)
1946 if (flags & TDF_SLIM)
1948 pp_character (buffer, ' ');
1949 if (e->dest == EXIT_BLOCK_PTR)
1950 pp_string (buffer, "EXIT");
1952 pp_decimal_int (buffer, e->dest->index);
1955 dump_edge_info (buffer->buffer->stream, e, 1);
1956 pp_newline (buffer);
1960 /* Dump PHI nodes of basic block BB to BUFFER with details described
1961 by FLAGS and indented by INDENT spaces. */
1964 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
1966 gimple_stmt_iterator i;
1968 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
1970 gimple phi = gsi_stmt (i);
1971 if (is_gimple_reg (gimple_phi_result (phi)) || (flags & TDF_VOPS))
1974 pp_string (buffer, "# ");
1975 dump_gimple_phi (buffer, phi, indent, flags);
1976 pp_newline (buffer);
1982 /* Dump jump to basic block BB that is represented implicitly in the cfg
1986 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
1990 stmt = first_stmt (bb);
1992 pp_string (buffer, "goto <bb ");
1993 pp_decimal_int (buffer, bb->index);
1994 pp_character (buffer, '>');
1995 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
1997 pp_string (buffer, " (");
1998 dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
1999 pp_character (buffer, ')');
2000 pp_semicolon (buffer);
2003 pp_semicolon (buffer);
2007 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2008 by INDENT spaces, with details given by FLAGS. */
2011 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2017 stmt = last_stmt (bb);
2019 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2021 edge true_edge, false_edge;
2023 /* When we are emitting the code or changing CFG, it is possible that
2024 the edges are not yet created. When we are using debug_bb in such
2025 a situation, we do not want it to crash. */
2026 if (EDGE_COUNT (bb->succs) != 2)
2028 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2030 INDENT (indent + 2);
2031 pp_cfg_jump (buffer, true_edge->dest);
2032 newline_and_indent (buffer, indent);
2033 pp_string (buffer, "else");
2034 newline_and_indent (buffer, indent + 2);
2035 pp_cfg_jump (buffer, false_edge->dest);
2036 pp_newline (buffer);
2040 /* If there is a fallthru edge, we may need to add an artificial
2041 goto to the dump. */
2042 e = find_fallthru_edge (bb->succs);
2044 if (e && e->dest != bb->next_bb)
2048 if ((flags & TDF_LINENO)
2049 && e->goto_locus != UNKNOWN_LOCATION
2052 expanded_location goto_xloc;
2053 goto_xloc = expand_location (e->goto_locus);
2054 pp_character (buffer, '[');
2057 pp_string (buffer, goto_xloc.file);
2058 pp_string (buffer, " : ");
2060 pp_decimal_int (buffer, goto_xloc.line);
2061 pp_string (buffer, " : ");
2062 pp_decimal_int (buffer, goto_xloc.column);
2063 pp_string (buffer, "] ");
2066 pp_cfg_jump (buffer, e->dest);
2067 pp_newline (buffer);
2072 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2073 indented by INDENT spaces. */
2076 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2079 gimple_stmt_iterator gsi;
2081 int label_indent = indent - 2;
2083 if (label_indent < 0)
2086 dump_bb_header (buffer, bb, indent, flags);
2087 dump_phi_nodes (buffer, bb, indent, flags);
2089 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2093 stmt = gsi_stmt (gsi);
2095 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2097 INDENT (curr_indent);
2098 dump_gimple_stmt (buffer, stmt, curr_indent, flags);
2099 pp_newline (buffer);
2100 dump_histograms_for_stmt (cfun, buffer->buffer->stream, stmt);
2103 dump_implicit_edges (buffer, bb, indent, flags);
2105 if (flags & TDF_BLOCKS)
2106 dump_bb_end (buffer, bb, indent, flags);
2110 /* Dumps basic block BB to FILE with details described by FLAGS and
2111 indented by INDENT spaces. */
2114 gimple_dump_bb (basic_block bb, FILE *file, int indent, int flags)
2116 maybe_init_pretty_print (file);
2117 gimple_dump_bb_buff (&buffer, bb, indent, flags);