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