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