OpenACC: Basic support for #pragma acc parallel.
[official-gcc.git] / gcc / gimple-pretty-print.c
blob59cb5bb283c5bbc2df6b8b7b7767d9bc37c28ae6
1 /* Pretty formatting of GIMPLE statements and expressions.
2 Copyright (C) 2001-2013 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 "tree.h"
27 #include "diagnostic.h"
28 #include "gimple-pretty-print.h"
29 #include "hashtab.h"
30 #include "bitmap.h"
31 #include "gimple.h"
32 #include "gimple-ssa.h"
33 #include "cgraph.h"
34 #include "tree-cfg.h"
35 #include "tree-ssanames.h"
36 #include "dumpfile.h" /* for dump_flags */
37 #include "value-prof.h"
38 #include "trans-mem.h"
40 #define INDENT(SPACE) \
41 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
43 #define GIMPLE_NIY do_niy (buffer,gs)
45 /* Try to print on BUFFER a default message for the unrecognized
46 gimple statement GS. */
48 static void
49 do_niy (pretty_printer *buffer, gimple gs)
51 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
52 gimple_code_name[(int) gimple_code (gs)]);
56 /* Emit a newline and SPC indentation spaces to BUFFER. */
58 static void
59 newline_and_indent (pretty_printer *buffer, int spc)
61 pp_newline (buffer);
62 INDENT (spc);
66 /* Print the GIMPLE statement GS on stderr. */
68 DEBUG_FUNCTION void
69 debug_gimple_stmt (gimple gs)
71 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
75 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
76 FLAGS as in pp_gimple_stmt_1. */
78 void
79 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
81 pretty_printer buffer;
82 pp_needs_newline (&buffer) = true;
83 buffer.buffer->stream = file;
84 pp_gimple_stmt_1 (&buffer, g, spc, flags);
85 pp_newline_and_flush (&buffer);
88 DEBUG_FUNCTION void
89 debug (gimple_statement_d &ref)
91 print_gimple_stmt (stderr, &ref, 0, 0);
94 DEBUG_FUNCTION void
95 debug (gimple_statement_d *ptr)
97 if (ptr)
98 debug (*ptr);
99 else
100 fprintf (stderr, "<nil>\n");
104 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
105 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
106 of the statement. */
108 void
109 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
111 flags |= TDF_RHS_ONLY;
112 pretty_printer buffer;
113 pp_needs_newline (&buffer) = true;
114 buffer.buffer->stream = file;
115 pp_gimple_stmt_1 (&buffer, g, spc, flags);
116 pp_flush (&buffer);
120 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
121 spaces and FLAGS as in pp_gimple_stmt_1.
122 The caller is responsible for calling pp_flush on BUFFER to finalize
123 the pretty printer. */
125 static void
126 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
128 gimple_stmt_iterator i;
130 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
132 gimple gs = gsi_stmt (i);
133 INDENT (spc);
134 pp_gimple_stmt_1 (buffer, gs, spc, flags);
135 if (!gsi_one_before_end_p (i))
136 pp_newline (buffer);
141 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
142 FLAGS as in pp_gimple_stmt_1. */
144 void
145 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
147 pretty_printer buffer;
148 pp_needs_newline (&buffer) = true;
149 buffer.buffer->stream = file;
150 dump_gimple_seq (&buffer, seq, spc, flags);
151 pp_newline_and_flush (&buffer);
155 /* Print the GIMPLE sequence SEQ on stderr. */
157 DEBUG_FUNCTION void
158 debug_gimple_seq (gimple_seq seq)
160 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
164 /* A simple helper to pretty-print some of the gimple tuples in the printf
165 style. The format modifiers are preceded by '%' and are:
166 'G' - outputs a string corresponding to the code of the given gimple,
167 'S' - outputs a gimple_seq with indent of spc + 2,
168 'T' - outputs the tree t,
169 'd' - outputs an int as a decimal,
170 's' - outputs a string,
171 'n' - outputs a newline,
172 'x' - outputs an int as hexadecimal,
173 '+' - increases indent by 2 then outputs a newline,
174 '-' - decreases indent by 2 then outputs a newline. */
176 static void
177 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
178 const char *fmt, ...)
180 va_list args;
181 const char *c;
182 const char *tmp;
184 va_start (args, fmt);
185 for (c = fmt; *c; c++)
187 if (*c == '%')
189 gimple_seq seq;
190 tree t;
191 gimple g;
192 switch (*++c)
194 case 'G':
195 g = va_arg (args, gimple);
196 tmp = gimple_code_name[gimple_code (g)];
197 pp_string (buffer, tmp);
198 break;
200 case 'S':
201 seq = va_arg (args, gimple_seq);
202 pp_newline (buffer);
203 dump_gimple_seq (buffer, seq, spc + 2, flags);
204 newline_and_indent (buffer, spc);
205 break;
207 case 'T':
208 t = va_arg (args, tree);
209 if (t == NULL_TREE)
210 pp_string (buffer, "NULL");
211 else
212 dump_generic_node (buffer, t, spc, flags, false);
213 break;
215 case 'd':
216 pp_decimal_int (buffer, va_arg (args, int));
217 break;
219 case 's':
220 pp_string (buffer, va_arg (args, char *));
221 break;
223 case 'n':
224 newline_and_indent (buffer, spc);
225 break;
227 case 'x':
228 pp_scalar (buffer, "%x", va_arg (args, int));
229 break;
231 case '+':
232 spc += 2;
233 newline_and_indent (buffer, spc);
234 break;
236 case '-':
237 spc -= 2;
238 newline_and_indent (buffer, spc);
239 break;
241 default:
242 gcc_unreachable ();
245 else
246 pp_character (buffer, *c);
248 va_end (args);
252 /* Helper for dump_gimple_assign. Print the unary RHS of the
253 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
255 static void
256 dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
258 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
259 tree lhs = gimple_assign_lhs (gs);
260 tree rhs = gimple_assign_rhs1 (gs);
262 switch (rhs_code)
264 case VIEW_CONVERT_EXPR:
265 case ASSERT_EXPR:
266 dump_generic_node (buffer, rhs, spc, flags, false);
267 break;
269 case FIXED_CONVERT_EXPR:
270 case ADDR_SPACE_CONVERT_EXPR:
271 case FIX_TRUNC_EXPR:
272 case FLOAT_EXPR:
273 CASE_CONVERT:
274 pp_left_paren (buffer);
275 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
276 pp_string (buffer, ") ");
277 if (op_prio (rhs) < op_code_prio (rhs_code))
279 pp_left_paren (buffer);
280 dump_generic_node (buffer, rhs, spc, flags, false);
281 pp_right_paren (buffer);
283 else
284 dump_generic_node (buffer, rhs, spc, flags, false);
285 break;
287 case PAREN_EXPR:
288 pp_string (buffer, "((");
289 dump_generic_node (buffer, rhs, spc, flags, false);
290 pp_string (buffer, "))");
291 break;
293 case ABS_EXPR:
294 pp_string (buffer, "ABS_EXPR <");
295 dump_generic_node (buffer, rhs, spc, flags, false);
296 pp_greater (buffer);
297 break;
299 default:
300 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
301 || TREE_CODE_CLASS (rhs_code) == tcc_constant
302 || TREE_CODE_CLASS (rhs_code) == tcc_reference
303 || rhs_code == SSA_NAME
304 || rhs_code == ADDR_EXPR
305 || rhs_code == CONSTRUCTOR)
307 dump_generic_node (buffer, rhs, spc, flags, false);
308 break;
310 else if (rhs_code == BIT_NOT_EXPR)
311 pp_complement (buffer);
312 else if (rhs_code == TRUTH_NOT_EXPR)
313 pp_exclamation (buffer);
314 else if (rhs_code == NEGATE_EXPR)
315 pp_minus (buffer);
316 else
318 pp_left_bracket (buffer);
319 pp_string (buffer, get_tree_code_name (rhs_code));
320 pp_string (buffer, "] ");
323 if (op_prio (rhs) < op_code_prio (rhs_code))
325 pp_left_paren (buffer);
326 dump_generic_node (buffer, rhs, spc, flags, false);
327 pp_right_paren (buffer);
329 else
330 dump_generic_node (buffer, rhs, spc, flags, false);
331 break;
336 /* Helper for dump_gimple_assign. Print the binary RHS of the
337 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
339 static void
340 dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
342 const char *p;
343 enum tree_code code = gimple_assign_rhs_code (gs);
344 switch (code)
346 case COMPLEX_EXPR:
347 case MIN_EXPR:
348 case MAX_EXPR:
349 case VEC_WIDEN_MULT_HI_EXPR:
350 case VEC_WIDEN_MULT_LO_EXPR:
351 case VEC_WIDEN_MULT_EVEN_EXPR:
352 case VEC_WIDEN_MULT_ODD_EXPR:
353 case VEC_PACK_TRUNC_EXPR:
354 case VEC_PACK_SAT_EXPR:
355 case VEC_PACK_FIX_TRUNC_EXPR:
356 case VEC_WIDEN_LSHIFT_HI_EXPR:
357 case VEC_WIDEN_LSHIFT_LO_EXPR:
358 for (p = get_tree_code_name (code); *p; p++)
359 pp_character (buffer, TOUPPER (*p));
360 pp_string (buffer, " <");
361 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
362 pp_string (buffer, ", ");
363 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
364 pp_greater (buffer);
365 break;
367 default:
368 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
370 pp_left_paren (buffer);
371 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
372 false);
373 pp_right_paren (buffer);
375 else
376 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
377 pp_space (buffer);
378 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
379 pp_space (buffer);
380 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
382 pp_left_paren (buffer);
383 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
384 false);
385 pp_right_paren (buffer);
387 else
388 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
392 /* Helper for dump_gimple_assign. Print the ternary RHS of the
393 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
395 static void
396 dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
398 const char *p;
399 enum tree_code code = gimple_assign_rhs_code (gs);
400 switch (code)
402 case WIDEN_MULT_PLUS_EXPR:
403 case WIDEN_MULT_MINUS_EXPR:
404 for (p = get_tree_code_name (code); *p; p++)
405 pp_character (buffer, TOUPPER (*p));
406 pp_string (buffer, " <");
407 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
408 pp_string (buffer, ", ");
409 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
410 pp_string (buffer, ", ");
411 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
412 pp_greater (buffer);
413 break;
415 case FMA_EXPR:
416 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
417 pp_string (buffer, " * ");
418 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
419 pp_string (buffer, " + ");
420 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
421 break;
423 case DOT_PROD_EXPR:
424 pp_string (buffer, "DOT_PROD_EXPR <");
425 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
426 pp_string (buffer, ", ");
427 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
428 pp_string (buffer, ", ");
429 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
430 pp_greater (buffer);
431 break;
433 case VEC_PERM_EXPR:
434 pp_string (buffer, "VEC_PERM_EXPR <");
435 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
436 pp_string (buffer, ", ");
437 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
438 pp_string (buffer, ", ");
439 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
440 pp_greater (buffer);
441 break;
443 case REALIGN_LOAD_EXPR:
444 pp_string (buffer, "REALIGN_LOAD <");
445 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
446 pp_string (buffer, ", ");
447 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
448 pp_string (buffer, ", ");
449 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
450 pp_greater (buffer);
451 break;
453 case COND_EXPR:
454 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
455 pp_string (buffer, " ? ");
456 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
457 pp_string (buffer, " : ");
458 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
459 break;
461 case VEC_COND_EXPR:
462 pp_string (buffer, "VEC_COND_EXPR <");
463 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
464 pp_string (buffer, ", ");
465 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
466 pp_string (buffer, ", ");
467 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
468 pp_greater (buffer);
469 break;
471 default:
472 gcc_unreachable ();
477 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
478 pp_gimple_stmt_1. */
480 static void
481 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
483 if (flags & TDF_RAW)
485 tree arg1 = NULL;
486 tree arg2 = NULL;
487 tree arg3 = NULL;
488 switch (gimple_num_ops (gs))
490 case 4:
491 arg3 = gimple_assign_rhs3 (gs);
492 case 3:
493 arg2 = gimple_assign_rhs2 (gs);
494 case 2:
495 arg1 = gimple_assign_rhs1 (gs);
496 break;
497 default:
498 gcc_unreachable ();
501 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
502 get_tree_code_name (gimple_assign_rhs_code (gs)),
503 gimple_assign_lhs (gs), arg1, arg2, arg3);
505 else
507 if (!(flags & TDF_RHS_ONLY))
509 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
510 pp_space (buffer);
511 pp_equal (buffer);
513 if (gimple_assign_nontemporal_move_p (gs))
514 pp_string (buffer, "{nt}");
516 if (gimple_has_volatile_ops (gs))
517 pp_string (buffer, "{v}");
519 pp_space (buffer);
522 if (gimple_num_ops (gs) == 2)
523 dump_unary_rhs (buffer, gs, spc, flags);
524 else if (gimple_num_ops (gs) == 3)
525 dump_binary_rhs (buffer, gs, spc, flags);
526 else if (gimple_num_ops (gs) == 4)
527 dump_ternary_rhs (buffer, gs, spc, flags);
528 else
529 gcc_unreachable ();
530 if (!(flags & TDF_RHS_ONLY))
531 pp_semicolon (buffer);
536 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
537 pp_gimple_stmt_1. */
539 static void
540 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
542 tree t, t2;
544 t = gimple_return_retval (gs);
545 t2 = gimple_return_retbnd (gs);
546 if (flags & TDF_RAW)
547 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
548 else
550 pp_string (buffer, "return");
551 if (t)
553 pp_space (buffer);
554 dump_generic_node (buffer, t, spc, flags, false);
556 if (t2)
558 pp_string (buffer, ", ");
559 dump_generic_node (buffer, t2, spc, flags, false);
561 pp_semicolon (buffer);
566 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
567 dump_gimple_call. */
569 static void
570 dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags)
572 size_t i;
574 for (i = 0; i < gimple_call_num_args (gs); i++)
576 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
577 if (i < gimple_call_num_args (gs) - 1)
578 pp_string (buffer, ", ");
581 if (gimple_call_va_arg_pack_p (gs))
583 if (gimple_call_num_args (gs) > 0)
585 pp_comma (buffer);
586 pp_space (buffer);
589 pp_string (buffer, "__builtin_va_arg_pack ()");
593 /* Dump the points-to solution *PT to BUFFER. */
595 static void
596 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
598 if (pt->anything)
600 pp_string (buffer, "anything ");
601 return;
603 if (pt->nonlocal)
604 pp_string (buffer, "nonlocal ");
605 if (pt->escaped)
606 pp_string (buffer, "escaped ");
607 if (pt->ipa_escaped)
608 pp_string (buffer, "unit-escaped ");
609 if (pt->null)
610 pp_string (buffer, "null ");
611 if (pt->vars
612 && !bitmap_empty_p (pt->vars))
614 bitmap_iterator bi;
615 unsigned i;
616 pp_string (buffer, "{ ");
617 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
619 pp_string (buffer, "D.");
620 pp_decimal_int (buffer, i);
621 pp_space (buffer);
623 pp_right_brace (buffer);
624 if (pt->vars_contains_global)
625 pp_string (buffer, " (glob)");
629 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
630 pp_gimple_stmt_1. */
632 static void
633 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
635 tree lhs = gimple_call_lhs (gs);
636 tree fn = gimple_call_fn (gs);
638 if (flags & TDF_ALIAS)
640 struct pt_solution *pt;
641 pt = gimple_call_use_set (gs);
642 if (!pt_solution_empty_p (pt))
644 pp_string (buffer, "# USE = ");
645 pp_points_to_solution (buffer, pt);
646 newline_and_indent (buffer, spc);
648 pt = gimple_call_clobber_set (gs);
649 if (!pt_solution_empty_p (pt))
651 pp_string (buffer, "# CLB = ");
652 pp_points_to_solution (buffer, pt);
653 newline_and_indent (buffer, spc);
657 if (flags & TDF_RAW)
659 if (gimple_call_internal_p (gs))
660 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
661 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
662 else
663 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
664 if (gimple_call_num_args (gs) > 0)
666 pp_string (buffer, ", ");
667 dump_gimple_call_args (buffer, gs, flags);
669 pp_greater (buffer);
671 else
673 if (lhs && !(flags & TDF_RHS_ONLY))
675 dump_generic_node (buffer, lhs, spc, flags, false);
676 pp_string (buffer, " =");
678 if (gimple_has_volatile_ops (gs))
679 pp_string (buffer, "{v}");
681 pp_space (buffer);
683 if (gimple_call_internal_p (gs))
684 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
685 else
686 print_call_name (buffer, fn, flags);
687 pp_string (buffer, " (");
688 dump_gimple_call_args (buffer, gs, flags);
689 pp_right_paren (buffer);
690 if (!(flags & TDF_RHS_ONLY))
691 pp_semicolon (buffer);
694 if (gimple_call_chain (gs))
696 pp_string (buffer, " [static-chain: ");
697 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
698 pp_right_bracket (buffer);
701 if (gimple_call_return_slot_opt_p (gs))
702 pp_string (buffer, " [return slot optimization]");
703 if (gimple_call_tail_p (gs))
704 pp_string (buffer, " [tail call]");
706 if (fn == NULL)
707 return;
709 /* Dump the arguments of _ITM_beginTransaction sanely. */
710 if (TREE_CODE (fn) == ADDR_EXPR)
711 fn = TREE_OPERAND (fn, 0);
712 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
713 pp_string (buffer, " [tm-clone]");
714 if (TREE_CODE (fn) == FUNCTION_DECL
715 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
716 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
717 && gimple_call_num_args (gs) > 0)
719 tree t = gimple_call_arg (gs, 0);
720 unsigned HOST_WIDE_INT props;
721 gcc_assert (TREE_CODE (t) == INTEGER_CST);
723 pp_string (buffer, " [ ");
725 /* Get the transaction code properties. */
726 props = TREE_INT_CST_LOW (t);
728 if (props & PR_INSTRUMENTEDCODE)
729 pp_string (buffer, "instrumentedCode ");
730 if (props & PR_UNINSTRUMENTEDCODE)
731 pp_string (buffer, "uninstrumentedCode ");
732 if (props & PR_HASNOXMMUPDATE)
733 pp_string (buffer, "hasNoXMMUpdate ");
734 if (props & PR_HASNOABORT)
735 pp_string (buffer, "hasNoAbort ");
736 if (props & PR_HASNOIRREVOCABLE)
737 pp_string (buffer, "hasNoIrrevocable ");
738 if (props & PR_DOESGOIRREVOCABLE)
739 pp_string (buffer, "doesGoIrrevocable ");
740 if (props & PR_HASNOSIMPLEREADS)
741 pp_string (buffer, "hasNoSimpleReads ");
742 if (props & PR_AWBARRIERSOMITTED)
743 pp_string (buffer, "awBarriersOmitted ");
744 if (props & PR_RARBARRIERSOMITTED)
745 pp_string (buffer, "RaRBarriersOmitted ");
746 if (props & PR_UNDOLOGCODE)
747 pp_string (buffer, "undoLogCode ");
748 if (props & PR_PREFERUNINSTRUMENTED)
749 pp_string (buffer, "preferUninstrumented ");
750 if (props & PR_EXCEPTIONBLOCK)
751 pp_string (buffer, "exceptionBlock ");
752 if (props & PR_HASELSE)
753 pp_string (buffer, "hasElse ");
754 if (props & PR_READONLY)
755 pp_string (buffer, "readOnly ");
757 pp_right_bracket (buffer);
762 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
763 pp_gimple_stmt_1. */
765 static void
766 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
768 unsigned int i;
770 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
771 if (flags & TDF_RAW)
772 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
773 gimple_switch_index (gs));
774 else
776 pp_string (buffer, "switch (");
777 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
778 pp_string (buffer, ") <");
781 for (i = 0; i < gimple_switch_num_labels (gs); i++)
783 tree case_label = gimple_switch_label (gs, i);
784 gcc_checking_assert (case_label != NULL_TREE);
785 dump_generic_node (buffer, case_label, spc, flags, false);
786 pp_space (buffer);
787 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
788 if (i < gimple_switch_num_labels (gs) - 1)
789 pp_string (buffer, ", ");
791 pp_greater (buffer);
795 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
796 pp_gimple_stmt_1. */
798 static void
799 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
801 if (flags & TDF_RAW)
802 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
803 get_tree_code_name (gimple_cond_code (gs)),
804 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
805 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
806 else
808 if (!(flags & TDF_RHS_ONLY))
809 pp_string (buffer, "if (");
810 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
811 pp_space (buffer);
812 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
813 pp_space (buffer);
814 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
815 if (!(flags & TDF_RHS_ONLY))
817 pp_right_paren (buffer);
819 if (gimple_cond_true_label (gs))
821 pp_string (buffer, " goto ");
822 dump_generic_node (buffer, gimple_cond_true_label (gs),
823 spc, flags, false);
824 pp_semicolon (buffer);
826 if (gimple_cond_false_label (gs))
828 pp_string (buffer, " else goto ");
829 dump_generic_node (buffer, gimple_cond_false_label (gs),
830 spc, flags, false);
831 pp_semicolon (buffer);
838 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
839 spaces of indent. FLAGS specifies details to show in the dump (see
840 TDF_* in dumpfils.h). */
842 static void
843 dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
845 tree label = gimple_label_label (gs);
846 if (flags & TDF_RAW)
847 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
848 else
850 dump_generic_node (buffer, label, spc, flags, false);
851 pp_colon (buffer);
853 if (DECL_NONLOCAL (label))
854 pp_string (buffer, " [non-local]");
855 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
856 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
859 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
860 spaces of indent. FLAGS specifies details to show in the dump (see
861 TDF_* in dumpfile.h). */
863 static void
864 dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
866 tree label = gimple_goto_dest (gs);
867 if (flags & TDF_RAW)
868 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
869 else
870 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
874 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
875 spaces of indent. FLAGS specifies details to show in the dump (see
876 TDF_* in dumpfile.h). */
878 static void
879 dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
881 if (flags & TDF_RAW)
882 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
883 else
884 pp_left_brace (buffer);
885 if (!(flags & TDF_SLIM))
887 tree var;
889 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
891 newline_and_indent (buffer, 2);
892 print_declaration (buffer, var, spc, flags);
894 if (gimple_bind_vars (gs))
895 pp_newline (buffer);
897 pp_newline (buffer);
898 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
899 newline_and_indent (buffer, spc);
900 if (flags & TDF_RAW)
901 pp_greater (buffer);
902 else
903 pp_right_brace (buffer);
907 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
908 indent. FLAGS specifies details to show in the dump (see TDF_* in
909 dumpfile.h). */
911 static void
912 dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
914 if (flags & TDF_RAW)
916 const char *type;
917 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
918 type = "GIMPLE_TRY_CATCH";
919 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
920 type = "GIMPLE_TRY_FINALLY";
921 else
922 type = "UNKNOWN GIMPLE_TRY";
923 dump_gimple_fmt (buffer, spc, flags,
924 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
925 gimple_try_eval (gs), gimple_try_cleanup (gs));
927 else
929 pp_string (buffer, "try");
930 newline_and_indent (buffer, spc + 2);
931 pp_left_brace (buffer);
932 pp_newline (buffer);
934 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
935 newline_and_indent (buffer, spc + 2);
936 pp_right_brace (buffer);
938 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
940 newline_and_indent (buffer, spc);
941 pp_string (buffer, "catch");
942 newline_and_indent (buffer, spc + 2);
943 pp_left_brace (buffer);
945 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
947 newline_and_indent (buffer, spc);
948 pp_string (buffer, "finally");
949 newline_and_indent (buffer, spc + 2);
950 pp_left_brace (buffer);
952 else
953 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
955 pp_newline (buffer);
956 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
957 newline_and_indent (buffer, spc + 2);
958 pp_right_brace (buffer);
963 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
964 indent. FLAGS specifies details to show in the dump (see TDF_* in
965 dumpfile.h). */
967 static void
968 dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
970 if (flags & TDF_RAW)
971 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
972 gimple_catch_types (gs), gimple_catch_handler (gs));
973 else
974 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
975 gimple_catch_types (gs), gimple_catch_handler (gs));
979 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
980 indent. FLAGS specifies details to show in the dump (see TDF_* in
981 dumpfile.h). */
983 static void
984 dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
986 if (flags & TDF_RAW)
987 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
988 gimple_eh_filter_types (gs),
989 gimple_eh_filter_failure (gs));
990 else
991 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
992 gimple_eh_filter_types (gs),
993 gimple_eh_filter_failure (gs));
997 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
999 static void
1000 dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
1001 int spc, int flags)
1003 if (flags & TDF_RAW)
1004 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1005 gimple_eh_must_not_throw_fndecl (gs));
1006 else
1007 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1008 gimple_eh_must_not_throw_fndecl (gs));
1012 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1013 indent. FLAGS specifies details to show in the dump (see TDF_* in
1014 dumpfile.h). */
1016 static void
1017 dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags)
1019 if (flags & TDF_RAW)
1020 dump_gimple_fmt (buffer, spc, flags,
1021 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1022 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1023 else
1024 dump_gimple_fmt (buffer, spc, flags,
1025 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1026 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1030 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1031 indent. FLAGS specifies details to show in the dump (see TDF_* in
1032 dumpfile.h). */
1034 static void
1035 dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
1037 if (flags & TDF_RAW)
1038 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1039 gimple_resx_region (gs));
1040 else
1041 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1044 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1046 static void
1047 dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
1049 if (flags & TDF_RAW)
1050 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1051 gimple_eh_dispatch_region (gs));
1052 else
1053 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1054 gimple_eh_dispatch_region (gs));
1057 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1058 of indent. FLAGS specifies details to show in the dump (see TDF_*
1059 in dumpfile.h). */
1061 static void
1062 dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
1064 switch (gs->gsbase.subcode)
1066 case GIMPLE_DEBUG_BIND:
1067 if (flags & TDF_RAW)
1068 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1069 gimple_debug_bind_get_var (gs),
1070 gimple_debug_bind_get_value (gs));
1071 else
1072 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1073 gimple_debug_bind_get_var (gs),
1074 gimple_debug_bind_get_value (gs));
1075 break;
1077 case GIMPLE_DEBUG_SOURCE_BIND:
1078 if (flags & TDF_RAW)
1079 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1080 gimple_debug_source_bind_get_var (gs),
1081 gimple_debug_source_bind_get_value (gs));
1082 else
1083 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1084 gimple_debug_source_bind_get_var (gs),
1085 gimple_debug_source_bind_get_value (gs));
1086 break;
1088 default:
1089 gcc_unreachable ();
1093 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1094 static void
1095 dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
1097 size_t i;
1099 if (flags & TDF_RAW)
1101 const char *kind;
1102 switch (gimple_omp_for_kind (gs))
1104 case GF_OMP_FOR_KIND_FOR:
1105 kind = "";
1106 break;
1107 case GF_OMP_FOR_KIND_SIMD:
1108 kind = " simd";
1109 break;
1110 case GF_OMP_FOR_KIND_DISTRIBUTE:
1111 kind = " distribute";
1112 break;
1113 default:
1114 gcc_unreachable ();
1116 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1117 kind, gimple_omp_body (gs));
1118 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1119 dump_gimple_fmt (buffer, spc, flags, " >,");
1120 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1121 dump_gimple_fmt (buffer, spc, flags,
1122 "%+%T, %T, %T, %s, %T,%n",
1123 gimple_omp_for_index (gs, i),
1124 gimple_omp_for_initial (gs, i),
1125 gimple_omp_for_final (gs, i),
1126 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1127 gimple_omp_for_incr (gs, i));
1128 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1129 gimple_omp_for_pre_body (gs));
1131 else
1133 switch (gimple_omp_for_kind (gs))
1135 case GF_OMP_FOR_KIND_FOR:
1136 pp_string (buffer, "#pragma omp for");
1137 break;
1138 case GF_OMP_FOR_KIND_SIMD:
1139 pp_string (buffer, "#pragma omp simd");
1140 break;
1141 case GF_OMP_FOR_KIND_DISTRIBUTE:
1142 pp_string (buffer, "#pragma omp distribute");
1143 break;
1144 default:
1145 gcc_unreachable ();
1147 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1148 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1150 if (i)
1151 spc += 2;
1152 newline_and_indent (buffer, spc);
1153 pp_string (buffer, "for (");
1154 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1155 flags, false);
1156 pp_string (buffer, " = ");
1157 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1158 flags, false);
1159 pp_string (buffer, "; ");
1161 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1162 flags, false);
1163 pp_space (buffer);
1164 switch (gimple_omp_for_cond (gs, i))
1166 case LT_EXPR:
1167 pp_less (buffer);
1168 break;
1169 case GT_EXPR:
1170 pp_greater (buffer);
1171 break;
1172 case LE_EXPR:
1173 pp_less_equal (buffer);
1174 break;
1175 case GE_EXPR:
1176 pp_greater_equal (buffer);
1177 break;
1178 default:
1179 gcc_unreachable ();
1181 pp_space (buffer);
1182 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1183 flags, false);
1184 pp_string (buffer, "; ");
1186 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1187 flags, false);
1188 pp_string (buffer, " = ");
1189 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1190 flags, false);
1191 pp_right_paren (buffer);
1194 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1196 newline_and_indent (buffer, spc + 2);
1197 pp_left_brace (buffer);
1198 pp_newline (buffer);
1199 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1200 newline_and_indent (buffer, spc + 2);
1201 pp_right_brace (buffer);
1206 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1208 static void
1209 dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags)
1211 if (flags & TDF_RAW)
1213 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1214 gimple_omp_continue_control_def (gs),
1215 gimple_omp_continue_control_use (gs));
1217 else
1219 pp_string (buffer, "#pragma omp continue (");
1220 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1221 spc, flags, false);
1222 pp_comma (buffer);
1223 pp_space (buffer);
1224 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1225 spc, flags, false);
1226 pp_right_paren (buffer);
1230 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1232 static void
1233 dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, int flags)
1235 if (flags & TDF_RAW)
1237 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1238 gimple_omp_body (gs));
1239 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1240 dump_gimple_fmt (buffer, spc, flags, " >");
1242 else
1244 pp_string (buffer, "#pragma omp single");
1245 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1246 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1248 newline_and_indent (buffer, spc + 2);
1249 pp_left_brace (buffer);
1250 pp_newline (buffer);
1251 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1252 newline_and_indent (buffer, spc + 2);
1253 pp_right_brace (buffer);
1258 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1260 static void
1261 dump_gimple_omp_target (pretty_printer *buffer, gimple gs, int spc, int flags)
1263 const char *kind;
1264 switch (gimple_omp_target_kind (gs))
1266 case GF_OMP_TARGET_KIND_REGION:
1267 kind = "";
1268 break;
1269 case GF_OMP_TARGET_KIND_DATA:
1270 kind = " data";
1271 break;
1272 case GF_OMP_TARGET_KIND_UPDATE:
1273 kind = " update";
1274 break;
1275 default:
1276 gcc_unreachable ();
1278 if (flags & TDF_RAW)
1280 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1281 kind, gimple_omp_body (gs));
1282 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1283 dump_gimple_fmt (buffer, spc, flags, " >");
1285 else
1287 pp_string (buffer, "#pragma omp target");
1288 pp_string (buffer, kind);
1289 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1290 if (gimple_omp_target_child_fn (gs))
1292 pp_string (buffer, " [child fn: ");
1293 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1294 spc, flags, false);
1295 pp_right_bracket (buffer);
1297 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1299 newline_and_indent (buffer, spc + 2);
1300 pp_character (buffer, '{');
1301 pp_newline (buffer);
1302 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1303 newline_and_indent (buffer, spc + 2);
1304 pp_character (buffer, '}');
1309 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1311 static void
1312 dump_gimple_omp_teams (pretty_printer *buffer, gimple gs, int spc, int flags)
1314 if (flags & TDF_RAW)
1316 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1317 gimple_omp_body (gs));
1318 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1319 dump_gimple_fmt (buffer, spc, flags, " >");
1321 else
1323 pp_string (buffer, "#pragma omp teams");
1324 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1325 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1327 newline_and_indent (buffer, spc + 2);
1328 pp_character (buffer, '{');
1329 pp_newline (buffer);
1330 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1331 newline_and_indent (buffer, spc + 2);
1332 pp_character (buffer, '}');
1337 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1339 static void
1340 dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
1341 int flags)
1343 if (flags & TDF_RAW)
1345 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1346 gimple_omp_body (gs));
1347 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1348 dump_gimple_fmt (buffer, spc, flags, " >");
1350 else
1352 pp_string (buffer, "#pragma omp sections");
1353 if (gimple_omp_sections_control (gs))
1355 pp_string (buffer, " <");
1356 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1357 flags, false);
1358 pp_greater (buffer);
1360 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1361 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1363 newline_and_indent (buffer, spc + 2);
1364 pp_left_brace (buffer);
1365 pp_newline (buffer);
1366 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1367 newline_and_indent (buffer, spc + 2);
1368 pp_right_brace (buffer);
1373 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1374 pretty_printer BUFFER. */
1376 static void
1377 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1379 if (flags & TDF_RAW)
1380 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1381 gimple_omp_body (gs));
1382 else
1384 switch (gimple_code (gs))
1386 case GIMPLE_OMP_MASTER:
1387 pp_string (buffer, "#pragma omp master");
1388 break;
1389 case GIMPLE_OMP_TASKGROUP:
1390 pp_string (buffer, "#pragma omp taskgroup");
1391 break;
1392 case GIMPLE_OMP_ORDERED:
1393 pp_string (buffer, "#pragma omp ordered");
1394 break;
1395 case GIMPLE_OMP_SECTION:
1396 pp_string (buffer, "#pragma omp section");
1397 break;
1398 default:
1399 gcc_unreachable ();
1401 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1403 newline_and_indent (buffer, spc + 2);
1404 pp_left_brace (buffer);
1405 pp_newline (buffer);
1406 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1407 newline_and_indent (buffer, spc + 2);
1408 pp_right_brace (buffer);
1413 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1415 static void
1416 dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
1417 int flags)
1419 if (flags & TDF_RAW)
1420 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1421 gimple_omp_body (gs));
1422 else
1424 pp_string (buffer, "#pragma omp critical");
1425 if (gimple_omp_critical_name (gs))
1427 pp_string (buffer, " (");
1428 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1429 flags, false);
1430 pp_right_paren (buffer);
1432 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1434 newline_and_indent (buffer, spc + 2);
1435 pp_left_brace (buffer);
1436 pp_newline (buffer);
1437 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1438 newline_and_indent (buffer, spc + 2);
1439 pp_right_brace (buffer);
1444 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1446 static void
1447 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1449 if (flags & TDF_RAW)
1451 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1452 (int) gimple_omp_return_nowait_p (gs));
1453 if (gimple_omp_return_lhs (gs))
1454 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1455 gimple_omp_return_lhs (gs));
1456 else
1457 dump_gimple_fmt (buffer, spc, flags, ">");
1459 else
1461 pp_string (buffer, "#pragma omp return");
1462 if (gimple_omp_return_nowait_p (gs))
1463 pp_string (buffer, "(nowait)");
1464 if (gimple_omp_return_lhs (gs))
1466 pp_string (buffer, " (set ");
1467 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1468 spc, flags, false);
1469 pp_character (buffer, ')');
1474 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1476 static void
1477 dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags)
1479 unsigned subcode = gimple_transaction_subcode (gs);
1481 if (flags & TDF_RAW)
1483 dump_gimple_fmt (buffer, spc, flags,
1484 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1485 gs, subcode, gimple_transaction_label (gs),
1486 gimple_transaction_body (gs));
1488 else
1490 if (subcode & GTMA_IS_OUTER)
1491 pp_string (buffer, "__transaction_atomic [[outer]]");
1492 else if (subcode & GTMA_IS_RELAXED)
1493 pp_string (buffer, "__transaction_relaxed");
1494 else
1495 pp_string (buffer, "__transaction_atomic");
1496 subcode &= ~GTMA_DECLARATION_MASK;
1498 if (subcode || gimple_transaction_label (gs))
1500 pp_string (buffer, " //");
1501 if (gimple_transaction_label (gs))
1503 pp_string (buffer, " LABEL=");
1504 dump_generic_node (buffer, gimple_transaction_label (gs),
1505 spc, flags, false);
1507 if (subcode)
1509 pp_string (buffer, " SUBCODE=[ ");
1510 if (subcode & GTMA_HAVE_ABORT)
1512 pp_string (buffer, "GTMA_HAVE_ABORT ");
1513 subcode &= ~GTMA_HAVE_ABORT;
1515 if (subcode & GTMA_HAVE_LOAD)
1517 pp_string (buffer, "GTMA_HAVE_LOAD ");
1518 subcode &= ~GTMA_HAVE_LOAD;
1520 if (subcode & GTMA_HAVE_STORE)
1522 pp_string (buffer, "GTMA_HAVE_STORE ");
1523 subcode &= ~GTMA_HAVE_STORE;
1525 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1527 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1528 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1530 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1532 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1533 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1535 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1537 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1538 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1540 if (subcode)
1541 pp_printf (buffer, "0x%x ", subcode);
1542 pp_right_bracket (buffer);
1546 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1548 newline_and_indent (buffer, spc + 2);
1549 pp_left_brace (buffer);
1550 pp_newline (buffer);
1551 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1552 spc + 4, flags);
1553 newline_and_indent (buffer, spc + 2);
1554 pp_right_brace (buffer);
1559 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1560 indent. FLAGS specifies details to show in the dump (see TDF_* in
1561 dumpfile.h). */
1563 static void
1564 dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
1566 unsigned int i, n, f, fields;
1568 if (flags & TDF_RAW)
1570 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1571 gimple_asm_string (gs));
1573 n = gimple_asm_noutputs (gs);
1574 if (n)
1576 newline_and_indent (buffer, spc + 2);
1577 pp_string (buffer, "OUTPUT: ");
1578 for (i = 0; i < n; i++)
1580 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1581 spc, flags, false);
1582 if (i < n - 1)
1583 pp_string (buffer, ", ");
1587 n = gimple_asm_ninputs (gs);
1588 if (n)
1590 newline_and_indent (buffer, spc + 2);
1591 pp_string (buffer, "INPUT: ");
1592 for (i = 0; i < n; i++)
1594 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1595 spc, flags, false);
1596 if (i < n - 1)
1597 pp_string (buffer, ", ");
1601 n = gimple_asm_nclobbers (gs);
1602 if (n)
1604 newline_and_indent (buffer, spc + 2);
1605 pp_string (buffer, "CLOBBER: ");
1606 for (i = 0; i < n; i++)
1608 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1609 spc, flags, false);
1610 if (i < n - 1)
1611 pp_string (buffer, ", ");
1615 n = gimple_asm_nlabels (gs);
1616 if (n)
1618 newline_and_indent (buffer, spc + 2);
1619 pp_string (buffer, "LABEL: ");
1620 for (i = 0; i < n; i++)
1622 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1623 spc, flags, false);
1624 if (i < n - 1)
1625 pp_string (buffer, ", ");
1629 newline_and_indent (buffer, spc);
1630 pp_greater (buffer);
1632 else
1634 pp_string (buffer, "__asm__");
1635 if (gimple_asm_volatile_p (gs))
1636 pp_string (buffer, " __volatile__");
1637 if (gimple_asm_nlabels (gs))
1638 pp_string (buffer, " goto");
1639 pp_string (buffer, "(\"");
1640 pp_string (buffer, gimple_asm_string (gs));
1641 pp_string (buffer, "\"");
1643 if (gimple_asm_nlabels (gs))
1644 fields = 4;
1645 else if (gimple_asm_nclobbers (gs))
1646 fields = 3;
1647 else if (gimple_asm_ninputs (gs))
1648 fields = 2;
1649 else if (gimple_asm_noutputs (gs))
1650 fields = 1;
1651 else
1652 fields = 0;
1654 for (f = 0; f < fields; ++f)
1656 pp_string (buffer, " : ");
1658 switch (f)
1660 case 0:
1661 n = gimple_asm_noutputs (gs);
1662 for (i = 0; i < n; i++)
1664 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1665 spc, flags, false);
1666 if (i < n - 1)
1667 pp_string (buffer, ", ");
1669 break;
1671 case 1:
1672 n = gimple_asm_ninputs (gs);
1673 for (i = 0; i < n; i++)
1675 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1676 spc, flags, false);
1677 if (i < n - 1)
1678 pp_string (buffer, ", ");
1680 break;
1682 case 2:
1683 n = gimple_asm_nclobbers (gs);
1684 for (i = 0; i < n; i++)
1686 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1687 spc, flags, false);
1688 if (i < n - 1)
1689 pp_string (buffer, ", ");
1691 break;
1693 case 3:
1694 n = gimple_asm_nlabels (gs);
1695 for (i = 0; i < n; i++)
1697 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1698 spc, flags, false);
1699 if (i < n - 1)
1700 pp_string (buffer, ", ");
1702 break;
1704 default:
1705 gcc_unreachable ();
1709 pp_string (buffer, ");");
1713 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1714 SPC spaces of indent. */
1716 static void
1717 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1719 if (TREE_CODE (node) != SSA_NAME)
1720 return;
1722 if (POINTER_TYPE_P (TREE_TYPE (node))
1723 && SSA_NAME_PTR_INFO (node))
1725 unsigned int align, misalign;
1726 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1727 pp_string (buffer, "# PT = ");
1728 pp_points_to_solution (buffer, &pi->pt);
1729 newline_and_indent (buffer, spc);
1730 if (get_ptr_info_alignment (pi, &align, &misalign))
1732 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1733 newline_and_indent (buffer, spc);
1737 if (!POINTER_TYPE_P (TREE_TYPE (node))
1738 && SSA_NAME_RANGE_INFO (node))
1740 double_int min, max, nonzero_bits;
1741 value_range_type range_type = get_range_info (node, &min, &max);
1743 if (range_type == VR_VARYING)
1744 pp_printf (buffer, "# RANGE VR_VARYING");
1745 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1747 pp_printf (buffer, "# RANGE ");
1748 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1749 pp_double_int (buffer, min, TYPE_UNSIGNED (TREE_TYPE (node)));
1750 pp_printf (buffer, ", ");
1751 pp_double_int (buffer, max, TYPE_UNSIGNED (TREE_TYPE (node)));
1752 pp_printf (buffer, "]");
1754 nonzero_bits = get_nonzero_bits (node);
1755 if (nonzero_bits != double_int_minus_one
1756 && (nonzero_bits
1757 != double_int::mask (TYPE_PRECISION (TREE_TYPE (node)))))
1759 pp_string (buffer, " NONZERO ");
1760 sprintf (pp_buffer (buffer)->digit_buffer,
1761 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
1762 (unsigned HOST_WIDE_INT) nonzero_bits.high,
1763 nonzero_bits.low);
1764 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
1766 newline_and_indent (buffer, spc);
1771 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1772 The caller is responsible for calling pp_flush on BUFFER to finalize
1773 pretty printer. If COMMENT is true, print this after #. */
1775 static void
1776 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, bool comment,
1777 int flags)
1779 size_t i;
1780 tree lhs = gimple_phi_result (phi);
1782 if (flags & TDF_ALIAS)
1783 dump_ssaname_info (buffer, lhs, spc);
1785 if (comment)
1786 pp_string (buffer, "# ");
1788 if (flags & TDF_RAW)
1789 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1790 gimple_phi_result (phi));
1791 else
1793 dump_generic_node (buffer, lhs, spc, flags, false);
1794 pp_string (buffer, " = PHI <");
1796 for (i = 0; i < gimple_phi_num_args (phi); i++)
1798 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1800 expanded_location xloc;
1802 xloc = expand_location (gimple_phi_arg_location (phi, i));
1803 pp_left_bracket (buffer);
1804 if (xloc.file)
1806 pp_string (buffer, xloc.file);
1807 pp_string (buffer, " : ");
1809 pp_decimal_int (buffer, xloc.line);
1810 pp_colon (buffer);
1811 pp_decimal_int (buffer, xloc.column);
1812 pp_string (buffer, "] ");
1814 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1815 false);
1816 pp_left_paren (buffer);
1817 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1818 pp_right_paren (buffer);
1819 if (i < gimple_phi_num_args (phi) - 1)
1820 pp_string (buffer, ", ");
1822 pp_greater (buffer);
1826 /* Dump a GIMPLE_OACC_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1827 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1828 dumpfile.h). */
1830 static void
1831 dump_gimple_oacc_parallel (pretty_printer *buffer, gimple gs, int spc,
1832 int flags)
1834 if (flags & TDF_RAW)
1836 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1837 gimple_omp_body (gs));
1838 dump_omp_clauses (buffer, gimple_oacc_parallel_clauses (gs), spc, flags);
1839 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1840 gimple_oacc_parallel_child_fn (gs),
1841 gimple_oacc_parallel_data_arg (gs));
1843 else
1845 gimple_seq body;
1846 pp_string (buffer, "#pragma acc parallel");
1847 dump_omp_clauses (buffer, gimple_oacc_parallel_clauses (gs), spc, flags);
1848 if (gimple_oacc_parallel_child_fn (gs))
1850 pp_string (buffer, " [child fn: ");
1851 dump_generic_node (buffer, gimple_oacc_parallel_child_fn (gs),
1852 spc, flags, false);
1853 pp_string (buffer, " (");
1854 if (gimple_oacc_parallel_data_arg (gs))
1855 dump_generic_node (buffer, gimple_oacc_parallel_data_arg (gs),
1856 spc, flags, false);
1857 else
1858 pp_string (buffer, "???");
1859 pp_string (buffer, ")]");
1861 body = gimple_omp_body (gs);
1862 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1864 newline_and_indent (buffer, spc + 2);
1865 pp_left_brace (buffer);
1866 pp_newline (buffer);
1867 dump_gimple_seq (buffer, body, spc + 4, flags);
1868 newline_and_indent (buffer, spc + 2);
1869 pp_right_brace (buffer);
1871 else if (body)
1873 pp_newline (buffer);
1874 dump_gimple_seq (buffer, body, spc + 2, flags);
1880 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1881 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1882 dumpfile.h). */
1884 static void
1885 dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1886 int flags)
1888 if (flags & TDF_RAW)
1890 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1891 gimple_omp_body (gs));
1892 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1893 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1894 gimple_omp_parallel_child_fn (gs),
1895 gimple_omp_parallel_data_arg (gs));
1897 else
1899 gimple_seq body;
1900 pp_string (buffer, "#pragma omp parallel");
1901 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1902 if (gimple_omp_parallel_child_fn (gs))
1904 pp_string (buffer, " [child fn: ");
1905 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1906 spc, flags, false);
1907 pp_string (buffer, " (");
1908 if (gimple_omp_parallel_data_arg (gs))
1909 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1910 spc, flags, false);
1911 else
1912 pp_string (buffer, "???");
1913 pp_string (buffer, ")]");
1915 body = gimple_omp_body (gs);
1916 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1918 newline_and_indent (buffer, spc + 2);
1919 pp_left_brace (buffer);
1920 pp_newline (buffer);
1921 dump_gimple_seq (buffer, body, spc + 4, flags);
1922 newline_and_indent (buffer, spc + 2);
1923 pp_right_brace (buffer);
1925 else if (body)
1927 pp_newline (buffer);
1928 dump_gimple_seq (buffer, body, spc + 2, flags);
1934 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1935 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1936 dumpfile.h). */
1938 static void
1939 dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
1940 int flags)
1942 if (flags & TDF_RAW)
1944 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1945 gimple_omp_body (gs));
1946 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1947 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1948 gimple_omp_task_child_fn (gs),
1949 gimple_omp_task_data_arg (gs),
1950 gimple_omp_task_copy_fn (gs),
1951 gimple_omp_task_arg_size (gs),
1952 gimple_omp_task_arg_size (gs));
1954 else
1956 gimple_seq body;
1957 pp_string (buffer, "#pragma omp task");
1958 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1959 if (gimple_omp_task_child_fn (gs))
1961 pp_string (buffer, " [child fn: ");
1962 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1963 spc, flags, false);
1964 pp_string (buffer, " (");
1965 if (gimple_omp_task_data_arg (gs))
1966 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1967 spc, flags, false);
1968 else
1969 pp_string (buffer, "???");
1970 pp_string (buffer, ")]");
1972 body = gimple_omp_body (gs);
1973 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1975 newline_and_indent (buffer, spc + 2);
1976 pp_left_brace (buffer);
1977 pp_newline (buffer);
1978 dump_gimple_seq (buffer, body, spc + 4, flags);
1979 newline_and_indent (buffer, spc + 2);
1980 pp_right_brace (buffer);
1982 else if (body)
1984 pp_newline (buffer);
1985 dump_gimple_seq (buffer, body, spc + 2, flags);
1991 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1992 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1993 in dumpfile.h). */
1995 static void
1996 dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
1997 int flags)
1999 if (flags & TDF_RAW)
2001 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2002 gimple_omp_atomic_load_lhs (gs),
2003 gimple_omp_atomic_load_rhs (gs));
2005 else
2007 pp_string (buffer, "#pragma omp atomic_load");
2008 if (gimple_omp_atomic_seq_cst_p (gs))
2009 pp_string (buffer, " seq_cst");
2010 if (gimple_omp_atomic_need_value_p (gs))
2011 pp_string (buffer, " [needed]");
2012 newline_and_indent (buffer, spc + 2);
2013 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2014 spc, flags, false);
2015 pp_space (buffer);
2016 pp_equal (buffer);
2017 pp_space (buffer);
2018 pp_star (buffer);
2019 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2020 spc, flags, false);
2024 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2025 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
2026 in dumpfile.h). */
2028 static void
2029 dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
2030 int flags)
2032 if (flags & TDF_RAW)
2034 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2035 gimple_omp_atomic_store_val (gs));
2037 else
2039 pp_string (buffer, "#pragma omp atomic_store ");
2040 if (gimple_omp_atomic_seq_cst_p (gs))
2041 pp_string (buffer, "seq_cst ");
2042 if (gimple_omp_atomic_need_value_p (gs))
2043 pp_string (buffer, "[needed] ");
2044 pp_left_paren (buffer);
2045 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2046 spc, flags, false);
2047 pp_right_paren (buffer);
2052 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2053 FLAGS are as in pp_gimple_stmt_1. */
2055 static void
2056 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
2058 tree vdef = gimple_vdef (gs);
2059 tree vuse = gimple_vuse (gs);
2061 if (!ssa_operands_active (DECL_STRUCT_FUNCTION (current_function_decl))
2062 || !gimple_references_memory_p (gs))
2063 return;
2065 if (vdef != NULL_TREE)
2067 pp_string (buffer, "# ");
2068 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2069 pp_string (buffer, " = VDEF <");
2070 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2071 pp_greater (buffer);
2072 newline_and_indent (buffer, spc);
2074 else if (vuse != NULL_TREE)
2076 pp_string (buffer, "# VUSE <");
2077 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2078 pp_greater (buffer);
2079 newline_and_indent (buffer, spc);
2084 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2085 spaces of indent. FLAGS specifies details to show in the dump (see
2086 TDF_* in dumpfile.h). The caller is responsible for calling
2087 pp_flush on BUFFER to finalize the pretty printer. */
2089 void
2090 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
2092 if (!gs)
2093 return;
2095 if (flags & TDF_STMTADDR)
2096 pp_printf (buffer, "<&%p> ", (void *) gs);
2098 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2100 expanded_location xloc = expand_location (gimple_location (gs));
2101 pp_left_bracket (buffer);
2102 if (xloc.file)
2104 pp_string (buffer, xloc.file);
2105 pp_string (buffer, " : ");
2107 pp_decimal_int (buffer, xloc.line);
2108 pp_colon (buffer);
2109 pp_decimal_int (buffer, xloc.column);
2110 pp_string (buffer, "] ");
2113 if (flags & TDF_EH)
2115 int lp_nr = lookup_stmt_eh_lp (gs);
2116 if (lp_nr > 0)
2117 pp_printf (buffer, "[LP %d] ", lp_nr);
2118 else if (lp_nr < 0)
2119 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2122 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2123 && gimple_has_mem_ops (gs))
2124 dump_gimple_mem_ops (buffer, gs, spc, flags);
2126 if (gimple_has_lhs (gs)
2127 && (flags & TDF_ALIAS))
2128 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2130 switch (gimple_code (gs))
2132 case GIMPLE_ASM:
2133 dump_gimple_asm (buffer, gs, spc, flags);
2134 break;
2136 case GIMPLE_ASSIGN:
2137 dump_gimple_assign (buffer, gs, spc, flags);
2138 break;
2140 case GIMPLE_BIND:
2141 dump_gimple_bind (buffer, gs, spc, flags);
2142 break;
2144 case GIMPLE_CALL:
2145 dump_gimple_call (buffer, gs, spc, flags);
2146 break;
2148 case GIMPLE_COND:
2149 dump_gimple_cond (buffer, gs, spc, flags);
2150 break;
2152 case GIMPLE_LABEL:
2153 dump_gimple_label (buffer, gs, spc, flags);
2154 break;
2156 case GIMPLE_GOTO:
2157 dump_gimple_goto (buffer, gs, spc, flags);
2158 break;
2160 case GIMPLE_NOP:
2161 pp_string (buffer, "GIMPLE_NOP");
2162 break;
2164 case GIMPLE_RETURN:
2165 dump_gimple_return (buffer, gs, spc, flags);
2166 break;
2168 case GIMPLE_SWITCH:
2169 dump_gimple_switch (buffer, gs, spc, flags);
2170 break;
2172 case GIMPLE_TRY:
2173 dump_gimple_try (buffer, gs, spc, flags);
2174 break;
2176 case GIMPLE_PHI:
2177 dump_gimple_phi (buffer, gs, spc, false, flags);
2178 break;
2180 case GIMPLE_OACC_PARALLEL:
2181 dump_gimple_oacc_parallel (buffer, gs, spc, flags);
2182 break;
2184 case GIMPLE_OMP_PARALLEL:
2185 dump_gimple_omp_parallel (buffer, gs, spc, flags);
2186 break;
2188 case GIMPLE_OMP_TASK:
2189 dump_gimple_omp_task (buffer, gs, spc, flags);
2190 break;
2192 case GIMPLE_OMP_ATOMIC_LOAD:
2193 dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
2195 break;
2197 case GIMPLE_OMP_ATOMIC_STORE:
2198 dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
2199 break;
2201 case GIMPLE_OMP_FOR:
2202 dump_gimple_omp_for (buffer, gs, spc, flags);
2203 break;
2205 case GIMPLE_OMP_CONTINUE:
2206 dump_gimple_omp_continue (buffer, gs, spc, flags);
2207 break;
2209 case GIMPLE_OMP_SINGLE:
2210 dump_gimple_omp_single (buffer, gs, spc, flags);
2211 break;
2213 case GIMPLE_OMP_TARGET:
2214 dump_gimple_omp_target (buffer, gs, spc, flags);
2215 break;
2217 case GIMPLE_OMP_TEAMS:
2218 dump_gimple_omp_teams (buffer, gs, spc, flags);
2219 break;
2221 case GIMPLE_OMP_RETURN:
2222 dump_gimple_omp_return (buffer, gs, spc, flags);
2223 break;
2225 case GIMPLE_OMP_SECTIONS:
2226 dump_gimple_omp_sections (buffer, gs, spc, flags);
2227 break;
2229 case GIMPLE_OMP_SECTIONS_SWITCH:
2230 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2231 break;
2233 case GIMPLE_OMP_MASTER:
2234 case GIMPLE_OMP_TASKGROUP:
2235 case GIMPLE_OMP_ORDERED:
2236 case GIMPLE_OMP_SECTION:
2237 dump_gimple_omp_block (buffer, gs, spc, flags);
2238 break;
2240 case GIMPLE_OMP_CRITICAL:
2241 dump_gimple_omp_critical (buffer, gs, spc, flags);
2242 break;
2244 case GIMPLE_CATCH:
2245 dump_gimple_catch (buffer, gs, spc, flags);
2246 break;
2248 case GIMPLE_EH_FILTER:
2249 dump_gimple_eh_filter (buffer, gs, spc, flags);
2250 break;
2252 case GIMPLE_EH_MUST_NOT_THROW:
2253 dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
2254 break;
2256 case GIMPLE_EH_ELSE:
2257 dump_gimple_eh_else (buffer, gs, spc, flags);
2258 break;
2260 case GIMPLE_RESX:
2261 dump_gimple_resx (buffer, gs, spc, flags);
2262 break;
2264 case GIMPLE_EH_DISPATCH:
2265 dump_gimple_eh_dispatch (buffer, gs, spc, flags);
2266 break;
2268 case GIMPLE_DEBUG:
2269 dump_gimple_debug (buffer, gs, spc, flags);
2270 break;
2272 case GIMPLE_PREDICT:
2273 pp_string (buffer, "// predicted ");
2274 if (gimple_predict_outcome (gs))
2275 pp_string (buffer, "likely by ");
2276 else
2277 pp_string (buffer, "unlikely by ");
2278 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2279 pp_string (buffer, " predictor.");
2280 break;
2282 case GIMPLE_TRANSACTION:
2283 dump_gimple_transaction (buffer, gs, spc, flags);
2284 break;
2286 default:
2287 GIMPLE_NIY;
2292 /* Dumps header of basic block BB to OUTF indented by INDENT
2293 spaces and details described by flags. */
2295 static void
2296 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2298 if (flags & TDF_BLOCKS)
2300 if (flags & TDF_LINENO)
2302 gimple_stmt_iterator gsi;
2304 if (flags & TDF_COMMENT)
2305 fputs (";; ", outf);
2307 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2308 if (!is_gimple_debug (gsi_stmt (gsi))
2309 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2311 fprintf (outf, "%*sstarting at line %d",
2312 indent, "", get_lineno (gsi_stmt (gsi)));
2313 break;
2315 if (bb->discriminator)
2316 fprintf (outf, ", discriminator %i", bb->discriminator);
2317 fputc ('\n', outf);
2320 else
2322 gimple stmt = first_stmt (bb);
2323 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2324 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2329 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2330 spaces. */
2332 static void
2333 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2334 basic_block bb ATTRIBUTE_UNUSED,
2335 int indent ATTRIBUTE_UNUSED,
2336 int flags ATTRIBUTE_UNUSED)
2338 /* There is currently no GIMPLE-specific basic block info to dump. */
2339 return;
2343 /* Dump PHI nodes of basic block BB to BUFFER with details described
2344 by FLAGS and indented by INDENT spaces. */
2346 static void
2347 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2349 gimple_stmt_iterator i;
2351 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2353 gimple phi = gsi_stmt (i);
2354 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2356 INDENT (indent);
2357 dump_gimple_phi (buffer, phi, indent, true, flags);
2358 pp_newline (buffer);
2364 /* Dump jump to basic block BB that is represented implicitly in the cfg
2365 to BUFFER. */
2367 static void
2368 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2370 gimple stmt;
2372 stmt = first_stmt (bb);
2374 pp_string (buffer, "goto <bb ");
2375 pp_decimal_int (buffer, bb->index);
2376 pp_greater (buffer);
2377 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2379 pp_string (buffer, " (");
2380 dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
2381 pp_right_paren (buffer);
2382 pp_semicolon (buffer);
2384 else
2385 pp_semicolon (buffer);
2389 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2390 by INDENT spaces, with details given by FLAGS. */
2392 static void
2393 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2394 int flags)
2396 edge e;
2397 gimple stmt;
2399 stmt = last_stmt (bb);
2401 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2403 edge true_edge, false_edge;
2405 /* When we are emitting the code or changing CFG, it is possible that
2406 the edges are not yet created. When we are using debug_bb in such
2407 a situation, we do not want it to crash. */
2408 if (EDGE_COUNT (bb->succs) != 2)
2409 return;
2410 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2412 INDENT (indent + 2);
2413 pp_cfg_jump (buffer, true_edge->dest);
2414 newline_and_indent (buffer, indent);
2415 pp_string (buffer, "else");
2416 newline_and_indent (buffer, indent + 2);
2417 pp_cfg_jump (buffer, false_edge->dest);
2418 pp_newline (buffer);
2419 return;
2422 /* If there is a fallthru edge, we may need to add an artificial
2423 goto to the dump. */
2424 e = find_fallthru_edge (bb->succs);
2426 if (e && e->dest != bb->next_bb)
2428 INDENT (indent);
2430 if ((flags & TDF_LINENO)
2431 && e->goto_locus != UNKNOWN_LOCATION
2434 expanded_location goto_xloc;
2435 goto_xloc = expand_location (e->goto_locus);
2436 pp_left_bracket (buffer);
2437 if (goto_xloc.file)
2439 pp_string (buffer, goto_xloc.file);
2440 pp_string (buffer, " : ");
2442 pp_decimal_int (buffer, goto_xloc.line);
2443 pp_string (buffer, " : ");
2444 pp_decimal_int (buffer, goto_xloc.column);
2445 pp_string (buffer, "] ");
2448 pp_cfg_jump (buffer, e->dest);
2449 pp_newline (buffer);
2454 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2455 indented by INDENT spaces. */
2457 static void
2458 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2459 int flags)
2461 gimple_stmt_iterator gsi;
2462 gimple stmt;
2463 int label_indent = indent - 2;
2465 if (label_indent < 0)
2466 label_indent = 0;
2468 dump_phi_nodes (buffer, bb, indent, flags);
2470 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2472 int curr_indent;
2474 stmt = gsi_stmt (gsi);
2476 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2478 INDENT (curr_indent);
2479 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2480 pp_newline_and_flush (buffer);
2481 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2482 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2483 pp_buffer (buffer)->stream, stmt);
2486 dump_implicit_edges (buffer, bb, indent, flags);
2487 pp_flush (buffer);
2491 /* Dumps basic block BB to FILE with details described by FLAGS and
2492 indented by INDENT spaces. */
2494 void
2495 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2497 dump_gimple_bb_header (file, bb, indent, flags);
2498 if (bb->index >= NUM_FIXED_BLOCKS)
2500 pretty_printer buffer;
2501 pp_needs_newline (&buffer) = true;
2502 buffer.buffer->stream = file;
2503 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2505 dump_gimple_bb_footer (file, bb, indent, flags);
2508 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2509 no indentation, for use as a label of a DOT graph record-node.
2510 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2511 histogram dumping doesn't know about pretty-printers. */
2513 void
2514 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2516 gimple_stmt_iterator gsi;
2518 pp_printf (pp, "<bb %d>:\n", bb->index);
2519 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2521 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2523 gimple phi = gsi_stmt (gsi);
2524 if (!virtual_operand_p (gimple_phi_result (phi))
2525 || (dump_flags & TDF_VOPS))
2527 pp_bar (pp);
2528 pp_write_text_to_stream (pp);
2529 pp_string (pp, "# ");
2530 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2531 pp_newline (pp);
2532 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2536 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2538 gimple stmt = gsi_stmt (gsi);
2539 pp_bar (pp);
2540 pp_write_text_to_stream (pp);
2541 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2542 pp_newline (pp);
2543 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2545 dump_implicit_edges (pp, bb, 0, dump_flags);
2546 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);