PR target/66563
[official-gcc.git] / gcc / gimple-pretty-print.c
bloba006fa924fda8e8576a0a2c7e4deb1555e0c4e12
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2015 Free Software Foundation, Inc.
3 Contributed by Aldy Hernandez <aldyh@redhat.com> and
4 Diego Novillo <dnovillo@google.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "alias.h"
27 #include "symtab.h"
28 #include "tree.h"
29 #include "fold-const.h"
30 #include "stringpool.h"
31 #include "diagnostic.h"
32 #include "gimple-pretty-print.h"
33 #include "bitmap.h"
34 #include "predict.h"
35 #include "hard-reg-set.h"
36 #include "function.h"
37 #include "basic-block.h"
38 #include "tree-ssa-alias.h"
39 #include "internal-fn.h"
40 #include "tree-eh.h"
41 #include "gimple-expr.h"
42 #include "gimple.h"
43 #include "gimple-iterator.h"
44 #include "gimple-ssa.h"
45 #include "plugin-api.h"
46 #include "ipa-ref.h"
47 #include "cgraph.h"
48 #include "tree-cfg.h"
49 #include "tree-ssanames.h"
50 #include "dumpfile.h" /* for dump_flags */
51 #include "value-prof.h"
52 #include "trans-mem.h"
54 #define INDENT(SPACE) \
55 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
57 #define GIMPLE_NIY do_niy (buffer,gs)
59 /* Try to print on BUFFER a default message for the unrecognized
60 gimple statement GS. */
62 static void
63 do_niy (pretty_printer *buffer, gimple gs)
65 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
66 gimple_code_name[(int) gimple_code (gs)]);
70 /* Emit a newline and SPC indentation spaces to BUFFER. */
72 static void
73 newline_and_indent (pretty_printer *buffer, int spc)
75 pp_newline (buffer);
76 INDENT (spc);
80 /* Print the GIMPLE statement GS on stderr. */
82 DEBUG_FUNCTION void
83 debug_gimple_stmt (gimple gs)
85 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
89 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
90 FLAGS as in pp_gimple_stmt_1. */
92 void
93 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
95 pretty_printer buffer;
96 pp_needs_newline (&buffer) = true;
97 buffer.buffer->stream = file;
98 pp_gimple_stmt_1 (&buffer, g, spc, flags);
99 pp_newline_and_flush (&buffer);
102 DEBUG_FUNCTION void
103 debug (gimple_statement_base &ref)
105 print_gimple_stmt (stderr, &ref, 0, 0);
108 DEBUG_FUNCTION void
109 debug (gimple_statement_base *ptr)
111 if (ptr)
112 debug (*ptr);
113 else
114 fprintf (stderr, "<nil>\n");
118 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
119 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
120 of the statement. */
122 void
123 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
125 flags |= TDF_RHS_ONLY;
126 pretty_printer buffer;
127 pp_needs_newline (&buffer) = true;
128 buffer.buffer->stream = file;
129 pp_gimple_stmt_1 (&buffer, g, spc, flags);
130 pp_flush (&buffer);
134 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
135 spaces and FLAGS as in pp_gimple_stmt_1.
136 The caller is responsible for calling pp_flush on BUFFER to finalize
137 the pretty printer. */
139 static void
140 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
142 gimple_stmt_iterator i;
144 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
146 gimple gs = gsi_stmt (i);
147 INDENT (spc);
148 pp_gimple_stmt_1 (buffer, gs, spc, flags);
149 if (!gsi_one_before_end_p (i))
150 pp_newline (buffer);
155 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
156 FLAGS as in pp_gimple_stmt_1. */
158 void
159 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
161 pretty_printer buffer;
162 pp_needs_newline (&buffer) = true;
163 buffer.buffer->stream = file;
164 dump_gimple_seq (&buffer, seq, spc, flags);
165 pp_newline_and_flush (&buffer);
169 /* Print the GIMPLE sequence SEQ on stderr. */
171 DEBUG_FUNCTION void
172 debug_gimple_seq (gimple_seq seq)
174 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
178 /* A simple helper to pretty-print some of the gimple tuples in the printf
179 style. The format modifiers are preceded by '%' and are:
180 'G' - outputs a string corresponding to the code of the given gimple,
181 'S' - outputs a gimple_seq with indent of spc + 2,
182 'T' - outputs the tree t,
183 'd' - outputs an int as a decimal,
184 's' - outputs a string,
185 'n' - outputs a newline,
186 'x' - outputs an int as hexadecimal,
187 '+' - increases indent by 2 then outputs a newline,
188 '-' - decreases indent by 2 then outputs a newline. */
190 static void
191 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
192 const char *fmt, ...)
194 va_list args;
195 const char *c;
196 const char *tmp;
198 va_start (args, fmt);
199 for (c = fmt; *c; c++)
201 if (*c == '%')
203 gimple_seq seq;
204 tree t;
205 gimple g;
206 switch (*++c)
208 case 'G':
209 g = va_arg (args, gimple);
210 tmp = gimple_code_name[gimple_code (g)];
211 pp_string (buffer, tmp);
212 break;
214 case 'S':
215 seq = va_arg (args, gimple_seq);
216 pp_newline (buffer);
217 dump_gimple_seq (buffer, seq, spc + 2, flags);
218 newline_and_indent (buffer, spc);
219 break;
221 case 'T':
222 t = va_arg (args, tree);
223 if (t == NULL_TREE)
224 pp_string (buffer, "NULL");
225 else
226 dump_generic_node (buffer, t, spc, flags, false);
227 break;
229 case 'd':
230 pp_decimal_int (buffer, va_arg (args, int));
231 break;
233 case 's':
234 pp_string (buffer, va_arg (args, char *));
235 break;
237 case 'n':
238 newline_and_indent (buffer, spc);
239 break;
241 case 'x':
242 pp_scalar (buffer, "%x", va_arg (args, int));
243 break;
245 case '+':
246 spc += 2;
247 newline_and_indent (buffer, spc);
248 break;
250 case '-':
251 spc -= 2;
252 newline_and_indent (buffer, spc);
253 break;
255 default:
256 gcc_unreachable ();
259 else
260 pp_character (buffer, *c);
262 va_end (args);
266 /* Helper for dump_gimple_assign. Print the unary RHS of the
267 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
269 static void
270 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
272 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
273 tree lhs = gimple_assign_lhs (gs);
274 tree rhs = gimple_assign_rhs1 (gs);
276 switch (rhs_code)
278 case VIEW_CONVERT_EXPR:
279 case ASSERT_EXPR:
280 dump_generic_node (buffer, rhs, spc, flags, false);
281 break;
283 case FIXED_CONVERT_EXPR:
284 case ADDR_SPACE_CONVERT_EXPR:
285 case FIX_TRUNC_EXPR:
286 case FLOAT_EXPR:
287 CASE_CONVERT:
288 pp_left_paren (buffer);
289 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
290 pp_string (buffer, ") ");
291 if (op_prio (rhs) < op_code_prio (rhs_code))
293 pp_left_paren (buffer);
294 dump_generic_node (buffer, rhs, spc, flags, false);
295 pp_right_paren (buffer);
297 else
298 dump_generic_node (buffer, rhs, spc, flags, false);
299 break;
301 case PAREN_EXPR:
302 pp_string (buffer, "((");
303 dump_generic_node (buffer, rhs, spc, flags, false);
304 pp_string (buffer, "))");
305 break;
307 case ABS_EXPR:
308 pp_string (buffer, "ABS_EXPR <");
309 dump_generic_node (buffer, rhs, spc, flags, false);
310 pp_greater (buffer);
311 break;
313 default:
314 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
315 || TREE_CODE_CLASS (rhs_code) == tcc_constant
316 || TREE_CODE_CLASS (rhs_code) == tcc_reference
317 || rhs_code == SSA_NAME
318 || rhs_code == ADDR_EXPR
319 || rhs_code == CONSTRUCTOR)
321 dump_generic_node (buffer, rhs, spc, flags, false);
322 break;
324 else if (rhs_code == BIT_NOT_EXPR)
325 pp_complement (buffer);
326 else if (rhs_code == TRUTH_NOT_EXPR)
327 pp_exclamation (buffer);
328 else if (rhs_code == NEGATE_EXPR)
329 pp_minus (buffer);
330 else
332 pp_left_bracket (buffer);
333 pp_string (buffer, get_tree_code_name (rhs_code));
334 pp_string (buffer, "] ");
337 if (op_prio (rhs) < op_code_prio (rhs_code))
339 pp_left_paren (buffer);
340 dump_generic_node (buffer, rhs, spc, flags, false);
341 pp_right_paren (buffer);
343 else
344 dump_generic_node (buffer, rhs, spc, flags, false);
345 break;
350 /* Helper for dump_gimple_assign. Print the binary RHS of the
351 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
353 static void
354 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
356 const char *p;
357 enum tree_code code = gimple_assign_rhs_code (gs);
358 switch (code)
360 case COMPLEX_EXPR:
361 case MIN_EXPR:
362 case MAX_EXPR:
363 case VEC_WIDEN_MULT_HI_EXPR:
364 case VEC_WIDEN_MULT_LO_EXPR:
365 case VEC_WIDEN_MULT_EVEN_EXPR:
366 case VEC_WIDEN_MULT_ODD_EXPR:
367 case VEC_PACK_TRUNC_EXPR:
368 case VEC_PACK_SAT_EXPR:
369 case VEC_PACK_FIX_TRUNC_EXPR:
370 case VEC_WIDEN_LSHIFT_HI_EXPR:
371 case VEC_WIDEN_LSHIFT_LO_EXPR:
372 for (p = get_tree_code_name (code); *p; p++)
373 pp_character (buffer, TOUPPER (*p));
374 pp_string (buffer, " <");
375 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
376 pp_string (buffer, ", ");
377 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
378 pp_greater (buffer);
379 break;
381 default:
382 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
384 pp_left_paren (buffer);
385 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
386 false);
387 pp_right_paren (buffer);
389 else
390 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
391 pp_space (buffer);
392 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
393 pp_space (buffer);
394 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
396 pp_left_paren (buffer);
397 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
398 false);
399 pp_right_paren (buffer);
401 else
402 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
406 /* Helper for dump_gimple_assign. Print the ternary RHS of the
407 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
409 static void
410 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
412 const char *p;
413 enum tree_code code = gimple_assign_rhs_code (gs);
414 switch (code)
416 case WIDEN_MULT_PLUS_EXPR:
417 case WIDEN_MULT_MINUS_EXPR:
418 for (p = get_tree_code_name (code); *p; p++)
419 pp_character (buffer, TOUPPER (*p));
420 pp_string (buffer, " <");
421 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
422 pp_string (buffer, ", ");
423 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
424 pp_string (buffer, ", ");
425 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
426 pp_greater (buffer);
427 break;
429 case FMA_EXPR:
430 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
431 pp_string (buffer, " * ");
432 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
433 pp_string (buffer, " + ");
434 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
435 break;
437 case DOT_PROD_EXPR:
438 pp_string (buffer, "DOT_PROD_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 SAD_EXPR:
448 pp_string (buffer, "SAD_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 VEC_PERM_EXPR:
458 pp_string (buffer, "VEC_PERM_EXPR <");
459 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
460 pp_string (buffer, ", ");
461 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
462 pp_string (buffer, ", ");
463 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
464 pp_greater (buffer);
465 break;
467 case REALIGN_LOAD_EXPR:
468 pp_string (buffer, "REALIGN_LOAD <");
469 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
470 pp_string (buffer, ", ");
471 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
472 pp_string (buffer, ", ");
473 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
474 pp_greater (buffer);
475 break;
477 case COND_EXPR:
478 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
479 pp_string (buffer, " ? ");
480 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
481 pp_string (buffer, " : ");
482 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
483 break;
485 case VEC_COND_EXPR:
486 pp_string (buffer, "VEC_COND_EXPR <");
487 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
488 pp_string (buffer, ", ");
489 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
490 pp_string (buffer, ", ");
491 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
492 pp_greater (buffer);
493 break;
495 default:
496 gcc_unreachable ();
501 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
502 pp_gimple_stmt_1. */
504 static void
505 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
507 if (flags & TDF_RAW)
509 tree arg1 = NULL;
510 tree arg2 = NULL;
511 tree arg3 = NULL;
512 switch (gimple_num_ops (gs))
514 case 4:
515 arg3 = gimple_assign_rhs3 (gs);
516 case 3:
517 arg2 = gimple_assign_rhs2 (gs);
518 case 2:
519 arg1 = gimple_assign_rhs1 (gs);
520 break;
521 default:
522 gcc_unreachable ();
525 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
526 get_tree_code_name (gimple_assign_rhs_code (gs)),
527 gimple_assign_lhs (gs), arg1, arg2, arg3);
529 else
531 if (!(flags & TDF_RHS_ONLY))
533 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
534 pp_space (buffer);
535 pp_equal (buffer);
537 if (gimple_assign_nontemporal_move_p (gs))
538 pp_string (buffer, "{nt}");
540 if (gimple_has_volatile_ops (gs))
541 pp_string (buffer, "{v}");
543 pp_space (buffer);
546 if (gimple_num_ops (gs) == 2)
547 dump_unary_rhs (buffer, gs, spc, flags);
548 else if (gimple_num_ops (gs) == 3)
549 dump_binary_rhs (buffer, gs, spc, flags);
550 else if (gimple_num_ops (gs) == 4)
551 dump_ternary_rhs (buffer, gs, spc, flags);
552 else
553 gcc_unreachable ();
554 if (!(flags & TDF_RHS_ONLY))
555 pp_semicolon (buffer);
560 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
561 pp_gimple_stmt_1. */
563 static void
564 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
566 tree t, t2;
568 t = gimple_return_retval (gs);
569 t2 = gimple_return_retbnd (gs);
570 if (flags & TDF_RAW)
571 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
572 else
574 pp_string (buffer, "return");
575 if (t)
577 pp_space (buffer);
578 dump_generic_node (buffer, t, spc, flags, false);
580 if (t2)
582 pp_string (buffer, ", ");
583 dump_generic_node (buffer, t2, spc, flags, false);
585 pp_semicolon (buffer);
590 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
591 dump_gimple_call. */
593 static void
594 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
596 size_t i;
598 for (i = 0; i < gimple_call_num_args (gs); i++)
600 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
601 if (i < gimple_call_num_args (gs) - 1)
602 pp_string (buffer, ", ");
605 if (gimple_call_va_arg_pack_p (gs))
607 if (gimple_call_num_args (gs) > 0)
609 pp_comma (buffer);
610 pp_space (buffer);
613 pp_string (buffer, "__builtin_va_arg_pack ()");
617 /* Dump the points-to solution *PT to BUFFER. */
619 static void
620 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
622 if (pt->anything)
624 pp_string (buffer, "anything ");
625 return;
627 if (pt->nonlocal)
628 pp_string (buffer, "nonlocal ");
629 if (pt->escaped)
630 pp_string (buffer, "escaped ");
631 if (pt->ipa_escaped)
632 pp_string (buffer, "unit-escaped ");
633 if (pt->null)
634 pp_string (buffer, "null ");
635 if (pt->vars
636 && !bitmap_empty_p (pt->vars))
638 bitmap_iterator bi;
639 unsigned i;
640 pp_string (buffer, "{ ");
641 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
643 pp_string (buffer, "D.");
644 pp_decimal_int (buffer, i);
645 pp_space (buffer);
647 pp_right_brace (buffer);
648 if (pt->vars_contains_nonlocal
649 && pt->vars_contains_escaped_heap)
650 pp_string (buffer, " (nonlocal, escaped heap)");
651 else if (pt->vars_contains_nonlocal
652 && pt->vars_contains_escaped)
653 pp_string (buffer, " (nonlocal, escaped)");
654 else if (pt->vars_contains_nonlocal)
655 pp_string (buffer, " (nonlocal)");
656 else if (pt->vars_contains_escaped_heap)
657 pp_string (buffer, " (escaped heap)");
658 else if (pt->vars_contains_escaped)
659 pp_string (buffer, " (escaped)");
663 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
664 pp_gimple_stmt_1. */
666 static void
667 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
669 tree lhs = gimple_call_lhs (gs);
670 tree fn = gimple_call_fn (gs);
672 if (flags & TDF_ALIAS)
674 struct pt_solution *pt;
675 pt = gimple_call_use_set (gs);
676 if (!pt_solution_empty_p (pt))
678 pp_string (buffer, "# USE = ");
679 pp_points_to_solution (buffer, pt);
680 newline_and_indent (buffer, spc);
682 pt = gimple_call_clobber_set (gs);
683 if (!pt_solution_empty_p (pt))
685 pp_string (buffer, "# CLB = ");
686 pp_points_to_solution (buffer, pt);
687 newline_and_indent (buffer, spc);
691 if (flags & TDF_RAW)
693 if (gimple_call_internal_p (gs))
694 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
695 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
696 else
697 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
698 if (gimple_call_num_args (gs) > 0)
700 pp_string (buffer, ", ");
701 dump_gimple_call_args (buffer, gs, flags);
703 pp_greater (buffer);
705 else
707 if (lhs && !(flags & TDF_RHS_ONLY))
709 dump_generic_node (buffer, lhs, spc, flags, false);
710 pp_string (buffer, " =");
712 if (gimple_has_volatile_ops (gs))
713 pp_string (buffer, "{v}");
715 pp_space (buffer);
717 if (gimple_call_internal_p (gs))
718 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
719 else
720 print_call_name (buffer, fn, flags);
721 pp_string (buffer, " (");
722 dump_gimple_call_args (buffer, gs, flags);
723 pp_right_paren (buffer);
724 if (!(flags & TDF_RHS_ONLY))
725 pp_semicolon (buffer);
728 if (gimple_call_chain (gs))
730 pp_string (buffer, " [static-chain: ");
731 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
732 pp_right_bracket (buffer);
735 if (gimple_call_return_slot_opt_p (gs))
736 pp_string (buffer, " [return slot optimization]");
737 if (gimple_call_tail_p (gs))
738 pp_string (buffer, " [tail call]");
740 if (fn == NULL)
741 return;
743 /* Dump the arguments of _ITM_beginTransaction sanely. */
744 if (TREE_CODE (fn) == ADDR_EXPR)
745 fn = TREE_OPERAND (fn, 0);
746 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
747 pp_string (buffer, " [tm-clone]");
748 if (TREE_CODE (fn) == FUNCTION_DECL
749 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
750 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
751 && gimple_call_num_args (gs) > 0)
753 tree t = gimple_call_arg (gs, 0);
754 unsigned HOST_WIDE_INT props;
755 gcc_assert (TREE_CODE (t) == INTEGER_CST);
757 pp_string (buffer, " [ ");
759 /* Get the transaction code properties. */
760 props = TREE_INT_CST_LOW (t);
762 if (props & PR_INSTRUMENTEDCODE)
763 pp_string (buffer, "instrumentedCode ");
764 if (props & PR_UNINSTRUMENTEDCODE)
765 pp_string (buffer, "uninstrumentedCode ");
766 if (props & PR_HASNOXMMUPDATE)
767 pp_string (buffer, "hasNoXMMUpdate ");
768 if (props & PR_HASNOABORT)
769 pp_string (buffer, "hasNoAbort ");
770 if (props & PR_HASNOIRREVOCABLE)
771 pp_string (buffer, "hasNoIrrevocable ");
772 if (props & PR_DOESGOIRREVOCABLE)
773 pp_string (buffer, "doesGoIrrevocable ");
774 if (props & PR_HASNOSIMPLEREADS)
775 pp_string (buffer, "hasNoSimpleReads ");
776 if (props & PR_AWBARRIERSOMITTED)
777 pp_string (buffer, "awBarriersOmitted ");
778 if (props & PR_RARBARRIERSOMITTED)
779 pp_string (buffer, "RaRBarriersOmitted ");
780 if (props & PR_UNDOLOGCODE)
781 pp_string (buffer, "undoLogCode ");
782 if (props & PR_PREFERUNINSTRUMENTED)
783 pp_string (buffer, "preferUninstrumented ");
784 if (props & PR_EXCEPTIONBLOCK)
785 pp_string (buffer, "exceptionBlock ");
786 if (props & PR_HASELSE)
787 pp_string (buffer, "hasElse ");
788 if (props & PR_READONLY)
789 pp_string (buffer, "readOnly ");
791 pp_right_bracket (buffer);
796 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
797 pp_gimple_stmt_1. */
799 static void
800 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
801 int flags)
803 unsigned int i;
805 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
806 if (flags & TDF_RAW)
807 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
808 gimple_switch_index (gs));
809 else
811 pp_string (buffer, "switch (");
812 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
813 pp_string (buffer, ") <");
816 for (i = 0; i < gimple_switch_num_labels (gs); i++)
818 tree case_label = gimple_switch_label (gs, i);
819 gcc_checking_assert (case_label != NULL_TREE);
820 dump_generic_node (buffer, case_label, spc, flags, false);
821 pp_space (buffer);
822 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
823 if (i < gimple_switch_num_labels (gs) - 1)
824 pp_string (buffer, ", ");
826 pp_greater (buffer);
830 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
831 pp_gimple_stmt_1. */
833 static void
834 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
836 if (flags & TDF_RAW)
837 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
838 get_tree_code_name (gimple_cond_code (gs)),
839 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
840 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
841 else
843 if (!(flags & TDF_RHS_ONLY))
844 pp_string (buffer, "if (");
845 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
846 pp_space (buffer);
847 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
848 pp_space (buffer);
849 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
850 if (!(flags & TDF_RHS_ONLY))
852 pp_right_paren (buffer);
854 if (gimple_cond_true_label (gs))
856 pp_string (buffer, " goto ");
857 dump_generic_node (buffer, gimple_cond_true_label (gs),
858 spc, flags, false);
859 pp_semicolon (buffer);
861 if (gimple_cond_false_label (gs))
863 pp_string (buffer, " else goto ");
864 dump_generic_node (buffer, gimple_cond_false_label (gs),
865 spc, flags, false);
866 pp_semicolon (buffer);
873 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
874 spaces of indent. FLAGS specifies details to show in the dump (see
875 TDF_* in dumpfils.h). */
877 static void
878 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
880 tree label = gimple_label_label (gs);
881 if (flags & TDF_RAW)
882 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
883 else
885 dump_generic_node (buffer, label, spc, flags, false);
886 pp_colon (buffer);
888 if (DECL_NONLOCAL (label))
889 pp_string (buffer, " [non-local]");
890 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
891 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
894 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
895 spaces of indent. FLAGS specifies details to show in the dump (see
896 TDF_* in dumpfile.h). */
898 static void
899 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
901 tree label = gimple_goto_dest (gs);
902 if (flags & TDF_RAW)
903 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
904 else
905 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
909 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
910 spaces of indent. FLAGS specifies details to show in the dump (see
911 TDF_* in dumpfile.h). */
913 static void
914 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
916 if (flags & TDF_RAW)
917 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
918 else
919 pp_left_brace (buffer);
920 if (!(flags & TDF_SLIM))
922 tree var;
924 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
926 newline_and_indent (buffer, 2);
927 print_declaration (buffer, var, spc, flags);
929 if (gimple_bind_vars (gs))
930 pp_newline (buffer);
932 pp_newline (buffer);
933 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
934 newline_and_indent (buffer, spc);
935 if (flags & TDF_RAW)
936 pp_greater (buffer);
937 else
938 pp_right_brace (buffer);
942 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
943 indent. FLAGS specifies details to show in the dump (see TDF_* in
944 dumpfile.h). */
946 static void
947 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
949 if (flags & TDF_RAW)
951 const char *type;
952 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
953 type = "GIMPLE_TRY_CATCH";
954 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
955 type = "GIMPLE_TRY_FINALLY";
956 else
957 type = "UNKNOWN GIMPLE_TRY";
958 dump_gimple_fmt (buffer, spc, flags,
959 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
960 gimple_try_eval (gs), gimple_try_cleanup (gs));
962 else
964 pp_string (buffer, "try");
965 newline_and_indent (buffer, spc + 2);
966 pp_left_brace (buffer);
967 pp_newline (buffer);
969 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
970 newline_and_indent (buffer, spc + 2);
971 pp_right_brace (buffer);
973 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
975 newline_and_indent (buffer, spc);
976 pp_string (buffer, "catch");
977 newline_and_indent (buffer, spc + 2);
978 pp_left_brace (buffer);
980 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
982 newline_and_indent (buffer, spc);
983 pp_string (buffer, "finally");
984 newline_and_indent (buffer, spc + 2);
985 pp_left_brace (buffer);
987 else
988 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
990 pp_newline (buffer);
991 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
992 newline_and_indent (buffer, spc + 2);
993 pp_right_brace (buffer);
998 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
999 indent. FLAGS specifies details to show in the dump (see TDF_* in
1000 dumpfile.h). */
1002 static void
1003 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
1005 if (flags & TDF_RAW)
1006 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1007 gimple_catch_types (gs), gimple_catch_handler (gs));
1008 else
1009 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1010 gimple_catch_types (gs), gimple_catch_handler (gs));
1014 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1015 indent. FLAGS specifies details to show in the dump (see TDF_* in
1016 dumpfile.h). */
1018 static void
1019 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1020 int flags)
1022 if (flags & TDF_RAW)
1023 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1024 gimple_eh_filter_types (gs),
1025 gimple_eh_filter_failure (gs));
1026 else
1027 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1028 gimple_eh_filter_types (gs),
1029 gimple_eh_filter_failure (gs));
1033 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1035 static void
1036 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1037 geh_mnt *gs, int spc, int flags)
1039 if (flags & TDF_RAW)
1040 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1041 gimple_eh_must_not_throw_fndecl (gs));
1042 else
1043 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1044 gimple_eh_must_not_throw_fndecl (gs));
1048 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1049 indent. FLAGS specifies details to show in the dump (see TDF_* in
1050 dumpfile.h). */
1052 static void
1053 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1054 int flags)
1056 if (flags & TDF_RAW)
1057 dump_gimple_fmt (buffer, spc, flags,
1058 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1059 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1060 else
1061 dump_gimple_fmt (buffer, spc, flags,
1062 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1063 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1067 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1068 indent. FLAGS specifies details to show in the dump (see TDF_* in
1069 dumpfile.h). */
1071 static void
1072 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
1074 if (flags & TDF_RAW)
1075 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1076 gimple_resx_region (gs));
1077 else
1078 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1081 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1083 static void
1084 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int flags)
1086 if (flags & TDF_RAW)
1087 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1088 gimple_eh_dispatch_region (gs));
1089 else
1090 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1091 gimple_eh_dispatch_region (gs));
1094 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1095 of indent. FLAGS specifies details to show in the dump (see TDF_*
1096 in dumpfile.h). */
1098 static void
1099 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
1101 switch (gs->subcode)
1103 case GIMPLE_DEBUG_BIND:
1104 if (flags & TDF_RAW)
1105 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1106 gimple_debug_bind_get_var (gs),
1107 gimple_debug_bind_get_value (gs));
1108 else
1109 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1110 gimple_debug_bind_get_var (gs),
1111 gimple_debug_bind_get_value (gs));
1112 break;
1114 case GIMPLE_DEBUG_SOURCE_BIND:
1115 if (flags & TDF_RAW)
1116 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1117 gimple_debug_source_bind_get_var (gs),
1118 gimple_debug_source_bind_get_value (gs));
1119 else
1120 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1121 gimple_debug_source_bind_get_var (gs),
1122 gimple_debug_source_bind_get_value (gs));
1123 break;
1125 default:
1126 gcc_unreachable ();
1130 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1131 static void
1132 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
1134 size_t i;
1136 if (flags & TDF_RAW)
1138 const char *kind;
1139 switch (gimple_omp_for_kind (gs))
1141 case GF_OMP_FOR_KIND_FOR:
1142 kind = "";
1143 break;
1144 case GF_OMP_FOR_KIND_DISTRIBUTE:
1145 kind = " distribute";
1146 break;
1147 case GF_OMP_FOR_KIND_CILKFOR:
1148 kind = " _Cilk_for";
1149 break;
1150 case GF_OMP_FOR_KIND_OACC_LOOP:
1151 kind = " oacc_loop";
1152 break;
1153 case GF_OMP_FOR_KIND_SIMD:
1154 kind = " simd";
1155 break;
1156 case GF_OMP_FOR_KIND_CILKSIMD:
1157 kind = " cilksimd";
1158 break;
1159 default:
1160 gcc_unreachable ();
1162 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1163 kind, gimple_omp_body (gs));
1164 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1165 dump_gimple_fmt (buffer, spc, flags, " >,");
1166 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1167 dump_gimple_fmt (buffer, spc, flags,
1168 "%+%T, %T, %T, %s, %T,%n",
1169 gimple_omp_for_index (gs, i),
1170 gimple_omp_for_initial (gs, i),
1171 gimple_omp_for_final (gs, i),
1172 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1173 gimple_omp_for_incr (gs, i));
1174 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1175 gimple_omp_for_pre_body (gs));
1177 else
1179 switch (gimple_omp_for_kind (gs))
1181 case GF_OMP_FOR_KIND_FOR:
1182 pp_string (buffer, "#pragma omp for");
1183 break;
1184 case GF_OMP_FOR_KIND_DISTRIBUTE:
1185 pp_string (buffer, "#pragma omp distribute");
1186 break;
1187 case GF_OMP_FOR_KIND_CILKFOR:
1188 break;
1189 case GF_OMP_FOR_KIND_OACC_LOOP:
1190 pp_string (buffer, "#pragma acc loop");
1191 break;
1192 case GF_OMP_FOR_KIND_SIMD:
1193 pp_string (buffer, "#pragma omp simd");
1194 break;
1195 case GF_OMP_FOR_KIND_CILKSIMD:
1196 pp_string (buffer, "#pragma simd");
1197 break;
1198 default:
1199 gcc_unreachable ();
1201 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1202 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1203 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1205 if (i)
1206 spc += 2;
1207 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1208 pp_string (buffer, "_Cilk_for (");
1209 else
1211 newline_and_indent (buffer, spc);
1212 pp_string (buffer, "for (");
1214 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1215 flags, false);
1216 pp_string (buffer, " = ");
1217 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1218 flags, false);
1219 pp_string (buffer, "; ");
1221 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1222 flags, false);
1223 pp_space (buffer);
1224 switch (gimple_omp_for_cond (gs, i))
1226 case LT_EXPR:
1227 pp_less (buffer);
1228 break;
1229 case GT_EXPR:
1230 pp_greater (buffer);
1231 break;
1232 case LE_EXPR:
1233 pp_less_equal (buffer);
1234 break;
1235 case GE_EXPR:
1236 pp_greater_equal (buffer);
1237 break;
1238 case NE_EXPR:
1239 pp_string (buffer, "!=");
1240 break;
1241 default:
1242 gcc_unreachable ();
1244 pp_space (buffer);
1245 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1246 flags, false);
1247 pp_string (buffer, "; ");
1249 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1250 flags, false);
1251 pp_string (buffer, " = ");
1252 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1253 flags, false);
1254 pp_right_paren (buffer);
1257 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1259 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1260 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1261 newline_and_indent (buffer, spc + 2);
1262 pp_left_brace (buffer);
1263 pp_newline (buffer);
1264 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1265 newline_and_indent (buffer, spc + 2);
1266 pp_right_brace (buffer);
1271 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1273 static void
1274 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1275 int spc, int flags)
1277 if (flags & TDF_RAW)
1279 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1280 gimple_omp_continue_control_def (gs),
1281 gimple_omp_continue_control_use (gs));
1283 else
1285 pp_string (buffer, "#pragma omp continue (");
1286 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1287 spc, flags, false);
1288 pp_comma (buffer);
1289 pp_space (buffer);
1290 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1291 spc, flags, false);
1292 pp_right_paren (buffer);
1296 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1298 static void
1299 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1300 int spc, int flags)
1302 if (flags & TDF_RAW)
1304 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1305 gimple_omp_body (gs));
1306 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1307 dump_gimple_fmt (buffer, spc, flags, " >");
1309 else
1311 pp_string (buffer, "#pragma omp single");
1312 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1313 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1315 newline_and_indent (buffer, spc + 2);
1316 pp_left_brace (buffer);
1317 pp_newline (buffer);
1318 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1319 newline_and_indent (buffer, spc + 2);
1320 pp_right_brace (buffer);
1325 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1327 static void
1328 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1329 int spc, int flags)
1331 const char *kind;
1332 switch (gimple_omp_target_kind (gs))
1334 case GF_OMP_TARGET_KIND_REGION:
1335 kind = "";
1336 break;
1337 case GF_OMP_TARGET_KIND_DATA:
1338 kind = " data";
1339 break;
1340 case GF_OMP_TARGET_KIND_UPDATE:
1341 kind = " update";
1342 break;
1343 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1344 kind = " oacc_kernels";
1345 break;
1346 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1347 kind = " oacc_parallel";
1348 break;
1349 case GF_OMP_TARGET_KIND_OACC_DATA:
1350 kind = " oacc_data";
1351 break;
1352 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1353 kind = " oacc_update";
1354 break;
1355 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1356 kind = " oacc_enter_exit_data";
1357 break;
1358 default:
1359 gcc_unreachable ();
1361 if (flags & TDF_RAW)
1363 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1364 kind, gimple_omp_body (gs));
1365 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1366 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1367 gimple_omp_target_child_fn (gs),
1368 gimple_omp_target_data_arg (gs));
1370 else
1372 pp_string (buffer, "#pragma omp target");
1373 pp_string (buffer, kind);
1374 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1375 if (gimple_omp_target_child_fn (gs))
1377 pp_string (buffer, " [child fn: ");
1378 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1379 spc, flags, false);
1380 pp_string (buffer, " (");
1381 if (gimple_omp_target_data_arg (gs))
1382 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1383 spc, flags, false);
1384 else
1385 pp_string (buffer, "???");
1386 pp_string (buffer, ")]");
1388 gimple_seq body = gimple_omp_body (gs);
1389 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1391 newline_and_indent (buffer, spc + 2);
1392 pp_left_brace (buffer);
1393 pp_newline (buffer);
1394 dump_gimple_seq (buffer, body, spc + 4, flags);
1395 newline_and_indent (buffer, spc + 2);
1396 pp_right_brace (buffer);
1398 else if (body)
1400 pp_newline (buffer);
1401 dump_gimple_seq (buffer, body, spc + 2, flags);
1406 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1408 static void
1409 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1410 int flags)
1412 if (flags & TDF_RAW)
1414 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1415 gimple_omp_body (gs));
1416 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1417 dump_gimple_fmt (buffer, spc, flags, " >");
1419 else
1421 pp_string (buffer, "#pragma omp teams");
1422 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1423 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1425 newline_and_indent (buffer, spc + 2);
1426 pp_character (buffer, '{');
1427 pp_newline (buffer);
1428 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1429 newline_and_indent (buffer, spc + 2);
1430 pp_character (buffer, '}');
1435 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1437 static void
1438 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1439 int spc, int flags)
1441 if (flags & TDF_RAW)
1443 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1444 gimple_omp_body (gs));
1445 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1446 dump_gimple_fmt (buffer, spc, flags, " >");
1448 else
1450 pp_string (buffer, "#pragma omp sections");
1451 if (gimple_omp_sections_control (gs))
1453 pp_string (buffer, " <");
1454 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1455 flags, false);
1456 pp_greater (buffer);
1458 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1459 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1461 newline_and_indent (buffer, spc + 2);
1462 pp_left_brace (buffer);
1463 pp_newline (buffer);
1464 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1465 newline_and_indent (buffer, spc + 2);
1466 pp_right_brace (buffer);
1471 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1472 pretty_printer BUFFER. */
1474 static void
1475 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1477 if (flags & TDF_RAW)
1478 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1479 gimple_omp_body (gs));
1480 else
1482 switch (gimple_code (gs))
1484 case GIMPLE_OMP_MASTER:
1485 pp_string (buffer, "#pragma omp master");
1486 break;
1487 case GIMPLE_OMP_TASKGROUP:
1488 pp_string (buffer, "#pragma omp taskgroup");
1489 break;
1490 case GIMPLE_OMP_ORDERED:
1491 pp_string (buffer, "#pragma omp ordered");
1492 break;
1493 case GIMPLE_OMP_SECTION:
1494 pp_string (buffer, "#pragma omp section");
1495 break;
1496 default:
1497 gcc_unreachable ();
1499 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1501 newline_and_indent (buffer, spc + 2);
1502 pp_left_brace (buffer);
1503 pp_newline (buffer);
1504 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1505 newline_and_indent (buffer, spc + 2);
1506 pp_right_brace (buffer);
1511 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1513 static void
1514 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1515 int spc, int flags)
1517 if (flags & TDF_RAW)
1518 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1519 gimple_omp_body (gs));
1520 else
1522 pp_string (buffer, "#pragma omp critical");
1523 if (gimple_omp_critical_name (gs))
1525 pp_string (buffer, " (");
1526 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1527 flags, false);
1528 pp_right_paren (buffer);
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_RETURN tuple on the pretty_printer BUFFER. */
1544 static void
1545 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1547 if (flags & TDF_RAW)
1549 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1550 (int) gimple_omp_return_nowait_p (gs));
1551 if (gimple_omp_return_lhs (gs))
1552 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1553 gimple_omp_return_lhs (gs));
1554 else
1555 dump_gimple_fmt (buffer, spc, flags, ">");
1557 else
1559 pp_string (buffer, "#pragma omp return");
1560 if (gimple_omp_return_nowait_p (gs))
1561 pp_string (buffer, "(nowait)");
1562 if (gimple_omp_return_lhs (gs))
1564 pp_string (buffer, " (set ");
1565 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1566 spc, flags, false);
1567 pp_character (buffer, ')');
1572 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1574 static void
1575 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1576 int spc, int flags)
1578 unsigned subcode = gimple_transaction_subcode (gs);
1580 if (flags & TDF_RAW)
1582 dump_gimple_fmt (buffer, spc, flags,
1583 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1584 gs, subcode, gimple_transaction_label (gs),
1585 gimple_transaction_body (gs));
1587 else
1589 if (subcode & GTMA_IS_OUTER)
1590 pp_string (buffer, "__transaction_atomic [[outer]]");
1591 else if (subcode & GTMA_IS_RELAXED)
1592 pp_string (buffer, "__transaction_relaxed");
1593 else
1594 pp_string (buffer, "__transaction_atomic");
1595 subcode &= ~GTMA_DECLARATION_MASK;
1597 if (subcode || gimple_transaction_label (gs))
1599 pp_string (buffer, " //");
1600 if (gimple_transaction_label (gs))
1602 pp_string (buffer, " LABEL=");
1603 dump_generic_node (buffer, gimple_transaction_label (gs),
1604 spc, flags, false);
1606 if (subcode)
1608 pp_string (buffer, " SUBCODE=[ ");
1609 if (subcode & GTMA_HAVE_ABORT)
1611 pp_string (buffer, "GTMA_HAVE_ABORT ");
1612 subcode &= ~GTMA_HAVE_ABORT;
1614 if (subcode & GTMA_HAVE_LOAD)
1616 pp_string (buffer, "GTMA_HAVE_LOAD ");
1617 subcode &= ~GTMA_HAVE_LOAD;
1619 if (subcode & GTMA_HAVE_STORE)
1621 pp_string (buffer, "GTMA_HAVE_STORE ");
1622 subcode &= ~GTMA_HAVE_STORE;
1624 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1626 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1627 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1629 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1631 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1632 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1634 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1636 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1637 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1639 if (subcode)
1640 pp_printf (buffer, "0x%x ", subcode);
1641 pp_right_bracket (buffer);
1645 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1647 newline_and_indent (buffer, spc + 2);
1648 pp_left_brace (buffer);
1649 pp_newline (buffer);
1650 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1651 spc + 4, flags);
1652 newline_and_indent (buffer, spc + 2);
1653 pp_right_brace (buffer);
1658 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1659 indent. FLAGS specifies details to show in the dump (see TDF_* in
1660 dumpfile.h). */
1662 static void
1663 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
1665 unsigned int i, n, f, fields;
1667 if (flags & TDF_RAW)
1669 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1670 gimple_asm_string (gs));
1672 n = gimple_asm_noutputs (gs);
1673 if (n)
1675 newline_and_indent (buffer, spc + 2);
1676 pp_string (buffer, "OUTPUT: ");
1677 for (i = 0; i < n; i++)
1679 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1680 spc, flags, false);
1681 if (i < n - 1)
1682 pp_string (buffer, ", ");
1686 n = gimple_asm_ninputs (gs);
1687 if (n)
1689 newline_and_indent (buffer, spc + 2);
1690 pp_string (buffer, "INPUT: ");
1691 for (i = 0; i < n; i++)
1693 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1694 spc, flags, false);
1695 if (i < n - 1)
1696 pp_string (buffer, ", ");
1700 n = gimple_asm_nclobbers (gs);
1701 if (n)
1703 newline_and_indent (buffer, spc + 2);
1704 pp_string (buffer, "CLOBBER: ");
1705 for (i = 0; i < n; i++)
1707 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1708 spc, flags, false);
1709 if (i < n - 1)
1710 pp_string (buffer, ", ");
1714 n = gimple_asm_nlabels (gs);
1715 if (n)
1717 newline_and_indent (buffer, spc + 2);
1718 pp_string (buffer, "LABEL: ");
1719 for (i = 0; i < n; i++)
1721 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1722 spc, flags, false);
1723 if (i < n - 1)
1724 pp_string (buffer, ", ");
1728 newline_and_indent (buffer, spc);
1729 pp_greater (buffer);
1731 else
1733 pp_string (buffer, "__asm__");
1734 if (gimple_asm_volatile_p (gs))
1735 pp_string (buffer, " __volatile__");
1736 if (gimple_asm_nlabels (gs))
1737 pp_string (buffer, " goto");
1738 pp_string (buffer, "(\"");
1739 pp_string (buffer, gimple_asm_string (gs));
1740 pp_string (buffer, "\"");
1742 if (gimple_asm_nlabels (gs))
1743 fields = 4;
1744 else if (gimple_asm_nclobbers (gs))
1745 fields = 3;
1746 else if (gimple_asm_ninputs (gs))
1747 fields = 2;
1748 else if (gimple_asm_noutputs (gs))
1749 fields = 1;
1750 else
1751 fields = 0;
1753 for (f = 0; f < fields; ++f)
1755 pp_string (buffer, " : ");
1757 switch (f)
1759 case 0:
1760 n = gimple_asm_noutputs (gs);
1761 for (i = 0; i < n; i++)
1763 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1764 spc, flags, false);
1765 if (i < n - 1)
1766 pp_string (buffer, ", ");
1768 break;
1770 case 1:
1771 n = gimple_asm_ninputs (gs);
1772 for (i = 0; i < n; i++)
1774 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1775 spc, flags, false);
1776 if (i < n - 1)
1777 pp_string (buffer, ", ");
1779 break;
1781 case 2:
1782 n = gimple_asm_nclobbers (gs);
1783 for (i = 0; i < n; i++)
1785 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1786 spc, flags, false);
1787 if (i < n - 1)
1788 pp_string (buffer, ", ");
1790 break;
1792 case 3:
1793 n = gimple_asm_nlabels (gs);
1794 for (i = 0; i < n; i++)
1796 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1797 spc, flags, false);
1798 if (i < n - 1)
1799 pp_string (buffer, ", ");
1801 break;
1803 default:
1804 gcc_unreachable ();
1808 pp_string (buffer, ");");
1812 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1813 SPC spaces of indent. */
1815 static void
1816 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1818 if (TREE_CODE (node) != SSA_NAME)
1819 return;
1821 if (POINTER_TYPE_P (TREE_TYPE (node))
1822 && SSA_NAME_PTR_INFO (node))
1824 unsigned int align, misalign;
1825 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1826 pp_string (buffer, "# PT = ");
1827 pp_points_to_solution (buffer, &pi->pt);
1828 newline_and_indent (buffer, spc);
1829 if (get_ptr_info_alignment (pi, &align, &misalign))
1831 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1832 newline_and_indent (buffer, spc);
1836 if (!POINTER_TYPE_P (TREE_TYPE (node))
1837 && SSA_NAME_RANGE_INFO (node))
1839 wide_int min, max, nonzero_bits;
1840 value_range_type range_type = get_range_info (node, &min, &max);
1842 if (range_type == VR_VARYING)
1843 pp_printf (buffer, "# RANGE VR_VARYING");
1844 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1846 pp_printf (buffer, "# RANGE ");
1847 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1848 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
1849 pp_printf (buffer, ", ");
1850 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
1851 pp_printf (buffer, "]");
1853 nonzero_bits = get_nonzero_bits (node);
1854 if (nonzero_bits != -1)
1856 pp_string (buffer, " NONZERO ");
1857 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
1859 newline_and_indent (buffer, spc);
1864 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1865 The caller is responsible for calling pp_flush on BUFFER to finalize
1866 pretty printer. If COMMENT is true, print this after #. */
1868 static void
1869 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
1870 int flags)
1872 size_t i;
1873 tree lhs = gimple_phi_result (phi);
1875 if (flags & TDF_ALIAS)
1876 dump_ssaname_info (buffer, lhs, spc);
1878 if (comment)
1879 pp_string (buffer, "# ");
1881 if (flags & TDF_RAW)
1882 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1883 gimple_phi_result (phi));
1884 else
1886 dump_generic_node (buffer, lhs, spc, flags, false);
1887 pp_string (buffer, " = PHI <");
1889 for (i = 0; i < gimple_phi_num_args (phi); i++)
1891 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1892 dump_location (buffer, gimple_phi_arg_location (phi, i));
1893 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1894 false);
1895 pp_left_paren (buffer);
1896 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1897 pp_right_paren (buffer);
1898 if (i < gimple_phi_num_args (phi) - 1)
1899 pp_string (buffer, ", ");
1901 pp_greater (buffer);
1905 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1906 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1907 dumpfile.h). */
1909 static void
1910 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
1911 int spc, int flags)
1913 if (flags & TDF_RAW)
1915 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1916 gimple_omp_body (gs));
1917 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1918 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1919 gimple_omp_parallel_child_fn (gs),
1920 gimple_omp_parallel_data_arg (gs));
1922 else
1924 gimple_seq body;
1925 pp_string (buffer, "#pragma omp parallel");
1926 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1927 if (gimple_omp_parallel_child_fn (gs))
1929 pp_string (buffer, " [child fn: ");
1930 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1931 spc, flags, false);
1932 pp_string (buffer, " (");
1933 if (gimple_omp_parallel_data_arg (gs))
1934 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1935 spc, flags, false);
1936 else
1937 pp_string (buffer, "???");
1938 pp_string (buffer, ")]");
1940 body = gimple_omp_body (gs);
1941 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1943 newline_and_indent (buffer, spc + 2);
1944 pp_left_brace (buffer);
1945 pp_newline (buffer);
1946 dump_gimple_seq (buffer, body, spc + 4, flags);
1947 newline_and_indent (buffer, spc + 2);
1948 pp_right_brace (buffer);
1950 else if (body)
1952 pp_newline (buffer);
1953 dump_gimple_seq (buffer, body, spc + 2, flags);
1959 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1960 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1961 dumpfile.h). */
1963 static void
1964 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
1965 int flags)
1967 if (flags & TDF_RAW)
1969 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1970 gimple_omp_body (gs));
1971 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1972 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1973 gimple_omp_task_child_fn (gs),
1974 gimple_omp_task_data_arg (gs),
1975 gimple_omp_task_copy_fn (gs),
1976 gimple_omp_task_arg_size (gs),
1977 gimple_omp_task_arg_size (gs));
1979 else
1981 gimple_seq body;
1982 pp_string (buffer, "#pragma omp task");
1983 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1984 if (gimple_omp_task_child_fn (gs))
1986 pp_string (buffer, " [child fn: ");
1987 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1988 spc, flags, false);
1989 pp_string (buffer, " (");
1990 if (gimple_omp_task_data_arg (gs))
1991 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1992 spc, flags, false);
1993 else
1994 pp_string (buffer, "???");
1995 pp_string (buffer, ")]");
1997 body = gimple_omp_body (gs);
1998 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2000 newline_and_indent (buffer, spc + 2);
2001 pp_left_brace (buffer);
2002 pp_newline (buffer);
2003 dump_gimple_seq (buffer, body, spc + 4, flags);
2004 newline_and_indent (buffer, spc + 2);
2005 pp_right_brace (buffer);
2007 else if (body)
2009 pp_newline (buffer);
2010 dump_gimple_seq (buffer, body, spc + 2, flags);
2016 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2017 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2018 in dumpfile.h). */
2020 static void
2021 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2022 int spc, int flags)
2024 if (flags & TDF_RAW)
2026 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2027 gimple_omp_atomic_load_lhs (gs),
2028 gimple_omp_atomic_load_rhs (gs));
2030 else
2032 pp_string (buffer, "#pragma omp atomic_load");
2033 if (gimple_omp_atomic_seq_cst_p (gs))
2034 pp_string (buffer, " seq_cst");
2035 if (gimple_omp_atomic_need_value_p (gs))
2036 pp_string (buffer, " [needed]");
2037 newline_and_indent (buffer, spc + 2);
2038 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2039 spc, flags, false);
2040 pp_space (buffer);
2041 pp_equal (buffer);
2042 pp_space (buffer);
2043 pp_star (buffer);
2044 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2045 spc, flags, false);
2049 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2050 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2051 in dumpfile.h). */
2053 static void
2054 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2055 gomp_atomic_store *gs, int spc, int flags)
2057 if (flags & TDF_RAW)
2059 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2060 gimple_omp_atomic_store_val (gs));
2062 else
2064 pp_string (buffer, "#pragma omp atomic_store ");
2065 if (gimple_omp_atomic_seq_cst_p (gs))
2066 pp_string (buffer, "seq_cst ");
2067 if (gimple_omp_atomic_need_value_p (gs))
2068 pp_string (buffer, "[needed] ");
2069 pp_left_paren (buffer);
2070 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2071 spc, flags, false);
2072 pp_right_paren (buffer);
2077 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2078 FLAGS are as in pp_gimple_stmt_1. */
2080 static void
2081 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
2083 tree vdef = gimple_vdef (gs);
2084 tree vuse = gimple_vuse (gs);
2086 if (vdef != NULL_TREE)
2088 pp_string (buffer, "# ");
2089 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2090 pp_string (buffer, " = VDEF <");
2091 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2092 pp_greater (buffer);
2093 newline_and_indent (buffer, spc);
2095 else if (vuse != NULL_TREE)
2097 pp_string (buffer, "# VUSE <");
2098 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2099 pp_greater (buffer);
2100 newline_and_indent (buffer, spc);
2105 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2106 spaces of indent. FLAGS specifies details to show in the dump (see
2107 TDF_* in dumpfile.h). The caller is responsible for calling
2108 pp_flush on BUFFER to finalize the pretty printer. */
2110 void
2111 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
2113 if (!gs)
2114 return;
2116 if (flags & TDF_STMTADDR)
2117 pp_printf (buffer, "<&%p> ", (void *) gs);
2119 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2120 dump_location (buffer, gimple_location (gs));
2122 if (flags & TDF_EH)
2124 int lp_nr = lookup_stmt_eh_lp (gs);
2125 if (lp_nr > 0)
2126 pp_printf (buffer, "[LP %d] ", lp_nr);
2127 else if (lp_nr < 0)
2128 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2131 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2132 && gimple_has_mem_ops (gs))
2133 dump_gimple_mem_ops (buffer, gs, spc, flags);
2135 if (gimple_has_lhs (gs)
2136 && (flags & TDF_ALIAS))
2137 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2139 switch (gimple_code (gs))
2141 case GIMPLE_ASM:
2142 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2143 break;
2145 case GIMPLE_ASSIGN:
2146 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2147 break;
2149 case GIMPLE_BIND:
2150 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2151 break;
2153 case GIMPLE_CALL:
2154 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2155 break;
2157 case GIMPLE_COND:
2158 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2159 break;
2161 case GIMPLE_LABEL:
2162 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2163 break;
2165 case GIMPLE_GOTO:
2166 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2167 break;
2169 case GIMPLE_NOP:
2170 pp_string (buffer, "GIMPLE_NOP");
2171 break;
2173 case GIMPLE_RETURN:
2174 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2175 break;
2177 case GIMPLE_SWITCH:
2178 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2179 break;
2181 case GIMPLE_TRY:
2182 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2183 break;
2185 case GIMPLE_PHI:
2186 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2187 break;
2189 case GIMPLE_OMP_PARALLEL:
2190 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2191 flags);
2192 break;
2194 case GIMPLE_OMP_TASK:
2195 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2196 break;
2198 case GIMPLE_OMP_ATOMIC_LOAD:
2199 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2200 spc, flags);
2201 break;
2203 case GIMPLE_OMP_ATOMIC_STORE:
2204 dump_gimple_omp_atomic_store (buffer,
2205 as_a <gomp_atomic_store *> (gs),
2206 spc, flags);
2207 break;
2209 case GIMPLE_OMP_FOR:
2210 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2211 break;
2213 case GIMPLE_OMP_CONTINUE:
2214 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2215 flags);
2216 break;
2218 case GIMPLE_OMP_SINGLE:
2219 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2220 flags);
2221 break;
2223 case GIMPLE_OMP_TARGET:
2224 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2225 flags);
2226 break;
2228 case GIMPLE_OMP_TEAMS:
2229 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2230 flags);
2231 break;
2233 case GIMPLE_OMP_RETURN:
2234 dump_gimple_omp_return (buffer, gs, spc, flags);
2235 break;
2237 case GIMPLE_OMP_SECTIONS:
2238 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2239 spc, flags);
2240 break;
2242 case GIMPLE_OMP_SECTIONS_SWITCH:
2243 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2244 break;
2246 case GIMPLE_OMP_MASTER:
2247 case GIMPLE_OMP_TASKGROUP:
2248 case GIMPLE_OMP_ORDERED:
2249 case GIMPLE_OMP_SECTION:
2250 dump_gimple_omp_block (buffer, gs, spc, flags);
2251 break;
2253 case GIMPLE_OMP_CRITICAL:
2254 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2255 flags);
2256 break;
2258 case GIMPLE_CATCH:
2259 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2260 break;
2262 case GIMPLE_EH_FILTER:
2263 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2264 break;
2266 case GIMPLE_EH_MUST_NOT_THROW:
2267 dump_gimple_eh_must_not_throw (buffer,
2268 as_a <geh_mnt *> (gs),
2269 spc, flags);
2270 break;
2272 case GIMPLE_EH_ELSE:
2273 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2274 break;
2276 case GIMPLE_RESX:
2277 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2278 break;
2280 case GIMPLE_EH_DISPATCH:
2281 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2282 flags);
2283 break;
2285 case GIMPLE_DEBUG:
2286 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2287 break;
2289 case GIMPLE_PREDICT:
2290 pp_string (buffer, "// predicted ");
2291 if (gimple_predict_outcome (gs))
2292 pp_string (buffer, "likely by ");
2293 else
2294 pp_string (buffer, "unlikely by ");
2295 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2296 pp_string (buffer, " predictor.");
2297 break;
2299 case GIMPLE_TRANSACTION:
2300 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2301 flags);
2302 break;
2304 default:
2305 GIMPLE_NIY;
2310 /* Dumps header of basic block BB to OUTF indented by INDENT
2311 spaces and details described by flags. */
2313 static void
2314 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2316 if (flags & TDF_BLOCKS)
2318 if (flags & TDF_LINENO)
2320 gimple_stmt_iterator gsi;
2322 if (flags & TDF_COMMENT)
2323 fputs (";; ", outf);
2325 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2326 if (!is_gimple_debug (gsi_stmt (gsi))
2327 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2329 fprintf (outf, "%*sstarting at line %d",
2330 indent, "", get_lineno (gsi_stmt (gsi)));
2331 break;
2333 if (bb->discriminator)
2334 fprintf (outf, ", discriminator %i", bb->discriminator);
2335 fputc ('\n', outf);
2338 else
2340 gimple stmt = first_stmt (bb);
2341 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2342 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2347 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2348 spaces. */
2350 static void
2351 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2352 basic_block bb ATTRIBUTE_UNUSED,
2353 int indent ATTRIBUTE_UNUSED,
2354 int flags ATTRIBUTE_UNUSED)
2356 /* There is currently no GIMPLE-specific basic block info to dump. */
2357 return;
2361 /* Dump PHI nodes of basic block BB to BUFFER with details described
2362 by FLAGS and indented by INDENT spaces. */
2364 static void
2365 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2367 gphi_iterator i;
2369 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2371 gphi *phi = i.phi ();
2372 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2374 INDENT (indent);
2375 dump_gimple_phi (buffer, phi, indent, true, flags);
2376 pp_newline (buffer);
2382 /* Dump jump to basic block BB that is represented implicitly in the cfg
2383 to BUFFER. */
2385 static void
2386 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2388 gimple stmt;
2390 stmt = first_stmt (bb);
2392 pp_string (buffer, "goto <bb ");
2393 pp_decimal_int (buffer, bb->index);
2394 pp_greater (buffer);
2395 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2397 pp_string (buffer, " (");
2398 dump_generic_node (buffer,
2399 gimple_label_label (as_a <glabel *> (stmt)),
2400 0, 0, false);
2401 pp_right_paren (buffer);
2402 pp_semicolon (buffer);
2404 else
2405 pp_semicolon (buffer);
2409 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2410 by INDENT spaces, with details given by FLAGS. */
2412 static void
2413 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2414 int flags)
2416 edge e;
2417 gimple stmt;
2419 stmt = last_stmt (bb);
2421 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2423 edge true_edge, false_edge;
2425 /* When we are emitting the code or changing CFG, it is possible that
2426 the edges are not yet created. When we are using debug_bb in such
2427 a situation, we do not want it to crash. */
2428 if (EDGE_COUNT (bb->succs) != 2)
2429 return;
2430 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2432 INDENT (indent + 2);
2433 pp_cfg_jump (buffer, true_edge->dest);
2434 newline_and_indent (buffer, indent);
2435 pp_string (buffer, "else");
2436 newline_and_indent (buffer, indent + 2);
2437 pp_cfg_jump (buffer, false_edge->dest);
2438 pp_newline (buffer);
2439 return;
2442 /* If there is a fallthru edge, we may need to add an artificial
2443 goto to the dump. */
2444 e = find_fallthru_edge (bb->succs);
2446 if (e && e->dest != bb->next_bb)
2448 INDENT (indent);
2450 if ((flags & TDF_LINENO)
2451 && e->goto_locus != UNKNOWN_LOCATION)
2452 dump_location (buffer, e->goto_locus);
2454 pp_cfg_jump (buffer, e->dest);
2455 pp_newline (buffer);
2460 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2461 indented by INDENT spaces. */
2463 static void
2464 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2465 int flags)
2467 gimple_stmt_iterator gsi;
2468 gimple stmt;
2469 int label_indent = indent - 2;
2471 if (label_indent < 0)
2472 label_indent = 0;
2474 dump_phi_nodes (buffer, bb, indent, flags);
2476 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2478 int curr_indent;
2480 stmt = gsi_stmt (gsi);
2482 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2484 INDENT (curr_indent);
2485 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2486 pp_newline_and_flush (buffer);
2487 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2488 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2489 pp_buffer (buffer)->stream, stmt);
2492 dump_implicit_edges (buffer, bb, indent, flags);
2493 pp_flush (buffer);
2497 /* Dumps basic block BB to FILE with details described by FLAGS and
2498 indented by INDENT spaces. */
2500 void
2501 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2503 dump_gimple_bb_header (file, bb, indent, flags);
2504 if (bb->index >= NUM_FIXED_BLOCKS)
2506 pretty_printer buffer;
2507 pp_needs_newline (&buffer) = true;
2508 buffer.buffer->stream = file;
2509 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2511 dump_gimple_bb_footer (file, bb, indent, flags);
2514 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2515 no indentation, for use as a label of a DOT graph record-node.
2516 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2517 histogram dumping doesn't know about pretty-printers. */
2519 void
2520 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2522 pp_printf (pp, "<bb %d>:\n", bb->index);
2523 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2525 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2526 gsi_next (&gsi))
2528 gphi *phi = gsi.phi ();
2529 if (!virtual_operand_p (gimple_phi_result (phi))
2530 || (dump_flags & TDF_VOPS))
2532 pp_bar (pp);
2533 pp_write_text_to_stream (pp);
2534 pp_string (pp, "# ");
2535 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2536 pp_newline (pp);
2537 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2541 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2542 gsi_next (&gsi))
2544 gimple stmt = gsi_stmt (gsi);
2545 pp_bar (pp);
2546 pp_write_text_to_stream (pp);
2547 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2548 pp_newline (pp);
2549 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2551 dump_implicit_edges (pp, bb, 0, dump_flags);
2552 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);