OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / gimple-pretty-print.c
1 /* Pretty formatting of GIMPLE statements and expressions.
2    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3    Free Software Foundation, Inc.
4    Contributed by Aldy Hernandez <aldyh@redhat.com> and
5    Diego Novillo <dnovillo@google.com>
6
7 This file is part of GCC.
8
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
12 version.
13
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17 for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3.  If not see
21 <http://www.gnu.org/licenses/>.  */
22
23 #include "config.h"
24 #include "system.h"
25 #include "coretypes.h"
26 #include "tm.h"
27 #include "tree.h"
28 #include "diagnostic.h"
29 #include "tree-pretty-print.h"
30 #include "gimple-pretty-print.h"
31 #include "hashtab.h"
32 #include "tree-flow.h"
33 #include "tree-pass.h"
34 #include "gimple.h"
35 #include "value-prof.h"
36
37 #define INDENT(SPACE)                                                   \
38   do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
39
40 static pretty_printer buffer;
41 static bool initialized = false;
42
43 #define GIMPLE_NIY do_niy (buffer,gs)
44
45 /* Try to print on BUFFER a default message for the unrecognized
46    gimple statement GS.  */
47
48 static void
49 do_niy (pretty_printer *buffer, gimple gs)
50 {
51   pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
52              gimple_code_name[(int) gimple_code (gs)]);
53 }
54
55
56 /* Initialize the pretty printer on FILE if needed.  */
57
58 static void
59 maybe_init_pretty_print (FILE *file)
60 {
61   if (!initialized)
62     {
63       pp_construct (&buffer, NULL, 0);
64       pp_needs_newline (&buffer) = true;
65       initialized = true;
66     }
67
68   buffer.buffer->stream = file;
69 }
70
71
72 /* Emit a newline and SPC indentantion spaces to BUFFER.  */
73
74 static void
75 newline_and_indent (pretty_printer *buffer, int spc)
76 {
77   pp_newline (buffer);
78   INDENT (spc);
79 }
80
81
82 /* Print the GIMPLE statement GS on stderr.  */
83
84 DEBUG_FUNCTION void
85 debug_gimple_stmt (gimple gs)
86 {
87   print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
88   fprintf (stderr, "\n");
89 }
90
91
92 /* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
93    FLAGS as in dump_gimple_stmt.  */
94
95 void
96 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
97 {
98   maybe_init_pretty_print (file);
99   dump_gimple_stmt (&buffer, g, spc, flags);
100   pp_flush (&buffer);
101 }
102
103
104 /* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
105    FLAGS as in dump_gimple_stmt.  Print only the right-hand side
106    of the statement.  */
107
108 void
109 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
110 {
111   flags |= TDF_RHS_ONLY;
112   maybe_init_pretty_print (file);
113   dump_gimple_stmt (&buffer, g, spc, flags);
114 }
115
116
117 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion
118    spaces and FLAGS as in dump_gimple_stmt.  */
119
120 static void
121 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
122 {
123   gimple_stmt_iterator i;
124
125   for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
126     {
127       gimple gs = gsi_stmt (i);
128       INDENT (spc);
129       dump_gimple_stmt (buffer, gs, spc, flags);
130       if (!gsi_one_before_end_p (i))
131         pp_newline (buffer);
132     }
133 }
134
135
136 /* Dump GIMPLE sequence SEQ to FILE using SPC indentantion spaces and
137    FLAGS as in dump_gimple_stmt.  */
138
139 void
140 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
141 {
142   maybe_init_pretty_print (file);
143   dump_gimple_seq (&buffer, seq, spc, flags);
144   pp_flush (&buffer);
145 }
146
147
148 /* Print the GIMPLE sequence SEQ on stderr.  */
149
150 DEBUG_FUNCTION void
151 debug_gimple_seq (gimple_seq seq)
152 {
153   print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
154 }
155
156
157 /* A simple helper to pretty-print some of the gimple tuples in the printf
158    style. The format modifiers are preceeded by '%' and are:
159      'G' - outputs a string corresponding to the code of the given gimple,
160      'S' - outputs a gimple_seq with indent of spc + 2,
161      'T' - outputs the tree t,
162      'd' - outputs an int as a decimal,
163      's' - outputs a string,
164      'n' - outputs a newline,
165      '+' - increases indent by 2 then outputs a newline,
166      '-' - decreases indent by 2 then outputs a newline.   */
167
168 static void
169 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
170                  const char *fmt, ...)
171 {
172   va_list args;
173   const char *c;
174   const char *tmp;
175
176   va_start (args, fmt);
177   for (c = fmt; *c; c++)
178     {
179       if (*c == '%')
180         {
181           gimple_seq seq;
182           tree t;
183           gimple g;
184           switch (*++c)
185             {
186               case 'G':
187                 g = va_arg (args, gimple);
188                 tmp = gimple_code_name[gimple_code (g)];
189                 pp_string (buffer, tmp);
190                 break;
191
192               case 'S':
193                 seq = va_arg (args, gimple_seq);
194                 pp_newline (buffer);
195                 dump_gimple_seq (buffer, seq, spc + 2, flags);
196                 newline_and_indent (buffer, spc);
197                 break;
198
199               case 'T':
200                 t = va_arg (args, tree);
201                 if (t == NULL_TREE)
202                   pp_string (buffer, "NULL");
203                 else
204                   dump_generic_node (buffer, t, spc, flags, false);
205                 break;
206
207               case 'd':
208                 pp_decimal_int (buffer, va_arg (args, int));
209                 break;
210
211               case 's':
212                 pp_string (buffer, va_arg (args, char *));
213                 break;
214
215               case 'n':
216                 newline_and_indent (buffer, spc);
217                 break;
218
219               case '+':
220                 spc += 2;
221                 newline_and_indent (buffer, spc);
222                 break;
223
224               case '-':
225                 spc -= 2;
226                 newline_and_indent (buffer, spc);
227                 break;
228
229               default:
230                 gcc_unreachable ();
231             }
232         }
233       else
234         pp_character (buffer, *c);
235     }
236   va_end (args);
237 }
238
239
240 /* Helper for dump_gimple_assign.  Print the unary RHS of the
241    assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
242
243 static void
244 dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
245 {
246   enum tree_code rhs_code = gimple_assign_rhs_code (gs);
247   tree lhs = gimple_assign_lhs (gs);
248   tree rhs = gimple_assign_rhs1 (gs);
249
250   switch (rhs_code)
251     {
252     case VIEW_CONVERT_EXPR:
253     case ASSERT_EXPR:
254       dump_generic_node (buffer, rhs, spc, flags, false);
255       break;
256
257     case FIXED_CONVERT_EXPR:
258     case ADDR_SPACE_CONVERT_EXPR:
259     case FIX_TRUNC_EXPR:
260     case FLOAT_EXPR:
261     CASE_CONVERT:
262       pp_character (buffer, '(');
263       dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
264       pp_string (buffer, ") ");
265       if (op_prio (rhs) < op_code_prio (rhs_code))
266         {
267           pp_character (buffer, '(');
268           dump_generic_node (buffer, rhs, spc, flags, false);
269           pp_character (buffer, ')');
270         }
271       else
272         dump_generic_node (buffer, rhs, spc, flags, false);
273       break;
274
275     case PAREN_EXPR:
276       pp_string (buffer, "((");
277       dump_generic_node (buffer, rhs, spc, flags, false);
278       pp_string (buffer, "))");
279       break;
280
281     case ABS_EXPR:
282       pp_string (buffer, "ABS_EXPR <");
283       dump_generic_node (buffer, rhs, spc, flags, false);
284       pp_character (buffer, '>');
285       break;
286
287     default:
288       if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
289           || TREE_CODE_CLASS (rhs_code) == tcc_constant
290           || TREE_CODE_CLASS (rhs_code) == tcc_reference
291           || rhs_code == SSA_NAME
292           || rhs_code == ADDR_EXPR
293           || rhs_code == CONSTRUCTOR)
294         {
295           dump_generic_node (buffer, rhs, spc, flags, false);
296           break;
297         }
298       else if (rhs_code == BIT_NOT_EXPR)
299         pp_character (buffer, '~');
300       else if (rhs_code == TRUTH_NOT_EXPR)
301         pp_character (buffer, '!');
302       else if (rhs_code == NEGATE_EXPR)
303         pp_character (buffer, '-');
304       else
305         {
306           pp_character (buffer, '[');
307           pp_string (buffer, tree_code_name [rhs_code]);
308           pp_string (buffer, "] ");
309         }
310
311       if (op_prio (rhs) < op_code_prio (rhs_code))
312         {
313           pp_character (buffer, '(');
314           dump_generic_node (buffer, rhs, spc, flags, false);
315           pp_character (buffer, ')');
316         }
317       else
318         dump_generic_node (buffer, rhs, spc, flags, false);
319       break;
320     }
321 }
322
323
324 /* Helper for dump_gimple_assign.  Print the binary RHS of the
325    assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
326
327 static void
328 dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
329 {
330   const char *p;
331   enum tree_code code = gimple_assign_rhs_code (gs);
332   switch (code)
333     {
334     case COMPLEX_EXPR:
335     case MIN_EXPR:
336     case MAX_EXPR:
337     case VEC_WIDEN_MULT_HI_EXPR:
338     case VEC_WIDEN_MULT_LO_EXPR:
339     case VEC_PACK_TRUNC_EXPR:
340     case VEC_PACK_SAT_EXPR:
341     case VEC_PACK_FIX_TRUNC_EXPR:
342     case VEC_EXTRACT_EVEN_EXPR:
343     case VEC_EXTRACT_ODD_EXPR:
344     case VEC_INTERLEAVE_HIGH_EXPR:
345     case VEC_INTERLEAVE_LOW_EXPR:
346       for (p = tree_code_name [(int) code]; *p; p++)
347         pp_character (buffer, TOUPPER (*p));
348       pp_string (buffer, " <");
349       dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
350       pp_string (buffer, ", ");
351       dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
352       pp_character (buffer, '>');
353       break;
354
355     default:
356       if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
357         {
358           pp_character (buffer, '(');
359           dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
360                              false);
361           pp_character (buffer, ')');
362         }
363       else
364         dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
365       pp_space (buffer);
366       pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
367       pp_space (buffer);
368       if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
369         {
370           pp_character (buffer, '(');
371           dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
372                              false);
373           pp_character (buffer, ')');
374         }
375       else
376         dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
377     }
378 }
379
380 /* Helper for dump_gimple_assign.  Print the ternary RHS of the
381    assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
382
383 static void
384 dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
385 {
386   const char *p;
387   enum tree_code code = gimple_assign_rhs_code (gs);
388   switch (code)
389     {
390     case WIDEN_MULT_PLUS_EXPR:
391     case WIDEN_MULT_MINUS_EXPR:
392       for (p = tree_code_name [(int) code]; *p; p++)
393         pp_character (buffer, TOUPPER (*p));
394       pp_string (buffer, " <");
395       dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
396       pp_string (buffer, ", ");
397       dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
398       pp_string (buffer, ", ");
399       dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
400       pp_character (buffer, '>');
401       break;
402
403     default:
404       gcc_unreachable ();
405     }
406 }
407
408
409 /* Dump the gimple assignment GS.  BUFFER, SPC and FLAGS are as in
410    dump_gimple_stmt.  */
411
412 static void
413 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
414 {
415   if (flags & TDF_RAW)
416     {
417       tree last;
418       if (gimple_num_ops (gs) == 2)
419         last = NULL_TREE;
420       else if (gimple_num_ops (gs) == 3)
421         last = gimple_assign_rhs2 (gs);
422       else
423         gcc_unreachable ();
424
425       dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T>", gs,
426                        tree_code_name[gimple_assign_rhs_code (gs)],
427                        gimple_assign_lhs (gs), gimple_assign_rhs1 (gs), last);
428     }
429   else
430     {
431       if (!(flags & TDF_RHS_ONLY))
432         {
433           dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
434           pp_space (buffer);
435           pp_character (buffer, '=');
436
437           if (gimple_assign_nontemporal_move_p (gs))
438             pp_string (buffer, "{nt}");
439
440           if (gimple_has_volatile_ops (gs))
441             pp_string (buffer, "{v}");
442
443           pp_space (buffer);
444         }
445
446       if (gimple_num_ops (gs) == 2)
447         dump_unary_rhs (buffer, gs, spc, flags);
448       else if (gimple_num_ops (gs) == 3)
449         dump_binary_rhs (buffer, gs, spc, flags);
450       else if (gimple_num_ops (gs) == 4)
451         dump_ternary_rhs (buffer, gs, spc, flags);
452       else
453         gcc_unreachable ();
454       if (!(flags & TDF_RHS_ONLY))
455         pp_semicolon(buffer);
456     }
457 }
458
459
460 /* Dump the return statement GS.  BUFFER, SPC and FLAGS are as in
461    dump_gimple_stmt.  */
462
463 static void
464 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
465 {
466   tree t;
467
468   t = gimple_return_retval (gs);
469   if (flags & TDF_RAW)
470     dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
471   else
472     {
473       pp_string (buffer, "return");
474       if (t)
475         {
476           pp_space (buffer);
477           dump_generic_node (buffer, t, spc, flags, false);
478         }
479       pp_semicolon (buffer);
480     }
481 }
482
483
484 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
485    dump_gimple_call.  */
486
487 static void
488 dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags)
489 {
490   size_t i;
491
492   for (i = 0; i < gimple_call_num_args (gs); i++)
493     {
494       dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
495       if (i < gimple_call_num_args (gs) - 1)
496         pp_string (buffer, ", ");
497     }
498
499   if (gimple_call_va_arg_pack_p (gs))
500     {
501       if (gimple_call_num_args (gs) > 0)
502         {
503           pp_character (buffer, ',');
504           pp_space (buffer);
505         }
506
507       pp_string (buffer, "__builtin_va_arg_pack ()");
508     }
509 }
510
511 /* Dump the points-to solution *PT to BUFFER.  */
512
513 static void
514 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
515 {
516   if (pt->anything)
517     {
518       pp_string (buffer, "anything ");
519       return;
520     }
521   if (pt->nonlocal)
522     pp_string (buffer, "nonlocal ");
523   if (pt->escaped)
524     pp_string (buffer, "escaped ");
525   if (pt->ipa_escaped)
526     pp_string (buffer, "unit-escaped ");
527   if (pt->null)
528     pp_string (buffer, "null ");
529   if (pt->vars
530       && !bitmap_empty_p (pt->vars))
531     {
532       bitmap_iterator bi;
533       unsigned i;
534       pp_string (buffer, "{ ");
535       EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
536         {
537           struct tree_decl_minimal in;
538           tree var;
539           in.uid = i;
540           var = (tree) htab_find_with_hash (gimple_referenced_vars (cfun),
541                                             &in, i);
542           if (var)
543             {
544               dump_generic_node (buffer, var, 0, dump_flags, false);
545               if (DECL_PT_UID (var) != DECL_UID (var))
546                 {
547                   pp_string (buffer, "ptD.");
548                   pp_decimal_int (buffer, DECL_PT_UID (var));
549                 }
550             }
551           else
552             {
553               pp_string (buffer, "D.");
554               pp_decimal_int (buffer, i);
555             }
556           pp_character (buffer, ' ');
557         }
558       pp_character (buffer, '}');
559       if (pt->vars_contains_global)
560         pp_string (buffer, " (glob)");
561       if (pt->vars_contains_restrict)
562         pp_string (buffer, " (restr)");
563     }
564 }
565
566 /* Dump the call statement GS.  BUFFER, SPC and FLAGS are as in
567    dump_gimple_stmt.  */
568
569 static void
570 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
571 {
572   tree lhs = gimple_call_lhs (gs);
573
574   if (flags & TDF_ALIAS)
575     {
576       struct pt_solution *pt;
577       pt = gimple_call_use_set (gs);
578       if (!pt_solution_empty_p (pt))
579         {
580           pp_string (buffer, "# USE = ");
581           pp_points_to_solution (buffer, pt);
582           newline_and_indent (buffer, spc);
583         }
584       pt = gimple_call_clobber_set (gs);
585       if (!pt_solution_empty_p (pt))
586         {
587           pp_string (buffer, "# CLB = ");
588           pp_points_to_solution (buffer, pt);
589           newline_and_indent (buffer, spc);
590         }
591     }
592
593   if (flags & TDF_RAW)
594     {
595       dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T",
596                      gs, gimple_call_fn (gs), lhs);
597       if (gimple_call_num_args (gs) > 0)
598         {
599           pp_string (buffer, ", ");
600           dump_gimple_call_args (buffer, gs, flags);
601         }
602       pp_character (buffer, '>');
603     }
604   else
605     {
606       if (lhs && !(flags & TDF_RHS_ONLY))
607         {
608           dump_generic_node (buffer, lhs, spc, flags, false);
609           pp_string (buffer, " =");
610
611           if (gimple_has_volatile_ops (gs))
612             pp_string (buffer, "{v}");
613
614           pp_space (buffer);
615         }
616       print_call_name (buffer, gimple_call_fn (gs), flags);
617       pp_string (buffer, " (");
618       dump_gimple_call_args (buffer, gs, flags);
619       pp_character (buffer, ')');
620       if (!(flags & TDF_RHS_ONLY))
621         pp_semicolon (buffer);
622     }
623
624   if (gimple_call_chain (gs))
625     {
626       pp_string (buffer, " [static-chain: ");
627       dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
628       pp_character (buffer, ']');
629     }
630
631   if (gimple_call_return_slot_opt_p (gs))
632     pp_string (buffer, " [return slot optimization]");
633
634   if (gimple_call_tail_p (gs))
635     pp_string (buffer, " [tail call]");
636 }
637
638
639 /* Dump the switch statement GS.  BUFFER, SPC and FLAGS are as in
640    dump_gimple_stmt.  */
641
642 static void
643 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
644 {
645   unsigned int i;
646
647   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
648   if (flags & TDF_RAW)
649     dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
650                    gimple_switch_index (gs));
651   else
652     {
653       pp_string (buffer, "switch (");
654       dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
655       pp_string (buffer, ") <");
656     }
657
658   for (i = 0; i < gimple_switch_num_labels (gs); i++)
659     {
660       tree case_label = gimple_switch_label (gs, i);
661       if (case_label == NULL_TREE)
662         continue;
663
664       dump_generic_node (buffer, case_label, spc, flags, false);
665       pp_character (buffer, ' ');
666       dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
667       if (i < gimple_switch_num_labels (gs) - 1)
668         pp_string (buffer, ", ");
669     }
670   pp_character (buffer, '>');
671 }
672
673
674 /* Dump the gimple conditional GS.  BUFFER, SPC and FLAGS are as in
675    dump_gimple_stmt.  */
676
677 static void
678 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
679 {
680   if (flags & TDF_RAW)
681     dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
682                    tree_code_name [gimple_cond_code (gs)],
683                    gimple_cond_lhs (gs), gimple_cond_rhs (gs),
684                    gimple_cond_true_label (gs), gimple_cond_false_label (gs));
685   else
686     {
687       if (!(flags & TDF_RHS_ONLY))
688         pp_string (buffer, "if (");
689       dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
690       pp_space (buffer);
691       pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
692       pp_space (buffer);
693       dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
694       if (!(flags & TDF_RHS_ONLY))
695         {
696           pp_character (buffer, ')');
697
698           if (gimple_cond_true_label (gs))
699             {
700               pp_string (buffer, " goto ");
701               dump_generic_node (buffer, gimple_cond_true_label (gs),
702                                  spc, flags, false);
703               pp_semicolon (buffer);
704             }
705           if (gimple_cond_false_label (gs))
706             {
707               pp_string (buffer, " else goto ");
708               dump_generic_node (buffer, gimple_cond_false_label (gs),
709                                  spc, flags, false);
710               pp_semicolon (buffer);
711             }
712         }
713     }
714 }
715
716
717 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
718    spaces of indent.  FLAGS specifies details to show in the dump (see
719    TDF_* in tree-pass.h).  */
720
721 static void
722 dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
723 {
724   tree label = gimple_label_label (gs);
725   if (flags & TDF_RAW)
726       dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
727   else
728     {
729       dump_generic_node (buffer, label, spc, flags, false);
730       pp_character (buffer, ':');
731     }
732   if (DECL_NONLOCAL (label))
733     pp_string (buffer, " [non-local]");
734   if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
735     pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
736 }
737
738 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
739    spaces of indent.  FLAGS specifies details to show in the dump (see
740    TDF_* in tree-pass.h).  */
741
742 static void
743 dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
744 {
745   tree label = gimple_goto_dest (gs);
746   if (flags & TDF_RAW)
747     dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
748   else
749     dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
750 }
751
752
753 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
754    spaces of indent.  FLAGS specifies details to show in the dump (see
755    TDF_* in tree-pass.h).  */
756
757 static void
758 dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
759 {
760   if (flags & TDF_RAW)
761     dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
762   else
763     pp_character (buffer, '{');
764   if (!(flags & TDF_SLIM))
765     {
766       tree var;
767
768       for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
769         {
770           newline_and_indent (buffer, 2);
771           print_declaration (buffer, var, spc, flags);
772         }
773       if (gimple_bind_vars (gs))
774         pp_newline (buffer);
775     }
776   pp_newline (buffer);
777   dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
778   newline_and_indent (buffer, spc);
779   if (flags & TDF_RAW)
780     pp_character (buffer, '>');
781   else
782     pp_character (buffer, '}');
783 }
784
785
786 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
787    indent.  FLAGS specifies details to show in the dump (see TDF_* in
788    tree-pass.h).  */
789
790 static void
791 dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
792 {
793   if (flags & TDF_RAW)
794     {
795       const char *type;
796       if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
797         type = "GIMPLE_TRY_CATCH";
798       else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
799         type = "GIMPLE_TRY_FINALLY";
800       else
801         type = "UNKNOWN GIMPLE_TRY";
802       dump_gimple_fmt (buffer, spc, flags,
803                        "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
804                        gimple_try_eval (gs), gimple_try_cleanup (gs));
805     }
806   else
807     {
808       pp_string (buffer, "try");
809       newline_and_indent (buffer, spc + 2);
810       pp_character (buffer, '{');
811       pp_newline (buffer);
812
813       dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
814       newline_and_indent (buffer, spc + 2);
815       pp_character (buffer, '}');
816
817       if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
818         {
819           newline_and_indent (buffer, spc);
820           pp_string (buffer, "catch");
821           newline_and_indent (buffer, spc + 2);
822           pp_character (buffer, '{');
823         }
824       else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
825         {
826           newline_and_indent (buffer, spc);
827           pp_string (buffer, "finally");
828           newline_and_indent (buffer, spc + 2);
829           pp_character (buffer, '{');
830         }
831       else
832         pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
833
834       pp_newline (buffer);
835       dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
836       newline_and_indent (buffer, spc + 2);
837       pp_character (buffer, '}');
838     }
839 }
840
841
842 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
843    indent.  FLAGS specifies details to show in the dump (see TDF_* in
844    tree-pass.h).  */
845
846 static void
847 dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
848 {
849   if (flags & TDF_RAW)
850       dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
851                        gimple_catch_types (gs), gimple_catch_handler (gs));
852   else
853       dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
854                        gimple_catch_types (gs), gimple_catch_handler (gs));
855 }
856
857
858 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
859    indent.  FLAGS specifies details to show in the dump (see TDF_* in
860    tree-pass.h).  */
861
862 static void
863 dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
864 {
865   if (flags & TDF_RAW)
866     dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
867                      gimple_eh_filter_types (gs),
868                      gimple_eh_filter_failure (gs));
869   else
870     dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
871                      gimple_eh_filter_types (gs),
872                      gimple_eh_filter_failure (gs));
873 }
874
875
876 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple.  */
877
878 static void
879 dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
880                                int spc, int flags)
881 {
882   if (flags & TDF_RAW)
883     dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
884                      gimple_eh_must_not_throw_fndecl (gs));
885   else
886     dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
887                      gimple_eh_must_not_throw_fndecl (gs));
888 }
889
890
891 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
892    indent.  FLAGS specifies details to show in the dump (see TDF_* in
893    tree-pass.h).  */
894
895 static void
896 dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
897 {
898   if (flags & TDF_RAW)
899     dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
900                      gimple_resx_region (gs));
901   else
902     dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
903 }
904
905 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER.  */
906
907 static void
908 dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
909 {
910   if (flags & TDF_RAW)
911     dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
912                      gimple_eh_dispatch_region (gs));
913   else
914     dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
915                      gimple_eh_dispatch_region (gs));
916 }
917
918 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
919    of indent.  FLAGS specifies details to show in the dump (see TDF_*
920    in tree-pass.h).  */
921
922 static void
923 dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
924 {
925   switch (gs->gsbase.subcode)
926     {
927     case GIMPLE_DEBUG_BIND:
928       if (flags & TDF_RAW)
929         dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
930                          gimple_debug_bind_get_var (gs),
931                          gimple_debug_bind_get_value (gs));
932       else
933         dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
934                          gimple_debug_bind_get_var (gs),
935                          gimple_debug_bind_get_value (gs));
936       break;
937
938     default:
939       gcc_unreachable ();
940     }
941 }
942
943 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER.  */
944 static void
945 dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
946 {
947   size_t i;
948
949   if (flags & TDF_RAW)
950     {
951       dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
952                        gimple_omp_body (gs));
953       dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
954       dump_gimple_fmt (buffer, spc, flags, " >,");
955       for (i = 0; i < gimple_omp_for_collapse (gs); i++)
956         dump_gimple_fmt (buffer, spc, flags,
957                          "%+%T, %T, %T, %s, %T,%n",
958                          gimple_omp_for_index (gs, i),
959                          gimple_omp_for_initial (gs, i),
960                          gimple_omp_for_final (gs, i),
961                          tree_code_name[gimple_omp_for_cond (gs, i)],
962                          gimple_omp_for_incr (gs, i));
963       dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
964                        gimple_omp_for_pre_body (gs));
965     }
966   else
967     {
968       pp_string (buffer, "#pragma omp for");
969       dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
970       for (i = 0; i < gimple_omp_for_collapse (gs); i++)
971         {
972           if (i)
973             spc += 2;
974           newline_and_indent (buffer, spc);
975           pp_string (buffer, "for (");
976           dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
977                              flags, false);
978           pp_string (buffer, " = ");
979           dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
980                              flags, false);
981           pp_string (buffer, "; ");
982
983           dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
984                              flags, false);
985           pp_space (buffer);
986           switch (gimple_omp_for_cond (gs, i))
987             {
988             case LT_EXPR:
989               pp_character (buffer, '<');
990               break;
991             case GT_EXPR:
992               pp_character (buffer, '>');
993               break;
994             case LE_EXPR:
995               pp_string (buffer, "<=");
996               break;
997             case GE_EXPR:
998               pp_string (buffer, ">=");
999               break;
1000             default:
1001               gcc_unreachable ();
1002             }
1003           pp_space (buffer);
1004           dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1005                              flags, false);
1006           pp_string (buffer, "; ");
1007
1008           dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1009                              flags, false);
1010           pp_string (buffer, " = ");
1011           dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1012                              flags, false);
1013           pp_character (buffer, ')');
1014         }
1015
1016       if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1017         {
1018           newline_and_indent (buffer, spc + 2);
1019           pp_character (buffer, '{');
1020           pp_newline (buffer);
1021           dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1022           newline_and_indent (buffer, spc + 2);
1023           pp_character (buffer, '}');
1024         }
1025     }
1026 }
1027
1028 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER.  */
1029
1030 static void
1031 dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags)
1032 {
1033   if (flags & TDF_RAW)
1034     {
1035       dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1036                        gimple_omp_continue_control_def (gs),
1037                        gimple_omp_continue_control_use (gs));
1038     }
1039   else
1040     {
1041       pp_string (buffer, "#pragma omp continue (");
1042       dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1043                          spc, flags, false);
1044       pp_character (buffer, ',');
1045       pp_space (buffer);
1046       dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1047                          spc, flags, false);
1048       pp_character (buffer, ')');
1049     }
1050 }
1051
1052 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER.  */
1053
1054 static void
1055 dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, int flags)
1056 {
1057   if (flags & TDF_RAW)
1058     {
1059       dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1060                        gimple_omp_body (gs));
1061       dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1062       dump_gimple_fmt (buffer, spc, flags, " >");
1063     }
1064   else
1065     {
1066       pp_string (buffer, "#pragma omp single");
1067       dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1068       if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1069         {
1070           newline_and_indent (buffer, spc + 2);
1071           pp_character (buffer, '{');
1072           pp_newline (buffer);
1073           dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1074           newline_and_indent (buffer, spc + 2);
1075           pp_character (buffer, '}');
1076         }
1077     }
1078 }
1079
1080 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER.  */
1081
1082 static void
1083 dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
1084                           int flags)
1085 {
1086   if (flags & TDF_RAW)
1087     {
1088       dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1089                        gimple_omp_body (gs));
1090       dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1091       dump_gimple_fmt (buffer, spc, flags, " >");
1092     }
1093   else
1094     {
1095       pp_string (buffer, "#pragma omp sections");
1096       if (gimple_omp_sections_control (gs))
1097         {
1098           pp_string (buffer, " <");
1099           dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1100                              flags, false);
1101           pp_character (buffer, '>');
1102         }
1103       dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1104       if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1105         {
1106           newline_and_indent (buffer, spc + 2);
1107           pp_character (buffer, '{');
1108           pp_newline (buffer);
1109           dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1110           newline_and_indent (buffer, spc + 2);
1111           pp_character (buffer, '}');
1112         }
1113     }
1114 }
1115
1116 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the pretty_printer
1117    BUFFER.  */
1118
1119 static void
1120 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1121 {
1122   if (flags & TDF_RAW)
1123     dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1124                      gimple_omp_body (gs));
1125   else
1126     {
1127       switch (gimple_code (gs))
1128         {
1129         case GIMPLE_OMP_MASTER:
1130           pp_string (buffer, "#pragma omp master");
1131           break;
1132         case GIMPLE_OMP_ORDERED:
1133           pp_string (buffer, "#pragma omp ordered");
1134           break;
1135         case GIMPLE_OMP_SECTION:
1136           pp_string (buffer, "#pragma omp section");
1137           break;
1138         default:
1139           gcc_unreachable ();
1140         }
1141       if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1142         {
1143           newline_and_indent (buffer, spc + 2);
1144           pp_character (buffer, '{');
1145           pp_newline (buffer);
1146           dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1147           newline_and_indent (buffer, spc + 2);
1148           pp_character (buffer, '}');
1149         }
1150     }
1151 }
1152
1153 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER.  */
1154
1155 static void
1156 dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
1157                           int flags)
1158 {
1159   if (flags & TDF_RAW)
1160     dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1161                      gimple_omp_body (gs));
1162   else
1163     {
1164       pp_string (buffer, "#pragma omp critical");
1165       if (gimple_omp_critical_name (gs))
1166         {
1167           pp_string (buffer, " (");
1168           dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1169                              flags, false);
1170           pp_character (buffer, ')');
1171         }
1172       if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1173         {
1174           newline_and_indent (buffer, spc + 2);
1175           pp_character (buffer, '{');
1176           pp_newline (buffer);
1177           dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1178           newline_and_indent (buffer, spc + 2);
1179           pp_character (buffer, '}');
1180         }
1181     }
1182 }
1183
1184 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER.  */
1185
1186 static void
1187 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1188 {
1189   if (flags & TDF_RAW)
1190     {
1191       dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d>", gs,
1192                        (int) gimple_omp_return_nowait_p (gs));
1193     }
1194   else
1195     {
1196       pp_string (buffer, "#pragma omp return");
1197       if (gimple_omp_return_nowait_p (gs))
1198         pp_string (buffer, "(nowait)");
1199     }
1200 }
1201
1202 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1203    indent.  FLAGS specifies details to show in the dump (see TDF_* in
1204    tree-pass.h).  */
1205
1206 static void
1207 dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
1208 {
1209   unsigned int i, n, f, fields;
1210
1211   if (flags & TDF_RAW)
1212     {
1213       dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1214                        gimple_asm_string (gs));
1215
1216       n = gimple_asm_noutputs (gs);
1217       if (n)
1218         {
1219           newline_and_indent (buffer, spc + 2);
1220           pp_string (buffer, "OUTPUT: ");
1221           for (i = 0; i < n; i++)
1222             {
1223               dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1224                                  spc, flags, false);
1225               if (i < n - 1)
1226                 pp_string (buffer, ", ");
1227             }
1228         }
1229
1230       n = gimple_asm_ninputs (gs);
1231       if (n)
1232         {
1233           newline_and_indent (buffer, spc + 2);
1234           pp_string (buffer, "INPUT: ");
1235           for (i = 0; i < n; i++)
1236             {
1237               dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1238                                  spc, flags, false);
1239               if (i < n - 1)
1240                 pp_string (buffer, ", ");
1241             }
1242         }
1243
1244       n = gimple_asm_nclobbers (gs);
1245       if (n)
1246         {
1247           newline_and_indent (buffer, spc + 2);
1248           pp_string (buffer, "CLOBBER: ");
1249           for (i = 0; i < n; i++)
1250             {
1251               dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1252                                  spc, flags, false);
1253               if (i < n - 1)
1254                 pp_string (buffer, ", ");
1255             }
1256         }
1257
1258       n = gimple_asm_nlabels (gs);
1259       if (n)
1260         {
1261           newline_and_indent (buffer, spc + 2);
1262           pp_string (buffer, "LABEL: ");
1263           for (i = 0; i < n; i++)
1264             {
1265               dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1266                                  spc, flags, false);
1267               if (i < n - 1)
1268                 pp_string (buffer, ", ");
1269             }
1270         }
1271
1272       newline_and_indent (buffer, spc);
1273       pp_character (buffer, '>');
1274     }
1275   else
1276     {
1277       pp_string (buffer, "__asm__");
1278       if (gimple_asm_volatile_p (gs))
1279         pp_string (buffer, " __volatile__");
1280       if (gimple_asm_nlabels (gs))
1281         pp_string (buffer, " goto");
1282       pp_string (buffer, "(\"");
1283       pp_string (buffer, gimple_asm_string (gs));
1284       pp_string (buffer, "\"");
1285
1286       if (gimple_asm_nlabels (gs))
1287         fields = 4;
1288       else if (gimple_asm_nclobbers (gs))
1289         fields = 3;
1290       else if (gimple_asm_ninputs (gs))
1291         fields = 2;
1292       else if (gimple_asm_noutputs (gs))
1293         fields = 1;
1294       else
1295         fields = 0;
1296
1297       for (f = 0; f < fields; ++f)
1298         {
1299           pp_string (buffer, " : ");
1300
1301           switch (f)
1302             {
1303             case 0:
1304               n = gimple_asm_noutputs (gs);
1305               for (i = 0; i < n; i++)
1306                 {
1307                   dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1308                                      spc, flags, false);
1309                   if (i < n - 1)
1310                     pp_string (buffer, ", ");
1311                 }
1312               break;
1313
1314             case 1:
1315               n = gimple_asm_ninputs (gs);
1316               for (i = 0; i < n; i++)
1317                 {
1318                   dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1319                                      spc, flags, false);
1320                   if (i < n - 1)
1321                     pp_string (buffer, ", ");
1322                 }
1323               break;
1324
1325             case 2:
1326               n = gimple_asm_nclobbers (gs);
1327               for (i = 0; i < n; i++)
1328                 {
1329                   dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1330                                      spc, flags, false);
1331                   if (i < n - 1)
1332                     pp_string (buffer, ", ");
1333                 }
1334               break;
1335
1336             case 3:
1337               n = gimple_asm_nlabels (gs);
1338               for (i = 0; i < n; i++)
1339                 {
1340                   dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1341                                      spc, flags, false);
1342                   if (i < n - 1)
1343                     pp_string (buffer, ", ");
1344                 }
1345               break;
1346
1347             default:
1348               gcc_unreachable ();
1349             }
1350         }
1351
1352       pp_string (buffer, ");");
1353     }
1354 }
1355
1356
1357 /* Dump a PHI node PHI.  BUFFER, SPC and FLAGS are as in
1358    dump_gimple_stmt.  */
1359
1360 static void
1361 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags)
1362 {
1363   size_t i;
1364   tree lhs = gimple_phi_result (phi);
1365
1366   if (flags & TDF_ALIAS
1367       && POINTER_TYPE_P (TREE_TYPE (lhs))
1368       && SSA_NAME_PTR_INFO (lhs))
1369     {
1370       pp_string (buffer, "PT = ");
1371       pp_points_to_solution (buffer, &SSA_NAME_PTR_INFO (lhs)->pt);
1372       newline_and_indent (buffer, spc);
1373       pp_string (buffer, "# ");
1374     }
1375
1376   if (flags & TDF_RAW)
1377       dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1378                        gimple_phi_result (phi));
1379   else
1380     {
1381       dump_generic_node (buffer, lhs, spc, flags, false);
1382       pp_string (buffer, " = PHI <");
1383     }
1384   for (i = 0; i < gimple_phi_num_args (phi); i++)
1385     {
1386       if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1387         {
1388           expanded_location xloc;
1389
1390           xloc = expand_location (gimple_phi_arg_location (phi, i));
1391           pp_character (buffer, '[');
1392           if (xloc.file)
1393             {
1394               pp_string (buffer, xloc.file);
1395               pp_string (buffer, " : ");
1396             }
1397           pp_decimal_int (buffer, xloc.line);
1398           pp_string (buffer, ":");
1399           pp_decimal_int (buffer, xloc.column);
1400           pp_string (buffer, "] ");
1401         }
1402       dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1403                          false);
1404       pp_character (buffer, '(');
1405       pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1406       pp_character (buffer, ')');
1407       if (i < gimple_phi_num_args (phi) - 1)
1408         pp_string (buffer, ", ");
1409     }
1410   pp_character (buffer, '>');
1411 }
1412
1413
1414 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1415    of indent.  FLAGS specifies details to show in the dump (see TDF_* in
1416    tree-pass.h).  */
1417
1418 static void
1419 dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1420                           int flags)
1421 {
1422   if (flags & TDF_RAW)
1423     {
1424       dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1425                        gimple_omp_body (gs));
1426       dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1427       dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1428                        gimple_omp_parallel_child_fn (gs),
1429                        gimple_omp_parallel_data_arg (gs));
1430     }
1431   else
1432     {
1433       gimple_seq body;
1434       pp_string (buffer, "#pragma omp parallel");
1435       dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1436       if (gimple_omp_parallel_child_fn (gs))
1437         {
1438           pp_string (buffer, " [child fn: ");
1439           dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1440                              spc, flags, false);
1441           pp_string (buffer, " (");
1442           if (gimple_omp_parallel_data_arg (gs))
1443             dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1444                                spc, flags, false);
1445           else
1446             pp_string (buffer, "???");
1447           pp_string (buffer, ")]");
1448         }
1449       body = gimple_omp_body (gs);
1450       if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1451         {
1452           newline_and_indent (buffer, spc + 2);
1453           pp_character (buffer, '{');
1454           pp_newline (buffer);
1455           dump_gimple_seq (buffer, body, spc + 4, flags);
1456           newline_and_indent (buffer, spc + 2);
1457           pp_character (buffer, '}');
1458         }
1459       else if (body)
1460         {
1461           pp_newline (buffer);
1462           dump_gimple_seq (buffer, body, spc + 2, flags);
1463         }
1464     }
1465 }
1466
1467
1468 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1469    of indent.  FLAGS specifies details to show in the dump (see TDF_* in
1470    tree-pass.h).  */
1471
1472 static void
1473 dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
1474                       int flags)
1475 {
1476   if (flags & TDF_RAW)
1477     {
1478       dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1479                        gimple_omp_body (gs));
1480       dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1481       dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1482                        gimple_omp_task_child_fn (gs),
1483                        gimple_omp_task_data_arg (gs),
1484                        gimple_omp_task_copy_fn (gs),
1485                        gimple_omp_task_arg_size (gs),
1486                        gimple_omp_task_arg_size (gs));
1487     }
1488   else
1489     {
1490       gimple_seq body;
1491       pp_string (buffer, "#pragma omp task");
1492       dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1493       if (gimple_omp_task_child_fn (gs))
1494         {
1495           pp_string (buffer, " [child fn: ");
1496           dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1497                              spc, flags, false);
1498           pp_string (buffer, " (");
1499           if (gimple_omp_task_data_arg (gs))
1500             dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1501                                spc, flags, false);
1502           else
1503             pp_string (buffer, "???");
1504           pp_string (buffer, ")]");
1505         }
1506       body = gimple_omp_body (gs);
1507       if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1508         {
1509           newline_and_indent (buffer, spc + 2);
1510           pp_character (buffer, '{');
1511           pp_newline (buffer);
1512           dump_gimple_seq (buffer, body, spc + 4, flags);
1513           newline_and_indent (buffer, spc + 2);
1514           pp_character (buffer, '}');
1515         }
1516       else if (body)
1517         {
1518           pp_newline (buffer);
1519           dump_gimple_seq (buffer, body, spc + 2, flags);
1520         }
1521     }
1522 }
1523
1524
1525 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1526    spaces of indent.  FLAGS specifies details to show in the dump (see TDF_*
1527    in tree-pass.h).  */
1528
1529 static void
1530 dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
1531                              int flags)
1532 {
1533   if (flags & TDF_RAW)
1534     {
1535       dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1536                        gimple_omp_atomic_load_lhs (gs),
1537                        gimple_omp_atomic_load_rhs (gs));
1538     }
1539   else
1540     {
1541       pp_string (buffer, "#pragma omp atomic_load");
1542       newline_and_indent (buffer, spc + 2);
1543       dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
1544                          spc, flags, false);
1545       pp_space (buffer);
1546       pp_character (buffer, '=');
1547       pp_space (buffer);
1548       pp_character (buffer, '*');
1549       dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
1550                          spc, flags, false);
1551     }
1552 }
1553
1554 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1555    spaces of indent.  FLAGS specifies details to show in the dump (see TDF_*
1556    in tree-pass.h).  */
1557
1558 static void
1559 dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
1560                              int flags)
1561 {
1562   if (flags & TDF_RAW)
1563     {
1564       dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1565                        gimple_omp_atomic_store_val (gs));
1566     }
1567   else
1568     {
1569       pp_string (buffer, "#pragma omp atomic_store (");
1570       dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
1571                          spc, flags, false);
1572       pp_character (buffer, ')');
1573     }
1574 }
1575
1576
1577 /* Dump all the memory operands for statement GS.  BUFFER, SPC and
1578    FLAGS are as in dump_gimple_stmt.  */
1579
1580 static void
1581 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
1582 {
1583   tree vdef = gimple_vdef (gs);
1584   tree vuse = gimple_vuse (gs);
1585
1586   if (!ssa_operands_active () || !gimple_references_memory_p (gs))
1587     return;
1588
1589   if (vdef != NULL_TREE)
1590     {
1591       pp_string (buffer, "# ");
1592       dump_generic_node (buffer, vdef, spc + 2, flags, false);
1593       pp_string (buffer, " = VDEF <");
1594       dump_generic_node (buffer, vuse, spc + 2, flags, false);
1595       pp_character (buffer, '>');
1596       newline_and_indent (buffer, spc);
1597     }
1598   else if (vuse != NULL_TREE)
1599     {
1600       pp_string (buffer, "# VUSE <");
1601       dump_generic_node (buffer, vuse, spc + 2, flags, false);
1602       pp_character (buffer, '>');
1603       newline_and_indent (buffer, spc);
1604     }
1605 }
1606
1607
1608 /* Dump the gimple statement GS on the pretty printer BUFFER, SPC
1609    spaces of indent.  FLAGS specifies details to show in the dump (see
1610    TDF_* in tree-pass.h).  */
1611
1612 void
1613 dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
1614 {
1615   if (!gs)
1616     return;
1617
1618   if (flags & TDF_STMTADDR)
1619     pp_printf (buffer, "<&%p> ", (void *) gs);
1620
1621   if ((flags & TDF_LINENO) && gimple_has_location (gs))
1622     {
1623       expanded_location xloc = expand_location (gimple_location (gs));
1624       pp_character (buffer, '[');
1625       if (xloc.file)
1626         {
1627           pp_string (buffer, xloc.file);
1628           pp_string (buffer, " : ");
1629         }
1630       pp_decimal_int (buffer, xloc.line);
1631       pp_string (buffer, ":");
1632       pp_decimal_int (buffer, xloc.column);
1633       pp_string (buffer, "] ");
1634     }
1635
1636   if (flags & TDF_EH)
1637     {
1638       int lp_nr = lookup_stmt_eh_lp (gs);
1639       if (lp_nr > 0)
1640         pp_printf (buffer, "[LP %d] ", lp_nr);
1641       else if (lp_nr < 0)
1642         pp_printf (buffer, "[MNT %d] ", -lp_nr);
1643     }
1644
1645   if ((flags & (TDF_VOPS|TDF_MEMSYMS))
1646       && gimple_has_mem_ops (gs))
1647     dump_gimple_mem_ops (buffer, gs, spc, flags);
1648
1649   if ((flags & TDF_ALIAS)
1650       && gimple_has_lhs (gs))
1651     {
1652       tree lhs = gimple_get_lhs (gs);
1653       if (TREE_CODE (lhs) == SSA_NAME
1654           && POINTER_TYPE_P (TREE_TYPE (lhs))
1655           && SSA_NAME_PTR_INFO (lhs))
1656         {
1657           pp_string (buffer, "# PT = ");
1658           pp_points_to_solution (buffer, &SSA_NAME_PTR_INFO (lhs)->pt);
1659           newline_and_indent (buffer, spc);
1660         }
1661     }
1662
1663   switch (gimple_code (gs))
1664     {
1665     case GIMPLE_ASM:
1666       dump_gimple_asm (buffer, gs, spc, flags);
1667       break;
1668
1669     case GIMPLE_ASSIGN:
1670       dump_gimple_assign (buffer, gs, spc, flags);
1671       break;
1672
1673     case GIMPLE_BIND:
1674       dump_gimple_bind (buffer, gs, spc, flags);
1675       break;
1676
1677     case GIMPLE_CALL:
1678       dump_gimple_call (buffer, gs, spc, flags);
1679       break;
1680
1681     case GIMPLE_COND:
1682       dump_gimple_cond (buffer, gs, spc, flags);
1683       break;
1684
1685     case GIMPLE_LABEL:
1686       dump_gimple_label (buffer, gs, spc, flags);
1687       break;
1688
1689     case GIMPLE_GOTO:
1690       dump_gimple_goto (buffer, gs, spc, flags);
1691       break;
1692
1693     case GIMPLE_NOP:
1694       pp_string (buffer, "GIMPLE_NOP");
1695       break;
1696
1697     case GIMPLE_RETURN:
1698       dump_gimple_return (buffer, gs, spc, flags);
1699       break;
1700
1701     case GIMPLE_SWITCH:
1702       dump_gimple_switch (buffer, gs, spc, flags);
1703       break;
1704
1705     case GIMPLE_TRY:
1706       dump_gimple_try (buffer, gs, spc, flags);
1707       break;
1708
1709     case GIMPLE_PHI:
1710       dump_gimple_phi (buffer, gs, spc, flags);
1711       break;
1712
1713     case GIMPLE_OMP_PARALLEL:
1714       dump_gimple_omp_parallel (buffer, gs, spc, flags);
1715       break;
1716
1717     case GIMPLE_OMP_TASK:
1718       dump_gimple_omp_task (buffer, gs, spc, flags);
1719       break;
1720
1721     case GIMPLE_OMP_ATOMIC_LOAD:
1722       dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
1723
1724       break;
1725
1726     case GIMPLE_OMP_ATOMIC_STORE:
1727       dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
1728       break;
1729
1730     case GIMPLE_OMP_FOR:
1731       dump_gimple_omp_for (buffer, gs, spc, flags);
1732       break;
1733
1734     case GIMPLE_OMP_CONTINUE:
1735       dump_gimple_omp_continue (buffer, gs, spc, flags);
1736       break;
1737
1738     case GIMPLE_OMP_SINGLE:
1739       dump_gimple_omp_single (buffer, gs, spc, flags);
1740       break;
1741
1742     case GIMPLE_OMP_RETURN:
1743       dump_gimple_omp_return (buffer, gs, spc, flags);
1744       break;
1745
1746     case GIMPLE_OMP_SECTIONS:
1747       dump_gimple_omp_sections (buffer, gs, spc, flags);
1748       break;
1749
1750     case GIMPLE_OMP_SECTIONS_SWITCH:
1751       pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
1752       break;
1753
1754     case GIMPLE_OMP_MASTER:
1755     case GIMPLE_OMP_ORDERED:
1756     case GIMPLE_OMP_SECTION:
1757       dump_gimple_omp_block (buffer, gs, spc, flags);
1758       break;
1759
1760     case GIMPLE_OMP_CRITICAL:
1761       dump_gimple_omp_critical (buffer, gs, spc, flags);
1762       break;
1763
1764     case GIMPLE_CATCH:
1765       dump_gimple_catch (buffer, gs, spc, flags);
1766       break;
1767
1768     case GIMPLE_EH_FILTER:
1769       dump_gimple_eh_filter (buffer, gs, spc, flags);
1770       break;
1771
1772     case GIMPLE_EH_MUST_NOT_THROW:
1773       dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
1774       break;
1775
1776     case GIMPLE_RESX:
1777       dump_gimple_resx (buffer, gs, spc, flags);
1778       break;
1779
1780     case GIMPLE_EH_DISPATCH:
1781       dump_gimple_eh_dispatch (buffer, gs, spc, flags);
1782       break;
1783
1784     case GIMPLE_DEBUG:
1785       dump_gimple_debug (buffer, gs, spc, flags);
1786       break;
1787
1788     case GIMPLE_PREDICT:
1789       pp_string (buffer, "// predicted ");
1790       if (gimple_predict_outcome (gs))
1791         pp_string (buffer, "likely by ");
1792       else
1793         pp_string (buffer, "unlikely by ");
1794       pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
1795       pp_string (buffer, " predictor.");
1796       break;
1797
1798     default:
1799       GIMPLE_NIY;
1800     }
1801
1802   /* If we're building a diagnostic, the formatted text will be
1803      written into BUFFER's stream by the caller; otherwise, write it
1804      now.  */
1805   if (!(flags & TDF_DIAGNOSTIC))
1806     pp_write_text_to_stream (buffer);
1807 }
1808
1809
1810 /* Dumps header of basic block BB to buffer BUFFER indented by INDENT
1811    spaces and details described by flags.  */
1812
1813 static void
1814 dump_bb_header (pretty_printer *buffer, basic_block bb, int indent, int flags)
1815 {
1816   edge e;
1817   gimple stmt;
1818   edge_iterator ei;
1819
1820   if (flags & TDF_BLOCKS)
1821     {
1822       INDENT (indent);
1823       pp_string (buffer, "# BLOCK ");
1824       pp_decimal_int (buffer, bb->index);
1825       if (bb->frequency)
1826         {
1827           pp_string (buffer, " freq:");
1828           pp_decimal_int (buffer, bb->frequency);
1829         }
1830       if (bb->count)
1831         {
1832           pp_string (buffer, " count:");
1833           pp_widest_integer (buffer, bb->count);
1834         }
1835
1836       if (flags & TDF_LINENO)
1837         {
1838           gimple_stmt_iterator gsi;
1839
1840           for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
1841             if (!is_gimple_debug (gsi_stmt (gsi))
1842                 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
1843               {
1844                 pp_string (buffer, ", starting at line ");
1845                 pp_decimal_int (buffer, get_lineno (gsi_stmt (gsi)));
1846                 break;
1847               }
1848
1849           if (bb->discriminator)
1850             {
1851               pp_string (buffer, ", discriminator ");
1852               pp_decimal_int (buffer, bb->discriminator);
1853             }
1854         }
1855       newline_and_indent (buffer, indent);
1856
1857       pp_string (buffer, "# PRED:");
1858       pp_write_text_to_stream (buffer);
1859       FOR_EACH_EDGE (e, ei, bb->preds)
1860         if (flags & TDF_SLIM)
1861           {
1862             pp_character (buffer, ' ');
1863             if (e->src == ENTRY_BLOCK_PTR)
1864               pp_string (buffer, "ENTRY");
1865             else
1866               pp_decimal_int (buffer, e->src->index);
1867           }
1868         else
1869           dump_edge_info (buffer->buffer->stream, e, 0);
1870       pp_newline (buffer);
1871     }
1872   else
1873     {
1874       stmt = first_stmt (bb);
1875       if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
1876         {
1877           INDENT (indent - 2);
1878           pp_string (buffer, "<bb ");
1879           pp_decimal_int (buffer, bb->index);
1880           pp_string (buffer, ">:");
1881           pp_newline (buffer);
1882         }
1883     }
1884   pp_write_text_to_stream (buffer);
1885   check_bb_profile (bb, buffer->buffer->stream);
1886 }
1887
1888
1889 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
1890    spaces.  */
1891
1892 static void
1893 dump_bb_end (pretty_printer *buffer, basic_block bb, int indent, int flags)
1894 {
1895   edge e;
1896   edge_iterator ei;
1897
1898   INDENT (indent);
1899   pp_string (buffer, "# SUCC:");
1900   pp_write_text_to_stream (buffer);
1901   FOR_EACH_EDGE (e, ei, bb->succs)
1902     if (flags & TDF_SLIM)
1903       {
1904         pp_character (buffer, ' ');
1905         if (e->dest == EXIT_BLOCK_PTR)
1906           pp_string (buffer, "EXIT");
1907         else
1908           pp_decimal_int (buffer, e->dest->index);
1909       }
1910     else
1911       dump_edge_info (buffer->buffer->stream, e, 1);
1912   pp_newline (buffer);
1913 }
1914
1915
1916 /* Dump PHI nodes of basic block BB to BUFFER with details described
1917    by FLAGS and indented by INDENT spaces.  */
1918
1919 static void
1920 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
1921 {
1922   gimple_stmt_iterator i;
1923
1924   for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
1925     {
1926       gimple phi = gsi_stmt (i);
1927       if (is_gimple_reg (gimple_phi_result (phi)) || (flags & TDF_VOPS))
1928         {
1929           INDENT (indent);
1930           pp_string (buffer, "# ");
1931           dump_gimple_phi (buffer, phi, indent, flags);
1932           pp_newline (buffer);
1933         }
1934     }
1935 }
1936
1937
1938 /* Dump jump to basic block BB that is represented implicitly in the cfg
1939    to BUFFER.  */
1940
1941 static void
1942 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
1943 {
1944   gimple stmt;
1945
1946   stmt = first_stmt (bb);
1947
1948   pp_string (buffer, "goto <bb ");
1949   pp_decimal_int (buffer, bb->index);
1950   pp_character (buffer, '>');
1951   if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
1952     {
1953       pp_string (buffer, " (");
1954       dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
1955       pp_character (buffer, ')');
1956       pp_semicolon (buffer);
1957     }
1958   else
1959     pp_semicolon (buffer);
1960 }
1961
1962
1963 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
1964    by INDENT spaces, with details given by FLAGS.  */
1965
1966 static void
1967 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
1968                      int flags)
1969 {
1970   edge e;
1971   edge_iterator ei;
1972   gimple stmt;
1973
1974   stmt = last_stmt (bb);
1975
1976   if (stmt && gimple_code (stmt) == GIMPLE_COND)
1977     {
1978       edge true_edge, false_edge;
1979
1980       /* When we are emitting the code or changing CFG, it is possible that
1981          the edges are not yet created.  When we are using debug_bb in such
1982          a situation, we do not want it to crash.  */
1983       if (EDGE_COUNT (bb->succs) != 2)
1984         return;
1985       extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
1986
1987       INDENT (indent + 2);
1988       pp_cfg_jump (buffer, true_edge->dest);
1989       newline_and_indent (buffer, indent);
1990       pp_string (buffer, "else");
1991       newline_and_indent (buffer, indent + 2);
1992       pp_cfg_jump (buffer, false_edge->dest);
1993       pp_newline (buffer);
1994       return;
1995     }
1996
1997   /* If there is a fallthru edge, we may need to add an artificial
1998      goto to the dump.  */
1999   FOR_EACH_EDGE (e, ei, bb->succs)
2000     if (e->flags & EDGE_FALLTHRU)
2001       break;
2002
2003   if (e && e->dest != bb->next_bb)
2004     {
2005       INDENT (indent);
2006
2007       if ((flags & TDF_LINENO)
2008           && e->goto_locus != UNKNOWN_LOCATION
2009           )
2010         {
2011           expanded_location goto_xloc;
2012           goto_xloc = expand_location (e->goto_locus);
2013           pp_character (buffer, '[');
2014           if (goto_xloc.file)
2015             {
2016               pp_string (buffer, goto_xloc.file);
2017               pp_string (buffer, " : ");
2018             }
2019           pp_decimal_int (buffer, goto_xloc.line);
2020           pp_string (buffer, " : ");
2021           pp_decimal_int (buffer, goto_xloc.column);
2022           pp_string (buffer, "] ");
2023         }
2024
2025       pp_cfg_jump (buffer, e->dest);
2026       pp_newline (buffer);
2027     }
2028 }
2029
2030
2031 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2032    indented by INDENT spaces.  */
2033
2034 static void
2035 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2036                      int flags)
2037 {
2038   gimple_stmt_iterator gsi;
2039   gimple stmt;
2040   int label_indent = indent - 2;
2041
2042   if (label_indent < 0)
2043     label_indent = 0;
2044
2045   dump_bb_header (buffer, bb, indent, flags);
2046   dump_phi_nodes (buffer, bb, indent, flags);
2047
2048   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2049     {
2050       int curr_indent;
2051
2052       stmt = gsi_stmt (gsi);
2053
2054       curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2055
2056       INDENT (curr_indent);
2057       dump_gimple_stmt (buffer, stmt, curr_indent, flags);
2058       pp_newline (buffer);
2059       dump_histograms_for_stmt (cfun, buffer->buffer->stream, stmt);
2060     }
2061
2062   dump_implicit_edges (buffer, bb, indent, flags);
2063
2064   if (flags & TDF_BLOCKS)
2065     dump_bb_end (buffer, bb, indent, flags);
2066 }
2067
2068
2069 /* Dumps basic block BB to FILE with details described by FLAGS and
2070    indented by INDENT spaces.  */
2071
2072 void
2073 gimple_dump_bb (basic_block bb, FILE *file, int indent, int flags)
2074 {
2075   maybe_init_pretty_print (file);
2076   gimple_dump_bb_buff (&buffer, bb, indent, flags);
2077   pp_flush (&buffer);
2078 }