2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / gcc / gimple-pretty-print.c
blob405d9e3e3bc5adce8d3f6ccd7647ec2d007a0b03
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2018 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, TDF_NONE);
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_PACK_FLOAT_EXPR:
433 case VEC_WIDEN_LSHIFT_HI_EXPR:
434 case VEC_WIDEN_LSHIFT_LO_EXPR:
435 case VEC_SERIES_EXPR:
436 for (p = get_tree_code_name (code); *p; p++)
437 pp_character (buffer, TOUPPER (*p));
438 pp_string (buffer, " <");
439 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
440 pp_string (buffer, ", ");
441 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
442 pp_greater (buffer);
443 break;
445 default:
446 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
448 pp_left_paren (buffer);
449 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
450 false);
451 pp_right_paren (buffer);
453 else
454 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
455 pp_space (buffer);
456 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
457 pp_space (buffer);
458 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
460 pp_left_paren (buffer);
461 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
462 false);
463 pp_right_paren (buffer);
465 else
466 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
470 /* Helper for dump_gimple_assign. Print the ternary RHS of the
471 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
473 static void
474 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc,
475 dump_flags_t flags)
477 const char *p;
478 enum tree_code code = gimple_assign_rhs_code (gs);
479 switch (code)
481 case WIDEN_MULT_PLUS_EXPR:
482 case WIDEN_MULT_MINUS_EXPR:
483 for (p = get_tree_code_name (code); *p; p++)
484 pp_character (buffer, TOUPPER (*p));
485 pp_string (buffer, " <");
486 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
487 pp_string (buffer, ", ");
488 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
489 pp_string (buffer, ", ");
490 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
491 pp_greater (buffer);
492 break;
494 case DOT_PROD_EXPR:
495 pp_string (buffer, "DOT_PROD_EXPR <");
496 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
497 pp_string (buffer, ", ");
498 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
499 pp_string (buffer, ", ");
500 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
501 pp_greater (buffer);
502 break;
504 case SAD_EXPR:
505 pp_string (buffer, "SAD_EXPR <");
506 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
507 pp_string (buffer, ", ");
508 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
509 pp_string (buffer, ", ");
510 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
511 pp_greater (buffer);
512 break;
514 case VEC_PERM_EXPR:
515 pp_string (buffer, "VEC_PERM_EXPR <");
516 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
517 pp_string (buffer, ", ");
518 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
519 pp_string (buffer, ", ");
520 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
521 pp_greater (buffer);
522 break;
524 case REALIGN_LOAD_EXPR:
525 pp_string (buffer, "REALIGN_LOAD <");
526 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
527 pp_string (buffer, ", ");
528 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
529 pp_string (buffer, ", ");
530 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
531 pp_greater (buffer);
532 break;
534 case COND_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 break;
542 case VEC_COND_EXPR:
543 pp_string (buffer, "VEC_COND_EXPR <");
544 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
545 pp_string (buffer, ", ");
546 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
547 pp_string (buffer, ", ");
548 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
549 pp_greater (buffer);
550 break;
552 case BIT_INSERT_EXPR:
553 pp_string (buffer, "BIT_INSERT_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 pp_string (buffer, " (");
560 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
561 pp_decimal_int (buffer,
562 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
563 else
564 dump_generic_node (buffer,
565 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
566 spc, flags, false);
567 pp_string (buffer, " bits)>");
568 break;
570 default:
571 gcc_unreachable ();
576 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
577 pp_gimple_stmt_1. */
579 static void
580 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc,
581 dump_flags_t flags)
583 if (flags & TDF_RAW)
585 tree arg1 = NULL;
586 tree arg2 = NULL;
587 tree arg3 = NULL;
588 switch (gimple_num_ops (gs))
590 case 4:
591 arg3 = gimple_assign_rhs3 (gs);
592 /* FALLTHRU */
593 case 3:
594 arg2 = gimple_assign_rhs2 (gs);
595 /* FALLTHRU */
596 case 2:
597 arg1 = gimple_assign_rhs1 (gs);
598 break;
599 default:
600 gcc_unreachable ();
603 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
604 get_tree_code_name (gimple_assign_rhs_code (gs)),
605 gimple_assign_lhs (gs), arg1, arg2, arg3);
607 else
609 if (!(flags & TDF_RHS_ONLY))
611 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
612 pp_space (buffer);
613 pp_equal (buffer);
615 if (gimple_assign_nontemporal_move_p (gs))
616 pp_string (buffer, "{nt}");
618 if (gimple_has_volatile_ops (gs))
619 pp_string (buffer, "{v}");
621 pp_space (buffer);
624 if (gimple_num_ops (gs) == 2)
625 dump_unary_rhs (buffer, gs, spc, flags);
626 else if (gimple_num_ops (gs) == 3)
627 dump_binary_rhs (buffer, gs, spc, flags);
628 else if (gimple_num_ops (gs) == 4)
629 dump_ternary_rhs (buffer, gs, spc, flags);
630 else
631 gcc_unreachable ();
632 if (!(flags & TDF_RHS_ONLY))
633 pp_semicolon (buffer);
638 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
639 pp_gimple_stmt_1. */
641 static void
642 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc,
643 dump_flags_t flags)
645 tree t, t2;
647 t = gimple_return_retval (gs);
648 t2 = gimple_return_retbnd (gs);
649 if (flags & TDF_RAW)
650 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
651 else
653 pp_string (buffer, "return");
654 if (t)
656 pp_space (buffer);
657 dump_generic_node (buffer, t, spc, flags, false);
659 if (t2)
661 pp_string (buffer, ", ");
662 dump_generic_node (buffer, t2, spc, flags, false);
664 pp_semicolon (buffer);
669 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
670 dump_gimple_call. */
672 static void
673 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, dump_flags_t flags)
675 size_t i = 0;
677 /* Pretty print first arg to certain internal fns. */
678 if (gimple_call_internal_p (gs))
680 const char *const *enums = NULL;
681 unsigned limit = 0;
683 switch (gimple_call_internal_fn (gs))
685 case IFN_UNIQUE:
686 #define DEF(X) #X
687 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
688 #undef DEF
689 enums = unique_args;
691 limit = ARRAY_SIZE (unique_args);
692 break;
694 case IFN_GOACC_LOOP:
695 #define DEF(X) #X
696 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
697 #undef DEF
698 enums = loop_args;
699 limit = ARRAY_SIZE (loop_args);
700 break;
702 case IFN_GOACC_REDUCTION:
703 #define DEF(X) #X
704 static const char *const reduction_args[]
705 = {IFN_GOACC_REDUCTION_CODES};
706 #undef DEF
707 enums = reduction_args;
708 limit = ARRAY_SIZE (reduction_args);
709 break;
711 case IFN_ASAN_MARK:
712 #define DEF(X) #X
713 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
714 #undef DEF
715 enums = asan_mark_args;
716 limit = ARRAY_SIZE (asan_mark_args);
717 break;
719 default:
720 break;
722 if (limit)
724 tree arg0 = gimple_call_arg (gs, 0);
725 HOST_WIDE_INT v;
727 if (TREE_CODE (arg0) == INTEGER_CST
728 && tree_fits_shwi_p (arg0)
729 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
731 i++;
732 pp_string (buffer, enums[v]);
737 for (; i < gimple_call_num_args (gs); i++)
739 if (i)
740 pp_string (buffer, ", ");
741 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
744 if (gimple_call_va_arg_pack_p (gs))
746 if (i)
747 pp_string (buffer, ", ");
749 pp_string (buffer, "__builtin_va_arg_pack ()");
753 /* Dump the points-to solution *PT to BUFFER. */
755 static void
756 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
758 if (pt->anything)
760 pp_string (buffer, "anything ");
761 return;
763 if (pt->nonlocal)
764 pp_string (buffer, "nonlocal ");
765 if (pt->escaped)
766 pp_string (buffer, "escaped ");
767 if (pt->ipa_escaped)
768 pp_string (buffer, "unit-escaped ");
769 if (pt->null)
770 pp_string (buffer, "null ");
771 if (pt->vars
772 && !bitmap_empty_p (pt->vars))
774 bitmap_iterator bi;
775 unsigned i;
776 pp_string (buffer, "{ ");
777 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
779 pp_string (buffer, "D.");
780 pp_decimal_int (buffer, i);
781 pp_space (buffer);
783 pp_right_brace (buffer);
784 if (pt->vars_contains_nonlocal
785 || pt->vars_contains_escaped
786 || pt->vars_contains_escaped_heap
787 || pt->vars_contains_restrict)
789 const char *comma = "";
790 pp_string (buffer, " (");
791 if (pt->vars_contains_nonlocal)
793 pp_string (buffer, "nonlocal");
794 comma = ", ";
796 if (pt->vars_contains_escaped)
798 pp_string (buffer, comma);
799 pp_string (buffer, "escaped");
800 comma = ", ";
802 if (pt->vars_contains_escaped_heap)
804 pp_string (buffer, comma);
805 pp_string (buffer, "escaped heap");
806 comma = ", ";
808 if (pt->vars_contains_restrict)
810 pp_string (buffer, comma);
811 pp_string (buffer, "restrict");
812 comma = ", ";
814 if (pt->vars_contains_interposable)
816 pp_string (buffer, comma);
817 pp_string (buffer, "interposable");
819 pp_string (buffer, ")");
825 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
826 pp_gimple_stmt_1. */
828 static void
829 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
830 dump_flags_t flags)
832 tree lhs = gimple_call_lhs (gs);
833 tree fn = gimple_call_fn (gs);
835 if (flags & TDF_ALIAS)
837 struct pt_solution *pt;
838 pt = gimple_call_use_set (gs);
839 if (!pt_solution_empty_p (pt))
841 pp_string (buffer, "# USE = ");
842 pp_points_to_solution (buffer, pt);
843 newline_and_indent (buffer, spc);
845 pt = gimple_call_clobber_set (gs);
846 if (!pt_solution_empty_p (pt))
848 pp_string (buffer, "# CLB = ");
849 pp_points_to_solution (buffer, pt);
850 newline_and_indent (buffer, spc);
854 if (flags & TDF_RAW)
856 if (gimple_call_internal_p (gs))
857 dump_gimple_fmt (buffer, spc, flags, "%G <.%s, %T", gs,
858 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
859 else
860 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
861 if (gimple_call_num_args (gs) > 0)
863 pp_string (buffer, ", ");
864 dump_gimple_call_args (buffer, gs, flags);
866 pp_greater (buffer);
868 else
870 if (lhs && !(flags & TDF_RHS_ONLY))
872 dump_generic_node (buffer, lhs, spc, flags, false);
873 pp_string (buffer, " =");
875 if (gimple_has_volatile_ops (gs))
876 pp_string (buffer, "{v}");
878 pp_space (buffer);
880 if (gimple_call_internal_p (gs))
882 pp_dot (buffer);
883 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
885 else
886 print_call_name (buffer, fn, flags);
887 pp_string (buffer, " (");
888 dump_gimple_call_args (buffer, gs, flags);
889 pp_right_paren (buffer);
890 if (!(flags & TDF_RHS_ONLY))
891 pp_semicolon (buffer);
894 if (gimple_call_chain (gs))
896 pp_string (buffer, " [static-chain: ");
897 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
898 pp_right_bracket (buffer);
901 if (gimple_call_return_slot_opt_p (gs))
902 pp_string (buffer, " [return slot optimization]");
903 if (gimple_call_tail_p (gs))
904 pp_string (buffer, " [tail call]");
905 if (gimple_call_must_tail_p (gs))
906 pp_string (buffer, " [must tail call]");
908 if (fn == NULL)
909 return;
911 /* Dump the arguments of _ITM_beginTransaction sanely. */
912 if (TREE_CODE (fn) == ADDR_EXPR)
913 fn = TREE_OPERAND (fn, 0);
914 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
915 pp_string (buffer, " [tm-clone]");
916 if (TREE_CODE (fn) == FUNCTION_DECL
917 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
918 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
919 && gimple_call_num_args (gs) > 0)
921 tree t = gimple_call_arg (gs, 0);
922 unsigned HOST_WIDE_INT props;
923 gcc_assert (TREE_CODE (t) == INTEGER_CST);
925 pp_string (buffer, " [ ");
927 /* Get the transaction code properties. */
928 props = TREE_INT_CST_LOW (t);
930 if (props & PR_INSTRUMENTEDCODE)
931 pp_string (buffer, "instrumentedCode ");
932 if (props & PR_UNINSTRUMENTEDCODE)
933 pp_string (buffer, "uninstrumentedCode ");
934 if (props & PR_HASNOXMMUPDATE)
935 pp_string (buffer, "hasNoXMMUpdate ");
936 if (props & PR_HASNOABORT)
937 pp_string (buffer, "hasNoAbort ");
938 if (props & PR_HASNOIRREVOCABLE)
939 pp_string (buffer, "hasNoIrrevocable ");
940 if (props & PR_DOESGOIRREVOCABLE)
941 pp_string (buffer, "doesGoIrrevocable ");
942 if (props & PR_HASNOSIMPLEREADS)
943 pp_string (buffer, "hasNoSimpleReads ");
944 if (props & PR_AWBARRIERSOMITTED)
945 pp_string (buffer, "awBarriersOmitted ");
946 if (props & PR_RARBARRIERSOMITTED)
947 pp_string (buffer, "RaRBarriersOmitted ");
948 if (props & PR_UNDOLOGCODE)
949 pp_string (buffer, "undoLogCode ");
950 if (props & PR_PREFERUNINSTRUMENTED)
951 pp_string (buffer, "preferUninstrumented ");
952 if (props & PR_EXCEPTIONBLOCK)
953 pp_string (buffer, "exceptionBlock ");
954 if (props & PR_HASELSE)
955 pp_string (buffer, "hasElse ");
956 if (props & PR_READONLY)
957 pp_string (buffer, "readOnly ");
959 pp_right_bracket (buffer);
964 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
965 pp_gimple_stmt_1. */
967 static void
968 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
969 dump_flags_t flags)
971 unsigned int i;
973 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
974 if (flags & TDF_RAW)
975 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
976 gimple_switch_index (gs));
977 else
979 pp_string (buffer, "switch (");
980 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
981 if (flags & TDF_GIMPLE)
982 pp_string (buffer, ") {");
983 else
984 pp_string (buffer, ") <");
987 for (i = 0; i < gimple_switch_num_labels (gs); i++)
989 tree case_label = gimple_switch_label (gs, i);
990 gcc_checking_assert (case_label != NULL_TREE);
991 dump_generic_node (buffer, case_label, spc, flags, false);
992 pp_space (buffer);
993 tree label = CASE_LABEL (case_label);
994 dump_generic_node (buffer, label, spc, flags, false);
996 if (cfun && cfun->cfg)
998 basic_block dest = label_to_block (label);
999 if (dest)
1001 edge label_edge = find_edge (gimple_bb (gs), dest);
1002 if (label_edge && !(flags & TDF_GIMPLE))
1003 dump_edge_probability (buffer, label_edge);
1007 if (i < gimple_switch_num_labels (gs) - 1)
1009 if (flags & TDF_GIMPLE)
1010 pp_string (buffer, "; ");
1011 else
1012 pp_string (buffer, ", ");
1015 if (flags & TDF_GIMPLE)
1016 pp_string (buffer, "; }");
1017 else
1018 pp_greater (buffer);
1022 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1023 pp_gimple_stmt_1. */
1025 static void
1026 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc,
1027 dump_flags_t flags)
1029 if (flags & TDF_RAW)
1030 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1031 get_tree_code_name (gimple_cond_code (gs)),
1032 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1033 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1034 else
1036 if (!(flags & TDF_RHS_ONLY))
1037 pp_string (buffer, "if (");
1038 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
1039 pp_space (buffer);
1040 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1041 pp_space (buffer);
1042 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
1043 if (!(flags & TDF_RHS_ONLY))
1045 edge_iterator ei;
1046 edge e, true_edge = NULL, false_edge = NULL;
1047 basic_block bb = gimple_bb (gs);
1049 if (bb)
1051 FOR_EACH_EDGE (e, ei, bb->succs)
1053 if (e->flags & EDGE_TRUE_VALUE)
1054 true_edge = e;
1055 else if (e->flags & EDGE_FALSE_VALUE)
1056 false_edge = e;
1060 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1062 pp_right_paren (buffer);
1064 if (gimple_cond_true_label (gs))
1066 pp_string (buffer, " goto ");
1067 dump_generic_node (buffer, gimple_cond_true_label (gs),
1068 spc, flags, false);
1069 if (has_edge_info && !(flags & TDF_GIMPLE))
1070 dump_edge_probability (buffer, true_edge);
1071 pp_semicolon (buffer);
1073 if (gimple_cond_false_label (gs))
1075 pp_string (buffer, " else goto ");
1076 dump_generic_node (buffer, gimple_cond_false_label (gs),
1077 spc, flags, false);
1078 if (has_edge_info && !(flags & TDF_GIMPLE))
1079 dump_edge_probability (buffer, false_edge);
1081 pp_semicolon (buffer);
1088 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1089 spaces of indent. FLAGS specifies details to show in the dump (see
1090 TDF_* in dumpfils.h). */
1092 static void
1093 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
1094 dump_flags_t flags)
1096 tree label = gimple_label_label (gs);
1097 if (flags & TDF_RAW)
1098 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1099 else
1101 dump_generic_node (buffer, label, spc, flags, false);
1102 pp_colon (buffer);
1104 if (flags & TDF_GIMPLE)
1105 return;
1106 if (DECL_NONLOCAL (label))
1107 pp_string (buffer, " [non-local]");
1108 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1109 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1112 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1113 spaces of indent. FLAGS specifies details to show in the dump (see
1114 TDF_* in dumpfile.h). */
1116 static void
1117 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc,
1118 dump_flags_t flags)
1120 tree label = gimple_goto_dest (gs);
1121 if (flags & TDF_RAW)
1122 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1123 else
1124 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1128 /* Dump a GIMPLE_BIND 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_bind (pretty_printer *buffer, gbind *gs, int spc,
1134 dump_flags_t flags)
1136 if (flags & TDF_RAW)
1137 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1138 else
1139 pp_left_brace (buffer);
1140 if (!(flags & TDF_SLIM))
1142 tree var;
1144 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1146 newline_and_indent (buffer, 2);
1147 print_declaration (buffer, var, spc, flags);
1149 if (gimple_bind_vars (gs))
1150 pp_newline (buffer);
1152 pp_newline (buffer);
1153 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1154 newline_and_indent (buffer, spc);
1155 if (flags & TDF_RAW)
1156 pp_greater (buffer);
1157 else
1158 pp_right_brace (buffer);
1162 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1163 indent. FLAGS specifies details to show in the dump (see TDF_* in
1164 dumpfile.h). */
1166 static void
1167 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc,
1168 dump_flags_t flags)
1170 if (flags & TDF_RAW)
1172 const char *type;
1173 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1174 type = "GIMPLE_TRY_CATCH";
1175 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1176 type = "GIMPLE_TRY_FINALLY";
1177 else
1178 type = "UNKNOWN GIMPLE_TRY";
1179 dump_gimple_fmt (buffer, spc, flags,
1180 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1181 gimple_try_eval (gs), gimple_try_cleanup (gs));
1183 else
1185 pp_string (buffer, "try");
1186 newline_and_indent (buffer, spc + 2);
1187 pp_left_brace (buffer);
1188 pp_newline (buffer);
1190 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1191 newline_and_indent (buffer, spc + 2);
1192 pp_right_brace (buffer);
1194 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1196 newline_and_indent (buffer, spc);
1197 pp_string (buffer, "catch");
1198 newline_and_indent (buffer, spc + 2);
1199 pp_left_brace (buffer);
1201 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1203 newline_and_indent (buffer, spc);
1204 pp_string (buffer, "finally");
1205 newline_and_indent (buffer, spc + 2);
1206 pp_left_brace (buffer);
1208 else
1209 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1211 pp_newline (buffer);
1212 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1213 newline_and_indent (buffer, spc + 2);
1214 pp_right_brace (buffer);
1219 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1220 indent. FLAGS specifies details to show in the dump (see TDF_* in
1221 dumpfile.h). */
1223 static void
1224 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc,
1225 dump_flags_t flags)
1227 if (flags & TDF_RAW)
1228 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1229 gimple_catch_types (gs), gimple_catch_handler (gs));
1230 else
1231 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1232 gimple_catch_types (gs), gimple_catch_handler (gs));
1236 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1237 indent. FLAGS specifies details to show in the dump (see TDF_* in
1238 dumpfile.h). */
1240 static void
1241 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1242 dump_flags_t flags)
1244 if (flags & TDF_RAW)
1245 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1246 gimple_eh_filter_types (gs),
1247 gimple_eh_filter_failure (gs));
1248 else
1249 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1250 gimple_eh_filter_types (gs),
1251 gimple_eh_filter_failure (gs));
1255 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1257 static void
1258 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1259 geh_mnt *gs, int spc, dump_flags_t flags)
1261 if (flags & TDF_RAW)
1262 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1263 gimple_eh_must_not_throw_fndecl (gs));
1264 else
1265 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1266 gimple_eh_must_not_throw_fndecl (gs));
1270 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1271 indent. FLAGS specifies details to show in the dump (see TDF_* in
1272 dumpfile.h). */
1274 static void
1275 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1276 dump_flags_t flags)
1278 if (flags & TDF_RAW)
1279 dump_gimple_fmt (buffer, spc, flags,
1280 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1281 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1282 else
1283 dump_gimple_fmt (buffer, spc, flags,
1284 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1285 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1289 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1290 indent. FLAGS specifies details to show in the dump (see TDF_* in
1291 dumpfile.h). */
1293 static void
1294 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc,
1295 dump_flags_t flags)
1297 if (flags & TDF_RAW)
1298 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1299 gimple_resx_region (gs));
1300 else
1301 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1304 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1306 static void
1307 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc,
1308 dump_flags_t flags)
1310 if (flags & TDF_RAW)
1311 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1312 gimple_eh_dispatch_region (gs));
1313 else
1314 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1315 gimple_eh_dispatch_region (gs));
1318 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1319 of indent. FLAGS specifies details to show in the dump (see TDF_*
1320 in dumpfile.h). */
1322 static void
1323 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc,
1324 dump_flags_t flags)
1326 switch (gs->subcode)
1328 case GIMPLE_DEBUG_BIND:
1329 if (flags & TDF_RAW)
1330 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1331 gimple_debug_bind_get_var (gs),
1332 gimple_debug_bind_get_value (gs));
1333 else
1334 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1335 gimple_debug_bind_get_var (gs),
1336 gimple_debug_bind_get_value (gs));
1337 break;
1339 case GIMPLE_DEBUG_SOURCE_BIND:
1340 if (flags & TDF_RAW)
1341 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1342 gimple_debug_source_bind_get_var (gs),
1343 gimple_debug_source_bind_get_value (gs));
1344 else
1345 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1346 gimple_debug_source_bind_get_var (gs),
1347 gimple_debug_source_bind_get_value (gs));
1348 break;
1350 case GIMPLE_DEBUG_BEGIN_STMT:
1351 if (flags & TDF_RAW)
1352 dump_gimple_fmt (buffer, spc, flags, "%G BEGIN_STMT", gs);
1353 else
1354 dump_gimple_fmt (buffer, spc, flags, "# DEBUG BEGIN_STMT");
1355 break;
1357 case GIMPLE_DEBUG_INLINE_ENTRY:
1358 if (flags & TDF_RAW)
1359 dump_gimple_fmt (buffer, spc, flags, "%G INLINE_ENTRY %T", gs,
1360 gimple_block (gs)
1361 ? block_ultimate_origin (gimple_block (gs))
1362 : NULL_TREE);
1363 else
1364 dump_gimple_fmt (buffer, spc, flags, "# DEBUG INLINE_ENTRY %T",
1365 gimple_block (gs)
1366 ? block_ultimate_origin (gimple_block (gs))
1367 : NULL_TREE);
1368 break;
1370 default:
1371 gcc_unreachable ();
1375 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1376 static void
1377 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc,
1378 dump_flags_t flags)
1380 size_t i;
1382 if (flags & TDF_RAW)
1384 const char *kind;
1385 switch (gimple_omp_for_kind (gs))
1387 case GF_OMP_FOR_KIND_FOR:
1388 kind = "";
1389 break;
1390 case GF_OMP_FOR_KIND_DISTRIBUTE:
1391 kind = " distribute";
1392 break;
1393 case GF_OMP_FOR_KIND_TASKLOOP:
1394 kind = " taskloop";
1395 break;
1396 case GF_OMP_FOR_KIND_OACC_LOOP:
1397 kind = " oacc_loop";
1398 break;
1399 case GF_OMP_FOR_KIND_SIMD:
1400 kind = " simd";
1401 break;
1402 default:
1403 gcc_unreachable ();
1405 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1406 kind, gimple_omp_body (gs));
1407 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1408 dump_gimple_fmt (buffer, spc, flags, " >,");
1409 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1410 dump_gimple_fmt (buffer, spc, flags,
1411 "%+%T, %T, %T, %s, %T,%n",
1412 gimple_omp_for_index (gs, i),
1413 gimple_omp_for_initial (gs, i),
1414 gimple_omp_for_final (gs, i),
1415 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1416 gimple_omp_for_incr (gs, i));
1417 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1418 gimple_omp_for_pre_body (gs));
1420 else
1422 switch (gimple_omp_for_kind (gs))
1424 case GF_OMP_FOR_KIND_FOR:
1425 pp_string (buffer, "#pragma omp for");
1426 break;
1427 case GF_OMP_FOR_KIND_DISTRIBUTE:
1428 pp_string (buffer, "#pragma omp distribute");
1429 break;
1430 case GF_OMP_FOR_KIND_TASKLOOP:
1431 pp_string (buffer, "#pragma omp taskloop");
1432 break;
1433 case GF_OMP_FOR_KIND_OACC_LOOP:
1434 pp_string (buffer, "#pragma acc loop");
1435 break;
1436 case GF_OMP_FOR_KIND_SIMD:
1437 pp_string (buffer, "#pragma omp simd");
1438 break;
1439 case GF_OMP_FOR_KIND_GRID_LOOP:
1440 pp_string (buffer, "#pragma omp for grid_loop");
1441 break;
1442 default:
1443 gcc_unreachable ();
1445 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1446 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1448 if (i)
1449 spc += 2;
1450 newline_and_indent (buffer, spc);
1451 pp_string (buffer, "for (");
1452 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1453 flags, false);
1454 pp_string (buffer, " = ");
1455 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1456 flags, false);
1457 pp_string (buffer, "; ");
1459 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1460 flags, false);
1461 pp_space (buffer);
1462 switch (gimple_omp_for_cond (gs, i))
1464 case LT_EXPR:
1465 pp_less (buffer);
1466 break;
1467 case GT_EXPR:
1468 pp_greater (buffer);
1469 break;
1470 case LE_EXPR:
1471 pp_less_equal (buffer);
1472 break;
1473 case GE_EXPR:
1474 pp_greater_equal (buffer);
1475 break;
1476 case NE_EXPR:
1477 pp_string (buffer, "!=");
1478 break;
1479 default:
1480 gcc_unreachable ();
1482 pp_space (buffer);
1483 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1484 flags, false);
1485 pp_string (buffer, "; ");
1487 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1488 flags, false);
1489 pp_string (buffer, " = ");
1490 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1491 flags, false);
1492 pp_right_paren (buffer);
1495 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1497 newline_and_indent (buffer, spc + 2);
1498 pp_left_brace (buffer);
1499 pp_newline (buffer);
1500 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1501 newline_and_indent (buffer, spc + 2);
1502 pp_right_brace (buffer);
1507 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1509 static void
1510 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1511 int spc, dump_flags_t flags)
1513 if (flags & TDF_RAW)
1515 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1516 gimple_omp_continue_control_def (gs),
1517 gimple_omp_continue_control_use (gs));
1519 else
1521 pp_string (buffer, "#pragma omp continue (");
1522 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1523 spc, flags, false);
1524 pp_comma (buffer);
1525 pp_space (buffer);
1526 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1527 spc, flags, false);
1528 pp_right_paren (buffer);
1532 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1534 static void
1535 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1536 int spc, dump_flags_t flags)
1538 if (flags & TDF_RAW)
1540 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1541 gimple_omp_body (gs));
1542 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1543 dump_gimple_fmt (buffer, spc, flags, " >");
1545 else
1547 pp_string (buffer, "#pragma omp single");
1548 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1549 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1551 newline_and_indent (buffer, spc + 2);
1552 pp_left_brace (buffer);
1553 pp_newline (buffer);
1554 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1555 newline_and_indent (buffer, spc + 2);
1556 pp_right_brace (buffer);
1561 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1563 static void
1564 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1565 int spc, dump_flags_t flags)
1567 const char *kind;
1568 switch (gimple_omp_target_kind (gs))
1570 case GF_OMP_TARGET_KIND_REGION:
1571 kind = "";
1572 break;
1573 case GF_OMP_TARGET_KIND_DATA:
1574 kind = " data";
1575 break;
1576 case GF_OMP_TARGET_KIND_UPDATE:
1577 kind = " update";
1578 break;
1579 case GF_OMP_TARGET_KIND_ENTER_DATA:
1580 kind = " enter data";
1581 break;
1582 case GF_OMP_TARGET_KIND_EXIT_DATA:
1583 kind = " exit data";
1584 break;
1585 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1586 kind = " oacc_kernels";
1587 break;
1588 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1589 kind = " oacc_parallel";
1590 break;
1591 case GF_OMP_TARGET_KIND_OACC_DATA:
1592 kind = " oacc_data";
1593 break;
1594 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1595 kind = " oacc_update";
1596 break;
1597 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1598 kind = " oacc_enter_exit_data";
1599 break;
1600 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1601 kind = " oacc_declare";
1602 break;
1603 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1604 kind = " oacc_host_data";
1605 break;
1606 default:
1607 gcc_unreachable ();
1609 if (flags & TDF_RAW)
1611 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1612 kind, gimple_omp_body (gs));
1613 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1614 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1615 gimple_omp_target_child_fn (gs),
1616 gimple_omp_target_data_arg (gs));
1618 else
1620 pp_string (buffer, "#pragma omp target");
1621 pp_string (buffer, kind);
1622 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1623 if (gimple_omp_target_child_fn (gs))
1625 pp_string (buffer, " [child fn: ");
1626 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1627 spc, flags, false);
1628 pp_string (buffer, " (");
1629 if (gimple_omp_target_data_arg (gs))
1630 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1631 spc, flags, false);
1632 else
1633 pp_string (buffer, "???");
1634 pp_string (buffer, ")]");
1636 gimple_seq body = gimple_omp_body (gs);
1637 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1639 newline_and_indent (buffer, spc + 2);
1640 pp_left_brace (buffer);
1641 pp_newline (buffer);
1642 dump_gimple_seq (buffer, body, spc + 4, flags);
1643 newline_and_indent (buffer, spc + 2);
1644 pp_right_brace (buffer);
1646 else if (body)
1648 pp_newline (buffer);
1649 dump_gimple_seq (buffer, body, spc + 2, flags);
1654 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1656 static void
1657 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1658 dump_flags_t flags)
1660 if (flags & TDF_RAW)
1662 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1663 gimple_omp_body (gs));
1664 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1665 dump_gimple_fmt (buffer, spc, flags, " >");
1667 else
1669 pp_string (buffer, "#pragma omp teams");
1670 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1671 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1673 newline_and_indent (buffer, spc + 2);
1674 pp_character (buffer, '{');
1675 pp_newline (buffer);
1676 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1677 newline_and_indent (buffer, spc + 2);
1678 pp_character (buffer, '}');
1683 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1685 static void
1686 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1687 int spc, dump_flags_t flags)
1689 if (flags & TDF_RAW)
1691 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1692 gimple_omp_body (gs));
1693 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1694 dump_gimple_fmt (buffer, spc, flags, " >");
1696 else
1698 pp_string (buffer, "#pragma omp sections");
1699 if (gimple_omp_sections_control (gs))
1701 pp_string (buffer, " <");
1702 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1703 flags, false);
1704 pp_greater (buffer);
1706 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1707 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1709 newline_and_indent (buffer, spc + 2);
1710 pp_left_brace (buffer);
1711 pp_newline (buffer);
1712 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1713 newline_and_indent (buffer, spc + 2);
1714 pp_right_brace (buffer);
1719 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1720 pretty_printer BUFFER. */
1722 static void
1723 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc,
1724 dump_flags_t flags)
1726 if (flags & TDF_RAW)
1727 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1728 gimple_omp_body (gs));
1729 else
1731 switch (gimple_code (gs))
1733 case GIMPLE_OMP_MASTER:
1734 pp_string (buffer, "#pragma omp master");
1735 break;
1736 case GIMPLE_OMP_TASKGROUP:
1737 pp_string (buffer, "#pragma omp taskgroup");
1738 break;
1739 case GIMPLE_OMP_SECTION:
1740 pp_string (buffer, "#pragma omp section");
1741 break;
1742 case GIMPLE_OMP_GRID_BODY:
1743 pp_string (buffer, "#pragma omp gridified body");
1744 break;
1745 default:
1746 gcc_unreachable ();
1748 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1750 newline_and_indent (buffer, spc + 2);
1751 pp_left_brace (buffer);
1752 pp_newline (buffer);
1753 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1754 newline_and_indent (buffer, spc + 2);
1755 pp_right_brace (buffer);
1760 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1762 static void
1763 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1764 int spc, dump_flags_t flags)
1766 if (flags & TDF_RAW)
1767 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1768 gimple_omp_body (gs));
1769 else
1771 pp_string (buffer, "#pragma omp critical");
1772 if (gimple_omp_critical_name (gs))
1774 pp_string (buffer, " (");
1775 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1776 flags, false);
1777 pp_right_paren (buffer);
1779 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1780 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1782 newline_and_indent (buffer, spc + 2);
1783 pp_left_brace (buffer);
1784 pp_newline (buffer);
1785 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1786 newline_and_indent (buffer, spc + 2);
1787 pp_right_brace (buffer);
1792 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1794 static void
1795 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1796 int spc, dump_flags_t flags)
1798 if (flags & TDF_RAW)
1799 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1800 gimple_omp_body (gs));
1801 else
1803 pp_string (buffer, "#pragma omp ordered");
1804 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1805 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1807 newline_and_indent (buffer, spc + 2);
1808 pp_left_brace (buffer);
1809 pp_newline (buffer);
1810 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1811 newline_and_indent (buffer, spc + 2);
1812 pp_right_brace (buffer);
1817 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1819 static void
1820 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc,
1821 dump_flags_t flags)
1823 if (flags & TDF_RAW)
1825 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1826 (int) gimple_omp_return_nowait_p (gs));
1827 if (gimple_omp_return_lhs (gs))
1828 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1829 gimple_omp_return_lhs (gs));
1830 else
1831 dump_gimple_fmt (buffer, spc, flags, ">");
1833 else
1835 pp_string (buffer, "#pragma omp return");
1836 if (gimple_omp_return_nowait_p (gs))
1837 pp_string (buffer, "(nowait)");
1838 if (gimple_omp_return_lhs (gs))
1840 pp_string (buffer, " (set ");
1841 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1842 spc, flags, false);
1843 pp_character (buffer, ')');
1848 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1850 static void
1851 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1852 int spc, dump_flags_t flags)
1854 unsigned subcode = gimple_transaction_subcode (gs);
1856 if (flags & TDF_RAW)
1858 dump_gimple_fmt (buffer, spc, flags,
1859 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1860 "<%+BODY <%S> >",
1861 gs, subcode, gimple_transaction_label_norm (gs),
1862 gimple_transaction_label_uninst (gs),
1863 gimple_transaction_label_over (gs),
1864 gimple_transaction_body (gs));
1866 else
1868 if (subcode & GTMA_IS_OUTER)
1869 pp_string (buffer, "__transaction_atomic [[outer]]");
1870 else if (subcode & GTMA_IS_RELAXED)
1871 pp_string (buffer, "__transaction_relaxed");
1872 else
1873 pp_string (buffer, "__transaction_atomic");
1874 subcode &= ~GTMA_DECLARATION_MASK;
1876 if (gimple_transaction_body (gs))
1878 newline_and_indent (buffer, spc + 2);
1879 pp_left_brace (buffer);
1880 pp_newline (buffer);
1881 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1882 spc + 4, flags);
1883 newline_and_indent (buffer, spc + 2);
1884 pp_right_brace (buffer);
1886 else
1888 pp_string (buffer, " //");
1889 if (gimple_transaction_label_norm (gs))
1891 pp_string (buffer, " NORM=");
1892 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1893 spc, flags, false);
1895 if (gimple_transaction_label_uninst (gs))
1897 pp_string (buffer, " UNINST=");
1898 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1899 spc, flags, false);
1901 if (gimple_transaction_label_over (gs))
1903 pp_string (buffer, " OVER=");
1904 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1905 spc, flags, false);
1907 if (subcode)
1909 pp_string (buffer, " SUBCODE=[ ");
1910 if (subcode & GTMA_HAVE_ABORT)
1912 pp_string (buffer, "GTMA_HAVE_ABORT ");
1913 subcode &= ~GTMA_HAVE_ABORT;
1915 if (subcode & GTMA_HAVE_LOAD)
1917 pp_string (buffer, "GTMA_HAVE_LOAD ");
1918 subcode &= ~GTMA_HAVE_LOAD;
1920 if (subcode & GTMA_HAVE_STORE)
1922 pp_string (buffer, "GTMA_HAVE_STORE ");
1923 subcode &= ~GTMA_HAVE_STORE;
1925 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1927 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1928 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1930 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1932 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1933 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1935 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1937 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1938 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1940 if (subcode)
1941 pp_printf (buffer, "0x%x ", subcode);
1942 pp_right_bracket (buffer);
1948 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1949 indent. FLAGS specifies details to show in the dump (see TDF_* in
1950 dumpfile.h). */
1952 static void
1953 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, dump_flags_t flags)
1955 unsigned int i, n, f, fields;
1957 if (flags & TDF_RAW)
1959 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1960 gimple_asm_string (gs));
1962 n = gimple_asm_noutputs (gs);
1963 if (n)
1965 newline_and_indent (buffer, spc + 2);
1966 pp_string (buffer, "OUTPUT: ");
1967 for (i = 0; i < n; i++)
1969 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1970 spc, flags, false);
1971 if (i < n - 1)
1972 pp_string (buffer, ", ");
1976 n = gimple_asm_ninputs (gs);
1977 if (n)
1979 newline_and_indent (buffer, spc + 2);
1980 pp_string (buffer, "INPUT: ");
1981 for (i = 0; i < n; i++)
1983 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1984 spc, flags, false);
1985 if (i < n - 1)
1986 pp_string (buffer, ", ");
1990 n = gimple_asm_nclobbers (gs);
1991 if (n)
1993 newline_and_indent (buffer, spc + 2);
1994 pp_string (buffer, "CLOBBER: ");
1995 for (i = 0; i < n; i++)
1997 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1998 spc, flags, false);
1999 if (i < n - 1)
2000 pp_string (buffer, ", ");
2004 n = gimple_asm_nlabels (gs);
2005 if (n)
2007 newline_and_indent (buffer, spc + 2);
2008 pp_string (buffer, "LABEL: ");
2009 for (i = 0; i < n; i++)
2011 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2012 spc, flags, false);
2013 if (i < n - 1)
2014 pp_string (buffer, ", ");
2018 newline_and_indent (buffer, spc);
2019 pp_greater (buffer);
2021 else
2023 pp_string (buffer, "__asm__");
2024 if (gimple_asm_volatile_p (gs))
2025 pp_string (buffer, " __volatile__");
2026 if (gimple_asm_nlabels (gs))
2027 pp_string (buffer, " goto");
2028 pp_string (buffer, "(\"");
2029 pp_string (buffer, gimple_asm_string (gs));
2030 pp_string (buffer, "\"");
2032 if (gimple_asm_nlabels (gs))
2033 fields = 4;
2034 else if (gimple_asm_nclobbers (gs))
2035 fields = 3;
2036 else if (gimple_asm_ninputs (gs))
2037 fields = 2;
2038 else if (gimple_asm_noutputs (gs))
2039 fields = 1;
2040 else
2041 fields = 0;
2043 for (f = 0; f < fields; ++f)
2045 pp_string (buffer, " : ");
2047 switch (f)
2049 case 0:
2050 n = gimple_asm_noutputs (gs);
2051 for (i = 0; i < n; i++)
2053 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2054 spc, flags, false);
2055 if (i < n - 1)
2056 pp_string (buffer, ", ");
2058 break;
2060 case 1:
2061 n = gimple_asm_ninputs (gs);
2062 for (i = 0; i < n; i++)
2064 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2065 spc, flags, false);
2066 if (i < n - 1)
2067 pp_string (buffer, ", ");
2069 break;
2071 case 2:
2072 n = gimple_asm_nclobbers (gs);
2073 for (i = 0; i < n; i++)
2075 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2076 spc, flags, false);
2077 if (i < n - 1)
2078 pp_string (buffer, ", ");
2080 break;
2082 case 3:
2083 n = gimple_asm_nlabels (gs);
2084 for (i = 0; i < n; i++)
2086 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2087 spc, flags, false);
2088 if (i < n - 1)
2089 pp_string (buffer, ", ");
2091 break;
2093 default:
2094 gcc_unreachable ();
2098 pp_string (buffer, ");");
2102 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2103 SPC spaces of indent. */
2105 static void
2106 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2108 if (TREE_CODE (node) != SSA_NAME)
2109 return;
2111 if (POINTER_TYPE_P (TREE_TYPE (node))
2112 && SSA_NAME_PTR_INFO (node))
2114 unsigned int align, misalign;
2115 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2116 pp_string (buffer, "# PT = ");
2117 pp_points_to_solution (buffer, &pi->pt);
2118 newline_and_indent (buffer, spc);
2119 if (get_ptr_info_alignment (pi, &align, &misalign))
2121 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2122 newline_and_indent (buffer, spc);
2126 if (!POINTER_TYPE_P (TREE_TYPE (node))
2127 && SSA_NAME_RANGE_INFO (node))
2129 wide_int min, max, nonzero_bits;
2130 value_range_type range_type = get_range_info (node, &min, &max);
2132 if (range_type == VR_VARYING)
2133 pp_printf (buffer, "# RANGE VR_VARYING");
2134 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2136 pp_printf (buffer, "# RANGE ");
2137 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2138 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2139 pp_printf (buffer, ", ");
2140 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2141 pp_printf (buffer, "]");
2143 nonzero_bits = get_nonzero_bits (node);
2144 if (nonzero_bits != -1)
2146 pp_string (buffer, " NONZERO ");
2147 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2149 newline_and_indent (buffer, spc);
2153 /* As dump_ssaname_info, but dump to FILE. */
2155 void
2156 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2158 pretty_printer buffer;
2159 pp_needs_newline (&buffer) = true;
2160 buffer.buffer->stream = file;
2161 dump_ssaname_info (&buffer, node, spc);
2162 pp_flush (&buffer);
2165 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2166 The caller is responsible for calling pp_flush on BUFFER to finalize
2167 pretty printer. If COMMENT is true, print this after #. */
2169 static void
2170 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2171 dump_flags_t flags)
2173 size_t i;
2174 tree lhs = gimple_phi_result (phi);
2176 if (flags & TDF_ALIAS)
2177 dump_ssaname_info (buffer, lhs, spc);
2179 if (comment)
2180 pp_string (buffer, "# ");
2182 if (flags & TDF_RAW)
2183 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2184 gimple_phi_result (phi));
2185 else
2187 dump_generic_node (buffer, lhs, spc, flags, false);
2188 if (flags & TDF_GIMPLE)
2189 pp_string (buffer, " = __PHI (");
2190 else
2191 pp_string (buffer, " = PHI <");
2193 for (i = 0; i < gimple_phi_num_args (phi); i++)
2195 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2196 dump_location (buffer, gimple_phi_arg_location (phi, i));
2197 if (flags & TDF_GIMPLE)
2199 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2200 gimple *stmt = first_stmt (src);
2201 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2203 pp_string (buffer, "bb_");
2204 pp_decimal_int (buffer, src->index);
2206 else
2207 dump_generic_node (buffer, gimple_label_label (as_a <glabel *> (stmt)), 0, flags,
2208 false);
2209 pp_string (buffer, ": ");
2211 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2212 false);
2213 if (! (flags & TDF_GIMPLE))
2215 pp_left_paren (buffer);
2216 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2217 pp_right_paren (buffer);
2219 if (i < gimple_phi_num_args (phi) - 1)
2220 pp_string (buffer, ", ");
2222 if (flags & TDF_GIMPLE)
2223 pp_string (buffer, ");");
2224 else
2225 pp_greater (buffer);
2229 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2230 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2231 dumpfile.h). */
2233 static void
2234 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2235 int spc, dump_flags_t flags)
2237 if (flags & TDF_RAW)
2239 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2240 gimple_omp_body (gs));
2241 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2242 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2243 gimple_omp_parallel_child_fn (gs),
2244 gimple_omp_parallel_data_arg (gs));
2246 else
2248 gimple_seq body;
2249 pp_string (buffer, "#pragma omp parallel");
2250 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2251 if (gimple_omp_parallel_child_fn (gs))
2253 pp_string (buffer, " [child fn: ");
2254 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2255 spc, flags, false);
2256 pp_string (buffer, " (");
2257 if (gimple_omp_parallel_data_arg (gs))
2258 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2259 spc, flags, false);
2260 else
2261 pp_string (buffer, "???");
2262 pp_string (buffer, ")]");
2264 body = gimple_omp_body (gs);
2265 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2267 newline_and_indent (buffer, spc + 2);
2268 pp_left_brace (buffer);
2269 pp_newline (buffer);
2270 dump_gimple_seq (buffer, body, spc + 4, flags);
2271 newline_and_indent (buffer, spc + 2);
2272 pp_right_brace (buffer);
2274 else if (body)
2276 pp_newline (buffer);
2277 dump_gimple_seq (buffer, body, spc + 2, flags);
2283 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2284 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2285 dumpfile.h). */
2287 static void
2288 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2289 dump_flags_t flags)
2291 if (flags & TDF_RAW)
2293 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2294 gimple_omp_body (gs));
2295 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2296 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2297 gimple_omp_task_child_fn (gs),
2298 gimple_omp_task_data_arg (gs),
2299 gimple_omp_task_copy_fn (gs),
2300 gimple_omp_task_arg_size (gs),
2301 gimple_omp_task_arg_size (gs));
2303 else
2305 gimple_seq body;
2306 if (gimple_omp_task_taskloop_p (gs))
2307 pp_string (buffer, "#pragma omp taskloop");
2308 else
2309 pp_string (buffer, "#pragma omp task");
2310 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2311 if (gimple_omp_task_child_fn (gs))
2313 pp_string (buffer, " [child fn: ");
2314 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2315 spc, flags, false);
2316 pp_string (buffer, " (");
2317 if (gimple_omp_task_data_arg (gs))
2318 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2319 spc, flags, false);
2320 else
2321 pp_string (buffer, "???");
2322 pp_string (buffer, ")]");
2324 body = gimple_omp_body (gs);
2325 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2327 newline_and_indent (buffer, spc + 2);
2328 pp_left_brace (buffer);
2329 pp_newline (buffer);
2330 dump_gimple_seq (buffer, body, spc + 4, flags);
2331 newline_and_indent (buffer, spc + 2);
2332 pp_right_brace (buffer);
2334 else if (body)
2336 pp_newline (buffer);
2337 dump_gimple_seq (buffer, body, spc + 2, flags);
2343 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2344 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2345 in dumpfile.h). */
2347 static void
2348 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2349 int spc, dump_flags_t flags)
2351 if (flags & TDF_RAW)
2353 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2354 gimple_omp_atomic_load_lhs (gs),
2355 gimple_omp_atomic_load_rhs (gs));
2357 else
2359 pp_string (buffer, "#pragma omp atomic_load");
2360 if (gimple_omp_atomic_seq_cst_p (gs))
2361 pp_string (buffer, " seq_cst");
2362 if (gimple_omp_atomic_need_value_p (gs))
2363 pp_string (buffer, " [needed]");
2364 newline_and_indent (buffer, spc + 2);
2365 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2366 spc, flags, false);
2367 pp_space (buffer);
2368 pp_equal (buffer);
2369 pp_space (buffer);
2370 pp_star (buffer);
2371 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2372 spc, flags, false);
2376 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2377 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2378 in dumpfile.h). */
2380 static void
2381 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2382 gomp_atomic_store *gs, int spc,
2383 dump_flags_t flags)
2385 if (flags & TDF_RAW)
2387 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2388 gimple_omp_atomic_store_val (gs));
2390 else
2392 pp_string (buffer, "#pragma omp atomic_store ");
2393 if (gimple_omp_atomic_seq_cst_p (gs))
2394 pp_string (buffer, "seq_cst ");
2395 if (gimple_omp_atomic_need_value_p (gs))
2396 pp_string (buffer, "[needed] ");
2397 pp_left_paren (buffer);
2398 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2399 spc, flags, false);
2400 pp_right_paren (buffer);
2405 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2406 FLAGS are as in pp_gimple_stmt_1. */
2408 static void
2409 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc,
2410 dump_flags_t flags)
2412 tree vdef = gimple_vdef (gs);
2413 tree vuse = gimple_vuse (gs);
2415 if (vdef != NULL_TREE)
2417 pp_string (buffer, "# ");
2418 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2419 pp_string (buffer, " = VDEF <");
2420 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2421 pp_greater (buffer);
2422 newline_and_indent (buffer, spc);
2424 else if (vuse != NULL_TREE)
2426 pp_string (buffer, "# VUSE <");
2427 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2428 pp_greater (buffer);
2429 newline_and_indent (buffer, spc);
2434 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2435 spaces of indent. FLAGS specifies details to show in the dump (see
2436 TDF_* in dumpfile.h). The caller is responsible for calling
2437 pp_flush on BUFFER to finalize the pretty printer. */
2439 void
2440 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc,
2441 dump_flags_t flags)
2443 if (!gs)
2444 return;
2446 if (flags & TDF_STMTADDR)
2447 pp_printf (buffer, "<&%p> ", (void *) gs);
2449 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2450 dump_location (buffer, gimple_location (gs));
2452 if (flags & TDF_EH)
2454 int lp_nr = lookup_stmt_eh_lp (gs);
2455 if (lp_nr > 0)
2456 pp_printf (buffer, "[LP %d] ", lp_nr);
2457 else if (lp_nr < 0)
2458 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2461 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2462 && gimple_has_mem_ops (gs))
2463 dump_gimple_mem_ops (buffer, gs, spc, flags);
2465 if (gimple_has_lhs (gs)
2466 && (flags & TDF_ALIAS))
2467 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2469 switch (gimple_code (gs))
2471 case GIMPLE_ASM:
2472 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2473 break;
2475 case GIMPLE_ASSIGN:
2476 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2477 break;
2479 case GIMPLE_BIND:
2480 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2481 break;
2483 case GIMPLE_CALL:
2484 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2485 break;
2487 case GIMPLE_COND:
2488 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2489 break;
2491 case GIMPLE_LABEL:
2492 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2493 break;
2495 case GIMPLE_GOTO:
2496 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2497 break;
2499 case GIMPLE_NOP:
2500 pp_string (buffer, "GIMPLE_NOP");
2501 break;
2503 case GIMPLE_RETURN:
2504 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2505 break;
2507 case GIMPLE_SWITCH:
2508 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2509 break;
2511 case GIMPLE_TRY:
2512 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2513 break;
2515 case GIMPLE_PHI:
2516 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2517 break;
2519 case GIMPLE_OMP_PARALLEL:
2520 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2521 flags);
2522 break;
2524 case GIMPLE_OMP_TASK:
2525 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2526 break;
2528 case GIMPLE_OMP_ATOMIC_LOAD:
2529 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2530 spc, flags);
2531 break;
2533 case GIMPLE_OMP_ATOMIC_STORE:
2534 dump_gimple_omp_atomic_store (buffer,
2535 as_a <gomp_atomic_store *> (gs),
2536 spc, flags);
2537 break;
2539 case GIMPLE_OMP_FOR:
2540 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2541 break;
2543 case GIMPLE_OMP_CONTINUE:
2544 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2545 flags);
2546 break;
2548 case GIMPLE_OMP_SINGLE:
2549 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2550 flags);
2551 break;
2553 case GIMPLE_OMP_TARGET:
2554 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2555 flags);
2556 break;
2558 case GIMPLE_OMP_TEAMS:
2559 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2560 flags);
2561 break;
2563 case GIMPLE_OMP_RETURN:
2564 dump_gimple_omp_return (buffer, gs, spc, flags);
2565 break;
2567 case GIMPLE_OMP_SECTIONS:
2568 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2569 spc, flags);
2570 break;
2572 case GIMPLE_OMP_SECTIONS_SWITCH:
2573 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2574 break;
2576 case GIMPLE_OMP_MASTER:
2577 case GIMPLE_OMP_TASKGROUP:
2578 case GIMPLE_OMP_SECTION:
2579 case GIMPLE_OMP_GRID_BODY:
2580 dump_gimple_omp_block (buffer, gs, spc, flags);
2581 break;
2583 case GIMPLE_OMP_ORDERED:
2584 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2585 flags);
2586 break;
2588 case GIMPLE_OMP_CRITICAL:
2589 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2590 flags);
2591 break;
2593 case GIMPLE_CATCH:
2594 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2595 break;
2597 case GIMPLE_EH_FILTER:
2598 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2599 break;
2601 case GIMPLE_EH_MUST_NOT_THROW:
2602 dump_gimple_eh_must_not_throw (buffer,
2603 as_a <geh_mnt *> (gs),
2604 spc, flags);
2605 break;
2607 case GIMPLE_EH_ELSE:
2608 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2609 break;
2611 case GIMPLE_RESX:
2612 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2613 break;
2615 case GIMPLE_EH_DISPATCH:
2616 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2617 flags);
2618 break;
2620 case GIMPLE_DEBUG:
2621 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2622 break;
2624 case GIMPLE_PREDICT:
2625 pp_string (buffer, "// predicted ");
2626 if (gimple_predict_outcome (gs))
2627 pp_string (buffer, "likely by ");
2628 else
2629 pp_string (buffer, "unlikely by ");
2630 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2631 pp_string (buffer, " predictor.");
2632 break;
2634 case GIMPLE_TRANSACTION:
2635 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2636 flags);
2637 break;
2639 default:
2640 GIMPLE_NIY;
2645 /* Dumps header of basic block BB to OUTF indented by INDENT
2646 spaces and details described by flags. */
2648 static void
2649 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
2650 dump_flags_t flags)
2652 if (flags & TDF_BLOCKS)
2654 if (flags & TDF_LINENO)
2656 gimple_stmt_iterator gsi;
2658 fputs (";; ", outf);
2660 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2661 if (!is_gimple_debug (gsi_stmt (gsi))
2662 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2664 fprintf (outf, "%*sstarting at line %d",
2665 indent, "", get_lineno (gsi_stmt (gsi)));
2666 break;
2668 if (bb->discriminator)
2669 fprintf (outf, ", discriminator %i", bb->discriminator);
2670 fputc ('\n', outf);
2673 else
2675 if (flags & TDF_GIMPLE)
2676 fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
2677 else
2678 fprintf (outf, "%*s<bb %d> %s:\n",
2679 indent, "", bb->index, dump_profile (bb->count));
2684 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2685 spaces. */
2687 static void
2688 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2689 basic_block bb ATTRIBUTE_UNUSED,
2690 int indent ATTRIBUTE_UNUSED,
2691 dump_flags_t flags ATTRIBUTE_UNUSED)
2693 /* There is currently no GIMPLE-specific basic block info to dump. */
2694 return;
2698 /* Dump PHI nodes of basic block BB to BUFFER with details described
2699 by FLAGS and indented by INDENT spaces. */
2701 static void
2702 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
2703 dump_flags_t flags)
2705 gphi_iterator i;
2707 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2709 gphi *phi = i.phi ();
2710 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2712 INDENT (indent);
2713 dump_gimple_phi (buffer, phi, indent,
2714 (flags & TDF_GIMPLE) ? false : true, flags);
2715 pp_newline (buffer);
2721 /* Dump jump to basic block BB that is represented implicitly in the cfg
2722 to BUFFER. */
2724 static void
2725 pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
2727 if (flags & TDF_GIMPLE)
2729 pp_string (buffer, "goto bb_");
2730 pp_decimal_int (buffer, e->dest->index);
2731 pp_semicolon (buffer);
2733 else
2735 pp_string (buffer, "goto <bb ");
2736 pp_decimal_int (buffer, e->dest->index);
2737 pp_greater (buffer);
2738 pp_semicolon (buffer);
2740 dump_edge_probability (buffer, e);
2745 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2746 by INDENT spaces, with details given by FLAGS. */
2748 static void
2749 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2750 dump_flags_t flags)
2752 edge e;
2753 gimple *stmt;
2755 stmt = last_stmt (bb);
2757 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2759 edge true_edge, false_edge;
2761 /* When we are emitting the code or changing CFG, it is possible that
2762 the edges are not yet created. When we are using debug_bb in such
2763 a situation, we do not want it to crash. */
2764 if (EDGE_COUNT (bb->succs) != 2)
2765 return;
2766 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2768 INDENT (indent + 2);
2769 pp_cfg_jump (buffer, true_edge, flags);
2770 newline_and_indent (buffer, indent);
2771 pp_string (buffer, "else");
2772 newline_and_indent (buffer, indent + 2);
2773 pp_cfg_jump (buffer, false_edge, flags);
2774 pp_newline (buffer);
2775 return;
2778 /* If there is a fallthru edge, we may need to add an artificial
2779 goto to the dump. */
2780 e = find_fallthru_edge (bb->succs);
2782 if (e && e->dest != bb->next_bb)
2784 INDENT (indent);
2786 if ((flags & TDF_LINENO)
2787 && e->goto_locus != UNKNOWN_LOCATION)
2788 dump_location (buffer, e->goto_locus);
2790 pp_cfg_jump (buffer, e, flags);
2791 pp_newline (buffer);
2796 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2797 indented by INDENT spaces. */
2799 static void
2800 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2801 dump_flags_t flags)
2803 gimple_stmt_iterator gsi;
2804 gimple *stmt;
2805 int label_indent = indent - 2;
2807 if (label_indent < 0)
2808 label_indent = 0;
2810 dump_phi_nodes (buffer, bb, indent, flags);
2812 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2814 int curr_indent;
2816 stmt = gsi_stmt (gsi);
2818 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2820 INDENT (curr_indent);
2821 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2822 pp_newline_and_flush (buffer);
2823 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2824 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2825 pp_buffer (buffer)->stream, stmt);
2828 dump_implicit_edges (buffer, bb, indent, flags);
2829 pp_flush (buffer);
2833 /* Dumps basic block BB to FILE with details described by FLAGS and
2834 indented by INDENT spaces. */
2836 void
2837 gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
2839 dump_gimple_bb_header (file, bb, indent, flags);
2840 if (bb->index >= NUM_FIXED_BLOCKS)
2842 pretty_printer buffer;
2843 pp_needs_newline (&buffer) = true;
2844 buffer.buffer->stream = file;
2845 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2847 dump_gimple_bb_footer (file, bb, indent, flags);
2850 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2851 no indentation, for use as a label of a DOT graph record-node.
2852 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2853 histogram dumping doesn't know about pretty-printers. */
2855 void
2856 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2858 pp_printf (pp, "<bb %d>:\n", bb->index);
2859 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2861 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2862 gsi_next (&gsi))
2864 gphi *phi = gsi.phi ();
2865 if (!virtual_operand_p (gimple_phi_result (phi))
2866 || (dump_flags & TDF_VOPS))
2868 pp_bar (pp);
2869 pp_write_text_to_stream (pp);
2870 pp_string (pp, "# ");
2871 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2872 pp_newline (pp);
2873 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2877 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2878 gsi_next (&gsi))
2880 gimple *stmt = gsi_stmt (gsi);
2881 pp_bar (pp);
2882 pp_write_text_to_stream (pp);
2883 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2884 pp_newline (pp);
2885 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2887 dump_implicit_edges (pp, bb, 0, dump_flags);
2888 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2892 /* Handle the %G format for TEXT. Same as %K in handle_K_format in
2893 tree-pretty-print.c but with a Gimple call statement as an argument. */
2895 void
2896 percent_G_format (text_info *text)
2898 gcall *stmt = va_arg (*text->args_ptr, gcall*);
2900 /* Build a call expression from the Gimple call statement and
2901 pass it to the K formatter that knows how to format it. */
2902 tree exp = build_vl_exp (CALL_EXPR, gimple_call_num_args (stmt) + 3);
2903 CALL_EXPR_FN (exp) = gimple_call_fn (stmt);
2904 TREE_TYPE (exp) = gimple_call_return_type (stmt);
2905 CALL_EXPR_STATIC_CHAIN (exp) = gimple_call_chain (stmt);
2906 SET_EXPR_LOCATION (exp, gimple_location (stmt));
2908 percent_K_format (text, exp);