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