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