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
)
312 enum tree_code code
= gimple_assign_rhs_code (gs
);
318 case VEC_WIDEN_MULT_HI_EXPR
:
319 case VEC_WIDEN_MULT_LO_EXPR
:
320 case VEC_PACK_TRUNC_EXPR
:
321 case VEC_PACK_SAT_EXPR
:
322 case VEC_PACK_FIX_TRUNC_EXPR
:
323 case VEC_EXTRACT_EVEN_EXPR
:
324 case VEC_EXTRACT_ODD_EXPR
:
325 case VEC_INTERLEAVE_HIGH_EXPR
:
326 case VEC_INTERLEAVE_LOW_EXPR
:
327 for (p
= tree_code_name
[(int) code
]; *p
; p
++)
328 pp_character (buffer
, TOUPPER (*p
));
329 pp_string (buffer
, " <");
330 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
331 pp_string (buffer
, ", ");
332 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
333 pp_character (buffer
, '>');
337 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
339 pp_string (buffer
, op_symbol_code (gimple_assign_rhs_code (gs
)));
341 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
346 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
350 dump_gimple_assign (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
355 if (gimple_num_ops (gs
) == 2)
357 else if (gimple_num_ops (gs
) == 3)
358 last
= gimple_assign_rhs2 (gs
);
362 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T>", gs
,
363 tree_code_name
[gimple_assign_rhs_code (gs
)],
364 gimple_assign_lhs (gs
), gimple_assign_rhs1 (gs
), last
);
368 if (!(flags
& TDF_RHS_ONLY
))
370 dump_generic_node (buffer
, gimple_assign_lhs (gs
), spc
, flags
, false);
372 pp_character (buffer
, '=');
374 if (gimple_assign_nontemporal_move_p (gs
))
375 pp_string (buffer
, "{nt}");
377 if (gimple_has_volatile_ops (gs
))
378 pp_string (buffer
, "{v}");
383 if (gimple_num_ops (gs
) == 2)
384 dump_unary_rhs (buffer
, gs
, spc
, flags
);
385 else if (gimple_num_ops (gs
) == 3)
386 dump_binary_rhs (buffer
, gs
, spc
, flags
);
389 if (!(flags
& TDF_RHS_ONLY
))
390 pp_semicolon(buffer
);
395 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
399 dump_gimple_return (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
403 t
= gimple_return_retval (gs
);
405 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, t
);
408 pp_string (buffer
, "return");
412 dump_generic_node (buffer
, t
, spc
, flags
, false);
414 pp_semicolon (buffer
);
419 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
423 dump_gimple_call_args (pretty_printer
*buffer
, gimple gs
, int flags
)
427 for (i
= 0; i
< gimple_call_num_args (gs
); i
++)
429 dump_generic_node (buffer
, gimple_call_arg (gs
, i
), 0, flags
, false);
430 if (i
< gimple_call_num_args (gs
) - 1)
431 pp_string (buffer
, ", ");
434 if (gimple_call_va_arg_pack_p (gs
))
436 if (gimple_call_num_args (gs
) > 0)
438 pp_character (buffer
, ',');
442 pp_string (buffer
, "__builtin_va_arg_pack ()");
447 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
451 dump_gimple_call (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
453 tree lhs
= gimple_call_lhs (gs
);
457 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T",
458 gs
, gimple_call_fn (gs
), lhs
);
459 if (gimple_call_num_args (gs
) > 0)
461 pp_string (buffer
, ", ");
462 dump_gimple_call_args (buffer
, gs
, flags
);
464 pp_string (buffer
, ">");
468 if (lhs
&& !(flags
& TDF_RHS_ONLY
))
470 dump_generic_node (buffer
, lhs
, spc
, flags
, false);
471 pp_string (buffer
, " =");
473 if (gimple_has_volatile_ops (gs
))
474 pp_string (buffer
, "{v}");
478 dump_generic_node (buffer
, gimple_call_fn (gs
), spc
, flags
, false);
479 pp_string (buffer
, " (");
480 dump_gimple_call_args (buffer
, gs
, flags
);
481 pp_string (buffer
, ")");
482 if (!(flags
& TDF_RHS_ONLY
))
483 pp_semicolon (buffer
);
486 if (gimple_call_chain (gs
))
488 pp_string (buffer
, " [static-chain: ");
489 dump_generic_node (buffer
, gimple_call_chain (gs
), spc
, flags
, false);
490 pp_character (buffer
, ']');
493 if (gimple_call_return_slot_opt_p (gs
))
494 pp_string (buffer
, " [return slot optimization]");
496 if (gimple_call_tail_p (gs
))
497 pp_string (buffer
, " [tail call]");
501 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
505 dump_gimple_switch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
509 GIMPLE_CHECK (gs
, GIMPLE_SWITCH
);
511 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", gs
,
512 gimple_switch_index (gs
));
515 pp_string (buffer
, "switch (");
516 dump_generic_node (buffer
, gimple_switch_index (gs
), spc
, flags
, true);
517 pp_string (buffer
, ") <");
520 for (i
= 0; i
< gimple_switch_num_labels (gs
); i
++)
522 tree case_label
= gimple_switch_label (gs
, i
);
523 if (case_label
== NULL_TREE
)
526 dump_generic_node (buffer
, case_label
, spc
, flags
, false);
527 pp_string (buffer
, " ");
528 dump_generic_node (buffer
, CASE_LABEL (case_label
), spc
, flags
, false);
529 if (i
< gimple_switch_num_labels (gs
) - 1)
530 pp_string (buffer
, ", ");
532 pp_string (buffer
, ">");
536 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
540 dump_gimple_cond (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
543 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T, %T>", gs
,
544 tree_code_name
[gimple_cond_code (gs
)],
545 gimple_cond_lhs (gs
), gimple_cond_rhs (gs
),
546 gimple_cond_true_label (gs
), gimple_cond_false_label (gs
));
549 if (!(flags
& TDF_RHS_ONLY
))
550 pp_string (buffer
, "if (");
551 dump_generic_node (buffer
, gimple_cond_lhs (gs
), spc
, flags
, false);
553 pp_string (buffer
, op_symbol_code (gimple_cond_code (gs
)));
555 dump_generic_node (buffer
, gimple_cond_rhs (gs
), spc
, flags
, false);
556 if (!(flags
& TDF_RHS_ONLY
))
558 pp_string (buffer
, ")");
560 if (gimple_cond_true_label (gs
))
562 pp_string (buffer
, " goto ");
563 dump_generic_node (buffer
, gimple_cond_true_label (gs
),
565 pp_semicolon (buffer
);
567 if (gimple_cond_false_label (gs
))
569 pp_string (buffer
, " else goto ");
570 dump_generic_node (buffer
, gimple_cond_false_label (gs
),
572 pp_semicolon (buffer
);
579 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
580 spaces of indent. FLAGS specifies details to show in the dump (see
581 TDF_* in tree-pass.h). */
584 dump_gimple_label (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
586 tree label
= gimple_label_label (gs
);
588 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
591 dump_generic_node (buffer
, label
, spc
, flags
, false);
592 pp_string (buffer
, ":");
594 if (DECL_NONLOCAL (label
))
595 pp_string (buffer
, " [non-local]");
598 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
599 spaces of indent. FLAGS specifies details to show in the dump (see
600 TDF_* in tree-pass.h). */
603 dump_gimple_goto (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
605 tree label
= gimple_goto_dest (gs
);
607 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
609 dump_gimple_fmt (buffer
, spc
, flags
, "goto %T;", label
);
613 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
614 spaces of indent. FLAGS specifies details to show in the dump (see
615 TDF_* in tree-pass.h). */
618 dump_gimple_bind (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
621 dump_gimple_fmt (buffer
, spc
, flags
, "%G <", gs
);
623 pp_character (buffer
, '{');
624 if (!(flags
& TDF_SLIM
))
628 for (var
= gimple_bind_vars (gs
); var
; var
= TREE_CHAIN (var
))
630 newline_and_indent (buffer
, 2);
631 print_declaration (buffer
, var
, spc
, flags
);
633 if (gimple_bind_vars (gs
))
637 dump_gimple_seq (buffer
, gimple_bind_body (gs
), spc
+ 2, flags
);
638 newline_and_indent (buffer
, spc
);
640 pp_character (buffer
, '>');
642 pp_character (buffer
, '}');
646 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
647 indent. FLAGS specifies details to show in the dump (see TDF_* in
651 dump_gimple_try (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
656 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
657 type
= "GIMPLE_TRY_CATCH";
658 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
659 type
= "GIMPLE_TRY_FINALLY";
661 type
= "UNKNOWN GIMPLE_TRY";
662 dump_gimple_fmt (buffer
, spc
, flags
,
663 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs
, type
,
664 gimple_try_eval (gs
), gimple_try_cleanup (gs
));
668 pp_string (buffer
, "try");
669 newline_and_indent (buffer
, spc
+ 2);
670 pp_string (buffer
, "{");
673 dump_gimple_seq (buffer
, gimple_try_eval (gs
), spc
+ 4, flags
);
674 newline_and_indent (buffer
, spc
+ 2);
675 pp_string (buffer
, "}");
677 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
679 newline_and_indent (buffer
, spc
);
680 pp_string (buffer
, "catch");
681 newline_and_indent (buffer
, spc
+ 2);
682 pp_string (buffer
, "{");
684 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
686 newline_and_indent (buffer
, spc
);
687 pp_string (buffer
, "finally");
688 newline_and_indent (buffer
, spc
+ 2);
689 pp_string (buffer
, "{");
692 pp_string (buffer
, " <UNKNOWN GIMPLE_TRY> {");
695 dump_gimple_seq (buffer
, gimple_try_cleanup (gs
), spc
+ 4, flags
);
696 newline_and_indent (buffer
, spc
+ 2);
697 pp_character (buffer
, '}');
702 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
703 indent. FLAGS specifies details to show in the dump (see TDF_* in
707 dump_gimple_catch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
710 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+CATCH <%S>%->", gs
,
711 gimple_catch_types (gs
), gimple_catch_handler (gs
));
713 dump_gimple_fmt (buffer
, spc
, flags
, "catch (%T)%+{%S}",
714 gimple_catch_types (gs
), gimple_catch_handler (gs
));
718 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
719 indent. FLAGS specifies details to show in the dump (see TDF_* in
723 dump_gimple_eh_filter (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
726 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+FAILURE <%S>%->", gs
,
727 gimple_eh_filter_types (gs
),
728 gimple_eh_filter_failure (gs
));
730 dump_gimple_fmt (buffer
, spc
, flags
, "<<<eh_filter (%T)>>>%+{%+%S%-}",
731 gimple_eh_filter_types (gs
),
732 gimple_eh_filter_failure (gs
));
736 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
737 indent. FLAGS specifies details to show in the dump (see TDF_* in
741 dump_gimple_resx (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
744 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%d>", gs
,
745 gimple_resx_region (gs
));
747 dump_gimple_fmt (buffer
, spc
, flags
, "resx %d", gimple_resx_region (gs
));
750 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
752 dump_gimple_omp_for (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
758 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
759 gimple_omp_body (gs
));
760 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
761 dump_gimple_fmt (buffer
, spc
, flags
, " >,");
762 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
763 dump_gimple_fmt (buffer
, spc
, flags
,
764 "%+%T, %T, %T, %s, %T,%n",
765 gimple_omp_for_index (gs
, i
),
766 gimple_omp_for_initial (gs
, i
),
767 gimple_omp_for_final (gs
, i
),
768 tree_code_name
[gimple_omp_for_cond (gs
, i
)],
769 gimple_omp_for_incr (gs
, i
));
770 dump_gimple_fmt (buffer
, spc
, flags
, "PRE_BODY <%S>%->",
771 gimple_omp_for_pre_body (gs
));
775 pp_string (buffer
, "#pragma omp for");
776 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
777 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
781 newline_and_indent (buffer
, spc
);
782 pp_string (buffer
, "for (");
783 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
785 pp_string (buffer
, " = ");
786 dump_generic_node (buffer
, gimple_omp_for_initial (gs
, i
), spc
,
788 pp_string (buffer
, "; ");
790 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
793 switch (gimple_omp_for_cond (gs
, i
))
796 pp_character (buffer
, '<');
799 pp_character (buffer
, '>');
802 pp_string (buffer
, "<=");
805 pp_string (buffer
, ">=");
811 dump_generic_node (buffer
, gimple_omp_for_final (gs
, i
), spc
,
813 pp_string (buffer
, "; ");
815 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
817 pp_string (buffer
, " = ");
818 dump_generic_node (buffer
, gimple_omp_for_incr (gs
, i
), spc
,
820 pp_character (buffer
, ')');
823 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
825 newline_and_indent (buffer
, spc
+ 2);
826 pp_character (buffer
, '{');
828 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
829 newline_and_indent (buffer
, spc
+ 2);
830 pp_character (buffer
, '}');
835 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
838 dump_gimple_omp_continue (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
842 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
843 gimple_omp_continue_control_def (gs
),
844 gimple_omp_continue_control_use (gs
));
848 pp_string (buffer
, "#pragma omp continue (");
849 dump_generic_node (buffer
, gimple_omp_continue_control_def (gs
),
851 pp_character (buffer
, ',');
853 dump_generic_node (buffer
, gimple_omp_continue_control_use (gs
),
855 pp_character (buffer
, ')');
859 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
862 dump_gimple_omp_single (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
866 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
867 gimple_omp_body (gs
));
868 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
869 dump_gimple_fmt (buffer
, spc
, flags
, " >");
873 pp_string (buffer
, "#pragma omp single");
874 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
875 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
877 newline_and_indent (buffer
, spc
+ 2);
878 pp_character (buffer
, '{');
880 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
881 newline_and_indent (buffer
, spc
+ 2);
882 pp_character (buffer
, '}');
887 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
890 dump_gimple_omp_sections (pretty_printer
*buffer
, gimple gs
, int spc
,
895 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
896 gimple_omp_body (gs
));
897 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
898 dump_gimple_fmt (buffer
, spc
, flags
, " >");
902 pp_string (buffer
, "#pragma omp sections");
903 if (gimple_omp_sections_control (gs
))
905 pp_string (buffer
, " <");
906 dump_generic_node (buffer
, gimple_omp_sections_control (gs
), spc
,
908 pp_character (buffer
, '>');
910 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
911 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
913 newline_and_indent (buffer
, spc
+ 2);
914 pp_character (buffer
, '{');
916 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
917 newline_and_indent (buffer
, spc
+ 2);
918 pp_character (buffer
, '}');
923 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the pretty_printer
927 dump_gimple_omp_block (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
930 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
931 gimple_omp_body (gs
));
934 switch (gimple_code (gs
))
936 case GIMPLE_OMP_MASTER
:
937 pp_string (buffer
, "#pragma omp master");
939 case GIMPLE_OMP_ORDERED
:
940 pp_string (buffer
, "#pragma omp ordered");
942 case GIMPLE_OMP_SECTION
:
943 pp_string (buffer
, "#pragma omp section");
948 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
950 newline_and_indent (buffer
, spc
+ 2);
951 pp_character (buffer
, '{');
953 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
954 newline_and_indent (buffer
, spc
+ 2);
955 pp_character (buffer
, '}');
960 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
963 dump_gimple_omp_critical (pretty_printer
*buffer
, gimple gs
, int spc
,
967 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
968 gimple_omp_body (gs
));
971 pp_string (buffer
, "#pragma omp critical");
972 if (gimple_omp_critical_name (gs
))
974 pp_string (buffer
, " (");
975 dump_generic_node (buffer
, gimple_omp_critical_name (gs
), spc
,
977 pp_character (buffer
, ')');
979 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
981 newline_and_indent (buffer
, spc
+ 2);
982 pp_character (buffer
, '{');
984 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
985 newline_and_indent (buffer
, spc
+ 2);
986 pp_character (buffer
, '}');
991 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
994 dump_gimple_omp_return (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
998 dump_gimple_fmt (buffer
, spc
, flags
, "%G <nowait=%d>", gs
,
999 (int) gimple_omp_return_nowait_p (gs
));
1003 pp_string (buffer
, "#pragma omp return");
1004 if (gimple_omp_return_nowait_p (gs
))
1005 pp_string (buffer
, "(nowait)");
1009 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1010 indent. FLAGS specifies details to show in the dump (see TDF_* in
1014 dump_gimple_asm (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1018 if (flags
& TDF_RAW
)
1019 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+STRING <%n%s%n>", gs
,
1020 gimple_asm_string (gs
));
1023 pp_string (buffer
, "__asm__");
1024 if (gimple_asm_volatile_p (gs
))
1025 pp_string (buffer
, " __volatile__");
1026 pp_string (buffer
, "(\"");
1027 pp_string (buffer
, gimple_asm_string (gs
));
1028 pp_string (buffer
, "\"");
1031 if (gimple_asm_ninputs (gs
)
1032 || gimple_asm_noutputs (gs
)
1033 || gimple_asm_nclobbers (gs
))
1035 if (gimple_asm_noutputs (gs
))
1037 if (flags
& TDF_RAW
)
1039 newline_and_indent (buffer
, spc
+ 2);
1040 pp_string (buffer
, "OUTPUT: ");
1043 pp_string (buffer
, " : ");
1046 for (i
= 0; i
< gimple_asm_noutputs (gs
); i
++)
1048 dump_generic_node (buffer
, gimple_asm_output_op (gs
, i
), spc
, flags
,
1050 if ( i
< gimple_asm_noutputs (gs
) -1)
1051 pp_string (buffer
, ", ");
1054 if (gimple_asm_ninputs (gs
))
1056 if (flags
& TDF_RAW
)
1058 newline_and_indent (buffer
, spc
+ 2);
1059 pp_string (buffer
, "INPUT: ");
1062 pp_string (buffer
, " : ");
1065 for (i
= 0; i
< gimple_asm_ninputs (gs
); i
++)
1067 dump_generic_node (buffer
, gimple_asm_input_op (gs
, i
), spc
, flags
,
1069 if (i
< gimple_asm_ninputs (gs
) -1)
1070 pp_string (buffer
, " : ");
1073 if (gimple_asm_nclobbers (gs
))
1075 if (flags
& TDF_RAW
)
1077 newline_and_indent (buffer
, spc
+ 2);
1078 pp_string (buffer
, "CLOBBER: ");
1081 pp_string (buffer
, " : ");
1084 for (i
= 0; i
< gimple_asm_nclobbers (gs
); i
++)
1086 dump_generic_node (buffer
, gimple_asm_clobber_op (gs
, i
), spc
, flags
,
1088 if ( i
< gimple_asm_nclobbers (gs
) -1)
1089 pp_string (buffer
, ", ");
1092 if (flags
& TDF_RAW
)
1094 newline_and_indent (buffer
, spc
);
1095 pp_character (buffer
, '>');
1098 pp_string (buffer
, ");");
1102 /* Dump the set of decls SYMS. BUFFER, SPC and FLAGS are as in
1103 dump_generic_node. */
1106 dump_symbols (pretty_printer
*buffer
, bitmap syms
, int flags
)
1112 pp_string (buffer
, "NIL");
1115 pp_string (buffer
, " { ");
1117 EXECUTE_IF_SET_IN_BITMAP (syms
, 0, i
, bi
)
1119 tree sym
= referenced_var_lookup (i
);
1120 dump_generic_node (buffer
, sym
, 0, flags
, false);
1121 pp_string (buffer
, " ");
1124 pp_string (buffer
, "}");
1129 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in
1130 dump_gimple_stmt. */
1133 dump_gimple_phi (pretty_printer
*buffer
, gimple phi
, int spc
, int flags
)
1137 if (flags
& TDF_RAW
)
1138 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", phi
,
1139 gimple_phi_result (phi
));
1142 dump_generic_node (buffer
, gimple_phi_result (phi
), spc
, flags
, false);
1143 pp_string (buffer
, " = PHI <");
1145 for (i
= 0; i
< gimple_phi_num_args (phi
); i
++)
1147 dump_generic_node (buffer
, gimple_phi_arg_def (phi
, i
), spc
, flags
,
1149 pp_string (buffer
, "(");
1150 pp_decimal_int (buffer
, gimple_phi_arg_edge (phi
, i
)->src
->index
);
1151 pp_string (buffer
, ")");
1152 if (i
< gimple_phi_num_args (phi
) - 1)
1153 pp_string (buffer
, ", ");
1155 pp_string (buffer
, ">");
1159 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1160 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1164 dump_gimple_omp_parallel (pretty_printer
*buffer
, gimple gs
, int spc
,
1167 if (flags
& TDF_RAW
)
1169 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1170 gimple_omp_body (gs
));
1171 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
1172 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T%n>",
1173 gimple_omp_parallel_child_fn (gs
),
1174 gimple_omp_parallel_data_arg (gs
));
1179 pp_string (buffer
, "#pragma omp parallel");
1180 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
1181 if (gimple_omp_parallel_child_fn (gs
))
1183 pp_string (buffer
, " [child fn: ");
1184 dump_generic_node (buffer
, gimple_omp_parallel_child_fn (gs
),
1186 pp_string (buffer
, " (");
1187 if (gimple_omp_parallel_data_arg (gs
))
1188 dump_generic_node (buffer
, gimple_omp_parallel_data_arg (gs
),
1191 pp_string (buffer
, "???");
1192 pp_string (buffer
, ")]");
1194 body
= gimple_omp_body (gs
);
1195 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
1197 newline_and_indent (buffer
, spc
+ 2);
1198 pp_character (buffer
, '{');
1199 pp_newline (buffer
);
1200 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
1201 newline_and_indent (buffer
, spc
+ 2);
1202 pp_character (buffer
, '}');
1206 pp_newline (buffer
);
1207 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
1213 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1214 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1218 dump_gimple_omp_task (pretty_printer
*buffer
, gimple gs
, int spc
,
1221 if (flags
& TDF_RAW
)
1223 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1224 gimple_omp_body (gs
));
1225 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
1226 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T, %T, %T, %T%n>",
1227 gimple_omp_task_child_fn (gs
),
1228 gimple_omp_task_data_arg (gs
),
1229 gimple_omp_task_copy_fn (gs
),
1230 gimple_omp_task_arg_size (gs
),
1231 gimple_omp_task_arg_size (gs
));
1236 pp_string (buffer
, "#pragma omp task");
1237 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
1238 if (gimple_omp_task_child_fn (gs
))
1240 pp_string (buffer
, " [child fn: ");
1241 dump_generic_node (buffer
, gimple_omp_task_child_fn (gs
),
1243 pp_string (buffer
, " (");
1244 if (gimple_omp_task_data_arg (gs
))
1245 dump_generic_node (buffer
, gimple_omp_task_data_arg (gs
),
1248 pp_string (buffer
, "???");
1249 pp_string (buffer
, ")]");
1251 body
= gimple_omp_body (gs
);
1252 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
1254 newline_and_indent (buffer
, spc
+ 2);
1255 pp_character (buffer
, '{');
1256 pp_newline (buffer
);
1257 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
1258 newline_and_indent (buffer
, spc
+ 2);
1259 pp_character (buffer
, '}');
1263 pp_newline (buffer
);
1264 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
1270 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1271 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1275 dump_gimple_omp_atomic_load (pretty_printer
*buffer
, gimple gs
, int spc
,
1278 if (flags
& TDF_RAW
)
1280 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
1281 gimple_omp_atomic_load_lhs (gs
),
1282 gimple_omp_atomic_load_rhs (gs
));
1286 pp_string (buffer
, "#pragma omp atomic_load");
1287 newline_and_indent (buffer
, spc
+ 2);
1288 dump_generic_node (buffer
, gimple_omp_atomic_load_lhs (gs
),
1291 pp_character (buffer
, '=');
1293 pp_character (buffer
, '*');
1294 dump_generic_node (buffer
, gimple_omp_atomic_load_rhs (gs
),
1299 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1300 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1304 dump_gimple_omp_atomic_store (pretty_printer
*buffer
, gimple gs
, int spc
,
1307 if (flags
& TDF_RAW
)
1309 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
,
1310 gimple_omp_atomic_store_val (gs
));
1314 pp_string (buffer
, "#pragma omp atomic_store (");
1315 dump_generic_node (buffer
, gimple_omp_atomic_store_val (gs
),
1317 pp_character (buffer
, ')');
1321 /* Dump a GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. BUFFER, SPC and
1322 FLAGS are as in dump_gimple_stmt. */
1325 dump_gimple_cdt (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1327 if (flags
& TDF_RAW
)
1328 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
1329 gimple_cdt_new_type (gs
), gimple_cdt_location (gs
));
1332 pp_string (buffer
, "<<<change_dynamic_type (");
1333 dump_generic_node (buffer
, gimple_cdt_new_type (gs
), spc
+ 2, flags
,
1335 pp_string (buffer
, ") ");
1336 dump_generic_node (buffer
, gimple_cdt_location (gs
), spc
+ 2, flags
,
1338 pp_string (buffer
, ")>>>");
1343 /* Dump all the memory operands for statement GS. BUFFER, SPC and
1344 FLAGS are as in dump_gimple_stmt. */
1347 dump_gimple_mem_ops (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1349 struct voptype_d
*vdefs
;
1350 struct voptype_d
*vuses
;
1353 if (!ssa_operands_active () || !gimple_references_memory_p (gs
))
1356 /* Even if the statement doesn't have virtual operators yet, it may
1357 contain symbol information (this happens before aliases have been
1359 if ((flags
& TDF_MEMSYMS
)
1360 && gimple_vuse_ops (gs
) == NULL
1361 && gimple_vdef_ops (gs
) == NULL
)
1363 if (gimple_loaded_syms (gs
))
1365 pp_string (buffer
, "# LOADS: ");
1366 dump_symbols (buffer
, gimple_loaded_syms (gs
), flags
);
1367 newline_and_indent (buffer
, spc
);
1370 if (gimple_stored_syms (gs
))
1372 pp_string (buffer
, "# STORES: ");
1373 dump_symbols (buffer
, gimple_stored_syms (gs
), flags
);
1374 newline_and_indent (buffer
, spc
);
1380 vuses
= gimple_vuse_ops (gs
);
1383 pp_string (buffer
, "# VUSE <");
1385 n
= VUSE_NUM (vuses
);
1386 for (i
= 0; i
< n
; i
++)
1388 dump_generic_node (buffer
, VUSE_OP (vuses
, i
), spc
+ 2, flags
, false);
1390 pp_string (buffer
, ", ");
1393 pp_string (buffer
, ">");
1395 if (flags
& TDF_MEMSYMS
)
1396 dump_symbols (buffer
, gimple_loaded_syms (gs
), flags
);
1398 newline_and_indent (buffer
, spc
);
1399 vuses
= vuses
->next
;
1402 vdefs
= gimple_vdef_ops (gs
);
1405 pp_string (buffer
, "# ");
1406 dump_generic_node (buffer
, VDEF_RESULT (vdefs
), spc
+ 2, flags
, false);
1407 pp_string (buffer
, " = VDEF <");
1409 n
= VDEF_NUM (vdefs
);
1410 for (i
= 0; i
< n
; i
++)
1412 dump_generic_node (buffer
, VDEF_OP (vdefs
, i
), spc
+ 2, flags
, 0);
1414 pp_string (buffer
, ", ");
1417 pp_string (buffer
, ">");
1419 if ((flags
& TDF_MEMSYMS
) && vdefs
->next
== NULL
)
1420 dump_symbols (buffer
, gimple_stored_syms (gs
), flags
);
1422 newline_and_indent (buffer
, spc
);
1423 vdefs
= vdefs
->next
;
1428 /* Dump the gimple statement GS on the pretty printer BUFFER, SPC
1429 spaces of indent. FLAGS specifies details to show in the dump (see
1430 TDF_* in tree-pass.h). */
1433 dump_gimple_stmt (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1438 if (flags
& TDF_STMTADDR
)
1439 pp_printf (buffer
, "<&%p> ", (void *) gs
);
1441 if ((flags
& TDF_LINENO
) && gimple_has_location (gs
))
1443 expanded_location xloc
= expand_location (gimple_location (gs
));
1444 pp_character (buffer
, '[');
1447 pp_string (buffer
, xloc
.file
);
1448 pp_string (buffer
, " : ");
1450 pp_decimal_int (buffer
, xloc
.line
);
1451 pp_string (buffer
, "] ");
1454 if ((flags
& (TDF_VOPS
|TDF_MEMSYMS
))
1455 && gimple_has_mem_ops (gs
))
1456 dump_gimple_mem_ops (buffer
, gs
, spc
, flags
);
1458 switch (gimple_code (gs
))
1461 dump_gimple_asm (buffer
, gs
, spc
, flags
);
1465 dump_gimple_assign (buffer
, gs
, spc
, flags
);
1469 dump_gimple_bind (buffer
, gs
, spc
, flags
);
1473 dump_gimple_call (buffer
, gs
, spc
, flags
);
1477 dump_gimple_cond (buffer
, gs
, spc
, flags
);
1481 dump_gimple_label (buffer
, gs
, spc
, flags
);
1485 dump_gimple_goto (buffer
, gs
, spc
, flags
);
1489 pp_string (buffer
, "GIMPLE_NOP");
1493 dump_gimple_return (buffer
, gs
, spc
, flags
);
1497 dump_gimple_switch (buffer
, gs
, spc
, flags
);
1501 dump_gimple_try (buffer
, gs
, spc
, flags
);
1505 dump_gimple_phi (buffer
, gs
, spc
, flags
);
1508 case GIMPLE_OMP_PARALLEL
:
1509 dump_gimple_omp_parallel (buffer
, gs
, spc
, flags
);
1512 case GIMPLE_OMP_TASK
:
1513 dump_gimple_omp_task (buffer
, gs
, spc
, flags
);
1516 case GIMPLE_OMP_ATOMIC_LOAD
:
1517 dump_gimple_omp_atomic_load (buffer
, gs
, spc
, flags
);
1521 case GIMPLE_OMP_ATOMIC_STORE
:
1522 dump_gimple_omp_atomic_store (buffer
, gs
, spc
, flags
);
1525 case GIMPLE_OMP_FOR
:
1526 dump_gimple_omp_for (buffer
, gs
, spc
, flags
);
1529 case GIMPLE_OMP_CONTINUE
:
1530 dump_gimple_omp_continue (buffer
, gs
, spc
, flags
);
1533 case GIMPLE_OMP_SINGLE
:
1534 dump_gimple_omp_single (buffer
, gs
, spc
, flags
);
1537 case GIMPLE_OMP_RETURN
:
1538 dump_gimple_omp_return (buffer
, gs
, spc
, flags
);
1541 case GIMPLE_OMP_SECTIONS
:
1542 dump_gimple_omp_sections (buffer
, gs
, spc
, flags
);
1545 case GIMPLE_OMP_SECTIONS_SWITCH
:
1546 pp_string (buffer
, "GIMPLE_SECTIONS_SWITCH");
1549 case GIMPLE_OMP_MASTER
:
1550 case GIMPLE_OMP_ORDERED
:
1551 case GIMPLE_OMP_SECTION
:
1552 dump_gimple_omp_block (buffer
, gs
, spc
, flags
);
1555 case GIMPLE_OMP_CRITICAL
:
1556 dump_gimple_omp_critical (buffer
, gs
, spc
, flags
);
1559 case GIMPLE_CHANGE_DYNAMIC_TYPE
:
1560 dump_gimple_cdt (buffer
, gs
, spc
, flags
);
1564 dump_gimple_catch (buffer
, gs
, spc
, flags
);
1567 case GIMPLE_EH_FILTER
:
1568 dump_gimple_eh_filter (buffer
, gs
, spc
, flags
);
1572 dump_gimple_resx (buffer
, gs
, spc
, flags
);
1575 case GIMPLE_PREDICT
:
1576 pp_string (buffer
, "// predicted ");
1577 if (gimple_predict_outcome (gs
))
1578 pp_string (buffer
, "likely by ");
1580 pp_string (buffer
, "unlikely by ");
1581 pp_string (buffer
, predictor_name (gimple_predict_predictor (gs
)));
1582 pp_string (buffer
, " predictor.");
1589 /* If we're building a diagnostic, the formatted text will be
1590 written into BUFFER's stream by the caller; otherwise, write it
1592 if (!(flags
& TDF_DIAGNOSTIC
))
1593 pp_write_text_to_stream (buffer
);
1597 /* Dumps header of basic block BB to buffer BUFFER indented by INDENT
1598 spaces and details described by flags. */
1601 dump_bb_header (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1607 if (flags
& TDF_BLOCKS
)
1610 pp_string (buffer
, "# BLOCK ");
1611 pp_decimal_int (buffer
, bb
->index
);
1614 pp_string (buffer
, " freq:");
1615 pp_decimal_int (buffer
, bb
->frequency
);
1619 pp_string (buffer
, " count:");
1620 pp_widest_integer (buffer
, bb
->count
);
1623 if (flags
& TDF_LINENO
)
1625 gimple_stmt_iterator gsi
;
1627 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
1628 if (get_lineno (gsi_stmt (gsi
)) != -1)
1630 pp_string (buffer
, ", starting at line ");
1631 pp_decimal_int (buffer
, get_lineno (gsi_stmt (gsi
)));
1635 newline_and_indent (buffer
, indent
);
1637 pp_string (buffer
, "# PRED:");
1638 pp_write_text_to_stream (buffer
);
1639 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
1640 if (flags
& TDF_SLIM
)
1642 pp_string (buffer
, " ");
1643 if (e
->src
== ENTRY_BLOCK_PTR
)
1644 pp_string (buffer
, "ENTRY");
1646 pp_decimal_int (buffer
, e
->src
->index
);
1649 dump_edge_info (buffer
->buffer
->stream
, e
, 0);
1650 pp_newline (buffer
);
1654 stmt
= first_stmt (bb
);
1655 if (!stmt
|| gimple_code (stmt
) != GIMPLE_LABEL
)
1657 INDENT (indent
- 2);
1658 pp_string (buffer
, "<bb ");
1659 pp_decimal_int (buffer
, bb
->index
);
1660 pp_string (buffer
, ">:");
1661 pp_newline (buffer
);
1664 pp_write_text_to_stream (buffer
);
1665 check_bb_profile (bb
, buffer
->buffer
->stream
);
1669 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
1673 dump_bb_end (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1679 pp_string (buffer
, "# SUCC:");
1680 pp_write_text_to_stream (buffer
);
1681 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
1682 if (flags
& TDF_SLIM
)
1684 pp_string (buffer
, " ");
1685 if (e
->dest
== EXIT_BLOCK_PTR
)
1686 pp_string (buffer
, "EXIT");
1688 pp_decimal_int (buffer
, e
->dest
->index
);
1691 dump_edge_info (buffer
->buffer
->stream
, e
, 1);
1692 pp_newline (buffer
);
1696 /* Dump PHI nodes of basic block BB to BUFFER with details described
1697 by FLAGS and indented by INDENT spaces. */
1700 dump_phi_nodes (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1702 gimple_stmt_iterator i
;
1704 for (i
= gsi_start_phis (bb
); !gsi_end_p (i
); gsi_next (&i
))
1706 gimple phi
= gsi_stmt (i
);
1707 if (is_gimple_reg (gimple_phi_result (phi
)) || (flags
& TDF_VOPS
))
1710 pp_string (buffer
, "# ");
1711 dump_gimple_phi (buffer
, phi
, indent
, flags
);
1712 pp_newline (buffer
);
1718 /* Dump jump to basic block BB that is represented implicitly in the cfg
1722 pp_cfg_jump (pretty_printer
*buffer
, basic_block bb
)
1726 stmt
= first_stmt (bb
);
1728 pp_string (buffer
, "goto <bb ");
1729 pp_decimal_int (buffer
, bb
->index
);
1730 pp_string (buffer
, ">");
1731 if (stmt
&& gimple_code (stmt
) == GIMPLE_LABEL
)
1733 pp_string (buffer
, " (");
1734 dump_generic_node (buffer
, gimple_label_label (stmt
), 0, 0, false);
1735 pp_string (buffer
, ")");
1736 pp_semicolon (buffer
);
1739 pp_semicolon (buffer
);
1743 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
1744 by INDENT spaces, with details given by FLAGS. */
1747 dump_implicit_edges (pretty_printer
*buffer
, basic_block bb
, int indent
,
1754 stmt
= last_stmt (bb
);
1756 if (stmt
&& gimple_code (stmt
) == GIMPLE_COND
)
1758 edge true_edge
, false_edge
;
1760 /* When we are emitting the code or changing CFG, it is possible that
1761 the edges are not yet created. When we are using debug_bb in such
1762 a situation, we do not want it to crash. */
1763 if (EDGE_COUNT (bb
->succs
) != 2)
1765 extract_true_false_edges_from_block (bb
, &true_edge
, &false_edge
);
1767 INDENT (indent
+ 2);
1768 pp_cfg_jump (buffer
, true_edge
->dest
);
1769 newline_and_indent (buffer
, indent
);
1770 pp_string (buffer
, "else");
1771 newline_and_indent (buffer
, indent
+ 2);
1772 pp_cfg_jump (buffer
, false_edge
->dest
);
1773 pp_newline (buffer
);
1777 /* If there is a fallthru edge, we may need to add an artificial
1778 goto to the dump. */
1779 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
1780 if (e
->flags
& EDGE_FALLTHRU
)
1783 if (e
&& e
->dest
!= bb
->next_bb
)
1787 if ((flags
& TDF_LINENO
)
1788 && e
->goto_locus
!= UNKNOWN_LOCATION
1791 expanded_location goto_xloc
;
1792 goto_xloc
= expand_location (e
->goto_locus
);
1793 pp_character (buffer
, '[');
1796 pp_string (buffer
, goto_xloc
.file
);
1797 pp_string (buffer
, " : ");
1799 pp_decimal_int (buffer
, goto_xloc
.line
);
1800 pp_string (buffer
, "] ");
1803 pp_cfg_jump (buffer
, e
->dest
);
1804 pp_newline (buffer
);
1809 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
1810 indented by INDENT spaces. */
1813 gimple_dump_bb_buff (pretty_printer
*buffer
, basic_block bb
, int indent
,
1816 gimple_stmt_iterator gsi
;
1818 int label_indent
= indent
- 2;
1820 if (label_indent
< 0)
1823 dump_bb_header (buffer
, bb
, indent
, flags
);
1824 dump_phi_nodes (buffer
, bb
, indent
, flags
);
1826 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
1830 stmt
= gsi_stmt (gsi
);
1832 curr_indent
= gimple_code (stmt
) == GIMPLE_LABEL
? label_indent
: indent
;
1834 INDENT (curr_indent
);
1835 dump_gimple_stmt (buffer
, stmt
, curr_indent
, flags
);
1836 pp_newline (buffer
);
1837 dump_histograms_for_stmt (cfun
, buffer
->buffer
->stream
, stmt
);
1840 dump_implicit_edges (buffer
, bb
, indent
, flags
);
1842 if (flags
& TDF_BLOCKS
)
1843 dump_bb_end (buffer
, bb
, indent
, flags
);
1847 /* Dumps basic block BB to FILE with details described by FLAGS and
1848 indented by INDENT spaces. */
1851 gimple_dump_bb (basic_block bb
, FILE *file
, int indent
, int flags
)
1853 maybe_init_pretty_print (file
);
1854 gimple_dump_bb_buff (&buffer
, bb
, indent
, flags
);