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