1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
3 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com> and
5 Diego Novillo <dnovillo@google.com>
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
25 #include "coretypes.h"
28 #include "diagnostic.h"
31 #include "tree-flow.h"
32 #include "tree-pass.h"
34 #include "value-prof.h"
36 #define INDENT(SPACE) \
37 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
39 static pretty_printer buffer
;
40 static bool initialized
= false;
42 #define GIMPLE_NIY do_niy (buffer,gs)
44 /* Try to print on BUFFER a default message for the unrecognized
45 gimple statement GS. */
48 do_niy (pretty_printer
*buffer
, gimple gs
)
50 pp_printf (buffer
, "<<< Unknown GIMPLE statement: %s >>>\n",
51 gimple_code_name
[(int) gimple_code (gs
)]);
55 /* Initialize the pretty printer on FILE if needed. */
58 maybe_init_pretty_print (FILE *file
)
62 pp_construct (&buffer
, NULL
, 0);
63 pp_needs_newline (&buffer
) = true;
67 buffer
.buffer
->stream
= file
;
71 /* Emit a newline and SPC indentantion spaces to BUFFER. */
74 newline_and_indent (pretty_printer
*buffer
, int spc
)
81 /* Print the GIMPLE statement GS on stderr. */
84 debug_gimple_stmt (gimple gs
)
86 print_gimple_stmt (stderr
, gs
, 0, TDF_VOPS
|TDF_MEMSYMS
);
87 fprintf (stderr
, "\n");
91 /* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
92 FLAGS as in dump_gimple_stmt. */
95 print_gimple_stmt (FILE *file
, gimple g
, int spc
, int flags
)
97 maybe_init_pretty_print (file
);
98 dump_gimple_stmt (&buffer
, g
, spc
, flags
);
103 /* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
104 FLAGS as in dump_gimple_stmt. Print only the right-hand side
108 print_gimple_expr (FILE *file
, gimple g
, int spc
, int flags
)
110 flags
|= TDF_RHS_ONLY
;
111 maybe_init_pretty_print (file
);
112 dump_gimple_stmt (&buffer
, g
, spc
, flags
);
116 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion
117 spaces and FLAGS as in dump_gimple_stmt. */
120 dump_gimple_seq (pretty_printer
*buffer
, gimple_seq seq
, int spc
, int flags
)
122 gimple_stmt_iterator i
;
124 for (i
= gsi_start (seq
); !gsi_end_p (i
); gsi_next (&i
))
126 gimple gs
= gsi_stmt (i
);
128 dump_gimple_stmt (buffer
, gs
, spc
, flags
);
129 if (!gsi_one_before_end_p (i
))
135 /* Dump GIMPLE sequence SEQ to FILE using SPC indentantion spaces and
136 FLAGS as in dump_gimple_stmt. */
139 print_gimple_seq (FILE *file
, gimple_seq seq
, int spc
, int flags
)
141 maybe_init_pretty_print (file
);
142 dump_gimple_seq (&buffer
, seq
, spc
, flags
);
147 /* Print the GIMPLE sequence SEQ on stderr. */
150 debug_gimple_seq (gimple_seq seq
)
152 print_gimple_seq (stderr
, seq
, 0, TDF_VOPS
|TDF_MEMSYMS
);
156 /* A simple helper to pretty-print some of the gimple tuples in the printf
157 style. The format modifiers are preceeded by '%' and are:
158 'G' - outputs a string corresponding to the code of the given gimple,
159 'S' - outputs a gimple_seq with indent of spc + 2,
160 'T' - outputs the tree t,
161 'd' - outputs an int as a decimal,
162 's' - outputs a string,
163 'n' - outputs a newline,
164 '+' - increases indent by 2 then outputs a newline,
165 '-' - decreases indent by 2 then outputs a newline. */
168 dump_gimple_fmt (pretty_printer
*buffer
, int spc
, int flags
,
169 const char *fmt
, ...)
175 va_start (args
, fmt
);
176 for (c
= fmt
; *c
; c
++)
186 g
= va_arg (args
, gimple
);
187 tmp
= gimple_code_name
[gimple_code (g
)];
188 pp_string (buffer
, tmp
);
192 seq
= va_arg (args
, gimple_seq
);
194 dump_gimple_seq (buffer
, seq
, spc
+ 2, flags
);
195 newline_and_indent (buffer
, spc
);
199 t
= va_arg (args
, tree
);
201 pp_string (buffer
, "NULL");
203 dump_generic_node (buffer
, t
, spc
, flags
, false);
207 pp_decimal_int (buffer
, va_arg (args
, int));
211 pp_string (buffer
, va_arg (args
, char *));
215 newline_and_indent (buffer
, spc
);
220 newline_and_indent (buffer
, spc
);
225 newline_and_indent (buffer
, spc
);
233 pp_character (buffer
, *c
);
239 /* Helper for dump_gimple_assign. Print the unary RHS of the
240 assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */
243 dump_unary_rhs (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
245 enum tree_code rhs_code
= gimple_assign_rhs_code (gs
);
246 tree lhs
= gimple_assign_lhs (gs
);
247 tree rhs
= gimple_assign_rhs1 (gs
);
251 case VIEW_CONVERT_EXPR
:
253 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
256 case FIXED_CONVERT_EXPR
:
260 pp_character (buffer
, '(');
261 dump_generic_node (buffer
, TREE_TYPE (lhs
), spc
, flags
, false);
262 pp_string (buffer
, ") ");
263 if (op_prio (rhs
) < op_code_prio (rhs_code
))
265 pp_character (buffer
, '(');
266 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
267 pp_character (buffer
, ')');
270 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
274 pp_string (buffer
, "((");
275 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
276 pp_string (buffer
, "))");
280 pp_string (buffer
, "ABS_EXPR <");
281 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
282 pp_character (buffer
, '>');
286 if (TREE_CODE_CLASS (rhs_code
) == tcc_declaration
287 || TREE_CODE_CLASS (rhs_code
) == tcc_constant
288 || TREE_CODE_CLASS (rhs_code
) == tcc_reference
289 || rhs_code
== SSA_NAME
290 || rhs_code
== ADDR_EXPR
291 || rhs_code
== CONSTRUCTOR
)
293 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
296 else if (rhs_code
== BIT_NOT_EXPR
)
297 pp_character (buffer
, '~');
298 else if (rhs_code
== TRUTH_NOT_EXPR
)
299 pp_character (buffer
, '!');
300 else if (rhs_code
== NEGATE_EXPR
)
301 pp_character (buffer
, '-');
302 else if (rhs_code
== NEGATENV_EXPR
)
303 pp_string (buffer
, "-/nv");
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);
381 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
385 dump_gimple_assign (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
390 if (gimple_num_ops (gs
) == 2)
392 else if (gimple_num_ops (gs
) == 3)
393 last
= gimple_assign_rhs2 (gs
);
397 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T>", gs
,
398 tree_code_name
[gimple_assign_rhs_code (gs
)],
399 gimple_assign_lhs (gs
), gimple_assign_rhs1 (gs
), last
);
403 if (!(flags
& TDF_RHS_ONLY
))
405 dump_generic_node (buffer
, gimple_assign_lhs (gs
), spc
, flags
, false);
407 pp_character (buffer
, '=');
409 if (gimple_assign_nontemporal_move_p (gs
))
410 pp_string (buffer
, "{nt}");
412 if (gimple_has_volatile_ops (gs
))
413 pp_string (buffer
, "{v}");
418 if (gimple_num_ops (gs
) == 2)
419 dump_unary_rhs (buffer
, gs
, spc
, flags
);
420 else if (gimple_num_ops (gs
) == 3)
421 dump_binary_rhs (buffer
, gs
, spc
, flags
);
424 if (!(flags
& TDF_RHS_ONLY
))
425 pp_semicolon(buffer
);
430 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
434 dump_gimple_return (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
438 t
= gimple_return_retval (gs
);
440 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, t
);
443 pp_string (buffer
, "return");
447 dump_generic_node (buffer
, t
, spc
, flags
, false);
449 pp_semicolon (buffer
);
454 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
458 dump_gimple_call_args (pretty_printer
*buffer
, gimple gs
, int flags
)
462 for (i
= 0; i
< gimple_call_num_args (gs
); i
++)
464 dump_generic_node (buffer
, gimple_call_arg (gs
, i
), 0, flags
, false);
465 if (i
< gimple_call_num_args (gs
) - 1)
466 pp_string (buffer
, ", ");
469 if (gimple_call_va_arg_pack_p (gs
))
471 if (gimple_call_num_args (gs
) > 0)
473 pp_character (buffer
, ',');
477 pp_string (buffer
, "__builtin_va_arg_pack ()");
482 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
486 dump_gimple_call (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
488 tree lhs
= gimple_call_lhs (gs
);
492 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T",
493 gs
, gimple_call_fn (gs
), lhs
);
494 if (gimple_call_num_args (gs
) > 0)
496 pp_string (buffer
, ", ");
497 dump_gimple_call_args (buffer
, gs
, flags
);
499 pp_character (buffer
, '>');
503 if (lhs
&& !(flags
& TDF_RHS_ONLY
))
505 dump_generic_node (buffer
, lhs
, spc
, flags
, false);
506 pp_string (buffer
, " =");
508 if (gimple_has_volatile_ops (gs
))
509 pp_string (buffer
, "{v}");
513 dump_generic_node (buffer
, gimple_call_fn (gs
), spc
, flags
, false);
514 pp_string (buffer
, " (");
515 dump_gimple_call_args (buffer
, gs
, flags
);
516 pp_character (buffer
, ')');
517 if (!(flags
& TDF_RHS_ONLY
))
518 pp_semicolon (buffer
);
521 if (gimple_call_chain (gs
))
523 pp_string (buffer
, " [static-chain: ");
524 dump_generic_node (buffer
, gimple_call_chain (gs
), spc
, flags
, false);
525 pp_character (buffer
, ']');
528 if (gimple_call_return_slot_opt_p (gs
))
529 pp_string (buffer
, " [return slot optimization]");
531 if (gimple_call_tail_p (gs
))
532 pp_string (buffer
, " [tail call]");
536 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
540 dump_gimple_switch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
544 GIMPLE_CHECK (gs
, GIMPLE_SWITCH
);
546 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", gs
,
547 gimple_switch_index (gs
));
550 pp_string (buffer
, "switch (");
551 dump_generic_node (buffer
, gimple_switch_index (gs
), spc
, flags
, true);
552 pp_string (buffer
, ") <");
555 for (i
= 0; i
< gimple_switch_num_labels (gs
); i
++)
557 tree case_label
= gimple_switch_label (gs
, i
);
558 if (case_label
== NULL_TREE
)
561 dump_generic_node (buffer
, case_label
, spc
, flags
, false);
562 pp_character (buffer
, ' ');
563 dump_generic_node (buffer
, CASE_LABEL (case_label
), spc
, flags
, false);
564 if (i
< gimple_switch_num_labels (gs
) - 1)
565 pp_string (buffer
, ", ");
567 pp_character (buffer
, '>');
571 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
575 dump_gimple_cond (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
578 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T, %T>", gs
,
579 tree_code_name
[gimple_cond_code (gs
)],
580 gimple_cond_lhs (gs
), gimple_cond_rhs (gs
),
581 gimple_cond_true_label (gs
), gimple_cond_false_label (gs
));
584 if (!(flags
& TDF_RHS_ONLY
))
585 pp_string (buffer
, "if (");
586 dump_generic_node (buffer
, gimple_cond_lhs (gs
), spc
, flags
, false);
588 pp_string (buffer
, op_symbol_code (gimple_cond_code (gs
)));
590 dump_generic_node (buffer
, gimple_cond_rhs (gs
), spc
, flags
, false);
591 if (!(flags
& TDF_RHS_ONLY
))
593 pp_character (buffer
, ')');
595 if (gimple_cond_true_label (gs
))
597 pp_string (buffer
, " goto ");
598 dump_generic_node (buffer
, gimple_cond_true_label (gs
),
600 pp_semicolon (buffer
);
602 if (gimple_cond_false_label (gs
))
604 pp_string (buffer
, " else goto ");
605 dump_generic_node (buffer
, gimple_cond_false_label (gs
),
607 pp_semicolon (buffer
);
614 /* Dump a GIMPLE_LABEL 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_label (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
621 tree label
= gimple_label_label (gs
);
623 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
626 dump_generic_node (buffer
, label
, spc
, flags
, false);
627 pp_character (buffer
, ':');
629 if (DECL_NONLOCAL (label
))
630 pp_string (buffer
, " [non-local]");
633 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
634 spaces of indent. FLAGS specifies details to show in the dump (see
635 TDF_* in tree-pass.h). */
638 dump_gimple_goto (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
640 tree label
= gimple_goto_dest (gs
);
642 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
644 dump_gimple_fmt (buffer
, spc
, flags
, "goto %T;", label
);
648 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
649 spaces of indent. FLAGS specifies details to show in the dump (see
650 TDF_* in tree-pass.h). */
653 dump_gimple_bind (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
656 dump_gimple_fmt (buffer
, spc
, flags
, "%G <", gs
);
658 pp_character (buffer
, '{');
659 if (!(flags
& TDF_SLIM
))
663 for (var
= gimple_bind_vars (gs
); var
; var
= TREE_CHAIN (var
))
665 newline_and_indent (buffer
, 2);
666 print_declaration (buffer
, var
, spc
, flags
);
668 if (gimple_bind_vars (gs
))
672 dump_gimple_seq (buffer
, gimple_bind_body (gs
), spc
+ 2, flags
);
673 newline_and_indent (buffer
, spc
);
675 pp_character (buffer
, '>');
677 pp_character (buffer
, '}');
681 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
682 indent. FLAGS specifies details to show in the dump (see TDF_* in
686 dump_gimple_try (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
691 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
692 type
= "GIMPLE_TRY_CATCH";
693 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
694 type
= "GIMPLE_TRY_FINALLY";
696 type
= "UNKNOWN GIMPLE_TRY";
697 dump_gimple_fmt (buffer
, spc
, flags
,
698 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs
, type
,
699 gimple_try_eval (gs
), gimple_try_cleanup (gs
));
703 pp_string (buffer
, "try");
704 newline_and_indent (buffer
, spc
+ 2);
705 pp_character (buffer
, '{');
708 dump_gimple_seq (buffer
, gimple_try_eval (gs
), spc
+ 4, flags
);
709 newline_and_indent (buffer
, spc
+ 2);
710 pp_character (buffer
, '}');
712 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
714 newline_and_indent (buffer
, spc
);
715 pp_string (buffer
, "catch");
716 newline_and_indent (buffer
, spc
+ 2);
717 pp_character (buffer
, '{');
719 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
721 newline_and_indent (buffer
, spc
);
722 pp_string (buffer
, "finally");
723 newline_and_indent (buffer
, spc
+ 2);
724 pp_character (buffer
, '{');
727 pp_string (buffer
, " <UNKNOWN GIMPLE_TRY> {");
730 dump_gimple_seq (buffer
, gimple_try_cleanup (gs
), spc
+ 4, flags
);
731 newline_and_indent (buffer
, spc
+ 2);
732 pp_character (buffer
, '}');
737 /* Dump a GIMPLE_CATCH 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_catch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
745 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+CATCH <%S>%->", gs
,
746 gimple_catch_types (gs
), gimple_catch_handler (gs
));
748 dump_gimple_fmt (buffer
, spc
, flags
, "catch (%T)%+{%S}",
749 gimple_catch_types (gs
), gimple_catch_handler (gs
));
753 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
754 indent. FLAGS specifies details to show in the dump (see TDF_* in
758 dump_gimple_eh_filter (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
761 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+FAILURE <%S>%->", gs
,
762 gimple_eh_filter_types (gs
),
763 gimple_eh_filter_failure (gs
));
765 dump_gimple_fmt (buffer
, spc
, flags
, "<<<eh_filter (%T)>>>%+{%+%S%-}",
766 gimple_eh_filter_types (gs
),
767 gimple_eh_filter_failure (gs
));
771 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
772 indent. FLAGS specifies details to show in the dump (see TDF_* in
776 dump_gimple_resx (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
779 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%d>", gs
,
780 gimple_resx_region (gs
));
782 dump_gimple_fmt (buffer
, spc
, flags
, "resx %d", gimple_resx_region (gs
));
785 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
787 dump_gimple_omp_for (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
793 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
794 gimple_omp_body (gs
));
795 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
796 dump_gimple_fmt (buffer
, spc
, flags
, " >,");
797 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
798 dump_gimple_fmt (buffer
, spc
, flags
,
799 "%+%T, %T, %T, %s, %T,%n",
800 gimple_omp_for_index (gs
, i
),
801 gimple_omp_for_initial (gs
, i
),
802 gimple_omp_for_final (gs
, i
),
803 tree_code_name
[gimple_omp_for_cond (gs
, i
)],
804 gimple_omp_for_incr (gs
, i
));
805 dump_gimple_fmt (buffer
, spc
, flags
, "PRE_BODY <%S>%->",
806 gimple_omp_for_pre_body (gs
));
810 pp_string (buffer
, "#pragma omp for");
811 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
812 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
816 newline_and_indent (buffer
, spc
);
817 pp_string (buffer
, "for (");
818 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
820 pp_string (buffer
, " = ");
821 dump_generic_node (buffer
, gimple_omp_for_initial (gs
, i
), spc
,
823 pp_string (buffer
, "; ");
825 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
828 switch (gimple_omp_for_cond (gs
, i
))
831 pp_character (buffer
, '<');
834 pp_character (buffer
, '>');
837 pp_string (buffer
, "<=");
840 pp_string (buffer
, ">=");
846 dump_generic_node (buffer
, gimple_omp_for_final (gs
, i
), spc
,
848 pp_string (buffer
, "; ");
850 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
852 pp_string (buffer
, " = ");
853 dump_generic_node (buffer
, gimple_omp_for_incr (gs
, i
), spc
,
855 pp_character (buffer
, ')');
858 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
860 newline_and_indent (buffer
, spc
+ 2);
861 pp_character (buffer
, '{');
863 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
864 newline_and_indent (buffer
, spc
+ 2);
865 pp_character (buffer
, '}');
870 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
873 dump_gimple_omp_continue (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
877 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
878 gimple_omp_continue_control_def (gs
),
879 gimple_omp_continue_control_use (gs
));
883 pp_string (buffer
, "#pragma omp continue (");
884 dump_generic_node (buffer
, gimple_omp_continue_control_def (gs
),
886 pp_character (buffer
, ',');
888 dump_generic_node (buffer
, gimple_omp_continue_control_use (gs
),
890 pp_character (buffer
, ')');
894 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
897 dump_gimple_omp_single (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
901 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
902 gimple_omp_body (gs
));
903 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
904 dump_gimple_fmt (buffer
, spc
, flags
, " >");
908 pp_string (buffer
, "#pragma omp single");
909 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
910 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
912 newline_and_indent (buffer
, spc
+ 2);
913 pp_character (buffer
, '{');
915 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
916 newline_and_indent (buffer
, spc
+ 2);
917 pp_character (buffer
, '}');
922 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
925 dump_gimple_omp_sections (pretty_printer
*buffer
, gimple gs
, int spc
,
930 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
931 gimple_omp_body (gs
));
932 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
933 dump_gimple_fmt (buffer
, spc
, flags
, " >");
937 pp_string (buffer
, "#pragma omp sections");
938 if (gimple_omp_sections_control (gs
))
940 pp_string (buffer
, " <");
941 dump_generic_node (buffer
, gimple_omp_sections_control (gs
), spc
,
943 pp_character (buffer
, '>');
945 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
946 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
948 newline_and_indent (buffer
, spc
+ 2);
949 pp_character (buffer
, '{');
951 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
952 newline_and_indent (buffer
, spc
+ 2);
953 pp_character (buffer
, '}');
958 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the pretty_printer
962 dump_gimple_omp_block (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
965 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
966 gimple_omp_body (gs
));
969 switch (gimple_code (gs
))
971 case GIMPLE_OMP_MASTER
:
972 pp_string (buffer
, "#pragma omp master");
974 case GIMPLE_OMP_ORDERED
:
975 pp_string (buffer
, "#pragma omp ordered");
977 case GIMPLE_OMP_SECTION
:
978 pp_string (buffer
, "#pragma omp section");
983 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
985 newline_and_indent (buffer
, spc
+ 2);
986 pp_character (buffer
, '{');
988 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
989 newline_and_indent (buffer
, spc
+ 2);
990 pp_character (buffer
, '}');
995 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
998 dump_gimple_omp_critical (pretty_printer
*buffer
, gimple gs
, int spc
,
1001 if (flags
& TDF_RAW
)
1002 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
1003 gimple_omp_body (gs
));
1006 pp_string (buffer
, "#pragma omp critical");
1007 if (gimple_omp_critical_name (gs
))
1009 pp_string (buffer
, " (");
1010 dump_generic_node (buffer
, gimple_omp_critical_name (gs
), spc
,
1012 pp_character (buffer
, ')');
1014 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1016 newline_and_indent (buffer
, spc
+ 2);
1017 pp_character (buffer
, '{');
1018 pp_newline (buffer
);
1019 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1020 newline_and_indent (buffer
, spc
+ 2);
1021 pp_character (buffer
, '}');
1026 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1029 dump_gimple_omp_return (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1031 if (flags
& TDF_RAW
)
1033 dump_gimple_fmt (buffer
, spc
, flags
, "%G <nowait=%d>", gs
,
1034 (int) gimple_omp_return_nowait_p (gs
));
1038 pp_string (buffer
, "#pragma omp return");
1039 if (gimple_omp_return_nowait_p (gs
))
1040 pp_string (buffer
, "(nowait)");
1044 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1045 indent. FLAGS specifies details to show in the dump (see TDF_* in
1049 dump_gimple_asm (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1053 if (flags
& TDF_RAW
)
1054 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+STRING <%n%s%n>", gs
,
1055 gimple_asm_string (gs
));
1058 pp_string (buffer
, "__asm__");
1059 if (gimple_asm_volatile_p (gs
))
1060 pp_string (buffer
, " __volatile__");
1061 pp_string (buffer
, "(\"");
1062 pp_string (buffer
, gimple_asm_string (gs
));
1063 pp_string (buffer
, "\"");
1066 if (gimple_asm_ninputs (gs
)
1067 || gimple_asm_noutputs (gs
)
1068 || gimple_asm_nclobbers (gs
))
1070 if (gimple_asm_noutputs (gs
))
1072 if (flags
& TDF_RAW
)
1074 newline_and_indent (buffer
, spc
+ 2);
1075 pp_string (buffer
, "OUTPUT: ");
1078 pp_string (buffer
, " : ");
1081 for (i
= 0; i
< gimple_asm_noutputs (gs
); i
++)
1083 dump_generic_node (buffer
, gimple_asm_output_op (gs
, i
), spc
, flags
,
1085 if ( i
< gimple_asm_noutputs (gs
) -1)
1086 pp_string (buffer
, ", ");
1089 if (gimple_asm_ninputs (gs
))
1091 if (flags
& TDF_RAW
)
1093 newline_and_indent (buffer
, spc
+ 2);
1094 pp_string (buffer
, "INPUT: ");
1097 pp_string (buffer
, " : ");
1100 for (i
= 0; i
< gimple_asm_ninputs (gs
); i
++)
1102 dump_generic_node (buffer
, gimple_asm_input_op (gs
, i
), spc
, flags
,
1104 if (i
< gimple_asm_ninputs (gs
) -1)
1105 pp_string (buffer
, " : ");
1108 if (gimple_asm_nclobbers (gs
))
1110 if (flags
& TDF_RAW
)
1112 newline_and_indent (buffer
, spc
+ 2);
1113 pp_string (buffer
, "CLOBBER: ");
1116 pp_string (buffer
, " : ");
1119 for (i
= 0; i
< gimple_asm_nclobbers (gs
); i
++)
1121 dump_generic_node (buffer
, gimple_asm_clobber_op (gs
, i
), spc
, flags
,
1123 if ( i
< gimple_asm_nclobbers (gs
) -1)
1124 pp_string (buffer
, ", ");
1127 if (flags
& TDF_RAW
)
1129 newline_and_indent (buffer
, spc
);
1130 pp_character (buffer
, '>');
1133 pp_string (buffer
, ");");
1137 /* Dump the set of decls SYMS. BUFFER, SPC and FLAGS are as in
1138 dump_generic_node. */
1141 dump_symbols (pretty_printer
*buffer
, bitmap syms
, int flags
)
1147 pp_string (buffer
, "NIL");
1150 pp_string (buffer
, " { ");
1152 EXECUTE_IF_SET_IN_BITMAP (syms
, 0, i
, bi
)
1154 tree sym
= referenced_var_lookup (i
);
1155 dump_generic_node (buffer
, sym
, 0, flags
, false);
1156 pp_character (buffer
, ' ');
1159 pp_character (buffer
, '}');
1164 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in
1165 dump_gimple_stmt. */
1168 dump_gimple_phi (pretty_printer
*buffer
, gimple phi
, int spc
, int flags
)
1172 if (flags
& TDF_RAW
)
1173 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", phi
,
1174 gimple_phi_result (phi
));
1177 dump_generic_node (buffer
, gimple_phi_result (phi
), spc
, flags
, false);
1178 pp_string (buffer
, " = PHI <");
1180 for (i
= 0; i
< gimple_phi_num_args (phi
); i
++)
1182 dump_generic_node (buffer
, gimple_phi_arg_def (phi
, i
), spc
, flags
,
1184 pp_character (buffer
, '(');
1185 pp_decimal_int (buffer
, gimple_phi_arg_edge (phi
, i
)->src
->index
);
1186 pp_character (buffer
, ')');
1187 if (i
< gimple_phi_num_args (phi
) - 1)
1188 pp_string (buffer
, ", ");
1190 pp_character (buffer
, '>');
1194 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1195 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1199 dump_gimple_omp_parallel (pretty_printer
*buffer
, gimple gs
, int spc
,
1202 if (flags
& TDF_RAW
)
1204 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1205 gimple_omp_body (gs
));
1206 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
1207 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T%n>",
1208 gimple_omp_parallel_child_fn (gs
),
1209 gimple_omp_parallel_data_arg (gs
));
1214 pp_string (buffer
, "#pragma omp parallel");
1215 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
1216 if (gimple_omp_parallel_child_fn (gs
))
1218 pp_string (buffer
, " [child fn: ");
1219 dump_generic_node (buffer
, gimple_omp_parallel_child_fn (gs
),
1221 pp_string (buffer
, " (");
1222 if (gimple_omp_parallel_data_arg (gs
))
1223 dump_generic_node (buffer
, gimple_omp_parallel_data_arg (gs
),
1226 pp_string (buffer
, "???");
1227 pp_string (buffer
, ")]");
1229 body
= gimple_omp_body (gs
);
1230 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
1232 newline_and_indent (buffer
, spc
+ 2);
1233 pp_character (buffer
, '{');
1234 pp_newline (buffer
);
1235 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
1236 newline_and_indent (buffer
, spc
+ 2);
1237 pp_character (buffer
, '}');
1241 pp_newline (buffer
);
1242 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
1248 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1249 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1253 dump_gimple_omp_task (pretty_printer
*buffer
, gimple gs
, int spc
,
1256 if (flags
& TDF_RAW
)
1258 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1259 gimple_omp_body (gs
));
1260 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
1261 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T, %T, %T, %T%n>",
1262 gimple_omp_task_child_fn (gs
),
1263 gimple_omp_task_data_arg (gs
),
1264 gimple_omp_task_copy_fn (gs
),
1265 gimple_omp_task_arg_size (gs
),
1266 gimple_omp_task_arg_size (gs
));
1271 pp_string (buffer
, "#pragma omp task");
1272 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
1273 if (gimple_omp_task_child_fn (gs
))
1275 pp_string (buffer
, " [child fn: ");
1276 dump_generic_node (buffer
, gimple_omp_task_child_fn (gs
),
1278 pp_string (buffer
, " (");
1279 if (gimple_omp_task_data_arg (gs
))
1280 dump_generic_node (buffer
, gimple_omp_task_data_arg (gs
),
1283 pp_string (buffer
, "???");
1284 pp_string (buffer
, ")]");
1286 body
= gimple_omp_body (gs
);
1287 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
1289 newline_and_indent (buffer
, spc
+ 2);
1290 pp_character (buffer
, '{');
1291 pp_newline (buffer
);
1292 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
1293 newline_and_indent (buffer
, spc
+ 2);
1294 pp_character (buffer
, '}');
1298 pp_newline (buffer
);
1299 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
1305 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1306 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1310 dump_gimple_omp_atomic_load (pretty_printer
*buffer
, gimple gs
, int spc
,
1313 if (flags
& TDF_RAW
)
1315 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
1316 gimple_omp_atomic_load_lhs (gs
),
1317 gimple_omp_atomic_load_rhs (gs
));
1321 pp_string (buffer
, "#pragma omp atomic_load");
1322 newline_and_indent (buffer
, spc
+ 2);
1323 dump_generic_node (buffer
, gimple_omp_atomic_load_lhs (gs
),
1326 pp_character (buffer
, '=');
1328 pp_character (buffer
, '*');
1329 dump_generic_node (buffer
, gimple_omp_atomic_load_rhs (gs
),
1334 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1335 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1339 dump_gimple_omp_atomic_store (pretty_printer
*buffer
, gimple gs
, int spc
,
1342 if (flags
& TDF_RAW
)
1344 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
,
1345 gimple_omp_atomic_store_val (gs
));
1349 pp_string (buffer
, "#pragma omp atomic_store (");
1350 dump_generic_node (buffer
, gimple_omp_atomic_store_val (gs
),
1352 pp_character (buffer
, ')');
1356 /* Dump a GIMPLE_CHANGE_DYNAMIC_TYPE statement GS. BUFFER, SPC and
1357 FLAGS are as in dump_gimple_stmt. */
1360 dump_gimple_cdt (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1362 if (flags
& TDF_RAW
)
1363 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
1364 gimple_cdt_new_type (gs
), gimple_cdt_location (gs
));
1367 pp_string (buffer
, "<<<change_dynamic_type (");
1368 dump_generic_node (buffer
, gimple_cdt_new_type (gs
), spc
+ 2, flags
,
1370 pp_string (buffer
, ") ");
1371 dump_generic_node (buffer
, gimple_cdt_location (gs
), spc
+ 2, flags
,
1373 pp_string (buffer
, ")>>>");
1378 /* Dump all the memory operands for statement GS. BUFFER, SPC and
1379 FLAGS are as in dump_gimple_stmt. */
1382 dump_gimple_mem_ops (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1384 struct voptype_d
*vdefs
;
1385 struct voptype_d
*vuses
;
1388 if (!ssa_operands_active () || !gimple_references_memory_p (gs
))
1391 /* Even if the statement doesn't have virtual operators yet, it may
1392 contain symbol information (this happens before aliases have been
1394 if ((flags
& TDF_MEMSYMS
)
1395 && gimple_vuse_ops (gs
) == NULL
1396 && gimple_vdef_ops (gs
) == NULL
)
1398 if (gimple_loaded_syms (gs
))
1400 pp_string (buffer
, "# LOADS: ");
1401 dump_symbols (buffer
, gimple_loaded_syms (gs
), flags
);
1402 newline_and_indent (buffer
, spc
);
1405 if (gimple_stored_syms (gs
))
1407 pp_string (buffer
, "# STORES: ");
1408 dump_symbols (buffer
, gimple_stored_syms (gs
), flags
);
1409 newline_and_indent (buffer
, spc
);
1415 vuses
= gimple_vuse_ops (gs
);
1418 pp_string (buffer
, "# VUSE <");
1420 n
= VUSE_NUM (vuses
);
1421 for (i
= 0; i
< n
; i
++)
1423 dump_generic_node (buffer
, VUSE_OP (vuses
, i
), spc
+ 2, flags
, false);
1425 pp_string (buffer
, ", ");
1428 pp_character (buffer
, '>');
1430 if (flags
& TDF_MEMSYMS
)
1431 dump_symbols (buffer
, gimple_loaded_syms (gs
), flags
);
1433 newline_and_indent (buffer
, spc
);
1434 vuses
= vuses
->next
;
1437 vdefs
= gimple_vdef_ops (gs
);
1440 pp_string (buffer
, "# ");
1441 dump_generic_node (buffer
, VDEF_RESULT (vdefs
), spc
+ 2, flags
, false);
1442 pp_string (buffer
, " = VDEF <");
1444 n
= VDEF_NUM (vdefs
);
1445 for (i
= 0; i
< n
; i
++)
1447 dump_generic_node (buffer
, VDEF_OP (vdefs
, i
), spc
+ 2, flags
, 0);
1449 pp_string (buffer
, ", ");
1452 pp_character (buffer
, '>');
1454 if ((flags
& TDF_MEMSYMS
) && vdefs
->next
== NULL
)
1455 dump_symbols (buffer
, gimple_stored_syms (gs
), flags
);
1457 newline_and_indent (buffer
, spc
);
1458 vdefs
= vdefs
->next
;
1463 /* Dump the gimple statement GS on the pretty printer BUFFER, SPC
1464 spaces of indent. FLAGS specifies details to show in the dump (see
1465 TDF_* in tree-pass.h). */
1468 dump_gimple_stmt (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1473 if (flags
& TDF_STMTADDR
)
1474 pp_printf (buffer
, "<&%p> ", (void *) gs
);
1476 if ((flags
& TDF_LINENO
) && gimple_has_location (gs
))
1478 expanded_location xloc
= expand_location (gimple_location (gs
));
1479 pp_character (buffer
, '[');
1482 pp_string (buffer
, xloc
.file
);
1483 pp_string (buffer
, " : ");
1485 pp_decimal_int (buffer
, xloc
.line
);
1486 pp_string (buffer
, "] ");
1489 if ((flags
& (TDF_VOPS
|TDF_MEMSYMS
))
1490 && gimple_has_mem_ops (gs
))
1491 dump_gimple_mem_ops (buffer
, gs
, spc
, flags
);
1493 switch (gimple_code (gs
))
1496 dump_gimple_asm (buffer
, gs
, spc
, flags
);
1500 dump_gimple_assign (buffer
, gs
, spc
, flags
);
1504 dump_gimple_bind (buffer
, gs
, spc
, flags
);
1508 dump_gimple_call (buffer
, gs
, spc
, flags
);
1512 dump_gimple_cond (buffer
, gs
, spc
, flags
);
1516 dump_gimple_label (buffer
, gs
, spc
, flags
);
1520 dump_gimple_goto (buffer
, gs
, spc
, flags
);
1524 pp_string (buffer
, "GIMPLE_NOP");
1528 dump_gimple_return (buffer
, gs
, spc
, flags
);
1532 dump_gimple_switch (buffer
, gs
, spc
, flags
);
1536 dump_gimple_try (buffer
, gs
, spc
, flags
);
1540 dump_gimple_phi (buffer
, gs
, spc
, flags
);
1543 case GIMPLE_OMP_PARALLEL
:
1544 dump_gimple_omp_parallel (buffer
, gs
, spc
, flags
);
1547 case GIMPLE_OMP_TASK
:
1548 dump_gimple_omp_task (buffer
, gs
, spc
, flags
);
1551 case GIMPLE_OMP_ATOMIC_LOAD
:
1552 dump_gimple_omp_atomic_load (buffer
, gs
, spc
, flags
);
1556 case GIMPLE_OMP_ATOMIC_STORE
:
1557 dump_gimple_omp_atomic_store (buffer
, gs
, spc
, flags
);
1560 case GIMPLE_OMP_FOR
:
1561 dump_gimple_omp_for (buffer
, gs
, spc
, flags
);
1564 case GIMPLE_OMP_CONTINUE
:
1565 dump_gimple_omp_continue (buffer
, gs
, spc
, flags
);
1568 case GIMPLE_OMP_SINGLE
:
1569 dump_gimple_omp_single (buffer
, gs
, spc
, flags
);
1572 case GIMPLE_OMP_RETURN
:
1573 dump_gimple_omp_return (buffer
, gs
, spc
, flags
);
1576 case GIMPLE_OMP_SECTIONS
:
1577 dump_gimple_omp_sections (buffer
, gs
, spc
, flags
);
1580 case GIMPLE_OMP_SECTIONS_SWITCH
:
1581 pp_string (buffer
, "GIMPLE_SECTIONS_SWITCH");
1584 case GIMPLE_OMP_MASTER
:
1585 case GIMPLE_OMP_ORDERED
:
1586 case GIMPLE_OMP_SECTION
:
1587 dump_gimple_omp_block (buffer
, gs
, spc
, flags
);
1590 case GIMPLE_OMP_CRITICAL
:
1591 dump_gimple_omp_critical (buffer
, gs
, spc
, flags
);
1594 case GIMPLE_CHANGE_DYNAMIC_TYPE
:
1595 dump_gimple_cdt (buffer
, gs
, spc
, flags
);
1599 dump_gimple_catch (buffer
, gs
, spc
, flags
);
1602 case GIMPLE_EH_FILTER
:
1603 dump_gimple_eh_filter (buffer
, gs
, spc
, flags
);
1607 dump_gimple_resx (buffer
, gs
, spc
, flags
);
1610 case GIMPLE_PREDICT
:
1611 pp_string (buffer
, "// predicted ");
1612 if (gimple_predict_outcome (gs
))
1613 pp_string (buffer
, "likely by ");
1615 pp_string (buffer
, "unlikely by ");
1616 pp_string (buffer
, predictor_name (gimple_predict_predictor (gs
)));
1617 pp_string (buffer
, " predictor.");
1624 /* If we're building a diagnostic, the formatted text will be
1625 written into BUFFER's stream by the caller; otherwise, write it
1627 if (!(flags
& TDF_DIAGNOSTIC
))
1628 pp_write_text_to_stream (buffer
);
1632 /* Dumps header of basic block BB to buffer BUFFER indented by INDENT
1633 spaces and details described by flags. */
1636 dump_bb_header (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1642 if (flags
& TDF_BLOCKS
)
1645 pp_string (buffer
, "# BLOCK ");
1646 pp_decimal_int (buffer
, bb
->index
);
1649 pp_string (buffer
, " freq:");
1650 pp_decimal_int (buffer
, bb
->frequency
);
1654 pp_string (buffer
, " count:");
1655 pp_widest_integer (buffer
, bb
->count
);
1658 if (flags
& TDF_LINENO
)
1660 gimple_stmt_iterator gsi
;
1662 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
1663 if (get_lineno (gsi_stmt (gsi
)) != -1)
1665 pp_string (buffer
, ", starting at line ");
1666 pp_decimal_int (buffer
, get_lineno (gsi_stmt (gsi
)));
1670 newline_and_indent (buffer
, indent
);
1672 pp_string (buffer
, "# PRED:");
1673 pp_write_text_to_stream (buffer
);
1674 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
1675 if (flags
& TDF_SLIM
)
1677 pp_character (buffer
, ' ');
1678 if (e
->src
== ENTRY_BLOCK_PTR
)
1679 pp_string (buffer
, "ENTRY");
1681 pp_decimal_int (buffer
, e
->src
->index
);
1684 dump_edge_info (buffer
->buffer
->stream
, e
, 0);
1685 pp_newline (buffer
);
1689 stmt
= first_stmt (bb
);
1690 if (!stmt
|| gimple_code (stmt
) != GIMPLE_LABEL
)
1692 INDENT (indent
- 2);
1693 pp_string (buffer
, "<bb ");
1694 pp_decimal_int (buffer
, bb
->index
);
1695 pp_string (buffer
, ">:");
1696 pp_newline (buffer
);
1699 pp_write_text_to_stream (buffer
);
1700 check_bb_profile (bb
, buffer
->buffer
->stream
);
1704 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
1708 dump_bb_end (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1714 pp_string (buffer
, "# SUCC:");
1715 pp_write_text_to_stream (buffer
);
1716 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
1717 if (flags
& TDF_SLIM
)
1719 pp_character (buffer
, ' ');
1720 if (e
->dest
== EXIT_BLOCK_PTR
)
1721 pp_string (buffer
, "EXIT");
1723 pp_decimal_int (buffer
, e
->dest
->index
);
1726 dump_edge_info (buffer
->buffer
->stream
, e
, 1);
1727 pp_newline (buffer
);
1731 /* Dump PHI nodes of basic block BB to BUFFER with details described
1732 by FLAGS and indented by INDENT spaces. */
1735 dump_phi_nodes (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
1737 gimple_stmt_iterator i
;
1739 for (i
= gsi_start_phis (bb
); !gsi_end_p (i
); gsi_next (&i
))
1741 gimple phi
= gsi_stmt (i
);
1742 if (is_gimple_reg (gimple_phi_result (phi
)) || (flags
& TDF_VOPS
))
1745 pp_string (buffer
, "# ");
1746 dump_gimple_phi (buffer
, phi
, indent
, flags
);
1747 pp_newline (buffer
);
1753 /* Dump jump to basic block BB that is represented implicitly in the cfg
1757 pp_cfg_jump (pretty_printer
*buffer
, basic_block bb
)
1761 stmt
= first_stmt (bb
);
1763 pp_string (buffer
, "goto <bb ");
1764 pp_decimal_int (buffer
, bb
->index
);
1765 pp_character (buffer
, '>');
1766 if (stmt
&& gimple_code (stmt
) == GIMPLE_LABEL
)
1768 pp_string (buffer
, " (");
1769 dump_generic_node (buffer
, gimple_label_label (stmt
), 0, 0, false);
1770 pp_character (buffer
, ')');
1771 pp_semicolon (buffer
);
1774 pp_semicolon (buffer
);
1778 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
1779 by INDENT spaces, with details given by FLAGS. */
1782 dump_implicit_edges (pretty_printer
*buffer
, basic_block bb
, int indent
,
1789 stmt
= last_stmt (bb
);
1791 if (stmt
&& gimple_code (stmt
) == GIMPLE_COND
)
1793 edge true_edge
, false_edge
;
1795 /* When we are emitting the code or changing CFG, it is possible that
1796 the edges are not yet created. When we are using debug_bb in such
1797 a situation, we do not want it to crash. */
1798 if (EDGE_COUNT (bb
->succs
) != 2)
1800 extract_true_false_edges_from_block (bb
, &true_edge
, &false_edge
);
1802 INDENT (indent
+ 2);
1803 pp_cfg_jump (buffer
, true_edge
->dest
);
1804 newline_and_indent (buffer
, indent
);
1805 pp_string (buffer
, "else");
1806 newline_and_indent (buffer
, indent
+ 2);
1807 pp_cfg_jump (buffer
, false_edge
->dest
);
1808 pp_newline (buffer
);
1812 /* If there is a fallthru edge, we may need to add an artificial
1813 goto to the dump. */
1814 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
1815 if (e
->flags
& EDGE_FALLTHRU
)
1818 if (e
&& e
->dest
!= bb
->next_bb
)
1822 if ((flags
& TDF_LINENO
)
1823 && e
->goto_locus
!= UNKNOWN_LOCATION
1826 expanded_location goto_xloc
;
1827 goto_xloc
= expand_location (e
->goto_locus
);
1828 pp_character (buffer
, '[');
1831 pp_string (buffer
, goto_xloc
.file
);
1832 pp_string (buffer
, " : ");
1834 pp_decimal_int (buffer
, goto_xloc
.line
);
1835 pp_string (buffer
, "] ");
1838 pp_cfg_jump (buffer
, e
->dest
);
1839 pp_newline (buffer
);
1844 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
1845 indented by INDENT spaces. */
1848 gimple_dump_bb_buff (pretty_printer
*buffer
, basic_block bb
, int indent
,
1851 gimple_stmt_iterator gsi
;
1853 int label_indent
= indent
- 2;
1855 if (label_indent
< 0)
1858 dump_bb_header (buffer
, bb
, indent
, flags
);
1859 dump_phi_nodes (buffer
, bb
, indent
, flags
);
1861 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
1865 stmt
= gsi_stmt (gsi
);
1867 curr_indent
= gimple_code (stmt
) == GIMPLE_LABEL
? label_indent
: indent
;
1869 INDENT (curr_indent
);
1870 dump_gimple_stmt (buffer
, stmt
, curr_indent
, flags
);
1871 pp_newline (buffer
);
1872 dump_histograms_for_stmt (cfun
, buffer
->buffer
->stream
, stmt
);
1875 dump_implicit_edges (buffer
, bb
, indent
, flags
);
1877 if (flags
& TDF_BLOCKS
)
1878 dump_bb_end (buffer
, bb
, indent
, flags
);
1882 /* Dumps basic block BB to FILE with details described by FLAGS and
1883 indented by INDENT spaces. */
1886 gimple_dump_bb (basic_block bb
, FILE *file
, int indent
, int flags
)
1888 maybe_init_pretty_print (file
);
1889 gimple_dump_bb_buff (&buffer
, bb
, indent
, flags
);