Introduce gimple_return
[official-gcc.git] / gcc / gimple-pretty-print.c
blobcfc111ce2cb7d3dc1cd37759fe87a085828c44d9
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2014 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
11 version.
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
16 for more details.
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/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "tree.h"
27 #include "stringpool.h"
28 #include "diagnostic.h"
29 #include "gimple-pretty-print.h"
30 #include "hashtab.h"
31 #include "bitmap.h"
32 #include "basic-block.h"
33 #include "tree-ssa-alias.h"
34 #include "internal-fn.h"
35 #include "tree-eh.h"
36 #include "gimple-expr.h"
37 #include "is-a.h"
38 #include "gimple.h"
39 #include "gimple-iterator.h"
40 #include "gimple-ssa.h"
41 #include "cgraph.h"
42 #include "tree-cfg.h"
43 #include "tree-ssanames.h"
44 #include "dumpfile.h" /* for dump_flags */
45 #include "value-prof.h"
46 #include "trans-mem.h"
48 #define INDENT(SPACE) \
49 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
51 #define GIMPLE_NIY do_niy (buffer,gs)
53 /* Try to print on BUFFER a default message for the unrecognized
54 gimple statement GS. */
56 static void
57 do_niy (pretty_printer *buffer, gimple gs)
59 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
60 gimple_code_name[(int) gimple_code (gs)]);
64 /* Emit a newline and SPC indentation spaces to BUFFER. */
66 static void
67 newline_and_indent (pretty_printer *buffer, int spc)
69 pp_newline (buffer);
70 INDENT (spc);
74 /* Print the GIMPLE statement GS on stderr. */
76 DEBUG_FUNCTION void
77 debug_gimple_stmt (gimple gs)
79 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
83 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
84 FLAGS as in pp_gimple_stmt_1. */
86 void
87 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
89 pretty_printer buffer;
90 pp_needs_newline (&buffer) = true;
91 buffer.buffer->stream = file;
92 pp_gimple_stmt_1 (&buffer, g, spc, flags);
93 pp_newline_and_flush (&buffer);
96 DEBUG_FUNCTION void
97 debug (gimple_statement_base &ref)
99 print_gimple_stmt (stderr, &ref, 0, 0);
102 DEBUG_FUNCTION void
103 debug (gimple_statement_base *ptr)
105 if (ptr)
106 debug (*ptr);
107 else
108 fprintf (stderr, "<nil>\n");
112 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
113 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
114 of the statement. */
116 void
117 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
119 flags |= TDF_RHS_ONLY;
120 pretty_printer buffer;
121 pp_needs_newline (&buffer) = true;
122 buffer.buffer->stream = file;
123 pp_gimple_stmt_1 (&buffer, g, spc, flags);
124 pp_flush (&buffer);
128 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
129 spaces and FLAGS as in pp_gimple_stmt_1.
130 The caller is responsible for calling pp_flush on BUFFER to finalize
131 the pretty printer. */
133 static void
134 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
136 gimple_stmt_iterator i;
138 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
140 gimple gs = gsi_stmt (i);
141 INDENT (spc);
142 pp_gimple_stmt_1 (buffer, gs, spc, flags);
143 if (!gsi_one_before_end_p (i))
144 pp_newline (buffer);
149 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
150 FLAGS as in pp_gimple_stmt_1. */
152 void
153 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
155 pretty_printer buffer;
156 pp_needs_newline (&buffer) = true;
157 buffer.buffer->stream = file;
158 dump_gimple_seq (&buffer, seq, spc, flags);
159 pp_newline_and_flush (&buffer);
163 /* Print the GIMPLE sequence SEQ on stderr. */
165 DEBUG_FUNCTION void
166 debug_gimple_seq (gimple_seq seq)
168 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
172 /* A simple helper to pretty-print some of the gimple tuples in the printf
173 style. The format modifiers are preceded by '%' and are:
174 'G' - outputs a string corresponding to the code of the given gimple,
175 'S' - outputs a gimple_seq with indent of spc + 2,
176 'T' - outputs the tree t,
177 'd' - outputs an int as a decimal,
178 's' - outputs a string,
179 'n' - outputs a newline,
180 'x' - outputs an int as hexadecimal,
181 '+' - increases indent by 2 then outputs a newline,
182 '-' - decreases indent by 2 then outputs a newline. */
184 static void
185 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
186 const char *fmt, ...)
188 va_list args;
189 const char *c;
190 const char *tmp;
192 va_start (args, fmt);
193 for (c = fmt; *c; c++)
195 if (*c == '%')
197 gimple_seq seq;
198 tree t;
199 gimple g;
200 switch (*++c)
202 case 'G':
203 g = va_arg (args, gimple);
204 tmp = gimple_code_name[gimple_code (g)];
205 pp_string (buffer, tmp);
206 break;
208 case 'S':
209 seq = va_arg (args, gimple_seq);
210 pp_newline (buffer);
211 dump_gimple_seq (buffer, seq, spc + 2, flags);
212 newline_and_indent (buffer, spc);
213 break;
215 case 'T':
216 t = va_arg (args, tree);
217 if (t == NULL_TREE)
218 pp_string (buffer, "NULL");
219 else
220 dump_generic_node (buffer, t, spc, flags, false);
221 break;
223 case 'd':
224 pp_decimal_int (buffer, va_arg (args, int));
225 break;
227 case 's':
228 pp_string (buffer, va_arg (args, char *));
229 break;
231 case 'n':
232 newline_and_indent (buffer, spc);
233 break;
235 case 'x':
236 pp_scalar (buffer, "%x", va_arg (args, int));
237 break;
239 case '+':
240 spc += 2;
241 newline_and_indent (buffer, spc);
242 break;
244 case '-':
245 spc -= 2;
246 newline_and_indent (buffer, spc);
247 break;
249 default:
250 gcc_unreachable ();
253 else
254 pp_character (buffer, *c);
256 va_end (args);
260 /* Helper for dump_gimple_assign. Print the unary RHS of the
261 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
263 static void
264 dump_unary_rhs (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
266 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
267 tree lhs = gimple_assign_lhs (gs);
268 tree rhs = gimple_assign_rhs1 (gs);
270 switch (rhs_code)
272 case VIEW_CONVERT_EXPR:
273 case ASSERT_EXPR:
274 dump_generic_node (buffer, rhs, spc, flags, false);
275 break;
277 case FIXED_CONVERT_EXPR:
278 case ADDR_SPACE_CONVERT_EXPR:
279 case FIX_TRUNC_EXPR:
280 case FLOAT_EXPR:
281 CASE_CONVERT:
282 pp_left_paren (buffer);
283 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
284 pp_string (buffer, ") ");
285 if (op_prio (rhs) < op_code_prio (rhs_code))
287 pp_left_paren (buffer);
288 dump_generic_node (buffer, rhs, spc, flags, false);
289 pp_right_paren (buffer);
291 else
292 dump_generic_node (buffer, rhs, spc, flags, false);
293 break;
295 case PAREN_EXPR:
296 pp_string (buffer, "((");
297 dump_generic_node (buffer, rhs, spc, flags, false);
298 pp_string (buffer, "))");
299 break;
301 case ABS_EXPR:
302 pp_string (buffer, "ABS_EXPR <");
303 dump_generic_node (buffer, rhs, spc, flags, false);
304 pp_greater (buffer);
305 break;
307 default:
308 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
309 || TREE_CODE_CLASS (rhs_code) == tcc_constant
310 || TREE_CODE_CLASS (rhs_code) == tcc_reference
311 || rhs_code == SSA_NAME
312 || rhs_code == ADDR_EXPR
313 || rhs_code == CONSTRUCTOR)
315 dump_generic_node (buffer, rhs, spc, flags, false);
316 break;
318 else if (rhs_code == BIT_NOT_EXPR)
319 pp_complement (buffer);
320 else if (rhs_code == TRUTH_NOT_EXPR)
321 pp_exclamation (buffer);
322 else if (rhs_code == NEGATE_EXPR)
323 pp_minus (buffer);
324 else
326 pp_left_bracket (buffer);
327 pp_string (buffer, get_tree_code_name (rhs_code));
328 pp_string (buffer, "] ");
331 if (op_prio (rhs) < op_code_prio (rhs_code))
333 pp_left_paren (buffer);
334 dump_generic_node (buffer, rhs, spc, flags, false);
335 pp_right_paren (buffer);
337 else
338 dump_generic_node (buffer, rhs, spc, flags, false);
339 break;
344 /* Helper for dump_gimple_assign. Print the binary RHS of the
345 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
347 static void
348 dump_binary_rhs (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
350 const char *p;
351 enum tree_code code = gimple_assign_rhs_code (gs);
352 switch (code)
354 case COMPLEX_EXPR:
355 case MIN_EXPR:
356 case MAX_EXPR:
357 case VEC_WIDEN_MULT_HI_EXPR:
358 case VEC_WIDEN_MULT_LO_EXPR:
359 case VEC_WIDEN_MULT_EVEN_EXPR:
360 case VEC_WIDEN_MULT_ODD_EXPR:
361 case VEC_PACK_TRUNC_EXPR:
362 case VEC_PACK_SAT_EXPR:
363 case VEC_PACK_FIX_TRUNC_EXPR:
364 case VEC_WIDEN_LSHIFT_HI_EXPR:
365 case VEC_WIDEN_LSHIFT_LO_EXPR:
366 for (p = get_tree_code_name (code); *p; p++)
367 pp_character (buffer, TOUPPER (*p));
368 pp_string (buffer, " <");
369 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
370 pp_string (buffer, ", ");
371 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
372 pp_greater (buffer);
373 break;
375 default:
376 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
378 pp_left_paren (buffer);
379 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
380 false);
381 pp_right_paren (buffer);
383 else
384 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
385 pp_space (buffer);
386 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
387 pp_space (buffer);
388 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
390 pp_left_paren (buffer);
391 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
392 false);
393 pp_right_paren (buffer);
395 else
396 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
400 /* Helper for dump_gimple_assign. Print the ternary RHS of the
401 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
403 static void
404 dump_ternary_rhs (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
406 const char *p;
407 enum tree_code code = gimple_assign_rhs_code (gs);
408 switch (code)
410 case WIDEN_MULT_PLUS_EXPR:
411 case WIDEN_MULT_MINUS_EXPR:
412 for (p = get_tree_code_name (code); *p; p++)
413 pp_character (buffer, TOUPPER (*p));
414 pp_string (buffer, " <");
415 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
416 pp_string (buffer, ", ");
417 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
418 pp_string (buffer, ", ");
419 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
420 pp_greater (buffer);
421 break;
423 case FMA_EXPR:
424 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
425 pp_string (buffer, " * ");
426 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
427 pp_string (buffer, " + ");
428 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
429 break;
431 case DOT_PROD_EXPR:
432 pp_string (buffer, "DOT_PROD_EXPR <");
433 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
434 pp_string (buffer, ", ");
435 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
436 pp_string (buffer, ", ");
437 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
438 pp_greater (buffer);
439 break;
441 case SAD_EXPR:
442 pp_string (buffer, "SAD_EXPR <");
443 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
444 pp_string (buffer, ", ");
445 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
446 pp_string (buffer, ", ");
447 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
448 pp_greater (buffer);
449 break;
451 case VEC_PERM_EXPR:
452 pp_string (buffer, "VEC_PERM_EXPR <");
453 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
454 pp_string (buffer, ", ");
455 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
456 pp_string (buffer, ", ");
457 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
458 pp_greater (buffer);
459 break;
461 case REALIGN_LOAD_EXPR:
462 pp_string (buffer, "REALIGN_LOAD <");
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);
468 pp_greater (buffer);
469 break;
471 case COND_EXPR:
472 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
473 pp_string (buffer, " ? ");
474 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
475 pp_string (buffer, " : ");
476 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
477 break;
479 case VEC_COND_EXPR:
480 pp_string (buffer, "VEC_COND_EXPR <");
481 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
482 pp_string (buffer, ", ");
483 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
484 pp_string (buffer, ", ");
485 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
486 pp_greater (buffer);
487 break;
489 default:
490 gcc_unreachable ();
495 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
496 pp_gimple_stmt_1. */
498 static void
499 dump_gimple_assign (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
501 if (flags & TDF_RAW)
503 tree arg1 = NULL;
504 tree arg2 = NULL;
505 tree arg3 = NULL;
506 switch (gimple_num_ops (gs))
508 case 4:
509 arg3 = gimple_assign_rhs3 (gs);
510 case 3:
511 arg2 = gimple_assign_rhs2 (gs);
512 case 2:
513 arg1 = gimple_assign_rhs1 (gs);
514 break;
515 default:
516 gcc_unreachable ();
519 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
520 get_tree_code_name (gimple_assign_rhs_code (gs)),
521 gimple_assign_lhs (gs), arg1, arg2, arg3);
523 else
525 if (!(flags & TDF_RHS_ONLY))
527 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
528 pp_space (buffer);
529 pp_equal (buffer);
531 if (gimple_assign_nontemporal_move_p (gs))
532 pp_string (buffer, "{nt}");
534 if (gimple_has_volatile_ops (gs))
535 pp_string (buffer, "{v}");
537 pp_space (buffer);
540 if (gimple_num_ops (gs) == 2)
541 dump_unary_rhs (buffer, gs, spc, flags);
542 else if (gimple_num_ops (gs) == 3)
543 dump_binary_rhs (buffer, gs, spc, flags);
544 else if (gimple_num_ops (gs) == 4)
545 dump_ternary_rhs (buffer, gs, spc, flags);
546 else
547 gcc_unreachable ();
548 if (!(flags & TDF_RHS_ONLY))
549 pp_semicolon (buffer);
554 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
555 pp_gimple_stmt_1. */
557 static void
558 dump_gimple_return (pretty_printer *buffer, gimple_return gs, int spc, int flags)
560 tree t;
562 t = gimple_return_retval (gs);
563 if (flags & TDF_RAW)
564 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
565 else
567 pp_string (buffer, "return");
568 if (t)
570 pp_space (buffer);
571 dump_generic_node (buffer, t, spc, flags, false);
573 pp_semicolon (buffer);
578 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
579 dump_gimple_call. */
581 static void
582 dump_gimple_call_args (pretty_printer *buffer, gimple_call gs, int flags)
584 size_t i;
586 for (i = 0; i < gimple_call_num_args (gs); i++)
588 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
589 if (i < gimple_call_num_args (gs) - 1)
590 pp_string (buffer, ", ");
593 if (gimple_call_va_arg_pack_p (gs))
595 if (gimple_call_num_args (gs) > 0)
597 pp_comma (buffer);
598 pp_space (buffer);
601 pp_string (buffer, "__builtin_va_arg_pack ()");
605 /* Dump the points-to solution *PT to BUFFER. */
607 static void
608 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
610 if (pt->anything)
612 pp_string (buffer, "anything ");
613 return;
615 if (pt->nonlocal)
616 pp_string (buffer, "nonlocal ");
617 if (pt->escaped)
618 pp_string (buffer, "escaped ");
619 if (pt->ipa_escaped)
620 pp_string (buffer, "unit-escaped ");
621 if (pt->null)
622 pp_string (buffer, "null ");
623 if (pt->vars
624 && !bitmap_empty_p (pt->vars))
626 bitmap_iterator bi;
627 unsigned i;
628 pp_string (buffer, "{ ");
629 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
631 pp_string (buffer, "D.");
632 pp_decimal_int (buffer, i);
633 pp_space (buffer);
635 pp_right_brace (buffer);
636 if (pt->vars_contains_nonlocal
637 && pt->vars_contains_escaped_heap)
638 pp_string (buffer, " (nonlocal, escaped heap)");
639 else if (pt->vars_contains_nonlocal
640 && pt->vars_contains_escaped)
641 pp_string (buffer, " (nonlocal, escaped)");
642 else if (pt->vars_contains_nonlocal)
643 pp_string (buffer, " (nonlocal)");
644 else if (pt->vars_contains_escaped_heap)
645 pp_string (buffer, " (escaped heap)");
646 else if (pt->vars_contains_escaped)
647 pp_string (buffer, " (escaped)");
651 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
652 pp_gimple_stmt_1. */
654 static void
655 dump_gimple_call (pretty_printer *buffer, gimple_call gs, int spc, int flags)
657 tree lhs = gimple_call_lhs (gs);
658 tree fn = gimple_call_fn (gs);
660 if (flags & TDF_ALIAS)
662 struct pt_solution *pt;
663 pt = gimple_call_use_set (gs);
664 if (!pt_solution_empty_p (pt))
666 pp_string (buffer, "# USE = ");
667 pp_points_to_solution (buffer, pt);
668 newline_and_indent (buffer, spc);
670 pt = gimple_call_clobber_set (gs);
671 if (!pt_solution_empty_p (pt))
673 pp_string (buffer, "# CLB = ");
674 pp_points_to_solution (buffer, pt);
675 newline_and_indent (buffer, spc);
679 if (flags & TDF_RAW)
681 if (gimple_call_internal_p (gs))
682 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
683 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
684 else
685 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
686 if (gimple_call_num_args (gs) > 0)
688 pp_string (buffer, ", ");
689 dump_gimple_call_args (buffer, gs, flags);
691 pp_greater (buffer);
693 else
695 if (lhs && !(flags & TDF_RHS_ONLY))
697 dump_generic_node (buffer, lhs, spc, flags, false);
698 pp_string (buffer, " =");
700 if (gimple_has_volatile_ops (gs))
701 pp_string (buffer, "{v}");
703 pp_space (buffer);
705 if (gimple_call_internal_p (gs))
706 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
707 else
708 print_call_name (buffer, fn, flags);
709 pp_string (buffer, " (");
710 dump_gimple_call_args (buffer, gs, flags);
711 pp_right_paren (buffer);
712 if (!(flags & TDF_RHS_ONLY))
713 pp_semicolon (buffer);
716 if (gimple_call_chain (gs))
718 pp_string (buffer, " [static-chain: ");
719 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
720 pp_right_bracket (buffer);
723 if (gimple_call_return_slot_opt_p (gs))
724 pp_string (buffer, " [return slot optimization]");
725 if (gimple_call_tail_p (gs))
726 pp_string (buffer, " [tail call]");
728 if (fn == NULL)
729 return;
731 /* Dump the arguments of _ITM_beginTransaction sanely. */
732 if (TREE_CODE (fn) == ADDR_EXPR)
733 fn = TREE_OPERAND (fn, 0);
734 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
735 pp_string (buffer, " [tm-clone]");
736 if (TREE_CODE (fn) == FUNCTION_DECL
737 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
738 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
739 && gimple_call_num_args (gs) > 0)
741 tree t = gimple_call_arg (gs, 0);
742 unsigned HOST_WIDE_INT props;
743 gcc_assert (TREE_CODE (t) == INTEGER_CST);
745 pp_string (buffer, " [ ");
747 /* Get the transaction code properties. */
748 props = TREE_INT_CST_LOW (t);
750 if (props & PR_INSTRUMENTEDCODE)
751 pp_string (buffer, "instrumentedCode ");
752 if (props & PR_UNINSTRUMENTEDCODE)
753 pp_string (buffer, "uninstrumentedCode ");
754 if (props & PR_HASNOXMMUPDATE)
755 pp_string (buffer, "hasNoXMMUpdate ");
756 if (props & PR_HASNOABORT)
757 pp_string (buffer, "hasNoAbort ");
758 if (props & PR_HASNOIRREVOCABLE)
759 pp_string (buffer, "hasNoIrrevocable ");
760 if (props & PR_DOESGOIRREVOCABLE)
761 pp_string (buffer, "doesGoIrrevocable ");
762 if (props & PR_HASNOSIMPLEREADS)
763 pp_string (buffer, "hasNoSimpleReads ");
764 if (props & PR_AWBARRIERSOMITTED)
765 pp_string (buffer, "awBarriersOmitted ");
766 if (props & PR_RARBARRIERSOMITTED)
767 pp_string (buffer, "RaRBarriersOmitted ");
768 if (props & PR_UNDOLOGCODE)
769 pp_string (buffer, "undoLogCode ");
770 if (props & PR_PREFERUNINSTRUMENTED)
771 pp_string (buffer, "preferUninstrumented ");
772 if (props & PR_EXCEPTIONBLOCK)
773 pp_string (buffer, "exceptionBlock ");
774 if (props & PR_HASELSE)
775 pp_string (buffer, "hasElse ");
776 if (props & PR_READONLY)
777 pp_string (buffer, "readOnly ");
779 pp_right_bracket (buffer);
784 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
785 pp_gimple_stmt_1. */
787 static void
788 dump_gimple_switch (pretty_printer *buffer, gimple_switch gs, int spc,
789 int flags)
791 unsigned int i;
793 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
794 if (flags & TDF_RAW)
795 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
796 gimple_switch_index (gs));
797 else
799 pp_string (buffer, "switch (");
800 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
801 pp_string (buffer, ") <");
804 for (i = 0; i < gimple_switch_num_labels (gs); i++)
806 tree case_label = gimple_switch_label (gs, i);
807 gcc_checking_assert (case_label != NULL_TREE);
808 dump_generic_node (buffer, case_label, spc, flags, false);
809 pp_space (buffer);
810 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
811 if (i < gimple_switch_num_labels (gs) - 1)
812 pp_string (buffer, ", ");
814 pp_greater (buffer);
818 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
819 pp_gimple_stmt_1. */
821 static void
822 dump_gimple_cond (pretty_printer *buffer, gimple_cond gs, int spc, int flags)
824 if (flags & TDF_RAW)
825 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
826 get_tree_code_name (gimple_cond_code (gs)),
827 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
828 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
829 else
831 if (!(flags & TDF_RHS_ONLY))
832 pp_string (buffer, "if (");
833 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
834 pp_space (buffer);
835 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
836 pp_space (buffer);
837 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
838 if (!(flags & TDF_RHS_ONLY))
840 pp_right_paren (buffer);
842 if (gimple_cond_true_label (gs))
844 pp_string (buffer, " goto ");
845 dump_generic_node (buffer, gimple_cond_true_label (gs),
846 spc, flags, false);
847 pp_semicolon (buffer);
849 if (gimple_cond_false_label (gs))
851 pp_string (buffer, " else goto ");
852 dump_generic_node (buffer, gimple_cond_false_label (gs),
853 spc, flags, false);
854 pp_semicolon (buffer);
861 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
862 spaces of indent. FLAGS specifies details to show in the dump (see
863 TDF_* in dumpfils.h). */
865 static void
866 dump_gimple_label (pretty_printer *buffer, gimple_label gs, int spc, int flags)
868 tree label = gimple_label_label (gs);
869 if (flags & TDF_RAW)
870 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
871 else
873 dump_generic_node (buffer, label, spc, flags, false);
874 pp_colon (buffer);
876 if (DECL_NONLOCAL (label))
877 pp_string (buffer, " [non-local]");
878 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
879 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
882 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
883 spaces of indent. FLAGS specifies details to show in the dump (see
884 TDF_* in dumpfile.h). */
886 static void
887 dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
889 tree label = gimple_goto_dest (gs);
890 if (flags & TDF_RAW)
891 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
892 else
893 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
897 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
898 spaces of indent. FLAGS specifies details to show in the dump (see
899 TDF_* in dumpfile.h). */
901 static void
902 dump_gimple_bind (pretty_printer *buffer, gimple_bind gs, int spc, int flags)
904 if (flags & TDF_RAW)
905 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
906 else
907 pp_left_brace (buffer);
908 if (!(flags & TDF_SLIM))
910 tree var;
912 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
914 newline_and_indent (buffer, 2);
915 print_declaration (buffer, var, spc, flags);
917 if (gimple_bind_vars (gs))
918 pp_newline (buffer);
920 pp_newline (buffer);
921 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
922 newline_and_indent (buffer, spc);
923 if (flags & TDF_RAW)
924 pp_greater (buffer);
925 else
926 pp_right_brace (buffer);
930 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
931 indent. FLAGS specifies details to show in the dump (see TDF_* in
932 dumpfile.h). */
934 static void
935 dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
937 if (flags & TDF_RAW)
939 const char *type;
940 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
941 type = "GIMPLE_TRY_CATCH";
942 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
943 type = "GIMPLE_TRY_FINALLY";
944 else
945 type = "UNKNOWN GIMPLE_TRY";
946 dump_gimple_fmt (buffer, spc, flags,
947 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
948 gimple_try_eval (gs), gimple_try_cleanup (gs));
950 else
952 pp_string (buffer, "try");
953 newline_and_indent (buffer, spc + 2);
954 pp_left_brace (buffer);
955 pp_newline (buffer);
957 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
958 newline_and_indent (buffer, spc + 2);
959 pp_right_brace (buffer);
961 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
963 newline_and_indent (buffer, spc);
964 pp_string (buffer, "catch");
965 newline_and_indent (buffer, spc + 2);
966 pp_left_brace (buffer);
968 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
970 newline_and_indent (buffer, spc);
971 pp_string (buffer, "finally");
972 newline_and_indent (buffer, spc + 2);
973 pp_left_brace (buffer);
975 else
976 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
978 pp_newline (buffer);
979 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
980 newline_and_indent (buffer, spc + 2);
981 pp_right_brace (buffer);
986 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
987 indent. FLAGS specifies details to show in the dump (see TDF_* in
988 dumpfile.h). */
990 static void
991 dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
993 if (flags & TDF_RAW)
994 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
995 gimple_catch_types (gs), gimple_catch_handler (gs));
996 else
997 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
998 gimple_catch_types (gs), gimple_catch_handler (gs));
1002 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1003 indent. FLAGS specifies details to show in the dump (see TDF_* in
1004 dumpfile.h). */
1006 static void
1007 dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
1009 if (flags & TDF_RAW)
1010 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1011 gimple_eh_filter_types (gs),
1012 gimple_eh_filter_failure (gs));
1013 else
1014 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1015 gimple_eh_filter_types (gs),
1016 gimple_eh_filter_failure (gs));
1020 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1022 static void
1023 dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
1024 int spc, int flags)
1026 if (flags & TDF_RAW)
1027 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1028 gimple_eh_must_not_throw_fndecl (gs));
1029 else
1030 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1031 gimple_eh_must_not_throw_fndecl (gs));
1035 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1036 indent. FLAGS specifies details to show in the dump (see TDF_* in
1037 dumpfile.h). */
1039 static void
1040 dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags)
1042 if (flags & TDF_RAW)
1043 dump_gimple_fmt (buffer, spc, flags,
1044 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1045 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1046 else
1047 dump_gimple_fmt (buffer, spc, flags,
1048 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1049 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1053 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1054 indent. FLAGS specifies details to show in the dump (see TDF_* in
1055 dumpfile.h). */
1057 static void
1058 dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
1060 if (flags & TDF_RAW)
1061 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1062 gimple_resx_region (gs));
1063 else
1064 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1067 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1069 static void
1070 dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
1072 if (flags & TDF_RAW)
1073 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1074 gimple_eh_dispatch_region (gs));
1075 else
1076 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1077 gimple_eh_dispatch_region (gs));
1080 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1081 of indent. FLAGS specifies details to show in the dump (see TDF_*
1082 in dumpfile.h). */
1084 static void
1085 dump_gimple_debug (pretty_printer *buffer, gimple_debug gs, int spc, int flags)
1087 switch (gs->subcode)
1089 case GIMPLE_DEBUG_BIND:
1090 if (flags & TDF_RAW)
1091 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1092 gimple_debug_bind_get_var (gs),
1093 gimple_debug_bind_get_value (gs));
1094 else
1095 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1096 gimple_debug_bind_get_var (gs),
1097 gimple_debug_bind_get_value (gs));
1098 break;
1100 case GIMPLE_DEBUG_SOURCE_BIND:
1101 if (flags & TDF_RAW)
1102 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1103 gimple_debug_source_bind_get_var (gs),
1104 gimple_debug_source_bind_get_value (gs));
1105 else
1106 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1107 gimple_debug_source_bind_get_var (gs),
1108 gimple_debug_source_bind_get_value (gs));
1109 break;
1111 default:
1112 gcc_unreachable ();
1116 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1117 static void
1118 dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
1120 size_t i;
1122 if (flags & TDF_RAW)
1124 const char *kind;
1125 switch (gimple_omp_for_kind (gs))
1127 case GF_OMP_FOR_KIND_FOR:
1128 kind = "";
1129 break;
1130 case GF_OMP_FOR_KIND_SIMD:
1131 kind = " simd";
1132 break;
1133 case GF_OMP_FOR_KIND_CILKSIMD:
1134 kind = " cilksimd";
1135 break;
1136 case GF_OMP_FOR_KIND_DISTRIBUTE:
1137 kind = " distribute";
1138 break;
1139 case GF_OMP_FOR_KIND_CILKFOR:
1140 kind = " _Cilk_for";
1141 break;
1142 default:
1143 gcc_unreachable ();
1145 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1146 kind, gimple_omp_body (gs));
1147 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1148 dump_gimple_fmt (buffer, spc, flags, " >,");
1149 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1150 dump_gimple_fmt (buffer, spc, flags,
1151 "%+%T, %T, %T, %s, %T,%n",
1152 gimple_omp_for_index (gs, i),
1153 gimple_omp_for_initial (gs, i),
1154 gimple_omp_for_final (gs, i),
1155 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1156 gimple_omp_for_incr (gs, i));
1157 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1158 gimple_omp_for_pre_body (gs));
1160 else
1162 switch (gimple_omp_for_kind (gs))
1164 case GF_OMP_FOR_KIND_FOR:
1165 pp_string (buffer, "#pragma omp for");
1166 break;
1167 case GF_OMP_FOR_KIND_SIMD:
1168 pp_string (buffer, "#pragma omp simd");
1169 break;
1170 case GF_OMP_FOR_KIND_CILKSIMD:
1171 pp_string (buffer, "#pragma simd");
1172 break;
1173 case GF_OMP_FOR_KIND_DISTRIBUTE:
1174 pp_string (buffer, "#pragma omp distribute");
1175 break;
1176 case GF_OMP_FOR_KIND_CILKFOR:
1177 break;
1178 default:
1179 gcc_unreachable ();
1181 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1182 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1183 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1185 if (i)
1186 spc += 2;
1187 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1188 pp_string (buffer, "_Cilk_for (");
1189 else
1191 newline_and_indent (buffer, spc);
1192 pp_string (buffer, "for (");
1194 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1195 flags, false);
1196 pp_string (buffer, " = ");
1197 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1198 flags, false);
1199 pp_string (buffer, "; ");
1201 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1202 flags, false);
1203 pp_space (buffer);
1204 switch (gimple_omp_for_cond (gs, i))
1206 case LT_EXPR:
1207 pp_less (buffer);
1208 break;
1209 case GT_EXPR:
1210 pp_greater (buffer);
1211 break;
1212 case LE_EXPR:
1213 pp_less_equal (buffer);
1214 break;
1215 case GE_EXPR:
1216 pp_greater_equal (buffer);
1217 break;
1218 case NE_EXPR:
1219 pp_string (buffer, "!=");
1220 break;
1221 default:
1222 gcc_unreachable ();
1224 pp_space (buffer);
1225 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1226 flags, false);
1227 pp_string (buffer, "; ");
1229 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1230 flags, false);
1231 pp_string (buffer, " = ");
1232 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1233 flags, false);
1234 pp_right_paren (buffer);
1237 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1239 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1240 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1241 newline_and_indent (buffer, spc + 2);
1242 pp_left_brace (buffer);
1243 pp_newline (buffer);
1244 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1245 newline_and_indent (buffer, spc + 2);
1246 pp_right_brace (buffer);
1251 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1253 static void
1254 dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags)
1256 if (flags & TDF_RAW)
1258 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1259 gimple_omp_continue_control_def (gs),
1260 gimple_omp_continue_control_use (gs));
1262 else
1264 pp_string (buffer, "#pragma omp continue (");
1265 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1266 spc, flags, false);
1267 pp_comma (buffer);
1268 pp_space (buffer);
1269 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1270 spc, flags, false);
1271 pp_right_paren (buffer);
1275 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1277 static void
1278 dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, int flags)
1280 if (flags & TDF_RAW)
1282 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1283 gimple_omp_body (gs));
1284 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1285 dump_gimple_fmt (buffer, spc, flags, " >");
1287 else
1289 pp_string (buffer, "#pragma omp single");
1290 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1291 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1293 newline_and_indent (buffer, spc + 2);
1294 pp_left_brace (buffer);
1295 pp_newline (buffer);
1296 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1297 newline_and_indent (buffer, spc + 2);
1298 pp_right_brace (buffer);
1303 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1305 static void
1306 dump_gimple_omp_target (pretty_printer *buffer, gimple gs, int spc, int flags)
1308 const char *kind;
1309 switch (gimple_omp_target_kind (gs))
1311 case GF_OMP_TARGET_KIND_REGION:
1312 kind = "";
1313 break;
1314 case GF_OMP_TARGET_KIND_DATA:
1315 kind = " data";
1316 break;
1317 case GF_OMP_TARGET_KIND_UPDATE:
1318 kind = " update";
1319 break;
1320 default:
1321 gcc_unreachable ();
1323 if (flags & TDF_RAW)
1325 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1326 kind, gimple_omp_body (gs));
1327 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1328 dump_gimple_fmt (buffer, spc, flags, " >");
1330 else
1332 pp_string (buffer, "#pragma omp target");
1333 pp_string (buffer, kind);
1334 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1335 if (gimple_omp_target_child_fn (gs))
1337 pp_string (buffer, " [child fn: ");
1338 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1339 spc, flags, false);
1340 pp_right_bracket (buffer);
1342 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1344 newline_and_indent (buffer, spc + 2);
1345 pp_character (buffer, '{');
1346 pp_newline (buffer);
1347 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1348 newline_and_indent (buffer, spc + 2);
1349 pp_character (buffer, '}');
1354 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1356 static void
1357 dump_gimple_omp_teams (pretty_printer *buffer, gimple gs, int spc, int flags)
1359 if (flags & TDF_RAW)
1361 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1362 gimple_omp_body (gs));
1363 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1364 dump_gimple_fmt (buffer, spc, flags, " >");
1366 else
1368 pp_string (buffer, "#pragma omp teams");
1369 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1370 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1372 newline_and_indent (buffer, spc + 2);
1373 pp_character (buffer, '{');
1374 pp_newline (buffer);
1375 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1376 newline_and_indent (buffer, spc + 2);
1377 pp_character (buffer, '}');
1382 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1384 static void
1385 dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
1386 int flags)
1388 if (flags & TDF_RAW)
1390 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1391 gimple_omp_body (gs));
1392 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1393 dump_gimple_fmt (buffer, spc, flags, " >");
1395 else
1397 pp_string (buffer, "#pragma omp sections");
1398 if (gimple_omp_sections_control (gs))
1400 pp_string (buffer, " <");
1401 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1402 flags, false);
1403 pp_greater (buffer);
1405 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1406 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1408 newline_and_indent (buffer, spc + 2);
1409 pp_left_brace (buffer);
1410 pp_newline (buffer);
1411 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1412 newline_and_indent (buffer, spc + 2);
1413 pp_right_brace (buffer);
1418 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1419 pretty_printer BUFFER. */
1421 static void
1422 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1424 if (flags & TDF_RAW)
1425 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1426 gimple_omp_body (gs));
1427 else
1429 switch (gimple_code (gs))
1431 case GIMPLE_OMP_MASTER:
1432 pp_string (buffer, "#pragma omp master");
1433 break;
1434 case GIMPLE_OMP_TASKGROUP:
1435 pp_string (buffer, "#pragma omp taskgroup");
1436 break;
1437 case GIMPLE_OMP_ORDERED:
1438 pp_string (buffer, "#pragma omp ordered");
1439 break;
1440 case GIMPLE_OMP_SECTION:
1441 pp_string (buffer, "#pragma omp section");
1442 break;
1443 default:
1444 gcc_unreachable ();
1446 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1448 newline_and_indent (buffer, spc + 2);
1449 pp_left_brace (buffer);
1450 pp_newline (buffer);
1451 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1452 newline_and_indent (buffer, spc + 2);
1453 pp_right_brace (buffer);
1458 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1460 static void
1461 dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
1462 int flags)
1464 if (flags & TDF_RAW)
1465 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1466 gimple_omp_body (gs));
1467 else
1469 pp_string (buffer, "#pragma omp critical");
1470 if (gimple_omp_critical_name (gs))
1472 pp_string (buffer, " (");
1473 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1474 flags, false);
1475 pp_right_paren (buffer);
1477 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1479 newline_and_indent (buffer, spc + 2);
1480 pp_left_brace (buffer);
1481 pp_newline (buffer);
1482 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1483 newline_and_indent (buffer, spc + 2);
1484 pp_right_brace (buffer);
1489 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1491 static void
1492 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1494 if (flags & TDF_RAW)
1496 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1497 (int) gimple_omp_return_nowait_p (gs));
1498 if (gimple_omp_return_lhs (gs))
1499 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1500 gimple_omp_return_lhs (gs));
1501 else
1502 dump_gimple_fmt (buffer, spc, flags, ">");
1504 else
1506 pp_string (buffer, "#pragma omp return");
1507 if (gimple_omp_return_nowait_p (gs))
1508 pp_string (buffer, "(nowait)");
1509 if (gimple_omp_return_lhs (gs))
1511 pp_string (buffer, " (set ");
1512 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1513 spc, flags, false);
1514 pp_character (buffer, ')');
1519 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1521 static void
1522 dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags)
1524 unsigned subcode = gimple_transaction_subcode (gs);
1526 if (flags & TDF_RAW)
1528 dump_gimple_fmt (buffer, spc, flags,
1529 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1530 gs, subcode, gimple_transaction_label (gs),
1531 gimple_transaction_body (gs));
1533 else
1535 if (subcode & GTMA_IS_OUTER)
1536 pp_string (buffer, "__transaction_atomic [[outer]]");
1537 else if (subcode & GTMA_IS_RELAXED)
1538 pp_string (buffer, "__transaction_relaxed");
1539 else
1540 pp_string (buffer, "__transaction_atomic");
1541 subcode &= ~GTMA_DECLARATION_MASK;
1543 if (subcode || gimple_transaction_label (gs))
1545 pp_string (buffer, " //");
1546 if (gimple_transaction_label (gs))
1548 pp_string (buffer, " LABEL=");
1549 dump_generic_node (buffer, gimple_transaction_label (gs),
1550 spc, flags, false);
1552 if (subcode)
1554 pp_string (buffer, " SUBCODE=[ ");
1555 if (subcode & GTMA_HAVE_ABORT)
1557 pp_string (buffer, "GTMA_HAVE_ABORT ");
1558 subcode &= ~GTMA_HAVE_ABORT;
1560 if (subcode & GTMA_HAVE_LOAD)
1562 pp_string (buffer, "GTMA_HAVE_LOAD ");
1563 subcode &= ~GTMA_HAVE_LOAD;
1565 if (subcode & GTMA_HAVE_STORE)
1567 pp_string (buffer, "GTMA_HAVE_STORE ");
1568 subcode &= ~GTMA_HAVE_STORE;
1570 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1572 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1573 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1575 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1577 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1578 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1580 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1582 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1583 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1585 if (subcode)
1586 pp_printf (buffer, "0x%x ", subcode);
1587 pp_right_bracket (buffer);
1591 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1593 newline_and_indent (buffer, spc + 2);
1594 pp_left_brace (buffer);
1595 pp_newline (buffer);
1596 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1597 spc + 4, flags);
1598 newline_and_indent (buffer, spc + 2);
1599 pp_right_brace (buffer);
1604 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1605 indent. FLAGS specifies details to show in the dump (see TDF_* in
1606 dumpfile.h). */
1608 static void
1609 dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
1611 unsigned int i, n, f, fields;
1613 if (flags & TDF_RAW)
1615 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1616 gimple_asm_string (gs));
1618 n = gimple_asm_noutputs (gs);
1619 if (n)
1621 newline_and_indent (buffer, spc + 2);
1622 pp_string (buffer, "OUTPUT: ");
1623 for (i = 0; i < n; i++)
1625 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1626 spc, flags, false);
1627 if (i < n - 1)
1628 pp_string (buffer, ", ");
1632 n = gimple_asm_ninputs (gs);
1633 if (n)
1635 newline_and_indent (buffer, spc + 2);
1636 pp_string (buffer, "INPUT: ");
1637 for (i = 0; i < n; i++)
1639 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1640 spc, flags, false);
1641 if (i < n - 1)
1642 pp_string (buffer, ", ");
1646 n = gimple_asm_nclobbers (gs);
1647 if (n)
1649 newline_and_indent (buffer, spc + 2);
1650 pp_string (buffer, "CLOBBER: ");
1651 for (i = 0; i < n; i++)
1653 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1654 spc, flags, false);
1655 if (i < n - 1)
1656 pp_string (buffer, ", ");
1660 n = gimple_asm_nlabels (gs);
1661 if (n)
1663 newline_and_indent (buffer, spc + 2);
1664 pp_string (buffer, "LABEL: ");
1665 for (i = 0; i < n; i++)
1667 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1668 spc, flags, false);
1669 if (i < n - 1)
1670 pp_string (buffer, ", ");
1674 newline_and_indent (buffer, spc);
1675 pp_greater (buffer);
1677 else
1679 pp_string (buffer, "__asm__");
1680 if (gimple_asm_volatile_p (gs))
1681 pp_string (buffer, " __volatile__");
1682 if (gimple_asm_nlabels (gs))
1683 pp_string (buffer, " goto");
1684 pp_string (buffer, "(\"");
1685 pp_string (buffer, gimple_asm_string (gs));
1686 pp_string (buffer, "\"");
1688 if (gimple_asm_nlabels (gs))
1689 fields = 4;
1690 else if (gimple_asm_nclobbers (gs))
1691 fields = 3;
1692 else if (gimple_asm_ninputs (gs))
1693 fields = 2;
1694 else if (gimple_asm_noutputs (gs))
1695 fields = 1;
1696 else
1697 fields = 0;
1699 for (f = 0; f < fields; ++f)
1701 pp_string (buffer, " : ");
1703 switch (f)
1705 case 0:
1706 n = gimple_asm_noutputs (gs);
1707 for (i = 0; i < n; i++)
1709 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1710 spc, flags, false);
1711 if (i < n - 1)
1712 pp_string (buffer, ", ");
1714 break;
1716 case 1:
1717 n = gimple_asm_ninputs (gs);
1718 for (i = 0; i < n; i++)
1720 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1721 spc, flags, false);
1722 if (i < n - 1)
1723 pp_string (buffer, ", ");
1725 break;
1727 case 2:
1728 n = gimple_asm_nclobbers (gs);
1729 for (i = 0; i < n; i++)
1731 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1732 spc, flags, false);
1733 if (i < n - 1)
1734 pp_string (buffer, ", ");
1736 break;
1738 case 3:
1739 n = gimple_asm_nlabels (gs);
1740 for (i = 0; i < n; i++)
1742 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1743 spc, flags, false);
1744 if (i < n - 1)
1745 pp_string (buffer, ", ");
1747 break;
1749 default:
1750 gcc_unreachable ();
1754 pp_string (buffer, ");");
1758 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1759 SPC spaces of indent. */
1761 static void
1762 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1764 if (TREE_CODE (node) != SSA_NAME)
1765 return;
1767 if (POINTER_TYPE_P (TREE_TYPE (node))
1768 && SSA_NAME_PTR_INFO (node))
1770 unsigned int align, misalign;
1771 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1772 pp_string (buffer, "# PT = ");
1773 pp_points_to_solution (buffer, &pi->pt);
1774 newline_and_indent (buffer, spc);
1775 if (get_ptr_info_alignment (pi, &align, &misalign))
1777 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1778 newline_and_indent (buffer, spc);
1782 if (!POINTER_TYPE_P (TREE_TYPE (node))
1783 && SSA_NAME_RANGE_INFO (node))
1785 wide_int min, max, nonzero_bits;
1786 value_range_type range_type = get_range_info (node, &min, &max);
1788 if (range_type == VR_VARYING)
1789 pp_printf (buffer, "# RANGE VR_VARYING");
1790 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1792 pp_printf (buffer, "# RANGE ");
1793 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1794 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
1795 pp_printf (buffer, ", ");
1796 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
1797 pp_printf (buffer, "]");
1799 nonzero_bits = get_nonzero_bits (node);
1800 if (nonzero_bits != -1)
1802 pp_string (buffer, " NONZERO ");
1803 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
1805 newline_and_indent (buffer, spc);
1810 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1811 The caller is responsible for calling pp_flush on BUFFER to finalize
1812 pretty printer. If COMMENT is true, print this after #. */
1814 static void
1815 dump_gimple_phi (pretty_printer *buffer, gimple_phi phi, int spc, bool comment,
1816 int flags)
1818 size_t i;
1819 tree lhs = gimple_phi_result (phi);
1821 if (flags & TDF_ALIAS)
1822 dump_ssaname_info (buffer, lhs, spc);
1824 if (comment)
1825 pp_string (buffer, "# ");
1827 if (flags & TDF_RAW)
1828 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1829 gimple_phi_result (phi));
1830 else
1832 dump_generic_node (buffer, lhs, spc, flags, false);
1833 pp_string (buffer, " = PHI <");
1835 for (i = 0; i < gimple_phi_num_args (phi); i++)
1837 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1838 dump_location (buffer, gimple_phi_arg_location (phi, i));
1839 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1840 false);
1841 pp_left_paren (buffer);
1842 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1843 pp_right_paren (buffer);
1844 if (i < gimple_phi_num_args (phi) - 1)
1845 pp_string (buffer, ", ");
1847 pp_greater (buffer);
1851 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1852 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1853 dumpfile.h). */
1855 static void
1856 dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1857 int flags)
1859 if (flags & TDF_RAW)
1861 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1862 gimple_omp_body (gs));
1863 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1864 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1865 gimple_omp_parallel_child_fn (gs),
1866 gimple_omp_parallel_data_arg (gs));
1868 else
1870 gimple_seq body;
1871 pp_string (buffer, "#pragma omp parallel");
1872 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1873 if (gimple_omp_parallel_child_fn (gs))
1875 pp_string (buffer, " [child fn: ");
1876 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1877 spc, flags, false);
1878 pp_string (buffer, " (");
1879 if (gimple_omp_parallel_data_arg (gs))
1880 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1881 spc, flags, false);
1882 else
1883 pp_string (buffer, "???");
1884 pp_string (buffer, ")]");
1886 body = gimple_omp_body (gs);
1887 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1889 newline_and_indent (buffer, spc + 2);
1890 pp_left_brace (buffer);
1891 pp_newline (buffer);
1892 dump_gimple_seq (buffer, body, spc + 4, flags);
1893 newline_and_indent (buffer, spc + 2);
1894 pp_right_brace (buffer);
1896 else if (body)
1898 pp_newline (buffer);
1899 dump_gimple_seq (buffer, body, spc + 2, flags);
1905 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1906 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1907 dumpfile.h). */
1909 static void
1910 dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
1911 int flags)
1913 if (flags & TDF_RAW)
1915 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1916 gimple_omp_body (gs));
1917 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1918 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1919 gimple_omp_task_child_fn (gs),
1920 gimple_omp_task_data_arg (gs),
1921 gimple_omp_task_copy_fn (gs),
1922 gimple_omp_task_arg_size (gs),
1923 gimple_omp_task_arg_size (gs));
1925 else
1927 gimple_seq body;
1928 pp_string (buffer, "#pragma omp task");
1929 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1930 if (gimple_omp_task_child_fn (gs))
1932 pp_string (buffer, " [child fn: ");
1933 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1934 spc, flags, false);
1935 pp_string (buffer, " (");
1936 if (gimple_omp_task_data_arg (gs))
1937 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1938 spc, flags, false);
1939 else
1940 pp_string (buffer, "???");
1941 pp_string (buffer, ")]");
1943 body = gimple_omp_body (gs);
1944 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1946 newline_and_indent (buffer, spc + 2);
1947 pp_left_brace (buffer);
1948 pp_newline (buffer);
1949 dump_gimple_seq (buffer, body, spc + 4, flags);
1950 newline_and_indent (buffer, spc + 2);
1951 pp_right_brace (buffer);
1953 else if (body)
1955 pp_newline (buffer);
1956 dump_gimple_seq (buffer, body, spc + 2, flags);
1962 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1963 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1964 in dumpfile.h). */
1966 static void
1967 dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
1968 int flags)
1970 if (flags & TDF_RAW)
1972 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1973 gimple_omp_atomic_load_lhs (gs),
1974 gimple_omp_atomic_load_rhs (gs));
1976 else
1978 pp_string (buffer, "#pragma omp atomic_load");
1979 if (gimple_omp_atomic_seq_cst_p (gs))
1980 pp_string (buffer, " seq_cst");
1981 if (gimple_omp_atomic_need_value_p (gs))
1982 pp_string (buffer, " [needed]");
1983 newline_and_indent (buffer, spc + 2);
1984 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
1985 spc, flags, false);
1986 pp_space (buffer);
1987 pp_equal (buffer);
1988 pp_space (buffer);
1989 pp_star (buffer);
1990 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
1991 spc, flags, false);
1995 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1996 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1997 in dumpfile.h). */
1999 static void
2000 dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
2001 int flags)
2003 if (flags & TDF_RAW)
2005 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2006 gimple_omp_atomic_store_val (gs));
2008 else
2010 pp_string (buffer, "#pragma omp atomic_store ");
2011 if (gimple_omp_atomic_seq_cst_p (gs))
2012 pp_string (buffer, "seq_cst ");
2013 if (gimple_omp_atomic_need_value_p (gs))
2014 pp_string (buffer, "[needed] ");
2015 pp_left_paren (buffer);
2016 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2017 spc, flags, false);
2018 pp_right_paren (buffer);
2023 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2024 FLAGS are as in pp_gimple_stmt_1. */
2026 static void
2027 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
2029 tree vdef = gimple_vdef (gs);
2030 tree vuse = gimple_vuse (gs);
2032 if (vdef != NULL_TREE)
2034 pp_string (buffer, "# ");
2035 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2036 pp_string (buffer, " = VDEF <");
2037 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2038 pp_greater (buffer);
2039 newline_and_indent (buffer, spc);
2041 else if (vuse != NULL_TREE)
2043 pp_string (buffer, "# VUSE <");
2044 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2045 pp_greater (buffer);
2046 newline_and_indent (buffer, spc);
2051 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2052 spaces of indent. FLAGS specifies details to show in the dump (see
2053 TDF_* in dumpfile.h). The caller is responsible for calling
2054 pp_flush on BUFFER to finalize the pretty printer. */
2056 void
2057 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
2059 if (!gs)
2060 return;
2062 if (flags & TDF_STMTADDR)
2063 pp_printf (buffer, "<&%p> ", (void *) gs);
2065 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2066 dump_location (buffer, gimple_location (gs));
2068 if (flags & TDF_EH)
2070 int lp_nr = lookup_stmt_eh_lp (gs);
2071 if (lp_nr > 0)
2072 pp_printf (buffer, "[LP %d] ", lp_nr);
2073 else if (lp_nr < 0)
2074 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2077 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2078 && gimple_has_mem_ops (gs))
2079 dump_gimple_mem_ops (buffer, gs, spc, flags);
2081 if (gimple_has_lhs (gs)
2082 && (flags & TDF_ALIAS))
2083 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2085 switch (gimple_code (gs))
2087 case GIMPLE_ASM:
2088 dump_gimple_asm (buffer, gs, spc, flags);
2089 break;
2091 case GIMPLE_ASSIGN:
2092 dump_gimple_assign (buffer, as_a <gimple_assign> (gs), spc, flags);
2093 break;
2095 case GIMPLE_BIND:
2096 dump_gimple_bind (buffer, as_a <gimple_bind> (gs), spc, flags);
2097 break;
2099 case GIMPLE_CALL:
2100 dump_gimple_call (buffer, as_a <gimple_call> (gs), spc, flags);
2101 break;
2103 case GIMPLE_COND:
2104 dump_gimple_cond (buffer, as_a <gimple_cond> (gs), spc, flags);
2105 break;
2107 case GIMPLE_LABEL:
2108 dump_gimple_label (buffer, as_a <gimple_label> (gs), spc, flags);
2109 break;
2111 case GIMPLE_GOTO:
2112 dump_gimple_goto (buffer, gs, spc, flags);
2113 break;
2115 case GIMPLE_NOP:
2116 pp_string (buffer, "GIMPLE_NOP");
2117 break;
2119 case GIMPLE_RETURN:
2120 dump_gimple_return (buffer, as_a <gimple_return> (gs), spc, flags);
2121 break;
2123 case GIMPLE_SWITCH:
2124 dump_gimple_switch (buffer, as_a <gimple_switch> (gs), spc, flags);
2125 break;
2127 case GIMPLE_TRY:
2128 dump_gimple_try (buffer, gs, spc, flags);
2129 break;
2131 case GIMPLE_PHI:
2132 dump_gimple_phi (buffer, as_a <gimple_phi> (gs), spc, false, flags);
2133 break;
2135 case GIMPLE_OMP_PARALLEL:
2136 dump_gimple_omp_parallel (buffer, gs, spc, flags);
2137 break;
2139 case GIMPLE_OMP_TASK:
2140 dump_gimple_omp_task (buffer, gs, spc, flags);
2141 break;
2143 case GIMPLE_OMP_ATOMIC_LOAD:
2144 dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
2146 break;
2148 case GIMPLE_OMP_ATOMIC_STORE:
2149 dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
2150 break;
2152 case GIMPLE_OMP_FOR:
2153 dump_gimple_omp_for (buffer, gs, spc, flags);
2154 break;
2156 case GIMPLE_OMP_CONTINUE:
2157 dump_gimple_omp_continue (buffer, gs, spc, flags);
2158 break;
2160 case GIMPLE_OMP_SINGLE:
2161 dump_gimple_omp_single (buffer, gs, spc, flags);
2162 break;
2164 case GIMPLE_OMP_TARGET:
2165 dump_gimple_omp_target (buffer, gs, spc, flags);
2166 break;
2168 case GIMPLE_OMP_TEAMS:
2169 dump_gimple_omp_teams (buffer, gs, spc, flags);
2170 break;
2172 case GIMPLE_OMP_RETURN:
2173 dump_gimple_omp_return (buffer, gs, spc, flags);
2174 break;
2176 case GIMPLE_OMP_SECTIONS:
2177 dump_gimple_omp_sections (buffer, gs, spc, flags);
2178 break;
2180 case GIMPLE_OMP_SECTIONS_SWITCH:
2181 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2182 break;
2184 case GIMPLE_OMP_MASTER:
2185 case GIMPLE_OMP_TASKGROUP:
2186 case GIMPLE_OMP_ORDERED:
2187 case GIMPLE_OMP_SECTION:
2188 dump_gimple_omp_block (buffer, gs, spc, flags);
2189 break;
2191 case GIMPLE_OMP_CRITICAL:
2192 dump_gimple_omp_critical (buffer, gs, spc, flags);
2193 break;
2195 case GIMPLE_CATCH:
2196 dump_gimple_catch (buffer, gs, spc, flags);
2197 break;
2199 case GIMPLE_EH_FILTER:
2200 dump_gimple_eh_filter (buffer, gs, spc, flags);
2201 break;
2203 case GIMPLE_EH_MUST_NOT_THROW:
2204 dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
2205 break;
2207 case GIMPLE_EH_ELSE:
2208 dump_gimple_eh_else (buffer, gs, spc, flags);
2209 break;
2211 case GIMPLE_RESX:
2212 dump_gimple_resx (buffer, gs, spc, flags);
2213 break;
2215 case GIMPLE_EH_DISPATCH:
2216 dump_gimple_eh_dispatch (buffer, gs, spc, flags);
2217 break;
2219 case GIMPLE_DEBUG:
2220 dump_gimple_debug (buffer, as_a <gimple_debug> (gs), spc, flags);
2221 break;
2223 case GIMPLE_PREDICT:
2224 pp_string (buffer, "// predicted ");
2225 if (gimple_predict_outcome (gs))
2226 pp_string (buffer, "likely by ");
2227 else
2228 pp_string (buffer, "unlikely by ");
2229 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2230 pp_string (buffer, " predictor.");
2231 break;
2233 case GIMPLE_TRANSACTION:
2234 dump_gimple_transaction (buffer, gs, spc, flags);
2235 break;
2237 default:
2238 GIMPLE_NIY;
2243 /* Dumps header of basic block BB to OUTF indented by INDENT
2244 spaces and details described by flags. */
2246 static void
2247 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2249 if (flags & TDF_BLOCKS)
2251 if (flags & TDF_LINENO)
2253 gimple_stmt_iterator gsi;
2255 if (flags & TDF_COMMENT)
2256 fputs (";; ", outf);
2258 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2259 if (!is_gimple_debug (gsi_stmt (gsi))
2260 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2262 fprintf (outf, "%*sstarting at line %d",
2263 indent, "", get_lineno (gsi_stmt (gsi)));
2264 break;
2266 if (bb->discriminator)
2267 fprintf (outf, ", discriminator %i", bb->discriminator);
2268 fputc ('\n', outf);
2271 else
2273 gimple stmt = first_stmt (bb);
2274 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2275 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2280 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2281 spaces. */
2283 static void
2284 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2285 basic_block bb ATTRIBUTE_UNUSED,
2286 int indent ATTRIBUTE_UNUSED,
2287 int flags ATTRIBUTE_UNUSED)
2289 /* There is currently no GIMPLE-specific basic block info to dump. */
2290 return;
2294 /* Dump PHI nodes of basic block BB to BUFFER with details described
2295 by FLAGS and indented by INDENT spaces. */
2297 static void
2298 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2300 gimple_phi_iterator i;
2302 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2304 gimple_phi phi = i.phi ();
2305 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2307 INDENT (indent);
2308 dump_gimple_phi (buffer, phi, indent, true, flags);
2309 pp_newline (buffer);
2315 /* Dump jump to basic block BB that is represented implicitly in the cfg
2316 to BUFFER. */
2318 static void
2319 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2321 gimple stmt;
2323 stmt = first_stmt (bb);
2325 pp_string (buffer, "goto <bb ");
2326 pp_decimal_int (buffer, bb->index);
2327 pp_greater (buffer);
2328 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2330 pp_string (buffer, " (");
2331 dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
2332 pp_right_paren (buffer);
2333 pp_semicolon (buffer);
2335 else
2336 pp_semicolon (buffer);
2340 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2341 by INDENT spaces, with details given by FLAGS. */
2343 static void
2344 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2345 int flags)
2347 edge e;
2348 gimple stmt;
2350 stmt = last_stmt (bb);
2352 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2354 edge true_edge, false_edge;
2356 /* When we are emitting the code or changing CFG, it is possible that
2357 the edges are not yet created. When we are using debug_bb in such
2358 a situation, we do not want it to crash. */
2359 if (EDGE_COUNT (bb->succs) != 2)
2360 return;
2361 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2363 INDENT (indent + 2);
2364 pp_cfg_jump (buffer, true_edge->dest);
2365 newline_and_indent (buffer, indent);
2366 pp_string (buffer, "else");
2367 newline_and_indent (buffer, indent + 2);
2368 pp_cfg_jump (buffer, false_edge->dest);
2369 pp_newline (buffer);
2370 return;
2373 /* If there is a fallthru edge, we may need to add an artificial
2374 goto to the dump. */
2375 e = find_fallthru_edge (bb->succs);
2377 if (e && e->dest != bb->next_bb)
2379 INDENT (indent);
2381 if ((flags & TDF_LINENO)
2382 && e->goto_locus != UNKNOWN_LOCATION)
2383 dump_location (buffer, e->goto_locus);
2385 pp_cfg_jump (buffer, e->dest);
2386 pp_newline (buffer);
2391 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2392 indented by INDENT spaces. */
2394 static void
2395 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2396 int flags)
2398 gimple_stmt_iterator gsi;
2399 gimple stmt;
2400 int label_indent = indent - 2;
2402 if (label_indent < 0)
2403 label_indent = 0;
2405 dump_phi_nodes (buffer, bb, indent, flags);
2407 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2409 int curr_indent;
2411 stmt = gsi_stmt (gsi);
2413 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2415 INDENT (curr_indent);
2416 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2417 pp_newline_and_flush (buffer);
2418 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2419 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2420 pp_buffer (buffer)->stream, stmt);
2423 dump_implicit_edges (buffer, bb, indent, flags);
2424 pp_flush (buffer);
2428 /* Dumps basic block BB to FILE with details described by FLAGS and
2429 indented by INDENT spaces. */
2431 void
2432 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2434 dump_gimple_bb_header (file, bb, indent, flags);
2435 if (bb->index >= NUM_FIXED_BLOCKS)
2437 pretty_printer buffer;
2438 pp_needs_newline (&buffer) = true;
2439 buffer.buffer->stream = file;
2440 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2442 dump_gimple_bb_footer (file, bb, indent, flags);
2445 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2446 no indentation, for use as a label of a DOT graph record-node.
2447 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2448 histogram dumping doesn't know about pretty-printers. */
2450 void
2451 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2453 gimple_stmt_iterator gsi;
2455 pp_printf (pp, "<bb %d>:\n", bb->index);
2456 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2458 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2460 gimple phi = gsi_stmt (gsi);
2461 if (!virtual_operand_p (gimple_phi_result (phi))
2462 || (dump_flags & TDF_VOPS))
2464 pp_bar (pp);
2465 pp_write_text_to_stream (pp);
2466 pp_string (pp, "# ");
2467 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2468 pp_newline (pp);
2469 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2473 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2475 gimple stmt = gsi_stmt (gsi);
2476 pp_bar (pp);
2477 pp_write_text_to_stream (pp);
2478 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2479 pp_newline (pp);
2480 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2482 dump_implicit_edges (pp, bb, 0, dump_flags);
2483 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);