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
, " >>>");
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
);
760 else if (flags
& TDF_NOUID
)
761 pp_printf (buffer
, "<Txxxx>");
763 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
765 pp_character (buffer
, ')');
766 dump_function_declaration (buffer
, fnode
, spc
, flags
);
770 unsigned int quals
= TYPE_QUALS (node
);
772 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
774 pp_string (buffer
, str
);
776 if (quals
& TYPE_QUAL_CONST
)
777 pp_string (buffer
, " const");
778 if (quals
& TYPE_QUAL_VOLATILE
)
779 pp_string (buffer
, " volatile");
780 if (quals
& TYPE_QUAL_RESTRICT
)
781 pp_string (buffer
, " restrict");
783 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
785 pp_string (buffer
, " <address-space-");
786 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
787 pp_string (buffer
, ">");
790 if (TYPE_REF_CAN_ALIAS_ALL (node
))
791 pp_string (buffer
, " {ref-all}");
801 if (integer_zerop (TREE_OPERAND (node
, 1))
802 /* Same pointer types, but ignoring POINTER_TYPE vs.
804 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 0)))
805 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))
806 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 0)))
807 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 1))))
808 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 0)))
809 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 1))))
810 && (TYPE_QUALS (TREE_TYPE (TREE_OPERAND (node
, 0)))
811 == TYPE_QUALS (TREE_TYPE (TREE_OPERAND (node
, 1))))
812 /* Same value types ignoring qualifiers. */
813 && (TYPE_MAIN_VARIANT (TREE_TYPE (node
))
815 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))))
817 if (TREE_CODE (TREE_OPERAND (node
, 0)) != ADDR_EXPR
)
819 pp_string (buffer
, "*");
820 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
824 dump_generic_node (buffer
,
825 TREE_OPERAND (TREE_OPERAND (node
, 0), 0),
830 pp_string (buffer
, "MEM[");
831 pp_string (buffer
, "(");
832 dump_generic_node (buffer
, TREE_TYPE (TREE_OPERAND (node
, 1)),
833 spc
, flags
| TDF_SLIM
, false);
834 pp_string (buffer
, ")");
835 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
837 if (!integer_zerop (TREE_OPERAND (node
, 1)))
839 pp_string (buffer
, " + ");
840 dump_generic_node (buffer
, TREE_OPERAND (node
, 1),
843 pp_string (buffer
, "]");
850 const char *sep
= "";
853 pp_string (buffer
, "MEM[");
855 tmp
= TMR_SYMBOL (node
);
858 pp_string (buffer
, sep
);
860 pp_string (buffer
, "symbol: ");
861 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
863 tmp
= TMR_BASE (node
);
866 pp_string (buffer
, sep
);
868 pp_string (buffer
, "base: ");
869 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
871 tmp
= TMR_INDEX (node
);
874 pp_string (buffer
, sep
);
876 pp_string (buffer
, "index: ");
877 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
879 tmp
= TMR_STEP (node
);
882 pp_string (buffer
, sep
);
884 pp_string (buffer
, "step: ");
885 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
887 tmp
= TMR_OFFSET (node
);
890 pp_string (buffer
, sep
);
892 pp_string (buffer
, "offset: ");
893 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
895 pp_string (buffer
, "]");
896 if (flags
& TDF_DETAILS
)
898 pp_string (buffer
, "{");
899 dump_generic_node (buffer
, TMR_ORIGINAL (node
), spc
, flags
,
901 pp_string (buffer
, "}");
910 /* Print the innermost component type. */
911 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
912 tmp
= TREE_TYPE (tmp
))
914 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
916 /* Print the dimensions. */
917 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
918 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
924 case QUAL_UNION_TYPE
:
926 unsigned int quals
= TYPE_QUALS (node
);
928 if (quals
& TYPE_QUAL_CONST
)
929 pp_string (buffer
, "const ");
930 if (quals
& TYPE_QUAL_VOLATILE
)
931 pp_string (buffer
, "volatile ");
933 /* Print the name of the structure. */
934 if (TREE_CODE (node
) == RECORD_TYPE
)
935 pp_string (buffer
, "struct ");
936 else if (TREE_CODE (node
) == UNION_TYPE
)
937 pp_string (buffer
, "union ");
939 if (TYPE_NAME (node
))
940 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
941 else if (!(flags
& TDF_SLIM
))
942 /* FIXME: If we eliminate the 'else' above and attempt
943 to show the fields for named types, we may get stuck
944 following a cycle of pointers to structs. The alleged
945 self-reference check in print_struct_decl will not detect
946 cycles involving more than one pointer or struct type. */
947 print_struct_decl (buffer
, node
, spc
, flags
);
956 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
958 /* In the case of a pointer, one may want to divide by the
959 size of the pointed-to type. Unfortunately, this not
960 straightforward. The C front-end maps expressions
965 in such a way that the two INTEGER_CST nodes for "5" have
966 different values but identical types. In the latter
967 case, the 5 is multiplied by sizeof (int) in c-common.c
968 (pointer_int_sum) to convert it to a byte address, and
969 yet the type of the node is left unchanged. Argh. What
970 is consistent though is that the number value corresponds
971 to bytes (UNITS) offset.
973 NB: Neither of the following divisors can be trivially
974 used to recover the original literal:
976 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
977 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
978 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
979 pp_string (buffer
, "B"); /* pseudo-unit */
981 else if (! host_integerp (node
, 0))
984 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (val
);
985 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (val
);
987 if (tree_int_cst_sgn (val
) < 0)
989 pp_character (buffer
, '-');
993 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
995 sprintf (pp_buffer (buffer
)->digit_buffer
,
996 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
997 (unsigned HOST_WIDE_INT
) high
, low
);
998 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
1001 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1005 /* Code copied from print_node. */
1008 if (TREE_OVERFLOW (node
))
1009 pp_string (buffer
, " overflow");
1011 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1012 d
= TREE_REAL_CST (node
);
1013 if (REAL_VALUE_ISINF (d
))
1014 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
1015 else if (REAL_VALUE_ISNAN (d
))
1016 pp_string (buffer
, " Nan");
1020 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
1021 pp_string (buffer
, string
);
1026 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
1027 pp_string (buffer
, "0x");
1028 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
1029 output_formatted_integer (buffer
, "%02x", *p
++);
1038 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
1039 pp_string (buffer
, string
);
1044 pp_string (buffer
, "__complex__ (");
1045 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
1046 pp_string (buffer
, ", ");
1047 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
1048 pp_string (buffer
, ")");
1052 pp_string (buffer
, "\"");
1053 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
1054 pp_string (buffer
, "\"");
1060 pp_string (buffer
, "{ ");
1061 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
1063 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
, false);
1064 if (TREE_CHAIN (elt
))
1065 pp_string (buffer
, ", ");
1067 pp_string (buffer
, " }");
1073 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1075 if (TREE_CODE (node
) == METHOD_TYPE
)
1077 if (TYPE_METHOD_BASETYPE (node
))
1078 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
1081 pp_string (buffer
, "<null method basetype>");
1082 pp_string (buffer
, "::");
1084 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1085 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1086 else if (flags
& TDF_NOUID
)
1087 pp_printf (buffer
, "<Txxxx>");
1089 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1090 dump_function_declaration (buffer
, node
, spc
, flags
);
1095 dump_decl_name (buffer
, node
, flags
);
1099 if (DECL_NAME (node
))
1100 dump_decl_name (buffer
, node
, flags
);
1101 else if (LABEL_DECL_UID (node
) != -1)
1102 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1105 if (flags
& TDF_NOUID
)
1106 pp_string (buffer
, "<D.xxxx>");
1108 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1113 if (DECL_IS_BUILTIN (node
))
1115 /* Don't print the declaration of built-in types. */
1118 if (DECL_NAME (node
))
1119 dump_decl_name (buffer
, node
, flags
);
1120 else if (TYPE_NAME (TREE_TYPE (node
)) != node
)
1122 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1123 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1124 && TYPE_METHODS (TREE_TYPE (node
)))
1126 /* The type is a c++ class: all structures have at least
1128 pp_string (buffer
, "class ");
1129 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1134 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1135 ? "union" : "struct "));
1136 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1140 pp_string (buffer
, "<anon>");
1146 case DEBUG_EXPR_DECL
:
1147 case NAMESPACE_DECL
:
1148 dump_decl_name (buffer
, node
, flags
);
1152 pp_string (buffer
, "<retval>");
1156 op0
= TREE_OPERAND (node
, 0);
1159 && (TREE_CODE (op0
) == INDIRECT_REF
1160 || (TREE_CODE (op0
) == MEM_REF
1161 && TREE_CODE (TREE_OPERAND (op0
, 0)) != ADDR_EXPR
1162 && integer_zerop (TREE_OPERAND (op0
, 1))
1163 /* Same pointer types, but ignoring POINTER_TYPE vs.
1165 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1166 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1167 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1168 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1169 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1170 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1171 && (TYPE_QUALS (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1172 == TYPE_QUALS (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1173 /* Same value types ignoring qualifiers. */
1174 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0
))
1175 == TYPE_MAIN_VARIANT
1176 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))))))
1178 op0
= TREE_OPERAND (op0
, 0);
1181 if (op_prio (op0
) < op_prio (node
))
1182 pp_character (buffer
, '(');
1183 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1184 if (op_prio (op0
) < op_prio (node
))
1185 pp_character (buffer
, ')');
1186 pp_string (buffer
, str
);
1187 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1188 op0
= component_ref_field_offset (node
);
1189 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1191 pp_string (buffer
, "{off: ");
1192 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1193 pp_character (buffer
, '}');
1198 pp_string (buffer
, "BIT_FIELD_REF <");
1199 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1200 pp_string (buffer
, ", ");
1201 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1202 pp_string (buffer
, ", ");
1203 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1204 pp_string (buffer
, ">");
1208 case ARRAY_RANGE_REF
:
1209 op0
= TREE_OPERAND (node
, 0);
1210 if (op_prio (op0
) < op_prio (node
))
1211 pp_character (buffer
, '(');
1212 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1213 if (op_prio (op0
) < op_prio (node
))
1214 pp_character (buffer
, ')');
1215 pp_character (buffer
, '[');
1216 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1217 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1218 pp_string (buffer
, " ...");
1219 pp_character (buffer
, ']');
1221 op0
= array_ref_low_bound (node
);
1222 op1
= array_ref_element_size (node
);
1224 if (!integer_zerop (op0
)
1225 || TREE_OPERAND (node
, 2)
1226 || TREE_OPERAND (node
, 3))
1228 pp_string (buffer
, "{lb: ");
1229 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1230 pp_string (buffer
, " sz: ");
1231 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1232 pp_character (buffer
, '}');
1238 unsigned HOST_WIDE_INT ix
;
1240 bool is_struct_init
= FALSE
;
1241 pp_character (buffer
, '{');
1242 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1243 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1244 is_struct_init
= TRUE
;
1245 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1247 if (field
&& is_struct_init
)
1249 pp_character (buffer
, '.');
1250 dump_generic_node (buffer
, field
, spc
, flags
, false);
1251 pp_string (buffer
, "=");
1253 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1254 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1255 val
= TREE_OPERAND (val
, 0);
1256 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1257 dump_decl_name (buffer
, val
, flags
);
1259 dump_generic_node (buffer
, val
, spc
, flags
, false);
1260 if (ix
!= VEC_length (constructor_elt
, CONSTRUCTOR_ELTS (node
)) - 1)
1262 pp_character (buffer
, ',');
1266 pp_character (buffer
, '}');
1273 if (flags
& TDF_SLIM
)
1275 pp_string (buffer
, "<COMPOUND_EXPR>");
1279 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1280 spc
, flags
, !(flags
& TDF_SLIM
));
1281 if (flags
& TDF_SLIM
)
1282 newline_and_indent (buffer
, spc
);
1285 pp_character (buffer
, ',');
1289 for (tp
= &TREE_OPERAND (node
, 1);
1290 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1291 tp
= &TREE_OPERAND (*tp
, 1))
1293 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1294 spc
, flags
, !(flags
& TDF_SLIM
));
1295 if (flags
& TDF_SLIM
)
1296 newline_and_indent (buffer
, spc
);
1299 pp_character (buffer
, ',');
1304 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1308 case STATEMENT_LIST
:
1310 tree_stmt_iterator si
;
1313 if (flags
& TDF_SLIM
)
1315 pp_string (buffer
, "<STATEMENT_LIST>");
1319 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1322 newline_and_indent (buffer
, spc
);
1325 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1332 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1335 pp_character (buffer
, '=');
1336 if (TREE_CODE (node
) == MODIFY_EXPR
1337 && MOVE_NONTEMPORAL (node
))
1338 pp_string (buffer
, "{nt}");
1340 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1345 pp_string (buffer
, "TARGET_EXPR <");
1346 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1347 pp_character (buffer
, ',');
1349 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1350 pp_character (buffer
, '>');
1354 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1359 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1361 pp_string (buffer
, "if (");
1362 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1363 pp_character (buffer
, ')');
1364 /* The lowered cond_exprs should always be printed in full. */
1365 if (COND_EXPR_THEN (node
)
1366 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1367 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1368 && COND_EXPR_ELSE (node
)
1369 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1370 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1373 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1375 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1377 pp_string (buffer
, " else ");
1378 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1382 else if (!(flags
& TDF_SLIM
))
1384 /* Output COND_EXPR_THEN. */
1385 if (COND_EXPR_THEN (node
))
1387 newline_and_indent (buffer
, spc
+2);
1388 pp_character (buffer
, '{');
1389 newline_and_indent (buffer
, spc
+4);
1390 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1392 newline_and_indent (buffer
, spc
+2);
1393 pp_character (buffer
, '}');
1396 /* Output COND_EXPR_ELSE. */
1397 if (COND_EXPR_ELSE (node
)
1398 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1400 newline_and_indent (buffer
, spc
);
1401 pp_string (buffer
, "else");
1402 newline_and_indent (buffer
, spc
+2);
1403 pp_character (buffer
, '{');
1404 newline_and_indent (buffer
, spc
+4);
1405 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1407 newline_and_indent (buffer
, spc
+2);
1408 pp_character (buffer
, '}');
1415 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1417 pp_character (buffer
, '?');
1419 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1421 pp_character (buffer
, ':');
1423 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1428 pp_character (buffer
, '{');
1429 if (!(flags
& TDF_SLIM
))
1431 if (BIND_EXPR_VARS (node
))
1433 pp_newline (buffer
);
1435 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= TREE_CHAIN (op0
))
1437 print_declaration (buffer
, op0
, spc
+2, flags
);
1438 pp_newline (buffer
);
1442 newline_and_indent (buffer
, spc
+2);
1443 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1444 newline_and_indent (buffer
, spc
);
1445 pp_character (buffer
, '}');
1451 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1453 /* Print parameters. */
1455 pp_character (buffer
, '(');
1458 call_expr_arg_iterator iter
;
1459 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1461 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1462 if (more_call_expr_args_p (&iter
))
1464 pp_character (buffer
, ',');
1469 if (CALL_EXPR_VA_ARG_PACK (node
))
1471 if (call_expr_nargs (node
) > 0)
1473 pp_character (buffer
, ',');
1476 pp_string (buffer
, "__builtin_va_arg_pack ()");
1478 pp_character (buffer
, ')');
1480 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1483 pp_string (buffer
, " [static-chain: ");
1484 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1485 pp_character (buffer
, ']');
1488 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1489 pp_string (buffer
, " [return slot optimization]");
1490 if (CALL_EXPR_TAILCALL (node
))
1491 pp_string (buffer
, " [tail call]");
1494 case WITH_CLEANUP_EXPR
:
1498 case CLEANUP_POINT_EXPR
:
1499 pp_string (buffer
, "<<cleanup_point ");
1500 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1501 pp_string (buffer
, ">>");
1504 case PLACEHOLDER_EXPR
:
1505 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1506 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1507 pp_character (buffer
, '>');
1510 /* Binary arithmetic and logic expressions. */
1511 case WIDEN_SUM_EXPR
:
1512 case WIDEN_MULT_EXPR
:
1515 case POINTER_PLUS_EXPR
:
1517 case TRUNC_DIV_EXPR
:
1519 case FLOOR_DIV_EXPR
:
1520 case ROUND_DIV_EXPR
:
1521 case TRUNC_MOD_EXPR
:
1523 case FLOOR_MOD_EXPR
:
1524 case ROUND_MOD_EXPR
:
1526 case EXACT_DIV_EXPR
:
1531 case VEC_LSHIFT_EXPR
:
1532 case VEC_RSHIFT_EXPR
:
1536 case TRUTH_ANDIF_EXPR
:
1537 case TRUTH_ORIF_EXPR
:
1538 case TRUTH_AND_EXPR
:
1540 case TRUTH_XOR_EXPR
:
1554 case UNORDERED_EXPR
:
1556 const char *op
= op_symbol (node
);
1557 op0
= TREE_OPERAND (node
, 0);
1558 op1
= TREE_OPERAND (node
, 1);
1560 /* When the operands are expressions with less priority,
1561 keep semantics of the tree representation. */
1562 if (op_prio (op0
) <= op_prio (node
))
1564 pp_character (buffer
, '(');
1565 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1566 pp_character (buffer
, ')');
1569 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1572 pp_string (buffer
, op
);
1575 /* When the operands are expressions with less priority,
1576 keep semantics of the tree representation. */
1577 if (op_prio (op1
) <= op_prio (node
))
1579 pp_character (buffer
, '(');
1580 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1581 pp_character (buffer
, ')');
1584 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1588 /* Unary arithmetic and logic expressions. */
1591 case TRUTH_NOT_EXPR
:
1593 case PREDECREMENT_EXPR
:
1594 case PREINCREMENT_EXPR
:
1595 case MISALIGNED_INDIRECT_REF
:
1597 if (TREE_CODE (node
) == ADDR_EXPR
1598 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1599 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1600 ; /* Do not output '&' for strings and function pointers. */
1602 pp_string (buffer
, op_symbol (node
));
1604 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1606 pp_character (buffer
, '(');
1607 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1608 pp_character (buffer
, ')');
1611 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1613 if (TREE_CODE (node
) == MISALIGNED_INDIRECT_REF
)
1615 pp_string (buffer
, "{misalignment: ");
1616 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1617 pp_character (buffer
, '}');
1621 case POSTDECREMENT_EXPR
:
1622 case POSTINCREMENT_EXPR
:
1623 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1625 pp_character (buffer
, '(');
1626 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1627 pp_character (buffer
, ')');
1630 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1631 pp_string (buffer
, op_symbol (node
));
1635 pp_string (buffer
, "MIN_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_character (buffer
, '>');
1643 pp_string (buffer
, "MAX_EXPR <");
1644 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1645 pp_string (buffer
, ", ");
1646 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1647 pp_character (buffer
, '>');
1651 pp_string (buffer
, "ABS_EXPR <");
1652 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1653 pp_character (buffer
, '>');
1660 case ADDR_SPACE_CONVERT_EXPR
:
1661 case FIXED_CONVERT_EXPR
:
1662 case FIX_TRUNC_EXPR
:
1665 type
= TREE_TYPE (node
);
1666 op0
= TREE_OPERAND (node
, 0);
1667 if (type
!= TREE_TYPE (op0
))
1669 pp_character (buffer
, '(');
1670 dump_generic_node (buffer
, type
, spc
, flags
, false);
1671 pp_string (buffer
, ") ");
1673 if (op_prio (op0
) < op_prio (node
))
1674 pp_character (buffer
, '(');
1675 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1676 if (op_prio (op0
) < op_prio (node
))
1677 pp_character (buffer
, ')');
1680 case VIEW_CONVERT_EXPR
:
1681 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1682 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1683 pp_string (buffer
, ">(");
1684 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1685 pp_character (buffer
, ')');
1689 pp_string (buffer
, "((");
1690 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1691 pp_string (buffer
, "))");
1694 case NON_LVALUE_EXPR
:
1695 pp_string (buffer
, "NON_LVALUE_EXPR <");
1696 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1697 pp_character (buffer
, '>');
1701 pp_string (buffer
, "SAVE_EXPR <");
1702 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1703 pp_character (buffer
, '>');
1707 pp_string (buffer
, "COMPLEX_EXPR <");
1708 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1709 pp_string (buffer
, ", ");
1710 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1711 pp_string (buffer
, ">");
1715 pp_string (buffer
, "CONJ_EXPR <");
1716 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1717 pp_string (buffer
, ">");
1721 pp_string (buffer
, "REALPART_EXPR <");
1722 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1723 pp_string (buffer
, ">");
1727 pp_string (buffer
, "IMAGPART_EXPR <");
1728 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1729 pp_string (buffer
, ">");
1733 pp_string (buffer
, "VA_ARG_EXPR <");
1734 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1735 pp_string (buffer
, ">");
1738 case TRY_FINALLY_EXPR
:
1739 case TRY_CATCH_EXPR
:
1740 pp_string (buffer
, "try");
1741 newline_and_indent (buffer
, spc
+2);
1742 pp_string (buffer
, "{");
1743 newline_and_indent (buffer
, spc
+4);
1744 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1745 newline_and_indent (buffer
, spc
+2);
1746 pp_string (buffer
, "}");
1747 newline_and_indent (buffer
, spc
);
1749 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1750 newline_and_indent (buffer
, spc
+2);
1751 pp_string (buffer
, "{");
1752 newline_and_indent (buffer
, spc
+4);
1753 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1754 newline_and_indent (buffer
, spc
+2);
1755 pp_string (buffer
, "}");
1760 pp_string (buffer
, "catch (");
1761 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1762 pp_string (buffer
, ")");
1763 newline_and_indent (buffer
, spc
+2);
1764 pp_string (buffer
, "{");
1765 newline_and_indent (buffer
, spc
+4);
1766 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1767 newline_and_indent (buffer
, spc
+2);
1768 pp_string (buffer
, "}");
1772 case EH_FILTER_EXPR
:
1773 pp_string (buffer
, "<<<eh_filter (");
1774 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1775 pp_string (buffer
, ")>>>");
1776 newline_and_indent (buffer
, spc
+2);
1777 pp_string (buffer
, "{");
1778 newline_and_indent (buffer
, spc
+4);
1779 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1780 newline_and_indent (buffer
, spc
+2);
1781 pp_string (buffer
, "}");
1786 op0
= TREE_OPERAND (node
, 0);
1787 /* If this is for break or continue, don't bother printing it. */
1788 if (DECL_NAME (op0
))
1790 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1791 if (strcmp (name
, "break") == 0
1792 || strcmp (name
, "continue") == 0)
1795 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1796 pp_character (buffer
, ':');
1797 if (DECL_NONLOCAL (op0
))
1798 pp_string (buffer
, " [non-local]");
1802 pp_string (buffer
, "while (1)");
1803 if (!(flags
& TDF_SLIM
))
1805 newline_and_indent (buffer
, spc
+2);
1806 pp_character (buffer
, '{');
1807 newline_and_indent (buffer
, spc
+4);
1808 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1809 newline_and_indent (buffer
, spc
+2);
1810 pp_character (buffer
, '}');
1816 pp_string (buffer
, "// predicted ");
1817 if (PREDICT_EXPR_OUTCOME (node
))
1818 pp_string (buffer
, "likely by ");
1820 pp_string (buffer
, "unlikely by ");
1821 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
1822 pp_string (buffer
, " predictor.");
1826 pp_string (buffer
, "return");
1827 op0
= TREE_OPERAND (node
, 0);
1831 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1832 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
1835 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1840 pp_string (buffer
, "if (");
1841 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1842 pp_string (buffer
, ") break");
1846 pp_string (buffer
, "switch (");
1847 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1848 pp_character (buffer
, ')');
1849 if (!(flags
& TDF_SLIM
))
1851 newline_and_indent (buffer
, spc
+2);
1852 pp_character (buffer
, '{');
1853 if (SWITCH_BODY (node
))
1855 newline_and_indent (buffer
, spc
+4);
1856 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1861 tree vec
= SWITCH_LABELS (node
);
1862 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1863 for (i
= 0; i
< n
; ++i
)
1865 tree elt
= TREE_VEC_ELT (vec
, i
);
1866 newline_and_indent (buffer
, spc
+4);
1869 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1870 pp_string (buffer
, " goto ");
1871 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1873 pp_semicolon (buffer
);
1876 pp_string (buffer
, "case ???: goto ???;");
1879 newline_and_indent (buffer
, spc
+2);
1880 pp_character (buffer
, '}');
1886 op0
= GOTO_DESTINATION (node
);
1887 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1889 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1890 if (strcmp (name
, "break") == 0
1891 || strcmp (name
, "continue") == 0)
1893 pp_string (buffer
, name
);
1897 pp_string (buffer
, "goto ");
1898 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1902 pp_string (buffer
, "__asm__");
1903 if (ASM_VOLATILE_P (node
))
1904 pp_string (buffer
, " __volatile__");
1905 pp_character (buffer
, '(');
1906 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1907 pp_character (buffer
, ':');
1908 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1909 pp_character (buffer
, ':');
1910 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1911 if (ASM_CLOBBERS (node
))
1913 pp_character (buffer
, ':');
1914 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1916 pp_string (buffer
, ")");
1919 case CASE_LABEL_EXPR
:
1920 if (CASE_LOW (node
) && CASE_HIGH (node
))
1922 pp_string (buffer
, "case ");
1923 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1924 pp_string (buffer
, " ... ");
1925 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1927 else if (CASE_LOW (node
))
1929 pp_string (buffer
, "case ");
1930 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1933 pp_string (buffer
, "default");
1934 pp_character (buffer
, ':');
1938 pp_string (buffer
, "OBJ_TYPE_REF(");
1939 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1940 pp_character (buffer
, ';');
1941 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1942 pp_character (buffer
, '-');
1943 pp_character (buffer
, '>');
1944 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
1945 pp_character (buffer
, ')');
1949 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
1950 pp_string (buffer
, "_");
1951 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1952 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
1953 pp_string (buffer
, "(ab)");
1954 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
1955 pp_string (buffer
, "(D)");
1958 case WITH_SIZE_EXPR
:
1959 pp_string (buffer
, "WITH_SIZE_EXPR <");
1960 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1961 pp_string (buffer
, ", ");
1962 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1963 pp_string (buffer
, ">");
1967 pp_string (buffer
, "ASSERT_EXPR <");
1968 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
1969 pp_string (buffer
, ", ");
1970 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
1971 pp_string (buffer
, ">");
1975 pp_string (buffer
, "scev_known");
1978 case SCEV_NOT_KNOWN
:
1979 pp_string (buffer
, "scev_not_known");
1982 case POLYNOMIAL_CHREC
:
1983 pp_string (buffer
, "{");
1984 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
1985 pp_string (buffer
, ", +, ");
1986 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
1987 pp_string (buffer
, "}_");
1988 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
1992 case REALIGN_LOAD_EXPR
:
1993 pp_string (buffer
, "REALIGN_LOAD <");
1994 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1995 pp_string (buffer
, ", ");
1996 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1997 pp_string (buffer
, ", ");
1998 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1999 pp_string (buffer
, ">");
2003 pp_string (buffer
, " VEC_COND_EXPR < ");
2004 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2005 pp_string (buffer
, " , ");
2006 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2007 pp_string (buffer
, " , ");
2008 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2009 pp_string (buffer
, " > ");
2013 pp_string (buffer
, " DOT_PROD_EXPR < ");
2014 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2015 pp_string (buffer
, ", ");
2016 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2017 pp_string (buffer
, ", ");
2018 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2019 pp_string (buffer
, " > ");
2022 case WIDEN_MULT_PLUS_EXPR
:
2023 pp_string (buffer
, " WIDEN_MULT_PLUS_EXPR < ");
2024 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2025 pp_string (buffer
, ", ");
2026 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2027 pp_string (buffer
, ", ");
2028 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2029 pp_string (buffer
, " > ");
2032 case WIDEN_MULT_MINUS_EXPR
:
2033 pp_string (buffer
, " WIDEN_MULT_MINUS_EXPR < ");
2034 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2035 pp_string (buffer
, ", ");
2036 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2037 pp_string (buffer
, ", ");
2038 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2039 pp_string (buffer
, " > ");
2043 pp_string (buffer
, "#pragma omp parallel");
2044 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
2047 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
2049 newline_and_indent (buffer
, spc
+ 2);
2050 pp_character (buffer
, '{');
2051 newline_and_indent (buffer
, spc
+ 4);
2052 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
2053 newline_and_indent (buffer
, spc
+ 2);
2054 pp_character (buffer
, '}');
2060 pp_string (buffer
, "#pragma omp task");
2061 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
2065 pp_string (buffer
, "#pragma omp for");
2066 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
2068 if (!(flags
& TDF_SLIM
))
2072 if (OMP_FOR_PRE_BODY (node
))
2074 newline_and_indent (buffer
, spc
+ 2);
2075 pp_character (buffer
, '{');
2077 newline_and_indent (buffer
, spc
);
2078 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
2082 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
2085 newline_and_indent (buffer
, spc
);
2086 pp_string (buffer
, "for (");
2087 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
2089 pp_string (buffer
, "; ");
2090 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
2092 pp_string (buffer
, "; ");
2093 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
2095 pp_string (buffer
, ")");
2097 if (OMP_FOR_BODY (node
))
2099 newline_and_indent (buffer
, spc
+ 2);
2100 pp_character (buffer
, '{');
2101 newline_and_indent (buffer
, spc
+ 4);
2102 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
2104 newline_and_indent (buffer
, spc
+ 2);
2105 pp_character (buffer
, '}');
2107 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
2108 if (OMP_FOR_PRE_BODY (node
))
2111 newline_and_indent (buffer
, spc
+ 2);
2112 pp_character (buffer
, '}');
2119 pp_string (buffer
, "#pragma omp sections");
2120 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2124 pp_string (buffer
, "#pragma omp section");
2128 pp_string (buffer
, "#pragma omp master");
2132 pp_string (buffer
, "#pragma omp ordered");
2136 pp_string (buffer
, "#pragma omp critical");
2137 if (OMP_CRITICAL_NAME (node
))
2140 pp_character (buffer
, '(');
2141 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2143 pp_character (buffer
, ')');
2148 pp_string (buffer
, "#pragma omp atomic");
2149 newline_and_indent (buffer
, spc
+ 2);
2150 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2152 pp_character (buffer
, '=');
2154 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2158 pp_string (buffer
, "#pragma omp single");
2159 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2163 dump_omp_clause (buffer
, node
, spc
, flags
);
2167 case REDUC_MAX_EXPR
:
2168 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2169 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2170 pp_string (buffer
, " > ");
2173 case REDUC_MIN_EXPR
:
2174 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2175 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2176 pp_string (buffer
, " > ");
2179 case REDUC_PLUS_EXPR
:
2180 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2181 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2182 pp_string (buffer
, " > ");
2185 case VEC_WIDEN_MULT_HI_EXPR
:
2186 pp_string (buffer
, " VEC_WIDEN_MULT_HI_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
, " > ");
2193 case VEC_WIDEN_MULT_LO_EXPR
:
2194 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
2195 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2196 pp_string (buffer
, ", ");
2197 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2198 pp_string (buffer
, " > ");
2201 case VEC_UNPACK_HI_EXPR
:
2202 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2203 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2204 pp_string (buffer
, " > ");
2207 case VEC_UNPACK_LO_EXPR
:
2208 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2209 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2210 pp_string (buffer
, " > ");
2213 case VEC_UNPACK_FLOAT_HI_EXPR
:
2214 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2215 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2216 pp_string (buffer
, " > ");
2219 case VEC_UNPACK_FLOAT_LO_EXPR
:
2220 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2221 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2222 pp_string (buffer
, " > ");
2225 case VEC_PACK_TRUNC_EXPR
:
2226 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2227 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2228 pp_string (buffer
, ", ");
2229 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2230 pp_string (buffer
, " > ");
2233 case VEC_PACK_SAT_EXPR
:
2234 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2235 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2236 pp_string (buffer
, ", ");
2237 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2238 pp_string (buffer
, " > ");
2241 case VEC_PACK_FIX_TRUNC_EXPR
:
2242 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2243 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2244 pp_string (buffer
, ", ");
2245 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2246 pp_string (buffer
, " > ");
2250 dump_block_node (buffer
, node
, spc
, flags
);
2253 case VEC_EXTRACT_EVEN_EXPR
:
2254 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2255 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2256 pp_string (buffer
, ", ");
2257 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2258 pp_string (buffer
, " > ");
2261 case VEC_EXTRACT_ODD_EXPR
:
2262 pp_string (buffer
, " VEC_EXTRACT_ODD_EXPR < ");
2263 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2264 pp_string (buffer
, ", ");
2265 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2266 pp_string (buffer
, " > ");
2269 case VEC_INTERLEAVE_HIGH_EXPR
:
2270 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_EXPR < ");
2271 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2272 pp_string (buffer
, ", ");
2273 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2274 pp_string (buffer
, " > ");
2277 case VEC_INTERLEAVE_LOW_EXPR
:
2278 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2279 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2280 pp_string (buffer
, ", ");
2281 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2282 pp_string (buffer
, " > ");
2289 if (is_stmt
&& is_expr
)
2290 pp_semicolon (buffer
);
2292 /* If we're building a diagnostic, the formatted text will be written
2293 into BUFFER's stream by the caller; otherwise, write it now. */
2294 if (!(flags
& TDF_DIAGNOSTIC
))
2295 pp_write_text_to_stream (buffer
);
2300 /* Print the declaration of a variable. */
2303 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2307 if (TREE_CODE (t
) == TYPE_DECL
)
2308 pp_string (buffer
, "typedef ");
2310 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2311 pp_string (buffer
, "register ");
2313 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2314 pp_string (buffer
, "extern ");
2315 else if (TREE_STATIC (t
))
2316 pp_string (buffer
, "static ");
2318 /* Print the type and name. */
2319 if (TREE_TYPE (t
) && TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2323 /* Print array's type. */
2324 tmp
= TREE_TYPE (t
);
2325 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2326 tmp
= TREE_TYPE (tmp
);
2327 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2329 /* Print variable's name. */
2331 dump_generic_node (buffer
, t
, spc
, flags
, false);
2333 /* Print the dimensions. */
2334 tmp
= TREE_TYPE (t
);
2335 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2337 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2338 tmp
= TREE_TYPE (tmp
);
2341 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2343 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2345 dump_decl_name (buffer
, t
, flags
);
2346 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2350 /* Print type declaration. */
2351 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2353 /* Print variable's name. */
2355 dump_generic_node (buffer
, t
, spc
, flags
, false);
2358 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2360 pp_string (buffer
, " __asm__ ");
2361 pp_character (buffer
, '(');
2362 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2363 pp_character (buffer
, ')');
2366 /* The initial value of a function serves to determine whether the function
2367 is declared or defined. So the following does not apply to function
2369 if (TREE_CODE (t
) != FUNCTION_DECL
)
2371 /* Print the initial value. */
2372 if (DECL_INITIAL (t
))
2375 pp_character (buffer
, '=');
2377 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2381 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2383 pp_string (buffer
, " [value-expr: ");
2384 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2385 pp_character (buffer
, ']');
2388 pp_character (buffer
, ';');
2392 /* Prints a structure: name, fields, and methods.
2393 FIXME: Still incomplete. */
2396 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2398 /* Print the name of the structure. */
2399 if (TYPE_NAME (node
))
2402 if (TREE_CODE (node
) == RECORD_TYPE
)
2403 pp_string (buffer
, "struct ");
2404 else if ((TREE_CODE (node
) == UNION_TYPE
2405 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2406 pp_string (buffer
, "union ");
2408 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2411 /* Print the contents of the structure. */
2412 pp_newline (buffer
);
2414 pp_character (buffer
, '{');
2415 pp_newline (buffer
);
2417 /* Print the fields of the structure. */
2420 tmp
= TYPE_FIELDS (node
);
2423 /* Avoid to print recursively the structure. */
2424 /* FIXME : Not implemented correctly...,
2425 what about the case when we have a cycle in the contain graph? ...
2426 Maybe this could be solved by looking at the scope in which the
2427 structure was declared. */
2428 if (TREE_TYPE (tmp
) != node
2429 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2430 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2432 print_declaration (buffer
, tmp
, spc
+2, flags
);
2433 pp_newline (buffer
);
2435 tmp
= TREE_CHAIN (tmp
);
2439 pp_character (buffer
, '}');
2442 /* Return the priority of the operator CODE.
2444 From lowest to highest precedence with either left-to-right (L-R)
2445 or right-to-left (R-L) associativity]:
2448 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2460 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2461 15 [L-R] fn() [] -> .
2463 unary +, - and * have higher precedence than the corresponding binary
2467 op_code_prio (enum tree_code code
)
2484 case TRUTH_ORIF_EXPR
:
2487 case TRUTH_AND_EXPR
:
2488 case TRUTH_ANDIF_EXPR
:
2495 case TRUTH_XOR_EXPR
:
2512 case UNORDERED_EXPR
:
2525 case WIDEN_SUM_EXPR
:
2527 case POINTER_PLUS_EXPR
:
2531 case VEC_WIDEN_MULT_HI_EXPR
:
2532 case VEC_WIDEN_MULT_LO_EXPR
:
2533 case WIDEN_MULT_EXPR
:
2535 case WIDEN_MULT_PLUS_EXPR
:
2536 case WIDEN_MULT_MINUS_EXPR
:
2538 case TRUNC_DIV_EXPR
:
2540 case FLOOR_DIV_EXPR
:
2541 case ROUND_DIV_EXPR
:
2543 case EXACT_DIV_EXPR
:
2544 case TRUNC_MOD_EXPR
:
2546 case FLOOR_MOD_EXPR
:
2547 case ROUND_MOD_EXPR
:
2550 case TRUTH_NOT_EXPR
:
2552 case POSTINCREMENT_EXPR
:
2553 case POSTDECREMENT_EXPR
:
2554 case PREINCREMENT_EXPR
:
2555 case PREDECREMENT_EXPR
:
2557 case MISALIGNED_INDIRECT_REF
:
2562 case FIX_TRUNC_EXPR
:
2568 case ARRAY_RANGE_REF
:
2572 /* Special expressions. */
2578 case REDUC_MAX_EXPR
:
2579 case REDUC_MIN_EXPR
:
2580 case REDUC_PLUS_EXPR
:
2581 case VEC_LSHIFT_EXPR
:
2582 case VEC_RSHIFT_EXPR
:
2583 case VEC_UNPACK_HI_EXPR
:
2584 case VEC_UNPACK_LO_EXPR
:
2585 case VEC_UNPACK_FLOAT_HI_EXPR
:
2586 case VEC_UNPACK_FLOAT_LO_EXPR
:
2587 case VEC_PACK_TRUNC_EXPR
:
2588 case VEC_PACK_SAT_EXPR
:
2592 /* Return an arbitrarily high precedence to avoid surrounding single
2593 VAR_DECLs in ()s. */
2598 /* Return the priority of the operator OP. */
2601 op_prio (const_tree op
)
2603 enum tree_code code
;
2608 code
= TREE_CODE (op
);
2609 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2610 return op_prio (TREE_OPERAND (op
, 0));
2612 return op_code_prio (code
);
2615 /* Return the symbol associated with operator CODE. */
2618 op_symbol_code (enum tree_code code
)
2626 case TRUTH_ORIF_EXPR
:
2629 case TRUTH_AND_EXPR
:
2630 case TRUTH_ANDIF_EXPR
:
2636 case TRUTH_XOR_EXPR
:
2646 case UNORDERED_EXPR
:
2692 case VEC_LSHIFT_EXPR
:
2695 case VEC_RSHIFT_EXPR
:
2698 case POINTER_PLUS_EXPR
:
2704 case REDUC_PLUS_EXPR
:
2707 case WIDEN_SUM_EXPR
:
2710 case WIDEN_MULT_EXPR
:
2720 case TRUTH_NOT_EXPR
:
2727 case MISALIGNED_INDIRECT_REF
:
2730 case TRUNC_DIV_EXPR
:
2737 case FLOOR_DIV_EXPR
:
2740 case ROUND_DIV_EXPR
:
2743 case EXACT_DIV_EXPR
:
2746 case TRUNC_MOD_EXPR
:
2752 case FLOOR_MOD_EXPR
:
2755 case ROUND_MOD_EXPR
:
2758 case PREDECREMENT_EXPR
:
2761 case PREINCREMENT_EXPR
:
2764 case POSTDECREMENT_EXPR
:
2767 case POSTINCREMENT_EXPR
:
2777 return "<<< ??? >>>";
2781 /* Return the symbol associated with operator OP. */
2784 op_symbol (const_tree op
)
2786 return op_symbol_code (TREE_CODE (op
));
2789 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2790 the gimple_call_fn of a GIMPLE_CALL. */
2793 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
2797 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2798 op0
= TREE_OPERAND (op0
, 0);
2801 switch (TREE_CODE (op0
))
2806 dump_function_name (buffer
, op0
, flags
);
2812 op0
= TREE_OPERAND (op0
, 0);
2816 pp_string (buffer
, "(");
2817 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
2818 pp_string (buffer
, ") ? ");
2819 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
2820 pp_string (buffer
, " : ");
2821 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
2825 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2826 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
2828 dump_generic_node (buffer
, op0
, 0, flags
, false);
2832 if (integer_zerop (TREE_OPERAND (op0
, 1)))
2834 op0
= TREE_OPERAND (op0
, 0);
2841 dump_generic_node (buffer
, op0
, 0, flags
, false);
2849 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2852 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2862 pp_string (buffer
, "\\b");
2866 pp_string (buffer
, "\\f");
2870 pp_string (buffer
, "\\n");
2874 pp_string (buffer
, "\\r");
2878 pp_string (buffer
, "\\t");
2882 pp_string (buffer
, "\\v");
2886 pp_string (buffer
, "\\\\");
2890 pp_string (buffer
, "\\\"");
2894 pp_string (buffer
, "\\'");
2897 /* No need to handle \0; the loop terminates on \0. */
2900 pp_string (buffer
, "\\1");
2904 pp_string (buffer
, "\\2");
2908 pp_string (buffer
, "\\3");
2912 pp_string (buffer
, "\\4");
2916 pp_string (buffer
, "\\5");
2920 pp_string (buffer
, "\\6");
2924 pp_string (buffer
, "\\7");
2928 pp_character (buffer
, str
[0]);
2936 maybe_init_pretty_print (FILE *file
)
2940 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
2941 pp_needs_newline (&buffer
) = true;
2942 pp_translate_identifiers (&buffer
) = false;
2946 buffer
.buffer
->stream
= file
;
2950 newline_and_indent (pretty_printer
*buffer
, int spc
)
2952 pp_newline (buffer
);
2956 /* Handle a %K format for TEXT. Separate from default_tree_printer so
2957 it can also be used in front ends.
2958 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
2962 percent_K_format (text_info
*text
)
2964 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
2965 gcc_assert (text
->locus
!= NULL
);
2966 *text
->locus
= EXPR_LOCATION (t
);
2967 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
2968 block
= TREE_BLOCK (t
);
2969 *pp_ti_abstract_origin (text
) = NULL
;
2971 && TREE_CODE (block
) == BLOCK
2972 && BLOCK_ABSTRACT_ORIGIN (block
))
2974 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
2976 while (TREE_CODE (ao
) == BLOCK
2977 && BLOCK_ABSTRACT_ORIGIN (ao
)
2978 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
2979 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
2981 if (TREE_CODE (ao
) == FUNCTION_DECL
)
2983 *pp_ti_abstract_origin (text
) = block
;
2986 block
= BLOCK_SUPERCONTEXT (block
);
2990 /* Print the identifier ID to PRETTY-PRINTER. */
2993 pp_base_tree_identifier (pretty_printer
*pp
, tree id
)
2995 if (pp_translate_identifiers (pp
))
2997 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
2998 pp_append_text (pp
, text
, text
+ strlen (text
));
3001 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
3002 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));