Reverting merge from trunk
[official-gcc.git] / gcc / gimple-pretty-print.c
blobb20d11ae3d48e99ae036abb35b2dca0689a95bc2
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-iterator.h"
33 #include "gimple-ssa.h"
34 #include "cgraph.h"
35 #include "tree-cfg.h"
36 #include "tree-ssanames.h"
37 #include "dumpfile.h" /* for dump_flags */
38 #include "value-prof.h"
39 #include "trans-mem.h"
41 #define INDENT(SPACE) \
42 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
44 #define GIMPLE_NIY do_niy (buffer,gs)
46 /* Try to print on BUFFER a default message for the unrecognized
47 gimple statement GS. */
49 static void
50 do_niy (pretty_printer *buffer, gimple gs)
52 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
53 gimple_code_name[(int) gimple_code (gs)]);
57 /* Emit a newline and SPC indentation spaces to BUFFER. */
59 static void
60 newline_and_indent (pretty_printer *buffer, int spc)
62 pp_newline (buffer);
63 INDENT (spc);
67 /* Print the GIMPLE statement GS on stderr. */
69 DEBUG_FUNCTION void
70 debug_gimple_stmt (gimple gs)
72 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
76 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
77 FLAGS as in pp_gimple_stmt_1. */
79 void
80 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
82 pretty_printer buffer;
83 pp_needs_newline (&buffer) = true;
84 buffer.buffer->stream = file;
85 pp_gimple_stmt_1 (&buffer, g, spc, flags);
86 pp_newline_and_flush (&buffer);
89 DEBUG_FUNCTION void
90 debug (gimple_statement_d &ref)
92 print_gimple_stmt (stderr, &ref, 0, 0);
95 DEBUG_FUNCTION void
96 debug (gimple_statement_d *ptr)
98 if (ptr)
99 debug (*ptr);
100 else
101 fprintf (stderr, "<nil>\n");
105 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
106 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
107 of the statement. */
109 void
110 print_gimple_expr (FILE *file, gimple g, int spc, int flags)
112 flags |= TDF_RHS_ONLY;
113 pretty_printer buffer;
114 pp_needs_newline (&buffer) = true;
115 buffer.buffer->stream = file;
116 pp_gimple_stmt_1 (&buffer, g, spc, flags);
117 pp_flush (&buffer);
121 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
122 spaces and FLAGS as in pp_gimple_stmt_1.
123 The caller is responsible for calling pp_flush on BUFFER to finalize
124 the pretty printer. */
126 static void
127 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
129 gimple_stmt_iterator i;
131 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
133 gimple gs = gsi_stmt (i);
134 INDENT (spc);
135 pp_gimple_stmt_1 (buffer, gs, spc, flags);
136 if (!gsi_one_before_end_p (i))
137 pp_newline (buffer);
142 /* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
143 FLAGS as in pp_gimple_stmt_1. */
145 void
146 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
148 pretty_printer buffer;
149 pp_needs_newline (&buffer) = true;
150 buffer.buffer->stream = file;
151 dump_gimple_seq (&buffer, seq, spc, flags);
152 pp_newline_and_flush (&buffer);
156 /* Print the GIMPLE sequence SEQ on stderr. */
158 DEBUG_FUNCTION void
159 debug_gimple_seq (gimple_seq seq)
161 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
165 /* A simple helper to pretty-print some of the gimple tuples in the printf
166 style. The format modifiers are preceded by '%' and are:
167 'G' - outputs a string corresponding to the code of the given gimple,
168 'S' - outputs a gimple_seq with indent of spc + 2,
169 'T' - outputs the tree t,
170 'd' - outputs an int as a decimal,
171 's' - outputs a string,
172 'n' - outputs a newline,
173 'x' - outputs an int as hexadecimal,
174 '+' - increases indent by 2 then outputs a newline,
175 '-' - decreases indent by 2 then outputs a newline. */
177 static void
178 dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
179 const char *fmt, ...)
181 va_list args;
182 const char *c;
183 const char *tmp;
185 va_start (args, fmt);
186 for (c = fmt; *c; c++)
188 if (*c == '%')
190 gimple_seq seq;
191 tree t;
192 gimple g;
193 switch (*++c)
195 case 'G':
196 g = va_arg (args, gimple);
197 tmp = gimple_code_name[gimple_code (g)];
198 pp_string (buffer, tmp);
199 break;
201 case 'S':
202 seq = va_arg (args, gimple_seq);
203 pp_newline (buffer);
204 dump_gimple_seq (buffer, seq, spc + 2, flags);
205 newline_and_indent (buffer, spc);
206 break;
208 case 'T':
209 t = va_arg (args, tree);
210 if (t == NULL_TREE)
211 pp_string (buffer, "NULL");
212 else
213 dump_generic_node (buffer, t, spc, flags, false);
214 break;
216 case 'd':
217 pp_decimal_int (buffer, va_arg (args, int));
218 break;
220 case 's':
221 pp_string (buffer, va_arg (args, char *));
222 break;
224 case 'n':
225 newline_and_indent (buffer, spc);
226 break;
228 case 'x':
229 pp_scalar (buffer, "%x", va_arg (args, int));
230 break;
232 case '+':
233 spc += 2;
234 newline_and_indent (buffer, spc);
235 break;
237 case '-':
238 spc -= 2;
239 newline_and_indent (buffer, spc);
240 break;
242 default:
243 gcc_unreachable ();
246 else
247 pp_character (buffer, *c);
249 va_end (args);
253 /* Helper for dump_gimple_assign. Print the unary RHS of the
254 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
256 static void
257 dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
259 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
260 tree lhs = gimple_assign_lhs (gs);
261 tree rhs = gimple_assign_rhs1 (gs);
263 switch (rhs_code)
265 case VIEW_CONVERT_EXPR:
266 case ASSERT_EXPR:
267 dump_generic_node (buffer, rhs, spc, flags, false);
268 break;
270 case FIXED_CONVERT_EXPR:
271 case ADDR_SPACE_CONVERT_EXPR:
272 case FIX_TRUNC_EXPR:
273 case FLOAT_EXPR:
274 CASE_CONVERT:
275 pp_left_paren (buffer);
276 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
277 pp_string (buffer, ") ");
278 if (op_prio (rhs) < op_code_prio (rhs_code))
280 pp_left_paren (buffer);
281 dump_generic_node (buffer, rhs, spc, flags, false);
282 pp_right_paren (buffer);
284 else
285 dump_generic_node (buffer, rhs, spc, flags, false);
286 break;
288 case PAREN_EXPR:
289 pp_string (buffer, "((");
290 dump_generic_node (buffer, rhs, spc, flags, false);
291 pp_string (buffer, "))");
292 break;
294 case ABS_EXPR:
295 pp_string (buffer, "ABS_EXPR <");
296 dump_generic_node (buffer, rhs, spc, flags, false);
297 pp_greater (buffer);
298 break;
300 default:
301 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
302 || TREE_CODE_CLASS (rhs_code) == tcc_constant
303 || TREE_CODE_CLASS (rhs_code) == tcc_reference
304 || rhs_code == SSA_NAME
305 || rhs_code == ADDR_EXPR
306 || rhs_code == CONSTRUCTOR)
308 dump_generic_node (buffer, rhs, spc, flags, false);
309 break;
311 else if (rhs_code == BIT_NOT_EXPR)
312 pp_complement (buffer);
313 else if (rhs_code == TRUTH_NOT_EXPR)
314 pp_exclamation (buffer);
315 else if (rhs_code == NEGATE_EXPR)
316 pp_minus (buffer);
317 else
319 pp_left_bracket (buffer);
320 pp_string (buffer, get_tree_code_name (rhs_code));
321 pp_string (buffer, "] ");
324 if (op_prio (rhs) < op_code_prio (rhs_code))
326 pp_left_paren (buffer);
327 dump_generic_node (buffer, rhs, spc, flags, false);
328 pp_right_paren (buffer);
330 else
331 dump_generic_node (buffer, rhs, spc, flags, false);
332 break;
337 /* Helper for dump_gimple_assign. Print the binary RHS of the
338 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
340 static void
341 dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
343 const char *p;
344 enum tree_code code = gimple_assign_rhs_code (gs);
345 switch (code)
347 case COMPLEX_EXPR:
348 case MIN_EXPR:
349 case MAX_EXPR:
350 case VEC_WIDEN_MULT_HI_EXPR:
351 case VEC_WIDEN_MULT_LO_EXPR:
352 case VEC_WIDEN_MULT_EVEN_EXPR:
353 case VEC_WIDEN_MULT_ODD_EXPR:
354 case VEC_PACK_TRUNC_EXPR:
355 case VEC_PACK_SAT_EXPR:
356 case VEC_PACK_FIX_TRUNC_EXPR:
357 case VEC_WIDEN_LSHIFT_HI_EXPR:
358 case VEC_WIDEN_LSHIFT_LO_EXPR:
359 for (p = get_tree_code_name (code); *p; p++)
360 pp_character (buffer, TOUPPER (*p));
361 pp_string (buffer, " <");
362 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
363 pp_string (buffer, ", ");
364 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
365 pp_greater (buffer);
366 break;
368 default:
369 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
371 pp_left_paren (buffer);
372 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
373 false);
374 pp_right_paren (buffer);
376 else
377 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
378 pp_space (buffer);
379 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
380 pp_space (buffer);
381 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
383 pp_left_paren (buffer);
384 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
385 false);
386 pp_right_paren (buffer);
388 else
389 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
393 /* Helper for dump_gimple_assign. Print the ternary RHS of the
394 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
396 static void
397 dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
399 const char *p;
400 enum tree_code code = gimple_assign_rhs_code (gs);
401 switch (code)
403 case WIDEN_MULT_PLUS_EXPR:
404 case WIDEN_MULT_MINUS_EXPR:
405 for (p = get_tree_code_name (code); *p; p++)
406 pp_character (buffer, TOUPPER (*p));
407 pp_string (buffer, " <");
408 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
409 pp_string (buffer, ", ");
410 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
411 pp_string (buffer, ", ");
412 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
413 pp_greater (buffer);
414 break;
416 case FMA_EXPR:
417 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
418 pp_string (buffer, " * ");
419 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
420 pp_string (buffer, " + ");
421 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
422 break;
424 case DOT_PROD_EXPR:
425 pp_string (buffer, "DOT_PROD_EXPR <");
426 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
427 pp_string (buffer, ", ");
428 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
429 pp_string (buffer, ", ");
430 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
431 pp_greater (buffer);
432 break;
434 case VEC_PERM_EXPR:
435 pp_string (buffer, "VEC_PERM_EXPR <");
436 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
437 pp_string (buffer, ", ");
438 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
439 pp_string (buffer, ", ");
440 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
441 pp_greater (buffer);
442 break;
444 case REALIGN_LOAD_EXPR:
445 pp_string (buffer, "REALIGN_LOAD <");
446 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
447 pp_string (buffer, ", ");
448 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
449 pp_string (buffer, ", ");
450 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
451 pp_greater (buffer);
452 break;
454 case COND_EXPR:
455 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
456 pp_string (buffer, " ? ");
457 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
458 pp_string (buffer, " : ");
459 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
460 break;
462 case VEC_COND_EXPR:
463 pp_string (buffer, "VEC_COND_EXPR <");
464 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
465 pp_string (buffer, ", ");
466 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
467 pp_string (buffer, ", ");
468 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
469 pp_greater (buffer);
470 break;
472 default:
473 gcc_unreachable ();
478 /* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
479 pp_gimple_stmt_1. */
481 static void
482 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
484 if (flags & TDF_RAW)
486 tree arg1 = NULL;
487 tree arg2 = NULL;
488 tree arg3 = NULL;
489 switch (gimple_num_ops (gs))
491 case 4:
492 arg3 = gimple_assign_rhs3 (gs);
493 case 3:
494 arg2 = gimple_assign_rhs2 (gs);
495 case 2:
496 arg1 = gimple_assign_rhs1 (gs);
497 break;
498 default:
499 gcc_unreachable ();
502 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
503 get_tree_code_name (gimple_assign_rhs_code (gs)),
504 gimple_assign_lhs (gs), arg1, arg2, arg3);
506 else
508 if (!(flags & TDF_RHS_ONLY))
510 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
511 pp_space (buffer);
512 pp_equal (buffer);
514 if (gimple_assign_nontemporal_move_p (gs))
515 pp_string (buffer, "{nt}");
517 if (gimple_has_volatile_ops (gs))
518 pp_string (buffer, "{v}");
520 pp_space (buffer);
523 if (gimple_num_ops (gs) == 2)
524 dump_unary_rhs (buffer, gs, spc, flags);
525 else if (gimple_num_ops (gs) == 3)
526 dump_binary_rhs (buffer, gs, spc, flags);
527 else if (gimple_num_ops (gs) == 4)
528 dump_ternary_rhs (buffer, gs, spc, flags);
529 else
530 gcc_unreachable ();
531 if (!(flags & TDF_RHS_ONLY))
532 pp_semicolon (buffer);
537 /* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
538 pp_gimple_stmt_1. */
540 static void
541 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
543 tree t, t2;
545 t = gimple_return_retval (gs);
546 t2 = gimple_return_retbnd (gs);
547 if (flags & TDF_RAW)
548 dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
549 else
551 pp_string (buffer, "return");
552 if (t)
554 pp_space (buffer);
555 dump_generic_node (buffer, t, spc, flags, false);
557 if (t2)
559 pp_string (buffer, ", ");
560 dump_generic_node (buffer, t2, spc, flags, false);
562 pp_semicolon (buffer);
567 /* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
568 dump_gimple_call. */
570 static void
571 dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags)
573 size_t i;
575 for (i = 0; i < gimple_call_num_args (gs); i++)
577 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
578 if (i < gimple_call_num_args (gs) - 1)
579 pp_string (buffer, ", ");
582 if (gimple_call_va_arg_pack_p (gs))
584 if (gimple_call_num_args (gs) > 0)
586 pp_comma (buffer);
587 pp_space (buffer);
590 pp_string (buffer, "__builtin_va_arg_pack ()");
594 /* Dump the points-to solution *PT to BUFFER. */
596 static void
597 pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
599 if (pt->anything)
601 pp_string (buffer, "anything ");
602 return;
604 if (pt->nonlocal)
605 pp_string (buffer, "nonlocal ");
606 if (pt->escaped)
607 pp_string (buffer, "escaped ");
608 if (pt->ipa_escaped)
609 pp_string (buffer, "unit-escaped ");
610 if (pt->null)
611 pp_string (buffer, "null ");
612 if (pt->vars
613 && !bitmap_empty_p (pt->vars))
615 bitmap_iterator bi;
616 unsigned i;
617 pp_string (buffer, "{ ");
618 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
620 pp_string (buffer, "D.");
621 pp_decimal_int (buffer, i);
622 pp_space (buffer);
624 pp_right_brace (buffer);
625 if (pt->vars_contains_nonlocal
626 && pt->vars_contains_escaped_heap)
627 pp_string (buffer, " (nonlocal, escaped heap)");
628 else if (pt->vars_contains_nonlocal
629 && pt->vars_contains_escaped)
630 pp_string (buffer, " (nonlocal, escaped)");
631 else if (pt->vars_contains_nonlocal)
632 pp_string (buffer, " (nonlocal)");
633 else if (pt->vars_contains_escaped_heap)
634 pp_string (buffer, " (escaped heap)");
635 else if (pt->vars_contains_escaped)
636 pp_string (buffer, " (escaped)");
640 /* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
641 pp_gimple_stmt_1. */
643 static void
644 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
646 tree lhs = gimple_call_lhs (gs);
647 tree fn = gimple_call_fn (gs);
649 if (flags & TDF_ALIAS)
651 struct pt_solution *pt;
652 pt = gimple_call_use_set (gs);
653 if (!pt_solution_empty_p (pt))
655 pp_string (buffer, "# USE = ");
656 pp_points_to_solution (buffer, pt);
657 newline_and_indent (buffer, spc);
659 pt = gimple_call_clobber_set (gs);
660 if (!pt_solution_empty_p (pt))
662 pp_string (buffer, "# CLB = ");
663 pp_points_to_solution (buffer, pt);
664 newline_and_indent (buffer, spc);
668 if (flags & TDF_RAW)
670 if (gimple_call_internal_p (gs))
671 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
672 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
673 else
674 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
675 if (gimple_call_num_args (gs) > 0)
677 pp_string (buffer, ", ");
678 dump_gimple_call_args (buffer, gs, flags);
680 pp_greater (buffer);
682 else
684 if (lhs && !(flags & TDF_RHS_ONLY))
686 dump_generic_node (buffer, lhs, spc, flags, false);
687 pp_string (buffer, " =");
689 if (gimple_has_volatile_ops (gs))
690 pp_string (buffer, "{v}");
692 pp_space (buffer);
694 if (gimple_call_internal_p (gs))
695 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
696 else
697 print_call_name (buffer, fn, flags);
698 pp_string (buffer, " (");
699 dump_gimple_call_args (buffer, gs, flags);
700 pp_right_paren (buffer);
701 if (!(flags & TDF_RHS_ONLY))
702 pp_semicolon (buffer);
705 if (gimple_call_chain (gs))
707 pp_string (buffer, " [static-chain: ");
708 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
709 pp_right_bracket (buffer);
712 if (gimple_call_return_slot_opt_p (gs))
713 pp_string (buffer, " [return slot optimization]");
714 if (gimple_call_tail_p (gs))
715 pp_string (buffer, " [tail call]");
717 if (fn == NULL)
718 return;
720 /* Dump the arguments of _ITM_beginTransaction sanely. */
721 if (TREE_CODE (fn) == ADDR_EXPR)
722 fn = TREE_OPERAND (fn, 0);
723 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
724 pp_string (buffer, " [tm-clone]");
725 if (TREE_CODE (fn) == FUNCTION_DECL
726 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
727 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
728 && gimple_call_num_args (gs) > 0)
730 tree t = gimple_call_arg (gs, 0);
731 unsigned HOST_WIDE_INT props;
732 gcc_assert (TREE_CODE (t) == INTEGER_CST);
734 pp_string (buffer, " [ ");
736 /* Get the transaction code properties. */
737 props = TREE_INT_CST_LOW (t);
739 if (props & PR_INSTRUMENTEDCODE)
740 pp_string (buffer, "instrumentedCode ");
741 if (props & PR_UNINSTRUMENTEDCODE)
742 pp_string (buffer, "uninstrumentedCode ");
743 if (props & PR_HASNOXMMUPDATE)
744 pp_string (buffer, "hasNoXMMUpdate ");
745 if (props & PR_HASNOABORT)
746 pp_string (buffer, "hasNoAbort ");
747 if (props & PR_HASNOIRREVOCABLE)
748 pp_string (buffer, "hasNoIrrevocable ");
749 if (props & PR_DOESGOIRREVOCABLE)
750 pp_string (buffer, "doesGoIrrevocable ");
751 if (props & PR_HASNOSIMPLEREADS)
752 pp_string (buffer, "hasNoSimpleReads ");
753 if (props & PR_AWBARRIERSOMITTED)
754 pp_string (buffer, "awBarriersOmitted ");
755 if (props & PR_RARBARRIERSOMITTED)
756 pp_string (buffer, "RaRBarriersOmitted ");
757 if (props & PR_UNDOLOGCODE)
758 pp_string (buffer, "undoLogCode ");
759 if (props & PR_PREFERUNINSTRUMENTED)
760 pp_string (buffer, "preferUninstrumented ");
761 if (props & PR_EXCEPTIONBLOCK)
762 pp_string (buffer, "exceptionBlock ");
763 if (props & PR_HASELSE)
764 pp_string (buffer, "hasElse ");
765 if (props & PR_READONLY)
766 pp_string (buffer, "readOnly ");
768 pp_right_bracket (buffer);
773 /* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
774 pp_gimple_stmt_1. */
776 static void
777 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
779 unsigned int i;
781 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
782 if (flags & TDF_RAW)
783 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
784 gimple_switch_index (gs));
785 else
787 pp_string (buffer, "switch (");
788 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
789 pp_string (buffer, ") <");
792 for (i = 0; i < gimple_switch_num_labels (gs); i++)
794 tree case_label = gimple_switch_label (gs, i);
795 gcc_checking_assert (case_label != NULL_TREE);
796 dump_generic_node (buffer, case_label, spc, flags, false);
797 pp_space (buffer);
798 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
799 if (i < gimple_switch_num_labels (gs) - 1)
800 pp_string (buffer, ", ");
802 pp_greater (buffer);
806 /* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
807 pp_gimple_stmt_1. */
809 static void
810 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
812 if (flags & TDF_RAW)
813 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
814 get_tree_code_name (gimple_cond_code (gs)),
815 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
816 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
817 else
819 if (!(flags & TDF_RHS_ONLY))
820 pp_string (buffer, "if (");
821 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
822 pp_space (buffer);
823 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
824 pp_space (buffer);
825 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
826 if (!(flags & TDF_RHS_ONLY))
828 pp_right_paren (buffer);
830 if (gimple_cond_true_label (gs))
832 pp_string (buffer, " goto ");
833 dump_generic_node (buffer, gimple_cond_true_label (gs),
834 spc, flags, false);
835 pp_semicolon (buffer);
837 if (gimple_cond_false_label (gs))
839 pp_string (buffer, " else goto ");
840 dump_generic_node (buffer, gimple_cond_false_label (gs),
841 spc, flags, false);
842 pp_semicolon (buffer);
849 /* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
850 spaces of indent. FLAGS specifies details to show in the dump (see
851 TDF_* in dumpfils.h). */
853 static void
854 dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
856 tree label = gimple_label_label (gs);
857 if (flags & TDF_RAW)
858 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
859 else
861 dump_generic_node (buffer, label, spc, flags, false);
862 pp_colon (buffer);
864 if (DECL_NONLOCAL (label))
865 pp_string (buffer, " [non-local]");
866 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
867 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
870 /* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
871 spaces of indent. FLAGS specifies details to show in the dump (see
872 TDF_* in dumpfile.h). */
874 static void
875 dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
877 tree label = gimple_goto_dest (gs);
878 if (flags & TDF_RAW)
879 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
880 else
881 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
885 /* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
886 spaces of indent. FLAGS specifies details to show in the dump (see
887 TDF_* in dumpfile.h). */
889 static void
890 dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
892 if (flags & TDF_RAW)
893 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
894 else
895 pp_left_brace (buffer);
896 if (!(flags & TDF_SLIM))
898 tree var;
900 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
902 newline_and_indent (buffer, 2);
903 print_declaration (buffer, var, spc, flags);
905 if (gimple_bind_vars (gs))
906 pp_newline (buffer);
908 pp_newline (buffer);
909 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
910 newline_and_indent (buffer, spc);
911 if (flags & TDF_RAW)
912 pp_greater (buffer);
913 else
914 pp_right_brace (buffer);
918 /* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
919 indent. FLAGS specifies details to show in the dump (see TDF_* in
920 dumpfile.h). */
922 static void
923 dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
925 if (flags & TDF_RAW)
927 const char *type;
928 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
929 type = "GIMPLE_TRY_CATCH";
930 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
931 type = "GIMPLE_TRY_FINALLY";
932 else
933 type = "UNKNOWN GIMPLE_TRY";
934 dump_gimple_fmt (buffer, spc, flags,
935 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
936 gimple_try_eval (gs), gimple_try_cleanup (gs));
938 else
940 pp_string (buffer, "try");
941 newline_and_indent (buffer, spc + 2);
942 pp_left_brace (buffer);
943 pp_newline (buffer);
945 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
946 newline_and_indent (buffer, spc + 2);
947 pp_right_brace (buffer);
949 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
951 newline_and_indent (buffer, spc);
952 pp_string (buffer, "catch");
953 newline_and_indent (buffer, spc + 2);
954 pp_left_brace (buffer);
956 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
958 newline_and_indent (buffer, spc);
959 pp_string (buffer, "finally");
960 newline_and_indent (buffer, spc + 2);
961 pp_left_brace (buffer);
963 else
964 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
966 pp_newline (buffer);
967 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
968 newline_and_indent (buffer, spc + 2);
969 pp_right_brace (buffer);
974 /* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
975 indent. FLAGS specifies details to show in the dump (see TDF_* in
976 dumpfile.h). */
978 static void
979 dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
981 if (flags & TDF_RAW)
982 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
983 gimple_catch_types (gs), gimple_catch_handler (gs));
984 else
985 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
986 gimple_catch_types (gs), gimple_catch_handler (gs));
990 /* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
991 indent. FLAGS specifies details to show in the dump (see TDF_* in
992 dumpfile.h). */
994 static void
995 dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
997 if (flags & TDF_RAW)
998 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
999 gimple_eh_filter_types (gs),
1000 gimple_eh_filter_failure (gs));
1001 else
1002 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1003 gimple_eh_filter_types (gs),
1004 gimple_eh_filter_failure (gs));
1008 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1010 static void
1011 dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
1012 int spc, int flags)
1014 if (flags & TDF_RAW)
1015 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1016 gimple_eh_must_not_throw_fndecl (gs));
1017 else
1018 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1019 gimple_eh_must_not_throw_fndecl (gs));
1023 /* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1024 indent. FLAGS specifies details to show in the dump (see TDF_* in
1025 dumpfile.h). */
1027 static void
1028 dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags)
1030 if (flags & TDF_RAW)
1031 dump_gimple_fmt (buffer, spc, flags,
1032 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1033 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1034 else
1035 dump_gimple_fmt (buffer, spc, flags,
1036 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1037 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1041 /* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1042 indent. FLAGS specifies details to show in the dump (see TDF_* in
1043 dumpfile.h). */
1045 static void
1046 dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
1048 if (flags & TDF_RAW)
1049 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1050 gimple_resx_region (gs));
1051 else
1052 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1055 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1057 static void
1058 dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
1060 if (flags & TDF_RAW)
1061 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1062 gimple_eh_dispatch_region (gs));
1063 else
1064 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1065 gimple_eh_dispatch_region (gs));
1068 /* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1069 of indent. FLAGS specifies details to show in the dump (see TDF_*
1070 in dumpfile.h). */
1072 static void
1073 dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
1075 switch (gs->gsbase.subcode)
1077 case GIMPLE_DEBUG_BIND:
1078 if (flags & TDF_RAW)
1079 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1080 gimple_debug_bind_get_var (gs),
1081 gimple_debug_bind_get_value (gs));
1082 else
1083 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1084 gimple_debug_bind_get_var (gs),
1085 gimple_debug_bind_get_value (gs));
1086 break;
1088 case GIMPLE_DEBUG_SOURCE_BIND:
1089 if (flags & TDF_RAW)
1090 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1091 gimple_debug_source_bind_get_var (gs),
1092 gimple_debug_source_bind_get_value (gs));
1093 else
1094 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1095 gimple_debug_source_bind_get_var (gs),
1096 gimple_debug_source_bind_get_value (gs));
1097 break;
1099 default:
1100 gcc_unreachable ();
1104 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1105 static void
1106 dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
1108 size_t i;
1110 if (flags & TDF_RAW)
1112 const char *kind;
1113 switch (gimple_omp_for_kind (gs))
1115 case GF_OMP_FOR_KIND_FOR:
1116 kind = "";
1117 break;
1118 case GF_OMP_FOR_KIND_SIMD:
1119 kind = " simd";
1120 break;
1121 case GF_OMP_FOR_KIND_CILKSIMD:
1122 kind = " cilksimd";
1123 case GF_OMP_FOR_KIND_DISTRIBUTE:
1124 kind = " distribute";
1125 break;
1126 default:
1127 gcc_unreachable ();
1129 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1130 kind, gimple_omp_body (gs));
1131 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1132 dump_gimple_fmt (buffer, spc, flags, " >,");
1133 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1134 dump_gimple_fmt (buffer, spc, flags,
1135 "%+%T, %T, %T, %s, %T,%n",
1136 gimple_omp_for_index (gs, i),
1137 gimple_omp_for_initial (gs, i),
1138 gimple_omp_for_final (gs, i),
1139 get_tree_code_name (gimple_omp_for_cond (gs, i)),
1140 gimple_omp_for_incr (gs, i));
1141 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1142 gimple_omp_for_pre_body (gs));
1144 else
1146 switch (gimple_omp_for_kind (gs))
1148 case GF_OMP_FOR_KIND_FOR:
1149 pp_string (buffer, "#pragma omp for");
1150 break;
1151 case GF_OMP_FOR_KIND_SIMD:
1152 pp_string (buffer, "#pragma omp simd");
1153 break;
1154 case GF_OMP_FOR_KIND_CILKSIMD:
1155 pp_string (buffer, "#pragma simd");
1156 break;
1157 case GF_OMP_FOR_KIND_DISTRIBUTE:
1158 pp_string (buffer, "#pragma omp distribute");
1159 break;
1160 default:
1161 gcc_unreachable ();
1163 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1164 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1166 if (i)
1167 spc += 2;
1168 newline_and_indent (buffer, spc);
1169 pp_string (buffer, "for (");
1170 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1171 flags, false);
1172 pp_string (buffer, " = ");
1173 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1174 flags, false);
1175 pp_string (buffer, "; ");
1177 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1178 flags, false);
1179 pp_space (buffer);
1180 switch (gimple_omp_for_cond (gs, i))
1182 case LT_EXPR:
1183 pp_less (buffer);
1184 break;
1185 case GT_EXPR:
1186 pp_greater (buffer);
1187 break;
1188 case LE_EXPR:
1189 pp_less_equal (buffer);
1190 break;
1191 case GE_EXPR:
1192 pp_greater_equal (buffer);
1193 break;
1194 default:
1195 gcc_unreachable ();
1197 pp_space (buffer);
1198 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1199 flags, false);
1200 pp_string (buffer, "; ");
1202 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1203 flags, false);
1204 pp_string (buffer, " = ");
1205 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1206 flags, false);
1207 pp_right_paren (buffer);
1210 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1212 newline_and_indent (buffer, spc + 2);
1213 pp_left_brace (buffer);
1214 pp_newline (buffer);
1215 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1216 newline_and_indent (buffer, spc + 2);
1217 pp_right_brace (buffer);
1222 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1224 static void
1225 dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags)
1227 if (flags & TDF_RAW)
1229 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1230 gimple_omp_continue_control_def (gs),
1231 gimple_omp_continue_control_use (gs));
1233 else
1235 pp_string (buffer, "#pragma omp continue (");
1236 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1237 spc, flags, false);
1238 pp_comma (buffer);
1239 pp_space (buffer);
1240 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1241 spc, flags, false);
1242 pp_right_paren (buffer);
1246 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1248 static void
1249 dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, int flags)
1251 if (flags & TDF_RAW)
1253 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1254 gimple_omp_body (gs));
1255 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1256 dump_gimple_fmt (buffer, spc, flags, " >");
1258 else
1260 pp_string (buffer, "#pragma omp single");
1261 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1262 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1264 newline_and_indent (buffer, spc + 2);
1265 pp_left_brace (buffer);
1266 pp_newline (buffer);
1267 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1268 newline_and_indent (buffer, spc + 2);
1269 pp_right_brace (buffer);
1274 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1276 static void
1277 dump_gimple_omp_target (pretty_printer *buffer, gimple gs, int spc, int flags)
1279 const char *kind;
1280 switch (gimple_omp_target_kind (gs))
1282 case GF_OMP_TARGET_KIND_REGION:
1283 kind = "";
1284 break;
1285 case GF_OMP_TARGET_KIND_DATA:
1286 kind = " data";
1287 break;
1288 case GF_OMP_TARGET_KIND_UPDATE:
1289 kind = " update";
1290 break;
1291 default:
1292 gcc_unreachable ();
1294 if (flags & TDF_RAW)
1296 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1297 kind, gimple_omp_body (gs));
1298 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1299 dump_gimple_fmt (buffer, spc, flags, " >");
1301 else
1303 pp_string (buffer, "#pragma omp target");
1304 pp_string (buffer, kind);
1305 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1306 if (gimple_omp_target_child_fn (gs))
1308 pp_string (buffer, " [child fn: ");
1309 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1310 spc, flags, false);
1311 pp_right_bracket (buffer);
1313 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1315 newline_and_indent (buffer, spc + 2);
1316 pp_character (buffer, '{');
1317 pp_newline (buffer);
1318 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1319 newline_and_indent (buffer, spc + 2);
1320 pp_character (buffer, '}');
1325 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1327 static void
1328 dump_gimple_omp_teams (pretty_printer *buffer, gimple gs, int spc, int flags)
1330 if (flags & TDF_RAW)
1332 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1333 gimple_omp_body (gs));
1334 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1335 dump_gimple_fmt (buffer, spc, flags, " >");
1337 else
1339 pp_string (buffer, "#pragma omp teams");
1340 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1341 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1343 newline_and_indent (buffer, spc + 2);
1344 pp_character (buffer, '{');
1345 pp_newline (buffer);
1346 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1347 newline_and_indent (buffer, spc + 2);
1348 pp_character (buffer, '}');
1353 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1355 static void
1356 dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
1357 int flags)
1359 if (flags & TDF_RAW)
1361 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1362 gimple_omp_body (gs));
1363 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1364 dump_gimple_fmt (buffer, spc, flags, " >");
1366 else
1368 pp_string (buffer, "#pragma omp sections");
1369 if (gimple_omp_sections_control (gs))
1371 pp_string (buffer, " <");
1372 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1373 flags, false);
1374 pp_greater (buffer);
1376 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1377 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1379 newline_and_indent (buffer, spc + 2);
1380 pp_left_brace (buffer);
1381 pp_newline (buffer);
1382 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1383 newline_and_indent (buffer, spc + 2);
1384 pp_right_brace (buffer);
1389 /* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
1390 pretty_printer BUFFER. */
1392 static void
1393 dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1395 if (flags & TDF_RAW)
1396 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1397 gimple_omp_body (gs));
1398 else
1400 switch (gimple_code (gs))
1402 case GIMPLE_OMP_MASTER:
1403 pp_string (buffer, "#pragma omp master");
1404 break;
1405 case GIMPLE_OMP_TASKGROUP:
1406 pp_string (buffer, "#pragma omp taskgroup");
1407 break;
1408 case GIMPLE_OMP_ORDERED:
1409 pp_string (buffer, "#pragma omp ordered");
1410 break;
1411 case GIMPLE_OMP_SECTION:
1412 pp_string (buffer, "#pragma omp section");
1413 break;
1414 default:
1415 gcc_unreachable ();
1417 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1419 newline_and_indent (buffer, spc + 2);
1420 pp_left_brace (buffer);
1421 pp_newline (buffer);
1422 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1423 newline_and_indent (buffer, spc + 2);
1424 pp_right_brace (buffer);
1429 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1431 static void
1432 dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
1433 int flags)
1435 if (flags & TDF_RAW)
1436 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1437 gimple_omp_body (gs));
1438 else
1440 pp_string (buffer, "#pragma omp critical");
1441 if (gimple_omp_critical_name (gs))
1443 pp_string (buffer, " (");
1444 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1445 flags, false);
1446 pp_right_paren (buffer);
1448 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1450 newline_and_indent (buffer, spc + 2);
1451 pp_left_brace (buffer);
1452 pp_newline (buffer);
1453 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1454 newline_and_indent (buffer, spc + 2);
1455 pp_right_brace (buffer);
1460 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1462 static void
1463 dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1465 if (flags & TDF_RAW)
1467 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
1468 (int) gimple_omp_return_nowait_p (gs));
1469 if (gimple_omp_return_lhs (gs))
1470 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1471 gimple_omp_return_lhs (gs));
1472 else
1473 dump_gimple_fmt (buffer, spc, flags, ">");
1475 else
1477 pp_string (buffer, "#pragma omp return");
1478 if (gimple_omp_return_nowait_p (gs))
1479 pp_string (buffer, "(nowait)");
1480 if (gimple_omp_return_lhs (gs))
1482 pp_string (buffer, " (set ");
1483 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1484 spc, flags, false);
1485 pp_character (buffer, ')');
1490 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1492 static void
1493 dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags)
1495 unsigned subcode = gimple_transaction_subcode (gs);
1497 if (flags & TDF_RAW)
1499 dump_gimple_fmt (buffer, spc, flags,
1500 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1501 gs, subcode, gimple_transaction_label (gs),
1502 gimple_transaction_body (gs));
1504 else
1506 if (subcode & GTMA_IS_OUTER)
1507 pp_string (buffer, "__transaction_atomic [[outer]]");
1508 else if (subcode & GTMA_IS_RELAXED)
1509 pp_string (buffer, "__transaction_relaxed");
1510 else
1511 pp_string (buffer, "__transaction_atomic");
1512 subcode &= ~GTMA_DECLARATION_MASK;
1514 if (subcode || gimple_transaction_label (gs))
1516 pp_string (buffer, " //");
1517 if (gimple_transaction_label (gs))
1519 pp_string (buffer, " LABEL=");
1520 dump_generic_node (buffer, gimple_transaction_label (gs),
1521 spc, flags, false);
1523 if (subcode)
1525 pp_string (buffer, " SUBCODE=[ ");
1526 if (subcode & GTMA_HAVE_ABORT)
1528 pp_string (buffer, "GTMA_HAVE_ABORT ");
1529 subcode &= ~GTMA_HAVE_ABORT;
1531 if (subcode & GTMA_HAVE_LOAD)
1533 pp_string (buffer, "GTMA_HAVE_LOAD ");
1534 subcode &= ~GTMA_HAVE_LOAD;
1536 if (subcode & GTMA_HAVE_STORE)
1538 pp_string (buffer, "GTMA_HAVE_STORE ");
1539 subcode &= ~GTMA_HAVE_STORE;
1541 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1543 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1544 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1546 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1548 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1549 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1551 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1553 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1554 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1556 if (subcode)
1557 pp_printf (buffer, "0x%x ", subcode);
1558 pp_right_bracket (buffer);
1562 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1564 newline_and_indent (buffer, spc + 2);
1565 pp_left_brace (buffer);
1566 pp_newline (buffer);
1567 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1568 spc + 4, flags);
1569 newline_and_indent (buffer, spc + 2);
1570 pp_right_brace (buffer);
1575 /* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1576 indent. FLAGS specifies details to show in the dump (see TDF_* in
1577 dumpfile.h). */
1579 static void
1580 dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
1582 unsigned int i, n, f, fields;
1584 if (flags & TDF_RAW)
1586 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1587 gimple_asm_string (gs));
1589 n = gimple_asm_noutputs (gs);
1590 if (n)
1592 newline_and_indent (buffer, spc + 2);
1593 pp_string (buffer, "OUTPUT: ");
1594 for (i = 0; i < n; i++)
1596 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1597 spc, flags, false);
1598 if (i < n - 1)
1599 pp_string (buffer, ", ");
1603 n = gimple_asm_ninputs (gs);
1604 if (n)
1606 newline_and_indent (buffer, spc + 2);
1607 pp_string (buffer, "INPUT: ");
1608 for (i = 0; i < n; i++)
1610 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1611 spc, flags, false);
1612 if (i < n - 1)
1613 pp_string (buffer, ", ");
1617 n = gimple_asm_nclobbers (gs);
1618 if (n)
1620 newline_and_indent (buffer, spc + 2);
1621 pp_string (buffer, "CLOBBER: ");
1622 for (i = 0; i < n; i++)
1624 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1625 spc, flags, false);
1626 if (i < n - 1)
1627 pp_string (buffer, ", ");
1631 n = gimple_asm_nlabels (gs);
1632 if (n)
1634 newline_and_indent (buffer, spc + 2);
1635 pp_string (buffer, "LABEL: ");
1636 for (i = 0; i < n; i++)
1638 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1639 spc, flags, false);
1640 if (i < n - 1)
1641 pp_string (buffer, ", ");
1645 newline_and_indent (buffer, spc);
1646 pp_greater (buffer);
1648 else
1650 pp_string (buffer, "__asm__");
1651 if (gimple_asm_volatile_p (gs))
1652 pp_string (buffer, " __volatile__");
1653 if (gimple_asm_nlabels (gs))
1654 pp_string (buffer, " goto");
1655 pp_string (buffer, "(\"");
1656 pp_string (buffer, gimple_asm_string (gs));
1657 pp_string (buffer, "\"");
1659 if (gimple_asm_nlabels (gs))
1660 fields = 4;
1661 else if (gimple_asm_nclobbers (gs))
1662 fields = 3;
1663 else if (gimple_asm_ninputs (gs))
1664 fields = 2;
1665 else if (gimple_asm_noutputs (gs))
1666 fields = 1;
1667 else
1668 fields = 0;
1670 for (f = 0; f < fields; ++f)
1672 pp_string (buffer, " : ");
1674 switch (f)
1676 case 0:
1677 n = gimple_asm_noutputs (gs);
1678 for (i = 0; i < n; i++)
1680 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1681 spc, flags, false);
1682 if (i < n - 1)
1683 pp_string (buffer, ", ");
1685 break;
1687 case 1:
1688 n = gimple_asm_ninputs (gs);
1689 for (i = 0; i < n; i++)
1691 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1692 spc, flags, false);
1693 if (i < n - 1)
1694 pp_string (buffer, ", ");
1696 break;
1698 case 2:
1699 n = gimple_asm_nclobbers (gs);
1700 for (i = 0; i < n; i++)
1702 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1703 spc, flags, false);
1704 if (i < n - 1)
1705 pp_string (buffer, ", ");
1707 break;
1709 case 3:
1710 n = gimple_asm_nlabels (gs);
1711 for (i = 0; i < n; i++)
1713 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1714 spc, flags, false);
1715 if (i < n - 1)
1716 pp_string (buffer, ", ");
1718 break;
1720 default:
1721 gcc_unreachable ();
1725 pp_string (buffer, ");");
1729 /* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
1730 SPC spaces of indent. */
1732 static void
1733 dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
1735 if (TREE_CODE (node) != SSA_NAME)
1736 return;
1738 if (POINTER_TYPE_P (TREE_TYPE (node))
1739 && SSA_NAME_PTR_INFO (node))
1741 unsigned int align, misalign;
1742 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
1743 pp_string (buffer, "# PT = ");
1744 pp_points_to_solution (buffer, &pi->pt);
1745 newline_and_indent (buffer, spc);
1746 if (get_ptr_info_alignment (pi, &align, &misalign))
1748 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
1749 newline_and_indent (buffer, spc);
1753 if (!POINTER_TYPE_P (TREE_TYPE (node))
1754 && SSA_NAME_RANGE_INFO (node))
1756 double_int min, max, nonzero_bits;
1757 value_range_type range_type = get_range_info (node, &min, &max);
1759 if (range_type == VR_VARYING)
1760 pp_printf (buffer, "# RANGE VR_VARYING");
1761 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
1763 pp_printf (buffer, "# RANGE ");
1764 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
1765 pp_double_int (buffer, min, TYPE_UNSIGNED (TREE_TYPE (node)));
1766 pp_printf (buffer, ", ");
1767 pp_double_int (buffer, max, TYPE_UNSIGNED (TREE_TYPE (node)));
1768 pp_printf (buffer, "]");
1770 nonzero_bits = get_nonzero_bits (node);
1771 if (nonzero_bits != double_int_minus_one
1772 && (nonzero_bits
1773 != double_int::mask (TYPE_PRECISION (TREE_TYPE (node)))))
1775 pp_string (buffer, " NONZERO ");
1776 sprintf (pp_buffer (buffer)->digit_buffer,
1777 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
1778 (unsigned HOST_WIDE_INT) nonzero_bits.high,
1779 nonzero_bits.low);
1780 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
1782 newline_and_indent (buffer, spc);
1787 /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
1788 The caller is responsible for calling pp_flush on BUFFER to finalize
1789 pretty printer. If COMMENT is true, print this after #. */
1791 static void
1792 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, bool comment,
1793 int flags)
1795 size_t i;
1796 tree lhs = gimple_phi_result (phi);
1798 if (flags & TDF_ALIAS)
1799 dump_ssaname_info (buffer, lhs, spc);
1801 if (comment)
1802 pp_string (buffer, "# ");
1804 if (flags & TDF_RAW)
1805 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1806 gimple_phi_result (phi));
1807 else
1809 dump_generic_node (buffer, lhs, spc, flags, false);
1810 pp_string (buffer, " = PHI <");
1812 for (i = 0; i < gimple_phi_num_args (phi); i++)
1814 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1816 expanded_location xloc;
1818 xloc = expand_location (gimple_phi_arg_location (phi, i));
1819 pp_left_bracket (buffer);
1820 if (xloc.file)
1822 pp_string (buffer, xloc.file);
1823 pp_string (buffer, " : ");
1825 pp_decimal_int (buffer, xloc.line);
1826 pp_colon (buffer);
1827 pp_decimal_int (buffer, xloc.column);
1828 pp_string (buffer, "] ");
1830 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1831 false);
1832 pp_left_paren (buffer);
1833 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
1834 pp_right_paren (buffer);
1835 if (i < gimple_phi_num_args (phi) - 1)
1836 pp_string (buffer, ", ");
1838 pp_greater (buffer);
1842 /* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1843 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1844 dumpfile.h). */
1846 static void
1847 dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1848 int flags)
1850 if (flags & TDF_RAW)
1852 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1853 gimple_omp_body (gs));
1854 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1855 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1856 gimple_omp_parallel_child_fn (gs),
1857 gimple_omp_parallel_data_arg (gs));
1859 else
1861 gimple_seq body;
1862 pp_string (buffer, "#pragma omp parallel");
1863 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1864 if (gimple_omp_parallel_child_fn (gs))
1866 pp_string (buffer, " [child fn: ");
1867 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1868 spc, flags, false);
1869 pp_string (buffer, " (");
1870 if (gimple_omp_parallel_data_arg (gs))
1871 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1872 spc, flags, false);
1873 else
1874 pp_string (buffer, "???");
1875 pp_string (buffer, ")]");
1877 body = gimple_omp_body (gs);
1878 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1880 newline_and_indent (buffer, spc + 2);
1881 pp_left_brace (buffer);
1882 pp_newline (buffer);
1883 dump_gimple_seq (buffer, body, spc + 4, flags);
1884 newline_and_indent (buffer, spc + 2);
1885 pp_right_brace (buffer);
1887 else if (body)
1889 pp_newline (buffer);
1890 dump_gimple_seq (buffer, body, spc + 2, flags);
1896 /* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1897 of indent. FLAGS specifies details to show in the dump (see TDF_* in
1898 dumpfile.h). */
1900 static void
1901 dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
1902 int flags)
1904 if (flags & TDF_RAW)
1906 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1907 gimple_omp_body (gs));
1908 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1909 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1910 gimple_omp_task_child_fn (gs),
1911 gimple_omp_task_data_arg (gs),
1912 gimple_omp_task_copy_fn (gs),
1913 gimple_omp_task_arg_size (gs),
1914 gimple_omp_task_arg_size (gs));
1916 else
1918 gimple_seq body;
1919 pp_string (buffer, "#pragma omp task");
1920 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1921 if (gimple_omp_task_child_fn (gs))
1923 pp_string (buffer, " [child fn: ");
1924 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1925 spc, flags, false);
1926 pp_string (buffer, " (");
1927 if (gimple_omp_task_data_arg (gs))
1928 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1929 spc, flags, false);
1930 else
1931 pp_string (buffer, "???");
1932 pp_string (buffer, ")]");
1934 body = gimple_omp_body (gs);
1935 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1937 newline_and_indent (buffer, spc + 2);
1938 pp_left_brace (buffer);
1939 pp_newline (buffer);
1940 dump_gimple_seq (buffer, body, spc + 4, flags);
1941 newline_and_indent (buffer, spc + 2);
1942 pp_right_brace (buffer);
1944 else if (body)
1946 pp_newline (buffer);
1947 dump_gimple_seq (buffer, body, spc + 2, flags);
1953 /* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1954 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1955 in dumpfile.h). */
1957 static void
1958 dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
1959 int flags)
1961 if (flags & TDF_RAW)
1963 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1964 gimple_omp_atomic_load_lhs (gs),
1965 gimple_omp_atomic_load_rhs (gs));
1967 else
1969 pp_string (buffer, "#pragma omp atomic_load");
1970 if (gimple_omp_atomic_seq_cst_p (gs))
1971 pp_string (buffer, " seq_cst");
1972 if (gimple_omp_atomic_need_value_p (gs))
1973 pp_string (buffer, " [needed]");
1974 newline_and_indent (buffer, spc + 2);
1975 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
1976 spc, flags, false);
1977 pp_space (buffer);
1978 pp_equal (buffer);
1979 pp_space (buffer);
1980 pp_star (buffer);
1981 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
1982 spc, flags, false);
1986 /* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1987 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
1988 in dumpfile.h). */
1990 static void
1991 dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
1992 int flags)
1994 if (flags & TDF_RAW)
1996 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1997 gimple_omp_atomic_store_val (gs));
1999 else
2001 pp_string (buffer, "#pragma omp atomic_store ");
2002 if (gimple_omp_atomic_seq_cst_p (gs))
2003 pp_string (buffer, "seq_cst ");
2004 if (gimple_omp_atomic_need_value_p (gs))
2005 pp_string (buffer, "[needed] ");
2006 pp_left_paren (buffer);
2007 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2008 spc, flags, false);
2009 pp_right_paren (buffer);
2014 /* Dump all the memory operands for statement GS. BUFFER, SPC and
2015 FLAGS are as in pp_gimple_stmt_1. */
2017 static void
2018 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
2020 tree vdef = gimple_vdef (gs);
2021 tree vuse = gimple_vuse (gs);
2023 if (!ssa_operands_active (DECL_STRUCT_FUNCTION (current_function_decl))
2024 || !gimple_references_memory_p (gs))
2025 return;
2027 if (vdef != NULL_TREE)
2029 pp_string (buffer, "# ");
2030 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2031 pp_string (buffer, " = VDEF <");
2032 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2033 pp_greater (buffer);
2034 newline_and_indent (buffer, spc);
2036 else if (vuse != NULL_TREE)
2038 pp_string (buffer, "# VUSE <");
2039 dump_generic_node (buffer, vuse, spc + 2, flags, false);
2040 pp_greater (buffer);
2041 newline_and_indent (buffer, spc);
2046 /* Print the gimple statement GS on the pretty printer BUFFER, SPC
2047 spaces of indent. FLAGS specifies details to show in the dump (see
2048 TDF_* in dumpfile.h). The caller is responsible for calling
2049 pp_flush on BUFFER to finalize the pretty printer. */
2051 void
2052 pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
2054 if (!gs)
2055 return;
2057 if (flags & TDF_STMTADDR)
2058 pp_printf (buffer, "<&%p> ", (void *) gs);
2060 if ((flags & TDF_LINENO) && gimple_has_location (gs))
2062 expanded_location xloc = expand_location (gimple_location (gs));
2063 pp_left_bracket (buffer);
2064 if (xloc.file)
2066 pp_string (buffer, xloc.file);
2067 pp_string (buffer, " : ");
2069 pp_decimal_int (buffer, xloc.line);
2070 pp_colon (buffer);
2071 pp_decimal_int (buffer, xloc.column);
2072 pp_string (buffer, "] ");
2075 if (flags & TDF_EH)
2077 int lp_nr = lookup_stmt_eh_lp (gs);
2078 if (lp_nr > 0)
2079 pp_printf (buffer, "[LP %d] ", lp_nr);
2080 else if (lp_nr < 0)
2081 pp_printf (buffer, "[MNT %d] ", -lp_nr);
2084 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2085 && gimple_has_mem_ops (gs))
2086 dump_gimple_mem_ops (buffer, gs, spc, flags);
2088 if (gimple_has_lhs (gs)
2089 && (flags & TDF_ALIAS))
2090 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
2092 switch (gimple_code (gs))
2094 case GIMPLE_ASM:
2095 dump_gimple_asm (buffer, gs, spc, flags);
2096 break;
2098 case GIMPLE_ASSIGN:
2099 dump_gimple_assign (buffer, gs, spc, flags);
2100 break;
2102 case GIMPLE_BIND:
2103 dump_gimple_bind (buffer, gs, spc, flags);
2104 break;
2106 case GIMPLE_CALL:
2107 dump_gimple_call (buffer, gs, spc, flags);
2108 break;
2110 case GIMPLE_COND:
2111 dump_gimple_cond (buffer, gs, spc, flags);
2112 break;
2114 case GIMPLE_LABEL:
2115 dump_gimple_label (buffer, gs, spc, flags);
2116 break;
2118 case GIMPLE_GOTO:
2119 dump_gimple_goto (buffer, gs, spc, flags);
2120 break;
2122 case GIMPLE_NOP:
2123 pp_string (buffer, "GIMPLE_NOP");
2124 break;
2126 case GIMPLE_RETURN:
2127 dump_gimple_return (buffer, gs, spc, flags);
2128 break;
2130 case GIMPLE_SWITCH:
2131 dump_gimple_switch (buffer, gs, spc, flags);
2132 break;
2134 case GIMPLE_TRY:
2135 dump_gimple_try (buffer, gs, spc, flags);
2136 break;
2138 case GIMPLE_PHI:
2139 dump_gimple_phi (buffer, gs, spc, false, flags);
2140 break;
2142 case GIMPLE_OMP_PARALLEL:
2143 dump_gimple_omp_parallel (buffer, gs, spc, flags);
2144 break;
2146 case GIMPLE_OMP_TASK:
2147 dump_gimple_omp_task (buffer, gs, spc, flags);
2148 break;
2150 case GIMPLE_OMP_ATOMIC_LOAD:
2151 dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
2153 break;
2155 case GIMPLE_OMP_ATOMIC_STORE:
2156 dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
2157 break;
2159 case GIMPLE_OMP_FOR:
2160 dump_gimple_omp_for (buffer, gs, spc, flags);
2161 break;
2163 case GIMPLE_OMP_CONTINUE:
2164 dump_gimple_omp_continue (buffer, gs, spc, flags);
2165 break;
2167 case GIMPLE_OMP_SINGLE:
2168 dump_gimple_omp_single (buffer, gs, spc, flags);
2169 break;
2171 case GIMPLE_OMP_TARGET:
2172 dump_gimple_omp_target (buffer, gs, spc, flags);
2173 break;
2175 case GIMPLE_OMP_TEAMS:
2176 dump_gimple_omp_teams (buffer, gs, spc, flags);
2177 break;
2179 case GIMPLE_OMP_RETURN:
2180 dump_gimple_omp_return (buffer, gs, spc, flags);
2181 break;
2183 case GIMPLE_OMP_SECTIONS:
2184 dump_gimple_omp_sections (buffer, gs, spc, flags);
2185 break;
2187 case GIMPLE_OMP_SECTIONS_SWITCH:
2188 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2189 break;
2191 case GIMPLE_OMP_MASTER:
2192 case GIMPLE_OMP_TASKGROUP:
2193 case GIMPLE_OMP_ORDERED:
2194 case GIMPLE_OMP_SECTION:
2195 dump_gimple_omp_block (buffer, gs, spc, flags);
2196 break;
2198 case GIMPLE_OMP_CRITICAL:
2199 dump_gimple_omp_critical (buffer, gs, spc, flags);
2200 break;
2202 case GIMPLE_CATCH:
2203 dump_gimple_catch (buffer, gs, spc, flags);
2204 break;
2206 case GIMPLE_EH_FILTER:
2207 dump_gimple_eh_filter (buffer, gs, spc, flags);
2208 break;
2210 case GIMPLE_EH_MUST_NOT_THROW:
2211 dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
2212 break;
2214 case GIMPLE_EH_ELSE:
2215 dump_gimple_eh_else (buffer, gs, spc, flags);
2216 break;
2218 case GIMPLE_RESX:
2219 dump_gimple_resx (buffer, gs, spc, flags);
2220 break;
2222 case GIMPLE_EH_DISPATCH:
2223 dump_gimple_eh_dispatch (buffer, gs, spc, flags);
2224 break;
2226 case GIMPLE_DEBUG:
2227 dump_gimple_debug (buffer, gs, spc, flags);
2228 break;
2230 case GIMPLE_PREDICT:
2231 pp_string (buffer, "// predicted ");
2232 if (gimple_predict_outcome (gs))
2233 pp_string (buffer, "likely by ");
2234 else
2235 pp_string (buffer, "unlikely by ");
2236 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2237 pp_string (buffer, " predictor.");
2238 break;
2240 case GIMPLE_TRANSACTION:
2241 dump_gimple_transaction (buffer, gs, spc, flags);
2242 break;
2244 default:
2245 GIMPLE_NIY;
2250 /* Dumps header of basic block BB to OUTF indented by INDENT
2251 spaces and details described by flags. */
2253 static void
2254 dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
2256 if (flags & TDF_BLOCKS)
2258 if (flags & TDF_LINENO)
2260 gimple_stmt_iterator gsi;
2262 if (flags & TDF_COMMENT)
2263 fputs (";; ", outf);
2265 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2266 if (!is_gimple_debug (gsi_stmt (gsi))
2267 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
2269 fprintf (outf, "%*sstarting at line %d",
2270 indent, "", get_lineno (gsi_stmt (gsi)));
2271 break;
2273 if (bb->discriminator)
2274 fprintf (outf, ", discriminator %i", bb->discriminator);
2275 fputc ('\n', outf);
2278 else
2280 gimple stmt = first_stmt (bb);
2281 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2282 fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
2287 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2288 spaces. */
2290 static void
2291 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2292 basic_block bb ATTRIBUTE_UNUSED,
2293 int indent ATTRIBUTE_UNUSED,
2294 int flags ATTRIBUTE_UNUSED)
2296 /* There is currently no GIMPLE-specific basic block info to dump. */
2297 return;
2301 /* Dump PHI nodes of basic block BB to BUFFER with details described
2302 by FLAGS and indented by INDENT spaces. */
2304 static void
2305 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2307 gimple_stmt_iterator i;
2309 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2311 gimple phi = gsi_stmt (i);
2312 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
2314 INDENT (indent);
2315 dump_gimple_phi (buffer, phi, indent, true, flags);
2316 pp_newline (buffer);
2322 /* Dump jump to basic block BB that is represented implicitly in the cfg
2323 to BUFFER. */
2325 static void
2326 pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2328 gimple stmt;
2330 stmt = first_stmt (bb);
2332 pp_string (buffer, "goto <bb ");
2333 pp_decimal_int (buffer, bb->index);
2334 pp_greater (buffer);
2335 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2337 pp_string (buffer, " (");
2338 dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
2339 pp_right_paren (buffer);
2340 pp_semicolon (buffer);
2342 else
2343 pp_semicolon (buffer);
2347 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2348 by INDENT spaces, with details given by FLAGS. */
2350 static void
2351 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2352 int flags)
2354 edge e;
2355 gimple stmt;
2357 stmt = last_stmt (bb);
2359 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2361 edge true_edge, false_edge;
2363 /* When we are emitting the code or changing CFG, it is possible that
2364 the edges are not yet created. When we are using debug_bb in such
2365 a situation, we do not want it to crash. */
2366 if (EDGE_COUNT (bb->succs) != 2)
2367 return;
2368 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2370 INDENT (indent + 2);
2371 pp_cfg_jump (buffer, true_edge->dest);
2372 newline_and_indent (buffer, indent);
2373 pp_string (buffer, "else");
2374 newline_and_indent (buffer, indent + 2);
2375 pp_cfg_jump (buffer, false_edge->dest);
2376 pp_newline (buffer);
2377 return;
2380 /* If there is a fallthru edge, we may need to add an artificial
2381 goto to the dump. */
2382 e = find_fallthru_edge (bb->succs);
2384 if (e && e->dest != bb->next_bb)
2386 INDENT (indent);
2388 if ((flags & TDF_LINENO)
2389 && e->goto_locus != UNKNOWN_LOCATION
2392 expanded_location goto_xloc;
2393 goto_xloc = expand_location (e->goto_locus);
2394 pp_left_bracket (buffer);
2395 if (goto_xloc.file)
2397 pp_string (buffer, goto_xloc.file);
2398 pp_string (buffer, " : ");
2400 pp_decimal_int (buffer, goto_xloc.line);
2401 pp_string (buffer, " : ");
2402 pp_decimal_int (buffer, goto_xloc.column);
2403 pp_string (buffer, "] ");
2406 pp_cfg_jump (buffer, e->dest);
2407 pp_newline (buffer);
2412 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2413 indented by INDENT spaces. */
2415 static void
2416 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2417 int flags)
2419 gimple_stmt_iterator gsi;
2420 gimple stmt;
2421 int label_indent = indent - 2;
2423 if (label_indent < 0)
2424 label_indent = 0;
2426 dump_phi_nodes (buffer, bb, indent, flags);
2428 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2430 int curr_indent;
2432 stmt = gsi_stmt (gsi);
2434 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2436 INDENT (curr_indent);
2437 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
2438 pp_newline_and_flush (buffer);
2439 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2440 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
2441 pp_buffer (buffer)->stream, stmt);
2444 dump_implicit_edges (buffer, bb, indent, flags);
2445 pp_flush (buffer);
2449 /* Dumps basic block BB to FILE with details described by FLAGS and
2450 indented by INDENT spaces. */
2452 void
2453 gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
2455 dump_gimple_bb_header (file, bb, indent, flags);
2456 if (bb->index >= NUM_FIXED_BLOCKS)
2458 pretty_printer buffer;
2459 pp_needs_newline (&buffer) = true;
2460 buffer.buffer->stream = file;
2461 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2463 dump_gimple_bb_footer (file, bb, indent, flags);
2466 /* Dumps basic block BB to pretty-printer PP with default dump flags and
2467 no indentation, for use as a label of a DOT graph record-node.
2468 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2469 histogram dumping doesn't know about pretty-printers. */
2471 void
2472 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2474 gimple_stmt_iterator gsi;
2476 pp_printf (pp, "<bb %d>:\n", bb->index);
2477 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2479 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2481 gimple phi = gsi_stmt (gsi);
2482 if (!virtual_operand_p (gimple_phi_result (phi))
2483 || (dump_flags & TDF_VOPS))
2485 pp_bar (pp);
2486 pp_write_text_to_stream (pp);
2487 pp_string (pp, "# ");
2488 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2489 pp_newline (pp);
2490 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2494 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2496 gimple stmt = gsi_stmt (gsi);
2497 pp_bar (pp);
2498 pp_write_text_to_stream (pp);
2499 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2500 pp_newline (pp);
2501 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2503 dump_implicit_edges (pp, bb, 0, dump_flags);
2504 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);