]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gimple-pretty-print.c
cfgexpand.c (expand_used_vars): Use virtual_operand_p.
[thirdparty/gcc.git] / gcc / gimple-pretty-print.c
CommitLineData
726a989a 1/* Pretty formatting of GIMPLE statements and expressions.
ddb555ed
JJ
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
3 2011 Free Software Foundation, Inc.
726a989a
RB
4 Contributed by Aldy Hernandez <aldyh@redhat.com> and
5 Diego Novillo <dnovillo@google.com>
6
7This file is part of GCC.
8
9GCC is free software; you can redistribute it and/or modify it under
10the terms of the GNU General Public License as published by the Free
11Software Foundation; either version 3, or (at your option) any later
12version.
13
14GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15WARRANTY; without even the implied warranty of MERCHANTABILITY or
16FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17for more details.
18
19You should have received a copy of the GNU General Public License
20along with GCC; see the file COPYING3. If not see
21<http://www.gnu.org/licenses/>. */
22
23#include "config.h"
24#include "system.h"
25#include "coretypes.h"
26#include "tm.h"
27#include "tree.h"
28#include "diagnostic.h"
cf835838 29#include "gimple-pretty-print.h"
726a989a
RB
30#include "hashtab.h"
31#include "tree-flow.h"
7ee2468b 32#include "dumpfile.h" /* for dump_flags */
726a989a
RB
33#include "gimple.h"
34#include "value-prof.h"
0a35513e 35#include "trans-mem.h"
726a989a
RB
36
37#define INDENT(SPACE) \
38 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
39
40static pretty_printer buffer;
41static bool initialized = false;
42
43#define GIMPLE_NIY do_niy (buffer,gs)
44
45/* Try to print on BUFFER a default message for the unrecognized
46 gimple statement GS. */
47
48static void
49do_niy (pretty_printer *buffer, gimple gs)
50{
51 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
52 gimple_code_name[(int) gimple_code (gs)]);
53}
54
55
56/* Initialize the pretty printer on FILE if needed. */
57
58static void
59maybe_init_pretty_print (FILE *file)
60{
61 if (!initialized)
62 {
63 pp_construct (&buffer, NULL, 0);
64 pp_needs_newline (&buffer) = true;
65 initialized = true;
66 }
67
68 buffer.buffer->stream = file;
69}
70
71
72/* Emit a newline and SPC indentantion spaces to BUFFER. */
73
74static void
75newline_and_indent (pretty_printer *buffer, int spc)
76{
77 pp_newline (buffer);
78 INDENT (spc);
79}
80
81
82/* Print the GIMPLE statement GS on stderr. */
83
24e47c76 84DEBUG_FUNCTION void
726a989a
RB
85debug_gimple_stmt (gimple gs)
86{
87 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
88 fprintf (stderr, "\n");
89}
90
91
92/* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
93 FLAGS as in dump_gimple_stmt. */
94
95void
96print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
97{
98 maybe_init_pretty_print (file);
99 dump_gimple_stmt (&buffer, g, spc, flags);
f8923f7e 100 pp_newline_and_flush (&buffer);
726a989a
RB
101}
102
103
104/* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
105 FLAGS as in dump_gimple_stmt. Print only the right-hand side
106 of the statement. */
107
108void
109print_gimple_expr (FILE *file, gimple g, int spc, int flags)
110{
111 flags |= TDF_RHS_ONLY;
112 maybe_init_pretty_print (file);
113 dump_gimple_stmt (&buffer, g, spc, flags);
114}
115
116
117/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion
c4669594
SB
118 spaces and FLAGS as in dump_gimple_stmt.
119 The caller is responsible for calling pp_flush on BUFFER to finalize
120 the pretty printer. */
726a989a
RB
121
122static void
123dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
124{
125 gimple_stmt_iterator i;
126
127 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
128 {
129 gimple gs = gsi_stmt (i);
130 INDENT (spc);
131 dump_gimple_stmt (buffer, gs, spc, flags);
132 if (!gsi_one_before_end_p (i))
133 pp_newline (buffer);
134 }
135}
136
137
138/* Dump GIMPLE sequence SEQ to FILE using SPC indentantion spaces and
139 FLAGS as in dump_gimple_stmt. */
140
141void
142print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
143{
144 maybe_init_pretty_print (file);
145 dump_gimple_seq (&buffer, seq, spc, flags);
f8923f7e 146 pp_newline_and_flush (&buffer);
726a989a
RB
147}
148
149
150/* Print the GIMPLE sequence SEQ on stderr. */
151
24e47c76 152DEBUG_FUNCTION void
726a989a
RB
153debug_gimple_seq (gimple_seq seq)
154{
155 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
156}
157
158
159/* A simple helper to pretty-print some of the gimple tuples in the printf
073a8998 160 style. The format modifiers are preceded by '%' and are:
726a989a
RB
161 'G' - outputs a string corresponding to the code of the given gimple,
162 'S' - outputs a gimple_seq with indent of spc + 2,
163 'T' - outputs the tree t,
164 'd' - outputs an int as a decimal,
165 's' - outputs a string,
166 'n' - outputs a newline,
0a35513e 167 'x' - outputs an int as hexadecimal,
726a989a
RB
168 '+' - increases indent by 2 then outputs a newline,
169 '-' - decreases indent by 2 then outputs a newline. */
170
171static void
172dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
173 const char *fmt, ...)
174{
175 va_list args;
176 const char *c;
177 const char *tmp;
178
179 va_start (args, fmt);
180 for (c = fmt; *c; c++)
181 {
182 if (*c == '%')
183 {
184 gimple_seq seq;
185 tree t;
186 gimple g;
187 switch (*++c)
188 {
189 case 'G':
190 g = va_arg (args, gimple);
191 tmp = gimple_code_name[gimple_code (g)];
192 pp_string (buffer, tmp);
193 break;
194
195 case 'S':
196 seq = va_arg (args, gimple_seq);
197 pp_newline (buffer);
198 dump_gimple_seq (buffer, seq, spc + 2, flags);
199 newline_and_indent (buffer, spc);
200 break;
201
202 case 'T':
203 t = va_arg (args, tree);
204 if (t == NULL_TREE)
205 pp_string (buffer, "NULL");
206 else
207 dump_generic_node (buffer, t, spc, flags, false);
208 break;
209
210 case 'd':
211 pp_decimal_int (buffer, va_arg (args, int));
212 break;
213
214 case 's':
215 pp_string (buffer, va_arg (args, char *));
216 break;
217
218 case 'n':
219 newline_and_indent (buffer, spc);
220 break;
221
0a35513e
AH
222 case 'x':
223 pp_scalar (buffer, "%x", va_arg (args, int));
224 break;
225
726a989a
RB
226 case '+':
227 spc += 2;
228 newline_and_indent (buffer, spc);
229 break;
230
231 case '-':
232 spc -= 2;
233 newline_and_indent (buffer, spc);
234 break;
235
236 default:
237 gcc_unreachable ();
238 }
b8698a0f 239 }
726a989a
RB
240 else
241 pp_character (buffer, *c);
242 }
243 va_end (args);
244}
245
246
247/* Helper for dump_gimple_assign. Print the unary RHS of the
248 assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */
249
250static void
251dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
252{
253 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
254 tree lhs = gimple_assign_lhs (gs);
255 tree rhs = gimple_assign_rhs1 (gs);
256
257 switch (rhs_code)
258 {
259 case VIEW_CONVERT_EXPR:
260 case ASSERT_EXPR:
261 dump_generic_node (buffer, rhs, spc, flags, false);
262 break;
263
264 case FIXED_CONVERT_EXPR:
09e881c9 265 case ADDR_SPACE_CONVERT_EXPR:
726a989a
RB
266 case FIX_TRUNC_EXPR:
267 case FLOAT_EXPR:
268 CASE_CONVERT:
0cf0d02b 269 pp_character (buffer, '(');
726a989a
RB
270 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
271 pp_string (buffer, ") ");
0cf0d02b
JJ
272 if (op_prio (rhs) < op_code_prio (rhs_code))
273 {
274 pp_character (buffer, '(');
275 dump_generic_node (buffer, rhs, spc, flags, false);
276 pp_character (buffer, ')');
277 }
278 else
279 dump_generic_node (buffer, rhs, spc, flags, false);
726a989a 280 break;
b8698a0f 281
726a989a
RB
282 case PAREN_EXPR:
283 pp_string (buffer, "((");
284 dump_generic_node (buffer, rhs, spc, flags, false);
285 pp_string (buffer, "))");
286 break;
b8698a0f 287
726a989a
RB
288 case ABS_EXPR:
289 pp_string (buffer, "ABS_EXPR <");
290 dump_generic_node (buffer, rhs, spc, flags, false);
0cf0d02b 291 pp_character (buffer, '>');
726a989a
RB
292 break;
293
294 default:
295 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
296 || TREE_CODE_CLASS (rhs_code) == tcc_constant
297 || TREE_CODE_CLASS (rhs_code) == tcc_reference
298 || rhs_code == SSA_NAME
299 || rhs_code == ADDR_EXPR
300 || rhs_code == CONSTRUCTOR)
0cf0d02b
JJ
301 {
302 dump_generic_node (buffer, rhs, spc, flags, false);
303 break;
304 }
726a989a 305 else if (rhs_code == BIT_NOT_EXPR)
0cf0d02b 306 pp_character (buffer, '~');
726a989a 307 else if (rhs_code == TRUTH_NOT_EXPR)
0cf0d02b 308 pp_character (buffer, '!');
726a989a 309 else if (rhs_code == NEGATE_EXPR)
0cf0d02b 310 pp_character (buffer, '-');
726a989a
RB
311 else
312 {
0cf0d02b 313 pp_character (buffer, '[');
726a989a
RB
314 pp_string (buffer, tree_code_name [rhs_code]);
315 pp_string (buffer, "] ");
316 }
317
0cf0d02b
JJ
318 if (op_prio (rhs) < op_code_prio (rhs_code))
319 {
320 pp_character (buffer, '(');
321 dump_generic_node (buffer, rhs, spc, flags, false);
322 pp_character (buffer, ')');
323 }
324 else
325 dump_generic_node (buffer, rhs, spc, flags, false);
726a989a
RB
326 break;
327 }
328}
329
330
331/* Helper for dump_gimple_assign. Print the binary RHS of the
332 assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */
333
334static void
335dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
336{
2603276e
JJ
337 const char *p;
338 enum tree_code code = gimple_assign_rhs_code (gs);
339 switch (code)
726a989a
RB
340 {
341 case COMPLEX_EXPR:
726a989a 342 case MIN_EXPR:
726a989a 343 case MAX_EXPR:
2603276e
JJ
344 case VEC_WIDEN_MULT_HI_EXPR:
345 case VEC_WIDEN_MULT_LO_EXPR:
3f30a9a6
RH
346 case VEC_WIDEN_MULT_EVEN_EXPR:
347 case VEC_WIDEN_MULT_ODD_EXPR:
2603276e
JJ
348 case VEC_PACK_TRUNC_EXPR:
349 case VEC_PACK_SAT_EXPR:
350 case VEC_PACK_FIX_TRUNC_EXPR:
36ba4aae
IR
351 case VEC_WIDEN_LSHIFT_HI_EXPR:
352 case VEC_WIDEN_LSHIFT_LO_EXPR:
2603276e
JJ
353 for (p = tree_code_name [(int) code]; *p; p++)
354 pp_character (buffer, TOUPPER (*p));
355 pp_string (buffer, " <");
726a989a
RB
356 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
357 pp_string (buffer, ", ");
358 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
2603276e 359 pp_character (buffer, '>');
726a989a
RB
360 break;
361
362 default:
0cf0d02b
JJ
363 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
364 {
365 pp_character (buffer, '(');
366 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
367 false);
368 pp_character (buffer, ')');
369 }
370 else
371 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
726a989a
RB
372 pp_space (buffer);
373 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
374 pp_space (buffer);
0cf0d02b
JJ
375 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
376 {
377 pp_character (buffer, '(');
378 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
379 false);
380 pp_character (buffer, ')');
381 }
382 else
383 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
726a989a
RB
384 }
385}
386
0354c0c7
BS
387/* Helper for dump_gimple_assign. Print the ternary RHS of the
388 assignment GS. BUFFER, SPC and FLAGS are as in dump_gimple_stmt. */
389
390static void
391dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
392{
393 const char *p;
394 enum tree_code code = gimple_assign_rhs_code (gs);
395 switch (code)
396 {
397 case WIDEN_MULT_PLUS_EXPR:
398 case WIDEN_MULT_MINUS_EXPR:
399 for (p = tree_code_name [(int) code]; *p; p++)
400 pp_character (buffer, TOUPPER (*p));
401 pp_string (buffer, " <");
402 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
403 pp_string (buffer, ", ");
404 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
405 pp_string (buffer, ", ");
406 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
407 pp_character (buffer, '>');
408 break;
409
16949072
RG
410 case FMA_EXPR:
411 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
412 pp_string (buffer, " * ");
413 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
414 pp_string (buffer, " + ");
415 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
416 break;
417
f471fe72
RG
418 case DOT_PROD_EXPR:
419 pp_string (buffer, "DOT_PROD_EXPR <");
420 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
421 pp_string (buffer, ", ");
422 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
423 pp_string (buffer, ", ");
424 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
425 pp_string (buffer, ">");
426 break;
f90e8e2e 427
2205ed25
RH
428 case VEC_PERM_EXPR:
429 pp_string (buffer, "VEC_PERM_EXPR <");
f90e8e2e
AS
430 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
431 pp_string (buffer, ", ");
432 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
433 pp_string (buffer, ", ");
434 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
435 pp_string (buffer, ">");
436 break;
f471fe72
RG
437
438 case REALIGN_LOAD_EXPR:
439 pp_string (buffer, "REALIGN_LOAD <");
440 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
441 pp_string (buffer, ", ");
442 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
443 pp_string (buffer, ", ");
444 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
4e71066d
RG
445 pp_string (buffer, ">");
446 break;
447
448 case COND_EXPR:
449 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
450 pp_string (buffer, " ? ");
451 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
452 pp_string (buffer, " : ");
453 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
454 break;
455
456 case VEC_COND_EXPR:
457 pp_string (buffer, "VEC_COND_EXPR <");
458 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
459 pp_string (buffer, ", ");
460 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
461 pp_string (buffer, ", ");
462 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
f471fe72
RG
463 pp_string (buffer, ">");
464 break;
465
0354c0c7
BS
466 default:
467 gcc_unreachable ();
468 }
469}
470
726a989a
RB
471
472/* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
473 dump_gimple_stmt. */
474
475static void
476dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
477{
478 if (flags & TDF_RAW)
479 {
874a3756
MG
480 tree arg1 = NULL;
481 tree arg2 = NULL;
482 tree arg3 = NULL;
483 switch (gimple_num_ops (gs))
484 {
485 case 4:
486 arg3 = gimple_assign_rhs3 (gs);
487 case 3:
488 arg2 = gimple_assign_rhs2 (gs);
489 case 2:
490 arg1 = gimple_assign_rhs1 (gs);
491 break;
492 default:
493 gcc_unreachable ();
494 }
726a989a 495
874a3756 496 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
726a989a 497 tree_code_name[gimple_assign_rhs_code (gs)],
874a3756 498 gimple_assign_lhs (gs), arg1, arg2, arg3);
726a989a
RB
499 }
500 else
501 {
502 if (!(flags & TDF_RHS_ONLY))
503 {
504 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
505 pp_space (buffer);
506 pp_character (buffer, '=');
507
508 if (gimple_assign_nontemporal_move_p (gs))
509 pp_string (buffer, "{nt}");
510
511 if (gimple_has_volatile_ops (gs))
512 pp_string (buffer, "{v}");
513
514 pp_space (buffer);
515 }
516
517 if (gimple_num_ops (gs) == 2)
518 dump_unary_rhs (buffer, gs, spc, flags);
519 else if (gimple_num_ops (gs) == 3)
520 dump_binary_rhs (buffer, gs, spc, flags);
0354c0c7
BS
521 else if (gimple_num_ops (gs) == 4)
522 dump_ternary_rhs (buffer, gs, spc, flags);
726a989a
RB
523 else
524 gcc_unreachable ();
525 if (!(flags & TDF_RHS_ONLY))
526 pp_semicolon(buffer);
527 }
528}
529
530
531/* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
532 dump_gimple_stmt. */
533
534static void
535dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
536{
537 tree t;
538
539 t = gimple_return_retval (gs);
540 if (flags & TDF_RAW)
541 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
542 else
543 {
544 pp_string (buffer, "return");
545 if (t)
546 {
547 pp_space (buffer);
548 dump_generic_node (buffer, t, spc, flags, false);
549 }
550 pp_semicolon (buffer);
551 }
552}
553
554
555/* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
556 dump_gimple_call. */
557
558static void
559dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags)
560{
561 size_t i;
562
563 for (i = 0; i < gimple_call_num_args (gs); i++)
564 {
565 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
566 if (i < gimple_call_num_args (gs) - 1)
567 pp_string (buffer, ", ");
568 }
569
570 if (gimple_call_va_arg_pack_p (gs))
571 {
572 if (gimple_call_num_args (gs) > 0)
573 {
574 pp_character (buffer, ',');
575 pp_space (buffer);
576 }
577
578 pp_string (buffer, "__builtin_va_arg_pack ()");
579 }
580}
581
25a6a873
RG
582/* Dump the points-to solution *PT to BUFFER. */
583
584static void
585pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
586{
587 if (pt->anything)
588 {
589 pp_string (buffer, "anything ");
590 return;
591 }
592 if (pt->nonlocal)
593 pp_string (buffer, "nonlocal ");
594 if (pt->escaped)
595 pp_string (buffer, "escaped ");
596 if (pt->ipa_escaped)
597 pp_string (buffer, "unit-escaped ");
598 if (pt->null)
599 pp_string (buffer, "null ");
600 if (pt->vars
601 && !bitmap_empty_p (pt->vars))
602 {
603 bitmap_iterator bi;
604 unsigned i;
605 pp_string (buffer, "{ ");
606 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
607 {
46eb666a
RG
608 pp_string (buffer, "D.");
609 pp_decimal_int (buffer, i);
25a6a873
RG
610 pp_character (buffer, ' ');
611 }
612 pp_character (buffer, '}');
613 if (pt->vars_contains_global)
614 pp_string (buffer, " (glob)");
25a6a873
RG
615 }
616}
726a989a
RB
617
618/* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
619 dump_gimple_stmt. */
620
621static void
622dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
623{
624 tree lhs = gimple_call_lhs (gs);
0a35513e 625 tree fn = gimple_call_fn (gs);
726a989a 626
25a6a873
RG
627 if (flags & TDF_ALIAS)
628 {
629 struct pt_solution *pt;
630 pt = gimple_call_use_set (gs);
631 if (!pt_solution_empty_p (pt))
632 {
633 pp_string (buffer, "# USE = ");
634 pp_points_to_solution (buffer, pt);
635 newline_and_indent (buffer, spc);
636 }
637 pt = gimple_call_clobber_set (gs);
638 if (!pt_solution_empty_p (pt))
639 {
640 pp_string (buffer, "# CLB = ");
641 pp_points_to_solution (buffer, pt);
642 newline_and_indent (buffer, spc);
643 }
644 }
645
726a989a
RB
646 if (flags & TDF_RAW)
647 {
25583c4f
RS
648 if (gimple_call_internal_p (gs))
649 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
650 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
651 else
0a35513e 652 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
726a989a
RB
653 if (gimple_call_num_args (gs) > 0)
654 {
655 pp_string (buffer, ", ");
656 dump_gimple_call_args (buffer, gs, flags);
657 }
0cf0d02b 658 pp_character (buffer, '>');
726a989a
RB
659 }
660 else
661 {
662 if (lhs && !(flags & TDF_RHS_ONLY))
663 {
664 dump_generic_node (buffer, lhs, spc, flags, false);
665 pp_string (buffer, " =");
666
667 if (gimple_has_volatile_ops (gs))
668 pp_string (buffer, "{v}");
669
670 pp_space (buffer);
671 }
25583c4f
RS
672 if (gimple_call_internal_p (gs))
673 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
674 else
0a35513e 675 print_call_name (buffer, fn, flags);
726a989a
RB
676 pp_string (buffer, " (");
677 dump_gimple_call_args (buffer, gs, flags);
0cf0d02b 678 pp_character (buffer, ')');
726a989a
RB
679 if (!(flags & TDF_RHS_ONLY))
680 pp_semicolon (buffer);
681 }
682
683 if (gimple_call_chain (gs))
684 {
685 pp_string (buffer, " [static-chain: ");
686 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
687 pp_character (buffer, ']');
688 }
689
690 if (gimple_call_return_slot_opt_p (gs))
691 pp_string (buffer, " [return slot optimization]");
726a989a
RB
692 if (gimple_call_tail_p (gs))
693 pp_string (buffer, " [tail call]");
0a35513e 694
cbe9d630
SD
695 if (fn == NULL)
696 return;
697
0a35513e
AH
698 /* Dump the arguments of _ITM_beginTransaction sanely. */
699 if (TREE_CODE (fn) == ADDR_EXPR)
700 fn = TREE_OPERAND (fn, 0);
701 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
702 pp_string (buffer, " [tm-clone]");
703 if (TREE_CODE (fn) == FUNCTION_DECL
704 && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
705 && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
706 && gimple_call_num_args (gs) > 0)
707 {
708 tree t = gimple_call_arg (gs, 0);
709 unsigned HOST_WIDE_INT props;
710 gcc_assert (TREE_CODE (t) == INTEGER_CST);
711
712 pp_string (buffer, " [ ");
713
714 /* Get the transaction code properties. */
715 props = TREE_INT_CST_LOW (t);
716
717 if (props & PR_INSTRUMENTEDCODE)
718 pp_string (buffer, "instrumentedCode ");
719 if (props & PR_UNINSTRUMENTEDCODE)
720 pp_string (buffer, "uninstrumentedCode ");
721 if (props & PR_HASNOXMMUPDATE)
722 pp_string (buffer, "hasNoXMMUpdate ");
723 if (props & PR_HASNOABORT)
724 pp_string (buffer, "hasNoAbort ");
725 if (props & PR_HASNOIRREVOCABLE)
726 pp_string (buffer, "hasNoIrrevocable ");
727 if (props & PR_DOESGOIRREVOCABLE)
728 pp_string (buffer, "doesGoIrrevocable ");
729 if (props & PR_HASNOSIMPLEREADS)
730 pp_string (buffer, "hasNoSimpleReads ");
731 if (props & PR_AWBARRIERSOMITTED)
732 pp_string (buffer, "awBarriersOmitted ");
733 if (props & PR_RARBARRIERSOMITTED)
734 pp_string (buffer, "RaRBarriersOmitted ");
735 if (props & PR_UNDOLOGCODE)
736 pp_string (buffer, "undoLogCode ");
737 if (props & PR_PREFERUNINSTRUMENTED)
738 pp_string (buffer, "preferUninstrumented ");
739 if (props & PR_EXCEPTIONBLOCK)
740 pp_string (buffer, "exceptionBlock ");
741 if (props & PR_HASELSE)
742 pp_string (buffer, "hasElse ");
743 if (props & PR_READONLY)
744 pp_string (buffer, "readOnly ");
745
746 pp_string (buffer, "]");
747 }
726a989a
RB
748}
749
750
751/* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
752 dump_gimple_stmt. */
753
754static void
755dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
756{
757 unsigned int i;
758
759 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
760 if (flags & TDF_RAW)
761 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
762 gimple_switch_index (gs));
763 else
764 {
765 pp_string (buffer, "switch (");
766 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
767 pp_string (buffer, ") <");
768 }
769
770 for (i = 0; i < gimple_switch_num_labels (gs); i++)
771 {
772 tree case_label = gimple_switch_label (gs, i);
773 if (case_label == NULL_TREE)
774 continue;
775
776 dump_generic_node (buffer, case_label, spc, flags, false);
0cf0d02b 777 pp_character (buffer, ' ');
726a989a
RB
778 dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
779 if (i < gimple_switch_num_labels (gs) - 1)
780 pp_string (buffer, ", ");
781 }
0cf0d02b 782 pp_character (buffer, '>');
726a989a
RB
783}
784
785
786/* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
787 dump_gimple_stmt. */
788
789static void
790dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
791{
792 if (flags & TDF_RAW)
793 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
794 tree_code_name [gimple_cond_code (gs)],
795 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
796 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
797 else
798 {
799 if (!(flags & TDF_RHS_ONLY))
800 pp_string (buffer, "if (");
801 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
802 pp_space (buffer);
803 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
804 pp_space (buffer);
805 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
806 if (!(flags & TDF_RHS_ONLY))
807 {
0cf0d02b 808 pp_character (buffer, ')');
726a989a
RB
809
810 if (gimple_cond_true_label (gs))
811 {
812 pp_string (buffer, " goto ");
813 dump_generic_node (buffer, gimple_cond_true_label (gs),
814 spc, flags, false);
815 pp_semicolon (buffer);
816 }
817 if (gimple_cond_false_label (gs))
818 {
819 pp_string (buffer, " else goto ");
820 dump_generic_node (buffer, gimple_cond_false_label (gs),
821 spc, flags, false);
822 pp_semicolon (buffer);
823 }
824 }
825 }
826}
827
828
829/* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
830 spaces of indent. FLAGS specifies details to show in the dump (see
7ee2468b 831 TDF_* in dumpfils.h). */
726a989a
RB
832
833static void
834dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
835{
836 tree label = gimple_label_label (gs);
837 if (flags & TDF_RAW)
838 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
839 else
840 {
841 dump_generic_node (buffer, label, spc, flags, false);
0cf0d02b 842 pp_character (buffer, ':');
726a989a
RB
843 }
844 if (DECL_NONLOCAL (label))
845 pp_string (buffer, " [non-local]");
1d65f45c
RH
846 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
847 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
726a989a
RB
848}
849
850/* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
851 spaces of indent. FLAGS specifies details to show in the dump (see
7ee2468b 852 TDF_* in dumpfile.h). */
726a989a
RB
853
854static void
855dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
856{
857 tree label = gimple_goto_dest (gs);
858 if (flags & TDF_RAW)
859 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
860 else
861 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
862}
863
864
865/* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
866 spaces of indent. FLAGS specifies details to show in the dump (see
7ee2468b 867 TDF_* in dumpfile.h). */
726a989a
RB
868
869static void
870dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
871{
872 if (flags & TDF_RAW)
873 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
874 else
875 pp_character (buffer, '{');
876 if (!(flags & TDF_SLIM))
877 {
878 tree var;
879
910ad8de 880 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
726a989a
RB
881 {
882 newline_and_indent (buffer, 2);
883 print_declaration (buffer, var, spc, flags);
884 }
885 if (gimple_bind_vars (gs))
886 pp_newline (buffer);
887 }
888 pp_newline (buffer);
889 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
890 newline_and_indent (buffer, spc);
891 if (flags & TDF_RAW)
892 pp_character (buffer, '>');
893 else
894 pp_character (buffer, '}');
895}
896
897
898/* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
899 indent. FLAGS specifies details to show in the dump (see TDF_* in
7ee2468b 900 dumpfile.h). */
726a989a
RB
901
902static void
903dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
904{
905 if (flags & TDF_RAW)
906 {
907 const char *type;
908 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
909 type = "GIMPLE_TRY_CATCH";
910 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
911 type = "GIMPLE_TRY_FINALLY";
912 else
913 type = "UNKNOWN GIMPLE_TRY";
914 dump_gimple_fmt (buffer, spc, flags,
915 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
916 gimple_try_eval (gs), gimple_try_cleanup (gs));
917 }
918 else
919 {
920 pp_string (buffer, "try");
921 newline_and_indent (buffer, spc + 2);
0cf0d02b 922 pp_character (buffer, '{');
726a989a
RB
923 pp_newline (buffer);
924
925 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
926 newline_and_indent (buffer, spc + 2);
0cf0d02b 927 pp_character (buffer, '}');
726a989a
RB
928
929 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
930 {
931 newline_and_indent (buffer, spc);
932 pp_string (buffer, "catch");
933 newline_and_indent (buffer, spc + 2);
0cf0d02b 934 pp_character (buffer, '{');
726a989a
RB
935 }
936 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
937 {
938 newline_and_indent (buffer, spc);
939 pp_string (buffer, "finally");
940 newline_and_indent (buffer, spc + 2);
0cf0d02b 941 pp_character (buffer, '{');
726a989a
RB
942 }
943 else
944 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
945
946 pp_newline (buffer);
947 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
948 newline_and_indent (buffer, spc + 2);
949 pp_character (buffer, '}');
950 }
951}
952
953
954/* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
955 indent. FLAGS specifies details to show in the dump (see TDF_* in
7ee2468b 956 dumpfile.h). */
726a989a
RB
957
958static void
959dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
960{
961 if (flags & TDF_RAW)
962 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
963 gimple_catch_types (gs), gimple_catch_handler (gs));
964 else
965 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
966 gimple_catch_types (gs), gimple_catch_handler (gs));
967}
968
969
970/* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
971 indent. FLAGS specifies details to show in the dump (see TDF_* in
7ee2468b 972 dumpfile.h). */
726a989a
RB
973
974static void
975dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
976{
977 if (flags & TDF_RAW)
978 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
979 gimple_eh_filter_types (gs),
980 gimple_eh_filter_failure (gs));
981 else
982 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
983 gimple_eh_filter_types (gs),
984 gimple_eh_filter_failure (gs));
985}
986
987
1d65f45c
RH
988/* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
989
990static void
991dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
992 int spc, int flags)
993{
994 if (flags & TDF_RAW)
995 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
996 gimple_eh_must_not_throw_fndecl (gs));
997 else
998 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
999 gimple_eh_must_not_throw_fndecl (gs));
1000}
1001
1002
0a35513e
AH
1003/* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1004 indent. FLAGS specifies details to show in the dump (see TDF_* in
7ee2468b 1005 dumpfile.h). */
0a35513e
AH
1006
1007static void
1008dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags)
1009{
1010 if (flags & TDF_RAW)
1011 dump_gimple_fmt (buffer, spc, flags,
1012 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1013 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1014 else
1015 dump_gimple_fmt (buffer, spc, flags,
1016 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1017 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1018}
1019
1020
726a989a
RB
1021/* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1022 indent. FLAGS specifies details to show in the dump (see TDF_* in
7ee2468b 1023 dumpfile.h). */
726a989a
RB
1024
1025static void
1026dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
1027{
1028 if (flags & TDF_RAW)
1029 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1d65f45c 1030 gimple_resx_region (gs));
726a989a
RB
1031 else
1032 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1033}
1034
1d65f45c
RH
1035/* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1036
1037static void
1038dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
1039{
1040 if (flags & TDF_RAW)
1041 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1042 gimple_eh_dispatch_region (gs));
1043 else
1044 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1045 gimple_eh_dispatch_region (gs));
1046}
1047
b5b8b0ac
AO
1048/* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1049 of indent. FLAGS specifies details to show in the dump (see TDF_*
7ee2468b 1050 in dumpfile.h). */
b5b8b0ac
AO
1051
1052static void
1053dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
1054{
1055 switch (gs->gsbase.subcode)
1056 {
1057 case GIMPLE_DEBUG_BIND:
1058 if (flags & TDF_RAW)
1059 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1060 gimple_debug_bind_get_var (gs),
1061 gimple_debug_bind_get_value (gs));
1062 else
1063 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1064 gimple_debug_bind_get_var (gs),
1065 gimple_debug_bind_get_value (gs));
1066 break;
1067
ddb555ed
JJ
1068 case GIMPLE_DEBUG_SOURCE_BIND:
1069 if (flags & TDF_RAW)
1070 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1071 gimple_debug_source_bind_get_var (gs),
1072 gimple_debug_source_bind_get_value (gs));
1073 else
1074 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1075 gimple_debug_source_bind_get_var (gs),
1076 gimple_debug_source_bind_get_value (gs));
1077 break;
1078
b5b8b0ac
AO
1079 default:
1080 gcc_unreachable ();
1081 }
1082}
1083
726a989a
RB
1084/* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1085static void
1086dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
1087{
1088 size_t i;
1089
1090 if (flags & TDF_RAW)
1091 {
1092 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1093 gimple_omp_body (gs));
1094 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1095 dump_gimple_fmt (buffer, spc, flags, " >,");
1096 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1097 dump_gimple_fmt (buffer, spc, flags,
1098 "%+%T, %T, %T, %s, %T,%n",
1099 gimple_omp_for_index (gs, i),
1100 gimple_omp_for_initial (gs, i),
1101 gimple_omp_for_final (gs, i),
1102 tree_code_name[gimple_omp_for_cond (gs, i)],
1103 gimple_omp_for_incr (gs, i));
1104 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1105 gimple_omp_for_pre_body (gs));
1106 }
1107 else
1108 {
1109 pp_string (buffer, "#pragma omp for");
1110 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1111 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1112 {
1113 if (i)
1114 spc += 2;
1115 newline_and_indent (buffer, spc);
1116 pp_string (buffer, "for (");
1117 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1118 flags, false);
1119 pp_string (buffer, " = ");
1120 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1121 flags, false);
1122 pp_string (buffer, "; ");
1123
1124 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1125 flags, false);
1126 pp_space (buffer);
1127 switch (gimple_omp_for_cond (gs, i))
1128 {
1129 case LT_EXPR:
1130 pp_character (buffer, '<');
1131 break;
1132 case GT_EXPR:
1133 pp_character (buffer, '>');
1134 break;
1135 case LE_EXPR:
1136 pp_string (buffer, "<=");
1137 break;
1138 case GE_EXPR:
1139 pp_string (buffer, ">=");
1140 break;
1141 default:
1142 gcc_unreachable ();
1143 }
1144 pp_space (buffer);
1145 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1146 flags, false);
1147 pp_string (buffer, "; ");
1148
1149 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1150 flags, false);
1151 pp_string (buffer, " = ");
1152 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1153 flags, false);
1154 pp_character (buffer, ')');
1155 }
1156
1157 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1158 {
1159 newline_and_indent (buffer, spc + 2);
1160 pp_character (buffer, '{');
1161 pp_newline (buffer);
1162 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1163 newline_and_indent (buffer, spc + 2);
1164 pp_character (buffer, '}');
1165 }
1166 }
1167}
1168
1169/* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1170
1171static void
1172dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags)
1173{
1174 if (flags & TDF_RAW)
1175 {
1176 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1177 gimple_omp_continue_control_def (gs),
1178 gimple_omp_continue_control_use (gs));
1179 }
1180 else
1181 {
1182 pp_string (buffer, "#pragma omp continue (");
1183 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1184 spc, flags, false);
1185 pp_character (buffer, ',');
1186 pp_space (buffer);
1187 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1188 spc, flags, false);
1189 pp_character (buffer, ')');
1190 }
1191}
1192
1193/* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1194
1195static void
1196dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, int flags)
1197{
1198 if (flags & TDF_RAW)
1199 {
1200 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1201 gimple_omp_body (gs));
1202 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1203 dump_gimple_fmt (buffer, spc, flags, " >");
1204 }
1205 else
1206 {
1207 pp_string (buffer, "#pragma omp single");
1208 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1209 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1210 {
1211 newline_and_indent (buffer, spc + 2);
1212 pp_character (buffer, '{');
1213 pp_newline (buffer);
1214 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1215 newline_and_indent (buffer, spc + 2);
1216 pp_character (buffer, '}');
1217 }
1218 }
1219}
1220
1221/* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1222
1223static void
1224dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
1225 int flags)
1226{
1227 if (flags & TDF_RAW)
1228 {
1229 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1230 gimple_omp_body (gs));
1231 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1232 dump_gimple_fmt (buffer, spc, flags, " >");
1233 }
1234 else
1235 {
1236 pp_string (buffer, "#pragma omp sections");
1237 if (gimple_omp_sections_control (gs))
1238 {
1239 pp_string (buffer, " <");
1240 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1241 flags, false);
1242 pp_character (buffer, '>');
1243 }
1244 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1245 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1246 {
1247 newline_and_indent (buffer, spc + 2);
1248 pp_character (buffer, '{');
1249 pp_newline (buffer);
1250 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1251 newline_and_indent (buffer, spc + 2);
1252 pp_character (buffer, '}');
1253 }
1254 }
1255}
1256
1257/* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the pretty_printer
1258 BUFFER. */
1259
1260static void
1261dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
1262{
1263 if (flags & TDF_RAW)
1264 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1265 gimple_omp_body (gs));
1266 else
1267 {
1268 switch (gimple_code (gs))
1269 {
1270 case GIMPLE_OMP_MASTER:
1271 pp_string (buffer, "#pragma omp master");
1272 break;
1273 case GIMPLE_OMP_ORDERED:
1274 pp_string (buffer, "#pragma omp ordered");
1275 break;
1276 case GIMPLE_OMP_SECTION:
1277 pp_string (buffer, "#pragma omp section");
1278 break;
1279 default:
1280 gcc_unreachable ();
1281 }
1282 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1283 {
1284 newline_and_indent (buffer, spc + 2);
1285 pp_character (buffer, '{');
1286 pp_newline (buffer);
1287 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1288 newline_and_indent (buffer, spc + 2);
1289 pp_character (buffer, '}');
1290 }
1291 }
1292}
1293
1294/* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1295
1296static void
1297dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
1298 int flags)
1299{
1300 if (flags & TDF_RAW)
1301 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1302 gimple_omp_body (gs));
1303 else
1304 {
1305 pp_string (buffer, "#pragma omp critical");
1306 if (gimple_omp_critical_name (gs))
1307 {
1308 pp_string (buffer, " (");
1309 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1310 flags, false);
1311 pp_character (buffer, ')');
1312 }
1313 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1314 {
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, '}');
1321 }
1322 }
1323}
1324
1325/* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1326
1327static void
1328dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
1329{
1330 if (flags & TDF_RAW)
1331 {
1332 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d>", gs,
1333 (int) gimple_omp_return_nowait_p (gs));
1334 }
1335 else
1336 {
1337 pp_string (buffer, "#pragma omp return");
1338 if (gimple_omp_return_nowait_p (gs))
1339 pp_string (buffer, "(nowait)");
1340 }
1341}
1342
0a35513e
AH
1343/* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1344
1345static void
1346dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags)
1347{
1348 unsigned subcode = gimple_transaction_subcode (gs);
1349
1350 if (flags & TDF_RAW)
1351 {
1352 dump_gimple_fmt (buffer, spc, flags,
1353 "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
1354 gs, subcode, gimple_transaction_label (gs),
1355 gimple_transaction_body (gs));
1356 }
1357 else
1358 {
1359 if (subcode & GTMA_IS_OUTER)
1360 pp_string (buffer, "__transaction_atomic [[outer]]");
1361 else if (subcode & GTMA_IS_RELAXED)
1362 pp_string (buffer, "__transaction_relaxed");
1363 else
1364 pp_string (buffer, "__transaction_atomic");
1365 subcode &= ~GTMA_DECLARATION_MASK;
1366
1367 if (subcode || gimple_transaction_label (gs))
1368 {
1369 pp_string (buffer, " //");
1370 if (gimple_transaction_label (gs))
1371 {
1372 pp_string (buffer, " LABEL=");
1373 dump_generic_node (buffer, gimple_transaction_label (gs),
1374 spc, flags, false);
1375 }
1376 if (subcode)
1377 {
1378 pp_string (buffer, " SUBCODE=[ ");
1379 if (subcode & GTMA_HAVE_ABORT)
1380 {
1381 pp_string (buffer, "GTMA_HAVE_ABORT ");
1382 subcode &= ~GTMA_HAVE_ABORT;
1383 }
1384 if (subcode & GTMA_HAVE_LOAD)
1385 {
1386 pp_string (buffer, "GTMA_HAVE_LOAD ");
1387 subcode &= ~GTMA_HAVE_LOAD;
1388 }
1389 if (subcode & GTMA_HAVE_STORE)
1390 {
1391 pp_string (buffer, "GTMA_HAVE_STORE ");
1392 subcode &= ~GTMA_HAVE_STORE;
1393 }
1394 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1395 {
1396 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1397 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1398 }
1399 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1400 {
1401 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1402 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1403 }
1404 if (subcode)
1405 pp_printf (buffer, "0x%x ", subcode);
1406 pp_string (buffer, "]");
1407 }
1408 }
1409
1410 if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
1411 {
1412 newline_and_indent (buffer, spc + 2);
1413 pp_character (buffer, '{');
1414 pp_newline (buffer);
1415 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1416 spc + 4, flags);
1417 newline_and_indent (buffer, spc + 2);
1418 pp_character (buffer, '}');
1419 }
1420 }
1421}
1422
726a989a
RB
1423/* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1424 indent. FLAGS specifies details to show in the dump (see TDF_* in
7ee2468b 1425 dumpfile.h). */
726a989a
RB
1426
1427static void
1428dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
1429{
1c384bf1 1430 unsigned int i, n, f, fields;
726a989a
RB
1431
1432 if (flags & TDF_RAW)
1c384bf1
RH
1433 {
1434 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1435 gimple_asm_string (gs));
1436
1437 n = gimple_asm_noutputs (gs);
1438 if (n)
1439 {
1440 newline_and_indent (buffer, spc + 2);
1441 pp_string (buffer, "OUTPUT: ");
1442 for (i = 0; i < n; i++)
1443 {
1444 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1445 spc, flags, false);
1446 if (i < n - 1)
1447 pp_string (buffer, ", ");
1448 }
1449 }
1450
1451 n = gimple_asm_ninputs (gs);
1452 if (n)
1453 {
1454 newline_and_indent (buffer, spc + 2);
1455 pp_string (buffer, "INPUT: ");
1456 for (i = 0; i < n; i++)
1457 {
1458 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1459 spc, flags, false);
1460 if (i < n - 1)
1461 pp_string (buffer, ", ");
1462 }
1463 }
1464
1465 n = gimple_asm_nclobbers (gs);
1466 if (n)
1467 {
1468 newline_and_indent (buffer, spc + 2);
1469 pp_string (buffer, "CLOBBER: ");
1470 for (i = 0; i < n; i++)
1471 {
1472 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1473 spc, flags, false);
1474 if (i < n - 1)
1475 pp_string (buffer, ", ");
1476 }
1477 }
1478
1479 n = gimple_asm_nlabels (gs);
1480 if (n)
1481 {
1482 newline_and_indent (buffer, spc + 2);
1483 pp_string (buffer, "LABEL: ");
1484 for (i = 0; i < n; i++)
1485 {
1486 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1487 spc, flags, false);
1488 if (i < n - 1)
1489 pp_string (buffer, ", ");
1490 }
1491 }
1492
1493 newline_and_indent (buffer, spc);
1494 pp_character (buffer, '>');
1495 }
726a989a
RB
1496 else
1497 {
1498 pp_string (buffer, "__asm__");
1499 if (gimple_asm_volatile_p (gs))
1500 pp_string (buffer, " __volatile__");
1c384bf1
RH
1501 if (gimple_asm_nlabels (gs))
1502 pp_string (buffer, " goto");
726a989a
RB
1503 pp_string (buffer, "(\"");
1504 pp_string (buffer, gimple_asm_string (gs));
1505 pp_string (buffer, "\"");
726a989a 1506
1c384bf1
RH
1507 if (gimple_asm_nlabels (gs))
1508 fields = 4;
1509 else if (gimple_asm_nclobbers (gs))
1510 fields = 3;
1511 else if (gimple_asm_ninputs (gs))
1512 fields = 2;
1513 else if (gimple_asm_noutputs (gs))
1514 fields = 1;
1515 else
1516 fields = 0;
726a989a 1517
1c384bf1
RH
1518 for (f = 0; f < fields; ++f)
1519 {
1520 pp_string (buffer, " : ");
726a989a 1521
1c384bf1
RH
1522 switch (f)
1523 {
1524 case 0:
1525 n = gimple_asm_noutputs (gs);
1526 for (i = 0; i < n; i++)
1527 {
1528 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1529 spc, flags, false);
1530 if (i < n - 1)
1531 pp_string (buffer, ", ");
1532 }
1533 break;
726a989a 1534
1c384bf1
RH
1535 case 1:
1536 n = gimple_asm_ninputs (gs);
1537 for (i = 0; i < n; i++)
1538 {
1539 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
1540 spc, flags, false);
1541 if (i < n - 1)
1542 pp_string (buffer, ", ");
1543 }
1544 break;
726a989a 1545
1c384bf1
RH
1546 case 2:
1547 n = gimple_asm_nclobbers (gs);
1548 for (i = 0; i < n; i++)
1549 {
1550 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
1551 spc, flags, false);
1552 if (i < n - 1)
1553 pp_string (buffer, ", ");
1554 }
1555 break;
726a989a 1556
1c384bf1
RH
1557 case 3:
1558 n = gimple_asm_nlabels (gs);
1559 for (i = 0; i < n; i++)
1560 {
1561 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
1562 spc, flags, false);
1563 if (i < n - 1)
1564 pp_string (buffer, ", ");
1565 }
1566 break;
1567
1568 default:
1569 gcc_unreachable ();
1570 }
1571 }
1572
1573 pp_string (buffer, ");");
726a989a 1574 }
726a989a
RB
1575}
1576
1577
c4669594
SB
1578/* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in dump_gimple_stmt.
1579 The caller is responsible for calling pp_flush on BUFFER to finalize
1580 pretty printer. */
726a989a
RB
1581
1582static void
1583dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags)
1584{
1585 size_t i;
f0107145
RG
1586 tree lhs = gimple_phi_result (phi);
1587
1588 if (flags & TDF_ALIAS
1589 && POINTER_TYPE_P (TREE_TYPE (lhs))
1590 && SSA_NAME_PTR_INFO (lhs))
1591 {
644ffefd 1592 unsigned int align, misalign;
1be38ccb 1593 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
f0107145 1594 pp_string (buffer, "PT = ");
1be38ccb
RG
1595 pp_points_to_solution (buffer, &pi->pt);
1596 newline_and_indent (buffer, spc);
644ffefd 1597 if (get_ptr_info_alignment (pi, &align, &misalign))
b1edf2bc 1598 {
644ffefd 1599 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
b1edf2bc
RG
1600 newline_and_indent (buffer, spc);
1601 }
f0107145
RG
1602 pp_string (buffer, "# ");
1603 }
726a989a
RB
1604
1605 if (flags & TDF_RAW)
1606 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
1607 gimple_phi_result (phi));
1608 else
1609 {
f0107145 1610 dump_generic_node (buffer, lhs, spc, flags, false);
726a989a
RB
1611 pp_string (buffer, " = PHI <");
1612 }
1613 for (i = 0; i < gimple_phi_num_args (phi); i++)
1614 {
f5045c96
AM
1615 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
1616 {
1617 expanded_location xloc;
1618
1619 xloc = expand_location (gimple_phi_arg_location (phi, i));
1620 pp_character (buffer, '[');
1621 if (xloc.file)
1622 {
1623 pp_string (buffer, xloc.file);
1624 pp_string (buffer, " : ");
1625 }
1626 pp_decimal_int (buffer, xloc.line);
1627 pp_string (buffer, ":");
1628 pp_decimal_int (buffer, xloc.column);
1629 pp_string (buffer, "] ");
1630 }
726a989a
RB
1631 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
1632 false);
0cf0d02b 1633 pp_character (buffer, '(');
726a989a 1634 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
0cf0d02b 1635 pp_character (buffer, ')');
726a989a
RB
1636 if (i < gimple_phi_num_args (phi) - 1)
1637 pp_string (buffer, ", ");
1638 }
0cf0d02b 1639 pp_character (buffer, '>');
726a989a
RB
1640}
1641
1642
1643/* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
1644 of indent. FLAGS specifies details to show in the dump (see TDF_* in
7ee2468b 1645 dumpfile.h). */
726a989a
RB
1646
1647static void
1648dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
1649 int flags)
1650{
1651 if (flags & TDF_RAW)
1652 {
1653 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1654 gimple_omp_body (gs));
1655 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1656 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1657 gimple_omp_parallel_child_fn (gs),
1658 gimple_omp_parallel_data_arg (gs));
1659 }
1660 else
1661 {
1662 gimple_seq body;
1663 pp_string (buffer, "#pragma omp parallel");
1664 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
1665 if (gimple_omp_parallel_child_fn (gs))
1666 {
1667 pp_string (buffer, " [child fn: ");
1668 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
1669 spc, flags, false);
1670 pp_string (buffer, " (");
1671 if (gimple_omp_parallel_data_arg (gs))
1672 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
1673 spc, flags, false);
1674 else
1675 pp_string (buffer, "???");
1676 pp_string (buffer, ")]");
1677 }
1678 body = gimple_omp_body (gs);
1679 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1680 {
1681 newline_and_indent (buffer, spc + 2);
1682 pp_character (buffer, '{');
1683 pp_newline (buffer);
1684 dump_gimple_seq (buffer, body, spc + 4, flags);
1685 newline_and_indent (buffer, spc + 2);
1686 pp_character (buffer, '}');
1687 }
1688 else if (body)
1689 {
1690 pp_newline (buffer);
1691 dump_gimple_seq (buffer, body, spc + 2, flags);
1692 }
1693 }
1694}
1695
1696
1697/* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
1698 of indent. FLAGS specifies details to show in the dump (see TDF_* in
7ee2468b 1699 dumpfile.h). */
726a989a
RB
1700
1701static void
1702dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
1703 int flags)
1704{
1705 if (flags & TDF_RAW)
1706 {
1707 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1708 gimple_omp_body (gs));
1709 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1710 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
1711 gimple_omp_task_child_fn (gs),
1712 gimple_omp_task_data_arg (gs),
1713 gimple_omp_task_copy_fn (gs),
1714 gimple_omp_task_arg_size (gs),
1715 gimple_omp_task_arg_size (gs));
1716 }
1717 else
1718 {
1719 gimple_seq body;
1720 pp_string (buffer, "#pragma omp task");
1721 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
1722 if (gimple_omp_task_child_fn (gs))
1723 {
1724 pp_string (buffer, " [child fn: ");
1725 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
1726 spc, flags, false);
1727 pp_string (buffer, " (");
1728 if (gimple_omp_task_data_arg (gs))
1729 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
1730 spc, flags, false);
1731 else
1732 pp_string (buffer, "???");
1733 pp_string (buffer, ")]");
1734 }
1735 body = gimple_omp_body (gs);
1736 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
1737 {
1738 newline_and_indent (buffer, spc + 2);
1739 pp_character (buffer, '{');
1740 pp_newline (buffer);
1741 dump_gimple_seq (buffer, body, spc + 4, flags);
1742 newline_and_indent (buffer, spc + 2);
1743 pp_character (buffer, '}');
1744 }
1745 else if (body)
1746 {
1747 pp_newline (buffer);
1748 dump_gimple_seq (buffer, body, spc + 2, flags);
1749 }
1750 }
1751}
1752
1753
1754/* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
1755 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
7ee2468b 1756 in dumpfile.h). */
726a989a
RB
1757
1758static void
1759dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
1760 int flags)
1761{
1762 if (flags & TDF_RAW)
1763 {
1764 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1765 gimple_omp_atomic_load_lhs (gs),
1766 gimple_omp_atomic_load_rhs (gs));
1767 }
1768 else
1769 {
1770 pp_string (buffer, "#pragma omp atomic_load");
05409788
RH
1771 if (gimple_omp_atomic_need_value_p (gs))
1772 pp_string (buffer, " [needed]");
726a989a
RB
1773 newline_and_indent (buffer, spc + 2);
1774 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
1775 spc, flags, false);
1776 pp_space (buffer);
1777 pp_character (buffer, '=');
1778 pp_space (buffer);
1779 pp_character (buffer, '*');
1780 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
1781 spc, flags, false);
1782 }
1783}
1784
1785/* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
1786 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
7ee2468b 1787 in dumpfile.h). */
726a989a
RB
1788
1789static void
1790dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
1791 int flags)
1792{
1793 if (flags & TDF_RAW)
1794 {
1795 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1796 gimple_omp_atomic_store_val (gs));
1797 }
1798 else
1799 {
05409788
RH
1800 pp_string (buffer, "#pragma omp atomic_store ");
1801 if (gimple_omp_atomic_need_value_p (gs))
1802 pp_string (buffer, "[needed] ");
1803 pp_character (buffer, '(');
726a989a
RB
1804 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
1805 spc, flags, false);
1806 pp_character (buffer, ')');
1807 }
1808}
1809
726a989a
RB
1810
1811/* Dump all the memory operands for statement GS. BUFFER, SPC and
1812 FLAGS are as in dump_gimple_stmt. */
1813
1814static void
1815dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
1816{
5006671f
RG
1817 tree vdef = gimple_vdef (gs);
1818 tree vuse = gimple_vuse (gs);
726a989a
RB
1819
1820 if (!ssa_operands_active () || !gimple_references_memory_p (gs))
1821 return;
1822
5006671f 1823 if (vdef != NULL_TREE)
726a989a 1824 {
5006671f
RG
1825 pp_string (buffer, "# ");
1826 dump_generic_node (buffer, vdef, spc + 2, flags, false);
1827 pp_string (buffer, " = VDEF <");
1828 dump_generic_node (buffer, vuse, spc + 2, flags, false);
0cf0d02b 1829 pp_character (buffer, '>');
726a989a 1830 newline_and_indent (buffer, spc);
726a989a 1831 }
5006671f 1832 else if (vuse != NULL_TREE)
726a989a 1833 {
5006671f
RG
1834 pp_string (buffer, "# VUSE <");
1835 dump_generic_node (buffer, vuse, spc + 2, flags, false);
0cf0d02b 1836 pp_character (buffer, '>');
726a989a 1837 newline_and_indent (buffer, spc);
726a989a
RB
1838 }
1839}
1840
1841
1842/* Dump the gimple statement GS on the pretty printer BUFFER, SPC
1843 spaces of indent. FLAGS specifies details to show in the dump (see
c4669594
SB
1844 TDF_* in dumpfile.h). The caller is responsible for calling
1845 pp_flush on BUFFER to finalize the pretty printer. */
726a989a
RB
1846
1847void
1848dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
1849{
1850 if (!gs)
1851 return;
1852
1853 if (flags & TDF_STMTADDR)
1854 pp_printf (buffer, "<&%p> ", (void *) gs);
1855
1856 if ((flags & TDF_LINENO) && gimple_has_location (gs))
1857 {
1858 expanded_location xloc = expand_location (gimple_location (gs));
1859 pp_character (buffer, '[');
1860 if (xloc.file)
1861 {
1862 pp_string (buffer, xloc.file);
1863 pp_string (buffer, " : ");
1864 }
1865 pp_decimal_int (buffer, xloc.line);
c2255bc4
AH
1866 pp_string (buffer, ":");
1867 pp_decimal_int (buffer, xloc.column);
726a989a
RB
1868 pp_string (buffer, "] ");
1869 }
1870
cae63f88
DN
1871 if (flags & TDF_EH)
1872 {
1d65f45c
RH
1873 int lp_nr = lookup_stmt_eh_lp (gs);
1874 if (lp_nr > 0)
1875 pp_printf (buffer, "[LP %d] ", lp_nr);
1876 else if (lp_nr < 0)
1877 pp_printf (buffer, "[MNT %d] ", -lp_nr);
cae63f88
DN
1878 }
1879
726a989a
RB
1880 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
1881 && gimple_has_mem_ops (gs))
1882 dump_gimple_mem_ops (buffer, gs, spc, flags);
1883
f0107145
RG
1884 if ((flags & TDF_ALIAS)
1885 && gimple_has_lhs (gs))
1886 {
1887 tree lhs = gimple_get_lhs (gs);
1888 if (TREE_CODE (lhs) == SSA_NAME
1889 && POINTER_TYPE_P (TREE_TYPE (lhs))
1890 && SSA_NAME_PTR_INFO (lhs))
1891 {
644ffefd 1892 unsigned int align, misalign;
1be38ccb 1893 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
f0107145 1894 pp_string (buffer, "# PT = ");
1be38ccb 1895 pp_points_to_solution (buffer, &pi->pt);
f0107145 1896 newline_and_indent (buffer, spc);
644ffefd 1897 if (get_ptr_info_alignment (pi, &align, &misalign))
1be38ccb
RG
1898 {
1899 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u",
644ffefd 1900 align, misalign);
1be38ccb
RG
1901 newline_and_indent (buffer, spc);
1902 }
f0107145
RG
1903 }
1904 }
1905
726a989a
RB
1906 switch (gimple_code (gs))
1907 {
1908 case GIMPLE_ASM:
1909 dump_gimple_asm (buffer, gs, spc, flags);
1910 break;
1911
1912 case GIMPLE_ASSIGN:
1913 dump_gimple_assign (buffer, gs, spc, flags);
1914 break;
1915
1916 case GIMPLE_BIND:
1917 dump_gimple_bind (buffer, gs, spc, flags);
1918 break;
1919
1920 case GIMPLE_CALL:
1921 dump_gimple_call (buffer, gs, spc, flags);
1922 break;
1923
1924 case GIMPLE_COND:
1925 dump_gimple_cond (buffer, gs, spc, flags);
1926 break;
1927
1928 case GIMPLE_LABEL:
1929 dump_gimple_label (buffer, gs, spc, flags);
1930 break;
1931
1932 case GIMPLE_GOTO:
1933 dump_gimple_goto (buffer, gs, spc, flags);
1934 break;
1935
1936 case GIMPLE_NOP:
1937 pp_string (buffer, "GIMPLE_NOP");
1938 break;
1939
1940 case GIMPLE_RETURN:
1941 dump_gimple_return (buffer, gs, spc, flags);
1942 break;
1943
1944 case GIMPLE_SWITCH:
1945 dump_gimple_switch (buffer, gs, spc, flags);
1946 break;
1947
1948 case GIMPLE_TRY:
1949 dump_gimple_try (buffer, gs, spc, flags);
1950 break;
1951
1952 case GIMPLE_PHI:
1953 dump_gimple_phi (buffer, gs, spc, flags);
1954 break;
1955
1956 case GIMPLE_OMP_PARALLEL:
1957 dump_gimple_omp_parallel (buffer, gs, spc, flags);
1958 break;
1959
1960 case GIMPLE_OMP_TASK:
1961 dump_gimple_omp_task (buffer, gs, spc, flags);
1962 break;
1963
1964 case GIMPLE_OMP_ATOMIC_LOAD:
1965 dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
1966
1967 break;
1968
1969 case GIMPLE_OMP_ATOMIC_STORE:
1970 dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
1971 break;
1972
1973 case GIMPLE_OMP_FOR:
1974 dump_gimple_omp_for (buffer, gs, spc, flags);
1975 break;
1976
1977 case GIMPLE_OMP_CONTINUE:
1978 dump_gimple_omp_continue (buffer, gs, spc, flags);
1979 break;
1980
1981 case GIMPLE_OMP_SINGLE:
1982 dump_gimple_omp_single (buffer, gs, spc, flags);
1983 break;
1984
1985 case GIMPLE_OMP_RETURN:
1986 dump_gimple_omp_return (buffer, gs, spc, flags);
1987 break;
1988
1989 case GIMPLE_OMP_SECTIONS:
1990 dump_gimple_omp_sections (buffer, gs, spc, flags);
1991 break;
1992
1993 case GIMPLE_OMP_SECTIONS_SWITCH:
1994 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
1995 break;
1996
1997 case GIMPLE_OMP_MASTER:
1998 case GIMPLE_OMP_ORDERED:
1999 case GIMPLE_OMP_SECTION:
2000 dump_gimple_omp_block (buffer, gs, spc, flags);
2001 break;
2002
2003 case GIMPLE_OMP_CRITICAL:
2004 dump_gimple_omp_critical (buffer, gs, spc, flags);
2005 break;
2006
726a989a
RB
2007 case GIMPLE_CATCH:
2008 dump_gimple_catch (buffer, gs, spc, flags);
2009 break;
2010
2011 case GIMPLE_EH_FILTER:
2012 dump_gimple_eh_filter (buffer, gs, spc, flags);
2013 break;
2014
1d65f45c
RH
2015 case GIMPLE_EH_MUST_NOT_THROW:
2016 dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
2017 break;
2018
0a35513e
AH
2019 case GIMPLE_EH_ELSE:
2020 dump_gimple_eh_else (buffer, gs, spc, flags);
2021 break;
2022
726a989a
RB
2023 case GIMPLE_RESX:
2024 dump_gimple_resx (buffer, gs, spc, flags);
2025 break;
2026
1d65f45c
RH
2027 case GIMPLE_EH_DISPATCH:
2028 dump_gimple_eh_dispatch (buffer, gs, spc, flags);
2029 break;
2030
b5b8b0ac
AO
2031 case GIMPLE_DEBUG:
2032 dump_gimple_debug (buffer, gs, spc, flags);
2033 break;
2034
726a989a
RB
2035 case GIMPLE_PREDICT:
2036 pp_string (buffer, "// predicted ");
2037 if (gimple_predict_outcome (gs))
2038 pp_string (buffer, "likely by ");
2039 else
2040 pp_string (buffer, "unlikely by ");
2041 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2042 pp_string (buffer, " predictor.");
2043 break;
2044
0a35513e
AH
2045 case GIMPLE_TRANSACTION:
2046 dump_gimple_transaction (buffer, gs, spc, flags);
2047 break;
2048
726a989a
RB
2049 default:
2050 GIMPLE_NIY;
2051 }
2052
2053 /* If we're building a diagnostic, the formatted text will be
2054 written into BUFFER's stream by the caller; otherwise, write it
2055 now. */
2056 if (!(flags & TDF_DIAGNOSTIC))
2057 pp_write_text_to_stream (buffer);
2058}
2059
2060
a315c44c 2061/* Dumps header of basic block BB to OUTF indented by INDENT
726a989a
RB
2062 spaces and details described by flags. */
2063
2064static void
a315c44c 2065dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
726a989a 2066{
726a989a
RB
2067 if (flags & TDF_BLOCKS)
2068 {
726a989a
RB
2069 if (flags & TDF_LINENO)
2070 {
2071 gimple_stmt_iterator gsi;
a315c44c
SB
2072 char *s_indent = (char *) alloca ((size_t) indent + 1);
2073 memset (s_indent, ' ', (size_t) indent);
2074 s_indent[indent] = '\0';
2075
2076 if (flags & TDF_COMMENT)
2077 fputs (";; ", outf);
726a989a
RB
2078
2079 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
b5b8b0ac
AO
2080 if (!is_gimple_debug (gsi_stmt (gsi))
2081 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
726a989a 2082 {
a315c44c
SB
2083 fprintf (outf, "%sstarting at line %d",
2084 s_indent, get_lineno (gsi_stmt (gsi)));
726a989a
RB
2085 break;
2086 }
a315c44c
SB
2087 if (bb->discriminator)
2088 fprintf (outf, ", discriminator %i", bb->discriminator);
2089 fputc ('\n', outf);
726a989a 2090 }
726a989a
RB
2091 }
2092 else
2093 {
a315c44c 2094 gimple stmt = first_stmt (bb);
726a989a
RB
2095 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2096 {
a315c44c
SB
2097 char *s_indent = (char *) alloca ((size_t) indent - 2 + 1);
2098 memset (s_indent, ' ', (size_t) indent);
2099 s_indent[indent] = '\0';
2100 fprintf (outf, "%s<bb %d>:\n", s_indent, bb->index);
726a989a
RB
2101 }
2102 }
726a989a
RB
2103}
2104
2105
2106/* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2107 spaces. */
2108
2109static void
c4669594
SB
2110dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2111 basic_block bb ATTRIBUTE_UNUSED,
2112 int indent ATTRIBUTE_UNUSED,
2113 int flags ATTRIBUTE_UNUSED)
726a989a 2114{
c4669594
SB
2115 /* There is currently no GIMPLE-specific basic block info to dump. */
2116 return;
726a989a
RB
2117}
2118
2119
2120/* Dump PHI nodes of basic block BB to BUFFER with details described
2121 by FLAGS and indented by INDENT spaces. */
2122
2123static void
2124dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
2125{
2126 gimple_stmt_iterator i;
2127
2128 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2129 {
2130 gimple phi = gsi_stmt (i);
ea057359 2131 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
726a989a
RB
2132 {
2133 INDENT (indent);
2134 pp_string (buffer, "# ");
2135 dump_gimple_phi (buffer, phi, indent, flags);
2136 pp_newline (buffer);
2137 }
2138 }
2139}
2140
2141
2142/* Dump jump to basic block BB that is represented implicitly in the cfg
2143 to BUFFER. */
2144
2145static void
2146pp_cfg_jump (pretty_printer *buffer, basic_block bb)
2147{
2148 gimple stmt;
2149
2150 stmt = first_stmt (bb);
2151
2152 pp_string (buffer, "goto <bb ");
2153 pp_decimal_int (buffer, bb->index);
0cf0d02b 2154 pp_character (buffer, '>');
726a989a
RB
2155 if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
2156 {
2157 pp_string (buffer, " (");
2158 dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
0cf0d02b 2159 pp_character (buffer, ')');
726a989a
RB
2160 pp_semicolon (buffer);
2161 }
2162 else
2163 pp_semicolon (buffer);
2164}
2165
2166
2167/* Dump edges represented implicitly in basic block BB to BUFFER, indented
2168 by INDENT spaces, with details given by FLAGS. */
2169
2170static void
2171dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
2172 int flags)
2173{
2174 edge e;
726a989a
RB
2175 gimple stmt;
2176
2177 stmt = last_stmt (bb);
2178
2179 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2180 {
2181 edge true_edge, false_edge;
2182
2183 /* When we are emitting the code or changing CFG, it is possible that
2184 the edges are not yet created. When we are using debug_bb in such
2185 a situation, we do not want it to crash. */
2186 if (EDGE_COUNT (bb->succs) != 2)
2187 return;
2188 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2189
2190 INDENT (indent + 2);
2191 pp_cfg_jump (buffer, true_edge->dest);
2192 newline_and_indent (buffer, indent);
2193 pp_string (buffer, "else");
2194 newline_and_indent (buffer, indent + 2);
2195 pp_cfg_jump (buffer, false_edge->dest);
2196 pp_newline (buffer);
2197 return;
2198 }
2199
2200 /* If there is a fallthru edge, we may need to add an artificial
2201 goto to the dump. */
0fd4b31d 2202 e = find_fallthru_edge (bb->succs);
726a989a
RB
2203
2204 if (e && e->dest != bb->next_bb)
2205 {
2206 INDENT (indent);
2207
2208 if ((flags & TDF_LINENO)
2209 && e->goto_locus != UNKNOWN_LOCATION
2210 )
2211 {
2212 expanded_location goto_xloc;
2213 goto_xloc = expand_location (e->goto_locus);
2214 pp_character (buffer, '[');
2215 if (goto_xloc.file)
2216 {
2217 pp_string (buffer, goto_xloc.file);
2218 pp_string (buffer, " : ");
2219 }
2220 pp_decimal_int (buffer, goto_xloc.line);
c2255bc4
AH
2221 pp_string (buffer, " : ");
2222 pp_decimal_int (buffer, goto_xloc.column);
726a989a
RB
2223 pp_string (buffer, "] ");
2224 }
2225
2226 pp_cfg_jump (buffer, e->dest);
2227 pp_newline (buffer);
2228 }
2229}
2230
2231
2232/* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2233 indented by INDENT spaces. */
2234
2235static void
2236gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
2237 int flags)
2238{
2239 gimple_stmt_iterator gsi;
2240 gimple stmt;
2241 int label_indent = indent - 2;
2242
2243 if (label_indent < 0)
2244 label_indent = 0;
2245
726a989a
RB
2246 dump_phi_nodes (buffer, bb, indent, flags);
2247
2248 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2249 {
2250 int curr_indent;
2251
2252 stmt = gsi_stmt (gsi);
2253
2254 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2255
2256 INDENT (curr_indent);
2257 dump_gimple_stmt (buffer, stmt, curr_indent, flags);
f8923f7e 2258 pp_newline_and_flush (buffer);
726a989a
RB
2259 dump_histograms_for_stmt (cfun, buffer->buffer->stream, stmt);
2260 }
2261
2262 dump_implicit_edges (buffer, bb, indent, flags);
3e31cf28 2263 pp_flush (buffer);
726a989a
RB
2264}
2265
2266
2267/* Dumps basic block BB to FILE with details described by FLAGS and
2268 indented by INDENT spaces. */
2269
2270void
a315c44c 2271gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
726a989a 2272{
a315c44c 2273 dump_gimple_bb_header (file, bb, indent, flags);
c4669594
SB
2274 if (bb->index >= NUM_FIXED_BLOCKS)
2275 {
2276 maybe_init_pretty_print (file);
2277 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2278 }
a315c44c 2279 dump_gimple_bb_footer (file, bb, indent, flags);
726a989a 2280}