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