PR middle-end/83164
[official-gcc.git] / gcc / gimple-pretty-print.c
blobe952f3378121f5e137aba94ef9a93fc8bd71434b
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2017 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 "dumpfile.h"
26 #include "backend.h"
27 #include "tree.h"
28 #include "gimple.h"
29 #include "gimple-predict.h"
30 #include "ssa.h"
31 #include "cgraph.h"
32 #include "gimple-pretty-print.h"
33 #include "internal-fn.h"
34 #include "tree-eh.h"
35 #include "gimple-iterator.h"
36 #include "tree-cfg.h"
37 #include "dumpfile.h" /* for dump_flags */
38 #include "value-prof.h"
39 #include "trans-mem.h"
40 #include "cfganal.h"
41 #include "stringpool.h"
42 #include "attribs.h"
43 #include "asan.h"
45 #define INDENT(SPACE) \
46 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
48 #define GIMPLE_NIY do_niy (buffer,gs)
50 /* Try to print on BUFFER a default message for the unrecognized
51 gimple statement GS. */
53 static void
54 do_niy (pretty_printer *buffer, gimple *gs)
56 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
57 gimple_code_name[(int) gimple_code (gs)]);
61 /* Emit a newline and SPC indentation spaces to BUFFER. */
63 static void
64 newline_and_indent (pretty_printer *buffer, int spc)
66 pp_newline (buffer);
67 INDENT (spc);
71 /* Print the GIMPLE statement GS on stderr. */
73 DEBUG_FUNCTION void
74 debug_gimple_stmt (gimple *gs)
76 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
80 /* Return formatted string of a VALUE probability
81 (biased by REG_BR_PROB_BASE). Returned string is allocated
82 by xstrdup_for_dump. */
84 static const char *
85 dump_profile (profile_count &count)
87 char *buf = NULL;
88 if (!count.initialized_p ())
89 return "";
90 if (count.ipa_p ())
91 buf = xasprintf ("[count: %" PRId64 "]",
92 count.to_gcov_type ());
93 else if (count.initialized_p ())
94 buf = xasprintf ("[local count: %" PRId64 "]",
95 count.to_gcov_type ());
97 const char *ret = xstrdup_for_dump (buf);
98 free (buf);
100 return ret;
103 /* Return formatted string of a VALUE probability
104 (biased by REG_BR_PROB_BASE). Returned string is allocated
105 by xstrdup_for_dump. */
107 static const char *
108 dump_probability (profile_probability probability)
110 float minimum = 0.01f;
111 float fvalue = -1;
113 if (probability.initialized_p ())
115 fvalue = probability.to_reg_br_prob_base () * 100.0f / REG_BR_PROB_BASE;
116 if (fvalue < minimum && probability.to_reg_br_prob_base ())
117 fvalue = minimum;
120 char *buf;
121 if (probability.initialized_p ())
122 buf = xasprintf ("[%.2f%%]", fvalue);
123 else
124 buf = xasprintf ("[INV]");
126 const char *ret = xstrdup_for_dump (buf);
127 free (buf);
129 return ret;
132 /* Dump E probability to BUFFER. */
134 static void
135 dump_edge_probability (pretty_printer *buffer, edge e)
137 pp_scalar (buffer, " %s", dump_probability (e->probability));
140 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
141 FLAGS as in pp_gimple_stmt_1. */
143 void
144 print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
146 pretty_printer buffer;
147 pp_needs_newline (&buffer) = true;
148 buffer.buffer->stream = file;
149 pp_gimple_stmt_1 (&buffer, g, spc, flags);
150 pp_newline_and_flush (&buffer);
153 DEBUG_FUNCTION void
154 debug (gimple &ref)
156 print_gimple_stmt (stderr, &ref, 0, 0);
159 DEBUG_FUNCTION void
160 debug (gimple *ptr)
162 if (ptr)
163 debug (*ptr);
164 else
165 fprintf (stderr, "<nil>\n");
169 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
170 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
171 of the statement. */
173 void
174 print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
176 flags |= TDF_RHS_ONLY;
177 pretty_printer buffer;
178 pp_needs_newline (&buffer) = true;
179 buffer.buffer->stream = file;
180 pp_gimple_stmt_1 (&buffer, g, spc, flags);
181 pp_flush (&buffer);
185 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
186 spaces and FLAGS as in pp_gimple_stmt_1.
187 The caller is responsible for calling pp_flush on BUFFER to finalize
188 the pretty printer. */
190 static void
191 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc,
192 dump_flags_t flags)
194 gimple_stmt_iterator i;
196 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
198 gimple *gs = gsi_stmt (i);
199 INDENT (spc);
200 pp_gimple_stmt_1 (buffer, gs, spc, flags);
201 if (!gsi_one_before_end_p (i))
202 pp_newline (buffer);
207 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
208 FLAGS as in pp_gimple_stmt_1. */
210 void
211 print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
213 pretty_printer buffer;
214 pp_needs_newline (&buffer) = true;
215 buffer.buffer->stream = file;
216 dump_gimple_seq (&buffer, seq, spc, flags);
217 pp_newline_and_flush (&buffer);
221 /* Print the GIMPLE sequence SEQ on stderr. */
223 DEBUG_FUNCTION void
224 debug_gimple_seq (gimple_seq seq)
226 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
230 /* A simple helper to pretty-print some of the gimple tuples in the printf
231 style. The format modifiers are preceded by '%' and are:
232 'G' - outputs a string corresponding to the code of the given gimple,
233 'S' - outputs a gimple_seq with indent of spc + 2,
234 'T' - outputs the tree t,
235 'd' - outputs an int as a decimal,
236 's' - outputs a string,
237 'n' - outputs a newline,
238 'x' - outputs an int as hexadecimal,
239 '+' - increases indent by 2 then outputs a newline,
240 '-' - decreases indent by 2 then outputs a newline. */
242 static void
243 dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags,
244 const char *fmt, ...)
246 va_list args;
247 const char *c;
248 const char *tmp;
250 va_start (args, fmt);
251 for (c = fmt; *c; c++)
253 if (*c == '%')
255 gimple_seq seq;
256 tree t;
257 gimple *g;
258 switch (*++c)
260 case 'G':
261 g = va_arg (args, gimple *);
262 tmp = gimple_code_name[gimple_code (g)];
263 pp_string (buffer, tmp);
264 break;
266 case 'S':
267 seq = va_arg (args, gimple_seq);
268 pp_newline (buffer);
269 dump_gimple_seq (buffer, seq, spc + 2, flags);
270 newline_and_indent (buffer, spc);
271 break;
273 case 'T':
274 t = va_arg (args, tree);
275 if (t == NULL_TREE)
276 pp_string (buffer, "NULL");
277 else
278 dump_generic_node (buffer, t, spc, flags, false);
279 break;
281 case 'd':
282 pp_decimal_int (buffer, va_arg (args, int));
283 break;
285 case 's':
286 pp_string (buffer, va_arg (args, char *));
287 break;
289 case 'n':
290 newline_and_indent (buffer, spc);
291 break;
293 case 'x':
294 pp_scalar (buffer, "%x", va_arg (args, int));
295 break;
297 case '+':
298 spc += 2;
299 newline_and_indent (buffer, spc);
300 break;
302 case '-':
303 spc -= 2;
304 newline_and_indent (buffer, spc);
305 break;
307 default:
308 gcc_unreachable ();
311 else
312 pp_character (buffer, *c);
314 va_end (args);
318 /* Helper for dump_gimple_assign. Print the unary RHS of the
319 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
321 static void
322 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc,
323 dump_flags_t flags)
325 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
326 tree lhs = gimple_assign_lhs (gs);
327 tree rhs = gimple_assign_rhs1 (gs);
329 switch (rhs_code)
331 case VIEW_CONVERT_EXPR:
332 case ASSERT_EXPR:
333 dump_generic_node (buffer, rhs, spc, flags, false);
334 break;
336 case FIXED_CONVERT_EXPR:
337 case ADDR_SPACE_CONVERT_EXPR:
338 case FIX_TRUNC_EXPR:
339 case FLOAT_EXPR:
340 CASE_CONVERT:
341 pp_left_paren (buffer);
342 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
343 pp_string (buffer, ") ");
344 if (op_prio (rhs) < op_code_prio (rhs_code))
346 pp_left_paren (buffer);
347 dump_generic_node (buffer, rhs, spc, flags, false);
348 pp_right_paren (buffer);
350 else
351 dump_generic_node (buffer, rhs, spc, flags, false);
352 break;
354 case PAREN_EXPR:
355 pp_string (buffer, "((");
356 dump_generic_node (buffer, rhs, spc, flags, false);
357 pp_string (buffer, "))");
358 break;
360 case ABS_EXPR:
361 if (flags & TDF_GIMPLE)
363 pp_string (buffer, "__ABS ");
364 dump_generic_node (buffer, rhs, spc, flags, false);
366 else
368 pp_string (buffer, "ABS_EXPR <");
369 dump_generic_node (buffer, rhs, spc, flags, false);
370 pp_greater (buffer);
372 break;
374 default:
375 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
376 || TREE_CODE_CLASS (rhs_code) == tcc_constant
377 || TREE_CODE_CLASS (rhs_code) == tcc_reference
378 || rhs_code == SSA_NAME
379 || rhs_code == ADDR_EXPR
380 || rhs_code == CONSTRUCTOR)
382 dump_generic_node (buffer, rhs, spc, flags, false);
383 break;
385 else if (rhs_code == BIT_NOT_EXPR)
386 pp_complement (buffer);
387 else if (rhs_code == TRUTH_NOT_EXPR)
388 pp_exclamation (buffer);
389 else if (rhs_code == NEGATE_EXPR)
390 pp_minus (buffer);
391 else
393 pp_left_bracket (buffer);
394 pp_string (buffer, get_tree_code_name (rhs_code));
395 pp_string (buffer, "] ");
398 if (op_prio (rhs) < op_code_prio (rhs_code))
400 pp_left_paren (buffer);
401 dump_generic_node (buffer, rhs, spc, flags, false);
402 pp_right_paren (buffer);
404 else
405 dump_generic_node (buffer, rhs, spc, flags, false);
406 break;
411 /* Helper for dump_gimple_assign. Print the binary RHS of the
412 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
414 static void
415 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc,
416 dump_flags_t flags)
418 const char *p;
419 enum tree_code code = gimple_assign_rhs_code (gs);
420 switch (code)
422 case COMPLEX_EXPR:
423 case MIN_EXPR:
424 case MAX_EXPR:
425 case VEC_WIDEN_MULT_HI_EXPR:
426 case VEC_WIDEN_MULT_LO_EXPR:
427 case VEC_WIDEN_MULT_EVEN_EXPR:
428 case VEC_WIDEN_MULT_ODD_EXPR:
429 case VEC_PACK_TRUNC_EXPR:
430 case VEC_PACK_SAT_EXPR:
431 case VEC_PACK_FIX_TRUNC_EXPR:
432 case VEC_WIDEN_LSHIFT_HI_EXPR:
433 case VEC_WIDEN_LSHIFT_LO_EXPR:
434 for (p = get_tree_code_name (code); *p; p++)
435 pp_character (buffer, TOUPPER (*p));
436 pp_string (buffer, " <");
437 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
438 pp_string (buffer, ", ");
439 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
440 pp_greater (buffer);
441 break;
443 default:
444 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
446 pp_left_paren (buffer);
447 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
448 false);
449 pp_right_paren (buffer);
451 else
452 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
453 pp_space (buffer);
454 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
455 pp_space (buffer);
456 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
458 pp_left_paren (buffer);
459 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
460 false);
461 pp_right_paren (buffer);
463 else
464 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
468 /* Helper for dump_gimple_assign. Print the ternary RHS of the
469 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
471 static void
472 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc,
473 dump_flags_t flags)
475 const char *p;
476 enum tree_code code = gimple_assign_rhs_code (gs);
477 switch (code)
479 case WIDEN_MULT_PLUS_EXPR:
480 case WIDEN_MULT_MINUS_EXPR:
481 for (p = get_tree_code_name (code); *p; p++)
482 pp_character (buffer, TOUPPER (*p));
483 pp_string (buffer, " <");
484 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
485 pp_string (buffer, ", ");
486 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
487 pp_string (buffer, ", ");
488 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
489 pp_greater (buffer);
490 break;
492 case FMA_EXPR:
493 if (flags & TDF_GIMPLE)
495 pp_string (buffer, "__FMA (");
496 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
497 pp_comma (buffer);
498 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
499 pp_comma (buffer);
500 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
501 pp_right_paren (buffer);
503 else
505 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
506 pp_string (buffer, " * ");
507 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
508 pp_string (buffer, " + ");
509 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
511 break;
513 case DOT_PROD_EXPR:
514 pp_string (buffer, "DOT_PROD_EXPR <");
515 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
516 pp_string (buffer, ", ");
517 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
518 pp_string (buffer, ", ");
519 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
520 pp_greater (buffer);
521 break;
523 case SAD_EXPR:
524 pp_string (buffer, "SAD_EXPR <");
525 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
526 pp_string (buffer, ", ");
527 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
528 pp_string (buffer, ", ");
529 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
530 pp_greater (buffer);
531 break;
533 case VEC_PERM_EXPR:
534 pp_string (buffer, "VEC_PERM_EXPR <");
535 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
536 pp_string (buffer, ", ");
537 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
538 pp_string (buffer, ", ");
539 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
540 pp_greater (buffer);
541 break;
543 case REALIGN_LOAD_EXPR:
544 pp_string (buffer, "REALIGN_LOAD <");
545 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
546 pp_string (buffer, ", ");
547 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
548 pp_string (buffer, ", ");
549 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
550 pp_greater (buffer);
551 break;
553 case COND_EXPR:
554 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
555 pp_string (buffer, " ? ");
556 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
557 pp_string (buffer, " : ");
558 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
559 break;
561 case VEC_COND_EXPR:
562 pp_string (buffer, "VEC_COND_EXPR <");
563 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
564 pp_string (buffer, ", ");
565 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
566 pp_string (buffer, ", ");
567 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
568 pp_greater (buffer);
569 break;
571 case BIT_INSERT_EXPR:
572 pp_string (buffer, "BIT_INSERT_EXPR <");
573 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
574 pp_string (buffer, ", ");
575 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
576 pp_string (buffer, ", ");
577 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
578 pp_string (buffer, " (");
579 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
580 pp_decimal_int (buffer,
581 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
582 else
583 dump_generic_node (buffer,
584 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
585 spc, flags, false);
586 pp_string (buffer, " bits)>");
587 break;
589 default:
590 gcc_unreachable ();
595 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
596 pp_gimple_stmt_1. */
598 static void
599 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc,
600 dump_flags_t flags)
602 if (flags & TDF_RAW)
604 tree arg1 = NULL;
605 tree arg2 = NULL;
606 tree arg3 = NULL;
607 switch (gimple_num_ops (gs))
609 case 4:
610 arg3 = gimple_assign_rhs3 (gs);
611 /* FALLTHRU */
612 case 3:
613 arg2 = gimple_assign_rhs2 (gs);
614 /* FALLTHRU */
615 case 2:
616 arg1 = gimple_assign_rhs1 (gs);
617 break;
618 default:
619 gcc_unreachable ();
622 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
623 get_tree_code_name (gimple_assign_rhs_code (gs)),
624 gimple_assign_lhs (gs), arg1, arg2, arg3);
626 else
628 if (!(flags & TDF_RHS_ONLY))
630 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
631 pp_space (buffer);
632 pp_equal (buffer);
634 if (gimple_assign_nontemporal_move_p (gs))
635 pp_string (buffer, "{nt}");
637 if (gimple_has_volatile_ops (gs))
638 pp_string (buffer, "{v}");
640 pp_space (buffer);
643 if (gimple_num_ops (gs) == 2)
644 dump_unary_rhs (buffer, gs, spc, flags);
645 else if (gimple_num_ops (gs) == 3)
646 dump_binary_rhs (buffer, gs, spc, flags);
647 else if (gimple_num_ops (gs) == 4)
648 dump_ternary_rhs (buffer, gs, spc, flags);
649 else
650 gcc_unreachable ();
651 if (!(flags & TDF_RHS_ONLY))
652 pp_semicolon (buffer);
657 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
658 pp_gimple_stmt_1. */
660 static void
661 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc,
662 dump_flags_t flags)
664 tree t, t2;
666 t = gimple_return_retval (gs);
667 t2 = gimple_return_retbnd (gs);
668 if (flags & TDF_RAW)
669 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
670 else
672 pp_string (buffer, "return");
673 if (t)
675 pp_space (buffer);
676 dump_generic_node (buffer, t, spc, flags, false);
678 if (t2)
680 pp_string (buffer, ", ");
681 dump_generic_node (buffer, t2, spc, flags, false);
683 pp_semicolon (buffer);
688 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
689 dump_gimple_call. */
691 static void
692 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, dump_flags_t flags)
694 size_t i = 0;
696 /* Pretty print first arg to certain internal fns. */
697 if (gimple_call_internal_p (gs))
699 const char *const *enums = NULL;
700 unsigned limit = 0;
702 switch (gimple_call_internal_fn (gs))
704 case IFN_UNIQUE:
705 #define DEF(X) #X
706 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
707 #undef DEF
708 enums = unique_args;
710 limit = ARRAY_SIZE (unique_args);
711 break;
713 case IFN_GOACC_LOOP:
714 #define DEF(X) #X
715 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
716 #undef DEF
717 enums = loop_args;
718 limit = ARRAY_SIZE (loop_args);
719 break;
721 case IFN_GOACC_REDUCTION:
722 #define DEF(X) #X
723 static const char *const reduction_args[]
724 = {IFN_GOACC_REDUCTION_CODES};
725 #undef DEF
726 enums = reduction_args;
727 limit = ARRAY_SIZE (reduction_args);
728 break;
730 case IFN_ASAN_MARK:
731 #define DEF(X) #X
732 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
733 #undef DEF
734 enums = asan_mark_args;
735 limit = ARRAY_SIZE (asan_mark_args);
736 break;
738 default:
739 break;
741 if (limit)
743 tree arg0 = gimple_call_arg (gs, 0);
744 HOST_WIDE_INT v;
746 if (TREE_CODE (arg0) == INTEGER_CST
747 && tree_fits_shwi_p (arg0)
748 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
750 i++;
751 pp_string (buffer, enums[v]);
756 for (; i < gimple_call_num_args (gs); i++)
758 if (i)
759 pp_string (buffer, ", ");
760 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
763 if (gimple_call_va_arg_pack_p (gs))
765 if (i)
766 pp_string (buffer, ", ");
768 pp_string (buffer, "__builtin_va_arg_pack ()");
772 /* Dump the points-to solution *PT to BUFFER. */
774 static void
775 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
777 if (pt->anything)
779 pp_string (buffer, "anything ");
780 return;
782 if (pt->nonlocal)
783 pp_string (buffer, "nonlocal ");
784 if (pt->escaped)
785 pp_string (buffer, "escaped ");
786 if (pt->ipa_escaped)
787 pp_string (buffer, "unit-escaped ");
788 if (pt->null)
789 pp_string (buffer, "null ");
790 if (pt->vars
791 && !bitmap_empty_p (pt->vars))
793 bitmap_iterator bi;
794 unsigned i;
795 pp_string (buffer, "{ ");
796 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
798 pp_string (buffer, "D.");
799 pp_decimal_int (buffer, i);
800 pp_space (buffer);
802 pp_right_brace (buffer);
803 if (pt->vars_contains_nonlocal
804 || pt->vars_contains_escaped
805 || pt->vars_contains_escaped_heap
806 || pt->vars_contains_restrict)
808 const char *comma = "";
809 pp_string (buffer, " (");
810 if (pt->vars_contains_nonlocal)
812 pp_string (buffer, "nonlocal");
813 comma = ", ";
815 if (pt->vars_contains_escaped)
817 pp_string (buffer, comma);
818 pp_string (buffer, "escaped");
819 comma = ", ";
821 if (pt->vars_contains_escaped_heap)
823 pp_string (buffer, comma);
824 pp_string (buffer, "escaped heap");
825 comma = ", ";
827 if (pt->vars_contains_restrict)
829 pp_string (buffer, comma);
830 pp_string (buffer, "restrict");
831 comma = ", ";
833 if (pt->vars_contains_interposable)
835 pp_string (buffer, comma);
836 pp_string (buffer, "interposable");
838 pp_string (buffer, ")");
844 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
845 pp_gimple_stmt_1. */
847 static void
848 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
849 dump_flags_t flags)
851 tree lhs = gimple_call_lhs (gs);
852 tree fn = gimple_call_fn (gs);
854 if (flags & TDF_ALIAS)
856 struct pt_solution *pt;
857 pt = gimple_call_use_set (gs);
858 if (!pt_solution_empty_p (pt))
860 pp_string (buffer, "# USE = ");
861 pp_points_to_solution (buffer, pt);
862 newline_and_indent (buffer, spc);
864 pt = gimple_call_clobber_set (gs);
865 if (!pt_solution_empty_p (pt))
867 pp_string (buffer, "# CLB = ");
868 pp_points_to_solution (buffer, pt);
869 newline_and_indent (buffer, spc);
873 if (flags & TDF_RAW)
875 if (gimple_call_internal_p (gs))
876 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
877 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
878 else
879 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
880 if (gimple_call_num_args (gs) > 0)
882 pp_string (buffer, ", ");
883 dump_gimple_call_args (buffer, gs, flags);
885 pp_greater (buffer);
887 else
889 if (lhs && !(flags & TDF_RHS_ONLY))
891 dump_generic_node (buffer, lhs, spc, flags, false);
892 pp_string (buffer, " =");
894 if (gimple_has_volatile_ops (gs))
895 pp_string (buffer, "{v}");
897 pp_space (buffer);
899 if (gimple_call_internal_p (gs))
900 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
901 else
902 print_call_name (buffer, fn, flags);
903 pp_string (buffer, " (");
904 dump_gimple_call_args (buffer, gs, flags);
905 pp_right_paren (buffer);
906 if (!(flags & TDF_RHS_ONLY))
907 pp_semicolon (buffer);
910 if (gimple_call_chain (gs))
912 pp_string (buffer, " [static-chain: ");
913 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
914 pp_right_bracket (buffer);
917 if (gimple_call_return_slot_opt_p (gs))
918 pp_string (buffer, " [return slot optimization]");
919 if (gimple_call_tail_p (gs))
920 pp_string (buffer, " [tail call]");
921 if (gimple_call_must_tail_p (gs))
922 pp_string (buffer, " [must tail call]");
924 if (fn == NULL)
925 return;
927 /* Dump the arguments of _ITM_beginTransaction sanely. */
928 if (TREE_CODE (fn) == ADDR_EXPR)
929 fn = TREE_OPERAND (fn, 0);
930 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
931 pp_string (buffer, " [tm-clone]");
932 if (TREE_CODE (fn) == FUNCTION_DECL
933 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
934 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
935 && gimple_call_num_args (gs) > 0)
937 tree t = gimple_call_arg (gs, 0);
938 unsigned HOST_WIDE_INT props;
939 gcc_assert (TREE_CODE (t) == INTEGER_CST);
941 pp_string (buffer, " [ ");
943 /* Get the transaction code properties. */
944 props = TREE_INT_CST_LOW (t);
946 if (props & PR_INSTRUMENTEDCODE)
947 pp_string (buffer, "instrumentedCode ");
948 if (props & PR_UNINSTRUMENTEDCODE)
949 pp_string (buffer, "uninstrumentedCode ");
950 if (props & PR_HASNOXMMUPDATE)
951 pp_string (buffer, "hasNoXMMUpdate ");
952 if (props & PR_HASNOABORT)
953 pp_string (buffer, "hasNoAbort ");
954 if (props & PR_HASNOIRREVOCABLE)
955 pp_string (buffer, "hasNoIrrevocable ");
956 if (props & PR_DOESGOIRREVOCABLE)
957 pp_string (buffer, "doesGoIrrevocable ");
958 if (props & PR_HASNOSIMPLEREADS)
959 pp_string (buffer, "hasNoSimpleReads ");
960 if (props & PR_AWBARRIERSOMITTED)
961 pp_string (buffer, "awBarriersOmitted ");
962 if (props & PR_RARBARRIERSOMITTED)
963 pp_string (buffer, "RaRBarriersOmitted ");
964 if (props & PR_UNDOLOGCODE)
965 pp_string (buffer, "undoLogCode ");
966 if (props & PR_PREFERUNINSTRUMENTED)
967 pp_string (buffer, "preferUninstrumented ");
968 if (props & PR_EXCEPTIONBLOCK)
969 pp_string (buffer, "exceptionBlock ");
970 if (props & PR_HASELSE)
971 pp_string (buffer, "hasElse ");
972 if (props & PR_READONLY)
973 pp_string (buffer, "readOnly ");
975 pp_right_bracket (buffer);
980 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
981 pp_gimple_stmt_1. */
983 static void
984 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
985 dump_flags_t flags)
987 unsigned int i;
989 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
990 if (flags & TDF_RAW)
991 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
992 gimple_switch_index (gs));
993 else
995 pp_string (buffer, "switch (");
996 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
997 if (flags & TDF_GIMPLE)
998 pp_string (buffer, ") {");
999 else
1000 pp_string (buffer, ") <");
1003 for (i = 0; i < gimple_switch_num_labels (gs); i++)
1005 tree case_label = gimple_switch_label (gs, i);
1006 gcc_checking_assert (case_label != NULL_TREE);
1007 dump_generic_node (buffer, case_label, spc, flags, false);
1008 pp_space (buffer);
1009 tree label = CASE_LABEL (case_label);
1010 dump_generic_node (buffer, label, spc, flags, false);
1012 if (cfun && cfun->cfg)
1014 basic_block dest = label_to_block (label);
1015 if (dest)
1017 edge label_edge = find_edge (gimple_bb (gs), dest);
1018 if (label_edge && !(flags & TDF_GIMPLE))
1019 dump_edge_probability (buffer, label_edge);
1023 if (i < gimple_switch_num_labels (gs) - 1)
1025 if (flags & TDF_GIMPLE)
1026 pp_string (buffer, "; ");
1027 else
1028 pp_string (buffer, ", ");
1031 if (flags & TDF_GIMPLE)
1032 pp_string (buffer, "; }");
1033 else
1034 pp_greater (buffer);
1038 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1039 pp_gimple_stmt_1. */
1041 static void
1042 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc,
1043 dump_flags_t flags)
1045 if (flags & TDF_RAW)
1046 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1047 get_tree_code_name (gimple_cond_code (gs)),
1048 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1049 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1050 else
1052 if (!(flags & TDF_RHS_ONLY))
1053 pp_string (buffer, "if (");
1054 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
1055 pp_space (buffer);
1056 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1057 pp_space (buffer);
1058 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
1059 if (!(flags & TDF_RHS_ONLY))
1061 edge_iterator ei;
1062 edge e, true_edge = NULL, false_edge = NULL;
1063 basic_block bb = gimple_bb (gs);
1065 if (bb)
1067 FOR_EACH_EDGE (e, ei, bb->succs)
1069 if (e->flags & EDGE_TRUE_VALUE)
1070 true_edge = e;
1071 else if (e->flags & EDGE_FALSE_VALUE)
1072 false_edge = e;
1076 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1078 pp_right_paren (buffer);
1080 if (gimple_cond_true_label (gs))
1082 pp_string (buffer, " goto ");
1083 dump_generic_node (buffer, gimple_cond_true_label (gs),
1084 spc, flags, false);
1085 if (has_edge_info && !(flags & TDF_GIMPLE))
1086 dump_edge_probability (buffer, true_edge);
1087 pp_semicolon (buffer);
1089 if (gimple_cond_false_label (gs))
1091 pp_string (buffer, " else goto ");
1092 dump_generic_node (buffer, gimple_cond_false_label (gs),
1093 spc, flags, false);
1094 if (has_edge_info && !(flags & TDF_GIMPLE))
1095 dump_edge_probability (buffer, false_edge);
1097 pp_semicolon (buffer);
1104 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1105 spaces of indent. FLAGS specifies details to show in the dump (see
1106 TDF_* in dumpfils.h). */
1108 static void
1109 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
1110 dump_flags_t flags)
1112 tree label = gimple_label_label (gs);
1113 if (flags & TDF_RAW)
1114 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1115 else
1117 dump_generic_node (buffer, label, spc, flags, false);
1118 pp_colon (buffer);
1120 if (flags & TDF_GIMPLE)
1121 return;
1122 if (DECL_NONLOCAL (label))
1123 pp_string (buffer, " [non-local]");
1124 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1125 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1128 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1129 spaces of indent. FLAGS specifies details to show in the dump (see
1130 TDF_* in dumpfile.h). */
1132 static void
1133 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc,
1134 dump_flags_t flags)
1136 tree label = gimple_goto_dest (gs);
1137 if (flags & TDF_RAW)
1138 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1139 else
1140 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1144 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1145 spaces of indent. FLAGS specifies details to show in the dump (see
1146 TDF_* in dumpfile.h). */
1148 static void
1149 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc,
1150 dump_flags_t flags)
1152 if (flags & TDF_RAW)
1153 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1154 else
1155 pp_left_brace (buffer);
1156 if (!(flags & TDF_SLIM))
1158 tree var;
1160 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1162 newline_and_indent (buffer, 2);
1163 print_declaration (buffer, var, spc, flags);
1165 if (gimple_bind_vars (gs))
1166 pp_newline (buffer);
1168 pp_newline (buffer);
1169 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1170 newline_and_indent (buffer, spc);
1171 if (flags & TDF_RAW)
1172 pp_greater (buffer);
1173 else
1174 pp_right_brace (buffer);
1178 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1179 indent. FLAGS specifies details to show in the dump (see TDF_* in
1180 dumpfile.h). */
1182 static void
1183 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc,
1184 dump_flags_t flags)
1186 if (flags & TDF_RAW)
1188 const char *type;
1189 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1190 type = "GIMPLE_TRY_CATCH";
1191 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1192 type = "GIMPLE_TRY_FINALLY";
1193 else
1194 type = "UNKNOWN GIMPLE_TRY";
1195 dump_gimple_fmt (buffer, spc, flags,
1196 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1197 gimple_try_eval (gs), gimple_try_cleanup (gs));
1199 else
1201 pp_string (buffer, "try");
1202 newline_and_indent (buffer, spc + 2);
1203 pp_left_brace (buffer);
1204 pp_newline (buffer);
1206 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1207 newline_and_indent (buffer, spc + 2);
1208 pp_right_brace (buffer);
1210 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1212 newline_and_indent (buffer, spc);
1213 pp_string (buffer, "catch");
1214 newline_and_indent (buffer, spc + 2);
1215 pp_left_brace (buffer);
1217 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1219 newline_and_indent (buffer, spc);
1220 pp_string (buffer, "finally");
1221 newline_and_indent (buffer, spc + 2);
1222 pp_left_brace (buffer);
1224 else
1225 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1227 pp_newline (buffer);
1228 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1229 newline_and_indent (buffer, spc + 2);
1230 pp_right_brace (buffer);
1235 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1236 indent. FLAGS specifies details to show in the dump (see TDF_* in
1237 dumpfile.h). */
1239 static void
1240 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc,
1241 dump_flags_t flags)
1243 if (flags & TDF_RAW)
1244 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1245 gimple_catch_types (gs), gimple_catch_handler (gs));
1246 else
1247 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1248 gimple_catch_types (gs), gimple_catch_handler (gs));
1252 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1253 indent. FLAGS specifies details to show in the dump (see TDF_* in
1254 dumpfile.h). */
1256 static void
1257 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1258 dump_flags_t flags)
1260 if (flags & TDF_RAW)
1261 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1262 gimple_eh_filter_types (gs),
1263 gimple_eh_filter_failure (gs));
1264 else
1265 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1266 gimple_eh_filter_types (gs),
1267 gimple_eh_filter_failure (gs));
1271 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1273 static void
1274 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1275 geh_mnt *gs, int spc, dump_flags_t flags)
1277 if (flags & TDF_RAW)
1278 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1279 gimple_eh_must_not_throw_fndecl (gs));
1280 else
1281 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1282 gimple_eh_must_not_throw_fndecl (gs));
1286 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1287 indent. FLAGS specifies details to show in the dump (see TDF_* in
1288 dumpfile.h). */
1290 static void
1291 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1292 dump_flags_t flags)
1294 if (flags & TDF_RAW)
1295 dump_gimple_fmt (buffer, spc, flags,
1296 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1297 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1298 else
1299 dump_gimple_fmt (buffer, spc, flags,
1300 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1301 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1305 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1306 indent. FLAGS specifies details to show in the dump (see TDF_* in
1307 dumpfile.h). */
1309 static void
1310 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc,
1311 dump_flags_t flags)
1313 if (flags & TDF_RAW)
1314 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1315 gimple_resx_region (gs));
1316 else
1317 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1320 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1322 static void
1323 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc,
1324 dump_flags_t flags)
1326 if (flags & TDF_RAW)
1327 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1328 gimple_eh_dispatch_region (gs));
1329 else
1330 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1331 gimple_eh_dispatch_region (gs));
1334 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1335 of indent. FLAGS specifies details to show in the dump (see TDF_*
1336 in dumpfile.h). */
1338 static void
1339 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc,
1340 dump_flags_t flags)
1342 switch (gs->subcode)
1344 case GIMPLE_DEBUG_BIND:
1345 if (flags & TDF_RAW)
1346 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1347 gimple_debug_bind_get_var (gs),
1348 gimple_debug_bind_get_value (gs));
1349 else
1350 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1351 gimple_debug_bind_get_var (gs),
1352 gimple_debug_bind_get_value (gs));
1353 break;
1355 case GIMPLE_DEBUG_SOURCE_BIND:
1356 if (flags & TDF_RAW)
1357 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1358 gimple_debug_source_bind_get_var (gs),
1359 gimple_debug_source_bind_get_value (gs));
1360 else
1361 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1362 gimple_debug_source_bind_get_var (gs),
1363 gimple_debug_source_bind_get_value (gs));
1364 break;
1366 default:
1367 gcc_unreachable ();
1371 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1372 static void
1373 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc,
1374 dump_flags_t flags)
1376 size_t i;
1378 if (flags & TDF_RAW)
1380 const char *kind;
1381 switch (gimple_omp_for_kind (gs))
1383 case GF_OMP_FOR_KIND_FOR:
1384 kind = "";
1385 break;
1386 case GF_OMP_FOR_KIND_DISTRIBUTE:
1387 kind = " distribute";
1388 break;
1389 case GF_OMP_FOR_KIND_TASKLOOP:
1390 kind = " taskloop";
1391 break;
1392 case GF_OMP_FOR_KIND_OACC_LOOP:
1393 kind = " oacc_loop";
1394 break;
1395 case GF_OMP_FOR_KIND_SIMD:
1396 kind = " simd";
1397 break;
1398 default:
1399 gcc_unreachable ();
1401 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1402 kind, gimple_omp_body (gs));
1403 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1404 dump_gimple_fmt (buffer, spc, flags, " >,");
1405 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1406 dump_gimple_fmt (buffer, spc, flags,
1407 "%+%T, %T, %T, %s, %T,%n",
1408 gimple_omp_for_index (gs, i),
1409 gimple_omp_for_initial (gs, i),
1410 gimple_omp_for_final (gs, i),
1411 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1412 gimple_omp_for_incr (gs, i));
1413 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1414 gimple_omp_for_pre_body (gs));
1416 else
1418 switch (gimple_omp_for_kind (gs))
1420 case GF_OMP_FOR_KIND_FOR:
1421 pp_string (buffer, "#pragma omp for");
1422 break;
1423 case GF_OMP_FOR_KIND_DISTRIBUTE:
1424 pp_string (buffer, "#pragma omp distribute");
1425 break;
1426 case GF_OMP_FOR_KIND_TASKLOOP:
1427 pp_string (buffer, "#pragma omp taskloop");
1428 break;
1429 case GF_OMP_FOR_KIND_OACC_LOOP:
1430 pp_string (buffer, "#pragma acc loop");
1431 break;
1432 case GF_OMP_FOR_KIND_SIMD:
1433 pp_string (buffer, "#pragma omp simd");
1434 break;
1435 case GF_OMP_FOR_KIND_GRID_LOOP:
1436 pp_string (buffer, "#pragma omp for grid_loop");
1437 break;
1438 default:
1439 gcc_unreachable ();
1441 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1442 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1444 if (i)
1445 spc += 2;
1446 newline_and_indent (buffer, spc);
1447 pp_string (buffer, "for (");
1448 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1449 flags, false);
1450 pp_string (buffer, " = ");
1451 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1452 flags, false);
1453 pp_string (buffer, "; ");
1455 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1456 flags, false);
1457 pp_space (buffer);
1458 switch (gimple_omp_for_cond (gs, i))
1460 case LT_EXPR:
1461 pp_less (buffer);
1462 break;
1463 case GT_EXPR:
1464 pp_greater (buffer);
1465 break;
1466 case LE_EXPR:
1467 pp_less_equal (buffer);
1468 break;
1469 case GE_EXPR:
1470 pp_greater_equal (buffer);
1471 break;
1472 case NE_EXPR:
1473 pp_string (buffer, "!=");
1474 break;
1475 default:
1476 gcc_unreachable ();
1478 pp_space (buffer);
1479 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1480 flags, false);
1481 pp_string (buffer, "; ");
1483 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1484 flags, false);
1485 pp_string (buffer, " = ");
1486 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1487 flags, false);
1488 pp_right_paren (buffer);
1491 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1493 newline_and_indent (buffer, spc + 2);
1494 pp_left_brace (buffer);
1495 pp_newline (buffer);
1496 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1497 newline_and_indent (buffer, spc + 2);
1498 pp_right_brace (buffer);
1503 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1505 static void
1506 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1507 int spc, dump_flags_t flags)
1509 if (flags & TDF_RAW)
1511 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1512 gimple_omp_continue_control_def (gs),
1513 gimple_omp_continue_control_use (gs));
1515 else
1517 pp_string (buffer, "#pragma omp continue (");
1518 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1519 spc, flags, false);
1520 pp_comma (buffer);
1521 pp_space (buffer);
1522 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1523 spc, flags, false);
1524 pp_right_paren (buffer);
1528 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1530 static void
1531 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1532 int spc, dump_flags_t flags)
1534 if (flags & TDF_RAW)
1536 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1537 gimple_omp_body (gs));
1538 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1539 dump_gimple_fmt (buffer, spc, flags, " >");
1541 else
1543 pp_string (buffer, "#pragma omp single");
1544 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1545 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1547 newline_and_indent (buffer, spc + 2);
1548 pp_left_brace (buffer);
1549 pp_newline (buffer);
1550 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1551 newline_and_indent (buffer, spc + 2);
1552 pp_right_brace (buffer);
1557 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1559 static void
1560 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1561 int spc, dump_flags_t flags)
1563 const char *kind;
1564 switch (gimple_omp_target_kind (gs))
1566 case GF_OMP_TARGET_KIND_REGION:
1567 kind = "";
1568 break;
1569 case GF_OMP_TARGET_KIND_DATA:
1570 kind = " data";
1571 break;
1572 case GF_OMP_TARGET_KIND_UPDATE:
1573 kind = " update";
1574 break;
1575 case GF_OMP_TARGET_KIND_ENTER_DATA:
1576 kind = " enter data";
1577 break;
1578 case GF_OMP_TARGET_KIND_EXIT_DATA:
1579 kind = " exit data";
1580 break;
1581 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1582 kind = " oacc_kernels";
1583 break;
1584 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1585 kind = " oacc_parallel";
1586 break;
1587 case GF_OMP_TARGET_KIND_OACC_DATA:
1588 kind = " oacc_data";
1589 break;
1590 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1591 kind = " oacc_update";
1592 break;
1593 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1594 kind = " oacc_enter_exit_data";
1595 break;
1596 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1597 kind = " oacc_declare";
1598 break;
1599 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1600 kind = " oacc_host_data";
1601 break;
1602 default:
1603 gcc_unreachable ();
1605 if (flags & TDF_RAW)
1607 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1608 kind, gimple_omp_body (gs));
1609 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1610 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1611 gimple_omp_target_child_fn (gs),
1612 gimple_omp_target_data_arg (gs));
1614 else
1616 pp_string (buffer, "#pragma omp target");
1617 pp_string (buffer, kind);
1618 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1619 if (gimple_omp_target_child_fn (gs))
1621 pp_string (buffer, " [child fn: ");
1622 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1623 spc, flags, false);
1624 pp_string (buffer, " (");
1625 if (gimple_omp_target_data_arg (gs))
1626 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1627 spc, flags, false);
1628 else
1629 pp_string (buffer, "???");
1630 pp_string (buffer, ")]");
1632 gimple_seq body = gimple_omp_body (gs);
1633 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1635 newline_and_indent (buffer, spc + 2);
1636 pp_left_brace (buffer);
1637 pp_newline (buffer);
1638 dump_gimple_seq (buffer, body, spc + 4, flags);
1639 newline_and_indent (buffer, spc + 2);
1640 pp_right_brace (buffer);
1642 else if (body)
1644 pp_newline (buffer);
1645 dump_gimple_seq (buffer, body, spc + 2, flags);
1650 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1652 static void
1653 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1654 dump_flags_t flags)
1656 if (flags & TDF_RAW)
1658 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1659 gimple_omp_body (gs));
1660 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1661 dump_gimple_fmt (buffer, spc, flags, " >");
1663 else
1665 pp_string (buffer, "#pragma omp teams");
1666 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1667 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1669 newline_and_indent (buffer, spc + 2);
1670 pp_character (buffer, '{');
1671 pp_newline (buffer);
1672 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1673 newline_and_indent (buffer, spc + 2);
1674 pp_character (buffer, '}');
1679 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1681 static void
1682 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1683 int spc, dump_flags_t flags)
1685 if (flags & TDF_RAW)
1687 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1688 gimple_omp_body (gs));
1689 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1690 dump_gimple_fmt (buffer, spc, flags, " >");
1692 else
1694 pp_string (buffer, "#pragma omp sections");
1695 if (gimple_omp_sections_control (gs))
1697 pp_string (buffer, " <");
1698 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1699 flags, false);
1700 pp_greater (buffer);
1702 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1703 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1705 newline_and_indent (buffer, spc + 2);
1706 pp_left_brace (buffer);
1707 pp_newline (buffer);
1708 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1709 newline_and_indent (buffer, spc + 2);
1710 pp_right_brace (buffer);
1715 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1716 pretty_printer BUFFER. */
1718 static void
1719 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc,
1720 dump_flags_t flags)
1722 if (flags & TDF_RAW)
1723 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1724 gimple_omp_body (gs));
1725 else
1727 switch (gimple_code (gs))
1729 case GIMPLE_OMP_MASTER:
1730 pp_string (buffer, "#pragma omp master");
1731 break;
1732 case GIMPLE_OMP_TASKGROUP:
1733 pp_string (buffer, "#pragma omp taskgroup");
1734 break;
1735 case GIMPLE_OMP_SECTION:
1736 pp_string (buffer, "#pragma omp section");
1737 break;
1738 case GIMPLE_OMP_GRID_BODY:
1739 pp_string (buffer, "#pragma omp gridified body");
1740 break;
1741 default:
1742 gcc_unreachable ();
1744 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1746 newline_and_indent (buffer, spc + 2);
1747 pp_left_brace (buffer);
1748 pp_newline (buffer);
1749 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1750 newline_and_indent (buffer, spc + 2);
1751 pp_right_brace (buffer);
1756 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1758 static void
1759 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1760 int spc, dump_flags_t flags)
1762 if (flags & TDF_RAW)
1763 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1764 gimple_omp_body (gs));
1765 else
1767 pp_string (buffer, "#pragma omp critical");
1768 if (gimple_omp_critical_name (gs))
1770 pp_string (buffer, " (");
1771 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1772 flags, false);
1773 pp_right_paren (buffer);
1775 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1776 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1778 newline_and_indent (buffer, spc + 2);
1779 pp_left_brace (buffer);
1780 pp_newline (buffer);
1781 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1782 newline_and_indent (buffer, spc + 2);
1783 pp_right_brace (buffer);
1788 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1790 static void
1791 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1792 int spc, dump_flags_t flags)
1794 if (flags & TDF_RAW)
1795 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1796 gimple_omp_body (gs));
1797 else
1799 pp_string (buffer, "#pragma omp ordered");
1800 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1801 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1803 newline_and_indent (buffer, spc + 2);
1804 pp_left_brace (buffer);
1805 pp_newline (buffer);
1806 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1807 newline_and_indent (buffer, spc + 2);
1808 pp_right_brace (buffer);
1813 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1815 static void
1816 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc,
1817 dump_flags_t flags)
1819 if (flags & TDF_RAW)
1821 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1822 (int) gimple_omp_return_nowait_p (gs));
1823 if (gimple_omp_return_lhs (gs))
1824 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1825 gimple_omp_return_lhs (gs));
1826 else
1827 dump_gimple_fmt (buffer, spc, flags, ">");
1829 else
1831 pp_string (buffer, "#pragma omp return");
1832 if (gimple_omp_return_nowait_p (gs))
1833 pp_string (buffer, "(nowait)");
1834 if (gimple_omp_return_lhs (gs))
1836 pp_string (buffer, " (set ");
1837 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1838 spc, flags, false);
1839 pp_character (buffer, ')');
1844 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1846 static void
1847 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1848 int spc, dump_flags_t flags)
1850 unsigned subcode = gimple_transaction_subcode (gs);
1852 if (flags & TDF_RAW)
1854 dump_gimple_fmt (buffer, spc, flags,
1855 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1856 "<%+BODY <%S> >",
1857 gs, subcode, gimple_transaction_label_norm (gs),
1858 gimple_transaction_label_uninst (gs),
1859 gimple_transaction_label_over (gs),
1860 gimple_transaction_body (gs));
1862 else
1864 if (subcode & GTMA_IS_OUTER)
1865 pp_string (buffer, "__transaction_atomic [[outer]]");
1866 else if (subcode & GTMA_IS_RELAXED)
1867 pp_string (buffer, "__transaction_relaxed");
1868 else
1869 pp_string (buffer, "__transaction_atomic");
1870 subcode &= ~GTMA_DECLARATION_MASK;
1872 if (gimple_transaction_body (gs))
1874 newline_and_indent (buffer, spc + 2);
1875 pp_left_brace (buffer);
1876 pp_newline (buffer);
1877 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1878 spc + 4, flags);
1879 newline_and_indent (buffer, spc + 2);
1880 pp_right_brace (buffer);
1882 else
1884 pp_string (buffer, " //");
1885 if (gimple_transaction_label_norm (gs))
1887 pp_string (buffer, " NORM=");
1888 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1889 spc, flags, false);
1891 if (gimple_transaction_label_uninst (gs))
1893 pp_string (buffer, " UNINST=");
1894 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1895 spc, flags, false);
1897 if (gimple_transaction_label_over (gs))
1899 pp_string (buffer, " OVER=");
1900 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1901 spc, flags, false);
1903 if (subcode)
1905 pp_string (buffer, " SUBCODE=[ ");
1906 if (subcode & GTMA_HAVE_ABORT)
1908 pp_string (buffer, "GTMA_HAVE_ABORT ");
1909 subcode &= ~GTMA_HAVE_ABORT;
1911 if (subcode & GTMA_HAVE_LOAD)
1913 pp_string (buffer, "GTMA_HAVE_LOAD ");
1914 subcode &= ~GTMA_HAVE_LOAD;
1916 if (subcode & GTMA_HAVE_STORE)
1918 pp_string (buffer, "GTMA_HAVE_STORE ");
1919 subcode &= ~GTMA_HAVE_STORE;
1921 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1923 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1924 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1926 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1928 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1929 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1931 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1933 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1934 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1936 if (subcode)
1937 pp_printf (buffer, "0x%x ", subcode);
1938 pp_right_bracket (buffer);
1944 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1945 indent. FLAGS specifies details to show in the dump (see TDF_* in
1946 dumpfile.h). */
1948 static void
1949 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, dump_flags_t flags)
1951 unsigned int i, n, f, fields;
1953 if (flags & TDF_RAW)
1955 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1956 gimple_asm_string (gs));
1958 n = gimple_asm_noutputs (gs);
1959 if (n)
1961 newline_and_indent (buffer, spc + 2);
1962 pp_string (buffer, "OUTPUT: ");
1963 for (i = 0; i < n; i++)
1965 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1966 spc, flags, false);
1967 if (i < n - 1)
1968 pp_string (buffer, ", ");
1972 n = gimple_asm_ninputs (gs);
1973 if (n)
1975 newline_and_indent (buffer, spc + 2);
1976 pp_string (buffer, "INPUT: ");
1977 for (i = 0; i < n; i++)
1979 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1980 spc, flags, false);
1981 if (i < n - 1)
1982 pp_string (buffer, ", ");
1986 n = gimple_asm_nclobbers (gs);
1987 if (n)
1989 newline_and_indent (buffer, spc + 2);
1990 pp_string (buffer, "CLOBBER: ");
1991 for (i = 0; i < n; i++)
1993 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1994 spc, flags, false);
1995 if (i < n - 1)
1996 pp_string (buffer, ", ");
2000 n = gimple_asm_nlabels (gs);
2001 if (n)
2003 newline_and_indent (buffer, spc + 2);
2004 pp_string (buffer, "LABEL: ");
2005 for (i = 0; i < n; i++)
2007 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2008 spc, flags, false);
2009 if (i < n - 1)
2010 pp_string (buffer, ", ");
2014 newline_and_indent (buffer, spc);
2015 pp_greater (buffer);
2017 else
2019 pp_string (buffer, "__asm__");
2020 if (gimple_asm_volatile_p (gs))
2021 pp_string (buffer, " __volatile__");
2022 if (gimple_asm_nlabels (gs))
2023 pp_string (buffer, " goto");
2024 pp_string (buffer, "(\"");
2025 pp_string (buffer, gimple_asm_string (gs));
2026 pp_string (buffer, "\"");
2028 if (gimple_asm_nlabels (gs))
2029 fields = 4;
2030 else if (gimple_asm_nclobbers (gs))
2031 fields = 3;
2032 else if (gimple_asm_ninputs (gs))
2033 fields = 2;
2034 else if (gimple_asm_noutputs (gs))
2035 fields = 1;
2036 else
2037 fields = 0;
2039 for (f = 0; f < fields; ++f)
2041 pp_string (buffer, " : ");
2043 switch (f)
2045 case 0:
2046 n = gimple_asm_noutputs (gs);
2047 for (i = 0; i < n; i++)
2049 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2050 spc, flags, false);
2051 if (i < n - 1)
2052 pp_string (buffer, ", ");
2054 break;
2056 case 1:
2057 n = gimple_asm_ninputs (gs);
2058 for (i = 0; i < n; i++)
2060 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2061 spc, flags, false);
2062 if (i < n - 1)
2063 pp_string (buffer, ", ");
2065 break;
2067 case 2:
2068 n = gimple_asm_nclobbers (gs);
2069 for (i = 0; i < n; i++)
2071 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2072 spc, flags, false);
2073 if (i < n - 1)
2074 pp_string (buffer, ", ");
2076 break;
2078 case 3:
2079 n = gimple_asm_nlabels (gs);
2080 for (i = 0; i < n; i++)
2082 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2083 spc, flags, false);
2084 if (i < n - 1)
2085 pp_string (buffer, ", ");
2087 break;
2089 default:
2090 gcc_unreachable ();
2094 pp_string (buffer, ");");
2098 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2099 SPC spaces of indent. */
2101 static void
2102 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2104 if (TREE_CODE (node) != SSA_NAME)
2105 return;
2107 if (POINTER_TYPE_P (TREE_TYPE (node))
2108 && SSA_NAME_PTR_INFO (node))
2110 unsigned int align, misalign;
2111 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2112 pp_string (buffer, "# PT = ");
2113 pp_points_to_solution (buffer, &pi->pt);
2114 newline_and_indent (buffer, spc);
2115 if (get_ptr_info_alignment (pi, &align, &misalign))
2117 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2118 newline_and_indent (buffer, spc);
2122 if (!POINTER_TYPE_P (TREE_TYPE (node))
2123 && SSA_NAME_RANGE_INFO (node))
2125 wide_int min, max, nonzero_bits;
2126 value_range_type range_type = get_range_info (node, &min, &max);
2128 if (range_type == VR_VARYING)
2129 pp_printf (buffer, "# RANGE VR_VARYING");
2130 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2132 pp_printf (buffer, "# RANGE ");
2133 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2134 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2135 pp_printf (buffer, ", ");
2136 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2137 pp_printf (buffer, "]");
2139 nonzero_bits = get_nonzero_bits (node);
2140 if (nonzero_bits != -1)
2142 pp_string (buffer, " NONZERO ");
2143 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2145 newline_and_indent (buffer, spc);
2149 /* As dump_ssaname_info, but dump to FILE. */
2151 void
2152 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2154 pretty_printer buffer;
2155 pp_needs_newline (&buffer) = true;
2156 buffer.buffer->stream = file;
2157 dump_ssaname_info (&buffer, node, spc);
2158 pp_flush (&buffer);
2161 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2162 The caller is responsible for calling pp_flush on BUFFER to finalize
2163 pretty printer. If COMMENT is true, print this after #. */
2165 static void
2166 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2167 dump_flags_t flags)
2169 size_t i;
2170 tree lhs = gimple_phi_result (phi);
2172 if (flags & TDF_ALIAS)
2173 dump_ssaname_info (buffer, lhs, spc);
2175 if (comment)
2176 pp_string (buffer, "# ");
2178 if (flags & TDF_RAW)
2179 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2180 gimple_phi_result (phi));
2181 else
2183 dump_generic_node (buffer, lhs, spc, flags, false);
2184 if (flags & TDF_GIMPLE)
2185 pp_string (buffer, " = __PHI (");
2186 else
2187 pp_string (buffer, " = PHI <");
2189 for (i = 0; i < gimple_phi_num_args (phi); i++)
2191 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2192 dump_location (buffer, gimple_phi_arg_location (phi, i));
2193 if (flags & TDF_GIMPLE)
2195 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2196 gimple *stmt = first_stmt (src);
2197 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2199 pp_string (buffer, "bb_");
2200 pp_decimal_int (buffer, src->index);
2202 else
2203 dump_generic_node (buffer, gimple_label_label (as_a <glabel *> (stmt)), 0, flags,
2204 false);
2205 pp_string (buffer, ": ");
2207 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2208 false);
2209 if (! (flags & TDF_GIMPLE))
2211 pp_left_paren (buffer);
2212 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2213 pp_right_paren (buffer);
2215 if (i < gimple_phi_num_args (phi) - 1)
2216 pp_string (buffer, ", ");
2218 if (flags & TDF_GIMPLE)
2219 pp_string (buffer, ");");
2220 else
2221 pp_greater (buffer);
2225 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2226 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2227 dumpfile.h). */
2229 static void
2230 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2231 int spc, dump_flags_t flags)
2233 if (flags & TDF_RAW)
2235 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2236 gimple_omp_body (gs));
2237 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2238 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2239 gimple_omp_parallel_child_fn (gs),
2240 gimple_omp_parallel_data_arg (gs));
2242 else
2244 gimple_seq body;
2245 pp_string (buffer, "#pragma omp parallel");
2246 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2247 if (gimple_omp_parallel_child_fn (gs))
2249 pp_string (buffer, " [child fn: ");
2250 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2251 spc, flags, false);
2252 pp_string (buffer, " (");
2253 if (gimple_omp_parallel_data_arg (gs))
2254 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2255 spc, flags, false);
2256 else
2257 pp_string (buffer, "???");
2258 pp_string (buffer, ")]");
2260 body = gimple_omp_body (gs);
2261 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2263 newline_and_indent (buffer, spc + 2);
2264 pp_left_brace (buffer);
2265 pp_newline (buffer);
2266 dump_gimple_seq (buffer, body, spc + 4, flags);
2267 newline_and_indent (buffer, spc + 2);
2268 pp_right_brace (buffer);
2270 else if (body)
2272 pp_newline (buffer);
2273 dump_gimple_seq (buffer, body, spc + 2, flags);
2279 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2280 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2281 dumpfile.h). */
2283 static void
2284 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2285 dump_flags_t flags)
2287 if (flags & TDF_RAW)
2289 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2290 gimple_omp_body (gs));
2291 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2292 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2293 gimple_omp_task_child_fn (gs),
2294 gimple_omp_task_data_arg (gs),
2295 gimple_omp_task_copy_fn (gs),
2296 gimple_omp_task_arg_size (gs),
2297 gimple_omp_task_arg_size (gs));
2299 else
2301 gimple_seq body;
2302 if (gimple_omp_task_taskloop_p (gs))
2303 pp_string (buffer, "#pragma omp taskloop");
2304 else
2305 pp_string (buffer, "#pragma omp task");
2306 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2307 if (gimple_omp_task_child_fn (gs))
2309 pp_string (buffer, " [child fn: ");
2310 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2311 spc, flags, false);
2312 pp_string (buffer, " (");
2313 if (gimple_omp_task_data_arg (gs))
2314 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2315 spc, flags, false);
2316 else
2317 pp_string (buffer, "???");
2318 pp_string (buffer, ")]");
2320 body = gimple_omp_body (gs);
2321 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2323 newline_and_indent (buffer, spc + 2);
2324 pp_left_brace (buffer);
2325 pp_newline (buffer);
2326 dump_gimple_seq (buffer, body, spc + 4, flags);
2327 newline_and_indent (buffer, spc + 2);
2328 pp_right_brace (buffer);
2330 else if (body)
2332 pp_newline (buffer);
2333 dump_gimple_seq (buffer, body, spc + 2, flags);
2339 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2340 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2341 in dumpfile.h). */
2343 static void
2344 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2345 int spc, dump_flags_t flags)
2347 if (flags & TDF_RAW)
2349 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2350 gimple_omp_atomic_load_lhs (gs),
2351 gimple_omp_atomic_load_rhs (gs));
2353 else
2355 pp_string (buffer, "#pragma omp atomic_load");
2356 if (gimple_omp_atomic_seq_cst_p (gs))
2357 pp_string (buffer, " seq_cst");
2358 if (gimple_omp_atomic_need_value_p (gs))
2359 pp_string (buffer, " [needed]");
2360 newline_and_indent (buffer, spc + 2);
2361 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2362 spc, flags, false);
2363 pp_space (buffer);
2364 pp_equal (buffer);
2365 pp_space (buffer);
2366 pp_star (buffer);
2367 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2368 spc, flags, false);
2372 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2373 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2374 in dumpfile.h). */
2376 static void
2377 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2378 gomp_atomic_store *gs, int spc,
2379 dump_flags_t flags)
2381 if (flags & TDF_RAW)
2383 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2384 gimple_omp_atomic_store_val (gs));
2386 else
2388 pp_string (buffer, "#pragma omp atomic_store ");
2389 if (gimple_omp_atomic_seq_cst_p (gs))
2390 pp_string (buffer, "seq_cst ");
2391 if (gimple_omp_atomic_need_value_p (gs))
2392 pp_string (buffer, "[needed] ");
2393 pp_left_paren (buffer);
2394 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2395 spc, flags, false);
2396 pp_right_paren (buffer);
2401 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2402 FLAGS are as in pp_gimple_stmt_1. */
2404 static void
2405 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc,
2406 dump_flags_t flags)
2408 tree vdef = gimple_vdef (gs);
2409 tree vuse = gimple_vuse (gs);
2411 if (vdef != NULL_TREE)
2413 pp_string (buffer, "# ");
2414 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2415 pp_string (buffer, " = VDEF <");
2416 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2417 pp_greater (buffer);
2418 newline_and_indent (buffer, spc);
2420 else if (vuse != NULL_TREE)
2422 pp_string (buffer, "# VUSE <");
2423 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2424 pp_greater (buffer);
2425 newline_and_indent (buffer, spc);
2430 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2431 spaces of indent. FLAGS specifies details to show in the dump (see
2432 TDF_* in dumpfile.h). The caller is responsible for calling
2433 pp_flush on BUFFER to finalize the pretty printer. */
2435 void
2436 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc,
2437 dump_flags_t flags)
2439 if (!gs)
2440 return;
2442 if (flags & TDF_STMTADDR)
2443 pp_printf (buffer, "<&%p> ", (void *) gs);
2445 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2446 dump_location (buffer, gimple_location (gs));
2448 if (flags & TDF_EH)
2450 int lp_nr = lookup_stmt_eh_lp (gs);
2451 if (lp_nr > 0)
2452 pp_printf (buffer, "[LP %d] ", lp_nr);
2453 else if (lp_nr < 0)
2454 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2457 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2458 && gimple_has_mem_ops (gs))
2459 dump_gimple_mem_ops (buffer, gs, spc, flags);
2461 if (gimple_has_lhs (gs)
2462 && (flags & TDF_ALIAS))
2463 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2465 switch (gimple_code (gs))
2467 case GIMPLE_ASM:
2468 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2469 break;
2471 case GIMPLE_ASSIGN:
2472 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2473 break;
2475 case GIMPLE_BIND:
2476 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2477 break;
2479 case GIMPLE_CALL:
2480 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2481 break;
2483 case GIMPLE_COND:
2484 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2485 break;
2487 case GIMPLE_LABEL:
2488 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2489 break;
2491 case GIMPLE_GOTO:
2492 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2493 break;
2495 case GIMPLE_NOP:
2496 pp_string (buffer, "GIMPLE_NOP");
2497 break;
2499 case GIMPLE_RETURN:
2500 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2501 break;
2503 case GIMPLE_SWITCH:
2504 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2505 break;
2507 case GIMPLE_TRY:
2508 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2509 break;
2511 case GIMPLE_PHI:
2512 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2513 break;
2515 case GIMPLE_OMP_PARALLEL:
2516 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2517 flags);
2518 break;
2520 case GIMPLE_OMP_TASK:
2521 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2522 break;
2524 case GIMPLE_OMP_ATOMIC_LOAD:
2525 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2526 spc, flags);
2527 break;
2529 case GIMPLE_OMP_ATOMIC_STORE:
2530 dump_gimple_omp_atomic_store (buffer,
2531 as_a <gomp_atomic_store *> (gs),
2532 spc, flags);
2533 break;
2535 case GIMPLE_OMP_FOR:
2536 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2537 break;
2539 case GIMPLE_OMP_CONTINUE:
2540 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2541 flags);
2542 break;
2544 case GIMPLE_OMP_SINGLE:
2545 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2546 flags);
2547 break;
2549 case GIMPLE_OMP_TARGET:
2550 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2551 flags);
2552 break;
2554 case GIMPLE_OMP_TEAMS:
2555 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2556 flags);
2557 break;
2559 case GIMPLE_OMP_RETURN:
2560 dump_gimple_omp_return (buffer, gs, spc, flags);
2561 break;
2563 case GIMPLE_OMP_SECTIONS:
2564 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2565 spc, flags);
2566 break;
2568 case GIMPLE_OMP_SECTIONS_SWITCH:
2569 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2570 break;
2572 case GIMPLE_OMP_MASTER:
2573 case GIMPLE_OMP_TASKGROUP:
2574 case GIMPLE_OMP_SECTION:
2575 case GIMPLE_OMP_GRID_BODY:
2576 dump_gimple_omp_block (buffer, gs, spc, flags);
2577 break;
2579 case GIMPLE_OMP_ORDERED:
2580 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2581 flags);
2582 break;
2584 case GIMPLE_OMP_CRITICAL:
2585 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2586 flags);
2587 break;
2589 case GIMPLE_CATCH:
2590 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2591 break;
2593 case GIMPLE_EH_FILTER:
2594 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2595 break;
2597 case GIMPLE_EH_MUST_NOT_THROW:
2598 dump_gimple_eh_must_not_throw (buffer,
2599 as_a <geh_mnt *> (gs),
2600 spc, flags);
2601 break;
2603 case GIMPLE_EH_ELSE:
2604 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2605 break;
2607 case GIMPLE_RESX:
2608 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2609 break;
2611 case GIMPLE_EH_DISPATCH:
2612 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2613 flags);
2614 break;
2616 case GIMPLE_DEBUG:
2617 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2618 break;
2620 case GIMPLE_PREDICT:
2621 pp_string (buffer, "// predicted ");
2622 if (gimple_predict_outcome (gs))
2623 pp_string (buffer, "likely by ");
2624 else
2625 pp_string (buffer, "unlikely by ");
2626 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2627 pp_string (buffer, " predictor.");
2628 break;
2630 case GIMPLE_TRANSACTION:
2631 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2632 flags);
2633 break;
2635 default:
2636 GIMPLE_NIY;
2641 /* Dumps header of basic block BB to OUTF indented by INDENT
2642 spaces and details described by flags. */
2644 static void
2645 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
2646 dump_flags_t flags)
2648 if (flags & TDF_BLOCKS)
2650 if (flags & TDF_LINENO)
2652 gimple_stmt_iterator gsi;
2654 fputs (";; ", outf);
2656 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2657 if (!is_gimple_debug (gsi_stmt (gsi))
2658 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2660 fprintf (outf, "%*sstarting at line %d",
2661 indent, "", get_lineno (gsi_stmt (gsi)));
2662 break;
2664 if (bb->discriminator)
2665 fprintf (outf, ", discriminator %i", bb->discriminator);
2666 fputc ('\n', outf);
2669 else
2671 if (flags & TDF_GIMPLE)
2672 fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
2673 else
2674 fprintf (outf, "%*s<bb %d> %s:\n",
2675 indent, "", bb->index, dump_profile (bb->count));
2680 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2681 spaces. */
2683 static void
2684 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2685 basic_block bb ATTRIBUTE_UNUSED,
2686 int indent ATTRIBUTE_UNUSED,
2687 dump_flags_t flags ATTRIBUTE_UNUSED)
2689 /* There is currently no GIMPLE-specific basic block info to dump. */
2690 return;
2694 /* Dump PHI nodes of basic block BB to BUFFER with details described
2695 by FLAGS and indented by INDENT spaces. */
2697 static void
2698 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
2699 dump_flags_t flags)
2701 gphi_iterator i;
2703 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2705 gphi *phi = i.phi ();
2706 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2708 INDENT (indent);
2709 dump_gimple_phi (buffer, phi, indent,
2710 (flags & TDF_GIMPLE) ? false : true, flags);
2711 pp_newline (buffer);
2717 /* Dump jump to basic block BB that is represented implicitly in the cfg
2718 to BUFFER. */
2720 static void
2721 pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
2723 if (flags & TDF_GIMPLE)
2725 pp_string (buffer, "goto bb_");
2726 pp_decimal_int (buffer, e->dest->index);
2727 pp_semicolon (buffer);
2729 else
2731 pp_string (buffer, "goto <bb ");
2732 pp_decimal_int (buffer, e->dest->index);
2733 pp_greater (buffer);
2734 pp_semicolon (buffer);
2736 dump_edge_probability (buffer, e);
2741 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2742 by INDENT spaces, with details given by FLAGS. */
2744 static void
2745 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2746 dump_flags_t flags)
2748 edge e;
2749 gimple *stmt;
2751 stmt = last_stmt (bb);
2753 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2755 edge true_edge, false_edge;
2757 /* When we are emitting the code or changing CFG, it is possible that
2758 the edges are not yet created. When we are using debug_bb in such
2759 a situation, we do not want it to crash. */
2760 if (EDGE_COUNT (bb->succs) != 2)
2761 return;
2762 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2764 INDENT (indent + 2);
2765 pp_cfg_jump (buffer, true_edge, flags);
2766 newline_and_indent (buffer, indent);
2767 pp_string (buffer, "else");
2768 newline_and_indent (buffer, indent + 2);
2769 pp_cfg_jump (buffer, false_edge, flags);
2770 pp_newline (buffer);
2771 return;
2774 /* If there is a fallthru edge, we may need to add an artificial
2775 goto to the dump. */
2776 e = find_fallthru_edge (bb->succs);
2778 if (e && e->dest != bb->next_bb)
2780 INDENT (indent);
2782 if ((flags & TDF_LINENO)
2783 && e->goto_locus != UNKNOWN_LOCATION)
2784 dump_location (buffer, e->goto_locus);
2786 pp_cfg_jump (buffer, e, flags);
2787 pp_newline (buffer);
2792 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2793 indented by INDENT spaces. */
2795 static void
2796 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2797 dump_flags_t flags)
2799 gimple_stmt_iterator gsi;
2800 gimple *stmt;
2801 int label_indent = indent - 2;
2803 if (label_indent < 0)
2804 label_indent = 0;
2806 dump_phi_nodes (buffer, bb, indent, flags);
2808 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2810 int curr_indent;
2812 stmt = gsi_stmt (gsi);
2814 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2816 INDENT (curr_indent);
2817 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2818 pp_newline_and_flush (buffer);
2819 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2820 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2821 pp_buffer (buffer)->stream, stmt);
2824 dump_implicit_edges (buffer, bb, indent, flags);
2825 pp_flush (buffer);
2829 /* Dumps basic block BB to FILE with details described by FLAGS and
2830 indented by INDENT spaces. */
2832 void
2833 gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
2835 dump_gimple_bb_header (file, bb, indent, flags);
2836 if (bb->index >= NUM_FIXED_BLOCKS)
2838 pretty_printer buffer;
2839 pp_needs_newline (&buffer) = true;
2840 buffer.buffer->stream = file;
2841 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2843 dump_gimple_bb_footer (file, bb, indent, flags);
2846 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2847 no indentation, for use as a label of a DOT graph record-node.
2848 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2849 histogram dumping doesn't know about pretty-printers. */
2851 void
2852 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2854 pp_printf (pp, "<bb %d>:\n", bb->index);
2855 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2857 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2858 gsi_next (&gsi))
2860 gphi *phi = gsi.phi ();
2861 if (!virtual_operand_p (gimple_phi_result (phi))
2862 || (dump_flags & TDF_VOPS))
2864 pp_bar (pp);
2865 pp_write_text_to_stream (pp);
2866 pp_string (pp, "# ");
2867 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2868 pp_newline (pp);
2869 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2873 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2874 gsi_next (&gsi))
2876 gimple *stmt = gsi_stmt (gsi);
2877 pp_bar (pp);
2878 pp_write_text_to_stream (pp);
2879 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2880 pp_newline (pp);
2881 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2883 dump_implicit_edges (pp, bb, 0, dump_flags);
2884 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2888 /* Handle the %G format for TEXT. Same as %K in handle_K_format in
2889 tree-pretty-print.c but with a Gimple call statement as an argument. */
2891 void
2892 percent_G_format (text_info *text)
2894 gcall *stmt = va_arg (*text->args_ptr, gcall*);
2896 /* Build a call expression from the Gimple call statement and
2897 pass it to the K formatter that knows how to format it. */
2898 tree exp = build_vl_exp (CALL_EXPR, gimple_call_num_args (stmt) + 3);
2899 CALL_EXPR_FN (exp) = gimple_call_fn (stmt);
2900 TREE_TYPE (exp) = gimple_call_return_type (stmt);
2901 CALL_EXPR_STATIC_CHAIN (exp) = gimple_call_chain (stmt);
2902 SET_EXPR_LOCATION (exp, gimple_location (stmt));
2904 percent_K_format (text, exp);