2013-10-11 Marc Glisse <marc.glisse@inria.fr>
[official-gcc.git] / gcc / gimple-pretty-print.c
blobf0f816671ec01f45c1e03863005dd7810d1c07c9
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-ssa.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_needs_newline (&buffer) = true;
79 buffer.buffer->stream = file;
80 pp_gimple_stmt_1 (&buffer, g, spc, flags);
81 pp_newline_and_flush (&buffer);
84 DEBUG_FUNCTION void
85 debug (gimple_statement_d &ref)
87 print_gimple_stmt (stderr, &ref, 0, 0);
90 DEBUG_FUNCTION void
91 debug (gimple_statement_d *ptr)
93 if (ptr)
94 debug (*ptr);
95 else
96 fprintf (stderr, "<nil>\n");
100 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
101 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
102 of the statement. */
104 void
105 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
107 flags |= TDF_RHS_ONLY;
108 pretty_printer buffer;
109 pp_needs_newline (&buffer) = true;
110 buffer.buffer->stream = file;
111 pp_gimple_stmt_1 (&buffer, g, spc, flags);
112 pp_flush (&buffer);
116 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
117 spaces and FLAGS as in pp_gimple_stmt_1.
118 The caller is responsible for calling pp_flush on BUFFER to finalize
119 the pretty printer. */
121 static void
122 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
124 gimple_stmt_iterator i;
126 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
128 gimple gs = gsi_stmt (i);
129 INDENT (spc);
130 pp_gimple_stmt_1 (buffer, gs, spc, flags);
131 if (!gsi_one_before_end_p (i))
132 pp_newline (buffer);
137 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
138 FLAGS as in pp_gimple_stmt_1. */
140 void
141 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
143 pretty_printer buffer;
144 pp_needs_newline (&buffer) = true;
145 buffer.buffer->stream = file;
146 dump_gimple_seq (&buffer, seq, spc, flags);
147 pp_newline_and_flush (&buffer);
151 /* Print the GIMPLE sequence SEQ on stderr. */
153 DEBUG_FUNCTION void
154 debug_gimple_seq (gimple_seq seq)
156 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
160 /* A simple helper to pretty-print some of the gimple tuples in the printf
161 style. The format modifiers are preceded by '%' and are:
162 'G' - outputs a string corresponding to the code of the given gimple,
163 'S' - outputs a gimple_seq with indent of spc + 2,
164 'T' - outputs the tree t,
165 'd' - outputs an int as a decimal,
166 's' - outputs a string,
167 'n' - outputs a newline,
168 'x' - outputs an int as hexadecimal,
169 '+' - increases indent by 2 then outputs a newline,
170 '-' - decreases indent by 2 then outputs a newline. */
172 static void
173 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
174 const char *fmt, ...)
176 va_list args;
177 const char *c;
178 const char *tmp;
180 va_start (args, fmt);
181 for (c = fmt; *c; c++)
183 if (*c == '%')
185 gimple_seq seq;
186 tree t;
187 gimple g;
188 switch (*++c)
190 case 'G':
191 g = va_arg (args, gimple);
192 tmp = gimple_code_name[gimple_code (g)];
193 pp_string (buffer, tmp);
194 break;
196 case 'S':
197 seq = va_arg (args, gimple_seq);
198 pp_newline (buffer);
199 dump_gimple_seq (buffer, seq, spc + 2, flags);
200 newline_and_indent (buffer, spc);
201 break;
203 case 'T':
204 t = va_arg (args, tree);
205 if (t == NULL_TREE)
206 pp_string (buffer, "NULL");
207 else
208 dump_generic_node (buffer, t, spc, flags, false);
209 break;
211 case 'd':
212 pp_decimal_int (buffer, va_arg (args, int));
213 break;
215 case 's':
216 pp_string (buffer, va_arg (args, char *));
217 break;
219 case 'n':
220 newline_and_indent (buffer, spc);
221 break;
223 case 'x':
224 pp_scalar (buffer, "%x", va_arg (args, int));
225 break;
227 case '+':
228 spc += 2;
229 newline_and_indent (buffer, spc);
230 break;
232 case '-':
233 spc -= 2;
234 newline_and_indent (buffer, spc);
235 break;
237 default:
238 gcc_unreachable ();
241 else
242 pp_character (buffer, *c);
244 va_end (args);
248 /* Helper for dump_gimple_assign. Print the unary RHS of the
249 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
251 static void
252 dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
254 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
255 tree lhs = gimple_assign_lhs (gs);
256 tree rhs = gimple_assign_rhs1 (gs);
258 switch (rhs_code)
260 case VIEW_CONVERT_EXPR:
261 case ASSERT_EXPR:
262 dump_generic_node (buffer, rhs, spc, flags, false);
263 break;
265 case FIXED_CONVERT_EXPR:
266 case ADDR_SPACE_CONVERT_EXPR:
267 case FIX_TRUNC_EXPR:
268 case FLOAT_EXPR:
269 CASE_CONVERT:
270 pp_left_paren (buffer);
271 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
272 pp_string (buffer, ") ");
273 if (op_prio (rhs) < op_code_prio (rhs_code))
275 pp_left_paren (buffer);
276 dump_generic_node (buffer, rhs, spc, flags, false);
277 pp_right_paren (buffer);
279 else
280 dump_generic_node (buffer, rhs, spc, flags, false);
281 break;
283 case PAREN_EXPR:
284 pp_string (buffer, "((");
285 dump_generic_node (buffer, rhs, spc, flags, false);
286 pp_string (buffer, "))");
287 break;
289 case ABS_EXPR:
290 pp_string (buffer, "ABS_EXPR <");
291 dump_generic_node (buffer, rhs, spc, flags, false);
292 pp_greater (buffer);
293 break;
295 default:
296 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
297 || TREE_CODE_CLASS (rhs_code) == tcc_constant
298 || TREE_CODE_CLASS (rhs_code) == tcc_reference
299 || rhs_code == SSA_NAME
300 || rhs_code == ADDR_EXPR
301 || rhs_code == CONSTRUCTOR)
303 dump_generic_node (buffer, rhs, spc, flags, false);
304 break;
306 else if (rhs_code == BIT_NOT_EXPR)
307 pp_complement (buffer);
308 else if (rhs_code == TRUTH_NOT_EXPR)
309 pp_exclamation (buffer);
310 else if (rhs_code == NEGATE_EXPR)
311 pp_minus (buffer);
312 else
314 pp_left_bracket (buffer);
315 pp_string (buffer, tree_code_name [rhs_code]);
316 pp_string (buffer, "] ");
319 if (op_prio (rhs) < op_code_prio (rhs_code))
321 pp_left_paren (buffer);
322 dump_generic_node (buffer, rhs, spc, flags, false);
323 pp_right_paren (buffer);
325 else
326 dump_generic_node (buffer, rhs, spc, flags, false);
327 break;
332 /* Helper for dump_gimple_assign. Print the binary RHS of the
333 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
335 static void
336 dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
338 const char *p;
339 enum tree_code code = gimple_assign_rhs_code (gs);
340 switch (code)
342 case COMPLEX_EXPR:
343 case MIN_EXPR:
344 case MAX_EXPR:
345 case VEC_WIDEN_MULT_HI_EXPR:
346 case VEC_WIDEN_MULT_LO_EXPR:
347 case VEC_WIDEN_MULT_EVEN_EXPR:
348 case VEC_WIDEN_MULT_ODD_EXPR:
349 case VEC_PACK_TRUNC_EXPR:
350 case VEC_PACK_SAT_EXPR:
351 case VEC_PACK_FIX_TRUNC_EXPR:
352 case VEC_WIDEN_LSHIFT_HI_EXPR:
353 case VEC_WIDEN_LSHIFT_LO_EXPR:
354 for (p = tree_code_name [(int) code]; *p; p++)
355 pp_character (buffer, TOUPPER (*p));
356 pp_string (buffer, " <");
357 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
358 pp_string (buffer, ", ");
359 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
360 pp_greater (buffer);
361 break;
363 default:
364 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
366 pp_left_paren (buffer);
367 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
368 false);
369 pp_right_paren (buffer);
371 else
372 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
373 pp_space (buffer);
374 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
375 pp_space (buffer);
376 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
378 pp_left_paren (buffer);
379 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
380 false);
381 pp_right_paren (buffer);
383 else
384 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
388 /* Helper for dump_gimple_assign. Print the ternary RHS of the
389 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
391 static void
392 dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
394 const char *p;
395 enum tree_code code = gimple_assign_rhs_code (gs);
396 switch (code)
398 case WIDEN_MULT_PLUS_EXPR:
399 case WIDEN_MULT_MINUS_EXPR:
400 for (p = tree_code_name [(int) code]; *p; p++)
401 pp_character (buffer, TOUPPER (*p));
402 pp_string (buffer, " <");
403 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
404 pp_string (buffer, ", ");
405 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
406 pp_string (buffer, ", ");
407 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
408 pp_greater (buffer);
409 break;
411 case FMA_EXPR:
412 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
413 pp_string (buffer, " * ");
414 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
415 pp_string (buffer, " + ");
416 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
417 break;
419 case DOT_PROD_EXPR:
420 pp_string (buffer, "DOT_PROD_EXPR <");
421 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
422 pp_string (buffer, ", ");
423 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
424 pp_string (buffer, ", ");
425 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
426 pp_greater (buffer);
427 break;
429 case VEC_PERM_EXPR:
430 pp_string (buffer, "VEC_PERM_EXPR <");
431 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
432 pp_string (buffer, ", ");
433 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
434 pp_string (buffer, ", ");
435 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
436 pp_greater (buffer);
437 break;
439 case REALIGN_LOAD_EXPR:
440 pp_string (buffer, "REALIGN_LOAD <");
441 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
442 pp_string (buffer, ", ");
443 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
444 pp_string (buffer, ", ");
445 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
446 pp_greater (buffer);
447 break;
449 case COND_EXPR:
450 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
451 pp_string (buffer, " ? ");
452 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
453 pp_string (buffer, " : ");
454 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
455 break;
457 case VEC_COND_EXPR:
458 pp_string (buffer, "VEC_COND_EXPR <");
459 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
460 pp_string (buffer, ", ");
461 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
462 pp_string (buffer, ", ");
463 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
464 pp_greater (buffer);
465 break;
467 default:
468 gcc_unreachable ();
473 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
474 pp_gimple_stmt_1. */
476 static void
477 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
479 if (flags & TDF_RAW)
481 tree arg1 = NULL;
482 tree arg2 = NULL;
483 tree arg3 = NULL;
484 switch (gimple_num_ops (gs))
486 case 4:
487 arg3 = gimple_assign_rhs3 (gs);
488 case 3:
489 arg2 = gimple_assign_rhs2 (gs);
490 case 2:
491 arg1 = gimple_assign_rhs1 (gs);
492 break;
493 default:
494 gcc_unreachable ();
497 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
498 tree_code_name[gimple_assign_rhs_code (gs)],
499 gimple_assign_lhs (gs), arg1, arg2, arg3);
501 else
503 if (!(flags & TDF_RHS_ONLY))
505 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
506 pp_space (buffer);
507 pp_equal (buffer);
509 if (gimple_assign_nontemporal_move_p (gs))
510 pp_string (buffer, "{nt}");
512 if (gimple_has_volatile_ops (gs))
513 pp_string (buffer, "{v}");
515 pp_space (buffer);
518 if (gimple_num_ops (gs) == 2)
519 dump_unary_rhs (buffer, gs, spc, flags);
520 else if (gimple_num_ops (gs) == 3)
521 dump_binary_rhs (buffer, gs, spc, flags);
522 else if (gimple_num_ops (gs) == 4)
523 dump_ternary_rhs (buffer, gs, spc, flags);
524 else
525 gcc_unreachable ();
526 if (!(flags & TDF_RHS_ONLY))
527 pp_semicolon (buffer);
532 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
533 pp_gimple_stmt_1. */
535 static void
536 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
538 tree t;
540 t = gimple_return_retval (gs);
541 if (flags & TDF_RAW)
542 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
543 else
545 pp_string (buffer, "return");
546 if (t)
548 pp_space (buffer);
549 dump_generic_node (buffer, t, spc, flags, false);
551 pp_semicolon (buffer);
556 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
557 dump_gimple_call. */
559 static void
560 dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags)
562 size_t i;
564 for (i = 0; i < gimple_call_num_args (gs); i++)
566 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
567 if (i < gimple_call_num_args (gs) - 1)
568 pp_string (buffer, ", ");
571 if (gimple_call_va_arg_pack_p (gs))
573 if (gimple_call_num_args (gs) > 0)
575 pp_comma (buffer);
576 pp_space (buffer);
579 pp_string (buffer, "__builtin_va_arg_pack ()");
583 /* Dump the points-to solution *PT to BUFFER. */
585 static void
586 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
588 if (pt->anything)
590 pp_string (buffer, "anything ");
591 return;
593 if (pt->nonlocal)
594 pp_string (buffer, "nonlocal ");
595 if (pt->escaped)
596 pp_string (buffer, "escaped ");
597 if (pt->ipa_escaped)
598 pp_string (buffer, "unit-escaped ");
599 if (pt->null)
600 pp_string (buffer, "null ");
601 if (pt->vars
602 && !bitmap_empty_p (pt->vars))
604 bitmap_iterator bi;
605 unsigned i;
606 pp_string (buffer, "{ ");
607 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
609 pp_string (buffer, "D.");
610 pp_decimal_int (buffer, i);
611 pp_space (buffer);
613 pp_right_brace (buffer);
614 if (pt->vars_contains_global)
615 pp_string (buffer, " (glob)");
619 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
620 pp_gimple_stmt_1. */
622 static void
623 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
625 tree lhs = gimple_call_lhs (gs);
626 tree fn = gimple_call_fn (gs);
628 if (flags & TDF_ALIAS)
630 struct pt_solution *pt;
631 pt = gimple_call_use_set (gs);
632 if (!pt_solution_empty_p (pt))
634 pp_string (buffer, "# USE = ");
635 pp_points_to_solution (buffer, pt);
636 newline_and_indent (buffer, spc);
638 pt = gimple_call_clobber_set (gs);
639 if (!pt_solution_empty_p (pt))
641 pp_string (buffer, "# CLB = ");
642 pp_points_to_solution (buffer, pt);
643 newline_and_indent (buffer, spc);
647 if (flags & TDF_RAW)
649 if (gimple_call_internal_p (gs))
650 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
651 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
652 else
653 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
654 if (gimple_call_num_args (gs) > 0)
656 pp_string (buffer, ", ");
657 dump_gimple_call_args (buffer, gs, flags);
659 pp_greater (buffer);
661 else
663 if (lhs && !(flags & TDF_RHS_ONLY))
665 dump_generic_node (buffer, lhs, spc, flags, false);
666 pp_string (buffer, " =");
668 if (gimple_has_volatile_ops (gs))
669 pp_string (buffer, "{v}");
671 pp_space (buffer);
673 if (gimple_call_internal_p (gs))
674 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
675 else
676 print_call_name (buffer, fn, flags);
677 pp_string (buffer, " (");
678 dump_gimple_call_args (buffer, gs, flags);
679 pp_right_paren (buffer);
680 if (!(flags & TDF_RHS_ONLY))
681 pp_semicolon (buffer);
684 if (gimple_call_chain (gs))
686 pp_string (buffer, " [static-chain: ");
687 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
688 pp_right_bracket (buffer);
691 if (gimple_call_return_slot_opt_p (gs))
692 pp_string (buffer, " [return slot optimization]");
693 if (gimple_call_tail_p (gs))
694 pp_string (buffer, " [tail call]");
696 if (fn == NULL)
697 return;
699 /* Dump the arguments of _ITM_beginTransaction sanely. */
700 if (TREE_CODE (fn) == ADDR_EXPR)
701 fn = TREE_OPERAND (fn, 0);
702 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
703 pp_string (buffer, " [tm-clone]");
704 if (TREE_CODE (fn) == FUNCTION_DECL
705 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
706 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
707 && gimple_call_num_args (gs) > 0)
709 tree t = gimple_call_arg (gs, 0);
710 unsigned HOST_WIDE_INT props;
711 gcc_assert (TREE_CODE (t) == INTEGER_CST);
713 pp_string (buffer, " [ ");
715 /* Get the transaction code properties. */
716 props = TREE_INT_CST_LOW (t);
718 if (props & PR_INSTRUMENTEDCODE)
719 pp_string (buffer, "instrumentedCode ");
720 if (props & PR_UNINSTRUMENTEDCODE)
721 pp_string (buffer, "uninstrumentedCode ");
722 if (props & PR_HASNOXMMUPDATE)
723 pp_string (buffer, "hasNoXMMUpdate ");
724 if (props & PR_HASNOABORT)
725 pp_string (buffer, "hasNoAbort ");
726 if (props & PR_HASNOIRREVOCABLE)
727 pp_string (buffer, "hasNoIrrevocable ");
728 if (props & PR_DOESGOIRREVOCABLE)
729 pp_string (buffer, "doesGoIrrevocable ");
730 if (props & PR_HASNOSIMPLEREADS)
731 pp_string (buffer, "hasNoSimpleReads ");
732 if (props & PR_AWBARRIERSOMITTED)
733 pp_string (buffer, "awBarriersOmitted ");
734 if (props & PR_RARBARRIERSOMITTED)
735 pp_string (buffer, "RaRBarriersOmitted ");
736 if (props & PR_UNDOLOGCODE)
737 pp_string (buffer, "undoLogCode ");
738 if (props & PR_PREFERUNINSTRUMENTED)
739 pp_string (buffer, "preferUninstrumented ");
740 if (props & PR_EXCEPTIONBLOCK)
741 pp_string (buffer, "exceptionBlock ");
742 if (props & PR_HASELSE)
743 pp_string (buffer, "hasElse ");
744 if (props & PR_READONLY)
745 pp_string (buffer, "readOnly ");
747 pp_right_bracket (buffer);
752 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
753 pp_gimple_stmt_1. */
755 static void
756 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
758 unsigned int i;
760 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
761 if (flags & TDF_RAW)
762 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
763 gimple_switch_index (gs));
764 else
766 pp_string (buffer, "switch (");
767 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
768 pp_string (buffer, ") <");
771 for (i = 0; i < gimple_switch_num_labels (gs); i++)
773 tree case_label = gimple_switch_label (gs, i);
774 gcc_checking_assert (case_label != NULL_TREE);
775 dump_generic_node (buffer, case_label, spc, flags, false);
776 pp_space (buffer);
777 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
778 if (i < gimple_switch_num_labels (gs) - 1)
779 pp_string (buffer, ", ");
781 pp_greater (buffer);
785 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
786 pp_gimple_stmt_1. */
788 static void
789 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
791 if (flags & TDF_RAW)
792 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
793 tree_code_name [gimple_cond_code (gs)],
794 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
795 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
796 else
798 if (!(flags & TDF_RHS_ONLY))
799 pp_string (buffer, "if (");
800 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
801 pp_space (buffer);
802 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
803 pp_space (buffer);
804 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
805 if (!(flags & TDF_RHS_ONLY))
807 pp_right_paren (buffer);
809 if (gimple_cond_true_label (gs))
811 pp_string (buffer, " goto ");
812 dump_generic_node (buffer, gimple_cond_true_label (gs),
813 spc, flags, false);
814 pp_semicolon (buffer);
816 if (gimple_cond_false_label (gs))
818 pp_string (buffer, " else goto ");
819 dump_generic_node (buffer, gimple_cond_false_label (gs),
820 spc, flags, false);
821 pp_semicolon (buffer);
828 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
829 spaces of indent. FLAGS specifies details to show in the dump (see
830 TDF_* in dumpfils.h). */
832 static void
833 dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
835 tree label = gimple_label_label (gs);
836 if (flags & TDF_RAW)
837 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
838 else
840 dump_generic_node (buffer, label, spc, flags, false);
841 pp_colon (buffer);
843 if (DECL_NONLOCAL (label))
844 pp_string (buffer, " [non-local]");
845 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
846 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
849 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
850 spaces of indent. FLAGS specifies details to show in the dump (see
851 TDF_* in dumpfile.h). */
853 static void
854 dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
856 tree label = gimple_goto_dest (gs);
857 if (flags & TDF_RAW)
858 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
859 else
860 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
864 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
865 spaces of indent. FLAGS specifies details to show in the dump (see
866 TDF_* in dumpfile.h). */
868 static void
869 dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
871 if (flags & TDF_RAW)
872 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
873 else
874 pp_left_brace (buffer);
875 if (!(flags & TDF_SLIM))
877 tree var;
879 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
881 newline_and_indent (buffer, 2);
882 print_declaration (buffer, var, spc, flags);
884 if (gimple_bind_vars (gs))
885 pp_newline (buffer);
887 pp_newline (buffer);
888 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
889 newline_and_indent (buffer, spc);
890 if (flags & TDF_RAW)
891 pp_greater (buffer);
892 else
893 pp_right_brace (buffer);
897 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
898 indent. FLAGS specifies details to show in the dump (see TDF_* in
899 dumpfile.h). */
901 static void
902 dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
904 if (flags & TDF_RAW)
906 const char *type;
907 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
908 type = "GIMPLE_TRY_CATCH";
909 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
910 type = "GIMPLE_TRY_FINALLY";
911 else
912 type = "UNKNOWN GIMPLE_TRY";
913 dump_gimple_fmt (buffer, spc, flags,
914 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
915 gimple_try_eval (gs), gimple_try_cleanup (gs));
917 else
919 pp_string (buffer, "try");
920 newline_and_indent (buffer, spc + 2);
921 pp_left_brace (buffer);
922 pp_newline (buffer);
924 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
925 newline_and_indent (buffer, spc + 2);
926 pp_right_brace (buffer);
928 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
930 newline_and_indent (buffer, spc);
931 pp_string (buffer, "catch");
932 newline_and_indent (buffer, spc + 2);
933 pp_left_brace (buffer);
935 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
937 newline_and_indent (buffer, spc);
938 pp_string (buffer, "finally");
939 newline_and_indent (buffer, spc + 2);
940 pp_left_brace (buffer);
942 else
943 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
945 pp_newline (buffer);
946 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
947 newline_and_indent (buffer, spc + 2);
948 pp_right_brace (buffer);
953 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
954 indent. FLAGS specifies details to show in the dump (see TDF_* in
955 dumpfile.h). */
957 static void
958 dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
960 if (flags & TDF_RAW)
961 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
962 gimple_catch_types (gs), gimple_catch_handler (gs));
963 else
964 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
965 gimple_catch_types (gs), gimple_catch_handler (gs));
969 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
970 indent. FLAGS specifies details to show in the dump (see TDF_* in
971 dumpfile.h). */
973 static void
974 dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
976 if (flags & TDF_RAW)
977 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
978 gimple_eh_filter_types (gs),
979 gimple_eh_filter_failure (gs));
980 else
981 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
982 gimple_eh_filter_types (gs),
983 gimple_eh_filter_failure (gs));
987 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
989 static void
990 dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
991 int spc, int flags)
993 if (flags & TDF_RAW)
994 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
995 gimple_eh_must_not_throw_fndecl (gs));
996 else
997 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
998 gimple_eh_must_not_throw_fndecl (gs));
1002 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1003 indent. FLAGS specifies details to show in the dump (see TDF_* in
1004 dumpfile.h). */
1006 static void
1007 dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags)
1009 if (flags & TDF_RAW)
1010 dump_gimple_fmt (buffer, spc, flags,
1011 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1012 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1013 else
1014 dump_gimple_fmt (buffer, spc, flags,
1015 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1016 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1020 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1021 indent. FLAGS specifies details to show in the dump (see TDF_* in
1022 dumpfile.h). */
1024 static void
1025 dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
1027 if (flags & TDF_RAW)
1028 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1029 gimple_resx_region (gs));
1030 else
1031 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1034 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1036 static void
1037 dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
1039 if (flags & TDF_RAW)
1040 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1041 gimple_eh_dispatch_region (gs));
1042 else
1043 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1044 gimple_eh_dispatch_region (gs));
1047 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1048 of indent. FLAGS specifies details to show in the dump (see TDF_*
1049 in dumpfile.h). */
1051 static void
1052 dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
1054 switch (gs->gsbase.subcode)
1056 case GIMPLE_DEBUG_BIND:
1057 if (flags & TDF_RAW)
1058 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1059 gimple_debug_bind_get_var (gs),
1060 gimple_debug_bind_get_value (gs));
1061 else
1062 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1063 gimple_debug_bind_get_var (gs),
1064 gimple_debug_bind_get_value (gs));
1065 break;
1067 case GIMPLE_DEBUG_SOURCE_BIND:
1068 if (flags & TDF_RAW)
1069 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1070 gimple_debug_source_bind_get_var (gs),
1071 gimple_debug_source_bind_get_value (gs));
1072 else
1073 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1074 gimple_debug_source_bind_get_var (gs),
1075 gimple_debug_source_bind_get_value (gs));
1076 break;
1078 default:
1079 gcc_unreachable ();
1083 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1084 static void
1085 dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
1087 size_t i;
1089 if (flags & TDF_RAW)
1091 const char *kind;
1092 switch (gimple_omp_for_kind (gs))
1094 case GF_OMP_FOR_KIND_FOR:
1095 kind = "";
1096 break;
1097 case GF_OMP_FOR_KIND_SIMD:
1098 kind = " simd";
1099 break;
1100 case GF_OMP_FOR_KIND_DISTRIBUTE:
1101 kind = " distribute";
1102 break;
1103 default:
1104 gcc_unreachable ();
1106 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1107 kind, gimple_omp_body (gs));
1108 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1109 dump_gimple_fmt (buffer, spc, flags, " >,");
1110 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1111 dump_gimple_fmt (buffer, spc, flags,
1112 "%+%T, %T, %T, %s, %T,%n",
1113 gimple_omp_for_index (gs, i),
1114 gimple_omp_for_initial (gs, i),
1115 gimple_omp_for_final (gs, i),
1116 tree_code_name[gimple_omp_for_cond (gs, i)],
1117 gimple_omp_for_incr (gs, i));
1118 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1119 gimple_omp_for_pre_body (gs));
1121 else
1123 switch (gimple_omp_for_kind (gs))
1125 case GF_OMP_FOR_KIND_FOR:
1126 pp_string (buffer, "#pragma omp for");
1127 break;
1128 case GF_OMP_FOR_KIND_SIMD:
1129 pp_string (buffer, "#pragma omp simd");
1130 break;
1131 case GF_OMP_FOR_KIND_DISTRIBUTE:
1132 pp_string (buffer, "#pragma omp distribute");
1133 break;
1134 default:
1135 gcc_unreachable ();
1137 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1138 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1140 if (i)
1141 spc += 2;
1142 newline_and_indent (buffer, spc);
1143 pp_string (buffer, "for (");
1144 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1145 flags, false);
1146 pp_string (buffer, " = ");
1147 dump_generic_node (buffer, gimple_omp_for_initial (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_space (buffer);
1154 switch (gimple_omp_for_cond (gs, i))
1156 case LT_EXPR:
1157 pp_less (buffer);
1158 break;
1159 case GT_EXPR:
1160 pp_greater (buffer);
1161 break;
1162 case LE_EXPR:
1163 pp_less_equal (buffer);
1164 break;
1165 case GE_EXPR:
1166 pp_greater_equal (buffer);
1167 break;
1168 default:
1169 gcc_unreachable ();
1171 pp_space (buffer);
1172 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1173 flags, false);
1174 pp_string (buffer, "; ");
1176 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1177 flags, false);
1178 pp_string (buffer, " = ");
1179 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1180 flags, false);
1181 pp_right_paren (buffer);
1184 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1186 newline_and_indent (buffer, spc + 2);
1187 pp_left_brace (buffer);
1188 pp_newline (buffer);
1189 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1190 newline_and_indent (buffer, spc + 2);
1191 pp_right_brace (buffer);
1196 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1198 static void
1199 dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags)
1201 if (flags & TDF_RAW)
1203 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1204 gimple_omp_continue_control_def (gs),
1205 gimple_omp_continue_control_use (gs));
1207 else
1209 pp_string (buffer, "#pragma omp continue (");
1210 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1211 spc, flags, false);
1212 pp_comma (buffer);
1213 pp_space (buffer);
1214 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1215 spc, flags, false);
1216 pp_right_paren (buffer);
1220 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1222 static void
1223 dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, 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_single_clauses (gs), spc, flags);
1230 dump_gimple_fmt (buffer, spc, flags, " >");
1232 else
1234 pp_string (buffer, "#pragma omp single");
1235 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1236 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1238 newline_and_indent (buffer, spc + 2);
1239 pp_left_brace (buffer);
1240 pp_newline (buffer);
1241 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1242 newline_and_indent (buffer, spc + 2);
1243 pp_right_brace (buffer);
1248 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1250 static void
1251 dump_gimple_omp_target (pretty_printer *buffer, gimple gs, int spc, int flags)
1253 const char *kind;
1254 switch (gimple_omp_target_kind (gs))
1256 case GF_OMP_TARGET_KIND_REGION:
1257 kind = "";
1258 break;
1259 case GF_OMP_TARGET_KIND_DATA:
1260 kind = " data";
1261 break;
1262 case GF_OMP_TARGET_KIND_UPDATE:
1263 kind = " update";
1264 break;
1265 default:
1266 gcc_unreachable ();
1268 if (flags & TDF_RAW)
1270 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1271 kind, gimple_omp_body (gs));
1272 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1273 dump_gimple_fmt (buffer, spc, flags, " >");
1275 else
1277 pp_string (buffer, "#pragma omp target");
1278 pp_string (buffer, kind);
1279 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1280 if (gimple_omp_target_child_fn (gs))
1282 pp_string (buffer, " [child fn: ");
1283 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1284 spc, flags, false);
1285 pp_right_bracket (buffer);
1287 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1289 newline_and_indent (buffer, spc + 2);
1290 pp_character (buffer, '{');
1291 pp_newline (buffer);
1292 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1293 newline_and_indent (buffer, spc + 2);
1294 pp_character (buffer, '}');
1299 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1301 static void
1302 dump_gimple_omp_teams (pretty_printer *buffer, gimple gs, int spc, int flags)
1304 if (flags & TDF_RAW)
1306 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1307 gimple_omp_body (gs));
1308 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1309 dump_gimple_fmt (buffer, spc, flags, " >");
1311 else
1313 pp_string (buffer, "#pragma omp teams");
1314 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1315 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1317 newline_and_indent (buffer, spc + 2);
1318 pp_character (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_character (buffer, '}');
1327 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1329 static void
1330 dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
1331 int flags)
1333 if (flags & TDF_RAW)
1335 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1336 gimple_omp_body (gs));
1337 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1338 dump_gimple_fmt (buffer, spc, flags, " >");
1340 else
1342 pp_string (buffer, "#pragma omp sections");
1343 if (gimple_omp_sections_control (gs))
1345 pp_string (buffer, " <");
1346 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1347 flags, false);
1348 pp_greater (buffer);
1350 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1351 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1353 newline_and_indent (buffer, spc + 2);
1354 pp_left_brace (buffer);
1355 pp_newline (buffer);
1356 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1357 newline_and_indent (buffer, spc + 2);
1358 pp_right_brace (buffer);
1363 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1364 pretty_printer BUFFER. */
1366 static void
1367 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1369 if (flags & TDF_RAW)
1370 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1371 gimple_omp_body (gs));
1372 else
1374 switch (gimple_code (gs))
1376 case GIMPLE_OMP_MASTER:
1377 pp_string (buffer, "#pragma omp master");
1378 break;
1379 case GIMPLE_OMP_TASKGROUP:
1380 pp_string (buffer, "#pragma omp taskgroup");
1381 break;
1382 case GIMPLE_OMP_ORDERED:
1383 pp_string (buffer, "#pragma omp ordered");
1384 break;
1385 case GIMPLE_OMP_SECTION:
1386 pp_string (buffer, "#pragma omp section");
1387 break;
1388 default:
1389 gcc_unreachable ();
1391 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1393 newline_and_indent (buffer, spc + 2);
1394 pp_left_brace (buffer);
1395 pp_newline (buffer);
1396 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1397 newline_and_indent (buffer, spc + 2);
1398 pp_right_brace (buffer);
1403 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1405 static void
1406 dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
1407 int flags)
1409 if (flags & TDF_RAW)
1410 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1411 gimple_omp_body (gs));
1412 else
1414 pp_string (buffer, "#pragma omp critical");
1415 if (gimple_omp_critical_name (gs))
1417 pp_string (buffer, " (");
1418 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1419 flags, false);
1420 pp_right_paren (buffer);
1422 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1424 newline_and_indent (buffer, spc + 2);
1425 pp_left_brace (buffer);
1426 pp_newline (buffer);
1427 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1428 newline_and_indent (buffer, spc + 2);
1429 pp_right_brace (buffer);
1434 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1436 static void
1437 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1439 if (flags & TDF_RAW)
1441 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1442 (int) gimple_omp_return_nowait_p (gs));
1443 if (gimple_omp_return_lhs (gs))
1444 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1445 gimple_omp_return_lhs (gs));
1446 else
1447 dump_gimple_fmt (buffer, spc, flags, ">");
1449 else
1451 pp_string (buffer, "#pragma omp return");
1452 if (gimple_omp_return_nowait_p (gs))
1453 pp_string (buffer, "(nowait)");
1454 if (gimple_omp_return_lhs (gs))
1456 pp_string (buffer, " (set ");
1457 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1458 spc, flags, false);
1459 pp_character (buffer, ')');
1464 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1466 static void
1467 dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags)
1469 unsigned subcode = gimple_transaction_subcode (gs);
1471 if (flags & TDF_RAW)
1473 dump_gimple_fmt (buffer, spc, flags,
1474 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1475 gs, subcode, gimple_transaction_label (gs),
1476 gimple_transaction_body (gs));
1478 else
1480 if (subcode & GTMA_IS_OUTER)
1481 pp_string (buffer, "__transaction_atomic [[outer]]");
1482 else if (subcode & GTMA_IS_RELAXED)
1483 pp_string (buffer, "__transaction_relaxed");
1484 else
1485 pp_string (buffer, "__transaction_atomic");
1486 subcode &= ~GTMA_DECLARATION_MASK;
1488 if (subcode || gimple_transaction_label (gs))
1490 pp_string (buffer, " //");
1491 if (gimple_transaction_label (gs))
1493 pp_string (buffer, " LABEL=");
1494 dump_generic_node (buffer, gimple_transaction_label (gs),
1495 spc, flags, false);
1497 if (subcode)
1499 pp_string (buffer, " SUBCODE=[ ");
1500 if (subcode & GTMA_HAVE_ABORT)
1502 pp_string (buffer, "GTMA_HAVE_ABORT ");
1503 subcode &= ~GTMA_HAVE_ABORT;
1505 if (subcode & GTMA_HAVE_LOAD)
1507 pp_string (buffer, "GTMA_HAVE_LOAD ");
1508 subcode &= ~GTMA_HAVE_LOAD;
1510 if (subcode & GTMA_HAVE_STORE)
1512 pp_string (buffer, "GTMA_HAVE_STORE ");
1513 subcode &= ~GTMA_HAVE_STORE;
1515 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1517 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1518 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1520 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1522 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1523 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1525 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1527 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1528 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1530 if (subcode)
1531 pp_printf (buffer, "0x%x ", subcode);
1532 pp_right_bracket (buffer);
1536 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1538 newline_and_indent (buffer, spc + 2);
1539 pp_left_brace (buffer);
1540 pp_newline (buffer);
1541 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1542 spc + 4, flags);
1543 newline_and_indent (buffer, spc + 2);
1544 pp_right_brace (buffer);
1549 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1550 indent. FLAGS specifies details to show in the dump (see TDF_* in
1551 dumpfile.h). */
1553 static void
1554 dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
1556 unsigned int i, n, f, fields;
1558 if (flags & TDF_RAW)
1560 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1561 gimple_asm_string (gs));
1563 n = gimple_asm_noutputs (gs);
1564 if (n)
1566 newline_and_indent (buffer, spc + 2);
1567 pp_string (buffer, "OUTPUT: ");
1568 for (i = 0; i < n; i++)
1570 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1571 spc, flags, false);
1572 if (i < n - 1)
1573 pp_string (buffer, ", ");
1577 n = gimple_asm_ninputs (gs);
1578 if (n)
1580 newline_and_indent (buffer, spc + 2);
1581 pp_string (buffer, "INPUT: ");
1582 for (i = 0; i < n; i++)
1584 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1585 spc, flags, false);
1586 if (i < n - 1)
1587 pp_string (buffer, ", ");
1591 n = gimple_asm_nclobbers (gs);
1592 if (n)
1594 newline_and_indent (buffer, spc + 2);
1595 pp_string (buffer, "CLOBBER: ");
1596 for (i = 0; i < n; i++)
1598 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1599 spc, flags, false);
1600 if (i < n - 1)
1601 pp_string (buffer, ", ");
1605 n = gimple_asm_nlabels (gs);
1606 if (n)
1608 newline_and_indent (buffer, spc + 2);
1609 pp_string (buffer, "LABEL: ");
1610 for (i = 0; i < n; i++)
1612 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1613 spc, flags, false);
1614 if (i < n - 1)
1615 pp_string (buffer, ", ");
1619 newline_and_indent (buffer, spc);
1620 pp_greater (buffer);
1622 else
1624 pp_string (buffer, "__asm__");
1625 if (gimple_asm_volatile_p (gs))
1626 pp_string (buffer, " __volatile__");
1627 if (gimple_asm_nlabels (gs))
1628 pp_string (buffer, " goto");
1629 pp_string (buffer, "(\"");
1630 pp_string (buffer, gimple_asm_string (gs));
1631 pp_string (buffer, "\"");
1633 if (gimple_asm_nlabels (gs))
1634 fields = 4;
1635 else if (gimple_asm_nclobbers (gs))
1636 fields = 3;
1637 else if (gimple_asm_ninputs (gs))
1638 fields = 2;
1639 else if (gimple_asm_noutputs (gs))
1640 fields = 1;
1641 else
1642 fields = 0;
1644 for (f = 0; f < fields; ++f)
1646 pp_string (buffer, " : ");
1648 switch (f)
1650 case 0:
1651 n = gimple_asm_noutputs (gs);
1652 for (i = 0; i < n; i++)
1654 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1655 spc, flags, false);
1656 if (i < n - 1)
1657 pp_string (buffer, ", ");
1659 break;
1661 case 1:
1662 n = gimple_asm_ninputs (gs);
1663 for (i = 0; i < n; i++)
1665 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1666 spc, flags, false);
1667 if (i < n - 1)
1668 pp_string (buffer, ", ");
1670 break;
1672 case 2:
1673 n = gimple_asm_nclobbers (gs);
1674 for (i = 0; i < n; i++)
1676 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1677 spc, flags, false);
1678 if (i < n - 1)
1679 pp_string (buffer, ", ");
1681 break;
1683 case 3:
1684 n = gimple_asm_nlabels (gs);
1685 for (i = 0; i < n; i++)
1687 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1688 spc, flags, false);
1689 if (i < n - 1)
1690 pp_string (buffer, ", ");
1692 break;
1694 default:
1695 gcc_unreachable ();
1699 pp_string (buffer, ");");
1703 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1704 SPC spaces of indent. */
1706 static void
1707 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1709 if (TREE_CODE (node) != SSA_NAME)
1710 return;
1712 if (POINTER_TYPE_P (TREE_TYPE (node))
1713 && SSA_NAME_PTR_INFO (node))
1715 unsigned int align, misalign;
1716 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1717 pp_string (buffer, "PT = ");
1718 pp_points_to_solution (buffer, &pi->pt);
1719 newline_and_indent (buffer, spc);
1720 if (get_ptr_info_alignment (pi, &align, &misalign))
1722 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1723 newline_and_indent (buffer, spc);
1725 pp_string (buffer, "# ");
1728 if (!POINTER_TYPE_P (TREE_TYPE (node))
1729 && SSA_NAME_RANGE_INFO (node))
1731 double_int min, max;
1732 value_range_type range_type = get_range_info (node, &min, &max);
1734 if (range_type == VR_VARYING)
1735 pp_printf (buffer, "# RANGE VR_VARYING");
1736 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1738 pp_printf (buffer, "# RANGE ");
1739 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1740 pp_double_int (buffer, min, TYPE_UNSIGNED (TREE_TYPE (node)));
1741 pp_printf (buffer, ", ");
1742 pp_double_int (buffer, max, TYPE_UNSIGNED (TREE_TYPE (node)));
1743 pp_printf (buffer, "]");
1744 newline_and_indent (buffer, spc);
1750 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1751 The caller is responsible for calling pp_flush on BUFFER to finalize
1752 pretty printer. */
1754 static void
1755 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags)
1757 size_t i;
1758 tree lhs = gimple_phi_result (phi);
1760 if (flags & TDF_ALIAS)
1761 dump_ssaname_info (buffer, lhs, spc);
1763 if (flags & TDF_RAW)
1764 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1765 gimple_phi_result (phi));
1766 else
1768 dump_generic_node (buffer, lhs, spc, flags, false);
1769 pp_string (buffer, " = PHI <");
1771 for (i = 0; i < gimple_phi_num_args (phi); i++)
1773 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1775 expanded_location xloc;
1777 xloc = expand_location (gimple_phi_arg_location (phi, i));
1778 pp_left_bracket (buffer);
1779 if (xloc.file)
1781 pp_string (buffer, xloc.file);
1782 pp_string (buffer, " : ");
1784 pp_decimal_int (buffer, xloc.line);
1785 pp_colon (buffer);
1786 pp_decimal_int (buffer, xloc.column);
1787 pp_string (buffer, "] ");
1789 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1790 false);
1791 pp_left_paren (buffer);
1792 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1793 pp_right_paren (buffer);
1794 if (i < gimple_phi_num_args (phi) - 1)
1795 pp_string (buffer, ", ");
1797 pp_greater (buffer);
1801 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1802 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1803 dumpfile.h). */
1805 static void
1806 dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1807 int flags)
1809 if (flags & TDF_RAW)
1811 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1812 gimple_omp_body (gs));
1813 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1814 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1815 gimple_omp_parallel_child_fn (gs),
1816 gimple_omp_parallel_data_arg (gs));
1818 else
1820 gimple_seq body;
1821 pp_string (buffer, "#pragma omp parallel");
1822 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1823 if (gimple_omp_parallel_child_fn (gs))
1825 pp_string (buffer, " [child fn: ");
1826 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1827 spc, flags, false);
1828 pp_string (buffer, " (");
1829 if (gimple_omp_parallel_data_arg (gs))
1830 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1831 spc, flags, false);
1832 else
1833 pp_string (buffer, "???");
1834 pp_string (buffer, ")]");
1836 body = gimple_omp_body (gs);
1837 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1839 newline_and_indent (buffer, spc + 2);
1840 pp_left_brace (buffer);
1841 pp_newline (buffer);
1842 dump_gimple_seq (buffer, body, spc + 4, flags);
1843 newline_and_indent (buffer, spc + 2);
1844 pp_right_brace (buffer);
1846 else if (body)
1848 pp_newline (buffer);
1849 dump_gimple_seq (buffer, body, spc + 2, flags);
1855 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1856 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1857 dumpfile.h). */
1859 static void
1860 dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
1861 int flags)
1863 if (flags & TDF_RAW)
1865 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1866 gimple_omp_body (gs));
1867 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1868 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1869 gimple_omp_task_child_fn (gs),
1870 gimple_omp_task_data_arg (gs),
1871 gimple_omp_task_copy_fn (gs),
1872 gimple_omp_task_arg_size (gs),
1873 gimple_omp_task_arg_size (gs));
1875 else
1877 gimple_seq body;
1878 pp_string (buffer, "#pragma omp task");
1879 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1880 if (gimple_omp_task_child_fn (gs))
1882 pp_string (buffer, " [child fn: ");
1883 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1884 spc, flags, false);
1885 pp_string (buffer, " (");
1886 if (gimple_omp_task_data_arg (gs))
1887 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1888 spc, flags, false);
1889 else
1890 pp_string (buffer, "???");
1891 pp_string (buffer, ")]");
1893 body = gimple_omp_body (gs);
1894 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1896 newline_and_indent (buffer, spc + 2);
1897 pp_left_brace (buffer);
1898 pp_newline (buffer);
1899 dump_gimple_seq (buffer, body, spc + 4, flags);
1900 newline_and_indent (buffer, spc + 2);
1901 pp_right_brace (buffer);
1903 else if (body)
1905 pp_newline (buffer);
1906 dump_gimple_seq (buffer, body, spc + 2, flags);
1912 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1913 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1914 in dumpfile.h). */
1916 static void
1917 dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
1918 int flags)
1920 if (flags & TDF_RAW)
1922 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1923 gimple_omp_atomic_load_lhs (gs),
1924 gimple_omp_atomic_load_rhs (gs));
1926 else
1928 pp_string (buffer, "#pragma omp atomic_load");
1929 if (gimple_omp_atomic_seq_cst_p (gs))
1930 pp_string (buffer, " seq_cst");
1931 if (gimple_omp_atomic_need_value_p (gs))
1932 pp_string (buffer, " [needed]");
1933 newline_and_indent (buffer, spc + 2);
1934 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
1935 spc, flags, false);
1936 pp_space (buffer);
1937 pp_equal (buffer);
1938 pp_space (buffer);
1939 pp_star (buffer);
1940 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
1941 spc, flags, false);
1945 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1946 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1947 in dumpfile.h). */
1949 static void
1950 dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
1951 int flags)
1953 if (flags & TDF_RAW)
1955 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1956 gimple_omp_atomic_store_val (gs));
1958 else
1960 pp_string (buffer, "#pragma omp atomic_store ");
1961 if (gimple_omp_atomic_seq_cst_p (gs))
1962 pp_string (buffer, "seq_cst ");
1963 if (gimple_omp_atomic_need_value_p (gs))
1964 pp_string (buffer, "[needed] ");
1965 pp_left_paren (buffer);
1966 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
1967 spc, flags, false);
1968 pp_right_paren (buffer);
1973 /* Dump all the memory operands for statement GS. BUFFER, SPC and
1974 FLAGS are as in pp_gimple_stmt_1. */
1976 static void
1977 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
1979 tree vdef = gimple_vdef (gs);
1980 tree vuse = gimple_vuse (gs);
1982 if (!ssa_operands_active (DECL_STRUCT_FUNCTION (current_function_decl))
1983 || !gimple_references_memory_p (gs))
1984 return;
1986 if (vdef != NULL_TREE)
1988 pp_string (buffer, "# ");
1989 dump_generic_node (buffer, vdef, spc + 2, flags, false);
1990 pp_string (buffer, " = VDEF <");
1991 dump_generic_node (buffer, vuse, spc + 2, flags, false);
1992 pp_greater (buffer);
1993 newline_and_indent (buffer, spc);
1995 else if (vuse != NULL_TREE)
1997 pp_string (buffer, "# VUSE <");
1998 dump_generic_node (buffer, vuse, spc + 2, flags, false);
1999 pp_greater (buffer);
2000 newline_and_indent (buffer, spc);
2005 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2006 spaces of indent. FLAGS specifies details to show in the dump (see
2007 TDF_* in dumpfile.h). The caller is responsible for calling
2008 pp_flush on BUFFER to finalize the pretty printer. */
2010 void
2011 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
2013 if (!gs)
2014 return;
2016 if (flags & TDF_STMTADDR)
2017 pp_printf (buffer, "<&%p> ", (void *) gs);
2019 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2021 expanded_location xloc = expand_location (gimple_location (gs));
2022 pp_left_bracket (buffer);
2023 if (xloc.file)
2025 pp_string (buffer, xloc.file);
2026 pp_string (buffer, " : ");
2028 pp_decimal_int (buffer, xloc.line);
2029 pp_colon (buffer);
2030 pp_decimal_int (buffer, xloc.column);
2031 pp_string (buffer, "] ");
2034 if (flags & TDF_EH)
2036 int lp_nr = lookup_stmt_eh_lp (gs);
2037 if (lp_nr > 0)
2038 pp_printf (buffer, "[LP %d] ", lp_nr);
2039 else if (lp_nr < 0)
2040 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2043 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2044 && gimple_has_mem_ops (gs))
2045 dump_gimple_mem_ops (buffer, gs, spc, flags);
2047 if (gimple_has_lhs (gs)
2048 && (flags & TDF_ALIAS))
2049 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2051 switch (gimple_code (gs))
2053 case GIMPLE_ASM:
2054 dump_gimple_asm (buffer, gs, spc, flags);
2055 break;
2057 case GIMPLE_ASSIGN:
2058 dump_gimple_assign (buffer, gs, spc, flags);
2059 break;
2061 case GIMPLE_BIND:
2062 dump_gimple_bind (buffer, gs, spc, flags);
2063 break;
2065 case GIMPLE_CALL:
2066 dump_gimple_call (buffer, gs, spc, flags);
2067 break;
2069 case GIMPLE_COND:
2070 dump_gimple_cond (buffer, gs, spc, flags);
2071 break;
2073 case GIMPLE_LABEL:
2074 dump_gimple_label (buffer, gs, spc, flags);
2075 break;
2077 case GIMPLE_GOTO:
2078 dump_gimple_goto (buffer, gs, spc, flags);
2079 break;
2081 case GIMPLE_NOP:
2082 pp_string (buffer, "GIMPLE_NOP");
2083 break;
2085 case GIMPLE_RETURN:
2086 dump_gimple_return (buffer, gs, spc, flags);
2087 break;
2089 case GIMPLE_SWITCH:
2090 dump_gimple_switch (buffer, gs, spc, flags);
2091 break;
2093 case GIMPLE_TRY:
2094 dump_gimple_try (buffer, gs, spc, flags);
2095 break;
2097 case GIMPLE_PHI:
2098 dump_gimple_phi (buffer, gs, spc, flags);
2099 break;
2101 case GIMPLE_OMP_PARALLEL:
2102 dump_gimple_omp_parallel (buffer, gs, spc, flags);
2103 break;
2105 case GIMPLE_OMP_TASK:
2106 dump_gimple_omp_task (buffer, gs, spc, flags);
2107 break;
2109 case GIMPLE_OMP_ATOMIC_LOAD:
2110 dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
2112 break;
2114 case GIMPLE_OMP_ATOMIC_STORE:
2115 dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
2116 break;
2118 case GIMPLE_OMP_FOR:
2119 dump_gimple_omp_for (buffer, gs, spc, flags);
2120 break;
2122 case GIMPLE_OMP_CONTINUE:
2123 dump_gimple_omp_continue (buffer, gs, spc, flags);
2124 break;
2126 case GIMPLE_OMP_SINGLE:
2127 dump_gimple_omp_single (buffer, gs, spc, flags);
2128 break;
2130 case GIMPLE_OMP_TARGET:
2131 dump_gimple_omp_target (buffer, gs, spc, flags);
2132 break;
2134 case GIMPLE_OMP_TEAMS:
2135 dump_gimple_omp_teams (buffer, gs, spc, flags);
2136 break;
2138 case GIMPLE_OMP_RETURN:
2139 dump_gimple_omp_return (buffer, gs, spc, flags);
2140 break;
2142 case GIMPLE_OMP_SECTIONS:
2143 dump_gimple_omp_sections (buffer, gs, spc, flags);
2144 break;
2146 case GIMPLE_OMP_SECTIONS_SWITCH:
2147 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2148 break;
2150 case GIMPLE_OMP_MASTER:
2151 case GIMPLE_OMP_TASKGROUP:
2152 case GIMPLE_OMP_ORDERED:
2153 case GIMPLE_OMP_SECTION:
2154 dump_gimple_omp_block (buffer, gs, spc, flags);
2155 break;
2157 case GIMPLE_OMP_CRITICAL:
2158 dump_gimple_omp_critical (buffer, gs, spc, flags);
2159 break;
2161 case GIMPLE_CATCH:
2162 dump_gimple_catch (buffer, gs, spc, flags);
2163 break;
2165 case GIMPLE_EH_FILTER:
2166 dump_gimple_eh_filter (buffer, gs, spc, flags);
2167 break;
2169 case GIMPLE_EH_MUST_NOT_THROW:
2170 dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
2171 break;
2173 case GIMPLE_EH_ELSE:
2174 dump_gimple_eh_else (buffer, gs, spc, flags);
2175 break;
2177 case GIMPLE_RESX:
2178 dump_gimple_resx (buffer, gs, spc, flags);
2179 break;
2181 case GIMPLE_EH_DISPATCH:
2182 dump_gimple_eh_dispatch (buffer, gs, spc, flags);
2183 break;
2185 case GIMPLE_DEBUG:
2186 dump_gimple_debug (buffer, gs, spc, flags);
2187 break;
2189 case GIMPLE_PREDICT:
2190 pp_string (buffer, "// predicted ");
2191 if (gimple_predict_outcome (gs))
2192 pp_string (buffer, "likely by ");
2193 else
2194 pp_string (buffer, "unlikely by ");
2195 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2196 pp_string (buffer, " predictor.");
2197 break;
2199 case GIMPLE_TRANSACTION:
2200 dump_gimple_transaction (buffer, gs, spc, flags);
2201 break;
2203 default:
2204 GIMPLE_NIY;
2209 /* Dumps header of basic block BB to OUTF indented by INDENT
2210 spaces and details described by flags. */
2212 static void
2213 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2215 if (flags & TDF_BLOCKS)
2217 if (flags & TDF_LINENO)
2219 gimple_stmt_iterator gsi;
2221 if (flags & TDF_COMMENT)
2222 fputs (";; ", outf);
2224 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2225 if (!is_gimple_debug (gsi_stmt (gsi))
2226 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2228 fprintf (outf, "%*sstarting at line %d",
2229 indent, "", get_lineno (gsi_stmt (gsi)));
2230 break;
2232 if (bb->discriminator)
2233 fprintf (outf, ", discriminator %i", bb->discriminator);
2234 fputc ('\n', outf);
2237 else
2239 gimple stmt = first_stmt (bb);
2240 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2241 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2246 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2247 spaces. */
2249 static void
2250 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2251 basic_block bb ATTRIBUTE_UNUSED,
2252 int indent ATTRIBUTE_UNUSED,
2253 int flags ATTRIBUTE_UNUSED)
2255 /* There is currently no GIMPLE-specific basic block info to dump. */
2256 return;
2260 /* Dump PHI nodes of basic block BB to BUFFER with details described
2261 by FLAGS and indented by INDENT spaces. */
2263 static void
2264 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2266 gimple_stmt_iterator i;
2268 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2270 gimple phi = gsi_stmt (i);
2271 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2273 INDENT (indent);
2274 pp_string (buffer, "# ");
2275 dump_gimple_phi (buffer, phi, indent, flags);
2276 pp_newline (buffer);
2282 /* Dump jump to basic block BB that is represented implicitly in the cfg
2283 to BUFFER. */
2285 static void
2286 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2288 gimple stmt;
2290 stmt = first_stmt (bb);
2292 pp_string (buffer, "goto <bb ");
2293 pp_decimal_int (buffer, bb->index);
2294 pp_greater (buffer);
2295 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2297 pp_string (buffer, " (");
2298 dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
2299 pp_right_paren (buffer);
2300 pp_semicolon (buffer);
2302 else
2303 pp_semicolon (buffer);
2307 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2308 by INDENT spaces, with details given by FLAGS. */
2310 static void
2311 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2312 int flags)
2314 edge e;
2315 gimple stmt;
2317 stmt = last_stmt (bb);
2319 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2321 edge true_edge, false_edge;
2323 /* When we are emitting the code or changing CFG, it is possible that
2324 the edges are not yet created. When we are using debug_bb in such
2325 a situation, we do not want it to crash. */
2326 if (EDGE_COUNT (bb->succs) != 2)
2327 return;
2328 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2330 INDENT (indent + 2);
2331 pp_cfg_jump (buffer, true_edge->dest);
2332 newline_and_indent (buffer, indent);
2333 pp_string (buffer, "else");
2334 newline_and_indent (buffer, indent + 2);
2335 pp_cfg_jump (buffer, false_edge->dest);
2336 pp_newline (buffer);
2337 return;
2340 /* If there is a fallthru edge, we may need to add an artificial
2341 goto to the dump. */
2342 e = find_fallthru_edge (bb->succs);
2344 if (e && e->dest != bb->next_bb)
2346 INDENT (indent);
2348 if ((flags & TDF_LINENO)
2349 && e->goto_locus != UNKNOWN_LOCATION
2352 expanded_location goto_xloc;
2353 goto_xloc = expand_location (e->goto_locus);
2354 pp_left_bracket (buffer);
2355 if (goto_xloc.file)
2357 pp_string (buffer, goto_xloc.file);
2358 pp_string (buffer, " : ");
2360 pp_decimal_int (buffer, goto_xloc.line);
2361 pp_string (buffer, " : ");
2362 pp_decimal_int (buffer, goto_xloc.column);
2363 pp_string (buffer, "] ");
2366 pp_cfg_jump (buffer, e->dest);
2367 pp_newline (buffer);
2372 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2373 indented by INDENT spaces. */
2375 static void
2376 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2377 int flags)
2379 gimple_stmt_iterator gsi;
2380 gimple stmt;
2381 int label_indent = indent - 2;
2383 if (label_indent < 0)
2384 label_indent = 0;
2386 dump_phi_nodes (buffer, bb, indent, flags);
2388 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2390 int curr_indent;
2392 stmt = gsi_stmt (gsi);
2394 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2396 INDENT (curr_indent);
2397 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2398 pp_newline_and_flush (buffer);
2399 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2400 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2401 pp_buffer (buffer)->stream, stmt);
2404 dump_implicit_edges (buffer, bb, indent, flags);
2405 pp_flush (buffer);
2409 /* Dumps basic block BB to FILE with details described by FLAGS and
2410 indented by INDENT spaces. */
2412 void
2413 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2415 dump_gimple_bb_header (file, bb, indent, flags);
2416 if (bb->index >= NUM_FIXED_BLOCKS)
2418 pretty_printer buffer;
2419 pp_needs_newline (&buffer) = true;
2420 buffer.buffer->stream = file;
2421 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2423 dump_gimple_bb_footer (file, bb, indent, flags);
2426 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2427 no indentation, for use as a label of a DOT graph record-node.
2428 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2429 histogram dumping doesn't know about pretty-printers. */
2431 void
2432 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2434 gimple_stmt_iterator gsi;
2436 pp_printf (pp, "<bb %d>:\n", bb->index);
2437 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2439 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2441 gimple phi = gsi_stmt (gsi);
2442 if (!virtual_operand_p (gimple_phi_result (phi))
2443 || (dump_flags & TDF_VOPS))
2445 pp_bar (pp);
2446 pp_write_text_to_stream (pp);
2447 pp_string (pp, "# ");
2448 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2449 pp_newline (pp);
2450 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2454 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2456 gimple stmt = gsi_stmt (gsi);
2457 pp_bar (pp);
2458 pp_write_text_to_stream (pp);
2459 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2460 pp_newline (pp);
2461 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2463 dump_implicit_edges (pp, bb, 0, dump_flags);
2464 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);