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