Fix memory leak in tree-vect-slp.c
[official-gcc.git] / gcc / gimple-pretty-print.c
blob4b0dc7c9a986bac37928a6992837c32ba0bbae75
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2016 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 "backend.h"
26 #include "tree.h"
27 #include "gimple.h"
28 #include "gimple-predict.h"
29 #include "ssa.h"
30 #include "cgraph.h"
31 #include "gimple-pretty-print.h"
32 #include "internal-fn.h"
33 #include "tree-eh.h"
34 #include "gimple-iterator.h"
35 #include "tree-cfg.h"
36 #include "dumpfile.h" /* for dump_flags */
37 #include "value-prof.h"
38 #include "trans-mem.h"
40 #define INDENT(SPACE) \
41 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
43 #define GIMPLE_NIY do_niy (buffer,gs)
45 /* Try to print on BUFFER a default message for the unrecognized
46 gimple statement GS. */
48 static void
49 do_niy (pretty_printer *buffer, gimple *gs)
51 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
52 gimple_code_name[(int) gimple_code (gs)]);
56 /* Emit a newline and SPC indentation spaces to BUFFER. */
58 static void
59 newline_and_indent (pretty_printer *buffer, int spc)
61 pp_newline (buffer);
62 INDENT (spc);
66 /* Print the GIMPLE statement GS on stderr. */
68 DEBUG_FUNCTION void
69 debug_gimple_stmt (gimple *gs)
71 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
75 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
76 FLAGS as in pp_gimple_stmt_1. */
78 void
79 print_gimple_stmt (FILE *file, gimple *g, int spc, int flags)
81 pretty_printer buffer;
82 pp_needs_newline (&buffer) = true;
83 buffer.buffer->stream = file;
84 pp_gimple_stmt_1 (&buffer, g, spc, flags);
85 pp_newline_and_flush (&buffer);
88 DEBUG_FUNCTION void
89 debug (gimple &ref)
91 print_gimple_stmt (stderr, &ref, 0, 0);
94 DEBUG_FUNCTION void
95 debug (gimple *ptr)
97 if (ptr)
98 debug (*ptr);
99 else
100 fprintf (stderr, "<nil>\n");
104 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
105 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
106 of the statement. */
108 void
109 print_gimple_expr (FILE *file, gimple *g, int spc, int flags)
111 flags |= TDF_RHS_ONLY;
112 pretty_printer buffer;
113 pp_needs_newline (&buffer) = true;
114 buffer.buffer->stream = file;
115 pp_gimple_stmt_1 (&buffer, g, spc, flags);
116 pp_flush (&buffer);
120 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
121 spaces and FLAGS as in pp_gimple_stmt_1.
122 The caller is responsible for calling pp_flush on BUFFER to finalize
123 the pretty printer. */
125 static void
126 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
128 gimple_stmt_iterator i;
130 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
132 gimple *gs = gsi_stmt (i);
133 INDENT (spc);
134 pp_gimple_stmt_1 (buffer, gs, spc, flags);
135 if (!gsi_one_before_end_p (i))
136 pp_newline (buffer);
141 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
142 FLAGS as in pp_gimple_stmt_1. */
144 void
145 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
147 pretty_printer buffer;
148 pp_needs_newline (&buffer) = true;
149 buffer.buffer->stream = file;
150 dump_gimple_seq (&buffer, seq, spc, flags);
151 pp_newline_and_flush (&buffer);
155 /* Print the GIMPLE sequence SEQ on stderr. */
157 DEBUG_FUNCTION void
158 debug_gimple_seq (gimple_seq seq)
160 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
164 /* A simple helper to pretty-print some of the gimple tuples in the printf
165 style. The format modifiers are preceded by '%' and are:
166 'G' - outputs a string corresponding to the code of the given gimple,
167 'S' - outputs a gimple_seq with indent of spc + 2,
168 'T' - outputs the tree t,
169 'd' - outputs an int as a decimal,
170 's' - outputs a string,
171 'n' - outputs a newline,
172 'x' - outputs an int as hexadecimal,
173 '+' - increases indent by 2 then outputs a newline,
174 '-' - decreases indent by 2 then outputs a newline. */
176 static void
177 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
178 const char *fmt, ...)
180 va_list args;
181 const char *c;
182 const char *tmp;
184 va_start (args, fmt);
185 for (c = fmt; *c; c++)
187 if (*c == '%')
189 gimple_seq seq;
190 tree t;
191 gimple *g;
192 switch (*++c)
194 case 'G':
195 g = va_arg (args, gimple *);
196 tmp = gimple_code_name[gimple_code (g)];
197 pp_string (buffer, tmp);
198 break;
200 case 'S':
201 seq = va_arg (args, gimple_seq);
202 pp_newline (buffer);
203 dump_gimple_seq (buffer, seq, spc + 2, flags);
204 newline_and_indent (buffer, spc);
205 break;
207 case 'T':
208 t = va_arg (args, tree);
209 if (t == NULL_TREE)
210 pp_string (buffer, "NULL");
211 else
212 dump_generic_node (buffer, t, spc, flags, false);
213 break;
215 case 'd':
216 pp_decimal_int (buffer, va_arg (args, int));
217 break;
219 case 's':
220 pp_string (buffer, va_arg (args, char *));
221 break;
223 case 'n':
224 newline_and_indent (buffer, spc);
225 break;
227 case 'x':
228 pp_scalar (buffer, "%x", va_arg (args, int));
229 break;
231 case '+':
232 spc += 2;
233 newline_and_indent (buffer, spc);
234 break;
236 case '-':
237 spc -= 2;
238 newline_and_indent (buffer, spc);
239 break;
241 default:
242 gcc_unreachable ();
245 else
246 pp_character (buffer, *c);
248 va_end (args);
252 /* Helper for dump_gimple_assign. Print the unary RHS of the
253 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
255 static void
256 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
258 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
259 tree lhs = gimple_assign_lhs (gs);
260 tree rhs = gimple_assign_rhs1 (gs);
262 switch (rhs_code)
264 case VIEW_CONVERT_EXPR:
265 case ASSERT_EXPR:
266 dump_generic_node (buffer, rhs, spc, flags, false);
267 break;
269 case FIXED_CONVERT_EXPR:
270 case ADDR_SPACE_CONVERT_EXPR:
271 case FIX_TRUNC_EXPR:
272 case FLOAT_EXPR:
273 CASE_CONVERT:
274 pp_left_paren (buffer);
275 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
276 pp_string (buffer, ") ");
277 if (op_prio (rhs) < op_code_prio (rhs_code))
279 pp_left_paren (buffer);
280 dump_generic_node (buffer, rhs, spc, flags, false);
281 pp_right_paren (buffer);
283 else
284 dump_generic_node (buffer, rhs, spc, flags, false);
285 break;
287 case PAREN_EXPR:
288 pp_string (buffer, "((");
289 dump_generic_node (buffer, rhs, spc, flags, false);
290 pp_string (buffer, "))");
291 break;
293 case ABS_EXPR:
294 pp_string (buffer, "ABS_EXPR <");
295 dump_generic_node (buffer, rhs, spc, flags, false);
296 pp_greater (buffer);
297 break;
299 default:
300 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
301 || TREE_CODE_CLASS (rhs_code) == tcc_constant
302 || TREE_CODE_CLASS (rhs_code) == tcc_reference
303 || rhs_code == SSA_NAME
304 || rhs_code == ADDR_EXPR
305 || rhs_code == CONSTRUCTOR)
307 dump_generic_node (buffer, rhs, spc, flags, false);
308 break;
310 else if (rhs_code == BIT_NOT_EXPR)
311 pp_complement (buffer);
312 else if (rhs_code == TRUTH_NOT_EXPR)
313 pp_exclamation (buffer);
314 else if (rhs_code == NEGATE_EXPR)
315 pp_minus (buffer);
316 else
318 pp_left_bracket (buffer);
319 pp_string (buffer, get_tree_code_name (rhs_code));
320 pp_string (buffer, "] ");
323 if (op_prio (rhs) < op_code_prio (rhs_code))
325 pp_left_paren (buffer);
326 dump_generic_node (buffer, rhs, spc, flags, false);
327 pp_right_paren (buffer);
329 else
330 dump_generic_node (buffer, rhs, spc, flags, false);
331 break;
336 /* Helper for dump_gimple_assign. Print the binary RHS of the
337 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
339 static void
340 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
342 const char *p;
343 enum tree_code code = gimple_assign_rhs_code (gs);
344 switch (code)
346 case COMPLEX_EXPR:
347 case MIN_EXPR:
348 case MAX_EXPR:
349 case VEC_WIDEN_MULT_HI_EXPR:
350 case VEC_WIDEN_MULT_LO_EXPR:
351 case VEC_WIDEN_MULT_EVEN_EXPR:
352 case VEC_WIDEN_MULT_ODD_EXPR:
353 case VEC_PACK_TRUNC_EXPR:
354 case VEC_PACK_SAT_EXPR:
355 case VEC_PACK_FIX_TRUNC_EXPR:
356 case VEC_WIDEN_LSHIFT_HI_EXPR:
357 case VEC_WIDEN_LSHIFT_LO_EXPR:
358 for (p = get_tree_code_name (code); *p; p++)
359 pp_character (buffer, TOUPPER (*p));
360 pp_string (buffer, " <");
361 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
362 pp_string (buffer, ", ");
363 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
364 pp_greater (buffer);
365 break;
367 default:
368 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
370 pp_left_paren (buffer);
371 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
372 false);
373 pp_right_paren (buffer);
375 else
376 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
377 pp_space (buffer);
378 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
379 pp_space (buffer);
380 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
382 pp_left_paren (buffer);
383 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
384 false);
385 pp_right_paren (buffer);
387 else
388 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
392 /* Helper for dump_gimple_assign. Print the ternary RHS of the
393 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
395 static void
396 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
398 const char *p;
399 enum tree_code code = gimple_assign_rhs_code (gs);
400 switch (code)
402 case WIDEN_MULT_PLUS_EXPR:
403 case WIDEN_MULT_MINUS_EXPR:
404 for (p = get_tree_code_name (code); *p; p++)
405 pp_character (buffer, TOUPPER (*p));
406 pp_string (buffer, " <");
407 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
408 pp_string (buffer, ", ");
409 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
410 pp_string (buffer, ", ");
411 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
412 pp_greater (buffer);
413 break;
415 case FMA_EXPR:
416 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
417 pp_string (buffer, " * ");
418 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
419 pp_string (buffer, " + ");
420 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
421 break;
423 case DOT_PROD_EXPR:
424 pp_string (buffer, "DOT_PROD_EXPR <");
425 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
426 pp_string (buffer, ", ");
427 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
428 pp_string (buffer, ", ");
429 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
430 pp_greater (buffer);
431 break;
433 case SAD_EXPR:
434 pp_string (buffer, "SAD_EXPR <");
435 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
436 pp_string (buffer, ", ");
437 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
438 pp_string (buffer, ", ");
439 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
440 pp_greater (buffer);
441 break;
443 case VEC_PERM_EXPR:
444 pp_string (buffer, "VEC_PERM_EXPR <");
445 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
446 pp_string (buffer, ", ");
447 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
448 pp_string (buffer, ", ");
449 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
450 pp_greater (buffer);
451 break;
453 case REALIGN_LOAD_EXPR:
454 pp_string (buffer, "REALIGN_LOAD <");
455 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
456 pp_string (buffer, ", ");
457 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
458 pp_string (buffer, ", ");
459 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
460 pp_greater (buffer);
461 break;
463 case COND_EXPR:
464 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
465 pp_string (buffer, " ? ");
466 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
467 pp_string (buffer, " : ");
468 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
469 break;
471 case VEC_COND_EXPR:
472 pp_string (buffer, "VEC_COND_EXPR <");
473 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
474 pp_string (buffer, ", ");
475 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
476 pp_string (buffer, ", ");
477 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
478 pp_greater (buffer);
479 break;
481 default:
482 gcc_unreachable ();
487 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
488 pp_gimple_stmt_1. */
490 static void
491 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
493 if (flags & TDF_RAW)
495 tree arg1 = NULL;
496 tree arg2 = NULL;
497 tree arg3 = NULL;
498 switch (gimple_num_ops (gs))
500 case 4:
501 arg3 = gimple_assign_rhs3 (gs);
502 case 3:
503 arg2 = gimple_assign_rhs2 (gs);
504 case 2:
505 arg1 = gimple_assign_rhs1 (gs);
506 break;
507 default:
508 gcc_unreachable ();
511 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
512 get_tree_code_name (gimple_assign_rhs_code (gs)),
513 gimple_assign_lhs (gs), arg1, arg2, arg3);
515 else
517 if (!(flags & TDF_RHS_ONLY))
519 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
520 pp_space (buffer);
521 pp_equal (buffer);
523 if (gimple_assign_nontemporal_move_p (gs))
524 pp_string (buffer, "{nt}");
526 if (gimple_has_volatile_ops (gs))
527 pp_string (buffer, "{v}");
529 pp_space (buffer);
532 if (gimple_num_ops (gs) == 2)
533 dump_unary_rhs (buffer, gs, spc, flags);
534 else if (gimple_num_ops (gs) == 3)
535 dump_binary_rhs (buffer, gs, spc, flags);
536 else if (gimple_num_ops (gs) == 4)
537 dump_ternary_rhs (buffer, gs, spc, flags);
538 else
539 gcc_unreachable ();
540 if (!(flags & TDF_RHS_ONLY))
541 pp_semicolon (buffer);
546 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
547 pp_gimple_stmt_1. */
549 static void
550 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
552 tree t, t2;
554 t = gimple_return_retval (gs);
555 t2 = gimple_return_retbnd (gs);
556 if (flags & TDF_RAW)
557 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
558 else
560 pp_string (buffer, "return");
561 if (t)
563 pp_space (buffer);
564 dump_generic_node (buffer, t, spc, flags, false);
566 if (t2)
568 pp_string (buffer, ", ");
569 dump_generic_node (buffer, t2, spc, flags, false);
571 pp_semicolon (buffer);
576 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
577 dump_gimple_call. */
579 static void
580 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
582 size_t i;
584 for (i = 0; i < gimple_call_num_args (gs); i++)
586 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
587 if (i < gimple_call_num_args (gs) - 1)
588 pp_string (buffer, ", ");
591 if (gimple_call_va_arg_pack_p (gs))
593 if (gimple_call_num_args (gs) > 0)
595 pp_comma (buffer);
596 pp_space (buffer);
599 pp_string (buffer, "__builtin_va_arg_pack ()");
603 /* Dump the points-to solution *PT to BUFFER. */
605 static void
606 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
608 if (pt->anything)
610 pp_string (buffer, "anything ");
611 return;
613 if (pt->nonlocal)
614 pp_string (buffer, "nonlocal ");
615 if (pt->escaped)
616 pp_string (buffer, "escaped ");
617 if (pt->ipa_escaped)
618 pp_string (buffer, "unit-escaped ");
619 if (pt->null)
620 pp_string (buffer, "null ");
621 if (pt->vars
622 && !bitmap_empty_p (pt->vars))
624 bitmap_iterator bi;
625 unsigned i;
626 pp_string (buffer, "{ ");
627 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
629 pp_string (buffer, "D.");
630 pp_decimal_int (buffer, i);
631 pp_space (buffer);
633 pp_right_brace (buffer);
634 if (pt->vars_contains_nonlocal
635 || pt->vars_contains_escaped
636 || pt->vars_contains_escaped_heap
637 || pt->vars_contains_restrict)
639 const char *comma = "";
640 pp_string (buffer, " (");
641 if (pt->vars_contains_nonlocal)
643 pp_string (buffer, "nonlocal");
644 comma = ", ";
646 if (pt->vars_contains_escaped)
648 pp_string (buffer, comma);
649 pp_string (buffer, "escaped");
650 comma = ", ";
652 if (pt->vars_contains_escaped_heap)
654 pp_string (buffer, comma);
655 pp_string (buffer, "escaped heap");
656 comma = ", ";
658 if (pt->vars_contains_restrict)
660 pp_string (buffer, comma);
661 pp_string (buffer, "restrict");
663 pp_string (buffer, ")");
669 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
670 pp_gimple_stmt_1. */
672 static void
673 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
675 tree lhs = gimple_call_lhs (gs);
676 tree fn = gimple_call_fn (gs);
678 if (flags & TDF_ALIAS)
680 struct pt_solution *pt;
681 pt = gimple_call_use_set (gs);
682 if (!pt_solution_empty_p (pt))
684 pp_string (buffer, "# USE = ");
685 pp_points_to_solution (buffer, pt);
686 newline_and_indent (buffer, spc);
688 pt = gimple_call_clobber_set (gs);
689 if (!pt_solution_empty_p (pt))
691 pp_string (buffer, "# CLB = ");
692 pp_points_to_solution (buffer, pt);
693 newline_and_indent (buffer, spc);
697 if (flags & TDF_RAW)
699 if (gimple_call_internal_p (gs))
700 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
701 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
702 else
703 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
704 if (gimple_call_num_args (gs) > 0)
706 pp_string (buffer, ", ");
707 dump_gimple_call_args (buffer, gs, flags);
709 pp_greater (buffer);
711 else
713 if (lhs && !(flags & TDF_RHS_ONLY))
715 dump_generic_node (buffer, lhs, spc, flags, false);
716 pp_string (buffer, " =");
718 if (gimple_has_volatile_ops (gs))
719 pp_string (buffer, "{v}");
721 pp_space (buffer);
723 if (gimple_call_internal_p (gs))
724 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
725 else
726 print_call_name (buffer, fn, flags);
727 pp_string (buffer, " (");
728 dump_gimple_call_args (buffer, gs, flags);
729 pp_right_paren (buffer);
730 if (!(flags & TDF_RHS_ONLY))
731 pp_semicolon (buffer);
734 if (gimple_call_chain (gs))
736 pp_string (buffer, " [static-chain: ");
737 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
738 pp_right_bracket (buffer);
741 if (gimple_call_return_slot_opt_p (gs))
742 pp_string (buffer, " [return slot optimization]");
743 if (gimple_call_tail_p (gs))
744 pp_string (buffer, " [tail call]");
746 if (fn == NULL)
747 return;
749 /* Dump the arguments of _ITM_beginTransaction sanely. */
750 if (TREE_CODE (fn) == ADDR_EXPR)
751 fn = TREE_OPERAND (fn, 0);
752 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
753 pp_string (buffer, " [tm-clone]");
754 if (TREE_CODE (fn) == FUNCTION_DECL
755 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
756 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
757 && gimple_call_num_args (gs) > 0)
759 tree t = gimple_call_arg (gs, 0);
760 unsigned HOST_WIDE_INT props;
761 gcc_assert (TREE_CODE (t) == INTEGER_CST);
763 pp_string (buffer, " [ ");
765 /* Get the transaction code properties. */
766 props = TREE_INT_CST_LOW (t);
768 if (props & PR_INSTRUMENTEDCODE)
769 pp_string (buffer, "instrumentedCode ");
770 if (props & PR_UNINSTRUMENTEDCODE)
771 pp_string (buffer, "uninstrumentedCode ");
772 if (props & PR_HASNOXMMUPDATE)
773 pp_string (buffer, "hasNoXMMUpdate ");
774 if (props & PR_HASNOABORT)
775 pp_string (buffer, "hasNoAbort ");
776 if (props & PR_HASNOIRREVOCABLE)
777 pp_string (buffer, "hasNoIrrevocable ");
778 if (props & PR_DOESGOIRREVOCABLE)
779 pp_string (buffer, "doesGoIrrevocable ");
780 if (props & PR_HASNOSIMPLEREADS)
781 pp_string (buffer, "hasNoSimpleReads ");
782 if (props & PR_AWBARRIERSOMITTED)
783 pp_string (buffer, "awBarriersOmitted ");
784 if (props & PR_RARBARRIERSOMITTED)
785 pp_string (buffer, "RaRBarriersOmitted ");
786 if (props & PR_UNDOLOGCODE)
787 pp_string (buffer, "undoLogCode ");
788 if (props & PR_PREFERUNINSTRUMENTED)
789 pp_string (buffer, "preferUninstrumented ");
790 if (props & PR_EXCEPTIONBLOCK)
791 pp_string (buffer, "exceptionBlock ");
792 if (props & PR_HASELSE)
793 pp_string (buffer, "hasElse ");
794 if (props & PR_READONLY)
795 pp_string (buffer, "readOnly ");
797 pp_right_bracket (buffer);
802 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
803 pp_gimple_stmt_1. */
805 static void
806 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
807 int flags)
809 unsigned int i;
811 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
812 if (flags & TDF_RAW)
813 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
814 gimple_switch_index (gs));
815 else
817 pp_string (buffer, "switch (");
818 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
819 pp_string (buffer, ") <");
822 for (i = 0; i < gimple_switch_num_labels (gs); i++)
824 tree case_label = gimple_switch_label (gs, i);
825 gcc_checking_assert (case_label != NULL_TREE);
826 dump_generic_node (buffer, case_label, spc, flags, false);
827 pp_space (buffer);
828 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
829 if (i < gimple_switch_num_labels (gs) - 1)
830 pp_string (buffer, ", ");
832 pp_greater (buffer);
836 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
837 pp_gimple_stmt_1. */
839 static void
840 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
842 if (flags & TDF_RAW)
843 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
844 get_tree_code_name (gimple_cond_code (gs)),
845 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
846 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
847 else
849 if (!(flags & TDF_RHS_ONLY))
850 pp_string (buffer, "if (");
851 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
852 pp_space (buffer);
853 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
854 pp_space (buffer);
855 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
856 if (!(flags & TDF_RHS_ONLY))
858 pp_right_paren (buffer);
860 if (gimple_cond_true_label (gs))
862 pp_string (buffer, " goto ");
863 dump_generic_node (buffer, gimple_cond_true_label (gs),
864 spc, flags, false);
865 pp_semicolon (buffer);
867 if (gimple_cond_false_label (gs))
869 pp_string (buffer, " else goto ");
870 dump_generic_node (buffer, gimple_cond_false_label (gs),
871 spc, flags, false);
872 pp_semicolon (buffer);
879 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
880 spaces of indent. FLAGS specifies details to show in the dump (see
881 TDF_* in dumpfils.h). */
883 static void
884 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
886 tree label = gimple_label_label (gs);
887 if (flags & TDF_RAW)
888 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
889 else
891 dump_generic_node (buffer, label, spc, flags, false);
892 pp_colon (buffer);
894 if (DECL_NONLOCAL (label))
895 pp_string (buffer, " [non-local]");
896 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
897 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
900 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
901 spaces of indent. FLAGS specifies details to show in the dump (see
902 TDF_* in dumpfile.h). */
904 static void
905 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
907 tree label = gimple_goto_dest (gs);
908 if (flags & TDF_RAW)
909 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
910 else
911 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
915 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
916 spaces of indent. FLAGS specifies details to show in the dump (see
917 TDF_* in dumpfile.h). */
919 static void
920 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
922 if (flags & TDF_RAW)
923 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
924 else
925 pp_left_brace (buffer);
926 if (!(flags & TDF_SLIM))
928 tree var;
930 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
932 newline_and_indent (buffer, 2);
933 print_declaration (buffer, var, spc, flags);
935 if (gimple_bind_vars (gs))
936 pp_newline (buffer);
938 pp_newline (buffer);
939 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
940 newline_and_indent (buffer, spc);
941 if (flags & TDF_RAW)
942 pp_greater (buffer);
943 else
944 pp_right_brace (buffer);
948 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
949 indent. FLAGS specifies details to show in the dump (see TDF_* in
950 dumpfile.h). */
952 static void
953 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
955 if (flags & TDF_RAW)
957 const char *type;
958 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
959 type = "GIMPLE_TRY_CATCH";
960 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
961 type = "GIMPLE_TRY_FINALLY";
962 else
963 type = "UNKNOWN GIMPLE_TRY";
964 dump_gimple_fmt (buffer, spc, flags,
965 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
966 gimple_try_eval (gs), gimple_try_cleanup (gs));
968 else
970 pp_string (buffer, "try");
971 newline_and_indent (buffer, spc + 2);
972 pp_left_brace (buffer);
973 pp_newline (buffer);
975 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
976 newline_and_indent (buffer, spc + 2);
977 pp_right_brace (buffer);
979 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
981 newline_and_indent (buffer, spc);
982 pp_string (buffer, "catch");
983 newline_and_indent (buffer, spc + 2);
984 pp_left_brace (buffer);
986 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
988 newline_and_indent (buffer, spc);
989 pp_string (buffer, "finally");
990 newline_and_indent (buffer, spc + 2);
991 pp_left_brace (buffer);
993 else
994 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
996 pp_newline (buffer);
997 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
998 newline_and_indent (buffer, spc + 2);
999 pp_right_brace (buffer);
1004 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1005 indent. FLAGS specifies details to show in the dump (see TDF_* in
1006 dumpfile.h). */
1008 static void
1009 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
1011 if (flags & TDF_RAW)
1012 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1013 gimple_catch_types (gs), gimple_catch_handler (gs));
1014 else
1015 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1016 gimple_catch_types (gs), gimple_catch_handler (gs));
1020 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1021 indent. FLAGS specifies details to show in the dump (see TDF_* in
1022 dumpfile.h). */
1024 static void
1025 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1026 int flags)
1028 if (flags & TDF_RAW)
1029 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1030 gimple_eh_filter_types (gs),
1031 gimple_eh_filter_failure (gs));
1032 else
1033 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1034 gimple_eh_filter_types (gs),
1035 gimple_eh_filter_failure (gs));
1039 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1041 static void
1042 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1043 geh_mnt *gs, int spc, int flags)
1045 if (flags & TDF_RAW)
1046 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1047 gimple_eh_must_not_throw_fndecl (gs));
1048 else
1049 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1050 gimple_eh_must_not_throw_fndecl (gs));
1054 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1055 indent. FLAGS specifies details to show in the dump (see TDF_* in
1056 dumpfile.h). */
1058 static void
1059 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1060 int flags)
1062 if (flags & TDF_RAW)
1063 dump_gimple_fmt (buffer, spc, flags,
1064 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1065 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1066 else
1067 dump_gimple_fmt (buffer, spc, flags,
1068 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1069 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1073 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1074 indent. FLAGS specifies details to show in the dump (see TDF_* in
1075 dumpfile.h). */
1077 static void
1078 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
1080 if (flags & TDF_RAW)
1081 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1082 gimple_resx_region (gs));
1083 else
1084 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1087 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1089 static void
1090 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int flags)
1092 if (flags & TDF_RAW)
1093 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1094 gimple_eh_dispatch_region (gs));
1095 else
1096 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1097 gimple_eh_dispatch_region (gs));
1100 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1101 of indent. FLAGS specifies details to show in the dump (see TDF_*
1102 in dumpfile.h). */
1104 static void
1105 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
1107 switch (gs->subcode)
1109 case GIMPLE_DEBUG_BIND:
1110 if (flags & TDF_RAW)
1111 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1112 gimple_debug_bind_get_var (gs),
1113 gimple_debug_bind_get_value (gs));
1114 else
1115 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1116 gimple_debug_bind_get_var (gs),
1117 gimple_debug_bind_get_value (gs));
1118 break;
1120 case GIMPLE_DEBUG_SOURCE_BIND:
1121 if (flags & TDF_RAW)
1122 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1123 gimple_debug_source_bind_get_var (gs),
1124 gimple_debug_source_bind_get_value (gs));
1125 else
1126 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1127 gimple_debug_source_bind_get_var (gs),
1128 gimple_debug_source_bind_get_value (gs));
1129 break;
1131 default:
1132 gcc_unreachable ();
1136 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1137 static void
1138 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
1140 size_t i;
1142 if (flags & TDF_RAW)
1144 const char *kind;
1145 switch (gimple_omp_for_kind (gs))
1147 case GF_OMP_FOR_KIND_FOR:
1148 kind = "";
1149 break;
1150 case GF_OMP_FOR_KIND_DISTRIBUTE:
1151 kind = " distribute";
1152 break;
1153 case GF_OMP_FOR_KIND_TASKLOOP:
1154 kind = " taskloop";
1155 break;
1156 case GF_OMP_FOR_KIND_CILKFOR:
1157 kind = " _Cilk_for";
1158 break;
1159 case GF_OMP_FOR_KIND_OACC_LOOP:
1160 kind = " oacc_loop";
1161 break;
1162 case GF_OMP_FOR_KIND_SIMD:
1163 kind = " simd";
1164 break;
1165 case GF_OMP_FOR_KIND_CILKSIMD:
1166 kind = " cilksimd";
1167 break;
1168 default:
1169 gcc_unreachable ();
1171 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1172 kind, gimple_omp_body (gs));
1173 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1174 dump_gimple_fmt (buffer, spc, flags, " >,");
1175 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1176 dump_gimple_fmt (buffer, spc, flags,
1177 "%+%T, %T, %T, %s, %T,%n",
1178 gimple_omp_for_index (gs, i),
1179 gimple_omp_for_initial (gs, i),
1180 gimple_omp_for_final (gs, i),
1181 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1182 gimple_omp_for_incr (gs, i));
1183 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1184 gimple_omp_for_pre_body (gs));
1186 else
1188 switch (gimple_omp_for_kind (gs))
1190 case GF_OMP_FOR_KIND_FOR:
1191 pp_string (buffer, "#pragma omp for");
1192 break;
1193 case GF_OMP_FOR_KIND_DISTRIBUTE:
1194 pp_string (buffer, "#pragma omp distribute");
1195 break;
1196 case GF_OMP_FOR_KIND_TASKLOOP:
1197 pp_string (buffer, "#pragma omp taskloop");
1198 break;
1199 case GF_OMP_FOR_KIND_CILKFOR:
1200 break;
1201 case GF_OMP_FOR_KIND_OACC_LOOP:
1202 pp_string (buffer, "#pragma acc loop");
1203 break;
1204 case GF_OMP_FOR_KIND_SIMD:
1205 pp_string (buffer, "#pragma omp simd");
1206 break;
1207 case GF_OMP_FOR_KIND_CILKSIMD:
1208 pp_string (buffer, "#pragma simd");
1209 break;
1210 case GF_OMP_FOR_KIND_GRID_LOOP:
1211 pp_string (buffer, "#pragma omp for grid_loop");
1212 break;
1213 default:
1214 gcc_unreachable ();
1216 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1217 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1218 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1220 if (i)
1221 spc += 2;
1222 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1223 pp_string (buffer, "_Cilk_for (");
1224 else
1226 newline_and_indent (buffer, spc);
1227 pp_string (buffer, "for (");
1229 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1230 flags, false);
1231 pp_string (buffer, " = ");
1232 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1233 flags, false);
1234 pp_string (buffer, "; ");
1236 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1237 flags, false);
1238 pp_space (buffer);
1239 switch (gimple_omp_for_cond (gs, i))
1241 case LT_EXPR:
1242 pp_less (buffer);
1243 break;
1244 case GT_EXPR:
1245 pp_greater (buffer);
1246 break;
1247 case LE_EXPR:
1248 pp_less_equal (buffer);
1249 break;
1250 case GE_EXPR:
1251 pp_greater_equal (buffer);
1252 break;
1253 case NE_EXPR:
1254 pp_string (buffer, "!=");
1255 break;
1256 default:
1257 gcc_unreachable ();
1259 pp_space (buffer);
1260 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1261 flags, false);
1262 pp_string (buffer, "; ");
1264 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1265 flags, false);
1266 pp_string (buffer, " = ");
1267 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1268 flags, false);
1269 pp_right_paren (buffer);
1272 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1274 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1275 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1276 newline_and_indent (buffer, spc + 2);
1277 pp_left_brace (buffer);
1278 pp_newline (buffer);
1279 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1280 newline_and_indent (buffer, spc + 2);
1281 pp_right_brace (buffer);
1286 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1288 static void
1289 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1290 int spc, int flags)
1292 if (flags & TDF_RAW)
1294 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1295 gimple_omp_continue_control_def (gs),
1296 gimple_omp_continue_control_use (gs));
1298 else
1300 pp_string (buffer, "#pragma omp continue (");
1301 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1302 spc, flags, false);
1303 pp_comma (buffer);
1304 pp_space (buffer);
1305 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1306 spc, flags, false);
1307 pp_right_paren (buffer);
1311 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1313 static void
1314 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1315 int spc, int flags)
1317 if (flags & TDF_RAW)
1319 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1320 gimple_omp_body (gs));
1321 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1322 dump_gimple_fmt (buffer, spc, flags, " >");
1324 else
1326 pp_string (buffer, "#pragma omp single");
1327 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1328 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1330 newline_and_indent (buffer, spc + 2);
1331 pp_left_brace (buffer);
1332 pp_newline (buffer);
1333 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1334 newline_and_indent (buffer, spc + 2);
1335 pp_right_brace (buffer);
1340 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1342 static void
1343 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1344 int spc, int flags)
1346 const char *kind;
1347 switch (gimple_omp_target_kind (gs))
1349 case GF_OMP_TARGET_KIND_REGION:
1350 kind = "";
1351 break;
1352 case GF_OMP_TARGET_KIND_DATA:
1353 kind = " data";
1354 break;
1355 case GF_OMP_TARGET_KIND_UPDATE:
1356 kind = " update";
1357 break;
1358 case GF_OMP_TARGET_KIND_ENTER_DATA:
1359 kind = " enter data";
1360 break;
1361 case GF_OMP_TARGET_KIND_EXIT_DATA:
1362 kind = " exit data";
1363 break;
1364 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1365 kind = " oacc_kernels";
1366 break;
1367 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1368 kind = " oacc_parallel";
1369 break;
1370 case GF_OMP_TARGET_KIND_OACC_DATA:
1371 kind = " oacc_data";
1372 break;
1373 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1374 kind = " oacc_update";
1375 break;
1376 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1377 kind = " oacc_enter_exit_data";
1378 break;
1379 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1380 kind = " oacc_declare";
1381 break;
1382 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1383 kind = " oacc_host_data";
1384 break;
1385 default:
1386 gcc_unreachable ();
1388 if (flags & TDF_RAW)
1390 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1391 kind, gimple_omp_body (gs));
1392 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1393 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1394 gimple_omp_target_child_fn (gs),
1395 gimple_omp_target_data_arg (gs));
1397 else
1399 pp_string (buffer, "#pragma omp target");
1400 pp_string (buffer, kind);
1401 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1402 if (gimple_omp_target_child_fn (gs))
1404 pp_string (buffer, " [child fn: ");
1405 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1406 spc, flags, false);
1407 pp_string (buffer, " (");
1408 if (gimple_omp_target_data_arg (gs))
1409 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1410 spc, flags, false);
1411 else
1412 pp_string (buffer, "???");
1413 pp_string (buffer, ")]");
1415 gimple_seq body = gimple_omp_body (gs);
1416 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1418 newline_and_indent (buffer, spc + 2);
1419 pp_left_brace (buffer);
1420 pp_newline (buffer);
1421 dump_gimple_seq (buffer, body, spc + 4, flags);
1422 newline_and_indent (buffer, spc + 2);
1423 pp_right_brace (buffer);
1425 else if (body)
1427 pp_newline (buffer);
1428 dump_gimple_seq (buffer, body, spc + 2, flags);
1433 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1435 static void
1436 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1437 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_teams_clauses (gs), spc, flags);
1444 dump_gimple_fmt (buffer, spc, flags, " >");
1446 else
1448 pp_string (buffer, "#pragma omp teams");
1449 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1450 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1452 newline_and_indent (buffer, spc + 2);
1453 pp_character (buffer, '{');
1454 pp_newline (buffer);
1455 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1456 newline_and_indent (buffer, spc + 2);
1457 pp_character (buffer, '}');
1462 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1464 static void
1465 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1466 int spc, int flags)
1468 if (flags & TDF_RAW)
1470 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1471 gimple_omp_body (gs));
1472 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1473 dump_gimple_fmt (buffer, spc, flags, " >");
1475 else
1477 pp_string (buffer, "#pragma omp sections");
1478 if (gimple_omp_sections_control (gs))
1480 pp_string (buffer, " <");
1481 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1482 flags, false);
1483 pp_greater (buffer);
1485 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1486 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1488 newline_and_indent (buffer, spc + 2);
1489 pp_left_brace (buffer);
1490 pp_newline (buffer);
1491 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1492 newline_and_indent (buffer, spc + 2);
1493 pp_right_brace (buffer);
1498 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1499 pretty_printer BUFFER. */
1501 static void
1502 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc, int flags)
1504 if (flags & TDF_RAW)
1505 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1506 gimple_omp_body (gs));
1507 else
1509 switch (gimple_code (gs))
1511 case GIMPLE_OMP_MASTER:
1512 pp_string (buffer, "#pragma omp master");
1513 break;
1514 case GIMPLE_OMP_TASKGROUP:
1515 pp_string (buffer, "#pragma omp taskgroup");
1516 break;
1517 case GIMPLE_OMP_SECTION:
1518 pp_string (buffer, "#pragma omp section");
1519 break;
1520 case GIMPLE_OMP_GRID_BODY:
1521 pp_string (buffer, "#pragma omp gridified body");
1522 break;
1523 default:
1524 gcc_unreachable ();
1526 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1528 newline_and_indent (buffer, spc + 2);
1529 pp_left_brace (buffer);
1530 pp_newline (buffer);
1531 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1532 newline_and_indent (buffer, spc + 2);
1533 pp_right_brace (buffer);
1538 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1540 static void
1541 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1542 int spc, int flags)
1544 if (flags & TDF_RAW)
1545 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1546 gimple_omp_body (gs));
1547 else
1549 pp_string (buffer, "#pragma omp critical");
1550 if (gimple_omp_critical_name (gs))
1552 pp_string (buffer, " (");
1553 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1554 flags, false);
1555 pp_right_paren (buffer);
1557 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1558 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1560 newline_and_indent (buffer, spc + 2);
1561 pp_left_brace (buffer);
1562 pp_newline (buffer);
1563 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1564 newline_and_indent (buffer, spc + 2);
1565 pp_right_brace (buffer);
1570 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1572 static void
1573 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1574 int spc, int flags)
1576 if (flags & TDF_RAW)
1577 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1578 gimple_omp_body (gs));
1579 else
1581 pp_string (buffer, "#pragma omp ordered");
1582 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1583 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1585 newline_and_indent (buffer, spc + 2);
1586 pp_left_brace (buffer);
1587 pp_newline (buffer);
1588 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1589 newline_and_indent (buffer, spc + 2);
1590 pp_right_brace (buffer);
1595 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1597 static void
1598 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc, int flags)
1600 if (flags & TDF_RAW)
1602 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1603 (int) gimple_omp_return_nowait_p (gs));
1604 if (gimple_omp_return_lhs (gs))
1605 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1606 gimple_omp_return_lhs (gs));
1607 else
1608 dump_gimple_fmt (buffer, spc, flags, ">");
1610 else
1612 pp_string (buffer, "#pragma omp return");
1613 if (gimple_omp_return_nowait_p (gs))
1614 pp_string (buffer, "(nowait)");
1615 if (gimple_omp_return_lhs (gs))
1617 pp_string (buffer, " (set ");
1618 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1619 spc, flags, false);
1620 pp_character (buffer, ')');
1625 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1627 static void
1628 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1629 int spc, int flags)
1631 unsigned subcode = gimple_transaction_subcode (gs);
1633 if (flags & TDF_RAW)
1635 dump_gimple_fmt (buffer, spc, flags,
1636 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1637 "<%+BODY <%S> >",
1638 gs, subcode, gimple_transaction_label_norm (gs),
1639 gimple_transaction_label_uninst (gs),
1640 gimple_transaction_label_over (gs),
1641 gimple_transaction_body (gs));
1643 else
1645 if (subcode & GTMA_IS_OUTER)
1646 pp_string (buffer, "__transaction_atomic [[outer]]");
1647 else if (subcode & GTMA_IS_RELAXED)
1648 pp_string (buffer, "__transaction_relaxed");
1649 else
1650 pp_string (buffer, "__transaction_atomic");
1651 subcode &= ~GTMA_DECLARATION_MASK;
1653 if (gimple_transaction_body (gs))
1655 newline_and_indent (buffer, spc + 2);
1656 pp_left_brace (buffer);
1657 pp_newline (buffer);
1658 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1659 spc + 4, flags);
1660 newline_and_indent (buffer, spc + 2);
1661 pp_right_brace (buffer);
1663 else
1665 pp_string (buffer, " //");
1666 if (gimple_transaction_label_norm (gs))
1668 pp_string (buffer, " NORM=");
1669 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1670 spc, flags, false);
1672 if (gimple_transaction_label_uninst (gs))
1674 pp_string (buffer, " UNINST=");
1675 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1676 spc, flags, false);
1678 if (gimple_transaction_label_over (gs))
1680 pp_string (buffer, " OVER=");
1681 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1682 spc, flags, false);
1684 if (subcode)
1686 pp_string (buffer, " SUBCODE=[ ");
1687 if (subcode & GTMA_HAVE_ABORT)
1689 pp_string (buffer, "GTMA_HAVE_ABORT ");
1690 subcode &= ~GTMA_HAVE_ABORT;
1692 if (subcode & GTMA_HAVE_LOAD)
1694 pp_string (buffer, "GTMA_HAVE_LOAD ");
1695 subcode &= ~GTMA_HAVE_LOAD;
1697 if (subcode & GTMA_HAVE_STORE)
1699 pp_string (buffer, "GTMA_HAVE_STORE ");
1700 subcode &= ~GTMA_HAVE_STORE;
1702 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1704 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1705 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1707 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1709 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1710 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1712 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1714 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1715 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1717 if (subcode)
1718 pp_printf (buffer, "0x%x ", subcode);
1719 pp_right_bracket (buffer);
1725 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1726 indent. FLAGS specifies details to show in the dump (see TDF_* in
1727 dumpfile.h). */
1729 static void
1730 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
1732 unsigned int i, n, f, fields;
1734 if (flags & TDF_RAW)
1736 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1737 gimple_asm_string (gs));
1739 n = gimple_asm_noutputs (gs);
1740 if (n)
1742 newline_and_indent (buffer, spc + 2);
1743 pp_string (buffer, "OUTPUT: ");
1744 for (i = 0; i < n; i++)
1746 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1747 spc, flags, false);
1748 if (i < n - 1)
1749 pp_string (buffer, ", ");
1753 n = gimple_asm_ninputs (gs);
1754 if (n)
1756 newline_and_indent (buffer, spc + 2);
1757 pp_string (buffer, "INPUT: ");
1758 for (i = 0; i < n; i++)
1760 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1761 spc, flags, false);
1762 if (i < n - 1)
1763 pp_string (buffer, ", ");
1767 n = gimple_asm_nclobbers (gs);
1768 if (n)
1770 newline_and_indent (buffer, spc + 2);
1771 pp_string (buffer, "CLOBBER: ");
1772 for (i = 0; i < n; i++)
1774 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1775 spc, flags, false);
1776 if (i < n - 1)
1777 pp_string (buffer, ", ");
1781 n = gimple_asm_nlabels (gs);
1782 if (n)
1784 newline_and_indent (buffer, spc + 2);
1785 pp_string (buffer, "LABEL: ");
1786 for (i = 0; i < n; i++)
1788 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1789 spc, flags, false);
1790 if (i < n - 1)
1791 pp_string (buffer, ", ");
1795 newline_and_indent (buffer, spc);
1796 pp_greater (buffer);
1798 else
1800 pp_string (buffer, "__asm__");
1801 if (gimple_asm_volatile_p (gs))
1802 pp_string (buffer, " __volatile__");
1803 if (gimple_asm_nlabels (gs))
1804 pp_string (buffer, " goto");
1805 pp_string (buffer, "(\"");
1806 pp_string (buffer, gimple_asm_string (gs));
1807 pp_string (buffer, "\"");
1809 if (gimple_asm_nlabels (gs))
1810 fields = 4;
1811 else if (gimple_asm_nclobbers (gs))
1812 fields = 3;
1813 else if (gimple_asm_ninputs (gs))
1814 fields = 2;
1815 else if (gimple_asm_noutputs (gs))
1816 fields = 1;
1817 else
1818 fields = 0;
1820 for (f = 0; f < fields; ++f)
1822 pp_string (buffer, " : ");
1824 switch (f)
1826 case 0:
1827 n = gimple_asm_noutputs (gs);
1828 for (i = 0; i < n; i++)
1830 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1831 spc, flags, false);
1832 if (i < n - 1)
1833 pp_string (buffer, ", ");
1835 break;
1837 case 1:
1838 n = gimple_asm_ninputs (gs);
1839 for (i = 0; i < n; i++)
1841 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1842 spc, flags, false);
1843 if (i < n - 1)
1844 pp_string (buffer, ", ");
1846 break;
1848 case 2:
1849 n = gimple_asm_nclobbers (gs);
1850 for (i = 0; i < n; i++)
1852 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1853 spc, flags, false);
1854 if (i < n - 1)
1855 pp_string (buffer, ", ");
1857 break;
1859 case 3:
1860 n = gimple_asm_nlabels (gs);
1861 for (i = 0; i < n; i++)
1863 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1864 spc, flags, false);
1865 if (i < n - 1)
1866 pp_string (buffer, ", ");
1868 break;
1870 default:
1871 gcc_unreachable ();
1875 pp_string (buffer, ");");
1879 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1880 SPC spaces of indent. */
1882 static void
1883 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1885 if (TREE_CODE (node) != SSA_NAME)
1886 return;
1888 if (POINTER_TYPE_P (TREE_TYPE (node))
1889 && SSA_NAME_PTR_INFO (node))
1891 unsigned int align, misalign;
1892 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1893 pp_string (buffer, "# PT = ");
1894 pp_points_to_solution (buffer, &pi->pt);
1895 newline_and_indent (buffer, spc);
1896 if (get_ptr_info_alignment (pi, &align, &misalign))
1898 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1899 newline_and_indent (buffer, spc);
1903 if (!POINTER_TYPE_P (TREE_TYPE (node))
1904 && SSA_NAME_RANGE_INFO (node))
1906 wide_int min, max, nonzero_bits;
1907 value_range_type range_type = get_range_info (node, &min, &max);
1909 if (range_type == VR_VARYING)
1910 pp_printf (buffer, "# RANGE VR_VARYING");
1911 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1913 pp_printf (buffer, "# RANGE ");
1914 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1915 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
1916 pp_printf (buffer, ", ");
1917 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
1918 pp_printf (buffer, "]");
1920 nonzero_bits = get_nonzero_bits (node);
1921 if (nonzero_bits != -1)
1923 pp_string (buffer, " NONZERO ");
1924 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
1926 newline_and_indent (buffer, spc);
1930 /* As dump_ssaname_info, but dump to FILE. */
1932 void
1933 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
1935 pretty_printer buffer;
1936 pp_needs_newline (&buffer) = true;
1937 buffer.buffer->stream = file;
1938 dump_ssaname_info (&buffer, node, spc);
1939 pp_flush (&buffer);
1942 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1943 The caller is responsible for calling pp_flush on BUFFER to finalize
1944 pretty printer. If COMMENT is true, print this after #. */
1946 static void
1947 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
1948 int flags)
1950 size_t i;
1951 tree lhs = gimple_phi_result (phi);
1953 if (flags & TDF_ALIAS)
1954 dump_ssaname_info (buffer, lhs, spc);
1956 if (comment)
1957 pp_string (buffer, "# ");
1959 if (flags & TDF_RAW)
1960 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1961 gimple_phi_result (phi));
1962 else
1964 dump_generic_node (buffer, lhs, spc, flags, false);
1965 pp_string (buffer, " = PHI <");
1967 for (i = 0; i < gimple_phi_num_args (phi); i++)
1969 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1970 dump_location (buffer, gimple_phi_arg_location (phi, i));
1971 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1972 false);
1973 pp_left_paren (buffer);
1974 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1975 pp_right_paren (buffer);
1976 if (i < gimple_phi_num_args (phi) - 1)
1977 pp_string (buffer, ", ");
1979 pp_greater (buffer);
1983 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1984 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1985 dumpfile.h). */
1987 static void
1988 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
1989 int spc, int flags)
1991 if (flags & TDF_RAW)
1993 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1994 gimple_omp_body (gs));
1995 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1996 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1997 gimple_omp_parallel_child_fn (gs),
1998 gimple_omp_parallel_data_arg (gs));
2000 else
2002 gimple_seq body;
2003 pp_string (buffer, "#pragma omp parallel");
2004 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2005 if (gimple_omp_parallel_child_fn (gs))
2007 pp_string (buffer, " [child fn: ");
2008 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2009 spc, flags, false);
2010 pp_string (buffer, " (");
2011 if (gimple_omp_parallel_data_arg (gs))
2012 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2013 spc, flags, false);
2014 else
2015 pp_string (buffer, "???");
2016 pp_string (buffer, ")]");
2018 body = gimple_omp_body (gs);
2019 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2021 newline_and_indent (buffer, spc + 2);
2022 pp_left_brace (buffer);
2023 pp_newline (buffer);
2024 dump_gimple_seq (buffer, body, spc + 4, flags);
2025 newline_and_indent (buffer, spc + 2);
2026 pp_right_brace (buffer);
2028 else if (body)
2030 pp_newline (buffer);
2031 dump_gimple_seq (buffer, body, spc + 2, flags);
2037 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2038 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2039 dumpfile.h). */
2041 static void
2042 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2043 int flags)
2045 if (flags & TDF_RAW)
2047 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2048 gimple_omp_body (gs));
2049 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2050 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2051 gimple_omp_task_child_fn (gs),
2052 gimple_omp_task_data_arg (gs),
2053 gimple_omp_task_copy_fn (gs),
2054 gimple_omp_task_arg_size (gs),
2055 gimple_omp_task_arg_size (gs));
2057 else
2059 gimple_seq body;
2060 if (gimple_omp_task_taskloop_p (gs))
2061 pp_string (buffer, "#pragma omp taskloop");
2062 else
2063 pp_string (buffer, "#pragma omp task");
2064 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2065 if (gimple_omp_task_child_fn (gs))
2067 pp_string (buffer, " [child fn: ");
2068 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2069 spc, flags, false);
2070 pp_string (buffer, " (");
2071 if (gimple_omp_task_data_arg (gs))
2072 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2073 spc, flags, false);
2074 else
2075 pp_string (buffer, "???");
2076 pp_string (buffer, ")]");
2078 body = gimple_omp_body (gs);
2079 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2081 newline_and_indent (buffer, spc + 2);
2082 pp_left_brace (buffer);
2083 pp_newline (buffer);
2084 dump_gimple_seq (buffer, body, spc + 4, flags);
2085 newline_and_indent (buffer, spc + 2);
2086 pp_right_brace (buffer);
2088 else if (body)
2090 pp_newline (buffer);
2091 dump_gimple_seq (buffer, body, spc + 2, flags);
2097 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2098 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2099 in dumpfile.h). */
2101 static void
2102 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2103 int spc, int flags)
2105 if (flags & TDF_RAW)
2107 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2108 gimple_omp_atomic_load_lhs (gs),
2109 gimple_omp_atomic_load_rhs (gs));
2111 else
2113 pp_string (buffer, "#pragma omp atomic_load");
2114 if (gimple_omp_atomic_seq_cst_p (gs))
2115 pp_string (buffer, " seq_cst");
2116 if (gimple_omp_atomic_need_value_p (gs))
2117 pp_string (buffer, " [needed]");
2118 newline_and_indent (buffer, spc + 2);
2119 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2120 spc, flags, false);
2121 pp_space (buffer);
2122 pp_equal (buffer);
2123 pp_space (buffer);
2124 pp_star (buffer);
2125 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2126 spc, flags, false);
2130 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2131 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2132 in dumpfile.h). */
2134 static void
2135 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2136 gomp_atomic_store *gs, int spc, int flags)
2138 if (flags & TDF_RAW)
2140 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2141 gimple_omp_atomic_store_val (gs));
2143 else
2145 pp_string (buffer, "#pragma omp atomic_store ");
2146 if (gimple_omp_atomic_seq_cst_p (gs))
2147 pp_string (buffer, "seq_cst ");
2148 if (gimple_omp_atomic_need_value_p (gs))
2149 pp_string (buffer, "[needed] ");
2150 pp_left_paren (buffer);
2151 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2152 spc, flags, false);
2153 pp_right_paren (buffer);
2158 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2159 FLAGS are as in pp_gimple_stmt_1. */
2161 static void
2162 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc, int flags)
2164 tree vdef = gimple_vdef (gs);
2165 tree vuse = gimple_vuse (gs);
2167 if (vdef != NULL_TREE)
2169 pp_string (buffer, "# ");
2170 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2171 pp_string (buffer, " = VDEF <");
2172 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2173 pp_greater (buffer);
2174 newline_and_indent (buffer, spc);
2176 else if (vuse != NULL_TREE)
2178 pp_string (buffer, "# VUSE <");
2179 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2180 pp_greater (buffer);
2181 newline_and_indent (buffer, spc);
2186 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2187 spaces of indent. FLAGS specifies details to show in the dump (see
2188 TDF_* in dumpfile.h). The caller is responsible for calling
2189 pp_flush on BUFFER to finalize the pretty printer. */
2191 void
2192 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
2194 if (!gs)
2195 return;
2197 if (flags & TDF_STMTADDR)
2198 pp_printf (buffer, "<&%p> ", (void *) gs);
2200 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2201 dump_location (buffer, gimple_location (gs));
2203 if (flags & TDF_EH)
2205 int lp_nr = lookup_stmt_eh_lp (gs);
2206 if (lp_nr > 0)
2207 pp_printf (buffer, "[LP %d] ", lp_nr);
2208 else if (lp_nr < 0)
2209 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2212 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2213 && gimple_has_mem_ops (gs))
2214 dump_gimple_mem_ops (buffer, gs, spc, flags);
2216 if (gimple_has_lhs (gs)
2217 && (flags & TDF_ALIAS))
2218 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2220 switch (gimple_code (gs))
2222 case GIMPLE_ASM:
2223 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2224 break;
2226 case GIMPLE_ASSIGN:
2227 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2228 break;
2230 case GIMPLE_BIND:
2231 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2232 break;
2234 case GIMPLE_CALL:
2235 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2236 break;
2238 case GIMPLE_COND:
2239 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2240 break;
2242 case GIMPLE_LABEL:
2243 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2244 break;
2246 case GIMPLE_GOTO:
2247 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2248 break;
2250 case GIMPLE_NOP:
2251 pp_string (buffer, "GIMPLE_NOP");
2252 break;
2254 case GIMPLE_RETURN:
2255 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2256 break;
2258 case GIMPLE_SWITCH:
2259 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2260 break;
2262 case GIMPLE_TRY:
2263 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2264 break;
2266 case GIMPLE_PHI:
2267 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2268 break;
2270 case GIMPLE_OMP_PARALLEL:
2271 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2272 flags);
2273 break;
2275 case GIMPLE_OMP_TASK:
2276 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2277 break;
2279 case GIMPLE_OMP_ATOMIC_LOAD:
2280 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2281 spc, flags);
2282 break;
2284 case GIMPLE_OMP_ATOMIC_STORE:
2285 dump_gimple_omp_atomic_store (buffer,
2286 as_a <gomp_atomic_store *> (gs),
2287 spc, flags);
2288 break;
2290 case GIMPLE_OMP_FOR:
2291 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2292 break;
2294 case GIMPLE_OMP_CONTINUE:
2295 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2296 flags);
2297 break;
2299 case GIMPLE_OMP_SINGLE:
2300 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2301 flags);
2302 break;
2304 case GIMPLE_OMP_TARGET:
2305 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2306 flags);
2307 break;
2309 case GIMPLE_OMP_TEAMS:
2310 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2311 flags);
2312 break;
2314 case GIMPLE_OMP_RETURN:
2315 dump_gimple_omp_return (buffer, gs, spc, flags);
2316 break;
2318 case GIMPLE_OMP_SECTIONS:
2319 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2320 spc, flags);
2321 break;
2323 case GIMPLE_OMP_SECTIONS_SWITCH:
2324 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2325 break;
2327 case GIMPLE_OMP_MASTER:
2328 case GIMPLE_OMP_TASKGROUP:
2329 case GIMPLE_OMP_SECTION:
2330 case GIMPLE_OMP_GRID_BODY:
2331 dump_gimple_omp_block (buffer, gs, spc, flags);
2332 break;
2334 case GIMPLE_OMP_ORDERED:
2335 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2336 flags);
2337 break;
2339 case GIMPLE_OMP_CRITICAL:
2340 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2341 flags);
2342 break;
2344 case GIMPLE_CATCH:
2345 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2346 break;
2348 case GIMPLE_EH_FILTER:
2349 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2350 break;
2352 case GIMPLE_EH_MUST_NOT_THROW:
2353 dump_gimple_eh_must_not_throw (buffer,
2354 as_a <geh_mnt *> (gs),
2355 spc, flags);
2356 break;
2358 case GIMPLE_EH_ELSE:
2359 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2360 break;
2362 case GIMPLE_RESX:
2363 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2364 break;
2366 case GIMPLE_EH_DISPATCH:
2367 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2368 flags);
2369 break;
2371 case GIMPLE_DEBUG:
2372 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2373 break;
2375 case GIMPLE_PREDICT:
2376 pp_string (buffer, "// predicted ");
2377 if (gimple_predict_outcome (gs))
2378 pp_string (buffer, "likely by ");
2379 else
2380 pp_string (buffer, "unlikely by ");
2381 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2382 pp_string (buffer, " predictor.");
2383 break;
2385 case GIMPLE_TRANSACTION:
2386 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2387 flags);
2388 break;
2390 default:
2391 GIMPLE_NIY;
2396 /* Dumps header of basic block BB to OUTF indented by INDENT
2397 spaces and details described by flags. */
2399 static void
2400 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2402 if (flags & TDF_BLOCKS)
2404 if (flags & TDF_LINENO)
2406 gimple_stmt_iterator gsi;
2408 if (flags & TDF_COMMENT)
2409 fputs (";; ", outf);
2411 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2412 if (!is_gimple_debug (gsi_stmt (gsi))
2413 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2415 fprintf (outf, "%*sstarting at line %d",
2416 indent, "", get_lineno (gsi_stmt (gsi)));
2417 break;
2419 if (bb->discriminator)
2420 fprintf (outf, ", discriminator %i", bb->discriminator);
2421 fputc ('\n', outf);
2424 else
2426 gimple *stmt = first_stmt (bb);
2427 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2428 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2433 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2434 spaces. */
2436 static void
2437 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2438 basic_block bb ATTRIBUTE_UNUSED,
2439 int indent ATTRIBUTE_UNUSED,
2440 int flags ATTRIBUTE_UNUSED)
2442 /* There is currently no GIMPLE-specific basic block info to dump. */
2443 return;
2447 /* Dump PHI nodes of basic block BB to BUFFER with details described
2448 by FLAGS and indented by INDENT spaces. */
2450 static void
2451 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2453 gphi_iterator i;
2455 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2457 gphi *phi = i.phi ();
2458 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2460 INDENT (indent);
2461 dump_gimple_phi (buffer, phi, indent, true, flags);
2462 pp_newline (buffer);
2468 /* Dump jump to basic block BB that is represented implicitly in the cfg
2469 to BUFFER. */
2471 static void
2472 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2474 gimple *stmt;
2476 stmt = first_stmt (bb);
2478 pp_string (buffer, "goto <bb ");
2479 pp_decimal_int (buffer, bb->index);
2480 pp_greater (buffer);
2481 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2483 pp_string (buffer, " (");
2484 dump_generic_node (buffer,
2485 gimple_label_label (as_a <glabel *> (stmt)),
2486 0, 0, false);
2487 pp_right_paren (buffer);
2488 pp_semicolon (buffer);
2490 else
2491 pp_semicolon (buffer);
2495 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2496 by INDENT spaces, with details given by FLAGS. */
2498 static void
2499 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2500 int flags)
2502 edge e;
2503 gimple *stmt;
2505 stmt = last_stmt (bb);
2507 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2509 edge true_edge, false_edge;
2511 /* When we are emitting the code or changing CFG, it is possible that
2512 the edges are not yet created. When we are using debug_bb in such
2513 a situation, we do not want it to crash. */
2514 if (EDGE_COUNT (bb->succs) != 2)
2515 return;
2516 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2518 INDENT (indent + 2);
2519 pp_cfg_jump (buffer, true_edge->dest);
2520 newline_and_indent (buffer, indent);
2521 pp_string (buffer, "else");
2522 newline_and_indent (buffer, indent + 2);
2523 pp_cfg_jump (buffer, false_edge->dest);
2524 pp_newline (buffer);
2525 return;
2528 /* If there is a fallthru edge, we may need to add an artificial
2529 goto to the dump. */
2530 e = find_fallthru_edge (bb->succs);
2532 if (e && e->dest != bb->next_bb)
2534 INDENT (indent);
2536 if ((flags & TDF_LINENO)
2537 && e->goto_locus != UNKNOWN_LOCATION)
2538 dump_location (buffer, e->goto_locus);
2540 pp_cfg_jump (buffer, e->dest);
2541 pp_newline (buffer);
2546 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2547 indented by INDENT spaces. */
2549 static void
2550 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2551 int flags)
2553 gimple_stmt_iterator gsi;
2554 gimple *stmt;
2555 int label_indent = indent - 2;
2557 if (label_indent < 0)
2558 label_indent = 0;
2560 dump_phi_nodes (buffer, bb, indent, flags);
2562 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2564 int curr_indent;
2566 stmt = gsi_stmt (gsi);
2568 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2570 INDENT (curr_indent);
2571 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2572 pp_newline_and_flush (buffer);
2573 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2574 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2575 pp_buffer (buffer)->stream, stmt);
2578 dump_implicit_edges (buffer, bb, indent, flags);
2579 pp_flush (buffer);
2583 /* Dumps basic block BB to FILE with details described by FLAGS and
2584 indented by INDENT spaces. */
2586 void
2587 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2589 dump_gimple_bb_header (file, bb, indent, flags);
2590 if (bb->index >= NUM_FIXED_BLOCKS)
2592 pretty_printer buffer;
2593 pp_needs_newline (&buffer) = true;
2594 buffer.buffer->stream = file;
2595 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2597 dump_gimple_bb_footer (file, bb, indent, flags);
2600 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2601 no indentation, for use as a label of a DOT graph record-node.
2602 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2603 histogram dumping doesn't know about pretty-printers. */
2605 void
2606 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2608 pp_printf (pp, "<bb %d>:\n", bb->index);
2609 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2611 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2612 gsi_next (&gsi))
2614 gphi *phi = gsi.phi ();
2615 if (!virtual_operand_p (gimple_phi_result (phi))
2616 || (dump_flags & TDF_VOPS))
2618 pp_bar (pp);
2619 pp_write_text_to_stream (pp);
2620 pp_string (pp, "# ");
2621 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2622 pp_newline (pp);
2623 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2627 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2628 gsi_next (&gsi))
2630 gimple *stmt = gsi_stmt (gsi);
2631 pp_bar (pp);
2632 pp_write_text_to_stream (pp);
2633 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2634 pp_newline (pp);
2635 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2637 dump_implicit_edges (pp, bb, 0, dump_flags);
2638 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);