PR libstdc++/85818 ensure path::preferred_separator is defined
[official-gcc.git] / gcc / gimple-pretty-print.c
blobafe01471a45cb0d73de270540dcb69982659c3f4
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2018 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 "stringpool.h"
42 #include "attribs.h"
43 #include "asan.h"
45 #define INDENT(SPACE) \
46 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
48 #define GIMPLE_NIY do_niy (buffer,gs)
50 /* Try to print on BUFFER a default message for the unrecognized
51 gimple statement GS. */
53 static void
54 do_niy (pretty_printer *buffer, gimple *gs)
56 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
57 gimple_code_name[(int) gimple_code (gs)]);
61 /* Emit a newline and SPC indentation spaces to BUFFER. */
63 static void
64 newline_and_indent (pretty_printer *buffer, int spc)
66 pp_newline (buffer);
67 INDENT (spc);
71 /* Print the GIMPLE statement GS on stderr. */
73 DEBUG_FUNCTION void
74 debug_gimple_stmt (gimple *gs)
76 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
80 /* Return formatted string of a VALUE probability
81 (biased by REG_BR_PROB_BASE). Returned string is allocated
82 by xstrdup_for_dump. */
84 static const char *
85 dump_profile (profile_count &count)
87 char *buf = NULL;
88 if (!count.initialized_p ())
89 return "";
90 if (count.ipa_p ())
91 buf = xasprintf ("[count: %" PRId64 "]",
92 count.to_gcov_type ());
93 else if (count.initialized_p ())
94 buf = xasprintf ("[local count: %" PRId64 "]",
95 count.to_gcov_type ());
97 const char *ret = xstrdup_for_dump (buf);
98 free (buf);
100 return ret;
103 /* Return formatted string of a VALUE probability
104 (biased by REG_BR_PROB_BASE). Returned string is allocated
105 by xstrdup_for_dump. */
107 static const char *
108 dump_probability (profile_probability probability)
110 float minimum = 0.01f;
111 float fvalue = -1;
113 if (probability.initialized_p ())
115 fvalue = probability.to_reg_br_prob_base () * 100.0f / REG_BR_PROB_BASE;
116 if (fvalue < minimum && probability.to_reg_br_prob_base ())
117 fvalue = minimum;
120 char *buf;
121 if (probability.initialized_p ())
122 buf = xasprintf ("[%.2f%%]", fvalue);
123 else
124 buf = xasprintf ("[INV]");
126 const char *ret = xstrdup_for_dump (buf);
127 free (buf);
129 return ret;
132 /* Dump E probability to BUFFER. */
134 static void
135 dump_edge_probability (pretty_printer *buffer, edge e)
137 pp_scalar (buffer, " %s", dump_probability (e->probability));
140 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
141 FLAGS as in pp_gimple_stmt_1. */
143 void
144 print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
146 pretty_printer buffer;
147 pp_needs_newline (&buffer) = true;
148 buffer.buffer->stream = file;
149 pp_gimple_stmt_1 (&buffer, g, spc, flags);
150 pp_newline_and_flush (&buffer);
153 DEBUG_FUNCTION void
154 debug (gimple &ref)
156 print_gimple_stmt (stderr, &ref, 0, 0);
159 DEBUG_FUNCTION void
160 debug (gimple *ptr)
162 if (ptr)
163 debug (*ptr);
164 else
165 fprintf (stderr, "<nil>\n");
169 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
170 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
171 of the statement. */
173 void
174 print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
176 flags |= TDF_RHS_ONLY;
177 pretty_printer buffer;
178 pp_needs_newline (&buffer) = true;
179 buffer.buffer->stream = file;
180 pp_gimple_stmt_1 (&buffer, g, spc, flags);
181 pp_flush (&buffer);
185 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
186 spaces and FLAGS as in pp_gimple_stmt_1.
187 The caller is responsible for calling pp_flush on BUFFER to finalize
188 the pretty printer. */
190 static void
191 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc,
192 dump_flags_t flags)
194 gimple_stmt_iterator i;
196 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
198 gimple *gs = gsi_stmt (i);
199 INDENT (spc);
200 pp_gimple_stmt_1 (buffer, gs, spc, flags);
201 if (!gsi_one_before_end_p (i))
202 pp_newline (buffer);
207 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
208 FLAGS as in pp_gimple_stmt_1. */
210 void
211 print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
213 pretty_printer buffer;
214 pp_needs_newline (&buffer) = true;
215 buffer.buffer->stream = file;
216 dump_gimple_seq (&buffer, seq, spc, flags);
217 pp_newline_and_flush (&buffer);
221 /* Print the GIMPLE sequence SEQ on stderr. */
223 DEBUG_FUNCTION void
224 debug_gimple_seq (gimple_seq seq)
226 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
230 /* A simple helper to pretty-print some of the gimple tuples in the printf
231 style. The format modifiers are preceded by '%' and are:
232 'G' - outputs a string corresponding to the code of the given gimple,
233 'S' - outputs a gimple_seq with indent of spc + 2,
234 'T' - outputs the tree t,
235 'd' - outputs an int as a decimal,
236 's' - outputs a string,
237 'n' - outputs a newline,
238 'x' - outputs an int as hexadecimal,
239 '+' - increases indent by 2 then outputs a newline,
240 '-' - decreases indent by 2 then outputs a newline. */
242 static void
243 dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags,
244 const char *fmt, ...)
246 va_list args;
247 const char *c;
248 const char *tmp;
250 va_start (args, fmt);
251 for (c = fmt; *c; c++)
253 if (*c == '%')
255 gimple_seq seq;
256 tree t;
257 gimple *g;
258 switch (*++c)
260 case 'G':
261 g = va_arg (args, gimple *);
262 tmp = gimple_code_name[gimple_code (g)];
263 pp_string (buffer, tmp);
264 break;
266 case 'S':
267 seq = va_arg (args, gimple_seq);
268 pp_newline (buffer);
269 dump_gimple_seq (buffer, seq, spc + 2, flags);
270 newline_and_indent (buffer, spc);
271 break;
273 case 'T':
274 t = va_arg (args, tree);
275 if (t == NULL_TREE)
276 pp_string (buffer, "NULL");
277 else
278 dump_generic_node (buffer, t, spc, flags, false);
279 break;
281 case 'd':
282 pp_decimal_int (buffer, va_arg (args, int));
283 break;
285 case 's':
286 pp_string (buffer, va_arg (args, char *));
287 break;
289 case 'n':
290 newline_and_indent (buffer, spc);
291 break;
293 case 'x':
294 pp_scalar (buffer, "%x", va_arg (args, int));
295 break;
297 case '+':
298 spc += 2;
299 newline_and_indent (buffer, spc);
300 break;
302 case '-':
303 spc -= 2;
304 newline_and_indent (buffer, spc);
305 break;
307 default:
308 gcc_unreachable ();
311 else
312 pp_character (buffer, *c);
314 va_end (args);
318 /* Helper for dump_gimple_assign. Print the unary RHS of the
319 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
321 static void
322 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc,
323 dump_flags_t flags)
325 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
326 tree lhs = gimple_assign_lhs (gs);
327 tree rhs = gimple_assign_rhs1 (gs);
329 switch (rhs_code)
331 case VIEW_CONVERT_EXPR:
332 case ASSERT_EXPR:
333 dump_generic_node (buffer, rhs, spc, flags, false);
334 break;
336 case FIXED_CONVERT_EXPR:
337 case ADDR_SPACE_CONVERT_EXPR:
338 case FIX_TRUNC_EXPR:
339 case FLOAT_EXPR:
340 CASE_CONVERT:
341 pp_left_paren (buffer);
342 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
343 pp_string (buffer, ") ");
344 if (op_prio (rhs) < op_code_prio (rhs_code))
346 pp_left_paren (buffer);
347 dump_generic_node (buffer, rhs, spc, flags, false);
348 pp_right_paren (buffer);
350 else
351 dump_generic_node (buffer, rhs, spc, flags, false);
352 break;
354 case PAREN_EXPR:
355 pp_string (buffer, "((");
356 dump_generic_node (buffer, rhs, spc, flags, false);
357 pp_string (buffer, "))");
358 break;
360 case ABS_EXPR:
361 if (flags & TDF_GIMPLE)
363 pp_string (buffer, "__ABS ");
364 dump_generic_node (buffer, rhs, spc, flags, false);
366 else
368 pp_string (buffer, "ABS_EXPR <");
369 dump_generic_node (buffer, rhs, spc, flags, false);
370 pp_greater (buffer);
372 break;
374 default:
375 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
376 || TREE_CODE_CLASS (rhs_code) == tcc_constant
377 || TREE_CODE_CLASS (rhs_code) == tcc_reference
378 || rhs_code == SSA_NAME
379 || rhs_code == ADDR_EXPR
380 || rhs_code == CONSTRUCTOR)
382 dump_generic_node (buffer, rhs, spc, flags, false);
383 break;
385 else if (rhs_code == BIT_NOT_EXPR)
386 pp_complement (buffer);
387 else if (rhs_code == TRUTH_NOT_EXPR)
388 pp_exclamation (buffer);
389 else if (rhs_code == NEGATE_EXPR)
390 pp_minus (buffer);
391 else
393 pp_left_bracket (buffer);
394 pp_string (buffer, get_tree_code_name (rhs_code));
395 pp_string (buffer, "] ");
398 if (op_prio (rhs) < op_code_prio (rhs_code))
400 pp_left_paren (buffer);
401 dump_generic_node (buffer, rhs, spc, flags, false);
402 pp_right_paren (buffer);
404 else
405 dump_generic_node (buffer, rhs, spc, flags, false);
406 break;
411 /* Helper for dump_gimple_assign. Print the binary RHS of the
412 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
414 static void
415 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc,
416 dump_flags_t flags)
418 const char *p;
419 enum tree_code code = gimple_assign_rhs_code (gs);
420 switch (code)
422 case COMPLEX_EXPR:
423 case MIN_EXPR:
424 case MAX_EXPR:
425 case VEC_WIDEN_MULT_HI_EXPR:
426 case VEC_WIDEN_MULT_LO_EXPR:
427 case VEC_WIDEN_MULT_EVEN_EXPR:
428 case VEC_WIDEN_MULT_ODD_EXPR:
429 case VEC_PACK_TRUNC_EXPR:
430 case VEC_PACK_SAT_EXPR:
431 case VEC_PACK_FIX_TRUNC_EXPR:
432 case VEC_WIDEN_LSHIFT_HI_EXPR:
433 case VEC_WIDEN_LSHIFT_LO_EXPR:
434 case VEC_SERIES_EXPR:
435 for (p = get_tree_code_name (code); *p; p++)
436 pp_character (buffer, TOUPPER (*p));
437 pp_string (buffer, " <");
438 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
439 pp_string (buffer, ", ");
440 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
441 pp_greater (buffer);
442 break;
444 default:
445 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
447 pp_left_paren (buffer);
448 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
449 false);
450 pp_right_paren (buffer);
452 else
453 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
454 pp_space (buffer);
455 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
456 pp_space (buffer);
457 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
459 pp_left_paren (buffer);
460 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
461 false);
462 pp_right_paren (buffer);
464 else
465 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
469 /* Helper for dump_gimple_assign. Print the ternary RHS of the
470 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
472 static void
473 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc,
474 dump_flags_t flags)
476 const char *p;
477 enum tree_code code = gimple_assign_rhs_code (gs);
478 switch (code)
480 case WIDEN_MULT_PLUS_EXPR:
481 case WIDEN_MULT_MINUS_EXPR:
482 for (p = get_tree_code_name (code); *p; p++)
483 pp_character (buffer, TOUPPER (*p));
484 pp_string (buffer, " <");
485 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
486 pp_string (buffer, ", ");
487 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
488 pp_string (buffer, ", ");
489 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
490 pp_greater (buffer);
491 break;
493 case FMA_EXPR:
494 if (flags & TDF_GIMPLE)
496 pp_string (buffer, "__FMA (");
497 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
498 pp_comma (buffer);
499 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
500 pp_comma (buffer);
501 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
502 pp_right_paren (buffer);
504 else
506 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
507 pp_string (buffer, " * ");
508 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
509 pp_string (buffer, " + ");
510 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
512 break;
514 case DOT_PROD_EXPR:
515 pp_string (buffer, "DOT_PROD_EXPR <");
516 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
517 pp_string (buffer, ", ");
518 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
519 pp_string (buffer, ", ");
520 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
521 pp_greater (buffer);
522 break;
524 case SAD_EXPR:
525 pp_string (buffer, "SAD_EXPR <");
526 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
527 pp_string (buffer, ", ");
528 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
529 pp_string (buffer, ", ");
530 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
531 pp_greater (buffer);
532 break;
534 case VEC_PERM_EXPR:
535 pp_string (buffer, "VEC_PERM_EXPR <");
536 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
537 pp_string (buffer, ", ");
538 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
539 pp_string (buffer, ", ");
540 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
541 pp_greater (buffer);
542 break;
544 case REALIGN_LOAD_EXPR:
545 pp_string (buffer, "REALIGN_LOAD <");
546 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
547 pp_string (buffer, ", ");
548 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
549 pp_string (buffer, ", ");
550 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
551 pp_greater (buffer);
552 break;
554 case COND_EXPR:
555 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
556 pp_string (buffer, " ? ");
557 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
558 pp_string (buffer, " : ");
559 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
560 break;
562 case VEC_COND_EXPR:
563 pp_string (buffer, "VEC_COND_EXPR <");
564 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
565 pp_string (buffer, ", ");
566 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
567 pp_string (buffer, ", ");
568 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
569 pp_greater (buffer);
570 break;
572 case BIT_INSERT_EXPR:
573 pp_string (buffer, "BIT_INSERT_EXPR <");
574 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
575 pp_string (buffer, ", ");
576 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
577 pp_string (buffer, ", ");
578 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
579 pp_string (buffer, " (");
580 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
581 pp_decimal_int (buffer,
582 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
583 else
584 dump_generic_node (buffer,
585 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
586 spc, flags, false);
587 pp_string (buffer, " bits)>");
588 break;
590 default:
591 gcc_unreachable ();
596 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
597 pp_gimple_stmt_1. */
599 static void
600 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc,
601 dump_flags_t flags)
603 if (flags & TDF_RAW)
605 tree arg1 = NULL;
606 tree arg2 = NULL;
607 tree arg3 = NULL;
608 switch (gimple_num_ops (gs))
610 case 4:
611 arg3 = gimple_assign_rhs3 (gs);
612 /* FALLTHRU */
613 case 3:
614 arg2 = gimple_assign_rhs2 (gs);
615 /* FALLTHRU */
616 case 2:
617 arg1 = gimple_assign_rhs1 (gs);
618 break;
619 default:
620 gcc_unreachable ();
623 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
624 get_tree_code_name (gimple_assign_rhs_code (gs)),
625 gimple_assign_lhs (gs), arg1, arg2, arg3);
627 else
629 if (!(flags & TDF_RHS_ONLY))
631 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
632 pp_space (buffer);
633 pp_equal (buffer);
635 if (gimple_assign_nontemporal_move_p (gs))
636 pp_string (buffer, "{nt}");
638 if (gimple_has_volatile_ops (gs))
639 pp_string (buffer, "{v}");
641 pp_space (buffer);
644 if (gimple_num_ops (gs) == 2)
645 dump_unary_rhs (buffer, gs, spc, flags);
646 else if (gimple_num_ops (gs) == 3)
647 dump_binary_rhs (buffer, gs, spc, flags);
648 else if (gimple_num_ops (gs) == 4)
649 dump_ternary_rhs (buffer, gs, spc, flags);
650 else
651 gcc_unreachable ();
652 if (!(flags & TDF_RHS_ONLY))
653 pp_semicolon (buffer);
658 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
659 pp_gimple_stmt_1. */
661 static void
662 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc,
663 dump_flags_t flags)
665 tree t, t2;
667 t = gimple_return_retval (gs);
668 t2 = gimple_return_retbnd (gs);
669 if (flags & TDF_RAW)
670 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
671 else
673 pp_string (buffer, "return");
674 if (t)
676 pp_space (buffer);
677 dump_generic_node (buffer, t, spc, flags, false);
679 if (t2)
681 pp_string (buffer, ", ");
682 dump_generic_node (buffer, t2, spc, flags, false);
684 pp_semicolon (buffer);
689 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
690 dump_gimple_call. */
692 static void
693 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, dump_flags_t flags)
695 size_t i = 0;
697 /* Pretty print first arg to certain internal fns. */
698 if (gimple_call_internal_p (gs))
700 const char *const *enums = NULL;
701 unsigned limit = 0;
703 switch (gimple_call_internal_fn (gs))
705 case IFN_UNIQUE:
706 #define DEF(X) #X
707 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
708 #undef DEF
709 enums = unique_args;
711 limit = ARRAY_SIZE (unique_args);
712 break;
714 case IFN_GOACC_LOOP:
715 #define DEF(X) #X
716 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
717 #undef DEF
718 enums = loop_args;
719 limit = ARRAY_SIZE (loop_args);
720 break;
722 case IFN_GOACC_REDUCTION:
723 #define DEF(X) #X
724 static const char *const reduction_args[]
725 = {IFN_GOACC_REDUCTION_CODES};
726 #undef DEF
727 enums = reduction_args;
728 limit = ARRAY_SIZE (reduction_args);
729 break;
731 case IFN_ASAN_MARK:
732 #define DEF(X) #X
733 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
734 #undef DEF
735 enums = asan_mark_args;
736 limit = ARRAY_SIZE (asan_mark_args);
737 break;
739 default:
740 break;
742 if (limit)
744 tree arg0 = gimple_call_arg (gs, 0);
745 HOST_WIDE_INT v;
747 if (TREE_CODE (arg0) == INTEGER_CST
748 && tree_fits_shwi_p (arg0)
749 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
751 i++;
752 pp_string (buffer, enums[v]);
757 for (; i < gimple_call_num_args (gs); i++)
759 if (i)
760 pp_string (buffer, ", ");
761 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
764 if (gimple_call_va_arg_pack_p (gs))
766 if (i)
767 pp_string (buffer, ", ");
769 pp_string (buffer, "__builtin_va_arg_pack ()");
773 /* Dump the points-to solution *PT to BUFFER. */
775 static void
776 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
778 if (pt->anything)
780 pp_string (buffer, "anything ");
781 return;
783 if (pt->nonlocal)
784 pp_string (buffer, "nonlocal ");
785 if (pt->escaped)
786 pp_string (buffer, "escaped ");
787 if (pt->ipa_escaped)
788 pp_string (buffer, "unit-escaped ");
789 if (pt->null)
790 pp_string (buffer, "null ");
791 if (pt->vars
792 && !bitmap_empty_p (pt->vars))
794 bitmap_iterator bi;
795 unsigned i;
796 pp_string (buffer, "{ ");
797 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
799 pp_string (buffer, "D.");
800 pp_decimal_int (buffer, i);
801 pp_space (buffer);
803 pp_right_brace (buffer);
804 if (pt->vars_contains_nonlocal
805 || pt->vars_contains_escaped
806 || pt->vars_contains_escaped_heap
807 || pt->vars_contains_restrict)
809 const char *comma = "";
810 pp_string (buffer, " (");
811 if (pt->vars_contains_nonlocal)
813 pp_string (buffer, "nonlocal");
814 comma = ", ";
816 if (pt->vars_contains_escaped)
818 pp_string (buffer, comma);
819 pp_string (buffer, "escaped");
820 comma = ", ";
822 if (pt->vars_contains_escaped_heap)
824 pp_string (buffer, comma);
825 pp_string (buffer, "escaped heap");
826 comma = ", ";
828 if (pt->vars_contains_restrict)
830 pp_string (buffer, comma);
831 pp_string (buffer, "restrict");
832 comma = ", ";
834 if (pt->vars_contains_interposable)
836 pp_string (buffer, comma);
837 pp_string (buffer, "interposable");
839 pp_string (buffer, ")");
845 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
846 pp_gimple_stmt_1. */
848 static void
849 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
850 dump_flags_t flags)
852 tree lhs = gimple_call_lhs (gs);
853 tree fn = gimple_call_fn (gs);
855 if (flags & TDF_ALIAS)
857 struct pt_solution *pt;
858 pt = gimple_call_use_set (gs);
859 if (!pt_solution_empty_p (pt))
861 pp_string (buffer, "# USE = ");
862 pp_points_to_solution (buffer, pt);
863 newline_and_indent (buffer, spc);
865 pt = gimple_call_clobber_set (gs);
866 if (!pt_solution_empty_p (pt))
868 pp_string (buffer, "# CLB = ");
869 pp_points_to_solution (buffer, pt);
870 newline_and_indent (buffer, spc);
874 if (flags & TDF_RAW)
876 if (gimple_call_internal_p (gs))
877 dump_gimple_fmt (buffer, spc, flags, "%G <.%s, %T", gs,
878 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
879 else
880 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
881 if (gimple_call_num_args (gs) > 0)
883 pp_string (buffer, ", ");
884 dump_gimple_call_args (buffer, gs, flags);
886 pp_greater (buffer);
888 else
890 if (lhs && !(flags & TDF_RHS_ONLY))
892 dump_generic_node (buffer, lhs, spc, flags, false);
893 pp_string (buffer, " =");
895 if (gimple_has_volatile_ops (gs))
896 pp_string (buffer, "{v}");
898 pp_space (buffer);
900 if (gimple_call_internal_p (gs))
902 pp_dot (buffer);
903 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
905 else
906 print_call_name (buffer, fn, flags);
907 pp_string (buffer, " (");
908 dump_gimple_call_args (buffer, gs, flags);
909 pp_right_paren (buffer);
910 if (!(flags & TDF_RHS_ONLY))
911 pp_semicolon (buffer);
914 if (gimple_call_chain (gs))
916 pp_string (buffer, " [static-chain: ");
917 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
918 pp_right_bracket (buffer);
921 if (gimple_call_return_slot_opt_p (gs))
922 pp_string (buffer, " [return slot optimization]");
923 if (gimple_call_tail_p (gs))
924 pp_string (buffer, " [tail call]");
925 if (gimple_call_must_tail_p (gs))
926 pp_string (buffer, " [must tail call]");
928 if (fn == NULL)
929 return;
931 /* Dump the arguments of _ITM_beginTransaction sanely. */
932 if (TREE_CODE (fn) == ADDR_EXPR)
933 fn = TREE_OPERAND (fn, 0);
934 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
935 pp_string (buffer, " [tm-clone]");
936 if (TREE_CODE (fn) == FUNCTION_DECL
937 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
938 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
939 && gimple_call_num_args (gs) > 0)
941 tree t = gimple_call_arg (gs, 0);
942 unsigned HOST_WIDE_INT props;
943 gcc_assert (TREE_CODE (t) == INTEGER_CST);
945 pp_string (buffer, " [ ");
947 /* Get the transaction code properties. */
948 props = TREE_INT_CST_LOW (t);
950 if (props & PR_INSTRUMENTEDCODE)
951 pp_string (buffer, "instrumentedCode ");
952 if (props & PR_UNINSTRUMENTEDCODE)
953 pp_string (buffer, "uninstrumentedCode ");
954 if (props & PR_HASNOXMMUPDATE)
955 pp_string (buffer, "hasNoXMMUpdate ");
956 if (props & PR_HASNOABORT)
957 pp_string (buffer, "hasNoAbort ");
958 if (props & PR_HASNOIRREVOCABLE)
959 pp_string (buffer, "hasNoIrrevocable ");
960 if (props & PR_DOESGOIRREVOCABLE)
961 pp_string (buffer, "doesGoIrrevocable ");
962 if (props & PR_HASNOSIMPLEREADS)
963 pp_string (buffer, "hasNoSimpleReads ");
964 if (props & PR_AWBARRIERSOMITTED)
965 pp_string (buffer, "awBarriersOmitted ");
966 if (props & PR_RARBARRIERSOMITTED)
967 pp_string (buffer, "RaRBarriersOmitted ");
968 if (props & PR_UNDOLOGCODE)
969 pp_string (buffer, "undoLogCode ");
970 if (props & PR_PREFERUNINSTRUMENTED)
971 pp_string (buffer, "preferUninstrumented ");
972 if (props & PR_EXCEPTIONBLOCK)
973 pp_string (buffer, "exceptionBlock ");
974 if (props & PR_HASELSE)
975 pp_string (buffer, "hasElse ");
976 if (props & PR_READONLY)
977 pp_string (buffer, "readOnly ");
979 pp_right_bracket (buffer);
984 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
985 pp_gimple_stmt_1. */
987 static void
988 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
989 dump_flags_t flags)
991 unsigned int i;
993 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
994 if (flags & TDF_RAW)
995 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
996 gimple_switch_index (gs));
997 else
999 pp_string (buffer, "switch (");
1000 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
1001 if (flags & TDF_GIMPLE)
1002 pp_string (buffer, ") {");
1003 else
1004 pp_string (buffer, ") <");
1007 for (i = 0; i < gimple_switch_num_labels (gs); i++)
1009 tree case_label = gimple_switch_label (gs, i);
1010 gcc_checking_assert (case_label != NULL_TREE);
1011 dump_generic_node (buffer, case_label, spc, flags, false);
1012 pp_space (buffer);
1013 tree label = CASE_LABEL (case_label);
1014 dump_generic_node (buffer, label, spc, flags, false);
1016 if (cfun && cfun->cfg)
1018 basic_block dest = label_to_block (label);
1019 if (dest)
1021 edge label_edge = find_edge (gimple_bb (gs), dest);
1022 if (label_edge && !(flags & TDF_GIMPLE))
1023 dump_edge_probability (buffer, label_edge);
1027 if (i < gimple_switch_num_labels (gs) - 1)
1029 if (flags & TDF_GIMPLE)
1030 pp_string (buffer, "; ");
1031 else
1032 pp_string (buffer, ", ");
1035 if (flags & TDF_GIMPLE)
1036 pp_string (buffer, "; }");
1037 else
1038 pp_greater (buffer);
1042 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1043 pp_gimple_stmt_1. */
1045 static void
1046 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc,
1047 dump_flags_t flags)
1049 if (flags & TDF_RAW)
1050 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1051 get_tree_code_name (gimple_cond_code (gs)),
1052 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1053 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1054 else
1056 if (!(flags & TDF_RHS_ONLY))
1057 pp_string (buffer, "if (");
1058 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
1059 pp_space (buffer);
1060 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1061 pp_space (buffer);
1062 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
1063 if (!(flags & TDF_RHS_ONLY))
1065 edge_iterator ei;
1066 edge e, true_edge = NULL, false_edge = NULL;
1067 basic_block bb = gimple_bb (gs);
1069 if (bb)
1071 FOR_EACH_EDGE (e, ei, bb->succs)
1073 if (e->flags & EDGE_TRUE_VALUE)
1074 true_edge = e;
1075 else if (e->flags & EDGE_FALSE_VALUE)
1076 false_edge = e;
1080 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1082 pp_right_paren (buffer);
1084 if (gimple_cond_true_label (gs))
1086 pp_string (buffer, " goto ");
1087 dump_generic_node (buffer, gimple_cond_true_label (gs),
1088 spc, flags, false);
1089 if (has_edge_info && !(flags & TDF_GIMPLE))
1090 dump_edge_probability (buffer, true_edge);
1091 pp_semicolon (buffer);
1093 if (gimple_cond_false_label (gs))
1095 pp_string (buffer, " else goto ");
1096 dump_generic_node (buffer, gimple_cond_false_label (gs),
1097 spc, flags, false);
1098 if (has_edge_info && !(flags & TDF_GIMPLE))
1099 dump_edge_probability (buffer, false_edge);
1101 pp_semicolon (buffer);
1108 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1109 spaces of indent. FLAGS specifies details to show in the dump (see
1110 TDF_* in dumpfils.h). */
1112 static void
1113 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
1114 dump_flags_t flags)
1116 tree label = gimple_label_label (gs);
1117 if (flags & TDF_RAW)
1118 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1119 else
1121 dump_generic_node (buffer, label, spc, flags, false);
1122 pp_colon (buffer);
1124 if (flags & TDF_GIMPLE)
1125 return;
1126 if (DECL_NONLOCAL (label))
1127 pp_string (buffer, " [non-local]");
1128 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1129 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1132 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1133 spaces of indent. FLAGS specifies details to show in the dump (see
1134 TDF_* in dumpfile.h). */
1136 static void
1137 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc,
1138 dump_flags_t flags)
1140 tree label = gimple_goto_dest (gs);
1141 if (flags & TDF_RAW)
1142 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1143 else
1144 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1148 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1149 spaces of indent. FLAGS specifies details to show in the dump (see
1150 TDF_* in dumpfile.h). */
1152 static void
1153 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc,
1154 dump_flags_t flags)
1156 if (flags & TDF_RAW)
1157 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1158 else
1159 pp_left_brace (buffer);
1160 if (!(flags & TDF_SLIM))
1162 tree var;
1164 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1166 newline_and_indent (buffer, 2);
1167 print_declaration (buffer, var, spc, flags);
1169 if (gimple_bind_vars (gs))
1170 pp_newline (buffer);
1172 pp_newline (buffer);
1173 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1174 newline_and_indent (buffer, spc);
1175 if (flags & TDF_RAW)
1176 pp_greater (buffer);
1177 else
1178 pp_right_brace (buffer);
1182 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1183 indent. FLAGS specifies details to show in the dump (see TDF_* in
1184 dumpfile.h). */
1186 static void
1187 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc,
1188 dump_flags_t flags)
1190 if (flags & TDF_RAW)
1192 const char *type;
1193 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1194 type = "GIMPLE_TRY_CATCH";
1195 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1196 type = "GIMPLE_TRY_FINALLY";
1197 else
1198 type = "UNKNOWN GIMPLE_TRY";
1199 dump_gimple_fmt (buffer, spc, flags,
1200 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1201 gimple_try_eval (gs), gimple_try_cleanup (gs));
1203 else
1205 pp_string (buffer, "try");
1206 newline_and_indent (buffer, spc + 2);
1207 pp_left_brace (buffer);
1208 pp_newline (buffer);
1210 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1211 newline_and_indent (buffer, spc + 2);
1212 pp_right_brace (buffer);
1214 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1216 newline_and_indent (buffer, spc);
1217 pp_string (buffer, "catch");
1218 newline_and_indent (buffer, spc + 2);
1219 pp_left_brace (buffer);
1221 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1223 newline_and_indent (buffer, spc);
1224 pp_string (buffer, "finally");
1225 newline_and_indent (buffer, spc + 2);
1226 pp_left_brace (buffer);
1228 else
1229 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1231 pp_newline (buffer);
1232 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1233 newline_and_indent (buffer, spc + 2);
1234 pp_right_brace (buffer);
1239 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1240 indent. FLAGS specifies details to show in the dump (see TDF_* in
1241 dumpfile.h). */
1243 static void
1244 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc,
1245 dump_flags_t flags)
1247 if (flags & TDF_RAW)
1248 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1249 gimple_catch_types (gs), gimple_catch_handler (gs));
1250 else
1251 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1252 gimple_catch_types (gs), gimple_catch_handler (gs));
1256 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1257 indent. FLAGS specifies details to show in the dump (see TDF_* in
1258 dumpfile.h). */
1260 static void
1261 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1262 dump_flags_t flags)
1264 if (flags & TDF_RAW)
1265 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1266 gimple_eh_filter_types (gs),
1267 gimple_eh_filter_failure (gs));
1268 else
1269 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1270 gimple_eh_filter_types (gs),
1271 gimple_eh_filter_failure (gs));
1275 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1277 static void
1278 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1279 geh_mnt *gs, int spc, dump_flags_t flags)
1281 if (flags & TDF_RAW)
1282 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1283 gimple_eh_must_not_throw_fndecl (gs));
1284 else
1285 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1286 gimple_eh_must_not_throw_fndecl (gs));
1290 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1291 indent. FLAGS specifies details to show in the dump (see TDF_* in
1292 dumpfile.h). */
1294 static void
1295 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1296 dump_flags_t flags)
1298 if (flags & TDF_RAW)
1299 dump_gimple_fmt (buffer, spc, flags,
1300 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1301 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1302 else
1303 dump_gimple_fmt (buffer, spc, flags,
1304 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1305 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1309 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1310 indent. FLAGS specifies details to show in the dump (see TDF_* in
1311 dumpfile.h). */
1313 static void
1314 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc,
1315 dump_flags_t flags)
1317 if (flags & TDF_RAW)
1318 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1319 gimple_resx_region (gs));
1320 else
1321 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1324 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1326 static void
1327 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc,
1328 dump_flags_t flags)
1330 if (flags & TDF_RAW)
1331 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1332 gimple_eh_dispatch_region (gs));
1333 else
1334 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1335 gimple_eh_dispatch_region (gs));
1338 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1339 of indent. FLAGS specifies details to show in the dump (see TDF_*
1340 in dumpfile.h). */
1342 static void
1343 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc,
1344 dump_flags_t flags)
1346 switch (gs->subcode)
1348 case GIMPLE_DEBUG_BIND:
1349 if (flags & TDF_RAW)
1350 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1351 gimple_debug_bind_get_var (gs),
1352 gimple_debug_bind_get_value (gs));
1353 else
1354 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1355 gimple_debug_bind_get_var (gs),
1356 gimple_debug_bind_get_value (gs));
1357 break;
1359 case GIMPLE_DEBUG_SOURCE_BIND:
1360 if (flags & TDF_RAW)
1361 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1362 gimple_debug_source_bind_get_var (gs),
1363 gimple_debug_source_bind_get_value (gs));
1364 else
1365 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1366 gimple_debug_source_bind_get_var (gs),
1367 gimple_debug_source_bind_get_value (gs));
1368 break;
1370 case GIMPLE_DEBUG_BEGIN_STMT:
1371 if (flags & TDF_RAW)
1372 dump_gimple_fmt (buffer, spc, flags, "%G BEGIN_STMT", gs);
1373 else
1374 dump_gimple_fmt (buffer, spc, flags, "# DEBUG BEGIN_STMT");
1375 break;
1377 case GIMPLE_DEBUG_INLINE_ENTRY:
1378 if (flags & TDF_RAW)
1379 dump_gimple_fmt (buffer, spc, flags, "%G INLINE_ENTRY %T", gs,
1380 gimple_block (gs)
1381 ? block_ultimate_origin (gimple_block (gs))
1382 : NULL_TREE);
1383 else
1384 dump_gimple_fmt (buffer, spc, flags, "# DEBUG INLINE_ENTRY %T",
1385 gimple_block (gs)
1386 ? block_ultimate_origin (gimple_block (gs))
1387 : NULL_TREE);
1388 break;
1390 default:
1391 gcc_unreachable ();
1395 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1396 static void
1397 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc,
1398 dump_flags_t flags)
1400 size_t i;
1402 if (flags & TDF_RAW)
1404 const char *kind;
1405 switch (gimple_omp_for_kind (gs))
1407 case GF_OMP_FOR_KIND_FOR:
1408 kind = "";
1409 break;
1410 case GF_OMP_FOR_KIND_DISTRIBUTE:
1411 kind = " distribute";
1412 break;
1413 case GF_OMP_FOR_KIND_TASKLOOP:
1414 kind = " taskloop";
1415 break;
1416 case GF_OMP_FOR_KIND_OACC_LOOP:
1417 kind = " oacc_loop";
1418 break;
1419 case GF_OMP_FOR_KIND_SIMD:
1420 kind = " simd";
1421 break;
1422 default:
1423 gcc_unreachable ();
1425 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1426 kind, gimple_omp_body (gs));
1427 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1428 dump_gimple_fmt (buffer, spc, flags, " >,");
1429 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1430 dump_gimple_fmt (buffer, spc, flags,
1431 "%+%T, %T, %T, %s, %T,%n",
1432 gimple_omp_for_index (gs, i),
1433 gimple_omp_for_initial (gs, i),
1434 gimple_omp_for_final (gs, i),
1435 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1436 gimple_omp_for_incr (gs, i));
1437 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1438 gimple_omp_for_pre_body (gs));
1440 else
1442 switch (gimple_omp_for_kind (gs))
1444 case GF_OMP_FOR_KIND_FOR:
1445 pp_string (buffer, "#pragma omp for");
1446 break;
1447 case GF_OMP_FOR_KIND_DISTRIBUTE:
1448 pp_string (buffer, "#pragma omp distribute");
1449 break;
1450 case GF_OMP_FOR_KIND_TASKLOOP:
1451 pp_string (buffer, "#pragma omp taskloop");
1452 break;
1453 case GF_OMP_FOR_KIND_OACC_LOOP:
1454 pp_string (buffer, "#pragma acc loop");
1455 break;
1456 case GF_OMP_FOR_KIND_SIMD:
1457 pp_string (buffer, "#pragma omp simd");
1458 break;
1459 case GF_OMP_FOR_KIND_GRID_LOOP:
1460 pp_string (buffer, "#pragma omp for grid_loop");
1461 break;
1462 default:
1463 gcc_unreachable ();
1465 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1466 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1468 if (i)
1469 spc += 2;
1470 newline_and_indent (buffer, spc);
1471 pp_string (buffer, "for (");
1472 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1473 flags, false);
1474 pp_string (buffer, " = ");
1475 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1476 flags, false);
1477 pp_string (buffer, "; ");
1479 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1480 flags, false);
1481 pp_space (buffer);
1482 switch (gimple_omp_for_cond (gs, i))
1484 case LT_EXPR:
1485 pp_less (buffer);
1486 break;
1487 case GT_EXPR:
1488 pp_greater (buffer);
1489 break;
1490 case LE_EXPR:
1491 pp_less_equal (buffer);
1492 break;
1493 case GE_EXPR:
1494 pp_greater_equal (buffer);
1495 break;
1496 case NE_EXPR:
1497 pp_string (buffer, "!=");
1498 break;
1499 default:
1500 gcc_unreachable ();
1502 pp_space (buffer);
1503 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1504 flags, false);
1505 pp_string (buffer, "; ");
1507 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1508 flags, false);
1509 pp_string (buffer, " = ");
1510 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1511 flags, false);
1512 pp_right_paren (buffer);
1515 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1517 newline_and_indent (buffer, spc + 2);
1518 pp_left_brace (buffer);
1519 pp_newline (buffer);
1520 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1521 newline_and_indent (buffer, spc + 2);
1522 pp_right_brace (buffer);
1527 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1529 static void
1530 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1531 int spc, dump_flags_t flags)
1533 if (flags & TDF_RAW)
1535 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1536 gimple_omp_continue_control_def (gs),
1537 gimple_omp_continue_control_use (gs));
1539 else
1541 pp_string (buffer, "#pragma omp continue (");
1542 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1543 spc, flags, false);
1544 pp_comma (buffer);
1545 pp_space (buffer);
1546 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1547 spc, flags, false);
1548 pp_right_paren (buffer);
1552 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1554 static void
1555 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1556 int spc, dump_flags_t flags)
1558 if (flags & TDF_RAW)
1560 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1561 gimple_omp_body (gs));
1562 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1563 dump_gimple_fmt (buffer, spc, flags, " >");
1565 else
1567 pp_string (buffer, "#pragma omp single");
1568 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1569 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1571 newline_and_indent (buffer, spc + 2);
1572 pp_left_brace (buffer);
1573 pp_newline (buffer);
1574 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1575 newline_and_indent (buffer, spc + 2);
1576 pp_right_brace (buffer);
1581 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1583 static void
1584 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1585 int spc, dump_flags_t flags)
1587 const char *kind;
1588 switch (gimple_omp_target_kind (gs))
1590 case GF_OMP_TARGET_KIND_REGION:
1591 kind = "";
1592 break;
1593 case GF_OMP_TARGET_KIND_DATA:
1594 kind = " data";
1595 break;
1596 case GF_OMP_TARGET_KIND_UPDATE:
1597 kind = " update";
1598 break;
1599 case GF_OMP_TARGET_KIND_ENTER_DATA:
1600 kind = " enter data";
1601 break;
1602 case GF_OMP_TARGET_KIND_EXIT_DATA:
1603 kind = " exit data";
1604 break;
1605 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1606 kind = " oacc_kernels";
1607 break;
1608 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1609 kind = " oacc_parallel";
1610 break;
1611 case GF_OMP_TARGET_KIND_OACC_DATA:
1612 kind = " oacc_data";
1613 break;
1614 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1615 kind = " oacc_update";
1616 break;
1617 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1618 kind = " oacc_enter_exit_data";
1619 break;
1620 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1621 kind = " oacc_declare";
1622 break;
1623 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1624 kind = " oacc_host_data";
1625 break;
1626 default:
1627 gcc_unreachable ();
1629 if (flags & TDF_RAW)
1631 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1632 kind, gimple_omp_body (gs));
1633 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1634 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1635 gimple_omp_target_child_fn (gs),
1636 gimple_omp_target_data_arg (gs));
1638 else
1640 pp_string (buffer, "#pragma omp target");
1641 pp_string (buffer, kind);
1642 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1643 if (gimple_omp_target_child_fn (gs))
1645 pp_string (buffer, " [child fn: ");
1646 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1647 spc, flags, false);
1648 pp_string (buffer, " (");
1649 if (gimple_omp_target_data_arg (gs))
1650 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1651 spc, flags, false);
1652 else
1653 pp_string (buffer, "???");
1654 pp_string (buffer, ")]");
1656 gimple_seq body = gimple_omp_body (gs);
1657 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1659 newline_and_indent (buffer, spc + 2);
1660 pp_left_brace (buffer);
1661 pp_newline (buffer);
1662 dump_gimple_seq (buffer, body, spc + 4, flags);
1663 newline_and_indent (buffer, spc + 2);
1664 pp_right_brace (buffer);
1666 else if (body)
1668 pp_newline (buffer);
1669 dump_gimple_seq (buffer, body, spc + 2, flags);
1674 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1676 static void
1677 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1678 dump_flags_t flags)
1680 if (flags & TDF_RAW)
1682 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1683 gimple_omp_body (gs));
1684 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1685 dump_gimple_fmt (buffer, spc, flags, " >");
1687 else
1689 pp_string (buffer, "#pragma omp teams");
1690 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1691 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1693 newline_and_indent (buffer, spc + 2);
1694 pp_character (buffer, '{');
1695 pp_newline (buffer);
1696 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1697 newline_and_indent (buffer, spc + 2);
1698 pp_character (buffer, '}');
1703 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1705 static void
1706 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1707 int spc, dump_flags_t flags)
1709 if (flags & TDF_RAW)
1711 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1712 gimple_omp_body (gs));
1713 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1714 dump_gimple_fmt (buffer, spc, flags, " >");
1716 else
1718 pp_string (buffer, "#pragma omp sections");
1719 if (gimple_omp_sections_control (gs))
1721 pp_string (buffer, " <");
1722 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1723 flags, false);
1724 pp_greater (buffer);
1726 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1727 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1729 newline_and_indent (buffer, spc + 2);
1730 pp_left_brace (buffer);
1731 pp_newline (buffer);
1732 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1733 newline_and_indent (buffer, spc + 2);
1734 pp_right_brace (buffer);
1739 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1740 pretty_printer BUFFER. */
1742 static void
1743 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc,
1744 dump_flags_t flags)
1746 if (flags & TDF_RAW)
1747 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1748 gimple_omp_body (gs));
1749 else
1751 switch (gimple_code (gs))
1753 case GIMPLE_OMP_MASTER:
1754 pp_string (buffer, "#pragma omp master");
1755 break;
1756 case GIMPLE_OMP_TASKGROUP:
1757 pp_string (buffer, "#pragma omp taskgroup");
1758 break;
1759 case GIMPLE_OMP_SECTION:
1760 pp_string (buffer, "#pragma omp section");
1761 break;
1762 case GIMPLE_OMP_GRID_BODY:
1763 pp_string (buffer, "#pragma omp gridified body");
1764 break;
1765 default:
1766 gcc_unreachable ();
1768 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1770 newline_and_indent (buffer, spc + 2);
1771 pp_left_brace (buffer);
1772 pp_newline (buffer);
1773 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1774 newline_and_indent (buffer, spc + 2);
1775 pp_right_brace (buffer);
1780 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1782 static void
1783 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1784 int spc, dump_flags_t flags)
1786 if (flags & TDF_RAW)
1787 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1788 gimple_omp_body (gs));
1789 else
1791 pp_string (buffer, "#pragma omp critical");
1792 if (gimple_omp_critical_name (gs))
1794 pp_string (buffer, " (");
1795 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1796 flags, false);
1797 pp_right_paren (buffer);
1799 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1800 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1802 newline_and_indent (buffer, spc + 2);
1803 pp_left_brace (buffer);
1804 pp_newline (buffer);
1805 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1806 newline_and_indent (buffer, spc + 2);
1807 pp_right_brace (buffer);
1812 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1814 static void
1815 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1816 int spc, dump_flags_t flags)
1818 if (flags & TDF_RAW)
1819 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1820 gimple_omp_body (gs));
1821 else
1823 pp_string (buffer, "#pragma omp ordered");
1824 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1825 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1827 newline_and_indent (buffer, spc + 2);
1828 pp_left_brace (buffer);
1829 pp_newline (buffer);
1830 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1831 newline_and_indent (buffer, spc + 2);
1832 pp_right_brace (buffer);
1837 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1839 static void
1840 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc,
1841 dump_flags_t flags)
1843 if (flags & TDF_RAW)
1845 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1846 (int) gimple_omp_return_nowait_p (gs));
1847 if (gimple_omp_return_lhs (gs))
1848 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1849 gimple_omp_return_lhs (gs));
1850 else
1851 dump_gimple_fmt (buffer, spc, flags, ">");
1853 else
1855 pp_string (buffer, "#pragma omp return");
1856 if (gimple_omp_return_nowait_p (gs))
1857 pp_string (buffer, "(nowait)");
1858 if (gimple_omp_return_lhs (gs))
1860 pp_string (buffer, " (set ");
1861 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1862 spc, flags, false);
1863 pp_character (buffer, ')');
1868 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1870 static void
1871 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1872 int spc, dump_flags_t flags)
1874 unsigned subcode = gimple_transaction_subcode (gs);
1876 if (flags & TDF_RAW)
1878 dump_gimple_fmt (buffer, spc, flags,
1879 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1880 "<%+BODY <%S> >",
1881 gs, subcode, gimple_transaction_label_norm (gs),
1882 gimple_transaction_label_uninst (gs),
1883 gimple_transaction_label_over (gs),
1884 gimple_transaction_body (gs));
1886 else
1888 if (subcode & GTMA_IS_OUTER)
1889 pp_string (buffer, "__transaction_atomic [[outer]]");
1890 else if (subcode & GTMA_IS_RELAXED)
1891 pp_string (buffer, "__transaction_relaxed");
1892 else
1893 pp_string (buffer, "__transaction_atomic");
1894 subcode &= ~GTMA_DECLARATION_MASK;
1896 if (gimple_transaction_body (gs))
1898 newline_and_indent (buffer, spc + 2);
1899 pp_left_brace (buffer);
1900 pp_newline (buffer);
1901 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1902 spc + 4, flags);
1903 newline_and_indent (buffer, spc + 2);
1904 pp_right_brace (buffer);
1906 else
1908 pp_string (buffer, " //");
1909 if (gimple_transaction_label_norm (gs))
1911 pp_string (buffer, " NORM=");
1912 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1913 spc, flags, false);
1915 if (gimple_transaction_label_uninst (gs))
1917 pp_string (buffer, " UNINST=");
1918 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1919 spc, flags, false);
1921 if (gimple_transaction_label_over (gs))
1923 pp_string (buffer, " OVER=");
1924 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1925 spc, flags, false);
1927 if (subcode)
1929 pp_string (buffer, " SUBCODE=[ ");
1930 if (subcode & GTMA_HAVE_ABORT)
1932 pp_string (buffer, "GTMA_HAVE_ABORT ");
1933 subcode &= ~GTMA_HAVE_ABORT;
1935 if (subcode & GTMA_HAVE_LOAD)
1937 pp_string (buffer, "GTMA_HAVE_LOAD ");
1938 subcode &= ~GTMA_HAVE_LOAD;
1940 if (subcode & GTMA_HAVE_STORE)
1942 pp_string (buffer, "GTMA_HAVE_STORE ");
1943 subcode &= ~GTMA_HAVE_STORE;
1945 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1947 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1948 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1950 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1952 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1953 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1955 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1957 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1958 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1960 if (subcode)
1961 pp_printf (buffer, "0x%x ", subcode);
1962 pp_right_bracket (buffer);
1968 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1969 indent. FLAGS specifies details to show in the dump (see TDF_* in
1970 dumpfile.h). */
1972 static void
1973 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, dump_flags_t flags)
1975 unsigned int i, n, f, fields;
1977 if (flags & TDF_RAW)
1979 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1980 gimple_asm_string (gs));
1982 n = gimple_asm_noutputs (gs);
1983 if (n)
1985 newline_and_indent (buffer, spc + 2);
1986 pp_string (buffer, "OUTPUT: ");
1987 for (i = 0; i < n; i++)
1989 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1990 spc, flags, false);
1991 if (i < n - 1)
1992 pp_string (buffer, ", ");
1996 n = gimple_asm_ninputs (gs);
1997 if (n)
1999 newline_and_indent (buffer, spc + 2);
2000 pp_string (buffer, "INPUT: ");
2001 for (i = 0; i < n; i++)
2003 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2004 spc, flags, false);
2005 if (i < n - 1)
2006 pp_string (buffer, ", ");
2010 n = gimple_asm_nclobbers (gs);
2011 if (n)
2013 newline_and_indent (buffer, spc + 2);
2014 pp_string (buffer, "CLOBBER: ");
2015 for (i = 0; i < n; i++)
2017 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2018 spc, flags, false);
2019 if (i < n - 1)
2020 pp_string (buffer, ", ");
2024 n = gimple_asm_nlabels (gs);
2025 if (n)
2027 newline_and_indent (buffer, spc + 2);
2028 pp_string (buffer, "LABEL: ");
2029 for (i = 0; i < n; i++)
2031 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2032 spc, flags, false);
2033 if (i < n - 1)
2034 pp_string (buffer, ", ");
2038 newline_and_indent (buffer, spc);
2039 pp_greater (buffer);
2041 else
2043 pp_string (buffer, "__asm__");
2044 if (gimple_asm_volatile_p (gs))
2045 pp_string (buffer, " __volatile__");
2046 if (gimple_asm_nlabels (gs))
2047 pp_string (buffer, " goto");
2048 pp_string (buffer, "(\"");
2049 pp_string (buffer, gimple_asm_string (gs));
2050 pp_string (buffer, "\"");
2052 if (gimple_asm_nlabels (gs))
2053 fields = 4;
2054 else if (gimple_asm_nclobbers (gs))
2055 fields = 3;
2056 else if (gimple_asm_ninputs (gs))
2057 fields = 2;
2058 else if (gimple_asm_noutputs (gs))
2059 fields = 1;
2060 else
2061 fields = 0;
2063 for (f = 0; f < fields; ++f)
2065 pp_string (buffer, " : ");
2067 switch (f)
2069 case 0:
2070 n = gimple_asm_noutputs (gs);
2071 for (i = 0; i < n; i++)
2073 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2074 spc, flags, false);
2075 if (i < n - 1)
2076 pp_string (buffer, ", ");
2078 break;
2080 case 1:
2081 n = gimple_asm_ninputs (gs);
2082 for (i = 0; i < n; i++)
2084 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2085 spc, flags, false);
2086 if (i < n - 1)
2087 pp_string (buffer, ", ");
2089 break;
2091 case 2:
2092 n = gimple_asm_nclobbers (gs);
2093 for (i = 0; i < n; i++)
2095 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2096 spc, flags, false);
2097 if (i < n - 1)
2098 pp_string (buffer, ", ");
2100 break;
2102 case 3:
2103 n = gimple_asm_nlabels (gs);
2104 for (i = 0; i < n; i++)
2106 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2107 spc, flags, false);
2108 if (i < n - 1)
2109 pp_string (buffer, ", ");
2111 break;
2113 default:
2114 gcc_unreachable ();
2118 pp_string (buffer, ");");
2122 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2123 SPC spaces of indent. */
2125 static void
2126 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2128 if (TREE_CODE (node) != SSA_NAME)
2129 return;
2131 if (POINTER_TYPE_P (TREE_TYPE (node))
2132 && SSA_NAME_PTR_INFO (node))
2134 unsigned int align, misalign;
2135 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2136 pp_string (buffer, "# PT = ");
2137 pp_points_to_solution (buffer, &pi->pt);
2138 newline_and_indent (buffer, spc);
2139 if (get_ptr_info_alignment (pi, &align, &misalign))
2141 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2142 newline_and_indent (buffer, spc);
2146 if (!POINTER_TYPE_P (TREE_TYPE (node))
2147 && SSA_NAME_RANGE_INFO (node))
2149 wide_int min, max, nonzero_bits;
2150 value_range_type range_type = get_range_info (node, &min, &max);
2152 if (range_type == VR_VARYING)
2153 pp_printf (buffer, "# RANGE VR_VARYING");
2154 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2156 pp_printf (buffer, "# RANGE ");
2157 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2158 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2159 pp_printf (buffer, ", ");
2160 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2161 pp_printf (buffer, "]");
2163 nonzero_bits = get_nonzero_bits (node);
2164 if (nonzero_bits != -1)
2166 pp_string (buffer, " NONZERO ");
2167 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2169 newline_and_indent (buffer, spc);
2173 /* As dump_ssaname_info, but dump to FILE. */
2175 void
2176 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2178 pretty_printer buffer;
2179 pp_needs_newline (&buffer) = true;
2180 buffer.buffer->stream = file;
2181 dump_ssaname_info (&buffer, node, spc);
2182 pp_flush (&buffer);
2185 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2186 The caller is responsible for calling pp_flush on BUFFER to finalize
2187 pretty printer. If COMMENT is true, print this after #. */
2189 static void
2190 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2191 dump_flags_t flags)
2193 size_t i;
2194 tree lhs = gimple_phi_result (phi);
2196 if (flags & TDF_ALIAS)
2197 dump_ssaname_info (buffer, lhs, spc);
2199 if (comment)
2200 pp_string (buffer, "# ");
2202 if (flags & TDF_RAW)
2203 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2204 gimple_phi_result (phi));
2205 else
2207 dump_generic_node (buffer, lhs, spc, flags, false);
2208 if (flags & TDF_GIMPLE)
2209 pp_string (buffer, " = __PHI (");
2210 else
2211 pp_string (buffer, " = PHI <");
2213 for (i = 0; i < gimple_phi_num_args (phi); i++)
2215 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2216 dump_location (buffer, gimple_phi_arg_location (phi, i));
2217 if (flags & TDF_GIMPLE)
2219 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2220 gimple *stmt = first_stmt (src);
2221 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2223 pp_string (buffer, "bb_");
2224 pp_decimal_int (buffer, src->index);
2226 else
2227 dump_generic_node (buffer, gimple_label_label (as_a <glabel *> (stmt)), 0, flags,
2228 false);
2229 pp_string (buffer, ": ");
2231 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2232 false);
2233 if (! (flags & TDF_GIMPLE))
2235 pp_left_paren (buffer);
2236 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2237 pp_right_paren (buffer);
2239 if (i < gimple_phi_num_args (phi) - 1)
2240 pp_string (buffer, ", ");
2242 if (flags & TDF_GIMPLE)
2243 pp_string (buffer, ");");
2244 else
2245 pp_greater (buffer);
2249 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2250 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2251 dumpfile.h). */
2253 static void
2254 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2255 int spc, dump_flags_t flags)
2257 if (flags & TDF_RAW)
2259 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2260 gimple_omp_body (gs));
2261 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2262 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2263 gimple_omp_parallel_child_fn (gs),
2264 gimple_omp_parallel_data_arg (gs));
2266 else
2268 gimple_seq body;
2269 pp_string (buffer, "#pragma omp parallel");
2270 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2271 if (gimple_omp_parallel_child_fn (gs))
2273 pp_string (buffer, " [child fn: ");
2274 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2275 spc, flags, false);
2276 pp_string (buffer, " (");
2277 if (gimple_omp_parallel_data_arg (gs))
2278 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2279 spc, flags, false);
2280 else
2281 pp_string (buffer, "???");
2282 pp_string (buffer, ")]");
2284 body = gimple_omp_body (gs);
2285 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2287 newline_and_indent (buffer, spc + 2);
2288 pp_left_brace (buffer);
2289 pp_newline (buffer);
2290 dump_gimple_seq (buffer, body, spc + 4, flags);
2291 newline_and_indent (buffer, spc + 2);
2292 pp_right_brace (buffer);
2294 else if (body)
2296 pp_newline (buffer);
2297 dump_gimple_seq (buffer, body, spc + 2, flags);
2303 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2304 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2305 dumpfile.h). */
2307 static void
2308 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2309 dump_flags_t flags)
2311 if (flags & TDF_RAW)
2313 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2314 gimple_omp_body (gs));
2315 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2316 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2317 gimple_omp_task_child_fn (gs),
2318 gimple_omp_task_data_arg (gs),
2319 gimple_omp_task_copy_fn (gs),
2320 gimple_omp_task_arg_size (gs),
2321 gimple_omp_task_arg_size (gs));
2323 else
2325 gimple_seq body;
2326 if (gimple_omp_task_taskloop_p (gs))
2327 pp_string (buffer, "#pragma omp taskloop");
2328 else
2329 pp_string (buffer, "#pragma omp task");
2330 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2331 if (gimple_omp_task_child_fn (gs))
2333 pp_string (buffer, " [child fn: ");
2334 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2335 spc, flags, false);
2336 pp_string (buffer, " (");
2337 if (gimple_omp_task_data_arg (gs))
2338 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2339 spc, flags, false);
2340 else
2341 pp_string (buffer, "???");
2342 pp_string (buffer, ")]");
2344 body = gimple_omp_body (gs);
2345 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2347 newline_and_indent (buffer, spc + 2);
2348 pp_left_brace (buffer);
2349 pp_newline (buffer);
2350 dump_gimple_seq (buffer, body, spc + 4, flags);
2351 newline_and_indent (buffer, spc + 2);
2352 pp_right_brace (buffer);
2354 else if (body)
2356 pp_newline (buffer);
2357 dump_gimple_seq (buffer, body, spc + 2, flags);
2363 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2364 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2365 in dumpfile.h). */
2367 static void
2368 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2369 int spc, dump_flags_t flags)
2371 if (flags & TDF_RAW)
2373 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2374 gimple_omp_atomic_load_lhs (gs),
2375 gimple_omp_atomic_load_rhs (gs));
2377 else
2379 pp_string (buffer, "#pragma omp atomic_load");
2380 if (gimple_omp_atomic_seq_cst_p (gs))
2381 pp_string (buffer, " seq_cst");
2382 if (gimple_omp_atomic_need_value_p (gs))
2383 pp_string (buffer, " [needed]");
2384 newline_and_indent (buffer, spc + 2);
2385 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2386 spc, flags, false);
2387 pp_space (buffer);
2388 pp_equal (buffer);
2389 pp_space (buffer);
2390 pp_star (buffer);
2391 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2392 spc, flags, false);
2396 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2397 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2398 in dumpfile.h). */
2400 static void
2401 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2402 gomp_atomic_store *gs, int spc,
2403 dump_flags_t flags)
2405 if (flags & TDF_RAW)
2407 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2408 gimple_omp_atomic_store_val (gs));
2410 else
2412 pp_string (buffer, "#pragma omp atomic_store ");
2413 if (gimple_omp_atomic_seq_cst_p (gs))
2414 pp_string (buffer, "seq_cst ");
2415 if (gimple_omp_atomic_need_value_p (gs))
2416 pp_string (buffer, "[needed] ");
2417 pp_left_paren (buffer);
2418 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2419 spc, flags, false);
2420 pp_right_paren (buffer);
2425 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2426 FLAGS are as in pp_gimple_stmt_1. */
2428 static void
2429 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc,
2430 dump_flags_t flags)
2432 tree vdef = gimple_vdef (gs);
2433 tree vuse = gimple_vuse (gs);
2435 if (vdef != NULL_TREE)
2437 pp_string (buffer, "# ");
2438 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2439 pp_string (buffer, " = VDEF <");
2440 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2441 pp_greater (buffer);
2442 newline_and_indent (buffer, spc);
2444 else if (vuse != NULL_TREE)
2446 pp_string (buffer, "# VUSE <");
2447 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2448 pp_greater (buffer);
2449 newline_and_indent (buffer, spc);
2454 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2455 spaces of indent. FLAGS specifies details to show in the dump (see
2456 TDF_* in dumpfile.h). The caller is responsible for calling
2457 pp_flush on BUFFER to finalize the pretty printer. */
2459 void
2460 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc,
2461 dump_flags_t flags)
2463 if (!gs)
2464 return;
2466 if (flags & TDF_STMTADDR)
2467 pp_printf (buffer, "<&%p> ", (void *) gs);
2469 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2470 dump_location (buffer, gimple_location (gs));
2472 if (flags & TDF_EH)
2474 int lp_nr = lookup_stmt_eh_lp (gs);
2475 if (lp_nr > 0)
2476 pp_printf (buffer, "[LP %d] ", lp_nr);
2477 else if (lp_nr < 0)
2478 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2481 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2482 && gimple_has_mem_ops (gs))
2483 dump_gimple_mem_ops (buffer, gs, spc, flags);
2485 if (gimple_has_lhs (gs)
2486 && (flags & TDF_ALIAS))
2487 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2489 switch (gimple_code (gs))
2491 case GIMPLE_ASM:
2492 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2493 break;
2495 case GIMPLE_ASSIGN:
2496 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2497 break;
2499 case GIMPLE_BIND:
2500 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2501 break;
2503 case GIMPLE_CALL:
2504 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2505 break;
2507 case GIMPLE_COND:
2508 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2509 break;
2511 case GIMPLE_LABEL:
2512 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2513 break;
2515 case GIMPLE_GOTO:
2516 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2517 break;
2519 case GIMPLE_NOP:
2520 pp_string (buffer, "GIMPLE_NOP");
2521 break;
2523 case GIMPLE_RETURN:
2524 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2525 break;
2527 case GIMPLE_SWITCH:
2528 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2529 break;
2531 case GIMPLE_TRY:
2532 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2533 break;
2535 case GIMPLE_PHI:
2536 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2537 break;
2539 case GIMPLE_OMP_PARALLEL:
2540 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2541 flags);
2542 break;
2544 case GIMPLE_OMP_TASK:
2545 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2546 break;
2548 case GIMPLE_OMP_ATOMIC_LOAD:
2549 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2550 spc, flags);
2551 break;
2553 case GIMPLE_OMP_ATOMIC_STORE:
2554 dump_gimple_omp_atomic_store (buffer,
2555 as_a <gomp_atomic_store *> (gs),
2556 spc, flags);
2557 break;
2559 case GIMPLE_OMP_FOR:
2560 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2561 break;
2563 case GIMPLE_OMP_CONTINUE:
2564 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2565 flags);
2566 break;
2568 case GIMPLE_OMP_SINGLE:
2569 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2570 flags);
2571 break;
2573 case GIMPLE_OMP_TARGET:
2574 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2575 flags);
2576 break;
2578 case GIMPLE_OMP_TEAMS:
2579 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2580 flags);
2581 break;
2583 case GIMPLE_OMP_RETURN:
2584 dump_gimple_omp_return (buffer, gs, spc, flags);
2585 break;
2587 case GIMPLE_OMP_SECTIONS:
2588 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2589 spc, flags);
2590 break;
2592 case GIMPLE_OMP_SECTIONS_SWITCH:
2593 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2594 break;
2596 case GIMPLE_OMP_MASTER:
2597 case GIMPLE_OMP_TASKGROUP:
2598 case GIMPLE_OMP_SECTION:
2599 case GIMPLE_OMP_GRID_BODY:
2600 dump_gimple_omp_block (buffer, gs, spc, flags);
2601 break;
2603 case GIMPLE_OMP_ORDERED:
2604 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2605 flags);
2606 break;
2608 case GIMPLE_OMP_CRITICAL:
2609 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2610 flags);
2611 break;
2613 case GIMPLE_CATCH:
2614 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2615 break;
2617 case GIMPLE_EH_FILTER:
2618 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2619 break;
2621 case GIMPLE_EH_MUST_NOT_THROW:
2622 dump_gimple_eh_must_not_throw (buffer,
2623 as_a <geh_mnt *> (gs),
2624 spc, flags);
2625 break;
2627 case GIMPLE_EH_ELSE:
2628 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2629 break;
2631 case GIMPLE_RESX:
2632 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2633 break;
2635 case GIMPLE_EH_DISPATCH:
2636 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2637 flags);
2638 break;
2640 case GIMPLE_DEBUG:
2641 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2642 break;
2644 case GIMPLE_PREDICT:
2645 pp_string (buffer, "// predicted ");
2646 if (gimple_predict_outcome (gs))
2647 pp_string (buffer, "likely by ");
2648 else
2649 pp_string (buffer, "unlikely by ");
2650 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2651 pp_string (buffer, " predictor.");
2652 break;
2654 case GIMPLE_TRANSACTION:
2655 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2656 flags);
2657 break;
2659 default:
2660 GIMPLE_NIY;
2665 /* Dumps header of basic block BB to OUTF indented by INDENT
2666 spaces and details described by flags. */
2668 static void
2669 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
2670 dump_flags_t flags)
2672 if (flags & TDF_BLOCKS)
2674 if (flags & TDF_LINENO)
2676 gimple_stmt_iterator gsi;
2678 fputs (";; ", outf);
2680 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2681 if (!is_gimple_debug (gsi_stmt (gsi))
2682 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2684 fprintf (outf, "%*sstarting at line %d",
2685 indent, "", get_lineno (gsi_stmt (gsi)));
2686 break;
2688 if (bb->discriminator)
2689 fprintf (outf, ", discriminator %i", bb->discriminator);
2690 fputc ('\n', outf);
2693 else
2695 if (flags & TDF_GIMPLE)
2696 fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
2697 else
2698 fprintf (outf, "%*s<bb %d> %s:\n",
2699 indent, "", bb->index, dump_profile (bb->count));
2704 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2705 spaces. */
2707 static void
2708 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2709 basic_block bb ATTRIBUTE_UNUSED,
2710 int indent ATTRIBUTE_UNUSED,
2711 dump_flags_t flags ATTRIBUTE_UNUSED)
2713 /* There is currently no GIMPLE-specific basic block info to dump. */
2714 return;
2718 /* Dump PHI nodes of basic block BB to BUFFER with details described
2719 by FLAGS and indented by INDENT spaces. */
2721 static void
2722 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
2723 dump_flags_t flags)
2725 gphi_iterator i;
2727 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2729 gphi *phi = i.phi ();
2730 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2732 INDENT (indent);
2733 dump_gimple_phi (buffer, phi, indent,
2734 (flags & TDF_GIMPLE) ? false : true, flags);
2735 pp_newline (buffer);
2741 /* Dump jump to basic block BB that is represented implicitly in the cfg
2742 to BUFFER. */
2744 static void
2745 pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
2747 if (flags & TDF_GIMPLE)
2749 pp_string (buffer, "goto bb_");
2750 pp_decimal_int (buffer, e->dest->index);
2751 pp_semicolon (buffer);
2753 else
2755 pp_string (buffer, "goto <bb ");
2756 pp_decimal_int (buffer, e->dest->index);
2757 pp_greater (buffer);
2758 pp_semicolon (buffer);
2760 dump_edge_probability (buffer, e);
2765 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2766 by INDENT spaces, with details given by FLAGS. */
2768 static void
2769 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2770 dump_flags_t flags)
2772 edge e;
2773 gimple *stmt;
2775 stmt = last_stmt (bb);
2777 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2779 edge true_edge, false_edge;
2781 /* When we are emitting the code or changing CFG, it is possible that
2782 the edges are not yet created. When we are using debug_bb in such
2783 a situation, we do not want it to crash. */
2784 if (EDGE_COUNT (bb->succs) != 2)
2785 return;
2786 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2788 INDENT (indent + 2);
2789 pp_cfg_jump (buffer, true_edge, flags);
2790 newline_and_indent (buffer, indent);
2791 pp_string (buffer, "else");
2792 newline_and_indent (buffer, indent + 2);
2793 pp_cfg_jump (buffer, false_edge, flags);
2794 pp_newline (buffer);
2795 return;
2798 /* If there is a fallthru edge, we may need to add an artificial
2799 goto to the dump. */
2800 e = find_fallthru_edge (bb->succs);
2802 if (e && e->dest != bb->next_bb)
2804 INDENT (indent);
2806 if ((flags & TDF_LINENO)
2807 && e->goto_locus != UNKNOWN_LOCATION)
2808 dump_location (buffer, e->goto_locus);
2810 pp_cfg_jump (buffer, e, flags);
2811 pp_newline (buffer);
2816 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2817 indented by INDENT spaces. */
2819 static void
2820 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2821 dump_flags_t flags)
2823 gimple_stmt_iterator gsi;
2824 gimple *stmt;
2825 int label_indent = indent - 2;
2827 if (label_indent < 0)
2828 label_indent = 0;
2830 dump_phi_nodes (buffer, bb, indent, flags);
2832 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2834 int curr_indent;
2836 stmt = gsi_stmt (gsi);
2838 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2840 INDENT (curr_indent);
2841 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2842 pp_newline_and_flush (buffer);
2843 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2844 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2845 pp_buffer (buffer)->stream, stmt);
2848 dump_implicit_edges (buffer, bb, indent, flags);
2849 pp_flush (buffer);
2853 /* Dumps basic block BB to FILE with details described by FLAGS and
2854 indented by INDENT spaces. */
2856 void
2857 gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
2859 dump_gimple_bb_header (file, bb, indent, flags);
2860 if (bb->index >= NUM_FIXED_BLOCKS)
2862 pretty_printer buffer;
2863 pp_needs_newline (&buffer) = true;
2864 buffer.buffer->stream = file;
2865 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2867 dump_gimple_bb_footer (file, bb, indent, flags);
2870 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2871 no indentation, for use as a label of a DOT graph record-node.
2872 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2873 histogram dumping doesn't know about pretty-printers. */
2875 void
2876 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2878 pp_printf (pp, "<bb %d>:\n", bb->index);
2879 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2881 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2882 gsi_next (&gsi))
2884 gphi *phi = gsi.phi ();
2885 if (!virtual_operand_p (gimple_phi_result (phi))
2886 || (dump_flags & TDF_VOPS))
2888 pp_bar (pp);
2889 pp_write_text_to_stream (pp);
2890 pp_string (pp, "# ");
2891 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2892 pp_newline (pp);
2893 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2897 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2898 gsi_next (&gsi))
2900 gimple *stmt = gsi_stmt (gsi);
2901 pp_bar (pp);
2902 pp_write_text_to_stream (pp);
2903 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2904 pp_newline (pp);
2905 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2907 dump_implicit_edges (pp, bb, 0, dump_flags);
2908 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2912 /* Handle the %G format for TEXT. Same as %K in handle_K_format in
2913 tree-pretty-print.c but with a Gimple call statement as an argument. */
2915 void
2916 percent_G_format (text_info *text)
2918 gcall *stmt = va_arg (*text->args_ptr, gcall*);
2920 /* Build a call expression from the Gimple call statement and
2921 pass it to the K formatter that knows how to format it. */
2922 tree exp = build_vl_exp (CALL_EXPR, gimple_call_num_args (stmt) + 3);
2923 CALL_EXPR_FN (exp) = gimple_call_fn (stmt);
2924 TREE_TYPE (exp) = gimple_call_return_type (stmt);
2925 CALL_EXPR_STATIC_CHAIN (exp) = gimple_call_chain (stmt);
2926 SET_EXPR_LOCATION (exp, gimple_location (stmt));
2928 percent_K_format (text, exp);