1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
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"
31 #include "tree-flow.h"
32 #include "tree-pass.h"
34 #include "value-prof.h"
36 #define INDENT(SPACE) \
37 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
39 static pretty_printer buffer
;
40 static bool initialized
= false;
42 #define GIMPLE_NIY do_niy (buffer,gs)
44 /* Try to print on BUFFER a default message for the unrecognized
45 gimple statement GS. */
48 do_niy (pretty_printer
*buffer
, gimple gs
)
50 pp_printf (buffer
, "<<< Unknown GIMPLE statement: %s >>>\n",
51 gimple_code_name
[(int) gimple_code (gs
)]);
55 /* Initialize the pretty printer on FILE if needed. */
58 maybe_init_pretty_print (FILE *file
)
62 pp_construct (&buffer
, NULL
, 0);
63 pp_needs_newline (&buffer
) = true;
67 buffer
.buffer
->stream
= file
;
71 /* Emit a newline and SPC indentantion spaces to BUFFER. */
74 newline_and_indent (pretty_printer
*buffer
, int spc
)
81 /* Print the GIMPLE statement GS on stderr. */
84 debug_gimple_stmt (gimple gs
)
86 print_gimple_stmt (stderr
, gs
, 0, TDF_VOPS
|TDF_MEMSYMS
);
87 fprintf (stderr
, "\n");
91 /* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
92 FLAGS as in dump_gimple_stmt. */
95 print_gimple_stmt (FILE *file
, gimple g
, int spc
, int flags
)
97 maybe_init_pretty_print (file
);
98 dump_gimple_stmt (&buffer
, g
, spc
, flags
);
103 /* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
104 FLAGS as in dump_gimple_stmt. Print only the right-hand side
108 print_gimple_expr (FILE *file
, gimple g
, int spc
, int flags
)
110 flags
|= TDF_RHS_ONLY
;
111 maybe_init_pretty_print (file
);
112 dump_gimple_stmt (&buffer
, g
, spc
, flags
);
116 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion
117 spaces and FLAGS as in dump_gimple_stmt. */
120 dump_gimple_seq (pretty_printer
*buffer
, gimple_seq seq
, int spc
, int flags
)
122 gimple_stmt_iterator i
;
124 for (i
= gsi_start (seq
); !gsi_end_p (i
); gsi_next (&i
))
126 gimple gs
= gsi_stmt (i
);
128 dump_gimple_stmt (buffer
, gs
, spc
, flags
);
129 if (!gsi_one_before_end_p (i
))
135 /* Dump GIMPLE sequence SEQ to FILE using SPC indentantion spaces and
136 FLAGS as in dump_gimple_stmt. */
139 print_gimple_seq (FILE *file
, gimple_seq seq
, int spc
, int flags
)
141 maybe_init_pretty_print (file
);
142 dump_gimple_seq (&buffer
, seq
, spc
, flags
);
147 /* Print the GIMPLE sequence SEQ on stderr. */
150 debug_gimple_seq (gimple_seq seq
)
152 print_gimple_seq (stderr
, seq
, 0, TDF_VOPS
|TDF_MEMSYMS
);
156 /* A simple helper to pretty-print some of the gimple tuples in the printf
157 style. The format modifiers are preceeded by '%' and are:
158 'G' - outputs a string corresponding to the code of the given gimple,
159 'S' - outputs a gimple_seq with indent of spc + 2,
160 'T' - outputs the tree t,
161 'd' - outputs an int as a decimal,
162 's' - outputs a string,
163 'n' - outputs a newline,
164 '+' - increases indent by 2 then outputs a newline,
165 '-' - decreases indent by 2 then outputs a newline. */
168 dump_gimple_fmt (pretty_printer
*buffer
, int spc
, int flags
,
169 const char *fmt
, ...)
175 va_start (args
, fmt
);
176 for (c
= fmt
; *c
; c
++)
186 g
= va_arg (args
, gimple
);
187 tmp
= gimple_code_name
[gimple_code (g
)];
188 pp_string (buffer
, tmp
);
192 seq
= va_arg (args
, gimple_seq
);
194 dump_gimple_seq (buffer
, seq
, spc
+ 2, flags
);
195 newline_and_indent (buffer
, spc
);
199 t
= va_arg (args
, tree
);
201 pp_string (buffer
, "NULL");
203 dump_generic_node (buffer
, t
, spc
, flags
, false);
207 pp_decimal_int (buffer
, va_arg (args
, int));
211 pp_string (buffer
, va_arg (args
, char *));
215 newline_and_indent (buffer
, spc
);
220 newline_and_indent (buffer
, spc
);
225 newline_and_indent (buffer
, spc
);
233 pp_character (buffer
, *c
);
239 /* Helper for dump_gimple_assign. Print the unary RHS of the
240 assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */
243 dump_unary_rhs (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
245 enum tree_code rhs_code
= gimple_assign_rhs_code (gs
);
246 tree lhs
= gimple_assign_lhs (gs
);
247 tree rhs
= gimple_assign_rhs1 (gs
);
251 case VIEW_CONVERT_EXPR
:
253 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
256 case FIXED_CONVERT_EXPR
:
257 case ADDR_SPACE_CONVERT_EXPR
:
261 pp_character (buffer
, '(');
262 dump_generic_node (buffer
, TREE_TYPE (lhs
), spc
, flags
, false);
263 pp_string (buffer
, ") ");
264 if (op_prio (rhs
) < op_code_prio (rhs_code
))
266 pp_character (buffer
, '(');
267 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
268 pp_character (buffer
, ')');
271 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
275 pp_string (buffer
, "((");
276 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
277 pp_string (buffer
, "))");
281 pp_string (buffer
, "ABS_EXPR <");
282 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
283 pp_character (buffer
, '>');
287 if (TREE_CODE_CLASS (rhs_code
) == tcc_declaration
288 || TREE_CODE_CLASS (rhs_code
) == tcc_constant
289 || TREE_CODE_CLASS (rhs_code
) == tcc_reference
290 || rhs_code
== SSA_NAME
291 || rhs_code
== ADDR_EXPR
292 || rhs_code
== CONSTRUCTOR
)
294 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
297 else if (rhs_code
== BIT_NOT_EXPR
)
298 pp_character (buffer
, '~');
299 else if (rhs_code
== TRUTH_NOT_EXPR
)
300 pp_character (buffer
, '!');
301 else if (rhs_code
== NEGATE_EXPR
)
302 pp_character (buffer
, '-');
305 pp_character (buffer
, '[');
306 pp_string (buffer
, tree_code_name
[rhs_code
]);
307 pp_string (buffer
, "] ");
310 if (op_prio (rhs
) < op_code_prio (rhs_code
))
312 pp_character (buffer
, '(');
313 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
314 pp_character (buffer
, ')');
317 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
323 /* Helper for dump_gimple_assign. Print the binary RHS of the
324 assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */
327 dump_binary_rhs (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
330 enum tree_code code
= gimple_assign_rhs_code (gs
);
336 case VEC_WIDEN_MULT_HI_EXPR
:
337 case VEC_WIDEN_MULT_LO_EXPR
:
338 case VEC_PACK_TRUNC_EXPR
:
339 case VEC_PACK_SAT_EXPR
:
340 case VEC_PACK_FIX_TRUNC_EXPR
:
341 case VEC_EXTRACT_EVEN_EXPR
:
342 case VEC_EXTRACT_ODD_EXPR
:
343 case VEC_INTERLEAVE_HIGH_EXPR
:
344 case VEC_INTERLEAVE_LOW_EXPR
:
345 for (p
= tree_code_name
[(int) code
]; *p
; p
++)
346 pp_character (buffer
, TOUPPER (*p
));
347 pp_string (buffer
, " <");
348 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
349 pp_string (buffer
, ", ");
350 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
351 pp_character (buffer
, '>');
355 if (op_prio (gimple_assign_rhs1 (gs
)) <= op_code_prio (code
))
357 pp_character (buffer
, '(');
358 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
,
360 pp_character (buffer
, ')');
363 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
365 pp_string (buffer
, op_symbol_code (gimple_assign_rhs_code (gs
)));
367 if (op_prio (gimple_assign_rhs2 (gs
)) <= op_code_prio (code
))
369 pp_character (buffer
, '(');
370 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
,
372 pp_character (buffer
, ')');
375 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
380 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
384 dump_gimple_assign (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
389 if (gimple_num_ops (gs
) == 2)
391 else if (gimple_num_ops (gs
) == 3)
392 last
= gimple_assign_rhs2 (gs
);
396 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T>", gs
,
397 tree_code_name
[gimple_assign_rhs_code (gs
)],
398 gimple_assign_lhs (gs
), gimple_assign_rhs1 (gs
), last
);
402 if (!(flags
& TDF_RHS_ONLY
))
404 dump_generic_node (buffer
, gimple_assign_lhs (gs
), spc
, flags
, false);
406 pp_character (buffer
, '=');
408 if (gimple_assign_nontemporal_move_p (gs
))
409 pp_string (buffer
, "{nt}");
411 if (gimple_has_volatile_ops (gs
))
412 pp_string (buffer
, "{v}");
417 if (gimple_num_ops (gs
) == 2)
418 dump_unary_rhs (buffer
, gs
, spc
, flags
);
419 else if (gimple_num_ops (gs
) == 3)
420 dump_binary_rhs (buffer
, gs
, spc
, flags
);
423 if (!(flags
& TDF_RHS_ONLY
))
424 pp_semicolon(buffer
);
429 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
433 dump_gimple_return (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
437 t
= gimple_return_retval (gs
);
439 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, t
);
442 pp_string (buffer
, "return");
446 dump_generic_node (buffer
, t
, spc
, flags
, false);
448 pp_semicolon (buffer
);
453 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
457 dump_gimple_call_args (pretty_printer
*buffer
, gimple gs
, int flags
)
461 for (i
= 0; i
< gimple_call_num_args (gs
); i
++)
463 dump_generic_node (buffer
, gimple_call_arg (gs
, i
), 0, flags
, false);
464 if (i
< gimple_call_num_args (gs
) - 1)
465 pp_string (buffer
, ", ");
468 if (gimple_call_va_arg_pack_p (gs
))
470 if (gimple_call_num_args (gs
) > 0)
472 pp_character (buffer
, ',');
476 pp_string (buffer
, "__builtin_va_arg_pack ()");
480 /* Dump the points-to solution *PT to BUFFER. */
483 pp_points_to_solution (pretty_printer
*buffer
, struct pt_solution
*pt
)
487 pp_string (buffer
, "anything ");
491 pp_string (buffer
, "nonlocal ");
493 pp_string (buffer
, "escaped ");
495 pp_string (buffer
, "unit-escaped ");
497 pp_string (buffer
, "null ");
499 && !bitmap_empty_p (pt
->vars
))
503 pp_string (buffer
, "{ ");
504 EXECUTE_IF_SET_IN_BITMAP (pt
->vars
, 0, i
, bi
)
506 struct tree_decl_minimal in
;
509 var
= (tree
) htab_find_with_hash (gimple_referenced_vars (cfun
),
513 dump_generic_node (buffer
, var
, 0, dump_flags
, false);
514 if (DECL_PT_UID (var
) != DECL_UID (var
))
516 pp_string (buffer
, "ptD.");
517 pp_decimal_int (buffer
, DECL_PT_UID (var
));
522 pp_string (buffer
, "D.");
523 pp_decimal_int (buffer
, i
);
525 pp_character (buffer
, ' ');
527 pp_character (buffer
, '}');
528 if (pt
->vars_contains_global
)
529 pp_string (buffer
, " (glob)");
530 if (pt
->vars_contains_restrict
)
531 pp_string (buffer
, " (restr)");
535 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
539 dump_gimple_call (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
541 tree lhs
= gimple_call_lhs (gs
);
543 if (flags
& TDF_ALIAS
)
545 struct pt_solution
*pt
;
546 pt
= gimple_call_use_set (gs
);
547 if (!pt_solution_empty_p (pt
))
549 pp_string (buffer
, "# USE = ");
550 pp_points_to_solution (buffer
, pt
);
551 newline_and_indent (buffer
, spc
);
553 pt
= gimple_call_clobber_set (gs
);
554 if (!pt_solution_empty_p (pt
))
556 pp_string (buffer
, "# CLB = ");
557 pp_points_to_solution (buffer
, pt
);
558 newline_and_indent (buffer
, spc
);
564 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T",
565 gs
, gimple_call_fn (gs
), lhs
);
566 if (gimple_call_num_args (gs
) > 0)
568 pp_string (buffer
, ", ");
569 dump_gimple_call_args (buffer
, gs
, flags
);
571 pp_character (buffer
, '>');
575 if (lhs
&& !(flags
& TDF_RHS_ONLY
))
577 dump_generic_node (buffer
, lhs
, spc
, flags
, false);
578 pp_string (buffer
, " =");
580 if (gimple_has_volatile_ops (gs
))
581 pp_string (buffer
, "{v}");
585 print_call_name (buffer
, gimple_call_fn (gs
), flags
);
586 pp_string (buffer
, " (");
587 dump_gimple_call_args (buffer
, gs
, flags
);
588 pp_character (buffer
, ')');
589 if (!(flags
& TDF_RHS_ONLY
))
590 pp_semicolon (buffer
);
593 if (gimple_call_chain (gs
))
595 pp_string (buffer
, " [static-chain: ");
596 dump_generic_node (buffer
, gimple_call_chain (gs
), spc
, flags
, false);
597 pp_character (buffer
, ']');
600 if (gimple_call_return_slot_opt_p (gs
))
601 pp_string (buffer
, " [return slot optimization]");
603 if (gimple_call_tail_p (gs
))
604 pp_string (buffer
, " [tail call]");
608 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
612 dump_gimple_switch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
616 GIMPLE_CHECK (gs
, GIMPLE_SWITCH
);
618 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", gs
,
619 gimple_switch_index (gs
));
622 pp_string (buffer
, "switch (");
623 dump_generic_node (buffer
, gimple_switch_index (gs
), spc
, flags
, true);
624 pp_string (buffer
, ") <");
627 for (i
= 0; i
< gimple_switch_num_labels (gs
); i
++)
629 tree case_label
= gimple_switch_label (gs
, i
);
630 if (case_label
== NULL_TREE
)
633 dump_generic_node (buffer
, case_label
, spc
, flags
, false);
634 pp_character (buffer
, ' ');
635 dump_generic_node (buffer
, CASE_LABEL (case_label
), spc
, flags
, false);
636 if (i
< gimple_switch_num_labels (gs
) - 1)
637 pp_string (buffer
, ", ");
639 pp_character (buffer
, '>');
643 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
647 dump_gimple_cond (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
650 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T, %T>", gs
,
651 tree_code_name
[gimple_cond_code (gs
)],
652 gimple_cond_lhs (gs
), gimple_cond_rhs (gs
),
653 gimple_cond_true_label (gs
), gimple_cond_false_label (gs
));
656 if (!(flags
& TDF_RHS_ONLY
))
657 pp_string (buffer
, "if (");
658 dump_generic_node (buffer
, gimple_cond_lhs (gs
), spc
, flags
, false);
660 pp_string (buffer
, op_symbol_code (gimple_cond_code (gs
)));
662 dump_generic_node (buffer
, gimple_cond_rhs (gs
), spc
, flags
, false);
663 if (!(flags
& TDF_RHS_ONLY
))
665 pp_character (buffer
, ')');
667 if (gimple_cond_true_label (gs
))
669 pp_string (buffer
, " goto ");
670 dump_generic_node (buffer
, gimple_cond_true_label (gs
),
672 pp_semicolon (buffer
);
674 if (gimple_cond_false_label (gs
))
676 pp_string (buffer
, " else goto ");
677 dump_generic_node (buffer
, gimple_cond_false_label (gs
),
679 pp_semicolon (buffer
);
686 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
687 spaces of indent. FLAGS specifies details to show in the dump (see
688 TDF_* in tree-pass.h). */
691 dump_gimple_label (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
693 tree label
= gimple_label_label (gs
);
695 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
698 dump_generic_node (buffer
, label
, spc
, flags
, false);
699 pp_character (buffer
, ':');
701 if (DECL_NONLOCAL (label
))
702 pp_string (buffer
, " [non-local]");
703 if ((flags
& TDF_EH
) && EH_LANDING_PAD_NR (label
))
704 pp_printf (buffer
, " [LP %d]", EH_LANDING_PAD_NR (label
));
707 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
708 spaces of indent. FLAGS specifies details to show in the dump (see
709 TDF_* in tree-pass.h). */
712 dump_gimple_goto (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
714 tree label
= gimple_goto_dest (gs
);
716 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
718 dump_gimple_fmt (buffer
, spc
, flags
, "goto %T;", label
);
722 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
723 spaces of indent. FLAGS specifies details to show in the dump (see
724 TDF_* in tree-pass.h). */
727 dump_gimple_bind (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
730 dump_gimple_fmt (buffer
, spc
, flags
, "%G <", gs
);
732 pp_character (buffer
, '{');
733 if (!(flags
& TDF_SLIM
))
737 for (var
= gimple_bind_vars (gs
); var
; var
= TREE_CHAIN (var
))
739 newline_and_indent (buffer
, 2);
740 print_declaration (buffer
, var
, spc
, flags
);
742 if (gimple_bind_vars (gs
))
746 dump_gimple_seq (buffer
, gimple_bind_body (gs
), spc
+ 2, flags
);
747 newline_and_indent (buffer
, spc
);
749 pp_character (buffer
, '>');
751 pp_character (buffer
, '}');
755 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
756 indent. FLAGS specifies details to show in the dump (see TDF_* in
760 dump_gimple_try (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
765 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
766 type
= "GIMPLE_TRY_CATCH";
767 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
768 type
= "GIMPLE_TRY_FINALLY";
770 type
= "UNKNOWN GIMPLE_TRY";
771 dump_gimple_fmt (buffer
, spc
, flags
,
772 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs
, type
,
773 gimple_try_eval (gs
), gimple_try_cleanup (gs
));
777 pp_string (buffer
, "try");
778 newline_and_indent (buffer
, spc
+ 2);
779 pp_character (buffer
, '{');
782 dump_gimple_seq (buffer
, gimple_try_eval (gs
), spc
+ 4, flags
);
783 newline_and_indent (buffer
, spc
+ 2);
784 pp_character (buffer
, '}');
786 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
788 newline_and_indent (buffer
, spc
);
789 pp_string (buffer
, "catch");
790 newline_and_indent (buffer
, spc
+ 2);
791 pp_character (buffer
, '{');
793 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
795 newline_and_indent (buffer
, spc
);
796 pp_string (buffer
, "finally");
797 newline_and_indent (buffer
, spc
+ 2);
798 pp_character (buffer
, '{');
801 pp_string (buffer
, " <UNKNOWN GIMPLE_TRY> {");
804 dump_gimple_seq (buffer
, gimple_try_cleanup (gs
), spc
+ 4, flags
);
805 newline_and_indent (buffer
, spc
+ 2);
806 pp_character (buffer
, '}');
811 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
812 indent. FLAGS specifies details to show in the dump (see TDF_* in
816 dump_gimple_catch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
819 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+CATCH <%S>%->", gs
,
820 gimple_catch_types (gs
), gimple_catch_handler (gs
));
822 dump_gimple_fmt (buffer
, spc
, flags
, "catch (%T)%+{%S}",
823 gimple_catch_types (gs
), gimple_catch_handler (gs
));
827 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
828 indent. FLAGS specifies details to show in the dump (see TDF_* in
832 dump_gimple_eh_filter (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
835 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+FAILURE <%S>%->", gs
,
836 gimple_eh_filter_types (gs
),
837 gimple_eh_filter_failure (gs
));
839 dump_gimple_fmt (buffer
, spc
, flags
, "<<<eh_filter (%T)>>>%+{%+%S%-}",
840 gimple_eh_filter_types (gs
),
841 gimple_eh_filter_failure (gs
));
845 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
848 dump_gimple_eh_must_not_throw (pretty_printer
*buffer
, gimple gs
,
852 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
,
853 gimple_eh_must_not_throw_fndecl (gs
));
855 dump_gimple_fmt (buffer
, spc
, flags
, "<<<eh_must_not_throw (%T)>>>",
856 gimple_eh_must_not_throw_fndecl (gs
));
860 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
861 indent. FLAGS specifies details to show in the dump (see TDF_* in
865 dump_gimple_resx (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
868 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%d>", gs
,
869 gimple_resx_region (gs
));
871 dump_gimple_fmt (buffer
, spc
, flags
, "resx %d", gimple_resx_region (gs
));
874 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
877 dump_gimple_eh_dispatch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
880 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%d>", gs
,
881 gimple_eh_dispatch_region (gs
));
883 dump_gimple_fmt (buffer
, spc
, flags
, "eh_dispatch %d",
884 gimple_eh_dispatch_region (gs
));
887 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
888 of indent. FLAGS specifies details to show in the dump (see TDF_*
892 dump_gimple_debug (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
894 switch (gs
->gsbase
.subcode
)
896 case GIMPLE_DEBUG_BIND
:
898 dump_gimple_fmt (buffer
, spc
, flags
, "%G BIND <%T, %T>", gs
,
899 gimple_debug_bind_get_var (gs
),
900 gimple_debug_bind_get_value (gs
));
902 dump_gimple_fmt (buffer
, spc
, flags
, "# DEBUG %T => %T",
903 gimple_debug_bind_get_var (gs
),
904 gimple_debug_bind_get_value (gs
));
912 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
914 dump_gimple_omp_for (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
920 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
921 gimple_omp_body (gs
));
922 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
923 dump_gimple_fmt (buffer
, spc
, flags
, " >,");
924 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
925 dump_gimple_fmt (buffer
, spc
, flags
,
926 "%+%T, %T, %T, %s, %T,%n",
927 gimple_omp_for_index (gs
, i
),
928 gimple_omp_for_initial (gs
, i
),
929 gimple_omp_for_final (gs
, i
),
930 tree_code_name
[gimple_omp_for_cond (gs
, i
)],
931 gimple_omp_for_incr (gs
, i
));
932 dump_gimple_fmt (buffer
, spc
, flags
, "PRE_BODY <%S>%->",
933 gimple_omp_for_pre_body (gs
));
937 pp_string (buffer
, "#pragma omp for");
938 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
939 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
943 newline_and_indent (buffer
, spc
);
944 pp_string (buffer
, "for (");
945 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
947 pp_string (buffer
, " = ");
948 dump_generic_node (buffer
, gimple_omp_for_initial (gs
, i
), spc
,
950 pp_string (buffer
, "; ");
952 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
955 switch (gimple_omp_for_cond (gs
, i
))
958 pp_character (buffer
, '<');
961 pp_character (buffer
, '>');
964 pp_string (buffer
, "<=");
967 pp_string (buffer
, ">=");
973 dump_generic_node (buffer
, gimple_omp_for_final (gs
, i
), spc
,
975 pp_string (buffer
, "; ");
977 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
979 pp_string (buffer
, " = ");
980 dump_generic_node (buffer
, gimple_omp_for_incr (gs
, i
), spc
,
982 pp_character (buffer
, ')');
985 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
987 newline_and_indent (buffer
, spc
+ 2);
988 pp_character (buffer
, '{');
990 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
991 newline_and_indent (buffer
, spc
+ 2);
992 pp_character (buffer
, '}');
997 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1000 dump_gimple_omp_continue (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1002 if (flags
& TDF_RAW
)
1004 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
1005 gimple_omp_continue_control_def (gs
),
1006 gimple_omp_continue_control_use (gs
));
1010 pp_string (buffer
, "#pragma omp continue (");
1011 dump_generic_node (buffer
, gimple_omp_continue_control_def (gs
),
1013 pp_character (buffer
, ',');
1015 dump_generic_node (buffer
, gimple_omp_continue_control_use (gs
),
1017 pp_character (buffer
, ')');
1021 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1024 dump_gimple_omp_single (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1026 if (flags
& TDF_RAW
)
1028 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1029 gimple_omp_body (gs
));
1030 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
1031 dump_gimple_fmt (buffer
, spc
, flags
, " >");
1035 pp_string (buffer
, "#pragma omp single");
1036 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
1037 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1039 newline_and_indent (buffer
, spc
+ 2);
1040 pp_character (buffer
, '{');
1041 pp_newline (buffer
);
1042 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1043 newline_and_indent (buffer
, spc
+ 2);
1044 pp_character (buffer
, '}');
1049 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1052 dump_gimple_omp_sections (pretty_printer
*buffer
, gimple gs
, int spc
,
1055 if (flags
& TDF_RAW
)
1057 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1058 gimple_omp_body (gs
));
1059 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
1060 dump_gimple_fmt (buffer
, spc
, flags
, " >");
1064 pp_string (buffer
, "#pragma omp sections");
1065 if (gimple_omp_sections_control (gs
))
1067 pp_string (buffer
, " <");
1068 dump_generic_node (buffer
, gimple_omp_sections_control (gs
), spc
,
1070 pp_character (buffer
, '>');
1072 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
1073 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1075 newline_and_indent (buffer
, spc
+ 2);
1076 pp_character (buffer
, '{');
1077 pp_newline (buffer
);
1078 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1079 newline_and_indent (buffer
, spc
+ 2);
1080 pp_character (buffer
, '}');
1085 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the pretty_printer
1089 dump_gimple_omp_block (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1091 if (flags
& TDF_RAW
)
1092 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
1093 gimple_omp_body (gs
));
1096 switch (gimple_code (gs
))
1098 case GIMPLE_OMP_MASTER
:
1099 pp_string (buffer
, "#pragma omp master");
1101 case GIMPLE_OMP_ORDERED
:
1102 pp_string (buffer
, "#pragma omp ordered");
1104 case GIMPLE_OMP_SECTION
:
1105 pp_string (buffer
, "#pragma omp section");
1110 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1112 newline_and_indent (buffer
, spc
+ 2);
1113 pp_character (buffer
, '{');
1114 pp_newline (buffer
);
1115 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1116 newline_and_indent (buffer
, spc
+ 2);
1117 pp_character (buffer
, '}');
1122 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1125 dump_gimple_omp_critical (pretty_printer
*buffer
, gimple gs
, int spc
,
1128 if (flags
& TDF_RAW
)
1129 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
1130 gimple_omp_body (gs
));
1133 pp_string (buffer
, "#pragma omp critical");
1134 if (gimple_omp_critical_name (gs
))
1136 pp_string (buffer
, " (");
1137 dump_generic_node (buffer
, gimple_omp_critical_name (gs
), spc
,
1139 pp_character (buffer
, ')');
1141 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1143 newline_and_indent (buffer
, spc
+ 2);
1144 pp_character (buffer
, '{');
1145 pp_newline (buffer
);
1146 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1147 newline_and_indent (buffer
, spc
+ 2);
1148 pp_character (buffer
, '}');
1153 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1156 dump_gimple_omp_return (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1158 if (flags
& TDF_RAW
)
1160 dump_gimple_fmt (buffer
, spc
, flags
, "%G <nowait=%d>", gs
,
1161 (int) gimple_omp_return_nowait_p (gs
));
1165 pp_string (buffer
, "#pragma omp return");
1166 if (gimple_omp_return_nowait_p (gs
))
1167 pp_string (buffer
, "(nowait)");
1171 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1172 indent. FLAGS specifies details to show in the dump (see TDF_* in
1176 dump_gimple_asm (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1178 unsigned int i
, n
, f
, fields
;
1180 if (flags
& TDF_RAW
)
1182 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+STRING <%n%s%n>", gs
,
1183 gimple_asm_string (gs
));
1185 n
= gimple_asm_noutputs (gs
);
1188 newline_and_indent (buffer
, spc
+ 2);
1189 pp_string (buffer
, "OUTPUT: ");
1190 for (i
= 0; i
< n
; i
++)
1192 dump_generic_node (buffer
, gimple_asm_output_op (gs
, i
),
1195 pp_string (buffer
, ", ");
1199 n
= gimple_asm_ninputs (gs
);
1202 newline_and_indent (buffer
, spc
+ 2);
1203 pp_string (buffer
, "INPUT: ");
1204 for (i
= 0; i
< n
; i
++)
1206 dump_generic_node (buffer
, gimple_asm_input_op (gs
, i
),
1209 pp_string (buffer
, ", ");
1213 n
= gimple_asm_nclobbers (gs
);
1216 newline_and_indent (buffer
, spc
+ 2);
1217 pp_string (buffer
, "CLOBBER: ");
1218 for (i
= 0; i
< n
; i
++)
1220 dump_generic_node (buffer
, gimple_asm_clobber_op (gs
, i
),
1223 pp_string (buffer
, ", ");
1227 n
= gimple_asm_nlabels (gs
);
1230 newline_and_indent (buffer
, spc
+ 2);
1231 pp_string (buffer
, "LABEL: ");
1232 for (i
= 0; i
< n
; i
++)
1234 dump_generic_node (buffer
, gimple_asm_label_op (gs
, i
),
1237 pp_string (buffer
, ", ");
1241 newline_and_indent (buffer
, spc
);
1242 pp_character (buffer
, '>');
1246 pp_string (buffer
, "__asm__");
1247 if (gimple_asm_volatile_p (gs
))
1248 pp_string (buffer
, " __volatile__");
1249 if (gimple_asm_nlabels (gs
))
1250 pp_string (buffer
, " goto");
1251 pp_string (buffer
, "(\"");
1252 pp_string (buffer
, gimple_asm_string (gs
));
1253 pp_string (buffer
, "\"");
1255 if (gimple_asm_nlabels (gs
))
1257 else if (gimple_asm_nclobbers (gs
))
1259 else if (gimple_asm_ninputs (gs
))
1261 else if (gimple_asm_noutputs (gs
))
1266 for (f
= 0; f
< fields
; ++f
)
1268 pp_string (buffer
, " : ");
1273 n
= gimple_asm_noutputs (gs
);
1274 for (i
= 0; i
< n
; i
++)
1276 dump_generic_node (buffer
, gimple_asm_output_op (gs
, i
),
1279 pp_string (buffer
, ", ");
1284 n
= gimple_asm_ninputs (gs
);
1285 for (i
= 0; i
< n
; i
++)
1287 dump_generic_node (buffer
, gimple_asm_input_op (gs
, i
),
1290 pp_string (buffer
, ", ");
1295 n
= gimple_asm_nclobbers (gs
);
1296 for (i
= 0; i
< n
; i
++)
1298 dump_generic_node (buffer
, gimple_asm_clobber_op (gs
, i
),
1301 pp_string (buffer
, ", ");
1306 n
= gimple_asm_nlabels (gs
);
1307 for (i
= 0; i
< n
; i
++)
1309 dump_generic_node (buffer
, gimple_asm_label_op (gs
, i
),
1312 pp_string (buffer
, ", ");
1321 pp_string (buffer
, ");");
1326 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in
1327 dump_gimple_stmt. */
1330 dump_gimple_phi (pretty_printer
*buffer
, gimple phi
, int spc
, int flags
)
1333 tree lhs
= gimple_phi_result (phi
);
1335 if (flags
& TDF_ALIAS
1336 && POINTER_TYPE_P (TREE_TYPE (lhs
))
1337 && SSA_NAME_PTR_INFO (lhs
))
1339 pp_string (buffer
, "PT = ");
1340 pp_points_to_solution (buffer
, &SSA_NAME_PTR_INFO (lhs
)->pt
);
1341 newline_and_indent (buffer
, spc
);
1342 pp_string (buffer
, "# ");
1345 if (flags
& TDF_RAW
)
1346 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", phi
,
1347 gimple_phi_result (phi
));
1350 dump_generic_node (buffer
, lhs
, spc
, flags
, false);
1351 pp_string (buffer
, " = PHI <");
1353 for (i
= 0; i
< gimple_phi_num_args (phi
); i
++)
1355 if ((flags
& TDF_LINENO
) && gimple_phi_arg_has_location (phi
, i
))
1357 expanded_location xloc
;
1359 xloc
= expand_location (gimple_phi_arg_location (phi
, i
));
1360 pp_character (buffer
, '[');
1363 pp_string (buffer
, xloc
.file
);
1364 pp_string (buffer
, " : ");
1366 pp_decimal_int (buffer
, xloc
.line
);
1367 pp_string (buffer
, ":");
1368 pp_decimal_int (buffer
, xloc
.column
);
1369 pp_string (buffer
, "] ");
1371 dump_generic_node (buffer
, gimple_phi_arg_def (phi
, i
), spc
, flags
,
1373 pp_character (buffer
, '(');
1374 pp_decimal_int (buffer
, gimple_phi_arg_edge (phi
, i
)->src
->index
);
1375 pp_character (buffer
, ')');
1376 if (i
< gimple_phi_num_args (phi
) - 1)
1377 pp_string (buffer
, ", ");
1379 pp_character (buffer
, '>');
1383 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1384 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1388 dump_gimple_omp_parallel (pretty_printer
*buffer
, gimple gs
, int spc
,
1391 if (flags
& TDF_RAW
)
1393 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1394 gimple_omp_body (gs
));
1395 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
1396 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T%n>",
1397 gimple_omp_parallel_child_fn (gs
),
1398 gimple_omp_parallel_data_arg (gs
));
1403 pp_string (buffer
, "#pragma omp parallel");
1404 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
1405 if (gimple_omp_parallel_child_fn (gs
))
1407 pp_string (buffer
, " [child fn: ");
1408 dump_generic_node (buffer
, gimple_omp_parallel_child_fn (gs
),
1410 pp_string (buffer
, " (");
1411 if (gimple_omp_parallel_data_arg (gs
))
1412 dump_generic_node (buffer
, gimple_omp_parallel_data_arg (gs
),
1415 pp_string (buffer
, "???");
1416 pp_string (buffer
, ")]");
1418 body
= gimple_omp_body (gs
);
1419 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
1421 newline_and_indent (buffer
, spc
+ 2);
1422 pp_character (buffer
, '{');
1423 pp_newline (buffer
);
1424 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
1425 newline_and_indent (buffer
, spc
+ 2);
1426 pp_character (buffer
, '}');
1430 pp_newline (buffer
);
1431 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
1437 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1438 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1442 dump_gimple_omp_task (pretty_printer
*buffer
, gimple gs
, int spc
,
1445 if (flags
& TDF_RAW
)
1447 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1448 gimple_omp_body (gs
));
1449 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
1450 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T, %T, %T, %T%n>",
1451 gimple_omp_task_child_fn (gs
),
1452 gimple_omp_task_data_arg (gs
),
1453 gimple_omp_task_copy_fn (gs
),
1454 gimple_omp_task_arg_size (gs
),
1455 gimple_omp_task_arg_size (gs
));
1460 pp_string (buffer
, "#pragma omp task");
1461 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
1462 if (gimple_omp_task_child_fn (gs
))
1464 pp_string (buffer
, " [child fn: ");
1465 dump_generic_node (buffer
, gimple_omp_task_child_fn (gs
),
1467 pp_string (buffer
, " (");
1468 if (gimple_omp_task_data_arg (gs
))
1469 dump_generic_node (buffer
, gimple_omp_task_data_arg (gs
),
1472 pp_string (buffer
, "???");
1473 pp_string (buffer
, ")]");
1475 body
= gimple_omp_body (gs
);
1476 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
1478 newline_and_indent (buffer
, spc
+ 2);
1479 pp_character (buffer
, '{');
1480 pp_newline (buffer
);
1481 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
1482 newline_and_indent (buffer
, spc
+ 2);
1483 pp_character (buffer
, '}');
1487 pp_newline (buffer
);
1488 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
1494 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1495 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1499 dump_gimple_omp_atomic_load (pretty_printer
*buffer
, gimple gs
, int spc
,
1502 if (flags
& TDF_RAW
)
1504 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
1505 gimple_omp_atomic_load_lhs (gs
),
1506 gimple_omp_atomic_load_rhs (gs
));
1510 pp_string (buffer
, "#pragma omp atomic_load");
1511 newline_and_indent (buffer
, spc
+ 2);
1512 dump_generic_node (buffer
, gimple_omp_atomic_load_lhs (gs
),
1515 pp_character (buffer
, '=');
1517 pp_character (buffer
, '*');
1518 dump_generic_node (buffer
, gimple_omp_atomic_load_rhs (gs
),
1523 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1524 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1528 dump_gimple_omp_atomic_store (pretty_printer
*buffer
, gimple gs
, int spc
,
1531 if (flags
& TDF_RAW
)
1533 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
,
1534 gimple_omp_atomic_store_val (gs
));
1538 pp_string (buffer
, "#pragma omp atomic_store (");
1539 dump_generic_node (buffer
, gimple_omp_atomic_store_val (gs
),
1541 pp_character (buffer
, ')');
1546 /* Dump all the memory operands for statement GS. BUFFER, SPC and
1547 FLAGS are as in dump_gimple_stmt. */
1550 dump_gimple_mem_ops (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1552 tree vdef
= gimple_vdef (gs
);
1553 tree vuse
= gimple_vuse (gs
);
1555 if (!ssa_operands_active () || !gimple_references_memory_p (gs
))
1558 if (vdef
!= NULL_TREE
)
1560 pp_string (buffer
, "# ");
1561 dump_generic_node (buffer
, vdef
, spc
+ 2, flags
, false);
1562 pp_string (buffer
, " = VDEF <");
1563 dump_generic_node (buffer
, vuse
, spc
+ 2, flags
, false);
1564 pp_character (buffer
, '>');
1565 newline_and_indent (buffer
, spc
);
1567 else if (vuse
!= NULL_TREE
)
1569 pp_string (buffer
, "# VUSE <");
1570 dump_generic_node (buffer
, vuse
, spc
+ 2, flags
, false);
1571 pp_character (buffer
, '>');
1572 newline_and_indent (buffer
, spc
);
1577 /* Dump the gimple statement GS on the pretty printer BUFFER, SPC
1578 spaces of indent. FLAGS specifies details to show in the dump (see
1579 TDF_* in tree-pass.h). */
1582 dump_gimple_stmt (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1587 if (flags
& TDF_STMTADDR
)
1588 pp_printf (buffer
, "<&%p> ", (void *) gs
);
1590 if ((flags
& TDF_LINENO
) && gimple_has_location (gs
))
1592 expanded_location xloc
= expand_location (gimple_location (gs
));
1593 pp_character (buffer
, '[');
1596 pp_string (buffer
, xloc
.file
);
1597 pp_string (buffer
, " : ");
1599 pp_decimal_int (buffer
, xloc
.line
);
1600 pp_string (buffer
, ":");
1601 pp_decimal_int (buffer
, xloc
.column
);
1602 pp_string (buffer
, "] ");
1607 int lp_nr
= lookup_stmt_eh_lp (gs
);
1609 pp_printf (buffer
, "[LP %d] ", lp_nr
);
1611 pp_printf (buffer
, "[MNT %d] ", -lp_nr
);
1614 if ((flags
& (TDF_VOPS
|TDF_MEMSYMS
))
1615 && gimple_has_mem_ops (gs
))
1616 dump_gimple_mem_ops (buffer
, gs
, spc
, flags
);
1618 if ((flags
& TDF_ALIAS
)
1619 && gimple_has_lhs (gs
))
1621 tree lhs
= gimple_get_lhs (gs
);
1622 if (TREE_CODE (lhs
) == SSA_NAME
1623 && POINTER_TYPE_P (TREE_TYPE (lhs
))
1624 && SSA_NAME_PTR_INFO (lhs
))
1626 pp_string (buffer
, "# PT = ");
1627 pp_points_to_solution (buffer
, &SSA_NAME_PTR_INFO (lhs
)->pt
);
1628 newline_and_indent (buffer
, spc
);
1632 switch (gimple_code (gs
))
1635 dump_gimple_asm (buffer
, gs
, spc
, flags
);
1639 dump_gimple_assign (buffer
, gs
, spc
, flags
);
1643 dump_gimple_bind (buffer
, gs
, spc
, flags
);
1647 dump_gimple_call (buffer
, gs
, spc
, flags
);
1651 dump_gimple_cond (buffer
, gs
, spc
, flags
);
1655 dump_gimple_label (buffer
, gs
, spc
, flags
);
1659 dump_gimple_goto (buffer
, gs
, spc
, flags
);
1663 pp_string (buffer
, "GIMPLE_NOP");
1667 dump_gimple_return (buffer
, gs
, spc
, flags
);
1671 dump_gimple_switch (buffer
, gs
, spc
, flags
);
1675 dump_gimple_try (buffer
, gs
, spc
, flags
);
1679 dump_gimple_phi (buffer
, gs
, spc
, flags
);
1682 case GIMPLE_OMP_PARALLEL
:
1683 dump_gimple_omp_parallel (buffer
, gs
, spc
, flags
);
1686 case GIMPLE_OMP_TASK
:
1687 dump_gimple_omp_task (buffer
, gs
, spc
, flags
);
1690 case GIMPLE_OMP_ATOMIC_LOAD
:
1691 dump_gimple_omp_atomic_load (buffer
, gs
, spc
, flags
);
1695 case GIMPLE_OMP_ATOMIC_STORE
:
1696 dump_gimple_omp_atomic_store (buffer
, gs
, spc
, flags
);
1699 case GIMPLE_OMP_FOR
:
1700 dump_gimple_omp_for (buffer
, gs
, spc
, flags
);
1703 case GIMPLE_OMP_CONTINUE
:
1704 dump_gimple_omp_continue (buffer
, gs
, spc
, flags
);
1707 case GIMPLE_OMP_SINGLE
:
1708 dump_gimple_omp_single (buffer
, gs
, spc
, flags
);
1711 case GIMPLE_OMP_RETURN
:
1712 dump_gimple_omp_return (buffer
, gs
, spc
, flags
);
1715 case GIMPLE_OMP_SECTIONS
:
1716 dump_gimple_omp_sections (buffer
, gs
, spc
, flags
);
1719 case GIMPLE_OMP_SECTIONS_SWITCH
:
1720 pp_string (buffer
, "GIMPLE_SECTIONS_SWITCH");
1723 case GIMPLE_OMP_MASTER
:
1724 case GIMPLE_OMP_ORDERED
:
1725 case GIMPLE_OMP_SECTION
:
1726 dump_gimple_omp_block (buffer
, gs
, spc
, flags
);
1729 case GIMPLE_OMP_CRITICAL
:
1730 dump_gimple_omp_critical (buffer
, gs
, spc
, flags
);
1734 dump_gimple_catch (buffer
, gs
, spc
, flags
);
1737 case GIMPLE_EH_FILTER
:
1738 dump_gimple_eh_filter (buffer
, gs
, spc
, flags
);
1741 case GIMPLE_EH_MUST_NOT_THROW
:
1742 dump_gimple_eh_must_not_throw (buffer
, gs
, spc
, flags
);
1746 dump_gimple_resx (buffer
, gs
, spc
, flags
);
1749 case GIMPLE_EH_DISPATCH
:
1750 dump_gimple_eh_dispatch (buffer
, gs
, spc
, flags
);
1754 dump_gimple_debug (buffer
, gs
, spc
, flags
);
1757 case GIMPLE_PREDICT
:
1758 pp_string (buffer
, "// predicted ");
1759 if (gimple_predict_outcome (gs
))
1760 pp_string (buffer
, "likely by ");
1762 pp_string (buffer
, "unlikely by ");
1763 pp_string (buffer
, predictor_name (gimple_predict_predictor (gs
)));
1764 pp_string (buffer
, " predictor.");
1771 /* If we're building a diagnostic, the formatted text will be
1772 written into BUFFER's stream by the caller; otherwise, write it
1774 if (!(flags
& TDF_DIAGNOSTIC
))
1775 pp_write_text_to_stream (buffer
);
1779 /* Dumps header of basic block BB to buffer BUFFER indented by INDENT
1780 spaces and details described by flags. */
1783 dump_bb_header (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1789 if (flags
& TDF_BLOCKS
)
1792 pp_string (buffer
, "# BLOCK ");
1793 pp_decimal_int (buffer
, bb
->index
);
1796 pp_string (buffer
, " freq:");
1797 pp_decimal_int (buffer
, bb
->frequency
);
1801 pp_string (buffer
, " count:");
1802 pp_widest_integer (buffer
, bb
->count
);
1805 if (flags
& TDF_LINENO
)
1807 gimple_stmt_iterator gsi
;
1809 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
1810 if (!is_gimple_debug (gsi_stmt (gsi
))
1811 && get_lineno (gsi_stmt (gsi
)) != UNKNOWN_LOCATION
)
1813 pp_string (buffer
, ", starting at line ");
1814 pp_decimal_int (buffer
, get_lineno (gsi_stmt (gsi
)));
1818 if (bb
->discriminator
)
1820 pp_string (buffer
, ", discriminator ");
1821 pp_decimal_int (buffer
, bb
->discriminator
);
1824 newline_and_indent (buffer
, indent
);
1826 pp_string (buffer
, "# PRED:");
1827 pp_write_text_to_stream (buffer
);
1828 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
1829 if (flags
& TDF_SLIM
)
1831 pp_character (buffer
, ' ');
1832 if (e
->src
== ENTRY_BLOCK_PTR
)
1833 pp_string (buffer
, "ENTRY");
1835 pp_decimal_int (buffer
, e
->src
->index
);
1838 dump_edge_info (buffer
->buffer
->stream
, e
, 0);
1839 pp_newline (buffer
);
1843 stmt
= first_stmt (bb
);
1844 if (!stmt
|| gimple_code (stmt
) != GIMPLE_LABEL
)
1846 INDENT (indent
- 2);
1847 pp_string (buffer
, "<bb ");
1848 pp_decimal_int (buffer
, bb
->index
);
1849 pp_string (buffer
, ">:");
1850 pp_newline (buffer
);
1853 pp_write_text_to_stream (buffer
);
1854 check_bb_profile (bb
, buffer
->buffer
->stream
);
1858 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
1862 dump_bb_end (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1868 pp_string (buffer
, "# SUCC:");
1869 pp_write_text_to_stream (buffer
);
1870 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
1871 if (flags
& TDF_SLIM
)
1873 pp_character (buffer
, ' ');
1874 if (e
->dest
== EXIT_BLOCK_PTR
)
1875 pp_string (buffer
, "EXIT");
1877 pp_decimal_int (buffer
, e
->dest
->index
);
1880 dump_edge_info (buffer
->buffer
->stream
, e
, 1);
1881 pp_newline (buffer
);
1885 /* Dump PHI nodes of basic block BB to BUFFER with details described
1886 by FLAGS and indented by INDENT spaces. */
1889 dump_phi_nodes (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1891 gimple_stmt_iterator i
;
1893 for (i
= gsi_start_phis (bb
); !gsi_end_p (i
); gsi_next (&i
))
1895 gimple phi
= gsi_stmt (i
);
1896 if (is_gimple_reg (gimple_phi_result (phi
)) || (flags
& TDF_VOPS
))
1899 pp_string (buffer
, "# ");
1900 dump_gimple_phi (buffer
, phi
, indent
, flags
);
1901 pp_newline (buffer
);
1907 /* Dump jump to basic block BB that is represented implicitly in the cfg
1911 pp_cfg_jump (pretty_printer
*buffer
, basic_block bb
)
1915 stmt
= first_stmt (bb
);
1917 pp_string (buffer
, "goto <bb ");
1918 pp_decimal_int (buffer
, bb
->index
);
1919 pp_character (buffer
, '>');
1920 if (stmt
&& gimple_code (stmt
) == GIMPLE_LABEL
)
1922 pp_string (buffer
, " (");
1923 dump_generic_node (buffer
, gimple_label_label (stmt
), 0, 0, false);
1924 pp_character (buffer
, ')');
1925 pp_semicolon (buffer
);
1928 pp_semicolon (buffer
);
1932 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
1933 by INDENT spaces, with details given by FLAGS. */
1936 dump_implicit_edges (pretty_printer
*buffer
, basic_block bb
, int indent
,
1943 stmt
= last_stmt (bb
);
1945 if (stmt
&& gimple_code (stmt
) == GIMPLE_COND
)
1947 edge true_edge
, false_edge
;
1949 /* When we are emitting the code or changing CFG, it is possible that
1950 the edges are not yet created. When we are using debug_bb in such
1951 a situation, we do not want it to crash. */
1952 if (EDGE_COUNT (bb
->succs
) != 2)
1954 extract_true_false_edges_from_block (bb
, &true_edge
, &false_edge
);
1956 INDENT (indent
+ 2);
1957 pp_cfg_jump (buffer
, true_edge
->dest
);
1958 newline_and_indent (buffer
, indent
);
1959 pp_string (buffer
, "else");
1960 newline_and_indent (buffer
, indent
+ 2);
1961 pp_cfg_jump (buffer
, false_edge
->dest
);
1962 pp_newline (buffer
);
1966 /* If there is a fallthru edge, we may need to add an artificial
1967 goto to the dump. */
1968 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
1969 if (e
->flags
& EDGE_FALLTHRU
)
1972 if (e
&& e
->dest
!= bb
->next_bb
)
1976 if ((flags
& TDF_LINENO
)
1977 && e
->goto_locus
!= UNKNOWN_LOCATION
1980 expanded_location goto_xloc
;
1981 goto_xloc
= expand_location (e
->goto_locus
);
1982 pp_character (buffer
, '[');
1985 pp_string (buffer
, goto_xloc
.file
);
1986 pp_string (buffer
, " : ");
1988 pp_decimal_int (buffer
, goto_xloc
.line
);
1989 pp_string (buffer
, " : ");
1990 pp_decimal_int (buffer
, goto_xloc
.column
);
1991 pp_string (buffer
, "] ");
1994 pp_cfg_jump (buffer
, e
->dest
);
1995 pp_newline (buffer
);
2000 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2001 indented by INDENT spaces. */
2004 gimple_dump_bb_buff (pretty_printer
*buffer
, basic_block bb
, int indent
,
2007 gimple_stmt_iterator gsi
;
2009 int label_indent
= indent
- 2;
2011 if (label_indent
< 0)
2014 dump_bb_header (buffer
, bb
, indent
, flags
);
2015 dump_phi_nodes (buffer
, bb
, indent
, flags
);
2017 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
2021 stmt
= gsi_stmt (gsi
);
2023 curr_indent
= gimple_code (stmt
) == GIMPLE_LABEL
? label_indent
: indent
;
2025 INDENT (curr_indent
);
2026 dump_gimple_stmt (buffer
, stmt
, curr_indent
, flags
);
2027 pp_newline (buffer
);
2028 dump_histograms_for_stmt (cfun
, buffer
->buffer
->stream
, stmt
);
2031 dump_implicit_edges (buffer
, bb
, indent
, flags
);
2033 if (flags
& TDF_BLOCKS
)
2034 dump_bb_end (buffer
, bb
, indent
, flags
);
2038 /* Dumps basic block BB to FILE with details described by FLAGS and
2039 indented by INDENT spaces. */
2042 gimple_dump_bb (basic_block bb
, FILE *file
, int indent
, int flags
)
2044 maybe_init_pretty_print (file
);
2045 gimple_dump_bb_buff (&buffer
, bb
, indent
, flags
);