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. */
236 arg
= TYPE_ARG_TYPES (node
);
237 while (arg
&& arg
!= void_list_node
&& arg
!= error_mark_node
)
241 pp_character (buffer
, ',');
245 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
246 arg
= TREE_CHAIN (arg
);
249 /* Drop the trailing void_type_node if we had any previous argument. */
250 if (arg
== void_list_node
&& !wrote_arg
)
251 pp_string (buffer
, "void");
252 /* Properly dump vararg function types. */
253 else if (!arg
&& wrote_arg
)
254 pp_string (buffer
, ", ...");
255 /* Avoid printing any arg for unprototyped functions. */
257 pp_character (buffer
, ')');
260 /* Dump the domain associated with an array. */
263 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
265 pp_character (buffer
, '[');
268 tree min
= TYPE_MIN_VALUE (domain
);
269 tree max
= TYPE_MAX_VALUE (domain
);
272 && integer_zerop (min
)
273 && host_integerp (max
, 0))
274 pp_wide_integer (buffer
, TREE_INT_CST_LOW (max
) + 1);
278 dump_generic_node (buffer
, min
, spc
, flags
, false);
279 pp_character (buffer
, ':');
281 dump_generic_node (buffer
, max
, spc
, flags
, false);
285 pp_string (buffer
, "<unknown>");
286 pp_character (buffer
, ']');
290 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
291 dump_generic_node. */
294 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
298 switch (OMP_CLAUSE_CODE (clause
))
300 case OMP_CLAUSE_PRIVATE
:
303 case OMP_CLAUSE_SHARED
:
306 case OMP_CLAUSE_FIRSTPRIVATE
:
307 name
= "firstprivate";
309 case OMP_CLAUSE_LASTPRIVATE
:
310 name
= "lastprivate";
312 case OMP_CLAUSE_COPYIN
:
315 case OMP_CLAUSE_COPYPRIVATE
:
316 name
= "copyprivate";
319 pp_string (buffer
, name
);
320 pp_character (buffer
, '(');
321 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
323 pp_character (buffer
, ')');
326 case OMP_CLAUSE_REDUCTION
:
327 pp_string (buffer
, "reduction(");
328 pp_string (buffer
, op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
329 pp_character (buffer
, ':');
330 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
332 pp_character (buffer
, ')');
336 pp_string (buffer
, "if(");
337 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
339 pp_character (buffer
, ')');
342 case OMP_CLAUSE_NUM_THREADS
:
343 pp_string (buffer
, "num_threads(");
344 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
346 pp_character (buffer
, ')');
349 case OMP_CLAUSE_NOWAIT
:
350 pp_string (buffer
, "nowait");
352 case OMP_CLAUSE_ORDERED
:
353 pp_string (buffer
, "ordered");
356 case OMP_CLAUSE_DEFAULT
:
357 pp_string (buffer
, "default(");
358 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
360 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
362 case OMP_CLAUSE_DEFAULT_SHARED
:
363 pp_string (buffer
, "shared");
365 case OMP_CLAUSE_DEFAULT_NONE
:
366 pp_string (buffer
, "none");
368 case OMP_CLAUSE_DEFAULT_PRIVATE
:
369 pp_string (buffer
, "private");
371 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE
:
372 pp_string (buffer
, "firstprivate");
377 pp_character (buffer
, ')');
380 case OMP_CLAUSE_SCHEDULE
:
381 pp_string (buffer
, "schedule(");
382 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
384 case OMP_CLAUSE_SCHEDULE_STATIC
:
385 pp_string (buffer
, "static");
387 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
388 pp_string (buffer
, "dynamic");
390 case OMP_CLAUSE_SCHEDULE_GUIDED
:
391 pp_string (buffer
, "guided");
393 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
394 pp_string (buffer
, "runtime");
396 case OMP_CLAUSE_SCHEDULE_AUTO
:
397 pp_string (buffer
, "auto");
402 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
404 pp_character (buffer
, ',');
405 dump_generic_node (buffer
,
406 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
409 pp_character (buffer
, ')');
412 case OMP_CLAUSE_UNTIED
:
413 pp_string (buffer
, "untied");
416 case OMP_CLAUSE_COLLAPSE
:
417 pp_string (buffer
, "collapse(");
418 dump_generic_node (buffer
,
419 OMP_CLAUSE_COLLAPSE_EXPR (clause
),
421 pp_character (buffer
, ')');
425 /* Should never happen. */
426 dump_generic_node (buffer
, clause
, spc
, flags
, false);
432 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
433 dump_generic_node. */
436 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
444 dump_omp_clause (buffer
, clause
, spc
, flags
);
445 clause
= OMP_CLAUSE_CHAIN (clause
);
453 /* Dump location LOC to BUFFER. */
456 dump_location (pretty_printer
*buffer
, location_t loc
)
458 expanded_location xloc
= expand_location (loc
);
460 pp_character (buffer
, '[');
463 pp_string (buffer
, xloc
.file
);
464 pp_string (buffer
, " : ");
466 pp_decimal_int (buffer
, xloc
.line
);
467 pp_string (buffer
, "] ");
471 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
472 dump_generic_node. */
475 dump_block_node (pretty_printer
*buffer
, tree block
, int spc
, int flags
)
479 pp_printf (buffer
, "BLOCK #%d ", BLOCK_NUMBER (block
));
481 if (flags
& TDF_ADDRESS
)
482 pp_printf (buffer
, "[%p] ", (void *) block
);
484 if (BLOCK_ABSTRACT (block
))
485 pp_string (buffer
, "[abstract] ");
487 if (TREE_ASM_WRITTEN (block
))
488 pp_string (buffer
, "[written] ");
490 if (flags
& TDF_SLIM
)
493 if (BLOCK_SOURCE_LOCATION (block
))
494 dump_location (buffer
, BLOCK_SOURCE_LOCATION (block
));
496 newline_and_indent (buffer
, spc
+ 2);
498 if (BLOCK_SUPERCONTEXT (block
))
500 pp_string (buffer
, "SUPERCONTEXT: ");
501 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (block
), 0,
502 flags
| TDF_SLIM
, false);
503 newline_and_indent (buffer
, spc
+ 2);
506 if (BLOCK_SUBBLOCKS (block
))
508 pp_string (buffer
, "SUBBLOCKS: ");
509 for (t
= BLOCK_SUBBLOCKS (block
); t
; t
= BLOCK_CHAIN (t
))
511 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
512 pp_string (buffer
, " ");
514 newline_and_indent (buffer
, spc
+ 2);
517 if (BLOCK_CHAIN (block
))
519 pp_string (buffer
, "SIBLINGS: ");
520 for (t
= BLOCK_CHAIN (block
); t
; t
= BLOCK_CHAIN (t
))
522 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
523 pp_string (buffer
, " ");
525 newline_and_indent (buffer
, spc
+ 2);
528 if (BLOCK_VARS (block
))
530 pp_string (buffer
, "VARS: ");
531 for (t
= BLOCK_VARS (block
); t
; t
= TREE_CHAIN (t
))
533 dump_generic_node (buffer
, t
, 0, flags
, false);
534 pp_string (buffer
, " ");
536 newline_and_indent (buffer
, spc
+ 2);
539 if (VEC_length (tree
, BLOCK_NONLOCALIZED_VARS (block
)) > 0)
542 VEC(tree
,gc
) *nlv
= BLOCK_NONLOCALIZED_VARS (block
);
544 pp_string (buffer
, "NONLOCALIZED_VARS: ");
545 FOR_EACH_VEC_ELT (tree
, nlv
, i
, t
)
547 dump_generic_node (buffer
, t
, 0, flags
, false);
548 pp_string (buffer
, " ");
550 newline_and_indent (buffer
, spc
+ 2);
553 if (BLOCK_ABSTRACT_ORIGIN (block
))
555 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
556 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (block
), 0,
557 flags
| TDF_SLIM
, false);
558 newline_and_indent (buffer
, spc
+ 2);
561 if (BLOCK_FRAGMENT_ORIGIN (block
))
563 pp_string (buffer
, "FRAGMENT_ORIGIN: ");
564 dump_generic_node (buffer
, BLOCK_FRAGMENT_ORIGIN (block
), 0,
565 flags
| TDF_SLIM
, false);
566 newline_and_indent (buffer
, spc
+ 2);
569 if (BLOCK_FRAGMENT_CHAIN (block
))
571 pp_string (buffer
, "FRAGMENT_CHAIN: ");
572 for (t
= BLOCK_FRAGMENT_CHAIN (block
); t
; t
= BLOCK_FRAGMENT_CHAIN (t
))
574 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
575 pp_string (buffer
, " ");
577 newline_and_indent (buffer
, spc
+ 2);
582 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
583 indent. FLAGS specifies details to show in the dump (see TDF_* in
584 tree-pass.h). If IS_STMT is true, the object printed is considered
585 to be a statement and it is terminated by ';' if appropriate. */
588 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
596 if (node
== NULL_TREE
)
599 is_expr
= EXPR_P (node
);
601 if (is_stmt
&& (flags
& TDF_STMTADDR
))
602 pp_printf (buffer
, "<&%p> ", (void *)node
);
604 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
605 dump_location (buffer
, EXPR_LOCATION (node
));
607 switch (TREE_CODE (node
))
610 pp_string (buffer
, "<<< error >>>");
613 case IDENTIFIER_NODE
:
614 pp_tree_identifier (buffer
, node
);
618 while (node
&& node
!= error_mark_node
)
620 if (TREE_PURPOSE (node
))
622 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
625 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
626 node
= TREE_CHAIN (node
);
627 if (node
&& TREE_CODE (node
) == TREE_LIST
)
629 pp_character (buffer
, ',');
636 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
642 if (TREE_VEC_LENGTH (node
) > 0)
644 size_t len
= TREE_VEC_LENGTH (node
);
645 for (i
= 0; i
< len
- 1; i
++)
647 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
649 pp_character (buffer
, ',');
652 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
661 case FIXED_POINT_TYPE
:
667 unsigned int quals
= TYPE_QUALS (node
);
668 enum tree_code_class tclass
;
670 if (quals
& TYPE_QUAL_CONST
)
671 pp_string (buffer
, "const ");
672 else if (quals
& TYPE_QUAL_VOLATILE
)
673 pp_string (buffer
, "volatile ");
674 else if (quals
& TYPE_QUAL_RESTRICT
)
675 pp_string (buffer
, "restrict ");
677 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
679 pp_string (buffer
, "<address-space-");
680 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
681 pp_string (buffer
, "> ");
684 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
686 if (tclass
== tcc_declaration
)
688 if (DECL_NAME (node
))
689 dump_decl_name (buffer
, node
, flags
);
691 pp_string (buffer
, "<unnamed type decl>");
693 else if (tclass
== tcc_type
)
695 if (TYPE_NAME (node
))
697 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
698 pp_tree_identifier (buffer
, TYPE_NAME (node
));
699 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
700 && DECL_NAME (TYPE_NAME (node
)))
701 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
703 pp_string (buffer
, "<unnamed type>");
705 else if (TREE_CODE (node
) == VECTOR_TYPE
)
707 pp_string (buffer
, "vector");
708 pp_character (buffer
, '(');
709 pp_wide_integer (buffer
, TYPE_VECTOR_SUBPARTS (node
));
710 pp_string (buffer
, ") ");
711 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
713 else if (TREE_CODE (node
) == INTEGER_TYPE
)
715 pp_string (buffer
, (TYPE_UNSIGNED (node
)
716 ? "<unnamed-unsigned:"
717 : "<unnamed-signed:"));
718 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
719 pp_string (buffer
, ">");
721 else if (TREE_CODE (node
) == COMPLEX_TYPE
)
723 pp_string (buffer
, "__complex__ ");
724 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
726 else if (TREE_CODE (node
) == REAL_TYPE
)
728 pp_string (buffer
, "<float:");
729 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
730 pp_string (buffer
, ">");
732 else if (TREE_CODE (node
) == FIXED_POINT_TYPE
)
734 pp_string (buffer
, "<fixed-point-");
735 pp_string (buffer
, TYPE_SATURATING (node
) ? "sat:" : "nonsat:");
736 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
737 pp_string (buffer
, ">");
739 else if (TREE_CODE (node
) == VOID_TYPE
)
740 pp_string (buffer
, "void");
742 pp_string (buffer
, "<unnamed type>");
749 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
751 if (TREE_TYPE (node
) == NULL
)
753 pp_string (buffer
, str
);
754 pp_string (buffer
, "<null type>");
756 else if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
758 tree fnode
= TREE_TYPE (node
);
760 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
762 pp_character (buffer
, '(');
763 pp_string (buffer
, str
);
764 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
765 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
766 else if (flags
& TDF_NOUID
)
767 pp_printf (buffer
, "<Txxxx>");
769 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
771 pp_character (buffer
, ')');
772 dump_function_declaration (buffer
, fnode
, spc
, flags
);
776 unsigned int quals
= TYPE_QUALS (node
);
778 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
780 pp_string (buffer
, str
);
782 if (quals
& TYPE_QUAL_CONST
)
783 pp_string (buffer
, " const");
784 if (quals
& TYPE_QUAL_VOLATILE
)
785 pp_string (buffer
, " volatile");
786 if (quals
& TYPE_QUAL_RESTRICT
)
787 pp_string (buffer
, " restrict");
789 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
791 pp_string (buffer
, " <address-space-");
792 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
793 pp_string (buffer
, ">");
796 if (TYPE_REF_CAN_ALIAS_ALL (node
))
797 pp_string (buffer
, " {ref-all}");
807 if (integer_zerop (TREE_OPERAND (node
, 1))
808 /* Dump the types of INTEGER_CSTs explicitly, for we can't
809 infer them and MEM_ATTR caching will share MEM_REFs
810 with differently-typed op0s. */
811 && TREE_CODE (TREE_OPERAND (node
, 0)) != INTEGER_CST
812 /* Same pointer types, but ignoring POINTER_TYPE vs.
814 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 0)))
815 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))
816 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 0)))
817 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 1))))
818 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 0)))
819 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 1))))
820 /* Same value types ignoring qualifiers. */
821 && (TYPE_MAIN_VARIANT (TREE_TYPE (node
))
823 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))))
825 if (TREE_CODE (TREE_OPERAND (node
, 0)) != ADDR_EXPR
)
827 pp_string (buffer
, "*");
828 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
832 dump_generic_node (buffer
,
833 TREE_OPERAND (TREE_OPERAND (node
, 0), 0),
840 pp_string (buffer
, "MEM[");
841 pp_string (buffer
, "(");
842 ptype
= TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node
, 1)));
843 dump_generic_node (buffer
, ptype
,
844 spc
, flags
| TDF_SLIM
, false);
845 pp_string (buffer
, ")");
846 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
848 if (!integer_zerop (TREE_OPERAND (node
, 1)))
850 pp_string (buffer
, " + ");
851 dump_generic_node (buffer
, TREE_OPERAND (node
, 1),
854 pp_string (buffer
, "]");
861 const char *sep
= "";
864 pp_string (buffer
, "MEM[");
866 if (TREE_CODE (TMR_BASE (node
)) == ADDR_EXPR
)
868 pp_string (buffer
, sep
);
870 pp_string (buffer
, "symbol: ");
871 dump_generic_node (buffer
, TREE_OPERAND (TMR_BASE (node
), 0),
876 pp_string (buffer
, sep
);
878 pp_string (buffer
, "base: ");
879 dump_generic_node (buffer
, TMR_BASE (node
), spc
, flags
, false);
881 tmp
= TMR_INDEX2 (node
);
884 pp_string (buffer
, sep
);
886 pp_string (buffer
, "base: ");
887 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
889 tmp
= TMR_INDEX (node
);
892 pp_string (buffer
, sep
);
894 pp_string (buffer
, "index: ");
895 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
897 tmp
= TMR_STEP (node
);
900 pp_string (buffer
, sep
);
902 pp_string (buffer
, "step: ");
903 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
905 tmp
= TMR_OFFSET (node
);
908 pp_string (buffer
, sep
);
910 pp_string (buffer
, "offset: ");
911 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
913 pp_string (buffer
, "]");
921 /* Print the innermost component type. */
922 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
923 tmp
= TREE_TYPE (tmp
))
925 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
927 /* Print the dimensions. */
928 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
929 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
935 case QUAL_UNION_TYPE
:
937 unsigned int quals
= TYPE_QUALS (node
);
939 if (quals
& TYPE_QUAL_CONST
)
940 pp_string (buffer
, "const ");
941 if (quals
& TYPE_QUAL_VOLATILE
)
942 pp_string (buffer
, "volatile ");
944 /* Print the name of the structure. */
945 if (TREE_CODE (node
) == RECORD_TYPE
)
946 pp_string (buffer
, "struct ");
947 else if (TREE_CODE (node
) == UNION_TYPE
)
948 pp_string (buffer
, "union ");
950 if (TYPE_NAME (node
))
951 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
952 else if (!(flags
& TDF_SLIM
))
953 /* FIXME: If we eliminate the 'else' above and attempt
954 to show the fields for named types, we may get stuck
955 following a cycle of pointers to structs. The alleged
956 self-reference check in print_struct_decl will not detect
957 cycles involving more than one pointer or struct type. */
958 print_struct_decl (buffer
, node
, spc
, flags
);
967 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
969 /* In the case of a pointer, one may want to divide by the
970 size of the pointed-to type. Unfortunately, this not
971 straightforward. The C front-end maps expressions
976 in such a way that the two INTEGER_CST nodes for "5" have
977 different values but identical types. In the latter
978 case, the 5 is multiplied by sizeof (int) in c-common.c
979 (pointer_int_sum) to convert it to a byte address, and
980 yet the type of the node is left unchanged. Argh. What
981 is consistent though is that the number value corresponds
982 to bytes (UNITS) offset.
984 NB: Neither of the following divisors can be trivially
985 used to recover the original literal:
987 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
988 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
989 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
990 pp_string (buffer
, "B"); /* pseudo-unit */
992 else if (! host_integerp (node
, 0))
995 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (val
);
996 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (val
);
998 if (tree_int_cst_sgn (val
) < 0)
1000 pp_character (buffer
, '-');
1001 high
= ~high
+ !low
;
1004 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
1006 sprintf (pp_buffer (buffer
)->digit_buffer
,
1007 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
1008 (unsigned HOST_WIDE_INT
) high
, low
);
1009 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
1012 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1016 /* Code copied from print_node. */
1019 if (TREE_OVERFLOW (node
))
1020 pp_string (buffer
, " overflow");
1022 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1023 d
= TREE_REAL_CST (node
);
1024 if (REAL_VALUE_ISINF (d
))
1025 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
1026 else if (REAL_VALUE_ISNAN (d
))
1027 pp_string (buffer
, " Nan");
1031 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
1032 pp_string (buffer
, string
);
1037 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
1038 pp_string (buffer
, "0x");
1039 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
1040 output_formatted_integer (buffer
, "%02x", *p
++);
1049 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
1050 pp_string (buffer
, string
);
1055 pp_string (buffer
, "__complex__ (");
1056 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
1057 pp_string (buffer
, ", ");
1058 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
1059 pp_string (buffer
, ")");
1063 pp_string (buffer
, "\"");
1064 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
1065 pp_string (buffer
, "\"");
1071 pp_string (buffer
, "{ ");
1072 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
1074 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
, false);
1075 if (TREE_CHAIN (elt
))
1076 pp_string (buffer
, ", ");
1078 pp_string (buffer
, " }");
1084 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1086 if (TREE_CODE (node
) == METHOD_TYPE
)
1088 if (TYPE_METHOD_BASETYPE (node
))
1089 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
1092 pp_string (buffer
, "<null method basetype>");
1093 pp_string (buffer
, "::");
1095 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1096 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1097 else if (flags
& TDF_NOUID
)
1098 pp_printf (buffer
, "<Txxxx>");
1100 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1101 dump_function_declaration (buffer
, node
, spc
, flags
);
1106 dump_decl_name (buffer
, node
, flags
);
1110 if (DECL_NAME (node
))
1111 dump_decl_name (buffer
, node
, flags
);
1112 else if (LABEL_DECL_UID (node
) != -1)
1113 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1116 if (flags
& TDF_NOUID
)
1117 pp_string (buffer
, "<D.xxxx>");
1119 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1124 if (DECL_IS_BUILTIN (node
))
1126 /* Don't print the declaration of built-in types. */
1129 if (DECL_NAME (node
))
1130 dump_decl_name (buffer
, node
, flags
);
1131 else if (TYPE_NAME (TREE_TYPE (node
)) != node
)
1133 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1134 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1135 && TYPE_METHODS (TREE_TYPE (node
)))
1137 /* The type is a c++ class: all structures have at least
1139 pp_string (buffer
, "class ");
1140 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1145 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1146 ? "union" : "struct "));
1147 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1151 pp_string (buffer
, "<anon>");
1157 case DEBUG_EXPR_DECL
:
1158 case NAMESPACE_DECL
:
1159 dump_decl_name (buffer
, node
, flags
);
1163 pp_string (buffer
, "<retval>");
1167 op0
= TREE_OPERAND (node
, 0);
1170 && (TREE_CODE (op0
) == INDIRECT_REF
1171 || (TREE_CODE (op0
) == MEM_REF
1172 && TREE_CODE (TREE_OPERAND (op0
, 0)) != ADDR_EXPR
1173 && integer_zerop (TREE_OPERAND (op0
, 1))
1174 /* Dump the types of INTEGER_CSTs explicitly, for we
1175 can't infer them and MEM_ATTR caching will share
1176 MEM_REFs with differently-typed op0s. */
1177 && TREE_CODE (TREE_OPERAND (op0
, 0)) != INTEGER_CST
1178 /* Same pointer types, but ignoring POINTER_TYPE vs.
1180 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1181 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1182 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1183 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1184 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1185 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1186 /* Same value types ignoring qualifiers. */
1187 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0
))
1188 == TYPE_MAIN_VARIANT
1189 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))))))
1191 op0
= TREE_OPERAND (op0
, 0);
1194 if (op_prio (op0
) < op_prio (node
))
1195 pp_character (buffer
, '(');
1196 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1197 if (op_prio (op0
) < op_prio (node
))
1198 pp_character (buffer
, ')');
1199 pp_string (buffer
, str
);
1200 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1201 op0
= component_ref_field_offset (node
);
1202 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1204 pp_string (buffer
, "{off: ");
1205 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1206 pp_character (buffer
, '}');
1211 pp_string (buffer
, "BIT_FIELD_REF <");
1212 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1213 pp_string (buffer
, ", ");
1214 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1215 pp_string (buffer
, ", ");
1216 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1217 pp_string (buffer
, ">");
1221 case ARRAY_RANGE_REF
:
1222 op0
= TREE_OPERAND (node
, 0);
1223 if (op_prio (op0
) < op_prio (node
))
1224 pp_character (buffer
, '(');
1225 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1226 if (op_prio (op0
) < op_prio (node
))
1227 pp_character (buffer
, ')');
1228 pp_character (buffer
, '[');
1229 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1230 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1231 pp_string (buffer
, " ...");
1232 pp_character (buffer
, ']');
1234 op0
= array_ref_low_bound (node
);
1235 op1
= array_ref_element_size (node
);
1237 if (!integer_zerop (op0
)
1238 || TREE_OPERAND (node
, 2)
1239 || TREE_OPERAND (node
, 3))
1241 pp_string (buffer
, "{lb: ");
1242 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1243 pp_string (buffer
, " sz: ");
1244 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1245 pp_character (buffer
, '}');
1251 unsigned HOST_WIDE_INT ix
;
1253 bool is_struct_init
= FALSE
;
1254 pp_character (buffer
, '{');
1255 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1256 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1257 is_struct_init
= TRUE
;
1258 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1260 if (field
&& is_struct_init
)
1262 pp_character (buffer
, '.');
1263 dump_generic_node (buffer
, field
, spc
, flags
, false);
1264 pp_string (buffer
, "=");
1266 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1267 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1268 val
= TREE_OPERAND (val
, 0);
1269 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1270 dump_decl_name (buffer
, val
, flags
);
1272 dump_generic_node (buffer
, val
, spc
, flags
, false);
1273 if (ix
!= VEC_length (constructor_elt
, CONSTRUCTOR_ELTS (node
)) - 1)
1275 pp_character (buffer
, ',');
1279 pp_character (buffer
, '}');
1286 if (flags
& TDF_SLIM
)
1288 pp_string (buffer
, "<COMPOUND_EXPR>");
1292 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1293 spc
, flags
, !(flags
& TDF_SLIM
));
1294 if (flags
& TDF_SLIM
)
1295 newline_and_indent (buffer
, spc
);
1298 pp_character (buffer
, ',');
1302 for (tp
= &TREE_OPERAND (node
, 1);
1303 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1304 tp
= &TREE_OPERAND (*tp
, 1))
1306 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1307 spc
, flags
, !(flags
& TDF_SLIM
));
1308 if (flags
& TDF_SLIM
)
1309 newline_and_indent (buffer
, spc
);
1312 pp_character (buffer
, ',');
1317 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1321 case STATEMENT_LIST
:
1323 tree_stmt_iterator si
;
1326 if (flags
& TDF_SLIM
)
1328 pp_string (buffer
, "<STATEMENT_LIST>");
1332 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1335 newline_and_indent (buffer
, spc
);
1338 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1345 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1348 pp_character (buffer
, '=');
1349 if (TREE_CODE (node
) == MODIFY_EXPR
1350 && MOVE_NONTEMPORAL (node
))
1351 pp_string (buffer
, "{nt}");
1353 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1358 pp_string (buffer
, "TARGET_EXPR <");
1359 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1360 pp_character (buffer
, ',');
1362 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1363 pp_character (buffer
, '>');
1367 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1372 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1374 pp_string (buffer
, "if (");
1375 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1376 pp_character (buffer
, ')');
1377 /* The lowered cond_exprs should always be printed in full. */
1378 if (COND_EXPR_THEN (node
)
1379 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1380 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1381 && COND_EXPR_ELSE (node
)
1382 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1383 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1386 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1388 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1390 pp_string (buffer
, " else ");
1391 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1395 else if (!(flags
& TDF_SLIM
))
1397 /* Output COND_EXPR_THEN. */
1398 if (COND_EXPR_THEN (node
))
1400 newline_and_indent (buffer
, spc
+2);
1401 pp_character (buffer
, '{');
1402 newline_and_indent (buffer
, spc
+4);
1403 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1405 newline_and_indent (buffer
, spc
+2);
1406 pp_character (buffer
, '}');
1409 /* Output COND_EXPR_ELSE. */
1410 if (COND_EXPR_ELSE (node
)
1411 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1413 newline_and_indent (buffer
, spc
);
1414 pp_string (buffer
, "else");
1415 newline_and_indent (buffer
, spc
+2);
1416 pp_character (buffer
, '{');
1417 newline_and_indent (buffer
, spc
+4);
1418 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1420 newline_and_indent (buffer
, spc
+2);
1421 pp_character (buffer
, '}');
1428 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1430 pp_character (buffer
, '?');
1432 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1434 pp_character (buffer
, ':');
1436 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1441 pp_character (buffer
, '{');
1442 if (!(flags
& TDF_SLIM
))
1444 if (BIND_EXPR_VARS (node
))
1446 pp_newline (buffer
);
1448 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= DECL_CHAIN (op0
))
1450 print_declaration (buffer
, op0
, spc
+2, flags
);
1451 pp_newline (buffer
);
1455 newline_and_indent (buffer
, spc
+2);
1456 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1457 newline_and_indent (buffer
, spc
);
1458 pp_character (buffer
, '}');
1464 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1466 /* Print parameters. */
1468 pp_character (buffer
, '(');
1471 call_expr_arg_iterator iter
;
1472 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1474 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1475 if (more_call_expr_args_p (&iter
))
1477 pp_character (buffer
, ',');
1482 if (CALL_EXPR_VA_ARG_PACK (node
))
1484 if (call_expr_nargs (node
) > 0)
1486 pp_character (buffer
, ',');
1489 pp_string (buffer
, "__builtin_va_arg_pack ()");
1491 pp_character (buffer
, ')');
1493 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1496 pp_string (buffer
, " [static-chain: ");
1497 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1498 pp_character (buffer
, ']');
1501 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1502 pp_string (buffer
, " [return slot optimization]");
1503 if (CALL_EXPR_TAILCALL (node
))
1504 pp_string (buffer
, " [tail call]");
1507 case WITH_CLEANUP_EXPR
:
1511 case CLEANUP_POINT_EXPR
:
1512 pp_string (buffer
, "<<cleanup_point ");
1513 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1514 pp_string (buffer
, ">>");
1517 case PLACEHOLDER_EXPR
:
1518 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1519 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1520 pp_character (buffer
, '>');
1523 /* Binary arithmetic and logic expressions. */
1524 case WIDEN_SUM_EXPR
:
1525 case WIDEN_MULT_EXPR
:
1528 case POINTER_PLUS_EXPR
:
1530 case TRUNC_DIV_EXPR
:
1532 case FLOOR_DIV_EXPR
:
1533 case ROUND_DIV_EXPR
:
1534 case TRUNC_MOD_EXPR
:
1536 case FLOOR_MOD_EXPR
:
1537 case ROUND_MOD_EXPR
:
1539 case EXACT_DIV_EXPR
:
1544 case VEC_LSHIFT_EXPR
:
1545 case VEC_RSHIFT_EXPR
:
1549 case TRUTH_ANDIF_EXPR
:
1550 case TRUTH_ORIF_EXPR
:
1551 case TRUTH_AND_EXPR
:
1553 case TRUTH_XOR_EXPR
:
1567 case UNORDERED_EXPR
:
1569 const char *op
= op_symbol (node
);
1570 op0
= TREE_OPERAND (node
, 0);
1571 op1
= TREE_OPERAND (node
, 1);
1573 /* When the operands are expressions with less priority,
1574 keep semantics of the tree representation. */
1575 if (op_prio (op0
) <= op_prio (node
))
1577 pp_character (buffer
, '(');
1578 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1579 pp_character (buffer
, ')');
1582 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1585 pp_string (buffer
, op
);
1588 /* When the operands are expressions with less priority,
1589 keep semantics of the tree representation. */
1590 if (op_prio (op1
) <= op_prio (node
))
1592 pp_character (buffer
, '(');
1593 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1594 pp_character (buffer
, ')');
1597 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1601 /* Unary arithmetic and logic expressions. */
1604 case TRUTH_NOT_EXPR
:
1606 case PREDECREMENT_EXPR
:
1607 case PREINCREMENT_EXPR
:
1609 if (TREE_CODE (node
) == ADDR_EXPR
1610 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1611 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1612 ; /* Do not output '&' for strings and function pointers. */
1614 pp_string (buffer
, op_symbol (node
));
1616 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1618 pp_character (buffer
, '(');
1619 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1620 pp_character (buffer
, ')');
1623 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1626 case POSTDECREMENT_EXPR
:
1627 case POSTINCREMENT_EXPR
:
1628 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1630 pp_character (buffer
, '(');
1631 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1632 pp_character (buffer
, ')');
1635 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1636 pp_string (buffer
, op_symbol (node
));
1640 pp_string (buffer
, "MIN_EXPR <");
1641 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1642 pp_string (buffer
, ", ");
1643 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1644 pp_character (buffer
, '>');
1648 pp_string (buffer
, "MAX_EXPR <");
1649 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1650 pp_string (buffer
, ", ");
1651 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1652 pp_character (buffer
, '>');
1656 pp_string (buffer
, "ABS_EXPR <");
1657 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1658 pp_character (buffer
, '>');
1665 case ADDR_SPACE_CONVERT_EXPR
:
1666 case FIXED_CONVERT_EXPR
:
1667 case FIX_TRUNC_EXPR
:
1670 type
= TREE_TYPE (node
);
1671 op0
= TREE_OPERAND (node
, 0);
1672 if (type
!= TREE_TYPE (op0
))
1674 pp_character (buffer
, '(');
1675 dump_generic_node (buffer
, type
, spc
, flags
, false);
1676 pp_string (buffer
, ") ");
1678 if (op_prio (op0
) < op_prio (node
))
1679 pp_character (buffer
, '(');
1680 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1681 if (op_prio (op0
) < op_prio (node
))
1682 pp_character (buffer
, ')');
1685 case VIEW_CONVERT_EXPR
:
1686 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1687 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1688 pp_string (buffer
, ">(");
1689 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1690 pp_character (buffer
, ')');
1694 pp_string (buffer
, "((");
1695 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1696 pp_string (buffer
, "))");
1699 case NON_LVALUE_EXPR
:
1700 pp_string (buffer
, "NON_LVALUE_EXPR <");
1701 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1702 pp_character (buffer
, '>');
1706 pp_string (buffer
, "SAVE_EXPR <");
1707 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1708 pp_character (buffer
, '>');
1712 pp_string (buffer
, "COMPLEX_EXPR <");
1713 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1714 pp_string (buffer
, ", ");
1715 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1716 pp_string (buffer
, ">");
1720 pp_string (buffer
, "CONJ_EXPR <");
1721 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1722 pp_string (buffer
, ">");
1726 pp_string (buffer
, "REALPART_EXPR <");
1727 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1728 pp_string (buffer
, ">");
1732 pp_string (buffer
, "IMAGPART_EXPR <");
1733 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1734 pp_string (buffer
, ">");
1738 pp_string (buffer
, "VA_ARG_EXPR <");
1739 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1740 pp_string (buffer
, ">");
1743 case TRY_FINALLY_EXPR
:
1744 case TRY_CATCH_EXPR
:
1745 pp_string (buffer
, "try");
1746 newline_and_indent (buffer
, spc
+2);
1747 pp_string (buffer
, "{");
1748 newline_and_indent (buffer
, spc
+4);
1749 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1750 newline_and_indent (buffer
, spc
+2);
1751 pp_string (buffer
, "}");
1752 newline_and_indent (buffer
, spc
);
1754 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1755 newline_and_indent (buffer
, spc
+2);
1756 pp_string (buffer
, "{");
1757 newline_and_indent (buffer
, spc
+4);
1758 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1759 newline_and_indent (buffer
, spc
+2);
1760 pp_string (buffer
, "}");
1765 pp_string (buffer
, "catch (");
1766 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1767 pp_string (buffer
, ")");
1768 newline_and_indent (buffer
, spc
+2);
1769 pp_string (buffer
, "{");
1770 newline_and_indent (buffer
, spc
+4);
1771 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1772 newline_and_indent (buffer
, spc
+2);
1773 pp_string (buffer
, "}");
1777 case EH_FILTER_EXPR
:
1778 pp_string (buffer
, "<<<eh_filter (");
1779 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1780 pp_string (buffer
, ")>>>");
1781 newline_and_indent (buffer
, spc
+2);
1782 pp_string (buffer
, "{");
1783 newline_and_indent (buffer
, spc
+4);
1784 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1785 newline_and_indent (buffer
, spc
+2);
1786 pp_string (buffer
, "}");
1791 op0
= TREE_OPERAND (node
, 0);
1792 /* If this is for break or continue, don't bother printing it. */
1793 if (DECL_NAME (op0
))
1795 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1796 if (strcmp (name
, "break") == 0
1797 || strcmp (name
, "continue") == 0)
1800 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1801 pp_character (buffer
, ':');
1802 if (DECL_NONLOCAL (op0
))
1803 pp_string (buffer
, " [non-local]");
1807 pp_string (buffer
, "while (1)");
1808 if (!(flags
& TDF_SLIM
))
1810 newline_and_indent (buffer
, spc
+2);
1811 pp_character (buffer
, '{');
1812 newline_and_indent (buffer
, spc
+4);
1813 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1814 newline_and_indent (buffer
, spc
+2);
1815 pp_character (buffer
, '}');
1821 pp_string (buffer
, "// predicted ");
1822 if (PREDICT_EXPR_OUTCOME (node
))
1823 pp_string (buffer
, "likely by ");
1825 pp_string (buffer
, "unlikely by ");
1826 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
1827 pp_string (buffer
, " predictor.");
1831 pp_string (buffer
, "return");
1832 op0
= TREE_OPERAND (node
, 0);
1836 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1837 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
1840 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1845 pp_string (buffer
, "if (");
1846 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1847 pp_string (buffer
, ") break");
1851 pp_string (buffer
, "switch (");
1852 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1853 pp_character (buffer
, ')');
1854 if (!(flags
& TDF_SLIM
))
1856 newline_and_indent (buffer
, spc
+2);
1857 pp_character (buffer
, '{');
1858 if (SWITCH_BODY (node
))
1860 newline_and_indent (buffer
, spc
+4);
1861 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1866 tree vec
= SWITCH_LABELS (node
);
1867 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1868 for (i
= 0; i
< n
; ++i
)
1870 tree elt
= TREE_VEC_ELT (vec
, i
);
1871 newline_and_indent (buffer
, spc
+4);
1874 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1875 pp_string (buffer
, " goto ");
1876 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1878 pp_semicolon (buffer
);
1881 pp_string (buffer
, "case ???: goto ???;");
1884 newline_and_indent (buffer
, spc
+2);
1885 pp_character (buffer
, '}');
1891 op0
= GOTO_DESTINATION (node
);
1892 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1894 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1895 if (strcmp (name
, "break") == 0
1896 || strcmp (name
, "continue") == 0)
1898 pp_string (buffer
, name
);
1902 pp_string (buffer
, "goto ");
1903 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1907 pp_string (buffer
, "__asm__");
1908 if (ASM_VOLATILE_P (node
))
1909 pp_string (buffer
, " __volatile__");
1910 pp_character (buffer
, '(');
1911 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1912 pp_character (buffer
, ':');
1913 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1914 pp_character (buffer
, ':');
1915 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1916 if (ASM_CLOBBERS (node
))
1918 pp_character (buffer
, ':');
1919 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1921 pp_string (buffer
, ")");
1924 case CASE_LABEL_EXPR
:
1925 if (CASE_LOW (node
) && CASE_HIGH (node
))
1927 pp_string (buffer
, "case ");
1928 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1929 pp_string (buffer
, " ... ");
1930 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1932 else if (CASE_LOW (node
))
1934 pp_string (buffer
, "case ");
1935 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1938 pp_string (buffer
, "default");
1939 pp_character (buffer
, ':');
1943 pp_string (buffer
, "OBJ_TYPE_REF(");
1944 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1945 pp_character (buffer
, ';');
1946 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1947 pp_character (buffer
, '-');
1948 pp_character (buffer
, '>');
1949 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
1950 pp_character (buffer
, ')');
1954 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
1955 pp_string (buffer
, "_");
1956 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1957 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
1958 pp_string (buffer
, "(ab)");
1959 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
1960 pp_string (buffer
, "(D)");
1963 case WITH_SIZE_EXPR
:
1964 pp_string (buffer
, "WITH_SIZE_EXPR <");
1965 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1966 pp_string (buffer
, ", ");
1967 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1968 pp_string (buffer
, ">");
1972 pp_string (buffer
, "ASSERT_EXPR <");
1973 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
1974 pp_string (buffer
, ", ");
1975 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
1976 pp_string (buffer
, ">");
1980 pp_string (buffer
, "scev_known");
1983 case SCEV_NOT_KNOWN
:
1984 pp_string (buffer
, "scev_not_known");
1987 case POLYNOMIAL_CHREC
:
1988 pp_string (buffer
, "{");
1989 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
1990 pp_string (buffer
, ", +, ");
1991 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
1992 pp_string (buffer
, "}_");
1993 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
1997 case REALIGN_LOAD_EXPR
:
1998 pp_string (buffer
, "REALIGN_LOAD <");
1999 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2000 pp_string (buffer
, ", ");
2001 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2002 pp_string (buffer
, ", ");
2003 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2004 pp_string (buffer
, ">");
2008 pp_string (buffer
, " VEC_COND_EXPR < ");
2009 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2010 pp_string (buffer
, " , ");
2011 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2012 pp_string (buffer
, " , ");
2013 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2014 pp_string (buffer
, " > ");
2018 pp_string (buffer
, " DOT_PROD_EXPR < ");
2019 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2020 pp_string (buffer
, ", ");
2021 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2022 pp_string (buffer
, ", ");
2023 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2024 pp_string (buffer
, " > ");
2027 case WIDEN_MULT_PLUS_EXPR
:
2028 pp_string (buffer
, " WIDEN_MULT_PLUS_EXPR < ");
2029 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2030 pp_string (buffer
, ", ");
2031 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2032 pp_string (buffer
, ", ");
2033 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2034 pp_string (buffer
, " > ");
2037 case WIDEN_MULT_MINUS_EXPR
:
2038 pp_string (buffer
, " WIDEN_MULT_MINUS_EXPR < ");
2039 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2040 pp_string (buffer
, ", ");
2041 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2042 pp_string (buffer
, ", ");
2043 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2044 pp_string (buffer
, " > ");
2048 pp_string (buffer
, " FMA_EXPR < ");
2049 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2050 pp_string (buffer
, ", ");
2051 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2052 pp_string (buffer
, ", ");
2053 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2054 pp_string (buffer
, " > ");
2058 pp_string (buffer
, "#pragma omp parallel");
2059 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
2062 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
2064 newline_and_indent (buffer
, spc
+ 2);
2065 pp_character (buffer
, '{');
2066 newline_and_indent (buffer
, spc
+ 4);
2067 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
2068 newline_and_indent (buffer
, spc
+ 2);
2069 pp_character (buffer
, '}');
2075 pp_string (buffer
, "#pragma omp task");
2076 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
2080 pp_string (buffer
, "#pragma omp for");
2081 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
2083 if (!(flags
& TDF_SLIM
))
2087 if (OMP_FOR_PRE_BODY (node
))
2089 newline_and_indent (buffer
, spc
+ 2);
2090 pp_character (buffer
, '{');
2092 newline_and_indent (buffer
, spc
);
2093 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
2097 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
2100 newline_and_indent (buffer
, spc
);
2101 pp_string (buffer
, "for (");
2102 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
2104 pp_string (buffer
, "; ");
2105 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
2107 pp_string (buffer
, "; ");
2108 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
2110 pp_string (buffer
, ")");
2112 if (OMP_FOR_BODY (node
))
2114 newline_and_indent (buffer
, spc
+ 2);
2115 pp_character (buffer
, '{');
2116 newline_and_indent (buffer
, spc
+ 4);
2117 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
2119 newline_and_indent (buffer
, spc
+ 2);
2120 pp_character (buffer
, '}');
2122 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
2123 if (OMP_FOR_PRE_BODY (node
))
2126 newline_and_indent (buffer
, spc
+ 2);
2127 pp_character (buffer
, '}');
2134 pp_string (buffer
, "#pragma omp sections");
2135 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2139 pp_string (buffer
, "#pragma omp section");
2143 pp_string (buffer
, "#pragma omp master");
2147 pp_string (buffer
, "#pragma omp ordered");
2151 pp_string (buffer
, "#pragma omp critical");
2152 if (OMP_CRITICAL_NAME (node
))
2155 pp_character (buffer
, '(');
2156 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2158 pp_character (buffer
, ')');
2163 pp_string (buffer
, "#pragma omp atomic");
2164 newline_and_indent (buffer
, spc
+ 2);
2165 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2167 pp_character (buffer
, '=');
2169 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2173 pp_string (buffer
, "#pragma omp single");
2174 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2178 dump_omp_clause (buffer
, node
, spc
, flags
);
2182 case REDUC_MAX_EXPR
:
2183 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2184 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2185 pp_string (buffer
, " > ");
2188 case REDUC_MIN_EXPR
:
2189 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2190 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2191 pp_string (buffer
, " > ");
2194 case REDUC_PLUS_EXPR
:
2195 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2196 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2197 pp_string (buffer
, " > ");
2200 case VEC_WIDEN_MULT_HI_EXPR
:
2201 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
2202 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2203 pp_string (buffer
, ", ");
2204 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2205 pp_string (buffer
, " > ");
2208 case VEC_WIDEN_MULT_LO_EXPR
:
2209 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
2210 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2211 pp_string (buffer
, ", ");
2212 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2213 pp_string (buffer
, " > ");
2216 case VEC_UNPACK_HI_EXPR
:
2217 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2218 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2219 pp_string (buffer
, " > ");
2222 case VEC_UNPACK_LO_EXPR
:
2223 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2224 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2225 pp_string (buffer
, " > ");
2228 case VEC_UNPACK_FLOAT_HI_EXPR
:
2229 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2230 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2231 pp_string (buffer
, " > ");
2234 case VEC_UNPACK_FLOAT_LO_EXPR
:
2235 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2236 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2237 pp_string (buffer
, " > ");
2240 case VEC_PACK_TRUNC_EXPR
:
2241 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2242 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2243 pp_string (buffer
, ", ");
2244 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2245 pp_string (buffer
, " > ");
2248 case VEC_PACK_SAT_EXPR
:
2249 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2250 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2251 pp_string (buffer
, ", ");
2252 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2253 pp_string (buffer
, " > ");
2256 case VEC_PACK_FIX_TRUNC_EXPR
:
2257 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2258 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2259 pp_string (buffer
, ", ");
2260 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2261 pp_string (buffer
, " > ");
2265 dump_block_node (buffer
, node
, spc
, flags
);
2268 case VEC_EXTRACT_EVEN_EXPR
:
2269 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2270 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2271 pp_string (buffer
, ", ");
2272 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2273 pp_string (buffer
, " > ");
2276 case VEC_EXTRACT_ODD_EXPR
:
2277 pp_string (buffer
, " VEC_EXTRACT_ODD_EXPR < ");
2278 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2279 pp_string (buffer
, ", ");
2280 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2281 pp_string (buffer
, " > ");
2284 case VEC_INTERLEAVE_HIGH_EXPR
:
2285 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_EXPR < ");
2286 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2287 pp_string (buffer
, ", ");
2288 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2289 pp_string (buffer
, " > ");
2292 case VEC_INTERLEAVE_LOW_EXPR
:
2293 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2294 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2295 pp_string (buffer
, ", ");
2296 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2297 pp_string (buffer
, " > ");
2304 if (is_stmt
&& is_expr
)
2305 pp_semicolon (buffer
);
2307 /* If we're building a diagnostic, the formatted text will be written
2308 into BUFFER's stream by the caller; otherwise, write it now. */
2309 if (!(flags
& TDF_DIAGNOSTIC
))
2310 pp_write_text_to_stream (buffer
);
2315 /* Print the declaration of a variable. */
2318 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2322 if (TREE_CODE (t
) == TYPE_DECL
)
2323 pp_string (buffer
, "typedef ");
2325 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2326 pp_string (buffer
, "register ");
2328 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2329 pp_string (buffer
, "extern ");
2330 else if (TREE_STATIC (t
))
2331 pp_string (buffer
, "static ");
2333 /* Print the type and name. */
2334 if (TREE_TYPE (t
) && TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2338 /* Print array's type. */
2339 tmp
= TREE_TYPE (t
);
2340 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2341 tmp
= TREE_TYPE (tmp
);
2342 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2344 /* Print variable's name. */
2346 dump_generic_node (buffer
, t
, spc
, flags
, false);
2348 /* Print the dimensions. */
2349 tmp
= TREE_TYPE (t
);
2350 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2352 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2353 tmp
= TREE_TYPE (tmp
);
2356 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2358 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2360 dump_decl_name (buffer
, t
, flags
);
2361 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2365 /* Print type declaration. */
2366 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2368 /* Print variable's name. */
2370 dump_generic_node (buffer
, t
, spc
, flags
, false);
2373 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2375 pp_string (buffer
, " __asm__ ");
2376 pp_character (buffer
, '(');
2377 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2378 pp_character (buffer
, ')');
2381 /* The initial value of a function serves to determine whether the function
2382 is declared or defined. So the following does not apply to function
2384 if (TREE_CODE (t
) != FUNCTION_DECL
)
2386 /* Print the initial value. */
2387 if (DECL_INITIAL (t
))
2390 pp_character (buffer
, '=');
2392 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2396 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2398 pp_string (buffer
, " [value-expr: ");
2399 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2400 pp_character (buffer
, ']');
2403 pp_character (buffer
, ';');
2407 /* Prints a structure: name, fields, and methods.
2408 FIXME: Still incomplete. */
2411 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2413 /* Print the name of the structure. */
2414 if (TYPE_NAME (node
))
2417 if (TREE_CODE (node
) == RECORD_TYPE
)
2418 pp_string (buffer
, "struct ");
2419 else if ((TREE_CODE (node
) == UNION_TYPE
2420 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2421 pp_string (buffer
, "union ");
2423 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2426 /* Print the contents of the structure. */
2427 pp_newline (buffer
);
2429 pp_character (buffer
, '{');
2430 pp_newline (buffer
);
2432 /* Print the fields of the structure. */
2435 tmp
= TYPE_FIELDS (node
);
2438 /* Avoid to print recursively the structure. */
2439 /* FIXME : Not implemented correctly...,
2440 what about the case when we have a cycle in the contain graph? ...
2441 Maybe this could be solved by looking at the scope in which the
2442 structure was declared. */
2443 if (TREE_TYPE (tmp
) != node
2444 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2445 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2447 print_declaration (buffer
, tmp
, spc
+2, flags
);
2448 pp_newline (buffer
);
2450 tmp
= DECL_CHAIN (tmp
);
2454 pp_character (buffer
, '}');
2457 /* Return the priority of the operator CODE.
2459 From lowest to highest precedence with either left-to-right (L-R)
2460 or right-to-left (R-L) associativity]:
2463 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2475 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2476 15 [L-R] fn() [] -> .
2478 unary +, - and * have higher precedence than the corresponding binary
2482 op_code_prio (enum tree_code code
)
2499 case TRUTH_ORIF_EXPR
:
2502 case TRUTH_AND_EXPR
:
2503 case TRUTH_ANDIF_EXPR
:
2510 case TRUTH_XOR_EXPR
:
2527 case UNORDERED_EXPR
:
2540 case WIDEN_SUM_EXPR
:
2542 case POINTER_PLUS_EXPR
:
2546 case VEC_WIDEN_MULT_HI_EXPR
:
2547 case VEC_WIDEN_MULT_LO_EXPR
:
2548 case WIDEN_MULT_EXPR
:
2550 case WIDEN_MULT_PLUS_EXPR
:
2551 case WIDEN_MULT_MINUS_EXPR
:
2553 case TRUNC_DIV_EXPR
:
2555 case FLOOR_DIV_EXPR
:
2556 case ROUND_DIV_EXPR
:
2558 case EXACT_DIV_EXPR
:
2559 case TRUNC_MOD_EXPR
:
2561 case FLOOR_MOD_EXPR
:
2562 case ROUND_MOD_EXPR
:
2566 case TRUTH_NOT_EXPR
:
2568 case POSTINCREMENT_EXPR
:
2569 case POSTDECREMENT_EXPR
:
2570 case PREINCREMENT_EXPR
:
2571 case PREDECREMENT_EXPR
:
2577 case FIX_TRUNC_EXPR
:
2583 case ARRAY_RANGE_REF
:
2587 /* Special expressions. */
2593 case REDUC_MAX_EXPR
:
2594 case REDUC_MIN_EXPR
:
2595 case REDUC_PLUS_EXPR
:
2596 case VEC_LSHIFT_EXPR
:
2597 case VEC_RSHIFT_EXPR
:
2598 case VEC_UNPACK_HI_EXPR
:
2599 case VEC_UNPACK_LO_EXPR
:
2600 case VEC_UNPACK_FLOAT_HI_EXPR
:
2601 case VEC_UNPACK_FLOAT_LO_EXPR
:
2602 case VEC_PACK_TRUNC_EXPR
:
2603 case VEC_PACK_SAT_EXPR
:
2607 /* Return an arbitrarily high precedence to avoid surrounding single
2608 VAR_DECLs in ()s. */
2613 /* Return the priority of the operator OP. */
2616 op_prio (const_tree op
)
2618 enum tree_code code
;
2623 code
= TREE_CODE (op
);
2624 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2625 return op_prio (TREE_OPERAND (op
, 0));
2627 return op_code_prio (code
);
2630 /* Return the symbol associated with operator CODE. */
2633 op_symbol_code (enum tree_code code
)
2641 case TRUTH_ORIF_EXPR
:
2644 case TRUTH_AND_EXPR
:
2645 case TRUTH_ANDIF_EXPR
:
2651 case TRUTH_XOR_EXPR
:
2661 case UNORDERED_EXPR
:
2707 case VEC_LSHIFT_EXPR
:
2710 case VEC_RSHIFT_EXPR
:
2713 case POINTER_PLUS_EXPR
:
2719 case REDUC_PLUS_EXPR
:
2722 case WIDEN_SUM_EXPR
:
2725 case WIDEN_MULT_EXPR
:
2735 case TRUTH_NOT_EXPR
:
2742 case TRUNC_DIV_EXPR
:
2749 case FLOOR_DIV_EXPR
:
2752 case ROUND_DIV_EXPR
:
2755 case EXACT_DIV_EXPR
:
2758 case TRUNC_MOD_EXPR
:
2764 case FLOOR_MOD_EXPR
:
2767 case ROUND_MOD_EXPR
:
2770 case PREDECREMENT_EXPR
:
2773 case PREINCREMENT_EXPR
:
2776 case POSTDECREMENT_EXPR
:
2779 case POSTINCREMENT_EXPR
:
2789 return "<<< ??? >>>";
2793 /* Return the symbol associated with operator OP. */
2796 op_symbol (const_tree op
)
2798 return op_symbol_code (TREE_CODE (op
));
2801 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2802 the gimple_call_fn of a GIMPLE_CALL. */
2805 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
2809 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2810 op0
= TREE_OPERAND (op0
, 0);
2813 switch (TREE_CODE (op0
))
2818 dump_function_name (buffer
, op0
, flags
);
2824 op0
= TREE_OPERAND (op0
, 0);
2828 pp_string (buffer
, "(");
2829 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
2830 pp_string (buffer
, ") ? ");
2831 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
2832 pp_string (buffer
, " : ");
2833 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
2837 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2838 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
2840 dump_generic_node (buffer
, op0
, 0, flags
, false);
2844 if (integer_zerop (TREE_OPERAND (op0
, 1)))
2846 op0
= TREE_OPERAND (op0
, 0);
2853 dump_generic_node (buffer
, op0
, 0, flags
, false);
2861 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2864 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2874 pp_string (buffer
, "\\b");
2878 pp_string (buffer
, "\\f");
2882 pp_string (buffer
, "\\n");
2886 pp_string (buffer
, "\\r");
2890 pp_string (buffer
, "\\t");
2894 pp_string (buffer
, "\\v");
2898 pp_string (buffer
, "\\\\");
2902 pp_string (buffer
, "\\\"");
2906 pp_string (buffer
, "\\'");
2909 /* No need to handle \0; the loop terminates on \0. */
2912 pp_string (buffer
, "\\1");
2916 pp_string (buffer
, "\\2");
2920 pp_string (buffer
, "\\3");
2924 pp_string (buffer
, "\\4");
2928 pp_string (buffer
, "\\5");
2932 pp_string (buffer
, "\\6");
2936 pp_string (buffer
, "\\7");
2940 pp_character (buffer
, str
[0]);
2948 maybe_init_pretty_print (FILE *file
)
2952 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
2953 pp_needs_newline (&buffer
) = true;
2954 pp_translate_identifiers (&buffer
) = false;
2958 buffer
.buffer
->stream
= file
;
2962 newline_and_indent (pretty_printer
*buffer
, int spc
)
2964 pp_newline (buffer
);
2968 /* Handle a %K format for TEXT. Separate from default_tree_printer so
2969 it can also be used in front ends.
2970 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
2974 percent_K_format (text_info
*text
)
2976 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
2977 gcc_assert (text
->locus
!= NULL
);
2978 *text
->locus
= EXPR_LOCATION (t
);
2979 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
2980 block
= TREE_BLOCK (t
);
2981 *pp_ti_abstract_origin (text
) = NULL
;
2983 && TREE_CODE (block
) == BLOCK
2984 && BLOCK_ABSTRACT_ORIGIN (block
))
2986 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
2988 while (TREE_CODE (ao
) == BLOCK
2989 && BLOCK_ABSTRACT_ORIGIN (ao
)
2990 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
2991 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
2993 if (TREE_CODE (ao
) == FUNCTION_DECL
)
2995 *pp_ti_abstract_origin (text
) = block
;
2998 block
= BLOCK_SUPERCONTEXT (block
);
3002 /* Print the identifier ID to PRETTY-PRINTER. */
3005 pp_base_tree_identifier (pretty_printer
*pp
, tree id
)
3007 if (pp_translate_identifiers (pp
))
3009 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
3010 pp_append_text (pp
, text
, text
+ strlen (text
));
3013 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
3014 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));