OSDN Git Service

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