1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2017 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"
29 #include "gimple-predict.h"
32 #include "gimple-pretty-print.h"
33 #include "internal-fn.h"
35 #include "gimple-iterator.h"
37 #include "dumpfile.h" /* for dump_flags */
38 #include "value-prof.h"
39 #include "trans-mem.h"
41 #include "stringpool.h"
45 #define INDENT(SPACE) \
46 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
48 #define GIMPLE_NIY do_niy (buffer,gs)
50 /* Try to print on BUFFER a default message for the unrecognized
51 gimple statement GS. */
54 do_niy (pretty_printer
*buffer
, gimple
*gs
)
56 pp_printf (buffer
, "<<< Unknown GIMPLE statement: %s >>>\n",
57 gimple_code_name
[(int) gimple_code (gs
)]);
61 /* Emit a newline and SPC indentation spaces to BUFFER. */
64 newline_and_indent (pretty_printer
*buffer
, int spc
)
71 /* Print the GIMPLE statement GS on stderr. */
74 debug_gimple_stmt (gimple
*gs
)
76 print_gimple_stmt (stderr
, gs
, 0, TDF_VOPS
|TDF_MEMSYMS
);
80 /* Return formatted string of a VALUE probability
81 (biased by REG_BR_PROB_BASE). Returned string is allocated
82 by xstrdup_for_dump. */
85 dump_profile (int frequency
, profile_count
&count
)
87 float minimum
= 0.01f
;
89 gcc_assert (0 <= frequency
&& frequency
<= REG_BR_PROB_BASE
);
90 float fvalue
= frequency
* 100.0f
/ REG_BR_PROB_BASE
;
91 if (fvalue
< minimum
&& frequency
> 0)
95 if (count
.initialized_p ())
96 buf
= xasprintf ("[%.2f%%] [count: %" PRId64
"]", fvalue
,
97 count
.to_gcov_type ());
99 buf
= xasprintf ("[%.2f%%] [count: INV]", fvalue
);
101 const char *ret
= xstrdup_for_dump (buf
);
107 /* Return formatted string of a VALUE probability
108 (biased by REG_BR_PROB_BASE). Returned string is allocated
109 by xstrdup_for_dump. */
112 dump_probability (profile_probability probability
, profile_count
&count
)
114 float minimum
= 0.01f
;
117 if (probability
.initialized_p ())
119 fvalue
= probability
.to_reg_br_prob_base () * 100.0f
/ REG_BR_PROB_BASE
;
120 if (fvalue
< minimum
&& probability
.to_reg_br_prob_base ())
125 if (count
.initialized_p ())
126 buf
= xasprintf ("[%.2f%%] [count: %" PRId64
"]", fvalue
,
127 count
.to_gcov_type ());
128 else if (probability
.initialized_p ())
129 buf
= xasprintf ("[%.2f%%] [count: INV]", fvalue
);
131 buf
= xasprintf ("[INV] [count: INV]");
133 const char *ret
= xstrdup_for_dump (buf
);
139 /* Dump E probability to BUFFER. */
142 dump_edge_probability (pretty_printer
*buffer
, edge e
)
144 pp_scalar (buffer
, " %s", dump_probability (e
->probability
, e
->count
));
147 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
148 FLAGS as in pp_gimple_stmt_1. */
151 print_gimple_stmt (FILE *file
, gimple
*g
, int spc
, dump_flags_t flags
)
153 pretty_printer buffer
;
154 pp_needs_newline (&buffer
) = true;
155 buffer
.buffer
->stream
= file
;
156 pp_gimple_stmt_1 (&buffer
, g
, spc
, flags
);
157 pp_newline_and_flush (&buffer
);
163 print_gimple_stmt (stderr
, &ref
, 0, 0);
172 fprintf (stderr
, "<nil>\n");
176 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
177 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
181 print_gimple_expr (FILE *file
, gimple
*g
, int spc
, dump_flags_t flags
)
183 flags
|= TDF_RHS_ONLY
;
184 pretty_printer buffer
;
185 pp_needs_newline (&buffer
) = true;
186 buffer
.buffer
->stream
= file
;
187 pp_gimple_stmt_1 (&buffer
, g
, spc
, flags
);
192 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
193 spaces and FLAGS as in pp_gimple_stmt_1.
194 The caller is responsible for calling pp_flush on BUFFER to finalize
195 the pretty printer. */
198 dump_gimple_seq (pretty_printer
*buffer
, gimple_seq seq
, int spc
,
201 gimple_stmt_iterator i
;
203 for (i
= gsi_start (seq
); !gsi_end_p (i
); gsi_next (&i
))
205 gimple
*gs
= gsi_stmt (i
);
207 pp_gimple_stmt_1 (buffer
, gs
, spc
, flags
);
208 if (!gsi_one_before_end_p (i
))
214 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
215 FLAGS as in pp_gimple_stmt_1. */
218 print_gimple_seq (FILE *file
, gimple_seq seq
, int spc
, dump_flags_t flags
)
220 pretty_printer buffer
;
221 pp_needs_newline (&buffer
) = true;
222 buffer
.buffer
->stream
= file
;
223 dump_gimple_seq (&buffer
, seq
, spc
, flags
);
224 pp_newline_and_flush (&buffer
);
228 /* Print the GIMPLE sequence SEQ on stderr. */
231 debug_gimple_seq (gimple_seq seq
)
233 print_gimple_seq (stderr
, seq
, 0, TDF_VOPS
|TDF_MEMSYMS
);
237 /* A simple helper to pretty-print some of the gimple tuples in the printf
238 style. The format modifiers are preceded by '%' and are:
239 'G' - outputs a string corresponding to the code of the given gimple,
240 'S' - outputs a gimple_seq with indent of spc + 2,
241 'T' - outputs the tree t,
242 'd' - outputs an int as a decimal,
243 's' - outputs a string,
244 'n' - outputs a newline,
245 'x' - outputs an int as hexadecimal,
246 '+' - increases indent by 2 then outputs a newline,
247 '-' - decreases indent by 2 then outputs a newline. */
250 dump_gimple_fmt (pretty_printer
*buffer
, int spc
, dump_flags_t flags
,
251 const char *fmt
, ...)
257 va_start (args
, fmt
);
258 for (c
= fmt
; *c
; c
++)
268 g
= va_arg (args
, gimple
*);
269 tmp
= gimple_code_name
[gimple_code (g
)];
270 pp_string (buffer
, tmp
);
274 seq
= va_arg (args
, gimple_seq
);
276 dump_gimple_seq (buffer
, seq
, spc
+ 2, flags
);
277 newline_and_indent (buffer
, spc
);
281 t
= va_arg (args
, tree
);
283 pp_string (buffer
, "NULL");
285 dump_generic_node (buffer
, t
, spc
, flags
, false);
289 pp_decimal_int (buffer
, va_arg (args
, int));
293 pp_string (buffer
, va_arg (args
, char *));
297 newline_and_indent (buffer
, spc
);
301 pp_scalar (buffer
, "%x", va_arg (args
, int));
306 newline_and_indent (buffer
, spc
);
311 newline_and_indent (buffer
, spc
);
319 pp_character (buffer
, *c
);
325 /* Helper for dump_gimple_assign. Print the unary RHS of the
326 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
329 dump_unary_rhs (pretty_printer
*buffer
, gassign
*gs
, int spc
,
332 enum tree_code rhs_code
= gimple_assign_rhs_code (gs
);
333 tree lhs
= gimple_assign_lhs (gs
);
334 tree rhs
= gimple_assign_rhs1 (gs
);
338 case VIEW_CONVERT_EXPR
:
340 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
343 case FIXED_CONVERT_EXPR
:
344 case ADDR_SPACE_CONVERT_EXPR
:
348 pp_left_paren (buffer
);
349 dump_generic_node (buffer
, TREE_TYPE (lhs
), spc
, flags
, false);
350 pp_string (buffer
, ") ");
351 if (op_prio (rhs
) < op_code_prio (rhs_code
))
353 pp_left_paren (buffer
);
354 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
355 pp_right_paren (buffer
);
358 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
362 pp_string (buffer
, "((");
363 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
364 pp_string (buffer
, "))");
368 if (flags
& TDF_GIMPLE
)
370 pp_string (buffer
, "__ABS ");
371 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
375 pp_string (buffer
, "ABS_EXPR <");
376 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
382 if (TREE_CODE_CLASS (rhs_code
) == tcc_declaration
383 || TREE_CODE_CLASS (rhs_code
) == tcc_constant
384 || TREE_CODE_CLASS (rhs_code
) == tcc_reference
385 || rhs_code
== SSA_NAME
386 || rhs_code
== ADDR_EXPR
387 || rhs_code
== CONSTRUCTOR
)
389 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
392 else if (rhs_code
== BIT_NOT_EXPR
)
393 pp_complement (buffer
);
394 else if (rhs_code
== TRUTH_NOT_EXPR
)
395 pp_exclamation (buffer
);
396 else if (rhs_code
== NEGATE_EXPR
)
400 pp_left_bracket (buffer
);
401 pp_string (buffer
, get_tree_code_name (rhs_code
));
402 pp_string (buffer
, "] ");
405 if (op_prio (rhs
) < op_code_prio (rhs_code
))
407 pp_left_paren (buffer
);
408 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
409 pp_right_paren (buffer
);
412 dump_generic_node (buffer
, rhs
, spc
, flags
, false);
418 /* Helper for dump_gimple_assign. Print the binary RHS of the
419 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
422 dump_binary_rhs (pretty_printer
*buffer
, gassign
*gs
, int spc
,
426 enum tree_code code
= gimple_assign_rhs_code (gs
);
432 case VEC_WIDEN_MULT_HI_EXPR
:
433 case VEC_WIDEN_MULT_LO_EXPR
:
434 case VEC_WIDEN_MULT_EVEN_EXPR
:
435 case VEC_WIDEN_MULT_ODD_EXPR
:
436 case VEC_PACK_TRUNC_EXPR
:
437 case VEC_PACK_SAT_EXPR
:
438 case VEC_PACK_FIX_TRUNC_EXPR
:
439 case VEC_WIDEN_LSHIFT_HI_EXPR
:
440 case VEC_WIDEN_LSHIFT_LO_EXPR
:
441 for (p
= get_tree_code_name (code
); *p
; p
++)
442 pp_character (buffer
, TOUPPER (*p
));
443 pp_string (buffer
, " <");
444 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
445 pp_string (buffer
, ", ");
446 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
451 if (op_prio (gimple_assign_rhs1 (gs
)) <= op_code_prio (code
))
453 pp_left_paren (buffer
);
454 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
,
456 pp_right_paren (buffer
);
459 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
461 pp_string (buffer
, op_symbol_code (gimple_assign_rhs_code (gs
)));
463 if (op_prio (gimple_assign_rhs2 (gs
)) <= op_code_prio (code
))
465 pp_left_paren (buffer
);
466 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
,
468 pp_right_paren (buffer
);
471 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
475 /* Helper for dump_gimple_assign. Print the ternary RHS of the
476 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
479 dump_ternary_rhs (pretty_printer
*buffer
, gassign
*gs
, int spc
,
483 enum tree_code code
= gimple_assign_rhs_code (gs
);
486 case WIDEN_MULT_PLUS_EXPR
:
487 case WIDEN_MULT_MINUS_EXPR
:
488 for (p
= get_tree_code_name (code
); *p
; p
++)
489 pp_character (buffer
, TOUPPER (*p
));
490 pp_string (buffer
, " <");
491 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
492 pp_string (buffer
, ", ");
493 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
494 pp_string (buffer
, ", ");
495 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
500 if (flags
& TDF_GIMPLE
)
502 pp_string (buffer
, "__FMA (");
503 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
505 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
507 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
508 pp_right_paren (buffer
);
512 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
513 pp_string (buffer
, " * ");
514 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
515 pp_string (buffer
, " + ");
516 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
521 pp_string (buffer
, "DOT_PROD_EXPR <");
522 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
523 pp_string (buffer
, ", ");
524 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
525 pp_string (buffer
, ", ");
526 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
531 pp_string (buffer
, "SAD_EXPR <");
532 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
533 pp_string (buffer
, ", ");
534 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
535 pp_string (buffer
, ", ");
536 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
541 pp_string (buffer
, "VEC_PERM_EXPR <");
542 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
543 pp_string (buffer
, ", ");
544 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
545 pp_string (buffer
, ", ");
546 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
550 case REALIGN_LOAD_EXPR
:
551 pp_string (buffer
, "REALIGN_LOAD <");
552 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
553 pp_string (buffer
, ", ");
554 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
555 pp_string (buffer
, ", ");
556 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
561 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
562 pp_string (buffer
, " ? ");
563 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
564 pp_string (buffer
, " : ");
565 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
569 pp_string (buffer
, "VEC_COND_EXPR <");
570 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
571 pp_string (buffer
, ", ");
572 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
573 pp_string (buffer
, ", ");
574 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
578 case BIT_INSERT_EXPR
:
579 pp_string (buffer
, "BIT_INSERT_EXPR <");
580 dump_generic_node (buffer
, gimple_assign_rhs1 (gs
), spc
, flags
, false);
581 pp_string (buffer
, ", ");
582 dump_generic_node (buffer
, gimple_assign_rhs2 (gs
), spc
, flags
, false);
583 pp_string (buffer
, ", ");
584 dump_generic_node (buffer
, gimple_assign_rhs3 (gs
), spc
, flags
, false);
585 pp_string (buffer
, " (");
586 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs
))))
587 pp_decimal_int (buffer
,
588 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs
))));
590 dump_generic_node (buffer
,
591 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs
))),
593 pp_string (buffer
, " bits)>");
602 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
606 dump_gimple_assign (pretty_printer
*buffer
, gassign
*gs
, int spc
,
614 switch (gimple_num_ops (gs
))
617 arg3
= gimple_assign_rhs3 (gs
);
620 arg2
= gimple_assign_rhs2 (gs
);
623 arg1
= gimple_assign_rhs1 (gs
);
629 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T, %T>", gs
,
630 get_tree_code_name (gimple_assign_rhs_code (gs
)),
631 gimple_assign_lhs (gs
), arg1
, arg2
, arg3
);
635 if (!(flags
& TDF_RHS_ONLY
))
637 dump_generic_node (buffer
, gimple_assign_lhs (gs
), spc
, flags
, false);
641 if (gimple_assign_nontemporal_move_p (gs
))
642 pp_string (buffer
, "{nt}");
644 if (gimple_has_volatile_ops (gs
))
645 pp_string (buffer
, "{v}");
650 if (gimple_num_ops (gs
) == 2)
651 dump_unary_rhs (buffer
, gs
, spc
, flags
);
652 else if (gimple_num_ops (gs
) == 3)
653 dump_binary_rhs (buffer
, gs
, spc
, flags
);
654 else if (gimple_num_ops (gs
) == 4)
655 dump_ternary_rhs (buffer
, gs
, spc
, flags
);
658 if (!(flags
& TDF_RHS_ONLY
))
659 pp_semicolon (buffer
);
664 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
668 dump_gimple_return (pretty_printer
*buffer
, greturn
*gs
, int spc
,
673 t
= gimple_return_retval (gs
);
674 t2
= gimple_return_retbnd (gs
);
676 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T %T>", gs
, t
, t2
);
679 pp_string (buffer
, "return");
683 dump_generic_node (buffer
, t
, spc
, flags
, false);
687 pp_string (buffer
, ", ");
688 dump_generic_node (buffer
, t2
, spc
, flags
, false);
690 pp_semicolon (buffer
);
695 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
699 dump_gimple_call_args (pretty_printer
*buffer
, gcall
*gs
, dump_flags_t flags
)
703 /* Pretty print first arg to certain internal fns. */
704 if (gimple_call_internal_p (gs
))
706 const char *const *enums
= NULL
;
709 switch (gimple_call_internal_fn (gs
))
713 static const char *const unique_args
[] = {IFN_UNIQUE_CODES
};
717 limit
= ARRAY_SIZE (unique_args
);
722 static const char *const loop_args
[] = {IFN_GOACC_LOOP_CODES
};
725 limit
= ARRAY_SIZE (loop_args
);
728 case IFN_GOACC_REDUCTION
:
730 static const char *const reduction_args
[]
731 = {IFN_GOACC_REDUCTION_CODES
};
733 enums
= reduction_args
;
734 limit
= ARRAY_SIZE (reduction_args
);
739 static const char *const asan_mark_args
[] = {IFN_ASAN_MARK_FLAGS
};
741 enums
= asan_mark_args
;
742 limit
= ARRAY_SIZE (asan_mark_args
);
750 tree arg0
= gimple_call_arg (gs
, 0);
753 if (TREE_CODE (arg0
) == INTEGER_CST
754 && tree_fits_shwi_p (arg0
)
755 && (v
= tree_to_shwi (arg0
)) >= 0 && v
< limit
)
758 pp_string (buffer
, enums
[v
]);
763 for (; i
< gimple_call_num_args (gs
); i
++)
766 pp_string (buffer
, ", ");
767 dump_generic_node (buffer
, gimple_call_arg (gs
, i
), 0, flags
, false);
770 if (gimple_call_va_arg_pack_p (gs
))
773 pp_string (buffer
, ", ");
775 pp_string (buffer
, "__builtin_va_arg_pack ()");
779 /* Dump the points-to solution *PT to BUFFER. */
782 pp_points_to_solution (pretty_printer
*buffer
, struct pt_solution
*pt
)
786 pp_string (buffer
, "anything ");
790 pp_string (buffer
, "nonlocal ");
792 pp_string (buffer
, "escaped ");
794 pp_string (buffer
, "unit-escaped ");
796 pp_string (buffer
, "null ");
798 && !bitmap_empty_p (pt
->vars
))
802 pp_string (buffer
, "{ ");
803 EXECUTE_IF_SET_IN_BITMAP (pt
->vars
, 0, i
, bi
)
805 pp_string (buffer
, "D.");
806 pp_decimal_int (buffer
, i
);
809 pp_right_brace (buffer
);
810 if (pt
->vars_contains_nonlocal
811 || pt
->vars_contains_escaped
812 || pt
->vars_contains_escaped_heap
813 || pt
->vars_contains_restrict
)
815 const char *comma
= "";
816 pp_string (buffer
, " (");
817 if (pt
->vars_contains_nonlocal
)
819 pp_string (buffer
, "nonlocal");
822 if (pt
->vars_contains_escaped
)
824 pp_string (buffer
, comma
);
825 pp_string (buffer
, "escaped");
828 if (pt
->vars_contains_escaped_heap
)
830 pp_string (buffer
, comma
);
831 pp_string (buffer
, "escaped heap");
834 if (pt
->vars_contains_restrict
)
836 pp_string (buffer
, comma
);
837 pp_string (buffer
, "restrict");
840 if (pt
->vars_contains_interposable
)
842 pp_string (buffer
, comma
);
843 pp_string (buffer
, "interposable");
845 pp_string (buffer
, ")");
851 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
855 dump_gimple_call (pretty_printer
*buffer
, gcall
*gs
, int spc
,
858 tree lhs
= gimple_call_lhs (gs
);
859 tree fn
= gimple_call_fn (gs
);
861 if (flags
& TDF_ALIAS
)
863 struct pt_solution
*pt
;
864 pt
= gimple_call_use_set (gs
);
865 if (!pt_solution_empty_p (pt
))
867 pp_string (buffer
, "# USE = ");
868 pp_points_to_solution (buffer
, pt
);
869 newline_and_indent (buffer
, spc
);
871 pt
= gimple_call_clobber_set (gs
);
872 if (!pt_solution_empty_p (pt
))
874 pp_string (buffer
, "# CLB = ");
875 pp_points_to_solution (buffer
, pt
);
876 newline_and_indent (buffer
, spc
);
882 if (gimple_call_internal_p (gs
))
883 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T", gs
,
884 internal_fn_name (gimple_call_internal_fn (gs
)), lhs
);
886 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T", gs
, fn
, lhs
);
887 if (gimple_call_num_args (gs
) > 0)
889 pp_string (buffer
, ", ");
890 dump_gimple_call_args (buffer
, gs
, flags
);
896 if (lhs
&& !(flags
& TDF_RHS_ONLY
))
898 dump_generic_node (buffer
, lhs
, spc
, flags
, false);
899 pp_string (buffer
, " =");
901 if (gimple_has_volatile_ops (gs
))
902 pp_string (buffer
, "{v}");
906 if (gimple_call_internal_p (gs
))
907 pp_string (buffer
, internal_fn_name (gimple_call_internal_fn (gs
)));
909 print_call_name (buffer
, fn
, flags
);
910 pp_string (buffer
, " (");
911 dump_gimple_call_args (buffer
, gs
, flags
);
912 pp_right_paren (buffer
);
913 if (!(flags
& TDF_RHS_ONLY
))
914 pp_semicolon (buffer
);
917 if (gimple_call_chain (gs
))
919 pp_string (buffer
, " [static-chain: ");
920 dump_generic_node (buffer
, gimple_call_chain (gs
), spc
, flags
, false);
921 pp_right_bracket (buffer
);
924 if (gimple_call_return_slot_opt_p (gs
))
925 pp_string (buffer
, " [return slot optimization]");
926 if (gimple_call_tail_p (gs
))
927 pp_string (buffer
, " [tail call]");
928 if (gimple_call_must_tail_p (gs
))
929 pp_string (buffer
, " [must tail call]");
934 /* Dump the arguments of _ITM_beginTransaction sanely. */
935 if (TREE_CODE (fn
) == ADDR_EXPR
)
936 fn
= TREE_OPERAND (fn
, 0);
937 if (TREE_CODE (fn
) == FUNCTION_DECL
&& decl_is_tm_clone (fn
))
938 pp_string (buffer
, " [tm-clone]");
939 if (TREE_CODE (fn
) == FUNCTION_DECL
940 && DECL_BUILT_IN_CLASS (fn
) == BUILT_IN_NORMAL
941 && DECL_FUNCTION_CODE (fn
) == BUILT_IN_TM_START
942 && gimple_call_num_args (gs
) > 0)
944 tree t
= gimple_call_arg (gs
, 0);
945 unsigned HOST_WIDE_INT props
;
946 gcc_assert (TREE_CODE (t
) == INTEGER_CST
);
948 pp_string (buffer
, " [ ");
950 /* Get the transaction code properties. */
951 props
= TREE_INT_CST_LOW (t
);
953 if (props
& PR_INSTRUMENTEDCODE
)
954 pp_string (buffer
, "instrumentedCode ");
955 if (props
& PR_UNINSTRUMENTEDCODE
)
956 pp_string (buffer
, "uninstrumentedCode ");
957 if (props
& PR_HASNOXMMUPDATE
)
958 pp_string (buffer
, "hasNoXMMUpdate ");
959 if (props
& PR_HASNOABORT
)
960 pp_string (buffer
, "hasNoAbort ");
961 if (props
& PR_HASNOIRREVOCABLE
)
962 pp_string (buffer
, "hasNoIrrevocable ");
963 if (props
& PR_DOESGOIRREVOCABLE
)
964 pp_string (buffer
, "doesGoIrrevocable ");
965 if (props
& PR_HASNOSIMPLEREADS
)
966 pp_string (buffer
, "hasNoSimpleReads ");
967 if (props
& PR_AWBARRIERSOMITTED
)
968 pp_string (buffer
, "awBarriersOmitted ");
969 if (props
& PR_RARBARRIERSOMITTED
)
970 pp_string (buffer
, "RaRBarriersOmitted ");
971 if (props
& PR_UNDOLOGCODE
)
972 pp_string (buffer
, "undoLogCode ");
973 if (props
& PR_PREFERUNINSTRUMENTED
)
974 pp_string (buffer
, "preferUninstrumented ");
975 if (props
& PR_EXCEPTIONBLOCK
)
976 pp_string (buffer
, "exceptionBlock ");
977 if (props
& PR_HASELSE
)
978 pp_string (buffer
, "hasElse ");
979 if (props
& PR_READONLY
)
980 pp_string (buffer
, "readOnly ");
982 pp_right_bracket (buffer
);
987 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
991 dump_gimple_switch (pretty_printer
*buffer
, gswitch
*gs
, int spc
,
996 GIMPLE_CHECK (gs
, GIMPLE_SWITCH
);
998 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", gs
,
999 gimple_switch_index (gs
));
1002 pp_string (buffer
, "switch (");
1003 dump_generic_node (buffer
, gimple_switch_index (gs
), spc
, flags
, true);
1004 if (flags
& TDF_GIMPLE
)
1005 pp_string (buffer
, ") {");
1007 pp_string (buffer
, ") <");
1010 for (i
= 0; i
< gimple_switch_num_labels (gs
); i
++)
1012 tree case_label
= gimple_switch_label (gs
, i
);
1013 gcc_checking_assert (case_label
!= NULL_TREE
);
1014 dump_generic_node (buffer
, case_label
, spc
, flags
, false);
1016 tree label
= CASE_LABEL (case_label
);
1017 dump_generic_node (buffer
, label
, spc
, flags
, false);
1019 if (cfun
&& cfun
->cfg
)
1021 basic_block dest
= label_to_block (label
);
1024 edge label_edge
= find_edge (gimple_bb (gs
), dest
);
1025 if (label_edge
&& !(flags
& TDF_GIMPLE
))
1026 dump_edge_probability (buffer
, label_edge
);
1030 if (i
< gimple_switch_num_labels (gs
) - 1)
1032 if (flags
& TDF_GIMPLE
)
1033 pp_string (buffer
, "; ");
1035 pp_string (buffer
, ", ");
1038 if (flags
& TDF_GIMPLE
)
1039 pp_string (buffer
, "; }");
1041 pp_greater (buffer
);
1045 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1046 pp_gimple_stmt_1. */
1049 dump_gimple_cond (pretty_printer
*buffer
, gcond
*gs
, int spc
,
1052 if (flags
& TDF_RAW
)
1053 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%s, %T, %T, %T, %T>", gs
,
1054 get_tree_code_name (gimple_cond_code (gs
)),
1055 gimple_cond_lhs (gs
), gimple_cond_rhs (gs
),
1056 gimple_cond_true_label (gs
), gimple_cond_false_label (gs
));
1059 if (!(flags
& TDF_RHS_ONLY
))
1060 pp_string (buffer
, "if (");
1061 dump_generic_node (buffer
, gimple_cond_lhs (gs
), spc
, flags
, false);
1063 pp_string (buffer
, op_symbol_code (gimple_cond_code (gs
)));
1065 dump_generic_node (buffer
, gimple_cond_rhs (gs
), spc
, flags
, false);
1066 if (!(flags
& TDF_RHS_ONLY
))
1069 edge e
, true_edge
= NULL
, false_edge
= NULL
;
1070 basic_block bb
= gimple_bb (gs
);
1074 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
1076 if (e
->flags
& EDGE_TRUE_VALUE
)
1078 else if (e
->flags
& EDGE_FALSE_VALUE
)
1083 bool has_edge_info
= true_edge
!= NULL
&& false_edge
!= NULL
;
1085 pp_right_paren (buffer
);
1087 if (gimple_cond_true_label (gs
))
1089 pp_string (buffer
, " goto ");
1090 dump_generic_node (buffer
, gimple_cond_true_label (gs
),
1092 if (has_edge_info
&& !(flags
& TDF_GIMPLE
))
1093 dump_edge_probability (buffer
, true_edge
);
1094 pp_semicolon (buffer
);
1096 if (gimple_cond_false_label (gs
))
1098 pp_string (buffer
, " else goto ");
1099 dump_generic_node (buffer
, gimple_cond_false_label (gs
),
1101 if (has_edge_info
&& !(flags
& TDF_GIMPLE
))
1102 dump_edge_probability (buffer
, false_edge
);
1104 pp_semicolon (buffer
);
1111 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1112 spaces of indent. FLAGS specifies details to show in the dump (see
1113 TDF_* in dumpfils.h). */
1116 dump_gimple_label (pretty_printer
*buffer
, glabel
*gs
, int spc
,
1119 tree label
= gimple_label_label (gs
);
1120 if (flags
& TDF_RAW
)
1121 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
1124 dump_generic_node (buffer
, label
, spc
, flags
, false);
1127 if (flags
& TDF_GIMPLE
)
1129 if (DECL_NONLOCAL (label
))
1130 pp_string (buffer
, " [non-local]");
1131 if ((flags
& TDF_EH
) && EH_LANDING_PAD_NR (label
))
1132 pp_printf (buffer
, " [LP %d]", EH_LANDING_PAD_NR (label
));
1135 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1136 spaces of indent. FLAGS specifies details to show in the dump (see
1137 TDF_* in dumpfile.h). */
1140 dump_gimple_goto (pretty_printer
*buffer
, ggoto
*gs
, int spc
,
1143 tree label
= gimple_goto_dest (gs
);
1144 if (flags
& TDF_RAW
)
1145 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
, label
);
1147 dump_gimple_fmt (buffer
, spc
, flags
, "goto %T;", label
);
1151 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1152 spaces of indent. FLAGS specifies details to show in the dump (see
1153 TDF_* in dumpfile.h). */
1156 dump_gimple_bind (pretty_printer
*buffer
, gbind
*gs
, int spc
,
1159 if (flags
& TDF_RAW
)
1160 dump_gimple_fmt (buffer
, spc
, flags
, "%G <", gs
);
1162 pp_left_brace (buffer
);
1163 if (!(flags
& TDF_SLIM
))
1167 for (var
= gimple_bind_vars (gs
); var
; var
= DECL_CHAIN (var
))
1169 newline_and_indent (buffer
, 2);
1170 print_declaration (buffer
, var
, spc
, flags
);
1172 if (gimple_bind_vars (gs
))
1173 pp_newline (buffer
);
1175 pp_newline (buffer
);
1176 dump_gimple_seq (buffer
, gimple_bind_body (gs
), spc
+ 2, flags
);
1177 newline_and_indent (buffer
, spc
);
1178 if (flags
& TDF_RAW
)
1179 pp_greater (buffer
);
1181 pp_right_brace (buffer
);
1185 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1186 indent. FLAGS specifies details to show in the dump (see TDF_* in
1190 dump_gimple_try (pretty_printer
*buffer
, gtry
*gs
, int spc
,
1193 if (flags
& TDF_RAW
)
1196 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
1197 type
= "GIMPLE_TRY_CATCH";
1198 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
1199 type
= "GIMPLE_TRY_FINALLY";
1201 type
= "UNKNOWN GIMPLE_TRY";
1202 dump_gimple_fmt (buffer
, spc
, flags
,
1203 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs
, type
,
1204 gimple_try_eval (gs
), gimple_try_cleanup (gs
));
1208 pp_string (buffer
, "try");
1209 newline_and_indent (buffer
, spc
+ 2);
1210 pp_left_brace (buffer
);
1211 pp_newline (buffer
);
1213 dump_gimple_seq (buffer
, gimple_try_eval (gs
), spc
+ 4, flags
);
1214 newline_and_indent (buffer
, spc
+ 2);
1215 pp_right_brace (buffer
);
1217 if (gimple_try_kind (gs
) == GIMPLE_TRY_CATCH
)
1219 newline_and_indent (buffer
, spc
);
1220 pp_string (buffer
, "catch");
1221 newline_and_indent (buffer
, spc
+ 2);
1222 pp_left_brace (buffer
);
1224 else if (gimple_try_kind (gs
) == GIMPLE_TRY_FINALLY
)
1226 newline_and_indent (buffer
, spc
);
1227 pp_string (buffer
, "finally");
1228 newline_and_indent (buffer
, spc
+ 2);
1229 pp_left_brace (buffer
);
1232 pp_string (buffer
, " <UNKNOWN GIMPLE_TRY> {");
1234 pp_newline (buffer
);
1235 dump_gimple_seq (buffer
, gimple_try_cleanup (gs
), spc
+ 4, flags
);
1236 newline_and_indent (buffer
, spc
+ 2);
1237 pp_right_brace (buffer
);
1242 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1243 indent. FLAGS specifies details to show in the dump (see TDF_* in
1247 dump_gimple_catch (pretty_printer
*buffer
, gcatch
*gs
, int spc
,
1250 if (flags
& TDF_RAW
)
1251 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+CATCH <%S>%->", gs
,
1252 gimple_catch_types (gs
), gimple_catch_handler (gs
));
1254 dump_gimple_fmt (buffer
, spc
, flags
, "catch (%T)%+{%S}",
1255 gimple_catch_types (gs
), gimple_catch_handler (gs
));
1259 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1260 indent. FLAGS specifies details to show in the dump (see TDF_* in
1264 dump_gimple_eh_filter (pretty_printer
*buffer
, geh_filter
*gs
, int spc
,
1267 if (flags
& TDF_RAW
)
1268 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %+FAILURE <%S>%->", gs
,
1269 gimple_eh_filter_types (gs
),
1270 gimple_eh_filter_failure (gs
));
1272 dump_gimple_fmt (buffer
, spc
, flags
, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1273 gimple_eh_filter_types (gs
),
1274 gimple_eh_filter_failure (gs
));
1278 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1281 dump_gimple_eh_must_not_throw (pretty_printer
*buffer
,
1282 geh_mnt
*gs
, int spc
, dump_flags_t flags
)
1284 if (flags
& TDF_RAW
)
1285 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
,
1286 gimple_eh_must_not_throw_fndecl (gs
));
1288 dump_gimple_fmt (buffer
, spc
, flags
, "<<<eh_must_not_throw (%T)>>>",
1289 gimple_eh_must_not_throw_fndecl (gs
));
1293 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1294 indent. FLAGS specifies details to show in the dump (see TDF_* in
1298 dump_gimple_eh_else (pretty_printer
*buffer
, geh_else
*gs
, int spc
,
1301 if (flags
& TDF_RAW
)
1302 dump_gimple_fmt (buffer
, spc
, flags
,
1303 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs
,
1304 gimple_eh_else_n_body (gs
), gimple_eh_else_e_body (gs
));
1306 dump_gimple_fmt (buffer
, spc
, flags
,
1307 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1308 gimple_eh_else_n_body (gs
), gimple_eh_else_e_body (gs
));
1312 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1313 indent. FLAGS specifies details to show in the dump (see TDF_* in
1317 dump_gimple_resx (pretty_printer
*buffer
, gresx
*gs
, int spc
,
1320 if (flags
& TDF_RAW
)
1321 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%d>", gs
,
1322 gimple_resx_region (gs
));
1324 dump_gimple_fmt (buffer
, spc
, flags
, "resx %d", gimple_resx_region (gs
));
1327 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1330 dump_gimple_eh_dispatch (pretty_printer
*buffer
, geh_dispatch
*gs
, int spc
,
1333 if (flags
& TDF_RAW
)
1334 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%d>", gs
,
1335 gimple_eh_dispatch_region (gs
));
1337 dump_gimple_fmt (buffer
, spc
, flags
, "eh_dispatch %d",
1338 gimple_eh_dispatch_region (gs
));
1341 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1342 of indent. FLAGS specifies details to show in the dump (see TDF_*
1346 dump_gimple_debug (pretty_printer
*buffer
, gdebug
*gs
, int spc
,
1349 switch (gs
->subcode
)
1351 case GIMPLE_DEBUG_BIND
:
1352 if (flags
& TDF_RAW
)
1353 dump_gimple_fmt (buffer
, spc
, flags
, "%G BIND <%T, %T>", gs
,
1354 gimple_debug_bind_get_var (gs
),
1355 gimple_debug_bind_get_value (gs
));
1357 dump_gimple_fmt (buffer
, spc
, flags
, "# DEBUG %T => %T",
1358 gimple_debug_bind_get_var (gs
),
1359 gimple_debug_bind_get_value (gs
));
1362 case GIMPLE_DEBUG_SOURCE_BIND
:
1363 if (flags
& TDF_RAW
)
1364 dump_gimple_fmt (buffer
, spc
, flags
, "%G SRCBIND <%T, %T>", gs
,
1365 gimple_debug_source_bind_get_var (gs
),
1366 gimple_debug_source_bind_get_value (gs
));
1368 dump_gimple_fmt (buffer
, spc
, flags
, "# DEBUG %T s=> %T",
1369 gimple_debug_source_bind_get_var (gs
),
1370 gimple_debug_source_bind_get_value (gs
));
1378 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1380 dump_gimple_omp_for (pretty_printer
*buffer
, gomp_for
*gs
, int spc
,
1385 if (flags
& TDF_RAW
)
1388 switch (gimple_omp_for_kind (gs
))
1390 case GF_OMP_FOR_KIND_FOR
:
1393 case GF_OMP_FOR_KIND_DISTRIBUTE
:
1394 kind
= " distribute";
1396 case GF_OMP_FOR_KIND_TASKLOOP
:
1399 case GF_OMP_FOR_KIND_CILKFOR
:
1400 kind
= " _Cilk_for";
1402 case GF_OMP_FOR_KIND_OACC_LOOP
:
1403 kind
= " oacc_loop";
1405 case GF_OMP_FOR_KIND_SIMD
:
1408 case GF_OMP_FOR_KIND_CILKSIMD
:
1414 dump_gimple_fmt (buffer
, spc
, flags
, "%G%s <%+BODY <%S>%nCLAUSES <", gs
,
1415 kind
, gimple_omp_body (gs
));
1416 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
1417 dump_gimple_fmt (buffer
, spc
, flags
, " >,");
1418 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
1419 dump_gimple_fmt (buffer
, spc
, flags
,
1420 "%+%T, %T, %T, %s, %T,%n",
1421 gimple_omp_for_index (gs
, i
),
1422 gimple_omp_for_initial (gs
, i
),
1423 gimple_omp_for_final (gs
, i
),
1424 get_tree_code_name (gimple_omp_for_cond (gs
, i
)),
1425 gimple_omp_for_incr (gs
, i
));
1426 dump_gimple_fmt (buffer
, spc
, flags
, "PRE_BODY <%S>%->",
1427 gimple_omp_for_pre_body (gs
));
1431 switch (gimple_omp_for_kind (gs
))
1433 case GF_OMP_FOR_KIND_FOR
:
1434 pp_string (buffer
, "#pragma omp for");
1436 case GF_OMP_FOR_KIND_DISTRIBUTE
:
1437 pp_string (buffer
, "#pragma omp distribute");
1439 case GF_OMP_FOR_KIND_TASKLOOP
:
1440 pp_string (buffer
, "#pragma omp taskloop");
1442 case GF_OMP_FOR_KIND_CILKFOR
:
1444 case GF_OMP_FOR_KIND_OACC_LOOP
:
1445 pp_string (buffer
, "#pragma acc loop");
1447 case GF_OMP_FOR_KIND_SIMD
:
1448 pp_string (buffer
, "#pragma omp simd");
1450 case GF_OMP_FOR_KIND_CILKSIMD
:
1451 pp_string (buffer
, "#pragma simd");
1453 case GF_OMP_FOR_KIND_GRID_LOOP
:
1454 pp_string (buffer
, "#pragma omp for grid_loop");
1459 if (gimple_omp_for_kind (gs
) != GF_OMP_FOR_KIND_CILKFOR
)
1460 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
1461 for (i
= 0; i
< gimple_omp_for_collapse (gs
); i
++)
1465 if (gimple_omp_for_kind (gs
) == GF_OMP_FOR_KIND_CILKFOR
)
1466 pp_string (buffer
, "_Cilk_for (");
1469 newline_and_indent (buffer
, spc
);
1470 pp_string (buffer
, "for (");
1472 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
1474 pp_string (buffer
, " = ");
1475 dump_generic_node (buffer
, gimple_omp_for_initial (gs
, i
), spc
,
1477 pp_string (buffer
, "; ");
1479 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
1482 switch (gimple_omp_for_cond (gs
, i
))
1488 pp_greater (buffer
);
1491 pp_less_equal (buffer
);
1494 pp_greater_equal (buffer
);
1497 pp_string (buffer
, "!=");
1503 dump_generic_node (buffer
, gimple_omp_for_final (gs
, i
), spc
,
1505 pp_string (buffer
, "; ");
1507 dump_generic_node (buffer
, gimple_omp_for_index (gs
, i
), spc
,
1509 pp_string (buffer
, " = ");
1510 dump_generic_node (buffer
, gimple_omp_for_incr (gs
, i
), spc
,
1512 pp_right_paren (buffer
);
1515 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1517 if (gimple_omp_for_kind (gs
) == GF_OMP_FOR_KIND_CILKFOR
)
1518 dump_omp_clauses (buffer
, gimple_omp_for_clauses (gs
), spc
, flags
);
1519 newline_and_indent (buffer
, spc
+ 2);
1520 pp_left_brace (buffer
);
1521 pp_newline (buffer
);
1522 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1523 newline_and_indent (buffer
, spc
+ 2);
1524 pp_right_brace (buffer
);
1529 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1532 dump_gimple_omp_continue (pretty_printer
*buffer
, gomp_continue
*gs
,
1533 int spc
, dump_flags_t flags
)
1535 if (flags
& TDF_RAW
)
1537 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
1538 gimple_omp_continue_control_def (gs
),
1539 gimple_omp_continue_control_use (gs
));
1543 pp_string (buffer
, "#pragma omp continue (");
1544 dump_generic_node (buffer
, gimple_omp_continue_control_def (gs
),
1548 dump_generic_node (buffer
, gimple_omp_continue_control_use (gs
),
1550 pp_right_paren (buffer
);
1554 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1557 dump_gimple_omp_single (pretty_printer
*buffer
, gomp_single
*gs
,
1558 int spc
, dump_flags_t flags
)
1560 if (flags
& TDF_RAW
)
1562 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1563 gimple_omp_body (gs
));
1564 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
1565 dump_gimple_fmt (buffer
, spc
, flags
, " >");
1569 pp_string (buffer
, "#pragma omp single");
1570 dump_omp_clauses (buffer
, gimple_omp_single_clauses (gs
), spc
, flags
);
1571 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1573 newline_and_indent (buffer
, spc
+ 2);
1574 pp_left_brace (buffer
);
1575 pp_newline (buffer
);
1576 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1577 newline_and_indent (buffer
, spc
+ 2);
1578 pp_right_brace (buffer
);
1583 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1586 dump_gimple_omp_target (pretty_printer
*buffer
, gomp_target
*gs
,
1587 int spc
, dump_flags_t flags
)
1590 switch (gimple_omp_target_kind (gs
))
1592 case GF_OMP_TARGET_KIND_REGION
:
1595 case GF_OMP_TARGET_KIND_DATA
:
1598 case GF_OMP_TARGET_KIND_UPDATE
:
1601 case GF_OMP_TARGET_KIND_ENTER_DATA
:
1602 kind
= " enter data";
1604 case GF_OMP_TARGET_KIND_EXIT_DATA
:
1605 kind
= " exit data";
1607 case GF_OMP_TARGET_KIND_OACC_KERNELS
:
1608 kind
= " oacc_kernels";
1610 case GF_OMP_TARGET_KIND_OACC_PARALLEL
:
1611 kind
= " oacc_parallel";
1613 case GF_OMP_TARGET_KIND_OACC_DATA
:
1614 kind
= " oacc_data";
1616 case GF_OMP_TARGET_KIND_OACC_UPDATE
:
1617 kind
= " oacc_update";
1619 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA
:
1620 kind
= " oacc_enter_exit_data";
1622 case GF_OMP_TARGET_KIND_OACC_DECLARE
:
1623 kind
= " oacc_declare";
1625 case GF_OMP_TARGET_KIND_OACC_HOST_DATA
:
1626 kind
= " oacc_host_data";
1631 if (flags
& TDF_RAW
)
1633 dump_gimple_fmt (buffer
, spc
, flags
, "%G%s <%+BODY <%S>%nCLAUSES <", gs
,
1634 kind
, gimple_omp_body (gs
));
1635 dump_omp_clauses (buffer
, gimple_omp_target_clauses (gs
), spc
, flags
);
1636 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T%n>",
1637 gimple_omp_target_child_fn (gs
),
1638 gimple_omp_target_data_arg (gs
));
1642 pp_string (buffer
, "#pragma omp target");
1643 pp_string (buffer
, kind
);
1644 dump_omp_clauses (buffer
, gimple_omp_target_clauses (gs
), spc
, flags
);
1645 if (gimple_omp_target_child_fn (gs
))
1647 pp_string (buffer
, " [child fn: ");
1648 dump_generic_node (buffer
, gimple_omp_target_child_fn (gs
),
1650 pp_string (buffer
, " (");
1651 if (gimple_omp_target_data_arg (gs
))
1652 dump_generic_node (buffer
, gimple_omp_target_data_arg (gs
),
1655 pp_string (buffer
, "???");
1656 pp_string (buffer
, ")]");
1658 gimple_seq body
= gimple_omp_body (gs
);
1659 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
1661 newline_and_indent (buffer
, spc
+ 2);
1662 pp_left_brace (buffer
);
1663 pp_newline (buffer
);
1664 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
1665 newline_and_indent (buffer
, spc
+ 2);
1666 pp_right_brace (buffer
);
1670 pp_newline (buffer
);
1671 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
1676 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1679 dump_gimple_omp_teams (pretty_printer
*buffer
, gomp_teams
*gs
, int spc
,
1682 if (flags
& TDF_RAW
)
1684 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1685 gimple_omp_body (gs
));
1686 dump_omp_clauses (buffer
, gimple_omp_teams_clauses (gs
), spc
, flags
);
1687 dump_gimple_fmt (buffer
, spc
, flags
, " >");
1691 pp_string (buffer
, "#pragma omp teams");
1692 dump_omp_clauses (buffer
, gimple_omp_teams_clauses (gs
), spc
, flags
);
1693 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1695 newline_and_indent (buffer
, spc
+ 2);
1696 pp_character (buffer
, '{');
1697 pp_newline (buffer
);
1698 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1699 newline_and_indent (buffer
, spc
+ 2);
1700 pp_character (buffer
, '}');
1705 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1708 dump_gimple_omp_sections (pretty_printer
*buffer
, gomp_sections
*gs
,
1709 int spc
, dump_flags_t flags
)
1711 if (flags
& TDF_RAW
)
1713 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
1714 gimple_omp_body (gs
));
1715 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
1716 dump_gimple_fmt (buffer
, spc
, flags
, " >");
1720 pp_string (buffer
, "#pragma omp sections");
1721 if (gimple_omp_sections_control (gs
))
1723 pp_string (buffer
, " <");
1724 dump_generic_node (buffer
, gimple_omp_sections_control (gs
), spc
,
1726 pp_greater (buffer
);
1728 dump_omp_clauses (buffer
, gimple_omp_sections_clauses (gs
), spc
, flags
);
1729 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1731 newline_and_indent (buffer
, spc
+ 2);
1732 pp_left_brace (buffer
);
1733 pp_newline (buffer
);
1734 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1735 newline_and_indent (buffer
, spc
+ 2);
1736 pp_right_brace (buffer
);
1741 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1742 pretty_printer BUFFER. */
1745 dump_gimple_omp_block (pretty_printer
*buffer
, gimple
*gs
, int spc
,
1748 if (flags
& TDF_RAW
)
1749 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
1750 gimple_omp_body (gs
));
1753 switch (gimple_code (gs
))
1755 case GIMPLE_OMP_MASTER
:
1756 pp_string (buffer
, "#pragma omp master");
1758 case GIMPLE_OMP_TASKGROUP
:
1759 pp_string (buffer
, "#pragma omp taskgroup");
1761 case GIMPLE_OMP_SECTION
:
1762 pp_string (buffer
, "#pragma omp section");
1764 case GIMPLE_OMP_GRID_BODY
:
1765 pp_string (buffer
, "#pragma omp gridified body");
1770 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1772 newline_and_indent (buffer
, spc
+ 2);
1773 pp_left_brace (buffer
);
1774 pp_newline (buffer
);
1775 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1776 newline_and_indent (buffer
, spc
+ 2);
1777 pp_right_brace (buffer
);
1782 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1785 dump_gimple_omp_critical (pretty_printer
*buffer
, gomp_critical
*gs
,
1786 int spc
, dump_flags_t flags
)
1788 if (flags
& TDF_RAW
)
1789 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
1790 gimple_omp_body (gs
));
1793 pp_string (buffer
, "#pragma omp critical");
1794 if (gimple_omp_critical_name (gs
))
1796 pp_string (buffer
, " (");
1797 dump_generic_node (buffer
, gimple_omp_critical_name (gs
), spc
,
1799 pp_right_paren (buffer
);
1801 dump_omp_clauses (buffer
, gimple_omp_critical_clauses (gs
), spc
, flags
);
1802 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1804 newline_and_indent (buffer
, spc
+ 2);
1805 pp_left_brace (buffer
);
1806 pp_newline (buffer
);
1807 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1808 newline_and_indent (buffer
, spc
+ 2);
1809 pp_right_brace (buffer
);
1814 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1817 dump_gimple_omp_ordered (pretty_printer
*buffer
, gomp_ordered
*gs
,
1818 int spc
, dump_flags_t flags
)
1820 if (flags
& TDF_RAW
)
1821 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S> >", gs
,
1822 gimple_omp_body (gs
));
1825 pp_string (buffer
, "#pragma omp ordered");
1826 dump_omp_clauses (buffer
, gimple_omp_ordered_clauses (gs
), spc
, flags
);
1827 if (!gimple_seq_empty_p (gimple_omp_body (gs
)))
1829 newline_and_indent (buffer
, spc
+ 2);
1830 pp_left_brace (buffer
);
1831 pp_newline (buffer
);
1832 dump_gimple_seq (buffer
, gimple_omp_body (gs
), spc
+ 4, flags
);
1833 newline_and_indent (buffer
, spc
+ 2);
1834 pp_right_brace (buffer
);
1839 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1842 dump_gimple_omp_return (pretty_printer
*buffer
, gimple
*gs
, int spc
,
1845 if (flags
& TDF_RAW
)
1847 dump_gimple_fmt (buffer
, spc
, flags
, "%G <nowait=%d", gs
,
1848 (int) gimple_omp_return_nowait_p (gs
));
1849 if (gimple_omp_return_lhs (gs
))
1850 dump_gimple_fmt (buffer
, spc
, flags
, ", lhs=%T>",
1851 gimple_omp_return_lhs (gs
));
1853 dump_gimple_fmt (buffer
, spc
, flags
, ">");
1857 pp_string (buffer
, "#pragma omp return");
1858 if (gimple_omp_return_nowait_p (gs
))
1859 pp_string (buffer
, "(nowait)");
1860 if (gimple_omp_return_lhs (gs
))
1862 pp_string (buffer
, " (set ");
1863 dump_generic_node (buffer
, gimple_omp_return_lhs (gs
),
1865 pp_character (buffer
, ')');
1870 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1873 dump_gimple_transaction (pretty_printer
*buffer
, gtransaction
*gs
,
1874 int spc
, dump_flags_t flags
)
1876 unsigned subcode
= gimple_transaction_subcode (gs
);
1878 if (flags
& TDF_RAW
)
1880 dump_gimple_fmt (buffer
, spc
, flags
,
1881 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1883 gs
, subcode
, gimple_transaction_label_norm (gs
),
1884 gimple_transaction_label_uninst (gs
),
1885 gimple_transaction_label_over (gs
),
1886 gimple_transaction_body (gs
));
1890 if (subcode
& GTMA_IS_OUTER
)
1891 pp_string (buffer
, "__transaction_atomic [[outer]]");
1892 else if (subcode
& GTMA_IS_RELAXED
)
1893 pp_string (buffer
, "__transaction_relaxed");
1895 pp_string (buffer
, "__transaction_atomic");
1896 subcode
&= ~GTMA_DECLARATION_MASK
;
1898 if (gimple_transaction_body (gs
))
1900 newline_and_indent (buffer
, spc
+ 2);
1901 pp_left_brace (buffer
);
1902 pp_newline (buffer
);
1903 dump_gimple_seq (buffer
, gimple_transaction_body (gs
),
1905 newline_and_indent (buffer
, spc
+ 2);
1906 pp_right_brace (buffer
);
1910 pp_string (buffer
, " //");
1911 if (gimple_transaction_label_norm (gs
))
1913 pp_string (buffer
, " NORM=");
1914 dump_generic_node (buffer
, gimple_transaction_label_norm (gs
),
1917 if (gimple_transaction_label_uninst (gs
))
1919 pp_string (buffer
, " UNINST=");
1920 dump_generic_node (buffer
, gimple_transaction_label_uninst (gs
),
1923 if (gimple_transaction_label_over (gs
))
1925 pp_string (buffer
, " OVER=");
1926 dump_generic_node (buffer
, gimple_transaction_label_over (gs
),
1931 pp_string (buffer
, " SUBCODE=[ ");
1932 if (subcode
& GTMA_HAVE_ABORT
)
1934 pp_string (buffer
, "GTMA_HAVE_ABORT ");
1935 subcode
&= ~GTMA_HAVE_ABORT
;
1937 if (subcode
& GTMA_HAVE_LOAD
)
1939 pp_string (buffer
, "GTMA_HAVE_LOAD ");
1940 subcode
&= ~GTMA_HAVE_LOAD
;
1942 if (subcode
& GTMA_HAVE_STORE
)
1944 pp_string (buffer
, "GTMA_HAVE_STORE ");
1945 subcode
&= ~GTMA_HAVE_STORE
;
1947 if (subcode
& GTMA_MAY_ENTER_IRREVOCABLE
)
1949 pp_string (buffer
, "GTMA_MAY_ENTER_IRREVOCABLE ");
1950 subcode
&= ~GTMA_MAY_ENTER_IRREVOCABLE
;
1952 if (subcode
& GTMA_DOES_GO_IRREVOCABLE
)
1954 pp_string (buffer
, "GTMA_DOES_GO_IRREVOCABLE ");
1955 subcode
&= ~GTMA_DOES_GO_IRREVOCABLE
;
1957 if (subcode
& GTMA_HAS_NO_INSTRUMENTATION
)
1959 pp_string (buffer
, "GTMA_HAS_NO_INSTRUMENTATION ");
1960 subcode
&= ~GTMA_HAS_NO_INSTRUMENTATION
;
1963 pp_printf (buffer
, "0x%x ", subcode
);
1964 pp_right_bracket (buffer
);
1970 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1971 indent. FLAGS specifies details to show in the dump (see TDF_* in
1975 dump_gimple_asm (pretty_printer
*buffer
, gasm
*gs
, int spc
, dump_flags_t flags
)
1977 unsigned int i
, n
, f
, fields
;
1979 if (flags
& TDF_RAW
)
1981 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+STRING <%n%s%n>", gs
,
1982 gimple_asm_string (gs
));
1984 n
= gimple_asm_noutputs (gs
);
1987 newline_and_indent (buffer
, spc
+ 2);
1988 pp_string (buffer
, "OUTPUT: ");
1989 for (i
= 0; i
< n
; i
++)
1991 dump_generic_node (buffer
, gimple_asm_output_op (gs
, i
),
1994 pp_string (buffer
, ", ");
1998 n
= gimple_asm_ninputs (gs
);
2001 newline_and_indent (buffer
, spc
+ 2);
2002 pp_string (buffer
, "INPUT: ");
2003 for (i
= 0; i
< n
; i
++)
2005 dump_generic_node (buffer
, gimple_asm_input_op (gs
, i
),
2008 pp_string (buffer
, ", ");
2012 n
= gimple_asm_nclobbers (gs
);
2015 newline_and_indent (buffer
, spc
+ 2);
2016 pp_string (buffer
, "CLOBBER: ");
2017 for (i
= 0; i
< n
; i
++)
2019 dump_generic_node (buffer
, gimple_asm_clobber_op (gs
, i
),
2022 pp_string (buffer
, ", ");
2026 n
= gimple_asm_nlabels (gs
);
2029 newline_and_indent (buffer
, spc
+ 2);
2030 pp_string (buffer
, "LABEL: ");
2031 for (i
= 0; i
< n
; i
++)
2033 dump_generic_node (buffer
, gimple_asm_label_op (gs
, i
),
2036 pp_string (buffer
, ", ");
2040 newline_and_indent (buffer
, spc
);
2041 pp_greater (buffer
);
2045 pp_string (buffer
, "__asm__");
2046 if (gimple_asm_volatile_p (gs
))
2047 pp_string (buffer
, " __volatile__");
2048 if (gimple_asm_nlabels (gs
))
2049 pp_string (buffer
, " goto");
2050 pp_string (buffer
, "(\"");
2051 pp_string (buffer
, gimple_asm_string (gs
));
2052 pp_string (buffer
, "\"");
2054 if (gimple_asm_nlabels (gs
))
2056 else if (gimple_asm_nclobbers (gs
))
2058 else if (gimple_asm_ninputs (gs
))
2060 else if (gimple_asm_noutputs (gs
))
2065 for (f
= 0; f
< fields
; ++f
)
2067 pp_string (buffer
, " : ");
2072 n
= gimple_asm_noutputs (gs
);
2073 for (i
= 0; i
< n
; i
++)
2075 dump_generic_node (buffer
, gimple_asm_output_op (gs
, i
),
2078 pp_string (buffer
, ", ");
2083 n
= gimple_asm_ninputs (gs
);
2084 for (i
= 0; i
< n
; i
++)
2086 dump_generic_node (buffer
, gimple_asm_input_op (gs
, i
),
2089 pp_string (buffer
, ", ");
2094 n
= gimple_asm_nclobbers (gs
);
2095 for (i
= 0; i
< n
; i
++)
2097 dump_generic_node (buffer
, gimple_asm_clobber_op (gs
, i
),
2100 pp_string (buffer
, ", ");
2105 n
= gimple_asm_nlabels (gs
);
2106 for (i
= 0; i
< n
; i
++)
2108 dump_generic_node (buffer
, gimple_asm_label_op (gs
, i
),
2111 pp_string (buffer
, ", ");
2120 pp_string (buffer
, ");");
2124 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2125 SPC spaces of indent. */
2128 dump_ssaname_info (pretty_printer
*buffer
, tree node
, int spc
)
2130 if (TREE_CODE (node
) != SSA_NAME
)
2133 if (POINTER_TYPE_P (TREE_TYPE (node
))
2134 && SSA_NAME_PTR_INFO (node
))
2136 unsigned int align
, misalign
;
2137 struct ptr_info_def
*pi
= SSA_NAME_PTR_INFO (node
);
2138 pp_string (buffer
, "# PT = ");
2139 pp_points_to_solution (buffer
, &pi
->pt
);
2140 newline_and_indent (buffer
, spc
);
2141 if (get_ptr_info_alignment (pi
, &align
, &misalign
))
2143 pp_printf (buffer
, "# ALIGN = %u, MISALIGN = %u", align
, misalign
);
2144 newline_and_indent (buffer
, spc
);
2148 if (!POINTER_TYPE_P (TREE_TYPE (node
))
2149 && SSA_NAME_RANGE_INFO (node
))
2151 wide_int min
, max
, nonzero_bits
;
2152 value_range_type range_type
= get_range_info (node
, &min
, &max
);
2154 if (range_type
== VR_VARYING
)
2155 pp_printf (buffer
, "# RANGE VR_VARYING");
2156 else if (range_type
== VR_RANGE
|| range_type
== VR_ANTI_RANGE
)
2158 pp_printf (buffer
, "# RANGE ");
2159 pp_printf (buffer
, "%s[", range_type
== VR_RANGE
? "" : "~");
2160 pp_wide_int (buffer
, min
, TYPE_SIGN (TREE_TYPE (node
)));
2161 pp_printf (buffer
, ", ");
2162 pp_wide_int (buffer
, max
, TYPE_SIGN (TREE_TYPE (node
)));
2163 pp_printf (buffer
, "]");
2165 nonzero_bits
= get_nonzero_bits (node
);
2166 if (nonzero_bits
!= -1)
2168 pp_string (buffer
, " NONZERO ");
2169 pp_wide_int (buffer
, nonzero_bits
, UNSIGNED
);
2171 newline_and_indent (buffer
, spc
);
2175 /* As dump_ssaname_info, but dump to FILE. */
2178 dump_ssaname_info_to_file (FILE *file
, tree node
, int spc
)
2180 pretty_printer buffer
;
2181 pp_needs_newline (&buffer
) = true;
2182 buffer
.buffer
->stream
= file
;
2183 dump_ssaname_info (&buffer
, node
, spc
);
2187 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2188 The caller is responsible for calling pp_flush on BUFFER to finalize
2189 pretty printer. If COMMENT is true, print this after #. */
2192 dump_gimple_phi (pretty_printer
*buffer
, gphi
*phi
, int spc
, bool comment
,
2196 tree lhs
= gimple_phi_result (phi
);
2198 if (flags
& TDF_ALIAS
)
2199 dump_ssaname_info (buffer
, lhs
, spc
);
2202 pp_string (buffer
, "# ");
2204 if (flags
& TDF_RAW
)
2205 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, ", phi
,
2206 gimple_phi_result (phi
));
2209 dump_generic_node (buffer
, lhs
, spc
, flags
, false);
2210 if (flags
& TDF_GIMPLE
)
2211 pp_string (buffer
, " = __PHI (");
2213 pp_string (buffer
, " = PHI <");
2215 for (i
= 0; i
< gimple_phi_num_args (phi
); i
++)
2217 if ((flags
& TDF_LINENO
) && gimple_phi_arg_has_location (phi
, i
))
2218 dump_location (buffer
, gimple_phi_arg_location (phi
, i
));
2219 if (flags
& TDF_GIMPLE
)
2221 basic_block src
= gimple_phi_arg_edge (phi
, i
)->src
;
2222 gimple
*stmt
= first_stmt (src
);
2223 if (!stmt
|| gimple_code (stmt
) != GIMPLE_LABEL
)
2225 pp_string (buffer
, "bb_");
2226 pp_decimal_int (buffer
, src
->index
);
2229 dump_generic_node (buffer
, gimple_label_label (as_a
<glabel
*> (stmt
)), 0, flags
,
2231 pp_string (buffer
, ": ");
2233 dump_generic_node (buffer
, gimple_phi_arg_def (phi
, i
), spc
, flags
,
2235 if (! (flags
& TDF_GIMPLE
))
2237 pp_left_paren (buffer
);
2238 pp_decimal_int (buffer
, gimple_phi_arg_edge (phi
, i
)->src
->index
);
2239 pp_right_paren (buffer
);
2241 if (i
< gimple_phi_num_args (phi
) - 1)
2242 pp_string (buffer
, ", ");
2244 if (flags
& TDF_GIMPLE
)
2245 pp_string (buffer
, ");");
2247 pp_greater (buffer
);
2251 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2252 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2256 dump_gimple_omp_parallel (pretty_printer
*buffer
, gomp_parallel
*gs
,
2257 int spc
, dump_flags_t flags
)
2259 if (flags
& TDF_RAW
)
2261 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
2262 gimple_omp_body (gs
));
2263 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
2264 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T%n>",
2265 gimple_omp_parallel_child_fn (gs
),
2266 gimple_omp_parallel_data_arg (gs
));
2271 pp_string (buffer
, "#pragma omp parallel");
2272 dump_omp_clauses (buffer
, gimple_omp_parallel_clauses (gs
), spc
, flags
);
2273 if (gimple_omp_parallel_child_fn (gs
))
2275 pp_string (buffer
, " [child fn: ");
2276 dump_generic_node (buffer
, gimple_omp_parallel_child_fn (gs
),
2278 pp_string (buffer
, " (");
2279 if (gimple_omp_parallel_data_arg (gs
))
2280 dump_generic_node (buffer
, gimple_omp_parallel_data_arg (gs
),
2283 pp_string (buffer
, "???");
2284 pp_string (buffer
, ")]");
2286 body
= gimple_omp_body (gs
);
2287 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
2289 newline_and_indent (buffer
, spc
+ 2);
2290 pp_left_brace (buffer
);
2291 pp_newline (buffer
);
2292 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
2293 newline_and_indent (buffer
, spc
+ 2);
2294 pp_right_brace (buffer
);
2298 pp_newline (buffer
);
2299 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
2305 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2306 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2310 dump_gimple_omp_task (pretty_printer
*buffer
, gomp_task
*gs
, int spc
,
2313 if (flags
& TDF_RAW
)
2315 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%+BODY <%S>%nCLAUSES <", gs
,
2316 gimple_omp_body (gs
));
2317 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
2318 dump_gimple_fmt (buffer
, spc
, flags
, " >, %T, %T, %T, %T, %T%n>",
2319 gimple_omp_task_child_fn (gs
),
2320 gimple_omp_task_data_arg (gs
),
2321 gimple_omp_task_copy_fn (gs
),
2322 gimple_omp_task_arg_size (gs
),
2323 gimple_omp_task_arg_size (gs
));
2328 if (gimple_omp_task_taskloop_p (gs
))
2329 pp_string (buffer
, "#pragma omp taskloop");
2331 pp_string (buffer
, "#pragma omp task");
2332 dump_omp_clauses (buffer
, gimple_omp_task_clauses (gs
), spc
, flags
);
2333 if (gimple_omp_task_child_fn (gs
))
2335 pp_string (buffer
, " [child fn: ");
2336 dump_generic_node (buffer
, gimple_omp_task_child_fn (gs
),
2338 pp_string (buffer
, " (");
2339 if (gimple_omp_task_data_arg (gs
))
2340 dump_generic_node (buffer
, gimple_omp_task_data_arg (gs
),
2343 pp_string (buffer
, "???");
2344 pp_string (buffer
, ")]");
2346 body
= gimple_omp_body (gs
);
2347 if (body
&& gimple_code (gimple_seq_first_stmt (body
)) != GIMPLE_BIND
)
2349 newline_and_indent (buffer
, spc
+ 2);
2350 pp_left_brace (buffer
);
2351 pp_newline (buffer
);
2352 dump_gimple_seq (buffer
, body
, spc
+ 4, flags
);
2353 newline_and_indent (buffer
, spc
+ 2);
2354 pp_right_brace (buffer
);
2358 pp_newline (buffer
);
2359 dump_gimple_seq (buffer
, body
, spc
+ 2, flags
);
2365 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2366 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2370 dump_gimple_omp_atomic_load (pretty_printer
*buffer
, gomp_atomic_load
*gs
,
2371 int spc
, dump_flags_t flags
)
2373 if (flags
& TDF_RAW
)
2375 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T, %T>", gs
,
2376 gimple_omp_atomic_load_lhs (gs
),
2377 gimple_omp_atomic_load_rhs (gs
));
2381 pp_string (buffer
, "#pragma omp atomic_load");
2382 if (gimple_omp_atomic_seq_cst_p (gs
))
2383 pp_string (buffer
, " seq_cst");
2384 if (gimple_omp_atomic_need_value_p (gs
))
2385 pp_string (buffer
, " [needed]");
2386 newline_and_indent (buffer
, spc
+ 2);
2387 dump_generic_node (buffer
, gimple_omp_atomic_load_lhs (gs
),
2393 dump_generic_node (buffer
, gimple_omp_atomic_load_rhs (gs
),
2398 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2399 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2403 dump_gimple_omp_atomic_store (pretty_printer
*buffer
,
2404 gomp_atomic_store
*gs
, int spc
,
2407 if (flags
& TDF_RAW
)
2409 dump_gimple_fmt (buffer
, spc
, flags
, "%G <%T>", gs
,
2410 gimple_omp_atomic_store_val (gs
));
2414 pp_string (buffer
, "#pragma omp atomic_store ");
2415 if (gimple_omp_atomic_seq_cst_p (gs
))
2416 pp_string (buffer
, "seq_cst ");
2417 if (gimple_omp_atomic_need_value_p (gs
))
2418 pp_string (buffer
, "[needed] ");
2419 pp_left_paren (buffer
);
2420 dump_generic_node (buffer
, gimple_omp_atomic_store_val (gs
),
2422 pp_right_paren (buffer
);
2427 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2428 FLAGS are as in pp_gimple_stmt_1. */
2431 dump_gimple_mem_ops (pretty_printer
*buffer
, gimple
*gs
, int spc
,
2434 tree vdef
= gimple_vdef (gs
);
2435 tree vuse
= gimple_vuse (gs
);
2437 if (vdef
!= NULL_TREE
)
2439 pp_string (buffer
, "# ");
2440 dump_generic_node (buffer
, vdef
, spc
+ 2, flags
, false);
2441 pp_string (buffer
, " = VDEF <");
2442 dump_generic_node (buffer
, vuse
, spc
+ 2, flags
, false);
2443 pp_greater (buffer
);
2444 newline_and_indent (buffer
, spc
);
2446 else if (vuse
!= NULL_TREE
)
2448 pp_string (buffer
, "# VUSE <");
2449 dump_generic_node (buffer
, vuse
, spc
+ 2, flags
, false);
2450 pp_greater (buffer
);
2451 newline_and_indent (buffer
, spc
);
2456 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2457 spaces of indent. FLAGS specifies details to show in the dump (see
2458 TDF_* in dumpfile.h). The caller is responsible for calling
2459 pp_flush on BUFFER to finalize the pretty printer. */
2462 pp_gimple_stmt_1 (pretty_printer
*buffer
, gimple
*gs
, int spc
,
2468 if (flags
& TDF_STMTADDR
)
2469 pp_printf (buffer
, "<&%p> ", (void *) gs
);
2471 if ((flags
& TDF_LINENO
) && gimple_has_location (gs
))
2472 dump_location (buffer
, gimple_location (gs
));
2476 int lp_nr
= lookup_stmt_eh_lp (gs
);
2478 pp_printf (buffer
, "[LP %d] ", lp_nr
);
2480 pp_printf (buffer
, "[MNT %d] ", -lp_nr
);
2483 if ((flags
& (TDF_VOPS
|TDF_MEMSYMS
))
2484 && gimple_has_mem_ops (gs
))
2485 dump_gimple_mem_ops (buffer
, gs
, spc
, flags
);
2487 if (gimple_has_lhs (gs
)
2488 && (flags
& TDF_ALIAS
))
2489 dump_ssaname_info (buffer
, gimple_get_lhs (gs
), spc
);
2491 switch (gimple_code (gs
))
2494 dump_gimple_asm (buffer
, as_a
<gasm
*> (gs
), spc
, flags
);
2498 dump_gimple_assign (buffer
, as_a
<gassign
*> (gs
), spc
, flags
);
2502 dump_gimple_bind (buffer
, as_a
<gbind
*> (gs
), spc
, flags
);
2506 dump_gimple_call (buffer
, as_a
<gcall
*> (gs
), spc
, flags
);
2510 dump_gimple_cond (buffer
, as_a
<gcond
*> (gs
), spc
, flags
);
2514 dump_gimple_label (buffer
, as_a
<glabel
*> (gs
), spc
, flags
);
2518 dump_gimple_goto (buffer
, as_a
<ggoto
*> (gs
), spc
, flags
);
2522 pp_string (buffer
, "GIMPLE_NOP");
2526 dump_gimple_return (buffer
, as_a
<greturn
*> (gs
), spc
, flags
);
2530 dump_gimple_switch (buffer
, as_a
<gswitch
*> (gs
), spc
, flags
);
2534 dump_gimple_try (buffer
, as_a
<gtry
*> (gs
), spc
, flags
);
2538 dump_gimple_phi (buffer
, as_a
<gphi
*> (gs
), spc
, false, flags
);
2541 case GIMPLE_OMP_PARALLEL
:
2542 dump_gimple_omp_parallel (buffer
, as_a
<gomp_parallel
*> (gs
), spc
,
2546 case GIMPLE_OMP_TASK
:
2547 dump_gimple_omp_task (buffer
, as_a
<gomp_task
*> (gs
), spc
, flags
);
2550 case GIMPLE_OMP_ATOMIC_LOAD
:
2551 dump_gimple_omp_atomic_load (buffer
, as_a
<gomp_atomic_load
*> (gs
),
2555 case GIMPLE_OMP_ATOMIC_STORE
:
2556 dump_gimple_omp_atomic_store (buffer
,
2557 as_a
<gomp_atomic_store
*> (gs
),
2561 case GIMPLE_OMP_FOR
:
2562 dump_gimple_omp_for (buffer
, as_a
<gomp_for
*> (gs
), spc
, flags
);
2565 case GIMPLE_OMP_CONTINUE
:
2566 dump_gimple_omp_continue (buffer
, as_a
<gomp_continue
*> (gs
), spc
,
2570 case GIMPLE_OMP_SINGLE
:
2571 dump_gimple_omp_single (buffer
, as_a
<gomp_single
*> (gs
), spc
,
2575 case GIMPLE_OMP_TARGET
:
2576 dump_gimple_omp_target (buffer
, as_a
<gomp_target
*> (gs
), spc
,
2580 case GIMPLE_OMP_TEAMS
:
2581 dump_gimple_omp_teams (buffer
, as_a
<gomp_teams
*> (gs
), spc
,
2585 case GIMPLE_OMP_RETURN
:
2586 dump_gimple_omp_return (buffer
, gs
, spc
, flags
);
2589 case GIMPLE_OMP_SECTIONS
:
2590 dump_gimple_omp_sections (buffer
, as_a
<gomp_sections
*> (gs
),
2594 case GIMPLE_OMP_SECTIONS_SWITCH
:
2595 pp_string (buffer
, "GIMPLE_SECTIONS_SWITCH");
2598 case GIMPLE_OMP_MASTER
:
2599 case GIMPLE_OMP_TASKGROUP
:
2600 case GIMPLE_OMP_SECTION
:
2601 case GIMPLE_OMP_GRID_BODY
:
2602 dump_gimple_omp_block (buffer
, gs
, spc
, flags
);
2605 case GIMPLE_OMP_ORDERED
:
2606 dump_gimple_omp_ordered (buffer
, as_a
<gomp_ordered
*> (gs
), spc
,
2610 case GIMPLE_OMP_CRITICAL
:
2611 dump_gimple_omp_critical (buffer
, as_a
<gomp_critical
*> (gs
), spc
,
2616 dump_gimple_catch (buffer
, as_a
<gcatch
*> (gs
), spc
, flags
);
2619 case GIMPLE_EH_FILTER
:
2620 dump_gimple_eh_filter (buffer
, as_a
<geh_filter
*> (gs
), spc
, flags
);
2623 case GIMPLE_EH_MUST_NOT_THROW
:
2624 dump_gimple_eh_must_not_throw (buffer
,
2625 as_a
<geh_mnt
*> (gs
),
2629 case GIMPLE_EH_ELSE
:
2630 dump_gimple_eh_else (buffer
, as_a
<geh_else
*> (gs
), spc
, flags
);
2634 dump_gimple_resx (buffer
, as_a
<gresx
*> (gs
), spc
, flags
);
2637 case GIMPLE_EH_DISPATCH
:
2638 dump_gimple_eh_dispatch (buffer
, as_a
<geh_dispatch
*> (gs
), spc
,
2643 dump_gimple_debug (buffer
, as_a
<gdebug
*> (gs
), spc
, flags
);
2646 case GIMPLE_PREDICT
:
2647 pp_string (buffer
, "// predicted ");
2648 if (gimple_predict_outcome (gs
))
2649 pp_string (buffer
, "likely by ");
2651 pp_string (buffer
, "unlikely by ");
2652 pp_string (buffer
, predictor_name (gimple_predict_predictor (gs
)));
2653 pp_string (buffer
, " predictor.");
2656 case GIMPLE_TRANSACTION
:
2657 dump_gimple_transaction (buffer
, as_a
<gtransaction
*> (gs
), spc
,
2667 /* Dumps header of basic block BB to OUTF indented by INDENT
2668 spaces and details described by flags. */
2671 dump_gimple_bb_header (FILE *outf
, basic_block bb
, int indent
,
2674 if (flags
& TDF_BLOCKS
)
2676 if (flags
& TDF_LINENO
)
2678 gimple_stmt_iterator gsi
;
2680 fputs (";; ", outf
);
2682 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
2683 if (!is_gimple_debug (gsi_stmt (gsi
))
2684 && get_lineno (gsi_stmt (gsi
)) != UNKNOWN_LOCATION
)
2686 fprintf (outf
, "%*sstarting at line %d",
2687 indent
, "", get_lineno (gsi_stmt (gsi
)));
2690 if (bb
->discriminator
)
2691 fprintf (outf
, ", discriminator %i", bb
->discriminator
);
2697 if (flags
& TDF_GIMPLE
)
2698 fprintf (outf
, "%*sbb_%d:\n", indent
, "", bb
->index
);
2700 fprintf (outf
, "%*s<bb %d> %s:\n",
2701 indent
, "", bb
->index
, dump_profile (bb
->frequency
,
2707 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2711 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED
,
2712 basic_block bb ATTRIBUTE_UNUSED
,
2713 int indent ATTRIBUTE_UNUSED
,
2714 dump_flags_t flags ATTRIBUTE_UNUSED
)
2716 /* There is currently no GIMPLE-specific basic block info to dump. */
2721 /* Dump PHI nodes of basic block BB to BUFFER with details described
2722 by FLAGS and indented by INDENT spaces. */
2725 dump_phi_nodes (pretty_printer
*buffer
, basic_block bb
, int indent
,
2730 for (i
= gsi_start_phis (bb
); !gsi_end_p (i
); gsi_next (&i
))
2732 gphi
*phi
= i
.phi ();
2733 if (!virtual_operand_p (gimple_phi_result (phi
)) || (flags
& TDF_VOPS
))
2736 dump_gimple_phi (buffer
, phi
, indent
,
2737 (flags
& TDF_GIMPLE
) ? false : true, flags
);
2738 pp_newline (buffer
);
2744 /* Dump jump to basic block BB that is represented implicitly in the cfg
2748 pp_cfg_jump (pretty_printer
*buffer
, edge e
, dump_flags_t flags
)
2750 if (flags
& TDF_GIMPLE
)
2752 pp_string (buffer
, "goto bb_");
2753 pp_decimal_int (buffer
, e
->dest
->index
);
2754 pp_semicolon (buffer
);
2758 pp_string (buffer
, "goto <bb ");
2759 pp_decimal_int (buffer
, e
->dest
->index
);
2760 pp_greater (buffer
);
2761 pp_semicolon (buffer
);
2763 dump_edge_probability (buffer
, e
);
2768 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2769 by INDENT spaces, with details given by FLAGS. */
2772 dump_implicit_edges (pretty_printer
*buffer
, basic_block bb
, int indent
,
2778 stmt
= last_stmt (bb
);
2780 if (stmt
&& gimple_code (stmt
) == GIMPLE_COND
)
2782 edge true_edge
, false_edge
;
2784 /* When we are emitting the code or changing CFG, it is possible that
2785 the edges are not yet created. When we are using debug_bb in such
2786 a situation, we do not want it to crash. */
2787 if (EDGE_COUNT (bb
->succs
) != 2)
2789 extract_true_false_edges_from_block (bb
, &true_edge
, &false_edge
);
2791 INDENT (indent
+ 2);
2792 pp_cfg_jump (buffer
, true_edge
, flags
);
2793 newline_and_indent (buffer
, indent
);
2794 pp_string (buffer
, "else");
2795 newline_and_indent (buffer
, indent
+ 2);
2796 pp_cfg_jump (buffer
, false_edge
, flags
);
2797 pp_newline (buffer
);
2801 /* If there is a fallthru edge, we may need to add an artificial
2802 goto to the dump. */
2803 e
= find_fallthru_edge (bb
->succs
);
2805 if (e
&& e
->dest
!= bb
->next_bb
)
2809 if ((flags
& TDF_LINENO
)
2810 && e
->goto_locus
!= UNKNOWN_LOCATION
)
2811 dump_location (buffer
, e
->goto_locus
);
2813 pp_cfg_jump (buffer
, e
, flags
);
2814 pp_newline (buffer
);
2819 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2820 indented by INDENT spaces. */
2823 gimple_dump_bb_buff (pretty_printer
*buffer
, basic_block bb
, int indent
,
2826 gimple_stmt_iterator gsi
;
2828 int label_indent
= indent
- 2;
2830 if (label_indent
< 0)
2833 dump_phi_nodes (buffer
, bb
, indent
, flags
);
2835 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
2839 stmt
= gsi_stmt (gsi
);
2841 curr_indent
= gimple_code (stmt
) == GIMPLE_LABEL
? label_indent
: indent
;
2843 INDENT (curr_indent
);
2844 pp_gimple_stmt_1 (buffer
, stmt
, curr_indent
, flags
);
2845 pp_newline_and_flush (buffer
);
2846 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl
));
2847 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl
),
2848 pp_buffer (buffer
)->stream
, stmt
);
2851 dump_implicit_edges (buffer
, bb
, indent
, flags
);
2856 /* Dumps basic block BB to FILE with details described by FLAGS and
2857 indented by INDENT spaces. */
2860 gimple_dump_bb (FILE *file
, basic_block bb
, int indent
, dump_flags_t flags
)
2862 dump_gimple_bb_header (file
, bb
, indent
, flags
);
2863 if (bb
->index
>= NUM_FIXED_BLOCKS
)
2865 pretty_printer buffer
;
2866 pp_needs_newline (&buffer
) = true;
2867 buffer
.buffer
->stream
= file
;
2868 gimple_dump_bb_buff (&buffer
, bb
, indent
, flags
);
2870 dump_gimple_bb_footer (file
, bb
, indent
, flags
);
2873 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2874 no indentation, for use as a label of a DOT graph record-node.
2875 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2876 histogram dumping doesn't know about pretty-printers. */
2879 gimple_dump_bb_for_graph (pretty_printer
*pp
, basic_block bb
)
2881 pp_printf (pp
, "<bb %d>:\n", bb
->index
);
2882 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);
2884 for (gphi_iterator gsi
= gsi_start_phis (bb
); !gsi_end_p (gsi
);
2887 gphi
*phi
= gsi
.phi ();
2888 if (!virtual_operand_p (gimple_phi_result (phi
))
2889 || (dump_flags
& TDF_VOPS
))
2892 pp_write_text_to_stream (pp
);
2893 pp_string (pp
, "# ");
2894 pp_gimple_stmt_1 (pp
, phi
, 0, dump_flags
);
2896 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);
2900 for (gimple_stmt_iterator gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
);
2903 gimple
*stmt
= gsi_stmt (gsi
);
2905 pp_write_text_to_stream (pp
);
2906 pp_gimple_stmt_1 (pp
, stmt
, 0, dump_flags
);
2908 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);
2910 dump_implicit_edges (pp
, bb
, 0, dump_flags
);
2911 pp_write_text_as_dot_label_to_stream (pp
, /*for_record=*/true);
2915 /* Handle the %G format for TEXT. Same as %K in handle_K_format in
2916 tree-pretty-print.c but with a Gimple call statement as an argument. */
2919 percent_G_format (text_info
*text
)
2921 gcall
*stmt
= va_arg (*text
->args_ptr
, gcall
*);
2923 /* Build a call expression from the Gimple call statement and
2924 pass it to the K formatter that knows how to format it. */
2925 tree exp
= build_vl_exp (CALL_EXPR
, gimple_call_num_args (stmt
) + 3);
2926 CALL_EXPR_FN (exp
) = gimple_call_fn (stmt
);
2927 TREE_TYPE (exp
) = gimple_call_return_type (stmt
);
2928 CALL_EXPR_STATIC_CHAIN (exp
) = gimple_call_chain (stmt
);
2929 SET_EXPR_LOCATION (exp
, gimple_location (stmt
));
2931 percent_K_format (text
, exp
);