[arm][2/2] Remove support for -march=armv3 and older
[official-gcc.git] / gcc / gimple-pretty-print.c
blob49e9e1276da03889dc25b53861bff241a0737c20
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2018 Free Software Foundation, Inc.
3 Contributed by Aldy Hernandez <aldyh@redhat.com> and
4 Diego Novillo <dnovillo@google.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "dumpfile.h"
26 #include "backend.h"
27 #include "tree.h"
28 #include "gimple.h"
29 #include "gimple-predict.h"
30 #include "ssa.h"
31 #include "cgraph.h"
32 #include "gimple-pretty-print.h"
33 #include "internal-fn.h"
34 #include "tree-eh.h"
35 #include "gimple-iterator.h"
36 #include "tree-cfg.h"
37 #include "dumpfile.h" /* for dump_flags */
38 #include "value-prof.h"
39 #include "trans-mem.h"
40 #include "cfganal.h"
41 #include "stringpool.h"
42 #include "attribs.h"
43 #include "asan.h"
45 #define INDENT(SPACE) \
46 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
48 #define GIMPLE_NIY do_niy (buffer,gs)
50 /* Try to print on BUFFER a default message for the unrecognized
51 gimple statement GS. */
53 static void
54 do_niy (pretty_printer *buffer, gimple *gs)
56 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
57 gimple_code_name[(int) gimple_code (gs)]);
61 /* Emit a newline and SPC indentation spaces to BUFFER. */
63 static void
64 newline_and_indent (pretty_printer *buffer, int spc)
66 pp_newline (buffer);
67 INDENT (spc);
71 /* Print the GIMPLE statement GS on stderr. */
73 DEBUG_FUNCTION void
74 debug_gimple_stmt (gimple *gs)
76 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
80 /* Return formatted string of a VALUE probability
81 (biased by REG_BR_PROB_BASE). Returned string is allocated
82 by xstrdup_for_dump. */
84 static const char *
85 dump_profile (profile_count &count)
87 char *buf = NULL;
88 if (!count.initialized_p ())
89 return "";
90 if (count.ipa_p ())
91 buf = xasprintf ("[count: %" PRId64 "]",
92 count.to_gcov_type ());
93 else if (count.initialized_p ())
94 buf = xasprintf ("[local count: %" PRId64 "]",
95 count.to_gcov_type ());
97 const char *ret = xstrdup_for_dump (buf);
98 free (buf);
100 return ret;
103 /* Return formatted string of a VALUE probability
104 (biased by REG_BR_PROB_BASE). Returned string is allocated
105 by xstrdup_for_dump. */
107 static const char *
108 dump_probability (profile_probability probability)
110 float minimum = 0.01f;
111 float fvalue = -1;
113 if (probability.initialized_p ())
115 fvalue = probability.to_reg_br_prob_base () * 100.0f / REG_BR_PROB_BASE;
116 if (fvalue < minimum && probability.to_reg_br_prob_base ())
117 fvalue = minimum;
120 char *buf;
121 if (probability.initialized_p ())
122 buf = xasprintf ("[%.2f%%]", fvalue);
123 else
124 buf = xasprintf ("[INV]");
126 const char *ret = xstrdup_for_dump (buf);
127 free (buf);
129 return ret;
132 /* Dump E probability to BUFFER. */
134 static void
135 dump_edge_probability (pretty_printer *buffer, edge e)
137 pp_scalar (buffer, " %s", dump_probability (e->probability));
140 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
141 FLAGS as in pp_gimple_stmt_1. */
143 void
144 print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
146 pretty_printer buffer;
147 pp_needs_newline (&buffer) = true;
148 buffer.buffer->stream = file;
149 pp_gimple_stmt_1 (&buffer, g, spc, flags);
150 pp_newline_and_flush (&buffer);
153 DEBUG_FUNCTION void
154 debug (gimple &ref)
156 print_gimple_stmt (stderr, &ref, 0, 0);
159 DEBUG_FUNCTION void
160 debug (gimple *ptr)
162 if (ptr)
163 debug (*ptr);
164 else
165 fprintf (stderr, "<nil>\n");
169 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
170 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
171 of the statement. */
173 void
174 print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
176 flags |= TDF_RHS_ONLY;
177 pretty_printer buffer;
178 pp_needs_newline (&buffer) = true;
179 buffer.buffer->stream = file;
180 pp_gimple_stmt_1 (&buffer, g, spc, flags);
181 pp_flush (&buffer);
185 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
186 spaces and FLAGS as in pp_gimple_stmt_1.
187 The caller is responsible for calling pp_flush on BUFFER to finalize
188 the pretty printer. */
190 static void
191 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc,
192 dump_flags_t flags)
194 gimple_stmt_iterator i;
196 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
198 gimple *gs = gsi_stmt (i);
199 INDENT (spc);
200 pp_gimple_stmt_1 (buffer, gs, spc, flags);
201 if (!gsi_one_before_end_p (i))
202 pp_newline (buffer);
207 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
208 FLAGS as in pp_gimple_stmt_1. */
210 void
211 print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
213 pretty_printer buffer;
214 pp_needs_newline (&buffer) = true;
215 buffer.buffer->stream = file;
216 dump_gimple_seq (&buffer, seq, spc, flags);
217 pp_newline_and_flush (&buffer);
221 /* Print the GIMPLE sequence SEQ on stderr. */
223 DEBUG_FUNCTION void
224 debug_gimple_seq (gimple_seq seq)
226 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
230 /* A simple helper to pretty-print some of the gimple tuples in the printf
231 style. The format modifiers are preceded by '%' and are:
232 'G' - outputs a string corresponding to the code of the given gimple,
233 'S' - outputs a gimple_seq with indent of spc + 2,
234 'T' - outputs the tree t,
235 'd' - outputs an int as a decimal,
236 's' - outputs a string,
237 'n' - outputs a newline,
238 'x' - outputs an int as hexadecimal,
239 '+' - increases indent by 2 then outputs a newline,
240 '-' - decreases indent by 2 then outputs a newline. */
242 static void
243 dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags,
244 const char *fmt, ...)
246 va_list args;
247 const char *c;
248 const char *tmp;
250 va_start (args, fmt);
251 for (c = fmt; *c; c++)
253 if (*c == '%')
255 gimple_seq seq;
256 tree t;
257 gimple *g;
258 switch (*++c)
260 case 'G':
261 g = va_arg (args, gimple *);
262 tmp = gimple_code_name[gimple_code (g)];
263 pp_string (buffer, tmp);
264 break;
266 case 'S':
267 seq = va_arg (args, gimple_seq);
268 pp_newline (buffer);
269 dump_gimple_seq (buffer, seq, spc + 2, flags);
270 newline_and_indent (buffer, spc);
271 break;
273 case 'T':
274 t = va_arg (args, tree);
275 if (t == NULL_TREE)
276 pp_string (buffer, "NULL");
277 else
278 dump_generic_node (buffer, t, spc, flags, false);
279 break;
281 case 'd':
282 pp_decimal_int (buffer, va_arg (args, int));
283 break;
285 case 's':
286 pp_string (buffer, va_arg (args, char *));
287 break;
289 case 'n':
290 newline_and_indent (buffer, spc);
291 break;
293 case 'x':
294 pp_scalar (buffer, "%x", va_arg (args, int));
295 break;
297 case '+':
298 spc += 2;
299 newline_and_indent (buffer, spc);
300 break;
302 case '-':
303 spc -= 2;
304 newline_and_indent (buffer, spc);
305 break;
307 default:
308 gcc_unreachable ();
311 else
312 pp_character (buffer, *c);
314 va_end (args);
318 /* Helper for dump_gimple_assign. Print the unary RHS of the
319 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
321 static void
322 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc,
323 dump_flags_t flags)
325 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
326 tree lhs = gimple_assign_lhs (gs);
327 tree rhs = gimple_assign_rhs1 (gs);
329 switch (rhs_code)
331 case VIEW_CONVERT_EXPR:
332 case ASSERT_EXPR:
333 dump_generic_node (buffer, rhs, spc, flags, false);
334 break;
336 case FIXED_CONVERT_EXPR:
337 case ADDR_SPACE_CONVERT_EXPR:
338 case FIX_TRUNC_EXPR:
339 case FLOAT_EXPR:
340 CASE_CONVERT:
341 pp_left_paren (buffer);
342 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
343 pp_string (buffer, ") ");
344 if (op_prio (rhs) < op_code_prio (rhs_code))
346 pp_left_paren (buffer);
347 dump_generic_node (buffer, rhs, spc, flags, false);
348 pp_right_paren (buffer);
350 else
351 dump_generic_node (buffer, rhs, spc, flags, false);
352 break;
354 case PAREN_EXPR:
355 pp_string (buffer, "((");
356 dump_generic_node (buffer, rhs, spc, flags, false);
357 pp_string (buffer, "))");
358 break;
360 case ABS_EXPR:
361 if (flags & TDF_GIMPLE)
363 pp_string (buffer, "__ABS ");
364 dump_generic_node (buffer, rhs, spc, flags, false);
366 else
368 pp_string (buffer, "ABS_EXPR <");
369 dump_generic_node (buffer, rhs, spc, flags, false);
370 pp_greater (buffer);
372 break;
374 default:
375 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
376 || TREE_CODE_CLASS (rhs_code) == tcc_constant
377 || TREE_CODE_CLASS (rhs_code) == tcc_reference
378 || rhs_code == SSA_NAME
379 || rhs_code == ADDR_EXPR
380 || rhs_code == CONSTRUCTOR)
382 dump_generic_node (buffer, rhs, spc, flags, false);
383 break;
385 else if (rhs_code == BIT_NOT_EXPR)
386 pp_complement (buffer);
387 else if (rhs_code == TRUTH_NOT_EXPR)
388 pp_exclamation (buffer);
389 else if (rhs_code == NEGATE_EXPR)
390 pp_minus (buffer);
391 else
393 pp_left_bracket (buffer);
394 pp_string (buffer, get_tree_code_name (rhs_code));
395 pp_string (buffer, "] ");
398 if (op_prio (rhs) < op_code_prio (rhs_code))
400 pp_left_paren (buffer);
401 dump_generic_node (buffer, rhs, spc, flags, false);
402 pp_right_paren (buffer);
404 else
405 dump_generic_node (buffer, rhs, spc, flags, false);
406 break;
411 /* Helper for dump_gimple_assign. Print the binary RHS of the
412 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
414 static void
415 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc,
416 dump_flags_t flags)
418 const char *p;
419 enum tree_code code = gimple_assign_rhs_code (gs);
420 switch (code)
422 case COMPLEX_EXPR:
423 case MIN_EXPR:
424 case MAX_EXPR:
425 case VEC_WIDEN_MULT_HI_EXPR:
426 case VEC_WIDEN_MULT_LO_EXPR:
427 case VEC_WIDEN_MULT_EVEN_EXPR:
428 case VEC_WIDEN_MULT_ODD_EXPR:
429 case VEC_PACK_TRUNC_EXPR:
430 case VEC_PACK_SAT_EXPR:
431 case VEC_PACK_FIX_TRUNC_EXPR:
432 case VEC_WIDEN_LSHIFT_HI_EXPR:
433 case VEC_WIDEN_LSHIFT_LO_EXPR:
434 case VEC_SERIES_EXPR:
435 for (p = get_tree_code_name (code); *p; p++)
436 pp_character (buffer, TOUPPER (*p));
437 pp_string (buffer, " <");
438 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
439 pp_string (buffer, ", ");
440 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
441 pp_greater (buffer);
442 break;
444 default:
445 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
447 pp_left_paren (buffer);
448 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
449 false);
450 pp_right_paren (buffer);
452 else
453 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
454 pp_space (buffer);
455 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
456 pp_space (buffer);
457 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
459 pp_left_paren (buffer);
460 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
461 false);
462 pp_right_paren (buffer);
464 else
465 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
469 /* Helper for dump_gimple_assign. Print the ternary RHS of the
470 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
472 static void
473 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc,
474 dump_flags_t flags)
476 const char *p;
477 enum tree_code code = gimple_assign_rhs_code (gs);
478 switch (code)
480 case WIDEN_MULT_PLUS_EXPR:
481 case WIDEN_MULT_MINUS_EXPR:
482 for (p = get_tree_code_name (code); *p; p++)
483 pp_character (buffer, TOUPPER (*p));
484 pp_string (buffer, " <");
485 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
486 pp_string (buffer, ", ");
487 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
488 pp_string (buffer, ", ");
489 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
490 pp_greater (buffer);
491 break;
493 case DOT_PROD_EXPR:
494 pp_string (buffer, "DOT_PROD_EXPR <");
495 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
496 pp_string (buffer, ", ");
497 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
498 pp_string (buffer, ", ");
499 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
500 pp_greater (buffer);
501 break;
503 case SAD_EXPR:
504 pp_string (buffer, "SAD_EXPR <");
505 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
506 pp_string (buffer, ", ");
507 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
508 pp_string (buffer, ", ");
509 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
510 pp_greater (buffer);
511 break;
513 case VEC_PERM_EXPR:
514 pp_string (buffer, "VEC_PERM_EXPR <");
515 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
516 pp_string (buffer, ", ");
517 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
518 pp_string (buffer, ", ");
519 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
520 pp_greater (buffer);
521 break;
523 case REALIGN_LOAD_EXPR:
524 pp_string (buffer, "REALIGN_LOAD <");
525 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
526 pp_string (buffer, ", ");
527 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
528 pp_string (buffer, ", ");
529 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
530 pp_greater (buffer);
531 break;
533 case COND_EXPR:
534 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
535 pp_string (buffer, " ? ");
536 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
537 pp_string (buffer, " : ");
538 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
539 break;
541 case VEC_COND_EXPR:
542 pp_string (buffer, "VEC_COND_EXPR <");
543 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
544 pp_string (buffer, ", ");
545 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
546 pp_string (buffer, ", ");
547 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
548 pp_greater (buffer);
549 break;
551 case BIT_INSERT_EXPR:
552 pp_string (buffer, "BIT_INSERT_EXPR <");
553 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
554 pp_string (buffer, ", ");
555 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
556 pp_string (buffer, ", ");
557 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
558 pp_string (buffer, " (");
559 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
560 pp_decimal_int (buffer,
561 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
562 else
563 dump_generic_node (buffer,
564 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
565 spc, flags, false);
566 pp_string (buffer, " bits)>");
567 break;
569 default:
570 gcc_unreachable ();
575 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
576 pp_gimple_stmt_1. */
578 static void
579 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc,
580 dump_flags_t flags)
582 if (flags & TDF_RAW)
584 tree arg1 = NULL;
585 tree arg2 = NULL;
586 tree arg3 = NULL;
587 switch (gimple_num_ops (gs))
589 case 4:
590 arg3 = gimple_assign_rhs3 (gs);
591 /* FALLTHRU */
592 case 3:
593 arg2 = gimple_assign_rhs2 (gs);
594 /* FALLTHRU */
595 case 2:
596 arg1 = gimple_assign_rhs1 (gs);
597 break;
598 default:
599 gcc_unreachable ();
602 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
603 get_tree_code_name (gimple_assign_rhs_code (gs)),
604 gimple_assign_lhs (gs), arg1, arg2, arg3);
606 else
608 if (!(flags & TDF_RHS_ONLY))
610 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
611 pp_space (buffer);
612 pp_equal (buffer);
614 if (gimple_assign_nontemporal_move_p (gs))
615 pp_string (buffer, "{nt}");
617 if (gimple_has_volatile_ops (gs))
618 pp_string (buffer, "{v}");
620 pp_space (buffer);
623 if (gimple_num_ops (gs) == 2)
624 dump_unary_rhs (buffer, gs, spc, flags);
625 else if (gimple_num_ops (gs) == 3)
626 dump_binary_rhs (buffer, gs, spc, flags);
627 else if (gimple_num_ops (gs) == 4)
628 dump_ternary_rhs (buffer, gs, spc, flags);
629 else
630 gcc_unreachable ();
631 if (!(flags & TDF_RHS_ONLY))
632 pp_semicolon (buffer);
637 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
638 pp_gimple_stmt_1. */
640 static void
641 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc,
642 dump_flags_t flags)
644 tree t, t2;
646 t = gimple_return_retval (gs);
647 t2 = gimple_return_retbnd (gs);
648 if (flags & TDF_RAW)
649 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
650 else
652 pp_string (buffer, "return");
653 if (t)
655 pp_space (buffer);
656 dump_generic_node (buffer, t, spc, flags, false);
658 if (t2)
660 pp_string (buffer, ", ");
661 dump_generic_node (buffer, t2, spc, flags, false);
663 pp_semicolon (buffer);
668 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
669 dump_gimple_call. */
671 static void
672 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, dump_flags_t flags)
674 size_t i = 0;
676 /* Pretty print first arg to certain internal fns. */
677 if (gimple_call_internal_p (gs))
679 const char *const *enums = NULL;
680 unsigned limit = 0;
682 switch (gimple_call_internal_fn (gs))
684 case IFN_UNIQUE:
685 #define DEF(X) #X
686 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
687 #undef DEF
688 enums = unique_args;
690 limit = ARRAY_SIZE (unique_args);
691 break;
693 case IFN_GOACC_LOOP:
694 #define DEF(X) #X
695 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
696 #undef DEF
697 enums = loop_args;
698 limit = ARRAY_SIZE (loop_args);
699 break;
701 case IFN_GOACC_REDUCTION:
702 #define DEF(X) #X
703 static const char *const reduction_args[]
704 = {IFN_GOACC_REDUCTION_CODES};
705 #undef DEF
706 enums = reduction_args;
707 limit = ARRAY_SIZE (reduction_args);
708 break;
710 case IFN_ASAN_MARK:
711 #define DEF(X) #X
712 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
713 #undef DEF
714 enums = asan_mark_args;
715 limit = ARRAY_SIZE (asan_mark_args);
716 break;
718 default:
719 break;
721 if (limit)
723 tree arg0 = gimple_call_arg (gs, 0);
724 HOST_WIDE_INT v;
726 if (TREE_CODE (arg0) == INTEGER_CST
727 && tree_fits_shwi_p (arg0)
728 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
730 i++;
731 pp_string (buffer, enums[v]);
736 for (; i < gimple_call_num_args (gs); i++)
738 if (i)
739 pp_string (buffer, ", ");
740 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
743 if (gimple_call_va_arg_pack_p (gs))
745 if (i)
746 pp_string (buffer, ", ");
748 pp_string (buffer, "__builtin_va_arg_pack ()");
752 /* Dump the points-to solution *PT to BUFFER. */
754 static void
755 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
757 if (pt->anything)
759 pp_string (buffer, "anything ");
760 return;
762 if (pt->nonlocal)
763 pp_string (buffer, "nonlocal ");
764 if (pt->escaped)
765 pp_string (buffer, "escaped ");
766 if (pt->ipa_escaped)
767 pp_string (buffer, "unit-escaped ");
768 if (pt->null)
769 pp_string (buffer, "null ");
770 if (pt->vars
771 && !bitmap_empty_p (pt->vars))
773 bitmap_iterator bi;
774 unsigned i;
775 pp_string (buffer, "{ ");
776 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
778 pp_string (buffer, "D.");
779 pp_decimal_int (buffer, i);
780 pp_space (buffer);
782 pp_right_brace (buffer);
783 if (pt->vars_contains_nonlocal
784 || pt->vars_contains_escaped
785 || pt->vars_contains_escaped_heap
786 || pt->vars_contains_restrict)
788 const char *comma = "";
789 pp_string (buffer, " (");
790 if (pt->vars_contains_nonlocal)
792 pp_string (buffer, "nonlocal");
793 comma = ", ";
795 if (pt->vars_contains_escaped)
797 pp_string (buffer, comma);
798 pp_string (buffer, "escaped");
799 comma = ", ";
801 if (pt->vars_contains_escaped_heap)
803 pp_string (buffer, comma);
804 pp_string (buffer, "escaped heap");
805 comma = ", ";
807 if (pt->vars_contains_restrict)
809 pp_string (buffer, comma);
810 pp_string (buffer, "restrict");
811 comma = ", ";
813 if (pt->vars_contains_interposable)
815 pp_string (buffer, comma);
816 pp_string (buffer, "interposable");
818 pp_string (buffer, ")");
824 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
825 pp_gimple_stmt_1. */
827 static void
828 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
829 dump_flags_t flags)
831 tree lhs = gimple_call_lhs (gs);
832 tree fn = gimple_call_fn (gs);
834 if (flags & TDF_ALIAS)
836 struct pt_solution *pt;
837 pt = gimple_call_use_set (gs);
838 if (!pt_solution_empty_p (pt))
840 pp_string (buffer, "# USE = ");
841 pp_points_to_solution (buffer, pt);
842 newline_and_indent (buffer, spc);
844 pt = gimple_call_clobber_set (gs);
845 if (!pt_solution_empty_p (pt))
847 pp_string (buffer, "# CLB = ");
848 pp_points_to_solution (buffer, pt);
849 newline_and_indent (buffer, spc);
853 if (flags & TDF_RAW)
855 if (gimple_call_internal_p (gs))
856 dump_gimple_fmt (buffer, spc, flags, "%G <.%s, %T", gs,
857 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
858 else
859 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
860 if (gimple_call_num_args (gs) > 0)
862 pp_string (buffer, ", ");
863 dump_gimple_call_args (buffer, gs, flags);
865 pp_greater (buffer);
867 else
869 if (lhs && !(flags & TDF_RHS_ONLY))
871 dump_generic_node (buffer, lhs, spc, flags, false);
872 pp_string (buffer, " =");
874 if (gimple_has_volatile_ops (gs))
875 pp_string (buffer, "{v}");
877 pp_space (buffer);
879 if (gimple_call_internal_p (gs))
881 pp_dot (buffer);
882 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
884 else
885 print_call_name (buffer, fn, flags);
886 pp_string (buffer, " (");
887 dump_gimple_call_args (buffer, gs, flags);
888 pp_right_paren (buffer);
889 if (!(flags & TDF_RHS_ONLY))
890 pp_semicolon (buffer);
893 if (gimple_call_chain (gs))
895 pp_string (buffer, " [static-chain: ");
896 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
897 pp_right_bracket (buffer);
900 if (gimple_call_return_slot_opt_p (gs))
901 pp_string (buffer, " [return slot optimization]");
902 if (gimple_call_tail_p (gs))
903 pp_string (buffer, " [tail call]");
904 if (gimple_call_must_tail_p (gs))
905 pp_string (buffer, " [must tail call]");
907 if (fn == NULL)
908 return;
910 /* Dump the arguments of _ITM_beginTransaction sanely. */
911 if (TREE_CODE (fn) == ADDR_EXPR)
912 fn = TREE_OPERAND (fn, 0);
913 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
914 pp_string (buffer, " [tm-clone]");
915 if (TREE_CODE (fn) == FUNCTION_DECL
916 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
917 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
918 && gimple_call_num_args (gs) > 0)
920 tree t = gimple_call_arg (gs, 0);
921 unsigned HOST_WIDE_INT props;
922 gcc_assert (TREE_CODE (t) == INTEGER_CST);
924 pp_string (buffer, " [ ");
926 /* Get the transaction code properties. */
927 props = TREE_INT_CST_LOW (t);
929 if (props & PR_INSTRUMENTEDCODE)
930 pp_string (buffer, "instrumentedCode ");
931 if (props & PR_UNINSTRUMENTEDCODE)
932 pp_string (buffer, "uninstrumentedCode ");
933 if (props & PR_HASNOXMMUPDATE)
934 pp_string (buffer, "hasNoXMMUpdate ");
935 if (props & PR_HASNOABORT)
936 pp_string (buffer, "hasNoAbort ");
937 if (props & PR_HASNOIRREVOCABLE)
938 pp_string (buffer, "hasNoIrrevocable ");
939 if (props & PR_DOESGOIRREVOCABLE)
940 pp_string (buffer, "doesGoIrrevocable ");
941 if (props & PR_HASNOSIMPLEREADS)
942 pp_string (buffer, "hasNoSimpleReads ");
943 if (props & PR_AWBARRIERSOMITTED)
944 pp_string (buffer, "awBarriersOmitted ");
945 if (props & PR_RARBARRIERSOMITTED)
946 pp_string (buffer, "RaRBarriersOmitted ");
947 if (props & PR_UNDOLOGCODE)
948 pp_string (buffer, "undoLogCode ");
949 if (props & PR_PREFERUNINSTRUMENTED)
950 pp_string (buffer, "preferUninstrumented ");
951 if (props & PR_EXCEPTIONBLOCK)
952 pp_string (buffer, "exceptionBlock ");
953 if (props & PR_HASELSE)
954 pp_string (buffer, "hasElse ");
955 if (props & PR_READONLY)
956 pp_string (buffer, "readOnly ");
958 pp_right_bracket (buffer);
963 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
964 pp_gimple_stmt_1. */
966 static void
967 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
968 dump_flags_t flags)
970 unsigned int i;
972 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
973 if (flags & TDF_RAW)
974 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
975 gimple_switch_index (gs));
976 else
978 pp_string (buffer, "switch (");
979 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
980 if (flags & TDF_GIMPLE)
981 pp_string (buffer, ") {");
982 else
983 pp_string (buffer, ") <");
986 for (i = 0; i < gimple_switch_num_labels (gs); i++)
988 tree case_label = gimple_switch_label (gs, i);
989 gcc_checking_assert (case_label != NULL_TREE);
990 dump_generic_node (buffer, case_label, spc, flags, false);
991 pp_space (buffer);
992 tree label = CASE_LABEL (case_label);
993 dump_generic_node (buffer, label, spc, flags, false);
995 if (cfun && cfun->cfg)
997 basic_block dest = label_to_block (label);
998 if (dest)
1000 edge label_edge = find_edge (gimple_bb (gs), dest);
1001 if (label_edge && !(flags & TDF_GIMPLE))
1002 dump_edge_probability (buffer, label_edge);
1006 if (i < gimple_switch_num_labels (gs) - 1)
1008 if (flags & TDF_GIMPLE)
1009 pp_string (buffer, "; ");
1010 else
1011 pp_string (buffer, ", ");
1014 if (flags & TDF_GIMPLE)
1015 pp_string (buffer, "; }");
1016 else
1017 pp_greater (buffer);
1021 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1022 pp_gimple_stmt_1. */
1024 static void
1025 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc,
1026 dump_flags_t flags)
1028 if (flags & TDF_RAW)
1029 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1030 get_tree_code_name (gimple_cond_code (gs)),
1031 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1032 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1033 else
1035 if (!(flags & TDF_RHS_ONLY))
1036 pp_string (buffer, "if (");
1037 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
1038 pp_space (buffer);
1039 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1040 pp_space (buffer);
1041 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
1042 if (!(flags & TDF_RHS_ONLY))
1044 edge_iterator ei;
1045 edge e, true_edge = NULL, false_edge = NULL;
1046 basic_block bb = gimple_bb (gs);
1048 if (bb)
1050 FOR_EACH_EDGE (e, ei, bb->succs)
1052 if (e->flags & EDGE_TRUE_VALUE)
1053 true_edge = e;
1054 else if (e->flags & EDGE_FALSE_VALUE)
1055 false_edge = e;
1059 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1061 pp_right_paren (buffer);
1063 if (gimple_cond_true_label (gs))
1065 pp_string (buffer, " goto ");
1066 dump_generic_node (buffer, gimple_cond_true_label (gs),
1067 spc, flags, false);
1068 if (has_edge_info && !(flags & TDF_GIMPLE))
1069 dump_edge_probability (buffer, true_edge);
1070 pp_semicolon (buffer);
1072 if (gimple_cond_false_label (gs))
1074 pp_string (buffer, " else goto ");
1075 dump_generic_node (buffer, gimple_cond_false_label (gs),
1076 spc, flags, false);
1077 if (has_edge_info && !(flags & TDF_GIMPLE))
1078 dump_edge_probability (buffer, false_edge);
1080 pp_semicolon (buffer);
1087 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1088 spaces of indent. FLAGS specifies details to show in the dump (see
1089 TDF_* in dumpfils.h). */
1091 static void
1092 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
1093 dump_flags_t flags)
1095 tree label = gimple_label_label (gs);
1096 if (flags & TDF_RAW)
1097 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1098 else
1100 dump_generic_node (buffer, label, spc, flags, false);
1101 pp_colon (buffer);
1103 if (flags & TDF_GIMPLE)
1104 return;
1105 if (DECL_NONLOCAL (label))
1106 pp_string (buffer, " [non-local]");
1107 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1108 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1111 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1112 spaces of indent. FLAGS specifies details to show in the dump (see
1113 TDF_* in dumpfile.h). */
1115 static void
1116 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc,
1117 dump_flags_t flags)
1119 tree label = gimple_goto_dest (gs);
1120 if (flags & TDF_RAW)
1121 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1122 else
1123 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1127 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1128 spaces of indent. FLAGS specifies details to show in the dump (see
1129 TDF_* in dumpfile.h). */
1131 static void
1132 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc,
1133 dump_flags_t flags)
1135 if (flags & TDF_RAW)
1136 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1137 else
1138 pp_left_brace (buffer);
1139 if (!(flags & TDF_SLIM))
1141 tree var;
1143 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1145 newline_and_indent (buffer, 2);
1146 print_declaration (buffer, var, spc, flags);
1148 if (gimple_bind_vars (gs))
1149 pp_newline (buffer);
1151 pp_newline (buffer);
1152 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1153 newline_and_indent (buffer, spc);
1154 if (flags & TDF_RAW)
1155 pp_greater (buffer);
1156 else
1157 pp_right_brace (buffer);
1161 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1162 indent. FLAGS specifies details to show in the dump (see TDF_* in
1163 dumpfile.h). */
1165 static void
1166 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc,
1167 dump_flags_t flags)
1169 if (flags & TDF_RAW)
1171 const char *type;
1172 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1173 type = "GIMPLE_TRY_CATCH";
1174 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1175 type = "GIMPLE_TRY_FINALLY";
1176 else
1177 type = "UNKNOWN GIMPLE_TRY";
1178 dump_gimple_fmt (buffer, spc, flags,
1179 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1180 gimple_try_eval (gs), gimple_try_cleanup (gs));
1182 else
1184 pp_string (buffer, "try");
1185 newline_and_indent (buffer, spc + 2);
1186 pp_left_brace (buffer);
1187 pp_newline (buffer);
1189 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1190 newline_and_indent (buffer, spc + 2);
1191 pp_right_brace (buffer);
1193 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1195 newline_and_indent (buffer, spc);
1196 pp_string (buffer, "catch");
1197 newline_and_indent (buffer, spc + 2);
1198 pp_left_brace (buffer);
1200 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1202 newline_and_indent (buffer, spc);
1203 pp_string (buffer, "finally");
1204 newline_and_indent (buffer, spc + 2);
1205 pp_left_brace (buffer);
1207 else
1208 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1210 pp_newline (buffer);
1211 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1212 newline_and_indent (buffer, spc + 2);
1213 pp_right_brace (buffer);
1218 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1219 indent. FLAGS specifies details to show in the dump (see TDF_* in
1220 dumpfile.h). */
1222 static void
1223 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc,
1224 dump_flags_t flags)
1226 if (flags & TDF_RAW)
1227 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1228 gimple_catch_types (gs), gimple_catch_handler (gs));
1229 else
1230 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1231 gimple_catch_types (gs), gimple_catch_handler (gs));
1235 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1236 indent. FLAGS specifies details to show in the dump (see TDF_* in
1237 dumpfile.h). */
1239 static void
1240 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1241 dump_flags_t flags)
1243 if (flags & TDF_RAW)
1244 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1245 gimple_eh_filter_types (gs),
1246 gimple_eh_filter_failure (gs));
1247 else
1248 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1249 gimple_eh_filter_types (gs),
1250 gimple_eh_filter_failure (gs));
1254 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1256 static void
1257 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1258 geh_mnt *gs, int spc, dump_flags_t flags)
1260 if (flags & TDF_RAW)
1261 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1262 gimple_eh_must_not_throw_fndecl (gs));
1263 else
1264 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1265 gimple_eh_must_not_throw_fndecl (gs));
1269 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1270 indent. FLAGS specifies details to show in the dump (see TDF_* in
1271 dumpfile.h). */
1273 static void
1274 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1275 dump_flags_t flags)
1277 if (flags & TDF_RAW)
1278 dump_gimple_fmt (buffer, spc, flags,
1279 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1280 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1281 else
1282 dump_gimple_fmt (buffer, spc, flags,
1283 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1284 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1288 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1289 indent. FLAGS specifies details to show in the dump (see TDF_* in
1290 dumpfile.h). */
1292 static void
1293 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc,
1294 dump_flags_t flags)
1296 if (flags & TDF_RAW)
1297 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1298 gimple_resx_region (gs));
1299 else
1300 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1303 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1305 static void
1306 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc,
1307 dump_flags_t flags)
1309 if (flags & TDF_RAW)
1310 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1311 gimple_eh_dispatch_region (gs));
1312 else
1313 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1314 gimple_eh_dispatch_region (gs));
1317 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1318 of indent. FLAGS specifies details to show in the dump (see TDF_*
1319 in dumpfile.h). */
1321 static void
1322 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc,
1323 dump_flags_t flags)
1325 switch (gs->subcode)
1327 case GIMPLE_DEBUG_BIND:
1328 if (flags & TDF_RAW)
1329 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1330 gimple_debug_bind_get_var (gs),
1331 gimple_debug_bind_get_value (gs));
1332 else
1333 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1334 gimple_debug_bind_get_var (gs),
1335 gimple_debug_bind_get_value (gs));
1336 break;
1338 case GIMPLE_DEBUG_SOURCE_BIND:
1339 if (flags & TDF_RAW)
1340 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1341 gimple_debug_source_bind_get_var (gs),
1342 gimple_debug_source_bind_get_value (gs));
1343 else
1344 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1345 gimple_debug_source_bind_get_var (gs),
1346 gimple_debug_source_bind_get_value (gs));
1347 break;
1349 case GIMPLE_DEBUG_BEGIN_STMT:
1350 if (flags & TDF_RAW)
1351 dump_gimple_fmt (buffer, spc, flags, "%G BEGIN_STMT", gs);
1352 else
1353 dump_gimple_fmt (buffer, spc, flags, "# DEBUG BEGIN_STMT");
1354 break;
1356 case GIMPLE_DEBUG_INLINE_ENTRY:
1357 if (flags & TDF_RAW)
1358 dump_gimple_fmt (buffer, spc, flags, "%G INLINE_ENTRY %T", gs,
1359 gimple_block (gs)
1360 ? block_ultimate_origin (gimple_block (gs))
1361 : NULL_TREE);
1362 else
1363 dump_gimple_fmt (buffer, spc, flags, "# DEBUG INLINE_ENTRY %T",
1364 gimple_block (gs)
1365 ? block_ultimate_origin (gimple_block (gs))
1366 : NULL_TREE);
1367 break;
1369 default:
1370 gcc_unreachable ();
1374 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1375 static void
1376 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc,
1377 dump_flags_t flags)
1379 size_t i;
1381 if (flags & TDF_RAW)
1383 const char *kind;
1384 switch (gimple_omp_for_kind (gs))
1386 case GF_OMP_FOR_KIND_FOR:
1387 kind = "";
1388 break;
1389 case GF_OMP_FOR_KIND_DISTRIBUTE:
1390 kind = " distribute";
1391 break;
1392 case GF_OMP_FOR_KIND_TASKLOOP:
1393 kind = " taskloop";
1394 break;
1395 case GF_OMP_FOR_KIND_OACC_LOOP:
1396 kind = " oacc_loop";
1397 break;
1398 case GF_OMP_FOR_KIND_SIMD:
1399 kind = " simd";
1400 break;
1401 default:
1402 gcc_unreachable ();
1404 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1405 kind, gimple_omp_body (gs));
1406 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1407 dump_gimple_fmt (buffer, spc, flags, " >,");
1408 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1409 dump_gimple_fmt (buffer, spc, flags,
1410 "%+%T, %T, %T, %s, %T,%n",
1411 gimple_omp_for_index (gs, i),
1412 gimple_omp_for_initial (gs, i),
1413 gimple_omp_for_final (gs, i),
1414 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1415 gimple_omp_for_incr (gs, i));
1416 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1417 gimple_omp_for_pre_body (gs));
1419 else
1421 switch (gimple_omp_for_kind (gs))
1423 case GF_OMP_FOR_KIND_FOR:
1424 pp_string (buffer, "#pragma omp for");
1425 break;
1426 case GF_OMP_FOR_KIND_DISTRIBUTE:
1427 pp_string (buffer, "#pragma omp distribute");
1428 break;
1429 case GF_OMP_FOR_KIND_TASKLOOP:
1430 pp_string (buffer, "#pragma omp taskloop");
1431 break;
1432 case GF_OMP_FOR_KIND_OACC_LOOP:
1433 pp_string (buffer, "#pragma acc loop");
1434 break;
1435 case GF_OMP_FOR_KIND_SIMD:
1436 pp_string (buffer, "#pragma omp simd");
1437 break;
1438 case GF_OMP_FOR_KIND_GRID_LOOP:
1439 pp_string (buffer, "#pragma omp for grid_loop");
1440 break;
1441 default:
1442 gcc_unreachable ();
1444 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1445 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1447 if (i)
1448 spc += 2;
1449 newline_and_indent (buffer, spc);
1450 pp_string (buffer, "for (");
1451 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1452 flags, false);
1453 pp_string (buffer, " = ");
1454 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1455 flags, false);
1456 pp_string (buffer, "; ");
1458 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1459 flags, false);
1460 pp_space (buffer);
1461 switch (gimple_omp_for_cond (gs, i))
1463 case LT_EXPR:
1464 pp_less (buffer);
1465 break;
1466 case GT_EXPR:
1467 pp_greater (buffer);
1468 break;
1469 case LE_EXPR:
1470 pp_less_equal (buffer);
1471 break;
1472 case GE_EXPR:
1473 pp_greater_equal (buffer);
1474 break;
1475 case NE_EXPR:
1476 pp_string (buffer, "!=");
1477 break;
1478 default:
1479 gcc_unreachable ();
1481 pp_space (buffer);
1482 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1483 flags, false);
1484 pp_string (buffer, "; ");
1486 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1487 flags, false);
1488 pp_string (buffer, " = ");
1489 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1490 flags, false);
1491 pp_right_paren (buffer);
1494 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1496 newline_and_indent (buffer, spc + 2);
1497 pp_left_brace (buffer);
1498 pp_newline (buffer);
1499 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1500 newline_and_indent (buffer, spc + 2);
1501 pp_right_brace (buffer);
1506 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1508 static void
1509 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1510 int spc, dump_flags_t flags)
1512 if (flags & TDF_RAW)
1514 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1515 gimple_omp_continue_control_def (gs),
1516 gimple_omp_continue_control_use (gs));
1518 else
1520 pp_string (buffer, "#pragma omp continue (");
1521 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1522 spc, flags, false);
1523 pp_comma (buffer);
1524 pp_space (buffer);
1525 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1526 spc, flags, false);
1527 pp_right_paren (buffer);
1531 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1533 static void
1534 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1535 int spc, dump_flags_t flags)
1537 if (flags & TDF_RAW)
1539 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1540 gimple_omp_body (gs));
1541 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1542 dump_gimple_fmt (buffer, spc, flags, " >");
1544 else
1546 pp_string (buffer, "#pragma omp single");
1547 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1548 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1550 newline_and_indent (buffer, spc + 2);
1551 pp_left_brace (buffer);
1552 pp_newline (buffer);
1553 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1554 newline_and_indent (buffer, spc + 2);
1555 pp_right_brace (buffer);
1560 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1562 static void
1563 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1564 int spc, dump_flags_t flags)
1566 const char *kind;
1567 switch (gimple_omp_target_kind (gs))
1569 case GF_OMP_TARGET_KIND_REGION:
1570 kind = "";
1571 break;
1572 case GF_OMP_TARGET_KIND_DATA:
1573 kind = " data";
1574 break;
1575 case GF_OMP_TARGET_KIND_UPDATE:
1576 kind = " update";
1577 break;
1578 case GF_OMP_TARGET_KIND_ENTER_DATA:
1579 kind = " enter data";
1580 break;
1581 case GF_OMP_TARGET_KIND_EXIT_DATA:
1582 kind = " exit data";
1583 break;
1584 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1585 kind = " oacc_kernels";
1586 break;
1587 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1588 kind = " oacc_parallel";
1589 break;
1590 case GF_OMP_TARGET_KIND_OACC_DATA:
1591 kind = " oacc_data";
1592 break;
1593 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1594 kind = " oacc_update";
1595 break;
1596 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1597 kind = " oacc_enter_exit_data";
1598 break;
1599 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1600 kind = " oacc_declare";
1601 break;
1602 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1603 kind = " oacc_host_data";
1604 break;
1605 default:
1606 gcc_unreachable ();
1608 if (flags & TDF_RAW)
1610 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1611 kind, gimple_omp_body (gs));
1612 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1613 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1614 gimple_omp_target_child_fn (gs),
1615 gimple_omp_target_data_arg (gs));
1617 else
1619 pp_string (buffer, "#pragma omp target");
1620 pp_string (buffer, kind);
1621 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1622 if (gimple_omp_target_child_fn (gs))
1624 pp_string (buffer, " [child fn: ");
1625 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1626 spc, flags, false);
1627 pp_string (buffer, " (");
1628 if (gimple_omp_target_data_arg (gs))
1629 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1630 spc, flags, false);
1631 else
1632 pp_string (buffer, "???");
1633 pp_string (buffer, ")]");
1635 gimple_seq body = gimple_omp_body (gs);
1636 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1638 newline_and_indent (buffer, spc + 2);
1639 pp_left_brace (buffer);
1640 pp_newline (buffer);
1641 dump_gimple_seq (buffer, body, spc + 4, flags);
1642 newline_and_indent (buffer, spc + 2);
1643 pp_right_brace (buffer);
1645 else if (body)
1647 pp_newline (buffer);
1648 dump_gimple_seq (buffer, body, spc + 2, flags);
1653 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1655 static void
1656 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1657 dump_flags_t flags)
1659 if (flags & TDF_RAW)
1661 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1662 gimple_omp_body (gs));
1663 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1664 dump_gimple_fmt (buffer, spc, flags, " >");
1666 else
1668 pp_string (buffer, "#pragma omp teams");
1669 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1670 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1672 newline_and_indent (buffer, spc + 2);
1673 pp_character (buffer, '{');
1674 pp_newline (buffer);
1675 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1676 newline_and_indent (buffer, spc + 2);
1677 pp_character (buffer, '}');
1682 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1684 static void
1685 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1686 int spc, dump_flags_t flags)
1688 if (flags & TDF_RAW)
1690 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1691 gimple_omp_body (gs));
1692 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1693 dump_gimple_fmt (buffer, spc, flags, " >");
1695 else
1697 pp_string (buffer, "#pragma omp sections");
1698 if (gimple_omp_sections_control (gs))
1700 pp_string (buffer, " <");
1701 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1702 flags, false);
1703 pp_greater (buffer);
1705 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1706 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1708 newline_and_indent (buffer, spc + 2);
1709 pp_left_brace (buffer);
1710 pp_newline (buffer);
1711 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1712 newline_and_indent (buffer, spc + 2);
1713 pp_right_brace (buffer);
1718 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1719 pretty_printer BUFFER. */
1721 static void
1722 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc,
1723 dump_flags_t flags)
1725 if (flags & TDF_RAW)
1726 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1727 gimple_omp_body (gs));
1728 else
1730 switch (gimple_code (gs))
1732 case GIMPLE_OMP_MASTER:
1733 pp_string (buffer, "#pragma omp master");
1734 break;
1735 case GIMPLE_OMP_TASKGROUP:
1736 pp_string (buffer, "#pragma omp taskgroup");
1737 break;
1738 case GIMPLE_OMP_SECTION:
1739 pp_string (buffer, "#pragma omp section");
1740 break;
1741 case GIMPLE_OMP_GRID_BODY:
1742 pp_string (buffer, "#pragma omp gridified body");
1743 break;
1744 default:
1745 gcc_unreachable ();
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_CRITICAL tuple on the pretty_printer BUFFER. */
1761 static void
1762 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1763 int spc, dump_flags_t 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 critical");
1771 if (gimple_omp_critical_name (gs))
1773 pp_string (buffer, " (");
1774 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1775 flags, false);
1776 pp_right_paren (buffer);
1778 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1779 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1781 newline_and_indent (buffer, spc + 2);
1782 pp_left_brace (buffer);
1783 pp_newline (buffer);
1784 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1785 newline_and_indent (buffer, spc + 2);
1786 pp_right_brace (buffer);
1791 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1793 static void
1794 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1795 int spc, dump_flags_t flags)
1797 if (flags & TDF_RAW)
1798 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1799 gimple_omp_body (gs));
1800 else
1802 pp_string (buffer, "#pragma omp ordered");
1803 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1804 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1806 newline_and_indent (buffer, spc + 2);
1807 pp_left_brace (buffer);
1808 pp_newline (buffer);
1809 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1810 newline_and_indent (buffer, spc + 2);
1811 pp_right_brace (buffer);
1816 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1818 static void
1819 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc,
1820 dump_flags_t flags)
1822 if (flags & TDF_RAW)
1824 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1825 (int) gimple_omp_return_nowait_p (gs));
1826 if (gimple_omp_return_lhs (gs))
1827 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1828 gimple_omp_return_lhs (gs));
1829 else
1830 dump_gimple_fmt (buffer, spc, flags, ">");
1832 else
1834 pp_string (buffer, "#pragma omp return");
1835 if (gimple_omp_return_nowait_p (gs))
1836 pp_string (buffer, "(nowait)");
1837 if (gimple_omp_return_lhs (gs))
1839 pp_string (buffer, " (set ");
1840 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1841 spc, flags, false);
1842 pp_character (buffer, ')');
1847 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1849 static void
1850 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1851 int spc, dump_flags_t flags)
1853 unsigned subcode = gimple_transaction_subcode (gs);
1855 if (flags & TDF_RAW)
1857 dump_gimple_fmt (buffer, spc, flags,
1858 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1859 "<%+BODY <%S> >",
1860 gs, subcode, gimple_transaction_label_norm (gs),
1861 gimple_transaction_label_uninst (gs),
1862 gimple_transaction_label_over (gs),
1863 gimple_transaction_body (gs));
1865 else
1867 if (subcode & GTMA_IS_OUTER)
1868 pp_string (buffer, "__transaction_atomic [[outer]]");
1869 else if (subcode & GTMA_IS_RELAXED)
1870 pp_string (buffer, "__transaction_relaxed");
1871 else
1872 pp_string (buffer, "__transaction_atomic");
1873 subcode &= ~GTMA_DECLARATION_MASK;
1875 if (gimple_transaction_body (gs))
1877 newline_and_indent (buffer, spc + 2);
1878 pp_left_brace (buffer);
1879 pp_newline (buffer);
1880 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1881 spc + 4, flags);
1882 newline_and_indent (buffer, spc + 2);
1883 pp_right_brace (buffer);
1885 else
1887 pp_string (buffer, " //");
1888 if (gimple_transaction_label_norm (gs))
1890 pp_string (buffer, " NORM=");
1891 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1892 spc, flags, false);
1894 if (gimple_transaction_label_uninst (gs))
1896 pp_string (buffer, " UNINST=");
1897 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1898 spc, flags, false);
1900 if (gimple_transaction_label_over (gs))
1902 pp_string (buffer, " OVER=");
1903 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1904 spc, flags, false);
1906 if (subcode)
1908 pp_string (buffer, " SUBCODE=[ ");
1909 if (subcode & GTMA_HAVE_ABORT)
1911 pp_string (buffer, "GTMA_HAVE_ABORT ");
1912 subcode &= ~GTMA_HAVE_ABORT;
1914 if (subcode & GTMA_HAVE_LOAD)
1916 pp_string (buffer, "GTMA_HAVE_LOAD ");
1917 subcode &= ~GTMA_HAVE_LOAD;
1919 if (subcode & GTMA_HAVE_STORE)
1921 pp_string (buffer, "GTMA_HAVE_STORE ");
1922 subcode &= ~GTMA_HAVE_STORE;
1924 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1926 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1927 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1929 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1931 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1932 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1934 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1936 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1937 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1939 if (subcode)
1940 pp_printf (buffer, "0x%x ", subcode);
1941 pp_right_bracket (buffer);
1947 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1948 indent. FLAGS specifies details to show in the dump (see TDF_* in
1949 dumpfile.h). */
1951 static void
1952 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, dump_flags_t flags)
1954 unsigned int i, n, f, fields;
1956 if (flags & TDF_RAW)
1958 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1959 gimple_asm_string (gs));
1961 n = gimple_asm_noutputs (gs);
1962 if (n)
1964 newline_and_indent (buffer, spc + 2);
1965 pp_string (buffer, "OUTPUT: ");
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, ", ");
1975 n = gimple_asm_ninputs (gs);
1976 if (n)
1978 newline_and_indent (buffer, spc + 2);
1979 pp_string (buffer, "INPUT: ");
1980 for (i = 0; i < n; i++)
1982 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1983 spc, flags, false);
1984 if (i < n - 1)
1985 pp_string (buffer, ", ");
1989 n = gimple_asm_nclobbers (gs);
1990 if (n)
1992 newline_and_indent (buffer, spc + 2);
1993 pp_string (buffer, "CLOBBER: ");
1994 for (i = 0; i < n; i++)
1996 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1997 spc, flags, false);
1998 if (i < n - 1)
1999 pp_string (buffer, ", ");
2003 n = gimple_asm_nlabels (gs);
2004 if (n)
2006 newline_and_indent (buffer, spc + 2);
2007 pp_string (buffer, "LABEL: ");
2008 for (i = 0; i < n; i++)
2010 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2011 spc, flags, false);
2012 if (i < n - 1)
2013 pp_string (buffer, ", ");
2017 newline_and_indent (buffer, spc);
2018 pp_greater (buffer);
2020 else
2022 pp_string (buffer, "__asm__");
2023 if (gimple_asm_volatile_p (gs))
2024 pp_string (buffer, " __volatile__");
2025 if (gimple_asm_nlabels (gs))
2026 pp_string (buffer, " goto");
2027 pp_string (buffer, "(\"");
2028 pp_string (buffer, gimple_asm_string (gs));
2029 pp_string (buffer, "\"");
2031 if (gimple_asm_nlabels (gs))
2032 fields = 4;
2033 else if (gimple_asm_nclobbers (gs))
2034 fields = 3;
2035 else if (gimple_asm_ninputs (gs))
2036 fields = 2;
2037 else if (gimple_asm_noutputs (gs))
2038 fields = 1;
2039 else
2040 fields = 0;
2042 for (f = 0; f < fields; ++f)
2044 pp_string (buffer, " : ");
2046 switch (f)
2048 case 0:
2049 n = gimple_asm_noutputs (gs);
2050 for (i = 0; i < n; i++)
2052 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2053 spc, flags, false);
2054 if (i < n - 1)
2055 pp_string (buffer, ", ");
2057 break;
2059 case 1:
2060 n = gimple_asm_ninputs (gs);
2061 for (i = 0; i < n; i++)
2063 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2064 spc, flags, false);
2065 if (i < n - 1)
2066 pp_string (buffer, ", ");
2068 break;
2070 case 2:
2071 n = gimple_asm_nclobbers (gs);
2072 for (i = 0; i < n; i++)
2074 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2075 spc, flags, false);
2076 if (i < n - 1)
2077 pp_string (buffer, ", ");
2079 break;
2081 case 3:
2082 n = gimple_asm_nlabels (gs);
2083 for (i = 0; i < n; i++)
2085 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2086 spc, flags, false);
2087 if (i < n - 1)
2088 pp_string (buffer, ", ");
2090 break;
2092 default:
2093 gcc_unreachable ();
2097 pp_string (buffer, ");");
2101 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2102 SPC spaces of indent. */
2104 static void
2105 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2107 if (TREE_CODE (node) != SSA_NAME)
2108 return;
2110 if (POINTER_TYPE_P (TREE_TYPE (node))
2111 && SSA_NAME_PTR_INFO (node))
2113 unsigned int align, misalign;
2114 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2115 pp_string (buffer, "# PT = ");
2116 pp_points_to_solution (buffer, &pi->pt);
2117 newline_and_indent (buffer, spc);
2118 if (get_ptr_info_alignment (pi, &align, &misalign))
2120 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2121 newline_and_indent (buffer, spc);
2125 if (!POINTER_TYPE_P (TREE_TYPE (node))
2126 && SSA_NAME_RANGE_INFO (node))
2128 wide_int min, max, nonzero_bits;
2129 value_range_type range_type = get_range_info (node, &min, &max);
2131 if (range_type == VR_VARYING)
2132 pp_printf (buffer, "# RANGE VR_VARYING");
2133 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2135 pp_printf (buffer, "# RANGE ");
2136 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2137 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2138 pp_printf (buffer, ", ");
2139 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2140 pp_printf (buffer, "]");
2142 nonzero_bits = get_nonzero_bits (node);
2143 if (nonzero_bits != -1)
2145 pp_string (buffer, " NONZERO ");
2146 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2148 newline_and_indent (buffer, spc);
2152 /* As dump_ssaname_info, but dump to FILE. */
2154 void
2155 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2157 pretty_printer buffer;
2158 pp_needs_newline (&buffer) = true;
2159 buffer.buffer->stream = file;
2160 dump_ssaname_info (&buffer, node, spc);
2161 pp_flush (&buffer);
2164 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2165 The caller is responsible for calling pp_flush on BUFFER to finalize
2166 pretty printer. If COMMENT is true, print this after #. */
2168 static void
2169 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2170 dump_flags_t flags)
2172 size_t i;
2173 tree lhs = gimple_phi_result (phi);
2175 if (flags & TDF_ALIAS)
2176 dump_ssaname_info (buffer, lhs, spc);
2178 if (comment)
2179 pp_string (buffer, "# ");
2181 if (flags & TDF_RAW)
2182 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2183 gimple_phi_result (phi));
2184 else
2186 dump_generic_node (buffer, lhs, spc, flags, false);
2187 if (flags & TDF_GIMPLE)
2188 pp_string (buffer, " = __PHI (");
2189 else
2190 pp_string (buffer, " = PHI <");
2192 for (i = 0; i < gimple_phi_num_args (phi); i++)
2194 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2195 dump_location (buffer, gimple_phi_arg_location (phi, i));
2196 if (flags & TDF_GIMPLE)
2198 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2199 gimple *stmt = first_stmt (src);
2200 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2202 pp_string (buffer, "bb_");
2203 pp_decimal_int (buffer, src->index);
2205 else
2206 dump_generic_node (buffer, gimple_label_label (as_a <glabel *> (stmt)), 0, flags,
2207 false);
2208 pp_string (buffer, ": ");
2210 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2211 false);
2212 if (! (flags & TDF_GIMPLE))
2214 pp_left_paren (buffer);
2215 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2216 pp_right_paren (buffer);
2218 if (i < gimple_phi_num_args (phi) - 1)
2219 pp_string (buffer, ", ");
2221 if (flags & TDF_GIMPLE)
2222 pp_string (buffer, ");");
2223 else
2224 pp_greater (buffer);
2228 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2229 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2230 dumpfile.h). */
2232 static void
2233 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2234 int spc, dump_flags_t flags)
2236 if (flags & TDF_RAW)
2238 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2239 gimple_omp_body (gs));
2240 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2241 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2242 gimple_omp_parallel_child_fn (gs),
2243 gimple_omp_parallel_data_arg (gs));
2245 else
2247 gimple_seq body;
2248 pp_string (buffer, "#pragma omp parallel");
2249 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2250 if (gimple_omp_parallel_child_fn (gs))
2252 pp_string (buffer, " [child fn: ");
2253 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2254 spc, flags, false);
2255 pp_string (buffer, " (");
2256 if (gimple_omp_parallel_data_arg (gs))
2257 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2258 spc, flags, false);
2259 else
2260 pp_string (buffer, "???");
2261 pp_string (buffer, ")]");
2263 body = gimple_omp_body (gs);
2264 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2266 newline_and_indent (buffer, spc + 2);
2267 pp_left_brace (buffer);
2268 pp_newline (buffer);
2269 dump_gimple_seq (buffer, body, spc + 4, flags);
2270 newline_and_indent (buffer, spc + 2);
2271 pp_right_brace (buffer);
2273 else if (body)
2275 pp_newline (buffer);
2276 dump_gimple_seq (buffer, body, spc + 2, flags);
2282 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2283 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2284 dumpfile.h). */
2286 static void
2287 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2288 dump_flags_t flags)
2290 if (flags & TDF_RAW)
2292 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2293 gimple_omp_body (gs));
2294 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2295 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2296 gimple_omp_task_child_fn (gs),
2297 gimple_omp_task_data_arg (gs),
2298 gimple_omp_task_copy_fn (gs),
2299 gimple_omp_task_arg_size (gs),
2300 gimple_omp_task_arg_size (gs));
2302 else
2304 gimple_seq body;
2305 if (gimple_omp_task_taskloop_p (gs))
2306 pp_string (buffer, "#pragma omp taskloop");
2307 else
2308 pp_string (buffer, "#pragma omp task");
2309 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2310 if (gimple_omp_task_child_fn (gs))
2312 pp_string (buffer, " [child fn: ");
2313 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2314 spc, flags, false);
2315 pp_string (buffer, " (");
2316 if (gimple_omp_task_data_arg (gs))
2317 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2318 spc, flags, false);
2319 else
2320 pp_string (buffer, "???");
2321 pp_string (buffer, ")]");
2323 body = gimple_omp_body (gs);
2324 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2326 newline_and_indent (buffer, spc + 2);
2327 pp_left_brace (buffer);
2328 pp_newline (buffer);
2329 dump_gimple_seq (buffer, body, spc + 4, flags);
2330 newline_and_indent (buffer, spc + 2);
2331 pp_right_brace (buffer);
2333 else if (body)
2335 pp_newline (buffer);
2336 dump_gimple_seq (buffer, body, spc + 2, flags);
2342 /* Dump a GIMPLE_OMP_ATOMIC_LOAD 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_load (pretty_printer *buffer, gomp_atomic_load *gs,
2348 int spc, dump_flags_t flags)
2350 if (flags & TDF_RAW)
2352 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2353 gimple_omp_atomic_load_lhs (gs),
2354 gimple_omp_atomic_load_rhs (gs));
2356 else
2358 pp_string (buffer, "#pragma omp atomic_load");
2359 if (gimple_omp_atomic_seq_cst_p (gs))
2360 pp_string (buffer, " seq_cst");
2361 if (gimple_omp_atomic_need_value_p (gs))
2362 pp_string (buffer, " [needed]");
2363 newline_and_indent (buffer, spc + 2);
2364 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2365 spc, flags, false);
2366 pp_space (buffer);
2367 pp_equal (buffer);
2368 pp_space (buffer);
2369 pp_star (buffer);
2370 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2371 spc, flags, false);
2375 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2376 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2377 in dumpfile.h). */
2379 static void
2380 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2381 gomp_atomic_store *gs, int spc,
2382 dump_flags_t flags)
2384 if (flags & TDF_RAW)
2386 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2387 gimple_omp_atomic_store_val (gs));
2389 else
2391 pp_string (buffer, "#pragma omp atomic_store ");
2392 if (gimple_omp_atomic_seq_cst_p (gs))
2393 pp_string (buffer, "seq_cst ");
2394 if (gimple_omp_atomic_need_value_p (gs))
2395 pp_string (buffer, "[needed] ");
2396 pp_left_paren (buffer);
2397 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2398 spc, flags, false);
2399 pp_right_paren (buffer);
2404 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2405 FLAGS are as in pp_gimple_stmt_1. */
2407 static void
2408 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc,
2409 dump_flags_t flags)
2411 tree vdef = gimple_vdef (gs);
2412 tree vuse = gimple_vuse (gs);
2414 if (vdef != NULL_TREE)
2416 pp_string (buffer, "# ");
2417 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2418 pp_string (buffer, " = VDEF <");
2419 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2420 pp_greater (buffer);
2421 newline_and_indent (buffer, spc);
2423 else if (vuse != NULL_TREE)
2425 pp_string (buffer, "# VUSE <");
2426 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2427 pp_greater (buffer);
2428 newline_and_indent (buffer, spc);
2433 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2434 spaces of indent. FLAGS specifies details to show in the dump (see
2435 TDF_* in dumpfile.h). The caller is responsible for calling
2436 pp_flush on BUFFER to finalize the pretty printer. */
2438 void
2439 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc,
2440 dump_flags_t flags)
2442 if (!gs)
2443 return;
2445 if (flags & TDF_STMTADDR)
2446 pp_printf (buffer, "<&%p> ", (void *) gs);
2448 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2449 dump_location (buffer, gimple_location (gs));
2451 if (flags & TDF_EH)
2453 int lp_nr = lookup_stmt_eh_lp (gs);
2454 if (lp_nr > 0)
2455 pp_printf (buffer, "[LP %d] ", lp_nr);
2456 else if (lp_nr < 0)
2457 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2460 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2461 && gimple_has_mem_ops (gs))
2462 dump_gimple_mem_ops (buffer, gs, spc, flags);
2464 if (gimple_has_lhs (gs)
2465 && (flags & TDF_ALIAS))
2466 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2468 switch (gimple_code (gs))
2470 case GIMPLE_ASM:
2471 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2472 break;
2474 case GIMPLE_ASSIGN:
2475 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2476 break;
2478 case GIMPLE_BIND:
2479 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2480 break;
2482 case GIMPLE_CALL:
2483 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2484 break;
2486 case GIMPLE_COND:
2487 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2488 break;
2490 case GIMPLE_LABEL:
2491 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2492 break;
2494 case GIMPLE_GOTO:
2495 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2496 break;
2498 case GIMPLE_NOP:
2499 pp_string (buffer, "GIMPLE_NOP");
2500 break;
2502 case GIMPLE_RETURN:
2503 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2504 break;
2506 case GIMPLE_SWITCH:
2507 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2508 break;
2510 case GIMPLE_TRY:
2511 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2512 break;
2514 case GIMPLE_PHI:
2515 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2516 break;
2518 case GIMPLE_OMP_PARALLEL:
2519 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2520 flags);
2521 break;
2523 case GIMPLE_OMP_TASK:
2524 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2525 break;
2527 case GIMPLE_OMP_ATOMIC_LOAD:
2528 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2529 spc, flags);
2530 break;
2532 case GIMPLE_OMP_ATOMIC_STORE:
2533 dump_gimple_omp_atomic_store (buffer,
2534 as_a <gomp_atomic_store *> (gs),
2535 spc, flags);
2536 break;
2538 case GIMPLE_OMP_FOR:
2539 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2540 break;
2542 case GIMPLE_OMP_CONTINUE:
2543 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2544 flags);
2545 break;
2547 case GIMPLE_OMP_SINGLE:
2548 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2549 flags);
2550 break;
2552 case GIMPLE_OMP_TARGET:
2553 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2554 flags);
2555 break;
2557 case GIMPLE_OMP_TEAMS:
2558 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2559 flags);
2560 break;
2562 case GIMPLE_OMP_RETURN:
2563 dump_gimple_omp_return (buffer, gs, spc, flags);
2564 break;
2566 case GIMPLE_OMP_SECTIONS:
2567 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2568 spc, flags);
2569 break;
2571 case GIMPLE_OMP_SECTIONS_SWITCH:
2572 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2573 break;
2575 case GIMPLE_OMP_MASTER:
2576 case GIMPLE_OMP_TASKGROUP:
2577 case GIMPLE_OMP_SECTION:
2578 case GIMPLE_OMP_GRID_BODY:
2579 dump_gimple_omp_block (buffer, gs, spc, flags);
2580 break;
2582 case GIMPLE_OMP_ORDERED:
2583 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2584 flags);
2585 break;
2587 case GIMPLE_OMP_CRITICAL:
2588 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2589 flags);
2590 break;
2592 case GIMPLE_CATCH:
2593 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2594 break;
2596 case GIMPLE_EH_FILTER:
2597 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2598 break;
2600 case GIMPLE_EH_MUST_NOT_THROW:
2601 dump_gimple_eh_must_not_throw (buffer,
2602 as_a <geh_mnt *> (gs),
2603 spc, flags);
2604 break;
2606 case GIMPLE_EH_ELSE:
2607 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2608 break;
2610 case GIMPLE_RESX:
2611 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2612 break;
2614 case GIMPLE_EH_DISPATCH:
2615 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2616 flags);
2617 break;
2619 case GIMPLE_DEBUG:
2620 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2621 break;
2623 case GIMPLE_PREDICT:
2624 pp_string (buffer, "// predicted ");
2625 if (gimple_predict_outcome (gs))
2626 pp_string (buffer, "likely by ");
2627 else
2628 pp_string (buffer, "unlikely by ");
2629 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2630 pp_string (buffer, " predictor.");
2631 break;
2633 case GIMPLE_TRANSACTION:
2634 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2635 flags);
2636 break;
2638 default:
2639 GIMPLE_NIY;
2644 /* Dumps header of basic block BB to OUTF indented by INDENT
2645 spaces and details described by flags. */
2647 static void
2648 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
2649 dump_flags_t flags)
2651 if (flags & TDF_BLOCKS)
2653 if (flags & TDF_LINENO)
2655 gimple_stmt_iterator gsi;
2657 fputs (";; ", outf);
2659 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2660 if (!is_gimple_debug (gsi_stmt (gsi))
2661 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2663 fprintf (outf, "%*sstarting at line %d",
2664 indent, "", get_lineno (gsi_stmt (gsi)));
2665 break;
2667 if (bb->discriminator)
2668 fprintf (outf, ", discriminator %i", bb->discriminator);
2669 fputc ('\n', outf);
2672 else
2674 if (flags & TDF_GIMPLE)
2675 fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
2676 else
2677 fprintf (outf, "%*s<bb %d> %s:\n",
2678 indent, "", bb->index, dump_profile (bb->count));
2683 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2684 spaces. */
2686 static void
2687 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2688 basic_block bb ATTRIBUTE_UNUSED,
2689 int indent ATTRIBUTE_UNUSED,
2690 dump_flags_t flags ATTRIBUTE_UNUSED)
2692 /* There is currently no GIMPLE-specific basic block info to dump. */
2693 return;
2697 /* Dump PHI nodes of basic block BB to BUFFER with details described
2698 by FLAGS and indented by INDENT spaces. */
2700 static void
2701 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
2702 dump_flags_t flags)
2704 gphi_iterator i;
2706 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2708 gphi *phi = i.phi ();
2709 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2711 INDENT (indent);
2712 dump_gimple_phi (buffer, phi, indent,
2713 (flags & TDF_GIMPLE) ? false : true, flags);
2714 pp_newline (buffer);
2720 /* Dump jump to basic block BB that is represented implicitly in the cfg
2721 to BUFFER. */
2723 static void
2724 pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
2726 if (flags & TDF_GIMPLE)
2728 pp_string (buffer, "goto bb_");
2729 pp_decimal_int (buffer, e->dest->index);
2730 pp_semicolon (buffer);
2732 else
2734 pp_string (buffer, "goto <bb ");
2735 pp_decimal_int (buffer, e->dest->index);
2736 pp_greater (buffer);
2737 pp_semicolon (buffer);
2739 dump_edge_probability (buffer, e);
2744 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2745 by INDENT spaces, with details given by FLAGS. */
2747 static void
2748 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2749 dump_flags_t flags)
2751 edge e;
2752 gimple *stmt;
2754 stmt = last_stmt (bb);
2756 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2758 edge true_edge, false_edge;
2760 /* When we are emitting the code or changing CFG, it is possible that
2761 the edges are not yet created. When we are using debug_bb in such
2762 a situation, we do not want it to crash. */
2763 if (EDGE_COUNT (bb->succs) != 2)
2764 return;
2765 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2767 INDENT (indent + 2);
2768 pp_cfg_jump (buffer, true_edge, flags);
2769 newline_and_indent (buffer, indent);
2770 pp_string (buffer, "else");
2771 newline_and_indent (buffer, indent + 2);
2772 pp_cfg_jump (buffer, false_edge, flags);
2773 pp_newline (buffer);
2774 return;
2777 /* If there is a fallthru edge, we may need to add an artificial
2778 goto to the dump. */
2779 e = find_fallthru_edge (bb->succs);
2781 if (e && e->dest != bb->next_bb)
2783 INDENT (indent);
2785 if ((flags & TDF_LINENO)
2786 && e->goto_locus != UNKNOWN_LOCATION)
2787 dump_location (buffer, e->goto_locus);
2789 pp_cfg_jump (buffer, e, flags);
2790 pp_newline (buffer);
2795 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2796 indented by INDENT spaces. */
2798 static void
2799 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2800 dump_flags_t flags)
2802 gimple_stmt_iterator gsi;
2803 gimple *stmt;
2804 int label_indent = indent - 2;
2806 if (label_indent < 0)
2807 label_indent = 0;
2809 dump_phi_nodes (buffer, bb, indent, flags);
2811 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2813 int curr_indent;
2815 stmt = gsi_stmt (gsi);
2817 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2819 INDENT (curr_indent);
2820 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2821 pp_newline_and_flush (buffer);
2822 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2823 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2824 pp_buffer (buffer)->stream, stmt);
2827 dump_implicit_edges (buffer, bb, indent, flags);
2828 pp_flush (buffer);
2832 /* Dumps basic block BB to FILE with details described by FLAGS and
2833 indented by INDENT spaces. */
2835 void
2836 gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
2838 dump_gimple_bb_header (file, bb, indent, flags);
2839 if (bb->index >= NUM_FIXED_BLOCKS)
2841 pretty_printer buffer;
2842 pp_needs_newline (&buffer) = true;
2843 buffer.buffer->stream = file;
2844 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2846 dump_gimple_bb_footer (file, bb, indent, flags);
2849 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2850 no indentation, for use as a label of a DOT graph record-node.
2851 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2852 histogram dumping doesn't know about pretty-printers. */
2854 void
2855 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2857 pp_printf (pp, "<bb %d>:\n", bb->index);
2858 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2860 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2861 gsi_next (&gsi))
2863 gphi *phi = gsi.phi ();
2864 if (!virtual_operand_p (gimple_phi_result (phi))
2865 || (dump_flags & TDF_VOPS))
2867 pp_bar (pp);
2868 pp_write_text_to_stream (pp);
2869 pp_string (pp, "# ");
2870 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2871 pp_newline (pp);
2872 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2876 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2877 gsi_next (&gsi))
2879 gimple *stmt = gsi_stmt (gsi);
2880 pp_bar (pp);
2881 pp_write_text_to_stream (pp);
2882 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2883 pp_newline (pp);
2884 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2886 dump_implicit_edges (pp, bb, 0, dump_flags);
2887 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2891 /* Handle the %G format for TEXT. Same as %K in handle_K_format in
2892 tree-pretty-print.c but with a Gimple call statement as an argument. */
2894 void
2895 percent_G_format (text_info *text)
2897 gcall *stmt = va_arg (*text->args_ptr, gcall*);
2899 /* Build a call expression from the Gimple call statement and
2900 pass it to the K formatter that knows how to format it. */
2901 tree exp = build_vl_exp (CALL_EXPR, gimple_call_num_args (stmt) + 3);
2902 CALL_EXPR_FN (exp) = gimple_call_fn (stmt);
2903 TREE_TYPE (exp) = gimple_call_return_type (stmt);
2904 CALL_EXPR_STATIC_CHAIN (exp) = gimple_call_chain (stmt);
2905 SET_EXPR_LOCATION (exp, gimple_location (stmt));
2907 percent_K_format (text, exp);