* es.po: Update.
[official-gcc.git] / gcc / gimple-pretty-print.c
bloba7a5d00dc2e63cbdfb7a26d3c69f385df9b243e2
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 if (flags & TDF_GIMPLE)
328 pp_string (buffer, "__ABS ");
329 dump_generic_node (buffer, rhs, spc, flags, false);
331 else
333 pp_string (buffer, "ABS_EXPR <");
334 dump_generic_node (buffer, rhs, spc, flags, false);
335 pp_greater (buffer);
337 break;
339 default:
340 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
341 || TREE_CODE_CLASS (rhs_code) == tcc_constant
342 || TREE_CODE_CLASS (rhs_code) == tcc_reference
343 || rhs_code == SSA_NAME
344 || rhs_code == ADDR_EXPR
345 || rhs_code == CONSTRUCTOR)
347 dump_generic_node (buffer, rhs, spc, flags, false);
348 break;
350 else if (rhs_code == BIT_NOT_EXPR)
351 pp_complement (buffer);
352 else if (rhs_code == TRUTH_NOT_EXPR)
353 pp_exclamation (buffer);
354 else if (rhs_code == NEGATE_EXPR)
355 pp_minus (buffer);
356 else
358 pp_left_bracket (buffer);
359 pp_string (buffer, get_tree_code_name (rhs_code));
360 pp_string (buffer, "] ");
363 if (op_prio (rhs) < op_code_prio (rhs_code))
365 pp_left_paren (buffer);
366 dump_generic_node (buffer, rhs, spc, flags, false);
367 pp_right_paren (buffer);
369 else
370 dump_generic_node (buffer, rhs, spc, flags, false);
371 break;
376 /* Helper for dump_gimple_assign. Print the binary RHS of the
377 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
379 static void
380 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
382 const char *p;
383 enum tree_code code = gimple_assign_rhs_code (gs);
384 switch (code)
386 case COMPLEX_EXPR:
387 case MIN_EXPR:
388 case MAX_EXPR:
389 case VEC_WIDEN_MULT_HI_EXPR:
390 case VEC_WIDEN_MULT_LO_EXPR:
391 case VEC_WIDEN_MULT_EVEN_EXPR:
392 case VEC_WIDEN_MULT_ODD_EXPR:
393 case VEC_PACK_TRUNC_EXPR:
394 case VEC_PACK_SAT_EXPR:
395 case VEC_PACK_FIX_TRUNC_EXPR:
396 case VEC_WIDEN_LSHIFT_HI_EXPR:
397 case VEC_WIDEN_LSHIFT_LO_EXPR:
398 for (p = get_tree_code_name (code); *p; p++)
399 pp_character (buffer, TOUPPER (*p));
400 pp_string (buffer, " <");
401 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
402 pp_string (buffer, ", ");
403 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
404 pp_greater (buffer);
405 break;
407 default:
408 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
410 pp_left_paren (buffer);
411 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
412 false);
413 pp_right_paren (buffer);
415 else
416 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
417 pp_space (buffer);
418 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
419 pp_space (buffer);
420 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
422 pp_left_paren (buffer);
423 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
424 false);
425 pp_right_paren (buffer);
427 else
428 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
432 /* Helper for dump_gimple_assign. Print the ternary RHS of the
433 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
435 static void
436 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
438 const char *p;
439 enum tree_code code = gimple_assign_rhs_code (gs);
440 switch (code)
442 case WIDEN_MULT_PLUS_EXPR:
443 case WIDEN_MULT_MINUS_EXPR:
444 for (p = get_tree_code_name (code); *p; p++)
445 pp_character (buffer, TOUPPER (*p));
446 pp_string (buffer, " <");
447 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
448 pp_string (buffer, ", ");
449 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
450 pp_string (buffer, ", ");
451 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
452 pp_greater (buffer);
453 break;
455 case FMA_EXPR:
456 if (flags & TDF_GIMPLE)
458 pp_string (buffer, "__FMA (");
459 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
460 pp_comma (buffer);
461 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
462 pp_comma (buffer);
463 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
464 pp_right_paren (buffer);
466 else
468 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
469 pp_string (buffer, " * ");
470 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
471 pp_string (buffer, " + ");
472 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
474 break;
476 case DOT_PROD_EXPR:
477 pp_string (buffer, "DOT_PROD_EXPR <");
478 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
479 pp_string (buffer, ", ");
480 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
481 pp_string (buffer, ", ");
482 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
483 pp_greater (buffer);
484 break;
486 case SAD_EXPR:
487 pp_string (buffer, "SAD_EXPR <");
488 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
489 pp_string (buffer, ", ");
490 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
491 pp_string (buffer, ", ");
492 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
493 pp_greater (buffer);
494 break;
496 case VEC_PERM_EXPR:
497 pp_string (buffer, "VEC_PERM_EXPR <");
498 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
499 pp_string (buffer, ", ");
500 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
501 pp_string (buffer, ", ");
502 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
503 pp_greater (buffer);
504 break;
506 case REALIGN_LOAD_EXPR:
507 pp_string (buffer, "REALIGN_LOAD <");
508 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
509 pp_string (buffer, ", ");
510 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
511 pp_string (buffer, ", ");
512 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
513 pp_greater (buffer);
514 break;
516 case COND_EXPR:
517 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
518 pp_string (buffer, " ? ");
519 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
520 pp_string (buffer, " : ");
521 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
522 break;
524 case VEC_COND_EXPR:
525 pp_string (buffer, "VEC_COND_EXPR <");
526 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
527 pp_string (buffer, ", ");
528 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
529 pp_string (buffer, ", ");
530 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
531 pp_greater (buffer);
532 break;
534 case BIT_INSERT_EXPR:
535 pp_string (buffer, "BIT_INSERT_EXPR <");
536 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
537 pp_string (buffer, ", ");
538 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
539 pp_string (buffer, ", ");
540 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
541 pp_string (buffer, " (");
542 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
543 pp_decimal_int (buffer,
544 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
545 else
546 dump_generic_node (buffer,
547 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
548 spc, flags, false);
549 pp_string (buffer, " bits)>");
550 break;
552 default:
553 gcc_unreachable ();
558 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
559 pp_gimple_stmt_1. */
561 static void
562 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
564 if (flags & TDF_RAW)
566 tree arg1 = NULL;
567 tree arg2 = NULL;
568 tree arg3 = NULL;
569 switch (gimple_num_ops (gs))
571 case 4:
572 arg3 = gimple_assign_rhs3 (gs);
573 /* FALLTHRU */
574 case 3:
575 arg2 = gimple_assign_rhs2 (gs);
576 /* FALLTHRU */
577 case 2:
578 arg1 = gimple_assign_rhs1 (gs);
579 break;
580 default:
581 gcc_unreachable ();
584 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
585 get_tree_code_name (gimple_assign_rhs_code (gs)),
586 gimple_assign_lhs (gs), arg1, arg2, arg3);
588 else
590 if (!(flags & TDF_RHS_ONLY))
592 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
593 pp_space (buffer);
594 pp_equal (buffer);
596 if (gimple_assign_nontemporal_move_p (gs))
597 pp_string (buffer, "{nt}");
599 if (gimple_has_volatile_ops (gs))
600 pp_string (buffer, "{v}");
602 pp_space (buffer);
605 if (gimple_num_ops (gs) == 2)
606 dump_unary_rhs (buffer, gs, spc, flags);
607 else if (gimple_num_ops (gs) == 3)
608 dump_binary_rhs (buffer, gs, spc, flags);
609 else if (gimple_num_ops (gs) == 4)
610 dump_ternary_rhs (buffer, gs, spc, flags);
611 else
612 gcc_unreachable ();
613 if (!(flags & TDF_RHS_ONLY))
614 pp_semicolon (buffer);
619 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
620 pp_gimple_stmt_1. */
622 static void
623 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
625 tree t, t2;
627 t = gimple_return_retval (gs);
628 t2 = gimple_return_retbnd (gs);
629 if (flags & TDF_RAW)
630 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
631 else
633 pp_string (buffer, "return");
634 if (t)
636 pp_space (buffer);
637 dump_generic_node (buffer, t, spc, flags, false);
639 if (t2)
641 pp_string (buffer, ", ");
642 dump_generic_node (buffer, t2, spc, flags, false);
644 pp_semicolon (buffer);
649 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
650 dump_gimple_call. */
652 static void
653 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
655 size_t i = 0;
657 /* Pretty print first arg to certain internal fns. */
658 if (gimple_call_internal_p (gs))
660 const char *const *enums = NULL;
661 unsigned limit = 0;
663 switch (gimple_call_internal_fn (gs))
665 case IFN_UNIQUE:
666 #define DEF(X) #X
667 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
668 #undef DEF
669 enums = unique_args;
671 limit = ARRAY_SIZE (unique_args);
672 break;
674 case IFN_GOACC_LOOP:
675 #define DEF(X) #X
676 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
677 #undef DEF
678 enums = loop_args;
679 limit = ARRAY_SIZE (loop_args);
680 break;
682 case IFN_GOACC_REDUCTION:
683 #define DEF(X) #X
684 static const char *const reduction_args[]
685 = {IFN_GOACC_REDUCTION_CODES};
686 #undef DEF
687 enums = reduction_args;
688 limit = ARRAY_SIZE (reduction_args);
689 break;
691 case IFN_ASAN_MARK:
692 #define DEF(X) #X
693 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
694 #undef DEF
695 enums = asan_mark_args;
696 limit = ARRAY_SIZE (asan_mark_args);
697 break;
699 default:
700 break;
702 if (limit)
704 tree arg0 = gimple_call_arg (gs, 0);
705 HOST_WIDE_INT v;
707 if (TREE_CODE (arg0) == INTEGER_CST
708 && tree_fits_shwi_p (arg0)
709 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
711 i++;
712 pp_string (buffer, enums[v]);
717 for (; i < gimple_call_num_args (gs); i++)
719 if (i)
720 pp_string (buffer, ", ");
721 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
724 if (gimple_call_va_arg_pack_p (gs))
726 if (i)
727 pp_string (buffer, ", ");
729 pp_string (buffer, "__builtin_va_arg_pack ()");
733 /* Dump the points-to solution *PT to BUFFER. */
735 static void
736 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
738 if (pt->anything)
740 pp_string (buffer, "anything ");
741 return;
743 if (pt->nonlocal)
744 pp_string (buffer, "nonlocal ");
745 if (pt->escaped)
746 pp_string (buffer, "escaped ");
747 if (pt->ipa_escaped)
748 pp_string (buffer, "unit-escaped ");
749 if (pt->null)
750 pp_string (buffer, "null ");
751 if (pt->vars
752 && !bitmap_empty_p (pt->vars))
754 bitmap_iterator bi;
755 unsigned i;
756 pp_string (buffer, "{ ");
757 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
759 pp_string (buffer, "D.");
760 pp_decimal_int (buffer, i);
761 pp_space (buffer);
763 pp_right_brace (buffer);
764 if (pt->vars_contains_nonlocal
765 || pt->vars_contains_escaped
766 || pt->vars_contains_escaped_heap
767 || pt->vars_contains_restrict)
769 const char *comma = "";
770 pp_string (buffer, " (");
771 if (pt->vars_contains_nonlocal)
773 pp_string (buffer, "nonlocal");
774 comma = ", ";
776 if (pt->vars_contains_escaped)
778 pp_string (buffer, comma);
779 pp_string (buffer, "escaped");
780 comma = ", ";
782 if (pt->vars_contains_escaped_heap)
784 pp_string (buffer, comma);
785 pp_string (buffer, "escaped heap");
786 comma = ", ";
788 if (pt->vars_contains_restrict)
790 pp_string (buffer, comma);
791 pp_string (buffer, "restrict");
792 comma = ", ";
794 if (pt->vars_contains_interposable)
796 pp_string (buffer, comma);
797 pp_string (buffer, "interposable");
799 pp_string (buffer, ")");
805 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
806 pp_gimple_stmt_1. */
808 static void
809 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
811 tree lhs = gimple_call_lhs (gs);
812 tree fn = gimple_call_fn (gs);
814 if (flags & TDF_ALIAS)
816 struct pt_solution *pt;
817 pt = gimple_call_use_set (gs);
818 if (!pt_solution_empty_p (pt))
820 pp_string (buffer, "# USE = ");
821 pp_points_to_solution (buffer, pt);
822 newline_and_indent (buffer, spc);
824 pt = gimple_call_clobber_set (gs);
825 if (!pt_solution_empty_p (pt))
827 pp_string (buffer, "# CLB = ");
828 pp_points_to_solution (buffer, pt);
829 newline_and_indent (buffer, spc);
833 if (flags & TDF_RAW)
835 if (gimple_call_internal_p (gs))
836 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
837 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
838 else
839 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
840 if (gimple_call_num_args (gs) > 0)
842 pp_string (buffer, ", ");
843 dump_gimple_call_args (buffer, gs, flags);
845 pp_greater (buffer);
847 else
849 if (lhs && !(flags & TDF_RHS_ONLY))
851 dump_generic_node (buffer, lhs, spc, flags, false);
852 pp_string (buffer, " =");
854 if (gimple_has_volatile_ops (gs))
855 pp_string (buffer, "{v}");
857 pp_space (buffer);
859 if (gimple_call_internal_p (gs))
860 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
861 else
862 print_call_name (buffer, fn, flags);
863 pp_string (buffer, " (");
864 dump_gimple_call_args (buffer, gs, flags);
865 pp_right_paren (buffer);
866 if (!(flags & TDF_RHS_ONLY))
867 pp_semicolon (buffer);
870 if (gimple_call_chain (gs))
872 pp_string (buffer, " [static-chain: ");
873 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
874 pp_right_bracket (buffer);
877 if (gimple_call_return_slot_opt_p (gs))
878 pp_string (buffer, " [return slot optimization]");
879 if (gimple_call_tail_p (gs))
880 pp_string (buffer, " [tail call]");
881 if (gimple_call_must_tail_p (gs))
882 pp_string (buffer, " [must tail call]");
884 if (fn == NULL)
885 return;
887 /* Dump the arguments of _ITM_beginTransaction sanely. */
888 if (TREE_CODE (fn) == ADDR_EXPR)
889 fn = TREE_OPERAND (fn, 0);
890 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
891 pp_string (buffer, " [tm-clone]");
892 if (TREE_CODE (fn) == FUNCTION_DECL
893 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
894 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
895 && gimple_call_num_args (gs) > 0)
897 tree t = gimple_call_arg (gs, 0);
898 unsigned HOST_WIDE_INT props;
899 gcc_assert (TREE_CODE (t) == INTEGER_CST);
901 pp_string (buffer, " [ ");
903 /* Get the transaction code properties. */
904 props = TREE_INT_CST_LOW (t);
906 if (props & PR_INSTRUMENTEDCODE)
907 pp_string (buffer, "instrumentedCode ");
908 if (props & PR_UNINSTRUMENTEDCODE)
909 pp_string (buffer, "uninstrumentedCode ");
910 if (props & PR_HASNOXMMUPDATE)
911 pp_string (buffer, "hasNoXMMUpdate ");
912 if (props & PR_HASNOABORT)
913 pp_string (buffer, "hasNoAbort ");
914 if (props & PR_HASNOIRREVOCABLE)
915 pp_string (buffer, "hasNoIrrevocable ");
916 if (props & PR_DOESGOIRREVOCABLE)
917 pp_string (buffer, "doesGoIrrevocable ");
918 if (props & PR_HASNOSIMPLEREADS)
919 pp_string (buffer, "hasNoSimpleReads ");
920 if (props & PR_AWBARRIERSOMITTED)
921 pp_string (buffer, "awBarriersOmitted ");
922 if (props & PR_RARBARRIERSOMITTED)
923 pp_string (buffer, "RaRBarriersOmitted ");
924 if (props & PR_UNDOLOGCODE)
925 pp_string (buffer, "undoLogCode ");
926 if (props & PR_PREFERUNINSTRUMENTED)
927 pp_string (buffer, "preferUninstrumented ");
928 if (props & PR_EXCEPTIONBLOCK)
929 pp_string (buffer, "exceptionBlock ");
930 if (props & PR_HASELSE)
931 pp_string (buffer, "hasElse ");
932 if (props & PR_READONLY)
933 pp_string (buffer, "readOnly ");
935 pp_right_bracket (buffer);
940 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
941 pp_gimple_stmt_1. */
943 static void
944 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
945 int flags)
947 unsigned int i;
949 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
950 if (flags & TDF_RAW)
951 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
952 gimple_switch_index (gs));
953 else
955 pp_string (buffer, "switch (");
956 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
957 if (flags & TDF_GIMPLE)
958 pp_string (buffer, ") {");
959 else
960 pp_string (buffer, ") <");
963 for (i = 0; i < gimple_switch_num_labels (gs); i++)
965 tree case_label = gimple_switch_label (gs, i);
966 gcc_checking_assert (case_label != NULL_TREE);
967 dump_generic_node (buffer, case_label, spc, flags, false);
968 pp_space (buffer);
969 tree label = CASE_LABEL (case_label);
970 dump_generic_node (buffer, label, spc, flags, false);
972 if (cfun && cfun->cfg)
974 basic_block dest = label_to_block (label);
975 if (dest)
977 edge label_edge = find_edge (gimple_bb (gs), dest);
978 if (label_edge && !(flags & TDF_GIMPLE))
979 dump_edge_probability (buffer, label_edge);
983 if (i < gimple_switch_num_labels (gs) - 1)
985 if (flags & TDF_GIMPLE)
986 pp_string (buffer, "; ");
987 else
988 pp_string (buffer, ", ");
991 if (flags & TDF_GIMPLE)
992 pp_string (buffer, "; }");
993 else
994 pp_greater (buffer);
998 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
999 pp_gimple_stmt_1. */
1001 static void
1002 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
1004 if (flags & TDF_RAW)
1005 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1006 get_tree_code_name (gimple_cond_code (gs)),
1007 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1008 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1009 else
1011 if (!(flags & TDF_RHS_ONLY))
1012 pp_string (buffer, "if (");
1013 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
1014 pp_space (buffer);
1015 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1016 pp_space (buffer);
1017 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
1018 if (!(flags & TDF_RHS_ONLY))
1020 edge_iterator ei;
1021 edge e, true_edge = NULL, false_edge = NULL;
1022 basic_block bb = gimple_bb (gs);
1024 if (bb)
1026 FOR_EACH_EDGE (e, ei, bb->succs)
1028 if (e->flags & EDGE_TRUE_VALUE)
1029 true_edge = e;
1030 else if (e->flags & EDGE_FALSE_VALUE)
1031 false_edge = e;
1035 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1037 pp_right_paren (buffer);
1039 if (gimple_cond_true_label (gs))
1041 pp_string (buffer, " goto ");
1042 dump_generic_node (buffer, gimple_cond_true_label (gs),
1043 spc, flags, false);
1044 if (has_edge_info && !(flags & TDF_GIMPLE))
1045 dump_edge_probability (buffer, true_edge);
1046 pp_semicolon (buffer);
1048 if (gimple_cond_false_label (gs))
1050 pp_string (buffer, " else goto ");
1051 dump_generic_node (buffer, gimple_cond_false_label (gs),
1052 spc, flags, false);
1053 if (has_edge_info && !(flags & TDF_GIMPLE))
1054 dump_edge_probability (buffer, false_edge);
1056 pp_semicolon (buffer);
1063 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1064 spaces of indent. FLAGS specifies details to show in the dump (see
1065 TDF_* in dumpfils.h). */
1067 static void
1068 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
1070 tree label = gimple_label_label (gs);
1071 if (flags & TDF_RAW)
1072 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1073 else
1075 dump_generic_node (buffer, label, spc, flags, false);
1076 basic_block bb = gimple_bb (gs);
1077 if (bb && !(flags & TDF_GIMPLE))
1078 pp_scalar (buffer, " %s", dump_probability (bb->frequency));
1079 pp_colon (buffer);
1081 if (flags & TDF_GIMPLE)
1082 return;
1083 if (DECL_NONLOCAL (label))
1084 pp_string (buffer, " [non-local]");
1085 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1086 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1089 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1090 spaces of indent. FLAGS specifies details to show in the dump (see
1091 TDF_* in dumpfile.h). */
1093 static void
1094 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
1096 tree label = gimple_goto_dest (gs);
1097 if (flags & TDF_RAW)
1098 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1099 else
1100 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1104 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1105 spaces of indent. FLAGS specifies details to show in the dump (see
1106 TDF_* in dumpfile.h). */
1108 static void
1109 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
1111 if (flags & TDF_RAW)
1112 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1113 else
1114 pp_left_brace (buffer);
1115 if (!(flags & TDF_SLIM))
1117 tree var;
1119 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1121 newline_and_indent (buffer, 2);
1122 print_declaration (buffer, var, spc, flags);
1124 if (gimple_bind_vars (gs))
1125 pp_newline (buffer);
1127 pp_newline (buffer);
1128 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1129 newline_and_indent (buffer, spc);
1130 if (flags & TDF_RAW)
1131 pp_greater (buffer);
1132 else
1133 pp_right_brace (buffer);
1137 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1138 indent. FLAGS specifies details to show in the dump (see TDF_* in
1139 dumpfile.h). */
1141 static void
1142 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
1144 if (flags & TDF_RAW)
1146 const char *type;
1147 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1148 type = "GIMPLE_TRY_CATCH";
1149 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1150 type = "GIMPLE_TRY_FINALLY";
1151 else
1152 type = "UNKNOWN GIMPLE_TRY";
1153 dump_gimple_fmt (buffer, spc, flags,
1154 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1155 gimple_try_eval (gs), gimple_try_cleanup (gs));
1157 else
1159 pp_string (buffer, "try");
1160 newline_and_indent (buffer, spc + 2);
1161 pp_left_brace (buffer);
1162 pp_newline (buffer);
1164 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1165 newline_and_indent (buffer, spc + 2);
1166 pp_right_brace (buffer);
1168 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1170 newline_and_indent (buffer, spc);
1171 pp_string (buffer, "catch");
1172 newline_and_indent (buffer, spc + 2);
1173 pp_left_brace (buffer);
1175 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1177 newline_and_indent (buffer, spc);
1178 pp_string (buffer, "finally");
1179 newline_and_indent (buffer, spc + 2);
1180 pp_left_brace (buffer);
1182 else
1183 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1185 pp_newline (buffer);
1186 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1187 newline_and_indent (buffer, spc + 2);
1188 pp_right_brace (buffer);
1193 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1194 indent. FLAGS specifies details to show in the dump (see TDF_* in
1195 dumpfile.h). */
1197 static void
1198 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
1200 if (flags & TDF_RAW)
1201 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1202 gimple_catch_types (gs), gimple_catch_handler (gs));
1203 else
1204 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1205 gimple_catch_types (gs), gimple_catch_handler (gs));
1209 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1210 indent. FLAGS specifies details to show in the dump (see TDF_* in
1211 dumpfile.h). */
1213 static void
1214 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1215 int flags)
1217 if (flags & TDF_RAW)
1218 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1219 gimple_eh_filter_types (gs),
1220 gimple_eh_filter_failure (gs));
1221 else
1222 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1223 gimple_eh_filter_types (gs),
1224 gimple_eh_filter_failure (gs));
1228 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1230 static void
1231 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1232 geh_mnt *gs, int spc, int flags)
1234 if (flags & TDF_RAW)
1235 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1236 gimple_eh_must_not_throw_fndecl (gs));
1237 else
1238 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1239 gimple_eh_must_not_throw_fndecl (gs));
1243 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1244 indent. FLAGS specifies details to show in the dump (see TDF_* in
1245 dumpfile.h). */
1247 static void
1248 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1249 int flags)
1251 if (flags & TDF_RAW)
1252 dump_gimple_fmt (buffer, spc, flags,
1253 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1254 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1255 else
1256 dump_gimple_fmt (buffer, spc, flags,
1257 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1258 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1262 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1263 indent. FLAGS specifies details to show in the dump (see TDF_* in
1264 dumpfile.h). */
1266 static void
1267 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
1269 if (flags & TDF_RAW)
1270 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1271 gimple_resx_region (gs));
1272 else
1273 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1276 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1278 static void
1279 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int flags)
1281 if (flags & TDF_RAW)
1282 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1283 gimple_eh_dispatch_region (gs));
1284 else
1285 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1286 gimple_eh_dispatch_region (gs));
1289 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1290 of indent. FLAGS specifies details to show in the dump (see TDF_*
1291 in dumpfile.h). */
1293 static void
1294 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
1296 switch (gs->subcode)
1298 case GIMPLE_DEBUG_BIND:
1299 if (flags & TDF_RAW)
1300 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1301 gimple_debug_bind_get_var (gs),
1302 gimple_debug_bind_get_value (gs));
1303 else
1304 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1305 gimple_debug_bind_get_var (gs),
1306 gimple_debug_bind_get_value (gs));
1307 break;
1309 case GIMPLE_DEBUG_SOURCE_BIND:
1310 if (flags & TDF_RAW)
1311 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1312 gimple_debug_source_bind_get_var (gs),
1313 gimple_debug_source_bind_get_value (gs));
1314 else
1315 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1316 gimple_debug_source_bind_get_var (gs),
1317 gimple_debug_source_bind_get_value (gs));
1318 break;
1320 default:
1321 gcc_unreachable ();
1325 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1326 static void
1327 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
1329 size_t i;
1331 if (flags & TDF_RAW)
1333 const char *kind;
1334 switch (gimple_omp_for_kind (gs))
1336 case GF_OMP_FOR_KIND_FOR:
1337 kind = "";
1338 break;
1339 case GF_OMP_FOR_KIND_DISTRIBUTE:
1340 kind = " distribute";
1341 break;
1342 case GF_OMP_FOR_KIND_TASKLOOP:
1343 kind = " taskloop";
1344 break;
1345 case GF_OMP_FOR_KIND_CILKFOR:
1346 kind = " _Cilk_for";
1347 break;
1348 case GF_OMP_FOR_KIND_OACC_LOOP:
1349 kind = " oacc_loop";
1350 break;
1351 case GF_OMP_FOR_KIND_SIMD:
1352 kind = " simd";
1353 break;
1354 case GF_OMP_FOR_KIND_CILKSIMD:
1355 kind = " cilksimd";
1356 break;
1357 default:
1358 gcc_unreachable ();
1360 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1361 kind, gimple_omp_body (gs));
1362 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1363 dump_gimple_fmt (buffer, spc, flags, " >,");
1364 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1365 dump_gimple_fmt (buffer, spc, flags,
1366 "%+%T, %T, %T, %s, %T,%n",
1367 gimple_omp_for_index (gs, i),
1368 gimple_omp_for_initial (gs, i),
1369 gimple_omp_for_final (gs, i),
1370 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1371 gimple_omp_for_incr (gs, i));
1372 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1373 gimple_omp_for_pre_body (gs));
1375 else
1377 switch (gimple_omp_for_kind (gs))
1379 case GF_OMP_FOR_KIND_FOR:
1380 pp_string (buffer, "#pragma omp for");
1381 break;
1382 case GF_OMP_FOR_KIND_DISTRIBUTE:
1383 pp_string (buffer, "#pragma omp distribute");
1384 break;
1385 case GF_OMP_FOR_KIND_TASKLOOP:
1386 pp_string (buffer, "#pragma omp taskloop");
1387 break;
1388 case GF_OMP_FOR_KIND_CILKFOR:
1389 break;
1390 case GF_OMP_FOR_KIND_OACC_LOOP:
1391 pp_string (buffer, "#pragma acc loop");
1392 break;
1393 case GF_OMP_FOR_KIND_SIMD:
1394 pp_string (buffer, "#pragma omp simd");
1395 break;
1396 case GF_OMP_FOR_KIND_CILKSIMD:
1397 pp_string (buffer, "#pragma simd");
1398 break;
1399 case GF_OMP_FOR_KIND_GRID_LOOP:
1400 pp_string (buffer, "#pragma omp for grid_loop");
1401 break;
1402 default:
1403 gcc_unreachable ();
1405 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1406 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1407 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1409 if (i)
1410 spc += 2;
1411 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1412 pp_string (buffer, "_Cilk_for (");
1413 else
1415 newline_and_indent (buffer, spc);
1416 pp_string (buffer, "for (");
1418 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1419 flags, false);
1420 pp_string (buffer, " = ");
1421 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1422 flags, false);
1423 pp_string (buffer, "; ");
1425 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1426 flags, false);
1427 pp_space (buffer);
1428 switch (gimple_omp_for_cond (gs, i))
1430 case LT_EXPR:
1431 pp_less (buffer);
1432 break;
1433 case GT_EXPR:
1434 pp_greater (buffer);
1435 break;
1436 case LE_EXPR:
1437 pp_less_equal (buffer);
1438 break;
1439 case GE_EXPR:
1440 pp_greater_equal (buffer);
1441 break;
1442 case NE_EXPR:
1443 pp_string (buffer, "!=");
1444 break;
1445 default:
1446 gcc_unreachable ();
1448 pp_space (buffer);
1449 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1450 flags, false);
1451 pp_string (buffer, "; ");
1453 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1454 flags, false);
1455 pp_string (buffer, " = ");
1456 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1457 flags, false);
1458 pp_right_paren (buffer);
1461 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1463 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1464 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1465 newline_and_indent (buffer, spc + 2);
1466 pp_left_brace (buffer);
1467 pp_newline (buffer);
1468 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1469 newline_and_indent (buffer, spc + 2);
1470 pp_right_brace (buffer);
1475 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1477 static void
1478 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1479 int spc, int flags)
1481 if (flags & TDF_RAW)
1483 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1484 gimple_omp_continue_control_def (gs),
1485 gimple_omp_continue_control_use (gs));
1487 else
1489 pp_string (buffer, "#pragma omp continue (");
1490 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1491 spc, flags, false);
1492 pp_comma (buffer);
1493 pp_space (buffer);
1494 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1495 spc, flags, false);
1496 pp_right_paren (buffer);
1500 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1502 static void
1503 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1504 int spc, int flags)
1506 if (flags & TDF_RAW)
1508 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1509 gimple_omp_body (gs));
1510 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1511 dump_gimple_fmt (buffer, spc, flags, " >");
1513 else
1515 pp_string (buffer, "#pragma omp single");
1516 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1517 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1519 newline_and_indent (buffer, spc + 2);
1520 pp_left_brace (buffer);
1521 pp_newline (buffer);
1522 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1523 newline_and_indent (buffer, spc + 2);
1524 pp_right_brace (buffer);
1529 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1531 static void
1532 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1533 int spc, int flags)
1535 const char *kind;
1536 switch (gimple_omp_target_kind (gs))
1538 case GF_OMP_TARGET_KIND_REGION:
1539 kind = "";
1540 break;
1541 case GF_OMP_TARGET_KIND_DATA:
1542 kind = " data";
1543 break;
1544 case GF_OMP_TARGET_KIND_UPDATE:
1545 kind = " update";
1546 break;
1547 case GF_OMP_TARGET_KIND_ENTER_DATA:
1548 kind = " enter data";
1549 break;
1550 case GF_OMP_TARGET_KIND_EXIT_DATA:
1551 kind = " exit data";
1552 break;
1553 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1554 kind = " oacc_kernels";
1555 break;
1556 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1557 kind = " oacc_parallel";
1558 break;
1559 case GF_OMP_TARGET_KIND_OACC_DATA:
1560 kind = " oacc_data";
1561 break;
1562 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1563 kind = " oacc_update";
1564 break;
1565 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1566 kind = " oacc_enter_exit_data";
1567 break;
1568 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1569 kind = " oacc_declare";
1570 break;
1571 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1572 kind = " oacc_host_data";
1573 break;
1574 default:
1575 gcc_unreachable ();
1577 if (flags & TDF_RAW)
1579 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1580 kind, gimple_omp_body (gs));
1581 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1582 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1583 gimple_omp_target_child_fn (gs),
1584 gimple_omp_target_data_arg (gs));
1586 else
1588 pp_string (buffer, "#pragma omp target");
1589 pp_string (buffer, kind);
1590 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1591 if (gimple_omp_target_child_fn (gs))
1593 pp_string (buffer, " [child fn: ");
1594 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1595 spc, flags, false);
1596 pp_string (buffer, " (");
1597 if (gimple_omp_target_data_arg (gs))
1598 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1599 spc, flags, false);
1600 else
1601 pp_string (buffer, "???");
1602 pp_string (buffer, ")]");
1604 gimple_seq body = gimple_omp_body (gs);
1605 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1607 newline_and_indent (buffer, spc + 2);
1608 pp_left_brace (buffer);
1609 pp_newline (buffer);
1610 dump_gimple_seq (buffer, body, spc + 4, flags);
1611 newline_and_indent (buffer, spc + 2);
1612 pp_right_brace (buffer);
1614 else if (body)
1616 pp_newline (buffer);
1617 dump_gimple_seq (buffer, body, spc + 2, flags);
1622 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1624 static void
1625 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1626 int flags)
1628 if (flags & TDF_RAW)
1630 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1631 gimple_omp_body (gs));
1632 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1633 dump_gimple_fmt (buffer, spc, flags, " >");
1635 else
1637 pp_string (buffer, "#pragma omp teams");
1638 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1639 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1641 newline_and_indent (buffer, spc + 2);
1642 pp_character (buffer, '{');
1643 pp_newline (buffer);
1644 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1645 newline_and_indent (buffer, spc + 2);
1646 pp_character (buffer, '}');
1651 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1653 static void
1654 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1655 int spc, int flags)
1657 if (flags & TDF_RAW)
1659 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1660 gimple_omp_body (gs));
1661 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1662 dump_gimple_fmt (buffer, spc, flags, " >");
1664 else
1666 pp_string (buffer, "#pragma omp sections");
1667 if (gimple_omp_sections_control (gs))
1669 pp_string (buffer, " <");
1670 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1671 flags, false);
1672 pp_greater (buffer);
1674 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1675 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1677 newline_and_indent (buffer, spc + 2);
1678 pp_left_brace (buffer);
1679 pp_newline (buffer);
1680 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1681 newline_and_indent (buffer, spc + 2);
1682 pp_right_brace (buffer);
1687 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1688 pretty_printer BUFFER. */
1690 static void
1691 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc, int flags)
1693 if (flags & TDF_RAW)
1694 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1695 gimple_omp_body (gs));
1696 else
1698 switch (gimple_code (gs))
1700 case GIMPLE_OMP_MASTER:
1701 pp_string (buffer, "#pragma omp master");
1702 break;
1703 case GIMPLE_OMP_TASKGROUP:
1704 pp_string (buffer, "#pragma omp taskgroup");
1705 break;
1706 case GIMPLE_OMP_SECTION:
1707 pp_string (buffer, "#pragma omp section");
1708 break;
1709 case GIMPLE_OMP_GRID_BODY:
1710 pp_string (buffer, "#pragma omp gridified body");
1711 break;
1712 default:
1713 gcc_unreachable ();
1715 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1717 newline_and_indent (buffer, spc + 2);
1718 pp_left_brace (buffer);
1719 pp_newline (buffer);
1720 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1721 newline_and_indent (buffer, spc + 2);
1722 pp_right_brace (buffer);
1727 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1729 static void
1730 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1731 int spc, int flags)
1733 if (flags & TDF_RAW)
1734 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1735 gimple_omp_body (gs));
1736 else
1738 pp_string (buffer, "#pragma omp critical");
1739 if (gimple_omp_critical_name (gs))
1741 pp_string (buffer, " (");
1742 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1743 flags, false);
1744 pp_right_paren (buffer);
1746 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1747 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1749 newline_and_indent (buffer, spc + 2);
1750 pp_left_brace (buffer);
1751 pp_newline (buffer);
1752 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1753 newline_and_indent (buffer, spc + 2);
1754 pp_right_brace (buffer);
1759 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1761 static void
1762 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1763 int spc, int flags)
1765 if (flags & TDF_RAW)
1766 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1767 gimple_omp_body (gs));
1768 else
1770 pp_string (buffer, "#pragma omp ordered");
1771 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1772 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1774 newline_and_indent (buffer, spc + 2);
1775 pp_left_brace (buffer);
1776 pp_newline (buffer);
1777 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1778 newline_and_indent (buffer, spc + 2);
1779 pp_right_brace (buffer);
1784 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1786 static void
1787 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc, int flags)
1789 if (flags & TDF_RAW)
1791 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1792 (int) gimple_omp_return_nowait_p (gs));
1793 if (gimple_omp_return_lhs (gs))
1794 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1795 gimple_omp_return_lhs (gs));
1796 else
1797 dump_gimple_fmt (buffer, spc, flags, ">");
1799 else
1801 pp_string (buffer, "#pragma omp return");
1802 if (gimple_omp_return_nowait_p (gs))
1803 pp_string (buffer, "(nowait)");
1804 if (gimple_omp_return_lhs (gs))
1806 pp_string (buffer, " (set ");
1807 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1808 spc, flags, false);
1809 pp_character (buffer, ')');
1814 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1816 static void
1817 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1818 int spc, int flags)
1820 unsigned subcode = gimple_transaction_subcode (gs);
1822 if (flags & TDF_RAW)
1824 dump_gimple_fmt (buffer, spc, flags,
1825 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1826 "<%+BODY <%S> >",
1827 gs, subcode, gimple_transaction_label_norm (gs),
1828 gimple_transaction_label_uninst (gs),
1829 gimple_transaction_label_over (gs),
1830 gimple_transaction_body (gs));
1832 else
1834 if (subcode & GTMA_IS_OUTER)
1835 pp_string (buffer, "__transaction_atomic [[outer]]");
1836 else if (subcode & GTMA_IS_RELAXED)
1837 pp_string (buffer, "__transaction_relaxed");
1838 else
1839 pp_string (buffer, "__transaction_atomic");
1840 subcode &= ~GTMA_DECLARATION_MASK;
1842 if (gimple_transaction_body (gs))
1844 newline_and_indent (buffer, spc + 2);
1845 pp_left_brace (buffer);
1846 pp_newline (buffer);
1847 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1848 spc + 4, flags);
1849 newline_and_indent (buffer, spc + 2);
1850 pp_right_brace (buffer);
1852 else
1854 pp_string (buffer, " //");
1855 if (gimple_transaction_label_norm (gs))
1857 pp_string (buffer, " NORM=");
1858 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1859 spc, flags, false);
1861 if (gimple_transaction_label_uninst (gs))
1863 pp_string (buffer, " UNINST=");
1864 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1865 spc, flags, false);
1867 if (gimple_transaction_label_over (gs))
1869 pp_string (buffer, " OVER=");
1870 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1871 spc, flags, false);
1873 if (subcode)
1875 pp_string (buffer, " SUBCODE=[ ");
1876 if (subcode & GTMA_HAVE_ABORT)
1878 pp_string (buffer, "GTMA_HAVE_ABORT ");
1879 subcode &= ~GTMA_HAVE_ABORT;
1881 if (subcode & GTMA_HAVE_LOAD)
1883 pp_string (buffer, "GTMA_HAVE_LOAD ");
1884 subcode &= ~GTMA_HAVE_LOAD;
1886 if (subcode & GTMA_HAVE_STORE)
1888 pp_string (buffer, "GTMA_HAVE_STORE ");
1889 subcode &= ~GTMA_HAVE_STORE;
1891 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1893 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1894 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1896 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1898 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1899 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1901 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1903 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1904 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1906 if (subcode)
1907 pp_printf (buffer, "0x%x ", subcode);
1908 pp_right_bracket (buffer);
1914 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1915 indent. FLAGS specifies details to show in the dump (see TDF_* in
1916 dumpfile.h). */
1918 static void
1919 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
1921 unsigned int i, n, f, fields;
1923 if (flags & TDF_RAW)
1925 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1926 gimple_asm_string (gs));
1928 n = gimple_asm_noutputs (gs);
1929 if (n)
1931 newline_and_indent (buffer, spc + 2);
1932 pp_string (buffer, "OUTPUT: ");
1933 for (i = 0; i < n; i++)
1935 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1936 spc, flags, false);
1937 if (i < n - 1)
1938 pp_string (buffer, ", ");
1942 n = gimple_asm_ninputs (gs);
1943 if (n)
1945 newline_and_indent (buffer, spc + 2);
1946 pp_string (buffer, "INPUT: ");
1947 for (i = 0; i < n; i++)
1949 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1950 spc, flags, false);
1951 if (i < n - 1)
1952 pp_string (buffer, ", ");
1956 n = gimple_asm_nclobbers (gs);
1957 if (n)
1959 newline_and_indent (buffer, spc + 2);
1960 pp_string (buffer, "CLOBBER: ");
1961 for (i = 0; i < n; i++)
1963 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1964 spc, flags, false);
1965 if (i < n - 1)
1966 pp_string (buffer, ", ");
1970 n = gimple_asm_nlabels (gs);
1971 if (n)
1973 newline_and_indent (buffer, spc + 2);
1974 pp_string (buffer, "LABEL: ");
1975 for (i = 0; i < n; i++)
1977 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1978 spc, flags, false);
1979 if (i < n - 1)
1980 pp_string (buffer, ", ");
1984 newline_and_indent (buffer, spc);
1985 pp_greater (buffer);
1987 else
1989 pp_string (buffer, "__asm__");
1990 if (gimple_asm_volatile_p (gs))
1991 pp_string (buffer, " __volatile__");
1992 if (gimple_asm_nlabels (gs))
1993 pp_string (buffer, " goto");
1994 pp_string (buffer, "(\"");
1995 pp_string (buffer, gimple_asm_string (gs));
1996 pp_string (buffer, "\"");
1998 if (gimple_asm_nlabels (gs))
1999 fields = 4;
2000 else if (gimple_asm_nclobbers (gs))
2001 fields = 3;
2002 else if (gimple_asm_ninputs (gs))
2003 fields = 2;
2004 else if (gimple_asm_noutputs (gs))
2005 fields = 1;
2006 else
2007 fields = 0;
2009 for (f = 0; f < fields; ++f)
2011 pp_string (buffer, " : ");
2013 switch (f)
2015 case 0:
2016 n = gimple_asm_noutputs (gs);
2017 for (i = 0; i < n; i++)
2019 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2020 spc, flags, false);
2021 if (i < n - 1)
2022 pp_string (buffer, ", ");
2024 break;
2026 case 1:
2027 n = gimple_asm_ninputs (gs);
2028 for (i = 0; i < n; i++)
2030 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2031 spc, flags, false);
2032 if (i < n - 1)
2033 pp_string (buffer, ", ");
2035 break;
2037 case 2:
2038 n = gimple_asm_nclobbers (gs);
2039 for (i = 0; i < n; i++)
2041 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2042 spc, flags, false);
2043 if (i < n - 1)
2044 pp_string (buffer, ", ");
2046 break;
2048 case 3:
2049 n = gimple_asm_nlabels (gs);
2050 for (i = 0; i < n; i++)
2052 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2053 spc, flags, false);
2054 if (i < n - 1)
2055 pp_string (buffer, ", ");
2057 break;
2059 default:
2060 gcc_unreachable ();
2064 pp_string (buffer, ");");
2068 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2069 SPC spaces of indent. */
2071 static void
2072 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2074 if (TREE_CODE (node) != SSA_NAME)
2075 return;
2077 if (POINTER_TYPE_P (TREE_TYPE (node))
2078 && SSA_NAME_PTR_INFO (node))
2080 unsigned int align, misalign;
2081 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2082 pp_string (buffer, "# PT = ");
2083 pp_points_to_solution (buffer, &pi->pt);
2084 newline_and_indent (buffer, spc);
2085 if (get_ptr_info_alignment (pi, &align, &misalign))
2087 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2088 newline_and_indent (buffer, spc);
2092 if (!POINTER_TYPE_P (TREE_TYPE (node))
2093 && SSA_NAME_RANGE_INFO (node))
2095 wide_int min, max, nonzero_bits;
2096 value_range_type range_type = get_range_info (node, &min, &max);
2098 if (range_type == VR_VARYING)
2099 pp_printf (buffer, "# RANGE VR_VARYING");
2100 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2102 pp_printf (buffer, "# RANGE ");
2103 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2104 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2105 pp_printf (buffer, ", ");
2106 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2107 pp_printf (buffer, "]");
2109 nonzero_bits = get_nonzero_bits (node);
2110 if (nonzero_bits != -1)
2112 pp_string (buffer, " NONZERO ");
2113 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2115 newline_and_indent (buffer, spc);
2119 /* As dump_ssaname_info, but dump to FILE. */
2121 void
2122 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2124 pretty_printer buffer;
2125 pp_needs_newline (&buffer) = true;
2126 buffer.buffer->stream = file;
2127 dump_ssaname_info (&buffer, node, spc);
2128 pp_flush (&buffer);
2131 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2132 The caller is responsible for calling pp_flush on BUFFER to finalize
2133 pretty printer. If COMMENT is true, print this after #. */
2135 static void
2136 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2137 int flags)
2139 size_t i;
2140 tree lhs = gimple_phi_result (phi);
2142 if (flags & TDF_ALIAS)
2143 dump_ssaname_info (buffer, lhs, spc);
2145 if (comment)
2146 pp_string (buffer, "# ");
2148 if (flags & TDF_RAW)
2149 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2150 gimple_phi_result (phi));
2151 else
2153 dump_generic_node (buffer, lhs, spc, flags, false);
2154 if (flags & TDF_GIMPLE)
2155 pp_string (buffer, " = __PHI (");
2156 else
2157 pp_string (buffer, " = PHI <");
2159 for (i = 0; i < gimple_phi_num_args (phi); i++)
2161 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2162 dump_location (buffer, gimple_phi_arg_location (phi, i));
2163 if (flags & TDF_GIMPLE)
2165 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2166 gimple *stmt = first_stmt (src);
2167 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2169 pp_string (buffer, "bb_");
2170 pp_decimal_int (buffer, src->index);
2172 else
2173 dump_generic_node (buffer, gimple_label_label (as_a <glabel *> (stmt)), 0, flags,
2174 false);
2175 pp_string (buffer, ": ");
2177 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2178 false);
2179 if (! (flags & TDF_GIMPLE))
2181 pp_left_paren (buffer);
2182 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2183 pp_right_paren (buffer);
2185 if (i < gimple_phi_num_args (phi) - 1)
2186 pp_string (buffer, ", ");
2188 if (flags & TDF_GIMPLE)
2189 pp_string (buffer, ");");
2190 else
2191 pp_greater (buffer);
2195 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2196 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2197 dumpfile.h). */
2199 static void
2200 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2201 int spc, int flags)
2203 if (flags & TDF_RAW)
2205 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2206 gimple_omp_body (gs));
2207 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2208 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2209 gimple_omp_parallel_child_fn (gs),
2210 gimple_omp_parallel_data_arg (gs));
2212 else
2214 gimple_seq body;
2215 pp_string (buffer, "#pragma omp parallel");
2216 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2217 if (gimple_omp_parallel_child_fn (gs))
2219 pp_string (buffer, " [child fn: ");
2220 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2221 spc, flags, false);
2222 pp_string (buffer, " (");
2223 if (gimple_omp_parallel_data_arg (gs))
2224 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2225 spc, flags, false);
2226 else
2227 pp_string (buffer, "???");
2228 pp_string (buffer, ")]");
2230 body = gimple_omp_body (gs);
2231 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2233 newline_and_indent (buffer, spc + 2);
2234 pp_left_brace (buffer);
2235 pp_newline (buffer);
2236 dump_gimple_seq (buffer, body, spc + 4, flags);
2237 newline_and_indent (buffer, spc + 2);
2238 pp_right_brace (buffer);
2240 else if (body)
2242 pp_newline (buffer);
2243 dump_gimple_seq (buffer, body, spc + 2, flags);
2249 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2250 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2251 dumpfile.h). */
2253 static void
2254 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2255 int flags)
2257 if (flags & TDF_RAW)
2259 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2260 gimple_omp_body (gs));
2261 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2262 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2263 gimple_omp_task_child_fn (gs),
2264 gimple_omp_task_data_arg (gs),
2265 gimple_omp_task_copy_fn (gs),
2266 gimple_omp_task_arg_size (gs),
2267 gimple_omp_task_arg_size (gs));
2269 else
2271 gimple_seq body;
2272 if (gimple_omp_task_taskloop_p (gs))
2273 pp_string (buffer, "#pragma omp taskloop");
2274 else
2275 pp_string (buffer, "#pragma omp task");
2276 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2277 if (gimple_omp_task_child_fn (gs))
2279 pp_string (buffer, " [child fn: ");
2280 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2281 spc, flags, false);
2282 pp_string (buffer, " (");
2283 if (gimple_omp_task_data_arg (gs))
2284 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2285 spc, flags, false);
2286 else
2287 pp_string (buffer, "???");
2288 pp_string (buffer, ")]");
2290 body = gimple_omp_body (gs);
2291 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2293 newline_and_indent (buffer, spc + 2);
2294 pp_left_brace (buffer);
2295 pp_newline (buffer);
2296 dump_gimple_seq (buffer, body, spc + 4, flags);
2297 newline_and_indent (buffer, spc + 2);
2298 pp_right_brace (buffer);
2300 else if (body)
2302 pp_newline (buffer);
2303 dump_gimple_seq (buffer, body, spc + 2, flags);
2309 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2310 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2311 in dumpfile.h). */
2313 static void
2314 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2315 int spc, int flags)
2317 if (flags & TDF_RAW)
2319 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2320 gimple_omp_atomic_load_lhs (gs),
2321 gimple_omp_atomic_load_rhs (gs));
2323 else
2325 pp_string (buffer, "#pragma omp atomic_load");
2326 if (gimple_omp_atomic_seq_cst_p (gs))
2327 pp_string (buffer, " seq_cst");
2328 if (gimple_omp_atomic_need_value_p (gs))
2329 pp_string (buffer, " [needed]");
2330 newline_and_indent (buffer, spc + 2);
2331 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2332 spc, flags, false);
2333 pp_space (buffer);
2334 pp_equal (buffer);
2335 pp_space (buffer);
2336 pp_star (buffer);
2337 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2338 spc, flags, false);
2342 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2343 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2344 in dumpfile.h). */
2346 static void
2347 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2348 gomp_atomic_store *gs, int spc, int flags)
2350 if (flags & TDF_RAW)
2352 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2353 gimple_omp_atomic_store_val (gs));
2355 else
2357 pp_string (buffer, "#pragma omp atomic_store ");
2358 if (gimple_omp_atomic_seq_cst_p (gs))
2359 pp_string (buffer, "seq_cst ");
2360 if (gimple_omp_atomic_need_value_p (gs))
2361 pp_string (buffer, "[needed] ");
2362 pp_left_paren (buffer);
2363 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2364 spc, flags, false);
2365 pp_right_paren (buffer);
2370 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2371 FLAGS are as in pp_gimple_stmt_1. */
2373 static void
2374 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc, int flags)
2376 tree vdef = gimple_vdef (gs);
2377 tree vuse = gimple_vuse (gs);
2379 if (vdef != NULL_TREE)
2381 pp_string (buffer, "# ");
2382 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2383 pp_string (buffer, " = VDEF <");
2384 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2385 pp_greater (buffer);
2386 newline_and_indent (buffer, spc);
2388 else if (vuse != NULL_TREE)
2390 pp_string (buffer, "# VUSE <");
2391 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2392 pp_greater (buffer);
2393 newline_and_indent (buffer, spc);
2398 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2399 spaces of indent. FLAGS specifies details to show in the dump (see
2400 TDF_* in dumpfile.h). The caller is responsible for calling
2401 pp_flush on BUFFER to finalize the pretty printer. */
2403 void
2404 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
2406 if (!gs)
2407 return;
2409 if (flags & TDF_STMTADDR)
2410 pp_printf (buffer, "<&%p> ", (void *) gs);
2412 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2413 dump_location (buffer, gimple_location (gs));
2415 if (flags & TDF_EH)
2417 int lp_nr = lookup_stmt_eh_lp (gs);
2418 if (lp_nr > 0)
2419 pp_printf (buffer, "[LP %d] ", lp_nr);
2420 else if (lp_nr < 0)
2421 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2424 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2425 && gimple_has_mem_ops (gs))
2426 dump_gimple_mem_ops (buffer, gs, spc, flags);
2428 if (gimple_has_lhs (gs)
2429 && (flags & TDF_ALIAS))
2430 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2432 switch (gimple_code (gs))
2434 case GIMPLE_ASM:
2435 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2436 break;
2438 case GIMPLE_ASSIGN:
2439 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2440 break;
2442 case GIMPLE_BIND:
2443 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2444 break;
2446 case GIMPLE_CALL:
2447 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2448 break;
2450 case GIMPLE_COND:
2451 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2452 break;
2454 case GIMPLE_LABEL:
2455 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2456 break;
2458 case GIMPLE_GOTO:
2459 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2460 break;
2462 case GIMPLE_NOP:
2463 pp_string (buffer, "GIMPLE_NOP");
2464 break;
2466 case GIMPLE_RETURN:
2467 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2468 break;
2470 case GIMPLE_SWITCH:
2471 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2472 break;
2474 case GIMPLE_TRY:
2475 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2476 break;
2478 case GIMPLE_PHI:
2479 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2480 break;
2482 case GIMPLE_OMP_PARALLEL:
2483 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2484 flags);
2485 break;
2487 case GIMPLE_OMP_TASK:
2488 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2489 break;
2491 case GIMPLE_OMP_ATOMIC_LOAD:
2492 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2493 spc, flags);
2494 break;
2496 case GIMPLE_OMP_ATOMIC_STORE:
2497 dump_gimple_omp_atomic_store (buffer,
2498 as_a <gomp_atomic_store *> (gs),
2499 spc, flags);
2500 break;
2502 case GIMPLE_OMP_FOR:
2503 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2504 break;
2506 case GIMPLE_OMP_CONTINUE:
2507 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2508 flags);
2509 break;
2511 case GIMPLE_OMP_SINGLE:
2512 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2513 flags);
2514 break;
2516 case GIMPLE_OMP_TARGET:
2517 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2518 flags);
2519 break;
2521 case GIMPLE_OMP_TEAMS:
2522 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2523 flags);
2524 break;
2526 case GIMPLE_OMP_RETURN:
2527 dump_gimple_omp_return (buffer, gs, spc, flags);
2528 break;
2530 case GIMPLE_OMP_SECTIONS:
2531 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2532 spc, flags);
2533 break;
2535 case GIMPLE_OMP_SECTIONS_SWITCH:
2536 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2537 break;
2539 case GIMPLE_OMP_MASTER:
2540 case GIMPLE_OMP_TASKGROUP:
2541 case GIMPLE_OMP_SECTION:
2542 case GIMPLE_OMP_GRID_BODY:
2543 dump_gimple_omp_block (buffer, gs, spc, flags);
2544 break;
2546 case GIMPLE_OMP_ORDERED:
2547 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2548 flags);
2549 break;
2551 case GIMPLE_OMP_CRITICAL:
2552 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2553 flags);
2554 break;
2556 case GIMPLE_CATCH:
2557 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2558 break;
2560 case GIMPLE_EH_FILTER:
2561 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2562 break;
2564 case GIMPLE_EH_MUST_NOT_THROW:
2565 dump_gimple_eh_must_not_throw (buffer,
2566 as_a <geh_mnt *> (gs),
2567 spc, flags);
2568 break;
2570 case GIMPLE_EH_ELSE:
2571 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2572 break;
2574 case GIMPLE_RESX:
2575 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2576 break;
2578 case GIMPLE_EH_DISPATCH:
2579 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2580 flags);
2581 break;
2583 case GIMPLE_DEBUG:
2584 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2585 break;
2587 case GIMPLE_PREDICT:
2588 pp_string (buffer, "// predicted ");
2589 if (gimple_predict_outcome (gs))
2590 pp_string (buffer, "likely by ");
2591 else
2592 pp_string (buffer, "unlikely by ");
2593 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2594 pp_string (buffer, " predictor.");
2595 break;
2597 case GIMPLE_TRANSACTION:
2598 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2599 flags);
2600 break;
2602 default:
2603 GIMPLE_NIY;
2608 /* Dumps header of basic block BB to OUTF indented by INDENT
2609 spaces and details described by flags. */
2611 static void
2612 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2614 if (flags & TDF_BLOCKS)
2616 if (flags & TDF_LINENO)
2618 gimple_stmt_iterator gsi;
2620 if (flags & TDF_COMMENT)
2621 fputs (";; ", outf);
2623 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2624 if (!is_gimple_debug (gsi_stmt (gsi))
2625 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2627 fprintf (outf, "%*sstarting at line %d",
2628 indent, "", get_lineno (gsi_stmt (gsi)));
2629 break;
2631 if (bb->discriminator)
2632 fprintf (outf, ", discriminator %i", bb->discriminator);
2633 fputc ('\n', outf);
2636 else
2638 gimple *stmt = first_stmt (bb);
2639 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2641 if (flags & TDF_GIMPLE)
2642 fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
2643 else
2644 fprintf (outf, "%*s<bb %d> %s:\n",
2645 indent, "", bb->index, dump_probability (bb->frequency));
2651 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2652 spaces. */
2654 static void
2655 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2656 basic_block bb ATTRIBUTE_UNUSED,
2657 int indent ATTRIBUTE_UNUSED,
2658 int flags ATTRIBUTE_UNUSED)
2660 /* There is currently no GIMPLE-specific basic block info to dump. */
2661 return;
2665 /* Dump PHI nodes of basic block BB to BUFFER with details described
2666 by FLAGS and indented by INDENT spaces. */
2668 static void
2669 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2671 gphi_iterator i;
2673 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2675 gphi *phi = i.phi ();
2676 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2678 INDENT (indent);
2679 dump_gimple_phi (buffer, phi, indent,
2680 (flags & TDF_GIMPLE) ? false : true, flags);
2681 pp_newline (buffer);
2687 /* Dump jump to basic block BB that is represented implicitly in the cfg
2688 to BUFFER. */
2690 static void
2691 pp_cfg_jump (pretty_printer *buffer, edge e, int flags)
2693 if (flags & TDF_GIMPLE)
2695 pp_string (buffer, "goto bb_");
2696 pp_decimal_int (buffer, e->dest->index);
2697 pp_semicolon (buffer);
2699 else
2701 gimple *stmt = first_stmt (e->dest);
2703 pp_string (buffer, "goto <bb ");
2704 pp_decimal_int (buffer, e->dest->index);
2705 pp_greater (buffer);
2706 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2708 pp_string (buffer, " (");
2709 dump_generic_node (buffer,
2710 gimple_label_label (as_a <glabel *> (stmt)),
2711 0, 0, false);
2712 pp_right_paren (buffer);
2713 pp_semicolon (buffer);
2715 else
2716 pp_semicolon (buffer);
2718 dump_edge_probability (buffer, e);
2723 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2724 by INDENT spaces, with details given by FLAGS. */
2726 static void
2727 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2728 int flags)
2730 edge e;
2731 gimple *stmt;
2733 stmt = last_stmt (bb);
2735 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2737 edge true_edge, false_edge;
2739 /* When we are emitting the code or changing CFG, it is possible that
2740 the edges are not yet created. When we are using debug_bb in such
2741 a situation, we do not want it to crash. */
2742 if (EDGE_COUNT (bb->succs) != 2)
2743 return;
2744 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2746 INDENT (indent + 2);
2747 pp_cfg_jump (buffer, true_edge, flags);
2748 newline_and_indent (buffer, indent);
2749 pp_string (buffer, "else");
2750 newline_and_indent (buffer, indent + 2);
2751 pp_cfg_jump (buffer, false_edge, flags);
2752 pp_newline (buffer);
2753 return;
2756 /* If there is a fallthru edge, we may need to add an artificial
2757 goto to the dump. */
2758 e = find_fallthru_edge (bb->succs);
2760 if (e && e->dest != bb->next_bb)
2762 INDENT (indent);
2764 if ((flags & TDF_LINENO)
2765 && e->goto_locus != UNKNOWN_LOCATION)
2766 dump_location (buffer, e->goto_locus);
2768 pp_cfg_jump (buffer, e, flags);
2769 pp_newline (buffer);
2774 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2775 indented by INDENT spaces. */
2777 static void
2778 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2779 int flags)
2781 gimple_stmt_iterator gsi;
2782 gimple *stmt;
2783 int label_indent = indent - 2;
2785 if (label_indent < 0)
2786 label_indent = 0;
2788 dump_phi_nodes (buffer, bb, indent, flags);
2790 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2792 int curr_indent;
2794 stmt = gsi_stmt (gsi);
2796 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2798 INDENT (curr_indent);
2799 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2800 pp_newline_and_flush (buffer);
2801 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2802 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2803 pp_buffer (buffer)->stream, stmt);
2806 dump_implicit_edges (buffer, bb, indent, flags);
2807 pp_flush (buffer);
2811 /* Dumps basic block BB to FILE with details described by FLAGS and
2812 indented by INDENT spaces. */
2814 void
2815 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2817 dump_gimple_bb_header (file, bb, indent, flags);
2818 if (bb->index >= NUM_FIXED_BLOCKS)
2820 pretty_printer buffer;
2821 pp_needs_newline (&buffer) = true;
2822 buffer.buffer->stream = file;
2823 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2825 dump_gimple_bb_footer (file, bb, indent, flags);
2828 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2829 no indentation, for use as a label of a DOT graph record-node.
2830 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2831 histogram dumping doesn't know about pretty-printers. */
2833 void
2834 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2836 pp_printf (pp, "<bb %d>:\n", bb->index);
2837 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2839 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2840 gsi_next (&gsi))
2842 gphi *phi = gsi.phi ();
2843 if (!virtual_operand_p (gimple_phi_result (phi))
2844 || (dump_flags & TDF_VOPS))
2846 pp_bar (pp);
2847 pp_write_text_to_stream (pp);
2848 pp_string (pp, "# ");
2849 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2850 pp_newline (pp);
2851 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2855 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2856 gsi_next (&gsi))
2858 gimple *stmt = gsi_stmt (gsi);
2859 pp_bar (pp);
2860 pp_write_text_to_stream (pp);
2861 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2862 pp_newline (pp);
2863 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2865 dump_implicit_edges (pp, bb, 0, dump_flags);
2866 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);