Implement TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS hook.
[official-gcc.git] / gcc / gimple-pretty-print.c
blob5fa4a0ab66d1057268ee0e95cdb799bf0dbf521e
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2015 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 "tm.h"
26 #include "input.h"
27 #include "alias.h"
28 #include "symtab.h"
29 #include "tree.h"
30 #include "fold-const.h"
31 #include "stringpool.h"
32 #include "diagnostic.h"
33 #include "gimple-pretty-print.h"
34 #include "bitmap.h"
35 #include "predict.h"
36 #include "hard-reg-set.h"
37 #include "input.h"
38 #include "function.h"
39 #include "basic-block.h"
40 #include "tree-ssa-alias.h"
41 #include "internal-fn.h"
42 #include "tree-eh.h"
43 #include "gimple-expr.h"
44 #include "is-a.h"
45 #include "gimple.h"
46 #include "gimple-iterator.h"
47 #include "gimple-ssa.h"
48 #include "plugin-api.h"
49 #include "ipa-ref.h"
50 #include "cgraph.h"
51 #include "tree-cfg.h"
52 #include "tree-ssanames.h"
53 #include "dumpfile.h" /* for dump_flags */
54 #include "value-prof.h"
55 #include "trans-mem.h"
57 #define INDENT(SPACE) \
58 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
60 #define GIMPLE_NIY do_niy (buffer,gs)
62 /* Try to print on BUFFER a default message for the unrecognized
63 gimple statement GS. */
65 static void
66 do_niy (pretty_printer *buffer, gimple gs)
68 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
69 gimple_code_name[(int) gimple_code (gs)]);
73 /* Emit a newline and SPC indentation spaces to BUFFER. */
75 static void
76 newline_and_indent (pretty_printer *buffer, int spc)
78 pp_newline (buffer);
79 INDENT (spc);
83 /* Print the GIMPLE statement GS on stderr. */
85 DEBUG_FUNCTION void
86 debug_gimple_stmt (gimple gs)
88 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
92 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
93 FLAGS as in pp_gimple_stmt_1. */
95 void
96 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
98 pretty_printer buffer;
99 pp_needs_newline (&buffer) = true;
100 buffer.buffer->stream = file;
101 pp_gimple_stmt_1 (&buffer, g, spc, flags);
102 pp_newline_and_flush (&buffer);
105 DEBUG_FUNCTION void
106 debug (gimple_statement_base &ref)
108 print_gimple_stmt (stderr, &ref, 0, 0);
111 DEBUG_FUNCTION void
112 debug (gimple_statement_base *ptr)
114 if (ptr)
115 debug (*ptr);
116 else
117 fprintf (stderr, "<nil>\n");
121 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
122 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
123 of the statement. */
125 void
126 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
128 flags |= TDF_RHS_ONLY;
129 pretty_printer buffer;
130 pp_needs_newline (&buffer) = true;
131 buffer.buffer->stream = file;
132 pp_gimple_stmt_1 (&buffer, g, spc, flags);
133 pp_flush (&buffer);
137 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
138 spaces and FLAGS as in pp_gimple_stmt_1.
139 The caller is responsible for calling pp_flush on BUFFER to finalize
140 the pretty printer. */
142 static void
143 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
145 gimple_stmt_iterator i;
147 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
149 gimple gs = gsi_stmt (i);
150 INDENT (spc);
151 pp_gimple_stmt_1 (buffer, gs, spc, flags);
152 if (!gsi_one_before_end_p (i))
153 pp_newline (buffer);
158 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
159 FLAGS as in pp_gimple_stmt_1. */
161 void
162 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
164 pretty_printer buffer;
165 pp_needs_newline (&buffer) = true;
166 buffer.buffer->stream = file;
167 dump_gimple_seq (&buffer, seq, spc, flags);
168 pp_newline_and_flush (&buffer);
172 /* Print the GIMPLE sequence SEQ on stderr. */
174 DEBUG_FUNCTION void
175 debug_gimple_seq (gimple_seq seq)
177 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
181 /* A simple helper to pretty-print some of the gimple tuples in the printf
182 style. The format modifiers are preceded by '%' and are:
183 'G' - outputs a string corresponding to the code of the given gimple,
184 'S' - outputs a gimple_seq with indent of spc + 2,
185 'T' - outputs the tree t,
186 'd' - outputs an int as a decimal,
187 's' - outputs a string,
188 'n' - outputs a newline,
189 'x' - outputs an int as hexadecimal,
190 '+' - increases indent by 2 then outputs a newline,
191 '-' - decreases indent by 2 then outputs a newline. */
193 static void
194 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
195 const char *fmt, ...)
197 va_list args;
198 const char *c;
199 const char *tmp;
201 va_start (args, fmt);
202 for (c = fmt; *c; c++)
204 if (*c == '%')
206 gimple_seq seq;
207 tree t;
208 gimple g;
209 switch (*++c)
211 case 'G':
212 g = va_arg (args, gimple);
213 tmp = gimple_code_name[gimple_code (g)];
214 pp_string (buffer, tmp);
215 break;
217 case 'S':
218 seq = va_arg (args, gimple_seq);
219 pp_newline (buffer);
220 dump_gimple_seq (buffer, seq, spc + 2, flags);
221 newline_and_indent (buffer, spc);
222 break;
224 case 'T':
225 t = va_arg (args, tree);
226 if (t == NULL_TREE)
227 pp_string (buffer, "NULL");
228 else
229 dump_generic_node (buffer, t, spc, flags, false);
230 break;
232 case 'd':
233 pp_decimal_int (buffer, va_arg (args, int));
234 break;
236 case 's':
237 pp_string (buffer, va_arg (args, char *));
238 break;
240 case 'n':
241 newline_and_indent (buffer, spc);
242 break;
244 case 'x':
245 pp_scalar (buffer, "%x", va_arg (args, int));
246 break;
248 case '+':
249 spc += 2;
250 newline_and_indent (buffer, spc);
251 break;
253 case '-':
254 spc -= 2;
255 newline_and_indent (buffer, spc);
256 break;
258 default:
259 gcc_unreachable ();
262 else
263 pp_character (buffer, *c);
265 va_end (args);
269 /* Helper for dump_gimple_assign. Print the unary RHS of the
270 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
272 static void
273 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
275 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
276 tree lhs = gimple_assign_lhs (gs);
277 tree rhs = gimple_assign_rhs1 (gs);
279 switch (rhs_code)
281 case VIEW_CONVERT_EXPR:
282 case ASSERT_EXPR:
283 dump_generic_node (buffer, rhs, spc, flags, false);
284 break;
286 case FIXED_CONVERT_EXPR:
287 case ADDR_SPACE_CONVERT_EXPR:
288 case FIX_TRUNC_EXPR:
289 case FLOAT_EXPR:
290 CASE_CONVERT:
291 pp_left_paren (buffer);
292 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
293 pp_string (buffer, ") ");
294 if (op_prio (rhs) < op_code_prio (rhs_code))
296 pp_left_paren (buffer);
297 dump_generic_node (buffer, rhs, spc, flags, false);
298 pp_right_paren (buffer);
300 else
301 dump_generic_node (buffer, rhs, spc, flags, false);
302 break;
304 case PAREN_EXPR:
305 pp_string (buffer, "((");
306 dump_generic_node (buffer, rhs, spc, flags, false);
307 pp_string (buffer, "))");
308 break;
310 case ABS_EXPR:
311 pp_string (buffer, "ABS_EXPR <");
312 dump_generic_node (buffer, rhs, spc, flags, false);
313 pp_greater (buffer);
314 break;
316 default:
317 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
318 || TREE_CODE_CLASS (rhs_code) == tcc_constant
319 || TREE_CODE_CLASS (rhs_code) == tcc_reference
320 || rhs_code == SSA_NAME
321 || rhs_code == ADDR_EXPR
322 || rhs_code == CONSTRUCTOR)
324 dump_generic_node (buffer, rhs, spc, flags, false);
325 break;
327 else if (rhs_code == BIT_NOT_EXPR)
328 pp_complement (buffer);
329 else if (rhs_code == TRUTH_NOT_EXPR)
330 pp_exclamation (buffer);
331 else if (rhs_code == NEGATE_EXPR)
332 pp_minus (buffer);
333 else
335 pp_left_bracket (buffer);
336 pp_string (buffer, get_tree_code_name (rhs_code));
337 pp_string (buffer, "] ");
340 if (op_prio (rhs) < op_code_prio (rhs_code))
342 pp_left_paren (buffer);
343 dump_generic_node (buffer, rhs, spc, flags, false);
344 pp_right_paren (buffer);
346 else
347 dump_generic_node (buffer, rhs, spc, flags, false);
348 break;
353 /* Helper for dump_gimple_assign. Print the binary RHS of the
354 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
356 static void
357 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
359 const char *p;
360 enum tree_code code = gimple_assign_rhs_code (gs);
361 switch (code)
363 case COMPLEX_EXPR:
364 case MIN_EXPR:
365 case MAX_EXPR:
366 case VEC_WIDEN_MULT_HI_EXPR:
367 case VEC_WIDEN_MULT_LO_EXPR:
368 case VEC_WIDEN_MULT_EVEN_EXPR:
369 case VEC_WIDEN_MULT_ODD_EXPR:
370 case VEC_PACK_TRUNC_EXPR:
371 case VEC_PACK_SAT_EXPR:
372 case VEC_PACK_FIX_TRUNC_EXPR:
373 case VEC_WIDEN_LSHIFT_HI_EXPR:
374 case VEC_WIDEN_LSHIFT_LO_EXPR:
375 for (p = get_tree_code_name (code); *p; p++)
376 pp_character (buffer, TOUPPER (*p));
377 pp_string (buffer, " <");
378 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
379 pp_string (buffer, ", ");
380 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
381 pp_greater (buffer);
382 break;
384 default:
385 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
387 pp_left_paren (buffer);
388 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
389 false);
390 pp_right_paren (buffer);
392 else
393 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
394 pp_space (buffer);
395 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
396 pp_space (buffer);
397 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
399 pp_left_paren (buffer);
400 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
401 false);
402 pp_right_paren (buffer);
404 else
405 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
409 /* Helper for dump_gimple_assign. Print the ternary RHS of the
410 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
412 static void
413 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
415 const char *p;
416 enum tree_code code = gimple_assign_rhs_code (gs);
417 switch (code)
419 case WIDEN_MULT_PLUS_EXPR:
420 case WIDEN_MULT_MINUS_EXPR:
421 for (p = get_tree_code_name (code); *p; p++)
422 pp_character (buffer, TOUPPER (*p));
423 pp_string (buffer, " <");
424 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
425 pp_string (buffer, ", ");
426 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
427 pp_string (buffer, ", ");
428 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
429 pp_greater (buffer);
430 break;
432 case FMA_EXPR:
433 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
434 pp_string (buffer, " * ");
435 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
436 pp_string (buffer, " + ");
437 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
438 break;
440 case DOT_PROD_EXPR:
441 pp_string (buffer, "DOT_PROD_EXPR <");
442 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
443 pp_string (buffer, ", ");
444 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
445 pp_string (buffer, ", ");
446 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
447 pp_greater (buffer);
448 break;
450 case SAD_EXPR:
451 pp_string (buffer, "SAD_EXPR <");
452 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
453 pp_string (buffer, ", ");
454 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
455 pp_string (buffer, ", ");
456 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
457 pp_greater (buffer);
458 break;
460 case VEC_PERM_EXPR:
461 pp_string (buffer, "VEC_PERM_EXPR <");
462 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
463 pp_string (buffer, ", ");
464 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
465 pp_string (buffer, ", ");
466 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
467 pp_greater (buffer);
468 break;
470 case REALIGN_LOAD_EXPR:
471 pp_string (buffer, "REALIGN_LOAD <");
472 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
473 pp_string (buffer, ", ");
474 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
475 pp_string (buffer, ", ");
476 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
477 pp_greater (buffer);
478 break;
480 case COND_EXPR:
481 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
482 pp_string (buffer, " ? ");
483 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
484 pp_string (buffer, " : ");
485 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
486 break;
488 case VEC_COND_EXPR:
489 pp_string (buffer, "VEC_COND_EXPR <");
490 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
491 pp_string (buffer, ", ");
492 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
493 pp_string (buffer, ", ");
494 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
495 pp_greater (buffer);
496 break;
498 default:
499 gcc_unreachable ();
504 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
505 pp_gimple_stmt_1. */
507 static void
508 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
510 if (flags & TDF_RAW)
512 tree arg1 = NULL;
513 tree arg2 = NULL;
514 tree arg3 = NULL;
515 switch (gimple_num_ops (gs))
517 case 4:
518 arg3 = gimple_assign_rhs3 (gs);
519 case 3:
520 arg2 = gimple_assign_rhs2 (gs);
521 case 2:
522 arg1 = gimple_assign_rhs1 (gs);
523 break;
524 default:
525 gcc_unreachable ();
528 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
529 get_tree_code_name (gimple_assign_rhs_code (gs)),
530 gimple_assign_lhs (gs), arg1, arg2, arg3);
532 else
534 if (!(flags & TDF_RHS_ONLY))
536 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
537 pp_space (buffer);
538 pp_equal (buffer);
540 if (gimple_assign_nontemporal_move_p (gs))
541 pp_string (buffer, "{nt}");
543 if (gimple_has_volatile_ops (gs))
544 pp_string (buffer, "{v}");
546 pp_space (buffer);
549 if (gimple_num_ops (gs) == 2)
550 dump_unary_rhs (buffer, gs, spc, flags);
551 else if (gimple_num_ops (gs) == 3)
552 dump_binary_rhs (buffer, gs, spc, flags);
553 else if (gimple_num_ops (gs) == 4)
554 dump_ternary_rhs (buffer, gs, spc, flags);
555 else
556 gcc_unreachable ();
557 if (!(flags & TDF_RHS_ONLY))
558 pp_semicolon (buffer);
563 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
564 pp_gimple_stmt_1. */
566 static void
567 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
569 tree t, t2;
571 t = gimple_return_retval (gs);
572 t2 = gimple_return_retbnd (gs);
573 if (flags & TDF_RAW)
574 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
575 else
577 pp_string (buffer, "return");
578 if (t)
580 pp_space (buffer);
581 dump_generic_node (buffer, t, spc, flags, false);
583 if (t2)
585 pp_string (buffer, ", ");
586 dump_generic_node (buffer, t2, spc, flags, false);
588 pp_semicolon (buffer);
593 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
594 dump_gimple_call. */
596 static void
597 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
599 size_t i;
601 for (i = 0; i < gimple_call_num_args (gs); i++)
603 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
604 if (i < gimple_call_num_args (gs) - 1)
605 pp_string (buffer, ", ");
608 if (gimple_call_va_arg_pack_p (gs))
610 if (gimple_call_num_args (gs) > 0)
612 pp_comma (buffer);
613 pp_space (buffer);
616 pp_string (buffer, "__builtin_va_arg_pack ()");
620 /* Dump the points-to solution *PT to BUFFER. */
622 static void
623 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
625 if (pt->anything)
627 pp_string (buffer, "anything ");
628 return;
630 if (pt->nonlocal)
631 pp_string (buffer, "nonlocal ");
632 if (pt->escaped)
633 pp_string (buffer, "escaped ");
634 if (pt->ipa_escaped)
635 pp_string (buffer, "unit-escaped ");
636 if (pt->null)
637 pp_string (buffer, "null ");
638 if (pt->vars
639 && !bitmap_empty_p (pt->vars))
641 bitmap_iterator bi;
642 unsigned i;
643 pp_string (buffer, "{ ");
644 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
646 pp_string (buffer, "D.");
647 pp_decimal_int (buffer, i);
648 pp_space (buffer);
650 pp_right_brace (buffer);
651 if (pt->vars_contains_nonlocal
652 && pt->vars_contains_escaped_heap)
653 pp_string (buffer, " (nonlocal, escaped heap)");
654 else if (pt->vars_contains_nonlocal
655 && pt->vars_contains_escaped)
656 pp_string (buffer, " (nonlocal, escaped)");
657 else if (pt->vars_contains_nonlocal)
658 pp_string (buffer, " (nonlocal)");
659 else if (pt->vars_contains_escaped_heap)
660 pp_string (buffer, " (escaped heap)");
661 else if (pt->vars_contains_escaped)
662 pp_string (buffer, " (escaped)");
666 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
667 pp_gimple_stmt_1. */
669 static void
670 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
672 tree lhs = gimple_call_lhs (gs);
673 tree fn = gimple_call_fn (gs);
675 if (flags & TDF_ALIAS)
677 struct pt_solution *pt;
678 pt = gimple_call_use_set (gs);
679 if (!pt_solution_empty_p (pt))
681 pp_string (buffer, "# USE = ");
682 pp_points_to_solution (buffer, pt);
683 newline_and_indent (buffer, spc);
685 pt = gimple_call_clobber_set (gs);
686 if (!pt_solution_empty_p (pt))
688 pp_string (buffer, "# CLB = ");
689 pp_points_to_solution (buffer, pt);
690 newline_and_indent (buffer, spc);
694 if (flags & TDF_RAW)
696 if (gimple_call_internal_p (gs))
697 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
698 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
699 else
700 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
701 if (gimple_call_num_args (gs) > 0)
703 pp_string (buffer, ", ");
704 dump_gimple_call_args (buffer, gs, flags);
706 pp_greater (buffer);
708 else
710 if (lhs && !(flags & TDF_RHS_ONLY))
712 dump_generic_node (buffer, lhs, spc, flags, false);
713 pp_string (buffer, " =");
715 if (gimple_has_volatile_ops (gs))
716 pp_string (buffer, "{v}");
718 pp_space (buffer);
720 if (gimple_call_internal_p (gs))
721 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
722 else
723 print_call_name (buffer, fn, flags);
724 pp_string (buffer, " (");
725 dump_gimple_call_args (buffer, gs, flags);
726 pp_right_paren (buffer);
727 if (!(flags & TDF_RHS_ONLY))
728 pp_semicolon (buffer);
731 if (gimple_call_chain (gs))
733 pp_string (buffer, " [static-chain: ");
734 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
735 pp_right_bracket (buffer);
738 if (gimple_call_return_slot_opt_p (gs))
739 pp_string (buffer, " [return slot optimization]");
740 if (gimple_call_tail_p (gs))
741 pp_string (buffer, " [tail call]");
743 if (fn == NULL)
744 return;
746 /* Dump the arguments of _ITM_beginTransaction sanely. */
747 if (TREE_CODE (fn) == ADDR_EXPR)
748 fn = TREE_OPERAND (fn, 0);
749 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
750 pp_string (buffer, " [tm-clone]");
751 if (TREE_CODE (fn) == FUNCTION_DECL
752 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
753 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
754 && gimple_call_num_args (gs) > 0)
756 tree t = gimple_call_arg (gs, 0);
757 unsigned HOST_WIDE_INT props;
758 gcc_assert (TREE_CODE (t) == INTEGER_CST);
760 pp_string (buffer, " [ ");
762 /* Get the transaction code properties. */
763 props = TREE_INT_CST_LOW (t);
765 if (props & PR_INSTRUMENTEDCODE)
766 pp_string (buffer, "instrumentedCode ");
767 if (props & PR_UNINSTRUMENTEDCODE)
768 pp_string (buffer, "uninstrumentedCode ");
769 if (props & PR_HASNOXMMUPDATE)
770 pp_string (buffer, "hasNoXMMUpdate ");
771 if (props & PR_HASNOABORT)
772 pp_string (buffer, "hasNoAbort ");
773 if (props & PR_HASNOIRREVOCABLE)
774 pp_string (buffer, "hasNoIrrevocable ");
775 if (props & PR_DOESGOIRREVOCABLE)
776 pp_string (buffer, "doesGoIrrevocable ");
777 if (props & PR_HASNOSIMPLEREADS)
778 pp_string (buffer, "hasNoSimpleReads ");
779 if (props & PR_AWBARRIERSOMITTED)
780 pp_string (buffer, "awBarriersOmitted ");
781 if (props & PR_RARBARRIERSOMITTED)
782 pp_string (buffer, "RaRBarriersOmitted ");
783 if (props & PR_UNDOLOGCODE)
784 pp_string (buffer, "undoLogCode ");
785 if (props & PR_PREFERUNINSTRUMENTED)
786 pp_string (buffer, "preferUninstrumented ");
787 if (props & PR_EXCEPTIONBLOCK)
788 pp_string (buffer, "exceptionBlock ");
789 if (props & PR_HASELSE)
790 pp_string (buffer, "hasElse ");
791 if (props & PR_READONLY)
792 pp_string (buffer, "readOnly ");
794 pp_right_bracket (buffer);
799 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
800 pp_gimple_stmt_1. */
802 static void
803 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
804 int flags)
806 unsigned int i;
808 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
809 if (flags & TDF_RAW)
810 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
811 gimple_switch_index (gs));
812 else
814 pp_string (buffer, "switch (");
815 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
816 pp_string (buffer, ") <");
819 for (i = 0; i < gimple_switch_num_labels (gs); i++)
821 tree case_label = gimple_switch_label (gs, i);
822 gcc_checking_assert (case_label != NULL_TREE);
823 dump_generic_node (buffer, case_label, spc, flags, false);
824 pp_space (buffer);
825 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
826 if (i < gimple_switch_num_labels (gs) - 1)
827 pp_string (buffer, ", ");
829 pp_greater (buffer);
833 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
834 pp_gimple_stmt_1. */
836 static void
837 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
839 if (flags & TDF_RAW)
840 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
841 get_tree_code_name (gimple_cond_code (gs)),
842 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
843 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
844 else
846 if (!(flags & TDF_RHS_ONLY))
847 pp_string (buffer, "if (");
848 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
849 pp_space (buffer);
850 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
851 pp_space (buffer);
852 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
853 if (!(flags & TDF_RHS_ONLY))
855 pp_right_paren (buffer);
857 if (gimple_cond_true_label (gs))
859 pp_string (buffer, " goto ");
860 dump_generic_node (buffer, gimple_cond_true_label (gs),
861 spc, flags, false);
862 pp_semicolon (buffer);
864 if (gimple_cond_false_label (gs))
866 pp_string (buffer, " else goto ");
867 dump_generic_node (buffer, gimple_cond_false_label (gs),
868 spc, flags, false);
869 pp_semicolon (buffer);
876 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
877 spaces of indent. FLAGS specifies details to show in the dump (see
878 TDF_* in dumpfils.h). */
880 static void
881 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
883 tree label = gimple_label_label (gs);
884 if (flags & TDF_RAW)
885 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
886 else
888 dump_generic_node (buffer, label, spc, flags, false);
889 pp_colon (buffer);
891 if (DECL_NONLOCAL (label))
892 pp_string (buffer, " [non-local]");
893 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
894 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
897 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
898 spaces of indent. FLAGS specifies details to show in the dump (see
899 TDF_* in dumpfile.h). */
901 static void
902 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
904 tree label = gimple_goto_dest (gs);
905 if (flags & TDF_RAW)
906 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
907 else
908 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
912 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
913 spaces of indent. FLAGS specifies details to show in the dump (see
914 TDF_* in dumpfile.h). */
916 static void
917 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
919 if (flags & TDF_RAW)
920 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
921 else
922 pp_left_brace (buffer);
923 if (!(flags & TDF_SLIM))
925 tree var;
927 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
929 newline_and_indent (buffer, 2);
930 print_declaration (buffer, var, spc, flags);
932 if (gimple_bind_vars (gs))
933 pp_newline (buffer);
935 pp_newline (buffer);
936 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
937 newline_and_indent (buffer, spc);
938 if (flags & TDF_RAW)
939 pp_greater (buffer);
940 else
941 pp_right_brace (buffer);
945 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
946 indent. FLAGS specifies details to show in the dump (see TDF_* in
947 dumpfile.h). */
949 static void
950 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
952 if (flags & TDF_RAW)
954 const char *type;
955 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
956 type = "GIMPLE_TRY_CATCH";
957 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
958 type = "GIMPLE_TRY_FINALLY";
959 else
960 type = "UNKNOWN GIMPLE_TRY";
961 dump_gimple_fmt (buffer, spc, flags,
962 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
963 gimple_try_eval (gs), gimple_try_cleanup (gs));
965 else
967 pp_string (buffer, "try");
968 newline_and_indent (buffer, spc + 2);
969 pp_left_brace (buffer);
970 pp_newline (buffer);
972 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
973 newline_and_indent (buffer, spc + 2);
974 pp_right_brace (buffer);
976 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
978 newline_and_indent (buffer, spc);
979 pp_string (buffer, "catch");
980 newline_and_indent (buffer, spc + 2);
981 pp_left_brace (buffer);
983 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
985 newline_and_indent (buffer, spc);
986 pp_string (buffer, "finally");
987 newline_and_indent (buffer, spc + 2);
988 pp_left_brace (buffer);
990 else
991 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
993 pp_newline (buffer);
994 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
995 newline_and_indent (buffer, spc + 2);
996 pp_right_brace (buffer);
1001 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1002 indent. FLAGS specifies details to show in the dump (see TDF_* in
1003 dumpfile.h). */
1005 static void
1006 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
1008 if (flags & TDF_RAW)
1009 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1010 gimple_catch_types (gs), gimple_catch_handler (gs));
1011 else
1012 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1013 gimple_catch_types (gs), gimple_catch_handler (gs));
1017 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1018 indent. FLAGS specifies details to show in the dump (see TDF_* in
1019 dumpfile.h). */
1021 static void
1022 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1023 int flags)
1025 if (flags & TDF_RAW)
1026 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1027 gimple_eh_filter_types (gs),
1028 gimple_eh_filter_failure (gs));
1029 else
1030 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1031 gimple_eh_filter_types (gs),
1032 gimple_eh_filter_failure (gs));
1036 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1038 static void
1039 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1040 geh_mnt *gs, int spc, int flags)
1042 if (flags & TDF_RAW)
1043 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1044 gimple_eh_must_not_throw_fndecl (gs));
1045 else
1046 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1047 gimple_eh_must_not_throw_fndecl (gs));
1051 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1052 indent. FLAGS specifies details to show in the dump (see TDF_* in
1053 dumpfile.h). */
1055 static void
1056 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1057 int flags)
1059 if (flags & TDF_RAW)
1060 dump_gimple_fmt (buffer, spc, flags,
1061 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1062 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1063 else
1064 dump_gimple_fmt (buffer, spc, flags,
1065 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1066 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1070 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1071 indent. FLAGS specifies details to show in the dump (see TDF_* in
1072 dumpfile.h). */
1074 static void
1075 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
1077 if (flags & TDF_RAW)
1078 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1079 gimple_resx_region (gs));
1080 else
1081 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1084 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1086 static void
1087 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int flags)
1089 if (flags & TDF_RAW)
1090 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1091 gimple_eh_dispatch_region (gs));
1092 else
1093 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1094 gimple_eh_dispatch_region (gs));
1097 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1098 of indent. FLAGS specifies details to show in the dump (see TDF_*
1099 in dumpfile.h). */
1101 static void
1102 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
1104 switch (gs->subcode)
1106 case GIMPLE_DEBUG_BIND:
1107 if (flags & TDF_RAW)
1108 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1109 gimple_debug_bind_get_var (gs),
1110 gimple_debug_bind_get_value (gs));
1111 else
1112 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1113 gimple_debug_bind_get_var (gs),
1114 gimple_debug_bind_get_value (gs));
1115 break;
1117 case GIMPLE_DEBUG_SOURCE_BIND:
1118 if (flags & TDF_RAW)
1119 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1120 gimple_debug_source_bind_get_var (gs),
1121 gimple_debug_source_bind_get_value (gs));
1122 else
1123 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1124 gimple_debug_source_bind_get_var (gs),
1125 gimple_debug_source_bind_get_value (gs));
1126 break;
1128 default:
1129 gcc_unreachable ();
1133 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1134 static void
1135 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
1137 size_t i;
1139 if (flags & TDF_RAW)
1141 const char *kind;
1142 switch (gimple_omp_for_kind (gs))
1144 case GF_OMP_FOR_KIND_FOR:
1145 kind = "";
1146 break;
1147 case GF_OMP_FOR_KIND_DISTRIBUTE:
1148 kind = " distribute";
1149 break;
1150 case GF_OMP_FOR_KIND_CILKFOR:
1151 kind = " _Cilk_for";
1152 break;
1153 case GF_OMP_FOR_KIND_OACC_LOOP:
1154 kind = " oacc_loop";
1155 break;
1156 case GF_OMP_FOR_KIND_SIMD:
1157 kind = " simd";
1158 break;
1159 case GF_OMP_FOR_KIND_CILKSIMD:
1160 kind = " cilksimd";
1161 break;
1162 default:
1163 gcc_unreachable ();
1165 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1166 kind, gimple_omp_body (gs));
1167 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1168 dump_gimple_fmt (buffer, spc, flags, " >,");
1169 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1170 dump_gimple_fmt (buffer, spc, flags,
1171 "%+%T, %T, %T, %s, %T,%n",
1172 gimple_omp_for_index (gs, i),
1173 gimple_omp_for_initial (gs, i),
1174 gimple_omp_for_final (gs, i),
1175 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1176 gimple_omp_for_incr (gs, i));
1177 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1178 gimple_omp_for_pre_body (gs));
1180 else
1182 switch (gimple_omp_for_kind (gs))
1184 case GF_OMP_FOR_KIND_FOR:
1185 pp_string (buffer, "#pragma omp for");
1186 break;
1187 case GF_OMP_FOR_KIND_DISTRIBUTE:
1188 pp_string (buffer, "#pragma omp distribute");
1189 break;
1190 case GF_OMP_FOR_KIND_CILKFOR:
1191 break;
1192 case GF_OMP_FOR_KIND_OACC_LOOP:
1193 pp_string (buffer, "#pragma acc loop");
1194 break;
1195 case GF_OMP_FOR_KIND_SIMD:
1196 pp_string (buffer, "#pragma omp simd");
1197 break;
1198 case GF_OMP_FOR_KIND_CILKSIMD:
1199 pp_string (buffer, "#pragma simd");
1200 break;
1201 default:
1202 gcc_unreachable ();
1204 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1205 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1206 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1208 if (i)
1209 spc += 2;
1210 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1211 pp_string (buffer, "_Cilk_for (");
1212 else
1214 newline_and_indent (buffer, spc);
1215 pp_string (buffer, "for (");
1217 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1218 flags, false);
1219 pp_string (buffer, " = ");
1220 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1221 flags, false);
1222 pp_string (buffer, "; ");
1224 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1225 flags, false);
1226 pp_space (buffer);
1227 switch (gimple_omp_for_cond (gs, i))
1229 case LT_EXPR:
1230 pp_less (buffer);
1231 break;
1232 case GT_EXPR:
1233 pp_greater (buffer);
1234 break;
1235 case LE_EXPR:
1236 pp_less_equal (buffer);
1237 break;
1238 case GE_EXPR:
1239 pp_greater_equal (buffer);
1240 break;
1241 case NE_EXPR:
1242 pp_string (buffer, "!=");
1243 break;
1244 default:
1245 gcc_unreachable ();
1247 pp_space (buffer);
1248 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1249 flags, false);
1250 pp_string (buffer, "; ");
1252 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1253 flags, false);
1254 pp_string (buffer, " = ");
1255 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1256 flags, false);
1257 pp_right_paren (buffer);
1260 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1262 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1263 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1264 newline_and_indent (buffer, spc + 2);
1265 pp_left_brace (buffer);
1266 pp_newline (buffer);
1267 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1268 newline_and_indent (buffer, spc + 2);
1269 pp_right_brace (buffer);
1274 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1276 static void
1277 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1278 int spc, int flags)
1280 if (flags & TDF_RAW)
1282 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1283 gimple_omp_continue_control_def (gs),
1284 gimple_omp_continue_control_use (gs));
1286 else
1288 pp_string (buffer, "#pragma omp continue (");
1289 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1290 spc, flags, false);
1291 pp_comma (buffer);
1292 pp_space (buffer);
1293 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1294 spc, flags, false);
1295 pp_right_paren (buffer);
1299 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1301 static void
1302 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1303 int spc, int flags)
1305 if (flags & TDF_RAW)
1307 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1308 gimple_omp_body (gs));
1309 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1310 dump_gimple_fmt (buffer, spc, flags, " >");
1312 else
1314 pp_string (buffer, "#pragma omp single");
1315 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1316 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1318 newline_and_indent (buffer, spc + 2);
1319 pp_left_brace (buffer);
1320 pp_newline (buffer);
1321 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1322 newline_and_indent (buffer, spc + 2);
1323 pp_right_brace (buffer);
1328 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1330 static void
1331 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1332 int spc, int flags)
1334 const char *kind;
1335 switch (gimple_omp_target_kind (gs))
1337 case GF_OMP_TARGET_KIND_REGION:
1338 kind = "";
1339 break;
1340 case GF_OMP_TARGET_KIND_DATA:
1341 kind = " data";
1342 break;
1343 case GF_OMP_TARGET_KIND_UPDATE:
1344 kind = " update";
1345 break;
1346 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1347 kind = " oacc_kernels";
1348 break;
1349 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1350 kind = " oacc_parallel";
1351 break;
1352 case GF_OMP_TARGET_KIND_OACC_DATA:
1353 kind = " oacc_data";
1354 break;
1355 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1356 kind = " oacc_update";
1357 break;
1358 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1359 kind = " oacc_enter_exit_data";
1360 break;
1361 default:
1362 gcc_unreachable ();
1364 if (flags & TDF_RAW)
1366 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1367 kind, gimple_omp_body (gs));
1368 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1369 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1370 gimple_omp_target_child_fn (gs),
1371 gimple_omp_target_data_arg (gs));
1373 else
1375 pp_string (buffer, "#pragma omp target");
1376 pp_string (buffer, kind);
1377 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1378 if (gimple_omp_target_child_fn (gs))
1380 pp_string (buffer, " [child fn: ");
1381 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1382 spc, flags, false);
1383 pp_string (buffer, " (");
1384 if (gimple_omp_target_data_arg (gs))
1385 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1386 spc, flags, false);
1387 else
1388 pp_string (buffer, "???");
1389 pp_string (buffer, ")]");
1391 gimple_seq body = gimple_omp_body (gs);
1392 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1394 newline_and_indent (buffer, spc + 2);
1395 pp_left_brace (buffer);
1396 pp_newline (buffer);
1397 dump_gimple_seq (buffer, body, spc + 4, flags);
1398 newline_and_indent (buffer, spc + 2);
1399 pp_right_brace (buffer);
1401 else if (body)
1403 pp_newline (buffer);
1404 dump_gimple_seq (buffer, body, spc + 2, flags);
1409 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1411 static void
1412 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1413 int flags)
1415 if (flags & TDF_RAW)
1417 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1418 gimple_omp_body (gs));
1419 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1420 dump_gimple_fmt (buffer, spc, flags, " >");
1422 else
1424 pp_string (buffer, "#pragma omp teams");
1425 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1426 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1428 newline_and_indent (buffer, spc + 2);
1429 pp_character (buffer, '{');
1430 pp_newline (buffer);
1431 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1432 newline_and_indent (buffer, spc + 2);
1433 pp_character (buffer, '}');
1438 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1440 static void
1441 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1442 int spc, int flags)
1444 if (flags & TDF_RAW)
1446 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1447 gimple_omp_body (gs));
1448 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1449 dump_gimple_fmt (buffer, spc, flags, " >");
1451 else
1453 pp_string (buffer, "#pragma omp sections");
1454 if (gimple_omp_sections_control (gs))
1456 pp_string (buffer, " <");
1457 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1458 flags, false);
1459 pp_greater (buffer);
1461 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1462 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1464 newline_and_indent (buffer, spc + 2);
1465 pp_left_brace (buffer);
1466 pp_newline (buffer);
1467 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1468 newline_and_indent (buffer, spc + 2);
1469 pp_right_brace (buffer);
1474 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1475 pretty_printer BUFFER. */
1477 static void
1478 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1480 if (flags & TDF_RAW)
1481 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1482 gimple_omp_body (gs));
1483 else
1485 switch (gimple_code (gs))
1487 case GIMPLE_OMP_MASTER:
1488 pp_string (buffer, "#pragma omp master");
1489 break;
1490 case GIMPLE_OMP_TASKGROUP:
1491 pp_string (buffer, "#pragma omp taskgroup");
1492 break;
1493 case GIMPLE_OMP_ORDERED:
1494 pp_string (buffer, "#pragma omp ordered");
1495 break;
1496 case GIMPLE_OMP_SECTION:
1497 pp_string (buffer, "#pragma omp section");
1498 break;
1499 default:
1500 gcc_unreachable ();
1502 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1504 newline_and_indent (buffer, spc + 2);
1505 pp_left_brace (buffer);
1506 pp_newline (buffer);
1507 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1508 newline_and_indent (buffer, spc + 2);
1509 pp_right_brace (buffer);
1514 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1516 static void
1517 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1518 int spc, int flags)
1520 if (flags & TDF_RAW)
1521 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1522 gimple_omp_body (gs));
1523 else
1525 pp_string (buffer, "#pragma omp critical");
1526 if (gimple_omp_critical_name (gs))
1528 pp_string (buffer, " (");
1529 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1530 flags, false);
1531 pp_right_paren (buffer);
1533 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1535 newline_and_indent (buffer, spc + 2);
1536 pp_left_brace (buffer);
1537 pp_newline (buffer);
1538 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1539 newline_and_indent (buffer, spc + 2);
1540 pp_right_brace (buffer);
1545 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1547 static void
1548 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1550 if (flags & TDF_RAW)
1552 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1553 (int) gimple_omp_return_nowait_p (gs));
1554 if (gimple_omp_return_lhs (gs))
1555 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1556 gimple_omp_return_lhs (gs));
1557 else
1558 dump_gimple_fmt (buffer, spc, flags, ">");
1560 else
1562 pp_string (buffer, "#pragma omp return");
1563 if (gimple_omp_return_nowait_p (gs))
1564 pp_string (buffer, "(nowait)");
1565 if (gimple_omp_return_lhs (gs))
1567 pp_string (buffer, " (set ");
1568 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1569 spc, flags, false);
1570 pp_character (buffer, ')');
1575 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1577 static void
1578 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1579 int spc, int flags)
1581 unsigned subcode = gimple_transaction_subcode (gs);
1583 if (flags & TDF_RAW)
1585 dump_gimple_fmt (buffer, spc, flags,
1586 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1587 gs, subcode, gimple_transaction_label (gs),
1588 gimple_transaction_body (gs));
1590 else
1592 if (subcode & GTMA_IS_OUTER)
1593 pp_string (buffer, "__transaction_atomic [[outer]]");
1594 else if (subcode & GTMA_IS_RELAXED)
1595 pp_string (buffer, "__transaction_relaxed");
1596 else
1597 pp_string (buffer, "__transaction_atomic");
1598 subcode &= ~GTMA_DECLARATION_MASK;
1600 if (subcode || gimple_transaction_label (gs))
1602 pp_string (buffer, " //");
1603 if (gimple_transaction_label (gs))
1605 pp_string (buffer, " LABEL=");
1606 dump_generic_node (buffer, gimple_transaction_label (gs),
1607 spc, flags, false);
1609 if (subcode)
1611 pp_string (buffer, " SUBCODE=[ ");
1612 if (subcode & GTMA_HAVE_ABORT)
1614 pp_string (buffer, "GTMA_HAVE_ABORT ");
1615 subcode &= ~GTMA_HAVE_ABORT;
1617 if (subcode & GTMA_HAVE_LOAD)
1619 pp_string (buffer, "GTMA_HAVE_LOAD ");
1620 subcode &= ~GTMA_HAVE_LOAD;
1622 if (subcode & GTMA_HAVE_STORE)
1624 pp_string (buffer, "GTMA_HAVE_STORE ");
1625 subcode &= ~GTMA_HAVE_STORE;
1627 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1629 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1630 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1632 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1634 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1635 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1637 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1639 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1640 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1642 if (subcode)
1643 pp_printf (buffer, "0x%x ", subcode);
1644 pp_right_bracket (buffer);
1648 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1650 newline_and_indent (buffer, spc + 2);
1651 pp_left_brace (buffer);
1652 pp_newline (buffer);
1653 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1654 spc + 4, flags);
1655 newline_and_indent (buffer, spc + 2);
1656 pp_right_brace (buffer);
1661 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1662 indent. FLAGS specifies details to show in the dump (see TDF_* in
1663 dumpfile.h). */
1665 static void
1666 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
1668 unsigned int i, n, f, fields;
1670 if (flags & TDF_RAW)
1672 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1673 gimple_asm_string (gs));
1675 n = gimple_asm_noutputs (gs);
1676 if (n)
1678 newline_and_indent (buffer, spc + 2);
1679 pp_string (buffer, "OUTPUT: ");
1680 for (i = 0; i < n; i++)
1682 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1683 spc, flags, false);
1684 if (i < n - 1)
1685 pp_string (buffer, ", ");
1689 n = gimple_asm_ninputs (gs);
1690 if (n)
1692 newline_and_indent (buffer, spc + 2);
1693 pp_string (buffer, "INPUT: ");
1694 for (i = 0; i < n; i++)
1696 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1697 spc, flags, false);
1698 if (i < n - 1)
1699 pp_string (buffer, ", ");
1703 n = gimple_asm_nclobbers (gs);
1704 if (n)
1706 newline_and_indent (buffer, spc + 2);
1707 pp_string (buffer, "CLOBBER: ");
1708 for (i = 0; i < n; i++)
1710 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1711 spc, flags, false);
1712 if (i < n - 1)
1713 pp_string (buffer, ", ");
1717 n = gimple_asm_nlabels (gs);
1718 if (n)
1720 newline_and_indent (buffer, spc + 2);
1721 pp_string (buffer, "LABEL: ");
1722 for (i = 0; i < n; i++)
1724 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1725 spc, flags, false);
1726 if (i < n - 1)
1727 pp_string (buffer, ", ");
1731 newline_and_indent (buffer, spc);
1732 pp_greater (buffer);
1734 else
1736 pp_string (buffer, "__asm__");
1737 if (gimple_asm_volatile_p (gs))
1738 pp_string (buffer, " __volatile__");
1739 if (gimple_asm_nlabels (gs))
1740 pp_string (buffer, " goto");
1741 pp_string (buffer, "(\"");
1742 pp_string (buffer, gimple_asm_string (gs));
1743 pp_string (buffer, "\"");
1745 if (gimple_asm_nlabels (gs))
1746 fields = 4;
1747 else if (gimple_asm_nclobbers (gs))
1748 fields = 3;
1749 else if (gimple_asm_ninputs (gs))
1750 fields = 2;
1751 else if (gimple_asm_noutputs (gs))
1752 fields = 1;
1753 else
1754 fields = 0;
1756 for (f = 0; f < fields; ++f)
1758 pp_string (buffer, " : ");
1760 switch (f)
1762 case 0:
1763 n = gimple_asm_noutputs (gs);
1764 for (i = 0; i < n; i++)
1766 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1767 spc, flags, false);
1768 if (i < n - 1)
1769 pp_string (buffer, ", ");
1771 break;
1773 case 1:
1774 n = gimple_asm_ninputs (gs);
1775 for (i = 0; i < n; i++)
1777 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1778 spc, flags, false);
1779 if (i < n - 1)
1780 pp_string (buffer, ", ");
1782 break;
1784 case 2:
1785 n = gimple_asm_nclobbers (gs);
1786 for (i = 0; i < n; i++)
1788 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1789 spc, flags, false);
1790 if (i < n - 1)
1791 pp_string (buffer, ", ");
1793 break;
1795 case 3:
1796 n = gimple_asm_nlabels (gs);
1797 for (i = 0; i < n; i++)
1799 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1800 spc, flags, false);
1801 if (i < n - 1)
1802 pp_string (buffer, ", ");
1804 break;
1806 default:
1807 gcc_unreachable ();
1811 pp_string (buffer, ");");
1815 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1816 SPC spaces of indent. */
1818 static void
1819 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1821 if (TREE_CODE (node) != SSA_NAME)
1822 return;
1824 if (POINTER_TYPE_P (TREE_TYPE (node))
1825 && SSA_NAME_PTR_INFO (node))
1827 unsigned int align, misalign;
1828 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1829 pp_string (buffer, "# PT = ");
1830 pp_points_to_solution (buffer, &pi->pt);
1831 newline_and_indent (buffer, spc);
1832 if (get_ptr_info_alignment (pi, &align, &misalign))
1834 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1835 newline_and_indent (buffer, spc);
1839 if (!POINTER_TYPE_P (TREE_TYPE (node))
1840 && SSA_NAME_RANGE_INFO (node))
1842 wide_int min, max, nonzero_bits;
1843 value_range_type range_type = get_range_info (node, &min, &max);
1845 if (range_type == VR_VARYING)
1846 pp_printf (buffer, "# RANGE VR_VARYING");
1847 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1849 pp_printf (buffer, "# RANGE ");
1850 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1851 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
1852 pp_printf (buffer, ", ");
1853 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
1854 pp_printf (buffer, "]");
1856 nonzero_bits = get_nonzero_bits (node);
1857 if (nonzero_bits != -1)
1859 pp_string (buffer, " NONZERO ");
1860 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
1862 newline_and_indent (buffer, spc);
1867 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1868 The caller is responsible for calling pp_flush on BUFFER to finalize
1869 pretty printer. If COMMENT is true, print this after #. */
1871 static void
1872 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
1873 int flags)
1875 size_t i;
1876 tree lhs = gimple_phi_result (phi);
1878 if (flags & TDF_ALIAS)
1879 dump_ssaname_info (buffer, lhs, spc);
1881 if (comment)
1882 pp_string (buffer, "# ");
1884 if (flags & TDF_RAW)
1885 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1886 gimple_phi_result (phi));
1887 else
1889 dump_generic_node (buffer, lhs, spc, flags, false);
1890 pp_string (buffer, " = PHI <");
1892 for (i = 0; i < gimple_phi_num_args (phi); i++)
1894 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1895 dump_location (buffer, gimple_phi_arg_location (phi, i));
1896 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1897 false);
1898 pp_left_paren (buffer);
1899 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1900 pp_right_paren (buffer);
1901 if (i < gimple_phi_num_args (phi) - 1)
1902 pp_string (buffer, ", ");
1904 pp_greater (buffer);
1908 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1909 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1910 dumpfile.h). */
1912 static void
1913 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
1914 int spc, int flags)
1916 if (flags & TDF_RAW)
1918 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1919 gimple_omp_body (gs));
1920 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1921 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1922 gimple_omp_parallel_child_fn (gs),
1923 gimple_omp_parallel_data_arg (gs));
1925 else
1927 gimple_seq body;
1928 pp_string (buffer, "#pragma omp parallel");
1929 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1930 if (gimple_omp_parallel_child_fn (gs))
1932 pp_string (buffer, " [child fn: ");
1933 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1934 spc, flags, false);
1935 pp_string (buffer, " (");
1936 if (gimple_omp_parallel_data_arg (gs))
1937 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1938 spc, flags, false);
1939 else
1940 pp_string (buffer, "???");
1941 pp_string (buffer, ")]");
1943 body = gimple_omp_body (gs);
1944 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1946 newline_and_indent (buffer, spc + 2);
1947 pp_left_brace (buffer);
1948 pp_newline (buffer);
1949 dump_gimple_seq (buffer, body, spc + 4, flags);
1950 newline_and_indent (buffer, spc + 2);
1951 pp_right_brace (buffer);
1953 else if (body)
1955 pp_newline (buffer);
1956 dump_gimple_seq (buffer, body, spc + 2, flags);
1962 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1963 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1964 dumpfile.h). */
1966 static void
1967 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
1968 int flags)
1970 if (flags & TDF_RAW)
1972 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1973 gimple_omp_body (gs));
1974 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1975 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1976 gimple_omp_task_child_fn (gs),
1977 gimple_omp_task_data_arg (gs),
1978 gimple_omp_task_copy_fn (gs),
1979 gimple_omp_task_arg_size (gs),
1980 gimple_omp_task_arg_size (gs));
1982 else
1984 gimple_seq body;
1985 pp_string (buffer, "#pragma omp task");
1986 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1987 if (gimple_omp_task_child_fn (gs))
1989 pp_string (buffer, " [child fn: ");
1990 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1991 spc, flags, false);
1992 pp_string (buffer, " (");
1993 if (gimple_omp_task_data_arg (gs))
1994 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1995 spc, flags, false);
1996 else
1997 pp_string (buffer, "???");
1998 pp_string (buffer, ")]");
2000 body = gimple_omp_body (gs);
2001 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2003 newline_and_indent (buffer, spc + 2);
2004 pp_left_brace (buffer);
2005 pp_newline (buffer);
2006 dump_gimple_seq (buffer, body, spc + 4, flags);
2007 newline_and_indent (buffer, spc + 2);
2008 pp_right_brace (buffer);
2010 else if (body)
2012 pp_newline (buffer);
2013 dump_gimple_seq (buffer, body, spc + 2, flags);
2019 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2020 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2021 in dumpfile.h). */
2023 static void
2024 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2025 int spc, int flags)
2027 if (flags & TDF_RAW)
2029 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2030 gimple_omp_atomic_load_lhs (gs),
2031 gimple_omp_atomic_load_rhs (gs));
2033 else
2035 pp_string (buffer, "#pragma omp atomic_load");
2036 if (gimple_omp_atomic_seq_cst_p (gs))
2037 pp_string (buffer, " seq_cst");
2038 if (gimple_omp_atomic_need_value_p (gs))
2039 pp_string (buffer, " [needed]");
2040 newline_and_indent (buffer, spc + 2);
2041 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2042 spc, flags, false);
2043 pp_space (buffer);
2044 pp_equal (buffer);
2045 pp_space (buffer);
2046 pp_star (buffer);
2047 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2048 spc, flags, false);
2052 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2053 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2054 in dumpfile.h). */
2056 static void
2057 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2058 gomp_atomic_store *gs, int spc, int flags)
2060 if (flags & TDF_RAW)
2062 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2063 gimple_omp_atomic_store_val (gs));
2065 else
2067 pp_string (buffer, "#pragma omp atomic_store ");
2068 if (gimple_omp_atomic_seq_cst_p (gs))
2069 pp_string (buffer, "seq_cst ");
2070 if (gimple_omp_atomic_need_value_p (gs))
2071 pp_string (buffer, "[needed] ");
2072 pp_left_paren (buffer);
2073 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2074 spc, flags, false);
2075 pp_right_paren (buffer);
2080 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2081 FLAGS are as in pp_gimple_stmt_1. */
2083 static void
2084 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
2086 tree vdef = gimple_vdef (gs);
2087 tree vuse = gimple_vuse (gs);
2089 if (vdef != NULL_TREE)
2091 pp_string (buffer, "# ");
2092 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2093 pp_string (buffer, " = VDEF <");
2094 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2095 pp_greater (buffer);
2096 newline_and_indent (buffer, spc);
2098 else if (vuse != NULL_TREE)
2100 pp_string (buffer, "# VUSE <");
2101 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2102 pp_greater (buffer);
2103 newline_and_indent (buffer, spc);
2108 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2109 spaces of indent. FLAGS specifies details to show in the dump (see
2110 TDF_* in dumpfile.h). The caller is responsible for calling
2111 pp_flush on BUFFER to finalize the pretty printer. */
2113 void
2114 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
2116 if (!gs)
2117 return;
2119 if (flags & TDF_STMTADDR)
2120 pp_printf (buffer, "<&%p> ", (void *) gs);
2122 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2123 dump_location (buffer, gimple_location (gs));
2125 if (flags & TDF_EH)
2127 int lp_nr = lookup_stmt_eh_lp (gs);
2128 if (lp_nr > 0)
2129 pp_printf (buffer, "[LP %d] ", lp_nr);
2130 else if (lp_nr < 0)
2131 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2134 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2135 && gimple_has_mem_ops (gs))
2136 dump_gimple_mem_ops (buffer, gs, spc, flags);
2138 if (gimple_has_lhs (gs)
2139 && (flags & TDF_ALIAS))
2140 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2142 switch (gimple_code (gs))
2144 case GIMPLE_ASM:
2145 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2146 break;
2148 case GIMPLE_ASSIGN:
2149 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2150 break;
2152 case GIMPLE_BIND:
2153 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2154 break;
2156 case GIMPLE_CALL:
2157 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2158 break;
2160 case GIMPLE_COND:
2161 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2162 break;
2164 case GIMPLE_LABEL:
2165 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2166 break;
2168 case GIMPLE_GOTO:
2169 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2170 break;
2172 case GIMPLE_NOP:
2173 pp_string (buffer, "GIMPLE_NOP");
2174 break;
2176 case GIMPLE_RETURN:
2177 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2178 break;
2180 case GIMPLE_SWITCH:
2181 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2182 break;
2184 case GIMPLE_TRY:
2185 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2186 break;
2188 case GIMPLE_PHI:
2189 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2190 break;
2192 case GIMPLE_OMP_PARALLEL:
2193 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2194 flags);
2195 break;
2197 case GIMPLE_OMP_TASK:
2198 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2199 break;
2201 case GIMPLE_OMP_ATOMIC_LOAD:
2202 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2203 spc, flags);
2204 break;
2206 case GIMPLE_OMP_ATOMIC_STORE:
2207 dump_gimple_omp_atomic_store (buffer,
2208 as_a <gomp_atomic_store *> (gs),
2209 spc, flags);
2210 break;
2212 case GIMPLE_OMP_FOR:
2213 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2214 break;
2216 case GIMPLE_OMP_CONTINUE:
2217 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2218 flags);
2219 break;
2221 case GIMPLE_OMP_SINGLE:
2222 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2223 flags);
2224 break;
2226 case GIMPLE_OMP_TARGET:
2227 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2228 flags);
2229 break;
2231 case GIMPLE_OMP_TEAMS:
2232 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2233 flags);
2234 break;
2236 case GIMPLE_OMP_RETURN:
2237 dump_gimple_omp_return (buffer, gs, spc, flags);
2238 break;
2240 case GIMPLE_OMP_SECTIONS:
2241 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2242 spc, flags);
2243 break;
2245 case GIMPLE_OMP_SECTIONS_SWITCH:
2246 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2247 break;
2249 case GIMPLE_OMP_MASTER:
2250 case GIMPLE_OMP_TASKGROUP:
2251 case GIMPLE_OMP_ORDERED:
2252 case GIMPLE_OMP_SECTION:
2253 dump_gimple_omp_block (buffer, gs, spc, flags);
2254 break;
2256 case GIMPLE_OMP_CRITICAL:
2257 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2258 flags);
2259 break;
2261 case GIMPLE_CATCH:
2262 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2263 break;
2265 case GIMPLE_EH_FILTER:
2266 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2267 break;
2269 case GIMPLE_EH_MUST_NOT_THROW:
2270 dump_gimple_eh_must_not_throw (buffer,
2271 as_a <geh_mnt *> (gs),
2272 spc, flags);
2273 break;
2275 case GIMPLE_EH_ELSE:
2276 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2277 break;
2279 case GIMPLE_RESX:
2280 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2281 break;
2283 case GIMPLE_EH_DISPATCH:
2284 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2285 flags);
2286 break;
2288 case GIMPLE_DEBUG:
2289 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2290 break;
2292 case GIMPLE_PREDICT:
2293 pp_string (buffer, "// predicted ");
2294 if (gimple_predict_outcome (gs))
2295 pp_string (buffer, "likely by ");
2296 else
2297 pp_string (buffer, "unlikely by ");
2298 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2299 pp_string (buffer, " predictor.");
2300 break;
2302 case GIMPLE_TRANSACTION:
2303 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2304 flags);
2305 break;
2307 default:
2308 GIMPLE_NIY;
2313 /* Dumps header of basic block BB to OUTF indented by INDENT
2314 spaces and details described by flags. */
2316 static void
2317 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2319 if (flags & TDF_BLOCKS)
2321 if (flags & TDF_LINENO)
2323 gimple_stmt_iterator gsi;
2325 if (flags & TDF_COMMENT)
2326 fputs (";; ", outf);
2328 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2329 if (!is_gimple_debug (gsi_stmt (gsi))
2330 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2332 fprintf (outf, "%*sstarting at line %d",
2333 indent, "", get_lineno (gsi_stmt (gsi)));
2334 break;
2336 if (bb->discriminator)
2337 fprintf (outf, ", discriminator %i", bb->discriminator);
2338 fputc ('\n', outf);
2341 else
2343 gimple stmt = first_stmt (bb);
2344 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2345 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2350 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2351 spaces. */
2353 static void
2354 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2355 basic_block bb ATTRIBUTE_UNUSED,
2356 int indent ATTRIBUTE_UNUSED,
2357 int flags ATTRIBUTE_UNUSED)
2359 /* There is currently no GIMPLE-specific basic block info to dump. */
2360 return;
2364 /* Dump PHI nodes of basic block BB to BUFFER with details described
2365 by FLAGS and indented by INDENT spaces. */
2367 static void
2368 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2370 gphi_iterator i;
2372 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2374 gphi *phi = i.phi ();
2375 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2377 INDENT (indent);
2378 dump_gimple_phi (buffer, phi, indent, true, flags);
2379 pp_newline (buffer);
2385 /* Dump jump to basic block BB that is represented implicitly in the cfg
2386 to BUFFER. */
2388 static void
2389 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2391 gimple stmt;
2393 stmt = first_stmt (bb);
2395 pp_string (buffer, "goto <bb ");
2396 pp_decimal_int (buffer, bb->index);
2397 pp_greater (buffer);
2398 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2400 pp_string (buffer, " (");
2401 dump_generic_node (buffer,
2402 gimple_label_label (as_a <glabel *> (stmt)),
2403 0, 0, false);
2404 pp_right_paren (buffer);
2405 pp_semicolon (buffer);
2407 else
2408 pp_semicolon (buffer);
2412 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2413 by INDENT spaces, with details given by FLAGS. */
2415 static void
2416 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2417 int flags)
2419 edge e;
2420 gimple stmt;
2422 stmt = last_stmt (bb);
2424 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2426 edge true_edge, false_edge;
2428 /* When we are emitting the code or changing CFG, it is possible that
2429 the edges are not yet created. When we are using debug_bb in such
2430 a situation, we do not want it to crash. */
2431 if (EDGE_COUNT (bb->succs) != 2)
2432 return;
2433 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2435 INDENT (indent + 2);
2436 pp_cfg_jump (buffer, true_edge->dest);
2437 newline_and_indent (buffer, indent);
2438 pp_string (buffer, "else");
2439 newline_and_indent (buffer, indent + 2);
2440 pp_cfg_jump (buffer, false_edge->dest);
2441 pp_newline (buffer);
2442 return;
2445 /* If there is a fallthru edge, we may need to add an artificial
2446 goto to the dump. */
2447 e = find_fallthru_edge (bb->succs);
2449 if (e && e->dest != bb->next_bb)
2451 INDENT (indent);
2453 if ((flags & TDF_LINENO)
2454 && e->goto_locus != UNKNOWN_LOCATION)
2455 dump_location (buffer, e->goto_locus);
2457 pp_cfg_jump (buffer, e->dest);
2458 pp_newline (buffer);
2463 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2464 indented by INDENT spaces. */
2466 static void
2467 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2468 int flags)
2470 gimple_stmt_iterator gsi;
2471 gimple stmt;
2472 int label_indent = indent - 2;
2474 if (label_indent < 0)
2475 label_indent = 0;
2477 dump_phi_nodes (buffer, bb, indent, flags);
2479 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2481 int curr_indent;
2483 stmt = gsi_stmt (gsi);
2485 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2487 INDENT (curr_indent);
2488 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2489 pp_newline_and_flush (buffer);
2490 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2491 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2492 pp_buffer (buffer)->stream, stmt);
2495 dump_implicit_edges (buffer, bb, indent, flags);
2496 pp_flush (buffer);
2500 /* Dumps basic block BB to FILE with details described by FLAGS and
2501 indented by INDENT spaces. */
2503 void
2504 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2506 dump_gimple_bb_header (file, bb, indent, flags);
2507 if (bb->index >= NUM_FIXED_BLOCKS)
2509 pretty_printer buffer;
2510 pp_needs_newline (&buffer) = true;
2511 buffer.buffer->stream = file;
2512 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2514 dump_gimple_bb_footer (file, bb, indent, flags);
2517 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2518 no indentation, for use as a label of a DOT graph record-node.
2519 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2520 histogram dumping doesn't know about pretty-printers. */
2522 void
2523 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2525 pp_printf (pp, "<bb %d>:\n", bb->index);
2526 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2528 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2529 gsi_next (&gsi))
2531 gphi *phi = gsi.phi ();
2532 if (!virtual_operand_p (gimple_phi_result (phi))
2533 || (dump_flags & TDF_VOPS))
2535 pp_bar (pp);
2536 pp_write_text_to_stream (pp);
2537 pp_string (pp, "# ");
2538 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2539 pp_newline (pp);
2540 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2544 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2545 gsi_next (&gsi))
2547 gimple stmt = gsi_stmt (gsi);
2548 pp_bar (pp);
2549 pp_write_text_to_stream (pp);
2550 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2551 pp_newline (pp);
2552 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2554 dump_implicit_edges (pp, bb, 0, dump_flags);
2555 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);