1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Contributed by Aldy Hernandez <aldyh@redhat.com> and
4 Diego Novillo <dnovillo@google.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
24 #include "coretypes.h"
27 #include "diagnostic.h"
28 #include "gimple-pretty-print.h"
32 #include "gimple-ssa.h"
35 #include "tree-ssanames.h"
36 #include "dumpfile.h" /* for dump_flags */
37 #include "value-prof.h"
38 #include "trans-mem.h"
40 #define INDENT(SPACE) \
41 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
43 #define GIMPLE_NIY do_niy (buffer,gs)
45 /* Try to print on BUFFER a default message for the unrecognized
46 gimple statement GS. */
49 do_niy (pretty_printer
*buffer
, gimple gs
)
51 pp_printf (buffer
, "<<< Unknown GIMPLE statement: %s >>>\n",
52 gimple_code_name
[(int) gimple_code (gs
)]);
56 /* Emit a newline and SPC indentation spaces to BUFFER. */
59 newline_and_indent (pretty_printer
*buffer
, int spc
)
66 /* Print the GIMPLE statement GS on stderr. */
69 debug_gimple_stmt (gimple gs
)
71 print_gimple_stmt (stderr
, gs
, 0, TDF_VOPS
|TDF_MEMSYMS
);
75 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
76 FLAGS as in pp_gimple_stmt_1. */
79 print_gimple_stmt (FILE *file
, gimple g
, int spc
, int flags
)
81 pretty_printer buffer
;
82 pp_needs_newline (&buffer
) = true;
83 buffer
.buffer
->stream
= file
;
84 pp_gimple_stmt_1 (&buffer
, g
, spc
, flags
);
85 pp_newline_and_flush (&buffer
);
89 debug (gimple_statement_d
&ref
)
91 print_gimple_stmt (stderr
, &ref
, 0, 0);
95 debug (gimple_statement_d
*ptr
)
100 fprintf (stderr
, "<nil>\n");
104 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
105 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
109 print_gimple_expr (FILE *file
, gimple g
, int spc
, int flags
)
111 flags
|= TDF_RHS_ONLY
;
112 pretty_printer buffer
;
113 pp_needs_newline (&buffer
) = true;
114 buffer
.buffer
->stream
= file
;
115 pp_gimple_stmt_1 (&buffer
, g
, spc
, flags
);
120 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
121 spaces and FLAGS as in pp_gimple_stmt_1.
122 The caller is responsible for calling pp_flush on BUFFER to finalize
123 the pretty printer. */
126 dump_gimple_seq (pretty_printer
*buffer
, gimple_seq seq
, int spc
, int flags
)
128 gimple_stmt_iterator i
;
130 for (i
= gsi_start (seq
); !gsi_end_p (i
); gsi_next (&i
))
132 gimple gs
= gsi_stmt (i
);
134 pp_gimple_stmt_1 (buffer
, gs
, spc
, flags
);
135 if (!gsi_one_before_end_p (i
))
141 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
142 FLAGS as in pp_gimple_stmt_1. */
145 print_gimple_seq (FILE *file
, gimple_seq seq
, int spc
, int flags
)
147 pretty_printer buffer
;
148 pp_needs_newline (&buffer
) = true;
149 buffer
.buffer
->stream
= file
;
150 dump_gimple_seq (&buffer
, seq
, spc
, flags
);
151 pp_newline_and_flush (&buffer
);
155 /* Print the GIMPLE sequence SEQ on stderr. */
158 debug_gimple_seq (gimple_seq seq
)
160 print_gimple_seq (stderr
, seq
, 0, TDF_VOPS
|TDF_MEMSYMS
);
164 /* A simple helper to pretty-print some of the gimple tuples in the printf
165 style. The format modifiers are preceded by '%' and are:
166 'G' - outputs a string corresponding to the code of the given gimple,
167 'S' - outputs a gimple_seq with indent of spc + 2,
168 'T' - outputs the tree t,
169 'd' - outputs an int as a decimal,
170 's' - outputs a string,
171 'n' - outputs a newline,
172 'x' - outputs an int as hexadecimal,
173 '+' - increases indent by 2 then outputs a newline,
174 '-' - decreases indent by 2 then outputs a newline. */
177 dump_gimple_fmt (pretty_printer
*buffer
, int spc
, int flags
,
178 const char *fmt
, ...)
184 va_start (args
, fmt
);
185 for (c
= fmt
; *c
; c
++)
195 g
= va_arg (args
, gimple
);
196 tmp
= gimple_code_name
[gimple_code (g
)];
197 pp_string (buffer
, tmp
);
201 seq
= va_arg (args
, gimple_seq
);
203 dump_gimple_seq (buffer
, seq
, spc
+ 2, flags
);
204 newline_and_indent (buffer
, spc
);
208 t
= va_arg (args
, tree
);
210 pp_string (buffer
, "NULL");
212 dump_generic_node (buffer
, t
, spc
, flags
, false);
216 pp_decimal_int (buffer
, va_arg (args
, int));
220 pp_string (buffer
, va_arg (args
, char *));
224 newline_and_indent (buffer
, spc
);
228 pp_scalar (buffer
, "%x", va_arg (args
, int));
233 newline_and_indent (buffer
, spc
);
238 newline_and_indent (buffer
, spc
);
246 pp_character (buffer
, *c
);
252 /* Helper for dump_gimple_assign. Print the unary RHS of the
253 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
256 dump_unary_rhs (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
258 enum tree_code rhs_code
= gimple_assign_rhs_code (gs
);
259 tree lhs
= gimple_assign_lhs (gs
);
260 tree rhs
= gimple_assign_rhs1 (gs
);
264 case VIEW_CONVERT_EXPR
:
266 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
269 case FIXED_CONVERT_EXPR
:
270 case ADDR_SPACE_CONVERT_EXPR
:
274 pp_left_paren (buffer
);
275 dump_generic_node (buffer
, TREE_TYPE (lhs
), spc
, flags
, false);
276 pp_string (buffer
, ") ");
277 if (op_prio (rhs
) < op_code_prio (rhs_code
))
279 pp_left_paren (buffer
);
280 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
281 pp_right_paren (buffer
);
284 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
288 pp_string (buffer
, "((");
289 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
290 pp_string (buffer
, "))");
294 pp_string (buffer
, "ABS_EXPR <");
295 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
300 if (TREE_CODE_CLASS (rhs_code
) == tcc_declaration
301 || TREE_CODE_CLASS (rhs_code
) == tcc_constant
302 || TREE_CODE_CLASS (rhs_code
) == tcc_reference
303 || rhs_code
== SSA_NAME
304 || rhs_code
== ADDR_EXPR
305 || rhs_code
== CONSTRUCTOR
)
307 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
310 else if (rhs_code
== BIT_NOT_EXPR
)
311 pp_complement (buffer
);
312 else if (rhs_code
== TRUTH_NOT_EXPR
)
313 pp_exclamation (buffer
);
314 else if (rhs_code
== NEGATE_EXPR
)
318 pp_left_bracket (buffer
);
319 pp_string (buffer
, get_tree_code_name (rhs_code
));
320 pp_string (buffer
, "] ");
323 if (op_prio (rhs
) < op_code_prio (rhs_code
))
325 pp_left_paren (buffer
);
326 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
327 pp_right_paren (buffer
);
330 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
336 /* Helper for dump_gimple_assign. Print the binary RHS of the
337 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
340 dump_binary_rhs (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
343 enum tree_code code
= gimple_assign_rhs_code (gs
);
349 case VEC_WIDEN_MULT_HI_EXPR
:
350 case VEC_WIDEN_MULT_LO_EXPR
:
351 case VEC_WIDEN_MULT_EVEN_EXPR
:
352 case VEC_WIDEN_MULT_ODD_EXPR
:
353 case VEC_PACK_TRUNC_EXPR
:
354 case VEC_PACK_SAT_EXPR
:
355 case VEC_PACK_FIX_TRUNC_EXPR
:
356 case VEC_WIDEN_LSHIFT_HI_EXPR
:
357 case VEC_WIDEN_LSHIFT_LO_EXPR
:
358 for (p
= get_tree_code_name (code
); *p
; p
++)
359 pp_character (buffer
, TOUPPER (*p
));
360 pp_string (buffer
, " <");
361 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
362 pp_string (buffer
, ", ");
363 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
368 if (op_prio (gimple_assign_rhs1 (gs
)) <= op_code_prio (code
))
370 pp_left_paren (buffer
);
371 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
,
373 pp_right_paren (buffer
);
376 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
378 pp_string (buffer
, op_symbol_code (gimple_assign_rhs_code (gs
)));
380 if (op_prio (gimple_assign_rhs2 (gs
)) <= op_code_prio (code
))
382 pp_left_paren (buffer
);
383 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
,
385 pp_right_paren (buffer
);
388 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
392 /* Helper for dump_gimple_assign. Print the ternary RHS of the
393 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
396 dump_ternary_rhs (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
399 enum tree_code code
= gimple_assign_rhs_code (gs
);
402 case WIDEN_MULT_PLUS_EXPR
:
403 case WIDEN_MULT_MINUS_EXPR
:
404 for (p
= get_tree_code_name (code
); *p
; p
++)
405 pp_character (buffer
, TOUPPER (*p
));
406 pp_string (buffer
, " <");
407 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
408 pp_string (buffer
, ", ");
409 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
410 pp_string (buffer
, ", ");
411 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
416 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
417 pp_string (buffer
, " * ");
418 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
419 pp_string (buffer
, " + ");
420 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
424 pp_string (buffer
, "DOT_PROD_EXPR <");
425 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
426 pp_string (buffer
, ", ");
427 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
428 pp_string (buffer
, ", ");
429 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
434 pp_string (buffer
, "VEC_PERM_EXPR <");
435 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
436 pp_string (buffer
, ", ");
437 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
438 pp_string (buffer
, ", ");
439 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
443 case REALIGN_LOAD_EXPR
:
444 pp_string (buffer
, "REALIGN_LOAD <");
445 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
446 pp_string (buffer
, ", ");
447 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
448 pp_string (buffer
, ", ");
449 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
454 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
455 pp_string (buffer
, " ? ");
456 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
457 pp_string (buffer
, " : ");
458 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
462 pp_string (buffer
, "VEC_COND_EXPR <");
463 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
464 pp_string (buffer
, ", ");
465 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
466 pp_string (buffer
, ", ");
467 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
477 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
481 dump_gimple_assign (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
488 switch (gimple_num_ops (gs
))
491 arg3
= gimple_assign_rhs3 (gs
);
493 arg2
= gimple_assign_rhs2 (gs
);
495 arg1
= gimple_assign_rhs1 (gs
);
501 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T, %T>", gs
,
502 get_tree_code_name (gimple_assign_rhs_code (gs
)),
503 gimple_assign_lhs (gs
), arg1
, arg2
, arg3
);
507 if (!(flags
& TDF_RHS_ONLY
))
509 dump_generic_node (buffer
, gimple_assign_lhs (gs
), spc
, flags
, false);
513 if (gimple_assign_nontemporal_move_p (gs
))
514 pp_string (buffer
, "{nt}");
516 if (gimple_has_volatile_ops (gs
))
517 pp_string (buffer
, "{v}");
522 if (gimple_num_ops (gs
) == 2)
523 dump_unary_rhs (buffer
, gs
, spc
, flags
);
524 else if (gimple_num_ops (gs
) == 3)
525 dump_binary_rhs (buffer
, gs
, spc
, flags
);
526 else if (gimple_num_ops (gs
) == 4)
527 dump_ternary_rhs (buffer
, gs
, spc
, flags
);
530 if (!(flags
& TDF_RHS_ONLY
))
531 pp_semicolon (buffer
);
536 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
540 dump_gimple_return (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
544 t
= gimple_return_retval (gs
);
545 t2
= gimple_return_retbnd (gs
);
547 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T %T>", gs
, t
, t2
);
550 pp_string (buffer
, "return");
554 dump_generic_node (buffer
, t
, spc
, flags
, false);
558 pp_string (buffer
, ", ");
559 dump_generic_node (buffer
, t2
, spc
, flags
, false);
561 pp_semicolon (buffer
);
566 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
570 dump_gimple_call_args (pretty_printer
*buffer
, gimple gs
, int flags
)
574 for (i
= 0; i
< gimple_call_num_args (gs
); i
++)
576 dump_generic_node (buffer
, gimple_call_arg (gs
, i
), 0, flags
, false);
577 if (i
< gimple_call_num_args (gs
) - 1)
578 pp_string (buffer
, ", ");
581 if (gimple_call_va_arg_pack_p (gs
))
583 if (gimple_call_num_args (gs
) > 0)
589 pp_string (buffer
, "__builtin_va_arg_pack ()");
593 /* Dump the points-to solution *PT to BUFFER. */
596 pp_points_to_solution (pretty_printer
*buffer
, struct pt_solution
*pt
)
600 pp_string (buffer
, "anything ");
604 pp_string (buffer
, "nonlocal ");
606 pp_string (buffer
, "escaped ");
608 pp_string (buffer
, "unit-escaped ");
610 pp_string (buffer
, "null ");
612 && !bitmap_empty_p (pt
->vars
))
616 pp_string (buffer
, "{ ");
617 EXECUTE_IF_SET_IN_BITMAP (pt
->vars
, 0, i
, bi
)
619 pp_string (buffer
, "D.");
620 pp_decimal_int (buffer
, i
);
623 pp_right_brace (buffer
);
624 if (pt
->vars_contains_global
)
625 pp_string (buffer
, " (glob)");
629 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
633 dump_gimple_call (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
635 tree lhs
= gimple_call_lhs (gs
);
636 tree fn
= gimple_call_fn (gs
);
638 if (flags
& TDF_ALIAS
)
640 struct pt_solution
*pt
;
641 pt
= gimple_call_use_set (gs
);
642 if (!pt_solution_empty_p (pt
))
644 pp_string (buffer
, "# USE = ");
645 pp_points_to_solution (buffer
, pt
);
646 newline_and_indent (buffer
, spc
);
648 pt
= gimple_call_clobber_set (gs
);
649 if (!pt_solution_empty_p (pt
))
651 pp_string (buffer
, "# CLB = ");
652 pp_points_to_solution (buffer
, pt
);
653 newline_and_indent (buffer
, spc
);
659 if (gimple_call_internal_p (gs
))
660 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T", gs
,
661 internal_fn_name (gimple_call_internal_fn (gs
)), lhs
);
663 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T", gs
, fn
, lhs
);
664 if (gimple_call_num_args (gs
) > 0)
666 pp_string (buffer
, ", ");
667 dump_gimple_call_args (buffer
, gs
, flags
);
673 if (lhs
&& !(flags
& TDF_RHS_ONLY
))
675 dump_generic_node (buffer
, lhs
, spc
, flags
, false);
676 pp_string (buffer
, " =");
678 if (gimple_has_volatile_ops (gs
))
679 pp_string (buffer
, "{v}");
683 if (gimple_call_internal_p (gs
))
684 pp_string (buffer
, internal_fn_name (gimple_call_internal_fn (gs
)));
686 print_call_name (buffer
, fn
, flags
);
687 pp_string (buffer
, " (");
688 dump_gimple_call_args (buffer
, gs
, flags
);
689 pp_right_paren (buffer
);
690 if (!(flags
& TDF_RHS_ONLY
))
691 pp_semicolon (buffer
);
694 if (gimple_call_chain (gs
))
696 pp_string (buffer
, " [static-chain: ");
697 dump_generic_node (buffer
, gimple_call_chain (gs
), spc
, flags
, false);
698 pp_right_bracket (buffer
);
701 if (gimple_call_return_slot_opt_p (gs
))
702 pp_string (buffer
, " [return slot optimization]");
703 if (gimple_call_tail_p (gs
))
704 pp_string (buffer
, " [tail call]");
709 /* Dump the arguments of _ITM_beginTransaction sanely. */
710 if (TREE_CODE (fn
) == ADDR_EXPR
)
711 fn
= TREE_OPERAND (fn
, 0);
712 if (TREE_CODE (fn
) == FUNCTION_DECL
&& decl_is_tm_clone (fn
))
713 pp_string (buffer
, " [tm-clone]");
714 if (TREE_CODE (fn
) == FUNCTION_DECL
715 && DECL_BUILT_IN_CLASS (fn
) == BUILT_IN_NORMAL
716 && DECL_FUNCTION_CODE (fn
) == BUILT_IN_TM_START
717 && gimple_call_num_args (gs
) > 0)
719 tree t
= gimple_call_arg (gs
, 0);
720 unsigned HOST_WIDE_INT props
;
721 gcc_assert (TREE_CODE (t
) == INTEGER_CST
);
723 pp_string (buffer
, " [ ");
725 /* Get the transaction code properties. */
726 props
= TREE_INT_CST_LOW (t
);
728 if (props
& PR_INSTRUMENTEDCODE
)
729 pp_string (buffer
, "instrumentedCode ");
730 if (props
& PR_UNINSTRUMENTEDCODE
)
731 pp_string (buffer
, "uninstrumentedCode ");
732 if (props
& PR_HASNOXMMUPDATE
)
733 pp_string (buffer
, "hasNoXMMUpdate ");
734 if (props
& PR_HASNOABORT
)
735 pp_string (buffer
, "hasNoAbort ");
736 if (props
& PR_HASNOIRREVOCABLE
)
737 pp_string (buffer
, "hasNoIrrevocable ");
738 if (props
& PR_DOESGOIRREVOCABLE
)
739 pp_string (buffer
, "doesGoIrrevocable ");
740 if (props
& PR_HASNOSIMPLEREADS
)
741 pp_string (buffer
, "hasNoSimpleReads ");
742 if (props
& PR_AWBARRIERSOMITTED
)
743 pp_string (buffer
, "awBarriersOmitted ");
744 if (props
& PR_RARBARRIERSOMITTED
)
745 pp_string (buffer
, "RaRBarriersOmitted ");
746 if (props
& PR_UNDOLOGCODE
)
747 pp_string (buffer
, "undoLogCode ");
748 if (props
& PR_PREFERUNINSTRUMENTED
)
749 pp_string (buffer
, "preferUninstrumented ");
750 if (props
& PR_EXCEPTIONBLOCK
)
751 pp_string (buffer
, "exceptionBlock ");
752 if (props
& PR_HASELSE
)
753 pp_string (buffer
, "hasElse ");
754 if (props
& PR_READONLY
)
755 pp_string (buffer
, "readOnly ");
757 pp_right_bracket (buffer
);
762 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
766 dump_gimple_switch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
770 GIMPLE_CHECK (gs
, GIMPLE_SWITCH
);
772 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", gs
,
773 gimple_switch_index (gs
));
776 pp_string (buffer
, "switch (");
777 dump_generic_node (buffer
, gimple_switch_index (gs
), spc
, flags
, true);
778 pp_string (buffer
, ") <");
781 for (i
= 0; i
< gimple_switch_num_labels (gs
); i
++)
783 tree case_label
= gimple_switch_label (gs
, i
);
784 gcc_checking_assert (case_label
!= NULL_TREE
);
785 dump_generic_node (buffer
, case_label
, spc
, flags
, false);
787 dump_generic_node (buffer
, CASE_LABEL (case_label
), spc
, flags
, false);
788 if (i
< gimple_switch_num_labels (gs
) - 1)
789 pp_string (buffer
, ", ");
795 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
799 dump_gimple_cond (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
802 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T, %T>", gs
,
803 get_tree_code_name (gimple_cond_code (gs
)),
804 gimple_cond_lhs (gs
), gimple_cond_rhs (gs
),
805 gimple_cond_true_label (gs
), gimple_cond_false_label (gs
));
808 if (!(flags
& TDF_RHS_ONLY
))
809 pp_string (buffer
, "if (");
810 dump_generic_node (buffer
, gimple_cond_lhs (gs
), spc
, flags
, false);
812 pp_string (buffer
, op_symbol_code (gimple_cond_code (gs
)));
814 dump_generic_node (buffer
, gimple_cond_rhs (gs
), spc
, flags
, false);
815 if (!(flags
& TDF_RHS_ONLY
))
817 pp_right_paren (buffer
);
819 if (gimple_cond_true_label (gs
))
821 pp_string (buffer
, " goto ");
822 dump_generic_node (buffer
, gimple_cond_true_label (gs
),
824 pp_semicolon (buffer
);
826 if (gimple_cond_false_label (gs
))
828 pp_string (buffer
, " else goto ");
829 dump_generic_node (buffer
, gimple_cond_false_label (gs
),
831 pp_semicolon (buffer
);
838 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
839 spaces of indent. FLAGS specifies details to show in the dump (see
840 TDF_* in dumpfils.h). */
843 dump_gimple_label (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
845 tree label
= gimple_label_label (gs
);
847 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
850 dump_generic_node (buffer
, label
, spc
, flags
, false);
853 if (DECL_NONLOCAL (label
))
854 pp_string (buffer
, " [non-local]");
855 if ((flags
& TDF_EH
) && EH_LANDING_PAD_NR (label
))
856 pp_printf (buffer
, " [LP %d]", EH_LANDING_PAD_NR (label
));
859 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
860 spaces of indent. FLAGS specifies details to show in the dump (see
861 TDF_* in dumpfile.h). */
864 dump_gimple_goto (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
866 tree label
= gimple_goto_dest (gs
);
868 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
870 dump_gimple_fmt (buffer
, spc
, flags
, "goto %T;", label
);
874 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
875 spaces of indent. FLAGS specifies details to show in the dump (see
876 TDF_* in dumpfile.h). */
879 dump_gimple_bind (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
882 dump_gimple_fmt (buffer
, spc
, flags
, "%G <", gs
);
884 pp_left_brace (buffer
);
885 if (!(flags
& TDF_SLIM
))
889 for (var
= gimple_bind_vars (gs
); var
; var
= DECL_CHAIN (var
))
891 newline_and_indent (buffer
, 2);
892 print_declaration (buffer
, var
, spc
, flags
);
894 if (gimple_bind_vars (gs
))
898 dump_gimple_seq (buffer
, gimple_bind_body (gs
), spc
+ 2, flags
);
899 newline_and_indent (buffer
, spc
);
903 pp_right_brace (buffer
);
907 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
908 indent. FLAGS specifies details to show in the dump (see TDF_* in
912 dump_gimple_try (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
917 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
918 type
= "GIMPLE_TRY_CATCH";
919 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
920 type
= "GIMPLE_TRY_FINALLY";
922 type
= "UNKNOWN GIMPLE_TRY";
923 dump_gimple_fmt (buffer
, spc
, flags
,
924 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs
, type
,
925 gimple_try_eval (gs
), gimple_try_cleanup (gs
));
929 pp_string (buffer
, "try");
930 newline_and_indent (buffer
, spc
+ 2);
931 pp_left_brace (buffer
);
934 dump_gimple_seq (buffer
, gimple_try_eval (gs
), spc
+ 4, flags
);
935 newline_and_indent (buffer
, spc
+ 2);
936 pp_right_brace (buffer
);
938 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
940 newline_and_indent (buffer
, spc
);
941 pp_string (buffer
, "catch");
942 newline_and_indent (buffer
, spc
+ 2);
943 pp_left_brace (buffer
);
945 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
947 newline_and_indent (buffer
, spc
);
948 pp_string (buffer
, "finally");
949 newline_and_indent (buffer
, spc
+ 2);
950 pp_left_brace (buffer
);
953 pp_string (buffer
, " <UNKNOWN GIMPLE_TRY> {");
956 dump_gimple_seq (buffer
, gimple_try_cleanup (gs
), spc
+ 4, flags
);
957 newline_and_indent (buffer
, spc
+ 2);
958 pp_right_brace (buffer
);
963 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
964 indent. FLAGS specifies details to show in the dump (see TDF_* in
968 dump_gimple_catch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
971 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+CATCH <%S>%->", gs
,
972 gimple_catch_types (gs
), gimple_catch_handler (gs
));
974 dump_gimple_fmt (buffer
, spc
, flags
, "catch (%T)%+{%S}",
975 gimple_catch_types (gs
), gimple_catch_handler (gs
));
979 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
980 indent. FLAGS specifies details to show in the dump (see TDF_* in
984 dump_gimple_eh_filter (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
987 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+FAILURE <%S>%->", gs
,
988 gimple_eh_filter_types (gs
),
989 gimple_eh_filter_failure (gs
));
991 dump_gimple_fmt (buffer
, spc
, flags
, "<<<eh_filter (%T)>>>%+{%+%S%-}",
992 gimple_eh_filter_types (gs
),
993 gimple_eh_filter_failure (gs
));
997 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1000 dump_gimple_eh_must_not_throw (pretty_printer
*buffer
, gimple gs
,
1003 if (flags
& TDF_RAW
)
1004 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
,
1005 gimple_eh_must_not_throw_fndecl (gs
));
1007 dump_gimple_fmt (buffer
, spc
, flags
, "<<<eh_must_not_throw (%T)>>>",
1008 gimple_eh_must_not_throw_fndecl (gs
));
1012 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1013 indent. FLAGS specifies details to show in the dump (see TDF_* in
1017 dump_gimple_eh_else (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1019 if (flags
& TDF_RAW
)
1020 dump_gimple_fmt (buffer
, spc
, flags
,
1021 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs
,
1022 gimple_eh_else_n_body (gs
), gimple_eh_else_e_body (gs
));
1024 dump_gimple_fmt (buffer
, spc
, flags
,
1025 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1026 gimple_eh_else_n_body (gs
), gimple_eh_else_e_body (gs
));
1030 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1031 indent. FLAGS specifies details to show in the dump (see TDF_* in
1035 dump_gimple_resx (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1037 if (flags
& TDF_RAW
)
1038 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%d>", gs
,
1039 gimple_resx_region (gs
));
1041 dump_gimple_fmt (buffer
, spc
, flags
, "resx %d", gimple_resx_region (gs
));
1044 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1047 dump_gimple_eh_dispatch (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1049 if (flags
& TDF_RAW
)
1050 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%d>", gs
,
1051 gimple_eh_dispatch_region (gs
));
1053 dump_gimple_fmt (buffer
, spc
, flags
, "eh_dispatch %d",
1054 gimple_eh_dispatch_region (gs
));
1057 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1058 of indent. FLAGS specifies details to show in the dump (see TDF_*
1062 dump_gimple_debug (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1064 switch (gs
->gsbase
.subcode
)
1066 case GIMPLE_DEBUG_BIND
:
1067 if (flags
& TDF_RAW
)
1068 dump_gimple_fmt (buffer
, spc
, flags
, "%G BIND <%T, %T>", gs
,
1069 gimple_debug_bind_get_var (gs
),
1070 gimple_debug_bind_get_value (gs
));
1072 dump_gimple_fmt (buffer
, spc
, flags
, "# DEBUG %T => %T",
1073 gimple_debug_bind_get_var (gs
),
1074 gimple_debug_bind_get_value (gs
));
1077 case GIMPLE_DEBUG_SOURCE_BIND
:
1078 if (flags
& TDF_RAW
)
1079 dump_gimple_fmt (buffer
, spc
, flags
, "%G SRCBIND <%T, %T>", gs
,
1080 gimple_debug_source_bind_get_var (gs
),
1081 gimple_debug_source_bind_get_value (gs
));
1083 dump_gimple_fmt (buffer
, spc
, flags
, "# DEBUG %T s=> %T",
1084 gimple_debug_source_bind_get_var (gs
),
1085 gimple_debug_source_bind_get_value (gs
));
1093 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1095 dump_gimple_omp_for (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1099 if (flags
& TDF_RAW
)
1102 switch (gimple_omp_for_kind (gs
))
1104 case GF_OMP_FOR_KIND_FOR
:
1107 case GF_OMP_FOR_KIND_SIMD
:
1110 case GF_OMP_FOR_KIND_DISTRIBUTE
:
1111 kind
= " distribute";
1116 dump_gimple_fmt (buffer
, spc
, flags
, "%G%s <%+BODY <%S>%nCLAUSES <", gs
,
1117 kind
, gimple_omp_body (gs
));
1118 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
1119 dump_gimple_fmt (buffer
, spc
, flags
, " >,");
1120 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
1121 dump_gimple_fmt (buffer
, spc
, flags
,
1122 "%+%T, %T, %T, %s, %T,%n",
1123 gimple_omp_for_index (gs
, i
),
1124 gimple_omp_for_initial (gs
, i
),
1125 gimple_omp_for_final (gs
, i
),
1126 get_tree_code_name (gimple_omp_for_cond (gs
, i
)),
1127 gimple_omp_for_incr (gs
, i
));
1128 dump_gimple_fmt (buffer
, spc
, flags
, "PRE_BODY <%S>%->",
1129 gimple_omp_for_pre_body (gs
));
1133 switch (gimple_omp_for_kind (gs
))
1135 case GF_OMP_FOR_KIND_FOR
:
1136 pp_string (buffer
, "#pragma omp for");
1138 case GF_OMP_FOR_KIND_SIMD
:
1139 pp_string (buffer
, "#pragma omp simd");
1141 case GF_OMP_FOR_KIND_DISTRIBUTE
:
1142 pp_string (buffer
, "#pragma omp distribute");
1147 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
1148 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
1152 newline_and_indent (buffer
, spc
);
1153 pp_string (buffer
, "for (");
1154 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
1156 pp_string (buffer
, " = ");
1157 dump_generic_node (buffer
, gimple_omp_for_initial (gs
, i
), spc
,
1159 pp_string (buffer
, "; ");
1161 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
1164 switch (gimple_omp_for_cond (gs
, i
))
1170 pp_greater (buffer
);
1173 pp_less_equal (buffer
);
1176 pp_greater_equal (buffer
);
1182 dump_generic_node (buffer
, gimple_omp_for_final (gs
, i
), spc
,
1184 pp_string (buffer
, "; ");
1186 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
1188 pp_string (buffer
, " = ");
1189 dump_generic_node (buffer
, gimple_omp_for_incr (gs
, i
), spc
,
1191 pp_right_paren (buffer
);
1194 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1196 newline_and_indent (buffer
, spc
+ 2);
1197 pp_left_brace (buffer
);
1198 pp_newline (buffer
);
1199 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1200 newline_and_indent (buffer
, spc
+ 2);
1201 pp_right_brace (buffer
);
1206 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1209 dump_gimple_omp_continue (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1211 if (flags
& TDF_RAW
)
1213 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
1214 gimple_omp_continue_control_def (gs
),
1215 gimple_omp_continue_control_use (gs
));
1219 pp_string (buffer
, "#pragma omp continue (");
1220 dump_generic_node (buffer
, gimple_omp_continue_control_def (gs
),
1224 dump_generic_node (buffer
, gimple_omp_continue_control_use (gs
),
1226 pp_right_paren (buffer
);
1230 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1233 dump_gimple_omp_single (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1235 if (flags
& TDF_RAW
)
1237 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1238 gimple_omp_body (gs
));
1239 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
1240 dump_gimple_fmt (buffer
, spc
, flags
, " >");
1244 pp_string (buffer
, "#pragma omp single");
1245 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
1246 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1248 newline_and_indent (buffer
, spc
+ 2);
1249 pp_left_brace (buffer
);
1250 pp_newline (buffer
);
1251 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1252 newline_and_indent (buffer
, spc
+ 2);
1253 pp_right_brace (buffer
);
1258 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1261 dump_gimple_omp_target (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1264 switch (gimple_omp_target_kind (gs
))
1266 case GF_OMP_TARGET_KIND_REGION
:
1269 case GF_OMP_TARGET_KIND_DATA
:
1272 case GF_OMP_TARGET_KIND_UPDATE
:
1278 if (flags
& TDF_RAW
)
1280 dump_gimple_fmt (buffer
, spc
, flags
, "%G%s <%+BODY <%S>%nCLAUSES <", gs
,
1281 kind
, gimple_omp_body (gs
));
1282 dump_omp_clauses (buffer
, gimple_omp_target_clauses (gs
), spc
, flags
);
1283 dump_gimple_fmt (buffer
, spc
, flags
, " >");
1287 pp_string (buffer
, "#pragma omp target");
1288 pp_string (buffer
, kind
);
1289 dump_omp_clauses (buffer
, gimple_omp_target_clauses (gs
), spc
, flags
);
1290 if (gimple_omp_target_child_fn (gs
))
1292 pp_string (buffer
, " [child fn: ");
1293 dump_generic_node (buffer
, gimple_omp_target_child_fn (gs
),
1295 pp_right_bracket (buffer
);
1297 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1299 newline_and_indent (buffer
, spc
+ 2);
1300 pp_character (buffer
, '{');
1301 pp_newline (buffer
);
1302 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1303 newline_and_indent (buffer
, spc
+ 2);
1304 pp_character (buffer
, '}');
1309 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1312 dump_gimple_omp_teams (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1314 if (flags
& TDF_RAW
)
1316 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1317 gimple_omp_body (gs
));
1318 dump_omp_clauses (buffer
, gimple_omp_teams_clauses (gs
), spc
, flags
);
1319 dump_gimple_fmt (buffer
, spc
, flags
, " >");
1323 pp_string (buffer
, "#pragma omp teams");
1324 dump_omp_clauses (buffer
, gimple_omp_teams_clauses (gs
), spc
, flags
);
1325 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1327 newline_and_indent (buffer
, spc
+ 2);
1328 pp_character (buffer
, '{');
1329 pp_newline (buffer
);
1330 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1331 newline_and_indent (buffer
, spc
+ 2);
1332 pp_character (buffer
, '}');
1337 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1340 dump_gimple_omp_sections (pretty_printer
*buffer
, gimple gs
, int spc
,
1343 if (flags
& TDF_RAW
)
1345 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1346 gimple_omp_body (gs
));
1347 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
1348 dump_gimple_fmt (buffer
, spc
, flags
, " >");
1352 pp_string (buffer
, "#pragma omp sections");
1353 if (gimple_omp_sections_control (gs
))
1355 pp_string (buffer
, " <");
1356 dump_generic_node (buffer
, gimple_omp_sections_control (gs
), spc
,
1358 pp_greater (buffer
);
1360 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
1361 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1363 newline_and_indent (buffer
, spc
+ 2);
1364 pp_left_brace (buffer
);
1365 pp_newline (buffer
);
1366 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1367 newline_and_indent (buffer
, spc
+ 2);
1368 pp_right_brace (buffer
);
1373 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1374 pretty_printer BUFFER. */
1377 dump_gimple_omp_block (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1379 if (flags
& TDF_RAW
)
1380 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
1381 gimple_omp_body (gs
));
1384 switch (gimple_code (gs
))
1386 case GIMPLE_OMP_MASTER
:
1387 pp_string (buffer
, "#pragma omp master");
1389 case GIMPLE_OMP_TASKGROUP
:
1390 pp_string (buffer
, "#pragma omp taskgroup");
1392 case GIMPLE_OMP_ORDERED
:
1393 pp_string (buffer
, "#pragma omp ordered");
1395 case GIMPLE_OMP_SECTION
:
1396 pp_string (buffer
, "#pragma omp section");
1401 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1403 newline_and_indent (buffer
, spc
+ 2);
1404 pp_left_brace (buffer
);
1405 pp_newline (buffer
);
1406 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1407 newline_and_indent (buffer
, spc
+ 2);
1408 pp_right_brace (buffer
);
1413 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1416 dump_gimple_omp_critical (pretty_printer
*buffer
, gimple gs
, int spc
,
1419 if (flags
& TDF_RAW
)
1420 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
1421 gimple_omp_body (gs
));
1424 pp_string (buffer
, "#pragma omp critical");
1425 if (gimple_omp_critical_name (gs
))
1427 pp_string (buffer
, " (");
1428 dump_generic_node (buffer
, gimple_omp_critical_name (gs
), spc
,
1430 pp_right_paren (buffer
);
1432 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1434 newline_and_indent (buffer
, spc
+ 2);
1435 pp_left_brace (buffer
);
1436 pp_newline (buffer
);
1437 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1438 newline_and_indent (buffer
, spc
+ 2);
1439 pp_right_brace (buffer
);
1444 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1447 dump_gimple_omp_return (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1449 if (flags
& TDF_RAW
)
1451 dump_gimple_fmt (buffer
, spc
, flags
, "%G <nowait=%d", gs
,
1452 (int) gimple_omp_return_nowait_p (gs
));
1453 if (gimple_omp_return_lhs (gs
))
1454 dump_gimple_fmt (buffer
, spc
, flags
, ", lhs=%T>",
1455 gimple_omp_return_lhs (gs
));
1457 dump_gimple_fmt (buffer
, spc
, flags
, ">");
1461 pp_string (buffer
, "#pragma omp return");
1462 if (gimple_omp_return_nowait_p (gs
))
1463 pp_string (buffer
, "(nowait)");
1464 if (gimple_omp_return_lhs (gs
))
1466 pp_string (buffer
, " (set ");
1467 dump_generic_node (buffer
, gimple_omp_return_lhs (gs
),
1469 pp_character (buffer
, ')');
1474 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1477 dump_gimple_transaction (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1479 unsigned subcode
= gimple_transaction_subcode (gs
);
1481 if (flags
& TDF_RAW
)
1483 dump_gimple_fmt (buffer
, spc
, flags
,
1484 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1485 gs
, subcode
, gimple_transaction_label (gs
),
1486 gimple_transaction_body (gs
));
1490 if (subcode
& GTMA_IS_OUTER
)
1491 pp_string (buffer
, "__transaction_atomic [[outer]]");
1492 else if (subcode
& GTMA_IS_RELAXED
)
1493 pp_string (buffer
, "__transaction_relaxed");
1495 pp_string (buffer
, "__transaction_atomic");
1496 subcode
&= ~GTMA_DECLARATION_MASK
;
1498 if (subcode
|| gimple_transaction_label (gs
))
1500 pp_string (buffer
, " //");
1501 if (gimple_transaction_label (gs
))
1503 pp_string (buffer
, " LABEL=");
1504 dump_generic_node (buffer
, gimple_transaction_label (gs
),
1509 pp_string (buffer
, " SUBCODE=[ ");
1510 if (subcode
& GTMA_HAVE_ABORT
)
1512 pp_string (buffer
, "GTMA_HAVE_ABORT ");
1513 subcode
&= ~GTMA_HAVE_ABORT
;
1515 if (subcode
& GTMA_HAVE_LOAD
)
1517 pp_string (buffer
, "GTMA_HAVE_LOAD ");
1518 subcode
&= ~GTMA_HAVE_LOAD
;
1520 if (subcode
& GTMA_HAVE_STORE
)
1522 pp_string (buffer
, "GTMA_HAVE_STORE ");
1523 subcode
&= ~GTMA_HAVE_STORE
;
1525 if (subcode
& GTMA_MAY_ENTER_IRREVOCABLE
)
1527 pp_string (buffer
, "GTMA_MAY_ENTER_IRREVOCABLE ");
1528 subcode
&= ~GTMA_MAY_ENTER_IRREVOCABLE
;
1530 if (subcode
& GTMA_DOES_GO_IRREVOCABLE
)
1532 pp_string (buffer
, "GTMA_DOES_GO_IRREVOCABLE ");
1533 subcode
&= ~GTMA_DOES_GO_IRREVOCABLE
;
1535 if (subcode
& GTMA_HAS_NO_INSTRUMENTATION
)
1537 pp_string (buffer
, "GTMA_HAS_NO_INSTRUMENTATION ");
1538 subcode
&= ~GTMA_HAS_NO_INSTRUMENTATION
;
1541 pp_printf (buffer
, "0x%x ", subcode
);
1542 pp_right_bracket (buffer
);
1546 if (!gimple_seq_empty_p (gimple_transaction_body (gs
)))
1548 newline_and_indent (buffer
, spc
+ 2);
1549 pp_left_brace (buffer
);
1550 pp_newline (buffer
);
1551 dump_gimple_seq (buffer
, gimple_transaction_body (gs
),
1553 newline_and_indent (buffer
, spc
+ 2);
1554 pp_right_brace (buffer
);
1559 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1560 indent. FLAGS specifies details to show in the dump (see TDF_* in
1564 dump_gimple_asm (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1566 unsigned int i
, n
, f
, fields
;
1568 if (flags
& TDF_RAW
)
1570 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+STRING <%n%s%n>", gs
,
1571 gimple_asm_string (gs
));
1573 n
= gimple_asm_noutputs (gs
);
1576 newline_and_indent (buffer
, spc
+ 2);
1577 pp_string (buffer
, "OUTPUT: ");
1578 for (i
= 0; i
< n
; i
++)
1580 dump_generic_node (buffer
, gimple_asm_output_op (gs
, i
),
1583 pp_string (buffer
, ", ");
1587 n
= gimple_asm_ninputs (gs
);
1590 newline_and_indent (buffer
, spc
+ 2);
1591 pp_string (buffer
, "INPUT: ");
1592 for (i
= 0; i
< n
; i
++)
1594 dump_generic_node (buffer
, gimple_asm_input_op (gs
, i
),
1597 pp_string (buffer
, ", ");
1601 n
= gimple_asm_nclobbers (gs
);
1604 newline_and_indent (buffer
, spc
+ 2);
1605 pp_string (buffer
, "CLOBBER: ");
1606 for (i
= 0; i
< n
; i
++)
1608 dump_generic_node (buffer
, gimple_asm_clobber_op (gs
, i
),
1611 pp_string (buffer
, ", ");
1615 n
= gimple_asm_nlabels (gs
);
1618 newline_and_indent (buffer
, spc
+ 2);
1619 pp_string (buffer
, "LABEL: ");
1620 for (i
= 0; i
< n
; i
++)
1622 dump_generic_node (buffer
, gimple_asm_label_op (gs
, i
),
1625 pp_string (buffer
, ", ");
1629 newline_and_indent (buffer
, spc
);
1630 pp_greater (buffer
);
1634 pp_string (buffer
, "__asm__");
1635 if (gimple_asm_volatile_p (gs
))
1636 pp_string (buffer
, " __volatile__");
1637 if (gimple_asm_nlabels (gs
))
1638 pp_string (buffer
, " goto");
1639 pp_string (buffer
, "(\"");
1640 pp_string (buffer
, gimple_asm_string (gs
));
1641 pp_string (buffer
, "\"");
1643 if (gimple_asm_nlabels (gs
))
1645 else if (gimple_asm_nclobbers (gs
))
1647 else if (gimple_asm_ninputs (gs
))
1649 else if (gimple_asm_noutputs (gs
))
1654 for (f
= 0; f
< fields
; ++f
)
1656 pp_string (buffer
, " : ");
1661 n
= gimple_asm_noutputs (gs
);
1662 for (i
= 0; i
< n
; i
++)
1664 dump_generic_node (buffer
, gimple_asm_output_op (gs
, i
),
1667 pp_string (buffer
, ", ");
1672 n
= gimple_asm_ninputs (gs
);
1673 for (i
= 0; i
< n
; i
++)
1675 dump_generic_node (buffer
, gimple_asm_input_op (gs
, i
),
1678 pp_string (buffer
, ", ");
1683 n
= gimple_asm_nclobbers (gs
);
1684 for (i
= 0; i
< n
; i
++)
1686 dump_generic_node (buffer
, gimple_asm_clobber_op (gs
, i
),
1689 pp_string (buffer
, ", ");
1694 n
= gimple_asm_nlabels (gs
);
1695 for (i
= 0; i
< n
; i
++)
1697 dump_generic_node (buffer
, gimple_asm_label_op (gs
, i
),
1700 pp_string (buffer
, ", ");
1709 pp_string (buffer
, ");");
1713 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1714 SPC spaces of indent. */
1717 dump_ssaname_info (pretty_printer
*buffer
, tree node
, int spc
)
1719 if (TREE_CODE (node
) != SSA_NAME
)
1722 if (POINTER_TYPE_P (TREE_TYPE (node
))
1723 && SSA_NAME_PTR_INFO (node
))
1725 unsigned int align
, misalign
;
1726 struct ptr_info_def
*pi
= SSA_NAME_PTR_INFO (node
);
1727 pp_string (buffer
, "# PT = ");
1728 pp_points_to_solution (buffer
, &pi
->pt
);
1729 newline_and_indent (buffer
, spc
);
1730 if (get_ptr_info_alignment (pi
, &align
, &misalign
))
1732 pp_printf (buffer
, "# ALIGN = %u, MISALIGN = %u", align
, misalign
);
1733 newline_and_indent (buffer
, spc
);
1737 if (!POINTER_TYPE_P (TREE_TYPE (node
))
1738 && SSA_NAME_RANGE_INFO (node
))
1740 double_int min
, max
;
1741 value_range_type range_type
= get_range_info (node
, &min
, &max
);
1743 if (range_type
== VR_VARYING
)
1744 pp_printf (buffer
, "# RANGE VR_VARYING");
1745 else if (range_type
== VR_RANGE
|| range_type
== VR_ANTI_RANGE
)
1747 pp_printf (buffer
, "# RANGE ");
1748 pp_printf (buffer
, "%s[", range_type
== VR_RANGE
? "" : "~");
1749 pp_double_int (buffer
, min
, TYPE_UNSIGNED (TREE_TYPE (node
)));
1750 pp_printf (buffer
, ", ");
1751 pp_double_int (buffer
, max
, TYPE_UNSIGNED (TREE_TYPE (node
)));
1752 pp_printf (buffer
, "]");
1753 newline_and_indent (buffer
, spc
);
1759 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1760 The caller is responsible for calling pp_flush on BUFFER to finalize
1761 pretty printer. If COMMENT is true, print this after #. */
1764 dump_gimple_phi (pretty_printer
*buffer
, gimple phi
, int spc
, bool comment
,
1768 tree lhs
= gimple_phi_result (phi
);
1770 if (flags
& TDF_ALIAS
)
1771 dump_ssaname_info (buffer
, lhs
, spc
);
1774 pp_string (buffer
, "# ");
1776 if (flags
& TDF_RAW
)
1777 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", phi
,
1778 gimple_phi_result (phi
));
1781 dump_generic_node (buffer
, lhs
, spc
, flags
, false);
1782 pp_string (buffer
, " = PHI <");
1784 for (i
= 0; i
< gimple_phi_num_args (phi
); i
++)
1786 if ((flags
& TDF_LINENO
) && gimple_phi_arg_has_location (phi
, i
))
1788 expanded_location xloc
;
1790 xloc
= expand_location (gimple_phi_arg_location (phi
, i
));
1791 pp_left_bracket (buffer
);
1794 pp_string (buffer
, xloc
.file
);
1795 pp_string (buffer
, " : ");
1797 pp_decimal_int (buffer
, xloc
.line
);
1799 pp_decimal_int (buffer
, xloc
.column
);
1800 pp_string (buffer
, "] ");
1802 dump_generic_node (buffer
, gimple_phi_arg_def (phi
, i
), spc
, flags
,
1804 pp_left_paren (buffer
);
1805 pp_decimal_int (buffer
, gimple_phi_arg_edge (phi
, i
)->src
->index
);
1806 pp_right_paren (buffer
);
1807 if (i
< gimple_phi_num_args (phi
) - 1)
1808 pp_string (buffer
, ", ");
1810 pp_greater (buffer
);
1814 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1815 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1819 dump_gimple_omp_parallel (pretty_printer
*buffer
, gimple gs
, int spc
,
1822 if (flags
& TDF_RAW
)
1824 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1825 gimple_omp_body (gs
));
1826 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
1827 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T%n>",
1828 gimple_omp_parallel_child_fn (gs
),
1829 gimple_omp_parallel_data_arg (gs
));
1834 pp_string (buffer
, "#pragma omp parallel");
1835 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
1836 if (gimple_omp_parallel_child_fn (gs
))
1838 pp_string (buffer
, " [child fn: ");
1839 dump_generic_node (buffer
, gimple_omp_parallel_child_fn (gs
),
1841 pp_string (buffer
, " (");
1842 if (gimple_omp_parallel_data_arg (gs
))
1843 dump_generic_node (buffer
, gimple_omp_parallel_data_arg (gs
),
1846 pp_string (buffer
, "???");
1847 pp_string (buffer
, ")]");
1849 body
= gimple_omp_body (gs
);
1850 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
1852 newline_and_indent (buffer
, spc
+ 2);
1853 pp_left_brace (buffer
);
1854 pp_newline (buffer
);
1855 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
1856 newline_and_indent (buffer
, spc
+ 2);
1857 pp_right_brace (buffer
);
1861 pp_newline (buffer
);
1862 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
1868 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1869 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1873 dump_gimple_omp_task (pretty_printer
*buffer
, gimple gs
, int spc
,
1876 if (flags
& TDF_RAW
)
1878 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1879 gimple_omp_body (gs
));
1880 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
1881 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T, %T, %T, %T%n>",
1882 gimple_omp_task_child_fn (gs
),
1883 gimple_omp_task_data_arg (gs
),
1884 gimple_omp_task_copy_fn (gs
),
1885 gimple_omp_task_arg_size (gs
),
1886 gimple_omp_task_arg_size (gs
));
1891 pp_string (buffer
, "#pragma omp task");
1892 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
1893 if (gimple_omp_task_child_fn (gs
))
1895 pp_string (buffer
, " [child fn: ");
1896 dump_generic_node (buffer
, gimple_omp_task_child_fn (gs
),
1898 pp_string (buffer
, " (");
1899 if (gimple_omp_task_data_arg (gs
))
1900 dump_generic_node (buffer
, gimple_omp_task_data_arg (gs
),
1903 pp_string (buffer
, "???");
1904 pp_string (buffer
, ")]");
1906 body
= gimple_omp_body (gs
);
1907 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
1909 newline_and_indent (buffer
, spc
+ 2);
1910 pp_left_brace (buffer
);
1911 pp_newline (buffer
);
1912 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
1913 newline_and_indent (buffer
, spc
+ 2);
1914 pp_right_brace (buffer
);
1918 pp_newline (buffer
);
1919 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
1925 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1926 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1930 dump_gimple_omp_atomic_load (pretty_printer
*buffer
, gimple gs
, int spc
,
1933 if (flags
& TDF_RAW
)
1935 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
1936 gimple_omp_atomic_load_lhs (gs
),
1937 gimple_omp_atomic_load_rhs (gs
));
1941 pp_string (buffer
, "#pragma omp atomic_load");
1942 if (gimple_omp_atomic_seq_cst_p (gs
))
1943 pp_string (buffer
, " seq_cst");
1944 if (gimple_omp_atomic_need_value_p (gs
))
1945 pp_string (buffer
, " [needed]");
1946 newline_and_indent (buffer
, spc
+ 2);
1947 dump_generic_node (buffer
, gimple_omp_atomic_load_lhs (gs
),
1953 dump_generic_node (buffer
, gimple_omp_atomic_load_rhs (gs
),
1958 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1959 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1963 dump_gimple_omp_atomic_store (pretty_printer
*buffer
, gimple gs
, int spc
,
1966 if (flags
& TDF_RAW
)
1968 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
,
1969 gimple_omp_atomic_store_val (gs
));
1973 pp_string (buffer
, "#pragma omp atomic_store ");
1974 if (gimple_omp_atomic_seq_cst_p (gs
))
1975 pp_string (buffer
, "seq_cst ");
1976 if (gimple_omp_atomic_need_value_p (gs
))
1977 pp_string (buffer
, "[needed] ");
1978 pp_left_paren (buffer
);
1979 dump_generic_node (buffer
, gimple_omp_atomic_store_val (gs
),
1981 pp_right_paren (buffer
);
1986 /* Dump all the memory operands for statement GS. BUFFER, SPC and
1987 FLAGS are as in pp_gimple_stmt_1. */
1990 dump_gimple_mem_ops (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
1992 tree vdef
= gimple_vdef (gs
);
1993 tree vuse
= gimple_vuse (gs
);
1995 if (!ssa_operands_active (DECL_STRUCT_FUNCTION (current_function_decl
))
1996 || !gimple_references_memory_p (gs
))
1999 if (vdef
!= NULL_TREE
)
2001 pp_string (buffer
, "# ");
2002 dump_generic_node (buffer
, vdef
, spc
+ 2, flags
, false);
2003 pp_string (buffer
, " = VDEF <");
2004 dump_generic_node (buffer
, vuse
, spc
+ 2, flags
, false);
2005 pp_greater (buffer
);
2006 newline_and_indent (buffer
, spc
);
2008 else if (vuse
!= NULL_TREE
)
2010 pp_string (buffer
, "# VUSE <");
2011 dump_generic_node (buffer
, vuse
, spc
+ 2, flags
, false);
2012 pp_greater (buffer
);
2013 newline_and_indent (buffer
, spc
);
2018 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2019 spaces of indent. FLAGS specifies details to show in the dump (see
2020 TDF_* in dumpfile.h). The caller is responsible for calling
2021 pp_flush on BUFFER to finalize the pretty printer. */
2024 pp_gimple_stmt_1 (pretty_printer
*buffer
, gimple gs
, int spc
, int flags
)
2029 if (flags
& TDF_STMTADDR
)
2030 pp_printf (buffer
, "<&%p> ", (void *) gs
);
2032 if ((flags
& TDF_LINENO
) && gimple_has_location (gs
))
2034 expanded_location xloc
= expand_location (gimple_location (gs
));
2035 pp_left_bracket (buffer
);
2038 pp_string (buffer
, xloc
.file
);
2039 pp_string (buffer
, " : ");
2041 pp_decimal_int (buffer
, xloc
.line
);
2043 pp_decimal_int (buffer
, xloc
.column
);
2044 pp_string (buffer
, "] ");
2049 int lp_nr
= lookup_stmt_eh_lp (gs
);
2051 pp_printf (buffer
, "[LP %d] ", lp_nr
);
2053 pp_printf (buffer
, "[MNT %d] ", -lp_nr
);
2056 if ((flags
& (TDF_VOPS
|TDF_MEMSYMS
))
2057 && gimple_has_mem_ops (gs
))
2058 dump_gimple_mem_ops (buffer
, gs
, spc
, flags
);
2060 if (gimple_has_lhs (gs
)
2061 && (flags
& TDF_ALIAS
))
2062 dump_ssaname_info (buffer
, gimple_get_lhs (gs
), spc
);
2064 switch (gimple_code (gs
))
2067 dump_gimple_asm (buffer
, gs
, spc
, flags
);
2071 dump_gimple_assign (buffer
, gs
, spc
, flags
);
2075 dump_gimple_bind (buffer
, gs
, spc
, flags
);
2079 dump_gimple_call (buffer
, gs
, spc
, flags
);
2083 dump_gimple_cond (buffer
, gs
, spc
, flags
);
2087 dump_gimple_label (buffer
, gs
, spc
, flags
);
2091 dump_gimple_goto (buffer
, gs
, spc
, flags
);
2095 pp_string (buffer
, "GIMPLE_NOP");
2099 dump_gimple_return (buffer
, gs
, spc
, flags
);
2103 dump_gimple_switch (buffer
, gs
, spc
, flags
);
2107 dump_gimple_try (buffer
, gs
, spc
, flags
);
2111 dump_gimple_phi (buffer
, gs
, spc
, false, flags
);
2114 case GIMPLE_OMP_PARALLEL
:
2115 dump_gimple_omp_parallel (buffer
, gs
, spc
, flags
);
2118 case GIMPLE_OMP_TASK
:
2119 dump_gimple_omp_task (buffer
, gs
, spc
, flags
);
2122 case GIMPLE_OMP_ATOMIC_LOAD
:
2123 dump_gimple_omp_atomic_load (buffer
, gs
, spc
, flags
);
2127 case GIMPLE_OMP_ATOMIC_STORE
:
2128 dump_gimple_omp_atomic_store (buffer
, gs
, spc
, flags
);
2131 case GIMPLE_OMP_FOR
:
2132 dump_gimple_omp_for (buffer
, gs
, spc
, flags
);
2135 case GIMPLE_OMP_CONTINUE
:
2136 dump_gimple_omp_continue (buffer
, gs
, spc
, flags
);
2139 case GIMPLE_OMP_SINGLE
:
2140 dump_gimple_omp_single (buffer
, gs
, spc
, flags
);
2143 case GIMPLE_OMP_TARGET
:
2144 dump_gimple_omp_target (buffer
, gs
, spc
, flags
);
2147 case GIMPLE_OMP_TEAMS
:
2148 dump_gimple_omp_teams (buffer
, gs
, spc
, flags
);
2151 case GIMPLE_OMP_RETURN
:
2152 dump_gimple_omp_return (buffer
, gs
, spc
, flags
);
2155 case GIMPLE_OMP_SECTIONS
:
2156 dump_gimple_omp_sections (buffer
, gs
, spc
, flags
);
2159 case GIMPLE_OMP_SECTIONS_SWITCH
:
2160 pp_string (buffer
, "GIMPLE_SECTIONS_SWITCH");
2163 case GIMPLE_OMP_MASTER
:
2164 case GIMPLE_OMP_TASKGROUP
:
2165 case GIMPLE_OMP_ORDERED
:
2166 case GIMPLE_OMP_SECTION
:
2167 dump_gimple_omp_block (buffer
, gs
, spc
, flags
);
2170 case GIMPLE_OMP_CRITICAL
:
2171 dump_gimple_omp_critical (buffer
, gs
, spc
, flags
);
2175 dump_gimple_catch (buffer
, gs
, spc
, flags
);
2178 case GIMPLE_EH_FILTER
:
2179 dump_gimple_eh_filter (buffer
, gs
, spc
, flags
);
2182 case GIMPLE_EH_MUST_NOT_THROW
:
2183 dump_gimple_eh_must_not_throw (buffer
, gs
, spc
, flags
);
2186 case GIMPLE_EH_ELSE
:
2187 dump_gimple_eh_else (buffer
, gs
, spc
, flags
);
2191 dump_gimple_resx (buffer
, gs
, spc
, flags
);
2194 case GIMPLE_EH_DISPATCH
:
2195 dump_gimple_eh_dispatch (buffer
, gs
, spc
, flags
);
2199 dump_gimple_debug (buffer
, gs
, spc
, flags
);
2202 case GIMPLE_PREDICT
:
2203 pp_string (buffer
, "// predicted ");
2204 if (gimple_predict_outcome (gs
))
2205 pp_string (buffer
, "likely by ");
2207 pp_string (buffer
, "unlikely by ");
2208 pp_string (buffer
, predictor_name (gimple_predict_predictor (gs
)));
2209 pp_string (buffer
, " predictor.");
2212 case GIMPLE_TRANSACTION
:
2213 dump_gimple_transaction (buffer
, gs
, spc
, flags
);
2222 /* Dumps header of basic block BB to OUTF indented by INDENT
2223 spaces and details described by flags. */
2226 dump_gimple_bb_header (FILE *outf
, basic_block bb
, int indent
, int flags
)
2228 if (flags
& TDF_BLOCKS
)
2230 if (flags
& TDF_LINENO
)
2232 gimple_stmt_iterator gsi
;
2234 if (flags
& TDF_COMMENT
)
2235 fputs (";; ", outf
);
2237 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
2238 if (!is_gimple_debug (gsi_stmt (gsi
))
2239 && get_lineno (gsi_stmt (gsi
)) != UNKNOWN_LOCATION
)
2241 fprintf (outf
, "%*sstarting at line %d",
2242 indent
, "", get_lineno (gsi_stmt (gsi
)));
2245 if (bb
->discriminator
)
2246 fprintf (outf
, ", discriminator %i", bb
->discriminator
);
2252 gimple stmt
= first_stmt (bb
);
2253 if (!stmt
|| gimple_code (stmt
) != GIMPLE_LABEL
)
2254 fprintf (outf
, "%*s<bb %d>:\n", indent
, "", bb
->index
);
2259 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2263 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED
,
2264 basic_block bb ATTRIBUTE_UNUSED
,
2265 int indent ATTRIBUTE_UNUSED
,
2266 int flags ATTRIBUTE_UNUSED
)
2268 /* There is currently no GIMPLE-specific basic block info to dump. */
2273 /* Dump PHI nodes of basic block BB to BUFFER with details described
2274 by FLAGS and indented by INDENT spaces. */
2277 dump_phi_nodes (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
2279 gimple_stmt_iterator i
;
2281 for (i
= gsi_start_phis (bb
); !gsi_end_p (i
); gsi_next (&i
))
2283 gimple phi
= gsi_stmt (i
);
2284 if (!virtual_operand_p (gimple_phi_result (phi
)) || (flags
& TDF_VOPS
))
2287 dump_gimple_phi (buffer
, phi
, indent
, true, flags
);
2288 pp_newline (buffer
);
2294 /* Dump jump to basic block BB that is represented implicitly in the cfg
2298 pp_cfg_jump (pretty_printer
*buffer
, basic_block bb
)
2302 stmt
= first_stmt (bb
);
2304 pp_string (buffer
, "goto <bb ");
2305 pp_decimal_int (buffer
, bb
->index
);
2306 pp_greater (buffer
);
2307 if (stmt
&& gimple_code (stmt
) == GIMPLE_LABEL
)
2309 pp_string (buffer
, " (");
2310 dump_generic_node (buffer
, gimple_label_label (stmt
), 0, 0, false);
2311 pp_right_paren (buffer
);
2312 pp_semicolon (buffer
);
2315 pp_semicolon (buffer
);
2319 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2320 by INDENT spaces, with details given by FLAGS. */
2323 dump_implicit_edges (pretty_printer
*buffer
, basic_block bb
, int indent
,
2329 stmt
= last_stmt (bb
);
2331 if (stmt
&& gimple_code (stmt
) == GIMPLE_COND
)
2333 edge true_edge
, false_edge
;
2335 /* When we are emitting the code or changing CFG, it is possible that
2336 the edges are not yet created. When we are using debug_bb in such
2337 a situation, we do not want it to crash. */
2338 if (EDGE_COUNT (bb
->succs
) != 2)
2340 extract_true_false_edges_from_block (bb
, &true_edge
, &false_edge
);
2342 INDENT (indent
+ 2);
2343 pp_cfg_jump (buffer
, true_edge
->dest
);
2344 newline_and_indent (buffer
, indent
);
2345 pp_string (buffer
, "else");
2346 newline_and_indent (buffer
, indent
+ 2);
2347 pp_cfg_jump (buffer
, false_edge
->dest
);
2348 pp_newline (buffer
);
2352 /* If there is a fallthru edge, we may need to add an artificial
2353 goto to the dump. */
2354 e
= find_fallthru_edge (bb
->succs
);
2356 if (e
&& e
->dest
!= bb
->next_bb
)
2360 if ((flags
& TDF_LINENO
)
2361 && e
->goto_locus
!= UNKNOWN_LOCATION
2364 expanded_location goto_xloc
;
2365 goto_xloc
= expand_location (e
->goto_locus
);
2366 pp_left_bracket (buffer
);
2369 pp_string (buffer
, goto_xloc
.file
);
2370 pp_string (buffer
, " : ");
2372 pp_decimal_int (buffer
, goto_xloc
.line
);
2373 pp_string (buffer
, " : ");
2374 pp_decimal_int (buffer
, goto_xloc
.column
);
2375 pp_string (buffer
, "] ");
2378 pp_cfg_jump (buffer
, e
->dest
);
2379 pp_newline (buffer
);
2384 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2385 indented by INDENT spaces. */
2388 gimple_dump_bb_buff (pretty_printer
*buffer
, basic_block bb
, int indent
,
2391 gimple_stmt_iterator gsi
;
2393 int label_indent
= indent
- 2;
2395 if (label_indent
< 0)
2398 dump_phi_nodes (buffer
, bb
, indent
, flags
);
2400 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
2404 stmt
= gsi_stmt (gsi
);
2406 curr_indent
= gimple_code (stmt
) == GIMPLE_LABEL
? label_indent
: indent
;
2408 INDENT (curr_indent
);
2409 pp_gimple_stmt_1 (buffer
, stmt
, curr_indent
, flags
);
2410 pp_newline_and_flush (buffer
);
2411 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl
));
2412 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl
),
2413 pp_buffer (buffer
)->stream
, stmt
);
2416 dump_implicit_edges (buffer
, bb
, indent
, flags
);
2421 /* Dumps basic block BB to FILE with details described by FLAGS and
2422 indented by INDENT spaces. */
2425 gimple_dump_bb (FILE *file
, basic_block bb
, int indent
, int flags
)
2427 dump_gimple_bb_header (file
, bb
, indent
, flags
);
2428 if (bb
->index
>= NUM_FIXED_BLOCKS
)
2430 pretty_printer buffer
;
2431 pp_needs_newline (&buffer
) = true;
2432 buffer
.buffer
->stream
= file
;
2433 gimple_dump_bb_buff (&buffer
, bb
, indent
, flags
);
2435 dump_gimple_bb_footer (file
, bb
, indent
, flags
);
2438 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2439 no indentation, for use as a label of a DOT graph record-node.
2440 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2441 histogram dumping doesn't know about pretty-printers. */
2444 gimple_dump_bb_for_graph (pretty_printer
*pp
, basic_block bb
)
2446 gimple_stmt_iterator gsi
;
2448 pp_printf (pp
, "<bb %d>:\n", bb
->index
);
2449 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);
2451 for (gsi
= gsi_start_phis (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
2453 gimple phi
= gsi_stmt (gsi
);
2454 if (!virtual_operand_p (gimple_phi_result (phi
))
2455 || (dump_flags
& TDF_VOPS
))
2458 pp_write_text_to_stream (pp
);
2459 pp_string (pp
, "# ");
2460 pp_gimple_stmt_1 (pp
, phi
, 0, dump_flags
);
2462 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);
2466 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
2468 gimple stmt
= gsi_stmt (gsi
);
2470 pp_write_text_to_stream (pp
);
2471 pp_gimple_stmt_1 (pp
, stmt
, 0, dump_flags
);
2473 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);
2475 dump_implicit_edges (pp
, bb
, 0, dump_flags
);
2476 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);