gcc/testsuite
[official-gcc.git] / gcc / tree-pretty-print.c
blobaee03319cf0bb8fa06fb420d111461b036749164
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 "hash-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 hash_set<tree> seen;
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 (seen.add (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");
124 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
125 void
126 print_generic_decl (FILE *file, tree decl, int flags)
128 maybe_init_pretty_print (file);
129 print_declaration (&buffer, decl, 2, flags);
130 pp_write_text_to_stream (&buffer);
133 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
134 to show in the dump. See TDF_* in dumpfile.h. */
136 void
137 print_generic_stmt (FILE *file, tree t, int flags)
139 maybe_init_pretty_print (file);
140 dump_generic_node (&buffer, t, 0, flags, true);
141 pp_newline_and_flush (&buffer);
144 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
145 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
146 INDENT spaces. */
148 void
149 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
151 int i;
153 maybe_init_pretty_print (file);
155 for (i = 0; i < indent; i++)
156 pp_space (&buffer);
157 dump_generic_node (&buffer, t, indent, flags, true);
158 pp_newline_and_flush (&buffer);
161 /* Print a single expression T on file FILE. FLAGS specifies details to show
162 in the dump. See TDF_* in dumpfile.h. */
164 void
165 print_generic_expr (FILE *file, tree t, int flags)
167 maybe_init_pretty_print (file);
168 dump_generic_node (&buffer, t, 0, flags, false);
169 pp_flush (&buffer);
172 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
173 in FLAGS. */
175 static void
176 dump_decl_name (pretty_printer *buffer, tree node, int flags)
178 if (DECL_NAME (node))
180 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
181 pp_tree_identifier (buffer, DECL_ASSEMBLER_NAME (node));
182 else
183 pp_tree_identifier (buffer, DECL_NAME (node));
185 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
187 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
188 pp_printf (buffer, "L.%d", (int) LABEL_DECL_UID (node));
189 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
191 if (flags & TDF_NOUID)
192 pp_string (buffer, "D#xxxx");
193 else
194 pp_printf (buffer, "D#%i", DEBUG_TEMP_UID (node));
196 else
198 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
199 if (flags & TDF_NOUID)
200 pp_printf (buffer, "%c.xxxx", c);
201 else
202 pp_printf (buffer, "%c.%u", c, DECL_UID (node));
205 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
207 if (flags & TDF_NOUID)
208 pp_printf (buffer, "ptD.xxxx");
209 else
210 pp_printf (buffer, "ptD.%u", DECL_PT_UID (node));
214 /* Like the above, but used for pretty printing function calls. */
216 static void
217 dump_function_name (pretty_printer *buffer, tree node, int flags)
219 if (TREE_CODE (node) == NOP_EXPR)
220 node = TREE_OPERAND (node, 0);
221 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
222 pp_string (buffer, lang_hooks.decl_printable_name (node, 1));
223 else
224 dump_decl_name (buffer, node, flags);
227 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
228 FLAGS are as in dump_generic_node. */
230 static void
231 dump_function_declaration (pretty_printer *buffer, tree node,
232 int spc, int flags)
234 bool wrote_arg = false;
235 tree arg;
237 pp_space (buffer);
238 pp_left_paren (buffer);
240 /* Print the argument types. */
241 arg = TYPE_ARG_TYPES (node);
242 while (arg && arg != void_list_node && arg != error_mark_node)
244 if (wrote_arg)
246 pp_comma (buffer);
247 pp_space (buffer);
249 wrote_arg = true;
250 dump_generic_node (buffer, TREE_VALUE (arg), spc, flags, false);
251 arg = TREE_CHAIN (arg);
254 /* Drop the trailing void_type_node if we had any previous argument. */
255 if (arg == void_list_node && !wrote_arg)
256 pp_string (buffer, "void");
257 /* Properly dump vararg function types. */
258 else if (!arg && wrote_arg)
259 pp_string (buffer, ", ...");
260 /* Avoid printing any arg for unprototyped functions. */
262 pp_right_paren (buffer);
265 /* Dump the domain associated with an array. */
267 static void
268 dump_array_domain (pretty_printer *buffer, tree domain, int spc, int flags)
270 pp_left_bracket (buffer);
271 if (domain)
273 tree min = TYPE_MIN_VALUE (domain);
274 tree max = TYPE_MAX_VALUE (domain);
276 if (min && max
277 && integer_zerop (min)
278 && tree_fits_shwi_p (max))
279 pp_wide_integer (buffer, tree_to_shwi (max) + 1);
280 else
282 if (min)
283 dump_generic_node (buffer, min, spc, flags, false);
284 pp_colon (buffer);
285 if (max)
286 dump_generic_node (buffer, max, spc, flags, false);
289 else
290 pp_string (buffer, "<unknown>");
291 pp_right_bracket (buffer);
295 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
296 dump_generic_node. */
298 static void
299 dump_omp_clause (pretty_printer *buffer, tree clause, int spc, int flags)
301 const char *name;
303 switch (OMP_CLAUSE_CODE (clause))
305 case OMP_CLAUSE_PRIVATE:
306 name = "private";
307 goto print_remap;
308 case OMP_CLAUSE_SHARED:
309 name = "shared";
310 goto print_remap;
311 case OMP_CLAUSE_FIRSTPRIVATE:
312 name = "firstprivate";
313 goto print_remap;
314 case OMP_CLAUSE_LASTPRIVATE:
315 name = "lastprivate";
316 goto print_remap;
317 case OMP_CLAUSE_COPYIN:
318 name = "copyin";
319 goto print_remap;
320 case OMP_CLAUSE_COPYPRIVATE:
321 name = "copyprivate";
322 goto print_remap;
323 case OMP_CLAUSE_UNIFORM:
324 name = "uniform";
325 goto print_remap;
326 case OMP_CLAUSE__LOOPTEMP_:
327 name = "_looptemp_";
328 goto print_remap;
329 print_remap:
330 pp_string (buffer, name);
331 pp_left_paren (buffer);
332 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
333 spc, flags, false);
334 pp_right_paren (buffer);
335 break;
337 case OMP_CLAUSE_REDUCTION:
338 pp_string (buffer, "reduction(");
339 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
341 pp_string (buffer,
342 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
343 pp_colon (buffer);
345 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
346 spc, flags, false);
347 pp_right_paren (buffer);
348 break;
350 case OMP_CLAUSE_IF:
351 pp_string (buffer, "if(");
352 dump_generic_node (buffer, OMP_CLAUSE_IF_EXPR (clause),
353 spc, flags, false);
354 pp_right_paren (buffer);
355 break;
357 case OMP_CLAUSE_NUM_THREADS:
358 pp_string (buffer, "num_threads(");
359 dump_generic_node (buffer, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
360 spc, flags, false);
361 pp_right_paren (buffer);
362 break;
364 case OMP_CLAUSE_NOWAIT:
365 pp_string (buffer, "nowait");
366 break;
367 case OMP_CLAUSE_ORDERED:
368 pp_string (buffer, "ordered");
369 break;
371 case OMP_CLAUSE_DEFAULT:
372 pp_string (buffer, "default(");
373 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
375 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
376 break;
377 case OMP_CLAUSE_DEFAULT_SHARED:
378 pp_string (buffer, "shared");
379 break;
380 case OMP_CLAUSE_DEFAULT_NONE:
381 pp_string (buffer, "none");
382 break;
383 case OMP_CLAUSE_DEFAULT_PRIVATE:
384 pp_string (buffer, "private");
385 break;
386 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
387 pp_string (buffer, "firstprivate");
388 break;
389 default:
390 gcc_unreachable ();
392 pp_right_paren (buffer);
393 break;
395 case OMP_CLAUSE_SCHEDULE:
396 pp_string (buffer, "schedule(");
397 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
399 case OMP_CLAUSE_SCHEDULE_STATIC:
400 pp_string (buffer, "static");
401 break;
402 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
403 pp_string (buffer, "dynamic");
404 break;
405 case OMP_CLAUSE_SCHEDULE_GUIDED:
406 pp_string (buffer, "guided");
407 break;
408 case OMP_CLAUSE_SCHEDULE_RUNTIME:
409 pp_string (buffer, "runtime");
410 break;
411 case OMP_CLAUSE_SCHEDULE_AUTO:
412 pp_string (buffer, "auto");
413 break;
414 default:
415 gcc_unreachable ();
417 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
419 pp_comma (buffer);
420 dump_generic_node (buffer, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
421 spc, flags, false);
423 pp_right_paren (buffer);
424 break;
426 case OMP_CLAUSE_UNTIED:
427 pp_string (buffer, "untied");
428 break;
430 case OMP_CLAUSE_COLLAPSE:
431 pp_string (buffer, "collapse(");
432 dump_generic_node (buffer, OMP_CLAUSE_COLLAPSE_EXPR (clause),
433 spc, flags, false);
434 pp_right_paren (buffer);
435 break;
437 case OMP_CLAUSE_FINAL:
438 pp_string (buffer, "final(");
439 dump_generic_node (buffer, OMP_CLAUSE_FINAL_EXPR (clause),
440 spc, flags, false);
441 pp_right_paren (buffer);
442 break;
444 case OMP_CLAUSE_MERGEABLE:
445 pp_string (buffer, "mergeable");
446 break;
448 case OMP_CLAUSE_LINEAR:
449 pp_string (buffer, "linear(");
450 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
451 spc, flags, false);
452 pp_colon (buffer);
453 dump_generic_node (buffer, OMP_CLAUSE_LINEAR_STEP (clause),
454 spc, flags, false);
455 pp_right_paren (buffer);
456 break;
458 case OMP_CLAUSE_ALIGNED:
459 pp_string (buffer, "aligned(");
460 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
461 spc, flags, false);
462 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
464 pp_colon (buffer);
465 dump_generic_node (buffer, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
466 spc, flags, false);
468 pp_right_paren (buffer);
469 break;
471 case OMP_CLAUSE_DEPEND:
472 pp_string (buffer, "depend(");
473 switch (OMP_CLAUSE_DEPEND_KIND (clause))
475 case OMP_CLAUSE_DEPEND_IN:
476 pp_string (buffer, "in");
477 break;
478 case OMP_CLAUSE_DEPEND_OUT:
479 pp_string (buffer, "out");
480 break;
481 case OMP_CLAUSE_DEPEND_INOUT:
482 pp_string (buffer, "inout");
483 break;
484 default:
485 gcc_unreachable ();
487 pp_colon (buffer);
488 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
489 spc, flags, false);
490 pp_right_paren (buffer);
491 break;
493 case OMP_CLAUSE_MAP:
494 pp_string (buffer, "map(");
495 switch (OMP_CLAUSE_MAP_KIND (clause))
497 case OMP_CLAUSE_MAP_ALLOC:
498 case OMP_CLAUSE_MAP_POINTER:
499 pp_string (buffer, "alloc");
500 break;
501 case OMP_CLAUSE_MAP_TO:
502 case OMP_CLAUSE_MAP_TO_PSET:
503 pp_string (buffer, "to");
504 break;
505 case OMP_CLAUSE_MAP_FROM:
506 pp_string (buffer, "from");
507 break;
508 case OMP_CLAUSE_MAP_TOFROM:
509 pp_string (buffer, "tofrom");
510 break;
511 default:
512 gcc_unreachable ();
514 pp_colon (buffer);
515 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
516 spc, flags, false);
517 print_clause_size:
518 if (OMP_CLAUSE_SIZE (clause))
520 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
521 && OMP_CLAUSE_MAP_KIND (clause) == OMP_CLAUSE_MAP_POINTER)
522 pp_string (buffer, " [pointer assign, bias: ");
523 else if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
524 && OMP_CLAUSE_MAP_KIND (clause) == OMP_CLAUSE_MAP_TO_PSET)
525 pp_string (buffer, " [pointer set, len: ");
526 else
527 pp_string (buffer, " [len: ");
528 dump_generic_node (buffer, OMP_CLAUSE_SIZE (clause),
529 spc, flags, false);
530 pp_right_bracket (buffer);
532 pp_right_paren (buffer);
533 break;
535 case OMP_CLAUSE_FROM:
536 pp_string (buffer, "from(");
537 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
538 spc, flags, false);
539 goto print_clause_size;
541 case OMP_CLAUSE_TO:
542 pp_string (buffer, "to(");
543 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
544 spc, flags, false);
545 goto print_clause_size;
547 case OMP_CLAUSE_NUM_TEAMS:
548 pp_string (buffer, "num_teams(");
549 dump_generic_node (buffer, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
550 spc, flags, false);
551 pp_right_paren (buffer);
552 break;
554 case OMP_CLAUSE_THREAD_LIMIT:
555 pp_string (buffer, "thread_limit(");
556 dump_generic_node (buffer, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
557 spc, flags, false);
558 pp_right_paren (buffer);
559 break;
561 case OMP_CLAUSE_DEVICE:
562 pp_string (buffer, "device(");
563 dump_generic_node (buffer, OMP_CLAUSE_DEVICE_ID (clause),
564 spc, flags, false);
565 pp_right_paren (buffer);
566 break;
568 case OMP_CLAUSE_DIST_SCHEDULE:
569 pp_string (buffer, "dist_schedule(static");
570 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
572 pp_comma (buffer);
573 dump_generic_node (buffer,
574 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
575 spc, flags, false);
577 pp_right_paren (buffer);
578 break;
580 case OMP_CLAUSE_PROC_BIND:
581 pp_string (buffer, "proc_bind(");
582 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
584 case OMP_CLAUSE_PROC_BIND_MASTER:
585 pp_string (buffer, "master");
586 break;
587 case OMP_CLAUSE_PROC_BIND_CLOSE:
588 pp_string (buffer, "close");
589 break;
590 case OMP_CLAUSE_PROC_BIND_SPREAD:
591 pp_string (buffer, "spread");
592 break;
593 default:
594 gcc_unreachable ();
596 pp_right_paren (buffer);
597 break;
599 case OMP_CLAUSE_SAFELEN:
600 pp_string (buffer, "safelen(");
601 dump_generic_node (buffer, OMP_CLAUSE_SAFELEN_EXPR (clause),
602 spc, flags, false);
603 pp_right_paren (buffer);
604 break;
606 case OMP_CLAUSE_SIMDLEN:
607 pp_string (buffer, "simdlen(");
608 dump_generic_node (buffer, OMP_CLAUSE_SIMDLEN_EXPR (clause),
609 spc, flags, false);
610 pp_right_paren (buffer);
611 break;
613 case OMP_CLAUSE__SIMDUID_:
614 pp_string (buffer, "_simduid_(");
615 dump_generic_node (buffer, OMP_CLAUSE__SIMDUID__DECL (clause),
616 spc, flags, false);
617 pp_right_paren (buffer);
618 break;
620 case OMP_CLAUSE_INBRANCH:
621 pp_string (buffer, "inbranch");
622 break;
623 case OMP_CLAUSE_NOTINBRANCH:
624 pp_string (buffer, "notinbranch");
625 break;
626 case OMP_CLAUSE_FOR:
627 pp_string (buffer, "for");
628 break;
629 case OMP_CLAUSE_PARALLEL:
630 pp_string (buffer, "parallel");
631 break;
632 case OMP_CLAUSE_SECTIONS:
633 pp_string (buffer, "sections");
634 break;
635 case OMP_CLAUSE_TASKGROUP:
636 pp_string (buffer, "taskgroup");
637 break;
639 default:
640 /* Should never happen. */
641 dump_generic_node (buffer, clause, spc, flags, false);
642 break;
647 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
648 dump_generic_node. */
650 void
651 dump_omp_clauses (pretty_printer *buffer, tree clause, int spc, int flags)
653 if (clause == NULL)
654 return;
656 pp_space (buffer);
657 while (1)
659 dump_omp_clause (buffer, clause, spc, flags);
660 clause = OMP_CLAUSE_CHAIN (clause);
661 if (clause == NULL)
662 return;
663 pp_space (buffer);
668 /* Dump location LOC to BUFFER. */
670 static void
671 dump_location (pretty_printer *buffer, location_t loc)
673 expanded_location xloc = expand_location (loc);
675 pp_left_bracket (buffer);
676 if (xloc.file)
678 pp_string (buffer, xloc.file);
679 pp_string (buffer, " : ");
681 pp_decimal_int (buffer, xloc.line);
682 pp_string (buffer, "] ");
686 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
687 dump_generic_node. */
689 static void
690 dump_block_node (pretty_printer *buffer, tree block, int spc, int flags)
692 tree t;
694 pp_printf (buffer, "BLOCK #%d ", BLOCK_NUMBER (block));
696 if (flags & TDF_ADDRESS)
697 pp_printf (buffer, "[%p] ", (void *) block);
699 if (BLOCK_ABSTRACT (block))
700 pp_string (buffer, "[abstract] ");
702 if (TREE_ASM_WRITTEN (block))
703 pp_string (buffer, "[written] ");
705 if (flags & TDF_SLIM)
706 return;
708 if (BLOCK_SOURCE_LOCATION (block))
709 dump_location (buffer, BLOCK_SOURCE_LOCATION (block));
711 newline_and_indent (buffer, spc + 2);
713 if (BLOCK_SUPERCONTEXT (block))
715 pp_string (buffer, "SUPERCONTEXT: ");
716 dump_generic_node (buffer, BLOCK_SUPERCONTEXT (block), 0,
717 flags | TDF_SLIM, false);
718 newline_and_indent (buffer, spc + 2);
721 if (BLOCK_SUBBLOCKS (block))
723 pp_string (buffer, "SUBBLOCKS: ");
724 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
726 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
727 pp_space (buffer);
729 newline_and_indent (buffer, spc + 2);
732 if (BLOCK_CHAIN (block))
734 pp_string (buffer, "SIBLINGS: ");
735 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
737 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
738 pp_space (buffer);
740 newline_and_indent (buffer, spc + 2);
743 if (BLOCK_VARS (block))
745 pp_string (buffer, "VARS: ");
746 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
748 dump_generic_node (buffer, t, 0, flags, false);
749 pp_space (buffer);
751 newline_and_indent (buffer, spc + 2);
754 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
756 unsigned i;
757 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
759 pp_string (buffer, "NONLOCALIZED_VARS: ");
760 FOR_EACH_VEC_ELT (*nlv, i, t)
762 dump_generic_node (buffer, t, 0, flags, false);
763 pp_space (buffer);
765 newline_and_indent (buffer, spc + 2);
768 if (BLOCK_ABSTRACT_ORIGIN (block))
770 pp_string (buffer, "ABSTRACT_ORIGIN: ");
771 dump_generic_node (buffer, BLOCK_ABSTRACT_ORIGIN (block), 0,
772 flags | TDF_SLIM, false);
773 newline_and_indent (buffer, spc + 2);
776 if (BLOCK_FRAGMENT_ORIGIN (block))
778 pp_string (buffer, "FRAGMENT_ORIGIN: ");
779 dump_generic_node (buffer, BLOCK_FRAGMENT_ORIGIN (block), 0,
780 flags | TDF_SLIM, false);
781 newline_and_indent (buffer, spc + 2);
784 if (BLOCK_FRAGMENT_CHAIN (block))
786 pp_string (buffer, "FRAGMENT_CHAIN: ");
787 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
789 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
790 pp_space (buffer);
792 newline_and_indent (buffer, spc + 2);
797 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
798 indent. FLAGS specifies details to show in the dump (see TDF_* in
799 dumpfile.h). If IS_STMT is true, the object printed is considered
800 to be a statement and it is terminated by ';' if appropriate. */
803 dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
804 bool is_stmt)
806 tree type;
807 tree op0, op1;
808 const char *str;
809 bool is_expr;
810 enum tree_code code;
812 if (node == NULL_TREE)
813 return spc;
815 is_expr = EXPR_P (node);
817 if (is_stmt && (flags & TDF_STMTADDR))
818 pp_printf (buffer, "<&%p> ", (void *)node);
820 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
821 dump_location (buffer, EXPR_LOCATION (node));
823 code = TREE_CODE (node);
824 switch (code)
826 case ERROR_MARK:
827 pp_string (buffer, "<<< error >>>");
828 break;
830 case IDENTIFIER_NODE:
831 pp_tree_identifier (buffer, node);
832 break;
834 case TREE_LIST:
835 while (node && node != error_mark_node)
837 if (TREE_PURPOSE (node))
839 dump_generic_node (buffer, TREE_PURPOSE (node), spc, flags, false);
840 pp_space (buffer);
842 dump_generic_node (buffer, TREE_VALUE (node), spc, flags, false);
843 node = TREE_CHAIN (node);
844 if (node && TREE_CODE (node) == TREE_LIST)
846 pp_comma (buffer);
847 pp_space (buffer);
850 break;
852 case TREE_BINFO:
853 dump_generic_node (buffer, BINFO_TYPE (node), spc, flags, false);
854 break;
856 case TREE_VEC:
858 size_t i;
859 if (TREE_VEC_LENGTH (node) > 0)
861 size_t len = TREE_VEC_LENGTH (node);
862 for (i = 0; i < len - 1; i++)
864 dump_generic_node (buffer, TREE_VEC_ELT (node, i), spc, flags,
865 false);
866 pp_comma (buffer);
867 pp_space (buffer);
869 dump_generic_node (buffer, TREE_VEC_ELT (node, len - 1), spc,
870 flags, false);
873 break;
875 case VOID_TYPE:
876 case INTEGER_TYPE:
877 case REAL_TYPE:
878 case FIXED_POINT_TYPE:
879 case COMPLEX_TYPE:
880 case VECTOR_TYPE:
881 case ENUMERAL_TYPE:
882 case BOOLEAN_TYPE:
884 unsigned int quals = TYPE_QUALS (node);
885 enum tree_code_class tclass;
887 if (quals & TYPE_QUAL_ATOMIC)
888 pp_string (buffer, "atomic ");
889 if (quals & TYPE_QUAL_CONST)
890 pp_string (buffer, "const ");
891 else if (quals & TYPE_QUAL_VOLATILE)
892 pp_string (buffer, "volatile ");
893 else if (quals & TYPE_QUAL_RESTRICT)
894 pp_string (buffer, "restrict ");
896 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
898 pp_string (buffer, "<address-space-");
899 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
900 pp_string (buffer, "> ");
903 tclass = TREE_CODE_CLASS (TREE_CODE (node));
905 if (tclass == tcc_declaration)
907 if (DECL_NAME (node))
908 dump_decl_name (buffer, node, flags);
909 else
910 pp_string (buffer, "<unnamed type decl>");
912 else if (tclass == tcc_type)
914 if (TYPE_NAME (node))
916 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
917 pp_tree_identifier (buffer, TYPE_NAME (node));
918 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
919 && DECL_NAME (TYPE_NAME (node)))
920 dump_decl_name (buffer, TYPE_NAME (node), flags);
921 else
922 pp_string (buffer, "<unnamed type>");
924 else if (TREE_CODE (node) == VECTOR_TYPE)
926 pp_string (buffer, "vector");
927 pp_left_paren (buffer);
928 pp_wide_integer (buffer, TYPE_VECTOR_SUBPARTS (node));
929 pp_string (buffer, ") ");
930 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
932 else if (TREE_CODE (node) == INTEGER_TYPE)
934 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
935 pp_string (buffer, (TYPE_UNSIGNED (node)
936 ? "unsigned char"
937 : "signed char"));
938 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
939 pp_string (buffer, (TYPE_UNSIGNED (node)
940 ? "unsigned short"
941 : "signed short"));
942 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
943 pp_string (buffer, (TYPE_UNSIGNED (node)
944 ? "unsigned int"
945 : "signed int"));
946 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
947 pp_string (buffer, (TYPE_UNSIGNED (node)
948 ? "unsigned long"
949 : "signed long"));
950 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
951 pp_string (buffer, (TYPE_UNSIGNED (node)
952 ? "unsigned long long"
953 : "signed long long"));
954 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
955 && exact_log2 (TYPE_PRECISION (node)) != -1)
957 pp_string (buffer, (TYPE_UNSIGNED (node) ? "uint" : "int"));
958 pp_decimal_int (buffer, TYPE_PRECISION (node));
959 pp_string (buffer, "_t");
961 else
963 pp_string (buffer, (TYPE_UNSIGNED (node)
964 ? "<unnamed-unsigned:"
965 : "<unnamed-signed:"));
966 pp_decimal_int (buffer, TYPE_PRECISION (node));
967 pp_greater (buffer);
970 else if (TREE_CODE (node) == COMPLEX_TYPE)
972 pp_string (buffer, "__complex__ ");
973 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
975 else if (TREE_CODE (node) == REAL_TYPE)
977 pp_string (buffer, "<float:");
978 pp_decimal_int (buffer, TYPE_PRECISION (node));
979 pp_greater (buffer);
981 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
983 pp_string (buffer, "<fixed-point-");
984 pp_string (buffer, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
985 pp_decimal_int (buffer, TYPE_PRECISION (node));
986 pp_greater (buffer);
988 else if (TREE_CODE (node) == VOID_TYPE)
989 pp_string (buffer, "void");
990 else
991 pp_string (buffer, "<unnamed type>");
993 break;
996 case POINTER_TYPE:
997 case REFERENCE_TYPE:
998 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1000 if (TREE_TYPE (node) == NULL)
1002 pp_string (buffer, str);
1003 pp_string (buffer, "<null type>");
1005 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1007 tree fnode = TREE_TYPE (node);
1009 dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags, false);
1010 pp_space (buffer);
1011 pp_left_paren (buffer);
1012 pp_string (buffer, str);
1013 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1014 dump_decl_name (buffer, TYPE_NAME (node), flags);
1015 else if (flags & TDF_NOUID)
1016 pp_printf (buffer, "<Txxxx>");
1017 else
1018 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1020 pp_right_paren (buffer);
1021 dump_function_declaration (buffer, fnode, spc, flags);
1023 else
1025 unsigned int quals = TYPE_QUALS (node);
1027 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1028 pp_space (buffer);
1029 pp_string (buffer, str);
1031 if (quals & TYPE_QUAL_CONST)
1032 pp_string (buffer, " const");
1033 if (quals & TYPE_QUAL_VOLATILE)
1034 pp_string (buffer, " volatile");
1035 if (quals & TYPE_QUAL_RESTRICT)
1036 pp_string (buffer, " restrict");
1038 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1040 pp_string (buffer, " <address-space-");
1041 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
1042 pp_greater (buffer);
1045 if (TYPE_REF_CAN_ALIAS_ALL (node))
1046 pp_string (buffer, " {ref-all}");
1048 break;
1050 case OFFSET_TYPE:
1051 NIY;
1052 break;
1054 case MEM_REF:
1056 if (integer_zerop (TREE_OPERAND (node, 1))
1057 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1058 infer them and MEM_ATTR caching will share MEM_REFs
1059 with differently-typed op0s. */
1060 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1061 /* Released SSA_NAMES have no TREE_TYPE. */
1062 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1063 /* Same pointer types, but ignoring POINTER_TYPE vs.
1064 REFERENCE_TYPE. */
1065 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1066 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1067 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1068 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1069 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1070 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1071 /* Same value types ignoring qualifiers. */
1072 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1073 == TYPE_MAIN_VARIANT
1074 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))))
1076 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1078 pp_star (buffer);
1079 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1080 spc, flags, false);
1082 else
1083 dump_generic_node (buffer,
1084 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1085 spc, flags, false);
1087 else
1089 tree ptype;
1091 pp_string (buffer, "MEM[");
1092 pp_left_paren (buffer);
1093 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1094 dump_generic_node (buffer, ptype,
1095 spc, flags | TDF_SLIM, false);
1096 pp_right_paren (buffer);
1097 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1098 spc, flags, false);
1099 if (!integer_zerop (TREE_OPERAND (node, 1)))
1101 pp_string (buffer, " + ");
1102 dump_generic_node (buffer, TREE_OPERAND (node, 1),
1103 spc, flags, false);
1105 pp_right_bracket (buffer);
1107 break;
1110 case TARGET_MEM_REF:
1112 const char *sep = "";
1113 tree tmp;
1115 pp_string (buffer, "MEM[");
1117 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1119 pp_string (buffer, sep);
1120 sep = ", ";
1121 pp_string (buffer, "symbol: ");
1122 dump_generic_node (buffer, TREE_OPERAND (TMR_BASE (node), 0),
1123 spc, flags, false);
1125 else
1127 pp_string (buffer, sep);
1128 sep = ", ";
1129 pp_string (buffer, "base: ");
1130 dump_generic_node (buffer, TMR_BASE (node), spc, flags, false);
1132 tmp = TMR_INDEX2 (node);
1133 if (tmp)
1135 pp_string (buffer, sep);
1136 sep = ", ";
1137 pp_string (buffer, "base: ");
1138 dump_generic_node (buffer, tmp, spc, flags, false);
1140 tmp = TMR_INDEX (node);
1141 if (tmp)
1143 pp_string (buffer, sep);
1144 sep = ", ";
1145 pp_string (buffer, "index: ");
1146 dump_generic_node (buffer, tmp, spc, flags, false);
1148 tmp = TMR_STEP (node);
1149 if (tmp)
1151 pp_string (buffer, sep);
1152 sep = ", ";
1153 pp_string (buffer, "step: ");
1154 dump_generic_node (buffer, tmp, spc, flags, false);
1156 tmp = TMR_OFFSET (node);
1157 if (tmp)
1159 pp_string (buffer, sep);
1160 sep = ", ";
1161 pp_string (buffer, "offset: ");
1162 dump_generic_node (buffer, tmp, spc, flags, false);
1164 pp_right_bracket (buffer);
1166 break;
1168 case ARRAY_TYPE:
1170 tree tmp;
1172 /* Print the innermost component type. */
1173 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1174 tmp = TREE_TYPE (tmp))
1176 dump_generic_node (buffer, tmp, spc, flags, false);
1178 /* Print the dimensions. */
1179 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1180 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
1181 break;
1184 case RECORD_TYPE:
1185 case UNION_TYPE:
1186 case QUAL_UNION_TYPE:
1188 unsigned int quals = TYPE_QUALS (node);
1190 if (quals & TYPE_QUAL_ATOMIC)
1191 pp_string (buffer, "atomic ");
1192 if (quals & TYPE_QUAL_CONST)
1193 pp_string (buffer, "const ");
1194 if (quals & TYPE_QUAL_VOLATILE)
1195 pp_string (buffer, "volatile ");
1197 /* Print the name of the structure. */
1198 if (TREE_CODE (node) == RECORD_TYPE)
1199 pp_string (buffer, "struct ");
1200 else if (TREE_CODE (node) == UNION_TYPE)
1201 pp_string (buffer, "union ");
1203 if (TYPE_NAME (node))
1204 dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false);
1205 else if (!(flags & TDF_SLIM))
1206 /* FIXME: If we eliminate the 'else' above and attempt
1207 to show the fields for named types, we may get stuck
1208 following a cycle of pointers to structs. The alleged
1209 self-reference check in print_struct_decl will not detect
1210 cycles involving more than one pointer or struct type. */
1211 print_struct_decl (buffer, node, spc, flags);
1212 break;
1215 case LANG_TYPE:
1216 NIY;
1217 break;
1219 case INTEGER_CST:
1220 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1222 /* In the case of a pointer, one may want to divide by the
1223 size of the pointed-to type. Unfortunately, this not
1224 straightforward. The C front-end maps expressions
1226 (int *) 5
1227 int *p; (p + 5)
1229 in such a way that the two INTEGER_CST nodes for "5" have
1230 different values but identical types. In the latter
1231 case, the 5 is multiplied by sizeof (int) in c-common.c
1232 (pointer_int_sum) to convert it to a byte address, and
1233 yet the type of the node is left unchanged. Argh. What
1234 is consistent though is that the number value corresponds
1235 to bytes (UNITS) offset.
1237 NB: Neither of the following divisors can be trivially
1238 used to recover the original literal:
1240 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1241 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1242 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
1243 pp_string (buffer, "B"); /* pseudo-unit */
1245 else if (tree_fits_shwi_p (node))
1246 pp_wide_integer (buffer, tree_to_shwi (node));
1247 else if (tree_fits_uhwi_p (node))
1248 pp_unsigned_wide_integer (buffer, tree_to_uhwi (node));
1249 else
1251 wide_int val = node;
1253 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1255 pp_minus (buffer);
1256 val = -val;
1258 print_hex (val, pp_buffer (buffer)->digit_buffer);
1259 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
1261 if (TREE_OVERFLOW (node))
1262 pp_string (buffer, "(OVF)");
1263 break;
1265 case REAL_CST:
1266 /* Code copied from print_node. */
1268 REAL_VALUE_TYPE d;
1269 if (TREE_OVERFLOW (node))
1270 pp_string (buffer, " overflow");
1272 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1273 d = TREE_REAL_CST (node);
1274 if (REAL_VALUE_ISINF (d))
1275 pp_string (buffer, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1276 else if (REAL_VALUE_ISNAN (d))
1277 pp_string (buffer, " Nan");
1278 else
1280 char string[100];
1281 real_to_decimal (string, &d, sizeof (string), 0, 1);
1282 pp_string (buffer, string);
1284 #else
1286 HOST_WIDE_INT i;
1287 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
1288 pp_string (buffer, "0x");
1289 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
1290 output_formatted_integer (buffer, "%02x", *p++);
1292 #endif
1293 break;
1296 case FIXED_CST:
1298 char string[100];
1299 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1300 pp_string (buffer, string);
1301 break;
1304 case COMPLEX_CST:
1305 pp_string (buffer, "__complex__ (");
1306 dump_generic_node (buffer, TREE_REALPART (node), spc, flags, false);
1307 pp_string (buffer, ", ");
1308 dump_generic_node (buffer, TREE_IMAGPART (node), spc, flags, false);
1309 pp_right_paren (buffer);
1310 break;
1312 case STRING_CST:
1313 pp_string (buffer, "\"");
1314 pretty_print_string (buffer, TREE_STRING_POINTER (node));
1315 pp_string (buffer, "\"");
1316 break;
1318 case VECTOR_CST:
1320 unsigned i;
1321 pp_string (buffer, "{ ");
1322 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1324 if (i != 0)
1325 pp_string (buffer, ", ");
1326 dump_generic_node (buffer, VECTOR_CST_ELT (node, i),
1327 spc, flags, false);
1329 pp_string (buffer, " }");
1331 break;
1333 case FUNCTION_TYPE:
1334 case METHOD_TYPE:
1335 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1336 pp_space (buffer);
1337 if (TREE_CODE (node) == METHOD_TYPE)
1339 if (TYPE_METHOD_BASETYPE (node))
1340 dump_decl_name (buffer, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1341 flags);
1342 else
1343 pp_string (buffer, "<null method basetype>");
1344 pp_colon_colon (buffer);
1346 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1347 dump_decl_name (buffer, TYPE_NAME (node), flags);
1348 else if (flags & TDF_NOUID)
1349 pp_printf (buffer, "<Txxxx>");
1350 else
1351 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1352 dump_function_declaration (buffer, node, spc, flags);
1353 break;
1355 case FUNCTION_DECL:
1356 case CONST_DECL:
1357 dump_decl_name (buffer, node, flags);
1358 break;
1360 case LABEL_DECL:
1361 if (DECL_NAME (node))
1362 dump_decl_name (buffer, node, flags);
1363 else if (LABEL_DECL_UID (node) != -1)
1364 pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node));
1365 else
1367 if (flags & TDF_NOUID)
1368 pp_string (buffer, "<D.xxxx>");
1369 else
1370 pp_printf (buffer, "<D.%u>", DECL_UID (node));
1372 break;
1374 case TYPE_DECL:
1375 if (DECL_IS_BUILTIN (node))
1377 /* Don't print the declaration of built-in types. */
1378 break;
1380 if (DECL_NAME (node))
1381 dump_decl_name (buffer, node, flags);
1382 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1384 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1385 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1386 && TYPE_METHODS (TREE_TYPE (node)))
1388 /* The type is a c++ class: all structures have at least
1389 4 methods. */
1390 pp_string (buffer, "class ");
1391 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1393 else
1395 pp_string (buffer,
1396 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1397 ? "union" : "struct "));
1398 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1401 else
1402 pp_string (buffer, "<anon>");
1403 break;
1405 case VAR_DECL:
1406 case PARM_DECL:
1407 case FIELD_DECL:
1408 case DEBUG_EXPR_DECL:
1409 case NAMESPACE_DECL:
1410 case NAMELIST_DECL:
1411 dump_decl_name (buffer, node, flags);
1412 break;
1414 case RESULT_DECL:
1415 pp_string (buffer, "<retval>");
1416 break;
1418 case COMPONENT_REF:
1419 op0 = TREE_OPERAND (node, 0);
1420 str = ".";
1421 if (op0
1422 && (TREE_CODE (op0) == INDIRECT_REF
1423 || (TREE_CODE (op0) == MEM_REF
1424 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1425 && integer_zerop (TREE_OPERAND (op0, 1))
1426 /* Dump the types of INTEGER_CSTs explicitly, for we
1427 can't infer them and MEM_ATTR caching will share
1428 MEM_REFs with differently-typed op0s. */
1429 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1430 /* Released SSA_NAMES have no TREE_TYPE. */
1431 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1432 /* Same pointer types, but ignoring POINTER_TYPE vs.
1433 REFERENCE_TYPE. */
1434 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1435 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1436 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1437 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1438 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1439 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1440 /* Same value types ignoring qualifiers. */
1441 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1442 == TYPE_MAIN_VARIANT
1443 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))))))
1445 op0 = TREE_OPERAND (op0, 0);
1446 str = "->";
1448 if (op_prio (op0) < op_prio (node))
1449 pp_left_paren (buffer);
1450 dump_generic_node (buffer, op0, spc, flags, false);
1451 if (op_prio (op0) < op_prio (node))
1452 pp_right_paren (buffer);
1453 pp_string (buffer, str);
1454 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1455 op0 = component_ref_field_offset (node);
1456 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1458 pp_string (buffer, "{off: ");
1459 dump_generic_node (buffer, op0, spc, flags, false);
1460 pp_right_brace (buffer);
1462 break;
1464 case BIT_FIELD_REF:
1465 pp_string (buffer, "BIT_FIELD_REF <");
1466 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1467 pp_string (buffer, ", ");
1468 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1469 pp_string (buffer, ", ");
1470 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1471 pp_greater (buffer);
1472 break;
1474 case ARRAY_REF:
1475 case ARRAY_RANGE_REF:
1476 op0 = TREE_OPERAND (node, 0);
1477 if (op_prio (op0) < op_prio (node))
1478 pp_left_paren (buffer);
1479 dump_generic_node (buffer, op0, spc, flags, false);
1480 if (op_prio (op0) < op_prio (node))
1481 pp_right_paren (buffer);
1482 pp_left_bracket (buffer);
1483 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1484 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1485 pp_string (buffer, " ...");
1486 pp_right_bracket (buffer);
1488 op0 = array_ref_low_bound (node);
1489 op1 = array_ref_element_size (node);
1491 if (!integer_zerop (op0)
1492 || TREE_OPERAND (node, 2)
1493 || TREE_OPERAND (node, 3))
1495 pp_string (buffer, "{lb: ");
1496 dump_generic_node (buffer, op0, spc, flags, false);
1497 pp_string (buffer, " sz: ");
1498 dump_generic_node (buffer, op1, spc, flags, false);
1499 pp_right_brace (buffer);
1501 break;
1503 case CONSTRUCTOR:
1505 unsigned HOST_WIDE_INT ix;
1506 tree field, val;
1507 bool is_struct_init = false;
1508 bool is_array_init = false;
1509 widest_int curidx;
1510 pp_left_brace (buffer);
1511 if (TREE_CLOBBER_P (node))
1512 pp_string (buffer, "CLOBBER");
1513 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1514 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1515 is_struct_init = true;
1516 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1517 && TYPE_DOMAIN (TREE_TYPE (node))
1518 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1519 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1520 == INTEGER_CST)
1522 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1523 is_array_init = true;
1524 curidx = wi::to_widest (minv);
1526 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1528 if (field)
1530 if (is_struct_init)
1532 pp_dot (buffer);
1533 dump_generic_node (buffer, field, spc, flags, false);
1534 pp_equal (buffer);
1536 else if (is_array_init
1537 && (TREE_CODE (field) != INTEGER_CST
1538 || curidx != wi::to_widest (field)))
1540 pp_left_bracket (buffer);
1541 if (TREE_CODE (field) == RANGE_EXPR)
1543 dump_generic_node (buffer, TREE_OPERAND (field, 0), spc,
1544 flags, false);
1545 pp_string (buffer, " ... ");
1546 dump_generic_node (buffer, TREE_OPERAND (field, 1), spc,
1547 flags, false);
1548 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1549 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1551 else
1552 dump_generic_node (buffer, field, spc, flags, false);
1553 if (TREE_CODE (field) == INTEGER_CST)
1554 curidx = wi::to_widest (field);
1555 pp_string (buffer, "]=");
1558 if (is_array_init)
1559 curidx += 1;
1560 if (val && TREE_CODE (val) == ADDR_EXPR)
1561 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1562 val = TREE_OPERAND (val, 0);
1563 if (val && TREE_CODE (val) == FUNCTION_DECL)
1564 dump_decl_name (buffer, val, flags);
1565 else
1566 dump_generic_node (buffer, val, spc, flags, false);
1567 if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1)
1569 pp_comma (buffer);
1570 pp_space (buffer);
1573 pp_right_brace (buffer);
1575 break;
1577 case COMPOUND_EXPR:
1579 tree *tp;
1580 if (flags & TDF_SLIM)
1582 pp_string (buffer, "<COMPOUND_EXPR>");
1583 break;
1586 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1587 spc, flags, !(flags & TDF_SLIM));
1588 if (flags & TDF_SLIM)
1589 newline_and_indent (buffer, spc);
1590 else
1592 pp_comma (buffer);
1593 pp_space (buffer);
1596 for (tp = &TREE_OPERAND (node, 1);
1597 TREE_CODE (*tp) == COMPOUND_EXPR;
1598 tp = &TREE_OPERAND (*tp, 1))
1600 dump_generic_node (buffer, TREE_OPERAND (*tp, 0),
1601 spc, flags, !(flags & TDF_SLIM));
1602 if (flags & TDF_SLIM)
1603 newline_and_indent (buffer, spc);
1604 else
1606 pp_comma (buffer);
1607 pp_space (buffer);
1611 dump_generic_node (buffer, *tp, spc, flags, !(flags & TDF_SLIM));
1613 break;
1615 case STATEMENT_LIST:
1617 tree_stmt_iterator si;
1618 bool first = true;
1620 if (flags & TDF_SLIM)
1622 pp_string (buffer, "<STATEMENT_LIST>");
1623 break;
1626 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1628 if (!first)
1629 newline_and_indent (buffer, spc);
1630 else
1631 first = false;
1632 dump_generic_node (buffer, tsi_stmt (si), spc, flags, true);
1635 break;
1637 case MODIFY_EXPR:
1638 case INIT_EXPR:
1639 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags,
1640 false);
1641 pp_space (buffer);
1642 pp_equal (buffer);
1643 pp_space (buffer);
1644 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags,
1645 false);
1646 break;
1648 case TARGET_EXPR:
1649 pp_string (buffer, "TARGET_EXPR <");
1650 dump_generic_node (buffer, TARGET_EXPR_SLOT (node), spc, flags, false);
1651 pp_comma (buffer);
1652 pp_space (buffer);
1653 dump_generic_node (buffer, TARGET_EXPR_INITIAL (node), spc, flags, false);
1654 pp_greater (buffer);
1655 break;
1657 case DECL_EXPR:
1658 print_declaration (buffer, DECL_EXPR_DECL (node), spc, flags);
1659 is_stmt = false;
1660 break;
1662 case COND_EXPR:
1663 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1665 pp_string (buffer, "if (");
1666 dump_generic_node (buffer, COND_EXPR_COND (node), spc, flags, false);
1667 pp_right_paren (buffer);
1668 /* The lowered cond_exprs should always be printed in full. */
1669 if (COND_EXPR_THEN (node)
1670 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1671 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1672 && COND_EXPR_ELSE (node)
1673 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1674 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1676 pp_space (buffer);
1677 dump_generic_node (buffer, COND_EXPR_THEN (node),
1678 0, flags, true);
1679 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1681 pp_string (buffer, " else ");
1682 dump_generic_node (buffer, COND_EXPR_ELSE (node),
1683 0, flags, true);
1686 else if (!(flags & TDF_SLIM))
1688 /* Output COND_EXPR_THEN. */
1689 if (COND_EXPR_THEN (node))
1691 newline_and_indent (buffer, spc+2);
1692 pp_left_brace (buffer);
1693 newline_and_indent (buffer, spc+4);
1694 dump_generic_node (buffer, COND_EXPR_THEN (node), spc+4,
1695 flags, true);
1696 newline_and_indent (buffer, spc+2);
1697 pp_right_brace (buffer);
1700 /* Output COND_EXPR_ELSE. */
1701 if (COND_EXPR_ELSE (node)
1702 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1704 newline_and_indent (buffer, spc);
1705 pp_string (buffer, "else");
1706 newline_and_indent (buffer, spc+2);
1707 pp_left_brace (buffer);
1708 newline_and_indent (buffer, spc+4);
1709 dump_generic_node (buffer, COND_EXPR_ELSE (node), spc+4,
1710 flags, true);
1711 newline_and_indent (buffer, spc+2);
1712 pp_right_brace (buffer);
1715 is_expr = false;
1717 else
1719 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1720 pp_space (buffer);
1721 pp_question (buffer);
1722 pp_space (buffer);
1723 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1724 pp_space (buffer);
1725 pp_colon (buffer);
1726 pp_space (buffer);
1727 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1729 break;
1731 case BIND_EXPR:
1732 pp_left_brace (buffer);
1733 if (!(flags & TDF_SLIM))
1735 if (BIND_EXPR_VARS (node))
1737 pp_newline (buffer);
1739 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
1741 print_declaration (buffer, op0, spc+2, flags);
1742 pp_newline (buffer);
1746 newline_and_indent (buffer, spc+2);
1747 dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, flags, true);
1748 newline_and_indent (buffer, spc);
1749 pp_right_brace (buffer);
1751 is_expr = false;
1752 break;
1754 case CALL_EXPR:
1755 if (CALL_EXPR_FN (node) != NULL_TREE)
1756 print_call_name (buffer, CALL_EXPR_FN (node), flags);
1757 else
1758 pp_string (buffer, internal_fn_name (CALL_EXPR_IFN (node)));
1760 /* Print parameters. */
1761 pp_space (buffer);
1762 pp_left_paren (buffer);
1764 tree arg;
1765 call_expr_arg_iterator iter;
1766 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1768 dump_generic_node (buffer, arg, spc, flags, false);
1769 if (more_call_expr_args_p (&iter))
1771 pp_comma (buffer);
1772 pp_space (buffer);
1776 if (CALL_EXPR_VA_ARG_PACK (node))
1778 if (call_expr_nargs (node) > 0)
1780 pp_comma (buffer);
1781 pp_space (buffer);
1783 pp_string (buffer, "__builtin_va_arg_pack ()");
1785 pp_right_paren (buffer);
1787 op1 = CALL_EXPR_STATIC_CHAIN (node);
1788 if (op1)
1790 pp_string (buffer, " [static-chain: ");
1791 dump_generic_node (buffer, op1, spc, flags, false);
1792 pp_right_bracket (buffer);
1795 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1796 pp_string (buffer, " [return slot optimization]");
1797 if (CALL_EXPR_TAILCALL (node))
1798 pp_string (buffer, " [tail call]");
1799 break;
1801 case WITH_CLEANUP_EXPR:
1802 NIY;
1803 break;
1805 case CLEANUP_POINT_EXPR:
1806 pp_string (buffer, "<<cleanup_point ");
1807 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1808 pp_string (buffer, ">>");
1809 break;
1811 case PLACEHOLDER_EXPR:
1812 pp_string (buffer, "<PLACEHOLDER_EXPR ");
1813 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1814 pp_greater (buffer);
1815 break;
1817 /* Binary arithmetic and logic expressions. */
1818 case WIDEN_SUM_EXPR:
1819 case WIDEN_MULT_EXPR:
1820 case MULT_EXPR:
1821 case MULT_HIGHPART_EXPR:
1822 case PLUS_EXPR:
1823 case POINTER_PLUS_EXPR:
1824 case MINUS_EXPR:
1825 case TRUNC_DIV_EXPR:
1826 case CEIL_DIV_EXPR:
1827 case FLOOR_DIV_EXPR:
1828 case ROUND_DIV_EXPR:
1829 case TRUNC_MOD_EXPR:
1830 case CEIL_MOD_EXPR:
1831 case FLOOR_MOD_EXPR:
1832 case ROUND_MOD_EXPR:
1833 case RDIV_EXPR:
1834 case EXACT_DIV_EXPR:
1835 case LSHIFT_EXPR:
1836 case RSHIFT_EXPR:
1837 case LROTATE_EXPR:
1838 case RROTATE_EXPR:
1839 case VEC_LSHIFT_EXPR:
1840 case VEC_RSHIFT_EXPR:
1841 case WIDEN_LSHIFT_EXPR:
1842 case BIT_IOR_EXPR:
1843 case BIT_XOR_EXPR:
1844 case BIT_AND_EXPR:
1845 case TRUTH_ANDIF_EXPR:
1846 case TRUTH_ORIF_EXPR:
1847 case TRUTH_AND_EXPR:
1848 case TRUTH_OR_EXPR:
1849 case TRUTH_XOR_EXPR:
1850 case LT_EXPR:
1851 case LE_EXPR:
1852 case GT_EXPR:
1853 case GE_EXPR:
1854 case EQ_EXPR:
1855 case NE_EXPR:
1856 case UNLT_EXPR:
1857 case UNLE_EXPR:
1858 case UNGT_EXPR:
1859 case UNGE_EXPR:
1860 case UNEQ_EXPR:
1861 case LTGT_EXPR:
1862 case ORDERED_EXPR:
1863 case UNORDERED_EXPR:
1865 const char *op = op_symbol (node);
1866 op0 = TREE_OPERAND (node, 0);
1867 op1 = TREE_OPERAND (node, 1);
1869 /* When the operands are expressions with less priority,
1870 keep semantics of the tree representation. */
1871 if (op_prio (op0) <= op_prio (node))
1873 pp_left_paren (buffer);
1874 dump_generic_node (buffer, op0, spc, flags, false);
1875 pp_right_paren (buffer);
1877 else
1878 dump_generic_node (buffer, op0, spc, flags, false);
1880 pp_space (buffer);
1881 pp_string (buffer, op);
1882 pp_space (buffer);
1884 /* When the operands are expressions with less priority,
1885 keep semantics of the tree representation. */
1886 if (op_prio (op1) <= op_prio (node))
1888 pp_left_paren (buffer);
1889 dump_generic_node (buffer, op1, spc, flags, false);
1890 pp_right_paren (buffer);
1892 else
1893 dump_generic_node (buffer, op1, spc, flags, false);
1895 break;
1897 /* Unary arithmetic and logic expressions. */
1898 case NEGATE_EXPR:
1899 case BIT_NOT_EXPR:
1900 case TRUTH_NOT_EXPR:
1901 case ADDR_EXPR:
1902 case PREDECREMENT_EXPR:
1903 case PREINCREMENT_EXPR:
1904 case INDIRECT_REF:
1905 if (TREE_CODE (node) == ADDR_EXPR
1906 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
1907 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
1908 ; /* Do not output '&' for strings and function pointers. */
1909 else
1910 pp_string (buffer, op_symbol (node));
1912 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1914 pp_left_paren (buffer);
1915 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1916 pp_right_paren (buffer);
1918 else
1919 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1920 break;
1922 case POSTDECREMENT_EXPR:
1923 case POSTINCREMENT_EXPR:
1924 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1926 pp_left_paren (buffer);
1927 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1928 pp_right_paren (buffer);
1930 else
1931 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1932 pp_string (buffer, op_symbol (node));
1933 break;
1935 case MIN_EXPR:
1936 pp_string (buffer, "MIN_EXPR <");
1937 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1938 pp_string (buffer, ", ");
1939 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1940 pp_greater (buffer);
1941 break;
1943 case MAX_EXPR:
1944 pp_string (buffer, "MAX_EXPR <");
1945 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1946 pp_string (buffer, ", ");
1947 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1948 pp_greater (buffer);
1949 break;
1951 case ABS_EXPR:
1952 pp_string (buffer, "ABS_EXPR <");
1953 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1954 pp_greater (buffer);
1955 break;
1957 case RANGE_EXPR:
1958 NIY;
1959 break;
1961 case ADDR_SPACE_CONVERT_EXPR:
1962 case FIXED_CONVERT_EXPR:
1963 case FIX_TRUNC_EXPR:
1964 case FLOAT_EXPR:
1965 CASE_CONVERT:
1966 type = TREE_TYPE (node);
1967 op0 = TREE_OPERAND (node, 0);
1968 if (type != TREE_TYPE (op0))
1970 pp_left_paren (buffer);
1971 dump_generic_node (buffer, type, spc, flags, false);
1972 pp_string (buffer, ") ");
1974 if (op_prio (op0) < op_prio (node))
1975 pp_left_paren (buffer);
1976 dump_generic_node (buffer, op0, spc, flags, false);
1977 if (op_prio (op0) < op_prio (node))
1978 pp_right_paren (buffer);
1979 break;
1981 case VIEW_CONVERT_EXPR:
1982 pp_string (buffer, "VIEW_CONVERT_EXPR<");
1983 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1984 pp_string (buffer, ">(");
1985 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1986 pp_right_paren (buffer);
1987 break;
1989 case PAREN_EXPR:
1990 pp_string (buffer, "((");
1991 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1992 pp_string (buffer, "))");
1993 break;
1995 case NON_LVALUE_EXPR:
1996 pp_string (buffer, "NON_LVALUE_EXPR <");
1997 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1998 pp_greater (buffer);
1999 break;
2001 case SAVE_EXPR:
2002 pp_string (buffer, "SAVE_EXPR <");
2003 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2004 pp_greater (buffer);
2005 break;
2007 case COMPLEX_EXPR:
2008 pp_string (buffer, "COMPLEX_EXPR <");
2009 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2010 pp_string (buffer, ", ");
2011 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2012 pp_greater (buffer);
2013 break;
2015 case CONJ_EXPR:
2016 pp_string (buffer, "CONJ_EXPR <");
2017 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2018 pp_greater (buffer);
2019 break;
2021 case REALPART_EXPR:
2022 pp_string (buffer, "REALPART_EXPR <");
2023 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2024 pp_greater (buffer);
2025 break;
2027 case IMAGPART_EXPR:
2028 pp_string (buffer, "IMAGPART_EXPR <");
2029 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2030 pp_greater (buffer);
2031 break;
2033 case VA_ARG_EXPR:
2034 pp_string (buffer, "VA_ARG_EXPR <");
2035 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2036 pp_greater (buffer);
2037 break;
2039 case TRY_FINALLY_EXPR:
2040 case TRY_CATCH_EXPR:
2041 pp_string (buffer, "try");
2042 newline_and_indent (buffer, spc+2);
2043 pp_left_brace (buffer);
2044 newline_and_indent (buffer, spc+4);
2045 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc+4, flags, true);
2046 newline_and_indent (buffer, spc+2);
2047 pp_right_brace (buffer);
2048 newline_and_indent (buffer, spc);
2049 pp_string (buffer,
2050 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2051 newline_and_indent (buffer, spc+2);
2052 pp_left_brace (buffer);
2053 newline_and_indent (buffer, spc+4);
2054 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4, flags, true);
2055 newline_and_indent (buffer, spc+2);
2056 pp_right_brace (buffer);
2057 is_expr = false;
2058 break;
2060 case CATCH_EXPR:
2061 pp_string (buffer, "catch (");
2062 dump_generic_node (buffer, CATCH_TYPES (node), spc+2, flags, false);
2063 pp_right_paren (buffer);
2064 newline_and_indent (buffer, spc+2);
2065 pp_left_brace (buffer);
2066 newline_and_indent (buffer, spc+4);
2067 dump_generic_node (buffer, CATCH_BODY (node), spc+4, flags, true);
2068 newline_and_indent (buffer, spc+2);
2069 pp_right_brace (buffer);
2070 is_expr = false;
2071 break;
2073 case EH_FILTER_EXPR:
2074 pp_string (buffer, "<<<eh_filter (");
2075 dump_generic_node (buffer, EH_FILTER_TYPES (node), spc+2, flags, false);
2076 pp_string (buffer, ")>>>");
2077 newline_and_indent (buffer, spc+2);
2078 pp_left_brace (buffer);
2079 newline_and_indent (buffer, spc+4);
2080 dump_generic_node (buffer, EH_FILTER_FAILURE (node), spc+4, flags, true);
2081 newline_and_indent (buffer, spc+2);
2082 pp_right_brace (buffer);
2083 is_expr = false;
2084 break;
2086 case LABEL_EXPR:
2087 op0 = TREE_OPERAND (node, 0);
2088 /* If this is for break or continue, don't bother printing it. */
2089 if (DECL_NAME (op0))
2091 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2092 if (strcmp (name, "break") == 0
2093 || strcmp (name, "continue") == 0)
2094 break;
2096 dump_generic_node (buffer, op0, spc, flags, false);
2097 pp_colon (buffer);
2098 if (DECL_NONLOCAL (op0))
2099 pp_string (buffer, " [non-local]");
2100 break;
2102 case LOOP_EXPR:
2103 pp_string (buffer, "while (1)");
2104 if (!(flags & TDF_SLIM))
2106 newline_and_indent (buffer, spc+2);
2107 pp_left_brace (buffer);
2108 newline_and_indent (buffer, spc+4);
2109 dump_generic_node (buffer, LOOP_EXPR_BODY (node), spc+4, flags, true);
2110 newline_and_indent (buffer, spc+2);
2111 pp_right_brace (buffer);
2113 is_expr = false;
2114 break;
2116 case PREDICT_EXPR:
2117 pp_string (buffer, "// predicted ");
2118 if (PREDICT_EXPR_OUTCOME (node))
2119 pp_string (buffer, "likely by ");
2120 else
2121 pp_string (buffer, "unlikely by ");
2122 pp_string (buffer, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2123 pp_string (buffer, " predictor.");
2124 break;
2126 case ANNOTATE_EXPR:
2127 pp_string (buffer, "ANNOTATE_EXPR <");
2128 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2129 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2131 case annot_expr_ivdep_kind:
2132 pp_string (buffer, ", ivdep");
2133 break;
2134 case annot_expr_no_vector_kind:
2135 pp_string (buffer, ", no-vector");
2136 break;
2137 case annot_expr_vector_kind:
2138 pp_string (buffer, ", vector");
2139 break;
2140 default:
2141 gcc_unreachable ();
2143 pp_greater (buffer);
2144 break;
2146 case RETURN_EXPR:
2147 pp_string (buffer, "return");
2148 op0 = TREE_OPERAND (node, 0);
2149 if (op0)
2151 pp_space (buffer);
2152 if (TREE_CODE (op0) == MODIFY_EXPR)
2153 dump_generic_node (buffer, TREE_OPERAND (op0, 1),
2154 spc, flags, false);
2155 else
2156 dump_generic_node (buffer, op0, spc, flags, false);
2158 break;
2160 case EXIT_EXPR:
2161 pp_string (buffer, "if (");
2162 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2163 pp_string (buffer, ") break");
2164 break;
2166 case SWITCH_EXPR:
2167 pp_string (buffer, "switch (");
2168 dump_generic_node (buffer, SWITCH_COND (node), spc, flags, false);
2169 pp_right_paren (buffer);
2170 if (!(flags & TDF_SLIM))
2172 newline_and_indent (buffer, spc+2);
2173 pp_left_brace (buffer);
2174 if (SWITCH_BODY (node))
2176 newline_and_indent (buffer, spc+4);
2177 dump_generic_node (buffer, SWITCH_BODY (node), spc+4, flags,
2178 true);
2180 else
2182 tree vec = SWITCH_LABELS (node);
2183 size_t i, n = TREE_VEC_LENGTH (vec);
2184 for (i = 0; i < n; ++i)
2186 tree elt = TREE_VEC_ELT (vec, i);
2187 newline_and_indent (buffer, spc+4);
2188 if (elt)
2190 dump_generic_node (buffer, elt, spc+4, flags, false);
2191 pp_string (buffer, " goto ");
2192 dump_generic_node (buffer, CASE_LABEL (elt), spc+4,
2193 flags, true);
2194 pp_semicolon (buffer);
2196 else
2197 pp_string (buffer, "case ???: goto ???;");
2200 newline_and_indent (buffer, spc+2);
2201 pp_right_brace (buffer);
2203 is_expr = false;
2204 break;
2206 case GOTO_EXPR:
2207 op0 = GOTO_DESTINATION (node);
2208 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2210 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2211 if (strcmp (name, "break") == 0
2212 || strcmp (name, "continue") == 0)
2214 pp_string (buffer, name);
2215 break;
2218 pp_string (buffer, "goto ");
2219 dump_generic_node (buffer, op0, spc, flags, false);
2220 break;
2222 case ASM_EXPR:
2223 pp_string (buffer, "__asm__");
2224 if (ASM_VOLATILE_P (node))
2225 pp_string (buffer, " __volatile__");
2226 pp_left_paren (buffer);
2227 dump_generic_node (buffer, ASM_STRING (node), spc, flags, false);
2228 pp_colon (buffer);
2229 dump_generic_node (buffer, ASM_OUTPUTS (node), spc, flags, false);
2230 pp_colon (buffer);
2231 dump_generic_node (buffer, ASM_INPUTS (node), spc, flags, false);
2232 if (ASM_CLOBBERS (node))
2234 pp_colon (buffer);
2235 dump_generic_node (buffer, ASM_CLOBBERS (node), spc, flags, false);
2237 pp_right_paren (buffer);
2238 break;
2240 case CASE_LABEL_EXPR:
2241 if (CASE_LOW (node) && CASE_HIGH (node))
2243 pp_string (buffer, "case ");
2244 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2245 pp_string (buffer, " ... ");
2246 dump_generic_node (buffer, CASE_HIGH (node), spc, flags, false);
2248 else if (CASE_LOW (node))
2250 pp_string (buffer, "case ");
2251 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2253 else
2254 pp_string (buffer, "default");
2255 pp_colon (buffer);
2256 break;
2258 case OBJ_TYPE_REF:
2259 pp_string (buffer, "OBJ_TYPE_REF(");
2260 dump_generic_node (buffer, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2261 pp_semicolon (buffer);
2262 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2264 pp_string (buffer, "(");
2265 dump_generic_node (buffer, obj_type_ref_class (node), spc, flags, false);
2266 pp_string (buffer, ")");
2268 dump_generic_node (buffer, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2269 pp_arrow (buffer);
2270 dump_generic_node (buffer, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2271 pp_right_paren (buffer);
2272 break;
2274 case SSA_NAME:
2275 if (SSA_NAME_IDENTIFIER (node))
2276 dump_generic_node (buffer, SSA_NAME_IDENTIFIER (node),
2277 spc, flags, false);
2278 pp_underscore (buffer);
2279 pp_decimal_int (buffer, SSA_NAME_VERSION (node));
2280 if (SSA_NAME_IS_DEFAULT_DEF (node))
2281 pp_string (buffer, "(D)");
2282 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2283 pp_string (buffer, "(ab)");
2284 break;
2286 case WITH_SIZE_EXPR:
2287 pp_string (buffer, "WITH_SIZE_EXPR <");
2288 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2289 pp_string (buffer, ", ");
2290 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2291 pp_greater (buffer);
2292 break;
2294 case ASSERT_EXPR:
2295 pp_string (buffer, "ASSERT_EXPR <");
2296 dump_generic_node (buffer, ASSERT_EXPR_VAR (node), spc, flags, false);
2297 pp_string (buffer, ", ");
2298 dump_generic_node (buffer, ASSERT_EXPR_COND (node), spc, flags, false);
2299 pp_greater (buffer);
2300 break;
2302 case SCEV_KNOWN:
2303 pp_string (buffer, "scev_known");
2304 break;
2306 case SCEV_NOT_KNOWN:
2307 pp_string (buffer, "scev_not_known");
2308 break;
2310 case POLYNOMIAL_CHREC:
2311 pp_left_brace (buffer);
2312 dump_generic_node (buffer, CHREC_LEFT (node), spc, flags, false);
2313 pp_string (buffer, ", +, ");
2314 dump_generic_node (buffer, CHREC_RIGHT (node), spc, flags, false);
2315 pp_string (buffer, "}_");
2316 dump_generic_node (buffer, CHREC_VAR (node), spc, flags, false);
2317 is_stmt = false;
2318 break;
2320 case REALIGN_LOAD_EXPR:
2321 pp_string (buffer, "REALIGN_LOAD <");
2322 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2323 pp_string (buffer, ", ");
2324 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2325 pp_string (buffer, ", ");
2326 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2327 pp_greater (buffer);
2328 break;
2330 case VEC_COND_EXPR:
2331 pp_string (buffer, " VEC_COND_EXPR < ");
2332 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2333 pp_string (buffer, " , ");
2334 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2335 pp_string (buffer, " , ");
2336 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2337 pp_string (buffer, " > ");
2338 break;
2340 case VEC_PERM_EXPR:
2341 pp_string (buffer, " VEC_PERM_EXPR < ");
2342 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2343 pp_string (buffer, " , ");
2344 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2345 pp_string (buffer, " , ");
2346 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2347 pp_string (buffer, " > ");
2348 break;
2350 case DOT_PROD_EXPR:
2351 pp_string (buffer, " DOT_PROD_EXPR < ");
2352 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2353 pp_string (buffer, ", ");
2354 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2355 pp_string (buffer, ", ");
2356 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2357 pp_string (buffer, " > ");
2358 break;
2360 case WIDEN_MULT_PLUS_EXPR:
2361 pp_string (buffer, " WIDEN_MULT_PLUS_EXPR < ");
2362 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2363 pp_string (buffer, ", ");
2364 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2365 pp_string (buffer, ", ");
2366 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2367 pp_string (buffer, " > ");
2368 break;
2370 case WIDEN_MULT_MINUS_EXPR:
2371 pp_string (buffer, " WIDEN_MULT_MINUS_EXPR < ");
2372 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2373 pp_string (buffer, ", ");
2374 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2375 pp_string (buffer, ", ");
2376 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2377 pp_string (buffer, " > ");
2378 break;
2380 case FMA_EXPR:
2381 pp_string (buffer, " FMA_EXPR < ");
2382 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2383 pp_string (buffer, ", ");
2384 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2385 pp_string (buffer, ", ");
2386 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2387 pp_string (buffer, " > ");
2388 break;
2390 case OMP_PARALLEL:
2391 pp_string (buffer, "#pragma omp parallel");
2392 dump_omp_clauses (buffer, OMP_PARALLEL_CLAUSES (node), spc, flags);
2394 dump_omp_body:
2395 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2397 newline_and_indent (buffer, spc + 2);
2398 pp_left_brace (buffer);
2399 newline_and_indent (buffer, spc + 4);
2400 dump_generic_node (buffer, OMP_BODY (node), spc + 4, flags, false);
2401 newline_and_indent (buffer, spc + 2);
2402 pp_right_brace (buffer);
2404 is_expr = false;
2405 break;
2407 case OMP_TASK:
2408 pp_string (buffer, "#pragma omp task");
2409 dump_omp_clauses (buffer, OMP_TASK_CLAUSES (node), spc, flags);
2410 goto dump_omp_body;
2412 case OMP_FOR:
2413 pp_string (buffer, "#pragma omp for");
2414 goto dump_omp_loop;
2416 case OMP_SIMD:
2417 pp_string (buffer, "#pragma omp simd");
2418 goto dump_omp_loop;
2420 case CILK_SIMD:
2421 pp_string (buffer, "#pragma simd");
2422 goto dump_omp_loop;
2424 case OMP_DISTRIBUTE:
2425 pp_string (buffer, "#pragma omp distribute");
2426 goto dump_omp_loop;
2428 case OMP_TEAMS:
2429 pp_string (buffer, "#pragma omp teams");
2430 dump_omp_clauses (buffer, OMP_TEAMS_CLAUSES (node), spc, flags);
2431 goto dump_omp_body;
2433 case OMP_TARGET_DATA:
2434 pp_string (buffer, "#pragma omp target data");
2435 dump_omp_clauses (buffer, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2436 goto dump_omp_body;
2438 case OMP_TARGET:
2439 pp_string (buffer, "#pragma omp target");
2440 dump_omp_clauses (buffer, OMP_TARGET_CLAUSES (node), spc, flags);
2441 goto dump_omp_body;
2443 case OMP_TARGET_UPDATE:
2444 pp_string (buffer, "#pragma omp target update");
2445 dump_omp_clauses (buffer, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2446 is_expr = false;
2447 break;
2449 dump_omp_loop:
2450 dump_omp_clauses (buffer, OMP_FOR_CLAUSES (node), spc, flags);
2452 if (!(flags & TDF_SLIM))
2454 int i;
2456 if (OMP_FOR_PRE_BODY (node))
2458 newline_and_indent (buffer, spc + 2);
2459 pp_left_brace (buffer);
2460 spc += 4;
2461 newline_and_indent (buffer, spc);
2462 dump_generic_node (buffer, OMP_FOR_PRE_BODY (node),
2463 spc, flags, false);
2465 if (OMP_FOR_INIT (node))
2467 spc -= 2;
2468 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2470 spc += 2;
2471 newline_and_indent (buffer, spc);
2472 pp_string (buffer, "for (");
2473 dump_generic_node (buffer,
2474 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2475 spc, flags, false);
2476 pp_string (buffer, "; ");
2477 dump_generic_node (buffer,
2478 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2479 spc, flags, false);
2480 pp_string (buffer, "; ");
2481 dump_generic_node (buffer,
2482 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2483 spc, flags, false);
2484 pp_right_paren (buffer);
2487 if (OMP_FOR_BODY (node))
2489 newline_and_indent (buffer, spc + 2);
2490 pp_left_brace (buffer);
2491 newline_and_indent (buffer, spc + 4);
2492 dump_generic_node (buffer, OMP_FOR_BODY (node), spc + 4, flags,
2493 false);
2494 newline_and_indent (buffer, spc + 2);
2495 pp_right_brace (buffer);
2497 if (OMP_FOR_INIT (node))
2498 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
2499 if (OMP_FOR_PRE_BODY (node))
2501 spc -= 4;
2502 newline_and_indent (buffer, spc + 2);
2503 pp_right_brace (buffer);
2506 is_expr = false;
2507 break;
2509 case OMP_SECTIONS:
2510 pp_string (buffer, "#pragma omp sections");
2511 dump_omp_clauses (buffer, OMP_SECTIONS_CLAUSES (node), spc, flags);
2512 goto dump_omp_body;
2514 case OMP_SECTION:
2515 pp_string (buffer, "#pragma omp section");
2516 goto dump_omp_body;
2518 case OMP_MASTER:
2519 pp_string (buffer, "#pragma omp master");
2520 goto dump_omp_body;
2522 case OMP_TASKGROUP:
2523 pp_string (buffer, "#pragma omp taskgroup");
2524 goto dump_omp_body;
2526 case OMP_ORDERED:
2527 pp_string (buffer, "#pragma omp ordered");
2528 goto dump_omp_body;
2530 case OMP_CRITICAL:
2531 pp_string (buffer, "#pragma omp critical");
2532 if (OMP_CRITICAL_NAME (node))
2534 pp_space (buffer);
2535 pp_left_paren (buffer);
2536 dump_generic_node (buffer, OMP_CRITICAL_NAME (node), spc,
2537 flags, false);
2538 pp_right_paren (buffer);
2540 goto dump_omp_body;
2542 case OMP_ATOMIC:
2543 pp_string (buffer, "#pragma omp atomic");
2544 if (OMP_ATOMIC_SEQ_CST (node))
2545 pp_string (buffer, " seq_cst");
2546 newline_and_indent (buffer, spc + 2);
2547 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2548 pp_space (buffer);
2549 pp_equal (buffer);
2550 pp_space (buffer);
2551 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2552 break;
2554 case OMP_ATOMIC_READ:
2555 pp_string (buffer, "#pragma omp atomic read");
2556 if (OMP_ATOMIC_SEQ_CST (node))
2557 pp_string (buffer, " seq_cst");
2558 newline_and_indent (buffer, spc + 2);
2559 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2560 pp_space (buffer);
2561 break;
2563 case OMP_ATOMIC_CAPTURE_OLD:
2564 case OMP_ATOMIC_CAPTURE_NEW:
2565 pp_string (buffer, "#pragma omp atomic capture");
2566 if (OMP_ATOMIC_SEQ_CST (node))
2567 pp_string (buffer, " seq_cst");
2568 newline_and_indent (buffer, spc + 2);
2569 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2570 pp_space (buffer);
2571 pp_equal (buffer);
2572 pp_space (buffer);
2573 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2574 break;
2576 case OMP_SINGLE:
2577 pp_string (buffer, "#pragma omp single");
2578 dump_omp_clauses (buffer, OMP_SINGLE_CLAUSES (node), spc, flags);
2579 goto dump_omp_body;
2581 case OMP_CLAUSE:
2582 dump_omp_clause (buffer, node, spc, flags);
2583 is_expr = false;
2584 break;
2586 case TRANSACTION_EXPR:
2587 if (TRANSACTION_EXPR_OUTER (node))
2588 pp_string (buffer, "__transaction_atomic [[outer]]");
2589 else if (TRANSACTION_EXPR_RELAXED (node))
2590 pp_string (buffer, "__transaction_relaxed");
2591 else
2592 pp_string (buffer, "__transaction_atomic");
2593 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
2595 newline_and_indent (buffer, spc);
2596 pp_left_brace (buffer);
2597 newline_and_indent (buffer, spc + 2);
2598 dump_generic_node (buffer, TRANSACTION_EXPR_BODY (node),
2599 spc + 2, flags, false);
2600 newline_and_indent (buffer, spc);
2601 pp_right_brace (buffer);
2603 is_expr = false;
2604 break;
2606 case REDUC_MAX_EXPR:
2607 pp_string (buffer, " REDUC_MAX_EXPR < ");
2608 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2609 pp_string (buffer, " > ");
2610 break;
2612 case REDUC_MIN_EXPR:
2613 pp_string (buffer, " REDUC_MIN_EXPR < ");
2614 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2615 pp_string (buffer, " > ");
2616 break;
2618 case REDUC_PLUS_EXPR:
2619 pp_string (buffer, " REDUC_PLUS_EXPR < ");
2620 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2621 pp_string (buffer, " > ");
2622 break;
2624 case VEC_WIDEN_MULT_HI_EXPR:
2625 case VEC_WIDEN_MULT_LO_EXPR:
2626 case VEC_WIDEN_MULT_EVEN_EXPR:
2627 case VEC_WIDEN_MULT_ODD_EXPR:
2628 case VEC_WIDEN_LSHIFT_HI_EXPR:
2629 case VEC_WIDEN_LSHIFT_LO_EXPR:
2630 pp_space (buffer);
2631 for (str = get_tree_code_name (code); *str; str++)
2632 pp_character (buffer, TOUPPER (*str));
2633 pp_string (buffer, " < ");
2634 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2635 pp_string (buffer, ", ");
2636 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2637 pp_string (buffer, " > ");
2638 break;
2640 case VEC_UNPACK_HI_EXPR:
2641 pp_string (buffer, " VEC_UNPACK_HI_EXPR < ");
2642 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2643 pp_string (buffer, " > ");
2644 break;
2646 case VEC_UNPACK_LO_EXPR:
2647 pp_string (buffer, " VEC_UNPACK_LO_EXPR < ");
2648 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2649 pp_string (buffer, " > ");
2650 break;
2652 case VEC_UNPACK_FLOAT_HI_EXPR:
2653 pp_string (buffer, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2654 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2655 pp_string (buffer, " > ");
2656 break;
2658 case VEC_UNPACK_FLOAT_LO_EXPR:
2659 pp_string (buffer, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2660 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2661 pp_string (buffer, " > ");
2662 break;
2664 case VEC_PACK_TRUNC_EXPR:
2665 pp_string (buffer, " VEC_PACK_TRUNC_EXPR < ");
2666 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2667 pp_string (buffer, ", ");
2668 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2669 pp_string (buffer, " > ");
2670 break;
2672 case VEC_PACK_SAT_EXPR:
2673 pp_string (buffer, " VEC_PACK_SAT_EXPR < ");
2674 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2675 pp_string (buffer, ", ");
2676 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2677 pp_string (buffer, " > ");
2678 break;
2680 case VEC_PACK_FIX_TRUNC_EXPR:
2681 pp_string (buffer, " VEC_PACK_FIX_TRUNC_EXPR < ");
2682 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2683 pp_string (buffer, ", ");
2684 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2685 pp_string (buffer, " > ");
2686 break;
2688 case BLOCK:
2689 dump_block_node (buffer, node, spc, flags);
2690 break;
2692 case CILK_SPAWN_STMT:
2693 pp_string (buffer, "_Cilk_spawn ");
2694 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2695 break;
2697 case CILK_SYNC_STMT:
2698 pp_string (buffer, "_Cilk_sync");
2699 break;
2701 default:
2702 NIY;
2705 if (is_stmt && is_expr)
2706 pp_semicolon (buffer);
2708 return spc;
2711 /* Print the declaration of a variable. */
2713 void
2714 print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
2716 INDENT (spc);
2718 if (TREE_CODE(t) == NAMELIST_DECL)
2720 pp_string(buffer, "namelist ");
2721 dump_decl_name (buffer, t, flags);
2722 pp_semicolon (buffer);
2723 return;
2726 if (TREE_CODE (t) == TYPE_DECL)
2727 pp_string (buffer, "typedef ");
2729 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
2730 pp_string (buffer, "register ");
2732 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2733 pp_string (buffer, "extern ");
2734 else if (TREE_STATIC (t))
2735 pp_string (buffer, "static ");
2737 /* Print the type and name. */
2738 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2740 tree tmp;
2742 /* Print array's type. */
2743 tmp = TREE_TYPE (t);
2744 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2745 tmp = TREE_TYPE (tmp);
2746 dump_generic_node (buffer, TREE_TYPE (tmp), spc, flags, false);
2748 /* Print variable's name. */
2749 pp_space (buffer);
2750 dump_generic_node (buffer, t, spc, flags, false);
2752 /* Print the dimensions. */
2753 tmp = TREE_TYPE (t);
2754 while (TREE_CODE (tmp) == ARRAY_TYPE)
2756 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
2757 tmp = TREE_TYPE (tmp);
2760 else if (TREE_CODE (t) == FUNCTION_DECL)
2762 dump_generic_node (buffer, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
2763 pp_space (buffer);
2764 dump_decl_name (buffer, t, flags);
2765 dump_function_declaration (buffer, TREE_TYPE (t), spc, flags);
2767 else
2769 /* Print type declaration. */
2770 dump_generic_node (buffer, TREE_TYPE (t), spc, flags, false);
2772 /* Print variable's name. */
2773 pp_space (buffer);
2774 dump_generic_node (buffer, t, spc, flags, false);
2777 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
2779 pp_string (buffer, " __asm__ ");
2780 pp_left_paren (buffer);
2781 dump_generic_node (buffer, DECL_ASSEMBLER_NAME (t), spc, flags, false);
2782 pp_right_paren (buffer);
2785 /* The initial value of a function serves to determine whether the function
2786 is declared or defined. So the following does not apply to function
2787 nodes. */
2788 if (TREE_CODE (t) != FUNCTION_DECL)
2790 /* Print the initial value. */
2791 if (DECL_INITIAL (t))
2793 pp_space (buffer);
2794 pp_equal (buffer);
2795 pp_space (buffer);
2796 dump_generic_node (buffer, DECL_INITIAL (t), spc, flags, false);
2800 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
2802 pp_string (buffer, " [value-expr: ");
2803 dump_generic_node (buffer, DECL_VALUE_EXPR (t), spc, flags, false);
2804 pp_right_bracket (buffer);
2807 pp_semicolon (buffer);
2811 /* Prints a structure: name, fields, and methods.
2812 FIXME: Still incomplete. */
2814 static void
2815 print_struct_decl (pretty_printer *buffer, const_tree node, int spc, int flags)
2817 /* Print the name of the structure. */
2818 if (TYPE_NAME (node))
2820 INDENT (spc);
2821 if (TREE_CODE (node) == RECORD_TYPE)
2822 pp_string (buffer, "struct ");
2823 else if ((TREE_CODE (node) == UNION_TYPE
2824 || TREE_CODE (node) == QUAL_UNION_TYPE))
2825 pp_string (buffer, "union ");
2827 dump_generic_node (buffer, TYPE_NAME (node), spc, 0, false);
2830 /* Print the contents of the structure. */
2831 pp_newline (buffer);
2832 INDENT (spc);
2833 pp_left_brace (buffer);
2834 pp_newline (buffer);
2836 /* Print the fields of the structure. */
2838 tree tmp;
2839 tmp = TYPE_FIELDS (node);
2840 while (tmp)
2842 /* Avoid to print recursively the structure. */
2843 /* FIXME : Not implemented correctly...,
2844 what about the case when we have a cycle in the contain graph? ...
2845 Maybe this could be solved by looking at the scope in which the
2846 structure was declared. */
2847 if (TREE_TYPE (tmp) != node
2848 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
2849 || TREE_TYPE (TREE_TYPE (tmp)) != node))
2851 print_declaration (buffer, tmp, spc+2, flags);
2852 pp_newline (buffer);
2854 tmp = DECL_CHAIN (tmp);
2857 INDENT (spc);
2858 pp_right_brace (buffer);
2861 /* Return the priority of the operator CODE.
2863 From lowest to highest precedence with either left-to-right (L-R)
2864 or right-to-left (R-L) associativity]:
2866 1 [L-R] ,
2867 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2868 3 [R-L] ?:
2869 4 [L-R] ||
2870 5 [L-R] &&
2871 6 [L-R] |
2872 7 [L-R] ^
2873 8 [L-R] &
2874 9 [L-R] == !=
2875 10 [L-R] < <= > >=
2876 11 [L-R] << >>
2877 12 [L-R] + -
2878 13 [L-R] * / %
2879 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2880 15 [L-R] fn() [] -> .
2882 unary +, - and * have higher precedence than the corresponding binary
2883 operators. */
2886 op_code_prio (enum tree_code code)
2888 switch (code)
2890 case TREE_LIST:
2891 case COMPOUND_EXPR:
2892 case BIND_EXPR:
2893 return 1;
2895 case MODIFY_EXPR:
2896 case INIT_EXPR:
2897 return 2;
2899 case COND_EXPR:
2900 return 3;
2902 case TRUTH_OR_EXPR:
2903 case TRUTH_ORIF_EXPR:
2904 return 4;
2906 case TRUTH_AND_EXPR:
2907 case TRUTH_ANDIF_EXPR:
2908 return 5;
2910 case BIT_IOR_EXPR:
2911 return 6;
2913 case BIT_XOR_EXPR:
2914 case TRUTH_XOR_EXPR:
2915 return 7;
2917 case BIT_AND_EXPR:
2918 return 8;
2920 case EQ_EXPR:
2921 case NE_EXPR:
2922 return 9;
2924 case UNLT_EXPR:
2925 case UNLE_EXPR:
2926 case UNGT_EXPR:
2927 case UNGE_EXPR:
2928 case UNEQ_EXPR:
2929 case LTGT_EXPR:
2930 case ORDERED_EXPR:
2931 case UNORDERED_EXPR:
2932 case LT_EXPR:
2933 case LE_EXPR:
2934 case GT_EXPR:
2935 case GE_EXPR:
2936 return 10;
2938 case LSHIFT_EXPR:
2939 case RSHIFT_EXPR:
2940 case LROTATE_EXPR:
2941 case RROTATE_EXPR:
2942 case VEC_WIDEN_LSHIFT_HI_EXPR:
2943 case VEC_WIDEN_LSHIFT_LO_EXPR:
2944 case WIDEN_LSHIFT_EXPR:
2945 return 11;
2947 case WIDEN_SUM_EXPR:
2948 case PLUS_EXPR:
2949 case POINTER_PLUS_EXPR:
2950 case MINUS_EXPR:
2951 return 12;
2953 case VEC_WIDEN_MULT_HI_EXPR:
2954 case VEC_WIDEN_MULT_LO_EXPR:
2955 case WIDEN_MULT_EXPR:
2956 case DOT_PROD_EXPR:
2957 case WIDEN_MULT_PLUS_EXPR:
2958 case WIDEN_MULT_MINUS_EXPR:
2959 case MULT_EXPR:
2960 case MULT_HIGHPART_EXPR:
2961 case TRUNC_DIV_EXPR:
2962 case CEIL_DIV_EXPR:
2963 case FLOOR_DIV_EXPR:
2964 case ROUND_DIV_EXPR:
2965 case RDIV_EXPR:
2966 case EXACT_DIV_EXPR:
2967 case TRUNC_MOD_EXPR:
2968 case CEIL_MOD_EXPR:
2969 case FLOOR_MOD_EXPR:
2970 case ROUND_MOD_EXPR:
2971 case FMA_EXPR:
2972 return 13;
2974 case TRUTH_NOT_EXPR:
2975 case BIT_NOT_EXPR:
2976 case POSTINCREMENT_EXPR:
2977 case POSTDECREMENT_EXPR:
2978 case PREINCREMENT_EXPR:
2979 case PREDECREMENT_EXPR:
2980 case NEGATE_EXPR:
2981 case INDIRECT_REF:
2982 case ADDR_EXPR:
2983 case FLOAT_EXPR:
2984 CASE_CONVERT:
2985 case FIX_TRUNC_EXPR:
2986 case TARGET_EXPR:
2987 return 14;
2989 case CALL_EXPR:
2990 case ARRAY_REF:
2991 case ARRAY_RANGE_REF:
2992 case COMPONENT_REF:
2993 return 15;
2995 /* Special expressions. */
2996 case MIN_EXPR:
2997 case MAX_EXPR:
2998 case ABS_EXPR:
2999 case REALPART_EXPR:
3000 case IMAGPART_EXPR:
3001 case REDUC_MAX_EXPR:
3002 case REDUC_MIN_EXPR:
3003 case REDUC_PLUS_EXPR:
3004 case VEC_LSHIFT_EXPR:
3005 case VEC_RSHIFT_EXPR:
3006 case VEC_UNPACK_HI_EXPR:
3007 case VEC_UNPACK_LO_EXPR:
3008 case VEC_UNPACK_FLOAT_HI_EXPR:
3009 case VEC_UNPACK_FLOAT_LO_EXPR:
3010 case VEC_PACK_TRUNC_EXPR:
3011 case VEC_PACK_SAT_EXPR:
3012 return 16;
3014 default:
3015 /* Return an arbitrarily high precedence to avoid surrounding single
3016 VAR_DECLs in ()s. */
3017 return 9999;
3021 /* Return the priority of the operator OP. */
3024 op_prio (const_tree op)
3026 enum tree_code code;
3028 if (op == NULL)
3029 return 9999;
3031 code = TREE_CODE (op);
3032 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3033 return op_prio (TREE_OPERAND (op, 0));
3035 return op_code_prio (code);
3038 /* Return the symbol associated with operator CODE. */
3040 const char *
3041 op_symbol_code (enum tree_code code)
3043 switch (code)
3045 case MODIFY_EXPR:
3046 return "=";
3048 case TRUTH_OR_EXPR:
3049 case TRUTH_ORIF_EXPR:
3050 return "||";
3052 case TRUTH_AND_EXPR:
3053 case TRUTH_ANDIF_EXPR:
3054 return "&&";
3056 case BIT_IOR_EXPR:
3057 return "|";
3059 case TRUTH_XOR_EXPR:
3060 case BIT_XOR_EXPR:
3061 return "^";
3063 case ADDR_EXPR:
3064 case BIT_AND_EXPR:
3065 return "&";
3067 case ORDERED_EXPR:
3068 return "ord";
3069 case UNORDERED_EXPR:
3070 return "unord";
3072 case EQ_EXPR:
3073 return "==";
3074 case UNEQ_EXPR:
3075 return "u==";
3077 case NE_EXPR:
3078 return "!=";
3080 case LT_EXPR:
3081 return "<";
3082 case UNLT_EXPR:
3083 return "u<";
3085 case LE_EXPR:
3086 return "<=";
3087 case UNLE_EXPR:
3088 return "u<=";
3090 case GT_EXPR:
3091 return ">";
3092 case UNGT_EXPR:
3093 return "u>";
3095 case GE_EXPR:
3096 return ">=";
3097 case UNGE_EXPR:
3098 return "u>=";
3100 case LTGT_EXPR:
3101 return "<>";
3103 case LSHIFT_EXPR:
3104 return "<<";
3106 case RSHIFT_EXPR:
3107 return ">>";
3109 case LROTATE_EXPR:
3110 return "r<<";
3112 case RROTATE_EXPR:
3113 return "r>>";
3115 case VEC_LSHIFT_EXPR:
3116 return "v<<";
3118 case VEC_RSHIFT_EXPR:
3119 return "v>>";
3121 case WIDEN_LSHIFT_EXPR:
3122 return "w<<";
3124 case POINTER_PLUS_EXPR:
3125 return "+";
3127 case PLUS_EXPR:
3128 return "+";
3130 case REDUC_PLUS_EXPR:
3131 return "r+";
3133 case WIDEN_SUM_EXPR:
3134 return "w+";
3136 case WIDEN_MULT_EXPR:
3137 return "w*";
3139 case MULT_HIGHPART_EXPR:
3140 return "h*";
3142 case NEGATE_EXPR:
3143 case MINUS_EXPR:
3144 return "-";
3146 case BIT_NOT_EXPR:
3147 return "~";
3149 case TRUTH_NOT_EXPR:
3150 return "!";
3152 case MULT_EXPR:
3153 case INDIRECT_REF:
3154 return "*";
3156 case TRUNC_DIV_EXPR:
3157 case RDIV_EXPR:
3158 return "/";
3160 case CEIL_DIV_EXPR:
3161 return "/[cl]";
3163 case FLOOR_DIV_EXPR:
3164 return "/[fl]";
3166 case ROUND_DIV_EXPR:
3167 return "/[rd]";
3169 case EXACT_DIV_EXPR:
3170 return "/[ex]";
3172 case TRUNC_MOD_EXPR:
3173 return "%";
3175 case CEIL_MOD_EXPR:
3176 return "%[cl]";
3178 case FLOOR_MOD_EXPR:
3179 return "%[fl]";
3181 case ROUND_MOD_EXPR:
3182 return "%[rd]";
3184 case PREDECREMENT_EXPR:
3185 return " --";
3187 case PREINCREMENT_EXPR:
3188 return " ++";
3190 case POSTDECREMENT_EXPR:
3191 return "-- ";
3193 case POSTINCREMENT_EXPR:
3194 return "++ ";
3196 case MAX_EXPR:
3197 return "max";
3199 case MIN_EXPR:
3200 return "min";
3202 default:
3203 return "<<< ??? >>>";
3207 /* Return the symbol associated with operator OP. */
3209 static const char *
3210 op_symbol (const_tree op)
3212 return op_symbol_code (TREE_CODE (op));
3215 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3216 the gimple_call_fn of a GIMPLE_CALL. */
3218 void
3219 print_call_name (pretty_printer *buffer, tree node, int flags)
3221 tree op0 = node;
3223 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3224 op0 = TREE_OPERAND (op0, 0);
3226 again:
3227 switch (TREE_CODE (op0))
3229 case VAR_DECL:
3230 case PARM_DECL:
3231 case FUNCTION_DECL:
3232 dump_function_name (buffer, op0, flags);
3233 break;
3235 case ADDR_EXPR:
3236 case INDIRECT_REF:
3237 case NOP_EXPR:
3238 op0 = TREE_OPERAND (op0, 0);
3239 goto again;
3241 case COND_EXPR:
3242 pp_left_paren (buffer);
3243 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, flags, false);
3244 pp_string (buffer, ") ? ");
3245 dump_generic_node (buffer, TREE_OPERAND (op0, 1), 0, flags, false);
3246 pp_string (buffer, " : ");
3247 dump_generic_node (buffer, TREE_OPERAND (op0, 2), 0, flags, false);
3248 break;
3250 case ARRAY_REF:
3251 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3252 dump_function_name (buffer, TREE_OPERAND (op0, 0), flags);
3253 else
3254 dump_generic_node (buffer, op0, 0, flags, false);
3255 break;
3257 case MEM_REF:
3258 if (integer_zerop (TREE_OPERAND (op0, 1)))
3260 op0 = TREE_OPERAND (op0, 0);
3261 goto again;
3263 /* Fallthru. */
3264 case COMPONENT_REF:
3265 case SSA_NAME:
3266 case OBJ_TYPE_REF:
3267 dump_generic_node (buffer, op0, 0, flags, false);
3268 break;
3270 default:
3271 NIY;
3275 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3277 static void
3278 pretty_print_string (pretty_printer *buffer, const char *str)
3280 if (str == NULL)
3281 return;
3283 while (*str)
3285 switch (str[0])
3287 case '\b':
3288 pp_string (buffer, "\\b");
3289 break;
3291 case '\f':
3292 pp_string (buffer, "\\f");
3293 break;
3295 case '\n':
3296 pp_string (buffer, "\\n");
3297 break;
3299 case '\r':
3300 pp_string (buffer, "\\r");
3301 break;
3303 case '\t':
3304 pp_string (buffer, "\\t");
3305 break;
3307 case '\v':
3308 pp_string (buffer, "\\v");
3309 break;
3311 case '\\':
3312 pp_string (buffer, "\\\\");
3313 break;
3315 case '\"':
3316 pp_string (buffer, "\\\"");
3317 break;
3319 case '\'':
3320 pp_string (buffer, "\\'");
3321 break;
3323 /* No need to handle \0; the loop terminates on \0. */
3325 case '\1':
3326 pp_string (buffer, "\\1");
3327 break;
3329 case '\2':
3330 pp_string (buffer, "\\2");
3331 break;
3333 case '\3':
3334 pp_string (buffer, "\\3");
3335 break;
3337 case '\4':
3338 pp_string (buffer, "\\4");
3339 break;
3341 case '\5':
3342 pp_string (buffer, "\\5");
3343 break;
3345 case '\6':
3346 pp_string (buffer, "\\6");
3347 break;
3349 case '\7':
3350 pp_string (buffer, "\\7");
3351 break;
3353 default:
3354 pp_character (buffer, str[0]);
3355 break;
3357 str++;
3361 static void
3362 maybe_init_pretty_print (FILE *file)
3364 if (!initialized)
3366 new (&buffer) pretty_printer ();
3367 pp_needs_newline (&buffer) = true;
3368 pp_translate_identifiers (&buffer) = false;
3369 initialized = 1;
3372 buffer.buffer->stream = file;
3375 static void
3376 newline_and_indent (pretty_printer *buffer, int spc)
3378 pp_newline (buffer);
3379 INDENT (spc);
3382 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3383 it can also be used in front ends.
3384 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3387 void
3388 percent_K_format (text_info *text)
3390 tree t = va_arg (*text->args_ptr, tree), block;
3391 gcc_assert (text->locus != NULL);
3392 *text->locus = EXPR_LOCATION (t);
3393 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3394 block = TREE_BLOCK (t);
3395 *pp_ti_abstract_origin (text) = NULL;
3397 if (in_lto_p)
3399 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3400 representing the outermost block of an inlined function.
3401 So walk the BLOCK tree until we hit such a scope. */
3402 while (block
3403 && TREE_CODE (block) == BLOCK)
3405 if (inlined_function_outer_scope_p (block))
3407 *pp_ti_abstract_origin (text) = block;
3408 break;
3410 block = BLOCK_SUPERCONTEXT (block);
3412 return;
3415 while (block
3416 && TREE_CODE (block) == BLOCK
3417 && BLOCK_ABSTRACT_ORIGIN (block))
3419 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3421 while (TREE_CODE (ao) == BLOCK
3422 && BLOCK_ABSTRACT_ORIGIN (ao)
3423 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3424 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3426 if (TREE_CODE (ao) == FUNCTION_DECL)
3428 *pp_ti_abstract_origin (text) = block;
3429 break;
3431 block = BLOCK_SUPERCONTEXT (block);
3435 /* Print the identifier ID to PRETTY-PRINTER. */
3437 void
3438 pp_tree_identifier (pretty_printer *pp, tree id)
3440 if (pp_translate_identifiers (pp))
3442 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3443 pp_append_text (pp, text, text + strlen (text));
3445 else
3446 pp_append_text (pp, IDENTIFIER_POINTER (id),
3447 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3450 /* A helper function that is used to dump function information before the
3451 function dump. */
3453 void
3454 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3456 const char *dname, *aname;
3457 struct cgraph_node *node = cgraph_node::get (fdecl);
3458 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3460 dname = lang_hooks.decl_printable_name (fdecl, 2);
3462 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3463 aname = (IDENTIFIER_POINTER
3464 (DECL_ASSEMBLER_NAME (fdecl)));
3465 else
3466 aname = "<unset-asm-name>";
3468 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3469 dname, aname, fun->funcdef_no);
3470 if (!(flags & TDF_NOUID))
3471 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3472 if (node)
3474 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
3475 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3476 node->frequency == NODE_FREQUENCY_HOT
3477 ? " (hot)"
3478 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3479 ? " (unlikely executed)"
3480 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3481 ? " (executed once)"
3482 : "");
3484 else
3485 fprintf (dump_file, ")\n\n");
3488 /* Dump double_int D to pretty_printer PP. UNS is true
3489 if D is unsigned and false otherwise. */
3490 void
3491 pp_double_int (pretty_printer *pp, double_int d, bool uns)
3493 if (d.fits_shwi ())
3494 pp_wide_integer (pp, d.low);
3495 else if (d.fits_uhwi ())
3496 pp_unsigned_wide_integer (pp, d.low);
3497 else
3499 unsigned HOST_WIDE_INT low = d.low;
3500 HOST_WIDE_INT high = d.high;
3501 if (!uns && d.is_negative ())
3503 pp_minus (pp);
3504 high = ~high + !low;
3505 low = -low;
3507 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3508 systems? */
3509 sprintf (pp_buffer (pp)->digit_buffer,
3510 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3511 (unsigned HOST_WIDE_INT) high, low);
3512 pp_string (pp, pp_buffer (pp)->digit_buffer);