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