libgo: add misc/cgo files
[official-gcc.git] / gcc / gimple-pretty-print.c
blob447921be036f3190a36e6de26540b42bdf2b9d48
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 "asan.h"
43 #define INDENT(SPACE) \
44 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
46 #define GIMPLE_NIY do_niy (buffer,gs)
48 /* Try to print on BUFFER a default message for the unrecognized
49 gimple statement GS. */
51 static void
52 do_niy (pretty_printer *buffer, gimple *gs)
54 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
55 gimple_code_name[(int) gimple_code (gs)]);
59 /* Emit a newline and SPC indentation spaces to BUFFER. */
61 static void
62 newline_and_indent (pretty_printer *buffer, int spc)
64 pp_newline (buffer);
65 INDENT (spc);
69 /* Print the GIMPLE statement GS on stderr. */
71 DEBUG_FUNCTION void
72 debug_gimple_stmt (gimple *gs)
74 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
78 /* Return formatted string of a VALUE probability
79 (biased by REG_BR_PROB_BASE). Returned string is allocated
80 by xstrdup_for_dump. */
82 static const char *
83 dump_probability (int frequency, profile_count &count)
85 float minimum = 0.01f;
87 gcc_assert (0 <= frequency && frequency <= REG_BR_PROB_BASE);
88 float fvalue = frequency * 100.0f / REG_BR_PROB_BASE;
89 if (fvalue < minimum && frequency > 0)
90 return "[0.01%]";
92 char *buf;
93 if (count.initialized_p ())
94 asprintf (&buf, "[%.2f%%] [count: %" PRId64 "]", fvalue,
95 count.to_gcov_type ());
96 else
97 asprintf (&buf, "[%.2f%%] [count: INV]", fvalue);
99 const char *ret = xstrdup_for_dump (buf);
100 free (buf);
102 return ret;
105 /* Dump E probability to BUFFER. */
107 static void
108 dump_edge_probability (pretty_printer *buffer, edge e)
110 pp_scalar (buffer, " %s", dump_probability (e->probability, e->count));
113 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
114 FLAGS as in pp_gimple_stmt_1. */
116 void
117 print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
119 pretty_printer buffer;
120 pp_needs_newline (&buffer) = true;
121 buffer.buffer->stream = file;
122 pp_gimple_stmt_1 (&buffer, g, spc, flags);
123 pp_newline_and_flush (&buffer);
126 DEBUG_FUNCTION void
127 debug (gimple &ref)
129 print_gimple_stmt (stderr, &ref, 0, 0);
132 DEBUG_FUNCTION void
133 debug (gimple *ptr)
135 if (ptr)
136 debug (*ptr);
137 else
138 fprintf (stderr, "<nil>\n");
142 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
143 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
144 of the statement. */
146 void
147 print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
149 flags |= TDF_RHS_ONLY;
150 pretty_printer buffer;
151 pp_needs_newline (&buffer) = true;
152 buffer.buffer->stream = file;
153 pp_gimple_stmt_1 (&buffer, g, spc, flags);
154 pp_flush (&buffer);
158 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
159 spaces and FLAGS as in pp_gimple_stmt_1.
160 The caller is responsible for calling pp_flush on BUFFER to finalize
161 the pretty printer. */
163 static void
164 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc,
165 dump_flags_t flags)
167 gimple_stmt_iterator i;
169 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
171 gimple *gs = gsi_stmt (i);
172 INDENT (spc);
173 pp_gimple_stmt_1 (buffer, gs, spc, flags);
174 if (!gsi_one_before_end_p (i))
175 pp_newline (buffer);
180 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
181 FLAGS as in pp_gimple_stmt_1. */
183 void
184 print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
186 pretty_printer buffer;
187 pp_needs_newline (&buffer) = true;
188 buffer.buffer->stream = file;
189 dump_gimple_seq (&buffer, seq, spc, flags);
190 pp_newline_and_flush (&buffer);
194 /* Print the GIMPLE sequence SEQ on stderr. */
196 DEBUG_FUNCTION void
197 debug_gimple_seq (gimple_seq seq)
199 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
203 /* A simple helper to pretty-print some of the gimple tuples in the printf
204 style. The format modifiers are preceded by '%' and are:
205 'G' - outputs a string corresponding to the code of the given gimple,
206 'S' - outputs a gimple_seq with indent of spc + 2,
207 'T' - outputs the tree t,
208 'd' - outputs an int as a decimal,
209 's' - outputs a string,
210 'n' - outputs a newline,
211 'x' - outputs an int as hexadecimal,
212 '+' - increases indent by 2 then outputs a newline,
213 '-' - decreases indent by 2 then outputs a newline. */
215 static void
216 dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags,
217 const char *fmt, ...)
219 va_list args;
220 const char *c;
221 const char *tmp;
223 va_start (args, fmt);
224 for (c = fmt; *c; c++)
226 if (*c == '%')
228 gimple_seq seq;
229 tree t;
230 gimple *g;
231 switch (*++c)
233 case 'G':
234 g = va_arg (args, gimple *);
235 tmp = gimple_code_name[gimple_code (g)];
236 pp_string (buffer, tmp);
237 break;
239 case 'S':
240 seq = va_arg (args, gimple_seq);
241 pp_newline (buffer);
242 dump_gimple_seq (buffer, seq, spc + 2, flags);
243 newline_and_indent (buffer, spc);
244 break;
246 case 'T':
247 t = va_arg (args, tree);
248 if (t == NULL_TREE)
249 pp_string (buffer, "NULL");
250 else
251 dump_generic_node (buffer, t, spc, flags, false);
252 break;
254 case 'd':
255 pp_decimal_int (buffer, va_arg (args, int));
256 break;
258 case 's':
259 pp_string (buffer, va_arg (args, char *));
260 break;
262 case 'n':
263 newline_and_indent (buffer, spc);
264 break;
266 case 'x':
267 pp_scalar (buffer, "%x", va_arg (args, int));
268 break;
270 case '+':
271 spc += 2;
272 newline_and_indent (buffer, spc);
273 break;
275 case '-':
276 spc -= 2;
277 newline_and_indent (buffer, spc);
278 break;
280 default:
281 gcc_unreachable ();
284 else
285 pp_character (buffer, *c);
287 va_end (args);
291 /* Helper for dump_gimple_assign. Print the unary RHS of the
292 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
294 static void
295 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc,
296 dump_flags_t flags)
298 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
299 tree lhs = gimple_assign_lhs (gs);
300 tree rhs = gimple_assign_rhs1 (gs);
302 switch (rhs_code)
304 case VIEW_CONVERT_EXPR:
305 case ASSERT_EXPR:
306 dump_generic_node (buffer, rhs, spc, flags, false);
307 break;
309 case FIXED_CONVERT_EXPR:
310 case ADDR_SPACE_CONVERT_EXPR:
311 case FIX_TRUNC_EXPR:
312 case FLOAT_EXPR:
313 CASE_CONVERT:
314 pp_left_paren (buffer);
315 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
316 pp_string (buffer, ") ");
317 if (op_prio (rhs) < op_code_prio (rhs_code))
319 pp_left_paren (buffer);
320 dump_generic_node (buffer, rhs, spc, flags, false);
321 pp_right_paren (buffer);
323 else
324 dump_generic_node (buffer, rhs, spc, flags, false);
325 break;
327 case PAREN_EXPR:
328 pp_string (buffer, "((");
329 dump_generic_node (buffer, rhs, spc, flags, false);
330 pp_string (buffer, "))");
331 break;
333 case ABS_EXPR:
334 if (flags & TDF_GIMPLE)
336 pp_string (buffer, "__ABS ");
337 dump_generic_node (buffer, rhs, spc, flags, false);
339 else
341 pp_string (buffer, "ABS_EXPR <");
342 dump_generic_node (buffer, rhs, spc, flags, false);
343 pp_greater (buffer);
345 break;
347 default:
348 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
349 || TREE_CODE_CLASS (rhs_code) == tcc_constant
350 || TREE_CODE_CLASS (rhs_code) == tcc_reference
351 || rhs_code == SSA_NAME
352 || rhs_code == ADDR_EXPR
353 || rhs_code == CONSTRUCTOR)
355 dump_generic_node (buffer, rhs, spc, flags, false);
356 break;
358 else if (rhs_code == BIT_NOT_EXPR)
359 pp_complement (buffer);
360 else if (rhs_code == TRUTH_NOT_EXPR)
361 pp_exclamation (buffer);
362 else if (rhs_code == NEGATE_EXPR)
363 pp_minus (buffer);
364 else
366 pp_left_bracket (buffer);
367 pp_string (buffer, get_tree_code_name (rhs_code));
368 pp_string (buffer, "] ");
371 if (op_prio (rhs) < op_code_prio (rhs_code))
373 pp_left_paren (buffer);
374 dump_generic_node (buffer, rhs, spc, flags, false);
375 pp_right_paren (buffer);
377 else
378 dump_generic_node (buffer, rhs, spc, flags, false);
379 break;
384 /* Helper for dump_gimple_assign. Print the binary RHS of the
385 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
387 static void
388 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc,
389 dump_flags_t flags)
391 const char *p;
392 enum tree_code code = gimple_assign_rhs_code (gs);
393 switch (code)
395 case COMPLEX_EXPR:
396 case MIN_EXPR:
397 case MAX_EXPR:
398 case VEC_WIDEN_MULT_HI_EXPR:
399 case VEC_WIDEN_MULT_LO_EXPR:
400 case VEC_WIDEN_MULT_EVEN_EXPR:
401 case VEC_WIDEN_MULT_ODD_EXPR:
402 case VEC_PACK_TRUNC_EXPR:
403 case VEC_PACK_SAT_EXPR:
404 case VEC_PACK_FIX_TRUNC_EXPR:
405 case VEC_WIDEN_LSHIFT_HI_EXPR:
406 case VEC_WIDEN_LSHIFT_LO_EXPR:
407 for (p = get_tree_code_name (code); *p; p++)
408 pp_character (buffer, TOUPPER (*p));
409 pp_string (buffer, " <");
410 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
411 pp_string (buffer, ", ");
412 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
413 pp_greater (buffer);
414 break;
416 default:
417 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
419 pp_left_paren (buffer);
420 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
421 false);
422 pp_right_paren (buffer);
424 else
425 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
426 pp_space (buffer);
427 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
428 pp_space (buffer);
429 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
431 pp_left_paren (buffer);
432 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
433 false);
434 pp_right_paren (buffer);
436 else
437 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
441 /* Helper for dump_gimple_assign. Print the ternary RHS of the
442 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
444 static void
445 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc,
446 dump_flags_t flags)
448 const char *p;
449 enum tree_code code = gimple_assign_rhs_code (gs);
450 switch (code)
452 case WIDEN_MULT_PLUS_EXPR:
453 case WIDEN_MULT_MINUS_EXPR:
454 for (p = get_tree_code_name (code); *p; p++)
455 pp_character (buffer, TOUPPER (*p));
456 pp_string (buffer, " <");
457 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
458 pp_string (buffer, ", ");
459 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
460 pp_string (buffer, ", ");
461 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
462 pp_greater (buffer);
463 break;
465 case FMA_EXPR:
466 if (flags & TDF_GIMPLE)
468 pp_string (buffer, "__FMA (");
469 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
470 pp_comma (buffer);
471 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
472 pp_comma (buffer);
473 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
474 pp_right_paren (buffer);
476 else
478 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
479 pp_string (buffer, " * ");
480 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
481 pp_string (buffer, " + ");
482 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
484 break;
486 case DOT_PROD_EXPR:
487 pp_string (buffer, "DOT_PROD_EXPR <");
488 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
489 pp_string (buffer, ", ");
490 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
491 pp_string (buffer, ", ");
492 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
493 pp_greater (buffer);
494 break;
496 case SAD_EXPR:
497 pp_string (buffer, "SAD_EXPR <");
498 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
499 pp_string (buffer, ", ");
500 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
501 pp_string (buffer, ", ");
502 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
503 pp_greater (buffer);
504 break;
506 case VEC_PERM_EXPR:
507 pp_string (buffer, "VEC_PERM_EXPR <");
508 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
509 pp_string (buffer, ", ");
510 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
511 pp_string (buffer, ", ");
512 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
513 pp_greater (buffer);
514 break;
516 case REALIGN_LOAD_EXPR:
517 pp_string (buffer, "REALIGN_LOAD <");
518 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
519 pp_string (buffer, ", ");
520 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
521 pp_string (buffer, ", ");
522 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
523 pp_greater (buffer);
524 break;
526 case COND_EXPR:
527 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
528 pp_string (buffer, " ? ");
529 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
530 pp_string (buffer, " : ");
531 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
532 break;
534 case VEC_COND_EXPR:
535 pp_string (buffer, "VEC_COND_EXPR <");
536 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
537 pp_string (buffer, ", ");
538 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
539 pp_string (buffer, ", ");
540 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
541 pp_greater (buffer);
542 break;
544 case BIT_INSERT_EXPR:
545 pp_string (buffer, "BIT_INSERT_EXPR <");
546 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
547 pp_string (buffer, ", ");
548 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
549 pp_string (buffer, ", ");
550 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
551 pp_string (buffer, " (");
552 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
553 pp_decimal_int (buffer,
554 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
555 else
556 dump_generic_node (buffer,
557 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
558 spc, flags, false);
559 pp_string (buffer, " bits)>");
560 break;
562 default:
563 gcc_unreachable ();
568 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
569 pp_gimple_stmt_1. */
571 static void
572 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc,
573 dump_flags_t flags)
575 if (flags & TDF_RAW)
577 tree arg1 = NULL;
578 tree arg2 = NULL;
579 tree arg3 = NULL;
580 switch (gimple_num_ops (gs))
582 case 4:
583 arg3 = gimple_assign_rhs3 (gs);
584 /* FALLTHRU */
585 case 3:
586 arg2 = gimple_assign_rhs2 (gs);
587 /* FALLTHRU */
588 case 2:
589 arg1 = gimple_assign_rhs1 (gs);
590 break;
591 default:
592 gcc_unreachable ();
595 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
596 get_tree_code_name (gimple_assign_rhs_code (gs)),
597 gimple_assign_lhs (gs), arg1, arg2, arg3);
599 else
601 if (!(flags & TDF_RHS_ONLY))
603 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
604 pp_space (buffer);
605 pp_equal (buffer);
607 if (gimple_assign_nontemporal_move_p (gs))
608 pp_string (buffer, "{nt}");
610 if (gimple_has_volatile_ops (gs))
611 pp_string (buffer, "{v}");
613 pp_space (buffer);
616 if (gimple_num_ops (gs) == 2)
617 dump_unary_rhs (buffer, gs, spc, flags);
618 else if (gimple_num_ops (gs) == 3)
619 dump_binary_rhs (buffer, gs, spc, flags);
620 else if (gimple_num_ops (gs) == 4)
621 dump_ternary_rhs (buffer, gs, spc, flags);
622 else
623 gcc_unreachable ();
624 if (!(flags & TDF_RHS_ONLY))
625 pp_semicolon (buffer);
630 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
631 pp_gimple_stmt_1. */
633 static void
634 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc,
635 dump_flags_t flags)
637 tree t, t2;
639 t = gimple_return_retval (gs);
640 t2 = gimple_return_retbnd (gs);
641 if (flags & TDF_RAW)
642 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
643 else
645 pp_string (buffer, "return");
646 if (t)
648 pp_space (buffer);
649 dump_generic_node (buffer, t, spc, flags, false);
651 if (t2)
653 pp_string (buffer, ", ");
654 dump_generic_node (buffer, t2, spc, flags, false);
656 pp_semicolon (buffer);
661 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
662 dump_gimple_call. */
664 static void
665 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, dump_flags_t flags)
667 size_t i = 0;
669 /* Pretty print first arg to certain internal fns. */
670 if (gimple_call_internal_p (gs))
672 const char *const *enums = NULL;
673 unsigned limit = 0;
675 switch (gimple_call_internal_fn (gs))
677 case IFN_UNIQUE:
678 #define DEF(X) #X
679 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
680 #undef DEF
681 enums = unique_args;
683 limit = ARRAY_SIZE (unique_args);
684 break;
686 case IFN_GOACC_LOOP:
687 #define DEF(X) #X
688 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
689 #undef DEF
690 enums = loop_args;
691 limit = ARRAY_SIZE (loop_args);
692 break;
694 case IFN_GOACC_REDUCTION:
695 #define DEF(X) #X
696 static const char *const reduction_args[]
697 = {IFN_GOACC_REDUCTION_CODES};
698 #undef DEF
699 enums = reduction_args;
700 limit = ARRAY_SIZE (reduction_args);
701 break;
703 case IFN_ASAN_MARK:
704 #define DEF(X) #X
705 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
706 #undef DEF
707 enums = asan_mark_args;
708 limit = ARRAY_SIZE (asan_mark_args);
709 break;
711 default:
712 break;
714 if (limit)
716 tree arg0 = gimple_call_arg (gs, 0);
717 HOST_WIDE_INT v;
719 if (TREE_CODE (arg0) == INTEGER_CST
720 && tree_fits_shwi_p (arg0)
721 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
723 i++;
724 pp_string (buffer, enums[v]);
729 for (; i < gimple_call_num_args (gs); i++)
731 if (i)
732 pp_string (buffer, ", ");
733 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
736 if (gimple_call_va_arg_pack_p (gs))
738 if (i)
739 pp_string (buffer, ", ");
741 pp_string (buffer, "__builtin_va_arg_pack ()");
745 /* Dump the points-to solution *PT to BUFFER. */
747 static void
748 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
750 if (pt->anything)
752 pp_string (buffer, "anything ");
753 return;
755 if (pt->nonlocal)
756 pp_string (buffer, "nonlocal ");
757 if (pt->escaped)
758 pp_string (buffer, "escaped ");
759 if (pt->ipa_escaped)
760 pp_string (buffer, "unit-escaped ");
761 if (pt->null)
762 pp_string (buffer, "null ");
763 if (pt->vars
764 && !bitmap_empty_p (pt->vars))
766 bitmap_iterator bi;
767 unsigned i;
768 pp_string (buffer, "{ ");
769 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
771 pp_string (buffer, "D.");
772 pp_decimal_int (buffer, i);
773 pp_space (buffer);
775 pp_right_brace (buffer);
776 if (pt->vars_contains_nonlocal
777 || pt->vars_contains_escaped
778 || pt->vars_contains_escaped_heap
779 || pt->vars_contains_restrict)
781 const char *comma = "";
782 pp_string (buffer, " (");
783 if (pt->vars_contains_nonlocal)
785 pp_string (buffer, "nonlocal");
786 comma = ", ";
788 if (pt->vars_contains_escaped)
790 pp_string (buffer, comma);
791 pp_string (buffer, "escaped");
792 comma = ", ";
794 if (pt->vars_contains_escaped_heap)
796 pp_string (buffer, comma);
797 pp_string (buffer, "escaped heap");
798 comma = ", ";
800 if (pt->vars_contains_restrict)
802 pp_string (buffer, comma);
803 pp_string (buffer, "restrict");
804 comma = ", ";
806 if (pt->vars_contains_interposable)
808 pp_string (buffer, comma);
809 pp_string (buffer, "interposable");
811 pp_string (buffer, ")");
817 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
818 pp_gimple_stmt_1. */
820 static void
821 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
822 dump_flags_t flags)
824 tree lhs = gimple_call_lhs (gs);
825 tree fn = gimple_call_fn (gs);
827 if (flags & TDF_ALIAS)
829 struct pt_solution *pt;
830 pt = gimple_call_use_set (gs);
831 if (!pt_solution_empty_p (pt))
833 pp_string (buffer, "# USE = ");
834 pp_points_to_solution (buffer, pt);
835 newline_and_indent (buffer, spc);
837 pt = gimple_call_clobber_set (gs);
838 if (!pt_solution_empty_p (pt))
840 pp_string (buffer, "# CLB = ");
841 pp_points_to_solution (buffer, pt);
842 newline_and_indent (buffer, spc);
846 if (flags & TDF_RAW)
848 if (gimple_call_internal_p (gs))
849 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
850 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
851 else
852 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
853 if (gimple_call_num_args (gs) > 0)
855 pp_string (buffer, ", ");
856 dump_gimple_call_args (buffer, gs, flags);
858 pp_greater (buffer);
860 else
862 if (lhs && !(flags & TDF_RHS_ONLY))
864 dump_generic_node (buffer, lhs, spc, flags, false);
865 pp_string (buffer, " =");
867 if (gimple_has_volatile_ops (gs))
868 pp_string (buffer, "{v}");
870 pp_space (buffer);
872 if (gimple_call_internal_p (gs))
873 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
874 else
875 print_call_name (buffer, fn, flags);
876 pp_string (buffer, " (");
877 dump_gimple_call_args (buffer, gs, flags);
878 pp_right_paren (buffer);
879 if (!(flags & TDF_RHS_ONLY))
880 pp_semicolon (buffer);
883 if (gimple_call_chain (gs))
885 pp_string (buffer, " [static-chain: ");
886 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
887 pp_right_bracket (buffer);
890 if (gimple_call_return_slot_opt_p (gs))
891 pp_string (buffer, " [return slot optimization]");
892 if (gimple_call_tail_p (gs))
893 pp_string (buffer, " [tail call]");
894 if (gimple_call_must_tail_p (gs))
895 pp_string (buffer, " [must tail call]");
897 if (fn == NULL)
898 return;
900 /* Dump the arguments of _ITM_beginTransaction sanely. */
901 if (TREE_CODE (fn) == ADDR_EXPR)
902 fn = TREE_OPERAND (fn, 0);
903 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
904 pp_string (buffer, " [tm-clone]");
905 if (TREE_CODE (fn) == FUNCTION_DECL
906 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
907 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
908 && gimple_call_num_args (gs) > 0)
910 tree t = gimple_call_arg (gs, 0);
911 unsigned HOST_WIDE_INT props;
912 gcc_assert (TREE_CODE (t) == INTEGER_CST);
914 pp_string (buffer, " [ ");
916 /* Get the transaction code properties. */
917 props = TREE_INT_CST_LOW (t);
919 if (props & PR_INSTRUMENTEDCODE)
920 pp_string (buffer, "instrumentedCode ");
921 if (props & PR_UNINSTRUMENTEDCODE)
922 pp_string (buffer, "uninstrumentedCode ");
923 if (props & PR_HASNOXMMUPDATE)
924 pp_string (buffer, "hasNoXMMUpdate ");
925 if (props & PR_HASNOABORT)
926 pp_string (buffer, "hasNoAbort ");
927 if (props & PR_HASNOIRREVOCABLE)
928 pp_string (buffer, "hasNoIrrevocable ");
929 if (props & PR_DOESGOIRREVOCABLE)
930 pp_string (buffer, "doesGoIrrevocable ");
931 if (props & PR_HASNOSIMPLEREADS)
932 pp_string (buffer, "hasNoSimpleReads ");
933 if (props & PR_AWBARRIERSOMITTED)
934 pp_string (buffer, "awBarriersOmitted ");
935 if (props & PR_RARBARRIERSOMITTED)
936 pp_string (buffer, "RaRBarriersOmitted ");
937 if (props & PR_UNDOLOGCODE)
938 pp_string (buffer, "undoLogCode ");
939 if (props & PR_PREFERUNINSTRUMENTED)
940 pp_string (buffer, "preferUninstrumented ");
941 if (props & PR_EXCEPTIONBLOCK)
942 pp_string (buffer, "exceptionBlock ");
943 if (props & PR_HASELSE)
944 pp_string (buffer, "hasElse ");
945 if (props & PR_READONLY)
946 pp_string (buffer, "readOnly ");
948 pp_right_bracket (buffer);
953 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
954 pp_gimple_stmt_1. */
956 static void
957 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
958 dump_flags_t flags)
960 unsigned int i;
962 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
963 if (flags & TDF_RAW)
964 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
965 gimple_switch_index (gs));
966 else
968 pp_string (buffer, "switch (");
969 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
970 if (flags & TDF_GIMPLE)
971 pp_string (buffer, ") {");
972 else
973 pp_string (buffer, ") <");
976 for (i = 0; i < gimple_switch_num_labels (gs); i++)
978 tree case_label = gimple_switch_label (gs, i);
979 gcc_checking_assert (case_label != NULL_TREE);
980 dump_generic_node (buffer, case_label, spc, flags, false);
981 pp_space (buffer);
982 tree label = CASE_LABEL (case_label);
983 dump_generic_node (buffer, label, spc, flags, false);
985 if (cfun && cfun->cfg)
987 basic_block dest = label_to_block (label);
988 if (dest)
990 edge label_edge = find_edge (gimple_bb (gs), dest);
991 if (label_edge && !(flags & TDF_GIMPLE))
992 dump_edge_probability (buffer, label_edge);
996 if (i < gimple_switch_num_labels (gs) - 1)
998 if (flags & TDF_GIMPLE)
999 pp_string (buffer, "; ");
1000 else
1001 pp_string (buffer, ", ");
1004 if (flags & TDF_GIMPLE)
1005 pp_string (buffer, "; }");
1006 else
1007 pp_greater (buffer);
1011 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1012 pp_gimple_stmt_1. */
1014 static void
1015 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc,
1016 dump_flags_t flags)
1018 if (flags & TDF_RAW)
1019 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1020 get_tree_code_name (gimple_cond_code (gs)),
1021 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1022 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1023 else
1025 if (!(flags & TDF_RHS_ONLY))
1026 pp_string (buffer, "if (");
1027 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
1028 pp_space (buffer);
1029 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1030 pp_space (buffer);
1031 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
1032 if (!(flags & TDF_RHS_ONLY))
1034 edge_iterator ei;
1035 edge e, true_edge = NULL, false_edge = NULL;
1036 basic_block bb = gimple_bb (gs);
1038 if (bb)
1040 FOR_EACH_EDGE (e, ei, bb->succs)
1042 if (e->flags & EDGE_TRUE_VALUE)
1043 true_edge = e;
1044 else if (e->flags & EDGE_FALSE_VALUE)
1045 false_edge = e;
1049 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1051 pp_right_paren (buffer);
1053 if (gimple_cond_true_label (gs))
1055 pp_string (buffer, " goto ");
1056 dump_generic_node (buffer, gimple_cond_true_label (gs),
1057 spc, flags, false);
1058 if (has_edge_info && !(flags & TDF_GIMPLE))
1059 dump_edge_probability (buffer, true_edge);
1060 pp_semicolon (buffer);
1062 if (gimple_cond_false_label (gs))
1064 pp_string (buffer, " else goto ");
1065 dump_generic_node (buffer, gimple_cond_false_label (gs),
1066 spc, flags, false);
1067 if (has_edge_info && !(flags & TDF_GIMPLE))
1068 dump_edge_probability (buffer, false_edge);
1070 pp_semicolon (buffer);
1077 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1078 spaces of indent. FLAGS specifies details to show in the dump (see
1079 TDF_* in dumpfils.h). */
1081 static void
1082 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
1083 dump_flags_t flags)
1085 tree label = gimple_label_label (gs);
1086 if (flags & TDF_RAW)
1087 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1088 else
1090 dump_generic_node (buffer, label, spc, flags, false);
1091 basic_block bb = gimple_bb (gs);
1092 if (bb && !(flags & TDF_GIMPLE))
1093 pp_scalar (buffer, " %s", dump_probability (bb->frequency, bb->count));
1094 pp_colon (buffer);
1096 if (flags & TDF_GIMPLE)
1097 return;
1098 if (DECL_NONLOCAL (label))
1099 pp_string (buffer, " [non-local]");
1100 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1101 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1104 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1105 spaces of indent. FLAGS specifies details to show in the dump (see
1106 TDF_* in dumpfile.h). */
1108 static void
1109 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc,
1110 dump_flags_t flags)
1112 tree label = gimple_goto_dest (gs);
1113 if (flags & TDF_RAW)
1114 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1115 else
1116 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1120 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1121 spaces of indent. FLAGS specifies details to show in the dump (see
1122 TDF_* in dumpfile.h). */
1124 static void
1125 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc,
1126 dump_flags_t flags)
1128 if (flags & TDF_RAW)
1129 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1130 else
1131 pp_left_brace (buffer);
1132 if (!(flags & TDF_SLIM))
1134 tree var;
1136 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1138 newline_and_indent (buffer, 2);
1139 print_declaration (buffer, var, spc, flags);
1141 if (gimple_bind_vars (gs))
1142 pp_newline (buffer);
1144 pp_newline (buffer);
1145 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1146 newline_and_indent (buffer, spc);
1147 if (flags & TDF_RAW)
1148 pp_greater (buffer);
1149 else
1150 pp_right_brace (buffer);
1154 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1155 indent. FLAGS specifies details to show in the dump (see TDF_* in
1156 dumpfile.h). */
1158 static void
1159 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc,
1160 dump_flags_t flags)
1162 if (flags & TDF_RAW)
1164 const char *type;
1165 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1166 type = "GIMPLE_TRY_CATCH";
1167 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1168 type = "GIMPLE_TRY_FINALLY";
1169 else
1170 type = "UNKNOWN GIMPLE_TRY";
1171 dump_gimple_fmt (buffer, spc, flags,
1172 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1173 gimple_try_eval (gs), gimple_try_cleanup (gs));
1175 else
1177 pp_string (buffer, "try");
1178 newline_and_indent (buffer, spc + 2);
1179 pp_left_brace (buffer);
1180 pp_newline (buffer);
1182 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1183 newline_and_indent (buffer, spc + 2);
1184 pp_right_brace (buffer);
1186 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1188 newline_and_indent (buffer, spc);
1189 pp_string (buffer, "catch");
1190 newline_and_indent (buffer, spc + 2);
1191 pp_left_brace (buffer);
1193 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1195 newline_and_indent (buffer, spc);
1196 pp_string (buffer, "finally");
1197 newline_and_indent (buffer, spc + 2);
1198 pp_left_brace (buffer);
1200 else
1201 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1203 pp_newline (buffer);
1204 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1205 newline_and_indent (buffer, spc + 2);
1206 pp_right_brace (buffer);
1211 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1212 indent. FLAGS specifies details to show in the dump (see TDF_* in
1213 dumpfile.h). */
1215 static void
1216 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc,
1217 dump_flags_t flags)
1219 if (flags & TDF_RAW)
1220 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1221 gimple_catch_types (gs), gimple_catch_handler (gs));
1222 else
1223 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1224 gimple_catch_types (gs), gimple_catch_handler (gs));
1228 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1229 indent. FLAGS specifies details to show in the dump (see TDF_* in
1230 dumpfile.h). */
1232 static void
1233 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1234 dump_flags_t flags)
1236 if (flags & TDF_RAW)
1237 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1238 gimple_eh_filter_types (gs),
1239 gimple_eh_filter_failure (gs));
1240 else
1241 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1242 gimple_eh_filter_types (gs),
1243 gimple_eh_filter_failure (gs));
1247 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1249 static void
1250 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1251 geh_mnt *gs, int spc, dump_flags_t flags)
1253 if (flags & TDF_RAW)
1254 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1255 gimple_eh_must_not_throw_fndecl (gs));
1256 else
1257 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1258 gimple_eh_must_not_throw_fndecl (gs));
1262 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1263 indent. FLAGS specifies details to show in the dump (see TDF_* in
1264 dumpfile.h). */
1266 static void
1267 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1268 dump_flags_t flags)
1270 if (flags & TDF_RAW)
1271 dump_gimple_fmt (buffer, spc, flags,
1272 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1273 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1274 else
1275 dump_gimple_fmt (buffer, spc, flags,
1276 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1277 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1281 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1282 indent. FLAGS specifies details to show in the dump (see TDF_* in
1283 dumpfile.h). */
1285 static void
1286 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc,
1287 dump_flags_t flags)
1289 if (flags & TDF_RAW)
1290 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1291 gimple_resx_region (gs));
1292 else
1293 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1296 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1298 static void
1299 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc,
1300 dump_flags_t flags)
1302 if (flags & TDF_RAW)
1303 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1304 gimple_eh_dispatch_region (gs));
1305 else
1306 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1307 gimple_eh_dispatch_region (gs));
1310 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1311 of indent. FLAGS specifies details to show in the dump (see TDF_*
1312 in dumpfile.h). */
1314 static void
1315 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc,
1316 dump_flags_t flags)
1318 switch (gs->subcode)
1320 case GIMPLE_DEBUG_BIND:
1321 if (flags & TDF_RAW)
1322 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1323 gimple_debug_bind_get_var (gs),
1324 gimple_debug_bind_get_value (gs));
1325 else
1326 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1327 gimple_debug_bind_get_var (gs),
1328 gimple_debug_bind_get_value (gs));
1329 break;
1331 case GIMPLE_DEBUG_SOURCE_BIND:
1332 if (flags & TDF_RAW)
1333 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1334 gimple_debug_source_bind_get_var (gs),
1335 gimple_debug_source_bind_get_value (gs));
1336 else
1337 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1338 gimple_debug_source_bind_get_var (gs),
1339 gimple_debug_source_bind_get_value (gs));
1340 break;
1342 default:
1343 gcc_unreachable ();
1347 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1348 static void
1349 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc,
1350 dump_flags_t flags)
1352 size_t i;
1354 if (flags & TDF_RAW)
1356 const char *kind;
1357 switch (gimple_omp_for_kind (gs))
1359 case GF_OMP_FOR_KIND_FOR:
1360 kind = "";
1361 break;
1362 case GF_OMP_FOR_KIND_DISTRIBUTE:
1363 kind = " distribute";
1364 break;
1365 case GF_OMP_FOR_KIND_TASKLOOP:
1366 kind = " taskloop";
1367 break;
1368 case GF_OMP_FOR_KIND_CILKFOR:
1369 kind = " _Cilk_for";
1370 break;
1371 case GF_OMP_FOR_KIND_OACC_LOOP:
1372 kind = " oacc_loop";
1373 break;
1374 case GF_OMP_FOR_KIND_SIMD:
1375 kind = " simd";
1376 break;
1377 case GF_OMP_FOR_KIND_CILKSIMD:
1378 kind = " cilksimd";
1379 break;
1380 default:
1381 gcc_unreachable ();
1383 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1384 kind, gimple_omp_body (gs));
1385 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1386 dump_gimple_fmt (buffer, spc, flags, " >,");
1387 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1388 dump_gimple_fmt (buffer, spc, flags,
1389 "%+%T, %T, %T, %s, %T,%n",
1390 gimple_omp_for_index (gs, i),
1391 gimple_omp_for_initial (gs, i),
1392 gimple_omp_for_final (gs, i),
1393 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1394 gimple_omp_for_incr (gs, i));
1395 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1396 gimple_omp_for_pre_body (gs));
1398 else
1400 switch (gimple_omp_for_kind (gs))
1402 case GF_OMP_FOR_KIND_FOR:
1403 pp_string (buffer, "#pragma omp for");
1404 break;
1405 case GF_OMP_FOR_KIND_DISTRIBUTE:
1406 pp_string (buffer, "#pragma omp distribute");
1407 break;
1408 case GF_OMP_FOR_KIND_TASKLOOP:
1409 pp_string (buffer, "#pragma omp taskloop");
1410 break;
1411 case GF_OMP_FOR_KIND_CILKFOR:
1412 break;
1413 case GF_OMP_FOR_KIND_OACC_LOOP:
1414 pp_string (buffer, "#pragma acc loop");
1415 break;
1416 case GF_OMP_FOR_KIND_SIMD:
1417 pp_string (buffer, "#pragma omp simd");
1418 break;
1419 case GF_OMP_FOR_KIND_CILKSIMD:
1420 pp_string (buffer, "#pragma simd");
1421 break;
1422 case GF_OMP_FOR_KIND_GRID_LOOP:
1423 pp_string (buffer, "#pragma omp for grid_loop");
1424 break;
1425 default:
1426 gcc_unreachable ();
1428 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1429 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1430 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1432 if (i)
1433 spc += 2;
1434 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1435 pp_string (buffer, "_Cilk_for (");
1436 else
1438 newline_and_indent (buffer, spc);
1439 pp_string (buffer, "for (");
1441 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1442 flags, false);
1443 pp_string (buffer, " = ");
1444 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1445 flags, false);
1446 pp_string (buffer, "; ");
1448 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1449 flags, false);
1450 pp_space (buffer);
1451 switch (gimple_omp_for_cond (gs, i))
1453 case LT_EXPR:
1454 pp_less (buffer);
1455 break;
1456 case GT_EXPR:
1457 pp_greater (buffer);
1458 break;
1459 case LE_EXPR:
1460 pp_less_equal (buffer);
1461 break;
1462 case GE_EXPR:
1463 pp_greater_equal (buffer);
1464 break;
1465 case NE_EXPR:
1466 pp_string (buffer, "!=");
1467 break;
1468 default:
1469 gcc_unreachable ();
1471 pp_space (buffer);
1472 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1473 flags, false);
1474 pp_string (buffer, "; ");
1476 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1477 flags, false);
1478 pp_string (buffer, " = ");
1479 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1480 flags, false);
1481 pp_right_paren (buffer);
1484 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1486 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1487 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1488 newline_and_indent (buffer, spc + 2);
1489 pp_left_brace (buffer);
1490 pp_newline (buffer);
1491 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1492 newline_and_indent (buffer, spc + 2);
1493 pp_right_brace (buffer);
1498 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1500 static void
1501 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1502 int spc, dump_flags_t flags)
1504 if (flags & TDF_RAW)
1506 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1507 gimple_omp_continue_control_def (gs),
1508 gimple_omp_continue_control_use (gs));
1510 else
1512 pp_string (buffer, "#pragma omp continue (");
1513 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1514 spc, flags, false);
1515 pp_comma (buffer);
1516 pp_space (buffer);
1517 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1518 spc, flags, false);
1519 pp_right_paren (buffer);
1523 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1525 static void
1526 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1527 int spc, dump_flags_t flags)
1529 if (flags & TDF_RAW)
1531 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1532 gimple_omp_body (gs));
1533 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1534 dump_gimple_fmt (buffer, spc, flags, " >");
1536 else
1538 pp_string (buffer, "#pragma omp single");
1539 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1540 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1542 newline_and_indent (buffer, spc + 2);
1543 pp_left_brace (buffer);
1544 pp_newline (buffer);
1545 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1546 newline_and_indent (buffer, spc + 2);
1547 pp_right_brace (buffer);
1552 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1554 static void
1555 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1556 int spc, dump_flags_t flags)
1558 const char *kind;
1559 switch (gimple_omp_target_kind (gs))
1561 case GF_OMP_TARGET_KIND_REGION:
1562 kind = "";
1563 break;
1564 case GF_OMP_TARGET_KIND_DATA:
1565 kind = " data";
1566 break;
1567 case GF_OMP_TARGET_KIND_UPDATE:
1568 kind = " update";
1569 break;
1570 case GF_OMP_TARGET_KIND_ENTER_DATA:
1571 kind = " enter data";
1572 break;
1573 case GF_OMP_TARGET_KIND_EXIT_DATA:
1574 kind = " exit data";
1575 break;
1576 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1577 kind = " oacc_kernels";
1578 break;
1579 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1580 kind = " oacc_parallel";
1581 break;
1582 case GF_OMP_TARGET_KIND_OACC_DATA:
1583 kind = " oacc_data";
1584 break;
1585 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1586 kind = " oacc_update";
1587 break;
1588 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1589 kind = " oacc_enter_exit_data";
1590 break;
1591 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1592 kind = " oacc_declare";
1593 break;
1594 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1595 kind = " oacc_host_data";
1596 break;
1597 default:
1598 gcc_unreachable ();
1600 if (flags & TDF_RAW)
1602 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1603 kind, gimple_omp_body (gs));
1604 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1605 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1606 gimple_omp_target_child_fn (gs),
1607 gimple_omp_target_data_arg (gs));
1609 else
1611 pp_string (buffer, "#pragma omp target");
1612 pp_string (buffer, kind);
1613 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1614 if (gimple_omp_target_child_fn (gs))
1616 pp_string (buffer, " [child fn: ");
1617 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1618 spc, flags, false);
1619 pp_string (buffer, " (");
1620 if (gimple_omp_target_data_arg (gs))
1621 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1622 spc, flags, false);
1623 else
1624 pp_string (buffer, "???");
1625 pp_string (buffer, ")]");
1627 gimple_seq body = gimple_omp_body (gs);
1628 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1630 newline_and_indent (buffer, spc + 2);
1631 pp_left_brace (buffer);
1632 pp_newline (buffer);
1633 dump_gimple_seq (buffer, body, spc + 4, flags);
1634 newline_and_indent (buffer, spc + 2);
1635 pp_right_brace (buffer);
1637 else if (body)
1639 pp_newline (buffer);
1640 dump_gimple_seq (buffer, body, spc + 2, flags);
1645 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1647 static void
1648 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1649 dump_flags_t flags)
1651 if (flags & TDF_RAW)
1653 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1654 gimple_omp_body (gs));
1655 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1656 dump_gimple_fmt (buffer, spc, flags, " >");
1658 else
1660 pp_string (buffer, "#pragma omp teams");
1661 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1662 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1664 newline_and_indent (buffer, spc + 2);
1665 pp_character (buffer, '{');
1666 pp_newline (buffer);
1667 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1668 newline_and_indent (buffer, spc + 2);
1669 pp_character (buffer, '}');
1674 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1676 static void
1677 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1678 int spc, dump_flags_t flags)
1680 if (flags & TDF_RAW)
1682 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1683 gimple_omp_body (gs));
1684 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1685 dump_gimple_fmt (buffer, spc, flags, " >");
1687 else
1689 pp_string (buffer, "#pragma omp sections");
1690 if (gimple_omp_sections_control (gs))
1692 pp_string (buffer, " <");
1693 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1694 flags, false);
1695 pp_greater (buffer);
1697 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1698 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1700 newline_and_indent (buffer, spc + 2);
1701 pp_left_brace (buffer);
1702 pp_newline (buffer);
1703 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1704 newline_and_indent (buffer, spc + 2);
1705 pp_right_brace (buffer);
1710 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1711 pretty_printer BUFFER. */
1713 static void
1714 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc,
1715 dump_flags_t flags)
1717 if (flags & TDF_RAW)
1718 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1719 gimple_omp_body (gs));
1720 else
1722 switch (gimple_code (gs))
1724 case GIMPLE_OMP_MASTER:
1725 pp_string (buffer, "#pragma omp master");
1726 break;
1727 case GIMPLE_OMP_TASKGROUP:
1728 pp_string (buffer, "#pragma omp taskgroup");
1729 break;
1730 case GIMPLE_OMP_SECTION:
1731 pp_string (buffer, "#pragma omp section");
1732 break;
1733 case GIMPLE_OMP_GRID_BODY:
1734 pp_string (buffer, "#pragma omp gridified body");
1735 break;
1736 default:
1737 gcc_unreachable ();
1739 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1741 newline_and_indent (buffer, spc + 2);
1742 pp_left_brace (buffer);
1743 pp_newline (buffer);
1744 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1745 newline_and_indent (buffer, spc + 2);
1746 pp_right_brace (buffer);
1751 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1753 static void
1754 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1755 int spc, dump_flags_t flags)
1757 if (flags & TDF_RAW)
1758 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1759 gimple_omp_body (gs));
1760 else
1762 pp_string (buffer, "#pragma omp critical");
1763 if (gimple_omp_critical_name (gs))
1765 pp_string (buffer, " (");
1766 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1767 flags, false);
1768 pp_right_paren (buffer);
1770 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1771 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1773 newline_and_indent (buffer, spc + 2);
1774 pp_left_brace (buffer);
1775 pp_newline (buffer);
1776 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1777 newline_and_indent (buffer, spc + 2);
1778 pp_right_brace (buffer);
1783 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1785 static void
1786 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1787 int spc, dump_flags_t flags)
1789 if (flags & TDF_RAW)
1790 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1791 gimple_omp_body (gs));
1792 else
1794 pp_string (buffer, "#pragma omp ordered");
1795 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1796 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1798 newline_and_indent (buffer, spc + 2);
1799 pp_left_brace (buffer);
1800 pp_newline (buffer);
1801 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1802 newline_and_indent (buffer, spc + 2);
1803 pp_right_brace (buffer);
1808 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1810 static void
1811 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc,
1812 dump_flags_t flags)
1814 if (flags & TDF_RAW)
1816 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1817 (int) gimple_omp_return_nowait_p (gs));
1818 if (gimple_omp_return_lhs (gs))
1819 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1820 gimple_omp_return_lhs (gs));
1821 else
1822 dump_gimple_fmt (buffer, spc, flags, ">");
1824 else
1826 pp_string (buffer, "#pragma omp return");
1827 if (gimple_omp_return_nowait_p (gs))
1828 pp_string (buffer, "(nowait)");
1829 if (gimple_omp_return_lhs (gs))
1831 pp_string (buffer, " (set ");
1832 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1833 spc, flags, false);
1834 pp_character (buffer, ')');
1839 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1841 static void
1842 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1843 int spc, dump_flags_t flags)
1845 unsigned subcode = gimple_transaction_subcode (gs);
1847 if (flags & TDF_RAW)
1849 dump_gimple_fmt (buffer, spc, flags,
1850 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1851 "<%+BODY <%S> >",
1852 gs, subcode, gimple_transaction_label_norm (gs),
1853 gimple_transaction_label_uninst (gs),
1854 gimple_transaction_label_over (gs),
1855 gimple_transaction_body (gs));
1857 else
1859 if (subcode & GTMA_IS_OUTER)
1860 pp_string (buffer, "__transaction_atomic [[outer]]");
1861 else if (subcode & GTMA_IS_RELAXED)
1862 pp_string (buffer, "__transaction_relaxed");
1863 else
1864 pp_string (buffer, "__transaction_atomic");
1865 subcode &= ~GTMA_DECLARATION_MASK;
1867 if (gimple_transaction_body (gs))
1869 newline_and_indent (buffer, spc + 2);
1870 pp_left_brace (buffer);
1871 pp_newline (buffer);
1872 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1873 spc + 4, flags);
1874 newline_and_indent (buffer, spc + 2);
1875 pp_right_brace (buffer);
1877 else
1879 pp_string (buffer, " //");
1880 if (gimple_transaction_label_norm (gs))
1882 pp_string (buffer, " NORM=");
1883 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1884 spc, flags, false);
1886 if (gimple_transaction_label_uninst (gs))
1888 pp_string (buffer, " UNINST=");
1889 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1890 spc, flags, false);
1892 if (gimple_transaction_label_over (gs))
1894 pp_string (buffer, " OVER=");
1895 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1896 spc, flags, false);
1898 if (subcode)
1900 pp_string (buffer, " SUBCODE=[ ");
1901 if (subcode & GTMA_HAVE_ABORT)
1903 pp_string (buffer, "GTMA_HAVE_ABORT ");
1904 subcode &= ~GTMA_HAVE_ABORT;
1906 if (subcode & GTMA_HAVE_LOAD)
1908 pp_string (buffer, "GTMA_HAVE_LOAD ");
1909 subcode &= ~GTMA_HAVE_LOAD;
1911 if (subcode & GTMA_HAVE_STORE)
1913 pp_string (buffer, "GTMA_HAVE_STORE ");
1914 subcode &= ~GTMA_HAVE_STORE;
1916 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1918 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1919 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1921 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1923 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1924 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1926 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1928 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1929 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1931 if (subcode)
1932 pp_printf (buffer, "0x%x ", subcode);
1933 pp_right_bracket (buffer);
1939 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1940 indent. FLAGS specifies details to show in the dump (see TDF_* in
1941 dumpfile.h). */
1943 static void
1944 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, dump_flags_t flags)
1946 unsigned int i, n, f, fields;
1948 if (flags & TDF_RAW)
1950 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1951 gimple_asm_string (gs));
1953 n = gimple_asm_noutputs (gs);
1954 if (n)
1956 newline_and_indent (buffer, spc + 2);
1957 pp_string (buffer, "OUTPUT: ");
1958 for (i = 0; i < n; i++)
1960 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1961 spc, flags, false);
1962 if (i < n - 1)
1963 pp_string (buffer, ", ");
1967 n = gimple_asm_ninputs (gs);
1968 if (n)
1970 newline_and_indent (buffer, spc + 2);
1971 pp_string (buffer, "INPUT: ");
1972 for (i = 0; i < n; i++)
1974 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1975 spc, flags, false);
1976 if (i < n - 1)
1977 pp_string (buffer, ", ");
1981 n = gimple_asm_nclobbers (gs);
1982 if (n)
1984 newline_and_indent (buffer, spc + 2);
1985 pp_string (buffer, "CLOBBER: ");
1986 for (i = 0; i < n; i++)
1988 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1989 spc, flags, false);
1990 if (i < n - 1)
1991 pp_string (buffer, ", ");
1995 n = gimple_asm_nlabels (gs);
1996 if (n)
1998 newline_and_indent (buffer, spc + 2);
1999 pp_string (buffer, "LABEL: ");
2000 for (i = 0; i < n; i++)
2002 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2003 spc, flags, false);
2004 if (i < n - 1)
2005 pp_string (buffer, ", ");
2009 newline_and_indent (buffer, spc);
2010 pp_greater (buffer);
2012 else
2014 pp_string (buffer, "__asm__");
2015 if (gimple_asm_volatile_p (gs))
2016 pp_string (buffer, " __volatile__");
2017 if (gimple_asm_nlabels (gs))
2018 pp_string (buffer, " goto");
2019 pp_string (buffer, "(\"");
2020 pp_string (buffer, gimple_asm_string (gs));
2021 pp_string (buffer, "\"");
2023 if (gimple_asm_nlabels (gs))
2024 fields = 4;
2025 else if (gimple_asm_nclobbers (gs))
2026 fields = 3;
2027 else if (gimple_asm_ninputs (gs))
2028 fields = 2;
2029 else if (gimple_asm_noutputs (gs))
2030 fields = 1;
2031 else
2032 fields = 0;
2034 for (f = 0; f < fields; ++f)
2036 pp_string (buffer, " : ");
2038 switch (f)
2040 case 0:
2041 n = gimple_asm_noutputs (gs);
2042 for (i = 0; i < n; i++)
2044 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2045 spc, flags, false);
2046 if (i < n - 1)
2047 pp_string (buffer, ", ");
2049 break;
2051 case 1:
2052 n = gimple_asm_ninputs (gs);
2053 for (i = 0; i < n; i++)
2055 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2056 spc, flags, false);
2057 if (i < n - 1)
2058 pp_string (buffer, ", ");
2060 break;
2062 case 2:
2063 n = gimple_asm_nclobbers (gs);
2064 for (i = 0; i < n; i++)
2066 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2067 spc, flags, false);
2068 if (i < n - 1)
2069 pp_string (buffer, ", ");
2071 break;
2073 case 3:
2074 n = gimple_asm_nlabels (gs);
2075 for (i = 0; i < n; i++)
2077 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2078 spc, flags, false);
2079 if (i < n - 1)
2080 pp_string (buffer, ", ");
2082 break;
2084 default:
2085 gcc_unreachable ();
2089 pp_string (buffer, ");");
2093 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2094 SPC spaces of indent. */
2096 static void
2097 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2099 if (TREE_CODE (node) != SSA_NAME)
2100 return;
2102 if (POINTER_TYPE_P (TREE_TYPE (node))
2103 && SSA_NAME_PTR_INFO (node))
2105 unsigned int align, misalign;
2106 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2107 pp_string (buffer, "# PT = ");
2108 pp_points_to_solution (buffer, &pi->pt);
2109 newline_and_indent (buffer, spc);
2110 if (get_ptr_info_alignment (pi, &align, &misalign))
2112 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2113 newline_and_indent (buffer, spc);
2117 if (!POINTER_TYPE_P (TREE_TYPE (node))
2118 && SSA_NAME_RANGE_INFO (node))
2120 wide_int min, max, nonzero_bits;
2121 value_range_type range_type = get_range_info (node, &min, &max);
2123 if (range_type == VR_VARYING)
2124 pp_printf (buffer, "# RANGE VR_VARYING");
2125 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2127 pp_printf (buffer, "# RANGE ");
2128 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2129 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2130 pp_printf (buffer, ", ");
2131 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2132 pp_printf (buffer, "]");
2134 nonzero_bits = get_nonzero_bits (node);
2135 if (nonzero_bits != -1)
2137 pp_string (buffer, " NONZERO ");
2138 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2140 newline_and_indent (buffer, spc);
2144 /* As dump_ssaname_info, but dump to FILE. */
2146 void
2147 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2149 pretty_printer buffer;
2150 pp_needs_newline (&buffer) = true;
2151 buffer.buffer->stream = file;
2152 dump_ssaname_info (&buffer, node, spc);
2153 pp_flush (&buffer);
2156 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2157 The caller is responsible for calling pp_flush on BUFFER to finalize
2158 pretty printer. If COMMENT is true, print this after #. */
2160 static void
2161 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2162 dump_flags_t flags)
2164 size_t i;
2165 tree lhs = gimple_phi_result (phi);
2167 if (flags & TDF_ALIAS)
2168 dump_ssaname_info (buffer, lhs, spc);
2170 if (comment)
2171 pp_string (buffer, "# ");
2173 if (flags & TDF_RAW)
2174 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2175 gimple_phi_result (phi));
2176 else
2178 dump_generic_node (buffer, lhs, spc, flags, false);
2179 if (flags & TDF_GIMPLE)
2180 pp_string (buffer, " = __PHI (");
2181 else
2182 pp_string (buffer, " = PHI <");
2184 for (i = 0; i < gimple_phi_num_args (phi); i++)
2186 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2187 dump_location (buffer, gimple_phi_arg_location (phi, i));
2188 if (flags & TDF_GIMPLE)
2190 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2191 gimple *stmt = first_stmt (src);
2192 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2194 pp_string (buffer, "bb_");
2195 pp_decimal_int (buffer, src->index);
2197 else
2198 dump_generic_node (buffer, gimple_label_label (as_a <glabel *> (stmt)), 0, flags,
2199 false);
2200 pp_string (buffer, ": ");
2202 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2203 false);
2204 if (! (flags & TDF_GIMPLE))
2206 pp_left_paren (buffer);
2207 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2208 pp_right_paren (buffer);
2210 if (i < gimple_phi_num_args (phi) - 1)
2211 pp_string (buffer, ", ");
2213 if (flags & TDF_GIMPLE)
2214 pp_string (buffer, ");");
2215 else
2216 pp_greater (buffer);
2220 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2221 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2222 dumpfile.h). */
2224 static void
2225 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2226 int spc, dump_flags_t flags)
2228 if (flags & TDF_RAW)
2230 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2231 gimple_omp_body (gs));
2232 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2233 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2234 gimple_omp_parallel_child_fn (gs),
2235 gimple_omp_parallel_data_arg (gs));
2237 else
2239 gimple_seq body;
2240 pp_string (buffer, "#pragma omp parallel");
2241 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2242 if (gimple_omp_parallel_child_fn (gs))
2244 pp_string (buffer, " [child fn: ");
2245 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2246 spc, flags, false);
2247 pp_string (buffer, " (");
2248 if (gimple_omp_parallel_data_arg (gs))
2249 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2250 spc, flags, false);
2251 else
2252 pp_string (buffer, "???");
2253 pp_string (buffer, ")]");
2255 body = gimple_omp_body (gs);
2256 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2258 newline_and_indent (buffer, spc + 2);
2259 pp_left_brace (buffer);
2260 pp_newline (buffer);
2261 dump_gimple_seq (buffer, body, spc + 4, flags);
2262 newline_and_indent (buffer, spc + 2);
2263 pp_right_brace (buffer);
2265 else if (body)
2267 pp_newline (buffer);
2268 dump_gimple_seq (buffer, body, spc + 2, flags);
2274 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2275 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2276 dumpfile.h). */
2278 static void
2279 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2280 dump_flags_t flags)
2282 if (flags & TDF_RAW)
2284 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2285 gimple_omp_body (gs));
2286 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2287 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2288 gimple_omp_task_child_fn (gs),
2289 gimple_omp_task_data_arg (gs),
2290 gimple_omp_task_copy_fn (gs),
2291 gimple_omp_task_arg_size (gs),
2292 gimple_omp_task_arg_size (gs));
2294 else
2296 gimple_seq body;
2297 if (gimple_omp_task_taskloop_p (gs))
2298 pp_string (buffer, "#pragma omp taskloop");
2299 else
2300 pp_string (buffer, "#pragma omp task");
2301 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2302 if (gimple_omp_task_child_fn (gs))
2304 pp_string (buffer, " [child fn: ");
2305 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2306 spc, flags, false);
2307 pp_string (buffer, " (");
2308 if (gimple_omp_task_data_arg (gs))
2309 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2310 spc, flags, false);
2311 else
2312 pp_string (buffer, "???");
2313 pp_string (buffer, ")]");
2315 body = gimple_omp_body (gs);
2316 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2318 newline_and_indent (buffer, spc + 2);
2319 pp_left_brace (buffer);
2320 pp_newline (buffer);
2321 dump_gimple_seq (buffer, body, spc + 4, flags);
2322 newline_and_indent (buffer, spc + 2);
2323 pp_right_brace (buffer);
2325 else if (body)
2327 pp_newline (buffer);
2328 dump_gimple_seq (buffer, body, spc + 2, flags);
2334 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2335 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2336 in dumpfile.h). */
2338 static void
2339 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2340 int spc, dump_flags_t flags)
2342 if (flags & TDF_RAW)
2344 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2345 gimple_omp_atomic_load_lhs (gs),
2346 gimple_omp_atomic_load_rhs (gs));
2348 else
2350 pp_string (buffer, "#pragma omp atomic_load");
2351 if (gimple_omp_atomic_seq_cst_p (gs))
2352 pp_string (buffer, " seq_cst");
2353 if (gimple_omp_atomic_need_value_p (gs))
2354 pp_string (buffer, " [needed]");
2355 newline_and_indent (buffer, spc + 2);
2356 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2357 spc, flags, false);
2358 pp_space (buffer);
2359 pp_equal (buffer);
2360 pp_space (buffer);
2361 pp_star (buffer);
2362 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2363 spc, flags, false);
2367 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2368 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2369 in dumpfile.h). */
2371 static void
2372 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2373 gomp_atomic_store *gs, int spc,
2374 dump_flags_t flags)
2376 if (flags & TDF_RAW)
2378 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2379 gimple_omp_atomic_store_val (gs));
2381 else
2383 pp_string (buffer, "#pragma omp atomic_store ");
2384 if (gimple_omp_atomic_seq_cst_p (gs))
2385 pp_string (buffer, "seq_cst ");
2386 if (gimple_omp_atomic_need_value_p (gs))
2387 pp_string (buffer, "[needed] ");
2388 pp_left_paren (buffer);
2389 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2390 spc, flags, false);
2391 pp_right_paren (buffer);
2396 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2397 FLAGS are as in pp_gimple_stmt_1. */
2399 static void
2400 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc,
2401 dump_flags_t flags)
2403 tree vdef = gimple_vdef (gs);
2404 tree vuse = gimple_vuse (gs);
2406 if (vdef != NULL_TREE)
2408 pp_string (buffer, "# ");
2409 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2410 pp_string (buffer, " = VDEF <");
2411 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2412 pp_greater (buffer);
2413 newline_and_indent (buffer, spc);
2415 else if (vuse != NULL_TREE)
2417 pp_string (buffer, "# VUSE <");
2418 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2419 pp_greater (buffer);
2420 newline_and_indent (buffer, spc);
2425 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2426 spaces of indent. FLAGS specifies details to show in the dump (see
2427 TDF_* in dumpfile.h). The caller is responsible for calling
2428 pp_flush on BUFFER to finalize the pretty printer. */
2430 void
2431 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc,
2432 dump_flags_t flags)
2434 if (!gs)
2435 return;
2437 if (flags & TDF_STMTADDR)
2438 pp_printf (buffer, "<&%p> ", (void *) gs);
2440 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2441 dump_location (buffer, gimple_location (gs));
2443 if (flags & TDF_EH)
2445 int lp_nr = lookup_stmt_eh_lp (gs);
2446 if (lp_nr > 0)
2447 pp_printf (buffer, "[LP %d] ", lp_nr);
2448 else if (lp_nr < 0)
2449 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2452 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2453 && gimple_has_mem_ops (gs))
2454 dump_gimple_mem_ops (buffer, gs, spc, flags);
2456 if (gimple_has_lhs (gs)
2457 && (flags & TDF_ALIAS))
2458 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2460 switch (gimple_code (gs))
2462 case GIMPLE_ASM:
2463 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2464 break;
2466 case GIMPLE_ASSIGN:
2467 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2468 break;
2470 case GIMPLE_BIND:
2471 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2472 break;
2474 case GIMPLE_CALL:
2475 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2476 break;
2478 case GIMPLE_COND:
2479 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2480 break;
2482 case GIMPLE_LABEL:
2483 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2484 break;
2486 case GIMPLE_GOTO:
2487 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2488 break;
2490 case GIMPLE_NOP:
2491 pp_string (buffer, "GIMPLE_NOP");
2492 break;
2494 case GIMPLE_RETURN:
2495 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2496 break;
2498 case GIMPLE_SWITCH:
2499 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2500 break;
2502 case GIMPLE_TRY:
2503 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2504 break;
2506 case GIMPLE_PHI:
2507 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2508 break;
2510 case GIMPLE_OMP_PARALLEL:
2511 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2512 flags);
2513 break;
2515 case GIMPLE_OMP_TASK:
2516 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2517 break;
2519 case GIMPLE_OMP_ATOMIC_LOAD:
2520 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2521 spc, flags);
2522 break;
2524 case GIMPLE_OMP_ATOMIC_STORE:
2525 dump_gimple_omp_atomic_store (buffer,
2526 as_a <gomp_atomic_store *> (gs),
2527 spc, flags);
2528 break;
2530 case GIMPLE_OMP_FOR:
2531 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2532 break;
2534 case GIMPLE_OMP_CONTINUE:
2535 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2536 flags);
2537 break;
2539 case GIMPLE_OMP_SINGLE:
2540 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2541 flags);
2542 break;
2544 case GIMPLE_OMP_TARGET:
2545 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2546 flags);
2547 break;
2549 case GIMPLE_OMP_TEAMS:
2550 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2551 flags);
2552 break;
2554 case GIMPLE_OMP_RETURN:
2555 dump_gimple_omp_return (buffer, gs, spc, flags);
2556 break;
2558 case GIMPLE_OMP_SECTIONS:
2559 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2560 spc, flags);
2561 break;
2563 case GIMPLE_OMP_SECTIONS_SWITCH:
2564 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2565 break;
2567 case GIMPLE_OMP_MASTER:
2568 case GIMPLE_OMP_TASKGROUP:
2569 case GIMPLE_OMP_SECTION:
2570 case GIMPLE_OMP_GRID_BODY:
2571 dump_gimple_omp_block (buffer, gs, spc, flags);
2572 break;
2574 case GIMPLE_OMP_ORDERED:
2575 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2576 flags);
2577 break;
2579 case GIMPLE_OMP_CRITICAL:
2580 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2581 flags);
2582 break;
2584 case GIMPLE_CATCH:
2585 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2586 break;
2588 case GIMPLE_EH_FILTER:
2589 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2590 break;
2592 case GIMPLE_EH_MUST_NOT_THROW:
2593 dump_gimple_eh_must_not_throw (buffer,
2594 as_a <geh_mnt *> (gs),
2595 spc, flags);
2596 break;
2598 case GIMPLE_EH_ELSE:
2599 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2600 break;
2602 case GIMPLE_RESX:
2603 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2604 break;
2606 case GIMPLE_EH_DISPATCH:
2607 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2608 flags);
2609 break;
2611 case GIMPLE_DEBUG:
2612 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2613 break;
2615 case GIMPLE_PREDICT:
2616 pp_string (buffer, "// predicted ");
2617 if (gimple_predict_outcome (gs))
2618 pp_string (buffer, "likely by ");
2619 else
2620 pp_string (buffer, "unlikely by ");
2621 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2622 pp_string (buffer, " predictor.");
2623 break;
2625 case GIMPLE_TRANSACTION:
2626 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2627 flags);
2628 break;
2630 default:
2631 GIMPLE_NIY;
2636 /* Dumps header of basic block BB to OUTF indented by INDENT
2637 spaces and details described by flags. */
2639 static void
2640 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
2641 dump_flags_t flags)
2643 if (flags & TDF_BLOCKS)
2645 if (flags & TDF_LINENO)
2647 gimple_stmt_iterator gsi;
2649 fputs (";; ", outf);
2651 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2652 if (!is_gimple_debug (gsi_stmt (gsi))
2653 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2655 fprintf (outf, "%*sstarting at line %d",
2656 indent, "", get_lineno (gsi_stmt (gsi)));
2657 break;
2659 if (bb->discriminator)
2660 fprintf (outf, ", discriminator %i", bb->discriminator);
2661 fputc ('\n', outf);
2664 else
2666 gimple *stmt = first_stmt (bb);
2667 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2669 if (flags & TDF_GIMPLE)
2670 fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
2671 else
2672 fprintf (outf, "%*s<bb %d> %s:\n",
2673 indent, "", bb->index, dump_probability (bb->frequency,
2674 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 gimple *stmt = first_stmt (e->dest);
2733 pp_string (buffer, "goto <bb ");
2734 pp_decimal_int (buffer, e->dest->index);
2735 pp_greater (buffer);
2736 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2738 pp_string (buffer, " (");
2739 dump_generic_node (buffer,
2740 gimple_label_label (as_a <glabel *> (stmt)),
2741 0, 0, false);
2742 pp_right_paren (buffer);
2743 pp_semicolon (buffer);
2745 else
2746 pp_semicolon (buffer);
2748 dump_edge_probability (buffer, e);
2753 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2754 by INDENT spaces, with details given by FLAGS. */
2756 static void
2757 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2758 dump_flags_t flags)
2760 edge e;
2761 gimple *stmt;
2763 stmt = last_stmt (bb);
2765 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2767 edge true_edge, false_edge;
2769 /* When we are emitting the code or changing CFG, it is possible that
2770 the edges are not yet created. When we are using debug_bb in such
2771 a situation, we do not want it to crash. */
2772 if (EDGE_COUNT (bb->succs) != 2)
2773 return;
2774 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2776 INDENT (indent + 2);
2777 pp_cfg_jump (buffer, true_edge, flags);
2778 newline_and_indent (buffer, indent);
2779 pp_string (buffer, "else");
2780 newline_and_indent (buffer, indent + 2);
2781 pp_cfg_jump (buffer, false_edge, flags);
2782 pp_newline (buffer);
2783 return;
2786 /* If there is a fallthru edge, we may need to add an artificial
2787 goto to the dump. */
2788 e = find_fallthru_edge (bb->succs);
2790 if (e && e->dest != bb->next_bb)
2792 INDENT (indent);
2794 if ((flags & TDF_LINENO)
2795 && e->goto_locus != UNKNOWN_LOCATION)
2796 dump_location (buffer, e->goto_locus);
2798 pp_cfg_jump (buffer, e, flags);
2799 pp_newline (buffer);
2804 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2805 indented by INDENT spaces. */
2807 static void
2808 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2809 dump_flags_t flags)
2811 gimple_stmt_iterator gsi;
2812 gimple *stmt;
2813 int label_indent = indent - 2;
2815 if (label_indent < 0)
2816 label_indent = 0;
2818 dump_phi_nodes (buffer, bb, indent, flags);
2820 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2822 int curr_indent;
2824 stmt = gsi_stmt (gsi);
2826 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2828 INDENT (curr_indent);
2829 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2830 pp_newline_and_flush (buffer);
2831 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2832 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2833 pp_buffer (buffer)->stream, stmt);
2836 dump_implicit_edges (buffer, bb, indent, flags);
2837 pp_flush (buffer);
2841 /* Dumps basic block BB to FILE with details described by FLAGS and
2842 indented by INDENT spaces. */
2844 void
2845 gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
2847 dump_gimple_bb_header (file, bb, indent, flags);
2848 if (bb->index >= NUM_FIXED_BLOCKS)
2850 pretty_printer buffer;
2851 pp_needs_newline (&buffer) = true;
2852 buffer.buffer->stream = file;
2853 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2855 dump_gimple_bb_footer (file, bb, indent, flags);
2858 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2859 no indentation, for use as a label of a DOT graph record-node.
2860 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2861 histogram dumping doesn't know about pretty-printers. */
2863 void
2864 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2866 pp_printf (pp, "<bb %d>:\n", bb->index);
2867 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2869 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2870 gsi_next (&gsi))
2872 gphi *phi = gsi.phi ();
2873 if (!virtual_operand_p (gimple_phi_result (phi))
2874 || (dump_flags & TDF_VOPS))
2876 pp_bar (pp);
2877 pp_write_text_to_stream (pp);
2878 pp_string (pp, "# ");
2879 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2880 pp_newline (pp);
2881 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2885 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2886 gsi_next (&gsi))
2888 gimple *stmt = gsi_stmt (gsi);
2889 pp_bar (pp);
2890 pp_write_text_to_stream (pp);
2891 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2892 pp_newline (pp);
2893 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2895 dump_implicit_edges (pp, bb, 0, dump_flags);
2896 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);