1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
3 2011 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 bool is_array_init
= false;
1255 double_int curidx
= double_int_zero
;
1256 pp_character (buffer
, '{');
1257 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1258 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1259 is_struct_init
= true;
1260 else if (TREE_CODE (TREE_TYPE (node
)) == ARRAY_TYPE
1261 && TYPE_DOMAIN (TREE_TYPE (node
))
1262 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)))
1263 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
))))
1266 tree minv
= TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)));
1267 is_array_init
= true;
1268 curidx
= tree_to_double_int (minv
);
1270 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1276 pp_character (buffer
, '.');
1277 dump_generic_node (buffer
, field
, spc
, flags
, false);
1278 pp_character (buffer
, '=');
1280 else if (is_array_init
1281 && (TREE_CODE (field
) != INTEGER_CST
1282 || !double_int_equal_p (tree_to_double_int (field
),
1285 pp_character (buffer
, '[');
1286 if (TREE_CODE (field
) == RANGE_EXPR
)
1288 dump_generic_node (buffer
, TREE_OPERAND (field
, 0), spc
,
1290 pp_string (buffer
, " ... ");
1291 dump_generic_node (buffer
, TREE_OPERAND (field
, 1), spc
,
1293 if (TREE_CODE (TREE_OPERAND (field
, 1)) == INTEGER_CST
)
1294 curidx
= tree_to_double_int (TREE_OPERAND (field
, 1));
1297 dump_generic_node (buffer
, field
, spc
, flags
, false);
1298 if (TREE_CODE (field
) == INTEGER_CST
)
1299 curidx
= tree_to_double_int (field
);
1300 pp_string (buffer
, "]=");
1304 curidx
= double_int_add (curidx
, double_int_one
);
1305 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1306 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1307 val
= TREE_OPERAND (val
, 0);
1308 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1309 dump_decl_name (buffer
, val
, flags
);
1311 dump_generic_node (buffer
, val
, spc
, flags
, false);
1312 if (ix
!= VEC_length (constructor_elt
, CONSTRUCTOR_ELTS (node
)) - 1)
1314 pp_character (buffer
, ',');
1318 pp_character (buffer
, '}');
1325 if (flags
& TDF_SLIM
)
1327 pp_string (buffer
, "<COMPOUND_EXPR>");
1331 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1332 spc
, flags
, !(flags
& TDF_SLIM
));
1333 if (flags
& TDF_SLIM
)
1334 newline_and_indent (buffer
, spc
);
1337 pp_character (buffer
, ',');
1341 for (tp
= &TREE_OPERAND (node
, 1);
1342 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1343 tp
= &TREE_OPERAND (*tp
, 1))
1345 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1346 spc
, flags
, !(flags
& TDF_SLIM
));
1347 if (flags
& TDF_SLIM
)
1348 newline_and_indent (buffer
, spc
);
1351 pp_character (buffer
, ',');
1356 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1360 case STATEMENT_LIST
:
1362 tree_stmt_iterator si
;
1365 if (flags
& TDF_SLIM
)
1367 pp_string (buffer
, "<STATEMENT_LIST>");
1371 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1374 newline_and_indent (buffer
, spc
);
1377 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1384 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1387 pp_character (buffer
, '=');
1388 if (TREE_CODE (node
) == MODIFY_EXPR
1389 && MOVE_NONTEMPORAL (node
))
1390 pp_string (buffer
, "{nt}");
1392 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1397 pp_string (buffer
, "TARGET_EXPR <");
1398 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1399 pp_character (buffer
, ',');
1401 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1402 pp_character (buffer
, '>');
1406 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1411 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1413 pp_string (buffer
, "if (");
1414 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1415 pp_character (buffer
, ')');
1416 /* The lowered cond_exprs should always be printed in full. */
1417 if (COND_EXPR_THEN (node
)
1418 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1419 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1420 && COND_EXPR_ELSE (node
)
1421 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1422 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1425 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1427 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1429 pp_string (buffer
, " else ");
1430 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1434 else if (!(flags
& TDF_SLIM
))
1436 /* Output COND_EXPR_THEN. */
1437 if (COND_EXPR_THEN (node
))
1439 newline_and_indent (buffer
, spc
+2);
1440 pp_character (buffer
, '{');
1441 newline_and_indent (buffer
, spc
+4);
1442 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1444 newline_and_indent (buffer
, spc
+2);
1445 pp_character (buffer
, '}');
1448 /* Output COND_EXPR_ELSE. */
1449 if (COND_EXPR_ELSE (node
)
1450 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1452 newline_and_indent (buffer
, spc
);
1453 pp_string (buffer
, "else");
1454 newline_and_indent (buffer
, spc
+2);
1455 pp_character (buffer
, '{');
1456 newline_and_indent (buffer
, spc
+4);
1457 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1459 newline_and_indent (buffer
, spc
+2);
1460 pp_character (buffer
, '}');
1467 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1469 pp_character (buffer
, '?');
1471 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1473 pp_character (buffer
, ':');
1475 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1480 pp_character (buffer
, '{');
1481 if (!(flags
& TDF_SLIM
))
1483 if (BIND_EXPR_VARS (node
))
1485 pp_newline (buffer
);
1487 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= DECL_CHAIN (op0
))
1489 print_declaration (buffer
, op0
, spc
+2, flags
);
1490 pp_newline (buffer
);
1494 newline_and_indent (buffer
, spc
+2);
1495 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1496 newline_and_indent (buffer
, spc
);
1497 pp_character (buffer
, '}');
1503 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1505 /* Print parameters. */
1507 pp_character (buffer
, '(');
1510 call_expr_arg_iterator iter
;
1511 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1513 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1514 if (more_call_expr_args_p (&iter
))
1516 pp_character (buffer
, ',');
1521 if (CALL_EXPR_VA_ARG_PACK (node
))
1523 if (call_expr_nargs (node
) > 0)
1525 pp_character (buffer
, ',');
1528 pp_string (buffer
, "__builtin_va_arg_pack ()");
1530 pp_character (buffer
, ')');
1532 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1535 pp_string (buffer
, " [static-chain: ");
1536 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1537 pp_character (buffer
, ']');
1540 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1541 pp_string (buffer
, " [return slot optimization]");
1542 if (CALL_EXPR_TAILCALL (node
))
1543 pp_string (buffer
, " [tail call]");
1546 case WITH_CLEANUP_EXPR
:
1550 case CLEANUP_POINT_EXPR
:
1551 pp_string (buffer
, "<<cleanup_point ");
1552 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1553 pp_string (buffer
, ">>");
1556 case PLACEHOLDER_EXPR
:
1557 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1558 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1559 pp_character (buffer
, '>');
1562 /* Binary arithmetic and logic expressions. */
1563 case WIDEN_SUM_EXPR
:
1564 case WIDEN_MULT_EXPR
:
1567 case POINTER_PLUS_EXPR
:
1569 case TRUNC_DIV_EXPR
:
1571 case FLOOR_DIV_EXPR
:
1572 case ROUND_DIV_EXPR
:
1573 case TRUNC_MOD_EXPR
:
1575 case FLOOR_MOD_EXPR
:
1576 case ROUND_MOD_EXPR
:
1578 case EXACT_DIV_EXPR
:
1583 case VEC_LSHIFT_EXPR
:
1584 case VEC_RSHIFT_EXPR
:
1588 case TRUTH_ANDIF_EXPR
:
1589 case TRUTH_ORIF_EXPR
:
1590 case TRUTH_AND_EXPR
:
1592 case TRUTH_XOR_EXPR
:
1606 case UNORDERED_EXPR
:
1608 const char *op
= op_symbol (node
);
1609 op0
= TREE_OPERAND (node
, 0);
1610 op1
= TREE_OPERAND (node
, 1);
1612 /* When the operands are expressions with less priority,
1613 keep semantics of the tree representation. */
1614 if (op_prio (op0
) <= op_prio (node
))
1616 pp_character (buffer
, '(');
1617 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1618 pp_character (buffer
, ')');
1621 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1624 pp_string (buffer
, op
);
1627 /* When the operands are expressions with less priority,
1628 keep semantics of the tree representation. */
1629 if (op_prio (op1
) <= op_prio (node
))
1631 pp_character (buffer
, '(');
1632 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1633 pp_character (buffer
, ')');
1636 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1640 /* Unary arithmetic and logic expressions. */
1643 case TRUTH_NOT_EXPR
:
1645 case PREDECREMENT_EXPR
:
1646 case PREINCREMENT_EXPR
:
1648 if (TREE_CODE (node
) == ADDR_EXPR
1649 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1650 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1651 ; /* Do not output '&' for strings and function pointers. */
1653 pp_string (buffer
, op_symbol (node
));
1655 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1657 pp_character (buffer
, '(');
1658 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1659 pp_character (buffer
, ')');
1662 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1665 case POSTDECREMENT_EXPR
:
1666 case POSTINCREMENT_EXPR
:
1667 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1669 pp_character (buffer
, '(');
1670 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1671 pp_character (buffer
, ')');
1674 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1675 pp_string (buffer
, op_symbol (node
));
1679 pp_string (buffer
, "MIN_EXPR <");
1680 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1681 pp_string (buffer
, ", ");
1682 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1683 pp_character (buffer
, '>');
1687 pp_string (buffer
, "MAX_EXPR <");
1688 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1689 pp_string (buffer
, ", ");
1690 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1691 pp_character (buffer
, '>');
1695 pp_string (buffer
, "ABS_EXPR <");
1696 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1697 pp_character (buffer
, '>');
1704 case ADDR_SPACE_CONVERT_EXPR
:
1705 case FIXED_CONVERT_EXPR
:
1706 case FIX_TRUNC_EXPR
:
1709 type
= TREE_TYPE (node
);
1710 op0
= TREE_OPERAND (node
, 0);
1711 if (type
!= TREE_TYPE (op0
))
1713 pp_character (buffer
, '(');
1714 dump_generic_node (buffer
, type
, spc
, flags
, false);
1715 pp_string (buffer
, ") ");
1717 if (op_prio (op0
) < op_prio (node
))
1718 pp_character (buffer
, '(');
1719 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1720 if (op_prio (op0
) < op_prio (node
))
1721 pp_character (buffer
, ')');
1724 case VIEW_CONVERT_EXPR
:
1725 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1726 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1727 pp_string (buffer
, ">(");
1728 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1729 pp_character (buffer
, ')');
1733 pp_string (buffer
, "((");
1734 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1735 pp_string (buffer
, "))");
1738 case NON_LVALUE_EXPR
:
1739 pp_string (buffer
, "NON_LVALUE_EXPR <");
1740 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1741 pp_character (buffer
, '>');
1745 pp_string (buffer
, "SAVE_EXPR <");
1746 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1747 pp_character (buffer
, '>');
1751 pp_string (buffer
, "COMPLEX_EXPR <");
1752 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1753 pp_string (buffer
, ", ");
1754 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1755 pp_string (buffer
, ">");
1759 pp_string (buffer
, "CONJ_EXPR <");
1760 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1761 pp_string (buffer
, ">");
1765 pp_string (buffer
, "REALPART_EXPR <");
1766 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1767 pp_string (buffer
, ">");
1771 pp_string (buffer
, "IMAGPART_EXPR <");
1772 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1773 pp_string (buffer
, ">");
1777 pp_string (buffer
, "VA_ARG_EXPR <");
1778 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1779 pp_string (buffer
, ">");
1782 case TRY_FINALLY_EXPR
:
1783 case TRY_CATCH_EXPR
:
1784 pp_string (buffer
, "try");
1785 newline_and_indent (buffer
, spc
+2);
1786 pp_string (buffer
, "{");
1787 newline_and_indent (buffer
, spc
+4);
1788 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1789 newline_and_indent (buffer
, spc
+2);
1790 pp_string (buffer
, "}");
1791 newline_and_indent (buffer
, spc
);
1793 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1794 newline_and_indent (buffer
, spc
+2);
1795 pp_string (buffer
, "{");
1796 newline_and_indent (buffer
, spc
+4);
1797 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1798 newline_and_indent (buffer
, spc
+2);
1799 pp_string (buffer
, "}");
1804 pp_string (buffer
, "catch (");
1805 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1806 pp_string (buffer
, ")");
1807 newline_and_indent (buffer
, spc
+2);
1808 pp_string (buffer
, "{");
1809 newline_and_indent (buffer
, spc
+4);
1810 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1811 newline_and_indent (buffer
, spc
+2);
1812 pp_string (buffer
, "}");
1816 case EH_FILTER_EXPR
:
1817 pp_string (buffer
, "<<<eh_filter (");
1818 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1819 pp_string (buffer
, ")>>>");
1820 newline_and_indent (buffer
, spc
+2);
1821 pp_string (buffer
, "{");
1822 newline_and_indent (buffer
, spc
+4);
1823 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1824 newline_and_indent (buffer
, spc
+2);
1825 pp_string (buffer
, "}");
1830 op0
= TREE_OPERAND (node
, 0);
1831 /* If this is for break or continue, don't bother printing it. */
1832 if (DECL_NAME (op0
))
1834 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1835 if (strcmp (name
, "break") == 0
1836 || strcmp (name
, "continue") == 0)
1839 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1840 pp_character (buffer
, ':');
1841 if (DECL_NONLOCAL (op0
))
1842 pp_string (buffer
, " [non-local]");
1846 pp_string (buffer
, "while (1)");
1847 if (!(flags
& TDF_SLIM
))
1849 newline_and_indent (buffer
, spc
+2);
1850 pp_character (buffer
, '{');
1851 newline_and_indent (buffer
, spc
+4);
1852 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1853 newline_and_indent (buffer
, spc
+2);
1854 pp_character (buffer
, '}');
1860 pp_string (buffer
, "// predicted ");
1861 if (PREDICT_EXPR_OUTCOME (node
))
1862 pp_string (buffer
, "likely by ");
1864 pp_string (buffer
, "unlikely by ");
1865 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
1866 pp_string (buffer
, " predictor.");
1870 pp_string (buffer
, "return");
1871 op0
= TREE_OPERAND (node
, 0);
1875 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1876 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
1879 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1884 pp_string (buffer
, "if (");
1885 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1886 pp_string (buffer
, ") break");
1890 pp_string (buffer
, "switch (");
1891 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1892 pp_character (buffer
, ')');
1893 if (!(flags
& TDF_SLIM
))
1895 newline_and_indent (buffer
, spc
+2);
1896 pp_character (buffer
, '{');
1897 if (SWITCH_BODY (node
))
1899 newline_and_indent (buffer
, spc
+4);
1900 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1905 tree vec
= SWITCH_LABELS (node
);
1906 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1907 for (i
= 0; i
< n
; ++i
)
1909 tree elt
= TREE_VEC_ELT (vec
, i
);
1910 newline_and_indent (buffer
, spc
+4);
1913 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1914 pp_string (buffer
, " goto ");
1915 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1917 pp_semicolon (buffer
);
1920 pp_string (buffer
, "case ???: goto ???;");
1923 newline_and_indent (buffer
, spc
+2);
1924 pp_character (buffer
, '}');
1930 op0
= GOTO_DESTINATION (node
);
1931 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1933 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1934 if (strcmp (name
, "break") == 0
1935 || strcmp (name
, "continue") == 0)
1937 pp_string (buffer
, name
);
1941 pp_string (buffer
, "goto ");
1942 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1946 pp_string (buffer
, "__asm__");
1947 if (ASM_VOLATILE_P (node
))
1948 pp_string (buffer
, " __volatile__");
1949 pp_character (buffer
, '(');
1950 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1951 pp_character (buffer
, ':');
1952 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1953 pp_character (buffer
, ':');
1954 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1955 if (ASM_CLOBBERS (node
))
1957 pp_character (buffer
, ':');
1958 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1960 pp_string (buffer
, ")");
1963 case CASE_LABEL_EXPR
:
1964 if (CASE_LOW (node
) && CASE_HIGH (node
))
1966 pp_string (buffer
, "case ");
1967 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1968 pp_string (buffer
, " ... ");
1969 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1971 else if (CASE_LOW (node
))
1973 pp_string (buffer
, "case ");
1974 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1977 pp_string (buffer
, "default");
1978 pp_character (buffer
, ':');
1982 pp_string (buffer
, "OBJ_TYPE_REF(");
1983 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1984 pp_character (buffer
, ';');
1985 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1986 pp_character (buffer
, '-');
1987 pp_character (buffer
, '>');
1988 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
1989 pp_character (buffer
, ')');
1993 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
1994 pp_string (buffer
, "_");
1995 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1996 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
1997 pp_string (buffer
, "(ab)");
1998 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
1999 pp_string (buffer
, "(D)");
2002 case WITH_SIZE_EXPR
:
2003 pp_string (buffer
, "WITH_SIZE_EXPR <");
2004 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2005 pp_string (buffer
, ", ");
2006 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2007 pp_string (buffer
, ">");
2011 pp_string (buffer
, "ASSERT_EXPR <");
2012 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
2013 pp_string (buffer
, ", ");
2014 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
2015 pp_string (buffer
, ">");
2019 pp_string (buffer
, "scev_known");
2022 case SCEV_NOT_KNOWN
:
2023 pp_string (buffer
, "scev_not_known");
2026 case POLYNOMIAL_CHREC
:
2027 pp_string (buffer
, "{");
2028 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
2029 pp_string (buffer
, ", +, ");
2030 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
2031 pp_string (buffer
, "}_");
2032 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
2036 case REALIGN_LOAD_EXPR
:
2037 pp_string (buffer
, "REALIGN_LOAD <");
2038 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2039 pp_string (buffer
, ", ");
2040 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2041 pp_string (buffer
, ", ");
2042 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2043 pp_string (buffer
, ">");
2047 pp_string (buffer
, " VEC_COND_EXPR < ");
2048 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2049 pp_string (buffer
, " , ");
2050 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2051 pp_string (buffer
, " , ");
2052 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2053 pp_string (buffer
, " > ");
2057 pp_string (buffer
, " DOT_PROD_EXPR < ");
2058 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2059 pp_string (buffer
, ", ");
2060 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2061 pp_string (buffer
, ", ");
2062 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2063 pp_string (buffer
, " > ");
2066 case WIDEN_MULT_PLUS_EXPR
:
2067 pp_string (buffer
, " WIDEN_MULT_PLUS_EXPR < ");
2068 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2069 pp_string (buffer
, ", ");
2070 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2071 pp_string (buffer
, ", ");
2072 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2073 pp_string (buffer
, " > ");
2076 case WIDEN_MULT_MINUS_EXPR
:
2077 pp_string (buffer
, " WIDEN_MULT_MINUS_EXPR < ");
2078 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2079 pp_string (buffer
, ", ");
2080 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2081 pp_string (buffer
, ", ");
2082 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2083 pp_string (buffer
, " > ");
2087 pp_string (buffer
, " FMA_EXPR < ");
2088 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2089 pp_string (buffer
, ", ");
2090 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2091 pp_string (buffer
, ", ");
2092 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2093 pp_string (buffer
, " > ");
2097 pp_string (buffer
, "#pragma omp parallel");
2098 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
2101 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
2103 newline_and_indent (buffer
, spc
+ 2);
2104 pp_character (buffer
, '{');
2105 newline_and_indent (buffer
, spc
+ 4);
2106 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
2107 newline_and_indent (buffer
, spc
+ 2);
2108 pp_character (buffer
, '}');
2114 pp_string (buffer
, "#pragma omp task");
2115 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
2119 pp_string (buffer
, "#pragma omp for");
2120 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
2122 if (!(flags
& TDF_SLIM
))
2126 if (OMP_FOR_PRE_BODY (node
))
2128 newline_and_indent (buffer
, spc
+ 2);
2129 pp_character (buffer
, '{');
2131 newline_and_indent (buffer
, spc
);
2132 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
2136 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
2139 newline_and_indent (buffer
, spc
);
2140 pp_string (buffer
, "for (");
2141 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
2143 pp_string (buffer
, "; ");
2144 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
2146 pp_string (buffer
, "; ");
2147 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
2149 pp_string (buffer
, ")");
2151 if (OMP_FOR_BODY (node
))
2153 newline_and_indent (buffer
, spc
+ 2);
2154 pp_character (buffer
, '{');
2155 newline_and_indent (buffer
, spc
+ 4);
2156 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
2158 newline_and_indent (buffer
, spc
+ 2);
2159 pp_character (buffer
, '}');
2161 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
2162 if (OMP_FOR_PRE_BODY (node
))
2165 newline_and_indent (buffer
, spc
+ 2);
2166 pp_character (buffer
, '}');
2173 pp_string (buffer
, "#pragma omp sections");
2174 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2178 pp_string (buffer
, "#pragma omp section");
2182 pp_string (buffer
, "#pragma omp master");
2186 pp_string (buffer
, "#pragma omp ordered");
2190 pp_string (buffer
, "#pragma omp critical");
2191 if (OMP_CRITICAL_NAME (node
))
2194 pp_character (buffer
, '(');
2195 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2197 pp_character (buffer
, ')');
2202 pp_string (buffer
, "#pragma omp atomic");
2203 newline_and_indent (buffer
, spc
+ 2);
2204 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2206 pp_character (buffer
, '=');
2208 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2212 pp_string (buffer
, "#pragma omp single");
2213 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2217 dump_omp_clause (buffer
, node
, spc
, flags
);
2221 case REDUC_MAX_EXPR
:
2222 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2223 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2224 pp_string (buffer
, " > ");
2227 case REDUC_MIN_EXPR
:
2228 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2229 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2230 pp_string (buffer
, " > ");
2233 case REDUC_PLUS_EXPR
:
2234 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2235 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2236 pp_string (buffer
, " > ");
2239 case VEC_WIDEN_MULT_HI_EXPR
:
2240 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
2241 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2242 pp_string (buffer
, ", ");
2243 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2244 pp_string (buffer
, " > ");
2247 case VEC_WIDEN_MULT_LO_EXPR
:
2248 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
2249 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2250 pp_string (buffer
, ", ");
2251 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2252 pp_string (buffer
, " > ");
2255 case VEC_UNPACK_HI_EXPR
:
2256 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2257 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2258 pp_string (buffer
, " > ");
2261 case VEC_UNPACK_LO_EXPR
:
2262 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2263 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2264 pp_string (buffer
, " > ");
2267 case VEC_UNPACK_FLOAT_HI_EXPR
:
2268 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2269 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2270 pp_string (buffer
, " > ");
2273 case VEC_UNPACK_FLOAT_LO_EXPR
:
2274 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2275 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2276 pp_string (buffer
, " > ");
2279 case VEC_PACK_TRUNC_EXPR
:
2280 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2281 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2282 pp_string (buffer
, ", ");
2283 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2284 pp_string (buffer
, " > ");
2287 case VEC_PACK_SAT_EXPR
:
2288 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2289 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2290 pp_string (buffer
, ", ");
2291 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2292 pp_string (buffer
, " > ");
2295 case VEC_PACK_FIX_TRUNC_EXPR
:
2296 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2297 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2298 pp_string (buffer
, ", ");
2299 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2300 pp_string (buffer
, " > ");
2304 dump_block_node (buffer
, node
, spc
, flags
);
2307 case VEC_EXTRACT_EVEN_EXPR
:
2308 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2309 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2310 pp_string (buffer
, ", ");
2311 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2312 pp_string (buffer
, " > ");
2315 case VEC_EXTRACT_ODD_EXPR
:
2316 pp_string (buffer
, " VEC_EXTRACT_ODD_EXPR < ");
2317 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2318 pp_string (buffer
, ", ");
2319 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2320 pp_string (buffer
, " > ");
2323 case VEC_INTERLEAVE_HIGH_EXPR
:
2324 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_EXPR < ");
2325 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2326 pp_string (buffer
, ", ");
2327 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2328 pp_string (buffer
, " > ");
2331 case VEC_INTERLEAVE_LOW_EXPR
:
2332 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2333 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2334 pp_string (buffer
, ", ");
2335 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2336 pp_string (buffer
, " > ");
2343 if (is_stmt
&& is_expr
)
2344 pp_semicolon (buffer
);
2346 /* If we're building a diagnostic, the formatted text will be written
2347 into BUFFER's stream by the caller; otherwise, write it now. */
2348 if (!(flags
& TDF_DIAGNOSTIC
))
2349 pp_write_text_to_stream (buffer
);
2354 /* Print the declaration of a variable. */
2357 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2361 if (TREE_CODE (t
) == TYPE_DECL
)
2362 pp_string (buffer
, "typedef ");
2364 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2365 pp_string (buffer
, "register ");
2367 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2368 pp_string (buffer
, "extern ");
2369 else if (TREE_STATIC (t
))
2370 pp_string (buffer
, "static ");
2372 /* Print the type and name. */
2373 if (TREE_TYPE (t
) && TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2377 /* Print array's type. */
2378 tmp
= TREE_TYPE (t
);
2379 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2380 tmp
= TREE_TYPE (tmp
);
2381 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2383 /* Print variable's name. */
2385 dump_generic_node (buffer
, t
, spc
, flags
, false);
2387 /* Print the dimensions. */
2388 tmp
= TREE_TYPE (t
);
2389 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2391 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2392 tmp
= TREE_TYPE (tmp
);
2395 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2397 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2399 dump_decl_name (buffer
, t
, flags
);
2400 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2404 /* Print type declaration. */
2405 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2407 /* Print variable's name. */
2409 dump_generic_node (buffer
, t
, spc
, flags
, false);
2412 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2414 pp_string (buffer
, " __asm__ ");
2415 pp_character (buffer
, '(');
2416 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2417 pp_character (buffer
, ')');
2420 /* The initial value of a function serves to determine whether the function
2421 is declared or defined. So the following does not apply to function
2423 if (TREE_CODE (t
) != FUNCTION_DECL
)
2425 /* Print the initial value. */
2426 if (DECL_INITIAL (t
))
2429 pp_character (buffer
, '=');
2431 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2435 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2437 pp_string (buffer
, " [value-expr: ");
2438 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2439 pp_character (buffer
, ']');
2442 pp_character (buffer
, ';');
2446 /* Prints a structure: name, fields, and methods.
2447 FIXME: Still incomplete. */
2450 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2452 /* Print the name of the structure. */
2453 if (TYPE_NAME (node
))
2456 if (TREE_CODE (node
) == RECORD_TYPE
)
2457 pp_string (buffer
, "struct ");
2458 else if ((TREE_CODE (node
) == UNION_TYPE
2459 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2460 pp_string (buffer
, "union ");
2462 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2465 /* Print the contents of the structure. */
2466 pp_newline (buffer
);
2468 pp_character (buffer
, '{');
2469 pp_newline (buffer
);
2471 /* Print the fields of the structure. */
2474 tmp
= TYPE_FIELDS (node
);
2477 /* Avoid to print recursively the structure. */
2478 /* FIXME : Not implemented correctly...,
2479 what about the case when we have a cycle in the contain graph? ...
2480 Maybe this could be solved by looking at the scope in which the
2481 structure was declared. */
2482 if (TREE_TYPE (tmp
) != node
2483 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2484 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2486 print_declaration (buffer
, tmp
, spc
+2, flags
);
2487 pp_newline (buffer
);
2489 tmp
= DECL_CHAIN (tmp
);
2493 pp_character (buffer
, '}');
2496 /* Return the priority of the operator CODE.
2498 From lowest to highest precedence with either left-to-right (L-R)
2499 or right-to-left (R-L) associativity]:
2502 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2514 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2515 15 [L-R] fn() [] -> .
2517 unary +, - and * have higher precedence than the corresponding binary
2521 op_code_prio (enum tree_code code
)
2538 case TRUTH_ORIF_EXPR
:
2541 case TRUTH_AND_EXPR
:
2542 case TRUTH_ANDIF_EXPR
:
2549 case TRUTH_XOR_EXPR
:
2566 case UNORDERED_EXPR
:
2579 case WIDEN_SUM_EXPR
:
2581 case POINTER_PLUS_EXPR
:
2585 case VEC_WIDEN_MULT_HI_EXPR
:
2586 case VEC_WIDEN_MULT_LO_EXPR
:
2587 case WIDEN_MULT_EXPR
:
2589 case WIDEN_MULT_PLUS_EXPR
:
2590 case WIDEN_MULT_MINUS_EXPR
:
2592 case TRUNC_DIV_EXPR
:
2594 case FLOOR_DIV_EXPR
:
2595 case ROUND_DIV_EXPR
:
2597 case EXACT_DIV_EXPR
:
2598 case TRUNC_MOD_EXPR
:
2600 case FLOOR_MOD_EXPR
:
2601 case ROUND_MOD_EXPR
:
2605 case TRUTH_NOT_EXPR
:
2607 case POSTINCREMENT_EXPR
:
2608 case POSTDECREMENT_EXPR
:
2609 case PREINCREMENT_EXPR
:
2610 case PREDECREMENT_EXPR
:
2616 case FIX_TRUNC_EXPR
:
2622 case ARRAY_RANGE_REF
:
2626 /* Special expressions. */
2632 case REDUC_MAX_EXPR
:
2633 case REDUC_MIN_EXPR
:
2634 case REDUC_PLUS_EXPR
:
2635 case VEC_LSHIFT_EXPR
:
2636 case VEC_RSHIFT_EXPR
:
2637 case VEC_UNPACK_HI_EXPR
:
2638 case VEC_UNPACK_LO_EXPR
:
2639 case VEC_UNPACK_FLOAT_HI_EXPR
:
2640 case VEC_UNPACK_FLOAT_LO_EXPR
:
2641 case VEC_PACK_TRUNC_EXPR
:
2642 case VEC_PACK_SAT_EXPR
:
2646 /* Return an arbitrarily high precedence to avoid surrounding single
2647 VAR_DECLs in ()s. */
2652 /* Return the priority of the operator OP. */
2655 op_prio (const_tree op
)
2657 enum tree_code code
;
2662 code
= TREE_CODE (op
);
2663 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2664 return op_prio (TREE_OPERAND (op
, 0));
2666 return op_code_prio (code
);
2669 /* Return the symbol associated with operator CODE. */
2672 op_symbol_code (enum tree_code code
)
2680 case TRUTH_ORIF_EXPR
:
2683 case TRUTH_AND_EXPR
:
2684 case TRUTH_ANDIF_EXPR
:
2690 case TRUTH_XOR_EXPR
:
2700 case UNORDERED_EXPR
:
2746 case VEC_LSHIFT_EXPR
:
2749 case VEC_RSHIFT_EXPR
:
2752 case POINTER_PLUS_EXPR
:
2758 case REDUC_PLUS_EXPR
:
2761 case WIDEN_SUM_EXPR
:
2764 case WIDEN_MULT_EXPR
:
2774 case TRUTH_NOT_EXPR
:
2781 case TRUNC_DIV_EXPR
:
2788 case FLOOR_DIV_EXPR
:
2791 case ROUND_DIV_EXPR
:
2794 case EXACT_DIV_EXPR
:
2797 case TRUNC_MOD_EXPR
:
2803 case FLOOR_MOD_EXPR
:
2806 case ROUND_MOD_EXPR
:
2809 case PREDECREMENT_EXPR
:
2812 case PREINCREMENT_EXPR
:
2815 case POSTDECREMENT_EXPR
:
2818 case POSTINCREMENT_EXPR
:
2828 return "<<< ??? >>>";
2832 /* Return the symbol associated with operator OP. */
2835 op_symbol (const_tree op
)
2837 return op_symbol_code (TREE_CODE (op
));
2840 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2841 the gimple_call_fn of a GIMPLE_CALL. */
2844 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
2848 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2849 op0
= TREE_OPERAND (op0
, 0);
2852 switch (TREE_CODE (op0
))
2857 dump_function_name (buffer
, op0
, flags
);
2863 op0
= TREE_OPERAND (op0
, 0);
2867 pp_string (buffer
, "(");
2868 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
2869 pp_string (buffer
, ") ? ");
2870 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
2871 pp_string (buffer
, " : ");
2872 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
2876 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2877 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
2879 dump_generic_node (buffer
, op0
, 0, flags
, false);
2883 if (integer_zerop (TREE_OPERAND (op0
, 1)))
2885 op0
= TREE_OPERAND (op0
, 0);
2892 dump_generic_node (buffer
, op0
, 0, flags
, false);
2900 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2903 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2913 pp_string (buffer
, "\\b");
2917 pp_string (buffer
, "\\f");
2921 pp_string (buffer
, "\\n");
2925 pp_string (buffer
, "\\r");
2929 pp_string (buffer
, "\\t");
2933 pp_string (buffer
, "\\v");
2937 pp_string (buffer
, "\\\\");
2941 pp_string (buffer
, "\\\"");
2945 pp_string (buffer
, "\\'");
2948 /* No need to handle \0; the loop terminates on \0. */
2951 pp_string (buffer
, "\\1");
2955 pp_string (buffer
, "\\2");
2959 pp_string (buffer
, "\\3");
2963 pp_string (buffer
, "\\4");
2967 pp_string (buffer
, "\\5");
2971 pp_string (buffer
, "\\6");
2975 pp_string (buffer
, "\\7");
2979 pp_character (buffer
, str
[0]);
2987 maybe_init_pretty_print (FILE *file
)
2991 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
2992 pp_needs_newline (&buffer
) = true;
2993 pp_translate_identifiers (&buffer
) = false;
2997 buffer
.buffer
->stream
= file
;
3001 newline_and_indent (pretty_printer
*buffer
, int spc
)
3003 pp_newline (buffer
);
3007 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3008 it can also be used in front ends.
3009 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3013 percent_K_format (text_info
*text
)
3015 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
3016 gcc_assert (text
->locus
!= NULL
);
3017 *text
->locus
= EXPR_LOCATION (t
);
3018 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
3019 block
= TREE_BLOCK (t
);
3020 *pp_ti_abstract_origin (text
) = NULL
;
3022 && TREE_CODE (block
) == BLOCK
3023 && BLOCK_ABSTRACT_ORIGIN (block
))
3025 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
3027 while (TREE_CODE (ao
) == BLOCK
3028 && BLOCK_ABSTRACT_ORIGIN (ao
)
3029 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
3030 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
3032 if (TREE_CODE (ao
) == FUNCTION_DECL
)
3034 *pp_ti_abstract_origin (text
) = block
;
3037 block
= BLOCK_SUPERCONTEXT (block
);
3041 /* Print the identifier ID to PRETTY-PRINTER. */
3044 pp_base_tree_identifier (pretty_printer
*pp
, tree id
)
3046 if (pp_translate_identifiers (pp
))
3048 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
3049 pp_append_text (pp
, text
, text
+ strlen (text
));
3052 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
3053 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));
3056 /* A helper function that is used to dump function information before the
3060 dump_function_header (FILE *dump_file
, tree fdecl
, int flags
)
3062 const char *dname
, *aname
;
3063 struct cgraph_node
*node
= cgraph_get_node (fdecl
);
3064 struct function
*fun
= DECL_STRUCT_FUNCTION (fdecl
);
3066 dname
= lang_hooks
.decl_printable_name (fdecl
, 2);
3068 if (DECL_ASSEMBLER_NAME_SET_P (fdecl
))
3069 aname
= (IDENTIFIER_POINTER
3070 (DECL_ASSEMBLER_NAME (fdecl
)));
3072 aname
= "<unset-asm-name>";
3074 fprintf (dump_file
, "\n;; Function %s (%s, funcdef_no=%d",
3075 dname
, aname
, fun
->funcdef_no
);
3076 if (!(flags
& TDF_NOUID
))
3077 fprintf (dump_file
, ", decl_uid=%d", DECL_UID (fdecl
));
3080 fprintf (dump_file
, ", cgraph_uid=%d)%s\n\n", node
->uid
,
3081 node
->frequency
== NODE_FREQUENCY_HOT
3083 : node
->frequency
== NODE_FREQUENCY_UNLIKELY_EXECUTED
3084 ? " (unlikely executed)"
3085 : node
->frequency
== NODE_FREQUENCY_EXECUTED_ONCE
3086 ? " (executed once)"
3090 fprintf (dump_file
, ")\n\n");