* config/sparc/sparc.opt (msubxc): New option.
[official-gcc.git] / gcc / gimple-pretty-print.c
blob10bf80139b6806824dd0e8e294712f5ffa933f01
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");
732 pp_string (buffer, ")");
738 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
739 pp_gimple_stmt_1. */
741 static void
742 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
744 tree lhs = gimple_call_lhs (gs);
745 tree fn = gimple_call_fn (gs);
747 if (flags & TDF_ALIAS)
749 struct pt_solution *pt;
750 pt = gimple_call_use_set (gs);
751 if (!pt_solution_empty_p (pt))
753 pp_string (buffer, "# USE = ");
754 pp_points_to_solution (buffer, pt);
755 newline_and_indent (buffer, spc);
757 pt = gimple_call_clobber_set (gs);
758 if (!pt_solution_empty_p (pt))
760 pp_string (buffer, "# CLB = ");
761 pp_points_to_solution (buffer, pt);
762 newline_and_indent (buffer, spc);
766 if (flags & TDF_RAW)
768 if (gimple_call_internal_p (gs))
769 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
770 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
771 else
772 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
773 if (gimple_call_num_args (gs) > 0)
775 pp_string (buffer, ", ");
776 dump_gimple_call_args (buffer, gs, flags);
778 pp_greater (buffer);
780 else
782 if (lhs && !(flags & TDF_RHS_ONLY))
784 dump_generic_node (buffer, lhs, spc, flags, false);
785 pp_string (buffer, " =");
787 if (gimple_has_volatile_ops (gs))
788 pp_string (buffer, "{v}");
790 pp_space (buffer);
792 if (gimple_call_internal_p (gs))
793 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
794 else
795 print_call_name (buffer, fn, flags);
796 pp_string (buffer, " (");
797 dump_gimple_call_args (buffer, gs, flags);
798 pp_right_paren (buffer);
799 if (!(flags & TDF_RHS_ONLY))
800 pp_semicolon (buffer);
803 if (gimple_call_chain (gs))
805 pp_string (buffer, " [static-chain: ");
806 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
807 pp_right_bracket (buffer);
810 if (gimple_call_return_slot_opt_p (gs))
811 pp_string (buffer, " [return slot optimization]");
812 if (gimple_call_tail_p (gs))
813 pp_string (buffer, " [tail call]");
814 if (gimple_call_must_tail_p (gs))
815 pp_string (buffer, " [must tail call]");
817 if (fn == NULL)
818 return;
820 /* Dump the arguments of _ITM_beginTransaction sanely. */
821 if (TREE_CODE (fn) == ADDR_EXPR)
822 fn = TREE_OPERAND (fn, 0);
823 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
824 pp_string (buffer, " [tm-clone]");
825 if (TREE_CODE (fn) == FUNCTION_DECL
826 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
827 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
828 && gimple_call_num_args (gs) > 0)
830 tree t = gimple_call_arg (gs, 0);
831 unsigned HOST_WIDE_INT props;
832 gcc_assert (TREE_CODE (t) == INTEGER_CST);
834 pp_string (buffer, " [ ");
836 /* Get the transaction code properties. */
837 props = TREE_INT_CST_LOW (t);
839 if (props & PR_INSTRUMENTEDCODE)
840 pp_string (buffer, "instrumentedCode ");
841 if (props & PR_UNINSTRUMENTEDCODE)
842 pp_string (buffer, "uninstrumentedCode ");
843 if (props & PR_HASNOXMMUPDATE)
844 pp_string (buffer, "hasNoXMMUpdate ");
845 if (props & PR_HASNOABORT)
846 pp_string (buffer, "hasNoAbort ");
847 if (props & PR_HASNOIRREVOCABLE)
848 pp_string (buffer, "hasNoIrrevocable ");
849 if (props & PR_DOESGOIRREVOCABLE)
850 pp_string (buffer, "doesGoIrrevocable ");
851 if (props & PR_HASNOSIMPLEREADS)
852 pp_string (buffer, "hasNoSimpleReads ");
853 if (props & PR_AWBARRIERSOMITTED)
854 pp_string (buffer, "awBarriersOmitted ");
855 if (props & PR_RARBARRIERSOMITTED)
856 pp_string (buffer, "RaRBarriersOmitted ");
857 if (props & PR_UNDOLOGCODE)
858 pp_string (buffer, "undoLogCode ");
859 if (props & PR_PREFERUNINSTRUMENTED)
860 pp_string (buffer, "preferUninstrumented ");
861 if (props & PR_EXCEPTIONBLOCK)
862 pp_string (buffer, "exceptionBlock ");
863 if (props & PR_HASELSE)
864 pp_string (buffer, "hasElse ");
865 if (props & PR_READONLY)
866 pp_string (buffer, "readOnly ");
868 pp_right_bracket (buffer);
873 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
874 pp_gimple_stmt_1. */
876 static void
877 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
878 int flags)
880 unsigned int i;
882 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
883 if (flags & TDF_RAW)
884 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
885 gimple_switch_index (gs));
886 else
888 pp_string (buffer, "switch (");
889 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
890 pp_string (buffer, ") <");
893 for (i = 0; i < gimple_switch_num_labels (gs); i++)
895 tree case_label = gimple_switch_label (gs, i);
896 gcc_checking_assert (case_label != NULL_TREE);
897 dump_generic_node (buffer, case_label, spc, flags, false);
898 pp_space (buffer);
899 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
900 if (i < gimple_switch_num_labels (gs) - 1)
901 pp_string (buffer, ", ");
903 pp_greater (buffer);
907 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
908 pp_gimple_stmt_1. */
910 static void
911 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
913 if (flags & TDF_RAW)
914 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
915 get_tree_code_name (gimple_cond_code (gs)),
916 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
917 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
918 else
920 if (!(flags & TDF_RHS_ONLY))
921 pp_string (buffer, "if (");
922 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
923 pp_space (buffer);
924 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
925 pp_space (buffer);
926 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
927 if (!(flags & TDF_RHS_ONLY))
929 pp_right_paren (buffer);
931 if (gimple_cond_true_label (gs))
933 pp_string (buffer, " goto ");
934 dump_generic_node (buffer, gimple_cond_true_label (gs),
935 spc, flags, false);
936 pp_semicolon (buffer);
938 if (gimple_cond_false_label (gs))
940 pp_string (buffer, " else goto ");
941 dump_generic_node (buffer, gimple_cond_false_label (gs),
942 spc, flags, false);
943 pp_semicolon (buffer);
950 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
951 spaces of indent. FLAGS specifies details to show in the dump (see
952 TDF_* in dumpfils.h). */
954 static void
955 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
957 tree label = gimple_label_label (gs);
958 if (flags & TDF_RAW)
959 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
960 else
962 dump_generic_node (buffer, label, spc, flags, false);
963 pp_colon (buffer);
965 if (DECL_NONLOCAL (label))
966 pp_string (buffer, " [non-local]");
967 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
968 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
971 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
972 spaces of indent. FLAGS specifies details to show in the dump (see
973 TDF_* in dumpfile.h). */
975 static void
976 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
978 tree label = gimple_goto_dest (gs);
979 if (flags & TDF_RAW)
980 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
981 else
982 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
986 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
987 spaces of indent. FLAGS specifies details to show in the dump (see
988 TDF_* in dumpfile.h). */
990 static void
991 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
993 if (flags & TDF_RAW)
994 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
995 else
996 pp_left_brace (buffer);
997 if (!(flags & TDF_SLIM))
999 tree var;
1001 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
1003 newline_and_indent (buffer, 2);
1004 print_declaration (buffer, var, spc, flags);
1006 if (gimple_bind_vars (gs))
1007 pp_newline (buffer);
1009 pp_newline (buffer);
1010 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1011 newline_and_indent (buffer, spc);
1012 if (flags & TDF_RAW)
1013 pp_greater (buffer);
1014 else
1015 pp_right_brace (buffer);
1019 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1020 indent. FLAGS specifies details to show in the dump (see TDF_* in
1021 dumpfile.h). */
1023 static void
1024 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
1026 if (flags & TDF_RAW)
1028 const char *type;
1029 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1030 type = "GIMPLE_TRY_CATCH";
1031 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1032 type = "GIMPLE_TRY_FINALLY";
1033 else
1034 type = "UNKNOWN GIMPLE_TRY";
1035 dump_gimple_fmt (buffer, spc, flags,
1036 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1037 gimple_try_eval (gs), gimple_try_cleanup (gs));
1039 else
1041 pp_string (buffer, "try");
1042 newline_and_indent (buffer, spc + 2);
1043 pp_left_brace (buffer);
1044 pp_newline (buffer);
1046 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1047 newline_and_indent (buffer, spc + 2);
1048 pp_right_brace (buffer);
1050 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1052 newline_and_indent (buffer, spc);
1053 pp_string (buffer, "catch");
1054 newline_and_indent (buffer, spc + 2);
1055 pp_left_brace (buffer);
1057 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1059 newline_and_indent (buffer, spc);
1060 pp_string (buffer, "finally");
1061 newline_and_indent (buffer, spc + 2);
1062 pp_left_brace (buffer);
1064 else
1065 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1067 pp_newline (buffer);
1068 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1069 newline_and_indent (buffer, spc + 2);
1070 pp_right_brace (buffer);
1075 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1076 indent. FLAGS specifies details to show in the dump (see TDF_* in
1077 dumpfile.h). */
1079 static void
1080 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
1082 if (flags & TDF_RAW)
1083 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1084 gimple_catch_types (gs), gimple_catch_handler (gs));
1085 else
1086 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1087 gimple_catch_types (gs), gimple_catch_handler (gs));
1091 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1092 indent. FLAGS specifies details to show in the dump (see TDF_* in
1093 dumpfile.h). */
1095 static void
1096 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1097 int flags)
1099 if (flags & TDF_RAW)
1100 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1101 gimple_eh_filter_types (gs),
1102 gimple_eh_filter_failure (gs));
1103 else
1104 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1105 gimple_eh_filter_types (gs),
1106 gimple_eh_filter_failure (gs));
1110 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1112 static void
1113 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1114 geh_mnt *gs, int spc, int flags)
1116 if (flags & TDF_RAW)
1117 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1118 gimple_eh_must_not_throw_fndecl (gs));
1119 else
1120 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1121 gimple_eh_must_not_throw_fndecl (gs));
1125 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1126 indent. FLAGS specifies details to show in the dump (see TDF_* in
1127 dumpfile.h). */
1129 static void
1130 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1131 int flags)
1133 if (flags & TDF_RAW)
1134 dump_gimple_fmt (buffer, spc, flags,
1135 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1136 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1137 else
1138 dump_gimple_fmt (buffer, spc, flags,
1139 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1140 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1144 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1145 indent. FLAGS specifies details to show in the dump (see TDF_* in
1146 dumpfile.h). */
1148 static void
1149 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
1151 if (flags & TDF_RAW)
1152 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1153 gimple_resx_region (gs));
1154 else
1155 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1158 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1160 static void
1161 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int flags)
1163 if (flags & TDF_RAW)
1164 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1165 gimple_eh_dispatch_region (gs));
1166 else
1167 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1168 gimple_eh_dispatch_region (gs));
1171 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1172 of indent. FLAGS specifies details to show in the dump (see TDF_*
1173 in dumpfile.h). */
1175 static void
1176 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
1178 switch (gs->subcode)
1180 case GIMPLE_DEBUG_BIND:
1181 if (flags & TDF_RAW)
1182 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1183 gimple_debug_bind_get_var (gs),
1184 gimple_debug_bind_get_value (gs));
1185 else
1186 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1187 gimple_debug_bind_get_var (gs),
1188 gimple_debug_bind_get_value (gs));
1189 break;
1191 case GIMPLE_DEBUG_SOURCE_BIND:
1192 if (flags & TDF_RAW)
1193 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1194 gimple_debug_source_bind_get_var (gs),
1195 gimple_debug_source_bind_get_value (gs));
1196 else
1197 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1198 gimple_debug_source_bind_get_var (gs),
1199 gimple_debug_source_bind_get_value (gs));
1200 break;
1202 default:
1203 gcc_unreachable ();
1207 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1208 static void
1209 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
1211 size_t i;
1213 if (flags & TDF_RAW)
1215 const char *kind;
1216 switch (gimple_omp_for_kind (gs))
1218 case GF_OMP_FOR_KIND_FOR:
1219 kind = "";
1220 break;
1221 case GF_OMP_FOR_KIND_DISTRIBUTE:
1222 kind = " distribute";
1223 break;
1224 case GF_OMP_FOR_KIND_TASKLOOP:
1225 kind = " taskloop";
1226 break;
1227 case GF_OMP_FOR_KIND_CILKFOR:
1228 kind = " _Cilk_for";
1229 break;
1230 case GF_OMP_FOR_KIND_OACC_LOOP:
1231 kind = " oacc_loop";
1232 break;
1233 case GF_OMP_FOR_KIND_SIMD:
1234 kind = " simd";
1235 break;
1236 case GF_OMP_FOR_KIND_CILKSIMD:
1237 kind = " cilksimd";
1238 break;
1239 default:
1240 gcc_unreachable ();
1242 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1243 kind, gimple_omp_body (gs));
1244 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1245 dump_gimple_fmt (buffer, spc, flags, " >,");
1246 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1247 dump_gimple_fmt (buffer, spc, flags,
1248 "%+%T, %T, %T, %s, %T,%n",
1249 gimple_omp_for_index (gs, i),
1250 gimple_omp_for_initial (gs, i),
1251 gimple_omp_for_final (gs, i),
1252 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1253 gimple_omp_for_incr (gs, i));
1254 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1255 gimple_omp_for_pre_body (gs));
1257 else
1259 switch (gimple_omp_for_kind (gs))
1261 case GF_OMP_FOR_KIND_FOR:
1262 pp_string (buffer, "#pragma omp for");
1263 break;
1264 case GF_OMP_FOR_KIND_DISTRIBUTE:
1265 pp_string (buffer, "#pragma omp distribute");
1266 break;
1267 case GF_OMP_FOR_KIND_TASKLOOP:
1268 pp_string (buffer, "#pragma omp taskloop");
1269 break;
1270 case GF_OMP_FOR_KIND_CILKFOR:
1271 break;
1272 case GF_OMP_FOR_KIND_OACC_LOOP:
1273 pp_string (buffer, "#pragma acc loop");
1274 break;
1275 case GF_OMP_FOR_KIND_SIMD:
1276 pp_string (buffer, "#pragma omp simd");
1277 break;
1278 case GF_OMP_FOR_KIND_CILKSIMD:
1279 pp_string (buffer, "#pragma simd");
1280 break;
1281 case GF_OMP_FOR_KIND_GRID_LOOP:
1282 pp_string (buffer, "#pragma omp for grid_loop");
1283 break;
1284 default:
1285 gcc_unreachable ();
1287 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1288 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1289 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1291 if (i)
1292 spc += 2;
1293 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1294 pp_string (buffer, "_Cilk_for (");
1295 else
1297 newline_and_indent (buffer, spc);
1298 pp_string (buffer, "for (");
1300 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1301 flags, false);
1302 pp_string (buffer, " = ");
1303 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1304 flags, false);
1305 pp_string (buffer, "; ");
1307 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1308 flags, false);
1309 pp_space (buffer);
1310 switch (gimple_omp_for_cond (gs, i))
1312 case LT_EXPR:
1313 pp_less (buffer);
1314 break;
1315 case GT_EXPR:
1316 pp_greater (buffer);
1317 break;
1318 case LE_EXPR:
1319 pp_less_equal (buffer);
1320 break;
1321 case GE_EXPR:
1322 pp_greater_equal (buffer);
1323 break;
1324 case NE_EXPR:
1325 pp_string (buffer, "!=");
1326 break;
1327 default:
1328 gcc_unreachable ();
1330 pp_space (buffer);
1331 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1332 flags, false);
1333 pp_string (buffer, "; ");
1335 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1336 flags, false);
1337 pp_string (buffer, " = ");
1338 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1339 flags, false);
1340 pp_right_paren (buffer);
1343 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1345 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1346 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1347 newline_and_indent (buffer, spc + 2);
1348 pp_left_brace (buffer);
1349 pp_newline (buffer);
1350 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1351 newline_and_indent (buffer, spc + 2);
1352 pp_right_brace (buffer);
1357 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1359 static void
1360 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1361 int spc, int flags)
1363 if (flags & TDF_RAW)
1365 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1366 gimple_omp_continue_control_def (gs),
1367 gimple_omp_continue_control_use (gs));
1369 else
1371 pp_string (buffer, "#pragma omp continue (");
1372 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1373 spc, flags, false);
1374 pp_comma (buffer);
1375 pp_space (buffer);
1376 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1377 spc, flags, false);
1378 pp_right_paren (buffer);
1382 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1384 static void
1385 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1386 int spc, int flags)
1388 if (flags & TDF_RAW)
1390 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1391 gimple_omp_body (gs));
1392 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1393 dump_gimple_fmt (buffer, spc, flags, " >");
1395 else
1397 pp_string (buffer, "#pragma omp single");
1398 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1399 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1401 newline_and_indent (buffer, spc + 2);
1402 pp_left_brace (buffer);
1403 pp_newline (buffer);
1404 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1405 newline_and_indent (buffer, spc + 2);
1406 pp_right_brace (buffer);
1411 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1413 static void
1414 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1415 int spc, int flags)
1417 const char *kind;
1418 switch (gimple_omp_target_kind (gs))
1420 case GF_OMP_TARGET_KIND_REGION:
1421 kind = "";
1422 break;
1423 case GF_OMP_TARGET_KIND_DATA:
1424 kind = " data";
1425 break;
1426 case GF_OMP_TARGET_KIND_UPDATE:
1427 kind = " update";
1428 break;
1429 case GF_OMP_TARGET_KIND_ENTER_DATA:
1430 kind = " enter data";
1431 break;
1432 case GF_OMP_TARGET_KIND_EXIT_DATA:
1433 kind = " exit data";
1434 break;
1435 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1436 kind = " oacc_kernels";
1437 break;
1438 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1439 kind = " oacc_parallel";
1440 break;
1441 case GF_OMP_TARGET_KIND_OACC_DATA:
1442 kind = " oacc_data";
1443 break;
1444 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1445 kind = " oacc_update";
1446 break;
1447 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1448 kind = " oacc_enter_exit_data";
1449 break;
1450 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1451 kind = " oacc_declare";
1452 break;
1453 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1454 kind = " oacc_host_data";
1455 break;
1456 default:
1457 gcc_unreachable ();
1459 if (flags & TDF_RAW)
1461 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1462 kind, gimple_omp_body (gs));
1463 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1464 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1465 gimple_omp_target_child_fn (gs),
1466 gimple_omp_target_data_arg (gs));
1468 else
1470 pp_string (buffer, "#pragma omp target");
1471 pp_string (buffer, kind);
1472 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1473 if (gimple_omp_target_child_fn (gs))
1475 pp_string (buffer, " [child fn: ");
1476 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1477 spc, flags, false);
1478 pp_string (buffer, " (");
1479 if (gimple_omp_target_data_arg (gs))
1480 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1481 spc, flags, false);
1482 else
1483 pp_string (buffer, "???");
1484 pp_string (buffer, ")]");
1486 gimple_seq body = gimple_omp_body (gs);
1487 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1489 newline_and_indent (buffer, spc + 2);
1490 pp_left_brace (buffer);
1491 pp_newline (buffer);
1492 dump_gimple_seq (buffer, body, spc + 4, flags);
1493 newline_and_indent (buffer, spc + 2);
1494 pp_right_brace (buffer);
1496 else if (body)
1498 pp_newline (buffer);
1499 dump_gimple_seq (buffer, body, spc + 2, flags);
1504 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1506 static void
1507 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1508 int flags)
1510 if (flags & TDF_RAW)
1512 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1513 gimple_omp_body (gs));
1514 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1515 dump_gimple_fmt (buffer, spc, flags, " >");
1517 else
1519 pp_string (buffer, "#pragma omp teams");
1520 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1521 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1523 newline_and_indent (buffer, spc + 2);
1524 pp_character (buffer, '{');
1525 pp_newline (buffer);
1526 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1527 newline_and_indent (buffer, spc + 2);
1528 pp_character (buffer, '}');
1533 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1535 static void
1536 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1537 int spc, int flags)
1539 if (flags & TDF_RAW)
1541 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1542 gimple_omp_body (gs));
1543 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1544 dump_gimple_fmt (buffer, spc, flags, " >");
1546 else
1548 pp_string (buffer, "#pragma omp sections");
1549 if (gimple_omp_sections_control (gs))
1551 pp_string (buffer, " <");
1552 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1553 flags, false);
1554 pp_greater (buffer);
1556 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1557 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1559 newline_and_indent (buffer, spc + 2);
1560 pp_left_brace (buffer);
1561 pp_newline (buffer);
1562 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1563 newline_and_indent (buffer, spc + 2);
1564 pp_right_brace (buffer);
1569 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1570 pretty_printer BUFFER. */
1572 static void
1573 dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc, int flags)
1575 if (flags & TDF_RAW)
1576 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1577 gimple_omp_body (gs));
1578 else
1580 switch (gimple_code (gs))
1582 case GIMPLE_OMP_MASTER:
1583 pp_string (buffer, "#pragma omp master");
1584 break;
1585 case GIMPLE_OMP_TASKGROUP:
1586 pp_string (buffer, "#pragma omp taskgroup");
1587 break;
1588 case GIMPLE_OMP_SECTION:
1589 pp_string (buffer, "#pragma omp section");
1590 break;
1591 case GIMPLE_OMP_GRID_BODY:
1592 pp_string (buffer, "#pragma omp gridified body");
1593 break;
1594 default:
1595 gcc_unreachable ();
1597 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1599 newline_and_indent (buffer, spc + 2);
1600 pp_left_brace (buffer);
1601 pp_newline (buffer);
1602 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1603 newline_and_indent (buffer, spc + 2);
1604 pp_right_brace (buffer);
1609 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1611 static void
1612 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1613 int spc, int flags)
1615 if (flags & TDF_RAW)
1616 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1617 gimple_omp_body (gs));
1618 else
1620 pp_string (buffer, "#pragma omp critical");
1621 if (gimple_omp_critical_name (gs))
1623 pp_string (buffer, " (");
1624 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1625 flags, false);
1626 pp_right_paren (buffer);
1628 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1629 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1631 newline_and_indent (buffer, spc + 2);
1632 pp_left_brace (buffer);
1633 pp_newline (buffer);
1634 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1635 newline_and_indent (buffer, spc + 2);
1636 pp_right_brace (buffer);
1641 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1643 static void
1644 dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
1645 int spc, int flags)
1647 if (flags & TDF_RAW)
1648 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1649 gimple_omp_body (gs));
1650 else
1652 pp_string (buffer, "#pragma omp ordered");
1653 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
1654 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1656 newline_and_indent (buffer, spc + 2);
1657 pp_left_brace (buffer);
1658 pp_newline (buffer);
1659 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1660 newline_and_indent (buffer, spc + 2);
1661 pp_right_brace (buffer);
1666 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1668 static void
1669 dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc, int flags)
1671 if (flags & TDF_RAW)
1673 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1674 (int) gimple_omp_return_nowait_p (gs));
1675 if (gimple_omp_return_lhs (gs))
1676 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1677 gimple_omp_return_lhs (gs));
1678 else
1679 dump_gimple_fmt (buffer, spc, flags, ">");
1681 else
1683 pp_string (buffer, "#pragma omp return");
1684 if (gimple_omp_return_nowait_p (gs))
1685 pp_string (buffer, "(nowait)");
1686 if (gimple_omp_return_lhs (gs))
1688 pp_string (buffer, " (set ");
1689 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1690 spc, flags, false);
1691 pp_character (buffer, ')');
1696 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1698 static void
1699 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1700 int spc, int flags)
1702 unsigned subcode = gimple_transaction_subcode (gs);
1704 if (flags & TDF_RAW)
1706 dump_gimple_fmt (buffer, spc, flags,
1707 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1708 "<%+BODY <%S> >",
1709 gs, subcode, gimple_transaction_label_norm (gs),
1710 gimple_transaction_label_uninst (gs),
1711 gimple_transaction_label_over (gs),
1712 gimple_transaction_body (gs));
1714 else
1716 if (subcode & GTMA_IS_OUTER)
1717 pp_string (buffer, "__transaction_atomic [[outer]]");
1718 else if (subcode & GTMA_IS_RELAXED)
1719 pp_string (buffer, "__transaction_relaxed");
1720 else
1721 pp_string (buffer, "__transaction_atomic");
1722 subcode &= ~GTMA_DECLARATION_MASK;
1724 if (gimple_transaction_body (gs))
1726 newline_and_indent (buffer, spc + 2);
1727 pp_left_brace (buffer);
1728 pp_newline (buffer);
1729 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1730 spc + 4, flags);
1731 newline_and_indent (buffer, spc + 2);
1732 pp_right_brace (buffer);
1734 else
1736 pp_string (buffer, " //");
1737 if (gimple_transaction_label_norm (gs))
1739 pp_string (buffer, " NORM=");
1740 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1741 spc, flags, false);
1743 if (gimple_transaction_label_uninst (gs))
1745 pp_string (buffer, " UNINST=");
1746 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1747 spc, flags, false);
1749 if (gimple_transaction_label_over (gs))
1751 pp_string (buffer, " OVER=");
1752 dump_generic_node (buffer, gimple_transaction_label_over (gs),
1753 spc, flags, false);
1755 if (subcode)
1757 pp_string (buffer, " SUBCODE=[ ");
1758 if (subcode & GTMA_HAVE_ABORT)
1760 pp_string (buffer, "GTMA_HAVE_ABORT ");
1761 subcode &= ~GTMA_HAVE_ABORT;
1763 if (subcode & GTMA_HAVE_LOAD)
1765 pp_string (buffer, "GTMA_HAVE_LOAD ");
1766 subcode &= ~GTMA_HAVE_LOAD;
1768 if (subcode & GTMA_HAVE_STORE)
1770 pp_string (buffer, "GTMA_HAVE_STORE ");
1771 subcode &= ~GTMA_HAVE_STORE;
1773 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1775 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1776 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1778 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1780 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1781 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1783 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1785 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1786 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1788 if (subcode)
1789 pp_printf (buffer, "0x%x ", subcode);
1790 pp_right_bracket (buffer);
1796 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1797 indent. FLAGS specifies details to show in the dump (see TDF_* in
1798 dumpfile.h). */
1800 static void
1801 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
1803 unsigned int i, n, f, fields;
1805 if (flags & TDF_RAW)
1807 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1808 gimple_asm_string (gs));
1810 n = gimple_asm_noutputs (gs);
1811 if (n)
1813 newline_and_indent (buffer, spc + 2);
1814 pp_string (buffer, "OUTPUT: ");
1815 for (i = 0; i < n; i++)
1817 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1818 spc, flags, false);
1819 if (i < n - 1)
1820 pp_string (buffer, ", ");
1824 n = gimple_asm_ninputs (gs);
1825 if (n)
1827 newline_and_indent (buffer, spc + 2);
1828 pp_string (buffer, "INPUT: ");
1829 for (i = 0; i < n; i++)
1831 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1832 spc, flags, false);
1833 if (i < n - 1)
1834 pp_string (buffer, ", ");
1838 n = gimple_asm_nclobbers (gs);
1839 if (n)
1841 newline_and_indent (buffer, spc + 2);
1842 pp_string (buffer, "CLOBBER: ");
1843 for (i = 0; i < n; i++)
1845 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1846 spc, flags, false);
1847 if (i < n - 1)
1848 pp_string (buffer, ", ");
1852 n = gimple_asm_nlabels (gs);
1853 if (n)
1855 newline_and_indent (buffer, spc + 2);
1856 pp_string (buffer, "LABEL: ");
1857 for (i = 0; i < n; i++)
1859 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1860 spc, flags, false);
1861 if (i < n - 1)
1862 pp_string (buffer, ", ");
1866 newline_and_indent (buffer, spc);
1867 pp_greater (buffer);
1869 else
1871 pp_string (buffer, "__asm__");
1872 if (gimple_asm_volatile_p (gs))
1873 pp_string (buffer, " __volatile__");
1874 if (gimple_asm_nlabels (gs))
1875 pp_string (buffer, " goto");
1876 pp_string (buffer, "(\"");
1877 pp_string (buffer, gimple_asm_string (gs));
1878 pp_string (buffer, "\"");
1880 if (gimple_asm_nlabels (gs))
1881 fields = 4;
1882 else if (gimple_asm_nclobbers (gs))
1883 fields = 3;
1884 else if (gimple_asm_ninputs (gs))
1885 fields = 2;
1886 else if (gimple_asm_noutputs (gs))
1887 fields = 1;
1888 else
1889 fields = 0;
1891 for (f = 0; f < fields; ++f)
1893 pp_string (buffer, " : ");
1895 switch (f)
1897 case 0:
1898 n = gimple_asm_noutputs (gs);
1899 for (i = 0; i < n; i++)
1901 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1902 spc, flags, false);
1903 if (i < n - 1)
1904 pp_string (buffer, ", ");
1906 break;
1908 case 1:
1909 n = gimple_asm_ninputs (gs);
1910 for (i = 0; i < n; i++)
1912 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1913 spc, flags, false);
1914 if (i < n - 1)
1915 pp_string (buffer, ", ");
1917 break;
1919 case 2:
1920 n = gimple_asm_nclobbers (gs);
1921 for (i = 0; i < n; i++)
1923 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1924 spc, flags, false);
1925 if (i < n - 1)
1926 pp_string (buffer, ", ");
1928 break;
1930 case 3:
1931 n = gimple_asm_nlabels (gs);
1932 for (i = 0; i < n; i++)
1934 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1935 spc, flags, false);
1936 if (i < n - 1)
1937 pp_string (buffer, ", ");
1939 break;
1941 default:
1942 gcc_unreachable ();
1946 pp_string (buffer, ");");
1950 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1951 SPC spaces of indent. */
1953 static void
1954 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1956 if (TREE_CODE (node) != SSA_NAME)
1957 return;
1959 if (POINTER_TYPE_P (TREE_TYPE (node))
1960 && SSA_NAME_PTR_INFO (node))
1962 unsigned int align, misalign;
1963 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1964 pp_string (buffer, "# PT = ");
1965 pp_points_to_solution (buffer, &pi->pt);
1966 newline_and_indent (buffer, spc);
1967 if (get_ptr_info_alignment (pi, &align, &misalign))
1969 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1970 newline_and_indent (buffer, spc);
1974 if (!POINTER_TYPE_P (TREE_TYPE (node))
1975 && SSA_NAME_RANGE_INFO (node))
1977 wide_int min, max, nonzero_bits;
1978 value_range_type range_type = get_range_info (node, &min, &max);
1980 if (range_type == VR_VARYING)
1981 pp_printf (buffer, "# RANGE VR_VARYING");
1982 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1984 pp_printf (buffer, "# RANGE ");
1985 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1986 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
1987 pp_printf (buffer, ", ");
1988 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
1989 pp_printf (buffer, "]");
1991 nonzero_bits = get_nonzero_bits (node);
1992 if (nonzero_bits != -1)
1994 pp_string (buffer, " NONZERO ");
1995 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
1997 newline_and_indent (buffer, spc);
2001 /* As dump_ssaname_info, but dump to FILE. */
2003 void
2004 dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2006 pretty_printer buffer;
2007 pp_needs_newline (&buffer) = true;
2008 buffer.buffer->stream = file;
2009 dump_ssaname_info (&buffer, node, spc);
2010 pp_flush (&buffer);
2013 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2014 The caller is responsible for calling pp_flush on BUFFER to finalize
2015 pretty printer. If COMMENT is true, print this after #. */
2017 static void
2018 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
2019 int flags)
2021 size_t i;
2022 tree lhs = gimple_phi_result (phi);
2024 if (flags & TDF_ALIAS)
2025 dump_ssaname_info (buffer, lhs, spc);
2027 if (comment)
2028 pp_string (buffer, "# ");
2030 if (flags & TDF_RAW)
2031 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2032 gimple_phi_result (phi));
2033 else
2035 dump_generic_node (buffer, lhs, spc, flags, false);
2036 pp_string (buffer, " = PHI <");
2038 for (i = 0; i < gimple_phi_num_args (phi); i++)
2040 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
2041 dump_location (buffer, gimple_phi_arg_location (phi, i));
2042 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2043 false);
2044 pp_left_paren (buffer);
2045 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2046 pp_right_paren (buffer);
2047 if (i < gimple_phi_num_args (phi) - 1)
2048 pp_string (buffer, ", ");
2050 pp_greater (buffer);
2054 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2055 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2056 dumpfile.h). */
2058 static void
2059 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
2060 int spc, int flags)
2062 if (flags & TDF_RAW)
2064 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2065 gimple_omp_body (gs));
2066 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2067 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2068 gimple_omp_parallel_child_fn (gs),
2069 gimple_omp_parallel_data_arg (gs));
2071 else
2073 gimple_seq body;
2074 pp_string (buffer, "#pragma omp parallel");
2075 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2076 if (gimple_omp_parallel_child_fn (gs))
2078 pp_string (buffer, " [child fn: ");
2079 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2080 spc, flags, false);
2081 pp_string (buffer, " (");
2082 if (gimple_omp_parallel_data_arg (gs))
2083 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2084 spc, flags, false);
2085 else
2086 pp_string (buffer, "???");
2087 pp_string (buffer, ")]");
2089 body = gimple_omp_body (gs);
2090 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2092 newline_and_indent (buffer, spc + 2);
2093 pp_left_brace (buffer);
2094 pp_newline (buffer);
2095 dump_gimple_seq (buffer, body, spc + 4, flags);
2096 newline_and_indent (buffer, spc + 2);
2097 pp_right_brace (buffer);
2099 else if (body)
2101 pp_newline (buffer);
2102 dump_gimple_seq (buffer, body, spc + 2, flags);
2108 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2109 of indent. FLAGS specifies details to show in the dump (see TDF_* in
2110 dumpfile.h). */
2112 static void
2113 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
2114 int flags)
2116 if (flags & TDF_RAW)
2118 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2119 gimple_omp_body (gs));
2120 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2121 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2122 gimple_omp_task_child_fn (gs),
2123 gimple_omp_task_data_arg (gs),
2124 gimple_omp_task_copy_fn (gs),
2125 gimple_omp_task_arg_size (gs),
2126 gimple_omp_task_arg_size (gs));
2128 else
2130 gimple_seq body;
2131 if (gimple_omp_task_taskloop_p (gs))
2132 pp_string (buffer, "#pragma omp taskloop");
2133 else
2134 pp_string (buffer, "#pragma omp task");
2135 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2136 if (gimple_omp_task_child_fn (gs))
2138 pp_string (buffer, " [child fn: ");
2139 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2140 spc, flags, false);
2141 pp_string (buffer, " (");
2142 if (gimple_omp_task_data_arg (gs))
2143 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2144 spc, flags, false);
2145 else
2146 pp_string (buffer, "???");
2147 pp_string (buffer, ")]");
2149 body = gimple_omp_body (gs);
2150 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2152 newline_and_indent (buffer, spc + 2);
2153 pp_left_brace (buffer);
2154 pp_newline (buffer);
2155 dump_gimple_seq (buffer, body, spc + 4, flags);
2156 newline_and_indent (buffer, spc + 2);
2157 pp_right_brace (buffer);
2159 else if (body)
2161 pp_newline (buffer);
2162 dump_gimple_seq (buffer, body, spc + 2, flags);
2168 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2169 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2170 in dumpfile.h). */
2172 static void
2173 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2174 int spc, int flags)
2176 if (flags & TDF_RAW)
2178 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2179 gimple_omp_atomic_load_lhs (gs),
2180 gimple_omp_atomic_load_rhs (gs));
2182 else
2184 pp_string (buffer, "#pragma omp atomic_load");
2185 if (gimple_omp_atomic_seq_cst_p (gs))
2186 pp_string (buffer, " seq_cst");
2187 if (gimple_omp_atomic_need_value_p (gs))
2188 pp_string (buffer, " [needed]");
2189 newline_and_indent (buffer, spc + 2);
2190 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2191 spc, flags, false);
2192 pp_space (buffer);
2193 pp_equal (buffer);
2194 pp_space (buffer);
2195 pp_star (buffer);
2196 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2197 spc, flags, false);
2201 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2202 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2203 in dumpfile.h). */
2205 static void
2206 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2207 gomp_atomic_store *gs, int spc, int flags)
2209 if (flags & TDF_RAW)
2211 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2212 gimple_omp_atomic_store_val (gs));
2214 else
2216 pp_string (buffer, "#pragma omp atomic_store ");
2217 if (gimple_omp_atomic_seq_cst_p (gs))
2218 pp_string (buffer, "seq_cst ");
2219 if (gimple_omp_atomic_need_value_p (gs))
2220 pp_string (buffer, "[needed] ");
2221 pp_left_paren (buffer);
2222 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2223 spc, flags, false);
2224 pp_right_paren (buffer);
2229 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2230 FLAGS are as in pp_gimple_stmt_1. */
2232 static void
2233 dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc, int flags)
2235 tree vdef = gimple_vdef (gs);
2236 tree vuse = gimple_vuse (gs);
2238 if (vdef != NULL_TREE)
2240 pp_string (buffer, "# ");
2241 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2242 pp_string (buffer, " = VDEF <");
2243 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2244 pp_greater (buffer);
2245 newline_and_indent (buffer, spc);
2247 else if (vuse != NULL_TREE)
2249 pp_string (buffer, "# VUSE <");
2250 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2251 pp_greater (buffer);
2252 newline_and_indent (buffer, spc);
2257 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2258 spaces of indent. FLAGS specifies details to show in the dump (see
2259 TDF_* in dumpfile.h). The caller is responsible for calling
2260 pp_flush on BUFFER to finalize the pretty printer. */
2262 void
2263 pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
2265 if (!gs)
2266 return;
2268 if (flags & TDF_STMTADDR)
2269 pp_printf (buffer, "<&%p> ", (void *) gs);
2271 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2272 dump_location (buffer, gimple_location (gs));
2274 if (flags & TDF_EH)
2276 int lp_nr = lookup_stmt_eh_lp (gs);
2277 if (lp_nr > 0)
2278 pp_printf (buffer, "[LP %d] ", lp_nr);
2279 else if (lp_nr < 0)
2280 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2283 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2284 && gimple_has_mem_ops (gs))
2285 dump_gimple_mem_ops (buffer, gs, spc, flags);
2287 if (gimple_has_lhs (gs)
2288 && (flags & TDF_ALIAS))
2289 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2291 switch (gimple_code (gs))
2293 case GIMPLE_ASM:
2294 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2295 break;
2297 case GIMPLE_ASSIGN:
2298 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2299 break;
2301 case GIMPLE_BIND:
2302 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2303 break;
2305 case GIMPLE_CALL:
2306 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2307 break;
2309 case GIMPLE_COND:
2310 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2311 break;
2313 case GIMPLE_LABEL:
2314 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2315 break;
2317 case GIMPLE_GOTO:
2318 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2319 break;
2321 case GIMPLE_NOP:
2322 pp_string (buffer, "GIMPLE_NOP");
2323 break;
2325 case GIMPLE_RETURN:
2326 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2327 break;
2329 case GIMPLE_SWITCH:
2330 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2331 break;
2333 case GIMPLE_TRY:
2334 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2335 break;
2337 case GIMPLE_PHI:
2338 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2339 break;
2341 case GIMPLE_OMP_PARALLEL:
2342 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2343 flags);
2344 break;
2346 case GIMPLE_OMP_TASK:
2347 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2348 break;
2350 case GIMPLE_OMP_ATOMIC_LOAD:
2351 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2352 spc, flags);
2353 break;
2355 case GIMPLE_OMP_ATOMIC_STORE:
2356 dump_gimple_omp_atomic_store (buffer,
2357 as_a <gomp_atomic_store *> (gs),
2358 spc, flags);
2359 break;
2361 case GIMPLE_OMP_FOR:
2362 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2363 break;
2365 case GIMPLE_OMP_CONTINUE:
2366 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2367 flags);
2368 break;
2370 case GIMPLE_OMP_SINGLE:
2371 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2372 flags);
2373 break;
2375 case GIMPLE_OMP_TARGET:
2376 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2377 flags);
2378 break;
2380 case GIMPLE_OMP_TEAMS:
2381 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2382 flags);
2383 break;
2385 case GIMPLE_OMP_RETURN:
2386 dump_gimple_omp_return (buffer, gs, spc, flags);
2387 break;
2389 case GIMPLE_OMP_SECTIONS:
2390 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2391 spc, flags);
2392 break;
2394 case GIMPLE_OMP_SECTIONS_SWITCH:
2395 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2396 break;
2398 case GIMPLE_OMP_MASTER:
2399 case GIMPLE_OMP_TASKGROUP:
2400 case GIMPLE_OMP_SECTION:
2401 case GIMPLE_OMP_GRID_BODY:
2402 dump_gimple_omp_block (buffer, gs, spc, flags);
2403 break;
2405 case GIMPLE_OMP_ORDERED:
2406 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2407 flags);
2408 break;
2410 case GIMPLE_OMP_CRITICAL:
2411 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2412 flags);
2413 break;
2415 case GIMPLE_CATCH:
2416 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2417 break;
2419 case GIMPLE_EH_FILTER:
2420 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2421 break;
2423 case GIMPLE_EH_MUST_NOT_THROW:
2424 dump_gimple_eh_must_not_throw (buffer,
2425 as_a <geh_mnt *> (gs),
2426 spc, flags);
2427 break;
2429 case GIMPLE_EH_ELSE:
2430 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2431 break;
2433 case GIMPLE_RESX:
2434 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2435 break;
2437 case GIMPLE_EH_DISPATCH:
2438 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2439 flags);
2440 break;
2442 case GIMPLE_DEBUG:
2443 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2444 break;
2446 case GIMPLE_PREDICT:
2447 pp_string (buffer, "// predicted ");
2448 if (gimple_predict_outcome (gs))
2449 pp_string (buffer, "likely by ");
2450 else
2451 pp_string (buffer, "unlikely by ");
2452 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2453 pp_string (buffer, " predictor.");
2454 break;
2456 case GIMPLE_TRANSACTION:
2457 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2458 flags);
2459 break;
2461 default:
2462 GIMPLE_NIY;
2467 /* Dumps header of basic block BB to OUTF indented by INDENT
2468 spaces and details described by flags. */
2470 static void
2471 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2473 if (flags & TDF_BLOCKS)
2475 if (flags & TDF_LINENO)
2477 gimple_stmt_iterator gsi;
2479 if (flags & TDF_COMMENT)
2480 fputs (";; ", outf);
2482 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2483 if (!is_gimple_debug (gsi_stmt (gsi))
2484 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2486 fprintf (outf, "%*sstarting at line %d",
2487 indent, "", get_lineno (gsi_stmt (gsi)));
2488 break;
2490 if (bb->discriminator)
2491 fprintf (outf, ", discriminator %i", bb->discriminator);
2492 fputc ('\n', outf);
2495 else
2497 gimple *stmt = first_stmt (bb);
2498 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2499 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2504 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2505 spaces. */
2507 static void
2508 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2509 basic_block bb ATTRIBUTE_UNUSED,
2510 int indent ATTRIBUTE_UNUSED,
2511 int flags ATTRIBUTE_UNUSED)
2513 /* There is currently no GIMPLE-specific basic block info to dump. */
2514 return;
2518 /* Dump PHI nodes of basic block BB to BUFFER with details described
2519 by FLAGS and indented by INDENT spaces. */
2521 static void
2522 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2524 gphi_iterator i;
2526 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2528 gphi *phi = i.phi ();
2529 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2531 INDENT (indent);
2532 dump_gimple_phi (buffer, phi, indent, true, flags);
2533 pp_newline (buffer);
2539 /* Dump jump to basic block BB that is represented implicitly in the cfg
2540 to BUFFER. */
2542 static void
2543 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2545 gimple *stmt;
2547 stmt = first_stmt (bb);
2549 pp_string (buffer, "goto <bb ");
2550 pp_decimal_int (buffer, bb->index);
2551 pp_greater (buffer);
2552 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2554 pp_string (buffer, " (");
2555 dump_generic_node (buffer,
2556 gimple_label_label (as_a <glabel *> (stmt)),
2557 0, 0, false);
2558 pp_right_paren (buffer);
2559 pp_semicolon (buffer);
2561 else
2562 pp_semicolon (buffer);
2566 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2567 by INDENT spaces, with details given by FLAGS. */
2569 static void
2570 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2571 int flags)
2573 edge e;
2574 gimple *stmt;
2576 stmt = last_stmt (bb);
2578 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2580 edge true_edge, false_edge;
2582 /* When we are emitting the code or changing CFG, it is possible that
2583 the edges are not yet created. When we are using debug_bb in such
2584 a situation, we do not want it to crash. */
2585 if (EDGE_COUNT (bb->succs) != 2)
2586 return;
2587 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2589 INDENT (indent + 2);
2590 pp_cfg_jump (buffer, true_edge->dest);
2591 newline_and_indent (buffer, indent);
2592 pp_string (buffer, "else");
2593 newline_and_indent (buffer, indent + 2);
2594 pp_cfg_jump (buffer, false_edge->dest);
2595 pp_newline (buffer);
2596 return;
2599 /* If there is a fallthru edge, we may need to add an artificial
2600 goto to the dump. */
2601 e = find_fallthru_edge (bb->succs);
2603 if (e && e->dest != bb->next_bb)
2605 INDENT (indent);
2607 if ((flags & TDF_LINENO)
2608 && e->goto_locus != UNKNOWN_LOCATION)
2609 dump_location (buffer, e->goto_locus);
2611 pp_cfg_jump (buffer, e->dest);
2612 pp_newline (buffer);
2617 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2618 indented by INDENT spaces. */
2620 static void
2621 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2622 int flags)
2624 gimple_stmt_iterator gsi;
2625 gimple *stmt;
2626 int label_indent = indent - 2;
2628 if (label_indent < 0)
2629 label_indent = 0;
2631 dump_phi_nodes (buffer, bb, indent, flags);
2633 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2635 int curr_indent;
2637 stmt = gsi_stmt (gsi);
2639 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2641 INDENT (curr_indent);
2642 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2643 pp_newline_and_flush (buffer);
2644 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2645 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2646 pp_buffer (buffer)->stream, stmt);
2649 dump_implicit_edges (buffer, bb, indent, flags);
2650 pp_flush (buffer);
2654 /* Dumps basic block BB to FILE with details described by FLAGS and
2655 indented by INDENT spaces. */
2657 void
2658 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2660 dump_gimple_bb_header (file, bb, indent, flags);
2661 if (bb->index >= NUM_FIXED_BLOCKS)
2663 pretty_printer buffer;
2664 pp_needs_newline (&buffer) = true;
2665 buffer.buffer->stream = file;
2666 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2668 dump_gimple_bb_footer (file, bb, indent, flags);
2671 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2672 no indentation, for use as a label of a DOT graph record-node.
2673 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2674 histogram dumping doesn't know about pretty-printers. */
2676 void
2677 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2679 pp_printf (pp, "<bb %d>:\n", bb->index);
2680 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2682 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2683 gsi_next (&gsi))
2685 gphi *phi = gsi.phi ();
2686 if (!virtual_operand_p (gimple_phi_result (phi))
2687 || (dump_flags & TDF_VOPS))
2689 pp_bar (pp);
2690 pp_write_text_to_stream (pp);
2691 pp_string (pp, "# ");
2692 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2693 pp_newline (pp);
2694 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2698 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2699 gsi_next (&gsi))
2701 gimple *stmt = gsi_stmt (gsi);
2702 pp_bar (pp);
2703 pp_write_text_to_stream (pp);
2704 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2705 pp_newline (pp);
2706 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2708 dump_implicit_edges (pp, bb, 0, dump_flags);
2709 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);