Skip various cmp-mem-const tests on lp64 hppa*-*-*
[official-gcc.git] / gcc / gimple-pretty-print.cc
blobabda8871f97fea6d18e18fe76245434097b23530
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2024 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_SERIES_EXPR:
463 for (p = get_tree_code_name (code); *p; p++)
464 pp_character (buffer, TOUPPER (*p));
465 pp_string (buffer, " <");
466 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
467 pp_string (buffer, ", ");
468 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
469 pp_greater (buffer);
470 break;
472 default:
473 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
475 pp_left_paren (buffer);
476 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
477 false);
478 pp_right_paren (buffer);
480 else
481 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
482 pp_space (buffer);
483 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs), flags));
484 pp_space (buffer);
485 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
487 pp_left_paren (buffer);
488 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
489 false);
490 pp_right_paren (buffer);
492 else
493 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
497 /* Helper for dump_gimple_assign. Print the ternary RHS of the
498 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
500 static void
501 dump_ternary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
502 dump_flags_t flags)
504 const char *p;
505 enum tree_code code = gimple_assign_rhs_code (gs);
506 switch (code)
508 case WIDEN_MULT_PLUS_EXPR:
509 case WIDEN_MULT_MINUS_EXPR:
510 for (p = get_tree_code_name (code); *p; p++)
511 pp_character (buffer, TOUPPER (*p));
512 pp_string (buffer, " <");
513 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
514 pp_string (buffer, ", ");
515 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
516 pp_string (buffer, ", ");
517 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
518 pp_greater (buffer);
519 break;
521 case DOT_PROD_EXPR:
522 pp_string (buffer, "DOT_PROD_EXPR <");
523 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
524 pp_string (buffer, ", ");
525 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
526 pp_string (buffer, ", ");
527 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
528 pp_greater (buffer);
529 break;
531 case SAD_EXPR:
532 pp_string (buffer, "SAD_EXPR <");
533 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
534 pp_string (buffer, ", ");
535 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
536 pp_string (buffer, ", ");
537 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
538 pp_greater (buffer);
539 break;
541 case VEC_PERM_EXPR:
542 if (flags & TDF_GIMPLE)
543 pp_string (buffer, "__VEC_PERM (");
544 else
545 pp_string (buffer, "VEC_PERM_EXPR <");
546 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
547 pp_string (buffer, ", ");
548 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
549 pp_string (buffer, ", ");
550 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
551 if (flags & TDF_GIMPLE)
552 pp_right_paren (buffer);
553 else
554 pp_greater (buffer);
555 break;
557 case REALIGN_LOAD_EXPR:
558 pp_string (buffer, "REALIGN_LOAD <");
559 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
560 pp_string (buffer, ", ");
561 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
562 pp_string (buffer, ", ");
563 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
564 pp_greater (buffer);
565 break;
567 case COND_EXPR:
568 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
569 pp_string (buffer, " ? ");
570 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
571 pp_string (buffer, " : ");
572 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
573 break;
575 case VEC_COND_EXPR:
576 pp_string (buffer, "VEC_COND_EXPR <");
577 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
578 pp_string (buffer, ", ");
579 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
580 pp_string (buffer, ", ");
581 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
582 pp_greater (buffer);
583 break;
585 case BIT_INSERT_EXPR:
586 if (flags & TDF_GIMPLE)
588 pp_string (buffer, "__BIT_INSERT (");
589 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc,
590 flags | TDF_SLIM, false);
591 pp_string (buffer, ", ");
592 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc,
593 flags | TDF_SLIM, false);
594 pp_string (buffer, ", ");
595 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc,
596 flags | TDF_SLIM, false);
597 pp_right_paren (buffer);
599 else
601 pp_string (buffer, "BIT_INSERT_EXPR <");
602 dump_generic_node (buffer, gimple_assign_rhs1 (gs),
603 spc, flags, false);
604 pp_string (buffer, ", ");
605 dump_generic_node (buffer, gimple_assign_rhs2 (gs),
606 spc, flags, false);
607 pp_string (buffer, ", ");
608 dump_generic_node (buffer, gimple_assign_rhs3 (gs),
609 spc, flags, false);
610 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
612 pp_string (buffer, " (");
613 pp_decimal_int (buffer, TYPE_PRECISION
614 (TREE_TYPE (gimple_assign_rhs2 (gs))));
615 pp_string (buffer, " bits)");
617 pp_greater (buffer);
619 break;
621 default:
622 gcc_unreachable ();
627 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
628 pp_gimple_stmt_1. */
630 static void
631 dump_gimple_assign (pretty_printer *buffer, const gassign *gs, int spc,
632 dump_flags_t flags)
634 if (flags & TDF_RAW)
636 tree arg1 = NULL;
637 tree arg2 = NULL;
638 tree arg3 = NULL;
639 switch (gimple_num_ops (gs))
641 case 4:
642 arg3 = gimple_assign_rhs3 (gs);
643 /* FALLTHRU */
644 case 3:
645 arg2 = gimple_assign_rhs2 (gs);
646 /* FALLTHRU */
647 case 2:
648 arg1 = gimple_assign_rhs1 (gs);
649 break;
650 default:
651 gcc_unreachable ();
654 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
655 get_tree_code_name (gimple_assign_rhs_code (gs)),
656 gimple_assign_lhs (gs), arg1, arg2, arg3);
658 else
660 if (!(flags & TDF_RHS_ONLY))
662 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
663 pp_space (buffer);
664 pp_equal (buffer);
666 if (gimple_assign_nontemporal_move_p (gs))
667 pp_string (buffer, "{nt}");
669 if (gimple_has_volatile_ops (gs))
670 pp_string (buffer, "{v}");
672 pp_space (buffer);
675 if (gimple_num_ops (gs) == 2)
676 dump_unary_rhs (buffer, gs, spc,
677 ((flags & TDF_GIMPLE)
678 && gimple_assign_rhs_class (gs) != GIMPLE_SINGLE_RHS)
679 ? (flags | TDF_GIMPLE_VAL) : flags);
680 else if (gimple_num_ops (gs) == 3)
681 dump_binary_rhs (buffer, gs, spc,
682 (flags & TDF_GIMPLE)
683 ? (flags | TDF_GIMPLE_VAL) : flags);
684 else if (gimple_num_ops (gs) == 4)
685 dump_ternary_rhs (buffer, gs, spc,
686 (flags & TDF_GIMPLE)
687 ? (flags | TDF_GIMPLE_VAL) : flags);
688 else
689 gcc_unreachable ();
690 if (!(flags & TDF_RHS_ONLY))
691 pp_semicolon (buffer);
696 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
697 pp_gimple_stmt_1. */
699 static void
700 dump_gimple_return (pretty_printer *buffer, const greturn *gs, int spc,
701 dump_flags_t flags)
703 tree t;
705 t = gimple_return_retval (gs);
706 if (flags & TDF_RAW)
707 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
708 else
710 pp_string (buffer, "return");
711 if (t)
713 pp_space (buffer);
714 dump_generic_node (buffer, t, spc, flags, false);
716 pp_semicolon (buffer);
721 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
722 dump_gimple_call. */
724 static void
725 dump_gimple_call_args (pretty_printer *buffer, const gcall *gs,
726 dump_flags_t flags)
728 size_t i = 0;
730 /* Pretty print first arg to certain internal fns. */
731 if (gimple_call_internal_p (gs))
733 const char *const *enums = NULL;
734 unsigned limit = 0;
736 switch (gimple_call_internal_fn (gs))
738 case IFN_UNIQUE:
739 #define DEF(X) #X
740 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
741 #undef DEF
742 enums = unique_args;
744 limit = ARRAY_SIZE (unique_args);
745 break;
747 case IFN_GOACC_LOOP:
748 #define DEF(X) #X
749 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
750 #undef DEF
751 enums = loop_args;
752 limit = ARRAY_SIZE (loop_args);
753 break;
755 case IFN_GOACC_REDUCTION:
756 #define DEF(X) #X
757 static const char *const reduction_args[]
758 = {IFN_GOACC_REDUCTION_CODES};
759 #undef DEF
760 enums = reduction_args;
761 limit = ARRAY_SIZE (reduction_args);
762 break;
764 case IFN_HWASAN_MARK:
765 case IFN_ASAN_MARK:
766 #define DEF(X) #X
767 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
768 #undef DEF
769 enums = asan_mark_args;
770 limit = ARRAY_SIZE (asan_mark_args);
771 break;
773 default:
774 break;
776 if (limit)
778 tree arg0 = gimple_call_arg (gs, 0);
779 HOST_WIDE_INT v;
781 if (TREE_CODE (arg0) == INTEGER_CST
782 && tree_fits_shwi_p (arg0)
783 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
785 i++;
786 pp_string (buffer, enums[v]);
791 for (; i < gimple_call_num_args (gs); i++)
793 if (i)
794 pp_string (buffer, ", ");
795 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
798 if (gimple_call_va_arg_pack_p (gs))
800 if (i)
801 pp_string (buffer, ", ");
803 pp_string (buffer, "__builtin_va_arg_pack ()");
807 /* Dump the points-to solution *PT to BUFFER. */
809 static void
810 pp_points_to_solution (pretty_printer *buffer, const pt_solution *pt)
812 if (pt->anything)
814 pp_string (buffer, "anything ");
815 return;
817 if (pt->nonlocal)
818 pp_string (buffer, "nonlocal ");
819 if (pt->escaped)
820 pp_string (buffer, "escaped ");
821 if (pt->ipa_escaped)
822 pp_string (buffer, "unit-escaped ");
823 if (pt->null)
824 pp_string (buffer, "null ");
825 if (pt->vars
826 && !bitmap_empty_p (pt->vars))
828 bitmap_iterator bi;
829 unsigned i;
830 pp_string (buffer, "{ ");
831 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
833 pp_string (buffer, "D.");
834 pp_decimal_int (buffer, i);
835 pp_space (buffer);
837 pp_right_brace (buffer);
838 if (pt->vars_contains_nonlocal
839 || pt->vars_contains_escaped
840 || pt->vars_contains_escaped_heap
841 || pt->vars_contains_restrict)
843 const char *comma = "";
844 pp_string (buffer, " (");
845 if (pt->vars_contains_nonlocal)
847 pp_string (buffer, "nonlocal");
848 comma = ", ";
850 if (pt->vars_contains_escaped)
852 pp_string (buffer, comma);
853 pp_string (buffer, "escaped");
854 comma = ", ";
856 if (pt->vars_contains_escaped_heap)
858 pp_string (buffer, comma);
859 pp_string (buffer, "escaped heap");
860 comma = ", ";
862 if (pt->vars_contains_restrict)
864 pp_string (buffer, comma);
865 pp_string (buffer, "restrict");
866 comma = ", ";
868 if (pt->vars_contains_interposable)
870 pp_string (buffer, comma);
871 pp_string (buffer, "interposable");
873 pp_string (buffer, ")");
879 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
880 pp_gimple_stmt_1. */
882 static void
883 dump_gimple_call (pretty_printer *buffer, const gcall *gs, int spc,
884 dump_flags_t flags)
886 tree lhs = gimple_call_lhs (gs);
887 tree fn = gimple_call_fn (gs);
889 if (flags & TDF_ALIAS)
891 const pt_solution *pt;
892 pt = gimple_call_use_set (gs);
893 if (!pt_solution_empty_p (pt))
895 pp_string (buffer, "# USE = ");
896 pp_points_to_solution (buffer, pt);
897 newline_and_indent (buffer, spc);
899 pt = gimple_call_clobber_set (gs);
900 if (!pt_solution_empty_p (pt))
902 pp_string (buffer, "# CLB = ");
903 pp_points_to_solution (buffer, pt);
904 newline_and_indent (buffer, spc);
908 if (flags & TDF_RAW)
910 if (gimple_call_internal_p (gs))
911 dump_gimple_fmt (buffer, spc, flags, "%G <.%s, %T", gs,
912 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
913 else
914 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
915 if (gimple_call_num_args (gs) > 0)
917 pp_string (buffer, ", ");
918 dump_gimple_call_args (buffer, gs, flags);
920 pp_greater (buffer);
922 else
924 if (lhs && !(flags & TDF_RHS_ONLY))
926 dump_generic_node (buffer, lhs, spc, flags, false);
927 pp_string (buffer, " =");
929 if (gimple_has_volatile_ops (gs))
930 pp_string (buffer, "{v}");
932 pp_space (buffer);
934 if (gimple_call_internal_p (gs))
936 pp_dot (buffer);
937 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
939 else
940 print_call_name (buffer, fn, flags);
941 pp_string (buffer, " (");
942 dump_gimple_call_args (buffer, gs, flags);
943 pp_right_paren (buffer);
944 if (!(flags & TDF_RHS_ONLY))
945 pp_semicolon (buffer);
948 if (gimple_call_chain (gs))
950 pp_string (buffer, " [static-chain: ");
951 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
952 pp_right_bracket (buffer);
955 if (gimple_call_return_slot_opt_p (gs))
956 pp_string (buffer, " [return slot optimization]");
957 if (gimple_call_tail_p (gs))
958 pp_string (buffer, " [tail call]");
959 if (gimple_call_must_tail_p (gs))
960 pp_string (buffer, " [must tail call]");
962 if (fn == NULL)
963 return;
965 /* Dump the arguments of _ITM_beginTransaction sanely. */
966 if (TREE_CODE (fn) == ADDR_EXPR)
967 fn = TREE_OPERAND (fn, 0);
968 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
969 pp_string (buffer, " [tm-clone]");
970 if (TREE_CODE (fn) == FUNCTION_DECL
971 && fndecl_built_in_p (fn, BUILT_IN_TM_START)
972 && gimple_call_num_args (gs) > 0)
974 tree t = gimple_call_arg (gs, 0);
975 unsigned HOST_WIDE_INT props;
976 gcc_assert (TREE_CODE (t) == INTEGER_CST);
978 pp_string (buffer, " [ ");
980 /* Get the transaction code properties. */
981 props = TREE_INT_CST_LOW (t);
983 if (props & PR_INSTRUMENTEDCODE)
984 pp_string (buffer, "instrumentedCode ");
985 if (props & PR_UNINSTRUMENTEDCODE)
986 pp_string (buffer, "uninstrumentedCode ");
987 if (props & PR_HASNOXMMUPDATE)
988 pp_string (buffer, "hasNoXMMUpdate ");
989 if (props & PR_HASNOABORT)
990 pp_string (buffer, "hasNoAbort ");
991 if (props & PR_HASNOIRREVOCABLE)
992 pp_string (buffer, "hasNoIrrevocable ");
993 if (props & PR_DOESGOIRREVOCABLE)
994 pp_string (buffer, "doesGoIrrevocable ");
995 if (props & PR_HASNOSIMPLEREADS)
996 pp_string (buffer, "hasNoSimpleReads ");
997 if (props & PR_AWBARRIERSOMITTED)
998 pp_string (buffer, "awBarriersOmitted ");
999 if (props & PR_RARBARRIERSOMITTED)
1000 pp_string (buffer, "RaRBarriersOmitted ");
1001 if (props & PR_UNDOLOGCODE)
1002 pp_string (buffer, "undoLogCode ");
1003 if (props & PR_PREFERUNINSTRUMENTED)
1004 pp_string (buffer, "preferUninstrumented ");
1005 if (props & PR_EXCEPTIONBLOCK)
1006 pp_string (buffer, "exceptionBlock ");
1007 if (props & PR_HASELSE)
1008 pp_string (buffer, "hasElse ");
1009 if (props & PR_READONLY)
1010 pp_string (buffer, "readOnly ");
1012 pp_right_bracket (buffer);
1017 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
1018 pp_gimple_stmt_1. */
1020 static void
1021 dump_gimple_switch (pretty_printer *buffer, const gswitch *gs, int spc,
1022 dump_flags_t flags)
1024 unsigned int i;
1026 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
1027 if (flags & TDF_RAW)
1028 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
1029 gimple_switch_index (gs));
1030 else
1032 pp_string (buffer, "switch (");
1033 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
1034 if (flags & TDF_GIMPLE)
1035 pp_string (buffer, ") {");
1036 else
1037 pp_string (buffer, ") <");
1040 for (i = 0; i < gimple_switch_num_labels (gs); i++)
1042 tree case_label = gimple_switch_label (gs, i);
1043 gcc_checking_assert (case_label != NULL_TREE);
1044 dump_generic_node (buffer, case_label, spc, flags, false);
1045 pp_space (buffer);
1046 tree label = CASE_LABEL (case_label);
1047 dump_generic_node (buffer, label, spc, flags, false);
1049 if (cfun && cfun->cfg)
1051 basic_block dest = label_to_block (cfun, label);
1052 if (dest)
1054 edge label_edge = find_edge (gimple_bb (gs), dest);
1055 if (label_edge && !(flags & TDF_GIMPLE))
1056 dump_edge_probability (buffer, label_edge);
1060 if (i < gimple_switch_num_labels (gs) - 1)
1062 if (flags & TDF_GIMPLE)
1063 pp_string (buffer, "; ");
1064 else
1065 pp_string (buffer, ", ");
1068 if (flags & TDF_GIMPLE)
1069 pp_string (buffer, "; }");
1070 else
1071 pp_greater (buffer);
1075 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1076 pp_gimple_stmt_1. */
1078 static void
1079 dump_gimple_cond (pretty_printer *buffer, const gcond *gs, int spc,
1080 dump_flags_t flags)
1082 if (flags & TDF_RAW)
1083 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1084 get_tree_code_name (gimple_cond_code (gs)),
1085 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1086 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1087 else
1089 if (!(flags & TDF_RHS_ONLY))
1090 pp_string (buffer, "if (");
1091 dump_generic_node (buffer, gimple_cond_lhs (gs), spc,
1092 flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : TDF_NONE),
1093 false);
1094 pp_space (buffer);
1095 pp_string (buffer, op_symbol_code (gimple_cond_code (gs), flags));
1096 pp_space (buffer);
1097 dump_generic_node (buffer, gimple_cond_rhs (gs), spc,
1098 flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : TDF_NONE),
1099 false);
1100 if (!(flags & TDF_RHS_ONLY))
1102 edge_iterator ei;
1103 edge e, true_edge = NULL, false_edge = NULL;
1104 basic_block bb = gimple_bb (gs);
1106 if (bb)
1108 FOR_EACH_EDGE (e, ei, bb->succs)
1110 if (e->flags & EDGE_TRUE_VALUE)
1111 true_edge = e;
1112 else if (e->flags & EDGE_FALSE_VALUE)
1113 false_edge = e;
1117 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1119 pp_right_paren (buffer);
1121 if (gimple_cond_true_label (gs))
1123 pp_string (buffer, " goto ");
1124 dump_generic_node (buffer, gimple_cond_true_label (gs),
1125 spc, flags, false);
1126 if (has_edge_info && !(flags & TDF_GIMPLE))
1127 dump_edge_probability (buffer, true_edge);
1128 pp_semicolon (buffer);
1130 if (gimple_cond_false_label (gs))
1132 pp_string (buffer, " else goto ");
1133 dump_generic_node (buffer, gimple_cond_false_label (gs),
1134 spc, flags, false);
1135 if (has_edge_info && !(flags & TDF_GIMPLE))
1136 dump_edge_probability (buffer, false_edge);
1138 pp_semicolon (buffer);
1145 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1146 spaces of indent. FLAGS specifies details to show in the dump (see
1147 TDF_* in dumpfils.h). */
1149 static void
1150 dump_gimple_label (pretty_printer *buffer, const glabel *gs, int spc,
1151 dump_flags_t flags)
1153 tree label = gimple_label_label (gs);
1154 if (flags & TDF_RAW)
1155 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1156 else
1158 dump_generic_node (buffer, label, spc, flags, false);
1159 pp_colon (buffer);
1161 if (flags & TDF_GIMPLE)
1162 return;
1163 if (DECL_NONLOCAL (label))
1164 pp_string (buffer, " [non-local]");
1165 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1166 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1169 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1170 spaces of indent. FLAGS specifies details to show in the dump (see
1171 TDF_* in dumpfile.h). */
1173 static void
1174 dump_gimple_goto (pretty_printer *buffer, const ggoto *gs, int spc,
1175 dump_flags_t flags)
1177 tree label = gimple_goto_dest (gs);
1178 if (flags & TDF_RAW)
1179 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1180 else
1181 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1185 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1186 spaces of indent. FLAGS specifies details to show in the dump (see
1187 TDF_* in dumpfile.h). */
1189 static void
1190 dump_gimple_bind (pretty_printer *buffer, const gbind *gs, int spc,
1191 dump_flags_t flags)
1193 if (flags & TDF_RAW)
1194 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1195 else
1196 pp_left_brace (buffer);
1197 if (!(flags & TDF_SLIM))
1199 tree var;
1201 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1203 newline_and_indent (buffer, 2);
1204 print_declaration (buffer, var, spc, flags);
1206 if (gimple_bind_vars (gs))
1207 pp_newline (buffer);
1209 pp_newline (buffer);
1210 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1211 newline_and_indent (buffer, spc);
1212 if (flags & TDF_RAW)
1213 pp_greater (buffer);
1214 else
1215 pp_right_brace (buffer);
1219 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1220 indent. FLAGS specifies details to show in the dump (see TDF_* in
1221 dumpfile.h). */
1223 static void
1224 dump_gimple_try (pretty_printer *buffer, const gtry *gs, int spc,
1225 dump_flags_t flags)
1227 if (flags & TDF_RAW)
1229 const char *type;
1230 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1231 type = "GIMPLE_TRY_CATCH";
1232 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1233 type = "GIMPLE_TRY_FINALLY";
1234 else
1235 type = "UNKNOWN GIMPLE_TRY";
1236 dump_gimple_fmt (buffer, spc, flags,
1237 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1238 gimple_try_eval (gs), gimple_try_cleanup (gs));
1240 else
1242 pp_string (buffer, "try");
1243 newline_and_indent (buffer, spc + 2);
1244 pp_left_brace (buffer);
1245 pp_newline (buffer);
1247 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1248 newline_and_indent (buffer, spc + 2);
1249 pp_right_brace (buffer);
1251 gimple_seq seq = gimple_try_cleanup (gs);
1253 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1255 newline_and_indent (buffer, spc);
1256 pp_string (buffer, "catch");
1257 newline_and_indent (buffer, spc + 2);
1258 pp_left_brace (buffer);
1260 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1262 newline_and_indent (buffer, spc);
1263 pp_string (buffer, "finally");
1264 newline_and_indent (buffer, spc + 2);
1265 pp_left_brace (buffer);
1267 if (seq && is_a <geh_else *> (gimple_seq_first_stmt (seq))
1268 && gimple_seq_nondebug_singleton_p (seq))
1270 geh_else *stmt = as_a <geh_else *> (gimple_seq_first_stmt (seq));
1271 seq = gimple_eh_else_n_body (stmt);
1272 pp_newline (buffer);
1273 dump_gimple_seq (buffer, seq, spc + 4, flags);
1274 newline_and_indent (buffer, spc + 2);
1275 pp_right_brace (buffer);
1276 seq = gimple_eh_else_e_body (stmt);
1277 newline_and_indent (buffer, spc);
1278 pp_string (buffer, "else");
1279 newline_and_indent (buffer, spc + 2);
1280 pp_left_brace (buffer);
1283 else
1284 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1286 pp_newline (buffer);
1287 dump_gimple_seq (buffer, seq, spc + 4, flags);
1288 newline_and_indent (buffer, spc + 2);
1289 pp_right_brace (buffer);
1294 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1295 indent. FLAGS specifies details to show in the dump (see TDF_* in
1296 dumpfile.h). */
1298 static void
1299 dump_gimple_catch (pretty_printer *buffer, const gcatch *gs, int spc,
1300 dump_flags_t flags)
1302 if (flags & TDF_RAW)
1303 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1304 gimple_catch_types (gs), gimple_catch_handler (gs));
1305 else
1306 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1307 gimple_catch_types (gs), gimple_catch_handler (gs));
1311 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1312 indent. FLAGS specifies details to show in the dump (see TDF_* in
1313 dumpfile.h). */
1315 static void
1316 dump_gimple_eh_filter (pretty_printer *buffer, const geh_filter *gs, int spc,
1317 dump_flags_t flags)
1319 if (flags & TDF_RAW)
1320 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1321 gimple_eh_filter_types (gs),
1322 gimple_eh_filter_failure (gs));
1323 else
1324 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1325 gimple_eh_filter_types (gs),
1326 gimple_eh_filter_failure (gs));
1330 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1332 static void
1333 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1334 const geh_mnt *gs, int spc, dump_flags_t flags)
1336 if (flags & TDF_RAW)
1337 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1338 gimple_eh_must_not_throw_fndecl (gs));
1339 else
1340 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1341 gimple_eh_must_not_throw_fndecl (gs));
1345 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1346 indent. FLAGS specifies details to show in the dump (see TDF_* in
1347 dumpfile.h). */
1349 static void
1350 dump_gimple_eh_else (pretty_printer *buffer, const geh_else *gs, int spc,
1351 dump_flags_t flags)
1353 if (flags & TDF_RAW)
1354 dump_gimple_fmt (buffer, spc, flags,
1355 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1356 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1357 else
1358 dump_gimple_fmt (buffer, spc, flags,
1359 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1360 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1364 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1365 indent. FLAGS specifies details to show in the dump (see TDF_* in
1366 dumpfile.h). */
1368 static void
1369 dump_gimple_resx (pretty_printer *buffer, const gresx *gs, int spc,
1370 dump_flags_t flags)
1372 if (flags & TDF_RAW)
1373 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1374 gimple_resx_region (gs));
1375 else
1376 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1379 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1381 static void
1382 dump_gimple_eh_dispatch (pretty_printer *buffer, const geh_dispatch *gs,
1383 int spc, dump_flags_t flags)
1385 if (flags & TDF_RAW)
1386 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1387 gimple_eh_dispatch_region (gs));
1388 else
1389 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1390 gimple_eh_dispatch_region (gs));
1393 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1394 of indent. FLAGS specifies details to show in the dump (see TDF_*
1395 in dumpfile.h). */
1397 static void
1398 dump_gimple_debug (pretty_printer *buffer, const gdebug *gs, int spc,
1399 dump_flags_t flags)
1401 switch (gs->subcode)
1403 case GIMPLE_DEBUG_BIND:
1404 if (flags & TDF_RAW)
1405 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1406 gimple_debug_bind_get_var (gs),
1407 gimple_debug_bind_get_value (gs));
1408 else
1409 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1410 gimple_debug_bind_get_var (gs),
1411 gimple_debug_bind_get_value (gs));
1412 break;
1414 case GIMPLE_DEBUG_SOURCE_BIND:
1415 if (flags & TDF_RAW)
1416 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1417 gimple_debug_source_bind_get_var (gs),
1418 gimple_debug_source_bind_get_value (gs));
1419 else
1420 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1421 gimple_debug_source_bind_get_var (gs),
1422 gimple_debug_source_bind_get_value (gs));
1423 break;
1425 case GIMPLE_DEBUG_BEGIN_STMT:
1426 if (flags & TDF_RAW)
1427 dump_gimple_fmt (buffer, spc, flags, "%G BEGIN_STMT", gs);
1428 else
1429 dump_gimple_fmt (buffer, spc, flags, "# DEBUG BEGIN_STMT");
1430 break;
1432 case GIMPLE_DEBUG_INLINE_ENTRY:
1433 if (flags & TDF_RAW)
1434 dump_gimple_fmt (buffer, spc, flags, "%G INLINE_ENTRY %T", gs,
1435 gimple_block (gs)
1436 ? block_ultimate_origin (gimple_block (gs))
1437 : NULL_TREE);
1438 else
1439 dump_gimple_fmt (buffer, spc, flags, "# DEBUG INLINE_ENTRY %T",
1440 gimple_block (gs)
1441 ? block_ultimate_origin (gimple_block (gs))
1442 : NULL_TREE);
1443 break;
1445 default:
1446 gcc_unreachable ();
1450 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1451 static void
1452 dump_gimple_omp_for (pretty_printer *buffer, const gomp_for *gs, int spc,
1453 dump_flags_t flags)
1455 size_t i;
1457 if (flags & TDF_RAW)
1459 const char *kind;
1460 switch (gimple_omp_for_kind (gs))
1462 case GF_OMP_FOR_KIND_FOR:
1463 kind = "";
1464 break;
1465 case GF_OMP_FOR_KIND_DISTRIBUTE:
1466 kind = " distribute";
1467 break;
1468 case GF_OMP_FOR_KIND_TASKLOOP:
1469 kind = " taskloop";
1470 break;
1471 case GF_OMP_FOR_KIND_OACC_LOOP:
1472 kind = " oacc_loop";
1473 break;
1474 case GF_OMP_FOR_KIND_SIMD:
1475 kind = " simd";
1476 break;
1477 default:
1478 gcc_unreachable ();
1480 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1481 kind, gimple_omp_body (gs));
1482 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1483 dump_gimple_fmt (buffer, spc, flags, " >,");
1484 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1485 dump_gimple_fmt (buffer, spc, flags,
1486 "%+%T, %T, %T, %s, %T,%n",
1487 gimple_omp_for_index (gs, i),
1488 gimple_omp_for_initial (gs, i),
1489 gimple_omp_for_final (gs, i),
1490 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1491 gimple_omp_for_incr (gs, i));
1492 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1493 gimple_omp_for_pre_body (gs));
1495 else
1497 switch (gimple_omp_for_kind (gs))
1499 case GF_OMP_FOR_KIND_FOR:
1500 pp_string (buffer, "#pragma omp for");
1501 break;
1502 case GF_OMP_FOR_KIND_DISTRIBUTE:
1503 pp_string (buffer, "#pragma omp distribute");
1504 break;
1505 case GF_OMP_FOR_KIND_TASKLOOP:
1506 pp_string (buffer, "#pragma omp taskloop");
1507 break;
1508 case GF_OMP_FOR_KIND_OACC_LOOP:
1509 pp_string (buffer, "#pragma acc loop");
1510 break;
1511 case GF_OMP_FOR_KIND_SIMD:
1512 pp_string (buffer, "#pragma omp simd");
1513 break;
1514 default:
1515 gcc_unreachable ();
1517 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1518 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1520 if (i)
1521 spc += 2;
1522 newline_and_indent (buffer, spc);
1523 pp_string (buffer, "for (");
1524 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1525 flags, false);
1526 pp_string (buffer, " = ");
1527 tree init = gimple_omp_for_initial (gs, i);
1528 if (TREE_CODE (init) != TREE_VEC)
1529 dump_generic_node (buffer, init, spc, flags, false);
1530 else
1531 dump_omp_loop_non_rect_expr (buffer, init, spc, flags);
1532 pp_string (buffer, "; ");
1534 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1535 flags, false);
1536 pp_space (buffer);
1537 switch (gimple_omp_for_cond (gs, i))
1539 case LT_EXPR:
1540 pp_less (buffer);
1541 break;
1542 case GT_EXPR:
1543 pp_greater (buffer);
1544 break;
1545 case LE_EXPR:
1546 pp_less_equal (buffer);
1547 break;
1548 case GE_EXPR:
1549 pp_greater_equal (buffer);
1550 break;
1551 case NE_EXPR:
1552 pp_string (buffer, "!=");
1553 break;
1554 default:
1555 gcc_unreachable ();
1557 pp_space (buffer);
1558 tree cond = gimple_omp_for_final (gs, i);
1559 if (TREE_CODE (cond) != TREE_VEC)
1560 dump_generic_node (buffer, cond, spc, flags, false);
1561 else
1562 dump_omp_loop_non_rect_expr (buffer, cond, spc, flags);
1563 pp_string (buffer, "; ");
1565 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1566 flags, false);
1567 pp_string (buffer, " = ");
1568 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1569 flags, false);
1570 pp_right_paren (buffer);
1573 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1575 newline_and_indent (buffer, spc + 2);
1576 pp_left_brace (buffer);
1577 pp_newline (buffer);
1578 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1579 newline_and_indent (buffer, spc + 2);
1580 pp_right_brace (buffer);
1585 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1587 static void
1588 dump_gimple_omp_continue (pretty_printer *buffer, const gomp_continue *gs,
1589 int spc, dump_flags_t flags)
1591 if (flags & TDF_RAW)
1593 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1594 gimple_omp_continue_control_def (gs),
1595 gimple_omp_continue_control_use (gs));
1597 else
1599 pp_string (buffer, "#pragma omp continue (");
1600 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1601 spc, flags, false);
1602 pp_comma (buffer);
1603 pp_space (buffer);
1604 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1605 spc, flags, false);
1606 pp_right_paren (buffer);
1610 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1612 static void
1613 dump_gimple_omp_single (pretty_printer *buffer, const gomp_single *gs,
1614 int spc, dump_flags_t flags)
1616 if (flags & TDF_RAW)
1618 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1619 gimple_omp_body (gs));
1620 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1621 dump_gimple_fmt (buffer, spc, flags, " >");
1623 else
1625 pp_string (buffer, "#pragma omp single");
1626 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1627 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1629 newline_and_indent (buffer, spc + 2);
1630 pp_left_brace (buffer);
1631 pp_newline (buffer);
1632 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1633 newline_and_indent (buffer, spc + 2);
1634 pp_right_brace (buffer);
1639 /* Dump a GIMPLE_OMP_TASKGROUP tuple on the pretty_printer BUFFER. */
1641 static void
1642 dump_gimple_omp_taskgroup (pretty_printer *buffer, const gimple *gs,
1643 int spc, dump_flags_t flags)
1645 if (flags & TDF_RAW)
1647 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1648 gimple_omp_body (gs));
1649 dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
1650 dump_gimple_fmt (buffer, spc, flags, " >");
1652 else
1654 pp_string (buffer, "#pragma omp taskgroup");
1655 dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
1656 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1658 newline_and_indent (buffer, spc + 2);
1659 pp_left_brace (buffer);
1660 pp_newline (buffer);
1661 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1662 newline_and_indent (buffer, spc + 2);
1663 pp_right_brace (buffer);
1668 /* Dump a GIMPLE_OMP_MASKED tuple on the pretty_printer BUFFER. */
1670 static void
1671 dump_gimple_omp_masked (pretty_printer *buffer, const gimple *gs,
1672 int spc, dump_flags_t flags)
1674 if (flags & TDF_RAW)
1676 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1677 gimple_omp_body (gs));
1678 dump_omp_clauses (buffer, gimple_omp_masked_clauses (gs), spc, flags);
1679 dump_gimple_fmt (buffer, spc, flags, " >");
1681 else
1683 pp_string (buffer, "#pragma omp masked");
1684 dump_omp_clauses (buffer, gimple_omp_masked_clauses (gs), spc, flags);
1685 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1687 newline_and_indent (buffer, spc + 2);
1688 pp_left_brace (buffer);
1689 pp_newline (buffer);
1690 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1691 newline_and_indent (buffer, spc + 2);
1692 pp_right_brace (buffer);
1697 /* Dump a GIMPLE_OMP_SCOPE tuple on the pretty_printer BUFFER. */
1699 static void
1700 dump_gimple_omp_scope (pretty_printer *buffer, const gimple *gs,
1701 int spc, dump_flags_t flags)
1703 if (flags & TDF_RAW)
1705 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1706 gimple_omp_body (gs));
1707 dump_omp_clauses (buffer, gimple_omp_scope_clauses (gs), spc, flags);
1708 dump_gimple_fmt (buffer, spc, flags, " >");
1710 else
1712 pp_string (buffer, "#pragma omp scope");
1713 dump_omp_clauses (buffer, gimple_omp_scope_clauses (gs), spc, flags);
1714 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1716 newline_and_indent (buffer, spc + 2);
1717 pp_left_brace (buffer);
1718 pp_newline (buffer);
1719 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1720 newline_and_indent (buffer, spc + 2);
1721 pp_right_brace (buffer);
1726 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1728 static void
1729 dump_gimple_omp_target (pretty_printer *buffer, const gomp_target *gs,
1730 int spc, dump_flags_t flags)
1732 const char *kind;
1733 switch (gimple_omp_target_kind (gs))
1735 case GF_OMP_TARGET_KIND_REGION:
1736 kind = "";
1737 break;
1738 case GF_OMP_TARGET_KIND_DATA:
1739 kind = " data";
1740 break;
1741 case GF_OMP_TARGET_KIND_UPDATE:
1742 kind = " update";
1743 break;
1744 case GF_OMP_TARGET_KIND_ENTER_DATA:
1745 kind = " enter data";
1746 break;
1747 case GF_OMP_TARGET_KIND_EXIT_DATA:
1748 kind = " exit data";
1749 break;
1750 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1751 kind = " oacc_kernels";
1752 break;
1753 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1754 kind = " oacc_parallel";
1755 break;
1756 case GF_OMP_TARGET_KIND_OACC_SERIAL:
1757 kind = " oacc_serial";
1758 break;
1759 case GF_OMP_TARGET_KIND_OACC_DATA:
1760 kind = " oacc_data";
1761 break;
1762 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1763 kind = " oacc_update";
1764 break;
1765 case GF_OMP_TARGET_KIND_OACC_ENTER_DATA:
1766 kind = " oacc_enter_data";
1767 break;
1768 case GF_OMP_TARGET_KIND_OACC_EXIT_DATA:
1769 kind = " oacc_exit_data";
1770 break;
1771 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1772 kind = " oacc_declare";
1773 break;
1774 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1775 kind = " oacc_host_data";
1776 break;
1777 case GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_PARALLELIZED:
1778 kind = " oacc_parallel_kernels_parallelized";
1779 break;
1780 case GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_GANG_SINGLE:
1781 kind = " oacc_parallel_kernels_gang_single";
1782 break;
1783 case GF_OMP_TARGET_KIND_OACC_DATA_KERNELS:
1784 kind = " oacc_data_kernels";
1785 break;
1786 default:
1787 gcc_unreachable ();
1789 if (flags & TDF_RAW)
1791 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1792 kind, gimple_omp_body (gs));
1793 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1794 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1795 gimple_omp_target_child_fn (gs),
1796 gimple_omp_target_data_arg (gs));
1798 else
1800 pp_string (buffer, "#pragma omp target");
1801 pp_string (buffer, kind);
1802 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1803 if (gimple_omp_target_child_fn (gs))
1805 pp_string (buffer, " [child fn: ");
1806 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1807 spc, flags, false);
1808 pp_string (buffer, " (");
1809 if (gimple_omp_target_data_arg (gs))
1810 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1811 spc, flags, false);
1812 else
1813 pp_string (buffer, "???");
1814 pp_string (buffer, ")]");
1816 gimple_seq body = gimple_omp_body (gs);
1817 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1819 newline_and_indent (buffer, spc + 2);
1820 pp_left_brace (buffer);
1821 pp_newline (buffer);
1822 dump_gimple_seq (buffer, body, spc + 4, flags);
1823 newline_and_indent (buffer, spc + 2);
1824 pp_right_brace (buffer);
1826 else if (body)
1828 pp_newline (buffer);
1829 dump_gimple_seq (buffer, body, spc + 2, flags);
1834 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1836 static void
1837 dump_gimple_omp_teams (pretty_printer *buffer, const gomp_teams *gs, int spc,
1838 dump_flags_t flags)
1840 if (flags & TDF_RAW)
1842 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1843 gimple_omp_body (gs));
1844 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1845 dump_gimple_fmt (buffer, spc, flags, " >");
1847 else
1849 pp_string (buffer, "#pragma omp teams");
1850 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1851 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1853 newline_and_indent (buffer, spc + 2);
1854 pp_character (buffer, '{');
1855 pp_newline (buffer);
1856 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1857 newline_and_indent (buffer, spc + 2);
1858 pp_character (buffer, '}');
1863 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1865 static void
1866 dump_gimple_omp_sections (pretty_printer *buffer, const gomp_sections *gs,
1867 int spc, dump_flags_t flags)
1869 if (flags & TDF_RAW)
1871 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1872 gimple_omp_body (gs));
1873 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1874 dump_gimple_fmt (buffer, spc, flags, " >");
1876 else
1878 pp_string (buffer, "#pragma omp sections");
1879 if (gimple_omp_sections_control (gs))
1881 pp_string (buffer, " <");
1882 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1883 flags, false);
1884 pp_greater (buffer);
1886 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1887 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1889 newline_and_indent (buffer, spc + 2);
1890 pp_left_brace (buffer);
1891 pp_newline (buffer);
1892 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1893 newline_and_indent (buffer, spc + 2);
1894 pp_right_brace (buffer);
1899 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION,STRUCTURED_BLOCK} tuple on the
1900 pretty_printer BUFFER. */
1902 static void
1903 dump_gimple_omp_block (pretty_printer *buffer, const gimple *gs, int spc,
1904 dump_flags_t flags)
1906 if (flags & TDF_RAW)
1907 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1908 gimple_omp_body (gs));
1909 else
1911 switch (gimple_code (gs))
1913 case GIMPLE_OMP_MASTER:
1914 pp_string (buffer, "#pragma omp master");
1915 break;
1916 case GIMPLE_OMP_SECTION:
1917 pp_string (buffer, "#pragma omp section");
1918 break;
1919 case GIMPLE_OMP_STRUCTURED_BLOCK:
1920 pp_string (buffer, "#pragma omp __structured_block");
1921 break;
1922 default:
1923 gcc_unreachable ();
1925 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1927 newline_and_indent (buffer, spc + 2);
1928 pp_left_brace (buffer);
1929 pp_newline (buffer);
1930 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1931 newline_and_indent (buffer, spc + 2);
1932 pp_right_brace (buffer);
1937 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1939 static void
1940 dump_gimple_omp_critical (pretty_printer *buffer, const gomp_critical *gs,
1941 int spc, dump_flags_t flags)
1943 if (flags & TDF_RAW)
1944 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1945 gimple_omp_body (gs));
1946 else
1948 pp_string (buffer, "#pragma omp critical");
1949 if (gimple_omp_critical_name (gs))
1951 pp_string (buffer, " (");
1952 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1953 flags, false);
1954 pp_right_paren (buffer);
1956 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1957 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1959 newline_and_indent (buffer, spc + 2);
1960 pp_left_brace (buffer);
1961 pp_newline (buffer);
1962 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1963 newline_and_indent (buffer, spc + 2);
1964 pp_right_brace (buffer);
1969 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1971 static void
1972 dump_gimple_omp_ordered (pretty_printer *buffer, const gomp_ordered *gs,
1973 int spc, dump_flags_t flags)
1975 if (flags & TDF_RAW)
1976 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1977 gimple_omp_body (gs));
1978 else
1980 pp_string (buffer, "#pragma omp ordered");
1981 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1982 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1984 newline_and_indent (buffer, spc + 2);
1985 pp_left_brace (buffer);
1986 pp_newline (buffer);
1987 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1988 newline_and_indent (buffer, spc + 2);
1989 pp_right_brace (buffer);
1994 /* Dump a GIMPLE_OMP_SCAN tuple on the pretty_printer BUFFER. */
1996 static void
1997 dump_gimple_omp_scan (pretty_printer *buffer, const gomp_scan *gs,
1998 int spc, dump_flags_t flags)
2000 if (flags & TDF_RAW)
2001 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
2002 gimple_omp_body (gs));
2003 else
2005 if (gimple_omp_scan_clauses (gs))
2007 pp_string (buffer, "#pragma omp scan");
2008 dump_omp_clauses (buffer, gimple_omp_scan_clauses (gs), spc, flags);
2010 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
2012 newline_and_indent (buffer, spc + 2);
2013 pp_left_brace (buffer);
2014 pp_newline (buffer);
2015 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
2016 newline_and_indent (buffer, spc + 2);
2017 pp_right_brace (buffer);
2022 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
2024 static void
2025 dump_gimple_omp_return (pretty_printer *buffer, const gimple *gs, int spc,
2026 dump_flags_t flags)
2028 if (flags & TDF_RAW)
2030 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
2031 (int) gimple_omp_return_nowait_p (gs));
2032 if (gimple_omp_return_lhs (gs))
2033 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
2034 gimple_omp_return_lhs (gs));
2035 else
2036 dump_gimple_fmt (buffer, spc, flags, ">");
2038 else
2040 pp_string (buffer, "#pragma omp return");
2041 if (gimple_omp_return_nowait_p (gs))
2042 pp_string (buffer, "(nowait)");
2043 if (gimple_omp_return_lhs (gs))
2045 pp_string (buffer, " (set ");
2046 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
2047 spc, flags, false);
2048 pp_character (buffer, ')');
2053 /* Dump a GIMPLE_ASSUME tuple on the pretty_printer BUFFER. */
2055 static void
2056 dump_gimple_assume (pretty_printer *buffer, const gimple *gs,
2057 int spc, dump_flags_t flags)
2059 if (flags & TDF_RAW)
2060 dump_gimple_fmt (buffer, spc, flags,
2061 "%G [GUARD=%T] <%+BODY <%S> >",
2062 gs, gimple_assume_guard (gs),
2063 gimple_assume_body (gs));
2064 else
2066 pp_string (buffer, "[[assume (");
2067 dump_generic_node (buffer, gimple_assume_guard (gs), spc, flags, false);
2068 pp_string (buffer, ")]]");
2069 newline_and_indent (buffer, spc + 2);
2070 pp_left_brace (buffer);
2071 pp_newline (buffer);
2072 dump_gimple_seq (buffer, gimple_assume_body (gs), spc + 4, flags);
2073 newline_and_indent (buffer, spc + 2);
2074 pp_right_brace (buffer);
2078 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
2080 static void
2081 dump_gimple_transaction (pretty_printer *buffer, const gtransaction *gs,
2082 int spc, dump_flags_t flags)
2084 unsigned subcode = gimple_transaction_subcode (gs);
2086 if (flags & TDF_RAW)
2088 dump_gimple_fmt (buffer, spc, flags,
2089 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
2090 "<%+BODY <%S> >",
2091 gs, subcode, gimple_transaction_label_norm (gs),
2092 gimple_transaction_label_uninst (gs),
2093 gimple_transaction_label_over (gs),
2094 gimple_transaction_body (gs));
2096 else
2098 if (subcode & GTMA_IS_OUTER)
2099 pp_string (buffer, "__transaction_atomic [[outer]]");
2100 else if (subcode & GTMA_IS_RELAXED)
2101 pp_string (buffer, "__transaction_relaxed");
2102 else
2103 pp_string (buffer, "__transaction_atomic");
2104 subcode &= ~GTMA_DECLARATION_MASK;
2106 if (gimple_transaction_body (gs))
2108 newline_and_indent (buffer, spc + 2);
2109 pp_left_brace (buffer);
2110 pp_newline (buffer);
2111 dump_gimple_seq (buffer, gimple_transaction_body (gs),
2112 spc + 4, flags);
2113 newline_and_indent (buffer, spc + 2);
2114 pp_right_brace (buffer);
2116 else
2118 pp_string (buffer, " //");
2119 if (gimple_transaction_label_norm (gs))
2121 pp_string (buffer, " NORM=");
2122 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
2123 spc, flags, false);
2125 if (gimple_transaction_label_uninst (gs))
2127 pp_string (buffer, " UNINST=");
2128 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
2129 spc, flags, false);
2131 if (gimple_transaction_label_over (gs))
2133 pp_string (buffer, " OVER=");
2134 dump_generic_node (buffer, gimple_transaction_label_over (gs),
2135 spc, flags, false);
2137 if (subcode)
2139 pp_string (buffer, " SUBCODE=[ ");
2140 if (subcode & GTMA_HAVE_ABORT)
2142 pp_string (buffer, "GTMA_HAVE_ABORT ");
2143 subcode &= ~GTMA_HAVE_ABORT;
2145 if (subcode & GTMA_HAVE_LOAD)
2147 pp_string (buffer, "GTMA_HAVE_LOAD ");
2148 subcode &= ~GTMA_HAVE_LOAD;
2150 if (subcode & GTMA_HAVE_STORE)
2152 pp_string (buffer, "GTMA_HAVE_STORE ");
2153 subcode &= ~GTMA_HAVE_STORE;
2155 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
2157 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
2158 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
2160 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
2162 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
2163 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
2165 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
2167 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
2168 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
2170 if (subcode)
2171 pp_printf (buffer, "0x%x ", subcode);
2172 pp_right_bracket (buffer);
2178 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
2179 indent. FLAGS specifies details to show in the dump (see TDF_* in
2180 dumpfile.h). */
2182 static void
2183 dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc,
2184 dump_flags_t flags)
2186 unsigned int i, n, f, fields;
2188 if (flags & TDF_RAW)
2190 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
2191 gimple_asm_string (gs));
2193 n = gimple_asm_noutputs (gs);
2194 if (n)
2196 newline_and_indent (buffer, spc + 2);
2197 pp_string (buffer, "OUTPUT: ");
2198 for (i = 0; i < n; i++)
2200 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2201 spc, flags, false);
2202 if (i < n - 1)
2203 pp_string (buffer, ", ");
2207 n = gimple_asm_ninputs (gs);
2208 if (n)
2210 newline_and_indent (buffer, spc + 2);
2211 pp_string (buffer, "INPUT: ");
2212 for (i = 0; i < n; i++)
2214 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2215 spc, flags, false);
2216 if (i < n - 1)
2217 pp_string (buffer, ", ");
2221 n = gimple_asm_nclobbers (gs);
2222 if (n)
2224 newline_and_indent (buffer, spc + 2);
2225 pp_string (buffer, "CLOBBER: ");
2226 for (i = 0; i < n; i++)
2228 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2229 spc, flags, false);
2230 if (i < n - 1)
2231 pp_string (buffer, ", ");
2235 n = gimple_asm_nlabels (gs);
2236 if (n)
2238 newline_and_indent (buffer, spc + 2);
2239 pp_string (buffer, "LABEL: ");
2240 for (i = 0; i < n; i++)
2242 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2243 spc, flags, false);
2244 if (i < n - 1)
2245 pp_string (buffer, ", ");
2249 newline_and_indent (buffer, spc);
2250 pp_greater (buffer);
2252 else
2254 pp_string (buffer, "__asm__");
2255 if (gimple_asm_volatile_p (gs))
2256 pp_string (buffer, " __volatile__");
2257 if (gimple_asm_inline_p (gs))
2258 pp_string (buffer, " __inline__");
2259 if (gimple_asm_nlabels (gs))
2260 pp_string (buffer, " goto");
2261 pp_string (buffer, "(\"");
2262 pp_string (buffer, gimple_asm_string (gs));
2263 pp_string (buffer, "\"");
2265 if (gimple_asm_nlabels (gs))
2266 fields = 4;
2267 else if (gimple_asm_nclobbers (gs))
2268 fields = 3;
2269 else if (gimple_asm_ninputs (gs))
2270 fields = 2;
2271 else if (gimple_asm_noutputs (gs))
2272 fields = 1;
2273 else
2274 fields = 0;
2276 for (f = 0; f < fields; ++f)
2278 pp_string (buffer, " : ");
2280 switch (f)
2282 case 0:
2283 n = gimple_asm_noutputs (gs);
2284 for (i = 0; i < n; i++)
2286 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2287 spc, flags, false);
2288 if (i < n - 1)
2289 pp_string (buffer, ", ");
2291 break;
2293 case 1:
2294 n = gimple_asm_ninputs (gs);
2295 for (i = 0; i < n; i++)
2297 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2298 spc, flags, false);
2299 if (i < n - 1)
2300 pp_string (buffer, ", ");
2302 break;
2304 case 2:
2305 n = gimple_asm_nclobbers (gs);
2306 for (i = 0; i < n; i++)
2308 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2309 spc, flags, false);
2310 if (i < n - 1)
2311 pp_string (buffer, ", ");
2313 break;
2315 case 3:
2316 n = gimple_asm_nlabels (gs);
2317 for (i = 0; i < n; i++)
2319 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2320 spc, flags, false);
2321 if (i < n - 1)
2322 pp_string (buffer, ", ");
2324 break;
2326 default:
2327 gcc_unreachable ();
2331 pp_string (buffer, ");");
2335 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2336 SPC spaces of indent. */
2338 static void
2339 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2341 if (TREE_CODE (node) != SSA_NAME)
2342 return;
2344 if (POINTER_TYPE_P (TREE_TYPE (node))
2345 && SSA_NAME_PTR_INFO (node))
2347 unsigned int align, misalign;
2348 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2349 pp_string (buffer, "# PT = ");
2350 pp_points_to_solution (buffer, &pi->pt);
2351 newline_and_indent (buffer, spc);
2352 if (get_ptr_info_alignment (pi, &align, &misalign))
2354 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2355 newline_and_indent (buffer, spc);
2359 if (!POINTER_TYPE_P (TREE_TYPE (node))
2360 && SSA_NAME_RANGE_INFO (node))
2362 Value_Range r (TREE_TYPE (node));
2363 get_global_range_query ()->range_of_expr (r, node);
2364 pp_string (buffer, "# RANGE ");
2365 pp_vrange (buffer, &r);
2366 newline_and_indent (buffer, spc);
2370 /* As dump_ssaname_info, but dump to FILE. */
2372 void
2373 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2375 pretty_printer buffer;
2376 pp_needs_newline (&buffer) = true;
2377 buffer.buffer->stream = file;
2378 dump_ssaname_info (&buffer, node, spc);
2379 pp_flush (&buffer);
2382 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2383 The caller is responsible for calling pp_flush on BUFFER to finalize
2384 pretty printer. If COMMENT is true, print this after #. */
2386 static void
2387 dump_gimple_phi (pretty_printer *buffer, const gphi *phi, int spc, bool comment,
2388 dump_flags_t flags)
2390 size_t i;
2391 tree lhs = gimple_phi_result (phi);
2393 if (flags & TDF_ALIAS)
2394 dump_ssaname_info (buffer, lhs, spc);
2396 if (comment)
2397 pp_string (buffer, "# ");
2399 if (flags & TDF_RAW)
2400 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2401 gimple_phi_result (phi));
2402 else
2404 dump_generic_node (buffer, lhs, spc, flags, false);
2405 if (flags & TDF_GIMPLE)
2406 pp_string (buffer, " = __PHI (");
2407 else
2408 pp_string (buffer, " = PHI <");
2410 for (i = 0; i < gimple_phi_num_args (phi); i++)
2412 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2413 dump_location (buffer, gimple_phi_arg_location (phi, i));
2414 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2415 if (flags & TDF_GIMPLE)
2417 pp_string (buffer, "__BB");
2418 pp_decimal_int (buffer, src->index);
2419 pp_string (buffer, ": ");
2421 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2422 false);
2423 if (! (flags & TDF_GIMPLE))
2425 pp_left_paren (buffer);
2426 pp_decimal_int (buffer, src->index);
2427 pp_right_paren (buffer);
2429 if (i < gimple_phi_num_args (phi) - 1)
2430 pp_string (buffer, ", ");
2432 if (flags & TDF_GIMPLE)
2433 pp_string (buffer, ");");
2434 else
2435 pp_greater (buffer);
2439 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2440 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2441 dumpfile.h). */
2443 static void
2444 dump_gimple_omp_parallel (pretty_printer *buffer, const gomp_parallel *gs,
2445 int spc, dump_flags_t flags)
2447 if (flags & TDF_RAW)
2449 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2450 gimple_omp_body (gs));
2451 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2452 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2453 gimple_omp_parallel_child_fn (gs),
2454 gimple_omp_parallel_data_arg (gs));
2456 else
2458 gimple_seq body;
2459 pp_string (buffer, "#pragma omp parallel");
2460 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2461 if (gimple_omp_parallel_child_fn (gs))
2463 pp_string (buffer, " [child fn: ");
2464 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2465 spc, flags, false);
2466 pp_string (buffer, " (");
2467 if (gimple_omp_parallel_data_arg (gs))
2468 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2469 spc, flags, false);
2470 else
2471 pp_string (buffer, "???");
2472 pp_string (buffer, ")]");
2474 body = gimple_omp_body (gs);
2475 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2477 newline_and_indent (buffer, spc + 2);
2478 pp_left_brace (buffer);
2479 pp_newline (buffer);
2480 dump_gimple_seq (buffer, body, spc + 4, flags);
2481 newline_and_indent (buffer, spc + 2);
2482 pp_right_brace (buffer);
2484 else if (body)
2486 pp_newline (buffer);
2487 dump_gimple_seq (buffer, body, spc + 2, flags);
2493 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2494 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2495 dumpfile.h). */
2497 static void
2498 dump_gimple_omp_task (pretty_printer *buffer, const gomp_task *gs, int spc,
2499 dump_flags_t flags)
2501 if (flags & TDF_RAW)
2503 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2504 gimple_omp_body (gs));
2505 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2506 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2507 gimple_omp_task_child_fn (gs),
2508 gimple_omp_task_data_arg (gs),
2509 gimple_omp_task_copy_fn (gs),
2510 gimple_omp_task_arg_size (gs),
2511 gimple_omp_task_arg_size (gs));
2513 else
2515 gimple_seq body;
2516 if (gimple_omp_task_taskloop_p (gs))
2517 pp_string (buffer, "#pragma omp taskloop");
2518 else if (gimple_omp_task_taskwait_p (gs))
2519 pp_string (buffer, "#pragma omp taskwait");
2520 else
2521 pp_string (buffer, "#pragma omp task");
2522 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2523 if (gimple_omp_task_child_fn (gs))
2525 pp_string (buffer, " [child fn: ");
2526 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2527 spc, flags, false);
2528 pp_string (buffer, " (");
2529 if (gimple_omp_task_data_arg (gs))
2530 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2531 spc, flags, false);
2532 else
2533 pp_string (buffer, "???");
2534 pp_string (buffer, ")]");
2536 body = gimple_omp_body (gs);
2537 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2539 newline_and_indent (buffer, spc + 2);
2540 pp_left_brace (buffer);
2541 pp_newline (buffer);
2542 dump_gimple_seq (buffer, body, spc + 4, flags);
2543 newline_and_indent (buffer, spc + 2);
2544 pp_right_brace (buffer);
2546 else if (body)
2548 pp_newline (buffer);
2549 dump_gimple_seq (buffer, body, spc + 2, flags);
2555 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2556 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2557 in dumpfile.h). */
2559 static void
2560 dump_gimple_omp_atomic_load (pretty_printer *buffer, const gomp_atomic_load *gs,
2561 int spc, dump_flags_t flags)
2563 if (flags & TDF_RAW)
2565 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2566 gimple_omp_atomic_load_lhs (gs),
2567 gimple_omp_atomic_load_rhs (gs));
2569 else
2571 pp_string (buffer, "#pragma omp atomic_load");
2572 dump_omp_atomic_memory_order (buffer,
2573 gimple_omp_atomic_memory_order (gs));
2574 if (gimple_omp_atomic_need_value_p (gs))
2575 pp_string (buffer, " [needed]");
2576 if (gimple_omp_atomic_weak_p (gs))
2577 pp_string (buffer, " [weak]");
2578 newline_and_indent (buffer, spc + 2);
2579 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2580 spc, flags, false);
2581 pp_space (buffer);
2582 pp_equal (buffer);
2583 pp_space (buffer);
2584 pp_star (buffer);
2585 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2586 spc, flags, false);
2590 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2591 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2592 in dumpfile.h). */
2594 static void
2595 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2596 const gomp_atomic_store *gs, int spc,
2597 dump_flags_t flags)
2599 if (flags & TDF_RAW)
2601 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2602 gimple_omp_atomic_store_val (gs));
2604 else
2606 pp_string (buffer, "#pragma omp atomic_store");
2607 dump_omp_atomic_memory_order (buffer,
2608 gimple_omp_atomic_memory_order (gs));
2609 pp_space (buffer);
2610 if (gimple_omp_atomic_need_value_p (gs))
2611 pp_string (buffer, "[needed] ");
2612 if (gimple_omp_atomic_weak_p (gs))
2613 pp_string (buffer, "[weak] ");
2614 pp_left_paren (buffer);
2615 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2616 spc, flags, false);
2617 pp_right_paren (buffer);
2622 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2623 FLAGS are as in pp_gimple_stmt_1. */
2625 static void
2626 dump_gimple_mem_ops (pretty_printer *buffer, const gimple *gs, int spc,
2627 dump_flags_t flags)
2629 tree vdef = gimple_vdef (gs);
2630 tree vuse = gimple_vuse (gs);
2632 if (vdef != NULL_TREE)
2634 pp_string (buffer, "# ");
2635 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2636 pp_string (buffer, " = VDEF <");
2637 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2638 pp_greater (buffer);
2639 newline_and_indent (buffer, spc);
2641 else if (vuse != NULL_TREE)
2643 pp_string (buffer, "# VUSE <");
2644 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2645 pp_greater (buffer);
2646 newline_and_indent (buffer, spc);
2651 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2652 spaces of indent. FLAGS specifies details to show in the dump (see
2653 TDF_* in dumpfile.h). The caller is responsible for calling
2654 pp_flush on BUFFER to finalize the pretty printer. */
2656 void
2657 pp_gimple_stmt_1 (pretty_printer *buffer, const gimple *gs, int spc,
2658 dump_flags_t flags)
2660 if (!gs)
2661 return;
2663 if (flags & TDF_STMTADDR)
2664 pp_printf (buffer, "<&%p> ", (const void *) gs);
2666 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2667 dump_location (buffer, gimple_location (gs));
2669 if (flags & TDF_EH)
2671 int lp_nr = lookup_stmt_eh_lp (gs);
2672 if (lp_nr > 0)
2673 pp_printf (buffer, "[LP %d] ", lp_nr);
2674 else if (lp_nr < 0)
2675 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2678 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2679 && gimple_has_mem_ops (gs))
2680 dump_gimple_mem_ops (buffer, gs, spc, flags);
2682 if (gimple_has_lhs (gs)
2683 && (flags & TDF_ALIAS))
2684 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2686 switch (gimple_code (gs))
2688 case GIMPLE_ASM:
2689 dump_gimple_asm (buffer, as_a <const gasm *> (gs), spc, flags);
2690 break;
2692 case GIMPLE_ASSIGN:
2693 dump_gimple_assign (buffer, as_a <const gassign *> (gs), spc, flags);
2694 break;
2696 case GIMPLE_BIND:
2697 dump_gimple_bind (buffer, as_a <const gbind *> (gs), spc, flags);
2698 break;
2700 case GIMPLE_CALL:
2701 dump_gimple_call (buffer, as_a <const gcall *> (gs), spc, flags);
2702 break;
2704 case GIMPLE_COND:
2705 dump_gimple_cond (buffer, as_a <const gcond *> (gs), spc, flags);
2706 break;
2708 case GIMPLE_LABEL:
2709 dump_gimple_label (buffer, as_a <const glabel *> (gs), spc, flags);
2710 break;
2712 case GIMPLE_GOTO:
2713 dump_gimple_goto (buffer, as_a <const ggoto *> (gs), spc, flags);
2714 break;
2716 case GIMPLE_NOP:
2717 pp_string (buffer, "GIMPLE_NOP");
2718 break;
2720 case GIMPLE_RETURN:
2721 dump_gimple_return (buffer, as_a <const greturn *> (gs), spc, flags);
2722 break;
2724 case GIMPLE_SWITCH:
2725 dump_gimple_switch (buffer, as_a <const gswitch *> (gs), spc, flags);
2726 break;
2728 case GIMPLE_TRY:
2729 dump_gimple_try (buffer, as_a <const gtry *> (gs), spc, flags);
2730 break;
2732 case GIMPLE_PHI:
2733 dump_gimple_phi (buffer, as_a <const gphi *> (gs), spc, false, flags);
2734 break;
2736 case GIMPLE_OMP_PARALLEL:
2737 dump_gimple_omp_parallel (buffer, as_a <const gomp_parallel *> (gs), spc,
2738 flags);
2739 break;
2741 case GIMPLE_OMP_TASK:
2742 dump_gimple_omp_task (buffer, as_a <const gomp_task *> (gs), spc, flags);
2743 break;
2745 case GIMPLE_OMP_ATOMIC_LOAD:
2746 dump_gimple_omp_atomic_load (buffer, as_a <const gomp_atomic_load *> (gs),
2747 spc, flags);
2748 break;
2750 case GIMPLE_OMP_ATOMIC_STORE:
2751 dump_gimple_omp_atomic_store (buffer,
2752 as_a <const gomp_atomic_store *> (gs),
2753 spc, flags);
2754 break;
2756 case GIMPLE_OMP_FOR:
2757 dump_gimple_omp_for (buffer, as_a <const gomp_for *> (gs), spc, flags);
2758 break;
2760 case GIMPLE_OMP_CONTINUE:
2761 dump_gimple_omp_continue (buffer, as_a <const gomp_continue *> (gs), spc,
2762 flags);
2763 break;
2765 case GIMPLE_OMP_SINGLE:
2766 dump_gimple_omp_single (buffer, as_a <const gomp_single *> (gs), spc,
2767 flags);
2768 break;
2770 case GIMPLE_OMP_TARGET:
2771 dump_gimple_omp_target (buffer, as_a <const gomp_target *> (gs), spc,
2772 flags);
2773 break;
2775 case GIMPLE_OMP_TEAMS:
2776 dump_gimple_omp_teams (buffer, as_a <const gomp_teams *> (gs), spc,
2777 flags);
2778 break;
2780 case GIMPLE_OMP_RETURN:
2781 dump_gimple_omp_return (buffer, gs, spc, flags);
2782 break;
2784 case GIMPLE_OMP_SECTIONS:
2785 dump_gimple_omp_sections (buffer, as_a <const gomp_sections *> (gs),
2786 spc, flags);
2787 break;
2789 case GIMPLE_OMP_SECTIONS_SWITCH:
2790 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2791 break;
2793 case GIMPLE_OMP_TASKGROUP:
2794 dump_gimple_omp_taskgroup (buffer, gs, spc, flags);
2795 break;
2797 case GIMPLE_OMP_MASKED:
2798 dump_gimple_omp_masked (buffer, gs, spc, flags);
2799 break;
2801 case GIMPLE_OMP_SCOPE:
2802 dump_gimple_omp_scope (buffer, gs, spc, flags);
2803 break;
2805 case GIMPLE_OMP_MASTER:
2806 case GIMPLE_OMP_SECTION:
2807 case GIMPLE_OMP_STRUCTURED_BLOCK:
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;
3008 if (safe_is_a <gcond *> (*gsi_last_bb (bb)))
3010 edge true_edge, false_edge;
3012 /* When we are emitting the code or changing CFG, it is possible that
3013 the edges are not yet created. When we are using debug_bb in such
3014 a situation, we do not want it to crash. */
3015 if (EDGE_COUNT (bb->succs) != 2)
3016 return;
3017 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
3019 INDENT (indent + 2);
3020 pp_cfg_jump (buffer, true_edge, flags);
3021 newline_and_indent (buffer, indent);
3022 pp_string (buffer, "else");
3023 newline_and_indent (buffer, indent + 2);
3024 pp_cfg_jump (buffer, false_edge, flags);
3025 pp_newline (buffer);
3026 return;
3029 /* If there is a fallthru edge, we may need to add an artificial
3030 goto to the dump. */
3031 e = find_fallthru_edge (bb->succs);
3033 if (e && (e->dest != bb->next_bb || (flags & TDF_GIMPLE)))
3035 INDENT (indent);
3037 if ((flags & TDF_LINENO)
3038 && e->goto_locus != UNKNOWN_LOCATION)
3039 dump_location (buffer, e->goto_locus);
3041 pp_cfg_jump (buffer, e, flags);
3042 pp_newline (buffer);
3047 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
3048 indented by INDENT spaces. */
3050 static void
3051 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
3052 dump_flags_t flags)
3054 gimple_stmt_iterator gsi;
3055 gimple *stmt;
3056 int label_indent = indent - 2;
3058 if (label_indent < 0)
3059 label_indent = 0;
3061 dump_phi_nodes (buffer, bb, indent, flags);
3063 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
3065 int curr_indent;
3067 stmt = gsi_stmt (gsi);
3069 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
3071 INDENT (curr_indent);
3072 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
3073 pp_newline_and_flush (buffer);
3074 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
3075 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
3076 pp_buffer (buffer)->stream, stmt);
3079 dump_implicit_edges (buffer, bb, indent, flags);
3080 pp_flush (buffer);
3084 /* Dumps basic block BB to FILE with details described by FLAGS and
3085 indented by INDENT spaces. */
3087 void
3088 gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
3090 dump_gimple_bb_header (file, bb, indent, flags);
3091 if (bb->index >= NUM_FIXED_BLOCKS)
3093 pretty_printer buffer;
3094 pp_needs_newline (&buffer) = true;
3095 buffer.buffer->stream = file;
3096 gimple_dump_bb_buff (&buffer, bb, indent, flags);
3098 dump_gimple_bb_footer (file, bb, indent, flags);
3101 /* Dumps basic block BB to pretty-printer PP with default dump flags and
3102 no indentation, for use as a label of a DOT graph record-node.
3103 ??? Should just use gimple_dump_bb_buff here, except that value profiling
3104 histogram dumping doesn't know about pretty-printers. */
3106 void
3107 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
3109 pp_printf (pp, "<bb %d>:\n", bb->index);
3110 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3112 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
3113 gsi_next (&gsi))
3115 gphi *phi = gsi.phi ();
3116 if (!virtual_operand_p (gimple_phi_result (phi))
3117 || (dump_flags & TDF_VOPS))
3119 pp_bar (pp);
3120 pp_write_text_to_stream (pp);
3121 pp_string (pp, "# ");
3122 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
3123 pp_newline (pp);
3124 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3128 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
3129 gsi_next (&gsi))
3131 gimple *stmt = gsi_stmt (gsi);
3132 pp_bar (pp);
3133 pp_write_text_to_stream (pp);
3134 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
3135 pp_newline (pp);
3136 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3138 dump_implicit_edges (pp, bb, 0, dump_flags);
3139 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3142 #if __GNUC__ >= 10
3143 # pragma GCC diagnostic pop
3144 #endif