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