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"
39 /* Local functions, macros and variables. */
40 static const char *op_symbol (const_tree
);
41 static void pretty_print_string (pretty_printer
*, const char*);
42 static void newline_and_indent (pretty_printer
*, int);
43 static void maybe_init_pretty_print (FILE *);
44 static void print_struct_decl (pretty_printer
*, const_tree
, int, int);
45 static void do_niy (pretty_printer
*, const_tree
);
47 #define INDENT(SPACE) do { \
48 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
50 #define NIY do_niy(buffer,node)
52 static pretty_printer buffer
;
53 static int initialized
= 0;
55 /* Try to print something for an unknown tree code. */
58 do_niy (pretty_printer
*buffer
, const_tree node
)
62 pp_string (buffer
, "<<< Unknown tree: ");
63 pp_string (buffer
, tree_code_name
[(int) TREE_CODE (node
)]);
67 len
= TREE_OPERAND_LENGTH (node
);
68 for (i
= 0; i
< len
; ++i
)
70 newline_and_indent (buffer
, 2);
71 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0, false);
75 pp_string (buffer
, " >>>");
78 /* Debugging function to print out a generic expression. */
81 debug_generic_expr (tree t
)
83 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
84 fprintf (stderr
, "\n");
87 /* Debugging function to print out a generic statement. */
90 debug_generic_stmt (tree t
)
92 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
93 fprintf (stderr
, "\n");
96 /* Debugging function to print out a chain of trees . */
99 debug_tree_chain (tree t
)
101 struct pointer_set_t
*seen
= pointer_set_create ();
105 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
106 fprintf (stderr
, " ");
108 if (pointer_set_insert (seen
, t
))
110 fprintf (stderr
, "... [cycled back to ");
111 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
112 fprintf (stderr
, "]");
116 fprintf (stderr
, "\n");
118 pointer_set_destroy (seen
);
121 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
123 print_generic_decl (FILE *file
, tree decl
, int flags
)
125 maybe_init_pretty_print (file
);
126 print_declaration (&buffer
, decl
, 2, flags
);
127 pp_write_text_to_stream (&buffer
);
130 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
131 to show in the dump. See TDF_* in tree-pass.h. */
134 print_generic_stmt (FILE *file
, tree t
, int flags
)
136 maybe_init_pretty_print (file
);
137 dump_generic_node (&buffer
, t
, 0, flags
, true);
141 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
142 to show in the dump. See TDF_* in tree-pass.h. The output is indented by
146 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
150 maybe_init_pretty_print (file
);
152 for (i
= 0; i
< indent
; i
++)
154 dump_generic_node (&buffer
, t
, indent
, flags
, true);
158 /* Print a single expression T on file FILE. FLAGS specifies details to show
159 in the dump. See TDF_* in tree-pass.h. */
162 print_generic_expr (FILE *file
, tree t
, int flags
)
164 maybe_init_pretty_print (file
);
165 dump_generic_node (&buffer
, t
, 0, flags
, false);
168 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
172 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
174 if (DECL_NAME (node
))
176 if ((flags
& TDF_ASMNAME
) && DECL_ASSEMBLER_NAME_SET_P (node
))
177 pp_tree_identifier (buffer
, DECL_ASSEMBLER_NAME (node
));
179 pp_tree_identifier (buffer
, DECL_NAME (node
));
181 if ((flags
& TDF_UID
) || DECL_NAME (node
) == NULL_TREE
)
183 if (TREE_CODE (node
) == LABEL_DECL
&& LABEL_DECL_UID (node
) != -1)
184 pp_printf (buffer
, "L.%d", (int) LABEL_DECL_UID (node
));
185 else if (TREE_CODE (node
) == DEBUG_EXPR_DECL
)
187 if (flags
& TDF_NOUID
)
188 pp_string (buffer
, "D#xxxx");
190 pp_printf (buffer
, "D#%i", DEBUG_TEMP_UID (node
));
194 char c
= TREE_CODE (node
) == CONST_DECL
? 'C' : 'D';
195 if (flags
& TDF_NOUID
)
196 pp_printf (buffer
, "%c.xxxx", c
);
198 pp_printf (buffer
, "%c.%u", c
, DECL_UID (node
));
201 if ((flags
& TDF_ALIAS
) && DECL_PT_UID (node
) != DECL_UID (node
))
203 if (flags
& TDF_NOUID
)
204 pp_printf (buffer
, "ptD.xxxx");
206 pp_printf (buffer
, "ptD.%u", DECL_PT_UID (node
));
210 /* Like the above, but used for pretty printing function calls. */
213 dump_function_name (pretty_printer
*buffer
, tree node
, int flags
)
215 if (TREE_CODE (node
) == NOP_EXPR
)
216 node
= TREE_OPERAND (node
, 0);
217 if (DECL_NAME (node
) && (flags
& TDF_ASMNAME
) == 0)
218 pp_string (buffer
, lang_hooks
.decl_printable_name (node
, 1));
220 dump_decl_name (buffer
, node
, flags
);
223 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
224 FLAGS are as in dump_generic_node. */
227 dump_function_declaration (pretty_printer
*buffer
, tree node
,
230 bool wrote_arg
= false;
234 pp_character (buffer
, '(');
236 /* Print the argument types. The last element in the list is a VOID_TYPE.
237 The following avoids printing the last element. */
238 arg
= TYPE_ARG_TYPES (node
);
239 while (arg
&& TREE_CHAIN (arg
) && arg
!= error_mark_node
)
242 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
243 arg
= TREE_CHAIN (arg
);
244 if (TREE_CHAIN (arg
) && TREE_CODE (TREE_CHAIN (arg
)) == TREE_LIST
)
246 pp_character (buffer
, ',');
252 pp_string (buffer
, "void");
254 pp_character (buffer
, ')');
257 /* Dump the domain associated with an array. */
260 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
262 pp_character (buffer
, '[');
265 tree min
= TYPE_MIN_VALUE (domain
);
266 tree max
= TYPE_MAX_VALUE (domain
);
269 && integer_zerop (min
)
270 && host_integerp (max
, 0))
271 pp_wide_integer (buffer
, TREE_INT_CST_LOW (max
) + 1);
275 dump_generic_node (buffer
, min
, spc
, flags
, false);
276 pp_character (buffer
, ':');
278 dump_generic_node (buffer
, max
, spc
, flags
, false);
282 pp_string (buffer
, "<unknown>");
283 pp_character (buffer
, ']');
287 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
288 dump_generic_node. */
291 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
295 switch (OMP_CLAUSE_CODE (clause
))
297 case OMP_CLAUSE_PRIVATE
:
300 case OMP_CLAUSE_SHARED
:
303 case OMP_CLAUSE_FIRSTPRIVATE
:
304 name
= "firstprivate";
306 case OMP_CLAUSE_LASTPRIVATE
:
307 name
= "lastprivate";
309 case OMP_CLAUSE_COPYIN
:
312 case OMP_CLAUSE_COPYPRIVATE
:
313 name
= "copyprivate";
316 pp_string (buffer
, name
);
317 pp_character (buffer
, '(');
318 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
320 pp_character (buffer
, ')');
323 case OMP_CLAUSE_REDUCTION
:
324 pp_string (buffer
, "reduction(");
325 pp_string (buffer
, op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
326 pp_character (buffer
, ':');
327 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
329 pp_character (buffer
, ')');
333 pp_string (buffer
, "if(");
334 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
336 pp_character (buffer
, ')');
339 case OMP_CLAUSE_NUM_THREADS
:
340 pp_string (buffer
, "num_threads(");
341 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
343 pp_character (buffer
, ')');
346 case OMP_CLAUSE_NOWAIT
:
347 pp_string (buffer
, "nowait");
349 case OMP_CLAUSE_ORDERED
:
350 pp_string (buffer
, "ordered");
353 case OMP_CLAUSE_DEFAULT
:
354 pp_string (buffer
, "default(");
355 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
357 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
359 case OMP_CLAUSE_DEFAULT_SHARED
:
360 pp_string (buffer
, "shared");
362 case OMP_CLAUSE_DEFAULT_NONE
:
363 pp_string (buffer
, "none");
365 case OMP_CLAUSE_DEFAULT_PRIVATE
:
366 pp_string (buffer
, "private");
368 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE
:
369 pp_string (buffer
, "firstprivate");
374 pp_character (buffer
, ')');
377 case OMP_CLAUSE_SCHEDULE
:
378 pp_string (buffer
, "schedule(");
379 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
381 case OMP_CLAUSE_SCHEDULE_STATIC
:
382 pp_string (buffer
, "static");
384 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
385 pp_string (buffer
, "dynamic");
387 case OMP_CLAUSE_SCHEDULE_GUIDED
:
388 pp_string (buffer
, "guided");
390 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
391 pp_string (buffer
, "runtime");
393 case OMP_CLAUSE_SCHEDULE_AUTO
:
394 pp_string (buffer
, "auto");
399 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
401 pp_character (buffer
, ',');
402 dump_generic_node (buffer
,
403 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
406 pp_character (buffer
, ')');
409 case OMP_CLAUSE_UNTIED
:
410 pp_string (buffer
, "untied");
413 case OMP_CLAUSE_COLLAPSE
:
414 pp_string (buffer
, "collapse(");
415 dump_generic_node (buffer
,
416 OMP_CLAUSE_COLLAPSE_EXPR (clause
),
418 pp_character (buffer
, ')');
422 /* Should never happen. */
423 dump_generic_node (buffer
, clause
, spc
, flags
, false);
429 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
430 dump_generic_node. */
433 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
441 dump_omp_clause (buffer
, clause
, spc
, flags
);
442 clause
= OMP_CLAUSE_CHAIN (clause
);
450 /* Dump location LOC to BUFFER. */
453 dump_location (pretty_printer
*buffer
, location_t loc
)
455 expanded_location xloc
= expand_location (loc
);
456 int discriminator
= get_discriminator_from_locus (loc
);
458 pp_character (buffer
, '[');
461 pp_string (buffer
, xloc
.file
);
462 pp_string (buffer
, " : ");
464 pp_decimal_int (buffer
, xloc
.line
);
467 pp_string (buffer
, " discrim ");
468 pp_decimal_int (buffer
, discriminator
);
470 pp_string (buffer
, "] ");
474 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
475 dump_generic_node. */
478 dump_block_node (pretty_printer
*buffer
, tree block
, int spc
, int flags
)
482 pp_printf (buffer
, "BLOCK #%d ", BLOCK_NUMBER (block
));
484 if (flags
& TDF_ADDRESS
)
485 pp_printf (buffer
, "[%p] ", (void *) block
);
487 if (BLOCK_ABSTRACT (block
))
488 pp_string (buffer
, "[abstract] ");
490 if (TREE_ASM_WRITTEN (block
))
491 pp_string (buffer
, "[written] ");
493 if (flags
& TDF_SLIM
)
496 if (BLOCK_SOURCE_LOCATION (block
))
497 dump_location (buffer
, BLOCK_SOURCE_LOCATION (block
));
499 newline_and_indent (buffer
, spc
+ 2);
501 if (BLOCK_SUPERCONTEXT (block
))
503 pp_string (buffer
, "SUPERCONTEXT: ");
504 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (block
), 0,
505 flags
| TDF_SLIM
, false);
506 newline_and_indent (buffer
, spc
+ 2);
509 if (BLOCK_SUBBLOCKS (block
))
511 pp_string (buffer
, "SUBBLOCKS: ");
512 for (t
= BLOCK_SUBBLOCKS (block
); t
; t
= BLOCK_CHAIN (t
))
514 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
515 pp_string (buffer
, " ");
517 newline_and_indent (buffer
, spc
+ 2);
520 if (BLOCK_CHAIN (block
))
522 pp_string (buffer
, "SIBLINGS: ");
523 for (t
= BLOCK_CHAIN (block
); t
; t
= BLOCK_CHAIN (t
))
525 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
526 pp_string (buffer
, " ");
528 newline_and_indent (buffer
, spc
+ 2);
531 if (BLOCK_VARS (block
))
533 pp_string (buffer
, "VARS: ");
534 for (t
= BLOCK_VARS (block
); t
; t
= TREE_CHAIN (t
))
536 dump_generic_node (buffer
, t
, 0, flags
, false);
537 pp_string (buffer
, " ");
539 newline_and_indent (buffer
, spc
+ 2);
542 if (VEC_length (tree
, BLOCK_NONLOCALIZED_VARS (block
)) > 0)
545 VEC(tree
,gc
) *nlv
= BLOCK_NONLOCALIZED_VARS (block
);
547 pp_string (buffer
, "NONLOCALIZED_VARS: ");
548 FOR_EACH_VEC_ELT (tree
, nlv
, i
, t
)
550 dump_generic_node (buffer
, t
, 0, flags
, false);
551 pp_string (buffer
, " ");
553 newline_and_indent (buffer
, spc
+ 2);
556 if (BLOCK_ABSTRACT_ORIGIN (block
))
558 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
559 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (block
), 0,
560 flags
| TDF_SLIM
, false);
561 newline_and_indent (buffer
, spc
+ 2);
564 if (BLOCK_FRAGMENT_ORIGIN (block
))
566 pp_string (buffer
, "FRAGMENT_ORIGIN: ");
567 dump_generic_node (buffer
, BLOCK_FRAGMENT_ORIGIN (block
), 0,
568 flags
| TDF_SLIM
, false);
569 newline_and_indent (buffer
, spc
+ 2);
572 if (BLOCK_FRAGMENT_CHAIN (block
))
574 pp_string (buffer
, "FRAGMENT_CHAIN: ");
575 for (t
= BLOCK_FRAGMENT_CHAIN (block
); t
; t
= BLOCK_FRAGMENT_CHAIN (t
))
577 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
578 pp_string (buffer
, " ");
580 newline_and_indent (buffer
, spc
+ 2);
585 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
586 indent. FLAGS specifies details to show in the dump (see TDF_* in
587 tree-pass.h). If IS_STMT is true, the object printed is considered
588 to be a statement and it is terminated by ';' if appropriate. */
591 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
599 if (node
== NULL_TREE
)
602 is_expr
= EXPR_P (node
);
604 if (is_stmt
&& (flags
& TDF_STMTADDR
))
605 pp_printf (buffer
, "<&%p> ", (void *)node
);
607 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
608 dump_location (buffer
, EXPR_LOCATION (node
));
610 switch (TREE_CODE (node
))
613 pp_string (buffer
, "<<< error >>>");
616 case IDENTIFIER_NODE
:
617 pp_tree_identifier (buffer
, node
);
621 while (node
&& node
!= error_mark_node
)
623 if (TREE_PURPOSE (node
))
625 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
628 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
629 node
= TREE_CHAIN (node
);
630 if (node
&& TREE_CODE (node
) == TREE_LIST
)
632 pp_character (buffer
, ',');
639 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
645 if (TREE_VEC_LENGTH (node
) > 0)
647 size_t len
= TREE_VEC_LENGTH (node
);
648 for (i
= 0; i
< len
- 1; i
++)
650 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
652 pp_character (buffer
, ',');
655 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
664 case FIXED_POINT_TYPE
:
670 unsigned int quals
= TYPE_QUALS (node
);
671 enum tree_code_class tclass
;
673 if (quals
& TYPE_QUAL_CONST
)
674 pp_string (buffer
, "const ");
675 else if (quals
& TYPE_QUAL_VOLATILE
)
676 pp_string (buffer
, "volatile ");
677 else if (quals
& TYPE_QUAL_RESTRICT
)
678 pp_string (buffer
, "restrict ");
680 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
682 pp_string (buffer
, "<address-space-");
683 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
684 pp_string (buffer
, "> ");
687 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
689 if (tclass
== tcc_declaration
)
691 if (DECL_NAME (node
))
692 dump_decl_name (buffer
, node
, flags
);
694 pp_string (buffer
, "<unnamed type decl>");
696 else if (tclass
== tcc_type
)
698 if (TYPE_NAME (node
))
700 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
701 pp_tree_identifier (buffer
, TYPE_NAME (node
));
702 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
703 && DECL_NAME (TYPE_NAME (node
)))
704 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
706 pp_string (buffer
, "<unnamed type>");
708 else if (TREE_CODE (node
) == VECTOR_TYPE
)
710 pp_string (buffer
, "vector");
711 pp_character (buffer
, '(');
712 pp_wide_integer (buffer
, TYPE_VECTOR_SUBPARTS (node
));
713 pp_string (buffer
, ") ");
714 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
716 else if (TREE_CODE (node
) == INTEGER_TYPE
)
718 pp_string (buffer
, (TYPE_UNSIGNED (node
)
719 ? "<unnamed-unsigned:"
720 : "<unnamed-signed:"));
721 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
722 pp_string (buffer
, ">");
724 else if (TREE_CODE (node
) == COMPLEX_TYPE
)
726 pp_string (buffer
, "__complex__ ");
727 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
729 else if (TREE_CODE (node
) == REAL_TYPE
)
731 pp_string (buffer
, "<float:");
732 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
733 pp_string (buffer
, ">");
735 else if (TREE_CODE (node
) == FIXED_POINT_TYPE
)
737 pp_string (buffer
, "<fixed-point-");
738 pp_string (buffer
, TYPE_SATURATING (node
) ? "sat:" : "nonsat:");
739 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
740 pp_string (buffer
, ">");
742 else if (TREE_CODE (node
) == VOID_TYPE
)
743 pp_string (buffer
, "void");
745 pp_string (buffer
, "<unnamed type>");
752 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
754 if (TREE_TYPE (node
) == NULL
)
756 pp_string (buffer
, str
);
757 pp_string (buffer
, "<null type>");
759 else if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
761 tree fnode
= TREE_TYPE (node
);
763 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
765 pp_character (buffer
, '(');
766 pp_string (buffer
, str
);
767 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
768 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
769 else if (flags
& TDF_NOUID
)
770 pp_printf (buffer
, "<Txxxx>");
772 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
774 pp_character (buffer
, ')');
775 dump_function_declaration (buffer
, fnode
, spc
, flags
);
779 unsigned int quals
= TYPE_QUALS (node
);
781 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
783 pp_string (buffer
, str
);
785 if (quals
& TYPE_QUAL_CONST
)
786 pp_string (buffer
, " const");
787 if (quals
& TYPE_QUAL_VOLATILE
)
788 pp_string (buffer
, " volatile");
789 if (quals
& TYPE_QUAL_RESTRICT
)
790 pp_string (buffer
, " restrict");
792 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
794 pp_string (buffer
, " <address-space-");
795 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
796 pp_string (buffer
, ">");
799 if (TYPE_REF_CAN_ALIAS_ALL (node
))
800 pp_string (buffer
, " {ref-all}");
810 if (integer_zerop (TREE_OPERAND (node
, 1))
811 /* Dump the types of INTEGER_CSTs explicitly, for we can't
812 infer them and MEM_ATTR caching will share MEM_REFs
813 with differently-typed op0s. */
814 && TREE_CODE (TREE_OPERAND (node
, 0)) != INTEGER_CST
815 /* Same pointer types, but ignoring POINTER_TYPE vs.
817 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 0)))
818 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))
819 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 0)))
820 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 1))))
821 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 0)))
822 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 1))))
823 /* Same value types ignoring qualifiers. */
824 && (TYPE_MAIN_VARIANT (TREE_TYPE (node
))
826 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))))
828 if (TREE_CODE (TREE_OPERAND (node
, 0)) != ADDR_EXPR
)
830 pp_string (buffer
, "*");
831 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
835 dump_generic_node (buffer
,
836 TREE_OPERAND (TREE_OPERAND (node
, 0), 0),
843 pp_string (buffer
, "MEM[");
844 pp_string (buffer
, "(");
845 ptype
= TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node
, 1)));
846 dump_generic_node (buffer
, ptype
,
847 spc
, flags
| TDF_SLIM
, false);
848 pp_string (buffer
, ")");
849 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
851 if (!integer_zerop (TREE_OPERAND (node
, 1)))
853 pp_string (buffer
, " + ");
854 dump_generic_node (buffer
, TREE_OPERAND (node
, 1),
857 pp_string (buffer
, "]");
864 const char *sep
= "";
867 pp_string (buffer
, "MEM[");
869 if (TREE_CODE (TMR_BASE (node
)) == ADDR_EXPR
)
871 pp_string (buffer
, sep
);
873 pp_string (buffer
, "symbol: ");
874 dump_generic_node (buffer
, TREE_OPERAND (TMR_BASE (node
), 0),
879 pp_string (buffer
, sep
);
881 pp_string (buffer
, "base: ");
882 dump_generic_node (buffer
, TMR_BASE (node
), spc
, flags
, false);
884 tmp
= TMR_INDEX2 (node
);
887 pp_string (buffer
, sep
);
889 pp_string (buffer
, "base: ");
890 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
892 tmp
= TMR_INDEX (node
);
895 pp_string (buffer
, sep
);
897 pp_string (buffer
, "index: ");
898 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
900 tmp
= TMR_STEP (node
);
903 pp_string (buffer
, sep
);
905 pp_string (buffer
, "step: ");
906 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
908 tmp
= TMR_OFFSET (node
);
911 pp_string (buffer
, sep
);
913 pp_string (buffer
, "offset: ");
914 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
916 pp_string (buffer
, "]");
924 /* Print the innermost component type. */
925 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
926 tmp
= TREE_TYPE (tmp
))
928 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
930 /* Print the dimensions. */
931 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
932 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
938 case QUAL_UNION_TYPE
:
940 unsigned int quals
= TYPE_QUALS (node
);
942 if (quals
& TYPE_QUAL_CONST
)
943 pp_string (buffer
, "const ");
944 if (quals
& TYPE_QUAL_VOLATILE
)
945 pp_string (buffer
, "volatile ");
947 /* Print the name of the structure. */
948 if (TREE_CODE (node
) == RECORD_TYPE
)
949 pp_string (buffer
, "struct ");
950 else if (TREE_CODE (node
) == UNION_TYPE
)
951 pp_string (buffer
, "union ");
953 if (TYPE_NAME (node
))
954 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
955 else if (!(flags
& TDF_SLIM
))
956 /* FIXME: If we eliminate the 'else' above and attempt
957 to show the fields for named types, we may get stuck
958 following a cycle of pointers to structs. The alleged
959 self-reference check in print_struct_decl will not detect
960 cycles involving more than one pointer or struct type. */
961 print_struct_decl (buffer
, node
, spc
, flags
);
970 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
972 /* In the case of a pointer, one may want to divide by the
973 size of the pointed-to type. Unfortunately, this not
974 straightforward. The C front-end maps expressions
979 in such a way that the two INTEGER_CST nodes for "5" have
980 different values but identical types. In the latter
981 case, the 5 is multiplied by sizeof (int) in c-common.c
982 (pointer_int_sum) to convert it to a byte address, and
983 yet the type of the node is left unchanged. Argh. What
984 is consistent though is that the number value corresponds
985 to bytes (UNITS) offset.
987 NB: Neither of the following divisors can be trivially
988 used to recover the original literal:
990 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
991 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
992 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
993 pp_string (buffer
, "B"); /* pseudo-unit */
995 else if (! host_integerp (node
, 0))
998 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (val
);
999 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (val
);
1001 if (tree_int_cst_sgn (val
) < 0)
1003 pp_character (buffer
, '-');
1004 high
= ~high
+ !low
;
1007 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
1009 sprintf (pp_buffer (buffer
)->digit_buffer
,
1010 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
1011 (unsigned HOST_WIDE_INT
) high
, low
);
1012 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
1015 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1019 /* Code copied from print_node. */
1022 if (TREE_OVERFLOW (node
))
1023 pp_string (buffer
, " overflow");
1025 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1026 d
= TREE_REAL_CST (node
);
1027 if (REAL_VALUE_ISINF (d
))
1028 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
1029 else if (REAL_VALUE_ISNAN (d
))
1030 pp_string (buffer
, " Nan");
1034 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
1035 pp_string (buffer
, string
);
1040 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
1041 pp_string (buffer
, "0x");
1042 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
1043 output_formatted_integer (buffer
, "%02x", *p
++);
1052 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
1053 pp_string (buffer
, string
);
1058 pp_string (buffer
, "__complex__ (");
1059 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
1060 pp_string (buffer
, ", ");
1061 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
1062 pp_string (buffer
, ")");
1066 pp_string (buffer
, "\"");
1067 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
1068 pp_string (buffer
, "\"");
1074 pp_string (buffer
, "{ ");
1075 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
1077 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
, false);
1078 if (TREE_CHAIN (elt
))
1079 pp_string (buffer
, ", ");
1081 pp_string (buffer
, " }");
1087 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1089 if (TREE_CODE (node
) == METHOD_TYPE
)
1091 if (TYPE_METHOD_BASETYPE (node
))
1092 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
1095 pp_string (buffer
, "<null method basetype>");
1096 pp_string (buffer
, "::");
1098 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1099 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1100 else if (flags
& TDF_NOUID
)
1101 pp_printf (buffer
, "<Txxxx>");
1103 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1104 dump_function_declaration (buffer
, node
, spc
, flags
);
1109 dump_decl_name (buffer
, node
, flags
);
1113 if (DECL_NAME (node
))
1114 dump_decl_name (buffer
, node
, flags
);
1115 else if (LABEL_DECL_UID (node
) != -1)
1116 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1119 if (flags
& TDF_NOUID
)
1120 pp_string (buffer
, "<D.xxxx>");
1122 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1127 if (DECL_IS_BUILTIN (node
))
1129 /* Don't print the declaration of built-in types. */
1132 if (DECL_NAME (node
))
1133 dump_decl_name (buffer
, node
, flags
);
1134 else if (TYPE_NAME (TREE_TYPE (node
)) != node
)
1136 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1137 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1138 && TYPE_METHODS (TREE_TYPE (node
)))
1140 /* The type is a c++ class: all structures have at least
1142 pp_string (buffer
, "class ");
1143 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1148 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1149 ? "union" : "struct "));
1150 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1154 pp_string (buffer
, "<anon>");
1160 case DEBUG_EXPR_DECL
:
1161 case NAMESPACE_DECL
:
1162 dump_decl_name (buffer
, node
, flags
);
1166 pp_string (buffer
, "<retval>");
1170 op0
= TREE_OPERAND (node
, 0);
1173 && (TREE_CODE (op0
) == INDIRECT_REF
1174 || (TREE_CODE (op0
) == MEM_REF
1175 && TREE_CODE (TREE_OPERAND (op0
, 0)) != ADDR_EXPR
1176 && integer_zerop (TREE_OPERAND (op0
, 1))
1177 /* Dump the types of INTEGER_CSTs explicitly, for we
1178 can't infer them and MEM_ATTR caching will share
1179 MEM_REFs with differently-typed op0s. */
1180 && TREE_CODE (TREE_OPERAND (op0
, 0)) != INTEGER_CST
1181 /* Same pointer types, but ignoring POINTER_TYPE vs.
1183 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1184 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1185 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1186 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1187 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1188 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1189 /* Same value types ignoring qualifiers. */
1190 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0
))
1191 == TYPE_MAIN_VARIANT
1192 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))))))
1194 op0
= TREE_OPERAND (op0
, 0);
1197 if (op_prio (op0
) < op_prio (node
))
1198 pp_character (buffer
, '(');
1199 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1200 if (op_prio (op0
) < op_prio (node
))
1201 pp_character (buffer
, ')');
1202 pp_string (buffer
, str
);
1203 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1204 op0
= component_ref_field_offset (node
);
1205 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1207 pp_string (buffer
, "{off: ");
1208 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1209 pp_character (buffer
, '}');
1214 pp_string (buffer
, "BIT_FIELD_REF <");
1215 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1216 pp_string (buffer
, ", ");
1217 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1218 pp_string (buffer
, ", ");
1219 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1220 pp_string (buffer
, ">");
1224 case ARRAY_RANGE_REF
:
1225 op0
= TREE_OPERAND (node
, 0);
1226 if (op_prio (op0
) < op_prio (node
))
1227 pp_character (buffer
, '(');
1228 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1229 if (op_prio (op0
) < op_prio (node
))
1230 pp_character (buffer
, ')');
1231 pp_character (buffer
, '[');
1232 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1233 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1234 pp_string (buffer
, " ...");
1235 pp_character (buffer
, ']');
1237 op0
= array_ref_low_bound (node
);
1238 op1
= array_ref_element_size (node
);
1240 if (!integer_zerop (op0
)
1241 || TREE_OPERAND (node
, 2)
1242 || TREE_OPERAND (node
, 3))
1244 pp_string (buffer
, "{lb: ");
1245 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1246 pp_string (buffer
, " sz: ");
1247 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1248 pp_character (buffer
, '}');
1254 unsigned HOST_WIDE_INT ix
;
1256 bool is_struct_init
= FALSE
;
1257 pp_character (buffer
, '{');
1258 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1259 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1260 is_struct_init
= TRUE
;
1261 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1263 if (field
&& is_struct_init
)
1265 pp_character (buffer
, '.');
1266 dump_generic_node (buffer
, field
, spc
, flags
, false);
1267 pp_string (buffer
, "=");
1269 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1270 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1271 val
= TREE_OPERAND (val
, 0);
1272 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1273 dump_decl_name (buffer
, val
, flags
);
1275 dump_generic_node (buffer
, val
, spc
, flags
, false);
1276 if (ix
!= VEC_length (constructor_elt
, CONSTRUCTOR_ELTS (node
)) - 1)
1278 pp_character (buffer
, ',');
1282 pp_character (buffer
, '}');
1289 if (flags
& TDF_SLIM
)
1291 pp_string (buffer
, "<COMPOUND_EXPR>");
1295 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1296 spc
, flags
, !(flags
& TDF_SLIM
));
1297 if (flags
& TDF_SLIM
)
1298 newline_and_indent (buffer
, spc
);
1301 pp_character (buffer
, ',');
1305 for (tp
= &TREE_OPERAND (node
, 1);
1306 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1307 tp
= &TREE_OPERAND (*tp
, 1))
1309 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1310 spc
, flags
, !(flags
& TDF_SLIM
));
1311 if (flags
& TDF_SLIM
)
1312 newline_and_indent (buffer
, spc
);
1315 pp_character (buffer
, ',');
1320 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1324 case STATEMENT_LIST
:
1326 tree_stmt_iterator si
;
1329 if (flags
& TDF_SLIM
)
1331 pp_string (buffer
, "<STATEMENT_LIST>");
1335 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1338 newline_and_indent (buffer
, spc
);
1341 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1348 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1351 pp_character (buffer
, '=');
1352 if (TREE_CODE (node
) == MODIFY_EXPR
1353 && MOVE_NONTEMPORAL (node
))
1354 pp_string (buffer
, "{nt}");
1356 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1361 pp_string (buffer
, "TARGET_EXPR <");
1362 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1363 pp_character (buffer
, ',');
1365 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1366 pp_character (buffer
, '>');
1370 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1375 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1377 pp_string (buffer
, "if (");
1378 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1379 pp_character (buffer
, ')');
1380 /* The lowered cond_exprs should always be printed in full. */
1381 if (COND_EXPR_THEN (node
)
1382 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1383 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1384 && COND_EXPR_ELSE (node
)
1385 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1386 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1389 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1391 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1393 pp_string (buffer
, " else ");
1394 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1398 else if (!(flags
& TDF_SLIM
))
1400 /* Output COND_EXPR_THEN. */
1401 if (COND_EXPR_THEN (node
))
1403 newline_and_indent (buffer
, spc
+2);
1404 pp_character (buffer
, '{');
1405 newline_and_indent (buffer
, spc
+4);
1406 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1408 newline_and_indent (buffer
, spc
+2);
1409 pp_character (buffer
, '}');
1412 /* Output COND_EXPR_ELSE. */
1413 if (COND_EXPR_ELSE (node
)
1414 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1416 newline_and_indent (buffer
, spc
);
1417 pp_string (buffer
, "else");
1418 newline_and_indent (buffer
, spc
+2);
1419 pp_character (buffer
, '{');
1420 newline_and_indent (buffer
, spc
+4);
1421 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1423 newline_and_indent (buffer
, spc
+2);
1424 pp_character (buffer
, '}');
1431 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1433 pp_character (buffer
, '?');
1435 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1437 pp_character (buffer
, ':');
1439 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1444 pp_character (buffer
, '{');
1445 if (!(flags
& TDF_SLIM
))
1447 if (BIND_EXPR_VARS (node
))
1449 pp_newline (buffer
);
1451 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= DECL_CHAIN (op0
))
1453 print_declaration (buffer
, op0
, spc
+2, flags
);
1454 pp_newline (buffer
);
1458 newline_and_indent (buffer
, spc
+2);
1459 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1460 newline_and_indent (buffer
, spc
);
1461 pp_character (buffer
, '}');
1467 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1469 /* Print parameters. */
1471 pp_character (buffer
, '(');
1474 call_expr_arg_iterator iter
;
1475 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1477 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1478 if (more_call_expr_args_p (&iter
))
1480 pp_character (buffer
, ',');
1485 if (CALL_EXPR_VA_ARG_PACK (node
))
1487 if (call_expr_nargs (node
) > 0)
1489 pp_character (buffer
, ',');
1492 pp_string (buffer
, "__builtin_va_arg_pack ()");
1494 pp_character (buffer
, ')');
1496 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1499 pp_string (buffer
, " [static-chain: ");
1500 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1501 pp_character (buffer
, ']');
1504 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1505 pp_string (buffer
, " [return slot optimization]");
1506 if (CALL_EXPR_TAILCALL (node
))
1507 pp_string (buffer
, " [tail call]");
1510 case WITH_CLEANUP_EXPR
:
1514 case CLEANUP_POINT_EXPR
:
1515 pp_string (buffer
, "<<cleanup_point ");
1516 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1517 pp_string (buffer
, ">>");
1520 case PLACEHOLDER_EXPR
:
1521 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1522 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1523 pp_character (buffer
, '>');
1526 /* Binary arithmetic and logic expressions. */
1527 case WIDEN_SUM_EXPR
:
1528 case WIDEN_MULT_EXPR
:
1531 case POINTER_PLUS_EXPR
:
1533 case TRUNC_DIV_EXPR
:
1535 case FLOOR_DIV_EXPR
:
1536 case ROUND_DIV_EXPR
:
1537 case TRUNC_MOD_EXPR
:
1539 case FLOOR_MOD_EXPR
:
1540 case ROUND_MOD_EXPR
:
1542 case EXACT_DIV_EXPR
:
1547 case VEC_LSHIFT_EXPR
:
1548 case VEC_RSHIFT_EXPR
:
1552 case TRUTH_ANDIF_EXPR
:
1553 case TRUTH_ORIF_EXPR
:
1554 case TRUTH_AND_EXPR
:
1556 case TRUTH_XOR_EXPR
:
1570 case UNORDERED_EXPR
:
1572 const char *op
= op_symbol (node
);
1573 op0
= TREE_OPERAND (node
, 0);
1574 op1
= TREE_OPERAND (node
, 1);
1576 /* When the operands are expressions with less priority,
1577 keep semantics of the tree representation. */
1578 if (op_prio (op0
) <= op_prio (node
))
1580 pp_character (buffer
, '(');
1581 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1582 pp_character (buffer
, ')');
1585 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1588 pp_string (buffer
, op
);
1591 /* When the operands are expressions with less priority,
1592 keep semantics of the tree representation. */
1593 if (op_prio (op1
) <= op_prio (node
))
1595 pp_character (buffer
, '(');
1596 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1597 pp_character (buffer
, ')');
1600 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1604 /* Unary arithmetic and logic expressions. */
1607 case TRUTH_NOT_EXPR
:
1609 case PREDECREMENT_EXPR
:
1610 case PREINCREMENT_EXPR
:
1612 if (TREE_CODE (node
) == ADDR_EXPR
1613 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1614 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1615 ; /* Do not output '&' for strings and function pointers. */
1617 pp_string (buffer
, op_symbol (node
));
1619 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1621 pp_character (buffer
, '(');
1622 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1623 pp_character (buffer
, ')');
1626 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1629 case POSTDECREMENT_EXPR
:
1630 case POSTINCREMENT_EXPR
:
1631 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1633 pp_character (buffer
, '(');
1634 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1635 pp_character (buffer
, ')');
1638 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1639 pp_string (buffer
, op_symbol (node
));
1643 pp_string (buffer
, "MIN_EXPR <");
1644 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1645 pp_string (buffer
, ", ");
1646 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1647 pp_character (buffer
, '>');
1651 pp_string (buffer
, "MAX_EXPR <");
1652 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1653 pp_string (buffer
, ", ");
1654 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1655 pp_character (buffer
, '>');
1659 pp_string (buffer
, "ABS_EXPR <");
1660 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1661 pp_character (buffer
, '>');
1668 case ADDR_SPACE_CONVERT_EXPR
:
1669 case FIXED_CONVERT_EXPR
:
1670 case FIX_TRUNC_EXPR
:
1673 type
= TREE_TYPE (node
);
1674 op0
= TREE_OPERAND (node
, 0);
1675 if (type
!= TREE_TYPE (op0
))
1677 pp_character (buffer
, '(');
1678 dump_generic_node (buffer
, type
, spc
, flags
, false);
1679 pp_string (buffer
, ") ");
1681 if (op_prio (op0
) < op_prio (node
))
1682 pp_character (buffer
, '(');
1683 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1684 if (op_prio (op0
) < op_prio (node
))
1685 pp_character (buffer
, ')');
1688 case VIEW_CONVERT_EXPR
:
1689 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1690 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1691 pp_string (buffer
, ">(");
1692 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1693 pp_character (buffer
, ')');
1697 pp_string (buffer
, "((");
1698 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1699 pp_string (buffer
, "))");
1702 case NON_LVALUE_EXPR
:
1703 pp_string (buffer
, "NON_LVALUE_EXPR <");
1704 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1705 pp_character (buffer
, '>');
1709 pp_string (buffer
, "SAVE_EXPR <");
1710 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1711 pp_character (buffer
, '>');
1715 pp_string (buffer
, "COMPLEX_EXPR <");
1716 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1717 pp_string (buffer
, ", ");
1718 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1719 pp_string (buffer
, ">");
1723 pp_string (buffer
, "CONJ_EXPR <");
1724 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1725 pp_string (buffer
, ">");
1729 pp_string (buffer
, "REALPART_EXPR <");
1730 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1731 pp_string (buffer
, ">");
1735 pp_string (buffer
, "IMAGPART_EXPR <");
1736 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1737 pp_string (buffer
, ">");
1741 pp_string (buffer
, "VA_ARG_EXPR <");
1742 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1743 pp_string (buffer
, ">");
1746 case TRY_FINALLY_EXPR
:
1747 case TRY_CATCH_EXPR
:
1748 pp_string (buffer
, "try");
1749 newline_and_indent (buffer
, spc
+2);
1750 pp_string (buffer
, "{");
1751 newline_and_indent (buffer
, spc
+4);
1752 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1753 newline_and_indent (buffer
, spc
+2);
1754 pp_string (buffer
, "}");
1755 newline_and_indent (buffer
, spc
);
1757 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1758 newline_and_indent (buffer
, spc
+2);
1759 pp_string (buffer
, "{");
1760 newline_and_indent (buffer
, spc
+4);
1761 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1762 newline_and_indent (buffer
, spc
+2);
1763 pp_string (buffer
, "}");
1768 pp_string (buffer
, "catch (");
1769 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1770 pp_string (buffer
, ")");
1771 newline_and_indent (buffer
, spc
+2);
1772 pp_string (buffer
, "{");
1773 newline_and_indent (buffer
, spc
+4);
1774 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1775 newline_and_indent (buffer
, spc
+2);
1776 pp_string (buffer
, "}");
1780 case EH_FILTER_EXPR
:
1781 pp_string (buffer
, "<<<eh_filter (");
1782 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1783 pp_string (buffer
, ")>>>");
1784 newline_and_indent (buffer
, spc
+2);
1785 pp_string (buffer
, "{");
1786 newline_and_indent (buffer
, spc
+4);
1787 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1788 newline_and_indent (buffer
, spc
+2);
1789 pp_string (buffer
, "}");
1794 op0
= TREE_OPERAND (node
, 0);
1795 /* If this is for break or continue, don't bother printing it. */
1796 if (DECL_NAME (op0
))
1798 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1799 if (strcmp (name
, "break") == 0
1800 || strcmp (name
, "continue") == 0)
1803 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1804 pp_character (buffer
, ':');
1805 if (DECL_NONLOCAL (op0
))
1806 pp_string (buffer
, " [non-local]");
1810 pp_string (buffer
, "while (1)");
1811 if (!(flags
& TDF_SLIM
))
1813 newline_and_indent (buffer
, spc
+2);
1814 pp_character (buffer
, '{');
1815 newline_and_indent (buffer
, spc
+4);
1816 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1817 newline_and_indent (buffer
, spc
+2);
1818 pp_character (buffer
, '}');
1824 pp_string (buffer
, "// predicted ");
1825 if (PREDICT_EXPR_OUTCOME (node
))
1826 pp_string (buffer
, "likely by ");
1828 pp_string (buffer
, "unlikely by ");
1829 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
1830 pp_string (buffer
, " predictor.");
1834 pp_string (buffer
, "return");
1835 op0
= TREE_OPERAND (node
, 0);
1839 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1840 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
1843 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1848 pp_string (buffer
, "if (");
1849 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1850 pp_string (buffer
, ") break");
1854 pp_string (buffer
, "switch (");
1855 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1856 pp_character (buffer
, ')');
1857 if (!(flags
& TDF_SLIM
))
1859 newline_and_indent (buffer
, spc
+2);
1860 pp_character (buffer
, '{');
1861 if (SWITCH_BODY (node
))
1863 newline_and_indent (buffer
, spc
+4);
1864 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1869 tree vec
= SWITCH_LABELS (node
);
1870 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1871 for (i
= 0; i
< n
; ++i
)
1873 tree elt
= TREE_VEC_ELT (vec
, i
);
1874 newline_and_indent (buffer
, spc
+4);
1877 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1878 pp_string (buffer
, " goto ");
1879 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1881 pp_semicolon (buffer
);
1884 pp_string (buffer
, "case ???: goto ???;");
1887 newline_and_indent (buffer
, spc
+2);
1888 pp_character (buffer
, '}');
1894 op0
= GOTO_DESTINATION (node
);
1895 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1897 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1898 if (strcmp (name
, "break") == 0
1899 || strcmp (name
, "continue") == 0)
1901 pp_string (buffer
, name
);
1905 pp_string (buffer
, "goto ");
1906 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1910 pp_string (buffer
, "__asm__");
1911 if (ASM_VOLATILE_P (node
))
1912 pp_string (buffer
, " __volatile__");
1913 pp_character (buffer
, '(');
1914 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1915 pp_character (buffer
, ':');
1916 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1917 pp_character (buffer
, ':');
1918 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1919 if (ASM_CLOBBERS (node
))
1921 pp_character (buffer
, ':');
1922 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1924 pp_string (buffer
, ")");
1927 case CASE_LABEL_EXPR
:
1928 if (CASE_LOW (node
) && CASE_HIGH (node
))
1930 pp_string (buffer
, "case ");
1931 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1932 pp_string (buffer
, " ... ");
1933 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1935 else if (CASE_LOW (node
))
1937 pp_string (buffer
, "case ");
1938 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1941 pp_string (buffer
, "default");
1942 pp_character (buffer
, ':');
1946 pp_string (buffer
, "OBJ_TYPE_REF(");
1947 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1948 pp_character (buffer
, ';');
1949 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1950 pp_character (buffer
, '-');
1951 pp_character (buffer
, '>');
1952 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
1953 pp_character (buffer
, ')');
1957 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
1958 pp_string (buffer
, "_");
1959 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1960 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
1961 pp_string (buffer
, "(ab)");
1962 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
1963 pp_string (buffer
, "(D)");
1966 case WITH_SIZE_EXPR
:
1967 pp_string (buffer
, "WITH_SIZE_EXPR <");
1968 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1969 pp_string (buffer
, ", ");
1970 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1971 pp_string (buffer
, ">");
1975 pp_string (buffer
, "ASSERT_EXPR <");
1976 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
1977 pp_string (buffer
, ", ");
1978 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
1979 pp_string (buffer
, ">");
1983 pp_string (buffer
, "scev_known");
1986 case SCEV_NOT_KNOWN
:
1987 pp_string (buffer
, "scev_not_known");
1990 case POLYNOMIAL_CHREC
:
1991 pp_string (buffer
, "{");
1992 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
1993 pp_string (buffer
, ", +, ");
1994 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
1995 pp_string (buffer
, "}_");
1996 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
2000 case REALIGN_LOAD_EXPR
:
2001 pp_string (buffer
, "REALIGN_LOAD <");
2002 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2003 pp_string (buffer
, ", ");
2004 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2005 pp_string (buffer
, ", ");
2006 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2007 pp_string (buffer
, ">");
2011 pp_string (buffer
, " VEC_COND_EXPR < ");
2012 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2013 pp_string (buffer
, " , ");
2014 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2015 pp_string (buffer
, " , ");
2016 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2017 pp_string (buffer
, " > ");
2021 pp_string (buffer
, " DOT_PROD_EXPR < ");
2022 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2023 pp_string (buffer
, ", ");
2024 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2025 pp_string (buffer
, ", ");
2026 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2027 pp_string (buffer
, " > ");
2030 case WIDEN_MULT_PLUS_EXPR
:
2031 pp_string (buffer
, " WIDEN_MULT_PLUS_EXPR < ");
2032 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2033 pp_string (buffer
, ", ");
2034 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2035 pp_string (buffer
, ", ");
2036 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2037 pp_string (buffer
, " > ");
2040 case WIDEN_MULT_MINUS_EXPR
:
2041 pp_string (buffer
, " WIDEN_MULT_MINUS_EXPR < ");
2042 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2043 pp_string (buffer
, ", ");
2044 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2045 pp_string (buffer
, ", ");
2046 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2047 pp_string (buffer
, " > ");
2051 pp_string (buffer
, " FMA_EXPR < ");
2052 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2053 pp_string (buffer
, ", ");
2054 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2055 pp_string (buffer
, ", ");
2056 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2057 pp_string (buffer
, " > ");
2061 pp_string (buffer
, "#pragma omp parallel");
2062 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
2065 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
2067 newline_and_indent (buffer
, spc
+ 2);
2068 pp_character (buffer
, '{');
2069 newline_and_indent (buffer
, spc
+ 4);
2070 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
2071 newline_and_indent (buffer
, spc
+ 2);
2072 pp_character (buffer
, '}');
2078 pp_string (buffer
, "#pragma omp task");
2079 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
2083 pp_string (buffer
, "#pragma omp for");
2084 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
2086 if (!(flags
& TDF_SLIM
))
2090 if (OMP_FOR_PRE_BODY (node
))
2092 newline_and_indent (buffer
, spc
+ 2);
2093 pp_character (buffer
, '{');
2095 newline_and_indent (buffer
, spc
);
2096 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
2100 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
2103 newline_and_indent (buffer
, spc
);
2104 pp_string (buffer
, "for (");
2105 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
2107 pp_string (buffer
, "; ");
2108 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
2110 pp_string (buffer
, "; ");
2111 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
2113 pp_string (buffer
, ")");
2115 if (OMP_FOR_BODY (node
))
2117 newline_and_indent (buffer
, spc
+ 2);
2118 pp_character (buffer
, '{');
2119 newline_and_indent (buffer
, spc
+ 4);
2120 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
2122 newline_and_indent (buffer
, spc
+ 2);
2123 pp_character (buffer
, '}');
2125 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
2126 if (OMP_FOR_PRE_BODY (node
))
2129 newline_and_indent (buffer
, spc
+ 2);
2130 pp_character (buffer
, '}');
2137 pp_string (buffer
, "#pragma omp sections");
2138 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2142 pp_string (buffer
, "#pragma omp section");
2146 pp_string (buffer
, "#pragma omp master");
2150 pp_string (buffer
, "#pragma omp ordered");
2154 pp_string (buffer
, "#pragma omp critical");
2155 if (OMP_CRITICAL_NAME (node
))
2158 pp_character (buffer
, '(');
2159 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2161 pp_character (buffer
, ')');
2166 pp_string (buffer
, "#pragma omp atomic");
2167 newline_and_indent (buffer
, spc
+ 2);
2168 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2170 pp_character (buffer
, '=');
2172 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2176 pp_string (buffer
, "#pragma omp single");
2177 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2181 dump_omp_clause (buffer
, node
, spc
, flags
);
2185 case REDUC_MAX_EXPR
:
2186 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2187 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2188 pp_string (buffer
, " > ");
2191 case REDUC_MIN_EXPR
:
2192 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2193 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2194 pp_string (buffer
, " > ");
2197 case REDUC_PLUS_EXPR
:
2198 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2199 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2200 pp_string (buffer
, " > ");
2203 case VEC_WIDEN_MULT_HI_EXPR
:
2204 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
2205 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2206 pp_string (buffer
, ", ");
2207 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2208 pp_string (buffer
, " > ");
2211 case VEC_WIDEN_MULT_LO_EXPR
:
2212 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
2213 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2214 pp_string (buffer
, ", ");
2215 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2216 pp_string (buffer
, " > ");
2219 case VEC_UNPACK_HI_EXPR
:
2220 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2221 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2222 pp_string (buffer
, " > ");
2225 case VEC_UNPACK_LO_EXPR
:
2226 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2227 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2228 pp_string (buffer
, " > ");
2231 case VEC_UNPACK_FLOAT_HI_EXPR
:
2232 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2233 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2234 pp_string (buffer
, " > ");
2237 case VEC_UNPACK_FLOAT_LO_EXPR
:
2238 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2239 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2240 pp_string (buffer
, " > ");
2243 case VEC_PACK_TRUNC_EXPR
:
2244 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2245 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2246 pp_string (buffer
, ", ");
2247 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2248 pp_string (buffer
, " > ");
2251 case VEC_PACK_SAT_EXPR
:
2252 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2253 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2254 pp_string (buffer
, ", ");
2255 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2256 pp_string (buffer
, " > ");
2259 case VEC_PACK_FIX_TRUNC_EXPR
:
2260 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2261 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2262 pp_string (buffer
, ", ");
2263 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2264 pp_string (buffer
, " > ");
2268 dump_block_node (buffer
, node
, spc
, flags
);
2271 case VEC_EXTRACT_EVEN_EXPR
:
2272 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2273 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2274 pp_string (buffer
, ", ");
2275 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2276 pp_string (buffer
, " > ");
2279 case VEC_EXTRACT_ODD_EXPR
:
2280 pp_string (buffer
, " VEC_EXTRACT_ODD_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_INTERLEAVE_HIGH_EXPR
:
2288 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_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_INTERLEAVE_LOW_EXPR
:
2296 pp_string (buffer
, " VEC_INTERLEAVE_LOW_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
, " > ");
2307 if (is_stmt
&& is_expr
)
2308 pp_semicolon (buffer
);
2310 /* If we're building a diagnostic, the formatted text will be written
2311 into BUFFER's stream by the caller; otherwise, write it now. */
2312 if (!(flags
& TDF_DIAGNOSTIC
))
2313 pp_write_text_to_stream (buffer
);
2318 /* Print the declaration of a variable. */
2321 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2325 if (TREE_CODE (t
) == TYPE_DECL
)
2326 pp_string (buffer
, "typedef ");
2328 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2329 pp_string (buffer
, "register ");
2331 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2332 pp_string (buffer
, "extern ");
2333 else if (TREE_STATIC (t
))
2334 pp_string (buffer
, "static ");
2336 /* Print the type and name. */
2337 if (TREE_TYPE (t
) && TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2341 /* Print array's type. */
2342 tmp
= TREE_TYPE (t
);
2343 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2344 tmp
= TREE_TYPE (tmp
);
2345 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2347 /* Print variable's name. */
2349 dump_generic_node (buffer
, t
, spc
, flags
, false);
2351 /* Print the dimensions. */
2352 tmp
= TREE_TYPE (t
);
2353 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2355 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2356 tmp
= TREE_TYPE (tmp
);
2359 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2361 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2363 dump_decl_name (buffer
, t
, flags
);
2364 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2368 /* Print type declaration. */
2369 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2371 /* Print variable's name. */
2373 dump_generic_node (buffer
, t
, spc
, flags
, false);
2376 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2378 pp_string (buffer
, " __asm__ ");
2379 pp_character (buffer
, '(');
2380 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2381 pp_character (buffer
, ')');
2384 /* The initial value of a function serves to determine whether the function
2385 is declared or defined. So the following does not apply to function
2387 if (TREE_CODE (t
) != FUNCTION_DECL
)
2389 /* Print the initial value. */
2390 if (DECL_INITIAL (t
))
2393 pp_character (buffer
, '=');
2395 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2399 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2401 pp_string (buffer
, " [value-expr: ");
2402 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2403 pp_character (buffer
, ']');
2406 pp_character (buffer
, ';');
2410 /* Prints a structure: name, fields, and methods.
2411 FIXME: Still incomplete. */
2414 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2416 /* Print the name of the structure. */
2417 if (TYPE_NAME (node
))
2420 if (TREE_CODE (node
) == RECORD_TYPE
)
2421 pp_string (buffer
, "struct ");
2422 else if ((TREE_CODE (node
) == UNION_TYPE
2423 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2424 pp_string (buffer
, "union ");
2426 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2429 /* Print the contents of the structure. */
2430 pp_newline (buffer
);
2432 pp_character (buffer
, '{');
2433 pp_newline (buffer
);
2435 /* Print the fields of the structure. */
2438 tmp
= TYPE_FIELDS (node
);
2441 /* Avoid to print recursively the structure. */
2442 /* FIXME : Not implemented correctly...,
2443 what about the case when we have a cycle in the contain graph? ...
2444 Maybe this could be solved by looking at the scope in which the
2445 structure was declared. */
2446 if (TREE_TYPE (tmp
) != node
2447 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2448 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2450 print_declaration (buffer
, tmp
, spc
+2, flags
);
2451 pp_newline (buffer
);
2453 tmp
= DECL_CHAIN (tmp
);
2457 pp_character (buffer
, '}');
2460 /* Return the priority of the operator CODE.
2462 From lowest to highest precedence with either left-to-right (L-R)
2463 or right-to-left (R-L) associativity]:
2466 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2478 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2479 15 [L-R] fn() [] -> .
2481 unary +, - and * have higher precedence than the corresponding binary
2485 op_code_prio (enum tree_code code
)
2502 case TRUTH_ORIF_EXPR
:
2505 case TRUTH_AND_EXPR
:
2506 case TRUTH_ANDIF_EXPR
:
2513 case TRUTH_XOR_EXPR
:
2530 case UNORDERED_EXPR
:
2543 case WIDEN_SUM_EXPR
:
2545 case POINTER_PLUS_EXPR
:
2549 case VEC_WIDEN_MULT_HI_EXPR
:
2550 case VEC_WIDEN_MULT_LO_EXPR
:
2551 case WIDEN_MULT_EXPR
:
2553 case WIDEN_MULT_PLUS_EXPR
:
2554 case WIDEN_MULT_MINUS_EXPR
:
2556 case TRUNC_DIV_EXPR
:
2558 case FLOOR_DIV_EXPR
:
2559 case ROUND_DIV_EXPR
:
2561 case EXACT_DIV_EXPR
:
2562 case TRUNC_MOD_EXPR
:
2564 case FLOOR_MOD_EXPR
:
2565 case ROUND_MOD_EXPR
:
2569 case TRUTH_NOT_EXPR
:
2571 case POSTINCREMENT_EXPR
:
2572 case POSTDECREMENT_EXPR
:
2573 case PREINCREMENT_EXPR
:
2574 case PREDECREMENT_EXPR
:
2580 case FIX_TRUNC_EXPR
:
2586 case ARRAY_RANGE_REF
:
2590 /* Special expressions. */
2596 case REDUC_MAX_EXPR
:
2597 case REDUC_MIN_EXPR
:
2598 case REDUC_PLUS_EXPR
:
2599 case VEC_LSHIFT_EXPR
:
2600 case VEC_RSHIFT_EXPR
:
2601 case VEC_UNPACK_HI_EXPR
:
2602 case VEC_UNPACK_LO_EXPR
:
2603 case VEC_UNPACK_FLOAT_HI_EXPR
:
2604 case VEC_UNPACK_FLOAT_LO_EXPR
:
2605 case VEC_PACK_TRUNC_EXPR
:
2606 case VEC_PACK_SAT_EXPR
:
2610 /* Return an arbitrarily high precedence to avoid surrounding single
2611 VAR_DECLs in ()s. */
2616 /* Return the priority of the operator OP. */
2619 op_prio (const_tree op
)
2621 enum tree_code code
;
2626 code
= TREE_CODE (op
);
2627 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2628 return op_prio (TREE_OPERAND (op
, 0));
2630 return op_code_prio (code
);
2633 /* Return the symbol associated with operator CODE. */
2636 op_symbol_code (enum tree_code code
)
2644 case TRUTH_ORIF_EXPR
:
2647 case TRUTH_AND_EXPR
:
2648 case TRUTH_ANDIF_EXPR
:
2654 case TRUTH_XOR_EXPR
:
2664 case UNORDERED_EXPR
:
2710 case VEC_LSHIFT_EXPR
:
2713 case VEC_RSHIFT_EXPR
:
2716 case POINTER_PLUS_EXPR
:
2722 case REDUC_PLUS_EXPR
:
2725 case WIDEN_SUM_EXPR
:
2728 case WIDEN_MULT_EXPR
:
2738 case TRUTH_NOT_EXPR
:
2745 case TRUNC_DIV_EXPR
:
2752 case FLOOR_DIV_EXPR
:
2755 case ROUND_DIV_EXPR
:
2758 case EXACT_DIV_EXPR
:
2761 case TRUNC_MOD_EXPR
:
2767 case FLOOR_MOD_EXPR
:
2770 case ROUND_MOD_EXPR
:
2773 case PREDECREMENT_EXPR
:
2776 case PREINCREMENT_EXPR
:
2779 case POSTDECREMENT_EXPR
:
2782 case POSTINCREMENT_EXPR
:
2792 return "<<< ??? >>>";
2796 /* Return the symbol associated with operator OP. */
2799 op_symbol (const_tree op
)
2801 return op_symbol_code (TREE_CODE (op
));
2804 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2805 the gimple_call_fn of a GIMPLE_CALL. */
2808 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
2812 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2813 op0
= TREE_OPERAND (op0
, 0);
2816 switch (TREE_CODE (op0
))
2821 dump_function_name (buffer
, op0
, flags
);
2827 op0
= TREE_OPERAND (op0
, 0);
2831 pp_string (buffer
, "(");
2832 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
2833 pp_string (buffer
, ") ? ");
2834 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
2835 pp_string (buffer
, " : ");
2836 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
2840 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2841 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
2843 dump_generic_node (buffer
, op0
, 0, flags
, false);
2847 if (integer_zerop (TREE_OPERAND (op0
, 1)))
2849 op0
= TREE_OPERAND (op0
, 0);
2856 dump_generic_node (buffer
, op0
, 0, flags
, false);
2864 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2867 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2877 pp_string (buffer
, "\\b");
2881 pp_string (buffer
, "\\f");
2885 pp_string (buffer
, "\\n");
2889 pp_string (buffer
, "\\r");
2893 pp_string (buffer
, "\\t");
2897 pp_string (buffer
, "\\v");
2901 pp_string (buffer
, "\\\\");
2905 pp_string (buffer
, "\\\"");
2909 pp_string (buffer
, "\\'");
2912 /* No need to handle \0; the loop terminates on \0. */
2915 pp_string (buffer
, "\\1");
2919 pp_string (buffer
, "\\2");
2923 pp_string (buffer
, "\\3");
2927 pp_string (buffer
, "\\4");
2931 pp_string (buffer
, "\\5");
2935 pp_string (buffer
, "\\6");
2939 pp_string (buffer
, "\\7");
2943 pp_character (buffer
, str
[0]);
2951 maybe_init_pretty_print (FILE *file
)
2955 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
2956 pp_needs_newline (&buffer
) = true;
2957 pp_translate_identifiers (&buffer
) = false;
2961 buffer
.buffer
->stream
= file
;
2965 newline_and_indent (pretty_printer
*buffer
, int spc
)
2967 pp_newline (buffer
);
2971 /* Handle a %K format for TEXT. Separate from default_tree_printer so
2972 it can also be used in front ends.
2973 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
2977 percent_K_format (text_info
*text
)
2979 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
2980 gcc_assert (text
->locus
!= NULL
);
2981 *text
->locus
= EXPR_LOCATION (t
);
2982 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
2983 block
= TREE_BLOCK (t
);
2984 *pp_ti_abstract_origin (text
) = NULL
;
2986 && TREE_CODE (block
) == BLOCK
2987 && BLOCK_ABSTRACT_ORIGIN (block
))
2989 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
2991 while (TREE_CODE (ao
) == BLOCK
2992 && BLOCK_ABSTRACT_ORIGIN (ao
)
2993 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
2994 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
2996 if (TREE_CODE (ao
) == FUNCTION_DECL
)
2998 *pp_ti_abstract_origin (text
) = block
;
3001 block
= BLOCK_SUPERCONTEXT (block
);
3005 /* Print the identifier ID to PRETTY-PRINTER. */
3008 pp_base_tree_identifier (pretty_printer
*pp
, tree id
)
3010 if (pp_translate_identifiers (pp
))
3012 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
3013 pp_append_text (pp
, text
, text
+ strlen (text
));
3016 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
3017 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));
3020 /* A helper function that is used to dump function information before the
3024 dump_function_header (FILE *dump_file
, tree fdecl
, int flags
)
3026 const char *dname
, *aname
;
3027 struct cgraph_node
*node
= cgraph_get_node (fdecl
);
3028 struct function
*fun
= DECL_STRUCT_FUNCTION (fdecl
);
3030 dname
= lang_hooks
.decl_printable_name (fdecl
, 2);
3032 if (DECL_ASSEMBLER_NAME_SET_P (fdecl
))
3033 aname
= (IDENTIFIER_POINTER
3034 (DECL_ASSEMBLER_NAME (fdecl
)));
3036 aname
= "<unset-asm-name>";
3038 if (L_IPO_COMP_MODE
)
3039 fprintf (dump_file
, "\n;; Function %s (%s, funcdef_no=%d:%d",
3040 dname
, aname
, FUNC_DECL_MODULE_ID (fun
),
3041 FUNC_DECL_FUNC_ID (fun
));
3043 fprintf (dump_file
, "\n;; Function %s (%s, funcdef_no=%d",
3044 dname
, aname
, fun
->funcdef_no
);
3045 if (!(flags
& TDF_NOUID
))
3046 fprintf (dump_file
, ", decl_uid=%d", DECL_UID (fdecl
));
3049 fprintf (dump_file
, ", cgraph_uid=%d)%s\n\n", node
->uid
,
3050 node
->frequency
== NODE_FREQUENCY_HOT
3052 : node
->frequency
== NODE_FREQUENCY_UNLIKELY_EXECUTED
3053 ? " (unlikely executed)"
3054 : node
->frequency
== NODE_FREQUENCY_EXECUTED_ONCE
3055 ? " (executed once)"
3059 fprintf (dump_file
, ")\n\n");