svn merge -r 216846:217483 svn+ssh://gcc.gnu.org/svn/gcc/trunk
[official-gcc.git] / gcc / gimple-pretty-print.c
blob72dfac62b25340de39937d968c98d8ca3fec1e03
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 "predict.h"
33 #include "vec.h"
34 #include "hash-set.h"
35 #include "machmode.h"
36 #include "hard-reg-set.h"
37 #include "input.h"
38 #include "function.h"
39 #include "basic-block.h"
40 #include "tree-ssa-alias.h"
41 #include "internal-fn.h"
42 #include "tree-eh.h"
43 #include "gimple-expr.h"
44 #include "is-a.h"
45 #include "gimple.h"
46 #include "gimple-iterator.h"
47 #include "gimple-ssa.h"
48 #include "hash-map.h"
49 #include "plugin-api.h"
50 #include "ipa-ref.h"
51 #include "cgraph.h"
52 #include "tree-cfg.h"
53 #include "tree-ssanames.h"
54 #include "dumpfile.h" /* for dump_flags */
55 #include "value-prof.h"
56 #include "trans-mem.h"
58 #define INDENT(SPACE) \
59 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
61 #define GIMPLE_NIY do_niy (buffer,gs)
63 /* Try to print on BUFFER a default message for the unrecognized
64 gimple statement GS. */
66 static void
67 do_niy (pretty_printer *buffer, gimple gs)
69 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
70 gimple_code_name[(int) gimple_code (gs)]);
74 /* Emit a newline and SPC indentation spaces to BUFFER. */
76 static void
77 newline_and_indent (pretty_printer *buffer, int spc)
79 pp_newline (buffer);
80 INDENT (spc);
84 /* Print the GIMPLE statement GS on stderr. */
86 DEBUG_FUNCTION void
87 debug_gimple_stmt (gimple gs)
89 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
93 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
94 FLAGS as in pp_gimple_stmt_1. */
96 void
97 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
99 pretty_printer buffer;
100 pp_needs_newline (&buffer) = true;
101 buffer.buffer->stream = file;
102 pp_gimple_stmt_1 (&buffer, g, spc, flags);
103 pp_newline_and_flush (&buffer);
106 DEBUG_FUNCTION void
107 debug (gimple_statement_base &ref)
109 print_gimple_stmt (stderr, &ref, 0, 0);
112 DEBUG_FUNCTION void
113 debug (gimple_statement_base *ptr)
115 if (ptr)
116 debug (*ptr);
117 else
118 fprintf (stderr, "<nil>\n");
122 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
123 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
124 of the statement. */
126 void
127 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
129 flags |= TDF_RHS_ONLY;
130 pretty_printer buffer;
131 pp_needs_newline (&buffer) = true;
132 buffer.buffer->stream = file;
133 pp_gimple_stmt_1 (&buffer, g, spc, flags);
134 pp_flush (&buffer);
138 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
139 spaces and FLAGS as in pp_gimple_stmt_1.
140 The caller is responsible for calling pp_flush on BUFFER to finalize
141 the pretty printer. */
143 static void
144 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
146 gimple_stmt_iterator i;
148 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
150 gimple gs = gsi_stmt (i);
151 INDENT (spc);
152 pp_gimple_stmt_1 (buffer, gs, spc, flags);
153 if (!gsi_one_before_end_p (i))
154 pp_newline (buffer);
159 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
160 FLAGS as in pp_gimple_stmt_1. */
162 void
163 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
165 pretty_printer buffer;
166 pp_needs_newline (&buffer) = true;
167 buffer.buffer->stream = file;
168 dump_gimple_seq (&buffer, seq, spc, flags);
169 pp_newline_and_flush (&buffer);
173 /* Print the GIMPLE sequence SEQ on stderr. */
175 DEBUG_FUNCTION void
176 debug_gimple_seq (gimple_seq seq)
178 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
182 /* A simple helper to pretty-print some of the gimple tuples in the printf
183 style. The format modifiers are preceded by '%' and are:
184 'G' - outputs a string corresponding to the code of the given gimple,
185 'S' - outputs a gimple_seq with indent of spc + 2,
186 'T' - outputs the tree t,
187 'd' - outputs an int as a decimal,
188 's' - outputs a string,
189 'n' - outputs a newline,
190 'x' - outputs an int as hexadecimal,
191 '+' - increases indent by 2 then outputs a newline,
192 '-' - decreases indent by 2 then outputs a newline. */
194 static void
195 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
196 const char *fmt, ...)
198 va_list args;
199 const char *c;
200 const char *tmp;
202 va_start (args, fmt);
203 for (c = fmt; *c; c++)
205 if (*c == '%')
207 gimple_seq seq;
208 tree t;
209 gimple g;
210 switch (*++c)
212 case 'G':
213 g = va_arg (args, gimple);
214 tmp = gimple_code_name[gimple_code (g)];
215 pp_string (buffer, tmp);
216 break;
218 case 'S':
219 seq = va_arg (args, gimple_seq);
220 pp_newline (buffer);
221 dump_gimple_seq (buffer, seq, spc + 2, flags);
222 newline_and_indent (buffer, spc);
223 break;
225 case 'T':
226 t = va_arg (args, tree);
227 if (t == NULL_TREE)
228 pp_string (buffer, "NULL");
229 else
230 dump_generic_node (buffer, t, spc, flags, false);
231 break;
233 case 'd':
234 pp_decimal_int (buffer, va_arg (args, int));
235 break;
237 case 's':
238 pp_string (buffer, va_arg (args, char *));
239 break;
241 case 'n':
242 newline_and_indent (buffer, spc);
243 break;
245 case 'x':
246 pp_scalar (buffer, "%x", va_arg (args, int));
247 break;
249 case '+':
250 spc += 2;
251 newline_and_indent (buffer, spc);
252 break;
254 case '-':
255 spc -= 2;
256 newline_and_indent (buffer, spc);
257 break;
259 default:
260 gcc_unreachable ();
263 else
264 pp_character (buffer, *c);
266 va_end (args);
270 /* Helper for dump_gimple_assign. Print the unary RHS of the
271 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
273 static void
274 dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
276 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
277 tree lhs = gimple_assign_lhs (gs);
278 tree rhs = gimple_assign_rhs1 (gs);
280 switch (rhs_code)
282 case VIEW_CONVERT_EXPR:
283 case ASSERT_EXPR:
284 dump_generic_node (buffer, rhs, spc, flags, false);
285 break;
287 case FIXED_CONVERT_EXPR:
288 case ADDR_SPACE_CONVERT_EXPR:
289 case FIX_TRUNC_EXPR:
290 case FLOAT_EXPR:
291 CASE_CONVERT:
292 pp_left_paren (buffer);
293 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
294 pp_string (buffer, ") ");
295 if (op_prio (rhs) < op_code_prio (rhs_code))
297 pp_left_paren (buffer);
298 dump_generic_node (buffer, rhs, spc, flags, false);
299 pp_right_paren (buffer);
301 else
302 dump_generic_node (buffer, rhs, spc, flags, false);
303 break;
305 case PAREN_EXPR:
306 pp_string (buffer, "((");
307 dump_generic_node (buffer, rhs, spc, flags, false);
308 pp_string (buffer, "))");
309 break;
311 case ABS_EXPR:
312 pp_string (buffer, "ABS_EXPR <");
313 dump_generic_node (buffer, rhs, spc, flags, false);
314 pp_greater (buffer);
315 break;
317 default:
318 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
319 || TREE_CODE_CLASS (rhs_code) == tcc_constant
320 || TREE_CODE_CLASS (rhs_code) == tcc_reference
321 || rhs_code == SSA_NAME
322 || rhs_code == ADDR_EXPR
323 || rhs_code == CONSTRUCTOR)
325 dump_generic_node (buffer, rhs, spc, flags, false);
326 break;
328 else if (rhs_code == BIT_NOT_EXPR)
329 pp_complement (buffer);
330 else if (rhs_code == TRUTH_NOT_EXPR)
331 pp_exclamation (buffer);
332 else if (rhs_code == NEGATE_EXPR)
333 pp_minus (buffer);
334 else
336 pp_left_bracket (buffer);
337 pp_string (buffer, get_tree_code_name (rhs_code));
338 pp_string (buffer, "] ");
341 if (op_prio (rhs) < op_code_prio (rhs_code))
343 pp_left_paren (buffer);
344 dump_generic_node (buffer, rhs, spc, flags, false);
345 pp_right_paren (buffer);
347 else
348 dump_generic_node (buffer, rhs, spc, flags, false);
349 break;
354 /* Helper for dump_gimple_assign. Print the binary RHS of the
355 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
357 static void
358 dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
360 const char *p;
361 enum tree_code code = gimple_assign_rhs_code (gs);
362 switch (code)
364 case COMPLEX_EXPR:
365 case MIN_EXPR:
366 case MAX_EXPR:
367 case VEC_WIDEN_MULT_HI_EXPR:
368 case VEC_WIDEN_MULT_LO_EXPR:
369 case VEC_WIDEN_MULT_EVEN_EXPR:
370 case VEC_WIDEN_MULT_ODD_EXPR:
371 case VEC_PACK_TRUNC_EXPR:
372 case VEC_PACK_SAT_EXPR:
373 case VEC_PACK_FIX_TRUNC_EXPR:
374 case VEC_WIDEN_LSHIFT_HI_EXPR:
375 case VEC_WIDEN_LSHIFT_LO_EXPR:
376 for (p = get_tree_code_name (code); *p; p++)
377 pp_character (buffer, TOUPPER (*p));
378 pp_string (buffer, " <");
379 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
380 pp_string (buffer, ", ");
381 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
382 pp_greater (buffer);
383 break;
385 default:
386 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
388 pp_left_paren (buffer);
389 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
390 false);
391 pp_right_paren (buffer);
393 else
394 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
395 pp_space (buffer);
396 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
397 pp_space (buffer);
398 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
400 pp_left_paren (buffer);
401 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
402 false);
403 pp_right_paren (buffer);
405 else
406 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
410 /* Helper for dump_gimple_assign. Print the ternary RHS of the
411 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
413 static void
414 dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
416 const char *p;
417 enum tree_code code = gimple_assign_rhs_code (gs);
418 switch (code)
420 case WIDEN_MULT_PLUS_EXPR:
421 case WIDEN_MULT_MINUS_EXPR:
422 for (p = get_tree_code_name (code); *p; p++)
423 pp_character (buffer, TOUPPER (*p));
424 pp_string (buffer, " <");
425 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
426 pp_string (buffer, ", ");
427 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
428 pp_string (buffer, ", ");
429 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
430 pp_greater (buffer);
431 break;
433 case FMA_EXPR:
434 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
435 pp_string (buffer, " * ");
436 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
437 pp_string (buffer, " + ");
438 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
439 break;
441 case DOT_PROD_EXPR:
442 pp_string (buffer, "DOT_PROD_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 SAD_EXPR:
452 pp_string (buffer, "SAD_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 VEC_PERM_EXPR:
462 pp_string (buffer, "VEC_PERM_EXPR <");
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 REALIGN_LOAD_EXPR:
472 pp_string (buffer, "REALIGN_LOAD <");
473 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
474 pp_string (buffer, ", ");
475 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
476 pp_string (buffer, ", ");
477 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
478 pp_greater (buffer);
479 break;
481 case COND_EXPR:
482 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
483 pp_string (buffer, " ? ");
484 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
485 pp_string (buffer, " : ");
486 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
487 break;
489 case VEC_COND_EXPR:
490 pp_string (buffer, "VEC_COND_EXPR <");
491 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
492 pp_string (buffer, ", ");
493 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
494 pp_string (buffer, ", ");
495 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
496 pp_greater (buffer);
497 break;
499 default:
500 gcc_unreachable ();
505 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
506 pp_gimple_stmt_1. */
508 static void
509 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
511 if (flags & TDF_RAW)
513 tree arg1 = NULL;
514 tree arg2 = NULL;
515 tree arg3 = NULL;
516 switch (gimple_num_ops (gs))
518 case 4:
519 arg3 = gimple_assign_rhs3 (gs);
520 case 3:
521 arg2 = gimple_assign_rhs2 (gs);
522 case 2:
523 arg1 = gimple_assign_rhs1 (gs);
524 break;
525 default:
526 gcc_unreachable ();
529 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
530 get_tree_code_name (gimple_assign_rhs_code (gs)),
531 gimple_assign_lhs (gs), arg1, arg2, arg3);
533 else
535 if (!(flags & TDF_RHS_ONLY))
537 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
538 pp_space (buffer);
539 pp_equal (buffer);
541 if (gimple_assign_nontemporal_move_p (gs))
542 pp_string (buffer, "{nt}");
544 if (gimple_has_volatile_ops (gs))
545 pp_string (buffer, "{v}");
547 pp_space (buffer);
550 if (gimple_num_ops (gs) == 2)
551 dump_unary_rhs (buffer, gs, spc, flags);
552 else if (gimple_num_ops (gs) == 3)
553 dump_binary_rhs (buffer, gs, spc, flags);
554 else if (gimple_num_ops (gs) == 4)
555 dump_ternary_rhs (buffer, gs, spc, flags);
556 else
557 gcc_unreachable ();
558 if (!(flags & TDF_RHS_ONLY))
559 pp_semicolon (buffer);
564 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
565 pp_gimple_stmt_1. */
567 static void
568 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
570 tree t, t2;
572 t = gimple_return_retval (gs);
573 t2 = gimple_return_retbnd (gs);
574 if (flags & TDF_RAW)
575 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
576 else
578 pp_string (buffer, "return");
579 if (t)
581 pp_space (buffer);
582 dump_generic_node (buffer, t, spc, flags, false);
584 if (t2)
586 pp_string (buffer, ", ");
587 dump_generic_node (buffer, t2, spc, flags, false);
589 pp_semicolon (buffer);
594 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
595 dump_gimple_call. */
597 static void
598 dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags)
600 size_t i;
602 for (i = 0; i < gimple_call_num_args (gs); i++)
604 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
605 if (i < gimple_call_num_args (gs) - 1)
606 pp_string (buffer, ", ");
609 if (gimple_call_va_arg_pack_p (gs))
611 if (gimple_call_num_args (gs) > 0)
613 pp_comma (buffer);
614 pp_space (buffer);
617 pp_string (buffer, "__builtin_va_arg_pack ()");
621 /* Dump the points-to solution *PT to BUFFER. */
623 static void
624 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
626 if (pt->anything)
628 pp_string (buffer, "anything ");
629 return;
631 if (pt->nonlocal)
632 pp_string (buffer, "nonlocal ");
633 if (pt->escaped)
634 pp_string (buffer, "escaped ");
635 if (pt->ipa_escaped)
636 pp_string (buffer, "unit-escaped ");
637 if (pt->null)
638 pp_string (buffer, "null ");
639 if (pt->vars
640 && !bitmap_empty_p (pt->vars))
642 bitmap_iterator bi;
643 unsigned i;
644 pp_string (buffer, "{ ");
645 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
647 pp_string (buffer, "D.");
648 pp_decimal_int (buffer, i);
649 pp_space (buffer);
651 pp_right_brace (buffer);
652 if (pt->vars_contains_nonlocal
653 && pt->vars_contains_escaped_heap)
654 pp_string (buffer, " (nonlocal, escaped heap)");
655 else if (pt->vars_contains_nonlocal
656 && pt->vars_contains_escaped)
657 pp_string (buffer, " (nonlocal, escaped)");
658 else if (pt->vars_contains_nonlocal)
659 pp_string (buffer, " (nonlocal)");
660 else if (pt->vars_contains_escaped_heap)
661 pp_string (buffer, " (escaped heap)");
662 else if (pt->vars_contains_escaped)
663 pp_string (buffer, " (escaped)");
667 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
668 pp_gimple_stmt_1. */
670 static void
671 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
673 tree lhs = gimple_call_lhs (gs);
674 tree fn = gimple_call_fn (gs);
676 if (flags & TDF_ALIAS)
678 struct pt_solution *pt;
679 pt = gimple_call_use_set (gs);
680 if (!pt_solution_empty_p (pt))
682 pp_string (buffer, "# USE = ");
683 pp_points_to_solution (buffer, pt);
684 newline_and_indent (buffer, spc);
686 pt = gimple_call_clobber_set (gs);
687 if (!pt_solution_empty_p (pt))
689 pp_string (buffer, "# CLB = ");
690 pp_points_to_solution (buffer, pt);
691 newline_and_indent (buffer, spc);
695 if (flags & TDF_RAW)
697 if (gimple_call_internal_p (gs))
698 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
699 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
700 else
701 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
702 if (gimple_call_num_args (gs) > 0)
704 pp_string (buffer, ", ");
705 dump_gimple_call_args (buffer, gs, flags);
707 pp_greater (buffer);
709 else
711 if (lhs && !(flags & TDF_RHS_ONLY))
713 dump_generic_node (buffer, lhs, spc, flags, false);
714 pp_string (buffer, " =");
716 if (gimple_has_volatile_ops (gs))
717 pp_string (buffer, "{v}");
719 pp_space (buffer);
721 if (gimple_call_internal_p (gs))
722 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
723 else
724 print_call_name (buffer, fn, flags);
725 pp_string (buffer, " (");
726 dump_gimple_call_args (buffer, gs, flags);
727 pp_right_paren (buffer);
728 if (!(flags & TDF_RHS_ONLY))
729 pp_semicolon (buffer);
732 if (gimple_call_chain (gs))
734 pp_string (buffer, " [static-chain: ");
735 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
736 pp_right_bracket (buffer);
739 if (gimple_call_return_slot_opt_p (gs))
740 pp_string (buffer, " [return slot optimization]");
741 if (gimple_call_tail_p (gs))
742 pp_string (buffer, " [tail call]");
744 if (fn == NULL)
745 return;
747 /* Dump the arguments of _ITM_beginTransaction sanely. */
748 if (TREE_CODE (fn) == ADDR_EXPR)
749 fn = TREE_OPERAND (fn, 0);
750 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
751 pp_string (buffer, " [tm-clone]");
752 if (TREE_CODE (fn) == FUNCTION_DECL
753 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
754 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
755 && gimple_call_num_args (gs) > 0)
757 tree t = gimple_call_arg (gs, 0);
758 unsigned HOST_WIDE_INT props;
759 gcc_assert (TREE_CODE (t) == INTEGER_CST);
761 pp_string (buffer, " [ ");
763 /* Get the transaction code properties. */
764 props = TREE_INT_CST_LOW (t);
766 if (props & PR_INSTRUMENTEDCODE)
767 pp_string (buffer, "instrumentedCode ");
768 if (props & PR_UNINSTRUMENTEDCODE)
769 pp_string (buffer, "uninstrumentedCode ");
770 if (props & PR_HASNOXMMUPDATE)
771 pp_string (buffer, "hasNoXMMUpdate ");
772 if (props & PR_HASNOABORT)
773 pp_string (buffer, "hasNoAbort ");
774 if (props & PR_HASNOIRREVOCABLE)
775 pp_string (buffer, "hasNoIrrevocable ");
776 if (props & PR_DOESGOIRREVOCABLE)
777 pp_string (buffer, "doesGoIrrevocable ");
778 if (props & PR_HASNOSIMPLEREADS)
779 pp_string (buffer, "hasNoSimpleReads ");
780 if (props & PR_AWBARRIERSOMITTED)
781 pp_string (buffer, "awBarriersOmitted ");
782 if (props & PR_RARBARRIERSOMITTED)
783 pp_string (buffer, "RaRBarriersOmitted ");
784 if (props & PR_UNDOLOGCODE)
785 pp_string (buffer, "undoLogCode ");
786 if (props & PR_PREFERUNINSTRUMENTED)
787 pp_string (buffer, "preferUninstrumented ");
788 if (props & PR_EXCEPTIONBLOCK)
789 pp_string (buffer, "exceptionBlock ");
790 if (props & PR_HASELSE)
791 pp_string (buffer, "hasElse ");
792 if (props & PR_READONLY)
793 pp_string (buffer, "readOnly ");
795 pp_right_bracket (buffer);
800 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
801 pp_gimple_stmt_1. */
803 static void
804 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
806 unsigned int i;
808 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
809 if (flags & TDF_RAW)
810 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
811 gimple_switch_index (gs));
812 else
814 pp_string (buffer, "switch (");
815 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
816 pp_string (buffer, ") <");
819 for (i = 0; i < gimple_switch_num_labels (gs); i++)
821 tree case_label = gimple_switch_label (gs, i);
822 gcc_checking_assert (case_label != NULL_TREE);
823 dump_generic_node (buffer, case_label, spc, flags, false);
824 pp_space (buffer);
825 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
826 if (i < gimple_switch_num_labels (gs) - 1)
827 pp_string (buffer, ", ");
829 pp_greater (buffer);
833 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
834 pp_gimple_stmt_1. */
836 static void
837 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
839 if (flags & TDF_RAW)
840 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
841 get_tree_code_name (gimple_cond_code (gs)),
842 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
843 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
844 else
846 if (!(flags & TDF_RHS_ONLY))
847 pp_string (buffer, "if (");
848 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
849 pp_space (buffer);
850 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
851 pp_space (buffer);
852 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
853 if (!(flags & TDF_RHS_ONLY))
855 pp_right_paren (buffer);
857 if (gimple_cond_true_label (gs))
859 pp_string (buffer, " goto ");
860 dump_generic_node (buffer, gimple_cond_true_label (gs),
861 spc, flags, false);
862 pp_semicolon (buffer);
864 if (gimple_cond_false_label (gs))
866 pp_string (buffer, " else goto ");
867 dump_generic_node (buffer, gimple_cond_false_label (gs),
868 spc, flags, false);
869 pp_semicolon (buffer);
876 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
877 spaces of indent. FLAGS specifies details to show in the dump (see
878 TDF_* in dumpfils.h). */
880 static void
881 dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
883 tree label = gimple_label_label (gs);
884 if (flags & TDF_RAW)
885 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
886 else
888 dump_generic_node (buffer, label, spc, flags, false);
889 pp_colon (buffer);
891 if (DECL_NONLOCAL (label))
892 pp_string (buffer, " [non-local]");
893 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
894 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
897 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
898 spaces of indent. FLAGS specifies details to show in the dump (see
899 TDF_* in dumpfile.h). */
901 static void
902 dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
904 tree label = gimple_goto_dest (gs);
905 if (flags & TDF_RAW)
906 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
907 else
908 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
912 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
913 spaces of indent. FLAGS specifies details to show in the dump (see
914 TDF_* in dumpfile.h). */
916 static void
917 dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
919 if (flags & TDF_RAW)
920 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
921 else
922 pp_left_brace (buffer);
923 if (!(flags & TDF_SLIM))
925 tree var;
927 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
929 newline_and_indent (buffer, 2);
930 print_declaration (buffer, var, spc, flags);
932 if (gimple_bind_vars (gs))
933 pp_newline (buffer);
935 pp_newline (buffer);
936 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
937 newline_and_indent (buffer, spc);
938 if (flags & TDF_RAW)
939 pp_greater (buffer);
940 else
941 pp_right_brace (buffer);
945 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
946 indent. FLAGS specifies details to show in the dump (see TDF_* in
947 dumpfile.h). */
949 static void
950 dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
952 if (flags & TDF_RAW)
954 const char *type;
955 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
956 type = "GIMPLE_TRY_CATCH";
957 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
958 type = "GIMPLE_TRY_FINALLY";
959 else
960 type = "UNKNOWN GIMPLE_TRY";
961 dump_gimple_fmt (buffer, spc, flags,
962 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
963 gimple_try_eval (gs), gimple_try_cleanup (gs));
965 else
967 pp_string (buffer, "try");
968 newline_and_indent (buffer, spc + 2);
969 pp_left_brace (buffer);
970 pp_newline (buffer);
972 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
973 newline_and_indent (buffer, spc + 2);
974 pp_right_brace (buffer);
976 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
978 newline_and_indent (buffer, spc);
979 pp_string (buffer, "catch");
980 newline_and_indent (buffer, spc + 2);
981 pp_left_brace (buffer);
983 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
985 newline_and_indent (buffer, spc);
986 pp_string (buffer, "finally");
987 newline_and_indent (buffer, spc + 2);
988 pp_left_brace (buffer);
990 else
991 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
993 pp_newline (buffer);
994 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
995 newline_and_indent (buffer, spc + 2);
996 pp_right_brace (buffer);
1001 /* Dump a GIMPLE_CATCH 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_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
1008 if (flags & TDF_RAW)
1009 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1010 gimple_catch_types (gs), gimple_catch_handler (gs));
1011 else
1012 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1013 gimple_catch_types (gs), gimple_catch_handler (gs));
1017 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1018 indent. FLAGS specifies details to show in the dump (see TDF_* in
1019 dumpfile.h). */
1021 static void
1022 dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
1024 if (flags & TDF_RAW)
1025 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1026 gimple_eh_filter_types (gs),
1027 gimple_eh_filter_failure (gs));
1028 else
1029 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1030 gimple_eh_filter_types (gs),
1031 gimple_eh_filter_failure (gs));
1035 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1037 static void
1038 dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
1039 int spc, int flags)
1041 if (flags & TDF_RAW)
1042 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1043 gimple_eh_must_not_throw_fndecl (gs));
1044 else
1045 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1046 gimple_eh_must_not_throw_fndecl (gs));
1050 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1051 indent. FLAGS specifies details to show in the dump (see TDF_* in
1052 dumpfile.h). */
1054 static void
1055 dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags)
1057 if (flags & TDF_RAW)
1058 dump_gimple_fmt (buffer, spc, flags,
1059 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1060 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1061 else
1062 dump_gimple_fmt (buffer, spc, flags,
1063 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1064 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1068 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1069 indent. FLAGS specifies details to show in the dump (see TDF_* in
1070 dumpfile.h). */
1072 static void
1073 dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
1075 if (flags & TDF_RAW)
1076 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1077 gimple_resx_region (gs));
1078 else
1079 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1082 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1084 static void
1085 dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
1087 if (flags & TDF_RAW)
1088 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1089 gimple_eh_dispatch_region (gs));
1090 else
1091 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1092 gimple_eh_dispatch_region (gs));
1095 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1096 of indent. FLAGS specifies details to show in the dump (see TDF_*
1097 in dumpfile.h). */
1099 static void
1100 dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
1102 switch (gs->subcode)
1104 case GIMPLE_DEBUG_BIND:
1105 if (flags & TDF_RAW)
1106 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1107 gimple_debug_bind_get_var (gs),
1108 gimple_debug_bind_get_value (gs));
1109 else
1110 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1111 gimple_debug_bind_get_var (gs),
1112 gimple_debug_bind_get_value (gs));
1113 break;
1115 case GIMPLE_DEBUG_SOURCE_BIND:
1116 if (flags & TDF_RAW)
1117 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1118 gimple_debug_source_bind_get_var (gs),
1119 gimple_debug_source_bind_get_value (gs));
1120 else
1121 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1122 gimple_debug_source_bind_get_var (gs),
1123 gimple_debug_source_bind_get_value (gs));
1124 break;
1126 default:
1127 gcc_unreachable ();
1131 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1132 static void
1133 dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
1135 size_t i;
1137 if (flags & TDF_RAW)
1139 const char *kind;
1140 switch (gimple_omp_for_kind (gs))
1142 case GF_OMP_FOR_KIND_FOR:
1143 kind = "";
1144 break;
1145 case GF_OMP_FOR_KIND_DISTRIBUTE:
1146 kind = " distribute";
1147 break;
1148 case GF_OMP_FOR_KIND_CILKFOR:
1149 kind = " _Cilk_for";
1150 break;
1151 case GF_OMP_FOR_KIND_OACC_LOOP:
1152 kind = " oacc_loop";
1153 break;
1154 case GF_OMP_FOR_KIND_SIMD:
1155 kind = " simd";
1156 break;
1157 case GF_OMP_FOR_KIND_CILKSIMD:
1158 kind = " cilksimd";
1159 break;
1160 default:
1161 gcc_unreachable ();
1163 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1164 kind, gimple_omp_body (gs));
1165 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1166 dump_gimple_fmt (buffer, spc, flags, " >,");
1167 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1168 dump_gimple_fmt (buffer, spc, flags,
1169 "%+%T, %T, %T, %s, %T,%n",
1170 gimple_omp_for_index (gs, i),
1171 gimple_omp_for_initial (gs, i),
1172 gimple_omp_for_final (gs, i),
1173 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1174 gimple_omp_for_incr (gs, i));
1175 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1176 gimple_omp_for_pre_body (gs));
1178 else
1180 switch (gimple_omp_for_kind (gs))
1182 case GF_OMP_FOR_KIND_FOR:
1183 pp_string (buffer, "#pragma omp for");
1184 break;
1185 case GF_OMP_FOR_KIND_DISTRIBUTE:
1186 pp_string (buffer, "#pragma omp distribute");
1187 break;
1188 case GF_OMP_FOR_KIND_CILKFOR:
1189 break;
1190 case GF_OMP_FOR_KIND_OACC_LOOP:
1191 pp_string (buffer, "#pragma acc loop");
1192 break;
1193 case GF_OMP_FOR_KIND_SIMD:
1194 pp_string (buffer, "#pragma omp simd");
1195 break;
1196 case GF_OMP_FOR_KIND_CILKSIMD:
1197 pp_string (buffer, "#pragma simd");
1198 break;
1199 default:
1200 gcc_unreachable ();
1202 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1203 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1204 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1206 if (i)
1207 spc += 2;
1208 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1209 pp_string (buffer, "_Cilk_for (");
1210 else
1212 newline_and_indent (buffer, spc);
1213 pp_string (buffer, "for (");
1215 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1216 flags, false);
1217 pp_string (buffer, " = ");
1218 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1219 flags, false);
1220 pp_string (buffer, "; ");
1222 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1223 flags, false);
1224 pp_space (buffer);
1225 switch (gimple_omp_for_cond (gs, i))
1227 case LT_EXPR:
1228 pp_less (buffer);
1229 break;
1230 case GT_EXPR:
1231 pp_greater (buffer);
1232 break;
1233 case LE_EXPR:
1234 pp_less_equal (buffer);
1235 break;
1236 case GE_EXPR:
1237 pp_greater_equal (buffer);
1238 break;
1239 case NE_EXPR:
1240 pp_string (buffer, "!=");
1241 break;
1242 default:
1243 gcc_unreachable ();
1245 pp_space (buffer);
1246 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1247 flags, false);
1248 pp_string (buffer, "; ");
1250 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1251 flags, false);
1252 pp_string (buffer, " = ");
1253 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1254 flags, false);
1255 pp_right_paren (buffer);
1258 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1260 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1261 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1262 newline_and_indent (buffer, spc + 2);
1263 pp_left_brace (buffer);
1264 pp_newline (buffer);
1265 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1266 newline_and_indent (buffer, spc + 2);
1267 pp_right_brace (buffer);
1272 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1274 static void
1275 dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, 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, gimple gs, int spc, int flags)
1301 if (flags & TDF_RAW)
1303 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1304 gimple_omp_body (gs));
1305 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1306 dump_gimple_fmt (buffer, spc, flags, " >");
1308 else
1310 pp_string (buffer, "#pragma omp single");
1311 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1312 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1314 newline_and_indent (buffer, spc + 2);
1315 pp_left_brace (buffer);
1316 pp_newline (buffer);
1317 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1318 newline_and_indent (buffer, spc + 2);
1319 pp_right_brace (buffer);
1324 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1326 static void
1327 dump_gimple_omp_target (pretty_printer *buffer, gimple gs, int spc, int flags)
1329 const char *kind;
1330 switch (gimple_omp_target_kind (gs))
1332 case GF_OMP_TARGET_KIND_REGION:
1333 kind = "";
1334 break;
1335 case GF_OMP_TARGET_KIND_DATA:
1336 kind = " data";
1337 break;
1338 case GF_OMP_TARGET_KIND_UPDATE:
1339 kind = " update";
1340 break;
1341 case GF_OMP_TARGET_KIND_OACC_DATA:
1342 kind = " oacc_data";
1343 break;
1344 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1345 kind = " oacc_enter_exit_data";
1346 break;
1347 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1348 kind = " oacc_update";
1349 break;
1350 default:
1351 gcc_unreachable ();
1353 if (flags & TDF_RAW)
1355 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1356 kind, gimple_omp_body (gs));
1357 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1358 dump_gimple_fmt (buffer, spc, flags, " >");
1360 else
1362 pp_string (buffer, "#pragma omp target");
1363 pp_string (buffer, kind);
1364 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1365 if (gimple_omp_target_child_fn (gs))
1367 pp_string (buffer, " [child fn: ");
1368 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1369 spc, flags, false);
1370 pp_right_bracket (buffer);
1372 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1374 newline_and_indent (buffer, spc + 2);
1375 pp_character (buffer, '{');
1376 pp_newline (buffer);
1377 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1378 newline_and_indent (buffer, spc + 2);
1379 pp_character (buffer, '}');
1384 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1386 static void
1387 dump_gimple_omp_teams (pretty_printer *buffer, gimple gs, int spc, int flags)
1389 if (flags & TDF_RAW)
1391 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1392 gimple_omp_body (gs));
1393 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1394 dump_gimple_fmt (buffer, spc, flags, " >");
1396 else
1398 pp_string (buffer, "#pragma omp teams");
1399 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1400 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1402 newline_and_indent (buffer, spc + 2);
1403 pp_character (buffer, '{');
1404 pp_newline (buffer);
1405 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1406 newline_and_indent (buffer, spc + 2);
1407 pp_character (buffer, '}');
1412 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1414 static void
1415 dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
1416 int flags)
1418 if (flags & TDF_RAW)
1420 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1421 gimple_omp_body (gs));
1422 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1423 dump_gimple_fmt (buffer, spc, flags, " >");
1425 else
1427 pp_string (buffer, "#pragma omp sections");
1428 if (gimple_omp_sections_control (gs))
1430 pp_string (buffer, " <");
1431 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1432 flags, false);
1433 pp_greater (buffer);
1435 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1436 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1438 newline_and_indent (buffer, spc + 2);
1439 pp_left_brace (buffer);
1440 pp_newline (buffer);
1441 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1442 newline_and_indent (buffer, spc + 2);
1443 pp_right_brace (buffer);
1448 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1449 pretty_printer BUFFER. */
1451 static void
1452 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1454 if (flags & TDF_RAW)
1455 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1456 gimple_omp_body (gs));
1457 else
1459 switch (gimple_code (gs))
1461 case GIMPLE_OMP_MASTER:
1462 pp_string (buffer, "#pragma omp master");
1463 break;
1464 case GIMPLE_OMP_TASKGROUP:
1465 pp_string (buffer, "#pragma omp taskgroup");
1466 break;
1467 case GIMPLE_OMP_ORDERED:
1468 pp_string (buffer, "#pragma omp ordered");
1469 break;
1470 case GIMPLE_OMP_SECTION:
1471 pp_string (buffer, "#pragma omp section");
1472 break;
1473 default:
1474 gcc_unreachable ();
1476 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1478 newline_and_indent (buffer, spc + 2);
1479 pp_left_brace (buffer);
1480 pp_newline (buffer);
1481 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1482 newline_and_indent (buffer, spc + 2);
1483 pp_right_brace (buffer);
1488 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1490 static void
1491 dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
1492 int flags)
1494 if (flags & TDF_RAW)
1495 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1496 gimple_omp_body (gs));
1497 else
1499 pp_string (buffer, "#pragma omp critical");
1500 if (gimple_omp_critical_name (gs))
1502 pp_string (buffer, " (");
1503 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1504 flags, false);
1505 pp_right_paren (buffer);
1507 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1509 newline_and_indent (buffer, spc + 2);
1510 pp_left_brace (buffer);
1511 pp_newline (buffer);
1512 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1513 newline_and_indent (buffer, spc + 2);
1514 pp_right_brace (buffer);
1519 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1521 static void
1522 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1524 if (flags & TDF_RAW)
1526 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1527 (int) gimple_omp_return_nowait_p (gs));
1528 if (gimple_omp_return_lhs (gs))
1529 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1530 gimple_omp_return_lhs (gs));
1531 else
1532 dump_gimple_fmt (buffer, spc, flags, ">");
1534 else
1536 pp_string (buffer, "#pragma omp return");
1537 if (gimple_omp_return_nowait_p (gs))
1538 pp_string (buffer, "(nowait)");
1539 if (gimple_omp_return_lhs (gs))
1541 pp_string (buffer, " (set ");
1542 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1543 spc, flags, false);
1544 pp_character (buffer, ')');
1549 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1551 static void
1552 dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags)
1554 unsigned subcode = gimple_transaction_subcode (gs);
1556 if (flags & TDF_RAW)
1558 dump_gimple_fmt (buffer, spc, flags,
1559 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1560 gs, subcode, gimple_transaction_label (gs),
1561 gimple_transaction_body (gs));
1563 else
1565 if (subcode & GTMA_IS_OUTER)
1566 pp_string (buffer, "__transaction_atomic [[outer]]");
1567 else if (subcode & GTMA_IS_RELAXED)
1568 pp_string (buffer, "__transaction_relaxed");
1569 else
1570 pp_string (buffer, "__transaction_atomic");
1571 subcode &= ~GTMA_DECLARATION_MASK;
1573 if (subcode || gimple_transaction_label (gs))
1575 pp_string (buffer, " //");
1576 if (gimple_transaction_label (gs))
1578 pp_string (buffer, " LABEL=");
1579 dump_generic_node (buffer, gimple_transaction_label (gs),
1580 spc, flags, false);
1582 if (subcode)
1584 pp_string (buffer, " SUBCODE=[ ");
1585 if (subcode & GTMA_HAVE_ABORT)
1587 pp_string (buffer, "GTMA_HAVE_ABORT ");
1588 subcode &= ~GTMA_HAVE_ABORT;
1590 if (subcode & GTMA_HAVE_LOAD)
1592 pp_string (buffer, "GTMA_HAVE_LOAD ");
1593 subcode &= ~GTMA_HAVE_LOAD;
1595 if (subcode & GTMA_HAVE_STORE)
1597 pp_string (buffer, "GTMA_HAVE_STORE ");
1598 subcode &= ~GTMA_HAVE_STORE;
1600 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1602 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1603 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1605 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1607 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1608 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1610 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1612 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1613 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1615 if (subcode)
1616 pp_printf (buffer, "0x%x ", subcode);
1617 pp_right_bracket (buffer);
1621 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1623 newline_and_indent (buffer, spc + 2);
1624 pp_left_brace (buffer);
1625 pp_newline (buffer);
1626 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1627 spc + 4, flags);
1628 newline_and_indent (buffer, spc + 2);
1629 pp_right_brace (buffer);
1634 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1635 indent. FLAGS specifies details to show in the dump (see TDF_* in
1636 dumpfile.h). */
1638 static void
1639 dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
1641 unsigned int i, n, f, fields;
1643 if (flags & TDF_RAW)
1645 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1646 gimple_asm_string (gs));
1648 n = gimple_asm_noutputs (gs);
1649 if (n)
1651 newline_and_indent (buffer, spc + 2);
1652 pp_string (buffer, "OUTPUT: ");
1653 for (i = 0; i < n; i++)
1655 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1656 spc, flags, false);
1657 if (i < n - 1)
1658 pp_string (buffer, ", ");
1662 n = gimple_asm_ninputs (gs);
1663 if (n)
1665 newline_and_indent (buffer, spc + 2);
1666 pp_string (buffer, "INPUT: ");
1667 for (i = 0; i < n; i++)
1669 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1670 spc, flags, false);
1671 if (i < n - 1)
1672 pp_string (buffer, ", ");
1676 n = gimple_asm_nclobbers (gs);
1677 if (n)
1679 newline_and_indent (buffer, spc + 2);
1680 pp_string (buffer, "CLOBBER: ");
1681 for (i = 0; i < n; i++)
1683 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1684 spc, flags, false);
1685 if (i < n - 1)
1686 pp_string (buffer, ", ");
1690 n = gimple_asm_nlabels (gs);
1691 if (n)
1693 newline_and_indent (buffer, spc + 2);
1694 pp_string (buffer, "LABEL: ");
1695 for (i = 0; i < n; i++)
1697 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1698 spc, flags, false);
1699 if (i < n - 1)
1700 pp_string (buffer, ", ");
1704 newline_and_indent (buffer, spc);
1705 pp_greater (buffer);
1707 else
1709 pp_string (buffer, "__asm__");
1710 if (gimple_asm_volatile_p (gs))
1711 pp_string (buffer, " __volatile__");
1712 if (gimple_asm_nlabels (gs))
1713 pp_string (buffer, " goto");
1714 pp_string (buffer, "(\"");
1715 pp_string (buffer, gimple_asm_string (gs));
1716 pp_string (buffer, "\"");
1718 if (gimple_asm_nlabels (gs))
1719 fields = 4;
1720 else if (gimple_asm_nclobbers (gs))
1721 fields = 3;
1722 else if (gimple_asm_ninputs (gs))
1723 fields = 2;
1724 else if (gimple_asm_noutputs (gs))
1725 fields = 1;
1726 else
1727 fields = 0;
1729 for (f = 0; f < fields; ++f)
1731 pp_string (buffer, " : ");
1733 switch (f)
1735 case 0:
1736 n = gimple_asm_noutputs (gs);
1737 for (i = 0; i < n; i++)
1739 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1740 spc, flags, false);
1741 if (i < n - 1)
1742 pp_string (buffer, ", ");
1744 break;
1746 case 1:
1747 n = gimple_asm_ninputs (gs);
1748 for (i = 0; i < n; i++)
1750 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1751 spc, flags, false);
1752 if (i < n - 1)
1753 pp_string (buffer, ", ");
1755 break;
1757 case 2:
1758 n = gimple_asm_nclobbers (gs);
1759 for (i = 0; i < n; i++)
1761 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1762 spc, flags, false);
1763 if (i < n - 1)
1764 pp_string (buffer, ", ");
1766 break;
1768 case 3:
1769 n = gimple_asm_nlabels (gs);
1770 for (i = 0; i < n; i++)
1772 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1773 spc, flags, false);
1774 if (i < n - 1)
1775 pp_string (buffer, ", ");
1777 break;
1779 default:
1780 gcc_unreachable ();
1784 pp_string (buffer, ");");
1788 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1789 SPC spaces of indent. */
1791 static void
1792 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1794 if (TREE_CODE (node) != SSA_NAME)
1795 return;
1797 if (POINTER_TYPE_P (TREE_TYPE (node))
1798 && SSA_NAME_PTR_INFO (node))
1800 unsigned int align, misalign;
1801 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1802 pp_string (buffer, "# PT = ");
1803 pp_points_to_solution (buffer, &pi->pt);
1804 newline_and_indent (buffer, spc);
1805 if (get_ptr_info_alignment (pi, &align, &misalign))
1807 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1808 newline_and_indent (buffer, spc);
1812 if (!POINTER_TYPE_P (TREE_TYPE (node))
1813 && SSA_NAME_RANGE_INFO (node))
1815 wide_int min, max, nonzero_bits;
1816 value_range_type range_type = get_range_info (node, &min, &max);
1818 if (range_type == VR_VARYING)
1819 pp_printf (buffer, "# RANGE VR_VARYING");
1820 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1822 pp_printf (buffer, "# RANGE ");
1823 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1824 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
1825 pp_printf (buffer, ", ");
1826 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
1827 pp_printf (buffer, "]");
1829 nonzero_bits = get_nonzero_bits (node);
1830 if (nonzero_bits != -1)
1832 pp_string (buffer, " NONZERO ");
1833 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
1835 newline_and_indent (buffer, spc);
1840 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1841 The caller is responsible for calling pp_flush on BUFFER to finalize
1842 pretty printer. If COMMENT is true, print this after #. */
1844 static void
1845 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, bool comment,
1846 int flags)
1848 size_t i;
1849 tree lhs = gimple_phi_result (phi);
1851 if (flags & TDF_ALIAS)
1852 dump_ssaname_info (buffer, lhs, spc);
1854 if (comment)
1855 pp_string (buffer, "# ");
1857 if (flags & TDF_RAW)
1858 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1859 gimple_phi_result (phi));
1860 else
1862 dump_generic_node (buffer, lhs, spc, flags, false);
1863 pp_string (buffer, " = PHI <");
1865 for (i = 0; i < gimple_phi_num_args (phi); i++)
1867 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1868 dump_location (buffer, gimple_phi_arg_location (phi, i));
1869 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1870 false);
1871 pp_left_paren (buffer);
1872 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1873 pp_right_paren (buffer);
1874 if (i < gimple_phi_num_args (phi) - 1)
1875 pp_string (buffer, ", ");
1877 pp_greater (buffer);
1881 /* Dump an OpenACC offload tuple on the pretty_printer BUFFER, SPC spaces
1882 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1883 dumpfile.h). */
1885 static void
1886 dump_gimple_oacc_offload (pretty_printer *buffer, gimple gs, int spc,
1887 int flags)
1889 tree (*gimple_omp_clauses) (const_gimple);
1890 tree (*gimple_omp_child_fn) (const_gimple);
1891 tree (*gimple_omp_data_arg) (const_gimple);
1892 const char *kind;
1893 switch (gimple_code (gs))
1895 case GIMPLE_OACC_KERNELS:
1896 gimple_omp_clauses = gimple_oacc_kernels_clauses;
1897 gimple_omp_child_fn = gimple_oacc_kernels_child_fn;
1898 gimple_omp_data_arg = gimple_oacc_kernels_data_arg;
1899 kind = "kernels";
1900 break;
1901 case GIMPLE_OACC_PARALLEL:
1902 gimple_omp_clauses = gimple_oacc_parallel_clauses;
1903 gimple_omp_child_fn = gimple_oacc_parallel_child_fn;
1904 gimple_omp_data_arg = gimple_oacc_parallel_data_arg;
1905 kind = "parallel";
1906 break;
1907 default:
1908 gcc_unreachable ();
1910 if (flags & TDF_RAW)
1912 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1913 gimple_omp_body (gs));
1914 dump_omp_clauses (buffer, gimple_omp_clauses (gs), spc, flags);
1915 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1916 gimple_omp_child_fn (gs), gimple_omp_data_arg (gs));
1918 else
1920 gimple_seq body;
1921 pp_string (buffer, "#pragma acc ");
1922 pp_string (buffer, kind);
1923 dump_omp_clauses (buffer, gimple_omp_clauses (gs), spc, flags);
1924 if (gimple_omp_child_fn (gs))
1926 pp_string (buffer, " [child fn: ");
1927 dump_generic_node (buffer, gimple_omp_child_fn (gs),
1928 spc, flags, false);
1929 pp_string (buffer, " (");
1930 if (gimple_omp_data_arg (gs))
1931 dump_generic_node (buffer, gimple_omp_data_arg (gs),
1932 spc, flags, false);
1933 else
1934 pp_string (buffer, "???");
1935 pp_string (buffer, ")]");
1937 body = gimple_omp_body (gs);
1938 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1940 newline_and_indent (buffer, spc + 2);
1941 pp_left_brace (buffer);
1942 pp_newline (buffer);
1943 dump_gimple_seq (buffer, body, spc + 4, flags);
1944 newline_and_indent (buffer, spc + 2);
1945 pp_right_brace (buffer);
1947 else if (body)
1949 pp_newline (buffer);
1950 dump_gimple_seq (buffer, body, spc + 2, flags);
1956 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1957 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1958 dumpfile.h). */
1960 static void
1961 dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1962 int flags)
1964 if (flags & TDF_RAW)
1966 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1967 gimple_omp_body (gs));
1968 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1969 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1970 gimple_omp_parallel_child_fn (gs),
1971 gimple_omp_parallel_data_arg (gs));
1973 else
1975 gimple_seq body;
1976 pp_string (buffer, "#pragma omp parallel");
1977 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1978 if (gimple_omp_parallel_child_fn (gs))
1980 pp_string (buffer, " [child fn: ");
1981 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1982 spc, flags, false);
1983 pp_string (buffer, " (");
1984 if (gimple_omp_parallel_data_arg (gs))
1985 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1986 spc, flags, false);
1987 else
1988 pp_string (buffer, "???");
1989 pp_string (buffer, ")]");
1991 body = gimple_omp_body (gs);
1992 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1994 newline_and_indent (buffer, spc + 2);
1995 pp_left_brace (buffer);
1996 pp_newline (buffer);
1997 dump_gimple_seq (buffer, body, spc + 4, flags);
1998 newline_and_indent (buffer, spc + 2);
1999 pp_right_brace (buffer);
2001 else if (body)
2003 pp_newline (buffer);
2004 dump_gimple_seq (buffer, body, spc + 2, flags);
2010 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2011 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2012 dumpfile.h). */
2014 static void
2015 dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
2016 int flags)
2018 if (flags & TDF_RAW)
2020 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2021 gimple_omp_body (gs));
2022 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2023 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2024 gimple_omp_task_child_fn (gs),
2025 gimple_omp_task_data_arg (gs),
2026 gimple_omp_task_copy_fn (gs),
2027 gimple_omp_task_arg_size (gs),
2028 gimple_omp_task_arg_size (gs));
2030 else
2032 gimple_seq body;
2033 pp_string (buffer, "#pragma omp task");
2034 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2035 if (gimple_omp_task_child_fn (gs))
2037 pp_string (buffer, " [child fn: ");
2038 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2039 spc, flags, false);
2040 pp_string (buffer, " (");
2041 if (gimple_omp_task_data_arg (gs))
2042 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2043 spc, flags, false);
2044 else
2045 pp_string (buffer, "???");
2046 pp_string (buffer, ")]");
2048 body = gimple_omp_body (gs);
2049 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2051 newline_and_indent (buffer, spc + 2);
2052 pp_left_brace (buffer);
2053 pp_newline (buffer);
2054 dump_gimple_seq (buffer, body, spc + 4, flags);
2055 newline_and_indent (buffer, spc + 2);
2056 pp_right_brace (buffer);
2058 else if (body)
2060 pp_newline (buffer);
2061 dump_gimple_seq (buffer, body, spc + 2, flags);
2067 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2068 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2069 in dumpfile.h). */
2071 static void
2072 dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
2073 int flags)
2075 if (flags & TDF_RAW)
2077 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2078 gimple_omp_atomic_load_lhs (gs),
2079 gimple_omp_atomic_load_rhs (gs));
2081 else
2083 pp_string (buffer, "#pragma omp atomic_load");
2084 if (gimple_omp_atomic_seq_cst_p (gs))
2085 pp_string (buffer, " seq_cst");
2086 if (gimple_omp_atomic_need_value_p (gs))
2087 pp_string (buffer, " [needed]");
2088 newline_and_indent (buffer, spc + 2);
2089 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2090 spc, flags, false);
2091 pp_space (buffer);
2092 pp_equal (buffer);
2093 pp_space (buffer);
2094 pp_star (buffer);
2095 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2096 spc, flags, false);
2100 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2101 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2102 in dumpfile.h). */
2104 static void
2105 dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
2106 int flags)
2108 if (flags & TDF_RAW)
2110 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2111 gimple_omp_atomic_store_val (gs));
2113 else
2115 pp_string (buffer, "#pragma omp atomic_store ");
2116 if (gimple_omp_atomic_seq_cst_p (gs))
2117 pp_string (buffer, "seq_cst ");
2118 if (gimple_omp_atomic_need_value_p (gs))
2119 pp_string (buffer, "[needed] ");
2120 pp_left_paren (buffer);
2121 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2122 spc, flags, false);
2123 pp_right_paren (buffer);
2128 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2129 FLAGS are as in pp_gimple_stmt_1. */
2131 static void
2132 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
2134 tree vdef = gimple_vdef (gs);
2135 tree vuse = gimple_vuse (gs);
2137 if (vdef != NULL_TREE)
2139 pp_string (buffer, "# ");
2140 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2141 pp_string (buffer, " = VDEF <");
2142 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2143 pp_greater (buffer);
2144 newline_and_indent (buffer, spc);
2146 else if (vuse != NULL_TREE)
2148 pp_string (buffer, "# VUSE <");
2149 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2150 pp_greater (buffer);
2151 newline_and_indent (buffer, spc);
2156 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2157 spaces of indent. FLAGS specifies details to show in the dump (see
2158 TDF_* in dumpfile.h). The caller is responsible for calling
2159 pp_flush on BUFFER to finalize the pretty printer. */
2161 void
2162 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
2164 if (!gs)
2165 return;
2167 if (flags & TDF_STMTADDR)
2168 pp_printf (buffer, "<&%p> ", (void *) gs);
2170 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2171 dump_location (buffer, gimple_location (gs));
2173 if (flags & TDF_EH)
2175 int lp_nr = lookup_stmt_eh_lp (gs);
2176 if (lp_nr > 0)
2177 pp_printf (buffer, "[LP %d] ", lp_nr);
2178 else if (lp_nr < 0)
2179 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2182 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2183 && gimple_has_mem_ops (gs))
2184 dump_gimple_mem_ops (buffer, gs, spc, flags);
2186 if (gimple_has_lhs (gs)
2187 && (flags & TDF_ALIAS))
2188 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2190 switch (gimple_code (gs))
2192 case GIMPLE_ASM:
2193 dump_gimple_asm (buffer, gs, spc, flags);
2194 break;
2196 case GIMPLE_ASSIGN:
2197 dump_gimple_assign (buffer, gs, spc, flags);
2198 break;
2200 case GIMPLE_BIND:
2201 dump_gimple_bind (buffer, gs, spc, flags);
2202 break;
2204 case GIMPLE_CALL:
2205 dump_gimple_call (buffer, gs, spc, flags);
2206 break;
2208 case GIMPLE_COND:
2209 dump_gimple_cond (buffer, gs, spc, flags);
2210 break;
2212 case GIMPLE_LABEL:
2213 dump_gimple_label (buffer, gs, spc, flags);
2214 break;
2216 case GIMPLE_GOTO:
2217 dump_gimple_goto (buffer, gs, spc, flags);
2218 break;
2220 case GIMPLE_NOP:
2221 pp_string (buffer, "GIMPLE_NOP");
2222 break;
2224 case GIMPLE_RETURN:
2225 dump_gimple_return (buffer, gs, spc, flags);
2226 break;
2228 case GIMPLE_SWITCH:
2229 dump_gimple_switch (buffer, gs, spc, flags);
2230 break;
2232 case GIMPLE_TRY:
2233 dump_gimple_try (buffer, gs, spc, flags);
2234 break;
2236 case GIMPLE_PHI:
2237 dump_gimple_phi (buffer, gs, spc, false, flags);
2238 break;
2240 case GIMPLE_OACC_KERNELS:
2241 case GIMPLE_OACC_PARALLEL:
2242 dump_gimple_oacc_offload (buffer, gs, spc, flags);
2243 break;
2245 case GIMPLE_OMP_PARALLEL:
2246 dump_gimple_omp_parallel (buffer, gs, spc, flags);
2247 break;
2249 case GIMPLE_OMP_TASK:
2250 dump_gimple_omp_task (buffer, gs, spc, flags);
2251 break;
2253 case GIMPLE_OMP_ATOMIC_LOAD:
2254 dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
2256 break;
2258 case GIMPLE_OMP_ATOMIC_STORE:
2259 dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
2260 break;
2262 case GIMPLE_OMP_FOR:
2263 dump_gimple_omp_for (buffer, gs, spc, flags);
2264 break;
2266 case GIMPLE_OMP_CONTINUE:
2267 dump_gimple_omp_continue (buffer, gs, spc, flags);
2268 break;
2270 case GIMPLE_OMP_SINGLE:
2271 dump_gimple_omp_single (buffer, gs, spc, flags);
2272 break;
2274 case GIMPLE_OMP_TARGET:
2275 dump_gimple_omp_target (buffer, gs, spc, flags);
2276 break;
2278 case GIMPLE_OMP_TEAMS:
2279 dump_gimple_omp_teams (buffer, gs, spc, flags);
2280 break;
2282 case GIMPLE_OMP_RETURN:
2283 dump_gimple_omp_return (buffer, gs, spc, flags);
2284 break;
2286 case GIMPLE_OMP_SECTIONS:
2287 dump_gimple_omp_sections (buffer, gs, spc, flags);
2288 break;
2290 case GIMPLE_OMP_SECTIONS_SWITCH:
2291 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2292 break;
2294 case GIMPLE_OMP_MASTER:
2295 case GIMPLE_OMP_TASKGROUP:
2296 case GIMPLE_OMP_ORDERED:
2297 case GIMPLE_OMP_SECTION:
2298 dump_gimple_omp_block (buffer, gs, spc, flags);
2299 break;
2301 case GIMPLE_OMP_CRITICAL:
2302 dump_gimple_omp_critical (buffer, gs, spc, flags);
2303 break;
2305 case GIMPLE_CATCH:
2306 dump_gimple_catch (buffer, gs, spc, flags);
2307 break;
2309 case GIMPLE_EH_FILTER:
2310 dump_gimple_eh_filter (buffer, gs, spc, flags);
2311 break;
2313 case GIMPLE_EH_MUST_NOT_THROW:
2314 dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
2315 break;
2317 case GIMPLE_EH_ELSE:
2318 dump_gimple_eh_else (buffer, gs, spc, flags);
2319 break;
2321 case GIMPLE_RESX:
2322 dump_gimple_resx (buffer, gs, spc, flags);
2323 break;
2325 case GIMPLE_EH_DISPATCH:
2326 dump_gimple_eh_dispatch (buffer, gs, spc, flags);
2327 break;
2329 case GIMPLE_DEBUG:
2330 dump_gimple_debug (buffer, gs, spc, flags);
2331 break;
2333 case GIMPLE_PREDICT:
2334 pp_string (buffer, "// predicted ");
2335 if (gimple_predict_outcome (gs))
2336 pp_string (buffer, "likely by ");
2337 else
2338 pp_string (buffer, "unlikely by ");
2339 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2340 pp_string (buffer, " predictor.");
2341 break;
2343 case GIMPLE_TRANSACTION:
2344 dump_gimple_transaction (buffer, gs, spc, flags);
2345 break;
2347 default:
2348 GIMPLE_NIY;
2353 /* Dumps header of basic block BB to OUTF indented by INDENT
2354 spaces and details described by flags. */
2356 static void
2357 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2359 if (flags & TDF_BLOCKS)
2361 if (flags & TDF_LINENO)
2363 gimple_stmt_iterator gsi;
2365 if (flags & TDF_COMMENT)
2366 fputs (";; ", outf);
2368 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2369 if (!is_gimple_debug (gsi_stmt (gsi))
2370 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2372 fprintf (outf, "%*sstarting at line %d",
2373 indent, "", get_lineno (gsi_stmt (gsi)));
2374 break;
2376 if (bb->discriminator)
2377 fprintf (outf, ", discriminator %i", bb->discriminator);
2378 fputc ('\n', outf);
2381 else
2383 gimple stmt = first_stmt (bb);
2384 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2385 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2390 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2391 spaces. */
2393 static void
2394 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2395 basic_block bb ATTRIBUTE_UNUSED,
2396 int indent ATTRIBUTE_UNUSED,
2397 int flags ATTRIBUTE_UNUSED)
2399 /* There is currently no GIMPLE-specific basic block info to dump. */
2400 return;
2404 /* Dump PHI nodes of basic block BB to BUFFER with details described
2405 by FLAGS and indented by INDENT spaces. */
2407 static void
2408 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2410 gimple_stmt_iterator i;
2412 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2414 gimple phi = gsi_stmt (i);
2415 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2417 INDENT (indent);
2418 dump_gimple_phi (buffer, phi, indent, true, flags);
2419 pp_newline (buffer);
2425 /* Dump jump to basic block BB that is represented implicitly in the cfg
2426 to BUFFER. */
2428 static void
2429 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2431 gimple stmt;
2433 stmt = first_stmt (bb);
2435 pp_string (buffer, "goto <bb ");
2436 pp_decimal_int (buffer, bb->index);
2437 pp_greater (buffer);
2438 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2440 pp_string (buffer, " (");
2441 dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
2442 pp_right_paren (buffer);
2443 pp_semicolon (buffer);
2445 else
2446 pp_semicolon (buffer);
2450 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2451 by INDENT spaces, with details given by FLAGS. */
2453 static void
2454 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2455 int flags)
2457 edge e;
2458 gimple stmt;
2460 stmt = last_stmt (bb);
2462 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2464 edge true_edge, false_edge;
2466 /* When we are emitting the code or changing CFG, it is possible that
2467 the edges are not yet created. When we are using debug_bb in such
2468 a situation, we do not want it to crash. */
2469 if (EDGE_COUNT (bb->succs) != 2)
2470 return;
2471 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2473 INDENT (indent + 2);
2474 pp_cfg_jump (buffer, true_edge->dest);
2475 newline_and_indent (buffer, indent);
2476 pp_string (buffer, "else");
2477 newline_and_indent (buffer, indent + 2);
2478 pp_cfg_jump (buffer, false_edge->dest);
2479 pp_newline (buffer);
2480 return;
2483 /* If there is a fallthru edge, we may need to add an artificial
2484 goto to the dump. */
2485 e = find_fallthru_edge (bb->succs);
2487 if (e && e->dest != bb->next_bb)
2489 INDENT (indent);
2491 if ((flags & TDF_LINENO)
2492 && e->goto_locus != UNKNOWN_LOCATION)
2493 dump_location (buffer, e->goto_locus);
2495 pp_cfg_jump (buffer, e->dest);
2496 pp_newline (buffer);
2501 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2502 indented by INDENT spaces. */
2504 static void
2505 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2506 int flags)
2508 gimple_stmt_iterator gsi;
2509 gimple stmt;
2510 int label_indent = indent - 2;
2512 if (label_indent < 0)
2513 label_indent = 0;
2515 dump_phi_nodes (buffer, bb, indent, flags);
2517 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2519 int curr_indent;
2521 stmt = gsi_stmt (gsi);
2523 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2525 INDENT (curr_indent);
2526 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2527 pp_newline_and_flush (buffer);
2528 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2529 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2530 pp_buffer (buffer)->stream, stmt);
2533 dump_implicit_edges (buffer, bb, indent, flags);
2534 pp_flush (buffer);
2538 /* Dumps basic block BB to FILE with details described by FLAGS and
2539 indented by INDENT spaces. */
2541 void
2542 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2544 dump_gimple_bb_header (file, bb, indent, flags);
2545 if (bb->index >= NUM_FIXED_BLOCKS)
2547 pretty_printer buffer;
2548 pp_needs_newline (&buffer) = true;
2549 buffer.buffer->stream = file;
2550 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2552 dump_gimple_bb_footer (file, bb, indent, flags);
2555 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2556 no indentation, for use as a label of a DOT graph record-node.
2557 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2558 histogram dumping doesn't know about pretty-printers. */
2560 void
2561 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2563 gimple_stmt_iterator gsi;
2565 pp_printf (pp, "<bb %d>:\n", bb->index);
2566 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2568 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2570 gimple phi = gsi_stmt (gsi);
2571 if (!virtual_operand_p (gimple_phi_result (phi))
2572 || (dump_flags & TDF_VOPS))
2574 pp_bar (pp);
2575 pp_write_text_to_stream (pp);
2576 pp_string (pp, "# ");
2577 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2578 pp_newline (pp);
2579 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2583 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2585 gimple stmt = gsi_stmt (gsi);
2586 pp_bar (pp);
2587 pp_write_text_to_stream (pp);
2588 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2589 pp_newline (pp);
2590 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2592 dump_implicit_edges (pp, bb, 0, dump_flags);
2593 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);