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