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