[AArch64] PR target/65491: Classify V1TF vectors as AAPCS64 short vectors rather...
[official-gcc.git] / gcc / gimple-pretty-print.c
blob2f9671f163bc1c0e95780e34b31cc26d18ac3414
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 "hash-set.h"
27 #include "machmode.h"
28 #include "vec.h"
29 #include "double-int.h"
30 #include "input.h"
31 #include "alias.h"
32 #include "symtab.h"
33 #include "wide-int.h"
34 #include "inchash.h"
35 #include "tree.h"
36 #include "fold-const.h"
37 #include "stringpool.h"
38 #include "diagnostic.h"
39 #include "gimple-pretty-print.h"
40 #include "bitmap.h"
41 #include "predict.h"
42 #include "hard-reg-set.h"
43 #include "input.h"
44 #include "function.h"
45 #include "basic-block.h"
46 #include "tree-ssa-alias.h"
47 #include "internal-fn.h"
48 #include "tree-eh.h"
49 #include "gimple-expr.h"
50 #include "is-a.h"
51 #include "gimple.h"
52 #include "gimple-iterator.h"
53 #include "gimple-ssa.h"
54 #include "hash-map.h"
55 #include "plugin-api.h"
56 #include "ipa-ref.h"
57 #include "cgraph.h"
58 #include "tree-cfg.h"
59 #include "tree-ssanames.h"
60 #include "dumpfile.h" /* for dump_flags */
61 #include "value-prof.h"
62 #include "trans-mem.h"
64 #define INDENT(SPACE) \
65 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
67 #define GIMPLE_NIY do_niy (buffer,gs)
69 /* Try to print on BUFFER a default message for the unrecognized
70 gimple statement GS. */
72 static void
73 do_niy (pretty_printer *buffer, gimple gs)
75 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
76 gimple_code_name[(int) gimple_code (gs)]);
80 /* Emit a newline and SPC indentation spaces to BUFFER. */
82 static void
83 newline_and_indent (pretty_printer *buffer, int spc)
85 pp_newline (buffer);
86 INDENT (spc);
90 /* Print the GIMPLE statement GS on stderr. */
92 DEBUG_FUNCTION void
93 debug_gimple_stmt (gimple gs)
95 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
99 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
100 FLAGS as in pp_gimple_stmt_1. */
102 void
103 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
105 pretty_printer buffer;
106 pp_needs_newline (&buffer) = true;
107 buffer.buffer->stream = file;
108 pp_gimple_stmt_1 (&buffer, g, spc, flags);
109 pp_newline_and_flush (&buffer);
112 DEBUG_FUNCTION void
113 debug (gimple_statement_base &ref)
115 print_gimple_stmt (stderr, &ref, 0, 0);
118 DEBUG_FUNCTION void
119 debug (gimple_statement_base *ptr)
121 if (ptr)
122 debug (*ptr);
123 else
124 fprintf (stderr, "<nil>\n");
128 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
129 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
130 of the statement. */
132 void
133 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
135 flags |= TDF_RHS_ONLY;
136 pretty_printer buffer;
137 pp_needs_newline (&buffer) = true;
138 buffer.buffer->stream = file;
139 pp_gimple_stmt_1 (&buffer, g, spc, flags);
140 pp_flush (&buffer);
144 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
145 spaces and FLAGS as in pp_gimple_stmt_1.
146 The caller is responsible for calling pp_flush on BUFFER to finalize
147 the pretty printer. */
149 static void
150 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
152 gimple_stmt_iterator i;
154 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
156 gimple gs = gsi_stmt (i);
157 INDENT (spc);
158 pp_gimple_stmt_1 (buffer, gs, spc, flags);
159 if (!gsi_one_before_end_p (i))
160 pp_newline (buffer);
165 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
166 FLAGS as in pp_gimple_stmt_1. */
168 void
169 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
171 pretty_printer buffer;
172 pp_needs_newline (&buffer) = true;
173 buffer.buffer->stream = file;
174 dump_gimple_seq (&buffer, seq, spc, flags);
175 pp_newline_and_flush (&buffer);
179 /* Print the GIMPLE sequence SEQ on stderr. */
181 DEBUG_FUNCTION void
182 debug_gimple_seq (gimple_seq seq)
184 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
188 /* A simple helper to pretty-print some of the gimple tuples in the printf
189 style. The format modifiers are preceded by '%' and are:
190 'G' - outputs a string corresponding to the code of the given gimple,
191 'S' - outputs a gimple_seq with indent of spc + 2,
192 'T' - outputs the tree t,
193 'd' - outputs an int as a decimal,
194 's' - outputs a string,
195 'n' - outputs a newline,
196 'x' - outputs an int as hexadecimal,
197 '+' - increases indent by 2 then outputs a newline,
198 '-' - decreases indent by 2 then outputs a newline. */
200 static void
201 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
202 const char *fmt, ...)
204 va_list args;
205 const char *c;
206 const char *tmp;
208 va_start (args, fmt);
209 for (c = fmt; *c; c++)
211 if (*c == '%')
213 gimple_seq seq;
214 tree t;
215 gimple g;
216 switch (*++c)
218 case 'G':
219 g = va_arg (args, gimple);
220 tmp = gimple_code_name[gimple_code (g)];
221 pp_string (buffer, tmp);
222 break;
224 case 'S':
225 seq = va_arg (args, gimple_seq);
226 pp_newline (buffer);
227 dump_gimple_seq (buffer, seq, spc + 2, flags);
228 newline_and_indent (buffer, spc);
229 break;
231 case 'T':
232 t = va_arg (args, tree);
233 if (t == NULL_TREE)
234 pp_string (buffer, "NULL");
235 else
236 dump_generic_node (buffer, t, spc, flags, false);
237 break;
239 case 'd':
240 pp_decimal_int (buffer, va_arg (args, int));
241 break;
243 case 's':
244 pp_string (buffer, va_arg (args, char *));
245 break;
247 case 'n':
248 newline_and_indent (buffer, spc);
249 break;
251 case 'x':
252 pp_scalar (buffer, "%x", va_arg (args, int));
253 break;
255 case '+':
256 spc += 2;
257 newline_and_indent (buffer, spc);
258 break;
260 case '-':
261 spc -= 2;
262 newline_and_indent (buffer, spc);
263 break;
265 default:
266 gcc_unreachable ();
269 else
270 pp_character (buffer, *c);
272 va_end (args);
276 /* Helper for dump_gimple_assign. Print the unary RHS of the
277 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
279 static void
280 dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
282 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
283 tree lhs = gimple_assign_lhs (gs);
284 tree rhs = gimple_assign_rhs1 (gs);
286 switch (rhs_code)
288 case VIEW_CONVERT_EXPR:
289 case ASSERT_EXPR:
290 dump_generic_node (buffer, rhs, spc, flags, false);
291 break;
293 case FIXED_CONVERT_EXPR:
294 case ADDR_SPACE_CONVERT_EXPR:
295 case FIX_TRUNC_EXPR:
296 case FLOAT_EXPR:
297 CASE_CONVERT:
298 pp_left_paren (buffer);
299 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
300 pp_string (buffer, ") ");
301 if (op_prio (rhs) < op_code_prio (rhs_code))
303 pp_left_paren (buffer);
304 dump_generic_node (buffer, rhs, spc, flags, false);
305 pp_right_paren (buffer);
307 else
308 dump_generic_node (buffer, rhs, spc, flags, false);
309 break;
311 case PAREN_EXPR:
312 pp_string (buffer, "((");
313 dump_generic_node (buffer, rhs, spc, flags, false);
314 pp_string (buffer, "))");
315 break;
317 case ABS_EXPR:
318 pp_string (buffer, "ABS_EXPR <");
319 dump_generic_node (buffer, rhs, spc, flags, false);
320 pp_greater (buffer);
321 break;
323 default:
324 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
325 || TREE_CODE_CLASS (rhs_code) == tcc_constant
326 || TREE_CODE_CLASS (rhs_code) == tcc_reference
327 || rhs_code == SSA_NAME
328 || rhs_code == ADDR_EXPR
329 || rhs_code == CONSTRUCTOR)
331 dump_generic_node (buffer, rhs, spc, flags, false);
332 break;
334 else if (rhs_code == BIT_NOT_EXPR)
335 pp_complement (buffer);
336 else if (rhs_code == TRUTH_NOT_EXPR)
337 pp_exclamation (buffer);
338 else if (rhs_code == NEGATE_EXPR)
339 pp_minus (buffer);
340 else
342 pp_left_bracket (buffer);
343 pp_string (buffer, get_tree_code_name (rhs_code));
344 pp_string (buffer, "] ");
347 if (op_prio (rhs) < op_code_prio (rhs_code))
349 pp_left_paren (buffer);
350 dump_generic_node (buffer, rhs, spc, flags, false);
351 pp_right_paren (buffer);
353 else
354 dump_generic_node (buffer, rhs, spc, flags, false);
355 break;
360 /* Helper for dump_gimple_assign. Print the binary RHS of the
361 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
363 static void
364 dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
366 const char *p;
367 enum tree_code code = gimple_assign_rhs_code (gs);
368 switch (code)
370 case COMPLEX_EXPR:
371 case MIN_EXPR:
372 case MAX_EXPR:
373 case VEC_WIDEN_MULT_HI_EXPR:
374 case VEC_WIDEN_MULT_LO_EXPR:
375 case VEC_WIDEN_MULT_EVEN_EXPR:
376 case VEC_WIDEN_MULT_ODD_EXPR:
377 case VEC_PACK_TRUNC_EXPR:
378 case VEC_PACK_SAT_EXPR:
379 case VEC_PACK_FIX_TRUNC_EXPR:
380 case VEC_WIDEN_LSHIFT_HI_EXPR:
381 case VEC_WIDEN_LSHIFT_LO_EXPR:
382 for (p = get_tree_code_name (code); *p; p++)
383 pp_character (buffer, TOUPPER (*p));
384 pp_string (buffer, " <");
385 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
386 pp_string (buffer, ", ");
387 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
388 pp_greater (buffer);
389 break;
391 default:
392 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
394 pp_left_paren (buffer);
395 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
396 false);
397 pp_right_paren (buffer);
399 else
400 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
401 pp_space (buffer);
402 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
403 pp_space (buffer);
404 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
406 pp_left_paren (buffer);
407 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
408 false);
409 pp_right_paren (buffer);
411 else
412 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
416 /* Helper for dump_gimple_assign. Print the ternary RHS of the
417 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
419 static void
420 dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
422 const char *p;
423 enum tree_code code = gimple_assign_rhs_code (gs);
424 switch (code)
426 case WIDEN_MULT_PLUS_EXPR:
427 case WIDEN_MULT_MINUS_EXPR:
428 for (p = get_tree_code_name (code); *p; p++)
429 pp_character (buffer, TOUPPER (*p));
430 pp_string (buffer, " <");
431 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
432 pp_string (buffer, ", ");
433 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
434 pp_string (buffer, ", ");
435 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
436 pp_greater (buffer);
437 break;
439 case FMA_EXPR:
440 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
441 pp_string (buffer, " * ");
442 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
443 pp_string (buffer, " + ");
444 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
445 break;
447 case DOT_PROD_EXPR:
448 pp_string (buffer, "DOT_PROD_EXPR <");
449 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
450 pp_string (buffer, ", ");
451 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
452 pp_string (buffer, ", ");
453 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
454 pp_greater (buffer);
455 break;
457 case SAD_EXPR:
458 pp_string (buffer, "SAD_EXPR <");
459 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
460 pp_string (buffer, ", ");
461 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
462 pp_string (buffer, ", ");
463 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
464 pp_greater (buffer);
465 break;
467 case VEC_PERM_EXPR:
468 pp_string (buffer, "VEC_PERM_EXPR <");
469 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
470 pp_string (buffer, ", ");
471 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
472 pp_string (buffer, ", ");
473 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
474 pp_greater (buffer);
475 break;
477 case REALIGN_LOAD_EXPR:
478 pp_string (buffer, "REALIGN_LOAD <");
479 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
480 pp_string (buffer, ", ");
481 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
482 pp_string (buffer, ", ");
483 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
484 pp_greater (buffer);
485 break;
487 case COND_EXPR:
488 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
489 pp_string (buffer, " ? ");
490 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
491 pp_string (buffer, " : ");
492 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
493 break;
495 case VEC_COND_EXPR:
496 pp_string (buffer, "VEC_COND_EXPR <");
497 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
498 pp_string (buffer, ", ");
499 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
500 pp_string (buffer, ", ");
501 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
502 pp_greater (buffer);
503 break;
505 default:
506 gcc_unreachable ();
511 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
512 pp_gimple_stmt_1. */
514 static void
515 dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
517 if (flags & TDF_RAW)
519 tree arg1 = NULL;
520 tree arg2 = NULL;
521 tree arg3 = NULL;
522 switch (gimple_num_ops (gs))
524 case 4:
525 arg3 = gimple_assign_rhs3 (gs);
526 case 3:
527 arg2 = gimple_assign_rhs2 (gs);
528 case 2:
529 arg1 = gimple_assign_rhs1 (gs);
530 break;
531 default:
532 gcc_unreachable ();
535 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
536 get_tree_code_name (gimple_assign_rhs_code (gs)),
537 gimple_assign_lhs (gs), arg1, arg2, arg3);
539 else
541 if (!(flags & TDF_RHS_ONLY))
543 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
544 pp_space (buffer);
545 pp_equal (buffer);
547 if (gimple_assign_nontemporal_move_p (gs))
548 pp_string (buffer, "{nt}");
550 if (gimple_has_volatile_ops (gs))
551 pp_string (buffer, "{v}");
553 pp_space (buffer);
556 if (gimple_num_ops (gs) == 2)
557 dump_unary_rhs (buffer, gs, spc, flags);
558 else if (gimple_num_ops (gs) == 3)
559 dump_binary_rhs (buffer, gs, spc, flags);
560 else if (gimple_num_ops (gs) == 4)
561 dump_ternary_rhs (buffer, gs, spc, flags);
562 else
563 gcc_unreachable ();
564 if (!(flags & TDF_RHS_ONLY))
565 pp_semicolon (buffer);
570 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
571 pp_gimple_stmt_1. */
573 static void
574 dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
576 tree t, t2;
578 t = gimple_return_retval (gs);
579 t2 = gimple_return_retbnd (gs);
580 if (flags & TDF_RAW)
581 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
582 else
584 pp_string (buffer, "return");
585 if (t)
587 pp_space (buffer);
588 dump_generic_node (buffer, t, spc, flags, false);
590 if (t2)
592 pp_string (buffer, ", ");
593 dump_generic_node (buffer, t2, spc, flags, false);
595 pp_semicolon (buffer);
600 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
601 dump_gimple_call. */
603 static void
604 dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
606 size_t i;
608 for (i = 0; i < gimple_call_num_args (gs); i++)
610 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
611 if (i < gimple_call_num_args (gs) - 1)
612 pp_string (buffer, ", ");
615 if (gimple_call_va_arg_pack_p (gs))
617 if (gimple_call_num_args (gs) > 0)
619 pp_comma (buffer);
620 pp_space (buffer);
623 pp_string (buffer, "__builtin_va_arg_pack ()");
627 /* Dump the points-to solution *PT to BUFFER. */
629 static void
630 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
632 if (pt->anything)
634 pp_string (buffer, "anything ");
635 return;
637 if (pt->nonlocal)
638 pp_string (buffer, "nonlocal ");
639 if (pt->escaped)
640 pp_string (buffer, "escaped ");
641 if (pt->ipa_escaped)
642 pp_string (buffer, "unit-escaped ");
643 if (pt->null)
644 pp_string (buffer, "null ");
645 if (pt->vars
646 && !bitmap_empty_p (pt->vars))
648 bitmap_iterator bi;
649 unsigned i;
650 pp_string (buffer, "{ ");
651 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
653 pp_string (buffer, "D.");
654 pp_decimal_int (buffer, i);
655 pp_space (buffer);
657 pp_right_brace (buffer);
658 if (pt->vars_contains_nonlocal
659 && pt->vars_contains_escaped_heap)
660 pp_string (buffer, " (nonlocal, escaped heap)");
661 else if (pt->vars_contains_nonlocal
662 && pt->vars_contains_escaped)
663 pp_string (buffer, " (nonlocal, escaped)");
664 else if (pt->vars_contains_nonlocal)
665 pp_string (buffer, " (nonlocal)");
666 else if (pt->vars_contains_escaped_heap)
667 pp_string (buffer, " (escaped heap)");
668 else if (pt->vars_contains_escaped)
669 pp_string (buffer, " (escaped)");
673 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
674 pp_gimple_stmt_1. */
676 static void
677 dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
679 tree lhs = gimple_call_lhs (gs);
680 tree fn = gimple_call_fn (gs);
682 if (flags & TDF_ALIAS)
684 struct pt_solution *pt;
685 pt = gimple_call_use_set (gs);
686 if (!pt_solution_empty_p (pt))
688 pp_string (buffer, "# USE = ");
689 pp_points_to_solution (buffer, pt);
690 newline_and_indent (buffer, spc);
692 pt = gimple_call_clobber_set (gs);
693 if (!pt_solution_empty_p (pt))
695 pp_string (buffer, "# CLB = ");
696 pp_points_to_solution (buffer, pt);
697 newline_and_indent (buffer, spc);
701 if (flags & TDF_RAW)
703 if (gimple_call_internal_p (gs))
704 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
705 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
706 else
707 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
708 if (gimple_call_num_args (gs) > 0)
710 pp_string (buffer, ", ");
711 dump_gimple_call_args (buffer, gs, flags);
713 pp_greater (buffer);
715 else
717 if (lhs && !(flags & TDF_RHS_ONLY))
719 dump_generic_node (buffer, lhs, spc, flags, false);
720 pp_string (buffer, " =");
722 if (gimple_has_volatile_ops (gs))
723 pp_string (buffer, "{v}");
725 pp_space (buffer);
727 if (gimple_call_internal_p (gs))
728 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
729 else
730 print_call_name (buffer, fn, flags);
731 pp_string (buffer, " (");
732 dump_gimple_call_args (buffer, gs, flags);
733 pp_right_paren (buffer);
734 if (!(flags & TDF_RHS_ONLY))
735 pp_semicolon (buffer);
738 if (gimple_call_chain (gs))
740 pp_string (buffer, " [static-chain: ");
741 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
742 pp_right_bracket (buffer);
745 if (gimple_call_return_slot_opt_p (gs))
746 pp_string (buffer, " [return slot optimization]");
747 if (gimple_call_tail_p (gs))
748 pp_string (buffer, " [tail call]");
750 if (fn == NULL)
751 return;
753 /* Dump the arguments of _ITM_beginTransaction sanely. */
754 if (TREE_CODE (fn) == ADDR_EXPR)
755 fn = TREE_OPERAND (fn, 0);
756 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
757 pp_string (buffer, " [tm-clone]");
758 if (TREE_CODE (fn) == FUNCTION_DECL
759 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
760 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
761 && gimple_call_num_args (gs) > 0)
763 tree t = gimple_call_arg (gs, 0);
764 unsigned HOST_WIDE_INT props;
765 gcc_assert (TREE_CODE (t) == INTEGER_CST);
767 pp_string (buffer, " [ ");
769 /* Get the transaction code properties. */
770 props = TREE_INT_CST_LOW (t);
772 if (props & PR_INSTRUMENTEDCODE)
773 pp_string (buffer, "instrumentedCode ");
774 if (props & PR_UNINSTRUMENTEDCODE)
775 pp_string (buffer, "uninstrumentedCode ");
776 if (props & PR_HASNOXMMUPDATE)
777 pp_string (buffer, "hasNoXMMUpdate ");
778 if (props & PR_HASNOABORT)
779 pp_string (buffer, "hasNoAbort ");
780 if (props & PR_HASNOIRREVOCABLE)
781 pp_string (buffer, "hasNoIrrevocable ");
782 if (props & PR_DOESGOIRREVOCABLE)
783 pp_string (buffer, "doesGoIrrevocable ");
784 if (props & PR_HASNOSIMPLEREADS)
785 pp_string (buffer, "hasNoSimpleReads ");
786 if (props & PR_AWBARRIERSOMITTED)
787 pp_string (buffer, "awBarriersOmitted ");
788 if (props & PR_RARBARRIERSOMITTED)
789 pp_string (buffer, "RaRBarriersOmitted ");
790 if (props & PR_UNDOLOGCODE)
791 pp_string (buffer, "undoLogCode ");
792 if (props & PR_PREFERUNINSTRUMENTED)
793 pp_string (buffer, "preferUninstrumented ");
794 if (props & PR_EXCEPTIONBLOCK)
795 pp_string (buffer, "exceptionBlock ");
796 if (props & PR_HASELSE)
797 pp_string (buffer, "hasElse ");
798 if (props & PR_READONLY)
799 pp_string (buffer, "readOnly ");
801 pp_right_bracket (buffer);
806 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
807 pp_gimple_stmt_1. */
809 static void
810 dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
811 int flags)
813 unsigned int i;
815 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
816 if (flags & TDF_RAW)
817 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
818 gimple_switch_index (gs));
819 else
821 pp_string (buffer, "switch (");
822 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
823 pp_string (buffer, ") <");
826 for (i = 0; i < gimple_switch_num_labels (gs); i++)
828 tree case_label = gimple_switch_label (gs, i);
829 gcc_checking_assert (case_label != NULL_TREE);
830 dump_generic_node (buffer, case_label, spc, flags, false);
831 pp_space (buffer);
832 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
833 if (i < gimple_switch_num_labels (gs) - 1)
834 pp_string (buffer, ", ");
836 pp_greater (buffer);
840 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
841 pp_gimple_stmt_1. */
843 static void
844 dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
846 if (flags & TDF_RAW)
847 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
848 get_tree_code_name (gimple_cond_code (gs)),
849 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
850 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
851 else
853 if (!(flags & TDF_RHS_ONLY))
854 pp_string (buffer, "if (");
855 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
856 pp_space (buffer);
857 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
858 pp_space (buffer);
859 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
860 if (!(flags & TDF_RHS_ONLY))
862 pp_right_paren (buffer);
864 if (gimple_cond_true_label (gs))
866 pp_string (buffer, " goto ");
867 dump_generic_node (buffer, gimple_cond_true_label (gs),
868 spc, flags, false);
869 pp_semicolon (buffer);
871 if (gimple_cond_false_label (gs))
873 pp_string (buffer, " else goto ");
874 dump_generic_node (buffer, gimple_cond_false_label (gs),
875 spc, flags, false);
876 pp_semicolon (buffer);
883 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
884 spaces of indent. FLAGS specifies details to show in the dump (see
885 TDF_* in dumpfils.h). */
887 static void
888 dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
890 tree label = gimple_label_label (gs);
891 if (flags & TDF_RAW)
892 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
893 else
895 dump_generic_node (buffer, label, spc, flags, false);
896 pp_colon (buffer);
898 if (DECL_NONLOCAL (label))
899 pp_string (buffer, " [non-local]");
900 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
901 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
904 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
905 spaces of indent. FLAGS specifies details to show in the dump (see
906 TDF_* in dumpfile.h). */
908 static void
909 dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
911 tree label = gimple_goto_dest (gs);
912 if (flags & TDF_RAW)
913 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
914 else
915 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
919 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
920 spaces of indent. FLAGS specifies details to show in the dump (see
921 TDF_* in dumpfile.h). */
923 static void
924 dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
926 if (flags & TDF_RAW)
927 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
928 else
929 pp_left_brace (buffer);
930 if (!(flags & TDF_SLIM))
932 tree var;
934 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
936 newline_and_indent (buffer, 2);
937 print_declaration (buffer, var, spc, flags);
939 if (gimple_bind_vars (gs))
940 pp_newline (buffer);
942 pp_newline (buffer);
943 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
944 newline_and_indent (buffer, spc);
945 if (flags & TDF_RAW)
946 pp_greater (buffer);
947 else
948 pp_right_brace (buffer);
952 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
953 indent. FLAGS specifies details to show in the dump (see TDF_* in
954 dumpfile.h). */
956 static void
957 dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
959 if (flags & TDF_RAW)
961 const char *type;
962 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
963 type = "GIMPLE_TRY_CATCH";
964 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
965 type = "GIMPLE_TRY_FINALLY";
966 else
967 type = "UNKNOWN GIMPLE_TRY";
968 dump_gimple_fmt (buffer, spc, flags,
969 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
970 gimple_try_eval (gs), gimple_try_cleanup (gs));
972 else
974 pp_string (buffer, "try");
975 newline_and_indent (buffer, spc + 2);
976 pp_left_brace (buffer);
977 pp_newline (buffer);
979 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
980 newline_and_indent (buffer, spc + 2);
981 pp_right_brace (buffer);
983 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
985 newline_and_indent (buffer, spc);
986 pp_string (buffer, "catch");
987 newline_and_indent (buffer, spc + 2);
988 pp_left_brace (buffer);
990 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
992 newline_and_indent (buffer, spc);
993 pp_string (buffer, "finally");
994 newline_and_indent (buffer, spc + 2);
995 pp_left_brace (buffer);
997 else
998 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1000 pp_newline (buffer);
1001 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1002 newline_and_indent (buffer, spc + 2);
1003 pp_right_brace (buffer);
1008 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1009 indent. FLAGS specifies details to show in the dump (see TDF_* in
1010 dumpfile.h). */
1012 static void
1013 dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
1015 if (flags & TDF_RAW)
1016 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1017 gimple_catch_types (gs), gimple_catch_handler (gs));
1018 else
1019 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1020 gimple_catch_types (gs), gimple_catch_handler (gs));
1024 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1025 indent. FLAGS specifies details to show in the dump (see TDF_* in
1026 dumpfile.h). */
1028 static void
1029 dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
1030 int flags)
1032 if (flags & TDF_RAW)
1033 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1034 gimple_eh_filter_types (gs),
1035 gimple_eh_filter_failure (gs));
1036 else
1037 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1038 gimple_eh_filter_types (gs),
1039 gimple_eh_filter_failure (gs));
1043 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1045 static void
1046 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
1047 geh_mnt *gs, int spc, int flags)
1049 if (flags & TDF_RAW)
1050 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1051 gimple_eh_must_not_throw_fndecl (gs));
1052 else
1053 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1054 gimple_eh_must_not_throw_fndecl (gs));
1058 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1059 indent. FLAGS specifies details to show in the dump (see TDF_* in
1060 dumpfile.h). */
1062 static void
1063 dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
1064 int flags)
1066 if (flags & TDF_RAW)
1067 dump_gimple_fmt (buffer, spc, flags,
1068 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1069 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1070 else
1071 dump_gimple_fmt (buffer, spc, flags,
1072 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1073 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1077 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1078 indent. FLAGS specifies details to show in the dump (see TDF_* in
1079 dumpfile.h). */
1081 static void
1082 dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
1084 if (flags & TDF_RAW)
1085 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1086 gimple_resx_region (gs));
1087 else
1088 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1091 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1093 static void
1094 dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int flags)
1096 if (flags & TDF_RAW)
1097 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1098 gimple_eh_dispatch_region (gs));
1099 else
1100 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1101 gimple_eh_dispatch_region (gs));
1104 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1105 of indent. FLAGS specifies details to show in the dump (see TDF_*
1106 in dumpfile.h). */
1108 static void
1109 dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
1111 switch (gs->subcode)
1113 case GIMPLE_DEBUG_BIND:
1114 if (flags & TDF_RAW)
1115 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1116 gimple_debug_bind_get_var (gs),
1117 gimple_debug_bind_get_value (gs));
1118 else
1119 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1120 gimple_debug_bind_get_var (gs),
1121 gimple_debug_bind_get_value (gs));
1122 break;
1124 case GIMPLE_DEBUG_SOURCE_BIND:
1125 if (flags & TDF_RAW)
1126 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1127 gimple_debug_source_bind_get_var (gs),
1128 gimple_debug_source_bind_get_value (gs));
1129 else
1130 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1131 gimple_debug_source_bind_get_var (gs),
1132 gimple_debug_source_bind_get_value (gs));
1133 break;
1135 default:
1136 gcc_unreachable ();
1140 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1141 static void
1142 dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
1144 size_t i;
1146 if (flags & TDF_RAW)
1148 const char *kind;
1149 switch (gimple_omp_for_kind (gs))
1151 case GF_OMP_FOR_KIND_FOR:
1152 kind = "";
1153 break;
1154 case GF_OMP_FOR_KIND_DISTRIBUTE:
1155 kind = " distribute";
1156 break;
1157 case GF_OMP_FOR_KIND_CILKFOR:
1158 kind = " _Cilk_for";
1159 break;
1160 case GF_OMP_FOR_KIND_OACC_LOOP:
1161 kind = " oacc_loop";
1162 break;
1163 case GF_OMP_FOR_KIND_SIMD:
1164 kind = " simd";
1165 break;
1166 case GF_OMP_FOR_KIND_CILKSIMD:
1167 kind = " cilksimd";
1168 break;
1169 default:
1170 gcc_unreachable ();
1172 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1173 kind, gimple_omp_body (gs));
1174 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1175 dump_gimple_fmt (buffer, spc, flags, " >,");
1176 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1177 dump_gimple_fmt (buffer, spc, flags,
1178 "%+%T, %T, %T, %s, %T,%n",
1179 gimple_omp_for_index (gs, i),
1180 gimple_omp_for_initial (gs, i),
1181 gimple_omp_for_final (gs, i),
1182 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1183 gimple_omp_for_incr (gs, i));
1184 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1185 gimple_omp_for_pre_body (gs));
1187 else
1189 switch (gimple_omp_for_kind (gs))
1191 case GF_OMP_FOR_KIND_FOR:
1192 pp_string (buffer, "#pragma omp for");
1193 break;
1194 case GF_OMP_FOR_KIND_DISTRIBUTE:
1195 pp_string (buffer, "#pragma omp distribute");
1196 break;
1197 case GF_OMP_FOR_KIND_CILKFOR:
1198 break;
1199 case GF_OMP_FOR_KIND_OACC_LOOP:
1200 pp_string (buffer, "#pragma acc loop");
1201 break;
1202 case GF_OMP_FOR_KIND_SIMD:
1203 pp_string (buffer, "#pragma omp simd");
1204 break;
1205 case GF_OMP_FOR_KIND_CILKSIMD:
1206 pp_string (buffer, "#pragma simd");
1207 break;
1208 default:
1209 gcc_unreachable ();
1211 if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
1212 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1213 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1215 if (i)
1216 spc += 2;
1217 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1218 pp_string (buffer, "_Cilk_for (");
1219 else
1221 newline_and_indent (buffer, spc);
1222 pp_string (buffer, "for (");
1224 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1225 flags, false);
1226 pp_string (buffer, " = ");
1227 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1228 flags, false);
1229 pp_string (buffer, "; ");
1231 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1232 flags, false);
1233 pp_space (buffer);
1234 switch (gimple_omp_for_cond (gs, i))
1236 case LT_EXPR:
1237 pp_less (buffer);
1238 break;
1239 case GT_EXPR:
1240 pp_greater (buffer);
1241 break;
1242 case LE_EXPR:
1243 pp_less_equal (buffer);
1244 break;
1245 case GE_EXPR:
1246 pp_greater_equal (buffer);
1247 break;
1248 case NE_EXPR:
1249 pp_string (buffer, "!=");
1250 break;
1251 default:
1252 gcc_unreachable ();
1254 pp_space (buffer);
1255 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1256 flags, false);
1257 pp_string (buffer, "; ");
1259 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1260 flags, false);
1261 pp_string (buffer, " = ");
1262 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1263 flags, false);
1264 pp_right_paren (buffer);
1267 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1269 if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
1270 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1271 newline_and_indent (buffer, spc + 2);
1272 pp_left_brace (buffer);
1273 pp_newline (buffer);
1274 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1275 newline_and_indent (buffer, spc + 2);
1276 pp_right_brace (buffer);
1281 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1283 static void
1284 dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
1285 int spc, int flags)
1287 if (flags & TDF_RAW)
1289 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1290 gimple_omp_continue_control_def (gs),
1291 gimple_omp_continue_control_use (gs));
1293 else
1295 pp_string (buffer, "#pragma omp continue (");
1296 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1297 spc, flags, false);
1298 pp_comma (buffer);
1299 pp_space (buffer);
1300 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1301 spc, flags, false);
1302 pp_right_paren (buffer);
1306 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1308 static void
1309 dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
1310 int spc, int flags)
1312 if (flags & TDF_RAW)
1314 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1315 gimple_omp_body (gs));
1316 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1317 dump_gimple_fmt (buffer, spc, flags, " >");
1319 else
1321 pp_string (buffer, "#pragma omp single");
1322 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1323 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1325 newline_and_indent (buffer, spc + 2);
1326 pp_left_brace (buffer);
1327 pp_newline (buffer);
1328 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1329 newline_and_indent (buffer, spc + 2);
1330 pp_right_brace (buffer);
1335 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1337 static void
1338 dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
1339 int spc, int flags)
1341 const char *kind;
1342 switch (gimple_omp_target_kind (gs))
1344 case GF_OMP_TARGET_KIND_REGION:
1345 kind = "";
1346 break;
1347 case GF_OMP_TARGET_KIND_DATA:
1348 kind = " data";
1349 break;
1350 case GF_OMP_TARGET_KIND_UPDATE:
1351 kind = " update";
1352 break;
1353 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1354 kind = " oacc_kernels";
1355 break;
1356 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1357 kind = " oacc_parallel";
1358 break;
1359 case GF_OMP_TARGET_KIND_OACC_DATA:
1360 kind = " oacc_data";
1361 break;
1362 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1363 kind = " oacc_update";
1364 break;
1365 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1366 kind = " oacc_enter_exit_data";
1367 break;
1368 default:
1369 gcc_unreachable ();
1371 if (flags & TDF_RAW)
1373 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1374 kind, gimple_omp_body (gs));
1375 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1376 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1377 gimple_omp_target_child_fn (gs),
1378 gimple_omp_target_data_arg (gs));
1380 else
1382 pp_string (buffer, "#pragma omp target");
1383 pp_string (buffer, kind);
1384 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1385 if (gimple_omp_target_child_fn (gs))
1387 pp_string (buffer, " [child fn: ");
1388 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1389 spc, flags, false);
1390 pp_string (buffer, " (");
1391 if (gimple_omp_target_data_arg (gs))
1392 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1393 spc, flags, false);
1394 else
1395 pp_string (buffer, "???");
1396 pp_string (buffer, ")]");
1398 gimple_seq body = gimple_omp_body (gs);
1399 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1401 newline_and_indent (buffer, spc + 2);
1402 pp_left_brace (buffer);
1403 pp_newline (buffer);
1404 dump_gimple_seq (buffer, body, spc + 4, flags);
1405 newline_and_indent (buffer, spc + 2);
1406 pp_right_brace (buffer);
1408 else if (body)
1410 pp_newline (buffer);
1411 dump_gimple_seq (buffer, body, spc + 2, flags);
1416 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1418 static void
1419 dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
1420 int flags)
1422 if (flags & TDF_RAW)
1424 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1425 gimple_omp_body (gs));
1426 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1427 dump_gimple_fmt (buffer, spc, flags, " >");
1429 else
1431 pp_string (buffer, "#pragma omp teams");
1432 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1433 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1435 newline_and_indent (buffer, spc + 2);
1436 pp_character (buffer, '{');
1437 pp_newline (buffer);
1438 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1439 newline_and_indent (buffer, spc + 2);
1440 pp_character (buffer, '}');
1445 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1447 static void
1448 dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
1449 int spc, int flags)
1451 if (flags & TDF_RAW)
1453 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1454 gimple_omp_body (gs));
1455 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1456 dump_gimple_fmt (buffer, spc, flags, " >");
1458 else
1460 pp_string (buffer, "#pragma omp sections");
1461 if (gimple_omp_sections_control (gs))
1463 pp_string (buffer, " <");
1464 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1465 flags, false);
1466 pp_greater (buffer);
1468 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1469 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1471 newline_and_indent (buffer, spc + 2);
1472 pp_left_brace (buffer);
1473 pp_newline (buffer);
1474 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1475 newline_and_indent (buffer, spc + 2);
1476 pp_right_brace (buffer);
1481 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1482 pretty_printer BUFFER. */
1484 static void
1485 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1487 if (flags & TDF_RAW)
1488 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1489 gimple_omp_body (gs));
1490 else
1492 switch (gimple_code (gs))
1494 case GIMPLE_OMP_MASTER:
1495 pp_string (buffer, "#pragma omp master");
1496 break;
1497 case GIMPLE_OMP_TASKGROUP:
1498 pp_string (buffer, "#pragma omp taskgroup");
1499 break;
1500 case GIMPLE_OMP_ORDERED:
1501 pp_string (buffer, "#pragma omp ordered");
1502 break;
1503 case GIMPLE_OMP_SECTION:
1504 pp_string (buffer, "#pragma omp section");
1505 break;
1506 default:
1507 gcc_unreachable ();
1509 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1511 newline_and_indent (buffer, spc + 2);
1512 pp_left_brace (buffer);
1513 pp_newline (buffer);
1514 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1515 newline_and_indent (buffer, spc + 2);
1516 pp_right_brace (buffer);
1521 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1523 static void
1524 dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
1525 int spc, int flags)
1527 if (flags & TDF_RAW)
1528 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1529 gimple_omp_body (gs));
1530 else
1532 pp_string (buffer, "#pragma omp critical");
1533 if (gimple_omp_critical_name (gs))
1535 pp_string (buffer, " (");
1536 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1537 flags, false);
1538 pp_right_paren (buffer);
1540 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1542 newline_and_indent (buffer, spc + 2);
1543 pp_left_brace (buffer);
1544 pp_newline (buffer);
1545 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1546 newline_and_indent (buffer, spc + 2);
1547 pp_right_brace (buffer);
1552 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1554 static void
1555 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1557 if (flags & TDF_RAW)
1559 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1560 (int) gimple_omp_return_nowait_p (gs));
1561 if (gimple_omp_return_lhs (gs))
1562 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1563 gimple_omp_return_lhs (gs));
1564 else
1565 dump_gimple_fmt (buffer, spc, flags, ">");
1567 else
1569 pp_string (buffer, "#pragma omp return");
1570 if (gimple_omp_return_nowait_p (gs))
1571 pp_string (buffer, "(nowait)");
1572 if (gimple_omp_return_lhs (gs))
1574 pp_string (buffer, " (set ");
1575 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1576 spc, flags, false);
1577 pp_character (buffer, ')');
1582 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1584 static void
1585 dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
1586 int spc, int flags)
1588 unsigned subcode = gimple_transaction_subcode (gs);
1590 if (flags & TDF_RAW)
1592 dump_gimple_fmt (buffer, spc, flags,
1593 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1594 gs, subcode, gimple_transaction_label (gs),
1595 gimple_transaction_body (gs));
1597 else
1599 if (subcode & GTMA_IS_OUTER)
1600 pp_string (buffer, "__transaction_atomic [[outer]]");
1601 else if (subcode & GTMA_IS_RELAXED)
1602 pp_string (buffer, "__transaction_relaxed");
1603 else
1604 pp_string (buffer, "__transaction_atomic");
1605 subcode &= ~GTMA_DECLARATION_MASK;
1607 if (subcode || gimple_transaction_label (gs))
1609 pp_string (buffer, " //");
1610 if (gimple_transaction_label (gs))
1612 pp_string (buffer, " LABEL=");
1613 dump_generic_node (buffer, gimple_transaction_label (gs),
1614 spc, flags, false);
1616 if (subcode)
1618 pp_string (buffer, " SUBCODE=[ ");
1619 if (subcode & GTMA_HAVE_ABORT)
1621 pp_string (buffer, "GTMA_HAVE_ABORT ");
1622 subcode &= ~GTMA_HAVE_ABORT;
1624 if (subcode & GTMA_HAVE_LOAD)
1626 pp_string (buffer, "GTMA_HAVE_LOAD ");
1627 subcode &= ~GTMA_HAVE_LOAD;
1629 if (subcode & GTMA_HAVE_STORE)
1631 pp_string (buffer, "GTMA_HAVE_STORE ");
1632 subcode &= ~GTMA_HAVE_STORE;
1634 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1636 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1637 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1639 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1641 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1642 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1644 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1646 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1647 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1649 if (subcode)
1650 pp_printf (buffer, "0x%x ", subcode);
1651 pp_right_bracket (buffer);
1655 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1657 newline_and_indent (buffer, spc + 2);
1658 pp_left_brace (buffer);
1659 pp_newline (buffer);
1660 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1661 spc + 4, flags);
1662 newline_and_indent (buffer, spc + 2);
1663 pp_right_brace (buffer);
1668 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1669 indent. FLAGS specifies details to show in the dump (see TDF_* in
1670 dumpfile.h). */
1672 static void
1673 dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
1675 unsigned int i, n, f, fields;
1677 if (flags & TDF_RAW)
1679 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1680 gimple_asm_string (gs));
1682 n = gimple_asm_noutputs (gs);
1683 if (n)
1685 newline_and_indent (buffer, spc + 2);
1686 pp_string (buffer, "OUTPUT: ");
1687 for (i = 0; i < n; i++)
1689 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1690 spc, flags, false);
1691 if (i < n - 1)
1692 pp_string (buffer, ", ");
1696 n = gimple_asm_ninputs (gs);
1697 if (n)
1699 newline_and_indent (buffer, spc + 2);
1700 pp_string (buffer, "INPUT: ");
1701 for (i = 0; i < n; i++)
1703 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1704 spc, flags, false);
1705 if (i < n - 1)
1706 pp_string (buffer, ", ");
1710 n = gimple_asm_nclobbers (gs);
1711 if (n)
1713 newline_and_indent (buffer, spc + 2);
1714 pp_string (buffer, "CLOBBER: ");
1715 for (i = 0; i < n; i++)
1717 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1718 spc, flags, false);
1719 if (i < n - 1)
1720 pp_string (buffer, ", ");
1724 n = gimple_asm_nlabels (gs);
1725 if (n)
1727 newline_and_indent (buffer, spc + 2);
1728 pp_string (buffer, "LABEL: ");
1729 for (i = 0; i < n; i++)
1731 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1732 spc, flags, false);
1733 if (i < n - 1)
1734 pp_string (buffer, ", ");
1738 newline_and_indent (buffer, spc);
1739 pp_greater (buffer);
1741 else
1743 pp_string (buffer, "__asm__");
1744 if (gimple_asm_volatile_p (gs))
1745 pp_string (buffer, " __volatile__");
1746 if (gimple_asm_nlabels (gs))
1747 pp_string (buffer, " goto");
1748 pp_string (buffer, "(\"");
1749 pp_string (buffer, gimple_asm_string (gs));
1750 pp_string (buffer, "\"");
1752 if (gimple_asm_nlabels (gs))
1753 fields = 4;
1754 else if (gimple_asm_nclobbers (gs))
1755 fields = 3;
1756 else if (gimple_asm_ninputs (gs))
1757 fields = 2;
1758 else if (gimple_asm_noutputs (gs))
1759 fields = 1;
1760 else
1761 fields = 0;
1763 for (f = 0; f < fields; ++f)
1765 pp_string (buffer, " : ");
1767 switch (f)
1769 case 0:
1770 n = gimple_asm_noutputs (gs);
1771 for (i = 0; i < n; i++)
1773 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1774 spc, flags, false);
1775 if (i < n - 1)
1776 pp_string (buffer, ", ");
1778 break;
1780 case 1:
1781 n = gimple_asm_ninputs (gs);
1782 for (i = 0; i < n; i++)
1784 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1785 spc, flags, false);
1786 if (i < n - 1)
1787 pp_string (buffer, ", ");
1789 break;
1791 case 2:
1792 n = gimple_asm_nclobbers (gs);
1793 for (i = 0; i < n; i++)
1795 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1796 spc, flags, false);
1797 if (i < n - 1)
1798 pp_string (buffer, ", ");
1800 break;
1802 case 3:
1803 n = gimple_asm_nlabels (gs);
1804 for (i = 0; i < n; i++)
1806 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1807 spc, flags, false);
1808 if (i < n - 1)
1809 pp_string (buffer, ", ");
1811 break;
1813 default:
1814 gcc_unreachable ();
1818 pp_string (buffer, ");");
1822 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1823 SPC spaces of indent. */
1825 static void
1826 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1828 if (TREE_CODE (node) != SSA_NAME)
1829 return;
1831 if (POINTER_TYPE_P (TREE_TYPE (node))
1832 && SSA_NAME_PTR_INFO (node))
1834 unsigned int align, misalign;
1835 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1836 pp_string (buffer, "# PT = ");
1837 pp_points_to_solution (buffer, &pi->pt);
1838 newline_and_indent (buffer, spc);
1839 if (get_ptr_info_alignment (pi, &align, &misalign))
1841 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1842 newline_and_indent (buffer, spc);
1846 if (!POINTER_TYPE_P (TREE_TYPE (node))
1847 && SSA_NAME_RANGE_INFO (node))
1849 wide_int min, max, nonzero_bits;
1850 value_range_type range_type = get_range_info (node, &min, &max);
1852 if (range_type == VR_VARYING)
1853 pp_printf (buffer, "# RANGE VR_VARYING");
1854 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1856 pp_printf (buffer, "# RANGE ");
1857 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1858 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
1859 pp_printf (buffer, ", ");
1860 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
1861 pp_printf (buffer, "]");
1863 nonzero_bits = get_nonzero_bits (node);
1864 if (nonzero_bits != -1)
1866 pp_string (buffer, " NONZERO ");
1867 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
1869 newline_and_indent (buffer, spc);
1874 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1875 The caller is responsible for calling pp_flush on BUFFER to finalize
1876 pretty printer. If COMMENT is true, print this after #. */
1878 static void
1879 dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
1880 int flags)
1882 size_t i;
1883 tree lhs = gimple_phi_result (phi);
1885 if (flags & TDF_ALIAS)
1886 dump_ssaname_info (buffer, lhs, spc);
1888 if (comment)
1889 pp_string (buffer, "# ");
1891 if (flags & TDF_RAW)
1892 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1893 gimple_phi_result (phi));
1894 else
1896 dump_generic_node (buffer, lhs, spc, flags, false);
1897 pp_string (buffer, " = PHI <");
1899 for (i = 0; i < gimple_phi_num_args (phi); i++)
1901 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1902 dump_location (buffer, gimple_phi_arg_location (phi, i));
1903 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1904 false);
1905 pp_left_paren (buffer);
1906 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1907 pp_right_paren (buffer);
1908 if (i < gimple_phi_num_args (phi) - 1)
1909 pp_string (buffer, ", ");
1911 pp_greater (buffer);
1915 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1916 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1917 dumpfile.h). */
1919 static void
1920 dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
1921 int spc, int flags)
1923 if (flags & TDF_RAW)
1925 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1926 gimple_omp_body (gs));
1927 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1928 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1929 gimple_omp_parallel_child_fn (gs),
1930 gimple_omp_parallel_data_arg (gs));
1932 else
1934 gimple_seq body;
1935 pp_string (buffer, "#pragma omp parallel");
1936 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1937 if (gimple_omp_parallel_child_fn (gs))
1939 pp_string (buffer, " [child fn: ");
1940 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1941 spc, flags, false);
1942 pp_string (buffer, " (");
1943 if (gimple_omp_parallel_data_arg (gs))
1944 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1945 spc, flags, false);
1946 else
1947 pp_string (buffer, "???");
1948 pp_string (buffer, ")]");
1950 body = gimple_omp_body (gs);
1951 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1953 newline_and_indent (buffer, spc + 2);
1954 pp_left_brace (buffer);
1955 pp_newline (buffer);
1956 dump_gimple_seq (buffer, body, spc + 4, flags);
1957 newline_and_indent (buffer, spc + 2);
1958 pp_right_brace (buffer);
1960 else if (body)
1962 pp_newline (buffer);
1963 dump_gimple_seq (buffer, body, spc + 2, flags);
1969 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1970 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1971 dumpfile.h). */
1973 static void
1974 dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
1975 int flags)
1977 if (flags & TDF_RAW)
1979 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1980 gimple_omp_body (gs));
1981 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1982 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1983 gimple_omp_task_child_fn (gs),
1984 gimple_omp_task_data_arg (gs),
1985 gimple_omp_task_copy_fn (gs),
1986 gimple_omp_task_arg_size (gs),
1987 gimple_omp_task_arg_size (gs));
1989 else
1991 gimple_seq body;
1992 pp_string (buffer, "#pragma omp task");
1993 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1994 if (gimple_omp_task_child_fn (gs))
1996 pp_string (buffer, " [child fn: ");
1997 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1998 spc, flags, false);
1999 pp_string (buffer, " (");
2000 if (gimple_omp_task_data_arg (gs))
2001 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2002 spc, flags, false);
2003 else
2004 pp_string (buffer, "???");
2005 pp_string (buffer, ")]");
2007 body = gimple_omp_body (gs);
2008 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2010 newline_and_indent (buffer, spc + 2);
2011 pp_left_brace (buffer);
2012 pp_newline (buffer);
2013 dump_gimple_seq (buffer, body, spc + 4, flags);
2014 newline_and_indent (buffer, spc + 2);
2015 pp_right_brace (buffer);
2017 else if (body)
2019 pp_newline (buffer);
2020 dump_gimple_seq (buffer, body, spc + 2, flags);
2026 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2027 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2028 in dumpfile.h). */
2030 static void
2031 dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
2032 int spc, int flags)
2034 if (flags & TDF_RAW)
2036 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2037 gimple_omp_atomic_load_lhs (gs),
2038 gimple_omp_atomic_load_rhs (gs));
2040 else
2042 pp_string (buffer, "#pragma omp atomic_load");
2043 if (gimple_omp_atomic_seq_cst_p (gs))
2044 pp_string (buffer, " seq_cst");
2045 if (gimple_omp_atomic_need_value_p (gs))
2046 pp_string (buffer, " [needed]");
2047 newline_and_indent (buffer, spc + 2);
2048 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2049 spc, flags, false);
2050 pp_space (buffer);
2051 pp_equal (buffer);
2052 pp_space (buffer);
2053 pp_star (buffer);
2054 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2055 spc, flags, false);
2059 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2060 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2061 in dumpfile.h). */
2063 static void
2064 dump_gimple_omp_atomic_store (pretty_printer *buffer,
2065 gomp_atomic_store *gs, int spc, int flags)
2067 if (flags & TDF_RAW)
2069 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2070 gimple_omp_atomic_store_val (gs));
2072 else
2074 pp_string (buffer, "#pragma omp atomic_store ");
2075 if (gimple_omp_atomic_seq_cst_p (gs))
2076 pp_string (buffer, "seq_cst ");
2077 if (gimple_omp_atomic_need_value_p (gs))
2078 pp_string (buffer, "[needed] ");
2079 pp_left_paren (buffer);
2080 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2081 spc, flags, false);
2082 pp_right_paren (buffer);
2087 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2088 FLAGS are as in pp_gimple_stmt_1. */
2090 static void
2091 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
2093 tree vdef = gimple_vdef (gs);
2094 tree vuse = gimple_vuse (gs);
2096 if (vdef != NULL_TREE)
2098 pp_string (buffer, "# ");
2099 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2100 pp_string (buffer, " = VDEF <");
2101 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2102 pp_greater (buffer);
2103 newline_and_indent (buffer, spc);
2105 else if (vuse != NULL_TREE)
2107 pp_string (buffer, "# VUSE <");
2108 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2109 pp_greater (buffer);
2110 newline_and_indent (buffer, spc);
2115 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2116 spaces of indent. FLAGS specifies details to show in the dump (see
2117 TDF_* in dumpfile.h). The caller is responsible for calling
2118 pp_flush on BUFFER to finalize the pretty printer. */
2120 void
2121 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
2123 if (!gs)
2124 return;
2126 if (flags & TDF_STMTADDR)
2127 pp_printf (buffer, "<&%p> ", (void *) gs);
2129 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2130 dump_location (buffer, gimple_location (gs));
2132 if (flags & TDF_EH)
2134 int lp_nr = lookup_stmt_eh_lp (gs);
2135 if (lp_nr > 0)
2136 pp_printf (buffer, "[LP %d] ", lp_nr);
2137 else if (lp_nr < 0)
2138 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2141 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2142 && gimple_has_mem_ops (gs))
2143 dump_gimple_mem_ops (buffer, gs, spc, flags);
2145 if (gimple_has_lhs (gs)
2146 && (flags & TDF_ALIAS))
2147 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2149 switch (gimple_code (gs))
2151 case GIMPLE_ASM:
2152 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
2153 break;
2155 case GIMPLE_ASSIGN:
2156 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
2157 break;
2159 case GIMPLE_BIND:
2160 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
2161 break;
2163 case GIMPLE_CALL:
2164 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
2165 break;
2167 case GIMPLE_COND:
2168 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
2169 break;
2171 case GIMPLE_LABEL:
2172 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
2173 break;
2175 case GIMPLE_GOTO:
2176 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
2177 break;
2179 case GIMPLE_NOP:
2180 pp_string (buffer, "GIMPLE_NOP");
2181 break;
2183 case GIMPLE_RETURN:
2184 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
2185 break;
2187 case GIMPLE_SWITCH:
2188 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
2189 break;
2191 case GIMPLE_TRY:
2192 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
2193 break;
2195 case GIMPLE_PHI:
2196 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
2197 break;
2199 case GIMPLE_OMP_PARALLEL:
2200 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2201 flags);
2202 break;
2204 case GIMPLE_OMP_TASK:
2205 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
2206 break;
2208 case GIMPLE_OMP_ATOMIC_LOAD:
2209 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2210 spc, flags);
2211 break;
2213 case GIMPLE_OMP_ATOMIC_STORE:
2214 dump_gimple_omp_atomic_store (buffer,
2215 as_a <gomp_atomic_store *> (gs),
2216 spc, flags);
2217 break;
2219 case GIMPLE_OMP_FOR:
2220 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
2221 break;
2223 case GIMPLE_OMP_CONTINUE:
2224 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2225 flags);
2226 break;
2228 case GIMPLE_OMP_SINGLE:
2229 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2230 flags);
2231 break;
2233 case GIMPLE_OMP_TARGET:
2234 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2235 flags);
2236 break;
2238 case GIMPLE_OMP_TEAMS:
2239 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2240 flags);
2241 break;
2243 case GIMPLE_OMP_RETURN:
2244 dump_gimple_omp_return (buffer, gs, spc, flags);
2245 break;
2247 case GIMPLE_OMP_SECTIONS:
2248 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2249 spc, flags);
2250 break;
2252 case GIMPLE_OMP_SECTIONS_SWITCH:
2253 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2254 break;
2256 case GIMPLE_OMP_MASTER:
2257 case GIMPLE_OMP_TASKGROUP:
2258 case GIMPLE_OMP_ORDERED:
2259 case GIMPLE_OMP_SECTION:
2260 dump_gimple_omp_block (buffer, gs, spc, flags);
2261 break;
2263 case GIMPLE_OMP_CRITICAL:
2264 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2265 flags);
2266 break;
2268 case GIMPLE_CATCH:
2269 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
2270 break;
2272 case GIMPLE_EH_FILTER:
2273 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
2274 break;
2276 case GIMPLE_EH_MUST_NOT_THROW:
2277 dump_gimple_eh_must_not_throw (buffer,
2278 as_a <geh_mnt *> (gs),
2279 spc, flags);
2280 break;
2282 case GIMPLE_EH_ELSE:
2283 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
2284 break;
2286 case GIMPLE_RESX:
2287 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
2288 break;
2290 case GIMPLE_EH_DISPATCH:
2291 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2292 flags);
2293 break;
2295 case GIMPLE_DEBUG:
2296 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
2297 break;
2299 case GIMPLE_PREDICT:
2300 pp_string (buffer, "// predicted ");
2301 if (gimple_predict_outcome (gs))
2302 pp_string (buffer, "likely by ");
2303 else
2304 pp_string (buffer, "unlikely by ");
2305 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2306 pp_string (buffer, " predictor.");
2307 break;
2309 case GIMPLE_TRANSACTION:
2310 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2311 flags);
2312 break;
2314 default:
2315 GIMPLE_NIY;
2320 /* Dumps header of basic block BB to OUTF indented by INDENT
2321 spaces and details described by flags. */
2323 static void
2324 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2326 if (flags & TDF_BLOCKS)
2328 if (flags & TDF_LINENO)
2330 gimple_stmt_iterator gsi;
2332 if (flags & TDF_COMMENT)
2333 fputs (";; ", outf);
2335 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2336 if (!is_gimple_debug (gsi_stmt (gsi))
2337 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2339 fprintf (outf, "%*sstarting at line %d",
2340 indent, "", get_lineno (gsi_stmt (gsi)));
2341 break;
2343 if (bb->discriminator)
2344 fprintf (outf, ", discriminator %i", bb->discriminator);
2345 fputc ('\n', outf);
2348 else
2350 gimple stmt = first_stmt (bb);
2351 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2352 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2357 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2358 spaces. */
2360 static void
2361 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2362 basic_block bb ATTRIBUTE_UNUSED,
2363 int indent ATTRIBUTE_UNUSED,
2364 int flags ATTRIBUTE_UNUSED)
2366 /* There is currently no GIMPLE-specific basic block info to dump. */
2367 return;
2371 /* Dump PHI nodes of basic block BB to BUFFER with details described
2372 by FLAGS and indented by INDENT spaces. */
2374 static void
2375 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2377 gphi_iterator i;
2379 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2381 gphi *phi = i.phi ();
2382 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2384 INDENT (indent);
2385 dump_gimple_phi (buffer, phi, indent, true, flags);
2386 pp_newline (buffer);
2392 /* Dump jump to basic block BB that is represented implicitly in the cfg
2393 to BUFFER. */
2395 static void
2396 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2398 gimple stmt;
2400 stmt = first_stmt (bb);
2402 pp_string (buffer, "goto <bb ");
2403 pp_decimal_int (buffer, bb->index);
2404 pp_greater (buffer);
2405 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2407 pp_string (buffer, " (");
2408 dump_generic_node (buffer,
2409 gimple_label_label (as_a <glabel *> (stmt)),
2410 0, 0, false);
2411 pp_right_paren (buffer);
2412 pp_semicolon (buffer);
2414 else
2415 pp_semicolon (buffer);
2419 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2420 by INDENT spaces, with details given by FLAGS. */
2422 static void
2423 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2424 int flags)
2426 edge e;
2427 gimple stmt;
2429 stmt = last_stmt (bb);
2431 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2433 edge true_edge, false_edge;
2435 /* When we are emitting the code or changing CFG, it is possible that
2436 the edges are not yet created. When we are using debug_bb in such
2437 a situation, we do not want it to crash. */
2438 if (EDGE_COUNT (bb->succs) != 2)
2439 return;
2440 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2442 INDENT (indent + 2);
2443 pp_cfg_jump (buffer, true_edge->dest);
2444 newline_and_indent (buffer, indent);
2445 pp_string (buffer, "else");
2446 newline_and_indent (buffer, indent + 2);
2447 pp_cfg_jump (buffer, false_edge->dest);
2448 pp_newline (buffer);
2449 return;
2452 /* If there is a fallthru edge, we may need to add an artificial
2453 goto to the dump. */
2454 e = find_fallthru_edge (bb->succs);
2456 if (e && e->dest != bb->next_bb)
2458 INDENT (indent);
2460 if ((flags & TDF_LINENO)
2461 && e->goto_locus != UNKNOWN_LOCATION)
2462 dump_location (buffer, e->goto_locus);
2464 pp_cfg_jump (buffer, e->dest);
2465 pp_newline (buffer);
2470 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2471 indented by INDENT spaces. */
2473 static void
2474 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2475 int flags)
2477 gimple_stmt_iterator gsi;
2478 gimple stmt;
2479 int label_indent = indent - 2;
2481 if (label_indent < 0)
2482 label_indent = 0;
2484 dump_phi_nodes (buffer, bb, indent, flags);
2486 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2488 int curr_indent;
2490 stmt = gsi_stmt (gsi);
2492 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2494 INDENT (curr_indent);
2495 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2496 pp_newline_and_flush (buffer);
2497 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2498 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2499 pp_buffer (buffer)->stream, stmt);
2502 dump_implicit_edges (buffer, bb, indent, flags);
2503 pp_flush (buffer);
2507 /* Dumps basic block BB to FILE with details described by FLAGS and
2508 indented by INDENT spaces. */
2510 void
2511 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2513 dump_gimple_bb_header (file, bb, indent, flags);
2514 if (bb->index >= NUM_FIXED_BLOCKS)
2516 pretty_printer buffer;
2517 pp_needs_newline (&buffer) = true;
2518 buffer.buffer->stream = file;
2519 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2521 dump_gimple_bb_footer (file, bb, indent, flags);
2524 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2525 no indentation, for use as a label of a DOT graph record-node.
2526 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2527 histogram dumping doesn't know about pretty-printers. */
2529 void
2530 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2532 pp_printf (pp, "<bb %d>:\n", bb->index);
2533 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2535 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2536 gsi_next (&gsi))
2538 gphi *phi = gsi.phi ();
2539 if (!virtual_operand_p (gimple_phi_result (phi))
2540 || (dump_flags & TDF_VOPS))
2542 pp_bar (pp);
2543 pp_write_text_to_stream (pp);
2544 pp_string (pp, "# ");
2545 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2546 pp_newline (pp);
2547 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2551 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2552 gsi_next (&gsi))
2554 gimple stmt = gsi_stmt (gsi);
2555 pp_bar (pp);
2556 pp_write_text_to_stream (pp);
2557 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2558 pp_newline (pp);
2559 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2561 dump_implicit_edges (pp, bb, 0, dump_flags);
2562 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);