1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
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
:
260 pp_string (buffer
, "(");
261 dump_generic_node (buffer
, TREE_TYPE (lhs
), spc
, flags
, false);
262 pp_string (buffer
, ") ");
263 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
267 pp_string (buffer
, "((");
268 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
269 pp_string (buffer
, "))");
273 pp_string (buffer
, "ABS_EXPR <");
274 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
275 pp_string (buffer
, ">");
279 if (TREE_CODE_CLASS (rhs_code
) == tcc_declaration
280 || TREE_CODE_CLASS (rhs_code
) == tcc_constant
281 || TREE_CODE_CLASS (rhs_code
) == tcc_reference
282 || rhs_code
== SSA_NAME
283 || rhs_code
== ADDR_EXPR
284 || rhs_code
== CONSTRUCTOR
)
286 else if (rhs_code
== BIT_NOT_EXPR
)
287 pp_string (buffer
, "~");
288 else if (rhs_code
== TRUTH_NOT_EXPR
)
289 pp_string (buffer
, "!");
290 else if (rhs_code
== NEGATE_EXPR
)
291 pp_string (buffer
, "-");
294 pp_string (buffer
, "[");
295 pp_string (buffer
, tree_code_name
[rhs_code
]);
296 pp_string (buffer
, "] ");
299 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
305 /* Helper for dump_gimple_assign. Print the binary RHS of the
306 assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */
309 dump_binary_rhs (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
311 switch (gimple_assign_rhs_code (gs
))
314 pp_string (buffer
, "COMPLEX_EXPR <");
315 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
316 pp_string (buffer
, ", ");
317 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
318 pp_string (buffer
, ">");
322 pp_string (buffer
, "MIN_EXPR <");
323 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
324 pp_string (buffer
, ", ");
325 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
326 pp_string (buffer
, ">");
330 pp_string (buffer
, "MAX_EXPR <");
331 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
332 pp_string (buffer
, ", ");
333 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
334 pp_string (buffer
, ">");
338 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
340 pp_string (buffer
, op_symbol_code (gimple_assign_rhs_code (gs
)));
342 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
347 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
351 dump_gimple_assign (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
356 if (gimple_num_ops (gs
) == 2)
358 else if (gimple_num_ops (gs
) == 3)
359 last
= gimple_assign_rhs2 (gs
);
363 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T>", gs
,
364 tree_code_name
[gimple_assign_rhs_code (gs
)],
365 gimple_assign_lhs (gs
), gimple_assign_rhs1 (gs
), last
);
369 if (!(flags
& TDF_RHS_ONLY
))
371 dump_generic_node (buffer
, gimple_assign_lhs (gs
), spc
, flags
, false);
373 pp_character (buffer
, '=');
375 if (gimple_assign_nontemporal_move_p (gs
))
376 pp_string (buffer
, "{nt}");
378 if (gimple_has_volatile_ops (gs
))
379 pp_string (buffer
, "{v}");
384 if (gimple_num_ops (gs
) == 2)
385 dump_unary_rhs (buffer
, gs
, spc
, flags
);
386 else if (gimple_num_ops (gs
) == 3)
387 dump_binary_rhs (buffer
, gs
, spc
, flags
);
390 if (!(flags
& TDF_RHS_ONLY
))
391 pp_semicolon(buffer
);
396 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
400 dump_gimple_return (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
404 t
= gimple_return_retval (gs
);
406 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, t
);
409 pp_string (buffer
, "return");
413 dump_generic_node (buffer
, t
, spc
, flags
, false);
415 pp_semicolon (buffer
);
420 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
424 dump_gimple_call_args (pretty_printer
*buffer
, gimple gs
, int flags
)
428 for (i
= 0; i
< gimple_call_num_args (gs
); i
++)
430 dump_generic_node (buffer
, gimple_call_arg (gs
, i
), 0, flags
, false);
431 if (i
< gimple_call_num_args (gs
) - 1)
432 pp_string (buffer
, ", ");
435 if (gimple_call_va_arg_pack_p (gs
))
437 if (gimple_call_num_args (gs
) > 0)
439 pp_character (buffer
, ',');
443 pp_string (buffer
, "__builtin_va_arg_pack ()");
448 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
452 dump_gimple_call (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
454 tree lhs
= gimple_call_lhs (gs
);
458 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T",
459 gs
, gimple_call_fn (gs
), lhs
);
460 if (gimple_call_num_args (gs
) > 0)
462 pp_string (buffer
, ", ");
463 dump_gimple_call_args (buffer
, gs
, flags
);
465 pp_string (buffer
, ">");
469 if (lhs
&& !(flags
& TDF_RHS_ONLY
))
471 dump_generic_node (buffer
, lhs
, spc
, flags
, false);
472 pp_string (buffer
, " =");
474 if (gimple_has_volatile_ops (gs
))
475 pp_string (buffer
, "{v}");
479 dump_generic_node (buffer
, gimple_call_fn (gs
), spc
, flags
, false);
480 pp_string (buffer
, " (");
481 dump_gimple_call_args (buffer
, gs
, flags
);
482 pp_string (buffer
, ")");
483 if (!(flags
& TDF_RHS_ONLY
))
484 pp_semicolon (buffer
);
487 if (gimple_call_chain (gs
))
489 pp_string (buffer
, " [static-chain: ");
490 dump_generic_node (buffer
, gimple_call_chain (gs
), spc
, flags
, false);
491 pp_character (buffer
, ']');
494 if (gimple_call_return_slot_opt_p (gs
))
495 pp_string (buffer
, " [return slot optimization]");
497 if (gimple_call_tail_p (gs
))
498 pp_string (buffer
, " [tail call]");
502 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
506 dump_gimple_switch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
510 GIMPLE_CHECK (gs
, GIMPLE_SWITCH
);
512 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", gs
,
513 gimple_switch_index (gs
));
516 pp_string (buffer
, "switch (");
517 dump_generic_node (buffer
, gimple_switch_index (gs
), spc
, flags
, true);
518 pp_string (buffer
, ") <");
521 for (i
= 0; i
< gimple_switch_num_labels (gs
); i
++)
523 tree case_label
= gimple_switch_label (gs
, i
);
524 if (case_label
== NULL_TREE
)
527 dump_generic_node (buffer
, case_label
, spc
, flags
, false);
528 pp_string (buffer
, " ");
529 dump_generic_node (buffer
, CASE_LABEL (case_label
), spc
, flags
, false);
530 if (i
< gimple_switch_num_labels (gs
) - 1)
531 pp_string (buffer
, ", ");
533 pp_string (buffer
, ">");
537 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
541 dump_gimple_cond (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
544 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T, %T>", gs
,
545 tree_code_name
[gimple_cond_code (gs
)],
546 gimple_cond_lhs (gs
), gimple_cond_rhs (gs
),
547 gimple_cond_true_label (gs
), gimple_cond_false_label (gs
));
550 if (!(flags
& TDF_RHS_ONLY
))
551 pp_string (buffer
, "if (");
552 dump_generic_node (buffer
, gimple_cond_lhs (gs
), spc
, flags
, false);
554 pp_string (buffer
, op_symbol_code (gimple_cond_code (gs
)));
556 dump_generic_node (buffer
, gimple_cond_rhs (gs
), spc
, flags
, false);
557 if (!(flags
& TDF_RHS_ONLY
))
559 pp_string (buffer
, ")");
561 if (gimple_cond_true_label (gs
))
563 pp_string (buffer
, " goto ");
564 dump_generic_node (buffer
, gimple_cond_true_label (gs
),
566 pp_semicolon (buffer
);
568 if (gimple_cond_false_label (gs
))
570 pp_string (buffer
, " else goto ");
571 dump_generic_node (buffer
, gimple_cond_false_label (gs
),
573 pp_semicolon (buffer
);
580 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
581 spaces of indent. FLAGS specifies details to show in the dump (see
582 TDF_* in tree-pass.h). */
585 dump_gimple_label (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
587 tree label
= gimple_label_label (gs
);
589 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
592 dump_generic_node (buffer
, label
, spc
, flags
, false);
593 pp_string (buffer
, ":");
595 if (DECL_NONLOCAL (label
))
596 pp_string (buffer
, " [non-local]");
599 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
600 spaces of indent. FLAGS specifies details to show in the dump (see
601 TDF_* in tree-pass.h). */
604 dump_gimple_goto (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
606 tree label
= gimple_goto_dest (gs
);
608 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
610 dump_gimple_fmt (buffer
, spc
, flags
, "goto %T;", label
);
614 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
615 spaces of indent. FLAGS specifies details to show in the dump (see
616 TDF_* in tree-pass.h). */
619 dump_gimple_bind (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
622 dump_gimple_fmt (buffer
, spc
, flags
, "%G <", gs
);
624 pp_character (buffer
, '{');
625 if (!(flags
& TDF_SLIM
))
629 for (var
= gimple_bind_vars (gs
); var
; var
= TREE_CHAIN (var
))
631 newline_and_indent (buffer
, 2);
632 print_declaration (buffer
, var
, spc
, flags
);
634 if (gimple_bind_vars (gs
))
638 dump_gimple_seq (buffer
, gimple_bind_body (gs
), spc
+ 2, flags
);
639 newline_and_indent (buffer
, spc
);
641 pp_character (buffer
, '>');
643 pp_character (buffer
, '}');
647 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
648 indent. FLAGS specifies details to show in the dump (see TDF_* in
652 dump_gimple_try (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
657 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
658 type
= "GIMPLE_TRY_CATCH";
659 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
660 type
= "GIMPLE_TRY_FINALLY";
662 type
= "UNKNOWN GIMPLE_TRY";
663 dump_gimple_fmt (buffer
, spc
, flags
,
664 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs
, type
,
665 gimple_try_eval (gs
), gimple_try_cleanup (gs
));
669 pp_string (buffer
, "try");
670 newline_and_indent (buffer
, spc
+ 2);
671 pp_string (buffer
, "{");
674 dump_gimple_seq (buffer
, gimple_try_eval (gs
), spc
+ 4, flags
);
675 newline_and_indent (buffer
, spc
+ 2);
676 pp_string (buffer
, "}");
678 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
680 newline_and_indent (buffer
, spc
);
681 pp_string (buffer
, "catch");
682 newline_and_indent (buffer
, spc
+ 2);
683 pp_string (buffer
, "{");
685 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
687 newline_and_indent (buffer
, spc
);
688 pp_string (buffer
, "finally");
689 newline_and_indent (buffer
, spc
+ 2);
690 pp_string (buffer
, "{");
693 pp_string (buffer
, " <UNKNOWN GIMPLE_TRY> {");
696 dump_gimple_seq (buffer
, gimple_try_cleanup (gs
), spc
+ 4, flags
);
697 newline_and_indent (buffer
, spc
+ 2);
698 pp_character (buffer
, '}');
703 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
704 indent. FLAGS specifies details to show in the dump (see TDF_* in
708 dump_gimple_catch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
711 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+CATCH <%S>%->", gs
,
712 gimple_catch_types (gs
), gimple_catch_handler (gs
));
714 dump_gimple_fmt (buffer
, spc
, flags
, "catch (%T)%+{%S}",
715 gimple_catch_types (gs
), gimple_catch_handler (gs
));
719 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
720 indent. FLAGS specifies details to show in the dump (see TDF_* in
724 dump_gimple_eh_filter (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
727 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+FAILURE <%S>%->", gs
,
728 gimple_eh_filter_types (gs
),
729 gimple_eh_filter_failure (gs
));
731 dump_gimple_fmt (buffer
, spc
, flags
, "<<<eh_filter (%T)>>>%+{%+%S%-}",
732 gimple_eh_filter_types (gs
),
733 gimple_eh_filter_failure (gs
));
737 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
738 indent. FLAGS specifies details to show in the dump (see TDF_* in
742 dump_gimple_resx (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
745 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%d>", gs
,
746 gimple_resx_region (gs
));
748 dump_gimple_fmt (buffer
, spc
, flags
, "resx %d", gimple_resx_region (gs
));
751 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
753 dump_gimple_omp_for (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
759 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
760 gimple_omp_body (gs
));
761 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
762 dump_gimple_fmt (buffer
, spc
, flags
, " >,");
763 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
764 dump_gimple_fmt (buffer
, spc
, flags
,
765 "%+%T, %T, %T, %s, %T,%n",
766 gimple_omp_for_index (gs
, i
),
767 gimple_omp_for_initial (gs
, i
),
768 gimple_omp_for_final (gs
, i
),
769 tree_code_name
[gimple_omp_for_cond (gs
, i
)],
770 gimple_omp_for_incr (gs
, i
));
771 dump_gimple_fmt (buffer
, spc
, flags
, "PRE_BODY <%S>%->",
772 gimple_omp_for_pre_body (gs
));
776 pp_string (buffer
, "#pragma omp for");
777 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
778 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
782 newline_and_indent (buffer
, spc
);
783 pp_string (buffer
, "for (");
784 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
786 pp_string (buffer
, " = ");
787 dump_generic_node (buffer
, gimple_omp_for_initial (gs
, i
), spc
,
789 pp_string (buffer
, "; ");
791 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
794 switch (gimple_omp_for_cond (gs
, i
))
797 pp_character (buffer
, '<');
800 pp_character (buffer
, '>');
803 pp_string (buffer
, "<=");
806 pp_string (buffer
, ">=");
812 dump_generic_node (buffer
, gimple_omp_for_final (gs
, i
), spc
,
814 pp_string (buffer
, "; ");
816 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
818 pp_string (buffer
, " = ");
819 dump_generic_node (buffer
, gimple_omp_for_incr (gs
, i
), spc
,
821 pp_character (buffer
, ')');
824 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
826 newline_and_indent (buffer
, spc
+ 2);
827 pp_character (buffer
, '{');
829 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
830 newline_and_indent (buffer
, spc
+ 2);
831 pp_character (buffer
, '}');
836 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
839 dump_gimple_omp_continue (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
843 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
844 gimple_omp_continue_control_def (gs
),
845 gimple_omp_continue_control_use (gs
));
849 pp_string (buffer
, "#pragma omp continue (");
850 dump_generic_node (buffer
, gimple_omp_continue_control_def (gs
),
852 pp_character (buffer
, ',');
854 dump_generic_node (buffer
, gimple_omp_continue_control_use (gs
),
856 pp_character (buffer
, ')');
860 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
863 dump_gimple_omp_single (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
867 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
868 gimple_omp_body (gs
));
869 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
870 dump_gimple_fmt (buffer
, spc
, flags
, " >");
874 pp_string (buffer
, "#pragma omp single");
875 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
876 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
878 newline_and_indent (buffer
, spc
+ 2);
879 pp_character (buffer
, '{');
881 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
882 newline_and_indent (buffer
, spc
+ 2);
883 pp_character (buffer
, '}');
888 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
891 dump_gimple_omp_sections (pretty_printer
*buffer
, gimple gs
, int spc
,
896 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
897 gimple_omp_body (gs
));
898 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
899 dump_gimple_fmt (buffer
, spc
, flags
, " >");
903 pp_string (buffer
, "#pragma omp sections");
904 if (gimple_omp_sections_control (gs
))
906 pp_string (buffer
, " <");
907 dump_generic_node (buffer
, gimple_omp_sections_control (gs
), spc
,
909 pp_character (buffer
, '>');
911 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
912 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
914 newline_and_indent (buffer
, spc
+ 2);
915 pp_character (buffer
, '{');
917 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
918 newline_and_indent (buffer
, spc
+ 2);
919 pp_character (buffer
, '}');
924 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the pretty_printer
928 dump_gimple_omp_block (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
931 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
932 gimple_omp_body (gs
));
935 switch (gimple_code (gs
))
937 case GIMPLE_OMP_MASTER
:
938 pp_string (buffer
, "#pragma omp master");
940 case GIMPLE_OMP_ORDERED
:
941 pp_string (buffer
, "#pragma omp ordered");
943 case GIMPLE_OMP_SECTION
:
944 pp_string (buffer
, "#pragma omp section");
949 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
951 newline_and_indent (buffer
, spc
+ 2);
952 pp_character (buffer
, '{');
954 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
955 newline_and_indent (buffer
, spc
+ 2);
956 pp_character (buffer
, '}');
961 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
964 dump_gimple_omp_critical (pretty_printer
*buffer
, gimple gs
, int spc
,
968 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
969 gimple_omp_body (gs
));
972 pp_string (buffer
, "#pragma omp critical");
973 if (gimple_omp_critical_name (gs
))
975 pp_string (buffer
, " (");
976 dump_generic_node (buffer
, gimple_omp_critical_name (gs
), spc
,
978 pp_character (buffer
, ')');
980 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
982 newline_and_indent (buffer
, spc
+ 2);
983 pp_character (buffer
, '{');
985 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
986 newline_and_indent (buffer
, spc
+ 2);
987 pp_character (buffer
, '}');
992 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
995 dump_gimple_omp_return (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
999 dump_gimple_fmt (buffer
, spc
, flags
, "%G <nowait=%d>", gs
,
1000 (int) gimple_omp_return_nowait_p (gs
));
1004 pp_string (buffer
, "#pragma omp return");
1005 if (gimple_omp_return_nowait_p (gs
))
1006 pp_string (buffer
, "(nowait)");
1010 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1011 indent. FLAGS specifies details to show in the dump (see TDF_* in
1015 dump_gimple_asm (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1019 if (flags
& TDF_RAW
)
1020 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+STRING <%n%s%n>", gs
,
1021 gimple_asm_string (gs
));
1024 pp_string (buffer
, "__asm__");
1025 if (gimple_asm_volatile_p (gs
))
1026 pp_string (buffer
, " __volatile__");
1027 pp_string (buffer
, "(\"");
1028 pp_string (buffer
, gimple_asm_string (gs
));
1029 pp_string (buffer
, "\"");
1032 if (gimple_asm_ninputs (gs
)
1033 || gimple_asm_noutputs (gs
)
1034 || gimple_asm_nclobbers (gs
))
1036 if (gimple_asm_noutputs (gs
))
1038 if (flags
& TDF_RAW
)
1040 newline_and_indent (buffer
, spc
+ 2);
1041 pp_string (buffer
, "OUTPUT: ");
1044 pp_string (buffer
, " : ");
1047 for (i
= 0; i
< gimple_asm_noutputs (gs
); i
++)
1049 dump_generic_node (buffer
, gimple_asm_output_op (gs
, i
), spc
, flags
,
1051 if ( i
< gimple_asm_noutputs (gs
) -1)
1052 pp_string (buffer
, ", ");
1055 if (gimple_asm_ninputs (gs
))
1057 if (flags
& TDF_RAW
)
1059 newline_and_indent (buffer
, spc
+ 2);
1060 pp_string (buffer
, "INPUT: ");
1063 pp_string (buffer
, " : ");
1066 for (i
= 0; i
< gimple_asm_ninputs (gs
); i
++)
1068 dump_generic_node (buffer
, gimple_asm_input_op (gs
, i
), spc
, flags
,
1070 if (i
< gimple_asm_ninputs (gs
) -1)
1071 pp_string (buffer
, " : ");
1074 if (gimple_asm_nclobbers (gs
))
1076 if (flags
& TDF_RAW
)
1078 newline_and_indent (buffer
, spc
+ 2);
1079 pp_string (buffer
, "CLOBBER: ");
1082 pp_string (buffer
, " : ");
1085 for (i
= 0; i
< gimple_asm_nclobbers (gs
); i
++)
1087 dump_generic_node (buffer
, gimple_asm_clobber_op (gs
, i
), spc
, flags
,
1089 if ( i
< gimple_asm_nclobbers (gs
) -1)
1090 pp_string (buffer
, ", ");
1093 if (flags
& TDF_RAW
)
1095 newline_and_indent (buffer
, spc
);
1096 pp_character (buffer
, '>');
1099 pp_string (buffer
, ");");
1103 /* Dump the set of decls SYMS. BUFFER, SPC and FLAGS are as in
1104 dump_generic_node. */
1107 dump_symbols (pretty_printer
*buffer
, bitmap syms
, int flags
)
1113 pp_string (buffer
, "NIL");
1116 pp_string (buffer
, " { ");
1118 EXECUTE_IF_SET_IN_BITMAP (syms
, 0, i
, bi
)
1120 tree sym
= referenced_var_lookup (i
);
1121 dump_generic_node (buffer
, sym
, 0, flags
, false);
1122 pp_string (buffer
, " ");
1125 pp_string (buffer
, "}");
1130 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in
1131 dump_gimple_stmt. */
1134 dump_gimple_phi (pretty_printer
*buffer
, gimple phi
, int spc
, int flags
)
1138 if (flags
& TDF_RAW
)
1139 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", phi
,
1140 gimple_phi_result (phi
));
1143 dump_generic_node (buffer
, gimple_phi_result (phi
), spc
, flags
, false);
1144 pp_string (buffer
, " = PHI <");
1146 for (i
= 0; i
< gimple_phi_num_args (phi
); i
++)
1148 dump_generic_node (buffer
, gimple_phi_arg_def (phi
, i
), spc
, flags
,
1150 pp_string (buffer
, "(");
1151 pp_decimal_int (buffer
, gimple_phi_arg_edge (phi
, i
)->src
->index
);
1152 pp_string (buffer
, ")");
1153 if (i
< gimple_phi_num_args (phi
) - 1)
1154 pp_string (buffer
, ", ");
1156 pp_string (buffer
, ">");
1160 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1161 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1165 dump_gimple_omp_parallel (pretty_printer
*buffer
, gimple gs
, int spc
,
1168 if (flags
& TDF_RAW
)
1170 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1171 gimple_omp_body (gs
));
1172 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
1173 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T%n>",
1174 gimple_omp_parallel_child_fn (gs
),
1175 gimple_omp_parallel_data_arg (gs
));
1180 pp_string (buffer
, "#pragma omp parallel");
1181 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
1182 if (gimple_omp_parallel_child_fn (gs
))
1184 pp_string (buffer
, " [child fn: ");
1185 dump_generic_node (buffer
, gimple_omp_parallel_child_fn (gs
),
1187 pp_string (buffer
, " (");
1188 if (gimple_omp_parallel_data_arg (gs
))
1189 dump_generic_node (buffer
, gimple_omp_parallel_data_arg (gs
),
1192 pp_string (buffer
, "???");
1193 pp_string (buffer
, ")]");
1195 body
= gimple_omp_body (gs
);
1196 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
1198 newline_and_indent (buffer
, spc
+ 2);
1199 pp_character (buffer
, '{');
1200 pp_newline (buffer
);
1201 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
1202 newline_and_indent (buffer
, spc
+ 2);
1203 pp_character (buffer
, '}');
1207 pp_newline (buffer
);
1208 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
1214 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1215 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1219 dump_gimple_omp_task (pretty_printer
*buffer
, gimple gs
, int spc
,
1222 if (flags
& TDF_RAW
)
1224 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1225 gimple_omp_body (gs
));
1226 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
1227 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T, %T, %T, %T%n>",
1228 gimple_omp_task_child_fn (gs
),
1229 gimple_omp_task_data_arg (gs
),
1230 gimple_omp_task_copy_fn (gs
),
1231 gimple_omp_task_arg_size (gs
),
1232 gimple_omp_task_arg_size (gs
));
1237 pp_string (buffer
, "#pragma omp task");
1238 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
1239 if (gimple_omp_task_child_fn (gs
))
1241 pp_string (buffer
, " [child fn: ");
1242 dump_generic_node (buffer
, gimple_omp_task_child_fn (gs
),
1244 pp_string (buffer
, " (");
1245 if (gimple_omp_task_data_arg (gs
))
1246 dump_generic_node (buffer
, gimple_omp_task_data_arg (gs
),
1249 pp_string (buffer
, "???");
1250 pp_string (buffer
, ")]");
1252 body
= gimple_omp_body (gs
);
1253 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
1255 newline_and_indent (buffer
, spc
+ 2);
1256 pp_character (buffer
, '{');
1257 pp_newline (buffer
);
1258 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
1259 newline_and_indent (buffer
, spc
+ 2);
1260 pp_character (buffer
, '}');
1264 pp_newline (buffer
);
1265 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
1271 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1272 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1276 dump_gimple_omp_atomic_load (pretty_printer
*buffer
, gimple gs
, int spc
,
1279 if (flags
& TDF_RAW
)
1281 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
1282 gimple_omp_atomic_load_lhs (gs
),
1283 gimple_omp_atomic_load_rhs (gs
));
1287 pp_string (buffer
, "#pragma omp atomic_load");
1288 newline_and_indent (buffer
, spc
+ 2);
1289 dump_generic_node (buffer
, gimple_omp_atomic_load_lhs (gs
),
1292 pp_character (buffer
, '=');
1294 pp_character (buffer
, '*');
1295 dump_generic_node (buffer
, gimple_omp_atomic_load_rhs (gs
),
1300 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1301 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1305 dump_gimple_omp_atomic_store (pretty_printer
*buffer
, gimple gs
, int spc
,
1308 if (flags
& TDF_RAW
)
1310 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
,
1311 gimple_omp_atomic_store_val (gs
));
1315 pp_string (buffer
, "#pragma omp atomic_store (");
1316 dump_generic_node (buffer
, gimple_omp_atomic_store_val (gs
),
1318 pp_character (buffer
, ')');
1322 /* Dump a GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. BUFFER, SPC and
1323 FLAGS are as in dump_gimple_stmt. */
1326 dump_gimple_cdt (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1328 if (flags
& TDF_RAW
)
1329 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
1330 gimple_cdt_new_type (gs
), gimple_cdt_location (gs
));
1333 pp_string (buffer
, "<<<change_dynamic_type (");
1334 dump_generic_node (buffer
, gimple_cdt_new_type (gs
), spc
+ 2, flags
,
1336 pp_string (buffer
, ") ");
1337 dump_generic_node (buffer
, gimple_cdt_location (gs
), spc
+ 2, flags
,
1339 pp_string (buffer
, ")>>>");
1344 /* Dump all the memory operands for statement GS. BUFFER, SPC and
1345 FLAGS are as in dump_gimple_stmt. */
1348 dump_gimple_mem_ops (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1350 struct voptype_d
*vdefs
;
1351 struct voptype_d
*vuses
;
1354 if (!ssa_operands_active () || !gimple_references_memory_p (gs
))
1357 /* Even if the statement doesn't have virtual operators yet, it may
1358 contain symbol information (this happens before aliases have been
1360 if ((flags
& TDF_MEMSYMS
)
1361 && gimple_vuse_ops (gs
) == NULL
1362 && gimple_vdef_ops (gs
) == NULL
)
1364 if (gimple_loaded_syms (gs
))
1366 pp_string (buffer
, "# LOADS: ");
1367 dump_symbols (buffer
, gimple_loaded_syms (gs
), flags
);
1368 newline_and_indent (buffer
, spc
);
1371 if (gimple_stored_syms (gs
))
1373 pp_string (buffer
, "# STORES: ");
1374 dump_symbols (buffer
, gimple_stored_syms (gs
), flags
);
1375 newline_and_indent (buffer
, spc
);
1381 vuses
= gimple_vuse_ops (gs
);
1384 pp_string (buffer
, "# VUSE <");
1386 n
= VUSE_NUM (vuses
);
1387 for (i
= 0; i
< n
; i
++)
1389 dump_generic_node (buffer
, VUSE_OP (vuses
, i
), spc
+ 2, flags
, false);
1391 pp_string (buffer
, ", ");
1394 pp_string (buffer
, ">");
1396 if (flags
& TDF_MEMSYMS
)
1397 dump_symbols (buffer
, gimple_loaded_syms (gs
), flags
);
1399 newline_and_indent (buffer
, spc
);
1400 vuses
= vuses
->next
;
1403 vdefs
= gimple_vdef_ops (gs
);
1406 pp_string (buffer
, "# ");
1407 dump_generic_node (buffer
, VDEF_RESULT (vdefs
), spc
+ 2, flags
, false);
1408 pp_string (buffer
, " = VDEF <");
1410 n
= VDEF_NUM (vdefs
);
1411 for (i
= 0; i
< n
; i
++)
1413 dump_generic_node (buffer
, VDEF_OP (vdefs
, i
), spc
+ 2, flags
, 0);
1415 pp_string (buffer
, ", ");
1418 pp_string (buffer
, ">");
1420 if ((flags
& TDF_MEMSYMS
) && vdefs
->next
== NULL
)
1421 dump_symbols (buffer
, gimple_stored_syms (gs
), flags
);
1423 newline_and_indent (buffer
, spc
);
1424 vdefs
= vdefs
->next
;
1429 /* Dump the gimple statement GS on the pretty printer BUFFER, SPC
1430 spaces of indent. FLAGS specifies details to show in the dump (see
1431 TDF_* in tree-pass.h). */
1434 dump_gimple_stmt (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1439 if (flags
& TDF_STMTADDR
)
1440 pp_printf (buffer
, "<&%p> ", (void *) gs
);
1442 if ((flags
& TDF_LINENO
) && gimple_has_location (gs
))
1444 expanded_location xloc
= expand_location (gimple_location (gs
));
1445 pp_character (buffer
, '[');
1448 pp_string (buffer
, xloc
.file
);
1449 pp_string (buffer
, " : ");
1451 pp_decimal_int (buffer
, xloc
.line
);
1452 pp_string (buffer
, "] ");
1455 if ((flags
& (TDF_VOPS
|TDF_MEMSYMS
))
1456 && gimple_has_mem_ops (gs
))
1457 dump_gimple_mem_ops (buffer
, gs
, spc
, flags
);
1459 switch (gimple_code (gs
))
1462 dump_gimple_asm (buffer
, gs
, spc
, flags
);
1466 dump_gimple_assign (buffer
, gs
, spc
, flags
);
1470 dump_gimple_bind (buffer
, gs
, spc
, flags
);
1474 dump_gimple_call (buffer
, gs
, spc
, flags
);
1478 dump_gimple_cond (buffer
, gs
, spc
, flags
);
1482 dump_gimple_label (buffer
, gs
, spc
, flags
);
1486 dump_gimple_goto (buffer
, gs
, spc
, flags
);
1490 pp_string (buffer
, "GIMPLE_NOP");
1494 dump_gimple_return (buffer
, gs
, spc
, flags
);
1498 dump_gimple_switch (buffer
, gs
, spc
, flags
);
1502 dump_gimple_try (buffer
, gs
, spc
, flags
);
1506 dump_gimple_phi (buffer
, gs
, spc
, flags
);
1509 case GIMPLE_OMP_PARALLEL
:
1510 dump_gimple_omp_parallel (buffer
, gs
, spc
, flags
);
1513 case GIMPLE_OMP_TASK
:
1514 dump_gimple_omp_task (buffer
, gs
, spc
, flags
);
1517 case GIMPLE_OMP_ATOMIC_LOAD
:
1518 dump_gimple_omp_atomic_load (buffer
, gs
, spc
, flags
);
1522 case GIMPLE_OMP_ATOMIC_STORE
:
1523 dump_gimple_omp_atomic_store (buffer
, gs
, spc
, flags
);
1526 case GIMPLE_OMP_FOR
:
1527 dump_gimple_omp_for (buffer
, gs
, spc
, flags
);
1530 case GIMPLE_OMP_CONTINUE
:
1531 dump_gimple_omp_continue (buffer
, gs
, spc
, flags
);
1534 case GIMPLE_OMP_SINGLE
:
1535 dump_gimple_omp_single (buffer
, gs
, spc
, flags
);
1538 case GIMPLE_OMP_RETURN
:
1539 dump_gimple_omp_return (buffer
, gs
, spc
, flags
);
1542 case GIMPLE_OMP_SECTIONS
:
1543 dump_gimple_omp_sections (buffer
, gs
, spc
, flags
);
1546 case GIMPLE_OMP_SECTIONS_SWITCH
:
1547 pp_string (buffer
, "GIMPLE_SECTIONS_SWITCH");
1550 case GIMPLE_OMP_MASTER
:
1551 case GIMPLE_OMP_ORDERED
:
1552 case GIMPLE_OMP_SECTION
:
1553 dump_gimple_omp_block (buffer
, gs
, spc
, flags
);
1556 case GIMPLE_OMP_CRITICAL
:
1557 dump_gimple_omp_critical (buffer
, gs
, spc
, flags
);
1560 case GIMPLE_CHANGE_DYNAMIC_TYPE
:
1561 dump_gimple_cdt (buffer
, gs
, spc
, flags
);
1565 dump_gimple_catch (buffer
, gs
, spc
, flags
);
1568 case GIMPLE_EH_FILTER
:
1569 dump_gimple_eh_filter (buffer
, gs
, spc
, flags
);
1573 dump_gimple_resx (buffer
, gs
, spc
, flags
);
1576 case GIMPLE_PREDICT
:
1577 pp_string (buffer
, "// predicted ");
1578 if (gimple_predict_outcome (gs
))
1579 pp_string (buffer
, "likely by ");
1581 pp_string (buffer
, "unlikely by ");
1582 pp_string (buffer
, predictor_name (gimple_predict_predictor (gs
)));
1583 pp_string (buffer
, " predictor.");
1590 /* If we're building a diagnostic, the formatted text will be
1591 written into BUFFER's stream by the caller; otherwise, write it
1593 if (!(flags
& TDF_DIAGNOSTIC
))
1594 pp_write_text_to_stream (buffer
);
1598 /* Dumps header of basic block BB to buffer BUFFER indented by INDENT
1599 spaces and details described by flags. */
1602 dump_bb_header (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1608 if (flags
& TDF_BLOCKS
)
1611 pp_string (buffer
, "# BLOCK ");
1612 pp_decimal_int (buffer
, bb
->index
);
1615 pp_string (buffer
, " freq:");
1616 pp_decimal_int (buffer
, bb
->frequency
);
1620 pp_string (buffer
, " count:");
1621 pp_widest_integer (buffer
, bb
->count
);
1624 if (flags
& TDF_LINENO
)
1626 gimple_stmt_iterator gsi
;
1628 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
1629 if (get_lineno (gsi_stmt (gsi
)) != -1)
1631 pp_string (buffer
, ", starting at line ");
1632 pp_decimal_int (buffer
, get_lineno (gsi_stmt (gsi
)));
1636 newline_and_indent (buffer
, indent
);
1638 pp_string (buffer
, "# PRED:");
1639 pp_write_text_to_stream (buffer
);
1640 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
1641 if (flags
& TDF_SLIM
)
1643 pp_string (buffer
, " ");
1644 if (e
->src
== ENTRY_BLOCK_PTR
)
1645 pp_string (buffer
, "ENTRY");
1647 pp_decimal_int (buffer
, e
->src
->index
);
1650 dump_edge_info (buffer
->buffer
->stream
, e
, 0);
1651 pp_newline (buffer
);
1655 stmt
= first_stmt (bb
);
1656 if (!stmt
|| gimple_code (stmt
) != GIMPLE_LABEL
)
1658 INDENT (indent
- 2);
1659 pp_string (buffer
, "<bb ");
1660 pp_decimal_int (buffer
, bb
->index
);
1661 pp_string (buffer
, ">:");
1662 pp_newline (buffer
);
1665 pp_write_text_to_stream (buffer
);
1666 check_bb_profile (bb
, buffer
->buffer
->stream
);
1670 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
1674 dump_bb_end (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1680 pp_string (buffer
, "# SUCC:");
1681 pp_write_text_to_stream (buffer
);
1682 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
1683 if (flags
& TDF_SLIM
)
1685 pp_string (buffer
, " ");
1686 if (e
->dest
== EXIT_BLOCK_PTR
)
1687 pp_string (buffer
, "EXIT");
1689 pp_decimal_int (buffer
, e
->dest
->index
);
1692 dump_edge_info (buffer
->buffer
->stream
, e
, 1);
1693 pp_newline (buffer
);
1697 /* Dump PHI nodes of basic block BB to BUFFER with details described
1698 by FLAGS and indented by INDENT spaces. */
1701 dump_phi_nodes (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1703 gimple_stmt_iterator i
;
1705 for (i
= gsi_start_phis (bb
); !gsi_end_p (i
); gsi_next (&i
))
1707 gimple phi
= gsi_stmt (i
);
1708 if (is_gimple_reg (gimple_phi_result (phi
)) || (flags
& TDF_VOPS
))
1711 pp_string (buffer
, "# ");
1712 dump_gimple_phi (buffer
, phi
, indent
, flags
);
1713 pp_newline (buffer
);
1719 /* Dump jump to basic block BB that is represented implicitly in the cfg
1723 pp_cfg_jump (pretty_printer
*buffer
, basic_block bb
)
1727 stmt
= first_stmt (bb
);
1729 pp_string (buffer
, "goto <bb ");
1730 pp_decimal_int (buffer
, bb
->index
);
1731 pp_string (buffer
, ">");
1732 if (stmt
&& gimple_code (stmt
) == GIMPLE_LABEL
)
1734 pp_string (buffer
, " (");
1735 dump_generic_node (buffer
, gimple_label_label (stmt
), 0, 0, false);
1736 pp_string (buffer
, ")");
1737 pp_semicolon (buffer
);
1740 pp_semicolon (buffer
);
1744 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
1745 by INDENT spaces, with details given by FLAGS. */
1748 dump_implicit_edges (pretty_printer
*buffer
, basic_block bb
, int indent
,
1755 stmt
= last_stmt (bb
);
1757 if (stmt
&& gimple_code (stmt
) == GIMPLE_COND
)
1759 edge true_edge
, false_edge
;
1761 /* When we are emitting the code or changing CFG, it is possible that
1762 the edges are not yet created. When we are using debug_bb in such
1763 a situation, we do not want it to crash. */
1764 if (EDGE_COUNT (bb
->succs
) != 2)
1766 extract_true_false_edges_from_block (bb
, &true_edge
, &false_edge
);
1768 INDENT (indent
+ 2);
1769 pp_cfg_jump (buffer
, true_edge
->dest
);
1770 newline_and_indent (buffer
, indent
);
1771 pp_string (buffer
, "else");
1772 newline_and_indent (buffer
, indent
+ 2);
1773 pp_cfg_jump (buffer
, false_edge
->dest
);
1774 pp_newline (buffer
);
1778 /* If there is a fallthru edge, we may need to add an artificial
1779 goto to the dump. */
1780 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
1781 if (e
->flags
& EDGE_FALLTHRU
)
1784 if (e
&& e
->dest
!= bb
->next_bb
)
1788 if ((flags
& TDF_LINENO
)
1789 && e
->goto_locus
!= UNKNOWN_LOCATION
1792 expanded_location goto_xloc
;
1793 goto_xloc
= expand_location (e
->goto_locus
);
1794 pp_character (buffer
, '[');
1797 pp_string (buffer
, goto_xloc
.file
);
1798 pp_string (buffer
, " : ");
1800 pp_decimal_int (buffer
, goto_xloc
.line
);
1801 pp_string (buffer
, "] ");
1804 pp_cfg_jump (buffer
, e
->dest
);
1805 pp_newline (buffer
);
1810 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
1811 indented by INDENT spaces. */
1814 gimple_dump_bb_buff (pretty_printer
*buffer
, basic_block bb
, int indent
,
1817 gimple_stmt_iterator gsi
;
1819 int label_indent
= indent
- 2;
1821 if (label_indent
< 0)
1824 dump_bb_header (buffer
, bb
, indent
, flags
);
1825 dump_phi_nodes (buffer
, bb
, indent
, flags
);
1827 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
1831 stmt
= gsi_stmt (gsi
);
1833 curr_indent
= gimple_code (stmt
) == GIMPLE_LABEL
? label_indent
: indent
;
1835 INDENT (curr_indent
);
1836 dump_gimple_stmt (buffer
, stmt
, curr_indent
, flags
);
1837 pp_newline (buffer
);
1838 dump_histograms_for_stmt (cfun
, buffer
->buffer
->stream
, stmt
);
1841 dump_implicit_edges (buffer
, bb
, indent
, flags
);
1843 if (flags
& TDF_BLOCKS
)
1844 dump_bb_end (buffer
, bb
, indent
, flags
);
1848 /* Dumps basic block BB to FILE with details described by FLAGS and
1849 indented by INDENT spaces. */
1852 gimple_dump_bb (basic_block bb
, FILE *file
, int indent
, int flags
)
1854 maybe_init_pretty_print (file
);
1855 gimple_dump_bb_buff (&buffer
, bb
, indent
, flags
);