]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gimple-pretty-print.c
* builtin-types.def (BT_FN_VOID_BOOL, BT_FN_VOID_SIZE_SIZE_PTR,
[thirdparty/gcc.git] / gcc / gimple-pretty-print.c
CommitLineData
75a70cf9 1/* Pretty formatting of GIMPLE statements and expressions.
8e8f6434 2 Copyright (C) 2001-2018 Free Software Foundation, Inc.
75a70cf9 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"
3f6e5ced 25#include "dumpfile.h"
9ef16211 26#include "backend.h"
75a70cf9 27#include "tree.h"
9ef16211 28#include "gimple.h"
d040a5b0 29#include "gimple-predict.h"
9ef16211 30#include "ssa.h"
7c29e30e 31#include "cgraph.h"
ce084dfc 32#include "gimple-pretty-print.h"
bc61cadb 33#include "internal-fn.h"
34#include "tree-eh.h"
dcf1a1ec 35#include "gimple-iterator.h"
073c1fd5 36#include "tree-cfg.h"
073c1fd5 37#include "dumpfile.h" /* for dump_flags */
75a70cf9 38#include "value-prof.h"
4c0315d0 39#include "trans-mem.h"
836ac9e8 40#include "cfganal.h"
30a86690 41#include "stringpool.h"
42#include "attribs.h"
a30589d5 43#include "asan.h"
75a70cf9 44
45#define INDENT(SPACE) \
46 do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
47
75a70cf9 48#define GIMPLE_NIY do_niy (buffer,gs)
49
50/* Try to print on BUFFER a default message for the unrecognized
51 gimple statement GS. */
52
53static void
42acab1c 54do_niy (pretty_printer *buffer, gimple *gs)
75a70cf9 55{
56 pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
57 gimple_code_name[(int) gimple_code (gs)]);
58}
59
60
8ae8ae1b 61/* Emit a newline and SPC indentation spaces to BUFFER. */
75a70cf9 62
63static void
64newline_and_indent (pretty_printer *buffer, int spc)
65{
66 pp_newline (buffer);
67 INDENT (spc);
68}
69
70
71/* Print the GIMPLE statement GS on stderr. */
72
4b987fac 73DEBUG_FUNCTION void
42acab1c 74debug_gimple_stmt (gimple *gs)
75a70cf9 75{
76 print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
75a70cf9 77}
78
c746d97a 79
80/* Return formatted string of a VALUE probability
81 (biased by REG_BR_PROB_BASE). Returned string is allocated
82 by xstrdup_for_dump. */
83
84static const char *
205ce1aa 85dump_profile (profile_count &count)
c746d97a 86{
fb9eabe8 87 char *buf = NULL;
205ce1aa 88 if (!count.initialized_p ())
94e5ea9f 89 return "";
205ce1aa 90 if (count.ipa_p ())
91 buf = xasprintf ("[count: %" PRId64 "]",
92 count.to_gcov_type ());
93 else if (count.initialized_p ())
94 buf = xasprintf ("[local count: %" PRId64 "]",
7ecd7544 95 count.to_gcov_type ());
5db60db9 96
c746d97a 97 const char *ret = xstrdup_for_dump (buf);
98 free (buf);
99
100 return ret;
101}
102
720cfc43 103/* Return formatted string of a VALUE probability
104 (biased by REG_BR_PROB_BASE). Returned string is allocated
105 by xstrdup_for_dump. */
106
107static const char *
ea5d3981 108dump_probability (profile_probability probability)
720cfc43 109{
110 float minimum = 0.01f;
111 float fvalue = -1;
112
113 if (probability.initialized_p ())
114 {
115 fvalue = probability.to_reg_br_prob_base () * 100.0f / REG_BR_PROB_BASE;
116 if (fvalue < minimum && probability.to_reg_br_prob_base ())
117 fvalue = minimum;
118 }
119
120 char *buf;
ea5d3981 121 if (probability.initialized_p ())
122 buf = xasprintf ("[%.2f%%]", fvalue);
720cfc43 123 else
ea5d3981 124 buf = xasprintf ("[INV]");
720cfc43 125
126 const char *ret = xstrdup_for_dump (buf);
127 free (buf);
128
129 return ret;
130}
131
836ac9e8 132/* Dump E probability to BUFFER. */
133
134static void
135dump_edge_probability (pretty_printer *buffer, edge e)
136{
ea5d3981 137 pp_scalar (buffer, " %s", dump_probability (e->probability));
836ac9e8 138}
75a70cf9 139
8ae8ae1b 140/* Print GIMPLE statement G to FILE using SPC indentation spaces and
141 FLAGS as in pp_gimple_stmt_1. */
75a70cf9 142
143void
3f6e5ced 144print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
75a70cf9 145{
ba0714c6 146 pretty_printer buffer;
ba0714c6 147 pp_needs_newline (&buffer) = true;
148 buffer.buffer->stream = file;
8ae8ae1b 149 pp_gimple_stmt_1 (&buffer, g, spc, flags);
5f7f600e 150 pp_newline_and_flush (&buffer);
75a70cf9 151}
152
c7d89805 153DEBUG_FUNCTION void
42acab1c 154debug (gimple &ref)
c7d89805 155{
54e7de93 156 print_gimple_stmt (stderr, &ref, 0, TDF_NONE);
c7d89805 157}
158
159DEBUG_FUNCTION void
42acab1c 160debug (gimple *ptr)
c7d89805 161{
162 if (ptr)
163 debug (*ptr);
164 else
165 fprintf (stderr, "<nil>\n");
166}
167
75a70cf9 168
8ae8ae1b 169/* Print GIMPLE statement G to FILE using SPC indentation spaces and
170 FLAGS as in pp_gimple_stmt_1. Print only the right-hand side
75a70cf9 171 of the statement. */
172
173void
3f6e5ced 174print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
75a70cf9 175{
176 flags |= TDF_RHS_ONLY;
ba0714c6 177 pretty_printer buffer;
ba0714c6 178 pp_needs_newline (&buffer) = true;
179 buffer.buffer->stream = file;
8ae8ae1b 180 pp_gimple_stmt_1 (&buffer, g, spc, flags);
229c964b 181 pp_flush (&buffer);
75a70cf9 182}
183
184
8ae8ae1b 185/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
186 spaces and FLAGS as in pp_gimple_stmt_1.
bec2cf98 187 The caller is responsible for calling pp_flush on BUFFER to finalize
188 the pretty printer. */
75a70cf9 189
190static void
3f6e5ced 191dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc,
192 dump_flags_t flags)
75a70cf9 193{
194 gimple_stmt_iterator i;
195
196 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
197 {
42acab1c 198 gimple *gs = gsi_stmt (i);
75a70cf9 199 INDENT (spc);
8ae8ae1b 200 pp_gimple_stmt_1 (buffer, gs, spc, flags);
75a70cf9 201 if (!gsi_one_before_end_p (i))
202 pp_newline (buffer);
203 }
204}
205
206
8ae8ae1b 207/* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
208 FLAGS as in pp_gimple_stmt_1. */
75a70cf9 209
210void
3f6e5ced 211print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
75a70cf9 212{
ba0714c6 213 pretty_printer buffer;
ba0714c6 214 pp_needs_newline (&buffer) = true;
215 buffer.buffer->stream = file;
75a70cf9 216 dump_gimple_seq (&buffer, seq, spc, flags);
5f7f600e 217 pp_newline_and_flush (&buffer);
75a70cf9 218}
219
220
221/* Print the GIMPLE sequence SEQ on stderr. */
222
4b987fac 223DEBUG_FUNCTION void
75a70cf9 224debug_gimple_seq (gimple_seq seq)
225{
226 print_gimple_seq (stderr, seq, 0, TDF_VOPS|TDF_MEMSYMS);
227}
228
229
230/* A simple helper to pretty-print some of the gimple tuples in the printf
9d75589a 231 style. The format modifiers are preceded by '%' and are:
75a70cf9 232 'G' - outputs a string corresponding to the code of the given gimple,
233 'S' - outputs a gimple_seq with indent of spc + 2,
234 'T' - outputs the tree t,
235 'd' - outputs an int as a decimal,
236 's' - outputs a string,
237 'n' - outputs a newline,
4c0315d0 238 'x' - outputs an int as hexadecimal,
75a70cf9 239 '+' - increases indent by 2 then outputs a newline,
240 '-' - decreases indent by 2 then outputs a newline. */
241
242static void
3f6e5ced 243dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags,
75a70cf9 244 const char *fmt, ...)
245{
246 va_list args;
247 const char *c;
248 const char *tmp;
249
250 va_start (args, fmt);
251 for (c = fmt; *c; c++)
252 {
253 if (*c == '%')
254 {
255 gimple_seq seq;
256 tree t;
42acab1c 257 gimple *g;
75a70cf9 258 switch (*++c)
259 {
260 case 'G':
42acab1c 261 g = va_arg (args, gimple *);
75a70cf9 262 tmp = gimple_code_name[gimple_code (g)];
263 pp_string (buffer, tmp);
264 break;
265
266 case 'S':
267 seq = va_arg (args, gimple_seq);
268 pp_newline (buffer);
269 dump_gimple_seq (buffer, seq, spc + 2, flags);
270 newline_and_indent (buffer, spc);
271 break;
272
273 case 'T':
274 t = va_arg (args, tree);
275 if (t == NULL_TREE)
276 pp_string (buffer, "NULL");
277 else
278 dump_generic_node (buffer, t, spc, flags, false);
279 break;
280
281 case 'd':
282 pp_decimal_int (buffer, va_arg (args, int));
283 break;
284
285 case 's':
286 pp_string (buffer, va_arg (args, char *));
287 break;
288
289 case 'n':
290 newline_and_indent (buffer, spc);
291 break;
292
4c0315d0 293 case 'x':
294 pp_scalar (buffer, "%x", va_arg (args, int));
295 break;
296
75a70cf9 297 case '+':
298 spc += 2;
299 newline_and_indent (buffer, spc);
300 break;
301
302 case '-':
303 spc -= 2;
304 newline_and_indent (buffer, spc);
305 break;
306
307 default:
308 gcc_unreachable ();
309 }
48e1416a 310 }
75a70cf9 311 else
312 pp_character (buffer, *c);
313 }
314 va_end (args);
315}
316
317
318/* Helper for dump_gimple_assign. Print the unary RHS of the
8ae8ae1b 319 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
75a70cf9 320
321static void
3f6e5ced 322dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc,
323 dump_flags_t flags)
75a70cf9 324{
325 enum tree_code rhs_code = gimple_assign_rhs_code (gs);
326 tree lhs = gimple_assign_lhs (gs);
327 tree rhs = gimple_assign_rhs1 (gs);
328
329 switch (rhs_code)
330 {
331 case VIEW_CONVERT_EXPR:
332 case ASSERT_EXPR:
333 dump_generic_node (buffer, rhs, spc, flags, false);
334 break;
335
336 case FIXED_CONVERT_EXPR:
bd1a81f7 337 case ADDR_SPACE_CONVERT_EXPR:
75a70cf9 338 case FIX_TRUNC_EXPR:
339 case FLOAT_EXPR:
340 CASE_CONVERT:
dda4f0ec 341 pp_left_paren (buffer);
75a70cf9 342 dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false);
343 pp_string (buffer, ") ");
e70f5f27 344 if (op_prio (rhs) < op_code_prio (rhs_code))
345 {
dda4f0ec 346 pp_left_paren (buffer);
e70f5f27 347 dump_generic_node (buffer, rhs, spc, flags, false);
dda4f0ec 348 pp_right_paren (buffer);
e70f5f27 349 }
350 else
351 dump_generic_node (buffer, rhs, spc, flags, false);
75a70cf9 352 break;
48e1416a 353
75a70cf9 354 case PAREN_EXPR:
355 pp_string (buffer, "((");
356 dump_generic_node (buffer, rhs, spc, flags, false);
357 pp_string (buffer, "))");
358 break;
48e1416a 359
75a70cf9 360 case ABS_EXPR:
1c67942e 361 case ABSU_EXPR:
78c6d67e 362 if (flags & TDF_GIMPLE)
363 {
1c67942e 364 pp_string (buffer,
365 rhs_code == ABS_EXPR ? "__ABS " : "__ABSU ");
78c6d67e 366 dump_generic_node (buffer, rhs, spc, flags, false);
367 }
368 else
369 {
1c67942e 370 pp_string (buffer,
371 rhs_code == ABS_EXPR ? "ABS_EXPR <" : "ABSU_EXPR <");
78c6d67e 372 dump_generic_node (buffer, rhs, spc, flags, false);
373 pp_greater (buffer);
374 }
75a70cf9 375 break;
376
377 default:
378 if (TREE_CODE_CLASS (rhs_code) == tcc_declaration
379 || TREE_CODE_CLASS (rhs_code) == tcc_constant
380 || TREE_CODE_CLASS (rhs_code) == tcc_reference
381 || rhs_code == SSA_NAME
382 || rhs_code == ADDR_EXPR
383 || rhs_code == CONSTRUCTOR)
e70f5f27 384 {
385 dump_generic_node (buffer, rhs, spc, flags, false);
386 break;
387 }
75a70cf9 388 else if (rhs_code == BIT_NOT_EXPR)
dda4f0ec 389 pp_complement (buffer);
75a70cf9 390 else if (rhs_code == TRUTH_NOT_EXPR)
dda4f0ec 391 pp_exclamation (buffer);
75a70cf9 392 else if (rhs_code == NEGATE_EXPR)
dda4f0ec 393 pp_minus (buffer);
75a70cf9 394 else
395 {
dda4f0ec 396 pp_left_bracket (buffer);
f3d35d4d 397 pp_string (buffer, get_tree_code_name (rhs_code));
75a70cf9 398 pp_string (buffer, "] ");
399 }
400
e70f5f27 401 if (op_prio (rhs) < op_code_prio (rhs_code))
402 {
dda4f0ec 403 pp_left_paren (buffer);
e70f5f27 404 dump_generic_node (buffer, rhs, spc, flags, false);
dda4f0ec 405 pp_right_paren (buffer);
e70f5f27 406 }
407 else
408 dump_generic_node (buffer, rhs, spc, flags, false);
75a70cf9 409 break;
410 }
411}
412
413
414/* Helper for dump_gimple_assign. Print the binary RHS of the
8ae8ae1b 415 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
75a70cf9 416
417static void
3f6e5ced 418dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc,
419 dump_flags_t flags)
75a70cf9 420{
b50a547c 421 const char *p;
422 enum tree_code code = gimple_assign_rhs_code (gs);
423 switch (code)
75a70cf9 424 {
425 case COMPLEX_EXPR:
75a70cf9 426 case MIN_EXPR:
75a70cf9 427 case MAX_EXPR:
b50a547c 428 case VEC_WIDEN_MULT_HI_EXPR:
429 case VEC_WIDEN_MULT_LO_EXPR:
79a78f7f 430 case VEC_WIDEN_MULT_EVEN_EXPR:
431 case VEC_WIDEN_MULT_ODD_EXPR:
b50a547c 432 case VEC_PACK_TRUNC_EXPR:
433 case VEC_PACK_SAT_EXPR:
434 case VEC_PACK_FIX_TRUNC_EXPR:
0efcdf5a 435 case VEC_PACK_FLOAT_EXPR:
6083c152 436 case VEC_WIDEN_LSHIFT_HI_EXPR:
437 case VEC_WIDEN_LSHIFT_LO_EXPR:
7ed29fa2 438 case VEC_SERIES_EXPR:
f3d35d4d 439 for (p = get_tree_code_name (code); *p; p++)
b50a547c 440 pp_character (buffer, TOUPPER (*p));
441 pp_string (buffer, " <");
75a70cf9 442 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
443 pp_string (buffer, ", ");
444 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
dda4f0ec 445 pp_greater (buffer);
75a70cf9 446 break;
447
448 default:
e70f5f27 449 if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code))
450 {
dda4f0ec 451 pp_left_paren (buffer);
e70f5f27 452 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
453 false);
dda4f0ec 454 pp_right_paren (buffer);
e70f5f27 455 }
456 else
457 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
75a70cf9 458 pp_space (buffer);
459 pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
460 pp_space (buffer);
e70f5f27 461 if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
462 {
dda4f0ec 463 pp_left_paren (buffer);
e70f5f27 464 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
465 false);
dda4f0ec 466 pp_right_paren (buffer);
e70f5f27 467 }
468 else
469 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
75a70cf9 470 }
471}
472
00f4f705 473/* Helper for dump_gimple_assign. Print the ternary RHS of the
8ae8ae1b 474 assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
00f4f705 475
476static void
3f6e5ced 477dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc,
478 dump_flags_t flags)
00f4f705 479{
480 const char *p;
481 enum tree_code code = gimple_assign_rhs_code (gs);
482 switch (code)
483 {
484 case WIDEN_MULT_PLUS_EXPR:
485 case WIDEN_MULT_MINUS_EXPR:
f3d35d4d 486 for (p = get_tree_code_name (code); *p; p++)
00f4f705 487 pp_character (buffer, TOUPPER (*p));
488 pp_string (buffer, " <");
489 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
490 pp_string (buffer, ", ");
491 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
492 pp_string (buffer, ", ");
493 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
dda4f0ec 494 pp_greater (buffer);
00f4f705 495 break;
496
c86930b0 497 case DOT_PROD_EXPR:
498 pp_string (buffer, "DOT_PROD_EXPR <");
499 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
500 pp_string (buffer, ", ");
501 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
502 pp_string (buffer, ", ");
503 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
a2287001 504 pp_greater (buffer);
505 break;
506
507 case SAD_EXPR:
508 pp_string (buffer, "SAD_EXPR <");
509 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
510 pp_string (buffer, ", ");
511 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
512 pp_string (buffer, ", ");
513 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
70d60d1d 514 pp_greater (buffer);
c86930b0 515 break;
6cf89e04 516
f4803722 517 case VEC_PERM_EXPR:
518 pp_string (buffer, "VEC_PERM_EXPR <");
6cf89e04 519 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
520 pp_string (buffer, ", ");
521 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
522 pp_string (buffer, ", ");
523 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
70d60d1d 524 pp_greater (buffer);
6cf89e04 525 break;
c86930b0 526
527 case REALIGN_LOAD_EXPR:
528 pp_string (buffer, "REALIGN_LOAD <");
529 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
530 pp_string (buffer, ", ");
531 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
532 pp_string (buffer, ", ");
533 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
70d60d1d 534 pp_greater (buffer);
8a2caf10 535 break;
536
537 case COND_EXPR:
538 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
539 pp_string (buffer, " ? ");
540 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
541 pp_string (buffer, " : ");
542 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
543 break;
544
545 case VEC_COND_EXPR:
546 pp_string (buffer, "VEC_COND_EXPR <");
547 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
548 pp_string (buffer, ", ");
549 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
550 pp_string (buffer, ", ");
551 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
70d60d1d 552 pp_greater (buffer);
c86930b0 553 break;
554
2506d97a 555 case BIT_INSERT_EXPR:
556 pp_string (buffer, "BIT_INSERT_EXPR <");
557 dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
558 pp_string (buffer, ", ");
559 dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
560 pp_string (buffer, ", ");
561 dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
562 pp_string (buffer, " (");
563 if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
564 pp_decimal_int (buffer,
565 TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
566 else
567 dump_generic_node (buffer,
568 TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
569 spc, flags, false);
570 pp_string (buffer, " bits)>");
571 break;
572
00f4f705 573 default:
574 gcc_unreachable ();
575 }
576}
577
75a70cf9 578
579/* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in
8ae8ae1b 580 pp_gimple_stmt_1. */
75a70cf9 581
582static void
3f6e5ced 583dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc,
584 dump_flags_t flags)
75a70cf9 585{
586 if (flags & TDF_RAW)
587 {
80a948aa 588 tree arg1 = NULL;
589 tree arg2 = NULL;
590 tree arg3 = NULL;
591 switch (gimple_num_ops (gs))
592 {
593 case 4:
594 arg3 = gimple_assign_rhs3 (gs);
e3533433 595 /* FALLTHRU */
80a948aa 596 case 3:
597 arg2 = gimple_assign_rhs2 (gs);
e3533433 598 /* FALLTHRU */
80a948aa 599 case 2:
600 arg1 = gimple_assign_rhs1 (gs);
601 break;
602 default:
603 gcc_unreachable ();
604 }
75a70cf9 605
80a948aa 606 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
f3d35d4d 607 get_tree_code_name (gimple_assign_rhs_code (gs)),
80a948aa 608 gimple_assign_lhs (gs), arg1, arg2, arg3);
75a70cf9 609 }
610 else
611 {
612 if (!(flags & TDF_RHS_ONLY))
613 {
614 dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false);
615 pp_space (buffer);
dda4f0ec 616 pp_equal (buffer);
75a70cf9 617
618 if (gimple_assign_nontemporal_move_p (gs))
619 pp_string (buffer, "{nt}");
620
621 if (gimple_has_volatile_ops (gs))
622 pp_string (buffer, "{v}");
623
624 pp_space (buffer);
625 }
626
627 if (gimple_num_ops (gs) == 2)
628 dump_unary_rhs (buffer, gs, spc, flags);
629 else if (gimple_num_ops (gs) == 3)
630 dump_binary_rhs (buffer, gs, spc, flags);
00f4f705 631 else if (gimple_num_ops (gs) == 4)
632 dump_ternary_rhs (buffer, gs, spc, flags);
75a70cf9 633 else
634 gcc_unreachable ();
635 if (!(flags & TDF_RHS_ONLY))
9af5ce0c 636 pp_semicolon (buffer);
75a70cf9 637 }
638}
639
640
641/* Dump the return statement GS. BUFFER, SPC and FLAGS are as in
8ae8ae1b 642 pp_gimple_stmt_1. */
75a70cf9 643
644static void
3f6e5ced 645dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc,
646 dump_flags_t flags)
75a70cf9 647{
cf696dea 648 tree t;
75a70cf9 649
650 t = gimple_return_retval (gs);
651 if (flags & TDF_RAW)
cf696dea 652 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
75a70cf9 653 else
654 {
655 pp_string (buffer, "return");
656 if (t)
657 {
658 pp_space (buffer);
659 dump_generic_node (buffer, t, spc, flags, false);
660 }
661 pp_semicolon (buffer);
662 }
663}
664
665
666/* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in
667 dump_gimple_call. */
668
669static void
3f6e5ced 670dump_gimple_call_args (pretty_printer *buffer, gcall *gs, dump_flags_t flags)
75a70cf9 671{
5961c777 672 size_t i = 0;
75a70cf9 673
5961c777 674 /* Pretty print first arg to certain internal fns. */
675 if (gimple_call_internal_p (gs))
676 {
677 const char *const *enums = NULL;
678 unsigned limit = 0;
679
680 switch (gimple_call_internal_fn (gs))
681 {
682 case IFN_UNIQUE:
683#define DEF(X) #X
684 static const char *const unique_args[] = {IFN_UNIQUE_CODES};
685#undef DEF
686 enums = unique_args;
687
688 limit = ARRAY_SIZE (unique_args);
689 break;
690
691 case IFN_GOACC_LOOP:
692#define DEF(X) #X
693 static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
694#undef DEF
695 enums = loop_args;
696 limit = ARRAY_SIZE (loop_args);
697 break;
698
699 case IFN_GOACC_REDUCTION:
700#define DEF(X) #X
701 static const char *const reduction_args[]
702 = {IFN_GOACC_REDUCTION_CODES};
703#undef DEF
704 enums = reduction_args;
705 limit = ARRAY_SIZE (reduction_args);
706 break;
707
a30589d5 708 case IFN_ASAN_MARK:
709#define DEF(X) #X
710 static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
711#undef DEF
712 enums = asan_mark_args;
713 limit = ARRAY_SIZE (asan_mark_args);
714 break;
715
5961c777 716 default:
717 break;
718 }
719 if (limit)
720 {
721 tree arg0 = gimple_call_arg (gs, 0);
722 HOST_WIDE_INT v;
723
724 if (TREE_CODE (arg0) == INTEGER_CST
725 && tree_fits_shwi_p (arg0)
726 && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
727 {
728 i++;
729 pp_string (buffer, enums[v]);
5961c777 730 }
731 }
732 }
733
734 for (; i < gimple_call_num_args (gs); i++)
75a70cf9 735 {
bad6473b 736 if (i)
75a70cf9 737 pp_string (buffer, ", ");
bad6473b 738 dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
75a70cf9 739 }
740
741 if (gimple_call_va_arg_pack_p (gs))
742 {
bad6473b 743 if (i)
744 pp_string (buffer, ", ");
75a70cf9 745
746 pp_string (buffer, "__builtin_va_arg_pack ()");
747 }
748}
749
1a981e1a 750/* Dump the points-to solution *PT to BUFFER. */
751
752static void
753pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
754{
755 if (pt->anything)
756 {
757 pp_string (buffer, "anything ");
758 return;
759 }
760 if (pt->nonlocal)
761 pp_string (buffer, "nonlocal ");
762 if (pt->escaped)
763 pp_string (buffer, "escaped ");
764 if (pt->ipa_escaped)
765 pp_string (buffer, "unit-escaped ");
766 if (pt->null)
767 pp_string (buffer, "null ");
768 if (pt->vars
769 && !bitmap_empty_p (pt->vars))
770 {
771 bitmap_iterator bi;
772 unsigned i;
773 pp_string (buffer, "{ ");
774 EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi)
775 {
b03e5397 776 pp_string (buffer, "D.");
777 pp_decimal_int (buffer, i);
dda4f0ec 778 pp_space (buffer);
1a981e1a 779 }
dda4f0ec 780 pp_right_brace (buffer);
420582bc 781 if (pt->vars_contains_nonlocal
5ffb4a0d 782 || pt->vars_contains_escaped
783 || pt->vars_contains_escaped_heap
784 || pt->vars_contains_restrict)
785 {
786 const char *comma = "";
787 pp_string (buffer, " (");
788 if (pt->vars_contains_nonlocal)
789 {
790 pp_string (buffer, "nonlocal");
791 comma = ", ";
792 }
793 if (pt->vars_contains_escaped)
794 {
795 pp_string (buffer, comma);
796 pp_string (buffer, "escaped");
797 comma = ", ";
798 }
799 if (pt->vars_contains_escaped_heap)
800 {
801 pp_string (buffer, comma);
802 pp_string (buffer, "escaped heap");
803 comma = ", ";
804 }
805 if (pt->vars_contains_restrict)
806 {
807 pp_string (buffer, comma);
808 pp_string (buffer, "restrict");
76bc343a 809 comma = ", ";
810 }
811 if (pt->vars_contains_interposable)
812 {
813 pp_string (buffer, comma);
814 pp_string (buffer, "interposable");
5ffb4a0d 815 }
816 pp_string (buffer, ")");
817 }
818
1a981e1a 819 }
820}
75a70cf9 821
822/* Dump the call statement GS. BUFFER, SPC and FLAGS are as in
8ae8ae1b 823 pp_gimple_stmt_1. */
75a70cf9 824
825static void
3f6e5ced 826dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
827 dump_flags_t flags)
75a70cf9 828{
829 tree lhs = gimple_call_lhs (gs);
4c0315d0 830 tree fn = gimple_call_fn (gs);
75a70cf9 831
1a981e1a 832 if (flags & TDF_ALIAS)
833 {
834 struct pt_solution *pt;
835 pt = gimple_call_use_set (gs);
836 if (!pt_solution_empty_p (pt))
837 {
838 pp_string (buffer, "# USE = ");
839 pp_points_to_solution (buffer, pt);
840 newline_and_indent (buffer, spc);
841 }
842 pt = gimple_call_clobber_set (gs);
843 if (!pt_solution_empty_p (pt))
844 {
845 pp_string (buffer, "# CLB = ");
846 pp_points_to_solution (buffer, pt);
847 newline_and_indent (buffer, spc);
848 }
849 }
850
75a70cf9 851 if (flags & TDF_RAW)
852 {
fb049fba 853 if (gimple_call_internal_p (gs))
0fe3dc7e 854 dump_gimple_fmt (buffer, spc, flags, "%G <.%s, %T", gs,
fb049fba 855 internal_fn_name (gimple_call_internal_fn (gs)), lhs);
856 else
4c0315d0 857 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
75a70cf9 858 if (gimple_call_num_args (gs) > 0)
859 {
860 pp_string (buffer, ", ");
861 dump_gimple_call_args (buffer, gs, flags);
862 }
dda4f0ec 863 pp_greater (buffer);
75a70cf9 864 }
865 else
866 {
867 if (lhs && !(flags & TDF_RHS_ONLY))
868 {
869 dump_generic_node (buffer, lhs, spc, flags, false);
870 pp_string (buffer, " =");
871
872 if (gimple_has_volatile_ops (gs))
873 pp_string (buffer, "{v}");
874
875 pp_space (buffer);
876 }
fb049fba 877 if (gimple_call_internal_p (gs))
0fe3dc7e 878 {
879 pp_dot (buffer);
880 pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
881 }
fb049fba 882 else
4c0315d0 883 print_call_name (buffer, fn, flags);
75a70cf9 884 pp_string (buffer, " (");
885 dump_gimple_call_args (buffer, gs, flags);
dda4f0ec 886 pp_right_paren (buffer);
75a70cf9 887 if (!(flags & TDF_RHS_ONLY))
888 pp_semicolon (buffer);
889 }
890
891 if (gimple_call_chain (gs))
892 {
893 pp_string (buffer, " [static-chain: ");
894 dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false);
dda4f0ec 895 pp_right_bracket (buffer);
75a70cf9 896 }
897
898 if (gimple_call_return_slot_opt_p (gs))
899 pp_string (buffer, " [return slot optimization]");
75a70cf9 900 if (gimple_call_tail_p (gs))
901 pp_string (buffer, " [tail call]");
b4a61e77 902 if (gimple_call_must_tail_p (gs))
903 pp_string (buffer, " [must tail call]");
4c0315d0 904
bd7750a3 905 if (fn == NULL)
906 return;
907
4c0315d0 908 /* Dump the arguments of _ITM_beginTransaction sanely. */
909 if (TREE_CODE (fn) == ADDR_EXPR)
910 fn = TREE_OPERAND (fn, 0);
911 if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
912 pp_string (buffer, " [tm-clone]");
913 if (TREE_CODE (fn) == FUNCTION_DECL
a0e9bfbb 914 && fndecl_built_in_p (fn, BUILT_IN_TM_START)
4c0315d0 915 && gimple_call_num_args (gs) > 0)
916 {
917 tree t = gimple_call_arg (gs, 0);
918 unsigned HOST_WIDE_INT props;
919 gcc_assert (TREE_CODE (t) == INTEGER_CST);
920
921 pp_string (buffer, " [ ");
922
923 /* Get the transaction code properties. */
f9ae6f95 924 props = TREE_INT_CST_LOW (t);
4c0315d0 925
926 if (props & PR_INSTRUMENTEDCODE)
927 pp_string (buffer, "instrumentedCode ");
928 if (props & PR_UNINSTRUMENTEDCODE)
929 pp_string (buffer, "uninstrumentedCode ");
930 if (props & PR_HASNOXMMUPDATE)
931 pp_string (buffer, "hasNoXMMUpdate ");
932 if (props & PR_HASNOABORT)
933 pp_string (buffer, "hasNoAbort ");
934 if (props & PR_HASNOIRREVOCABLE)
935 pp_string (buffer, "hasNoIrrevocable ");
936 if (props & PR_DOESGOIRREVOCABLE)
937 pp_string (buffer, "doesGoIrrevocable ");
938 if (props & PR_HASNOSIMPLEREADS)
939 pp_string (buffer, "hasNoSimpleReads ");
940 if (props & PR_AWBARRIERSOMITTED)
941 pp_string (buffer, "awBarriersOmitted ");
942 if (props & PR_RARBARRIERSOMITTED)
943 pp_string (buffer, "RaRBarriersOmitted ");
944 if (props & PR_UNDOLOGCODE)
945 pp_string (buffer, "undoLogCode ");
946 if (props & PR_PREFERUNINSTRUMENTED)
947 pp_string (buffer, "preferUninstrumented ");
948 if (props & PR_EXCEPTIONBLOCK)
949 pp_string (buffer, "exceptionBlock ");
950 if (props & PR_HASELSE)
951 pp_string (buffer, "hasElse ");
952 if (props & PR_READONLY)
953 pp_string (buffer, "readOnly ");
954
70d60d1d 955 pp_right_bracket (buffer);
4c0315d0 956 }
75a70cf9 957}
958
959
960/* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in
8ae8ae1b 961 pp_gimple_stmt_1. */
75a70cf9 962
963static void
1a91d914 964dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
3f6e5ced 965 dump_flags_t flags)
75a70cf9 966{
967 unsigned int i;
968
969 GIMPLE_CHECK (gs, GIMPLE_SWITCH);
970 if (flags & TDF_RAW)
971 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs,
972 gimple_switch_index (gs));
973 else
974 {
975 pp_string (buffer, "switch (");
976 dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
b1f04d34 977 if (flags & TDF_GIMPLE)
978 pp_string (buffer, ") {");
979 else
980 pp_string (buffer, ") <");
75a70cf9 981 }
982
983 for (i = 0; i < gimple_switch_num_labels (gs); i++)
984 {
985 tree case_label = gimple_switch_label (gs, i);
49a70175 986 gcc_checking_assert (case_label != NULL_TREE);
75a70cf9 987 dump_generic_node (buffer, case_label, spc, flags, false);
dda4f0ec 988 pp_space (buffer);
836ac9e8 989 tree label = CASE_LABEL (case_label);
990 dump_generic_node (buffer, label, spc, flags, false);
991
992 if (cfun && cfun->cfg)
993 {
0fb4f2ce 994 basic_block dest = label_to_block (cfun, label);
836ac9e8 995 if (dest)
996 {
997 edge label_edge = find_edge (gimple_bb (gs), dest);
998 if (label_edge && !(flags & TDF_GIMPLE))
999 dump_edge_probability (buffer, label_edge);
1000 }
1001 }
1002
75a70cf9 1003 if (i < gimple_switch_num_labels (gs) - 1)
b1f04d34 1004 {
1005 if (flags & TDF_GIMPLE)
1006 pp_string (buffer, "; ");
1007 else
1008 pp_string (buffer, ", ");
1009 }
75a70cf9 1010 }
b1f04d34 1011 if (flags & TDF_GIMPLE)
1012 pp_string (buffer, "; }");
1013 else
1014 pp_greater (buffer);
75a70cf9 1015}
1016
1017
1018/* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in
8ae8ae1b 1019 pp_gimple_stmt_1. */
75a70cf9 1020
1021static void
3f6e5ced 1022dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc,
1023 dump_flags_t flags)
75a70cf9 1024{
1025 if (flags & TDF_RAW)
1026 dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
f3d35d4d 1027 get_tree_code_name (gimple_cond_code (gs)),
1028 gimple_cond_lhs (gs), gimple_cond_rhs (gs),
1029 gimple_cond_true_label (gs), gimple_cond_false_label (gs));
75a70cf9 1030 else
1031 {
1032 if (!(flags & TDF_RHS_ONLY))
1033 pp_string (buffer, "if (");
1034 dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false);
1035 pp_space (buffer);
1036 pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
1037 pp_space (buffer);
1038 dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
1039 if (!(flags & TDF_RHS_ONLY))
1040 {
836ac9e8 1041 edge_iterator ei;
1042 edge e, true_edge = NULL, false_edge = NULL;
1043 basic_block bb = gimple_bb (gs);
1044
1045 if (bb)
1046 {
1047 FOR_EACH_EDGE (e, ei, bb->succs)
1048 {
1049 if (e->flags & EDGE_TRUE_VALUE)
1050 true_edge = e;
1051 else if (e->flags & EDGE_FALSE_VALUE)
1052 false_edge = e;
1053 }
1054 }
1055
1056 bool has_edge_info = true_edge != NULL && false_edge != NULL;
1057
dda4f0ec 1058 pp_right_paren (buffer);
75a70cf9 1059
1060 if (gimple_cond_true_label (gs))
1061 {
1062 pp_string (buffer, " goto ");
1063 dump_generic_node (buffer, gimple_cond_true_label (gs),
1064 spc, flags, false);
836ac9e8 1065 if (has_edge_info && !(flags & TDF_GIMPLE))
1066 dump_edge_probability (buffer, true_edge);
75a70cf9 1067 pp_semicolon (buffer);
1068 }
1069 if (gimple_cond_false_label (gs))
1070 {
1071 pp_string (buffer, " else goto ");
1072 dump_generic_node (buffer, gimple_cond_false_label (gs),
1073 spc, flags, false);
836ac9e8 1074 if (has_edge_info && !(flags & TDF_GIMPLE))
1075 dump_edge_probability (buffer, false_edge);
1076
75a70cf9 1077 pp_semicolon (buffer);
1078 }
1079 }
1080 }
1081}
1082
1083
1084/* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC
1085 spaces of indent. FLAGS specifies details to show in the dump (see
b9ed1410 1086 TDF_* in dumpfils.h). */
75a70cf9 1087
1088static void
3f6e5ced 1089dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
1090 dump_flags_t flags)
75a70cf9 1091{
1092 tree label = gimple_label_label (gs);
1093 if (flags & TDF_RAW)
b1f04d34 1094 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
75a70cf9 1095 else
1096 {
1097 dump_generic_node (buffer, label, spc, flags, false);
dda4f0ec 1098 pp_colon (buffer);
75a70cf9 1099 }
b1f04d34 1100 if (flags & TDF_GIMPLE)
1101 return;
75a70cf9 1102 if (DECL_NONLOCAL (label))
1103 pp_string (buffer, " [non-local]");
e38def9c 1104 if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
1105 pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label));
75a70cf9 1106}
1107
1108/* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC
1109 spaces of indent. FLAGS specifies details to show in the dump (see
b9ed1410 1110 TDF_* in dumpfile.h). */
75a70cf9 1111
1112static void
3f6e5ced 1113dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc,
1114 dump_flags_t flags)
75a70cf9 1115{
1116 tree label = gimple_goto_dest (gs);
1117 if (flags & TDF_RAW)
1118 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
1119 else
1120 dump_gimple_fmt (buffer, spc, flags, "goto %T;", label);
1121}
1122
1123
1124/* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC
1125 spaces of indent. FLAGS specifies details to show in the dump (see
b9ed1410 1126 TDF_* in dumpfile.h). */
75a70cf9 1127
1128static void
3f6e5ced 1129dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc,
1130 dump_flags_t flags)
75a70cf9 1131{
1132 if (flags & TDF_RAW)
1133 dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
1134 else
dda4f0ec 1135 pp_left_brace (buffer);
75a70cf9 1136 if (!(flags & TDF_SLIM))
1137 {
1138 tree var;
1139
1767a056 1140 for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var))
75a70cf9 1141 {
1142 newline_and_indent (buffer, 2);
1143 print_declaration (buffer, var, spc, flags);
1144 }
1145 if (gimple_bind_vars (gs))
1146 pp_newline (buffer);
1147 }
1148 pp_newline (buffer);
1149 dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags);
1150 newline_and_indent (buffer, spc);
1151 if (flags & TDF_RAW)
dda4f0ec 1152 pp_greater (buffer);
75a70cf9 1153 else
dda4f0ec 1154 pp_right_brace (buffer);
75a70cf9 1155}
1156
1157
1158/* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of
1159 indent. FLAGS specifies details to show in the dump (see TDF_* in
b9ed1410 1160 dumpfile.h). */
75a70cf9 1161
1162static void
3f6e5ced 1163dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc,
1164 dump_flags_t flags)
75a70cf9 1165{
1166 if (flags & TDF_RAW)
1167 {
1168 const char *type;
1169 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1170 type = "GIMPLE_TRY_CATCH";
1171 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1172 type = "GIMPLE_TRY_FINALLY";
1173 else
1174 type = "UNKNOWN GIMPLE_TRY";
1175 dump_gimple_fmt (buffer, spc, flags,
1176 "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type,
1177 gimple_try_eval (gs), gimple_try_cleanup (gs));
1178 }
1179 else
1180 {
1181 pp_string (buffer, "try");
1182 newline_and_indent (buffer, spc + 2);
dda4f0ec 1183 pp_left_brace (buffer);
75a70cf9 1184 pp_newline (buffer);
1185
1186 dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags);
1187 newline_and_indent (buffer, spc + 2);
dda4f0ec 1188 pp_right_brace (buffer);
75a70cf9 1189
1190 if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
1191 {
1192 newline_and_indent (buffer, spc);
1193 pp_string (buffer, "catch");
1194 newline_and_indent (buffer, spc + 2);
dda4f0ec 1195 pp_left_brace (buffer);
75a70cf9 1196 }
1197 else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY)
1198 {
1199 newline_and_indent (buffer, spc);
1200 pp_string (buffer, "finally");
1201 newline_and_indent (buffer, spc + 2);
dda4f0ec 1202 pp_left_brace (buffer);
75a70cf9 1203 }
1204 else
1205 pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
1206
1207 pp_newline (buffer);
1208 dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
1209 newline_and_indent (buffer, spc + 2);
dda4f0ec 1210 pp_right_brace (buffer);
75a70cf9 1211 }
1212}
1213
1214
1215/* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of
1216 indent. FLAGS specifies details to show in the dump (see TDF_* in
b9ed1410 1217 dumpfile.h). */
75a70cf9 1218
1219static void
3f6e5ced 1220dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc,
1221 dump_flags_t flags)
75a70cf9 1222{
1223 if (flags & TDF_RAW)
1224 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
1225 gimple_catch_types (gs), gimple_catch_handler (gs));
1226 else
1227 dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}",
1228 gimple_catch_types (gs), gimple_catch_handler (gs));
1229}
1230
1231
1232/* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of
1233 indent. FLAGS specifies details to show in the dump (see TDF_* in
b9ed1410 1234 dumpfile.h). */
75a70cf9 1235
1236static void
1a91d914 1237dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
3f6e5ced 1238 dump_flags_t flags)
75a70cf9 1239{
1240 if (flags & TDF_RAW)
1241 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
1242 gimple_eh_filter_types (gs),
1243 gimple_eh_filter_failure (gs));
1244 else
1245 dump_gimple_fmt (buffer, spc, flags, "<<<eh_filter (%T)>>>%+{%+%S%-}",
1246 gimple_eh_filter_types (gs),
1247 gimple_eh_filter_failure (gs));
1248}
1249
1250
e38def9c 1251/* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */
1252
1253static void
1a91d914 1254dump_gimple_eh_must_not_throw (pretty_printer *buffer,
3f6e5ced 1255 geh_mnt *gs, int spc, dump_flags_t flags)
e38def9c 1256{
1257 if (flags & TDF_RAW)
1258 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
1259 gimple_eh_must_not_throw_fndecl (gs));
1260 else
1261 dump_gimple_fmt (buffer, spc, flags, "<<<eh_must_not_throw (%T)>>>",
1262 gimple_eh_must_not_throw_fndecl (gs));
1263}
1264
1265
4c0315d0 1266/* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of
1267 indent. FLAGS specifies details to show in the dump (see TDF_* in
b9ed1410 1268 dumpfile.h). */
4c0315d0 1269
1270static void
1a91d914 1271dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
3f6e5ced 1272 dump_flags_t flags)
4c0315d0 1273{
1274 if (flags & TDF_RAW)
1275 dump_gimple_fmt (buffer, spc, flags,
1276 "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs,
1277 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1278 else
1279 dump_gimple_fmt (buffer, spc, flags,
1280 "<<<if_normal_exit>>>%+{%S}%-<<<else_eh_exit>>>%+{%S}",
1281 gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs));
1282}
1283
1284
75a70cf9 1285/* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of
1286 indent. FLAGS specifies details to show in the dump (see TDF_* in
b9ed1410 1287 dumpfile.h). */
75a70cf9 1288
1289static void
3f6e5ced 1290dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc,
1291 dump_flags_t flags)
75a70cf9 1292{
1293 if (flags & TDF_RAW)
1294 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
e38def9c 1295 gimple_resx_region (gs));
75a70cf9 1296 else
1297 dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs));
1298}
1299
e38def9c 1300/* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */
1301
1302static void
3f6e5ced 1303dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc,
1304 dump_flags_t flags)
e38def9c 1305{
1306 if (flags & TDF_RAW)
1307 dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
1308 gimple_eh_dispatch_region (gs));
1309 else
1310 dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d",
1311 gimple_eh_dispatch_region (gs));
1312}
1313
9845d120 1314/* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces
1315 of indent. FLAGS specifies details to show in the dump (see TDF_*
b9ed1410 1316 in dumpfile.h). */
9845d120 1317
1318static void
3f6e5ced 1319dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc,
1320 dump_flags_t flags)
9845d120 1321{
de6bd75e 1322 switch (gs->subcode)
9845d120 1323 {
1324 case GIMPLE_DEBUG_BIND:
1325 if (flags & TDF_RAW)
1326 dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs,
1327 gimple_debug_bind_get_var (gs),
1328 gimple_debug_bind_get_value (gs));
1329 else
1330 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T",
1331 gimple_debug_bind_get_var (gs),
1332 gimple_debug_bind_get_value (gs));
1333 break;
1334
841424cc 1335 case GIMPLE_DEBUG_SOURCE_BIND:
1336 if (flags & TDF_RAW)
1337 dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs,
1338 gimple_debug_source_bind_get_var (gs),
1339 gimple_debug_source_bind_get_value (gs));
1340 else
1341 dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T",
1342 gimple_debug_source_bind_get_var (gs),
1343 gimple_debug_source_bind_get_value (gs));
1344 break;
1345
90567983 1346 case GIMPLE_DEBUG_BEGIN_STMT:
1347 if (flags & TDF_RAW)
1348 dump_gimple_fmt (buffer, spc, flags, "%G BEGIN_STMT", gs);
1349 else
1350 dump_gimple_fmt (buffer, spc, flags, "# DEBUG BEGIN_STMT");
1351 break;
1352
8f6f3638 1353 case GIMPLE_DEBUG_INLINE_ENTRY:
1354 if (flags & TDF_RAW)
1355 dump_gimple_fmt (buffer, spc, flags, "%G INLINE_ENTRY %T", gs,
1356 gimple_block (gs)
1357 ? block_ultimate_origin (gimple_block (gs))
1358 : NULL_TREE);
1359 else
1360 dump_gimple_fmt (buffer, spc, flags, "# DEBUG INLINE_ENTRY %T",
1361 gimple_block (gs)
1362 ? block_ultimate_origin (gimple_block (gs))
1363 : NULL_TREE);
1364 break;
1365
9845d120 1366 default:
1367 gcc_unreachable ();
1368 }
1369}
1370
75a70cf9 1371/* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
1372static void
3f6e5ced 1373dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc,
1374 dump_flags_t flags)
75a70cf9 1375{
1376 size_t i;
1377
1378 if (flags & TDF_RAW)
1379 {
3d483a94 1380 const char *kind;
1381 switch (gimple_omp_for_kind (gs))
1382 {
1383 case GF_OMP_FOR_KIND_FOR:
1384 kind = "";
1385 break;
bc7bff74 1386 case GF_OMP_FOR_KIND_DISTRIBUTE:
1387 kind = " distribute";
1388 break;
43895be5 1389 case GF_OMP_FOR_KIND_TASKLOOP:
1390 kind = " taskloop";
1391 break;
ca4c3545 1392 case GF_OMP_FOR_KIND_OACC_LOOP:
1393 kind = " oacc_loop";
1394 break;
1395 case GF_OMP_FOR_KIND_SIMD:
1396 kind = " simd";
1397 break;
3d483a94 1398 default:
1399 gcc_unreachable ();
1400 }
1401 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1402 kind, gimple_omp_body (gs));
75a70cf9 1403 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
1404 dump_gimple_fmt (buffer, spc, flags, " >,");
1405 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1406 dump_gimple_fmt (buffer, spc, flags,
1407 "%+%T, %T, %T, %s, %T,%n",
1408 gimple_omp_for_index (gs, i),
1409 gimple_omp_for_initial (gs, i),
1410 gimple_omp_for_final (gs, i),
f3d35d4d 1411 get_tree_code_name (gimple_omp_for_cond (gs, i)),
75a70cf9 1412 gimple_omp_for_incr (gs, i));
1413 dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->",
1414 gimple_omp_for_pre_body (gs));
1415 }
1416 else
1417 {
3d483a94 1418 switch (gimple_omp_for_kind (gs))
1419 {
1420 case GF_OMP_FOR_KIND_FOR:
1421 pp_string (buffer, "#pragma omp for");
1422 break;
ca4c3545 1423 case GF_OMP_FOR_KIND_DISTRIBUTE:
1424 pp_string (buffer, "#pragma omp distribute");
1425 break;
43895be5 1426 case GF_OMP_FOR_KIND_TASKLOOP:
1427 pp_string (buffer, "#pragma omp taskloop");
1428 break;
ca4c3545 1429 case GF_OMP_FOR_KIND_OACC_LOOP:
1430 pp_string (buffer, "#pragma acc loop");
1431 break;
3d483a94 1432 case GF_OMP_FOR_KIND_SIMD:
1433 pp_string (buffer, "#pragma omp simd");
1434 break;
56686608 1435 case GF_OMP_FOR_KIND_GRID_LOOP:
1436 pp_string (buffer, "#pragma omp for grid_loop");
1437 break;
3d483a94 1438 default:
1439 gcc_unreachable ();
1440 }
efa02472 1441 dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
75a70cf9 1442 for (i = 0; i < gimple_omp_for_collapse (gs); i++)
1443 {
1444 if (i)
1445 spc += 2;
efa02472 1446 newline_and_indent (buffer, spc);
1447 pp_string (buffer, "for (");
75a70cf9 1448 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1449 flags, false);
1450 pp_string (buffer, " = ");
1451 dump_generic_node (buffer, gimple_omp_for_initial (gs, i), spc,
1452 flags, false);
1453 pp_string (buffer, "; ");
1454
1455 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1456 flags, false);
1457 pp_space (buffer);
1458 switch (gimple_omp_for_cond (gs, i))
1459 {
1460 case LT_EXPR:
dda4f0ec 1461 pp_less (buffer);
75a70cf9 1462 break;
1463 case GT_EXPR:
dda4f0ec 1464 pp_greater (buffer);
75a70cf9 1465 break;
1466 case LE_EXPR:
70d60d1d 1467 pp_less_equal (buffer);
75a70cf9 1468 break;
1469 case GE_EXPR:
70d60d1d 1470 pp_greater_equal (buffer);
75a70cf9 1471 break;
40750995 1472 case NE_EXPR:
1473 pp_string (buffer, "!=");
1474 break;
75a70cf9 1475 default:
1476 gcc_unreachable ();
1477 }
1478 pp_space (buffer);
1479 dump_generic_node (buffer, gimple_omp_for_final (gs, i), spc,
1480 flags, false);
1481 pp_string (buffer, "; ");
1482
1483 dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
1484 flags, false);
1485 pp_string (buffer, " = ");
1486 dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc,
1487 flags, false);
dda4f0ec 1488 pp_right_paren (buffer);
75a70cf9 1489 }
1490
1491 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1492 {
1493 newline_and_indent (buffer, spc + 2);
dda4f0ec 1494 pp_left_brace (buffer);
75a70cf9 1495 pp_newline (buffer);
1496 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1497 newline_and_indent (buffer, spc + 2);
dda4f0ec 1498 pp_right_brace (buffer);
75a70cf9 1499 }
1500 }
1501}
1502
1503/* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */
1504
1505static void
1a91d914 1506dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
3f6e5ced 1507 int spc, dump_flags_t flags)
75a70cf9 1508{
1509 if (flags & TDF_RAW)
1510 {
1511 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
1512 gimple_omp_continue_control_def (gs),
1513 gimple_omp_continue_control_use (gs));
1514 }
1515 else
1516 {
1517 pp_string (buffer, "#pragma omp continue (");
1518 dump_generic_node (buffer, gimple_omp_continue_control_def (gs),
1519 spc, flags, false);
dda4f0ec 1520 pp_comma (buffer);
75a70cf9 1521 pp_space (buffer);
1522 dump_generic_node (buffer, gimple_omp_continue_control_use (gs),
1523 spc, flags, false);
dda4f0ec 1524 pp_right_paren (buffer);
75a70cf9 1525 }
1526}
1527
1528/* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */
1529
1530static void
1a91d914 1531dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
3f6e5ced 1532 int spc, dump_flags_t flags)
75a70cf9 1533{
1534 if (flags & TDF_RAW)
1535 {
1536 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1537 gimple_omp_body (gs));
1538 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1539 dump_gimple_fmt (buffer, spc, flags, " >");
1540 }
1541 else
1542 {
1543 pp_string (buffer, "#pragma omp single");
1544 dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags);
1545 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1546 {
1547 newline_and_indent (buffer, spc + 2);
dda4f0ec 1548 pp_left_brace (buffer);
75a70cf9 1549 pp_newline (buffer);
1550 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1551 newline_and_indent (buffer, spc + 2);
dda4f0ec 1552 pp_right_brace (buffer);
75a70cf9 1553 }
1554 }
1555}
1556
7e5a76c8 1557/* Dump a GIMPLE_OMP_TASKGROUP tuple on the pretty_printer BUFFER. */
1558
1559static void
1560dump_gimple_omp_taskgroup (pretty_printer *buffer, gimple *gs,
1561 int spc, dump_flags_t flags)
1562{
1563 if (flags & TDF_RAW)
1564 {
1565 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1566 gimple_omp_body (gs));
1567 dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
1568 dump_gimple_fmt (buffer, spc, flags, " >");
1569 }
1570 else
1571 {
1572 pp_string (buffer, "#pragma omp taskgroup");
1573 dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
1574 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1575 {
1576 newline_and_indent (buffer, spc + 2);
1577 pp_left_brace (buffer);
1578 pp_newline (buffer);
1579 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1580 newline_and_indent (buffer, spc + 2);
1581 pp_right_brace (buffer);
1582 }
1583 }
1584}
1585
bc7bff74 1586/* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */
1587
1588static void
1a91d914 1589dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
3f6e5ced 1590 int spc, dump_flags_t flags)
bc7bff74 1591{
1592 const char *kind;
1593 switch (gimple_omp_target_kind (gs))
1594 {
1595 case GF_OMP_TARGET_KIND_REGION:
1596 kind = "";
1597 break;
1598 case GF_OMP_TARGET_KIND_DATA:
1599 kind = " data";
1600 break;
1601 case GF_OMP_TARGET_KIND_UPDATE:
1602 kind = " update";
1603 break;
43895be5 1604 case GF_OMP_TARGET_KIND_ENTER_DATA:
1605 kind = " enter data";
1606 break;
1607 case GF_OMP_TARGET_KIND_EXIT_DATA:
1608 kind = " exit data";
1609 break;
ca4c3545 1610 case GF_OMP_TARGET_KIND_OACC_KERNELS:
1611 kind = " oacc_kernels";
1612 break;
1613 case GF_OMP_TARGET_KIND_OACC_PARALLEL:
1614 kind = " oacc_parallel";
1615 break;
1616 case GF_OMP_TARGET_KIND_OACC_DATA:
1617 kind = " oacc_data";
1618 break;
1619 case GF_OMP_TARGET_KIND_OACC_UPDATE:
1620 kind = " oacc_update";
1621 break;
1622 case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
1623 kind = " oacc_enter_exit_data";
1624 break;
2fc5e987 1625 case GF_OMP_TARGET_KIND_OACC_DECLARE:
1626 kind = " oacc_declare";
1627 break;
571b3486 1628 case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
1629 kind = " oacc_host_data";
1630 break;
bc7bff74 1631 default:
1632 gcc_unreachable ();
1633 }
1634 if (flags & TDF_RAW)
1635 {
1636 dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs,
1637 kind, gimple_omp_body (gs));
1638 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
ca4c3545 1639 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
1640 gimple_omp_target_child_fn (gs),
1641 gimple_omp_target_data_arg (gs));
bc7bff74 1642 }
1643 else
1644 {
1645 pp_string (buffer, "#pragma omp target");
1646 pp_string (buffer, kind);
1647 dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags);
1648 if (gimple_omp_target_child_fn (gs))
1649 {
1650 pp_string (buffer, " [child fn: ");
1651 dump_generic_node (buffer, gimple_omp_target_child_fn (gs),
1652 spc, flags, false);
ca4c3545 1653 pp_string (buffer, " (");
1654 if (gimple_omp_target_data_arg (gs))
1655 dump_generic_node (buffer, gimple_omp_target_data_arg (gs),
1656 spc, flags, false);
1657 else
1658 pp_string (buffer, "???");
1659 pp_string (buffer, ")]");
bc7bff74 1660 }
ca4c3545 1661 gimple_seq body = gimple_omp_body (gs);
1662 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
bc7bff74 1663 {
1664 newline_and_indent (buffer, spc + 2);
ca4c3545 1665 pp_left_brace (buffer);
bc7bff74 1666 pp_newline (buffer);
ca4c3545 1667 dump_gimple_seq (buffer, body, spc + 4, flags);
bc7bff74 1668 newline_and_indent (buffer, spc + 2);
ca4c3545 1669 pp_right_brace (buffer);
1670 }
1671 else if (body)
1672 {
1673 pp_newline (buffer);
1674 dump_gimple_seq (buffer, body, spc + 2, flags);
bc7bff74 1675 }
1676 }
1677}
1678
1679/* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */
1680
1681static void
1a91d914 1682dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
3f6e5ced 1683 dump_flags_t flags)
bc7bff74 1684{
1685 if (flags & TDF_RAW)
1686 {
1687 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1688 gimple_omp_body (gs));
1689 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1690 dump_gimple_fmt (buffer, spc, flags, " >");
1691 }
1692 else
1693 {
1694 pp_string (buffer, "#pragma omp teams");
1695 dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags);
1696 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1697 {
1698 newline_and_indent (buffer, spc + 2);
1699 pp_character (buffer, '{');
1700 pp_newline (buffer);
1701 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1702 newline_and_indent (buffer, spc + 2);
1703 pp_character (buffer, '}');
1704 }
1705 }
1706}
1707
75a70cf9 1708/* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
1709
1710static void
1a91d914 1711dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
3f6e5ced 1712 int spc, dump_flags_t flags)
75a70cf9 1713{
1714 if (flags & TDF_RAW)
1715 {
1716 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
1717 gimple_omp_body (gs));
1718 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1719 dump_gimple_fmt (buffer, spc, flags, " >");
1720 }
1721 else
1722 {
1723 pp_string (buffer, "#pragma omp sections");
1724 if (gimple_omp_sections_control (gs))
1725 {
1726 pp_string (buffer, " <");
1727 dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
1728 flags, false);
dda4f0ec 1729 pp_greater (buffer);
75a70cf9 1730 }
1731 dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
1732 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1733 {
1734 newline_and_indent (buffer, spc + 2);
dda4f0ec 1735 pp_left_brace (buffer);
75a70cf9 1736 pp_newline (buffer);
1737 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1738 newline_and_indent (buffer, spc + 2);
dda4f0ec 1739 pp_right_brace (buffer);
75a70cf9 1740 }
1741 }
1742}
1743
7e5a76c8 1744/* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the
bc7bff74 1745 pretty_printer BUFFER. */
75a70cf9 1746
1747static void
3f6e5ced 1748dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc,
1749 dump_flags_t flags)
75a70cf9 1750{
1751 if (flags & TDF_RAW)
1752 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1753 gimple_omp_body (gs));
1754 else
1755 {
1756 switch (gimple_code (gs))
1757 {
1758 case GIMPLE_OMP_MASTER:
1759 pp_string (buffer, "#pragma omp master");
1760 break;
bc7bff74 1761 case GIMPLE_OMP_TASKGROUP:
1762 pp_string (buffer, "#pragma omp taskgroup");
1763 break;
75a70cf9 1764 case GIMPLE_OMP_SECTION:
1765 pp_string (buffer, "#pragma omp section");
1766 break;
56686608 1767 case GIMPLE_OMP_GRID_BODY:
1768 pp_string (buffer, "#pragma omp gridified body");
1769 break;
75a70cf9 1770 default:
1771 gcc_unreachable ();
1772 }
1773 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1774 {
1775 newline_and_indent (buffer, spc + 2);
dda4f0ec 1776 pp_left_brace (buffer);
75a70cf9 1777 pp_newline (buffer);
1778 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1779 newline_and_indent (buffer, spc + 2);
dda4f0ec 1780 pp_right_brace (buffer);
75a70cf9 1781 }
1782 }
1783}
1784
1785/* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
1786
1787static void
1a91d914 1788dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
3f6e5ced 1789 int spc, dump_flags_t flags)
75a70cf9 1790{
1791 if (flags & TDF_RAW)
1792 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1793 gimple_omp_body (gs));
1794 else
1795 {
1796 pp_string (buffer, "#pragma omp critical");
1797 if (gimple_omp_critical_name (gs))
1798 {
1799 pp_string (buffer, " (");
1800 dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
1801 flags, false);
dda4f0ec 1802 pp_right_paren (buffer);
75a70cf9 1803 }
43895be5 1804 dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags);
1805 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1806 {
1807 newline_and_indent (buffer, spc + 2);
1808 pp_left_brace (buffer);
1809 pp_newline (buffer);
1810 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1811 newline_and_indent (buffer, spc + 2);
1812 pp_right_brace (buffer);
1813 }
1814 }
1815}
1816
1817/* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */
1818
1819static void
1820dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
3f6e5ced 1821 int spc, dump_flags_t flags)
43895be5 1822{
1823 if (flags & TDF_RAW)
1824 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
1825 gimple_omp_body (gs));
1826 else
1827 {
1828 pp_string (buffer, "#pragma omp ordered");
1829 dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags);
75a70cf9 1830 if (!gimple_seq_empty_p (gimple_omp_body (gs)))
1831 {
1832 newline_and_indent (buffer, spc + 2);
dda4f0ec 1833 pp_left_brace (buffer);
75a70cf9 1834 pp_newline (buffer);
1835 dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
1836 newline_and_indent (buffer, spc + 2);
dda4f0ec 1837 pp_right_brace (buffer);
75a70cf9 1838 }
1839 }
1840}
1841
1842/* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
1843
1844static void
3f6e5ced 1845dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc,
1846 dump_flags_t flags)
75a70cf9 1847{
1848 if (flags & TDF_RAW)
1849 {
bc7bff74 1850 dump_gimple_fmt (buffer, spc, flags, "%G <nowait=%d", gs,
75a70cf9 1851 (int) gimple_omp_return_nowait_p (gs));
bc7bff74 1852 if (gimple_omp_return_lhs (gs))
1853 dump_gimple_fmt (buffer, spc, flags, ", lhs=%T>",
1854 gimple_omp_return_lhs (gs));
1855 else
1856 dump_gimple_fmt (buffer, spc, flags, ">");
75a70cf9 1857 }
1858 else
1859 {
1860 pp_string (buffer, "#pragma omp return");
1861 if (gimple_omp_return_nowait_p (gs))
1862 pp_string (buffer, "(nowait)");
bc7bff74 1863 if (gimple_omp_return_lhs (gs))
1864 {
1865 pp_string (buffer, " (set ");
1866 dump_generic_node (buffer, gimple_omp_return_lhs (gs),
1867 spc, flags, false);
1868 pp_character (buffer, ')');
1869 }
75a70cf9 1870 }
1871}
1872
4c0315d0 1873/* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */
1874
1875static void
1a91d914 1876dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
3f6e5ced 1877 int spc, dump_flags_t flags)
4c0315d0 1878{
1879 unsigned subcode = gimple_transaction_subcode (gs);
1880
1881 if (flags & TDF_RAW)
1882 {
1883 dump_gimple_fmt (buffer, spc, flags,
a08574d7 1884 "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
1885 "<%+BODY <%S> >",
1886 gs, subcode, gimple_transaction_label_norm (gs),
1887 gimple_transaction_label_uninst (gs),
1888 gimple_transaction_label_over (gs),
4c0315d0 1889 gimple_transaction_body (gs));
1890 }
1891 else
1892 {
1893 if (subcode & GTMA_IS_OUTER)
1894 pp_string (buffer, "__transaction_atomic [[outer]]");
1895 else if (subcode & GTMA_IS_RELAXED)
1896 pp_string (buffer, "__transaction_relaxed");
1897 else
1898 pp_string (buffer, "__transaction_atomic");
1899 subcode &= ~GTMA_DECLARATION_MASK;
1900
a08574d7 1901 if (gimple_transaction_body (gs))
1902 {
1903 newline_and_indent (buffer, spc + 2);
1904 pp_left_brace (buffer);
1905 pp_newline (buffer);
1906 dump_gimple_seq (buffer, gimple_transaction_body (gs),
1907 spc + 4, flags);
1908 newline_and_indent (buffer, spc + 2);
1909 pp_right_brace (buffer);
1910 }
1911 else
4c0315d0 1912 {
1913 pp_string (buffer, " //");
a08574d7 1914 if (gimple_transaction_label_norm (gs))
1915 {
1916 pp_string (buffer, " NORM=");
1917 dump_generic_node (buffer, gimple_transaction_label_norm (gs),
1918 spc, flags, false);
1919 }
1920 if (gimple_transaction_label_uninst (gs))
4c0315d0 1921 {
a08574d7 1922 pp_string (buffer, " UNINST=");
1923 dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
1924 spc, flags, false);
1925 }
1926 if (gimple_transaction_label_over (gs))
1927 {
1928 pp_string (buffer, " OVER=");
1929 dump_generic_node (buffer, gimple_transaction_label_over (gs),
4c0315d0 1930 spc, flags, false);
1931 }
1932 if (subcode)
1933 {
1934 pp_string (buffer, " SUBCODE=[ ");
1935 if (subcode & GTMA_HAVE_ABORT)
1936 {
1937 pp_string (buffer, "GTMA_HAVE_ABORT ");
1938 subcode &= ~GTMA_HAVE_ABORT;
1939 }
1940 if (subcode & GTMA_HAVE_LOAD)
1941 {
1942 pp_string (buffer, "GTMA_HAVE_LOAD ");
1943 subcode &= ~GTMA_HAVE_LOAD;
1944 }
1945 if (subcode & GTMA_HAVE_STORE)
1946 {
1947 pp_string (buffer, "GTMA_HAVE_STORE ");
1948 subcode &= ~GTMA_HAVE_STORE;
1949 }
1950 if (subcode & GTMA_MAY_ENTER_IRREVOCABLE)
1951 {
1952 pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE ");
1953 subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE;
1954 }
1955 if (subcode & GTMA_DOES_GO_IRREVOCABLE)
1956 {
1957 pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE ");
1958 subcode &= ~GTMA_DOES_GO_IRREVOCABLE;
1959 }
1910089e 1960 if (subcode & GTMA_HAS_NO_INSTRUMENTATION)
1961 {
1962 pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION ");
1963 subcode &= ~GTMA_HAS_NO_INSTRUMENTATION;
1964 }
4c0315d0 1965 if (subcode)
1966 pp_printf (buffer, "0x%x ", subcode);
70d60d1d 1967 pp_right_bracket (buffer);
4c0315d0 1968 }
1969 }
4c0315d0 1970 }
1971}
1972
75a70cf9 1973/* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of
1974 indent. FLAGS specifies details to show in the dump (see TDF_* in
b9ed1410 1975 dumpfile.h). */
75a70cf9 1976
1977static void
3f6e5ced 1978dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, dump_flags_t flags)
75a70cf9 1979{
78f55ca8 1980 unsigned int i, n, f, fields;
75a70cf9 1981
1982 if (flags & TDF_RAW)
78f55ca8 1983 {
1984 dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs,
1985 gimple_asm_string (gs));
1986
1987 n = gimple_asm_noutputs (gs);
1988 if (n)
1989 {
1990 newline_and_indent (buffer, spc + 2);
1991 pp_string (buffer, "OUTPUT: ");
1992 for (i = 0; i < n; i++)
1993 {
1994 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
1995 spc, flags, false);
1996 if (i < n - 1)
1997 pp_string (buffer, ", ");
1998 }
1999 }
2000
2001 n = gimple_asm_ninputs (gs);
2002 if (n)
2003 {
2004 newline_and_indent (buffer, spc + 2);
2005 pp_string (buffer, "INPUT: ");
2006 for (i = 0; i < n; i++)
2007 {
2008 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2009 spc, flags, false);
2010 if (i < n - 1)
2011 pp_string (buffer, ", ");
2012 }
2013 }
2014
2015 n = gimple_asm_nclobbers (gs);
2016 if (n)
2017 {
2018 newline_and_indent (buffer, spc + 2);
2019 pp_string (buffer, "CLOBBER: ");
2020 for (i = 0; i < n; i++)
2021 {
2022 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2023 spc, flags, false);
2024 if (i < n - 1)
2025 pp_string (buffer, ", ");
2026 }
2027 }
2028
2029 n = gimple_asm_nlabels (gs);
2030 if (n)
2031 {
2032 newline_and_indent (buffer, spc + 2);
2033 pp_string (buffer, "LABEL: ");
2034 for (i = 0; i < n; i++)
2035 {
2036 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2037 spc, flags, false);
2038 if (i < n - 1)
2039 pp_string (buffer, ", ");
2040 }
2041 }
2042
2043 newline_and_indent (buffer, spc);
dda4f0ec 2044 pp_greater (buffer);
78f55ca8 2045 }
75a70cf9 2046 else
2047 {
2048 pp_string (buffer, "__asm__");
2049 if (gimple_asm_volatile_p (gs))
2050 pp_string (buffer, " __volatile__");
78f55ca8 2051 if (gimple_asm_nlabels (gs))
2052 pp_string (buffer, " goto");
75a70cf9 2053 pp_string (buffer, "(\"");
2054 pp_string (buffer, gimple_asm_string (gs));
2055 pp_string (buffer, "\"");
75a70cf9 2056
78f55ca8 2057 if (gimple_asm_nlabels (gs))
2058 fields = 4;
2059 else if (gimple_asm_nclobbers (gs))
2060 fields = 3;
2061 else if (gimple_asm_ninputs (gs))
2062 fields = 2;
2063 else if (gimple_asm_noutputs (gs))
2064 fields = 1;
2065 else
2066 fields = 0;
75a70cf9 2067
78f55ca8 2068 for (f = 0; f < fields; ++f)
2069 {
2070 pp_string (buffer, " : ");
75a70cf9 2071
78f55ca8 2072 switch (f)
2073 {
2074 case 0:
2075 n = gimple_asm_noutputs (gs);
2076 for (i = 0; i < n; i++)
2077 {
2078 dump_generic_node (buffer, gimple_asm_output_op (gs, i),
2079 spc, flags, false);
2080 if (i < n - 1)
2081 pp_string (buffer, ", ");
2082 }
2083 break;
75a70cf9 2084
78f55ca8 2085 case 1:
2086 n = gimple_asm_ninputs (gs);
2087 for (i = 0; i < n; i++)
2088 {
2089 dump_generic_node (buffer, gimple_asm_input_op (gs, i),
2090 spc, flags, false);
2091 if (i < n - 1)
2092 pp_string (buffer, ", ");
2093 }
2094 break;
75a70cf9 2095
78f55ca8 2096 case 2:
2097 n = gimple_asm_nclobbers (gs);
2098 for (i = 0; i < n; i++)
2099 {
2100 dump_generic_node (buffer, gimple_asm_clobber_op (gs, i),
2101 spc, flags, false);
2102 if (i < n - 1)
2103 pp_string (buffer, ", ");
2104 }
2105 break;
75a70cf9 2106
78f55ca8 2107 case 3:
2108 n = gimple_asm_nlabels (gs);
2109 for (i = 0; i < n; i++)
2110 {
2111 dump_generic_node (buffer, gimple_asm_label_op (gs, i),
2112 spc, flags, false);
2113 if (i < n - 1)
2114 pp_string (buffer, ", ");
2115 }
2116 break;
2117
2118 default:
2119 gcc_unreachable ();
2120 }
2121 }
2122
2123 pp_string (buffer, ");");
75a70cf9 2124 }
75a70cf9 2125}
2126
3c59e4a7 2127/* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with
2128 SPC spaces of indent. */
75a70cf9 2129
2130static void
3c59e4a7 2131dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
75a70cf9 2132{
3c59e4a7 2133 if (TREE_CODE (node) != SSA_NAME)
2134 return;
71e11843 2135
3c59e4a7 2136 if (POINTER_TYPE_P (TREE_TYPE (node))
2137 && SSA_NAME_PTR_INFO (node))
71e11843 2138 {
ceea063b 2139 unsigned int align, misalign;
3c59e4a7 2140 struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
64fd716d 2141 pp_string (buffer, "# PT = ");
153c3b50 2142 pp_points_to_solution (buffer, &pi->pt);
2143 newline_and_indent (buffer, spc);
ceea063b 2144 if (get_ptr_info_alignment (pi, &align, &misalign))
57d4f313 2145 {
ceea063b 2146 pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign);
57d4f313 2147 newline_and_indent (buffer, spc);
2148 }
71e11843 2149 }
75a70cf9 2150
3c59e4a7 2151 if (!POINTER_TYPE_P (TREE_TYPE (node))
2152 && SSA_NAME_RANGE_INFO (node))
2153 {
9c1be15e 2154 wide_int min, max, nonzero_bits;
be44111e 2155 value_range_kind range_type = get_range_info (node, &min, &max);
3c59e4a7 2156
2157 if (range_type == VR_VARYING)
64fd716d 2158 pp_printf (buffer, "# RANGE VR_VARYING");
3c59e4a7 2159 else if (range_type == VR_RANGE || range_type == VR_ANTI_RANGE)
0cf78115 2160 {
2161 pp_printf (buffer, "# RANGE ");
2162 pp_printf (buffer, "%s[", range_type == VR_RANGE ? "" : "~");
6b409616 2163 pp_wide_int (buffer, min, TYPE_SIGN (TREE_TYPE (node)));
0cf78115 2164 pp_printf (buffer, ", ");
6b409616 2165 pp_wide_int (buffer, max, TYPE_SIGN (TREE_TYPE (node)));
0cf78115 2166 pp_printf (buffer, "]");
0cf78115 2167 }
fc08b993 2168 nonzero_bits = get_nonzero_bits (node);
9c1be15e 2169 if (nonzero_bits != -1)
fc08b993 2170 {
2171 pp_string (buffer, " NONZERO ");
aeb682a2 2172 pp_wide_int (buffer, nonzero_bits, UNSIGNED);
fc08b993 2173 }
2174 newline_and_indent (buffer, spc);
3c59e4a7 2175 }
2176}
2177
be5e9c7f 2178/* As dump_ssaname_info, but dump to FILE. */
2179
2180void
2181dump_ssaname_info_to_file (FILE *file, tree node, int spc)
2182{
2183 pretty_printer buffer;
2184 pp_needs_newline (&buffer) = true;
2185 buffer.buffer->stream = file;
2186 dump_ssaname_info (&buffer, node, spc);
2187 pp_flush (&buffer);
2188}
3c59e4a7 2189
2190/* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
2191 The caller is responsible for calling pp_flush on BUFFER to finalize
64fd716d 2192 pretty printer. If COMMENT is true, print this after #. */
3c59e4a7 2193
2194static void
1a91d914 2195dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
3f6e5ced 2196 dump_flags_t flags)
3c59e4a7 2197{
2198 size_t i;
2199 tree lhs = gimple_phi_result (phi);
2200
2201 if (flags & TDF_ALIAS)
2202 dump_ssaname_info (buffer, lhs, spc);
2203
64fd716d 2204 if (comment)
2205 pp_string (buffer, "# ");
2206
75a70cf9 2207 if (flags & TDF_RAW)
0cf78115 2208 dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi,
2209 gimple_phi_result (phi));
75a70cf9 2210 else
2211 {
71e11843 2212 dump_generic_node (buffer, lhs, spc, flags, false);
b1f04d34 2213 if (flags & TDF_GIMPLE)
2214 pp_string (buffer, " = __PHI (");
2215 else
2216 pp_string (buffer, " = PHI <");
75a70cf9 2217 }
2218 for (i = 0; i < gimple_phi_num_args (phi); i++)
2219 {
efbcb6de 2220 if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
e522a604 2221 dump_location (buffer, gimple_phi_arg_location (phi, i));
b1f04d34 2222 if (flags & TDF_GIMPLE)
2223 {
2224 basic_block src = gimple_phi_arg_edge (phi, i)->src;
2225 gimple *stmt = first_stmt (src);
2226 if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
2227 {
2228 pp_string (buffer, "bb_");
2229 pp_decimal_int (buffer, src->index);
2230 }
2231 else
2232 dump_generic_node (buffer, gimple_label_label (as_a <glabel *> (stmt)), 0, flags,
2233 false);
2234 pp_string (buffer, ": ");
2235 }
75a70cf9 2236 dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
2237 false);
b1f04d34 2238 if (! (flags & TDF_GIMPLE))
2239 {
2240 pp_left_paren (buffer);
2241 pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
2242 pp_right_paren (buffer);
2243 }
75a70cf9 2244 if (i < gimple_phi_num_args (phi) - 1)
2245 pp_string (buffer, ", ");
2246 }
b1f04d34 2247 if (flags & TDF_GIMPLE)
2248 pp_string (buffer, ");");
2249 else
2250 pp_greater (buffer);
75a70cf9 2251}
2252
2253
2254/* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces
2255 of indent. FLAGS specifies details to show in the dump (see TDF_* in
b9ed1410 2256 dumpfile.h). */
75a70cf9 2257
2258static void
1a91d914 2259dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
3f6e5ced 2260 int spc, dump_flags_t flags)
75a70cf9 2261{
2262 if (flags & TDF_RAW)
2263 {
2264 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2265 gimple_omp_body (gs));
2266 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2267 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>",
2268 gimple_omp_parallel_child_fn (gs),
2269 gimple_omp_parallel_data_arg (gs));
2270 }
2271 else
2272 {
2273 gimple_seq body;
2274 pp_string (buffer, "#pragma omp parallel");
2275 dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
2276 if (gimple_omp_parallel_child_fn (gs))
2277 {
2278 pp_string (buffer, " [child fn: ");
2279 dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs),
2280 spc, flags, false);
2281 pp_string (buffer, " (");
2282 if (gimple_omp_parallel_data_arg (gs))
2283 dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs),
2284 spc, flags, false);
2285 else
2286 pp_string (buffer, "???");
2287 pp_string (buffer, ")]");
2288 }
2289 body = gimple_omp_body (gs);
2290 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2291 {
2292 newline_and_indent (buffer, spc + 2);
dda4f0ec 2293 pp_left_brace (buffer);
75a70cf9 2294 pp_newline (buffer);
2295 dump_gimple_seq (buffer, body, spc + 4, flags);
2296 newline_and_indent (buffer, spc + 2);
dda4f0ec 2297 pp_right_brace (buffer);
75a70cf9 2298 }
2299 else if (body)
2300 {
2301 pp_newline (buffer);
2302 dump_gimple_seq (buffer, body, spc + 2, flags);
2303 }
2304 }
2305}
2306
2307
2308/* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces
2309 of indent. FLAGS specifies details to show in the dump (see TDF_* in
b9ed1410 2310 dumpfile.h). */
75a70cf9 2311
2312static void
1a91d914 2313dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
3f6e5ced 2314 dump_flags_t flags)
75a70cf9 2315{
2316 if (flags & TDF_RAW)
2317 {
2318 dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
2319 gimple_omp_body (gs));
2320 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2321 dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>",
2322 gimple_omp_task_child_fn (gs),
2323 gimple_omp_task_data_arg (gs),
2324 gimple_omp_task_copy_fn (gs),
2325 gimple_omp_task_arg_size (gs),
2326 gimple_omp_task_arg_size (gs));
2327 }
2328 else
2329 {
2330 gimple_seq body;
43895be5 2331 if (gimple_omp_task_taskloop_p (gs))
2332 pp_string (buffer, "#pragma omp taskloop");
7e5a76c8 2333 else if (gimple_omp_task_taskwait_p (gs))
2334 pp_string (buffer, "#pragma omp taskwait");
43895be5 2335 else
2336 pp_string (buffer, "#pragma omp task");
75a70cf9 2337 dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
2338 if (gimple_omp_task_child_fn (gs))
2339 {
2340 pp_string (buffer, " [child fn: ");
2341 dump_generic_node (buffer, gimple_omp_task_child_fn (gs),
2342 spc, flags, false);
2343 pp_string (buffer, " (");
2344 if (gimple_omp_task_data_arg (gs))
2345 dump_generic_node (buffer, gimple_omp_task_data_arg (gs),
2346 spc, flags, false);
2347 else
2348 pp_string (buffer, "???");
2349 pp_string (buffer, ")]");
2350 }
2351 body = gimple_omp_body (gs);
2352 if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
2353 {
2354 newline_and_indent (buffer, spc + 2);
dda4f0ec 2355 pp_left_brace (buffer);
75a70cf9 2356 pp_newline (buffer);
2357 dump_gimple_seq (buffer, body, spc + 4, flags);
2358 newline_and_indent (buffer, spc + 2);
dda4f0ec 2359 pp_right_brace (buffer);
75a70cf9 2360 }
2361 else if (body)
2362 {
2363 pp_newline (buffer);
2364 dump_gimple_seq (buffer, body, spc + 2, flags);
2365 }
2366 }
2367}
2368
2369
2370/* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC
2371 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
b9ed1410 2372 in dumpfile.h). */
75a70cf9 2373
2374static void
1a91d914 2375dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
3f6e5ced 2376 int spc, dump_flags_t flags)
75a70cf9 2377{
2378 if (flags & TDF_RAW)
2379 {
2380 dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs,
2381 gimple_omp_atomic_load_lhs (gs),
2382 gimple_omp_atomic_load_rhs (gs));
2383 }
2384 else
2385 {
2386 pp_string (buffer, "#pragma omp atomic_load");
7e5a76c8 2387 dump_omp_atomic_memory_order (buffer,
2388 gimple_omp_atomic_memory_order (gs));
3ec11c49 2389 if (gimple_omp_atomic_need_value_p (gs))
2390 pp_string (buffer, " [needed]");
75a70cf9 2391 newline_and_indent (buffer, spc + 2);
2392 dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs),
2393 spc, flags, false);
2394 pp_space (buffer);
dda4f0ec 2395 pp_equal (buffer);
75a70cf9 2396 pp_space (buffer);
dda4f0ec 2397 pp_star (buffer);
75a70cf9 2398 dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs),
2399 spc, flags, false);
2400 }
2401}
2402
2403/* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC
2404 spaces of indent. FLAGS specifies details to show in the dump (see TDF_*
b9ed1410 2405 in dumpfile.h). */
75a70cf9 2406
2407static void
1a91d914 2408dump_gimple_omp_atomic_store (pretty_printer *buffer,
3f6e5ced 2409 gomp_atomic_store *gs, int spc,
2410 dump_flags_t flags)
75a70cf9 2411{
2412 if (flags & TDF_RAW)
2413 {
2414 dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
2415 gimple_omp_atomic_store_val (gs));
2416 }
2417 else
2418 {
7e5a76c8 2419 pp_string (buffer, "#pragma omp atomic_store");
2420 dump_omp_atomic_memory_order (buffer,
2421 gimple_omp_atomic_memory_order (gs));
2422 pp_space (buffer);
3ec11c49 2423 if (gimple_omp_atomic_need_value_p (gs))
2424 pp_string (buffer, "[needed] ");
dda4f0ec 2425 pp_left_paren (buffer);
75a70cf9 2426 dump_generic_node (buffer, gimple_omp_atomic_store_val (gs),
2427 spc, flags, false);
dda4f0ec 2428 pp_right_paren (buffer);
75a70cf9 2429 }
2430}
2431
75a70cf9 2432
2433/* Dump all the memory operands for statement GS. BUFFER, SPC and
8ae8ae1b 2434 FLAGS are as in pp_gimple_stmt_1. */
75a70cf9 2435
2436static void
3f6e5ced 2437dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc,
2438 dump_flags_t flags)
75a70cf9 2439{
dd277d48 2440 tree vdef = gimple_vdef (gs);
2441 tree vuse = gimple_vuse (gs);
75a70cf9 2442
dd277d48 2443 if (vdef != NULL_TREE)
75a70cf9 2444 {
dd277d48 2445 pp_string (buffer, "# ");
2446 dump_generic_node (buffer, vdef, spc + 2, flags, false);
2447 pp_string (buffer, " = VDEF <");
2448 dump_generic_node (buffer, vuse, spc + 2, flags, false);
dda4f0ec 2449 pp_greater (buffer);
75a70cf9 2450 newline_and_indent (buffer, spc);
75a70cf9 2451 }
dd277d48 2452 else if (vuse != NULL_TREE)
75a70cf9 2453 {
dd277d48 2454 pp_string (buffer, "# VUSE <");
2455 dump_generic_node (buffer, vuse, spc + 2, flags, false);
dda4f0ec 2456 pp_greater (buffer);
75a70cf9 2457 newline_and_indent (buffer, spc);
75a70cf9 2458 }
2459}
2460
2461
8ae8ae1b 2462/* Print the gimple statement GS on the pretty printer BUFFER, SPC
75a70cf9 2463 spaces of indent. FLAGS specifies details to show in the dump (see
bec2cf98 2464 TDF_* in dumpfile.h). The caller is responsible for calling
2465 pp_flush on BUFFER to finalize the pretty printer. */
75a70cf9 2466
2467void
3f6e5ced 2468pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc,
2469 dump_flags_t flags)
75a70cf9 2470{
2471 if (!gs)
2472 return;
2473
2474 if (flags & TDF_STMTADDR)
2475 pp_printf (buffer, "<&%p> ", (void *) gs);
2476
2477 if ((flags & TDF_LINENO) && gimple_has_location (gs))
e522a604 2478 dump_location (buffer, gimple_location (gs));
75a70cf9 2479
d60ec13d 2480 if (flags & TDF_EH)
2481 {
e38def9c 2482 int lp_nr = lookup_stmt_eh_lp (gs);
2483 if (lp_nr > 0)
2484 pp_printf (buffer, "[LP %d] ", lp_nr);
2485 else if (lp_nr < 0)
2486 pp_printf (buffer, "[MNT %d] ", -lp_nr);
d60ec13d 2487 }
2488
75a70cf9 2489 if ((flags & (TDF_VOPS|TDF_MEMSYMS))
2490 && gimple_has_mem_ops (gs))
2491 dump_gimple_mem_ops (buffer, gs, spc, flags);
2492
3c59e4a7 2493 if (gimple_has_lhs (gs)
2494 && (flags & TDF_ALIAS))
2495 dump_ssaname_info (buffer, gimple_get_lhs (gs), spc);
71e11843 2496
75a70cf9 2497 switch (gimple_code (gs))
2498 {
2499 case GIMPLE_ASM:
1a91d914 2500 dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
75a70cf9 2501 break;
2502
2503 case GIMPLE_ASSIGN:
1a91d914 2504 dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
75a70cf9 2505 break;
2506
2507 case GIMPLE_BIND:
1a91d914 2508 dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
75a70cf9 2509 break;
2510
2511 case GIMPLE_CALL:
1a91d914 2512 dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
75a70cf9 2513 break;
2514
2515 case GIMPLE_COND:
1a91d914 2516 dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
75a70cf9 2517 break;
2518
2519 case GIMPLE_LABEL:
1a91d914 2520 dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
75a70cf9 2521 break;
2522
2523 case GIMPLE_GOTO:
1a91d914 2524 dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
75a70cf9 2525 break;
2526
2527 case GIMPLE_NOP:
2528 pp_string (buffer, "GIMPLE_NOP");
2529 break;
2530
2531 case GIMPLE_RETURN:
1a91d914 2532 dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
75a70cf9 2533 break;
2534
2535 case GIMPLE_SWITCH:
1a91d914 2536 dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
75a70cf9 2537 break;
2538
2539 case GIMPLE_TRY:
1a91d914 2540 dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
75a70cf9 2541 break;
2542
2543 case GIMPLE_PHI:
1a91d914 2544 dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
75a70cf9 2545 break;
2546
2547 case GIMPLE_OMP_PARALLEL:
1a91d914 2548 dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
2549 flags);
75a70cf9 2550 break;
2551
2552 case GIMPLE_OMP_TASK:
1a91d914 2553 dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
75a70cf9 2554 break;
2555
2556 case GIMPLE_OMP_ATOMIC_LOAD:
1a91d914 2557 dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
2558 spc, flags);
75a70cf9 2559 break;
2560
2561 case GIMPLE_OMP_ATOMIC_STORE:
1a91d914 2562 dump_gimple_omp_atomic_store (buffer,
2563 as_a <gomp_atomic_store *> (gs),
2564 spc, flags);
75a70cf9 2565 break;
2566
2567 case GIMPLE_OMP_FOR:
1a91d914 2568 dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
75a70cf9 2569 break;
2570
2571 case GIMPLE_OMP_CONTINUE:
1a91d914 2572 dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
2573 flags);
75a70cf9 2574 break;
2575
2576 case GIMPLE_OMP_SINGLE:
1a91d914 2577 dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
2578 flags);
75a70cf9 2579 break;
2580
bc7bff74 2581 case GIMPLE_OMP_TARGET:
1a91d914 2582 dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
2583 flags);
bc7bff74 2584 break;
2585
2586 case GIMPLE_OMP_TEAMS:
1a91d914 2587 dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
2588 flags);
bc7bff74 2589 break;
2590
75a70cf9 2591 case GIMPLE_OMP_RETURN:
2592 dump_gimple_omp_return (buffer, gs, spc, flags);
2593 break;
2594
2595 case GIMPLE_OMP_SECTIONS:
1a91d914 2596 dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
2597 spc, flags);
75a70cf9 2598 break;
2599
2600 case GIMPLE_OMP_SECTIONS_SWITCH:
2601 pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
2602 break;
2603
bc7bff74 2604 case GIMPLE_OMP_TASKGROUP:
7e5a76c8 2605 dump_gimple_omp_taskgroup (buffer, gs, spc, flags);
2606 break;
2607
2608 case GIMPLE_OMP_MASTER:
75a70cf9 2609 case GIMPLE_OMP_SECTION:
56686608 2610 case GIMPLE_OMP_GRID_BODY:
75a70cf9 2611 dump_gimple_omp_block (buffer, gs, spc, flags);
2612 break;
2613
43895be5 2614 case GIMPLE_OMP_ORDERED:
2615 dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
2616 flags);
2617 break;
2618
75a70cf9 2619 case GIMPLE_OMP_CRITICAL:
1a91d914 2620 dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
2621 flags);
75a70cf9 2622 break;
2623
75a70cf9 2624 case GIMPLE_CATCH:
1a91d914 2625 dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
75a70cf9 2626 break;
2627
2628 case GIMPLE_EH_FILTER:
1a91d914 2629 dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
75a70cf9 2630 break;
2631
e38def9c 2632 case GIMPLE_EH_MUST_NOT_THROW:
1a91d914 2633 dump_gimple_eh_must_not_throw (buffer,
2634 as_a <geh_mnt *> (gs),
2635 spc, flags);
e38def9c 2636 break;
2637
4c0315d0 2638 case GIMPLE_EH_ELSE:
1a91d914 2639 dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
4c0315d0 2640 break;
2641
75a70cf9 2642 case GIMPLE_RESX:
1a91d914 2643 dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
75a70cf9 2644 break;
2645
e38def9c 2646 case GIMPLE_EH_DISPATCH:
1a91d914 2647 dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
2648 flags);
e38def9c 2649 break;
2650
9845d120 2651 case GIMPLE_DEBUG:
1a91d914 2652 dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
9845d120 2653 break;
2654
75a70cf9 2655 case GIMPLE_PREDICT:
2656 pp_string (buffer, "// predicted ");
2657 if (gimple_predict_outcome (gs))
2658 pp_string (buffer, "likely by ");
2659 else
2660 pp_string (buffer, "unlikely by ");
2661 pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
2662 pp_string (buffer, " predictor.");
2663 break;
2664
4c0315d0 2665 case GIMPLE_TRANSACTION:
1a91d914 2666 dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
2667 flags);
4c0315d0 2668 break;
2669
75a70cf9 2670 default:
2671 GIMPLE_NIY;
2672 }
75a70cf9 2673}
2674
2675
5147ec07 2676/* Dumps header of basic block BB to OUTF indented by INDENT
75a70cf9 2677 spaces and details described by flags. */
2678
2679static void
3f6e5ced 2680dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
2681 dump_flags_t flags)
75a70cf9 2682{
75a70cf9 2683 if (flags & TDF_BLOCKS)
2684 {
75a70cf9 2685 if (flags & TDF_LINENO)
2686 {
2687 gimple_stmt_iterator gsi;
5147ec07 2688
7f337d45 2689 fputs (";; ", outf);
75a70cf9 2690
2691 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
9845d120 2692 if (!is_gimple_debug (gsi_stmt (gsi))
2693 && get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
75a70cf9 2694 {
75199f11 2695 fprintf (outf, "%*sstarting at line %d",
2696 indent, "", get_lineno (gsi_stmt (gsi)));
75a70cf9 2697 break;
2698 }
5147ec07 2699 if (bb->discriminator)
2700 fprintf (outf, ", discriminator %i", bb->discriminator);
2701 fputc ('\n', outf);
75a70cf9 2702 }
75a70cf9 2703 }
2704 else
2705 {
67b7c1c4 2706 if (flags & TDF_GIMPLE)
2707 fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
2708 else
2709 fprintf (outf, "%*s<bb %d> %s:\n",
205ce1aa 2710 indent, "", bb->index, dump_profile (bb->count));
75a70cf9 2711 }
75a70cf9 2712}
2713
2714
2715/* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2716 spaces. */
2717
2718static void
bec2cf98 2719dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
2720 basic_block bb ATTRIBUTE_UNUSED,
2721 int indent ATTRIBUTE_UNUSED,
3f6e5ced 2722 dump_flags_t flags ATTRIBUTE_UNUSED)
75a70cf9 2723{
bec2cf98 2724 /* There is currently no GIMPLE-specific basic block info to dump. */
2725 return;
75a70cf9 2726}
2727
2728
2729/* Dump PHI nodes of basic block BB to BUFFER with details described
2730 by FLAGS and indented by INDENT spaces. */
2731
2732static void
3f6e5ced 2733dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
2734 dump_flags_t flags)
75a70cf9 2735{
1a91d914 2736 gphi_iterator i;
75a70cf9 2737
2738 for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
2739 {
1a91d914 2740 gphi *phi = i.phi ();
7c782c9b 2741 if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
75a70cf9 2742 {
2743 INDENT (indent);
b1f04d34 2744 dump_gimple_phi (buffer, phi, indent,
2745 (flags & TDF_GIMPLE) ? false : true, flags);
75a70cf9 2746 pp_newline (buffer);
2747 }
2748 }
2749}
2750
2751
2752/* Dump jump to basic block BB that is represented implicitly in the cfg
2753 to BUFFER. */
2754
2755static void
3f6e5ced 2756pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
75a70cf9 2757{
b1f04d34 2758 if (flags & TDF_GIMPLE)
75a70cf9 2759 {
b1f04d34 2760 pp_string (buffer, "goto bb_");
836ac9e8 2761 pp_decimal_int (buffer, e->dest->index);
75a70cf9 2762 pp_semicolon (buffer);
2763 }
2764 else
b1f04d34 2765 {
b1f04d34 2766 pp_string (buffer, "goto <bb ");
836ac9e8 2767 pp_decimal_int (buffer, e->dest->index);
b1f04d34 2768 pp_greater (buffer);
67b7c1c4 2769 pp_semicolon (buffer);
836ac9e8 2770
2771 dump_edge_probability (buffer, e);
b1f04d34 2772 }
75a70cf9 2773}
2774
2775
2776/* Dump edges represented implicitly in basic block BB to BUFFER, indented
2777 by INDENT spaces, with details given by FLAGS. */
2778
2779static void
2780dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
3f6e5ced 2781 dump_flags_t flags)
75a70cf9 2782{
2783 edge e;
42acab1c 2784 gimple *stmt;
75a70cf9 2785
2786 stmt = last_stmt (bb);
2787
2788 if (stmt && gimple_code (stmt) == GIMPLE_COND)
2789 {
2790 edge true_edge, false_edge;
2791
2792 /* When we are emitting the code or changing CFG, it is possible that
2793 the edges are not yet created. When we are using debug_bb in such
2794 a situation, we do not want it to crash. */
2795 if (EDGE_COUNT (bb->succs) != 2)
2796 return;
2797 extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
2798
2799 INDENT (indent + 2);
836ac9e8 2800 pp_cfg_jump (buffer, true_edge, flags);
75a70cf9 2801 newline_and_indent (buffer, indent);
2802 pp_string (buffer, "else");
2803 newline_and_indent (buffer, indent + 2);
836ac9e8 2804 pp_cfg_jump (buffer, false_edge, flags);
75a70cf9 2805 pp_newline (buffer);
2806 return;
2807 }
2808
2809 /* If there is a fallthru edge, we may need to add an artificial
2810 goto to the dump. */
7f58c05e 2811 e = find_fallthru_edge (bb->succs);
75a70cf9 2812
2813 if (e && e->dest != bb->next_bb)
2814 {
2815 INDENT (indent);
2816
2817 if ((flags & TDF_LINENO)
e522a604 2818 && e->goto_locus != UNKNOWN_LOCATION)
2819 dump_location (buffer, e->goto_locus);
75a70cf9 2820
836ac9e8 2821 pp_cfg_jump (buffer, e, flags);
75a70cf9 2822 pp_newline (buffer);
2823 }
2824}
2825
2826
2827/* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2828 indented by INDENT spaces. */
2829
2830static void
2831gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
3f6e5ced 2832 dump_flags_t flags)
75a70cf9 2833{
2834 gimple_stmt_iterator gsi;
42acab1c 2835 gimple *stmt;
75a70cf9 2836 int label_indent = indent - 2;
2837
2838 if (label_indent < 0)
2839 label_indent = 0;
2840
75a70cf9 2841 dump_phi_nodes (buffer, bb, indent, flags);
2842
2843 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
2844 {
2845 int curr_indent;
2846
2847 stmt = gsi_stmt (gsi);
2848
2849 curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
2850
2851 INDENT (curr_indent);
8ae8ae1b 2852 pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
5f7f600e 2853 pp_newline_and_flush (buffer);
8d672d12 2854 gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
2855 dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
9af5ce0c 2856 pp_buffer (buffer)->stream, stmt);
75a70cf9 2857 }
2858
2859 dump_implicit_edges (buffer, bb, indent, flags);
051a57b6 2860 pp_flush (buffer);
75a70cf9 2861}
2862
2863
2864/* Dumps basic block BB to FILE with details described by FLAGS and
2865 indented by INDENT spaces. */
2866
2867void
3f6e5ced 2868gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
75a70cf9 2869{
5147ec07 2870 dump_gimple_bb_header (file, bb, indent, flags);
bec2cf98 2871 if (bb->index >= NUM_FIXED_BLOCKS)
2872 {
ba0714c6 2873 pretty_printer buffer;
ba0714c6 2874 pp_needs_newline (&buffer) = true;
2875 buffer.buffer->stream = file;
bec2cf98 2876 gimple_dump_bb_buff (&buffer, bb, indent, flags);
2877 }
5147ec07 2878 dump_gimple_bb_footer (file, bb, indent, flags);
75a70cf9 2879}
229c964b 2880
2881/* Dumps basic block BB to pretty-printer PP with default dump flags and
2882 no indentation, for use as a label of a DOT graph record-node.
2883 ??? Should just use gimple_dump_bb_buff here, except that value profiling
2884 histogram dumping doesn't know about pretty-printers. */
2885
2886void
2887gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
2888{
229c964b 2889 pp_printf (pp, "<bb %d>:\n", bb->index);
2890 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2891
1a91d914 2892 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2893 gsi_next (&gsi))
229c964b 2894 {
1a91d914 2895 gphi *phi = gsi.phi ();
229c964b 2896 if (!virtual_operand_p (gimple_phi_result (phi))
2897 || (dump_flags & TDF_VOPS))
2898 {
dda4f0ec 2899 pp_bar (pp);
229c964b 2900 pp_write_text_to_stream (pp);
2901 pp_string (pp, "# ");
2902 pp_gimple_stmt_1 (pp, phi, 0, dump_flags);
2903 pp_newline (pp);
2904 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2905 }
2906 }
2907
1a91d914 2908 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2909 gsi_next (&gsi))
229c964b 2910 {
42acab1c 2911 gimple *stmt = gsi_stmt (gsi);
dda4f0ec 2912 pp_bar (pp);
229c964b 2913 pp_write_text_to_stream (pp);
2914 pp_gimple_stmt_1 (pp, stmt, 0, dump_flags);
2915 pp_newline (pp);
2916 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2917 }
2918 dump_implicit_edges (pp, bb, 0, dump_flags);
2919 pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
2920}
2921
c8616982 2922
2923/* Handle the %G format for TEXT. Same as %K in handle_K_format in
a2e93b74 2924 tree-pretty-print.c but with a Gimple statement as an argument. */
c8616982 2925
2926void
2927percent_G_format (text_info *text)
2928{
a2e93b74 2929 gimple *stmt = va_arg (*text->args_ptr, gimple*);
c8616982 2930
a2e93b74 2931 tree block = gimple_block (stmt);
2932 percent_K_format (text, gimple_location (stmt), block);
c8616982 2933}