Introduce dump_flags_t type and use it instead of int type.
[official-gcc.git] / gcc / gimple-pretty-print.c
blobc99dfe1192cd645ef9b0baf3b7323e3b60a8fa3e
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 value)
85 float minimum = 0.01f;
87 gcc_assert (0 <= value && value <= REG_BR_PROB_BASE);
88 float fvalue = value * 100.0f / REG_BR_PROB_BASE;
89 if (fvalue < minimum && value > 0)
90 return "[0.01%]";
92 char *buf;
93 asprintf (&buf, "[%.2f%%]", fvalue);
94 const char *ret = xstrdup_for_dump (buf);
95 free (buf);
97 return ret;
100 /* Dump E probability to BUFFER. */
102 static void
103 dump_edge_probability (pretty_printer *buffer, edge e)
105 pp_scalar (buffer, " %s", dump_probability (e->probability));
108 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
109 FLAGS as in pp_gimple_stmt_1. */
111 void
112 print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
114 pretty_printer buffer;
115 pp_needs_newline (&buffer) = true;
116 buffer.buffer->stream = file;
117 pp_gimple_stmt_1 (&buffer, g, spc, flags);
118 pp_newline_and_flush (&buffer);
121 DEBUG_FUNCTION void
122 debug (gimple &ref)
124 print_gimple_stmt (stderr, &ref, 0, 0);
127 DEBUG_FUNCTION void
128 debug (gimple *ptr)
130 if (ptr)
131 debug (*ptr);
132 else
133 fprintf (stderr, "<nil>\n");
137 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
138 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
139 of the statement. */
141 void
142 print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
144 flags |= TDF_RHS_ONLY;
145 pretty_printer buffer;
146 pp_needs_newline (&buffer) = true;
147 buffer.buffer->stream = file;
148 pp_gimple_stmt_1 (&buffer, g, spc, flags);
149 pp_flush (&buffer);
153 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
154 spaces and FLAGS as in pp_gimple_stmt_1.
155 The caller is responsible for calling pp_flush on BUFFER to finalize
156 the pretty printer. */
158 static void
159 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc,
160 dump_flags_t flags)
162 gimple_stmt_iterator i;
164 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
166 gimple *gs = gsi_stmt (i);
167 INDENT (spc);
168 pp_gimple_stmt_1 (buffer, gs, spc, flags);
169 if (!gsi_one_before_end_p (i))
170 pp_newline (buffer);
175 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
176 FLAGS as in pp_gimple_stmt_1. */
178 void
179 print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
181 pretty_printer buffer;
182 pp_needs_newline (&buffer) = true;
183 buffer.buffer->stream = file;
184 dump_gimple_seq (&buffer, seq, spc, flags);
185 pp_newline_and_flush (&buffer);
189 /* Print the GIMPLE sequence SEQ on stderr. */
191 DEBUG_FUNCTION void
192 debug_gimple_seq (gimple_seq seq)
194 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
198 /* A simple helper to pretty-print some of the gimple tuples in the printf
199 style. The format modifiers are preceded by '%' and are:
200 'G' - outputs a string corresponding to the code of the given gimple,
201 'S' - outputs a gimple_seq with indent of spc + 2,
202 'T' - outputs the tree t,
203 'd' - outputs an int as a decimal,
204 's' - outputs a string,
205 'n' - outputs a newline,
206 'x' - outputs an int as hexadecimal,
207 '+' - increases indent by 2 then outputs a newline,
208 '-' - decreases indent by 2 then outputs a newline. */
210 static void
211 dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags,
212 const char *fmt, ...)
214 va_list args;
215 const char *c;
216 const char *tmp;
218 va_start (args, fmt);
219 for (c = fmt; *c; c++)
221 if (*c == '%')
223 gimple_seq seq;
224 tree t;
225 gimple *g;
226 switch (*++c)
228 case 'G':
229 g = va_arg (args, gimple *);
230 tmp = gimple_code_name[gimple_code (g)];
231 pp_string (buffer, tmp);
232 break;
234 case 'S':
235 seq = va_arg (args, gimple_seq);
236 pp_newline (buffer);
237 dump_gimple_seq (buffer, seq, spc + 2, flags);
238 newline_and_indent (buffer, spc);
239 break;
241 case 'T':
242 t = va_arg (args, tree);
243 if (t == NULL_TREE)
244 pp_string (buffer, "NULL");
245 else
246 dump_generic_node (buffer, t, spc, flags, false);
247 break;
249 case 'd':
250 pp_decimal_int (buffer, va_arg (args, int));
251 break;
253 case 's':
254 pp_string (buffer, va_arg (args, char *));
255 break;
257 case 'n':
258 newline_and_indent (buffer, spc);
259 break;
261 case 'x':
262 pp_scalar (buffer, "%x", va_arg (args, int));
263 break;
265 case '+':
266 spc += 2;
267 newline_and_indent (buffer, spc);
268 break;
270 case '-':
271 spc -= 2;
272 newline_and_indent (buffer, spc);
273 break;
275 default:
276 gcc_unreachable ();
279 else
280 pp_character (buffer, *c);
282 va_end (args);
286 /* Helper for dump_gimple_assign. Print the unary RHS of the
287 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
289 static void
290 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc,
291 dump_flags_t flags)
293 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
294 tree lhs = gimple_assign_lhs (gs);
295 tree rhs = gimple_assign_rhs1 (gs);
297 switch (rhs_code)
299 case VIEW_CONVERT_EXPR:
300 case ASSERT_EXPR:
301 dump_generic_node (buffer, rhs, spc, flags, false);
302 break;
304 case FIXED_CONVERT_EXPR:
305 case ADDR_SPACE_CONVERT_EXPR:
306 case FIX_TRUNC_EXPR:
307 case FLOAT_EXPR:
308 CASE_CONVERT:
309 pp_left_paren (buffer);
310 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
311 pp_string (buffer, ") ");
312 if (op_prio (rhs) < op_code_prio (rhs_code))
314 pp_left_paren (buffer);
315 dump_generic_node (buffer, rhs, spc, flags, false);
316 pp_right_paren (buffer);
318 else
319 dump_generic_node (buffer, rhs, spc, flags, false);
320 break;
322 case PAREN_EXPR:
323 pp_string (buffer, "((");
324 dump_generic_node (buffer, rhs, spc, flags, false);
325 pp_string (buffer, "))");
326 break;
328 case ABS_EXPR:
329 if (flags & TDF_GIMPLE)
331 pp_string (buffer, "__ABS ");
332 dump_generic_node (buffer, rhs, spc, flags, false);
334 else
336 pp_string (buffer, "ABS_EXPR <");
337 dump_generic_node (buffer, rhs, spc, flags, false);
338 pp_greater (buffer);
340 break;
342 default:
343 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
344 || TREE_CODE_CLASS (rhs_code) == tcc_constant
345 || TREE_CODE_CLASS (rhs_code) == tcc_reference
346 || rhs_code == SSA_NAME
347 || rhs_code == ADDR_EXPR
348 || rhs_code == CONSTRUCTOR)
350 dump_generic_node (buffer, rhs, spc, flags, false);
351 break;
353 else if (rhs_code == BIT_NOT_EXPR)
354 pp_complement (buffer);
355 else if (rhs_code == TRUTH_NOT_EXPR)
356 pp_exclamation (buffer);
357 else if (rhs_code == NEGATE_EXPR)
358 pp_minus (buffer);
359 else
361 pp_left_bracket (buffer);
362 pp_string (buffer, get_tree_code_name (rhs_code));
363 pp_string (buffer, "] ");
366 if (op_prio (rhs) < op_code_prio (rhs_code))
368 pp_left_paren (buffer);
369 dump_generic_node (buffer, rhs, spc, flags, false);
370 pp_right_paren (buffer);
372 else
373 dump_generic_node (buffer, rhs, spc, flags, false);
374 break;
379 /* Helper for dump_gimple_assign. Print the binary RHS of the
380 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
382 static void
383 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc,
384 dump_flags_t flags)
386 const char *p;
387 enum tree_code code = gimple_assign_rhs_code (gs);
388 switch (code)
390 case COMPLEX_EXPR:
391 case MIN_EXPR:
392 case MAX_EXPR:
393 case VEC_WIDEN_MULT_HI_EXPR:
394 case VEC_WIDEN_MULT_LO_EXPR:
395 case VEC_WIDEN_MULT_EVEN_EXPR:
396 case VEC_WIDEN_MULT_ODD_EXPR:
397 case VEC_PACK_TRUNC_EXPR:
398 case VEC_PACK_SAT_EXPR:
399 case VEC_PACK_FIX_TRUNC_EXPR:
400 case VEC_WIDEN_LSHIFT_HI_EXPR:
401 case VEC_WIDEN_LSHIFT_LO_EXPR:
402 for (p = get_tree_code_name (code); *p; p++)
403 pp_character (buffer, TOUPPER (*p));
404 pp_string (buffer, " <");
405 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
406 pp_string (buffer, ", ");
407 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
408 pp_greater (buffer);
409 break;
411 default:
412 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
414 pp_left_paren (buffer);
415 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
416 false);
417 pp_right_paren (buffer);
419 else
420 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
421 pp_space (buffer);
422 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
423 pp_space (buffer);
424 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
426 pp_left_paren (buffer);
427 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
428 false);
429 pp_right_paren (buffer);
431 else
432 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
436 /* Helper for dump_gimple_assign. Print the ternary RHS of the
437 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
439 static void
440 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc,
441 dump_flags_t flags)
443 const char *p;
444 enum tree_code code = gimple_assign_rhs_code (gs);
445 switch (code)
447 case WIDEN_MULT_PLUS_EXPR:
448 case WIDEN_MULT_MINUS_EXPR:
449 for (p = get_tree_code_name (code); *p; p++)
450 pp_character (buffer, TOUPPER (*p));
451 pp_string (buffer, " <");
452 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
453 pp_string (buffer, ", ");
454 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
455 pp_string (buffer, ", ");
456 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
457 pp_greater (buffer);
458 break;
460 case FMA_EXPR:
461 if (flags & TDF_GIMPLE)
463 pp_string (buffer, "__FMA (");
464 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
465 pp_comma (buffer);
466 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
467 pp_comma (buffer);
468 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
469 pp_right_paren (buffer);
471 else
473 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
474 pp_string (buffer, " * ");
475 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
476 pp_string (buffer, " + ");
477 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
479 break;
481 case DOT_PROD_EXPR:
482 pp_string (buffer, "DOT_PROD_EXPR <");
483 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
484 pp_string (buffer, ", ");
485 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
486 pp_string (buffer, ", ");
487 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
488 pp_greater (buffer);
489 break;
491 case SAD_EXPR:
492 pp_string (buffer, "SAD_EXPR <");
493 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
494 pp_string (buffer, ", ");
495 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
496 pp_string (buffer, ", ");
497 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
498 pp_greater (buffer);
499 break;
501 case VEC_PERM_EXPR:
502 pp_string (buffer, "VEC_PERM_EXPR <");
503 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
504 pp_string (buffer, ", ");
505 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
506 pp_string (buffer, ", ");
507 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
508 pp_greater (buffer);
509 break;
511 case REALIGN_LOAD_EXPR:
512 pp_string (buffer, "REALIGN_LOAD <");
513 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
514 pp_string (buffer, ", ");
515 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
516 pp_string (buffer, ", ");
517 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
518 pp_greater (buffer);
519 break;
521 case COND_EXPR:
522 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
523 pp_string (buffer, " ? ");
524 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
525 pp_string (buffer, " : ");
526 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
527 break;
529 case VEC_COND_EXPR:
530 pp_string (buffer, "VEC_COND_EXPR <");
531 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
532 pp_string (buffer, ", ");
533 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
534 pp_string (buffer, ", ");
535 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
536 pp_greater (buffer);
537 break;
539 case BIT_INSERT_EXPR:
540 pp_string (buffer, "BIT_INSERT_EXPR <");
541 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
542 pp_string (buffer, ", ");
543 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
544 pp_string (buffer, ", ");
545 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
546 pp_string (buffer, " (");
547 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
548 pp_decimal_int (buffer,
549 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
550 else
551 dump_generic_node (buffer,
552 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
553 spc, flags, false);
554 pp_string (buffer, " bits)>");
555 break;
557 default:
558 gcc_unreachable ();
563 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
564 pp_gimple_stmt_1. */
566 static void
567 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc,
568 dump_flags_t flags)
570 if (flags & TDF_RAW)
572 tree arg1 = NULL;
573 tree arg2 = NULL;
574 tree arg3 = NULL;
575 switch (gimple_num_ops (gs))
577 case 4:
578 arg3 = gimple_assign_rhs3 (gs);
579 /* FALLTHRU */
580 case 3:
581 arg2 = gimple_assign_rhs2 (gs);
582 /* FALLTHRU */
583 case 2:
584 arg1 = gimple_assign_rhs1 (gs);
585 break;
586 default:
587 gcc_unreachable ();
590 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
591 get_tree_code_name (gimple_assign_rhs_code (gs)),
592 gimple_assign_lhs (gs), arg1, arg2, arg3);
594 else
596 if (!(flags & TDF_RHS_ONLY))
598 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
599 pp_space (buffer);
600 pp_equal (buffer);
602 if (gimple_assign_nontemporal_move_p (gs))
603 pp_string (buffer, "{nt}");
605 if (gimple_has_volatile_ops (gs))
606 pp_string (buffer, "{v}");
608 pp_space (buffer);
611 if (gimple_num_ops (gs) == 2)
612 dump_unary_rhs (buffer, gs, spc, flags);
613 else if (gimple_num_ops (gs) == 3)
614 dump_binary_rhs (buffer, gs, spc, flags);
615 else if (gimple_num_ops (gs) == 4)
616 dump_ternary_rhs (buffer, gs, spc, flags);
617 else
618 gcc_unreachable ();
619 if (!(flags & TDF_RHS_ONLY))
620 pp_semicolon (buffer);
625 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
626 pp_gimple_stmt_1. */
628 static void
629 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc,
630 dump_flags_t flags)
632 tree t, t2;
634 t = gimple_return_retval (gs);
635 t2 = gimple_return_retbnd (gs);
636 if (flags & TDF_RAW)
637 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
638 else
640 pp_string (buffer, "return");
641 if (t)
643 pp_space (buffer);
644 dump_generic_node (buffer, t, spc, flags, false);
646 if (t2)
648 pp_string (buffer, ", ");
649 dump_generic_node (buffer, t2, spc, flags, false);
651 pp_semicolon (buffer);
656 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
657 dump_gimple_call. */
659 static void
660 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, dump_flags_t flags)
662 size_t i = 0;
664 /* Pretty print first arg to certain internal fns. */
665 if (gimple_call_internal_p (gs))
667 const char *const *enums = NULL;
668 unsigned limit = 0;
670 switch (gimple_call_internal_fn (gs))
672 case IFN_UNIQUE:
673 #define DEF(X) #X
674 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
675 #undef DEF
676 enums = unique_args;
678 limit = ARRAY_SIZE (unique_args);
679 break;
681 case IFN_GOACC_LOOP:
682 #define DEF(X) #X
683 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
684 #undef DEF
685 enums = loop_args;
686 limit = ARRAY_SIZE (loop_args);
687 break;
689 case IFN_GOACC_REDUCTION:
690 #define DEF(X) #X
691 static const char *const reduction_args[]
692 = {IFN_GOACC_REDUCTION_CODES};
693 #undef DEF
694 enums = reduction_args;
695 limit = ARRAY_SIZE (reduction_args);
696 break;
698 case IFN_ASAN_MARK:
699 #define DEF(X) #X
700 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
701 #undef DEF
702 enums = asan_mark_args;
703 limit = ARRAY_SIZE (asan_mark_args);
704 break;
706 default:
707 break;
709 if (limit)
711 tree arg0 = gimple_call_arg (gs, 0);
712 HOST_WIDE_INT v;
714 if (TREE_CODE (arg0) == INTEGER_CST
715 && tree_fits_shwi_p (arg0)
716 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
718 i++;
719 pp_string (buffer, enums[v]);
724 for (; i < gimple_call_num_args (gs); i++)
726 if (i)
727 pp_string (buffer, ", ");
728 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
731 if (gimple_call_va_arg_pack_p (gs))
733 if (i)
734 pp_string (buffer, ", ");
736 pp_string (buffer, "__builtin_va_arg_pack ()");
740 /* Dump the points-to solution *PT to BUFFER. */
742 static void
743 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
745 if (pt->anything)
747 pp_string (buffer, "anything ");
748 return;
750 if (pt->nonlocal)
751 pp_string (buffer, "nonlocal ");
752 if (pt->escaped)
753 pp_string (buffer, "escaped ");
754 if (pt->ipa_escaped)
755 pp_string (buffer, "unit-escaped ");
756 if (pt->null)
757 pp_string (buffer, "null ");
758 if (pt->vars
759 && !bitmap_empty_p (pt->vars))
761 bitmap_iterator bi;
762 unsigned i;
763 pp_string (buffer, "{ ");
764 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
766 pp_string (buffer, "D.");
767 pp_decimal_int (buffer, i);
768 pp_space (buffer);
770 pp_right_brace (buffer);
771 if (pt->vars_contains_nonlocal
772 || pt->vars_contains_escaped
773 || pt->vars_contains_escaped_heap
774 || pt->vars_contains_restrict)
776 const char *comma = "";
777 pp_string (buffer, " (");
778 if (pt->vars_contains_nonlocal)
780 pp_string (buffer, "nonlocal");
781 comma = ", ";
783 if (pt->vars_contains_escaped)
785 pp_string (buffer, comma);
786 pp_string (buffer, "escaped");
787 comma = ", ";
789 if (pt->vars_contains_escaped_heap)
791 pp_string (buffer, comma);
792 pp_string (buffer, "escaped heap");
793 comma = ", ";
795 if (pt->vars_contains_restrict)
797 pp_string (buffer, comma);
798 pp_string (buffer, "restrict");
799 comma = ", ";
801 if (pt->vars_contains_interposable)
803 pp_string (buffer, comma);
804 pp_string (buffer, "interposable");
806 pp_string (buffer, ")");
812 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
813 pp_gimple_stmt_1. */
815 static void
816 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
817 dump_flags_t flags)
819 tree lhs = gimple_call_lhs (gs);
820 tree fn = gimple_call_fn (gs);
822 if (flags & TDF_ALIAS)
824 struct pt_solution *pt;
825 pt = gimple_call_use_set (gs);
826 if (!pt_solution_empty_p (pt))
828 pp_string (buffer, "# USE = ");
829 pp_points_to_solution (buffer, pt);
830 newline_and_indent (buffer, spc);
832 pt = gimple_call_clobber_set (gs);
833 if (!pt_solution_empty_p (pt))
835 pp_string (buffer, "# CLB = ");
836 pp_points_to_solution (buffer, pt);
837 newline_and_indent (buffer, spc);
841 if (flags & TDF_RAW)
843 if (gimple_call_internal_p (gs))
844 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
845 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
846 else
847 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
848 if (gimple_call_num_args (gs) > 0)
850 pp_string (buffer, ", ");
851 dump_gimple_call_args (buffer, gs, flags);
853 pp_greater (buffer);
855 else
857 if (lhs && !(flags & TDF_RHS_ONLY))
859 dump_generic_node (buffer, lhs, spc, flags, false);
860 pp_string (buffer, " =");
862 if (gimple_has_volatile_ops (gs))
863 pp_string (buffer, "{v}");
865 pp_space (buffer);
867 if (gimple_call_internal_p (gs))
868 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
869 else
870 print_call_name (buffer, fn, flags);
871 pp_string (buffer, " (");
872 dump_gimple_call_args (buffer, gs, flags);
873 pp_right_paren (buffer);
874 if (!(flags & TDF_RHS_ONLY))
875 pp_semicolon (buffer);
878 if (gimple_call_chain (gs))
880 pp_string (buffer, " [static-chain: ");
881 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
882 pp_right_bracket (buffer);
885 if (gimple_call_return_slot_opt_p (gs))
886 pp_string (buffer, " [return slot optimization]");
887 if (gimple_call_tail_p (gs))
888 pp_string (buffer, " [tail call]");
889 if (gimple_call_must_tail_p (gs))
890 pp_string (buffer, " [must tail call]");
892 if (fn == NULL)
893 return;
895 /* Dump the arguments of _ITM_beginTransaction sanely. */
896 if (TREE_CODE (fn) == ADDR_EXPR)
897 fn = TREE_OPERAND (fn, 0);
898 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
899 pp_string (buffer, " [tm-clone]");
900 if (TREE_CODE (fn) == FUNCTION_DECL
901 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
902 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
903 && gimple_call_num_args (gs) > 0)
905 tree t = gimple_call_arg (gs, 0);
906 unsigned HOST_WIDE_INT props;
907 gcc_assert (TREE_CODE (t) == INTEGER_CST);
909 pp_string (buffer, " [ ");
911 /* Get the transaction code properties. */
912 props = TREE_INT_CST_LOW (t);
914 if (props & PR_INSTRUMENTEDCODE)
915 pp_string (buffer, "instrumentedCode ");
916 if (props & PR_UNINSTRUMENTEDCODE)
917 pp_string (buffer, "uninstrumentedCode ");
918 if (props & PR_HASNOXMMUPDATE)
919 pp_string (buffer, "hasNoXMMUpdate ");
920 if (props & PR_HASNOABORT)
921 pp_string (buffer, "hasNoAbort ");
922 if (props & PR_HASNOIRREVOCABLE)
923 pp_string (buffer, "hasNoIrrevocable ");
924 if (props & PR_DOESGOIRREVOCABLE)
925 pp_string (buffer, "doesGoIrrevocable ");
926 if (props & PR_HASNOSIMPLEREADS)
927 pp_string (buffer, "hasNoSimpleReads ");
928 if (props & PR_AWBARRIERSOMITTED)
929 pp_string (buffer, "awBarriersOmitted ");
930 if (props & PR_RARBARRIERSOMITTED)
931 pp_string (buffer, "RaRBarriersOmitted ");
932 if (props & PR_UNDOLOGCODE)
933 pp_string (buffer, "undoLogCode ");
934 if (props & PR_PREFERUNINSTRUMENTED)
935 pp_string (buffer, "preferUninstrumented ");
936 if (props & PR_EXCEPTIONBLOCK)
937 pp_string (buffer, "exceptionBlock ");
938 if (props & PR_HASELSE)
939 pp_string (buffer, "hasElse ");
940 if (props & PR_READONLY)
941 pp_string (buffer, "readOnly ");
943 pp_right_bracket (buffer);
948 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
949 pp_gimple_stmt_1. */
951 static void
952 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
953 dump_flags_t flags)
955 unsigned int i;
957 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
958 if (flags & TDF_RAW)
959 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
960 gimple_switch_index (gs));
961 else
963 pp_string (buffer, "switch (");
964 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
965 if (flags & TDF_GIMPLE)
966 pp_string (buffer, ") {");
967 else
968 pp_string (buffer, ") <");
971 for (i = 0; i < gimple_switch_num_labels (gs); i++)
973 tree case_label = gimple_switch_label (gs, i);
974 gcc_checking_assert (case_label != NULL_TREE);
975 dump_generic_node (buffer, case_label, spc, flags, false);
976 pp_space (buffer);
977 tree label = CASE_LABEL (case_label);
978 dump_generic_node (buffer, label, spc, flags, false);
980 if (cfun && cfun->cfg)
982 basic_block dest = label_to_block (label);
983 if (dest)
985 edge label_edge = find_edge (gimple_bb (gs), dest);
986 if (label_edge && !(flags & TDF_GIMPLE))
987 dump_edge_probability (buffer, label_edge);
991 if (i < gimple_switch_num_labels (gs) - 1)
993 if (flags & TDF_GIMPLE)
994 pp_string (buffer, "; ");
995 else
996 pp_string (buffer, ", ");
999 if (flags & TDF_GIMPLE)
1000 pp_string (buffer, "; }");
1001 else
1002 pp_greater (buffer);
1006 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1007 pp_gimple_stmt_1. */
1009 static void
1010 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc,
1011 dump_flags_t flags)
1013 if (flags & TDF_RAW)
1014 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1015 get_tree_code_name (gimple_cond_code (gs)),
1016 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1017 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1018 else
1020 if (!(flags & TDF_RHS_ONLY))
1021 pp_string (buffer, "if (");
1022 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
1023 pp_space (buffer);
1024 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1025 pp_space (buffer);
1026 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
1027 if (!(flags & TDF_RHS_ONLY))
1029 edge_iterator ei;
1030 edge e, true_edge = NULL, false_edge = NULL;
1031 basic_block bb = gimple_bb (gs);
1033 if (bb)
1035 FOR_EACH_EDGE (e, ei, bb->succs)
1037 if (e->flags & EDGE_TRUE_VALUE)
1038 true_edge = e;
1039 else if (e->flags & EDGE_FALSE_VALUE)
1040 false_edge = e;
1044 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1046 pp_right_paren (buffer);
1048 if (gimple_cond_true_label (gs))
1050 pp_string (buffer, " goto ");
1051 dump_generic_node (buffer, gimple_cond_true_label (gs),
1052 spc, flags, false);
1053 if (has_edge_info && !(flags & TDF_GIMPLE))
1054 dump_edge_probability (buffer, true_edge);
1055 pp_semicolon (buffer);
1057 if (gimple_cond_false_label (gs))
1059 pp_string (buffer, " else goto ");
1060 dump_generic_node (buffer, gimple_cond_false_label (gs),
1061 spc, flags, false);
1062 if (has_edge_info && !(flags & TDF_GIMPLE))
1063 dump_edge_probability (buffer, false_edge);
1065 pp_semicolon (buffer);
1072 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1073 spaces of indent. FLAGS specifies details to show in the dump (see
1074 TDF_* in dumpfils.h). */
1076 static void
1077 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
1078 dump_flags_t flags)
1080 tree label = gimple_label_label (gs);
1081 if (flags & TDF_RAW)
1082 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1083 else
1085 dump_generic_node (buffer, label, spc, flags, false);
1086 basic_block bb = gimple_bb (gs);
1087 if (bb && !(flags & TDF_GIMPLE))
1088 pp_scalar (buffer, " %s", dump_probability (bb->frequency));
1089 pp_colon (buffer);
1091 if (flags & TDF_GIMPLE)
1092 return;
1093 if (DECL_NONLOCAL (label))
1094 pp_string (buffer, " [non-local]");
1095 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1096 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1099 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1100 spaces of indent. FLAGS specifies details to show in the dump (see
1101 TDF_* in dumpfile.h). */
1103 static void
1104 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc,
1105 dump_flags_t flags)
1107 tree label = gimple_goto_dest (gs);
1108 if (flags & TDF_RAW)
1109 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1110 else
1111 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1115 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1116 spaces of indent. FLAGS specifies details to show in the dump (see
1117 TDF_* in dumpfile.h). */
1119 static void
1120 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc,
1121 dump_flags_t flags)
1123 if (flags & TDF_RAW)
1124 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1125 else
1126 pp_left_brace (buffer);
1127 if (!(flags & TDF_SLIM))
1129 tree var;
1131 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1133 newline_and_indent (buffer, 2);
1134 print_declaration (buffer, var, spc, flags);
1136 if (gimple_bind_vars (gs))
1137 pp_newline (buffer);
1139 pp_newline (buffer);
1140 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1141 newline_and_indent (buffer, spc);
1142 if (flags & TDF_RAW)
1143 pp_greater (buffer);
1144 else
1145 pp_right_brace (buffer);
1149 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1150 indent. FLAGS specifies details to show in the dump (see TDF_* in
1151 dumpfile.h). */
1153 static void
1154 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc,
1155 dump_flags_t flags)
1157 if (flags & TDF_RAW)
1159 const char *type;
1160 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1161 type = "GIMPLE_TRY_CATCH";
1162 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1163 type = "GIMPLE_TRY_FINALLY";
1164 else
1165 type = "UNKNOWN GIMPLE_TRY";
1166 dump_gimple_fmt (buffer, spc, flags,
1167 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1168 gimple_try_eval (gs), gimple_try_cleanup (gs));
1170 else
1172 pp_string (buffer, "try");
1173 newline_and_indent (buffer, spc + 2);
1174 pp_left_brace (buffer);
1175 pp_newline (buffer);
1177 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1178 newline_and_indent (buffer, spc + 2);
1179 pp_right_brace (buffer);
1181 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1183 newline_and_indent (buffer, spc);
1184 pp_string (buffer, "catch");
1185 newline_and_indent (buffer, spc + 2);
1186 pp_left_brace (buffer);
1188 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1190 newline_and_indent (buffer, spc);
1191 pp_string (buffer, "finally");
1192 newline_and_indent (buffer, spc + 2);
1193 pp_left_brace (buffer);
1195 else
1196 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1198 pp_newline (buffer);
1199 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1200 newline_and_indent (buffer, spc + 2);
1201 pp_right_brace (buffer);
1206 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1207 indent. FLAGS specifies details to show in the dump (see TDF_* in
1208 dumpfile.h). */
1210 static void
1211 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc,
1212 dump_flags_t flags)
1214 if (flags & TDF_RAW)
1215 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1216 gimple_catch_types (gs), gimple_catch_handler (gs));
1217 else
1218 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1219 gimple_catch_types (gs), gimple_catch_handler (gs));
1223 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1224 indent. FLAGS specifies details to show in the dump (see TDF_* in
1225 dumpfile.h). */
1227 static void
1228 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1229 dump_flags_t flags)
1231 if (flags & TDF_RAW)
1232 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1233 gimple_eh_filter_types (gs),
1234 gimple_eh_filter_failure (gs));
1235 else
1236 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1237 gimple_eh_filter_types (gs),
1238 gimple_eh_filter_failure (gs));
1242 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1244 static void
1245 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1246 geh_mnt *gs, int spc, dump_flags_t flags)
1248 if (flags & TDF_RAW)
1249 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1250 gimple_eh_must_not_throw_fndecl (gs));
1251 else
1252 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1253 gimple_eh_must_not_throw_fndecl (gs));
1257 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1258 indent. FLAGS specifies details to show in the dump (see TDF_* in
1259 dumpfile.h). */
1261 static void
1262 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1263 dump_flags_t flags)
1265 if (flags & TDF_RAW)
1266 dump_gimple_fmt (buffer, spc, flags,
1267 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1268 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1269 else
1270 dump_gimple_fmt (buffer, spc, flags,
1271 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1272 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1276 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1277 indent. FLAGS specifies details to show in the dump (see TDF_* in
1278 dumpfile.h). */
1280 static void
1281 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc,
1282 dump_flags_t flags)
1284 if (flags & TDF_RAW)
1285 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1286 gimple_resx_region (gs));
1287 else
1288 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1291 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1293 static void
1294 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *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_eh_dispatch_region (gs));
1300 else
1301 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1302 gimple_eh_dispatch_region (gs));
1305 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1306 of indent. FLAGS specifies details to show in the dump (see TDF_*
1307 in dumpfile.h). */
1309 static void
1310 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc,
1311 dump_flags_t flags)
1313 switch (gs->subcode)
1315 case GIMPLE_DEBUG_BIND:
1316 if (flags & TDF_RAW)
1317 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1318 gimple_debug_bind_get_var (gs),
1319 gimple_debug_bind_get_value (gs));
1320 else
1321 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1322 gimple_debug_bind_get_var (gs),
1323 gimple_debug_bind_get_value (gs));
1324 break;
1326 case GIMPLE_DEBUG_SOURCE_BIND:
1327 if (flags & TDF_RAW)
1328 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1329 gimple_debug_source_bind_get_var (gs),
1330 gimple_debug_source_bind_get_value (gs));
1331 else
1332 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1333 gimple_debug_source_bind_get_var (gs),
1334 gimple_debug_source_bind_get_value (gs));
1335 break;
1337 default:
1338 gcc_unreachable ();
1342 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1343 static void
1344 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc,
1345 dump_flags_t flags)
1347 size_t i;
1349 if (flags & TDF_RAW)
1351 const char *kind;
1352 switch (gimple_omp_for_kind (gs))
1354 case GF_OMP_FOR_KIND_FOR:
1355 kind = "";
1356 break;
1357 case GF_OMP_FOR_KIND_DISTRIBUTE:
1358 kind = " distribute";
1359 break;
1360 case GF_OMP_FOR_KIND_TASKLOOP:
1361 kind = " taskloop";
1362 break;
1363 case GF_OMP_FOR_KIND_CILKFOR:
1364 kind = " _Cilk_for";
1365 break;
1366 case GF_OMP_FOR_KIND_OACC_LOOP:
1367 kind = " oacc_loop";
1368 break;
1369 case GF_OMP_FOR_KIND_SIMD:
1370 kind = " simd";
1371 break;
1372 case GF_OMP_FOR_KIND_CILKSIMD:
1373 kind = " cilksimd";
1374 break;
1375 default:
1376 gcc_unreachable ();
1378 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1379 kind, gimple_omp_body (gs));
1380 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1381 dump_gimple_fmt (buffer, spc, flags, " >,");
1382 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1383 dump_gimple_fmt (buffer, spc, flags,
1384 "%+%T, %T, %T, %s, %T,%n",
1385 gimple_omp_for_index (gs, i),
1386 gimple_omp_for_initial (gs, i),
1387 gimple_omp_for_final (gs, i),
1388 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1389 gimple_omp_for_incr (gs, i));
1390 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1391 gimple_omp_for_pre_body (gs));
1393 else
1395 switch (gimple_omp_for_kind (gs))
1397 case GF_OMP_FOR_KIND_FOR:
1398 pp_string (buffer, "#pragma omp for");
1399 break;
1400 case GF_OMP_FOR_KIND_DISTRIBUTE:
1401 pp_string (buffer, "#pragma omp distribute");
1402 break;
1403 case GF_OMP_FOR_KIND_TASKLOOP:
1404 pp_string (buffer, "#pragma omp taskloop");
1405 break;
1406 case GF_OMP_FOR_KIND_CILKFOR:
1407 break;
1408 case GF_OMP_FOR_KIND_OACC_LOOP:
1409 pp_string (buffer, "#pragma acc loop");
1410 break;
1411 case GF_OMP_FOR_KIND_SIMD:
1412 pp_string (buffer, "#pragma omp simd");
1413 break;
1414 case GF_OMP_FOR_KIND_CILKSIMD:
1415 pp_string (buffer, "#pragma simd");
1416 break;
1417 case GF_OMP_FOR_KIND_GRID_LOOP:
1418 pp_string (buffer, "#pragma omp for grid_loop");
1419 break;
1420 default:
1421 gcc_unreachable ();
1423 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1424 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1425 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1427 if (i)
1428 spc += 2;
1429 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1430 pp_string (buffer, "_Cilk_for (");
1431 else
1433 newline_and_indent (buffer, spc);
1434 pp_string (buffer, "for (");
1436 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1437 flags, false);
1438 pp_string (buffer, " = ");
1439 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1440 flags, false);
1441 pp_string (buffer, "; ");
1443 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1444 flags, false);
1445 pp_space (buffer);
1446 switch (gimple_omp_for_cond (gs, i))
1448 case LT_EXPR:
1449 pp_less (buffer);
1450 break;
1451 case GT_EXPR:
1452 pp_greater (buffer);
1453 break;
1454 case LE_EXPR:
1455 pp_less_equal (buffer);
1456 break;
1457 case GE_EXPR:
1458 pp_greater_equal (buffer);
1459 break;
1460 case NE_EXPR:
1461 pp_string (buffer, "!=");
1462 break;
1463 default:
1464 gcc_unreachable ();
1466 pp_space (buffer);
1467 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1468 flags, false);
1469 pp_string (buffer, "; ");
1471 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1472 flags, false);
1473 pp_string (buffer, " = ");
1474 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1475 flags, false);
1476 pp_right_paren (buffer);
1479 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1481 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1482 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1483 newline_and_indent (buffer, spc + 2);
1484 pp_left_brace (buffer);
1485 pp_newline (buffer);
1486 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1487 newline_and_indent (buffer, spc + 2);
1488 pp_right_brace (buffer);
1493 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1495 static void
1496 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1497 int spc, dump_flags_t flags)
1499 if (flags & TDF_RAW)
1501 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1502 gimple_omp_continue_control_def (gs),
1503 gimple_omp_continue_control_use (gs));
1505 else
1507 pp_string (buffer, "#pragma omp continue (");
1508 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1509 spc, flags, false);
1510 pp_comma (buffer);
1511 pp_space (buffer);
1512 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1513 spc, flags, false);
1514 pp_right_paren (buffer);
1518 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1520 static void
1521 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1522 int spc, dump_flags_t flags)
1524 if (flags & TDF_RAW)
1526 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1527 gimple_omp_body (gs));
1528 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1529 dump_gimple_fmt (buffer, spc, flags, " >");
1531 else
1533 pp_string (buffer, "#pragma omp single");
1534 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1535 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1537 newline_and_indent (buffer, spc + 2);
1538 pp_left_brace (buffer);
1539 pp_newline (buffer);
1540 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1541 newline_and_indent (buffer, spc + 2);
1542 pp_right_brace (buffer);
1547 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1549 static void
1550 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1551 int spc, dump_flags_t flags)
1553 const char *kind;
1554 switch (gimple_omp_target_kind (gs))
1556 case GF_OMP_TARGET_KIND_REGION:
1557 kind = "";
1558 break;
1559 case GF_OMP_TARGET_KIND_DATA:
1560 kind = " data";
1561 break;
1562 case GF_OMP_TARGET_KIND_UPDATE:
1563 kind = " update";
1564 break;
1565 case GF_OMP_TARGET_KIND_ENTER_DATA:
1566 kind = " enter data";
1567 break;
1568 case GF_OMP_TARGET_KIND_EXIT_DATA:
1569 kind = " exit data";
1570 break;
1571 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1572 kind = " oacc_kernels";
1573 break;
1574 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1575 kind = " oacc_parallel";
1576 break;
1577 case GF_OMP_TARGET_KIND_OACC_DATA:
1578 kind = " oacc_data";
1579 break;
1580 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1581 kind = " oacc_update";
1582 break;
1583 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1584 kind = " oacc_enter_exit_data";
1585 break;
1586 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1587 kind = " oacc_declare";
1588 break;
1589 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1590 kind = " oacc_host_data";
1591 break;
1592 default:
1593 gcc_unreachable ();
1595 if (flags & TDF_RAW)
1597 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1598 kind, gimple_omp_body (gs));
1599 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1600 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1601 gimple_omp_target_child_fn (gs),
1602 gimple_omp_target_data_arg (gs));
1604 else
1606 pp_string (buffer, "#pragma omp target");
1607 pp_string (buffer, kind);
1608 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1609 if (gimple_omp_target_child_fn (gs))
1611 pp_string (buffer, " [child fn: ");
1612 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1613 spc, flags, false);
1614 pp_string (buffer, " (");
1615 if (gimple_omp_target_data_arg (gs))
1616 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1617 spc, flags, false);
1618 else
1619 pp_string (buffer, "???");
1620 pp_string (buffer, ")]");
1622 gimple_seq body = gimple_omp_body (gs);
1623 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1625 newline_and_indent (buffer, spc + 2);
1626 pp_left_brace (buffer);
1627 pp_newline (buffer);
1628 dump_gimple_seq (buffer, body, spc + 4, flags);
1629 newline_and_indent (buffer, spc + 2);
1630 pp_right_brace (buffer);
1632 else if (body)
1634 pp_newline (buffer);
1635 dump_gimple_seq (buffer, body, spc + 2, flags);
1640 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1642 static void
1643 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1644 dump_flags_t flags)
1646 if (flags & TDF_RAW)
1648 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1649 gimple_omp_body (gs));
1650 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1651 dump_gimple_fmt (buffer, spc, flags, " >");
1653 else
1655 pp_string (buffer, "#pragma omp teams");
1656 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1657 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1659 newline_and_indent (buffer, spc + 2);
1660 pp_character (buffer, '{');
1661 pp_newline (buffer);
1662 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1663 newline_and_indent (buffer, spc + 2);
1664 pp_character (buffer, '}');
1669 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1671 static void
1672 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1673 int spc, dump_flags_t flags)
1675 if (flags & TDF_RAW)
1677 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1678 gimple_omp_body (gs));
1679 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1680 dump_gimple_fmt (buffer, spc, flags, " >");
1682 else
1684 pp_string (buffer, "#pragma omp sections");
1685 if (gimple_omp_sections_control (gs))
1687 pp_string (buffer, " <");
1688 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1689 flags, false);
1690 pp_greater (buffer);
1692 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1693 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1695 newline_and_indent (buffer, spc + 2);
1696 pp_left_brace (buffer);
1697 pp_newline (buffer);
1698 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1699 newline_and_indent (buffer, spc + 2);
1700 pp_right_brace (buffer);
1705 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1706 pretty_printer BUFFER. */
1708 static void
1709 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc,
1710 dump_flags_t flags)
1712 if (flags & TDF_RAW)
1713 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1714 gimple_omp_body (gs));
1715 else
1717 switch (gimple_code (gs))
1719 case GIMPLE_OMP_MASTER:
1720 pp_string (buffer, "#pragma omp master");
1721 break;
1722 case GIMPLE_OMP_TASKGROUP:
1723 pp_string (buffer, "#pragma omp taskgroup");
1724 break;
1725 case GIMPLE_OMP_SECTION:
1726 pp_string (buffer, "#pragma omp section");
1727 break;
1728 case GIMPLE_OMP_GRID_BODY:
1729 pp_string (buffer, "#pragma omp gridified body");
1730 break;
1731 default:
1732 gcc_unreachable ();
1734 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1736 newline_and_indent (buffer, spc + 2);
1737 pp_left_brace (buffer);
1738 pp_newline (buffer);
1739 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1740 newline_and_indent (buffer, spc + 2);
1741 pp_right_brace (buffer);
1746 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1748 static void
1749 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1750 int spc, dump_flags_t flags)
1752 if (flags & TDF_RAW)
1753 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1754 gimple_omp_body (gs));
1755 else
1757 pp_string (buffer, "#pragma omp critical");
1758 if (gimple_omp_critical_name (gs))
1760 pp_string (buffer, " (");
1761 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1762 flags, false);
1763 pp_right_paren (buffer);
1765 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1766 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1768 newline_and_indent (buffer, spc + 2);
1769 pp_left_brace (buffer);
1770 pp_newline (buffer);
1771 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1772 newline_and_indent (buffer, spc + 2);
1773 pp_right_brace (buffer);
1778 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1780 static void
1781 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1782 int spc, dump_flags_t flags)
1784 if (flags & TDF_RAW)
1785 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1786 gimple_omp_body (gs));
1787 else
1789 pp_string (buffer, "#pragma omp ordered");
1790 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1791 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1793 newline_and_indent (buffer, spc + 2);
1794 pp_left_brace (buffer);
1795 pp_newline (buffer);
1796 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1797 newline_and_indent (buffer, spc + 2);
1798 pp_right_brace (buffer);
1803 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1805 static void
1806 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc,
1807 dump_flags_t flags)
1809 if (flags & TDF_RAW)
1811 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1812 (int) gimple_omp_return_nowait_p (gs));
1813 if (gimple_omp_return_lhs (gs))
1814 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1815 gimple_omp_return_lhs (gs));
1816 else
1817 dump_gimple_fmt (buffer, spc, flags, ">");
1819 else
1821 pp_string (buffer, "#pragma omp return");
1822 if (gimple_omp_return_nowait_p (gs))
1823 pp_string (buffer, "(nowait)");
1824 if (gimple_omp_return_lhs (gs))
1826 pp_string (buffer, " (set ");
1827 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1828 spc, flags, false);
1829 pp_character (buffer, ')');
1834 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1836 static void
1837 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1838 int spc, dump_flags_t flags)
1840 unsigned subcode = gimple_transaction_subcode (gs);
1842 if (flags & TDF_RAW)
1844 dump_gimple_fmt (buffer, spc, flags,
1845 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1846 "<%+BODY <%S> >",
1847 gs, subcode, gimple_transaction_label_norm (gs),
1848 gimple_transaction_label_uninst (gs),
1849 gimple_transaction_label_over (gs),
1850 gimple_transaction_body (gs));
1852 else
1854 if (subcode & GTMA_IS_OUTER)
1855 pp_string (buffer, "__transaction_atomic [[outer]]");
1856 else if (subcode & GTMA_IS_RELAXED)
1857 pp_string (buffer, "__transaction_relaxed");
1858 else
1859 pp_string (buffer, "__transaction_atomic");
1860 subcode &= ~GTMA_DECLARATION_MASK;
1862 if (gimple_transaction_body (gs))
1864 newline_and_indent (buffer, spc + 2);
1865 pp_left_brace (buffer);
1866 pp_newline (buffer);
1867 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1868 spc + 4, flags);
1869 newline_and_indent (buffer, spc + 2);
1870 pp_right_brace (buffer);
1872 else
1874 pp_string (buffer, " //");
1875 if (gimple_transaction_label_norm (gs))
1877 pp_string (buffer, " NORM=");
1878 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1879 spc, flags, false);
1881 if (gimple_transaction_label_uninst (gs))
1883 pp_string (buffer, " UNINST=");
1884 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1885 spc, flags, false);
1887 if (gimple_transaction_label_over (gs))
1889 pp_string (buffer, " OVER=");
1890 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1891 spc, flags, false);
1893 if (subcode)
1895 pp_string (buffer, " SUBCODE=[ ");
1896 if (subcode & GTMA_HAVE_ABORT)
1898 pp_string (buffer, "GTMA_HAVE_ABORT ");
1899 subcode &= ~GTMA_HAVE_ABORT;
1901 if (subcode & GTMA_HAVE_LOAD)
1903 pp_string (buffer, "GTMA_HAVE_LOAD ");
1904 subcode &= ~GTMA_HAVE_LOAD;
1906 if (subcode & GTMA_HAVE_STORE)
1908 pp_string (buffer, "GTMA_HAVE_STORE ");
1909 subcode &= ~GTMA_HAVE_STORE;
1911 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1913 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1914 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1916 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1918 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1919 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1921 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1923 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1924 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1926 if (subcode)
1927 pp_printf (buffer, "0x%x ", subcode);
1928 pp_right_bracket (buffer);
1934 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1935 indent. FLAGS specifies details to show in the dump (see TDF_* in
1936 dumpfile.h). */
1938 static void
1939 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, dump_flags_t flags)
1941 unsigned int i, n, f, fields;
1943 if (flags & TDF_RAW)
1945 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1946 gimple_asm_string (gs));
1948 n = gimple_asm_noutputs (gs);
1949 if (n)
1951 newline_and_indent (buffer, spc + 2);
1952 pp_string (buffer, "OUTPUT: ");
1953 for (i = 0; i < n; i++)
1955 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1956 spc, flags, false);
1957 if (i < n - 1)
1958 pp_string (buffer, ", ");
1962 n = gimple_asm_ninputs (gs);
1963 if (n)
1965 newline_and_indent (buffer, spc + 2);
1966 pp_string (buffer, "INPUT: ");
1967 for (i = 0; i < n; i++)
1969 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1970 spc, flags, false);
1971 if (i < n - 1)
1972 pp_string (buffer, ", ");
1976 n = gimple_asm_nclobbers (gs);
1977 if (n)
1979 newline_and_indent (buffer, spc + 2);
1980 pp_string (buffer, "CLOBBER: ");
1981 for (i = 0; i < n; i++)
1983 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1984 spc, flags, false);
1985 if (i < n - 1)
1986 pp_string (buffer, ", ");
1990 n = gimple_asm_nlabels (gs);
1991 if (n)
1993 newline_and_indent (buffer, spc + 2);
1994 pp_string (buffer, "LABEL: ");
1995 for (i = 0; i < n; i++)
1997 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1998 spc, flags, false);
1999 if (i < n - 1)
2000 pp_string (buffer, ", ");
2004 newline_and_indent (buffer, spc);
2005 pp_greater (buffer);
2007 else
2009 pp_string (buffer, "__asm__");
2010 if (gimple_asm_volatile_p (gs))
2011 pp_string (buffer, " __volatile__");
2012 if (gimple_asm_nlabels (gs))
2013 pp_string (buffer, " goto");
2014 pp_string (buffer, "(\"");
2015 pp_string (buffer, gimple_asm_string (gs));
2016 pp_string (buffer, "\"");
2018 if (gimple_asm_nlabels (gs))
2019 fields = 4;
2020 else if (gimple_asm_nclobbers (gs))
2021 fields = 3;
2022 else if (gimple_asm_ninputs (gs))
2023 fields = 2;
2024 else if (gimple_asm_noutputs (gs))
2025 fields = 1;
2026 else
2027 fields = 0;
2029 for (f = 0; f < fields; ++f)
2031 pp_string (buffer, " : ");
2033 switch (f)
2035 case 0:
2036 n = gimple_asm_noutputs (gs);
2037 for (i = 0; i < n; i++)
2039 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2040 spc, flags, false);
2041 if (i < n - 1)
2042 pp_string (buffer, ", ");
2044 break;
2046 case 1:
2047 n = gimple_asm_ninputs (gs);
2048 for (i = 0; i < n; i++)
2050 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2051 spc, flags, false);
2052 if (i < n - 1)
2053 pp_string (buffer, ", ");
2055 break;
2057 case 2:
2058 n = gimple_asm_nclobbers (gs);
2059 for (i = 0; i < n; i++)
2061 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2062 spc, flags, false);
2063 if (i < n - 1)
2064 pp_string (buffer, ", ");
2066 break;
2068 case 3:
2069 n = gimple_asm_nlabels (gs);
2070 for (i = 0; i < n; i++)
2072 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2073 spc, flags, false);
2074 if (i < n - 1)
2075 pp_string (buffer, ", ");
2077 break;
2079 default:
2080 gcc_unreachable ();
2084 pp_string (buffer, ");");
2088 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2089 SPC spaces of indent. */
2091 static void
2092 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2094 if (TREE_CODE (node) != SSA_NAME)
2095 return;
2097 if (POINTER_TYPE_P (TREE_TYPE (node))
2098 && SSA_NAME_PTR_INFO (node))
2100 unsigned int align, misalign;
2101 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2102 pp_string (buffer, "# PT = ");
2103 pp_points_to_solution (buffer, &pi->pt);
2104 newline_and_indent (buffer, spc);
2105 if (get_ptr_info_alignment (pi, &align, &misalign))
2107 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2108 newline_and_indent (buffer, spc);
2112 if (!POINTER_TYPE_P (TREE_TYPE (node))
2113 && SSA_NAME_RANGE_INFO (node))
2115 wide_int min, max, nonzero_bits;
2116 value_range_type range_type = get_range_info (node, &min, &max);
2118 if (range_type == VR_VARYING)
2119 pp_printf (buffer, "# RANGE VR_VARYING");
2120 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2122 pp_printf (buffer, "# RANGE ");
2123 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2124 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2125 pp_printf (buffer, ", ");
2126 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2127 pp_printf (buffer, "]");
2129 nonzero_bits = get_nonzero_bits (node);
2130 if (nonzero_bits != -1)
2132 pp_string (buffer, " NONZERO ");
2133 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2135 newline_and_indent (buffer, spc);
2139 /* As dump_ssaname_info, but dump to FILE. */
2141 void
2142 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2144 pretty_printer buffer;
2145 pp_needs_newline (&buffer) = true;
2146 buffer.buffer->stream = file;
2147 dump_ssaname_info (&buffer, node, spc);
2148 pp_flush (&buffer);
2151 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2152 The caller is responsible for calling pp_flush on BUFFER to finalize
2153 pretty printer. If COMMENT is true, print this after #. */
2155 static void
2156 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2157 dump_flags_t flags)
2159 size_t i;
2160 tree lhs = gimple_phi_result (phi);
2162 if (flags & TDF_ALIAS)
2163 dump_ssaname_info (buffer, lhs, spc);
2165 if (comment)
2166 pp_string (buffer, "# ");
2168 if (flags & TDF_RAW)
2169 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2170 gimple_phi_result (phi));
2171 else
2173 dump_generic_node (buffer, lhs, spc, flags, false);
2174 if (flags & TDF_GIMPLE)
2175 pp_string (buffer, " = __PHI (");
2176 else
2177 pp_string (buffer, " = PHI <");
2179 for (i = 0; i < gimple_phi_num_args (phi); i++)
2181 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2182 dump_location (buffer, gimple_phi_arg_location (phi, i));
2183 if (flags & TDF_GIMPLE)
2185 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2186 gimple *stmt = first_stmt (src);
2187 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2189 pp_string (buffer, "bb_");
2190 pp_decimal_int (buffer, src->index);
2192 else
2193 dump_generic_node (buffer, gimple_label_label (as_a <glabel *> (stmt)), 0, flags,
2194 false);
2195 pp_string (buffer, ": ");
2197 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2198 false);
2199 if (! (flags & TDF_GIMPLE))
2201 pp_left_paren (buffer);
2202 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2203 pp_right_paren (buffer);
2205 if (i < gimple_phi_num_args (phi) - 1)
2206 pp_string (buffer, ", ");
2208 if (flags & TDF_GIMPLE)
2209 pp_string (buffer, ");");
2210 else
2211 pp_greater (buffer);
2215 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2216 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2217 dumpfile.h). */
2219 static void
2220 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2221 int spc, dump_flags_t flags)
2223 if (flags & TDF_RAW)
2225 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2226 gimple_omp_body (gs));
2227 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2228 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2229 gimple_omp_parallel_child_fn (gs),
2230 gimple_omp_parallel_data_arg (gs));
2232 else
2234 gimple_seq body;
2235 pp_string (buffer, "#pragma omp parallel");
2236 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2237 if (gimple_omp_parallel_child_fn (gs))
2239 pp_string (buffer, " [child fn: ");
2240 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2241 spc, flags, false);
2242 pp_string (buffer, " (");
2243 if (gimple_omp_parallel_data_arg (gs))
2244 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2245 spc, flags, false);
2246 else
2247 pp_string (buffer, "???");
2248 pp_string (buffer, ")]");
2250 body = gimple_omp_body (gs);
2251 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2253 newline_and_indent (buffer, spc + 2);
2254 pp_left_brace (buffer);
2255 pp_newline (buffer);
2256 dump_gimple_seq (buffer, body, spc + 4, flags);
2257 newline_and_indent (buffer, spc + 2);
2258 pp_right_brace (buffer);
2260 else if (body)
2262 pp_newline (buffer);
2263 dump_gimple_seq (buffer, body, spc + 2, flags);
2269 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2270 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2271 dumpfile.h). */
2273 static void
2274 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2275 dump_flags_t flags)
2277 if (flags & TDF_RAW)
2279 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2280 gimple_omp_body (gs));
2281 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2282 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2283 gimple_omp_task_child_fn (gs),
2284 gimple_omp_task_data_arg (gs),
2285 gimple_omp_task_copy_fn (gs),
2286 gimple_omp_task_arg_size (gs),
2287 gimple_omp_task_arg_size (gs));
2289 else
2291 gimple_seq body;
2292 if (gimple_omp_task_taskloop_p (gs))
2293 pp_string (buffer, "#pragma omp taskloop");
2294 else
2295 pp_string (buffer, "#pragma omp task");
2296 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2297 if (gimple_omp_task_child_fn (gs))
2299 pp_string (buffer, " [child fn: ");
2300 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2301 spc, flags, false);
2302 pp_string (buffer, " (");
2303 if (gimple_omp_task_data_arg (gs))
2304 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2305 spc, flags, false);
2306 else
2307 pp_string (buffer, "???");
2308 pp_string (buffer, ")]");
2310 body = gimple_omp_body (gs);
2311 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2313 newline_and_indent (buffer, spc + 2);
2314 pp_left_brace (buffer);
2315 pp_newline (buffer);
2316 dump_gimple_seq (buffer, body, spc + 4, flags);
2317 newline_and_indent (buffer, spc + 2);
2318 pp_right_brace (buffer);
2320 else if (body)
2322 pp_newline (buffer);
2323 dump_gimple_seq (buffer, body, spc + 2, flags);
2329 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2330 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2331 in dumpfile.h). */
2333 static void
2334 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2335 int spc, dump_flags_t flags)
2337 if (flags & TDF_RAW)
2339 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2340 gimple_omp_atomic_load_lhs (gs),
2341 gimple_omp_atomic_load_rhs (gs));
2343 else
2345 pp_string (buffer, "#pragma omp atomic_load");
2346 if (gimple_omp_atomic_seq_cst_p (gs))
2347 pp_string (buffer, " seq_cst");
2348 if (gimple_omp_atomic_need_value_p (gs))
2349 pp_string (buffer, " [needed]");
2350 newline_and_indent (buffer, spc + 2);
2351 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2352 spc, flags, false);
2353 pp_space (buffer);
2354 pp_equal (buffer);
2355 pp_space (buffer);
2356 pp_star (buffer);
2357 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2358 spc, flags, false);
2362 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2363 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2364 in dumpfile.h). */
2366 static void
2367 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2368 gomp_atomic_store *gs, int spc,
2369 dump_flags_t flags)
2371 if (flags & TDF_RAW)
2373 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2374 gimple_omp_atomic_store_val (gs));
2376 else
2378 pp_string (buffer, "#pragma omp atomic_store ");
2379 if (gimple_omp_atomic_seq_cst_p (gs))
2380 pp_string (buffer, "seq_cst ");
2381 if (gimple_omp_atomic_need_value_p (gs))
2382 pp_string (buffer, "[needed] ");
2383 pp_left_paren (buffer);
2384 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2385 spc, flags, false);
2386 pp_right_paren (buffer);
2391 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2392 FLAGS are as in pp_gimple_stmt_1. */
2394 static void
2395 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc,
2396 dump_flags_t flags)
2398 tree vdef = gimple_vdef (gs);
2399 tree vuse = gimple_vuse (gs);
2401 if (vdef != NULL_TREE)
2403 pp_string (buffer, "# ");
2404 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2405 pp_string (buffer, " = VDEF <");
2406 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2407 pp_greater (buffer);
2408 newline_and_indent (buffer, spc);
2410 else if (vuse != NULL_TREE)
2412 pp_string (buffer, "# VUSE <");
2413 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2414 pp_greater (buffer);
2415 newline_and_indent (buffer, spc);
2420 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2421 spaces of indent. FLAGS specifies details to show in the dump (see
2422 TDF_* in dumpfile.h). The caller is responsible for calling
2423 pp_flush on BUFFER to finalize the pretty printer. */
2425 void
2426 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc,
2427 dump_flags_t flags)
2429 if (!gs)
2430 return;
2432 if (flags & TDF_STMTADDR)
2433 pp_printf (buffer, "<&%p> ", (void *) gs);
2435 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2436 dump_location (buffer, gimple_location (gs));
2438 if (flags & TDF_EH)
2440 int lp_nr = lookup_stmt_eh_lp (gs);
2441 if (lp_nr > 0)
2442 pp_printf (buffer, "[LP %d] ", lp_nr);
2443 else if (lp_nr < 0)
2444 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2447 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2448 && gimple_has_mem_ops (gs))
2449 dump_gimple_mem_ops (buffer, gs, spc, flags);
2451 if (gimple_has_lhs (gs)
2452 && (flags & TDF_ALIAS))
2453 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2455 switch (gimple_code (gs))
2457 case GIMPLE_ASM:
2458 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2459 break;
2461 case GIMPLE_ASSIGN:
2462 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2463 break;
2465 case GIMPLE_BIND:
2466 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2467 break;
2469 case GIMPLE_CALL:
2470 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2471 break;
2473 case GIMPLE_COND:
2474 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2475 break;
2477 case GIMPLE_LABEL:
2478 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2479 break;
2481 case GIMPLE_GOTO:
2482 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2483 break;
2485 case GIMPLE_NOP:
2486 pp_string (buffer, "GIMPLE_NOP");
2487 break;
2489 case GIMPLE_RETURN:
2490 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2491 break;
2493 case GIMPLE_SWITCH:
2494 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2495 break;
2497 case GIMPLE_TRY:
2498 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2499 break;
2501 case GIMPLE_PHI:
2502 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2503 break;
2505 case GIMPLE_OMP_PARALLEL:
2506 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2507 flags);
2508 break;
2510 case GIMPLE_OMP_TASK:
2511 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2512 break;
2514 case GIMPLE_OMP_ATOMIC_LOAD:
2515 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2516 spc, flags);
2517 break;
2519 case GIMPLE_OMP_ATOMIC_STORE:
2520 dump_gimple_omp_atomic_store (buffer,
2521 as_a <gomp_atomic_store *> (gs),
2522 spc, flags);
2523 break;
2525 case GIMPLE_OMP_FOR:
2526 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2527 break;
2529 case GIMPLE_OMP_CONTINUE:
2530 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2531 flags);
2532 break;
2534 case GIMPLE_OMP_SINGLE:
2535 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2536 flags);
2537 break;
2539 case GIMPLE_OMP_TARGET:
2540 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2541 flags);
2542 break;
2544 case GIMPLE_OMP_TEAMS:
2545 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2546 flags);
2547 break;
2549 case GIMPLE_OMP_RETURN:
2550 dump_gimple_omp_return (buffer, gs, spc, flags);
2551 break;
2553 case GIMPLE_OMP_SECTIONS:
2554 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2555 spc, flags);
2556 break;
2558 case GIMPLE_OMP_SECTIONS_SWITCH:
2559 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2560 break;
2562 case GIMPLE_OMP_MASTER:
2563 case GIMPLE_OMP_TASKGROUP:
2564 case GIMPLE_OMP_SECTION:
2565 case GIMPLE_OMP_GRID_BODY:
2566 dump_gimple_omp_block (buffer, gs, spc, flags);
2567 break;
2569 case GIMPLE_OMP_ORDERED:
2570 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2571 flags);
2572 break;
2574 case GIMPLE_OMP_CRITICAL:
2575 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2576 flags);
2577 break;
2579 case GIMPLE_CATCH:
2580 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2581 break;
2583 case GIMPLE_EH_FILTER:
2584 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2585 break;
2587 case GIMPLE_EH_MUST_NOT_THROW:
2588 dump_gimple_eh_must_not_throw (buffer,
2589 as_a <geh_mnt *> (gs),
2590 spc, flags);
2591 break;
2593 case GIMPLE_EH_ELSE:
2594 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2595 break;
2597 case GIMPLE_RESX:
2598 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2599 break;
2601 case GIMPLE_EH_DISPATCH:
2602 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2603 flags);
2604 break;
2606 case GIMPLE_DEBUG:
2607 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2608 break;
2610 case GIMPLE_PREDICT:
2611 pp_string (buffer, "// predicted ");
2612 if (gimple_predict_outcome (gs))
2613 pp_string (buffer, "likely by ");
2614 else
2615 pp_string (buffer, "unlikely by ");
2616 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2617 pp_string (buffer, " predictor.");
2618 break;
2620 case GIMPLE_TRANSACTION:
2621 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2622 flags);
2623 break;
2625 default:
2626 GIMPLE_NIY;
2631 /* Dumps header of basic block BB to OUTF indented by INDENT
2632 spaces and details described by flags. */
2634 static void
2635 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
2636 dump_flags_t flags)
2638 if (flags & TDF_BLOCKS)
2640 if (flags & TDF_LINENO)
2642 gimple_stmt_iterator gsi;
2644 if (flags & TDF_COMMENT)
2645 fputs (";; ", outf);
2647 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2648 if (!is_gimple_debug (gsi_stmt (gsi))
2649 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2651 fprintf (outf, "%*sstarting at line %d",
2652 indent, "", get_lineno (gsi_stmt (gsi)));
2653 break;
2655 if (bb->discriminator)
2656 fprintf (outf, ", discriminator %i", bb->discriminator);
2657 fputc ('\n', outf);
2660 else
2662 gimple *stmt = first_stmt (bb);
2663 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2665 if (flags & TDF_GIMPLE)
2666 fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
2667 else
2668 fprintf (outf, "%*s<bb %d> %s:\n",
2669 indent, "", bb->index, dump_probability (bb->frequency));
2675 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2676 spaces. */
2678 static void
2679 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2680 basic_block bb ATTRIBUTE_UNUSED,
2681 int indent ATTRIBUTE_UNUSED,
2682 dump_flags_t flags ATTRIBUTE_UNUSED)
2684 /* There is currently no GIMPLE-specific basic block info to dump. */
2685 return;
2689 /* Dump PHI nodes of basic block BB to BUFFER with details described
2690 by FLAGS and indented by INDENT spaces. */
2692 static void
2693 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
2694 dump_flags_t flags)
2696 gphi_iterator i;
2698 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2700 gphi *phi = i.phi ();
2701 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2703 INDENT (indent);
2704 dump_gimple_phi (buffer, phi, indent,
2705 (flags & TDF_GIMPLE) ? false : true, flags);
2706 pp_newline (buffer);
2712 /* Dump jump to basic block BB that is represented implicitly in the cfg
2713 to BUFFER. */
2715 static void
2716 pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
2718 if (flags & TDF_GIMPLE)
2720 pp_string (buffer, "goto bb_");
2721 pp_decimal_int (buffer, e->dest->index);
2722 pp_semicolon (buffer);
2724 else
2726 gimple *stmt = first_stmt (e->dest);
2728 pp_string (buffer, "goto <bb ");
2729 pp_decimal_int (buffer, e->dest->index);
2730 pp_greater (buffer);
2731 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2733 pp_string (buffer, " (");
2734 dump_generic_node (buffer,
2735 gimple_label_label (as_a <glabel *> (stmt)),
2736 0, 0, false);
2737 pp_right_paren (buffer);
2738 pp_semicolon (buffer);
2740 else
2741 pp_semicolon (buffer);
2743 dump_edge_probability (buffer, e);
2748 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2749 by INDENT spaces, with details given by FLAGS. */
2751 static void
2752 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2753 dump_flags_t flags)
2755 edge e;
2756 gimple *stmt;
2758 stmt = last_stmt (bb);
2760 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2762 edge true_edge, false_edge;
2764 /* When we are emitting the code or changing CFG, it is possible that
2765 the edges are not yet created. When we are using debug_bb in such
2766 a situation, we do not want it to crash. */
2767 if (EDGE_COUNT (bb->succs) != 2)
2768 return;
2769 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2771 INDENT (indent + 2);
2772 pp_cfg_jump (buffer, true_edge, flags);
2773 newline_and_indent (buffer, indent);
2774 pp_string (buffer, "else");
2775 newline_and_indent (buffer, indent + 2);
2776 pp_cfg_jump (buffer, false_edge, flags);
2777 pp_newline (buffer);
2778 return;
2781 /* If there is a fallthru edge, we may need to add an artificial
2782 goto to the dump. */
2783 e = find_fallthru_edge (bb->succs);
2785 if (e && e->dest != bb->next_bb)
2787 INDENT (indent);
2789 if ((flags & TDF_LINENO)
2790 && e->goto_locus != UNKNOWN_LOCATION)
2791 dump_location (buffer, e->goto_locus);
2793 pp_cfg_jump (buffer, e, flags);
2794 pp_newline (buffer);
2799 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2800 indented by INDENT spaces. */
2802 static void
2803 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2804 dump_flags_t flags)
2806 gimple_stmt_iterator gsi;
2807 gimple *stmt;
2808 int label_indent = indent - 2;
2810 if (label_indent < 0)
2811 label_indent = 0;
2813 dump_phi_nodes (buffer, bb, indent, flags);
2815 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2817 int curr_indent;
2819 stmt = gsi_stmt (gsi);
2821 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2823 INDENT (curr_indent);
2824 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2825 pp_newline_and_flush (buffer);
2826 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2827 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2828 pp_buffer (buffer)->stream, stmt);
2831 dump_implicit_edges (buffer, bb, indent, flags);
2832 pp_flush (buffer);
2836 /* Dumps basic block BB to FILE with details described by FLAGS and
2837 indented by INDENT spaces. */
2839 void
2840 gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
2842 dump_gimple_bb_header (file, bb, indent, flags);
2843 if (bb->index >= NUM_FIXED_BLOCKS)
2845 pretty_printer buffer;
2846 pp_needs_newline (&buffer) = true;
2847 buffer.buffer->stream = file;
2848 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2850 dump_gimple_bb_footer (file, bb, indent, flags);
2853 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2854 no indentation, for use as a label of a DOT graph record-node.
2855 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2856 histogram dumping doesn't know about pretty-printers. */
2858 void
2859 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2861 pp_printf (pp, "<bb %d>:\n", bb->index);
2862 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2864 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2865 gsi_next (&gsi))
2867 gphi *phi = gsi.phi ();
2868 if (!virtual_operand_p (gimple_phi_result (phi))
2869 || (dump_flags & TDF_VOPS))
2871 pp_bar (pp);
2872 pp_write_text_to_stream (pp);
2873 pp_string (pp, "# ");
2874 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2875 pp_newline (pp);
2876 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2880 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2881 gsi_next (&gsi))
2883 gimple *stmt = gsi_stmt (gsi);
2884 pp_bar (pp);
2885 pp_write_text_to_stream (pp);
2886 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2887 pp_newline (pp);
2888 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2890 dump_implicit_edges (pp, bb, 0, dump_flags);
2891 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);