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