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