PR target/81369
[official-gcc.git] / gcc / gimple-pretty-print.c
blob4012b3b9e2d445f0b88c26bd024e845ff8a5689a
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2017 Free Software Foundation, Inc.
3 Contributed by Aldy Hernandez <aldyh@redhat.com> and
4 Diego Novillo <dnovillo@google.com>
6 This file is part of GCC.
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.
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.
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/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "dumpfile.h"
26 #include "backend.h"
27 #include "tree.h"
28 #include "gimple.h"
29 #include "gimple-predict.h"
30 #include "ssa.h"
31 #include "cgraph.h"
32 #include "gimple-pretty-print.h"
33 #include "internal-fn.h"
34 #include "tree-eh.h"
35 #include "gimple-iterator.h"
36 #include "tree-cfg.h"
37 #include "dumpfile.h" /* for dump_flags */
38 #include "value-prof.h"
39 #include "trans-mem.h"
40 #include "cfganal.h"
41 #include "asan.h"
43 #define INDENT(SPACE) \
44 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
46 #define GIMPLE_NIY do_niy (buffer,gs)
48 /* Try to print on BUFFER a default message for the unrecognized
49 gimple statement GS. */
51 static void
52 do_niy (pretty_printer *buffer, gimple *gs)
54 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
55 gimple_code_name[(int) gimple_code (gs)]);
59 /* Emit a newline and SPC indentation spaces to BUFFER. */
61 static void
62 newline_and_indent (pretty_printer *buffer, int spc)
64 pp_newline (buffer);
65 INDENT (spc);
69 /* Print the GIMPLE statement GS on stderr. */
71 DEBUG_FUNCTION void
72 debug_gimple_stmt (gimple *gs)
74 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
78 /* Return formatted string of a VALUE probability
79 (biased by REG_BR_PROB_BASE). Returned string is allocated
80 by xstrdup_for_dump. */
82 static const char *
83 dump_profile (int frequency, profile_count &count)
85 float minimum = 0.01f;
87 gcc_assert (0 <= frequency && frequency <= REG_BR_PROB_BASE);
88 float fvalue = frequency * 100.0f / REG_BR_PROB_BASE;
89 if (fvalue < minimum && frequency > 0)
90 return "[0.01%]";
92 char *buf;
93 if (count.initialized_p ())
94 asprintf (&buf, "[%.2f%%] [count: %" PRId64 "]", fvalue,
95 count.to_gcov_type ());
96 else
97 asprintf (&buf, "[%.2f%%] [count: INV]", fvalue);
99 const char *ret = xstrdup_for_dump (buf);
100 free (buf);
102 return ret;
105 /* Return formatted string of a VALUE probability
106 (biased by REG_BR_PROB_BASE). Returned string is allocated
107 by xstrdup_for_dump. */
109 static const char *
110 dump_probability (profile_probability probability, profile_count &count)
112 float minimum = 0.01f;
113 float fvalue = -1;
115 if (probability.initialized_p ())
117 fvalue = probability.to_reg_br_prob_base () * 100.0f / REG_BR_PROB_BASE;
118 if (fvalue < minimum && probability.to_reg_br_prob_base ())
119 fvalue = minimum;
122 char *buf;
123 if (count.initialized_p ())
124 asprintf (&buf, "[%.2f%%] [count: %" PRId64 "]", fvalue,
125 count.to_gcov_type ());
126 else if (probability.initialized_p ())
127 asprintf (&buf, "[%.2f%%] [count: INV]", fvalue);
128 else
129 asprintf (&buf, "[INV] [count: INV]");
131 const char *ret = xstrdup_for_dump (buf);
132 free (buf);
134 return ret;
137 /* Dump E probability to BUFFER. */
139 static void
140 dump_edge_probability (pretty_printer *buffer, edge e)
142 pp_scalar (buffer, " %s", dump_probability (e->probability, e->count));
145 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
146 FLAGS as in pp_gimple_stmt_1. */
148 void
149 print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
151 pretty_printer buffer;
152 pp_needs_newline (&buffer) = true;
153 buffer.buffer->stream = file;
154 pp_gimple_stmt_1 (&buffer, g, spc, flags);
155 pp_newline_and_flush (&buffer);
158 DEBUG_FUNCTION void
159 debug (gimple &ref)
161 print_gimple_stmt (stderr, &ref, 0, 0);
164 DEBUG_FUNCTION void
165 debug (gimple *ptr)
167 if (ptr)
168 debug (*ptr);
169 else
170 fprintf (stderr, "<nil>\n");
174 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
175 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
176 of the statement. */
178 void
179 print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
181 flags |= TDF_RHS_ONLY;
182 pretty_printer buffer;
183 pp_needs_newline (&buffer) = true;
184 buffer.buffer->stream = file;
185 pp_gimple_stmt_1 (&buffer, g, spc, flags);
186 pp_flush (&buffer);
190 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
191 spaces and FLAGS as in pp_gimple_stmt_1.
192 The caller is responsible for calling pp_flush on BUFFER to finalize
193 the pretty printer. */
195 static void
196 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc,
197 dump_flags_t flags)
199 gimple_stmt_iterator i;
201 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
203 gimple *gs = gsi_stmt (i);
204 INDENT (spc);
205 pp_gimple_stmt_1 (buffer, gs, spc, flags);
206 if (!gsi_one_before_end_p (i))
207 pp_newline (buffer);
212 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
213 FLAGS as in pp_gimple_stmt_1. */
215 void
216 print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
218 pretty_printer buffer;
219 pp_needs_newline (&buffer) = true;
220 buffer.buffer->stream = file;
221 dump_gimple_seq (&buffer, seq, spc, flags);
222 pp_newline_and_flush (&buffer);
226 /* Print the GIMPLE sequence SEQ on stderr. */
228 DEBUG_FUNCTION void
229 debug_gimple_seq (gimple_seq seq)
231 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
235 /* A simple helper to pretty-print some of the gimple tuples in the printf
236 style. The format modifiers are preceded by '%' and are:
237 'G' - outputs a string corresponding to the code of the given gimple,
238 'S' - outputs a gimple_seq with indent of spc + 2,
239 'T' - outputs the tree t,
240 'd' - outputs an int as a decimal,
241 's' - outputs a string,
242 'n' - outputs a newline,
243 'x' - outputs an int as hexadecimal,
244 '+' - increases indent by 2 then outputs a newline,
245 '-' - decreases indent by 2 then outputs a newline. */
247 static void
248 dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags,
249 const char *fmt, ...)
251 va_list args;
252 const char *c;
253 const char *tmp;
255 va_start (args, fmt);
256 for (c = fmt; *c; c++)
258 if (*c == '%')
260 gimple_seq seq;
261 tree t;
262 gimple *g;
263 switch (*++c)
265 case 'G':
266 g = va_arg (args, gimple *);
267 tmp = gimple_code_name[gimple_code (g)];
268 pp_string (buffer, tmp);
269 break;
271 case 'S':
272 seq = va_arg (args, gimple_seq);
273 pp_newline (buffer);
274 dump_gimple_seq (buffer, seq, spc + 2, flags);
275 newline_and_indent (buffer, spc);
276 break;
278 case 'T':
279 t = va_arg (args, tree);
280 if (t == NULL_TREE)
281 pp_string (buffer, "NULL");
282 else
283 dump_generic_node (buffer, t, spc, flags, false);
284 break;
286 case 'd':
287 pp_decimal_int (buffer, va_arg (args, int));
288 break;
290 case 's':
291 pp_string (buffer, va_arg (args, char *));
292 break;
294 case 'n':
295 newline_and_indent (buffer, spc);
296 break;
298 case 'x':
299 pp_scalar (buffer, "%x", va_arg (args, int));
300 break;
302 case '+':
303 spc += 2;
304 newline_and_indent (buffer, spc);
305 break;
307 case '-':
308 spc -= 2;
309 newline_and_indent (buffer, spc);
310 break;
312 default:
313 gcc_unreachable ();
316 else
317 pp_character (buffer, *c);
319 va_end (args);
323 /* Helper for dump_gimple_assign. Print the unary RHS of the
324 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
326 static void
327 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc,
328 dump_flags_t flags)
330 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
331 tree lhs = gimple_assign_lhs (gs);
332 tree rhs = gimple_assign_rhs1 (gs);
334 switch (rhs_code)
336 case VIEW_CONVERT_EXPR:
337 case ASSERT_EXPR:
338 dump_generic_node (buffer, rhs, spc, flags, false);
339 break;
341 case FIXED_CONVERT_EXPR:
342 case ADDR_SPACE_CONVERT_EXPR:
343 case FIX_TRUNC_EXPR:
344 case FLOAT_EXPR:
345 CASE_CONVERT:
346 pp_left_paren (buffer);
347 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
348 pp_string (buffer, ") ");
349 if (op_prio (rhs) < op_code_prio (rhs_code))
351 pp_left_paren (buffer);
352 dump_generic_node (buffer, rhs, spc, flags, false);
353 pp_right_paren (buffer);
355 else
356 dump_generic_node (buffer, rhs, spc, flags, false);
357 break;
359 case PAREN_EXPR:
360 pp_string (buffer, "((");
361 dump_generic_node (buffer, rhs, spc, flags, false);
362 pp_string (buffer, "))");
363 break;
365 case ABS_EXPR:
366 if (flags & TDF_GIMPLE)
368 pp_string (buffer, "__ABS ");
369 dump_generic_node (buffer, rhs, spc, flags, false);
371 else
373 pp_string (buffer, "ABS_EXPR <");
374 dump_generic_node (buffer, rhs, spc, flags, false);
375 pp_greater (buffer);
377 break;
379 default:
380 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
381 || TREE_CODE_CLASS (rhs_code) == tcc_constant
382 || TREE_CODE_CLASS (rhs_code) == tcc_reference
383 || rhs_code == SSA_NAME
384 || rhs_code == ADDR_EXPR
385 || rhs_code == CONSTRUCTOR)
387 dump_generic_node (buffer, rhs, spc, flags, false);
388 break;
390 else if (rhs_code == BIT_NOT_EXPR)
391 pp_complement (buffer);
392 else if (rhs_code == TRUTH_NOT_EXPR)
393 pp_exclamation (buffer);
394 else if (rhs_code == NEGATE_EXPR)
395 pp_minus (buffer);
396 else
398 pp_left_bracket (buffer);
399 pp_string (buffer, get_tree_code_name (rhs_code));
400 pp_string (buffer, "] ");
403 if (op_prio (rhs) < op_code_prio (rhs_code))
405 pp_left_paren (buffer);
406 dump_generic_node (buffer, rhs, spc, flags, false);
407 pp_right_paren (buffer);
409 else
410 dump_generic_node (buffer, rhs, spc, flags, false);
411 break;
416 /* Helper for dump_gimple_assign. Print the binary RHS of the
417 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
419 static void
420 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc,
421 dump_flags_t flags)
423 const char *p;
424 enum tree_code code = gimple_assign_rhs_code (gs);
425 switch (code)
427 case COMPLEX_EXPR:
428 case MIN_EXPR:
429 case MAX_EXPR:
430 case VEC_WIDEN_MULT_HI_EXPR:
431 case VEC_WIDEN_MULT_LO_EXPR:
432 case VEC_WIDEN_MULT_EVEN_EXPR:
433 case VEC_WIDEN_MULT_ODD_EXPR:
434 case VEC_PACK_TRUNC_EXPR:
435 case VEC_PACK_SAT_EXPR:
436 case VEC_PACK_FIX_TRUNC_EXPR:
437 case VEC_WIDEN_LSHIFT_HI_EXPR:
438 case VEC_WIDEN_LSHIFT_LO_EXPR:
439 for (p = get_tree_code_name (code); *p; p++)
440 pp_character (buffer, TOUPPER (*p));
441 pp_string (buffer, " <");
442 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
443 pp_string (buffer, ", ");
444 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
445 pp_greater (buffer);
446 break;
448 default:
449 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
451 pp_left_paren (buffer);
452 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
453 false);
454 pp_right_paren (buffer);
456 else
457 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
458 pp_space (buffer);
459 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
460 pp_space (buffer);
461 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
463 pp_left_paren (buffer);
464 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
465 false);
466 pp_right_paren (buffer);
468 else
469 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
473 /* Helper for dump_gimple_assign. Print the ternary RHS of the
474 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
476 static void
477 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc,
478 dump_flags_t flags)
480 const char *p;
481 enum tree_code code = gimple_assign_rhs_code (gs);
482 switch (code)
484 case WIDEN_MULT_PLUS_EXPR:
485 case WIDEN_MULT_MINUS_EXPR:
486 for (p = get_tree_code_name (code); *p; p++)
487 pp_character (buffer, TOUPPER (*p));
488 pp_string (buffer, " <");
489 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
490 pp_string (buffer, ", ");
491 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
492 pp_string (buffer, ", ");
493 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
494 pp_greater (buffer);
495 break;
497 case FMA_EXPR:
498 if (flags & TDF_GIMPLE)
500 pp_string (buffer, "__FMA (");
501 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
502 pp_comma (buffer);
503 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
504 pp_comma (buffer);
505 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
506 pp_right_paren (buffer);
508 else
510 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
511 pp_string (buffer, " * ");
512 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
513 pp_string (buffer, " + ");
514 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
516 break;
518 case DOT_PROD_EXPR:
519 pp_string (buffer, "DOT_PROD_EXPR <");
520 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
521 pp_string (buffer, ", ");
522 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
523 pp_string (buffer, ", ");
524 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
525 pp_greater (buffer);
526 break;
528 case SAD_EXPR:
529 pp_string (buffer, "SAD_EXPR <");
530 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
531 pp_string (buffer, ", ");
532 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
533 pp_string (buffer, ", ");
534 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
535 pp_greater (buffer);
536 break;
538 case VEC_PERM_EXPR:
539 pp_string (buffer, "VEC_PERM_EXPR <");
540 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
541 pp_string (buffer, ", ");
542 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
543 pp_string (buffer, ", ");
544 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
545 pp_greater (buffer);
546 break;
548 case REALIGN_LOAD_EXPR:
549 pp_string (buffer, "REALIGN_LOAD <");
550 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
551 pp_string (buffer, ", ");
552 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
553 pp_string (buffer, ", ");
554 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
555 pp_greater (buffer);
556 break;
558 case COND_EXPR:
559 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
560 pp_string (buffer, " ? ");
561 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
562 pp_string (buffer, " : ");
563 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
564 break;
566 case VEC_COND_EXPR:
567 pp_string (buffer, "VEC_COND_EXPR <");
568 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
569 pp_string (buffer, ", ");
570 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
571 pp_string (buffer, ", ");
572 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
573 pp_greater (buffer);
574 break;
576 case BIT_INSERT_EXPR:
577 pp_string (buffer, "BIT_INSERT_EXPR <");
578 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
579 pp_string (buffer, ", ");
580 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
581 pp_string (buffer, ", ");
582 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
583 pp_string (buffer, " (");
584 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
585 pp_decimal_int (buffer,
586 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
587 else
588 dump_generic_node (buffer,
589 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
590 spc, flags, false);
591 pp_string (buffer, " bits)>");
592 break;
594 default:
595 gcc_unreachable ();
600 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
601 pp_gimple_stmt_1. */
603 static void
604 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc,
605 dump_flags_t flags)
607 if (flags & TDF_RAW)
609 tree arg1 = NULL;
610 tree arg2 = NULL;
611 tree arg3 = NULL;
612 switch (gimple_num_ops (gs))
614 case 4:
615 arg3 = gimple_assign_rhs3 (gs);
616 /* FALLTHRU */
617 case 3:
618 arg2 = gimple_assign_rhs2 (gs);
619 /* FALLTHRU */
620 case 2:
621 arg1 = gimple_assign_rhs1 (gs);
622 break;
623 default:
624 gcc_unreachable ();
627 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
628 get_tree_code_name (gimple_assign_rhs_code (gs)),
629 gimple_assign_lhs (gs), arg1, arg2, arg3);
631 else
633 if (!(flags & TDF_RHS_ONLY))
635 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
636 pp_space (buffer);
637 pp_equal (buffer);
639 if (gimple_assign_nontemporal_move_p (gs))
640 pp_string (buffer, "{nt}");
642 if (gimple_has_volatile_ops (gs))
643 pp_string (buffer, "{v}");
645 pp_space (buffer);
648 if (gimple_num_ops (gs) == 2)
649 dump_unary_rhs (buffer, gs, spc, flags);
650 else if (gimple_num_ops (gs) == 3)
651 dump_binary_rhs (buffer, gs, spc, flags);
652 else if (gimple_num_ops (gs) == 4)
653 dump_ternary_rhs (buffer, gs, spc, flags);
654 else
655 gcc_unreachable ();
656 if (!(flags & TDF_RHS_ONLY))
657 pp_semicolon (buffer);
662 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
663 pp_gimple_stmt_1. */
665 static void
666 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc,
667 dump_flags_t flags)
669 tree t, t2;
671 t = gimple_return_retval (gs);
672 t2 = gimple_return_retbnd (gs);
673 if (flags & TDF_RAW)
674 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
675 else
677 pp_string (buffer, "return");
678 if (t)
680 pp_space (buffer);
681 dump_generic_node (buffer, t, spc, flags, false);
683 if (t2)
685 pp_string (buffer, ", ");
686 dump_generic_node (buffer, t2, spc, flags, false);
688 pp_semicolon (buffer);
693 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
694 dump_gimple_call. */
696 static void
697 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, dump_flags_t flags)
699 size_t i = 0;
701 /* Pretty print first arg to certain internal fns. */
702 if (gimple_call_internal_p (gs))
704 const char *const *enums = NULL;
705 unsigned limit = 0;
707 switch (gimple_call_internal_fn (gs))
709 case IFN_UNIQUE:
710 #define DEF(X) #X
711 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
712 #undef DEF
713 enums = unique_args;
715 limit = ARRAY_SIZE (unique_args);
716 break;
718 case IFN_GOACC_LOOP:
719 #define DEF(X) #X
720 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
721 #undef DEF
722 enums = loop_args;
723 limit = ARRAY_SIZE (loop_args);
724 break;
726 case IFN_GOACC_REDUCTION:
727 #define DEF(X) #X
728 static const char *const reduction_args[]
729 = {IFN_GOACC_REDUCTION_CODES};
730 #undef DEF
731 enums = reduction_args;
732 limit = ARRAY_SIZE (reduction_args);
733 break;
735 case IFN_ASAN_MARK:
736 #define DEF(X) #X
737 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
738 #undef DEF
739 enums = asan_mark_args;
740 limit = ARRAY_SIZE (asan_mark_args);
741 break;
743 default:
744 break;
746 if (limit)
748 tree arg0 = gimple_call_arg (gs, 0);
749 HOST_WIDE_INT v;
751 if (TREE_CODE (arg0) == INTEGER_CST
752 && tree_fits_shwi_p (arg0)
753 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
755 i++;
756 pp_string (buffer, enums[v]);
761 for (; i < gimple_call_num_args (gs); i++)
763 if (i)
764 pp_string (buffer, ", ");
765 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
768 if (gimple_call_va_arg_pack_p (gs))
770 if (i)
771 pp_string (buffer, ", ");
773 pp_string (buffer, "__builtin_va_arg_pack ()");
777 /* Dump the points-to solution *PT to BUFFER. */
779 static void
780 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
782 if (pt->anything)
784 pp_string (buffer, "anything ");
785 return;
787 if (pt->nonlocal)
788 pp_string (buffer, "nonlocal ");
789 if (pt->escaped)
790 pp_string (buffer, "escaped ");
791 if (pt->ipa_escaped)
792 pp_string (buffer, "unit-escaped ");
793 if (pt->null)
794 pp_string (buffer, "null ");
795 if (pt->vars
796 && !bitmap_empty_p (pt->vars))
798 bitmap_iterator bi;
799 unsigned i;
800 pp_string (buffer, "{ ");
801 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
803 pp_string (buffer, "D.");
804 pp_decimal_int (buffer, i);
805 pp_space (buffer);
807 pp_right_brace (buffer);
808 if (pt->vars_contains_nonlocal
809 || pt->vars_contains_escaped
810 || pt->vars_contains_escaped_heap
811 || pt->vars_contains_restrict)
813 const char *comma = "";
814 pp_string (buffer, " (");
815 if (pt->vars_contains_nonlocal)
817 pp_string (buffer, "nonlocal");
818 comma = ", ";
820 if (pt->vars_contains_escaped)
822 pp_string (buffer, comma);
823 pp_string (buffer, "escaped");
824 comma = ", ";
826 if (pt->vars_contains_escaped_heap)
828 pp_string (buffer, comma);
829 pp_string (buffer, "escaped heap");
830 comma = ", ";
832 if (pt->vars_contains_restrict)
834 pp_string (buffer, comma);
835 pp_string (buffer, "restrict");
836 comma = ", ";
838 if (pt->vars_contains_interposable)
840 pp_string (buffer, comma);
841 pp_string (buffer, "interposable");
843 pp_string (buffer, ")");
849 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
850 pp_gimple_stmt_1. */
852 static void
853 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
854 dump_flags_t flags)
856 tree lhs = gimple_call_lhs (gs);
857 tree fn = gimple_call_fn (gs);
859 if (flags & TDF_ALIAS)
861 struct pt_solution *pt;
862 pt = gimple_call_use_set (gs);
863 if (!pt_solution_empty_p (pt))
865 pp_string (buffer, "# USE = ");
866 pp_points_to_solution (buffer, pt);
867 newline_and_indent (buffer, spc);
869 pt = gimple_call_clobber_set (gs);
870 if (!pt_solution_empty_p (pt))
872 pp_string (buffer, "# CLB = ");
873 pp_points_to_solution (buffer, pt);
874 newline_and_indent (buffer, spc);
878 if (flags & TDF_RAW)
880 if (gimple_call_internal_p (gs))
881 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
882 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
883 else
884 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
885 if (gimple_call_num_args (gs) > 0)
887 pp_string (buffer, ", ");
888 dump_gimple_call_args (buffer, gs, flags);
890 pp_greater (buffer);
892 else
894 if (lhs && !(flags & TDF_RHS_ONLY))
896 dump_generic_node (buffer, lhs, spc, flags, false);
897 pp_string (buffer, " =");
899 if (gimple_has_volatile_ops (gs))
900 pp_string (buffer, "{v}");
902 pp_space (buffer);
904 if (gimple_call_internal_p (gs))
905 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
906 else
907 print_call_name (buffer, fn, flags);
908 pp_string (buffer, " (");
909 dump_gimple_call_args (buffer, gs, flags);
910 pp_right_paren (buffer);
911 if (!(flags & TDF_RHS_ONLY))
912 pp_semicolon (buffer);
915 if (gimple_call_chain (gs))
917 pp_string (buffer, " [static-chain: ");
918 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
919 pp_right_bracket (buffer);
922 if (gimple_call_return_slot_opt_p (gs))
923 pp_string (buffer, " [return slot optimization]");
924 if (gimple_call_tail_p (gs))
925 pp_string (buffer, " [tail call]");
926 if (gimple_call_must_tail_p (gs))
927 pp_string (buffer, " [must tail call]");
929 if (fn == NULL)
930 return;
932 /* Dump the arguments of _ITM_beginTransaction sanely. */
933 if (TREE_CODE (fn) == ADDR_EXPR)
934 fn = TREE_OPERAND (fn, 0);
935 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
936 pp_string (buffer, " [tm-clone]");
937 if (TREE_CODE (fn) == FUNCTION_DECL
938 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
939 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
940 && gimple_call_num_args (gs) > 0)
942 tree t = gimple_call_arg (gs, 0);
943 unsigned HOST_WIDE_INT props;
944 gcc_assert (TREE_CODE (t) == INTEGER_CST);
946 pp_string (buffer, " [ ");
948 /* Get the transaction code properties. */
949 props = TREE_INT_CST_LOW (t);
951 if (props & PR_INSTRUMENTEDCODE)
952 pp_string (buffer, "instrumentedCode ");
953 if (props & PR_UNINSTRUMENTEDCODE)
954 pp_string (buffer, "uninstrumentedCode ");
955 if (props & PR_HASNOXMMUPDATE)
956 pp_string (buffer, "hasNoXMMUpdate ");
957 if (props & PR_HASNOABORT)
958 pp_string (buffer, "hasNoAbort ");
959 if (props & PR_HASNOIRREVOCABLE)
960 pp_string (buffer, "hasNoIrrevocable ");
961 if (props & PR_DOESGOIRREVOCABLE)
962 pp_string (buffer, "doesGoIrrevocable ");
963 if (props & PR_HASNOSIMPLEREADS)
964 pp_string (buffer, "hasNoSimpleReads ");
965 if (props & PR_AWBARRIERSOMITTED)
966 pp_string (buffer, "awBarriersOmitted ");
967 if (props & PR_RARBARRIERSOMITTED)
968 pp_string (buffer, "RaRBarriersOmitted ");
969 if (props & PR_UNDOLOGCODE)
970 pp_string (buffer, "undoLogCode ");
971 if (props & PR_PREFERUNINSTRUMENTED)
972 pp_string (buffer, "preferUninstrumented ");
973 if (props & PR_EXCEPTIONBLOCK)
974 pp_string (buffer, "exceptionBlock ");
975 if (props & PR_HASELSE)
976 pp_string (buffer, "hasElse ");
977 if (props & PR_READONLY)
978 pp_string (buffer, "readOnly ");
980 pp_right_bracket (buffer);
985 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
986 pp_gimple_stmt_1. */
988 static void
989 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
990 dump_flags_t flags)
992 unsigned int i;
994 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
995 if (flags & TDF_RAW)
996 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
997 gimple_switch_index (gs));
998 else
1000 pp_string (buffer, "switch (");
1001 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
1002 if (flags & TDF_GIMPLE)
1003 pp_string (buffer, ") {");
1004 else
1005 pp_string (buffer, ") <");
1008 for (i = 0; i < gimple_switch_num_labels (gs); i++)
1010 tree case_label = gimple_switch_label (gs, i);
1011 gcc_checking_assert (case_label != NULL_TREE);
1012 dump_generic_node (buffer, case_label, spc, flags, false);
1013 pp_space (buffer);
1014 tree label = CASE_LABEL (case_label);
1015 dump_generic_node (buffer, label, spc, flags, false);
1017 if (cfun && cfun->cfg)
1019 basic_block dest = label_to_block (label);
1020 if (dest)
1022 edge label_edge = find_edge (gimple_bb (gs), dest);
1023 if (label_edge && !(flags & TDF_GIMPLE))
1024 dump_edge_probability (buffer, label_edge);
1028 if (i < gimple_switch_num_labels (gs) - 1)
1030 if (flags & TDF_GIMPLE)
1031 pp_string (buffer, "; ");
1032 else
1033 pp_string (buffer, ", ");
1036 if (flags & TDF_GIMPLE)
1037 pp_string (buffer, "; }");
1038 else
1039 pp_greater (buffer);
1043 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1044 pp_gimple_stmt_1. */
1046 static void
1047 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc,
1048 dump_flags_t flags)
1050 if (flags & TDF_RAW)
1051 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1052 get_tree_code_name (gimple_cond_code (gs)),
1053 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1054 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1055 else
1057 if (!(flags & TDF_RHS_ONLY))
1058 pp_string (buffer, "if (");
1059 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
1060 pp_space (buffer);
1061 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1062 pp_space (buffer);
1063 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
1064 if (!(flags & TDF_RHS_ONLY))
1066 edge_iterator ei;
1067 edge e, true_edge = NULL, false_edge = NULL;
1068 basic_block bb = gimple_bb (gs);
1070 if (bb)
1072 FOR_EACH_EDGE (e, ei, bb->succs)
1074 if (e->flags & EDGE_TRUE_VALUE)
1075 true_edge = e;
1076 else if (e->flags & EDGE_FALSE_VALUE)
1077 false_edge = e;
1081 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1083 pp_right_paren (buffer);
1085 if (gimple_cond_true_label (gs))
1087 pp_string (buffer, " goto ");
1088 dump_generic_node (buffer, gimple_cond_true_label (gs),
1089 spc, flags, false);
1090 if (has_edge_info && !(flags & TDF_GIMPLE))
1091 dump_edge_probability (buffer, true_edge);
1092 pp_semicolon (buffer);
1094 if (gimple_cond_false_label (gs))
1096 pp_string (buffer, " else goto ");
1097 dump_generic_node (buffer, gimple_cond_false_label (gs),
1098 spc, flags, false);
1099 if (has_edge_info && !(flags & TDF_GIMPLE))
1100 dump_edge_probability (buffer, false_edge);
1102 pp_semicolon (buffer);
1109 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1110 spaces of indent. FLAGS specifies details to show in the dump (see
1111 TDF_* in dumpfils.h). */
1113 static void
1114 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
1115 dump_flags_t flags)
1117 tree label = gimple_label_label (gs);
1118 if (flags & TDF_RAW)
1119 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1120 else
1122 dump_generic_node (buffer, label, spc, flags, false);
1123 basic_block bb = gimple_bb (gs);
1124 if (bb && !(flags & TDF_GIMPLE))
1125 pp_scalar (buffer, " %s", dump_profile (bb->frequency, bb->count));
1126 pp_colon (buffer);
1128 if (flags & TDF_GIMPLE)
1129 return;
1130 if (DECL_NONLOCAL (label))
1131 pp_string (buffer, " [non-local]");
1132 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1133 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1136 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1137 spaces of indent. FLAGS specifies details to show in the dump (see
1138 TDF_* in dumpfile.h). */
1140 static void
1141 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc,
1142 dump_flags_t flags)
1144 tree label = gimple_goto_dest (gs);
1145 if (flags & TDF_RAW)
1146 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1147 else
1148 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1152 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1153 spaces of indent. FLAGS specifies details to show in the dump (see
1154 TDF_* in dumpfile.h). */
1156 static void
1157 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc,
1158 dump_flags_t flags)
1160 if (flags & TDF_RAW)
1161 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1162 else
1163 pp_left_brace (buffer);
1164 if (!(flags & TDF_SLIM))
1166 tree var;
1168 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1170 newline_and_indent (buffer, 2);
1171 print_declaration (buffer, var, spc, flags);
1173 if (gimple_bind_vars (gs))
1174 pp_newline (buffer);
1176 pp_newline (buffer);
1177 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1178 newline_and_indent (buffer, spc);
1179 if (flags & TDF_RAW)
1180 pp_greater (buffer);
1181 else
1182 pp_right_brace (buffer);
1186 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1187 indent. FLAGS specifies details to show in the dump (see TDF_* in
1188 dumpfile.h). */
1190 static void
1191 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc,
1192 dump_flags_t flags)
1194 if (flags & TDF_RAW)
1196 const char *type;
1197 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1198 type = "GIMPLE_TRY_CATCH";
1199 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1200 type = "GIMPLE_TRY_FINALLY";
1201 else
1202 type = "UNKNOWN GIMPLE_TRY";
1203 dump_gimple_fmt (buffer, spc, flags,
1204 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1205 gimple_try_eval (gs), gimple_try_cleanup (gs));
1207 else
1209 pp_string (buffer, "try");
1210 newline_and_indent (buffer, spc + 2);
1211 pp_left_brace (buffer);
1212 pp_newline (buffer);
1214 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1215 newline_and_indent (buffer, spc + 2);
1216 pp_right_brace (buffer);
1218 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1220 newline_and_indent (buffer, spc);
1221 pp_string (buffer, "catch");
1222 newline_and_indent (buffer, spc + 2);
1223 pp_left_brace (buffer);
1225 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1227 newline_and_indent (buffer, spc);
1228 pp_string (buffer, "finally");
1229 newline_and_indent (buffer, spc + 2);
1230 pp_left_brace (buffer);
1232 else
1233 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1235 pp_newline (buffer);
1236 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1237 newline_and_indent (buffer, spc + 2);
1238 pp_right_brace (buffer);
1243 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1244 indent. FLAGS specifies details to show in the dump (see TDF_* in
1245 dumpfile.h). */
1247 static void
1248 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc,
1249 dump_flags_t flags)
1251 if (flags & TDF_RAW)
1252 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1253 gimple_catch_types (gs), gimple_catch_handler (gs));
1254 else
1255 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1256 gimple_catch_types (gs), gimple_catch_handler (gs));
1260 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1261 indent. FLAGS specifies details to show in the dump (see TDF_* in
1262 dumpfile.h). */
1264 static void
1265 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1266 dump_flags_t flags)
1268 if (flags & TDF_RAW)
1269 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1270 gimple_eh_filter_types (gs),
1271 gimple_eh_filter_failure (gs));
1272 else
1273 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1274 gimple_eh_filter_types (gs),
1275 gimple_eh_filter_failure (gs));
1279 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1281 static void
1282 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1283 geh_mnt *gs, int spc, dump_flags_t flags)
1285 if (flags & TDF_RAW)
1286 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1287 gimple_eh_must_not_throw_fndecl (gs));
1288 else
1289 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1290 gimple_eh_must_not_throw_fndecl (gs));
1294 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1295 indent. FLAGS specifies details to show in the dump (see TDF_* in
1296 dumpfile.h). */
1298 static void
1299 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1300 dump_flags_t flags)
1302 if (flags & TDF_RAW)
1303 dump_gimple_fmt (buffer, spc, flags,
1304 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1305 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1306 else
1307 dump_gimple_fmt (buffer, spc, flags,
1308 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1309 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1313 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1314 indent. FLAGS specifies details to show in the dump (see TDF_* in
1315 dumpfile.h). */
1317 static void
1318 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc,
1319 dump_flags_t flags)
1321 if (flags & TDF_RAW)
1322 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1323 gimple_resx_region (gs));
1324 else
1325 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1328 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1330 static void
1331 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc,
1332 dump_flags_t flags)
1334 if (flags & TDF_RAW)
1335 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1336 gimple_eh_dispatch_region (gs));
1337 else
1338 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1339 gimple_eh_dispatch_region (gs));
1342 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1343 of indent. FLAGS specifies details to show in the dump (see TDF_*
1344 in dumpfile.h). */
1346 static void
1347 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc,
1348 dump_flags_t flags)
1350 switch (gs->subcode)
1352 case GIMPLE_DEBUG_BIND:
1353 if (flags & TDF_RAW)
1354 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1355 gimple_debug_bind_get_var (gs),
1356 gimple_debug_bind_get_value (gs));
1357 else
1358 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1359 gimple_debug_bind_get_var (gs),
1360 gimple_debug_bind_get_value (gs));
1361 break;
1363 case GIMPLE_DEBUG_SOURCE_BIND:
1364 if (flags & TDF_RAW)
1365 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1366 gimple_debug_source_bind_get_var (gs),
1367 gimple_debug_source_bind_get_value (gs));
1368 else
1369 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1370 gimple_debug_source_bind_get_var (gs),
1371 gimple_debug_source_bind_get_value (gs));
1372 break;
1374 default:
1375 gcc_unreachable ();
1379 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1380 static void
1381 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc,
1382 dump_flags_t flags)
1384 size_t i;
1386 if (flags & TDF_RAW)
1388 const char *kind;
1389 switch (gimple_omp_for_kind (gs))
1391 case GF_OMP_FOR_KIND_FOR:
1392 kind = "";
1393 break;
1394 case GF_OMP_FOR_KIND_DISTRIBUTE:
1395 kind = " distribute";
1396 break;
1397 case GF_OMP_FOR_KIND_TASKLOOP:
1398 kind = " taskloop";
1399 break;
1400 case GF_OMP_FOR_KIND_CILKFOR:
1401 kind = " _Cilk_for";
1402 break;
1403 case GF_OMP_FOR_KIND_OACC_LOOP:
1404 kind = " oacc_loop";
1405 break;
1406 case GF_OMP_FOR_KIND_SIMD:
1407 kind = " simd";
1408 break;
1409 case GF_OMP_FOR_KIND_CILKSIMD:
1410 kind = " cilksimd";
1411 break;
1412 default:
1413 gcc_unreachable ();
1415 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1416 kind, gimple_omp_body (gs));
1417 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1418 dump_gimple_fmt (buffer, spc, flags, " >,");
1419 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1420 dump_gimple_fmt (buffer, spc, flags,
1421 "%+%T, %T, %T, %s, %T,%n",
1422 gimple_omp_for_index (gs, i),
1423 gimple_omp_for_initial (gs, i),
1424 gimple_omp_for_final (gs, i),
1425 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1426 gimple_omp_for_incr (gs, i));
1427 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1428 gimple_omp_for_pre_body (gs));
1430 else
1432 switch (gimple_omp_for_kind (gs))
1434 case GF_OMP_FOR_KIND_FOR:
1435 pp_string (buffer, "#pragma omp for");
1436 break;
1437 case GF_OMP_FOR_KIND_DISTRIBUTE:
1438 pp_string (buffer, "#pragma omp distribute");
1439 break;
1440 case GF_OMP_FOR_KIND_TASKLOOP:
1441 pp_string (buffer, "#pragma omp taskloop");
1442 break;
1443 case GF_OMP_FOR_KIND_CILKFOR:
1444 break;
1445 case GF_OMP_FOR_KIND_OACC_LOOP:
1446 pp_string (buffer, "#pragma acc loop");
1447 break;
1448 case GF_OMP_FOR_KIND_SIMD:
1449 pp_string (buffer, "#pragma omp simd");
1450 break;
1451 case GF_OMP_FOR_KIND_CILKSIMD:
1452 pp_string (buffer, "#pragma simd");
1453 break;
1454 case GF_OMP_FOR_KIND_GRID_LOOP:
1455 pp_string (buffer, "#pragma omp for grid_loop");
1456 break;
1457 default:
1458 gcc_unreachable ();
1460 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1461 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1462 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1464 if (i)
1465 spc += 2;
1466 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1467 pp_string (buffer, "_Cilk_for (");
1468 else
1470 newline_and_indent (buffer, spc);
1471 pp_string (buffer, "for (");
1473 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1474 flags, false);
1475 pp_string (buffer, " = ");
1476 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1477 flags, false);
1478 pp_string (buffer, "; ");
1480 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1481 flags, false);
1482 pp_space (buffer);
1483 switch (gimple_omp_for_cond (gs, i))
1485 case LT_EXPR:
1486 pp_less (buffer);
1487 break;
1488 case GT_EXPR:
1489 pp_greater (buffer);
1490 break;
1491 case LE_EXPR:
1492 pp_less_equal (buffer);
1493 break;
1494 case GE_EXPR:
1495 pp_greater_equal (buffer);
1496 break;
1497 case NE_EXPR:
1498 pp_string (buffer, "!=");
1499 break;
1500 default:
1501 gcc_unreachable ();
1503 pp_space (buffer);
1504 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1505 flags, false);
1506 pp_string (buffer, "; ");
1508 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1509 flags, false);
1510 pp_string (buffer, " = ");
1511 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1512 flags, false);
1513 pp_right_paren (buffer);
1516 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1518 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1519 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1520 newline_and_indent (buffer, spc + 2);
1521 pp_left_brace (buffer);
1522 pp_newline (buffer);
1523 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1524 newline_and_indent (buffer, spc + 2);
1525 pp_right_brace (buffer);
1530 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1532 static void
1533 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1534 int spc, dump_flags_t flags)
1536 if (flags & TDF_RAW)
1538 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1539 gimple_omp_continue_control_def (gs),
1540 gimple_omp_continue_control_use (gs));
1542 else
1544 pp_string (buffer, "#pragma omp continue (");
1545 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1546 spc, flags, false);
1547 pp_comma (buffer);
1548 pp_space (buffer);
1549 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1550 spc, flags, false);
1551 pp_right_paren (buffer);
1555 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1557 static void
1558 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1559 int spc, dump_flags_t flags)
1561 if (flags & TDF_RAW)
1563 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1564 gimple_omp_body (gs));
1565 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1566 dump_gimple_fmt (buffer, spc, flags, " >");
1568 else
1570 pp_string (buffer, "#pragma omp single");
1571 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1572 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1574 newline_and_indent (buffer, spc + 2);
1575 pp_left_brace (buffer);
1576 pp_newline (buffer);
1577 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1578 newline_and_indent (buffer, spc + 2);
1579 pp_right_brace (buffer);
1584 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1586 static void
1587 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1588 int spc, dump_flags_t flags)
1590 const char *kind;
1591 switch (gimple_omp_target_kind (gs))
1593 case GF_OMP_TARGET_KIND_REGION:
1594 kind = "";
1595 break;
1596 case GF_OMP_TARGET_KIND_DATA:
1597 kind = " data";
1598 break;
1599 case GF_OMP_TARGET_KIND_UPDATE:
1600 kind = " update";
1601 break;
1602 case GF_OMP_TARGET_KIND_ENTER_DATA:
1603 kind = " enter data";
1604 break;
1605 case GF_OMP_TARGET_KIND_EXIT_DATA:
1606 kind = " exit data";
1607 break;
1608 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1609 kind = " oacc_kernels";
1610 break;
1611 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1612 kind = " oacc_parallel";
1613 break;
1614 case GF_OMP_TARGET_KIND_OACC_DATA:
1615 kind = " oacc_data";
1616 break;
1617 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1618 kind = " oacc_update";
1619 break;
1620 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1621 kind = " oacc_enter_exit_data";
1622 break;
1623 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1624 kind = " oacc_declare";
1625 break;
1626 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1627 kind = " oacc_host_data";
1628 break;
1629 default:
1630 gcc_unreachable ();
1632 if (flags & TDF_RAW)
1634 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1635 kind, gimple_omp_body (gs));
1636 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1637 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1638 gimple_omp_target_child_fn (gs),
1639 gimple_omp_target_data_arg (gs));
1641 else
1643 pp_string (buffer, "#pragma omp target");
1644 pp_string (buffer, kind);
1645 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1646 if (gimple_omp_target_child_fn (gs))
1648 pp_string (buffer, " [child fn: ");
1649 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1650 spc, flags, false);
1651 pp_string (buffer, " (");
1652 if (gimple_omp_target_data_arg (gs))
1653 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1654 spc, flags, false);
1655 else
1656 pp_string (buffer, "???");
1657 pp_string (buffer, ")]");
1659 gimple_seq body = gimple_omp_body (gs);
1660 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1662 newline_and_indent (buffer, spc + 2);
1663 pp_left_brace (buffer);
1664 pp_newline (buffer);
1665 dump_gimple_seq (buffer, body, spc + 4, flags);
1666 newline_and_indent (buffer, spc + 2);
1667 pp_right_brace (buffer);
1669 else if (body)
1671 pp_newline (buffer);
1672 dump_gimple_seq (buffer, body, spc + 2, flags);
1677 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1679 static void
1680 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1681 dump_flags_t flags)
1683 if (flags & TDF_RAW)
1685 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1686 gimple_omp_body (gs));
1687 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1688 dump_gimple_fmt (buffer, spc, flags, " >");
1690 else
1692 pp_string (buffer, "#pragma omp teams");
1693 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1694 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1696 newline_and_indent (buffer, spc + 2);
1697 pp_character (buffer, '{');
1698 pp_newline (buffer);
1699 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1700 newline_and_indent (buffer, spc + 2);
1701 pp_character (buffer, '}');
1706 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1708 static void
1709 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1710 int spc, dump_flags_t flags)
1712 if (flags & TDF_RAW)
1714 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1715 gimple_omp_body (gs));
1716 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1717 dump_gimple_fmt (buffer, spc, flags, " >");
1719 else
1721 pp_string (buffer, "#pragma omp sections");
1722 if (gimple_omp_sections_control (gs))
1724 pp_string (buffer, " <");
1725 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1726 flags, false);
1727 pp_greater (buffer);
1729 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1730 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1732 newline_and_indent (buffer, spc + 2);
1733 pp_left_brace (buffer);
1734 pp_newline (buffer);
1735 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1736 newline_and_indent (buffer, spc + 2);
1737 pp_right_brace (buffer);
1742 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1743 pretty_printer BUFFER. */
1745 static void
1746 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc,
1747 dump_flags_t flags)
1749 if (flags & TDF_RAW)
1750 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1751 gimple_omp_body (gs));
1752 else
1754 switch (gimple_code (gs))
1756 case GIMPLE_OMP_MASTER:
1757 pp_string (buffer, "#pragma omp master");
1758 break;
1759 case GIMPLE_OMP_TASKGROUP:
1760 pp_string (buffer, "#pragma omp taskgroup");
1761 break;
1762 case GIMPLE_OMP_SECTION:
1763 pp_string (buffer, "#pragma omp section");
1764 break;
1765 case GIMPLE_OMP_GRID_BODY:
1766 pp_string (buffer, "#pragma omp gridified body");
1767 break;
1768 default:
1769 gcc_unreachable ();
1771 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1773 newline_and_indent (buffer, spc + 2);
1774 pp_left_brace (buffer);
1775 pp_newline (buffer);
1776 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1777 newline_and_indent (buffer, spc + 2);
1778 pp_right_brace (buffer);
1783 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1785 static void
1786 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1787 int spc, dump_flags_t flags)
1789 if (flags & TDF_RAW)
1790 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1791 gimple_omp_body (gs));
1792 else
1794 pp_string (buffer, "#pragma omp critical");
1795 if (gimple_omp_critical_name (gs))
1797 pp_string (buffer, " (");
1798 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1799 flags, false);
1800 pp_right_paren (buffer);
1802 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1803 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1805 newline_and_indent (buffer, spc + 2);
1806 pp_left_brace (buffer);
1807 pp_newline (buffer);
1808 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1809 newline_and_indent (buffer, spc + 2);
1810 pp_right_brace (buffer);
1815 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1817 static void
1818 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1819 int spc, dump_flags_t flags)
1821 if (flags & TDF_RAW)
1822 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1823 gimple_omp_body (gs));
1824 else
1826 pp_string (buffer, "#pragma omp ordered");
1827 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1828 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1830 newline_and_indent (buffer, spc + 2);
1831 pp_left_brace (buffer);
1832 pp_newline (buffer);
1833 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1834 newline_and_indent (buffer, spc + 2);
1835 pp_right_brace (buffer);
1840 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1842 static void
1843 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc,
1844 dump_flags_t flags)
1846 if (flags & TDF_RAW)
1848 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1849 (int) gimple_omp_return_nowait_p (gs));
1850 if (gimple_omp_return_lhs (gs))
1851 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1852 gimple_omp_return_lhs (gs));
1853 else
1854 dump_gimple_fmt (buffer, spc, flags, ">");
1856 else
1858 pp_string (buffer, "#pragma omp return");
1859 if (gimple_omp_return_nowait_p (gs))
1860 pp_string (buffer, "(nowait)");
1861 if (gimple_omp_return_lhs (gs))
1863 pp_string (buffer, " (set ");
1864 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1865 spc, flags, false);
1866 pp_character (buffer, ')');
1871 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1873 static void
1874 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1875 int spc, dump_flags_t flags)
1877 unsigned subcode = gimple_transaction_subcode (gs);
1879 if (flags & TDF_RAW)
1881 dump_gimple_fmt (buffer, spc, flags,
1882 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1883 "<%+BODY <%S> >",
1884 gs, subcode, gimple_transaction_label_norm (gs),
1885 gimple_transaction_label_uninst (gs),
1886 gimple_transaction_label_over (gs),
1887 gimple_transaction_body (gs));
1889 else
1891 if (subcode & GTMA_IS_OUTER)
1892 pp_string (buffer, "__transaction_atomic [[outer]]");
1893 else if (subcode & GTMA_IS_RELAXED)
1894 pp_string (buffer, "__transaction_relaxed");
1895 else
1896 pp_string (buffer, "__transaction_atomic");
1897 subcode &= ~GTMA_DECLARATION_MASK;
1899 if (gimple_transaction_body (gs))
1901 newline_and_indent (buffer, spc + 2);
1902 pp_left_brace (buffer);
1903 pp_newline (buffer);
1904 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1905 spc + 4, flags);
1906 newline_and_indent (buffer, spc + 2);
1907 pp_right_brace (buffer);
1909 else
1911 pp_string (buffer, " //");
1912 if (gimple_transaction_label_norm (gs))
1914 pp_string (buffer, " NORM=");
1915 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1916 spc, flags, false);
1918 if (gimple_transaction_label_uninst (gs))
1920 pp_string (buffer, " UNINST=");
1921 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1922 spc, flags, false);
1924 if (gimple_transaction_label_over (gs))
1926 pp_string (buffer, " OVER=");
1927 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1928 spc, flags, false);
1930 if (subcode)
1932 pp_string (buffer, " SUBCODE=[ ");
1933 if (subcode & GTMA_HAVE_ABORT)
1935 pp_string (buffer, "GTMA_HAVE_ABORT ");
1936 subcode &= ~GTMA_HAVE_ABORT;
1938 if (subcode & GTMA_HAVE_LOAD)
1940 pp_string (buffer, "GTMA_HAVE_LOAD ");
1941 subcode &= ~GTMA_HAVE_LOAD;
1943 if (subcode & GTMA_HAVE_STORE)
1945 pp_string (buffer, "GTMA_HAVE_STORE ");
1946 subcode &= ~GTMA_HAVE_STORE;
1948 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1950 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1951 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1953 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1955 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1956 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1958 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1960 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1961 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1963 if (subcode)
1964 pp_printf (buffer, "0x%x ", subcode);
1965 pp_right_bracket (buffer);
1971 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1972 indent. FLAGS specifies details to show in the dump (see TDF_* in
1973 dumpfile.h). */
1975 static void
1976 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, dump_flags_t flags)
1978 unsigned int i, n, f, fields;
1980 if (flags & TDF_RAW)
1982 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1983 gimple_asm_string (gs));
1985 n = gimple_asm_noutputs (gs);
1986 if (n)
1988 newline_and_indent (buffer, spc + 2);
1989 pp_string (buffer, "OUTPUT: ");
1990 for (i = 0; i < n; i++)
1992 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1993 spc, flags, false);
1994 if (i < n - 1)
1995 pp_string (buffer, ", ");
1999 n = gimple_asm_ninputs (gs);
2000 if (n)
2002 newline_and_indent (buffer, spc + 2);
2003 pp_string (buffer, "INPUT: ");
2004 for (i = 0; i < n; i++)
2006 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2007 spc, flags, false);
2008 if (i < n - 1)
2009 pp_string (buffer, ", ");
2013 n = gimple_asm_nclobbers (gs);
2014 if (n)
2016 newline_and_indent (buffer, spc + 2);
2017 pp_string (buffer, "CLOBBER: ");
2018 for (i = 0; i < n; i++)
2020 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2021 spc, flags, false);
2022 if (i < n - 1)
2023 pp_string (buffer, ", ");
2027 n = gimple_asm_nlabels (gs);
2028 if (n)
2030 newline_and_indent (buffer, spc + 2);
2031 pp_string (buffer, "LABEL: ");
2032 for (i = 0; i < n; i++)
2034 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2035 spc, flags, false);
2036 if (i < n - 1)
2037 pp_string (buffer, ", ");
2041 newline_and_indent (buffer, spc);
2042 pp_greater (buffer);
2044 else
2046 pp_string (buffer, "__asm__");
2047 if (gimple_asm_volatile_p (gs))
2048 pp_string (buffer, " __volatile__");
2049 if (gimple_asm_nlabels (gs))
2050 pp_string (buffer, " goto");
2051 pp_string (buffer, "(\"");
2052 pp_string (buffer, gimple_asm_string (gs));
2053 pp_string (buffer, "\"");
2055 if (gimple_asm_nlabels (gs))
2056 fields = 4;
2057 else if (gimple_asm_nclobbers (gs))
2058 fields = 3;
2059 else if (gimple_asm_ninputs (gs))
2060 fields = 2;
2061 else if (gimple_asm_noutputs (gs))
2062 fields = 1;
2063 else
2064 fields = 0;
2066 for (f = 0; f < fields; ++f)
2068 pp_string (buffer, " : ");
2070 switch (f)
2072 case 0:
2073 n = gimple_asm_noutputs (gs);
2074 for (i = 0; i < n; i++)
2076 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2077 spc, flags, false);
2078 if (i < n - 1)
2079 pp_string (buffer, ", ");
2081 break;
2083 case 1:
2084 n = gimple_asm_ninputs (gs);
2085 for (i = 0; i < n; i++)
2087 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2088 spc, flags, false);
2089 if (i < n - 1)
2090 pp_string (buffer, ", ");
2092 break;
2094 case 2:
2095 n = gimple_asm_nclobbers (gs);
2096 for (i = 0; i < n; i++)
2098 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2099 spc, flags, false);
2100 if (i < n - 1)
2101 pp_string (buffer, ", ");
2103 break;
2105 case 3:
2106 n = gimple_asm_nlabels (gs);
2107 for (i = 0; i < n; i++)
2109 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2110 spc, flags, false);
2111 if (i < n - 1)
2112 pp_string (buffer, ", ");
2114 break;
2116 default:
2117 gcc_unreachable ();
2121 pp_string (buffer, ");");
2125 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2126 SPC spaces of indent. */
2128 static void
2129 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2131 if (TREE_CODE (node) != SSA_NAME)
2132 return;
2134 if (POINTER_TYPE_P (TREE_TYPE (node))
2135 && SSA_NAME_PTR_INFO (node))
2137 unsigned int align, misalign;
2138 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2139 pp_string (buffer, "# PT = ");
2140 pp_points_to_solution (buffer, &pi->pt);
2141 newline_and_indent (buffer, spc);
2142 if (get_ptr_info_alignment (pi, &align, &misalign))
2144 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2145 newline_and_indent (buffer, spc);
2149 if (!POINTER_TYPE_P (TREE_TYPE (node))
2150 && SSA_NAME_RANGE_INFO (node))
2152 wide_int min, max, nonzero_bits;
2153 value_range_type range_type = get_range_info (node, &min, &max);
2155 if (range_type == VR_VARYING)
2156 pp_printf (buffer, "# RANGE VR_VARYING");
2157 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2159 pp_printf (buffer, "# RANGE ");
2160 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2161 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2162 pp_printf (buffer, ", ");
2163 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2164 pp_printf (buffer, "]");
2166 nonzero_bits = get_nonzero_bits (node);
2167 if (nonzero_bits != -1)
2169 pp_string (buffer, " NONZERO ");
2170 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2172 newline_and_indent (buffer, spc);
2176 /* As dump_ssaname_info, but dump to FILE. */
2178 void
2179 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2181 pretty_printer buffer;
2182 pp_needs_newline (&buffer) = true;
2183 buffer.buffer->stream = file;
2184 dump_ssaname_info (&buffer, node, spc);
2185 pp_flush (&buffer);
2188 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2189 The caller is responsible for calling pp_flush on BUFFER to finalize
2190 pretty printer. If COMMENT is true, print this after #. */
2192 static void
2193 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2194 dump_flags_t flags)
2196 size_t i;
2197 tree lhs = gimple_phi_result (phi);
2199 if (flags & TDF_ALIAS)
2200 dump_ssaname_info (buffer, lhs, spc);
2202 if (comment)
2203 pp_string (buffer, "# ");
2205 if (flags & TDF_RAW)
2206 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2207 gimple_phi_result (phi));
2208 else
2210 dump_generic_node (buffer, lhs, spc, flags, false);
2211 if (flags & TDF_GIMPLE)
2212 pp_string (buffer, " = __PHI (");
2213 else
2214 pp_string (buffer, " = PHI <");
2216 for (i = 0; i < gimple_phi_num_args (phi); i++)
2218 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2219 dump_location (buffer, gimple_phi_arg_location (phi, i));
2220 if (flags & TDF_GIMPLE)
2222 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2223 gimple *stmt = first_stmt (src);
2224 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2226 pp_string (buffer, "bb_");
2227 pp_decimal_int (buffer, src->index);
2229 else
2230 dump_generic_node (buffer, gimple_label_label (as_a <glabel *> (stmt)), 0, flags,
2231 false);
2232 pp_string (buffer, ": ");
2234 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2235 false);
2236 if (! (flags & TDF_GIMPLE))
2238 pp_left_paren (buffer);
2239 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2240 pp_right_paren (buffer);
2242 if (i < gimple_phi_num_args (phi) - 1)
2243 pp_string (buffer, ", ");
2245 if (flags & TDF_GIMPLE)
2246 pp_string (buffer, ");");
2247 else
2248 pp_greater (buffer);
2252 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2253 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2254 dumpfile.h). */
2256 static void
2257 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2258 int spc, dump_flags_t flags)
2260 if (flags & TDF_RAW)
2262 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2263 gimple_omp_body (gs));
2264 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2265 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2266 gimple_omp_parallel_child_fn (gs),
2267 gimple_omp_parallel_data_arg (gs));
2269 else
2271 gimple_seq body;
2272 pp_string (buffer, "#pragma omp parallel");
2273 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2274 if (gimple_omp_parallel_child_fn (gs))
2276 pp_string (buffer, " [child fn: ");
2277 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2278 spc, flags, false);
2279 pp_string (buffer, " (");
2280 if (gimple_omp_parallel_data_arg (gs))
2281 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2282 spc, flags, false);
2283 else
2284 pp_string (buffer, "???");
2285 pp_string (buffer, ")]");
2287 body = gimple_omp_body (gs);
2288 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2290 newline_and_indent (buffer, spc + 2);
2291 pp_left_brace (buffer);
2292 pp_newline (buffer);
2293 dump_gimple_seq (buffer, body, spc + 4, flags);
2294 newline_and_indent (buffer, spc + 2);
2295 pp_right_brace (buffer);
2297 else if (body)
2299 pp_newline (buffer);
2300 dump_gimple_seq (buffer, body, spc + 2, flags);
2306 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2307 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2308 dumpfile.h). */
2310 static void
2311 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2312 dump_flags_t flags)
2314 if (flags & TDF_RAW)
2316 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2317 gimple_omp_body (gs));
2318 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2319 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2320 gimple_omp_task_child_fn (gs),
2321 gimple_omp_task_data_arg (gs),
2322 gimple_omp_task_copy_fn (gs),
2323 gimple_omp_task_arg_size (gs),
2324 gimple_omp_task_arg_size (gs));
2326 else
2328 gimple_seq body;
2329 if (gimple_omp_task_taskloop_p (gs))
2330 pp_string (buffer, "#pragma omp taskloop");
2331 else
2332 pp_string (buffer, "#pragma omp task");
2333 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2334 if (gimple_omp_task_child_fn (gs))
2336 pp_string (buffer, " [child fn: ");
2337 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2338 spc, flags, false);
2339 pp_string (buffer, " (");
2340 if (gimple_omp_task_data_arg (gs))
2341 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2342 spc, flags, false);
2343 else
2344 pp_string (buffer, "???");
2345 pp_string (buffer, ")]");
2347 body = gimple_omp_body (gs);
2348 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2350 newline_and_indent (buffer, spc + 2);
2351 pp_left_brace (buffer);
2352 pp_newline (buffer);
2353 dump_gimple_seq (buffer, body, spc + 4, flags);
2354 newline_and_indent (buffer, spc + 2);
2355 pp_right_brace (buffer);
2357 else if (body)
2359 pp_newline (buffer);
2360 dump_gimple_seq (buffer, body, spc + 2, flags);
2366 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2367 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2368 in dumpfile.h). */
2370 static void
2371 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2372 int spc, dump_flags_t flags)
2374 if (flags & TDF_RAW)
2376 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2377 gimple_omp_atomic_load_lhs (gs),
2378 gimple_omp_atomic_load_rhs (gs));
2380 else
2382 pp_string (buffer, "#pragma omp atomic_load");
2383 if (gimple_omp_atomic_seq_cst_p (gs))
2384 pp_string (buffer, " seq_cst");
2385 if (gimple_omp_atomic_need_value_p (gs))
2386 pp_string (buffer, " [needed]");
2387 newline_and_indent (buffer, spc + 2);
2388 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2389 spc, flags, false);
2390 pp_space (buffer);
2391 pp_equal (buffer);
2392 pp_space (buffer);
2393 pp_star (buffer);
2394 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2395 spc, flags, false);
2399 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2400 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2401 in dumpfile.h). */
2403 static void
2404 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2405 gomp_atomic_store *gs, int spc,
2406 dump_flags_t flags)
2408 if (flags & TDF_RAW)
2410 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2411 gimple_omp_atomic_store_val (gs));
2413 else
2415 pp_string (buffer, "#pragma omp atomic_store ");
2416 if (gimple_omp_atomic_seq_cst_p (gs))
2417 pp_string (buffer, "seq_cst ");
2418 if (gimple_omp_atomic_need_value_p (gs))
2419 pp_string (buffer, "[needed] ");
2420 pp_left_paren (buffer);
2421 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2422 spc, flags, false);
2423 pp_right_paren (buffer);
2428 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2429 FLAGS are as in pp_gimple_stmt_1. */
2431 static void
2432 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc,
2433 dump_flags_t flags)
2435 tree vdef = gimple_vdef (gs);
2436 tree vuse = gimple_vuse (gs);
2438 if (vdef != NULL_TREE)
2440 pp_string (buffer, "# ");
2441 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2442 pp_string (buffer, " = VDEF <");
2443 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2444 pp_greater (buffer);
2445 newline_and_indent (buffer, spc);
2447 else if (vuse != NULL_TREE)
2449 pp_string (buffer, "# VUSE <");
2450 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2451 pp_greater (buffer);
2452 newline_and_indent (buffer, spc);
2457 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2458 spaces of indent. FLAGS specifies details to show in the dump (see
2459 TDF_* in dumpfile.h). The caller is responsible for calling
2460 pp_flush on BUFFER to finalize the pretty printer. */
2462 void
2463 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc,
2464 dump_flags_t flags)
2466 if (!gs)
2467 return;
2469 if (flags & TDF_STMTADDR)
2470 pp_printf (buffer, "<&%p> ", (void *) gs);
2472 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2473 dump_location (buffer, gimple_location (gs));
2475 if (flags & TDF_EH)
2477 int lp_nr = lookup_stmt_eh_lp (gs);
2478 if (lp_nr > 0)
2479 pp_printf (buffer, "[LP %d] ", lp_nr);
2480 else if (lp_nr < 0)
2481 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2484 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2485 && gimple_has_mem_ops (gs))
2486 dump_gimple_mem_ops (buffer, gs, spc, flags);
2488 if (gimple_has_lhs (gs)
2489 && (flags & TDF_ALIAS))
2490 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2492 switch (gimple_code (gs))
2494 case GIMPLE_ASM:
2495 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2496 break;
2498 case GIMPLE_ASSIGN:
2499 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2500 break;
2502 case GIMPLE_BIND:
2503 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2504 break;
2506 case GIMPLE_CALL:
2507 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2508 break;
2510 case GIMPLE_COND:
2511 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2512 break;
2514 case GIMPLE_LABEL:
2515 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2516 break;
2518 case GIMPLE_GOTO:
2519 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2520 break;
2522 case GIMPLE_NOP:
2523 pp_string (buffer, "GIMPLE_NOP");
2524 break;
2526 case GIMPLE_RETURN:
2527 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2528 break;
2530 case GIMPLE_SWITCH:
2531 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2532 break;
2534 case GIMPLE_TRY:
2535 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2536 break;
2538 case GIMPLE_PHI:
2539 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2540 break;
2542 case GIMPLE_OMP_PARALLEL:
2543 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2544 flags);
2545 break;
2547 case GIMPLE_OMP_TASK:
2548 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2549 break;
2551 case GIMPLE_OMP_ATOMIC_LOAD:
2552 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2553 spc, flags);
2554 break;
2556 case GIMPLE_OMP_ATOMIC_STORE:
2557 dump_gimple_omp_atomic_store (buffer,
2558 as_a <gomp_atomic_store *> (gs),
2559 spc, flags);
2560 break;
2562 case GIMPLE_OMP_FOR:
2563 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2564 break;
2566 case GIMPLE_OMP_CONTINUE:
2567 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2568 flags);
2569 break;
2571 case GIMPLE_OMP_SINGLE:
2572 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2573 flags);
2574 break;
2576 case GIMPLE_OMP_TARGET:
2577 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2578 flags);
2579 break;
2581 case GIMPLE_OMP_TEAMS:
2582 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2583 flags);
2584 break;
2586 case GIMPLE_OMP_RETURN:
2587 dump_gimple_omp_return (buffer, gs, spc, flags);
2588 break;
2590 case GIMPLE_OMP_SECTIONS:
2591 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2592 spc, flags);
2593 break;
2595 case GIMPLE_OMP_SECTIONS_SWITCH:
2596 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2597 break;
2599 case GIMPLE_OMP_MASTER:
2600 case GIMPLE_OMP_TASKGROUP:
2601 case GIMPLE_OMP_SECTION:
2602 case GIMPLE_OMP_GRID_BODY:
2603 dump_gimple_omp_block (buffer, gs, spc, flags);
2604 break;
2606 case GIMPLE_OMP_ORDERED:
2607 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2608 flags);
2609 break;
2611 case GIMPLE_OMP_CRITICAL:
2612 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2613 flags);
2614 break;
2616 case GIMPLE_CATCH:
2617 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2618 break;
2620 case GIMPLE_EH_FILTER:
2621 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2622 break;
2624 case GIMPLE_EH_MUST_NOT_THROW:
2625 dump_gimple_eh_must_not_throw (buffer,
2626 as_a <geh_mnt *> (gs),
2627 spc, flags);
2628 break;
2630 case GIMPLE_EH_ELSE:
2631 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2632 break;
2634 case GIMPLE_RESX:
2635 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2636 break;
2638 case GIMPLE_EH_DISPATCH:
2639 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2640 flags);
2641 break;
2643 case GIMPLE_DEBUG:
2644 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2645 break;
2647 case GIMPLE_PREDICT:
2648 pp_string (buffer, "// predicted ");
2649 if (gimple_predict_outcome (gs))
2650 pp_string (buffer, "likely by ");
2651 else
2652 pp_string (buffer, "unlikely by ");
2653 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2654 pp_string (buffer, " predictor.");
2655 break;
2657 case GIMPLE_TRANSACTION:
2658 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2659 flags);
2660 break;
2662 default:
2663 GIMPLE_NIY;
2668 /* Dumps header of basic block BB to OUTF indented by INDENT
2669 spaces and details described by flags. */
2671 static void
2672 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
2673 dump_flags_t flags)
2675 if (flags & TDF_BLOCKS)
2677 if (flags & TDF_LINENO)
2679 gimple_stmt_iterator gsi;
2681 fputs (";; ", outf);
2683 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2684 if (!is_gimple_debug (gsi_stmt (gsi))
2685 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2687 fprintf (outf, "%*sstarting at line %d",
2688 indent, "", get_lineno (gsi_stmt (gsi)));
2689 break;
2691 if (bb->discriminator)
2692 fprintf (outf, ", discriminator %i", bb->discriminator);
2693 fputc ('\n', outf);
2696 else
2698 gimple *stmt = first_stmt (bb);
2699 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2701 if (flags & TDF_GIMPLE)
2702 fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
2703 else
2704 fprintf (outf, "%*s<bb %d> %s:\n",
2705 indent, "", bb->index, dump_profile (bb->frequency,
2706 bb->count));
2712 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2713 spaces. */
2715 static void
2716 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2717 basic_block bb ATTRIBUTE_UNUSED,
2718 int indent ATTRIBUTE_UNUSED,
2719 dump_flags_t flags ATTRIBUTE_UNUSED)
2721 /* There is currently no GIMPLE-specific basic block info to dump. */
2722 return;
2726 /* Dump PHI nodes of basic block BB to BUFFER with details described
2727 by FLAGS and indented by INDENT spaces. */
2729 static void
2730 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
2731 dump_flags_t flags)
2733 gphi_iterator i;
2735 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2737 gphi *phi = i.phi ();
2738 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2740 INDENT (indent);
2741 dump_gimple_phi (buffer, phi, indent,
2742 (flags & TDF_GIMPLE) ? false : true, flags);
2743 pp_newline (buffer);
2749 /* Dump jump to basic block BB that is represented implicitly in the cfg
2750 to BUFFER. */
2752 static void
2753 pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
2755 if (flags & TDF_GIMPLE)
2757 pp_string (buffer, "goto bb_");
2758 pp_decimal_int (buffer, e->dest->index);
2759 pp_semicolon (buffer);
2761 else
2763 gimple *stmt = first_stmt (e->dest);
2765 pp_string (buffer, "goto <bb ");
2766 pp_decimal_int (buffer, e->dest->index);
2767 pp_greater (buffer);
2768 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2770 pp_string (buffer, " (");
2771 dump_generic_node (buffer,
2772 gimple_label_label (as_a <glabel *> (stmt)),
2773 0, 0, false);
2774 pp_right_paren (buffer);
2775 pp_semicolon (buffer);
2777 else
2778 pp_semicolon (buffer);
2780 dump_edge_probability (buffer, e);
2785 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2786 by INDENT spaces, with details given by FLAGS. */
2788 static void
2789 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2790 dump_flags_t flags)
2792 edge e;
2793 gimple *stmt;
2795 stmt = last_stmt (bb);
2797 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2799 edge true_edge, false_edge;
2801 /* When we are emitting the code or changing CFG, it is possible that
2802 the edges are not yet created. When we are using debug_bb in such
2803 a situation, we do not want it to crash. */
2804 if (EDGE_COUNT (bb->succs) != 2)
2805 return;
2806 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2808 INDENT (indent + 2);
2809 pp_cfg_jump (buffer, true_edge, flags);
2810 newline_and_indent (buffer, indent);
2811 pp_string (buffer, "else");
2812 newline_and_indent (buffer, indent + 2);
2813 pp_cfg_jump (buffer, false_edge, flags);
2814 pp_newline (buffer);
2815 return;
2818 /* If there is a fallthru edge, we may need to add an artificial
2819 goto to the dump. */
2820 e = find_fallthru_edge (bb->succs);
2822 if (e && e->dest != bb->next_bb)
2824 INDENT (indent);
2826 if ((flags & TDF_LINENO)
2827 && e->goto_locus != UNKNOWN_LOCATION)
2828 dump_location (buffer, e->goto_locus);
2830 pp_cfg_jump (buffer, e, flags);
2831 pp_newline (buffer);
2836 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2837 indented by INDENT spaces. */
2839 static void
2840 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2841 dump_flags_t flags)
2843 gimple_stmt_iterator gsi;
2844 gimple *stmt;
2845 int label_indent = indent - 2;
2847 if (label_indent < 0)
2848 label_indent = 0;
2850 dump_phi_nodes (buffer, bb, indent, flags);
2852 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2854 int curr_indent;
2856 stmt = gsi_stmt (gsi);
2858 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2860 INDENT (curr_indent);
2861 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2862 pp_newline_and_flush (buffer);
2863 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2864 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2865 pp_buffer (buffer)->stream, stmt);
2868 dump_implicit_edges (buffer, bb, indent, flags);
2869 pp_flush (buffer);
2873 /* Dumps basic block BB to FILE with details described by FLAGS and
2874 indented by INDENT spaces. */
2876 void
2877 gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
2879 dump_gimple_bb_header (file, bb, indent, flags);
2880 if (bb->index >= NUM_FIXED_BLOCKS)
2882 pretty_printer buffer;
2883 pp_needs_newline (&buffer) = true;
2884 buffer.buffer->stream = file;
2885 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2887 dump_gimple_bb_footer (file, bb, indent, flags);
2890 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2891 no indentation, for use as a label of a DOT graph record-node.
2892 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2893 histogram dumping doesn't know about pretty-printers. */
2895 void
2896 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2898 pp_printf (pp, "<bb %d>:\n", bb->index);
2899 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2901 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2902 gsi_next (&gsi))
2904 gphi *phi = gsi.phi ();
2905 if (!virtual_operand_p (gimple_phi_result (phi))
2906 || (dump_flags & TDF_VOPS))
2908 pp_bar (pp);
2909 pp_write_text_to_stream (pp);
2910 pp_string (pp, "# ");
2911 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2912 pp_newline (pp);
2913 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2917 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2918 gsi_next (&gsi))
2920 gimple *stmt = gsi_stmt (gsi);
2921 pp_bar (pp);
2922 pp_write_text_to_stream (pp);
2923 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2924 pp_newline (pp);
2925 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2927 dump_implicit_edges (pp, bb, 0, dump_flags);
2928 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);