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