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_EACH_VEC_ELT (tree
, nlv
, i
, t
)
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
, ">");
735 else if (TREE_CODE (node
) == VOID_TYPE
)
736 pp_string (buffer
, "void");
738 pp_string (buffer
, "<unnamed type>");
745 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
747 if (TREE_TYPE (node
) == NULL
)
749 pp_string (buffer
, str
);
750 pp_string (buffer
, "<null type>");
752 else if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
754 tree fnode
= TREE_TYPE (node
);
756 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
758 pp_character (buffer
, '(');
759 pp_string (buffer
, str
);
760 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
761 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
762 else if (flags
& TDF_NOUID
)
763 pp_printf (buffer
, "<Txxxx>");
765 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
767 pp_character (buffer
, ')');
768 dump_function_declaration (buffer
, fnode
, spc
, flags
);
772 unsigned int quals
= TYPE_QUALS (node
);
774 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
776 pp_string (buffer
, str
);
778 if (quals
& TYPE_QUAL_CONST
)
779 pp_string (buffer
, " const");
780 if (quals
& TYPE_QUAL_VOLATILE
)
781 pp_string (buffer
, " volatile");
782 if (quals
& TYPE_QUAL_RESTRICT
)
783 pp_string (buffer
, " restrict");
785 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
787 pp_string (buffer
, " <address-space-");
788 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
789 pp_string (buffer
, ">");
792 if (TYPE_REF_CAN_ALIAS_ALL (node
))
793 pp_string (buffer
, " {ref-all}");
803 if (integer_zerop (TREE_OPERAND (node
, 1))
804 /* Dump the types of INTEGER_CSTs explicitly, for we can't
805 infer them and MEM_ATTR caching will share MEM_REFs
806 with differently-typed op0s. */
807 && TREE_CODE (TREE_OPERAND (node
, 0)) != INTEGER_CST
808 /* Same pointer types, but ignoring POINTER_TYPE vs.
810 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 0)))
811 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))
812 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 0)))
813 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 1))))
814 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 0)))
815 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 1))))
816 /* Same value types ignoring qualifiers. */
817 && (TYPE_MAIN_VARIANT (TREE_TYPE (node
))
819 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))))
821 if (TREE_CODE (TREE_OPERAND (node
, 0)) != ADDR_EXPR
)
823 pp_string (buffer
, "*");
824 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
828 dump_generic_node (buffer
,
829 TREE_OPERAND (TREE_OPERAND (node
, 0), 0),
836 pp_string (buffer
, "MEM[");
837 pp_string (buffer
, "(");
838 ptype
= TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node
, 1)));
839 dump_generic_node (buffer
, ptype
,
840 spc
, flags
| TDF_SLIM
, false);
841 pp_string (buffer
, ")");
842 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
844 if (!integer_zerop (TREE_OPERAND (node
, 1)))
846 pp_string (buffer
, " + ");
847 dump_generic_node (buffer
, TREE_OPERAND (node
, 1),
850 pp_string (buffer
, "]");
857 const char *sep
= "";
860 pp_string (buffer
, "MEM[");
862 if (TREE_CODE (TMR_BASE (node
)) == ADDR_EXPR
)
864 pp_string (buffer
, sep
);
866 pp_string (buffer
, "symbol: ");
867 dump_generic_node (buffer
, TREE_OPERAND (TMR_BASE (node
), 0),
872 pp_string (buffer
, sep
);
874 pp_string (buffer
, "base: ");
875 dump_generic_node (buffer
, TMR_BASE (node
), spc
, flags
, false);
877 tmp
= TMR_INDEX2 (node
);
880 pp_string (buffer
, sep
);
882 pp_string (buffer
, "base: ");
883 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
885 tmp
= TMR_INDEX (node
);
888 pp_string (buffer
, sep
);
890 pp_string (buffer
, "index: ");
891 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
893 tmp
= TMR_STEP (node
);
896 pp_string (buffer
, sep
);
898 pp_string (buffer
, "step: ");
899 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
901 tmp
= TMR_OFFSET (node
);
904 pp_string (buffer
, sep
);
906 pp_string (buffer
, "offset: ");
907 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
909 pp_string (buffer
, "]");
917 /* Print the innermost component type. */
918 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
919 tmp
= TREE_TYPE (tmp
))
921 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
923 /* Print the dimensions. */
924 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
925 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
931 case QUAL_UNION_TYPE
:
933 unsigned int quals
= TYPE_QUALS (node
);
935 if (quals
& TYPE_QUAL_CONST
)
936 pp_string (buffer
, "const ");
937 if (quals
& TYPE_QUAL_VOLATILE
)
938 pp_string (buffer
, "volatile ");
940 /* Print the name of the structure. */
941 if (TREE_CODE (node
) == RECORD_TYPE
)
942 pp_string (buffer
, "struct ");
943 else if (TREE_CODE (node
) == UNION_TYPE
)
944 pp_string (buffer
, "union ");
946 if (TYPE_NAME (node
))
947 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
948 else if (!(flags
& TDF_SLIM
))
949 /* FIXME: If we eliminate the 'else' above and attempt
950 to show the fields for named types, we may get stuck
951 following a cycle of pointers to structs. The alleged
952 self-reference check in print_struct_decl will not detect
953 cycles involving more than one pointer or struct type. */
954 print_struct_decl (buffer
, node
, spc
, flags
);
963 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
965 /* In the case of a pointer, one may want to divide by the
966 size of the pointed-to type. Unfortunately, this not
967 straightforward. The C front-end maps expressions
972 in such a way that the two INTEGER_CST nodes for "5" have
973 different values but identical types. In the latter
974 case, the 5 is multiplied by sizeof (int) in c-common.c
975 (pointer_int_sum) to convert it to a byte address, and
976 yet the type of the node is left unchanged. Argh. What
977 is consistent though is that the number value corresponds
978 to bytes (UNITS) offset.
980 NB: Neither of the following divisors can be trivially
981 used to recover the original literal:
983 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
984 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
985 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
986 pp_string (buffer
, "B"); /* pseudo-unit */
988 else if (! host_integerp (node
, 0))
991 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (val
);
992 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (val
);
994 if (tree_int_cst_sgn (val
) < 0)
996 pp_character (buffer
, '-');
1000 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
1002 sprintf (pp_buffer (buffer
)->digit_buffer
,
1003 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
1004 (unsigned HOST_WIDE_INT
) high
, low
);
1005 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
1008 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1012 /* Code copied from print_node. */
1015 if (TREE_OVERFLOW (node
))
1016 pp_string (buffer
, " overflow");
1018 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1019 d
= TREE_REAL_CST (node
);
1020 if (REAL_VALUE_ISINF (d
))
1021 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
1022 else if (REAL_VALUE_ISNAN (d
))
1023 pp_string (buffer
, " Nan");
1027 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
1028 pp_string (buffer
, string
);
1033 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
1034 pp_string (buffer
, "0x");
1035 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
1036 output_formatted_integer (buffer
, "%02x", *p
++);
1045 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
1046 pp_string (buffer
, string
);
1051 pp_string (buffer
, "__complex__ (");
1052 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
1053 pp_string (buffer
, ", ");
1054 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
1055 pp_string (buffer
, ")");
1059 pp_string (buffer
, "\"");
1060 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
1061 pp_string (buffer
, "\"");
1067 pp_string (buffer
, "{ ");
1068 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
1070 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
, false);
1071 if (TREE_CHAIN (elt
))
1072 pp_string (buffer
, ", ");
1074 pp_string (buffer
, " }");
1080 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1082 if (TREE_CODE (node
) == METHOD_TYPE
)
1084 if (TYPE_METHOD_BASETYPE (node
))
1085 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
1088 pp_string (buffer
, "<null method basetype>");
1089 pp_string (buffer
, "::");
1091 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1092 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1093 else if (flags
& TDF_NOUID
)
1094 pp_printf (buffer
, "<Txxxx>");
1096 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1097 dump_function_declaration (buffer
, node
, spc
, flags
);
1102 dump_decl_name (buffer
, node
, flags
);
1106 if (DECL_NAME (node
))
1107 dump_decl_name (buffer
, node
, flags
);
1108 else if (LABEL_DECL_UID (node
) != -1)
1109 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1112 if (flags
& TDF_NOUID
)
1113 pp_string (buffer
, "<D.xxxx>");
1115 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1120 if (DECL_IS_BUILTIN (node
))
1122 /* Don't print the declaration of built-in types. */
1125 if (DECL_NAME (node
))
1126 dump_decl_name (buffer
, node
, flags
);
1127 else if (TYPE_NAME (TREE_TYPE (node
)) != node
)
1129 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1130 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1131 && TYPE_METHODS (TREE_TYPE (node
)))
1133 /* The type is a c++ class: all structures have at least
1135 pp_string (buffer
, "class ");
1136 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1141 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1142 ? "union" : "struct "));
1143 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1147 pp_string (buffer
, "<anon>");
1153 case DEBUG_EXPR_DECL
:
1154 case NAMESPACE_DECL
:
1155 dump_decl_name (buffer
, node
, flags
);
1159 pp_string (buffer
, "<retval>");
1163 op0
= TREE_OPERAND (node
, 0);
1166 && (TREE_CODE (op0
) == INDIRECT_REF
1167 || (TREE_CODE (op0
) == MEM_REF
1168 && TREE_CODE (TREE_OPERAND (op0
, 0)) != ADDR_EXPR
1169 && integer_zerop (TREE_OPERAND (op0
, 1))
1170 /* Dump the types of INTEGER_CSTs explicitly, for we
1171 can't infer them and MEM_ATTR caching will share
1172 MEM_REFs with differently-typed op0s. */
1173 && TREE_CODE (TREE_OPERAND (op0
, 0)) != INTEGER_CST
1174 /* Same pointer types, but ignoring POINTER_TYPE vs.
1176 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1177 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1178 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1179 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1180 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1181 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1182 /* Same value types ignoring qualifiers. */
1183 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0
))
1184 == TYPE_MAIN_VARIANT
1185 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))))))
1187 op0
= TREE_OPERAND (op0
, 0);
1190 if (op_prio (op0
) < op_prio (node
))
1191 pp_character (buffer
, '(');
1192 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1193 if (op_prio (op0
) < op_prio (node
))
1194 pp_character (buffer
, ')');
1195 pp_string (buffer
, str
);
1196 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1197 op0
= component_ref_field_offset (node
);
1198 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1200 pp_string (buffer
, "{off: ");
1201 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1202 pp_character (buffer
, '}');
1207 pp_string (buffer
, "BIT_FIELD_REF <");
1208 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1209 pp_string (buffer
, ", ");
1210 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1211 pp_string (buffer
, ", ");
1212 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1213 pp_string (buffer
, ">");
1217 case ARRAY_RANGE_REF
:
1218 op0
= TREE_OPERAND (node
, 0);
1219 if (op_prio (op0
) < op_prio (node
))
1220 pp_character (buffer
, '(');
1221 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1222 if (op_prio (op0
) < op_prio (node
))
1223 pp_character (buffer
, ')');
1224 pp_character (buffer
, '[');
1225 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1226 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1227 pp_string (buffer
, " ...");
1228 pp_character (buffer
, ']');
1230 op0
= array_ref_low_bound (node
);
1231 op1
= array_ref_element_size (node
);
1233 if (!integer_zerop (op0
)
1234 || TREE_OPERAND (node
, 2)
1235 || TREE_OPERAND (node
, 3))
1237 pp_string (buffer
, "{lb: ");
1238 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1239 pp_string (buffer
, " sz: ");
1240 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1241 pp_character (buffer
, '}');
1247 unsigned HOST_WIDE_INT ix
;
1249 bool is_struct_init
= FALSE
;
1250 pp_character (buffer
, '{');
1251 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1252 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1253 is_struct_init
= TRUE
;
1254 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1256 if (field
&& is_struct_init
)
1258 pp_character (buffer
, '.');
1259 dump_generic_node (buffer
, field
, spc
, flags
, false);
1260 pp_string (buffer
, "=");
1262 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1263 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1264 val
= TREE_OPERAND (val
, 0);
1265 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1266 dump_decl_name (buffer
, val
, flags
);
1268 dump_generic_node (buffer
, val
, spc
, flags
, false);
1269 if (ix
!= VEC_length (constructor_elt
, CONSTRUCTOR_ELTS (node
)) - 1)
1271 pp_character (buffer
, ',');
1275 pp_character (buffer
, '}');
1282 if (flags
& TDF_SLIM
)
1284 pp_string (buffer
, "<COMPOUND_EXPR>");
1288 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1289 spc
, flags
, !(flags
& TDF_SLIM
));
1290 if (flags
& TDF_SLIM
)
1291 newline_and_indent (buffer
, spc
);
1294 pp_character (buffer
, ',');
1298 for (tp
= &TREE_OPERAND (node
, 1);
1299 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1300 tp
= &TREE_OPERAND (*tp
, 1))
1302 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1303 spc
, flags
, !(flags
& TDF_SLIM
));
1304 if (flags
& TDF_SLIM
)
1305 newline_and_indent (buffer
, spc
);
1308 pp_character (buffer
, ',');
1313 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1317 case STATEMENT_LIST
:
1319 tree_stmt_iterator si
;
1322 if (flags
& TDF_SLIM
)
1324 pp_string (buffer
, "<STATEMENT_LIST>");
1328 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1331 newline_and_indent (buffer
, spc
);
1334 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1341 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1344 pp_character (buffer
, '=');
1345 if (TREE_CODE (node
) == MODIFY_EXPR
1346 && MOVE_NONTEMPORAL (node
))
1347 pp_string (buffer
, "{nt}");
1349 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1354 pp_string (buffer
, "TARGET_EXPR <");
1355 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1356 pp_character (buffer
, ',');
1358 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1359 pp_character (buffer
, '>');
1363 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1368 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1370 pp_string (buffer
, "if (");
1371 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1372 pp_character (buffer
, ')');
1373 /* The lowered cond_exprs should always be printed in full. */
1374 if (COND_EXPR_THEN (node
)
1375 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1376 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1377 && COND_EXPR_ELSE (node
)
1378 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1379 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1382 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1384 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1386 pp_string (buffer
, " else ");
1387 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1391 else if (!(flags
& TDF_SLIM
))
1393 /* Output COND_EXPR_THEN. */
1394 if (COND_EXPR_THEN (node
))
1396 newline_and_indent (buffer
, spc
+2);
1397 pp_character (buffer
, '{');
1398 newline_and_indent (buffer
, spc
+4);
1399 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1401 newline_and_indent (buffer
, spc
+2);
1402 pp_character (buffer
, '}');
1405 /* Output COND_EXPR_ELSE. */
1406 if (COND_EXPR_ELSE (node
)
1407 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1409 newline_and_indent (buffer
, spc
);
1410 pp_string (buffer
, "else");
1411 newline_and_indent (buffer
, spc
+2);
1412 pp_character (buffer
, '{');
1413 newline_and_indent (buffer
, spc
+4);
1414 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1416 newline_and_indent (buffer
, spc
+2);
1417 pp_character (buffer
, '}');
1424 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1426 pp_character (buffer
, '?');
1428 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1430 pp_character (buffer
, ':');
1432 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1437 pp_character (buffer
, '{');
1438 if (!(flags
& TDF_SLIM
))
1440 if (BIND_EXPR_VARS (node
))
1442 pp_newline (buffer
);
1444 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= DECL_CHAIN (op0
))
1446 print_declaration (buffer
, op0
, spc
+2, flags
);
1447 pp_newline (buffer
);
1451 newline_and_indent (buffer
, spc
+2);
1452 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1453 newline_and_indent (buffer
, spc
);
1454 pp_character (buffer
, '}');
1460 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1462 /* Print parameters. */
1464 pp_character (buffer
, '(');
1467 call_expr_arg_iterator iter
;
1468 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1470 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1471 if (more_call_expr_args_p (&iter
))
1473 pp_character (buffer
, ',');
1478 if (CALL_EXPR_VA_ARG_PACK (node
))
1480 if (call_expr_nargs (node
) > 0)
1482 pp_character (buffer
, ',');
1485 pp_string (buffer
, "__builtin_va_arg_pack ()");
1487 pp_character (buffer
, ')');
1489 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1492 pp_string (buffer
, " [static-chain: ");
1493 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1494 pp_character (buffer
, ']');
1497 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1498 pp_string (buffer
, " [return slot optimization]");
1499 if (CALL_EXPR_TAILCALL (node
))
1500 pp_string (buffer
, " [tail call]");
1503 case WITH_CLEANUP_EXPR
:
1507 case CLEANUP_POINT_EXPR
:
1508 pp_string (buffer
, "<<cleanup_point ");
1509 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1510 pp_string (buffer
, ">>");
1513 case PLACEHOLDER_EXPR
:
1514 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1515 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1516 pp_character (buffer
, '>');
1519 /* Binary arithmetic and logic expressions. */
1520 case WIDEN_SUM_EXPR
:
1521 case WIDEN_MULT_EXPR
:
1524 case POINTER_PLUS_EXPR
:
1526 case TRUNC_DIV_EXPR
:
1528 case FLOOR_DIV_EXPR
:
1529 case ROUND_DIV_EXPR
:
1530 case TRUNC_MOD_EXPR
:
1532 case FLOOR_MOD_EXPR
:
1533 case ROUND_MOD_EXPR
:
1535 case EXACT_DIV_EXPR
:
1540 case VEC_LSHIFT_EXPR
:
1541 case VEC_RSHIFT_EXPR
:
1545 case TRUTH_ANDIF_EXPR
:
1546 case TRUTH_ORIF_EXPR
:
1547 case TRUTH_AND_EXPR
:
1549 case TRUTH_XOR_EXPR
:
1563 case UNORDERED_EXPR
:
1565 const char *op
= op_symbol (node
);
1566 op0
= TREE_OPERAND (node
, 0);
1567 op1
= TREE_OPERAND (node
, 1);
1569 /* When the operands are expressions with less priority,
1570 keep semantics of the tree representation. */
1571 if (op_prio (op0
) <= op_prio (node
))
1573 pp_character (buffer
, '(');
1574 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1575 pp_character (buffer
, ')');
1578 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1581 pp_string (buffer
, op
);
1584 /* When the operands are expressions with less priority,
1585 keep semantics of the tree representation. */
1586 if (op_prio (op1
) <= op_prio (node
))
1588 pp_character (buffer
, '(');
1589 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1590 pp_character (buffer
, ')');
1593 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1597 /* Unary arithmetic and logic expressions. */
1600 case TRUTH_NOT_EXPR
:
1602 case PREDECREMENT_EXPR
:
1603 case PREINCREMENT_EXPR
:
1605 if (TREE_CODE (node
) == ADDR_EXPR
1606 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1607 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1608 ; /* Do not output '&' for strings and function pointers. */
1610 pp_string (buffer
, op_symbol (node
));
1612 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1614 pp_character (buffer
, '(');
1615 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1616 pp_character (buffer
, ')');
1619 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1622 case POSTDECREMENT_EXPR
:
1623 case POSTINCREMENT_EXPR
:
1624 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1626 pp_character (buffer
, '(');
1627 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1628 pp_character (buffer
, ')');
1631 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1632 pp_string (buffer
, op_symbol (node
));
1636 pp_string (buffer
, "MIN_EXPR <");
1637 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1638 pp_string (buffer
, ", ");
1639 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1640 pp_character (buffer
, '>');
1644 pp_string (buffer
, "MAX_EXPR <");
1645 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1646 pp_string (buffer
, ", ");
1647 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1648 pp_character (buffer
, '>');
1652 pp_string (buffer
, "ABS_EXPR <");
1653 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1654 pp_character (buffer
, '>');
1661 case ADDR_SPACE_CONVERT_EXPR
:
1662 case FIXED_CONVERT_EXPR
:
1663 case FIX_TRUNC_EXPR
:
1666 type
= TREE_TYPE (node
);
1667 op0
= TREE_OPERAND (node
, 0);
1668 if (type
!= TREE_TYPE (op0
))
1670 pp_character (buffer
, '(');
1671 dump_generic_node (buffer
, type
, spc
, flags
, false);
1672 pp_string (buffer
, ") ");
1674 if (op_prio (op0
) < op_prio (node
))
1675 pp_character (buffer
, '(');
1676 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1677 if (op_prio (op0
) < op_prio (node
))
1678 pp_character (buffer
, ')');
1681 case VIEW_CONVERT_EXPR
:
1682 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1683 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1684 pp_string (buffer
, ">(");
1685 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1686 pp_character (buffer
, ')');
1690 pp_string (buffer
, "((");
1691 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1692 pp_string (buffer
, "))");
1695 case NON_LVALUE_EXPR
:
1696 pp_string (buffer
, "NON_LVALUE_EXPR <");
1697 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1698 pp_character (buffer
, '>');
1702 pp_string (buffer
, "SAVE_EXPR <");
1703 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1704 pp_character (buffer
, '>');
1708 pp_string (buffer
, "COMPLEX_EXPR <");
1709 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1710 pp_string (buffer
, ", ");
1711 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1712 pp_string (buffer
, ">");
1716 pp_string (buffer
, "CONJ_EXPR <");
1717 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1718 pp_string (buffer
, ">");
1722 pp_string (buffer
, "REALPART_EXPR <");
1723 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1724 pp_string (buffer
, ">");
1728 pp_string (buffer
, "IMAGPART_EXPR <");
1729 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1730 pp_string (buffer
, ">");
1734 pp_string (buffer
, "VA_ARG_EXPR <");
1735 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1736 pp_string (buffer
, ">");
1739 case TRY_FINALLY_EXPR
:
1740 case TRY_CATCH_EXPR
:
1741 pp_string (buffer
, "try");
1742 newline_and_indent (buffer
, spc
+2);
1743 pp_string (buffer
, "{");
1744 newline_and_indent (buffer
, spc
+4);
1745 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1746 newline_and_indent (buffer
, spc
+2);
1747 pp_string (buffer
, "}");
1748 newline_and_indent (buffer
, spc
);
1750 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1751 newline_and_indent (buffer
, spc
+2);
1752 pp_string (buffer
, "{");
1753 newline_and_indent (buffer
, spc
+4);
1754 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1755 newline_and_indent (buffer
, spc
+2);
1756 pp_string (buffer
, "}");
1761 pp_string (buffer
, "catch (");
1762 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1763 pp_string (buffer
, ")");
1764 newline_and_indent (buffer
, spc
+2);
1765 pp_string (buffer
, "{");
1766 newline_and_indent (buffer
, spc
+4);
1767 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1768 newline_and_indent (buffer
, spc
+2);
1769 pp_string (buffer
, "}");
1773 case EH_FILTER_EXPR
:
1774 pp_string (buffer
, "<<<eh_filter (");
1775 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1776 pp_string (buffer
, ")>>>");
1777 newline_and_indent (buffer
, spc
+2);
1778 pp_string (buffer
, "{");
1779 newline_and_indent (buffer
, spc
+4);
1780 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1781 newline_and_indent (buffer
, spc
+2);
1782 pp_string (buffer
, "}");
1787 op0
= TREE_OPERAND (node
, 0);
1788 /* If this is for break or continue, don't bother printing it. */
1789 if (DECL_NAME (op0
))
1791 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1792 if (strcmp (name
, "break") == 0
1793 || strcmp (name
, "continue") == 0)
1796 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1797 pp_character (buffer
, ':');
1798 if (DECL_NONLOCAL (op0
))
1799 pp_string (buffer
, " [non-local]");
1803 pp_string (buffer
, "while (1)");
1804 if (!(flags
& TDF_SLIM
))
1806 newline_and_indent (buffer
, spc
+2);
1807 pp_character (buffer
, '{');
1808 newline_and_indent (buffer
, spc
+4);
1809 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1810 newline_and_indent (buffer
, spc
+2);
1811 pp_character (buffer
, '}');
1817 pp_string (buffer
, "// predicted ");
1818 if (PREDICT_EXPR_OUTCOME (node
))
1819 pp_string (buffer
, "likely by ");
1821 pp_string (buffer
, "unlikely by ");
1822 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
1823 pp_string (buffer
, " predictor.");
1827 pp_string (buffer
, "return");
1828 op0
= TREE_OPERAND (node
, 0);
1832 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1833 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
1836 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1841 pp_string (buffer
, "if (");
1842 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1843 pp_string (buffer
, ") break");
1847 pp_string (buffer
, "switch (");
1848 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1849 pp_character (buffer
, ')');
1850 if (!(flags
& TDF_SLIM
))
1852 newline_and_indent (buffer
, spc
+2);
1853 pp_character (buffer
, '{');
1854 if (SWITCH_BODY (node
))
1856 newline_and_indent (buffer
, spc
+4);
1857 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1862 tree vec
= SWITCH_LABELS (node
);
1863 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1864 for (i
= 0; i
< n
; ++i
)
1866 tree elt
= TREE_VEC_ELT (vec
, i
);
1867 newline_and_indent (buffer
, spc
+4);
1870 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1871 pp_string (buffer
, " goto ");
1872 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1874 pp_semicolon (buffer
);
1877 pp_string (buffer
, "case ???: goto ???;");
1880 newline_and_indent (buffer
, spc
+2);
1881 pp_character (buffer
, '}');
1887 op0
= GOTO_DESTINATION (node
);
1888 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1890 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1891 if (strcmp (name
, "break") == 0
1892 || strcmp (name
, "continue") == 0)
1894 pp_string (buffer
, name
);
1898 pp_string (buffer
, "goto ");
1899 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1903 pp_string (buffer
, "__asm__");
1904 if (ASM_VOLATILE_P (node
))
1905 pp_string (buffer
, " __volatile__");
1906 pp_character (buffer
, '(');
1907 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1908 pp_character (buffer
, ':');
1909 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1910 pp_character (buffer
, ':');
1911 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1912 if (ASM_CLOBBERS (node
))
1914 pp_character (buffer
, ':');
1915 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1917 pp_string (buffer
, ")");
1920 case CASE_LABEL_EXPR
:
1921 if (CASE_LOW (node
) && CASE_HIGH (node
))
1923 pp_string (buffer
, "case ");
1924 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1925 pp_string (buffer
, " ... ");
1926 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1928 else if (CASE_LOW (node
))
1930 pp_string (buffer
, "case ");
1931 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1934 pp_string (buffer
, "default");
1935 pp_character (buffer
, ':');
1939 pp_string (buffer
, "OBJ_TYPE_REF(");
1940 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1941 pp_character (buffer
, ';');
1942 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1943 pp_character (buffer
, '-');
1944 pp_character (buffer
, '>');
1945 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
1946 pp_character (buffer
, ')');
1950 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
1951 pp_string (buffer
, "_");
1952 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1953 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
1954 pp_string (buffer
, "(ab)");
1955 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
1956 pp_string (buffer
, "(D)");
1959 case WITH_SIZE_EXPR
:
1960 pp_string (buffer
, "WITH_SIZE_EXPR <");
1961 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1962 pp_string (buffer
, ", ");
1963 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1964 pp_string (buffer
, ">");
1968 pp_string (buffer
, "ASSERT_EXPR <");
1969 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
1970 pp_string (buffer
, ", ");
1971 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
1972 pp_string (buffer
, ">");
1976 pp_string (buffer
, "scev_known");
1979 case SCEV_NOT_KNOWN
:
1980 pp_string (buffer
, "scev_not_known");
1983 case POLYNOMIAL_CHREC
:
1984 pp_string (buffer
, "{");
1985 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
1986 pp_string (buffer
, ", +, ");
1987 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
1988 pp_string (buffer
, "}_");
1989 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
1993 case REALIGN_LOAD_EXPR
:
1994 pp_string (buffer
, "REALIGN_LOAD <");
1995 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1996 pp_string (buffer
, ", ");
1997 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1998 pp_string (buffer
, ", ");
1999 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2000 pp_string (buffer
, ">");
2004 pp_string (buffer
, " VEC_COND_EXPR < ");
2005 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2006 pp_string (buffer
, " , ");
2007 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2008 pp_string (buffer
, " , ");
2009 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2010 pp_string (buffer
, " > ");
2014 pp_string (buffer
, " DOT_PROD_EXPR < ");
2015 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2016 pp_string (buffer
, ", ");
2017 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2018 pp_string (buffer
, ", ");
2019 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2020 pp_string (buffer
, " > ");
2023 case WIDEN_MULT_PLUS_EXPR
:
2024 pp_string (buffer
, " WIDEN_MULT_PLUS_EXPR < ");
2025 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2026 pp_string (buffer
, ", ");
2027 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2028 pp_string (buffer
, ", ");
2029 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2030 pp_string (buffer
, " > ");
2033 case WIDEN_MULT_MINUS_EXPR
:
2034 pp_string (buffer
, " WIDEN_MULT_MINUS_EXPR < ");
2035 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2036 pp_string (buffer
, ", ");
2037 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2038 pp_string (buffer
, ", ");
2039 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2040 pp_string (buffer
, " > ");
2044 pp_string (buffer
, " FMA_EXPR < ");
2045 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2046 pp_string (buffer
, ", ");
2047 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2048 pp_string (buffer
, ", ");
2049 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2050 pp_string (buffer
, " > ");
2054 pp_string (buffer
, "#pragma omp parallel");
2055 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
2058 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
2060 newline_and_indent (buffer
, spc
+ 2);
2061 pp_character (buffer
, '{');
2062 newline_and_indent (buffer
, spc
+ 4);
2063 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
2064 newline_and_indent (buffer
, spc
+ 2);
2065 pp_character (buffer
, '}');
2071 pp_string (buffer
, "#pragma omp task");
2072 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
2076 pp_string (buffer
, "#pragma omp for");
2077 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
2079 if (!(flags
& TDF_SLIM
))
2083 if (OMP_FOR_PRE_BODY (node
))
2085 newline_and_indent (buffer
, spc
+ 2);
2086 pp_character (buffer
, '{');
2088 newline_and_indent (buffer
, spc
);
2089 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
2093 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
2096 newline_and_indent (buffer
, spc
);
2097 pp_string (buffer
, "for (");
2098 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
2100 pp_string (buffer
, "; ");
2101 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
2103 pp_string (buffer
, "; ");
2104 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
2106 pp_string (buffer
, ")");
2108 if (OMP_FOR_BODY (node
))
2110 newline_and_indent (buffer
, spc
+ 2);
2111 pp_character (buffer
, '{');
2112 newline_and_indent (buffer
, spc
+ 4);
2113 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
2115 newline_and_indent (buffer
, spc
+ 2);
2116 pp_character (buffer
, '}');
2118 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
2119 if (OMP_FOR_PRE_BODY (node
))
2122 newline_and_indent (buffer
, spc
+ 2);
2123 pp_character (buffer
, '}');
2130 pp_string (buffer
, "#pragma omp sections");
2131 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2135 pp_string (buffer
, "#pragma omp section");
2139 pp_string (buffer
, "#pragma omp master");
2143 pp_string (buffer
, "#pragma omp ordered");
2147 pp_string (buffer
, "#pragma omp critical");
2148 if (OMP_CRITICAL_NAME (node
))
2151 pp_character (buffer
, '(');
2152 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2154 pp_character (buffer
, ')');
2159 pp_string (buffer
, "#pragma omp atomic");
2160 newline_and_indent (buffer
, spc
+ 2);
2161 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2163 pp_character (buffer
, '=');
2165 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2169 pp_string (buffer
, "#pragma omp single");
2170 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2174 dump_omp_clause (buffer
, node
, spc
, flags
);
2178 case REDUC_MAX_EXPR
:
2179 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2180 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2181 pp_string (buffer
, " > ");
2184 case REDUC_MIN_EXPR
:
2185 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2186 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2187 pp_string (buffer
, " > ");
2190 case REDUC_PLUS_EXPR
:
2191 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2192 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2193 pp_string (buffer
, " > ");
2196 case VEC_WIDEN_MULT_HI_EXPR
:
2197 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
2198 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2199 pp_string (buffer
, ", ");
2200 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2201 pp_string (buffer
, " > ");
2204 case VEC_WIDEN_MULT_LO_EXPR
:
2205 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
2206 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2207 pp_string (buffer
, ", ");
2208 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2209 pp_string (buffer
, " > ");
2212 case VEC_UNPACK_HI_EXPR
:
2213 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2214 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2215 pp_string (buffer
, " > ");
2218 case VEC_UNPACK_LO_EXPR
:
2219 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2220 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2221 pp_string (buffer
, " > ");
2224 case VEC_UNPACK_FLOAT_HI_EXPR
:
2225 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2226 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2227 pp_string (buffer
, " > ");
2230 case VEC_UNPACK_FLOAT_LO_EXPR
:
2231 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2232 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2233 pp_string (buffer
, " > ");
2236 case VEC_PACK_TRUNC_EXPR
:
2237 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2238 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2239 pp_string (buffer
, ", ");
2240 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2241 pp_string (buffer
, " > ");
2244 case VEC_PACK_SAT_EXPR
:
2245 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2246 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2247 pp_string (buffer
, ", ");
2248 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2249 pp_string (buffer
, " > ");
2252 case VEC_PACK_FIX_TRUNC_EXPR
:
2253 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2254 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2255 pp_string (buffer
, ", ");
2256 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2257 pp_string (buffer
, " > ");
2261 dump_block_node (buffer
, node
, spc
, flags
);
2264 case VEC_EXTRACT_EVEN_EXPR
:
2265 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2266 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2267 pp_string (buffer
, ", ");
2268 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2269 pp_string (buffer
, " > ");
2272 case VEC_EXTRACT_ODD_EXPR
:
2273 pp_string (buffer
, " VEC_EXTRACT_ODD_EXPR < ");
2274 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2275 pp_string (buffer
, ", ");
2276 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2277 pp_string (buffer
, " > ");
2280 case VEC_INTERLEAVE_HIGH_EXPR
:
2281 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_EXPR < ");
2282 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2283 pp_string (buffer
, ", ");
2284 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2285 pp_string (buffer
, " > ");
2288 case VEC_INTERLEAVE_LOW_EXPR
:
2289 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2290 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2291 pp_string (buffer
, ", ");
2292 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2293 pp_string (buffer
, " > ");
2300 if (is_stmt
&& is_expr
)
2301 pp_semicolon (buffer
);
2303 /* If we're building a diagnostic, the formatted text will be written
2304 into BUFFER's stream by the caller; otherwise, write it now. */
2305 if (!(flags
& TDF_DIAGNOSTIC
))
2306 pp_write_text_to_stream (buffer
);
2311 /* Print the declaration of a variable. */
2314 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2318 if (TREE_CODE (t
) == TYPE_DECL
)
2319 pp_string (buffer
, "typedef ");
2321 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2322 pp_string (buffer
, "register ");
2324 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2325 pp_string (buffer
, "extern ");
2326 else if (TREE_STATIC (t
))
2327 pp_string (buffer
, "static ");
2329 /* Print the type and name. */
2330 if (TREE_TYPE (t
) && TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2334 /* Print array's type. */
2335 tmp
= TREE_TYPE (t
);
2336 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2337 tmp
= TREE_TYPE (tmp
);
2338 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2340 /* Print variable's name. */
2342 dump_generic_node (buffer
, t
, spc
, flags
, false);
2344 /* Print the dimensions. */
2345 tmp
= TREE_TYPE (t
);
2346 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2348 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2349 tmp
= TREE_TYPE (tmp
);
2352 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2354 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2356 dump_decl_name (buffer
, t
, flags
);
2357 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2361 /* Print type declaration. */
2362 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2364 /* Print variable's name. */
2366 dump_generic_node (buffer
, t
, spc
, flags
, false);
2369 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2371 pp_string (buffer
, " __asm__ ");
2372 pp_character (buffer
, '(');
2373 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2374 pp_character (buffer
, ')');
2377 /* The initial value of a function serves to determine whether the function
2378 is declared or defined. So the following does not apply to function
2380 if (TREE_CODE (t
) != FUNCTION_DECL
)
2382 /* Print the initial value. */
2383 if (DECL_INITIAL (t
))
2386 pp_character (buffer
, '=');
2388 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2392 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2394 pp_string (buffer
, " [value-expr: ");
2395 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2396 pp_character (buffer
, ']');
2399 pp_character (buffer
, ';');
2403 /* Prints a structure: name, fields, and methods.
2404 FIXME: Still incomplete. */
2407 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2409 /* Print the name of the structure. */
2410 if (TYPE_NAME (node
))
2413 if (TREE_CODE (node
) == RECORD_TYPE
)
2414 pp_string (buffer
, "struct ");
2415 else if ((TREE_CODE (node
) == UNION_TYPE
2416 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2417 pp_string (buffer
, "union ");
2419 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2422 /* Print the contents of the structure. */
2423 pp_newline (buffer
);
2425 pp_character (buffer
, '{');
2426 pp_newline (buffer
);
2428 /* Print the fields of the structure. */
2431 tmp
= TYPE_FIELDS (node
);
2434 /* Avoid to print recursively the structure. */
2435 /* FIXME : Not implemented correctly...,
2436 what about the case when we have a cycle in the contain graph? ...
2437 Maybe this could be solved by looking at the scope in which the
2438 structure was declared. */
2439 if (TREE_TYPE (tmp
) != node
2440 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2441 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2443 print_declaration (buffer
, tmp
, spc
+2, flags
);
2444 pp_newline (buffer
);
2446 tmp
= DECL_CHAIN (tmp
);
2450 pp_character (buffer
, '}');
2453 /* Return the priority of the operator CODE.
2455 From lowest to highest precedence with either left-to-right (L-R)
2456 or right-to-left (R-L) associativity]:
2459 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2471 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2472 15 [L-R] fn() [] -> .
2474 unary +, - and * have higher precedence than the corresponding binary
2478 op_code_prio (enum tree_code code
)
2495 case TRUTH_ORIF_EXPR
:
2498 case TRUTH_AND_EXPR
:
2499 case TRUTH_ANDIF_EXPR
:
2506 case TRUTH_XOR_EXPR
:
2523 case UNORDERED_EXPR
:
2536 case WIDEN_SUM_EXPR
:
2538 case POINTER_PLUS_EXPR
:
2542 case VEC_WIDEN_MULT_HI_EXPR
:
2543 case VEC_WIDEN_MULT_LO_EXPR
:
2544 case WIDEN_MULT_EXPR
:
2546 case WIDEN_MULT_PLUS_EXPR
:
2547 case WIDEN_MULT_MINUS_EXPR
:
2549 case TRUNC_DIV_EXPR
:
2551 case FLOOR_DIV_EXPR
:
2552 case ROUND_DIV_EXPR
:
2554 case EXACT_DIV_EXPR
:
2555 case TRUNC_MOD_EXPR
:
2557 case FLOOR_MOD_EXPR
:
2558 case ROUND_MOD_EXPR
:
2562 case TRUTH_NOT_EXPR
:
2564 case POSTINCREMENT_EXPR
:
2565 case POSTDECREMENT_EXPR
:
2566 case PREINCREMENT_EXPR
:
2567 case PREDECREMENT_EXPR
:
2573 case FIX_TRUNC_EXPR
:
2579 case ARRAY_RANGE_REF
:
2583 /* Special expressions. */
2589 case REDUC_MAX_EXPR
:
2590 case REDUC_MIN_EXPR
:
2591 case REDUC_PLUS_EXPR
:
2592 case VEC_LSHIFT_EXPR
:
2593 case VEC_RSHIFT_EXPR
:
2594 case VEC_UNPACK_HI_EXPR
:
2595 case VEC_UNPACK_LO_EXPR
:
2596 case VEC_UNPACK_FLOAT_HI_EXPR
:
2597 case VEC_UNPACK_FLOAT_LO_EXPR
:
2598 case VEC_PACK_TRUNC_EXPR
:
2599 case VEC_PACK_SAT_EXPR
:
2603 /* Return an arbitrarily high precedence to avoid surrounding single
2604 VAR_DECLs in ()s. */
2609 /* Return the priority of the operator OP. */
2612 op_prio (const_tree op
)
2614 enum tree_code code
;
2619 code
= TREE_CODE (op
);
2620 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2621 return op_prio (TREE_OPERAND (op
, 0));
2623 return op_code_prio (code
);
2626 /* Return the symbol associated with operator CODE. */
2629 op_symbol_code (enum tree_code code
)
2637 case TRUTH_ORIF_EXPR
:
2640 case TRUTH_AND_EXPR
:
2641 case TRUTH_ANDIF_EXPR
:
2647 case TRUTH_XOR_EXPR
:
2657 case UNORDERED_EXPR
:
2703 case VEC_LSHIFT_EXPR
:
2706 case VEC_RSHIFT_EXPR
:
2709 case POINTER_PLUS_EXPR
:
2715 case REDUC_PLUS_EXPR
:
2718 case WIDEN_SUM_EXPR
:
2721 case WIDEN_MULT_EXPR
:
2731 case TRUTH_NOT_EXPR
:
2738 case TRUNC_DIV_EXPR
:
2745 case FLOOR_DIV_EXPR
:
2748 case ROUND_DIV_EXPR
:
2751 case EXACT_DIV_EXPR
:
2754 case TRUNC_MOD_EXPR
:
2760 case FLOOR_MOD_EXPR
:
2763 case ROUND_MOD_EXPR
:
2766 case PREDECREMENT_EXPR
:
2769 case PREINCREMENT_EXPR
:
2772 case POSTDECREMENT_EXPR
:
2775 case POSTINCREMENT_EXPR
:
2785 return "<<< ??? >>>";
2789 /* Return the symbol associated with operator OP. */
2792 op_symbol (const_tree op
)
2794 return op_symbol_code (TREE_CODE (op
));
2797 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2798 the gimple_call_fn of a GIMPLE_CALL. */
2801 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
2805 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2806 op0
= TREE_OPERAND (op0
, 0);
2809 switch (TREE_CODE (op0
))
2814 dump_function_name (buffer
, op0
, flags
);
2820 op0
= TREE_OPERAND (op0
, 0);
2824 pp_string (buffer
, "(");
2825 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
2826 pp_string (buffer
, ") ? ");
2827 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
2828 pp_string (buffer
, " : ");
2829 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
2833 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2834 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
2836 dump_generic_node (buffer
, op0
, 0, flags
, false);
2840 if (integer_zerop (TREE_OPERAND (op0
, 1)))
2842 op0
= TREE_OPERAND (op0
, 0);
2849 dump_generic_node (buffer
, op0
, 0, flags
, false);
2857 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2860 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2870 pp_string (buffer
, "\\b");
2874 pp_string (buffer
, "\\f");
2878 pp_string (buffer
, "\\n");
2882 pp_string (buffer
, "\\r");
2886 pp_string (buffer
, "\\t");
2890 pp_string (buffer
, "\\v");
2894 pp_string (buffer
, "\\\\");
2898 pp_string (buffer
, "\\\"");
2902 pp_string (buffer
, "\\'");
2905 /* No need to handle \0; the loop terminates on \0. */
2908 pp_string (buffer
, "\\1");
2912 pp_string (buffer
, "\\2");
2916 pp_string (buffer
, "\\3");
2920 pp_string (buffer
, "\\4");
2924 pp_string (buffer
, "\\5");
2928 pp_string (buffer
, "\\6");
2932 pp_string (buffer
, "\\7");
2936 pp_character (buffer
, str
[0]);
2944 maybe_init_pretty_print (FILE *file
)
2948 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
2949 pp_needs_newline (&buffer
) = true;
2950 pp_translate_identifiers (&buffer
) = false;
2954 buffer
.buffer
->stream
= file
;
2958 newline_and_indent (pretty_printer
*buffer
, int spc
)
2960 pp_newline (buffer
);
2964 /* Handle a %K format for TEXT. Separate from default_tree_printer so
2965 it can also be used in front ends.
2966 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
2970 percent_K_format (text_info
*text
)
2972 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
2973 gcc_assert (text
->locus
!= NULL
);
2974 *text
->locus
= EXPR_LOCATION (t
);
2975 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
2976 block
= TREE_BLOCK (t
);
2977 *pp_ti_abstract_origin (text
) = NULL
;
2979 && TREE_CODE (block
) == BLOCK
2980 && BLOCK_ABSTRACT_ORIGIN (block
))
2982 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
2984 while (TREE_CODE (ao
) == BLOCK
2985 && BLOCK_ABSTRACT_ORIGIN (ao
)
2986 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
2987 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
2989 if (TREE_CODE (ao
) == FUNCTION_DECL
)
2991 *pp_ti_abstract_origin (text
) = block
;
2994 block
= BLOCK_SUPERCONTEXT (block
);
2998 /* Print the identifier ID to PRETTY-PRINTER. */
3001 pp_base_tree_identifier (pretty_printer
*pp
, tree id
)
3003 if (pp_translate_identifiers (pp
))
3005 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
3006 pp_append_text (pp
, text
, text
+ strlen (text
));
3009 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
3010 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));