Implement protection of stack variables
[official-gcc.git] / gcc / gimple-pretty-print.c
bloba5a493a088809a17d93a191a51d3730cb4ff719b
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
3 2011 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com> and
5 Diego Novillo <dnovillo@google.com>
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
12 version.
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
23 #include "config.h"
24 #include "system.h"
25 #include "coretypes.h"
26 #include "tm.h"
27 #include "tree.h"
28 #include "diagnostic.h"
29 #include "gimple-pretty-print.h"
30 #include "hashtab.h"
31 #include "tree-flow.h"
32 #include "dumpfile.h" /* for dump_flags */
33 #include "gimple.h"
34 #include "value-prof.h"
35 #include "trans-mem.h"
37 #define INDENT(SPACE) \
38 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
40 static pretty_printer buffer;
41 static bool initialized = false;
43 #define GIMPLE_NIY do_niy (buffer,gs)
45 /* Try to print on BUFFER a default message for the unrecognized
46 gimple statement GS. */
48 static void
49 do_niy (pretty_printer *buffer, gimple gs)
51 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
52 gimple_code_name[(int) gimple_code (gs)]);
56 /* Initialize the pretty printer on FILE if needed. */
58 static void
59 maybe_init_pretty_print (FILE *file)
61 if (!initialized)
63 pp_construct (&buffer, NULL, 0);
64 pp_needs_newline (&buffer) = true;
65 initialized = true;
68 buffer.buffer->stream = file;
72 /* Emit a newline and SPC indentation spaces to BUFFER. */
74 static void
75 newline_and_indent (pretty_printer *buffer, int spc)
77 pp_newline (buffer);
78 INDENT (spc);
82 /* Print the GIMPLE statement GS on stderr. */
84 DEBUG_FUNCTION void
85 debug_gimple_stmt (gimple gs)
87 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
88 fprintf (stderr, "\n");
92 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
93 FLAGS as in pp_gimple_stmt_1. */
95 void
96 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
98 maybe_init_pretty_print (file);
99 pp_gimple_stmt_1 (&buffer, g, spc, flags);
100 pp_newline_and_flush (&buffer);
104 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
105 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
106 of the statement. */
108 void
109 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
111 flags |= TDF_RHS_ONLY;
112 maybe_init_pretty_print (file);
113 pp_gimple_stmt_1 (&buffer, g, spc, flags);
117 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
118 spaces and FLAGS as in pp_gimple_stmt_1.
119 The caller is responsible for calling pp_flush on BUFFER to finalize
120 the pretty printer. */
122 static void
123 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
125 gimple_stmt_iterator i;
127 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
129 gimple gs = gsi_stmt (i);
130 INDENT (spc);
131 pp_gimple_stmt_1 (buffer, gs, spc, flags);
132 if (!gsi_one_before_end_p (i))
133 pp_newline (buffer);
138 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
139 FLAGS as in pp_gimple_stmt_1. */
141 void
142 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
144 maybe_init_pretty_print (file);
145 dump_gimple_seq (&buffer, seq, spc, flags);
146 pp_newline_and_flush (&buffer);
150 /* Print the GIMPLE sequence SEQ on stderr. */
152 DEBUG_FUNCTION void
153 debug_gimple_seq (gimple_seq seq)
155 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
159 /* A simple helper to pretty-print some of the gimple tuples in the printf
160 style. The format modifiers are preceded by '%' and are:
161 'G' - outputs a string corresponding to the code of the given gimple,
162 'S' - outputs a gimple_seq with indent of spc + 2,
163 'T' - outputs the tree t,
164 'd' - outputs an int as a decimal,
165 's' - outputs a string,
166 'n' - outputs a newline,
167 'x' - outputs an int as hexadecimal,
168 '+' - increases indent by 2 then outputs a newline,
169 '-' - decreases indent by 2 then outputs a newline. */
171 static void
172 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
173 const char *fmt, ...)
175 va_list args;
176 const char *c;
177 const char *tmp;
179 va_start (args, fmt);
180 for (c = fmt; *c; c++)
182 if (*c == '%')
184 gimple_seq seq;
185 tree t;
186 gimple g;
187 switch (*++c)
189 case 'G':
190 g = va_arg (args, gimple);
191 tmp = gimple_code_name[gimple_code (g)];
192 pp_string (buffer, tmp);
193 break;
195 case 'S':
196 seq = va_arg (args, gimple_seq);
197 pp_newline (buffer);
198 dump_gimple_seq (buffer, seq, spc + 2, flags);
199 newline_and_indent (buffer, spc);
200 break;
202 case 'T':
203 t = va_arg (args, tree);
204 if (t == NULL_TREE)
205 pp_string (buffer, "NULL");
206 else
207 dump_generic_node (buffer, t, spc, flags, false);
208 break;
210 case 'd':
211 pp_decimal_int (buffer, va_arg (args, int));
212 break;
214 case 's':
215 pp_string (buffer, va_arg (args, char *));
216 break;
218 case 'n':
219 newline_and_indent (buffer, spc);
220 break;
222 case 'x':
223 pp_scalar (buffer, "%x", va_arg (args, int));
224 break;
226 case '+':
227 spc += 2;
228 newline_and_indent (buffer, spc);
229 break;
231 case '-':
232 spc -= 2;
233 newline_and_indent (buffer, spc);
234 break;
236 default:
237 gcc_unreachable ();
240 else
241 pp_character (buffer, *c);
243 va_end (args);
247 /* Helper for dump_gimple_assign. Print the unary RHS of the
248 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
250 static void
251 dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
253 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
254 tree lhs = gimple_assign_lhs (gs);
255 tree rhs = gimple_assign_rhs1 (gs);
257 switch (rhs_code)
259 case VIEW_CONVERT_EXPR:
260 case ASSERT_EXPR:
261 dump_generic_node (buffer, rhs, spc, flags, false);
262 break;
264 case FIXED_CONVERT_EXPR:
265 case ADDR_SPACE_CONVERT_EXPR:
266 case FIX_TRUNC_EXPR:
267 case FLOAT_EXPR:
268 CASE_CONVERT:
269 pp_character (buffer, '(');
270 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
271 pp_string (buffer, ") ");
272 if (op_prio (rhs) < op_code_prio (rhs_code))
274 pp_character (buffer, '(');
275 dump_generic_node (buffer, rhs, spc, flags, false);
276 pp_character (buffer, ')');
278 else
279 dump_generic_node (buffer, rhs, spc, flags, false);
280 break;
282 case PAREN_EXPR:
283 pp_string (buffer, "((");
284 dump_generic_node (buffer, rhs, spc, flags, false);
285 pp_string (buffer, "))");
286 break;
288 case ABS_EXPR:
289 pp_string (buffer, "ABS_EXPR <");
290 dump_generic_node (buffer, rhs, spc, flags, false);
291 pp_character (buffer, '>');
292 break;
294 default:
295 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
296 || TREE_CODE_CLASS (rhs_code) == tcc_constant
297 || TREE_CODE_CLASS (rhs_code) == tcc_reference
298 || rhs_code == SSA_NAME
299 || rhs_code == ADDR_EXPR
300 || rhs_code == CONSTRUCTOR)
302 dump_generic_node (buffer, rhs, spc, flags, false);
303 break;
305 else if (rhs_code == BIT_NOT_EXPR)
306 pp_character (buffer, '~');
307 else if (rhs_code == TRUTH_NOT_EXPR)
308 pp_character (buffer, '!');
309 else if (rhs_code == NEGATE_EXPR)
310 pp_character (buffer, '-');
311 else
313 pp_character (buffer, '[');
314 pp_string (buffer, tree_code_name [rhs_code]);
315 pp_string (buffer, "] ");
318 if (op_prio (rhs) < op_code_prio (rhs_code))
320 pp_character (buffer, '(');
321 dump_generic_node (buffer, rhs, spc, flags, false);
322 pp_character (buffer, ')');
324 else
325 dump_generic_node (buffer, rhs, spc, flags, false);
326 break;
331 /* Helper for dump_gimple_assign. Print the binary RHS of the
332 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
334 static void
335 dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
337 const char *p;
338 enum tree_code code = gimple_assign_rhs_code (gs);
339 switch (code)
341 case COMPLEX_EXPR:
342 case MIN_EXPR:
343 case MAX_EXPR:
344 case VEC_WIDEN_MULT_HI_EXPR:
345 case VEC_WIDEN_MULT_LO_EXPR:
346 case VEC_WIDEN_MULT_EVEN_EXPR:
347 case VEC_WIDEN_MULT_ODD_EXPR:
348 case VEC_PACK_TRUNC_EXPR:
349 case VEC_PACK_SAT_EXPR:
350 case VEC_PACK_FIX_TRUNC_EXPR:
351 case VEC_WIDEN_LSHIFT_HI_EXPR:
352 case VEC_WIDEN_LSHIFT_LO_EXPR:
353 for (p = tree_code_name [(int) code]; *p; p++)
354 pp_character (buffer, TOUPPER (*p));
355 pp_string (buffer, " <");
356 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
357 pp_string (buffer, ", ");
358 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
359 pp_character (buffer, '>');
360 break;
362 default:
363 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
365 pp_character (buffer, '(');
366 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
367 false);
368 pp_character (buffer, ')');
370 else
371 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
372 pp_space (buffer);
373 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
374 pp_space (buffer);
375 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
377 pp_character (buffer, '(');
378 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
379 false);
380 pp_character (buffer, ')');
382 else
383 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
387 /* Helper for dump_gimple_assign. Print the ternary RHS of the
388 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
390 static void
391 dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
393 const char *p;
394 enum tree_code code = gimple_assign_rhs_code (gs);
395 switch (code)
397 case WIDEN_MULT_PLUS_EXPR:
398 case WIDEN_MULT_MINUS_EXPR:
399 for (p = tree_code_name [(int) code]; *p; p++)
400 pp_character (buffer, TOUPPER (*p));
401 pp_string (buffer, " <");
402 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
403 pp_string (buffer, ", ");
404 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
405 pp_string (buffer, ", ");
406 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
407 pp_character (buffer, '>');
408 break;
410 case FMA_EXPR:
411 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
412 pp_string (buffer, " * ");
413 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
414 pp_string (buffer, " + ");
415 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
416 break;
418 case DOT_PROD_EXPR:
419 pp_string (buffer, "DOT_PROD_EXPR <");
420 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
421 pp_string (buffer, ", ");
422 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
423 pp_string (buffer, ", ");
424 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
425 pp_string (buffer, ">");
426 break;
428 case VEC_PERM_EXPR:
429 pp_string (buffer, "VEC_PERM_EXPR <");
430 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
431 pp_string (buffer, ", ");
432 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
433 pp_string (buffer, ", ");
434 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
435 pp_string (buffer, ">");
436 break;
438 case REALIGN_LOAD_EXPR:
439 pp_string (buffer, "REALIGN_LOAD <");
440 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
441 pp_string (buffer, ", ");
442 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
443 pp_string (buffer, ", ");
444 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
445 pp_string (buffer, ">");
446 break;
448 case COND_EXPR:
449 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
450 pp_string (buffer, " ? ");
451 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
452 pp_string (buffer, " : ");
453 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
454 break;
456 case VEC_COND_EXPR:
457 pp_string (buffer, "VEC_COND_EXPR <");
458 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
459 pp_string (buffer, ", ");
460 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
461 pp_string (buffer, ", ");
462 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
463 pp_string (buffer, ">");
464 break;
466 default:
467 gcc_unreachable ();
472 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
473 pp_gimple_stmt_1. */
475 static void
476 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
478 if (flags & TDF_RAW)
480 tree arg1 = NULL;
481 tree arg2 = NULL;
482 tree arg3 = NULL;
483 switch (gimple_num_ops (gs))
485 case 4:
486 arg3 = gimple_assign_rhs3 (gs);
487 case 3:
488 arg2 = gimple_assign_rhs2 (gs);
489 case 2:
490 arg1 = gimple_assign_rhs1 (gs);
491 break;
492 default:
493 gcc_unreachable ();
496 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
497 tree_code_name[gimple_assign_rhs_code (gs)],
498 gimple_assign_lhs (gs), arg1, arg2, arg3);
500 else
502 if (!(flags & TDF_RHS_ONLY))
504 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
505 pp_space (buffer);
506 pp_character (buffer, '=');
508 if (gimple_assign_nontemporal_move_p (gs))
509 pp_string (buffer, "{nt}");
511 if (gimple_has_volatile_ops (gs))
512 pp_string (buffer, "{v}");
514 pp_space (buffer);
517 if (gimple_num_ops (gs) == 2)
518 dump_unary_rhs (buffer, gs, spc, flags);
519 else if (gimple_num_ops (gs) == 3)
520 dump_binary_rhs (buffer, gs, spc, flags);
521 else if (gimple_num_ops (gs) == 4)
522 dump_ternary_rhs (buffer, gs, spc, flags);
523 else
524 gcc_unreachable ();
525 if (!(flags & TDF_RHS_ONLY))
526 pp_semicolon(buffer);
531 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
532 pp_gimple_stmt_1. */
534 static void
535 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
537 tree t;
539 t = gimple_return_retval (gs);
540 if (flags & TDF_RAW)
541 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
542 else
544 pp_string (buffer, "return");
545 if (t)
547 pp_space (buffer);
548 dump_generic_node (buffer, t, spc, flags, false);
550 pp_semicolon (buffer);
555 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
556 dump_gimple_call. */
558 static void
559 dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags)
561 size_t i;
563 for (i = 0; i < gimple_call_num_args (gs); i++)
565 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
566 if (i < gimple_call_num_args (gs) - 1)
567 pp_string (buffer, ", ");
570 if (gimple_call_va_arg_pack_p (gs))
572 if (gimple_call_num_args (gs) > 0)
574 pp_character (buffer, ',');
575 pp_space (buffer);
578 pp_string (buffer, "__builtin_va_arg_pack ()");
582 /* Dump the points-to solution *PT to BUFFER. */
584 static void
585 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
587 if (pt->anything)
589 pp_string (buffer, "anything ");
590 return;
592 if (pt->nonlocal)
593 pp_string (buffer, "nonlocal ");
594 if (pt->escaped)
595 pp_string (buffer, "escaped ");
596 if (pt->ipa_escaped)
597 pp_string (buffer, "unit-escaped ");
598 if (pt->null)
599 pp_string (buffer, "null ");
600 if (pt->vars
601 && !bitmap_empty_p (pt->vars))
603 bitmap_iterator bi;
604 unsigned i;
605 pp_string (buffer, "{ ");
606 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
608 pp_string (buffer, "D.");
609 pp_decimal_int (buffer, i);
610 pp_character (buffer, ' ');
612 pp_character (buffer, '}');
613 if (pt->vars_contains_global)
614 pp_string (buffer, " (glob)");
618 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
619 pp_gimple_stmt_1. */
621 static void
622 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
624 tree lhs = gimple_call_lhs (gs);
625 tree fn = gimple_call_fn (gs);
627 if (flags & TDF_ALIAS)
629 struct pt_solution *pt;
630 pt = gimple_call_use_set (gs);
631 if (!pt_solution_empty_p (pt))
633 pp_string (buffer, "# USE = ");
634 pp_points_to_solution (buffer, pt);
635 newline_and_indent (buffer, spc);
637 pt = gimple_call_clobber_set (gs);
638 if (!pt_solution_empty_p (pt))
640 pp_string (buffer, "# CLB = ");
641 pp_points_to_solution (buffer, pt);
642 newline_and_indent (buffer, spc);
646 if (flags & TDF_RAW)
648 if (gimple_call_internal_p (gs))
649 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
650 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
651 else
652 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
653 if (gimple_call_num_args (gs) > 0)
655 pp_string (buffer, ", ");
656 dump_gimple_call_args (buffer, gs, flags);
658 pp_character (buffer, '>');
660 else
662 if (lhs && !(flags & TDF_RHS_ONLY))
664 dump_generic_node (buffer, lhs, spc, flags, false);
665 pp_string (buffer, " =");
667 if (gimple_has_volatile_ops (gs))
668 pp_string (buffer, "{v}");
670 pp_space (buffer);
672 if (gimple_call_internal_p (gs))
673 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
674 else
675 print_call_name (buffer, fn, flags);
676 pp_string (buffer, " (");
677 dump_gimple_call_args (buffer, gs, flags);
678 pp_character (buffer, ')');
679 if (!(flags & TDF_RHS_ONLY))
680 pp_semicolon (buffer);
683 if (gimple_call_chain (gs))
685 pp_string (buffer, " [static-chain: ");
686 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
687 pp_character (buffer, ']');
690 if (gimple_call_return_slot_opt_p (gs))
691 pp_string (buffer, " [return slot optimization]");
692 if (gimple_call_tail_p (gs))
693 pp_string (buffer, " [tail call]");
695 if (fn == NULL)
696 return;
698 /* Dump the arguments of _ITM_beginTransaction sanely. */
699 if (TREE_CODE (fn) == ADDR_EXPR)
700 fn = TREE_OPERAND (fn, 0);
701 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
702 pp_string (buffer, " [tm-clone]");
703 if (TREE_CODE (fn) == FUNCTION_DECL
704 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
705 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
706 && gimple_call_num_args (gs) > 0)
708 tree t = gimple_call_arg (gs, 0);
709 unsigned HOST_WIDE_INT props;
710 gcc_assert (TREE_CODE (t) == INTEGER_CST);
712 pp_string (buffer, " [ ");
714 /* Get the transaction code properties. */
715 props = TREE_INT_CST_LOW (t);
717 if (props & PR_INSTRUMENTEDCODE)
718 pp_string (buffer, "instrumentedCode ");
719 if (props & PR_UNINSTRUMENTEDCODE)
720 pp_string (buffer, "uninstrumentedCode ");
721 if (props & PR_HASNOXMMUPDATE)
722 pp_string (buffer, "hasNoXMMUpdate ");
723 if (props & PR_HASNOABORT)
724 pp_string (buffer, "hasNoAbort ");
725 if (props & PR_HASNOIRREVOCABLE)
726 pp_string (buffer, "hasNoIrrevocable ");
727 if (props & PR_DOESGOIRREVOCABLE)
728 pp_string (buffer, "doesGoIrrevocable ");
729 if (props & PR_HASNOSIMPLEREADS)
730 pp_string (buffer, "hasNoSimpleReads ");
731 if (props & PR_AWBARRIERSOMITTED)
732 pp_string (buffer, "awBarriersOmitted ");
733 if (props & PR_RARBARRIERSOMITTED)
734 pp_string (buffer, "RaRBarriersOmitted ");
735 if (props & PR_UNDOLOGCODE)
736 pp_string (buffer, "undoLogCode ");
737 if (props & PR_PREFERUNINSTRUMENTED)
738 pp_string (buffer, "preferUninstrumented ");
739 if (props & PR_EXCEPTIONBLOCK)
740 pp_string (buffer, "exceptionBlock ");
741 if (props & PR_HASELSE)
742 pp_string (buffer, "hasElse ");
743 if (props & PR_READONLY)
744 pp_string (buffer, "readOnly ");
746 pp_string (buffer, "]");
751 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
752 pp_gimple_stmt_1. */
754 static void
755 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
757 unsigned int i;
759 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
760 if (flags & TDF_RAW)
761 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
762 gimple_switch_index (gs));
763 else
765 pp_string (buffer, "switch (");
766 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
767 pp_string (buffer, ") <");
770 for (i = 0; i < gimple_switch_num_labels (gs); i++)
772 tree case_label = gimple_switch_label (gs, i);
773 gcc_checking_assert (case_label != NULL_TREE);
774 dump_generic_node (buffer, case_label, spc, flags, false);
775 pp_character (buffer, ' ');
776 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
777 if (i < gimple_switch_num_labels (gs) - 1)
778 pp_string (buffer, ", ");
780 pp_character (buffer, '>');
784 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
785 pp_gimple_stmt_1. */
787 static void
788 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
790 if (flags & TDF_RAW)
791 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
792 tree_code_name [gimple_cond_code (gs)],
793 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
794 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
795 else
797 if (!(flags & TDF_RHS_ONLY))
798 pp_string (buffer, "if (");
799 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
800 pp_space (buffer);
801 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
802 pp_space (buffer);
803 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
804 if (!(flags & TDF_RHS_ONLY))
806 pp_character (buffer, ')');
808 if (gimple_cond_true_label (gs))
810 pp_string (buffer, " goto ");
811 dump_generic_node (buffer, gimple_cond_true_label (gs),
812 spc, flags, false);
813 pp_semicolon (buffer);
815 if (gimple_cond_false_label (gs))
817 pp_string (buffer, " else goto ");
818 dump_generic_node (buffer, gimple_cond_false_label (gs),
819 spc, flags, false);
820 pp_semicolon (buffer);
827 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
828 spaces of indent. FLAGS specifies details to show in the dump (see
829 TDF_* in dumpfils.h). */
831 static void
832 dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
834 tree label = gimple_label_label (gs);
835 if (flags & TDF_RAW)
836 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
837 else
839 dump_generic_node (buffer, label, spc, flags, false);
840 pp_character (buffer, ':');
842 if (DECL_NONLOCAL (label))
843 pp_string (buffer, " [non-local]");
844 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
845 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
848 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
849 spaces of indent. FLAGS specifies details to show in the dump (see
850 TDF_* in dumpfile.h). */
852 static void
853 dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
855 tree label = gimple_goto_dest (gs);
856 if (flags & TDF_RAW)
857 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
858 else
859 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
863 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
864 spaces of indent. FLAGS specifies details to show in the dump (see
865 TDF_* in dumpfile.h). */
867 static void
868 dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
870 if (flags & TDF_RAW)
871 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
872 else
873 pp_character (buffer, '{');
874 if (!(flags & TDF_SLIM))
876 tree var;
878 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
880 newline_and_indent (buffer, 2);
881 print_declaration (buffer, var, spc, flags);
883 if (gimple_bind_vars (gs))
884 pp_newline (buffer);
886 pp_newline (buffer);
887 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
888 newline_and_indent (buffer, spc);
889 if (flags & TDF_RAW)
890 pp_character (buffer, '>');
891 else
892 pp_character (buffer, '}');
896 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
897 indent. FLAGS specifies details to show in the dump (see TDF_* in
898 dumpfile.h). */
900 static void
901 dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
903 if (flags & TDF_RAW)
905 const char *type;
906 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
907 type = "GIMPLE_TRY_CATCH";
908 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
909 type = "GIMPLE_TRY_FINALLY";
910 else
911 type = "UNKNOWN GIMPLE_TRY";
912 dump_gimple_fmt (buffer, spc, flags,
913 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
914 gimple_try_eval (gs), gimple_try_cleanup (gs));
916 else
918 pp_string (buffer, "try");
919 newline_and_indent (buffer, spc + 2);
920 pp_character (buffer, '{');
921 pp_newline (buffer);
923 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
924 newline_and_indent (buffer, spc + 2);
925 pp_character (buffer, '}');
927 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
929 newline_and_indent (buffer, spc);
930 pp_string (buffer, "catch");
931 newline_and_indent (buffer, spc + 2);
932 pp_character (buffer, '{');
934 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
936 newline_and_indent (buffer, spc);
937 pp_string (buffer, "finally");
938 newline_and_indent (buffer, spc + 2);
939 pp_character (buffer, '{');
941 else
942 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
944 pp_newline (buffer);
945 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
946 newline_and_indent (buffer, spc + 2);
947 pp_character (buffer, '}');
952 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
953 indent. FLAGS specifies details to show in the dump (see TDF_* in
954 dumpfile.h). */
956 static void
957 dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
959 if (flags & TDF_RAW)
960 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
961 gimple_catch_types (gs), gimple_catch_handler (gs));
962 else
963 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
964 gimple_catch_types (gs), gimple_catch_handler (gs));
968 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
969 indent. FLAGS specifies details to show in the dump (see TDF_* in
970 dumpfile.h). */
972 static void
973 dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
975 if (flags & TDF_RAW)
976 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
977 gimple_eh_filter_types (gs),
978 gimple_eh_filter_failure (gs));
979 else
980 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
981 gimple_eh_filter_types (gs),
982 gimple_eh_filter_failure (gs));
986 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
988 static void
989 dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
990 int spc, int flags)
992 if (flags & TDF_RAW)
993 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
994 gimple_eh_must_not_throw_fndecl (gs));
995 else
996 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
997 gimple_eh_must_not_throw_fndecl (gs));
1001 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1002 indent. FLAGS specifies details to show in the dump (see TDF_* in
1003 dumpfile.h). */
1005 static void
1006 dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags)
1008 if (flags & TDF_RAW)
1009 dump_gimple_fmt (buffer, spc, flags,
1010 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1011 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1012 else
1013 dump_gimple_fmt (buffer, spc, flags,
1014 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1015 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1019 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1020 indent. FLAGS specifies details to show in the dump (see TDF_* in
1021 dumpfile.h). */
1023 static void
1024 dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
1026 if (flags & TDF_RAW)
1027 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1028 gimple_resx_region (gs));
1029 else
1030 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1033 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1035 static void
1036 dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
1038 if (flags & TDF_RAW)
1039 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1040 gimple_eh_dispatch_region (gs));
1041 else
1042 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1043 gimple_eh_dispatch_region (gs));
1046 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1047 of indent. FLAGS specifies details to show in the dump (see TDF_*
1048 in dumpfile.h). */
1050 static void
1051 dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
1053 switch (gs->gsbase.subcode)
1055 case GIMPLE_DEBUG_BIND:
1056 if (flags & TDF_RAW)
1057 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1058 gimple_debug_bind_get_var (gs),
1059 gimple_debug_bind_get_value (gs));
1060 else
1061 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1062 gimple_debug_bind_get_var (gs),
1063 gimple_debug_bind_get_value (gs));
1064 break;
1066 case GIMPLE_DEBUG_SOURCE_BIND:
1067 if (flags & TDF_RAW)
1068 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1069 gimple_debug_source_bind_get_var (gs),
1070 gimple_debug_source_bind_get_value (gs));
1071 else
1072 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1073 gimple_debug_source_bind_get_var (gs),
1074 gimple_debug_source_bind_get_value (gs));
1075 break;
1077 default:
1078 gcc_unreachable ();
1082 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1083 static void
1084 dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
1086 size_t i;
1088 if (flags & TDF_RAW)
1090 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1091 gimple_omp_body (gs));
1092 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1093 dump_gimple_fmt (buffer, spc, flags, " >,");
1094 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1095 dump_gimple_fmt (buffer, spc, flags,
1096 "%+%T, %T, %T, %s, %T,%n",
1097 gimple_omp_for_index (gs, i),
1098 gimple_omp_for_initial (gs, i),
1099 gimple_omp_for_final (gs, i),
1100 tree_code_name[gimple_omp_for_cond (gs, i)],
1101 gimple_omp_for_incr (gs, i));
1102 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1103 gimple_omp_for_pre_body (gs));
1105 else
1107 pp_string (buffer, "#pragma omp for");
1108 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1109 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1111 if (i)
1112 spc += 2;
1113 newline_and_indent (buffer, spc);
1114 pp_string (buffer, "for (");
1115 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1116 flags, false);
1117 pp_string (buffer, " = ");
1118 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1119 flags, false);
1120 pp_string (buffer, "; ");
1122 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1123 flags, false);
1124 pp_space (buffer);
1125 switch (gimple_omp_for_cond (gs, i))
1127 case LT_EXPR:
1128 pp_character (buffer, '<');
1129 break;
1130 case GT_EXPR:
1131 pp_character (buffer, '>');
1132 break;
1133 case LE_EXPR:
1134 pp_string (buffer, "<=");
1135 break;
1136 case GE_EXPR:
1137 pp_string (buffer, ">=");
1138 break;
1139 default:
1140 gcc_unreachable ();
1142 pp_space (buffer);
1143 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1144 flags, false);
1145 pp_string (buffer, "; ");
1147 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1148 flags, false);
1149 pp_string (buffer, " = ");
1150 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1151 flags, false);
1152 pp_character (buffer, ')');
1155 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1157 newline_and_indent (buffer, spc + 2);
1158 pp_character (buffer, '{');
1159 pp_newline (buffer);
1160 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1161 newline_and_indent (buffer, spc + 2);
1162 pp_character (buffer, '}');
1167 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1169 static void
1170 dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags)
1172 if (flags & TDF_RAW)
1174 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1175 gimple_omp_continue_control_def (gs),
1176 gimple_omp_continue_control_use (gs));
1178 else
1180 pp_string (buffer, "#pragma omp continue (");
1181 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1182 spc, flags, false);
1183 pp_character (buffer, ',');
1184 pp_space (buffer);
1185 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1186 spc, flags, false);
1187 pp_character (buffer, ')');
1191 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1193 static void
1194 dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, int flags)
1196 if (flags & TDF_RAW)
1198 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1199 gimple_omp_body (gs));
1200 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1201 dump_gimple_fmt (buffer, spc, flags, " >");
1203 else
1205 pp_string (buffer, "#pragma omp single");
1206 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1207 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1209 newline_and_indent (buffer, spc + 2);
1210 pp_character (buffer, '{');
1211 pp_newline (buffer);
1212 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1213 newline_and_indent (buffer, spc + 2);
1214 pp_character (buffer, '}');
1219 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1221 static void
1222 dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
1223 int flags)
1225 if (flags & TDF_RAW)
1227 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1228 gimple_omp_body (gs));
1229 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1230 dump_gimple_fmt (buffer, spc, flags, " >");
1232 else
1234 pp_string (buffer, "#pragma omp sections");
1235 if (gimple_omp_sections_control (gs))
1237 pp_string (buffer, " <");
1238 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1239 flags, false);
1240 pp_character (buffer, '>');
1242 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1243 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1245 newline_and_indent (buffer, spc + 2);
1246 pp_character (buffer, '{');
1247 pp_newline (buffer);
1248 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1249 newline_and_indent (buffer, spc + 2);
1250 pp_character (buffer, '}');
1255 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the pretty_printer
1256 BUFFER. */
1258 static void
1259 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1261 if (flags & TDF_RAW)
1262 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1263 gimple_omp_body (gs));
1264 else
1266 switch (gimple_code (gs))
1268 case GIMPLE_OMP_MASTER:
1269 pp_string (buffer, "#pragma omp master");
1270 break;
1271 case GIMPLE_OMP_ORDERED:
1272 pp_string (buffer, "#pragma omp ordered");
1273 break;
1274 case GIMPLE_OMP_SECTION:
1275 pp_string (buffer, "#pragma omp section");
1276 break;
1277 default:
1278 gcc_unreachable ();
1280 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1282 newline_and_indent (buffer, spc + 2);
1283 pp_character (buffer, '{');
1284 pp_newline (buffer);
1285 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1286 newline_and_indent (buffer, spc + 2);
1287 pp_character (buffer, '}');
1292 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1294 static void
1295 dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
1296 int flags)
1298 if (flags & TDF_RAW)
1299 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1300 gimple_omp_body (gs));
1301 else
1303 pp_string (buffer, "#pragma omp critical");
1304 if (gimple_omp_critical_name (gs))
1306 pp_string (buffer, " (");
1307 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1308 flags, false);
1309 pp_character (buffer, ')');
1311 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1313 newline_and_indent (buffer, spc + 2);
1314 pp_character (buffer, '{');
1315 pp_newline (buffer);
1316 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1317 newline_and_indent (buffer, spc + 2);
1318 pp_character (buffer, '}');
1323 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1325 static void
1326 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1328 if (flags & TDF_RAW)
1330 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d>", gs,
1331 (int) gimple_omp_return_nowait_p (gs));
1333 else
1335 pp_string (buffer, "#pragma omp return");
1336 if (gimple_omp_return_nowait_p (gs))
1337 pp_string (buffer, "(nowait)");
1341 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1343 static void
1344 dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags)
1346 unsigned subcode = gimple_transaction_subcode (gs);
1348 if (flags & TDF_RAW)
1350 dump_gimple_fmt (buffer, spc, flags,
1351 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1352 gs, subcode, gimple_transaction_label (gs),
1353 gimple_transaction_body (gs));
1355 else
1357 if (subcode & GTMA_IS_OUTER)
1358 pp_string (buffer, "__transaction_atomic [[outer]]");
1359 else if (subcode & GTMA_IS_RELAXED)
1360 pp_string (buffer, "__transaction_relaxed");
1361 else
1362 pp_string (buffer, "__transaction_atomic");
1363 subcode &= ~GTMA_DECLARATION_MASK;
1365 if (subcode || gimple_transaction_label (gs))
1367 pp_string (buffer, " //");
1368 if (gimple_transaction_label (gs))
1370 pp_string (buffer, " LABEL=");
1371 dump_generic_node (buffer, gimple_transaction_label (gs),
1372 spc, flags, false);
1374 if (subcode)
1376 pp_string (buffer, " SUBCODE=[ ");
1377 if (subcode & GTMA_HAVE_ABORT)
1379 pp_string (buffer, "GTMA_HAVE_ABORT ");
1380 subcode &= ~GTMA_HAVE_ABORT;
1382 if (subcode & GTMA_HAVE_LOAD)
1384 pp_string (buffer, "GTMA_HAVE_LOAD ");
1385 subcode &= ~GTMA_HAVE_LOAD;
1387 if (subcode & GTMA_HAVE_STORE)
1389 pp_string (buffer, "GTMA_HAVE_STORE ");
1390 subcode &= ~GTMA_HAVE_STORE;
1392 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1394 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1395 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1397 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1399 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1400 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1402 if (subcode)
1403 pp_printf (buffer, "0x%x ", subcode);
1404 pp_string (buffer, "]");
1408 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1410 newline_and_indent (buffer, spc + 2);
1411 pp_character (buffer, '{');
1412 pp_newline (buffer);
1413 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1414 spc + 4, flags);
1415 newline_and_indent (buffer, spc + 2);
1416 pp_character (buffer, '}');
1421 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1422 indent. FLAGS specifies details to show in the dump (see TDF_* in
1423 dumpfile.h). */
1425 static void
1426 dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
1428 unsigned int i, n, f, fields;
1430 if (flags & TDF_RAW)
1432 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1433 gimple_asm_string (gs));
1435 n = gimple_asm_noutputs (gs);
1436 if (n)
1438 newline_and_indent (buffer, spc + 2);
1439 pp_string (buffer, "OUTPUT: ");
1440 for (i = 0; i < n; i++)
1442 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1443 spc, flags, false);
1444 if (i < n - 1)
1445 pp_string (buffer, ", ");
1449 n = gimple_asm_ninputs (gs);
1450 if (n)
1452 newline_and_indent (buffer, spc + 2);
1453 pp_string (buffer, "INPUT: ");
1454 for (i = 0; i < n; i++)
1456 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1457 spc, flags, false);
1458 if (i < n - 1)
1459 pp_string (buffer, ", ");
1463 n = gimple_asm_nclobbers (gs);
1464 if (n)
1466 newline_and_indent (buffer, spc + 2);
1467 pp_string (buffer, "CLOBBER: ");
1468 for (i = 0; i < n; i++)
1470 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1471 spc, flags, false);
1472 if (i < n - 1)
1473 pp_string (buffer, ", ");
1477 n = gimple_asm_nlabels (gs);
1478 if (n)
1480 newline_and_indent (buffer, spc + 2);
1481 pp_string (buffer, "LABEL: ");
1482 for (i = 0; i < n; i++)
1484 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1485 spc, flags, false);
1486 if (i < n - 1)
1487 pp_string (buffer, ", ");
1491 newline_and_indent (buffer, spc);
1492 pp_character (buffer, '>');
1494 else
1496 pp_string (buffer, "__asm__");
1497 if (gimple_asm_volatile_p (gs))
1498 pp_string (buffer, " __volatile__");
1499 if (gimple_asm_nlabels (gs))
1500 pp_string (buffer, " goto");
1501 pp_string (buffer, "(\"");
1502 pp_string (buffer, gimple_asm_string (gs));
1503 pp_string (buffer, "\"");
1505 if (gimple_asm_nlabels (gs))
1506 fields = 4;
1507 else if (gimple_asm_nclobbers (gs))
1508 fields = 3;
1509 else if (gimple_asm_ninputs (gs))
1510 fields = 2;
1511 else if (gimple_asm_noutputs (gs))
1512 fields = 1;
1513 else
1514 fields = 0;
1516 for (f = 0; f < fields; ++f)
1518 pp_string (buffer, " : ");
1520 switch (f)
1522 case 0:
1523 n = gimple_asm_noutputs (gs);
1524 for (i = 0; i < n; i++)
1526 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1527 spc, flags, false);
1528 if (i < n - 1)
1529 pp_string (buffer, ", ");
1531 break;
1533 case 1:
1534 n = gimple_asm_ninputs (gs);
1535 for (i = 0; i < n; i++)
1537 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1538 spc, flags, false);
1539 if (i < n - 1)
1540 pp_string (buffer, ", ");
1542 break;
1544 case 2:
1545 n = gimple_asm_nclobbers (gs);
1546 for (i = 0; i < n; i++)
1548 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1549 spc, flags, false);
1550 if (i < n - 1)
1551 pp_string (buffer, ", ");
1553 break;
1555 case 3:
1556 n = gimple_asm_nlabels (gs);
1557 for (i = 0; i < n; i++)
1559 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1560 spc, flags, false);
1561 if (i < n - 1)
1562 pp_string (buffer, ", ");
1564 break;
1566 default:
1567 gcc_unreachable ();
1571 pp_string (buffer, ");");
1576 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1577 The caller is responsible for calling pp_flush on BUFFER to finalize
1578 pretty printer. */
1580 static void
1581 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags)
1583 size_t i;
1584 tree lhs = gimple_phi_result (phi);
1586 if (flags & TDF_ALIAS
1587 && POINTER_TYPE_P (TREE_TYPE (lhs))
1588 && SSA_NAME_PTR_INFO (lhs))
1590 unsigned int align, misalign;
1591 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
1592 pp_string (buffer, "PT = ");
1593 pp_points_to_solution (buffer, &pi->pt);
1594 newline_and_indent (buffer, spc);
1595 if (get_ptr_info_alignment (pi, &align, &misalign))
1597 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1598 newline_and_indent (buffer, spc);
1600 pp_string (buffer, "# ");
1603 if (flags & TDF_RAW)
1604 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1605 gimple_phi_result (phi));
1606 else
1608 dump_generic_node (buffer, lhs, spc, flags, false);
1609 pp_string (buffer, " = PHI <");
1611 for (i = 0; i < gimple_phi_num_args (phi); i++)
1613 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1615 expanded_location xloc;
1617 xloc = expand_location (gimple_phi_arg_location (phi, i));
1618 pp_character (buffer, '[');
1619 if (xloc.file)
1621 pp_string (buffer, xloc.file);
1622 pp_string (buffer, " : ");
1624 pp_decimal_int (buffer, xloc.line);
1625 pp_string (buffer, ":");
1626 pp_decimal_int (buffer, xloc.column);
1627 pp_string (buffer, "] ");
1629 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1630 false);
1631 pp_character (buffer, '(');
1632 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1633 pp_character (buffer, ')');
1634 if (i < gimple_phi_num_args (phi) - 1)
1635 pp_string (buffer, ", ");
1637 pp_character (buffer, '>');
1641 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1642 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1643 dumpfile.h). */
1645 static void
1646 dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1647 int flags)
1649 if (flags & TDF_RAW)
1651 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1652 gimple_omp_body (gs));
1653 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1654 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1655 gimple_omp_parallel_child_fn (gs),
1656 gimple_omp_parallel_data_arg (gs));
1658 else
1660 gimple_seq body;
1661 pp_string (buffer, "#pragma omp parallel");
1662 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1663 if (gimple_omp_parallel_child_fn (gs))
1665 pp_string (buffer, " [child fn: ");
1666 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1667 spc, flags, false);
1668 pp_string (buffer, " (");
1669 if (gimple_omp_parallel_data_arg (gs))
1670 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1671 spc, flags, false);
1672 else
1673 pp_string (buffer, "???");
1674 pp_string (buffer, ")]");
1676 body = gimple_omp_body (gs);
1677 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1679 newline_and_indent (buffer, spc + 2);
1680 pp_character (buffer, '{');
1681 pp_newline (buffer);
1682 dump_gimple_seq (buffer, body, spc + 4, flags);
1683 newline_and_indent (buffer, spc + 2);
1684 pp_character (buffer, '}');
1686 else if (body)
1688 pp_newline (buffer);
1689 dump_gimple_seq (buffer, body, spc + 2, flags);
1695 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1696 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1697 dumpfile.h). */
1699 static void
1700 dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
1701 int flags)
1703 if (flags & TDF_RAW)
1705 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1706 gimple_omp_body (gs));
1707 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1708 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1709 gimple_omp_task_child_fn (gs),
1710 gimple_omp_task_data_arg (gs),
1711 gimple_omp_task_copy_fn (gs),
1712 gimple_omp_task_arg_size (gs),
1713 gimple_omp_task_arg_size (gs));
1715 else
1717 gimple_seq body;
1718 pp_string (buffer, "#pragma omp task");
1719 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1720 if (gimple_omp_task_child_fn (gs))
1722 pp_string (buffer, " [child fn: ");
1723 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1724 spc, flags, false);
1725 pp_string (buffer, " (");
1726 if (gimple_omp_task_data_arg (gs))
1727 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1728 spc, flags, false);
1729 else
1730 pp_string (buffer, "???");
1731 pp_string (buffer, ")]");
1733 body = gimple_omp_body (gs);
1734 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1736 newline_and_indent (buffer, spc + 2);
1737 pp_character (buffer, '{');
1738 pp_newline (buffer);
1739 dump_gimple_seq (buffer, body, spc + 4, flags);
1740 newline_and_indent (buffer, spc + 2);
1741 pp_character (buffer, '}');
1743 else if (body)
1745 pp_newline (buffer);
1746 dump_gimple_seq (buffer, body, spc + 2, flags);
1752 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1753 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1754 in dumpfile.h). */
1756 static void
1757 dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
1758 int flags)
1760 if (flags & TDF_RAW)
1762 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1763 gimple_omp_atomic_load_lhs (gs),
1764 gimple_omp_atomic_load_rhs (gs));
1766 else
1768 pp_string (buffer, "#pragma omp atomic_load");
1769 if (gimple_omp_atomic_need_value_p (gs))
1770 pp_string (buffer, " [needed]");
1771 newline_and_indent (buffer, spc + 2);
1772 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
1773 spc, flags, false);
1774 pp_space (buffer);
1775 pp_character (buffer, '=');
1776 pp_space (buffer);
1777 pp_character (buffer, '*');
1778 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
1779 spc, flags, false);
1783 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1784 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1785 in dumpfile.h). */
1787 static void
1788 dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
1789 int flags)
1791 if (flags & TDF_RAW)
1793 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1794 gimple_omp_atomic_store_val (gs));
1796 else
1798 pp_string (buffer, "#pragma omp atomic_store ");
1799 if (gimple_omp_atomic_need_value_p (gs))
1800 pp_string (buffer, "[needed] ");
1801 pp_character (buffer, '(');
1802 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
1803 spc, flags, false);
1804 pp_character (buffer, ')');
1809 /* Dump all the memory operands for statement GS. BUFFER, SPC and
1810 FLAGS are as in pp_gimple_stmt_1. */
1812 static void
1813 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
1815 tree vdef = gimple_vdef (gs);
1816 tree vuse = gimple_vuse (gs);
1818 if (!ssa_operands_active (DECL_STRUCT_FUNCTION (current_function_decl))
1819 || !gimple_references_memory_p (gs))
1820 return;
1822 if (vdef != NULL_TREE)
1824 pp_string (buffer, "# ");
1825 dump_generic_node (buffer, vdef, spc + 2, flags, false);
1826 pp_string (buffer, " = VDEF <");
1827 dump_generic_node (buffer, vuse, spc + 2, flags, false);
1828 pp_character (buffer, '>');
1829 newline_and_indent (buffer, spc);
1831 else if (vuse != NULL_TREE)
1833 pp_string (buffer, "# VUSE <");
1834 dump_generic_node (buffer, vuse, spc + 2, flags, false);
1835 pp_character (buffer, '>');
1836 newline_and_indent (buffer, spc);
1841 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
1842 spaces of indent. FLAGS specifies details to show in the dump (see
1843 TDF_* in dumpfile.h). The caller is responsible for calling
1844 pp_flush on BUFFER to finalize the pretty printer. */
1846 void
1847 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
1849 if (!gs)
1850 return;
1852 if (flags & TDF_STMTADDR)
1853 pp_printf (buffer, "<&%p> ", (void *) gs);
1855 if ((flags & TDF_LINENO) && gimple_has_location (gs))
1857 expanded_location xloc = expand_location (gimple_location (gs));
1858 pp_character (buffer, '[');
1859 if (xloc.file)
1861 pp_string (buffer, xloc.file);
1862 pp_string (buffer, " : ");
1864 pp_decimal_int (buffer, xloc.line);
1865 pp_string (buffer, ":");
1866 pp_decimal_int (buffer, xloc.column);
1867 pp_string (buffer, "] ");
1870 if (flags & TDF_EH)
1872 int lp_nr = lookup_stmt_eh_lp (gs);
1873 if (lp_nr > 0)
1874 pp_printf (buffer, "[LP %d] ", lp_nr);
1875 else if (lp_nr < 0)
1876 pp_printf (buffer, "[MNT %d] ", -lp_nr);
1879 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
1880 && gimple_has_mem_ops (gs))
1881 dump_gimple_mem_ops (buffer, gs, spc, flags);
1883 if ((flags & TDF_ALIAS)
1884 && gimple_has_lhs (gs))
1886 tree lhs = gimple_get_lhs (gs);
1887 if (TREE_CODE (lhs) == SSA_NAME
1888 && POINTER_TYPE_P (TREE_TYPE (lhs))
1889 && SSA_NAME_PTR_INFO (lhs))
1891 unsigned int align, misalign;
1892 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
1893 pp_string (buffer, "# PT = ");
1894 pp_points_to_solution (buffer, &pi->pt);
1895 newline_and_indent (buffer, spc);
1896 if (get_ptr_info_alignment (pi, &align, &misalign))
1898 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u",
1899 align, misalign);
1900 newline_and_indent (buffer, spc);
1905 switch (gimple_code (gs))
1907 case GIMPLE_ASM:
1908 dump_gimple_asm (buffer, gs, spc, flags);
1909 break;
1911 case GIMPLE_ASSIGN:
1912 dump_gimple_assign (buffer, gs, spc, flags);
1913 break;
1915 case GIMPLE_BIND:
1916 dump_gimple_bind (buffer, gs, spc, flags);
1917 break;
1919 case GIMPLE_CALL:
1920 dump_gimple_call (buffer, gs, spc, flags);
1921 break;
1923 case GIMPLE_COND:
1924 dump_gimple_cond (buffer, gs, spc, flags);
1925 break;
1927 case GIMPLE_LABEL:
1928 dump_gimple_label (buffer, gs, spc, flags);
1929 break;
1931 case GIMPLE_GOTO:
1932 dump_gimple_goto (buffer, gs, spc, flags);
1933 break;
1935 case GIMPLE_NOP:
1936 pp_string (buffer, "GIMPLE_NOP");
1937 break;
1939 case GIMPLE_RETURN:
1940 dump_gimple_return (buffer, gs, spc, flags);
1941 break;
1943 case GIMPLE_SWITCH:
1944 dump_gimple_switch (buffer, gs, spc, flags);
1945 break;
1947 case GIMPLE_TRY:
1948 dump_gimple_try (buffer, gs, spc, flags);
1949 break;
1951 case GIMPLE_PHI:
1952 dump_gimple_phi (buffer, gs, spc, flags);
1953 break;
1955 case GIMPLE_OMP_PARALLEL:
1956 dump_gimple_omp_parallel (buffer, gs, spc, flags);
1957 break;
1959 case GIMPLE_OMP_TASK:
1960 dump_gimple_omp_task (buffer, gs, spc, flags);
1961 break;
1963 case GIMPLE_OMP_ATOMIC_LOAD:
1964 dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
1966 break;
1968 case GIMPLE_OMP_ATOMIC_STORE:
1969 dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
1970 break;
1972 case GIMPLE_OMP_FOR:
1973 dump_gimple_omp_for (buffer, gs, spc, flags);
1974 break;
1976 case GIMPLE_OMP_CONTINUE:
1977 dump_gimple_omp_continue (buffer, gs, spc, flags);
1978 break;
1980 case GIMPLE_OMP_SINGLE:
1981 dump_gimple_omp_single (buffer, gs, spc, flags);
1982 break;
1984 case GIMPLE_OMP_RETURN:
1985 dump_gimple_omp_return (buffer, gs, spc, flags);
1986 break;
1988 case GIMPLE_OMP_SECTIONS:
1989 dump_gimple_omp_sections (buffer, gs, spc, flags);
1990 break;
1992 case GIMPLE_OMP_SECTIONS_SWITCH:
1993 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
1994 break;
1996 case GIMPLE_OMP_MASTER:
1997 case GIMPLE_OMP_ORDERED:
1998 case GIMPLE_OMP_SECTION:
1999 dump_gimple_omp_block (buffer, gs, spc, flags);
2000 break;
2002 case GIMPLE_OMP_CRITICAL:
2003 dump_gimple_omp_critical (buffer, gs, spc, flags);
2004 break;
2006 case GIMPLE_CATCH:
2007 dump_gimple_catch (buffer, gs, spc, flags);
2008 break;
2010 case GIMPLE_EH_FILTER:
2011 dump_gimple_eh_filter (buffer, gs, spc, flags);
2012 break;
2014 case GIMPLE_EH_MUST_NOT_THROW:
2015 dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
2016 break;
2018 case GIMPLE_EH_ELSE:
2019 dump_gimple_eh_else (buffer, gs, spc, flags);
2020 break;
2022 case GIMPLE_RESX:
2023 dump_gimple_resx (buffer, gs, spc, flags);
2024 break;
2026 case GIMPLE_EH_DISPATCH:
2027 dump_gimple_eh_dispatch (buffer, gs, spc, flags);
2028 break;
2030 case GIMPLE_DEBUG:
2031 dump_gimple_debug (buffer, gs, spc, flags);
2032 break;
2034 case GIMPLE_PREDICT:
2035 pp_string (buffer, "// predicted ");
2036 if (gimple_predict_outcome (gs))
2037 pp_string (buffer, "likely by ");
2038 else
2039 pp_string (buffer, "unlikely by ");
2040 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2041 pp_string (buffer, " predictor.");
2042 break;
2044 case GIMPLE_TRANSACTION:
2045 dump_gimple_transaction (buffer, gs, spc, flags);
2046 break;
2048 default:
2049 GIMPLE_NIY;
2052 /* If we're building a diagnostic, the formatted text will be
2053 written into BUFFER's stream by the caller; otherwise, write it
2054 now. */
2055 if (!(flags & TDF_DIAGNOSTIC))
2056 pp_write_text_to_stream (buffer);
2060 /* Dumps header of basic block BB to OUTF indented by INDENT
2061 spaces and details described by flags. */
2063 static void
2064 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2066 if (flags & TDF_BLOCKS)
2068 if (flags & TDF_LINENO)
2070 gimple_stmt_iterator gsi;
2072 if (flags & TDF_COMMENT)
2073 fputs (";; ", outf);
2075 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2076 if (!is_gimple_debug (gsi_stmt (gsi))
2077 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2079 fprintf (outf, "%*sstarting at line %d",
2080 indent, "", get_lineno (gsi_stmt (gsi)));
2081 break;
2083 if (bb->discriminator)
2084 fprintf (outf, ", discriminator %i", bb->discriminator);
2085 fputc ('\n', outf);
2088 else
2090 gimple stmt = first_stmt (bb);
2091 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2092 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2097 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2098 spaces. */
2100 static void
2101 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2102 basic_block bb ATTRIBUTE_UNUSED,
2103 int indent ATTRIBUTE_UNUSED,
2104 int flags ATTRIBUTE_UNUSED)
2106 /* There is currently no GIMPLE-specific basic block info to dump. */
2107 return;
2111 /* Dump PHI nodes of basic block BB to BUFFER with details described
2112 by FLAGS and indented by INDENT spaces. */
2114 static void
2115 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2117 gimple_stmt_iterator i;
2119 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2121 gimple phi = gsi_stmt (i);
2122 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2124 INDENT (indent);
2125 pp_string (buffer, "# ");
2126 dump_gimple_phi (buffer, phi, indent, flags);
2127 pp_newline (buffer);
2133 /* Dump jump to basic block BB that is represented implicitly in the cfg
2134 to BUFFER. */
2136 static void
2137 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2139 gimple stmt;
2141 stmt = first_stmt (bb);
2143 pp_string (buffer, "goto <bb ");
2144 pp_decimal_int (buffer, bb->index);
2145 pp_character (buffer, '>');
2146 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2148 pp_string (buffer, " (");
2149 dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
2150 pp_character (buffer, ')');
2151 pp_semicolon (buffer);
2153 else
2154 pp_semicolon (buffer);
2158 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2159 by INDENT spaces, with details given by FLAGS. */
2161 static void
2162 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2163 int flags)
2165 edge e;
2166 gimple stmt;
2168 stmt = last_stmt (bb);
2170 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2172 edge true_edge, false_edge;
2174 /* When we are emitting the code or changing CFG, it is possible that
2175 the edges are not yet created. When we are using debug_bb in such
2176 a situation, we do not want it to crash. */
2177 if (EDGE_COUNT (bb->succs) != 2)
2178 return;
2179 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2181 INDENT (indent + 2);
2182 pp_cfg_jump (buffer, true_edge->dest);
2183 newline_and_indent (buffer, indent);
2184 pp_string (buffer, "else");
2185 newline_and_indent (buffer, indent + 2);
2186 pp_cfg_jump (buffer, false_edge->dest);
2187 pp_newline (buffer);
2188 return;
2191 /* If there is a fallthru edge, we may need to add an artificial
2192 goto to the dump. */
2193 e = find_fallthru_edge (bb->succs);
2195 if (e && e->dest != bb->next_bb)
2197 INDENT (indent);
2199 if ((flags & TDF_LINENO)
2200 && e->goto_locus != UNKNOWN_LOCATION
2203 expanded_location goto_xloc;
2204 goto_xloc = expand_location (e->goto_locus);
2205 pp_character (buffer, '[');
2206 if (goto_xloc.file)
2208 pp_string (buffer, goto_xloc.file);
2209 pp_string (buffer, " : ");
2211 pp_decimal_int (buffer, goto_xloc.line);
2212 pp_string (buffer, " : ");
2213 pp_decimal_int (buffer, goto_xloc.column);
2214 pp_string (buffer, "] ");
2217 pp_cfg_jump (buffer, e->dest);
2218 pp_newline (buffer);
2223 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2224 indented by INDENT spaces. */
2226 static void
2227 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2228 int flags)
2230 gimple_stmt_iterator gsi;
2231 gimple stmt;
2232 int label_indent = indent - 2;
2234 if (label_indent < 0)
2235 label_indent = 0;
2237 dump_phi_nodes (buffer, bb, indent, flags);
2239 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2241 int curr_indent;
2243 stmt = gsi_stmt (gsi);
2245 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2247 INDENT (curr_indent);
2248 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2249 pp_newline_and_flush (buffer);
2250 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2251 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2252 buffer->buffer->stream, stmt);
2255 dump_implicit_edges (buffer, bb, indent, flags);
2256 pp_flush (buffer);
2260 /* Dumps basic block BB to FILE with details described by FLAGS and
2261 indented by INDENT spaces. */
2263 void
2264 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2266 dump_gimple_bb_header (file, bb, indent, flags);
2267 if (bb->index >= NUM_FIXED_BLOCKS)
2269 maybe_init_pretty_print (file);
2270 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2272 dump_gimple_bb_footer (file, bb, indent, flags);