Remove unused variable and field
[official-gcc.git] / gcc / gimple-pretty-print.c
blob1d4068079ec6fdeeb2d5a0c0527447b1d315a765
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Contributed by Aldy Hernandez <aldyh@redhat.com> and
4 Diego Novillo <dnovillo@google.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
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 "diagnostic.h"
28 #include "gimple-pretty-print.h"
29 #include "hashtab.h"
30 #include "tree-flow.h"
31 #include "dumpfile.h" /* for dump_flags */
32 #include "gimple.h"
33 #include "value-prof.h"
34 #include "trans-mem.h"
36 #define INDENT(SPACE) \
37 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
39 #define GIMPLE_NIY do_niy (buffer,gs)
41 /* Try to print on BUFFER a default message for the unrecognized
42 gimple statement GS. */
44 static void
45 do_niy (pretty_printer *buffer, gimple gs)
47 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
48 gimple_code_name[(int) gimple_code (gs)]);
52 /* Emit a newline and SPC indentation spaces to BUFFER. */
54 static void
55 newline_and_indent (pretty_printer *buffer, int spc)
57 pp_newline (buffer);
58 INDENT (spc);
62 /* Print the GIMPLE statement GS on stderr. */
64 DEBUG_FUNCTION void
65 debug_gimple_stmt (gimple gs)
67 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
71 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
72 FLAGS as in pp_gimple_stmt_1. */
74 void
75 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
77 pretty_printer buffer;
78 pp_construct (&buffer, NULL, 0);
79 pp_needs_newline (&buffer) = true;
80 buffer.buffer->stream = file;
81 pp_gimple_stmt_1 (&buffer, g, spc, flags);
82 pp_newline_and_flush (&buffer);
85 DEBUG_FUNCTION void
86 debug (gimple_statement_d &ref)
88 print_gimple_stmt (stderr, &ref, 0, 0);
91 DEBUG_FUNCTION void
92 debug (gimple_statement_d *ptr)
94 if (ptr)
95 debug (*ptr);
96 else
97 fprintf (stderr, "<nil>\n");
101 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
102 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
103 of the statement. */
105 void
106 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
108 flags |= TDF_RHS_ONLY;
109 pretty_printer buffer;
110 pp_construct (&buffer, NULL, 0);
111 pp_needs_newline (&buffer) = true;
112 buffer.buffer->stream = file;
113 pp_gimple_stmt_1 (&buffer, g, spc, flags);
114 pp_flush (&buffer);
118 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
119 spaces and FLAGS as in pp_gimple_stmt_1.
120 The caller is responsible for calling pp_flush on BUFFER to finalize
121 the pretty printer. */
123 static void
124 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
126 gimple_stmt_iterator i;
128 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
130 gimple gs = gsi_stmt (i);
131 INDENT (spc);
132 pp_gimple_stmt_1 (buffer, gs, spc, flags);
133 if (!gsi_one_before_end_p (i))
134 pp_newline (buffer);
139 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
140 FLAGS as in pp_gimple_stmt_1. */
142 void
143 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
145 pretty_printer buffer;
146 pp_construct (&buffer, NULL, 0);
147 pp_needs_newline (&buffer) = true;
148 buffer.buffer->stream = file;
149 dump_gimple_seq (&buffer, seq, spc, flags);
150 pp_newline_and_flush (&buffer);
154 /* Print the GIMPLE sequence SEQ on stderr. */
156 DEBUG_FUNCTION void
157 debug_gimple_seq (gimple_seq seq)
159 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
163 /* A simple helper to pretty-print some of the gimple tuples in the printf
164 style. The format modifiers are preceded by '%' and are:
165 'G' - outputs a string corresponding to the code of the given gimple,
166 'S' - outputs a gimple_seq with indent of spc + 2,
167 'T' - outputs the tree t,
168 'd' - outputs an int as a decimal,
169 's' - outputs a string,
170 'n' - outputs a newline,
171 'x' - outputs an int as hexadecimal,
172 '+' - increases indent by 2 then outputs a newline,
173 '-' - decreases indent by 2 then outputs a newline. */
175 static void
176 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
177 const char *fmt, ...)
179 va_list args;
180 const char *c;
181 const char *tmp;
183 va_start (args, fmt);
184 for (c = fmt; *c; c++)
186 if (*c == '%')
188 gimple_seq seq;
189 tree t;
190 gimple g;
191 switch (*++c)
193 case 'G':
194 g = va_arg (args, gimple);
195 tmp = gimple_code_name[gimple_code (g)];
196 pp_string (buffer, tmp);
197 break;
199 case 'S':
200 seq = va_arg (args, gimple_seq);
201 pp_newline (buffer);
202 dump_gimple_seq (buffer, seq, spc + 2, flags);
203 newline_and_indent (buffer, spc);
204 break;
206 case 'T':
207 t = va_arg (args, tree);
208 if (t == NULL_TREE)
209 pp_string (buffer, "NULL");
210 else
211 dump_generic_node (buffer, t, spc, flags, false);
212 break;
214 case 'd':
215 pp_decimal_int (buffer, va_arg (args, int));
216 break;
218 case 's':
219 pp_string (buffer, va_arg (args, char *));
220 break;
222 case 'n':
223 newline_and_indent (buffer, spc);
224 break;
226 case 'x':
227 pp_scalar (buffer, "%x", va_arg (args, int));
228 break;
230 case '+':
231 spc += 2;
232 newline_and_indent (buffer, spc);
233 break;
235 case '-':
236 spc -= 2;
237 newline_and_indent (buffer, spc);
238 break;
240 default:
241 gcc_unreachable ();
244 else
245 pp_character (buffer, *c);
247 va_end (args);
251 /* Helper for dump_gimple_assign. Print the unary RHS of the
252 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
254 static void
255 dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
257 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
258 tree lhs = gimple_assign_lhs (gs);
259 tree rhs = gimple_assign_rhs1 (gs);
261 switch (rhs_code)
263 case VIEW_CONVERT_EXPR:
264 case ASSERT_EXPR:
265 dump_generic_node (buffer, rhs, spc, flags, false);
266 break;
268 case FIXED_CONVERT_EXPR:
269 case ADDR_SPACE_CONVERT_EXPR:
270 case FIX_TRUNC_EXPR:
271 case FLOAT_EXPR:
272 CASE_CONVERT:
273 pp_left_paren (buffer);
274 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
275 pp_string (buffer, ") ");
276 if (op_prio (rhs) < op_code_prio (rhs_code))
278 pp_left_paren (buffer);
279 dump_generic_node (buffer, rhs, spc, flags, false);
280 pp_right_paren (buffer);
282 else
283 dump_generic_node (buffer, rhs, spc, flags, false);
284 break;
286 case PAREN_EXPR:
287 pp_string (buffer, "((");
288 dump_generic_node (buffer, rhs, spc, flags, false);
289 pp_string (buffer, "))");
290 break;
292 case ABS_EXPR:
293 pp_string (buffer, "ABS_EXPR <");
294 dump_generic_node (buffer, rhs, spc, flags, false);
295 pp_greater (buffer);
296 break;
298 default:
299 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
300 || TREE_CODE_CLASS (rhs_code) == tcc_constant
301 || TREE_CODE_CLASS (rhs_code) == tcc_reference
302 || rhs_code == SSA_NAME
303 || rhs_code == ADDR_EXPR
304 || rhs_code == CONSTRUCTOR)
306 dump_generic_node (buffer, rhs, spc, flags, false);
307 break;
309 else if (rhs_code == BIT_NOT_EXPR)
310 pp_complement (buffer);
311 else if (rhs_code == TRUTH_NOT_EXPR)
312 pp_exclamation (buffer);
313 else if (rhs_code == NEGATE_EXPR)
314 pp_minus (buffer);
315 else
317 pp_left_bracket (buffer);
318 pp_string (buffer, tree_code_name [rhs_code]);
319 pp_string (buffer, "] ");
322 if (op_prio (rhs) < op_code_prio (rhs_code))
324 pp_left_paren (buffer);
325 dump_generic_node (buffer, rhs, spc, flags, false);
326 pp_right_paren (buffer);
328 else
329 dump_generic_node (buffer, rhs, spc, flags, false);
330 break;
335 /* Helper for dump_gimple_assign. Print the binary RHS of the
336 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
338 static void
339 dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
341 const char *p;
342 enum tree_code code = gimple_assign_rhs_code (gs);
343 switch (code)
345 case COMPLEX_EXPR:
346 case MIN_EXPR:
347 case MAX_EXPR:
348 case VEC_WIDEN_MULT_HI_EXPR:
349 case VEC_WIDEN_MULT_LO_EXPR:
350 case VEC_WIDEN_MULT_EVEN_EXPR:
351 case VEC_WIDEN_MULT_ODD_EXPR:
352 case VEC_PACK_TRUNC_EXPR:
353 case VEC_PACK_SAT_EXPR:
354 case VEC_PACK_FIX_TRUNC_EXPR:
355 case VEC_WIDEN_LSHIFT_HI_EXPR:
356 case VEC_WIDEN_LSHIFT_LO_EXPR:
357 for (p = tree_code_name [(int) code]; *p; p++)
358 pp_character (buffer, TOUPPER (*p));
359 pp_string (buffer, " <");
360 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
361 pp_string (buffer, ", ");
362 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
363 pp_greater (buffer);
364 break;
366 default:
367 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
369 pp_left_paren (buffer);
370 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
371 false);
372 pp_right_paren (buffer);
374 else
375 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
376 pp_space (buffer);
377 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
378 pp_space (buffer);
379 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
381 pp_left_paren (buffer);
382 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
383 false);
384 pp_right_paren (buffer);
386 else
387 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
391 /* Helper for dump_gimple_assign. Print the ternary RHS of the
392 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
394 static void
395 dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
397 const char *p;
398 enum tree_code code = gimple_assign_rhs_code (gs);
399 switch (code)
401 case WIDEN_MULT_PLUS_EXPR:
402 case WIDEN_MULT_MINUS_EXPR:
403 for (p = tree_code_name [(int) code]; *p; p++)
404 pp_character (buffer, TOUPPER (*p));
405 pp_string (buffer, " <");
406 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
407 pp_string (buffer, ", ");
408 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
409 pp_string (buffer, ", ");
410 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
411 pp_greater (buffer);
412 break;
414 case FMA_EXPR:
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 break;
422 case DOT_PROD_EXPR:
423 pp_string (buffer, "DOT_PROD_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 pp_greater (buffer);
430 break;
432 case VEC_PERM_EXPR:
433 pp_string (buffer, "VEC_PERM_EXPR <");
434 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
435 pp_string (buffer, ", ");
436 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
437 pp_string (buffer, ", ");
438 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
439 pp_greater (buffer);
440 break;
442 case REALIGN_LOAD_EXPR:
443 pp_string (buffer, "REALIGN_LOAD <");
444 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
445 pp_string (buffer, ", ");
446 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
447 pp_string (buffer, ", ");
448 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
449 pp_greater (buffer);
450 break;
452 case COND_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 break;
460 case VEC_COND_EXPR:
461 pp_string (buffer, "VEC_COND_EXPR <");
462 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
463 pp_string (buffer, ", ");
464 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
465 pp_string (buffer, ", ");
466 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
467 pp_greater (buffer);
468 break;
470 default:
471 gcc_unreachable ();
476 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
477 pp_gimple_stmt_1. */
479 static void
480 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
482 if (flags & TDF_RAW)
484 tree arg1 = NULL;
485 tree arg2 = NULL;
486 tree arg3 = NULL;
487 switch (gimple_num_ops (gs))
489 case 4:
490 arg3 = gimple_assign_rhs3 (gs);
491 case 3:
492 arg2 = gimple_assign_rhs2 (gs);
493 case 2:
494 arg1 = gimple_assign_rhs1 (gs);
495 break;
496 default:
497 gcc_unreachable ();
500 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
501 tree_code_name[gimple_assign_rhs_code (gs)],
502 gimple_assign_lhs (gs), arg1, arg2, arg3);
504 else
506 if (!(flags & TDF_RHS_ONLY))
508 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
509 pp_space (buffer);
510 pp_equal (buffer);
512 if (gimple_assign_nontemporal_move_p (gs))
513 pp_string (buffer, "{nt}");
515 if (gimple_has_volatile_ops (gs))
516 pp_string (buffer, "{v}");
518 pp_space (buffer);
521 if (gimple_num_ops (gs) == 2)
522 dump_unary_rhs (buffer, gs, spc, flags);
523 else if (gimple_num_ops (gs) == 3)
524 dump_binary_rhs (buffer, gs, spc, flags);
525 else if (gimple_num_ops (gs) == 4)
526 dump_ternary_rhs (buffer, gs, spc, flags);
527 else
528 gcc_unreachable ();
529 if (!(flags & TDF_RHS_ONLY))
530 pp_semicolon(buffer);
535 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
536 pp_gimple_stmt_1. */
538 static void
539 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
541 tree t;
543 t = gimple_return_retval (gs);
544 if (flags & TDF_RAW)
545 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
546 else
548 pp_string (buffer, "return");
549 if (t)
551 pp_space (buffer);
552 dump_generic_node (buffer, t, spc, flags, false);
554 pp_semicolon (buffer);
559 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
560 dump_gimple_call. */
562 static void
563 dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags)
565 size_t i;
567 for (i = 0; i < gimple_call_num_args (gs); i++)
569 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
570 if (i < gimple_call_num_args (gs) - 1)
571 pp_string (buffer, ", ");
574 if (gimple_call_va_arg_pack_p (gs))
576 if (gimple_call_num_args (gs) > 0)
578 pp_comma (buffer);
579 pp_space (buffer);
582 pp_string (buffer, "__builtin_va_arg_pack ()");
586 /* Dump the points-to solution *PT to BUFFER. */
588 static void
589 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
591 if (pt->anything)
593 pp_string (buffer, "anything ");
594 return;
596 if (pt->nonlocal)
597 pp_string (buffer, "nonlocal ");
598 if (pt->escaped)
599 pp_string (buffer, "escaped ");
600 if (pt->ipa_escaped)
601 pp_string (buffer, "unit-escaped ");
602 if (pt->null)
603 pp_string (buffer, "null ");
604 if (pt->vars
605 && !bitmap_empty_p (pt->vars))
607 bitmap_iterator bi;
608 unsigned i;
609 pp_string (buffer, "{ ");
610 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
612 pp_string (buffer, "D.");
613 pp_decimal_int (buffer, i);
614 pp_space (buffer);
616 pp_right_brace (buffer);
617 if (pt->vars_contains_global)
618 pp_string (buffer, " (glob)");
622 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
623 pp_gimple_stmt_1. */
625 static void
626 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
628 tree lhs = gimple_call_lhs (gs);
629 tree fn = gimple_call_fn (gs);
631 if (flags & TDF_ALIAS)
633 struct pt_solution *pt;
634 pt = gimple_call_use_set (gs);
635 if (!pt_solution_empty_p (pt))
637 pp_string (buffer, "# USE = ");
638 pp_points_to_solution (buffer, pt);
639 newline_and_indent (buffer, spc);
641 pt = gimple_call_clobber_set (gs);
642 if (!pt_solution_empty_p (pt))
644 pp_string (buffer, "# CLB = ");
645 pp_points_to_solution (buffer, pt);
646 newline_and_indent (buffer, spc);
650 if (flags & TDF_RAW)
652 if (gimple_call_internal_p (gs))
653 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
654 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
655 else
656 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
657 if (gimple_call_num_args (gs) > 0)
659 pp_string (buffer, ", ");
660 dump_gimple_call_args (buffer, gs, flags);
662 pp_greater (buffer);
664 else
666 if (lhs && !(flags & TDF_RHS_ONLY))
668 dump_generic_node (buffer, lhs, spc, flags, false);
669 pp_string (buffer, " =");
671 if (gimple_has_volatile_ops (gs))
672 pp_string (buffer, "{v}");
674 pp_space (buffer);
676 if (gimple_call_internal_p (gs))
677 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
678 else
679 print_call_name (buffer, fn, flags);
680 pp_string (buffer, " (");
681 dump_gimple_call_args (buffer, gs, flags);
682 pp_right_paren (buffer);
683 if (!(flags & TDF_RHS_ONLY))
684 pp_semicolon (buffer);
687 if (gimple_call_chain (gs))
689 pp_string (buffer, " [static-chain: ");
690 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
691 pp_right_bracket (buffer);
694 if (gimple_call_return_slot_opt_p (gs))
695 pp_string (buffer, " [return slot optimization]");
696 if (gimple_call_tail_p (gs))
697 pp_string (buffer, " [tail call]");
699 if (fn == NULL)
700 return;
702 /* Dump the arguments of _ITM_beginTransaction sanely. */
703 if (TREE_CODE (fn) == ADDR_EXPR)
704 fn = TREE_OPERAND (fn, 0);
705 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
706 pp_string (buffer, " [tm-clone]");
707 if (TREE_CODE (fn) == FUNCTION_DECL
708 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
709 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
710 && gimple_call_num_args (gs) > 0)
712 tree t = gimple_call_arg (gs, 0);
713 unsigned HOST_WIDE_INT props;
714 gcc_assert (TREE_CODE (t) == INTEGER_CST);
716 pp_string (buffer, " [ ");
718 /* Get the transaction code properties. */
719 props = TREE_INT_CST_LOW (t);
721 if (props & PR_INSTRUMENTEDCODE)
722 pp_string (buffer, "instrumentedCode ");
723 if (props & PR_UNINSTRUMENTEDCODE)
724 pp_string (buffer, "uninstrumentedCode ");
725 if (props & PR_HASNOXMMUPDATE)
726 pp_string (buffer, "hasNoXMMUpdate ");
727 if (props & PR_HASNOABORT)
728 pp_string (buffer, "hasNoAbort ");
729 if (props & PR_HASNOIRREVOCABLE)
730 pp_string (buffer, "hasNoIrrevocable ");
731 if (props & PR_DOESGOIRREVOCABLE)
732 pp_string (buffer, "doesGoIrrevocable ");
733 if (props & PR_HASNOSIMPLEREADS)
734 pp_string (buffer, "hasNoSimpleReads ");
735 if (props & PR_AWBARRIERSOMITTED)
736 pp_string (buffer, "awBarriersOmitted ");
737 if (props & PR_RARBARRIERSOMITTED)
738 pp_string (buffer, "RaRBarriersOmitted ");
739 if (props & PR_UNDOLOGCODE)
740 pp_string (buffer, "undoLogCode ");
741 if (props & PR_PREFERUNINSTRUMENTED)
742 pp_string (buffer, "preferUninstrumented ");
743 if (props & PR_EXCEPTIONBLOCK)
744 pp_string (buffer, "exceptionBlock ");
745 if (props & PR_HASELSE)
746 pp_string (buffer, "hasElse ");
747 if (props & PR_READONLY)
748 pp_string (buffer, "readOnly ");
750 pp_right_bracket (buffer);
755 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
756 pp_gimple_stmt_1. */
758 static void
759 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
761 unsigned int i;
763 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
764 if (flags & TDF_RAW)
765 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
766 gimple_switch_index (gs));
767 else
769 pp_string (buffer, "switch (");
770 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
771 pp_string (buffer, ") <");
774 for (i = 0; i < gimple_switch_num_labels (gs); i++)
776 tree case_label = gimple_switch_label (gs, i);
777 gcc_checking_assert (case_label != NULL_TREE);
778 dump_generic_node (buffer, case_label, spc, flags, false);
779 pp_space (buffer);
780 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
781 if (i < gimple_switch_num_labels (gs) - 1)
782 pp_string (buffer, ", ");
784 pp_greater (buffer);
788 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
789 pp_gimple_stmt_1. */
791 static void
792 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
794 if (flags & TDF_RAW)
795 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
796 tree_code_name [gimple_cond_code (gs)],
797 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
798 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
799 else
801 if (!(flags & TDF_RHS_ONLY))
802 pp_string (buffer, "if (");
803 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
804 pp_space (buffer);
805 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
806 pp_space (buffer);
807 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
808 if (!(flags & TDF_RHS_ONLY))
810 pp_right_paren (buffer);
812 if (gimple_cond_true_label (gs))
814 pp_string (buffer, " goto ");
815 dump_generic_node (buffer, gimple_cond_true_label (gs),
816 spc, flags, false);
817 pp_semicolon (buffer);
819 if (gimple_cond_false_label (gs))
821 pp_string (buffer, " else goto ");
822 dump_generic_node (buffer, gimple_cond_false_label (gs),
823 spc, flags, false);
824 pp_semicolon (buffer);
831 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
832 spaces of indent. FLAGS specifies details to show in the dump (see
833 TDF_* in dumpfils.h). */
835 static void
836 dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
838 tree label = gimple_label_label (gs);
839 if (flags & TDF_RAW)
840 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
841 else
843 dump_generic_node (buffer, label, spc, flags, false);
844 pp_colon (buffer);
846 if (DECL_NONLOCAL (label))
847 pp_string (buffer, " [non-local]");
848 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
849 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
852 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
853 spaces of indent. FLAGS specifies details to show in the dump (see
854 TDF_* in dumpfile.h). */
856 static void
857 dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
859 tree label = gimple_goto_dest (gs);
860 if (flags & TDF_RAW)
861 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
862 else
863 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
867 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
868 spaces of indent. FLAGS specifies details to show in the dump (see
869 TDF_* in dumpfile.h). */
871 static void
872 dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
874 if (flags & TDF_RAW)
875 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
876 else
877 pp_left_brace (buffer);
878 if (!(flags & TDF_SLIM))
880 tree var;
882 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
884 newline_and_indent (buffer, 2);
885 print_declaration (buffer, var, spc, flags);
887 if (gimple_bind_vars (gs))
888 pp_newline (buffer);
890 pp_newline (buffer);
891 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
892 newline_and_indent (buffer, spc);
893 if (flags & TDF_RAW)
894 pp_greater (buffer);
895 else
896 pp_right_brace (buffer);
900 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
901 indent. FLAGS specifies details to show in the dump (see TDF_* in
902 dumpfile.h). */
904 static void
905 dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
907 if (flags & TDF_RAW)
909 const char *type;
910 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
911 type = "GIMPLE_TRY_CATCH";
912 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
913 type = "GIMPLE_TRY_FINALLY";
914 else
915 type = "UNKNOWN GIMPLE_TRY";
916 dump_gimple_fmt (buffer, spc, flags,
917 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
918 gimple_try_eval (gs), gimple_try_cleanup (gs));
920 else
922 pp_string (buffer, "try");
923 newline_and_indent (buffer, spc + 2);
924 pp_left_brace (buffer);
925 pp_newline (buffer);
927 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
928 newline_and_indent (buffer, spc + 2);
929 pp_right_brace (buffer);
931 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
933 newline_and_indent (buffer, spc);
934 pp_string (buffer, "catch");
935 newline_and_indent (buffer, spc + 2);
936 pp_left_brace (buffer);
938 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
940 newline_and_indent (buffer, spc);
941 pp_string (buffer, "finally");
942 newline_and_indent (buffer, spc + 2);
943 pp_left_brace (buffer);
945 else
946 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
948 pp_newline (buffer);
949 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
950 newline_and_indent (buffer, spc + 2);
951 pp_right_brace (buffer);
956 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
957 indent. FLAGS specifies details to show in the dump (see TDF_* in
958 dumpfile.h). */
960 static void
961 dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
963 if (flags & TDF_RAW)
964 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
965 gimple_catch_types (gs), gimple_catch_handler (gs));
966 else
967 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
968 gimple_catch_types (gs), gimple_catch_handler (gs));
972 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
973 indent. FLAGS specifies details to show in the dump (see TDF_* in
974 dumpfile.h). */
976 static void
977 dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
979 if (flags & TDF_RAW)
980 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
981 gimple_eh_filter_types (gs),
982 gimple_eh_filter_failure (gs));
983 else
984 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
985 gimple_eh_filter_types (gs),
986 gimple_eh_filter_failure (gs));
990 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
992 static void
993 dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
994 int spc, int flags)
996 if (flags & TDF_RAW)
997 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
998 gimple_eh_must_not_throw_fndecl (gs));
999 else
1000 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1001 gimple_eh_must_not_throw_fndecl (gs));
1005 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1006 indent. FLAGS specifies details to show in the dump (see TDF_* in
1007 dumpfile.h). */
1009 static void
1010 dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags)
1012 if (flags & TDF_RAW)
1013 dump_gimple_fmt (buffer, spc, flags,
1014 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1015 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1016 else
1017 dump_gimple_fmt (buffer, spc, flags,
1018 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1019 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1023 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1024 indent. FLAGS specifies details to show in the dump (see TDF_* in
1025 dumpfile.h). */
1027 static void
1028 dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
1030 if (flags & TDF_RAW)
1031 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1032 gimple_resx_region (gs));
1033 else
1034 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1037 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1039 static void
1040 dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
1042 if (flags & TDF_RAW)
1043 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1044 gimple_eh_dispatch_region (gs));
1045 else
1046 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1047 gimple_eh_dispatch_region (gs));
1050 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1051 of indent. FLAGS specifies details to show in the dump (see TDF_*
1052 in dumpfile.h). */
1054 static void
1055 dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
1057 switch (gs->gsbase.subcode)
1059 case GIMPLE_DEBUG_BIND:
1060 if (flags & TDF_RAW)
1061 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1062 gimple_debug_bind_get_var (gs),
1063 gimple_debug_bind_get_value (gs));
1064 else
1065 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1066 gimple_debug_bind_get_var (gs),
1067 gimple_debug_bind_get_value (gs));
1068 break;
1070 case GIMPLE_DEBUG_SOURCE_BIND:
1071 if (flags & TDF_RAW)
1072 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1073 gimple_debug_source_bind_get_var (gs),
1074 gimple_debug_source_bind_get_value (gs));
1075 else
1076 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1077 gimple_debug_source_bind_get_var (gs),
1078 gimple_debug_source_bind_get_value (gs));
1079 break;
1081 default:
1082 gcc_unreachable ();
1086 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1087 static void
1088 dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
1090 size_t i;
1092 if (flags & TDF_RAW)
1094 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1095 gimple_omp_body (gs));
1096 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1097 dump_gimple_fmt (buffer, spc, flags, " >,");
1098 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1099 dump_gimple_fmt (buffer, spc, flags,
1100 "%+%T, %T, %T, %s, %T,%n",
1101 gimple_omp_for_index (gs, i),
1102 gimple_omp_for_initial (gs, i),
1103 gimple_omp_for_final (gs, i),
1104 tree_code_name[gimple_omp_for_cond (gs, i)],
1105 gimple_omp_for_incr (gs, i));
1106 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1107 gimple_omp_for_pre_body (gs));
1109 else
1111 pp_string (buffer, "#pragma omp for");
1112 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1113 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1115 if (i)
1116 spc += 2;
1117 newline_and_indent (buffer, spc);
1118 pp_string (buffer, "for (");
1119 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1120 flags, false);
1121 pp_string (buffer, " = ");
1122 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1123 flags, false);
1124 pp_string (buffer, "; ");
1126 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1127 flags, false);
1128 pp_space (buffer);
1129 switch (gimple_omp_for_cond (gs, i))
1131 case LT_EXPR:
1132 pp_less (buffer);
1133 break;
1134 case GT_EXPR:
1135 pp_greater (buffer);
1136 break;
1137 case LE_EXPR:
1138 pp_less_equal (buffer);
1139 break;
1140 case GE_EXPR:
1141 pp_greater_equal (buffer);
1142 break;
1143 default:
1144 gcc_unreachable ();
1146 pp_space (buffer);
1147 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1148 flags, false);
1149 pp_string (buffer, "; ");
1151 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1152 flags, false);
1153 pp_string (buffer, " = ");
1154 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1155 flags, false);
1156 pp_right_paren (buffer);
1159 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1161 newline_and_indent (buffer, spc + 2);
1162 pp_left_brace (buffer);
1163 pp_newline (buffer);
1164 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1165 newline_and_indent (buffer, spc + 2);
1166 pp_right_brace (buffer);
1171 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1173 static void
1174 dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags)
1176 if (flags & TDF_RAW)
1178 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1179 gimple_omp_continue_control_def (gs),
1180 gimple_omp_continue_control_use (gs));
1182 else
1184 pp_string (buffer, "#pragma omp continue (");
1185 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1186 spc, flags, false);
1187 pp_comma (buffer);
1188 pp_space (buffer);
1189 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1190 spc, flags, false);
1191 pp_right_paren (buffer);
1195 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1197 static void
1198 dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, int flags)
1200 if (flags & TDF_RAW)
1202 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1203 gimple_omp_body (gs));
1204 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1205 dump_gimple_fmt (buffer, spc, flags, " >");
1207 else
1209 pp_string (buffer, "#pragma omp single");
1210 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1211 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1213 newline_and_indent (buffer, spc + 2);
1214 pp_left_brace (buffer);
1215 pp_newline (buffer);
1216 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1217 newline_and_indent (buffer, spc + 2);
1218 pp_right_brace (buffer);
1223 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1225 static void
1226 dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
1227 int flags)
1229 if (flags & TDF_RAW)
1231 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1232 gimple_omp_body (gs));
1233 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1234 dump_gimple_fmt (buffer, spc, flags, " >");
1236 else
1238 pp_string (buffer, "#pragma omp sections");
1239 if (gimple_omp_sections_control (gs))
1241 pp_string (buffer, " <");
1242 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1243 flags, false);
1244 pp_greater (buffer);
1246 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1247 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1249 newline_and_indent (buffer, spc + 2);
1250 pp_left_brace (buffer);
1251 pp_newline (buffer);
1252 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1253 newline_and_indent (buffer, spc + 2);
1254 pp_right_brace (buffer);
1259 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the pretty_printer
1260 BUFFER. */
1262 static void
1263 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1265 if (flags & TDF_RAW)
1266 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1267 gimple_omp_body (gs));
1268 else
1270 switch (gimple_code (gs))
1272 case GIMPLE_OMP_MASTER:
1273 pp_string (buffer, "#pragma omp master");
1274 break;
1275 case GIMPLE_OMP_ORDERED:
1276 pp_string (buffer, "#pragma omp ordered");
1277 break;
1278 case GIMPLE_OMP_SECTION:
1279 pp_string (buffer, "#pragma omp section");
1280 break;
1281 default:
1282 gcc_unreachable ();
1284 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1286 newline_and_indent (buffer, spc + 2);
1287 pp_left_brace (buffer);
1288 pp_newline (buffer);
1289 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1290 newline_and_indent (buffer, spc + 2);
1291 pp_right_brace (buffer);
1296 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1298 static void
1299 dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
1300 int flags)
1302 if (flags & TDF_RAW)
1303 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1304 gimple_omp_body (gs));
1305 else
1307 pp_string (buffer, "#pragma omp critical");
1308 if (gimple_omp_critical_name (gs))
1310 pp_string (buffer, " (");
1311 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1312 flags, false);
1313 pp_right_paren (buffer);
1315 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1317 newline_and_indent (buffer, spc + 2);
1318 pp_left_brace (buffer);
1319 pp_newline (buffer);
1320 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1321 newline_and_indent (buffer, spc + 2);
1322 pp_right_brace (buffer);
1327 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1329 static void
1330 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1332 if (flags & TDF_RAW)
1334 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d>", gs,
1335 (int) gimple_omp_return_nowait_p (gs));
1337 else
1339 pp_string (buffer, "#pragma omp return");
1340 if (gimple_omp_return_nowait_p (gs))
1341 pp_string (buffer, "(nowait)");
1345 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1347 static void
1348 dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags)
1350 unsigned subcode = gimple_transaction_subcode (gs);
1352 if (flags & TDF_RAW)
1354 dump_gimple_fmt (buffer, spc, flags,
1355 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1356 gs, subcode, gimple_transaction_label (gs),
1357 gimple_transaction_body (gs));
1359 else
1361 if (subcode & GTMA_IS_OUTER)
1362 pp_string (buffer, "__transaction_atomic [[outer]]");
1363 else if (subcode & GTMA_IS_RELAXED)
1364 pp_string (buffer, "__transaction_relaxed");
1365 else
1366 pp_string (buffer, "__transaction_atomic");
1367 subcode &= ~GTMA_DECLARATION_MASK;
1369 if (subcode || gimple_transaction_label (gs))
1371 pp_string (buffer, " //");
1372 if (gimple_transaction_label (gs))
1374 pp_string (buffer, " LABEL=");
1375 dump_generic_node (buffer, gimple_transaction_label (gs),
1376 spc, flags, false);
1378 if (subcode)
1380 pp_string (buffer, " SUBCODE=[ ");
1381 if (subcode & GTMA_HAVE_ABORT)
1383 pp_string (buffer, "GTMA_HAVE_ABORT ");
1384 subcode &= ~GTMA_HAVE_ABORT;
1386 if (subcode & GTMA_HAVE_LOAD)
1388 pp_string (buffer, "GTMA_HAVE_LOAD ");
1389 subcode &= ~GTMA_HAVE_LOAD;
1391 if (subcode & GTMA_HAVE_STORE)
1393 pp_string (buffer, "GTMA_HAVE_STORE ");
1394 subcode &= ~GTMA_HAVE_STORE;
1396 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1398 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1399 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1401 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1403 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1404 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1406 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1408 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1409 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1411 if (subcode)
1412 pp_printf (buffer, "0x%x ", subcode);
1413 pp_right_bracket (buffer);
1417 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1419 newline_and_indent (buffer, spc + 2);
1420 pp_left_brace (buffer);
1421 pp_newline (buffer);
1422 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1423 spc + 4, flags);
1424 newline_and_indent (buffer, spc + 2);
1425 pp_right_brace (buffer);
1430 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1431 indent. FLAGS specifies details to show in the dump (see TDF_* in
1432 dumpfile.h). */
1434 static void
1435 dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
1437 unsigned int i, n, f, fields;
1439 if (flags & TDF_RAW)
1441 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1442 gimple_asm_string (gs));
1444 n = gimple_asm_noutputs (gs);
1445 if (n)
1447 newline_and_indent (buffer, spc + 2);
1448 pp_string (buffer, "OUTPUT: ");
1449 for (i = 0; i < n; i++)
1451 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1452 spc, flags, false);
1453 if (i < n - 1)
1454 pp_string (buffer, ", ");
1458 n = gimple_asm_ninputs (gs);
1459 if (n)
1461 newline_and_indent (buffer, spc + 2);
1462 pp_string (buffer, "INPUT: ");
1463 for (i = 0; i < n; i++)
1465 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1466 spc, flags, false);
1467 if (i < n - 1)
1468 pp_string (buffer, ", ");
1472 n = gimple_asm_nclobbers (gs);
1473 if (n)
1475 newline_and_indent (buffer, spc + 2);
1476 pp_string (buffer, "CLOBBER: ");
1477 for (i = 0; i < n; i++)
1479 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1480 spc, flags, false);
1481 if (i < n - 1)
1482 pp_string (buffer, ", ");
1486 n = gimple_asm_nlabels (gs);
1487 if (n)
1489 newline_and_indent (buffer, spc + 2);
1490 pp_string (buffer, "LABEL: ");
1491 for (i = 0; i < n; i++)
1493 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1494 spc, flags, false);
1495 if (i < n - 1)
1496 pp_string (buffer, ", ");
1500 newline_and_indent (buffer, spc);
1501 pp_greater (buffer);
1503 else
1505 pp_string (buffer, "__asm__");
1506 if (gimple_asm_volatile_p (gs))
1507 pp_string (buffer, " __volatile__");
1508 if (gimple_asm_nlabels (gs))
1509 pp_string (buffer, " goto");
1510 pp_string (buffer, "(\"");
1511 pp_string (buffer, gimple_asm_string (gs));
1512 pp_string (buffer, "\"");
1514 if (gimple_asm_nlabels (gs))
1515 fields = 4;
1516 else if (gimple_asm_nclobbers (gs))
1517 fields = 3;
1518 else if (gimple_asm_ninputs (gs))
1519 fields = 2;
1520 else if (gimple_asm_noutputs (gs))
1521 fields = 1;
1522 else
1523 fields = 0;
1525 for (f = 0; f < fields; ++f)
1527 pp_string (buffer, " : ");
1529 switch (f)
1531 case 0:
1532 n = gimple_asm_noutputs (gs);
1533 for (i = 0; i < n; i++)
1535 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1536 spc, flags, false);
1537 if (i < n - 1)
1538 pp_string (buffer, ", ");
1540 break;
1542 case 1:
1543 n = gimple_asm_ninputs (gs);
1544 for (i = 0; i < n; i++)
1546 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1547 spc, flags, false);
1548 if (i < n - 1)
1549 pp_string (buffer, ", ");
1551 break;
1553 case 2:
1554 n = gimple_asm_nclobbers (gs);
1555 for (i = 0; i < n; i++)
1557 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1558 spc, flags, false);
1559 if (i < n - 1)
1560 pp_string (buffer, ", ");
1562 break;
1564 case 3:
1565 n = gimple_asm_nlabels (gs);
1566 for (i = 0; i < n; i++)
1568 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1569 spc, flags, false);
1570 if (i < n - 1)
1571 pp_string (buffer, ", ");
1573 break;
1575 default:
1576 gcc_unreachable ();
1580 pp_string (buffer, ");");
1585 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1586 The caller is responsible for calling pp_flush on BUFFER to finalize
1587 pretty printer. */
1589 static void
1590 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags)
1592 size_t i;
1593 tree lhs = gimple_phi_result (phi);
1595 if (flags & TDF_ALIAS
1596 && POINTER_TYPE_P (TREE_TYPE (lhs))
1597 && SSA_NAME_PTR_INFO (lhs))
1599 unsigned int align, misalign;
1600 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
1601 pp_string (buffer, "PT = ");
1602 pp_points_to_solution (buffer, &pi->pt);
1603 newline_and_indent (buffer, spc);
1604 if (get_ptr_info_alignment (pi, &align, &misalign))
1606 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1607 newline_and_indent (buffer, spc);
1609 pp_string (buffer, "# ");
1612 if (flags & TDF_RAW)
1613 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1614 gimple_phi_result (phi));
1615 else
1617 dump_generic_node (buffer, lhs, spc, flags, false);
1618 pp_string (buffer, " = PHI <");
1620 for (i = 0; i < gimple_phi_num_args (phi); i++)
1622 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1624 expanded_location xloc;
1626 xloc = expand_location (gimple_phi_arg_location (phi, i));
1627 pp_left_bracket (buffer);
1628 if (xloc.file)
1630 pp_string (buffer, xloc.file);
1631 pp_string (buffer, " : ");
1633 pp_decimal_int (buffer, xloc.line);
1634 pp_colon (buffer);
1635 pp_decimal_int (buffer, xloc.column);
1636 pp_string (buffer, "] ");
1638 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1639 false);
1640 pp_left_paren (buffer);
1641 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1642 pp_right_paren (buffer);
1643 if (i < gimple_phi_num_args (phi) - 1)
1644 pp_string (buffer, ", ");
1646 pp_greater (buffer);
1650 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1651 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1652 dumpfile.h). */
1654 static void
1655 dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1656 int flags)
1658 if (flags & TDF_RAW)
1660 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1661 gimple_omp_body (gs));
1662 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1663 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1664 gimple_omp_parallel_child_fn (gs),
1665 gimple_omp_parallel_data_arg (gs));
1667 else
1669 gimple_seq body;
1670 pp_string (buffer, "#pragma omp parallel");
1671 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1672 if (gimple_omp_parallel_child_fn (gs))
1674 pp_string (buffer, " [child fn: ");
1675 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1676 spc, flags, false);
1677 pp_string (buffer, " (");
1678 if (gimple_omp_parallel_data_arg (gs))
1679 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1680 spc, flags, false);
1681 else
1682 pp_string (buffer, "???");
1683 pp_string (buffer, ")]");
1685 body = gimple_omp_body (gs);
1686 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1688 newline_and_indent (buffer, spc + 2);
1689 pp_left_brace (buffer);
1690 pp_newline (buffer);
1691 dump_gimple_seq (buffer, body, spc + 4, flags);
1692 newline_and_indent (buffer, spc + 2);
1693 pp_right_brace (buffer);
1695 else if (body)
1697 pp_newline (buffer);
1698 dump_gimple_seq (buffer, body, spc + 2, flags);
1704 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1705 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1706 dumpfile.h). */
1708 static void
1709 dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
1710 int flags)
1712 if (flags & TDF_RAW)
1714 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1715 gimple_omp_body (gs));
1716 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1717 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1718 gimple_omp_task_child_fn (gs),
1719 gimple_omp_task_data_arg (gs),
1720 gimple_omp_task_copy_fn (gs),
1721 gimple_omp_task_arg_size (gs),
1722 gimple_omp_task_arg_size (gs));
1724 else
1726 gimple_seq body;
1727 pp_string (buffer, "#pragma omp task");
1728 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1729 if (gimple_omp_task_child_fn (gs))
1731 pp_string (buffer, " [child fn: ");
1732 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1733 spc, flags, false);
1734 pp_string (buffer, " (");
1735 if (gimple_omp_task_data_arg (gs))
1736 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1737 spc, flags, false);
1738 else
1739 pp_string (buffer, "???");
1740 pp_string (buffer, ")]");
1742 body = gimple_omp_body (gs);
1743 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1745 newline_and_indent (buffer, spc + 2);
1746 pp_left_brace (buffer);
1747 pp_newline (buffer);
1748 dump_gimple_seq (buffer, body, spc + 4, flags);
1749 newline_and_indent (buffer, spc + 2);
1750 pp_right_brace (buffer);
1752 else if (body)
1754 pp_newline (buffer);
1755 dump_gimple_seq (buffer, body, spc + 2, flags);
1761 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1762 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1763 in dumpfile.h). */
1765 static void
1766 dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
1767 int flags)
1769 if (flags & TDF_RAW)
1771 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1772 gimple_omp_atomic_load_lhs (gs),
1773 gimple_omp_atomic_load_rhs (gs));
1775 else
1777 pp_string (buffer, "#pragma omp atomic_load");
1778 if (gimple_omp_atomic_need_value_p (gs))
1779 pp_string (buffer, " [needed]");
1780 newline_and_indent (buffer, spc + 2);
1781 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
1782 spc, flags, false);
1783 pp_space (buffer);
1784 pp_equal (buffer);
1785 pp_space (buffer);
1786 pp_star (buffer);
1787 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
1788 spc, flags, false);
1792 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1793 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1794 in dumpfile.h). */
1796 static void
1797 dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
1798 int flags)
1800 if (flags & TDF_RAW)
1802 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1803 gimple_omp_atomic_store_val (gs));
1805 else
1807 pp_string (buffer, "#pragma omp atomic_store ");
1808 if (gimple_omp_atomic_need_value_p (gs))
1809 pp_string (buffer, "[needed] ");
1810 pp_left_paren (buffer);
1811 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
1812 spc, flags, false);
1813 pp_right_paren (buffer);
1818 /* Dump all the memory operands for statement GS. BUFFER, SPC and
1819 FLAGS are as in pp_gimple_stmt_1. */
1821 static void
1822 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
1824 tree vdef = gimple_vdef (gs);
1825 tree vuse = gimple_vuse (gs);
1827 if (!ssa_operands_active (DECL_STRUCT_FUNCTION (current_function_decl))
1828 || !gimple_references_memory_p (gs))
1829 return;
1831 if (vdef != NULL_TREE)
1833 pp_string (buffer, "# ");
1834 dump_generic_node (buffer, vdef, spc + 2, flags, false);
1835 pp_string (buffer, " = VDEF <");
1836 dump_generic_node (buffer, vuse, spc + 2, flags, false);
1837 pp_greater (buffer);
1838 newline_and_indent (buffer, spc);
1840 else if (vuse != NULL_TREE)
1842 pp_string (buffer, "# VUSE <");
1843 dump_generic_node (buffer, vuse, spc + 2, flags, false);
1844 pp_greater (buffer);
1845 newline_and_indent (buffer, spc);
1850 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
1851 spaces of indent. FLAGS specifies details to show in the dump (see
1852 TDF_* in dumpfile.h). The caller is responsible for calling
1853 pp_flush on BUFFER to finalize the pretty printer. */
1855 void
1856 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
1858 if (!gs)
1859 return;
1861 if (flags & TDF_STMTADDR)
1862 pp_printf (buffer, "<&%p> ", (void *) gs);
1864 if ((flags & TDF_LINENO) && gimple_has_location (gs))
1866 expanded_location xloc = expand_location (gimple_location (gs));
1867 pp_left_bracket (buffer);
1868 if (xloc.file)
1870 pp_string (buffer, xloc.file);
1871 pp_string (buffer, " : ");
1873 pp_decimal_int (buffer, xloc.line);
1874 pp_colon (buffer);
1875 pp_decimal_int (buffer, xloc.column);
1876 pp_string (buffer, "] ");
1879 if (flags & TDF_EH)
1881 int lp_nr = lookup_stmt_eh_lp (gs);
1882 if (lp_nr > 0)
1883 pp_printf (buffer, "[LP %d] ", lp_nr);
1884 else if (lp_nr < 0)
1885 pp_printf (buffer, "[MNT %d] ", -lp_nr);
1888 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
1889 && gimple_has_mem_ops (gs))
1890 dump_gimple_mem_ops (buffer, gs, spc, flags);
1892 if ((flags & TDF_ALIAS)
1893 && gimple_has_lhs (gs))
1895 tree lhs = gimple_get_lhs (gs);
1896 if (TREE_CODE (lhs) == SSA_NAME
1897 && POINTER_TYPE_P (TREE_TYPE (lhs))
1898 && SSA_NAME_PTR_INFO (lhs))
1900 unsigned int align, misalign;
1901 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
1902 pp_string (buffer, "# PT = ");
1903 pp_points_to_solution (buffer, &pi->pt);
1904 newline_and_indent (buffer, spc);
1905 if (get_ptr_info_alignment (pi, &align, &misalign))
1907 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u",
1908 align, misalign);
1909 newline_and_indent (buffer, spc);
1914 switch (gimple_code (gs))
1916 case GIMPLE_ASM:
1917 dump_gimple_asm (buffer, gs, spc, flags);
1918 break;
1920 case GIMPLE_ASSIGN:
1921 dump_gimple_assign (buffer, gs, spc, flags);
1922 break;
1924 case GIMPLE_BIND:
1925 dump_gimple_bind (buffer, gs, spc, flags);
1926 break;
1928 case GIMPLE_CALL:
1929 dump_gimple_call (buffer, gs, spc, flags);
1930 break;
1932 case GIMPLE_COND:
1933 dump_gimple_cond (buffer, gs, spc, flags);
1934 break;
1936 case GIMPLE_LABEL:
1937 dump_gimple_label (buffer, gs, spc, flags);
1938 break;
1940 case GIMPLE_GOTO:
1941 dump_gimple_goto (buffer, gs, spc, flags);
1942 break;
1944 case GIMPLE_NOP:
1945 pp_string (buffer, "GIMPLE_NOP");
1946 break;
1948 case GIMPLE_RETURN:
1949 dump_gimple_return (buffer, gs, spc, flags);
1950 break;
1952 case GIMPLE_SWITCH:
1953 dump_gimple_switch (buffer, gs, spc, flags);
1954 break;
1956 case GIMPLE_TRY:
1957 dump_gimple_try (buffer, gs, spc, flags);
1958 break;
1960 case GIMPLE_PHI:
1961 dump_gimple_phi (buffer, gs, spc, flags);
1962 break;
1964 case GIMPLE_OMP_PARALLEL:
1965 dump_gimple_omp_parallel (buffer, gs, spc, flags);
1966 break;
1968 case GIMPLE_OMP_TASK:
1969 dump_gimple_omp_task (buffer, gs, spc, flags);
1970 break;
1972 case GIMPLE_OMP_ATOMIC_LOAD:
1973 dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
1975 break;
1977 case GIMPLE_OMP_ATOMIC_STORE:
1978 dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
1979 break;
1981 case GIMPLE_OMP_FOR:
1982 dump_gimple_omp_for (buffer, gs, spc, flags);
1983 break;
1985 case GIMPLE_OMP_CONTINUE:
1986 dump_gimple_omp_continue (buffer, gs, spc, flags);
1987 break;
1989 case GIMPLE_OMP_SINGLE:
1990 dump_gimple_omp_single (buffer, gs, spc, flags);
1991 break;
1993 case GIMPLE_OMP_RETURN:
1994 dump_gimple_omp_return (buffer, gs, spc, flags);
1995 break;
1997 case GIMPLE_OMP_SECTIONS:
1998 dump_gimple_omp_sections (buffer, gs, spc, flags);
1999 break;
2001 case GIMPLE_OMP_SECTIONS_SWITCH:
2002 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2003 break;
2005 case GIMPLE_OMP_MASTER:
2006 case GIMPLE_OMP_ORDERED:
2007 case GIMPLE_OMP_SECTION:
2008 dump_gimple_omp_block (buffer, gs, spc, flags);
2009 break;
2011 case GIMPLE_OMP_CRITICAL:
2012 dump_gimple_omp_critical (buffer, gs, spc, flags);
2013 break;
2015 case GIMPLE_CATCH:
2016 dump_gimple_catch (buffer, gs, spc, flags);
2017 break;
2019 case GIMPLE_EH_FILTER:
2020 dump_gimple_eh_filter (buffer, gs, spc, flags);
2021 break;
2023 case GIMPLE_EH_MUST_NOT_THROW:
2024 dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
2025 break;
2027 case GIMPLE_EH_ELSE:
2028 dump_gimple_eh_else (buffer, gs, spc, flags);
2029 break;
2031 case GIMPLE_RESX:
2032 dump_gimple_resx (buffer, gs, spc, flags);
2033 break;
2035 case GIMPLE_EH_DISPATCH:
2036 dump_gimple_eh_dispatch (buffer, gs, spc, flags);
2037 break;
2039 case GIMPLE_DEBUG:
2040 dump_gimple_debug (buffer, gs, spc, flags);
2041 break;
2043 case GIMPLE_PREDICT:
2044 pp_string (buffer, "// predicted ");
2045 if (gimple_predict_outcome (gs))
2046 pp_string (buffer, "likely by ");
2047 else
2048 pp_string (buffer, "unlikely by ");
2049 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2050 pp_string (buffer, " predictor.");
2051 break;
2053 case GIMPLE_TRANSACTION:
2054 dump_gimple_transaction (buffer, gs, spc, flags);
2055 break;
2057 default:
2058 GIMPLE_NIY;
2063 /* Dumps header of basic block BB to OUTF indented by INDENT
2064 spaces and details described by flags. */
2066 static void
2067 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2069 if (flags & TDF_BLOCKS)
2071 if (flags & TDF_LINENO)
2073 gimple_stmt_iterator gsi;
2075 if (flags & TDF_COMMENT)
2076 fputs (";; ", outf);
2078 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2079 if (!is_gimple_debug (gsi_stmt (gsi))
2080 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2082 fprintf (outf, "%*sstarting at line %d",
2083 indent, "", get_lineno (gsi_stmt (gsi)));
2084 break;
2086 if (bb->discriminator)
2087 fprintf (outf, ", discriminator %i", bb->discriminator);
2088 fputc ('\n', outf);
2091 else
2093 gimple stmt = first_stmt (bb);
2094 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2095 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2100 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2101 spaces. */
2103 static void
2104 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2105 basic_block bb ATTRIBUTE_UNUSED,
2106 int indent ATTRIBUTE_UNUSED,
2107 int flags ATTRIBUTE_UNUSED)
2109 /* There is currently no GIMPLE-specific basic block info to dump. */
2110 return;
2114 /* Dump PHI nodes of basic block BB to BUFFER with details described
2115 by FLAGS and indented by INDENT spaces. */
2117 static void
2118 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2120 gimple_stmt_iterator i;
2122 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2124 gimple phi = gsi_stmt (i);
2125 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2127 INDENT (indent);
2128 pp_string (buffer, "# ");
2129 dump_gimple_phi (buffer, phi, indent, flags);
2130 pp_newline (buffer);
2136 /* Dump jump to basic block BB that is represented implicitly in the cfg
2137 to BUFFER. */
2139 static void
2140 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2142 gimple stmt;
2144 stmt = first_stmt (bb);
2146 pp_string (buffer, "goto <bb ");
2147 pp_decimal_int (buffer, bb->index);
2148 pp_greater (buffer);
2149 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2151 pp_string (buffer, " (");
2152 dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
2153 pp_right_paren (buffer);
2154 pp_semicolon (buffer);
2156 else
2157 pp_semicolon (buffer);
2161 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2162 by INDENT spaces, with details given by FLAGS. */
2164 static void
2165 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2166 int flags)
2168 edge e;
2169 gimple stmt;
2171 stmt = last_stmt (bb);
2173 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2175 edge true_edge, false_edge;
2177 /* When we are emitting the code or changing CFG, it is possible that
2178 the edges are not yet created. When we are using debug_bb in such
2179 a situation, we do not want it to crash. */
2180 if (EDGE_COUNT (bb->succs) != 2)
2181 return;
2182 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2184 INDENT (indent + 2);
2185 pp_cfg_jump (buffer, true_edge->dest);
2186 newline_and_indent (buffer, indent);
2187 pp_string (buffer, "else");
2188 newline_and_indent (buffer, indent + 2);
2189 pp_cfg_jump (buffer, false_edge->dest);
2190 pp_newline (buffer);
2191 return;
2194 /* If there is a fallthru edge, we may need to add an artificial
2195 goto to the dump. */
2196 e = find_fallthru_edge (bb->succs);
2198 if (e && e->dest != bb->next_bb)
2200 INDENT (indent);
2202 if ((flags & TDF_LINENO)
2203 && e->goto_locus != UNKNOWN_LOCATION
2206 expanded_location goto_xloc;
2207 goto_xloc = expand_location (e->goto_locus);
2208 pp_left_bracket (buffer);
2209 if (goto_xloc.file)
2211 pp_string (buffer, goto_xloc.file);
2212 pp_string (buffer, " : ");
2214 pp_decimal_int (buffer, goto_xloc.line);
2215 pp_string (buffer, " : ");
2216 pp_decimal_int (buffer, goto_xloc.column);
2217 pp_string (buffer, "] ");
2220 pp_cfg_jump (buffer, e->dest);
2221 pp_newline (buffer);
2226 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2227 indented by INDENT spaces. */
2229 static void
2230 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2231 int flags)
2233 gimple_stmt_iterator gsi;
2234 gimple stmt;
2235 int label_indent = indent - 2;
2237 if (label_indent < 0)
2238 label_indent = 0;
2240 dump_phi_nodes (buffer, bb, indent, flags);
2242 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2244 int curr_indent;
2246 stmt = gsi_stmt (gsi);
2248 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2250 INDENT (curr_indent);
2251 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2252 pp_newline_and_flush (buffer);
2253 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2254 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2255 buffer->buffer->stream, stmt);
2258 dump_implicit_edges (buffer, bb, indent, flags);
2259 pp_flush (buffer);
2263 /* Dumps basic block BB to FILE with details described by FLAGS and
2264 indented by INDENT spaces. */
2266 void
2267 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2269 dump_gimple_bb_header (file, bb, indent, flags);
2270 if (bb->index >= NUM_FIXED_BLOCKS)
2272 pretty_printer buffer;
2273 pp_construct (&buffer, NULL, 0);
2274 pp_needs_newline (&buffer) = true;
2275 buffer.buffer->stream = file;
2276 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2278 dump_gimple_bb_footer (file, bb, indent, flags);
2281 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2282 no indentation, for use as a label of a DOT graph record-node.
2283 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2284 histogram dumping doesn't know about pretty-printers. */
2286 void
2287 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2289 gimple_stmt_iterator gsi;
2291 pp_printf (pp, "<bb %d>:\n", bb->index);
2292 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2294 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2296 gimple phi = gsi_stmt (gsi);
2297 if (!virtual_operand_p (gimple_phi_result (phi))
2298 || (dump_flags & TDF_VOPS))
2300 pp_bar (pp);
2301 pp_write_text_to_stream (pp);
2302 pp_string (pp, "# ");
2303 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2304 pp_newline (pp);
2305 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2309 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2311 gimple stmt = gsi_stmt (gsi);
2312 pp_bar (pp);
2313 pp_write_text_to_stream (pp);
2314 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2315 pp_newline (pp);
2316 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2318 dump_implicit_edges (pp, bb, 0, dump_flags);
2319 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);