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