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
, "while (1)");
1692 if (!(flags
& TDF_SLIM
))
1694 newline_and_indent (buffer
, spc
+2);
1695 pp_character (buffer
, '{');
1696 newline_and_indent (buffer
, spc
+4);
1697 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1698 newline_and_indent (buffer
, spc
+2);
1699 pp_character (buffer
, '}');
1705 pp_string (buffer
, "// predicted ");
1706 if (PREDICT_EXPR_OUTCOME (node
))
1707 pp_string (buffer
, "likely by ");
1709 pp_string (buffer
, "unlikely by ");
1710 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
1711 pp_string (buffer
, " predictor.");
1715 pp_string (buffer
, "return");
1716 op0
= TREE_OPERAND (node
, 0);
1720 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1721 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
1724 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1729 pp_string (buffer
, "if (");
1730 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1731 pp_string (buffer
, ") break");
1735 pp_string (buffer
, "switch (");
1736 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1737 pp_character (buffer
, ')');
1738 if (!(flags
& TDF_SLIM
))
1740 newline_and_indent (buffer
, spc
+2);
1741 pp_character (buffer
, '{');
1742 if (SWITCH_BODY (node
))
1744 newline_and_indent (buffer
, spc
+4);
1745 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1750 tree vec
= SWITCH_LABELS (node
);
1751 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1752 for (i
= 0; i
< n
; ++i
)
1754 tree elt
= TREE_VEC_ELT (vec
, i
);
1755 newline_and_indent (buffer
, spc
+4);
1758 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1759 pp_string (buffer
, " goto ");
1760 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1762 pp_semicolon (buffer
);
1765 pp_string (buffer
, "case ???: goto ???;");
1768 newline_and_indent (buffer
, spc
+2);
1769 pp_character (buffer
, '}');
1775 op0
= GOTO_DESTINATION (node
);
1776 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1778 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1779 if (strcmp (name
, "break") == 0
1780 || strcmp (name
, "continue") == 0)
1782 pp_string (buffer
, name
);
1786 pp_string (buffer
, "goto ");
1787 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1791 pp_string (buffer
, "__asm__");
1792 if (ASM_VOLATILE_P (node
))
1793 pp_string (buffer
, " __volatile__");
1794 pp_character (buffer
, '(');
1795 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1796 pp_character (buffer
, ':');
1797 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1798 pp_character (buffer
, ':');
1799 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1800 if (ASM_CLOBBERS (node
))
1802 pp_character (buffer
, ':');
1803 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1805 pp_string (buffer
, ")");
1808 case CASE_LABEL_EXPR
:
1809 if (CASE_LOW (node
) && CASE_HIGH (node
))
1811 pp_string (buffer
, "case ");
1812 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1813 pp_string (buffer
, " ... ");
1814 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1816 else if (CASE_LOW (node
))
1818 pp_string (buffer
, "case ");
1819 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1822 pp_string (buffer
, "default");
1823 pp_character (buffer
, ':');
1827 pp_string (buffer
, "OBJ_TYPE_REF(");
1828 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1829 pp_character (buffer
, ';');
1830 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1831 pp_character (buffer
, '-');
1832 pp_character (buffer
, '>');
1833 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
1834 pp_character (buffer
, ')');
1838 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
1839 pp_string (buffer
, "_");
1840 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1841 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
1842 pp_string (buffer
, "(ab)");
1843 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
1844 pp_string (buffer
, "(D)");
1847 case WITH_SIZE_EXPR
:
1848 pp_string (buffer
, "WITH_SIZE_EXPR <");
1849 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1850 pp_string (buffer
, ", ");
1851 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1852 pp_string (buffer
, ">");
1856 pp_string (buffer
, "ASSERT_EXPR <");
1857 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
1858 pp_string (buffer
, ", ");
1859 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
1860 pp_string (buffer
, ">");
1864 pp_string (buffer
, "scev_known");
1867 case SCEV_NOT_KNOWN
:
1868 pp_string (buffer
, "scev_not_known");
1871 case POLYNOMIAL_CHREC
:
1872 pp_string (buffer
, "{");
1873 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
1874 pp_string (buffer
, ", +, ");
1875 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
1876 pp_string (buffer
, "}_");
1877 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
1881 case REALIGN_LOAD_EXPR
:
1882 pp_string (buffer
, "REALIGN_LOAD <");
1883 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1884 pp_string (buffer
, ", ");
1885 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1886 pp_string (buffer
, ", ");
1887 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1888 pp_string (buffer
, ">");
1892 pp_string (buffer
, " VEC_COND_EXPR < ");
1893 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1894 pp_string (buffer
, " , ");
1895 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1896 pp_string (buffer
, " , ");
1897 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1898 pp_string (buffer
, " > ");
1902 pp_string (buffer
, " DOT_PROD_EXPR < ");
1903 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1904 pp_string (buffer
, ", ");
1905 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1906 pp_string (buffer
, ", ");
1907 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1908 pp_string (buffer
, " > ");
1912 pp_string (buffer
, "#pragma omp parallel");
1913 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
1916 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
1918 newline_and_indent (buffer
, spc
+ 2);
1919 pp_character (buffer
, '{');
1920 newline_and_indent (buffer
, spc
+ 4);
1921 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
1922 newline_and_indent (buffer
, spc
+ 2);
1923 pp_character (buffer
, '}');
1929 pp_string (buffer
, "#pragma omp task");
1930 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
1934 pp_string (buffer
, "#pragma omp for");
1935 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
1937 if (!(flags
& TDF_SLIM
))
1941 if (OMP_FOR_PRE_BODY (node
))
1943 newline_and_indent (buffer
, spc
+ 2);
1944 pp_character (buffer
, '{');
1946 newline_and_indent (buffer
, spc
);
1947 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
1951 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
1954 newline_and_indent (buffer
, spc
);
1955 pp_string (buffer
, "for (");
1956 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
1958 pp_string (buffer
, "; ");
1959 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
1961 pp_string (buffer
, "; ");
1962 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
1964 pp_string (buffer
, ")");
1966 if (OMP_FOR_BODY (node
))
1968 newline_and_indent (buffer
, spc
+ 2);
1969 pp_character (buffer
, '{');
1970 newline_and_indent (buffer
, spc
+ 4);
1971 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
1973 newline_and_indent (buffer
, spc
+ 2);
1974 pp_character (buffer
, '}');
1976 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
1977 if (OMP_FOR_PRE_BODY (node
))
1980 newline_and_indent (buffer
, spc
+ 2);
1981 pp_character (buffer
, '}');
1988 pp_string (buffer
, "#pragma omp sections");
1989 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
1993 pp_string (buffer
, "#pragma omp section");
1997 pp_string (buffer
, "#pragma omp master");
2001 pp_string (buffer
, "#pragma omp ordered");
2005 pp_string (buffer
, "#pragma omp critical");
2006 if (OMP_CRITICAL_NAME (node
))
2009 pp_character (buffer
, '(');
2010 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2012 pp_character (buffer
, ')');
2017 pp_string (buffer
, "#pragma omp atomic");
2018 newline_and_indent (buffer
, spc
+ 2);
2019 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2021 pp_character (buffer
, '=');
2023 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2027 pp_string (buffer
, "#pragma omp single");
2028 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2032 dump_omp_clause (buffer
, node
, spc
, flags
);
2036 case REDUC_MAX_EXPR
:
2037 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2038 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2039 pp_string (buffer
, " > ");
2042 case REDUC_MIN_EXPR
:
2043 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2044 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2045 pp_string (buffer
, " > ");
2048 case REDUC_PLUS_EXPR
:
2049 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2050 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2051 pp_string (buffer
, " > ");
2054 case VEC_WIDEN_MULT_HI_EXPR
:
2055 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
2056 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2057 pp_string (buffer
, ", ");
2058 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2059 pp_string (buffer
, " > ");
2062 case VEC_WIDEN_MULT_LO_EXPR
:
2063 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
2064 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2065 pp_string (buffer
, ", ");
2066 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2067 pp_string (buffer
, " > ");
2070 case VEC_UNPACK_HI_EXPR
:
2071 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2072 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2073 pp_string (buffer
, " > ");
2076 case VEC_UNPACK_LO_EXPR
:
2077 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2078 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2079 pp_string (buffer
, " > ");
2082 case VEC_UNPACK_FLOAT_HI_EXPR
:
2083 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2084 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2085 pp_string (buffer
, " > ");
2088 case VEC_UNPACK_FLOAT_LO_EXPR
:
2089 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2090 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2091 pp_string (buffer
, " > ");
2094 case VEC_PACK_TRUNC_EXPR
:
2095 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2096 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2097 pp_string (buffer
, ", ");
2098 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2099 pp_string (buffer
, " > ");
2102 case VEC_PACK_SAT_EXPR
:
2103 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2104 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2105 pp_string (buffer
, ", ");
2106 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2107 pp_string (buffer
, " > ");
2110 case VEC_PACK_FIX_TRUNC_EXPR
:
2111 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2112 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2113 pp_string (buffer
, ", ");
2114 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2115 pp_string (buffer
, " > ");
2119 dump_block_node (buffer
, node
, spc
, flags
);
2122 case VEC_EXTRACT_EVEN_EXPR
:
2123 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2124 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2125 pp_string (buffer
, ", ");
2126 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2127 pp_string (buffer
, " > ");
2130 case VEC_EXTRACT_ODD_EXPR
:
2131 pp_string (buffer
, " VEC_EXTRACT_ODD_EXPR < ");
2132 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2133 pp_string (buffer
, ", ");
2134 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2135 pp_string (buffer
, " > ");
2138 case VEC_INTERLEAVE_HIGH_EXPR
:
2139 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_EXPR < ");
2140 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2141 pp_string (buffer
, ", ");
2142 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2143 pp_string (buffer
, " > ");
2146 case VEC_INTERLEAVE_LOW_EXPR
:
2147 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2148 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2149 pp_string (buffer
, ", ");
2150 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2151 pp_string (buffer
, " > ");
2158 if (is_stmt
&& is_expr
)
2159 pp_semicolon (buffer
);
2161 /* If we're building a diagnostic, the formatted text will be written
2162 into BUFFER's stream by the caller; otherwise, write it now. */
2163 if (!(flags
& TDF_DIAGNOSTIC
))
2164 pp_write_text_to_stream (buffer
);
2169 /* Print the declaration of a variable. */
2172 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2176 if (TREE_CODE (t
) == TYPE_DECL
)
2177 pp_string (buffer
, "typedef ");
2179 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2180 pp_string (buffer
, "register ");
2182 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2183 pp_string (buffer
, "extern ");
2184 else if (TREE_STATIC (t
))
2185 pp_string (buffer
, "static ");
2187 /* Print the type and name. */
2188 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2192 /* Print array's type. */
2193 tmp
= TREE_TYPE (t
);
2194 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2195 tmp
= TREE_TYPE (tmp
);
2196 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2198 /* Print variable's name. */
2200 dump_generic_node (buffer
, t
, spc
, flags
, false);
2202 /* Print the dimensions. */
2203 tmp
= TREE_TYPE (t
);
2204 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2206 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2207 tmp
= TREE_TYPE (tmp
);
2210 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2212 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2214 dump_decl_name (buffer
, t
, flags
);
2215 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2219 /* Print type declaration. */
2220 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2222 /* Print variable's name. */
2224 dump_generic_node (buffer
, t
, spc
, flags
, false);
2227 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2229 pp_string (buffer
, " __asm__ ");
2230 pp_character (buffer
, '(');
2231 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2232 pp_character (buffer
, ')');
2235 /* The initial value of a function serves to determine whether the function
2236 is declared or defined. So the following does not apply to function
2238 if (TREE_CODE (t
) != FUNCTION_DECL
)
2240 /* Print the initial value. */
2241 if (DECL_INITIAL (t
))
2244 pp_character (buffer
, '=');
2246 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2250 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2252 pp_string (buffer
, " [value-expr: ");
2253 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2254 pp_character (buffer
, ']');
2257 pp_character (buffer
, ';');
2261 /* Prints a structure: name, fields, and methods.
2262 FIXME: Still incomplete. */
2265 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2267 /* Print the name of the structure. */
2268 if (TYPE_NAME (node
))
2271 if (TREE_CODE (node
) == RECORD_TYPE
)
2272 pp_string (buffer
, "struct ");
2273 else if ((TREE_CODE (node
) == UNION_TYPE
2274 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2275 pp_string (buffer
, "union ");
2277 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2280 /* Print the contents of the structure. */
2281 pp_newline (buffer
);
2283 pp_character (buffer
, '{');
2284 pp_newline (buffer
);
2286 /* Print the fields of the structure. */
2289 tmp
= TYPE_FIELDS (node
);
2292 /* Avoid to print recursively the structure. */
2293 /* FIXME : Not implemented correctly...,
2294 what about the case when we have a cycle in the contain graph? ...
2295 Maybe this could be solved by looking at the scope in which the
2296 structure was declared. */
2297 if (TREE_TYPE (tmp
) != node
2298 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2299 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2301 print_declaration (buffer
, tmp
, spc
+2, flags
);
2302 pp_newline (buffer
);
2304 tmp
= TREE_CHAIN (tmp
);
2308 pp_character (buffer
, '}');
2311 /* Return the priority of the operator CODE.
2313 From lowest to highest precedence with either left-to-right (L-R)
2314 or right-to-left (R-L) associativity]:
2317 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2329 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2330 15 [L-R] fn() [] -> .
2332 unary +, - and * have higher precedence than the corresponding binary
2336 op_code_prio (enum tree_code code
)
2353 case TRUTH_ORIF_EXPR
:
2356 case TRUTH_AND_EXPR
:
2357 case TRUTH_ANDIF_EXPR
:
2364 case TRUTH_XOR_EXPR
:
2381 case UNORDERED_EXPR
:
2394 case WIDEN_SUM_EXPR
:
2396 case POINTER_PLUS_EXPR
:
2400 case VEC_WIDEN_MULT_HI_EXPR
:
2401 case VEC_WIDEN_MULT_LO_EXPR
:
2402 case WIDEN_MULT_EXPR
:
2405 case TRUNC_DIV_EXPR
:
2407 case FLOOR_DIV_EXPR
:
2408 case ROUND_DIV_EXPR
:
2410 case EXACT_DIV_EXPR
:
2411 case TRUNC_MOD_EXPR
:
2413 case FLOOR_MOD_EXPR
:
2414 case ROUND_MOD_EXPR
:
2417 case TRUTH_NOT_EXPR
:
2419 case POSTINCREMENT_EXPR
:
2420 case POSTDECREMENT_EXPR
:
2421 case PREINCREMENT_EXPR
:
2422 case PREDECREMENT_EXPR
:
2424 case ALIGN_INDIRECT_REF
:
2425 case MISALIGNED_INDIRECT_REF
:
2430 case FIX_TRUNC_EXPR
:
2436 case ARRAY_RANGE_REF
:
2440 /* Special expressions. */
2446 case REDUC_MAX_EXPR
:
2447 case REDUC_MIN_EXPR
:
2448 case REDUC_PLUS_EXPR
:
2449 case VEC_LSHIFT_EXPR
:
2450 case VEC_RSHIFT_EXPR
:
2451 case VEC_UNPACK_HI_EXPR
:
2452 case VEC_UNPACK_LO_EXPR
:
2453 case VEC_UNPACK_FLOAT_HI_EXPR
:
2454 case VEC_UNPACK_FLOAT_LO_EXPR
:
2455 case VEC_PACK_TRUNC_EXPR
:
2456 case VEC_PACK_SAT_EXPR
:
2460 /* Return an arbitrarily high precedence to avoid surrounding single
2461 VAR_DECLs in ()s. */
2466 /* Return the priority of the operator OP. */
2469 op_prio (const_tree op
)
2471 enum tree_code code
;
2476 code
= TREE_CODE (op
);
2477 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2478 return op_prio (TREE_OPERAND (op
, 0));
2480 return op_code_prio (code
);
2483 /* Return the symbol associated with operator CODE. */
2486 op_symbol_code (enum tree_code code
)
2494 case TRUTH_ORIF_EXPR
:
2497 case TRUTH_AND_EXPR
:
2498 case TRUTH_ANDIF_EXPR
:
2504 case TRUTH_XOR_EXPR
:
2514 case UNORDERED_EXPR
:
2560 case VEC_LSHIFT_EXPR
:
2563 case VEC_RSHIFT_EXPR
:
2566 case POINTER_PLUS_EXPR
:
2572 case REDUC_PLUS_EXPR
:
2575 case WIDEN_SUM_EXPR
:
2578 case WIDEN_MULT_EXPR
:
2588 case TRUTH_NOT_EXPR
:
2595 case ALIGN_INDIRECT_REF
:
2598 case MISALIGNED_INDIRECT_REF
:
2601 case TRUNC_DIV_EXPR
:
2608 case FLOOR_DIV_EXPR
:
2611 case ROUND_DIV_EXPR
:
2614 case EXACT_DIV_EXPR
:
2617 case TRUNC_MOD_EXPR
:
2623 case FLOOR_MOD_EXPR
:
2626 case ROUND_MOD_EXPR
:
2629 case PREDECREMENT_EXPR
:
2632 case PREINCREMENT_EXPR
:
2635 case POSTDECREMENT_EXPR
:
2638 case POSTINCREMENT_EXPR
:
2648 return "<<< ??? >>>";
2652 /* Return the symbol associated with operator OP. */
2655 op_symbol (const_tree op
)
2657 return op_symbol_code (TREE_CODE (op
));
2660 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2661 the gimple_call_fn of a GIMPLE_CALL. */
2664 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
2668 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2669 op0
= TREE_OPERAND (op0
, 0);
2672 switch (TREE_CODE (op0
))
2677 dump_function_name (buffer
, op0
, flags
);
2683 op0
= TREE_OPERAND (op0
, 0);
2687 pp_string (buffer
, "(");
2688 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
2689 pp_string (buffer
, ") ? ");
2690 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
2691 pp_string (buffer
, " : ");
2692 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
2696 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2697 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
2699 dump_generic_node (buffer
, op0
, 0, flags
, false);
2705 dump_generic_node (buffer
, op0
, 0, flags
, false);
2713 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2716 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2726 pp_string (buffer
, "\\b");
2730 pp_string (buffer
, "\\f");
2734 pp_string (buffer
, "\\n");
2738 pp_string (buffer
, "\\r");
2742 pp_string (buffer
, "\\t");
2746 pp_string (buffer
, "\\v");
2750 pp_string (buffer
, "\\\\");
2754 pp_string (buffer
, "\\\"");
2758 pp_string (buffer
, "\\'");
2761 /* No need to handle \0; the loop terminates on \0. */
2764 pp_string (buffer
, "\\1");
2768 pp_string (buffer
, "\\2");
2772 pp_string (buffer
, "\\3");
2776 pp_string (buffer
, "\\4");
2780 pp_string (buffer
, "\\5");
2784 pp_string (buffer
, "\\6");
2788 pp_string (buffer
, "\\7");
2792 pp_character (buffer
, str
[0]);
2800 maybe_init_pretty_print (FILE *file
)
2804 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
2805 pp_needs_newline (&buffer
) = true;
2806 pp_translate_identifiers (&buffer
) = false;
2810 buffer
.buffer
->stream
= file
;
2814 newline_and_indent (pretty_printer
*buffer
, int spc
)
2816 pp_newline (buffer
);