2013-11-20 Jan-Benedict Glaw <jbglaw@lug-owl.de>
[official-gcc.git] / gcc / gimple-pretty-print.c
blob4529e79205ebafb7bc6da9b8f6c633419f007632
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 "stringpool.h"
28 #include "diagnostic.h"
29 #include "gimple-pretty-print.h"
30 #include "hashtab.h"
31 #include "bitmap.h"
32 #include "gimple.h"
33 #include "gimple-iterator.h"
34 #include "gimple-ssa.h"
35 #include "cgraph.h"
36 #include "tree-cfg.h"
37 #include "tree-ssanames.h"
38 #include "dumpfile.h" /* for dump_flags */
39 #include "value-prof.h"
40 #include "trans-mem.h"
42 #define INDENT(SPACE) \
43 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
45 #define GIMPLE_NIY do_niy (buffer,gs)
47 /* Try to print on BUFFER a default message for the unrecognized
48 gimple statement GS. */
50 static void
51 do_niy (pretty_printer *buffer, gimple gs)
53 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
54 gimple_code_name[(int) gimple_code (gs)]);
58 /* Emit a newline and SPC indentation spaces to BUFFER. */
60 static void
61 newline_and_indent (pretty_printer *buffer, int spc)
63 pp_newline (buffer);
64 INDENT (spc);
68 /* Print the GIMPLE statement GS on stderr. */
70 DEBUG_FUNCTION void
71 debug_gimple_stmt (gimple gs)
73 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
77 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
78 FLAGS as in pp_gimple_stmt_1. */
80 void
81 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
83 pretty_printer buffer;
84 pp_needs_newline (&buffer) = true;
85 buffer.buffer->stream = file;
86 pp_gimple_stmt_1 (&buffer, g, spc, flags);
87 pp_newline_and_flush (&buffer);
90 DEBUG_FUNCTION void
91 debug (gimple_statement_base &ref)
93 print_gimple_stmt (stderr, &ref, 0, 0);
96 DEBUG_FUNCTION void
97 debug (gimple_statement_base *ptr)
99 if (ptr)
100 debug (*ptr);
101 else
102 fprintf (stderr, "<nil>\n");
106 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
107 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
108 of the statement. */
110 void
111 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
113 flags |= TDF_RHS_ONLY;
114 pretty_printer buffer;
115 pp_needs_newline (&buffer) = true;
116 buffer.buffer->stream = file;
117 pp_gimple_stmt_1 (&buffer, g, spc, flags);
118 pp_flush (&buffer);
122 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
123 spaces and FLAGS as in pp_gimple_stmt_1.
124 The caller is responsible for calling pp_flush on BUFFER to finalize
125 the pretty printer. */
127 static void
128 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
130 gimple_stmt_iterator i;
132 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
134 gimple gs = gsi_stmt (i);
135 INDENT (spc);
136 pp_gimple_stmt_1 (buffer, gs, spc, flags);
137 if (!gsi_one_before_end_p (i))
138 pp_newline (buffer);
143 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
144 FLAGS as in pp_gimple_stmt_1. */
146 void
147 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
149 pretty_printer buffer;
150 pp_needs_newline (&buffer) = true;
151 buffer.buffer->stream = file;
152 dump_gimple_seq (&buffer, seq, spc, flags);
153 pp_newline_and_flush (&buffer);
157 /* Print the GIMPLE sequence SEQ on stderr. */
159 DEBUG_FUNCTION void
160 debug_gimple_seq (gimple_seq seq)
162 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
166 /* A simple helper to pretty-print some of the gimple tuples in the printf
167 style. The format modifiers are preceded by '%' and are:
168 'G' - outputs a string corresponding to the code of the given gimple,
169 'S' - outputs a gimple_seq with indent of spc + 2,
170 'T' - outputs the tree t,
171 'd' - outputs an int as a decimal,
172 's' - outputs a string,
173 'n' - outputs a newline,
174 'x' - outputs an int as hexadecimal,
175 '+' - increases indent by 2 then outputs a newline,
176 '-' - decreases indent by 2 then outputs a newline. */
178 static void
179 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
180 const char *fmt, ...)
182 va_list args;
183 const char *c;
184 const char *tmp;
186 va_start (args, fmt);
187 for (c = fmt; *c; c++)
189 if (*c == '%')
191 gimple_seq seq;
192 tree t;
193 gimple g;
194 switch (*++c)
196 case 'G':
197 g = va_arg (args, gimple);
198 tmp = gimple_code_name[gimple_code (g)];
199 pp_string (buffer, tmp);
200 break;
202 case 'S':
203 seq = va_arg (args, gimple_seq);
204 pp_newline (buffer);
205 dump_gimple_seq (buffer, seq, spc + 2, flags);
206 newline_and_indent (buffer, spc);
207 break;
209 case 'T':
210 t = va_arg (args, tree);
211 if (t == NULL_TREE)
212 pp_string (buffer, "NULL");
213 else
214 dump_generic_node (buffer, t, spc, flags, false);
215 break;
217 case 'd':
218 pp_decimal_int (buffer, va_arg (args, int));
219 break;
221 case 's':
222 pp_string (buffer, va_arg (args, char *));
223 break;
225 case 'n':
226 newline_and_indent (buffer, spc);
227 break;
229 case 'x':
230 pp_scalar (buffer, "%x", va_arg (args, int));
231 break;
233 case '+':
234 spc += 2;
235 newline_and_indent (buffer, spc);
236 break;
238 case '-':
239 spc -= 2;
240 newline_and_indent (buffer, spc);
241 break;
243 default:
244 gcc_unreachable ();
247 else
248 pp_character (buffer, *c);
250 va_end (args);
254 /* Helper for dump_gimple_assign. Print the unary RHS of the
255 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
257 static void
258 dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
260 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
261 tree lhs = gimple_assign_lhs (gs);
262 tree rhs = gimple_assign_rhs1 (gs);
264 switch (rhs_code)
266 case VIEW_CONVERT_EXPR:
267 case ASSERT_EXPR:
268 dump_generic_node (buffer, rhs, spc, flags, false);
269 break;
271 case FIXED_CONVERT_EXPR:
272 case ADDR_SPACE_CONVERT_EXPR:
273 case FIX_TRUNC_EXPR:
274 case FLOAT_EXPR:
275 CASE_CONVERT:
276 pp_left_paren (buffer);
277 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
278 pp_string (buffer, ") ");
279 if (op_prio (rhs) < op_code_prio (rhs_code))
281 pp_left_paren (buffer);
282 dump_generic_node (buffer, rhs, spc, flags, false);
283 pp_right_paren (buffer);
285 else
286 dump_generic_node (buffer, rhs, spc, flags, false);
287 break;
289 case PAREN_EXPR:
290 pp_string (buffer, "((");
291 dump_generic_node (buffer, rhs, spc, flags, false);
292 pp_string (buffer, "))");
293 break;
295 case ABS_EXPR:
296 pp_string (buffer, "ABS_EXPR <");
297 dump_generic_node (buffer, rhs, spc, flags, false);
298 pp_greater (buffer);
299 break;
301 default:
302 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
303 || TREE_CODE_CLASS (rhs_code) == tcc_constant
304 || TREE_CODE_CLASS (rhs_code) == tcc_reference
305 || rhs_code == SSA_NAME
306 || rhs_code == ADDR_EXPR
307 || rhs_code == CONSTRUCTOR)
309 dump_generic_node (buffer, rhs, spc, flags, false);
310 break;
312 else if (rhs_code == BIT_NOT_EXPR)
313 pp_complement (buffer);
314 else if (rhs_code == TRUTH_NOT_EXPR)
315 pp_exclamation (buffer);
316 else if (rhs_code == NEGATE_EXPR)
317 pp_minus (buffer);
318 else
320 pp_left_bracket (buffer);
321 pp_string (buffer, get_tree_code_name (rhs_code));
322 pp_string (buffer, "] ");
325 if (op_prio (rhs) < op_code_prio (rhs_code))
327 pp_left_paren (buffer);
328 dump_generic_node (buffer, rhs, spc, flags, false);
329 pp_right_paren (buffer);
331 else
332 dump_generic_node (buffer, rhs, spc, flags, false);
333 break;
338 /* Helper for dump_gimple_assign. Print the binary RHS of the
339 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
341 static void
342 dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
344 const char *p;
345 enum tree_code code = gimple_assign_rhs_code (gs);
346 switch (code)
348 case COMPLEX_EXPR:
349 case MIN_EXPR:
350 case MAX_EXPR:
351 case VEC_WIDEN_MULT_HI_EXPR:
352 case VEC_WIDEN_MULT_LO_EXPR:
353 case VEC_WIDEN_MULT_EVEN_EXPR:
354 case VEC_WIDEN_MULT_ODD_EXPR:
355 case VEC_PACK_TRUNC_EXPR:
356 case VEC_PACK_SAT_EXPR:
357 case VEC_PACK_FIX_TRUNC_EXPR:
358 case VEC_WIDEN_LSHIFT_HI_EXPR:
359 case VEC_WIDEN_LSHIFT_LO_EXPR:
360 for (p = get_tree_code_name (code); *p; p++)
361 pp_character (buffer, TOUPPER (*p));
362 pp_string (buffer, " <");
363 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
364 pp_string (buffer, ", ");
365 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
366 pp_greater (buffer);
367 break;
369 default:
370 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
372 pp_left_paren (buffer);
373 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
374 false);
375 pp_right_paren (buffer);
377 else
378 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
379 pp_space (buffer);
380 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
381 pp_space (buffer);
382 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
384 pp_left_paren (buffer);
385 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
386 false);
387 pp_right_paren (buffer);
389 else
390 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
394 /* Helper for dump_gimple_assign. Print the ternary RHS of the
395 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
397 static void
398 dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
400 const char *p;
401 enum tree_code code = gimple_assign_rhs_code (gs);
402 switch (code)
404 case WIDEN_MULT_PLUS_EXPR:
405 case WIDEN_MULT_MINUS_EXPR:
406 for (p = get_tree_code_name (code); *p; p++)
407 pp_character (buffer, TOUPPER (*p));
408 pp_string (buffer, " <");
409 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
410 pp_string (buffer, ", ");
411 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
412 pp_string (buffer, ", ");
413 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
414 pp_greater (buffer);
415 break;
417 case FMA_EXPR:
418 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
419 pp_string (buffer, " * ");
420 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
421 pp_string (buffer, " + ");
422 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
423 break;
425 case DOT_PROD_EXPR:
426 pp_string (buffer, "DOT_PROD_EXPR <");
427 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
428 pp_string (buffer, ", ");
429 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
430 pp_string (buffer, ", ");
431 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
432 pp_greater (buffer);
433 break;
435 case VEC_PERM_EXPR:
436 pp_string (buffer, "VEC_PERM_EXPR <");
437 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
438 pp_string (buffer, ", ");
439 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
440 pp_string (buffer, ", ");
441 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
442 pp_greater (buffer);
443 break;
445 case REALIGN_LOAD_EXPR:
446 pp_string (buffer, "REALIGN_LOAD <");
447 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
448 pp_string (buffer, ", ");
449 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
450 pp_string (buffer, ", ");
451 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
452 pp_greater (buffer);
453 break;
455 case COND_EXPR:
456 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
457 pp_string (buffer, " ? ");
458 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
459 pp_string (buffer, " : ");
460 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
461 break;
463 case VEC_COND_EXPR:
464 pp_string (buffer, "VEC_COND_EXPR <");
465 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
466 pp_string (buffer, ", ");
467 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
468 pp_string (buffer, ", ");
469 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
470 pp_greater (buffer);
471 break;
473 default:
474 gcc_unreachable ();
479 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
480 pp_gimple_stmt_1. */
482 static void
483 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
485 if (flags & TDF_RAW)
487 tree arg1 = NULL;
488 tree arg2 = NULL;
489 tree arg3 = NULL;
490 switch (gimple_num_ops (gs))
492 case 4:
493 arg3 = gimple_assign_rhs3 (gs);
494 case 3:
495 arg2 = gimple_assign_rhs2 (gs);
496 case 2:
497 arg1 = gimple_assign_rhs1 (gs);
498 break;
499 default:
500 gcc_unreachable ();
503 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
504 get_tree_code_name (gimple_assign_rhs_code (gs)),
505 gimple_assign_lhs (gs), arg1, arg2, arg3);
507 else
509 if (!(flags & TDF_RHS_ONLY))
511 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
512 pp_space (buffer);
513 pp_equal (buffer);
515 if (gimple_assign_nontemporal_move_p (gs))
516 pp_string (buffer, "{nt}");
518 if (gimple_has_volatile_ops (gs))
519 pp_string (buffer, "{v}");
521 pp_space (buffer);
524 if (gimple_num_ops (gs) == 2)
525 dump_unary_rhs (buffer, gs, spc, flags);
526 else if (gimple_num_ops (gs) == 3)
527 dump_binary_rhs (buffer, gs, spc, flags);
528 else if (gimple_num_ops (gs) == 4)
529 dump_ternary_rhs (buffer, gs, spc, flags);
530 else
531 gcc_unreachable ();
532 if (!(flags & TDF_RHS_ONLY))
533 pp_semicolon (buffer);
538 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
539 pp_gimple_stmt_1. */
541 static void
542 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
544 tree t, t2;
546 t = gimple_return_retval (gs);
547 t2 = gimple_return_retbnd (gs);
548 if (flags & TDF_RAW)
549 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
550 else
552 pp_string (buffer, "return");
553 if (t)
555 pp_space (buffer);
556 dump_generic_node (buffer, t, spc, flags, false);
558 if (t2)
560 pp_string (buffer, ", ");
561 dump_generic_node (buffer, t2, spc, flags, false);
563 pp_semicolon (buffer);
568 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
569 dump_gimple_call. */
571 static void
572 dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags)
574 size_t i;
576 for (i = 0; i < gimple_call_num_args (gs); i++)
578 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
579 if (i < gimple_call_num_args (gs) - 1)
580 pp_string (buffer, ", ");
583 if (gimple_call_va_arg_pack_p (gs))
585 if (gimple_call_num_args (gs) > 0)
587 pp_comma (buffer);
588 pp_space (buffer);
591 pp_string (buffer, "__builtin_va_arg_pack ()");
595 /* Dump the points-to solution *PT to BUFFER. */
597 static void
598 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
600 if (pt->anything)
602 pp_string (buffer, "anything ");
603 return;
605 if (pt->nonlocal)
606 pp_string (buffer, "nonlocal ");
607 if (pt->escaped)
608 pp_string (buffer, "escaped ");
609 if (pt->ipa_escaped)
610 pp_string (buffer, "unit-escaped ");
611 if (pt->null)
612 pp_string (buffer, "null ");
613 if (pt->vars
614 && !bitmap_empty_p (pt->vars))
616 bitmap_iterator bi;
617 unsigned i;
618 pp_string (buffer, "{ ");
619 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
621 pp_string (buffer, "D.");
622 pp_decimal_int (buffer, i);
623 pp_space (buffer);
625 pp_right_brace (buffer);
626 if (pt->vars_contains_nonlocal
627 && pt->vars_contains_escaped_heap)
628 pp_string (buffer, " (nonlocal, escaped heap)");
629 else if (pt->vars_contains_nonlocal
630 && pt->vars_contains_escaped)
631 pp_string (buffer, " (nonlocal, escaped)");
632 else if (pt->vars_contains_nonlocal)
633 pp_string (buffer, " (nonlocal)");
634 else if (pt->vars_contains_escaped_heap)
635 pp_string (buffer, " (escaped heap)");
636 else if (pt->vars_contains_escaped)
637 pp_string (buffer, " (escaped)");
641 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
642 pp_gimple_stmt_1. */
644 static void
645 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
647 tree lhs = gimple_call_lhs (gs);
648 tree fn = gimple_call_fn (gs);
650 if (flags & TDF_ALIAS)
652 struct pt_solution *pt;
653 pt = gimple_call_use_set (gs);
654 if (!pt_solution_empty_p (pt))
656 pp_string (buffer, "# USE = ");
657 pp_points_to_solution (buffer, pt);
658 newline_and_indent (buffer, spc);
660 pt = gimple_call_clobber_set (gs);
661 if (!pt_solution_empty_p (pt))
663 pp_string (buffer, "# CLB = ");
664 pp_points_to_solution (buffer, pt);
665 newline_and_indent (buffer, spc);
669 if (flags & TDF_RAW)
671 if (gimple_call_internal_p (gs))
672 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
673 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
674 else
675 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
676 if (gimple_call_num_args (gs) > 0)
678 pp_string (buffer, ", ");
679 dump_gimple_call_args (buffer, gs, flags);
681 pp_greater (buffer);
683 else
685 if (lhs && !(flags & TDF_RHS_ONLY))
687 dump_generic_node (buffer, lhs, spc, flags, false);
688 pp_string (buffer, " =");
690 if (gimple_has_volatile_ops (gs))
691 pp_string (buffer, "{v}");
693 pp_space (buffer);
695 if (gimple_call_internal_p (gs))
696 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
697 else
698 print_call_name (buffer, fn, flags);
699 pp_string (buffer, " (");
700 dump_gimple_call_args (buffer, gs, flags);
701 pp_right_paren (buffer);
702 if (!(flags & TDF_RHS_ONLY))
703 pp_semicolon (buffer);
706 if (gimple_call_chain (gs))
708 pp_string (buffer, " [static-chain: ");
709 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
710 pp_right_bracket (buffer);
713 if (gimple_call_return_slot_opt_p (gs))
714 pp_string (buffer, " [return slot optimization]");
715 if (gimple_call_tail_p (gs))
716 pp_string (buffer, " [tail call]");
718 if (fn == NULL)
719 return;
721 /* Dump the arguments of _ITM_beginTransaction sanely. */
722 if (TREE_CODE (fn) == ADDR_EXPR)
723 fn = TREE_OPERAND (fn, 0);
724 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
725 pp_string (buffer, " [tm-clone]");
726 if (TREE_CODE (fn) == FUNCTION_DECL
727 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
728 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
729 && gimple_call_num_args (gs) > 0)
731 tree t = gimple_call_arg (gs, 0);
732 unsigned HOST_WIDE_INT props;
733 gcc_assert (TREE_CODE (t) == INTEGER_CST);
735 pp_string (buffer, " [ ");
737 /* Get the transaction code properties. */
738 props = TREE_INT_CST_LOW (t);
740 if (props & PR_INSTRUMENTEDCODE)
741 pp_string (buffer, "instrumentedCode ");
742 if (props & PR_UNINSTRUMENTEDCODE)
743 pp_string (buffer, "uninstrumentedCode ");
744 if (props & PR_HASNOXMMUPDATE)
745 pp_string (buffer, "hasNoXMMUpdate ");
746 if (props & PR_HASNOABORT)
747 pp_string (buffer, "hasNoAbort ");
748 if (props & PR_HASNOIRREVOCABLE)
749 pp_string (buffer, "hasNoIrrevocable ");
750 if (props & PR_DOESGOIRREVOCABLE)
751 pp_string (buffer, "doesGoIrrevocable ");
752 if (props & PR_HASNOSIMPLEREADS)
753 pp_string (buffer, "hasNoSimpleReads ");
754 if (props & PR_AWBARRIERSOMITTED)
755 pp_string (buffer, "awBarriersOmitted ");
756 if (props & PR_RARBARRIERSOMITTED)
757 pp_string (buffer, "RaRBarriersOmitted ");
758 if (props & PR_UNDOLOGCODE)
759 pp_string (buffer, "undoLogCode ");
760 if (props & PR_PREFERUNINSTRUMENTED)
761 pp_string (buffer, "preferUninstrumented ");
762 if (props & PR_EXCEPTIONBLOCK)
763 pp_string (buffer, "exceptionBlock ");
764 if (props & PR_HASELSE)
765 pp_string (buffer, "hasElse ");
766 if (props & PR_READONLY)
767 pp_string (buffer, "readOnly ");
769 pp_right_bracket (buffer);
774 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
775 pp_gimple_stmt_1. */
777 static void
778 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
780 unsigned int i;
782 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
783 if (flags & TDF_RAW)
784 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
785 gimple_switch_index (gs));
786 else
788 pp_string (buffer, "switch (");
789 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
790 pp_string (buffer, ") <");
793 for (i = 0; i < gimple_switch_num_labels (gs); i++)
795 tree case_label = gimple_switch_label (gs, i);
796 gcc_checking_assert (case_label != NULL_TREE);
797 dump_generic_node (buffer, case_label, spc, flags, false);
798 pp_space (buffer);
799 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
800 if (i < gimple_switch_num_labels (gs) - 1)
801 pp_string (buffer, ", ");
803 pp_greater (buffer);
807 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
808 pp_gimple_stmt_1. */
810 static void
811 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
813 if (flags & TDF_RAW)
814 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
815 get_tree_code_name (gimple_cond_code (gs)),
816 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
817 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
818 else
820 if (!(flags & TDF_RHS_ONLY))
821 pp_string (buffer, "if (");
822 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
823 pp_space (buffer);
824 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
825 pp_space (buffer);
826 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
827 if (!(flags & TDF_RHS_ONLY))
829 pp_right_paren (buffer);
831 if (gimple_cond_true_label (gs))
833 pp_string (buffer, " goto ");
834 dump_generic_node (buffer, gimple_cond_true_label (gs),
835 spc, flags, false);
836 pp_semicolon (buffer);
838 if (gimple_cond_false_label (gs))
840 pp_string (buffer, " else goto ");
841 dump_generic_node (buffer, gimple_cond_false_label (gs),
842 spc, flags, false);
843 pp_semicolon (buffer);
850 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
851 spaces of indent. FLAGS specifies details to show in the dump (see
852 TDF_* in dumpfils.h). */
854 static void
855 dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
857 tree label = gimple_label_label (gs);
858 if (flags & TDF_RAW)
859 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
860 else
862 dump_generic_node (buffer, label, spc, flags, false);
863 pp_colon (buffer);
865 if (DECL_NONLOCAL (label))
866 pp_string (buffer, " [non-local]");
867 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
868 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
871 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
872 spaces of indent. FLAGS specifies details to show in the dump (see
873 TDF_* in dumpfile.h). */
875 static void
876 dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
878 tree label = gimple_goto_dest (gs);
879 if (flags & TDF_RAW)
880 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
881 else
882 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
886 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
887 spaces of indent. FLAGS specifies details to show in the dump (see
888 TDF_* in dumpfile.h). */
890 static void
891 dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
893 if (flags & TDF_RAW)
894 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
895 else
896 pp_left_brace (buffer);
897 if (!(flags & TDF_SLIM))
899 tree var;
901 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
903 newline_and_indent (buffer, 2);
904 print_declaration (buffer, var, spc, flags);
906 if (gimple_bind_vars (gs))
907 pp_newline (buffer);
909 pp_newline (buffer);
910 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
911 newline_and_indent (buffer, spc);
912 if (flags & TDF_RAW)
913 pp_greater (buffer);
914 else
915 pp_right_brace (buffer);
919 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
920 indent. FLAGS specifies details to show in the dump (see TDF_* in
921 dumpfile.h). */
923 static void
924 dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
926 if (flags & TDF_RAW)
928 const char *type;
929 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
930 type = "GIMPLE_TRY_CATCH";
931 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
932 type = "GIMPLE_TRY_FINALLY";
933 else
934 type = "UNKNOWN GIMPLE_TRY";
935 dump_gimple_fmt (buffer, spc, flags,
936 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
937 gimple_try_eval (gs), gimple_try_cleanup (gs));
939 else
941 pp_string (buffer, "try");
942 newline_and_indent (buffer, spc + 2);
943 pp_left_brace (buffer);
944 pp_newline (buffer);
946 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
947 newline_and_indent (buffer, spc + 2);
948 pp_right_brace (buffer);
950 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
952 newline_and_indent (buffer, spc);
953 pp_string (buffer, "catch");
954 newline_and_indent (buffer, spc + 2);
955 pp_left_brace (buffer);
957 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
959 newline_and_indent (buffer, spc);
960 pp_string (buffer, "finally");
961 newline_and_indent (buffer, spc + 2);
962 pp_left_brace (buffer);
964 else
965 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
967 pp_newline (buffer);
968 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
969 newline_and_indent (buffer, spc + 2);
970 pp_right_brace (buffer);
975 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
976 indent. FLAGS specifies details to show in the dump (see TDF_* in
977 dumpfile.h). */
979 static void
980 dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
982 if (flags & TDF_RAW)
983 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
984 gimple_catch_types (gs), gimple_catch_handler (gs));
985 else
986 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
987 gimple_catch_types (gs), gimple_catch_handler (gs));
991 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
992 indent. FLAGS specifies details to show in the dump (see TDF_* in
993 dumpfile.h). */
995 static void
996 dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
998 if (flags & TDF_RAW)
999 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1000 gimple_eh_filter_types (gs),
1001 gimple_eh_filter_failure (gs));
1002 else
1003 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1004 gimple_eh_filter_types (gs),
1005 gimple_eh_filter_failure (gs));
1009 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1011 static void
1012 dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
1013 int spc, int flags)
1015 if (flags & TDF_RAW)
1016 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1017 gimple_eh_must_not_throw_fndecl (gs));
1018 else
1019 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1020 gimple_eh_must_not_throw_fndecl (gs));
1024 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1025 indent. FLAGS specifies details to show in the dump (see TDF_* in
1026 dumpfile.h). */
1028 static void
1029 dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags)
1031 if (flags & TDF_RAW)
1032 dump_gimple_fmt (buffer, spc, flags,
1033 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1034 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1035 else
1036 dump_gimple_fmt (buffer, spc, flags,
1037 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1038 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1042 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1043 indent. FLAGS specifies details to show in the dump (see TDF_* in
1044 dumpfile.h). */
1046 static void
1047 dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
1049 if (flags & TDF_RAW)
1050 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1051 gimple_resx_region (gs));
1052 else
1053 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1056 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1058 static void
1059 dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
1061 if (flags & TDF_RAW)
1062 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1063 gimple_eh_dispatch_region (gs));
1064 else
1065 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1066 gimple_eh_dispatch_region (gs));
1069 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1070 of indent. FLAGS specifies details to show in the dump (see TDF_*
1071 in dumpfile.h). */
1073 static void
1074 dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
1076 switch (gs->subcode)
1078 case GIMPLE_DEBUG_BIND:
1079 if (flags & TDF_RAW)
1080 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1081 gimple_debug_bind_get_var (gs),
1082 gimple_debug_bind_get_value (gs));
1083 else
1084 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1085 gimple_debug_bind_get_var (gs),
1086 gimple_debug_bind_get_value (gs));
1087 break;
1089 case GIMPLE_DEBUG_SOURCE_BIND:
1090 if (flags & TDF_RAW)
1091 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1092 gimple_debug_source_bind_get_var (gs),
1093 gimple_debug_source_bind_get_value (gs));
1094 else
1095 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1096 gimple_debug_source_bind_get_var (gs),
1097 gimple_debug_source_bind_get_value (gs));
1098 break;
1100 default:
1101 gcc_unreachable ();
1105 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1106 static void
1107 dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
1109 size_t i;
1111 if (flags & TDF_RAW)
1113 const char *kind;
1114 switch (gimple_omp_for_kind (gs))
1116 case GF_OMP_FOR_KIND_FOR:
1117 kind = "";
1118 break;
1119 case GF_OMP_FOR_KIND_SIMD:
1120 kind = " simd";
1121 break;
1122 case GF_OMP_FOR_KIND_CILKSIMD:
1123 kind = " cilksimd";
1124 case GF_OMP_FOR_KIND_DISTRIBUTE:
1125 kind = " distribute";
1126 break;
1127 default:
1128 gcc_unreachable ();
1130 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1131 kind, gimple_omp_body (gs));
1132 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1133 dump_gimple_fmt (buffer, spc, flags, " >,");
1134 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1135 dump_gimple_fmt (buffer, spc, flags,
1136 "%+%T, %T, %T, %s, %T,%n",
1137 gimple_omp_for_index (gs, i),
1138 gimple_omp_for_initial (gs, i),
1139 gimple_omp_for_final (gs, i),
1140 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1141 gimple_omp_for_incr (gs, i));
1142 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1143 gimple_omp_for_pre_body (gs));
1145 else
1147 switch (gimple_omp_for_kind (gs))
1149 case GF_OMP_FOR_KIND_FOR:
1150 pp_string (buffer, "#pragma omp for");
1151 break;
1152 case GF_OMP_FOR_KIND_SIMD:
1153 pp_string (buffer, "#pragma omp simd");
1154 break;
1155 case GF_OMP_FOR_KIND_CILKSIMD:
1156 pp_string (buffer, "#pragma simd");
1157 break;
1158 case GF_OMP_FOR_KIND_DISTRIBUTE:
1159 pp_string (buffer, "#pragma omp distribute");
1160 break;
1161 default:
1162 gcc_unreachable ();
1164 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1165 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1167 if (i)
1168 spc += 2;
1169 newline_and_indent (buffer, spc);
1170 pp_string (buffer, "for (");
1171 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1172 flags, false);
1173 pp_string (buffer, " = ");
1174 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1175 flags, false);
1176 pp_string (buffer, "; ");
1178 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1179 flags, false);
1180 pp_space (buffer);
1181 switch (gimple_omp_for_cond (gs, i))
1183 case LT_EXPR:
1184 pp_less (buffer);
1185 break;
1186 case GT_EXPR:
1187 pp_greater (buffer);
1188 break;
1189 case LE_EXPR:
1190 pp_less_equal (buffer);
1191 break;
1192 case GE_EXPR:
1193 pp_greater_equal (buffer);
1194 break;
1195 default:
1196 gcc_unreachable ();
1198 pp_space (buffer);
1199 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1200 flags, false);
1201 pp_string (buffer, "; ");
1203 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1204 flags, false);
1205 pp_string (buffer, " = ");
1206 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1207 flags, false);
1208 pp_right_paren (buffer);
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_CONTINUE tuple on the pretty_printer BUFFER. */
1225 static void
1226 dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags)
1228 if (flags & TDF_RAW)
1230 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1231 gimple_omp_continue_control_def (gs),
1232 gimple_omp_continue_control_use (gs));
1234 else
1236 pp_string (buffer, "#pragma omp continue (");
1237 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1238 spc, flags, false);
1239 pp_comma (buffer);
1240 pp_space (buffer);
1241 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1242 spc, flags, false);
1243 pp_right_paren (buffer);
1247 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1249 static void
1250 dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, int flags)
1252 if (flags & TDF_RAW)
1254 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1255 gimple_omp_body (gs));
1256 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1257 dump_gimple_fmt (buffer, spc, flags, " >");
1259 else
1261 pp_string (buffer, "#pragma omp single");
1262 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1263 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1265 newline_and_indent (buffer, spc + 2);
1266 pp_left_brace (buffer);
1267 pp_newline (buffer);
1268 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1269 newline_and_indent (buffer, spc + 2);
1270 pp_right_brace (buffer);
1275 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1277 static void
1278 dump_gimple_omp_target (pretty_printer *buffer, gimple gs, int spc, int flags)
1280 const char *kind;
1281 switch (gimple_omp_target_kind (gs))
1283 case GF_OMP_TARGET_KIND_REGION:
1284 kind = "";
1285 break;
1286 case GF_OMP_TARGET_KIND_DATA:
1287 kind = " data";
1288 break;
1289 case GF_OMP_TARGET_KIND_UPDATE:
1290 kind = " update";
1291 break;
1292 default:
1293 gcc_unreachable ();
1295 if (flags & TDF_RAW)
1297 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1298 kind, gimple_omp_body (gs));
1299 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1300 dump_gimple_fmt (buffer, spc, flags, " >");
1302 else
1304 pp_string (buffer, "#pragma omp target");
1305 pp_string (buffer, kind);
1306 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1307 if (gimple_omp_target_child_fn (gs))
1309 pp_string (buffer, " [child fn: ");
1310 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1311 spc, flags, false);
1312 pp_right_bracket (buffer);
1314 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1316 newline_and_indent (buffer, spc + 2);
1317 pp_character (buffer, '{');
1318 pp_newline (buffer);
1319 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1320 newline_and_indent (buffer, spc + 2);
1321 pp_character (buffer, '}');
1326 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1328 static void
1329 dump_gimple_omp_teams (pretty_printer *buffer, gimple gs, int spc, int flags)
1331 if (flags & TDF_RAW)
1333 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1334 gimple_omp_body (gs));
1335 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1336 dump_gimple_fmt (buffer, spc, flags, " >");
1338 else
1340 pp_string (buffer, "#pragma omp teams");
1341 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1342 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1344 newline_and_indent (buffer, spc + 2);
1345 pp_character (buffer, '{');
1346 pp_newline (buffer);
1347 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1348 newline_and_indent (buffer, spc + 2);
1349 pp_character (buffer, '}');
1354 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1356 static void
1357 dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
1358 int flags)
1360 if (flags & TDF_RAW)
1362 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1363 gimple_omp_body (gs));
1364 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1365 dump_gimple_fmt (buffer, spc, flags, " >");
1367 else
1369 pp_string (buffer, "#pragma omp sections");
1370 if (gimple_omp_sections_control (gs))
1372 pp_string (buffer, " <");
1373 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1374 flags, false);
1375 pp_greater (buffer);
1377 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1378 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1380 newline_and_indent (buffer, spc + 2);
1381 pp_left_brace (buffer);
1382 pp_newline (buffer);
1383 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1384 newline_and_indent (buffer, spc + 2);
1385 pp_right_brace (buffer);
1390 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1391 pretty_printer BUFFER. */
1393 static void
1394 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1396 if (flags & TDF_RAW)
1397 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1398 gimple_omp_body (gs));
1399 else
1401 switch (gimple_code (gs))
1403 case GIMPLE_OMP_MASTER:
1404 pp_string (buffer, "#pragma omp master");
1405 break;
1406 case GIMPLE_OMP_TASKGROUP:
1407 pp_string (buffer, "#pragma omp taskgroup");
1408 break;
1409 case GIMPLE_OMP_ORDERED:
1410 pp_string (buffer, "#pragma omp ordered");
1411 break;
1412 case GIMPLE_OMP_SECTION:
1413 pp_string (buffer, "#pragma omp section");
1414 break;
1415 default:
1416 gcc_unreachable ();
1418 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1420 newline_and_indent (buffer, spc + 2);
1421 pp_left_brace (buffer);
1422 pp_newline (buffer);
1423 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1424 newline_and_indent (buffer, spc + 2);
1425 pp_right_brace (buffer);
1430 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1432 static void
1433 dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
1434 int flags)
1436 if (flags & TDF_RAW)
1437 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1438 gimple_omp_body (gs));
1439 else
1441 pp_string (buffer, "#pragma omp critical");
1442 if (gimple_omp_critical_name (gs))
1444 pp_string (buffer, " (");
1445 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1446 flags, false);
1447 pp_right_paren (buffer);
1449 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1451 newline_and_indent (buffer, spc + 2);
1452 pp_left_brace (buffer);
1453 pp_newline (buffer);
1454 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1455 newline_and_indent (buffer, spc + 2);
1456 pp_right_brace (buffer);
1461 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1463 static void
1464 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1466 if (flags & TDF_RAW)
1468 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1469 (int) gimple_omp_return_nowait_p (gs));
1470 if (gimple_omp_return_lhs (gs))
1471 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1472 gimple_omp_return_lhs (gs));
1473 else
1474 dump_gimple_fmt (buffer, spc, flags, ">");
1476 else
1478 pp_string (buffer, "#pragma omp return");
1479 if (gimple_omp_return_nowait_p (gs))
1480 pp_string (buffer, "(nowait)");
1481 if (gimple_omp_return_lhs (gs))
1483 pp_string (buffer, " (set ");
1484 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1485 spc, flags, false);
1486 pp_character (buffer, ')');
1491 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1493 static void
1494 dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags)
1496 unsigned subcode = gimple_transaction_subcode (gs);
1498 if (flags & TDF_RAW)
1500 dump_gimple_fmt (buffer, spc, flags,
1501 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1502 gs, subcode, gimple_transaction_label (gs),
1503 gimple_transaction_body (gs));
1505 else
1507 if (subcode & GTMA_IS_OUTER)
1508 pp_string (buffer, "__transaction_atomic [[outer]]");
1509 else if (subcode & GTMA_IS_RELAXED)
1510 pp_string (buffer, "__transaction_relaxed");
1511 else
1512 pp_string (buffer, "__transaction_atomic");
1513 subcode &= ~GTMA_DECLARATION_MASK;
1515 if (subcode || gimple_transaction_label (gs))
1517 pp_string (buffer, " //");
1518 if (gimple_transaction_label (gs))
1520 pp_string (buffer, " LABEL=");
1521 dump_generic_node (buffer, gimple_transaction_label (gs),
1522 spc, flags, false);
1524 if (subcode)
1526 pp_string (buffer, " SUBCODE=[ ");
1527 if (subcode & GTMA_HAVE_ABORT)
1529 pp_string (buffer, "GTMA_HAVE_ABORT ");
1530 subcode &= ~GTMA_HAVE_ABORT;
1532 if (subcode & GTMA_HAVE_LOAD)
1534 pp_string (buffer, "GTMA_HAVE_LOAD ");
1535 subcode &= ~GTMA_HAVE_LOAD;
1537 if (subcode & GTMA_HAVE_STORE)
1539 pp_string (buffer, "GTMA_HAVE_STORE ");
1540 subcode &= ~GTMA_HAVE_STORE;
1542 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1544 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1545 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1547 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1549 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1550 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1552 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1554 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1555 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1557 if (subcode)
1558 pp_printf (buffer, "0x%x ", subcode);
1559 pp_right_bracket (buffer);
1563 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1565 newline_and_indent (buffer, spc + 2);
1566 pp_left_brace (buffer);
1567 pp_newline (buffer);
1568 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1569 spc + 4, flags);
1570 newline_and_indent (buffer, spc + 2);
1571 pp_right_brace (buffer);
1576 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1577 indent. FLAGS specifies details to show in the dump (see TDF_* in
1578 dumpfile.h). */
1580 static void
1581 dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
1583 unsigned int i, n, f, fields;
1585 if (flags & TDF_RAW)
1587 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1588 gimple_asm_string (gs));
1590 n = gimple_asm_noutputs (gs);
1591 if (n)
1593 newline_and_indent (buffer, spc + 2);
1594 pp_string (buffer, "OUTPUT: ");
1595 for (i = 0; i < n; i++)
1597 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1598 spc, flags, false);
1599 if (i < n - 1)
1600 pp_string (buffer, ", ");
1604 n = gimple_asm_ninputs (gs);
1605 if (n)
1607 newline_and_indent (buffer, spc + 2);
1608 pp_string (buffer, "INPUT: ");
1609 for (i = 0; i < n; i++)
1611 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1612 spc, flags, false);
1613 if (i < n - 1)
1614 pp_string (buffer, ", ");
1618 n = gimple_asm_nclobbers (gs);
1619 if (n)
1621 newline_and_indent (buffer, spc + 2);
1622 pp_string (buffer, "CLOBBER: ");
1623 for (i = 0; i < n; i++)
1625 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1626 spc, flags, false);
1627 if (i < n - 1)
1628 pp_string (buffer, ", ");
1632 n = gimple_asm_nlabels (gs);
1633 if (n)
1635 newline_and_indent (buffer, spc + 2);
1636 pp_string (buffer, "LABEL: ");
1637 for (i = 0; i < n; i++)
1639 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1640 spc, flags, false);
1641 if (i < n - 1)
1642 pp_string (buffer, ", ");
1646 newline_and_indent (buffer, spc);
1647 pp_greater (buffer);
1649 else
1651 pp_string (buffer, "__asm__");
1652 if (gimple_asm_volatile_p (gs))
1653 pp_string (buffer, " __volatile__");
1654 if (gimple_asm_nlabels (gs))
1655 pp_string (buffer, " goto");
1656 pp_string (buffer, "(\"");
1657 pp_string (buffer, gimple_asm_string (gs));
1658 pp_string (buffer, "\"");
1660 if (gimple_asm_nlabels (gs))
1661 fields = 4;
1662 else if (gimple_asm_nclobbers (gs))
1663 fields = 3;
1664 else if (gimple_asm_ninputs (gs))
1665 fields = 2;
1666 else if (gimple_asm_noutputs (gs))
1667 fields = 1;
1668 else
1669 fields = 0;
1671 for (f = 0; f < fields; ++f)
1673 pp_string (buffer, " : ");
1675 switch (f)
1677 case 0:
1678 n = gimple_asm_noutputs (gs);
1679 for (i = 0; i < n; i++)
1681 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1682 spc, flags, false);
1683 if (i < n - 1)
1684 pp_string (buffer, ", ");
1686 break;
1688 case 1:
1689 n = gimple_asm_ninputs (gs);
1690 for (i = 0; i < n; i++)
1692 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1693 spc, flags, false);
1694 if (i < n - 1)
1695 pp_string (buffer, ", ");
1697 break;
1699 case 2:
1700 n = gimple_asm_nclobbers (gs);
1701 for (i = 0; i < n; i++)
1703 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1704 spc, flags, false);
1705 if (i < n - 1)
1706 pp_string (buffer, ", ");
1708 break;
1710 case 3:
1711 n = gimple_asm_nlabels (gs);
1712 for (i = 0; i < n; i++)
1714 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1715 spc, flags, false);
1716 if (i < n - 1)
1717 pp_string (buffer, ", ");
1719 break;
1721 default:
1722 gcc_unreachable ();
1726 pp_string (buffer, ");");
1730 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1731 SPC spaces of indent. */
1733 static void
1734 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1736 if (TREE_CODE (node) != SSA_NAME)
1737 return;
1739 if (POINTER_TYPE_P (TREE_TYPE (node))
1740 && SSA_NAME_PTR_INFO (node))
1742 unsigned int align, misalign;
1743 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1744 pp_string (buffer, "# PT = ");
1745 pp_points_to_solution (buffer, &pi->pt);
1746 newline_and_indent (buffer, spc);
1747 if (get_ptr_info_alignment (pi, &align, &misalign))
1749 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1750 newline_and_indent (buffer, spc);
1754 if (!POINTER_TYPE_P (TREE_TYPE (node))
1755 && SSA_NAME_RANGE_INFO (node))
1757 double_int min, max, nonzero_bits;
1758 value_range_type range_type = get_range_info (node, &min, &max);
1760 if (range_type == VR_VARYING)
1761 pp_printf (buffer, "# RANGE VR_VARYING");
1762 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1764 pp_printf (buffer, "# RANGE ");
1765 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1766 pp_double_int (buffer, min, TYPE_UNSIGNED (TREE_TYPE (node)));
1767 pp_printf (buffer, ", ");
1768 pp_double_int (buffer, max, TYPE_UNSIGNED (TREE_TYPE (node)));
1769 pp_printf (buffer, "]");
1771 nonzero_bits = get_nonzero_bits (node);
1772 if (nonzero_bits != double_int_minus_one
1773 && (nonzero_bits
1774 != double_int::mask (TYPE_PRECISION (TREE_TYPE (node)))))
1776 pp_string (buffer, " NONZERO ");
1777 sprintf (pp_buffer (buffer)->digit_buffer,
1778 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
1779 (unsigned HOST_WIDE_INT) nonzero_bits.high,
1780 nonzero_bits.low);
1781 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
1783 newline_and_indent (buffer, spc);
1788 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1789 The caller is responsible for calling pp_flush on BUFFER to finalize
1790 pretty printer. If COMMENT is true, print this after #. */
1792 static void
1793 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, bool comment,
1794 int flags)
1796 size_t i;
1797 tree lhs = gimple_phi_result (phi);
1799 if (flags & TDF_ALIAS)
1800 dump_ssaname_info (buffer, lhs, spc);
1802 if (comment)
1803 pp_string (buffer, "# ");
1805 if (flags & TDF_RAW)
1806 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1807 gimple_phi_result (phi));
1808 else
1810 dump_generic_node (buffer, lhs, spc, flags, false);
1811 pp_string (buffer, " = PHI <");
1813 for (i = 0; i < gimple_phi_num_args (phi); i++)
1815 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1817 expanded_location xloc;
1819 xloc = expand_location (gimple_phi_arg_location (phi, i));
1820 pp_left_bracket (buffer);
1821 if (xloc.file)
1823 pp_string (buffer, xloc.file);
1824 pp_string (buffer, " : ");
1826 pp_decimal_int (buffer, xloc.line);
1827 pp_colon (buffer);
1828 pp_decimal_int (buffer, xloc.column);
1829 pp_string (buffer, "] ");
1831 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1832 false);
1833 pp_left_paren (buffer);
1834 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1835 pp_right_paren (buffer);
1836 if (i < gimple_phi_num_args (phi) - 1)
1837 pp_string (buffer, ", ");
1839 pp_greater (buffer);
1843 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1844 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1845 dumpfile.h). */
1847 static void
1848 dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1849 int flags)
1851 if (flags & TDF_RAW)
1853 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1854 gimple_omp_body (gs));
1855 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1856 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1857 gimple_omp_parallel_child_fn (gs),
1858 gimple_omp_parallel_data_arg (gs));
1860 else
1862 gimple_seq body;
1863 pp_string (buffer, "#pragma omp parallel");
1864 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1865 if (gimple_omp_parallel_child_fn (gs))
1867 pp_string (buffer, " [child fn: ");
1868 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1869 spc, flags, false);
1870 pp_string (buffer, " (");
1871 if (gimple_omp_parallel_data_arg (gs))
1872 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1873 spc, flags, false);
1874 else
1875 pp_string (buffer, "???");
1876 pp_string (buffer, ")]");
1878 body = gimple_omp_body (gs);
1879 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1881 newline_and_indent (buffer, spc + 2);
1882 pp_left_brace (buffer);
1883 pp_newline (buffer);
1884 dump_gimple_seq (buffer, body, spc + 4, flags);
1885 newline_and_indent (buffer, spc + 2);
1886 pp_right_brace (buffer);
1888 else if (body)
1890 pp_newline (buffer);
1891 dump_gimple_seq (buffer, body, spc + 2, flags);
1897 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1898 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1899 dumpfile.h). */
1901 static void
1902 dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
1903 int flags)
1905 if (flags & TDF_RAW)
1907 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1908 gimple_omp_body (gs));
1909 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1910 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1911 gimple_omp_task_child_fn (gs),
1912 gimple_omp_task_data_arg (gs),
1913 gimple_omp_task_copy_fn (gs),
1914 gimple_omp_task_arg_size (gs),
1915 gimple_omp_task_arg_size (gs));
1917 else
1919 gimple_seq body;
1920 pp_string (buffer, "#pragma omp task");
1921 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1922 if (gimple_omp_task_child_fn (gs))
1924 pp_string (buffer, " [child fn: ");
1925 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1926 spc, flags, false);
1927 pp_string (buffer, " (");
1928 if (gimple_omp_task_data_arg (gs))
1929 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1930 spc, flags, false);
1931 else
1932 pp_string (buffer, "???");
1933 pp_string (buffer, ")]");
1935 body = gimple_omp_body (gs);
1936 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1938 newline_and_indent (buffer, spc + 2);
1939 pp_left_brace (buffer);
1940 pp_newline (buffer);
1941 dump_gimple_seq (buffer, body, spc + 4, flags);
1942 newline_and_indent (buffer, spc + 2);
1943 pp_right_brace (buffer);
1945 else if (body)
1947 pp_newline (buffer);
1948 dump_gimple_seq (buffer, body, spc + 2, flags);
1954 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1955 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1956 in dumpfile.h). */
1958 static void
1959 dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
1960 int flags)
1962 if (flags & TDF_RAW)
1964 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1965 gimple_omp_atomic_load_lhs (gs),
1966 gimple_omp_atomic_load_rhs (gs));
1968 else
1970 pp_string (buffer, "#pragma omp atomic_load");
1971 if (gimple_omp_atomic_seq_cst_p (gs))
1972 pp_string (buffer, " seq_cst");
1973 if (gimple_omp_atomic_need_value_p (gs))
1974 pp_string (buffer, " [needed]");
1975 newline_and_indent (buffer, spc + 2);
1976 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
1977 spc, flags, false);
1978 pp_space (buffer);
1979 pp_equal (buffer);
1980 pp_space (buffer);
1981 pp_star (buffer);
1982 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
1983 spc, flags, false);
1987 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1988 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1989 in dumpfile.h). */
1991 static void
1992 dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
1993 int flags)
1995 if (flags & TDF_RAW)
1997 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1998 gimple_omp_atomic_store_val (gs));
2000 else
2002 pp_string (buffer, "#pragma omp atomic_store ");
2003 if (gimple_omp_atomic_seq_cst_p (gs))
2004 pp_string (buffer, "seq_cst ");
2005 if (gimple_omp_atomic_need_value_p (gs))
2006 pp_string (buffer, "[needed] ");
2007 pp_left_paren (buffer);
2008 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2009 spc, flags, false);
2010 pp_right_paren (buffer);
2015 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2016 FLAGS are as in pp_gimple_stmt_1. */
2018 static void
2019 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
2021 tree vdef = gimple_vdef (gs);
2022 tree vuse = gimple_vuse (gs);
2024 if (!ssa_operands_active (DECL_STRUCT_FUNCTION (current_function_decl))
2025 || !gimple_references_memory_p (gs))
2026 return;
2028 if (vdef != NULL_TREE)
2030 pp_string (buffer, "# ");
2031 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2032 pp_string (buffer, " = VDEF <");
2033 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2034 pp_greater (buffer);
2035 newline_and_indent (buffer, spc);
2037 else if (vuse != NULL_TREE)
2039 pp_string (buffer, "# VUSE <");
2040 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2041 pp_greater (buffer);
2042 newline_and_indent (buffer, spc);
2047 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2048 spaces of indent. FLAGS specifies details to show in the dump (see
2049 TDF_* in dumpfile.h). The caller is responsible for calling
2050 pp_flush on BUFFER to finalize the pretty printer. */
2052 void
2053 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
2055 if (!gs)
2056 return;
2058 if (flags & TDF_STMTADDR)
2059 pp_printf (buffer, "<&%p> ", (void *) gs);
2061 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2063 expanded_location xloc = expand_location (gimple_location (gs));
2064 pp_left_bracket (buffer);
2065 if (xloc.file)
2067 pp_string (buffer, xloc.file);
2068 pp_string (buffer, " : ");
2070 pp_decimal_int (buffer, xloc.line);
2071 pp_colon (buffer);
2072 pp_decimal_int (buffer, xloc.column);
2073 pp_string (buffer, "] ");
2076 if (flags & TDF_EH)
2078 int lp_nr = lookup_stmt_eh_lp (gs);
2079 if (lp_nr > 0)
2080 pp_printf (buffer, "[LP %d] ", lp_nr);
2081 else if (lp_nr < 0)
2082 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2085 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2086 && gimple_has_mem_ops (gs))
2087 dump_gimple_mem_ops (buffer, gs, spc, flags);
2089 if (gimple_has_lhs (gs)
2090 && (flags & TDF_ALIAS))
2091 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2093 switch (gimple_code (gs))
2095 case GIMPLE_ASM:
2096 dump_gimple_asm (buffer, gs, spc, flags);
2097 break;
2099 case GIMPLE_ASSIGN:
2100 dump_gimple_assign (buffer, gs, spc, flags);
2101 break;
2103 case GIMPLE_BIND:
2104 dump_gimple_bind (buffer, gs, spc, flags);
2105 break;
2107 case GIMPLE_CALL:
2108 dump_gimple_call (buffer, gs, spc, flags);
2109 break;
2111 case GIMPLE_COND:
2112 dump_gimple_cond (buffer, gs, spc, flags);
2113 break;
2115 case GIMPLE_LABEL:
2116 dump_gimple_label (buffer, gs, spc, flags);
2117 break;
2119 case GIMPLE_GOTO:
2120 dump_gimple_goto (buffer, gs, spc, flags);
2121 break;
2123 case GIMPLE_NOP:
2124 pp_string (buffer, "GIMPLE_NOP");
2125 break;
2127 case GIMPLE_RETURN:
2128 dump_gimple_return (buffer, gs, spc, flags);
2129 break;
2131 case GIMPLE_SWITCH:
2132 dump_gimple_switch (buffer, gs, spc, flags);
2133 break;
2135 case GIMPLE_TRY:
2136 dump_gimple_try (buffer, gs, spc, flags);
2137 break;
2139 case GIMPLE_PHI:
2140 dump_gimple_phi (buffer, gs, spc, false, flags);
2141 break;
2143 case GIMPLE_OMP_PARALLEL:
2144 dump_gimple_omp_parallel (buffer, gs, spc, flags);
2145 break;
2147 case GIMPLE_OMP_TASK:
2148 dump_gimple_omp_task (buffer, gs, spc, flags);
2149 break;
2151 case GIMPLE_OMP_ATOMIC_LOAD:
2152 dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
2154 break;
2156 case GIMPLE_OMP_ATOMIC_STORE:
2157 dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
2158 break;
2160 case GIMPLE_OMP_FOR:
2161 dump_gimple_omp_for (buffer, gs, spc, flags);
2162 break;
2164 case GIMPLE_OMP_CONTINUE:
2165 dump_gimple_omp_continue (buffer, gs, spc, flags);
2166 break;
2168 case GIMPLE_OMP_SINGLE:
2169 dump_gimple_omp_single (buffer, gs, spc, flags);
2170 break;
2172 case GIMPLE_OMP_TARGET:
2173 dump_gimple_omp_target (buffer, gs, spc, flags);
2174 break;
2176 case GIMPLE_OMP_TEAMS:
2177 dump_gimple_omp_teams (buffer, gs, spc, flags);
2178 break;
2180 case GIMPLE_OMP_RETURN:
2181 dump_gimple_omp_return (buffer, gs, spc, flags);
2182 break;
2184 case GIMPLE_OMP_SECTIONS:
2185 dump_gimple_omp_sections (buffer, gs, spc, flags);
2186 break;
2188 case GIMPLE_OMP_SECTIONS_SWITCH:
2189 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2190 break;
2192 case GIMPLE_OMP_MASTER:
2193 case GIMPLE_OMP_TASKGROUP:
2194 case GIMPLE_OMP_ORDERED:
2195 case GIMPLE_OMP_SECTION:
2196 dump_gimple_omp_block (buffer, gs, spc, flags);
2197 break;
2199 case GIMPLE_OMP_CRITICAL:
2200 dump_gimple_omp_critical (buffer, gs, spc, flags);
2201 break;
2203 case GIMPLE_CATCH:
2204 dump_gimple_catch (buffer, gs, spc, flags);
2205 break;
2207 case GIMPLE_EH_FILTER:
2208 dump_gimple_eh_filter (buffer, gs, spc, flags);
2209 break;
2211 case GIMPLE_EH_MUST_NOT_THROW:
2212 dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
2213 break;
2215 case GIMPLE_EH_ELSE:
2216 dump_gimple_eh_else (buffer, gs, spc, flags);
2217 break;
2219 case GIMPLE_RESX:
2220 dump_gimple_resx (buffer, gs, spc, flags);
2221 break;
2223 case GIMPLE_EH_DISPATCH:
2224 dump_gimple_eh_dispatch (buffer, gs, spc, flags);
2225 break;
2227 case GIMPLE_DEBUG:
2228 dump_gimple_debug (buffer, gs, spc, flags);
2229 break;
2231 case GIMPLE_PREDICT:
2232 pp_string (buffer, "// predicted ");
2233 if (gimple_predict_outcome (gs))
2234 pp_string (buffer, "likely by ");
2235 else
2236 pp_string (buffer, "unlikely by ");
2237 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2238 pp_string (buffer, " predictor.");
2239 break;
2241 case GIMPLE_TRANSACTION:
2242 dump_gimple_transaction (buffer, gs, spc, flags);
2243 break;
2245 default:
2246 GIMPLE_NIY;
2251 /* Dumps header of basic block BB to OUTF indented by INDENT
2252 spaces and details described by flags. */
2254 static void
2255 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2257 if (flags & TDF_BLOCKS)
2259 if (flags & TDF_LINENO)
2261 gimple_stmt_iterator gsi;
2263 if (flags & TDF_COMMENT)
2264 fputs (";; ", outf);
2266 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2267 if (!is_gimple_debug (gsi_stmt (gsi))
2268 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2270 fprintf (outf, "%*sstarting at line %d",
2271 indent, "", get_lineno (gsi_stmt (gsi)));
2272 break;
2274 if (bb->discriminator)
2275 fprintf (outf, ", discriminator %i", bb->discriminator);
2276 fputc ('\n', outf);
2279 else
2281 gimple stmt = first_stmt (bb);
2282 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2283 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2288 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2289 spaces. */
2291 static void
2292 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2293 basic_block bb ATTRIBUTE_UNUSED,
2294 int indent ATTRIBUTE_UNUSED,
2295 int flags ATTRIBUTE_UNUSED)
2297 /* There is currently no GIMPLE-specific basic block info to dump. */
2298 return;
2302 /* Dump PHI nodes of basic block BB to BUFFER with details described
2303 by FLAGS and indented by INDENT spaces. */
2305 static void
2306 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2308 gimple_stmt_iterator i;
2310 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2312 gimple phi = gsi_stmt (i);
2313 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2315 INDENT (indent);
2316 dump_gimple_phi (buffer, phi, indent, true, flags);
2317 pp_newline (buffer);
2323 /* Dump jump to basic block BB that is represented implicitly in the cfg
2324 to BUFFER. */
2326 static void
2327 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2329 gimple stmt;
2331 stmt = first_stmt (bb);
2333 pp_string (buffer, "goto <bb ");
2334 pp_decimal_int (buffer, bb->index);
2335 pp_greater (buffer);
2336 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2338 pp_string (buffer, " (");
2339 dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
2340 pp_right_paren (buffer);
2341 pp_semicolon (buffer);
2343 else
2344 pp_semicolon (buffer);
2348 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2349 by INDENT spaces, with details given by FLAGS. */
2351 static void
2352 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2353 int flags)
2355 edge e;
2356 gimple stmt;
2358 stmt = last_stmt (bb);
2360 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2362 edge true_edge, false_edge;
2364 /* When we are emitting the code or changing CFG, it is possible that
2365 the edges are not yet created. When we are using debug_bb in such
2366 a situation, we do not want it to crash. */
2367 if (EDGE_COUNT (bb->succs) != 2)
2368 return;
2369 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2371 INDENT (indent + 2);
2372 pp_cfg_jump (buffer, true_edge->dest);
2373 newline_and_indent (buffer, indent);
2374 pp_string (buffer, "else");
2375 newline_and_indent (buffer, indent + 2);
2376 pp_cfg_jump (buffer, false_edge->dest);
2377 pp_newline (buffer);
2378 return;
2381 /* If there is a fallthru edge, we may need to add an artificial
2382 goto to the dump. */
2383 e = find_fallthru_edge (bb->succs);
2385 if (e && e->dest != bb->next_bb)
2387 INDENT (indent);
2389 if ((flags & TDF_LINENO)
2390 && e->goto_locus != UNKNOWN_LOCATION
2393 expanded_location goto_xloc;
2394 goto_xloc = expand_location (e->goto_locus);
2395 pp_left_bracket (buffer);
2396 if (goto_xloc.file)
2398 pp_string (buffer, goto_xloc.file);
2399 pp_string (buffer, " : ");
2401 pp_decimal_int (buffer, goto_xloc.line);
2402 pp_string (buffer, " : ");
2403 pp_decimal_int (buffer, goto_xloc.column);
2404 pp_string (buffer, "] ");
2407 pp_cfg_jump (buffer, e->dest);
2408 pp_newline (buffer);
2413 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2414 indented by INDENT spaces. */
2416 static void
2417 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2418 int flags)
2420 gimple_stmt_iterator gsi;
2421 gimple stmt;
2422 int label_indent = indent - 2;
2424 if (label_indent < 0)
2425 label_indent = 0;
2427 dump_phi_nodes (buffer, bb, indent, flags);
2429 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2431 int curr_indent;
2433 stmt = gsi_stmt (gsi);
2435 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2437 INDENT (curr_indent);
2438 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2439 pp_newline_and_flush (buffer);
2440 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2441 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2442 pp_buffer (buffer)->stream, stmt);
2445 dump_implicit_edges (buffer, bb, indent, flags);
2446 pp_flush (buffer);
2450 /* Dumps basic block BB to FILE with details described by FLAGS and
2451 indented by INDENT spaces. */
2453 void
2454 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2456 dump_gimple_bb_header (file, bb, indent, flags);
2457 if (bb->index >= NUM_FIXED_BLOCKS)
2459 pretty_printer buffer;
2460 pp_needs_newline (&buffer) = true;
2461 buffer.buffer->stream = file;
2462 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2464 dump_gimple_bb_footer (file, bb, indent, flags);
2467 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2468 no indentation, for use as a label of a DOT graph record-node.
2469 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2470 histogram dumping doesn't know about pretty-printers. */
2472 void
2473 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2475 gimple_stmt_iterator gsi;
2477 pp_printf (pp, "<bb %d>:\n", bb->index);
2478 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2480 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2482 gimple phi = gsi_stmt (gsi);
2483 if (!virtual_operand_p (gimple_phi_result (phi))
2484 || (dump_flags & TDF_VOPS))
2486 pp_bar (pp);
2487 pp_write_text_to_stream (pp);
2488 pp_string (pp, "# ");
2489 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2490 pp_newline (pp);
2491 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2495 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2497 gimple stmt = gsi_stmt (gsi);
2498 pp_bar (pp);
2499 pp_write_text_to_stream (pp);
2500 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2501 pp_newline (pp);
2502 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2504 dump_implicit_edges (pp, bb, 0, dump_flags);
2505 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);