[gcc/]
[official-gcc.git] / gcc / tree-pretty-print.c
blobca6e014f96ef6188a829fead89eec26e59cf088b
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2014 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "tree.h"
26 #include "stor-layout.h"
27 #include "expr.h"
28 #include "tree-pretty-print.h"
29 #include "hashtab.h"
30 #include "pointer-set.h"
31 #include "gimple-expr.h"
32 #include "cgraph.h"
33 #include "langhooks.h"
34 #include "tree-iterator.h"
35 #include "tree-chrec.h"
36 #include "dumpfile.h"
37 #include "value-prof.h"
38 #include "predict.h"
39 #include "wide-int-print.h"
40 #include "internal-fn.h"
42 #include <new> // For placement-new.
44 /* Local functions, macros and variables. */
45 static const char *op_symbol (const_tree);
46 static void pretty_print_string (pretty_printer *, const char*);
47 static void newline_and_indent (pretty_printer *, int);
48 static void maybe_init_pretty_print (FILE *);
49 static void print_struct_decl (pretty_printer *, const_tree, int, int);
50 static void do_niy (pretty_printer *, const_tree);
52 #define INDENT(SPACE) do { \
53 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
55 #define NIY do_niy (buffer, node)
57 static pretty_printer buffer;
58 static int initialized = 0;
60 /* Try to print something for an unknown tree code. */
62 static void
63 do_niy (pretty_printer *buffer, const_tree node)
65 int i, len;
67 pp_string (buffer, "<<< Unknown tree: ");
68 pp_string (buffer, get_tree_code_name (TREE_CODE (node)));
70 if (EXPR_P (node))
72 len = TREE_OPERAND_LENGTH (node);
73 for (i = 0; i < len; ++i)
75 newline_and_indent (buffer, 2);
76 dump_generic_node (buffer, TREE_OPERAND (node, i), 2, 0, false);
80 pp_string (buffer, " >>>");
83 /* Debugging function to print out a generic expression. */
85 DEBUG_FUNCTION void
86 debug_generic_expr (tree t)
88 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
89 fprintf (stderr, "\n");
92 /* Debugging function to print out a generic statement. */
94 DEBUG_FUNCTION void
95 debug_generic_stmt (tree t)
97 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
98 fprintf (stderr, "\n");
101 /* Debugging function to print out a chain of trees . */
103 DEBUG_FUNCTION void
104 debug_tree_chain (tree t)
106 struct pointer_set_t *seen = pointer_set_create ();
108 while (t)
110 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
111 fprintf (stderr, " ");
112 t = TREE_CHAIN (t);
113 if (pointer_set_insert (seen, t))
115 fprintf (stderr, "... [cycled back to ");
116 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
117 fprintf (stderr, "]");
118 break;
121 fprintf (stderr, "\n");
123 pointer_set_destroy (seen);
126 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
127 void
128 print_generic_decl (FILE *file, tree decl, int flags)
130 maybe_init_pretty_print (file);
131 print_declaration (&buffer, decl, 2, flags);
132 pp_write_text_to_stream (&buffer);
135 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
136 to show in the dump. See TDF_* in dumpfile.h. */
138 void
139 print_generic_stmt (FILE *file, tree t, int flags)
141 maybe_init_pretty_print (file);
142 dump_generic_node (&buffer, t, 0, flags, true);
143 pp_newline_and_flush (&buffer);
146 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
147 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
148 INDENT spaces. */
150 void
151 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
153 int i;
155 maybe_init_pretty_print (file);
157 for (i = 0; i < indent; i++)
158 pp_space (&buffer);
159 dump_generic_node (&buffer, t, indent, flags, true);
160 pp_newline_and_flush (&buffer);
163 /* Print a single expression T on file FILE. FLAGS specifies details to show
164 in the dump. See TDF_* in dumpfile.h. */
166 void
167 print_generic_expr (FILE *file, tree t, int flags)
169 maybe_init_pretty_print (file);
170 dump_generic_node (&buffer, t, 0, flags, false);
171 pp_flush (&buffer);
174 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
175 in FLAGS. */
177 static void
178 dump_decl_name (pretty_printer *buffer, tree node, int flags)
180 if (DECL_NAME (node))
182 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
183 pp_tree_identifier (buffer, DECL_ASSEMBLER_NAME (node));
184 else
185 pp_tree_identifier (buffer, DECL_NAME (node));
187 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
189 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
190 pp_printf (buffer, "L.%d", (int) LABEL_DECL_UID (node));
191 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
193 if (flags & TDF_NOUID)
194 pp_string (buffer, "D#xxxx");
195 else
196 pp_printf (buffer, "D#%i", DEBUG_TEMP_UID (node));
198 else
200 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
201 if (flags & TDF_NOUID)
202 pp_printf (buffer, "%c.xxxx", c);
203 else
204 pp_printf (buffer, "%c.%u", c, DECL_UID (node));
207 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
209 if (flags & TDF_NOUID)
210 pp_printf (buffer, "ptD.xxxx");
211 else
212 pp_printf (buffer, "ptD.%u", DECL_PT_UID (node));
216 /* Like the above, but used for pretty printing function calls. */
218 static void
219 dump_function_name (pretty_printer *buffer, tree node, int flags)
221 if (TREE_CODE (node) == NOP_EXPR)
222 node = TREE_OPERAND (node, 0);
223 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
224 pp_string (buffer, lang_hooks.decl_printable_name (node, 1));
225 else
226 dump_decl_name (buffer, node, flags);
229 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
230 FLAGS are as in dump_generic_node. */
232 static void
233 dump_function_declaration (pretty_printer *buffer, tree node,
234 int spc, int flags)
236 bool wrote_arg = false;
237 tree arg;
239 pp_space (buffer);
240 pp_left_paren (buffer);
242 /* Print the argument types. */
243 arg = TYPE_ARG_TYPES (node);
244 while (arg && arg != void_list_node && arg != error_mark_node)
246 if (wrote_arg)
248 pp_comma (buffer);
249 pp_space (buffer);
251 wrote_arg = true;
252 dump_generic_node (buffer, TREE_VALUE (arg), spc, flags, false);
253 arg = TREE_CHAIN (arg);
256 /* Drop the trailing void_type_node if we had any previous argument. */
257 if (arg == void_list_node && !wrote_arg)
258 pp_string (buffer, "void");
259 /* Properly dump vararg function types. */
260 else if (!arg && wrote_arg)
261 pp_string (buffer, ", ...");
262 /* Avoid printing any arg for unprototyped functions. */
264 pp_right_paren (buffer);
267 /* Dump the domain associated with an array. */
269 static void
270 dump_array_domain (pretty_printer *buffer, tree domain, int spc, int flags)
272 pp_left_bracket (buffer);
273 if (domain)
275 tree min = TYPE_MIN_VALUE (domain);
276 tree max = TYPE_MAX_VALUE (domain);
278 if (min && max
279 && integer_zerop (min)
280 && tree_fits_shwi_p (max))
281 pp_wide_integer (buffer, tree_to_shwi (max) + 1);
282 else
284 if (min)
285 dump_generic_node (buffer, min, spc, flags, false);
286 pp_colon (buffer);
287 if (max)
288 dump_generic_node (buffer, max, spc, flags, false);
291 else
292 pp_string (buffer, "<unknown>");
293 pp_right_bracket (buffer);
297 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
298 dump_generic_node. */
300 static void
301 dump_omp_clause (pretty_printer *buffer, tree clause, int spc, int flags)
303 const char *name;
305 switch (OMP_CLAUSE_CODE (clause))
307 case OMP_CLAUSE_PRIVATE:
308 name = "private";
309 goto print_remap;
310 case OMP_CLAUSE_SHARED:
311 name = "shared";
312 goto print_remap;
313 case OMP_CLAUSE_FIRSTPRIVATE:
314 name = "firstprivate";
315 goto print_remap;
316 case OMP_CLAUSE_LASTPRIVATE:
317 name = "lastprivate";
318 goto print_remap;
319 case OMP_CLAUSE_COPYIN:
320 name = "copyin";
321 goto print_remap;
322 case OMP_CLAUSE_COPYPRIVATE:
323 name = "copyprivate";
324 goto print_remap;
325 case OMP_CLAUSE_UNIFORM:
326 name = "uniform";
327 goto print_remap;
328 case OMP_CLAUSE__LOOPTEMP_:
329 name = "_looptemp_";
330 goto print_remap;
331 print_remap:
332 pp_string (buffer, name);
333 pp_left_paren (buffer);
334 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
335 spc, flags, false);
336 pp_right_paren (buffer);
337 break;
339 case OMP_CLAUSE_REDUCTION:
340 pp_string (buffer, "reduction(");
341 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
343 pp_string (buffer,
344 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
345 pp_colon (buffer);
347 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
348 spc, flags, false);
349 pp_right_paren (buffer);
350 break;
352 case OMP_CLAUSE_IF:
353 pp_string (buffer, "if(");
354 dump_generic_node (buffer, OMP_CLAUSE_IF_EXPR (clause),
355 spc, flags, false);
356 pp_right_paren (buffer);
357 break;
359 case OMP_CLAUSE_NUM_THREADS:
360 pp_string (buffer, "num_threads(");
361 dump_generic_node (buffer, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
362 spc, flags, false);
363 pp_right_paren (buffer);
364 break;
366 case OMP_CLAUSE_NOWAIT:
367 pp_string (buffer, "nowait");
368 break;
369 case OMP_CLAUSE_ORDERED:
370 pp_string (buffer, "ordered");
371 break;
373 case OMP_CLAUSE_DEFAULT:
374 pp_string (buffer, "default(");
375 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
377 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
378 break;
379 case OMP_CLAUSE_DEFAULT_SHARED:
380 pp_string (buffer, "shared");
381 break;
382 case OMP_CLAUSE_DEFAULT_NONE:
383 pp_string (buffer, "none");
384 break;
385 case OMP_CLAUSE_DEFAULT_PRIVATE:
386 pp_string (buffer, "private");
387 break;
388 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
389 pp_string (buffer, "firstprivate");
390 break;
391 default:
392 gcc_unreachable ();
394 pp_right_paren (buffer);
395 break;
397 case OMP_CLAUSE_SCHEDULE:
398 pp_string (buffer, "schedule(");
399 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
401 case OMP_CLAUSE_SCHEDULE_STATIC:
402 pp_string (buffer, "static");
403 break;
404 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
405 pp_string (buffer, "dynamic");
406 break;
407 case OMP_CLAUSE_SCHEDULE_GUIDED:
408 pp_string (buffer, "guided");
409 break;
410 case OMP_CLAUSE_SCHEDULE_RUNTIME:
411 pp_string (buffer, "runtime");
412 break;
413 case OMP_CLAUSE_SCHEDULE_AUTO:
414 pp_string (buffer, "auto");
415 break;
416 default:
417 gcc_unreachable ();
419 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
421 pp_comma (buffer);
422 dump_generic_node (buffer, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
423 spc, flags, false);
425 pp_right_paren (buffer);
426 break;
428 case OMP_CLAUSE_UNTIED:
429 pp_string (buffer, "untied");
430 break;
432 case OMP_CLAUSE_COLLAPSE:
433 pp_string (buffer, "collapse(");
434 dump_generic_node (buffer, OMP_CLAUSE_COLLAPSE_EXPR (clause),
435 spc, flags, false);
436 pp_right_paren (buffer);
437 break;
439 case OMP_CLAUSE_FINAL:
440 pp_string (buffer, "final(");
441 dump_generic_node (buffer, OMP_CLAUSE_FINAL_EXPR (clause),
442 spc, flags, false);
443 pp_right_paren (buffer);
444 break;
446 case OMP_CLAUSE_MERGEABLE:
447 pp_string (buffer, "mergeable");
448 break;
450 case OMP_CLAUSE_LINEAR:
451 pp_string (buffer, "linear(");
452 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
453 spc, flags, false);
454 pp_colon (buffer);
455 dump_generic_node (buffer, OMP_CLAUSE_LINEAR_STEP (clause),
456 spc, flags, false);
457 pp_right_paren (buffer);
458 break;
460 case OMP_CLAUSE_ALIGNED:
461 pp_string (buffer, "aligned(");
462 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
463 spc, flags, false);
464 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
466 pp_colon (buffer);
467 dump_generic_node (buffer, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
468 spc, flags, false);
470 pp_right_paren (buffer);
471 break;
473 case OMP_CLAUSE_DEPEND:
474 pp_string (buffer, "depend(");
475 switch (OMP_CLAUSE_DEPEND_KIND (clause))
477 case OMP_CLAUSE_DEPEND_IN:
478 pp_string (buffer, "in");
479 break;
480 case OMP_CLAUSE_DEPEND_OUT:
481 pp_string (buffer, "out");
482 break;
483 case OMP_CLAUSE_DEPEND_INOUT:
484 pp_string (buffer, "inout");
485 break;
486 default:
487 gcc_unreachable ();
489 pp_colon (buffer);
490 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
491 spc, flags, false);
492 pp_right_paren (buffer);
493 break;
495 case OMP_CLAUSE_MAP:
496 pp_string (buffer, "map(");
497 switch (OMP_CLAUSE_MAP_KIND (clause))
499 case OMP_CLAUSE_MAP_ALLOC:
500 case OMP_CLAUSE_MAP_POINTER:
501 pp_string (buffer, "alloc");
502 break;
503 case OMP_CLAUSE_MAP_TO:
504 case OMP_CLAUSE_MAP_TO_PSET:
505 pp_string (buffer, "to");
506 break;
507 case OMP_CLAUSE_MAP_FROM:
508 pp_string (buffer, "from");
509 break;
510 case OMP_CLAUSE_MAP_TOFROM:
511 pp_string (buffer, "tofrom");
512 break;
513 default:
514 gcc_unreachable ();
516 pp_colon (buffer);
517 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
518 spc, flags, false);
519 print_clause_size:
520 if (OMP_CLAUSE_SIZE (clause))
522 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
523 && OMP_CLAUSE_MAP_KIND (clause) == OMP_CLAUSE_MAP_POINTER)
524 pp_string (buffer, " [pointer assign, bias: ");
525 else if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
526 && OMP_CLAUSE_MAP_KIND (clause) == OMP_CLAUSE_MAP_TO_PSET)
527 pp_string (buffer, " [pointer set, len: ");
528 else
529 pp_string (buffer, " [len: ");
530 dump_generic_node (buffer, OMP_CLAUSE_SIZE (clause),
531 spc, flags, false);
532 pp_right_bracket (buffer);
534 pp_right_paren (buffer);
535 break;
537 case OMP_CLAUSE_FROM:
538 pp_string (buffer, "from(");
539 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
540 spc, flags, false);
541 goto print_clause_size;
543 case OMP_CLAUSE_TO:
544 pp_string (buffer, "to(");
545 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
546 spc, flags, false);
547 goto print_clause_size;
549 case OMP_CLAUSE_NUM_TEAMS:
550 pp_string (buffer, "num_teams(");
551 dump_generic_node (buffer, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
552 spc, flags, false);
553 pp_right_paren (buffer);
554 break;
556 case OMP_CLAUSE_THREAD_LIMIT:
557 pp_string (buffer, "thread_limit(");
558 dump_generic_node (buffer, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
559 spc, flags, false);
560 pp_right_paren (buffer);
561 break;
563 case OMP_CLAUSE_DEVICE:
564 pp_string (buffer, "device(");
565 dump_generic_node (buffer, OMP_CLAUSE_DEVICE_ID (clause),
566 spc, flags, false);
567 pp_right_paren (buffer);
568 break;
570 case OMP_CLAUSE_DIST_SCHEDULE:
571 pp_string (buffer, "dist_schedule(static");
572 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
574 pp_comma (buffer);
575 dump_generic_node (buffer,
576 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
577 spc, flags, false);
579 pp_right_paren (buffer);
580 break;
582 case OMP_CLAUSE_PROC_BIND:
583 pp_string (buffer, "proc_bind(");
584 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
586 case OMP_CLAUSE_PROC_BIND_MASTER:
587 pp_string (buffer, "master");
588 break;
589 case OMP_CLAUSE_PROC_BIND_CLOSE:
590 pp_string (buffer, "close");
591 break;
592 case OMP_CLAUSE_PROC_BIND_SPREAD:
593 pp_string (buffer, "spread");
594 break;
595 default:
596 gcc_unreachable ();
598 pp_right_paren (buffer);
599 break;
601 case OMP_CLAUSE_SAFELEN:
602 pp_string (buffer, "safelen(");
603 dump_generic_node (buffer, OMP_CLAUSE_SAFELEN_EXPR (clause),
604 spc, flags, false);
605 pp_right_paren (buffer);
606 break;
608 case OMP_CLAUSE_SIMDLEN:
609 pp_string (buffer, "simdlen(");
610 dump_generic_node (buffer, OMP_CLAUSE_SIMDLEN_EXPR (clause),
611 spc, flags, false);
612 pp_right_paren (buffer);
613 break;
615 case OMP_CLAUSE__SIMDUID_:
616 pp_string (buffer, "_simduid_(");
617 dump_generic_node (buffer, OMP_CLAUSE__SIMDUID__DECL (clause),
618 spc, flags, false);
619 pp_right_paren (buffer);
620 break;
622 case OMP_CLAUSE_INBRANCH:
623 pp_string (buffer, "inbranch");
624 break;
625 case OMP_CLAUSE_NOTINBRANCH:
626 pp_string (buffer, "notinbranch");
627 break;
628 case OMP_CLAUSE_FOR:
629 pp_string (buffer, "for");
630 break;
631 case OMP_CLAUSE_PARALLEL:
632 pp_string (buffer, "parallel");
633 break;
634 case OMP_CLAUSE_SECTIONS:
635 pp_string (buffer, "sections");
636 break;
637 case OMP_CLAUSE_TASKGROUP:
638 pp_string (buffer, "taskgroup");
639 break;
641 default:
642 /* Should never happen. */
643 dump_generic_node (buffer, clause, spc, flags, false);
644 break;
649 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
650 dump_generic_node. */
652 void
653 dump_omp_clauses (pretty_printer *buffer, tree clause, int spc, int flags)
655 if (clause == NULL)
656 return;
658 pp_space (buffer);
659 while (1)
661 dump_omp_clause (buffer, clause, spc, flags);
662 clause = OMP_CLAUSE_CHAIN (clause);
663 if (clause == NULL)
664 return;
665 pp_space (buffer);
670 /* Dump location LOC to BUFFER. */
672 static void
673 dump_location (pretty_printer *buffer, location_t loc)
675 expanded_location xloc = expand_location (loc);
677 pp_left_bracket (buffer);
678 if (xloc.file)
680 pp_string (buffer, xloc.file);
681 pp_string (buffer, " : ");
683 pp_decimal_int (buffer, xloc.line);
684 pp_string (buffer, "] ");
688 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
689 dump_generic_node. */
691 static void
692 dump_block_node (pretty_printer *buffer, tree block, int spc, int flags)
694 tree t;
696 pp_printf (buffer, "BLOCK #%d ", BLOCK_NUMBER (block));
698 if (flags & TDF_ADDRESS)
699 pp_printf (buffer, "[%p] ", (void *) block);
701 if (BLOCK_ABSTRACT (block))
702 pp_string (buffer, "[abstract] ");
704 if (TREE_ASM_WRITTEN (block))
705 pp_string (buffer, "[written] ");
707 if (flags & TDF_SLIM)
708 return;
710 if (BLOCK_SOURCE_LOCATION (block))
711 dump_location (buffer, BLOCK_SOURCE_LOCATION (block));
713 newline_and_indent (buffer, spc + 2);
715 if (BLOCK_SUPERCONTEXT (block))
717 pp_string (buffer, "SUPERCONTEXT: ");
718 dump_generic_node (buffer, BLOCK_SUPERCONTEXT (block), 0,
719 flags | TDF_SLIM, false);
720 newline_and_indent (buffer, spc + 2);
723 if (BLOCK_SUBBLOCKS (block))
725 pp_string (buffer, "SUBBLOCKS: ");
726 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
728 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
729 pp_space (buffer);
731 newline_and_indent (buffer, spc + 2);
734 if (BLOCK_CHAIN (block))
736 pp_string (buffer, "SIBLINGS: ");
737 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
739 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
740 pp_space (buffer);
742 newline_and_indent (buffer, spc + 2);
745 if (BLOCK_VARS (block))
747 pp_string (buffer, "VARS: ");
748 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
750 dump_generic_node (buffer, t, 0, flags, false);
751 pp_space (buffer);
753 newline_and_indent (buffer, spc + 2);
756 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
758 unsigned i;
759 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
761 pp_string (buffer, "NONLOCALIZED_VARS: ");
762 FOR_EACH_VEC_ELT (*nlv, i, t)
764 dump_generic_node (buffer, t, 0, flags, false);
765 pp_space (buffer);
767 newline_and_indent (buffer, spc + 2);
770 if (BLOCK_ABSTRACT_ORIGIN (block))
772 pp_string (buffer, "ABSTRACT_ORIGIN: ");
773 dump_generic_node (buffer, BLOCK_ABSTRACT_ORIGIN (block), 0,
774 flags | TDF_SLIM, false);
775 newline_and_indent (buffer, spc + 2);
778 if (BLOCK_FRAGMENT_ORIGIN (block))
780 pp_string (buffer, "FRAGMENT_ORIGIN: ");
781 dump_generic_node (buffer, BLOCK_FRAGMENT_ORIGIN (block), 0,
782 flags | TDF_SLIM, false);
783 newline_and_indent (buffer, spc + 2);
786 if (BLOCK_FRAGMENT_CHAIN (block))
788 pp_string (buffer, "FRAGMENT_CHAIN: ");
789 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
791 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
792 pp_space (buffer);
794 newline_and_indent (buffer, spc + 2);
799 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
800 indent. FLAGS specifies details to show in the dump (see TDF_* in
801 dumpfile.h). If IS_STMT is true, the object printed is considered
802 to be a statement and it is terminated by ';' if appropriate. */
805 dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
806 bool is_stmt)
808 tree type;
809 tree op0, op1;
810 const char *str;
811 bool is_expr;
812 enum tree_code code;
814 if (node == NULL_TREE)
815 return spc;
817 is_expr = EXPR_P (node);
819 if (is_stmt && (flags & TDF_STMTADDR))
820 pp_printf (buffer, "<&%p> ", (void *)node);
822 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
823 dump_location (buffer, EXPR_LOCATION (node));
825 code = TREE_CODE (node);
826 switch (code)
828 case ERROR_MARK:
829 pp_string (buffer, "<<< error >>>");
830 break;
832 case IDENTIFIER_NODE:
833 pp_tree_identifier (buffer, node);
834 break;
836 case TREE_LIST:
837 while (node && node != error_mark_node)
839 if (TREE_PURPOSE (node))
841 dump_generic_node (buffer, TREE_PURPOSE (node), spc, flags, false);
842 pp_space (buffer);
844 dump_generic_node (buffer, TREE_VALUE (node), spc, flags, false);
845 node = TREE_CHAIN (node);
846 if (node && TREE_CODE (node) == TREE_LIST)
848 pp_comma (buffer);
849 pp_space (buffer);
852 break;
854 case TREE_BINFO:
855 dump_generic_node (buffer, BINFO_TYPE (node), spc, flags, false);
856 break;
858 case TREE_VEC:
860 size_t i;
861 if (TREE_VEC_LENGTH (node) > 0)
863 size_t len = TREE_VEC_LENGTH (node);
864 for (i = 0; i < len - 1; i++)
866 dump_generic_node (buffer, TREE_VEC_ELT (node, i), spc, flags,
867 false);
868 pp_comma (buffer);
869 pp_space (buffer);
871 dump_generic_node (buffer, TREE_VEC_ELT (node, len - 1), spc,
872 flags, false);
875 break;
877 case VOID_TYPE:
878 case INTEGER_TYPE:
879 case REAL_TYPE:
880 case FIXED_POINT_TYPE:
881 case COMPLEX_TYPE:
882 case VECTOR_TYPE:
883 case ENUMERAL_TYPE:
884 case BOOLEAN_TYPE:
886 unsigned int quals = TYPE_QUALS (node);
887 enum tree_code_class tclass;
889 if (quals & TYPE_QUAL_ATOMIC)
890 pp_string (buffer, "atomic ");
891 if (quals & TYPE_QUAL_CONST)
892 pp_string (buffer, "const ");
893 else if (quals & TYPE_QUAL_VOLATILE)
894 pp_string (buffer, "volatile ");
895 else if (quals & TYPE_QUAL_RESTRICT)
896 pp_string (buffer, "restrict ");
898 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
900 pp_string (buffer, "<address-space-");
901 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
902 pp_string (buffer, "> ");
905 tclass = TREE_CODE_CLASS (TREE_CODE (node));
907 if (tclass == tcc_declaration)
909 if (DECL_NAME (node))
910 dump_decl_name (buffer, node, flags);
911 else
912 pp_string (buffer, "<unnamed type decl>");
914 else if (tclass == tcc_type)
916 if (TYPE_NAME (node))
918 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
919 pp_tree_identifier (buffer, TYPE_NAME (node));
920 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
921 && DECL_NAME (TYPE_NAME (node)))
922 dump_decl_name (buffer, TYPE_NAME (node), flags);
923 else
924 pp_string (buffer, "<unnamed type>");
926 else if (TREE_CODE (node) == VECTOR_TYPE)
928 pp_string (buffer, "vector");
929 pp_left_paren (buffer);
930 pp_wide_integer (buffer, TYPE_VECTOR_SUBPARTS (node));
931 pp_string (buffer, ") ");
932 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
934 else if (TREE_CODE (node) == INTEGER_TYPE)
936 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
937 pp_string (buffer, (TYPE_UNSIGNED (node)
938 ? "unsigned char"
939 : "signed char"));
940 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
941 pp_string (buffer, (TYPE_UNSIGNED (node)
942 ? "unsigned short"
943 : "signed short"));
944 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
945 pp_string (buffer, (TYPE_UNSIGNED (node)
946 ? "unsigned int"
947 : "signed int"));
948 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
949 pp_string (buffer, (TYPE_UNSIGNED (node)
950 ? "unsigned long"
951 : "signed long"));
952 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
953 pp_string (buffer, (TYPE_UNSIGNED (node)
954 ? "unsigned long long"
955 : "signed long long"));
956 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
957 && exact_log2 (TYPE_PRECISION (node)) != -1)
959 pp_string (buffer, (TYPE_UNSIGNED (node) ? "uint" : "int"));
960 pp_decimal_int (buffer, TYPE_PRECISION (node));
961 pp_string (buffer, "_t");
963 else
965 pp_string (buffer, (TYPE_UNSIGNED (node)
966 ? "<unnamed-unsigned:"
967 : "<unnamed-signed:"));
968 pp_decimal_int (buffer, TYPE_PRECISION (node));
969 pp_greater (buffer);
972 else if (TREE_CODE (node) == COMPLEX_TYPE)
974 pp_string (buffer, "__complex__ ");
975 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
977 else if (TREE_CODE (node) == REAL_TYPE)
979 pp_string (buffer, "<float:");
980 pp_decimal_int (buffer, TYPE_PRECISION (node));
981 pp_greater (buffer);
983 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
985 pp_string (buffer, "<fixed-point-");
986 pp_string (buffer, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
987 pp_decimal_int (buffer, TYPE_PRECISION (node));
988 pp_greater (buffer);
990 else if (TREE_CODE (node) == VOID_TYPE)
991 pp_string (buffer, "void");
992 else
993 pp_string (buffer, "<unnamed type>");
995 break;
998 case POINTER_TYPE:
999 case REFERENCE_TYPE:
1000 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1002 if (TREE_TYPE (node) == NULL)
1004 pp_string (buffer, str);
1005 pp_string (buffer, "<null type>");
1007 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1009 tree fnode = TREE_TYPE (node);
1011 dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags, false);
1012 pp_space (buffer);
1013 pp_left_paren (buffer);
1014 pp_string (buffer, str);
1015 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1016 dump_decl_name (buffer, TYPE_NAME (node), flags);
1017 else if (flags & TDF_NOUID)
1018 pp_printf (buffer, "<Txxxx>");
1019 else
1020 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1022 pp_right_paren (buffer);
1023 dump_function_declaration (buffer, fnode, spc, flags);
1025 else
1027 unsigned int quals = TYPE_QUALS (node);
1029 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1030 pp_space (buffer);
1031 pp_string (buffer, str);
1033 if (quals & TYPE_QUAL_CONST)
1034 pp_string (buffer, " const");
1035 if (quals & TYPE_QUAL_VOLATILE)
1036 pp_string (buffer, " volatile");
1037 if (quals & TYPE_QUAL_RESTRICT)
1038 pp_string (buffer, " restrict");
1040 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1042 pp_string (buffer, " <address-space-");
1043 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
1044 pp_greater (buffer);
1047 if (TYPE_REF_CAN_ALIAS_ALL (node))
1048 pp_string (buffer, " {ref-all}");
1050 break;
1052 case OFFSET_TYPE:
1053 NIY;
1054 break;
1056 case MEM_REF:
1058 if (integer_zerop (TREE_OPERAND (node, 1))
1059 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1060 infer them and MEM_ATTR caching will share MEM_REFs
1061 with differently-typed op0s. */
1062 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1063 /* Released SSA_NAMES have no TREE_TYPE. */
1064 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1065 /* Same pointer types, but ignoring POINTER_TYPE vs.
1066 REFERENCE_TYPE. */
1067 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1068 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1069 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1070 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1071 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1072 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1073 /* Same value types ignoring qualifiers. */
1074 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1075 == TYPE_MAIN_VARIANT
1076 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))))
1078 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1080 pp_star (buffer);
1081 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1082 spc, flags, false);
1084 else
1085 dump_generic_node (buffer,
1086 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1087 spc, flags, false);
1089 else
1091 tree ptype;
1093 pp_string (buffer, "MEM[");
1094 pp_left_paren (buffer);
1095 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1096 dump_generic_node (buffer, ptype,
1097 spc, flags | TDF_SLIM, false);
1098 pp_right_paren (buffer);
1099 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1100 spc, flags, false);
1101 if (!integer_zerop (TREE_OPERAND (node, 1)))
1103 pp_string (buffer, " + ");
1104 dump_generic_node (buffer, TREE_OPERAND (node, 1),
1105 spc, flags, false);
1107 pp_right_bracket (buffer);
1109 break;
1112 case TARGET_MEM_REF:
1114 const char *sep = "";
1115 tree tmp;
1117 pp_string (buffer, "MEM[");
1119 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1121 pp_string (buffer, sep);
1122 sep = ", ";
1123 pp_string (buffer, "symbol: ");
1124 dump_generic_node (buffer, TREE_OPERAND (TMR_BASE (node), 0),
1125 spc, flags, false);
1127 else
1129 pp_string (buffer, sep);
1130 sep = ", ";
1131 pp_string (buffer, "base: ");
1132 dump_generic_node (buffer, TMR_BASE (node), spc, flags, false);
1134 tmp = TMR_INDEX2 (node);
1135 if (tmp)
1137 pp_string (buffer, sep);
1138 sep = ", ";
1139 pp_string (buffer, "base: ");
1140 dump_generic_node (buffer, tmp, spc, flags, false);
1142 tmp = TMR_INDEX (node);
1143 if (tmp)
1145 pp_string (buffer, sep);
1146 sep = ", ";
1147 pp_string (buffer, "index: ");
1148 dump_generic_node (buffer, tmp, spc, flags, false);
1150 tmp = TMR_STEP (node);
1151 if (tmp)
1153 pp_string (buffer, sep);
1154 sep = ", ";
1155 pp_string (buffer, "step: ");
1156 dump_generic_node (buffer, tmp, spc, flags, false);
1158 tmp = TMR_OFFSET (node);
1159 if (tmp)
1161 pp_string (buffer, sep);
1162 sep = ", ";
1163 pp_string (buffer, "offset: ");
1164 dump_generic_node (buffer, tmp, spc, flags, false);
1166 pp_right_bracket (buffer);
1168 break;
1170 case ARRAY_TYPE:
1172 tree tmp;
1174 /* Print the innermost component type. */
1175 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1176 tmp = TREE_TYPE (tmp))
1178 dump_generic_node (buffer, tmp, spc, flags, false);
1180 /* Print the dimensions. */
1181 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1182 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
1183 break;
1186 case RECORD_TYPE:
1187 case UNION_TYPE:
1188 case QUAL_UNION_TYPE:
1190 unsigned int quals = TYPE_QUALS (node);
1192 if (quals & TYPE_QUAL_ATOMIC)
1193 pp_string (buffer, "atomic ");
1194 if (quals & TYPE_QUAL_CONST)
1195 pp_string (buffer, "const ");
1196 if (quals & TYPE_QUAL_VOLATILE)
1197 pp_string (buffer, "volatile ");
1199 /* Print the name of the structure. */
1200 if (TREE_CODE (node) == RECORD_TYPE)
1201 pp_string (buffer, "struct ");
1202 else if (TREE_CODE (node) == UNION_TYPE)
1203 pp_string (buffer, "union ");
1205 if (TYPE_NAME (node))
1206 dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false);
1207 else if (!(flags & TDF_SLIM))
1208 /* FIXME: If we eliminate the 'else' above and attempt
1209 to show the fields for named types, we may get stuck
1210 following a cycle of pointers to structs. The alleged
1211 self-reference check in print_struct_decl will not detect
1212 cycles involving more than one pointer or struct type. */
1213 print_struct_decl (buffer, node, spc, flags);
1214 break;
1217 case LANG_TYPE:
1218 NIY;
1219 break;
1221 case INTEGER_CST:
1222 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1224 /* In the case of a pointer, one may want to divide by the
1225 size of the pointed-to type. Unfortunately, this not
1226 straightforward. The C front-end maps expressions
1228 (int *) 5
1229 int *p; (p + 5)
1231 in such a way that the two INTEGER_CST nodes for "5" have
1232 different values but identical types. In the latter
1233 case, the 5 is multiplied by sizeof (int) in c-common.c
1234 (pointer_int_sum) to convert it to a byte address, and
1235 yet the type of the node is left unchanged. Argh. What
1236 is consistent though is that the number value corresponds
1237 to bytes (UNITS) offset.
1239 NB: Neither of the following divisors can be trivially
1240 used to recover the original literal:
1242 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1243 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1244 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
1245 pp_string (buffer, "B"); /* pseudo-unit */
1247 else if (tree_fits_shwi_p (node))
1248 pp_wide_integer (buffer, tree_to_shwi (node));
1249 else if (tree_fits_uhwi_p (node))
1250 pp_unsigned_wide_integer (buffer, tree_to_uhwi (node));
1251 else
1253 wide_int val = node;
1255 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1257 pp_minus (buffer);
1258 val = -val;
1260 print_hex (val, pp_buffer (buffer)->digit_buffer);
1261 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
1263 if (TREE_OVERFLOW (node))
1264 pp_string (buffer, "(OVF)");
1265 break;
1267 case REAL_CST:
1268 /* Code copied from print_node. */
1270 REAL_VALUE_TYPE d;
1271 if (TREE_OVERFLOW (node))
1272 pp_string (buffer, " overflow");
1274 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1275 d = TREE_REAL_CST (node);
1276 if (REAL_VALUE_ISINF (d))
1277 pp_string (buffer, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1278 else if (REAL_VALUE_ISNAN (d))
1279 pp_string (buffer, " Nan");
1280 else
1282 char string[100];
1283 real_to_decimal (string, &d, sizeof (string), 0, 1);
1284 pp_string (buffer, string);
1286 #else
1288 HOST_WIDE_INT i;
1289 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
1290 pp_string (buffer, "0x");
1291 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
1292 output_formatted_integer (buffer, "%02x", *p++);
1294 #endif
1295 break;
1298 case FIXED_CST:
1300 char string[100];
1301 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1302 pp_string (buffer, string);
1303 break;
1306 case COMPLEX_CST:
1307 pp_string (buffer, "__complex__ (");
1308 dump_generic_node (buffer, TREE_REALPART (node), spc, flags, false);
1309 pp_string (buffer, ", ");
1310 dump_generic_node (buffer, TREE_IMAGPART (node), spc, flags, false);
1311 pp_right_paren (buffer);
1312 break;
1314 case STRING_CST:
1315 pp_string (buffer, "\"");
1316 pretty_print_string (buffer, TREE_STRING_POINTER (node));
1317 pp_string (buffer, "\"");
1318 break;
1320 case VECTOR_CST:
1322 unsigned i;
1323 pp_string (buffer, "{ ");
1324 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1326 if (i != 0)
1327 pp_string (buffer, ", ");
1328 dump_generic_node (buffer, VECTOR_CST_ELT (node, i),
1329 spc, flags, false);
1331 pp_string (buffer, " }");
1333 break;
1335 case FUNCTION_TYPE:
1336 case METHOD_TYPE:
1337 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1338 pp_space (buffer);
1339 if (TREE_CODE (node) == METHOD_TYPE)
1341 if (TYPE_METHOD_BASETYPE (node))
1342 dump_decl_name (buffer, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1343 flags);
1344 else
1345 pp_string (buffer, "<null method basetype>");
1346 pp_colon_colon (buffer);
1348 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1349 dump_decl_name (buffer, TYPE_NAME (node), flags);
1350 else if (flags & TDF_NOUID)
1351 pp_printf (buffer, "<Txxxx>");
1352 else
1353 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1354 dump_function_declaration (buffer, node, spc, flags);
1355 break;
1357 case FUNCTION_DECL:
1358 case CONST_DECL:
1359 dump_decl_name (buffer, node, flags);
1360 break;
1362 case LABEL_DECL:
1363 if (DECL_NAME (node))
1364 dump_decl_name (buffer, node, flags);
1365 else if (LABEL_DECL_UID (node) != -1)
1366 pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node));
1367 else
1369 if (flags & TDF_NOUID)
1370 pp_string (buffer, "<D.xxxx>");
1371 else
1372 pp_printf (buffer, "<D.%u>", DECL_UID (node));
1374 break;
1376 case TYPE_DECL:
1377 if (DECL_IS_BUILTIN (node))
1379 /* Don't print the declaration of built-in types. */
1380 break;
1382 if (DECL_NAME (node))
1383 dump_decl_name (buffer, node, flags);
1384 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1386 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1387 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1388 && TYPE_METHODS (TREE_TYPE (node)))
1390 /* The type is a c++ class: all structures have at least
1391 4 methods. */
1392 pp_string (buffer, "class ");
1393 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1395 else
1397 pp_string (buffer,
1398 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1399 ? "union" : "struct "));
1400 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1403 else
1404 pp_string (buffer, "<anon>");
1405 break;
1407 case VAR_DECL:
1408 case PARM_DECL:
1409 case FIELD_DECL:
1410 case DEBUG_EXPR_DECL:
1411 case NAMESPACE_DECL:
1412 case NAMELIST_DECL:
1413 dump_decl_name (buffer, node, flags);
1414 break;
1416 case RESULT_DECL:
1417 pp_string (buffer, "<retval>");
1418 break;
1420 case COMPONENT_REF:
1421 op0 = TREE_OPERAND (node, 0);
1422 str = ".";
1423 if (op0
1424 && (TREE_CODE (op0) == INDIRECT_REF
1425 || (TREE_CODE (op0) == MEM_REF
1426 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1427 && integer_zerop (TREE_OPERAND (op0, 1))
1428 /* Dump the types of INTEGER_CSTs explicitly, for we
1429 can't infer them and MEM_ATTR caching will share
1430 MEM_REFs with differently-typed op0s. */
1431 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1432 /* Released SSA_NAMES have no TREE_TYPE. */
1433 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1434 /* Same pointer types, but ignoring POINTER_TYPE vs.
1435 REFERENCE_TYPE. */
1436 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1437 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1438 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1439 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1440 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1441 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1442 /* Same value types ignoring qualifiers. */
1443 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1444 == TYPE_MAIN_VARIANT
1445 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))))))
1447 op0 = TREE_OPERAND (op0, 0);
1448 str = "->";
1450 if (op_prio (op0) < op_prio (node))
1451 pp_left_paren (buffer);
1452 dump_generic_node (buffer, op0, spc, flags, false);
1453 if (op_prio (op0) < op_prio (node))
1454 pp_right_paren (buffer);
1455 pp_string (buffer, str);
1456 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1457 op0 = component_ref_field_offset (node);
1458 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1460 pp_string (buffer, "{off: ");
1461 dump_generic_node (buffer, op0, spc, flags, false);
1462 pp_right_brace (buffer);
1464 break;
1466 case BIT_FIELD_REF:
1467 pp_string (buffer, "BIT_FIELD_REF <");
1468 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1469 pp_string (buffer, ", ");
1470 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1471 pp_string (buffer, ", ");
1472 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1473 pp_greater (buffer);
1474 break;
1476 case ARRAY_REF:
1477 case ARRAY_RANGE_REF:
1478 op0 = TREE_OPERAND (node, 0);
1479 if (op_prio (op0) < op_prio (node))
1480 pp_left_paren (buffer);
1481 dump_generic_node (buffer, op0, spc, flags, false);
1482 if (op_prio (op0) < op_prio (node))
1483 pp_right_paren (buffer);
1484 pp_left_bracket (buffer);
1485 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1486 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1487 pp_string (buffer, " ...");
1488 pp_right_bracket (buffer);
1490 op0 = array_ref_low_bound (node);
1491 op1 = array_ref_element_size (node);
1493 if (!integer_zerop (op0)
1494 || TREE_OPERAND (node, 2)
1495 || TREE_OPERAND (node, 3))
1497 pp_string (buffer, "{lb: ");
1498 dump_generic_node (buffer, op0, spc, flags, false);
1499 pp_string (buffer, " sz: ");
1500 dump_generic_node (buffer, op1, spc, flags, false);
1501 pp_right_brace (buffer);
1503 break;
1505 case CONSTRUCTOR:
1507 unsigned HOST_WIDE_INT ix;
1508 tree field, val;
1509 bool is_struct_init = false;
1510 bool is_array_init = false;
1511 widest_int curidx;
1512 pp_left_brace (buffer);
1513 if (TREE_CLOBBER_P (node))
1514 pp_string (buffer, "CLOBBER");
1515 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1516 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1517 is_struct_init = true;
1518 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1519 && TYPE_DOMAIN (TREE_TYPE (node))
1520 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1521 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1522 == INTEGER_CST)
1524 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1525 is_array_init = true;
1526 curidx = wi::to_widest (minv);
1528 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1530 if (field)
1532 if (is_struct_init)
1534 pp_dot (buffer);
1535 dump_generic_node (buffer, field, spc, flags, false);
1536 pp_equal (buffer);
1538 else if (is_array_init
1539 && (TREE_CODE (field) != INTEGER_CST
1540 || curidx != wi::to_widest (field)))
1542 pp_left_bracket (buffer);
1543 if (TREE_CODE (field) == RANGE_EXPR)
1545 dump_generic_node (buffer, TREE_OPERAND (field, 0), spc,
1546 flags, false);
1547 pp_string (buffer, " ... ");
1548 dump_generic_node (buffer, TREE_OPERAND (field, 1), spc,
1549 flags, false);
1550 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1551 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1553 else
1554 dump_generic_node (buffer, field, spc, flags, false);
1555 if (TREE_CODE (field) == INTEGER_CST)
1556 curidx = wi::to_widest (field);
1557 pp_string (buffer, "]=");
1560 if (is_array_init)
1561 curidx += 1;
1562 if (val && TREE_CODE (val) == ADDR_EXPR)
1563 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1564 val = TREE_OPERAND (val, 0);
1565 if (val && TREE_CODE (val) == FUNCTION_DECL)
1566 dump_decl_name (buffer, val, flags);
1567 else
1568 dump_generic_node (buffer, val, spc, flags, false);
1569 if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1)
1571 pp_comma (buffer);
1572 pp_space (buffer);
1575 pp_right_brace (buffer);
1577 break;
1579 case COMPOUND_EXPR:
1581 tree *tp;
1582 if (flags & TDF_SLIM)
1584 pp_string (buffer, "<COMPOUND_EXPR>");
1585 break;
1588 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1589 spc, flags, !(flags & TDF_SLIM));
1590 if (flags & TDF_SLIM)
1591 newline_and_indent (buffer, spc);
1592 else
1594 pp_comma (buffer);
1595 pp_space (buffer);
1598 for (tp = &TREE_OPERAND (node, 1);
1599 TREE_CODE (*tp) == COMPOUND_EXPR;
1600 tp = &TREE_OPERAND (*tp, 1))
1602 dump_generic_node (buffer, TREE_OPERAND (*tp, 0),
1603 spc, flags, !(flags & TDF_SLIM));
1604 if (flags & TDF_SLIM)
1605 newline_and_indent (buffer, spc);
1606 else
1608 pp_comma (buffer);
1609 pp_space (buffer);
1613 dump_generic_node (buffer, *tp, spc, flags, !(flags & TDF_SLIM));
1615 break;
1617 case STATEMENT_LIST:
1619 tree_stmt_iterator si;
1620 bool first = true;
1622 if (flags & TDF_SLIM)
1624 pp_string (buffer, "<STATEMENT_LIST>");
1625 break;
1628 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1630 if (!first)
1631 newline_and_indent (buffer, spc);
1632 else
1633 first = false;
1634 dump_generic_node (buffer, tsi_stmt (si), spc, flags, true);
1637 break;
1639 case MODIFY_EXPR:
1640 case INIT_EXPR:
1641 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags,
1642 false);
1643 pp_space (buffer);
1644 pp_equal (buffer);
1645 pp_space (buffer);
1646 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags,
1647 false);
1648 break;
1650 case TARGET_EXPR:
1651 pp_string (buffer, "TARGET_EXPR <");
1652 dump_generic_node (buffer, TARGET_EXPR_SLOT (node), spc, flags, false);
1653 pp_comma (buffer);
1654 pp_space (buffer);
1655 dump_generic_node (buffer, TARGET_EXPR_INITIAL (node), spc, flags, false);
1656 pp_greater (buffer);
1657 break;
1659 case DECL_EXPR:
1660 print_declaration (buffer, DECL_EXPR_DECL (node), spc, flags);
1661 is_stmt = false;
1662 break;
1664 case COND_EXPR:
1665 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1667 pp_string (buffer, "if (");
1668 dump_generic_node (buffer, COND_EXPR_COND (node), spc, flags, false);
1669 pp_right_paren (buffer);
1670 /* The lowered cond_exprs should always be printed in full. */
1671 if (COND_EXPR_THEN (node)
1672 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1673 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1674 && COND_EXPR_ELSE (node)
1675 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1676 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1678 pp_space (buffer);
1679 dump_generic_node (buffer, COND_EXPR_THEN (node),
1680 0, flags, true);
1681 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1683 pp_string (buffer, " else ");
1684 dump_generic_node (buffer, COND_EXPR_ELSE (node),
1685 0, flags, true);
1688 else if (!(flags & TDF_SLIM))
1690 /* Output COND_EXPR_THEN. */
1691 if (COND_EXPR_THEN (node))
1693 newline_and_indent (buffer, spc+2);
1694 pp_left_brace (buffer);
1695 newline_and_indent (buffer, spc+4);
1696 dump_generic_node (buffer, COND_EXPR_THEN (node), spc+4,
1697 flags, true);
1698 newline_and_indent (buffer, spc+2);
1699 pp_right_brace (buffer);
1702 /* Output COND_EXPR_ELSE. */
1703 if (COND_EXPR_ELSE (node)
1704 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1706 newline_and_indent (buffer, spc);
1707 pp_string (buffer, "else");
1708 newline_and_indent (buffer, spc+2);
1709 pp_left_brace (buffer);
1710 newline_and_indent (buffer, spc+4);
1711 dump_generic_node (buffer, COND_EXPR_ELSE (node), spc+4,
1712 flags, true);
1713 newline_and_indent (buffer, spc+2);
1714 pp_right_brace (buffer);
1717 is_expr = false;
1719 else
1721 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1722 pp_space (buffer);
1723 pp_question (buffer);
1724 pp_space (buffer);
1725 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1726 pp_space (buffer);
1727 pp_colon (buffer);
1728 pp_space (buffer);
1729 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1731 break;
1733 case BIND_EXPR:
1734 pp_left_brace (buffer);
1735 if (!(flags & TDF_SLIM))
1737 if (BIND_EXPR_VARS (node))
1739 pp_newline (buffer);
1741 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
1743 print_declaration (buffer, op0, spc+2, flags);
1744 pp_newline (buffer);
1748 newline_and_indent (buffer, spc+2);
1749 dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, flags, true);
1750 newline_and_indent (buffer, spc);
1751 pp_right_brace (buffer);
1753 is_expr = false;
1754 break;
1756 case CALL_EXPR:
1757 if (CALL_EXPR_FN (node) != NULL_TREE)
1758 print_call_name (buffer, CALL_EXPR_FN (node), flags);
1759 else
1760 pp_string (buffer, internal_fn_name (CALL_EXPR_IFN (node)));
1762 /* Print parameters. */
1763 pp_space (buffer);
1764 pp_left_paren (buffer);
1766 tree arg;
1767 call_expr_arg_iterator iter;
1768 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1770 dump_generic_node (buffer, arg, spc, flags, false);
1771 if (more_call_expr_args_p (&iter))
1773 pp_comma (buffer);
1774 pp_space (buffer);
1778 if (CALL_EXPR_VA_ARG_PACK (node))
1780 if (call_expr_nargs (node) > 0)
1782 pp_comma (buffer);
1783 pp_space (buffer);
1785 pp_string (buffer, "__builtin_va_arg_pack ()");
1787 pp_right_paren (buffer);
1789 op1 = CALL_EXPR_STATIC_CHAIN (node);
1790 if (op1)
1792 pp_string (buffer, " [static-chain: ");
1793 dump_generic_node (buffer, op1, spc, flags, false);
1794 pp_right_bracket (buffer);
1797 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1798 pp_string (buffer, " [return slot optimization]");
1799 if (CALL_EXPR_TAILCALL (node))
1800 pp_string (buffer, " [tail call]");
1801 break;
1803 case WITH_CLEANUP_EXPR:
1804 NIY;
1805 break;
1807 case CLEANUP_POINT_EXPR:
1808 pp_string (buffer, "<<cleanup_point ");
1809 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1810 pp_string (buffer, ">>");
1811 break;
1813 case PLACEHOLDER_EXPR:
1814 pp_string (buffer, "<PLACEHOLDER_EXPR ");
1815 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1816 pp_greater (buffer);
1817 break;
1819 /* Binary arithmetic and logic expressions. */
1820 case WIDEN_SUM_EXPR:
1821 case WIDEN_MULT_EXPR:
1822 case MULT_EXPR:
1823 case MULT_HIGHPART_EXPR:
1824 case PLUS_EXPR:
1825 case POINTER_PLUS_EXPR:
1826 case MINUS_EXPR:
1827 case TRUNC_DIV_EXPR:
1828 case CEIL_DIV_EXPR:
1829 case FLOOR_DIV_EXPR:
1830 case ROUND_DIV_EXPR:
1831 case TRUNC_MOD_EXPR:
1832 case CEIL_MOD_EXPR:
1833 case FLOOR_MOD_EXPR:
1834 case ROUND_MOD_EXPR:
1835 case RDIV_EXPR:
1836 case EXACT_DIV_EXPR:
1837 case LSHIFT_EXPR:
1838 case RSHIFT_EXPR:
1839 case LROTATE_EXPR:
1840 case RROTATE_EXPR:
1841 case VEC_LSHIFT_EXPR:
1842 case VEC_RSHIFT_EXPR:
1843 case WIDEN_LSHIFT_EXPR:
1844 case BIT_IOR_EXPR:
1845 case BIT_XOR_EXPR:
1846 case BIT_AND_EXPR:
1847 case TRUTH_ANDIF_EXPR:
1848 case TRUTH_ORIF_EXPR:
1849 case TRUTH_AND_EXPR:
1850 case TRUTH_OR_EXPR:
1851 case TRUTH_XOR_EXPR:
1852 case LT_EXPR:
1853 case LE_EXPR:
1854 case GT_EXPR:
1855 case GE_EXPR:
1856 case EQ_EXPR:
1857 case NE_EXPR:
1858 case UNLT_EXPR:
1859 case UNLE_EXPR:
1860 case UNGT_EXPR:
1861 case UNGE_EXPR:
1862 case UNEQ_EXPR:
1863 case LTGT_EXPR:
1864 case ORDERED_EXPR:
1865 case UNORDERED_EXPR:
1867 const char *op = op_symbol (node);
1868 op0 = TREE_OPERAND (node, 0);
1869 op1 = TREE_OPERAND (node, 1);
1871 /* When the operands are expressions with less priority,
1872 keep semantics of the tree representation. */
1873 if (op_prio (op0) <= op_prio (node))
1875 pp_left_paren (buffer);
1876 dump_generic_node (buffer, op0, spc, flags, false);
1877 pp_right_paren (buffer);
1879 else
1880 dump_generic_node (buffer, op0, spc, flags, false);
1882 pp_space (buffer);
1883 pp_string (buffer, op);
1884 pp_space (buffer);
1886 /* When the operands are expressions with less priority,
1887 keep semantics of the tree representation. */
1888 if (op_prio (op1) <= op_prio (node))
1890 pp_left_paren (buffer);
1891 dump_generic_node (buffer, op1, spc, flags, false);
1892 pp_right_paren (buffer);
1894 else
1895 dump_generic_node (buffer, op1, spc, flags, false);
1897 break;
1899 /* Unary arithmetic and logic expressions. */
1900 case NEGATE_EXPR:
1901 case BIT_NOT_EXPR:
1902 case TRUTH_NOT_EXPR:
1903 case ADDR_EXPR:
1904 case PREDECREMENT_EXPR:
1905 case PREINCREMENT_EXPR:
1906 case INDIRECT_REF:
1907 if (TREE_CODE (node) == ADDR_EXPR
1908 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
1909 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
1910 ; /* Do not output '&' for strings and function pointers. */
1911 else
1912 pp_string (buffer, op_symbol (node));
1914 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1916 pp_left_paren (buffer);
1917 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1918 pp_right_paren (buffer);
1920 else
1921 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1922 break;
1924 case POSTDECREMENT_EXPR:
1925 case POSTINCREMENT_EXPR:
1926 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1928 pp_left_paren (buffer);
1929 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1930 pp_right_paren (buffer);
1932 else
1933 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1934 pp_string (buffer, op_symbol (node));
1935 break;
1937 case MIN_EXPR:
1938 pp_string (buffer, "MIN_EXPR <");
1939 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1940 pp_string (buffer, ", ");
1941 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1942 pp_greater (buffer);
1943 break;
1945 case MAX_EXPR:
1946 pp_string (buffer, "MAX_EXPR <");
1947 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1948 pp_string (buffer, ", ");
1949 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1950 pp_greater (buffer);
1951 break;
1953 case ABS_EXPR:
1954 pp_string (buffer, "ABS_EXPR <");
1955 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1956 pp_greater (buffer);
1957 break;
1959 case RANGE_EXPR:
1960 NIY;
1961 break;
1963 case ADDR_SPACE_CONVERT_EXPR:
1964 case FIXED_CONVERT_EXPR:
1965 case FIX_TRUNC_EXPR:
1966 case FLOAT_EXPR:
1967 CASE_CONVERT:
1968 type = TREE_TYPE (node);
1969 op0 = TREE_OPERAND (node, 0);
1970 if (type != TREE_TYPE (op0))
1972 pp_left_paren (buffer);
1973 dump_generic_node (buffer, type, spc, flags, false);
1974 pp_string (buffer, ") ");
1976 if (op_prio (op0) < op_prio (node))
1977 pp_left_paren (buffer);
1978 dump_generic_node (buffer, op0, spc, flags, false);
1979 if (op_prio (op0) < op_prio (node))
1980 pp_right_paren (buffer);
1981 break;
1983 case VIEW_CONVERT_EXPR:
1984 pp_string (buffer, "VIEW_CONVERT_EXPR<");
1985 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1986 pp_string (buffer, ">(");
1987 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1988 pp_right_paren (buffer);
1989 break;
1991 case PAREN_EXPR:
1992 pp_string (buffer, "((");
1993 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1994 pp_string (buffer, "))");
1995 break;
1997 case NON_LVALUE_EXPR:
1998 pp_string (buffer, "NON_LVALUE_EXPR <");
1999 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2000 pp_greater (buffer);
2001 break;
2003 case SAVE_EXPR:
2004 pp_string (buffer, "SAVE_EXPR <");
2005 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2006 pp_greater (buffer);
2007 break;
2009 case COMPLEX_EXPR:
2010 pp_string (buffer, "COMPLEX_EXPR <");
2011 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2012 pp_string (buffer, ", ");
2013 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2014 pp_greater (buffer);
2015 break;
2017 case CONJ_EXPR:
2018 pp_string (buffer, "CONJ_EXPR <");
2019 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2020 pp_greater (buffer);
2021 break;
2023 case REALPART_EXPR:
2024 pp_string (buffer, "REALPART_EXPR <");
2025 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2026 pp_greater (buffer);
2027 break;
2029 case IMAGPART_EXPR:
2030 pp_string (buffer, "IMAGPART_EXPR <");
2031 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2032 pp_greater (buffer);
2033 break;
2035 case VA_ARG_EXPR:
2036 pp_string (buffer, "VA_ARG_EXPR <");
2037 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2038 pp_greater (buffer);
2039 break;
2041 case TRY_FINALLY_EXPR:
2042 case TRY_CATCH_EXPR:
2043 pp_string (buffer, "try");
2044 newline_and_indent (buffer, spc+2);
2045 pp_left_brace (buffer);
2046 newline_and_indent (buffer, spc+4);
2047 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc+4, flags, true);
2048 newline_and_indent (buffer, spc+2);
2049 pp_right_brace (buffer);
2050 newline_and_indent (buffer, spc);
2051 pp_string (buffer,
2052 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2053 newline_and_indent (buffer, spc+2);
2054 pp_left_brace (buffer);
2055 newline_and_indent (buffer, spc+4);
2056 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4, flags, true);
2057 newline_and_indent (buffer, spc+2);
2058 pp_right_brace (buffer);
2059 is_expr = false;
2060 break;
2062 case CATCH_EXPR:
2063 pp_string (buffer, "catch (");
2064 dump_generic_node (buffer, CATCH_TYPES (node), spc+2, flags, false);
2065 pp_right_paren (buffer);
2066 newline_and_indent (buffer, spc+2);
2067 pp_left_brace (buffer);
2068 newline_and_indent (buffer, spc+4);
2069 dump_generic_node (buffer, CATCH_BODY (node), spc+4, flags, true);
2070 newline_and_indent (buffer, spc+2);
2071 pp_right_brace (buffer);
2072 is_expr = false;
2073 break;
2075 case EH_FILTER_EXPR:
2076 pp_string (buffer, "<<<eh_filter (");
2077 dump_generic_node (buffer, EH_FILTER_TYPES (node), spc+2, flags, false);
2078 pp_string (buffer, ")>>>");
2079 newline_and_indent (buffer, spc+2);
2080 pp_left_brace (buffer);
2081 newline_and_indent (buffer, spc+4);
2082 dump_generic_node (buffer, EH_FILTER_FAILURE (node), spc+4, flags, true);
2083 newline_and_indent (buffer, spc+2);
2084 pp_right_brace (buffer);
2085 is_expr = false;
2086 break;
2088 case LABEL_EXPR:
2089 op0 = TREE_OPERAND (node, 0);
2090 /* If this is for break or continue, don't bother printing it. */
2091 if (DECL_NAME (op0))
2093 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2094 if (strcmp (name, "break") == 0
2095 || strcmp (name, "continue") == 0)
2096 break;
2098 dump_generic_node (buffer, op0, spc, flags, false);
2099 pp_colon (buffer);
2100 if (DECL_NONLOCAL (op0))
2101 pp_string (buffer, " [non-local]");
2102 break;
2104 case LOOP_EXPR:
2105 pp_string (buffer, "while (1)");
2106 if (!(flags & TDF_SLIM))
2108 newline_and_indent (buffer, spc+2);
2109 pp_left_brace (buffer);
2110 newline_and_indent (buffer, spc+4);
2111 dump_generic_node (buffer, LOOP_EXPR_BODY (node), spc+4, flags, true);
2112 newline_and_indent (buffer, spc+2);
2113 pp_right_brace (buffer);
2115 is_expr = false;
2116 break;
2118 case PREDICT_EXPR:
2119 pp_string (buffer, "// predicted ");
2120 if (PREDICT_EXPR_OUTCOME (node))
2121 pp_string (buffer, "likely by ");
2122 else
2123 pp_string (buffer, "unlikely by ");
2124 pp_string (buffer, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2125 pp_string (buffer, " predictor.");
2126 break;
2128 case ANNOTATE_EXPR:
2129 pp_string (buffer, "ANNOTATE_EXPR <");
2130 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2131 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2133 case annot_expr_ivdep_kind:
2134 pp_string (buffer, ", ivdep");
2135 break;
2136 case annot_expr_no_vector_kind:
2137 pp_string (buffer, ", no-vector");
2138 break;
2139 case annot_expr_vector_kind:
2140 pp_string (buffer, ", vector");
2141 break;
2142 default:
2143 gcc_unreachable ();
2145 pp_greater (buffer);
2146 break;
2148 case RETURN_EXPR:
2149 pp_string (buffer, "return");
2150 op0 = TREE_OPERAND (node, 0);
2151 if (op0)
2153 pp_space (buffer);
2154 if (TREE_CODE (op0) == MODIFY_EXPR)
2155 dump_generic_node (buffer, TREE_OPERAND (op0, 1),
2156 spc, flags, false);
2157 else
2158 dump_generic_node (buffer, op0, spc, flags, false);
2160 break;
2162 case EXIT_EXPR:
2163 pp_string (buffer, "if (");
2164 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2165 pp_string (buffer, ") break");
2166 break;
2168 case SWITCH_EXPR:
2169 pp_string (buffer, "switch (");
2170 dump_generic_node (buffer, SWITCH_COND (node), spc, flags, false);
2171 pp_right_paren (buffer);
2172 if (!(flags & TDF_SLIM))
2174 newline_and_indent (buffer, spc+2);
2175 pp_left_brace (buffer);
2176 if (SWITCH_BODY (node))
2178 newline_and_indent (buffer, spc+4);
2179 dump_generic_node (buffer, SWITCH_BODY (node), spc+4, flags,
2180 true);
2182 else
2184 tree vec = SWITCH_LABELS (node);
2185 size_t i, n = TREE_VEC_LENGTH (vec);
2186 for (i = 0; i < n; ++i)
2188 tree elt = TREE_VEC_ELT (vec, i);
2189 newline_and_indent (buffer, spc+4);
2190 if (elt)
2192 dump_generic_node (buffer, elt, spc+4, flags, false);
2193 pp_string (buffer, " goto ");
2194 dump_generic_node (buffer, CASE_LABEL (elt), spc+4,
2195 flags, true);
2196 pp_semicolon (buffer);
2198 else
2199 pp_string (buffer, "case ???: goto ???;");
2202 newline_and_indent (buffer, spc+2);
2203 pp_right_brace (buffer);
2205 is_expr = false;
2206 break;
2208 case GOTO_EXPR:
2209 op0 = GOTO_DESTINATION (node);
2210 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2212 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2213 if (strcmp (name, "break") == 0
2214 || strcmp (name, "continue") == 0)
2216 pp_string (buffer, name);
2217 break;
2220 pp_string (buffer, "goto ");
2221 dump_generic_node (buffer, op0, spc, flags, false);
2222 break;
2224 case ASM_EXPR:
2225 pp_string (buffer, "__asm__");
2226 if (ASM_VOLATILE_P (node))
2227 pp_string (buffer, " __volatile__");
2228 pp_left_paren (buffer);
2229 dump_generic_node (buffer, ASM_STRING (node), spc, flags, false);
2230 pp_colon (buffer);
2231 dump_generic_node (buffer, ASM_OUTPUTS (node), spc, flags, false);
2232 pp_colon (buffer);
2233 dump_generic_node (buffer, ASM_INPUTS (node), spc, flags, false);
2234 if (ASM_CLOBBERS (node))
2236 pp_colon (buffer);
2237 dump_generic_node (buffer, ASM_CLOBBERS (node), spc, flags, false);
2239 pp_right_paren (buffer);
2240 break;
2242 case CASE_LABEL_EXPR:
2243 if (CASE_LOW (node) && CASE_HIGH (node))
2245 pp_string (buffer, "case ");
2246 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2247 pp_string (buffer, " ... ");
2248 dump_generic_node (buffer, CASE_HIGH (node), spc, flags, false);
2250 else if (CASE_LOW (node))
2252 pp_string (buffer, "case ");
2253 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2255 else
2256 pp_string (buffer, "default");
2257 pp_colon (buffer);
2258 break;
2260 case OBJ_TYPE_REF:
2261 pp_string (buffer, "OBJ_TYPE_REF(");
2262 dump_generic_node (buffer, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2263 pp_semicolon (buffer);
2264 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2266 pp_string (buffer, "(");
2267 dump_generic_node (buffer, obj_type_ref_class (node), spc, flags, false);
2268 pp_string (buffer, ")");
2270 dump_generic_node (buffer, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2271 pp_arrow (buffer);
2272 dump_generic_node (buffer, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2273 pp_right_paren (buffer);
2274 break;
2276 case SSA_NAME:
2277 if (SSA_NAME_IDENTIFIER (node))
2278 dump_generic_node (buffer, SSA_NAME_IDENTIFIER (node),
2279 spc, flags, false);
2280 pp_underscore (buffer);
2281 pp_decimal_int (buffer, SSA_NAME_VERSION (node));
2282 if (SSA_NAME_IS_DEFAULT_DEF (node))
2283 pp_string (buffer, "(D)");
2284 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2285 pp_string (buffer, "(ab)");
2286 break;
2288 case WITH_SIZE_EXPR:
2289 pp_string (buffer, "WITH_SIZE_EXPR <");
2290 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2291 pp_string (buffer, ", ");
2292 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2293 pp_greater (buffer);
2294 break;
2296 case ASSERT_EXPR:
2297 pp_string (buffer, "ASSERT_EXPR <");
2298 dump_generic_node (buffer, ASSERT_EXPR_VAR (node), spc, flags, false);
2299 pp_string (buffer, ", ");
2300 dump_generic_node (buffer, ASSERT_EXPR_COND (node), spc, flags, false);
2301 pp_greater (buffer);
2302 break;
2304 case SCEV_KNOWN:
2305 pp_string (buffer, "scev_known");
2306 break;
2308 case SCEV_NOT_KNOWN:
2309 pp_string (buffer, "scev_not_known");
2310 break;
2312 case POLYNOMIAL_CHREC:
2313 pp_left_brace (buffer);
2314 dump_generic_node (buffer, CHREC_LEFT (node), spc, flags, false);
2315 pp_string (buffer, ", +, ");
2316 dump_generic_node (buffer, CHREC_RIGHT (node), spc, flags, false);
2317 pp_string (buffer, "}_");
2318 dump_generic_node (buffer, CHREC_VAR (node), spc, flags, false);
2319 is_stmt = false;
2320 break;
2322 case REALIGN_LOAD_EXPR:
2323 pp_string (buffer, "REALIGN_LOAD <");
2324 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2325 pp_string (buffer, ", ");
2326 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2327 pp_string (buffer, ", ");
2328 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2329 pp_greater (buffer);
2330 break;
2332 case VEC_COND_EXPR:
2333 pp_string (buffer, " VEC_COND_EXPR < ");
2334 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2335 pp_string (buffer, " , ");
2336 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2337 pp_string (buffer, " , ");
2338 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2339 pp_string (buffer, " > ");
2340 break;
2342 case VEC_PERM_EXPR:
2343 pp_string (buffer, " VEC_PERM_EXPR < ");
2344 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2345 pp_string (buffer, " , ");
2346 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2347 pp_string (buffer, " , ");
2348 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2349 pp_string (buffer, " > ");
2350 break;
2352 case DOT_PROD_EXPR:
2353 pp_string (buffer, " DOT_PROD_EXPR < ");
2354 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2355 pp_string (buffer, ", ");
2356 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2357 pp_string (buffer, ", ");
2358 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2359 pp_string (buffer, " > ");
2360 break;
2362 case WIDEN_MULT_PLUS_EXPR:
2363 pp_string (buffer, " WIDEN_MULT_PLUS_EXPR < ");
2364 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2365 pp_string (buffer, ", ");
2366 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2367 pp_string (buffer, ", ");
2368 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2369 pp_string (buffer, " > ");
2370 break;
2372 case WIDEN_MULT_MINUS_EXPR:
2373 pp_string (buffer, " WIDEN_MULT_MINUS_EXPR < ");
2374 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2375 pp_string (buffer, ", ");
2376 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2377 pp_string (buffer, ", ");
2378 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2379 pp_string (buffer, " > ");
2380 break;
2382 case FMA_EXPR:
2383 pp_string (buffer, " FMA_EXPR < ");
2384 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2385 pp_string (buffer, ", ");
2386 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2387 pp_string (buffer, ", ");
2388 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2389 pp_string (buffer, " > ");
2390 break;
2392 case OMP_PARALLEL:
2393 pp_string (buffer, "#pragma omp parallel");
2394 dump_omp_clauses (buffer, OMP_PARALLEL_CLAUSES (node), spc, flags);
2396 dump_omp_body:
2397 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2399 newline_and_indent (buffer, spc + 2);
2400 pp_left_brace (buffer);
2401 newline_and_indent (buffer, spc + 4);
2402 dump_generic_node (buffer, OMP_BODY (node), spc + 4, flags, false);
2403 newline_and_indent (buffer, spc + 2);
2404 pp_right_brace (buffer);
2406 is_expr = false;
2407 break;
2409 case OMP_TASK:
2410 pp_string (buffer, "#pragma omp task");
2411 dump_omp_clauses (buffer, OMP_TASK_CLAUSES (node), spc, flags);
2412 goto dump_omp_body;
2414 case OMP_FOR:
2415 pp_string (buffer, "#pragma omp for");
2416 goto dump_omp_loop;
2418 case OMP_SIMD:
2419 pp_string (buffer, "#pragma omp simd");
2420 goto dump_omp_loop;
2422 case CILK_SIMD:
2423 pp_string (buffer, "#pragma simd");
2424 goto dump_omp_loop;
2426 case OMP_DISTRIBUTE:
2427 pp_string (buffer, "#pragma omp distribute");
2428 goto dump_omp_loop;
2430 case OMP_TEAMS:
2431 pp_string (buffer, "#pragma omp teams");
2432 dump_omp_clauses (buffer, OMP_TEAMS_CLAUSES (node), spc, flags);
2433 goto dump_omp_body;
2435 case OMP_TARGET_DATA:
2436 pp_string (buffer, "#pragma omp target data");
2437 dump_omp_clauses (buffer, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2438 goto dump_omp_body;
2440 case OMP_TARGET:
2441 pp_string (buffer, "#pragma omp target");
2442 dump_omp_clauses (buffer, OMP_TARGET_CLAUSES (node), spc, flags);
2443 goto dump_omp_body;
2445 case OMP_TARGET_UPDATE:
2446 pp_string (buffer, "#pragma omp target update");
2447 dump_omp_clauses (buffer, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2448 is_expr = false;
2449 break;
2451 dump_omp_loop:
2452 dump_omp_clauses (buffer, OMP_FOR_CLAUSES (node), spc, flags);
2454 if (!(flags & TDF_SLIM))
2456 int i;
2458 if (OMP_FOR_PRE_BODY (node))
2460 newline_and_indent (buffer, spc + 2);
2461 pp_left_brace (buffer);
2462 spc += 4;
2463 newline_and_indent (buffer, spc);
2464 dump_generic_node (buffer, OMP_FOR_PRE_BODY (node),
2465 spc, flags, false);
2467 if (OMP_FOR_INIT (node))
2469 spc -= 2;
2470 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2472 spc += 2;
2473 newline_and_indent (buffer, spc);
2474 pp_string (buffer, "for (");
2475 dump_generic_node (buffer,
2476 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2477 spc, flags, false);
2478 pp_string (buffer, "; ");
2479 dump_generic_node (buffer,
2480 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2481 spc, flags, false);
2482 pp_string (buffer, "; ");
2483 dump_generic_node (buffer,
2484 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2485 spc, flags, false);
2486 pp_right_paren (buffer);
2489 if (OMP_FOR_BODY (node))
2491 newline_and_indent (buffer, spc + 2);
2492 pp_left_brace (buffer);
2493 newline_and_indent (buffer, spc + 4);
2494 dump_generic_node (buffer, OMP_FOR_BODY (node), spc + 4, flags,
2495 false);
2496 newline_and_indent (buffer, spc + 2);
2497 pp_right_brace (buffer);
2499 if (OMP_FOR_INIT (node))
2500 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
2501 if (OMP_FOR_PRE_BODY (node))
2503 spc -= 4;
2504 newline_and_indent (buffer, spc + 2);
2505 pp_right_brace (buffer);
2508 is_expr = false;
2509 break;
2511 case OMP_SECTIONS:
2512 pp_string (buffer, "#pragma omp sections");
2513 dump_omp_clauses (buffer, OMP_SECTIONS_CLAUSES (node), spc, flags);
2514 goto dump_omp_body;
2516 case OMP_SECTION:
2517 pp_string (buffer, "#pragma omp section");
2518 goto dump_omp_body;
2520 case OMP_MASTER:
2521 pp_string (buffer, "#pragma omp master");
2522 goto dump_omp_body;
2524 case OMP_TASKGROUP:
2525 pp_string (buffer, "#pragma omp taskgroup");
2526 goto dump_omp_body;
2528 case OMP_ORDERED:
2529 pp_string (buffer, "#pragma omp ordered");
2530 goto dump_omp_body;
2532 case OMP_CRITICAL:
2533 pp_string (buffer, "#pragma omp critical");
2534 if (OMP_CRITICAL_NAME (node))
2536 pp_space (buffer);
2537 pp_left_paren (buffer);
2538 dump_generic_node (buffer, OMP_CRITICAL_NAME (node), spc,
2539 flags, false);
2540 pp_right_paren (buffer);
2542 goto dump_omp_body;
2544 case OMP_ATOMIC:
2545 pp_string (buffer, "#pragma omp atomic");
2546 if (OMP_ATOMIC_SEQ_CST (node))
2547 pp_string (buffer, " seq_cst");
2548 newline_and_indent (buffer, spc + 2);
2549 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2550 pp_space (buffer);
2551 pp_equal (buffer);
2552 pp_space (buffer);
2553 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2554 break;
2556 case OMP_ATOMIC_READ:
2557 pp_string (buffer, "#pragma omp atomic read");
2558 if (OMP_ATOMIC_SEQ_CST (node))
2559 pp_string (buffer, " seq_cst");
2560 newline_and_indent (buffer, spc + 2);
2561 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2562 pp_space (buffer);
2563 break;
2565 case OMP_ATOMIC_CAPTURE_OLD:
2566 case OMP_ATOMIC_CAPTURE_NEW:
2567 pp_string (buffer, "#pragma omp atomic capture");
2568 if (OMP_ATOMIC_SEQ_CST (node))
2569 pp_string (buffer, " seq_cst");
2570 newline_and_indent (buffer, spc + 2);
2571 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2572 pp_space (buffer);
2573 pp_equal (buffer);
2574 pp_space (buffer);
2575 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2576 break;
2578 case OMP_SINGLE:
2579 pp_string (buffer, "#pragma omp single");
2580 dump_omp_clauses (buffer, OMP_SINGLE_CLAUSES (node), spc, flags);
2581 goto dump_omp_body;
2583 case OMP_CLAUSE:
2584 dump_omp_clause (buffer, node, spc, flags);
2585 is_expr = false;
2586 break;
2588 case TRANSACTION_EXPR:
2589 if (TRANSACTION_EXPR_OUTER (node))
2590 pp_string (buffer, "__transaction_atomic [[outer]]");
2591 else if (TRANSACTION_EXPR_RELAXED (node))
2592 pp_string (buffer, "__transaction_relaxed");
2593 else
2594 pp_string (buffer, "__transaction_atomic");
2595 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
2597 newline_and_indent (buffer, spc);
2598 pp_left_brace (buffer);
2599 newline_and_indent (buffer, spc + 2);
2600 dump_generic_node (buffer, TRANSACTION_EXPR_BODY (node),
2601 spc + 2, flags, false);
2602 newline_and_indent (buffer, spc);
2603 pp_right_brace (buffer);
2605 is_expr = false;
2606 break;
2608 case REDUC_MAX_EXPR:
2609 pp_string (buffer, " REDUC_MAX_EXPR < ");
2610 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2611 pp_string (buffer, " > ");
2612 break;
2614 case REDUC_MIN_EXPR:
2615 pp_string (buffer, " REDUC_MIN_EXPR < ");
2616 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2617 pp_string (buffer, " > ");
2618 break;
2620 case REDUC_PLUS_EXPR:
2621 pp_string (buffer, " REDUC_PLUS_EXPR < ");
2622 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2623 pp_string (buffer, " > ");
2624 break;
2626 case VEC_WIDEN_MULT_HI_EXPR:
2627 case VEC_WIDEN_MULT_LO_EXPR:
2628 case VEC_WIDEN_MULT_EVEN_EXPR:
2629 case VEC_WIDEN_MULT_ODD_EXPR:
2630 case VEC_WIDEN_LSHIFT_HI_EXPR:
2631 case VEC_WIDEN_LSHIFT_LO_EXPR:
2632 pp_space (buffer);
2633 for (str = get_tree_code_name (code); *str; str++)
2634 pp_character (buffer, TOUPPER (*str));
2635 pp_string (buffer, " < ");
2636 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2637 pp_string (buffer, ", ");
2638 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2639 pp_string (buffer, " > ");
2640 break;
2642 case VEC_UNPACK_HI_EXPR:
2643 pp_string (buffer, " VEC_UNPACK_HI_EXPR < ");
2644 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2645 pp_string (buffer, " > ");
2646 break;
2648 case VEC_UNPACK_LO_EXPR:
2649 pp_string (buffer, " VEC_UNPACK_LO_EXPR < ");
2650 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2651 pp_string (buffer, " > ");
2652 break;
2654 case VEC_UNPACK_FLOAT_HI_EXPR:
2655 pp_string (buffer, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2656 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2657 pp_string (buffer, " > ");
2658 break;
2660 case VEC_UNPACK_FLOAT_LO_EXPR:
2661 pp_string (buffer, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2662 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2663 pp_string (buffer, " > ");
2664 break;
2666 case VEC_PACK_TRUNC_EXPR:
2667 pp_string (buffer, " VEC_PACK_TRUNC_EXPR < ");
2668 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2669 pp_string (buffer, ", ");
2670 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2671 pp_string (buffer, " > ");
2672 break;
2674 case VEC_PACK_SAT_EXPR:
2675 pp_string (buffer, " VEC_PACK_SAT_EXPR < ");
2676 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2677 pp_string (buffer, ", ");
2678 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2679 pp_string (buffer, " > ");
2680 break;
2682 case VEC_PACK_FIX_TRUNC_EXPR:
2683 pp_string (buffer, " VEC_PACK_FIX_TRUNC_EXPR < ");
2684 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2685 pp_string (buffer, ", ");
2686 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2687 pp_string (buffer, " > ");
2688 break;
2690 case BLOCK:
2691 dump_block_node (buffer, node, spc, flags);
2692 break;
2694 case CILK_SPAWN_STMT:
2695 pp_string (buffer, "_Cilk_spawn ");
2696 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2697 break;
2699 case CILK_SYNC_STMT:
2700 pp_string (buffer, "_Cilk_sync");
2701 break;
2703 default:
2704 NIY;
2707 if (is_stmt && is_expr)
2708 pp_semicolon (buffer);
2710 return spc;
2713 /* Print the declaration of a variable. */
2715 void
2716 print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
2718 INDENT (spc);
2720 if (TREE_CODE(t) == NAMELIST_DECL)
2722 pp_string(buffer, "namelist ");
2723 dump_decl_name (buffer, t, flags);
2724 pp_semicolon (buffer);
2725 return;
2728 if (TREE_CODE (t) == TYPE_DECL)
2729 pp_string (buffer, "typedef ");
2731 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
2732 pp_string (buffer, "register ");
2734 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2735 pp_string (buffer, "extern ");
2736 else if (TREE_STATIC (t))
2737 pp_string (buffer, "static ");
2739 /* Print the type and name. */
2740 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2742 tree tmp;
2744 /* Print array's type. */
2745 tmp = TREE_TYPE (t);
2746 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2747 tmp = TREE_TYPE (tmp);
2748 dump_generic_node (buffer, TREE_TYPE (tmp), spc, flags, false);
2750 /* Print variable's name. */
2751 pp_space (buffer);
2752 dump_generic_node (buffer, t, spc, flags, false);
2754 /* Print the dimensions. */
2755 tmp = TREE_TYPE (t);
2756 while (TREE_CODE (tmp) == ARRAY_TYPE)
2758 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
2759 tmp = TREE_TYPE (tmp);
2762 else if (TREE_CODE (t) == FUNCTION_DECL)
2764 dump_generic_node (buffer, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
2765 pp_space (buffer);
2766 dump_decl_name (buffer, t, flags);
2767 dump_function_declaration (buffer, TREE_TYPE (t), spc, flags);
2769 else
2771 /* Print type declaration. */
2772 dump_generic_node (buffer, TREE_TYPE (t), spc, flags, false);
2774 /* Print variable's name. */
2775 pp_space (buffer);
2776 dump_generic_node (buffer, t, spc, flags, false);
2779 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
2781 pp_string (buffer, " __asm__ ");
2782 pp_left_paren (buffer);
2783 dump_generic_node (buffer, DECL_ASSEMBLER_NAME (t), spc, flags, false);
2784 pp_right_paren (buffer);
2787 /* The initial value of a function serves to determine whether the function
2788 is declared or defined. So the following does not apply to function
2789 nodes. */
2790 if (TREE_CODE (t) != FUNCTION_DECL)
2792 /* Print the initial value. */
2793 if (DECL_INITIAL (t))
2795 pp_space (buffer);
2796 pp_equal (buffer);
2797 pp_space (buffer);
2798 dump_generic_node (buffer, DECL_INITIAL (t), spc, flags, false);
2802 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
2804 pp_string (buffer, " [value-expr: ");
2805 dump_generic_node (buffer, DECL_VALUE_EXPR (t), spc, flags, false);
2806 pp_right_bracket (buffer);
2809 pp_semicolon (buffer);
2813 /* Prints a structure: name, fields, and methods.
2814 FIXME: Still incomplete. */
2816 static void
2817 print_struct_decl (pretty_printer *buffer, const_tree node, int spc, int flags)
2819 /* Print the name of the structure. */
2820 if (TYPE_NAME (node))
2822 INDENT (spc);
2823 if (TREE_CODE (node) == RECORD_TYPE)
2824 pp_string (buffer, "struct ");
2825 else if ((TREE_CODE (node) == UNION_TYPE
2826 || TREE_CODE (node) == QUAL_UNION_TYPE))
2827 pp_string (buffer, "union ");
2829 dump_generic_node (buffer, TYPE_NAME (node), spc, 0, false);
2832 /* Print the contents of the structure. */
2833 pp_newline (buffer);
2834 INDENT (spc);
2835 pp_left_brace (buffer);
2836 pp_newline (buffer);
2838 /* Print the fields of the structure. */
2840 tree tmp;
2841 tmp = TYPE_FIELDS (node);
2842 while (tmp)
2844 /* Avoid to print recursively the structure. */
2845 /* FIXME : Not implemented correctly...,
2846 what about the case when we have a cycle in the contain graph? ...
2847 Maybe this could be solved by looking at the scope in which the
2848 structure was declared. */
2849 if (TREE_TYPE (tmp) != node
2850 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
2851 || TREE_TYPE (TREE_TYPE (tmp)) != node))
2853 print_declaration (buffer, tmp, spc+2, flags);
2854 pp_newline (buffer);
2856 tmp = DECL_CHAIN (tmp);
2859 INDENT (spc);
2860 pp_right_brace (buffer);
2863 /* Return the priority of the operator CODE.
2865 From lowest to highest precedence with either left-to-right (L-R)
2866 or right-to-left (R-L) associativity]:
2868 1 [L-R] ,
2869 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2870 3 [R-L] ?:
2871 4 [L-R] ||
2872 5 [L-R] &&
2873 6 [L-R] |
2874 7 [L-R] ^
2875 8 [L-R] &
2876 9 [L-R] == !=
2877 10 [L-R] < <= > >=
2878 11 [L-R] << >>
2879 12 [L-R] + -
2880 13 [L-R] * / %
2881 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2882 15 [L-R] fn() [] -> .
2884 unary +, - and * have higher precedence than the corresponding binary
2885 operators. */
2888 op_code_prio (enum tree_code code)
2890 switch (code)
2892 case TREE_LIST:
2893 case COMPOUND_EXPR:
2894 case BIND_EXPR:
2895 return 1;
2897 case MODIFY_EXPR:
2898 case INIT_EXPR:
2899 return 2;
2901 case COND_EXPR:
2902 return 3;
2904 case TRUTH_OR_EXPR:
2905 case TRUTH_ORIF_EXPR:
2906 return 4;
2908 case TRUTH_AND_EXPR:
2909 case TRUTH_ANDIF_EXPR:
2910 return 5;
2912 case BIT_IOR_EXPR:
2913 return 6;
2915 case BIT_XOR_EXPR:
2916 case TRUTH_XOR_EXPR:
2917 return 7;
2919 case BIT_AND_EXPR:
2920 return 8;
2922 case EQ_EXPR:
2923 case NE_EXPR:
2924 return 9;
2926 case UNLT_EXPR:
2927 case UNLE_EXPR:
2928 case UNGT_EXPR:
2929 case UNGE_EXPR:
2930 case UNEQ_EXPR:
2931 case LTGT_EXPR:
2932 case ORDERED_EXPR:
2933 case UNORDERED_EXPR:
2934 case LT_EXPR:
2935 case LE_EXPR:
2936 case GT_EXPR:
2937 case GE_EXPR:
2938 return 10;
2940 case LSHIFT_EXPR:
2941 case RSHIFT_EXPR:
2942 case LROTATE_EXPR:
2943 case RROTATE_EXPR:
2944 case VEC_WIDEN_LSHIFT_HI_EXPR:
2945 case VEC_WIDEN_LSHIFT_LO_EXPR:
2946 case WIDEN_LSHIFT_EXPR:
2947 return 11;
2949 case WIDEN_SUM_EXPR:
2950 case PLUS_EXPR:
2951 case POINTER_PLUS_EXPR:
2952 case MINUS_EXPR:
2953 return 12;
2955 case VEC_WIDEN_MULT_HI_EXPR:
2956 case VEC_WIDEN_MULT_LO_EXPR:
2957 case WIDEN_MULT_EXPR:
2958 case DOT_PROD_EXPR:
2959 case WIDEN_MULT_PLUS_EXPR:
2960 case WIDEN_MULT_MINUS_EXPR:
2961 case MULT_EXPR:
2962 case MULT_HIGHPART_EXPR:
2963 case TRUNC_DIV_EXPR:
2964 case CEIL_DIV_EXPR:
2965 case FLOOR_DIV_EXPR:
2966 case ROUND_DIV_EXPR:
2967 case RDIV_EXPR:
2968 case EXACT_DIV_EXPR:
2969 case TRUNC_MOD_EXPR:
2970 case CEIL_MOD_EXPR:
2971 case FLOOR_MOD_EXPR:
2972 case ROUND_MOD_EXPR:
2973 case FMA_EXPR:
2974 return 13;
2976 case TRUTH_NOT_EXPR:
2977 case BIT_NOT_EXPR:
2978 case POSTINCREMENT_EXPR:
2979 case POSTDECREMENT_EXPR:
2980 case PREINCREMENT_EXPR:
2981 case PREDECREMENT_EXPR:
2982 case NEGATE_EXPR:
2983 case INDIRECT_REF:
2984 case ADDR_EXPR:
2985 case FLOAT_EXPR:
2986 CASE_CONVERT:
2987 case FIX_TRUNC_EXPR:
2988 case TARGET_EXPR:
2989 return 14;
2991 case CALL_EXPR:
2992 case ARRAY_REF:
2993 case ARRAY_RANGE_REF:
2994 case COMPONENT_REF:
2995 return 15;
2997 /* Special expressions. */
2998 case MIN_EXPR:
2999 case MAX_EXPR:
3000 case ABS_EXPR:
3001 case REALPART_EXPR:
3002 case IMAGPART_EXPR:
3003 case REDUC_MAX_EXPR:
3004 case REDUC_MIN_EXPR:
3005 case REDUC_PLUS_EXPR:
3006 case VEC_LSHIFT_EXPR:
3007 case VEC_RSHIFT_EXPR:
3008 case VEC_UNPACK_HI_EXPR:
3009 case VEC_UNPACK_LO_EXPR:
3010 case VEC_UNPACK_FLOAT_HI_EXPR:
3011 case VEC_UNPACK_FLOAT_LO_EXPR:
3012 case VEC_PACK_TRUNC_EXPR:
3013 case VEC_PACK_SAT_EXPR:
3014 return 16;
3016 default:
3017 /* Return an arbitrarily high precedence to avoid surrounding single
3018 VAR_DECLs in ()s. */
3019 return 9999;
3023 /* Return the priority of the operator OP. */
3026 op_prio (const_tree op)
3028 enum tree_code code;
3030 if (op == NULL)
3031 return 9999;
3033 code = TREE_CODE (op);
3034 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3035 return op_prio (TREE_OPERAND (op, 0));
3037 return op_code_prio (code);
3040 /* Return the symbol associated with operator CODE. */
3042 const char *
3043 op_symbol_code (enum tree_code code)
3045 switch (code)
3047 case MODIFY_EXPR:
3048 return "=";
3050 case TRUTH_OR_EXPR:
3051 case TRUTH_ORIF_EXPR:
3052 return "||";
3054 case TRUTH_AND_EXPR:
3055 case TRUTH_ANDIF_EXPR:
3056 return "&&";
3058 case BIT_IOR_EXPR:
3059 return "|";
3061 case TRUTH_XOR_EXPR:
3062 case BIT_XOR_EXPR:
3063 return "^";
3065 case ADDR_EXPR:
3066 case BIT_AND_EXPR:
3067 return "&";
3069 case ORDERED_EXPR:
3070 return "ord";
3071 case UNORDERED_EXPR:
3072 return "unord";
3074 case EQ_EXPR:
3075 return "==";
3076 case UNEQ_EXPR:
3077 return "u==";
3079 case NE_EXPR:
3080 return "!=";
3082 case LT_EXPR:
3083 return "<";
3084 case UNLT_EXPR:
3085 return "u<";
3087 case LE_EXPR:
3088 return "<=";
3089 case UNLE_EXPR:
3090 return "u<=";
3092 case GT_EXPR:
3093 return ">";
3094 case UNGT_EXPR:
3095 return "u>";
3097 case GE_EXPR:
3098 return ">=";
3099 case UNGE_EXPR:
3100 return "u>=";
3102 case LTGT_EXPR:
3103 return "<>";
3105 case LSHIFT_EXPR:
3106 return "<<";
3108 case RSHIFT_EXPR:
3109 return ">>";
3111 case LROTATE_EXPR:
3112 return "r<<";
3114 case RROTATE_EXPR:
3115 return "r>>";
3117 case VEC_LSHIFT_EXPR:
3118 return "v<<";
3120 case VEC_RSHIFT_EXPR:
3121 return "v>>";
3123 case WIDEN_LSHIFT_EXPR:
3124 return "w<<";
3126 case POINTER_PLUS_EXPR:
3127 return "+";
3129 case PLUS_EXPR:
3130 return "+";
3132 case REDUC_PLUS_EXPR:
3133 return "r+";
3135 case WIDEN_SUM_EXPR:
3136 return "w+";
3138 case WIDEN_MULT_EXPR:
3139 return "w*";
3141 case MULT_HIGHPART_EXPR:
3142 return "h*";
3144 case NEGATE_EXPR:
3145 case MINUS_EXPR:
3146 return "-";
3148 case BIT_NOT_EXPR:
3149 return "~";
3151 case TRUTH_NOT_EXPR:
3152 return "!";
3154 case MULT_EXPR:
3155 case INDIRECT_REF:
3156 return "*";
3158 case TRUNC_DIV_EXPR:
3159 case RDIV_EXPR:
3160 return "/";
3162 case CEIL_DIV_EXPR:
3163 return "/[cl]";
3165 case FLOOR_DIV_EXPR:
3166 return "/[fl]";
3168 case ROUND_DIV_EXPR:
3169 return "/[rd]";
3171 case EXACT_DIV_EXPR:
3172 return "/[ex]";
3174 case TRUNC_MOD_EXPR:
3175 return "%";
3177 case CEIL_MOD_EXPR:
3178 return "%[cl]";
3180 case FLOOR_MOD_EXPR:
3181 return "%[fl]";
3183 case ROUND_MOD_EXPR:
3184 return "%[rd]";
3186 case PREDECREMENT_EXPR:
3187 return " --";
3189 case PREINCREMENT_EXPR:
3190 return " ++";
3192 case POSTDECREMENT_EXPR:
3193 return "-- ";
3195 case POSTINCREMENT_EXPR:
3196 return "++ ";
3198 case MAX_EXPR:
3199 return "max";
3201 case MIN_EXPR:
3202 return "min";
3204 default:
3205 return "<<< ??? >>>";
3209 /* Return the symbol associated with operator OP. */
3211 static const char *
3212 op_symbol (const_tree op)
3214 return op_symbol_code (TREE_CODE (op));
3217 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3218 the gimple_call_fn of a GIMPLE_CALL. */
3220 void
3221 print_call_name (pretty_printer *buffer, tree node, int flags)
3223 tree op0 = node;
3225 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3226 op0 = TREE_OPERAND (op0, 0);
3228 again:
3229 switch (TREE_CODE (op0))
3231 case VAR_DECL:
3232 case PARM_DECL:
3233 case FUNCTION_DECL:
3234 dump_function_name (buffer, op0, flags);
3235 break;
3237 case ADDR_EXPR:
3238 case INDIRECT_REF:
3239 case NOP_EXPR:
3240 op0 = TREE_OPERAND (op0, 0);
3241 goto again;
3243 case COND_EXPR:
3244 pp_left_paren (buffer);
3245 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, flags, false);
3246 pp_string (buffer, ") ? ");
3247 dump_generic_node (buffer, TREE_OPERAND (op0, 1), 0, flags, false);
3248 pp_string (buffer, " : ");
3249 dump_generic_node (buffer, TREE_OPERAND (op0, 2), 0, flags, false);
3250 break;
3252 case ARRAY_REF:
3253 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3254 dump_function_name (buffer, TREE_OPERAND (op0, 0), flags);
3255 else
3256 dump_generic_node (buffer, op0, 0, flags, false);
3257 break;
3259 case MEM_REF:
3260 if (integer_zerop (TREE_OPERAND (op0, 1)))
3262 op0 = TREE_OPERAND (op0, 0);
3263 goto again;
3265 /* Fallthru. */
3266 case COMPONENT_REF:
3267 case SSA_NAME:
3268 case OBJ_TYPE_REF:
3269 dump_generic_node (buffer, op0, 0, flags, false);
3270 break;
3272 default:
3273 NIY;
3277 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3279 static void
3280 pretty_print_string (pretty_printer *buffer, const char *str)
3282 if (str == NULL)
3283 return;
3285 while (*str)
3287 switch (str[0])
3289 case '\b':
3290 pp_string (buffer, "\\b");
3291 break;
3293 case '\f':
3294 pp_string (buffer, "\\f");
3295 break;
3297 case '\n':
3298 pp_string (buffer, "\\n");
3299 break;
3301 case '\r':
3302 pp_string (buffer, "\\r");
3303 break;
3305 case '\t':
3306 pp_string (buffer, "\\t");
3307 break;
3309 case '\v':
3310 pp_string (buffer, "\\v");
3311 break;
3313 case '\\':
3314 pp_string (buffer, "\\\\");
3315 break;
3317 case '\"':
3318 pp_string (buffer, "\\\"");
3319 break;
3321 case '\'':
3322 pp_string (buffer, "\\'");
3323 break;
3325 /* No need to handle \0; the loop terminates on \0. */
3327 case '\1':
3328 pp_string (buffer, "\\1");
3329 break;
3331 case '\2':
3332 pp_string (buffer, "\\2");
3333 break;
3335 case '\3':
3336 pp_string (buffer, "\\3");
3337 break;
3339 case '\4':
3340 pp_string (buffer, "\\4");
3341 break;
3343 case '\5':
3344 pp_string (buffer, "\\5");
3345 break;
3347 case '\6':
3348 pp_string (buffer, "\\6");
3349 break;
3351 case '\7':
3352 pp_string (buffer, "\\7");
3353 break;
3355 default:
3356 pp_character (buffer, str[0]);
3357 break;
3359 str++;
3363 static void
3364 maybe_init_pretty_print (FILE *file)
3366 if (!initialized)
3368 new (&buffer) pretty_printer ();
3369 pp_needs_newline (&buffer) = true;
3370 pp_translate_identifiers (&buffer) = false;
3371 initialized = 1;
3374 buffer.buffer->stream = file;
3377 static void
3378 newline_and_indent (pretty_printer *buffer, int spc)
3380 pp_newline (buffer);
3381 INDENT (spc);
3384 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3385 it can also be used in front ends.
3386 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3389 void
3390 percent_K_format (text_info *text)
3392 tree t = va_arg (*text->args_ptr, tree), block;
3393 gcc_assert (text->locus != NULL);
3394 *text->locus = EXPR_LOCATION (t);
3395 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3396 block = TREE_BLOCK (t);
3397 *pp_ti_abstract_origin (text) = NULL;
3399 if (in_lto_p)
3401 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3402 representing the outermost block of an inlined function.
3403 So walk the BLOCK tree until we hit such a scope. */
3404 while (block
3405 && TREE_CODE (block) == BLOCK)
3407 if (inlined_function_outer_scope_p (block))
3409 *pp_ti_abstract_origin (text) = block;
3410 break;
3412 block = BLOCK_SUPERCONTEXT (block);
3414 return;
3417 while (block
3418 && TREE_CODE (block) == BLOCK
3419 && BLOCK_ABSTRACT_ORIGIN (block))
3421 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3423 while (TREE_CODE (ao) == BLOCK
3424 && BLOCK_ABSTRACT_ORIGIN (ao)
3425 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3426 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3428 if (TREE_CODE (ao) == FUNCTION_DECL)
3430 *pp_ti_abstract_origin (text) = block;
3431 break;
3433 block = BLOCK_SUPERCONTEXT (block);
3437 /* Print the identifier ID to PRETTY-PRINTER. */
3439 void
3440 pp_tree_identifier (pretty_printer *pp, tree id)
3442 if (pp_translate_identifiers (pp))
3444 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3445 pp_append_text (pp, text, text + strlen (text));
3447 else
3448 pp_append_text (pp, IDENTIFIER_POINTER (id),
3449 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3452 /* A helper function that is used to dump function information before the
3453 function dump. */
3455 void
3456 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3458 const char *dname, *aname;
3459 struct cgraph_node *node = cgraph_node::get (fdecl);
3460 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3462 dname = lang_hooks.decl_printable_name (fdecl, 2);
3464 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3465 aname = (IDENTIFIER_POINTER
3466 (DECL_ASSEMBLER_NAME (fdecl)));
3467 else
3468 aname = "<unset-asm-name>";
3470 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3471 dname, aname, fun->funcdef_no);
3472 if (!(flags & TDF_NOUID))
3473 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3474 if (node)
3476 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
3477 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3478 node->frequency == NODE_FREQUENCY_HOT
3479 ? " (hot)"
3480 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3481 ? " (unlikely executed)"
3482 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3483 ? " (executed once)"
3484 : "");
3486 else
3487 fprintf (dump_file, ")\n\n");
3490 /* Dump double_int D to pretty_printer PP. UNS is true
3491 if D is unsigned and false otherwise. */
3492 void
3493 pp_double_int (pretty_printer *pp, double_int d, bool uns)
3495 if (d.fits_shwi ())
3496 pp_wide_integer (pp, d.low);
3497 else if (d.fits_uhwi ())
3498 pp_unsigned_wide_integer (pp, d.low);
3499 else
3501 unsigned HOST_WIDE_INT low = d.low;
3502 HOST_WIDE_INT high = d.high;
3503 if (!uns && d.is_negative ())
3505 pp_minus (pp);
3506 high = ~high + !low;
3507 low = -low;
3509 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3510 systems? */
3511 sprintf (pp_buffer (pp)->digit_buffer,
3512 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3513 (unsigned HOST_WIDE_INT) high, low);
3514 pp_string (pp, pp_buffer (pp)->digit_buffer);