Add Cortex-A15 tuning to gcc.dg/uninit-pred-8_a.c
[official-gcc.git] / gcc / gimple-pretty-print.c
blob91c839d327dd83e469ca647d55f900300dc0ea24
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 "backend.h"
26 #include "tree.h"
27 #include "gimple.h"
28 #include "gimple-predict.h"
29 #include "ssa.h"
30 #include "cgraph.h"
31 #include "gimple-pretty-print.h"
32 #include "internal-fn.h"
33 #include "tree-eh.h"
34 #include "gimple-iterator.h"
35 #include "tree-cfg.h"
36 #include "dumpfile.h" /* for dump_flags */
37 #include "value-prof.h"
38 #include "trans-mem.h"
39 #include "cfganal.h"
40 #include "asan.h"
42 #define INDENT(SPACE) \
43 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
45 #define GIMPLE_NIY do_niy (buffer,gs)
47 /* Try to print on BUFFER a default message for the unrecognized
48 gimple statement GS. */
50 static void
51 do_niy (pretty_printer *buffer, gimple *gs)
53 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
54 gimple_code_name[(int) gimple_code (gs)]);
58 /* Emit a newline and SPC indentation spaces to BUFFER. */
60 static void
61 newline_and_indent (pretty_printer *buffer, int spc)
63 pp_newline (buffer);
64 INDENT (spc);
68 /* Print the GIMPLE statement GS on stderr. */
70 DEBUG_FUNCTION void
71 debug_gimple_stmt (gimple *gs)
73 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
77 /* Return formatted string of a VALUE probability
78 (biased by REG_BR_PROB_BASE). Returned string is allocated
79 by xstrdup_for_dump. */
81 static const char *
82 dump_probability (int value)
84 float minimum = 0.01f;
86 gcc_assert (0 <= value && value <= REG_BR_PROB_BASE);
87 float fvalue = value * 100.0f / REG_BR_PROB_BASE;
88 if (fvalue < minimum && value > 0)
89 return "[0.01%]";
91 char *buf;
92 asprintf (&buf, "[%.2f%%]", fvalue);
93 const char *ret = xstrdup_for_dump (buf);
94 free (buf);
96 return ret;
99 /* Dump E probability to BUFFER. */
101 static void
102 dump_edge_probability (pretty_printer *buffer, edge e)
104 pp_scalar (buffer, " %s", dump_probability (e->probability));
107 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
108 FLAGS as in pp_gimple_stmt_1. */
110 void
111 print_gimple_stmt (FILE *file, gimple *g, int spc, int flags)
113 pretty_printer buffer;
114 pp_needs_newline (&buffer) = true;
115 buffer.buffer->stream = file;
116 pp_gimple_stmt_1 (&buffer, g, spc, flags);
117 pp_newline_and_flush (&buffer);
120 DEBUG_FUNCTION void
121 debug (gimple &ref)
123 print_gimple_stmt (stderr, &ref, 0, 0);
126 DEBUG_FUNCTION void
127 debug (gimple *ptr)
129 if (ptr)
130 debug (*ptr);
131 else
132 fprintf (stderr, "<nil>\n");
136 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
137 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
138 of the statement. */
140 void
141 print_gimple_expr (FILE *file, gimple *g, int spc, int flags)
143 flags |= TDF_RHS_ONLY;
144 pretty_printer buffer;
145 pp_needs_newline (&buffer) = true;
146 buffer.buffer->stream = file;
147 pp_gimple_stmt_1 (&buffer, g, spc, flags);
148 pp_flush (&buffer);
152 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
153 spaces and FLAGS as in pp_gimple_stmt_1.
154 The caller is responsible for calling pp_flush on BUFFER to finalize
155 the pretty printer. */
157 static void
158 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
160 gimple_stmt_iterator i;
162 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
164 gimple *gs = gsi_stmt (i);
165 INDENT (spc);
166 pp_gimple_stmt_1 (buffer, gs, spc, flags);
167 if (!gsi_one_before_end_p (i))
168 pp_newline (buffer);
173 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
174 FLAGS as in pp_gimple_stmt_1. */
176 void
177 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
179 pretty_printer buffer;
180 pp_needs_newline (&buffer) = true;
181 buffer.buffer->stream = file;
182 dump_gimple_seq (&buffer, seq, spc, flags);
183 pp_newline_and_flush (&buffer);
187 /* Print the GIMPLE sequence SEQ on stderr. */
189 DEBUG_FUNCTION void
190 debug_gimple_seq (gimple_seq seq)
192 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
196 /* A simple helper to pretty-print some of the gimple tuples in the printf
197 style. The format modifiers are preceded by '%' and are:
198 'G' - outputs a string corresponding to the code of the given gimple,
199 'S' - outputs a gimple_seq with indent of spc + 2,
200 'T' - outputs the tree t,
201 'd' - outputs an int as a decimal,
202 's' - outputs a string,
203 'n' - outputs a newline,
204 'x' - outputs an int as hexadecimal,
205 '+' - increases indent by 2 then outputs a newline,
206 '-' - decreases indent by 2 then outputs a newline. */
208 static void
209 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
210 const char *fmt, ...)
212 va_list args;
213 const char *c;
214 const char *tmp;
216 va_start (args, fmt);
217 for (c = fmt; *c; c++)
219 if (*c == '%')
221 gimple_seq seq;
222 tree t;
223 gimple *g;
224 switch (*++c)
226 case 'G':
227 g = va_arg (args, gimple *);
228 tmp = gimple_code_name[gimple_code (g)];
229 pp_string (buffer, tmp);
230 break;
232 case 'S':
233 seq = va_arg (args, gimple_seq);
234 pp_newline (buffer);
235 dump_gimple_seq (buffer, seq, spc + 2, flags);
236 newline_and_indent (buffer, spc);
237 break;
239 case 'T':
240 t = va_arg (args, tree);
241 if (t == NULL_TREE)
242 pp_string (buffer, "NULL");
243 else
244 dump_generic_node (buffer, t, spc, flags, false);
245 break;
247 case 'd':
248 pp_decimal_int (buffer, va_arg (args, int));
249 break;
251 case 's':
252 pp_string (buffer, va_arg (args, char *));
253 break;
255 case 'n':
256 newline_and_indent (buffer, spc);
257 break;
259 case 'x':
260 pp_scalar (buffer, "%x", va_arg (args, int));
261 break;
263 case '+':
264 spc += 2;
265 newline_and_indent (buffer, spc);
266 break;
268 case '-':
269 spc -= 2;
270 newline_and_indent (buffer, spc);
271 break;
273 default:
274 gcc_unreachable ();
277 else
278 pp_character (buffer, *c);
280 va_end (args);
284 /* Helper for dump_gimple_assign. Print the unary RHS of the
285 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
287 static void
288 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
290 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
291 tree lhs = gimple_assign_lhs (gs);
292 tree rhs = gimple_assign_rhs1 (gs);
294 switch (rhs_code)
296 case VIEW_CONVERT_EXPR:
297 case ASSERT_EXPR:
298 dump_generic_node (buffer, rhs, spc, flags, false);
299 break;
301 case FIXED_CONVERT_EXPR:
302 case ADDR_SPACE_CONVERT_EXPR:
303 case FIX_TRUNC_EXPR:
304 case FLOAT_EXPR:
305 CASE_CONVERT:
306 pp_left_paren (buffer);
307 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
308 pp_string (buffer, ") ");
309 if (op_prio (rhs) < op_code_prio (rhs_code))
311 pp_left_paren (buffer);
312 dump_generic_node (buffer, rhs, spc, flags, false);
313 pp_right_paren (buffer);
315 else
316 dump_generic_node (buffer, rhs, spc, flags, false);
317 break;
319 case PAREN_EXPR:
320 pp_string (buffer, "((");
321 dump_generic_node (buffer, rhs, spc, flags, false);
322 pp_string (buffer, "))");
323 break;
325 case ABS_EXPR:
326 pp_string (buffer, "ABS_EXPR <");
327 dump_generic_node (buffer, rhs, spc, flags, false);
328 pp_greater (buffer);
329 break;
331 default:
332 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
333 || TREE_CODE_CLASS (rhs_code) == tcc_constant
334 || TREE_CODE_CLASS (rhs_code) == tcc_reference
335 || rhs_code == SSA_NAME
336 || rhs_code == ADDR_EXPR
337 || rhs_code == CONSTRUCTOR)
339 dump_generic_node (buffer, rhs, spc, flags, false);
340 break;
342 else if (rhs_code == BIT_NOT_EXPR)
343 pp_complement (buffer);
344 else if (rhs_code == TRUTH_NOT_EXPR)
345 pp_exclamation (buffer);
346 else if (rhs_code == NEGATE_EXPR)
347 pp_minus (buffer);
348 else
350 pp_left_bracket (buffer);
351 pp_string (buffer, get_tree_code_name (rhs_code));
352 pp_string (buffer, "] ");
355 if (op_prio (rhs) < op_code_prio (rhs_code))
357 pp_left_paren (buffer);
358 dump_generic_node (buffer, rhs, spc, flags, false);
359 pp_right_paren (buffer);
361 else
362 dump_generic_node (buffer, rhs, spc, flags, false);
363 break;
368 /* Helper for dump_gimple_assign. Print the binary RHS of the
369 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
371 static void
372 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
374 const char *p;
375 enum tree_code code = gimple_assign_rhs_code (gs);
376 switch (code)
378 case COMPLEX_EXPR:
379 case MIN_EXPR:
380 case MAX_EXPR:
381 case VEC_WIDEN_MULT_HI_EXPR:
382 case VEC_WIDEN_MULT_LO_EXPR:
383 case VEC_WIDEN_MULT_EVEN_EXPR:
384 case VEC_WIDEN_MULT_ODD_EXPR:
385 case VEC_PACK_TRUNC_EXPR:
386 case VEC_PACK_SAT_EXPR:
387 case VEC_PACK_FIX_TRUNC_EXPR:
388 case VEC_WIDEN_LSHIFT_HI_EXPR:
389 case VEC_WIDEN_LSHIFT_LO_EXPR:
390 for (p = get_tree_code_name (code); *p; p++)
391 pp_character (buffer, TOUPPER (*p));
392 pp_string (buffer, " <");
393 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
394 pp_string (buffer, ", ");
395 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
396 pp_greater (buffer);
397 break;
399 default:
400 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
402 pp_left_paren (buffer);
403 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
404 false);
405 pp_right_paren (buffer);
407 else
408 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
409 pp_space (buffer);
410 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
411 pp_space (buffer);
412 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
414 pp_left_paren (buffer);
415 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
416 false);
417 pp_right_paren (buffer);
419 else
420 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
424 /* Helper for dump_gimple_assign. Print the ternary RHS of the
425 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
427 static void
428 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
430 const char *p;
431 enum tree_code code = gimple_assign_rhs_code (gs);
432 switch (code)
434 case WIDEN_MULT_PLUS_EXPR:
435 case WIDEN_MULT_MINUS_EXPR:
436 for (p = get_tree_code_name (code); *p; p++)
437 pp_character (buffer, TOUPPER (*p));
438 pp_string (buffer, " <");
439 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
440 pp_string (buffer, ", ");
441 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
442 pp_string (buffer, ", ");
443 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
444 pp_greater (buffer);
445 break;
447 case FMA_EXPR:
448 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
449 pp_string (buffer, " * ");
450 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
451 pp_string (buffer, " + ");
452 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
453 break;
455 case DOT_PROD_EXPR:
456 pp_string (buffer, "DOT_PROD_EXPR <");
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 SAD_EXPR:
466 pp_string (buffer, "SAD_EXPR <");
467 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
468 pp_string (buffer, ", ");
469 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
470 pp_string (buffer, ", ");
471 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
472 pp_greater (buffer);
473 break;
475 case VEC_PERM_EXPR:
476 pp_string (buffer, "VEC_PERM_EXPR <");
477 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
478 pp_string (buffer, ", ");
479 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
480 pp_string (buffer, ", ");
481 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
482 pp_greater (buffer);
483 break;
485 case REALIGN_LOAD_EXPR:
486 pp_string (buffer, "REALIGN_LOAD <");
487 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
488 pp_string (buffer, ", ");
489 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
490 pp_string (buffer, ", ");
491 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
492 pp_greater (buffer);
493 break;
495 case COND_EXPR:
496 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
497 pp_string (buffer, " ? ");
498 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
499 pp_string (buffer, " : ");
500 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
501 break;
503 case VEC_COND_EXPR:
504 pp_string (buffer, "VEC_COND_EXPR <");
505 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
506 pp_string (buffer, ", ");
507 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
508 pp_string (buffer, ", ");
509 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
510 pp_greater (buffer);
511 break;
513 case BIT_INSERT_EXPR:
514 pp_string (buffer, "BIT_INSERT_EXPR <");
515 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
516 pp_string (buffer, ", ");
517 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
518 pp_string (buffer, ", ");
519 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
520 pp_string (buffer, " (");
521 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
522 pp_decimal_int (buffer,
523 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
524 else
525 dump_generic_node (buffer,
526 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
527 spc, flags, false);
528 pp_string (buffer, " bits)>");
529 break;
531 default:
532 gcc_unreachable ();
537 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
538 pp_gimple_stmt_1. */
540 static void
541 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
543 if (flags & TDF_RAW)
545 tree arg1 = NULL;
546 tree arg2 = NULL;
547 tree arg3 = NULL;
548 switch (gimple_num_ops (gs))
550 case 4:
551 arg3 = gimple_assign_rhs3 (gs);
552 /* FALLTHRU */
553 case 3:
554 arg2 = gimple_assign_rhs2 (gs);
555 /* FALLTHRU */
556 case 2:
557 arg1 = gimple_assign_rhs1 (gs);
558 break;
559 default:
560 gcc_unreachable ();
563 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
564 get_tree_code_name (gimple_assign_rhs_code (gs)),
565 gimple_assign_lhs (gs), arg1, arg2, arg3);
567 else
569 if (!(flags & TDF_RHS_ONLY))
571 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
572 pp_space (buffer);
573 pp_equal (buffer);
575 if (gimple_assign_nontemporal_move_p (gs))
576 pp_string (buffer, "{nt}");
578 if (gimple_has_volatile_ops (gs))
579 pp_string (buffer, "{v}");
581 pp_space (buffer);
584 if (gimple_num_ops (gs) == 2)
585 dump_unary_rhs (buffer, gs, spc, flags);
586 else if (gimple_num_ops (gs) == 3)
587 dump_binary_rhs (buffer, gs, spc, flags);
588 else if (gimple_num_ops (gs) == 4)
589 dump_ternary_rhs (buffer, gs, spc, flags);
590 else
591 gcc_unreachable ();
592 if (!(flags & TDF_RHS_ONLY))
593 pp_semicolon (buffer);
598 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
599 pp_gimple_stmt_1. */
601 static void
602 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
604 tree t, t2;
606 t = gimple_return_retval (gs);
607 t2 = gimple_return_retbnd (gs);
608 if (flags & TDF_RAW)
609 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
610 else
612 pp_string (buffer, "return");
613 if (t)
615 pp_space (buffer);
616 dump_generic_node (buffer, t, spc, flags, false);
618 if (t2)
620 pp_string (buffer, ", ");
621 dump_generic_node (buffer, t2, spc, flags, false);
623 pp_semicolon (buffer);
628 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
629 dump_gimple_call. */
631 static void
632 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
634 size_t i = 0;
636 /* Pretty print first arg to certain internal fns. */
637 if (gimple_call_internal_p (gs))
639 const char *const *enums = NULL;
640 unsigned limit = 0;
642 switch (gimple_call_internal_fn (gs))
644 case IFN_UNIQUE:
645 #define DEF(X) #X
646 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
647 #undef DEF
648 enums = unique_args;
650 limit = ARRAY_SIZE (unique_args);
651 break;
653 case IFN_GOACC_LOOP:
654 #define DEF(X) #X
655 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
656 #undef DEF
657 enums = loop_args;
658 limit = ARRAY_SIZE (loop_args);
659 break;
661 case IFN_GOACC_REDUCTION:
662 #define DEF(X) #X
663 static const char *const reduction_args[]
664 = {IFN_GOACC_REDUCTION_CODES};
665 #undef DEF
666 enums = reduction_args;
667 limit = ARRAY_SIZE (reduction_args);
668 break;
670 case IFN_ASAN_MARK:
671 #define DEF(X) #X
672 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
673 #undef DEF
674 enums = asan_mark_args;
675 limit = ARRAY_SIZE (asan_mark_args);
676 break;
678 default:
679 break;
681 if (limit)
683 tree arg0 = gimple_call_arg (gs, 0);
684 HOST_WIDE_INT v;
686 if (TREE_CODE (arg0) == INTEGER_CST
687 && tree_fits_shwi_p (arg0)
688 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
690 i++;
691 pp_string (buffer, enums[v]);
696 for (; i < gimple_call_num_args (gs); i++)
698 if (i)
699 pp_string (buffer, ", ");
700 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
703 if (gimple_call_va_arg_pack_p (gs))
705 if (i)
706 pp_string (buffer, ", ");
708 pp_string (buffer, "__builtin_va_arg_pack ()");
712 /* Dump the points-to solution *PT to BUFFER. */
714 static void
715 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
717 if (pt->anything)
719 pp_string (buffer, "anything ");
720 return;
722 if (pt->nonlocal)
723 pp_string (buffer, "nonlocal ");
724 if (pt->escaped)
725 pp_string (buffer, "escaped ");
726 if (pt->ipa_escaped)
727 pp_string (buffer, "unit-escaped ");
728 if (pt->null)
729 pp_string (buffer, "null ");
730 if (pt->vars
731 && !bitmap_empty_p (pt->vars))
733 bitmap_iterator bi;
734 unsigned i;
735 pp_string (buffer, "{ ");
736 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
738 pp_string (buffer, "D.");
739 pp_decimal_int (buffer, i);
740 pp_space (buffer);
742 pp_right_brace (buffer);
743 if (pt->vars_contains_nonlocal
744 || pt->vars_contains_escaped
745 || pt->vars_contains_escaped_heap
746 || pt->vars_contains_restrict)
748 const char *comma = "";
749 pp_string (buffer, " (");
750 if (pt->vars_contains_nonlocal)
752 pp_string (buffer, "nonlocal");
753 comma = ", ";
755 if (pt->vars_contains_escaped)
757 pp_string (buffer, comma);
758 pp_string (buffer, "escaped");
759 comma = ", ";
761 if (pt->vars_contains_escaped_heap)
763 pp_string (buffer, comma);
764 pp_string (buffer, "escaped heap");
765 comma = ", ";
767 if (pt->vars_contains_restrict)
769 pp_string (buffer, comma);
770 pp_string (buffer, "restrict");
771 comma = ", ";
773 if (pt->vars_contains_interposable)
775 pp_string (buffer, comma);
776 pp_string (buffer, "interposable");
778 pp_string (buffer, ")");
784 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
785 pp_gimple_stmt_1. */
787 static void
788 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
790 tree lhs = gimple_call_lhs (gs);
791 tree fn = gimple_call_fn (gs);
793 if (flags & TDF_ALIAS)
795 struct pt_solution *pt;
796 pt = gimple_call_use_set (gs);
797 if (!pt_solution_empty_p (pt))
799 pp_string (buffer, "# USE = ");
800 pp_points_to_solution (buffer, pt);
801 newline_and_indent (buffer, spc);
803 pt = gimple_call_clobber_set (gs);
804 if (!pt_solution_empty_p (pt))
806 pp_string (buffer, "# CLB = ");
807 pp_points_to_solution (buffer, pt);
808 newline_and_indent (buffer, spc);
812 if (flags & TDF_RAW)
814 if (gimple_call_internal_p (gs))
815 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
816 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
817 else
818 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
819 if (gimple_call_num_args (gs) > 0)
821 pp_string (buffer, ", ");
822 dump_gimple_call_args (buffer, gs, flags);
824 pp_greater (buffer);
826 else
828 if (lhs && !(flags & TDF_RHS_ONLY))
830 dump_generic_node (buffer, lhs, spc, flags, false);
831 pp_string (buffer, " =");
833 if (gimple_has_volatile_ops (gs))
834 pp_string (buffer, "{v}");
836 pp_space (buffer);
838 if (gimple_call_internal_p (gs))
839 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
840 else
841 print_call_name (buffer, fn, flags);
842 pp_string (buffer, " (");
843 dump_gimple_call_args (buffer, gs, flags);
844 pp_right_paren (buffer);
845 if (!(flags & TDF_RHS_ONLY))
846 pp_semicolon (buffer);
849 if (gimple_call_chain (gs))
851 pp_string (buffer, " [static-chain: ");
852 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
853 pp_right_bracket (buffer);
856 if (gimple_call_return_slot_opt_p (gs))
857 pp_string (buffer, " [return slot optimization]");
858 if (gimple_call_tail_p (gs))
859 pp_string (buffer, " [tail call]");
860 if (gimple_call_must_tail_p (gs))
861 pp_string (buffer, " [must tail call]");
863 if (fn == NULL)
864 return;
866 /* Dump the arguments of _ITM_beginTransaction sanely. */
867 if (TREE_CODE (fn) == ADDR_EXPR)
868 fn = TREE_OPERAND (fn, 0);
869 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
870 pp_string (buffer, " [tm-clone]");
871 if (TREE_CODE (fn) == FUNCTION_DECL
872 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
873 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
874 && gimple_call_num_args (gs) > 0)
876 tree t = gimple_call_arg (gs, 0);
877 unsigned HOST_WIDE_INT props;
878 gcc_assert (TREE_CODE (t) == INTEGER_CST);
880 pp_string (buffer, " [ ");
882 /* Get the transaction code properties. */
883 props = TREE_INT_CST_LOW (t);
885 if (props & PR_INSTRUMENTEDCODE)
886 pp_string (buffer, "instrumentedCode ");
887 if (props & PR_UNINSTRUMENTEDCODE)
888 pp_string (buffer, "uninstrumentedCode ");
889 if (props & PR_HASNOXMMUPDATE)
890 pp_string (buffer, "hasNoXMMUpdate ");
891 if (props & PR_HASNOABORT)
892 pp_string (buffer, "hasNoAbort ");
893 if (props & PR_HASNOIRREVOCABLE)
894 pp_string (buffer, "hasNoIrrevocable ");
895 if (props & PR_DOESGOIRREVOCABLE)
896 pp_string (buffer, "doesGoIrrevocable ");
897 if (props & PR_HASNOSIMPLEREADS)
898 pp_string (buffer, "hasNoSimpleReads ");
899 if (props & PR_AWBARRIERSOMITTED)
900 pp_string (buffer, "awBarriersOmitted ");
901 if (props & PR_RARBARRIERSOMITTED)
902 pp_string (buffer, "RaRBarriersOmitted ");
903 if (props & PR_UNDOLOGCODE)
904 pp_string (buffer, "undoLogCode ");
905 if (props & PR_PREFERUNINSTRUMENTED)
906 pp_string (buffer, "preferUninstrumented ");
907 if (props & PR_EXCEPTIONBLOCK)
908 pp_string (buffer, "exceptionBlock ");
909 if (props & PR_HASELSE)
910 pp_string (buffer, "hasElse ");
911 if (props & PR_READONLY)
912 pp_string (buffer, "readOnly ");
914 pp_right_bracket (buffer);
919 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
920 pp_gimple_stmt_1. */
922 static void
923 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
924 int flags)
926 unsigned int i;
928 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
929 if (flags & TDF_RAW)
930 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
931 gimple_switch_index (gs));
932 else
934 pp_string (buffer, "switch (");
935 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
936 if (flags & TDF_GIMPLE)
937 pp_string (buffer, ") {");
938 else
939 pp_string (buffer, ") <");
942 for (i = 0; i < gimple_switch_num_labels (gs); i++)
944 tree case_label = gimple_switch_label (gs, i);
945 gcc_checking_assert (case_label != NULL_TREE);
946 dump_generic_node (buffer, case_label, spc, flags, false);
947 pp_space (buffer);
948 tree label = CASE_LABEL (case_label);
949 dump_generic_node (buffer, label, spc, flags, false);
951 if (cfun && cfun->cfg)
953 basic_block dest = label_to_block (label);
954 if (dest)
956 edge label_edge = find_edge (gimple_bb (gs), dest);
957 if (label_edge && !(flags & TDF_GIMPLE))
958 dump_edge_probability (buffer, label_edge);
962 if (i < gimple_switch_num_labels (gs) - 1)
964 if (flags & TDF_GIMPLE)
965 pp_string (buffer, "; ");
966 else
967 pp_string (buffer, ", ");
970 if (flags & TDF_GIMPLE)
971 pp_string (buffer, "; }");
972 else
973 pp_greater (buffer);
977 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
978 pp_gimple_stmt_1. */
980 static void
981 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
983 if (flags & TDF_RAW)
984 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
985 get_tree_code_name (gimple_cond_code (gs)),
986 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
987 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
988 else
990 if (!(flags & TDF_RHS_ONLY))
991 pp_string (buffer, "if (");
992 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
993 pp_space (buffer);
994 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
995 pp_space (buffer);
996 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
997 if (!(flags & TDF_RHS_ONLY))
999 edge_iterator ei;
1000 edge e, true_edge = NULL, false_edge = NULL;
1001 basic_block bb = gimple_bb (gs);
1003 if (bb)
1005 FOR_EACH_EDGE (e, ei, bb->succs)
1007 if (e->flags & EDGE_TRUE_VALUE)
1008 true_edge = e;
1009 else if (e->flags & EDGE_FALSE_VALUE)
1010 false_edge = e;
1014 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1016 pp_right_paren (buffer);
1018 if (gimple_cond_true_label (gs))
1020 pp_string (buffer, " goto ");
1021 dump_generic_node (buffer, gimple_cond_true_label (gs),
1022 spc, flags, false);
1023 if (has_edge_info && !(flags & TDF_GIMPLE))
1024 dump_edge_probability (buffer, true_edge);
1025 pp_semicolon (buffer);
1027 if (gimple_cond_false_label (gs))
1029 pp_string (buffer, " else goto ");
1030 dump_generic_node (buffer, gimple_cond_false_label (gs),
1031 spc, flags, false);
1032 if (has_edge_info && !(flags & TDF_GIMPLE))
1033 dump_edge_probability (buffer, false_edge);
1035 pp_semicolon (buffer);
1042 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1043 spaces of indent. FLAGS specifies details to show in the dump (see
1044 TDF_* in dumpfils.h). */
1046 static void
1047 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
1049 tree label = gimple_label_label (gs);
1050 if (flags & TDF_RAW)
1051 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1052 else
1054 dump_generic_node (buffer, label, spc, flags, false);
1055 basic_block bb = gimple_bb (gs);
1056 if (bb && !(flags & TDF_GIMPLE))
1057 pp_scalar (buffer, " %s", dump_probability (bb->frequency));
1058 pp_colon (buffer);
1060 if (flags & TDF_GIMPLE)
1061 return;
1062 if (DECL_NONLOCAL (label))
1063 pp_string (buffer, " [non-local]");
1064 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1065 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1068 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1069 spaces of indent. FLAGS specifies details to show in the dump (see
1070 TDF_* in dumpfile.h). */
1072 static void
1073 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
1075 tree label = gimple_goto_dest (gs);
1076 if (flags & TDF_RAW)
1077 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1078 else
1079 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1083 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1084 spaces of indent. FLAGS specifies details to show in the dump (see
1085 TDF_* in dumpfile.h). */
1087 static void
1088 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
1090 if (flags & TDF_RAW)
1091 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1092 else
1093 pp_left_brace (buffer);
1094 if (!(flags & TDF_SLIM))
1096 tree var;
1098 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1100 newline_and_indent (buffer, 2);
1101 print_declaration (buffer, var, spc, flags);
1103 if (gimple_bind_vars (gs))
1104 pp_newline (buffer);
1106 pp_newline (buffer);
1107 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1108 newline_and_indent (buffer, spc);
1109 if (flags & TDF_RAW)
1110 pp_greater (buffer);
1111 else
1112 pp_right_brace (buffer);
1116 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1117 indent. FLAGS specifies details to show in the dump (see TDF_* in
1118 dumpfile.h). */
1120 static void
1121 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
1123 if (flags & TDF_RAW)
1125 const char *type;
1126 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1127 type = "GIMPLE_TRY_CATCH";
1128 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1129 type = "GIMPLE_TRY_FINALLY";
1130 else
1131 type = "UNKNOWN GIMPLE_TRY";
1132 dump_gimple_fmt (buffer, spc, flags,
1133 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1134 gimple_try_eval (gs), gimple_try_cleanup (gs));
1136 else
1138 pp_string (buffer, "try");
1139 newline_and_indent (buffer, spc + 2);
1140 pp_left_brace (buffer);
1141 pp_newline (buffer);
1143 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1144 newline_and_indent (buffer, spc + 2);
1145 pp_right_brace (buffer);
1147 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1149 newline_and_indent (buffer, spc);
1150 pp_string (buffer, "catch");
1151 newline_and_indent (buffer, spc + 2);
1152 pp_left_brace (buffer);
1154 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1156 newline_and_indent (buffer, spc);
1157 pp_string (buffer, "finally");
1158 newline_and_indent (buffer, spc + 2);
1159 pp_left_brace (buffer);
1161 else
1162 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1164 pp_newline (buffer);
1165 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1166 newline_and_indent (buffer, spc + 2);
1167 pp_right_brace (buffer);
1172 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1173 indent. FLAGS specifies details to show in the dump (see TDF_* in
1174 dumpfile.h). */
1176 static void
1177 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
1179 if (flags & TDF_RAW)
1180 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1181 gimple_catch_types (gs), gimple_catch_handler (gs));
1182 else
1183 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1184 gimple_catch_types (gs), gimple_catch_handler (gs));
1188 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1189 indent. FLAGS specifies details to show in the dump (see TDF_* in
1190 dumpfile.h). */
1192 static void
1193 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1194 int flags)
1196 if (flags & TDF_RAW)
1197 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1198 gimple_eh_filter_types (gs),
1199 gimple_eh_filter_failure (gs));
1200 else
1201 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1202 gimple_eh_filter_types (gs),
1203 gimple_eh_filter_failure (gs));
1207 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1209 static void
1210 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1211 geh_mnt *gs, int spc, int flags)
1213 if (flags & TDF_RAW)
1214 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1215 gimple_eh_must_not_throw_fndecl (gs));
1216 else
1217 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1218 gimple_eh_must_not_throw_fndecl (gs));
1222 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1223 indent. FLAGS specifies details to show in the dump (see TDF_* in
1224 dumpfile.h). */
1226 static void
1227 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1228 int flags)
1230 if (flags & TDF_RAW)
1231 dump_gimple_fmt (buffer, spc, flags,
1232 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1233 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1234 else
1235 dump_gimple_fmt (buffer, spc, flags,
1236 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1237 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1241 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1242 indent. FLAGS specifies details to show in the dump (see TDF_* in
1243 dumpfile.h). */
1245 static void
1246 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
1248 if (flags & TDF_RAW)
1249 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1250 gimple_resx_region (gs));
1251 else
1252 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1255 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1257 static void
1258 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int flags)
1260 if (flags & TDF_RAW)
1261 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1262 gimple_eh_dispatch_region (gs));
1263 else
1264 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1265 gimple_eh_dispatch_region (gs));
1268 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1269 of indent. FLAGS specifies details to show in the dump (see TDF_*
1270 in dumpfile.h). */
1272 static void
1273 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
1275 switch (gs->subcode)
1277 case GIMPLE_DEBUG_BIND:
1278 if (flags & TDF_RAW)
1279 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1280 gimple_debug_bind_get_var (gs),
1281 gimple_debug_bind_get_value (gs));
1282 else
1283 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1284 gimple_debug_bind_get_var (gs),
1285 gimple_debug_bind_get_value (gs));
1286 break;
1288 case GIMPLE_DEBUG_SOURCE_BIND:
1289 if (flags & TDF_RAW)
1290 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1291 gimple_debug_source_bind_get_var (gs),
1292 gimple_debug_source_bind_get_value (gs));
1293 else
1294 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1295 gimple_debug_source_bind_get_var (gs),
1296 gimple_debug_source_bind_get_value (gs));
1297 break;
1299 default:
1300 gcc_unreachable ();
1304 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1305 static void
1306 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
1308 size_t i;
1310 if (flags & TDF_RAW)
1312 const char *kind;
1313 switch (gimple_omp_for_kind (gs))
1315 case GF_OMP_FOR_KIND_FOR:
1316 kind = "";
1317 break;
1318 case GF_OMP_FOR_KIND_DISTRIBUTE:
1319 kind = " distribute";
1320 break;
1321 case GF_OMP_FOR_KIND_TASKLOOP:
1322 kind = " taskloop";
1323 break;
1324 case GF_OMP_FOR_KIND_CILKFOR:
1325 kind = " _Cilk_for";
1326 break;
1327 case GF_OMP_FOR_KIND_OACC_LOOP:
1328 kind = " oacc_loop";
1329 break;
1330 case GF_OMP_FOR_KIND_SIMD:
1331 kind = " simd";
1332 break;
1333 case GF_OMP_FOR_KIND_CILKSIMD:
1334 kind = " cilksimd";
1335 break;
1336 default:
1337 gcc_unreachable ();
1339 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1340 kind, gimple_omp_body (gs));
1341 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1342 dump_gimple_fmt (buffer, spc, flags, " >,");
1343 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1344 dump_gimple_fmt (buffer, spc, flags,
1345 "%+%T, %T, %T, %s, %T,%n",
1346 gimple_omp_for_index (gs, i),
1347 gimple_omp_for_initial (gs, i),
1348 gimple_omp_for_final (gs, i),
1349 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1350 gimple_omp_for_incr (gs, i));
1351 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1352 gimple_omp_for_pre_body (gs));
1354 else
1356 switch (gimple_omp_for_kind (gs))
1358 case GF_OMP_FOR_KIND_FOR:
1359 pp_string (buffer, "#pragma omp for");
1360 break;
1361 case GF_OMP_FOR_KIND_DISTRIBUTE:
1362 pp_string (buffer, "#pragma omp distribute");
1363 break;
1364 case GF_OMP_FOR_KIND_TASKLOOP:
1365 pp_string (buffer, "#pragma omp taskloop");
1366 break;
1367 case GF_OMP_FOR_KIND_CILKFOR:
1368 break;
1369 case GF_OMP_FOR_KIND_OACC_LOOP:
1370 pp_string (buffer, "#pragma acc loop");
1371 break;
1372 case GF_OMP_FOR_KIND_SIMD:
1373 pp_string (buffer, "#pragma omp simd");
1374 break;
1375 case GF_OMP_FOR_KIND_CILKSIMD:
1376 pp_string (buffer, "#pragma simd");
1377 break;
1378 case GF_OMP_FOR_KIND_GRID_LOOP:
1379 pp_string (buffer, "#pragma omp for grid_loop");
1380 break;
1381 default:
1382 gcc_unreachable ();
1384 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1385 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1386 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1388 if (i)
1389 spc += 2;
1390 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1391 pp_string (buffer, "_Cilk_for (");
1392 else
1394 newline_and_indent (buffer, spc);
1395 pp_string (buffer, "for (");
1397 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1398 flags, false);
1399 pp_string (buffer, " = ");
1400 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1401 flags, false);
1402 pp_string (buffer, "; ");
1404 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1405 flags, false);
1406 pp_space (buffer);
1407 switch (gimple_omp_for_cond (gs, i))
1409 case LT_EXPR:
1410 pp_less (buffer);
1411 break;
1412 case GT_EXPR:
1413 pp_greater (buffer);
1414 break;
1415 case LE_EXPR:
1416 pp_less_equal (buffer);
1417 break;
1418 case GE_EXPR:
1419 pp_greater_equal (buffer);
1420 break;
1421 case NE_EXPR:
1422 pp_string (buffer, "!=");
1423 break;
1424 default:
1425 gcc_unreachable ();
1427 pp_space (buffer);
1428 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1429 flags, false);
1430 pp_string (buffer, "; ");
1432 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1433 flags, false);
1434 pp_string (buffer, " = ");
1435 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1436 flags, false);
1437 pp_right_paren (buffer);
1440 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1442 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1443 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1444 newline_and_indent (buffer, spc + 2);
1445 pp_left_brace (buffer);
1446 pp_newline (buffer);
1447 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1448 newline_and_indent (buffer, spc + 2);
1449 pp_right_brace (buffer);
1454 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1456 static void
1457 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1458 int spc, int flags)
1460 if (flags & TDF_RAW)
1462 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1463 gimple_omp_continue_control_def (gs),
1464 gimple_omp_continue_control_use (gs));
1466 else
1468 pp_string (buffer, "#pragma omp continue (");
1469 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1470 spc, flags, false);
1471 pp_comma (buffer);
1472 pp_space (buffer);
1473 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1474 spc, flags, false);
1475 pp_right_paren (buffer);
1479 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1481 static void
1482 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1483 int spc, int flags)
1485 if (flags & TDF_RAW)
1487 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1488 gimple_omp_body (gs));
1489 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1490 dump_gimple_fmt (buffer, spc, flags, " >");
1492 else
1494 pp_string (buffer, "#pragma omp single");
1495 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1496 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1498 newline_and_indent (buffer, spc + 2);
1499 pp_left_brace (buffer);
1500 pp_newline (buffer);
1501 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1502 newline_and_indent (buffer, spc + 2);
1503 pp_right_brace (buffer);
1508 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1510 static void
1511 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1512 int spc, int flags)
1514 const char *kind;
1515 switch (gimple_omp_target_kind (gs))
1517 case GF_OMP_TARGET_KIND_REGION:
1518 kind = "";
1519 break;
1520 case GF_OMP_TARGET_KIND_DATA:
1521 kind = " data";
1522 break;
1523 case GF_OMP_TARGET_KIND_UPDATE:
1524 kind = " update";
1525 break;
1526 case GF_OMP_TARGET_KIND_ENTER_DATA:
1527 kind = " enter data";
1528 break;
1529 case GF_OMP_TARGET_KIND_EXIT_DATA:
1530 kind = " exit data";
1531 break;
1532 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1533 kind = " oacc_kernels";
1534 break;
1535 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1536 kind = " oacc_parallel";
1537 break;
1538 case GF_OMP_TARGET_KIND_OACC_DATA:
1539 kind = " oacc_data";
1540 break;
1541 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1542 kind = " oacc_update";
1543 break;
1544 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1545 kind = " oacc_enter_exit_data";
1546 break;
1547 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1548 kind = " oacc_declare";
1549 break;
1550 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1551 kind = " oacc_host_data";
1552 break;
1553 default:
1554 gcc_unreachable ();
1556 if (flags & TDF_RAW)
1558 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1559 kind, gimple_omp_body (gs));
1560 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1561 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1562 gimple_omp_target_child_fn (gs),
1563 gimple_omp_target_data_arg (gs));
1565 else
1567 pp_string (buffer, "#pragma omp target");
1568 pp_string (buffer, kind);
1569 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1570 if (gimple_omp_target_child_fn (gs))
1572 pp_string (buffer, " [child fn: ");
1573 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1574 spc, flags, false);
1575 pp_string (buffer, " (");
1576 if (gimple_omp_target_data_arg (gs))
1577 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1578 spc, flags, false);
1579 else
1580 pp_string (buffer, "???");
1581 pp_string (buffer, ")]");
1583 gimple_seq body = gimple_omp_body (gs);
1584 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1586 newline_and_indent (buffer, spc + 2);
1587 pp_left_brace (buffer);
1588 pp_newline (buffer);
1589 dump_gimple_seq (buffer, body, spc + 4, flags);
1590 newline_and_indent (buffer, spc + 2);
1591 pp_right_brace (buffer);
1593 else if (body)
1595 pp_newline (buffer);
1596 dump_gimple_seq (buffer, body, spc + 2, flags);
1601 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1603 static void
1604 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1605 int flags)
1607 if (flags & TDF_RAW)
1609 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1610 gimple_omp_body (gs));
1611 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1612 dump_gimple_fmt (buffer, spc, flags, " >");
1614 else
1616 pp_string (buffer, "#pragma omp teams");
1617 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1618 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1620 newline_and_indent (buffer, spc + 2);
1621 pp_character (buffer, '{');
1622 pp_newline (buffer);
1623 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1624 newline_and_indent (buffer, spc + 2);
1625 pp_character (buffer, '}');
1630 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1632 static void
1633 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1634 int spc, int flags)
1636 if (flags & TDF_RAW)
1638 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1639 gimple_omp_body (gs));
1640 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1641 dump_gimple_fmt (buffer, spc, flags, " >");
1643 else
1645 pp_string (buffer, "#pragma omp sections");
1646 if (gimple_omp_sections_control (gs))
1648 pp_string (buffer, " <");
1649 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1650 flags, false);
1651 pp_greater (buffer);
1653 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1654 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1656 newline_and_indent (buffer, spc + 2);
1657 pp_left_brace (buffer);
1658 pp_newline (buffer);
1659 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1660 newline_and_indent (buffer, spc + 2);
1661 pp_right_brace (buffer);
1666 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1667 pretty_printer BUFFER. */
1669 static void
1670 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc, int flags)
1672 if (flags & TDF_RAW)
1673 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1674 gimple_omp_body (gs));
1675 else
1677 switch (gimple_code (gs))
1679 case GIMPLE_OMP_MASTER:
1680 pp_string (buffer, "#pragma omp master");
1681 break;
1682 case GIMPLE_OMP_TASKGROUP:
1683 pp_string (buffer, "#pragma omp taskgroup");
1684 break;
1685 case GIMPLE_OMP_SECTION:
1686 pp_string (buffer, "#pragma omp section");
1687 break;
1688 case GIMPLE_OMP_GRID_BODY:
1689 pp_string (buffer, "#pragma omp gridified body");
1690 break;
1691 default:
1692 gcc_unreachable ();
1694 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1696 newline_and_indent (buffer, spc + 2);
1697 pp_left_brace (buffer);
1698 pp_newline (buffer);
1699 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1700 newline_and_indent (buffer, spc + 2);
1701 pp_right_brace (buffer);
1706 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1708 static void
1709 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1710 int spc, int 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 pp_string (buffer, "#pragma omp critical");
1718 if (gimple_omp_critical_name (gs))
1720 pp_string (buffer, " (");
1721 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1722 flags, false);
1723 pp_right_paren (buffer);
1725 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1726 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1728 newline_and_indent (buffer, spc + 2);
1729 pp_left_brace (buffer);
1730 pp_newline (buffer);
1731 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1732 newline_and_indent (buffer, spc + 2);
1733 pp_right_brace (buffer);
1738 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1740 static void
1741 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1742 int spc, int flags)
1744 if (flags & TDF_RAW)
1745 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1746 gimple_omp_body (gs));
1747 else
1749 pp_string (buffer, "#pragma omp ordered");
1750 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1751 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1753 newline_and_indent (buffer, spc + 2);
1754 pp_left_brace (buffer);
1755 pp_newline (buffer);
1756 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1757 newline_and_indent (buffer, spc + 2);
1758 pp_right_brace (buffer);
1763 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1765 static void
1766 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc, int flags)
1768 if (flags & TDF_RAW)
1770 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1771 (int) gimple_omp_return_nowait_p (gs));
1772 if (gimple_omp_return_lhs (gs))
1773 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1774 gimple_omp_return_lhs (gs));
1775 else
1776 dump_gimple_fmt (buffer, spc, flags, ">");
1778 else
1780 pp_string (buffer, "#pragma omp return");
1781 if (gimple_omp_return_nowait_p (gs))
1782 pp_string (buffer, "(nowait)");
1783 if (gimple_omp_return_lhs (gs))
1785 pp_string (buffer, " (set ");
1786 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1787 spc, flags, false);
1788 pp_character (buffer, ')');
1793 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1795 static void
1796 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1797 int spc, int flags)
1799 unsigned subcode = gimple_transaction_subcode (gs);
1801 if (flags & TDF_RAW)
1803 dump_gimple_fmt (buffer, spc, flags,
1804 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1805 "<%+BODY <%S> >",
1806 gs, subcode, gimple_transaction_label_norm (gs),
1807 gimple_transaction_label_uninst (gs),
1808 gimple_transaction_label_over (gs),
1809 gimple_transaction_body (gs));
1811 else
1813 if (subcode & GTMA_IS_OUTER)
1814 pp_string (buffer, "__transaction_atomic [[outer]]");
1815 else if (subcode & GTMA_IS_RELAXED)
1816 pp_string (buffer, "__transaction_relaxed");
1817 else
1818 pp_string (buffer, "__transaction_atomic");
1819 subcode &= ~GTMA_DECLARATION_MASK;
1821 if (gimple_transaction_body (gs))
1823 newline_and_indent (buffer, spc + 2);
1824 pp_left_brace (buffer);
1825 pp_newline (buffer);
1826 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1827 spc + 4, flags);
1828 newline_and_indent (buffer, spc + 2);
1829 pp_right_brace (buffer);
1831 else
1833 pp_string (buffer, " //");
1834 if (gimple_transaction_label_norm (gs))
1836 pp_string (buffer, " NORM=");
1837 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1838 spc, flags, false);
1840 if (gimple_transaction_label_uninst (gs))
1842 pp_string (buffer, " UNINST=");
1843 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1844 spc, flags, false);
1846 if (gimple_transaction_label_over (gs))
1848 pp_string (buffer, " OVER=");
1849 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1850 spc, flags, false);
1852 if (subcode)
1854 pp_string (buffer, " SUBCODE=[ ");
1855 if (subcode & GTMA_HAVE_ABORT)
1857 pp_string (buffer, "GTMA_HAVE_ABORT ");
1858 subcode &= ~GTMA_HAVE_ABORT;
1860 if (subcode & GTMA_HAVE_LOAD)
1862 pp_string (buffer, "GTMA_HAVE_LOAD ");
1863 subcode &= ~GTMA_HAVE_LOAD;
1865 if (subcode & GTMA_HAVE_STORE)
1867 pp_string (buffer, "GTMA_HAVE_STORE ");
1868 subcode &= ~GTMA_HAVE_STORE;
1870 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1872 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1873 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1875 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1877 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1878 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1880 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1882 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1883 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1885 if (subcode)
1886 pp_printf (buffer, "0x%x ", subcode);
1887 pp_right_bracket (buffer);
1893 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1894 indent. FLAGS specifies details to show in the dump (see TDF_* in
1895 dumpfile.h). */
1897 static void
1898 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
1900 unsigned int i, n, f, fields;
1902 if (flags & TDF_RAW)
1904 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1905 gimple_asm_string (gs));
1907 n = gimple_asm_noutputs (gs);
1908 if (n)
1910 newline_and_indent (buffer, spc + 2);
1911 pp_string (buffer, "OUTPUT: ");
1912 for (i = 0; i < n; i++)
1914 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1915 spc, flags, false);
1916 if (i < n - 1)
1917 pp_string (buffer, ", ");
1921 n = gimple_asm_ninputs (gs);
1922 if (n)
1924 newline_and_indent (buffer, spc + 2);
1925 pp_string (buffer, "INPUT: ");
1926 for (i = 0; i < n; i++)
1928 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1929 spc, flags, false);
1930 if (i < n - 1)
1931 pp_string (buffer, ", ");
1935 n = gimple_asm_nclobbers (gs);
1936 if (n)
1938 newline_and_indent (buffer, spc + 2);
1939 pp_string (buffer, "CLOBBER: ");
1940 for (i = 0; i < n; i++)
1942 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1943 spc, flags, false);
1944 if (i < n - 1)
1945 pp_string (buffer, ", ");
1949 n = gimple_asm_nlabels (gs);
1950 if (n)
1952 newline_and_indent (buffer, spc + 2);
1953 pp_string (buffer, "LABEL: ");
1954 for (i = 0; i < n; i++)
1956 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1957 spc, flags, false);
1958 if (i < n - 1)
1959 pp_string (buffer, ", ");
1963 newline_and_indent (buffer, spc);
1964 pp_greater (buffer);
1966 else
1968 pp_string (buffer, "__asm__");
1969 if (gimple_asm_volatile_p (gs))
1970 pp_string (buffer, " __volatile__");
1971 if (gimple_asm_nlabels (gs))
1972 pp_string (buffer, " goto");
1973 pp_string (buffer, "(\"");
1974 pp_string (buffer, gimple_asm_string (gs));
1975 pp_string (buffer, "\"");
1977 if (gimple_asm_nlabels (gs))
1978 fields = 4;
1979 else if (gimple_asm_nclobbers (gs))
1980 fields = 3;
1981 else if (gimple_asm_ninputs (gs))
1982 fields = 2;
1983 else if (gimple_asm_noutputs (gs))
1984 fields = 1;
1985 else
1986 fields = 0;
1988 for (f = 0; f < fields; ++f)
1990 pp_string (buffer, " : ");
1992 switch (f)
1994 case 0:
1995 n = gimple_asm_noutputs (gs);
1996 for (i = 0; i < n; i++)
1998 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1999 spc, flags, false);
2000 if (i < n - 1)
2001 pp_string (buffer, ", ");
2003 break;
2005 case 1:
2006 n = gimple_asm_ninputs (gs);
2007 for (i = 0; i < n; i++)
2009 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2010 spc, flags, false);
2011 if (i < n - 1)
2012 pp_string (buffer, ", ");
2014 break;
2016 case 2:
2017 n = gimple_asm_nclobbers (gs);
2018 for (i = 0; i < n; i++)
2020 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2021 spc, flags, false);
2022 if (i < n - 1)
2023 pp_string (buffer, ", ");
2025 break;
2027 case 3:
2028 n = gimple_asm_nlabels (gs);
2029 for (i = 0; i < n; i++)
2031 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2032 spc, flags, false);
2033 if (i < n - 1)
2034 pp_string (buffer, ", ");
2036 break;
2038 default:
2039 gcc_unreachable ();
2043 pp_string (buffer, ");");
2047 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2048 SPC spaces of indent. */
2050 static void
2051 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2053 if (TREE_CODE (node) != SSA_NAME)
2054 return;
2056 if (POINTER_TYPE_P (TREE_TYPE (node))
2057 && SSA_NAME_PTR_INFO (node))
2059 unsigned int align, misalign;
2060 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2061 pp_string (buffer, "# PT = ");
2062 pp_points_to_solution (buffer, &pi->pt);
2063 newline_and_indent (buffer, spc);
2064 if (get_ptr_info_alignment (pi, &align, &misalign))
2066 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2067 newline_and_indent (buffer, spc);
2071 if (!POINTER_TYPE_P (TREE_TYPE (node))
2072 && SSA_NAME_RANGE_INFO (node))
2074 wide_int min, max, nonzero_bits;
2075 value_range_type range_type = get_range_info (node, &min, &max);
2077 if (range_type == VR_VARYING)
2078 pp_printf (buffer, "# RANGE VR_VARYING");
2079 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2081 pp_printf (buffer, "# RANGE ");
2082 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2083 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2084 pp_printf (buffer, ", ");
2085 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2086 pp_printf (buffer, "]");
2088 nonzero_bits = get_nonzero_bits (node);
2089 if (nonzero_bits != -1)
2091 pp_string (buffer, " NONZERO ");
2092 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2094 newline_and_indent (buffer, spc);
2098 /* As dump_ssaname_info, but dump to FILE. */
2100 void
2101 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2103 pretty_printer buffer;
2104 pp_needs_newline (&buffer) = true;
2105 buffer.buffer->stream = file;
2106 dump_ssaname_info (&buffer, node, spc);
2107 pp_flush (&buffer);
2110 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2111 The caller is responsible for calling pp_flush on BUFFER to finalize
2112 pretty printer. If COMMENT is true, print this after #. */
2114 static void
2115 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2116 int flags)
2118 size_t i;
2119 tree lhs = gimple_phi_result (phi);
2121 if (flags & TDF_ALIAS)
2122 dump_ssaname_info (buffer, lhs, spc);
2124 if (comment)
2125 pp_string (buffer, "# ");
2127 if (flags & TDF_RAW)
2128 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2129 gimple_phi_result (phi));
2130 else
2132 dump_generic_node (buffer, lhs, spc, flags, false);
2133 if (flags & TDF_GIMPLE)
2134 pp_string (buffer, " = __PHI (");
2135 else
2136 pp_string (buffer, " = PHI <");
2138 for (i = 0; i < gimple_phi_num_args (phi); i++)
2140 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2141 dump_location (buffer, gimple_phi_arg_location (phi, i));
2142 if (flags & TDF_GIMPLE)
2144 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2145 gimple *stmt = first_stmt (src);
2146 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2148 pp_string (buffer, "bb_");
2149 pp_decimal_int (buffer, src->index);
2151 else
2152 dump_generic_node (buffer, gimple_label_label (as_a <glabel *> (stmt)), 0, flags,
2153 false);
2154 pp_string (buffer, ": ");
2156 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2157 false);
2158 if (! (flags & TDF_GIMPLE))
2160 pp_left_paren (buffer);
2161 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2162 pp_right_paren (buffer);
2164 if (i < gimple_phi_num_args (phi) - 1)
2165 pp_string (buffer, ", ");
2167 if (flags & TDF_GIMPLE)
2168 pp_string (buffer, ");");
2169 else
2170 pp_greater (buffer);
2174 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2175 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2176 dumpfile.h). */
2178 static void
2179 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2180 int spc, int flags)
2182 if (flags & TDF_RAW)
2184 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2185 gimple_omp_body (gs));
2186 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2187 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2188 gimple_omp_parallel_child_fn (gs),
2189 gimple_omp_parallel_data_arg (gs));
2191 else
2193 gimple_seq body;
2194 pp_string (buffer, "#pragma omp parallel");
2195 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2196 if (gimple_omp_parallel_child_fn (gs))
2198 pp_string (buffer, " [child fn: ");
2199 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2200 spc, flags, false);
2201 pp_string (buffer, " (");
2202 if (gimple_omp_parallel_data_arg (gs))
2203 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2204 spc, flags, false);
2205 else
2206 pp_string (buffer, "???");
2207 pp_string (buffer, ")]");
2209 body = gimple_omp_body (gs);
2210 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2212 newline_and_indent (buffer, spc + 2);
2213 pp_left_brace (buffer);
2214 pp_newline (buffer);
2215 dump_gimple_seq (buffer, body, spc + 4, flags);
2216 newline_and_indent (buffer, spc + 2);
2217 pp_right_brace (buffer);
2219 else if (body)
2221 pp_newline (buffer);
2222 dump_gimple_seq (buffer, body, spc + 2, flags);
2228 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2229 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2230 dumpfile.h). */
2232 static void
2233 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2234 int flags)
2236 if (flags & TDF_RAW)
2238 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2239 gimple_omp_body (gs));
2240 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2241 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2242 gimple_omp_task_child_fn (gs),
2243 gimple_omp_task_data_arg (gs),
2244 gimple_omp_task_copy_fn (gs),
2245 gimple_omp_task_arg_size (gs),
2246 gimple_omp_task_arg_size (gs));
2248 else
2250 gimple_seq body;
2251 if (gimple_omp_task_taskloop_p (gs))
2252 pp_string (buffer, "#pragma omp taskloop");
2253 else
2254 pp_string (buffer, "#pragma omp task");
2255 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2256 if (gimple_omp_task_child_fn (gs))
2258 pp_string (buffer, " [child fn: ");
2259 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2260 spc, flags, false);
2261 pp_string (buffer, " (");
2262 if (gimple_omp_task_data_arg (gs))
2263 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2264 spc, flags, false);
2265 else
2266 pp_string (buffer, "???");
2267 pp_string (buffer, ")]");
2269 body = gimple_omp_body (gs);
2270 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2272 newline_and_indent (buffer, spc + 2);
2273 pp_left_brace (buffer);
2274 pp_newline (buffer);
2275 dump_gimple_seq (buffer, body, spc + 4, flags);
2276 newline_and_indent (buffer, spc + 2);
2277 pp_right_brace (buffer);
2279 else if (body)
2281 pp_newline (buffer);
2282 dump_gimple_seq (buffer, body, spc + 2, flags);
2288 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2289 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2290 in dumpfile.h). */
2292 static void
2293 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2294 int spc, int flags)
2296 if (flags & TDF_RAW)
2298 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2299 gimple_omp_atomic_load_lhs (gs),
2300 gimple_omp_atomic_load_rhs (gs));
2302 else
2304 pp_string (buffer, "#pragma omp atomic_load");
2305 if (gimple_omp_atomic_seq_cst_p (gs))
2306 pp_string (buffer, " seq_cst");
2307 if (gimple_omp_atomic_need_value_p (gs))
2308 pp_string (buffer, " [needed]");
2309 newline_and_indent (buffer, spc + 2);
2310 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2311 spc, flags, false);
2312 pp_space (buffer);
2313 pp_equal (buffer);
2314 pp_space (buffer);
2315 pp_star (buffer);
2316 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2317 spc, flags, false);
2321 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2322 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2323 in dumpfile.h). */
2325 static void
2326 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2327 gomp_atomic_store *gs, int spc, int flags)
2329 if (flags & TDF_RAW)
2331 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2332 gimple_omp_atomic_store_val (gs));
2334 else
2336 pp_string (buffer, "#pragma omp atomic_store ");
2337 if (gimple_omp_atomic_seq_cst_p (gs))
2338 pp_string (buffer, "seq_cst ");
2339 if (gimple_omp_atomic_need_value_p (gs))
2340 pp_string (buffer, "[needed] ");
2341 pp_left_paren (buffer);
2342 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2343 spc, flags, false);
2344 pp_right_paren (buffer);
2349 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2350 FLAGS are as in pp_gimple_stmt_1. */
2352 static void
2353 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc, int flags)
2355 tree vdef = gimple_vdef (gs);
2356 tree vuse = gimple_vuse (gs);
2358 if (vdef != NULL_TREE)
2360 pp_string (buffer, "# ");
2361 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2362 pp_string (buffer, " = VDEF <");
2363 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2364 pp_greater (buffer);
2365 newline_and_indent (buffer, spc);
2367 else if (vuse != NULL_TREE)
2369 pp_string (buffer, "# VUSE <");
2370 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2371 pp_greater (buffer);
2372 newline_and_indent (buffer, spc);
2377 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2378 spaces of indent. FLAGS specifies details to show in the dump (see
2379 TDF_* in dumpfile.h). The caller is responsible for calling
2380 pp_flush on BUFFER to finalize the pretty printer. */
2382 void
2383 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
2385 if (!gs)
2386 return;
2388 if (flags & TDF_STMTADDR)
2389 pp_printf (buffer, "<&%p> ", (void *) gs);
2391 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2392 dump_location (buffer, gimple_location (gs));
2394 if (flags & TDF_EH)
2396 int lp_nr = lookup_stmt_eh_lp (gs);
2397 if (lp_nr > 0)
2398 pp_printf (buffer, "[LP %d] ", lp_nr);
2399 else if (lp_nr < 0)
2400 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2403 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2404 && gimple_has_mem_ops (gs))
2405 dump_gimple_mem_ops (buffer, gs, spc, flags);
2407 if (gimple_has_lhs (gs)
2408 && (flags & TDF_ALIAS))
2409 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2411 switch (gimple_code (gs))
2413 case GIMPLE_ASM:
2414 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2415 break;
2417 case GIMPLE_ASSIGN:
2418 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2419 break;
2421 case GIMPLE_BIND:
2422 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2423 break;
2425 case GIMPLE_CALL:
2426 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2427 break;
2429 case GIMPLE_COND:
2430 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2431 break;
2433 case GIMPLE_LABEL:
2434 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2435 break;
2437 case GIMPLE_GOTO:
2438 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2439 break;
2441 case GIMPLE_NOP:
2442 pp_string (buffer, "GIMPLE_NOP");
2443 break;
2445 case GIMPLE_RETURN:
2446 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2447 break;
2449 case GIMPLE_SWITCH:
2450 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2451 break;
2453 case GIMPLE_TRY:
2454 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2455 break;
2457 case GIMPLE_PHI:
2458 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2459 break;
2461 case GIMPLE_OMP_PARALLEL:
2462 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2463 flags);
2464 break;
2466 case GIMPLE_OMP_TASK:
2467 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2468 break;
2470 case GIMPLE_OMP_ATOMIC_LOAD:
2471 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2472 spc, flags);
2473 break;
2475 case GIMPLE_OMP_ATOMIC_STORE:
2476 dump_gimple_omp_atomic_store (buffer,
2477 as_a <gomp_atomic_store *> (gs),
2478 spc, flags);
2479 break;
2481 case GIMPLE_OMP_FOR:
2482 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2483 break;
2485 case GIMPLE_OMP_CONTINUE:
2486 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2487 flags);
2488 break;
2490 case GIMPLE_OMP_SINGLE:
2491 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2492 flags);
2493 break;
2495 case GIMPLE_OMP_TARGET:
2496 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2497 flags);
2498 break;
2500 case GIMPLE_OMP_TEAMS:
2501 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2502 flags);
2503 break;
2505 case GIMPLE_OMP_RETURN:
2506 dump_gimple_omp_return (buffer, gs, spc, flags);
2507 break;
2509 case GIMPLE_OMP_SECTIONS:
2510 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2511 spc, flags);
2512 break;
2514 case GIMPLE_OMP_SECTIONS_SWITCH:
2515 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2516 break;
2518 case GIMPLE_OMP_MASTER:
2519 case GIMPLE_OMP_TASKGROUP:
2520 case GIMPLE_OMP_SECTION:
2521 case GIMPLE_OMP_GRID_BODY:
2522 dump_gimple_omp_block (buffer, gs, spc, flags);
2523 break;
2525 case GIMPLE_OMP_ORDERED:
2526 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2527 flags);
2528 break;
2530 case GIMPLE_OMP_CRITICAL:
2531 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2532 flags);
2533 break;
2535 case GIMPLE_CATCH:
2536 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2537 break;
2539 case GIMPLE_EH_FILTER:
2540 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2541 break;
2543 case GIMPLE_EH_MUST_NOT_THROW:
2544 dump_gimple_eh_must_not_throw (buffer,
2545 as_a <geh_mnt *> (gs),
2546 spc, flags);
2547 break;
2549 case GIMPLE_EH_ELSE:
2550 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2551 break;
2553 case GIMPLE_RESX:
2554 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2555 break;
2557 case GIMPLE_EH_DISPATCH:
2558 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2559 flags);
2560 break;
2562 case GIMPLE_DEBUG:
2563 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2564 break;
2566 case GIMPLE_PREDICT:
2567 pp_string (buffer, "// predicted ");
2568 if (gimple_predict_outcome (gs))
2569 pp_string (buffer, "likely by ");
2570 else
2571 pp_string (buffer, "unlikely by ");
2572 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2573 pp_string (buffer, " predictor.");
2574 break;
2576 case GIMPLE_TRANSACTION:
2577 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2578 flags);
2579 break;
2581 default:
2582 GIMPLE_NIY;
2587 /* Dumps header of basic block BB to OUTF indented by INDENT
2588 spaces and details described by flags. */
2590 static void
2591 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2593 if (flags & TDF_BLOCKS)
2595 if (flags & TDF_LINENO)
2597 gimple_stmt_iterator gsi;
2599 if (flags & TDF_COMMENT)
2600 fputs (";; ", outf);
2602 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2603 if (!is_gimple_debug (gsi_stmt (gsi))
2604 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2606 fprintf (outf, "%*sstarting at line %d",
2607 indent, "", get_lineno (gsi_stmt (gsi)));
2608 break;
2610 if (bb->discriminator)
2611 fprintf (outf, ", discriminator %i", bb->discriminator);
2612 fputc ('\n', outf);
2615 else
2617 gimple *stmt = first_stmt (bb);
2618 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2620 if (flags & TDF_GIMPLE)
2621 fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
2622 else
2623 fprintf (outf, "%*s<bb %d> %s:\n",
2624 indent, "", bb->index, dump_probability (bb->frequency));
2630 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2631 spaces. */
2633 static void
2634 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2635 basic_block bb ATTRIBUTE_UNUSED,
2636 int indent ATTRIBUTE_UNUSED,
2637 int flags ATTRIBUTE_UNUSED)
2639 /* There is currently no GIMPLE-specific basic block info to dump. */
2640 return;
2644 /* Dump PHI nodes of basic block BB to BUFFER with details described
2645 by FLAGS and indented by INDENT spaces. */
2647 static void
2648 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2650 gphi_iterator i;
2652 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2654 gphi *phi = i.phi ();
2655 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2657 INDENT (indent);
2658 dump_gimple_phi (buffer, phi, indent,
2659 (flags & TDF_GIMPLE) ? false : true, flags);
2660 pp_newline (buffer);
2666 /* Dump jump to basic block BB that is represented implicitly in the cfg
2667 to BUFFER. */
2669 static void
2670 pp_cfg_jump (pretty_printer *buffer, edge e, int flags)
2672 if (flags & TDF_GIMPLE)
2674 pp_string (buffer, "goto bb_");
2675 pp_decimal_int (buffer, e->dest->index);
2676 pp_semicolon (buffer);
2678 else
2680 gimple *stmt = first_stmt (e->dest);
2682 pp_string (buffer, "goto <bb ");
2683 pp_decimal_int (buffer, e->dest->index);
2684 pp_greater (buffer);
2685 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2687 pp_string (buffer, " (");
2688 dump_generic_node (buffer,
2689 gimple_label_label (as_a <glabel *> (stmt)),
2690 0, 0, false);
2691 pp_right_paren (buffer);
2692 pp_semicolon (buffer);
2694 else
2695 pp_semicolon (buffer);
2697 dump_edge_probability (buffer, e);
2702 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2703 by INDENT spaces, with details given by FLAGS. */
2705 static void
2706 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2707 int flags)
2709 edge e;
2710 gimple *stmt;
2712 stmt = last_stmt (bb);
2714 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2716 edge true_edge, false_edge;
2718 /* When we are emitting the code or changing CFG, it is possible that
2719 the edges are not yet created. When we are using debug_bb in such
2720 a situation, we do not want it to crash. */
2721 if (EDGE_COUNT (bb->succs) != 2)
2722 return;
2723 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2725 INDENT (indent + 2);
2726 pp_cfg_jump (buffer, true_edge, flags);
2727 newline_and_indent (buffer, indent);
2728 pp_string (buffer, "else");
2729 newline_and_indent (buffer, indent + 2);
2730 pp_cfg_jump (buffer, false_edge, flags);
2731 pp_newline (buffer);
2732 return;
2735 /* If there is a fallthru edge, we may need to add an artificial
2736 goto to the dump. */
2737 e = find_fallthru_edge (bb->succs);
2739 if (e && e->dest != bb->next_bb)
2741 INDENT (indent);
2743 if ((flags & TDF_LINENO)
2744 && e->goto_locus != UNKNOWN_LOCATION)
2745 dump_location (buffer, e->goto_locus);
2747 pp_cfg_jump (buffer, e, flags);
2748 pp_newline (buffer);
2753 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2754 indented by INDENT spaces. */
2756 static void
2757 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2758 int flags)
2760 gimple_stmt_iterator gsi;
2761 gimple *stmt;
2762 int label_indent = indent - 2;
2764 if (label_indent < 0)
2765 label_indent = 0;
2767 dump_phi_nodes (buffer, bb, indent, flags);
2769 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2771 int curr_indent;
2773 stmt = gsi_stmt (gsi);
2775 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2777 INDENT (curr_indent);
2778 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2779 pp_newline_and_flush (buffer);
2780 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2781 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2782 pp_buffer (buffer)->stream, stmt);
2785 dump_implicit_edges (buffer, bb, indent, flags);
2786 pp_flush (buffer);
2790 /* Dumps basic block BB to FILE with details described by FLAGS and
2791 indented by INDENT spaces. */
2793 void
2794 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2796 dump_gimple_bb_header (file, bb, indent, flags);
2797 if (bb->index >= NUM_FIXED_BLOCKS)
2799 pretty_printer buffer;
2800 pp_needs_newline (&buffer) = true;
2801 buffer.buffer->stream = file;
2802 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2804 dump_gimple_bb_footer (file, bb, indent, flags);
2807 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2808 no indentation, for use as a label of a DOT graph record-node.
2809 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2810 histogram dumping doesn't know about pretty-printers. */
2812 void
2813 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2815 pp_printf (pp, "<bb %d>:\n", bb->index);
2816 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2818 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2819 gsi_next (&gsi))
2821 gphi *phi = gsi.phi ();
2822 if (!virtual_operand_p (gimple_phi_result (phi))
2823 || (dump_flags & TDF_VOPS))
2825 pp_bar (pp);
2826 pp_write_text_to_stream (pp);
2827 pp_string (pp, "# ");
2828 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2829 pp_newline (pp);
2830 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2834 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2835 gsi_next (&gsi))
2837 gimple *stmt = gsi_stmt (gsi);
2838 pp_bar (pp);
2839 pp_write_text_to_stream (pp);
2840 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2841 pp_newline (pp);
2842 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2844 dump_implicit_edges (pp, bb, 0, dump_flags);
2845 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);