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