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
, '>');
409 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
413 dump_gimple_assign (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
418 if (gimple_num_ops (gs
) == 2)
420 else if (gimple_num_ops (gs
) == 3)
421 last
= gimple_assign_rhs2 (gs
);
425 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T>", gs
,
426 tree_code_name
[gimple_assign_rhs_code (gs
)],
427 gimple_assign_lhs (gs
), gimple_assign_rhs1 (gs
), last
);
431 if (!(flags
& TDF_RHS_ONLY
))
433 dump_generic_node (buffer
, gimple_assign_lhs (gs
), spc
, flags
, false);
435 pp_character (buffer
, '=');
437 if (gimple_assign_nontemporal_move_p (gs
))
438 pp_string (buffer
, "{nt}");
440 if (gimple_has_volatile_ops (gs
))
441 pp_string (buffer
, "{v}");
446 if (gimple_num_ops (gs
) == 2)
447 dump_unary_rhs (buffer
, gs
, spc
, flags
);
448 else if (gimple_num_ops (gs
) == 3)
449 dump_binary_rhs (buffer
, gs
, spc
, flags
);
450 else if (gimple_num_ops (gs
) == 4)
451 dump_ternary_rhs (buffer
, gs
, spc
, flags
);
454 if (!(flags
& TDF_RHS_ONLY
))
455 pp_semicolon(buffer
);
460 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
464 dump_gimple_return (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
468 t
= gimple_return_retval (gs
);
470 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, t
);
473 pp_string (buffer
, "return");
477 dump_generic_node (buffer
, t
, spc
, flags
, false);
479 pp_semicolon (buffer
);
484 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
488 dump_gimple_call_args (pretty_printer
*buffer
, gimple gs
, int flags
)
492 for (i
= 0; i
< gimple_call_num_args (gs
); i
++)
494 dump_generic_node (buffer
, gimple_call_arg (gs
, i
), 0, flags
, false);
495 if (i
< gimple_call_num_args (gs
) - 1)
496 pp_string (buffer
, ", ");
499 if (gimple_call_va_arg_pack_p (gs
))
501 if (gimple_call_num_args (gs
) > 0)
503 pp_character (buffer
, ',');
507 pp_string (buffer
, "__builtin_va_arg_pack ()");
511 /* Dump the points-to solution *PT to BUFFER. */
514 pp_points_to_solution (pretty_printer
*buffer
, struct pt_solution
*pt
)
518 pp_string (buffer
, "anything ");
522 pp_string (buffer
, "nonlocal ");
524 pp_string (buffer
, "escaped ");
526 pp_string (buffer
, "unit-escaped ");
528 pp_string (buffer
, "null ");
530 && !bitmap_empty_p (pt
->vars
))
534 pp_string (buffer
, "{ ");
535 EXECUTE_IF_SET_IN_BITMAP (pt
->vars
, 0, i
, bi
)
537 struct tree_decl_minimal in
;
540 var
= (tree
) htab_find_with_hash (gimple_referenced_vars (cfun
),
544 dump_generic_node (buffer
, var
, 0, dump_flags
, false);
545 if (DECL_PT_UID (var
) != DECL_UID (var
))
547 pp_string (buffer
, "ptD.");
548 pp_decimal_int (buffer
, DECL_PT_UID (var
));
553 pp_string (buffer
, "D.");
554 pp_decimal_int (buffer
, i
);
556 pp_character (buffer
, ' ');
558 pp_character (buffer
, '}');
559 if (pt
->vars_contains_global
)
560 pp_string (buffer
, " (glob)");
561 if (pt
->vars_contains_restrict
)
562 pp_string (buffer
, " (restr)");
566 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
570 dump_gimple_call (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
572 tree lhs
= gimple_call_lhs (gs
);
574 if (flags
& TDF_ALIAS
)
576 struct pt_solution
*pt
;
577 pt
= gimple_call_use_set (gs
);
578 if (!pt_solution_empty_p (pt
))
580 pp_string (buffer
, "# USE = ");
581 pp_points_to_solution (buffer
, pt
);
582 newline_and_indent (buffer
, spc
);
584 pt
= gimple_call_clobber_set (gs
);
585 if (!pt_solution_empty_p (pt
))
587 pp_string (buffer
, "# CLB = ");
588 pp_points_to_solution (buffer
, pt
);
589 newline_and_indent (buffer
, spc
);
595 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T",
596 gs
, gimple_call_fn (gs
), lhs
);
597 if (gimple_call_num_args (gs
) > 0)
599 pp_string (buffer
, ", ");
600 dump_gimple_call_args (buffer
, gs
, flags
);
602 pp_character (buffer
, '>');
606 if (lhs
&& !(flags
& TDF_RHS_ONLY
))
608 dump_generic_node (buffer
, lhs
, spc
, flags
, false);
609 pp_string (buffer
, " =");
611 if (gimple_has_volatile_ops (gs
))
612 pp_string (buffer
, "{v}");
616 print_call_name (buffer
, gimple_call_fn (gs
), flags
);
617 pp_string (buffer
, " (");
618 dump_gimple_call_args (buffer
, gs
, flags
);
619 pp_character (buffer
, ')');
620 if (!(flags
& TDF_RHS_ONLY
))
621 pp_semicolon (buffer
);
624 if (gimple_call_chain (gs
))
626 pp_string (buffer
, " [static-chain: ");
627 dump_generic_node (buffer
, gimple_call_chain (gs
), spc
, flags
, false);
628 pp_character (buffer
, ']');
631 if (gimple_call_return_slot_opt_p (gs
))
632 pp_string (buffer
, " [return slot optimization]");
634 if (gimple_call_tail_p (gs
))
635 pp_string (buffer
, " [tail call]");
639 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
643 dump_gimple_switch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
647 GIMPLE_CHECK (gs
, GIMPLE_SWITCH
);
649 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", gs
,
650 gimple_switch_index (gs
));
653 pp_string (buffer
, "switch (");
654 dump_generic_node (buffer
, gimple_switch_index (gs
), spc
, flags
, true);
655 pp_string (buffer
, ") <");
658 for (i
= 0; i
< gimple_switch_num_labels (gs
); i
++)
660 tree case_label
= gimple_switch_label (gs
, i
);
661 if (case_label
== NULL_TREE
)
664 dump_generic_node (buffer
, case_label
, spc
, flags
, false);
665 pp_character (buffer
, ' ');
666 dump_generic_node (buffer
, CASE_LABEL (case_label
), spc
, flags
, false);
667 if (i
< gimple_switch_num_labels (gs
) - 1)
668 pp_string (buffer
, ", ");
670 pp_character (buffer
, '>');
674 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
678 dump_gimple_cond (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
681 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T, %T>", gs
,
682 tree_code_name
[gimple_cond_code (gs
)],
683 gimple_cond_lhs (gs
), gimple_cond_rhs (gs
),
684 gimple_cond_true_label (gs
), gimple_cond_false_label (gs
));
687 if (!(flags
& TDF_RHS_ONLY
))
688 pp_string (buffer
, "if (");
689 dump_generic_node (buffer
, gimple_cond_lhs (gs
), spc
, flags
, false);
691 pp_string (buffer
, op_symbol_code (gimple_cond_code (gs
)));
693 dump_generic_node (buffer
, gimple_cond_rhs (gs
), spc
, flags
, false);
694 if (!(flags
& TDF_RHS_ONLY
))
696 pp_character (buffer
, ')');
698 if (gimple_cond_true_label (gs
))
700 pp_string (buffer
, " goto ");
701 dump_generic_node (buffer
, gimple_cond_true_label (gs
),
703 pp_semicolon (buffer
);
705 if (gimple_cond_false_label (gs
))
707 pp_string (buffer
, " else goto ");
708 dump_generic_node (buffer
, gimple_cond_false_label (gs
),
710 pp_semicolon (buffer
);
717 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
718 spaces of indent. FLAGS specifies details to show in the dump (see
719 TDF_* in tree-pass.h). */
722 dump_gimple_label (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
724 tree label
= gimple_label_label (gs
);
726 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
729 dump_generic_node (buffer
, label
, spc
, flags
, false);
730 pp_character (buffer
, ':');
732 if (DECL_NONLOCAL (label
))
733 pp_string (buffer
, " [non-local]");
734 if ((flags
& TDF_EH
) && EH_LANDING_PAD_NR (label
))
735 pp_printf (buffer
, " [LP %d]", EH_LANDING_PAD_NR (label
));
738 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
739 spaces of indent. FLAGS specifies details to show in the dump (see
740 TDF_* in tree-pass.h). */
743 dump_gimple_goto (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
745 tree label
= gimple_goto_dest (gs
);
747 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
749 dump_gimple_fmt (buffer
, spc
, flags
, "goto %T;", label
);
753 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
754 spaces of indent. FLAGS specifies details to show in the dump (see
755 TDF_* in tree-pass.h). */
758 dump_gimple_bind (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
761 dump_gimple_fmt (buffer
, spc
, flags
, "%G <", gs
);
763 pp_character (buffer
, '{');
764 if (!(flags
& TDF_SLIM
))
768 for (var
= gimple_bind_vars (gs
); var
; var
= TREE_CHAIN (var
))
770 newline_and_indent (buffer
, 2);
771 print_declaration (buffer
, var
, spc
, flags
);
773 if (gimple_bind_vars (gs
))
777 dump_gimple_seq (buffer
, gimple_bind_body (gs
), spc
+ 2, flags
);
778 newline_and_indent (buffer
, spc
);
780 pp_character (buffer
, '>');
782 pp_character (buffer
, '}');
786 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
787 indent. FLAGS specifies details to show in the dump (see TDF_* in
791 dump_gimple_try (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
796 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
797 type
= "GIMPLE_TRY_CATCH";
798 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
799 type
= "GIMPLE_TRY_FINALLY";
801 type
= "UNKNOWN GIMPLE_TRY";
802 dump_gimple_fmt (buffer
, spc
, flags
,
803 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs
, type
,
804 gimple_try_eval (gs
), gimple_try_cleanup (gs
));
808 pp_string (buffer
, "try");
809 newline_and_indent (buffer
, spc
+ 2);
810 pp_character (buffer
, '{');
813 dump_gimple_seq (buffer
, gimple_try_eval (gs
), spc
+ 4, flags
);
814 newline_and_indent (buffer
, spc
+ 2);
815 pp_character (buffer
, '}');
817 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
819 newline_and_indent (buffer
, spc
);
820 pp_string (buffer
, "catch");
821 newline_and_indent (buffer
, spc
+ 2);
822 pp_character (buffer
, '{');
824 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
826 newline_and_indent (buffer
, spc
);
827 pp_string (buffer
, "finally");
828 newline_and_indent (buffer
, spc
+ 2);
829 pp_character (buffer
, '{');
832 pp_string (buffer
, " <UNKNOWN GIMPLE_TRY> {");
835 dump_gimple_seq (buffer
, gimple_try_cleanup (gs
), spc
+ 4, flags
);
836 newline_and_indent (buffer
, spc
+ 2);
837 pp_character (buffer
, '}');
842 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
843 indent. FLAGS specifies details to show in the dump (see TDF_* in
847 dump_gimple_catch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
850 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+CATCH <%S>%->", gs
,
851 gimple_catch_types (gs
), gimple_catch_handler (gs
));
853 dump_gimple_fmt (buffer
, spc
, flags
, "catch (%T)%+{%S}",
854 gimple_catch_types (gs
), gimple_catch_handler (gs
));
858 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
859 indent. FLAGS specifies details to show in the dump (see TDF_* in
863 dump_gimple_eh_filter (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
866 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+FAILURE <%S>%->", gs
,
867 gimple_eh_filter_types (gs
),
868 gimple_eh_filter_failure (gs
));
870 dump_gimple_fmt (buffer
, spc
, flags
, "<<<eh_filter (%T)>>>%+{%+%S%-}",
871 gimple_eh_filter_types (gs
),
872 gimple_eh_filter_failure (gs
));
876 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
879 dump_gimple_eh_must_not_throw (pretty_printer
*buffer
, gimple gs
,
883 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
,
884 gimple_eh_must_not_throw_fndecl (gs
));
886 dump_gimple_fmt (buffer
, spc
, flags
, "<<<eh_must_not_throw (%T)>>>",
887 gimple_eh_must_not_throw_fndecl (gs
));
891 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
892 indent. FLAGS specifies details to show in the dump (see TDF_* in
896 dump_gimple_resx (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
899 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%d>", gs
,
900 gimple_resx_region (gs
));
902 dump_gimple_fmt (buffer
, spc
, flags
, "resx %d", gimple_resx_region (gs
));
905 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
908 dump_gimple_eh_dispatch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
911 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%d>", gs
,
912 gimple_eh_dispatch_region (gs
));
914 dump_gimple_fmt (buffer
, spc
, flags
, "eh_dispatch %d",
915 gimple_eh_dispatch_region (gs
));
918 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
919 of indent. FLAGS specifies details to show in the dump (see TDF_*
923 dump_gimple_debug (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
925 switch (gs
->gsbase
.subcode
)
927 case GIMPLE_DEBUG_BIND
:
929 dump_gimple_fmt (buffer
, spc
, flags
, "%G BIND <%T, %T>", gs
,
930 gimple_debug_bind_get_var (gs
),
931 gimple_debug_bind_get_value (gs
));
933 dump_gimple_fmt (buffer
, spc
, flags
, "# DEBUG %T => %T",
934 gimple_debug_bind_get_var (gs
),
935 gimple_debug_bind_get_value (gs
));
943 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
945 dump_gimple_omp_for (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
951 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
952 gimple_omp_body (gs
));
953 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
954 dump_gimple_fmt (buffer
, spc
, flags
, " >,");
955 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
956 dump_gimple_fmt (buffer
, spc
, flags
,
957 "%+%T, %T, %T, %s, %T,%n",
958 gimple_omp_for_index (gs
, i
),
959 gimple_omp_for_initial (gs
, i
),
960 gimple_omp_for_final (gs
, i
),
961 tree_code_name
[gimple_omp_for_cond (gs
, i
)],
962 gimple_omp_for_incr (gs
, i
));
963 dump_gimple_fmt (buffer
, spc
, flags
, "PRE_BODY <%S>%->",
964 gimple_omp_for_pre_body (gs
));
968 pp_string (buffer
, "#pragma omp for");
969 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
970 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
974 newline_and_indent (buffer
, spc
);
975 pp_string (buffer
, "for (");
976 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
978 pp_string (buffer
, " = ");
979 dump_generic_node (buffer
, gimple_omp_for_initial (gs
, i
), spc
,
981 pp_string (buffer
, "; ");
983 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
986 switch (gimple_omp_for_cond (gs
, i
))
989 pp_character (buffer
, '<');
992 pp_character (buffer
, '>');
995 pp_string (buffer
, "<=");
998 pp_string (buffer
, ">=");
1004 dump_generic_node (buffer
, gimple_omp_for_final (gs
, i
), spc
,
1006 pp_string (buffer
, "; ");
1008 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
1010 pp_string (buffer
, " = ");
1011 dump_generic_node (buffer
, gimple_omp_for_incr (gs
, i
), spc
,
1013 pp_character (buffer
, ')');
1016 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1018 newline_and_indent (buffer
, spc
+ 2);
1019 pp_character (buffer
, '{');
1020 pp_newline (buffer
);
1021 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1022 newline_and_indent (buffer
, spc
+ 2);
1023 pp_character (buffer
, '}');
1028 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1031 dump_gimple_omp_continue (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1033 if (flags
& TDF_RAW
)
1035 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
1036 gimple_omp_continue_control_def (gs
),
1037 gimple_omp_continue_control_use (gs
));
1041 pp_string (buffer
, "#pragma omp continue (");
1042 dump_generic_node (buffer
, gimple_omp_continue_control_def (gs
),
1044 pp_character (buffer
, ',');
1046 dump_generic_node (buffer
, gimple_omp_continue_control_use (gs
),
1048 pp_character (buffer
, ')');
1052 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1055 dump_gimple_omp_single (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1057 if (flags
& TDF_RAW
)
1059 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1060 gimple_omp_body (gs
));
1061 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
1062 dump_gimple_fmt (buffer
, spc
, flags
, " >");
1066 pp_string (buffer
, "#pragma omp single");
1067 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
1068 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1070 newline_and_indent (buffer
, spc
+ 2);
1071 pp_character (buffer
, '{');
1072 pp_newline (buffer
);
1073 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1074 newline_and_indent (buffer
, spc
+ 2);
1075 pp_character (buffer
, '}');
1080 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1083 dump_gimple_omp_sections (pretty_printer
*buffer
, gimple gs
, int spc
,
1086 if (flags
& TDF_RAW
)
1088 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1089 gimple_omp_body (gs
));
1090 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
1091 dump_gimple_fmt (buffer
, spc
, flags
, " >");
1095 pp_string (buffer
, "#pragma omp sections");
1096 if (gimple_omp_sections_control (gs
))
1098 pp_string (buffer
, " <");
1099 dump_generic_node (buffer
, gimple_omp_sections_control (gs
), spc
,
1101 pp_character (buffer
, '>');
1103 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
1104 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1106 newline_and_indent (buffer
, spc
+ 2);
1107 pp_character (buffer
, '{');
1108 pp_newline (buffer
);
1109 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1110 newline_and_indent (buffer
, spc
+ 2);
1111 pp_character (buffer
, '}');
1116 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the pretty_printer
1120 dump_gimple_omp_block (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1122 if (flags
& TDF_RAW
)
1123 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
1124 gimple_omp_body (gs
));
1127 switch (gimple_code (gs
))
1129 case GIMPLE_OMP_MASTER
:
1130 pp_string (buffer
, "#pragma omp master");
1132 case GIMPLE_OMP_ORDERED
:
1133 pp_string (buffer
, "#pragma omp ordered");
1135 case GIMPLE_OMP_SECTION
:
1136 pp_string (buffer
, "#pragma omp section");
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_CRITICAL tuple on the pretty_printer BUFFER. */
1156 dump_gimple_omp_critical (pretty_printer
*buffer
, gimple gs
, int spc
,
1159 if (flags
& TDF_RAW
)
1160 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
1161 gimple_omp_body (gs
));
1164 pp_string (buffer
, "#pragma omp critical");
1165 if (gimple_omp_critical_name (gs
))
1167 pp_string (buffer
, " (");
1168 dump_generic_node (buffer
, gimple_omp_critical_name (gs
), spc
,
1170 pp_character (buffer
, ')');
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_RETURN tuple on the pretty_printer BUFFER. */
1187 dump_gimple_omp_return (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1189 if (flags
& TDF_RAW
)
1191 dump_gimple_fmt (buffer
, spc
, flags
, "%G <nowait=%d>", gs
,
1192 (int) gimple_omp_return_nowait_p (gs
));
1196 pp_string (buffer
, "#pragma omp return");
1197 if (gimple_omp_return_nowait_p (gs
))
1198 pp_string (buffer
, "(nowait)");
1202 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1203 indent. FLAGS specifies details to show in the dump (see TDF_* in
1207 dump_gimple_asm (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1209 unsigned int i
, n
, f
, fields
;
1211 if (flags
& TDF_RAW
)
1213 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+STRING <%n%s%n>", gs
,
1214 gimple_asm_string (gs
));
1216 n
= gimple_asm_noutputs (gs
);
1219 newline_and_indent (buffer
, spc
+ 2);
1220 pp_string (buffer
, "OUTPUT: ");
1221 for (i
= 0; i
< n
; i
++)
1223 dump_generic_node (buffer
, gimple_asm_output_op (gs
, i
),
1226 pp_string (buffer
, ", ");
1230 n
= gimple_asm_ninputs (gs
);
1233 newline_and_indent (buffer
, spc
+ 2);
1234 pp_string (buffer
, "INPUT: ");
1235 for (i
= 0; i
< n
; i
++)
1237 dump_generic_node (buffer
, gimple_asm_input_op (gs
, i
),
1240 pp_string (buffer
, ", ");
1244 n
= gimple_asm_nclobbers (gs
);
1247 newline_and_indent (buffer
, spc
+ 2);
1248 pp_string (buffer
, "CLOBBER: ");
1249 for (i
= 0; i
< n
; i
++)
1251 dump_generic_node (buffer
, gimple_asm_clobber_op (gs
, i
),
1254 pp_string (buffer
, ", ");
1258 n
= gimple_asm_nlabels (gs
);
1261 newline_and_indent (buffer
, spc
+ 2);
1262 pp_string (buffer
, "LABEL: ");
1263 for (i
= 0; i
< n
; i
++)
1265 dump_generic_node (buffer
, gimple_asm_label_op (gs
, i
),
1268 pp_string (buffer
, ", ");
1272 newline_and_indent (buffer
, spc
);
1273 pp_character (buffer
, '>');
1277 pp_string (buffer
, "__asm__");
1278 if (gimple_asm_volatile_p (gs
))
1279 pp_string (buffer
, " __volatile__");
1280 if (gimple_asm_nlabels (gs
))
1281 pp_string (buffer
, " goto");
1282 pp_string (buffer
, "(\"");
1283 pp_string (buffer
, gimple_asm_string (gs
));
1284 pp_string (buffer
, "\"");
1286 if (gimple_asm_nlabels (gs
))
1288 else if (gimple_asm_nclobbers (gs
))
1290 else if (gimple_asm_ninputs (gs
))
1292 else if (gimple_asm_noutputs (gs
))
1297 for (f
= 0; f
< fields
; ++f
)
1299 pp_string (buffer
, " : ");
1304 n
= gimple_asm_noutputs (gs
);
1305 for (i
= 0; i
< n
; i
++)
1307 dump_generic_node (buffer
, gimple_asm_output_op (gs
, i
),
1310 pp_string (buffer
, ", ");
1315 n
= gimple_asm_ninputs (gs
);
1316 for (i
= 0; i
< n
; i
++)
1318 dump_generic_node (buffer
, gimple_asm_input_op (gs
, i
),
1321 pp_string (buffer
, ", ");
1326 n
= gimple_asm_nclobbers (gs
);
1327 for (i
= 0; i
< n
; i
++)
1329 dump_generic_node (buffer
, gimple_asm_clobber_op (gs
, i
),
1332 pp_string (buffer
, ", ");
1337 n
= gimple_asm_nlabels (gs
);
1338 for (i
= 0; i
< n
; i
++)
1340 dump_generic_node (buffer
, gimple_asm_label_op (gs
, i
),
1343 pp_string (buffer
, ", ");
1352 pp_string (buffer
, ");");
1357 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in
1358 dump_gimple_stmt. */
1361 dump_gimple_phi (pretty_printer
*buffer
, gimple phi
, int spc
, int flags
)
1364 tree lhs
= gimple_phi_result (phi
);
1366 if (flags
& TDF_ALIAS
1367 && POINTER_TYPE_P (TREE_TYPE (lhs
))
1368 && SSA_NAME_PTR_INFO (lhs
))
1370 pp_string (buffer
, "PT = ");
1371 pp_points_to_solution (buffer
, &SSA_NAME_PTR_INFO (lhs
)->pt
);
1372 newline_and_indent (buffer
, spc
);
1373 pp_string (buffer
, "# ");
1376 if (flags
& TDF_RAW
)
1377 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", phi
,
1378 gimple_phi_result (phi
));
1381 dump_generic_node (buffer
, lhs
, spc
, flags
, false);
1382 pp_string (buffer
, " = PHI <");
1384 for (i
= 0; i
< gimple_phi_num_args (phi
); i
++)
1386 if ((flags
& TDF_LINENO
) && gimple_phi_arg_has_location (phi
, i
))
1388 expanded_location xloc
;
1390 xloc
= expand_location (gimple_phi_arg_location (phi
, i
));
1391 pp_character (buffer
, '[');
1394 pp_string (buffer
, xloc
.file
);
1395 pp_string (buffer
, " : ");
1397 pp_decimal_int (buffer
, xloc
.line
);
1398 pp_string (buffer
, ":");
1399 pp_decimal_int (buffer
, xloc
.column
);
1400 pp_string (buffer
, "] ");
1402 dump_generic_node (buffer
, gimple_phi_arg_def (phi
, i
), spc
, flags
,
1404 pp_character (buffer
, '(');
1405 pp_decimal_int (buffer
, gimple_phi_arg_edge (phi
, i
)->src
->index
);
1406 pp_character (buffer
, ')');
1407 if (i
< gimple_phi_num_args (phi
) - 1)
1408 pp_string (buffer
, ", ");
1410 pp_character (buffer
, '>');
1414 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1415 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1419 dump_gimple_omp_parallel (pretty_printer
*buffer
, gimple gs
, int spc
,
1422 if (flags
& TDF_RAW
)
1424 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1425 gimple_omp_body (gs
));
1426 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
1427 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T%n>",
1428 gimple_omp_parallel_child_fn (gs
),
1429 gimple_omp_parallel_data_arg (gs
));
1434 pp_string (buffer
, "#pragma omp parallel");
1435 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
1436 if (gimple_omp_parallel_child_fn (gs
))
1438 pp_string (buffer
, " [child fn: ");
1439 dump_generic_node (buffer
, gimple_omp_parallel_child_fn (gs
),
1441 pp_string (buffer
, " (");
1442 if (gimple_omp_parallel_data_arg (gs
))
1443 dump_generic_node (buffer
, gimple_omp_parallel_data_arg (gs
),
1446 pp_string (buffer
, "???");
1447 pp_string (buffer
, ")]");
1449 body
= gimple_omp_body (gs
);
1450 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
1452 newline_and_indent (buffer
, spc
+ 2);
1453 pp_character (buffer
, '{');
1454 pp_newline (buffer
);
1455 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
1456 newline_and_indent (buffer
, spc
+ 2);
1457 pp_character (buffer
, '}');
1461 pp_newline (buffer
);
1462 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
1468 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1469 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1473 dump_gimple_omp_task (pretty_printer
*buffer
, gimple gs
, int spc
,
1476 if (flags
& TDF_RAW
)
1478 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1479 gimple_omp_body (gs
));
1480 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
1481 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T, %T, %T, %T%n>",
1482 gimple_omp_task_child_fn (gs
),
1483 gimple_omp_task_data_arg (gs
),
1484 gimple_omp_task_copy_fn (gs
),
1485 gimple_omp_task_arg_size (gs
),
1486 gimple_omp_task_arg_size (gs
));
1491 pp_string (buffer
, "#pragma omp task");
1492 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
1493 if (gimple_omp_task_child_fn (gs
))
1495 pp_string (buffer
, " [child fn: ");
1496 dump_generic_node (buffer
, gimple_omp_task_child_fn (gs
),
1498 pp_string (buffer
, " (");
1499 if (gimple_omp_task_data_arg (gs
))
1500 dump_generic_node (buffer
, gimple_omp_task_data_arg (gs
),
1503 pp_string (buffer
, "???");
1504 pp_string (buffer
, ")]");
1506 body
= gimple_omp_body (gs
);
1507 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
1509 newline_and_indent (buffer
, spc
+ 2);
1510 pp_character (buffer
, '{');
1511 pp_newline (buffer
);
1512 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
1513 newline_and_indent (buffer
, spc
+ 2);
1514 pp_character (buffer
, '}');
1518 pp_newline (buffer
);
1519 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
1525 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1526 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1530 dump_gimple_omp_atomic_load (pretty_printer
*buffer
, gimple gs
, int spc
,
1533 if (flags
& TDF_RAW
)
1535 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
1536 gimple_omp_atomic_load_lhs (gs
),
1537 gimple_omp_atomic_load_rhs (gs
));
1541 pp_string (buffer
, "#pragma omp atomic_load");
1542 newline_and_indent (buffer
, spc
+ 2);
1543 dump_generic_node (buffer
, gimple_omp_atomic_load_lhs (gs
),
1546 pp_character (buffer
, '=');
1548 pp_character (buffer
, '*');
1549 dump_generic_node (buffer
, gimple_omp_atomic_load_rhs (gs
),
1554 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1555 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1559 dump_gimple_omp_atomic_store (pretty_printer
*buffer
, gimple gs
, int spc
,
1562 if (flags
& TDF_RAW
)
1564 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
,
1565 gimple_omp_atomic_store_val (gs
));
1569 pp_string (buffer
, "#pragma omp atomic_store (");
1570 dump_generic_node (buffer
, gimple_omp_atomic_store_val (gs
),
1572 pp_character (buffer
, ')');
1577 /* Dump all the memory operands for statement GS. BUFFER, SPC and
1578 FLAGS are as in dump_gimple_stmt. */
1581 dump_gimple_mem_ops (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1583 tree vdef
= gimple_vdef (gs
);
1584 tree vuse
= gimple_vuse (gs
);
1586 if (!ssa_operands_active () || !gimple_references_memory_p (gs
))
1589 if (vdef
!= NULL_TREE
)
1591 pp_string (buffer
, "# ");
1592 dump_generic_node (buffer
, vdef
, spc
+ 2, flags
, false);
1593 pp_string (buffer
, " = VDEF <");
1594 dump_generic_node (buffer
, vuse
, spc
+ 2, flags
, false);
1595 pp_character (buffer
, '>');
1596 newline_and_indent (buffer
, spc
);
1598 else if (vuse
!= NULL_TREE
)
1600 pp_string (buffer
, "# VUSE <");
1601 dump_generic_node (buffer
, vuse
, spc
+ 2, flags
, false);
1602 pp_character (buffer
, '>');
1603 newline_and_indent (buffer
, spc
);
1608 /* Dump the gimple statement GS on the pretty printer BUFFER, SPC
1609 spaces of indent. FLAGS specifies details to show in the dump (see
1610 TDF_* in tree-pass.h). */
1613 dump_gimple_stmt (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1618 if (flags
& TDF_STMTADDR
)
1619 pp_printf (buffer
, "<&%p> ", (void *) gs
);
1621 if ((flags
& TDF_LINENO
) && gimple_has_location (gs
))
1623 expanded_location xloc
= expand_location (gimple_location (gs
));
1624 pp_character (buffer
, '[');
1627 pp_string (buffer
, xloc
.file
);
1628 pp_string (buffer
, " : ");
1630 pp_decimal_int (buffer
, xloc
.line
);
1631 pp_string (buffer
, ":");
1632 pp_decimal_int (buffer
, xloc
.column
);
1633 pp_string (buffer
, "] ");
1638 int lp_nr
= lookup_stmt_eh_lp (gs
);
1640 pp_printf (buffer
, "[LP %d] ", lp_nr
);
1642 pp_printf (buffer
, "[MNT %d] ", -lp_nr
);
1645 if ((flags
& (TDF_VOPS
|TDF_MEMSYMS
))
1646 && gimple_has_mem_ops (gs
))
1647 dump_gimple_mem_ops (buffer
, gs
, spc
, flags
);
1649 if ((flags
& TDF_ALIAS
)
1650 && gimple_has_lhs (gs
))
1652 tree lhs
= gimple_get_lhs (gs
);
1653 if (TREE_CODE (lhs
) == SSA_NAME
1654 && POINTER_TYPE_P (TREE_TYPE (lhs
))
1655 && SSA_NAME_PTR_INFO (lhs
))
1657 pp_string (buffer
, "# PT = ");
1658 pp_points_to_solution (buffer
, &SSA_NAME_PTR_INFO (lhs
)->pt
);
1659 newline_and_indent (buffer
, spc
);
1663 switch (gimple_code (gs
))
1666 dump_gimple_asm (buffer
, gs
, spc
, flags
);
1670 dump_gimple_assign (buffer
, gs
, spc
, flags
);
1674 dump_gimple_bind (buffer
, gs
, spc
, flags
);
1678 dump_gimple_call (buffer
, gs
, spc
, flags
);
1682 dump_gimple_cond (buffer
, gs
, spc
, flags
);
1686 dump_gimple_label (buffer
, gs
, spc
, flags
);
1690 dump_gimple_goto (buffer
, gs
, spc
, flags
);
1694 pp_string (buffer
, "GIMPLE_NOP");
1698 dump_gimple_return (buffer
, gs
, spc
, flags
);
1702 dump_gimple_switch (buffer
, gs
, spc
, flags
);
1706 dump_gimple_try (buffer
, gs
, spc
, flags
);
1710 dump_gimple_phi (buffer
, gs
, spc
, flags
);
1713 case GIMPLE_OMP_PARALLEL
:
1714 dump_gimple_omp_parallel (buffer
, gs
, spc
, flags
);
1717 case GIMPLE_OMP_TASK
:
1718 dump_gimple_omp_task (buffer
, gs
, spc
, flags
);
1721 case GIMPLE_OMP_ATOMIC_LOAD
:
1722 dump_gimple_omp_atomic_load (buffer
, gs
, spc
, flags
);
1726 case GIMPLE_OMP_ATOMIC_STORE
:
1727 dump_gimple_omp_atomic_store (buffer
, gs
, spc
, flags
);
1730 case GIMPLE_OMP_FOR
:
1731 dump_gimple_omp_for (buffer
, gs
, spc
, flags
);
1734 case GIMPLE_OMP_CONTINUE
:
1735 dump_gimple_omp_continue (buffer
, gs
, spc
, flags
);
1738 case GIMPLE_OMP_SINGLE
:
1739 dump_gimple_omp_single (buffer
, gs
, spc
, flags
);
1742 case GIMPLE_OMP_RETURN
:
1743 dump_gimple_omp_return (buffer
, gs
, spc
, flags
);
1746 case GIMPLE_OMP_SECTIONS
:
1747 dump_gimple_omp_sections (buffer
, gs
, spc
, flags
);
1750 case GIMPLE_OMP_SECTIONS_SWITCH
:
1751 pp_string (buffer
, "GIMPLE_SECTIONS_SWITCH");
1754 case GIMPLE_OMP_MASTER
:
1755 case GIMPLE_OMP_ORDERED
:
1756 case GIMPLE_OMP_SECTION
:
1757 dump_gimple_omp_block (buffer
, gs
, spc
, flags
);
1760 case GIMPLE_OMP_CRITICAL
:
1761 dump_gimple_omp_critical (buffer
, gs
, spc
, flags
);
1765 dump_gimple_catch (buffer
, gs
, spc
, flags
);
1768 case GIMPLE_EH_FILTER
:
1769 dump_gimple_eh_filter (buffer
, gs
, spc
, flags
);
1772 case GIMPLE_EH_MUST_NOT_THROW
:
1773 dump_gimple_eh_must_not_throw (buffer
, gs
, spc
, flags
);
1777 dump_gimple_resx (buffer
, gs
, spc
, flags
);
1780 case GIMPLE_EH_DISPATCH
:
1781 dump_gimple_eh_dispatch (buffer
, gs
, spc
, flags
);
1785 dump_gimple_debug (buffer
, gs
, spc
, flags
);
1788 case GIMPLE_PREDICT
:
1789 pp_string (buffer
, "// predicted ");
1790 if (gimple_predict_outcome (gs
))
1791 pp_string (buffer
, "likely by ");
1793 pp_string (buffer
, "unlikely by ");
1794 pp_string (buffer
, predictor_name (gimple_predict_predictor (gs
)));
1795 pp_string (buffer
, " predictor.");
1802 /* If we're building a diagnostic, the formatted text will be
1803 written into BUFFER's stream by the caller; otherwise, write it
1805 if (!(flags
& TDF_DIAGNOSTIC
))
1806 pp_write_text_to_stream (buffer
);
1810 /* Dumps header of basic block BB to buffer BUFFER indented by INDENT
1811 spaces and details described by flags. */
1814 dump_bb_header (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1820 if (flags
& TDF_BLOCKS
)
1823 pp_string (buffer
, "# BLOCK ");
1824 pp_decimal_int (buffer
, bb
->index
);
1827 pp_string (buffer
, " freq:");
1828 pp_decimal_int (buffer
, bb
->frequency
);
1832 pp_string (buffer
, " count:");
1833 pp_widest_integer (buffer
, bb
->count
);
1836 if (flags
& TDF_LINENO
)
1838 gimple_stmt_iterator gsi
;
1840 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
1841 if (!is_gimple_debug (gsi_stmt (gsi
))
1842 && get_lineno (gsi_stmt (gsi
)) != UNKNOWN_LOCATION
)
1844 pp_string (buffer
, ", starting at line ");
1845 pp_decimal_int (buffer
, get_lineno (gsi_stmt (gsi
)));
1849 if (bb
->discriminator
)
1851 pp_string (buffer
, ", discriminator ");
1852 pp_decimal_int (buffer
, bb
->discriminator
);
1855 newline_and_indent (buffer
, indent
);
1857 pp_string (buffer
, "# PRED:");
1858 pp_write_text_to_stream (buffer
);
1859 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
1860 if (flags
& TDF_SLIM
)
1862 pp_character (buffer
, ' ');
1863 if (e
->src
== ENTRY_BLOCK_PTR
)
1864 pp_string (buffer
, "ENTRY");
1866 pp_decimal_int (buffer
, e
->src
->index
);
1869 dump_edge_info (buffer
->buffer
->stream
, e
, 0);
1870 pp_newline (buffer
);
1874 stmt
= first_stmt (bb
);
1875 if (!stmt
|| gimple_code (stmt
) != GIMPLE_LABEL
)
1877 INDENT (indent
- 2);
1878 pp_string (buffer
, "<bb ");
1879 pp_decimal_int (buffer
, bb
->index
);
1880 pp_string (buffer
, ">:");
1881 pp_newline (buffer
);
1884 pp_write_text_to_stream (buffer
);
1885 check_bb_profile (bb
, buffer
->buffer
->stream
);
1889 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
1893 dump_bb_end (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1899 pp_string (buffer
, "# SUCC:");
1900 pp_write_text_to_stream (buffer
);
1901 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
1902 if (flags
& TDF_SLIM
)
1904 pp_character (buffer
, ' ');
1905 if (e
->dest
== EXIT_BLOCK_PTR
)
1906 pp_string (buffer
, "EXIT");
1908 pp_decimal_int (buffer
, e
->dest
->index
);
1911 dump_edge_info (buffer
->buffer
->stream
, e
, 1);
1912 pp_newline (buffer
);
1916 /* Dump PHI nodes of basic block BB to BUFFER with details described
1917 by FLAGS and indented by INDENT spaces. */
1920 dump_phi_nodes (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1922 gimple_stmt_iterator i
;
1924 for (i
= gsi_start_phis (bb
); !gsi_end_p (i
); gsi_next (&i
))
1926 gimple phi
= gsi_stmt (i
);
1927 if (is_gimple_reg (gimple_phi_result (phi
)) || (flags
& TDF_VOPS
))
1930 pp_string (buffer
, "# ");
1931 dump_gimple_phi (buffer
, phi
, indent
, flags
);
1932 pp_newline (buffer
);
1938 /* Dump jump to basic block BB that is represented implicitly in the cfg
1942 pp_cfg_jump (pretty_printer
*buffer
, basic_block bb
)
1946 stmt
= first_stmt (bb
);
1948 pp_string (buffer
, "goto <bb ");
1949 pp_decimal_int (buffer
, bb
->index
);
1950 pp_character (buffer
, '>');
1951 if (stmt
&& gimple_code (stmt
) == GIMPLE_LABEL
)
1953 pp_string (buffer
, " (");
1954 dump_generic_node (buffer
, gimple_label_label (stmt
), 0, 0, false);
1955 pp_character (buffer
, ')');
1956 pp_semicolon (buffer
);
1959 pp_semicolon (buffer
);
1963 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
1964 by INDENT spaces, with details given by FLAGS. */
1967 dump_implicit_edges (pretty_printer
*buffer
, basic_block bb
, int indent
,
1974 stmt
= last_stmt (bb
);
1976 if (stmt
&& gimple_code (stmt
) == GIMPLE_COND
)
1978 edge true_edge
, false_edge
;
1980 /* When we are emitting the code or changing CFG, it is possible that
1981 the edges are not yet created. When we are using debug_bb in such
1982 a situation, we do not want it to crash. */
1983 if (EDGE_COUNT (bb
->succs
) != 2)
1985 extract_true_false_edges_from_block (bb
, &true_edge
, &false_edge
);
1987 INDENT (indent
+ 2);
1988 pp_cfg_jump (buffer
, true_edge
->dest
);
1989 newline_and_indent (buffer
, indent
);
1990 pp_string (buffer
, "else");
1991 newline_and_indent (buffer
, indent
+ 2);
1992 pp_cfg_jump (buffer
, false_edge
->dest
);
1993 pp_newline (buffer
);
1997 /* If there is a fallthru edge, we may need to add an artificial
1998 goto to the dump. */
1999 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
2000 if (e
->flags
& EDGE_FALLTHRU
)
2003 if (e
&& e
->dest
!= bb
->next_bb
)
2007 if ((flags
& TDF_LINENO
)
2008 && e
->goto_locus
!= UNKNOWN_LOCATION
2011 expanded_location goto_xloc
;
2012 goto_xloc
= expand_location (e
->goto_locus
);
2013 pp_character (buffer
, '[');
2016 pp_string (buffer
, goto_xloc
.file
);
2017 pp_string (buffer
, " : ");
2019 pp_decimal_int (buffer
, goto_xloc
.line
);
2020 pp_string (buffer
, " : ");
2021 pp_decimal_int (buffer
, goto_xloc
.column
);
2022 pp_string (buffer
, "] ");
2025 pp_cfg_jump (buffer
, e
->dest
);
2026 pp_newline (buffer
);
2031 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2032 indented by INDENT spaces. */
2035 gimple_dump_bb_buff (pretty_printer
*buffer
, basic_block bb
, int indent
,
2038 gimple_stmt_iterator gsi
;
2040 int label_indent
= indent
- 2;
2042 if (label_indent
< 0)
2045 dump_bb_header (buffer
, bb
, indent
, flags
);
2046 dump_phi_nodes (buffer
, bb
, indent
, flags
);
2048 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
2052 stmt
= gsi_stmt (gsi
);
2054 curr_indent
= gimple_code (stmt
) == GIMPLE_LABEL
? label_indent
: indent
;
2056 INDENT (curr_indent
);
2057 dump_gimple_stmt (buffer
, stmt
, curr_indent
, flags
);
2058 pp_newline (buffer
);
2059 dump_histograms_for_stmt (cfun
, buffer
->buffer
->stream
, stmt
);
2062 dump_implicit_edges (buffer
, bb
, indent
, flags
);
2064 if (flags
& TDF_BLOCKS
)
2065 dump_bb_end (buffer
, bb
, indent
, flags
);
2069 /* Dumps basic block BB to FILE with details described by FLAGS and
2070 indented by INDENT spaces. */
2073 gimple_dump_bb (basic_block bb
, FILE *file
, int indent
, int flags
)
2075 maybe_init_pretty_print (file
);
2076 gimple_dump_bb_buff (&buffer
, bb
, indent
, flags
);