2013-10-30 Balaji V. Iyer <balaji.v.iyer@intel.com>
[official-gcc.git] / gcc / gimple-pretty-print.c
blob248dfea01af449b5aeb4b672eb3c259df476760f
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;
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, "]");
1753 newline_and_indent (buffer, spc);
1759 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1760 The caller is responsible for calling pp_flush on BUFFER to finalize
1761 pretty printer. If COMMENT is true, print this after #. */
1763 static void
1764 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, bool comment,
1765 int flags)
1767 size_t i;
1768 tree lhs = gimple_phi_result (phi);
1770 if (flags & TDF_ALIAS)
1771 dump_ssaname_info (buffer, lhs, spc);
1773 if (comment)
1774 pp_string (buffer, "# ");
1776 if (flags & TDF_RAW)
1777 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1778 gimple_phi_result (phi));
1779 else
1781 dump_generic_node (buffer, lhs, spc, flags, false);
1782 pp_string (buffer, " = PHI <");
1784 for (i = 0; i < gimple_phi_num_args (phi); i++)
1786 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1788 expanded_location xloc;
1790 xloc = expand_location (gimple_phi_arg_location (phi, i));
1791 pp_left_bracket (buffer);
1792 if (xloc.file)
1794 pp_string (buffer, xloc.file);
1795 pp_string (buffer, " : ");
1797 pp_decimal_int (buffer, xloc.line);
1798 pp_colon (buffer);
1799 pp_decimal_int (buffer, xloc.column);
1800 pp_string (buffer, "] ");
1802 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1803 false);
1804 pp_left_paren (buffer);
1805 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1806 pp_right_paren (buffer);
1807 if (i < gimple_phi_num_args (phi) - 1)
1808 pp_string (buffer, ", ");
1810 pp_greater (buffer);
1814 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1815 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1816 dumpfile.h). */
1818 static void
1819 dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1820 int flags)
1822 if (flags & TDF_RAW)
1824 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1825 gimple_omp_body (gs));
1826 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1827 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1828 gimple_omp_parallel_child_fn (gs),
1829 gimple_omp_parallel_data_arg (gs));
1831 else
1833 gimple_seq body;
1834 pp_string (buffer, "#pragma omp parallel");
1835 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1836 if (gimple_omp_parallel_child_fn (gs))
1838 pp_string (buffer, " [child fn: ");
1839 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1840 spc, flags, false);
1841 pp_string (buffer, " (");
1842 if (gimple_omp_parallel_data_arg (gs))
1843 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1844 spc, flags, false);
1845 else
1846 pp_string (buffer, "???");
1847 pp_string (buffer, ")]");
1849 body = gimple_omp_body (gs);
1850 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1852 newline_and_indent (buffer, spc + 2);
1853 pp_left_brace (buffer);
1854 pp_newline (buffer);
1855 dump_gimple_seq (buffer, body, spc + 4, flags);
1856 newline_and_indent (buffer, spc + 2);
1857 pp_right_brace (buffer);
1859 else if (body)
1861 pp_newline (buffer);
1862 dump_gimple_seq (buffer, body, spc + 2, flags);
1868 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1869 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1870 dumpfile.h). */
1872 static void
1873 dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
1874 int flags)
1876 if (flags & TDF_RAW)
1878 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1879 gimple_omp_body (gs));
1880 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1881 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1882 gimple_omp_task_child_fn (gs),
1883 gimple_omp_task_data_arg (gs),
1884 gimple_omp_task_copy_fn (gs),
1885 gimple_omp_task_arg_size (gs),
1886 gimple_omp_task_arg_size (gs));
1888 else
1890 gimple_seq body;
1891 pp_string (buffer, "#pragma omp task");
1892 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1893 if (gimple_omp_task_child_fn (gs))
1895 pp_string (buffer, " [child fn: ");
1896 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1897 spc, flags, false);
1898 pp_string (buffer, " (");
1899 if (gimple_omp_task_data_arg (gs))
1900 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1901 spc, flags, false);
1902 else
1903 pp_string (buffer, "???");
1904 pp_string (buffer, ")]");
1906 body = gimple_omp_body (gs);
1907 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1909 newline_and_indent (buffer, spc + 2);
1910 pp_left_brace (buffer);
1911 pp_newline (buffer);
1912 dump_gimple_seq (buffer, body, spc + 4, flags);
1913 newline_and_indent (buffer, spc + 2);
1914 pp_right_brace (buffer);
1916 else if (body)
1918 pp_newline (buffer);
1919 dump_gimple_seq (buffer, body, spc + 2, flags);
1925 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1926 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1927 in dumpfile.h). */
1929 static void
1930 dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
1931 int flags)
1933 if (flags & TDF_RAW)
1935 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1936 gimple_omp_atomic_load_lhs (gs),
1937 gimple_omp_atomic_load_rhs (gs));
1939 else
1941 pp_string (buffer, "#pragma omp atomic_load");
1942 if (gimple_omp_atomic_seq_cst_p (gs))
1943 pp_string (buffer, " seq_cst");
1944 if (gimple_omp_atomic_need_value_p (gs))
1945 pp_string (buffer, " [needed]");
1946 newline_and_indent (buffer, spc + 2);
1947 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
1948 spc, flags, false);
1949 pp_space (buffer);
1950 pp_equal (buffer);
1951 pp_space (buffer);
1952 pp_star (buffer);
1953 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
1954 spc, flags, false);
1958 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1959 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1960 in dumpfile.h). */
1962 static void
1963 dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
1964 int flags)
1966 if (flags & TDF_RAW)
1968 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1969 gimple_omp_atomic_store_val (gs));
1971 else
1973 pp_string (buffer, "#pragma omp atomic_store ");
1974 if (gimple_omp_atomic_seq_cst_p (gs))
1975 pp_string (buffer, "seq_cst ");
1976 if (gimple_omp_atomic_need_value_p (gs))
1977 pp_string (buffer, "[needed] ");
1978 pp_left_paren (buffer);
1979 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
1980 spc, flags, false);
1981 pp_right_paren (buffer);
1986 /* Dump all the memory operands for statement GS. BUFFER, SPC and
1987 FLAGS are as in pp_gimple_stmt_1. */
1989 static void
1990 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
1992 tree vdef = gimple_vdef (gs);
1993 tree vuse = gimple_vuse (gs);
1995 if (!ssa_operands_active (DECL_STRUCT_FUNCTION (current_function_decl))
1996 || !gimple_references_memory_p (gs))
1997 return;
1999 if (vdef != NULL_TREE)
2001 pp_string (buffer, "# ");
2002 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2003 pp_string (buffer, " = VDEF <");
2004 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2005 pp_greater (buffer);
2006 newline_and_indent (buffer, spc);
2008 else if (vuse != NULL_TREE)
2010 pp_string (buffer, "# VUSE <");
2011 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2012 pp_greater (buffer);
2013 newline_and_indent (buffer, spc);
2018 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2019 spaces of indent. FLAGS specifies details to show in the dump (see
2020 TDF_* in dumpfile.h). The caller is responsible for calling
2021 pp_flush on BUFFER to finalize the pretty printer. */
2023 void
2024 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
2026 if (!gs)
2027 return;
2029 if (flags & TDF_STMTADDR)
2030 pp_printf (buffer, "<&%p> ", (void *) gs);
2032 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2034 expanded_location xloc = expand_location (gimple_location (gs));
2035 pp_left_bracket (buffer);
2036 if (xloc.file)
2038 pp_string (buffer, xloc.file);
2039 pp_string (buffer, " : ");
2041 pp_decimal_int (buffer, xloc.line);
2042 pp_colon (buffer);
2043 pp_decimal_int (buffer, xloc.column);
2044 pp_string (buffer, "] ");
2047 if (flags & TDF_EH)
2049 int lp_nr = lookup_stmt_eh_lp (gs);
2050 if (lp_nr > 0)
2051 pp_printf (buffer, "[LP %d] ", lp_nr);
2052 else if (lp_nr < 0)
2053 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2056 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2057 && gimple_has_mem_ops (gs))
2058 dump_gimple_mem_ops (buffer, gs, spc, flags);
2060 if (gimple_has_lhs (gs)
2061 && (flags & TDF_ALIAS))
2062 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2064 switch (gimple_code (gs))
2066 case GIMPLE_ASM:
2067 dump_gimple_asm (buffer, gs, spc, flags);
2068 break;
2070 case GIMPLE_ASSIGN:
2071 dump_gimple_assign (buffer, gs, spc, flags);
2072 break;
2074 case GIMPLE_BIND:
2075 dump_gimple_bind (buffer, gs, spc, flags);
2076 break;
2078 case GIMPLE_CALL:
2079 dump_gimple_call (buffer, gs, spc, flags);
2080 break;
2082 case GIMPLE_COND:
2083 dump_gimple_cond (buffer, gs, spc, flags);
2084 break;
2086 case GIMPLE_LABEL:
2087 dump_gimple_label (buffer, gs, spc, flags);
2088 break;
2090 case GIMPLE_GOTO:
2091 dump_gimple_goto (buffer, gs, spc, flags);
2092 break;
2094 case GIMPLE_NOP:
2095 pp_string (buffer, "GIMPLE_NOP");
2096 break;
2098 case GIMPLE_RETURN:
2099 dump_gimple_return (buffer, gs, spc, flags);
2100 break;
2102 case GIMPLE_SWITCH:
2103 dump_gimple_switch (buffer, gs, spc, flags);
2104 break;
2106 case GIMPLE_TRY:
2107 dump_gimple_try (buffer, gs, spc, flags);
2108 break;
2110 case GIMPLE_PHI:
2111 dump_gimple_phi (buffer, gs, spc, false, flags);
2112 break;
2114 case GIMPLE_OMP_PARALLEL:
2115 dump_gimple_omp_parallel (buffer, gs, spc, flags);
2116 break;
2118 case GIMPLE_OMP_TASK:
2119 dump_gimple_omp_task (buffer, gs, spc, flags);
2120 break;
2122 case GIMPLE_OMP_ATOMIC_LOAD:
2123 dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
2125 break;
2127 case GIMPLE_OMP_ATOMIC_STORE:
2128 dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
2129 break;
2131 case GIMPLE_OMP_FOR:
2132 dump_gimple_omp_for (buffer, gs, spc, flags);
2133 break;
2135 case GIMPLE_OMP_CONTINUE:
2136 dump_gimple_omp_continue (buffer, gs, spc, flags);
2137 break;
2139 case GIMPLE_OMP_SINGLE:
2140 dump_gimple_omp_single (buffer, gs, spc, flags);
2141 break;
2143 case GIMPLE_OMP_TARGET:
2144 dump_gimple_omp_target (buffer, gs, spc, flags);
2145 break;
2147 case GIMPLE_OMP_TEAMS:
2148 dump_gimple_omp_teams (buffer, gs, spc, flags);
2149 break;
2151 case GIMPLE_OMP_RETURN:
2152 dump_gimple_omp_return (buffer, gs, spc, flags);
2153 break;
2155 case GIMPLE_OMP_SECTIONS:
2156 dump_gimple_omp_sections (buffer, gs, spc, flags);
2157 break;
2159 case GIMPLE_OMP_SECTIONS_SWITCH:
2160 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2161 break;
2163 case GIMPLE_OMP_MASTER:
2164 case GIMPLE_OMP_TASKGROUP:
2165 case GIMPLE_OMP_ORDERED:
2166 case GIMPLE_OMP_SECTION:
2167 dump_gimple_omp_block (buffer, gs, spc, flags);
2168 break;
2170 case GIMPLE_OMP_CRITICAL:
2171 dump_gimple_omp_critical (buffer, gs, spc, flags);
2172 break;
2174 case GIMPLE_CATCH:
2175 dump_gimple_catch (buffer, gs, spc, flags);
2176 break;
2178 case GIMPLE_EH_FILTER:
2179 dump_gimple_eh_filter (buffer, gs, spc, flags);
2180 break;
2182 case GIMPLE_EH_MUST_NOT_THROW:
2183 dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
2184 break;
2186 case GIMPLE_EH_ELSE:
2187 dump_gimple_eh_else (buffer, gs, spc, flags);
2188 break;
2190 case GIMPLE_RESX:
2191 dump_gimple_resx (buffer, gs, spc, flags);
2192 break;
2194 case GIMPLE_EH_DISPATCH:
2195 dump_gimple_eh_dispatch (buffer, gs, spc, flags);
2196 break;
2198 case GIMPLE_DEBUG:
2199 dump_gimple_debug (buffer, gs, spc, flags);
2200 break;
2202 case GIMPLE_PREDICT:
2203 pp_string (buffer, "// predicted ");
2204 if (gimple_predict_outcome (gs))
2205 pp_string (buffer, "likely by ");
2206 else
2207 pp_string (buffer, "unlikely by ");
2208 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2209 pp_string (buffer, " predictor.");
2210 break;
2212 case GIMPLE_TRANSACTION:
2213 dump_gimple_transaction (buffer, gs, spc, flags);
2214 break;
2216 default:
2217 GIMPLE_NIY;
2222 /* Dumps header of basic block BB to OUTF indented by INDENT
2223 spaces and details described by flags. */
2225 static void
2226 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2228 if (flags & TDF_BLOCKS)
2230 if (flags & TDF_LINENO)
2232 gimple_stmt_iterator gsi;
2234 if (flags & TDF_COMMENT)
2235 fputs (";; ", outf);
2237 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2238 if (!is_gimple_debug (gsi_stmt (gsi))
2239 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2241 fprintf (outf, "%*sstarting at line %d",
2242 indent, "", get_lineno (gsi_stmt (gsi)));
2243 break;
2245 if (bb->discriminator)
2246 fprintf (outf, ", discriminator %i", bb->discriminator);
2247 fputc ('\n', outf);
2250 else
2252 gimple stmt = first_stmt (bb);
2253 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2254 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2259 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2260 spaces. */
2262 static void
2263 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2264 basic_block bb ATTRIBUTE_UNUSED,
2265 int indent ATTRIBUTE_UNUSED,
2266 int flags ATTRIBUTE_UNUSED)
2268 /* There is currently no GIMPLE-specific basic block info to dump. */
2269 return;
2273 /* Dump PHI nodes of basic block BB to BUFFER with details described
2274 by FLAGS and indented by INDENT spaces. */
2276 static void
2277 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2279 gimple_stmt_iterator i;
2281 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2283 gimple phi = gsi_stmt (i);
2284 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2286 INDENT (indent);
2287 dump_gimple_phi (buffer, phi, indent, true, flags);
2288 pp_newline (buffer);
2294 /* Dump jump to basic block BB that is represented implicitly in the cfg
2295 to BUFFER. */
2297 static void
2298 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2300 gimple stmt;
2302 stmt = first_stmt (bb);
2304 pp_string (buffer, "goto <bb ");
2305 pp_decimal_int (buffer, bb->index);
2306 pp_greater (buffer);
2307 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2309 pp_string (buffer, " (");
2310 dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
2311 pp_right_paren (buffer);
2312 pp_semicolon (buffer);
2314 else
2315 pp_semicolon (buffer);
2319 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2320 by INDENT spaces, with details given by FLAGS. */
2322 static void
2323 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2324 int flags)
2326 edge e;
2327 gimple stmt;
2329 stmt = last_stmt (bb);
2331 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2333 edge true_edge, false_edge;
2335 /* When we are emitting the code or changing CFG, it is possible that
2336 the edges are not yet created. When we are using debug_bb in such
2337 a situation, we do not want it to crash. */
2338 if (EDGE_COUNT (bb->succs) != 2)
2339 return;
2340 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2342 INDENT (indent + 2);
2343 pp_cfg_jump (buffer, true_edge->dest);
2344 newline_and_indent (buffer, indent);
2345 pp_string (buffer, "else");
2346 newline_and_indent (buffer, indent + 2);
2347 pp_cfg_jump (buffer, false_edge->dest);
2348 pp_newline (buffer);
2349 return;
2352 /* If there is a fallthru edge, we may need to add an artificial
2353 goto to the dump. */
2354 e = find_fallthru_edge (bb->succs);
2356 if (e && e->dest != bb->next_bb)
2358 INDENT (indent);
2360 if ((flags & TDF_LINENO)
2361 && e->goto_locus != UNKNOWN_LOCATION
2364 expanded_location goto_xloc;
2365 goto_xloc = expand_location (e->goto_locus);
2366 pp_left_bracket (buffer);
2367 if (goto_xloc.file)
2369 pp_string (buffer, goto_xloc.file);
2370 pp_string (buffer, " : ");
2372 pp_decimal_int (buffer, goto_xloc.line);
2373 pp_string (buffer, " : ");
2374 pp_decimal_int (buffer, goto_xloc.column);
2375 pp_string (buffer, "] ");
2378 pp_cfg_jump (buffer, e->dest);
2379 pp_newline (buffer);
2384 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2385 indented by INDENT spaces. */
2387 static void
2388 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2389 int flags)
2391 gimple_stmt_iterator gsi;
2392 gimple stmt;
2393 int label_indent = indent - 2;
2395 if (label_indent < 0)
2396 label_indent = 0;
2398 dump_phi_nodes (buffer, bb, indent, flags);
2400 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2402 int curr_indent;
2404 stmt = gsi_stmt (gsi);
2406 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2408 INDENT (curr_indent);
2409 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2410 pp_newline_and_flush (buffer);
2411 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2412 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2413 pp_buffer (buffer)->stream, stmt);
2416 dump_implicit_edges (buffer, bb, indent, flags);
2417 pp_flush (buffer);
2421 /* Dumps basic block BB to FILE with details described by FLAGS and
2422 indented by INDENT spaces. */
2424 void
2425 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2427 dump_gimple_bb_header (file, bb, indent, flags);
2428 if (bb->index >= NUM_FIXED_BLOCKS)
2430 pretty_printer buffer;
2431 pp_needs_newline (&buffer) = true;
2432 buffer.buffer->stream = file;
2433 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2435 dump_gimple_bb_footer (file, bb, indent, flags);
2438 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2439 no indentation, for use as a label of a DOT graph record-node.
2440 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2441 histogram dumping doesn't know about pretty-printers. */
2443 void
2444 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2446 gimple_stmt_iterator gsi;
2448 pp_printf (pp, "<bb %d>:\n", bb->index);
2449 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2451 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2453 gimple phi = gsi_stmt (gsi);
2454 if (!virtual_operand_p (gimple_phi_result (phi))
2455 || (dump_flags & TDF_VOPS))
2457 pp_bar (pp);
2458 pp_write_text_to_stream (pp);
2459 pp_string (pp, "# ");
2460 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2461 pp_newline (pp);
2462 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2466 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2468 gimple stmt = gsi_stmt (gsi);
2469 pp_bar (pp);
2470 pp_write_text_to_stream (pp);
2471 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2472 pp_newline (pp);
2473 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2475 dump_implicit_edges (pp, bb, 0, dump_flags);
2476 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);