OSDN Git Service

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