OpenACC acc_on_device.
[official-gcc.git] / gcc / gimple-pretty-print.c
blob2c8c5a3dfbb9727b9aa3519d0d55bf45db165dbf
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2014 Free Software Foundation, Inc.
3 Contributed by Aldy Hernandez <aldyh@redhat.com> and
4 Diego Novillo <dnovillo@google.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "tree.h"
27 #include "stringpool.h"
28 #include "diagnostic.h"
29 #include "gimple-pretty-print.h"
30 #include "hashtab.h"
31 #include "bitmap.h"
32 #include "basic-block.h"
33 #include "tree-ssa-alias.h"
34 #include "internal-fn.h"
35 #include "tree-eh.h"
36 #include "gimple-expr.h"
37 #include "is-a.h"
38 #include "gimple.h"
39 #include "gimple-iterator.h"
40 #include "gimple-ssa.h"
41 #include "cgraph.h"
42 #include "tree-cfg.h"
43 #include "tree-ssanames.h"
44 #include "dumpfile.h" /* for dump_flags */
45 #include "value-prof.h"
46 #include "trans-mem.h"
48 #define INDENT(SPACE) \
49 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
51 #define GIMPLE_NIY do_niy (buffer,gs)
53 /* Try to print on BUFFER a default message for the unrecognized
54 gimple statement GS. */
56 static void
57 do_niy (pretty_printer *buffer, gimple gs)
59 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
60 gimple_code_name[(int) gimple_code (gs)]);
64 /* Emit a newline and SPC indentation spaces to BUFFER. */
66 static void
67 newline_and_indent (pretty_printer *buffer, int spc)
69 pp_newline (buffer);
70 INDENT (spc);
74 /* Print the GIMPLE statement GS on stderr. */
76 DEBUG_FUNCTION void
77 debug_gimple_stmt (gimple gs)
79 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
83 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
84 FLAGS as in pp_gimple_stmt_1. */
86 void
87 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
89 pretty_printer buffer;
90 pp_needs_newline (&buffer) = true;
91 buffer.buffer->stream = file;
92 pp_gimple_stmt_1 (&buffer, g, spc, flags);
93 pp_newline_and_flush (&buffer);
96 DEBUG_FUNCTION void
97 debug (gimple_statement_base &ref)
99 print_gimple_stmt (stderr, &ref, 0, 0);
102 DEBUG_FUNCTION void
103 debug (gimple_statement_base *ptr)
105 if (ptr)
106 debug (*ptr);
107 else
108 fprintf (stderr, "<nil>\n");
112 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
113 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
114 of the statement. */
116 void
117 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
119 flags |= TDF_RHS_ONLY;
120 pretty_printer buffer;
121 pp_needs_newline (&buffer) = true;
122 buffer.buffer->stream = file;
123 pp_gimple_stmt_1 (&buffer, g, spc, flags);
124 pp_flush (&buffer);
128 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
129 spaces and FLAGS as in pp_gimple_stmt_1.
130 The caller is responsible for calling pp_flush on BUFFER to finalize
131 the pretty printer. */
133 static void
134 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
136 gimple_stmt_iterator i;
138 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
140 gimple gs = gsi_stmt (i);
141 INDENT (spc);
142 pp_gimple_stmt_1 (buffer, gs, spc, flags);
143 if (!gsi_one_before_end_p (i))
144 pp_newline (buffer);
149 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
150 FLAGS as in pp_gimple_stmt_1. */
152 void
153 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
155 pretty_printer buffer;
156 pp_needs_newline (&buffer) = true;
157 buffer.buffer->stream = file;
158 dump_gimple_seq (&buffer, seq, spc, flags);
159 pp_newline_and_flush (&buffer);
163 /* Print the GIMPLE sequence SEQ on stderr. */
165 DEBUG_FUNCTION void
166 debug_gimple_seq (gimple_seq seq)
168 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
172 /* A simple helper to pretty-print some of the gimple tuples in the printf
173 style. The format modifiers are preceded by '%' and are:
174 'G' - outputs a string corresponding to the code of the given gimple,
175 'S' - outputs a gimple_seq with indent of spc + 2,
176 'T' - outputs the tree t,
177 'd' - outputs an int as a decimal,
178 's' - outputs a string,
179 'n' - outputs a newline,
180 'x' - outputs an int as hexadecimal,
181 '+' - increases indent by 2 then outputs a newline,
182 '-' - decreases indent by 2 then outputs a newline. */
184 static void
185 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
186 const char *fmt, ...)
188 va_list args;
189 const char *c;
190 const char *tmp;
192 va_start (args, fmt);
193 for (c = fmt; *c; c++)
195 if (*c == '%')
197 gimple_seq seq;
198 tree t;
199 gimple g;
200 switch (*++c)
202 case 'G':
203 g = va_arg (args, gimple);
204 tmp = gimple_code_name[gimple_code (g)];
205 pp_string (buffer, tmp);
206 break;
208 case 'S':
209 seq = va_arg (args, gimple_seq);
210 pp_newline (buffer);
211 dump_gimple_seq (buffer, seq, spc + 2, flags);
212 newline_and_indent (buffer, spc);
213 break;
215 case 'T':
216 t = va_arg (args, tree);
217 if (t == NULL_TREE)
218 pp_string (buffer, "NULL");
219 else
220 dump_generic_node (buffer, t, spc, flags, false);
221 break;
223 case 'd':
224 pp_decimal_int (buffer, va_arg (args, int));
225 break;
227 case 's':
228 pp_string (buffer, va_arg (args, char *));
229 break;
231 case 'n':
232 newline_and_indent (buffer, spc);
233 break;
235 case 'x':
236 pp_scalar (buffer, "%x", va_arg (args, int));
237 break;
239 case '+':
240 spc += 2;
241 newline_and_indent (buffer, spc);
242 break;
244 case '-':
245 spc -= 2;
246 newline_and_indent (buffer, spc);
247 break;
249 default:
250 gcc_unreachable ();
253 else
254 pp_character (buffer, *c);
256 va_end (args);
260 /* Helper for dump_gimple_assign. Print the unary RHS of the
261 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
263 static void
264 dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
266 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
267 tree lhs = gimple_assign_lhs (gs);
268 tree rhs = gimple_assign_rhs1 (gs);
270 switch (rhs_code)
272 case VIEW_CONVERT_EXPR:
273 case ASSERT_EXPR:
274 dump_generic_node (buffer, rhs, spc, flags, false);
275 break;
277 case FIXED_CONVERT_EXPR:
278 case ADDR_SPACE_CONVERT_EXPR:
279 case FIX_TRUNC_EXPR:
280 case FLOAT_EXPR:
281 CASE_CONVERT:
282 pp_left_paren (buffer);
283 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
284 pp_string (buffer, ") ");
285 if (op_prio (rhs) < op_code_prio (rhs_code))
287 pp_left_paren (buffer);
288 dump_generic_node (buffer, rhs, spc, flags, false);
289 pp_right_paren (buffer);
291 else
292 dump_generic_node (buffer, rhs, spc, flags, false);
293 break;
295 case PAREN_EXPR:
296 pp_string (buffer, "((");
297 dump_generic_node (buffer, rhs, spc, flags, false);
298 pp_string (buffer, "))");
299 break;
301 case ABS_EXPR:
302 pp_string (buffer, "ABS_EXPR <");
303 dump_generic_node (buffer, rhs, spc, flags, false);
304 pp_greater (buffer);
305 break;
307 default:
308 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
309 || TREE_CODE_CLASS (rhs_code) == tcc_constant
310 || TREE_CODE_CLASS (rhs_code) == tcc_reference
311 || rhs_code == SSA_NAME
312 || rhs_code == ADDR_EXPR
313 || rhs_code == CONSTRUCTOR)
315 dump_generic_node (buffer, rhs, spc, flags, false);
316 break;
318 else if (rhs_code == BIT_NOT_EXPR)
319 pp_complement (buffer);
320 else if (rhs_code == TRUTH_NOT_EXPR)
321 pp_exclamation (buffer);
322 else if (rhs_code == NEGATE_EXPR)
323 pp_minus (buffer);
324 else
326 pp_left_bracket (buffer);
327 pp_string (buffer, get_tree_code_name (rhs_code));
328 pp_string (buffer, "] ");
331 if (op_prio (rhs) < op_code_prio (rhs_code))
333 pp_left_paren (buffer);
334 dump_generic_node (buffer, rhs, spc, flags, false);
335 pp_right_paren (buffer);
337 else
338 dump_generic_node (buffer, rhs, spc, flags, false);
339 break;
344 /* Helper for dump_gimple_assign. Print the binary RHS of the
345 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
347 static void
348 dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
350 const char *p;
351 enum tree_code code = gimple_assign_rhs_code (gs);
352 switch (code)
354 case COMPLEX_EXPR:
355 case MIN_EXPR:
356 case MAX_EXPR:
357 case VEC_WIDEN_MULT_HI_EXPR:
358 case VEC_WIDEN_MULT_LO_EXPR:
359 case VEC_WIDEN_MULT_EVEN_EXPR:
360 case VEC_WIDEN_MULT_ODD_EXPR:
361 case VEC_PACK_TRUNC_EXPR:
362 case VEC_PACK_SAT_EXPR:
363 case VEC_PACK_FIX_TRUNC_EXPR:
364 case VEC_WIDEN_LSHIFT_HI_EXPR:
365 case VEC_WIDEN_LSHIFT_LO_EXPR:
366 for (p = get_tree_code_name (code); *p; p++)
367 pp_character (buffer, TOUPPER (*p));
368 pp_string (buffer, " <");
369 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
370 pp_string (buffer, ", ");
371 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
372 pp_greater (buffer);
373 break;
375 default:
376 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
378 pp_left_paren (buffer);
379 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
380 false);
381 pp_right_paren (buffer);
383 else
384 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
385 pp_space (buffer);
386 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
387 pp_space (buffer);
388 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
390 pp_left_paren (buffer);
391 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
392 false);
393 pp_right_paren (buffer);
395 else
396 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
400 /* Helper for dump_gimple_assign. Print the ternary RHS of the
401 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
403 static void
404 dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
406 const char *p;
407 enum tree_code code = gimple_assign_rhs_code (gs);
408 switch (code)
410 case WIDEN_MULT_PLUS_EXPR:
411 case WIDEN_MULT_MINUS_EXPR:
412 for (p = get_tree_code_name (code); *p; p++)
413 pp_character (buffer, TOUPPER (*p));
414 pp_string (buffer, " <");
415 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
416 pp_string (buffer, ", ");
417 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
418 pp_string (buffer, ", ");
419 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
420 pp_greater (buffer);
421 break;
423 case FMA_EXPR:
424 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
425 pp_string (buffer, " * ");
426 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
427 pp_string (buffer, " + ");
428 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
429 break;
431 case DOT_PROD_EXPR:
432 pp_string (buffer, "DOT_PROD_EXPR <");
433 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
434 pp_string (buffer, ", ");
435 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
436 pp_string (buffer, ", ");
437 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
438 pp_greater (buffer);
439 break;
441 case SAD_EXPR:
442 pp_string (buffer, "SAD_EXPR <");
443 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
444 pp_string (buffer, ", ");
445 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
446 pp_string (buffer, ", ");
447 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
448 pp_greater (buffer);
449 break;
451 case VEC_PERM_EXPR:
452 pp_string (buffer, "VEC_PERM_EXPR <");
453 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
454 pp_string (buffer, ", ");
455 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
456 pp_string (buffer, ", ");
457 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
458 pp_greater (buffer);
459 break;
461 case REALIGN_LOAD_EXPR:
462 pp_string (buffer, "REALIGN_LOAD <");
463 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
464 pp_string (buffer, ", ");
465 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
466 pp_string (buffer, ", ");
467 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
468 pp_greater (buffer);
469 break;
471 case COND_EXPR:
472 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
473 pp_string (buffer, " ? ");
474 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
475 pp_string (buffer, " : ");
476 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
477 break;
479 case VEC_COND_EXPR:
480 pp_string (buffer, "VEC_COND_EXPR <");
481 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
482 pp_string (buffer, ", ");
483 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
484 pp_string (buffer, ", ");
485 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
486 pp_greater (buffer);
487 break;
489 default:
490 gcc_unreachable ();
495 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
496 pp_gimple_stmt_1. */
498 static void
499 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
501 if (flags & TDF_RAW)
503 tree arg1 = NULL;
504 tree arg2 = NULL;
505 tree arg3 = NULL;
506 switch (gimple_num_ops (gs))
508 case 4:
509 arg3 = gimple_assign_rhs3 (gs);
510 case 3:
511 arg2 = gimple_assign_rhs2 (gs);
512 case 2:
513 arg1 = gimple_assign_rhs1 (gs);
514 break;
515 default:
516 gcc_unreachable ();
519 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
520 get_tree_code_name (gimple_assign_rhs_code (gs)),
521 gimple_assign_lhs (gs), arg1, arg2, arg3);
523 else
525 if (!(flags & TDF_RHS_ONLY))
527 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
528 pp_space (buffer);
529 pp_equal (buffer);
531 if (gimple_assign_nontemporal_move_p (gs))
532 pp_string (buffer, "{nt}");
534 if (gimple_has_volatile_ops (gs))
535 pp_string (buffer, "{v}");
537 pp_space (buffer);
540 if (gimple_num_ops (gs) == 2)
541 dump_unary_rhs (buffer, gs, spc, flags);
542 else if (gimple_num_ops (gs) == 3)
543 dump_binary_rhs (buffer, gs, spc, flags);
544 else if (gimple_num_ops (gs) == 4)
545 dump_ternary_rhs (buffer, gs, spc, flags);
546 else
547 gcc_unreachable ();
548 if (!(flags & TDF_RHS_ONLY))
549 pp_semicolon (buffer);
554 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
555 pp_gimple_stmt_1. */
557 static void
558 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
560 tree t;
562 t = gimple_return_retval (gs);
563 if (flags & TDF_RAW)
564 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
565 else
567 pp_string (buffer, "return");
568 if (t)
570 pp_space (buffer);
571 dump_generic_node (buffer, t, spc, flags, false);
573 pp_semicolon (buffer);
578 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
579 dump_gimple_call. */
581 static void
582 dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags)
584 size_t i;
586 for (i = 0; i < gimple_call_num_args (gs); i++)
588 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
589 if (i < gimple_call_num_args (gs) - 1)
590 pp_string (buffer, ", ");
593 if (gimple_call_va_arg_pack_p (gs))
595 if (gimple_call_num_args (gs) > 0)
597 pp_comma (buffer);
598 pp_space (buffer);
601 pp_string (buffer, "__builtin_va_arg_pack ()");
605 /* Dump the points-to solution *PT to BUFFER. */
607 static void
608 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
610 if (pt->anything)
612 pp_string (buffer, "anything ");
613 return;
615 if (pt->nonlocal)
616 pp_string (buffer, "nonlocal ");
617 if (pt->escaped)
618 pp_string (buffer, "escaped ");
619 if (pt->ipa_escaped)
620 pp_string (buffer, "unit-escaped ");
621 if (pt->null)
622 pp_string (buffer, "null ");
623 if (pt->vars
624 && !bitmap_empty_p (pt->vars))
626 bitmap_iterator bi;
627 unsigned i;
628 pp_string (buffer, "{ ");
629 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
631 pp_string (buffer, "D.");
632 pp_decimal_int (buffer, i);
633 pp_space (buffer);
635 pp_right_brace (buffer);
636 if (pt->vars_contains_nonlocal
637 && pt->vars_contains_escaped_heap)
638 pp_string (buffer, " (nonlocal, escaped heap)");
639 else if (pt->vars_contains_nonlocal
640 && pt->vars_contains_escaped)
641 pp_string (buffer, " (nonlocal, escaped)");
642 else if (pt->vars_contains_nonlocal)
643 pp_string (buffer, " (nonlocal)");
644 else if (pt->vars_contains_escaped_heap)
645 pp_string (buffer, " (escaped heap)");
646 else if (pt->vars_contains_escaped)
647 pp_string (buffer, " (escaped)");
651 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
652 pp_gimple_stmt_1. */
654 static void
655 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
657 tree lhs = gimple_call_lhs (gs);
658 tree fn = gimple_call_fn (gs);
660 if (flags & TDF_ALIAS)
662 struct pt_solution *pt;
663 pt = gimple_call_use_set (gs);
664 if (!pt_solution_empty_p (pt))
666 pp_string (buffer, "# USE = ");
667 pp_points_to_solution (buffer, pt);
668 newline_and_indent (buffer, spc);
670 pt = gimple_call_clobber_set (gs);
671 if (!pt_solution_empty_p (pt))
673 pp_string (buffer, "# CLB = ");
674 pp_points_to_solution (buffer, pt);
675 newline_and_indent (buffer, spc);
679 if (flags & TDF_RAW)
681 if (gimple_call_internal_p (gs))
682 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
683 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
684 else
685 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
686 if (gimple_call_num_args (gs) > 0)
688 pp_string (buffer, ", ");
689 dump_gimple_call_args (buffer, gs, flags);
691 pp_greater (buffer);
693 else
695 if (lhs && !(flags & TDF_RHS_ONLY))
697 dump_generic_node (buffer, lhs, spc, flags, false);
698 pp_string (buffer, " =");
700 if (gimple_has_volatile_ops (gs))
701 pp_string (buffer, "{v}");
703 pp_space (buffer);
705 if (gimple_call_internal_p (gs))
706 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
707 else
708 print_call_name (buffer, fn, flags);
709 pp_string (buffer, " (");
710 dump_gimple_call_args (buffer, gs, flags);
711 pp_right_paren (buffer);
712 if (!(flags & TDF_RHS_ONLY))
713 pp_semicolon (buffer);
716 if (gimple_call_chain (gs))
718 pp_string (buffer, " [static-chain: ");
719 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
720 pp_right_bracket (buffer);
723 if (gimple_call_return_slot_opt_p (gs))
724 pp_string (buffer, " [return slot optimization]");
725 if (gimple_call_tail_p (gs))
726 pp_string (buffer, " [tail call]");
728 if (fn == NULL)
729 return;
731 /* Dump the arguments of _ITM_beginTransaction sanely. */
732 if (TREE_CODE (fn) == ADDR_EXPR)
733 fn = TREE_OPERAND (fn, 0);
734 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
735 pp_string (buffer, " [tm-clone]");
736 if (TREE_CODE (fn) == FUNCTION_DECL
737 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
738 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
739 && gimple_call_num_args (gs) > 0)
741 tree t = gimple_call_arg (gs, 0);
742 unsigned HOST_WIDE_INT props;
743 gcc_assert (TREE_CODE (t) == INTEGER_CST);
745 pp_string (buffer, " [ ");
747 /* Get the transaction code properties. */
748 props = TREE_INT_CST_LOW (t);
750 if (props & PR_INSTRUMENTEDCODE)
751 pp_string (buffer, "instrumentedCode ");
752 if (props & PR_UNINSTRUMENTEDCODE)
753 pp_string (buffer, "uninstrumentedCode ");
754 if (props & PR_HASNOXMMUPDATE)
755 pp_string (buffer, "hasNoXMMUpdate ");
756 if (props & PR_HASNOABORT)
757 pp_string (buffer, "hasNoAbort ");
758 if (props & PR_HASNOIRREVOCABLE)
759 pp_string (buffer, "hasNoIrrevocable ");
760 if (props & PR_DOESGOIRREVOCABLE)
761 pp_string (buffer, "doesGoIrrevocable ");
762 if (props & PR_HASNOSIMPLEREADS)
763 pp_string (buffer, "hasNoSimpleReads ");
764 if (props & PR_AWBARRIERSOMITTED)
765 pp_string (buffer, "awBarriersOmitted ");
766 if (props & PR_RARBARRIERSOMITTED)
767 pp_string (buffer, "RaRBarriersOmitted ");
768 if (props & PR_UNDOLOGCODE)
769 pp_string (buffer, "undoLogCode ");
770 if (props & PR_PREFERUNINSTRUMENTED)
771 pp_string (buffer, "preferUninstrumented ");
772 if (props & PR_EXCEPTIONBLOCK)
773 pp_string (buffer, "exceptionBlock ");
774 if (props & PR_HASELSE)
775 pp_string (buffer, "hasElse ");
776 if (props & PR_READONLY)
777 pp_string (buffer, "readOnly ");
779 pp_right_bracket (buffer);
784 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
785 pp_gimple_stmt_1. */
787 static void
788 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
790 unsigned int i;
792 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
793 if (flags & TDF_RAW)
794 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
795 gimple_switch_index (gs));
796 else
798 pp_string (buffer, "switch (");
799 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
800 pp_string (buffer, ") <");
803 for (i = 0; i < gimple_switch_num_labels (gs); i++)
805 tree case_label = gimple_switch_label (gs, i);
806 gcc_checking_assert (case_label != NULL_TREE);
807 dump_generic_node (buffer, case_label, spc, flags, false);
808 pp_space (buffer);
809 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
810 if (i < gimple_switch_num_labels (gs) - 1)
811 pp_string (buffer, ", ");
813 pp_greater (buffer);
817 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
818 pp_gimple_stmt_1. */
820 static void
821 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
823 if (flags & TDF_RAW)
824 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
825 get_tree_code_name (gimple_cond_code (gs)),
826 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
827 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
828 else
830 if (!(flags & TDF_RHS_ONLY))
831 pp_string (buffer, "if (");
832 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
833 pp_space (buffer);
834 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
835 pp_space (buffer);
836 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
837 if (!(flags & TDF_RHS_ONLY))
839 pp_right_paren (buffer);
841 if (gimple_cond_true_label (gs))
843 pp_string (buffer, " goto ");
844 dump_generic_node (buffer, gimple_cond_true_label (gs),
845 spc, flags, false);
846 pp_semicolon (buffer);
848 if (gimple_cond_false_label (gs))
850 pp_string (buffer, " else goto ");
851 dump_generic_node (buffer, gimple_cond_false_label (gs),
852 spc, flags, false);
853 pp_semicolon (buffer);
860 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
861 spaces of indent. FLAGS specifies details to show in the dump (see
862 TDF_* in dumpfils.h). */
864 static void
865 dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
867 tree label = gimple_label_label (gs);
868 if (flags & TDF_RAW)
869 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
870 else
872 dump_generic_node (buffer, label, spc, flags, false);
873 pp_colon (buffer);
875 if (DECL_NONLOCAL (label))
876 pp_string (buffer, " [non-local]");
877 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
878 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
881 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
882 spaces of indent. FLAGS specifies details to show in the dump (see
883 TDF_* in dumpfile.h). */
885 static void
886 dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
888 tree label = gimple_goto_dest (gs);
889 if (flags & TDF_RAW)
890 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
891 else
892 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
896 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
897 spaces of indent. FLAGS specifies details to show in the dump (see
898 TDF_* in dumpfile.h). */
900 static void
901 dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
903 if (flags & TDF_RAW)
904 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
905 else
906 pp_left_brace (buffer);
907 if (!(flags & TDF_SLIM))
909 tree var;
911 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
913 newline_and_indent (buffer, 2);
914 print_declaration (buffer, var, spc, flags);
916 if (gimple_bind_vars (gs))
917 pp_newline (buffer);
919 pp_newline (buffer);
920 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
921 newline_and_indent (buffer, spc);
922 if (flags & TDF_RAW)
923 pp_greater (buffer);
924 else
925 pp_right_brace (buffer);
929 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
930 indent. FLAGS specifies details to show in the dump (see TDF_* in
931 dumpfile.h). */
933 static void
934 dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
936 if (flags & TDF_RAW)
938 const char *type;
939 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
940 type = "GIMPLE_TRY_CATCH";
941 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
942 type = "GIMPLE_TRY_FINALLY";
943 else
944 type = "UNKNOWN GIMPLE_TRY";
945 dump_gimple_fmt (buffer, spc, flags,
946 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
947 gimple_try_eval (gs), gimple_try_cleanup (gs));
949 else
951 pp_string (buffer, "try");
952 newline_and_indent (buffer, spc + 2);
953 pp_left_brace (buffer);
954 pp_newline (buffer);
956 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
957 newline_and_indent (buffer, spc + 2);
958 pp_right_brace (buffer);
960 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
962 newline_and_indent (buffer, spc);
963 pp_string (buffer, "catch");
964 newline_and_indent (buffer, spc + 2);
965 pp_left_brace (buffer);
967 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
969 newline_and_indent (buffer, spc);
970 pp_string (buffer, "finally");
971 newline_and_indent (buffer, spc + 2);
972 pp_left_brace (buffer);
974 else
975 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
977 pp_newline (buffer);
978 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
979 newline_and_indent (buffer, spc + 2);
980 pp_right_brace (buffer);
985 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
986 indent. FLAGS specifies details to show in the dump (see TDF_* in
987 dumpfile.h). */
989 static void
990 dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
992 if (flags & TDF_RAW)
993 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
994 gimple_catch_types (gs), gimple_catch_handler (gs));
995 else
996 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
997 gimple_catch_types (gs), gimple_catch_handler (gs));
1001 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1002 indent. FLAGS specifies details to show in the dump (see TDF_* in
1003 dumpfile.h). */
1005 static void
1006 dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
1008 if (flags & TDF_RAW)
1009 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1010 gimple_eh_filter_types (gs),
1011 gimple_eh_filter_failure (gs));
1012 else
1013 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1014 gimple_eh_filter_types (gs),
1015 gimple_eh_filter_failure (gs));
1019 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1021 static void
1022 dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
1023 int spc, int flags)
1025 if (flags & TDF_RAW)
1026 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1027 gimple_eh_must_not_throw_fndecl (gs));
1028 else
1029 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1030 gimple_eh_must_not_throw_fndecl (gs));
1034 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1035 indent. FLAGS specifies details to show in the dump (see TDF_* in
1036 dumpfile.h). */
1038 static void
1039 dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags)
1041 if (flags & TDF_RAW)
1042 dump_gimple_fmt (buffer, spc, flags,
1043 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1044 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1045 else
1046 dump_gimple_fmt (buffer, spc, flags,
1047 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1048 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1052 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1053 indent. FLAGS specifies details to show in the dump (see TDF_* in
1054 dumpfile.h). */
1056 static void
1057 dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
1059 if (flags & TDF_RAW)
1060 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1061 gimple_resx_region (gs));
1062 else
1063 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1066 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1068 static void
1069 dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
1071 if (flags & TDF_RAW)
1072 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1073 gimple_eh_dispatch_region (gs));
1074 else
1075 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1076 gimple_eh_dispatch_region (gs));
1079 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1080 of indent. FLAGS specifies details to show in the dump (see TDF_*
1081 in dumpfile.h). */
1083 static void
1084 dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
1086 switch (gs->subcode)
1088 case GIMPLE_DEBUG_BIND:
1089 if (flags & TDF_RAW)
1090 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1091 gimple_debug_bind_get_var (gs),
1092 gimple_debug_bind_get_value (gs));
1093 else
1094 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1095 gimple_debug_bind_get_var (gs),
1096 gimple_debug_bind_get_value (gs));
1097 break;
1099 case GIMPLE_DEBUG_SOURCE_BIND:
1100 if (flags & TDF_RAW)
1101 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1102 gimple_debug_source_bind_get_var (gs),
1103 gimple_debug_source_bind_get_value (gs));
1104 else
1105 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1106 gimple_debug_source_bind_get_var (gs),
1107 gimple_debug_source_bind_get_value (gs));
1108 break;
1110 default:
1111 gcc_unreachable ();
1115 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1116 static void
1117 dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
1119 size_t i;
1121 if (flags & TDF_RAW)
1123 const char *kind;
1124 switch (gimple_omp_for_kind (gs))
1126 case GF_OMP_FOR_KIND_FOR:
1127 kind = "";
1128 break;
1129 case GF_OMP_FOR_KIND_DISTRIBUTE:
1130 kind = " distribute";
1131 break;
1132 case GF_OMP_FOR_KIND_CILKFOR:
1133 kind = " _Cilk_for";
1134 break;
1135 case GF_OMP_FOR_KIND_OACC_LOOP:
1136 kind = " oacc_loop";
1137 break;
1138 case GF_OMP_FOR_KIND_SIMD:
1139 kind = " simd";
1140 break;
1141 case GF_OMP_FOR_KIND_CILKSIMD:
1142 kind = " cilksimd";
1143 break;
1144 default:
1145 gcc_unreachable ();
1147 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1148 kind, gimple_omp_body (gs));
1149 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1150 dump_gimple_fmt (buffer, spc, flags, " >,");
1151 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1152 dump_gimple_fmt (buffer, spc, flags,
1153 "%+%T, %T, %T, %s, %T,%n",
1154 gimple_omp_for_index (gs, i),
1155 gimple_omp_for_initial (gs, i),
1156 gimple_omp_for_final (gs, i),
1157 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1158 gimple_omp_for_incr (gs, i));
1159 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1160 gimple_omp_for_pre_body (gs));
1162 else
1164 switch (gimple_omp_for_kind (gs))
1166 case GF_OMP_FOR_KIND_FOR:
1167 pp_string (buffer, "#pragma omp for");
1168 break;
1169 case GF_OMP_FOR_KIND_DISTRIBUTE:
1170 pp_string (buffer, "#pragma omp distribute");
1171 break;
1172 case GF_OMP_FOR_KIND_CILKFOR:
1173 break;
1174 case GF_OMP_FOR_KIND_OACC_LOOP:
1175 pp_string (buffer, "#pragma acc loop");
1176 break;
1177 case GF_OMP_FOR_KIND_SIMD:
1178 pp_string (buffer, "#pragma omp simd");
1179 break;
1180 case GF_OMP_FOR_KIND_CILKSIMD:
1181 pp_string (buffer, "#pragma simd");
1182 break;
1183 default:
1184 gcc_unreachable ();
1186 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1187 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1188 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1190 if (i)
1191 spc += 2;
1192 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1193 pp_string (buffer, "_Cilk_for (");
1194 else
1196 newline_and_indent (buffer, spc);
1197 pp_string (buffer, "for (");
1199 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1200 flags, false);
1201 pp_string (buffer, " = ");
1202 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1203 flags, false);
1204 pp_string (buffer, "; ");
1206 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1207 flags, false);
1208 pp_space (buffer);
1209 switch (gimple_omp_for_cond (gs, i))
1211 case LT_EXPR:
1212 pp_less (buffer);
1213 break;
1214 case GT_EXPR:
1215 pp_greater (buffer);
1216 break;
1217 case LE_EXPR:
1218 pp_less_equal (buffer);
1219 break;
1220 case GE_EXPR:
1221 pp_greater_equal (buffer);
1222 break;
1223 case NE_EXPR:
1224 pp_string (buffer, "!=");
1225 break;
1226 default:
1227 gcc_unreachable ();
1229 pp_space (buffer);
1230 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1231 flags, false);
1232 pp_string (buffer, "; ");
1234 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1235 flags, false);
1236 pp_string (buffer, " = ");
1237 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1238 flags, false);
1239 pp_right_paren (buffer);
1242 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1244 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1245 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1246 newline_and_indent (buffer, spc + 2);
1247 pp_left_brace (buffer);
1248 pp_newline (buffer);
1249 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1250 newline_and_indent (buffer, spc + 2);
1251 pp_right_brace (buffer);
1256 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1258 static void
1259 dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags)
1261 if (flags & TDF_RAW)
1263 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1264 gimple_omp_continue_control_def (gs),
1265 gimple_omp_continue_control_use (gs));
1267 else
1269 pp_string (buffer, "#pragma omp continue (");
1270 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1271 spc, flags, false);
1272 pp_comma (buffer);
1273 pp_space (buffer);
1274 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1275 spc, flags, false);
1276 pp_right_paren (buffer);
1280 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1282 static void
1283 dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, int flags)
1285 if (flags & TDF_RAW)
1287 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1288 gimple_omp_body (gs));
1289 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1290 dump_gimple_fmt (buffer, spc, flags, " >");
1292 else
1294 pp_string (buffer, "#pragma omp single");
1295 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1296 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1298 newline_and_indent (buffer, spc + 2);
1299 pp_left_brace (buffer);
1300 pp_newline (buffer);
1301 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1302 newline_and_indent (buffer, spc + 2);
1303 pp_right_brace (buffer);
1308 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1310 static void
1311 dump_gimple_omp_target (pretty_printer *buffer, gimple gs, int spc, int flags)
1313 const char *kind;
1314 switch (gimple_omp_target_kind (gs))
1316 case GF_OMP_TARGET_KIND_REGION:
1317 kind = "";
1318 break;
1319 case GF_OMP_TARGET_KIND_DATA:
1320 kind = " data";
1321 break;
1322 case GF_OMP_TARGET_KIND_UPDATE:
1323 kind = " update";
1324 break;
1325 case GF_OMP_TARGET_KIND_OACC_DATA:
1326 kind = " oacc_data";
1327 break;
1328 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1329 kind = " oacc_update";
1330 break;
1331 default:
1332 gcc_unreachable ();
1334 if (flags & TDF_RAW)
1336 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1337 kind, gimple_omp_body (gs));
1338 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1339 dump_gimple_fmt (buffer, spc, flags, " >");
1341 else
1343 pp_string (buffer, "#pragma omp target");
1344 pp_string (buffer, kind);
1345 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1346 if (gimple_omp_target_child_fn (gs))
1348 pp_string (buffer, " [child fn: ");
1349 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1350 spc, flags, false);
1351 pp_right_bracket (buffer);
1353 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1355 newline_and_indent (buffer, spc + 2);
1356 pp_character (buffer, '{');
1357 pp_newline (buffer);
1358 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1359 newline_and_indent (buffer, spc + 2);
1360 pp_character (buffer, '}');
1365 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1367 static void
1368 dump_gimple_omp_teams (pretty_printer *buffer, gimple gs, int spc, int flags)
1370 if (flags & TDF_RAW)
1372 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1373 gimple_omp_body (gs));
1374 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1375 dump_gimple_fmt (buffer, spc, flags, " >");
1377 else
1379 pp_string (buffer, "#pragma omp teams");
1380 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1381 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1383 newline_and_indent (buffer, spc + 2);
1384 pp_character (buffer, '{');
1385 pp_newline (buffer);
1386 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1387 newline_and_indent (buffer, spc + 2);
1388 pp_character (buffer, '}');
1393 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1395 static void
1396 dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
1397 int flags)
1399 if (flags & TDF_RAW)
1401 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1402 gimple_omp_body (gs));
1403 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1404 dump_gimple_fmt (buffer, spc, flags, " >");
1406 else
1408 pp_string (buffer, "#pragma omp sections");
1409 if (gimple_omp_sections_control (gs))
1411 pp_string (buffer, " <");
1412 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1413 flags, false);
1414 pp_greater (buffer);
1416 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1417 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1419 newline_and_indent (buffer, spc + 2);
1420 pp_left_brace (buffer);
1421 pp_newline (buffer);
1422 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1423 newline_and_indent (buffer, spc + 2);
1424 pp_right_brace (buffer);
1429 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1430 pretty_printer BUFFER. */
1432 static void
1433 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1435 if (flags & TDF_RAW)
1436 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1437 gimple_omp_body (gs));
1438 else
1440 switch (gimple_code (gs))
1442 case GIMPLE_OMP_MASTER:
1443 pp_string (buffer, "#pragma omp master");
1444 break;
1445 case GIMPLE_OMP_TASKGROUP:
1446 pp_string (buffer, "#pragma omp taskgroup");
1447 break;
1448 case GIMPLE_OMP_ORDERED:
1449 pp_string (buffer, "#pragma omp ordered");
1450 break;
1451 case GIMPLE_OMP_SECTION:
1452 pp_string (buffer, "#pragma omp section");
1453 break;
1454 default:
1455 gcc_unreachable ();
1457 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1459 newline_and_indent (buffer, spc + 2);
1460 pp_left_brace (buffer);
1461 pp_newline (buffer);
1462 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1463 newline_and_indent (buffer, spc + 2);
1464 pp_right_brace (buffer);
1469 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1471 static void
1472 dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
1473 int flags)
1475 if (flags & TDF_RAW)
1476 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1477 gimple_omp_body (gs));
1478 else
1480 pp_string (buffer, "#pragma omp critical");
1481 if (gimple_omp_critical_name (gs))
1483 pp_string (buffer, " (");
1484 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1485 flags, false);
1486 pp_right_paren (buffer);
1488 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1490 newline_and_indent (buffer, spc + 2);
1491 pp_left_brace (buffer);
1492 pp_newline (buffer);
1493 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1494 newline_and_indent (buffer, spc + 2);
1495 pp_right_brace (buffer);
1500 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1502 static void
1503 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1505 if (flags & TDF_RAW)
1507 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1508 (int) gimple_omp_return_nowait_p (gs));
1509 if (gimple_omp_return_lhs (gs))
1510 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1511 gimple_omp_return_lhs (gs));
1512 else
1513 dump_gimple_fmt (buffer, spc, flags, ">");
1515 else
1517 pp_string (buffer, "#pragma omp return");
1518 if (gimple_omp_return_nowait_p (gs))
1519 pp_string (buffer, "(nowait)");
1520 if (gimple_omp_return_lhs (gs))
1522 pp_string (buffer, " (set ");
1523 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1524 spc, flags, false);
1525 pp_character (buffer, ')');
1530 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1532 static void
1533 dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags)
1535 unsigned subcode = gimple_transaction_subcode (gs);
1537 if (flags & TDF_RAW)
1539 dump_gimple_fmt (buffer, spc, flags,
1540 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1541 gs, subcode, gimple_transaction_label (gs),
1542 gimple_transaction_body (gs));
1544 else
1546 if (subcode & GTMA_IS_OUTER)
1547 pp_string (buffer, "__transaction_atomic [[outer]]");
1548 else if (subcode & GTMA_IS_RELAXED)
1549 pp_string (buffer, "__transaction_relaxed");
1550 else
1551 pp_string (buffer, "__transaction_atomic");
1552 subcode &= ~GTMA_DECLARATION_MASK;
1554 if (subcode || gimple_transaction_label (gs))
1556 pp_string (buffer, " //");
1557 if (gimple_transaction_label (gs))
1559 pp_string (buffer, " LABEL=");
1560 dump_generic_node (buffer, gimple_transaction_label (gs),
1561 spc, flags, false);
1563 if (subcode)
1565 pp_string (buffer, " SUBCODE=[ ");
1566 if (subcode & GTMA_HAVE_ABORT)
1568 pp_string (buffer, "GTMA_HAVE_ABORT ");
1569 subcode &= ~GTMA_HAVE_ABORT;
1571 if (subcode & GTMA_HAVE_LOAD)
1573 pp_string (buffer, "GTMA_HAVE_LOAD ");
1574 subcode &= ~GTMA_HAVE_LOAD;
1576 if (subcode & GTMA_HAVE_STORE)
1578 pp_string (buffer, "GTMA_HAVE_STORE ");
1579 subcode &= ~GTMA_HAVE_STORE;
1581 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1583 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1584 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1586 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1588 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1589 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1591 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1593 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1594 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1596 if (subcode)
1597 pp_printf (buffer, "0x%x ", subcode);
1598 pp_right_bracket (buffer);
1602 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1604 newline_and_indent (buffer, spc + 2);
1605 pp_left_brace (buffer);
1606 pp_newline (buffer);
1607 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1608 spc + 4, flags);
1609 newline_and_indent (buffer, spc + 2);
1610 pp_right_brace (buffer);
1615 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1616 indent. FLAGS specifies details to show in the dump (see TDF_* in
1617 dumpfile.h). */
1619 static void
1620 dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
1622 unsigned int i, n, f, fields;
1624 if (flags & TDF_RAW)
1626 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1627 gimple_asm_string (gs));
1629 n = gimple_asm_noutputs (gs);
1630 if (n)
1632 newline_and_indent (buffer, spc + 2);
1633 pp_string (buffer, "OUTPUT: ");
1634 for (i = 0; i < n; i++)
1636 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1637 spc, flags, false);
1638 if (i < n - 1)
1639 pp_string (buffer, ", ");
1643 n = gimple_asm_ninputs (gs);
1644 if (n)
1646 newline_and_indent (buffer, spc + 2);
1647 pp_string (buffer, "INPUT: ");
1648 for (i = 0; i < n; i++)
1650 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1651 spc, flags, false);
1652 if (i < n - 1)
1653 pp_string (buffer, ", ");
1657 n = gimple_asm_nclobbers (gs);
1658 if (n)
1660 newline_and_indent (buffer, spc + 2);
1661 pp_string (buffer, "CLOBBER: ");
1662 for (i = 0; i < n; i++)
1664 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1665 spc, flags, false);
1666 if (i < n - 1)
1667 pp_string (buffer, ", ");
1671 n = gimple_asm_nlabels (gs);
1672 if (n)
1674 newline_and_indent (buffer, spc + 2);
1675 pp_string (buffer, "LABEL: ");
1676 for (i = 0; i < n; i++)
1678 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1679 spc, flags, false);
1680 if (i < n - 1)
1681 pp_string (buffer, ", ");
1685 newline_and_indent (buffer, spc);
1686 pp_greater (buffer);
1688 else
1690 pp_string (buffer, "__asm__");
1691 if (gimple_asm_volatile_p (gs))
1692 pp_string (buffer, " __volatile__");
1693 if (gimple_asm_nlabels (gs))
1694 pp_string (buffer, " goto");
1695 pp_string (buffer, "(\"");
1696 pp_string (buffer, gimple_asm_string (gs));
1697 pp_string (buffer, "\"");
1699 if (gimple_asm_nlabels (gs))
1700 fields = 4;
1701 else if (gimple_asm_nclobbers (gs))
1702 fields = 3;
1703 else if (gimple_asm_ninputs (gs))
1704 fields = 2;
1705 else if (gimple_asm_noutputs (gs))
1706 fields = 1;
1707 else
1708 fields = 0;
1710 for (f = 0; f < fields; ++f)
1712 pp_string (buffer, " : ");
1714 switch (f)
1716 case 0:
1717 n = gimple_asm_noutputs (gs);
1718 for (i = 0; i < n; i++)
1720 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1721 spc, flags, false);
1722 if (i < n - 1)
1723 pp_string (buffer, ", ");
1725 break;
1727 case 1:
1728 n = gimple_asm_ninputs (gs);
1729 for (i = 0; i < n; i++)
1731 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1732 spc, flags, false);
1733 if (i < n - 1)
1734 pp_string (buffer, ", ");
1736 break;
1738 case 2:
1739 n = gimple_asm_nclobbers (gs);
1740 for (i = 0; i < n; i++)
1742 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1743 spc, flags, false);
1744 if (i < n - 1)
1745 pp_string (buffer, ", ");
1747 break;
1749 case 3:
1750 n = gimple_asm_nlabels (gs);
1751 for (i = 0; i < n; i++)
1753 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1754 spc, flags, false);
1755 if (i < n - 1)
1756 pp_string (buffer, ", ");
1758 break;
1760 default:
1761 gcc_unreachable ();
1765 pp_string (buffer, ");");
1769 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1770 SPC spaces of indent. */
1772 static void
1773 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1775 if (TREE_CODE (node) != SSA_NAME)
1776 return;
1778 if (POINTER_TYPE_P (TREE_TYPE (node))
1779 && SSA_NAME_PTR_INFO (node))
1781 unsigned int align, misalign;
1782 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1783 pp_string (buffer, "# PT = ");
1784 pp_points_to_solution (buffer, &pi->pt);
1785 newline_and_indent (buffer, spc);
1786 if (get_ptr_info_alignment (pi, &align, &misalign))
1788 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1789 newline_and_indent (buffer, spc);
1793 if (!POINTER_TYPE_P (TREE_TYPE (node))
1794 && SSA_NAME_RANGE_INFO (node))
1796 wide_int min, max, nonzero_bits;
1797 value_range_type range_type = get_range_info (node, &min, &max);
1799 if (range_type == VR_VARYING)
1800 pp_printf (buffer, "# RANGE VR_VARYING");
1801 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1803 pp_printf (buffer, "# RANGE ");
1804 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1805 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
1806 pp_printf (buffer, ", ");
1807 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
1808 pp_printf (buffer, "]");
1810 nonzero_bits = get_nonzero_bits (node);
1811 if (nonzero_bits != -1)
1813 pp_string (buffer, " NONZERO ");
1814 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
1816 newline_and_indent (buffer, spc);
1821 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1822 The caller is responsible for calling pp_flush on BUFFER to finalize
1823 pretty printer. If COMMENT is true, print this after #. */
1825 static void
1826 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, bool comment,
1827 int flags)
1829 size_t i;
1830 tree lhs = gimple_phi_result (phi);
1832 if (flags & TDF_ALIAS)
1833 dump_ssaname_info (buffer, lhs, spc);
1835 if (comment)
1836 pp_string (buffer, "# ");
1838 if (flags & TDF_RAW)
1839 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1840 gimple_phi_result (phi));
1841 else
1843 dump_generic_node (buffer, lhs, spc, flags, false);
1844 pp_string (buffer, " = PHI <");
1846 for (i = 0; i < gimple_phi_num_args (phi); i++)
1848 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1850 expanded_location xloc;
1852 xloc = expand_location (gimple_phi_arg_location (phi, i));
1853 pp_left_bracket (buffer);
1854 if (xloc.file)
1856 pp_string (buffer, xloc.file);
1857 pp_string (buffer, " : ");
1859 pp_decimal_int (buffer, xloc.line);
1860 pp_colon (buffer);
1861 pp_decimal_int (buffer, xloc.column);
1862 pp_string (buffer, "] ");
1864 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1865 false);
1866 pp_left_paren (buffer);
1867 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1868 pp_right_paren (buffer);
1869 if (i < gimple_phi_num_args (phi) - 1)
1870 pp_string (buffer, ", ");
1872 pp_greater (buffer);
1876 /* Dump an OpenACC offload tuple on the pretty_printer BUFFER, SPC spaces
1877 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1878 dumpfile.h). */
1880 static void
1881 dump_gimple_oacc_offload (pretty_printer *buffer, gimple gs, int spc,
1882 int flags)
1884 tree (*gimple_omp_clauses) (const_gimple);
1885 tree (*gimple_omp_child_fn) (const_gimple);
1886 tree (*gimple_omp_data_arg) (const_gimple);
1887 const char *kind;
1888 switch (gimple_code (gs))
1890 case GIMPLE_OACC_KERNELS:
1891 gimple_omp_clauses = gimple_oacc_kernels_clauses;
1892 gimple_omp_child_fn = gimple_oacc_kernels_child_fn;
1893 gimple_omp_data_arg = gimple_oacc_kernels_data_arg;
1894 kind = "kernels";
1895 break;
1896 case GIMPLE_OACC_PARALLEL:
1897 gimple_omp_clauses = gimple_oacc_parallel_clauses;
1898 gimple_omp_child_fn = gimple_oacc_parallel_child_fn;
1899 gimple_omp_data_arg = gimple_oacc_parallel_data_arg;
1900 kind = "parallel";
1901 break;
1902 default:
1903 gcc_unreachable ();
1905 if (flags & TDF_RAW)
1907 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1908 gimple_omp_body (gs));
1909 dump_omp_clauses (buffer, gimple_omp_clauses (gs), spc, flags);
1910 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1911 gimple_omp_child_fn (gs), gimple_omp_data_arg (gs));
1913 else
1915 gimple_seq body;
1916 pp_string (buffer, "#pragma acc ");
1917 pp_string (buffer, kind);
1918 dump_omp_clauses (buffer, gimple_omp_clauses (gs), spc, flags);
1919 if (gimple_omp_child_fn (gs))
1921 pp_string (buffer, " [child fn: ");
1922 dump_generic_node (buffer, gimple_omp_child_fn (gs),
1923 spc, flags, false);
1924 pp_string (buffer, " (");
1925 if (gimple_omp_data_arg (gs))
1926 dump_generic_node (buffer, gimple_omp_data_arg (gs),
1927 spc, flags, false);
1928 else
1929 pp_string (buffer, "???");
1930 pp_string (buffer, ")]");
1932 body = gimple_omp_body (gs);
1933 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1935 newline_and_indent (buffer, spc + 2);
1936 pp_left_brace (buffer);
1937 pp_newline (buffer);
1938 dump_gimple_seq (buffer, body, spc + 4, flags);
1939 newline_and_indent (buffer, spc + 2);
1940 pp_right_brace (buffer);
1942 else if (body)
1944 pp_newline (buffer);
1945 dump_gimple_seq (buffer, body, spc + 2, flags);
1951 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1952 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1953 dumpfile.h). */
1955 static void
1956 dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1957 int flags)
1959 if (flags & TDF_RAW)
1961 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1962 gimple_omp_body (gs));
1963 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1964 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1965 gimple_omp_parallel_child_fn (gs),
1966 gimple_omp_parallel_data_arg (gs));
1968 else
1970 gimple_seq body;
1971 pp_string (buffer, "#pragma omp parallel");
1972 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1973 if (gimple_omp_parallel_child_fn (gs))
1975 pp_string (buffer, " [child fn: ");
1976 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1977 spc, flags, false);
1978 pp_string (buffer, " (");
1979 if (gimple_omp_parallel_data_arg (gs))
1980 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1981 spc, flags, false);
1982 else
1983 pp_string (buffer, "???");
1984 pp_string (buffer, ")]");
1986 body = gimple_omp_body (gs);
1987 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1989 newline_and_indent (buffer, spc + 2);
1990 pp_left_brace (buffer);
1991 pp_newline (buffer);
1992 dump_gimple_seq (buffer, body, spc + 4, flags);
1993 newline_and_indent (buffer, spc + 2);
1994 pp_right_brace (buffer);
1996 else if (body)
1998 pp_newline (buffer);
1999 dump_gimple_seq (buffer, body, spc + 2, flags);
2005 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2006 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2007 dumpfile.h). */
2009 static void
2010 dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
2011 int flags)
2013 if (flags & TDF_RAW)
2015 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2016 gimple_omp_body (gs));
2017 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2018 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2019 gimple_omp_task_child_fn (gs),
2020 gimple_omp_task_data_arg (gs),
2021 gimple_omp_task_copy_fn (gs),
2022 gimple_omp_task_arg_size (gs),
2023 gimple_omp_task_arg_size (gs));
2025 else
2027 gimple_seq body;
2028 pp_string (buffer, "#pragma omp task");
2029 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2030 if (gimple_omp_task_child_fn (gs))
2032 pp_string (buffer, " [child fn: ");
2033 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2034 spc, flags, false);
2035 pp_string (buffer, " (");
2036 if (gimple_omp_task_data_arg (gs))
2037 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2038 spc, flags, false);
2039 else
2040 pp_string (buffer, "???");
2041 pp_string (buffer, ")]");
2043 body = gimple_omp_body (gs);
2044 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2046 newline_and_indent (buffer, spc + 2);
2047 pp_left_brace (buffer);
2048 pp_newline (buffer);
2049 dump_gimple_seq (buffer, body, spc + 4, flags);
2050 newline_and_indent (buffer, spc + 2);
2051 pp_right_brace (buffer);
2053 else if (body)
2055 pp_newline (buffer);
2056 dump_gimple_seq (buffer, body, spc + 2, flags);
2062 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2063 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2064 in dumpfile.h). */
2066 static void
2067 dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
2068 int flags)
2070 if (flags & TDF_RAW)
2072 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2073 gimple_omp_atomic_load_lhs (gs),
2074 gimple_omp_atomic_load_rhs (gs));
2076 else
2078 pp_string (buffer, "#pragma omp atomic_load");
2079 if (gimple_omp_atomic_seq_cst_p (gs))
2080 pp_string (buffer, " seq_cst");
2081 if (gimple_omp_atomic_need_value_p (gs))
2082 pp_string (buffer, " [needed]");
2083 newline_and_indent (buffer, spc + 2);
2084 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2085 spc, flags, false);
2086 pp_space (buffer);
2087 pp_equal (buffer);
2088 pp_space (buffer);
2089 pp_star (buffer);
2090 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2091 spc, flags, false);
2095 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2096 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2097 in dumpfile.h). */
2099 static void
2100 dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
2101 int flags)
2103 if (flags & TDF_RAW)
2105 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2106 gimple_omp_atomic_store_val (gs));
2108 else
2110 pp_string (buffer, "#pragma omp atomic_store ");
2111 if (gimple_omp_atomic_seq_cst_p (gs))
2112 pp_string (buffer, "seq_cst ");
2113 if (gimple_omp_atomic_need_value_p (gs))
2114 pp_string (buffer, "[needed] ");
2115 pp_left_paren (buffer);
2116 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2117 spc, flags, false);
2118 pp_right_paren (buffer);
2123 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2124 FLAGS are as in pp_gimple_stmt_1. */
2126 static void
2127 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
2129 tree vdef = gimple_vdef (gs);
2130 tree vuse = gimple_vuse (gs);
2132 if (vdef != NULL_TREE)
2134 pp_string (buffer, "# ");
2135 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2136 pp_string (buffer, " = VDEF <");
2137 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2138 pp_greater (buffer);
2139 newline_and_indent (buffer, spc);
2141 else if (vuse != NULL_TREE)
2143 pp_string (buffer, "# VUSE <");
2144 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2145 pp_greater (buffer);
2146 newline_and_indent (buffer, spc);
2151 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2152 spaces of indent. FLAGS specifies details to show in the dump (see
2153 TDF_* in dumpfile.h). The caller is responsible for calling
2154 pp_flush on BUFFER to finalize the pretty printer. */
2156 void
2157 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
2159 if (!gs)
2160 return;
2162 if (flags & TDF_STMTADDR)
2163 pp_printf (buffer, "<&%p> ", (void *) gs);
2165 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2167 expanded_location xloc = expand_location (gimple_location (gs));
2168 pp_left_bracket (buffer);
2169 if (xloc.file)
2171 pp_string (buffer, xloc.file);
2172 pp_string (buffer, " : ");
2174 pp_decimal_int (buffer, xloc.line);
2175 pp_colon (buffer);
2176 pp_decimal_int (buffer, xloc.column);
2177 pp_string (buffer, "] ");
2180 if (flags & TDF_EH)
2182 int lp_nr = lookup_stmt_eh_lp (gs);
2183 if (lp_nr > 0)
2184 pp_printf (buffer, "[LP %d] ", lp_nr);
2185 else if (lp_nr < 0)
2186 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2189 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2190 && gimple_has_mem_ops (gs))
2191 dump_gimple_mem_ops (buffer, gs, spc, flags);
2193 if (gimple_has_lhs (gs)
2194 && (flags & TDF_ALIAS))
2195 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2197 switch (gimple_code (gs))
2199 case GIMPLE_ASM:
2200 dump_gimple_asm (buffer, gs, spc, flags);
2201 break;
2203 case GIMPLE_ASSIGN:
2204 dump_gimple_assign (buffer, gs, spc, flags);
2205 break;
2207 case GIMPLE_BIND:
2208 dump_gimple_bind (buffer, gs, spc, flags);
2209 break;
2211 case GIMPLE_CALL:
2212 dump_gimple_call (buffer, gs, spc, flags);
2213 break;
2215 case GIMPLE_COND:
2216 dump_gimple_cond (buffer, gs, spc, flags);
2217 break;
2219 case GIMPLE_LABEL:
2220 dump_gimple_label (buffer, gs, spc, flags);
2221 break;
2223 case GIMPLE_GOTO:
2224 dump_gimple_goto (buffer, gs, spc, flags);
2225 break;
2227 case GIMPLE_NOP:
2228 pp_string (buffer, "GIMPLE_NOP");
2229 break;
2231 case GIMPLE_RETURN:
2232 dump_gimple_return (buffer, gs, spc, flags);
2233 break;
2235 case GIMPLE_SWITCH:
2236 dump_gimple_switch (buffer, gs, spc, flags);
2237 break;
2239 case GIMPLE_TRY:
2240 dump_gimple_try (buffer, gs, spc, flags);
2241 break;
2243 case GIMPLE_PHI:
2244 dump_gimple_phi (buffer, gs, spc, false, flags);
2245 break;
2247 case GIMPLE_OACC_KERNELS:
2248 case GIMPLE_OACC_PARALLEL:
2249 dump_gimple_oacc_offload (buffer, gs, spc, flags);
2250 break;
2252 case GIMPLE_OMP_PARALLEL:
2253 dump_gimple_omp_parallel (buffer, gs, spc, flags);
2254 break;
2256 case GIMPLE_OMP_TASK:
2257 dump_gimple_omp_task (buffer, gs, spc, flags);
2258 break;
2260 case GIMPLE_OMP_ATOMIC_LOAD:
2261 dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
2263 break;
2265 case GIMPLE_OMP_ATOMIC_STORE:
2266 dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
2267 break;
2269 case GIMPLE_OMP_FOR:
2270 dump_gimple_omp_for (buffer, gs, spc, flags);
2271 break;
2273 case GIMPLE_OMP_CONTINUE:
2274 dump_gimple_omp_continue (buffer, gs, spc, flags);
2275 break;
2277 case GIMPLE_OMP_SINGLE:
2278 dump_gimple_omp_single (buffer, gs, spc, flags);
2279 break;
2281 case GIMPLE_OMP_TARGET:
2282 dump_gimple_omp_target (buffer, gs, spc, flags);
2283 break;
2285 case GIMPLE_OMP_TEAMS:
2286 dump_gimple_omp_teams (buffer, gs, spc, flags);
2287 break;
2289 case GIMPLE_OMP_RETURN:
2290 dump_gimple_omp_return (buffer, gs, spc, flags);
2291 break;
2293 case GIMPLE_OMP_SECTIONS:
2294 dump_gimple_omp_sections (buffer, gs, spc, flags);
2295 break;
2297 case GIMPLE_OMP_SECTIONS_SWITCH:
2298 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2299 break;
2301 case GIMPLE_OMP_MASTER:
2302 case GIMPLE_OMP_TASKGROUP:
2303 case GIMPLE_OMP_ORDERED:
2304 case GIMPLE_OMP_SECTION:
2305 dump_gimple_omp_block (buffer, gs, spc, flags);
2306 break;
2308 case GIMPLE_OMP_CRITICAL:
2309 dump_gimple_omp_critical (buffer, gs, spc, flags);
2310 break;
2312 case GIMPLE_CATCH:
2313 dump_gimple_catch (buffer, gs, spc, flags);
2314 break;
2316 case GIMPLE_EH_FILTER:
2317 dump_gimple_eh_filter (buffer, gs, spc, flags);
2318 break;
2320 case GIMPLE_EH_MUST_NOT_THROW:
2321 dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
2322 break;
2324 case GIMPLE_EH_ELSE:
2325 dump_gimple_eh_else (buffer, gs, spc, flags);
2326 break;
2328 case GIMPLE_RESX:
2329 dump_gimple_resx (buffer, gs, spc, flags);
2330 break;
2332 case GIMPLE_EH_DISPATCH:
2333 dump_gimple_eh_dispatch (buffer, gs, spc, flags);
2334 break;
2336 case GIMPLE_DEBUG:
2337 dump_gimple_debug (buffer, gs, spc, flags);
2338 break;
2340 case GIMPLE_PREDICT:
2341 pp_string (buffer, "// predicted ");
2342 if (gimple_predict_outcome (gs))
2343 pp_string (buffer, "likely by ");
2344 else
2345 pp_string (buffer, "unlikely by ");
2346 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2347 pp_string (buffer, " predictor.");
2348 break;
2350 case GIMPLE_TRANSACTION:
2351 dump_gimple_transaction (buffer, gs, spc, flags);
2352 break;
2354 default:
2355 GIMPLE_NIY;
2360 /* Dumps header of basic block BB to OUTF indented by INDENT
2361 spaces and details described by flags. */
2363 static void
2364 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2366 if (flags & TDF_BLOCKS)
2368 if (flags & TDF_LINENO)
2370 gimple_stmt_iterator gsi;
2372 if (flags & TDF_COMMENT)
2373 fputs (";; ", outf);
2375 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2376 if (!is_gimple_debug (gsi_stmt (gsi))
2377 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2379 fprintf (outf, "%*sstarting at line %d",
2380 indent, "", get_lineno (gsi_stmt (gsi)));
2381 break;
2383 if (bb->discriminator)
2384 fprintf (outf, ", discriminator %i", bb->discriminator);
2385 fputc ('\n', outf);
2388 else
2390 gimple stmt = first_stmt (bb);
2391 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2392 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2397 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2398 spaces. */
2400 static void
2401 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2402 basic_block bb ATTRIBUTE_UNUSED,
2403 int indent ATTRIBUTE_UNUSED,
2404 int flags ATTRIBUTE_UNUSED)
2406 /* There is currently no GIMPLE-specific basic block info to dump. */
2407 return;
2411 /* Dump PHI nodes of basic block BB to BUFFER with details described
2412 by FLAGS and indented by INDENT spaces. */
2414 static void
2415 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2417 gimple_stmt_iterator i;
2419 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2421 gimple phi = gsi_stmt (i);
2422 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2424 INDENT (indent);
2425 dump_gimple_phi (buffer, phi, indent, true, flags);
2426 pp_newline (buffer);
2432 /* Dump jump to basic block BB that is represented implicitly in the cfg
2433 to BUFFER. */
2435 static void
2436 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2438 gimple stmt;
2440 stmt = first_stmt (bb);
2442 pp_string (buffer, "goto <bb ");
2443 pp_decimal_int (buffer, bb->index);
2444 pp_greater (buffer);
2445 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2447 pp_string (buffer, " (");
2448 dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
2449 pp_right_paren (buffer);
2450 pp_semicolon (buffer);
2452 else
2453 pp_semicolon (buffer);
2457 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2458 by INDENT spaces, with details given by FLAGS. */
2460 static void
2461 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2462 int flags)
2464 edge e;
2465 gimple stmt;
2467 stmt = last_stmt (bb);
2469 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2471 edge true_edge, false_edge;
2473 /* When we are emitting the code or changing CFG, it is possible that
2474 the edges are not yet created. When we are using debug_bb in such
2475 a situation, we do not want it to crash. */
2476 if (EDGE_COUNT (bb->succs) != 2)
2477 return;
2478 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2480 INDENT (indent + 2);
2481 pp_cfg_jump (buffer, true_edge->dest);
2482 newline_and_indent (buffer, indent);
2483 pp_string (buffer, "else");
2484 newline_and_indent (buffer, indent + 2);
2485 pp_cfg_jump (buffer, false_edge->dest);
2486 pp_newline (buffer);
2487 return;
2490 /* If there is a fallthru edge, we may need to add an artificial
2491 goto to the dump. */
2492 e = find_fallthru_edge (bb->succs);
2494 if (e && e->dest != bb->next_bb)
2496 INDENT (indent);
2498 if ((flags & TDF_LINENO)
2499 && e->goto_locus != UNKNOWN_LOCATION
2502 expanded_location goto_xloc;
2503 goto_xloc = expand_location (e->goto_locus);
2504 pp_left_bracket (buffer);
2505 if (goto_xloc.file)
2507 pp_string (buffer, goto_xloc.file);
2508 pp_string (buffer, " : ");
2510 pp_decimal_int (buffer, goto_xloc.line);
2511 pp_string (buffer, " : ");
2512 pp_decimal_int (buffer, goto_xloc.column);
2513 pp_string (buffer, "] ");
2516 pp_cfg_jump (buffer, e->dest);
2517 pp_newline (buffer);
2522 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2523 indented by INDENT spaces. */
2525 static void
2526 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2527 int flags)
2529 gimple_stmt_iterator gsi;
2530 gimple stmt;
2531 int label_indent = indent - 2;
2533 if (label_indent < 0)
2534 label_indent = 0;
2536 dump_phi_nodes (buffer, bb, indent, flags);
2538 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2540 int curr_indent;
2542 stmt = gsi_stmt (gsi);
2544 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2546 INDENT (curr_indent);
2547 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2548 pp_newline_and_flush (buffer);
2549 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2550 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2551 pp_buffer (buffer)->stream, stmt);
2554 dump_implicit_edges (buffer, bb, indent, flags);
2555 pp_flush (buffer);
2559 /* Dumps basic block BB to FILE with details described by FLAGS and
2560 indented by INDENT spaces. */
2562 void
2563 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2565 dump_gimple_bb_header (file, bb, indent, flags);
2566 if (bb->index >= NUM_FIXED_BLOCKS)
2568 pretty_printer buffer;
2569 pp_needs_newline (&buffer) = true;
2570 buffer.buffer->stream = file;
2571 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2573 dump_gimple_bb_footer (file, bb, indent, flags);
2576 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2577 no indentation, for use as a label of a DOT graph record-node.
2578 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2579 histogram dumping doesn't know about pretty-printers. */
2581 void
2582 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2584 gimple_stmt_iterator gsi;
2586 pp_printf (pp, "<bb %d>:\n", bb->index);
2587 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2589 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2591 gimple phi = gsi_stmt (gsi);
2592 if (!virtual_operand_p (gimple_phi_result (phi))
2593 || (dump_flags & TDF_VOPS))
2595 pp_bar (pp);
2596 pp_write_text_to_stream (pp);
2597 pp_string (pp, "# ");
2598 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2599 pp_newline (pp);
2600 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2604 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2606 gimple stmt = gsi_stmt (gsi);
2607 pp_bar (pp);
2608 pp_write_text_to_stream (pp);
2609 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2610 pp_newline (pp);
2611 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2613 dump_implicit_edges (pp, bb, 0, dump_flags);
2614 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);