[31/77] Use scalar_int_mode for move2add
[official-gcc.git] / gcc / gimple-pretty-print.c
blobed8e51c1c4677735462f88f460db64ee6cb63924
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2017 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"
45 #define INDENT(SPACE) \
46 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
48 #define GIMPLE_NIY do_niy (buffer,gs)
50 /* Try to print on BUFFER a default message for the unrecognized
51 gimple statement GS. */
53 static void
54 do_niy (pretty_printer *buffer, gimple *gs)
56 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
57 gimple_code_name[(int) gimple_code (gs)]);
61 /* Emit a newline and SPC indentation spaces to BUFFER. */
63 static void
64 newline_and_indent (pretty_printer *buffer, int spc)
66 pp_newline (buffer);
67 INDENT (spc);
71 /* Print the GIMPLE statement GS on stderr. */
73 DEBUG_FUNCTION void
74 debug_gimple_stmt (gimple *gs)
76 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
80 /* Return formatted string of a VALUE probability
81 (biased by REG_BR_PROB_BASE). Returned string is allocated
82 by xstrdup_for_dump. */
84 static const char *
85 dump_profile (int frequency, profile_count &count)
87 float minimum = 0.01f;
89 gcc_assert (0 <= frequency && frequency <= REG_BR_PROB_BASE);
90 float fvalue = frequency * 100.0f / REG_BR_PROB_BASE;
91 if (fvalue < minimum && frequency > 0)
92 return "[0.01%]";
94 char *buf;
95 if (count.initialized_p ())
96 buf = xasprintf ("[%.2f%%] [count: %" PRId64 "]", fvalue,
97 count.to_gcov_type ());
98 else
99 buf = xasprintf ("[%.2f%%] [count: INV]", fvalue);
101 const char *ret = xstrdup_for_dump (buf);
102 free (buf);
104 return ret;
107 /* Return formatted string of a VALUE probability
108 (biased by REG_BR_PROB_BASE). Returned string is allocated
109 by xstrdup_for_dump. */
111 static const char *
112 dump_probability (profile_probability probability, profile_count &count)
114 float minimum = 0.01f;
115 float fvalue = -1;
117 if (probability.initialized_p ())
119 fvalue = probability.to_reg_br_prob_base () * 100.0f / REG_BR_PROB_BASE;
120 if (fvalue < minimum && probability.to_reg_br_prob_base ())
121 fvalue = minimum;
124 char *buf;
125 if (count.initialized_p ())
126 buf = xasprintf ("[%.2f%%] [count: %" PRId64 "]", fvalue,
127 count.to_gcov_type ());
128 else if (probability.initialized_p ())
129 buf = xasprintf ("[%.2f%%] [count: INV]", fvalue);
130 else
131 buf = xasprintf ("[INV] [count: INV]");
133 const char *ret = xstrdup_for_dump (buf);
134 free (buf);
136 return ret;
139 /* Dump E probability to BUFFER. */
141 static void
142 dump_edge_probability (pretty_printer *buffer, edge e)
144 pp_scalar (buffer, " %s", dump_probability (e->probability, e->count));
147 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
148 FLAGS as in pp_gimple_stmt_1. */
150 void
151 print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
153 pretty_printer buffer;
154 pp_needs_newline (&buffer) = true;
155 buffer.buffer->stream = file;
156 pp_gimple_stmt_1 (&buffer, g, spc, flags);
157 pp_newline_and_flush (&buffer);
160 DEBUG_FUNCTION void
161 debug (gimple &ref)
163 print_gimple_stmt (stderr, &ref, 0, 0);
166 DEBUG_FUNCTION void
167 debug (gimple *ptr)
169 if (ptr)
170 debug (*ptr);
171 else
172 fprintf (stderr, "<nil>\n");
176 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
177 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
178 of the statement. */
180 void
181 print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
183 flags |= TDF_RHS_ONLY;
184 pretty_printer buffer;
185 pp_needs_newline (&buffer) = true;
186 buffer.buffer->stream = file;
187 pp_gimple_stmt_1 (&buffer, g, spc, flags);
188 pp_flush (&buffer);
192 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
193 spaces and FLAGS as in pp_gimple_stmt_1.
194 The caller is responsible for calling pp_flush on BUFFER to finalize
195 the pretty printer. */
197 static void
198 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc,
199 dump_flags_t flags)
201 gimple_stmt_iterator i;
203 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
205 gimple *gs = gsi_stmt (i);
206 INDENT (spc);
207 pp_gimple_stmt_1 (buffer, gs, spc, flags);
208 if (!gsi_one_before_end_p (i))
209 pp_newline (buffer);
214 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
215 FLAGS as in pp_gimple_stmt_1. */
217 void
218 print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
220 pretty_printer buffer;
221 pp_needs_newline (&buffer) = true;
222 buffer.buffer->stream = file;
223 dump_gimple_seq (&buffer, seq, spc, flags);
224 pp_newline_and_flush (&buffer);
228 /* Print the GIMPLE sequence SEQ on stderr. */
230 DEBUG_FUNCTION void
231 debug_gimple_seq (gimple_seq seq)
233 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
237 /* A simple helper to pretty-print some of the gimple tuples in the printf
238 style. The format modifiers are preceded by '%' and are:
239 'G' - outputs a string corresponding to the code of the given gimple,
240 'S' - outputs a gimple_seq with indent of spc + 2,
241 'T' - outputs the tree t,
242 'd' - outputs an int as a decimal,
243 's' - outputs a string,
244 'n' - outputs a newline,
245 'x' - outputs an int as hexadecimal,
246 '+' - increases indent by 2 then outputs a newline,
247 '-' - decreases indent by 2 then outputs a newline. */
249 static void
250 dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags,
251 const char *fmt, ...)
253 va_list args;
254 const char *c;
255 const char *tmp;
257 va_start (args, fmt);
258 for (c = fmt; *c; c++)
260 if (*c == '%')
262 gimple_seq seq;
263 tree t;
264 gimple *g;
265 switch (*++c)
267 case 'G':
268 g = va_arg (args, gimple *);
269 tmp = gimple_code_name[gimple_code (g)];
270 pp_string (buffer, tmp);
271 break;
273 case 'S':
274 seq = va_arg (args, gimple_seq);
275 pp_newline (buffer);
276 dump_gimple_seq (buffer, seq, spc + 2, flags);
277 newline_and_indent (buffer, spc);
278 break;
280 case 'T':
281 t = va_arg (args, tree);
282 if (t == NULL_TREE)
283 pp_string (buffer, "NULL");
284 else
285 dump_generic_node (buffer, t, spc, flags, false);
286 break;
288 case 'd':
289 pp_decimal_int (buffer, va_arg (args, int));
290 break;
292 case 's':
293 pp_string (buffer, va_arg (args, char *));
294 break;
296 case 'n':
297 newline_and_indent (buffer, spc);
298 break;
300 case 'x':
301 pp_scalar (buffer, "%x", va_arg (args, int));
302 break;
304 case '+':
305 spc += 2;
306 newline_and_indent (buffer, spc);
307 break;
309 case '-':
310 spc -= 2;
311 newline_and_indent (buffer, spc);
312 break;
314 default:
315 gcc_unreachable ();
318 else
319 pp_character (buffer, *c);
321 va_end (args);
325 /* Helper for dump_gimple_assign. Print the unary RHS of the
326 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
328 static void
329 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc,
330 dump_flags_t flags)
332 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
333 tree lhs = gimple_assign_lhs (gs);
334 tree rhs = gimple_assign_rhs1 (gs);
336 switch (rhs_code)
338 case VIEW_CONVERT_EXPR:
339 case ASSERT_EXPR:
340 dump_generic_node (buffer, rhs, spc, flags, false);
341 break;
343 case FIXED_CONVERT_EXPR:
344 case ADDR_SPACE_CONVERT_EXPR:
345 case FIX_TRUNC_EXPR:
346 case FLOAT_EXPR:
347 CASE_CONVERT:
348 pp_left_paren (buffer);
349 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
350 pp_string (buffer, ") ");
351 if (op_prio (rhs) < op_code_prio (rhs_code))
353 pp_left_paren (buffer);
354 dump_generic_node (buffer, rhs, spc, flags, false);
355 pp_right_paren (buffer);
357 else
358 dump_generic_node (buffer, rhs, spc, flags, false);
359 break;
361 case PAREN_EXPR:
362 pp_string (buffer, "((");
363 dump_generic_node (buffer, rhs, spc, flags, false);
364 pp_string (buffer, "))");
365 break;
367 case ABS_EXPR:
368 if (flags & TDF_GIMPLE)
370 pp_string (buffer, "__ABS ");
371 dump_generic_node (buffer, rhs, spc, flags, false);
373 else
375 pp_string (buffer, "ABS_EXPR <");
376 dump_generic_node (buffer, rhs, spc, flags, false);
377 pp_greater (buffer);
379 break;
381 default:
382 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
383 || TREE_CODE_CLASS (rhs_code) == tcc_constant
384 || TREE_CODE_CLASS (rhs_code) == tcc_reference
385 || rhs_code == SSA_NAME
386 || rhs_code == ADDR_EXPR
387 || rhs_code == CONSTRUCTOR)
389 dump_generic_node (buffer, rhs, spc, flags, false);
390 break;
392 else if (rhs_code == BIT_NOT_EXPR)
393 pp_complement (buffer);
394 else if (rhs_code == TRUTH_NOT_EXPR)
395 pp_exclamation (buffer);
396 else if (rhs_code == NEGATE_EXPR)
397 pp_minus (buffer);
398 else
400 pp_left_bracket (buffer);
401 pp_string (buffer, get_tree_code_name (rhs_code));
402 pp_string (buffer, "] ");
405 if (op_prio (rhs) < op_code_prio (rhs_code))
407 pp_left_paren (buffer);
408 dump_generic_node (buffer, rhs, spc, flags, false);
409 pp_right_paren (buffer);
411 else
412 dump_generic_node (buffer, rhs, spc, flags, false);
413 break;
418 /* Helper for dump_gimple_assign. Print the binary RHS of the
419 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
421 static void
422 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc,
423 dump_flags_t flags)
425 const char *p;
426 enum tree_code code = gimple_assign_rhs_code (gs);
427 switch (code)
429 case COMPLEX_EXPR:
430 case MIN_EXPR:
431 case MAX_EXPR:
432 case VEC_WIDEN_MULT_HI_EXPR:
433 case VEC_WIDEN_MULT_LO_EXPR:
434 case VEC_WIDEN_MULT_EVEN_EXPR:
435 case VEC_WIDEN_MULT_ODD_EXPR:
436 case VEC_PACK_TRUNC_EXPR:
437 case VEC_PACK_SAT_EXPR:
438 case VEC_PACK_FIX_TRUNC_EXPR:
439 case VEC_WIDEN_LSHIFT_HI_EXPR:
440 case VEC_WIDEN_LSHIFT_LO_EXPR:
441 for (p = get_tree_code_name (code); *p; p++)
442 pp_character (buffer, TOUPPER (*p));
443 pp_string (buffer, " <");
444 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
445 pp_string (buffer, ", ");
446 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
447 pp_greater (buffer);
448 break;
450 default:
451 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
453 pp_left_paren (buffer);
454 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
455 false);
456 pp_right_paren (buffer);
458 else
459 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
460 pp_space (buffer);
461 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
462 pp_space (buffer);
463 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
465 pp_left_paren (buffer);
466 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
467 false);
468 pp_right_paren (buffer);
470 else
471 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
475 /* Helper for dump_gimple_assign. Print the ternary RHS of the
476 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
478 static void
479 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc,
480 dump_flags_t flags)
482 const char *p;
483 enum tree_code code = gimple_assign_rhs_code (gs);
484 switch (code)
486 case WIDEN_MULT_PLUS_EXPR:
487 case WIDEN_MULT_MINUS_EXPR:
488 for (p = get_tree_code_name (code); *p; p++)
489 pp_character (buffer, TOUPPER (*p));
490 pp_string (buffer, " <");
491 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
492 pp_string (buffer, ", ");
493 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
494 pp_string (buffer, ", ");
495 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
496 pp_greater (buffer);
497 break;
499 case FMA_EXPR:
500 if (flags & TDF_GIMPLE)
502 pp_string (buffer, "__FMA (");
503 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
504 pp_comma (buffer);
505 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
506 pp_comma (buffer);
507 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
508 pp_right_paren (buffer);
510 else
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);
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 pp_string (buffer, "VEC_PERM_EXPR <");
542 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
543 pp_string (buffer, ", ");
544 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
545 pp_string (buffer, ", ");
546 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
547 pp_greater (buffer);
548 break;
550 case REALIGN_LOAD_EXPR:
551 pp_string (buffer, "REALIGN_LOAD <");
552 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
553 pp_string (buffer, ", ");
554 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
555 pp_string (buffer, ", ");
556 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
557 pp_greater (buffer);
558 break;
560 case COND_EXPR:
561 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
562 pp_string (buffer, " ? ");
563 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
564 pp_string (buffer, " : ");
565 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
566 break;
568 case VEC_COND_EXPR:
569 pp_string (buffer, "VEC_COND_EXPR <");
570 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
571 pp_string (buffer, ", ");
572 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
573 pp_string (buffer, ", ");
574 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
575 pp_greater (buffer);
576 break;
578 case BIT_INSERT_EXPR:
579 pp_string (buffer, "BIT_INSERT_EXPR <");
580 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
581 pp_string (buffer, ", ");
582 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
583 pp_string (buffer, ", ");
584 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
585 pp_string (buffer, " (");
586 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
587 pp_decimal_int (buffer,
588 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
589 else
590 dump_generic_node (buffer,
591 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
592 spc, flags, false);
593 pp_string (buffer, " bits)>");
594 break;
596 default:
597 gcc_unreachable ();
602 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
603 pp_gimple_stmt_1. */
605 static void
606 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc,
607 dump_flags_t flags)
609 if (flags & TDF_RAW)
611 tree arg1 = NULL;
612 tree arg2 = NULL;
613 tree arg3 = NULL;
614 switch (gimple_num_ops (gs))
616 case 4:
617 arg3 = gimple_assign_rhs3 (gs);
618 /* FALLTHRU */
619 case 3:
620 arg2 = gimple_assign_rhs2 (gs);
621 /* FALLTHRU */
622 case 2:
623 arg1 = gimple_assign_rhs1 (gs);
624 break;
625 default:
626 gcc_unreachable ();
629 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
630 get_tree_code_name (gimple_assign_rhs_code (gs)),
631 gimple_assign_lhs (gs), arg1, arg2, arg3);
633 else
635 if (!(flags & TDF_RHS_ONLY))
637 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
638 pp_space (buffer);
639 pp_equal (buffer);
641 if (gimple_assign_nontemporal_move_p (gs))
642 pp_string (buffer, "{nt}");
644 if (gimple_has_volatile_ops (gs))
645 pp_string (buffer, "{v}");
647 pp_space (buffer);
650 if (gimple_num_ops (gs) == 2)
651 dump_unary_rhs (buffer, gs, spc, flags);
652 else if (gimple_num_ops (gs) == 3)
653 dump_binary_rhs (buffer, gs, spc, flags);
654 else if (gimple_num_ops (gs) == 4)
655 dump_ternary_rhs (buffer, gs, spc, flags);
656 else
657 gcc_unreachable ();
658 if (!(flags & TDF_RHS_ONLY))
659 pp_semicolon (buffer);
664 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
665 pp_gimple_stmt_1. */
667 static void
668 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc,
669 dump_flags_t flags)
671 tree t, t2;
673 t = gimple_return_retval (gs);
674 t2 = gimple_return_retbnd (gs);
675 if (flags & TDF_RAW)
676 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
677 else
679 pp_string (buffer, "return");
680 if (t)
682 pp_space (buffer);
683 dump_generic_node (buffer, t, spc, flags, false);
685 if (t2)
687 pp_string (buffer, ", ");
688 dump_generic_node (buffer, t2, spc, flags, false);
690 pp_semicolon (buffer);
695 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
696 dump_gimple_call. */
698 static void
699 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, dump_flags_t flags)
701 size_t i = 0;
703 /* Pretty print first arg to certain internal fns. */
704 if (gimple_call_internal_p (gs))
706 const char *const *enums = NULL;
707 unsigned limit = 0;
709 switch (gimple_call_internal_fn (gs))
711 case IFN_UNIQUE:
712 #define DEF(X) #X
713 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
714 #undef DEF
715 enums = unique_args;
717 limit = ARRAY_SIZE (unique_args);
718 break;
720 case IFN_GOACC_LOOP:
721 #define DEF(X) #X
722 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
723 #undef DEF
724 enums = loop_args;
725 limit = ARRAY_SIZE (loop_args);
726 break;
728 case IFN_GOACC_REDUCTION:
729 #define DEF(X) #X
730 static const char *const reduction_args[]
731 = {IFN_GOACC_REDUCTION_CODES};
732 #undef DEF
733 enums = reduction_args;
734 limit = ARRAY_SIZE (reduction_args);
735 break;
737 case IFN_ASAN_MARK:
738 #define DEF(X) #X
739 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
740 #undef DEF
741 enums = asan_mark_args;
742 limit = ARRAY_SIZE (asan_mark_args);
743 break;
745 default:
746 break;
748 if (limit)
750 tree arg0 = gimple_call_arg (gs, 0);
751 HOST_WIDE_INT v;
753 if (TREE_CODE (arg0) == INTEGER_CST
754 && tree_fits_shwi_p (arg0)
755 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
757 i++;
758 pp_string (buffer, enums[v]);
763 for (; i < gimple_call_num_args (gs); i++)
765 if (i)
766 pp_string (buffer, ", ");
767 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
770 if (gimple_call_va_arg_pack_p (gs))
772 if (i)
773 pp_string (buffer, ", ");
775 pp_string (buffer, "__builtin_va_arg_pack ()");
779 /* Dump the points-to solution *PT to BUFFER. */
781 static void
782 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
784 if (pt->anything)
786 pp_string (buffer, "anything ");
787 return;
789 if (pt->nonlocal)
790 pp_string (buffer, "nonlocal ");
791 if (pt->escaped)
792 pp_string (buffer, "escaped ");
793 if (pt->ipa_escaped)
794 pp_string (buffer, "unit-escaped ");
795 if (pt->null)
796 pp_string (buffer, "null ");
797 if (pt->vars
798 && !bitmap_empty_p (pt->vars))
800 bitmap_iterator bi;
801 unsigned i;
802 pp_string (buffer, "{ ");
803 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
805 pp_string (buffer, "D.");
806 pp_decimal_int (buffer, i);
807 pp_space (buffer);
809 pp_right_brace (buffer);
810 if (pt->vars_contains_nonlocal
811 || pt->vars_contains_escaped
812 || pt->vars_contains_escaped_heap
813 || pt->vars_contains_restrict)
815 const char *comma = "";
816 pp_string (buffer, " (");
817 if (pt->vars_contains_nonlocal)
819 pp_string (buffer, "nonlocal");
820 comma = ", ";
822 if (pt->vars_contains_escaped)
824 pp_string (buffer, comma);
825 pp_string (buffer, "escaped");
826 comma = ", ";
828 if (pt->vars_contains_escaped_heap)
830 pp_string (buffer, comma);
831 pp_string (buffer, "escaped heap");
832 comma = ", ";
834 if (pt->vars_contains_restrict)
836 pp_string (buffer, comma);
837 pp_string (buffer, "restrict");
838 comma = ", ";
840 if (pt->vars_contains_interposable)
842 pp_string (buffer, comma);
843 pp_string (buffer, "interposable");
845 pp_string (buffer, ")");
851 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
852 pp_gimple_stmt_1. */
854 static void
855 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
856 dump_flags_t flags)
858 tree lhs = gimple_call_lhs (gs);
859 tree fn = gimple_call_fn (gs);
861 if (flags & TDF_ALIAS)
863 struct pt_solution *pt;
864 pt = gimple_call_use_set (gs);
865 if (!pt_solution_empty_p (pt))
867 pp_string (buffer, "# USE = ");
868 pp_points_to_solution (buffer, pt);
869 newline_and_indent (buffer, spc);
871 pt = gimple_call_clobber_set (gs);
872 if (!pt_solution_empty_p (pt))
874 pp_string (buffer, "# CLB = ");
875 pp_points_to_solution (buffer, pt);
876 newline_and_indent (buffer, spc);
880 if (flags & TDF_RAW)
882 if (gimple_call_internal_p (gs))
883 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
884 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
885 else
886 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
887 if (gimple_call_num_args (gs) > 0)
889 pp_string (buffer, ", ");
890 dump_gimple_call_args (buffer, gs, flags);
892 pp_greater (buffer);
894 else
896 if (lhs && !(flags & TDF_RHS_ONLY))
898 dump_generic_node (buffer, lhs, spc, flags, false);
899 pp_string (buffer, " =");
901 if (gimple_has_volatile_ops (gs))
902 pp_string (buffer, "{v}");
904 pp_space (buffer);
906 if (gimple_call_internal_p (gs))
907 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
908 else
909 print_call_name (buffer, fn, flags);
910 pp_string (buffer, " (");
911 dump_gimple_call_args (buffer, gs, flags);
912 pp_right_paren (buffer);
913 if (!(flags & TDF_RHS_ONLY))
914 pp_semicolon (buffer);
917 if (gimple_call_chain (gs))
919 pp_string (buffer, " [static-chain: ");
920 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
921 pp_right_bracket (buffer);
924 if (gimple_call_return_slot_opt_p (gs))
925 pp_string (buffer, " [return slot optimization]");
926 if (gimple_call_tail_p (gs))
927 pp_string (buffer, " [tail call]");
928 if (gimple_call_must_tail_p (gs))
929 pp_string (buffer, " [must tail call]");
931 if (fn == NULL)
932 return;
934 /* Dump the arguments of _ITM_beginTransaction sanely. */
935 if (TREE_CODE (fn) == ADDR_EXPR)
936 fn = TREE_OPERAND (fn, 0);
937 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
938 pp_string (buffer, " [tm-clone]");
939 if (TREE_CODE (fn) == FUNCTION_DECL
940 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
941 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
942 && gimple_call_num_args (gs) > 0)
944 tree t = gimple_call_arg (gs, 0);
945 unsigned HOST_WIDE_INT props;
946 gcc_assert (TREE_CODE (t) == INTEGER_CST);
948 pp_string (buffer, " [ ");
950 /* Get the transaction code properties. */
951 props = TREE_INT_CST_LOW (t);
953 if (props & PR_INSTRUMENTEDCODE)
954 pp_string (buffer, "instrumentedCode ");
955 if (props & PR_UNINSTRUMENTEDCODE)
956 pp_string (buffer, "uninstrumentedCode ");
957 if (props & PR_HASNOXMMUPDATE)
958 pp_string (buffer, "hasNoXMMUpdate ");
959 if (props & PR_HASNOABORT)
960 pp_string (buffer, "hasNoAbort ");
961 if (props & PR_HASNOIRREVOCABLE)
962 pp_string (buffer, "hasNoIrrevocable ");
963 if (props & PR_DOESGOIRREVOCABLE)
964 pp_string (buffer, "doesGoIrrevocable ");
965 if (props & PR_HASNOSIMPLEREADS)
966 pp_string (buffer, "hasNoSimpleReads ");
967 if (props & PR_AWBARRIERSOMITTED)
968 pp_string (buffer, "awBarriersOmitted ");
969 if (props & PR_RARBARRIERSOMITTED)
970 pp_string (buffer, "RaRBarriersOmitted ");
971 if (props & PR_UNDOLOGCODE)
972 pp_string (buffer, "undoLogCode ");
973 if (props & PR_PREFERUNINSTRUMENTED)
974 pp_string (buffer, "preferUninstrumented ");
975 if (props & PR_EXCEPTIONBLOCK)
976 pp_string (buffer, "exceptionBlock ");
977 if (props & PR_HASELSE)
978 pp_string (buffer, "hasElse ");
979 if (props & PR_READONLY)
980 pp_string (buffer, "readOnly ");
982 pp_right_bracket (buffer);
987 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
988 pp_gimple_stmt_1. */
990 static void
991 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
992 dump_flags_t flags)
994 unsigned int i;
996 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
997 if (flags & TDF_RAW)
998 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
999 gimple_switch_index (gs));
1000 else
1002 pp_string (buffer, "switch (");
1003 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
1004 if (flags & TDF_GIMPLE)
1005 pp_string (buffer, ") {");
1006 else
1007 pp_string (buffer, ") <");
1010 for (i = 0; i < gimple_switch_num_labels (gs); i++)
1012 tree case_label = gimple_switch_label (gs, i);
1013 gcc_checking_assert (case_label != NULL_TREE);
1014 dump_generic_node (buffer, case_label, spc, flags, false);
1015 pp_space (buffer);
1016 tree label = CASE_LABEL (case_label);
1017 dump_generic_node (buffer, label, spc, flags, false);
1019 if (cfun && cfun->cfg)
1021 basic_block dest = label_to_block (label);
1022 if (dest)
1024 edge label_edge = find_edge (gimple_bb (gs), dest);
1025 if (label_edge && !(flags & TDF_GIMPLE))
1026 dump_edge_probability (buffer, label_edge);
1030 if (i < gimple_switch_num_labels (gs) - 1)
1032 if (flags & TDF_GIMPLE)
1033 pp_string (buffer, "; ");
1034 else
1035 pp_string (buffer, ", ");
1038 if (flags & TDF_GIMPLE)
1039 pp_string (buffer, "; }");
1040 else
1041 pp_greater (buffer);
1045 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
1046 pp_gimple_stmt_1. */
1048 static void
1049 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc,
1050 dump_flags_t flags)
1052 if (flags & TDF_RAW)
1053 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
1054 get_tree_code_name (gimple_cond_code (gs)),
1055 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1056 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
1057 else
1059 if (!(flags & TDF_RHS_ONLY))
1060 pp_string (buffer, "if (");
1061 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
1062 pp_space (buffer);
1063 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1064 pp_space (buffer);
1065 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
1066 if (!(flags & TDF_RHS_ONLY))
1068 edge_iterator ei;
1069 edge e, true_edge = NULL, false_edge = NULL;
1070 basic_block bb = gimple_bb (gs);
1072 if (bb)
1074 FOR_EACH_EDGE (e, ei, bb->succs)
1076 if (e->flags & EDGE_TRUE_VALUE)
1077 true_edge = e;
1078 else if (e->flags & EDGE_FALSE_VALUE)
1079 false_edge = e;
1083 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1085 pp_right_paren (buffer);
1087 if (gimple_cond_true_label (gs))
1089 pp_string (buffer, " goto ");
1090 dump_generic_node (buffer, gimple_cond_true_label (gs),
1091 spc, flags, false);
1092 if (has_edge_info && !(flags & TDF_GIMPLE))
1093 dump_edge_probability (buffer, true_edge);
1094 pp_semicolon (buffer);
1096 if (gimple_cond_false_label (gs))
1098 pp_string (buffer, " else goto ");
1099 dump_generic_node (buffer, gimple_cond_false_label (gs),
1100 spc, flags, false);
1101 if (has_edge_info && !(flags & TDF_GIMPLE))
1102 dump_edge_probability (buffer, false_edge);
1104 pp_semicolon (buffer);
1111 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1112 spaces of indent. FLAGS specifies details to show in the dump (see
1113 TDF_* in dumpfils.h). */
1115 static void
1116 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
1117 dump_flags_t flags)
1119 tree label = gimple_label_label (gs);
1120 if (flags & TDF_RAW)
1121 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1122 else
1124 dump_generic_node (buffer, label, spc, flags, false);
1125 pp_colon (buffer);
1127 if (flags & TDF_GIMPLE)
1128 return;
1129 if (DECL_NONLOCAL (label))
1130 pp_string (buffer, " [non-local]");
1131 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1132 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
1135 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1136 spaces of indent. FLAGS specifies details to show in the dump (see
1137 TDF_* in dumpfile.h). */
1139 static void
1140 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc,
1141 dump_flags_t flags)
1143 tree label = gimple_goto_dest (gs);
1144 if (flags & TDF_RAW)
1145 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1146 else
1147 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1151 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1152 spaces of indent. FLAGS specifies details to show in the dump (see
1153 TDF_* in dumpfile.h). */
1155 static void
1156 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc,
1157 dump_flags_t flags)
1159 if (flags & TDF_RAW)
1160 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1161 else
1162 pp_left_brace (buffer);
1163 if (!(flags & TDF_SLIM))
1165 tree var;
1167 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1169 newline_and_indent (buffer, 2);
1170 print_declaration (buffer, var, spc, flags);
1172 if (gimple_bind_vars (gs))
1173 pp_newline (buffer);
1175 pp_newline (buffer);
1176 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1177 newline_and_indent (buffer, spc);
1178 if (flags & TDF_RAW)
1179 pp_greater (buffer);
1180 else
1181 pp_right_brace (buffer);
1185 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1186 indent. FLAGS specifies details to show in the dump (see TDF_* in
1187 dumpfile.h). */
1189 static void
1190 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc,
1191 dump_flags_t flags)
1193 if (flags & TDF_RAW)
1195 const char *type;
1196 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1197 type = "GIMPLE_TRY_CATCH";
1198 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1199 type = "GIMPLE_TRY_FINALLY";
1200 else
1201 type = "UNKNOWN GIMPLE_TRY";
1202 dump_gimple_fmt (buffer, spc, flags,
1203 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1204 gimple_try_eval (gs), gimple_try_cleanup (gs));
1206 else
1208 pp_string (buffer, "try");
1209 newline_and_indent (buffer, spc + 2);
1210 pp_left_brace (buffer);
1211 pp_newline (buffer);
1213 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1214 newline_and_indent (buffer, spc + 2);
1215 pp_right_brace (buffer);
1217 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1219 newline_and_indent (buffer, spc);
1220 pp_string (buffer, "catch");
1221 newline_and_indent (buffer, spc + 2);
1222 pp_left_brace (buffer);
1224 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1226 newline_and_indent (buffer, spc);
1227 pp_string (buffer, "finally");
1228 newline_and_indent (buffer, spc + 2);
1229 pp_left_brace (buffer);
1231 else
1232 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1234 pp_newline (buffer);
1235 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1236 newline_and_indent (buffer, spc + 2);
1237 pp_right_brace (buffer);
1242 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1243 indent. FLAGS specifies details to show in the dump (see TDF_* in
1244 dumpfile.h). */
1246 static void
1247 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc,
1248 dump_flags_t flags)
1250 if (flags & TDF_RAW)
1251 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1252 gimple_catch_types (gs), gimple_catch_handler (gs));
1253 else
1254 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1255 gimple_catch_types (gs), gimple_catch_handler (gs));
1259 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1260 indent. FLAGS specifies details to show in the dump (see TDF_* in
1261 dumpfile.h). */
1263 static void
1264 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1265 dump_flags_t flags)
1267 if (flags & TDF_RAW)
1268 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1269 gimple_eh_filter_types (gs),
1270 gimple_eh_filter_failure (gs));
1271 else
1272 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1273 gimple_eh_filter_types (gs),
1274 gimple_eh_filter_failure (gs));
1278 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1280 static void
1281 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1282 geh_mnt *gs, int spc, dump_flags_t flags)
1284 if (flags & TDF_RAW)
1285 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1286 gimple_eh_must_not_throw_fndecl (gs));
1287 else
1288 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1289 gimple_eh_must_not_throw_fndecl (gs));
1293 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1294 indent. FLAGS specifies details to show in the dump (see TDF_* in
1295 dumpfile.h). */
1297 static void
1298 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1299 dump_flags_t flags)
1301 if (flags & TDF_RAW)
1302 dump_gimple_fmt (buffer, spc, flags,
1303 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1304 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1305 else
1306 dump_gimple_fmt (buffer, spc, flags,
1307 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1308 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1312 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1313 indent. FLAGS specifies details to show in the dump (see TDF_* in
1314 dumpfile.h). */
1316 static void
1317 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc,
1318 dump_flags_t flags)
1320 if (flags & TDF_RAW)
1321 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1322 gimple_resx_region (gs));
1323 else
1324 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1327 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1329 static void
1330 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc,
1331 dump_flags_t flags)
1333 if (flags & TDF_RAW)
1334 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1335 gimple_eh_dispatch_region (gs));
1336 else
1337 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1338 gimple_eh_dispatch_region (gs));
1341 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1342 of indent. FLAGS specifies details to show in the dump (see TDF_*
1343 in dumpfile.h). */
1345 static void
1346 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc,
1347 dump_flags_t flags)
1349 switch (gs->subcode)
1351 case GIMPLE_DEBUG_BIND:
1352 if (flags & TDF_RAW)
1353 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1354 gimple_debug_bind_get_var (gs),
1355 gimple_debug_bind_get_value (gs));
1356 else
1357 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1358 gimple_debug_bind_get_var (gs),
1359 gimple_debug_bind_get_value (gs));
1360 break;
1362 case GIMPLE_DEBUG_SOURCE_BIND:
1363 if (flags & TDF_RAW)
1364 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1365 gimple_debug_source_bind_get_var (gs),
1366 gimple_debug_source_bind_get_value (gs));
1367 else
1368 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1369 gimple_debug_source_bind_get_var (gs),
1370 gimple_debug_source_bind_get_value (gs));
1371 break;
1373 default:
1374 gcc_unreachable ();
1378 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1379 static void
1380 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc,
1381 dump_flags_t flags)
1383 size_t i;
1385 if (flags & TDF_RAW)
1387 const char *kind;
1388 switch (gimple_omp_for_kind (gs))
1390 case GF_OMP_FOR_KIND_FOR:
1391 kind = "";
1392 break;
1393 case GF_OMP_FOR_KIND_DISTRIBUTE:
1394 kind = " distribute";
1395 break;
1396 case GF_OMP_FOR_KIND_TASKLOOP:
1397 kind = " taskloop";
1398 break;
1399 case GF_OMP_FOR_KIND_CILKFOR:
1400 kind = " _Cilk_for";
1401 break;
1402 case GF_OMP_FOR_KIND_OACC_LOOP:
1403 kind = " oacc_loop";
1404 break;
1405 case GF_OMP_FOR_KIND_SIMD:
1406 kind = " simd";
1407 break;
1408 case GF_OMP_FOR_KIND_CILKSIMD:
1409 kind = " cilksimd";
1410 break;
1411 default:
1412 gcc_unreachable ();
1414 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1415 kind, gimple_omp_body (gs));
1416 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1417 dump_gimple_fmt (buffer, spc, flags, " >,");
1418 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1419 dump_gimple_fmt (buffer, spc, flags,
1420 "%+%T, %T, %T, %s, %T,%n",
1421 gimple_omp_for_index (gs, i),
1422 gimple_omp_for_initial (gs, i),
1423 gimple_omp_for_final (gs, i),
1424 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1425 gimple_omp_for_incr (gs, i));
1426 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1427 gimple_omp_for_pre_body (gs));
1429 else
1431 switch (gimple_omp_for_kind (gs))
1433 case GF_OMP_FOR_KIND_FOR:
1434 pp_string (buffer, "#pragma omp for");
1435 break;
1436 case GF_OMP_FOR_KIND_DISTRIBUTE:
1437 pp_string (buffer, "#pragma omp distribute");
1438 break;
1439 case GF_OMP_FOR_KIND_TASKLOOP:
1440 pp_string (buffer, "#pragma omp taskloop");
1441 break;
1442 case GF_OMP_FOR_KIND_CILKFOR:
1443 break;
1444 case GF_OMP_FOR_KIND_OACC_LOOP:
1445 pp_string (buffer, "#pragma acc loop");
1446 break;
1447 case GF_OMP_FOR_KIND_SIMD:
1448 pp_string (buffer, "#pragma omp simd");
1449 break;
1450 case GF_OMP_FOR_KIND_CILKSIMD:
1451 pp_string (buffer, "#pragma simd");
1452 break;
1453 case GF_OMP_FOR_KIND_GRID_LOOP:
1454 pp_string (buffer, "#pragma omp for grid_loop");
1455 break;
1456 default:
1457 gcc_unreachable ();
1459 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1460 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1461 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1463 if (i)
1464 spc += 2;
1465 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1466 pp_string (buffer, "_Cilk_for (");
1467 else
1469 newline_and_indent (buffer, spc);
1470 pp_string (buffer, "for (");
1472 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1473 flags, false);
1474 pp_string (buffer, " = ");
1475 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1476 flags, false);
1477 pp_string (buffer, "; ");
1479 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1480 flags, false);
1481 pp_space (buffer);
1482 switch (gimple_omp_for_cond (gs, i))
1484 case LT_EXPR:
1485 pp_less (buffer);
1486 break;
1487 case GT_EXPR:
1488 pp_greater (buffer);
1489 break;
1490 case LE_EXPR:
1491 pp_less_equal (buffer);
1492 break;
1493 case GE_EXPR:
1494 pp_greater_equal (buffer);
1495 break;
1496 case NE_EXPR:
1497 pp_string (buffer, "!=");
1498 break;
1499 default:
1500 gcc_unreachable ();
1502 pp_space (buffer);
1503 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1504 flags, false);
1505 pp_string (buffer, "; ");
1507 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1508 flags, false);
1509 pp_string (buffer, " = ");
1510 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1511 flags, false);
1512 pp_right_paren (buffer);
1515 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1517 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1518 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1519 newline_and_indent (buffer, spc + 2);
1520 pp_left_brace (buffer);
1521 pp_newline (buffer);
1522 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1523 newline_and_indent (buffer, spc + 2);
1524 pp_right_brace (buffer);
1529 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1531 static void
1532 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1533 int spc, dump_flags_t flags)
1535 if (flags & TDF_RAW)
1537 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1538 gimple_omp_continue_control_def (gs),
1539 gimple_omp_continue_control_use (gs));
1541 else
1543 pp_string (buffer, "#pragma omp continue (");
1544 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1545 spc, flags, false);
1546 pp_comma (buffer);
1547 pp_space (buffer);
1548 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1549 spc, flags, false);
1550 pp_right_paren (buffer);
1554 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1556 static void
1557 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1558 int spc, dump_flags_t flags)
1560 if (flags & TDF_RAW)
1562 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1563 gimple_omp_body (gs));
1564 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1565 dump_gimple_fmt (buffer, spc, flags, " >");
1567 else
1569 pp_string (buffer, "#pragma omp single");
1570 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1571 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1573 newline_and_indent (buffer, spc + 2);
1574 pp_left_brace (buffer);
1575 pp_newline (buffer);
1576 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1577 newline_and_indent (buffer, spc + 2);
1578 pp_right_brace (buffer);
1583 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1585 static void
1586 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1587 int spc, dump_flags_t flags)
1589 const char *kind;
1590 switch (gimple_omp_target_kind (gs))
1592 case GF_OMP_TARGET_KIND_REGION:
1593 kind = "";
1594 break;
1595 case GF_OMP_TARGET_KIND_DATA:
1596 kind = " data";
1597 break;
1598 case GF_OMP_TARGET_KIND_UPDATE:
1599 kind = " update";
1600 break;
1601 case GF_OMP_TARGET_KIND_ENTER_DATA:
1602 kind = " enter data";
1603 break;
1604 case GF_OMP_TARGET_KIND_EXIT_DATA:
1605 kind = " exit data";
1606 break;
1607 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1608 kind = " oacc_kernels";
1609 break;
1610 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1611 kind = " oacc_parallel";
1612 break;
1613 case GF_OMP_TARGET_KIND_OACC_DATA:
1614 kind = " oacc_data";
1615 break;
1616 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1617 kind = " oacc_update";
1618 break;
1619 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1620 kind = " oacc_enter_exit_data";
1621 break;
1622 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1623 kind = " oacc_declare";
1624 break;
1625 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1626 kind = " oacc_host_data";
1627 break;
1628 default:
1629 gcc_unreachable ();
1631 if (flags & TDF_RAW)
1633 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1634 kind, gimple_omp_body (gs));
1635 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1636 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1637 gimple_omp_target_child_fn (gs),
1638 gimple_omp_target_data_arg (gs));
1640 else
1642 pp_string (buffer, "#pragma omp target");
1643 pp_string (buffer, kind);
1644 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1645 if (gimple_omp_target_child_fn (gs))
1647 pp_string (buffer, " [child fn: ");
1648 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1649 spc, flags, false);
1650 pp_string (buffer, " (");
1651 if (gimple_omp_target_data_arg (gs))
1652 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1653 spc, flags, false);
1654 else
1655 pp_string (buffer, "???");
1656 pp_string (buffer, ")]");
1658 gimple_seq body = gimple_omp_body (gs);
1659 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1661 newline_and_indent (buffer, spc + 2);
1662 pp_left_brace (buffer);
1663 pp_newline (buffer);
1664 dump_gimple_seq (buffer, body, spc + 4, flags);
1665 newline_and_indent (buffer, spc + 2);
1666 pp_right_brace (buffer);
1668 else if (body)
1670 pp_newline (buffer);
1671 dump_gimple_seq (buffer, body, spc + 2, flags);
1676 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1678 static void
1679 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1680 dump_flags_t flags)
1682 if (flags & TDF_RAW)
1684 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1685 gimple_omp_body (gs));
1686 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1687 dump_gimple_fmt (buffer, spc, flags, " >");
1689 else
1691 pp_string (buffer, "#pragma omp teams");
1692 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1693 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1695 newline_and_indent (buffer, spc + 2);
1696 pp_character (buffer, '{');
1697 pp_newline (buffer);
1698 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1699 newline_and_indent (buffer, spc + 2);
1700 pp_character (buffer, '}');
1705 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1707 static void
1708 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1709 int spc, dump_flags_t flags)
1711 if (flags & TDF_RAW)
1713 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1714 gimple_omp_body (gs));
1715 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1716 dump_gimple_fmt (buffer, spc, flags, " >");
1718 else
1720 pp_string (buffer, "#pragma omp sections");
1721 if (gimple_omp_sections_control (gs))
1723 pp_string (buffer, " <");
1724 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1725 flags, false);
1726 pp_greater (buffer);
1728 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1729 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1731 newline_and_indent (buffer, spc + 2);
1732 pp_left_brace (buffer);
1733 pp_newline (buffer);
1734 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1735 newline_and_indent (buffer, spc + 2);
1736 pp_right_brace (buffer);
1741 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1742 pretty_printer BUFFER. */
1744 static void
1745 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc,
1746 dump_flags_t flags)
1748 if (flags & TDF_RAW)
1749 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1750 gimple_omp_body (gs));
1751 else
1753 switch (gimple_code (gs))
1755 case GIMPLE_OMP_MASTER:
1756 pp_string (buffer, "#pragma omp master");
1757 break;
1758 case GIMPLE_OMP_TASKGROUP:
1759 pp_string (buffer, "#pragma omp taskgroup");
1760 break;
1761 case GIMPLE_OMP_SECTION:
1762 pp_string (buffer, "#pragma omp section");
1763 break;
1764 case GIMPLE_OMP_GRID_BODY:
1765 pp_string (buffer, "#pragma omp gridified body");
1766 break;
1767 default:
1768 gcc_unreachable ();
1770 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1772 newline_and_indent (buffer, spc + 2);
1773 pp_left_brace (buffer);
1774 pp_newline (buffer);
1775 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1776 newline_and_indent (buffer, spc + 2);
1777 pp_right_brace (buffer);
1782 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1784 static void
1785 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1786 int spc, dump_flags_t flags)
1788 if (flags & TDF_RAW)
1789 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1790 gimple_omp_body (gs));
1791 else
1793 pp_string (buffer, "#pragma omp critical");
1794 if (gimple_omp_critical_name (gs))
1796 pp_string (buffer, " (");
1797 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1798 flags, false);
1799 pp_right_paren (buffer);
1801 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1802 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1804 newline_and_indent (buffer, spc + 2);
1805 pp_left_brace (buffer);
1806 pp_newline (buffer);
1807 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1808 newline_and_indent (buffer, spc + 2);
1809 pp_right_brace (buffer);
1814 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1816 static void
1817 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1818 int spc, dump_flags_t flags)
1820 if (flags & TDF_RAW)
1821 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1822 gimple_omp_body (gs));
1823 else
1825 pp_string (buffer, "#pragma omp ordered");
1826 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1827 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1829 newline_and_indent (buffer, spc + 2);
1830 pp_left_brace (buffer);
1831 pp_newline (buffer);
1832 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1833 newline_and_indent (buffer, spc + 2);
1834 pp_right_brace (buffer);
1839 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1841 static void
1842 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc,
1843 dump_flags_t flags)
1845 if (flags & TDF_RAW)
1847 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1848 (int) gimple_omp_return_nowait_p (gs));
1849 if (gimple_omp_return_lhs (gs))
1850 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1851 gimple_omp_return_lhs (gs));
1852 else
1853 dump_gimple_fmt (buffer, spc, flags, ">");
1855 else
1857 pp_string (buffer, "#pragma omp return");
1858 if (gimple_omp_return_nowait_p (gs))
1859 pp_string (buffer, "(nowait)");
1860 if (gimple_omp_return_lhs (gs))
1862 pp_string (buffer, " (set ");
1863 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1864 spc, flags, false);
1865 pp_character (buffer, ')');
1870 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1872 static void
1873 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1874 int spc, dump_flags_t flags)
1876 unsigned subcode = gimple_transaction_subcode (gs);
1878 if (flags & TDF_RAW)
1880 dump_gimple_fmt (buffer, spc, flags,
1881 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1882 "<%+BODY <%S> >",
1883 gs, subcode, gimple_transaction_label_norm (gs),
1884 gimple_transaction_label_uninst (gs),
1885 gimple_transaction_label_over (gs),
1886 gimple_transaction_body (gs));
1888 else
1890 if (subcode & GTMA_IS_OUTER)
1891 pp_string (buffer, "__transaction_atomic [[outer]]");
1892 else if (subcode & GTMA_IS_RELAXED)
1893 pp_string (buffer, "__transaction_relaxed");
1894 else
1895 pp_string (buffer, "__transaction_atomic");
1896 subcode &= ~GTMA_DECLARATION_MASK;
1898 if (gimple_transaction_body (gs))
1900 newline_and_indent (buffer, spc + 2);
1901 pp_left_brace (buffer);
1902 pp_newline (buffer);
1903 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1904 spc + 4, flags);
1905 newline_and_indent (buffer, spc + 2);
1906 pp_right_brace (buffer);
1908 else
1910 pp_string (buffer, " //");
1911 if (gimple_transaction_label_norm (gs))
1913 pp_string (buffer, " NORM=");
1914 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1915 spc, flags, false);
1917 if (gimple_transaction_label_uninst (gs))
1919 pp_string (buffer, " UNINST=");
1920 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1921 spc, flags, false);
1923 if (gimple_transaction_label_over (gs))
1925 pp_string (buffer, " OVER=");
1926 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1927 spc, flags, false);
1929 if (subcode)
1931 pp_string (buffer, " SUBCODE=[ ");
1932 if (subcode & GTMA_HAVE_ABORT)
1934 pp_string (buffer, "GTMA_HAVE_ABORT ");
1935 subcode &= ~GTMA_HAVE_ABORT;
1937 if (subcode & GTMA_HAVE_LOAD)
1939 pp_string (buffer, "GTMA_HAVE_LOAD ");
1940 subcode &= ~GTMA_HAVE_LOAD;
1942 if (subcode & GTMA_HAVE_STORE)
1944 pp_string (buffer, "GTMA_HAVE_STORE ");
1945 subcode &= ~GTMA_HAVE_STORE;
1947 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1949 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1950 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1952 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1954 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1955 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1957 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1959 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1960 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1962 if (subcode)
1963 pp_printf (buffer, "0x%x ", subcode);
1964 pp_right_bracket (buffer);
1970 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1971 indent. FLAGS specifies details to show in the dump (see TDF_* in
1972 dumpfile.h). */
1974 static void
1975 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, dump_flags_t flags)
1977 unsigned int i, n, f, fields;
1979 if (flags & TDF_RAW)
1981 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1982 gimple_asm_string (gs));
1984 n = gimple_asm_noutputs (gs);
1985 if (n)
1987 newline_and_indent (buffer, spc + 2);
1988 pp_string (buffer, "OUTPUT: ");
1989 for (i = 0; i < n; i++)
1991 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1992 spc, flags, false);
1993 if (i < n - 1)
1994 pp_string (buffer, ", ");
1998 n = gimple_asm_ninputs (gs);
1999 if (n)
2001 newline_and_indent (buffer, spc + 2);
2002 pp_string (buffer, "INPUT: ");
2003 for (i = 0; i < n; i++)
2005 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2006 spc, flags, false);
2007 if (i < n - 1)
2008 pp_string (buffer, ", ");
2012 n = gimple_asm_nclobbers (gs);
2013 if (n)
2015 newline_and_indent (buffer, spc + 2);
2016 pp_string (buffer, "CLOBBER: ");
2017 for (i = 0; i < n; i++)
2019 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2020 spc, flags, false);
2021 if (i < n - 1)
2022 pp_string (buffer, ", ");
2026 n = gimple_asm_nlabels (gs);
2027 if (n)
2029 newline_and_indent (buffer, spc + 2);
2030 pp_string (buffer, "LABEL: ");
2031 for (i = 0; i < n; i++)
2033 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2034 spc, flags, false);
2035 if (i < n - 1)
2036 pp_string (buffer, ", ");
2040 newline_and_indent (buffer, spc);
2041 pp_greater (buffer);
2043 else
2045 pp_string (buffer, "__asm__");
2046 if (gimple_asm_volatile_p (gs))
2047 pp_string (buffer, " __volatile__");
2048 if (gimple_asm_nlabels (gs))
2049 pp_string (buffer, " goto");
2050 pp_string (buffer, "(\"");
2051 pp_string (buffer, gimple_asm_string (gs));
2052 pp_string (buffer, "\"");
2054 if (gimple_asm_nlabels (gs))
2055 fields = 4;
2056 else if (gimple_asm_nclobbers (gs))
2057 fields = 3;
2058 else if (gimple_asm_ninputs (gs))
2059 fields = 2;
2060 else if (gimple_asm_noutputs (gs))
2061 fields = 1;
2062 else
2063 fields = 0;
2065 for (f = 0; f < fields; ++f)
2067 pp_string (buffer, " : ");
2069 switch (f)
2071 case 0:
2072 n = gimple_asm_noutputs (gs);
2073 for (i = 0; i < n; i++)
2075 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2076 spc, flags, false);
2077 if (i < n - 1)
2078 pp_string (buffer, ", ");
2080 break;
2082 case 1:
2083 n = gimple_asm_ninputs (gs);
2084 for (i = 0; i < n; i++)
2086 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2087 spc, flags, false);
2088 if (i < n - 1)
2089 pp_string (buffer, ", ");
2091 break;
2093 case 2:
2094 n = gimple_asm_nclobbers (gs);
2095 for (i = 0; i < n; i++)
2097 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2098 spc, flags, false);
2099 if (i < n - 1)
2100 pp_string (buffer, ", ");
2102 break;
2104 case 3:
2105 n = gimple_asm_nlabels (gs);
2106 for (i = 0; i < n; i++)
2108 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2109 spc, flags, false);
2110 if (i < n - 1)
2111 pp_string (buffer, ", ");
2113 break;
2115 default:
2116 gcc_unreachable ();
2120 pp_string (buffer, ");");
2124 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2125 SPC spaces of indent. */
2127 static void
2128 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
2130 if (TREE_CODE (node) != SSA_NAME)
2131 return;
2133 if (POINTER_TYPE_P (TREE_TYPE (node))
2134 && SSA_NAME_PTR_INFO (node))
2136 unsigned int align, misalign;
2137 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
2138 pp_string (buffer, "# PT = ");
2139 pp_points_to_solution (buffer, &pi->pt);
2140 newline_and_indent (buffer, spc);
2141 if (get_ptr_info_alignment (pi, &align, &misalign))
2143 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
2144 newline_and_indent (buffer, spc);
2148 if (!POINTER_TYPE_P (TREE_TYPE (node))
2149 && SSA_NAME_RANGE_INFO (node))
2151 wide_int min, max, nonzero_bits;
2152 value_range_type range_type = get_range_info (node, &min, &max);
2154 if (range_type == VR_VARYING)
2155 pp_printf (buffer, "# RANGE VR_VARYING");
2156 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
2158 pp_printf (buffer, "# RANGE ");
2159 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
2160 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
2161 pp_printf (buffer, ", ");
2162 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
2163 pp_printf (buffer, "]");
2165 nonzero_bits = get_nonzero_bits (node);
2166 if (nonzero_bits != -1)
2168 pp_string (buffer, " NONZERO ");
2169 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2171 newline_and_indent (buffer, spc);
2175 /* As dump_ssaname_info, but dump to FILE. */
2177 void
2178 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2180 pretty_printer buffer;
2181 pp_needs_newline (&buffer) = true;
2182 buffer.buffer->stream = file;
2183 dump_ssaname_info (&buffer, node, spc);
2184 pp_flush (&buffer);
2187 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2188 The caller is responsible for calling pp_flush on BUFFER to finalize
2189 pretty printer. If COMMENT is true, print this after #. */
2191 static void
2192 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2193 dump_flags_t flags)
2195 size_t i;
2196 tree lhs = gimple_phi_result (phi);
2198 if (flags & TDF_ALIAS)
2199 dump_ssaname_info (buffer, lhs, spc);
2201 if (comment)
2202 pp_string (buffer, "# ");
2204 if (flags & TDF_RAW)
2205 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2206 gimple_phi_result (phi));
2207 else
2209 dump_generic_node (buffer, lhs, spc, flags, false);
2210 if (flags & TDF_GIMPLE)
2211 pp_string (buffer, " = __PHI (");
2212 else
2213 pp_string (buffer, " = PHI <");
2215 for (i = 0; i < gimple_phi_num_args (phi); i++)
2217 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2218 dump_location (buffer, gimple_phi_arg_location (phi, i));
2219 if (flags & TDF_GIMPLE)
2221 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2222 gimple *stmt = first_stmt (src);
2223 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2225 pp_string (buffer, "bb_");
2226 pp_decimal_int (buffer, src->index);
2228 else
2229 dump_generic_node (buffer, gimple_label_label (as_a <glabel *> (stmt)), 0, flags,
2230 false);
2231 pp_string (buffer, ": ");
2233 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2234 false);
2235 if (! (flags & TDF_GIMPLE))
2237 pp_left_paren (buffer);
2238 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2239 pp_right_paren (buffer);
2241 if (i < gimple_phi_num_args (phi) - 1)
2242 pp_string (buffer, ", ");
2244 if (flags & TDF_GIMPLE)
2245 pp_string (buffer, ");");
2246 else
2247 pp_greater (buffer);
2251 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2252 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2253 dumpfile.h). */
2255 static void
2256 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2257 int spc, dump_flags_t flags)
2259 if (flags & TDF_RAW)
2261 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2262 gimple_omp_body (gs));
2263 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2264 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2265 gimple_omp_parallel_child_fn (gs),
2266 gimple_omp_parallel_data_arg (gs));
2268 else
2270 gimple_seq body;
2271 pp_string (buffer, "#pragma omp parallel");
2272 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2273 if (gimple_omp_parallel_child_fn (gs))
2275 pp_string (buffer, " [child fn: ");
2276 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2277 spc, flags, false);
2278 pp_string (buffer, " (");
2279 if (gimple_omp_parallel_data_arg (gs))
2280 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2281 spc, flags, false);
2282 else
2283 pp_string (buffer, "???");
2284 pp_string (buffer, ")]");
2286 body = gimple_omp_body (gs);
2287 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2289 newline_and_indent (buffer, spc + 2);
2290 pp_left_brace (buffer);
2291 pp_newline (buffer);
2292 dump_gimple_seq (buffer, body, spc + 4, flags);
2293 newline_and_indent (buffer, spc + 2);
2294 pp_right_brace (buffer);
2296 else if (body)
2298 pp_newline (buffer);
2299 dump_gimple_seq (buffer, body, spc + 2, flags);
2305 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2306 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2307 dumpfile.h). */
2309 static void
2310 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2311 dump_flags_t flags)
2313 if (flags & TDF_RAW)
2315 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2316 gimple_omp_body (gs));
2317 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2318 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2319 gimple_omp_task_child_fn (gs),
2320 gimple_omp_task_data_arg (gs),
2321 gimple_omp_task_copy_fn (gs),
2322 gimple_omp_task_arg_size (gs),
2323 gimple_omp_task_arg_size (gs));
2325 else
2327 gimple_seq body;
2328 if (gimple_omp_task_taskloop_p (gs))
2329 pp_string (buffer, "#pragma omp taskloop");
2330 else
2331 pp_string (buffer, "#pragma omp task");
2332 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2333 if (gimple_omp_task_child_fn (gs))
2335 pp_string (buffer, " [child fn: ");
2336 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2337 spc, flags, false);
2338 pp_string (buffer, " (");
2339 if (gimple_omp_task_data_arg (gs))
2340 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2341 spc, flags, false);
2342 else
2343 pp_string (buffer, "???");
2344 pp_string (buffer, ")]");
2346 body = gimple_omp_body (gs);
2347 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2349 newline_and_indent (buffer, spc + 2);
2350 pp_left_brace (buffer);
2351 pp_newline (buffer);
2352 dump_gimple_seq (buffer, body, spc + 4, flags);
2353 newline_and_indent (buffer, spc + 2);
2354 pp_right_brace (buffer);
2356 else if (body)
2358 pp_newline (buffer);
2359 dump_gimple_seq (buffer, body, spc + 2, flags);
2365 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2366 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2367 in dumpfile.h). */
2369 static void
2370 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2371 int spc, dump_flags_t flags)
2373 if (flags & TDF_RAW)
2375 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2376 gimple_omp_atomic_load_lhs (gs),
2377 gimple_omp_atomic_load_rhs (gs));
2379 else
2381 pp_string (buffer, "#pragma omp atomic_load");
2382 if (gimple_omp_atomic_seq_cst_p (gs))
2383 pp_string (buffer, " seq_cst");
2384 if (gimple_omp_atomic_need_value_p (gs))
2385 pp_string (buffer, " [needed]");
2386 newline_and_indent (buffer, spc + 2);
2387 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2388 spc, flags, false);
2389 pp_space (buffer);
2390 pp_equal (buffer);
2391 pp_space (buffer);
2392 pp_star (buffer);
2393 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2394 spc, flags, false);
2398 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2399 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2400 in dumpfile.h). */
2402 static void
2403 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2404 gomp_atomic_store *gs, int spc,
2405 dump_flags_t flags)
2407 if (flags & TDF_RAW)
2409 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2410 gimple_omp_atomic_store_val (gs));
2412 else
2414 pp_string (buffer, "#pragma omp atomic_store ");
2415 if (gimple_omp_atomic_seq_cst_p (gs))
2416 pp_string (buffer, "seq_cst ");
2417 if (gimple_omp_atomic_need_value_p (gs))
2418 pp_string (buffer, "[needed] ");
2419 pp_left_paren (buffer);
2420 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2421 spc, flags, false);
2422 pp_right_paren (buffer);
2427 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2428 FLAGS are as in pp_gimple_stmt_1. */
2430 static void
2431 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc,
2432 dump_flags_t flags)
2434 tree vdef = gimple_vdef (gs);
2435 tree vuse = gimple_vuse (gs);
2437 if (vdef != NULL_TREE)
2439 pp_string (buffer, "# ");
2440 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2441 pp_string (buffer, " = VDEF <");
2442 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2443 pp_greater (buffer);
2444 newline_and_indent (buffer, spc);
2446 else if (vuse != NULL_TREE)
2448 pp_string (buffer, "# VUSE <");
2449 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2450 pp_greater (buffer);
2451 newline_and_indent (buffer, spc);
2456 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2457 spaces of indent. FLAGS specifies details to show in the dump (see
2458 TDF_* in dumpfile.h). The caller is responsible for calling
2459 pp_flush on BUFFER to finalize the pretty printer. */
2461 void
2462 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc,
2463 dump_flags_t flags)
2465 if (!gs)
2466 return;
2468 if (flags & TDF_STMTADDR)
2469 pp_printf (buffer, "<&%p> ", (void *) gs);
2471 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2472 dump_location (buffer, gimple_location (gs));
2474 if (flags & TDF_EH)
2476 int lp_nr = lookup_stmt_eh_lp (gs);
2477 if (lp_nr > 0)
2478 pp_printf (buffer, "[LP %d] ", lp_nr);
2479 else if (lp_nr < 0)
2480 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2483 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2484 && gimple_has_mem_ops (gs))
2485 dump_gimple_mem_ops (buffer, gs, spc, flags);
2487 if (gimple_has_lhs (gs)
2488 && (flags & TDF_ALIAS))
2489 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2491 switch (gimple_code (gs))
2493 case GIMPLE_ASM:
2494 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2495 break;
2497 case GIMPLE_ASSIGN:
2498 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2499 break;
2501 case GIMPLE_BIND:
2502 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2503 break;
2505 case GIMPLE_CALL:
2506 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2507 break;
2509 case GIMPLE_COND:
2510 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2511 break;
2513 case GIMPLE_LABEL:
2514 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2515 break;
2517 case GIMPLE_GOTO:
2518 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2519 break;
2521 case GIMPLE_NOP:
2522 pp_string (buffer, "GIMPLE_NOP");
2523 break;
2525 case GIMPLE_RETURN:
2526 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2527 break;
2529 case GIMPLE_SWITCH:
2530 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2531 break;
2533 case GIMPLE_TRY:
2534 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2535 break;
2537 case GIMPLE_PHI:
2538 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2539 break;
2541 case GIMPLE_OMP_PARALLEL:
2542 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2543 flags);
2544 break;
2546 case GIMPLE_OMP_TASK:
2547 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2548 break;
2550 case GIMPLE_OMP_ATOMIC_LOAD:
2551 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2552 spc, flags);
2553 break;
2555 case GIMPLE_OMP_ATOMIC_STORE:
2556 dump_gimple_omp_atomic_store (buffer,
2557 as_a <gomp_atomic_store *> (gs),
2558 spc, flags);
2559 break;
2561 case GIMPLE_OMP_FOR:
2562 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2563 break;
2565 case GIMPLE_OMP_CONTINUE:
2566 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2567 flags);
2568 break;
2570 case GIMPLE_OMP_SINGLE:
2571 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2572 flags);
2573 break;
2575 case GIMPLE_OMP_TARGET:
2576 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2577 flags);
2578 break;
2580 case GIMPLE_OMP_TEAMS:
2581 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2582 flags);
2583 break;
2585 case GIMPLE_OMP_RETURN:
2586 dump_gimple_omp_return (buffer, gs, spc, flags);
2587 break;
2589 case GIMPLE_OMP_SECTIONS:
2590 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2591 spc, flags);
2592 break;
2594 case GIMPLE_OMP_SECTIONS_SWITCH:
2595 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2596 break;
2598 case GIMPLE_OMP_MASTER:
2599 case GIMPLE_OMP_TASKGROUP:
2600 case GIMPLE_OMP_SECTION:
2601 case GIMPLE_OMP_GRID_BODY:
2602 dump_gimple_omp_block (buffer, gs, spc, flags);
2603 break;
2605 case GIMPLE_OMP_ORDERED:
2606 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2607 flags);
2608 break;
2610 case GIMPLE_OMP_CRITICAL:
2611 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2612 flags);
2613 break;
2615 case GIMPLE_CATCH:
2616 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2617 break;
2619 case GIMPLE_EH_FILTER:
2620 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2621 break;
2623 case GIMPLE_EH_MUST_NOT_THROW:
2624 dump_gimple_eh_must_not_throw (buffer,
2625 as_a <geh_mnt *> (gs),
2626 spc, flags);
2627 break;
2629 case GIMPLE_EH_ELSE:
2630 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2631 break;
2633 case GIMPLE_RESX:
2634 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2635 break;
2637 case GIMPLE_EH_DISPATCH:
2638 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2639 flags);
2640 break;
2642 case GIMPLE_DEBUG:
2643 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2644 break;
2646 case GIMPLE_PREDICT:
2647 pp_string (buffer, "// predicted ");
2648 if (gimple_predict_outcome (gs))
2649 pp_string (buffer, "likely by ");
2650 else
2651 pp_string (buffer, "unlikely by ");
2652 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2653 pp_string (buffer, " predictor.");
2654 break;
2656 case GIMPLE_TRANSACTION:
2657 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2658 flags);
2659 break;
2661 default:
2662 GIMPLE_NIY;
2667 /* Dumps header of basic block BB to OUTF indented by INDENT
2668 spaces and details described by flags. */
2670 static void
2671 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
2672 dump_flags_t flags)
2674 if (flags & TDF_BLOCKS)
2676 if (flags & TDF_LINENO)
2678 gimple_stmt_iterator gsi;
2680 fputs (";; ", outf);
2682 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2683 if (!is_gimple_debug (gsi_stmt (gsi))
2684 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2686 fprintf (outf, "%*sstarting at line %d",
2687 indent, "", get_lineno (gsi_stmt (gsi)));
2688 break;
2690 if (bb->discriminator)
2691 fprintf (outf, ", discriminator %i", bb->discriminator);
2692 fputc ('\n', outf);
2695 else
2697 if (flags & TDF_GIMPLE)
2698 fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
2699 else
2700 fprintf (outf, "%*s<bb %d> %s:\n",
2701 indent, "", bb->index, dump_profile (bb->frequency,
2702 bb->count));
2707 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2708 spaces. */
2710 static void
2711 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2712 basic_block bb ATTRIBUTE_UNUSED,
2713 int indent ATTRIBUTE_UNUSED,
2714 dump_flags_t flags ATTRIBUTE_UNUSED)
2716 /* There is currently no GIMPLE-specific basic block info to dump. */
2717 return;
2721 /* Dump PHI nodes of basic block BB to BUFFER with details described
2722 by FLAGS and indented by INDENT spaces. */
2724 static void
2725 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
2726 dump_flags_t flags)
2728 gphi_iterator i;
2730 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2732 gphi *phi = i.phi ();
2733 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2735 INDENT (indent);
2736 dump_gimple_phi (buffer, phi, indent,
2737 (flags & TDF_GIMPLE) ? false : true, flags);
2738 pp_newline (buffer);
2744 /* Dump jump to basic block BB that is represented implicitly in the cfg
2745 to BUFFER. */
2747 static void
2748 pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
2750 if (flags & TDF_GIMPLE)
2752 pp_string (buffer, "goto bb_");
2753 pp_decimal_int (buffer, e->dest->index);
2754 pp_semicolon (buffer);
2756 else
2758 pp_string (buffer, "goto <bb ");
2759 pp_decimal_int (buffer, e->dest->index);
2760 pp_greater (buffer);
2761 pp_semicolon (buffer);
2763 dump_edge_probability (buffer, e);
2768 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2769 by INDENT spaces, with details given by FLAGS. */
2771 static void
2772 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2773 dump_flags_t flags)
2775 edge e;
2776 gimple *stmt;
2778 stmt = last_stmt (bb);
2780 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2782 edge true_edge, false_edge;
2784 /* When we are emitting the code or changing CFG, it is possible that
2785 the edges are not yet created. When we are using debug_bb in such
2786 a situation, we do not want it to crash. */
2787 if (EDGE_COUNT (bb->succs) != 2)
2788 return;
2789 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2791 INDENT (indent + 2);
2792 pp_cfg_jump (buffer, true_edge, flags);
2793 newline_and_indent (buffer, indent);
2794 pp_string (buffer, "else");
2795 newline_and_indent (buffer, indent + 2);
2796 pp_cfg_jump (buffer, false_edge, flags);
2797 pp_newline (buffer);
2798 return;
2801 /* If there is a fallthru edge, we may need to add an artificial
2802 goto to the dump. */
2803 e = find_fallthru_edge (bb->succs);
2805 if (e && e->dest != bb->next_bb)
2807 INDENT (indent);
2809 if ((flags & TDF_LINENO)
2810 && e->goto_locus != UNKNOWN_LOCATION)
2811 dump_location (buffer, e->goto_locus);
2813 pp_cfg_jump (buffer, e, flags);
2814 pp_newline (buffer);
2819 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2820 indented by INDENT spaces. */
2822 static void
2823 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2824 dump_flags_t flags)
2826 gimple_stmt_iterator gsi;
2827 gimple *stmt;
2828 int label_indent = indent - 2;
2830 if (label_indent < 0)
2831 label_indent = 0;
2833 dump_phi_nodes (buffer, bb, indent, flags);
2835 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2837 int curr_indent;
2839 stmt = gsi_stmt (gsi);
2841 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2843 INDENT (curr_indent);
2844 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2845 pp_newline_and_flush (buffer);
2846 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2847 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2848 pp_buffer (buffer)->stream, stmt);
2851 dump_implicit_edges (buffer, bb, indent, flags);
2852 pp_flush (buffer);
2856 /* Dumps basic block BB to FILE with details described by FLAGS and
2857 indented by INDENT spaces. */
2859 void
2860 gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
2862 dump_gimple_bb_header (file, bb, indent, flags);
2863 if (bb->index >= NUM_FIXED_BLOCKS)
2865 pretty_printer buffer;
2866 pp_needs_newline (&buffer) = true;
2867 buffer.buffer->stream = file;
2868 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2870 dump_gimple_bb_footer (file, bb, indent, flags);
2873 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2874 no indentation, for use as a label of a DOT graph record-node.
2875 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2876 histogram dumping doesn't know about pretty-printers. */
2878 void
2879 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2881 pp_printf (pp, "<bb %d>:\n", bb->index);
2882 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2884 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2885 gsi_next (&gsi))
2887 gphi *phi = gsi.phi ();
2888 if (!virtual_operand_p (gimple_phi_result (phi))
2889 || (dump_flags & TDF_VOPS))
2891 pp_bar (pp);
2892 pp_write_text_to_stream (pp);
2893 pp_string (pp, "# ");
2894 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2895 pp_newline (pp);
2896 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2900 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2901 gsi_next (&gsi))
2903 gimple *stmt = gsi_stmt (gsi);
2904 pp_bar (pp);
2905 pp_write_text_to_stream (pp);
2906 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2907 pp_newline (pp);
2908 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2910 dump_implicit_edges (pp, bb, 0, dump_flags);
2911 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2915 /* Handle the %G format for TEXT. Same as %K in handle_K_format in
2916 tree-pretty-print.c but with a Gimple call statement as an argument. */
2918 void
2919 percent_G_format (text_info *text)
2921 gcall *stmt = va_arg (*text->args_ptr, gcall*);
2923 /* Build a call expression from the Gimple call statement and
2924 pass it to the K formatter that knows how to format it. */
2925 tree exp = build_vl_exp (CALL_EXPR, gimple_call_num_args (stmt) + 3);
2926 CALL_EXPR_FN (exp) = gimple_call_fn (stmt);
2927 TREE_TYPE (exp) = gimple_call_return_type (stmt);
2928 CALL_EXPR_STATIC_CHAIN (exp) = gimple_call_chain (stmt);
2929 SET_EXPR_LOCATION (exp, gimple_location (stmt));
2931 percent_K_format (text, exp);