PR middle-end/66633
[official-gcc.git] / gcc / gimple-pretty-print.c
blobe8e3a6d0494b6ee2ad282beee55e8866ae8b997f
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2015 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 "alias.h"
27 #include "symtab.h"
28 #include "tree.h"
29 #include "fold-const.h"
30 #include "stringpool.h"
31 #include "diagnostic.h"
32 #include "gimple-pretty-print.h"
33 #include "bitmap.h"
34 #include "predict.h"
35 #include "hard-reg-set.h"
36 #include "function.h"
37 #include "basic-block.h"
38 #include "tree-ssa-alias.h"
39 #include "internal-fn.h"
40 #include "tree-eh.h"
41 #include "gimple-expr.h"
42 #include "gimple.h"
43 #include "gimple-iterator.h"
44 #include "gimple-ssa.h"
45 #include "cgraph.h"
46 #include "tree-cfg.h"
47 #include "tree-ssanames.h"
48 #include "dumpfile.h" /* for dump_flags */
49 #include "value-prof.h"
50 #include "trans-mem.h"
52 #define INDENT(SPACE) \
53 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
55 #define GIMPLE_NIY do_niy (buffer,gs)
57 /* Try to print on BUFFER a default message for the unrecognized
58 gimple statement GS. */
60 static void
61 do_niy (pretty_printer *buffer, gimple gs)
63 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
64 gimple_code_name[(int) gimple_code (gs)]);
68 /* Emit a newline and SPC indentation spaces to BUFFER. */
70 static void
71 newline_and_indent (pretty_printer *buffer, int spc)
73 pp_newline (buffer);
74 INDENT (spc);
78 /* Print the GIMPLE statement GS on stderr. */
80 DEBUG_FUNCTION void
81 debug_gimple_stmt (gimple gs)
83 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
87 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
88 FLAGS as in pp_gimple_stmt_1. */
90 void
91 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
93 pretty_printer buffer;
94 pp_needs_newline (&buffer) = true;
95 buffer.buffer->stream = file;
96 pp_gimple_stmt_1 (&buffer, g, spc, flags);
97 pp_newline_and_flush (&buffer);
100 DEBUG_FUNCTION void
101 debug (gimple_statement_base &ref)
103 print_gimple_stmt (stderr, &ref, 0, 0);
106 DEBUG_FUNCTION void
107 debug (gimple_statement_base *ptr)
109 if (ptr)
110 debug (*ptr);
111 else
112 fprintf (stderr, "<nil>\n");
116 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
117 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
118 of the statement. */
120 void
121 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
123 flags |= TDF_RHS_ONLY;
124 pretty_printer buffer;
125 pp_needs_newline (&buffer) = true;
126 buffer.buffer->stream = file;
127 pp_gimple_stmt_1 (&buffer, g, spc, flags);
128 pp_flush (&buffer);
132 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
133 spaces and FLAGS as in pp_gimple_stmt_1.
134 The caller is responsible for calling pp_flush on BUFFER to finalize
135 the pretty printer. */
137 static void
138 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
140 gimple_stmt_iterator i;
142 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
144 gimple gs = gsi_stmt (i);
145 INDENT (spc);
146 pp_gimple_stmt_1 (buffer, gs, spc, flags);
147 if (!gsi_one_before_end_p (i))
148 pp_newline (buffer);
153 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
154 FLAGS as in pp_gimple_stmt_1. */
156 void
157 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
159 pretty_printer buffer;
160 pp_needs_newline (&buffer) = true;
161 buffer.buffer->stream = file;
162 dump_gimple_seq (&buffer, seq, spc, flags);
163 pp_newline_and_flush (&buffer);
167 /* Print the GIMPLE sequence SEQ on stderr. */
169 DEBUG_FUNCTION void
170 debug_gimple_seq (gimple_seq seq)
172 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
176 /* A simple helper to pretty-print some of the gimple tuples in the printf
177 style. The format modifiers are preceded by '%' and are:
178 'G' - outputs a string corresponding to the code of the given gimple,
179 'S' - outputs a gimple_seq with indent of spc + 2,
180 'T' - outputs the tree t,
181 'd' - outputs an int as a decimal,
182 's' - outputs a string,
183 'n' - outputs a newline,
184 'x' - outputs an int as hexadecimal,
185 '+' - increases indent by 2 then outputs a newline,
186 '-' - decreases indent by 2 then outputs a newline. */
188 static void
189 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
190 const char *fmt, ...)
192 va_list args;
193 const char *c;
194 const char *tmp;
196 va_start (args, fmt);
197 for (c = fmt; *c; c++)
199 if (*c == '%')
201 gimple_seq seq;
202 tree t;
203 gimple g;
204 switch (*++c)
206 case 'G':
207 g = va_arg (args, gimple);
208 tmp = gimple_code_name[gimple_code (g)];
209 pp_string (buffer, tmp);
210 break;
212 case 'S':
213 seq = va_arg (args, gimple_seq);
214 pp_newline (buffer);
215 dump_gimple_seq (buffer, seq, spc + 2, flags);
216 newline_and_indent (buffer, spc);
217 break;
219 case 'T':
220 t = va_arg (args, tree);
221 if (t == NULL_TREE)
222 pp_string (buffer, "NULL");
223 else
224 dump_generic_node (buffer, t, spc, flags, false);
225 break;
227 case 'd':
228 pp_decimal_int (buffer, va_arg (args, int));
229 break;
231 case 's':
232 pp_string (buffer, va_arg (args, char *));
233 break;
235 case 'n':
236 newline_and_indent (buffer, spc);
237 break;
239 case 'x':
240 pp_scalar (buffer, "%x", va_arg (args, int));
241 break;
243 case '+':
244 spc += 2;
245 newline_and_indent (buffer, spc);
246 break;
248 case '-':
249 spc -= 2;
250 newline_and_indent (buffer, spc);
251 break;
253 default:
254 gcc_unreachable ();
257 else
258 pp_character (buffer, *c);
260 va_end (args);
264 /* Helper for dump_gimple_assign. Print the unary RHS of the
265 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
267 static void
268 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
270 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
271 tree lhs = gimple_assign_lhs (gs);
272 tree rhs = gimple_assign_rhs1 (gs);
274 switch (rhs_code)
276 case VIEW_CONVERT_EXPR:
277 case ASSERT_EXPR:
278 dump_generic_node (buffer, rhs, spc, flags, false);
279 break;
281 case FIXED_CONVERT_EXPR:
282 case ADDR_SPACE_CONVERT_EXPR:
283 case FIX_TRUNC_EXPR:
284 case FLOAT_EXPR:
285 CASE_CONVERT:
286 pp_left_paren (buffer);
287 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
288 pp_string (buffer, ") ");
289 if (op_prio (rhs) < op_code_prio (rhs_code))
291 pp_left_paren (buffer);
292 dump_generic_node (buffer, rhs, spc, flags, false);
293 pp_right_paren (buffer);
295 else
296 dump_generic_node (buffer, rhs, spc, flags, false);
297 break;
299 case PAREN_EXPR:
300 pp_string (buffer, "((");
301 dump_generic_node (buffer, rhs, spc, flags, false);
302 pp_string (buffer, "))");
303 break;
305 case ABS_EXPR:
306 pp_string (buffer, "ABS_EXPR <");
307 dump_generic_node (buffer, rhs, spc, flags, false);
308 pp_greater (buffer);
309 break;
311 default:
312 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
313 || TREE_CODE_CLASS (rhs_code) == tcc_constant
314 || TREE_CODE_CLASS (rhs_code) == tcc_reference
315 || rhs_code == SSA_NAME
316 || rhs_code == ADDR_EXPR
317 || rhs_code == CONSTRUCTOR)
319 dump_generic_node (buffer, rhs, spc, flags, false);
320 break;
322 else if (rhs_code == BIT_NOT_EXPR)
323 pp_complement (buffer);
324 else if (rhs_code == TRUTH_NOT_EXPR)
325 pp_exclamation (buffer);
326 else if (rhs_code == NEGATE_EXPR)
327 pp_minus (buffer);
328 else
330 pp_left_bracket (buffer);
331 pp_string (buffer, get_tree_code_name (rhs_code));
332 pp_string (buffer, "] ");
335 if (op_prio (rhs) < op_code_prio (rhs_code))
337 pp_left_paren (buffer);
338 dump_generic_node (buffer, rhs, spc, flags, false);
339 pp_right_paren (buffer);
341 else
342 dump_generic_node (buffer, rhs, spc, flags, false);
343 break;
348 /* Helper for dump_gimple_assign. Print the binary RHS of the
349 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
351 static void
352 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
354 const char *p;
355 enum tree_code code = gimple_assign_rhs_code (gs);
356 switch (code)
358 case COMPLEX_EXPR:
359 case MIN_EXPR:
360 case MAX_EXPR:
361 case VEC_WIDEN_MULT_HI_EXPR:
362 case VEC_WIDEN_MULT_LO_EXPR:
363 case VEC_WIDEN_MULT_EVEN_EXPR:
364 case VEC_WIDEN_MULT_ODD_EXPR:
365 case VEC_PACK_TRUNC_EXPR:
366 case VEC_PACK_SAT_EXPR:
367 case VEC_PACK_FIX_TRUNC_EXPR:
368 case VEC_WIDEN_LSHIFT_HI_EXPR:
369 case VEC_WIDEN_LSHIFT_LO_EXPR:
370 for (p = get_tree_code_name (code); *p; p++)
371 pp_character (buffer, TOUPPER (*p));
372 pp_string (buffer, " <");
373 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
374 pp_string (buffer, ", ");
375 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
376 pp_greater (buffer);
377 break;
379 default:
380 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
382 pp_left_paren (buffer);
383 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
384 false);
385 pp_right_paren (buffer);
387 else
388 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
389 pp_space (buffer);
390 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
391 pp_space (buffer);
392 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
394 pp_left_paren (buffer);
395 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
396 false);
397 pp_right_paren (buffer);
399 else
400 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
404 /* Helper for dump_gimple_assign. Print the ternary RHS of the
405 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
407 static void
408 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
410 const char *p;
411 enum tree_code code = gimple_assign_rhs_code (gs);
412 switch (code)
414 case WIDEN_MULT_PLUS_EXPR:
415 case WIDEN_MULT_MINUS_EXPR:
416 for (p = get_tree_code_name (code); *p; p++)
417 pp_character (buffer, TOUPPER (*p));
418 pp_string (buffer, " <");
419 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
420 pp_string (buffer, ", ");
421 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
422 pp_string (buffer, ", ");
423 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
424 pp_greater (buffer);
425 break;
427 case FMA_EXPR:
428 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
429 pp_string (buffer, " * ");
430 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
431 pp_string (buffer, " + ");
432 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
433 break;
435 case DOT_PROD_EXPR:
436 pp_string (buffer, "DOT_PROD_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 SAD_EXPR:
446 pp_string (buffer, "SAD_EXPR <");
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 VEC_PERM_EXPR:
456 pp_string (buffer, "VEC_PERM_EXPR <");
457 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
458 pp_string (buffer, ", ");
459 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
460 pp_string (buffer, ", ");
461 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
462 pp_greater (buffer);
463 break;
465 case REALIGN_LOAD_EXPR:
466 pp_string (buffer, "REALIGN_LOAD <");
467 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
468 pp_string (buffer, ", ");
469 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
470 pp_string (buffer, ", ");
471 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
472 pp_greater (buffer);
473 break;
475 case COND_EXPR:
476 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
477 pp_string (buffer, " ? ");
478 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
479 pp_string (buffer, " : ");
480 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
481 break;
483 case VEC_COND_EXPR:
484 pp_string (buffer, "VEC_COND_EXPR <");
485 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
486 pp_string (buffer, ", ");
487 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
488 pp_string (buffer, ", ");
489 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
490 pp_greater (buffer);
491 break;
493 default:
494 gcc_unreachable ();
499 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
500 pp_gimple_stmt_1. */
502 static void
503 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
505 if (flags & TDF_RAW)
507 tree arg1 = NULL;
508 tree arg2 = NULL;
509 tree arg3 = NULL;
510 switch (gimple_num_ops (gs))
512 case 4:
513 arg3 = gimple_assign_rhs3 (gs);
514 case 3:
515 arg2 = gimple_assign_rhs2 (gs);
516 case 2:
517 arg1 = gimple_assign_rhs1 (gs);
518 break;
519 default:
520 gcc_unreachable ();
523 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
524 get_tree_code_name (gimple_assign_rhs_code (gs)),
525 gimple_assign_lhs (gs), arg1, arg2, arg3);
527 else
529 if (!(flags & TDF_RHS_ONLY))
531 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
532 pp_space (buffer);
533 pp_equal (buffer);
535 if (gimple_assign_nontemporal_move_p (gs))
536 pp_string (buffer, "{nt}");
538 if (gimple_has_volatile_ops (gs))
539 pp_string (buffer, "{v}");
541 pp_space (buffer);
544 if (gimple_num_ops (gs) == 2)
545 dump_unary_rhs (buffer, gs, spc, flags);
546 else if (gimple_num_ops (gs) == 3)
547 dump_binary_rhs (buffer, gs, spc, flags);
548 else if (gimple_num_ops (gs) == 4)
549 dump_ternary_rhs (buffer, gs, spc, flags);
550 else
551 gcc_unreachable ();
552 if (!(flags & TDF_RHS_ONLY))
553 pp_semicolon (buffer);
558 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
559 pp_gimple_stmt_1. */
561 static void
562 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
564 tree t, t2;
566 t = gimple_return_retval (gs);
567 t2 = gimple_return_retbnd (gs);
568 if (flags & TDF_RAW)
569 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
570 else
572 pp_string (buffer, "return");
573 if (t)
575 pp_space (buffer);
576 dump_generic_node (buffer, t, spc, flags, false);
578 if (t2)
580 pp_string (buffer, ", ");
581 dump_generic_node (buffer, t2, spc, flags, false);
583 pp_semicolon (buffer);
588 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
589 dump_gimple_call. */
591 static void
592 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
594 size_t i;
596 for (i = 0; i < gimple_call_num_args (gs); i++)
598 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
599 if (i < gimple_call_num_args (gs) - 1)
600 pp_string (buffer, ", ");
603 if (gimple_call_va_arg_pack_p (gs))
605 if (gimple_call_num_args (gs) > 0)
607 pp_comma (buffer);
608 pp_space (buffer);
611 pp_string (buffer, "__builtin_va_arg_pack ()");
615 /* Dump the points-to solution *PT to BUFFER. */
617 static void
618 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
620 if (pt->anything)
622 pp_string (buffer, "anything ");
623 return;
625 if (pt->nonlocal)
626 pp_string (buffer, "nonlocal ");
627 if (pt->escaped)
628 pp_string (buffer, "escaped ");
629 if (pt->ipa_escaped)
630 pp_string (buffer, "unit-escaped ");
631 if (pt->null)
632 pp_string (buffer, "null ");
633 if (pt->vars
634 && !bitmap_empty_p (pt->vars))
636 bitmap_iterator bi;
637 unsigned i;
638 pp_string (buffer, "{ ");
639 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
641 pp_string (buffer, "D.");
642 pp_decimal_int (buffer, i);
643 pp_space (buffer);
645 pp_right_brace (buffer);
646 if (pt->vars_contains_nonlocal
647 && pt->vars_contains_escaped_heap)
648 pp_string (buffer, " (nonlocal, escaped heap)");
649 else if (pt->vars_contains_nonlocal
650 && pt->vars_contains_escaped)
651 pp_string (buffer, " (nonlocal, escaped)");
652 else if (pt->vars_contains_nonlocal)
653 pp_string (buffer, " (nonlocal)");
654 else if (pt->vars_contains_escaped_heap)
655 pp_string (buffer, " (escaped heap)");
656 else if (pt->vars_contains_escaped)
657 pp_string (buffer, " (escaped)");
661 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
662 pp_gimple_stmt_1. */
664 static void
665 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
667 tree lhs = gimple_call_lhs (gs);
668 tree fn = gimple_call_fn (gs);
670 if (flags & TDF_ALIAS)
672 struct pt_solution *pt;
673 pt = gimple_call_use_set (gs);
674 if (!pt_solution_empty_p (pt))
676 pp_string (buffer, "# USE = ");
677 pp_points_to_solution (buffer, pt);
678 newline_and_indent (buffer, spc);
680 pt = gimple_call_clobber_set (gs);
681 if (!pt_solution_empty_p (pt))
683 pp_string (buffer, "# CLB = ");
684 pp_points_to_solution (buffer, pt);
685 newline_and_indent (buffer, spc);
689 if (flags & TDF_RAW)
691 if (gimple_call_internal_p (gs))
692 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
693 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
694 else
695 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
696 if (gimple_call_num_args (gs) > 0)
698 pp_string (buffer, ", ");
699 dump_gimple_call_args (buffer, gs, flags);
701 pp_greater (buffer);
703 else
705 if (lhs && !(flags & TDF_RHS_ONLY))
707 dump_generic_node (buffer, lhs, spc, flags, false);
708 pp_string (buffer, " =");
710 if (gimple_has_volatile_ops (gs))
711 pp_string (buffer, "{v}");
713 pp_space (buffer);
715 if (gimple_call_internal_p (gs))
716 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
717 else
718 print_call_name (buffer, fn, flags);
719 pp_string (buffer, " (");
720 dump_gimple_call_args (buffer, gs, flags);
721 pp_right_paren (buffer);
722 if (!(flags & TDF_RHS_ONLY))
723 pp_semicolon (buffer);
726 if (gimple_call_chain (gs))
728 pp_string (buffer, " [static-chain: ");
729 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
730 pp_right_bracket (buffer);
733 if (gimple_call_return_slot_opt_p (gs))
734 pp_string (buffer, " [return slot optimization]");
735 if (gimple_call_tail_p (gs))
736 pp_string (buffer, " [tail call]");
738 if (fn == NULL)
739 return;
741 /* Dump the arguments of _ITM_beginTransaction sanely. */
742 if (TREE_CODE (fn) == ADDR_EXPR)
743 fn = TREE_OPERAND (fn, 0);
744 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
745 pp_string (buffer, " [tm-clone]");
746 if (TREE_CODE (fn) == FUNCTION_DECL
747 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
748 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
749 && gimple_call_num_args (gs) > 0)
751 tree t = gimple_call_arg (gs, 0);
752 unsigned HOST_WIDE_INT props;
753 gcc_assert (TREE_CODE (t) == INTEGER_CST);
755 pp_string (buffer, " [ ");
757 /* Get the transaction code properties. */
758 props = TREE_INT_CST_LOW (t);
760 if (props & PR_INSTRUMENTEDCODE)
761 pp_string (buffer, "instrumentedCode ");
762 if (props & PR_UNINSTRUMENTEDCODE)
763 pp_string (buffer, "uninstrumentedCode ");
764 if (props & PR_HASNOXMMUPDATE)
765 pp_string (buffer, "hasNoXMMUpdate ");
766 if (props & PR_HASNOABORT)
767 pp_string (buffer, "hasNoAbort ");
768 if (props & PR_HASNOIRREVOCABLE)
769 pp_string (buffer, "hasNoIrrevocable ");
770 if (props & PR_DOESGOIRREVOCABLE)
771 pp_string (buffer, "doesGoIrrevocable ");
772 if (props & PR_HASNOSIMPLEREADS)
773 pp_string (buffer, "hasNoSimpleReads ");
774 if (props & PR_AWBARRIERSOMITTED)
775 pp_string (buffer, "awBarriersOmitted ");
776 if (props & PR_RARBARRIERSOMITTED)
777 pp_string (buffer, "RaRBarriersOmitted ");
778 if (props & PR_UNDOLOGCODE)
779 pp_string (buffer, "undoLogCode ");
780 if (props & PR_PREFERUNINSTRUMENTED)
781 pp_string (buffer, "preferUninstrumented ");
782 if (props & PR_EXCEPTIONBLOCK)
783 pp_string (buffer, "exceptionBlock ");
784 if (props & PR_HASELSE)
785 pp_string (buffer, "hasElse ");
786 if (props & PR_READONLY)
787 pp_string (buffer, "readOnly ");
789 pp_right_bracket (buffer);
794 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
795 pp_gimple_stmt_1. */
797 static void
798 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
799 int flags)
801 unsigned int i;
803 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
804 if (flags & TDF_RAW)
805 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
806 gimple_switch_index (gs));
807 else
809 pp_string (buffer, "switch (");
810 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
811 pp_string (buffer, ") <");
814 for (i = 0; i < gimple_switch_num_labels (gs); i++)
816 tree case_label = gimple_switch_label (gs, i);
817 gcc_checking_assert (case_label != NULL_TREE);
818 dump_generic_node (buffer, case_label, spc, flags, false);
819 pp_space (buffer);
820 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
821 if (i < gimple_switch_num_labels (gs) - 1)
822 pp_string (buffer, ", ");
824 pp_greater (buffer);
828 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
829 pp_gimple_stmt_1. */
831 static void
832 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
834 if (flags & TDF_RAW)
835 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
836 get_tree_code_name (gimple_cond_code (gs)),
837 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
838 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
839 else
841 if (!(flags & TDF_RHS_ONLY))
842 pp_string (buffer, "if (");
843 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
844 pp_space (buffer);
845 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
846 pp_space (buffer);
847 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
848 if (!(flags & TDF_RHS_ONLY))
850 pp_right_paren (buffer);
852 if (gimple_cond_true_label (gs))
854 pp_string (buffer, " goto ");
855 dump_generic_node (buffer, gimple_cond_true_label (gs),
856 spc, flags, false);
857 pp_semicolon (buffer);
859 if (gimple_cond_false_label (gs))
861 pp_string (buffer, " else goto ");
862 dump_generic_node (buffer, gimple_cond_false_label (gs),
863 spc, flags, false);
864 pp_semicolon (buffer);
871 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
872 spaces of indent. FLAGS specifies details to show in the dump (see
873 TDF_* in dumpfils.h). */
875 static void
876 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
878 tree label = gimple_label_label (gs);
879 if (flags & TDF_RAW)
880 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
881 else
883 dump_generic_node (buffer, label, spc, flags, false);
884 pp_colon (buffer);
886 if (DECL_NONLOCAL (label))
887 pp_string (buffer, " [non-local]");
888 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
889 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
892 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
893 spaces of indent. FLAGS specifies details to show in the dump (see
894 TDF_* in dumpfile.h). */
896 static void
897 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
899 tree label = gimple_goto_dest (gs);
900 if (flags & TDF_RAW)
901 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
902 else
903 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
907 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
908 spaces of indent. FLAGS specifies details to show in the dump (see
909 TDF_* in dumpfile.h). */
911 static void
912 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
914 if (flags & TDF_RAW)
915 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
916 else
917 pp_left_brace (buffer);
918 if (!(flags & TDF_SLIM))
920 tree var;
922 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
924 newline_and_indent (buffer, 2);
925 print_declaration (buffer, var, spc, flags);
927 if (gimple_bind_vars (gs))
928 pp_newline (buffer);
930 pp_newline (buffer);
931 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
932 newline_and_indent (buffer, spc);
933 if (flags & TDF_RAW)
934 pp_greater (buffer);
935 else
936 pp_right_brace (buffer);
940 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
941 indent. FLAGS specifies details to show in the dump (see TDF_* in
942 dumpfile.h). */
944 static void
945 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
947 if (flags & TDF_RAW)
949 const char *type;
950 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
951 type = "GIMPLE_TRY_CATCH";
952 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
953 type = "GIMPLE_TRY_FINALLY";
954 else
955 type = "UNKNOWN GIMPLE_TRY";
956 dump_gimple_fmt (buffer, spc, flags,
957 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
958 gimple_try_eval (gs), gimple_try_cleanup (gs));
960 else
962 pp_string (buffer, "try");
963 newline_and_indent (buffer, spc + 2);
964 pp_left_brace (buffer);
965 pp_newline (buffer);
967 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
968 newline_and_indent (buffer, spc + 2);
969 pp_right_brace (buffer);
971 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
973 newline_and_indent (buffer, spc);
974 pp_string (buffer, "catch");
975 newline_and_indent (buffer, spc + 2);
976 pp_left_brace (buffer);
978 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
980 newline_and_indent (buffer, spc);
981 pp_string (buffer, "finally");
982 newline_and_indent (buffer, spc + 2);
983 pp_left_brace (buffer);
985 else
986 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
988 pp_newline (buffer);
989 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
990 newline_and_indent (buffer, spc + 2);
991 pp_right_brace (buffer);
996 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
997 indent. FLAGS specifies details to show in the dump (see TDF_* in
998 dumpfile.h). */
1000 static void
1001 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
1003 if (flags & TDF_RAW)
1004 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1005 gimple_catch_types (gs), gimple_catch_handler (gs));
1006 else
1007 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1008 gimple_catch_types (gs), gimple_catch_handler (gs));
1012 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1013 indent. FLAGS specifies details to show in the dump (see TDF_* in
1014 dumpfile.h). */
1016 static void
1017 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1018 int flags)
1020 if (flags & TDF_RAW)
1021 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1022 gimple_eh_filter_types (gs),
1023 gimple_eh_filter_failure (gs));
1024 else
1025 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1026 gimple_eh_filter_types (gs),
1027 gimple_eh_filter_failure (gs));
1031 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1033 static void
1034 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1035 geh_mnt *gs, int spc, int flags)
1037 if (flags & TDF_RAW)
1038 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1039 gimple_eh_must_not_throw_fndecl (gs));
1040 else
1041 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1042 gimple_eh_must_not_throw_fndecl (gs));
1046 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1047 indent. FLAGS specifies details to show in the dump (see TDF_* in
1048 dumpfile.h). */
1050 static void
1051 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1052 int flags)
1054 if (flags & TDF_RAW)
1055 dump_gimple_fmt (buffer, spc, flags,
1056 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1057 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1058 else
1059 dump_gimple_fmt (buffer, spc, flags,
1060 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1061 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1065 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1066 indent. FLAGS specifies details to show in the dump (see TDF_* in
1067 dumpfile.h). */
1069 static void
1070 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
1072 if (flags & TDF_RAW)
1073 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1074 gimple_resx_region (gs));
1075 else
1076 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1079 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1081 static void
1082 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int flags)
1084 if (flags & TDF_RAW)
1085 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1086 gimple_eh_dispatch_region (gs));
1087 else
1088 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1089 gimple_eh_dispatch_region (gs));
1092 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1093 of indent. FLAGS specifies details to show in the dump (see TDF_*
1094 in dumpfile.h). */
1096 static void
1097 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
1099 switch (gs->subcode)
1101 case GIMPLE_DEBUG_BIND:
1102 if (flags & TDF_RAW)
1103 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1104 gimple_debug_bind_get_var (gs),
1105 gimple_debug_bind_get_value (gs));
1106 else
1107 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1108 gimple_debug_bind_get_var (gs),
1109 gimple_debug_bind_get_value (gs));
1110 break;
1112 case GIMPLE_DEBUG_SOURCE_BIND:
1113 if (flags & TDF_RAW)
1114 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1115 gimple_debug_source_bind_get_var (gs),
1116 gimple_debug_source_bind_get_value (gs));
1117 else
1118 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1119 gimple_debug_source_bind_get_var (gs),
1120 gimple_debug_source_bind_get_value (gs));
1121 break;
1123 default:
1124 gcc_unreachable ();
1128 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1129 static void
1130 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
1132 size_t i;
1134 if (flags & TDF_RAW)
1136 const char *kind;
1137 switch (gimple_omp_for_kind (gs))
1139 case GF_OMP_FOR_KIND_FOR:
1140 kind = "";
1141 break;
1142 case GF_OMP_FOR_KIND_DISTRIBUTE:
1143 kind = " distribute";
1144 break;
1145 case GF_OMP_FOR_KIND_CILKFOR:
1146 kind = " _Cilk_for";
1147 break;
1148 case GF_OMP_FOR_KIND_OACC_LOOP:
1149 kind = " oacc_loop";
1150 break;
1151 case GF_OMP_FOR_KIND_SIMD:
1152 kind = " simd";
1153 break;
1154 case GF_OMP_FOR_KIND_CILKSIMD:
1155 kind = " cilksimd";
1156 break;
1157 default:
1158 gcc_unreachable ();
1160 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1161 kind, gimple_omp_body (gs));
1162 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1163 dump_gimple_fmt (buffer, spc, flags, " >,");
1164 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1165 dump_gimple_fmt (buffer, spc, flags,
1166 "%+%T, %T, %T, %s, %T,%n",
1167 gimple_omp_for_index (gs, i),
1168 gimple_omp_for_initial (gs, i),
1169 gimple_omp_for_final (gs, i),
1170 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1171 gimple_omp_for_incr (gs, i));
1172 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1173 gimple_omp_for_pre_body (gs));
1175 else
1177 switch (gimple_omp_for_kind (gs))
1179 case GF_OMP_FOR_KIND_FOR:
1180 pp_string (buffer, "#pragma omp for");
1181 break;
1182 case GF_OMP_FOR_KIND_DISTRIBUTE:
1183 pp_string (buffer, "#pragma omp distribute");
1184 break;
1185 case GF_OMP_FOR_KIND_CILKFOR:
1186 break;
1187 case GF_OMP_FOR_KIND_OACC_LOOP:
1188 pp_string (buffer, "#pragma acc loop");
1189 break;
1190 case GF_OMP_FOR_KIND_SIMD:
1191 pp_string (buffer, "#pragma omp simd");
1192 break;
1193 case GF_OMP_FOR_KIND_CILKSIMD:
1194 pp_string (buffer, "#pragma simd");
1195 break;
1196 default:
1197 gcc_unreachable ();
1199 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1200 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1201 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1203 if (i)
1204 spc += 2;
1205 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1206 pp_string (buffer, "_Cilk_for (");
1207 else
1209 newline_and_indent (buffer, spc);
1210 pp_string (buffer, "for (");
1212 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1213 flags, false);
1214 pp_string (buffer, " = ");
1215 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1216 flags, false);
1217 pp_string (buffer, "; ");
1219 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1220 flags, false);
1221 pp_space (buffer);
1222 switch (gimple_omp_for_cond (gs, i))
1224 case LT_EXPR:
1225 pp_less (buffer);
1226 break;
1227 case GT_EXPR:
1228 pp_greater (buffer);
1229 break;
1230 case LE_EXPR:
1231 pp_less_equal (buffer);
1232 break;
1233 case GE_EXPR:
1234 pp_greater_equal (buffer);
1235 break;
1236 case NE_EXPR:
1237 pp_string (buffer, "!=");
1238 break;
1239 default:
1240 gcc_unreachable ();
1242 pp_space (buffer);
1243 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1244 flags, false);
1245 pp_string (buffer, "; ");
1247 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1248 flags, false);
1249 pp_string (buffer, " = ");
1250 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1251 flags, false);
1252 pp_right_paren (buffer);
1255 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1257 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1258 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1259 newline_and_indent (buffer, spc + 2);
1260 pp_left_brace (buffer);
1261 pp_newline (buffer);
1262 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1263 newline_and_indent (buffer, spc + 2);
1264 pp_right_brace (buffer);
1269 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1271 static void
1272 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1273 int spc, int flags)
1275 if (flags & TDF_RAW)
1277 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1278 gimple_omp_continue_control_def (gs),
1279 gimple_omp_continue_control_use (gs));
1281 else
1283 pp_string (buffer, "#pragma omp continue (");
1284 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1285 spc, flags, false);
1286 pp_comma (buffer);
1287 pp_space (buffer);
1288 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1289 spc, flags, false);
1290 pp_right_paren (buffer);
1294 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1296 static void
1297 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1298 int spc, int flags)
1300 if (flags & TDF_RAW)
1302 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1303 gimple_omp_body (gs));
1304 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1305 dump_gimple_fmt (buffer, spc, flags, " >");
1307 else
1309 pp_string (buffer, "#pragma omp single");
1310 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1311 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1313 newline_and_indent (buffer, spc + 2);
1314 pp_left_brace (buffer);
1315 pp_newline (buffer);
1316 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1317 newline_and_indent (buffer, spc + 2);
1318 pp_right_brace (buffer);
1323 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1325 static void
1326 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1327 int spc, int flags)
1329 const char *kind;
1330 switch (gimple_omp_target_kind (gs))
1332 case GF_OMP_TARGET_KIND_REGION:
1333 kind = "";
1334 break;
1335 case GF_OMP_TARGET_KIND_DATA:
1336 kind = " data";
1337 break;
1338 case GF_OMP_TARGET_KIND_UPDATE:
1339 kind = " update";
1340 break;
1341 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1342 kind = " oacc_kernels";
1343 break;
1344 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1345 kind = " oacc_parallel";
1346 break;
1347 case GF_OMP_TARGET_KIND_OACC_DATA:
1348 kind = " oacc_data";
1349 break;
1350 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1351 kind = " oacc_update";
1352 break;
1353 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1354 kind = " oacc_enter_exit_data";
1355 break;
1356 default:
1357 gcc_unreachable ();
1359 if (flags & TDF_RAW)
1361 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1362 kind, gimple_omp_body (gs));
1363 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1364 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1365 gimple_omp_target_child_fn (gs),
1366 gimple_omp_target_data_arg (gs));
1368 else
1370 pp_string (buffer, "#pragma omp target");
1371 pp_string (buffer, kind);
1372 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1373 if (gimple_omp_target_child_fn (gs))
1375 pp_string (buffer, " [child fn: ");
1376 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1377 spc, flags, false);
1378 pp_string (buffer, " (");
1379 if (gimple_omp_target_data_arg (gs))
1380 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1381 spc, flags, false);
1382 else
1383 pp_string (buffer, "???");
1384 pp_string (buffer, ")]");
1386 gimple_seq body = gimple_omp_body (gs);
1387 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1389 newline_and_indent (buffer, spc + 2);
1390 pp_left_brace (buffer);
1391 pp_newline (buffer);
1392 dump_gimple_seq (buffer, body, spc + 4, flags);
1393 newline_and_indent (buffer, spc + 2);
1394 pp_right_brace (buffer);
1396 else if (body)
1398 pp_newline (buffer);
1399 dump_gimple_seq (buffer, body, spc + 2, flags);
1404 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1406 static void
1407 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1408 int flags)
1410 if (flags & TDF_RAW)
1412 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1413 gimple_omp_body (gs));
1414 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1415 dump_gimple_fmt (buffer, spc, flags, " >");
1417 else
1419 pp_string (buffer, "#pragma omp teams");
1420 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1421 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1423 newline_and_indent (buffer, spc + 2);
1424 pp_character (buffer, '{');
1425 pp_newline (buffer);
1426 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1427 newline_and_indent (buffer, spc + 2);
1428 pp_character (buffer, '}');
1433 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1435 static void
1436 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1437 int spc, int flags)
1439 if (flags & TDF_RAW)
1441 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1442 gimple_omp_body (gs));
1443 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1444 dump_gimple_fmt (buffer, spc, flags, " >");
1446 else
1448 pp_string (buffer, "#pragma omp sections");
1449 if (gimple_omp_sections_control (gs))
1451 pp_string (buffer, " <");
1452 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1453 flags, false);
1454 pp_greater (buffer);
1456 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1457 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1459 newline_and_indent (buffer, spc + 2);
1460 pp_left_brace (buffer);
1461 pp_newline (buffer);
1462 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1463 newline_and_indent (buffer, spc + 2);
1464 pp_right_brace (buffer);
1469 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1470 pretty_printer BUFFER. */
1472 static void
1473 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1475 if (flags & TDF_RAW)
1476 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1477 gimple_omp_body (gs));
1478 else
1480 switch (gimple_code (gs))
1482 case GIMPLE_OMP_MASTER:
1483 pp_string (buffer, "#pragma omp master");
1484 break;
1485 case GIMPLE_OMP_TASKGROUP:
1486 pp_string (buffer, "#pragma omp taskgroup");
1487 break;
1488 case GIMPLE_OMP_ORDERED:
1489 pp_string (buffer, "#pragma omp ordered");
1490 break;
1491 case GIMPLE_OMP_SECTION:
1492 pp_string (buffer, "#pragma omp section");
1493 break;
1494 default:
1495 gcc_unreachable ();
1497 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1499 newline_and_indent (buffer, spc + 2);
1500 pp_left_brace (buffer);
1501 pp_newline (buffer);
1502 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1503 newline_and_indent (buffer, spc + 2);
1504 pp_right_brace (buffer);
1509 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1511 static void
1512 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1513 int spc, int flags)
1515 if (flags & TDF_RAW)
1516 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1517 gimple_omp_body (gs));
1518 else
1520 pp_string (buffer, "#pragma omp critical");
1521 if (gimple_omp_critical_name (gs))
1523 pp_string (buffer, " (");
1524 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1525 flags, false);
1526 pp_right_paren (buffer);
1528 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1530 newline_and_indent (buffer, spc + 2);
1531 pp_left_brace (buffer);
1532 pp_newline (buffer);
1533 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1534 newline_and_indent (buffer, spc + 2);
1535 pp_right_brace (buffer);
1540 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1542 static void
1543 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1545 if (flags & TDF_RAW)
1547 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1548 (int) gimple_omp_return_nowait_p (gs));
1549 if (gimple_omp_return_lhs (gs))
1550 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1551 gimple_omp_return_lhs (gs));
1552 else
1553 dump_gimple_fmt (buffer, spc, flags, ">");
1555 else
1557 pp_string (buffer, "#pragma omp return");
1558 if (gimple_omp_return_nowait_p (gs))
1559 pp_string (buffer, "(nowait)");
1560 if (gimple_omp_return_lhs (gs))
1562 pp_string (buffer, " (set ");
1563 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1564 spc, flags, false);
1565 pp_character (buffer, ')');
1570 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1572 static void
1573 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1574 int spc, int flags)
1576 unsigned subcode = gimple_transaction_subcode (gs);
1578 if (flags & TDF_RAW)
1580 dump_gimple_fmt (buffer, spc, flags,
1581 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1582 gs, subcode, gimple_transaction_label (gs),
1583 gimple_transaction_body (gs));
1585 else
1587 if (subcode & GTMA_IS_OUTER)
1588 pp_string (buffer, "__transaction_atomic [[outer]]");
1589 else if (subcode & GTMA_IS_RELAXED)
1590 pp_string (buffer, "__transaction_relaxed");
1591 else
1592 pp_string (buffer, "__transaction_atomic");
1593 subcode &= ~GTMA_DECLARATION_MASK;
1595 if (subcode || gimple_transaction_label (gs))
1597 pp_string (buffer, " //");
1598 if (gimple_transaction_label (gs))
1600 pp_string (buffer, " LABEL=");
1601 dump_generic_node (buffer, gimple_transaction_label (gs),
1602 spc, flags, false);
1604 if (subcode)
1606 pp_string (buffer, " SUBCODE=[ ");
1607 if (subcode & GTMA_HAVE_ABORT)
1609 pp_string (buffer, "GTMA_HAVE_ABORT ");
1610 subcode &= ~GTMA_HAVE_ABORT;
1612 if (subcode & GTMA_HAVE_LOAD)
1614 pp_string (buffer, "GTMA_HAVE_LOAD ");
1615 subcode &= ~GTMA_HAVE_LOAD;
1617 if (subcode & GTMA_HAVE_STORE)
1619 pp_string (buffer, "GTMA_HAVE_STORE ");
1620 subcode &= ~GTMA_HAVE_STORE;
1622 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1624 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1625 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1627 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1629 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1630 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1632 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1634 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1635 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1637 if (subcode)
1638 pp_printf (buffer, "0x%x ", subcode);
1639 pp_right_bracket (buffer);
1643 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1645 newline_and_indent (buffer, spc + 2);
1646 pp_left_brace (buffer);
1647 pp_newline (buffer);
1648 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1649 spc + 4, flags);
1650 newline_and_indent (buffer, spc + 2);
1651 pp_right_brace (buffer);
1656 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1657 indent. FLAGS specifies details to show in the dump (see TDF_* in
1658 dumpfile.h). */
1660 static void
1661 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
1663 unsigned int i, n, f, fields;
1665 if (flags & TDF_RAW)
1667 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1668 gimple_asm_string (gs));
1670 n = gimple_asm_noutputs (gs);
1671 if (n)
1673 newline_and_indent (buffer, spc + 2);
1674 pp_string (buffer, "OUTPUT: ");
1675 for (i = 0; i < n; i++)
1677 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1678 spc, flags, false);
1679 if (i < n - 1)
1680 pp_string (buffer, ", ");
1684 n = gimple_asm_ninputs (gs);
1685 if (n)
1687 newline_and_indent (buffer, spc + 2);
1688 pp_string (buffer, "INPUT: ");
1689 for (i = 0; i < n; i++)
1691 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1692 spc, flags, false);
1693 if (i < n - 1)
1694 pp_string (buffer, ", ");
1698 n = gimple_asm_nclobbers (gs);
1699 if (n)
1701 newline_and_indent (buffer, spc + 2);
1702 pp_string (buffer, "CLOBBER: ");
1703 for (i = 0; i < n; i++)
1705 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1706 spc, flags, false);
1707 if (i < n - 1)
1708 pp_string (buffer, ", ");
1712 n = gimple_asm_nlabels (gs);
1713 if (n)
1715 newline_and_indent (buffer, spc + 2);
1716 pp_string (buffer, "LABEL: ");
1717 for (i = 0; i < n; i++)
1719 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1720 spc, flags, false);
1721 if (i < n - 1)
1722 pp_string (buffer, ", ");
1726 newline_and_indent (buffer, spc);
1727 pp_greater (buffer);
1729 else
1731 pp_string (buffer, "__asm__");
1732 if (gimple_asm_volatile_p (gs))
1733 pp_string (buffer, " __volatile__");
1734 if (gimple_asm_nlabels (gs))
1735 pp_string (buffer, " goto");
1736 pp_string (buffer, "(\"");
1737 pp_string (buffer, gimple_asm_string (gs));
1738 pp_string (buffer, "\"");
1740 if (gimple_asm_nlabels (gs))
1741 fields = 4;
1742 else if (gimple_asm_nclobbers (gs))
1743 fields = 3;
1744 else if (gimple_asm_ninputs (gs))
1745 fields = 2;
1746 else if (gimple_asm_noutputs (gs))
1747 fields = 1;
1748 else
1749 fields = 0;
1751 for (f = 0; f < fields; ++f)
1753 pp_string (buffer, " : ");
1755 switch (f)
1757 case 0:
1758 n = gimple_asm_noutputs (gs);
1759 for (i = 0; i < n; i++)
1761 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1762 spc, flags, false);
1763 if (i < n - 1)
1764 pp_string (buffer, ", ");
1766 break;
1768 case 1:
1769 n = gimple_asm_ninputs (gs);
1770 for (i = 0; i < n; i++)
1772 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1773 spc, flags, false);
1774 if (i < n - 1)
1775 pp_string (buffer, ", ");
1777 break;
1779 case 2:
1780 n = gimple_asm_nclobbers (gs);
1781 for (i = 0; i < n; i++)
1783 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1784 spc, flags, false);
1785 if (i < n - 1)
1786 pp_string (buffer, ", ");
1788 break;
1790 case 3:
1791 n = gimple_asm_nlabels (gs);
1792 for (i = 0; i < n; i++)
1794 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1795 spc, flags, false);
1796 if (i < n - 1)
1797 pp_string (buffer, ", ");
1799 break;
1801 default:
1802 gcc_unreachable ();
1806 pp_string (buffer, ");");
1810 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1811 SPC spaces of indent. */
1813 static void
1814 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1816 if (TREE_CODE (node) != SSA_NAME)
1817 return;
1819 if (POINTER_TYPE_P (TREE_TYPE (node))
1820 && SSA_NAME_PTR_INFO (node))
1822 unsigned int align, misalign;
1823 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1824 pp_string (buffer, "# PT = ");
1825 pp_points_to_solution (buffer, &pi->pt);
1826 newline_and_indent (buffer, spc);
1827 if (get_ptr_info_alignment (pi, &align, &misalign))
1829 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1830 newline_and_indent (buffer, spc);
1834 if (!POINTER_TYPE_P (TREE_TYPE (node))
1835 && SSA_NAME_RANGE_INFO (node))
1837 wide_int min, max, nonzero_bits;
1838 value_range_type range_type = get_range_info (node, &min, &max);
1840 if (range_type == VR_VARYING)
1841 pp_printf (buffer, "# RANGE VR_VARYING");
1842 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1844 pp_printf (buffer, "# RANGE ");
1845 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1846 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
1847 pp_printf (buffer, ", ");
1848 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
1849 pp_printf (buffer, "]");
1851 nonzero_bits = get_nonzero_bits (node);
1852 if (nonzero_bits != -1)
1854 pp_string (buffer, " NONZERO ");
1855 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
1857 newline_and_indent (buffer, spc);
1862 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1863 The caller is responsible for calling pp_flush on BUFFER to finalize
1864 pretty printer. If COMMENT is true, print this after #. */
1866 static void
1867 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
1868 int flags)
1870 size_t i;
1871 tree lhs = gimple_phi_result (phi);
1873 if (flags & TDF_ALIAS)
1874 dump_ssaname_info (buffer, lhs, spc);
1876 if (comment)
1877 pp_string (buffer, "# ");
1879 if (flags & TDF_RAW)
1880 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1881 gimple_phi_result (phi));
1882 else
1884 dump_generic_node (buffer, lhs, spc, flags, false);
1885 pp_string (buffer, " = PHI <");
1887 for (i = 0; i < gimple_phi_num_args (phi); i++)
1889 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1890 dump_location (buffer, gimple_phi_arg_location (phi, i));
1891 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1892 false);
1893 pp_left_paren (buffer);
1894 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1895 pp_right_paren (buffer);
1896 if (i < gimple_phi_num_args (phi) - 1)
1897 pp_string (buffer, ", ");
1899 pp_greater (buffer);
1903 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1904 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1905 dumpfile.h). */
1907 static void
1908 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
1909 int spc, int flags)
1911 if (flags & TDF_RAW)
1913 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1914 gimple_omp_body (gs));
1915 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1916 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1917 gimple_omp_parallel_child_fn (gs),
1918 gimple_omp_parallel_data_arg (gs));
1920 else
1922 gimple_seq body;
1923 pp_string (buffer, "#pragma omp parallel");
1924 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1925 if (gimple_omp_parallel_child_fn (gs))
1927 pp_string (buffer, " [child fn: ");
1928 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1929 spc, flags, false);
1930 pp_string (buffer, " (");
1931 if (gimple_omp_parallel_data_arg (gs))
1932 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1933 spc, flags, false);
1934 else
1935 pp_string (buffer, "???");
1936 pp_string (buffer, ")]");
1938 body = gimple_omp_body (gs);
1939 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1941 newline_and_indent (buffer, spc + 2);
1942 pp_left_brace (buffer);
1943 pp_newline (buffer);
1944 dump_gimple_seq (buffer, body, spc + 4, flags);
1945 newline_and_indent (buffer, spc + 2);
1946 pp_right_brace (buffer);
1948 else if (body)
1950 pp_newline (buffer);
1951 dump_gimple_seq (buffer, body, spc + 2, flags);
1957 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1958 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1959 dumpfile.h). */
1961 static void
1962 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
1963 int flags)
1965 if (flags & TDF_RAW)
1967 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1968 gimple_omp_body (gs));
1969 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1970 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1971 gimple_omp_task_child_fn (gs),
1972 gimple_omp_task_data_arg (gs),
1973 gimple_omp_task_copy_fn (gs),
1974 gimple_omp_task_arg_size (gs),
1975 gimple_omp_task_arg_size (gs));
1977 else
1979 gimple_seq body;
1980 pp_string (buffer, "#pragma omp task");
1981 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1982 if (gimple_omp_task_child_fn (gs))
1984 pp_string (buffer, " [child fn: ");
1985 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1986 spc, flags, false);
1987 pp_string (buffer, " (");
1988 if (gimple_omp_task_data_arg (gs))
1989 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1990 spc, flags, false);
1991 else
1992 pp_string (buffer, "???");
1993 pp_string (buffer, ")]");
1995 body = gimple_omp_body (gs);
1996 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1998 newline_and_indent (buffer, spc + 2);
1999 pp_left_brace (buffer);
2000 pp_newline (buffer);
2001 dump_gimple_seq (buffer, body, spc + 4, flags);
2002 newline_and_indent (buffer, spc + 2);
2003 pp_right_brace (buffer);
2005 else if (body)
2007 pp_newline (buffer);
2008 dump_gimple_seq (buffer, body, spc + 2, flags);
2014 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2015 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2016 in dumpfile.h). */
2018 static void
2019 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2020 int spc, int flags)
2022 if (flags & TDF_RAW)
2024 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2025 gimple_omp_atomic_load_lhs (gs),
2026 gimple_omp_atomic_load_rhs (gs));
2028 else
2030 pp_string (buffer, "#pragma omp atomic_load");
2031 if (gimple_omp_atomic_seq_cst_p (gs))
2032 pp_string (buffer, " seq_cst");
2033 if (gimple_omp_atomic_need_value_p (gs))
2034 pp_string (buffer, " [needed]");
2035 newline_and_indent (buffer, spc + 2);
2036 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2037 spc, flags, false);
2038 pp_space (buffer);
2039 pp_equal (buffer);
2040 pp_space (buffer);
2041 pp_star (buffer);
2042 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2043 spc, flags, false);
2047 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2048 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2049 in dumpfile.h). */
2051 static void
2052 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2053 gomp_atomic_store *gs, int spc, int flags)
2055 if (flags & TDF_RAW)
2057 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2058 gimple_omp_atomic_store_val (gs));
2060 else
2062 pp_string (buffer, "#pragma omp atomic_store ");
2063 if (gimple_omp_atomic_seq_cst_p (gs))
2064 pp_string (buffer, "seq_cst ");
2065 if (gimple_omp_atomic_need_value_p (gs))
2066 pp_string (buffer, "[needed] ");
2067 pp_left_paren (buffer);
2068 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2069 spc, flags, false);
2070 pp_right_paren (buffer);
2075 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2076 FLAGS are as in pp_gimple_stmt_1. */
2078 static void
2079 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
2081 tree vdef = gimple_vdef (gs);
2082 tree vuse = gimple_vuse (gs);
2084 if (vdef != NULL_TREE)
2086 pp_string (buffer, "# ");
2087 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2088 pp_string (buffer, " = VDEF <");
2089 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2090 pp_greater (buffer);
2091 newline_and_indent (buffer, spc);
2093 else if (vuse != NULL_TREE)
2095 pp_string (buffer, "# VUSE <");
2096 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2097 pp_greater (buffer);
2098 newline_and_indent (buffer, spc);
2103 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2104 spaces of indent. FLAGS specifies details to show in the dump (see
2105 TDF_* in dumpfile.h). The caller is responsible for calling
2106 pp_flush on BUFFER to finalize the pretty printer. */
2108 void
2109 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
2111 if (!gs)
2112 return;
2114 if (flags & TDF_STMTADDR)
2115 pp_printf (buffer, "<&%p> ", (void *) gs);
2117 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2118 dump_location (buffer, gimple_location (gs));
2120 if (flags & TDF_EH)
2122 int lp_nr = lookup_stmt_eh_lp (gs);
2123 if (lp_nr > 0)
2124 pp_printf (buffer, "[LP %d] ", lp_nr);
2125 else if (lp_nr < 0)
2126 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2129 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2130 && gimple_has_mem_ops (gs))
2131 dump_gimple_mem_ops (buffer, gs, spc, flags);
2133 if (gimple_has_lhs (gs)
2134 && (flags & TDF_ALIAS))
2135 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2137 switch (gimple_code (gs))
2139 case GIMPLE_ASM:
2140 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2141 break;
2143 case GIMPLE_ASSIGN:
2144 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2145 break;
2147 case GIMPLE_BIND:
2148 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2149 break;
2151 case GIMPLE_CALL:
2152 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2153 break;
2155 case GIMPLE_COND:
2156 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2157 break;
2159 case GIMPLE_LABEL:
2160 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2161 break;
2163 case GIMPLE_GOTO:
2164 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2165 break;
2167 case GIMPLE_NOP:
2168 pp_string (buffer, "GIMPLE_NOP");
2169 break;
2171 case GIMPLE_RETURN:
2172 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2173 break;
2175 case GIMPLE_SWITCH:
2176 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2177 break;
2179 case GIMPLE_TRY:
2180 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2181 break;
2183 case GIMPLE_PHI:
2184 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2185 break;
2187 case GIMPLE_OMP_PARALLEL:
2188 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2189 flags);
2190 break;
2192 case GIMPLE_OMP_TASK:
2193 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2194 break;
2196 case GIMPLE_OMP_ATOMIC_LOAD:
2197 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2198 spc, flags);
2199 break;
2201 case GIMPLE_OMP_ATOMIC_STORE:
2202 dump_gimple_omp_atomic_store (buffer,
2203 as_a <gomp_atomic_store *> (gs),
2204 spc, flags);
2205 break;
2207 case GIMPLE_OMP_FOR:
2208 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2209 break;
2211 case GIMPLE_OMP_CONTINUE:
2212 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2213 flags);
2214 break;
2216 case GIMPLE_OMP_SINGLE:
2217 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2218 flags);
2219 break;
2221 case GIMPLE_OMP_TARGET:
2222 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2223 flags);
2224 break;
2226 case GIMPLE_OMP_TEAMS:
2227 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2228 flags);
2229 break;
2231 case GIMPLE_OMP_RETURN:
2232 dump_gimple_omp_return (buffer, gs, spc, flags);
2233 break;
2235 case GIMPLE_OMP_SECTIONS:
2236 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2237 spc, flags);
2238 break;
2240 case GIMPLE_OMP_SECTIONS_SWITCH:
2241 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2242 break;
2244 case GIMPLE_OMP_MASTER:
2245 case GIMPLE_OMP_TASKGROUP:
2246 case GIMPLE_OMP_ORDERED:
2247 case GIMPLE_OMP_SECTION:
2248 dump_gimple_omp_block (buffer, gs, spc, flags);
2249 break;
2251 case GIMPLE_OMP_CRITICAL:
2252 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2253 flags);
2254 break;
2256 case GIMPLE_CATCH:
2257 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2258 break;
2260 case GIMPLE_EH_FILTER:
2261 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2262 break;
2264 case GIMPLE_EH_MUST_NOT_THROW:
2265 dump_gimple_eh_must_not_throw (buffer,
2266 as_a <geh_mnt *> (gs),
2267 spc, flags);
2268 break;
2270 case GIMPLE_EH_ELSE:
2271 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2272 break;
2274 case GIMPLE_RESX:
2275 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2276 break;
2278 case GIMPLE_EH_DISPATCH:
2279 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2280 flags);
2281 break;
2283 case GIMPLE_DEBUG:
2284 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2285 break;
2287 case GIMPLE_PREDICT:
2288 pp_string (buffer, "// predicted ");
2289 if (gimple_predict_outcome (gs))
2290 pp_string (buffer, "likely by ");
2291 else
2292 pp_string (buffer, "unlikely by ");
2293 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2294 pp_string (buffer, " predictor.");
2295 break;
2297 case GIMPLE_TRANSACTION:
2298 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2299 flags);
2300 break;
2302 default:
2303 GIMPLE_NIY;
2308 /* Dumps header of basic block BB to OUTF indented by INDENT
2309 spaces and details described by flags. */
2311 static void
2312 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2314 if (flags & TDF_BLOCKS)
2316 if (flags & TDF_LINENO)
2318 gimple_stmt_iterator gsi;
2320 if (flags & TDF_COMMENT)
2321 fputs (";; ", outf);
2323 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2324 if (!is_gimple_debug (gsi_stmt (gsi))
2325 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2327 fprintf (outf, "%*sstarting at line %d",
2328 indent, "", get_lineno (gsi_stmt (gsi)));
2329 break;
2331 if (bb->discriminator)
2332 fprintf (outf, ", discriminator %i", bb->discriminator);
2333 fputc ('\n', outf);
2336 else
2338 gimple stmt = first_stmt (bb);
2339 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2340 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2345 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2346 spaces. */
2348 static void
2349 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2350 basic_block bb ATTRIBUTE_UNUSED,
2351 int indent ATTRIBUTE_UNUSED,
2352 int flags ATTRIBUTE_UNUSED)
2354 /* There is currently no GIMPLE-specific basic block info to dump. */
2355 return;
2359 /* Dump PHI nodes of basic block BB to BUFFER with details described
2360 by FLAGS and indented by INDENT spaces. */
2362 static void
2363 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2365 gphi_iterator i;
2367 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2369 gphi *phi = i.phi ();
2370 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2372 INDENT (indent);
2373 dump_gimple_phi (buffer, phi, indent, true, flags);
2374 pp_newline (buffer);
2380 /* Dump jump to basic block BB that is represented implicitly in the cfg
2381 to BUFFER. */
2383 static void
2384 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2386 gimple stmt;
2388 stmt = first_stmt (bb);
2390 pp_string (buffer, "goto <bb ");
2391 pp_decimal_int (buffer, bb->index);
2392 pp_greater (buffer);
2393 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2395 pp_string (buffer, " (");
2396 dump_generic_node (buffer,
2397 gimple_label_label (as_a <glabel *> (stmt)),
2398 0, 0, false);
2399 pp_right_paren (buffer);
2400 pp_semicolon (buffer);
2402 else
2403 pp_semicolon (buffer);
2407 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2408 by INDENT spaces, with details given by FLAGS. */
2410 static void
2411 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2412 int flags)
2414 edge e;
2415 gimple stmt;
2417 stmt = last_stmt (bb);
2419 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2421 edge true_edge, false_edge;
2423 /* When we are emitting the code or changing CFG, it is possible that
2424 the edges are not yet created. When we are using debug_bb in such
2425 a situation, we do not want it to crash. */
2426 if (EDGE_COUNT (bb->succs) != 2)
2427 return;
2428 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2430 INDENT (indent + 2);
2431 pp_cfg_jump (buffer, true_edge->dest);
2432 newline_and_indent (buffer, indent);
2433 pp_string (buffer, "else");
2434 newline_and_indent (buffer, indent + 2);
2435 pp_cfg_jump (buffer, false_edge->dest);
2436 pp_newline (buffer);
2437 return;
2440 /* If there is a fallthru edge, we may need to add an artificial
2441 goto to the dump. */
2442 e = find_fallthru_edge (bb->succs);
2444 if (e && e->dest != bb->next_bb)
2446 INDENT (indent);
2448 if ((flags & TDF_LINENO)
2449 && e->goto_locus != UNKNOWN_LOCATION)
2450 dump_location (buffer, e->goto_locus);
2452 pp_cfg_jump (buffer, e->dest);
2453 pp_newline (buffer);
2458 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2459 indented by INDENT spaces. */
2461 static void
2462 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2463 int flags)
2465 gimple_stmt_iterator gsi;
2466 gimple stmt;
2467 int label_indent = indent - 2;
2469 if (label_indent < 0)
2470 label_indent = 0;
2472 dump_phi_nodes (buffer, bb, indent, flags);
2474 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2476 int curr_indent;
2478 stmt = gsi_stmt (gsi);
2480 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2482 INDENT (curr_indent);
2483 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2484 pp_newline_and_flush (buffer);
2485 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2486 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2487 pp_buffer (buffer)->stream, stmt);
2490 dump_implicit_edges (buffer, bb, indent, flags);
2491 pp_flush (buffer);
2495 /* Dumps basic block BB to FILE with details described by FLAGS and
2496 indented by INDENT spaces. */
2498 void
2499 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2501 dump_gimple_bb_header (file, bb, indent, flags);
2502 if (bb->index >= NUM_FIXED_BLOCKS)
2504 pretty_printer buffer;
2505 pp_needs_newline (&buffer) = true;
2506 buffer.buffer->stream = file;
2507 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2509 dump_gimple_bb_footer (file, bb, indent, flags);
2512 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2513 no indentation, for use as a label of a DOT graph record-node.
2514 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2515 histogram dumping doesn't know about pretty-printers. */
2517 void
2518 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2520 pp_printf (pp, "<bb %d>:\n", bb->index);
2521 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2523 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2524 gsi_next (&gsi))
2526 gphi *phi = gsi.phi ();
2527 if (!virtual_operand_p (gimple_phi_result (phi))
2528 || (dump_flags & TDF_VOPS))
2530 pp_bar (pp);
2531 pp_write_text_to_stream (pp);
2532 pp_string (pp, "# ");
2533 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2534 pp_newline (pp);
2535 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2539 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2540 gsi_next (&gsi))
2542 gimple stmt = gsi_stmt (gsi);
2543 pp_bar (pp);
2544 pp_write_text_to_stream (pp);
2545 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2546 pp_newline (pp);
2547 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2549 dump_implicit_edges (pp, bb, 0, dump_flags);
2550 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);