Avoid no-stack-protector-attr fails on hppa*-*-*.
[official-gcc.git] / gcc / gimple-pretty-print.c
blob1096f7b8dbe62d73fa7a1f8061b8395dddfd631b
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
3 Contributed by Aldy Hernandez <aldyh@redhat.com> and
4 Diego Novillo <dnovillo@google.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "dumpfile.h"
26 #include "backend.h"
27 #include "tree.h"
28 #include "gimple.h"
29 #include "gimple-predict.h"
30 #include "ssa.h"
31 #include "cgraph.h"
32 #include "gimple-pretty-print.h"
33 #include "internal-fn.h"
34 #include "tree-eh.h"
35 #include "gimple-iterator.h"
36 #include "tree-cfg.h"
37 #include "dumpfile.h" /* for dump_flags */
38 #include "value-prof.h"
39 #include "trans-mem.h"
40 #include "cfganal.h"
41 #include "stringpool.h"
42 #include "attribs.h"
43 #include "asan.h"
44 #include "cfgloop.h"
46 /* Disable warnings about quoting issues in the pp_xxx calls below
47 that (intentionally) don't follow GCC diagnostic conventions. */
48 #if __GNUC__ >= 10
49 # pragma GCC diagnostic push
50 # pragma GCC diagnostic ignored "-Wformat-diag"
51 #endif
53 #define INDENT(SPACE) \
54 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
56 #define GIMPLE_NIY do_niy (buffer,gs)
58 /* Try to print on BUFFER a default message for the unrecognized
59 gimple statement GS. */
61 static void
62 do_niy (pretty_printer *buffer, const gimple *gs)
64 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
65 gimple_code_name[(int) gimple_code (gs)]);
69 /* Emit a newline and SPC indentation spaces to BUFFER. */
71 static void
72 newline_and_indent (pretty_printer *buffer, int spc)
74 pp_newline (buffer);
75 INDENT (spc);
79 /* Print the GIMPLE statement GS on stderr. */
81 DEBUG_FUNCTION void
82 debug_gimple_stmt (gimple *gs)
84 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
88 /* Return formatted string of a VALUE probability
89 (biased by REG_BR_PROB_BASE). Returned string is allocated
90 by xstrdup_for_dump. */
92 static const char *
93 dump_profile (profile_count &count)
95 char *buf = NULL;
96 if (!count.initialized_p ())
97 return "";
98 if (count.ipa_p ())
99 buf = xasprintf ("[count: %" PRId64 "]",
100 count.to_gcov_type ());
101 else if (count.initialized_p ())
102 buf = xasprintf ("[local count: %" PRId64 "]",
103 count.to_gcov_type ());
105 const char *ret = xstrdup_for_dump (buf);
106 free (buf);
108 return ret;
111 /* Return formatted string of a VALUE probability
112 (biased by REG_BR_PROB_BASE). Returned string is allocated
113 by xstrdup_for_dump. */
115 static const char *
116 dump_probability (profile_probability probability)
118 float minimum = 0.01f;
119 float fvalue = -1;
121 if (probability.initialized_p ())
123 fvalue = probability.to_reg_br_prob_base () * 100.0f / REG_BR_PROB_BASE;
124 if (fvalue < minimum && probability.to_reg_br_prob_base ())
125 fvalue = minimum;
128 char *buf;
129 if (probability.initialized_p ())
130 buf = xasprintf ("[%.2f%%]", fvalue);
131 else
132 buf = xasprintf ("[INV]");
134 const char *ret = xstrdup_for_dump (buf);
135 free (buf);
137 return ret;
140 /* Dump E probability to BUFFER. */
142 static void
143 dump_edge_probability (pretty_printer *buffer, edge e)
145 pp_scalar (buffer, " %s", dump_probability (e->probability));
148 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
149 FLAGS as in pp_gimple_stmt_1. */
151 void
152 print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
154 pretty_printer buffer;
155 pp_needs_newline (&buffer) = true;
156 buffer.buffer->stream = file;
157 pp_gimple_stmt_1 (&buffer, g, spc, flags);
158 pp_newline_and_flush (&buffer);
161 DEBUG_FUNCTION void
162 debug (gimple &ref)
164 print_gimple_stmt (stderr, &ref, 0, TDF_NONE);
167 DEBUG_FUNCTION void
168 debug (gimple *ptr)
170 if (ptr)
171 debug (*ptr);
172 else
173 fprintf (stderr, "<nil>\n");
177 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
178 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
179 of the statement. */
181 void
182 print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
184 flags |= TDF_RHS_ONLY;
185 pretty_printer buffer;
186 pp_needs_newline (&buffer) = true;
187 buffer.buffer->stream = file;
188 pp_gimple_stmt_1 (&buffer, g, spc, flags);
189 pp_flush (&buffer);
193 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
194 spaces and FLAGS as in pp_gimple_stmt_1.
195 The caller is responsible for calling pp_flush on BUFFER to finalize
196 the pretty printer. */
198 static void
199 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc,
200 dump_flags_t flags)
202 gimple_stmt_iterator i;
204 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
206 gimple *gs = gsi_stmt (i);
207 INDENT (spc);
208 pp_gimple_stmt_1 (buffer, gs, spc, flags);
209 if (!gsi_one_before_end_p (i))
210 pp_newline (buffer);
215 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
216 FLAGS as in pp_gimple_stmt_1. */
218 void
219 print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
221 pretty_printer buffer;
222 pp_needs_newline (&buffer) = true;
223 buffer.buffer->stream = file;
224 dump_gimple_seq (&buffer, seq, spc, flags);
225 pp_newline_and_flush (&buffer);
229 /* Print the GIMPLE sequence SEQ on stderr. */
231 DEBUG_FUNCTION void
232 debug_gimple_seq (gimple_seq seq)
234 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
238 /* A simple helper to pretty-print some of the gimple tuples in the printf
239 style. The format modifiers are preceded by '%' and are:
240 'G' - outputs a string corresponding to the code of the given gimple,
241 'S' - outputs a gimple_seq with indent of spc + 2,
242 'T' - outputs the tree t,
243 'd' - outputs an int as a decimal,
244 's' - outputs a string,
245 'n' - outputs a newline,
246 'x' - outputs an int as hexadecimal,
247 '+' - increases indent by 2 then outputs a newline,
248 '-' - decreases indent by 2 then outputs a newline. */
250 static void
251 dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags,
252 const char *fmt, ...)
254 va_list args;
255 const char *c;
256 const char *tmp;
258 va_start (args, fmt);
259 for (c = fmt; *c; c++)
261 if (*c == '%')
263 gimple_seq seq;
264 tree t;
265 gimple *g;
266 switch (*++c)
268 case 'G':
269 g = va_arg (args, gimple *);
270 tmp = gimple_code_name[gimple_code (g)];
271 pp_string (buffer, tmp);
272 break;
274 case 'S':
275 seq = va_arg (args, gimple_seq);
276 pp_newline (buffer);
277 dump_gimple_seq (buffer, seq, spc + 2, flags);
278 newline_and_indent (buffer, spc);
279 break;
281 case 'T':
282 t = va_arg (args, tree);
283 if (t == NULL_TREE)
284 pp_string (buffer, "NULL");
285 else
286 dump_generic_node (buffer, t, spc, flags, false);
287 break;
289 case 'd':
290 pp_decimal_int (buffer, va_arg (args, int));
291 break;
293 case 's':
294 pp_string (buffer, va_arg (args, char *));
295 break;
297 case 'n':
298 newline_and_indent (buffer, spc);
299 break;
301 case 'x':
302 pp_scalar (buffer, "%x", va_arg (args, int));
303 break;
305 case '+':
306 spc += 2;
307 newline_and_indent (buffer, spc);
308 break;
310 case '-':
311 spc -= 2;
312 newline_and_indent (buffer, spc);
313 break;
315 default:
316 gcc_unreachable ();
319 else
320 pp_character (buffer, *c);
322 va_end (args);
326 /* Helper for dump_gimple_assign. Print the unary RHS of the
327 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
329 static void
330 dump_unary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
331 dump_flags_t flags)
333 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
334 tree lhs = gimple_assign_lhs (gs);
335 tree rhs = gimple_assign_rhs1 (gs);
337 switch (rhs_code)
339 case VIEW_CONVERT_EXPR:
340 case ASSERT_EXPR:
341 dump_generic_node (buffer, rhs, spc, flags, false);
342 break;
344 case FIXED_CONVERT_EXPR:
345 case ADDR_SPACE_CONVERT_EXPR:
346 case FIX_TRUNC_EXPR:
347 case FLOAT_EXPR:
348 CASE_CONVERT:
349 pp_left_paren (buffer);
350 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
351 pp_string (buffer, ") ");
352 if (op_prio (rhs) < op_code_prio (rhs_code))
354 pp_left_paren (buffer);
355 dump_generic_node (buffer, rhs, spc, flags, false);
356 pp_right_paren (buffer);
358 else
359 dump_generic_node (buffer, rhs, spc, flags, false);
360 break;
362 case PAREN_EXPR:
363 pp_string (buffer, "((");
364 dump_generic_node (buffer, rhs, spc, flags, false);
365 pp_string (buffer, "))");
366 break;
368 case ABS_EXPR:
369 case ABSU_EXPR:
370 if (flags & TDF_GIMPLE)
372 pp_string (buffer,
373 rhs_code == ABS_EXPR ? "__ABS " : "__ABSU ");
374 dump_generic_node (buffer, rhs, spc, flags, false);
376 else
378 pp_string (buffer,
379 rhs_code == ABS_EXPR ? "ABS_EXPR <" : "ABSU_EXPR <");
380 dump_generic_node (buffer, rhs, spc, flags, false);
381 pp_greater (buffer);
383 break;
385 default:
386 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
387 || TREE_CODE_CLASS (rhs_code) == tcc_constant
388 || TREE_CODE_CLASS (rhs_code) == tcc_reference
389 || rhs_code == SSA_NAME
390 || rhs_code == ADDR_EXPR
391 || rhs_code == CONSTRUCTOR)
393 dump_generic_node (buffer, rhs, spc, flags, false);
394 break;
396 else if (rhs_code == BIT_NOT_EXPR)
397 pp_complement (buffer);
398 else if (rhs_code == TRUTH_NOT_EXPR)
399 pp_exclamation (buffer);
400 else if (rhs_code == NEGATE_EXPR)
401 pp_minus (buffer);
402 else
404 pp_left_bracket (buffer);
405 pp_string (buffer, get_tree_code_name (rhs_code));
406 pp_string (buffer, "] ");
409 if (op_prio (rhs) < op_code_prio (rhs_code))
411 pp_left_paren (buffer);
412 dump_generic_node (buffer, rhs, spc, flags, false);
413 pp_right_paren (buffer);
415 else
416 dump_generic_node (buffer, rhs, spc, flags, false);
417 break;
422 /* Helper for dump_gimple_assign. Print the binary RHS of the
423 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
425 static void
426 dump_binary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
427 dump_flags_t flags)
429 const char *p;
430 enum tree_code code = gimple_assign_rhs_code (gs);
431 switch (code)
433 case MIN_EXPR:
434 case MAX_EXPR:
435 if (flags & TDF_GIMPLE)
437 pp_string (buffer, code == MIN_EXPR ? "__MIN (" : "__MAX (");
438 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
439 false);
440 pp_string (buffer, ", ");
441 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
442 false);
443 pp_string (buffer, ")");
444 break;
446 else
448 gcc_fallthrough ();
450 case COMPLEX_EXPR:
451 case VEC_WIDEN_MULT_HI_EXPR:
452 case VEC_WIDEN_MULT_LO_EXPR:
453 case VEC_WIDEN_MULT_EVEN_EXPR:
454 case VEC_WIDEN_MULT_ODD_EXPR:
455 case VEC_PACK_TRUNC_EXPR:
456 case VEC_PACK_SAT_EXPR:
457 case VEC_PACK_FIX_TRUNC_EXPR:
458 case VEC_PACK_FLOAT_EXPR:
459 case VEC_WIDEN_LSHIFT_HI_EXPR:
460 case VEC_WIDEN_LSHIFT_LO_EXPR:
461 case VEC_SERIES_EXPR:
462 for (p = get_tree_code_name (code); *p; p++)
463 pp_character (buffer, TOUPPER (*p));
464 pp_string (buffer, " <");
465 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
466 pp_string (buffer, ", ");
467 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
468 pp_greater (buffer);
469 break;
471 default:
472 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
474 pp_left_paren (buffer);
475 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
476 false);
477 pp_right_paren (buffer);
479 else
480 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
481 pp_space (buffer);
482 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
483 pp_space (buffer);
484 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
486 pp_left_paren (buffer);
487 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
488 false);
489 pp_right_paren (buffer);
491 else
492 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
496 /* Helper for dump_gimple_assign. Print the ternary RHS of the
497 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
499 static void
500 dump_ternary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
501 dump_flags_t flags)
503 const char *p;
504 enum tree_code code = gimple_assign_rhs_code (gs);
505 switch (code)
507 case WIDEN_MULT_PLUS_EXPR:
508 case WIDEN_MULT_MINUS_EXPR:
509 for (p = get_tree_code_name (code); *p; p++)
510 pp_character (buffer, TOUPPER (*p));
511 pp_string (buffer, " <");
512 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
513 pp_string (buffer, ", ");
514 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
515 pp_string (buffer, ", ");
516 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
517 pp_greater (buffer);
518 break;
520 case DOT_PROD_EXPR:
521 pp_string (buffer, "DOT_PROD_EXPR <");
522 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
523 pp_string (buffer, ", ");
524 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
525 pp_string (buffer, ", ");
526 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
527 pp_greater (buffer);
528 break;
530 case SAD_EXPR:
531 pp_string (buffer, "SAD_EXPR <");
532 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
533 pp_string (buffer, ", ");
534 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
535 pp_string (buffer, ", ");
536 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
537 pp_greater (buffer);
538 break;
540 case VEC_PERM_EXPR:
541 if (flags & TDF_GIMPLE)
542 pp_string (buffer, "__VEC_PERM (");
543 else
544 pp_string (buffer, "VEC_PERM_EXPR <");
545 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
546 pp_string (buffer, ", ");
547 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
548 pp_string (buffer, ", ");
549 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
550 if (flags & TDF_GIMPLE)
551 pp_right_paren (buffer);
552 else
553 pp_greater (buffer);
554 break;
556 case REALIGN_LOAD_EXPR:
557 pp_string (buffer, "REALIGN_LOAD <");
558 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
559 pp_string (buffer, ", ");
560 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
561 pp_string (buffer, ", ");
562 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
563 pp_greater (buffer);
564 break;
566 case COND_EXPR:
567 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
568 pp_string (buffer, " ? ");
569 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
570 pp_string (buffer, " : ");
571 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
572 break;
574 case VEC_COND_EXPR:
575 pp_string (buffer, "VEC_COND_EXPR <");
576 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
577 pp_string (buffer, ", ");
578 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
579 pp_string (buffer, ", ");
580 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
581 pp_greater (buffer);
582 break;
584 case BIT_INSERT_EXPR:
585 if (flags & TDF_GIMPLE)
587 pp_string (buffer, "__BIT_INSERT (");
588 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc,
589 flags | TDF_SLIM, false);
590 pp_string (buffer, ", ");
591 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc,
592 flags | TDF_SLIM, false);
593 pp_string (buffer, ", ");
594 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc,
595 flags | TDF_SLIM, false);
596 pp_right_paren (buffer);
598 else
600 pp_string (buffer, "BIT_INSERT_EXPR <");
601 dump_generic_node (buffer, gimple_assign_rhs1 (gs),
602 spc, flags, false);
603 pp_string (buffer, ", ");
604 dump_generic_node (buffer, gimple_assign_rhs2 (gs),
605 spc, flags, false);
606 pp_string (buffer, ", ");
607 dump_generic_node (buffer, gimple_assign_rhs3 (gs),
608 spc, flags, false);
609 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
611 pp_string (buffer, " (");
612 pp_decimal_int (buffer, TYPE_PRECISION
613 (TREE_TYPE (gimple_assign_rhs2 (gs))));
614 pp_string (buffer, " bits)");
616 pp_greater (buffer);
618 break;
620 default:
621 gcc_unreachable ();
626 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
627 pp_gimple_stmt_1. */
629 static void
630 dump_gimple_assign (pretty_printer *buffer, const gassign *gs, int spc,
631 dump_flags_t flags)
633 if (flags & TDF_RAW)
635 tree arg1 = NULL;
636 tree arg2 = NULL;
637 tree arg3 = NULL;
638 switch (gimple_num_ops (gs))
640 case 4:
641 arg3 = gimple_assign_rhs3 (gs);
642 /* FALLTHRU */
643 case 3:
644 arg2 = gimple_assign_rhs2 (gs);
645 /* FALLTHRU */
646 case 2:
647 arg1 = gimple_assign_rhs1 (gs);
648 break;
649 default:
650 gcc_unreachable ();
653 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
654 get_tree_code_name (gimple_assign_rhs_code (gs)),
655 gimple_assign_lhs (gs), arg1, arg2, arg3);
657 else
659 if (!(flags & TDF_RHS_ONLY))
661 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
662 pp_space (buffer);
663 pp_equal (buffer);
665 if (gimple_assign_nontemporal_move_p (gs))
666 pp_string (buffer, "{nt}");
668 if (gimple_has_volatile_ops (gs))
669 pp_string (buffer, "{v}");
671 pp_space (buffer);
674 if (gimple_num_ops (gs) == 2)
675 dump_unary_rhs (buffer, gs, spc, flags);
676 else if (gimple_num_ops (gs) == 3)
677 dump_binary_rhs (buffer, gs, spc, flags);
678 else if (gimple_num_ops (gs) == 4)
679 dump_ternary_rhs (buffer, gs, spc, flags);
680 else
681 gcc_unreachable ();
682 if (!(flags & TDF_RHS_ONLY))
683 pp_semicolon (buffer);
688 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
689 pp_gimple_stmt_1. */
691 static void
692 dump_gimple_return (pretty_printer *buffer, const greturn *gs, int spc,
693 dump_flags_t flags)
695 tree t;
697 t = gimple_return_retval (gs);
698 if (flags & TDF_RAW)
699 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
700 else
702 pp_string (buffer, "return");
703 if (t)
705 pp_space (buffer);
706 dump_generic_node (buffer, t, spc, flags, false);
708 pp_semicolon (buffer);
713 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
714 dump_gimple_call. */
716 static void
717 dump_gimple_call_args (pretty_printer *buffer, const gcall *gs,
718 dump_flags_t flags)
720 size_t i = 0;
722 /* Pretty print first arg to certain internal fns. */
723 if (gimple_call_internal_p (gs))
725 const char *const *enums = NULL;
726 unsigned limit = 0;
728 switch (gimple_call_internal_fn (gs))
730 case IFN_UNIQUE:
731 #define DEF(X) #X
732 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
733 #undef DEF
734 enums = unique_args;
736 limit = ARRAY_SIZE (unique_args);
737 break;
739 case IFN_GOACC_LOOP:
740 #define DEF(X) #X
741 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
742 #undef DEF
743 enums = loop_args;
744 limit = ARRAY_SIZE (loop_args);
745 break;
747 case IFN_GOACC_REDUCTION:
748 #define DEF(X) #X
749 static const char *const reduction_args[]
750 = {IFN_GOACC_REDUCTION_CODES};
751 #undef DEF
752 enums = reduction_args;
753 limit = ARRAY_SIZE (reduction_args);
754 break;
756 case IFN_HWASAN_MARK:
757 case IFN_ASAN_MARK:
758 #define DEF(X) #X
759 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
760 #undef DEF
761 enums = asan_mark_args;
762 limit = ARRAY_SIZE (asan_mark_args);
763 break;
765 default:
766 break;
768 if (limit)
770 tree arg0 = gimple_call_arg (gs, 0);
771 HOST_WIDE_INT v;
773 if (TREE_CODE (arg0) == INTEGER_CST
774 && tree_fits_shwi_p (arg0)
775 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
777 i++;
778 pp_string (buffer, enums[v]);
783 for (; i < gimple_call_num_args (gs); i++)
785 if (i)
786 pp_string (buffer, ", ");
787 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
790 if (gimple_call_va_arg_pack_p (gs))
792 if (i)
793 pp_string (buffer, ", ");
795 pp_string (buffer, "__builtin_va_arg_pack ()");
799 /* Dump the points-to solution *PT to BUFFER. */
801 static void
802 pp_points_to_solution (pretty_printer *buffer, const pt_solution *pt)
804 if (pt->anything)
806 pp_string (buffer, "anything ");
807 return;
809 if (pt->nonlocal)
810 pp_string (buffer, "nonlocal ");
811 if (pt->escaped)
812 pp_string (buffer, "escaped ");
813 if (pt->ipa_escaped)
814 pp_string (buffer, "unit-escaped ");
815 if (pt->null)
816 pp_string (buffer, "null ");
817 if (pt->vars
818 && !bitmap_empty_p (pt->vars))
820 bitmap_iterator bi;
821 unsigned i;
822 pp_string (buffer, "{ ");
823 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
825 pp_string (buffer, "D.");
826 pp_decimal_int (buffer, i);
827 pp_space (buffer);
829 pp_right_brace (buffer);
830 if (pt->vars_contains_nonlocal
831 || pt->vars_contains_escaped
832 || pt->vars_contains_escaped_heap
833 || pt->vars_contains_restrict)
835 const char *comma = "";
836 pp_string (buffer, " (");
837 if (pt->vars_contains_nonlocal)
839 pp_string (buffer, "nonlocal");
840 comma = ", ";
842 if (pt->vars_contains_escaped)
844 pp_string (buffer, comma);
845 pp_string (buffer, "escaped");
846 comma = ", ";
848 if (pt->vars_contains_escaped_heap)
850 pp_string (buffer, comma);
851 pp_string (buffer, "escaped heap");
852 comma = ", ";
854 if (pt->vars_contains_restrict)
856 pp_string (buffer, comma);
857 pp_string (buffer, "restrict");
858 comma = ", ";
860 if (pt->vars_contains_interposable)
862 pp_string (buffer, comma);
863 pp_string (buffer, "interposable");
865 pp_string (buffer, ")");
871 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
872 pp_gimple_stmt_1. */
874 static void
875 dump_gimple_call (pretty_printer *buffer, const gcall *gs, int spc,
876 dump_flags_t flags)
878 tree lhs = gimple_call_lhs (gs);
879 tree fn = gimple_call_fn (gs);
881 if (flags & TDF_ALIAS)
883 const pt_solution *pt;
884 pt = gimple_call_use_set (gs);
885 if (!pt_solution_empty_p (pt))
887 pp_string (buffer, "# USE = ");
888 pp_points_to_solution (buffer, pt);
889 newline_and_indent (buffer, spc);
891 pt = gimple_call_clobber_set (gs);
892 if (!pt_solution_empty_p (pt))
894 pp_string (buffer, "# CLB = ");
895 pp_points_to_solution (buffer, pt);
896 newline_and_indent (buffer, spc);
900 if (flags & TDF_RAW)
902 if (gimple_call_internal_p (gs))
903 dump_gimple_fmt (buffer, spc, flags, "%G <.%s, %T", gs,
904 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
905 else
906 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
907 if (gimple_call_num_args (gs) > 0)
909 pp_string (buffer, ", ");
910 dump_gimple_call_args (buffer, gs, flags);
912 pp_greater (buffer);
914 else
916 if (lhs && !(flags & TDF_RHS_ONLY))
918 dump_generic_node (buffer, lhs, spc, flags, false);
919 pp_string (buffer, " =");
921 if (gimple_has_volatile_ops (gs))
922 pp_string (buffer, "{v}");
924 pp_space (buffer);
926 if (gimple_call_internal_p (gs))
928 pp_dot (buffer);
929 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
931 else
932 print_call_name (buffer, fn, flags);
933 pp_string (buffer, " (");
934 dump_gimple_call_args (buffer, gs, flags);
935 pp_right_paren (buffer);
936 if (!(flags & TDF_RHS_ONLY))
937 pp_semicolon (buffer);
940 if (gimple_call_chain (gs))
942 pp_string (buffer, " [static-chain: ");
943 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
944 pp_right_bracket (buffer);
947 if (gimple_call_return_slot_opt_p (gs))
948 pp_string (buffer, " [return slot optimization]");
949 if (gimple_call_tail_p (gs))
950 pp_string (buffer, " [tail call]");
951 if (gimple_call_must_tail_p (gs))
952 pp_string (buffer, " [must tail call]");
954 if (fn == NULL)
955 return;
957 /* Dump the arguments of _ITM_beginTransaction sanely. */
958 if (TREE_CODE (fn) == ADDR_EXPR)
959 fn = TREE_OPERAND (fn, 0);
960 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
961 pp_string (buffer, " [tm-clone]");
962 if (TREE_CODE (fn) == FUNCTION_DECL
963 && fndecl_built_in_p (fn, BUILT_IN_TM_START)
964 && gimple_call_num_args (gs) > 0)
966 tree t = gimple_call_arg (gs, 0);
967 unsigned HOST_WIDE_INT props;
968 gcc_assert (TREE_CODE (t) == INTEGER_CST);
970 pp_string (buffer, " [ ");
972 /* Get the transaction code properties. */
973 props = TREE_INT_CST_LOW (t);
975 if (props & PR_INSTRUMENTEDCODE)
976 pp_string (buffer, "instrumentedCode ");
977 if (props & PR_UNINSTRUMENTEDCODE)
978 pp_string (buffer, "uninstrumentedCode ");
979 if (props & PR_HASNOXMMUPDATE)
980 pp_string (buffer, "hasNoXMMUpdate ");
981 if (props & PR_HASNOABORT)
982 pp_string (buffer, "hasNoAbort ");
983 if (props & PR_HASNOIRREVOCABLE)
984 pp_string (buffer, "hasNoIrrevocable ");
985 if (props & PR_DOESGOIRREVOCABLE)
986 pp_string (buffer, "doesGoIrrevocable ");
987 if (props & PR_HASNOSIMPLEREADS)
988 pp_string (buffer, "hasNoSimpleReads ");
989 if (props & PR_AWBARRIERSOMITTED)
990 pp_string (buffer, "awBarriersOmitted ");
991 if (props & PR_RARBARRIERSOMITTED)
992 pp_string (buffer, "RaRBarriersOmitted ");
993 if (props & PR_UNDOLOGCODE)
994 pp_string (buffer, "undoLogCode ");
995 if (props & PR_PREFERUNINSTRUMENTED)
996 pp_string (buffer, "preferUninstrumented ");
997 if (props & PR_EXCEPTIONBLOCK)
998 pp_string (buffer, "exceptionBlock ");
999 if (props & PR_HASELSE)
1000 pp_string (buffer, "hasElse ");
1001 if (props & PR_READONLY)
1002 pp_string (buffer, "readOnly ");
1004 pp_right_bracket (buffer);
1009 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
1010 pp_gimple_stmt_1. */
1012 static void
1013 dump_gimple_switch (pretty_printer *buffer, const gswitch *gs, int spc,
1014 dump_flags_t flags)
1016 unsigned int i;
1018 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
1019 if (flags & TDF_RAW)
1020 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
1021 gimple_switch_index (gs));
1022 else
1024 pp_string (buffer, "switch (");
1025 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
1026 if (flags & TDF_GIMPLE)
1027 pp_string (buffer, ") {");
1028 else
1029 pp_string (buffer, ") <");
1032 for (i = 0; i < gimple_switch_num_labels (gs); i++)
1034 tree case_label = gimple_switch_label (gs, i);
1035 gcc_checking_assert (case_label != NULL_TREE);
1036 dump_generic_node (buffer, case_label, spc, flags, false);
1037 pp_space (buffer);
1038 tree label = CASE_LABEL (case_label);
1039 dump_generic_node (buffer, label, spc, flags, false);
1041 if (cfun && cfun->cfg)
1043 basic_block dest = label_to_block (cfun, label);
1044 if (dest)
1046 edge label_edge = find_edge (gimple_bb (gs), dest);
1047 if (label_edge && !(flags & TDF_GIMPLE))
1048 dump_edge_probability (buffer, label_edge);
1052 if (i < gimple_switch_num_labels (gs) - 1)
1054 if (flags & TDF_GIMPLE)
1055 pp_string (buffer, "; ");
1056 else
1057 pp_string (buffer, ", ");
1060 if (flags & TDF_GIMPLE)
1061 pp_string (buffer, "; }");
1062 else
1063 pp_greater (buffer);
1067 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1068 pp_gimple_stmt_1. */
1070 static void
1071 dump_gimple_cond (pretty_printer *buffer, const gcond *gs, int spc,
1072 dump_flags_t flags)
1074 if (flags & TDF_RAW)
1075 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1076 get_tree_code_name (gimple_cond_code (gs)),
1077 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1078 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1079 else
1081 if (!(flags & TDF_RHS_ONLY))
1082 pp_string (buffer, "if (");
1083 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
1084 pp_space (buffer);
1085 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1086 pp_space (buffer);
1087 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
1088 if (!(flags & TDF_RHS_ONLY))
1090 edge_iterator ei;
1091 edge e, true_edge = NULL, false_edge = NULL;
1092 basic_block bb = gimple_bb (gs);
1094 if (bb)
1096 FOR_EACH_EDGE (e, ei, bb->succs)
1098 if (e->flags & EDGE_TRUE_VALUE)
1099 true_edge = e;
1100 else if (e->flags & EDGE_FALSE_VALUE)
1101 false_edge = e;
1105 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1107 pp_right_paren (buffer);
1109 if (gimple_cond_true_label (gs))
1111 pp_string (buffer, " goto ");
1112 dump_generic_node (buffer, gimple_cond_true_label (gs),
1113 spc, flags, false);
1114 if (has_edge_info && !(flags & TDF_GIMPLE))
1115 dump_edge_probability (buffer, true_edge);
1116 pp_semicolon (buffer);
1118 if (gimple_cond_false_label (gs))
1120 pp_string (buffer, " else goto ");
1121 dump_generic_node (buffer, gimple_cond_false_label (gs),
1122 spc, flags, false);
1123 if (has_edge_info && !(flags & TDF_GIMPLE))
1124 dump_edge_probability (buffer, false_edge);
1126 pp_semicolon (buffer);
1133 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1134 spaces of indent. FLAGS specifies details to show in the dump (see
1135 TDF_* in dumpfils.h). */
1137 static void
1138 dump_gimple_label (pretty_printer *buffer, const glabel *gs, int spc,
1139 dump_flags_t flags)
1141 tree label = gimple_label_label (gs);
1142 if (flags & TDF_RAW)
1143 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1144 else
1146 dump_generic_node (buffer, label, spc, flags, false);
1147 pp_colon (buffer);
1149 if (flags & TDF_GIMPLE)
1150 return;
1151 if (DECL_NONLOCAL (label))
1152 pp_string (buffer, " [non-local]");
1153 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1154 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1157 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1158 spaces of indent. FLAGS specifies details to show in the dump (see
1159 TDF_* in dumpfile.h). */
1161 static void
1162 dump_gimple_goto (pretty_printer *buffer, const ggoto *gs, int spc,
1163 dump_flags_t flags)
1165 tree label = gimple_goto_dest (gs);
1166 if (flags & TDF_RAW)
1167 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1168 else
1169 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1173 /* Dump a GIMPLE_BIND 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_bind (pretty_printer *buffer, const gbind *gs, int spc,
1179 dump_flags_t flags)
1181 if (flags & TDF_RAW)
1182 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1183 else
1184 pp_left_brace (buffer);
1185 if (!(flags & TDF_SLIM))
1187 tree var;
1189 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1191 newline_and_indent (buffer, 2);
1192 print_declaration (buffer, var, spc, flags);
1194 if (gimple_bind_vars (gs))
1195 pp_newline (buffer);
1197 pp_newline (buffer);
1198 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1199 newline_and_indent (buffer, spc);
1200 if (flags & TDF_RAW)
1201 pp_greater (buffer);
1202 else
1203 pp_right_brace (buffer);
1207 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1208 indent. FLAGS specifies details to show in the dump (see TDF_* in
1209 dumpfile.h). */
1211 static void
1212 dump_gimple_try (pretty_printer *buffer, const gtry *gs, int spc,
1213 dump_flags_t flags)
1215 if (flags & TDF_RAW)
1217 const char *type;
1218 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1219 type = "GIMPLE_TRY_CATCH";
1220 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1221 type = "GIMPLE_TRY_FINALLY";
1222 else
1223 type = "UNKNOWN GIMPLE_TRY";
1224 dump_gimple_fmt (buffer, spc, flags,
1225 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1226 gimple_try_eval (gs), gimple_try_cleanup (gs));
1228 else
1230 pp_string (buffer, "try");
1231 newline_and_indent (buffer, spc + 2);
1232 pp_left_brace (buffer);
1233 pp_newline (buffer);
1235 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1236 newline_and_indent (buffer, spc + 2);
1237 pp_right_brace (buffer);
1239 gimple_seq seq = gimple_try_cleanup (gs);
1241 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1243 newline_and_indent (buffer, spc);
1244 pp_string (buffer, "catch");
1245 newline_and_indent (buffer, spc + 2);
1246 pp_left_brace (buffer);
1248 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1250 newline_and_indent (buffer, spc);
1251 pp_string (buffer, "finally");
1252 newline_and_indent (buffer, spc + 2);
1253 pp_left_brace (buffer);
1255 if (seq && is_a <geh_else *> (gimple_seq_first_stmt (seq))
1256 && gimple_seq_nondebug_singleton_p (seq))
1258 geh_else *stmt = as_a <geh_else *> (gimple_seq_first_stmt (seq));
1259 seq = gimple_eh_else_n_body (stmt);
1260 pp_newline (buffer);
1261 dump_gimple_seq (buffer, seq, spc + 4, flags);
1262 newline_and_indent (buffer, spc + 2);
1263 pp_right_brace (buffer);
1264 seq = gimple_eh_else_e_body (stmt);
1265 newline_and_indent (buffer, spc);
1266 pp_string (buffer, "else");
1267 newline_and_indent (buffer, spc + 2);
1268 pp_left_brace (buffer);
1271 else
1272 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1274 pp_newline (buffer);
1275 dump_gimple_seq (buffer, seq, spc + 4, flags);
1276 newline_and_indent (buffer, spc + 2);
1277 pp_right_brace (buffer);
1282 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1283 indent. FLAGS specifies details to show in the dump (see TDF_* in
1284 dumpfile.h). */
1286 static void
1287 dump_gimple_catch (pretty_printer *buffer, const gcatch *gs, int spc,
1288 dump_flags_t flags)
1290 if (flags & TDF_RAW)
1291 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1292 gimple_catch_types (gs), gimple_catch_handler (gs));
1293 else
1294 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1295 gimple_catch_types (gs), gimple_catch_handler (gs));
1299 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1300 indent. FLAGS specifies details to show in the dump (see TDF_* in
1301 dumpfile.h). */
1303 static void
1304 dump_gimple_eh_filter (pretty_printer *buffer, const geh_filter *gs, int spc,
1305 dump_flags_t flags)
1307 if (flags & TDF_RAW)
1308 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1309 gimple_eh_filter_types (gs),
1310 gimple_eh_filter_failure (gs));
1311 else
1312 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1313 gimple_eh_filter_types (gs),
1314 gimple_eh_filter_failure (gs));
1318 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1320 static void
1321 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1322 const geh_mnt *gs, int spc, dump_flags_t flags)
1324 if (flags & TDF_RAW)
1325 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1326 gimple_eh_must_not_throw_fndecl (gs));
1327 else
1328 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1329 gimple_eh_must_not_throw_fndecl (gs));
1333 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1334 indent. FLAGS specifies details to show in the dump (see TDF_* in
1335 dumpfile.h). */
1337 static void
1338 dump_gimple_eh_else (pretty_printer *buffer, const geh_else *gs, int spc,
1339 dump_flags_t flags)
1341 if (flags & TDF_RAW)
1342 dump_gimple_fmt (buffer, spc, flags,
1343 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1344 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1345 else
1346 dump_gimple_fmt (buffer, spc, flags,
1347 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1348 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1352 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1353 indent. FLAGS specifies details to show in the dump (see TDF_* in
1354 dumpfile.h). */
1356 static void
1357 dump_gimple_resx (pretty_printer *buffer, const gresx *gs, int spc,
1358 dump_flags_t flags)
1360 if (flags & TDF_RAW)
1361 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1362 gimple_resx_region (gs));
1363 else
1364 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1367 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1369 static void
1370 dump_gimple_eh_dispatch (pretty_printer *buffer, const geh_dispatch *gs,
1371 int spc, dump_flags_t flags)
1373 if (flags & TDF_RAW)
1374 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1375 gimple_eh_dispatch_region (gs));
1376 else
1377 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1378 gimple_eh_dispatch_region (gs));
1381 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1382 of indent. FLAGS specifies details to show in the dump (see TDF_*
1383 in dumpfile.h). */
1385 static void
1386 dump_gimple_debug (pretty_printer *buffer, const gdebug *gs, int spc,
1387 dump_flags_t flags)
1389 switch (gs->subcode)
1391 case GIMPLE_DEBUG_BIND:
1392 if (flags & TDF_RAW)
1393 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1394 gimple_debug_bind_get_var (gs),
1395 gimple_debug_bind_get_value (gs));
1396 else
1397 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1398 gimple_debug_bind_get_var (gs),
1399 gimple_debug_bind_get_value (gs));
1400 break;
1402 case GIMPLE_DEBUG_SOURCE_BIND:
1403 if (flags & TDF_RAW)
1404 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1405 gimple_debug_source_bind_get_var (gs),
1406 gimple_debug_source_bind_get_value (gs));
1407 else
1408 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1409 gimple_debug_source_bind_get_var (gs),
1410 gimple_debug_source_bind_get_value (gs));
1411 break;
1413 case GIMPLE_DEBUG_BEGIN_STMT:
1414 if (flags & TDF_RAW)
1415 dump_gimple_fmt (buffer, spc, flags, "%G BEGIN_STMT", gs);
1416 else
1417 dump_gimple_fmt (buffer, spc, flags, "# DEBUG BEGIN_STMT");
1418 break;
1420 case GIMPLE_DEBUG_INLINE_ENTRY:
1421 if (flags & TDF_RAW)
1422 dump_gimple_fmt (buffer, spc, flags, "%G INLINE_ENTRY %T", gs,
1423 gimple_block (gs)
1424 ? block_ultimate_origin (gimple_block (gs))
1425 : NULL_TREE);
1426 else
1427 dump_gimple_fmt (buffer, spc, flags, "# DEBUG INLINE_ENTRY %T",
1428 gimple_block (gs)
1429 ? block_ultimate_origin (gimple_block (gs))
1430 : NULL_TREE);
1431 break;
1433 default:
1434 gcc_unreachable ();
1438 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1439 static void
1440 dump_gimple_omp_for (pretty_printer *buffer, const gomp_for *gs, int spc,
1441 dump_flags_t flags)
1443 size_t i;
1445 if (flags & TDF_RAW)
1447 const char *kind;
1448 switch (gimple_omp_for_kind (gs))
1450 case GF_OMP_FOR_KIND_FOR:
1451 kind = "";
1452 break;
1453 case GF_OMP_FOR_KIND_DISTRIBUTE:
1454 kind = " distribute";
1455 break;
1456 case GF_OMP_FOR_KIND_TASKLOOP:
1457 kind = " taskloop";
1458 break;
1459 case GF_OMP_FOR_KIND_OACC_LOOP:
1460 kind = " oacc_loop";
1461 break;
1462 case GF_OMP_FOR_KIND_SIMD:
1463 kind = " simd";
1464 break;
1465 default:
1466 gcc_unreachable ();
1468 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1469 kind, gimple_omp_body (gs));
1470 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1471 dump_gimple_fmt (buffer, spc, flags, " >,");
1472 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1473 dump_gimple_fmt (buffer, spc, flags,
1474 "%+%T, %T, %T, %s, %T,%n",
1475 gimple_omp_for_index (gs, i),
1476 gimple_omp_for_initial (gs, i),
1477 gimple_omp_for_final (gs, i),
1478 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1479 gimple_omp_for_incr (gs, i));
1480 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1481 gimple_omp_for_pre_body (gs));
1483 else
1485 switch (gimple_omp_for_kind (gs))
1487 case GF_OMP_FOR_KIND_FOR:
1488 pp_string (buffer, "#pragma omp for");
1489 break;
1490 case GF_OMP_FOR_KIND_DISTRIBUTE:
1491 pp_string (buffer, "#pragma omp distribute");
1492 break;
1493 case GF_OMP_FOR_KIND_TASKLOOP:
1494 pp_string (buffer, "#pragma omp taskloop");
1495 break;
1496 case GF_OMP_FOR_KIND_OACC_LOOP:
1497 pp_string (buffer, "#pragma acc loop");
1498 break;
1499 case GF_OMP_FOR_KIND_SIMD:
1500 pp_string (buffer, "#pragma omp simd");
1501 break;
1502 default:
1503 gcc_unreachable ();
1505 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1506 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1508 if (i)
1509 spc += 2;
1510 newline_and_indent (buffer, spc);
1511 pp_string (buffer, "for (");
1512 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1513 flags, false);
1514 pp_string (buffer, " = ");
1515 tree init = gimple_omp_for_initial (gs, i);
1516 if (TREE_CODE (init) != TREE_VEC)
1517 dump_generic_node (buffer, init, spc, flags, false);
1518 else
1519 dump_omp_loop_non_rect_expr (buffer, init, spc, flags);
1520 pp_string (buffer, "; ");
1522 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1523 flags, false);
1524 pp_space (buffer);
1525 switch (gimple_omp_for_cond (gs, i))
1527 case LT_EXPR:
1528 pp_less (buffer);
1529 break;
1530 case GT_EXPR:
1531 pp_greater (buffer);
1532 break;
1533 case LE_EXPR:
1534 pp_less_equal (buffer);
1535 break;
1536 case GE_EXPR:
1537 pp_greater_equal (buffer);
1538 break;
1539 case NE_EXPR:
1540 pp_string (buffer, "!=");
1541 break;
1542 default:
1543 gcc_unreachable ();
1545 pp_space (buffer);
1546 tree cond = gimple_omp_for_final (gs, i);
1547 if (TREE_CODE (cond) != TREE_VEC)
1548 dump_generic_node (buffer, cond, spc, flags, false);
1549 else
1550 dump_omp_loop_non_rect_expr (buffer, cond, spc, flags);
1551 pp_string (buffer, "; ");
1553 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1554 flags, false);
1555 pp_string (buffer, " = ");
1556 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1557 flags, false);
1558 pp_right_paren (buffer);
1561 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1563 newline_and_indent (buffer, spc + 2);
1564 pp_left_brace (buffer);
1565 pp_newline (buffer);
1566 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1567 newline_and_indent (buffer, spc + 2);
1568 pp_right_brace (buffer);
1573 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1575 static void
1576 dump_gimple_omp_continue (pretty_printer *buffer, const gomp_continue *gs,
1577 int spc, dump_flags_t flags)
1579 if (flags & TDF_RAW)
1581 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1582 gimple_omp_continue_control_def (gs),
1583 gimple_omp_continue_control_use (gs));
1585 else
1587 pp_string (buffer, "#pragma omp continue (");
1588 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1589 spc, flags, false);
1590 pp_comma (buffer);
1591 pp_space (buffer);
1592 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1593 spc, flags, false);
1594 pp_right_paren (buffer);
1598 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1600 static void
1601 dump_gimple_omp_single (pretty_printer *buffer, const gomp_single *gs,
1602 int spc, dump_flags_t flags)
1604 if (flags & TDF_RAW)
1606 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1607 gimple_omp_body (gs));
1608 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1609 dump_gimple_fmt (buffer, spc, flags, " >");
1611 else
1613 pp_string (buffer, "#pragma omp single");
1614 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1615 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1617 newline_and_indent (buffer, spc + 2);
1618 pp_left_brace (buffer);
1619 pp_newline (buffer);
1620 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1621 newline_and_indent (buffer, spc + 2);
1622 pp_right_brace (buffer);
1627 /* Dump a GIMPLE_OMP_TASKGROUP tuple on the pretty_printer BUFFER. */
1629 static void
1630 dump_gimple_omp_taskgroup (pretty_printer *buffer, const gimple *gs,
1631 int spc, dump_flags_t flags)
1633 if (flags & TDF_RAW)
1635 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1636 gimple_omp_body (gs));
1637 dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
1638 dump_gimple_fmt (buffer, spc, flags, " >");
1640 else
1642 pp_string (buffer, "#pragma omp taskgroup");
1643 dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
1644 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1646 newline_and_indent (buffer, spc + 2);
1647 pp_left_brace (buffer);
1648 pp_newline (buffer);
1649 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1650 newline_and_indent (buffer, spc + 2);
1651 pp_right_brace (buffer);
1656 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1658 static void
1659 dump_gimple_omp_target (pretty_printer *buffer, const gomp_target *gs,
1660 int spc, dump_flags_t flags)
1662 const char *kind;
1663 switch (gimple_omp_target_kind (gs))
1665 case GF_OMP_TARGET_KIND_REGION:
1666 kind = "";
1667 break;
1668 case GF_OMP_TARGET_KIND_DATA:
1669 kind = " data";
1670 break;
1671 case GF_OMP_TARGET_KIND_UPDATE:
1672 kind = " update";
1673 break;
1674 case GF_OMP_TARGET_KIND_ENTER_DATA:
1675 kind = " enter data";
1676 break;
1677 case GF_OMP_TARGET_KIND_EXIT_DATA:
1678 kind = " exit data";
1679 break;
1680 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1681 kind = " oacc_kernels";
1682 break;
1683 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1684 kind = " oacc_parallel";
1685 break;
1686 case GF_OMP_TARGET_KIND_OACC_SERIAL:
1687 kind = " oacc_serial";
1688 break;
1689 case GF_OMP_TARGET_KIND_OACC_DATA:
1690 kind = " oacc_data";
1691 break;
1692 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1693 kind = " oacc_update";
1694 break;
1695 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1696 kind = " oacc_enter_exit_data";
1697 break;
1698 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1699 kind = " oacc_declare";
1700 break;
1701 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1702 kind = " oacc_host_data";
1703 break;
1704 case GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_PARALLELIZED:
1705 kind = " oacc_parallel_kernels_parallelized";
1706 break;
1707 case GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_GANG_SINGLE:
1708 kind = " oacc_parallel_kernels_gang_single";
1709 break;
1710 case GF_OMP_TARGET_KIND_OACC_DATA_KERNELS:
1711 kind = " oacc_data_kernels";
1712 break;
1713 default:
1714 gcc_unreachable ();
1716 if (flags & TDF_RAW)
1718 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1719 kind, gimple_omp_body (gs));
1720 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1721 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1722 gimple_omp_target_child_fn (gs),
1723 gimple_omp_target_data_arg (gs));
1725 else
1727 pp_string (buffer, "#pragma omp target");
1728 pp_string (buffer, kind);
1729 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1730 if (gimple_omp_target_child_fn (gs))
1732 pp_string (buffer, " [child fn: ");
1733 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1734 spc, flags, false);
1735 pp_string (buffer, " (");
1736 if (gimple_omp_target_data_arg (gs))
1737 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1738 spc, flags, false);
1739 else
1740 pp_string (buffer, "???");
1741 pp_string (buffer, ")]");
1743 gimple_seq body = gimple_omp_body (gs);
1744 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1746 newline_and_indent (buffer, spc + 2);
1747 pp_left_brace (buffer);
1748 pp_newline (buffer);
1749 dump_gimple_seq (buffer, body, spc + 4, flags);
1750 newline_and_indent (buffer, spc + 2);
1751 pp_right_brace (buffer);
1753 else if (body)
1755 pp_newline (buffer);
1756 dump_gimple_seq (buffer, body, spc + 2, flags);
1761 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1763 static void
1764 dump_gimple_omp_teams (pretty_printer *buffer, const gomp_teams *gs, int spc,
1765 dump_flags_t flags)
1767 if (flags & TDF_RAW)
1769 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1770 gimple_omp_body (gs));
1771 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1772 dump_gimple_fmt (buffer, spc, flags, " >");
1774 else
1776 pp_string (buffer, "#pragma omp teams");
1777 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1778 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1780 newline_and_indent (buffer, spc + 2);
1781 pp_character (buffer, '{');
1782 pp_newline (buffer);
1783 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1784 newline_and_indent (buffer, spc + 2);
1785 pp_character (buffer, '}');
1790 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1792 static void
1793 dump_gimple_omp_sections (pretty_printer *buffer, const gomp_sections *gs,
1794 int spc, dump_flags_t flags)
1796 if (flags & TDF_RAW)
1798 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1799 gimple_omp_body (gs));
1800 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1801 dump_gimple_fmt (buffer, spc, flags, " >");
1803 else
1805 pp_string (buffer, "#pragma omp sections");
1806 if (gimple_omp_sections_control (gs))
1808 pp_string (buffer, " <");
1809 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1810 flags, false);
1811 pp_greater (buffer);
1813 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1814 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1816 newline_and_indent (buffer, spc + 2);
1817 pp_left_brace (buffer);
1818 pp_newline (buffer);
1819 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1820 newline_and_indent (buffer, spc + 2);
1821 pp_right_brace (buffer);
1826 /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the
1827 pretty_printer BUFFER. */
1829 static void
1830 dump_gimple_omp_block (pretty_printer *buffer, const gimple *gs, int spc,
1831 dump_flags_t flags)
1833 if (flags & TDF_RAW)
1834 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1835 gimple_omp_body (gs));
1836 else
1838 switch (gimple_code (gs))
1840 case GIMPLE_OMP_MASTER:
1841 pp_string (buffer, "#pragma omp master");
1842 break;
1843 case GIMPLE_OMP_SECTION:
1844 pp_string (buffer, "#pragma omp section");
1845 break;
1846 default:
1847 gcc_unreachable ();
1849 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1851 newline_and_indent (buffer, spc + 2);
1852 pp_left_brace (buffer);
1853 pp_newline (buffer);
1854 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1855 newline_and_indent (buffer, spc + 2);
1856 pp_right_brace (buffer);
1861 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1863 static void
1864 dump_gimple_omp_critical (pretty_printer *buffer, const gomp_critical *gs,
1865 int spc, dump_flags_t flags)
1867 if (flags & TDF_RAW)
1868 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1869 gimple_omp_body (gs));
1870 else
1872 pp_string (buffer, "#pragma omp critical");
1873 if (gimple_omp_critical_name (gs))
1875 pp_string (buffer, " (");
1876 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1877 flags, false);
1878 pp_right_paren (buffer);
1880 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1881 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1883 newline_and_indent (buffer, spc + 2);
1884 pp_left_brace (buffer);
1885 pp_newline (buffer);
1886 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1887 newline_and_indent (buffer, spc + 2);
1888 pp_right_brace (buffer);
1893 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1895 static void
1896 dump_gimple_omp_ordered (pretty_printer *buffer, const gomp_ordered *gs,
1897 int spc, dump_flags_t flags)
1899 if (flags & TDF_RAW)
1900 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1901 gimple_omp_body (gs));
1902 else
1904 pp_string (buffer, "#pragma omp ordered");
1905 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1906 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1908 newline_and_indent (buffer, spc + 2);
1909 pp_left_brace (buffer);
1910 pp_newline (buffer);
1911 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1912 newline_and_indent (buffer, spc + 2);
1913 pp_right_brace (buffer);
1918 /* Dump a GIMPLE_OMP_SCAN tuple on the pretty_printer BUFFER. */
1920 static void
1921 dump_gimple_omp_scan (pretty_printer *buffer, const gomp_scan *gs,
1922 int spc, dump_flags_t flags)
1924 if (flags & TDF_RAW)
1925 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1926 gimple_omp_body (gs));
1927 else
1929 if (gimple_omp_scan_clauses (gs))
1931 pp_string (buffer, "#pragma omp scan");
1932 dump_omp_clauses (buffer, gimple_omp_scan_clauses (gs), spc, flags);
1934 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1936 newline_and_indent (buffer, spc + 2);
1937 pp_left_brace (buffer);
1938 pp_newline (buffer);
1939 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1940 newline_and_indent (buffer, spc + 2);
1941 pp_right_brace (buffer);
1946 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1948 static void
1949 dump_gimple_omp_return (pretty_printer *buffer, const gimple *gs, int spc,
1950 dump_flags_t flags)
1952 if (flags & TDF_RAW)
1954 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1955 (int) gimple_omp_return_nowait_p (gs));
1956 if (gimple_omp_return_lhs (gs))
1957 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1958 gimple_omp_return_lhs (gs));
1959 else
1960 dump_gimple_fmt (buffer, spc, flags, ">");
1962 else
1964 pp_string (buffer, "#pragma omp return");
1965 if (gimple_omp_return_nowait_p (gs))
1966 pp_string (buffer, "(nowait)");
1967 if (gimple_omp_return_lhs (gs))
1969 pp_string (buffer, " (set ");
1970 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1971 spc, flags, false);
1972 pp_character (buffer, ')');
1977 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1979 static void
1980 dump_gimple_transaction (pretty_printer *buffer, const gtransaction *gs,
1981 int spc, dump_flags_t flags)
1983 unsigned subcode = gimple_transaction_subcode (gs);
1985 if (flags & TDF_RAW)
1987 dump_gimple_fmt (buffer, spc, flags,
1988 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1989 "<%+BODY <%S> >",
1990 gs, subcode, gimple_transaction_label_norm (gs),
1991 gimple_transaction_label_uninst (gs),
1992 gimple_transaction_label_over (gs),
1993 gimple_transaction_body (gs));
1995 else
1997 if (subcode & GTMA_IS_OUTER)
1998 pp_string (buffer, "__transaction_atomic [[outer]]");
1999 else if (subcode & GTMA_IS_RELAXED)
2000 pp_string (buffer, "__transaction_relaxed");
2001 else
2002 pp_string (buffer, "__transaction_atomic");
2003 subcode &= ~GTMA_DECLARATION_MASK;
2005 if (gimple_transaction_body (gs))
2007 newline_and_indent (buffer, spc + 2);
2008 pp_left_brace (buffer);
2009 pp_newline (buffer);
2010 dump_gimple_seq (buffer, gimple_transaction_body (gs),
2011 spc + 4, flags);
2012 newline_and_indent (buffer, spc + 2);
2013 pp_right_brace (buffer);
2015 else
2017 pp_string (buffer, " //");
2018 if (gimple_transaction_label_norm (gs))
2020 pp_string (buffer, " NORM=");
2021 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
2022 spc, flags, false);
2024 if (gimple_transaction_label_uninst (gs))
2026 pp_string (buffer, " UNINST=");
2027 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
2028 spc, flags, false);
2030 if (gimple_transaction_label_over (gs))
2032 pp_string (buffer, " OVER=");
2033 dump_generic_node (buffer, gimple_transaction_label_over (gs),
2034 spc, flags, false);
2036 if (subcode)
2038 pp_string (buffer, " SUBCODE=[ ");
2039 if (subcode & GTMA_HAVE_ABORT)
2041 pp_string (buffer, "GTMA_HAVE_ABORT ");
2042 subcode &= ~GTMA_HAVE_ABORT;
2044 if (subcode & GTMA_HAVE_LOAD)
2046 pp_string (buffer, "GTMA_HAVE_LOAD ");
2047 subcode &= ~GTMA_HAVE_LOAD;
2049 if (subcode & GTMA_HAVE_STORE)
2051 pp_string (buffer, "GTMA_HAVE_STORE ");
2052 subcode &= ~GTMA_HAVE_STORE;
2054 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
2056 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
2057 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
2059 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
2061 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
2062 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
2064 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
2066 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
2067 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
2069 if (subcode)
2070 pp_printf (buffer, "0x%x ", subcode);
2071 pp_right_bracket (buffer);
2077 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
2078 indent. FLAGS specifies details to show in the dump (see TDF_* in
2079 dumpfile.h). */
2081 static void
2082 dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc,
2083 dump_flags_t flags)
2085 unsigned int i, n, f, fields;
2087 if (flags & TDF_RAW)
2089 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
2090 gimple_asm_string (gs));
2092 n = gimple_asm_noutputs (gs);
2093 if (n)
2095 newline_and_indent (buffer, spc + 2);
2096 pp_string (buffer, "OUTPUT: ");
2097 for (i = 0; i < n; i++)
2099 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2100 spc, flags, false);
2101 if (i < n - 1)
2102 pp_string (buffer, ", ");
2106 n = gimple_asm_ninputs (gs);
2107 if (n)
2109 newline_and_indent (buffer, spc + 2);
2110 pp_string (buffer, "INPUT: ");
2111 for (i = 0; i < n; i++)
2113 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2114 spc, flags, false);
2115 if (i < n - 1)
2116 pp_string (buffer, ", ");
2120 n = gimple_asm_nclobbers (gs);
2121 if (n)
2123 newline_and_indent (buffer, spc + 2);
2124 pp_string (buffer, "CLOBBER: ");
2125 for (i = 0; i < n; i++)
2127 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2128 spc, flags, false);
2129 if (i < n - 1)
2130 pp_string (buffer, ", ");
2134 n = gimple_asm_nlabels (gs);
2135 if (n)
2137 newline_and_indent (buffer, spc + 2);
2138 pp_string (buffer, "LABEL: ");
2139 for (i = 0; i < n; i++)
2141 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2142 spc, flags, false);
2143 if (i < n - 1)
2144 pp_string (buffer, ", ");
2148 newline_and_indent (buffer, spc);
2149 pp_greater (buffer);
2151 else
2153 pp_string (buffer, "__asm__");
2154 if (gimple_asm_volatile_p (gs))
2155 pp_string (buffer, " __volatile__");
2156 if (gimple_asm_inline_p (gs))
2157 pp_string (buffer, " __inline__");
2158 if (gimple_asm_nlabels (gs))
2159 pp_string (buffer, " goto");
2160 pp_string (buffer, "(\"");
2161 pp_string (buffer, gimple_asm_string (gs));
2162 pp_string (buffer, "\"");
2164 if (gimple_asm_nlabels (gs))
2165 fields = 4;
2166 else if (gimple_asm_nclobbers (gs))
2167 fields = 3;
2168 else if (gimple_asm_ninputs (gs))
2169 fields = 2;
2170 else if (gimple_asm_noutputs (gs))
2171 fields = 1;
2172 else
2173 fields = 0;
2175 for (f = 0; f < fields; ++f)
2177 pp_string (buffer, " : ");
2179 switch (f)
2181 case 0:
2182 n = gimple_asm_noutputs (gs);
2183 for (i = 0; i < n; i++)
2185 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2186 spc, flags, false);
2187 if (i < n - 1)
2188 pp_string (buffer, ", ");
2190 break;
2192 case 1:
2193 n = gimple_asm_ninputs (gs);
2194 for (i = 0; i < n; i++)
2196 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2197 spc, flags, false);
2198 if (i < n - 1)
2199 pp_string (buffer, ", ");
2201 break;
2203 case 2:
2204 n = gimple_asm_nclobbers (gs);
2205 for (i = 0; i < n; i++)
2207 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2208 spc, flags, false);
2209 if (i < n - 1)
2210 pp_string (buffer, ", ");
2212 break;
2214 case 3:
2215 n = gimple_asm_nlabels (gs);
2216 for (i = 0; i < n; i++)
2218 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2219 spc, flags, false);
2220 if (i < n - 1)
2221 pp_string (buffer, ", ");
2223 break;
2225 default:
2226 gcc_unreachable ();
2230 pp_string (buffer, ");");
2234 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2235 SPC spaces of indent. */
2237 static void
2238 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2240 if (TREE_CODE (node) != SSA_NAME)
2241 return;
2243 if (POINTER_TYPE_P (TREE_TYPE (node))
2244 && SSA_NAME_PTR_INFO (node))
2246 unsigned int align, misalign;
2247 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2248 pp_string (buffer, "# PT = ");
2249 pp_points_to_solution (buffer, &pi->pt);
2250 newline_and_indent (buffer, spc);
2251 if (get_ptr_info_alignment (pi, &align, &misalign))
2253 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2254 newline_and_indent (buffer, spc);
2258 if (!POINTER_TYPE_P (TREE_TYPE (node))
2259 && SSA_NAME_RANGE_INFO (node))
2261 wide_int min, max, nonzero_bits;
2262 value_range_kind range_type = get_range_info (node, &min, &max);
2264 if (range_type == VR_VARYING)
2265 pp_printf (buffer, "# RANGE VR_VARYING");
2266 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2268 pp_printf (buffer, "# RANGE ");
2269 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2270 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2271 pp_printf (buffer, ", ");
2272 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2273 pp_printf (buffer, "]");
2275 nonzero_bits = get_nonzero_bits (node);
2276 if (nonzero_bits != -1)
2278 pp_string (buffer, " NONZERO ");
2279 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2281 newline_and_indent (buffer, spc);
2285 /* As dump_ssaname_info, but dump to FILE. */
2287 void
2288 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2290 pretty_printer buffer;
2291 pp_needs_newline (&buffer) = true;
2292 buffer.buffer->stream = file;
2293 dump_ssaname_info (&buffer, node, spc);
2294 pp_flush (&buffer);
2297 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2298 The caller is responsible for calling pp_flush on BUFFER to finalize
2299 pretty printer. If COMMENT is true, print this after #. */
2301 static void
2302 dump_gimple_phi (pretty_printer *buffer, const gphi *phi, int spc, bool comment,
2303 dump_flags_t flags)
2305 size_t i;
2306 tree lhs = gimple_phi_result (phi);
2308 if (flags & TDF_ALIAS)
2309 dump_ssaname_info (buffer, lhs, spc);
2311 if (comment)
2312 pp_string (buffer, "# ");
2314 if (flags & TDF_RAW)
2315 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2316 gimple_phi_result (phi));
2317 else
2319 dump_generic_node (buffer, lhs, spc, flags, false);
2320 if (flags & TDF_GIMPLE)
2321 pp_string (buffer, " = __PHI (");
2322 else
2323 pp_string (buffer, " = PHI <");
2325 for (i = 0; i < gimple_phi_num_args (phi); i++)
2327 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2328 dump_location (buffer, gimple_phi_arg_location (phi, i));
2329 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2330 if (flags & TDF_GIMPLE)
2332 pp_string (buffer, "__BB");
2333 pp_decimal_int (buffer, src->index);
2334 pp_string (buffer, ": ");
2336 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2337 false);
2338 if (! (flags & TDF_GIMPLE))
2340 pp_left_paren (buffer);
2341 pp_decimal_int (buffer, src->index);
2342 pp_right_paren (buffer);
2344 if (i < gimple_phi_num_args (phi) - 1)
2345 pp_string (buffer, ", ");
2347 if (flags & TDF_GIMPLE)
2348 pp_string (buffer, ");");
2349 else
2350 pp_greater (buffer);
2354 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2355 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2356 dumpfile.h). */
2358 static void
2359 dump_gimple_omp_parallel (pretty_printer *buffer, const gomp_parallel *gs,
2360 int spc, dump_flags_t flags)
2362 if (flags & TDF_RAW)
2364 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2365 gimple_omp_body (gs));
2366 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2367 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2368 gimple_omp_parallel_child_fn (gs),
2369 gimple_omp_parallel_data_arg (gs));
2371 else
2373 gimple_seq body;
2374 pp_string (buffer, "#pragma omp parallel");
2375 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2376 if (gimple_omp_parallel_child_fn (gs))
2378 pp_string (buffer, " [child fn: ");
2379 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2380 spc, flags, false);
2381 pp_string (buffer, " (");
2382 if (gimple_omp_parallel_data_arg (gs))
2383 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2384 spc, flags, false);
2385 else
2386 pp_string (buffer, "???");
2387 pp_string (buffer, ")]");
2389 body = gimple_omp_body (gs);
2390 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2392 newline_and_indent (buffer, spc + 2);
2393 pp_left_brace (buffer);
2394 pp_newline (buffer);
2395 dump_gimple_seq (buffer, body, spc + 4, flags);
2396 newline_and_indent (buffer, spc + 2);
2397 pp_right_brace (buffer);
2399 else if (body)
2401 pp_newline (buffer);
2402 dump_gimple_seq (buffer, body, spc + 2, flags);
2408 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2409 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2410 dumpfile.h). */
2412 static void
2413 dump_gimple_omp_task (pretty_printer *buffer, const gomp_task *gs, int spc,
2414 dump_flags_t flags)
2416 if (flags & TDF_RAW)
2418 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2419 gimple_omp_body (gs));
2420 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2421 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2422 gimple_omp_task_child_fn (gs),
2423 gimple_omp_task_data_arg (gs),
2424 gimple_omp_task_copy_fn (gs),
2425 gimple_omp_task_arg_size (gs),
2426 gimple_omp_task_arg_size (gs));
2428 else
2430 gimple_seq body;
2431 if (gimple_omp_task_taskloop_p (gs))
2432 pp_string (buffer, "#pragma omp taskloop");
2433 else if (gimple_omp_task_taskwait_p (gs))
2434 pp_string (buffer, "#pragma omp taskwait");
2435 else
2436 pp_string (buffer, "#pragma omp task");
2437 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2438 if (gimple_omp_task_child_fn (gs))
2440 pp_string (buffer, " [child fn: ");
2441 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2442 spc, flags, false);
2443 pp_string (buffer, " (");
2444 if (gimple_omp_task_data_arg (gs))
2445 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2446 spc, flags, false);
2447 else
2448 pp_string (buffer, "???");
2449 pp_string (buffer, ")]");
2451 body = gimple_omp_body (gs);
2452 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2454 newline_and_indent (buffer, spc + 2);
2455 pp_left_brace (buffer);
2456 pp_newline (buffer);
2457 dump_gimple_seq (buffer, body, spc + 4, flags);
2458 newline_and_indent (buffer, spc + 2);
2459 pp_right_brace (buffer);
2461 else if (body)
2463 pp_newline (buffer);
2464 dump_gimple_seq (buffer, body, spc + 2, flags);
2470 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2471 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2472 in dumpfile.h). */
2474 static void
2475 dump_gimple_omp_atomic_load (pretty_printer *buffer, const gomp_atomic_load *gs,
2476 int spc, dump_flags_t flags)
2478 if (flags & TDF_RAW)
2480 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2481 gimple_omp_atomic_load_lhs (gs),
2482 gimple_omp_atomic_load_rhs (gs));
2484 else
2486 pp_string (buffer, "#pragma omp atomic_load");
2487 dump_omp_atomic_memory_order (buffer,
2488 gimple_omp_atomic_memory_order (gs));
2489 if (gimple_omp_atomic_need_value_p (gs))
2490 pp_string (buffer, " [needed]");
2491 newline_and_indent (buffer, spc + 2);
2492 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2493 spc, flags, false);
2494 pp_space (buffer);
2495 pp_equal (buffer);
2496 pp_space (buffer);
2497 pp_star (buffer);
2498 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2499 spc, flags, false);
2503 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2504 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2505 in dumpfile.h). */
2507 static void
2508 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2509 const gomp_atomic_store *gs, int spc,
2510 dump_flags_t flags)
2512 if (flags & TDF_RAW)
2514 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2515 gimple_omp_atomic_store_val (gs));
2517 else
2519 pp_string (buffer, "#pragma omp atomic_store");
2520 dump_omp_atomic_memory_order (buffer,
2521 gimple_omp_atomic_memory_order (gs));
2522 pp_space (buffer);
2523 if (gimple_omp_atomic_need_value_p (gs))
2524 pp_string (buffer, "[needed] ");
2525 pp_left_paren (buffer);
2526 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2527 spc, flags, false);
2528 pp_right_paren (buffer);
2533 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2534 FLAGS are as in pp_gimple_stmt_1. */
2536 static void
2537 dump_gimple_mem_ops (pretty_printer *buffer, const gimple *gs, int spc,
2538 dump_flags_t flags)
2540 tree vdef = gimple_vdef (gs);
2541 tree vuse = gimple_vuse (gs);
2543 if (vdef != NULL_TREE)
2545 pp_string (buffer, "# ");
2546 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2547 pp_string (buffer, " = VDEF <");
2548 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2549 pp_greater (buffer);
2550 newline_and_indent (buffer, spc);
2552 else if (vuse != NULL_TREE)
2554 pp_string (buffer, "# VUSE <");
2555 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2556 pp_greater (buffer);
2557 newline_and_indent (buffer, spc);
2562 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2563 spaces of indent. FLAGS specifies details to show in the dump (see
2564 TDF_* in dumpfile.h). The caller is responsible for calling
2565 pp_flush on BUFFER to finalize the pretty printer. */
2567 void
2568 pp_gimple_stmt_1 (pretty_printer *buffer, const gimple *gs, int spc,
2569 dump_flags_t flags)
2571 if (!gs)
2572 return;
2574 if (flags & TDF_STMTADDR)
2575 pp_printf (buffer, "<&%p> ", (const void *) gs);
2577 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2578 dump_location (buffer, gimple_location (gs));
2580 if (flags & TDF_EH)
2582 int lp_nr = lookup_stmt_eh_lp (gs);
2583 if (lp_nr > 0)
2584 pp_printf (buffer, "[LP %d] ", lp_nr);
2585 else if (lp_nr < 0)
2586 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2589 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2590 && gimple_has_mem_ops (gs))
2591 dump_gimple_mem_ops (buffer, gs, spc, flags);
2593 if (gimple_has_lhs (gs)
2594 && (flags & TDF_ALIAS))
2595 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2597 switch (gimple_code (gs))
2599 case GIMPLE_ASM:
2600 dump_gimple_asm (buffer, as_a <const gasm *> (gs), spc, flags);
2601 break;
2603 case GIMPLE_ASSIGN:
2604 dump_gimple_assign (buffer, as_a <const gassign *> (gs), spc, flags);
2605 break;
2607 case GIMPLE_BIND:
2608 dump_gimple_bind (buffer, as_a <const gbind *> (gs), spc, flags);
2609 break;
2611 case GIMPLE_CALL:
2612 dump_gimple_call (buffer, as_a <const gcall *> (gs), spc, flags);
2613 break;
2615 case GIMPLE_COND:
2616 dump_gimple_cond (buffer, as_a <const gcond *> (gs), spc, flags);
2617 break;
2619 case GIMPLE_LABEL:
2620 dump_gimple_label (buffer, as_a <const glabel *> (gs), spc, flags);
2621 break;
2623 case GIMPLE_GOTO:
2624 dump_gimple_goto (buffer, as_a <const ggoto *> (gs), spc, flags);
2625 break;
2627 case GIMPLE_NOP:
2628 pp_string (buffer, "GIMPLE_NOP");
2629 break;
2631 case GIMPLE_RETURN:
2632 dump_gimple_return (buffer, as_a <const greturn *> (gs), spc, flags);
2633 break;
2635 case GIMPLE_SWITCH:
2636 dump_gimple_switch (buffer, as_a <const gswitch *> (gs), spc, flags);
2637 break;
2639 case GIMPLE_TRY:
2640 dump_gimple_try (buffer, as_a <const gtry *> (gs), spc, flags);
2641 break;
2643 case GIMPLE_PHI:
2644 dump_gimple_phi (buffer, as_a <const gphi *> (gs), spc, false, flags);
2645 break;
2647 case GIMPLE_OMP_PARALLEL:
2648 dump_gimple_omp_parallel (buffer, as_a <const gomp_parallel *> (gs), spc,
2649 flags);
2650 break;
2652 case GIMPLE_OMP_TASK:
2653 dump_gimple_omp_task (buffer, as_a <const gomp_task *> (gs), spc, flags);
2654 break;
2656 case GIMPLE_OMP_ATOMIC_LOAD:
2657 dump_gimple_omp_atomic_load (buffer, as_a <const gomp_atomic_load *> (gs),
2658 spc, flags);
2659 break;
2661 case GIMPLE_OMP_ATOMIC_STORE:
2662 dump_gimple_omp_atomic_store (buffer,
2663 as_a <const gomp_atomic_store *> (gs),
2664 spc, flags);
2665 break;
2667 case GIMPLE_OMP_FOR:
2668 dump_gimple_omp_for (buffer, as_a <const gomp_for *> (gs), spc, flags);
2669 break;
2671 case GIMPLE_OMP_CONTINUE:
2672 dump_gimple_omp_continue (buffer, as_a <const gomp_continue *> (gs), spc,
2673 flags);
2674 break;
2676 case GIMPLE_OMP_SINGLE:
2677 dump_gimple_omp_single (buffer, as_a <const gomp_single *> (gs), spc,
2678 flags);
2679 break;
2681 case GIMPLE_OMP_TARGET:
2682 dump_gimple_omp_target (buffer, as_a <const gomp_target *> (gs), spc,
2683 flags);
2684 break;
2686 case GIMPLE_OMP_TEAMS:
2687 dump_gimple_omp_teams (buffer, as_a <const gomp_teams *> (gs), spc,
2688 flags);
2689 break;
2691 case GIMPLE_OMP_RETURN:
2692 dump_gimple_omp_return (buffer, gs, spc, flags);
2693 break;
2695 case GIMPLE_OMP_SECTIONS:
2696 dump_gimple_omp_sections (buffer, as_a <const gomp_sections *> (gs),
2697 spc, flags);
2698 break;
2700 case GIMPLE_OMP_SECTIONS_SWITCH:
2701 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2702 break;
2704 case GIMPLE_OMP_TASKGROUP:
2705 dump_gimple_omp_taskgroup (buffer, gs, spc, flags);
2706 break;
2708 case GIMPLE_OMP_MASTER:
2709 case GIMPLE_OMP_SECTION:
2710 dump_gimple_omp_block (buffer, gs, spc, flags);
2711 break;
2713 case GIMPLE_OMP_ORDERED:
2714 dump_gimple_omp_ordered (buffer, as_a <const gomp_ordered *> (gs), spc,
2715 flags);
2716 break;
2718 case GIMPLE_OMP_SCAN:
2719 dump_gimple_omp_scan (buffer, as_a <const gomp_scan *> (gs), spc,
2720 flags);
2721 break;
2723 case GIMPLE_OMP_CRITICAL:
2724 dump_gimple_omp_critical (buffer, as_a <const gomp_critical *> (gs), spc,
2725 flags);
2726 break;
2728 case GIMPLE_CATCH:
2729 dump_gimple_catch (buffer, as_a <const gcatch *> (gs), spc, flags);
2730 break;
2732 case GIMPLE_EH_FILTER:
2733 dump_gimple_eh_filter (buffer, as_a <const geh_filter *> (gs), spc,
2734 flags);
2735 break;
2737 case GIMPLE_EH_MUST_NOT_THROW:
2738 dump_gimple_eh_must_not_throw (buffer,
2739 as_a <const geh_mnt *> (gs),
2740 spc, flags);
2741 break;
2743 case GIMPLE_EH_ELSE:
2744 dump_gimple_eh_else (buffer, as_a <const geh_else *> (gs), spc, flags);
2745 break;
2747 case GIMPLE_RESX:
2748 dump_gimple_resx (buffer, as_a <const gresx *> (gs), spc, flags);
2749 break;
2751 case GIMPLE_EH_DISPATCH:
2752 dump_gimple_eh_dispatch (buffer, as_a <const geh_dispatch *> (gs), spc,
2753 flags);
2754 break;
2756 case GIMPLE_DEBUG:
2757 dump_gimple_debug (buffer, as_a <const gdebug *> (gs), spc, flags);
2758 break;
2760 case GIMPLE_PREDICT:
2761 pp_string (buffer, "// predicted ");
2762 if (gimple_predict_outcome (gs))
2763 pp_string (buffer, "likely by ");
2764 else
2765 pp_string (buffer, "unlikely by ");
2766 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2767 pp_string (buffer, " predictor.");
2768 break;
2770 case GIMPLE_TRANSACTION:
2771 dump_gimple_transaction (buffer, as_a <const gtransaction *> (gs), spc,
2772 flags);
2773 break;
2775 default:
2776 GIMPLE_NIY;
2781 /* Dumps header of basic block BB to OUTF indented by INDENT
2782 spaces and details described by flags. */
2784 static void
2785 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
2786 dump_flags_t flags)
2788 if (flags & TDF_BLOCKS)
2790 if (flags & TDF_LINENO)
2792 gimple_stmt_iterator gsi;
2794 fputs (";; ", outf);
2796 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2797 if (!is_gimple_debug (gsi_stmt (gsi))
2798 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2800 fprintf (outf, "%*sstarting at line %d",
2801 indent, "", get_lineno (gsi_stmt (gsi)));
2802 break;
2804 if (bb->discriminator)
2805 fprintf (outf, ", discriminator %i", bb->discriminator);
2806 fputc ('\n', outf);
2809 else
2811 if (flags & TDF_GIMPLE)
2813 fprintf (outf, "%*s__BB(%d", indent, "", bb->index);
2814 if (bb->loop_father->header == bb)
2815 fprintf (outf, ",loop_header(%d)", bb->loop_father->num);
2816 if (bb->count.initialized_p ())
2817 fprintf (outf, ",%s(%d)",
2818 profile_quality_as_string (bb->count.quality ()),
2819 bb->count.value ());
2820 fprintf (outf, "):\n");
2822 else
2823 fprintf (outf, "%*s<bb %d> %s:\n",
2824 indent, "", bb->index, dump_profile (bb->count));
2829 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2830 spaces. */
2832 static void
2833 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2834 basic_block bb ATTRIBUTE_UNUSED,
2835 int indent ATTRIBUTE_UNUSED,
2836 dump_flags_t flags ATTRIBUTE_UNUSED)
2838 /* There is currently no GIMPLE-specific basic block info to dump. */
2839 return;
2843 /* Dump PHI nodes of basic block BB to BUFFER with details described
2844 by FLAGS and indented by INDENT spaces. */
2846 static void
2847 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
2848 dump_flags_t flags)
2850 gphi_iterator i;
2852 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2854 gphi *phi = i.phi ();
2855 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2857 INDENT (indent);
2858 dump_gimple_phi (buffer, phi, indent,
2859 (flags & TDF_GIMPLE) ? false : true, flags);
2860 pp_newline (buffer);
2866 /* Dump jump to basic block BB that is represented implicitly in the cfg
2867 to BUFFER. */
2869 static void
2870 pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
2872 if (flags & TDF_GIMPLE)
2874 pp_string (buffer, "goto __BB");
2875 pp_decimal_int (buffer, e->dest->index);
2876 if (e->probability.initialized_p ())
2878 pp_string (buffer, "(");
2879 pp_string (buffer,
2880 profile_quality_as_string (e->probability.quality ()));
2881 pp_string (buffer, "(");
2882 pp_decimal_int (buffer, e->probability.value ());
2883 pp_string (buffer, "))");
2885 pp_semicolon (buffer);
2887 else
2889 pp_string (buffer, "goto <bb ");
2890 pp_decimal_int (buffer, e->dest->index);
2891 pp_greater (buffer);
2892 pp_semicolon (buffer);
2894 dump_edge_probability (buffer, e);
2899 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2900 by INDENT spaces, with details given by FLAGS. */
2902 static void
2903 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2904 dump_flags_t flags)
2906 edge e;
2907 gimple *stmt;
2909 stmt = last_stmt (bb);
2911 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2913 edge true_edge, false_edge;
2915 /* When we are emitting the code or changing CFG, it is possible that
2916 the edges are not yet created. When we are using debug_bb in such
2917 a situation, we do not want it to crash. */
2918 if (EDGE_COUNT (bb->succs) != 2)
2919 return;
2920 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2922 INDENT (indent + 2);
2923 pp_cfg_jump (buffer, true_edge, flags);
2924 newline_and_indent (buffer, indent);
2925 pp_string (buffer, "else");
2926 newline_and_indent (buffer, indent + 2);
2927 pp_cfg_jump (buffer, false_edge, flags);
2928 pp_newline (buffer);
2929 return;
2932 /* If there is a fallthru edge, we may need to add an artificial
2933 goto to the dump. */
2934 e = find_fallthru_edge (bb->succs);
2936 if (e && (e->dest != bb->next_bb || (flags & TDF_GIMPLE)))
2938 INDENT (indent);
2940 if ((flags & TDF_LINENO)
2941 && e->goto_locus != UNKNOWN_LOCATION)
2942 dump_location (buffer, e->goto_locus);
2944 pp_cfg_jump (buffer, e, flags);
2945 pp_newline (buffer);
2950 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2951 indented by INDENT spaces. */
2953 static void
2954 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2955 dump_flags_t flags)
2957 gimple_stmt_iterator gsi;
2958 gimple *stmt;
2959 int label_indent = indent - 2;
2961 if (label_indent < 0)
2962 label_indent = 0;
2964 dump_phi_nodes (buffer, bb, indent, flags);
2966 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2968 int curr_indent;
2970 stmt = gsi_stmt (gsi);
2972 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2974 INDENT (curr_indent);
2975 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2976 pp_newline_and_flush (buffer);
2977 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2978 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2979 pp_buffer (buffer)->stream, stmt);
2982 dump_implicit_edges (buffer, bb, indent, flags);
2983 pp_flush (buffer);
2987 /* Dumps basic block BB to FILE with details described by FLAGS and
2988 indented by INDENT spaces. */
2990 void
2991 gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
2993 dump_gimple_bb_header (file, bb, indent, flags);
2994 if (bb->index >= NUM_FIXED_BLOCKS)
2996 pretty_printer buffer;
2997 pp_needs_newline (&buffer) = true;
2998 buffer.buffer->stream = file;
2999 gimple_dump_bb_buff (&buffer, bb, indent, flags);
3001 dump_gimple_bb_footer (file, bb, indent, flags);
3004 /* Dumps basic block BB to pretty-printer PP with default dump flags and
3005 no indentation, for use as a label of a DOT graph record-node.
3006 ??? Should just use gimple_dump_bb_buff here, except that value profiling
3007 histogram dumping doesn't know about pretty-printers. */
3009 void
3010 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
3012 pp_printf (pp, "<bb %d>:\n", bb->index);
3013 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3015 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
3016 gsi_next (&gsi))
3018 gphi *phi = gsi.phi ();
3019 if (!virtual_operand_p (gimple_phi_result (phi))
3020 || (dump_flags & TDF_VOPS))
3022 pp_bar (pp);
3023 pp_write_text_to_stream (pp);
3024 pp_string (pp, "# ");
3025 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
3026 pp_newline (pp);
3027 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3031 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
3032 gsi_next (&gsi))
3034 gimple *stmt = gsi_stmt (gsi);
3035 pp_bar (pp);
3036 pp_write_text_to_stream (pp);
3037 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
3038 pp_newline (pp);
3039 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3041 dump_implicit_edges (pp, bb, 0, dump_flags);
3042 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
3046 /* Handle the %G format for TEXT. Same as %K in handle_K_format in
3047 tree-pretty-print.c but with a Gimple statement as an argument. */
3049 void
3050 percent_G_format (text_info *text)
3052 gimple *stmt = va_arg (*text->args_ptr, gimple*);
3054 /* Fall back on the rich location if the statement doesn't have one. */
3055 location_t loc = gimple_location (stmt);
3056 if (loc == UNKNOWN_LOCATION)
3057 loc = text->m_richloc->get_loc ();
3058 tree block = gimple_block (stmt);
3059 percent_K_format (text, loc, block);
3062 #if __GNUC__ >= 10
3063 # pragma GCC diagnostic pop
3064 #endif