1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
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 "tree-pretty-print.h"
30 #include "tree-flow.h"
31 #include "langhooks.h"
32 #include "tree-iterator.h"
33 #include "tree-chrec.h"
34 #include "tree-pass.h"
35 #include "value-prof.h"
38 /* Local functions, macros and variables. */
39 static const char *op_symbol (const_tree
);
40 static void pretty_print_string (pretty_printer
*, const char*);
41 static void newline_and_indent (pretty_printer
*, int);
42 static void maybe_init_pretty_print (FILE *);
43 static void print_struct_decl (pretty_printer
*, const_tree
, int, int);
44 static void do_niy (pretty_printer
*, const_tree
);
46 #define INDENT(SPACE) do { \
47 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
49 #define NIY do_niy(buffer,node)
51 static pretty_printer buffer
;
52 static int initialized
= 0;
54 /* Try to print something for an unknown tree code. */
57 do_niy (pretty_printer
*buffer
, const_tree node
)
61 pp_string (buffer
, "<<< Unknown tree: ");
62 pp_string (buffer
, tree_code_name
[(int) TREE_CODE (node
)]);
66 len
= TREE_OPERAND_LENGTH (node
);
67 for (i
= 0; i
< len
; ++i
)
69 newline_and_indent (buffer
, 2);
70 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0, false);
74 pp_string (buffer
, " >>>\n");
77 /* Debugging function to print out a generic expression. */
80 debug_generic_expr (tree t
)
82 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
83 fprintf (stderr
, "\n");
86 /* Debugging function to print out a generic statement. */
89 debug_generic_stmt (tree t
)
91 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
92 fprintf (stderr
, "\n");
95 /* Debugging function to print out a chain of trees . */
98 debug_tree_chain (tree t
)
100 struct pointer_set_t
*seen
= pointer_set_create ();
104 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
105 fprintf (stderr
, " ");
107 if (pointer_set_insert (seen
, t
))
109 fprintf (stderr
, "... [cycled back to ");
110 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
111 fprintf (stderr
, "]");
115 fprintf (stderr
, "\n");
117 pointer_set_destroy (seen
);
120 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
122 print_generic_decl (FILE *file
, tree decl
, int flags
)
124 maybe_init_pretty_print (file
);
125 print_declaration (&buffer
, decl
, 2, flags
);
126 pp_write_text_to_stream (&buffer
);
129 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
130 to show in the dump. See TDF_* in tree-pass.h. */
133 print_generic_stmt (FILE *file
, tree t
, int flags
)
135 maybe_init_pretty_print (file
);
136 dump_generic_node (&buffer
, t
, 0, flags
, true);
140 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
141 to show in the dump. See TDF_* in tree-pass.h. The output is indented by
145 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
149 maybe_init_pretty_print (file
);
151 for (i
= 0; i
< indent
; i
++)
153 dump_generic_node (&buffer
, t
, indent
, flags
, true);
157 /* Print a single expression T on file FILE. FLAGS specifies details to show
158 in the dump. See TDF_* in tree-pass.h. */
161 print_generic_expr (FILE *file
, tree t
, int flags
)
163 maybe_init_pretty_print (file
);
164 dump_generic_node (&buffer
, t
, 0, flags
, false);
167 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
171 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
173 if (DECL_NAME (node
))
175 if ((flags
& TDF_ASMNAME
) && DECL_ASSEMBLER_NAME_SET_P (node
))
176 pp_tree_identifier (buffer
, DECL_ASSEMBLER_NAME (node
));
178 pp_tree_identifier (buffer
, DECL_NAME (node
));
180 if ((flags
& TDF_UID
) || DECL_NAME (node
) == NULL_TREE
)
182 if (TREE_CODE (node
) == LABEL_DECL
&& LABEL_DECL_UID (node
) != -1)
183 pp_printf (buffer
, "L.%d", (int) LABEL_DECL_UID (node
));
184 else if (TREE_CODE (node
) == DEBUG_EXPR_DECL
)
186 if (flags
& TDF_NOUID
)
187 pp_string (buffer
, "D#xxxx");
189 pp_printf (buffer
, "D#%i", DEBUG_TEMP_UID (node
));
193 char c
= TREE_CODE (node
) == CONST_DECL
? 'C' : 'D';
194 if (flags
& TDF_NOUID
)
195 pp_printf (buffer
, "%c.xxxx", c
);
197 pp_printf (buffer
, "%c.%u", c
, DECL_UID (node
));
200 if ((flags
& TDF_ALIAS
) && DECL_PT_UID (node
) != DECL_UID (node
))
202 if (flags
& TDF_NOUID
)
203 pp_printf (buffer
, "ptD.xxxx");
205 pp_printf (buffer
, "ptD.%u", DECL_PT_UID (node
));
209 /* Like the above, but used for pretty printing function calls. */
212 dump_function_name (pretty_printer
*buffer
, tree node
, int flags
)
214 if (TREE_CODE (node
) == NOP_EXPR
)
215 node
= TREE_OPERAND (node
, 0);
216 if (DECL_NAME (node
) && (flags
& TDF_ASMNAME
) == 0)
217 pp_string (buffer
, lang_hooks
.decl_printable_name (node
, 1));
219 dump_decl_name (buffer
, node
, flags
);
222 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
223 FLAGS are as in dump_generic_node. */
226 dump_function_declaration (pretty_printer
*buffer
, tree node
,
229 bool wrote_arg
= false;
233 pp_character (buffer
, '(');
235 /* Print the argument types. The last element in the list is a VOID_TYPE.
236 The following avoids printing the last element. */
237 arg
= TYPE_ARG_TYPES (node
);
238 while (arg
&& TREE_CHAIN (arg
) && arg
!= error_mark_node
)
241 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
242 arg
= TREE_CHAIN (arg
);
243 if (TREE_CHAIN (arg
) && TREE_CODE (TREE_CHAIN (arg
)) == TREE_LIST
)
245 pp_character (buffer
, ',');
251 pp_string (buffer
, "void");
253 pp_character (buffer
, ')');
256 /* Dump the domain associated with an array. */
259 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
261 pp_character (buffer
, '[');
264 tree min
= TYPE_MIN_VALUE (domain
);
265 tree max
= TYPE_MAX_VALUE (domain
);
268 && integer_zerop (min
)
269 && host_integerp (max
, 0))
270 pp_wide_integer (buffer
, TREE_INT_CST_LOW (max
) + 1);
274 dump_generic_node (buffer
, min
, spc
, flags
, false);
275 pp_character (buffer
, ':');
277 dump_generic_node (buffer
, max
, spc
, flags
, false);
281 pp_string (buffer
, "<unknown>");
282 pp_character (buffer
, ']');
286 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
287 dump_generic_node. */
290 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
294 switch (OMP_CLAUSE_CODE (clause
))
296 case OMP_CLAUSE_PRIVATE
:
299 case OMP_CLAUSE_SHARED
:
302 case OMP_CLAUSE_FIRSTPRIVATE
:
303 name
= "firstprivate";
305 case OMP_CLAUSE_LASTPRIVATE
:
306 name
= "lastprivate";
308 case OMP_CLAUSE_COPYIN
:
311 case OMP_CLAUSE_COPYPRIVATE
:
312 name
= "copyprivate";
315 pp_string (buffer
, name
);
316 pp_character (buffer
, '(');
317 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
319 pp_character (buffer
, ')');
322 case OMP_CLAUSE_REDUCTION
:
323 pp_string (buffer
, "reduction(");
324 pp_string (buffer
, op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
325 pp_character (buffer
, ':');
326 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
328 pp_character (buffer
, ')');
332 pp_string (buffer
, "if(");
333 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
335 pp_character (buffer
, ')');
338 case OMP_CLAUSE_NUM_THREADS
:
339 pp_string (buffer
, "num_threads(");
340 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
342 pp_character (buffer
, ')');
345 case OMP_CLAUSE_NOWAIT
:
346 pp_string (buffer
, "nowait");
348 case OMP_CLAUSE_ORDERED
:
349 pp_string (buffer
, "ordered");
352 case OMP_CLAUSE_DEFAULT
:
353 pp_string (buffer
, "default(");
354 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
356 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
358 case OMP_CLAUSE_DEFAULT_SHARED
:
359 pp_string (buffer
, "shared");
361 case OMP_CLAUSE_DEFAULT_NONE
:
362 pp_string (buffer
, "none");
364 case OMP_CLAUSE_DEFAULT_PRIVATE
:
365 pp_string (buffer
, "private");
367 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE
:
368 pp_string (buffer
, "firstprivate");
373 pp_character (buffer
, ')');
376 case OMP_CLAUSE_SCHEDULE
:
377 pp_string (buffer
, "schedule(");
378 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
380 case OMP_CLAUSE_SCHEDULE_STATIC
:
381 pp_string (buffer
, "static");
383 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
384 pp_string (buffer
, "dynamic");
386 case OMP_CLAUSE_SCHEDULE_GUIDED
:
387 pp_string (buffer
, "guided");
389 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
390 pp_string (buffer
, "runtime");
392 case OMP_CLAUSE_SCHEDULE_AUTO
:
393 pp_string (buffer
, "auto");
398 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
400 pp_character (buffer
, ',');
401 dump_generic_node (buffer
,
402 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
405 pp_character (buffer
, ')');
408 case OMP_CLAUSE_UNTIED
:
409 pp_string (buffer
, "untied");
412 case OMP_CLAUSE_COLLAPSE
:
413 pp_string (buffer
, "collapse(");
414 dump_generic_node (buffer
,
415 OMP_CLAUSE_COLLAPSE_EXPR (clause
),
417 pp_character (buffer
, ')');
421 /* Should never happen. */
422 dump_generic_node (buffer
, clause
, spc
, flags
, false);
428 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
429 dump_generic_node. */
432 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
440 dump_omp_clause (buffer
, clause
, spc
, flags
);
441 clause
= OMP_CLAUSE_CHAIN (clause
);
449 /* Dump location LOC to BUFFER. */
452 dump_location (pretty_printer
*buffer
, location_t loc
)
454 expanded_location xloc
= expand_location (loc
);
456 pp_character (buffer
, '[');
459 pp_string (buffer
, xloc
.file
);
460 pp_string (buffer
, " : ");
462 pp_decimal_int (buffer
, xloc
.line
);
463 pp_string (buffer
, "] ");
467 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
468 dump_generic_node. */
471 dump_block_node (pretty_printer
*buffer
, tree block
, int spc
, int flags
)
475 pp_printf (buffer
, "BLOCK #%d ", BLOCK_NUMBER (block
));
477 if (flags
& TDF_ADDRESS
)
478 pp_printf (buffer
, "[%p] ", (void *) block
);
480 if (BLOCK_ABSTRACT (block
))
481 pp_string (buffer
, "[abstract] ");
483 if (TREE_ASM_WRITTEN (block
))
484 pp_string (buffer
, "[written] ");
486 if (flags
& TDF_SLIM
)
489 if (BLOCK_SOURCE_LOCATION (block
))
490 dump_location (buffer
, BLOCK_SOURCE_LOCATION (block
));
492 newline_and_indent (buffer
, spc
+ 2);
494 if (BLOCK_SUPERCONTEXT (block
))
496 pp_string (buffer
, "SUPERCONTEXT: ");
497 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (block
), 0,
498 flags
| TDF_SLIM
, false);
499 newline_and_indent (buffer
, spc
+ 2);
502 if (BLOCK_SUBBLOCKS (block
))
504 pp_string (buffer
, "SUBBLOCKS: ");
505 for (t
= BLOCK_SUBBLOCKS (block
); t
; t
= BLOCK_CHAIN (t
))
507 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
508 pp_string (buffer
, " ");
510 newline_and_indent (buffer
, spc
+ 2);
513 if (BLOCK_CHAIN (block
))
515 pp_string (buffer
, "SIBLINGS: ");
516 for (t
= BLOCK_CHAIN (block
); t
; t
= BLOCK_CHAIN (t
))
518 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
519 pp_string (buffer
, " ");
521 newline_and_indent (buffer
, spc
+ 2);
524 if (BLOCK_VARS (block
))
526 pp_string (buffer
, "VARS: ");
527 for (t
= BLOCK_VARS (block
); t
; t
= TREE_CHAIN (t
))
529 dump_generic_node (buffer
, t
, 0, flags
, false);
530 pp_string (buffer
, " ");
532 newline_and_indent (buffer
, spc
+ 2);
535 if (VEC_length (tree
, BLOCK_NONLOCALIZED_VARS (block
)) > 0)
538 VEC(tree
,gc
) *nlv
= BLOCK_NONLOCALIZED_VARS (block
);
540 pp_string (buffer
, "NONLOCALIZED_VARS: ");
541 for (i
= 0; VEC_iterate (tree
, nlv
, i
, t
); i
++)
543 dump_generic_node (buffer
, t
, 0, flags
, false);
544 pp_string (buffer
, " ");
546 newline_and_indent (buffer
, spc
+ 2);
549 if (BLOCK_ABSTRACT_ORIGIN (block
))
551 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
552 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (block
), 0,
553 flags
| TDF_SLIM
, false);
554 newline_and_indent (buffer
, spc
+ 2);
557 if (BLOCK_FRAGMENT_ORIGIN (block
))
559 pp_string (buffer
, "FRAGMENT_ORIGIN: ");
560 dump_generic_node (buffer
, BLOCK_FRAGMENT_ORIGIN (block
), 0,
561 flags
| TDF_SLIM
, false);
562 newline_and_indent (buffer
, spc
+ 2);
565 if (BLOCK_FRAGMENT_CHAIN (block
))
567 pp_string (buffer
, "FRAGMENT_CHAIN: ");
568 for (t
= BLOCK_FRAGMENT_CHAIN (block
); t
; t
= BLOCK_FRAGMENT_CHAIN (t
))
570 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
571 pp_string (buffer
, " ");
573 newline_and_indent (buffer
, spc
+ 2);
578 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
579 indent. FLAGS specifies details to show in the dump (see TDF_* in
580 tree-pass.h). If IS_STMT is true, the object printed is considered
581 to be a statement and it is terminated by ';' if appropriate. */
584 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
592 if (node
== NULL_TREE
)
595 is_expr
= EXPR_P (node
);
597 if (is_stmt
&& (flags
& TDF_STMTADDR
))
598 pp_printf (buffer
, "<&%p> ", (void *)node
);
600 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
601 dump_location (buffer
, EXPR_LOCATION (node
));
603 switch (TREE_CODE (node
))
606 pp_string (buffer
, "<<< error >>>");
609 case IDENTIFIER_NODE
:
610 pp_tree_identifier (buffer
, node
);
614 while (node
&& node
!= error_mark_node
)
616 if (TREE_PURPOSE (node
))
618 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
621 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
622 node
= TREE_CHAIN (node
);
623 if (node
&& TREE_CODE (node
) == TREE_LIST
)
625 pp_character (buffer
, ',');
632 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
638 if (TREE_VEC_LENGTH (node
) > 0)
640 size_t len
= TREE_VEC_LENGTH (node
);
641 for (i
= 0; i
< len
- 1; i
++)
643 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
645 pp_character (buffer
, ',');
648 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
657 case FIXED_POINT_TYPE
:
663 unsigned int quals
= TYPE_QUALS (node
);
664 enum tree_code_class tclass
;
666 if (quals
& TYPE_QUAL_CONST
)
667 pp_string (buffer
, "const ");
668 else if (quals
& TYPE_QUAL_VOLATILE
)
669 pp_string (buffer
, "volatile ");
670 else if (quals
& TYPE_QUAL_RESTRICT
)
671 pp_string (buffer
, "restrict ");
673 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
675 pp_string (buffer
, "<address-space-");
676 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
677 pp_string (buffer
, "> ");
680 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
682 if (tclass
== tcc_declaration
)
684 if (DECL_NAME (node
))
685 dump_decl_name (buffer
, node
, flags
);
687 pp_string (buffer
, "<unnamed type decl>");
689 else if (tclass
== tcc_type
)
691 if (TYPE_NAME (node
))
693 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
694 pp_tree_identifier (buffer
, TYPE_NAME (node
));
695 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
696 && DECL_NAME (TYPE_NAME (node
)))
697 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
699 pp_string (buffer
, "<unnamed type>");
701 else if (TREE_CODE (node
) == VECTOR_TYPE
)
703 pp_string (buffer
, "vector");
704 pp_character (buffer
, '(');
705 pp_wide_integer (buffer
, TYPE_VECTOR_SUBPARTS (node
));
706 pp_string (buffer
, ") ");
707 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
709 else if (TREE_CODE (node
) == INTEGER_TYPE
)
711 pp_string (buffer
, (TYPE_UNSIGNED (node
)
712 ? "<unnamed-unsigned:"
713 : "<unnamed-signed:"));
714 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
715 pp_string (buffer
, ">");
717 else if (TREE_CODE (node
) == COMPLEX_TYPE
)
719 pp_string (buffer
, "__complex__ ");
720 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
722 else if (TREE_CODE (node
) == REAL_TYPE
)
724 pp_string (buffer
, "<float:");
725 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
726 pp_string (buffer
, ">");
728 else if (TREE_CODE (node
) == FIXED_POINT_TYPE
)
730 pp_string (buffer
, "<fixed-point-");
731 pp_string (buffer
, TYPE_SATURATING (node
) ? "sat:" : "nonsat:");
732 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
733 pp_string (buffer
, ">");
736 pp_string (buffer
, "<unnamed type>");
743 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
745 if (TREE_TYPE (node
) == NULL
)
747 pp_string (buffer
, str
);
748 pp_string (buffer
, "<null type>");
750 else if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
752 tree fnode
= TREE_TYPE (node
);
754 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
756 pp_character (buffer
, '(');
757 pp_string (buffer
, str
);
758 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
759 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
761 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
763 pp_character (buffer
, ')');
764 dump_function_declaration (buffer
, fnode
, spc
, flags
);
768 unsigned int quals
= TYPE_QUALS (node
);
770 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
772 pp_string (buffer
, str
);
774 if (quals
& TYPE_QUAL_CONST
)
775 pp_string (buffer
, " const");
776 if (quals
& TYPE_QUAL_VOLATILE
)
777 pp_string (buffer
, " volatile");
778 if (quals
& TYPE_QUAL_RESTRICT
)
779 pp_string (buffer
, " restrict");
781 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
783 pp_string (buffer
, " <address-space-");
784 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
785 pp_string (buffer
, ">");
788 if (TYPE_REF_CAN_ALIAS_ALL (node
))
789 pp_string (buffer
, " {ref-all}");
799 const char *sep
= "";
802 pp_string (buffer
, "MEM[");
804 tmp
= TMR_SYMBOL (node
);
807 pp_string (buffer
, sep
);
809 pp_string (buffer
, "symbol: ");
810 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
812 tmp
= TMR_BASE (node
);
815 pp_string (buffer
, sep
);
817 pp_string (buffer
, "base: ");
818 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
820 tmp
= TMR_INDEX (node
);
823 pp_string (buffer
, sep
);
825 pp_string (buffer
, "index: ");
826 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
828 tmp
= TMR_STEP (node
);
831 pp_string (buffer
, sep
);
833 pp_string (buffer
, "step: ");
834 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
836 tmp
= TMR_OFFSET (node
);
839 pp_string (buffer
, sep
);
841 pp_string (buffer
, "offset: ");
842 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
844 pp_string (buffer
, "]");
845 if (flags
& TDF_DETAILS
)
847 pp_string (buffer
, "{");
848 dump_generic_node (buffer
, TMR_ORIGINAL (node
), spc
, flags
,
850 pp_string (buffer
, "}");
859 /* Print the innermost component type. */
860 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
861 tmp
= TREE_TYPE (tmp
))
863 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
865 /* Print the dimensions. */
866 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
867 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
873 case QUAL_UNION_TYPE
:
875 unsigned int quals
= TYPE_QUALS (node
);
877 if (quals
& TYPE_QUAL_CONST
)
878 pp_string (buffer
, "const ");
879 if (quals
& TYPE_QUAL_VOLATILE
)
880 pp_string (buffer
, "volatile ");
882 /* Print the name of the structure. */
883 if (TREE_CODE (node
) == RECORD_TYPE
)
884 pp_string (buffer
, "struct ");
885 else if (TREE_CODE (node
) == UNION_TYPE
)
886 pp_string (buffer
, "union ");
888 if (TYPE_NAME (node
))
889 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
890 else if (!(flags
& TDF_SLIM
))
891 /* FIXME: If we eliminate the 'else' above and attempt
892 to show the fields for named types, we may get stuck
893 following a cycle of pointers to structs. The alleged
894 self-reference check in print_struct_decl will not detect
895 cycles involving more than one pointer or struct type. */
896 print_struct_decl (buffer
, node
, spc
, flags
);
905 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
907 /* In the case of a pointer, one may want to divide by the
908 size of the pointed-to type. Unfortunately, this not
909 straightforward. The C front-end maps expressions
914 in such a way that the two INTEGER_CST nodes for "5" have
915 different values but identical types. In the latter
916 case, the 5 is multiplied by sizeof (int) in c-common.c
917 (pointer_int_sum) to convert it to a byte address, and
918 yet the type of the node is left unchanged. Argh. What
919 is consistent though is that the number value corresponds
920 to bytes (UNITS) offset.
922 NB: Neither of the following divisors can be trivially
923 used to recover the original literal:
925 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
926 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
927 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
928 pp_string (buffer
, "B"); /* pseudo-unit */
930 else if (! host_integerp (node
, 0))
933 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (val
);
934 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (val
);
936 if (tree_int_cst_sgn (val
) < 0)
938 pp_character (buffer
, '-');
942 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
944 sprintf (pp_buffer (buffer
)->digit_buffer
,
945 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
946 (unsigned HOST_WIDE_INT
) high
, low
);
947 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
950 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
954 /* Code copied from print_node. */
957 if (TREE_OVERFLOW (node
))
958 pp_string (buffer
, " overflow");
960 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
961 d
= TREE_REAL_CST (node
);
962 if (REAL_VALUE_ISINF (d
))
963 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
964 else if (REAL_VALUE_ISNAN (d
))
965 pp_string (buffer
, " Nan");
969 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
970 pp_string (buffer
, string
);
975 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
976 pp_string (buffer
, "0x");
977 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
978 output_formatted_integer (buffer
, "%02x", *p
++);
987 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
988 pp_string (buffer
, string
);
993 pp_string (buffer
, "__complex__ (");
994 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
995 pp_string (buffer
, ", ");
996 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
997 pp_string (buffer
, ")");
1001 pp_string (buffer
, "\"");
1002 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
1003 pp_string (buffer
, "\"");
1009 pp_string (buffer
, "{ ");
1010 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
1012 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
, false);
1013 if (TREE_CHAIN (elt
))
1014 pp_string (buffer
, ", ");
1016 pp_string (buffer
, " }");
1022 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1024 if (TREE_CODE (node
) == METHOD_TYPE
)
1026 if (TYPE_METHOD_BASETYPE (node
))
1027 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
1030 pp_string (buffer
, "<null method basetype>");
1031 pp_string (buffer
, "::");
1033 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1034 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1036 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1037 dump_function_declaration (buffer
, node
, spc
, flags
);
1042 dump_decl_name (buffer
, node
, flags
);
1046 if (DECL_NAME (node
))
1047 dump_decl_name (buffer
, node
, flags
);
1048 else if (LABEL_DECL_UID (node
) != -1)
1049 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1052 if (flags
& TDF_NOUID
)
1053 pp_string (buffer
, "<D.xxxx>");
1055 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1060 if (DECL_IS_BUILTIN (node
))
1062 /* Don't print the declaration of built-in types. */
1065 if (DECL_NAME (node
))
1066 dump_decl_name (buffer
, node
, flags
);
1069 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1070 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1071 && TYPE_METHODS (TREE_TYPE (node
)))
1073 /* The type is a c++ class: all structures have at least
1075 pp_string (buffer
, "class ");
1076 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1081 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1082 ? "union" : "struct "));
1083 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1091 case DEBUG_EXPR_DECL
:
1092 case NAMESPACE_DECL
:
1093 dump_decl_name (buffer
, node
, flags
);
1097 pp_string (buffer
, "<retval>");
1101 op0
= TREE_OPERAND (node
, 0);
1103 if (op0
&& TREE_CODE (op0
) == INDIRECT_REF
)
1105 op0
= TREE_OPERAND (op0
, 0);
1108 if (op_prio (op0
) < op_prio (node
))
1109 pp_character (buffer
, '(');
1110 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1111 if (op_prio (op0
) < op_prio (node
))
1112 pp_character (buffer
, ')');
1113 pp_string (buffer
, str
);
1114 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1115 op0
= component_ref_field_offset (node
);
1116 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1118 pp_string (buffer
, "{off: ");
1119 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1120 pp_character (buffer
, '}');
1125 pp_string (buffer
, "BIT_FIELD_REF <");
1126 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1127 pp_string (buffer
, ", ");
1128 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1129 pp_string (buffer
, ", ");
1130 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1131 pp_string (buffer
, ">");
1135 case ARRAY_RANGE_REF
:
1136 op0
= TREE_OPERAND (node
, 0);
1137 if (op_prio (op0
) < op_prio (node
))
1138 pp_character (buffer
, '(');
1139 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1140 if (op_prio (op0
) < op_prio (node
))
1141 pp_character (buffer
, ')');
1142 pp_character (buffer
, '[');
1143 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1144 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1145 pp_string (buffer
, " ...");
1146 pp_character (buffer
, ']');
1148 op0
= array_ref_low_bound (node
);
1149 op1
= array_ref_element_size (node
);
1151 if (!integer_zerop (op0
)
1152 || TREE_OPERAND (node
, 2)
1153 || TREE_OPERAND (node
, 3))
1155 pp_string (buffer
, "{lb: ");
1156 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1157 pp_string (buffer
, " sz: ");
1158 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1159 pp_character (buffer
, '}');
1165 unsigned HOST_WIDE_INT ix
;
1167 bool is_struct_init
= FALSE
;
1168 pp_character (buffer
, '{');
1169 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1170 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1171 is_struct_init
= TRUE
;
1172 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1174 if (field
&& is_struct_init
)
1176 pp_character (buffer
, '.');
1177 dump_generic_node (buffer
, field
, spc
, flags
, false);
1178 pp_string (buffer
, "=");
1180 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1181 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1182 val
= TREE_OPERAND (val
, 0);
1183 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1184 dump_decl_name (buffer
, val
, flags
);
1186 dump_generic_node (buffer
, val
, spc
, flags
, false);
1187 if (ix
!= VEC_length (constructor_elt
, CONSTRUCTOR_ELTS (node
)) - 1)
1189 pp_character (buffer
, ',');
1193 pp_character (buffer
, '}');
1200 if (flags
& TDF_SLIM
)
1202 pp_string (buffer
, "<COMPOUND_EXPR>");
1206 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1207 spc
, flags
, !(flags
& TDF_SLIM
));
1208 if (flags
& TDF_SLIM
)
1209 newline_and_indent (buffer
, spc
);
1212 pp_character (buffer
, ',');
1216 for (tp
= &TREE_OPERAND (node
, 1);
1217 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1218 tp
= &TREE_OPERAND (*tp
, 1))
1220 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1221 spc
, flags
, !(flags
& TDF_SLIM
));
1222 if (flags
& TDF_SLIM
)
1223 newline_and_indent (buffer
, spc
);
1226 pp_character (buffer
, ',');
1231 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1235 case STATEMENT_LIST
:
1237 tree_stmt_iterator si
;
1240 if (flags
& TDF_SLIM
)
1242 pp_string (buffer
, "<STATEMENT_LIST>");
1246 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1249 newline_and_indent (buffer
, spc
);
1252 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1259 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1262 pp_character (buffer
, '=');
1263 if (TREE_CODE (node
) == MODIFY_EXPR
1264 && MOVE_NONTEMPORAL (node
))
1265 pp_string (buffer
, "{nt}");
1267 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1272 pp_string (buffer
, "TARGET_EXPR <");
1273 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1274 pp_character (buffer
, ',');
1276 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1277 pp_character (buffer
, '>');
1281 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1286 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1288 pp_string (buffer
, "if (");
1289 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1290 pp_character (buffer
, ')');
1291 /* The lowered cond_exprs should always be printed in full. */
1292 if (COND_EXPR_THEN (node
)
1293 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1294 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1295 && COND_EXPR_ELSE (node
)
1296 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1297 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1300 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1302 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1304 pp_string (buffer
, " else ");
1305 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1309 else if (!(flags
& TDF_SLIM
))
1311 /* Output COND_EXPR_THEN. */
1312 if (COND_EXPR_THEN (node
))
1314 newline_and_indent (buffer
, spc
+2);
1315 pp_character (buffer
, '{');
1316 newline_and_indent (buffer
, spc
+4);
1317 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1319 newline_and_indent (buffer
, spc
+2);
1320 pp_character (buffer
, '}');
1323 /* Output COND_EXPR_ELSE. */
1324 if (COND_EXPR_ELSE (node
)
1325 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1327 newline_and_indent (buffer
, spc
);
1328 pp_string (buffer
, "else");
1329 newline_and_indent (buffer
, spc
+2);
1330 pp_character (buffer
, '{');
1331 newline_and_indent (buffer
, spc
+4);
1332 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1334 newline_and_indent (buffer
, spc
+2);
1335 pp_character (buffer
, '}');
1342 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1344 pp_character (buffer
, '?');
1346 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1348 pp_character (buffer
, ':');
1350 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1355 pp_character (buffer
, '{');
1356 if (!(flags
& TDF_SLIM
))
1358 if (BIND_EXPR_VARS (node
))
1360 pp_newline (buffer
);
1362 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= TREE_CHAIN (op0
))
1364 print_declaration (buffer
, op0
, spc
+2, flags
);
1365 pp_newline (buffer
);
1369 newline_and_indent (buffer
, spc
+2);
1370 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1371 newline_and_indent (buffer
, spc
);
1372 pp_character (buffer
, '}');
1378 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1380 /* Print parameters. */
1382 pp_character (buffer
, '(');
1385 call_expr_arg_iterator iter
;
1386 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1388 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1389 if (more_call_expr_args_p (&iter
))
1391 pp_character (buffer
, ',');
1396 if (CALL_EXPR_VA_ARG_PACK (node
))
1398 if (call_expr_nargs (node
) > 0)
1400 pp_character (buffer
, ',');
1403 pp_string (buffer
, "__builtin_va_arg_pack ()");
1405 pp_character (buffer
, ')');
1407 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1410 pp_string (buffer
, " [static-chain: ");
1411 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1412 pp_character (buffer
, ']');
1415 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1416 pp_string (buffer
, " [return slot optimization]");
1417 if (CALL_EXPR_TAILCALL (node
))
1418 pp_string (buffer
, " [tail call]");
1421 case WITH_CLEANUP_EXPR
:
1425 case CLEANUP_POINT_EXPR
:
1426 pp_string (buffer
, "<<cleanup_point ");
1427 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1428 pp_string (buffer
, ">>");
1431 case PLACEHOLDER_EXPR
:
1432 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1433 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1434 pp_character (buffer
, '>');
1437 /* Binary arithmetic and logic expressions. */
1438 case WIDEN_SUM_EXPR
:
1439 case WIDEN_MULT_EXPR
:
1442 case POINTER_PLUS_EXPR
:
1444 case TRUNC_DIV_EXPR
:
1446 case FLOOR_DIV_EXPR
:
1447 case ROUND_DIV_EXPR
:
1448 case TRUNC_MOD_EXPR
:
1450 case FLOOR_MOD_EXPR
:
1451 case ROUND_MOD_EXPR
:
1453 case EXACT_DIV_EXPR
:
1458 case VEC_LSHIFT_EXPR
:
1459 case VEC_RSHIFT_EXPR
:
1463 case TRUTH_ANDIF_EXPR
:
1464 case TRUTH_ORIF_EXPR
:
1465 case TRUTH_AND_EXPR
:
1467 case TRUTH_XOR_EXPR
:
1481 case UNORDERED_EXPR
:
1483 const char *op
= op_symbol (node
);
1484 op0
= TREE_OPERAND (node
, 0);
1485 op1
= TREE_OPERAND (node
, 1);
1487 /* When the operands are expressions with less priority,
1488 keep semantics of the tree representation. */
1489 if (op_prio (op0
) <= op_prio (node
))
1491 pp_character (buffer
, '(');
1492 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1493 pp_character (buffer
, ')');
1496 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1499 pp_string (buffer
, op
);
1502 /* When the operands are expressions with less priority,
1503 keep semantics of the tree representation. */
1504 if (op_prio (op1
) <= op_prio (node
))
1506 pp_character (buffer
, '(');
1507 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1508 pp_character (buffer
, ')');
1511 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1515 /* Unary arithmetic and logic expressions. */
1518 case TRUTH_NOT_EXPR
:
1520 case PREDECREMENT_EXPR
:
1521 case PREINCREMENT_EXPR
:
1522 case ALIGN_INDIRECT_REF
:
1523 case MISALIGNED_INDIRECT_REF
:
1525 if (TREE_CODE (node
) == ADDR_EXPR
1526 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1527 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1528 ; /* Do not output '&' for strings and function pointers. */
1530 pp_string (buffer
, op_symbol (node
));
1532 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1534 pp_character (buffer
, '(');
1535 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1536 pp_character (buffer
, ')');
1539 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1541 if (TREE_CODE (node
) == MISALIGNED_INDIRECT_REF
)
1543 pp_string (buffer
, "{misalignment: ");
1544 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1545 pp_character (buffer
, '}');
1549 case POSTDECREMENT_EXPR
:
1550 case POSTINCREMENT_EXPR
:
1551 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1553 pp_character (buffer
, '(');
1554 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1555 pp_character (buffer
, ')');
1558 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1559 pp_string (buffer
, op_symbol (node
));
1563 pp_string (buffer
, "MIN_EXPR <");
1564 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1565 pp_string (buffer
, ", ");
1566 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1567 pp_character (buffer
, '>');
1571 pp_string (buffer
, "MAX_EXPR <");
1572 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1573 pp_string (buffer
, ", ");
1574 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1575 pp_character (buffer
, '>');
1579 pp_string (buffer
, "ABS_EXPR <");
1580 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1581 pp_character (buffer
, '>');
1588 case ADDR_SPACE_CONVERT_EXPR
:
1589 case FIXED_CONVERT_EXPR
:
1590 case FIX_TRUNC_EXPR
:
1593 type
= TREE_TYPE (node
);
1594 op0
= TREE_OPERAND (node
, 0);
1595 if (type
!= TREE_TYPE (op0
))
1597 pp_character (buffer
, '(');
1598 dump_generic_node (buffer
, type
, spc
, flags
, false);
1599 pp_string (buffer
, ") ");
1601 if (op_prio (op0
) < op_prio (node
))
1602 pp_character (buffer
, '(');
1603 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1604 if (op_prio (op0
) < op_prio (node
))
1605 pp_character (buffer
, ')');
1608 case VIEW_CONVERT_EXPR
:
1609 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1610 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1611 pp_string (buffer
, ">(");
1612 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1613 pp_character (buffer
, ')');
1617 pp_string (buffer
, "((");
1618 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1619 pp_string (buffer
, "))");
1622 case NON_LVALUE_EXPR
:
1623 pp_string (buffer
, "NON_LVALUE_EXPR <");
1624 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1625 pp_character (buffer
, '>');
1629 pp_string (buffer
, "SAVE_EXPR <");
1630 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1631 pp_character (buffer
, '>');
1635 pp_string (buffer
, "COMPLEX_EXPR <");
1636 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1637 pp_string (buffer
, ", ");
1638 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1639 pp_string (buffer
, ">");
1643 pp_string (buffer
, "CONJ_EXPR <");
1644 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1645 pp_string (buffer
, ">");
1649 pp_string (buffer
, "REALPART_EXPR <");
1650 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1651 pp_string (buffer
, ">");
1655 pp_string (buffer
, "IMAGPART_EXPR <");
1656 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1657 pp_string (buffer
, ">");
1661 pp_string (buffer
, "VA_ARG_EXPR <");
1662 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1663 pp_string (buffer
, ">");
1666 case TRY_FINALLY_EXPR
:
1667 case TRY_CATCH_EXPR
:
1668 pp_string (buffer
, "try");
1669 newline_and_indent (buffer
, spc
+2);
1670 pp_string (buffer
, "{");
1671 newline_and_indent (buffer
, spc
+4);
1672 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1673 newline_and_indent (buffer
, spc
+2);
1674 pp_string (buffer
, "}");
1675 newline_and_indent (buffer
, spc
);
1677 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1678 newline_and_indent (buffer
, spc
+2);
1679 pp_string (buffer
, "{");
1680 newline_and_indent (buffer
, spc
+4);
1681 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1682 newline_and_indent (buffer
, spc
+2);
1683 pp_string (buffer
, "}");
1688 pp_string (buffer
, "catch (");
1689 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1690 pp_string (buffer
, ")");
1691 newline_and_indent (buffer
, spc
+2);
1692 pp_string (buffer
, "{");
1693 newline_and_indent (buffer
, spc
+4);
1694 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1695 newline_and_indent (buffer
, spc
+2);
1696 pp_string (buffer
, "}");
1700 case EH_FILTER_EXPR
:
1701 pp_string (buffer
, "<<<eh_filter (");
1702 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1703 pp_string (buffer
, ")>>>");
1704 newline_and_indent (buffer
, spc
+2);
1705 pp_string (buffer
, "{");
1706 newline_and_indent (buffer
, spc
+4);
1707 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1708 newline_and_indent (buffer
, spc
+2);
1709 pp_string (buffer
, "}");
1714 op0
= TREE_OPERAND (node
, 0);
1715 /* If this is for break or continue, don't bother printing it. */
1716 if (DECL_NAME (op0
))
1718 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1719 if (strcmp (name
, "break") == 0
1720 || strcmp (name
, "continue") == 0)
1723 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1724 pp_character (buffer
, ':');
1725 if (DECL_NONLOCAL (op0
))
1726 pp_string (buffer
, " [non-local]");
1730 pp_string (buffer
, "while (1)");
1731 if (!(flags
& TDF_SLIM
))
1733 newline_and_indent (buffer
, spc
+2);
1734 pp_character (buffer
, '{');
1735 newline_and_indent (buffer
, spc
+4);
1736 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1737 newline_and_indent (buffer
, spc
+2);
1738 pp_character (buffer
, '}');
1744 pp_string (buffer
, "// predicted ");
1745 if (PREDICT_EXPR_OUTCOME (node
))
1746 pp_string (buffer
, "likely by ");
1748 pp_string (buffer
, "unlikely by ");
1749 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
1750 pp_string (buffer
, " predictor.");
1754 pp_string (buffer
, "return");
1755 op0
= TREE_OPERAND (node
, 0);
1759 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1760 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
1763 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1768 pp_string (buffer
, "if (");
1769 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1770 pp_string (buffer
, ") break");
1774 pp_string (buffer
, "switch (");
1775 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1776 pp_character (buffer
, ')');
1777 if (!(flags
& TDF_SLIM
))
1779 newline_and_indent (buffer
, spc
+2);
1780 pp_character (buffer
, '{');
1781 if (SWITCH_BODY (node
))
1783 newline_and_indent (buffer
, spc
+4);
1784 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1789 tree vec
= SWITCH_LABELS (node
);
1790 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1791 for (i
= 0; i
< n
; ++i
)
1793 tree elt
= TREE_VEC_ELT (vec
, i
);
1794 newline_and_indent (buffer
, spc
+4);
1797 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1798 pp_string (buffer
, " goto ");
1799 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1801 pp_semicolon (buffer
);
1804 pp_string (buffer
, "case ???: goto ???;");
1807 newline_and_indent (buffer
, spc
+2);
1808 pp_character (buffer
, '}');
1814 op0
= GOTO_DESTINATION (node
);
1815 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1817 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1818 if (strcmp (name
, "break") == 0
1819 || strcmp (name
, "continue") == 0)
1821 pp_string (buffer
, name
);
1825 pp_string (buffer
, "goto ");
1826 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1830 pp_string (buffer
, "__asm__");
1831 if (ASM_VOLATILE_P (node
))
1832 pp_string (buffer
, " __volatile__");
1833 pp_character (buffer
, '(');
1834 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1835 pp_character (buffer
, ':');
1836 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1837 pp_character (buffer
, ':');
1838 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1839 if (ASM_CLOBBERS (node
))
1841 pp_character (buffer
, ':');
1842 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1844 pp_string (buffer
, ")");
1847 case CASE_LABEL_EXPR
:
1848 if (CASE_LOW (node
) && CASE_HIGH (node
))
1850 pp_string (buffer
, "case ");
1851 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1852 pp_string (buffer
, " ... ");
1853 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1855 else if (CASE_LOW (node
))
1857 pp_string (buffer
, "case ");
1858 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1861 pp_string (buffer
, "default");
1862 pp_character (buffer
, ':');
1866 pp_string (buffer
, "OBJ_TYPE_REF(");
1867 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1868 pp_character (buffer
, ';');
1869 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1870 pp_character (buffer
, '-');
1871 pp_character (buffer
, '>');
1872 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
1873 pp_character (buffer
, ')');
1877 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
1878 pp_string (buffer
, "_");
1879 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1880 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
1881 pp_string (buffer
, "(ab)");
1882 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
1883 pp_string (buffer
, "(D)");
1886 case WITH_SIZE_EXPR
:
1887 pp_string (buffer
, "WITH_SIZE_EXPR <");
1888 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1889 pp_string (buffer
, ", ");
1890 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1891 pp_string (buffer
, ">");
1895 pp_string (buffer
, "ASSERT_EXPR <");
1896 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
1897 pp_string (buffer
, ", ");
1898 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
1899 pp_string (buffer
, ">");
1903 pp_string (buffer
, "scev_known");
1906 case SCEV_NOT_KNOWN
:
1907 pp_string (buffer
, "scev_not_known");
1910 case POLYNOMIAL_CHREC
:
1911 pp_string (buffer
, "{");
1912 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
1913 pp_string (buffer
, ", +, ");
1914 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
1915 pp_string (buffer
, "}_");
1916 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
1920 case REALIGN_LOAD_EXPR
:
1921 pp_string (buffer
, "REALIGN_LOAD <");
1922 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1923 pp_string (buffer
, ", ");
1924 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1925 pp_string (buffer
, ", ");
1926 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1927 pp_string (buffer
, ">");
1931 pp_string (buffer
, " VEC_COND_EXPR < ");
1932 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1933 pp_string (buffer
, " , ");
1934 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1935 pp_string (buffer
, " , ");
1936 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1937 pp_string (buffer
, " > ");
1941 pp_string (buffer
, " DOT_PROD_EXPR < ");
1942 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1943 pp_string (buffer
, ", ");
1944 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1945 pp_string (buffer
, ", ");
1946 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1947 pp_string (buffer
, " > ");
1951 pp_string (buffer
, "#pragma omp parallel");
1952 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
1955 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
1957 newline_and_indent (buffer
, spc
+ 2);
1958 pp_character (buffer
, '{');
1959 newline_and_indent (buffer
, spc
+ 4);
1960 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
1961 newline_and_indent (buffer
, spc
+ 2);
1962 pp_character (buffer
, '}');
1968 pp_string (buffer
, "#pragma omp task");
1969 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
1973 pp_string (buffer
, "#pragma omp for");
1974 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
1976 if (!(flags
& TDF_SLIM
))
1980 if (OMP_FOR_PRE_BODY (node
))
1982 newline_and_indent (buffer
, spc
+ 2);
1983 pp_character (buffer
, '{');
1985 newline_and_indent (buffer
, spc
);
1986 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
1990 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
1993 newline_and_indent (buffer
, spc
);
1994 pp_string (buffer
, "for (");
1995 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
1997 pp_string (buffer
, "; ");
1998 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
2000 pp_string (buffer
, "; ");
2001 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
2003 pp_string (buffer
, ")");
2005 if (OMP_FOR_BODY (node
))
2007 newline_and_indent (buffer
, spc
+ 2);
2008 pp_character (buffer
, '{');
2009 newline_and_indent (buffer
, spc
+ 4);
2010 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
2012 newline_and_indent (buffer
, spc
+ 2);
2013 pp_character (buffer
, '}');
2015 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
2016 if (OMP_FOR_PRE_BODY (node
))
2019 newline_and_indent (buffer
, spc
+ 2);
2020 pp_character (buffer
, '}');
2027 pp_string (buffer
, "#pragma omp sections");
2028 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2032 pp_string (buffer
, "#pragma omp section");
2036 pp_string (buffer
, "#pragma omp master");
2040 pp_string (buffer
, "#pragma omp ordered");
2044 pp_string (buffer
, "#pragma omp critical");
2045 if (OMP_CRITICAL_NAME (node
))
2048 pp_character (buffer
, '(');
2049 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2051 pp_character (buffer
, ')');
2056 pp_string (buffer
, "#pragma omp atomic");
2057 newline_and_indent (buffer
, spc
+ 2);
2058 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2060 pp_character (buffer
, '=');
2062 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2066 pp_string (buffer
, "#pragma omp single");
2067 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2071 dump_omp_clause (buffer
, node
, spc
, flags
);
2075 case REDUC_MAX_EXPR
:
2076 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2077 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2078 pp_string (buffer
, " > ");
2081 case REDUC_MIN_EXPR
:
2082 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2083 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2084 pp_string (buffer
, " > ");
2087 case REDUC_PLUS_EXPR
:
2088 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2089 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2090 pp_string (buffer
, " > ");
2093 case VEC_WIDEN_MULT_HI_EXPR
:
2094 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
2095 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2096 pp_string (buffer
, ", ");
2097 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2098 pp_string (buffer
, " > ");
2101 case VEC_WIDEN_MULT_LO_EXPR
:
2102 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
2103 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2104 pp_string (buffer
, ", ");
2105 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2106 pp_string (buffer
, " > ");
2109 case VEC_UNPACK_HI_EXPR
:
2110 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2111 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2112 pp_string (buffer
, " > ");
2115 case VEC_UNPACK_LO_EXPR
:
2116 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2117 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2118 pp_string (buffer
, " > ");
2121 case VEC_UNPACK_FLOAT_HI_EXPR
:
2122 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2123 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2124 pp_string (buffer
, " > ");
2127 case VEC_UNPACK_FLOAT_LO_EXPR
:
2128 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2129 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2130 pp_string (buffer
, " > ");
2133 case VEC_PACK_TRUNC_EXPR
:
2134 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2135 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2136 pp_string (buffer
, ", ");
2137 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2138 pp_string (buffer
, " > ");
2141 case VEC_PACK_SAT_EXPR
:
2142 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2143 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2144 pp_string (buffer
, ", ");
2145 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2146 pp_string (buffer
, " > ");
2149 case VEC_PACK_FIX_TRUNC_EXPR
:
2150 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2151 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2152 pp_string (buffer
, ", ");
2153 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2154 pp_string (buffer
, " > ");
2158 dump_block_node (buffer
, node
, spc
, flags
);
2161 case VEC_EXTRACT_EVEN_EXPR
:
2162 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2163 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2164 pp_string (buffer
, ", ");
2165 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2166 pp_string (buffer
, " > ");
2169 case VEC_EXTRACT_ODD_EXPR
:
2170 pp_string (buffer
, " VEC_EXTRACT_ODD_EXPR < ");
2171 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2172 pp_string (buffer
, ", ");
2173 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2174 pp_string (buffer
, " > ");
2177 case VEC_INTERLEAVE_HIGH_EXPR
:
2178 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_EXPR < ");
2179 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2180 pp_string (buffer
, ", ");
2181 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2182 pp_string (buffer
, " > ");
2185 case VEC_INTERLEAVE_LOW_EXPR
:
2186 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2187 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2188 pp_string (buffer
, ", ");
2189 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2190 pp_string (buffer
, " > ");
2197 if (is_stmt
&& is_expr
)
2198 pp_semicolon (buffer
);
2200 /* If we're building a diagnostic, the formatted text will be written
2201 into BUFFER's stream by the caller; otherwise, write it now. */
2202 if (!(flags
& TDF_DIAGNOSTIC
))
2203 pp_write_text_to_stream (buffer
);
2208 /* Print the declaration of a variable. */
2211 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2215 if (TREE_CODE (t
) == TYPE_DECL
)
2216 pp_string (buffer
, "typedef ");
2218 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2219 pp_string (buffer
, "register ");
2221 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2222 pp_string (buffer
, "extern ");
2223 else if (TREE_STATIC (t
))
2224 pp_string (buffer
, "static ");
2226 /* Print the type and name. */
2227 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2231 /* Print array's type. */
2232 tmp
= TREE_TYPE (t
);
2233 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2234 tmp
= TREE_TYPE (tmp
);
2235 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2237 /* Print variable's name. */
2239 dump_generic_node (buffer
, t
, spc
, flags
, false);
2241 /* Print the dimensions. */
2242 tmp
= TREE_TYPE (t
);
2243 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2245 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2246 tmp
= TREE_TYPE (tmp
);
2249 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2251 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2253 dump_decl_name (buffer
, t
, flags
);
2254 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2258 /* Print type declaration. */
2259 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2261 /* Print variable's name. */
2263 dump_generic_node (buffer
, t
, spc
, flags
, false);
2266 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2268 pp_string (buffer
, " __asm__ ");
2269 pp_character (buffer
, '(');
2270 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2271 pp_character (buffer
, ')');
2274 /* The initial value of a function serves to determine whether the function
2275 is declared or defined. So the following does not apply to function
2277 if (TREE_CODE (t
) != FUNCTION_DECL
)
2279 /* Print the initial value. */
2280 if (DECL_INITIAL (t
))
2283 pp_character (buffer
, '=');
2285 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2289 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2291 pp_string (buffer
, " [value-expr: ");
2292 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2293 pp_character (buffer
, ']');
2296 pp_character (buffer
, ';');
2300 /* Prints a structure: name, fields, and methods.
2301 FIXME: Still incomplete. */
2304 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2306 /* Print the name of the structure. */
2307 if (TYPE_NAME (node
))
2310 if (TREE_CODE (node
) == RECORD_TYPE
)
2311 pp_string (buffer
, "struct ");
2312 else if ((TREE_CODE (node
) == UNION_TYPE
2313 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2314 pp_string (buffer
, "union ");
2316 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2319 /* Print the contents of the structure. */
2320 pp_newline (buffer
);
2322 pp_character (buffer
, '{');
2323 pp_newline (buffer
);
2325 /* Print the fields of the structure. */
2328 tmp
= TYPE_FIELDS (node
);
2331 /* Avoid to print recursively the structure. */
2332 /* FIXME : Not implemented correctly...,
2333 what about the case when we have a cycle in the contain graph? ...
2334 Maybe this could be solved by looking at the scope in which the
2335 structure was declared. */
2336 if (TREE_TYPE (tmp
) != node
2337 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2338 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2340 print_declaration (buffer
, tmp
, spc
+2, flags
);
2341 pp_newline (buffer
);
2343 tmp
= TREE_CHAIN (tmp
);
2347 pp_character (buffer
, '}');
2350 /* Return the priority of the operator CODE.
2352 From lowest to highest precedence with either left-to-right (L-R)
2353 or right-to-left (R-L) associativity]:
2356 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2368 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2369 15 [L-R] fn() [] -> .
2371 unary +, - and * have higher precedence than the corresponding binary
2375 op_code_prio (enum tree_code code
)
2392 case TRUTH_ORIF_EXPR
:
2395 case TRUTH_AND_EXPR
:
2396 case TRUTH_ANDIF_EXPR
:
2403 case TRUTH_XOR_EXPR
:
2420 case UNORDERED_EXPR
:
2433 case WIDEN_SUM_EXPR
:
2435 case POINTER_PLUS_EXPR
:
2439 case VEC_WIDEN_MULT_HI_EXPR
:
2440 case VEC_WIDEN_MULT_LO_EXPR
:
2441 case WIDEN_MULT_EXPR
:
2444 case TRUNC_DIV_EXPR
:
2446 case FLOOR_DIV_EXPR
:
2447 case ROUND_DIV_EXPR
:
2449 case EXACT_DIV_EXPR
:
2450 case TRUNC_MOD_EXPR
:
2452 case FLOOR_MOD_EXPR
:
2453 case ROUND_MOD_EXPR
:
2456 case TRUTH_NOT_EXPR
:
2458 case POSTINCREMENT_EXPR
:
2459 case POSTDECREMENT_EXPR
:
2460 case PREINCREMENT_EXPR
:
2461 case PREDECREMENT_EXPR
:
2463 case ALIGN_INDIRECT_REF
:
2464 case MISALIGNED_INDIRECT_REF
:
2469 case FIX_TRUNC_EXPR
:
2475 case ARRAY_RANGE_REF
:
2479 /* Special expressions. */
2485 case REDUC_MAX_EXPR
:
2486 case REDUC_MIN_EXPR
:
2487 case REDUC_PLUS_EXPR
:
2488 case VEC_LSHIFT_EXPR
:
2489 case VEC_RSHIFT_EXPR
:
2490 case VEC_UNPACK_HI_EXPR
:
2491 case VEC_UNPACK_LO_EXPR
:
2492 case VEC_UNPACK_FLOAT_HI_EXPR
:
2493 case VEC_UNPACK_FLOAT_LO_EXPR
:
2494 case VEC_PACK_TRUNC_EXPR
:
2495 case VEC_PACK_SAT_EXPR
:
2499 /* Return an arbitrarily high precedence to avoid surrounding single
2500 VAR_DECLs in ()s. */
2505 /* Return the priority of the operator OP. */
2508 op_prio (const_tree op
)
2510 enum tree_code code
;
2515 code
= TREE_CODE (op
);
2516 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2517 return op_prio (TREE_OPERAND (op
, 0));
2519 return op_code_prio (code
);
2522 /* Return the symbol associated with operator CODE. */
2525 op_symbol_code (enum tree_code code
)
2533 case TRUTH_ORIF_EXPR
:
2536 case TRUTH_AND_EXPR
:
2537 case TRUTH_ANDIF_EXPR
:
2543 case TRUTH_XOR_EXPR
:
2553 case UNORDERED_EXPR
:
2599 case VEC_LSHIFT_EXPR
:
2602 case VEC_RSHIFT_EXPR
:
2605 case POINTER_PLUS_EXPR
:
2611 case REDUC_PLUS_EXPR
:
2614 case WIDEN_SUM_EXPR
:
2617 case WIDEN_MULT_EXPR
:
2627 case TRUTH_NOT_EXPR
:
2634 case ALIGN_INDIRECT_REF
:
2637 case MISALIGNED_INDIRECT_REF
:
2640 case TRUNC_DIV_EXPR
:
2647 case FLOOR_DIV_EXPR
:
2650 case ROUND_DIV_EXPR
:
2653 case EXACT_DIV_EXPR
:
2656 case TRUNC_MOD_EXPR
:
2662 case FLOOR_MOD_EXPR
:
2665 case ROUND_MOD_EXPR
:
2668 case PREDECREMENT_EXPR
:
2671 case PREINCREMENT_EXPR
:
2674 case POSTDECREMENT_EXPR
:
2677 case POSTINCREMENT_EXPR
:
2687 return "<<< ??? >>>";
2691 /* Return the symbol associated with operator OP. */
2694 op_symbol (const_tree op
)
2696 return op_symbol_code (TREE_CODE (op
));
2699 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2700 the gimple_call_fn of a GIMPLE_CALL. */
2703 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
2707 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2708 op0
= TREE_OPERAND (op0
, 0);
2711 switch (TREE_CODE (op0
))
2716 dump_function_name (buffer
, op0
, flags
);
2722 op0
= TREE_OPERAND (op0
, 0);
2726 pp_string (buffer
, "(");
2727 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
2728 pp_string (buffer
, ") ? ");
2729 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
2730 pp_string (buffer
, " : ");
2731 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
2735 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2736 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
2738 dump_generic_node (buffer
, op0
, 0, flags
, false);
2744 dump_generic_node (buffer
, op0
, 0, flags
, false);
2752 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2755 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2765 pp_string (buffer
, "\\b");
2769 pp_string (buffer
, "\\f");
2773 pp_string (buffer
, "\\n");
2777 pp_string (buffer
, "\\r");
2781 pp_string (buffer
, "\\t");
2785 pp_string (buffer
, "\\v");
2789 pp_string (buffer
, "\\\\");
2793 pp_string (buffer
, "\\\"");
2797 pp_string (buffer
, "\\'");
2800 /* No need to handle \0; the loop terminates on \0. */
2803 pp_string (buffer
, "\\1");
2807 pp_string (buffer
, "\\2");
2811 pp_string (buffer
, "\\3");
2815 pp_string (buffer
, "\\4");
2819 pp_string (buffer
, "\\5");
2823 pp_string (buffer
, "\\6");
2827 pp_string (buffer
, "\\7");
2831 pp_character (buffer
, str
[0]);
2839 maybe_init_pretty_print (FILE *file
)
2843 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
2844 pp_needs_newline (&buffer
) = true;
2845 pp_translate_identifiers (&buffer
) = false;
2849 buffer
.buffer
->stream
= file
;
2853 newline_and_indent (pretty_printer
*buffer
, int spc
)
2855 pp_newline (buffer
);
2859 /* Handle a %K format for TEXT. Separate from default_tree_printer so
2860 it can also be used in front ends.
2861 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
2865 percent_K_format (text_info
*text
)
2867 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
2868 gcc_assert (text
->locus
!= NULL
);
2869 *text
->locus
= EXPR_LOCATION (t
);
2870 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
2871 block
= TREE_BLOCK (t
);
2872 *pp_ti_abstract_origin (text
) = NULL
;
2874 && TREE_CODE (block
) == BLOCK
2875 && BLOCK_ABSTRACT_ORIGIN (block
))
2877 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
2879 while (TREE_CODE (ao
) == BLOCK
2880 && BLOCK_ABSTRACT_ORIGIN (ao
)
2881 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
2882 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
2884 if (TREE_CODE (ao
) == FUNCTION_DECL
)
2886 *pp_ti_abstract_origin (text
) = block
;
2889 block
= BLOCK_SUPERCONTEXT (block
);
2893 /* Print the identifier ID to PRETTY-PRINTER. */
2896 pp_base_tree_identifier (pretty_printer
*pp
, tree id
)
2898 if (pp_translate_identifiers (pp
))
2900 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
2901 pp_append_text (pp
, text
, text
+ strlen (text
));
2904 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
2905 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));