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