typeck.c (cp_truthvalue_conversion): Add tsubst_flags_t parameter and use it in calls...
[official-gcc.git] / gcc / gimple-pretty-print.c
blobf59cc2aa31880fbb5b8ab9abeae8b15cf4a0a145
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2019 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"
44 #include "cfgloop.h"
46 /* Disable warnings about quoting issues in the pp_xxx calls below
47 that (intentionally) don't follow GCC diagnostic conventions. */
48 #if __GNUC__ >= 10
49 # pragma GCC diagnostic push
50 # pragma GCC diagnostic ignored "-Wformat-diag"
51 #endif
53 #define INDENT(SPACE) \
54 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
56 #define GIMPLE_NIY do_niy (buffer,gs)
58 /* Try to print on BUFFER a default message for the unrecognized
59 gimple statement GS. */
61 static void
62 do_niy (pretty_printer *buffer, gimple *gs)
64 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
65 gimple_code_name[(int) gimple_code (gs)]);
69 /* Emit a newline and SPC indentation spaces to BUFFER. */
71 static void
72 newline_and_indent (pretty_printer *buffer, int spc)
74 pp_newline (buffer);
75 INDENT (spc);
79 /* Print the GIMPLE statement GS on stderr. */
81 DEBUG_FUNCTION void
82 debug_gimple_stmt (gimple *gs)
84 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
88 /* Return formatted string of a VALUE probability
89 (biased by REG_BR_PROB_BASE). Returned string is allocated
90 by xstrdup_for_dump. */
92 static const char *
93 dump_profile (profile_count &count)
95 char *buf = NULL;
96 if (!count.initialized_p ())
97 return "";
98 if (count.ipa_p ())
99 buf = xasprintf ("[count: %" PRId64 "]",
100 count.to_gcov_type ());
101 else if (count.initialized_p ())
102 buf = xasprintf ("[local count: %" PRId64 "]",
103 count.to_gcov_type ());
105 const char *ret = xstrdup_for_dump (buf);
106 free (buf);
108 return ret;
111 /* Return formatted string of a VALUE probability
112 (biased by REG_BR_PROB_BASE). Returned string is allocated
113 by xstrdup_for_dump. */
115 static const char *
116 dump_probability (profile_probability probability)
118 float minimum = 0.01f;
119 float fvalue = -1;
121 if (probability.initialized_p ())
123 fvalue = probability.to_reg_br_prob_base () * 100.0f / REG_BR_PROB_BASE;
124 if (fvalue < minimum && probability.to_reg_br_prob_base ())
125 fvalue = minimum;
128 char *buf;
129 if (probability.initialized_p ())
130 buf = xasprintf ("[%.2f%%]", fvalue);
131 else
132 buf = xasprintf ("[INV]");
134 const char *ret = xstrdup_for_dump (buf);
135 free (buf);
137 return ret;
140 /* Dump E probability to BUFFER. */
142 static void
143 dump_edge_probability (pretty_printer *buffer, edge e)
145 pp_scalar (buffer, " %s", dump_probability (e->probability));
148 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
149 FLAGS as in pp_gimple_stmt_1. */
151 void
152 print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
154 pretty_printer buffer;
155 pp_needs_newline (&buffer) = true;
156 buffer.buffer->stream = file;
157 pp_gimple_stmt_1 (&buffer, g, spc, flags);
158 pp_newline_and_flush (&buffer);
161 DEBUG_FUNCTION void
162 debug (gimple &ref)
164 print_gimple_stmt (stderr, &ref, 0, TDF_NONE);
167 DEBUG_FUNCTION void
168 debug (gimple *ptr)
170 if (ptr)
171 debug (*ptr);
172 else
173 fprintf (stderr, "<nil>\n");
177 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
178 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
179 of the statement. */
181 void
182 print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
184 flags |= TDF_RHS_ONLY;
185 pretty_printer buffer;
186 pp_needs_newline (&buffer) = true;
187 buffer.buffer->stream = file;
188 pp_gimple_stmt_1 (&buffer, g, spc, flags);
189 pp_flush (&buffer);
193 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
194 spaces and FLAGS as in pp_gimple_stmt_1.
195 The caller is responsible for calling pp_flush on BUFFER to finalize
196 the pretty printer. */
198 static void
199 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc,
200 dump_flags_t flags)
202 gimple_stmt_iterator i;
204 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
206 gimple *gs = gsi_stmt (i);
207 INDENT (spc);
208 pp_gimple_stmt_1 (buffer, gs, spc, flags);
209 if (!gsi_one_before_end_p (i))
210 pp_newline (buffer);
215 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
216 FLAGS as in pp_gimple_stmt_1. */
218 void
219 print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
221 pretty_printer buffer;
222 pp_needs_newline (&buffer) = true;
223 buffer.buffer->stream = file;
224 dump_gimple_seq (&buffer, seq, spc, flags);
225 pp_newline_and_flush (&buffer);
229 /* Print the GIMPLE sequence SEQ on stderr. */
231 DEBUG_FUNCTION void
232 debug_gimple_seq (gimple_seq seq)
234 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
238 /* A simple helper to pretty-print some of the gimple tuples in the printf
239 style. The format modifiers are preceded by '%' and are:
240 'G' - outputs a string corresponding to the code of the given gimple,
241 'S' - outputs a gimple_seq with indent of spc + 2,
242 'T' - outputs the tree t,
243 'd' - outputs an int as a decimal,
244 's' - outputs a string,
245 'n' - outputs a newline,
246 'x' - outputs an int as hexadecimal,
247 '+' - increases indent by 2 then outputs a newline,
248 '-' - decreases indent by 2 then outputs a newline. */
250 static void
251 dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags,
252 const char *fmt, ...)
254 va_list args;
255 const char *c;
256 const char *tmp;
258 va_start (args, fmt);
259 for (c = fmt; *c; c++)
261 if (*c == '%')
263 gimple_seq seq;
264 tree t;
265 gimple *g;
266 switch (*++c)
268 case 'G':
269 g = va_arg (args, gimple *);
270 tmp = gimple_code_name[gimple_code (g)];
271 pp_string (buffer, tmp);
272 break;
274 case 'S':
275 seq = va_arg (args, gimple_seq);
276 pp_newline (buffer);
277 dump_gimple_seq (buffer, seq, spc + 2, flags);
278 newline_and_indent (buffer, spc);
279 break;
281 case 'T':
282 t = va_arg (args, tree);
283 if (t == NULL_TREE)
284 pp_string (buffer, "NULL");
285 else
286 dump_generic_node (buffer, t, spc, flags, false);
287 break;
289 case 'd':
290 pp_decimal_int (buffer, va_arg (args, int));
291 break;
293 case 's':
294 pp_string (buffer, va_arg (args, char *));
295 break;
297 case 'n':
298 newline_and_indent (buffer, spc);
299 break;
301 case 'x':
302 pp_scalar (buffer, "%x", va_arg (args, int));
303 break;
305 case '+':
306 spc += 2;
307 newline_and_indent (buffer, spc);
308 break;
310 case '-':
311 spc -= 2;
312 newline_and_indent (buffer, spc);
313 break;
315 default:
316 gcc_unreachable ();
319 else
320 pp_character (buffer, *c);
322 va_end (args);
326 /* Helper for dump_gimple_assign. Print the unary RHS of the
327 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
329 static void
330 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc,
331 dump_flags_t flags)
333 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
334 tree lhs = gimple_assign_lhs (gs);
335 tree rhs = gimple_assign_rhs1 (gs);
337 switch (rhs_code)
339 case VIEW_CONVERT_EXPR:
340 case ASSERT_EXPR:
341 dump_generic_node (buffer, rhs, spc, flags, false);
342 break;
344 case FIXED_CONVERT_EXPR:
345 case ADDR_SPACE_CONVERT_EXPR:
346 case FIX_TRUNC_EXPR:
347 case FLOAT_EXPR:
348 CASE_CONVERT:
349 pp_left_paren (buffer);
350 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
351 pp_string (buffer, ") ");
352 if (op_prio (rhs) < op_code_prio (rhs_code))
354 pp_left_paren (buffer);
355 dump_generic_node (buffer, rhs, spc, flags, false);
356 pp_right_paren (buffer);
358 else
359 dump_generic_node (buffer, rhs, spc, flags, false);
360 break;
362 case PAREN_EXPR:
363 pp_string (buffer, "((");
364 dump_generic_node (buffer, rhs, spc, flags, false);
365 pp_string (buffer, "))");
366 break;
368 case ABS_EXPR:
369 case ABSU_EXPR:
370 if (flags & TDF_GIMPLE)
372 pp_string (buffer,
373 rhs_code == ABS_EXPR ? "__ABS " : "__ABSU ");
374 dump_generic_node (buffer, rhs, spc, flags, false);
376 else
378 pp_string (buffer,
379 rhs_code == ABS_EXPR ? "ABS_EXPR <" : "ABSU_EXPR <");
380 dump_generic_node (buffer, rhs, spc, flags, false);
381 pp_greater (buffer);
383 break;
385 default:
386 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
387 || TREE_CODE_CLASS (rhs_code) == tcc_constant
388 || TREE_CODE_CLASS (rhs_code) == tcc_reference
389 || rhs_code == SSA_NAME
390 || rhs_code == ADDR_EXPR
391 || rhs_code == CONSTRUCTOR)
393 dump_generic_node (buffer, rhs, spc, flags, false);
394 break;
396 else if (rhs_code == BIT_NOT_EXPR)
397 pp_complement (buffer);
398 else if (rhs_code == TRUTH_NOT_EXPR)
399 pp_exclamation (buffer);
400 else if (rhs_code == NEGATE_EXPR)
401 pp_minus (buffer);
402 else
404 pp_left_bracket (buffer);
405 pp_string (buffer, get_tree_code_name (rhs_code));
406 pp_string (buffer, "] ");
409 if (op_prio (rhs) < op_code_prio (rhs_code))
411 pp_left_paren (buffer);
412 dump_generic_node (buffer, rhs, spc, flags, false);
413 pp_right_paren (buffer);
415 else
416 dump_generic_node (buffer, rhs, spc, flags, false);
417 break;
422 /* Helper for dump_gimple_assign. Print the binary RHS of the
423 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
425 static void
426 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc,
427 dump_flags_t flags)
429 const char *p;
430 enum tree_code code = gimple_assign_rhs_code (gs);
431 switch (code)
433 case MIN_EXPR:
434 case MAX_EXPR:
435 if (flags & TDF_GIMPLE)
437 pp_string (buffer, code == MIN_EXPR ? "__MIN (" : "__MAX (");
438 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
439 false);
440 pp_string (buffer, ", ");
441 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
442 false);
443 pp_string (buffer, ")");
444 break;
446 else
447 gcc_fallthrough ();
448 case COMPLEX_EXPR:
449 case VEC_WIDEN_MULT_HI_EXPR:
450 case VEC_WIDEN_MULT_LO_EXPR:
451 case VEC_WIDEN_MULT_EVEN_EXPR:
452 case VEC_WIDEN_MULT_ODD_EXPR:
453 case VEC_PACK_TRUNC_EXPR:
454 case VEC_PACK_SAT_EXPR:
455 case VEC_PACK_FIX_TRUNC_EXPR:
456 case VEC_PACK_FLOAT_EXPR:
457 case VEC_WIDEN_LSHIFT_HI_EXPR:
458 case VEC_WIDEN_LSHIFT_LO_EXPR:
459 case VEC_SERIES_EXPR:
460 for (p = get_tree_code_name (code); *p; p++)
461 pp_character (buffer, TOUPPER (*p));
462 pp_string (buffer, " <");
463 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
464 pp_string (buffer, ", ");
465 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
466 pp_greater (buffer);
467 break;
469 default:
470 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
472 pp_left_paren (buffer);
473 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
474 false);
475 pp_right_paren (buffer);
477 else
478 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
479 pp_space (buffer);
480 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
481 pp_space (buffer);
482 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
484 pp_left_paren (buffer);
485 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
486 false);
487 pp_right_paren (buffer);
489 else
490 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
494 /* Helper for dump_gimple_assign. Print the ternary RHS of the
495 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
497 static void
498 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc,
499 dump_flags_t flags)
501 const char *p;
502 enum tree_code code = gimple_assign_rhs_code (gs);
503 switch (code)
505 case WIDEN_MULT_PLUS_EXPR:
506 case WIDEN_MULT_MINUS_EXPR:
507 for (p = get_tree_code_name (code); *p; p++)
508 pp_character (buffer, TOUPPER (*p));
509 pp_string (buffer, " <");
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);
515 pp_greater (buffer);
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 if (flags & TDF_GIMPLE)
540 pp_string (buffer, "__VEC_PERM (");
541 else
542 pp_string (buffer, "VEC_PERM_EXPR <");
543 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
544 pp_string (buffer, ", ");
545 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
546 pp_string (buffer, ", ");
547 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
548 if (flags & TDF_GIMPLE)
549 pp_right_paren (buffer);
550 else
551 pp_greater (buffer);
552 break;
554 case REALIGN_LOAD_EXPR:
555 pp_string (buffer, "REALIGN_LOAD <");
556 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
557 pp_string (buffer, ", ");
558 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
559 pp_string (buffer, ", ");
560 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
561 pp_greater (buffer);
562 break;
564 case COND_EXPR:
565 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
566 pp_string (buffer, " ? ");
567 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
568 pp_string (buffer, " : ");
569 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
570 break;
572 case VEC_COND_EXPR:
573 pp_string (buffer, "VEC_COND_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_greater (buffer);
580 break;
582 case BIT_INSERT_EXPR:
583 if (flags & TDF_GIMPLE)
585 pp_string (buffer, "__BIT_INSERT (");
586 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc,
587 flags | TDF_SLIM, false);
588 pp_string (buffer, ", ");
589 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc,
590 flags | TDF_SLIM, false);
591 pp_string (buffer, ", ");
592 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc,
593 flags | TDF_SLIM, false);
594 pp_right_paren (buffer);
596 else
598 pp_string (buffer, "BIT_INSERT_EXPR <");
599 dump_generic_node (buffer, gimple_assign_rhs1 (gs),
600 spc, flags, false);
601 pp_string (buffer, ", ");
602 dump_generic_node (buffer, gimple_assign_rhs2 (gs),
603 spc, flags, false);
604 pp_string (buffer, ", ");
605 dump_generic_node (buffer, gimple_assign_rhs3 (gs),
606 spc, flags, false);
607 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
609 pp_string (buffer, " (");
610 pp_decimal_int (buffer, TYPE_PRECISION
611 (TREE_TYPE (gimple_assign_rhs2 (gs))));
612 pp_string (buffer, " bits)");
614 pp_greater (buffer);
616 break;
618 default:
619 gcc_unreachable ();
624 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
625 pp_gimple_stmt_1. */
627 static void
628 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc,
629 dump_flags_t flags)
631 if (flags & TDF_RAW)
633 tree arg1 = NULL;
634 tree arg2 = NULL;
635 tree arg3 = NULL;
636 switch (gimple_num_ops (gs))
638 case 4:
639 arg3 = gimple_assign_rhs3 (gs);
640 /* FALLTHRU */
641 case 3:
642 arg2 = gimple_assign_rhs2 (gs);
643 /* FALLTHRU */
644 case 2:
645 arg1 = gimple_assign_rhs1 (gs);
646 break;
647 default:
648 gcc_unreachable ();
651 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
652 get_tree_code_name (gimple_assign_rhs_code (gs)),
653 gimple_assign_lhs (gs), arg1, arg2, arg3);
655 else
657 if (!(flags & TDF_RHS_ONLY))
659 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
660 pp_space (buffer);
661 pp_equal (buffer);
663 if (gimple_assign_nontemporal_move_p (gs))
664 pp_string (buffer, "{nt}");
666 if (gimple_has_volatile_ops (gs))
667 pp_string (buffer, "{v}");
669 pp_space (buffer);
672 if (gimple_num_ops (gs) == 2)
673 dump_unary_rhs (buffer, gs, spc, flags);
674 else if (gimple_num_ops (gs) == 3)
675 dump_binary_rhs (buffer, gs, spc, flags);
676 else if (gimple_num_ops (gs) == 4)
677 dump_ternary_rhs (buffer, gs, spc, flags);
678 else
679 gcc_unreachable ();
680 if (!(flags & TDF_RHS_ONLY))
681 pp_semicolon (buffer);
686 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
687 pp_gimple_stmt_1. */
689 static void
690 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc,
691 dump_flags_t flags)
693 tree t;
695 t = gimple_return_retval (gs);
696 if (flags & TDF_RAW)
697 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
698 else
700 pp_string (buffer, "return");
701 if (t)
703 pp_space (buffer);
704 dump_generic_node (buffer, t, spc, flags, false);
706 pp_semicolon (buffer);
711 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
712 dump_gimple_call. */
714 static void
715 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, dump_flags_t flags)
717 size_t i = 0;
719 /* Pretty print first arg to certain internal fns. */
720 if (gimple_call_internal_p (gs))
722 const char *const *enums = NULL;
723 unsigned limit = 0;
725 switch (gimple_call_internal_fn (gs))
727 case IFN_UNIQUE:
728 #define DEF(X) #X
729 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
730 #undef DEF
731 enums = unique_args;
733 limit = ARRAY_SIZE (unique_args);
734 break;
736 case IFN_GOACC_LOOP:
737 #define DEF(X) #X
738 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
739 #undef DEF
740 enums = loop_args;
741 limit = ARRAY_SIZE (loop_args);
742 break;
744 case IFN_GOACC_REDUCTION:
745 #define DEF(X) #X
746 static const char *const reduction_args[]
747 = {IFN_GOACC_REDUCTION_CODES};
748 #undef DEF
749 enums = reduction_args;
750 limit = ARRAY_SIZE (reduction_args);
751 break;
753 case IFN_ASAN_MARK:
754 #define DEF(X) #X
755 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
756 #undef DEF
757 enums = asan_mark_args;
758 limit = ARRAY_SIZE (asan_mark_args);
759 break;
761 default:
762 break;
764 if (limit)
766 tree arg0 = gimple_call_arg (gs, 0);
767 HOST_WIDE_INT v;
769 if (TREE_CODE (arg0) == INTEGER_CST
770 && tree_fits_shwi_p (arg0)
771 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
773 i++;
774 pp_string (buffer, enums[v]);
779 for (; i < gimple_call_num_args (gs); i++)
781 if (i)
782 pp_string (buffer, ", ");
783 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
786 if (gimple_call_va_arg_pack_p (gs))
788 if (i)
789 pp_string (buffer, ", ");
791 pp_string (buffer, "__builtin_va_arg_pack ()");
795 /* Dump the points-to solution *PT to BUFFER. */
797 static void
798 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
800 if (pt->anything)
802 pp_string (buffer, "anything ");
803 return;
805 if (pt->nonlocal)
806 pp_string (buffer, "nonlocal ");
807 if (pt->escaped)
808 pp_string (buffer, "escaped ");
809 if (pt->ipa_escaped)
810 pp_string (buffer, "unit-escaped ");
811 if (pt->null)
812 pp_string (buffer, "null ");
813 if (pt->vars
814 && !bitmap_empty_p (pt->vars))
816 bitmap_iterator bi;
817 unsigned i;
818 pp_string (buffer, "{ ");
819 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
821 pp_string (buffer, "D.");
822 pp_decimal_int (buffer, i);
823 pp_space (buffer);
825 pp_right_brace (buffer);
826 if (pt->vars_contains_nonlocal
827 || pt->vars_contains_escaped
828 || pt->vars_contains_escaped_heap
829 || pt->vars_contains_restrict)
831 const char *comma = "";
832 pp_string (buffer, " (");
833 if (pt->vars_contains_nonlocal)
835 pp_string (buffer, "nonlocal");
836 comma = ", ";
838 if (pt->vars_contains_escaped)
840 pp_string (buffer, comma);
841 pp_string (buffer, "escaped");
842 comma = ", ";
844 if (pt->vars_contains_escaped_heap)
846 pp_string (buffer, comma);
847 pp_string (buffer, "escaped heap");
848 comma = ", ";
850 if (pt->vars_contains_restrict)
852 pp_string (buffer, comma);
853 pp_string (buffer, "restrict");
854 comma = ", ";
856 if (pt->vars_contains_interposable)
858 pp_string (buffer, comma);
859 pp_string (buffer, "interposable");
861 pp_string (buffer, ")");
867 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
868 pp_gimple_stmt_1. */
870 static void
871 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
872 dump_flags_t flags)
874 tree lhs = gimple_call_lhs (gs);
875 tree fn = gimple_call_fn (gs);
877 if (flags & TDF_ALIAS)
879 struct pt_solution *pt;
880 pt = gimple_call_use_set (gs);
881 if (!pt_solution_empty_p (pt))
883 pp_string (buffer, "# USE = ");
884 pp_points_to_solution (buffer, pt);
885 newline_and_indent (buffer, spc);
887 pt = gimple_call_clobber_set (gs);
888 if (!pt_solution_empty_p (pt))
890 pp_string (buffer, "# CLB = ");
891 pp_points_to_solution (buffer, pt);
892 newline_and_indent (buffer, spc);
896 if (flags & TDF_RAW)
898 if (gimple_call_internal_p (gs))
899 dump_gimple_fmt (buffer, spc, flags, "%G <.%s, %T", gs,
900 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
901 else
902 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
903 if (gimple_call_num_args (gs) > 0)
905 pp_string (buffer, ", ");
906 dump_gimple_call_args (buffer, gs, flags);
908 pp_greater (buffer);
910 else
912 if (lhs && !(flags & TDF_RHS_ONLY))
914 dump_generic_node (buffer, lhs, spc, flags, false);
915 pp_string (buffer, " =");
917 if (gimple_has_volatile_ops (gs))
918 pp_string (buffer, "{v}");
920 pp_space (buffer);
922 if (gimple_call_internal_p (gs))
924 pp_dot (buffer);
925 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
927 else
928 print_call_name (buffer, fn, flags);
929 pp_string (buffer, " (");
930 dump_gimple_call_args (buffer, gs, flags);
931 pp_right_paren (buffer);
932 if (!(flags & TDF_RHS_ONLY))
933 pp_semicolon (buffer);
936 if (gimple_call_chain (gs))
938 pp_string (buffer, " [static-chain: ");
939 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
940 pp_right_bracket (buffer);
943 if (gimple_call_return_slot_opt_p (gs))
944 pp_string (buffer, " [return slot optimization]");
945 if (gimple_call_tail_p (gs))
946 pp_string (buffer, " [tail call]");
947 if (gimple_call_must_tail_p (gs))
948 pp_string (buffer, " [must tail call]");
950 if (fn == NULL)
951 return;
953 /* Dump the arguments of _ITM_beginTransaction sanely. */
954 if (TREE_CODE (fn) == ADDR_EXPR)
955 fn = TREE_OPERAND (fn, 0);
956 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
957 pp_string (buffer, " [tm-clone]");
958 if (TREE_CODE (fn) == FUNCTION_DECL
959 && fndecl_built_in_p (fn, BUILT_IN_TM_START)
960 && gimple_call_num_args (gs) > 0)
962 tree t = gimple_call_arg (gs, 0);
963 unsigned HOST_WIDE_INT props;
964 gcc_assert (TREE_CODE (t) == INTEGER_CST);
966 pp_string (buffer, " [ ");
968 /* Get the transaction code properties. */
969 props = TREE_INT_CST_LOW (t);
971 if (props & PR_INSTRUMENTEDCODE)
972 pp_string (buffer, "instrumentedCode ");
973 if (props & PR_UNINSTRUMENTEDCODE)
974 pp_string (buffer, "uninstrumentedCode ");
975 if (props & PR_HASNOXMMUPDATE)
976 pp_string (buffer, "hasNoXMMUpdate ");
977 if (props & PR_HASNOABORT)
978 pp_string (buffer, "hasNoAbort ");
979 if (props & PR_HASNOIRREVOCABLE)
980 pp_string (buffer, "hasNoIrrevocable ");
981 if (props & PR_DOESGOIRREVOCABLE)
982 pp_string (buffer, "doesGoIrrevocable ");
983 if (props & PR_HASNOSIMPLEREADS)
984 pp_string (buffer, "hasNoSimpleReads ");
985 if (props & PR_AWBARRIERSOMITTED)
986 pp_string (buffer, "awBarriersOmitted ");
987 if (props & PR_RARBARRIERSOMITTED)
988 pp_string (buffer, "RaRBarriersOmitted ");
989 if (props & PR_UNDOLOGCODE)
990 pp_string (buffer, "undoLogCode ");
991 if (props & PR_PREFERUNINSTRUMENTED)
992 pp_string (buffer, "preferUninstrumented ");
993 if (props & PR_EXCEPTIONBLOCK)
994 pp_string (buffer, "exceptionBlock ");
995 if (props & PR_HASELSE)
996 pp_string (buffer, "hasElse ");
997 if (props & PR_READONLY)
998 pp_string (buffer, "readOnly ");
1000 pp_right_bracket (buffer);
1005 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
1006 pp_gimple_stmt_1. */
1008 static void
1009 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
1010 dump_flags_t flags)
1012 unsigned int i;
1014 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
1015 if (flags & TDF_RAW)
1016 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
1017 gimple_switch_index (gs));
1018 else
1020 pp_string (buffer, "switch (");
1021 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
1022 if (flags & TDF_GIMPLE)
1023 pp_string (buffer, ") {");
1024 else
1025 pp_string (buffer, ") <");
1028 for (i = 0; i < gimple_switch_num_labels (gs); i++)
1030 tree case_label = gimple_switch_label (gs, i);
1031 gcc_checking_assert (case_label != NULL_TREE);
1032 dump_generic_node (buffer, case_label, spc, flags, false);
1033 pp_space (buffer);
1034 tree label = CASE_LABEL (case_label);
1035 dump_generic_node (buffer, label, spc, flags, false);
1037 if (cfun && cfun->cfg)
1039 basic_block dest = label_to_block (cfun, label);
1040 if (dest)
1042 edge label_edge = find_edge (gimple_bb (gs), dest);
1043 if (label_edge && !(flags & TDF_GIMPLE))
1044 dump_edge_probability (buffer, label_edge);
1048 if (i < gimple_switch_num_labels (gs) - 1)
1050 if (flags & TDF_GIMPLE)
1051 pp_string (buffer, "; ");
1052 else
1053 pp_string (buffer, ", ");
1056 if (flags & TDF_GIMPLE)
1057 pp_string (buffer, "; }");
1058 else
1059 pp_greater (buffer);
1063 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1064 pp_gimple_stmt_1. */
1066 static void
1067 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc,
1068 dump_flags_t flags)
1070 if (flags & TDF_RAW)
1071 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1072 get_tree_code_name (gimple_cond_code (gs)),
1073 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1074 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1075 else
1077 if (!(flags & TDF_RHS_ONLY))
1078 pp_string (buffer, "if (");
1079 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
1080 pp_space (buffer);
1081 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1082 pp_space (buffer);
1083 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
1084 if (!(flags & TDF_RHS_ONLY))
1086 edge_iterator ei;
1087 edge e, true_edge = NULL, false_edge = NULL;
1088 basic_block bb = gimple_bb (gs);
1090 if (bb)
1092 FOR_EACH_EDGE (e, ei, bb->succs)
1094 if (e->flags & EDGE_TRUE_VALUE)
1095 true_edge = e;
1096 else if (e->flags & EDGE_FALSE_VALUE)
1097 false_edge = e;
1101 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1103 pp_right_paren (buffer);
1105 if (gimple_cond_true_label (gs))
1107 pp_string (buffer, " goto ");
1108 dump_generic_node (buffer, gimple_cond_true_label (gs),
1109 spc, flags, false);
1110 if (has_edge_info && !(flags & TDF_GIMPLE))
1111 dump_edge_probability (buffer, true_edge);
1112 pp_semicolon (buffer);
1114 if (gimple_cond_false_label (gs))
1116 pp_string (buffer, " else goto ");
1117 dump_generic_node (buffer, gimple_cond_false_label (gs),
1118 spc, flags, false);
1119 if (has_edge_info && !(flags & TDF_GIMPLE))
1120 dump_edge_probability (buffer, false_edge);
1122 pp_semicolon (buffer);
1129 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1130 spaces of indent. FLAGS specifies details to show in the dump (see
1131 TDF_* in dumpfils.h). */
1133 static void
1134 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
1135 dump_flags_t flags)
1137 tree label = gimple_label_label (gs);
1138 if (flags & TDF_RAW)
1139 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1140 else
1142 dump_generic_node (buffer, label, spc, flags, false);
1143 pp_colon (buffer);
1145 if (flags & TDF_GIMPLE)
1146 return;
1147 if (DECL_NONLOCAL (label))
1148 pp_string (buffer, " [non-local]");
1149 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1150 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1153 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1154 spaces of indent. FLAGS specifies details to show in the dump (see
1155 TDF_* in dumpfile.h). */
1157 static void
1158 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc,
1159 dump_flags_t flags)
1161 tree label = gimple_goto_dest (gs);
1162 if (flags & TDF_RAW)
1163 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1164 else
1165 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1169 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1170 spaces of indent. FLAGS specifies details to show in the dump (see
1171 TDF_* in dumpfile.h). */
1173 static void
1174 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc,
1175 dump_flags_t flags)
1177 if (flags & TDF_RAW)
1178 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1179 else
1180 pp_left_brace (buffer);
1181 if (!(flags & TDF_SLIM))
1183 tree var;
1185 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1187 newline_and_indent (buffer, 2);
1188 print_declaration (buffer, var, spc, flags);
1190 if (gimple_bind_vars (gs))
1191 pp_newline (buffer);
1193 pp_newline (buffer);
1194 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1195 newline_and_indent (buffer, spc);
1196 if (flags & TDF_RAW)
1197 pp_greater (buffer);
1198 else
1199 pp_right_brace (buffer);
1203 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1204 indent. FLAGS specifies details to show in the dump (see TDF_* in
1205 dumpfile.h). */
1207 static void
1208 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc,
1209 dump_flags_t flags)
1211 if (flags & TDF_RAW)
1213 const char *type;
1214 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1215 type = "GIMPLE_TRY_CATCH";
1216 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1217 type = "GIMPLE_TRY_FINALLY";
1218 else
1219 type = "UNKNOWN GIMPLE_TRY";
1220 dump_gimple_fmt (buffer, spc, flags,
1221 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1222 gimple_try_eval (gs), gimple_try_cleanup (gs));
1224 else
1226 pp_string (buffer, "try");
1227 newline_and_indent (buffer, spc + 2);
1228 pp_left_brace (buffer);
1229 pp_newline (buffer);
1231 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1232 newline_and_indent (buffer, spc + 2);
1233 pp_right_brace (buffer);
1235 gimple_seq seq = gimple_try_cleanup (gs);
1237 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1239 newline_and_indent (buffer, spc);
1240 pp_string (buffer, "catch");
1241 newline_and_indent (buffer, spc + 2);
1242 pp_left_brace (buffer);
1244 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1246 newline_and_indent (buffer, spc);
1247 pp_string (buffer, "finally");
1248 newline_and_indent (buffer, spc + 2);
1249 pp_left_brace (buffer);
1251 if (seq && is_a <geh_else *> (gimple_seq_first_stmt (seq))
1252 && gimple_seq_nondebug_singleton_p (seq))
1254 geh_else *stmt = as_a <geh_else *> (gimple_seq_first_stmt (seq));
1255 seq = gimple_eh_else_n_body (stmt);
1256 pp_newline (buffer);
1257 dump_gimple_seq (buffer, seq, spc + 4, flags);
1258 newline_and_indent (buffer, spc + 2);
1259 pp_right_brace (buffer);
1260 seq = gimple_eh_else_e_body (stmt);
1261 newline_and_indent (buffer, spc);
1262 pp_string (buffer, "else");
1263 newline_and_indent (buffer, spc + 2);
1264 pp_left_brace (buffer);
1267 else
1268 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1270 pp_newline (buffer);
1271 dump_gimple_seq (buffer, seq, spc + 4, flags);
1272 newline_and_indent (buffer, spc + 2);
1273 pp_right_brace (buffer);
1278 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1279 indent. FLAGS specifies details to show in the dump (see TDF_* in
1280 dumpfile.h). */
1282 static void
1283 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc,
1284 dump_flags_t flags)
1286 if (flags & TDF_RAW)
1287 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1288 gimple_catch_types (gs), gimple_catch_handler (gs));
1289 else
1290 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1291 gimple_catch_types (gs), gimple_catch_handler (gs));
1295 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1296 indent. FLAGS specifies details to show in the dump (see TDF_* in
1297 dumpfile.h). */
1299 static void
1300 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1301 dump_flags_t flags)
1303 if (flags & TDF_RAW)
1304 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1305 gimple_eh_filter_types (gs),
1306 gimple_eh_filter_failure (gs));
1307 else
1308 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1309 gimple_eh_filter_types (gs),
1310 gimple_eh_filter_failure (gs));
1314 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1316 static void
1317 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1318 geh_mnt *gs, int spc, dump_flags_t flags)
1320 if (flags & TDF_RAW)
1321 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1322 gimple_eh_must_not_throw_fndecl (gs));
1323 else
1324 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1325 gimple_eh_must_not_throw_fndecl (gs));
1329 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1330 indent. FLAGS specifies details to show in the dump (see TDF_* in
1331 dumpfile.h). */
1333 static void
1334 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1335 dump_flags_t flags)
1337 if (flags & TDF_RAW)
1338 dump_gimple_fmt (buffer, spc, flags,
1339 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1340 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1341 else
1342 dump_gimple_fmt (buffer, spc, flags,
1343 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1344 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1348 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1349 indent. FLAGS specifies details to show in the dump (see TDF_* in
1350 dumpfile.h). */
1352 static void
1353 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc,
1354 dump_flags_t flags)
1356 if (flags & TDF_RAW)
1357 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1358 gimple_resx_region (gs));
1359 else
1360 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1363 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1365 static void
1366 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc,
1367 dump_flags_t flags)
1369 if (flags & TDF_RAW)
1370 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1371 gimple_eh_dispatch_region (gs));
1372 else
1373 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1374 gimple_eh_dispatch_region (gs));
1377 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1378 of indent. FLAGS specifies details to show in the dump (see TDF_*
1379 in dumpfile.h). */
1381 static void
1382 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc,
1383 dump_flags_t flags)
1385 switch (gs->subcode)
1387 case GIMPLE_DEBUG_BIND:
1388 if (flags & TDF_RAW)
1389 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1390 gimple_debug_bind_get_var (gs),
1391 gimple_debug_bind_get_value (gs));
1392 else
1393 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1394 gimple_debug_bind_get_var (gs),
1395 gimple_debug_bind_get_value (gs));
1396 break;
1398 case GIMPLE_DEBUG_SOURCE_BIND:
1399 if (flags & TDF_RAW)
1400 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1401 gimple_debug_source_bind_get_var (gs),
1402 gimple_debug_source_bind_get_value (gs));
1403 else
1404 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1405 gimple_debug_source_bind_get_var (gs),
1406 gimple_debug_source_bind_get_value (gs));
1407 break;
1409 case GIMPLE_DEBUG_BEGIN_STMT:
1410 if (flags & TDF_RAW)
1411 dump_gimple_fmt (buffer, spc, flags, "%G BEGIN_STMT", gs);
1412 else
1413 dump_gimple_fmt (buffer, spc, flags, "# DEBUG BEGIN_STMT");
1414 break;
1416 case GIMPLE_DEBUG_INLINE_ENTRY:
1417 if (flags & TDF_RAW)
1418 dump_gimple_fmt (buffer, spc, flags, "%G INLINE_ENTRY %T", gs,
1419 gimple_block (gs)
1420 ? block_ultimate_origin (gimple_block (gs))
1421 : NULL_TREE);
1422 else
1423 dump_gimple_fmt (buffer, spc, flags, "# DEBUG INLINE_ENTRY %T",
1424 gimple_block (gs)
1425 ? block_ultimate_origin (gimple_block (gs))
1426 : NULL_TREE);
1427 break;
1429 default:
1430 gcc_unreachable ();
1434 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1435 static void
1436 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc,
1437 dump_flags_t flags)
1439 size_t i;
1441 if (flags & TDF_RAW)
1443 const char *kind;
1444 switch (gimple_omp_for_kind (gs))
1446 case GF_OMP_FOR_KIND_FOR:
1447 kind = "";
1448 break;
1449 case GF_OMP_FOR_KIND_DISTRIBUTE:
1450 kind = " distribute";
1451 break;
1452 case GF_OMP_FOR_KIND_TASKLOOP:
1453 kind = " taskloop";
1454 break;
1455 case GF_OMP_FOR_KIND_OACC_LOOP:
1456 kind = " oacc_loop";
1457 break;
1458 case GF_OMP_FOR_KIND_SIMD:
1459 kind = " simd";
1460 break;
1461 default:
1462 gcc_unreachable ();
1464 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1465 kind, gimple_omp_body (gs));
1466 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1467 dump_gimple_fmt (buffer, spc, flags, " >,");
1468 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1469 dump_gimple_fmt (buffer, spc, flags,
1470 "%+%T, %T, %T, %s, %T,%n",
1471 gimple_omp_for_index (gs, i),
1472 gimple_omp_for_initial (gs, i),
1473 gimple_omp_for_final (gs, i),
1474 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1475 gimple_omp_for_incr (gs, i));
1476 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1477 gimple_omp_for_pre_body (gs));
1479 else
1481 switch (gimple_omp_for_kind (gs))
1483 case GF_OMP_FOR_KIND_FOR:
1484 pp_string (buffer, "#pragma omp for");
1485 break;
1486 case GF_OMP_FOR_KIND_DISTRIBUTE:
1487 pp_string (buffer, "#pragma omp distribute");
1488 break;
1489 case GF_OMP_FOR_KIND_TASKLOOP:
1490 pp_string (buffer, "#pragma omp taskloop");
1491 break;
1492 case GF_OMP_FOR_KIND_OACC_LOOP:
1493 pp_string (buffer, "#pragma acc loop");
1494 break;
1495 case GF_OMP_FOR_KIND_SIMD:
1496 pp_string (buffer, "#pragma omp simd");
1497 break;
1498 case GF_OMP_FOR_KIND_GRID_LOOP:
1499 pp_string (buffer, "#pragma omp for grid_loop");
1500 break;
1501 default:
1502 gcc_unreachable ();
1504 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1505 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1507 if (i)
1508 spc += 2;
1509 newline_and_indent (buffer, spc);
1510 pp_string (buffer, "for (");
1511 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1512 flags, false);
1513 pp_string (buffer, " = ");
1514 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1515 flags, false);
1516 pp_string (buffer, "; ");
1518 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1519 flags, false);
1520 pp_space (buffer);
1521 switch (gimple_omp_for_cond (gs, i))
1523 case LT_EXPR:
1524 pp_less (buffer);
1525 break;
1526 case GT_EXPR:
1527 pp_greater (buffer);
1528 break;
1529 case LE_EXPR:
1530 pp_less_equal (buffer);
1531 break;
1532 case GE_EXPR:
1533 pp_greater_equal (buffer);
1534 break;
1535 case NE_EXPR:
1536 pp_string (buffer, "!=");
1537 break;
1538 default:
1539 gcc_unreachable ();
1541 pp_space (buffer);
1542 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1543 flags, false);
1544 pp_string (buffer, "; ");
1546 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1547 flags, false);
1548 pp_string (buffer, " = ");
1549 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1550 flags, false);
1551 pp_right_paren (buffer);
1554 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1556 newline_and_indent (buffer, spc + 2);
1557 pp_left_brace (buffer);
1558 pp_newline (buffer);
1559 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1560 newline_and_indent (buffer, spc + 2);
1561 pp_right_brace (buffer);
1566 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1568 static void
1569 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1570 int spc, dump_flags_t flags)
1572 if (flags & TDF_RAW)
1574 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1575 gimple_omp_continue_control_def (gs),
1576 gimple_omp_continue_control_use (gs));
1578 else
1580 pp_string (buffer, "#pragma omp continue (");
1581 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1582 spc, flags, false);
1583 pp_comma (buffer);
1584 pp_space (buffer);
1585 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1586 spc, flags, false);
1587 pp_right_paren (buffer);
1591 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1593 static void
1594 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1595 int spc, dump_flags_t flags)
1597 if (flags & TDF_RAW)
1599 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1600 gimple_omp_body (gs));
1601 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1602 dump_gimple_fmt (buffer, spc, flags, " >");
1604 else
1606 pp_string (buffer, "#pragma omp single");
1607 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1608 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1610 newline_and_indent (buffer, spc + 2);
1611 pp_left_brace (buffer);
1612 pp_newline (buffer);
1613 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1614 newline_and_indent (buffer, spc + 2);
1615 pp_right_brace (buffer);
1620 /* Dump a GIMPLE_OMP_TASKGROUP tuple on the pretty_printer BUFFER. */
1622 static void
1623 dump_gimple_omp_taskgroup (pretty_printer *buffer, gimple *gs,
1624 int spc, dump_flags_t flags)
1626 if (flags & TDF_RAW)
1628 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1629 gimple_omp_body (gs));
1630 dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
1631 dump_gimple_fmt (buffer, spc, flags, " >");
1633 else
1635 pp_string (buffer, "#pragma omp taskgroup");
1636 dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
1637 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1639 newline_and_indent (buffer, spc + 2);
1640 pp_left_brace (buffer);
1641 pp_newline (buffer);
1642 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1643 newline_and_indent (buffer, spc + 2);
1644 pp_right_brace (buffer);
1649 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1651 static void
1652 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1653 int spc, dump_flags_t flags)
1655 const char *kind;
1656 switch (gimple_omp_target_kind (gs))
1658 case GF_OMP_TARGET_KIND_REGION:
1659 kind = "";
1660 break;
1661 case GF_OMP_TARGET_KIND_DATA:
1662 kind = " data";
1663 break;
1664 case GF_OMP_TARGET_KIND_UPDATE:
1665 kind = " update";
1666 break;
1667 case GF_OMP_TARGET_KIND_ENTER_DATA:
1668 kind = " enter data";
1669 break;
1670 case GF_OMP_TARGET_KIND_EXIT_DATA:
1671 kind = " exit data";
1672 break;
1673 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1674 kind = " oacc_kernels";
1675 break;
1676 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1677 kind = " oacc_parallel";
1678 break;
1679 case GF_OMP_TARGET_KIND_OACC_SERIAL:
1680 kind = " oacc_serial";
1681 break;
1682 case GF_OMP_TARGET_KIND_OACC_DATA:
1683 kind = " oacc_data";
1684 break;
1685 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1686 kind = " oacc_update";
1687 break;
1688 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1689 kind = " oacc_enter_exit_data";
1690 break;
1691 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1692 kind = " oacc_declare";
1693 break;
1694 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1695 kind = " oacc_host_data";
1696 break;
1697 default:
1698 gcc_unreachable ();
1700 if (flags & TDF_RAW)
1702 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1703 kind, gimple_omp_body (gs));
1704 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1705 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1706 gimple_omp_target_child_fn (gs),
1707 gimple_omp_target_data_arg (gs));
1709 else
1711 pp_string (buffer, "#pragma omp target");
1712 pp_string (buffer, kind);
1713 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1714 if (gimple_omp_target_child_fn (gs))
1716 pp_string (buffer, " [child fn: ");
1717 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1718 spc, flags, false);
1719 pp_string (buffer, " (");
1720 if (gimple_omp_target_data_arg (gs))
1721 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1722 spc, flags, false);
1723 else
1724 pp_string (buffer, "???");
1725 pp_string (buffer, ")]");
1727 gimple_seq body = gimple_omp_body (gs);
1728 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1730 newline_and_indent (buffer, spc + 2);
1731 pp_left_brace (buffer);
1732 pp_newline (buffer);
1733 dump_gimple_seq (buffer, body, spc + 4, flags);
1734 newline_and_indent (buffer, spc + 2);
1735 pp_right_brace (buffer);
1737 else if (body)
1739 pp_newline (buffer);
1740 dump_gimple_seq (buffer, body, spc + 2, flags);
1745 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1747 static void
1748 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1749 dump_flags_t flags)
1751 if (flags & TDF_RAW)
1753 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1754 gimple_omp_body (gs));
1755 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1756 dump_gimple_fmt (buffer, spc, flags, " >");
1758 else
1760 pp_string (buffer, "#pragma omp teams");
1761 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1762 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1764 newline_and_indent (buffer, spc + 2);
1765 pp_character (buffer, '{');
1766 pp_newline (buffer);
1767 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1768 newline_and_indent (buffer, spc + 2);
1769 pp_character (buffer, '}');
1774 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1776 static void
1777 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1778 int spc, dump_flags_t flags)
1780 if (flags & TDF_RAW)
1782 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1783 gimple_omp_body (gs));
1784 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1785 dump_gimple_fmt (buffer, spc, flags, " >");
1787 else
1789 pp_string (buffer, "#pragma omp sections");
1790 if (gimple_omp_sections_control (gs))
1792 pp_string (buffer, " <");
1793 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1794 flags, false);
1795 pp_greater (buffer);
1797 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1798 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1800 newline_and_indent (buffer, spc + 2);
1801 pp_left_brace (buffer);
1802 pp_newline (buffer);
1803 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1804 newline_and_indent (buffer, spc + 2);
1805 pp_right_brace (buffer);
1810 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the
1811 pretty_printer BUFFER. */
1813 static void
1814 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc,
1815 dump_flags_t flags)
1817 if (flags & TDF_RAW)
1818 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1819 gimple_omp_body (gs));
1820 else
1822 switch (gimple_code (gs))
1824 case GIMPLE_OMP_MASTER:
1825 pp_string (buffer, "#pragma omp master");
1826 break;
1827 case GIMPLE_OMP_SECTION:
1828 pp_string (buffer, "#pragma omp section");
1829 break;
1830 case GIMPLE_OMP_GRID_BODY:
1831 pp_string (buffer, "#pragma omp gridified body");
1832 break;
1833 default:
1834 gcc_unreachable ();
1836 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1838 newline_and_indent (buffer, spc + 2);
1839 pp_left_brace (buffer);
1840 pp_newline (buffer);
1841 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1842 newline_and_indent (buffer, spc + 2);
1843 pp_right_brace (buffer);
1848 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1850 static void
1851 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1852 int spc, dump_flags_t flags)
1854 if (flags & TDF_RAW)
1855 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1856 gimple_omp_body (gs));
1857 else
1859 pp_string (buffer, "#pragma omp critical");
1860 if (gimple_omp_critical_name (gs))
1862 pp_string (buffer, " (");
1863 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1864 flags, false);
1865 pp_right_paren (buffer);
1867 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1868 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1870 newline_and_indent (buffer, spc + 2);
1871 pp_left_brace (buffer);
1872 pp_newline (buffer);
1873 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1874 newline_and_indent (buffer, spc + 2);
1875 pp_right_brace (buffer);
1880 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1882 static void
1883 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1884 int spc, dump_flags_t flags)
1886 if (flags & TDF_RAW)
1887 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1888 gimple_omp_body (gs));
1889 else
1891 pp_string (buffer, "#pragma omp ordered");
1892 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1893 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1895 newline_and_indent (buffer, spc + 2);
1896 pp_left_brace (buffer);
1897 pp_newline (buffer);
1898 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1899 newline_and_indent (buffer, spc + 2);
1900 pp_right_brace (buffer);
1905 /* Dump a GIMPLE_OMP_SCAN tuple on the pretty_printer BUFFER. */
1907 static void
1908 dump_gimple_omp_scan (pretty_printer *buffer, gomp_scan *gs,
1909 int spc, dump_flags_t flags)
1911 if (flags & TDF_RAW)
1912 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1913 gimple_omp_body (gs));
1914 else
1916 if (gimple_omp_scan_clauses (gs))
1918 pp_string (buffer, "#pragma omp scan");
1919 dump_omp_clauses (buffer, gimple_omp_scan_clauses (gs), spc, flags);
1921 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1923 newline_and_indent (buffer, spc + 2);
1924 pp_left_brace (buffer);
1925 pp_newline (buffer);
1926 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1927 newline_and_indent (buffer, spc + 2);
1928 pp_right_brace (buffer);
1933 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1935 static void
1936 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc,
1937 dump_flags_t flags)
1939 if (flags & TDF_RAW)
1941 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1942 (int) gimple_omp_return_nowait_p (gs));
1943 if (gimple_omp_return_lhs (gs))
1944 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1945 gimple_omp_return_lhs (gs));
1946 else
1947 dump_gimple_fmt (buffer, spc, flags, ">");
1949 else
1951 pp_string (buffer, "#pragma omp return");
1952 if (gimple_omp_return_nowait_p (gs))
1953 pp_string (buffer, "(nowait)");
1954 if (gimple_omp_return_lhs (gs))
1956 pp_string (buffer, " (set ");
1957 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1958 spc, flags, false);
1959 pp_character (buffer, ')');
1964 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1966 static void
1967 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1968 int spc, dump_flags_t flags)
1970 unsigned subcode = gimple_transaction_subcode (gs);
1972 if (flags & TDF_RAW)
1974 dump_gimple_fmt (buffer, spc, flags,
1975 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1976 "<%+BODY <%S> >",
1977 gs, subcode, gimple_transaction_label_norm (gs),
1978 gimple_transaction_label_uninst (gs),
1979 gimple_transaction_label_over (gs),
1980 gimple_transaction_body (gs));
1982 else
1984 if (subcode & GTMA_IS_OUTER)
1985 pp_string (buffer, "__transaction_atomic [[outer]]");
1986 else if (subcode & GTMA_IS_RELAXED)
1987 pp_string (buffer, "__transaction_relaxed");
1988 else
1989 pp_string (buffer, "__transaction_atomic");
1990 subcode &= ~GTMA_DECLARATION_MASK;
1992 if (gimple_transaction_body (gs))
1994 newline_and_indent (buffer, spc + 2);
1995 pp_left_brace (buffer);
1996 pp_newline (buffer);
1997 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1998 spc + 4, flags);
1999 newline_and_indent (buffer, spc + 2);
2000 pp_right_brace (buffer);
2002 else
2004 pp_string (buffer, " //");
2005 if (gimple_transaction_label_norm (gs))
2007 pp_string (buffer, " NORM=");
2008 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
2009 spc, flags, false);
2011 if (gimple_transaction_label_uninst (gs))
2013 pp_string (buffer, " UNINST=");
2014 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
2015 spc, flags, false);
2017 if (gimple_transaction_label_over (gs))
2019 pp_string (buffer, " OVER=");
2020 dump_generic_node (buffer, gimple_transaction_label_over (gs),
2021 spc, flags, false);
2023 if (subcode)
2025 pp_string (buffer, " SUBCODE=[ ");
2026 if (subcode & GTMA_HAVE_ABORT)
2028 pp_string (buffer, "GTMA_HAVE_ABORT ");
2029 subcode &= ~GTMA_HAVE_ABORT;
2031 if (subcode & GTMA_HAVE_LOAD)
2033 pp_string (buffer, "GTMA_HAVE_LOAD ");
2034 subcode &= ~GTMA_HAVE_LOAD;
2036 if (subcode & GTMA_HAVE_STORE)
2038 pp_string (buffer, "GTMA_HAVE_STORE ");
2039 subcode &= ~GTMA_HAVE_STORE;
2041 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
2043 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
2044 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
2046 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
2048 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
2049 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
2051 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
2053 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
2054 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
2056 if (subcode)
2057 pp_printf (buffer, "0x%x ", subcode);
2058 pp_right_bracket (buffer);
2064 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
2065 indent. FLAGS specifies details to show in the dump (see TDF_* in
2066 dumpfile.h). */
2068 static void
2069 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, dump_flags_t flags)
2071 unsigned int i, n, f, fields;
2073 if (flags & TDF_RAW)
2075 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
2076 gimple_asm_string (gs));
2078 n = gimple_asm_noutputs (gs);
2079 if (n)
2081 newline_and_indent (buffer, spc + 2);
2082 pp_string (buffer, "OUTPUT: ");
2083 for (i = 0; i < n; i++)
2085 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2086 spc, flags, false);
2087 if (i < n - 1)
2088 pp_string (buffer, ", ");
2092 n = gimple_asm_ninputs (gs);
2093 if (n)
2095 newline_and_indent (buffer, spc + 2);
2096 pp_string (buffer, "INPUT: ");
2097 for (i = 0; i < n; i++)
2099 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2100 spc, flags, false);
2101 if (i < n - 1)
2102 pp_string (buffer, ", ");
2106 n = gimple_asm_nclobbers (gs);
2107 if (n)
2109 newline_and_indent (buffer, spc + 2);
2110 pp_string (buffer, "CLOBBER: ");
2111 for (i = 0; i < n; i++)
2113 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2114 spc, flags, false);
2115 if (i < n - 1)
2116 pp_string (buffer, ", ");
2120 n = gimple_asm_nlabels (gs);
2121 if (n)
2123 newline_and_indent (buffer, spc + 2);
2124 pp_string (buffer, "LABEL: ");
2125 for (i = 0; i < n; i++)
2127 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2128 spc, flags, false);
2129 if (i < n - 1)
2130 pp_string (buffer, ", ");
2134 newline_and_indent (buffer, spc);
2135 pp_greater (buffer);
2137 else
2139 pp_string (buffer, "__asm__");
2140 if (gimple_asm_volatile_p (gs))
2141 pp_string (buffer, " __volatile__");
2142 if (gimple_asm_inline_p (gs))
2143 pp_string (buffer, " __inline__");
2144 if (gimple_asm_nlabels (gs))
2145 pp_string (buffer, " goto");
2146 pp_string (buffer, "(\"");
2147 pp_string (buffer, gimple_asm_string (gs));
2148 pp_string (buffer, "\"");
2150 if (gimple_asm_nlabels (gs))
2151 fields = 4;
2152 else if (gimple_asm_nclobbers (gs))
2153 fields = 3;
2154 else if (gimple_asm_ninputs (gs))
2155 fields = 2;
2156 else if (gimple_asm_noutputs (gs))
2157 fields = 1;
2158 else
2159 fields = 0;
2161 for (f = 0; f < fields; ++f)
2163 pp_string (buffer, " : ");
2165 switch (f)
2167 case 0:
2168 n = gimple_asm_noutputs (gs);
2169 for (i = 0; i < n; i++)
2171 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2172 spc, flags, false);
2173 if (i < n - 1)
2174 pp_string (buffer, ", ");
2176 break;
2178 case 1:
2179 n = gimple_asm_ninputs (gs);
2180 for (i = 0; i < n; i++)
2182 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2183 spc, flags, false);
2184 if (i < n - 1)
2185 pp_string (buffer, ", ");
2187 break;
2189 case 2:
2190 n = gimple_asm_nclobbers (gs);
2191 for (i = 0; i < n; i++)
2193 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2194 spc, flags, false);
2195 if (i < n - 1)
2196 pp_string (buffer, ", ");
2198 break;
2200 case 3:
2201 n = gimple_asm_nlabels (gs);
2202 for (i = 0; i < n; i++)
2204 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2205 spc, flags, false);
2206 if (i < n - 1)
2207 pp_string (buffer, ", ");
2209 break;
2211 default:
2212 gcc_unreachable ();
2216 pp_string (buffer, ");");
2220 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2221 SPC spaces of indent. */
2223 static void
2224 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2226 if (TREE_CODE (node) != SSA_NAME)
2227 return;
2229 if (POINTER_TYPE_P (TREE_TYPE (node))
2230 && SSA_NAME_PTR_INFO (node))
2232 unsigned int align, misalign;
2233 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2234 pp_string (buffer, "# PT = ");
2235 pp_points_to_solution (buffer, &pi->pt);
2236 newline_and_indent (buffer, spc);
2237 if (get_ptr_info_alignment (pi, &align, &misalign))
2239 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2240 newline_and_indent (buffer, spc);
2244 if (!POINTER_TYPE_P (TREE_TYPE (node))
2245 && SSA_NAME_RANGE_INFO (node))
2247 wide_int min, max, nonzero_bits;
2248 value_range_kind range_type = get_range_info (node, &min, &max);
2250 if (range_type == VR_VARYING)
2251 pp_printf (buffer, "# RANGE VR_VARYING");
2252 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2254 pp_printf (buffer, "# RANGE ");
2255 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2256 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2257 pp_printf (buffer, ", ");
2258 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2259 pp_printf (buffer, "]");
2261 nonzero_bits = get_nonzero_bits (node);
2262 if (nonzero_bits != -1)
2264 pp_string (buffer, " NONZERO ");
2265 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2267 newline_and_indent (buffer, spc);
2271 /* As dump_ssaname_info, but dump to FILE. */
2273 void
2274 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2276 pretty_printer buffer;
2277 pp_needs_newline (&buffer) = true;
2278 buffer.buffer->stream = file;
2279 dump_ssaname_info (&buffer, node, spc);
2280 pp_flush (&buffer);
2283 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2284 The caller is responsible for calling pp_flush on BUFFER to finalize
2285 pretty printer. If COMMENT is true, print this after #. */
2287 static void
2288 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2289 dump_flags_t flags)
2291 size_t i;
2292 tree lhs = gimple_phi_result (phi);
2294 if (flags & TDF_ALIAS)
2295 dump_ssaname_info (buffer, lhs, spc);
2297 if (comment)
2298 pp_string (buffer, "# ");
2300 if (flags & TDF_RAW)
2301 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2302 gimple_phi_result (phi));
2303 else
2305 dump_generic_node (buffer, lhs, spc, flags, false);
2306 if (flags & TDF_GIMPLE)
2307 pp_string (buffer, " = __PHI (");
2308 else
2309 pp_string (buffer, " = PHI <");
2311 for (i = 0; i < gimple_phi_num_args (phi); i++)
2313 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2314 dump_location (buffer, gimple_phi_arg_location (phi, i));
2315 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2316 if (flags & TDF_GIMPLE)
2318 pp_string (buffer, "__BB");
2319 pp_decimal_int (buffer, src->index);
2320 pp_string (buffer, ": ");
2322 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2323 false);
2324 if (! (flags & TDF_GIMPLE))
2326 pp_left_paren (buffer);
2327 pp_decimal_int (buffer, src->index);
2328 pp_right_paren (buffer);
2330 if (i < gimple_phi_num_args (phi) - 1)
2331 pp_string (buffer, ", ");
2333 if (flags & TDF_GIMPLE)
2334 pp_string (buffer, ");");
2335 else
2336 pp_greater (buffer);
2340 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2341 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2342 dumpfile.h). */
2344 static void
2345 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2346 int spc, dump_flags_t flags)
2348 if (flags & TDF_RAW)
2350 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2351 gimple_omp_body (gs));
2352 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2353 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2354 gimple_omp_parallel_child_fn (gs),
2355 gimple_omp_parallel_data_arg (gs));
2357 else
2359 gimple_seq body;
2360 pp_string (buffer, "#pragma omp parallel");
2361 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2362 if (gimple_omp_parallel_child_fn (gs))
2364 pp_string (buffer, " [child fn: ");
2365 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2366 spc, flags, false);
2367 pp_string (buffer, " (");
2368 if (gimple_omp_parallel_data_arg (gs))
2369 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2370 spc, flags, false);
2371 else
2372 pp_string (buffer, "???");
2373 pp_string (buffer, ")]");
2375 body = gimple_omp_body (gs);
2376 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2378 newline_and_indent (buffer, spc + 2);
2379 pp_left_brace (buffer);
2380 pp_newline (buffer);
2381 dump_gimple_seq (buffer, body, spc + 4, flags);
2382 newline_and_indent (buffer, spc + 2);
2383 pp_right_brace (buffer);
2385 else if (body)
2387 pp_newline (buffer);
2388 dump_gimple_seq (buffer, body, spc + 2, flags);
2394 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2395 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2396 dumpfile.h). */
2398 static void
2399 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2400 dump_flags_t flags)
2402 if (flags & TDF_RAW)
2404 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2405 gimple_omp_body (gs));
2406 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2407 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2408 gimple_omp_task_child_fn (gs),
2409 gimple_omp_task_data_arg (gs),
2410 gimple_omp_task_copy_fn (gs),
2411 gimple_omp_task_arg_size (gs),
2412 gimple_omp_task_arg_size (gs));
2414 else
2416 gimple_seq body;
2417 if (gimple_omp_task_taskloop_p (gs))
2418 pp_string (buffer, "#pragma omp taskloop");
2419 else if (gimple_omp_task_taskwait_p (gs))
2420 pp_string (buffer, "#pragma omp taskwait");
2421 else
2422 pp_string (buffer, "#pragma omp task");
2423 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2424 if (gimple_omp_task_child_fn (gs))
2426 pp_string (buffer, " [child fn: ");
2427 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2428 spc, flags, false);
2429 pp_string (buffer, " (");
2430 if (gimple_omp_task_data_arg (gs))
2431 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2432 spc, flags, false);
2433 else
2434 pp_string (buffer, "???");
2435 pp_string (buffer, ")]");
2437 body = gimple_omp_body (gs);
2438 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2440 newline_and_indent (buffer, spc + 2);
2441 pp_left_brace (buffer);
2442 pp_newline (buffer);
2443 dump_gimple_seq (buffer, body, spc + 4, flags);
2444 newline_and_indent (buffer, spc + 2);
2445 pp_right_brace (buffer);
2447 else if (body)
2449 pp_newline (buffer);
2450 dump_gimple_seq (buffer, body, spc + 2, flags);
2456 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2457 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2458 in dumpfile.h). */
2460 static void
2461 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2462 int spc, dump_flags_t flags)
2464 if (flags & TDF_RAW)
2466 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2467 gimple_omp_atomic_load_lhs (gs),
2468 gimple_omp_atomic_load_rhs (gs));
2470 else
2472 pp_string (buffer, "#pragma omp atomic_load");
2473 dump_omp_atomic_memory_order (buffer,
2474 gimple_omp_atomic_memory_order (gs));
2475 if (gimple_omp_atomic_need_value_p (gs))
2476 pp_string (buffer, " [needed]");
2477 newline_and_indent (buffer, spc + 2);
2478 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2479 spc, flags, false);
2480 pp_space (buffer);
2481 pp_equal (buffer);
2482 pp_space (buffer);
2483 pp_star (buffer);
2484 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2485 spc, flags, false);
2489 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2490 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2491 in dumpfile.h). */
2493 static void
2494 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2495 gomp_atomic_store *gs, int spc,
2496 dump_flags_t flags)
2498 if (flags & TDF_RAW)
2500 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2501 gimple_omp_atomic_store_val (gs));
2503 else
2505 pp_string (buffer, "#pragma omp atomic_store");
2506 dump_omp_atomic_memory_order (buffer,
2507 gimple_omp_atomic_memory_order (gs));
2508 pp_space (buffer);
2509 if (gimple_omp_atomic_need_value_p (gs))
2510 pp_string (buffer, "[needed] ");
2511 pp_left_paren (buffer);
2512 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2513 spc, flags, false);
2514 pp_right_paren (buffer);
2519 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2520 FLAGS are as in pp_gimple_stmt_1. */
2522 static void
2523 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc,
2524 dump_flags_t flags)
2526 tree vdef = gimple_vdef (gs);
2527 tree vuse = gimple_vuse (gs);
2529 if (vdef != NULL_TREE)
2531 pp_string (buffer, "# ");
2532 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2533 pp_string (buffer, " = VDEF <");
2534 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2535 pp_greater (buffer);
2536 newline_and_indent (buffer, spc);
2538 else if (vuse != NULL_TREE)
2540 pp_string (buffer, "# VUSE <");
2541 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2542 pp_greater (buffer);
2543 newline_and_indent (buffer, spc);
2548 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2549 spaces of indent. FLAGS specifies details to show in the dump (see
2550 TDF_* in dumpfile.h). The caller is responsible for calling
2551 pp_flush on BUFFER to finalize the pretty printer. */
2553 void
2554 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc,
2555 dump_flags_t flags)
2557 if (!gs)
2558 return;
2560 if (flags & TDF_STMTADDR)
2561 pp_printf (buffer, "<&%p> ", (void *) gs);
2563 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2564 dump_location (buffer, gimple_location (gs));
2566 if (flags & TDF_EH)
2568 int lp_nr = lookup_stmt_eh_lp (gs);
2569 if (lp_nr > 0)
2570 pp_printf (buffer, "[LP %d] ", lp_nr);
2571 else if (lp_nr < 0)
2572 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2575 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2576 && gimple_has_mem_ops (gs))
2577 dump_gimple_mem_ops (buffer, gs, spc, flags);
2579 if (gimple_has_lhs (gs)
2580 && (flags & TDF_ALIAS))
2581 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2583 switch (gimple_code (gs))
2585 case GIMPLE_ASM:
2586 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2587 break;
2589 case GIMPLE_ASSIGN:
2590 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2591 break;
2593 case GIMPLE_BIND:
2594 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2595 break;
2597 case GIMPLE_CALL:
2598 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2599 break;
2601 case GIMPLE_COND:
2602 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2603 break;
2605 case GIMPLE_LABEL:
2606 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2607 break;
2609 case GIMPLE_GOTO:
2610 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2611 break;
2613 case GIMPLE_NOP:
2614 pp_string (buffer, "GIMPLE_NOP");
2615 break;
2617 case GIMPLE_RETURN:
2618 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2619 break;
2621 case GIMPLE_SWITCH:
2622 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2623 break;
2625 case GIMPLE_TRY:
2626 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2627 break;
2629 case GIMPLE_PHI:
2630 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2631 break;
2633 case GIMPLE_OMP_PARALLEL:
2634 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2635 flags);
2636 break;
2638 case GIMPLE_OMP_TASK:
2639 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2640 break;
2642 case GIMPLE_OMP_ATOMIC_LOAD:
2643 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2644 spc, flags);
2645 break;
2647 case GIMPLE_OMP_ATOMIC_STORE:
2648 dump_gimple_omp_atomic_store (buffer,
2649 as_a <gomp_atomic_store *> (gs),
2650 spc, flags);
2651 break;
2653 case GIMPLE_OMP_FOR:
2654 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2655 break;
2657 case GIMPLE_OMP_CONTINUE:
2658 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2659 flags);
2660 break;
2662 case GIMPLE_OMP_SINGLE:
2663 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2664 flags);
2665 break;
2667 case GIMPLE_OMP_TARGET:
2668 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2669 flags);
2670 break;
2672 case GIMPLE_OMP_TEAMS:
2673 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2674 flags);
2675 break;
2677 case GIMPLE_OMP_RETURN:
2678 dump_gimple_omp_return (buffer, gs, spc, flags);
2679 break;
2681 case GIMPLE_OMP_SECTIONS:
2682 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2683 spc, flags);
2684 break;
2686 case GIMPLE_OMP_SECTIONS_SWITCH:
2687 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2688 break;
2690 case GIMPLE_OMP_TASKGROUP:
2691 dump_gimple_omp_taskgroup (buffer, gs, spc, flags);
2692 break;
2694 case GIMPLE_OMP_MASTER:
2695 case GIMPLE_OMP_SECTION:
2696 case GIMPLE_OMP_GRID_BODY:
2697 dump_gimple_omp_block (buffer, gs, spc, flags);
2698 break;
2700 case GIMPLE_OMP_ORDERED:
2701 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2702 flags);
2703 break;
2705 case GIMPLE_OMP_SCAN:
2706 dump_gimple_omp_scan (buffer, as_a <gomp_scan *> (gs), spc,
2707 flags);
2708 break;
2710 case GIMPLE_OMP_CRITICAL:
2711 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2712 flags);
2713 break;
2715 case GIMPLE_CATCH:
2716 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2717 break;
2719 case GIMPLE_EH_FILTER:
2720 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2721 break;
2723 case GIMPLE_EH_MUST_NOT_THROW:
2724 dump_gimple_eh_must_not_throw (buffer,
2725 as_a <geh_mnt *> (gs),
2726 spc, flags);
2727 break;
2729 case GIMPLE_EH_ELSE:
2730 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2731 break;
2733 case GIMPLE_RESX:
2734 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2735 break;
2737 case GIMPLE_EH_DISPATCH:
2738 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2739 flags);
2740 break;
2742 case GIMPLE_DEBUG:
2743 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2744 break;
2746 case GIMPLE_PREDICT:
2747 pp_string (buffer, "// predicted ");
2748 if (gimple_predict_outcome (gs))
2749 pp_string (buffer, "likely by ");
2750 else
2751 pp_string (buffer, "unlikely by ");
2752 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2753 pp_string (buffer, " predictor.");
2754 break;
2756 case GIMPLE_TRANSACTION:
2757 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2758 flags);
2759 break;
2761 default:
2762 GIMPLE_NIY;
2767 /* Dumps header of basic block BB to OUTF indented by INDENT
2768 spaces and details described by flags. */
2770 static void
2771 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
2772 dump_flags_t flags)
2774 if (flags & TDF_BLOCKS)
2776 if (flags & TDF_LINENO)
2778 gimple_stmt_iterator gsi;
2780 fputs (";; ", outf);
2782 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2783 if (!is_gimple_debug (gsi_stmt (gsi))
2784 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2786 fprintf (outf, "%*sstarting at line %d",
2787 indent, "", get_lineno (gsi_stmt (gsi)));
2788 break;
2790 if (bb->discriminator)
2791 fprintf (outf, ", discriminator %i", bb->discriminator);
2792 fputc ('\n', outf);
2795 else
2797 if (flags & TDF_GIMPLE)
2799 fprintf (outf, "%*s__BB(%d", indent, "", bb->index);
2800 if (bb->loop_father->header == bb)
2801 fprintf (outf, ",loop_header(%d)", bb->loop_father->num);
2802 if (bb->count.initialized_p ())
2803 fprintf (outf, ",%s(%d)",
2804 profile_quality_as_string (bb->count.quality ()),
2805 bb->count.value ());
2806 fprintf (outf, "):\n");
2808 else
2809 fprintf (outf, "%*s<bb %d> %s:\n",
2810 indent, "", bb->index, dump_profile (bb->count));
2815 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2816 spaces. */
2818 static void
2819 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2820 basic_block bb ATTRIBUTE_UNUSED,
2821 int indent ATTRIBUTE_UNUSED,
2822 dump_flags_t flags ATTRIBUTE_UNUSED)
2824 /* There is currently no GIMPLE-specific basic block info to dump. */
2825 return;
2829 /* Dump PHI nodes of basic block BB to BUFFER with details described
2830 by FLAGS and indented by INDENT spaces. */
2832 static void
2833 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
2834 dump_flags_t flags)
2836 gphi_iterator i;
2838 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2840 gphi *phi = i.phi ();
2841 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2843 INDENT (indent);
2844 dump_gimple_phi (buffer, phi, indent,
2845 (flags & TDF_GIMPLE) ? false : true, flags);
2846 pp_newline (buffer);
2852 /* Dump jump to basic block BB that is represented implicitly in the cfg
2853 to BUFFER. */
2855 static void
2856 pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
2858 if (flags & TDF_GIMPLE)
2860 pp_string (buffer, "goto __BB");
2861 pp_decimal_int (buffer, e->dest->index);
2862 if (e->probability.initialized_p ())
2864 pp_string (buffer, "(");
2865 pp_string (buffer,
2866 profile_quality_as_string (e->probability.quality ()));
2867 pp_string (buffer, "(");
2868 pp_decimal_int (buffer, e->probability.value ());
2869 pp_string (buffer, "))");
2871 pp_semicolon (buffer);
2873 else
2875 pp_string (buffer, "goto <bb ");
2876 pp_decimal_int (buffer, e->dest->index);
2877 pp_greater (buffer);
2878 pp_semicolon (buffer);
2880 dump_edge_probability (buffer, e);
2885 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2886 by INDENT spaces, with details given by FLAGS. */
2888 static void
2889 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2890 dump_flags_t flags)
2892 edge e;
2893 gimple *stmt;
2895 stmt = last_stmt (bb);
2897 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2899 edge true_edge, false_edge;
2901 /* When we are emitting the code or changing CFG, it is possible that
2902 the edges are not yet created. When we are using debug_bb in such
2903 a situation, we do not want it to crash. */
2904 if (EDGE_COUNT (bb->succs) != 2)
2905 return;
2906 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2908 INDENT (indent + 2);
2909 pp_cfg_jump (buffer, true_edge, flags);
2910 newline_and_indent (buffer, indent);
2911 pp_string (buffer, "else");
2912 newline_and_indent (buffer, indent + 2);
2913 pp_cfg_jump (buffer, false_edge, flags);
2914 pp_newline (buffer);
2915 return;
2918 /* If there is a fallthru edge, we may need to add an artificial
2919 goto to the dump. */
2920 e = find_fallthru_edge (bb->succs);
2922 if (e && (e->dest != bb->next_bb || (flags & TDF_GIMPLE)))
2924 INDENT (indent);
2926 if ((flags & TDF_LINENO)
2927 && e->goto_locus != UNKNOWN_LOCATION)
2928 dump_location (buffer, e->goto_locus);
2930 pp_cfg_jump (buffer, e, flags);
2931 pp_newline (buffer);
2936 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2937 indented by INDENT spaces. */
2939 static void
2940 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2941 dump_flags_t flags)
2943 gimple_stmt_iterator gsi;
2944 gimple *stmt;
2945 int label_indent = indent - 2;
2947 if (label_indent < 0)
2948 label_indent = 0;
2950 dump_phi_nodes (buffer, bb, indent, flags);
2952 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2954 int curr_indent;
2956 stmt = gsi_stmt (gsi);
2958 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2960 INDENT (curr_indent);
2961 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2962 pp_newline_and_flush (buffer);
2963 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2964 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2965 pp_buffer (buffer)->stream, stmt);
2968 dump_implicit_edges (buffer, bb, indent, flags);
2969 pp_flush (buffer);
2973 /* Dumps basic block BB to FILE with details described by FLAGS and
2974 indented by INDENT spaces. */
2976 void
2977 gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
2979 dump_gimple_bb_header (file, bb, indent, flags);
2980 if (bb->index >= NUM_FIXED_BLOCKS)
2982 pretty_printer buffer;
2983 pp_needs_newline (&buffer) = true;
2984 buffer.buffer->stream = file;
2985 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2987 dump_gimple_bb_footer (file, bb, indent, flags);
2990 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2991 no indentation, for use as a label of a DOT graph record-node.
2992 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2993 histogram dumping doesn't know about pretty-printers. */
2995 void
2996 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2998 pp_printf (pp, "<bb %d>:\n", bb->index);
2999 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3001 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
3002 gsi_next (&gsi))
3004 gphi *phi = gsi.phi ();
3005 if (!virtual_operand_p (gimple_phi_result (phi))
3006 || (dump_flags & TDF_VOPS))
3008 pp_bar (pp);
3009 pp_write_text_to_stream (pp);
3010 pp_string (pp, "# ");
3011 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
3012 pp_newline (pp);
3013 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3017 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
3018 gsi_next (&gsi))
3020 gimple *stmt = gsi_stmt (gsi);
3021 pp_bar (pp);
3022 pp_write_text_to_stream (pp);
3023 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
3024 pp_newline (pp);
3025 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3027 dump_implicit_edges (pp, bb, 0, dump_flags);
3028 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3032 /* Handle the %G format for TEXT. Same as %K in handle_K_format in
3033 tree-pretty-print.c but with a Gimple statement as an argument. */
3035 void
3036 percent_G_format (text_info *text)
3038 gimple *stmt = va_arg (*text->args_ptr, gimple*);
3040 /* Fall back on the rich location if the statement doesn't have one. */
3041 location_t loc = gimple_location (stmt);
3042 if (loc == UNKNOWN_LOCATION)
3043 loc = text->m_richloc->get_loc ();
3044 tree block = gimple_block (stmt);
3045 percent_K_format (text, loc, block);
3048 #if __GNUC__ >= 10
3049 # pragma GCC diagnostic pop
3050 #endif