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