1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
3 Free Software Foundation, Inc.
4 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
24 #include "coretypes.h"
28 #include "diagnostic.h"
31 #include "tree-flow.h"
32 #include "langhooks.h"
33 #include "tree-iterator.h"
34 #include "tree-chrec.h"
35 #include "tree-pass.h"
36 #include "fixed-value.h"
37 #include "value-prof.h"
40 /* Local functions, macros and variables. */
41 static const char *op_symbol (const_tree
);
42 static void pretty_print_string (pretty_printer
*, const char*);
43 static void newline_and_indent (pretty_printer
*, int);
44 static void maybe_init_pretty_print (FILE *);
45 static void print_struct_decl (pretty_printer
*, const_tree
, int, int);
46 static void do_niy (pretty_printer
*, const_tree
);
48 #define INDENT(SPACE) do { \
49 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
51 #define NIY do_niy(buffer,node)
53 static pretty_printer buffer
;
54 static int initialized
= 0;
56 /* Try to print something for an unknown tree code. */
59 do_niy (pretty_printer
*buffer
, const_tree node
)
63 pp_string (buffer
, "<<< Unknown tree: ");
64 pp_string (buffer
, tree_code_name
[(int) TREE_CODE (node
)]);
68 len
= TREE_OPERAND_LENGTH (node
);
69 for (i
= 0; i
< len
; ++i
)
71 newline_and_indent (buffer
, 2);
72 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0, false);
76 pp_string (buffer
, " >>>\n");
79 /* Debugging function to print out a generic expression. */
82 debug_generic_expr (tree t
)
84 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
85 fprintf (stderr
, "\n");
88 /* Debugging function to print out a generic statement. */
91 debug_generic_stmt (tree t
)
93 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
94 fprintf (stderr
, "\n");
97 /* Debugging function to print out a chain of trees . */
100 debug_tree_chain (tree t
)
102 struct pointer_set_t
*seen
= pointer_set_create ();
106 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
107 fprintf (stderr
, " ");
109 if (pointer_set_insert (seen
, t
))
111 fprintf (stderr
, "... [cycled back to ");
112 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
113 fprintf (stderr
, "]");
117 fprintf (stderr
, "\n");
119 pointer_set_destroy (seen
);
122 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
124 print_generic_decl (FILE *file
, tree decl
, int flags
)
126 maybe_init_pretty_print (file
);
127 print_declaration (&buffer
, decl
, 2, flags
);
128 pp_write_text_to_stream (&buffer
);
131 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
132 to show in the dump. See TDF_* in tree-pass.h. */
135 print_generic_stmt (FILE *file
, tree t
, int flags
)
137 maybe_init_pretty_print (file
);
138 dump_generic_node (&buffer
, t
, 0, flags
, true);
142 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
143 to show in the dump. See TDF_* in tree-pass.h. The output is indented by
147 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
151 maybe_init_pretty_print (file
);
153 for (i
= 0; i
< indent
; i
++)
155 dump_generic_node (&buffer
, t
, indent
, flags
, true);
159 /* Print a single expression T on file FILE. FLAGS specifies details to show
160 in the dump. See TDF_* in tree-pass.h. */
163 print_generic_expr (FILE *file
, tree t
, int flags
)
165 maybe_init_pretty_print (file
);
166 dump_generic_node (&buffer
, t
, 0, flags
, false);
169 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
173 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
175 if (DECL_NAME (node
))
177 if ((flags
& TDF_ASMNAME
) && DECL_ASSEMBLER_NAME_SET_P (node
))
178 pp_tree_identifier (buffer
, DECL_ASSEMBLER_NAME (node
));
180 pp_tree_identifier (buffer
, DECL_NAME (node
));
182 if ((flags
& TDF_UID
) || DECL_NAME (node
) == NULL_TREE
)
184 if (TREE_CODE (node
) == LABEL_DECL
&& LABEL_DECL_UID (node
) != -1)
185 pp_printf (buffer
, "L.%d", (int) LABEL_DECL_UID (node
));
188 char c
= TREE_CODE (node
) == CONST_DECL
? 'C' : 'D';
189 pp_printf (buffer
, "%c.%u", c
, DECL_UID (node
));
194 /* Like the above, but used for pretty printing function calls. */
197 dump_function_name (pretty_printer
*buffer
, tree node
, int flags
)
199 if (TREE_CODE (node
) == NOP_EXPR
)
200 node
= TREE_OPERAND (node
, 0);
201 if (DECL_NAME (node
) && (flags
& TDF_ASMNAME
) == 0)
202 pp_string (buffer
, lang_hooks
.decl_printable_name (node
, 1));
204 dump_decl_name (buffer
, node
, flags
);
207 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
208 FLAGS are as in dump_generic_node. */
211 dump_function_declaration (pretty_printer
*buffer
, tree node
,
214 bool wrote_arg
= false;
218 pp_character (buffer
, '(');
220 /* Print the argument types. The last element in the list is a VOID_TYPE.
221 The following avoids printing the last element. */
222 arg
= TYPE_ARG_TYPES (node
);
223 while (arg
&& TREE_CHAIN (arg
) && arg
!= error_mark_node
)
226 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
227 arg
= TREE_CHAIN (arg
);
228 if (TREE_CHAIN (arg
) && TREE_CODE (TREE_CHAIN (arg
)) == TREE_LIST
)
230 pp_character (buffer
, ',');
236 pp_string (buffer
, "void");
238 pp_character (buffer
, ')');
241 /* Dump the domain associated with an array. */
244 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
246 pp_character (buffer
, '[');
249 tree min
= TYPE_MIN_VALUE (domain
);
250 tree max
= TYPE_MAX_VALUE (domain
);
253 && integer_zerop (min
)
254 && host_integerp (max
, 0))
255 pp_wide_integer (buffer
, TREE_INT_CST_LOW (max
) + 1);
259 dump_generic_node (buffer
, min
, spc
, flags
, false);
260 pp_character (buffer
, ':');
262 dump_generic_node (buffer
, max
, spc
, flags
, false);
266 pp_string (buffer
, "<unknown>");
267 pp_character (buffer
, ']');
271 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
272 dump_generic_node. */
275 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
279 switch (OMP_CLAUSE_CODE (clause
))
281 case OMP_CLAUSE_PRIVATE
:
284 case OMP_CLAUSE_SHARED
:
287 case OMP_CLAUSE_FIRSTPRIVATE
:
288 name
= "firstprivate";
290 case OMP_CLAUSE_LASTPRIVATE
:
291 name
= "lastprivate";
293 case OMP_CLAUSE_COPYIN
:
296 case OMP_CLAUSE_COPYPRIVATE
:
297 name
= "copyprivate";
300 pp_string (buffer
, name
);
301 pp_character (buffer
, '(');
302 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
304 pp_character (buffer
, ')');
307 case OMP_CLAUSE_REDUCTION
:
308 pp_string (buffer
, "reduction(");
309 pp_string (buffer
, op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
310 pp_character (buffer
, ':');
311 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
313 pp_character (buffer
, ')');
317 pp_string (buffer
, "if(");
318 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
320 pp_character (buffer
, ')');
323 case OMP_CLAUSE_NUM_THREADS
:
324 pp_string (buffer
, "num_threads(");
325 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
327 pp_character (buffer
, ')');
330 case OMP_CLAUSE_NOWAIT
:
331 pp_string (buffer
, "nowait");
333 case OMP_CLAUSE_ORDERED
:
334 pp_string (buffer
, "ordered");
337 case OMP_CLAUSE_DEFAULT
:
338 pp_string (buffer
, "default(");
339 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
341 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
343 case OMP_CLAUSE_DEFAULT_SHARED
:
344 pp_string (buffer
, "shared");
346 case OMP_CLAUSE_DEFAULT_NONE
:
347 pp_string (buffer
, "none");
349 case OMP_CLAUSE_DEFAULT_PRIVATE
:
350 pp_string (buffer
, "private");
352 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE
:
353 pp_string (buffer
, "firstprivate");
358 pp_character (buffer
, ')');
361 case OMP_CLAUSE_SCHEDULE
:
362 pp_string (buffer
, "schedule(");
363 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
365 case OMP_CLAUSE_SCHEDULE_STATIC
:
366 pp_string (buffer
, "static");
368 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
369 pp_string (buffer
, "dynamic");
371 case OMP_CLAUSE_SCHEDULE_GUIDED
:
372 pp_string (buffer
, "guided");
374 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
375 pp_string (buffer
, "runtime");
377 case OMP_CLAUSE_SCHEDULE_AUTO
:
378 pp_string (buffer
, "auto");
383 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
385 pp_character (buffer
, ',');
386 dump_generic_node (buffer
,
387 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
390 pp_character (buffer
, ')');
393 case OMP_CLAUSE_UNTIED
:
394 pp_string (buffer
, "untied");
397 case OMP_CLAUSE_COLLAPSE
:
398 pp_string (buffer
, "collapse(");
399 dump_generic_node (buffer
,
400 OMP_CLAUSE_COLLAPSE_EXPR (clause
),
402 pp_character (buffer
, ')');
406 /* Should never happen. */
407 dump_generic_node (buffer
, clause
, spc
, flags
, false);
413 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
414 dump_generic_node. */
417 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
425 dump_omp_clause (buffer
, clause
, spc
, flags
);
426 clause
= OMP_CLAUSE_CHAIN (clause
);
434 /* Dump location LOC to BUFFER. */
437 dump_location (pretty_printer
*buffer
, location_t loc
)
439 expanded_location xloc
= expand_location (loc
);
441 pp_character (buffer
, '[');
444 pp_string (buffer
, xloc
.file
);
445 pp_string (buffer
, " : ");
447 pp_decimal_int (buffer
, xloc
.line
);
448 pp_string (buffer
, "] ");
452 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
453 dump_generic_node. */
456 dump_block_node (pretty_printer
*buffer
, tree block
, int spc
, int flags
)
460 pp_printf (buffer
, "BLOCK #%d ", BLOCK_NUMBER (block
));
462 if (flags
& TDF_ADDRESS
)
463 pp_printf (buffer
, "[%p] ", (void *) block
);
465 if (BLOCK_ABSTRACT (block
))
466 pp_string (buffer
, "[abstract] ");
468 if (TREE_ASM_WRITTEN (block
))
469 pp_string (buffer
, "[written] ");
471 if (flags
& TDF_SLIM
)
474 if (BLOCK_SOURCE_LOCATION (block
))
475 dump_location (buffer
, BLOCK_SOURCE_LOCATION (block
));
477 newline_and_indent (buffer
, spc
+ 2);
479 if (BLOCK_SUPERCONTEXT (block
))
481 pp_string (buffer
, "SUPERCONTEXT: ");
482 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (block
), 0,
483 flags
| TDF_SLIM
, false);
484 newline_and_indent (buffer
, spc
+ 2);
487 if (BLOCK_SUBBLOCKS (block
))
489 pp_string (buffer
, "SUBBLOCKS: ");
490 for (t
= BLOCK_SUBBLOCKS (block
); t
; t
= BLOCK_CHAIN (t
))
492 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
493 pp_string (buffer
, " ");
495 newline_and_indent (buffer
, spc
+ 2);
498 if (BLOCK_CHAIN (block
))
500 pp_string (buffer
, "SIBLINGS: ");
501 for (t
= BLOCK_CHAIN (block
); t
; t
= BLOCK_CHAIN (t
))
503 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
504 pp_string (buffer
, " ");
506 newline_and_indent (buffer
, spc
+ 2);
509 if (BLOCK_VARS (block
))
511 pp_string (buffer
, "VARS: ");
512 for (t
= BLOCK_VARS (block
); t
; t
= TREE_CHAIN (t
))
514 dump_generic_node (buffer
, t
, 0, flags
, false);
515 pp_string (buffer
, " ");
517 newline_and_indent (buffer
, spc
+ 2);
520 if (VEC_length (tree
, BLOCK_NONLOCALIZED_VARS (block
)) > 0)
523 VEC(tree
,gc
) *nlv
= BLOCK_NONLOCALIZED_VARS (block
);
525 pp_string (buffer
, "NONLOCALIZED_VARS: ");
526 for (i
= 0; VEC_iterate (tree
, nlv
, i
, t
); i
++)
528 dump_generic_node (buffer
, t
, 0, flags
, false);
529 pp_string (buffer
, " ");
531 newline_and_indent (buffer
, spc
+ 2);
534 if (BLOCK_ABSTRACT_ORIGIN (block
))
536 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
537 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (block
), 0,
538 flags
| TDF_SLIM
, false);
539 newline_and_indent (buffer
, spc
+ 2);
542 if (BLOCK_FRAGMENT_ORIGIN (block
))
544 pp_string (buffer
, "FRAGMENT_ORIGIN: ");
545 dump_generic_node (buffer
, BLOCK_FRAGMENT_ORIGIN (block
), 0,
546 flags
| TDF_SLIM
, false);
547 newline_and_indent (buffer
, spc
+ 2);
550 if (BLOCK_FRAGMENT_CHAIN (block
))
552 pp_string (buffer
, "FRAGMENT_CHAIN: ");
553 for (t
= BLOCK_FRAGMENT_CHAIN (block
); t
; t
= BLOCK_FRAGMENT_CHAIN (t
))
555 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
556 pp_string (buffer
, " ");
558 newline_and_indent (buffer
, spc
+ 2);
563 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
564 indent. FLAGS specifies details to show in the dump (see TDF_* in
565 tree-pass.h). If IS_STMT is true, the object printed is considered
566 to be a statement and it is terminated by ';' if appropriate. */
569 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
577 if (node
== NULL_TREE
)
580 is_expr
= EXPR_P (node
);
582 if (is_stmt
&& (flags
& TDF_STMTADDR
))
583 pp_printf (buffer
, "<&%p> ", (void *)node
);
585 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
586 dump_location (buffer
, EXPR_LOCATION (node
));
588 switch (TREE_CODE (node
))
591 pp_string (buffer
, "<<< error >>>");
594 case IDENTIFIER_NODE
:
595 pp_tree_identifier (buffer
, node
);
599 while (node
&& node
!= error_mark_node
)
601 if (TREE_PURPOSE (node
))
603 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
606 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
607 node
= TREE_CHAIN (node
);
608 if (node
&& TREE_CODE (node
) == TREE_LIST
)
610 pp_character (buffer
, ',');
617 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
623 if (TREE_VEC_LENGTH (node
) > 0)
625 size_t len
= TREE_VEC_LENGTH (node
);
626 for (i
= 0; i
< len
- 1; i
++)
628 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
630 pp_character (buffer
, ',');
633 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
642 case FIXED_POINT_TYPE
:
648 unsigned int quals
= TYPE_QUALS (node
);
649 enum tree_code_class tclass
;
651 if (quals
& TYPE_QUAL_CONST
)
652 pp_string (buffer
, "const ");
653 else if (quals
& TYPE_QUAL_VOLATILE
)
654 pp_string (buffer
, "volatile ");
655 else if (quals
& TYPE_QUAL_RESTRICT
)
656 pp_string (buffer
, "restrict ");
658 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
660 if (tclass
== tcc_declaration
)
662 if (DECL_NAME (node
))
663 dump_decl_name (buffer
, node
, flags
);
665 pp_string (buffer
, "<unnamed type decl>");
667 else if (tclass
== tcc_type
)
669 if (TYPE_NAME (node
))
671 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
672 pp_tree_identifier (buffer
, TYPE_NAME (node
));
673 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
674 && DECL_NAME (TYPE_NAME (node
)))
675 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
677 pp_string (buffer
, "<unnamed type>");
679 else if (TREE_CODE (node
) == VECTOR_TYPE
)
681 pp_string (buffer
, "vector ");
682 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
684 else if (TREE_CODE (node
) == INTEGER_TYPE
)
686 pp_string (buffer
, (TYPE_UNSIGNED (node
)
687 ? "<unnamed-unsigned:"
688 : "<unnamed-signed:"));
689 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
690 pp_string (buffer
, ">");
692 else if (TREE_CODE (node
) == COMPLEX_TYPE
)
694 pp_string (buffer
, "__complex__ ");
695 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
697 else if (TREE_CODE (node
) == REAL_TYPE
)
699 pp_string (buffer
, "<float:");
700 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
701 pp_string (buffer
, ">");
703 else if (TREE_CODE (node
) == FIXED_POINT_TYPE
)
705 pp_string (buffer
, "<fixed-point-");
706 pp_string (buffer
, TYPE_SATURATING (node
) ? "sat:" : "nonsat:");
707 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
708 pp_string (buffer
, ">");
711 pp_string (buffer
, "<unnamed type>");
718 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
720 if (TREE_TYPE (node
) == NULL
)
722 pp_string (buffer
, str
);
723 pp_string (buffer
, "<null type>");
725 else if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
727 tree fnode
= TREE_TYPE (node
);
729 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
731 pp_character (buffer
, '(');
732 pp_string (buffer
, str
);
733 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
734 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
736 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
738 pp_character (buffer
, ')');
739 dump_function_declaration (buffer
, fnode
, spc
, flags
);
743 unsigned int quals
= TYPE_QUALS (node
);
745 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
747 pp_string (buffer
, str
);
749 if (quals
& TYPE_QUAL_CONST
)
750 pp_string (buffer
, " const");
751 if (quals
& TYPE_QUAL_VOLATILE
)
752 pp_string (buffer
, " volatile");
753 if (quals
& TYPE_QUAL_RESTRICT
)
754 pp_string (buffer
, " restrict");
756 if (TYPE_REF_CAN_ALIAS_ALL (node
))
757 pp_string (buffer
, " {ref-all}");
767 const char *sep
= "";
770 pp_string (buffer
, "MEM[");
772 tmp
= TMR_SYMBOL (node
);
775 pp_string (buffer
, sep
);
777 pp_string (buffer
, "symbol: ");
778 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
780 tmp
= TMR_BASE (node
);
783 pp_string (buffer
, sep
);
785 pp_string (buffer
, "base: ");
786 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
788 tmp
= TMR_INDEX (node
);
791 pp_string (buffer
, sep
);
793 pp_string (buffer
, "index: ");
794 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
796 tmp
= TMR_STEP (node
);
799 pp_string (buffer
, sep
);
801 pp_string (buffer
, "step: ");
802 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
804 tmp
= TMR_OFFSET (node
);
807 pp_string (buffer
, sep
);
809 pp_string (buffer
, "offset: ");
810 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
812 pp_string (buffer
, "]");
813 if (flags
& TDF_DETAILS
)
815 pp_string (buffer
, "{");
816 dump_generic_node (buffer
, TMR_ORIGINAL (node
), spc
, flags
,
818 pp_string (buffer
, "}");
827 /* Print the innermost component type. */
828 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
829 tmp
= TREE_TYPE (tmp
))
831 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
833 /* Print the dimensions. */
834 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
835 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
841 case QUAL_UNION_TYPE
:
843 unsigned int quals
= TYPE_QUALS (node
);
845 if (quals
& TYPE_QUAL_CONST
)
846 pp_string (buffer
, "const ");
847 if (quals
& TYPE_QUAL_VOLATILE
)
848 pp_string (buffer
, "volatile ");
850 /* Print the name of the structure. */
851 if (TREE_CODE (node
) == RECORD_TYPE
)
852 pp_string (buffer
, "struct ");
853 else if (TREE_CODE (node
) == UNION_TYPE
)
854 pp_string (buffer
, "union ");
856 if (TYPE_NAME (node
))
857 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
858 else if (!(flags
& TDF_SLIM
))
859 /* FIXME: If we eliminate the 'else' above and attempt
860 to show the fields for named types, we may get stuck
861 following a cycle of pointers to structs. The alleged
862 self-reference check in print_struct_decl will not detect
863 cycles involving more than one pointer or struct type. */
864 print_struct_decl (buffer
, node
, spc
, flags
);
873 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
875 /* In the case of a pointer, one may want to divide by the
876 size of the pointed-to type. Unfortunately, this not
877 straightforward. The C front-end maps expressions
882 in such a way that the two INTEGER_CST nodes for "5" have
883 different values but identical types. In the latter
884 case, the 5 is multiplied by sizeof (int) in c-common.c
885 (pointer_int_sum) to convert it to a byte address, and
886 yet the type of the node is left unchanged. Argh. What
887 is consistent though is that the number value corresponds
888 to bytes (UNITS) offset.
890 NB: Neither of the following divisors can be trivially
891 used to recover the original literal:
893 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
894 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
895 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
896 pp_string (buffer
, "B"); /* pseudo-unit */
898 else if (! host_integerp (node
, 0))
901 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (val
);
902 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (val
);
904 if (tree_int_cst_sgn (val
) < 0)
906 pp_character (buffer
, '-');
910 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
912 sprintf (pp_buffer (buffer
)->digit_buffer
,
913 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
914 (unsigned HOST_WIDE_INT
) high
, low
);
915 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
918 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
922 /* Code copied from print_node. */
925 if (TREE_OVERFLOW (node
))
926 pp_string (buffer
, " overflow");
928 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
929 d
= TREE_REAL_CST (node
);
930 if (REAL_VALUE_ISINF (d
))
931 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
932 else if (REAL_VALUE_ISNAN (d
))
933 pp_string (buffer
, " Nan");
937 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
938 pp_string (buffer
, string
);
943 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
944 pp_string (buffer
, "0x");
945 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
946 output_formatted_integer (buffer
, "%02x", *p
++);
955 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
956 pp_string (buffer
, string
);
961 pp_string (buffer
, "__complex__ (");
962 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
963 pp_string (buffer
, ", ");
964 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
965 pp_string (buffer
, ")");
969 pp_string (buffer
, "\"");
970 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
971 pp_string (buffer
, "\"");
977 pp_string (buffer
, "{ ");
978 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
980 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
, false);
981 if (TREE_CHAIN (elt
))
982 pp_string (buffer
, ", ");
984 pp_string (buffer
, " }");
990 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
992 if (TREE_CODE (node
) == METHOD_TYPE
)
994 if (TYPE_METHOD_BASETYPE (node
))
995 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
998 pp_string (buffer
, "<null method basetype>");
999 pp_string (buffer
, "::");
1001 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1002 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1004 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1005 dump_function_declaration (buffer
, node
, spc
, flags
);
1010 dump_decl_name (buffer
, node
, flags
);
1014 if (DECL_NAME (node
))
1015 dump_decl_name (buffer
, node
, flags
);
1016 else if (LABEL_DECL_UID (node
) != -1)
1017 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1019 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1023 if (DECL_IS_BUILTIN (node
))
1025 /* Don't print the declaration of built-in types. */
1028 if (DECL_NAME (node
))
1029 dump_decl_name (buffer
, node
, flags
);
1032 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1033 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1034 && TYPE_METHODS (TREE_TYPE (node
)))
1036 /* The type is a c++ class: all structures have at least
1038 pp_string (buffer
, "class ");
1039 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1044 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1045 ? "union" : "struct "));
1046 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1054 case NAMESPACE_DECL
:
1055 dump_decl_name (buffer
, node
, flags
);
1059 pp_string (buffer
, "<retval>");
1063 op0
= TREE_OPERAND (node
, 0);
1065 if (op0
&& TREE_CODE (op0
) == INDIRECT_REF
)
1067 op0
= TREE_OPERAND (op0
, 0);
1070 if (op_prio (op0
) < op_prio (node
))
1071 pp_character (buffer
, '(');
1072 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1073 if (op_prio (op0
) < op_prio (node
))
1074 pp_character (buffer
, ')');
1075 pp_string (buffer
, str
);
1076 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1077 op0
= component_ref_field_offset (node
);
1078 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1080 pp_string (buffer
, "{off: ");
1081 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1082 pp_character (buffer
, '}');
1087 pp_string (buffer
, "BIT_FIELD_REF <");
1088 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1089 pp_string (buffer
, ", ");
1090 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1091 pp_string (buffer
, ", ");
1092 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1093 pp_string (buffer
, ">");
1097 case ARRAY_RANGE_REF
:
1098 op0
= TREE_OPERAND (node
, 0);
1099 if (op_prio (op0
) < op_prio (node
))
1100 pp_character (buffer
, '(');
1101 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1102 if (op_prio (op0
) < op_prio (node
))
1103 pp_character (buffer
, ')');
1104 pp_character (buffer
, '[');
1105 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1106 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1107 pp_string (buffer
, " ...");
1108 pp_character (buffer
, ']');
1110 op0
= array_ref_low_bound (node
);
1111 op1
= array_ref_element_size (node
);
1113 if (!integer_zerop (op0
)
1114 || TREE_OPERAND (node
, 2)
1115 || TREE_OPERAND (node
, 3))
1117 pp_string (buffer
, "{lb: ");
1118 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1119 pp_string (buffer
, " sz: ");
1120 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1121 pp_character (buffer
, '}');
1127 unsigned HOST_WIDE_INT ix
;
1129 bool is_struct_init
= FALSE
;
1130 pp_character (buffer
, '{');
1131 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1132 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1133 is_struct_init
= TRUE
;
1134 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1136 if (field
&& is_struct_init
)
1138 pp_character (buffer
, '.');
1139 dump_generic_node (buffer
, field
, spc
, flags
, false);
1140 pp_string (buffer
, "=");
1142 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1143 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1144 val
= TREE_OPERAND (val
, 0);
1145 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1146 dump_decl_name (buffer
, val
, flags
);
1148 dump_generic_node (buffer
, val
, spc
, flags
, false);
1149 if (ix
!= VEC_length (constructor_elt
, CONSTRUCTOR_ELTS (node
)) - 1)
1151 pp_character (buffer
, ',');
1155 pp_character (buffer
, '}');
1162 if (flags
& TDF_SLIM
)
1164 pp_string (buffer
, "<COMPOUND_EXPR>");
1168 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1169 spc
, flags
, !(flags
& TDF_SLIM
));
1170 if (flags
& TDF_SLIM
)
1171 newline_and_indent (buffer
, spc
);
1174 pp_character (buffer
, ',');
1178 for (tp
= &TREE_OPERAND (node
, 1);
1179 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1180 tp
= &TREE_OPERAND (*tp
, 1))
1182 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1183 spc
, flags
, !(flags
& TDF_SLIM
));
1184 if (flags
& TDF_SLIM
)
1185 newline_and_indent (buffer
, spc
);
1188 pp_character (buffer
, ',');
1193 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1197 case STATEMENT_LIST
:
1199 tree_stmt_iterator si
;
1202 if (flags
& TDF_SLIM
)
1204 pp_string (buffer
, "<STATEMENT_LIST>");
1208 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1211 newline_and_indent (buffer
, spc
);
1214 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1221 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1224 pp_character (buffer
, '=');
1225 if (TREE_CODE (node
) == MODIFY_EXPR
1226 && MOVE_NONTEMPORAL (node
))
1227 pp_string (buffer
, "{nt}");
1229 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1234 pp_string (buffer
, "TARGET_EXPR <");
1235 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1236 pp_character (buffer
, ',');
1238 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1239 pp_character (buffer
, '>');
1243 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1248 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1250 pp_string (buffer
, "if (");
1251 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1252 pp_character (buffer
, ')');
1253 /* The lowered cond_exprs should always be printed in full. */
1254 if (COND_EXPR_THEN (node
)
1255 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1256 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1257 && COND_EXPR_ELSE (node
)
1258 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1259 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1262 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1264 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1266 pp_string (buffer
, " else ");
1267 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1271 else if (!(flags
& TDF_SLIM
))
1273 /* Output COND_EXPR_THEN. */
1274 if (COND_EXPR_THEN (node
))
1276 newline_and_indent (buffer
, spc
+2);
1277 pp_character (buffer
, '{');
1278 newline_and_indent (buffer
, spc
+4);
1279 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1281 newline_and_indent (buffer
, spc
+2);
1282 pp_character (buffer
, '}');
1285 /* Output COND_EXPR_ELSE. */
1286 if (COND_EXPR_ELSE (node
)
1287 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1289 newline_and_indent (buffer
, spc
);
1290 pp_string (buffer
, "else");
1291 newline_and_indent (buffer
, spc
+2);
1292 pp_character (buffer
, '{');
1293 newline_and_indent (buffer
, spc
+4);
1294 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1296 newline_and_indent (buffer
, spc
+2);
1297 pp_character (buffer
, '}');
1304 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1306 pp_character (buffer
, '?');
1308 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1310 pp_character (buffer
, ':');
1312 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1317 pp_character (buffer
, '{');
1318 if (!(flags
& TDF_SLIM
))
1320 if (BIND_EXPR_VARS (node
))
1322 pp_newline (buffer
);
1324 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= TREE_CHAIN (op0
))
1326 print_declaration (buffer
, op0
, spc
+2, flags
);
1327 pp_newline (buffer
);
1331 newline_and_indent (buffer
, spc
+2);
1332 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1333 newline_and_indent (buffer
, spc
);
1334 pp_character (buffer
, '}');
1340 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1342 /* Print parameters. */
1344 pp_character (buffer
, '(');
1347 call_expr_arg_iterator iter
;
1348 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1350 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1351 if (more_call_expr_args_p (&iter
))
1353 pp_character (buffer
, ',');
1358 if (CALL_EXPR_VA_ARG_PACK (node
))
1360 if (call_expr_nargs (node
) > 0)
1362 pp_character (buffer
, ',');
1365 pp_string (buffer
, "__builtin_va_arg_pack ()");
1367 pp_character (buffer
, ')');
1369 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1372 pp_string (buffer
, " [static-chain: ");
1373 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1374 pp_character (buffer
, ']');
1377 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1378 pp_string (buffer
, " [return slot optimization]");
1379 if (CALL_EXPR_TAILCALL (node
))
1380 pp_string (buffer
, " [tail call]");
1383 case WITH_CLEANUP_EXPR
:
1387 case CLEANUP_POINT_EXPR
:
1388 pp_string (buffer
, "<<cleanup_point ");
1389 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1390 pp_string (buffer
, ">>");
1393 case PLACEHOLDER_EXPR
:
1394 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1395 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1396 pp_character (buffer
, '>');
1399 /* Binary arithmetic and logic expressions. */
1400 case WIDEN_SUM_EXPR
:
1401 case WIDEN_MULT_EXPR
:
1404 case POINTER_PLUS_EXPR
:
1406 case TRUNC_DIV_EXPR
:
1408 case FLOOR_DIV_EXPR
:
1409 case ROUND_DIV_EXPR
:
1410 case TRUNC_MOD_EXPR
:
1412 case FLOOR_MOD_EXPR
:
1413 case ROUND_MOD_EXPR
:
1415 case EXACT_DIV_EXPR
:
1420 case VEC_LSHIFT_EXPR
:
1421 case VEC_RSHIFT_EXPR
:
1425 case TRUTH_ANDIF_EXPR
:
1426 case TRUTH_ORIF_EXPR
:
1427 case TRUTH_AND_EXPR
:
1429 case TRUTH_XOR_EXPR
:
1443 case UNORDERED_EXPR
:
1445 const char *op
= op_symbol (node
);
1446 op0
= TREE_OPERAND (node
, 0);
1447 op1
= TREE_OPERAND (node
, 1);
1449 /* When the operands are expressions with less priority,
1450 keep semantics of the tree representation. */
1451 if (op_prio (op0
) <= op_prio (node
))
1453 pp_character (buffer
, '(');
1454 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1455 pp_character (buffer
, ')');
1458 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1461 pp_string (buffer
, op
);
1464 /* When the operands are expressions with less priority,
1465 keep semantics of the tree representation. */
1466 if (op_prio (op1
) <= op_prio (node
))
1468 pp_character (buffer
, '(');
1469 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1470 pp_character (buffer
, ')');
1473 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1477 /* Unary arithmetic and logic expressions. */
1480 case TRUTH_NOT_EXPR
:
1482 case PREDECREMENT_EXPR
:
1483 case PREINCREMENT_EXPR
:
1484 case ALIGN_INDIRECT_REF
:
1485 case MISALIGNED_INDIRECT_REF
:
1487 if (TREE_CODE (node
) == ADDR_EXPR
1488 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1489 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1490 ; /* Do not output '&' for strings and function pointers. */
1492 pp_string (buffer
, op_symbol (node
));
1494 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1496 pp_character (buffer
, '(');
1497 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1498 pp_character (buffer
, ')');
1501 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1503 if (TREE_CODE (node
) == MISALIGNED_INDIRECT_REF
)
1505 pp_string (buffer
, "{misalignment: ");
1506 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1507 pp_character (buffer
, '}');
1511 case POSTDECREMENT_EXPR
:
1512 case POSTINCREMENT_EXPR
:
1513 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1515 pp_character (buffer
, '(');
1516 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1517 pp_character (buffer
, ')');
1520 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1521 pp_string (buffer
, op_symbol (node
));
1525 pp_string (buffer
, "MIN_EXPR <");
1526 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1527 pp_string (buffer
, ", ");
1528 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1529 pp_character (buffer
, '>');
1533 pp_string (buffer
, "MAX_EXPR <");
1534 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1535 pp_string (buffer
, ", ");
1536 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1537 pp_character (buffer
, '>');
1541 pp_string (buffer
, "ABS_EXPR <");
1542 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1543 pp_character (buffer
, '>');
1550 case FIXED_CONVERT_EXPR
:
1551 case FIX_TRUNC_EXPR
:
1554 type
= TREE_TYPE (node
);
1555 op0
= TREE_OPERAND (node
, 0);
1556 if (type
!= TREE_TYPE (op0
))
1558 pp_character (buffer
, '(');
1559 dump_generic_node (buffer
, type
, spc
, flags
, false);
1560 pp_string (buffer
, ") ");
1562 if (op_prio (op0
) < op_prio (node
))
1563 pp_character (buffer
, '(');
1564 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1565 if (op_prio (op0
) < op_prio (node
))
1566 pp_character (buffer
, ')');
1569 case VIEW_CONVERT_EXPR
:
1570 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1571 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1572 pp_string (buffer
, ">(");
1573 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1574 pp_character (buffer
, ')');
1578 pp_string (buffer
, "((");
1579 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1580 pp_string (buffer
, "))");
1583 case NON_LVALUE_EXPR
:
1584 pp_string (buffer
, "NON_LVALUE_EXPR <");
1585 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1586 pp_character (buffer
, '>');
1590 pp_string (buffer
, "SAVE_EXPR <");
1591 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1592 pp_character (buffer
, '>');
1596 pp_string (buffer
, "COMPLEX_EXPR <");
1597 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1598 pp_string (buffer
, ", ");
1599 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1600 pp_string (buffer
, ">");
1604 pp_string (buffer
, "CONJ_EXPR <");
1605 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1606 pp_string (buffer
, ">");
1610 pp_string (buffer
, "REALPART_EXPR <");
1611 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1612 pp_string (buffer
, ">");
1616 pp_string (buffer
, "IMAGPART_EXPR <");
1617 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1618 pp_string (buffer
, ">");
1622 pp_string (buffer
, "VA_ARG_EXPR <");
1623 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1624 pp_string (buffer
, ">");
1627 case TRY_FINALLY_EXPR
:
1628 case TRY_CATCH_EXPR
:
1629 pp_string (buffer
, "try");
1630 newline_and_indent (buffer
, spc
+2);
1631 pp_string (buffer
, "{");
1632 newline_and_indent (buffer
, spc
+4);
1633 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1634 newline_and_indent (buffer
, spc
+2);
1635 pp_string (buffer
, "}");
1636 newline_and_indent (buffer
, spc
);
1638 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1639 newline_and_indent (buffer
, spc
+2);
1640 pp_string (buffer
, "{");
1641 newline_and_indent (buffer
, spc
+4);
1642 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1643 newline_and_indent (buffer
, spc
+2);
1644 pp_string (buffer
, "}");
1649 pp_string (buffer
, "catch (");
1650 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1651 pp_string (buffer
, ")");
1652 newline_and_indent (buffer
, spc
+2);
1653 pp_string (buffer
, "{");
1654 newline_and_indent (buffer
, spc
+4);
1655 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1656 newline_and_indent (buffer
, spc
+2);
1657 pp_string (buffer
, "}");
1661 case EH_FILTER_EXPR
:
1662 pp_string (buffer
, "<<<eh_filter (");
1663 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1664 pp_string (buffer
, ")>>>");
1665 newline_and_indent (buffer
, spc
+2);
1666 pp_string (buffer
, "{");
1667 newline_and_indent (buffer
, spc
+4);
1668 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1669 newline_and_indent (buffer
, spc
+2);
1670 pp_string (buffer
, "}");
1675 op0
= TREE_OPERAND (node
, 0);
1676 /* If this is for break or continue, don't bother printing it. */
1677 if (DECL_NAME (op0
))
1679 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1680 if (strcmp (name
, "break") == 0
1681 || strcmp (name
, "continue") == 0)
1684 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1685 pp_character (buffer
, ':');
1686 if (DECL_NONLOCAL (op0
))
1687 pp_string (buffer
, " [non-local]");
1691 pp_string (buffer
, "<<<exception object>>>");
1695 pp_string (buffer
, "<<<filter object>>>");
1699 pp_string (buffer
, "while (1)");
1700 if (!(flags
& TDF_SLIM
))
1702 newline_and_indent (buffer
, spc
+2);
1703 pp_character (buffer
, '{');
1704 newline_and_indent (buffer
, spc
+4);
1705 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1706 newline_and_indent (buffer
, spc
+2);
1707 pp_character (buffer
, '}');
1713 pp_string (buffer
, "// predicted ");
1714 if (PREDICT_EXPR_OUTCOME (node
))
1715 pp_string (buffer
, "likely by ");
1717 pp_string (buffer
, "unlikely by ");
1718 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
1719 pp_string (buffer
, " predictor.");
1723 pp_string (buffer
, "return");
1724 op0
= TREE_OPERAND (node
, 0);
1728 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1729 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
1732 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1737 pp_string (buffer
, "if (");
1738 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1739 pp_string (buffer
, ") break");
1743 pp_string (buffer
, "switch (");
1744 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1745 pp_character (buffer
, ')');
1746 if (!(flags
& TDF_SLIM
))
1748 newline_and_indent (buffer
, spc
+2);
1749 pp_character (buffer
, '{');
1750 if (SWITCH_BODY (node
))
1752 newline_and_indent (buffer
, spc
+4);
1753 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1758 tree vec
= SWITCH_LABELS (node
);
1759 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1760 for (i
= 0; i
< n
; ++i
)
1762 tree elt
= TREE_VEC_ELT (vec
, i
);
1763 newline_and_indent (buffer
, spc
+4);
1766 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1767 pp_string (buffer
, " goto ");
1768 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1770 pp_semicolon (buffer
);
1773 pp_string (buffer
, "case ???: goto ???;");
1776 newline_and_indent (buffer
, spc
+2);
1777 pp_character (buffer
, '}');
1783 op0
= GOTO_DESTINATION (node
);
1784 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1786 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1787 if (strcmp (name
, "break") == 0
1788 || strcmp (name
, "continue") == 0)
1790 pp_string (buffer
, name
);
1794 pp_string (buffer
, "goto ");
1795 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1799 pp_string (buffer
, "resx ");
1800 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1804 pp_string (buffer
, "__asm__");
1805 if (ASM_VOLATILE_P (node
))
1806 pp_string (buffer
, " __volatile__");
1807 pp_character (buffer
, '(');
1808 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1809 pp_character (buffer
, ':');
1810 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1811 pp_character (buffer
, ':');
1812 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1813 if (ASM_CLOBBERS (node
))
1815 pp_character (buffer
, ':');
1816 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1818 pp_string (buffer
, ")");
1821 case CASE_LABEL_EXPR
:
1822 if (CASE_LOW (node
) && CASE_HIGH (node
))
1824 pp_string (buffer
, "case ");
1825 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1826 pp_string (buffer
, " ... ");
1827 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1829 else if (CASE_LOW (node
))
1831 pp_string (buffer
, "case ");
1832 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1835 pp_string (buffer
, "default");
1836 pp_character (buffer
, ':');
1840 pp_string (buffer
, "OBJ_TYPE_REF(");
1841 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1842 pp_character (buffer
, ';');
1843 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1844 pp_character (buffer
, '-');
1845 pp_character (buffer
, '>');
1846 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
1847 pp_character (buffer
, ')');
1851 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
1852 pp_string (buffer
, "_");
1853 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1854 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
1855 pp_string (buffer
, "(ab)");
1856 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
1857 pp_string (buffer
, "(D)");
1860 case WITH_SIZE_EXPR
:
1861 pp_string (buffer
, "WITH_SIZE_EXPR <");
1862 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1863 pp_string (buffer
, ", ");
1864 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1865 pp_string (buffer
, ">");
1869 pp_string (buffer
, "ASSERT_EXPR <");
1870 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
1871 pp_string (buffer
, ", ");
1872 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
1873 pp_string (buffer
, ">");
1877 pp_string (buffer
, "scev_known");
1880 case SCEV_NOT_KNOWN
:
1881 pp_string (buffer
, "scev_not_known");
1884 case POLYNOMIAL_CHREC
:
1885 pp_string (buffer
, "{");
1886 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
1887 pp_string (buffer
, ", +, ");
1888 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
1889 pp_string (buffer
, "}_");
1890 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
1894 case REALIGN_LOAD_EXPR
:
1895 pp_string (buffer
, "REALIGN_LOAD <");
1896 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1897 pp_string (buffer
, ", ");
1898 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1899 pp_string (buffer
, ", ");
1900 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1901 pp_string (buffer
, ">");
1905 pp_string (buffer
, " VEC_COND_EXPR < ");
1906 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1907 pp_string (buffer
, " , ");
1908 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1909 pp_string (buffer
, " , ");
1910 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1911 pp_string (buffer
, " > ");
1915 pp_string (buffer
, " DOT_PROD_EXPR < ");
1916 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1917 pp_string (buffer
, ", ");
1918 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1919 pp_string (buffer
, ", ");
1920 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1921 pp_string (buffer
, " > ");
1925 pp_string (buffer
, "#pragma omp parallel");
1926 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
1929 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
1931 newline_and_indent (buffer
, spc
+ 2);
1932 pp_character (buffer
, '{');
1933 newline_and_indent (buffer
, spc
+ 4);
1934 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
1935 newline_and_indent (buffer
, spc
+ 2);
1936 pp_character (buffer
, '}');
1942 pp_string (buffer
, "#pragma omp task");
1943 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
1947 pp_string (buffer
, "#pragma omp for");
1948 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
1950 if (!(flags
& TDF_SLIM
))
1954 if (OMP_FOR_PRE_BODY (node
))
1956 newline_and_indent (buffer
, spc
+ 2);
1957 pp_character (buffer
, '{');
1959 newline_and_indent (buffer
, spc
);
1960 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
1964 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
1967 newline_and_indent (buffer
, spc
);
1968 pp_string (buffer
, "for (");
1969 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
1971 pp_string (buffer
, "; ");
1972 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
1974 pp_string (buffer
, "; ");
1975 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
1977 pp_string (buffer
, ")");
1979 if (OMP_FOR_BODY (node
))
1981 newline_and_indent (buffer
, spc
+ 2);
1982 pp_character (buffer
, '{');
1983 newline_and_indent (buffer
, spc
+ 4);
1984 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
1986 newline_and_indent (buffer
, spc
+ 2);
1987 pp_character (buffer
, '}');
1989 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
1990 if (OMP_FOR_PRE_BODY (node
))
1993 newline_and_indent (buffer
, spc
+ 2);
1994 pp_character (buffer
, '}');
2001 pp_string (buffer
, "#pragma omp sections");
2002 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2006 pp_string (buffer
, "#pragma omp section");
2010 pp_string (buffer
, "#pragma omp master");
2014 pp_string (buffer
, "#pragma omp ordered");
2018 pp_string (buffer
, "#pragma omp critical");
2019 if (OMP_CRITICAL_NAME (node
))
2022 pp_character (buffer
, '(');
2023 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2025 pp_character (buffer
, ')');
2030 pp_string (buffer
, "#pragma omp atomic");
2031 newline_and_indent (buffer
, spc
+ 2);
2032 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2034 pp_character (buffer
, '=');
2036 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2040 pp_string (buffer
, "#pragma omp single");
2041 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2045 dump_omp_clause (buffer
, node
, spc
, flags
);
2049 case REDUC_MAX_EXPR
:
2050 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2051 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2052 pp_string (buffer
, " > ");
2055 case REDUC_MIN_EXPR
:
2056 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2057 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2058 pp_string (buffer
, " > ");
2061 case REDUC_PLUS_EXPR
:
2062 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2063 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2064 pp_string (buffer
, " > ");
2067 case VEC_WIDEN_MULT_HI_EXPR
:
2068 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
2069 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2070 pp_string (buffer
, ", ");
2071 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2072 pp_string (buffer
, " > ");
2075 case VEC_WIDEN_MULT_LO_EXPR
:
2076 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
2077 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2078 pp_string (buffer
, ", ");
2079 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2080 pp_string (buffer
, " > ");
2083 case VEC_UNPACK_HI_EXPR
:
2084 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2085 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2086 pp_string (buffer
, " > ");
2089 case VEC_UNPACK_LO_EXPR
:
2090 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2091 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2092 pp_string (buffer
, " > ");
2095 case VEC_UNPACK_FLOAT_HI_EXPR
:
2096 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2097 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2098 pp_string (buffer
, " > ");
2101 case VEC_UNPACK_FLOAT_LO_EXPR
:
2102 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2103 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2104 pp_string (buffer
, " > ");
2107 case VEC_PACK_TRUNC_EXPR
:
2108 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2109 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2110 pp_string (buffer
, ", ");
2111 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2112 pp_string (buffer
, " > ");
2115 case VEC_PACK_SAT_EXPR
:
2116 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2117 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2118 pp_string (buffer
, ", ");
2119 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2120 pp_string (buffer
, " > ");
2123 case VEC_PACK_FIX_TRUNC_EXPR
:
2124 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2125 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2126 pp_string (buffer
, ", ");
2127 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2128 pp_string (buffer
, " > ");
2132 dump_block_node (buffer
, node
, spc
, flags
);
2135 case VEC_EXTRACT_EVEN_EXPR
:
2136 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2137 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2138 pp_string (buffer
, ", ");
2139 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2140 pp_string (buffer
, " > ");
2143 case VEC_EXTRACT_ODD_EXPR
:
2144 pp_string (buffer
, " VEC_EXTRACT_ODD_EXPR < ");
2145 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2146 pp_string (buffer
, ", ");
2147 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2148 pp_string (buffer
, " > ");
2151 case VEC_INTERLEAVE_HIGH_EXPR
:
2152 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_EXPR < ");
2153 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2154 pp_string (buffer
, ", ");
2155 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2156 pp_string (buffer
, " > ");
2159 case VEC_INTERLEAVE_LOW_EXPR
:
2160 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2161 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2162 pp_string (buffer
, ", ");
2163 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2164 pp_string (buffer
, " > ");
2171 if (is_stmt
&& is_expr
)
2172 pp_semicolon (buffer
);
2174 /* If we're building a diagnostic, the formatted text will be written
2175 into BUFFER's stream by the caller; otherwise, write it now. */
2176 if (!(flags
& TDF_DIAGNOSTIC
))
2177 pp_write_text_to_stream (buffer
);
2182 /* Print the declaration of a variable. */
2185 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2189 if (TREE_CODE (t
) == TYPE_DECL
)
2190 pp_string (buffer
, "typedef ");
2192 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2193 pp_string (buffer
, "register ");
2195 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2196 pp_string (buffer
, "extern ");
2197 else if (TREE_STATIC (t
))
2198 pp_string (buffer
, "static ");
2200 /* Print the type and name. */
2201 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2205 /* Print array's type. */
2206 tmp
= TREE_TYPE (t
);
2207 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2208 tmp
= TREE_TYPE (tmp
);
2209 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2211 /* Print variable's name. */
2213 dump_generic_node (buffer
, t
, spc
, flags
, false);
2215 /* Print the dimensions. */
2216 tmp
= TREE_TYPE (t
);
2217 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2219 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2220 tmp
= TREE_TYPE (tmp
);
2223 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2225 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2227 dump_decl_name (buffer
, t
, flags
);
2228 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2232 /* Print type declaration. */
2233 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2235 /* Print variable's name. */
2237 dump_generic_node (buffer
, t
, spc
, flags
, false);
2240 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2242 pp_string (buffer
, " __asm__ ");
2243 pp_character (buffer
, '(');
2244 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2245 pp_character (buffer
, ')');
2248 /* The initial value of a function serves to determine whether the function
2249 is declared or defined. So the following does not apply to function
2251 if (TREE_CODE (t
) != FUNCTION_DECL
)
2253 /* Print the initial value. */
2254 if (DECL_INITIAL (t
))
2257 pp_character (buffer
, '=');
2259 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2263 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2265 pp_string (buffer
, " [value-expr: ");
2266 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2267 pp_character (buffer
, ']');
2270 pp_character (buffer
, ';');
2274 /* Prints a structure: name, fields, and methods.
2275 FIXME: Still incomplete. */
2278 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2280 /* Print the name of the structure. */
2281 if (TYPE_NAME (node
))
2284 if (TREE_CODE (node
) == RECORD_TYPE
)
2285 pp_string (buffer
, "struct ");
2286 else if ((TREE_CODE (node
) == UNION_TYPE
2287 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2288 pp_string (buffer
, "union ");
2290 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2293 /* Print the contents of the structure. */
2294 pp_newline (buffer
);
2296 pp_character (buffer
, '{');
2297 pp_newline (buffer
);
2299 /* Print the fields of the structure. */
2302 tmp
= TYPE_FIELDS (node
);
2305 /* Avoid to print recursively the structure. */
2306 /* FIXME : Not implemented correctly...,
2307 what about the case when we have a cycle in the contain graph? ...
2308 Maybe this could be solved by looking at the scope in which the
2309 structure was declared. */
2310 if (TREE_TYPE (tmp
) != node
2311 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2312 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2314 print_declaration (buffer
, tmp
, spc
+2, flags
);
2315 pp_newline (buffer
);
2317 tmp
= TREE_CHAIN (tmp
);
2321 pp_character (buffer
, '}');
2324 /* Return the priority of the operator CODE.
2326 From lowest to highest precedence with either left-to-right (L-R)
2327 or right-to-left (R-L) associativity]:
2330 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2342 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2343 15 [L-R] fn() [] -> .
2345 unary +, - and * have higher precedence than the corresponding binary
2349 op_code_prio (enum tree_code code
)
2366 case TRUTH_ORIF_EXPR
:
2369 case TRUTH_AND_EXPR
:
2370 case TRUTH_ANDIF_EXPR
:
2377 case TRUTH_XOR_EXPR
:
2394 case UNORDERED_EXPR
:
2407 case WIDEN_SUM_EXPR
:
2409 case POINTER_PLUS_EXPR
:
2413 case VEC_WIDEN_MULT_HI_EXPR
:
2414 case VEC_WIDEN_MULT_LO_EXPR
:
2415 case WIDEN_MULT_EXPR
:
2418 case TRUNC_DIV_EXPR
:
2420 case FLOOR_DIV_EXPR
:
2421 case ROUND_DIV_EXPR
:
2423 case EXACT_DIV_EXPR
:
2424 case TRUNC_MOD_EXPR
:
2426 case FLOOR_MOD_EXPR
:
2427 case ROUND_MOD_EXPR
:
2430 case TRUTH_NOT_EXPR
:
2432 case POSTINCREMENT_EXPR
:
2433 case POSTDECREMENT_EXPR
:
2434 case PREINCREMENT_EXPR
:
2435 case PREDECREMENT_EXPR
:
2437 case ALIGN_INDIRECT_REF
:
2438 case MISALIGNED_INDIRECT_REF
:
2443 case FIX_TRUNC_EXPR
:
2449 case ARRAY_RANGE_REF
:
2453 /* Special expressions. */
2459 case REDUC_MAX_EXPR
:
2460 case REDUC_MIN_EXPR
:
2461 case REDUC_PLUS_EXPR
:
2462 case VEC_LSHIFT_EXPR
:
2463 case VEC_RSHIFT_EXPR
:
2464 case VEC_UNPACK_HI_EXPR
:
2465 case VEC_UNPACK_LO_EXPR
:
2466 case VEC_UNPACK_FLOAT_HI_EXPR
:
2467 case VEC_UNPACK_FLOAT_LO_EXPR
:
2468 case VEC_PACK_TRUNC_EXPR
:
2469 case VEC_PACK_SAT_EXPR
:
2473 /* Return an arbitrarily high precedence to avoid surrounding single
2474 VAR_DECLs in ()s. */
2479 /* Return the priority of the operator OP. */
2482 op_prio (const_tree op
)
2484 enum tree_code code
;
2489 code
= TREE_CODE (op
);
2490 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2491 return op_prio (TREE_OPERAND (op
, 0));
2493 return op_code_prio (code
);
2496 /* Return the symbol associated with operator CODE. */
2499 op_symbol_code (enum tree_code code
)
2507 case TRUTH_ORIF_EXPR
:
2510 case TRUTH_AND_EXPR
:
2511 case TRUTH_ANDIF_EXPR
:
2517 case TRUTH_XOR_EXPR
:
2527 case UNORDERED_EXPR
:
2573 case VEC_LSHIFT_EXPR
:
2576 case VEC_RSHIFT_EXPR
:
2579 case POINTER_PLUS_EXPR
:
2585 case REDUC_PLUS_EXPR
:
2588 case WIDEN_SUM_EXPR
:
2591 case WIDEN_MULT_EXPR
:
2601 case TRUTH_NOT_EXPR
:
2608 case ALIGN_INDIRECT_REF
:
2611 case MISALIGNED_INDIRECT_REF
:
2614 case TRUNC_DIV_EXPR
:
2621 case FLOOR_DIV_EXPR
:
2624 case ROUND_DIV_EXPR
:
2627 case EXACT_DIV_EXPR
:
2630 case TRUNC_MOD_EXPR
:
2636 case FLOOR_MOD_EXPR
:
2639 case ROUND_MOD_EXPR
:
2642 case PREDECREMENT_EXPR
:
2645 case PREINCREMENT_EXPR
:
2648 case POSTDECREMENT_EXPR
:
2651 case POSTINCREMENT_EXPR
:
2661 return "<<< ??? >>>";
2665 /* Return the symbol associated with operator OP. */
2668 op_symbol (const_tree op
)
2670 return op_symbol_code (TREE_CODE (op
));
2673 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2674 the gimple_call_fn of a GIMPLE_CALL. */
2677 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
2681 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2682 op0
= TREE_OPERAND (op0
, 0);
2685 switch (TREE_CODE (op0
))
2690 dump_function_name (buffer
, op0
, flags
);
2696 op0
= TREE_OPERAND (op0
, 0);
2700 pp_string (buffer
, "(");
2701 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
2702 pp_string (buffer
, ") ? ");
2703 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
2704 pp_string (buffer
, " : ");
2705 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
2709 /* The function is a pointer contained in a structure. */
2710 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == INDIRECT_REF
||
2711 TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2712 dump_function_name (buffer
, TREE_OPERAND (op0
, 1), flags
);
2714 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
2716 We can have several levels of structures and a function
2717 pointer inside. This is not implemented yet... */
2722 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2723 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
2725 dump_generic_node (buffer
, op0
, 0, flags
, false);
2730 dump_generic_node (buffer
, op0
, 0, flags
, false);
2738 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2741 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2751 pp_string (buffer
, "\\b");
2755 pp_string (buffer
, "\\f");
2759 pp_string (buffer
, "\\n");
2763 pp_string (buffer
, "\\r");
2767 pp_string (buffer
, "\\t");
2771 pp_string (buffer
, "\\v");
2775 pp_string (buffer
, "\\\\");
2779 pp_string (buffer
, "\\\"");
2783 pp_string (buffer
, "\\'");
2786 /* No need to handle \0; the loop terminates on \0. */
2789 pp_string (buffer
, "\\1");
2793 pp_string (buffer
, "\\2");
2797 pp_string (buffer
, "\\3");
2801 pp_string (buffer
, "\\4");
2805 pp_string (buffer
, "\\5");
2809 pp_string (buffer
, "\\6");
2813 pp_string (buffer
, "\\7");
2817 pp_character (buffer
, str
[0]);
2825 maybe_init_pretty_print (FILE *file
)
2829 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
2830 pp_needs_newline (&buffer
) = true;
2831 pp_translate_identifiers (&buffer
) = false;
2835 buffer
.buffer
->stream
= file
;
2839 newline_and_indent (pretty_printer
*buffer
, int spc
)
2841 pp_newline (buffer
);