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