Fix for ICE with -g on testcase with incomplete types.
[official-gcc.git] / gcc / gimple-pretty-print.c
blob9780220c47d47f0226cc8ded2b4e2566093a7178
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 "backend.h"
26 #include "tree.h"
27 #include "gimple.h"
28 #include "gimple-predict.h"
29 #include "hard-reg-set.h"
30 #include "ssa.h"
31 #include "alias.h"
32 #include "fold-const.h"
33 #include "diagnostic.h"
34 #include "gimple-pretty-print.h"
35 #include "internal-fn.h"
36 #include "tree-eh.h"
37 #include "gimple-iterator.h"
38 #include "cgraph.h"
39 #include "tree-cfg.h"
40 #include "dumpfile.h" /* for dump_flags */
41 #include "value-prof.h"
42 #include "trans-mem.h"
44 #define INDENT(SPACE) \
45 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
47 #define GIMPLE_NIY do_niy (buffer,gs)
49 /* Try to print on BUFFER a default message for the unrecognized
50 gimple statement GS. */
52 static void
53 do_niy (pretty_printer *buffer, gimple *gs)
55 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
56 gimple_code_name[(int) gimple_code (gs)]);
60 /* Emit a newline and SPC indentation spaces to BUFFER. */
62 static void
63 newline_and_indent (pretty_printer *buffer, int spc)
65 pp_newline (buffer);
66 INDENT (spc);
70 /* Print the GIMPLE statement GS on stderr. */
72 DEBUG_FUNCTION void
73 debug_gimple_stmt (gimple *gs)
75 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
79 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
80 FLAGS as in pp_gimple_stmt_1. */
82 void
83 print_gimple_stmt (FILE *file, gimple *g, int spc, int flags)
85 pretty_printer buffer;
86 pp_needs_newline (&buffer) = true;
87 buffer.buffer->stream = file;
88 pp_gimple_stmt_1 (&buffer, g, spc, flags);
89 pp_newline_and_flush (&buffer);
92 DEBUG_FUNCTION void
93 debug (gimple &ref)
95 print_gimple_stmt (stderr, &ref, 0, 0);
98 DEBUG_FUNCTION void
99 debug (gimple *ptr)
101 if (ptr)
102 debug (*ptr);
103 else
104 fprintf (stderr, "<nil>\n");
108 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
109 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
110 of the statement. */
112 void
113 print_gimple_expr (FILE *file, gimple *g, int spc, int flags)
115 flags |= TDF_RHS_ONLY;
116 pretty_printer buffer;
117 pp_needs_newline (&buffer) = true;
118 buffer.buffer->stream = file;
119 pp_gimple_stmt_1 (&buffer, g, spc, flags);
120 pp_flush (&buffer);
124 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
125 spaces and FLAGS as in pp_gimple_stmt_1.
126 The caller is responsible for calling pp_flush on BUFFER to finalize
127 the pretty printer. */
129 static void
130 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
132 gimple_stmt_iterator i;
134 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
136 gimple *gs = gsi_stmt (i);
137 INDENT (spc);
138 pp_gimple_stmt_1 (buffer, gs, spc, flags);
139 if (!gsi_one_before_end_p (i))
140 pp_newline (buffer);
145 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
146 FLAGS as in pp_gimple_stmt_1. */
148 void
149 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
151 pretty_printer buffer;
152 pp_needs_newline (&buffer) = true;
153 buffer.buffer->stream = file;
154 dump_gimple_seq (&buffer, seq, spc, flags);
155 pp_newline_and_flush (&buffer);
159 /* Print the GIMPLE sequence SEQ on stderr. */
161 DEBUG_FUNCTION void
162 debug_gimple_seq (gimple_seq seq)
164 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
168 /* A simple helper to pretty-print some of the gimple tuples in the printf
169 style. The format modifiers are preceded by '%' and are:
170 'G' - outputs a string corresponding to the code of the given gimple,
171 'S' - outputs a gimple_seq with indent of spc + 2,
172 'T' - outputs the tree t,
173 'd' - outputs an int as a decimal,
174 's' - outputs a string,
175 'n' - outputs a newline,
176 'x' - outputs an int as hexadecimal,
177 '+' - increases indent by 2 then outputs a newline,
178 '-' - decreases indent by 2 then outputs a newline. */
180 static void
181 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
182 const char *fmt, ...)
184 va_list args;
185 const char *c;
186 const char *tmp;
188 va_start (args, fmt);
189 for (c = fmt; *c; c++)
191 if (*c == '%')
193 gimple_seq seq;
194 tree t;
195 gimple *g;
196 switch (*++c)
198 case 'G':
199 g = va_arg (args, gimple *);
200 tmp = gimple_code_name[gimple_code (g)];
201 pp_string (buffer, tmp);
202 break;
204 case 'S':
205 seq = va_arg (args, gimple_seq);
206 pp_newline (buffer);
207 dump_gimple_seq (buffer, seq, spc + 2, flags);
208 newline_and_indent (buffer, spc);
209 break;
211 case 'T':
212 t = va_arg (args, tree);
213 if (t == NULL_TREE)
214 pp_string (buffer, "NULL");
215 else
216 dump_generic_node (buffer, t, spc, flags, false);
217 break;
219 case 'd':
220 pp_decimal_int (buffer, va_arg (args, int));
221 break;
223 case 's':
224 pp_string (buffer, va_arg (args, char *));
225 break;
227 case 'n':
228 newline_and_indent (buffer, spc);
229 break;
231 case 'x':
232 pp_scalar (buffer, "%x", va_arg (args, int));
233 break;
235 case '+':
236 spc += 2;
237 newline_and_indent (buffer, spc);
238 break;
240 case '-':
241 spc -= 2;
242 newline_and_indent (buffer, spc);
243 break;
245 default:
246 gcc_unreachable ();
249 else
250 pp_character (buffer, *c);
252 va_end (args);
256 /* Helper for dump_gimple_assign. Print the unary RHS of the
257 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
259 static void
260 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
262 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
263 tree lhs = gimple_assign_lhs (gs);
264 tree rhs = gimple_assign_rhs1 (gs);
266 switch (rhs_code)
268 case VIEW_CONVERT_EXPR:
269 case ASSERT_EXPR:
270 dump_generic_node (buffer, rhs, spc, flags, false);
271 break;
273 case FIXED_CONVERT_EXPR:
274 case ADDR_SPACE_CONVERT_EXPR:
275 case FIX_TRUNC_EXPR:
276 case FLOAT_EXPR:
277 CASE_CONVERT:
278 pp_left_paren (buffer);
279 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
280 pp_string (buffer, ") ");
281 if (op_prio (rhs) < op_code_prio (rhs_code))
283 pp_left_paren (buffer);
284 dump_generic_node (buffer, rhs, spc, flags, false);
285 pp_right_paren (buffer);
287 else
288 dump_generic_node (buffer, rhs, spc, flags, false);
289 break;
291 case PAREN_EXPR:
292 pp_string (buffer, "((");
293 dump_generic_node (buffer, rhs, spc, flags, false);
294 pp_string (buffer, "))");
295 break;
297 case ABS_EXPR:
298 pp_string (buffer, "ABS_EXPR <");
299 dump_generic_node (buffer, rhs, spc, flags, false);
300 pp_greater (buffer);
301 break;
303 default:
304 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
305 || TREE_CODE_CLASS (rhs_code) == tcc_constant
306 || TREE_CODE_CLASS (rhs_code) == tcc_reference
307 || rhs_code == SSA_NAME
308 || rhs_code == ADDR_EXPR
309 || rhs_code == CONSTRUCTOR)
311 dump_generic_node (buffer, rhs, spc, flags, false);
312 break;
314 else if (rhs_code == BIT_NOT_EXPR)
315 pp_complement (buffer);
316 else if (rhs_code == TRUTH_NOT_EXPR)
317 pp_exclamation (buffer);
318 else if (rhs_code == NEGATE_EXPR)
319 pp_minus (buffer);
320 else
322 pp_left_bracket (buffer);
323 pp_string (buffer, get_tree_code_name (rhs_code));
324 pp_string (buffer, "] ");
327 if (op_prio (rhs) < op_code_prio (rhs_code))
329 pp_left_paren (buffer);
330 dump_generic_node (buffer, rhs, spc, flags, false);
331 pp_right_paren (buffer);
333 else
334 dump_generic_node (buffer, rhs, spc, flags, false);
335 break;
340 /* Helper for dump_gimple_assign. Print the binary RHS of the
341 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
343 static void
344 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
346 const char *p;
347 enum tree_code code = gimple_assign_rhs_code (gs);
348 switch (code)
350 case COMPLEX_EXPR:
351 case MIN_EXPR:
352 case MAX_EXPR:
353 case VEC_WIDEN_MULT_HI_EXPR:
354 case VEC_WIDEN_MULT_LO_EXPR:
355 case VEC_WIDEN_MULT_EVEN_EXPR:
356 case VEC_WIDEN_MULT_ODD_EXPR:
357 case VEC_PACK_TRUNC_EXPR:
358 case VEC_PACK_SAT_EXPR:
359 case VEC_PACK_FIX_TRUNC_EXPR:
360 case VEC_WIDEN_LSHIFT_HI_EXPR:
361 case VEC_WIDEN_LSHIFT_LO_EXPR:
362 for (p = get_tree_code_name (code); *p; p++)
363 pp_character (buffer, TOUPPER (*p));
364 pp_string (buffer, " <");
365 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
366 pp_string (buffer, ", ");
367 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
368 pp_greater (buffer);
369 break;
371 default:
372 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
374 pp_left_paren (buffer);
375 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
376 false);
377 pp_right_paren (buffer);
379 else
380 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
381 pp_space (buffer);
382 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
383 pp_space (buffer);
384 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
386 pp_left_paren (buffer);
387 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
388 false);
389 pp_right_paren (buffer);
391 else
392 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
396 /* Helper for dump_gimple_assign. Print the ternary RHS of the
397 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
399 static void
400 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
402 const char *p;
403 enum tree_code code = gimple_assign_rhs_code (gs);
404 switch (code)
406 case WIDEN_MULT_PLUS_EXPR:
407 case WIDEN_MULT_MINUS_EXPR:
408 for (p = get_tree_code_name (code); *p; p++)
409 pp_character (buffer, TOUPPER (*p));
410 pp_string (buffer, " <");
411 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
412 pp_string (buffer, ", ");
413 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
414 pp_string (buffer, ", ");
415 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
416 pp_greater (buffer);
417 break;
419 case FMA_EXPR:
420 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
421 pp_string (buffer, " * ");
422 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
423 pp_string (buffer, " + ");
424 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
425 break;
427 case DOT_PROD_EXPR:
428 pp_string (buffer, "DOT_PROD_EXPR <");
429 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
430 pp_string (buffer, ", ");
431 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
432 pp_string (buffer, ", ");
433 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
434 pp_greater (buffer);
435 break;
437 case SAD_EXPR:
438 pp_string (buffer, "SAD_EXPR <");
439 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
440 pp_string (buffer, ", ");
441 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
442 pp_string (buffer, ", ");
443 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
444 pp_greater (buffer);
445 break;
447 case VEC_PERM_EXPR:
448 pp_string (buffer, "VEC_PERM_EXPR <");
449 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
450 pp_string (buffer, ", ");
451 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
452 pp_string (buffer, ", ");
453 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
454 pp_greater (buffer);
455 break;
457 case REALIGN_LOAD_EXPR:
458 pp_string (buffer, "REALIGN_LOAD <");
459 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
460 pp_string (buffer, ", ");
461 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
462 pp_string (buffer, ", ");
463 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
464 pp_greater (buffer);
465 break;
467 case COND_EXPR:
468 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
469 pp_string (buffer, " ? ");
470 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
471 pp_string (buffer, " : ");
472 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
473 break;
475 case VEC_COND_EXPR:
476 pp_string (buffer, "VEC_COND_EXPR <");
477 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
478 pp_string (buffer, ", ");
479 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
480 pp_string (buffer, ", ");
481 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
482 pp_greater (buffer);
483 break;
485 default:
486 gcc_unreachable ();
491 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
492 pp_gimple_stmt_1. */
494 static void
495 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
497 if (flags & TDF_RAW)
499 tree arg1 = NULL;
500 tree arg2 = NULL;
501 tree arg3 = NULL;
502 switch (gimple_num_ops (gs))
504 case 4:
505 arg3 = gimple_assign_rhs3 (gs);
506 case 3:
507 arg2 = gimple_assign_rhs2 (gs);
508 case 2:
509 arg1 = gimple_assign_rhs1 (gs);
510 break;
511 default:
512 gcc_unreachable ();
515 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
516 get_tree_code_name (gimple_assign_rhs_code (gs)),
517 gimple_assign_lhs (gs), arg1, arg2, arg3);
519 else
521 if (!(flags & TDF_RHS_ONLY))
523 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
524 pp_space (buffer);
525 pp_equal (buffer);
527 if (gimple_assign_nontemporal_move_p (gs))
528 pp_string (buffer, "{nt}");
530 if (gimple_has_volatile_ops (gs))
531 pp_string (buffer, "{v}");
533 pp_space (buffer);
536 if (gimple_num_ops (gs) == 2)
537 dump_unary_rhs (buffer, gs, spc, flags);
538 else if (gimple_num_ops (gs) == 3)
539 dump_binary_rhs (buffer, gs, spc, flags);
540 else if (gimple_num_ops (gs) == 4)
541 dump_ternary_rhs (buffer, gs, spc, flags);
542 else
543 gcc_unreachable ();
544 if (!(flags & TDF_RHS_ONLY))
545 pp_semicolon (buffer);
550 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
551 pp_gimple_stmt_1. */
553 static void
554 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
556 tree t, t2;
558 t = gimple_return_retval (gs);
559 t2 = gimple_return_retbnd (gs);
560 if (flags & TDF_RAW)
561 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
562 else
564 pp_string (buffer, "return");
565 if (t)
567 pp_space (buffer);
568 dump_generic_node (buffer, t, spc, flags, false);
570 if (t2)
572 pp_string (buffer, ", ");
573 dump_generic_node (buffer, t2, spc, flags, false);
575 pp_semicolon (buffer);
580 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
581 dump_gimple_call. */
583 static void
584 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
586 size_t i;
588 for (i = 0; i < gimple_call_num_args (gs); i++)
590 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
591 if (i < gimple_call_num_args (gs) - 1)
592 pp_string (buffer, ", ");
595 if (gimple_call_va_arg_pack_p (gs))
597 if (gimple_call_num_args (gs) > 0)
599 pp_comma (buffer);
600 pp_space (buffer);
603 pp_string (buffer, "__builtin_va_arg_pack ()");
607 /* Dump the points-to solution *PT to BUFFER. */
609 static void
610 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
612 if (pt->anything)
614 pp_string (buffer, "anything ");
615 return;
617 if (pt->nonlocal)
618 pp_string (buffer, "nonlocal ");
619 if (pt->escaped)
620 pp_string (buffer, "escaped ");
621 if (pt->ipa_escaped)
622 pp_string (buffer, "unit-escaped ");
623 if (pt->null)
624 pp_string (buffer, "null ");
625 if (pt->vars
626 && !bitmap_empty_p (pt->vars))
628 bitmap_iterator bi;
629 unsigned i;
630 pp_string (buffer, "{ ");
631 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
633 pp_string (buffer, "D.");
634 pp_decimal_int (buffer, i);
635 pp_space (buffer);
637 pp_right_brace (buffer);
638 if (pt->vars_contains_nonlocal
639 && pt->vars_contains_escaped_heap)
640 pp_string (buffer, " (nonlocal, escaped heap)");
641 else if (pt->vars_contains_nonlocal
642 && pt->vars_contains_escaped)
643 pp_string (buffer, " (nonlocal, escaped)");
644 else if (pt->vars_contains_nonlocal)
645 pp_string (buffer, " (nonlocal)");
646 else if (pt->vars_contains_escaped_heap)
647 pp_string (buffer, " (escaped heap)");
648 else if (pt->vars_contains_escaped)
649 pp_string (buffer, " (escaped)");
653 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
654 pp_gimple_stmt_1. */
656 static void
657 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
659 tree lhs = gimple_call_lhs (gs);
660 tree fn = gimple_call_fn (gs);
662 if (flags & TDF_ALIAS)
664 struct pt_solution *pt;
665 pt = gimple_call_use_set (gs);
666 if (!pt_solution_empty_p (pt))
668 pp_string (buffer, "# USE = ");
669 pp_points_to_solution (buffer, pt);
670 newline_and_indent (buffer, spc);
672 pt = gimple_call_clobber_set (gs);
673 if (!pt_solution_empty_p (pt))
675 pp_string (buffer, "# CLB = ");
676 pp_points_to_solution (buffer, pt);
677 newline_and_indent (buffer, spc);
681 if (flags & TDF_RAW)
683 if (gimple_call_internal_p (gs))
684 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
685 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
686 else
687 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
688 if (gimple_call_num_args (gs) > 0)
690 pp_string (buffer, ", ");
691 dump_gimple_call_args (buffer, gs, flags);
693 pp_greater (buffer);
695 else
697 if (lhs && !(flags & TDF_RHS_ONLY))
699 dump_generic_node (buffer, lhs, spc, flags, false);
700 pp_string (buffer, " =");
702 if (gimple_has_volatile_ops (gs))
703 pp_string (buffer, "{v}");
705 pp_space (buffer);
707 if (gimple_call_internal_p (gs))
708 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
709 else
710 print_call_name (buffer, fn, flags);
711 pp_string (buffer, " (");
712 dump_gimple_call_args (buffer, gs, flags);
713 pp_right_paren (buffer);
714 if (!(flags & TDF_RHS_ONLY))
715 pp_semicolon (buffer);
718 if (gimple_call_chain (gs))
720 pp_string (buffer, " [static-chain: ");
721 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
722 pp_right_bracket (buffer);
725 if (gimple_call_return_slot_opt_p (gs))
726 pp_string (buffer, " [return slot optimization]");
727 if (gimple_call_tail_p (gs))
728 pp_string (buffer, " [tail call]");
730 if (fn == NULL)
731 return;
733 /* Dump the arguments of _ITM_beginTransaction sanely. */
734 if (TREE_CODE (fn) == ADDR_EXPR)
735 fn = TREE_OPERAND (fn, 0);
736 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
737 pp_string (buffer, " [tm-clone]");
738 if (TREE_CODE (fn) == FUNCTION_DECL
739 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
740 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
741 && gimple_call_num_args (gs) > 0)
743 tree t = gimple_call_arg (gs, 0);
744 unsigned HOST_WIDE_INT props;
745 gcc_assert (TREE_CODE (t) == INTEGER_CST);
747 pp_string (buffer, " [ ");
749 /* Get the transaction code properties. */
750 props = TREE_INT_CST_LOW (t);
752 if (props & PR_INSTRUMENTEDCODE)
753 pp_string (buffer, "instrumentedCode ");
754 if (props & PR_UNINSTRUMENTEDCODE)
755 pp_string (buffer, "uninstrumentedCode ");
756 if (props & PR_HASNOXMMUPDATE)
757 pp_string (buffer, "hasNoXMMUpdate ");
758 if (props & PR_HASNOABORT)
759 pp_string (buffer, "hasNoAbort ");
760 if (props & PR_HASNOIRREVOCABLE)
761 pp_string (buffer, "hasNoIrrevocable ");
762 if (props & PR_DOESGOIRREVOCABLE)
763 pp_string (buffer, "doesGoIrrevocable ");
764 if (props & PR_HASNOSIMPLEREADS)
765 pp_string (buffer, "hasNoSimpleReads ");
766 if (props & PR_AWBARRIERSOMITTED)
767 pp_string (buffer, "awBarriersOmitted ");
768 if (props & PR_RARBARRIERSOMITTED)
769 pp_string (buffer, "RaRBarriersOmitted ");
770 if (props & PR_UNDOLOGCODE)
771 pp_string (buffer, "undoLogCode ");
772 if (props & PR_PREFERUNINSTRUMENTED)
773 pp_string (buffer, "preferUninstrumented ");
774 if (props & PR_EXCEPTIONBLOCK)
775 pp_string (buffer, "exceptionBlock ");
776 if (props & PR_HASELSE)
777 pp_string (buffer, "hasElse ");
778 if (props & PR_READONLY)
779 pp_string (buffer, "readOnly ");
781 pp_right_bracket (buffer);
786 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
787 pp_gimple_stmt_1. */
789 static void
790 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
791 int flags)
793 unsigned int i;
795 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
796 if (flags & TDF_RAW)
797 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
798 gimple_switch_index (gs));
799 else
801 pp_string (buffer, "switch (");
802 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
803 pp_string (buffer, ") <");
806 for (i = 0; i < gimple_switch_num_labels (gs); i++)
808 tree case_label = gimple_switch_label (gs, i);
809 gcc_checking_assert (case_label != NULL_TREE);
810 dump_generic_node (buffer, case_label, spc, flags, false);
811 pp_space (buffer);
812 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
813 if (i < gimple_switch_num_labels (gs) - 1)
814 pp_string (buffer, ", ");
816 pp_greater (buffer);
820 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
821 pp_gimple_stmt_1. */
823 static void
824 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
826 if (flags & TDF_RAW)
827 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
828 get_tree_code_name (gimple_cond_code (gs)),
829 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
830 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
831 else
833 if (!(flags & TDF_RHS_ONLY))
834 pp_string (buffer, "if (");
835 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
836 pp_space (buffer);
837 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
838 pp_space (buffer);
839 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
840 if (!(flags & TDF_RHS_ONLY))
842 pp_right_paren (buffer);
844 if (gimple_cond_true_label (gs))
846 pp_string (buffer, " goto ");
847 dump_generic_node (buffer, gimple_cond_true_label (gs),
848 spc, flags, false);
849 pp_semicolon (buffer);
851 if (gimple_cond_false_label (gs))
853 pp_string (buffer, " else goto ");
854 dump_generic_node (buffer, gimple_cond_false_label (gs),
855 spc, flags, false);
856 pp_semicolon (buffer);
863 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
864 spaces of indent. FLAGS specifies details to show in the dump (see
865 TDF_* in dumpfils.h). */
867 static void
868 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
870 tree label = gimple_label_label (gs);
871 if (flags & TDF_RAW)
872 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
873 else
875 dump_generic_node (buffer, label, spc, flags, false);
876 pp_colon (buffer);
878 if (DECL_NONLOCAL (label))
879 pp_string (buffer, " [non-local]");
880 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
881 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
884 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
885 spaces of indent. FLAGS specifies details to show in the dump (see
886 TDF_* in dumpfile.h). */
888 static void
889 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
891 tree label = gimple_goto_dest (gs);
892 if (flags & TDF_RAW)
893 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
894 else
895 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
899 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
900 spaces of indent. FLAGS specifies details to show in the dump (see
901 TDF_* in dumpfile.h). */
903 static void
904 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
906 if (flags & TDF_RAW)
907 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
908 else
909 pp_left_brace (buffer);
910 if (!(flags & TDF_SLIM))
912 tree var;
914 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
916 newline_and_indent (buffer, 2);
917 print_declaration (buffer, var, spc, flags);
919 if (gimple_bind_vars (gs))
920 pp_newline (buffer);
922 pp_newline (buffer);
923 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
924 newline_and_indent (buffer, spc);
925 if (flags & TDF_RAW)
926 pp_greater (buffer);
927 else
928 pp_right_brace (buffer);
932 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
933 indent. FLAGS specifies details to show in the dump (see TDF_* in
934 dumpfile.h). */
936 static void
937 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
939 if (flags & TDF_RAW)
941 const char *type;
942 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
943 type = "GIMPLE_TRY_CATCH";
944 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
945 type = "GIMPLE_TRY_FINALLY";
946 else
947 type = "UNKNOWN GIMPLE_TRY";
948 dump_gimple_fmt (buffer, spc, flags,
949 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
950 gimple_try_eval (gs), gimple_try_cleanup (gs));
952 else
954 pp_string (buffer, "try");
955 newline_and_indent (buffer, spc + 2);
956 pp_left_brace (buffer);
957 pp_newline (buffer);
959 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
960 newline_and_indent (buffer, spc + 2);
961 pp_right_brace (buffer);
963 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
965 newline_and_indent (buffer, spc);
966 pp_string (buffer, "catch");
967 newline_and_indent (buffer, spc + 2);
968 pp_left_brace (buffer);
970 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
972 newline_and_indent (buffer, spc);
973 pp_string (buffer, "finally");
974 newline_and_indent (buffer, spc + 2);
975 pp_left_brace (buffer);
977 else
978 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
980 pp_newline (buffer);
981 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
982 newline_and_indent (buffer, spc + 2);
983 pp_right_brace (buffer);
988 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
989 indent. FLAGS specifies details to show in the dump (see TDF_* in
990 dumpfile.h). */
992 static void
993 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
995 if (flags & TDF_RAW)
996 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
997 gimple_catch_types (gs), gimple_catch_handler (gs));
998 else
999 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1000 gimple_catch_types (gs), gimple_catch_handler (gs));
1004 /* Dump a GIMPLE_EH_FILTER 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_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1010 int flags)
1012 if (flags & TDF_RAW)
1013 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1014 gimple_eh_filter_types (gs),
1015 gimple_eh_filter_failure (gs));
1016 else
1017 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1018 gimple_eh_filter_types (gs),
1019 gimple_eh_filter_failure (gs));
1023 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1025 static void
1026 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1027 geh_mnt *gs, int spc, int flags)
1029 if (flags & TDF_RAW)
1030 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1031 gimple_eh_must_not_throw_fndecl (gs));
1032 else
1033 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1034 gimple_eh_must_not_throw_fndecl (gs));
1038 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1039 indent. FLAGS specifies details to show in the dump (see TDF_* in
1040 dumpfile.h). */
1042 static void
1043 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1044 int flags)
1046 if (flags & TDF_RAW)
1047 dump_gimple_fmt (buffer, spc, flags,
1048 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1049 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1050 else
1051 dump_gimple_fmt (buffer, spc, flags,
1052 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1053 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1057 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1058 indent. FLAGS specifies details to show in the dump (see TDF_* in
1059 dumpfile.h). */
1061 static void
1062 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
1064 if (flags & TDF_RAW)
1065 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1066 gimple_resx_region (gs));
1067 else
1068 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1071 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1073 static void
1074 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int flags)
1076 if (flags & TDF_RAW)
1077 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1078 gimple_eh_dispatch_region (gs));
1079 else
1080 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1081 gimple_eh_dispatch_region (gs));
1084 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1085 of indent. FLAGS specifies details to show in the dump (see TDF_*
1086 in dumpfile.h). */
1088 static void
1089 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
1091 switch (gs->subcode)
1093 case GIMPLE_DEBUG_BIND:
1094 if (flags & TDF_RAW)
1095 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1096 gimple_debug_bind_get_var (gs),
1097 gimple_debug_bind_get_value (gs));
1098 else
1099 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1100 gimple_debug_bind_get_var (gs),
1101 gimple_debug_bind_get_value (gs));
1102 break;
1104 case GIMPLE_DEBUG_SOURCE_BIND:
1105 if (flags & TDF_RAW)
1106 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1107 gimple_debug_source_bind_get_var (gs),
1108 gimple_debug_source_bind_get_value (gs));
1109 else
1110 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1111 gimple_debug_source_bind_get_var (gs),
1112 gimple_debug_source_bind_get_value (gs));
1113 break;
1115 default:
1116 gcc_unreachable ();
1120 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1121 static void
1122 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
1124 size_t i;
1126 if (flags & TDF_RAW)
1128 const char *kind;
1129 switch (gimple_omp_for_kind (gs))
1131 case GF_OMP_FOR_KIND_FOR:
1132 kind = "";
1133 break;
1134 case GF_OMP_FOR_KIND_DISTRIBUTE:
1135 kind = " distribute";
1136 break;
1137 case GF_OMP_FOR_KIND_TASKLOOP:
1138 kind = " taskloop";
1139 break;
1140 case GF_OMP_FOR_KIND_CILKFOR:
1141 kind = " _Cilk_for";
1142 break;
1143 case GF_OMP_FOR_KIND_OACC_LOOP:
1144 kind = " oacc_loop";
1145 break;
1146 case GF_OMP_FOR_KIND_SIMD:
1147 kind = " simd";
1148 break;
1149 case GF_OMP_FOR_KIND_CILKSIMD:
1150 kind = " cilksimd";
1151 break;
1152 default:
1153 gcc_unreachable ();
1155 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1156 kind, gimple_omp_body (gs));
1157 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1158 dump_gimple_fmt (buffer, spc, flags, " >,");
1159 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1160 dump_gimple_fmt (buffer, spc, flags,
1161 "%+%T, %T, %T, %s, %T,%n",
1162 gimple_omp_for_index (gs, i),
1163 gimple_omp_for_initial (gs, i),
1164 gimple_omp_for_final (gs, i),
1165 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1166 gimple_omp_for_incr (gs, i));
1167 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1168 gimple_omp_for_pre_body (gs));
1170 else
1172 switch (gimple_omp_for_kind (gs))
1174 case GF_OMP_FOR_KIND_FOR:
1175 pp_string (buffer, "#pragma omp for");
1176 break;
1177 case GF_OMP_FOR_KIND_DISTRIBUTE:
1178 pp_string (buffer, "#pragma omp distribute");
1179 break;
1180 case GF_OMP_FOR_KIND_TASKLOOP:
1181 pp_string (buffer, "#pragma omp taskloop");
1182 break;
1183 case GF_OMP_FOR_KIND_CILKFOR:
1184 break;
1185 case GF_OMP_FOR_KIND_OACC_LOOP:
1186 pp_string (buffer, "#pragma acc loop");
1187 break;
1188 case GF_OMP_FOR_KIND_SIMD:
1189 pp_string (buffer, "#pragma omp simd");
1190 break;
1191 case GF_OMP_FOR_KIND_CILKSIMD:
1192 pp_string (buffer, "#pragma simd");
1193 break;
1194 default:
1195 gcc_unreachable ();
1197 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1198 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1199 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1201 if (i)
1202 spc += 2;
1203 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1204 pp_string (buffer, "_Cilk_for (");
1205 else
1207 newline_and_indent (buffer, spc);
1208 pp_string (buffer, "for (");
1210 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1211 flags, false);
1212 pp_string (buffer, " = ");
1213 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1214 flags, false);
1215 pp_string (buffer, "; ");
1217 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1218 flags, false);
1219 pp_space (buffer);
1220 switch (gimple_omp_for_cond (gs, i))
1222 case LT_EXPR:
1223 pp_less (buffer);
1224 break;
1225 case GT_EXPR:
1226 pp_greater (buffer);
1227 break;
1228 case LE_EXPR:
1229 pp_less_equal (buffer);
1230 break;
1231 case GE_EXPR:
1232 pp_greater_equal (buffer);
1233 break;
1234 case NE_EXPR:
1235 pp_string (buffer, "!=");
1236 break;
1237 default:
1238 gcc_unreachable ();
1240 pp_space (buffer);
1241 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1242 flags, false);
1243 pp_string (buffer, "; ");
1245 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1246 flags, false);
1247 pp_string (buffer, " = ");
1248 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1249 flags, false);
1250 pp_right_paren (buffer);
1253 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1255 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1256 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1257 newline_and_indent (buffer, spc + 2);
1258 pp_left_brace (buffer);
1259 pp_newline (buffer);
1260 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1261 newline_and_indent (buffer, spc + 2);
1262 pp_right_brace (buffer);
1267 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1269 static void
1270 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1271 int spc, int flags)
1273 if (flags & TDF_RAW)
1275 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1276 gimple_omp_continue_control_def (gs),
1277 gimple_omp_continue_control_use (gs));
1279 else
1281 pp_string (buffer, "#pragma omp continue (");
1282 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1283 spc, flags, false);
1284 pp_comma (buffer);
1285 pp_space (buffer);
1286 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1287 spc, flags, false);
1288 pp_right_paren (buffer);
1292 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1294 static void
1295 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1296 int spc, int flags)
1298 if (flags & TDF_RAW)
1300 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1301 gimple_omp_body (gs));
1302 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1303 dump_gimple_fmt (buffer, spc, flags, " >");
1305 else
1307 pp_string (buffer, "#pragma omp single");
1308 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1309 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1311 newline_and_indent (buffer, spc + 2);
1312 pp_left_brace (buffer);
1313 pp_newline (buffer);
1314 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1315 newline_and_indent (buffer, spc + 2);
1316 pp_right_brace (buffer);
1321 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1323 static void
1324 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1325 int spc, int flags)
1327 const char *kind;
1328 switch (gimple_omp_target_kind (gs))
1330 case GF_OMP_TARGET_KIND_REGION:
1331 kind = "";
1332 break;
1333 case GF_OMP_TARGET_KIND_DATA:
1334 kind = " data";
1335 break;
1336 case GF_OMP_TARGET_KIND_UPDATE:
1337 kind = " update";
1338 break;
1339 case GF_OMP_TARGET_KIND_ENTER_DATA:
1340 kind = " enter data";
1341 break;
1342 case GF_OMP_TARGET_KIND_EXIT_DATA:
1343 kind = " exit data";
1344 break;
1345 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1346 kind = " oacc_kernels";
1347 break;
1348 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1349 kind = " oacc_parallel";
1350 break;
1351 case GF_OMP_TARGET_KIND_OACC_DATA:
1352 kind = " oacc_data";
1353 break;
1354 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1355 kind = " oacc_update";
1356 break;
1357 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1358 kind = " oacc_enter_exit_data";
1359 break;
1360 default:
1361 gcc_unreachable ();
1363 if (flags & TDF_RAW)
1365 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1366 kind, gimple_omp_body (gs));
1367 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1368 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1369 gimple_omp_target_child_fn (gs),
1370 gimple_omp_target_data_arg (gs));
1372 else
1374 pp_string (buffer, "#pragma omp target");
1375 pp_string (buffer, kind);
1376 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1377 if (gimple_omp_target_child_fn (gs))
1379 pp_string (buffer, " [child fn: ");
1380 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1381 spc, flags, false);
1382 pp_string (buffer, " (");
1383 if (gimple_omp_target_data_arg (gs))
1384 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1385 spc, flags, false);
1386 else
1387 pp_string (buffer, "???");
1388 pp_string (buffer, ")]");
1390 gimple_seq body = gimple_omp_body (gs);
1391 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1393 newline_and_indent (buffer, spc + 2);
1394 pp_left_brace (buffer);
1395 pp_newline (buffer);
1396 dump_gimple_seq (buffer, body, spc + 4, flags);
1397 newline_and_indent (buffer, spc + 2);
1398 pp_right_brace (buffer);
1400 else if (body)
1402 pp_newline (buffer);
1403 dump_gimple_seq (buffer, body, spc + 2, flags);
1408 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1410 static void
1411 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1412 int flags)
1414 if (flags & TDF_RAW)
1416 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1417 gimple_omp_body (gs));
1418 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1419 dump_gimple_fmt (buffer, spc, flags, " >");
1421 else
1423 pp_string (buffer, "#pragma omp teams");
1424 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1425 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1427 newline_and_indent (buffer, spc + 2);
1428 pp_character (buffer, '{');
1429 pp_newline (buffer);
1430 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1431 newline_and_indent (buffer, spc + 2);
1432 pp_character (buffer, '}');
1437 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1439 static void
1440 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1441 int spc, int flags)
1443 if (flags & TDF_RAW)
1445 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1446 gimple_omp_body (gs));
1447 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1448 dump_gimple_fmt (buffer, spc, flags, " >");
1450 else
1452 pp_string (buffer, "#pragma omp sections");
1453 if (gimple_omp_sections_control (gs))
1455 pp_string (buffer, " <");
1456 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1457 flags, false);
1458 pp_greater (buffer);
1460 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1461 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1463 newline_and_indent (buffer, spc + 2);
1464 pp_left_brace (buffer);
1465 pp_newline (buffer);
1466 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1467 newline_and_indent (buffer, spc + 2);
1468 pp_right_brace (buffer);
1473 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1474 pretty_printer BUFFER. */
1476 static void
1477 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc, int flags)
1479 if (flags & TDF_RAW)
1480 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1481 gimple_omp_body (gs));
1482 else
1484 switch (gimple_code (gs))
1486 case GIMPLE_OMP_MASTER:
1487 pp_string (buffer, "#pragma omp master");
1488 break;
1489 case GIMPLE_OMP_TASKGROUP:
1490 pp_string (buffer, "#pragma omp taskgroup");
1491 break;
1492 case GIMPLE_OMP_SECTION:
1493 pp_string (buffer, "#pragma omp section");
1494 break;
1495 default:
1496 gcc_unreachable ();
1498 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1500 newline_and_indent (buffer, spc + 2);
1501 pp_left_brace (buffer);
1502 pp_newline (buffer);
1503 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1504 newline_and_indent (buffer, spc + 2);
1505 pp_right_brace (buffer);
1510 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1512 static void
1513 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1514 int spc, int flags)
1516 if (flags & TDF_RAW)
1517 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1518 gimple_omp_body (gs));
1519 else
1521 pp_string (buffer, "#pragma omp critical");
1522 if (gimple_omp_critical_name (gs))
1524 pp_string (buffer, " (");
1525 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1526 flags, false);
1527 pp_right_paren (buffer);
1529 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1530 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1532 newline_and_indent (buffer, spc + 2);
1533 pp_left_brace (buffer);
1534 pp_newline (buffer);
1535 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1536 newline_and_indent (buffer, spc + 2);
1537 pp_right_brace (buffer);
1542 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1544 static void
1545 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1546 int spc, int flags)
1548 if (flags & TDF_RAW)
1549 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1550 gimple_omp_body (gs));
1551 else
1553 pp_string (buffer, "#pragma omp ordered");
1554 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1555 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1557 newline_and_indent (buffer, spc + 2);
1558 pp_left_brace (buffer);
1559 pp_newline (buffer);
1560 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1561 newline_and_indent (buffer, spc + 2);
1562 pp_right_brace (buffer);
1567 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1569 static void
1570 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc, int flags)
1572 if (flags & TDF_RAW)
1574 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1575 (int) gimple_omp_return_nowait_p (gs));
1576 if (gimple_omp_return_lhs (gs))
1577 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1578 gimple_omp_return_lhs (gs));
1579 else
1580 dump_gimple_fmt (buffer, spc, flags, ">");
1582 else
1584 pp_string (buffer, "#pragma omp return");
1585 if (gimple_omp_return_nowait_p (gs))
1586 pp_string (buffer, "(nowait)");
1587 if (gimple_omp_return_lhs (gs))
1589 pp_string (buffer, " (set ");
1590 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1591 spc, flags, false);
1592 pp_character (buffer, ')');
1597 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1599 static void
1600 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1601 int spc, int flags)
1603 unsigned subcode = gimple_transaction_subcode (gs);
1605 if (flags & TDF_RAW)
1607 dump_gimple_fmt (buffer, spc, flags,
1608 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1609 gs, subcode, gimple_transaction_label (gs),
1610 gimple_transaction_body (gs));
1612 else
1614 if (subcode & GTMA_IS_OUTER)
1615 pp_string (buffer, "__transaction_atomic [[outer]]");
1616 else if (subcode & GTMA_IS_RELAXED)
1617 pp_string (buffer, "__transaction_relaxed");
1618 else
1619 pp_string (buffer, "__transaction_atomic");
1620 subcode &= ~GTMA_DECLARATION_MASK;
1622 if (subcode || gimple_transaction_label (gs))
1624 pp_string (buffer, " //");
1625 if (gimple_transaction_label (gs))
1627 pp_string (buffer, " LABEL=");
1628 dump_generic_node (buffer, gimple_transaction_label (gs),
1629 spc, flags, false);
1631 if (subcode)
1633 pp_string (buffer, " SUBCODE=[ ");
1634 if (subcode & GTMA_HAVE_ABORT)
1636 pp_string (buffer, "GTMA_HAVE_ABORT ");
1637 subcode &= ~GTMA_HAVE_ABORT;
1639 if (subcode & GTMA_HAVE_LOAD)
1641 pp_string (buffer, "GTMA_HAVE_LOAD ");
1642 subcode &= ~GTMA_HAVE_LOAD;
1644 if (subcode & GTMA_HAVE_STORE)
1646 pp_string (buffer, "GTMA_HAVE_STORE ");
1647 subcode &= ~GTMA_HAVE_STORE;
1649 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1651 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1652 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1654 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1656 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1657 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1659 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1661 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1662 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1664 if (subcode)
1665 pp_printf (buffer, "0x%x ", subcode);
1666 pp_right_bracket (buffer);
1670 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1672 newline_and_indent (buffer, spc + 2);
1673 pp_left_brace (buffer);
1674 pp_newline (buffer);
1675 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1676 spc + 4, flags);
1677 newline_and_indent (buffer, spc + 2);
1678 pp_right_brace (buffer);
1683 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1684 indent. FLAGS specifies details to show in the dump (see TDF_* in
1685 dumpfile.h). */
1687 static void
1688 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
1690 unsigned int i, n, f, fields;
1692 if (flags & TDF_RAW)
1694 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1695 gimple_asm_string (gs));
1697 n = gimple_asm_noutputs (gs);
1698 if (n)
1700 newline_and_indent (buffer, spc + 2);
1701 pp_string (buffer, "OUTPUT: ");
1702 for (i = 0; i < n; i++)
1704 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1705 spc, flags, false);
1706 if (i < n - 1)
1707 pp_string (buffer, ", ");
1711 n = gimple_asm_ninputs (gs);
1712 if (n)
1714 newline_and_indent (buffer, spc + 2);
1715 pp_string (buffer, "INPUT: ");
1716 for (i = 0; i < n; i++)
1718 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1719 spc, flags, false);
1720 if (i < n - 1)
1721 pp_string (buffer, ", ");
1725 n = gimple_asm_nclobbers (gs);
1726 if (n)
1728 newline_and_indent (buffer, spc + 2);
1729 pp_string (buffer, "CLOBBER: ");
1730 for (i = 0; i < n; i++)
1732 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1733 spc, flags, false);
1734 if (i < n - 1)
1735 pp_string (buffer, ", ");
1739 n = gimple_asm_nlabels (gs);
1740 if (n)
1742 newline_and_indent (buffer, spc + 2);
1743 pp_string (buffer, "LABEL: ");
1744 for (i = 0; i < n; i++)
1746 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1747 spc, flags, false);
1748 if (i < n - 1)
1749 pp_string (buffer, ", ");
1753 newline_and_indent (buffer, spc);
1754 pp_greater (buffer);
1756 else
1758 pp_string (buffer, "__asm__");
1759 if (gimple_asm_volatile_p (gs))
1760 pp_string (buffer, " __volatile__");
1761 if (gimple_asm_nlabels (gs))
1762 pp_string (buffer, " goto");
1763 pp_string (buffer, "(\"");
1764 pp_string (buffer, gimple_asm_string (gs));
1765 pp_string (buffer, "\"");
1767 if (gimple_asm_nlabels (gs))
1768 fields = 4;
1769 else if (gimple_asm_nclobbers (gs))
1770 fields = 3;
1771 else if (gimple_asm_ninputs (gs))
1772 fields = 2;
1773 else if (gimple_asm_noutputs (gs))
1774 fields = 1;
1775 else
1776 fields = 0;
1778 for (f = 0; f < fields; ++f)
1780 pp_string (buffer, " : ");
1782 switch (f)
1784 case 0:
1785 n = gimple_asm_noutputs (gs);
1786 for (i = 0; i < n; i++)
1788 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1789 spc, flags, false);
1790 if (i < n - 1)
1791 pp_string (buffer, ", ");
1793 break;
1795 case 1:
1796 n = gimple_asm_ninputs (gs);
1797 for (i = 0; i < n; i++)
1799 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1800 spc, flags, false);
1801 if (i < n - 1)
1802 pp_string (buffer, ", ");
1804 break;
1806 case 2:
1807 n = gimple_asm_nclobbers (gs);
1808 for (i = 0; i < n; i++)
1810 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1811 spc, flags, false);
1812 if (i < n - 1)
1813 pp_string (buffer, ", ");
1815 break;
1817 case 3:
1818 n = gimple_asm_nlabels (gs);
1819 for (i = 0; i < n; i++)
1821 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1822 spc, flags, false);
1823 if (i < n - 1)
1824 pp_string (buffer, ", ");
1826 break;
1828 default:
1829 gcc_unreachable ();
1833 pp_string (buffer, ");");
1837 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1838 SPC spaces of indent. */
1840 static void
1841 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1843 if (TREE_CODE (node) != SSA_NAME)
1844 return;
1846 if (POINTER_TYPE_P (TREE_TYPE (node))
1847 && SSA_NAME_PTR_INFO (node))
1849 unsigned int align, misalign;
1850 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1851 pp_string (buffer, "# PT = ");
1852 pp_points_to_solution (buffer, &pi->pt);
1853 newline_and_indent (buffer, spc);
1854 if (get_ptr_info_alignment (pi, &align, &misalign))
1856 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1857 newline_and_indent (buffer, spc);
1861 if (!POINTER_TYPE_P (TREE_TYPE (node))
1862 && SSA_NAME_RANGE_INFO (node))
1864 wide_int min, max, nonzero_bits;
1865 value_range_type range_type = get_range_info (node, &min, &max);
1867 if (range_type == VR_VARYING)
1868 pp_printf (buffer, "# RANGE VR_VARYING");
1869 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1871 pp_printf (buffer, "# RANGE ");
1872 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1873 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
1874 pp_printf (buffer, ", ");
1875 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
1876 pp_printf (buffer, "]");
1878 nonzero_bits = get_nonzero_bits (node);
1879 if (nonzero_bits != -1)
1881 pp_string (buffer, " NONZERO ");
1882 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
1884 newline_and_indent (buffer, spc);
1889 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1890 The caller is responsible for calling pp_flush on BUFFER to finalize
1891 pretty printer. If COMMENT is true, print this after #. */
1893 static void
1894 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
1895 int flags)
1897 size_t i;
1898 tree lhs = gimple_phi_result (phi);
1900 if (flags & TDF_ALIAS)
1901 dump_ssaname_info (buffer, lhs, spc);
1903 if (comment)
1904 pp_string (buffer, "# ");
1906 if (flags & TDF_RAW)
1907 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1908 gimple_phi_result (phi));
1909 else
1911 dump_generic_node (buffer, lhs, spc, flags, false);
1912 pp_string (buffer, " = PHI <");
1914 for (i = 0; i < gimple_phi_num_args (phi); i++)
1916 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1917 dump_location (buffer, gimple_phi_arg_location (phi, i));
1918 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1919 false);
1920 pp_left_paren (buffer);
1921 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1922 pp_right_paren (buffer);
1923 if (i < gimple_phi_num_args (phi) - 1)
1924 pp_string (buffer, ", ");
1926 pp_greater (buffer);
1930 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1931 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1932 dumpfile.h). */
1934 static void
1935 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
1936 int spc, int flags)
1938 if (flags & TDF_RAW)
1940 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1941 gimple_omp_body (gs));
1942 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1943 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1944 gimple_omp_parallel_child_fn (gs),
1945 gimple_omp_parallel_data_arg (gs));
1947 else
1949 gimple_seq body;
1950 pp_string (buffer, "#pragma omp parallel");
1951 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1952 if (gimple_omp_parallel_child_fn (gs))
1954 pp_string (buffer, " [child fn: ");
1955 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1956 spc, flags, false);
1957 pp_string (buffer, " (");
1958 if (gimple_omp_parallel_data_arg (gs))
1959 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1960 spc, flags, false);
1961 else
1962 pp_string (buffer, "???");
1963 pp_string (buffer, ")]");
1965 body = gimple_omp_body (gs);
1966 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1968 newline_and_indent (buffer, spc + 2);
1969 pp_left_brace (buffer);
1970 pp_newline (buffer);
1971 dump_gimple_seq (buffer, body, spc + 4, flags);
1972 newline_and_indent (buffer, spc + 2);
1973 pp_right_brace (buffer);
1975 else if (body)
1977 pp_newline (buffer);
1978 dump_gimple_seq (buffer, body, spc + 2, flags);
1984 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1985 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1986 dumpfile.h). */
1988 static void
1989 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
1990 int flags)
1992 if (flags & TDF_RAW)
1994 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1995 gimple_omp_body (gs));
1996 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1997 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1998 gimple_omp_task_child_fn (gs),
1999 gimple_omp_task_data_arg (gs),
2000 gimple_omp_task_copy_fn (gs),
2001 gimple_omp_task_arg_size (gs),
2002 gimple_omp_task_arg_size (gs));
2004 else
2006 gimple_seq body;
2007 if (gimple_omp_task_taskloop_p (gs))
2008 pp_string (buffer, "#pragma omp taskloop");
2009 else
2010 pp_string (buffer, "#pragma omp task");
2011 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2012 if (gimple_omp_task_child_fn (gs))
2014 pp_string (buffer, " [child fn: ");
2015 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2016 spc, flags, false);
2017 pp_string (buffer, " (");
2018 if (gimple_omp_task_data_arg (gs))
2019 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2020 spc, flags, false);
2021 else
2022 pp_string (buffer, "???");
2023 pp_string (buffer, ")]");
2025 body = gimple_omp_body (gs);
2026 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2028 newline_and_indent (buffer, spc + 2);
2029 pp_left_brace (buffer);
2030 pp_newline (buffer);
2031 dump_gimple_seq (buffer, body, spc + 4, flags);
2032 newline_and_indent (buffer, spc + 2);
2033 pp_right_brace (buffer);
2035 else if (body)
2037 pp_newline (buffer);
2038 dump_gimple_seq (buffer, body, spc + 2, flags);
2044 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2045 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2046 in dumpfile.h). */
2048 static void
2049 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2050 int spc, int flags)
2052 if (flags & TDF_RAW)
2054 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2055 gimple_omp_atomic_load_lhs (gs),
2056 gimple_omp_atomic_load_rhs (gs));
2058 else
2060 pp_string (buffer, "#pragma omp atomic_load");
2061 if (gimple_omp_atomic_seq_cst_p (gs))
2062 pp_string (buffer, " seq_cst");
2063 if (gimple_omp_atomic_need_value_p (gs))
2064 pp_string (buffer, " [needed]");
2065 newline_and_indent (buffer, spc + 2);
2066 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2067 spc, flags, false);
2068 pp_space (buffer);
2069 pp_equal (buffer);
2070 pp_space (buffer);
2071 pp_star (buffer);
2072 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2073 spc, flags, false);
2077 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2078 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2079 in dumpfile.h). */
2081 static void
2082 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2083 gomp_atomic_store *gs, int spc, int flags)
2085 if (flags & TDF_RAW)
2087 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2088 gimple_omp_atomic_store_val (gs));
2090 else
2092 pp_string (buffer, "#pragma omp atomic_store ");
2093 if (gimple_omp_atomic_seq_cst_p (gs))
2094 pp_string (buffer, "seq_cst ");
2095 if (gimple_omp_atomic_need_value_p (gs))
2096 pp_string (buffer, "[needed] ");
2097 pp_left_paren (buffer);
2098 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2099 spc, flags, false);
2100 pp_right_paren (buffer);
2105 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2106 FLAGS are as in pp_gimple_stmt_1. */
2108 static void
2109 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc, int flags)
2111 tree vdef = gimple_vdef (gs);
2112 tree vuse = gimple_vuse (gs);
2114 if (vdef != NULL_TREE)
2116 pp_string (buffer, "# ");
2117 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2118 pp_string (buffer, " = VDEF <");
2119 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2120 pp_greater (buffer);
2121 newline_and_indent (buffer, spc);
2123 else if (vuse != NULL_TREE)
2125 pp_string (buffer, "# VUSE <");
2126 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2127 pp_greater (buffer);
2128 newline_and_indent (buffer, spc);
2133 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2134 spaces of indent. FLAGS specifies details to show in the dump (see
2135 TDF_* in dumpfile.h). The caller is responsible for calling
2136 pp_flush on BUFFER to finalize the pretty printer. */
2138 void
2139 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
2141 if (!gs)
2142 return;
2144 if (flags & TDF_STMTADDR)
2145 pp_printf (buffer, "<&%p> ", (void *) gs);
2147 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2148 dump_location (buffer, gimple_location (gs));
2150 if (flags & TDF_EH)
2152 int lp_nr = lookup_stmt_eh_lp (gs);
2153 if (lp_nr > 0)
2154 pp_printf (buffer, "[LP %d] ", lp_nr);
2155 else if (lp_nr < 0)
2156 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2159 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2160 && gimple_has_mem_ops (gs))
2161 dump_gimple_mem_ops (buffer, gs, spc, flags);
2163 if (gimple_has_lhs (gs)
2164 && (flags & TDF_ALIAS))
2165 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2167 switch (gimple_code (gs))
2169 case GIMPLE_ASM:
2170 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2171 break;
2173 case GIMPLE_ASSIGN:
2174 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2175 break;
2177 case GIMPLE_BIND:
2178 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2179 break;
2181 case GIMPLE_CALL:
2182 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2183 break;
2185 case GIMPLE_COND:
2186 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2187 break;
2189 case GIMPLE_LABEL:
2190 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2191 break;
2193 case GIMPLE_GOTO:
2194 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2195 break;
2197 case GIMPLE_NOP:
2198 pp_string (buffer, "GIMPLE_NOP");
2199 break;
2201 case GIMPLE_RETURN:
2202 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2203 break;
2205 case GIMPLE_SWITCH:
2206 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2207 break;
2209 case GIMPLE_TRY:
2210 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2211 break;
2213 case GIMPLE_PHI:
2214 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2215 break;
2217 case GIMPLE_OMP_PARALLEL:
2218 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2219 flags);
2220 break;
2222 case GIMPLE_OMP_TASK:
2223 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2224 break;
2226 case GIMPLE_OMP_ATOMIC_LOAD:
2227 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2228 spc, flags);
2229 break;
2231 case GIMPLE_OMP_ATOMIC_STORE:
2232 dump_gimple_omp_atomic_store (buffer,
2233 as_a <gomp_atomic_store *> (gs),
2234 spc, flags);
2235 break;
2237 case GIMPLE_OMP_FOR:
2238 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2239 break;
2241 case GIMPLE_OMP_CONTINUE:
2242 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2243 flags);
2244 break;
2246 case GIMPLE_OMP_SINGLE:
2247 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2248 flags);
2249 break;
2251 case GIMPLE_OMP_TARGET:
2252 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2253 flags);
2254 break;
2256 case GIMPLE_OMP_TEAMS:
2257 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2258 flags);
2259 break;
2261 case GIMPLE_OMP_RETURN:
2262 dump_gimple_omp_return (buffer, gs, spc, flags);
2263 break;
2265 case GIMPLE_OMP_SECTIONS:
2266 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2267 spc, flags);
2268 break;
2270 case GIMPLE_OMP_SECTIONS_SWITCH:
2271 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2272 break;
2274 case GIMPLE_OMP_MASTER:
2275 case GIMPLE_OMP_TASKGROUP:
2276 case GIMPLE_OMP_SECTION:
2277 dump_gimple_omp_block (buffer, gs, spc, flags);
2278 break;
2280 case GIMPLE_OMP_ORDERED:
2281 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2282 flags);
2283 break;
2285 case GIMPLE_OMP_CRITICAL:
2286 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2287 flags);
2288 break;
2290 case GIMPLE_CATCH:
2291 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2292 break;
2294 case GIMPLE_EH_FILTER:
2295 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2296 break;
2298 case GIMPLE_EH_MUST_NOT_THROW:
2299 dump_gimple_eh_must_not_throw (buffer,
2300 as_a <geh_mnt *> (gs),
2301 spc, flags);
2302 break;
2304 case GIMPLE_EH_ELSE:
2305 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2306 break;
2308 case GIMPLE_RESX:
2309 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2310 break;
2312 case GIMPLE_EH_DISPATCH:
2313 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2314 flags);
2315 break;
2317 case GIMPLE_DEBUG:
2318 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2319 break;
2321 case GIMPLE_PREDICT:
2322 pp_string (buffer, "// predicted ");
2323 if (gimple_predict_outcome (gs))
2324 pp_string (buffer, "likely by ");
2325 else
2326 pp_string (buffer, "unlikely by ");
2327 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2328 pp_string (buffer, " predictor.");
2329 break;
2331 case GIMPLE_TRANSACTION:
2332 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2333 flags);
2334 break;
2336 default:
2337 GIMPLE_NIY;
2342 /* Dumps header of basic block BB to OUTF indented by INDENT
2343 spaces and details described by flags. */
2345 static void
2346 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2348 if (flags & TDF_BLOCKS)
2350 if (flags & TDF_LINENO)
2352 gimple_stmt_iterator gsi;
2354 if (flags & TDF_COMMENT)
2355 fputs (";; ", outf);
2357 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2358 if (!is_gimple_debug (gsi_stmt (gsi))
2359 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2361 fprintf (outf, "%*sstarting at line %d",
2362 indent, "", get_lineno (gsi_stmt (gsi)));
2363 break;
2365 if (bb->discriminator)
2366 fprintf (outf, ", discriminator %i", bb->discriminator);
2367 fputc ('\n', outf);
2370 else
2372 gimple *stmt = first_stmt (bb);
2373 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2374 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2379 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2380 spaces. */
2382 static void
2383 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2384 basic_block bb ATTRIBUTE_UNUSED,
2385 int indent ATTRIBUTE_UNUSED,
2386 int flags ATTRIBUTE_UNUSED)
2388 /* There is currently no GIMPLE-specific basic block info to dump. */
2389 return;
2393 /* Dump PHI nodes of basic block BB to BUFFER with details described
2394 by FLAGS and indented by INDENT spaces. */
2396 static void
2397 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2399 gphi_iterator i;
2401 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2403 gphi *phi = i.phi ();
2404 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2406 INDENT (indent);
2407 dump_gimple_phi (buffer, phi, indent, true, flags);
2408 pp_newline (buffer);
2414 /* Dump jump to basic block BB that is represented implicitly in the cfg
2415 to BUFFER. */
2417 static void
2418 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2420 gimple *stmt;
2422 stmt = first_stmt (bb);
2424 pp_string (buffer, "goto <bb ");
2425 pp_decimal_int (buffer, bb->index);
2426 pp_greater (buffer);
2427 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2429 pp_string (buffer, " (");
2430 dump_generic_node (buffer,
2431 gimple_label_label (as_a <glabel *> (stmt)),
2432 0, 0, false);
2433 pp_right_paren (buffer);
2434 pp_semicolon (buffer);
2436 else
2437 pp_semicolon (buffer);
2441 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2442 by INDENT spaces, with details given by FLAGS. */
2444 static void
2445 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2446 int flags)
2448 edge e;
2449 gimple *stmt;
2451 stmt = last_stmt (bb);
2453 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2455 edge true_edge, false_edge;
2457 /* When we are emitting the code or changing CFG, it is possible that
2458 the edges are not yet created. When we are using debug_bb in such
2459 a situation, we do not want it to crash. */
2460 if (EDGE_COUNT (bb->succs) != 2)
2461 return;
2462 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2464 INDENT (indent + 2);
2465 pp_cfg_jump (buffer, true_edge->dest);
2466 newline_and_indent (buffer, indent);
2467 pp_string (buffer, "else");
2468 newline_and_indent (buffer, indent + 2);
2469 pp_cfg_jump (buffer, false_edge->dest);
2470 pp_newline (buffer);
2471 return;
2474 /* If there is a fallthru edge, we may need to add an artificial
2475 goto to the dump. */
2476 e = find_fallthru_edge (bb->succs);
2478 if (e && e->dest != bb->next_bb)
2480 INDENT (indent);
2482 if ((flags & TDF_LINENO)
2483 && e->goto_locus != UNKNOWN_LOCATION)
2484 dump_location (buffer, e->goto_locus);
2486 pp_cfg_jump (buffer, e->dest);
2487 pp_newline (buffer);
2492 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2493 indented by INDENT spaces. */
2495 static void
2496 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2497 int flags)
2499 gimple_stmt_iterator gsi;
2500 gimple *stmt;
2501 int label_indent = indent - 2;
2503 if (label_indent < 0)
2504 label_indent = 0;
2506 dump_phi_nodes (buffer, bb, indent, flags);
2508 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2510 int curr_indent;
2512 stmt = gsi_stmt (gsi);
2514 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2516 INDENT (curr_indent);
2517 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2518 pp_newline_and_flush (buffer);
2519 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2520 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2521 pp_buffer (buffer)->stream, stmt);
2524 dump_implicit_edges (buffer, bb, indent, flags);
2525 pp_flush (buffer);
2529 /* Dumps basic block BB to FILE with details described by FLAGS and
2530 indented by INDENT spaces. */
2532 void
2533 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2535 dump_gimple_bb_header (file, bb, indent, flags);
2536 if (bb->index >= NUM_FIXED_BLOCKS)
2538 pretty_printer buffer;
2539 pp_needs_newline (&buffer) = true;
2540 buffer.buffer->stream = file;
2541 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2543 dump_gimple_bb_footer (file, bb, indent, flags);
2546 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2547 no indentation, for use as a label of a DOT graph record-node.
2548 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2549 histogram dumping doesn't know about pretty-printers. */
2551 void
2552 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2554 pp_printf (pp, "<bb %d>:\n", bb->index);
2555 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2557 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2558 gsi_next (&gsi))
2560 gphi *phi = gsi.phi ();
2561 if (!virtual_operand_p (gimple_phi_result (phi))
2562 || (dump_flags & TDF_VOPS))
2564 pp_bar (pp);
2565 pp_write_text_to_stream (pp);
2566 pp_string (pp, "# ");
2567 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2568 pp_newline (pp);
2569 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2573 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2574 gsi_next (&gsi))
2576 gimple *stmt = gsi_stmt (gsi);
2577 pp_bar (pp);
2578 pp_write_text_to_stream (pp);
2579 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2580 pp_newline (pp);
2581 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2583 dump_implicit_edges (pp, bb, 0, dump_flags);
2584 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);