2016-11-10 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / gimple-pretty-print.c
blobf588f5e445edb22672b8e565cf7ebf1e472e18db
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2016 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 "backend.h"
26 #include "tree.h"
27 #include "gimple.h"
28 #include "gimple-predict.h"
29 #include "ssa.h"
30 #include "cgraph.h"
31 #include "gimple-pretty-print.h"
32 #include "internal-fn.h"
33 #include "tree-eh.h"
34 #include "gimple-iterator.h"
35 #include "tree-cfg.h"
36 #include "dumpfile.h" /* for dump_flags */
37 #include "value-prof.h"
38 #include "trans-mem.h"
40 #define INDENT(SPACE) \
41 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
43 #define GIMPLE_NIY do_niy (buffer,gs)
45 /* Try to print on BUFFER a default message for the unrecognized
46 gimple statement GS. */
48 static void
49 do_niy (pretty_printer *buffer, gimple *gs)
51 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
52 gimple_code_name[(int) gimple_code (gs)]);
56 /* Emit a newline and SPC indentation spaces to BUFFER. */
58 static void
59 newline_and_indent (pretty_printer *buffer, int spc)
61 pp_newline (buffer);
62 INDENT (spc);
66 /* Print the GIMPLE statement GS on stderr. */
68 DEBUG_FUNCTION void
69 debug_gimple_stmt (gimple *gs)
71 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
75 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
76 FLAGS as in pp_gimple_stmt_1. */
78 void
79 print_gimple_stmt (FILE *file, gimple *g, int spc, int flags)
81 pretty_printer buffer;
82 pp_needs_newline (&buffer) = true;
83 buffer.buffer->stream = file;
84 pp_gimple_stmt_1 (&buffer, g, spc, flags);
85 pp_newline_and_flush (&buffer);
88 DEBUG_FUNCTION void
89 debug (gimple &ref)
91 print_gimple_stmt (stderr, &ref, 0, 0);
94 DEBUG_FUNCTION void
95 debug (gimple *ptr)
97 if (ptr)
98 debug (*ptr);
99 else
100 fprintf (stderr, "<nil>\n");
104 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
105 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
106 of the statement. */
108 void
109 print_gimple_expr (FILE *file, gimple *g, int spc, int flags)
111 flags |= TDF_RHS_ONLY;
112 pretty_printer buffer;
113 pp_needs_newline (&buffer) = true;
114 buffer.buffer->stream = file;
115 pp_gimple_stmt_1 (&buffer, g, spc, flags);
116 pp_flush (&buffer);
120 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
121 spaces and FLAGS as in pp_gimple_stmt_1.
122 The caller is responsible for calling pp_flush on BUFFER to finalize
123 the pretty printer. */
125 static void
126 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
128 gimple_stmt_iterator i;
130 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
132 gimple *gs = gsi_stmt (i);
133 INDENT (spc);
134 pp_gimple_stmt_1 (buffer, gs, spc, flags);
135 if (!gsi_one_before_end_p (i))
136 pp_newline (buffer);
141 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
142 FLAGS as in pp_gimple_stmt_1. */
144 void
145 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
147 pretty_printer buffer;
148 pp_needs_newline (&buffer) = true;
149 buffer.buffer->stream = file;
150 dump_gimple_seq (&buffer, seq, spc, flags);
151 pp_newline_and_flush (&buffer);
155 /* Print the GIMPLE sequence SEQ on stderr. */
157 DEBUG_FUNCTION void
158 debug_gimple_seq (gimple_seq seq)
160 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
164 /* A simple helper to pretty-print some of the gimple tuples in the printf
165 style. The format modifiers are preceded by '%' and are:
166 'G' - outputs a string corresponding to the code of the given gimple,
167 'S' - outputs a gimple_seq with indent of spc + 2,
168 'T' - outputs the tree t,
169 'd' - outputs an int as a decimal,
170 's' - outputs a string,
171 'n' - outputs a newline,
172 'x' - outputs an int as hexadecimal,
173 '+' - increases indent by 2 then outputs a newline,
174 '-' - decreases indent by 2 then outputs a newline. */
176 static void
177 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
178 const char *fmt, ...)
180 va_list args;
181 const char *c;
182 const char *tmp;
184 va_start (args, fmt);
185 for (c = fmt; *c; c++)
187 if (*c == '%')
189 gimple_seq seq;
190 tree t;
191 gimple *g;
192 switch (*++c)
194 case 'G':
195 g = va_arg (args, gimple *);
196 tmp = gimple_code_name[gimple_code (g)];
197 pp_string (buffer, tmp);
198 break;
200 case 'S':
201 seq = va_arg (args, gimple_seq);
202 pp_newline (buffer);
203 dump_gimple_seq (buffer, seq, spc + 2, flags);
204 newline_and_indent (buffer, spc);
205 break;
207 case 'T':
208 t = va_arg (args, tree);
209 if (t == NULL_TREE)
210 pp_string (buffer, "NULL");
211 else
212 dump_generic_node (buffer, t, spc, flags, false);
213 break;
215 case 'd':
216 pp_decimal_int (buffer, va_arg (args, int));
217 break;
219 case 's':
220 pp_string (buffer, va_arg (args, char *));
221 break;
223 case 'n':
224 newline_and_indent (buffer, spc);
225 break;
227 case 'x':
228 pp_scalar (buffer, "%x", va_arg (args, int));
229 break;
231 case '+':
232 spc += 2;
233 newline_and_indent (buffer, spc);
234 break;
236 case '-':
237 spc -= 2;
238 newline_and_indent (buffer, spc);
239 break;
241 default:
242 gcc_unreachable ();
245 else
246 pp_character (buffer, *c);
248 va_end (args);
252 /* Helper for dump_gimple_assign. Print the unary RHS of the
253 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
255 static void
256 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
258 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
259 tree lhs = gimple_assign_lhs (gs);
260 tree rhs = gimple_assign_rhs1 (gs);
262 switch (rhs_code)
264 case VIEW_CONVERT_EXPR:
265 case ASSERT_EXPR:
266 dump_generic_node (buffer, rhs, spc, flags, false);
267 break;
269 case FIXED_CONVERT_EXPR:
270 case ADDR_SPACE_CONVERT_EXPR:
271 case FIX_TRUNC_EXPR:
272 case FLOAT_EXPR:
273 CASE_CONVERT:
274 pp_left_paren (buffer);
275 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
276 pp_string (buffer, ") ");
277 if (op_prio (rhs) < op_code_prio (rhs_code))
279 pp_left_paren (buffer);
280 dump_generic_node (buffer, rhs, spc, flags, false);
281 pp_right_paren (buffer);
283 else
284 dump_generic_node (buffer, rhs, spc, flags, false);
285 break;
287 case PAREN_EXPR:
288 pp_string (buffer, "((");
289 dump_generic_node (buffer, rhs, spc, flags, false);
290 pp_string (buffer, "))");
291 break;
293 case ABS_EXPR:
294 pp_string (buffer, "ABS_EXPR <");
295 dump_generic_node (buffer, rhs, spc, flags, false);
296 pp_greater (buffer);
297 break;
299 default:
300 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
301 || TREE_CODE_CLASS (rhs_code) == tcc_constant
302 || TREE_CODE_CLASS (rhs_code) == tcc_reference
303 || rhs_code == SSA_NAME
304 || rhs_code == ADDR_EXPR
305 || rhs_code == CONSTRUCTOR)
307 dump_generic_node (buffer, rhs, spc, flags, false);
308 break;
310 else if (rhs_code == BIT_NOT_EXPR)
311 pp_complement (buffer);
312 else if (rhs_code == TRUTH_NOT_EXPR)
313 pp_exclamation (buffer);
314 else if (rhs_code == NEGATE_EXPR)
315 pp_minus (buffer);
316 else
318 pp_left_bracket (buffer);
319 pp_string (buffer, get_tree_code_name (rhs_code));
320 pp_string (buffer, "] ");
323 if (op_prio (rhs) < op_code_prio (rhs_code))
325 pp_left_paren (buffer);
326 dump_generic_node (buffer, rhs, spc, flags, false);
327 pp_right_paren (buffer);
329 else
330 dump_generic_node (buffer, rhs, spc, flags, false);
331 break;
336 /* Helper for dump_gimple_assign. Print the binary RHS of the
337 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
339 static void
340 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
342 const char *p;
343 enum tree_code code = gimple_assign_rhs_code (gs);
344 switch (code)
346 case COMPLEX_EXPR:
347 case MIN_EXPR:
348 case MAX_EXPR:
349 case VEC_WIDEN_MULT_HI_EXPR:
350 case VEC_WIDEN_MULT_LO_EXPR:
351 case VEC_WIDEN_MULT_EVEN_EXPR:
352 case VEC_WIDEN_MULT_ODD_EXPR:
353 case VEC_PACK_TRUNC_EXPR:
354 case VEC_PACK_SAT_EXPR:
355 case VEC_PACK_FIX_TRUNC_EXPR:
356 case VEC_WIDEN_LSHIFT_HI_EXPR:
357 case VEC_WIDEN_LSHIFT_LO_EXPR:
358 for (p = get_tree_code_name (code); *p; p++)
359 pp_character (buffer, TOUPPER (*p));
360 pp_string (buffer, " <");
361 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
362 pp_string (buffer, ", ");
363 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
364 pp_greater (buffer);
365 break;
367 default:
368 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
370 pp_left_paren (buffer);
371 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
372 false);
373 pp_right_paren (buffer);
375 else
376 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
377 pp_space (buffer);
378 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
379 pp_space (buffer);
380 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
382 pp_left_paren (buffer);
383 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
384 false);
385 pp_right_paren (buffer);
387 else
388 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
392 /* Helper for dump_gimple_assign. Print the ternary RHS of the
393 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
395 static void
396 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
398 const char *p;
399 enum tree_code code = gimple_assign_rhs_code (gs);
400 switch (code)
402 case WIDEN_MULT_PLUS_EXPR:
403 case WIDEN_MULT_MINUS_EXPR:
404 for (p = get_tree_code_name (code); *p; p++)
405 pp_character (buffer, TOUPPER (*p));
406 pp_string (buffer, " <");
407 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
408 pp_string (buffer, ", ");
409 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
410 pp_string (buffer, ", ");
411 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
412 pp_greater (buffer);
413 break;
415 case FMA_EXPR:
416 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
417 pp_string (buffer, " * ");
418 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
419 pp_string (buffer, " + ");
420 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
421 break;
423 case DOT_PROD_EXPR:
424 pp_string (buffer, "DOT_PROD_EXPR <");
425 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
426 pp_string (buffer, ", ");
427 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
428 pp_string (buffer, ", ");
429 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
430 pp_greater (buffer);
431 break;
433 case SAD_EXPR:
434 pp_string (buffer, "SAD_EXPR <");
435 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
436 pp_string (buffer, ", ");
437 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
438 pp_string (buffer, ", ");
439 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
440 pp_greater (buffer);
441 break;
443 case VEC_PERM_EXPR:
444 pp_string (buffer, "VEC_PERM_EXPR <");
445 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
446 pp_string (buffer, ", ");
447 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
448 pp_string (buffer, ", ");
449 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
450 pp_greater (buffer);
451 break;
453 case REALIGN_LOAD_EXPR:
454 pp_string (buffer, "REALIGN_LOAD <");
455 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
456 pp_string (buffer, ", ");
457 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
458 pp_string (buffer, ", ");
459 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
460 pp_greater (buffer);
461 break;
463 case COND_EXPR:
464 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
465 pp_string (buffer, " ? ");
466 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
467 pp_string (buffer, " : ");
468 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
469 break;
471 case VEC_COND_EXPR:
472 pp_string (buffer, "VEC_COND_EXPR <");
473 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
474 pp_string (buffer, ", ");
475 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
476 pp_string (buffer, ", ");
477 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
478 pp_greater (buffer);
479 break;
481 case BIT_INSERT_EXPR:
482 pp_string (buffer, "BIT_INSERT_EXPR <");
483 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
484 pp_string (buffer, ", ");
485 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
486 pp_string (buffer, ", ");
487 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
488 pp_string (buffer, " (");
489 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
490 pp_decimal_int (buffer,
491 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
492 else
493 dump_generic_node (buffer,
494 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
495 spc, flags, false);
496 pp_string (buffer, " bits)>");
497 break;
499 default:
500 gcc_unreachable ();
505 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
506 pp_gimple_stmt_1. */
508 static void
509 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
511 if (flags & TDF_RAW)
513 tree arg1 = NULL;
514 tree arg2 = NULL;
515 tree arg3 = NULL;
516 switch (gimple_num_ops (gs))
518 case 4:
519 arg3 = gimple_assign_rhs3 (gs);
520 /* FALLTHRU */
521 case 3:
522 arg2 = gimple_assign_rhs2 (gs);
523 /* FALLTHRU */
524 case 2:
525 arg1 = gimple_assign_rhs1 (gs);
526 break;
527 default:
528 gcc_unreachable ();
531 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
532 get_tree_code_name (gimple_assign_rhs_code (gs)),
533 gimple_assign_lhs (gs), arg1, arg2, arg3);
535 else
537 if (!(flags & TDF_RHS_ONLY))
539 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
540 pp_space (buffer);
541 pp_equal (buffer);
543 if (gimple_assign_nontemporal_move_p (gs))
544 pp_string (buffer, "{nt}");
546 if (gimple_has_volatile_ops (gs))
547 pp_string (buffer, "{v}");
549 pp_space (buffer);
552 if (gimple_num_ops (gs) == 2)
553 dump_unary_rhs (buffer, gs, spc, flags);
554 else if (gimple_num_ops (gs) == 3)
555 dump_binary_rhs (buffer, gs, spc, flags);
556 else if (gimple_num_ops (gs) == 4)
557 dump_ternary_rhs (buffer, gs, spc, flags);
558 else
559 gcc_unreachable ();
560 if (!(flags & TDF_RHS_ONLY))
561 pp_semicolon (buffer);
566 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
567 pp_gimple_stmt_1. */
569 static void
570 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
572 tree t, t2;
574 t = gimple_return_retval (gs);
575 t2 = gimple_return_retbnd (gs);
576 if (flags & TDF_RAW)
577 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
578 else
580 pp_string (buffer, "return");
581 if (t)
583 pp_space (buffer);
584 dump_generic_node (buffer, t, spc, flags, false);
586 if (t2)
588 pp_string (buffer, ", ");
589 dump_generic_node (buffer, t2, spc, flags, false);
591 pp_semicolon (buffer);
596 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
597 dump_gimple_call. */
599 static void
600 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
602 size_t i = 0;
604 /* Pretty print first arg to certain internal fns. */
605 if (gimple_call_internal_p (gs))
607 const char *const *enums = NULL;
608 unsigned limit = 0;
610 switch (gimple_call_internal_fn (gs))
612 case IFN_UNIQUE:
613 #define DEF(X) #X
614 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
615 #undef DEF
616 enums = unique_args;
618 limit = ARRAY_SIZE (unique_args);
619 break;
621 case IFN_GOACC_LOOP:
622 #define DEF(X) #X
623 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
624 #undef DEF
625 enums = loop_args;
626 limit = ARRAY_SIZE (loop_args);
627 break;
629 case IFN_GOACC_REDUCTION:
630 #define DEF(X) #X
631 static const char *const reduction_args[]
632 = {IFN_GOACC_REDUCTION_CODES};
633 #undef DEF
634 enums = reduction_args;
635 limit = ARRAY_SIZE (reduction_args);
636 break;
638 default:
639 break;
641 if (limit)
643 tree arg0 = gimple_call_arg (gs, 0);
644 HOST_WIDE_INT v;
646 if (TREE_CODE (arg0) == INTEGER_CST
647 && tree_fits_shwi_p (arg0)
648 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
650 i++;
651 pp_string (buffer, enums[v]);
656 for (; i < gimple_call_num_args (gs); i++)
658 if (i)
659 pp_string (buffer, ", ");
660 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
663 if (gimple_call_va_arg_pack_p (gs))
665 if (i)
666 pp_string (buffer, ", ");
668 pp_string (buffer, "__builtin_va_arg_pack ()");
672 /* Dump the points-to solution *PT to BUFFER. */
674 static void
675 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
677 if (pt->anything)
679 pp_string (buffer, "anything ");
680 return;
682 if (pt->nonlocal)
683 pp_string (buffer, "nonlocal ");
684 if (pt->escaped)
685 pp_string (buffer, "escaped ");
686 if (pt->ipa_escaped)
687 pp_string (buffer, "unit-escaped ");
688 if (pt->null)
689 pp_string (buffer, "null ");
690 if (pt->vars
691 && !bitmap_empty_p (pt->vars))
693 bitmap_iterator bi;
694 unsigned i;
695 pp_string (buffer, "{ ");
696 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
698 pp_string (buffer, "D.");
699 pp_decimal_int (buffer, i);
700 pp_space (buffer);
702 pp_right_brace (buffer);
703 if (pt->vars_contains_nonlocal
704 || pt->vars_contains_escaped
705 || pt->vars_contains_escaped_heap
706 || pt->vars_contains_restrict)
708 const char *comma = "";
709 pp_string (buffer, " (");
710 if (pt->vars_contains_nonlocal)
712 pp_string (buffer, "nonlocal");
713 comma = ", ";
715 if (pt->vars_contains_escaped)
717 pp_string (buffer, comma);
718 pp_string (buffer, "escaped");
719 comma = ", ";
721 if (pt->vars_contains_escaped_heap)
723 pp_string (buffer, comma);
724 pp_string (buffer, "escaped heap");
725 comma = ", ";
727 if (pt->vars_contains_restrict)
729 pp_string (buffer, comma);
730 pp_string (buffer, "restrict");
731 comma = ", ";
733 if (pt->vars_contains_interposable)
735 pp_string (buffer, comma);
736 pp_string (buffer, "interposable");
738 pp_string (buffer, ")");
744 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
745 pp_gimple_stmt_1. */
747 static void
748 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
750 tree lhs = gimple_call_lhs (gs);
751 tree fn = gimple_call_fn (gs);
753 if (flags & TDF_ALIAS)
755 struct pt_solution *pt;
756 pt = gimple_call_use_set (gs);
757 if (!pt_solution_empty_p (pt))
759 pp_string (buffer, "# USE = ");
760 pp_points_to_solution (buffer, pt);
761 newline_and_indent (buffer, spc);
763 pt = gimple_call_clobber_set (gs);
764 if (!pt_solution_empty_p (pt))
766 pp_string (buffer, "# CLB = ");
767 pp_points_to_solution (buffer, pt);
768 newline_and_indent (buffer, spc);
772 if (flags & TDF_RAW)
774 if (gimple_call_internal_p (gs))
775 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
776 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
777 else
778 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
779 if (gimple_call_num_args (gs) > 0)
781 pp_string (buffer, ", ");
782 dump_gimple_call_args (buffer, gs, flags);
784 pp_greater (buffer);
786 else
788 if (lhs && !(flags & TDF_RHS_ONLY))
790 dump_generic_node (buffer, lhs, spc, flags, false);
791 pp_string (buffer, " =");
793 if (gimple_has_volatile_ops (gs))
794 pp_string (buffer, "{v}");
796 pp_space (buffer);
798 if (gimple_call_internal_p (gs))
799 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
800 else
801 print_call_name (buffer, fn, flags);
802 pp_string (buffer, " (");
803 dump_gimple_call_args (buffer, gs, flags);
804 pp_right_paren (buffer);
805 if (!(flags & TDF_RHS_ONLY))
806 pp_semicolon (buffer);
809 if (gimple_call_chain (gs))
811 pp_string (buffer, " [static-chain: ");
812 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
813 pp_right_bracket (buffer);
816 if (gimple_call_return_slot_opt_p (gs))
817 pp_string (buffer, " [return slot optimization]");
818 if (gimple_call_tail_p (gs))
819 pp_string (buffer, " [tail call]");
820 if (gimple_call_must_tail_p (gs))
821 pp_string (buffer, " [must tail call]");
823 if (fn == NULL)
824 return;
826 /* Dump the arguments of _ITM_beginTransaction sanely. */
827 if (TREE_CODE (fn) == ADDR_EXPR)
828 fn = TREE_OPERAND (fn, 0);
829 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
830 pp_string (buffer, " [tm-clone]");
831 if (TREE_CODE (fn) == FUNCTION_DECL
832 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
833 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
834 && gimple_call_num_args (gs) > 0)
836 tree t = gimple_call_arg (gs, 0);
837 unsigned HOST_WIDE_INT props;
838 gcc_assert (TREE_CODE (t) == INTEGER_CST);
840 pp_string (buffer, " [ ");
842 /* Get the transaction code properties. */
843 props = TREE_INT_CST_LOW (t);
845 if (props & PR_INSTRUMENTEDCODE)
846 pp_string (buffer, "instrumentedCode ");
847 if (props & PR_UNINSTRUMENTEDCODE)
848 pp_string (buffer, "uninstrumentedCode ");
849 if (props & PR_HASNOXMMUPDATE)
850 pp_string (buffer, "hasNoXMMUpdate ");
851 if (props & PR_HASNOABORT)
852 pp_string (buffer, "hasNoAbort ");
853 if (props & PR_HASNOIRREVOCABLE)
854 pp_string (buffer, "hasNoIrrevocable ");
855 if (props & PR_DOESGOIRREVOCABLE)
856 pp_string (buffer, "doesGoIrrevocable ");
857 if (props & PR_HASNOSIMPLEREADS)
858 pp_string (buffer, "hasNoSimpleReads ");
859 if (props & PR_AWBARRIERSOMITTED)
860 pp_string (buffer, "awBarriersOmitted ");
861 if (props & PR_RARBARRIERSOMITTED)
862 pp_string (buffer, "RaRBarriersOmitted ");
863 if (props & PR_UNDOLOGCODE)
864 pp_string (buffer, "undoLogCode ");
865 if (props & PR_PREFERUNINSTRUMENTED)
866 pp_string (buffer, "preferUninstrumented ");
867 if (props & PR_EXCEPTIONBLOCK)
868 pp_string (buffer, "exceptionBlock ");
869 if (props & PR_HASELSE)
870 pp_string (buffer, "hasElse ");
871 if (props & PR_READONLY)
872 pp_string (buffer, "readOnly ");
874 pp_right_bracket (buffer);
879 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
880 pp_gimple_stmt_1. */
882 static void
883 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
884 int flags)
886 unsigned int i;
888 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
889 if (flags & TDF_RAW)
890 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
891 gimple_switch_index (gs));
892 else
894 pp_string (buffer, "switch (");
895 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
896 pp_string (buffer, ") <");
899 for (i = 0; i < gimple_switch_num_labels (gs); i++)
901 tree case_label = gimple_switch_label (gs, i);
902 gcc_checking_assert (case_label != NULL_TREE);
903 dump_generic_node (buffer, case_label, spc, flags, false);
904 pp_space (buffer);
905 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
906 if (i < gimple_switch_num_labels (gs) - 1)
907 pp_string (buffer, ", ");
909 pp_greater (buffer);
913 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
914 pp_gimple_stmt_1. */
916 static void
917 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
919 if (flags & TDF_RAW)
920 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
921 get_tree_code_name (gimple_cond_code (gs)),
922 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
923 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
924 else
926 if (!(flags & TDF_RHS_ONLY))
927 pp_string (buffer, "if (");
928 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
929 pp_space (buffer);
930 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
931 pp_space (buffer);
932 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
933 if (!(flags & TDF_RHS_ONLY))
935 pp_right_paren (buffer);
937 if (gimple_cond_true_label (gs))
939 pp_string (buffer, " goto ");
940 dump_generic_node (buffer, gimple_cond_true_label (gs),
941 spc, flags, false);
942 pp_semicolon (buffer);
944 if (gimple_cond_false_label (gs))
946 pp_string (buffer, " else goto ");
947 dump_generic_node (buffer, gimple_cond_false_label (gs),
948 spc, flags, false);
949 pp_semicolon (buffer);
956 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
957 spaces of indent. FLAGS specifies details to show in the dump (see
958 TDF_* in dumpfils.h). */
960 static void
961 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
963 tree label = gimple_label_label (gs);
964 if (flags & TDF_RAW)
965 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
966 else
968 dump_generic_node (buffer, label, spc, flags, false);
969 pp_colon (buffer);
971 if (DECL_NONLOCAL (label))
972 pp_string (buffer, " [non-local]");
973 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
974 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
977 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
978 spaces of indent. FLAGS specifies details to show in the dump (see
979 TDF_* in dumpfile.h). */
981 static void
982 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
984 tree label = gimple_goto_dest (gs);
985 if (flags & TDF_RAW)
986 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
987 else
988 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
992 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
993 spaces of indent. FLAGS specifies details to show in the dump (see
994 TDF_* in dumpfile.h). */
996 static void
997 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
999 if (flags & TDF_RAW)
1000 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1001 else
1002 pp_left_brace (buffer);
1003 if (!(flags & TDF_SLIM))
1005 tree var;
1007 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1009 newline_and_indent (buffer, 2);
1010 print_declaration (buffer, var, spc, flags);
1012 if (gimple_bind_vars (gs))
1013 pp_newline (buffer);
1015 pp_newline (buffer);
1016 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1017 newline_and_indent (buffer, spc);
1018 if (flags & TDF_RAW)
1019 pp_greater (buffer);
1020 else
1021 pp_right_brace (buffer);
1025 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1026 indent. FLAGS specifies details to show in the dump (see TDF_* in
1027 dumpfile.h). */
1029 static void
1030 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
1032 if (flags & TDF_RAW)
1034 const char *type;
1035 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1036 type = "GIMPLE_TRY_CATCH";
1037 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1038 type = "GIMPLE_TRY_FINALLY";
1039 else
1040 type = "UNKNOWN GIMPLE_TRY";
1041 dump_gimple_fmt (buffer, spc, flags,
1042 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1043 gimple_try_eval (gs), gimple_try_cleanup (gs));
1045 else
1047 pp_string (buffer, "try");
1048 newline_and_indent (buffer, spc + 2);
1049 pp_left_brace (buffer);
1050 pp_newline (buffer);
1052 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1053 newline_and_indent (buffer, spc + 2);
1054 pp_right_brace (buffer);
1056 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1058 newline_and_indent (buffer, spc);
1059 pp_string (buffer, "catch");
1060 newline_and_indent (buffer, spc + 2);
1061 pp_left_brace (buffer);
1063 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1065 newline_and_indent (buffer, spc);
1066 pp_string (buffer, "finally");
1067 newline_and_indent (buffer, spc + 2);
1068 pp_left_brace (buffer);
1070 else
1071 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1073 pp_newline (buffer);
1074 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1075 newline_and_indent (buffer, spc + 2);
1076 pp_right_brace (buffer);
1081 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1082 indent. FLAGS specifies details to show in the dump (see TDF_* in
1083 dumpfile.h). */
1085 static void
1086 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
1088 if (flags & TDF_RAW)
1089 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1090 gimple_catch_types (gs), gimple_catch_handler (gs));
1091 else
1092 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1093 gimple_catch_types (gs), gimple_catch_handler (gs));
1097 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1098 indent. FLAGS specifies details to show in the dump (see TDF_* in
1099 dumpfile.h). */
1101 static void
1102 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1103 int flags)
1105 if (flags & TDF_RAW)
1106 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1107 gimple_eh_filter_types (gs),
1108 gimple_eh_filter_failure (gs));
1109 else
1110 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1111 gimple_eh_filter_types (gs),
1112 gimple_eh_filter_failure (gs));
1116 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1118 static void
1119 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1120 geh_mnt *gs, int spc, int flags)
1122 if (flags & TDF_RAW)
1123 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1124 gimple_eh_must_not_throw_fndecl (gs));
1125 else
1126 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1127 gimple_eh_must_not_throw_fndecl (gs));
1131 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1132 indent. FLAGS specifies details to show in the dump (see TDF_* in
1133 dumpfile.h). */
1135 static void
1136 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1137 int flags)
1139 if (flags & TDF_RAW)
1140 dump_gimple_fmt (buffer, spc, flags,
1141 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1142 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1143 else
1144 dump_gimple_fmt (buffer, spc, flags,
1145 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1146 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1150 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1151 indent. FLAGS specifies details to show in the dump (see TDF_* in
1152 dumpfile.h). */
1154 static void
1155 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
1157 if (flags & TDF_RAW)
1158 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1159 gimple_resx_region (gs));
1160 else
1161 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1164 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1166 static void
1167 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int flags)
1169 if (flags & TDF_RAW)
1170 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1171 gimple_eh_dispatch_region (gs));
1172 else
1173 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1174 gimple_eh_dispatch_region (gs));
1177 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1178 of indent. FLAGS specifies details to show in the dump (see TDF_*
1179 in dumpfile.h). */
1181 static void
1182 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
1184 switch (gs->subcode)
1186 case GIMPLE_DEBUG_BIND:
1187 if (flags & TDF_RAW)
1188 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1189 gimple_debug_bind_get_var (gs),
1190 gimple_debug_bind_get_value (gs));
1191 else
1192 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1193 gimple_debug_bind_get_var (gs),
1194 gimple_debug_bind_get_value (gs));
1195 break;
1197 case GIMPLE_DEBUG_SOURCE_BIND:
1198 if (flags & TDF_RAW)
1199 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1200 gimple_debug_source_bind_get_var (gs),
1201 gimple_debug_source_bind_get_value (gs));
1202 else
1203 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1204 gimple_debug_source_bind_get_var (gs),
1205 gimple_debug_source_bind_get_value (gs));
1206 break;
1208 default:
1209 gcc_unreachable ();
1213 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1214 static void
1215 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
1217 size_t i;
1219 if (flags & TDF_RAW)
1221 const char *kind;
1222 switch (gimple_omp_for_kind (gs))
1224 case GF_OMP_FOR_KIND_FOR:
1225 kind = "";
1226 break;
1227 case GF_OMP_FOR_KIND_DISTRIBUTE:
1228 kind = " distribute";
1229 break;
1230 case GF_OMP_FOR_KIND_TASKLOOP:
1231 kind = " taskloop";
1232 break;
1233 case GF_OMP_FOR_KIND_CILKFOR:
1234 kind = " _Cilk_for";
1235 break;
1236 case GF_OMP_FOR_KIND_OACC_LOOP:
1237 kind = " oacc_loop";
1238 break;
1239 case GF_OMP_FOR_KIND_SIMD:
1240 kind = " simd";
1241 break;
1242 case GF_OMP_FOR_KIND_CILKSIMD:
1243 kind = " cilksimd";
1244 break;
1245 default:
1246 gcc_unreachable ();
1248 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1249 kind, gimple_omp_body (gs));
1250 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1251 dump_gimple_fmt (buffer, spc, flags, " >,");
1252 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1253 dump_gimple_fmt (buffer, spc, flags,
1254 "%+%T, %T, %T, %s, %T,%n",
1255 gimple_omp_for_index (gs, i),
1256 gimple_omp_for_initial (gs, i),
1257 gimple_omp_for_final (gs, i),
1258 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1259 gimple_omp_for_incr (gs, i));
1260 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1261 gimple_omp_for_pre_body (gs));
1263 else
1265 switch (gimple_omp_for_kind (gs))
1267 case GF_OMP_FOR_KIND_FOR:
1268 pp_string (buffer, "#pragma omp for");
1269 break;
1270 case GF_OMP_FOR_KIND_DISTRIBUTE:
1271 pp_string (buffer, "#pragma omp distribute");
1272 break;
1273 case GF_OMP_FOR_KIND_TASKLOOP:
1274 pp_string (buffer, "#pragma omp taskloop");
1275 break;
1276 case GF_OMP_FOR_KIND_CILKFOR:
1277 break;
1278 case GF_OMP_FOR_KIND_OACC_LOOP:
1279 pp_string (buffer, "#pragma acc loop");
1280 break;
1281 case GF_OMP_FOR_KIND_SIMD:
1282 pp_string (buffer, "#pragma omp simd");
1283 break;
1284 case GF_OMP_FOR_KIND_CILKSIMD:
1285 pp_string (buffer, "#pragma simd");
1286 break;
1287 case GF_OMP_FOR_KIND_GRID_LOOP:
1288 pp_string (buffer, "#pragma omp for grid_loop");
1289 break;
1290 default:
1291 gcc_unreachable ();
1293 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1294 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1295 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1297 if (i)
1298 spc += 2;
1299 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1300 pp_string (buffer, "_Cilk_for (");
1301 else
1303 newline_and_indent (buffer, spc);
1304 pp_string (buffer, "for (");
1306 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1307 flags, false);
1308 pp_string (buffer, " = ");
1309 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1310 flags, false);
1311 pp_string (buffer, "; ");
1313 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1314 flags, false);
1315 pp_space (buffer);
1316 switch (gimple_omp_for_cond (gs, i))
1318 case LT_EXPR:
1319 pp_less (buffer);
1320 break;
1321 case GT_EXPR:
1322 pp_greater (buffer);
1323 break;
1324 case LE_EXPR:
1325 pp_less_equal (buffer);
1326 break;
1327 case GE_EXPR:
1328 pp_greater_equal (buffer);
1329 break;
1330 case NE_EXPR:
1331 pp_string (buffer, "!=");
1332 break;
1333 default:
1334 gcc_unreachable ();
1336 pp_space (buffer);
1337 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1338 flags, false);
1339 pp_string (buffer, "; ");
1341 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1342 flags, false);
1343 pp_string (buffer, " = ");
1344 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1345 flags, false);
1346 pp_right_paren (buffer);
1349 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1351 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1352 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1353 newline_and_indent (buffer, spc + 2);
1354 pp_left_brace (buffer);
1355 pp_newline (buffer);
1356 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1357 newline_and_indent (buffer, spc + 2);
1358 pp_right_brace (buffer);
1363 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1365 static void
1366 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1367 int spc, int flags)
1369 if (flags & TDF_RAW)
1371 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1372 gimple_omp_continue_control_def (gs),
1373 gimple_omp_continue_control_use (gs));
1375 else
1377 pp_string (buffer, "#pragma omp continue (");
1378 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1379 spc, flags, false);
1380 pp_comma (buffer);
1381 pp_space (buffer);
1382 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1383 spc, flags, false);
1384 pp_right_paren (buffer);
1388 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1390 static void
1391 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1392 int spc, int flags)
1394 if (flags & TDF_RAW)
1396 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1397 gimple_omp_body (gs));
1398 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1399 dump_gimple_fmt (buffer, spc, flags, " >");
1401 else
1403 pp_string (buffer, "#pragma omp single");
1404 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1405 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1407 newline_and_indent (buffer, spc + 2);
1408 pp_left_brace (buffer);
1409 pp_newline (buffer);
1410 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1411 newline_and_indent (buffer, spc + 2);
1412 pp_right_brace (buffer);
1417 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1419 static void
1420 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1421 int spc, int flags)
1423 const char *kind;
1424 switch (gimple_omp_target_kind (gs))
1426 case GF_OMP_TARGET_KIND_REGION:
1427 kind = "";
1428 break;
1429 case GF_OMP_TARGET_KIND_DATA:
1430 kind = " data";
1431 break;
1432 case GF_OMP_TARGET_KIND_UPDATE:
1433 kind = " update";
1434 break;
1435 case GF_OMP_TARGET_KIND_ENTER_DATA:
1436 kind = " enter data";
1437 break;
1438 case GF_OMP_TARGET_KIND_EXIT_DATA:
1439 kind = " exit data";
1440 break;
1441 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1442 kind = " oacc_kernels";
1443 break;
1444 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1445 kind = " oacc_parallel";
1446 break;
1447 case GF_OMP_TARGET_KIND_OACC_DATA:
1448 kind = " oacc_data";
1449 break;
1450 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1451 kind = " oacc_update";
1452 break;
1453 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1454 kind = " oacc_enter_exit_data";
1455 break;
1456 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1457 kind = " oacc_declare";
1458 break;
1459 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1460 kind = " oacc_host_data";
1461 break;
1462 default:
1463 gcc_unreachable ();
1465 if (flags & TDF_RAW)
1467 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1468 kind, gimple_omp_body (gs));
1469 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1470 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1471 gimple_omp_target_child_fn (gs),
1472 gimple_omp_target_data_arg (gs));
1474 else
1476 pp_string (buffer, "#pragma omp target");
1477 pp_string (buffer, kind);
1478 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1479 if (gimple_omp_target_child_fn (gs))
1481 pp_string (buffer, " [child fn: ");
1482 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1483 spc, flags, false);
1484 pp_string (buffer, " (");
1485 if (gimple_omp_target_data_arg (gs))
1486 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1487 spc, flags, false);
1488 else
1489 pp_string (buffer, "???");
1490 pp_string (buffer, ")]");
1492 gimple_seq body = gimple_omp_body (gs);
1493 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1495 newline_and_indent (buffer, spc + 2);
1496 pp_left_brace (buffer);
1497 pp_newline (buffer);
1498 dump_gimple_seq (buffer, body, spc + 4, flags);
1499 newline_and_indent (buffer, spc + 2);
1500 pp_right_brace (buffer);
1502 else if (body)
1504 pp_newline (buffer);
1505 dump_gimple_seq (buffer, body, spc + 2, flags);
1510 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1512 static void
1513 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1514 int flags)
1516 if (flags & TDF_RAW)
1518 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1519 gimple_omp_body (gs));
1520 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1521 dump_gimple_fmt (buffer, spc, flags, " >");
1523 else
1525 pp_string (buffer, "#pragma omp teams");
1526 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1527 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1529 newline_and_indent (buffer, spc + 2);
1530 pp_character (buffer, '{');
1531 pp_newline (buffer);
1532 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1533 newline_and_indent (buffer, spc + 2);
1534 pp_character (buffer, '}');
1539 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1541 static void
1542 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1543 int spc, int flags)
1545 if (flags & TDF_RAW)
1547 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1548 gimple_omp_body (gs));
1549 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1550 dump_gimple_fmt (buffer, spc, flags, " >");
1552 else
1554 pp_string (buffer, "#pragma omp sections");
1555 if (gimple_omp_sections_control (gs))
1557 pp_string (buffer, " <");
1558 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1559 flags, false);
1560 pp_greater (buffer);
1562 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1563 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1565 newline_and_indent (buffer, spc + 2);
1566 pp_left_brace (buffer);
1567 pp_newline (buffer);
1568 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1569 newline_and_indent (buffer, spc + 2);
1570 pp_right_brace (buffer);
1575 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1576 pretty_printer BUFFER. */
1578 static void
1579 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc, int flags)
1581 if (flags & TDF_RAW)
1582 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1583 gimple_omp_body (gs));
1584 else
1586 switch (gimple_code (gs))
1588 case GIMPLE_OMP_MASTER:
1589 pp_string (buffer, "#pragma omp master");
1590 break;
1591 case GIMPLE_OMP_TASKGROUP:
1592 pp_string (buffer, "#pragma omp taskgroup");
1593 break;
1594 case GIMPLE_OMP_SECTION:
1595 pp_string (buffer, "#pragma omp section");
1596 break;
1597 case GIMPLE_OMP_GRID_BODY:
1598 pp_string (buffer, "#pragma omp gridified body");
1599 break;
1600 default:
1601 gcc_unreachable ();
1603 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1605 newline_and_indent (buffer, spc + 2);
1606 pp_left_brace (buffer);
1607 pp_newline (buffer);
1608 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1609 newline_and_indent (buffer, spc + 2);
1610 pp_right_brace (buffer);
1615 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1617 static void
1618 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1619 int spc, int flags)
1621 if (flags & TDF_RAW)
1622 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1623 gimple_omp_body (gs));
1624 else
1626 pp_string (buffer, "#pragma omp critical");
1627 if (gimple_omp_critical_name (gs))
1629 pp_string (buffer, " (");
1630 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1631 flags, false);
1632 pp_right_paren (buffer);
1634 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1635 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1637 newline_and_indent (buffer, spc + 2);
1638 pp_left_brace (buffer);
1639 pp_newline (buffer);
1640 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1641 newline_and_indent (buffer, spc + 2);
1642 pp_right_brace (buffer);
1647 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1649 static void
1650 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1651 int spc, int flags)
1653 if (flags & TDF_RAW)
1654 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1655 gimple_omp_body (gs));
1656 else
1658 pp_string (buffer, "#pragma omp ordered");
1659 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1660 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1662 newline_and_indent (buffer, spc + 2);
1663 pp_left_brace (buffer);
1664 pp_newline (buffer);
1665 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1666 newline_and_indent (buffer, spc + 2);
1667 pp_right_brace (buffer);
1672 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1674 static void
1675 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc, int flags)
1677 if (flags & TDF_RAW)
1679 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1680 (int) gimple_omp_return_nowait_p (gs));
1681 if (gimple_omp_return_lhs (gs))
1682 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1683 gimple_omp_return_lhs (gs));
1684 else
1685 dump_gimple_fmt (buffer, spc, flags, ">");
1687 else
1689 pp_string (buffer, "#pragma omp return");
1690 if (gimple_omp_return_nowait_p (gs))
1691 pp_string (buffer, "(nowait)");
1692 if (gimple_omp_return_lhs (gs))
1694 pp_string (buffer, " (set ");
1695 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1696 spc, flags, false);
1697 pp_character (buffer, ')');
1702 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1704 static void
1705 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1706 int spc, int flags)
1708 unsigned subcode = gimple_transaction_subcode (gs);
1710 if (flags & TDF_RAW)
1712 dump_gimple_fmt (buffer, spc, flags,
1713 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1714 "<%+BODY <%S> >",
1715 gs, subcode, gimple_transaction_label_norm (gs),
1716 gimple_transaction_label_uninst (gs),
1717 gimple_transaction_label_over (gs),
1718 gimple_transaction_body (gs));
1720 else
1722 if (subcode & GTMA_IS_OUTER)
1723 pp_string (buffer, "__transaction_atomic [[outer]]");
1724 else if (subcode & GTMA_IS_RELAXED)
1725 pp_string (buffer, "__transaction_relaxed");
1726 else
1727 pp_string (buffer, "__transaction_atomic");
1728 subcode &= ~GTMA_DECLARATION_MASK;
1730 if (gimple_transaction_body (gs))
1732 newline_and_indent (buffer, spc + 2);
1733 pp_left_brace (buffer);
1734 pp_newline (buffer);
1735 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1736 spc + 4, flags);
1737 newline_and_indent (buffer, spc + 2);
1738 pp_right_brace (buffer);
1740 else
1742 pp_string (buffer, " //");
1743 if (gimple_transaction_label_norm (gs))
1745 pp_string (buffer, " NORM=");
1746 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1747 spc, flags, false);
1749 if (gimple_transaction_label_uninst (gs))
1751 pp_string (buffer, " UNINST=");
1752 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1753 spc, flags, false);
1755 if (gimple_transaction_label_over (gs))
1757 pp_string (buffer, " OVER=");
1758 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1759 spc, flags, false);
1761 if (subcode)
1763 pp_string (buffer, " SUBCODE=[ ");
1764 if (subcode & GTMA_HAVE_ABORT)
1766 pp_string (buffer, "GTMA_HAVE_ABORT ");
1767 subcode &= ~GTMA_HAVE_ABORT;
1769 if (subcode & GTMA_HAVE_LOAD)
1771 pp_string (buffer, "GTMA_HAVE_LOAD ");
1772 subcode &= ~GTMA_HAVE_LOAD;
1774 if (subcode & GTMA_HAVE_STORE)
1776 pp_string (buffer, "GTMA_HAVE_STORE ");
1777 subcode &= ~GTMA_HAVE_STORE;
1779 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1781 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1782 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1784 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1786 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1787 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1789 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1791 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1792 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1794 if (subcode)
1795 pp_printf (buffer, "0x%x ", subcode);
1796 pp_right_bracket (buffer);
1802 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1803 indent. FLAGS specifies details to show in the dump (see TDF_* in
1804 dumpfile.h). */
1806 static void
1807 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
1809 unsigned int i, n, f, fields;
1811 if (flags & TDF_RAW)
1813 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1814 gimple_asm_string (gs));
1816 n = gimple_asm_noutputs (gs);
1817 if (n)
1819 newline_and_indent (buffer, spc + 2);
1820 pp_string (buffer, "OUTPUT: ");
1821 for (i = 0; i < n; i++)
1823 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1824 spc, flags, false);
1825 if (i < n - 1)
1826 pp_string (buffer, ", ");
1830 n = gimple_asm_ninputs (gs);
1831 if (n)
1833 newline_and_indent (buffer, spc + 2);
1834 pp_string (buffer, "INPUT: ");
1835 for (i = 0; i < n; i++)
1837 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1838 spc, flags, false);
1839 if (i < n - 1)
1840 pp_string (buffer, ", ");
1844 n = gimple_asm_nclobbers (gs);
1845 if (n)
1847 newline_and_indent (buffer, spc + 2);
1848 pp_string (buffer, "CLOBBER: ");
1849 for (i = 0; i < n; i++)
1851 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1852 spc, flags, false);
1853 if (i < n - 1)
1854 pp_string (buffer, ", ");
1858 n = gimple_asm_nlabels (gs);
1859 if (n)
1861 newline_and_indent (buffer, spc + 2);
1862 pp_string (buffer, "LABEL: ");
1863 for (i = 0; i < n; i++)
1865 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1866 spc, flags, false);
1867 if (i < n - 1)
1868 pp_string (buffer, ", ");
1872 newline_and_indent (buffer, spc);
1873 pp_greater (buffer);
1875 else
1877 pp_string (buffer, "__asm__");
1878 if (gimple_asm_volatile_p (gs))
1879 pp_string (buffer, " __volatile__");
1880 if (gimple_asm_nlabels (gs))
1881 pp_string (buffer, " goto");
1882 pp_string (buffer, "(\"");
1883 pp_string (buffer, gimple_asm_string (gs));
1884 pp_string (buffer, "\"");
1886 if (gimple_asm_nlabels (gs))
1887 fields = 4;
1888 else if (gimple_asm_nclobbers (gs))
1889 fields = 3;
1890 else if (gimple_asm_ninputs (gs))
1891 fields = 2;
1892 else if (gimple_asm_noutputs (gs))
1893 fields = 1;
1894 else
1895 fields = 0;
1897 for (f = 0; f < fields; ++f)
1899 pp_string (buffer, " : ");
1901 switch (f)
1903 case 0:
1904 n = gimple_asm_noutputs (gs);
1905 for (i = 0; i < n; i++)
1907 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1908 spc, flags, false);
1909 if (i < n - 1)
1910 pp_string (buffer, ", ");
1912 break;
1914 case 1:
1915 n = gimple_asm_ninputs (gs);
1916 for (i = 0; i < n; i++)
1918 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1919 spc, flags, false);
1920 if (i < n - 1)
1921 pp_string (buffer, ", ");
1923 break;
1925 case 2:
1926 n = gimple_asm_nclobbers (gs);
1927 for (i = 0; i < n; i++)
1929 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1930 spc, flags, false);
1931 if (i < n - 1)
1932 pp_string (buffer, ", ");
1934 break;
1936 case 3:
1937 n = gimple_asm_nlabels (gs);
1938 for (i = 0; i < n; i++)
1940 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1941 spc, flags, false);
1942 if (i < n - 1)
1943 pp_string (buffer, ", ");
1945 break;
1947 default:
1948 gcc_unreachable ();
1952 pp_string (buffer, ");");
1956 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1957 SPC spaces of indent. */
1959 static void
1960 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1962 if (TREE_CODE (node) != SSA_NAME)
1963 return;
1965 if (POINTER_TYPE_P (TREE_TYPE (node))
1966 && SSA_NAME_PTR_INFO (node))
1968 unsigned int align, misalign;
1969 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1970 pp_string (buffer, "# PT = ");
1971 pp_points_to_solution (buffer, &pi->pt);
1972 newline_and_indent (buffer, spc);
1973 if (get_ptr_info_alignment (pi, &align, &misalign))
1975 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1976 newline_and_indent (buffer, spc);
1980 if (!POINTER_TYPE_P (TREE_TYPE (node))
1981 && SSA_NAME_RANGE_INFO (node))
1983 wide_int min, max, nonzero_bits;
1984 value_range_type range_type = get_range_info (node, &min, &max);
1986 if (range_type == VR_VARYING)
1987 pp_printf (buffer, "# RANGE VR_VARYING");
1988 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1990 pp_printf (buffer, "# RANGE ");
1991 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1992 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
1993 pp_printf (buffer, ", ");
1994 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
1995 pp_printf (buffer, "]");
1997 nonzero_bits = get_nonzero_bits (node);
1998 if (nonzero_bits != -1)
2000 pp_string (buffer, " NONZERO ");
2001 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
2003 newline_and_indent (buffer, spc);
2007 /* As dump_ssaname_info, but dump to FILE. */
2009 void
2010 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2012 pretty_printer buffer;
2013 pp_needs_newline (&buffer) = true;
2014 buffer.buffer->stream = file;
2015 dump_ssaname_info (&buffer, node, spc);
2016 pp_flush (&buffer);
2019 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2020 The caller is responsible for calling pp_flush on BUFFER to finalize
2021 pretty printer. If COMMENT is true, print this after #. */
2023 static void
2024 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2025 int flags)
2027 size_t i;
2028 tree lhs = gimple_phi_result (phi);
2030 if (flags & TDF_ALIAS)
2031 dump_ssaname_info (buffer, lhs, spc);
2033 if (comment)
2034 pp_string (buffer, "# ");
2036 if (flags & TDF_RAW)
2037 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2038 gimple_phi_result (phi));
2039 else
2041 dump_generic_node (buffer, lhs, spc, flags, false);
2042 pp_string (buffer, " = PHI <");
2044 for (i = 0; i < gimple_phi_num_args (phi); i++)
2046 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2047 dump_location (buffer, gimple_phi_arg_location (phi, i));
2048 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2049 false);
2050 pp_left_paren (buffer);
2051 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2052 pp_right_paren (buffer);
2053 if (i < gimple_phi_num_args (phi) - 1)
2054 pp_string (buffer, ", ");
2056 pp_greater (buffer);
2060 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2061 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2062 dumpfile.h). */
2064 static void
2065 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2066 int spc, int flags)
2068 if (flags & TDF_RAW)
2070 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2071 gimple_omp_body (gs));
2072 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2073 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2074 gimple_omp_parallel_child_fn (gs),
2075 gimple_omp_parallel_data_arg (gs));
2077 else
2079 gimple_seq body;
2080 pp_string (buffer, "#pragma omp parallel");
2081 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2082 if (gimple_omp_parallel_child_fn (gs))
2084 pp_string (buffer, " [child fn: ");
2085 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2086 spc, flags, false);
2087 pp_string (buffer, " (");
2088 if (gimple_omp_parallel_data_arg (gs))
2089 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2090 spc, flags, false);
2091 else
2092 pp_string (buffer, "???");
2093 pp_string (buffer, ")]");
2095 body = gimple_omp_body (gs);
2096 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2098 newline_and_indent (buffer, spc + 2);
2099 pp_left_brace (buffer);
2100 pp_newline (buffer);
2101 dump_gimple_seq (buffer, body, spc + 4, flags);
2102 newline_and_indent (buffer, spc + 2);
2103 pp_right_brace (buffer);
2105 else if (body)
2107 pp_newline (buffer);
2108 dump_gimple_seq (buffer, body, spc + 2, flags);
2114 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2115 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2116 dumpfile.h). */
2118 static void
2119 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2120 int flags)
2122 if (flags & TDF_RAW)
2124 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2125 gimple_omp_body (gs));
2126 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2127 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2128 gimple_omp_task_child_fn (gs),
2129 gimple_omp_task_data_arg (gs),
2130 gimple_omp_task_copy_fn (gs),
2131 gimple_omp_task_arg_size (gs),
2132 gimple_omp_task_arg_size (gs));
2134 else
2136 gimple_seq body;
2137 if (gimple_omp_task_taskloop_p (gs))
2138 pp_string (buffer, "#pragma omp taskloop");
2139 else
2140 pp_string (buffer, "#pragma omp task");
2141 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2142 if (gimple_omp_task_child_fn (gs))
2144 pp_string (buffer, " [child fn: ");
2145 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2146 spc, flags, false);
2147 pp_string (buffer, " (");
2148 if (gimple_omp_task_data_arg (gs))
2149 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2150 spc, flags, false);
2151 else
2152 pp_string (buffer, "???");
2153 pp_string (buffer, ")]");
2155 body = gimple_omp_body (gs);
2156 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2158 newline_and_indent (buffer, spc + 2);
2159 pp_left_brace (buffer);
2160 pp_newline (buffer);
2161 dump_gimple_seq (buffer, body, spc + 4, flags);
2162 newline_and_indent (buffer, spc + 2);
2163 pp_right_brace (buffer);
2165 else if (body)
2167 pp_newline (buffer);
2168 dump_gimple_seq (buffer, body, spc + 2, flags);
2174 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2175 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2176 in dumpfile.h). */
2178 static void
2179 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2180 int spc, int flags)
2182 if (flags & TDF_RAW)
2184 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2185 gimple_omp_atomic_load_lhs (gs),
2186 gimple_omp_atomic_load_rhs (gs));
2188 else
2190 pp_string (buffer, "#pragma omp atomic_load");
2191 if (gimple_omp_atomic_seq_cst_p (gs))
2192 pp_string (buffer, " seq_cst");
2193 if (gimple_omp_atomic_need_value_p (gs))
2194 pp_string (buffer, " [needed]");
2195 newline_and_indent (buffer, spc + 2);
2196 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2197 spc, flags, false);
2198 pp_space (buffer);
2199 pp_equal (buffer);
2200 pp_space (buffer);
2201 pp_star (buffer);
2202 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2203 spc, flags, false);
2207 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2208 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2209 in dumpfile.h). */
2211 static void
2212 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2213 gomp_atomic_store *gs, int spc, int flags)
2215 if (flags & TDF_RAW)
2217 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2218 gimple_omp_atomic_store_val (gs));
2220 else
2222 pp_string (buffer, "#pragma omp atomic_store ");
2223 if (gimple_omp_atomic_seq_cst_p (gs))
2224 pp_string (buffer, "seq_cst ");
2225 if (gimple_omp_atomic_need_value_p (gs))
2226 pp_string (buffer, "[needed] ");
2227 pp_left_paren (buffer);
2228 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2229 spc, flags, false);
2230 pp_right_paren (buffer);
2235 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2236 FLAGS are as in pp_gimple_stmt_1. */
2238 static void
2239 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc, int flags)
2241 tree vdef = gimple_vdef (gs);
2242 tree vuse = gimple_vuse (gs);
2244 if (vdef != NULL_TREE)
2246 pp_string (buffer, "# ");
2247 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2248 pp_string (buffer, " = VDEF <");
2249 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2250 pp_greater (buffer);
2251 newline_and_indent (buffer, spc);
2253 else if (vuse != NULL_TREE)
2255 pp_string (buffer, "# VUSE <");
2256 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2257 pp_greater (buffer);
2258 newline_and_indent (buffer, spc);
2263 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2264 spaces of indent. FLAGS specifies details to show in the dump (see
2265 TDF_* in dumpfile.h). The caller is responsible for calling
2266 pp_flush on BUFFER to finalize the pretty printer. */
2268 void
2269 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
2271 if (!gs)
2272 return;
2274 if (flags & TDF_STMTADDR)
2275 pp_printf (buffer, "<&%p> ", (void *) gs);
2277 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2278 dump_location (buffer, gimple_location (gs));
2280 if (flags & TDF_EH)
2282 int lp_nr = lookup_stmt_eh_lp (gs);
2283 if (lp_nr > 0)
2284 pp_printf (buffer, "[LP %d] ", lp_nr);
2285 else if (lp_nr < 0)
2286 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2289 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2290 && gimple_has_mem_ops (gs))
2291 dump_gimple_mem_ops (buffer, gs, spc, flags);
2293 if (gimple_has_lhs (gs)
2294 && (flags & TDF_ALIAS))
2295 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2297 switch (gimple_code (gs))
2299 case GIMPLE_ASM:
2300 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2301 break;
2303 case GIMPLE_ASSIGN:
2304 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2305 break;
2307 case GIMPLE_BIND:
2308 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2309 break;
2311 case GIMPLE_CALL:
2312 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2313 break;
2315 case GIMPLE_COND:
2316 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2317 break;
2319 case GIMPLE_LABEL:
2320 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2321 break;
2323 case GIMPLE_GOTO:
2324 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2325 break;
2327 case GIMPLE_NOP:
2328 pp_string (buffer, "GIMPLE_NOP");
2329 break;
2331 case GIMPLE_RETURN:
2332 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2333 break;
2335 case GIMPLE_SWITCH:
2336 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2337 break;
2339 case GIMPLE_TRY:
2340 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2341 break;
2343 case GIMPLE_PHI:
2344 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2345 break;
2347 case GIMPLE_OMP_PARALLEL:
2348 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2349 flags);
2350 break;
2352 case GIMPLE_OMP_TASK:
2353 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2354 break;
2356 case GIMPLE_OMP_ATOMIC_LOAD:
2357 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2358 spc, flags);
2359 break;
2361 case GIMPLE_OMP_ATOMIC_STORE:
2362 dump_gimple_omp_atomic_store (buffer,
2363 as_a <gomp_atomic_store *> (gs),
2364 spc, flags);
2365 break;
2367 case GIMPLE_OMP_FOR:
2368 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2369 break;
2371 case GIMPLE_OMP_CONTINUE:
2372 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2373 flags);
2374 break;
2376 case GIMPLE_OMP_SINGLE:
2377 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2378 flags);
2379 break;
2381 case GIMPLE_OMP_TARGET:
2382 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2383 flags);
2384 break;
2386 case GIMPLE_OMP_TEAMS:
2387 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2388 flags);
2389 break;
2391 case GIMPLE_OMP_RETURN:
2392 dump_gimple_omp_return (buffer, gs, spc, flags);
2393 break;
2395 case GIMPLE_OMP_SECTIONS:
2396 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2397 spc, flags);
2398 break;
2400 case GIMPLE_OMP_SECTIONS_SWITCH:
2401 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2402 break;
2404 case GIMPLE_OMP_MASTER:
2405 case GIMPLE_OMP_TASKGROUP:
2406 case GIMPLE_OMP_SECTION:
2407 case GIMPLE_OMP_GRID_BODY:
2408 dump_gimple_omp_block (buffer, gs, spc, flags);
2409 break;
2411 case GIMPLE_OMP_ORDERED:
2412 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2413 flags);
2414 break;
2416 case GIMPLE_OMP_CRITICAL:
2417 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2418 flags);
2419 break;
2421 case GIMPLE_CATCH:
2422 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2423 break;
2425 case GIMPLE_EH_FILTER:
2426 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2427 break;
2429 case GIMPLE_EH_MUST_NOT_THROW:
2430 dump_gimple_eh_must_not_throw (buffer,
2431 as_a <geh_mnt *> (gs),
2432 spc, flags);
2433 break;
2435 case GIMPLE_EH_ELSE:
2436 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2437 break;
2439 case GIMPLE_RESX:
2440 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2441 break;
2443 case GIMPLE_EH_DISPATCH:
2444 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2445 flags);
2446 break;
2448 case GIMPLE_DEBUG:
2449 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2450 break;
2452 case GIMPLE_PREDICT:
2453 pp_string (buffer, "// predicted ");
2454 if (gimple_predict_outcome (gs))
2455 pp_string (buffer, "likely by ");
2456 else
2457 pp_string (buffer, "unlikely by ");
2458 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2459 pp_string (buffer, " predictor.");
2460 break;
2462 case GIMPLE_TRANSACTION:
2463 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2464 flags);
2465 break;
2467 default:
2468 GIMPLE_NIY;
2473 /* Dumps header of basic block BB to OUTF indented by INDENT
2474 spaces and details described by flags. */
2476 static void
2477 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2479 if (flags & TDF_BLOCKS)
2481 if (flags & TDF_LINENO)
2483 gimple_stmt_iterator gsi;
2485 if (flags & TDF_COMMENT)
2486 fputs (";; ", outf);
2488 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2489 if (!is_gimple_debug (gsi_stmt (gsi))
2490 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2492 fprintf (outf, "%*sstarting at line %d",
2493 indent, "", get_lineno (gsi_stmt (gsi)));
2494 break;
2496 if (bb->discriminator)
2497 fprintf (outf, ", discriminator %i", bb->discriminator);
2498 fputc ('\n', outf);
2501 else
2503 gimple *stmt = first_stmt (bb);
2504 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2505 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2510 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2511 spaces. */
2513 static void
2514 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2515 basic_block bb ATTRIBUTE_UNUSED,
2516 int indent ATTRIBUTE_UNUSED,
2517 int flags ATTRIBUTE_UNUSED)
2519 /* There is currently no GIMPLE-specific basic block info to dump. */
2520 return;
2524 /* Dump PHI nodes of basic block BB to BUFFER with details described
2525 by FLAGS and indented by INDENT spaces. */
2527 static void
2528 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2530 gphi_iterator i;
2532 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2534 gphi *phi = i.phi ();
2535 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2537 INDENT (indent);
2538 dump_gimple_phi (buffer, phi, indent, true, flags);
2539 pp_newline (buffer);
2545 /* Dump jump to basic block BB that is represented implicitly in the cfg
2546 to BUFFER. */
2548 static void
2549 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2551 gimple *stmt;
2553 stmt = first_stmt (bb);
2555 pp_string (buffer, "goto <bb ");
2556 pp_decimal_int (buffer, bb->index);
2557 pp_greater (buffer);
2558 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2560 pp_string (buffer, " (");
2561 dump_generic_node (buffer,
2562 gimple_label_label (as_a <glabel *> (stmt)),
2563 0, 0, false);
2564 pp_right_paren (buffer);
2565 pp_semicolon (buffer);
2567 else
2568 pp_semicolon (buffer);
2572 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2573 by INDENT spaces, with details given by FLAGS. */
2575 static void
2576 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2577 int flags)
2579 edge e;
2580 gimple *stmt;
2582 stmt = last_stmt (bb);
2584 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2586 edge true_edge, false_edge;
2588 /* When we are emitting the code or changing CFG, it is possible that
2589 the edges are not yet created. When we are using debug_bb in such
2590 a situation, we do not want it to crash. */
2591 if (EDGE_COUNT (bb->succs) != 2)
2592 return;
2593 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2595 INDENT (indent + 2);
2596 pp_cfg_jump (buffer, true_edge->dest);
2597 newline_and_indent (buffer, indent);
2598 pp_string (buffer, "else");
2599 newline_and_indent (buffer, indent + 2);
2600 pp_cfg_jump (buffer, false_edge->dest);
2601 pp_newline (buffer);
2602 return;
2605 /* If there is a fallthru edge, we may need to add an artificial
2606 goto to the dump. */
2607 e = find_fallthru_edge (bb->succs);
2609 if (e && e->dest != bb->next_bb)
2611 INDENT (indent);
2613 if ((flags & TDF_LINENO)
2614 && e->goto_locus != UNKNOWN_LOCATION)
2615 dump_location (buffer, e->goto_locus);
2617 pp_cfg_jump (buffer, e->dest);
2618 pp_newline (buffer);
2623 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2624 indented by INDENT spaces. */
2626 static void
2627 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2628 int flags)
2630 gimple_stmt_iterator gsi;
2631 gimple *stmt;
2632 int label_indent = indent - 2;
2634 if (label_indent < 0)
2635 label_indent = 0;
2637 dump_phi_nodes (buffer, bb, indent, flags);
2639 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2641 int curr_indent;
2643 stmt = gsi_stmt (gsi);
2645 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2647 INDENT (curr_indent);
2648 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2649 pp_newline_and_flush (buffer);
2650 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2651 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2652 pp_buffer (buffer)->stream, stmt);
2655 dump_implicit_edges (buffer, bb, indent, flags);
2656 pp_flush (buffer);
2660 /* Dumps basic block BB to FILE with details described by FLAGS and
2661 indented by INDENT spaces. */
2663 void
2664 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2666 dump_gimple_bb_header (file, bb, indent, flags);
2667 if (bb->index >= NUM_FIXED_BLOCKS)
2669 pretty_printer buffer;
2670 pp_needs_newline (&buffer) = true;
2671 buffer.buffer->stream = file;
2672 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2674 dump_gimple_bb_footer (file, bb, indent, flags);
2677 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2678 no indentation, for use as a label of a DOT graph record-node.
2679 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2680 histogram dumping doesn't know about pretty-printers. */
2682 void
2683 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2685 pp_printf (pp, "<bb %d>:\n", bb->index);
2686 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2688 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2689 gsi_next (&gsi))
2691 gphi *phi = gsi.phi ();
2692 if (!virtual_operand_p (gimple_phi_result (phi))
2693 || (dump_flags & TDF_VOPS))
2695 pp_bar (pp);
2696 pp_write_text_to_stream (pp);
2697 pp_string (pp, "# ");
2698 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2699 pp_newline (pp);
2700 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2704 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2705 gsi_next (&gsi))
2707 gimple *stmt = gsi_stmt (gsi);
2708 pp_bar (pp);
2709 pp_write_text_to_stream (pp);
2710 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2711 pp_newline (pp);
2712 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2714 dump_implicit_edges (pp, bb, 0, dump_flags);
2715 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);