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    2011  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     case FMA_EXPR:
404       dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
405       pp_string (buffer, " * ");
406       dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
407       pp_string (buffer, " + ");
408       dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
409       break;
410
411     case DOT_PROD_EXPR:
412       pp_string (buffer, "DOT_PROD_EXPR <");
413       dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
414       pp_string (buffer, ", ");
415       dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
416       pp_string (buffer, ", ");
417       dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
418       pp_string (buffer, ">");
419       break;
420
421     case REALIGN_LOAD_EXPR:
422       pp_string (buffer, "REALIGN_LOAD <");
423       dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
424       pp_string (buffer, ", ");
425       dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
426       pp_string (buffer, ", ");
427       dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
428       pp_string (buffer, ">");
429       break;
430
431     case COND_EXPR:
432       dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
433       pp_string (buffer, " ? ");
434       dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
435       pp_string (buffer, " : ");
436       dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
437       break;
438
439     case VEC_COND_EXPR:
440       pp_string (buffer, "VEC_COND_EXPR <");
441       dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
442       pp_string (buffer, ", ");
443       dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
444       pp_string (buffer, ", ");
445       dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
446       pp_string (buffer, ">");
447       break;
448
449     default:
450       gcc_unreachable ();
451     }
452 }
453
454
455 /* Dump the gimple assignment GS.  BUFFER, SPC and FLAGS are as in
456    dump_gimple_stmt.  */
457
458 static void
459 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
460 {
461   if (flags & TDF_RAW)
462     {
463       tree last;
464       if (gimple_num_ops (gs) == 2)
465         last = NULL_TREE;
466       else if (gimple_num_ops (gs) == 3)
467         last = gimple_assign_rhs2 (gs);
468       else
469         gcc_unreachable ();
470
471       dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T>", gs,
472                        tree_code_name[gimple_assign_rhs_code (gs)],
473                        gimple_assign_lhs (gs), gimple_assign_rhs1 (gs), last);
474     }
475   else
476     {
477       if (!(flags & TDF_RHS_ONLY))
478         {
479           dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
480           pp_space (buffer);
481           pp_character (buffer, '=');
482
483           if (gimple_assign_nontemporal_move_p (gs))
484             pp_string (buffer, "{nt}");
485
486           if (gimple_has_volatile_ops (gs))
487             pp_string (buffer, "{v}");
488
489           pp_space (buffer);
490         }
491
492       if (gimple_num_ops (gs) == 2)
493         dump_unary_rhs (buffer, gs, spc, flags);
494       else if (gimple_num_ops (gs) == 3)
495         dump_binary_rhs (buffer, gs, spc, flags);
496       else if (gimple_num_ops (gs) == 4)
497         dump_ternary_rhs (buffer, gs, spc, flags);
498       else
499         gcc_unreachable ();
500       if (!(flags & TDF_RHS_ONLY))
501         pp_semicolon(buffer);
502     }
503 }
504
505
506 /* Dump the return statement GS.  BUFFER, SPC and FLAGS are as in
507    dump_gimple_stmt.  */
508
509 static void
510 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
511 {
512   tree t;
513
514   t = gimple_return_retval (gs);
515   if (flags & TDF_RAW)
516     dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
517   else
518     {
519       pp_string (buffer, "return");
520       if (t)
521         {
522           pp_space (buffer);
523           dump_generic_node (buffer, t, spc, flags, false);
524         }
525       pp_semicolon (buffer);
526     }
527 }
528
529
530 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
531    dump_gimple_call.  */
532
533 static void
534 dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags)
535 {
536   size_t i;
537
538   for (i = 0; i < gimple_call_num_args (gs); i++)
539     {
540       dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
541       if (i < gimple_call_num_args (gs) - 1)
542         pp_string (buffer, ", ");
543     }
544
545   if (gimple_call_va_arg_pack_p (gs))
546     {
547       if (gimple_call_num_args (gs) > 0)
548         {
549           pp_character (buffer, ',');
550           pp_space (buffer);
551         }
552
553       pp_string (buffer, "__builtin_va_arg_pack ()");
554     }
555 }
556
557 /* Dump the points-to solution *PT to BUFFER.  */
558
559 static void
560 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
561 {
562   if (pt->anything)
563     {
564       pp_string (buffer, "anything ");
565       return;
566     }
567   if (pt->nonlocal)
568     pp_string (buffer, "nonlocal ");
569   if (pt->escaped)
570     pp_string (buffer, "escaped ");
571   if (pt->ipa_escaped)
572     pp_string (buffer, "unit-escaped ");
573   if (pt->null)
574     pp_string (buffer, "null ");
575   if (pt->vars
576       && !bitmap_empty_p (pt->vars))
577     {
578       bitmap_iterator bi;
579       unsigned i;
580       pp_string (buffer, "{ ");
581       EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
582         {
583           tree var = referenced_var_lookup (cfun, i);
584           if (var)
585             {
586               dump_generic_node (buffer, var, 0, dump_flags, false);
587               if (DECL_PT_UID (var) != DECL_UID (var))
588                 {
589                   pp_string (buffer, "ptD.");
590                   pp_decimal_int (buffer, DECL_PT_UID (var));
591                 }
592             }
593           else
594             {
595               pp_string (buffer, "D.");
596               pp_decimal_int (buffer, i);
597             }
598           pp_character (buffer, ' ');
599         }
600       pp_character (buffer, '}');
601       if (pt->vars_contains_global)
602         pp_string (buffer, " (glob)");
603       if (pt->vars_contains_restrict)
604         pp_string (buffer, " (restr)");
605     }
606 }
607
608 /* Dump the call statement GS.  BUFFER, SPC and FLAGS are as in
609    dump_gimple_stmt.  */
610
611 static void
612 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
613 {
614   tree lhs = gimple_call_lhs (gs);
615
616   if (flags & TDF_ALIAS)
617     {
618       struct pt_solution *pt;
619       pt = gimple_call_use_set (gs);
620       if (!pt_solution_empty_p (pt))
621         {
622           pp_string (buffer, "# USE = ");
623           pp_points_to_solution (buffer, pt);
624           newline_and_indent (buffer, spc);
625         }
626       pt = gimple_call_clobber_set (gs);
627       if (!pt_solution_empty_p (pt))
628         {
629           pp_string (buffer, "# CLB = ");
630           pp_points_to_solution (buffer, pt);
631           newline_and_indent (buffer, spc);
632         }
633     }
634
635   if (flags & TDF_RAW)
636     {
637       if (gimple_call_internal_p (gs))
638         dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
639                          internal_fn_name (gimple_call_internal_fn (gs)), lhs);
640       else
641         dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T",
642                          gs, gimple_call_fn (gs), lhs);
643       if (gimple_call_num_args (gs) > 0)
644         {
645           pp_string (buffer, ", ");
646           dump_gimple_call_args (buffer, gs, flags);
647         }
648       pp_character (buffer, '>');
649     }
650   else
651     {
652       if (lhs && !(flags & TDF_RHS_ONLY))
653         {
654           dump_generic_node (buffer, lhs, spc, flags, false);
655           pp_string (buffer, " =");
656
657           if (gimple_has_volatile_ops (gs))
658             pp_string (buffer, "{v}");
659
660           pp_space (buffer);
661         }
662       if (gimple_call_internal_p (gs))
663         pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
664       else
665         print_call_name (buffer, gimple_call_fn (gs), flags);
666       pp_string (buffer, " (");
667       dump_gimple_call_args (buffer, gs, flags);
668       pp_character (buffer, ')');
669       if (!(flags & TDF_RHS_ONLY))
670         pp_semicolon (buffer);
671     }
672
673   if (gimple_call_chain (gs))
674     {
675       pp_string (buffer, " [static-chain: ");
676       dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
677       pp_character (buffer, ']');
678     }
679
680   if (gimple_call_return_slot_opt_p (gs))
681     pp_string (buffer, " [return slot optimization]");
682
683   if (gimple_call_tail_p (gs))
684     pp_string (buffer, " [tail call]");
685 }
686
687
688 /* Dump the switch statement GS.  BUFFER, SPC and FLAGS are as in
689    dump_gimple_stmt.  */
690
691 static void
692 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
693 {
694   unsigned int i;
695
696   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
697   if (flags & TDF_RAW)
698     dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
699                    gimple_switch_index (gs));
700   else
701     {
702       pp_string (buffer, "switch (");
703       dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
704       pp_string (buffer, ") <");
705     }
706
707   for (i = 0; i < gimple_switch_num_labels (gs); i++)
708     {
709       tree case_label = gimple_switch_label (gs, i);
710       if (case_label == NULL_TREE)
711         continue;
712
713       dump_generic_node (buffer, case_label, spc, flags, false);
714       pp_character (buffer, ' ');
715       dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
716       if (i < gimple_switch_num_labels (gs) - 1)
717         pp_string (buffer, ", ");
718     }
719   pp_character (buffer, '>');
720 }
721
722
723 /* Dump the gimple conditional GS.  BUFFER, SPC and FLAGS are as in
724    dump_gimple_stmt.  */
725
726 static void
727 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
728 {
729   if (flags & TDF_RAW)
730     dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
731                    tree_code_name [gimple_cond_code (gs)],
732                    gimple_cond_lhs (gs), gimple_cond_rhs (gs),
733                    gimple_cond_true_label (gs), gimple_cond_false_label (gs));
734   else
735     {
736       if (!(flags & TDF_RHS_ONLY))
737         pp_string (buffer, "if (");
738       dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
739       pp_space (buffer);
740       pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
741       pp_space (buffer);
742       dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
743       if (!(flags & TDF_RHS_ONLY))
744         {
745           pp_character (buffer, ')');
746
747           if (gimple_cond_true_label (gs))
748             {
749               pp_string (buffer, " goto ");
750               dump_generic_node (buffer, gimple_cond_true_label (gs),
751                                  spc, flags, false);
752               pp_semicolon (buffer);
753             }
754           if (gimple_cond_false_label (gs))
755             {
756               pp_string (buffer, " else goto ");
757               dump_generic_node (buffer, gimple_cond_false_label (gs),
758                                  spc, flags, false);
759               pp_semicolon (buffer);
760             }
761         }
762     }
763 }
764
765
766 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
767    spaces of indent.  FLAGS specifies details to show in the dump (see
768    TDF_* in tree-pass.h).  */
769
770 static void
771 dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
772 {
773   tree label = gimple_label_label (gs);
774   if (flags & TDF_RAW)
775       dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
776   else
777     {
778       dump_generic_node (buffer, label, spc, flags, false);
779       pp_character (buffer, ':');
780     }
781   if (DECL_NONLOCAL (label))
782     pp_string (buffer, " [non-local]");
783   if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
784     pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
785 }
786
787 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
788    spaces of indent.  FLAGS specifies details to show in the dump (see
789    TDF_* in tree-pass.h).  */
790
791 static void
792 dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
793 {
794   tree label = gimple_goto_dest (gs);
795   if (flags & TDF_RAW)
796     dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
797   else
798     dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
799 }
800
801
802 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
803    spaces of indent.  FLAGS specifies details to show in the dump (see
804    TDF_* in tree-pass.h).  */
805
806 static void
807 dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
808 {
809   if (flags & TDF_RAW)
810     dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
811   else
812     pp_character (buffer, '{');
813   if (!(flags & TDF_SLIM))
814     {
815       tree var;
816
817       for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
818         {
819           newline_and_indent (buffer, 2);
820           print_declaration (buffer, var, spc, flags);
821         }
822       if (gimple_bind_vars (gs))
823         pp_newline (buffer);
824     }
825   pp_newline (buffer);
826   dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
827   newline_and_indent (buffer, spc);
828   if (flags & TDF_RAW)
829     pp_character (buffer, '>');
830   else
831     pp_character (buffer, '}');
832 }
833
834
835 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
836    indent.  FLAGS specifies details to show in the dump (see TDF_* in
837    tree-pass.h).  */
838
839 static void
840 dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
841 {
842   if (flags & TDF_RAW)
843     {
844       const char *type;
845       if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
846         type = "GIMPLE_TRY_CATCH";
847       else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
848         type = "GIMPLE_TRY_FINALLY";
849       else
850         type = "UNKNOWN GIMPLE_TRY";
851       dump_gimple_fmt (buffer, spc, flags,
852                        "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
853                        gimple_try_eval (gs), gimple_try_cleanup (gs));
854     }
855   else
856     {
857       pp_string (buffer, "try");
858       newline_and_indent (buffer, spc + 2);
859       pp_character (buffer, '{');
860       pp_newline (buffer);
861
862       dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
863       newline_and_indent (buffer, spc + 2);
864       pp_character (buffer, '}');
865
866       if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
867         {
868           newline_and_indent (buffer, spc);
869           pp_string (buffer, "catch");
870           newline_and_indent (buffer, spc + 2);
871           pp_character (buffer, '{');
872         }
873       else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
874         {
875           newline_and_indent (buffer, spc);
876           pp_string (buffer, "finally");
877           newline_and_indent (buffer, spc + 2);
878           pp_character (buffer, '{');
879         }
880       else
881         pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
882
883       pp_newline (buffer);
884       dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
885       newline_and_indent (buffer, spc + 2);
886       pp_character (buffer, '}');
887     }
888 }
889
890
891 /* Dump a GIMPLE_CATCH 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_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
897 {
898   if (flags & TDF_RAW)
899       dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
900                        gimple_catch_types (gs), gimple_catch_handler (gs));
901   else
902       dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
903                        gimple_catch_types (gs), gimple_catch_handler (gs));
904 }
905
906
907 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
908    indent.  FLAGS specifies details to show in the dump (see TDF_* in
909    tree-pass.h).  */
910
911 static void
912 dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
913 {
914   if (flags & TDF_RAW)
915     dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
916                      gimple_eh_filter_types (gs),
917                      gimple_eh_filter_failure (gs));
918   else
919     dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
920                      gimple_eh_filter_types (gs),
921                      gimple_eh_filter_failure (gs));
922 }
923
924
925 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple.  */
926
927 static void
928 dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
929                                int spc, int flags)
930 {
931   if (flags & TDF_RAW)
932     dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
933                      gimple_eh_must_not_throw_fndecl (gs));
934   else
935     dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
936                      gimple_eh_must_not_throw_fndecl (gs));
937 }
938
939
940 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
941    indent.  FLAGS specifies details to show in the dump (see TDF_* in
942    tree-pass.h).  */
943
944 static void
945 dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
946 {
947   if (flags & TDF_RAW)
948     dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
949                      gimple_resx_region (gs));
950   else
951     dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
952 }
953
954 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER.  */
955
956 static void
957 dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
958 {
959   if (flags & TDF_RAW)
960     dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
961                      gimple_eh_dispatch_region (gs));
962   else
963     dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
964                      gimple_eh_dispatch_region (gs));
965 }
966
967 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
968    of indent.  FLAGS specifies details to show in the dump (see TDF_*
969    in tree-pass.h).  */
970
971 static void
972 dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
973 {
974   switch (gs->gsbase.subcode)
975     {
976     case GIMPLE_DEBUG_BIND:
977       if (flags & TDF_RAW)
978         dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
979                          gimple_debug_bind_get_var (gs),
980                          gimple_debug_bind_get_value (gs));
981       else
982         dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
983                          gimple_debug_bind_get_var (gs),
984                          gimple_debug_bind_get_value (gs));
985       break;
986
987     case GIMPLE_DEBUG_SOURCE_BIND:
988       if (flags & TDF_RAW)
989         dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
990                          gimple_debug_source_bind_get_var (gs),
991                          gimple_debug_source_bind_get_value (gs));
992       else
993         dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
994                          gimple_debug_source_bind_get_var (gs),
995                          gimple_debug_source_bind_get_value (gs));
996       break;
997
998     default:
999       gcc_unreachable ();
1000     }
1001 }
1002
1003 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER.  */
1004 static void
1005 dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
1006 {
1007   size_t i;
1008
1009   if (flags & TDF_RAW)
1010     {
1011       dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1012                        gimple_omp_body (gs));
1013       dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1014       dump_gimple_fmt (buffer, spc, flags, " >,");
1015       for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1016         dump_gimple_fmt (buffer, spc, flags,
1017                          "%+%T, %T, %T, %s, %T,%n",
1018                          gimple_omp_for_index (gs, i),
1019                          gimple_omp_for_initial (gs, i),
1020                          gimple_omp_for_final (gs, i),
1021                          tree_code_name[gimple_omp_for_cond (gs, i)],
1022                          gimple_omp_for_incr (gs, i));
1023       dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1024                        gimple_omp_for_pre_body (gs));
1025     }
1026   else
1027     {
1028       pp_string (buffer, "#pragma omp for");
1029       dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1030       for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1031         {
1032           if (i)
1033             spc += 2;
1034           newline_and_indent (buffer, spc);
1035           pp_string (buffer, "for (");
1036           dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1037                              flags, false);
1038           pp_string (buffer, " = ");
1039           dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1040                              flags, false);
1041           pp_string (buffer, "; ");
1042
1043           dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1044                              flags, false);
1045           pp_space (buffer);
1046           switch (gimple_omp_for_cond (gs, i))
1047             {
1048             case LT_EXPR:
1049               pp_character (buffer, '<');
1050               break;
1051             case GT_EXPR:
1052               pp_character (buffer, '>');
1053               break;
1054             case LE_EXPR:
1055               pp_string (buffer, "<=");
1056               break;
1057             case GE_EXPR:
1058               pp_string (buffer, ">=");
1059               break;
1060             default:
1061               gcc_unreachable ();
1062             }
1063           pp_space (buffer);
1064           dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1065                              flags, false);
1066           pp_string (buffer, "; ");
1067
1068           dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1069                              flags, false);
1070           pp_string (buffer, " = ");
1071           dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1072                              flags, false);
1073           pp_character (buffer, ')');
1074         }
1075
1076       if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1077         {
1078           newline_and_indent (buffer, spc + 2);
1079           pp_character (buffer, '{');
1080           pp_newline (buffer);
1081           dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1082           newline_and_indent (buffer, spc + 2);
1083           pp_character (buffer, '}');
1084         }
1085     }
1086 }
1087
1088 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER.  */
1089
1090 static void
1091 dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags)
1092 {
1093   if (flags & TDF_RAW)
1094     {
1095       dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1096                        gimple_omp_continue_control_def (gs),
1097                        gimple_omp_continue_control_use (gs));
1098     }
1099   else
1100     {
1101       pp_string (buffer, "#pragma omp continue (");
1102       dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1103                          spc, flags, false);
1104       pp_character (buffer, ',');
1105       pp_space (buffer);
1106       dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1107                          spc, flags, false);
1108       pp_character (buffer, ')');
1109     }
1110 }
1111
1112 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER.  */
1113
1114 static void
1115 dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, int flags)
1116 {
1117   if (flags & TDF_RAW)
1118     {
1119       dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1120                        gimple_omp_body (gs));
1121       dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1122       dump_gimple_fmt (buffer, spc, flags, " >");
1123     }
1124   else
1125     {
1126       pp_string (buffer, "#pragma omp single");
1127       dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1128       if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1129         {
1130           newline_and_indent (buffer, spc + 2);
1131           pp_character (buffer, '{');
1132           pp_newline (buffer);
1133           dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1134           newline_and_indent (buffer, spc + 2);
1135           pp_character (buffer, '}');
1136         }
1137     }
1138 }
1139
1140 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER.  */
1141
1142 static void
1143 dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
1144                           int flags)
1145 {
1146   if (flags & TDF_RAW)
1147     {
1148       dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1149                        gimple_omp_body (gs));
1150       dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1151       dump_gimple_fmt (buffer, spc, flags, " >");
1152     }
1153   else
1154     {
1155       pp_string (buffer, "#pragma omp sections");
1156       if (gimple_omp_sections_control (gs))
1157         {
1158           pp_string (buffer, " <");
1159           dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1160                              flags, false);
1161           pp_character (buffer, '>');
1162         }
1163       dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1164       if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1165         {
1166           newline_and_indent (buffer, spc + 2);
1167           pp_character (buffer, '{');
1168           pp_newline (buffer);
1169           dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1170           newline_and_indent (buffer, spc + 2);
1171           pp_character (buffer, '}');
1172         }
1173     }
1174 }
1175
1176 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the pretty_printer
1177    BUFFER.  */
1178
1179 static void
1180 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1181 {
1182   if (flags & TDF_RAW)
1183     dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1184                      gimple_omp_body (gs));
1185   else
1186     {
1187       switch (gimple_code (gs))
1188         {
1189         case GIMPLE_OMP_MASTER:
1190           pp_string (buffer, "#pragma omp master");
1191           break;
1192         case GIMPLE_OMP_ORDERED:
1193           pp_string (buffer, "#pragma omp ordered");
1194           break;
1195         case GIMPLE_OMP_SECTION:
1196           pp_string (buffer, "#pragma omp section");
1197           break;
1198         default:
1199           gcc_unreachable ();
1200         }
1201       if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1202         {
1203           newline_and_indent (buffer, spc + 2);
1204           pp_character (buffer, '{');
1205           pp_newline (buffer);
1206           dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1207           newline_and_indent (buffer, spc + 2);
1208           pp_character (buffer, '}');
1209         }
1210     }
1211 }
1212
1213 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER.  */
1214
1215 static void
1216 dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
1217                           int flags)
1218 {
1219   if (flags & TDF_RAW)
1220     dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1221                      gimple_omp_body (gs));
1222   else
1223     {
1224       pp_string (buffer, "#pragma omp critical");
1225       if (gimple_omp_critical_name (gs))
1226         {
1227           pp_string (buffer, " (");
1228           dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1229                              flags, false);
1230           pp_character (buffer, ')');
1231         }
1232       if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1233         {
1234           newline_and_indent (buffer, spc + 2);
1235           pp_character (buffer, '{');
1236           pp_newline (buffer);
1237           dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1238           newline_and_indent (buffer, spc + 2);
1239           pp_character (buffer, '}');
1240         }
1241     }
1242 }
1243
1244 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER.  */
1245
1246 static void
1247 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1248 {
1249   if (flags & TDF_RAW)
1250     {
1251       dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d>", gs,
1252                        (int) gimple_omp_return_nowait_p (gs));
1253     }
1254   else
1255     {
1256       pp_string (buffer, "#pragma omp return");
1257       if (gimple_omp_return_nowait_p (gs))
1258         pp_string (buffer, "(nowait)");
1259     }
1260 }
1261
1262 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1263    indent.  FLAGS specifies details to show in the dump (see TDF_* in
1264    tree-pass.h).  */
1265
1266 static void
1267 dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
1268 {
1269   unsigned int i, n, f, fields;
1270
1271   if (flags & TDF_RAW)
1272     {
1273       dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1274                        gimple_asm_string (gs));
1275
1276       n = gimple_asm_noutputs (gs);
1277       if (n)
1278         {
1279           newline_and_indent (buffer, spc + 2);
1280           pp_string (buffer, "OUTPUT: ");
1281           for (i = 0; i < n; i++)
1282             {
1283               dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1284                                  spc, flags, false);
1285               if (i < n - 1)
1286                 pp_string (buffer, ", ");
1287             }
1288         }
1289
1290       n = gimple_asm_ninputs (gs);
1291       if (n)
1292         {
1293           newline_and_indent (buffer, spc + 2);
1294           pp_string (buffer, "INPUT: ");
1295           for (i = 0; i < n; i++)
1296             {
1297               dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1298                                  spc, flags, false);
1299               if (i < n - 1)
1300                 pp_string (buffer, ", ");
1301             }
1302         }
1303
1304       n = gimple_asm_nclobbers (gs);
1305       if (n)
1306         {
1307           newline_and_indent (buffer, spc + 2);
1308           pp_string (buffer, "CLOBBER: ");
1309           for (i = 0; i < n; i++)
1310             {
1311               dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1312                                  spc, flags, false);
1313               if (i < n - 1)
1314                 pp_string (buffer, ", ");
1315             }
1316         }
1317
1318       n = gimple_asm_nlabels (gs);
1319       if (n)
1320         {
1321           newline_and_indent (buffer, spc + 2);
1322           pp_string (buffer, "LABEL: ");
1323           for (i = 0; i < n; i++)
1324             {
1325               dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1326                                  spc, flags, false);
1327               if (i < n - 1)
1328                 pp_string (buffer, ", ");
1329             }
1330         }
1331
1332       newline_and_indent (buffer, spc);
1333       pp_character (buffer, '>');
1334     }
1335   else
1336     {
1337       pp_string (buffer, "__asm__");
1338       if (gimple_asm_volatile_p (gs))
1339         pp_string (buffer, " __volatile__");
1340       if (gimple_asm_nlabels (gs))
1341         pp_string (buffer, " goto");
1342       pp_string (buffer, "(\"");
1343       pp_string (buffer, gimple_asm_string (gs));
1344       pp_string (buffer, "\"");
1345
1346       if (gimple_asm_nlabels (gs))
1347         fields = 4;
1348       else if (gimple_asm_nclobbers (gs))
1349         fields = 3;
1350       else if (gimple_asm_ninputs (gs))
1351         fields = 2;
1352       else if (gimple_asm_noutputs (gs))
1353         fields = 1;
1354       else
1355         fields = 0;
1356
1357       for (f = 0; f < fields; ++f)
1358         {
1359           pp_string (buffer, " : ");
1360
1361           switch (f)
1362             {
1363             case 0:
1364               n = gimple_asm_noutputs (gs);
1365               for (i = 0; i < n; i++)
1366                 {
1367                   dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1368                                      spc, flags, false);
1369                   if (i < n - 1)
1370                     pp_string (buffer, ", ");
1371                 }
1372               break;
1373
1374             case 1:
1375               n = gimple_asm_ninputs (gs);
1376               for (i = 0; i < n; i++)
1377                 {
1378                   dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1379                                      spc, flags, false);
1380                   if (i < n - 1)
1381                     pp_string (buffer, ", ");
1382                 }
1383               break;
1384
1385             case 2:
1386               n = gimple_asm_nclobbers (gs);
1387               for (i = 0; i < n; i++)
1388                 {
1389                   dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1390                                      spc, flags, false);
1391                   if (i < n - 1)
1392                     pp_string (buffer, ", ");
1393                 }
1394               break;
1395
1396             case 3:
1397               n = gimple_asm_nlabels (gs);
1398               for (i = 0; i < n; i++)
1399                 {
1400                   dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1401                                      spc, flags, false);
1402                   if (i < n - 1)
1403                     pp_string (buffer, ", ");
1404                 }
1405               break;
1406
1407             default:
1408               gcc_unreachable ();
1409             }
1410         }
1411
1412       pp_string (buffer, ");");
1413     }
1414 }
1415
1416
1417 /* Dump a PHI node PHI.  BUFFER, SPC and FLAGS are as in
1418    dump_gimple_stmt.  */
1419
1420 static void
1421 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags)
1422 {
1423   size_t i;
1424   tree lhs = gimple_phi_result (phi);
1425
1426   if (flags & TDF_ALIAS
1427       && POINTER_TYPE_P (TREE_TYPE (lhs))
1428       && SSA_NAME_PTR_INFO (lhs))
1429     {
1430       struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
1431       pp_string (buffer, "PT = ");
1432       pp_points_to_solution (buffer, &pi->pt);
1433       newline_and_indent (buffer, spc);
1434       if (pi->align != 1)
1435         pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u",
1436                    pi->align, pi->misalign);
1437       newline_and_indent (buffer, spc);
1438       pp_string (buffer, "# ");
1439     }
1440
1441   if (flags & TDF_RAW)
1442       dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1443                        gimple_phi_result (phi));
1444   else
1445     {
1446       dump_generic_node (buffer, lhs, spc, flags, false);
1447       pp_string (buffer, " = PHI <");
1448     }
1449   for (i = 0; i < gimple_phi_num_args (phi); i++)
1450     {
1451       if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1452         {
1453           expanded_location xloc;
1454
1455           xloc = expand_location (gimple_phi_arg_location (phi, i));
1456           pp_character (buffer, '[');
1457           if (xloc.file)
1458             {
1459               pp_string (buffer, xloc.file);
1460               pp_string (buffer, " : ");
1461             }
1462           pp_decimal_int (buffer, xloc.line);
1463           pp_string (buffer, ":");
1464           pp_decimal_int (buffer, xloc.column);
1465           pp_string (buffer, "] ");
1466         }
1467       dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1468                          false);
1469       pp_character (buffer, '(');
1470       pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1471       pp_character (buffer, ')');
1472       if (i < gimple_phi_num_args (phi) - 1)
1473         pp_string (buffer, ", ");
1474     }
1475   pp_character (buffer, '>');
1476 }
1477
1478
1479 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1480    of indent.  FLAGS specifies details to show in the dump (see TDF_* in
1481    tree-pass.h).  */
1482
1483 static void
1484 dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1485                           int flags)
1486 {
1487   if (flags & TDF_RAW)
1488     {
1489       dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1490                        gimple_omp_body (gs));
1491       dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1492       dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1493                        gimple_omp_parallel_child_fn (gs),
1494                        gimple_omp_parallel_data_arg (gs));
1495     }
1496   else
1497     {
1498       gimple_seq body;
1499       pp_string (buffer, "#pragma omp parallel");
1500       dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1501       if (gimple_omp_parallel_child_fn (gs))
1502         {
1503           pp_string (buffer, " [child fn: ");
1504           dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1505                              spc, flags, false);
1506           pp_string (buffer, " (");
1507           if (gimple_omp_parallel_data_arg (gs))
1508             dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1509                                spc, flags, false);
1510           else
1511             pp_string (buffer, "???");
1512           pp_string (buffer, ")]");
1513         }
1514       body = gimple_omp_body (gs);
1515       if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1516         {
1517           newline_and_indent (buffer, spc + 2);
1518           pp_character (buffer, '{');
1519           pp_newline (buffer);
1520           dump_gimple_seq (buffer, body, spc + 4, flags);
1521           newline_and_indent (buffer, spc + 2);
1522           pp_character (buffer, '}');
1523         }
1524       else if (body)
1525         {
1526           pp_newline (buffer);
1527           dump_gimple_seq (buffer, body, spc + 2, flags);
1528         }
1529     }
1530 }
1531
1532
1533 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1534    of indent.  FLAGS specifies details to show in the dump (see TDF_* in
1535    tree-pass.h).  */
1536
1537 static void
1538 dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
1539                       int flags)
1540 {
1541   if (flags & TDF_RAW)
1542     {
1543       dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1544                        gimple_omp_body (gs));
1545       dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1546       dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1547                        gimple_omp_task_child_fn (gs),
1548                        gimple_omp_task_data_arg (gs),
1549                        gimple_omp_task_copy_fn (gs),
1550                        gimple_omp_task_arg_size (gs),
1551                        gimple_omp_task_arg_size (gs));
1552     }
1553   else
1554     {
1555       gimple_seq body;
1556       pp_string (buffer, "#pragma omp task");
1557       dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1558       if (gimple_omp_task_child_fn (gs))
1559         {
1560           pp_string (buffer, " [child fn: ");
1561           dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1562                              spc, flags, false);
1563           pp_string (buffer, " (");
1564           if (gimple_omp_task_data_arg (gs))
1565             dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1566                                spc, flags, false);
1567           else
1568             pp_string (buffer, "???");
1569           pp_string (buffer, ")]");
1570         }
1571       body = gimple_omp_body (gs);
1572       if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1573         {
1574           newline_and_indent (buffer, spc + 2);
1575           pp_character (buffer, '{');
1576           pp_newline (buffer);
1577           dump_gimple_seq (buffer, body, spc + 4, flags);
1578           newline_and_indent (buffer, spc + 2);
1579           pp_character (buffer, '}');
1580         }
1581       else if (body)
1582         {
1583           pp_newline (buffer);
1584           dump_gimple_seq (buffer, body, spc + 2, flags);
1585         }
1586     }
1587 }
1588
1589
1590 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1591    spaces of indent.  FLAGS specifies details to show in the dump (see TDF_*
1592    in tree-pass.h).  */
1593
1594 static void
1595 dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
1596                              int flags)
1597 {
1598   if (flags & TDF_RAW)
1599     {
1600       dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1601                        gimple_omp_atomic_load_lhs (gs),
1602                        gimple_omp_atomic_load_rhs (gs));
1603     }
1604   else
1605     {
1606       pp_string (buffer, "#pragma omp atomic_load");
1607       newline_and_indent (buffer, spc + 2);
1608       dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
1609                          spc, flags, false);
1610       pp_space (buffer);
1611       pp_character (buffer, '=');
1612       pp_space (buffer);
1613       pp_character (buffer, '*');
1614       dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
1615                          spc, flags, false);
1616     }
1617 }
1618
1619 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1620    spaces of indent.  FLAGS specifies details to show in the dump (see TDF_*
1621    in tree-pass.h).  */
1622
1623 static void
1624 dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
1625                              int flags)
1626 {
1627   if (flags & TDF_RAW)
1628     {
1629       dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1630                        gimple_omp_atomic_store_val (gs));
1631     }
1632   else
1633     {
1634       pp_string (buffer, "#pragma omp atomic_store (");
1635       dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
1636                          spc, flags, false);
1637       pp_character (buffer, ')');
1638     }
1639 }
1640
1641
1642 /* Dump all the memory operands for statement GS.  BUFFER, SPC and
1643    FLAGS are as in dump_gimple_stmt.  */
1644
1645 static void
1646 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
1647 {
1648   tree vdef = gimple_vdef (gs);
1649   tree vuse = gimple_vuse (gs);
1650
1651   if (!ssa_operands_active () || !gimple_references_memory_p (gs))
1652     return;
1653
1654   if (vdef != NULL_TREE)
1655     {
1656       pp_string (buffer, "# ");
1657       dump_generic_node (buffer, vdef, spc + 2, flags, false);
1658       pp_string (buffer, " = VDEF <");
1659       dump_generic_node (buffer, vuse, spc + 2, flags, false);
1660       pp_character (buffer, '>');
1661       newline_and_indent (buffer, spc);
1662     }
1663   else if (vuse != NULL_TREE)
1664     {
1665       pp_string (buffer, "# VUSE <");
1666       dump_generic_node (buffer, vuse, spc + 2, flags, false);
1667       pp_character (buffer, '>');
1668       newline_and_indent (buffer, spc);
1669     }
1670 }
1671
1672
1673 /* Dump the gimple statement GS on the pretty printer BUFFER, SPC
1674    spaces of indent.  FLAGS specifies details to show in the dump (see
1675    TDF_* in tree-pass.h).  */
1676
1677 void
1678 dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
1679 {
1680   if (!gs)
1681     return;
1682
1683   if (flags & TDF_STMTADDR)
1684     pp_printf (buffer, "<&%p> ", (void *) gs);
1685
1686   if ((flags & TDF_LINENO) && gimple_has_location (gs))
1687     {
1688       expanded_location xloc = expand_location (gimple_location (gs));
1689       pp_character (buffer, '[');
1690       if (xloc.file)
1691         {
1692           pp_string (buffer, xloc.file);
1693           pp_string (buffer, " : ");
1694         }
1695       pp_decimal_int (buffer, xloc.line);
1696       pp_string (buffer, ":");
1697       pp_decimal_int (buffer, xloc.column);
1698       pp_string (buffer, "] ");
1699     }
1700
1701   if (flags & TDF_EH)
1702     {
1703       int lp_nr = lookup_stmt_eh_lp (gs);
1704       if (lp_nr > 0)
1705         pp_printf (buffer, "[LP %d] ", lp_nr);
1706       else if (lp_nr < 0)
1707         pp_printf (buffer, "[MNT %d] ", -lp_nr);
1708     }
1709
1710   if ((flags & (TDF_VOPS|TDF_MEMSYMS))
1711       && gimple_has_mem_ops (gs))
1712     dump_gimple_mem_ops (buffer, gs, spc, flags);
1713
1714   if ((flags & TDF_ALIAS)
1715       && gimple_has_lhs (gs))
1716     {
1717       tree lhs = gimple_get_lhs (gs);
1718       if (TREE_CODE (lhs) == SSA_NAME
1719           && POINTER_TYPE_P (TREE_TYPE (lhs))
1720           && SSA_NAME_PTR_INFO (lhs))
1721         {
1722           struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
1723           pp_string (buffer, "# PT = ");
1724           pp_points_to_solution (buffer, &pi->pt);
1725           newline_and_indent (buffer, spc);
1726           if (pi->align != 1)
1727             {
1728               pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u",
1729                          pi->align, pi->misalign);
1730               newline_and_indent (buffer, spc);
1731             }
1732         }
1733     }
1734
1735   switch (gimple_code (gs))
1736     {
1737     case GIMPLE_ASM:
1738       dump_gimple_asm (buffer, gs, spc, flags);
1739       break;
1740
1741     case GIMPLE_ASSIGN:
1742       dump_gimple_assign (buffer, gs, spc, flags);
1743       break;
1744
1745     case GIMPLE_BIND:
1746       dump_gimple_bind (buffer, gs, spc, flags);
1747       break;
1748
1749     case GIMPLE_CALL:
1750       dump_gimple_call (buffer, gs, spc, flags);
1751       break;
1752
1753     case GIMPLE_COND:
1754       dump_gimple_cond (buffer, gs, spc, flags);
1755       break;
1756
1757     case GIMPLE_LABEL:
1758       dump_gimple_label (buffer, gs, spc, flags);
1759       break;
1760
1761     case GIMPLE_GOTO:
1762       dump_gimple_goto (buffer, gs, spc, flags);
1763       break;
1764
1765     case GIMPLE_NOP:
1766       pp_string (buffer, "GIMPLE_NOP");
1767       break;
1768
1769     case GIMPLE_RETURN:
1770       dump_gimple_return (buffer, gs, spc, flags);
1771       break;
1772
1773     case GIMPLE_SWITCH:
1774       dump_gimple_switch (buffer, gs, spc, flags);
1775       break;
1776
1777     case GIMPLE_TRY:
1778       dump_gimple_try (buffer, gs, spc, flags);
1779       break;
1780
1781     case GIMPLE_PHI:
1782       dump_gimple_phi (buffer, gs, spc, flags);
1783       break;
1784
1785     case GIMPLE_OMP_PARALLEL:
1786       dump_gimple_omp_parallel (buffer, gs, spc, flags);
1787       break;
1788
1789     case GIMPLE_OMP_TASK:
1790       dump_gimple_omp_task (buffer, gs, spc, flags);
1791       break;
1792
1793     case GIMPLE_OMP_ATOMIC_LOAD:
1794       dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
1795
1796       break;
1797
1798     case GIMPLE_OMP_ATOMIC_STORE:
1799       dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
1800       break;
1801
1802     case GIMPLE_OMP_FOR:
1803       dump_gimple_omp_for (buffer, gs, spc, flags);
1804       break;
1805
1806     case GIMPLE_OMP_CONTINUE:
1807       dump_gimple_omp_continue (buffer, gs, spc, flags);
1808       break;
1809
1810     case GIMPLE_OMP_SINGLE:
1811       dump_gimple_omp_single (buffer, gs, spc, flags);
1812       break;
1813
1814     case GIMPLE_OMP_RETURN:
1815       dump_gimple_omp_return (buffer, gs, spc, flags);
1816       break;
1817
1818     case GIMPLE_OMP_SECTIONS:
1819       dump_gimple_omp_sections (buffer, gs, spc, flags);
1820       break;
1821
1822     case GIMPLE_OMP_SECTIONS_SWITCH:
1823       pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
1824       break;
1825
1826     case GIMPLE_OMP_MASTER:
1827     case GIMPLE_OMP_ORDERED:
1828     case GIMPLE_OMP_SECTION:
1829       dump_gimple_omp_block (buffer, gs, spc, flags);
1830       break;
1831
1832     case GIMPLE_OMP_CRITICAL:
1833       dump_gimple_omp_critical (buffer, gs, spc, flags);
1834       break;
1835
1836     case GIMPLE_CATCH:
1837       dump_gimple_catch (buffer, gs, spc, flags);
1838       break;
1839
1840     case GIMPLE_EH_FILTER:
1841       dump_gimple_eh_filter (buffer, gs, spc, flags);
1842       break;
1843
1844     case GIMPLE_EH_MUST_NOT_THROW:
1845       dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
1846       break;
1847
1848     case GIMPLE_RESX:
1849       dump_gimple_resx (buffer, gs, spc, flags);
1850       break;
1851
1852     case GIMPLE_EH_DISPATCH:
1853       dump_gimple_eh_dispatch (buffer, gs, spc, flags);
1854       break;
1855
1856     case GIMPLE_DEBUG:
1857       dump_gimple_debug (buffer, gs, spc, flags);
1858       break;
1859
1860     case GIMPLE_PREDICT:
1861       pp_string (buffer, "// predicted ");
1862       if (gimple_predict_outcome (gs))
1863         pp_string (buffer, "likely by ");
1864       else
1865         pp_string (buffer, "unlikely by ");
1866       pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
1867       pp_string (buffer, " predictor.");
1868       break;
1869
1870     default:
1871       GIMPLE_NIY;
1872     }
1873
1874   /* If we're building a diagnostic, the formatted text will be
1875      written into BUFFER's stream by the caller; otherwise, write it
1876      now.  */
1877   if (!(flags & TDF_DIAGNOSTIC))
1878     pp_write_text_to_stream (buffer);
1879 }
1880
1881
1882 /* Dumps header of basic block BB to buffer BUFFER indented by INDENT
1883    spaces and details described by flags.  */
1884
1885 static void
1886 dump_bb_header (pretty_printer *buffer, basic_block bb, int indent, int flags)
1887 {
1888   edge e;
1889   gimple stmt;
1890   edge_iterator ei;
1891
1892   if (flags & TDF_BLOCKS)
1893     {
1894       INDENT (indent);
1895       pp_string (buffer, "# BLOCK ");
1896       pp_decimal_int (buffer, bb->index);
1897       if (bb->frequency)
1898         {
1899           pp_string (buffer, " freq:");
1900           pp_decimal_int (buffer, bb->frequency);
1901         }
1902       if (bb->count)
1903         {
1904           pp_string (buffer, " count:");
1905           pp_widest_integer (buffer, bb->count);
1906         }
1907
1908       if (flags & TDF_LINENO)
1909         {
1910           gimple_stmt_iterator gsi;
1911
1912           for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
1913             if (!is_gimple_debug (gsi_stmt (gsi))
1914                 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
1915               {
1916                 pp_string (buffer, ", starting at line ");
1917                 pp_decimal_int (buffer, get_lineno (gsi_stmt (gsi)));
1918                 break;
1919               }
1920
1921           if (bb->discriminator)
1922             {
1923               pp_string (buffer, ", discriminator ");
1924               pp_decimal_int (buffer, bb->discriminator);
1925             }
1926         }
1927       newline_and_indent (buffer, indent);
1928
1929       pp_string (buffer, "# PRED:");
1930       pp_write_text_to_stream (buffer);
1931       FOR_EACH_EDGE (e, ei, bb->preds)
1932         if (flags & TDF_SLIM)
1933           {
1934             pp_character (buffer, ' ');
1935             if (e->src == ENTRY_BLOCK_PTR)
1936               pp_string (buffer, "ENTRY");
1937             else
1938               pp_decimal_int (buffer, e->src->index);
1939           }
1940         else
1941           dump_edge_info (buffer->buffer->stream, e, 0);
1942       pp_newline (buffer);
1943     }
1944   else
1945     {
1946       stmt = first_stmt (bb);
1947       if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
1948         {
1949           INDENT (indent - 2);
1950           pp_string (buffer, "<bb ");
1951           pp_decimal_int (buffer, bb->index);
1952           pp_string (buffer, ">:");
1953           pp_newline (buffer);
1954         }
1955     }
1956   pp_write_text_to_stream (buffer);
1957   if (cfun)
1958     check_bb_profile (bb, buffer->buffer->stream);
1959 }
1960
1961
1962 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
1963    spaces.  */
1964
1965 static void
1966 dump_bb_end (pretty_printer *buffer, basic_block bb, int indent, int flags)
1967 {
1968   edge e;
1969   edge_iterator ei;
1970
1971   INDENT (indent);
1972   pp_string (buffer, "# SUCC:");
1973   pp_write_text_to_stream (buffer);
1974   FOR_EACH_EDGE (e, ei, bb->succs)
1975     if (flags & TDF_SLIM)
1976       {
1977         pp_character (buffer, ' ');
1978         if (e->dest == EXIT_BLOCK_PTR)
1979           pp_string (buffer, "EXIT");
1980         else
1981           pp_decimal_int (buffer, e->dest->index);
1982       }
1983     else
1984       dump_edge_info (buffer->buffer->stream, e, 1);
1985   pp_newline (buffer);
1986 }
1987
1988
1989 /* Dump PHI nodes of basic block BB to BUFFER with details described
1990    by FLAGS and indented by INDENT spaces.  */
1991
1992 static void
1993 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
1994 {
1995   gimple_stmt_iterator i;
1996
1997   for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
1998     {
1999       gimple phi = gsi_stmt (i);
2000       if (is_gimple_reg (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2001         {
2002           INDENT (indent);
2003           pp_string (buffer, "# ");
2004           dump_gimple_phi (buffer, phi, indent, flags);
2005           pp_newline (buffer);
2006         }
2007     }
2008 }
2009
2010
2011 /* Dump jump to basic block BB that is represented implicitly in the cfg
2012    to BUFFER.  */
2013
2014 static void
2015 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2016 {
2017   gimple stmt;
2018
2019   stmt = first_stmt (bb);
2020
2021   pp_string (buffer, "goto <bb ");
2022   pp_decimal_int (buffer, bb->index);
2023   pp_character (buffer, '>');
2024   if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2025     {
2026       pp_string (buffer, " (");
2027       dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
2028       pp_character (buffer, ')');
2029       pp_semicolon (buffer);
2030     }
2031   else
2032     pp_semicolon (buffer);
2033 }
2034
2035
2036 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2037    by INDENT spaces, with details given by FLAGS.  */
2038
2039 static void
2040 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2041                      int flags)
2042 {
2043   edge e;
2044   gimple stmt;
2045
2046   stmt = last_stmt (bb);
2047
2048   if (stmt && gimple_code (stmt) == GIMPLE_COND)
2049     {
2050       edge true_edge, false_edge;
2051
2052       /* When we are emitting the code or changing CFG, it is possible that
2053          the edges are not yet created.  When we are using debug_bb in such
2054          a situation, we do not want it to crash.  */
2055       if (EDGE_COUNT (bb->succs) != 2)
2056         return;
2057       extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2058
2059       INDENT (indent + 2);
2060       pp_cfg_jump (buffer, true_edge->dest);
2061       newline_and_indent (buffer, indent);
2062       pp_string (buffer, "else");
2063       newline_and_indent (buffer, indent + 2);
2064       pp_cfg_jump (buffer, false_edge->dest);
2065       pp_newline (buffer);
2066       return;
2067     }
2068
2069   /* If there is a fallthru edge, we may need to add an artificial
2070      goto to the dump.  */
2071   e = find_fallthru_edge (bb->succs);
2072
2073   if (e && e->dest != bb->next_bb)
2074     {
2075       INDENT (indent);
2076
2077       if ((flags & TDF_LINENO)
2078           && e->goto_locus != UNKNOWN_LOCATION
2079           )
2080         {
2081           expanded_location goto_xloc;
2082           goto_xloc = expand_location (e->goto_locus);
2083           pp_character (buffer, '[');
2084           if (goto_xloc.file)
2085             {
2086               pp_string (buffer, goto_xloc.file);
2087               pp_string (buffer, " : ");
2088             }
2089           pp_decimal_int (buffer, goto_xloc.line);
2090           pp_string (buffer, " : ");
2091           pp_decimal_int (buffer, goto_xloc.column);
2092           pp_string (buffer, "] ");
2093         }
2094
2095       pp_cfg_jump (buffer, e->dest);
2096       pp_newline (buffer);
2097     }
2098 }
2099
2100
2101 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2102    indented by INDENT spaces.  */
2103
2104 static void
2105 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2106                      int flags)
2107 {
2108   gimple_stmt_iterator gsi;
2109   gimple stmt;
2110   int label_indent = indent - 2;
2111
2112   if (label_indent < 0)
2113     label_indent = 0;
2114
2115   dump_bb_header (buffer, bb, indent, flags);
2116   dump_phi_nodes (buffer, bb, indent, flags);
2117
2118   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2119     {
2120       int curr_indent;
2121
2122       stmt = gsi_stmt (gsi);
2123
2124       curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2125
2126       INDENT (curr_indent);
2127       dump_gimple_stmt (buffer, stmt, curr_indent, flags);
2128       pp_newline (buffer);
2129       dump_histograms_for_stmt (cfun, buffer->buffer->stream, stmt);
2130     }
2131
2132   dump_implicit_edges (buffer, bb, indent, flags);
2133
2134   if (flags & TDF_BLOCKS)
2135     dump_bb_end (buffer, bb, indent, flags);
2136 }
2137
2138
2139 /* Dumps basic block BB to FILE with details described by FLAGS and
2140    indented by INDENT spaces.  */
2141
2142 void
2143 gimple_dump_bb (basic_block bb, FILE *file, int indent, int flags)
2144 {
2145   maybe_init_pretty_print (file);
2146   gimple_dump_bb_buff (&buffer, bb, indent, flags);
2147   pp_flush (&buffer);
2148 }