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