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 #define PRINT_FUNCTION_NAME(NODE) pp_printf \
54 (buffer, "%s", TREE_CODE (NODE) == NOP_EXPR ? \
55 lang_hooks.decl_printable_name (TREE_OPERAND (NODE, 0), 1) : \
56 lang_hooks.decl_printable_name (NODE, 1))
58 static pretty_printer buffer
;
59 static int initialized
= 0;
61 /* Try to print something for an unknown tree code. */
64 do_niy (pretty_printer
*buffer
, const_tree node
)
68 pp_string (buffer
, "<<< Unknown tree: ");
69 pp_string (buffer
, tree_code_name
[(int) TREE_CODE (node
)]);
73 len
= TREE_OPERAND_LENGTH (node
);
74 for (i
= 0; i
< len
; ++i
)
76 newline_and_indent (buffer
, 2);
77 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0, false);
81 pp_string (buffer
, " >>>\n");
84 /* Debugging function to print out a generic expression. */
87 debug_generic_expr (tree t
)
89 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
90 fprintf (stderr
, "\n");
93 /* Debugging function to print out a generic statement. */
96 debug_generic_stmt (tree t
)
98 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
99 fprintf (stderr
, "\n");
102 /* Debugging function to print out a chain of trees . */
105 debug_tree_chain (tree t
)
109 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
110 fprintf(stderr
, " ");
113 fprintf (stderr
, "\n");
116 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
118 print_generic_decl (FILE *file
, tree decl
, int flags
)
120 maybe_init_pretty_print (file
);
121 print_declaration (&buffer
, decl
, 2, flags
);
122 pp_write_text_to_stream (&buffer
);
125 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
126 to show in the dump. See TDF_* in tree-pass.h. */
129 print_generic_stmt (FILE *file
, tree t
, int flags
)
131 maybe_init_pretty_print (file
);
132 dump_generic_node (&buffer
, t
, 0, flags
, true);
136 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
137 to show in the dump. See TDF_* in tree-pass.h. The output is indented by
141 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
145 maybe_init_pretty_print (file
);
147 for (i
= 0; i
< indent
; i
++)
149 dump_generic_node (&buffer
, t
, indent
, flags
, true);
153 /* Print a single expression T on file FILE. FLAGS specifies details to show
154 in the dump. See TDF_* in tree-pass.h. */
157 print_generic_expr (FILE *file
, tree t
, int flags
)
159 maybe_init_pretty_print (file
);
160 dump_generic_node (&buffer
, t
, 0, flags
, false);
163 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
167 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
172 pp_tree_identifier (buffer
, DECL_NAME (t
));
173 if ((flags
& TDF_UID
)
174 || DECL_NAME (t
) == NULL_TREE
)
176 if (TREE_CODE (t
) == LABEL_DECL
177 && LABEL_DECL_UID (t
) != -1)
178 pp_printf (buffer
, "L.%d", (int) LABEL_DECL_UID (t
));
181 char c
= TREE_CODE (t
) == CONST_DECL
? 'C' : 'D';
182 pp_printf (buffer
, "%c.%u", c
, DECL_UID (t
));
187 /* Like the above, but used for pretty printing function calls. */
190 dump_function_name (pretty_printer
*buffer
, tree node
)
192 if (DECL_NAME (node
))
193 PRINT_FUNCTION_NAME (node
);
195 dump_decl_name (buffer
, node
, 0);
198 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
199 FLAGS are as in dump_generic_node. */
202 dump_function_declaration (pretty_printer
*buffer
, tree node
,
205 bool wrote_arg
= false;
209 pp_character (buffer
, '(');
211 /* Print the argument types. The last element in the list is a VOID_TYPE.
212 The following avoids printing the last element. */
213 arg
= TYPE_ARG_TYPES (node
);
214 while (arg
&& TREE_CHAIN (arg
) && arg
!= error_mark_node
)
217 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
218 arg
= TREE_CHAIN (arg
);
219 if (TREE_CHAIN (arg
) && TREE_CODE (TREE_CHAIN (arg
)) == TREE_LIST
)
221 pp_character (buffer
, ',');
227 pp_string (buffer
, "void");
229 pp_character (buffer
, ')');
232 /* Dump the domain associated with an array. */
235 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
237 pp_character (buffer
, '[');
240 tree min
= TYPE_MIN_VALUE (domain
);
241 tree max
= TYPE_MAX_VALUE (domain
);
244 && integer_zerop (min
)
245 && host_integerp (max
, 0))
246 pp_wide_integer (buffer
, TREE_INT_CST_LOW (max
) + 1);
250 dump_generic_node (buffer
, min
, spc
, flags
, false);
251 pp_character (buffer
, ':');
253 dump_generic_node (buffer
, max
, spc
, flags
, false);
257 pp_string (buffer
, "<unknown>");
258 pp_character (buffer
, ']');
262 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
263 dump_generic_node. */
266 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
270 switch (OMP_CLAUSE_CODE (clause
))
272 case OMP_CLAUSE_PRIVATE
:
275 case OMP_CLAUSE_SHARED
:
278 case OMP_CLAUSE_FIRSTPRIVATE
:
279 name
= "firstprivate";
281 case OMP_CLAUSE_LASTPRIVATE
:
282 name
= "lastprivate";
284 case OMP_CLAUSE_COPYIN
:
287 case OMP_CLAUSE_COPYPRIVATE
:
288 name
= "copyprivate";
291 pp_string (buffer
, name
);
292 pp_character (buffer
, '(');
293 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
295 pp_character (buffer
, ')');
298 case OMP_CLAUSE_REDUCTION
:
299 pp_string (buffer
, "reduction(");
300 pp_string (buffer
, op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
301 pp_character (buffer
, ':');
302 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
304 pp_character (buffer
, ')');
308 pp_string (buffer
, "if(");
309 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
311 pp_character (buffer
, ')');
314 case OMP_CLAUSE_NUM_THREADS
:
315 pp_string (buffer
, "num_threads(");
316 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
318 pp_character (buffer
, ')');
321 case OMP_CLAUSE_NOWAIT
:
322 pp_string (buffer
, "nowait");
324 case OMP_CLAUSE_ORDERED
:
325 pp_string (buffer
, "ordered");
328 case OMP_CLAUSE_DEFAULT
:
329 pp_string (buffer
, "default(");
330 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
332 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
334 case OMP_CLAUSE_DEFAULT_SHARED
:
335 pp_string (buffer
, "shared");
337 case OMP_CLAUSE_DEFAULT_NONE
:
338 pp_string (buffer
, "none");
340 case OMP_CLAUSE_DEFAULT_PRIVATE
:
341 pp_string (buffer
, "private");
343 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE
:
344 pp_string (buffer
, "firstprivate");
349 pp_character (buffer
, ')');
352 case OMP_CLAUSE_SCHEDULE
:
353 pp_string (buffer
, "schedule(");
354 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
356 case OMP_CLAUSE_SCHEDULE_STATIC
:
357 pp_string (buffer
, "static");
359 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
360 pp_string (buffer
, "dynamic");
362 case OMP_CLAUSE_SCHEDULE_GUIDED
:
363 pp_string (buffer
, "guided");
365 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
366 pp_string (buffer
, "runtime");
368 case OMP_CLAUSE_SCHEDULE_AUTO
:
369 pp_string (buffer
, "auto");
374 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
376 pp_character (buffer
, ',');
377 dump_generic_node (buffer
,
378 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
381 pp_character (buffer
, ')');
384 case OMP_CLAUSE_UNTIED
:
385 pp_string (buffer
, "untied");
388 case OMP_CLAUSE_COLLAPSE
:
389 pp_string (buffer
, "collapse(");
390 dump_generic_node (buffer
,
391 OMP_CLAUSE_COLLAPSE_EXPR (clause
),
393 pp_character (buffer
, ')');
397 /* Should never happen. */
398 dump_generic_node (buffer
, clause
, spc
, flags
, false);
404 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
405 dump_generic_node. */
408 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
416 dump_omp_clause (buffer
, clause
, spc
, flags
);
417 clause
= OMP_CLAUSE_CHAIN (clause
);
425 /* Dump location LOC to BUFFER. */
428 dump_location (pretty_printer
*buffer
, location_t loc
)
430 expanded_location xloc
= expand_location (loc
);
432 pp_character (buffer
, '[');
435 pp_string (buffer
, xloc
.file
);
436 pp_string (buffer
, " : ");
438 pp_decimal_int (buffer
, xloc
.line
);
439 pp_string (buffer
, "] ");
443 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
444 dump_generic_node. */
447 dump_block_node (pretty_printer
*buffer
, tree block
, int spc
, int flags
)
451 pp_printf (buffer
, "BLOCK #%d ", BLOCK_NUMBER (block
));
453 if (flags
& TDF_ADDRESS
)
454 pp_printf (buffer
, "[%p] ", (void *) block
);
456 if (BLOCK_ABSTRACT (block
))
457 pp_string (buffer
, "[abstract] ");
459 if (TREE_ASM_WRITTEN (block
))
460 pp_string (buffer
, "[written] ");
462 if (flags
& TDF_SLIM
)
465 if (BLOCK_SOURCE_LOCATION (block
))
466 dump_location (buffer
, BLOCK_SOURCE_LOCATION (block
));
468 newline_and_indent (buffer
, spc
+ 2);
470 if (BLOCK_SUPERCONTEXT (block
))
472 pp_string (buffer
, "SUPERCONTEXT: ");
473 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (block
), 0,
474 flags
| TDF_SLIM
, false);
475 newline_and_indent (buffer
, spc
+ 2);
478 if (BLOCK_SUBBLOCKS (block
))
480 pp_string (buffer
, "SUBBLOCKS: ");
481 for (t
= BLOCK_SUBBLOCKS (block
); t
; t
= BLOCK_CHAIN (t
))
483 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
484 pp_string (buffer
, " ");
486 newline_and_indent (buffer
, spc
+ 2);
489 if (BLOCK_CHAIN (block
))
491 pp_string (buffer
, "SIBLINGS: ");
492 for (t
= BLOCK_CHAIN (block
); t
; t
= BLOCK_CHAIN (t
))
494 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
495 pp_string (buffer
, " ");
497 newline_and_indent (buffer
, spc
+ 2);
500 if (BLOCK_VARS (block
))
502 pp_string (buffer
, "VARS: ");
503 for (t
= BLOCK_VARS (block
); t
; t
= TREE_CHAIN (t
))
505 dump_generic_node (buffer
, t
, 0, flags
, false);
506 pp_string (buffer
, " ");
508 newline_and_indent (buffer
, spc
+ 2);
511 if (VEC_length (tree
, BLOCK_NONLOCALIZED_VARS (block
)) > 0)
514 VEC(tree
,gc
) *nlv
= BLOCK_NONLOCALIZED_VARS (block
);
516 pp_string (buffer
, "NONLOCALIZED_VARS: ");
517 for (i
= 0; VEC_iterate (tree
, nlv
, i
, t
); i
++)
519 dump_generic_node (buffer
, t
, 0, flags
, false);
520 pp_string (buffer
, " ");
522 newline_and_indent (buffer
, spc
+ 2);
525 if (BLOCK_ABSTRACT_ORIGIN (block
))
527 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
528 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (block
), 0,
529 flags
| TDF_SLIM
, false);
530 newline_and_indent (buffer
, spc
+ 2);
533 if (BLOCK_FRAGMENT_ORIGIN (block
))
535 pp_string (buffer
, "FRAGMENT_ORIGIN: ");
536 dump_generic_node (buffer
, BLOCK_FRAGMENT_ORIGIN (block
), 0,
537 flags
| TDF_SLIM
, false);
538 newline_and_indent (buffer
, spc
+ 2);
541 if (BLOCK_FRAGMENT_CHAIN (block
))
543 pp_string (buffer
, "FRAGMENT_CHAIN: ");
544 for (t
= BLOCK_FRAGMENT_CHAIN (block
); t
; t
= BLOCK_FRAGMENT_CHAIN (t
))
546 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
547 pp_string (buffer
, " ");
549 newline_and_indent (buffer
, spc
+ 2);
554 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
555 indent. FLAGS specifies details to show in the dump (see TDF_* in
556 tree-pass.h). If IS_STMT is true, the object printed is considered
557 to be a statement and it is terminated by ';' if appropriate. */
560 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
568 if (node
== NULL_TREE
)
571 is_expr
= EXPR_P (node
);
573 if (is_stmt
&& (flags
& TDF_STMTADDR
))
574 pp_printf (buffer
, "<&%p> ", (void *)node
);
576 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
577 dump_location (buffer
, EXPR_LOCATION (node
));
579 switch (TREE_CODE (node
))
582 pp_string (buffer
, "<<< error >>>");
585 case IDENTIFIER_NODE
:
586 pp_tree_identifier (buffer
, node
);
590 while (node
&& node
!= error_mark_node
)
592 if (TREE_PURPOSE (node
))
594 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
597 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
598 node
= TREE_CHAIN (node
);
599 if (node
&& TREE_CODE (node
) == TREE_LIST
)
601 pp_character (buffer
, ',');
608 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
614 if (TREE_VEC_LENGTH (node
) > 0)
616 size_t len
= TREE_VEC_LENGTH (node
);
617 for (i
= 0; i
< len
- 1; i
++)
619 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
621 pp_character (buffer
, ',');
624 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
633 case FIXED_POINT_TYPE
:
639 unsigned int quals
= TYPE_QUALS (node
);
640 enum tree_code_class tclass
;
642 if (quals
& TYPE_QUAL_CONST
)
643 pp_string (buffer
, "const ");
644 else if (quals
& TYPE_QUAL_VOLATILE
)
645 pp_string (buffer
, "volatile ");
646 else if (quals
& TYPE_QUAL_RESTRICT
)
647 pp_string (buffer
, "restrict ");
649 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
651 if (tclass
== tcc_declaration
)
653 if (DECL_NAME (node
))
654 dump_decl_name (buffer
, node
, flags
);
656 pp_string (buffer
, "<unnamed type decl>");
658 else if (tclass
== tcc_type
)
660 if (TYPE_NAME (node
))
662 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
663 pp_tree_identifier (buffer
, TYPE_NAME (node
));
664 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
665 && DECL_NAME (TYPE_NAME (node
)))
666 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
668 pp_string (buffer
, "<unnamed type>");
670 else if (TREE_CODE (node
) == VECTOR_TYPE
)
672 pp_string (buffer
, "vector ");
673 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
675 else if (TREE_CODE (node
) == INTEGER_TYPE
)
677 pp_string (buffer
, (TYPE_UNSIGNED (node
)
678 ? "<unnamed-unsigned:"
679 : "<unnamed-signed:"));
680 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
681 pp_string (buffer
, ">");
683 else if (TREE_CODE (node
) == COMPLEX_TYPE
)
685 pp_string (buffer
, "__complex__ ");
686 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
688 else if (TREE_CODE (node
) == REAL_TYPE
)
690 pp_string (buffer
, "<float:");
691 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
692 pp_string (buffer
, ">");
694 else if (TREE_CODE (node
) == FIXED_POINT_TYPE
)
696 pp_string (buffer
, "<fixed-point-");
697 pp_string (buffer
, TYPE_SATURATING (node
) ? "sat:" : "nonsat:");
698 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
699 pp_string (buffer
, ">");
702 pp_string (buffer
, "<unnamed type>");
709 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
711 if (TREE_TYPE (node
) == NULL
)
713 pp_string (buffer
, str
);
714 pp_string (buffer
, "<null type>");
716 else if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
718 tree fnode
= TREE_TYPE (node
);
720 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
722 pp_character (buffer
, '(');
723 pp_string (buffer
, str
);
724 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
725 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
727 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
729 pp_character (buffer
, ')');
730 dump_function_declaration (buffer
, fnode
, spc
, flags
);
734 unsigned int quals
= TYPE_QUALS (node
);
736 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
738 pp_string (buffer
, str
);
740 if (quals
& TYPE_QUAL_CONST
)
741 pp_string (buffer
, " const");
742 if (quals
& TYPE_QUAL_VOLATILE
)
743 pp_string (buffer
, " volatile");
744 if (quals
& TYPE_QUAL_RESTRICT
)
745 pp_string (buffer
, " restrict");
747 if (TYPE_REF_CAN_ALIAS_ALL (node
))
748 pp_string (buffer
, " {ref-all}");
758 const char *sep
= "";
761 pp_string (buffer
, "MEM[");
763 tmp
= TMR_SYMBOL (node
);
766 pp_string (buffer
, sep
);
768 pp_string (buffer
, "symbol: ");
769 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
771 tmp
= TMR_BASE (node
);
774 pp_string (buffer
, sep
);
776 pp_string (buffer
, "base: ");
777 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
779 tmp
= TMR_INDEX (node
);
782 pp_string (buffer
, sep
);
784 pp_string (buffer
, "index: ");
785 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
787 tmp
= TMR_STEP (node
);
790 pp_string (buffer
, sep
);
792 pp_string (buffer
, "step: ");
793 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
795 tmp
= TMR_OFFSET (node
);
798 pp_string (buffer
, sep
);
800 pp_string (buffer
, "offset: ");
801 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
803 pp_string (buffer
, "]");
804 if (flags
& TDF_DETAILS
)
806 pp_string (buffer
, "{");
807 dump_generic_node (buffer
, TMR_ORIGINAL (node
), spc
, flags
,
809 pp_string (buffer
, "}");
818 /* Print the innermost component type. */
819 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
820 tmp
= TREE_TYPE (tmp
))
822 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
824 /* Print the dimensions. */
825 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
826 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
832 case QUAL_UNION_TYPE
:
834 unsigned int quals
= TYPE_QUALS (node
);
836 if (quals
& TYPE_QUAL_CONST
)
837 pp_string (buffer
, "const ");
838 if (quals
& TYPE_QUAL_VOLATILE
)
839 pp_string (buffer
, "volatile ");
841 /* Print the name of the structure. */
842 if (TREE_CODE (node
) == RECORD_TYPE
)
843 pp_string (buffer
, "struct ");
844 else if (TREE_CODE (node
) == UNION_TYPE
)
845 pp_string (buffer
, "union ");
847 if (TYPE_NAME (node
))
848 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
849 else if (!(flags
& TDF_SLIM
))
850 /* FIXME: If we eliminate the 'else' above and attempt
851 to show the fields for named types, we may get stuck
852 following a cycle of pointers to structs. The alleged
853 self-reference check in print_struct_decl will not detect
854 cycles involving more than one pointer or struct type. */
855 print_struct_decl (buffer
, node
, spc
, flags
);
864 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
866 /* In the case of a pointer, one may want to divide by the
867 size of the pointed-to type. Unfortunately, this not
868 straightforward. The C front-end maps expressions
873 in such a way that the two INTEGER_CST nodes for "5" have
874 different values but identical types. In the latter
875 case, the 5 is multiplied by sizeof (int) in c-common.c
876 (pointer_int_sum) to convert it to a byte address, and
877 yet the type of the node is left unchanged. Argh. What
878 is consistent though is that the number value corresponds
879 to bytes (UNITS) offset.
881 NB: Neither of the following divisors can be trivially
882 used to recover the original literal:
884 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
885 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
886 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
887 pp_string (buffer
, "B"); /* pseudo-unit */
889 else if (! host_integerp (node
, 0))
892 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (val
);
893 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (val
);
895 if (tree_int_cst_sgn (val
) < 0)
897 pp_character (buffer
, '-');
901 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
903 sprintf (pp_buffer (buffer
)->digit_buffer
,
904 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
905 (unsigned HOST_WIDE_INT
) high
, low
);
906 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
909 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
913 /* Code copied from print_node. */
916 if (TREE_OVERFLOW (node
))
917 pp_string (buffer
, " overflow");
919 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
920 d
= TREE_REAL_CST (node
);
921 if (REAL_VALUE_ISINF (d
))
922 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
923 else if (REAL_VALUE_ISNAN (d
))
924 pp_string (buffer
, " Nan");
928 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
929 pp_string (buffer
, string
);
934 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
935 pp_string (buffer
, "0x");
936 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
937 output_formatted_integer (buffer
, "%02x", *p
++);
946 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
947 pp_string (buffer
, string
);
952 pp_string (buffer
, "__complex__ (");
953 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
954 pp_string (buffer
, ", ");
955 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
956 pp_string (buffer
, ")");
960 pp_string (buffer
, "\"");
961 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
962 pp_string (buffer
, "\"");
968 pp_string (buffer
, "{ ");
969 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
971 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
, false);
972 if (TREE_CHAIN (elt
))
973 pp_string (buffer
, ", ");
975 pp_string (buffer
, " }");
981 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
983 if (TREE_CODE (node
) == METHOD_TYPE
)
985 if (TYPE_METHOD_BASETYPE (node
))
986 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
989 pp_string (buffer
, "<null method basetype>");
990 pp_string (buffer
, "::");
992 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
993 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
995 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
996 dump_function_declaration (buffer
, node
, spc
, flags
);
1001 dump_decl_name (buffer
, node
, flags
);
1005 if (DECL_NAME (node
))
1006 dump_decl_name (buffer
, node
, flags
);
1007 else if (LABEL_DECL_UID (node
) != -1)
1008 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1010 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1014 if (DECL_IS_BUILTIN (node
))
1016 /* Don't print the declaration of built-in types. */
1019 if (DECL_NAME (node
))
1020 dump_decl_name (buffer
, node
, flags
);
1023 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1024 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1025 && TYPE_METHODS (TREE_TYPE (node
)))
1027 /* The type is a c++ class: all structures have at least
1029 pp_string (buffer
, "class ");
1030 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1035 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1036 ? "union" : "struct "));
1037 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1045 case NAMESPACE_DECL
:
1046 dump_decl_name (buffer
, node
, flags
);
1050 pp_string (buffer
, "<retval>");
1054 op0
= TREE_OPERAND (node
, 0);
1056 if (TREE_CODE (op0
) == INDIRECT_REF
)
1058 op0
= TREE_OPERAND (op0
, 0);
1061 if (op_prio (op0
) < op_prio (node
))
1062 pp_character (buffer
, '(');
1063 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1064 if (op_prio (op0
) < op_prio (node
))
1065 pp_character (buffer
, ')');
1066 pp_string (buffer
, str
);
1067 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1068 op0
= component_ref_field_offset (node
);
1069 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1071 pp_string (buffer
, "{off: ");
1072 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1073 pp_character (buffer
, '}');
1078 pp_string (buffer
, "BIT_FIELD_REF <");
1079 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1080 pp_string (buffer
, ", ");
1081 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1082 pp_string (buffer
, ", ");
1083 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1084 pp_string (buffer
, ">");
1088 case ARRAY_RANGE_REF
:
1089 op0
= TREE_OPERAND (node
, 0);
1090 if (op_prio (op0
) < op_prio (node
))
1091 pp_character (buffer
, '(');
1092 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1093 if (op_prio (op0
) < op_prio (node
))
1094 pp_character (buffer
, ')');
1095 pp_character (buffer
, '[');
1096 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1097 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1098 pp_string (buffer
, " ...");
1099 pp_character (buffer
, ']');
1101 op0
= array_ref_low_bound (node
);
1102 op1
= array_ref_element_size (node
);
1104 if (!integer_zerop (op0
)
1105 || TREE_OPERAND (node
, 2)
1106 || TREE_OPERAND (node
, 3))
1108 pp_string (buffer
, "{lb: ");
1109 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1110 pp_string (buffer
, " sz: ");
1111 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1112 pp_character (buffer
, '}');
1118 unsigned HOST_WIDE_INT ix
;
1120 bool is_struct_init
= FALSE
;
1121 pp_character (buffer
, '{');
1122 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1123 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1124 is_struct_init
= TRUE
;
1125 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1127 if (field
&& is_struct_init
)
1129 pp_character (buffer
, '.');
1130 dump_generic_node (buffer
, field
, spc
, flags
, false);
1131 pp_string (buffer
, "=");
1133 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1134 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1135 val
= TREE_OPERAND (val
, 0);
1136 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1137 dump_decl_name (buffer
, val
, flags
);
1139 dump_generic_node (buffer
, val
, spc
, flags
, false);
1140 if (ix
!= VEC_length (constructor_elt
, CONSTRUCTOR_ELTS (node
)) - 1)
1142 pp_character (buffer
, ',');
1146 pp_character (buffer
, '}');
1153 if (flags
& TDF_SLIM
)
1155 pp_string (buffer
, "<COMPOUND_EXPR>");
1159 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1160 spc
, flags
, !(flags
& TDF_SLIM
));
1161 if (flags
& TDF_SLIM
)
1162 newline_and_indent (buffer
, spc
);
1165 pp_character (buffer
, ',');
1169 for (tp
= &TREE_OPERAND (node
, 1);
1170 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1171 tp
= &TREE_OPERAND (*tp
, 1))
1173 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1174 spc
, flags
, !(flags
& TDF_SLIM
));
1175 if (flags
& TDF_SLIM
)
1176 newline_and_indent (buffer
, spc
);
1179 pp_character (buffer
, ',');
1184 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1188 case STATEMENT_LIST
:
1190 tree_stmt_iterator si
;
1193 if (flags
& TDF_SLIM
)
1195 pp_string (buffer
, "<STATEMENT_LIST>");
1199 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1202 newline_and_indent (buffer
, spc
);
1205 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1212 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1215 pp_character (buffer
, '=');
1216 if (TREE_CODE (node
) == MODIFY_EXPR
1217 && MOVE_NONTEMPORAL (node
))
1218 pp_string (buffer
, "{nt}");
1220 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1225 pp_string (buffer
, "TARGET_EXPR <");
1226 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1227 pp_character (buffer
, ',');
1229 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1230 pp_character (buffer
, '>');
1234 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1239 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1241 pp_string (buffer
, "if (");
1242 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1243 pp_character (buffer
, ')');
1244 /* The lowered cond_exprs should always be printed in full. */
1245 if (COND_EXPR_THEN (node
)
1246 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1247 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1248 && COND_EXPR_ELSE (node
)
1249 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1250 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1253 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1255 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1257 pp_string (buffer
, " else ");
1258 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1262 else if (!(flags
& TDF_SLIM
))
1264 /* Output COND_EXPR_THEN. */
1265 if (COND_EXPR_THEN (node
))
1267 newline_and_indent (buffer
, spc
+2);
1268 pp_character (buffer
, '{');
1269 newline_and_indent (buffer
, spc
+4);
1270 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1272 newline_and_indent (buffer
, spc
+2);
1273 pp_character (buffer
, '}');
1276 /* Output COND_EXPR_ELSE. */
1277 if (COND_EXPR_ELSE (node
)
1278 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1280 newline_and_indent (buffer
, spc
);
1281 pp_string (buffer
, "else");
1282 newline_and_indent (buffer
, spc
+2);
1283 pp_character (buffer
, '{');
1284 newline_and_indent (buffer
, spc
+4);
1285 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1287 newline_and_indent (buffer
, spc
+2);
1288 pp_character (buffer
, '}');
1295 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1297 pp_character (buffer
, '?');
1299 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1301 pp_character (buffer
, ':');
1303 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1308 pp_character (buffer
, '{');
1309 if (!(flags
& TDF_SLIM
))
1311 if (BIND_EXPR_VARS (node
))
1313 pp_newline (buffer
);
1315 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= TREE_CHAIN (op0
))
1317 print_declaration (buffer
, op0
, spc
+2, flags
);
1318 pp_newline (buffer
);
1322 newline_and_indent (buffer
, spc
+2);
1323 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1324 newline_and_indent (buffer
, spc
);
1325 pp_character (buffer
, '}');
1331 print_call_name (buffer
, CALL_EXPR_FN (node
));
1333 /* Print parameters. */
1335 pp_character (buffer
, '(');
1338 call_expr_arg_iterator iter
;
1339 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1341 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1342 if (more_call_expr_args_p (&iter
))
1344 pp_character (buffer
, ',');
1349 if (CALL_EXPR_VA_ARG_PACK (node
))
1351 if (call_expr_nargs (node
) > 0)
1353 pp_character (buffer
, ',');
1356 pp_string (buffer
, "__builtin_va_arg_pack ()");
1358 pp_character (buffer
, ')');
1360 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1363 pp_string (buffer
, " [static-chain: ");
1364 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1365 pp_character (buffer
, ']');
1368 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1369 pp_string (buffer
, " [return slot optimization]");
1370 if (CALL_EXPR_TAILCALL (node
))
1371 pp_string (buffer
, " [tail call]");
1374 case WITH_CLEANUP_EXPR
:
1378 case CLEANUP_POINT_EXPR
:
1379 pp_string (buffer
, "<<cleanup_point ");
1380 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1381 pp_string (buffer
, ">>");
1384 case PLACEHOLDER_EXPR
:
1385 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1386 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1387 pp_character (buffer
, '>');
1390 /* Binary arithmetic and logic expressions. */
1391 case WIDEN_SUM_EXPR
:
1392 case WIDEN_MULT_EXPR
:
1395 case POINTER_PLUS_EXPR
:
1397 case TRUNC_DIV_EXPR
:
1399 case FLOOR_DIV_EXPR
:
1400 case ROUND_DIV_EXPR
:
1401 case TRUNC_MOD_EXPR
:
1403 case FLOOR_MOD_EXPR
:
1404 case ROUND_MOD_EXPR
:
1406 case EXACT_DIV_EXPR
:
1411 case VEC_LSHIFT_EXPR
:
1412 case VEC_RSHIFT_EXPR
:
1416 case TRUTH_ANDIF_EXPR
:
1417 case TRUTH_ORIF_EXPR
:
1418 case TRUTH_AND_EXPR
:
1420 case TRUTH_XOR_EXPR
:
1434 case UNORDERED_EXPR
:
1436 const char *op
= op_symbol (node
);
1437 op0
= TREE_OPERAND (node
, 0);
1438 op1
= TREE_OPERAND (node
, 1);
1440 /* When the operands are expressions with less priority,
1441 keep semantics of the tree representation. */
1442 if (op_prio (op0
) <= op_prio (node
))
1444 pp_character (buffer
, '(');
1445 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1446 pp_character (buffer
, ')');
1449 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1452 pp_string (buffer
, op
);
1455 /* When the operands are expressions with less priority,
1456 keep semantics of the tree representation. */
1457 if (op_prio (op1
) <= op_prio (node
))
1459 pp_character (buffer
, '(');
1460 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1461 pp_character (buffer
, ')');
1464 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1468 /* Unary arithmetic and logic expressions. */
1471 case TRUTH_NOT_EXPR
:
1473 case PREDECREMENT_EXPR
:
1474 case PREINCREMENT_EXPR
:
1475 case ALIGN_INDIRECT_REF
:
1476 case MISALIGNED_INDIRECT_REF
:
1478 if (TREE_CODE (node
) == ADDR_EXPR
1479 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1480 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1481 ; /* Do not output '&' for strings and function pointers. */
1483 pp_string (buffer
, op_symbol (node
));
1485 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1487 pp_character (buffer
, '(');
1488 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1489 pp_character (buffer
, ')');
1492 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1494 if (TREE_CODE (node
) == MISALIGNED_INDIRECT_REF
)
1496 pp_string (buffer
, "{misalignment: ");
1497 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1498 pp_character (buffer
, '}');
1502 case POSTDECREMENT_EXPR
:
1503 case POSTINCREMENT_EXPR
:
1504 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1506 pp_character (buffer
, '(');
1507 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1508 pp_character (buffer
, ')');
1511 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1512 pp_string (buffer
, op_symbol (node
));
1516 pp_string (buffer
, "MIN_EXPR <");
1517 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1518 pp_string (buffer
, ", ");
1519 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1520 pp_character (buffer
, '>');
1524 pp_string (buffer
, "MAX_EXPR <");
1525 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1526 pp_string (buffer
, ", ");
1527 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1528 pp_character (buffer
, '>');
1532 pp_string (buffer
, "ABS_EXPR <");
1533 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1534 pp_character (buffer
, '>');
1541 case FIXED_CONVERT_EXPR
:
1542 case FIX_TRUNC_EXPR
:
1545 type
= TREE_TYPE (node
);
1546 op0
= TREE_OPERAND (node
, 0);
1547 if (type
!= TREE_TYPE (op0
))
1549 pp_character (buffer
, '(');
1550 dump_generic_node (buffer
, type
, spc
, flags
, false);
1551 pp_string (buffer
, ") ");
1553 if (op_prio (op0
) < op_prio (node
))
1554 pp_character (buffer
, '(');
1555 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1556 if (op_prio (op0
) < op_prio (node
))
1557 pp_character (buffer
, ')');
1560 case VIEW_CONVERT_EXPR
:
1561 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1562 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1563 pp_string (buffer
, ">(");
1564 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1565 pp_character (buffer
, ')');
1569 pp_string (buffer
, "((");
1570 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1571 pp_string (buffer
, "))");
1574 case NON_LVALUE_EXPR
:
1575 pp_string (buffer
, "NON_LVALUE_EXPR <");
1576 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1577 pp_character (buffer
, '>');
1581 pp_string (buffer
, "SAVE_EXPR <");
1582 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1583 pp_character (buffer
, '>');
1587 pp_string (buffer
, "COMPLEX_EXPR <");
1588 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1589 pp_string (buffer
, ", ");
1590 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1591 pp_string (buffer
, ">");
1595 pp_string (buffer
, "CONJ_EXPR <");
1596 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1597 pp_string (buffer
, ">");
1601 pp_string (buffer
, "REALPART_EXPR <");
1602 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1603 pp_string (buffer
, ">");
1607 pp_string (buffer
, "IMAGPART_EXPR <");
1608 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1609 pp_string (buffer
, ">");
1613 pp_string (buffer
, "VA_ARG_EXPR <");
1614 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1615 pp_string (buffer
, ">");
1618 case TRY_FINALLY_EXPR
:
1619 case TRY_CATCH_EXPR
:
1620 pp_string (buffer
, "try");
1621 newline_and_indent (buffer
, spc
+2);
1622 pp_string (buffer
, "{");
1623 newline_and_indent (buffer
, spc
+4);
1624 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1625 newline_and_indent (buffer
, spc
+2);
1626 pp_string (buffer
, "}");
1627 newline_and_indent (buffer
, spc
);
1629 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
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
, 1), spc
+4, flags
, true);
1634 newline_and_indent (buffer
, spc
+2);
1635 pp_string (buffer
, "}");
1640 pp_string (buffer
, "catch (");
1641 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1642 pp_string (buffer
, ")");
1643 newline_and_indent (buffer
, spc
+2);
1644 pp_string (buffer
, "{");
1645 newline_and_indent (buffer
, spc
+4);
1646 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1647 newline_and_indent (buffer
, spc
+2);
1648 pp_string (buffer
, "}");
1652 case EH_FILTER_EXPR
:
1653 pp_string (buffer
, "<<<eh_filter (");
1654 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1655 pp_string (buffer
, ")>>>");
1656 newline_and_indent (buffer
, spc
+2);
1657 pp_string (buffer
, "{");
1658 newline_and_indent (buffer
, spc
+4);
1659 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1660 newline_and_indent (buffer
, spc
+2);
1661 pp_string (buffer
, "}");
1666 op0
= TREE_OPERAND (node
, 0);
1667 /* If this is for break or continue, don't bother printing it. */
1668 if (DECL_NAME (op0
))
1670 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1671 if (strcmp (name
, "break") == 0
1672 || strcmp (name
, "continue") == 0)
1675 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1676 pp_character (buffer
, ':');
1677 if (DECL_NONLOCAL (op0
))
1678 pp_string (buffer
, " [non-local]");
1682 pp_string (buffer
, "<<<exception object>>>");
1686 pp_string (buffer
, "<<<filter object>>>");
1690 pp_string (buffer
, "while (1)");
1691 if (!(flags
& TDF_SLIM
))
1693 newline_and_indent (buffer
, spc
+2);
1694 pp_character (buffer
, '{');
1695 newline_and_indent (buffer
, spc
+4);
1696 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1697 newline_and_indent (buffer
, spc
+2);
1698 pp_character (buffer
, '}');
1704 pp_string (buffer
, "// predicted ");
1705 if (PREDICT_EXPR_OUTCOME (node
))
1706 pp_string (buffer
, "likely by ");
1708 pp_string (buffer
, "unlikely by ");
1709 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
1710 pp_string (buffer
, " predictor.");
1714 pp_string (buffer
, "return");
1715 op0
= TREE_OPERAND (node
, 0);
1719 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1720 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
1723 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1728 pp_string (buffer
, "if (");
1729 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1730 pp_string (buffer
, ") break");
1734 pp_string (buffer
, "switch (");
1735 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1736 pp_character (buffer
, ')');
1737 if (!(flags
& TDF_SLIM
))
1739 newline_and_indent (buffer
, spc
+2);
1740 pp_character (buffer
, '{');
1741 if (SWITCH_BODY (node
))
1743 newline_and_indent (buffer
, spc
+4);
1744 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1749 tree vec
= SWITCH_LABELS (node
);
1750 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1751 for (i
= 0; i
< n
; ++i
)
1753 tree elt
= TREE_VEC_ELT (vec
, i
);
1754 newline_and_indent (buffer
, spc
+4);
1757 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1758 pp_string (buffer
, " goto ");
1759 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1761 pp_semicolon (buffer
);
1764 pp_string (buffer
, "case ???: goto ???;");
1767 newline_and_indent (buffer
, spc
+2);
1768 pp_character (buffer
, '}');
1774 op0
= GOTO_DESTINATION (node
);
1775 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1777 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1778 if (strcmp (name
, "break") == 0
1779 || strcmp (name
, "continue") == 0)
1781 pp_string (buffer
, name
);
1785 pp_string (buffer
, "goto ");
1786 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1790 pp_string (buffer
, "resx ");
1791 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1795 pp_string (buffer
, "__asm__");
1796 if (ASM_VOLATILE_P (node
))
1797 pp_string (buffer
, " __volatile__");
1798 pp_character (buffer
, '(');
1799 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1800 pp_character (buffer
, ':');
1801 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1802 pp_character (buffer
, ':');
1803 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1804 if (ASM_CLOBBERS (node
))
1806 pp_character (buffer
, ':');
1807 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1809 pp_string (buffer
, ")");
1812 case CASE_LABEL_EXPR
:
1813 if (CASE_LOW (node
) && CASE_HIGH (node
))
1815 pp_string (buffer
, "case ");
1816 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1817 pp_string (buffer
, " ... ");
1818 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1820 else if (CASE_LOW (node
))
1822 pp_string (buffer
, "case ");
1823 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1826 pp_string (buffer
, "default");
1827 pp_character (buffer
, ':');
1831 pp_string (buffer
, "OBJ_TYPE_REF(");
1832 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1833 pp_character (buffer
, ';');
1834 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1835 pp_character (buffer
, '-');
1836 pp_character (buffer
, '>');
1837 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
1838 pp_character (buffer
, ')');
1842 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
1843 pp_string (buffer
, "_");
1844 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1845 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
1846 pp_string (buffer
, "(ab)");
1847 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
1848 pp_string (buffer
, "(D)");
1851 case WITH_SIZE_EXPR
:
1852 pp_string (buffer
, "WITH_SIZE_EXPR <");
1853 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1854 pp_string (buffer
, ", ");
1855 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1856 pp_string (buffer
, ">");
1860 pp_string (buffer
, "ASSERT_EXPR <");
1861 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
1862 pp_string (buffer
, ", ");
1863 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
1864 pp_string (buffer
, ">");
1868 pp_string (buffer
, "scev_known");
1871 case SCEV_NOT_KNOWN
:
1872 pp_string (buffer
, "scev_not_known");
1875 case POLYNOMIAL_CHREC
:
1876 pp_string (buffer
, "{");
1877 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
1878 pp_string (buffer
, ", +, ");
1879 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
1880 pp_string (buffer
, "}_");
1881 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
1885 case REALIGN_LOAD_EXPR
:
1886 pp_string (buffer
, "REALIGN_LOAD <");
1887 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1888 pp_string (buffer
, ", ");
1889 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1890 pp_string (buffer
, ", ");
1891 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1892 pp_string (buffer
, ">");
1896 pp_string (buffer
, " VEC_COND_EXPR < ");
1897 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1898 pp_string (buffer
, " , ");
1899 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1900 pp_string (buffer
, " , ");
1901 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1902 pp_string (buffer
, " > ");
1906 pp_string (buffer
, " DOT_PROD_EXPR < ");
1907 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1908 pp_string (buffer
, ", ");
1909 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1910 pp_string (buffer
, ", ");
1911 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1912 pp_string (buffer
, " > ");
1916 pp_string (buffer
, "#pragma omp parallel");
1917 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
1920 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
1922 newline_and_indent (buffer
, spc
+ 2);
1923 pp_character (buffer
, '{');
1924 newline_and_indent (buffer
, spc
+ 4);
1925 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
1926 newline_and_indent (buffer
, spc
+ 2);
1927 pp_character (buffer
, '}');
1933 pp_string (buffer
, "#pragma omp task");
1934 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
1938 pp_string (buffer
, "#pragma omp for");
1939 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
1941 if (!(flags
& TDF_SLIM
))
1945 if (OMP_FOR_PRE_BODY (node
))
1947 newline_and_indent (buffer
, spc
+ 2);
1948 pp_character (buffer
, '{');
1950 newline_and_indent (buffer
, spc
);
1951 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
1955 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
1958 newline_and_indent (buffer
, spc
);
1959 pp_string (buffer
, "for (");
1960 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
1962 pp_string (buffer
, "; ");
1963 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
1965 pp_string (buffer
, "; ");
1966 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
1968 pp_string (buffer
, ")");
1970 if (OMP_FOR_BODY (node
))
1972 newline_and_indent (buffer
, spc
+ 2);
1973 pp_character (buffer
, '{');
1974 newline_and_indent (buffer
, spc
+ 4);
1975 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
1977 newline_and_indent (buffer
, spc
+ 2);
1978 pp_character (buffer
, '}');
1980 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
1981 if (OMP_FOR_PRE_BODY (node
))
1984 newline_and_indent (buffer
, spc
+ 2);
1985 pp_character (buffer
, '}');
1992 pp_string (buffer
, "#pragma omp sections");
1993 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
1997 pp_string (buffer
, "#pragma omp section");
2001 pp_string (buffer
, "#pragma omp master");
2005 pp_string (buffer
, "#pragma omp ordered");
2009 pp_string (buffer
, "#pragma omp critical");
2010 if (OMP_CRITICAL_NAME (node
))
2013 pp_character (buffer
, '(');
2014 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2016 pp_character (buffer
, ')');
2021 pp_string (buffer
, "#pragma omp atomic");
2022 newline_and_indent (buffer
, spc
+ 2);
2023 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2025 pp_character (buffer
, '=');
2027 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2031 pp_string (buffer
, "#pragma omp single");
2032 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2036 dump_omp_clause (buffer
, node
, spc
, flags
);
2040 case REDUC_MAX_EXPR
:
2041 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2042 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2043 pp_string (buffer
, " > ");
2046 case REDUC_MIN_EXPR
:
2047 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2048 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2049 pp_string (buffer
, " > ");
2052 case REDUC_PLUS_EXPR
:
2053 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2054 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2055 pp_string (buffer
, " > ");
2058 case VEC_WIDEN_MULT_HI_EXPR
:
2059 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
2060 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2061 pp_string (buffer
, ", ");
2062 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2063 pp_string (buffer
, " > ");
2066 case VEC_WIDEN_MULT_LO_EXPR
:
2067 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
2068 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2069 pp_string (buffer
, ", ");
2070 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2071 pp_string (buffer
, " > ");
2074 case VEC_UNPACK_HI_EXPR
:
2075 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2076 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2077 pp_string (buffer
, " > ");
2080 case VEC_UNPACK_LO_EXPR
:
2081 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2082 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2083 pp_string (buffer
, " > ");
2086 case VEC_UNPACK_FLOAT_HI_EXPR
:
2087 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2088 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2089 pp_string (buffer
, " > ");
2092 case VEC_UNPACK_FLOAT_LO_EXPR
:
2093 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2094 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2095 pp_string (buffer
, " > ");
2098 case VEC_PACK_TRUNC_EXPR
:
2099 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2100 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2101 pp_string (buffer
, ", ");
2102 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2103 pp_string (buffer
, " > ");
2106 case VEC_PACK_SAT_EXPR
:
2107 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2108 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2109 pp_string (buffer
, ", ");
2110 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2111 pp_string (buffer
, " > ");
2114 case VEC_PACK_FIX_TRUNC_EXPR
:
2115 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2116 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2117 pp_string (buffer
, ", ");
2118 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2119 pp_string (buffer
, " > ");
2123 dump_block_node (buffer
, node
, spc
, flags
);
2126 case VEC_EXTRACT_EVEN_EXPR
:
2127 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2128 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2129 pp_string (buffer
, ", ");
2130 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2131 pp_string (buffer
, " > ");
2134 case VEC_EXTRACT_ODD_EXPR
:
2135 pp_string (buffer
, " VEC_EXTRACT_ODD_EXPR < ");
2136 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2137 pp_string (buffer
, ", ");
2138 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2139 pp_string (buffer
, " > ");
2142 case VEC_INTERLEAVE_HIGH_EXPR
:
2143 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_EXPR < ");
2144 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2145 pp_string (buffer
, ", ");
2146 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2147 pp_string (buffer
, " > ");
2150 case VEC_INTERLEAVE_LOW_EXPR
:
2151 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2152 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2153 pp_string (buffer
, ", ");
2154 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2155 pp_string (buffer
, " > ");
2162 if (is_stmt
&& is_expr
)
2163 pp_semicolon (buffer
);
2165 /* If we're building a diagnostic, the formatted text will be written
2166 into BUFFER's stream by the caller; otherwise, write it now. */
2167 if (!(flags
& TDF_DIAGNOSTIC
))
2168 pp_write_text_to_stream (buffer
);
2173 /* Print the declaration of a variable. */
2176 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2180 if (TREE_CODE (t
) == TYPE_DECL
)
2181 pp_string (buffer
, "typedef ");
2183 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2184 pp_string (buffer
, "register ");
2186 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2187 pp_string (buffer
, "extern ");
2188 else if (TREE_STATIC (t
))
2189 pp_string (buffer
, "static ");
2191 /* Print the type and name. */
2192 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2196 /* Print array's type. */
2197 tmp
= TREE_TYPE (t
);
2198 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2199 tmp
= TREE_TYPE (tmp
);
2200 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2202 /* Print variable's name. */
2204 dump_generic_node (buffer
, t
, spc
, flags
, false);
2206 /* Print the dimensions. */
2207 tmp
= TREE_TYPE (t
);
2208 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2210 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2211 tmp
= TREE_TYPE (tmp
);
2214 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2216 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2218 dump_decl_name (buffer
, t
, flags
);
2219 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2223 /* Print type declaration. */
2224 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2226 /* Print variable's name. */
2228 dump_generic_node (buffer
, t
, spc
, flags
, false);
2231 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2233 pp_string (buffer
, " __asm__ ");
2234 pp_character (buffer
, '(');
2235 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2236 pp_character (buffer
, ')');
2239 /* The initial value of a function serves to determine whether the function
2240 is declared or defined. So the following does not apply to function
2242 if (TREE_CODE (t
) != FUNCTION_DECL
)
2244 /* Print the initial value. */
2245 if (DECL_INITIAL (t
))
2248 pp_character (buffer
, '=');
2250 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2254 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2256 pp_string (buffer
, " [value-expr: ");
2257 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2258 pp_character (buffer
, ']');
2261 pp_character (buffer
, ';');
2265 /* Prints a structure: name, fields, and methods.
2266 FIXME: Still incomplete. */
2269 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2271 /* Print the name of the structure. */
2272 if (TYPE_NAME (node
))
2275 if (TREE_CODE (node
) == RECORD_TYPE
)
2276 pp_string (buffer
, "struct ");
2277 else if ((TREE_CODE (node
) == UNION_TYPE
2278 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2279 pp_string (buffer
, "union ");
2281 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2284 /* Print the contents of the structure. */
2285 pp_newline (buffer
);
2287 pp_character (buffer
, '{');
2288 pp_newline (buffer
);
2290 /* Print the fields of the structure. */
2293 tmp
= TYPE_FIELDS (node
);
2296 /* Avoid to print recursively the structure. */
2297 /* FIXME : Not implemented correctly...,
2298 what about the case when we have a cycle in the contain graph? ...
2299 Maybe this could be solved by looking at the scope in which the
2300 structure was declared. */
2301 if (TREE_TYPE (tmp
) != node
2302 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2303 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2305 print_declaration (buffer
, tmp
, spc
+2, flags
);
2306 pp_newline (buffer
);
2308 tmp
= TREE_CHAIN (tmp
);
2312 pp_character (buffer
, '}');
2315 /* Return the priority of the operator CODE.
2317 From lowest to highest precedence with either left-to-right (L-R)
2318 or right-to-left (R-L) associativity]:
2321 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2333 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2334 15 [L-R] fn() [] -> .
2336 unary +, - and * have higher precedence than the corresponding binary
2340 op_code_prio (enum tree_code code
)
2357 case TRUTH_ORIF_EXPR
:
2360 case TRUTH_AND_EXPR
:
2361 case TRUTH_ANDIF_EXPR
:
2368 case TRUTH_XOR_EXPR
:
2385 case UNORDERED_EXPR
:
2398 case WIDEN_SUM_EXPR
:
2400 case POINTER_PLUS_EXPR
:
2404 case VEC_WIDEN_MULT_HI_EXPR
:
2405 case VEC_WIDEN_MULT_LO_EXPR
:
2406 case WIDEN_MULT_EXPR
:
2409 case TRUNC_DIV_EXPR
:
2411 case FLOOR_DIV_EXPR
:
2412 case ROUND_DIV_EXPR
:
2414 case EXACT_DIV_EXPR
:
2415 case TRUNC_MOD_EXPR
:
2417 case FLOOR_MOD_EXPR
:
2418 case ROUND_MOD_EXPR
:
2421 case TRUTH_NOT_EXPR
:
2423 case POSTINCREMENT_EXPR
:
2424 case POSTDECREMENT_EXPR
:
2425 case PREINCREMENT_EXPR
:
2426 case PREDECREMENT_EXPR
:
2428 case ALIGN_INDIRECT_REF
:
2429 case MISALIGNED_INDIRECT_REF
:
2434 case FIX_TRUNC_EXPR
:
2440 case ARRAY_RANGE_REF
:
2444 /* Special expressions. */
2450 case REDUC_MAX_EXPR
:
2451 case REDUC_MIN_EXPR
:
2452 case REDUC_PLUS_EXPR
:
2453 case VEC_LSHIFT_EXPR
:
2454 case VEC_RSHIFT_EXPR
:
2455 case VEC_UNPACK_HI_EXPR
:
2456 case VEC_UNPACK_LO_EXPR
:
2457 case VEC_UNPACK_FLOAT_HI_EXPR
:
2458 case VEC_UNPACK_FLOAT_LO_EXPR
:
2459 case VEC_PACK_TRUNC_EXPR
:
2460 case VEC_PACK_SAT_EXPR
:
2464 /* Return an arbitrarily high precedence to avoid surrounding single
2465 VAR_DECLs in ()s. */
2470 /* Return the priority of the operator OP. */
2473 op_prio (const_tree op
)
2475 enum tree_code code
;
2480 code
= TREE_CODE (op
);
2481 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2482 return op_prio (TREE_OPERAND (op
, 0));
2484 return op_code_prio (code
);
2487 /* Return the symbol associated with operator CODE. */
2490 op_symbol_code (enum tree_code code
)
2498 case TRUTH_ORIF_EXPR
:
2501 case TRUTH_AND_EXPR
:
2502 case TRUTH_ANDIF_EXPR
:
2508 case TRUTH_XOR_EXPR
:
2518 case UNORDERED_EXPR
:
2564 case VEC_LSHIFT_EXPR
:
2567 case VEC_RSHIFT_EXPR
:
2570 case POINTER_PLUS_EXPR
:
2576 case REDUC_PLUS_EXPR
:
2579 case WIDEN_SUM_EXPR
:
2582 case WIDEN_MULT_EXPR
:
2592 case TRUTH_NOT_EXPR
:
2599 case ALIGN_INDIRECT_REF
:
2602 case MISALIGNED_INDIRECT_REF
:
2605 case TRUNC_DIV_EXPR
:
2612 case FLOOR_DIV_EXPR
:
2615 case ROUND_DIV_EXPR
:
2618 case EXACT_DIV_EXPR
:
2621 case TRUNC_MOD_EXPR
:
2627 case FLOOR_MOD_EXPR
:
2630 case ROUND_MOD_EXPR
:
2633 case PREDECREMENT_EXPR
:
2636 case PREINCREMENT_EXPR
:
2639 case POSTDECREMENT_EXPR
:
2642 case POSTINCREMENT_EXPR
:
2652 return "<<< ??? >>>";
2656 /* Return the symbol associated with operator OP. */
2659 op_symbol (const_tree op
)
2661 return op_symbol_code (TREE_CODE (op
));
2664 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2665 the gimple_call_fn of a GIMPLE_CALL. */
2668 print_call_name (pretty_printer
*buffer
, tree node
)
2672 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2673 op0
= TREE_OPERAND (op0
, 0);
2676 switch (TREE_CODE (op0
))
2681 dump_function_name (buffer
, op0
);
2687 op0
= TREE_OPERAND (op0
, 0);
2691 pp_string (buffer
, "(");
2692 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2693 pp_string (buffer
, ") ? ");
2694 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, 0, false);
2695 pp_string (buffer
, " : ");
2696 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, 0, false);
2700 /* The function is a pointer contained in a structure. */
2701 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == INDIRECT_REF
||
2702 TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2703 dump_function_name (buffer
, TREE_OPERAND (op0
, 1));
2705 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2707 We can have several levels of structures and a function
2708 pointer inside. This is not implemented yet... */
2713 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2714 dump_function_name (buffer
, TREE_OPERAND (op0
, 0));
2716 dump_generic_node (buffer
, op0
, 0, 0, false);
2721 dump_generic_node (buffer
, op0
, 0, 0, false);
2729 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2732 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2742 pp_string (buffer
, "\\b");
2746 pp_string (buffer
, "\\f");
2750 pp_string (buffer
, "\\n");
2754 pp_string (buffer
, "\\r");
2758 pp_string (buffer
, "\\t");
2762 pp_string (buffer
, "\\v");
2766 pp_string (buffer
, "\\\\");
2770 pp_string (buffer
, "\\\"");
2774 pp_string (buffer
, "\\'");
2777 /* No need to handle \0; the loop terminates on \0. */
2780 pp_string (buffer
, "\\1");
2784 pp_string (buffer
, "\\2");
2788 pp_string (buffer
, "\\3");
2792 pp_string (buffer
, "\\4");
2796 pp_string (buffer
, "\\5");
2800 pp_string (buffer
, "\\6");
2804 pp_string (buffer
, "\\7");
2808 pp_character (buffer
, str
[0]);
2816 maybe_init_pretty_print (FILE *file
)
2820 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
2821 pp_needs_newline (&buffer
) = true;
2822 pp_translate_identifiers (&buffer
) = false;
2826 buffer
.buffer
->stream
= file
;
2830 newline_and_indent (pretty_printer
*buffer
, int spc
)
2832 pp_newline (buffer
);