Small fix for -fdump-ada-spec
[official-gcc.git] / gcc / gimple-pretty-print.cc
blob300e9d7ed1e7be73f30875e08c461a8880c3134e
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2023 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 "value-range-pretty-print.h"
34 #include "internal-fn.h"
35 #include "tree-eh.h"
36 #include "gimple-iterator.h"
37 #include "tree-cfg.h"
38 #include "dumpfile.h" /* for dump_flags */
39 #include "value-prof.h"
40 #include "trans-mem.h"
41 #include "cfganal.h"
42 #include "stringpool.h"
43 #include "attribs.h"
44 #include "asan.h"
45 #include "cfgloop.h"
46 #include "gimple-range.h"
48 /* Disable warnings about quoting issues in the pp_xxx calls below
49 that (intentionally) don't follow GCC diagnostic conventions. */
50 #if __GNUC__ >= 10
51 # pragma GCC diagnostic push
52 # pragma GCC diagnostic ignored "-Wformat-diag"
53 #endif
55 #define INDENT(SPACE) \
56 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
58 #define GIMPLE_NIY do_niy (buffer,gs)
60 /* Try to print on BUFFER a default message for the unrecognized
61 gimple statement GS. */
63 static void
64 do_niy (pretty_printer *buffer, const gimple *gs)
66 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
67 gimple_code_name[(int) gimple_code (gs)]);
71 /* Emit a newline and SPC indentation spaces to BUFFER. */
73 static void
74 newline_and_indent (pretty_printer *buffer, int spc)
76 pp_newline (buffer);
77 INDENT (spc);
81 /* Print the GIMPLE statement GS on stderr. */
83 DEBUG_FUNCTION void
84 debug_gimple_stmt (gimple *gs)
86 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
90 /* Return formatted string of a VALUE probability
91 (biased by REG_BR_PROB_BASE). Returned string is allocated
92 by xstrdup_for_dump. */
94 static const char *
95 dump_profile (profile_count &count)
97 char *buf = NULL;
98 if (!count.initialized_p ())
99 return "";
100 if (count.ipa_p ())
101 buf = xasprintf ("[count: %" PRId64 "]",
102 count.to_gcov_type ());
103 else if (count.initialized_p ())
104 buf = xasprintf ("[local count: %" PRId64 "]",
105 count.to_gcov_type ());
107 const char *ret = xstrdup_for_dump (buf);
108 free (buf);
110 return ret;
113 /* Return formatted string of a VALUE probability
114 (biased by REG_BR_PROB_BASE). Returned string is allocated
115 by xstrdup_for_dump. */
117 static const char *
118 dump_probability (profile_probability probability)
120 float minimum = 0.01f;
121 float fvalue = -1;
123 if (probability.initialized_p ())
125 fvalue = probability.to_reg_br_prob_base () * 100.0f / REG_BR_PROB_BASE;
126 if (fvalue < minimum && probability.to_reg_br_prob_base ())
127 fvalue = minimum;
130 char *buf;
131 if (probability.initialized_p ())
132 buf = xasprintf ("[%.2f%%]", fvalue);
133 else
134 buf = xasprintf ("[INV]");
136 const char *ret = xstrdup_for_dump (buf);
137 free (buf);
139 return ret;
142 /* Dump E probability to BUFFER. */
144 static void
145 dump_edge_probability (pretty_printer *buffer, edge e)
147 pp_scalar (buffer, " %s", dump_probability (e->probability));
150 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
151 FLAGS as in pp_gimple_stmt_1. */
153 void
154 print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
156 pretty_printer buffer;
157 pp_needs_newline (&buffer) = true;
158 buffer.buffer->stream = file;
159 pp_gimple_stmt_1 (&buffer, g, spc, flags);
160 pp_newline_and_flush (&buffer);
163 DEBUG_FUNCTION void
164 debug (gimple &ref)
166 print_gimple_stmt (stderr, &ref, 0, TDF_NONE);
169 DEBUG_FUNCTION void
170 debug (gimple *ptr)
172 if (ptr)
173 debug (*ptr);
174 else
175 fprintf (stderr, "<nil>\n");
179 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
180 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
181 of the statement. */
183 void
184 print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
186 flags |= TDF_RHS_ONLY;
187 pretty_printer buffer;
188 pp_needs_newline (&buffer) = true;
189 buffer.buffer->stream = file;
190 pp_gimple_stmt_1 (&buffer, g, spc, flags);
191 pp_flush (&buffer);
195 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
196 spaces and FLAGS as in pp_gimple_stmt_1.
197 The caller is responsible for calling pp_flush on BUFFER to finalize
198 the pretty printer. */
200 static void
201 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc,
202 dump_flags_t flags)
204 gimple_stmt_iterator i;
206 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
208 gimple *gs = gsi_stmt (i);
209 INDENT (spc);
210 pp_gimple_stmt_1 (buffer, gs, spc, flags);
211 if (!gsi_one_before_end_p (i))
212 pp_newline (buffer);
217 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
218 FLAGS as in pp_gimple_stmt_1. */
220 void
221 print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
223 pretty_printer buffer;
224 pp_needs_newline (&buffer) = true;
225 buffer.buffer->stream = file;
226 dump_gimple_seq (&buffer, seq, spc, flags);
227 pp_newline_and_flush (&buffer);
231 /* Print the GIMPLE sequence SEQ on stderr. */
233 DEBUG_FUNCTION void
234 debug_gimple_seq (gimple_seq seq)
236 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
240 /* A simple helper to pretty-print some of the gimple tuples in the printf
241 style. The format modifiers are preceded by '%' and are:
242 'G' - outputs a string corresponding to the code of the given gimple,
243 'S' - outputs a gimple_seq with indent of spc + 2,
244 'T' - outputs the tree t,
245 'd' - outputs an int as a decimal,
246 's' - outputs a string,
247 'n' - outputs a newline,
248 'x' - outputs an int as hexadecimal,
249 '+' - increases indent by 2 then outputs a newline,
250 '-' - decreases indent by 2 then outputs a newline. */
252 static void
253 dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags,
254 const char *fmt, ...)
256 va_list args;
257 const char *c;
258 const char *tmp;
260 va_start (args, fmt);
261 for (c = fmt; *c; c++)
263 if (*c == '%')
265 gimple_seq seq;
266 tree t;
267 gimple *g;
268 switch (*++c)
270 case 'G':
271 g = va_arg (args, gimple *);
272 tmp = gimple_code_name[gimple_code (g)];
273 pp_string (buffer, tmp);
274 break;
276 case 'S':
277 seq = va_arg (args, gimple_seq);
278 pp_newline (buffer);
279 dump_gimple_seq (buffer, seq, spc + 2, flags);
280 newline_and_indent (buffer, spc);
281 break;
283 case 'T':
284 t = va_arg (args, tree);
285 if (t == NULL_TREE)
286 pp_string (buffer, "NULL");
287 else
288 dump_generic_node (buffer, t, spc, flags, false);
289 break;
291 case 'd':
292 pp_decimal_int (buffer, va_arg (args, int));
293 break;
295 case 's':
296 pp_string (buffer, va_arg (args, char *));
297 break;
299 case 'n':
300 newline_and_indent (buffer, spc);
301 break;
303 case 'x':
304 pp_scalar (buffer, "%x", va_arg (args, int));
305 break;
307 case '+':
308 spc += 2;
309 newline_and_indent (buffer, spc);
310 break;
312 case '-':
313 spc -= 2;
314 newline_and_indent (buffer, spc);
315 break;
317 default:
318 gcc_unreachable ();
321 else
322 pp_character (buffer, *c);
324 va_end (args);
328 /* Helper for dump_gimple_assign. Print the unary RHS of the
329 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
331 static void
332 dump_unary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
333 dump_flags_t flags)
335 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
336 tree lhs = gimple_assign_lhs (gs);
337 tree rhs = gimple_assign_rhs1 (gs);
339 switch (rhs_code)
341 case VIEW_CONVERT_EXPR:
342 dump_generic_node (buffer, rhs, spc, flags, false);
343 break;
345 case FIXED_CONVERT_EXPR:
346 case ADDR_SPACE_CONVERT_EXPR:
347 case FIX_TRUNC_EXPR:
348 case FLOAT_EXPR:
349 CASE_CONVERT:
350 pp_left_paren (buffer);
351 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
352 pp_string (buffer, ") ");
353 if (op_prio (rhs) < op_code_prio (rhs_code))
355 pp_left_paren (buffer);
356 dump_generic_node (buffer, rhs, spc, flags, false);
357 pp_right_paren (buffer);
359 else
360 dump_generic_node (buffer, rhs, spc, flags, false);
361 break;
363 case PAREN_EXPR:
364 pp_string (buffer, "((");
365 dump_generic_node (buffer, rhs, spc, flags, false);
366 pp_string (buffer, "))");
367 break;
369 case ABS_EXPR:
370 case ABSU_EXPR:
371 if (flags & TDF_GIMPLE)
373 pp_string (buffer,
374 rhs_code == ABS_EXPR ? "__ABS " : "__ABSU ");
375 dump_generic_node (buffer, rhs, spc, flags, false);
377 else
379 pp_string (buffer,
380 rhs_code == ABS_EXPR ? "ABS_EXPR <" : "ABSU_EXPR <");
381 dump_generic_node (buffer, rhs, spc, flags, false);
382 pp_greater (buffer);
384 break;
386 default:
387 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
388 || TREE_CODE_CLASS (rhs_code) == tcc_constant
389 || TREE_CODE_CLASS (rhs_code) == tcc_reference
390 || rhs_code == SSA_NAME
391 || rhs_code == ADDR_EXPR
392 || rhs_code == CONSTRUCTOR)
394 dump_generic_node (buffer, rhs, spc, flags, false);
395 break;
397 else if (rhs_code == BIT_NOT_EXPR)
398 pp_complement (buffer);
399 else if (rhs_code == TRUTH_NOT_EXPR)
400 pp_exclamation (buffer);
401 else if (rhs_code == NEGATE_EXPR)
402 pp_minus (buffer);
403 else
405 pp_left_bracket (buffer);
406 pp_string (buffer, get_tree_code_name (rhs_code));
407 pp_string (buffer, "] ");
410 if (op_prio (rhs) < op_code_prio (rhs_code))
412 pp_left_paren (buffer);
413 dump_generic_node (buffer, rhs, spc, flags, false);
414 pp_right_paren (buffer);
416 else
417 dump_generic_node (buffer, rhs, spc, flags, false);
418 break;
423 /* Helper for dump_gimple_assign. Print the binary RHS of the
424 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
426 static void
427 dump_binary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
428 dump_flags_t flags)
430 const char *p;
431 enum tree_code code = gimple_assign_rhs_code (gs);
432 switch (code)
434 case MIN_EXPR:
435 case MAX_EXPR:
436 if (flags & TDF_GIMPLE)
438 pp_string (buffer, code == MIN_EXPR ? "__MIN (" : "__MAX (");
439 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
440 false);
441 pp_string (buffer, ", ");
442 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
443 false);
444 pp_string (buffer, ")");
445 break;
447 else
449 gcc_fallthrough ();
451 case COMPLEX_EXPR:
452 case VEC_WIDEN_MULT_HI_EXPR:
453 case VEC_WIDEN_MULT_LO_EXPR:
454 case VEC_WIDEN_MULT_EVEN_EXPR:
455 case VEC_WIDEN_MULT_ODD_EXPR:
456 case VEC_PACK_TRUNC_EXPR:
457 case VEC_PACK_SAT_EXPR:
458 case VEC_PACK_FIX_TRUNC_EXPR:
459 case VEC_PACK_FLOAT_EXPR:
460 case VEC_WIDEN_LSHIFT_HI_EXPR:
461 case VEC_WIDEN_LSHIFT_LO_EXPR:
462 case VEC_WIDEN_PLUS_HI_EXPR:
463 case VEC_WIDEN_PLUS_LO_EXPR:
464 case VEC_WIDEN_MINUS_HI_EXPR:
465 case VEC_WIDEN_MINUS_LO_EXPR:
466 case VEC_SERIES_EXPR:
467 for (p = get_tree_code_name (code); *p; p++)
468 pp_character (buffer, TOUPPER (*p));
469 pp_string (buffer, " <");
470 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
471 pp_string (buffer, ", ");
472 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
473 pp_greater (buffer);
474 break;
476 default:
477 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
479 pp_left_paren (buffer);
480 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
481 false);
482 pp_right_paren (buffer);
484 else
485 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
486 pp_space (buffer);
487 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
488 pp_space (buffer);
489 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
491 pp_left_paren (buffer);
492 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
493 false);
494 pp_right_paren (buffer);
496 else
497 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
501 /* Helper for dump_gimple_assign. Print the ternary RHS of the
502 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
504 static void
505 dump_ternary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
506 dump_flags_t flags)
508 const char *p;
509 enum tree_code code = gimple_assign_rhs_code (gs);
510 switch (code)
512 case WIDEN_MULT_PLUS_EXPR:
513 case WIDEN_MULT_MINUS_EXPR:
514 for (p = get_tree_code_name (code); *p; p++)
515 pp_character (buffer, TOUPPER (*p));
516 pp_string (buffer, " <");
517 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
518 pp_string (buffer, ", ");
519 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
520 pp_string (buffer, ", ");
521 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
522 pp_greater (buffer);
523 break;
525 case DOT_PROD_EXPR:
526 pp_string (buffer, "DOT_PROD_EXPR <");
527 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
528 pp_string (buffer, ", ");
529 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
530 pp_string (buffer, ", ");
531 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
532 pp_greater (buffer);
533 break;
535 case SAD_EXPR:
536 pp_string (buffer, "SAD_EXPR <");
537 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
538 pp_string (buffer, ", ");
539 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
540 pp_string (buffer, ", ");
541 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
542 pp_greater (buffer);
543 break;
545 case VEC_PERM_EXPR:
546 if (flags & TDF_GIMPLE)
547 pp_string (buffer, "__VEC_PERM (");
548 else
549 pp_string (buffer, "VEC_PERM_EXPR <");
550 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
551 pp_string (buffer, ", ");
552 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
553 pp_string (buffer, ", ");
554 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
555 if (flags & TDF_GIMPLE)
556 pp_right_paren (buffer);
557 else
558 pp_greater (buffer);
559 break;
561 case REALIGN_LOAD_EXPR:
562 pp_string (buffer, "REALIGN_LOAD <");
563 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
564 pp_string (buffer, ", ");
565 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
566 pp_string (buffer, ", ");
567 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
568 pp_greater (buffer);
569 break;
571 case COND_EXPR:
572 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
573 pp_string (buffer, " ? ");
574 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
575 pp_string (buffer, " : ");
576 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
577 break;
579 case VEC_COND_EXPR:
580 pp_string (buffer, "VEC_COND_EXPR <");
581 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
582 pp_string (buffer, ", ");
583 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
584 pp_string (buffer, ", ");
585 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
586 pp_greater (buffer);
587 break;
589 case BIT_INSERT_EXPR:
590 if (flags & TDF_GIMPLE)
592 pp_string (buffer, "__BIT_INSERT (");
593 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc,
594 flags | TDF_SLIM, false);
595 pp_string (buffer, ", ");
596 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc,
597 flags | TDF_SLIM, false);
598 pp_string (buffer, ", ");
599 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc,
600 flags | TDF_SLIM, false);
601 pp_right_paren (buffer);
603 else
605 pp_string (buffer, "BIT_INSERT_EXPR <");
606 dump_generic_node (buffer, gimple_assign_rhs1 (gs),
607 spc, flags, false);
608 pp_string (buffer, ", ");
609 dump_generic_node (buffer, gimple_assign_rhs2 (gs),
610 spc, flags, false);
611 pp_string (buffer, ", ");
612 dump_generic_node (buffer, gimple_assign_rhs3 (gs),
613 spc, flags, false);
614 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
616 pp_string (buffer, " (");
617 pp_decimal_int (buffer, TYPE_PRECISION
618 (TREE_TYPE (gimple_assign_rhs2 (gs))));
619 pp_string (buffer, " bits)");
621 pp_greater (buffer);
623 break;
625 default:
626 gcc_unreachable ();
631 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
632 pp_gimple_stmt_1. */
634 static void
635 dump_gimple_assign (pretty_printer *buffer, const gassign *gs, int spc,
636 dump_flags_t flags)
638 if (flags & TDF_RAW)
640 tree arg1 = NULL;
641 tree arg2 = NULL;
642 tree arg3 = NULL;
643 switch (gimple_num_ops (gs))
645 case 4:
646 arg3 = gimple_assign_rhs3 (gs);
647 /* FALLTHRU */
648 case 3:
649 arg2 = gimple_assign_rhs2 (gs);
650 /* FALLTHRU */
651 case 2:
652 arg1 = gimple_assign_rhs1 (gs);
653 break;
654 default:
655 gcc_unreachable ();
658 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
659 get_tree_code_name (gimple_assign_rhs_code (gs)),
660 gimple_assign_lhs (gs), arg1, arg2, arg3);
662 else
664 if (!(flags & TDF_RHS_ONLY))
666 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
667 pp_space (buffer);
668 pp_equal (buffer);
670 if (gimple_assign_nontemporal_move_p (gs))
671 pp_string (buffer, "{nt}");
673 if (gimple_has_volatile_ops (gs))
674 pp_string (buffer, "{v}");
676 pp_space (buffer);
679 if (gimple_num_ops (gs) == 2)
680 dump_unary_rhs (buffer, gs, spc,
681 ((flags & TDF_GIMPLE)
682 && gimple_assign_rhs_class (gs) != GIMPLE_SINGLE_RHS)
683 ? (flags | TDF_GIMPLE_VAL) : flags);
684 else if (gimple_num_ops (gs) == 3)
685 dump_binary_rhs (buffer, gs, spc,
686 (flags & TDF_GIMPLE)
687 ? (flags | TDF_GIMPLE_VAL) : flags);
688 else if (gimple_num_ops (gs) == 4)
689 dump_ternary_rhs (buffer, gs, spc,
690 (flags & TDF_GIMPLE)
691 ? (flags | TDF_GIMPLE_VAL) : flags);
692 else
693 gcc_unreachable ();
694 if (!(flags & TDF_RHS_ONLY))
695 pp_semicolon (buffer);
700 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
701 pp_gimple_stmt_1. */
703 static void
704 dump_gimple_return (pretty_printer *buffer, const greturn *gs, int spc,
705 dump_flags_t flags)
707 tree t;
709 t = gimple_return_retval (gs);
710 if (flags & TDF_RAW)
711 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
712 else
714 pp_string (buffer, "return");
715 if (t)
717 pp_space (buffer);
718 dump_generic_node (buffer, t, spc, flags, false);
720 pp_semicolon (buffer);
725 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
726 dump_gimple_call. */
728 static void
729 dump_gimple_call_args (pretty_printer *buffer, const gcall *gs,
730 dump_flags_t flags)
732 size_t i = 0;
734 /* Pretty print first arg to certain internal fns. */
735 if (gimple_call_internal_p (gs))
737 const char *const *enums = NULL;
738 unsigned limit = 0;
740 switch (gimple_call_internal_fn (gs))
742 case IFN_UNIQUE:
743 #define DEF(X) #X
744 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
745 #undef DEF
746 enums = unique_args;
748 limit = ARRAY_SIZE (unique_args);
749 break;
751 case IFN_GOACC_LOOP:
752 #define DEF(X) #X
753 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
754 #undef DEF
755 enums = loop_args;
756 limit = ARRAY_SIZE (loop_args);
757 break;
759 case IFN_GOACC_REDUCTION:
760 #define DEF(X) #X
761 static const char *const reduction_args[]
762 = {IFN_GOACC_REDUCTION_CODES};
763 #undef DEF
764 enums = reduction_args;
765 limit = ARRAY_SIZE (reduction_args);
766 break;
768 case IFN_HWASAN_MARK:
769 case IFN_ASAN_MARK:
770 #define DEF(X) #X
771 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
772 #undef DEF
773 enums = asan_mark_args;
774 limit = ARRAY_SIZE (asan_mark_args);
775 break;
777 default:
778 break;
780 if (limit)
782 tree arg0 = gimple_call_arg (gs, 0);
783 HOST_WIDE_INT v;
785 if (TREE_CODE (arg0) == INTEGER_CST
786 && tree_fits_shwi_p (arg0)
787 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
789 i++;
790 pp_string (buffer, enums[v]);
795 for (; i < gimple_call_num_args (gs); i++)
797 if (i)
798 pp_string (buffer, ", ");
799 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
802 if (gimple_call_va_arg_pack_p (gs))
804 if (i)
805 pp_string (buffer, ", ");
807 pp_string (buffer, "__builtin_va_arg_pack ()");
811 /* Dump the points-to solution *PT to BUFFER. */
813 static void
814 pp_points_to_solution (pretty_printer *buffer, const pt_solution *pt)
816 if (pt->anything)
818 pp_string (buffer, "anything ");
819 return;
821 if (pt->nonlocal)
822 pp_string (buffer, "nonlocal ");
823 if (pt->escaped)
824 pp_string (buffer, "escaped ");
825 if (pt->ipa_escaped)
826 pp_string (buffer, "unit-escaped ");
827 if (pt->null)
828 pp_string (buffer, "null ");
829 if (pt->vars
830 && !bitmap_empty_p (pt->vars))
832 bitmap_iterator bi;
833 unsigned i;
834 pp_string (buffer, "{ ");
835 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
837 pp_string (buffer, "D.");
838 pp_decimal_int (buffer, i);
839 pp_space (buffer);
841 pp_right_brace (buffer);
842 if (pt->vars_contains_nonlocal
843 || pt->vars_contains_escaped
844 || pt->vars_contains_escaped_heap
845 || pt->vars_contains_restrict)
847 const char *comma = "";
848 pp_string (buffer, " (");
849 if (pt->vars_contains_nonlocal)
851 pp_string (buffer, "nonlocal");
852 comma = ", ";
854 if (pt->vars_contains_escaped)
856 pp_string (buffer, comma);
857 pp_string (buffer, "escaped");
858 comma = ", ";
860 if (pt->vars_contains_escaped_heap)
862 pp_string (buffer, comma);
863 pp_string (buffer, "escaped heap");
864 comma = ", ";
866 if (pt->vars_contains_restrict)
868 pp_string (buffer, comma);
869 pp_string (buffer, "restrict");
870 comma = ", ";
872 if (pt->vars_contains_interposable)
874 pp_string (buffer, comma);
875 pp_string (buffer, "interposable");
877 pp_string (buffer, ")");
883 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
884 pp_gimple_stmt_1. */
886 static void
887 dump_gimple_call (pretty_printer *buffer, const gcall *gs, int spc,
888 dump_flags_t flags)
890 tree lhs = gimple_call_lhs (gs);
891 tree fn = gimple_call_fn (gs);
893 if (flags & TDF_ALIAS)
895 const pt_solution *pt;
896 pt = gimple_call_use_set (gs);
897 if (!pt_solution_empty_p (pt))
899 pp_string (buffer, "# USE = ");
900 pp_points_to_solution (buffer, pt);
901 newline_and_indent (buffer, spc);
903 pt = gimple_call_clobber_set (gs);
904 if (!pt_solution_empty_p (pt))
906 pp_string (buffer, "# CLB = ");
907 pp_points_to_solution (buffer, pt);
908 newline_and_indent (buffer, spc);
912 if (flags & TDF_RAW)
914 if (gimple_call_internal_p (gs))
915 dump_gimple_fmt (buffer, spc, flags, "%G <.%s, %T", gs,
916 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
917 else
918 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
919 if (gimple_call_num_args (gs) > 0)
921 pp_string (buffer, ", ");
922 dump_gimple_call_args (buffer, gs, flags);
924 pp_greater (buffer);
926 else
928 if (lhs && !(flags & TDF_RHS_ONLY))
930 dump_generic_node (buffer, lhs, spc, flags, false);
931 pp_string (buffer, " =");
933 if (gimple_has_volatile_ops (gs))
934 pp_string (buffer, "{v}");
936 pp_space (buffer);
938 if (gimple_call_internal_p (gs))
940 pp_dot (buffer);
941 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
943 else
944 print_call_name (buffer, fn, flags);
945 pp_string (buffer, " (");
946 dump_gimple_call_args (buffer, gs, flags);
947 pp_right_paren (buffer);
948 if (!(flags & TDF_RHS_ONLY))
949 pp_semicolon (buffer);
952 if (gimple_call_chain (gs))
954 pp_string (buffer, " [static-chain: ");
955 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
956 pp_right_bracket (buffer);
959 if (gimple_call_return_slot_opt_p (gs))
960 pp_string (buffer, " [return slot optimization]");
961 if (gimple_call_tail_p (gs))
962 pp_string (buffer, " [tail call]");
963 if (gimple_call_must_tail_p (gs))
964 pp_string (buffer, " [must tail call]");
966 if (fn == NULL)
967 return;
969 /* Dump the arguments of _ITM_beginTransaction sanely. */
970 if (TREE_CODE (fn) == ADDR_EXPR)
971 fn = TREE_OPERAND (fn, 0);
972 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
973 pp_string (buffer, " [tm-clone]");
974 if (TREE_CODE (fn) == FUNCTION_DECL
975 && fndecl_built_in_p (fn, BUILT_IN_TM_START)
976 && gimple_call_num_args (gs) > 0)
978 tree t = gimple_call_arg (gs, 0);
979 unsigned HOST_WIDE_INT props;
980 gcc_assert (TREE_CODE (t) == INTEGER_CST);
982 pp_string (buffer, " [ ");
984 /* Get the transaction code properties. */
985 props = TREE_INT_CST_LOW (t);
987 if (props & PR_INSTRUMENTEDCODE)
988 pp_string (buffer, "instrumentedCode ");
989 if (props & PR_UNINSTRUMENTEDCODE)
990 pp_string (buffer, "uninstrumentedCode ");
991 if (props & PR_HASNOXMMUPDATE)
992 pp_string (buffer, "hasNoXMMUpdate ");
993 if (props & PR_HASNOABORT)
994 pp_string (buffer, "hasNoAbort ");
995 if (props & PR_HASNOIRREVOCABLE)
996 pp_string (buffer, "hasNoIrrevocable ");
997 if (props & PR_DOESGOIRREVOCABLE)
998 pp_string (buffer, "doesGoIrrevocable ");
999 if (props & PR_HASNOSIMPLEREADS)
1000 pp_string (buffer, "hasNoSimpleReads ");
1001 if (props & PR_AWBARRIERSOMITTED)
1002 pp_string (buffer, "awBarriersOmitted ");
1003 if (props & PR_RARBARRIERSOMITTED)
1004 pp_string (buffer, "RaRBarriersOmitted ");
1005 if (props & PR_UNDOLOGCODE)
1006 pp_string (buffer, "undoLogCode ");
1007 if (props & PR_PREFERUNINSTRUMENTED)
1008 pp_string (buffer, "preferUninstrumented ");
1009 if (props & PR_EXCEPTIONBLOCK)
1010 pp_string (buffer, "exceptionBlock ");
1011 if (props & PR_HASELSE)
1012 pp_string (buffer, "hasElse ");
1013 if (props & PR_READONLY)
1014 pp_string (buffer, "readOnly ");
1016 pp_right_bracket (buffer);
1021 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
1022 pp_gimple_stmt_1. */
1024 static void
1025 dump_gimple_switch (pretty_printer *buffer, const gswitch *gs, int spc,
1026 dump_flags_t flags)
1028 unsigned int i;
1030 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
1031 if (flags & TDF_RAW)
1032 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
1033 gimple_switch_index (gs));
1034 else
1036 pp_string (buffer, "switch (");
1037 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
1038 if (flags & TDF_GIMPLE)
1039 pp_string (buffer, ") {");
1040 else
1041 pp_string (buffer, ") <");
1044 for (i = 0; i < gimple_switch_num_labels (gs); i++)
1046 tree case_label = gimple_switch_label (gs, i);
1047 gcc_checking_assert (case_label != NULL_TREE);
1048 dump_generic_node (buffer, case_label, spc, flags, false);
1049 pp_space (buffer);
1050 tree label = CASE_LABEL (case_label);
1051 dump_generic_node (buffer, label, spc, flags, false);
1053 if (cfun && cfun->cfg)
1055 basic_block dest = label_to_block (cfun, label);
1056 if (dest)
1058 edge label_edge = find_edge (gimple_bb (gs), dest);
1059 if (label_edge && !(flags & TDF_GIMPLE))
1060 dump_edge_probability (buffer, label_edge);
1064 if (i < gimple_switch_num_labels (gs) - 1)
1066 if (flags & TDF_GIMPLE)
1067 pp_string (buffer, "; ");
1068 else
1069 pp_string (buffer, ", ");
1072 if (flags & TDF_GIMPLE)
1073 pp_string (buffer, "; }");
1074 else
1075 pp_greater (buffer);
1079 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1080 pp_gimple_stmt_1. */
1082 static void
1083 dump_gimple_cond (pretty_printer *buffer, const gcond *gs, int spc,
1084 dump_flags_t flags)
1086 if (flags & TDF_RAW)
1087 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1088 get_tree_code_name (gimple_cond_code (gs)),
1089 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1090 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1091 else
1093 if (!(flags & TDF_RHS_ONLY))
1094 pp_string (buffer, "if (");
1095 dump_generic_node (buffer, gimple_cond_lhs (gs), spc,
1096 flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : TDF_NONE),
1097 false);
1098 pp_space (buffer);
1099 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1100 pp_space (buffer);
1101 dump_generic_node (buffer, gimple_cond_rhs (gs), spc,
1102 flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : TDF_NONE),
1103 false);
1104 if (!(flags & TDF_RHS_ONLY))
1106 edge_iterator ei;
1107 edge e, true_edge = NULL, false_edge = NULL;
1108 basic_block bb = gimple_bb (gs);
1110 if (bb)
1112 FOR_EACH_EDGE (e, ei, bb->succs)
1114 if (e->flags & EDGE_TRUE_VALUE)
1115 true_edge = e;
1116 else if (e->flags & EDGE_FALSE_VALUE)
1117 false_edge = e;
1121 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1123 pp_right_paren (buffer);
1125 if (gimple_cond_true_label (gs))
1127 pp_string (buffer, " goto ");
1128 dump_generic_node (buffer, gimple_cond_true_label (gs),
1129 spc, flags, false);
1130 if (has_edge_info && !(flags & TDF_GIMPLE))
1131 dump_edge_probability (buffer, true_edge);
1132 pp_semicolon (buffer);
1134 if (gimple_cond_false_label (gs))
1136 pp_string (buffer, " else goto ");
1137 dump_generic_node (buffer, gimple_cond_false_label (gs),
1138 spc, flags, false);
1139 if (has_edge_info && !(flags & TDF_GIMPLE))
1140 dump_edge_probability (buffer, false_edge);
1142 pp_semicolon (buffer);
1149 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1150 spaces of indent. FLAGS specifies details to show in the dump (see
1151 TDF_* in dumpfils.h). */
1153 static void
1154 dump_gimple_label (pretty_printer *buffer, const glabel *gs, int spc,
1155 dump_flags_t flags)
1157 tree label = gimple_label_label (gs);
1158 if (flags & TDF_RAW)
1159 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1160 else
1162 dump_generic_node (buffer, label, spc, flags, false);
1163 pp_colon (buffer);
1165 if (flags & TDF_GIMPLE)
1166 return;
1167 if (DECL_NONLOCAL (label))
1168 pp_string (buffer, " [non-local]");
1169 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1170 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1173 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1174 spaces of indent. FLAGS specifies details to show in the dump (see
1175 TDF_* in dumpfile.h). */
1177 static void
1178 dump_gimple_goto (pretty_printer *buffer, const ggoto *gs, int spc,
1179 dump_flags_t flags)
1181 tree label = gimple_goto_dest (gs);
1182 if (flags & TDF_RAW)
1183 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1184 else
1185 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1189 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1190 spaces of indent. FLAGS specifies details to show in the dump (see
1191 TDF_* in dumpfile.h). */
1193 static void
1194 dump_gimple_bind (pretty_printer *buffer, const gbind *gs, int spc,
1195 dump_flags_t flags)
1197 if (flags & TDF_RAW)
1198 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1199 else
1200 pp_left_brace (buffer);
1201 if (!(flags & TDF_SLIM))
1203 tree var;
1205 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1207 newline_and_indent (buffer, 2);
1208 print_declaration (buffer, var, spc, flags);
1210 if (gimple_bind_vars (gs))
1211 pp_newline (buffer);
1213 pp_newline (buffer);
1214 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1215 newline_and_indent (buffer, spc);
1216 if (flags & TDF_RAW)
1217 pp_greater (buffer);
1218 else
1219 pp_right_brace (buffer);
1223 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1224 indent. FLAGS specifies details to show in the dump (see TDF_* in
1225 dumpfile.h). */
1227 static void
1228 dump_gimple_try (pretty_printer *buffer, const gtry *gs, int spc,
1229 dump_flags_t flags)
1231 if (flags & TDF_RAW)
1233 const char *type;
1234 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1235 type = "GIMPLE_TRY_CATCH";
1236 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1237 type = "GIMPLE_TRY_FINALLY";
1238 else
1239 type = "UNKNOWN GIMPLE_TRY";
1240 dump_gimple_fmt (buffer, spc, flags,
1241 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1242 gimple_try_eval (gs), gimple_try_cleanup (gs));
1244 else
1246 pp_string (buffer, "try");
1247 newline_and_indent (buffer, spc + 2);
1248 pp_left_brace (buffer);
1249 pp_newline (buffer);
1251 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1252 newline_and_indent (buffer, spc + 2);
1253 pp_right_brace (buffer);
1255 gimple_seq seq = gimple_try_cleanup (gs);
1257 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1259 newline_and_indent (buffer, spc);
1260 pp_string (buffer, "catch");
1261 newline_and_indent (buffer, spc + 2);
1262 pp_left_brace (buffer);
1264 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1266 newline_and_indent (buffer, spc);
1267 pp_string (buffer, "finally");
1268 newline_and_indent (buffer, spc + 2);
1269 pp_left_brace (buffer);
1271 if (seq && is_a <geh_else *> (gimple_seq_first_stmt (seq))
1272 && gimple_seq_nondebug_singleton_p (seq))
1274 geh_else *stmt = as_a <geh_else *> (gimple_seq_first_stmt (seq));
1275 seq = gimple_eh_else_n_body (stmt);
1276 pp_newline (buffer);
1277 dump_gimple_seq (buffer, seq, spc + 4, flags);
1278 newline_and_indent (buffer, spc + 2);
1279 pp_right_brace (buffer);
1280 seq = gimple_eh_else_e_body (stmt);
1281 newline_and_indent (buffer, spc);
1282 pp_string (buffer, "else");
1283 newline_and_indent (buffer, spc + 2);
1284 pp_left_brace (buffer);
1287 else
1288 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1290 pp_newline (buffer);
1291 dump_gimple_seq (buffer, seq, spc + 4, flags);
1292 newline_and_indent (buffer, spc + 2);
1293 pp_right_brace (buffer);
1298 /* Dump a GIMPLE_CATCH 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_catch (pretty_printer *buffer, const gcatch *gs, int spc,
1304 dump_flags_t flags)
1306 if (flags & TDF_RAW)
1307 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1308 gimple_catch_types (gs), gimple_catch_handler (gs));
1309 else
1310 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1311 gimple_catch_types (gs), gimple_catch_handler (gs));
1315 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1316 indent. FLAGS specifies details to show in the dump (see TDF_* in
1317 dumpfile.h). */
1319 static void
1320 dump_gimple_eh_filter (pretty_printer *buffer, const geh_filter *gs, int spc,
1321 dump_flags_t flags)
1323 if (flags & TDF_RAW)
1324 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1325 gimple_eh_filter_types (gs),
1326 gimple_eh_filter_failure (gs));
1327 else
1328 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1329 gimple_eh_filter_types (gs),
1330 gimple_eh_filter_failure (gs));
1334 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1336 static void
1337 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1338 const geh_mnt *gs, int spc, dump_flags_t flags)
1340 if (flags & TDF_RAW)
1341 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1342 gimple_eh_must_not_throw_fndecl (gs));
1343 else
1344 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1345 gimple_eh_must_not_throw_fndecl (gs));
1349 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1350 indent. FLAGS specifies details to show in the dump (see TDF_* in
1351 dumpfile.h). */
1353 static void
1354 dump_gimple_eh_else (pretty_printer *buffer, const geh_else *gs, int spc,
1355 dump_flags_t flags)
1357 if (flags & TDF_RAW)
1358 dump_gimple_fmt (buffer, spc, flags,
1359 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1360 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1361 else
1362 dump_gimple_fmt (buffer, spc, flags,
1363 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1364 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1368 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1369 indent. FLAGS specifies details to show in the dump (see TDF_* in
1370 dumpfile.h). */
1372 static void
1373 dump_gimple_resx (pretty_printer *buffer, const gresx *gs, int spc,
1374 dump_flags_t flags)
1376 if (flags & TDF_RAW)
1377 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1378 gimple_resx_region (gs));
1379 else
1380 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1383 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1385 static void
1386 dump_gimple_eh_dispatch (pretty_printer *buffer, const geh_dispatch *gs,
1387 int spc, dump_flags_t flags)
1389 if (flags & TDF_RAW)
1390 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1391 gimple_eh_dispatch_region (gs));
1392 else
1393 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1394 gimple_eh_dispatch_region (gs));
1397 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1398 of indent. FLAGS specifies details to show in the dump (see TDF_*
1399 in dumpfile.h). */
1401 static void
1402 dump_gimple_debug (pretty_printer *buffer, const gdebug *gs, int spc,
1403 dump_flags_t flags)
1405 switch (gs->subcode)
1407 case GIMPLE_DEBUG_BIND:
1408 if (flags & TDF_RAW)
1409 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1410 gimple_debug_bind_get_var (gs),
1411 gimple_debug_bind_get_value (gs));
1412 else
1413 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1414 gimple_debug_bind_get_var (gs),
1415 gimple_debug_bind_get_value (gs));
1416 break;
1418 case GIMPLE_DEBUG_SOURCE_BIND:
1419 if (flags & TDF_RAW)
1420 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1421 gimple_debug_source_bind_get_var (gs),
1422 gimple_debug_source_bind_get_value (gs));
1423 else
1424 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1425 gimple_debug_source_bind_get_var (gs),
1426 gimple_debug_source_bind_get_value (gs));
1427 break;
1429 case GIMPLE_DEBUG_BEGIN_STMT:
1430 if (flags & TDF_RAW)
1431 dump_gimple_fmt (buffer, spc, flags, "%G BEGIN_STMT", gs);
1432 else
1433 dump_gimple_fmt (buffer, spc, flags, "# DEBUG BEGIN_STMT");
1434 break;
1436 case GIMPLE_DEBUG_INLINE_ENTRY:
1437 if (flags & TDF_RAW)
1438 dump_gimple_fmt (buffer, spc, flags, "%G INLINE_ENTRY %T", gs,
1439 gimple_block (gs)
1440 ? block_ultimate_origin (gimple_block (gs))
1441 : NULL_TREE);
1442 else
1443 dump_gimple_fmt (buffer, spc, flags, "# DEBUG INLINE_ENTRY %T",
1444 gimple_block (gs)
1445 ? block_ultimate_origin (gimple_block (gs))
1446 : NULL_TREE);
1447 break;
1449 default:
1450 gcc_unreachable ();
1454 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1455 static void
1456 dump_gimple_omp_for (pretty_printer *buffer, const gomp_for *gs, int spc,
1457 dump_flags_t flags)
1459 size_t i;
1461 if (flags & TDF_RAW)
1463 const char *kind;
1464 switch (gimple_omp_for_kind (gs))
1466 case GF_OMP_FOR_KIND_FOR:
1467 kind = "";
1468 break;
1469 case GF_OMP_FOR_KIND_DISTRIBUTE:
1470 kind = " distribute";
1471 break;
1472 case GF_OMP_FOR_KIND_TASKLOOP:
1473 kind = " taskloop";
1474 break;
1475 case GF_OMP_FOR_KIND_OACC_LOOP:
1476 kind = " oacc_loop";
1477 break;
1478 case GF_OMP_FOR_KIND_SIMD:
1479 kind = " simd";
1480 break;
1481 default:
1482 gcc_unreachable ();
1484 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1485 kind, gimple_omp_body (gs));
1486 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1487 dump_gimple_fmt (buffer, spc, flags, " >,");
1488 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1489 dump_gimple_fmt (buffer, spc, flags,
1490 "%+%T, %T, %T, %s, %T,%n",
1491 gimple_omp_for_index (gs, i),
1492 gimple_omp_for_initial (gs, i),
1493 gimple_omp_for_final (gs, i),
1494 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1495 gimple_omp_for_incr (gs, i));
1496 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1497 gimple_omp_for_pre_body (gs));
1499 else
1501 switch (gimple_omp_for_kind (gs))
1503 case GF_OMP_FOR_KIND_FOR:
1504 pp_string (buffer, "#pragma omp for");
1505 break;
1506 case GF_OMP_FOR_KIND_DISTRIBUTE:
1507 pp_string (buffer, "#pragma omp distribute");
1508 break;
1509 case GF_OMP_FOR_KIND_TASKLOOP:
1510 pp_string (buffer, "#pragma omp taskloop");
1511 break;
1512 case GF_OMP_FOR_KIND_OACC_LOOP:
1513 pp_string (buffer, "#pragma acc loop");
1514 break;
1515 case GF_OMP_FOR_KIND_SIMD:
1516 pp_string (buffer, "#pragma omp simd");
1517 break;
1518 default:
1519 gcc_unreachable ();
1521 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1522 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1524 if (i)
1525 spc += 2;
1526 newline_and_indent (buffer, spc);
1527 pp_string (buffer, "for (");
1528 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1529 flags, false);
1530 pp_string (buffer, " = ");
1531 tree init = gimple_omp_for_initial (gs, i);
1532 if (TREE_CODE (init) != TREE_VEC)
1533 dump_generic_node (buffer, init, spc, flags, false);
1534 else
1535 dump_omp_loop_non_rect_expr (buffer, init, spc, flags);
1536 pp_string (buffer, "; ");
1538 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1539 flags, false);
1540 pp_space (buffer);
1541 switch (gimple_omp_for_cond (gs, i))
1543 case LT_EXPR:
1544 pp_less (buffer);
1545 break;
1546 case GT_EXPR:
1547 pp_greater (buffer);
1548 break;
1549 case LE_EXPR:
1550 pp_less_equal (buffer);
1551 break;
1552 case GE_EXPR:
1553 pp_greater_equal (buffer);
1554 break;
1555 case NE_EXPR:
1556 pp_string (buffer, "!=");
1557 break;
1558 default:
1559 gcc_unreachable ();
1561 pp_space (buffer);
1562 tree cond = gimple_omp_for_final (gs, i);
1563 if (TREE_CODE (cond) != TREE_VEC)
1564 dump_generic_node (buffer, cond, spc, flags, false);
1565 else
1566 dump_omp_loop_non_rect_expr (buffer, cond, spc, flags);
1567 pp_string (buffer, "; ");
1569 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1570 flags, false);
1571 pp_string (buffer, " = ");
1572 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1573 flags, false);
1574 pp_right_paren (buffer);
1577 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1579 newline_and_indent (buffer, spc + 2);
1580 pp_left_brace (buffer);
1581 pp_newline (buffer);
1582 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1583 newline_and_indent (buffer, spc + 2);
1584 pp_right_brace (buffer);
1589 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1591 static void
1592 dump_gimple_omp_continue (pretty_printer *buffer, const gomp_continue *gs,
1593 int spc, dump_flags_t flags)
1595 if (flags & TDF_RAW)
1597 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1598 gimple_omp_continue_control_def (gs),
1599 gimple_omp_continue_control_use (gs));
1601 else
1603 pp_string (buffer, "#pragma omp continue (");
1604 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1605 spc, flags, false);
1606 pp_comma (buffer);
1607 pp_space (buffer);
1608 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1609 spc, flags, false);
1610 pp_right_paren (buffer);
1614 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1616 static void
1617 dump_gimple_omp_single (pretty_printer *buffer, const gomp_single *gs,
1618 int spc, dump_flags_t flags)
1620 if (flags & TDF_RAW)
1622 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1623 gimple_omp_body (gs));
1624 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1625 dump_gimple_fmt (buffer, spc, flags, " >");
1627 else
1629 pp_string (buffer, "#pragma omp single");
1630 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1631 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1633 newline_and_indent (buffer, spc + 2);
1634 pp_left_brace (buffer);
1635 pp_newline (buffer);
1636 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1637 newline_and_indent (buffer, spc + 2);
1638 pp_right_brace (buffer);
1643 /* Dump a GIMPLE_OMP_TASKGROUP tuple on the pretty_printer BUFFER. */
1645 static void
1646 dump_gimple_omp_taskgroup (pretty_printer *buffer, const gimple *gs,
1647 int spc, dump_flags_t flags)
1649 if (flags & TDF_RAW)
1651 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1652 gimple_omp_body (gs));
1653 dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
1654 dump_gimple_fmt (buffer, spc, flags, " >");
1656 else
1658 pp_string (buffer, "#pragma omp taskgroup");
1659 dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
1660 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1662 newline_and_indent (buffer, spc + 2);
1663 pp_left_brace (buffer);
1664 pp_newline (buffer);
1665 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1666 newline_and_indent (buffer, spc + 2);
1667 pp_right_brace (buffer);
1672 /* Dump a GIMPLE_OMP_MASKED tuple on the pretty_printer BUFFER. */
1674 static void
1675 dump_gimple_omp_masked (pretty_printer *buffer, const gimple *gs,
1676 int spc, dump_flags_t flags)
1678 if (flags & TDF_RAW)
1680 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1681 gimple_omp_body (gs));
1682 dump_omp_clauses (buffer, gimple_omp_masked_clauses (gs), spc, flags);
1683 dump_gimple_fmt (buffer, spc, flags, " >");
1685 else
1687 pp_string (buffer, "#pragma omp masked");
1688 dump_omp_clauses (buffer, gimple_omp_masked_clauses (gs), spc, flags);
1689 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1691 newline_and_indent (buffer, spc + 2);
1692 pp_left_brace (buffer);
1693 pp_newline (buffer);
1694 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1695 newline_and_indent (buffer, spc + 2);
1696 pp_right_brace (buffer);
1701 /* Dump a GIMPLE_OMP_SCOPE tuple on the pretty_printer BUFFER. */
1703 static void
1704 dump_gimple_omp_scope (pretty_printer *buffer, const gimple *gs,
1705 int spc, dump_flags_t flags)
1707 if (flags & TDF_RAW)
1709 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1710 gimple_omp_body (gs));
1711 dump_omp_clauses (buffer, gimple_omp_scope_clauses (gs), spc, flags);
1712 dump_gimple_fmt (buffer, spc, flags, " >");
1714 else
1716 pp_string (buffer, "#pragma omp scope");
1717 dump_omp_clauses (buffer, gimple_omp_scope_clauses (gs), spc, flags);
1718 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1720 newline_and_indent (buffer, spc + 2);
1721 pp_left_brace (buffer);
1722 pp_newline (buffer);
1723 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1724 newline_and_indent (buffer, spc + 2);
1725 pp_right_brace (buffer);
1730 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1732 static void
1733 dump_gimple_omp_target (pretty_printer *buffer, const gomp_target *gs,
1734 int spc, dump_flags_t flags)
1736 const char *kind;
1737 switch (gimple_omp_target_kind (gs))
1739 case GF_OMP_TARGET_KIND_REGION:
1740 kind = "";
1741 break;
1742 case GF_OMP_TARGET_KIND_DATA:
1743 kind = " data";
1744 break;
1745 case GF_OMP_TARGET_KIND_UPDATE:
1746 kind = " update";
1747 break;
1748 case GF_OMP_TARGET_KIND_ENTER_DATA:
1749 kind = " enter data";
1750 break;
1751 case GF_OMP_TARGET_KIND_EXIT_DATA:
1752 kind = " exit data";
1753 break;
1754 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1755 kind = " oacc_kernels";
1756 break;
1757 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1758 kind = " oacc_parallel";
1759 break;
1760 case GF_OMP_TARGET_KIND_OACC_SERIAL:
1761 kind = " oacc_serial";
1762 break;
1763 case GF_OMP_TARGET_KIND_OACC_DATA:
1764 kind = " oacc_data";
1765 break;
1766 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1767 kind = " oacc_update";
1768 break;
1769 case GF_OMP_TARGET_KIND_OACC_ENTER_DATA:
1770 kind = " oacc_enter_data";
1771 break;
1772 case GF_OMP_TARGET_KIND_OACC_EXIT_DATA:
1773 kind = " oacc_exit_data";
1774 break;
1775 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1776 kind = " oacc_declare";
1777 break;
1778 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1779 kind = " oacc_host_data";
1780 break;
1781 case GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_PARALLELIZED:
1782 kind = " oacc_parallel_kernels_parallelized";
1783 break;
1784 case GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_GANG_SINGLE:
1785 kind = " oacc_parallel_kernels_gang_single";
1786 break;
1787 case GF_OMP_TARGET_KIND_OACC_DATA_KERNELS:
1788 kind = " oacc_data_kernels";
1789 break;
1790 default:
1791 gcc_unreachable ();
1793 if (flags & TDF_RAW)
1795 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1796 kind, gimple_omp_body (gs));
1797 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1798 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1799 gimple_omp_target_child_fn (gs),
1800 gimple_omp_target_data_arg (gs));
1802 else
1804 pp_string (buffer, "#pragma omp target");
1805 pp_string (buffer, kind);
1806 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1807 if (gimple_omp_target_child_fn (gs))
1809 pp_string (buffer, " [child fn: ");
1810 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1811 spc, flags, false);
1812 pp_string (buffer, " (");
1813 if (gimple_omp_target_data_arg (gs))
1814 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1815 spc, flags, false);
1816 else
1817 pp_string (buffer, "???");
1818 pp_string (buffer, ")]");
1820 gimple_seq body = gimple_omp_body (gs);
1821 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1823 newline_and_indent (buffer, spc + 2);
1824 pp_left_brace (buffer);
1825 pp_newline (buffer);
1826 dump_gimple_seq (buffer, body, spc + 4, flags);
1827 newline_and_indent (buffer, spc + 2);
1828 pp_right_brace (buffer);
1830 else if (body)
1832 pp_newline (buffer);
1833 dump_gimple_seq (buffer, body, spc + 2, flags);
1838 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1840 static void
1841 dump_gimple_omp_teams (pretty_printer *buffer, const gomp_teams *gs, int spc,
1842 dump_flags_t flags)
1844 if (flags & TDF_RAW)
1846 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1847 gimple_omp_body (gs));
1848 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1849 dump_gimple_fmt (buffer, spc, flags, " >");
1851 else
1853 pp_string (buffer, "#pragma omp teams");
1854 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1855 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1857 newline_and_indent (buffer, spc + 2);
1858 pp_character (buffer, '{');
1859 pp_newline (buffer);
1860 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1861 newline_and_indent (buffer, spc + 2);
1862 pp_character (buffer, '}');
1867 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1869 static void
1870 dump_gimple_omp_sections (pretty_printer *buffer, const gomp_sections *gs,
1871 int spc, dump_flags_t flags)
1873 if (flags & TDF_RAW)
1875 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1876 gimple_omp_body (gs));
1877 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1878 dump_gimple_fmt (buffer, spc, flags, " >");
1880 else
1882 pp_string (buffer, "#pragma omp sections");
1883 if (gimple_omp_sections_control (gs))
1885 pp_string (buffer, " <");
1886 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1887 flags, false);
1888 pp_greater (buffer);
1890 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1891 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1893 newline_and_indent (buffer, spc + 2);
1894 pp_left_brace (buffer);
1895 pp_newline (buffer);
1896 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1897 newline_and_indent (buffer, spc + 2);
1898 pp_right_brace (buffer);
1903 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the
1904 pretty_printer BUFFER. */
1906 static void
1907 dump_gimple_omp_block (pretty_printer *buffer, const gimple *gs, int spc,
1908 dump_flags_t flags)
1910 if (flags & TDF_RAW)
1911 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1912 gimple_omp_body (gs));
1913 else
1915 switch (gimple_code (gs))
1917 case GIMPLE_OMP_MASTER:
1918 pp_string (buffer, "#pragma omp master");
1919 break;
1920 case GIMPLE_OMP_SECTION:
1921 pp_string (buffer, "#pragma omp section");
1922 break;
1923 default:
1924 gcc_unreachable ();
1926 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1928 newline_and_indent (buffer, spc + 2);
1929 pp_left_brace (buffer);
1930 pp_newline (buffer);
1931 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1932 newline_and_indent (buffer, spc + 2);
1933 pp_right_brace (buffer);
1938 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1940 static void
1941 dump_gimple_omp_critical (pretty_printer *buffer, const gomp_critical *gs,
1942 int spc, dump_flags_t flags)
1944 if (flags & TDF_RAW)
1945 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1946 gimple_omp_body (gs));
1947 else
1949 pp_string (buffer, "#pragma omp critical");
1950 if (gimple_omp_critical_name (gs))
1952 pp_string (buffer, " (");
1953 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1954 flags, false);
1955 pp_right_paren (buffer);
1957 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1958 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1960 newline_and_indent (buffer, spc + 2);
1961 pp_left_brace (buffer);
1962 pp_newline (buffer);
1963 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1964 newline_and_indent (buffer, spc + 2);
1965 pp_right_brace (buffer);
1970 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1972 static void
1973 dump_gimple_omp_ordered (pretty_printer *buffer, const gomp_ordered *gs,
1974 int spc, dump_flags_t flags)
1976 if (flags & TDF_RAW)
1977 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1978 gimple_omp_body (gs));
1979 else
1981 pp_string (buffer, "#pragma omp ordered");
1982 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1983 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1985 newline_and_indent (buffer, spc + 2);
1986 pp_left_brace (buffer);
1987 pp_newline (buffer);
1988 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1989 newline_and_indent (buffer, spc + 2);
1990 pp_right_brace (buffer);
1995 /* Dump a GIMPLE_OMP_SCAN tuple on the pretty_printer BUFFER. */
1997 static void
1998 dump_gimple_omp_scan (pretty_printer *buffer, const gomp_scan *gs,
1999 int spc, dump_flags_t flags)
2001 if (flags & TDF_RAW)
2002 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
2003 gimple_omp_body (gs));
2004 else
2006 if (gimple_omp_scan_clauses (gs))
2008 pp_string (buffer, "#pragma omp scan");
2009 dump_omp_clauses (buffer, gimple_omp_scan_clauses (gs), spc, flags);
2011 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
2013 newline_and_indent (buffer, spc + 2);
2014 pp_left_brace (buffer);
2015 pp_newline (buffer);
2016 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
2017 newline_and_indent (buffer, spc + 2);
2018 pp_right_brace (buffer);
2023 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
2025 static void
2026 dump_gimple_omp_return (pretty_printer *buffer, const gimple *gs, int spc,
2027 dump_flags_t flags)
2029 if (flags & TDF_RAW)
2031 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
2032 (int) gimple_omp_return_nowait_p (gs));
2033 if (gimple_omp_return_lhs (gs))
2034 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
2035 gimple_omp_return_lhs (gs));
2036 else
2037 dump_gimple_fmt (buffer, spc, flags, ">");
2039 else
2041 pp_string (buffer, "#pragma omp return");
2042 if (gimple_omp_return_nowait_p (gs))
2043 pp_string (buffer, "(nowait)");
2044 if (gimple_omp_return_lhs (gs))
2046 pp_string (buffer, " (set ");
2047 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
2048 spc, flags, false);
2049 pp_character (buffer, ')');
2054 /* Dump a GIMPLE_ASSUME tuple on the pretty_printer BUFFER. */
2056 static void
2057 dump_gimple_assume (pretty_printer *buffer, const gimple *gs,
2058 int spc, dump_flags_t flags)
2060 if (flags & TDF_RAW)
2061 dump_gimple_fmt (buffer, spc, flags,
2062 "%G [GUARD=%T] <%+BODY <%S> >",
2063 gs, gimple_assume_guard (gs),
2064 gimple_assume_body (gs));
2065 else
2067 pp_string (buffer, "[[assume (");
2068 dump_generic_node (buffer, gimple_assume_guard (gs), spc, flags, false);
2069 pp_string (buffer, ")]]");
2070 newline_and_indent (buffer, spc + 2);
2071 pp_left_brace (buffer);
2072 pp_newline (buffer);
2073 dump_gimple_seq (buffer, gimple_assume_body (gs), spc + 4, flags);
2074 newline_and_indent (buffer, spc + 2);
2075 pp_right_brace (buffer);
2079 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
2081 static void
2082 dump_gimple_transaction (pretty_printer *buffer, const gtransaction *gs,
2083 int spc, dump_flags_t flags)
2085 unsigned subcode = gimple_transaction_subcode (gs);
2087 if (flags & TDF_RAW)
2089 dump_gimple_fmt (buffer, spc, flags,
2090 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
2091 "<%+BODY <%S> >",
2092 gs, subcode, gimple_transaction_label_norm (gs),
2093 gimple_transaction_label_uninst (gs),
2094 gimple_transaction_label_over (gs),
2095 gimple_transaction_body (gs));
2097 else
2099 if (subcode & GTMA_IS_OUTER)
2100 pp_string (buffer, "__transaction_atomic [[outer]]");
2101 else if (subcode & GTMA_IS_RELAXED)
2102 pp_string (buffer, "__transaction_relaxed");
2103 else
2104 pp_string (buffer, "__transaction_atomic");
2105 subcode &= ~GTMA_DECLARATION_MASK;
2107 if (gimple_transaction_body (gs))
2109 newline_and_indent (buffer, spc + 2);
2110 pp_left_brace (buffer);
2111 pp_newline (buffer);
2112 dump_gimple_seq (buffer, gimple_transaction_body (gs),
2113 spc + 4, flags);
2114 newline_and_indent (buffer, spc + 2);
2115 pp_right_brace (buffer);
2117 else
2119 pp_string (buffer, " //");
2120 if (gimple_transaction_label_norm (gs))
2122 pp_string (buffer, " NORM=");
2123 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
2124 spc, flags, false);
2126 if (gimple_transaction_label_uninst (gs))
2128 pp_string (buffer, " UNINST=");
2129 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
2130 spc, flags, false);
2132 if (gimple_transaction_label_over (gs))
2134 pp_string (buffer, " OVER=");
2135 dump_generic_node (buffer, gimple_transaction_label_over (gs),
2136 spc, flags, false);
2138 if (subcode)
2140 pp_string (buffer, " SUBCODE=[ ");
2141 if (subcode & GTMA_HAVE_ABORT)
2143 pp_string (buffer, "GTMA_HAVE_ABORT ");
2144 subcode &= ~GTMA_HAVE_ABORT;
2146 if (subcode & GTMA_HAVE_LOAD)
2148 pp_string (buffer, "GTMA_HAVE_LOAD ");
2149 subcode &= ~GTMA_HAVE_LOAD;
2151 if (subcode & GTMA_HAVE_STORE)
2153 pp_string (buffer, "GTMA_HAVE_STORE ");
2154 subcode &= ~GTMA_HAVE_STORE;
2156 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
2158 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
2159 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
2161 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
2163 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
2164 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
2166 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
2168 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
2169 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
2171 if (subcode)
2172 pp_printf (buffer, "0x%x ", subcode);
2173 pp_right_bracket (buffer);
2179 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
2180 indent. FLAGS specifies details to show in the dump (see TDF_* in
2181 dumpfile.h). */
2183 static void
2184 dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc,
2185 dump_flags_t flags)
2187 unsigned int i, n, f, fields;
2189 if (flags & TDF_RAW)
2191 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
2192 gimple_asm_string (gs));
2194 n = gimple_asm_noutputs (gs);
2195 if (n)
2197 newline_and_indent (buffer, spc + 2);
2198 pp_string (buffer, "OUTPUT: ");
2199 for (i = 0; i < n; i++)
2201 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2202 spc, flags, false);
2203 if (i < n - 1)
2204 pp_string (buffer, ", ");
2208 n = gimple_asm_ninputs (gs);
2209 if (n)
2211 newline_and_indent (buffer, spc + 2);
2212 pp_string (buffer, "INPUT: ");
2213 for (i = 0; i < n; i++)
2215 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2216 spc, flags, false);
2217 if (i < n - 1)
2218 pp_string (buffer, ", ");
2222 n = gimple_asm_nclobbers (gs);
2223 if (n)
2225 newline_and_indent (buffer, spc + 2);
2226 pp_string (buffer, "CLOBBER: ");
2227 for (i = 0; i < n; i++)
2229 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2230 spc, flags, false);
2231 if (i < n - 1)
2232 pp_string (buffer, ", ");
2236 n = gimple_asm_nlabels (gs);
2237 if (n)
2239 newline_and_indent (buffer, spc + 2);
2240 pp_string (buffer, "LABEL: ");
2241 for (i = 0; i < n; i++)
2243 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2244 spc, flags, false);
2245 if (i < n - 1)
2246 pp_string (buffer, ", ");
2250 newline_and_indent (buffer, spc);
2251 pp_greater (buffer);
2253 else
2255 pp_string (buffer, "__asm__");
2256 if (gimple_asm_volatile_p (gs))
2257 pp_string (buffer, " __volatile__");
2258 if (gimple_asm_inline_p (gs))
2259 pp_string (buffer, " __inline__");
2260 if (gimple_asm_nlabels (gs))
2261 pp_string (buffer, " goto");
2262 pp_string (buffer, "(\"");
2263 pp_string (buffer, gimple_asm_string (gs));
2264 pp_string (buffer, "\"");
2266 if (gimple_asm_nlabels (gs))
2267 fields = 4;
2268 else if (gimple_asm_nclobbers (gs))
2269 fields = 3;
2270 else if (gimple_asm_ninputs (gs))
2271 fields = 2;
2272 else if (gimple_asm_noutputs (gs))
2273 fields = 1;
2274 else
2275 fields = 0;
2277 for (f = 0; f < fields; ++f)
2279 pp_string (buffer, " : ");
2281 switch (f)
2283 case 0:
2284 n = gimple_asm_noutputs (gs);
2285 for (i = 0; i < n; i++)
2287 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2288 spc, flags, false);
2289 if (i < n - 1)
2290 pp_string (buffer, ", ");
2292 break;
2294 case 1:
2295 n = gimple_asm_ninputs (gs);
2296 for (i = 0; i < n; i++)
2298 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2299 spc, flags, false);
2300 if (i < n - 1)
2301 pp_string (buffer, ", ");
2303 break;
2305 case 2:
2306 n = gimple_asm_nclobbers (gs);
2307 for (i = 0; i < n; i++)
2309 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2310 spc, flags, false);
2311 if (i < n - 1)
2312 pp_string (buffer, ", ");
2314 break;
2316 case 3:
2317 n = gimple_asm_nlabels (gs);
2318 for (i = 0; i < n; i++)
2320 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2321 spc, flags, false);
2322 if (i < n - 1)
2323 pp_string (buffer, ", ");
2325 break;
2327 default:
2328 gcc_unreachable ();
2332 pp_string (buffer, ");");
2336 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2337 SPC spaces of indent. */
2339 static void
2340 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2342 if (TREE_CODE (node) != SSA_NAME)
2343 return;
2345 if (POINTER_TYPE_P (TREE_TYPE (node))
2346 && SSA_NAME_PTR_INFO (node))
2348 unsigned int align, misalign;
2349 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2350 pp_string (buffer, "# PT = ");
2351 pp_points_to_solution (buffer, &pi->pt);
2352 newline_and_indent (buffer, spc);
2353 if (get_ptr_info_alignment (pi, &align, &misalign))
2355 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2356 newline_and_indent (buffer, spc);
2360 if (!POINTER_TYPE_P (TREE_TYPE (node))
2361 && SSA_NAME_RANGE_INFO (node))
2363 Value_Range r (TREE_TYPE (node));
2364 get_global_range_query ()->range_of_expr (r, node);
2365 pp_string (buffer, "# RANGE ");
2366 pp_vrange (buffer, &r);
2367 newline_and_indent (buffer, spc);
2371 /* As dump_ssaname_info, but dump to FILE. */
2373 void
2374 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2376 pretty_printer buffer;
2377 pp_needs_newline (&buffer) = true;
2378 buffer.buffer->stream = file;
2379 dump_ssaname_info (&buffer, node, spc);
2380 pp_flush (&buffer);
2383 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2384 The caller is responsible for calling pp_flush on BUFFER to finalize
2385 pretty printer. If COMMENT is true, print this after #. */
2387 static void
2388 dump_gimple_phi (pretty_printer *buffer, const gphi *phi, int spc, bool comment,
2389 dump_flags_t flags)
2391 size_t i;
2392 tree lhs = gimple_phi_result (phi);
2394 if (flags & TDF_ALIAS)
2395 dump_ssaname_info (buffer, lhs, spc);
2397 if (comment)
2398 pp_string (buffer, "# ");
2400 if (flags & TDF_RAW)
2401 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2402 gimple_phi_result (phi));
2403 else
2405 dump_generic_node (buffer, lhs, spc, flags, false);
2406 if (flags & TDF_GIMPLE)
2407 pp_string (buffer, " = __PHI (");
2408 else
2409 pp_string (buffer, " = PHI <");
2411 for (i = 0; i < gimple_phi_num_args (phi); i++)
2413 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2414 dump_location (buffer, gimple_phi_arg_location (phi, i));
2415 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2416 if (flags & TDF_GIMPLE)
2418 pp_string (buffer, "__BB");
2419 pp_decimal_int (buffer, src->index);
2420 pp_string (buffer, ": ");
2422 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2423 false);
2424 if (! (flags & TDF_GIMPLE))
2426 pp_left_paren (buffer);
2427 pp_decimal_int (buffer, src->index);
2428 pp_right_paren (buffer);
2430 if (i < gimple_phi_num_args (phi) - 1)
2431 pp_string (buffer, ", ");
2433 if (flags & TDF_GIMPLE)
2434 pp_string (buffer, ");");
2435 else
2436 pp_greater (buffer);
2440 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2441 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2442 dumpfile.h). */
2444 static void
2445 dump_gimple_omp_parallel (pretty_printer *buffer, const gomp_parallel *gs,
2446 int spc, dump_flags_t flags)
2448 if (flags & TDF_RAW)
2450 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2451 gimple_omp_body (gs));
2452 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2453 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2454 gimple_omp_parallel_child_fn (gs),
2455 gimple_omp_parallel_data_arg (gs));
2457 else
2459 gimple_seq body;
2460 pp_string (buffer, "#pragma omp parallel");
2461 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2462 if (gimple_omp_parallel_child_fn (gs))
2464 pp_string (buffer, " [child fn: ");
2465 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2466 spc, flags, false);
2467 pp_string (buffer, " (");
2468 if (gimple_omp_parallel_data_arg (gs))
2469 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2470 spc, flags, false);
2471 else
2472 pp_string (buffer, "???");
2473 pp_string (buffer, ")]");
2475 body = gimple_omp_body (gs);
2476 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2478 newline_and_indent (buffer, spc + 2);
2479 pp_left_brace (buffer);
2480 pp_newline (buffer);
2481 dump_gimple_seq (buffer, body, spc + 4, flags);
2482 newline_and_indent (buffer, spc + 2);
2483 pp_right_brace (buffer);
2485 else if (body)
2487 pp_newline (buffer);
2488 dump_gimple_seq (buffer, body, spc + 2, flags);
2494 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2495 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2496 dumpfile.h). */
2498 static void
2499 dump_gimple_omp_task (pretty_printer *buffer, const gomp_task *gs, int spc,
2500 dump_flags_t flags)
2502 if (flags & TDF_RAW)
2504 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2505 gimple_omp_body (gs));
2506 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2507 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2508 gimple_omp_task_child_fn (gs),
2509 gimple_omp_task_data_arg (gs),
2510 gimple_omp_task_copy_fn (gs),
2511 gimple_omp_task_arg_size (gs),
2512 gimple_omp_task_arg_size (gs));
2514 else
2516 gimple_seq body;
2517 if (gimple_omp_task_taskloop_p (gs))
2518 pp_string (buffer, "#pragma omp taskloop");
2519 else if (gimple_omp_task_taskwait_p (gs))
2520 pp_string (buffer, "#pragma omp taskwait");
2521 else
2522 pp_string (buffer, "#pragma omp task");
2523 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2524 if (gimple_omp_task_child_fn (gs))
2526 pp_string (buffer, " [child fn: ");
2527 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2528 spc, flags, false);
2529 pp_string (buffer, " (");
2530 if (gimple_omp_task_data_arg (gs))
2531 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2532 spc, flags, false);
2533 else
2534 pp_string (buffer, "???");
2535 pp_string (buffer, ")]");
2537 body = gimple_omp_body (gs);
2538 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2540 newline_and_indent (buffer, spc + 2);
2541 pp_left_brace (buffer);
2542 pp_newline (buffer);
2543 dump_gimple_seq (buffer, body, spc + 4, flags);
2544 newline_and_indent (buffer, spc + 2);
2545 pp_right_brace (buffer);
2547 else if (body)
2549 pp_newline (buffer);
2550 dump_gimple_seq (buffer, body, spc + 2, flags);
2556 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2557 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2558 in dumpfile.h). */
2560 static void
2561 dump_gimple_omp_atomic_load (pretty_printer *buffer, const gomp_atomic_load *gs,
2562 int spc, dump_flags_t flags)
2564 if (flags & TDF_RAW)
2566 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2567 gimple_omp_atomic_load_lhs (gs),
2568 gimple_omp_atomic_load_rhs (gs));
2570 else
2572 pp_string (buffer, "#pragma omp atomic_load");
2573 dump_omp_atomic_memory_order (buffer,
2574 gimple_omp_atomic_memory_order (gs));
2575 if (gimple_omp_atomic_need_value_p (gs))
2576 pp_string (buffer, " [needed]");
2577 if (gimple_omp_atomic_weak_p (gs))
2578 pp_string (buffer, " [weak]");
2579 newline_and_indent (buffer, spc + 2);
2580 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2581 spc, flags, false);
2582 pp_space (buffer);
2583 pp_equal (buffer);
2584 pp_space (buffer);
2585 pp_star (buffer);
2586 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2587 spc, flags, false);
2591 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2592 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2593 in dumpfile.h). */
2595 static void
2596 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2597 const gomp_atomic_store *gs, int spc,
2598 dump_flags_t flags)
2600 if (flags & TDF_RAW)
2602 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2603 gimple_omp_atomic_store_val (gs));
2605 else
2607 pp_string (buffer, "#pragma omp atomic_store");
2608 dump_omp_atomic_memory_order (buffer,
2609 gimple_omp_atomic_memory_order (gs));
2610 pp_space (buffer);
2611 if (gimple_omp_atomic_need_value_p (gs))
2612 pp_string (buffer, "[needed] ");
2613 if (gimple_omp_atomic_weak_p (gs))
2614 pp_string (buffer, "[weak] ");
2615 pp_left_paren (buffer);
2616 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2617 spc, flags, false);
2618 pp_right_paren (buffer);
2623 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2624 FLAGS are as in pp_gimple_stmt_1. */
2626 static void
2627 dump_gimple_mem_ops (pretty_printer *buffer, const gimple *gs, int spc,
2628 dump_flags_t flags)
2630 tree vdef = gimple_vdef (gs);
2631 tree vuse = gimple_vuse (gs);
2633 if (vdef != NULL_TREE)
2635 pp_string (buffer, "# ");
2636 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2637 pp_string (buffer, " = VDEF <");
2638 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2639 pp_greater (buffer);
2640 newline_and_indent (buffer, spc);
2642 else if (vuse != NULL_TREE)
2644 pp_string (buffer, "# VUSE <");
2645 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2646 pp_greater (buffer);
2647 newline_and_indent (buffer, spc);
2652 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2653 spaces of indent. FLAGS specifies details to show in the dump (see
2654 TDF_* in dumpfile.h). The caller is responsible for calling
2655 pp_flush on BUFFER to finalize the pretty printer. */
2657 void
2658 pp_gimple_stmt_1 (pretty_printer *buffer, const gimple *gs, int spc,
2659 dump_flags_t flags)
2661 if (!gs)
2662 return;
2664 if (flags & TDF_STMTADDR)
2665 pp_printf (buffer, "<&%p> ", (const void *) gs);
2667 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2668 dump_location (buffer, gimple_location (gs));
2670 if (flags & TDF_EH)
2672 int lp_nr = lookup_stmt_eh_lp (gs);
2673 if (lp_nr > 0)
2674 pp_printf (buffer, "[LP %d] ", lp_nr);
2675 else if (lp_nr < 0)
2676 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2679 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2680 && gimple_has_mem_ops (gs))
2681 dump_gimple_mem_ops (buffer, gs, spc, flags);
2683 if (gimple_has_lhs (gs)
2684 && (flags & TDF_ALIAS))
2685 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2687 switch (gimple_code (gs))
2689 case GIMPLE_ASM:
2690 dump_gimple_asm (buffer, as_a <const gasm *> (gs), spc, flags);
2691 break;
2693 case GIMPLE_ASSIGN:
2694 dump_gimple_assign (buffer, as_a <const gassign *> (gs), spc, flags);
2695 break;
2697 case GIMPLE_BIND:
2698 dump_gimple_bind (buffer, as_a <const gbind *> (gs), spc, flags);
2699 break;
2701 case GIMPLE_CALL:
2702 dump_gimple_call (buffer, as_a <const gcall *> (gs), spc, flags);
2703 break;
2705 case GIMPLE_COND:
2706 dump_gimple_cond (buffer, as_a <const gcond *> (gs), spc, flags);
2707 break;
2709 case GIMPLE_LABEL:
2710 dump_gimple_label (buffer, as_a <const glabel *> (gs), spc, flags);
2711 break;
2713 case GIMPLE_GOTO:
2714 dump_gimple_goto (buffer, as_a <const ggoto *> (gs), spc, flags);
2715 break;
2717 case GIMPLE_NOP:
2718 pp_string (buffer, "GIMPLE_NOP");
2719 break;
2721 case GIMPLE_RETURN:
2722 dump_gimple_return (buffer, as_a <const greturn *> (gs), spc, flags);
2723 break;
2725 case GIMPLE_SWITCH:
2726 dump_gimple_switch (buffer, as_a <const gswitch *> (gs), spc, flags);
2727 break;
2729 case GIMPLE_TRY:
2730 dump_gimple_try (buffer, as_a <const gtry *> (gs), spc, flags);
2731 break;
2733 case GIMPLE_PHI:
2734 dump_gimple_phi (buffer, as_a <const gphi *> (gs), spc, false, flags);
2735 break;
2737 case GIMPLE_OMP_PARALLEL:
2738 dump_gimple_omp_parallel (buffer, as_a <const gomp_parallel *> (gs), spc,
2739 flags);
2740 break;
2742 case GIMPLE_OMP_TASK:
2743 dump_gimple_omp_task (buffer, as_a <const gomp_task *> (gs), spc, flags);
2744 break;
2746 case GIMPLE_OMP_ATOMIC_LOAD:
2747 dump_gimple_omp_atomic_load (buffer, as_a <const gomp_atomic_load *> (gs),
2748 spc, flags);
2749 break;
2751 case GIMPLE_OMP_ATOMIC_STORE:
2752 dump_gimple_omp_atomic_store (buffer,
2753 as_a <const gomp_atomic_store *> (gs),
2754 spc, flags);
2755 break;
2757 case GIMPLE_OMP_FOR:
2758 dump_gimple_omp_for (buffer, as_a <const gomp_for *> (gs), spc, flags);
2759 break;
2761 case GIMPLE_OMP_CONTINUE:
2762 dump_gimple_omp_continue (buffer, as_a <const gomp_continue *> (gs), spc,
2763 flags);
2764 break;
2766 case GIMPLE_OMP_SINGLE:
2767 dump_gimple_omp_single (buffer, as_a <const gomp_single *> (gs), spc,
2768 flags);
2769 break;
2771 case GIMPLE_OMP_TARGET:
2772 dump_gimple_omp_target (buffer, as_a <const gomp_target *> (gs), spc,
2773 flags);
2774 break;
2776 case GIMPLE_OMP_TEAMS:
2777 dump_gimple_omp_teams (buffer, as_a <const gomp_teams *> (gs), spc,
2778 flags);
2779 break;
2781 case GIMPLE_OMP_RETURN:
2782 dump_gimple_omp_return (buffer, gs, spc, flags);
2783 break;
2785 case GIMPLE_OMP_SECTIONS:
2786 dump_gimple_omp_sections (buffer, as_a <const gomp_sections *> (gs),
2787 spc, flags);
2788 break;
2790 case GIMPLE_OMP_SECTIONS_SWITCH:
2791 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2792 break;
2794 case GIMPLE_OMP_TASKGROUP:
2795 dump_gimple_omp_taskgroup (buffer, gs, spc, flags);
2796 break;
2798 case GIMPLE_OMP_MASKED:
2799 dump_gimple_omp_masked (buffer, gs, spc, flags);
2800 break;
2802 case GIMPLE_OMP_SCOPE:
2803 dump_gimple_omp_scope (buffer, gs, spc, flags);
2804 break;
2806 case GIMPLE_OMP_MASTER:
2807 case GIMPLE_OMP_SECTION:
2808 dump_gimple_omp_block (buffer, gs, spc, flags);
2809 break;
2811 case GIMPLE_OMP_ORDERED:
2812 dump_gimple_omp_ordered (buffer, as_a <const gomp_ordered *> (gs), spc,
2813 flags);
2814 break;
2816 case GIMPLE_OMP_SCAN:
2817 dump_gimple_omp_scan (buffer, as_a <const gomp_scan *> (gs), spc,
2818 flags);
2819 break;
2821 case GIMPLE_OMP_CRITICAL:
2822 dump_gimple_omp_critical (buffer, as_a <const gomp_critical *> (gs), spc,
2823 flags);
2824 break;
2826 case GIMPLE_CATCH:
2827 dump_gimple_catch (buffer, as_a <const gcatch *> (gs), spc, flags);
2828 break;
2830 case GIMPLE_EH_FILTER:
2831 dump_gimple_eh_filter (buffer, as_a <const geh_filter *> (gs), spc,
2832 flags);
2833 break;
2835 case GIMPLE_EH_MUST_NOT_THROW:
2836 dump_gimple_eh_must_not_throw (buffer,
2837 as_a <const geh_mnt *> (gs),
2838 spc, flags);
2839 break;
2841 case GIMPLE_EH_ELSE:
2842 dump_gimple_eh_else (buffer, as_a <const geh_else *> (gs), spc, flags);
2843 break;
2845 case GIMPLE_RESX:
2846 dump_gimple_resx (buffer, as_a <const gresx *> (gs), spc, flags);
2847 break;
2849 case GIMPLE_EH_DISPATCH:
2850 dump_gimple_eh_dispatch (buffer, as_a <const geh_dispatch *> (gs), spc,
2851 flags);
2852 break;
2854 case GIMPLE_DEBUG:
2855 dump_gimple_debug (buffer, as_a <const gdebug *> (gs), spc, flags);
2856 break;
2858 case GIMPLE_PREDICT:
2859 pp_string (buffer, "// predicted ");
2860 if (gimple_predict_outcome (gs))
2861 pp_string (buffer, "likely by ");
2862 else
2863 pp_string (buffer, "unlikely by ");
2864 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2865 pp_string (buffer, " predictor.");
2866 break;
2868 case GIMPLE_ASSUME:
2869 dump_gimple_assume (buffer, gs, spc, flags);
2870 break;
2872 case GIMPLE_TRANSACTION:
2873 dump_gimple_transaction (buffer, as_a <const gtransaction *> (gs), spc,
2874 flags);
2875 break;
2877 default:
2878 GIMPLE_NIY;
2883 /* Dumps header of basic block BB to OUTF indented by INDENT
2884 spaces and details described by flags. */
2886 static void
2887 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
2888 dump_flags_t flags)
2890 if (flags & TDF_BLOCKS)
2892 if (flags & TDF_LINENO)
2894 gimple_stmt_iterator gsi;
2896 fputs (";; ", outf);
2898 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2899 if (!is_gimple_debug (gsi_stmt (gsi))
2900 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2902 fprintf (outf, "%*sstarting at line %d",
2903 indent, "", get_lineno (gsi_stmt (gsi)));
2904 break;
2906 fputc ('\n', outf);
2909 else
2911 if (flags & TDF_GIMPLE)
2913 fprintf (outf, "%*s__BB(%d", indent, "", bb->index);
2914 if (bb->loop_father->header == bb)
2915 fprintf (outf, ",loop_header(%d)", bb->loop_father->num);
2916 if (bb->count.initialized_p ())
2917 fprintf (outf, ",%s(%" PRIu64 ")",
2918 profile_quality_as_string (bb->count.quality ()),
2919 bb->count.value ());
2920 fprintf (outf, "):\n");
2922 else
2923 fprintf (outf, "%*s<bb %d> %s:\n",
2924 indent, "", bb->index, dump_profile (bb->count));
2929 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2930 spaces. */
2932 static void
2933 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2934 basic_block bb ATTRIBUTE_UNUSED,
2935 int indent ATTRIBUTE_UNUSED,
2936 dump_flags_t flags ATTRIBUTE_UNUSED)
2938 /* There is currently no GIMPLE-specific basic block info to dump. */
2939 return;
2943 /* Dump PHI nodes of basic block BB to BUFFER with details described
2944 by FLAGS and indented by INDENT spaces. */
2946 static void
2947 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
2948 dump_flags_t flags)
2950 gphi_iterator i;
2952 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2954 gphi *phi = i.phi ();
2955 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2957 INDENT (indent);
2958 dump_gimple_phi (buffer, phi, indent,
2959 (flags & TDF_GIMPLE) ? false : true, flags);
2960 pp_newline (buffer);
2966 /* Dump jump to basic block BB that is represented implicitly in the cfg
2967 to BUFFER. */
2969 static void
2970 pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
2972 if (flags & TDF_GIMPLE)
2974 pp_string (buffer, "goto __BB");
2975 pp_decimal_int (buffer, e->dest->index);
2976 if (e->probability.initialized_p ())
2978 pp_string (buffer, "(");
2979 pp_string (buffer,
2980 profile_quality_as_string (e->probability.quality ()));
2981 pp_string (buffer, "(");
2982 pp_decimal_int (buffer, e->probability.value ());
2983 pp_string (buffer, "))");
2985 pp_semicolon (buffer);
2987 else
2989 pp_string (buffer, "goto <bb ");
2990 pp_decimal_int (buffer, e->dest->index);
2991 pp_greater (buffer);
2992 pp_semicolon (buffer);
2994 dump_edge_probability (buffer, e);
2999 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
3000 by INDENT spaces, with details given by FLAGS. */
3002 static void
3003 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
3004 dump_flags_t flags)
3006 edge e;
3007 gimple *stmt;
3009 stmt = last_stmt (bb);
3011 if (stmt && gimple_code (stmt) == GIMPLE_COND)
3013 edge true_edge, false_edge;
3015 /* When we are emitting the code or changing CFG, it is possible that
3016 the edges are not yet created. When we are using debug_bb in such
3017 a situation, we do not want it to crash. */
3018 if (EDGE_COUNT (bb->succs) != 2)
3019 return;
3020 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
3022 INDENT (indent + 2);
3023 pp_cfg_jump (buffer, true_edge, flags);
3024 newline_and_indent (buffer, indent);
3025 pp_string (buffer, "else");
3026 newline_and_indent (buffer, indent + 2);
3027 pp_cfg_jump (buffer, false_edge, flags);
3028 pp_newline (buffer);
3029 return;
3032 /* If there is a fallthru edge, we may need to add an artificial
3033 goto to the dump. */
3034 e = find_fallthru_edge (bb->succs);
3036 if (e && (e->dest != bb->next_bb || (flags & TDF_GIMPLE)))
3038 INDENT (indent);
3040 if ((flags & TDF_LINENO)
3041 && e->goto_locus != UNKNOWN_LOCATION)
3042 dump_location (buffer, e->goto_locus);
3044 pp_cfg_jump (buffer, e, flags);
3045 pp_newline (buffer);
3050 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
3051 indented by INDENT spaces. */
3053 static void
3054 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
3055 dump_flags_t flags)
3057 gimple_stmt_iterator gsi;
3058 gimple *stmt;
3059 int label_indent = indent - 2;
3061 if (label_indent < 0)
3062 label_indent = 0;
3064 dump_phi_nodes (buffer, bb, indent, flags);
3066 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
3068 int curr_indent;
3070 stmt = gsi_stmt (gsi);
3072 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
3074 INDENT (curr_indent);
3075 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
3076 pp_newline_and_flush (buffer);
3077 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
3078 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
3079 pp_buffer (buffer)->stream, stmt);
3082 dump_implicit_edges (buffer, bb, indent, flags);
3083 pp_flush (buffer);
3087 /* Dumps basic block BB to FILE with details described by FLAGS and
3088 indented by INDENT spaces. */
3090 void
3091 gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
3093 dump_gimple_bb_header (file, bb, indent, flags);
3094 if (bb->index >= NUM_FIXED_BLOCKS)
3096 pretty_printer buffer;
3097 pp_needs_newline (&buffer) = true;
3098 buffer.buffer->stream = file;
3099 gimple_dump_bb_buff (&buffer, bb, indent, flags);
3101 dump_gimple_bb_footer (file, bb, indent, flags);
3104 /* Dumps basic block BB to pretty-printer PP with default dump flags and
3105 no indentation, for use as a label of a DOT graph record-node.
3106 ??? Should just use gimple_dump_bb_buff here, except that value profiling
3107 histogram dumping doesn't know about pretty-printers. */
3109 void
3110 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
3112 pp_printf (pp, "<bb %d>:\n", bb->index);
3113 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3115 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
3116 gsi_next (&gsi))
3118 gphi *phi = gsi.phi ();
3119 if (!virtual_operand_p (gimple_phi_result (phi))
3120 || (dump_flags & TDF_VOPS))
3122 pp_bar (pp);
3123 pp_write_text_to_stream (pp);
3124 pp_string (pp, "# ");
3125 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
3126 pp_newline (pp);
3127 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3131 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
3132 gsi_next (&gsi))
3134 gimple *stmt = gsi_stmt (gsi);
3135 pp_bar (pp);
3136 pp_write_text_to_stream (pp);
3137 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
3138 pp_newline (pp);
3139 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3141 dump_implicit_edges (pp, bb, 0, dump_flags);
3142 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3145 #if __GNUC__ >= 10
3146 # pragma GCC diagnostic pop
3147 #endif