Re: Refactor copying decl section names
[official-gcc.git] / gcc / gimple-pretty-print.c
bloba01bf90165745b00c5316176902cc9a63ce67b39
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2020 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, const 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, const 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, const 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
448 gcc_fallthrough ();
450 case COMPLEX_EXPR:
451 case VEC_WIDEN_MULT_HI_EXPR:
452 case VEC_WIDEN_MULT_LO_EXPR:
453 case VEC_WIDEN_MULT_EVEN_EXPR:
454 case VEC_WIDEN_MULT_ODD_EXPR:
455 case VEC_PACK_TRUNC_EXPR:
456 case VEC_PACK_SAT_EXPR:
457 case VEC_PACK_FIX_TRUNC_EXPR:
458 case VEC_PACK_FLOAT_EXPR:
459 case VEC_WIDEN_LSHIFT_HI_EXPR:
460 case VEC_WIDEN_LSHIFT_LO_EXPR:
461 case VEC_SERIES_EXPR:
462 for (p = get_tree_code_name (code); *p; p++)
463 pp_character (buffer, TOUPPER (*p));
464 pp_string (buffer, " <");
465 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
466 pp_string (buffer, ", ");
467 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
468 pp_greater (buffer);
469 break;
471 default:
472 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
474 pp_left_paren (buffer);
475 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
476 false);
477 pp_right_paren (buffer);
479 else
480 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
481 pp_space (buffer);
482 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
483 pp_space (buffer);
484 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
486 pp_left_paren (buffer);
487 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
488 false);
489 pp_right_paren (buffer);
491 else
492 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
496 /* Helper for dump_gimple_assign. Print the ternary RHS of the
497 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
499 static void
500 dump_ternary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
501 dump_flags_t flags)
503 const char *p;
504 enum tree_code code = gimple_assign_rhs_code (gs);
505 switch (code)
507 case WIDEN_MULT_PLUS_EXPR:
508 case WIDEN_MULT_MINUS_EXPR:
509 for (p = get_tree_code_name (code); *p; p++)
510 pp_character (buffer, TOUPPER (*p));
511 pp_string (buffer, " <");
512 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
513 pp_string (buffer, ", ");
514 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
515 pp_string (buffer, ", ");
516 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
517 pp_greater (buffer);
518 break;
520 case DOT_PROD_EXPR:
521 pp_string (buffer, "DOT_PROD_EXPR <");
522 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
523 pp_string (buffer, ", ");
524 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
525 pp_string (buffer, ", ");
526 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
527 pp_greater (buffer);
528 break;
530 case SAD_EXPR:
531 pp_string (buffer, "SAD_EXPR <");
532 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
533 pp_string (buffer, ", ");
534 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
535 pp_string (buffer, ", ");
536 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
537 pp_greater (buffer);
538 break;
540 case VEC_PERM_EXPR:
541 if (flags & TDF_GIMPLE)
542 pp_string (buffer, "__VEC_PERM (");
543 else
544 pp_string (buffer, "VEC_PERM_EXPR <");
545 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
546 pp_string (buffer, ", ");
547 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
548 pp_string (buffer, ", ");
549 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
550 if (flags & TDF_GIMPLE)
551 pp_right_paren (buffer);
552 else
553 pp_greater (buffer);
554 break;
556 case REALIGN_LOAD_EXPR:
557 pp_string (buffer, "REALIGN_LOAD <");
558 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
559 pp_string (buffer, ", ");
560 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
561 pp_string (buffer, ", ");
562 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
563 pp_greater (buffer);
564 break;
566 case COND_EXPR:
567 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
568 pp_string (buffer, " ? ");
569 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
570 pp_string (buffer, " : ");
571 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
572 break;
574 case VEC_COND_EXPR:
575 pp_string (buffer, "VEC_COND_EXPR <");
576 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
577 pp_string (buffer, ", ");
578 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
579 pp_string (buffer, ", ");
580 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
581 pp_greater (buffer);
582 break;
584 case BIT_INSERT_EXPR:
585 if (flags & TDF_GIMPLE)
587 pp_string (buffer, "__BIT_INSERT (");
588 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc,
589 flags | TDF_SLIM, false);
590 pp_string (buffer, ", ");
591 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc,
592 flags | TDF_SLIM, false);
593 pp_string (buffer, ", ");
594 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc,
595 flags | TDF_SLIM, false);
596 pp_right_paren (buffer);
598 else
600 pp_string (buffer, "BIT_INSERT_EXPR <");
601 dump_generic_node (buffer, gimple_assign_rhs1 (gs),
602 spc, flags, false);
603 pp_string (buffer, ", ");
604 dump_generic_node (buffer, gimple_assign_rhs2 (gs),
605 spc, flags, false);
606 pp_string (buffer, ", ");
607 dump_generic_node (buffer, gimple_assign_rhs3 (gs),
608 spc, flags, false);
609 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
611 pp_string (buffer, " (");
612 pp_decimal_int (buffer, TYPE_PRECISION
613 (TREE_TYPE (gimple_assign_rhs2 (gs))));
614 pp_string (buffer, " bits)");
616 pp_greater (buffer);
618 break;
620 default:
621 gcc_unreachable ();
626 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
627 pp_gimple_stmt_1. */
629 static void
630 dump_gimple_assign (pretty_printer *buffer, const gassign *gs, int spc,
631 dump_flags_t flags)
633 if (flags & TDF_RAW)
635 tree arg1 = NULL;
636 tree arg2 = NULL;
637 tree arg3 = NULL;
638 switch (gimple_num_ops (gs))
640 case 4:
641 arg3 = gimple_assign_rhs3 (gs);
642 /* FALLTHRU */
643 case 3:
644 arg2 = gimple_assign_rhs2 (gs);
645 /* FALLTHRU */
646 case 2:
647 arg1 = gimple_assign_rhs1 (gs);
648 break;
649 default:
650 gcc_unreachable ();
653 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
654 get_tree_code_name (gimple_assign_rhs_code (gs)),
655 gimple_assign_lhs (gs), arg1, arg2, arg3);
657 else
659 if (!(flags & TDF_RHS_ONLY))
661 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
662 pp_space (buffer);
663 pp_equal (buffer);
665 if (gimple_assign_nontemporal_move_p (gs))
666 pp_string (buffer, "{nt}");
668 if (gimple_has_volatile_ops (gs))
669 pp_string (buffer, "{v}");
671 pp_space (buffer);
674 if (gimple_num_ops (gs) == 2)
675 dump_unary_rhs (buffer, gs, spc, flags);
676 else if (gimple_num_ops (gs) == 3)
677 dump_binary_rhs (buffer, gs, spc, flags);
678 else if (gimple_num_ops (gs) == 4)
679 dump_ternary_rhs (buffer, gs, spc, flags);
680 else
681 gcc_unreachable ();
682 if (!(flags & TDF_RHS_ONLY))
683 pp_semicolon (buffer);
688 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
689 pp_gimple_stmt_1. */
691 static void
692 dump_gimple_return (pretty_printer *buffer, const greturn *gs, int spc,
693 dump_flags_t flags)
695 tree t;
697 t = gimple_return_retval (gs);
698 if (flags & TDF_RAW)
699 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
700 else
702 pp_string (buffer, "return");
703 if (t)
705 pp_space (buffer);
706 dump_generic_node (buffer, t, spc, flags, false);
708 pp_semicolon (buffer);
713 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
714 dump_gimple_call. */
716 static void
717 dump_gimple_call_args (pretty_printer *buffer, const gcall *gs,
718 dump_flags_t flags)
720 size_t i = 0;
722 /* Pretty print first arg to certain internal fns. */
723 if (gimple_call_internal_p (gs))
725 const char *const *enums = NULL;
726 unsigned limit = 0;
728 switch (gimple_call_internal_fn (gs))
730 case IFN_UNIQUE:
731 #define DEF(X) #X
732 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
733 #undef DEF
734 enums = unique_args;
736 limit = ARRAY_SIZE (unique_args);
737 break;
739 case IFN_GOACC_LOOP:
740 #define DEF(X) #X
741 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
742 #undef DEF
743 enums = loop_args;
744 limit = ARRAY_SIZE (loop_args);
745 break;
747 case IFN_GOACC_REDUCTION:
748 #define DEF(X) #X
749 static const char *const reduction_args[]
750 = {IFN_GOACC_REDUCTION_CODES};
751 #undef DEF
752 enums = reduction_args;
753 limit = ARRAY_SIZE (reduction_args);
754 break;
756 case IFN_ASAN_MARK:
757 #define DEF(X) #X
758 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
759 #undef DEF
760 enums = asan_mark_args;
761 limit = ARRAY_SIZE (asan_mark_args);
762 break;
764 default:
765 break;
767 if (limit)
769 tree arg0 = gimple_call_arg (gs, 0);
770 HOST_WIDE_INT v;
772 if (TREE_CODE (arg0) == INTEGER_CST
773 && tree_fits_shwi_p (arg0)
774 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
776 i++;
777 pp_string (buffer, enums[v]);
782 for (; i < gimple_call_num_args (gs); i++)
784 if (i)
785 pp_string (buffer, ", ");
786 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
789 if (gimple_call_va_arg_pack_p (gs))
791 if (i)
792 pp_string (buffer, ", ");
794 pp_string (buffer, "__builtin_va_arg_pack ()");
798 /* Dump the points-to solution *PT to BUFFER. */
800 static void
801 pp_points_to_solution (pretty_printer *buffer, const pt_solution *pt)
803 if (pt->anything)
805 pp_string (buffer, "anything ");
806 return;
808 if (pt->nonlocal)
809 pp_string (buffer, "nonlocal ");
810 if (pt->escaped)
811 pp_string (buffer, "escaped ");
812 if (pt->ipa_escaped)
813 pp_string (buffer, "unit-escaped ");
814 if (pt->null)
815 pp_string (buffer, "null ");
816 if (pt->vars
817 && !bitmap_empty_p (pt->vars))
819 bitmap_iterator bi;
820 unsigned i;
821 pp_string (buffer, "{ ");
822 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
824 pp_string (buffer, "D.");
825 pp_decimal_int (buffer, i);
826 pp_space (buffer);
828 pp_right_brace (buffer);
829 if (pt->vars_contains_nonlocal
830 || pt->vars_contains_escaped
831 || pt->vars_contains_escaped_heap
832 || pt->vars_contains_restrict)
834 const char *comma = "";
835 pp_string (buffer, " (");
836 if (pt->vars_contains_nonlocal)
838 pp_string (buffer, "nonlocal");
839 comma = ", ";
841 if (pt->vars_contains_escaped)
843 pp_string (buffer, comma);
844 pp_string (buffer, "escaped");
845 comma = ", ";
847 if (pt->vars_contains_escaped_heap)
849 pp_string (buffer, comma);
850 pp_string (buffer, "escaped heap");
851 comma = ", ";
853 if (pt->vars_contains_restrict)
855 pp_string (buffer, comma);
856 pp_string (buffer, "restrict");
857 comma = ", ";
859 if (pt->vars_contains_interposable)
861 pp_string (buffer, comma);
862 pp_string (buffer, "interposable");
864 pp_string (buffer, ")");
870 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
871 pp_gimple_stmt_1. */
873 static void
874 dump_gimple_call (pretty_printer *buffer, const gcall *gs, int spc,
875 dump_flags_t flags)
877 tree lhs = gimple_call_lhs (gs);
878 tree fn = gimple_call_fn (gs);
880 if (flags & TDF_ALIAS)
882 const pt_solution *pt;
883 pt = gimple_call_use_set (gs);
884 if (!pt_solution_empty_p (pt))
886 pp_string (buffer, "# USE = ");
887 pp_points_to_solution (buffer, pt);
888 newline_and_indent (buffer, spc);
890 pt = gimple_call_clobber_set (gs);
891 if (!pt_solution_empty_p (pt))
893 pp_string (buffer, "# CLB = ");
894 pp_points_to_solution (buffer, pt);
895 newline_and_indent (buffer, spc);
899 if (flags & TDF_RAW)
901 if (gimple_call_internal_p (gs))
902 dump_gimple_fmt (buffer, spc, flags, "%G <.%s, %T", gs,
903 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
904 else
905 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
906 if (gimple_call_num_args (gs) > 0)
908 pp_string (buffer, ", ");
909 dump_gimple_call_args (buffer, gs, flags);
911 pp_greater (buffer);
913 else
915 if (lhs && !(flags & TDF_RHS_ONLY))
917 dump_generic_node (buffer, lhs, spc, flags, false);
918 pp_string (buffer, " =");
920 if (gimple_has_volatile_ops (gs))
921 pp_string (buffer, "{v}");
923 pp_space (buffer);
925 if (gimple_call_internal_p (gs))
927 pp_dot (buffer);
928 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
930 else
931 print_call_name (buffer, fn, flags);
932 pp_string (buffer, " (");
933 dump_gimple_call_args (buffer, gs, flags);
934 pp_right_paren (buffer);
935 if (!(flags & TDF_RHS_ONLY))
936 pp_semicolon (buffer);
939 if (gimple_call_chain (gs))
941 pp_string (buffer, " [static-chain: ");
942 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
943 pp_right_bracket (buffer);
946 if (gimple_call_return_slot_opt_p (gs))
947 pp_string (buffer, " [return slot optimization]");
948 if (gimple_call_tail_p (gs))
949 pp_string (buffer, " [tail call]");
950 if (gimple_call_must_tail_p (gs))
951 pp_string (buffer, " [must tail call]");
953 if (fn == NULL)
954 return;
956 /* Dump the arguments of _ITM_beginTransaction sanely. */
957 if (TREE_CODE (fn) == ADDR_EXPR)
958 fn = TREE_OPERAND (fn, 0);
959 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
960 pp_string (buffer, " [tm-clone]");
961 if (TREE_CODE (fn) == FUNCTION_DECL
962 && fndecl_built_in_p (fn, BUILT_IN_TM_START)
963 && gimple_call_num_args (gs) > 0)
965 tree t = gimple_call_arg (gs, 0);
966 unsigned HOST_WIDE_INT props;
967 gcc_assert (TREE_CODE (t) == INTEGER_CST);
969 pp_string (buffer, " [ ");
971 /* Get the transaction code properties. */
972 props = TREE_INT_CST_LOW (t);
974 if (props & PR_INSTRUMENTEDCODE)
975 pp_string (buffer, "instrumentedCode ");
976 if (props & PR_UNINSTRUMENTEDCODE)
977 pp_string (buffer, "uninstrumentedCode ");
978 if (props & PR_HASNOXMMUPDATE)
979 pp_string (buffer, "hasNoXMMUpdate ");
980 if (props & PR_HASNOABORT)
981 pp_string (buffer, "hasNoAbort ");
982 if (props & PR_HASNOIRREVOCABLE)
983 pp_string (buffer, "hasNoIrrevocable ");
984 if (props & PR_DOESGOIRREVOCABLE)
985 pp_string (buffer, "doesGoIrrevocable ");
986 if (props & PR_HASNOSIMPLEREADS)
987 pp_string (buffer, "hasNoSimpleReads ");
988 if (props & PR_AWBARRIERSOMITTED)
989 pp_string (buffer, "awBarriersOmitted ");
990 if (props & PR_RARBARRIERSOMITTED)
991 pp_string (buffer, "RaRBarriersOmitted ");
992 if (props & PR_UNDOLOGCODE)
993 pp_string (buffer, "undoLogCode ");
994 if (props & PR_PREFERUNINSTRUMENTED)
995 pp_string (buffer, "preferUninstrumented ");
996 if (props & PR_EXCEPTIONBLOCK)
997 pp_string (buffer, "exceptionBlock ");
998 if (props & PR_HASELSE)
999 pp_string (buffer, "hasElse ");
1000 if (props & PR_READONLY)
1001 pp_string (buffer, "readOnly ");
1003 pp_right_bracket (buffer);
1008 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
1009 pp_gimple_stmt_1. */
1011 static void
1012 dump_gimple_switch (pretty_printer *buffer, const gswitch *gs, int spc,
1013 dump_flags_t flags)
1015 unsigned int i;
1017 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
1018 if (flags & TDF_RAW)
1019 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
1020 gimple_switch_index (gs));
1021 else
1023 pp_string (buffer, "switch (");
1024 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
1025 if (flags & TDF_GIMPLE)
1026 pp_string (buffer, ") {");
1027 else
1028 pp_string (buffer, ") <");
1031 for (i = 0; i < gimple_switch_num_labels (gs); i++)
1033 tree case_label = gimple_switch_label (gs, i);
1034 gcc_checking_assert (case_label != NULL_TREE);
1035 dump_generic_node (buffer, case_label, spc, flags, false);
1036 pp_space (buffer);
1037 tree label = CASE_LABEL (case_label);
1038 dump_generic_node (buffer, label, spc, flags, false);
1040 if (cfun && cfun->cfg)
1042 basic_block dest = label_to_block (cfun, label);
1043 if (dest)
1045 edge label_edge = find_edge (gimple_bb (gs), dest);
1046 if (label_edge && !(flags & TDF_GIMPLE))
1047 dump_edge_probability (buffer, label_edge);
1051 if (i < gimple_switch_num_labels (gs) - 1)
1053 if (flags & TDF_GIMPLE)
1054 pp_string (buffer, "; ");
1055 else
1056 pp_string (buffer, ", ");
1059 if (flags & TDF_GIMPLE)
1060 pp_string (buffer, "; }");
1061 else
1062 pp_greater (buffer);
1066 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1067 pp_gimple_stmt_1. */
1069 static void
1070 dump_gimple_cond (pretty_printer *buffer, const gcond *gs, int spc,
1071 dump_flags_t flags)
1073 if (flags & TDF_RAW)
1074 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1075 get_tree_code_name (gimple_cond_code (gs)),
1076 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1077 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1078 else
1080 if (!(flags & TDF_RHS_ONLY))
1081 pp_string (buffer, "if (");
1082 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
1083 pp_space (buffer);
1084 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1085 pp_space (buffer);
1086 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
1087 if (!(flags & TDF_RHS_ONLY))
1089 edge_iterator ei;
1090 edge e, true_edge = NULL, false_edge = NULL;
1091 basic_block bb = gimple_bb (gs);
1093 if (bb)
1095 FOR_EACH_EDGE (e, ei, bb->succs)
1097 if (e->flags & EDGE_TRUE_VALUE)
1098 true_edge = e;
1099 else if (e->flags & EDGE_FALSE_VALUE)
1100 false_edge = e;
1104 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1106 pp_right_paren (buffer);
1108 if (gimple_cond_true_label (gs))
1110 pp_string (buffer, " goto ");
1111 dump_generic_node (buffer, gimple_cond_true_label (gs),
1112 spc, flags, false);
1113 if (has_edge_info && !(flags & TDF_GIMPLE))
1114 dump_edge_probability (buffer, true_edge);
1115 pp_semicolon (buffer);
1117 if (gimple_cond_false_label (gs))
1119 pp_string (buffer, " else goto ");
1120 dump_generic_node (buffer, gimple_cond_false_label (gs),
1121 spc, flags, false);
1122 if (has_edge_info && !(flags & TDF_GIMPLE))
1123 dump_edge_probability (buffer, false_edge);
1125 pp_semicolon (buffer);
1132 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1133 spaces of indent. FLAGS specifies details to show in the dump (see
1134 TDF_* in dumpfils.h). */
1136 static void
1137 dump_gimple_label (pretty_printer *buffer, const glabel *gs, int spc,
1138 dump_flags_t flags)
1140 tree label = gimple_label_label (gs);
1141 if (flags & TDF_RAW)
1142 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1143 else
1145 dump_generic_node (buffer, label, spc, flags, false);
1146 pp_colon (buffer);
1148 if (flags & TDF_GIMPLE)
1149 return;
1150 if (DECL_NONLOCAL (label))
1151 pp_string (buffer, " [non-local]");
1152 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1153 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1156 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1157 spaces of indent. FLAGS specifies details to show in the dump (see
1158 TDF_* in dumpfile.h). */
1160 static void
1161 dump_gimple_goto (pretty_printer *buffer, const ggoto *gs, int spc,
1162 dump_flags_t flags)
1164 tree label = gimple_goto_dest (gs);
1165 if (flags & TDF_RAW)
1166 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1167 else
1168 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1172 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1173 spaces of indent. FLAGS specifies details to show in the dump (see
1174 TDF_* in dumpfile.h). */
1176 static void
1177 dump_gimple_bind (pretty_printer *buffer, const gbind *gs, int spc,
1178 dump_flags_t flags)
1180 if (flags & TDF_RAW)
1181 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1182 else
1183 pp_left_brace (buffer);
1184 if (!(flags & TDF_SLIM))
1186 tree var;
1188 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1190 newline_and_indent (buffer, 2);
1191 print_declaration (buffer, var, spc, flags);
1193 if (gimple_bind_vars (gs))
1194 pp_newline (buffer);
1196 pp_newline (buffer);
1197 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1198 newline_and_indent (buffer, spc);
1199 if (flags & TDF_RAW)
1200 pp_greater (buffer);
1201 else
1202 pp_right_brace (buffer);
1206 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1207 indent. FLAGS specifies details to show in the dump (see TDF_* in
1208 dumpfile.h). */
1210 static void
1211 dump_gimple_try (pretty_printer *buffer, const gtry *gs, int spc,
1212 dump_flags_t flags)
1214 if (flags & TDF_RAW)
1216 const char *type;
1217 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1218 type = "GIMPLE_TRY_CATCH";
1219 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1220 type = "GIMPLE_TRY_FINALLY";
1221 else
1222 type = "UNKNOWN GIMPLE_TRY";
1223 dump_gimple_fmt (buffer, spc, flags,
1224 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1225 gimple_try_eval (gs), gimple_try_cleanup (gs));
1227 else
1229 pp_string (buffer, "try");
1230 newline_and_indent (buffer, spc + 2);
1231 pp_left_brace (buffer);
1232 pp_newline (buffer);
1234 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1235 newline_and_indent (buffer, spc + 2);
1236 pp_right_brace (buffer);
1238 gimple_seq seq = gimple_try_cleanup (gs);
1240 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1242 newline_and_indent (buffer, spc);
1243 pp_string (buffer, "catch");
1244 newline_and_indent (buffer, spc + 2);
1245 pp_left_brace (buffer);
1247 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1249 newline_and_indent (buffer, spc);
1250 pp_string (buffer, "finally");
1251 newline_and_indent (buffer, spc + 2);
1252 pp_left_brace (buffer);
1254 if (seq && is_a <geh_else *> (gimple_seq_first_stmt (seq))
1255 && gimple_seq_nondebug_singleton_p (seq))
1257 geh_else *stmt = as_a <geh_else *> (gimple_seq_first_stmt (seq));
1258 seq = gimple_eh_else_n_body (stmt);
1259 pp_newline (buffer);
1260 dump_gimple_seq (buffer, seq, spc + 4, flags);
1261 newline_and_indent (buffer, spc + 2);
1262 pp_right_brace (buffer);
1263 seq = gimple_eh_else_e_body (stmt);
1264 newline_and_indent (buffer, spc);
1265 pp_string (buffer, "else");
1266 newline_and_indent (buffer, spc + 2);
1267 pp_left_brace (buffer);
1270 else
1271 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1273 pp_newline (buffer);
1274 dump_gimple_seq (buffer, seq, spc + 4, flags);
1275 newline_and_indent (buffer, spc + 2);
1276 pp_right_brace (buffer);
1281 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1282 indent. FLAGS specifies details to show in the dump (see TDF_* in
1283 dumpfile.h). */
1285 static void
1286 dump_gimple_catch (pretty_printer *buffer, const gcatch *gs, int spc,
1287 dump_flags_t flags)
1289 if (flags & TDF_RAW)
1290 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1291 gimple_catch_types (gs), gimple_catch_handler (gs));
1292 else
1293 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1294 gimple_catch_types (gs), gimple_catch_handler (gs));
1298 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1299 indent. FLAGS specifies details to show in the dump (see TDF_* in
1300 dumpfile.h). */
1302 static void
1303 dump_gimple_eh_filter (pretty_printer *buffer, const geh_filter *gs, int spc,
1304 dump_flags_t flags)
1306 if (flags & TDF_RAW)
1307 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1308 gimple_eh_filter_types (gs),
1309 gimple_eh_filter_failure (gs));
1310 else
1311 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1312 gimple_eh_filter_types (gs),
1313 gimple_eh_filter_failure (gs));
1317 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1319 static void
1320 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1321 const geh_mnt *gs, int spc, dump_flags_t flags)
1323 if (flags & TDF_RAW)
1324 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1325 gimple_eh_must_not_throw_fndecl (gs));
1326 else
1327 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1328 gimple_eh_must_not_throw_fndecl (gs));
1332 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1333 indent. FLAGS specifies details to show in the dump (see TDF_* in
1334 dumpfile.h). */
1336 static void
1337 dump_gimple_eh_else (pretty_printer *buffer, const geh_else *gs, int spc,
1338 dump_flags_t flags)
1340 if (flags & TDF_RAW)
1341 dump_gimple_fmt (buffer, spc, flags,
1342 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1343 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1344 else
1345 dump_gimple_fmt (buffer, spc, flags,
1346 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1347 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1351 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1352 indent. FLAGS specifies details to show in the dump (see TDF_* in
1353 dumpfile.h). */
1355 static void
1356 dump_gimple_resx (pretty_printer *buffer, const gresx *gs, int spc,
1357 dump_flags_t flags)
1359 if (flags & TDF_RAW)
1360 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1361 gimple_resx_region (gs));
1362 else
1363 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1366 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1368 static void
1369 dump_gimple_eh_dispatch (pretty_printer *buffer, const geh_dispatch *gs,
1370 int spc, dump_flags_t flags)
1372 if (flags & TDF_RAW)
1373 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1374 gimple_eh_dispatch_region (gs));
1375 else
1376 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1377 gimple_eh_dispatch_region (gs));
1380 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1381 of indent. FLAGS specifies details to show in the dump (see TDF_*
1382 in dumpfile.h). */
1384 static void
1385 dump_gimple_debug (pretty_printer *buffer, const gdebug *gs, int spc,
1386 dump_flags_t flags)
1388 switch (gs->subcode)
1390 case GIMPLE_DEBUG_BIND:
1391 if (flags & TDF_RAW)
1392 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1393 gimple_debug_bind_get_var (gs),
1394 gimple_debug_bind_get_value (gs));
1395 else
1396 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1397 gimple_debug_bind_get_var (gs),
1398 gimple_debug_bind_get_value (gs));
1399 break;
1401 case GIMPLE_DEBUG_SOURCE_BIND:
1402 if (flags & TDF_RAW)
1403 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1404 gimple_debug_source_bind_get_var (gs),
1405 gimple_debug_source_bind_get_value (gs));
1406 else
1407 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1408 gimple_debug_source_bind_get_var (gs),
1409 gimple_debug_source_bind_get_value (gs));
1410 break;
1412 case GIMPLE_DEBUG_BEGIN_STMT:
1413 if (flags & TDF_RAW)
1414 dump_gimple_fmt (buffer, spc, flags, "%G BEGIN_STMT", gs);
1415 else
1416 dump_gimple_fmt (buffer, spc, flags, "# DEBUG BEGIN_STMT");
1417 break;
1419 case GIMPLE_DEBUG_INLINE_ENTRY:
1420 if (flags & TDF_RAW)
1421 dump_gimple_fmt (buffer, spc, flags, "%G INLINE_ENTRY %T", gs,
1422 gimple_block (gs)
1423 ? block_ultimate_origin (gimple_block (gs))
1424 : NULL_TREE);
1425 else
1426 dump_gimple_fmt (buffer, spc, flags, "# DEBUG INLINE_ENTRY %T",
1427 gimple_block (gs)
1428 ? block_ultimate_origin (gimple_block (gs))
1429 : NULL_TREE);
1430 break;
1432 default:
1433 gcc_unreachable ();
1437 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1438 static void
1439 dump_gimple_omp_for (pretty_printer *buffer, const gomp_for *gs, int spc,
1440 dump_flags_t flags)
1442 size_t i;
1444 if (flags & TDF_RAW)
1446 const char *kind;
1447 switch (gimple_omp_for_kind (gs))
1449 case GF_OMP_FOR_KIND_FOR:
1450 kind = "";
1451 break;
1452 case GF_OMP_FOR_KIND_DISTRIBUTE:
1453 kind = " distribute";
1454 break;
1455 case GF_OMP_FOR_KIND_TASKLOOP:
1456 kind = " taskloop";
1457 break;
1458 case GF_OMP_FOR_KIND_OACC_LOOP:
1459 kind = " oacc_loop";
1460 break;
1461 case GF_OMP_FOR_KIND_SIMD:
1462 kind = " simd";
1463 break;
1464 default:
1465 gcc_unreachable ();
1467 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1468 kind, gimple_omp_body (gs));
1469 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1470 dump_gimple_fmt (buffer, spc, flags, " >,");
1471 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1472 dump_gimple_fmt (buffer, spc, flags,
1473 "%+%T, %T, %T, %s, %T,%n",
1474 gimple_omp_for_index (gs, i),
1475 gimple_omp_for_initial (gs, i),
1476 gimple_omp_for_final (gs, i),
1477 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1478 gimple_omp_for_incr (gs, i));
1479 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1480 gimple_omp_for_pre_body (gs));
1482 else
1484 switch (gimple_omp_for_kind (gs))
1486 case GF_OMP_FOR_KIND_FOR:
1487 pp_string (buffer, "#pragma omp for");
1488 break;
1489 case GF_OMP_FOR_KIND_DISTRIBUTE:
1490 pp_string (buffer, "#pragma omp distribute");
1491 break;
1492 case GF_OMP_FOR_KIND_TASKLOOP:
1493 pp_string (buffer, "#pragma omp taskloop");
1494 break;
1495 case GF_OMP_FOR_KIND_OACC_LOOP:
1496 pp_string (buffer, "#pragma acc loop");
1497 break;
1498 case GF_OMP_FOR_KIND_SIMD:
1499 pp_string (buffer, "#pragma omp simd");
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 tree init = gimple_omp_for_initial (gs, i);
1515 if (TREE_CODE (init) != TREE_VEC)
1516 dump_generic_node (buffer, init, spc, flags, false);
1517 else
1518 dump_omp_loop_non_rect_expr (buffer, init, spc, flags);
1519 pp_string (buffer, "; ");
1521 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1522 flags, false);
1523 pp_space (buffer);
1524 switch (gimple_omp_for_cond (gs, i))
1526 case LT_EXPR:
1527 pp_less (buffer);
1528 break;
1529 case GT_EXPR:
1530 pp_greater (buffer);
1531 break;
1532 case LE_EXPR:
1533 pp_less_equal (buffer);
1534 break;
1535 case GE_EXPR:
1536 pp_greater_equal (buffer);
1537 break;
1538 case NE_EXPR:
1539 pp_string (buffer, "!=");
1540 break;
1541 default:
1542 gcc_unreachable ();
1544 pp_space (buffer);
1545 tree cond = gimple_omp_for_final (gs, i);
1546 if (TREE_CODE (cond) != TREE_VEC)
1547 dump_generic_node (buffer, cond, spc, flags, false);
1548 else
1549 dump_omp_loop_non_rect_expr (buffer, cond, spc, flags);
1550 pp_string (buffer, "; ");
1552 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1553 flags, false);
1554 pp_string (buffer, " = ");
1555 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1556 flags, false);
1557 pp_right_paren (buffer);
1560 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1562 newline_and_indent (buffer, spc + 2);
1563 pp_left_brace (buffer);
1564 pp_newline (buffer);
1565 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1566 newline_and_indent (buffer, spc + 2);
1567 pp_right_brace (buffer);
1572 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1574 static void
1575 dump_gimple_omp_continue (pretty_printer *buffer, const gomp_continue *gs,
1576 int spc, dump_flags_t flags)
1578 if (flags & TDF_RAW)
1580 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1581 gimple_omp_continue_control_def (gs),
1582 gimple_omp_continue_control_use (gs));
1584 else
1586 pp_string (buffer, "#pragma omp continue (");
1587 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1588 spc, flags, false);
1589 pp_comma (buffer);
1590 pp_space (buffer);
1591 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1592 spc, flags, false);
1593 pp_right_paren (buffer);
1597 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1599 static void
1600 dump_gimple_omp_single (pretty_printer *buffer, const gomp_single *gs,
1601 int spc, dump_flags_t flags)
1603 if (flags & TDF_RAW)
1605 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1606 gimple_omp_body (gs));
1607 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1608 dump_gimple_fmt (buffer, spc, flags, " >");
1610 else
1612 pp_string (buffer, "#pragma omp single");
1613 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1614 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1616 newline_and_indent (buffer, spc + 2);
1617 pp_left_brace (buffer);
1618 pp_newline (buffer);
1619 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1620 newline_and_indent (buffer, spc + 2);
1621 pp_right_brace (buffer);
1626 /* Dump a GIMPLE_OMP_TASKGROUP tuple on the pretty_printer BUFFER. */
1628 static void
1629 dump_gimple_omp_taskgroup (pretty_printer *buffer, const gimple *gs,
1630 int spc, dump_flags_t flags)
1632 if (flags & TDF_RAW)
1634 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1635 gimple_omp_body (gs));
1636 dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
1637 dump_gimple_fmt (buffer, spc, flags, " >");
1639 else
1641 pp_string (buffer, "#pragma omp taskgroup");
1642 dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
1643 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1645 newline_and_indent (buffer, spc + 2);
1646 pp_left_brace (buffer);
1647 pp_newline (buffer);
1648 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1649 newline_and_indent (buffer, spc + 2);
1650 pp_right_brace (buffer);
1655 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1657 static void
1658 dump_gimple_omp_target (pretty_printer *buffer, const gomp_target *gs,
1659 int spc, dump_flags_t flags)
1661 const char *kind;
1662 switch (gimple_omp_target_kind (gs))
1664 case GF_OMP_TARGET_KIND_REGION:
1665 kind = "";
1666 break;
1667 case GF_OMP_TARGET_KIND_DATA:
1668 kind = " data";
1669 break;
1670 case GF_OMP_TARGET_KIND_UPDATE:
1671 kind = " update";
1672 break;
1673 case GF_OMP_TARGET_KIND_ENTER_DATA:
1674 kind = " enter data";
1675 break;
1676 case GF_OMP_TARGET_KIND_EXIT_DATA:
1677 kind = " exit data";
1678 break;
1679 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1680 kind = " oacc_kernels";
1681 break;
1682 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1683 kind = " oacc_parallel";
1684 break;
1685 case GF_OMP_TARGET_KIND_OACC_SERIAL:
1686 kind = " oacc_serial";
1687 break;
1688 case GF_OMP_TARGET_KIND_OACC_DATA:
1689 kind = " oacc_data";
1690 break;
1691 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1692 kind = " oacc_update";
1693 break;
1694 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1695 kind = " oacc_enter_exit_data";
1696 break;
1697 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1698 kind = " oacc_declare";
1699 break;
1700 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1701 kind = " oacc_host_data";
1702 break;
1703 default:
1704 gcc_unreachable ();
1706 if (flags & TDF_RAW)
1708 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1709 kind, gimple_omp_body (gs));
1710 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1711 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1712 gimple_omp_target_child_fn (gs),
1713 gimple_omp_target_data_arg (gs));
1715 else
1717 pp_string (buffer, "#pragma omp target");
1718 pp_string (buffer, kind);
1719 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1720 if (gimple_omp_target_child_fn (gs))
1722 pp_string (buffer, " [child fn: ");
1723 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1724 spc, flags, false);
1725 pp_string (buffer, " (");
1726 if (gimple_omp_target_data_arg (gs))
1727 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1728 spc, flags, false);
1729 else
1730 pp_string (buffer, "???");
1731 pp_string (buffer, ")]");
1733 gimple_seq body = gimple_omp_body (gs);
1734 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1736 newline_and_indent (buffer, spc + 2);
1737 pp_left_brace (buffer);
1738 pp_newline (buffer);
1739 dump_gimple_seq (buffer, body, spc + 4, flags);
1740 newline_and_indent (buffer, spc + 2);
1741 pp_right_brace (buffer);
1743 else if (body)
1745 pp_newline (buffer);
1746 dump_gimple_seq (buffer, body, spc + 2, flags);
1751 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1753 static void
1754 dump_gimple_omp_teams (pretty_printer *buffer, const gomp_teams *gs, int spc,
1755 dump_flags_t flags)
1757 if (flags & TDF_RAW)
1759 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1760 gimple_omp_body (gs));
1761 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1762 dump_gimple_fmt (buffer, spc, flags, " >");
1764 else
1766 pp_string (buffer, "#pragma omp teams");
1767 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1768 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1770 newline_and_indent (buffer, spc + 2);
1771 pp_character (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_character (buffer, '}');
1780 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1782 static void
1783 dump_gimple_omp_sections (pretty_printer *buffer, const gomp_sections *gs,
1784 int spc, dump_flags_t flags)
1786 if (flags & TDF_RAW)
1788 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1789 gimple_omp_body (gs));
1790 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1791 dump_gimple_fmt (buffer, spc, flags, " >");
1793 else
1795 pp_string (buffer, "#pragma omp sections");
1796 if (gimple_omp_sections_control (gs))
1798 pp_string (buffer, " <");
1799 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1800 flags, false);
1801 pp_greater (buffer);
1803 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1804 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1806 newline_and_indent (buffer, spc + 2);
1807 pp_left_brace (buffer);
1808 pp_newline (buffer);
1809 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1810 newline_and_indent (buffer, spc + 2);
1811 pp_right_brace (buffer);
1816 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the
1817 pretty_printer BUFFER. */
1819 static void
1820 dump_gimple_omp_block (pretty_printer *buffer, const gimple *gs, int spc,
1821 dump_flags_t flags)
1823 if (flags & TDF_RAW)
1824 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1825 gimple_omp_body (gs));
1826 else
1828 switch (gimple_code (gs))
1830 case GIMPLE_OMP_MASTER:
1831 pp_string (buffer, "#pragma omp master");
1832 break;
1833 case GIMPLE_OMP_SECTION:
1834 pp_string (buffer, "#pragma omp section");
1835 break;
1836 default:
1837 gcc_unreachable ();
1839 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1841 newline_and_indent (buffer, spc + 2);
1842 pp_left_brace (buffer);
1843 pp_newline (buffer);
1844 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1845 newline_and_indent (buffer, spc + 2);
1846 pp_right_brace (buffer);
1851 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1853 static void
1854 dump_gimple_omp_critical (pretty_printer *buffer, const gomp_critical *gs,
1855 int spc, dump_flags_t flags)
1857 if (flags & TDF_RAW)
1858 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1859 gimple_omp_body (gs));
1860 else
1862 pp_string (buffer, "#pragma omp critical");
1863 if (gimple_omp_critical_name (gs))
1865 pp_string (buffer, " (");
1866 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1867 flags, false);
1868 pp_right_paren (buffer);
1870 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1871 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1873 newline_and_indent (buffer, spc + 2);
1874 pp_left_brace (buffer);
1875 pp_newline (buffer);
1876 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1877 newline_and_indent (buffer, spc + 2);
1878 pp_right_brace (buffer);
1883 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1885 static void
1886 dump_gimple_omp_ordered (pretty_printer *buffer, const gomp_ordered *gs,
1887 int spc, dump_flags_t flags)
1889 if (flags & TDF_RAW)
1890 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1891 gimple_omp_body (gs));
1892 else
1894 pp_string (buffer, "#pragma omp ordered");
1895 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1896 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1898 newline_and_indent (buffer, spc + 2);
1899 pp_left_brace (buffer);
1900 pp_newline (buffer);
1901 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1902 newline_and_indent (buffer, spc + 2);
1903 pp_right_brace (buffer);
1908 /* Dump a GIMPLE_OMP_SCAN tuple on the pretty_printer BUFFER. */
1910 static void
1911 dump_gimple_omp_scan (pretty_printer *buffer, const gomp_scan *gs,
1912 int spc, dump_flags_t flags)
1914 if (flags & TDF_RAW)
1915 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1916 gimple_omp_body (gs));
1917 else
1919 if (gimple_omp_scan_clauses (gs))
1921 pp_string (buffer, "#pragma omp scan");
1922 dump_omp_clauses (buffer, gimple_omp_scan_clauses (gs), spc, flags);
1924 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1926 newline_and_indent (buffer, spc + 2);
1927 pp_left_brace (buffer);
1928 pp_newline (buffer);
1929 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1930 newline_and_indent (buffer, spc + 2);
1931 pp_right_brace (buffer);
1936 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1938 static void
1939 dump_gimple_omp_return (pretty_printer *buffer, const gimple *gs, int spc,
1940 dump_flags_t flags)
1942 if (flags & TDF_RAW)
1944 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1945 (int) gimple_omp_return_nowait_p (gs));
1946 if (gimple_omp_return_lhs (gs))
1947 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1948 gimple_omp_return_lhs (gs));
1949 else
1950 dump_gimple_fmt (buffer, spc, flags, ">");
1952 else
1954 pp_string (buffer, "#pragma omp return");
1955 if (gimple_omp_return_nowait_p (gs))
1956 pp_string (buffer, "(nowait)");
1957 if (gimple_omp_return_lhs (gs))
1959 pp_string (buffer, " (set ");
1960 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1961 spc, flags, false);
1962 pp_character (buffer, ')');
1967 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1969 static void
1970 dump_gimple_transaction (pretty_printer *buffer, const gtransaction *gs,
1971 int spc, dump_flags_t flags)
1973 unsigned subcode = gimple_transaction_subcode (gs);
1975 if (flags & TDF_RAW)
1977 dump_gimple_fmt (buffer, spc, flags,
1978 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1979 "<%+BODY <%S> >",
1980 gs, subcode, gimple_transaction_label_norm (gs),
1981 gimple_transaction_label_uninst (gs),
1982 gimple_transaction_label_over (gs),
1983 gimple_transaction_body (gs));
1985 else
1987 if (subcode & GTMA_IS_OUTER)
1988 pp_string (buffer, "__transaction_atomic [[outer]]");
1989 else if (subcode & GTMA_IS_RELAXED)
1990 pp_string (buffer, "__transaction_relaxed");
1991 else
1992 pp_string (buffer, "__transaction_atomic");
1993 subcode &= ~GTMA_DECLARATION_MASK;
1995 if (gimple_transaction_body (gs))
1997 newline_and_indent (buffer, spc + 2);
1998 pp_left_brace (buffer);
1999 pp_newline (buffer);
2000 dump_gimple_seq (buffer, gimple_transaction_body (gs),
2001 spc + 4, flags);
2002 newline_and_indent (buffer, spc + 2);
2003 pp_right_brace (buffer);
2005 else
2007 pp_string (buffer, " //");
2008 if (gimple_transaction_label_norm (gs))
2010 pp_string (buffer, " NORM=");
2011 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
2012 spc, flags, false);
2014 if (gimple_transaction_label_uninst (gs))
2016 pp_string (buffer, " UNINST=");
2017 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
2018 spc, flags, false);
2020 if (gimple_transaction_label_over (gs))
2022 pp_string (buffer, " OVER=");
2023 dump_generic_node (buffer, gimple_transaction_label_over (gs),
2024 spc, flags, false);
2026 if (subcode)
2028 pp_string (buffer, " SUBCODE=[ ");
2029 if (subcode & GTMA_HAVE_ABORT)
2031 pp_string (buffer, "GTMA_HAVE_ABORT ");
2032 subcode &= ~GTMA_HAVE_ABORT;
2034 if (subcode & GTMA_HAVE_LOAD)
2036 pp_string (buffer, "GTMA_HAVE_LOAD ");
2037 subcode &= ~GTMA_HAVE_LOAD;
2039 if (subcode & GTMA_HAVE_STORE)
2041 pp_string (buffer, "GTMA_HAVE_STORE ");
2042 subcode &= ~GTMA_HAVE_STORE;
2044 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
2046 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
2047 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
2049 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
2051 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
2052 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
2054 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
2056 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
2057 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
2059 if (subcode)
2060 pp_printf (buffer, "0x%x ", subcode);
2061 pp_right_bracket (buffer);
2067 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
2068 indent. FLAGS specifies details to show in the dump (see TDF_* in
2069 dumpfile.h). */
2071 static void
2072 dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc,
2073 dump_flags_t flags)
2075 unsigned int i, n, f, fields;
2077 if (flags & TDF_RAW)
2079 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
2080 gimple_asm_string (gs));
2082 n = gimple_asm_noutputs (gs);
2083 if (n)
2085 newline_and_indent (buffer, spc + 2);
2086 pp_string (buffer, "OUTPUT: ");
2087 for (i = 0; i < n; i++)
2089 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2090 spc, flags, false);
2091 if (i < n - 1)
2092 pp_string (buffer, ", ");
2096 n = gimple_asm_ninputs (gs);
2097 if (n)
2099 newline_and_indent (buffer, spc + 2);
2100 pp_string (buffer, "INPUT: ");
2101 for (i = 0; i < n; i++)
2103 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2104 spc, flags, false);
2105 if (i < n - 1)
2106 pp_string (buffer, ", ");
2110 n = gimple_asm_nclobbers (gs);
2111 if (n)
2113 newline_and_indent (buffer, spc + 2);
2114 pp_string (buffer, "CLOBBER: ");
2115 for (i = 0; i < n; i++)
2117 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2118 spc, flags, false);
2119 if (i < n - 1)
2120 pp_string (buffer, ", ");
2124 n = gimple_asm_nlabels (gs);
2125 if (n)
2127 newline_and_indent (buffer, spc + 2);
2128 pp_string (buffer, "LABEL: ");
2129 for (i = 0; i < n; i++)
2131 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2132 spc, flags, false);
2133 if (i < n - 1)
2134 pp_string (buffer, ", ");
2138 newline_and_indent (buffer, spc);
2139 pp_greater (buffer);
2141 else
2143 pp_string (buffer, "__asm__");
2144 if (gimple_asm_volatile_p (gs))
2145 pp_string (buffer, " __volatile__");
2146 if (gimple_asm_inline_p (gs))
2147 pp_string (buffer, " __inline__");
2148 if (gimple_asm_nlabels (gs))
2149 pp_string (buffer, " goto");
2150 pp_string (buffer, "(\"");
2151 pp_string (buffer, gimple_asm_string (gs));
2152 pp_string (buffer, "\"");
2154 if (gimple_asm_nlabels (gs))
2155 fields = 4;
2156 else if (gimple_asm_nclobbers (gs))
2157 fields = 3;
2158 else if (gimple_asm_ninputs (gs))
2159 fields = 2;
2160 else if (gimple_asm_noutputs (gs))
2161 fields = 1;
2162 else
2163 fields = 0;
2165 for (f = 0; f < fields; ++f)
2167 pp_string (buffer, " : ");
2169 switch (f)
2171 case 0:
2172 n = gimple_asm_noutputs (gs);
2173 for (i = 0; i < n; i++)
2175 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2176 spc, flags, false);
2177 if (i < n - 1)
2178 pp_string (buffer, ", ");
2180 break;
2182 case 1:
2183 n = gimple_asm_ninputs (gs);
2184 for (i = 0; i < n; i++)
2186 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2187 spc, flags, false);
2188 if (i < n - 1)
2189 pp_string (buffer, ", ");
2191 break;
2193 case 2:
2194 n = gimple_asm_nclobbers (gs);
2195 for (i = 0; i < n; i++)
2197 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2198 spc, flags, false);
2199 if (i < n - 1)
2200 pp_string (buffer, ", ");
2202 break;
2204 case 3:
2205 n = gimple_asm_nlabels (gs);
2206 for (i = 0; i < n; i++)
2208 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2209 spc, flags, false);
2210 if (i < n - 1)
2211 pp_string (buffer, ", ");
2213 break;
2215 default:
2216 gcc_unreachable ();
2220 pp_string (buffer, ");");
2224 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2225 SPC spaces of indent. */
2227 static void
2228 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2230 if (TREE_CODE (node) != SSA_NAME)
2231 return;
2233 if (POINTER_TYPE_P (TREE_TYPE (node))
2234 && SSA_NAME_PTR_INFO (node))
2236 unsigned int align, misalign;
2237 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2238 pp_string (buffer, "# PT = ");
2239 pp_points_to_solution (buffer, &pi->pt);
2240 newline_and_indent (buffer, spc);
2241 if (get_ptr_info_alignment (pi, &align, &misalign))
2243 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2244 newline_and_indent (buffer, spc);
2248 if (!POINTER_TYPE_P (TREE_TYPE (node))
2249 && SSA_NAME_RANGE_INFO (node))
2251 wide_int min, max, nonzero_bits;
2252 value_range_kind range_type = get_range_info (node, &min, &max);
2254 if (range_type == VR_VARYING)
2255 pp_printf (buffer, "# RANGE VR_VARYING");
2256 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2258 pp_printf (buffer, "# RANGE ");
2259 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2260 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2261 pp_printf (buffer, ", ");
2262 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2263 pp_printf (buffer, "]");
2265 nonzero_bits = get_nonzero_bits (node);
2266 if (nonzero_bits != -1)
2268 pp_string (buffer, " NONZERO ");
2269 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2271 newline_and_indent (buffer, spc);
2275 /* As dump_ssaname_info, but dump to FILE. */
2277 void
2278 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2280 pretty_printer buffer;
2281 pp_needs_newline (&buffer) = true;
2282 buffer.buffer->stream = file;
2283 dump_ssaname_info (&buffer, node, spc);
2284 pp_flush (&buffer);
2287 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2288 The caller is responsible for calling pp_flush on BUFFER to finalize
2289 pretty printer. If COMMENT is true, print this after #. */
2291 static void
2292 dump_gimple_phi (pretty_printer *buffer, const gphi *phi, int spc, bool comment,
2293 dump_flags_t flags)
2295 size_t i;
2296 tree lhs = gimple_phi_result (phi);
2298 if (flags & TDF_ALIAS)
2299 dump_ssaname_info (buffer, lhs, spc);
2301 if (comment)
2302 pp_string (buffer, "# ");
2304 if (flags & TDF_RAW)
2305 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2306 gimple_phi_result (phi));
2307 else
2309 dump_generic_node (buffer, lhs, spc, flags, false);
2310 if (flags & TDF_GIMPLE)
2311 pp_string (buffer, " = __PHI (");
2312 else
2313 pp_string (buffer, " = PHI <");
2315 for (i = 0; i < gimple_phi_num_args (phi); i++)
2317 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2318 dump_location (buffer, gimple_phi_arg_location (phi, i));
2319 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2320 if (flags & TDF_GIMPLE)
2322 pp_string (buffer, "__BB");
2323 pp_decimal_int (buffer, src->index);
2324 pp_string (buffer, ": ");
2326 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2327 false);
2328 if (! (flags & TDF_GIMPLE))
2330 pp_left_paren (buffer);
2331 pp_decimal_int (buffer, src->index);
2332 pp_right_paren (buffer);
2334 if (i < gimple_phi_num_args (phi) - 1)
2335 pp_string (buffer, ", ");
2337 if (flags & TDF_GIMPLE)
2338 pp_string (buffer, ");");
2339 else
2340 pp_greater (buffer);
2344 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2345 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2346 dumpfile.h). */
2348 static void
2349 dump_gimple_omp_parallel (pretty_printer *buffer, const gomp_parallel *gs,
2350 int spc, dump_flags_t flags)
2352 if (flags & TDF_RAW)
2354 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2355 gimple_omp_body (gs));
2356 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2357 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2358 gimple_omp_parallel_child_fn (gs),
2359 gimple_omp_parallel_data_arg (gs));
2361 else
2363 gimple_seq body;
2364 pp_string (buffer, "#pragma omp parallel");
2365 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2366 if (gimple_omp_parallel_child_fn (gs))
2368 pp_string (buffer, " [child fn: ");
2369 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2370 spc, flags, false);
2371 pp_string (buffer, " (");
2372 if (gimple_omp_parallel_data_arg (gs))
2373 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2374 spc, flags, false);
2375 else
2376 pp_string (buffer, "???");
2377 pp_string (buffer, ")]");
2379 body = gimple_omp_body (gs);
2380 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2382 newline_and_indent (buffer, spc + 2);
2383 pp_left_brace (buffer);
2384 pp_newline (buffer);
2385 dump_gimple_seq (buffer, body, spc + 4, flags);
2386 newline_and_indent (buffer, spc + 2);
2387 pp_right_brace (buffer);
2389 else if (body)
2391 pp_newline (buffer);
2392 dump_gimple_seq (buffer, body, spc + 2, flags);
2398 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2399 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2400 dumpfile.h). */
2402 static void
2403 dump_gimple_omp_task (pretty_printer *buffer, const gomp_task *gs, int spc,
2404 dump_flags_t flags)
2406 if (flags & TDF_RAW)
2408 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2409 gimple_omp_body (gs));
2410 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2411 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2412 gimple_omp_task_child_fn (gs),
2413 gimple_omp_task_data_arg (gs),
2414 gimple_omp_task_copy_fn (gs),
2415 gimple_omp_task_arg_size (gs),
2416 gimple_omp_task_arg_size (gs));
2418 else
2420 gimple_seq body;
2421 if (gimple_omp_task_taskloop_p (gs))
2422 pp_string (buffer, "#pragma omp taskloop");
2423 else if (gimple_omp_task_taskwait_p (gs))
2424 pp_string (buffer, "#pragma omp taskwait");
2425 else
2426 pp_string (buffer, "#pragma omp task");
2427 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2428 if (gimple_omp_task_child_fn (gs))
2430 pp_string (buffer, " [child fn: ");
2431 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2432 spc, flags, false);
2433 pp_string (buffer, " (");
2434 if (gimple_omp_task_data_arg (gs))
2435 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2436 spc, flags, false);
2437 else
2438 pp_string (buffer, "???");
2439 pp_string (buffer, ")]");
2441 body = gimple_omp_body (gs);
2442 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2444 newline_and_indent (buffer, spc + 2);
2445 pp_left_brace (buffer);
2446 pp_newline (buffer);
2447 dump_gimple_seq (buffer, body, spc + 4, flags);
2448 newline_and_indent (buffer, spc + 2);
2449 pp_right_brace (buffer);
2451 else if (body)
2453 pp_newline (buffer);
2454 dump_gimple_seq (buffer, body, spc + 2, flags);
2460 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2461 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2462 in dumpfile.h). */
2464 static void
2465 dump_gimple_omp_atomic_load (pretty_printer *buffer, const gomp_atomic_load *gs,
2466 int spc, dump_flags_t flags)
2468 if (flags & TDF_RAW)
2470 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2471 gimple_omp_atomic_load_lhs (gs),
2472 gimple_omp_atomic_load_rhs (gs));
2474 else
2476 pp_string (buffer, "#pragma omp atomic_load");
2477 dump_omp_atomic_memory_order (buffer,
2478 gimple_omp_atomic_memory_order (gs));
2479 if (gimple_omp_atomic_need_value_p (gs))
2480 pp_string (buffer, " [needed]");
2481 newline_and_indent (buffer, spc + 2);
2482 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2483 spc, flags, false);
2484 pp_space (buffer);
2485 pp_equal (buffer);
2486 pp_space (buffer);
2487 pp_star (buffer);
2488 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2489 spc, flags, false);
2493 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2494 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2495 in dumpfile.h). */
2497 static void
2498 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2499 const gomp_atomic_store *gs, int spc,
2500 dump_flags_t flags)
2502 if (flags & TDF_RAW)
2504 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2505 gimple_omp_atomic_store_val (gs));
2507 else
2509 pp_string (buffer, "#pragma omp atomic_store");
2510 dump_omp_atomic_memory_order (buffer,
2511 gimple_omp_atomic_memory_order (gs));
2512 pp_space (buffer);
2513 if (gimple_omp_atomic_need_value_p (gs))
2514 pp_string (buffer, "[needed] ");
2515 pp_left_paren (buffer);
2516 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2517 spc, flags, false);
2518 pp_right_paren (buffer);
2523 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2524 FLAGS are as in pp_gimple_stmt_1. */
2526 static void
2527 dump_gimple_mem_ops (pretty_printer *buffer, const gimple *gs, int spc,
2528 dump_flags_t flags)
2530 tree vdef = gimple_vdef (gs);
2531 tree vuse = gimple_vuse (gs);
2533 if (vdef != NULL_TREE)
2535 pp_string (buffer, "# ");
2536 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2537 pp_string (buffer, " = VDEF <");
2538 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2539 pp_greater (buffer);
2540 newline_and_indent (buffer, spc);
2542 else if (vuse != NULL_TREE)
2544 pp_string (buffer, "# VUSE <");
2545 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2546 pp_greater (buffer);
2547 newline_and_indent (buffer, spc);
2552 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2553 spaces of indent. FLAGS specifies details to show in the dump (see
2554 TDF_* in dumpfile.h). The caller is responsible for calling
2555 pp_flush on BUFFER to finalize the pretty printer. */
2557 void
2558 pp_gimple_stmt_1 (pretty_printer *buffer, const gimple *gs, int spc,
2559 dump_flags_t flags)
2561 if (!gs)
2562 return;
2564 if (flags & TDF_STMTADDR)
2565 pp_printf (buffer, "<&%p> ", (const void *) gs);
2567 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2568 dump_location (buffer, gimple_location (gs));
2570 if (flags & TDF_EH)
2572 int lp_nr = lookup_stmt_eh_lp (gs);
2573 if (lp_nr > 0)
2574 pp_printf (buffer, "[LP %d] ", lp_nr);
2575 else if (lp_nr < 0)
2576 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2579 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2580 && gimple_has_mem_ops (gs))
2581 dump_gimple_mem_ops (buffer, gs, spc, flags);
2583 if (gimple_has_lhs (gs)
2584 && (flags & TDF_ALIAS))
2585 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2587 switch (gimple_code (gs))
2589 case GIMPLE_ASM:
2590 dump_gimple_asm (buffer, as_a <const gasm *> (gs), spc, flags);
2591 break;
2593 case GIMPLE_ASSIGN:
2594 dump_gimple_assign (buffer, as_a <const gassign *> (gs), spc, flags);
2595 break;
2597 case GIMPLE_BIND:
2598 dump_gimple_bind (buffer, as_a <const gbind *> (gs), spc, flags);
2599 break;
2601 case GIMPLE_CALL:
2602 dump_gimple_call (buffer, as_a <const gcall *> (gs), spc, flags);
2603 break;
2605 case GIMPLE_COND:
2606 dump_gimple_cond (buffer, as_a <const gcond *> (gs), spc, flags);
2607 break;
2609 case GIMPLE_LABEL:
2610 dump_gimple_label (buffer, as_a <const glabel *> (gs), spc, flags);
2611 break;
2613 case GIMPLE_GOTO:
2614 dump_gimple_goto (buffer, as_a <const ggoto *> (gs), spc, flags);
2615 break;
2617 case GIMPLE_NOP:
2618 pp_string (buffer, "GIMPLE_NOP");
2619 break;
2621 case GIMPLE_RETURN:
2622 dump_gimple_return (buffer, as_a <const greturn *> (gs), spc, flags);
2623 break;
2625 case GIMPLE_SWITCH:
2626 dump_gimple_switch (buffer, as_a <const gswitch *> (gs), spc, flags);
2627 break;
2629 case GIMPLE_TRY:
2630 dump_gimple_try (buffer, as_a <const gtry *> (gs), spc, flags);
2631 break;
2633 case GIMPLE_PHI:
2634 dump_gimple_phi (buffer, as_a <const gphi *> (gs), spc, false, flags);
2635 break;
2637 case GIMPLE_OMP_PARALLEL:
2638 dump_gimple_omp_parallel (buffer, as_a <const gomp_parallel *> (gs), spc,
2639 flags);
2640 break;
2642 case GIMPLE_OMP_TASK:
2643 dump_gimple_omp_task (buffer, as_a <const gomp_task *> (gs), spc, flags);
2644 break;
2646 case GIMPLE_OMP_ATOMIC_LOAD:
2647 dump_gimple_omp_atomic_load (buffer, as_a <const gomp_atomic_load *> (gs),
2648 spc, flags);
2649 break;
2651 case GIMPLE_OMP_ATOMIC_STORE:
2652 dump_gimple_omp_atomic_store (buffer,
2653 as_a <const gomp_atomic_store *> (gs),
2654 spc, flags);
2655 break;
2657 case GIMPLE_OMP_FOR:
2658 dump_gimple_omp_for (buffer, as_a <const gomp_for *> (gs), spc, flags);
2659 break;
2661 case GIMPLE_OMP_CONTINUE:
2662 dump_gimple_omp_continue (buffer, as_a <const gomp_continue *> (gs), spc,
2663 flags);
2664 break;
2666 case GIMPLE_OMP_SINGLE:
2667 dump_gimple_omp_single (buffer, as_a <const gomp_single *> (gs), spc,
2668 flags);
2669 break;
2671 case GIMPLE_OMP_TARGET:
2672 dump_gimple_omp_target (buffer, as_a <const gomp_target *> (gs), spc,
2673 flags);
2674 break;
2676 case GIMPLE_OMP_TEAMS:
2677 dump_gimple_omp_teams (buffer, as_a <const gomp_teams *> (gs), spc,
2678 flags);
2679 break;
2681 case GIMPLE_OMP_RETURN:
2682 dump_gimple_omp_return (buffer, gs, spc, flags);
2683 break;
2685 case GIMPLE_OMP_SECTIONS:
2686 dump_gimple_omp_sections (buffer, as_a <const gomp_sections *> (gs),
2687 spc, flags);
2688 break;
2690 case GIMPLE_OMP_SECTIONS_SWITCH:
2691 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2692 break;
2694 case GIMPLE_OMP_TASKGROUP:
2695 dump_gimple_omp_taskgroup (buffer, gs, spc, flags);
2696 break;
2698 case GIMPLE_OMP_MASTER:
2699 case GIMPLE_OMP_SECTION:
2700 dump_gimple_omp_block (buffer, gs, spc, flags);
2701 break;
2703 case GIMPLE_OMP_ORDERED:
2704 dump_gimple_omp_ordered (buffer, as_a <const gomp_ordered *> (gs), spc,
2705 flags);
2706 break;
2708 case GIMPLE_OMP_SCAN:
2709 dump_gimple_omp_scan (buffer, as_a <const gomp_scan *> (gs), spc,
2710 flags);
2711 break;
2713 case GIMPLE_OMP_CRITICAL:
2714 dump_gimple_omp_critical (buffer, as_a <const gomp_critical *> (gs), spc,
2715 flags);
2716 break;
2718 case GIMPLE_CATCH:
2719 dump_gimple_catch (buffer, as_a <const gcatch *> (gs), spc, flags);
2720 break;
2722 case GIMPLE_EH_FILTER:
2723 dump_gimple_eh_filter (buffer, as_a <const geh_filter *> (gs), spc,
2724 flags);
2725 break;
2727 case GIMPLE_EH_MUST_NOT_THROW:
2728 dump_gimple_eh_must_not_throw (buffer,
2729 as_a <const geh_mnt *> (gs),
2730 spc, flags);
2731 break;
2733 case GIMPLE_EH_ELSE:
2734 dump_gimple_eh_else (buffer, as_a <const geh_else *> (gs), spc, flags);
2735 break;
2737 case GIMPLE_RESX:
2738 dump_gimple_resx (buffer, as_a <const gresx *> (gs), spc, flags);
2739 break;
2741 case GIMPLE_EH_DISPATCH:
2742 dump_gimple_eh_dispatch (buffer, as_a <const geh_dispatch *> (gs), spc,
2743 flags);
2744 break;
2746 case GIMPLE_DEBUG:
2747 dump_gimple_debug (buffer, as_a <const gdebug *> (gs), spc, flags);
2748 break;
2750 case GIMPLE_PREDICT:
2751 pp_string (buffer, "// predicted ");
2752 if (gimple_predict_outcome (gs))
2753 pp_string (buffer, "likely by ");
2754 else
2755 pp_string (buffer, "unlikely by ");
2756 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2757 pp_string (buffer, " predictor.");
2758 break;
2760 case GIMPLE_TRANSACTION:
2761 dump_gimple_transaction (buffer, as_a <const gtransaction *> (gs), spc,
2762 flags);
2763 break;
2765 default:
2766 GIMPLE_NIY;
2771 /* Dumps header of basic block BB to OUTF indented by INDENT
2772 spaces and details described by flags. */
2774 static void
2775 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
2776 dump_flags_t flags)
2778 if (flags & TDF_BLOCKS)
2780 if (flags & TDF_LINENO)
2782 gimple_stmt_iterator gsi;
2784 fputs (";; ", outf);
2786 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2787 if (!is_gimple_debug (gsi_stmt (gsi))
2788 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2790 fprintf (outf, "%*sstarting at line %d",
2791 indent, "", get_lineno (gsi_stmt (gsi)));
2792 break;
2794 if (bb->discriminator)
2795 fprintf (outf, ", discriminator %i", bb->discriminator);
2796 fputc ('\n', outf);
2799 else
2801 if (flags & TDF_GIMPLE)
2803 fprintf (outf, "%*s__BB(%d", indent, "", bb->index);
2804 if (bb->loop_father->header == bb)
2805 fprintf (outf, ",loop_header(%d)", bb->loop_father->num);
2806 if (bb->count.initialized_p ())
2807 fprintf (outf, ",%s(%d)",
2808 profile_quality_as_string (bb->count.quality ()),
2809 bb->count.value ());
2810 fprintf (outf, "):\n");
2812 else
2813 fprintf (outf, "%*s<bb %d> %s:\n",
2814 indent, "", bb->index, dump_profile (bb->count));
2819 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2820 spaces. */
2822 static void
2823 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2824 basic_block bb ATTRIBUTE_UNUSED,
2825 int indent ATTRIBUTE_UNUSED,
2826 dump_flags_t flags ATTRIBUTE_UNUSED)
2828 /* There is currently no GIMPLE-specific basic block info to dump. */
2829 return;
2833 /* Dump PHI nodes of basic block BB to BUFFER with details described
2834 by FLAGS and indented by INDENT spaces. */
2836 static void
2837 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
2838 dump_flags_t flags)
2840 gphi_iterator i;
2842 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2844 gphi *phi = i.phi ();
2845 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2847 INDENT (indent);
2848 dump_gimple_phi (buffer, phi, indent,
2849 (flags & TDF_GIMPLE) ? false : true, flags);
2850 pp_newline (buffer);
2856 /* Dump jump to basic block BB that is represented implicitly in the cfg
2857 to BUFFER. */
2859 static void
2860 pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
2862 if (flags & TDF_GIMPLE)
2864 pp_string (buffer, "goto __BB");
2865 pp_decimal_int (buffer, e->dest->index);
2866 if (e->probability.initialized_p ())
2868 pp_string (buffer, "(");
2869 pp_string (buffer,
2870 profile_quality_as_string (e->probability.quality ()));
2871 pp_string (buffer, "(");
2872 pp_decimal_int (buffer, e->probability.value ());
2873 pp_string (buffer, "))");
2875 pp_semicolon (buffer);
2877 else
2879 pp_string (buffer, "goto <bb ");
2880 pp_decimal_int (buffer, e->dest->index);
2881 pp_greater (buffer);
2882 pp_semicolon (buffer);
2884 dump_edge_probability (buffer, e);
2889 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2890 by INDENT spaces, with details given by FLAGS. */
2892 static void
2893 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2894 dump_flags_t flags)
2896 edge e;
2897 gimple *stmt;
2899 stmt = last_stmt (bb);
2901 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2903 edge true_edge, false_edge;
2905 /* When we are emitting the code or changing CFG, it is possible that
2906 the edges are not yet created. When we are using debug_bb in such
2907 a situation, we do not want it to crash. */
2908 if (EDGE_COUNT (bb->succs) != 2)
2909 return;
2910 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2912 INDENT (indent + 2);
2913 pp_cfg_jump (buffer, true_edge, flags);
2914 newline_and_indent (buffer, indent);
2915 pp_string (buffer, "else");
2916 newline_and_indent (buffer, indent + 2);
2917 pp_cfg_jump (buffer, false_edge, flags);
2918 pp_newline (buffer);
2919 return;
2922 /* If there is a fallthru edge, we may need to add an artificial
2923 goto to the dump. */
2924 e = find_fallthru_edge (bb->succs);
2926 if (e && (e->dest != bb->next_bb || (flags & TDF_GIMPLE)))
2928 INDENT (indent);
2930 if ((flags & TDF_LINENO)
2931 && e->goto_locus != UNKNOWN_LOCATION)
2932 dump_location (buffer, e->goto_locus);
2934 pp_cfg_jump (buffer, e, flags);
2935 pp_newline (buffer);
2940 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2941 indented by INDENT spaces. */
2943 static void
2944 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2945 dump_flags_t flags)
2947 gimple_stmt_iterator gsi;
2948 gimple *stmt;
2949 int label_indent = indent - 2;
2951 if (label_indent < 0)
2952 label_indent = 0;
2954 dump_phi_nodes (buffer, bb, indent, flags);
2956 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2958 int curr_indent;
2960 stmt = gsi_stmt (gsi);
2962 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2964 INDENT (curr_indent);
2965 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2966 pp_newline_and_flush (buffer);
2967 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2968 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2969 pp_buffer (buffer)->stream, stmt);
2972 dump_implicit_edges (buffer, bb, indent, flags);
2973 pp_flush (buffer);
2977 /* Dumps basic block BB to FILE with details described by FLAGS and
2978 indented by INDENT spaces. */
2980 void
2981 gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
2983 dump_gimple_bb_header (file, bb, indent, flags);
2984 if (bb->index >= NUM_FIXED_BLOCKS)
2986 pretty_printer buffer;
2987 pp_needs_newline (&buffer) = true;
2988 buffer.buffer->stream = file;
2989 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2991 dump_gimple_bb_footer (file, bb, indent, flags);
2994 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2995 no indentation, for use as a label of a DOT graph record-node.
2996 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2997 histogram dumping doesn't know about pretty-printers. */
2999 void
3000 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
3002 pp_printf (pp, "<bb %d>:\n", bb->index);
3003 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3005 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
3006 gsi_next (&gsi))
3008 gphi *phi = gsi.phi ();
3009 if (!virtual_operand_p (gimple_phi_result (phi))
3010 || (dump_flags & TDF_VOPS))
3012 pp_bar (pp);
3013 pp_write_text_to_stream (pp);
3014 pp_string (pp, "# ");
3015 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
3016 pp_newline (pp);
3017 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3021 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
3022 gsi_next (&gsi))
3024 gimple *stmt = gsi_stmt (gsi);
3025 pp_bar (pp);
3026 pp_write_text_to_stream (pp);
3027 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
3028 pp_newline (pp);
3029 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3031 dump_implicit_edges (pp, bb, 0, dump_flags);
3032 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3036 /* Handle the %G format for TEXT. Same as %K in handle_K_format in
3037 tree-pretty-print.c but with a Gimple statement as an argument. */
3039 void
3040 percent_G_format (text_info *text)
3042 gimple *stmt = va_arg (*text->args_ptr, gimple*);
3044 /* Fall back on the rich location if the statement doesn't have one. */
3045 location_t loc = gimple_location (stmt);
3046 if (loc == UNKNOWN_LOCATION)
3047 loc = text->m_richloc->get_loc ();
3048 tree block = gimple_block (stmt);
3049 percent_K_format (text, loc, block);
3052 #if __GNUC__ >= 10
3053 # pragma GCC diagnostic pop
3054 #endif