[ARM][committed] Sort ARMv8 processors by alphabetic order
[official-gcc.git] / gcc / gimple-pretty-print.c
blobb5e866d36fabeb3cd354d9f98f690522f166e833
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2016 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"
41 #define INDENT(SPACE) \
42 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
44 #define GIMPLE_NIY do_niy (buffer,gs)
46 /* Try to print on BUFFER a default message for the unrecognized
47 gimple statement GS. */
49 static void
50 do_niy (pretty_printer *buffer, gimple *gs)
52 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
53 gimple_code_name[(int) gimple_code (gs)]);
57 /* Emit a newline and SPC indentation spaces to BUFFER. */
59 static void
60 newline_and_indent (pretty_printer *buffer, int spc)
62 pp_newline (buffer);
63 INDENT (spc);
67 /* Print the GIMPLE statement GS on stderr. */
69 DEBUG_FUNCTION void
70 debug_gimple_stmt (gimple *gs)
72 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
75 /* Dump E probability to BUFFER. */
77 static void
78 dump_edge_probability (pretty_printer *buffer, edge e)
80 pp_scalar (buffer, " [%.1f%%]",
81 e->probability * 100.0 / REG_BR_PROB_BASE);
84 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
85 FLAGS as in pp_gimple_stmt_1. */
87 void
88 print_gimple_stmt (FILE *file, gimple *g, int spc, int flags)
90 pretty_printer buffer;
91 pp_needs_newline (&buffer) = true;
92 buffer.buffer->stream = file;
93 pp_gimple_stmt_1 (&buffer, g, spc, flags);
94 pp_newline_and_flush (&buffer);
97 DEBUG_FUNCTION void
98 debug (gimple &ref)
100 print_gimple_stmt (stderr, &ref, 0, 0);
103 DEBUG_FUNCTION void
104 debug (gimple *ptr)
106 if (ptr)
107 debug (*ptr);
108 else
109 fprintf (stderr, "<nil>\n");
113 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
114 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
115 of the statement. */
117 void
118 print_gimple_expr (FILE *file, gimple *g, int spc, int flags)
120 flags |= TDF_RHS_ONLY;
121 pretty_printer buffer;
122 pp_needs_newline (&buffer) = true;
123 buffer.buffer->stream = file;
124 pp_gimple_stmt_1 (&buffer, g, spc, flags);
125 pp_flush (&buffer);
129 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
130 spaces and FLAGS as in pp_gimple_stmt_1.
131 The caller is responsible for calling pp_flush on BUFFER to finalize
132 the pretty printer. */
134 static void
135 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
137 gimple_stmt_iterator i;
139 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
141 gimple *gs = gsi_stmt (i);
142 INDENT (spc);
143 pp_gimple_stmt_1 (buffer, gs, spc, flags);
144 if (!gsi_one_before_end_p (i))
145 pp_newline (buffer);
150 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
151 FLAGS as in pp_gimple_stmt_1. */
153 void
154 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
156 pretty_printer buffer;
157 pp_needs_newline (&buffer) = true;
158 buffer.buffer->stream = file;
159 dump_gimple_seq (&buffer, seq, spc, flags);
160 pp_newline_and_flush (&buffer);
164 /* Print the GIMPLE sequence SEQ on stderr. */
166 DEBUG_FUNCTION void
167 debug_gimple_seq (gimple_seq seq)
169 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
173 /* A simple helper to pretty-print some of the gimple tuples in the printf
174 style. The format modifiers are preceded by '%' and are:
175 'G' - outputs a string corresponding to the code of the given gimple,
176 'S' - outputs a gimple_seq with indent of spc + 2,
177 'T' - outputs the tree t,
178 'd' - outputs an int as a decimal,
179 's' - outputs a string,
180 'n' - outputs a newline,
181 'x' - outputs an int as hexadecimal,
182 '+' - increases indent by 2 then outputs a newline,
183 '-' - decreases indent by 2 then outputs a newline. */
185 static void
186 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
187 const char *fmt, ...)
189 va_list args;
190 const char *c;
191 const char *tmp;
193 va_start (args, fmt);
194 for (c = fmt; *c; c++)
196 if (*c == '%')
198 gimple_seq seq;
199 tree t;
200 gimple *g;
201 switch (*++c)
203 case 'G':
204 g = va_arg (args, gimple *);
205 tmp = gimple_code_name[gimple_code (g)];
206 pp_string (buffer, tmp);
207 break;
209 case 'S':
210 seq = va_arg (args, gimple_seq);
211 pp_newline (buffer);
212 dump_gimple_seq (buffer, seq, spc + 2, flags);
213 newline_and_indent (buffer, spc);
214 break;
216 case 'T':
217 t = va_arg (args, tree);
218 if (t == NULL_TREE)
219 pp_string (buffer, "NULL");
220 else
221 dump_generic_node (buffer, t, spc, flags, false);
222 break;
224 case 'd':
225 pp_decimal_int (buffer, va_arg (args, int));
226 break;
228 case 's':
229 pp_string (buffer, va_arg (args, char *));
230 break;
232 case 'n':
233 newline_and_indent (buffer, spc);
234 break;
236 case 'x':
237 pp_scalar (buffer, "%x", va_arg (args, int));
238 break;
240 case '+':
241 spc += 2;
242 newline_and_indent (buffer, spc);
243 break;
245 case '-':
246 spc -= 2;
247 newline_and_indent (buffer, spc);
248 break;
250 default:
251 gcc_unreachable ();
254 else
255 pp_character (buffer, *c);
257 va_end (args);
261 /* Helper for dump_gimple_assign. Print the unary RHS of the
262 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
264 static void
265 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
267 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
268 tree lhs = gimple_assign_lhs (gs);
269 tree rhs = gimple_assign_rhs1 (gs);
271 switch (rhs_code)
273 case VIEW_CONVERT_EXPR:
274 case ASSERT_EXPR:
275 dump_generic_node (buffer, rhs, spc, flags, false);
276 break;
278 case FIXED_CONVERT_EXPR:
279 case ADDR_SPACE_CONVERT_EXPR:
280 case FIX_TRUNC_EXPR:
281 case FLOAT_EXPR:
282 CASE_CONVERT:
283 pp_left_paren (buffer);
284 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
285 pp_string (buffer, ") ");
286 if (op_prio (rhs) < op_code_prio (rhs_code))
288 pp_left_paren (buffer);
289 dump_generic_node (buffer, rhs, spc, flags, false);
290 pp_right_paren (buffer);
292 else
293 dump_generic_node (buffer, rhs, spc, flags, false);
294 break;
296 case PAREN_EXPR:
297 pp_string (buffer, "((");
298 dump_generic_node (buffer, rhs, spc, flags, false);
299 pp_string (buffer, "))");
300 break;
302 case ABS_EXPR:
303 pp_string (buffer, "ABS_EXPR <");
304 dump_generic_node (buffer, rhs, spc, flags, false);
305 pp_greater (buffer);
306 break;
308 default:
309 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
310 || TREE_CODE_CLASS (rhs_code) == tcc_constant
311 || TREE_CODE_CLASS (rhs_code) == tcc_reference
312 || rhs_code == SSA_NAME
313 || rhs_code == ADDR_EXPR
314 || rhs_code == CONSTRUCTOR)
316 dump_generic_node (buffer, rhs, spc, flags, false);
317 break;
319 else if (rhs_code == BIT_NOT_EXPR)
320 pp_complement (buffer);
321 else if (rhs_code == TRUTH_NOT_EXPR)
322 pp_exclamation (buffer);
323 else if (rhs_code == NEGATE_EXPR)
324 pp_minus (buffer);
325 else
327 pp_left_bracket (buffer);
328 pp_string (buffer, get_tree_code_name (rhs_code));
329 pp_string (buffer, "] ");
332 if (op_prio (rhs) < op_code_prio (rhs_code))
334 pp_left_paren (buffer);
335 dump_generic_node (buffer, rhs, spc, flags, false);
336 pp_right_paren (buffer);
338 else
339 dump_generic_node (buffer, rhs, spc, flags, false);
340 break;
345 /* Helper for dump_gimple_assign. Print the binary RHS of the
346 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
348 static void
349 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
351 const char *p;
352 enum tree_code code = gimple_assign_rhs_code (gs);
353 switch (code)
355 case COMPLEX_EXPR:
356 case MIN_EXPR:
357 case MAX_EXPR:
358 case VEC_WIDEN_MULT_HI_EXPR:
359 case VEC_WIDEN_MULT_LO_EXPR:
360 case VEC_WIDEN_MULT_EVEN_EXPR:
361 case VEC_WIDEN_MULT_ODD_EXPR:
362 case VEC_PACK_TRUNC_EXPR:
363 case VEC_PACK_SAT_EXPR:
364 case VEC_PACK_FIX_TRUNC_EXPR:
365 case VEC_WIDEN_LSHIFT_HI_EXPR:
366 case VEC_WIDEN_LSHIFT_LO_EXPR:
367 for (p = get_tree_code_name (code); *p; p++)
368 pp_character (buffer, TOUPPER (*p));
369 pp_string (buffer, " <");
370 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
371 pp_string (buffer, ", ");
372 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
373 pp_greater (buffer);
374 break;
376 default:
377 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
379 pp_left_paren (buffer);
380 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
381 false);
382 pp_right_paren (buffer);
384 else
385 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
386 pp_space (buffer);
387 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
388 pp_space (buffer);
389 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
391 pp_left_paren (buffer);
392 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
393 false);
394 pp_right_paren (buffer);
396 else
397 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
401 /* Helper for dump_gimple_assign. Print the ternary RHS of the
402 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
404 static void
405 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
407 const char *p;
408 enum tree_code code = gimple_assign_rhs_code (gs);
409 switch (code)
411 case WIDEN_MULT_PLUS_EXPR:
412 case WIDEN_MULT_MINUS_EXPR:
413 for (p = get_tree_code_name (code); *p; p++)
414 pp_character (buffer, TOUPPER (*p));
415 pp_string (buffer, " <");
416 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
417 pp_string (buffer, ", ");
418 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
419 pp_string (buffer, ", ");
420 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
421 pp_greater (buffer);
422 break;
424 case FMA_EXPR:
425 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
426 pp_string (buffer, " * ");
427 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
428 pp_string (buffer, " + ");
429 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
430 break;
432 case DOT_PROD_EXPR:
433 pp_string (buffer, "DOT_PROD_EXPR <");
434 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
435 pp_string (buffer, ", ");
436 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
437 pp_string (buffer, ", ");
438 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
439 pp_greater (buffer);
440 break;
442 case SAD_EXPR:
443 pp_string (buffer, "SAD_EXPR <");
444 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
445 pp_string (buffer, ", ");
446 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
447 pp_string (buffer, ", ");
448 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
449 pp_greater (buffer);
450 break;
452 case VEC_PERM_EXPR:
453 pp_string (buffer, "VEC_PERM_EXPR <");
454 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
455 pp_string (buffer, ", ");
456 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
457 pp_string (buffer, ", ");
458 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
459 pp_greater (buffer);
460 break;
462 case REALIGN_LOAD_EXPR:
463 pp_string (buffer, "REALIGN_LOAD <");
464 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
465 pp_string (buffer, ", ");
466 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
467 pp_string (buffer, ", ");
468 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
469 pp_greater (buffer);
470 break;
472 case COND_EXPR:
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);
478 break;
480 case VEC_COND_EXPR:
481 pp_string (buffer, "VEC_COND_EXPR <");
482 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
483 pp_string (buffer, ", ");
484 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
485 pp_string (buffer, ", ");
486 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
487 pp_greater (buffer);
488 break;
490 case BIT_INSERT_EXPR:
491 pp_string (buffer, "BIT_INSERT_EXPR <");
492 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
493 pp_string (buffer, ", ");
494 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
495 pp_string (buffer, ", ");
496 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
497 pp_string (buffer, " (");
498 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
499 pp_decimal_int (buffer,
500 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
501 else
502 dump_generic_node (buffer,
503 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
504 spc, flags, false);
505 pp_string (buffer, " bits)>");
506 break;
508 default:
509 gcc_unreachable ();
514 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
515 pp_gimple_stmt_1. */
517 static void
518 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
520 if (flags & TDF_RAW)
522 tree arg1 = NULL;
523 tree arg2 = NULL;
524 tree arg3 = NULL;
525 switch (gimple_num_ops (gs))
527 case 4:
528 arg3 = gimple_assign_rhs3 (gs);
529 /* FALLTHRU */
530 case 3:
531 arg2 = gimple_assign_rhs2 (gs);
532 /* FALLTHRU */
533 case 2:
534 arg1 = gimple_assign_rhs1 (gs);
535 break;
536 default:
537 gcc_unreachable ();
540 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
541 get_tree_code_name (gimple_assign_rhs_code (gs)),
542 gimple_assign_lhs (gs), arg1, arg2, arg3);
544 else
546 if (!(flags & TDF_RHS_ONLY))
548 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
549 pp_space (buffer);
550 pp_equal (buffer);
552 if (gimple_assign_nontemporal_move_p (gs))
553 pp_string (buffer, "{nt}");
555 if (gimple_has_volatile_ops (gs))
556 pp_string (buffer, "{v}");
558 pp_space (buffer);
561 if (gimple_num_ops (gs) == 2)
562 dump_unary_rhs (buffer, gs, spc, flags);
563 else if (gimple_num_ops (gs) == 3)
564 dump_binary_rhs (buffer, gs, spc, flags);
565 else if (gimple_num_ops (gs) == 4)
566 dump_ternary_rhs (buffer, gs, spc, flags);
567 else
568 gcc_unreachable ();
569 if (!(flags & TDF_RHS_ONLY))
570 pp_semicolon (buffer);
575 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
576 pp_gimple_stmt_1. */
578 static void
579 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
581 tree t, t2;
583 t = gimple_return_retval (gs);
584 t2 = gimple_return_retbnd (gs);
585 if (flags & TDF_RAW)
586 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
587 else
589 pp_string (buffer, "return");
590 if (t)
592 pp_space (buffer);
593 dump_generic_node (buffer, t, spc, flags, false);
595 if (t2)
597 pp_string (buffer, ", ");
598 dump_generic_node (buffer, t2, spc, flags, false);
600 pp_semicolon (buffer);
605 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
606 dump_gimple_call. */
608 static void
609 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
611 size_t i = 0;
613 /* Pretty print first arg to certain internal fns. */
614 if (gimple_call_internal_p (gs))
616 const char *const *enums = NULL;
617 unsigned limit = 0;
619 switch (gimple_call_internal_fn (gs))
621 case IFN_UNIQUE:
622 #define DEF(X) #X
623 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
624 #undef DEF
625 enums = unique_args;
627 limit = ARRAY_SIZE (unique_args);
628 break;
630 case IFN_GOACC_LOOP:
631 #define DEF(X) #X
632 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
633 #undef DEF
634 enums = loop_args;
635 limit = ARRAY_SIZE (loop_args);
636 break;
638 case IFN_GOACC_REDUCTION:
639 #define DEF(X) #X
640 static const char *const reduction_args[]
641 = {IFN_GOACC_REDUCTION_CODES};
642 #undef DEF
643 enums = reduction_args;
644 limit = ARRAY_SIZE (reduction_args);
645 break;
647 default:
648 break;
650 if (limit)
652 tree arg0 = gimple_call_arg (gs, 0);
653 HOST_WIDE_INT v;
655 if (TREE_CODE (arg0) == INTEGER_CST
656 && tree_fits_shwi_p (arg0)
657 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
659 i++;
660 pp_string (buffer, enums[v]);
665 for (; i < gimple_call_num_args (gs); i++)
667 if (i)
668 pp_string (buffer, ", ");
669 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
672 if (gimple_call_va_arg_pack_p (gs))
674 if (i)
675 pp_string (buffer, ", ");
677 pp_string (buffer, "__builtin_va_arg_pack ()");
681 /* Dump the points-to solution *PT to BUFFER. */
683 static void
684 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
686 if (pt->anything)
688 pp_string (buffer, "anything ");
689 return;
691 if (pt->nonlocal)
692 pp_string (buffer, "nonlocal ");
693 if (pt->escaped)
694 pp_string (buffer, "escaped ");
695 if (pt->ipa_escaped)
696 pp_string (buffer, "unit-escaped ");
697 if (pt->null)
698 pp_string (buffer, "null ");
699 if (pt->vars
700 && !bitmap_empty_p (pt->vars))
702 bitmap_iterator bi;
703 unsigned i;
704 pp_string (buffer, "{ ");
705 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
707 pp_string (buffer, "D.");
708 pp_decimal_int (buffer, i);
709 pp_space (buffer);
711 pp_right_brace (buffer);
712 if (pt->vars_contains_nonlocal
713 || pt->vars_contains_escaped
714 || pt->vars_contains_escaped_heap
715 || pt->vars_contains_restrict)
717 const char *comma = "";
718 pp_string (buffer, " (");
719 if (pt->vars_contains_nonlocal)
721 pp_string (buffer, "nonlocal");
722 comma = ", ";
724 if (pt->vars_contains_escaped)
726 pp_string (buffer, comma);
727 pp_string (buffer, "escaped");
728 comma = ", ";
730 if (pt->vars_contains_escaped_heap)
732 pp_string (buffer, comma);
733 pp_string (buffer, "escaped heap");
734 comma = ", ";
736 if (pt->vars_contains_restrict)
738 pp_string (buffer, comma);
739 pp_string (buffer, "restrict");
740 comma = ", ";
742 if (pt->vars_contains_interposable)
744 pp_string (buffer, comma);
745 pp_string (buffer, "interposable");
747 pp_string (buffer, ")");
753 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
754 pp_gimple_stmt_1. */
756 static void
757 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
759 tree lhs = gimple_call_lhs (gs);
760 tree fn = gimple_call_fn (gs);
762 if (flags & TDF_ALIAS)
764 struct pt_solution *pt;
765 pt = gimple_call_use_set (gs);
766 if (!pt_solution_empty_p (pt))
768 pp_string (buffer, "# USE = ");
769 pp_points_to_solution (buffer, pt);
770 newline_and_indent (buffer, spc);
772 pt = gimple_call_clobber_set (gs);
773 if (!pt_solution_empty_p (pt))
775 pp_string (buffer, "# CLB = ");
776 pp_points_to_solution (buffer, pt);
777 newline_and_indent (buffer, spc);
781 if (flags & TDF_RAW)
783 if (gimple_call_internal_p (gs))
784 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
785 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
786 else
787 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
788 if (gimple_call_num_args (gs) > 0)
790 pp_string (buffer, ", ");
791 dump_gimple_call_args (buffer, gs, flags);
793 pp_greater (buffer);
795 else
797 if (lhs && !(flags & TDF_RHS_ONLY))
799 dump_generic_node (buffer, lhs, spc, flags, false);
800 pp_string (buffer, " =");
802 if (gimple_has_volatile_ops (gs))
803 pp_string (buffer, "{v}");
805 pp_space (buffer);
807 if (gimple_call_internal_p (gs))
808 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
809 else
810 print_call_name (buffer, fn, flags);
811 pp_string (buffer, " (");
812 dump_gimple_call_args (buffer, gs, flags);
813 pp_right_paren (buffer);
814 if (!(flags & TDF_RHS_ONLY))
815 pp_semicolon (buffer);
818 if (gimple_call_chain (gs))
820 pp_string (buffer, " [static-chain: ");
821 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
822 pp_right_bracket (buffer);
825 if (gimple_call_return_slot_opt_p (gs))
826 pp_string (buffer, " [return slot optimization]");
827 if (gimple_call_tail_p (gs))
828 pp_string (buffer, " [tail call]");
829 if (gimple_call_must_tail_p (gs))
830 pp_string (buffer, " [must tail call]");
832 if (fn == NULL)
833 return;
835 /* Dump the arguments of _ITM_beginTransaction sanely. */
836 if (TREE_CODE (fn) == ADDR_EXPR)
837 fn = TREE_OPERAND (fn, 0);
838 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
839 pp_string (buffer, " [tm-clone]");
840 if (TREE_CODE (fn) == FUNCTION_DECL
841 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
842 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
843 && gimple_call_num_args (gs) > 0)
845 tree t = gimple_call_arg (gs, 0);
846 unsigned HOST_WIDE_INT props;
847 gcc_assert (TREE_CODE (t) == INTEGER_CST);
849 pp_string (buffer, " [ ");
851 /* Get the transaction code properties. */
852 props = TREE_INT_CST_LOW (t);
854 if (props & PR_INSTRUMENTEDCODE)
855 pp_string (buffer, "instrumentedCode ");
856 if (props & PR_UNINSTRUMENTEDCODE)
857 pp_string (buffer, "uninstrumentedCode ");
858 if (props & PR_HASNOXMMUPDATE)
859 pp_string (buffer, "hasNoXMMUpdate ");
860 if (props & PR_HASNOABORT)
861 pp_string (buffer, "hasNoAbort ");
862 if (props & PR_HASNOIRREVOCABLE)
863 pp_string (buffer, "hasNoIrrevocable ");
864 if (props & PR_DOESGOIRREVOCABLE)
865 pp_string (buffer, "doesGoIrrevocable ");
866 if (props & PR_HASNOSIMPLEREADS)
867 pp_string (buffer, "hasNoSimpleReads ");
868 if (props & PR_AWBARRIERSOMITTED)
869 pp_string (buffer, "awBarriersOmitted ");
870 if (props & PR_RARBARRIERSOMITTED)
871 pp_string (buffer, "RaRBarriersOmitted ");
872 if (props & PR_UNDOLOGCODE)
873 pp_string (buffer, "undoLogCode ");
874 if (props & PR_PREFERUNINSTRUMENTED)
875 pp_string (buffer, "preferUninstrumented ");
876 if (props & PR_EXCEPTIONBLOCK)
877 pp_string (buffer, "exceptionBlock ");
878 if (props & PR_HASELSE)
879 pp_string (buffer, "hasElse ");
880 if (props & PR_READONLY)
881 pp_string (buffer, "readOnly ");
883 pp_right_bracket (buffer);
888 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
889 pp_gimple_stmt_1. */
891 static void
892 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
893 int flags)
895 unsigned int i;
897 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
898 if (flags & TDF_RAW)
899 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
900 gimple_switch_index (gs));
901 else
903 pp_string (buffer, "switch (");
904 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
905 if (flags & TDF_GIMPLE)
906 pp_string (buffer, ") {");
907 else
908 pp_string (buffer, ") <");
911 for (i = 0; i < gimple_switch_num_labels (gs); i++)
913 tree case_label = gimple_switch_label (gs, i);
914 gcc_checking_assert (case_label != NULL_TREE);
915 dump_generic_node (buffer, case_label, spc, flags, false);
916 pp_space (buffer);
917 tree label = CASE_LABEL (case_label);
918 dump_generic_node (buffer, label, spc, flags, false);
920 if (cfun && cfun->cfg)
922 basic_block dest = label_to_block (label);
923 if (dest)
925 edge label_edge = find_edge (gimple_bb (gs), dest);
926 if (label_edge && !(flags & TDF_GIMPLE))
927 dump_edge_probability (buffer, label_edge);
931 if (i < gimple_switch_num_labels (gs) - 1)
933 if (flags & TDF_GIMPLE)
934 pp_string (buffer, "; ");
935 else
936 pp_string (buffer, ", ");
939 if (flags & TDF_GIMPLE)
940 pp_string (buffer, "; }");
941 else
942 pp_greater (buffer);
946 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
947 pp_gimple_stmt_1. */
949 static void
950 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
952 if (flags & TDF_RAW)
953 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
954 get_tree_code_name (gimple_cond_code (gs)),
955 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
956 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
957 else
959 if (!(flags & TDF_RHS_ONLY))
960 pp_string (buffer, "if (");
961 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
962 pp_space (buffer);
963 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
964 pp_space (buffer);
965 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
966 if (!(flags & TDF_RHS_ONLY))
968 edge_iterator ei;
969 edge e, true_edge = NULL, false_edge = NULL;
970 basic_block bb = gimple_bb (gs);
972 if (bb)
974 FOR_EACH_EDGE (e, ei, bb->succs)
976 if (e->flags & EDGE_TRUE_VALUE)
977 true_edge = e;
978 else if (e->flags & EDGE_FALSE_VALUE)
979 false_edge = e;
983 bool has_edge_info = true_edge != NULL && false_edge != NULL;
985 pp_right_paren (buffer);
987 if (gimple_cond_true_label (gs))
989 pp_string (buffer, " goto ");
990 dump_generic_node (buffer, gimple_cond_true_label (gs),
991 spc, flags, false);
992 if (has_edge_info && !(flags & TDF_GIMPLE))
993 dump_edge_probability (buffer, true_edge);
994 pp_semicolon (buffer);
996 if (gimple_cond_false_label (gs))
998 pp_string (buffer, " else goto ");
999 dump_generic_node (buffer, gimple_cond_false_label (gs),
1000 spc, flags, false);
1001 if (has_edge_info && !(flags & TDF_GIMPLE))
1002 dump_edge_probability (buffer, false_edge);
1004 pp_semicolon (buffer);
1011 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1012 spaces of indent. FLAGS specifies details to show in the dump (see
1013 TDF_* in dumpfils.h). */
1015 static void
1016 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
1018 tree label = gimple_label_label (gs);
1019 if (flags & TDF_RAW)
1020 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1021 else
1023 dump_generic_node (buffer, label, spc, flags, false);
1024 basic_block bb = gimple_bb (gs);
1025 if (bb && !(flags & TDF_GIMPLE))
1026 pp_scalar (buffer, " [%.1f%%]",
1027 bb->frequency * 100.0 / REG_BR_PROB_BASE);
1028 pp_colon (buffer);
1030 if (flags & TDF_GIMPLE)
1031 return;
1032 if (DECL_NONLOCAL (label))
1033 pp_string (buffer, " [non-local]");
1034 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1035 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1038 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1039 spaces of indent. FLAGS specifies details to show in the dump (see
1040 TDF_* in dumpfile.h). */
1042 static void
1043 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
1045 tree label = gimple_goto_dest (gs);
1046 if (flags & TDF_RAW)
1047 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1048 else
1049 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1053 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1054 spaces of indent. FLAGS specifies details to show in the dump (see
1055 TDF_* in dumpfile.h). */
1057 static void
1058 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
1060 if (flags & TDF_RAW)
1061 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1062 else
1063 pp_left_brace (buffer);
1064 if (!(flags & TDF_SLIM))
1066 tree var;
1068 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1070 newline_and_indent (buffer, 2);
1071 print_declaration (buffer, var, spc, flags);
1073 if (gimple_bind_vars (gs))
1074 pp_newline (buffer);
1076 pp_newline (buffer);
1077 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1078 newline_and_indent (buffer, spc);
1079 if (flags & TDF_RAW)
1080 pp_greater (buffer);
1081 else
1082 pp_right_brace (buffer);
1086 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1087 indent. FLAGS specifies details to show in the dump (see TDF_* in
1088 dumpfile.h). */
1090 static void
1091 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
1093 if (flags & TDF_RAW)
1095 const char *type;
1096 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1097 type = "GIMPLE_TRY_CATCH";
1098 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1099 type = "GIMPLE_TRY_FINALLY";
1100 else
1101 type = "UNKNOWN GIMPLE_TRY";
1102 dump_gimple_fmt (buffer, spc, flags,
1103 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1104 gimple_try_eval (gs), gimple_try_cleanup (gs));
1106 else
1108 pp_string (buffer, "try");
1109 newline_and_indent (buffer, spc + 2);
1110 pp_left_brace (buffer);
1111 pp_newline (buffer);
1113 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1114 newline_and_indent (buffer, spc + 2);
1115 pp_right_brace (buffer);
1117 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1119 newline_and_indent (buffer, spc);
1120 pp_string (buffer, "catch");
1121 newline_and_indent (buffer, spc + 2);
1122 pp_left_brace (buffer);
1124 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1126 newline_and_indent (buffer, spc);
1127 pp_string (buffer, "finally");
1128 newline_and_indent (buffer, spc + 2);
1129 pp_left_brace (buffer);
1131 else
1132 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1134 pp_newline (buffer);
1135 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1136 newline_and_indent (buffer, spc + 2);
1137 pp_right_brace (buffer);
1142 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1143 indent. FLAGS specifies details to show in the dump (see TDF_* in
1144 dumpfile.h). */
1146 static void
1147 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
1149 if (flags & TDF_RAW)
1150 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1151 gimple_catch_types (gs), gimple_catch_handler (gs));
1152 else
1153 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1154 gimple_catch_types (gs), gimple_catch_handler (gs));
1158 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1159 indent. FLAGS specifies details to show in the dump (see TDF_* in
1160 dumpfile.h). */
1162 static void
1163 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1164 int flags)
1166 if (flags & TDF_RAW)
1167 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1168 gimple_eh_filter_types (gs),
1169 gimple_eh_filter_failure (gs));
1170 else
1171 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1172 gimple_eh_filter_types (gs),
1173 gimple_eh_filter_failure (gs));
1177 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1179 static void
1180 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1181 geh_mnt *gs, int spc, int flags)
1183 if (flags & TDF_RAW)
1184 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1185 gimple_eh_must_not_throw_fndecl (gs));
1186 else
1187 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1188 gimple_eh_must_not_throw_fndecl (gs));
1192 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1193 indent. FLAGS specifies details to show in the dump (see TDF_* in
1194 dumpfile.h). */
1196 static void
1197 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1198 int flags)
1200 if (flags & TDF_RAW)
1201 dump_gimple_fmt (buffer, spc, flags,
1202 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1203 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1204 else
1205 dump_gimple_fmt (buffer, spc, flags,
1206 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1207 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1211 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1212 indent. FLAGS specifies details to show in the dump (see TDF_* in
1213 dumpfile.h). */
1215 static void
1216 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
1218 if (flags & TDF_RAW)
1219 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1220 gimple_resx_region (gs));
1221 else
1222 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1225 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1227 static void
1228 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int flags)
1230 if (flags & TDF_RAW)
1231 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1232 gimple_eh_dispatch_region (gs));
1233 else
1234 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1235 gimple_eh_dispatch_region (gs));
1238 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1239 of indent. FLAGS specifies details to show in the dump (see TDF_*
1240 in dumpfile.h). */
1242 static void
1243 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
1245 switch (gs->subcode)
1247 case GIMPLE_DEBUG_BIND:
1248 if (flags & TDF_RAW)
1249 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1250 gimple_debug_bind_get_var (gs),
1251 gimple_debug_bind_get_value (gs));
1252 else
1253 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1254 gimple_debug_bind_get_var (gs),
1255 gimple_debug_bind_get_value (gs));
1256 break;
1258 case GIMPLE_DEBUG_SOURCE_BIND:
1259 if (flags & TDF_RAW)
1260 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1261 gimple_debug_source_bind_get_var (gs),
1262 gimple_debug_source_bind_get_value (gs));
1263 else
1264 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1265 gimple_debug_source_bind_get_var (gs),
1266 gimple_debug_source_bind_get_value (gs));
1267 break;
1269 default:
1270 gcc_unreachable ();
1274 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1275 static void
1276 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
1278 size_t i;
1280 if (flags & TDF_RAW)
1282 const char *kind;
1283 switch (gimple_omp_for_kind (gs))
1285 case GF_OMP_FOR_KIND_FOR:
1286 kind = "";
1287 break;
1288 case GF_OMP_FOR_KIND_DISTRIBUTE:
1289 kind = " distribute";
1290 break;
1291 case GF_OMP_FOR_KIND_TASKLOOP:
1292 kind = " taskloop";
1293 break;
1294 case GF_OMP_FOR_KIND_CILKFOR:
1295 kind = " _Cilk_for";
1296 break;
1297 case GF_OMP_FOR_KIND_OACC_LOOP:
1298 kind = " oacc_loop";
1299 break;
1300 case GF_OMP_FOR_KIND_SIMD:
1301 kind = " simd";
1302 break;
1303 case GF_OMP_FOR_KIND_CILKSIMD:
1304 kind = " cilksimd";
1305 break;
1306 default:
1307 gcc_unreachable ();
1309 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1310 kind, gimple_omp_body (gs));
1311 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1312 dump_gimple_fmt (buffer, spc, flags, " >,");
1313 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1314 dump_gimple_fmt (buffer, spc, flags,
1315 "%+%T, %T, %T, %s, %T,%n",
1316 gimple_omp_for_index (gs, i),
1317 gimple_omp_for_initial (gs, i),
1318 gimple_omp_for_final (gs, i),
1319 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1320 gimple_omp_for_incr (gs, i));
1321 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1322 gimple_omp_for_pre_body (gs));
1324 else
1326 switch (gimple_omp_for_kind (gs))
1328 case GF_OMP_FOR_KIND_FOR:
1329 pp_string (buffer, "#pragma omp for");
1330 break;
1331 case GF_OMP_FOR_KIND_DISTRIBUTE:
1332 pp_string (buffer, "#pragma omp distribute");
1333 break;
1334 case GF_OMP_FOR_KIND_TASKLOOP:
1335 pp_string (buffer, "#pragma omp taskloop");
1336 break;
1337 case GF_OMP_FOR_KIND_CILKFOR:
1338 break;
1339 case GF_OMP_FOR_KIND_OACC_LOOP:
1340 pp_string (buffer, "#pragma acc loop");
1341 break;
1342 case GF_OMP_FOR_KIND_SIMD:
1343 pp_string (buffer, "#pragma omp simd");
1344 break;
1345 case GF_OMP_FOR_KIND_CILKSIMD:
1346 pp_string (buffer, "#pragma simd");
1347 break;
1348 case GF_OMP_FOR_KIND_GRID_LOOP:
1349 pp_string (buffer, "#pragma omp for grid_loop");
1350 break;
1351 default:
1352 gcc_unreachable ();
1354 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1355 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1356 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1358 if (i)
1359 spc += 2;
1360 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1361 pp_string (buffer, "_Cilk_for (");
1362 else
1364 newline_and_indent (buffer, spc);
1365 pp_string (buffer, "for (");
1367 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1368 flags, false);
1369 pp_string (buffer, " = ");
1370 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1371 flags, false);
1372 pp_string (buffer, "; ");
1374 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1375 flags, false);
1376 pp_space (buffer);
1377 switch (gimple_omp_for_cond (gs, i))
1379 case LT_EXPR:
1380 pp_less (buffer);
1381 break;
1382 case GT_EXPR:
1383 pp_greater (buffer);
1384 break;
1385 case LE_EXPR:
1386 pp_less_equal (buffer);
1387 break;
1388 case GE_EXPR:
1389 pp_greater_equal (buffer);
1390 break;
1391 case NE_EXPR:
1392 pp_string (buffer, "!=");
1393 break;
1394 default:
1395 gcc_unreachable ();
1397 pp_space (buffer);
1398 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1399 flags, false);
1400 pp_string (buffer, "; ");
1402 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1403 flags, false);
1404 pp_string (buffer, " = ");
1405 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1406 flags, false);
1407 pp_right_paren (buffer);
1410 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1412 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1413 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1414 newline_and_indent (buffer, spc + 2);
1415 pp_left_brace (buffer);
1416 pp_newline (buffer);
1417 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1418 newline_and_indent (buffer, spc + 2);
1419 pp_right_brace (buffer);
1424 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1426 static void
1427 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1428 int spc, int flags)
1430 if (flags & TDF_RAW)
1432 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1433 gimple_omp_continue_control_def (gs),
1434 gimple_omp_continue_control_use (gs));
1436 else
1438 pp_string (buffer, "#pragma omp continue (");
1439 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1440 spc, flags, false);
1441 pp_comma (buffer);
1442 pp_space (buffer);
1443 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1444 spc, flags, false);
1445 pp_right_paren (buffer);
1449 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1451 static void
1452 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1453 int spc, int flags)
1455 if (flags & TDF_RAW)
1457 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1458 gimple_omp_body (gs));
1459 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1460 dump_gimple_fmt (buffer, spc, flags, " >");
1462 else
1464 pp_string (buffer, "#pragma omp single");
1465 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1466 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1468 newline_and_indent (buffer, spc + 2);
1469 pp_left_brace (buffer);
1470 pp_newline (buffer);
1471 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1472 newline_and_indent (buffer, spc + 2);
1473 pp_right_brace (buffer);
1478 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1480 static void
1481 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1482 int spc, int flags)
1484 const char *kind;
1485 switch (gimple_omp_target_kind (gs))
1487 case GF_OMP_TARGET_KIND_REGION:
1488 kind = "";
1489 break;
1490 case GF_OMP_TARGET_KIND_DATA:
1491 kind = " data";
1492 break;
1493 case GF_OMP_TARGET_KIND_UPDATE:
1494 kind = " update";
1495 break;
1496 case GF_OMP_TARGET_KIND_ENTER_DATA:
1497 kind = " enter data";
1498 break;
1499 case GF_OMP_TARGET_KIND_EXIT_DATA:
1500 kind = " exit data";
1501 break;
1502 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1503 kind = " oacc_kernels";
1504 break;
1505 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1506 kind = " oacc_parallel";
1507 break;
1508 case GF_OMP_TARGET_KIND_OACC_DATA:
1509 kind = " oacc_data";
1510 break;
1511 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1512 kind = " oacc_update";
1513 break;
1514 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1515 kind = " oacc_enter_exit_data";
1516 break;
1517 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1518 kind = " oacc_declare";
1519 break;
1520 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1521 kind = " oacc_host_data";
1522 break;
1523 default:
1524 gcc_unreachable ();
1526 if (flags & TDF_RAW)
1528 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1529 kind, gimple_omp_body (gs));
1530 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1531 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1532 gimple_omp_target_child_fn (gs),
1533 gimple_omp_target_data_arg (gs));
1535 else
1537 pp_string (buffer, "#pragma omp target");
1538 pp_string (buffer, kind);
1539 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1540 if (gimple_omp_target_child_fn (gs))
1542 pp_string (buffer, " [child fn: ");
1543 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1544 spc, flags, false);
1545 pp_string (buffer, " (");
1546 if (gimple_omp_target_data_arg (gs))
1547 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1548 spc, flags, false);
1549 else
1550 pp_string (buffer, "???");
1551 pp_string (buffer, ")]");
1553 gimple_seq body = gimple_omp_body (gs);
1554 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1556 newline_and_indent (buffer, spc + 2);
1557 pp_left_brace (buffer);
1558 pp_newline (buffer);
1559 dump_gimple_seq (buffer, body, spc + 4, flags);
1560 newline_and_indent (buffer, spc + 2);
1561 pp_right_brace (buffer);
1563 else if (body)
1565 pp_newline (buffer);
1566 dump_gimple_seq (buffer, body, spc + 2, flags);
1571 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1573 static void
1574 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1575 int flags)
1577 if (flags & TDF_RAW)
1579 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1580 gimple_omp_body (gs));
1581 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1582 dump_gimple_fmt (buffer, spc, flags, " >");
1584 else
1586 pp_string (buffer, "#pragma omp teams");
1587 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1588 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1590 newline_and_indent (buffer, spc + 2);
1591 pp_character (buffer, '{');
1592 pp_newline (buffer);
1593 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1594 newline_and_indent (buffer, spc + 2);
1595 pp_character (buffer, '}');
1600 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1602 static void
1603 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1604 int spc, int flags)
1606 if (flags & TDF_RAW)
1608 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1609 gimple_omp_body (gs));
1610 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1611 dump_gimple_fmt (buffer, spc, flags, " >");
1613 else
1615 pp_string (buffer, "#pragma omp sections");
1616 if (gimple_omp_sections_control (gs))
1618 pp_string (buffer, " <");
1619 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1620 flags, false);
1621 pp_greater (buffer);
1623 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1624 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1626 newline_and_indent (buffer, spc + 2);
1627 pp_left_brace (buffer);
1628 pp_newline (buffer);
1629 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1630 newline_and_indent (buffer, spc + 2);
1631 pp_right_brace (buffer);
1636 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1637 pretty_printer BUFFER. */
1639 static void
1640 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc, int flags)
1642 if (flags & TDF_RAW)
1643 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1644 gimple_omp_body (gs));
1645 else
1647 switch (gimple_code (gs))
1649 case GIMPLE_OMP_MASTER:
1650 pp_string (buffer, "#pragma omp master");
1651 break;
1652 case GIMPLE_OMP_TASKGROUP:
1653 pp_string (buffer, "#pragma omp taskgroup");
1654 break;
1655 case GIMPLE_OMP_SECTION:
1656 pp_string (buffer, "#pragma omp section");
1657 break;
1658 case GIMPLE_OMP_GRID_BODY:
1659 pp_string (buffer, "#pragma omp gridified body");
1660 break;
1661 default:
1662 gcc_unreachable ();
1664 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1666 newline_and_indent (buffer, spc + 2);
1667 pp_left_brace (buffer);
1668 pp_newline (buffer);
1669 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1670 newline_and_indent (buffer, spc + 2);
1671 pp_right_brace (buffer);
1676 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1678 static void
1679 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1680 int spc, int flags)
1682 if (flags & TDF_RAW)
1683 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1684 gimple_omp_body (gs));
1685 else
1687 pp_string (buffer, "#pragma omp critical");
1688 if (gimple_omp_critical_name (gs))
1690 pp_string (buffer, " (");
1691 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1692 flags, false);
1693 pp_right_paren (buffer);
1695 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1696 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1698 newline_and_indent (buffer, spc + 2);
1699 pp_left_brace (buffer);
1700 pp_newline (buffer);
1701 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1702 newline_and_indent (buffer, spc + 2);
1703 pp_right_brace (buffer);
1708 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1710 static void
1711 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1712 int spc, int flags)
1714 if (flags & TDF_RAW)
1715 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1716 gimple_omp_body (gs));
1717 else
1719 pp_string (buffer, "#pragma omp ordered");
1720 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1721 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1723 newline_and_indent (buffer, spc + 2);
1724 pp_left_brace (buffer);
1725 pp_newline (buffer);
1726 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1727 newline_and_indent (buffer, spc + 2);
1728 pp_right_brace (buffer);
1733 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1735 static void
1736 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc, int flags)
1738 if (flags & TDF_RAW)
1740 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1741 (int) gimple_omp_return_nowait_p (gs));
1742 if (gimple_omp_return_lhs (gs))
1743 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1744 gimple_omp_return_lhs (gs));
1745 else
1746 dump_gimple_fmt (buffer, spc, flags, ">");
1748 else
1750 pp_string (buffer, "#pragma omp return");
1751 if (gimple_omp_return_nowait_p (gs))
1752 pp_string (buffer, "(nowait)");
1753 if (gimple_omp_return_lhs (gs))
1755 pp_string (buffer, " (set ");
1756 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1757 spc, flags, false);
1758 pp_character (buffer, ')');
1763 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1765 static void
1766 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1767 int spc, int flags)
1769 unsigned subcode = gimple_transaction_subcode (gs);
1771 if (flags & TDF_RAW)
1773 dump_gimple_fmt (buffer, spc, flags,
1774 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1775 "<%+BODY <%S> >",
1776 gs, subcode, gimple_transaction_label_norm (gs),
1777 gimple_transaction_label_uninst (gs),
1778 gimple_transaction_label_over (gs),
1779 gimple_transaction_body (gs));
1781 else
1783 if (subcode & GTMA_IS_OUTER)
1784 pp_string (buffer, "__transaction_atomic [[outer]]");
1785 else if (subcode & GTMA_IS_RELAXED)
1786 pp_string (buffer, "__transaction_relaxed");
1787 else
1788 pp_string (buffer, "__transaction_atomic");
1789 subcode &= ~GTMA_DECLARATION_MASK;
1791 if (gimple_transaction_body (gs))
1793 newline_and_indent (buffer, spc + 2);
1794 pp_left_brace (buffer);
1795 pp_newline (buffer);
1796 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1797 spc + 4, flags);
1798 newline_and_indent (buffer, spc + 2);
1799 pp_right_brace (buffer);
1801 else
1803 pp_string (buffer, " //");
1804 if (gimple_transaction_label_norm (gs))
1806 pp_string (buffer, " NORM=");
1807 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1808 spc, flags, false);
1810 if (gimple_transaction_label_uninst (gs))
1812 pp_string (buffer, " UNINST=");
1813 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1814 spc, flags, false);
1816 if (gimple_transaction_label_over (gs))
1818 pp_string (buffer, " OVER=");
1819 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1820 spc, flags, false);
1822 if (subcode)
1824 pp_string (buffer, " SUBCODE=[ ");
1825 if (subcode & GTMA_HAVE_ABORT)
1827 pp_string (buffer, "GTMA_HAVE_ABORT ");
1828 subcode &= ~GTMA_HAVE_ABORT;
1830 if (subcode & GTMA_HAVE_LOAD)
1832 pp_string (buffer, "GTMA_HAVE_LOAD ");
1833 subcode &= ~GTMA_HAVE_LOAD;
1835 if (subcode & GTMA_HAVE_STORE)
1837 pp_string (buffer, "GTMA_HAVE_STORE ");
1838 subcode &= ~GTMA_HAVE_STORE;
1840 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1842 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1843 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1845 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1847 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1848 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1850 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1852 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1853 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1855 if (subcode)
1856 pp_printf (buffer, "0x%x ", subcode);
1857 pp_right_bracket (buffer);
1863 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1864 indent. FLAGS specifies details to show in the dump (see TDF_* in
1865 dumpfile.h). */
1867 static void
1868 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
1870 unsigned int i, n, f, fields;
1872 if (flags & TDF_RAW)
1874 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1875 gimple_asm_string (gs));
1877 n = gimple_asm_noutputs (gs);
1878 if (n)
1880 newline_and_indent (buffer, spc + 2);
1881 pp_string (buffer, "OUTPUT: ");
1882 for (i = 0; i < n; i++)
1884 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1885 spc, flags, false);
1886 if (i < n - 1)
1887 pp_string (buffer, ", ");
1891 n = gimple_asm_ninputs (gs);
1892 if (n)
1894 newline_and_indent (buffer, spc + 2);
1895 pp_string (buffer, "INPUT: ");
1896 for (i = 0; i < n; i++)
1898 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1899 spc, flags, false);
1900 if (i < n - 1)
1901 pp_string (buffer, ", ");
1905 n = gimple_asm_nclobbers (gs);
1906 if (n)
1908 newline_and_indent (buffer, spc + 2);
1909 pp_string (buffer, "CLOBBER: ");
1910 for (i = 0; i < n; i++)
1912 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1913 spc, flags, false);
1914 if (i < n - 1)
1915 pp_string (buffer, ", ");
1919 n = gimple_asm_nlabels (gs);
1920 if (n)
1922 newline_and_indent (buffer, spc + 2);
1923 pp_string (buffer, "LABEL: ");
1924 for (i = 0; i < n; i++)
1926 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1927 spc, flags, false);
1928 if (i < n - 1)
1929 pp_string (buffer, ", ");
1933 newline_and_indent (buffer, spc);
1934 pp_greater (buffer);
1936 else
1938 pp_string (buffer, "__asm__");
1939 if (gimple_asm_volatile_p (gs))
1940 pp_string (buffer, " __volatile__");
1941 if (gimple_asm_nlabels (gs))
1942 pp_string (buffer, " goto");
1943 pp_string (buffer, "(\"");
1944 pp_string (buffer, gimple_asm_string (gs));
1945 pp_string (buffer, "\"");
1947 if (gimple_asm_nlabels (gs))
1948 fields = 4;
1949 else if (gimple_asm_nclobbers (gs))
1950 fields = 3;
1951 else if (gimple_asm_ninputs (gs))
1952 fields = 2;
1953 else if (gimple_asm_noutputs (gs))
1954 fields = 1;
1955 else
1956 fields = 0;
1958 for (f = 0; f < fields; ++f)
1960 pp_string (buffer, " : ");
1962 switch (f)
1964 case 0:
1965 n = gimple_asm_noutputs (gs);
1966 for (i = 0; i < n; i++)
1968 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1969 spc, flags, false);
1970 if (i < n - 1)
1971 pp_string (buffer, ", ");
1973 break;
1975 case 1:
1976 n = gimple_asm_ninputs (gs);
1977 for (i = 0; i < n; i++)
1979 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1980 spc, flags, false);
1981 if (i < n - 1)
1982 pp_string (buffer, ", ");
1984 break;
1986 case 2:
1987 n = gimple_asm_nclobbers (gs);
1988 for (i = 0; i < n; i++)
1990 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1991 spc, flags, false);
1992 if (i < n - 1)
1993 pp_string (buffer, ", ");
1995 break;
1997 case 3:
1998 n = gimple_asm_nlabels (gs);
1999 for (i = 0; i < n; i++)
2001 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2002 spc, flags, false);
2003 if (i < n - 1)
2004 pp_string (buffer, ", ");
2006 break;
2008 default:
2009 gcc_unreachable ();
2013 pp_string (buffer, ");");
2017 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2018 SPC spaces of indent. */
2020 static void
2021 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2023 if (TREE_CODE (node) != SSA_NAME)
2024 return;
2026 if (POINTER_TYPE_P (TREE_TYPE (node))
2027 && SSA_NAME_PTR_INFO (node))
2029 unsigned int align, misalign;
2030 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2031 pp_string (buffer, "# PT = ");
2032 pp_points_to_solution (buffer, &pi->pt);
2033 newline_and_indent (buffer, spc);
2034 if (get_ptr_info_alignment (pi, &align, &misalign))
2036 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2037 newline_and_indent (buffer, spc);
2041 if (!POINTER_TYPE_P (TREE_TYPE (node))
2042 && SSA_NAME_RANGE_INFO (node))
2044 wide_int min, max, nonzero_bits;
2045 value_range_type range_type = get_range_info (node, &min, &max);
2047 if (range_type == VR_VARYING)
2048 pp_printf (buffer, "# RANGE VR_VARYING");
2049 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2051 pp_printf (buffer, "# RANGE ");
2052 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2053 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2054 pp_printf (buffer, ", ");
2055 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2056 pp_printf (buffer, "]");
2058 nonzero_bits = get_nonzero_bits (node);
2059 if (nonzero_bits != -1)
2061 pp_string (buffer, " NONZERO ");
2062 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2064 newline_and_indent (buffer, spc);
2068 /* As dump_ssaname_info, but dump to FILE. */
2070 void
2071 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2073 pretty_printer buffer;
2074 pp_needs_newline (&buffer) = true;
2075 buffer.buffer->stream = file;
2076 dump_ssaname_info (&buffer, node, spc);
2077 pp_flush (&buffer);
2080 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2081 The caller is responsible for calling pp_flush on BUFFER to finalize
2082 pretty printer. If COMMENT is true, print this after #. */
2084 static void
2085 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2086 int flags)
2088 size_t i;
2089 tree lhs = gimple_phi_result (phi);
2091 if (flags & TDF_ALIAS)
2092 dump_ssaname_info (buffer, lhs, spc);
2094 if (comment)
2095 pp_string (buffer, "# ");
2097 if (flags & TDF_RAW)
2098 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2099 gimple_phi_result (phi));
2100 else
2102 dump_generic_node (buffer, lhs, spc, flags, false);
2103 if (flags & TDF_GIMPLE)
2104 pp_string (buffer, " = __PHI (");
2105 else
2106 pp_string (buffer, " = PHI <");
2108 for (i = 0; i < gimple_phi_num_args (phi); i++)
2110 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2111 dump_location (buffer, gimple_phi_arg_location (phi, i));
2112 if (flags & TDF_GIMPLE)
2114 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2115 gimple *stmt = first_stmt (src);
2116 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2118 pp_string (buffer, "bb_");
2119 pp_decimal_int (buffer, src->index);
2121 else
2122 dump_generic_node (buffer, gimple_label_label (as_a <glabel *> (stmt)), 0, flags,
2123 false);
2124 pp_string (buffer, ": ");
2126 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2127 false);
2128 if (! (flags & TDF_GIMPLE))
2130 pp_left_paren (buffer);
2131 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2132 pp_right_paren (buffer);
2134 if (i < gimple_phi_num_args (phi) - 1)
2135 pp_string (buffer, ", ");
2137 if (flags & TDF_GIMPLE)
2138 pp_string (buffer, ");");
2139 else
2140 pp_greater (buffer);
2144 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2145 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2146 dumpfile.h). */
2148 static void
2149 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2150 int spc, int flags)
2152 if (flags & TDF_RAW)
2154 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2155 gimple_omp_body (gs));
2156 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2157 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2158 gimple_omp_parallel_child_fn (gs),
2159 gimple_omp_parallel_data_arg (gs));
2161 else
2163 gimple_seq body;
2164 pp_string (buffer, "#pragma omp parallel");
2165 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2166 if (gimple_omp_parallel_child_fn (gs))
2168 pp_string (buffer, " [child fn: ");
2169 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2170 spc, flags, false);
2171 pp_string (buffer, " (");
2172 if (gimple_omp_parallel_data_arg (gs))
2173 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2174 spc, flags, false);
2175 else
2176 pp_string (buffer, "???");
2177 pp_string (buffer, ")]");
2179 body = gimple_omp_body (gs);
2180 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2182 newline_and_indent (buffer, spc + 2);
2183 pp_left_brace (buffer);
2184 pp_newline (buffer);
2185 dump_gimple_seq (buffer, body, spc + 4, flags);
2186 newline_and_indent (buffer, spc + 2);
2187 pp_right_brace (buffer);
2189 else if (body)
2191 pp_newline (buffer);
2192 dump_gimple_seq (buffer, body, spc + 2, flags);
2198 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2199 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2200 dumpfile.h). */
2202 static void
2203 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2204 int flags)
2206 if (flags & TDF_RAW)
2208 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2209 gimple_omp_body (gs));
2210 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2211 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2212 gimple_omp_task_child_fn (gs),
2213 gimple_omp_task_data_arg (gs),
2214 gimple_omp_task_copy_fn (gs),
2215 gimple_omp_task_arg_size (gs),
2216 gimple_omp_task_arg_size (gs));
2218 else
2220 gimple_seq body;
2221 if (gimple_omp_task_taskloop_p (gs))
2222 pp_string (buffer, "#pragma omp taskloop");
2223 else
2224 pp_string (buffer, "#pragma omp task");
2225 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2226 if (gimple_omp_task_child_fn (gs))
2228 pp_string (buffer, " [child fn: ");
2229 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2230 spc, flags, false);
2231 pp_string (buffer, " (");
2232 if (gimple_omp_task_data_arg (gs))
2233 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2234 spc, flags, false);
2235 else
2236 pp_string (buffer, "???");
2237 pp_string (buffer, ")]");
2239 body = gimple_omp_body (gs);
2240 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2242 newline_and_indent (buffer, spc + 2);
2243 pp_left_brace (buffer);
2244 pp_newline (buffer);
2245 dump_gimple_seq (buffer, body, spc + 4, flags);
2246 newline_and_indent (buffer, spc + 2);
2247 pp_right_brace (buffer);
2249 else if (body)
2251 pp_newline (buffer);
2252 dump_gimple_seq (buffer, body, spc + 2, flags);
2258 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2259 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2260 in dumpfile.h). */
2262 static void
2263 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2264 int spc, int flags)
2266 if (flags & TDF_RAW)
2268 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2269 gimple_omp_atomic_load_lhs (gs),
2270 gimple_omp_atomic_load_rhs (gs));
2272 else
2274 pp_string (buffer, "#pragma omp atomic_load");
2275 if (gimple_omp_atomic_seq_cst_p (gs))
2276 pp_string (buffer, " seq_cst");
2277 if (gimple_omp_atomic_need_value_p (gs))
2278 pp_string (buffer, " [needed]");
2279 newline_and_indent (buffer, spc + 2);
2280 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2281 spc, flags, false);
2282 pp_space (buffer);
2283 pp_equal (buffer);
2284 pp_space (buffer);
2285 pp_star (buffer);
2286 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2287 spc, flags, false);
2291 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2292 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2293 in dumpfile.h). */
2295 static void
2296 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2297 gomp_atomic_store *gs, int spc, int flags)
2299 if (flags & TDF_RAW)
2301 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2302 gimple_omp_atomic_store_val (gs));
2304 else
2306 pp_string (buffer, "#pragma omp atomic_store ");
2307 if (gimple_omp_atomic_seq_cst_p (gs))
2308 pp_string (buffer, "seq_cst ");
2309 if (gimple_omp_atomic_need_value_p (gs))
2310 pp_string (buffer, "[needed] ");
2311 pp_left_paren (buffer);
2312 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2313 spc, flags, false);
2314 pp_right_paren (buffer);
2319 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2320 FLAGS are as in pp_gimple_stmt_1. */
2322 static void
2323 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc, int flags)
2325 tree vdef = gimple_vdef (gs);
2326 tree vuse = gimple_vuse (gs);
2328 if (vdef != NULL_TREE)
2330 pp_string (buffer, "# ");
2331 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2332 pp_string (buffer, " = VDEF <");
2333 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2334 pp_greater (buffer);
2335 newline_and_indent (buffer, spc);
2337 else if (vuse != NULL_TREE)
2339 pp_string (buffer, "# VUSE <");
2340 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2341 pp_greater (buffer);
2342 newline_and_indent (buffer, spc);
2347 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2348 spaces of indent. FLAGS specifies details to show in the dump (see
2349 TDF_* in dumpfile.h). The caller is responsible for calling
2350 pp_flush on BUFFER to finalize the pretty printer. */
2352 void
2353 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
2355 if (!gs)
2356 return;
2358 if (flags & TDF_STMTADDR)
2359 pp_printf (buffer, "<&%p> ", (void *) gs);
2361 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2362 dump_location (buffer, gimple_location (gs));
2364 if (flags & TDF_EH)
2366 int lp_nr = lookup_stmt_eh_lp (gs);
2367 if (lp_nr > 0)
2368 pp_printf (buffer, "[LP %d] ", lp_nr);
2369 else if (lp_nr < 0)
2370 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2373 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2374 && gimple_has_mem_ops (gs))
2375 dump_gimple_mem_ops (buffer, gs, spc, flags);
2377 if (gimple_has_lhs (gs)
2378 && (flags & TDF_ALIAS))
2379 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2381 switch (gimple_code (gs))
2383 case GIMPLE_ASM:
2384 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2385 break;
2387 case GIMPLE_ASSIGN:
2388 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2389 break;
2391 case GIMPLE_BIND:
2392 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2393 break;
2395 case GIMPLE_CALL:
2396 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2397 break;
2399 case GIMPLE_COND:
2400 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2401 break;
2403 case GIMPLE_LABEL:
2404 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2405 break;
2407 case GIMPLE_GOTO:
2408 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2409 break;
2411 case GIMPLE_NOP:
2412 pp_string (buffer, "GIMPLE_NOP");
2413 break;
2415 case GIMPLE_RETURN:
2416 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2417 break;
2419 case GIMPLE_SWITCH:
2420 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2421 break;
2423 case GIMPLE_TRY:
2424 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2425 break;
2427 case GIMPLE_PHI:
2428 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2429 break;
2431 case GIMPLE_OMP_PARALLEL:
2432 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2433 flags);
2434 break;
2436 case GIMPLE_OMP_TASK:
2437 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2438 break;
2440 case GIMPLE_OMP_ATOMIC_LOAD:
2441 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2442 spc, flags);
2443 break;
2445 case GIMPLE_OMP_ATOMIC_STORE:
2446 dump_gimple_omp_atomic_store (buffer,
2447 as_a <gomp_atomic_store *> (gs),
2448 spc, flags);
2449 break;
2451 case GIMPLE_OMP_FOR:
2452 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2453 break;
2455 case GIMPLE_OMP_CONTINUE:
2456 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2457 flags);
2458 break;
2460 case GIMPLE_OMP_SINGLE:
2461 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2462 flags);
2463 break;
2465 case GIMPLE_OMP_TARGET:
2466 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2467 flags);
2468 break;
2470 case GIMPLE_OMP_TEAMS:
2471 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2472 flags);
2473 break;
2475 case GIMPLE_OMP_RETURN:
2476 dump_gimple_omp_return (buffer, gs, spc, flags);
2477 break;
2479 case GIMPLE_OMP_SECTIONS:
2480 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2481 spc, flags);
2482 break;
2484 case GIMPLE_OMP_SECTIONS_SWITCH:
2485 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2486 break;
2488 case GIMPLE_OMP_MASTER:
2489 case GIMPLE_OMP_TASKGROUP:
2490 case GIMPLE_OMP_SECTION:
2491 case GIMPLE_OMP_GRID_BODY:
2492 dump_gimple_omp_block (buffer, gs, spc, flags);
2493 break;
2495 case GIMPLE_OMP_ORDERED:
2496 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2497 flags);
2498 break;
2500 case GIMPLE_OMP_CRITICAL:
2501 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2502 flags);
2503 break;
2505 case GIMPLE_CATCH:
2506 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2507 break;
2509 case GIMPLE_EH_FILTER:
2510 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2511 break;
2513 case GIMPLE_EH_MUST_NOT_THROW:
2514 dump_gimple_eh_must_not_throw (buffer,
2515 as_a <geh_mnt *> (gs),
2516 spc, flags);
2517 break;
2519 case GIMPLE_EH_ELSE:
2520 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2521 break;
2523 case GIMPLE_RESX:
2524 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2525 break;
2527 case GIMPLE_EH_DISPATCH:
2528 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2529 flags);
2530 break;
2532 case GIMPLE_DEBUG:
2533 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2534 break;
2536 case GIMPLE_PREDICT:
2537 pp_string (buffer, "// predicted ");
2538 if (gimple_predict_outcome (gs))
2539 pp_string (buffer, "likely by ");
2540 else
2541 pp_string (buffer, "unlikely by ");
2542 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2543 pp_string (buffer, " predictor.");
2544 break;
2546 case GIMPLE_TRANSACTION:
2547 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2548 flags);
2549 break;
2551 default:
2552 GIMPLE_NIY;
2557 /* Dumps header of basic block BB to OUTF indented by INDENT
2558 spaces and details described by flags. */
2560 static void
2561 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2563 if (flags & TDF_BLOCKS)
2565 if (flags & TDF_LINENO)
2567 gimple_stmt_iterator gsi;
2569 if (flags & TDF_COMMENT)
2570 fputs (";; ", outf);
2572 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2573 if (!is_gimple_debug (gsi_stmt (gsi))
2574 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2576 fprintf (outf, "%*sstarting at line %d",
2577 indent, "", get_lineno (gsi_stmt (gsi)));
2578 break;
2580 if (bb->discriminator)
2581 fprintf (outf, ", discriminator %i", bb->discriminator);
2582 fputc ('\n', outf);
2585 else
2587 gimple *stmt = first_stmt (bb);
2588 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2590 if (flags & TDF_GIMPLE)
2591 fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
2592 else
2593 fprintf (outf, "%*s<bb %d> [%.1f%%]:\n", indent, "", bb->index,
2594 bb->frequency * 100.0 / REG_BR_PROB_BASE);
2600 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2601 spaces. */
2603 static void
2604 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2605 basic_block bb ATTRIBUTE_UNUSED,
2606 int indent ATTRIBUTE_UNUSED,
2607 int flags ATTRIBUTE_UNUSED)
2609 /* There is currently no GIMPLE-specific basic block info to dump. */
2610 return;
2614 /* Dump PHI nodes of basic block BB to BUFFER with details described
2615 by FLAGS and indented by INDENT spaces. */
2617 static void
2618 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2620 gphi_iterator i;
2622 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2624 gphi *phi = i.phi ();
2625 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2627 INDENT (indent);
2628 dump_gimple_phi (buffer, phi, indent,
2629 (flags & TDF_GIMPLE) ? false : true, flags);
2630 pp_newline (buffer);
2636 /* Dump jump to basic block BB that is represented implicitly in the cfg
2637 to BUFFER. */
2639 static void
2640 pp_cfg_jump (pretty_printer *buffer, edge e, int flags)
2642 if (flags & TDF_GIMPLE)
2644 pp_string (buffer, "goto bb_");
2645 pp_decimal_int (buffer, e->dest->index);
2646 pp_semicolon (buffer);
2648 else
2650 gimple *stmt = first_stmt (e->dest);
2652 pp_string (buffer, "goto <bb ");
2653 pp_decimal_int (buffer, e->dest->index);
2654 pp_greater (buffer);
2655 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2657 pp_string (buffer, " (");
2658 dump_generic_node (buffer,
2659 gimple_label_label (as_a <glabel *> (stmt)),
2660 0, 0, false);
2661 pp_right_paren (buffer);
2662 pp_semicolon (buffer);
2664 else
2665 pp_semicolon (buffer);
2667 dump_edge_probability (buffer, e);
2672 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2673 by INDENT spaces, with details given by FLAGS. */
2675 static void
2676 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2677 int flags)
2679 edge e;
2680 gimple *stmt;
2682 stmt = last_stmt (bb);
2684 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2686 edge true_edge, false_edge;
2688 /* When we are emitting the code or changing CFG, it is possible that
2689 the edges are not yet created. When we are using debug_bb in such
2690 a situation, we do not want it to crash. */
2691 if (EDGE_COUNT (bb->succs) != 2)
2692 return;
2693 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2695 INDENT (indent + 2);
2696 pp_cfg_jump (buffer, true_edge, flags);
2697 newline_and_indent (buffer, indent);
2698 pp_string (buffer, "else");
2699 newline_and_indent (buffer, indent + 2);
2700 pp_cfg_jump (buffer, false_edge, flags);
2701 pp_newline (buffer);
2702 return;
2705 /* If there is a fallthru edge, we may need to add an artificial
2706 goto to the dump. */
2707 e = find_fallthru_edge (bb->succs);
2709 if (e && e->dest != bb->next_bb)
2711 INDENT (indent);
2713 if ((flags & TDF_LINENO)
2714 && e->goto_locus != UNKNOWN_LOCATION)
2715 dump_location (buffer, e->goto_locus);
2717 pp_cfg_jump (buffer, e, flags);
2718 pp_newline (buffer);
2723 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2724 indented by INDENT spaces. */
2726 static void
2727 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2728 int flags)
2730 gimple_stmt_iterator gsi;
2731 gimple *stmt;
2732 int label_indent = indent - 2;
2734 if (label_indent < 0)
2735 label_indent = 0;
2737 dump_phi_nodes (buffer, bb, indent, flags);
2739 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2741 int curr_indent;
2743 stmt = gsi_stmt (gsi);
2745 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2747 INDENT (curr_indent);
2748 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2749 pp_newline_and_flush (buffer);
2750 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2751 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2752 pp_buffer (buffer)->stream, stmt);
2755 dump_implicit_edges (buffer, bb, indent, flags);
2756 pp_flush (buffer);
2760 /* Dumps basic block BB to FILE with details described by FLAGS and
2761 indented by INDENT spaces. */
2763 void
2764 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2766 dump_gimple_bb_header (file, bb, indent, flags);
2767 if (bb->index >= NUM_FIXED_BLOCKS)
2769 pretty_printer buffer;
2770 pp_needs_newline (&buffer) = true;
2771 buffer.buffer->stream = file;
2772 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2774 dump_gimple_bb_footer (file, bb, indent, flags);
2777 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2778 no indentation, for use as a label of a DOT graph record-node.
2779 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2780 histogram dumping doesn't know about pretty-printers. */
2782 void
2783 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2785 pp_printf (pp, "<bb %d>:\n", bb->index);
2786 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2788 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2789 gsi_next (&gsi))
2791 gphi *phi = gsi.phi ();
2792 if (!virtual_operand_p (gimple_phi_result (phi))
2793 || (dump_flags & TDF_VOPS))
2795 pp_bar (pp);
2796 pp_write_text_to_stream (pp);
2797 pp_string (pp, "# ");
2798 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2799 pp_newline (pp);
2800 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2804 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2805 gsi_next (&gsi))
2807 gimple *stmt = gsi_stmt (gsi);
2808 pp_bar (pp);
2809 pp_write_text_to_stream (pp);
2810 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2811 pp_newline (pp);
2812 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2814 dump_implicit_edges (pp, bb, 0, dump_flags);
2815 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);