1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
26 #include "tree-pretty-print.h"
28 #include "tree-flow.h"
29 #include "langhooks.h"
30 #include "tree-iterator.h"
31 #include "tree-chrec.h"
33 #include "value-prof.h"
36 /* Local functions, macros and variables. */
37 static const char *op_symbol (const_tree
);
38 static void pretty_print_string (pretty_printer
*, const char*);
39 static void newline_and_indent (pretty_printer
*, int);
40 static void maybe_init_pretty_print (FILE *);
41 static void print_struct_decl (pretty_printer
*, const_tree
, int, int);
42 static void do_niy (pretty_printer
*, const_tree
);
44 #define INDENT(SPACE) do { \
45 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
47 #define NIY do_niy(buffer,node)
49 static pretty_printer buffer
;
50 static int initialized
= 0;
52 /* Try to print something for an unknown tree code. */
55 do_niy (pretty_printer
*buffer
, const_tree node
)
59 pp_string (buffer
, "<<< Unknown tree: ");
60 pp_string (buffer
, tree_code_name
[(int) TREE_CODE (node
)]);
64 len
= TREE_OPERAND_LENGTH (node
);
65 for (i
= 0; i
< len
; ++i
)
67 newline_and_indent (buffer
, 2);
68 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0, false);
72 pp_string (buffer
, " >>>");
75 /* Debugging function to print out a generic expression. */
78 debug_generic_expr (tree t
)
80 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
81 fprintf (stderr
, "\n");
84 /* Debugging function to print out a generic statement. */
87 debug_generic_stmt (tree t
)
89 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
90 fprintf (stderr
, "\n");
93 /* Debugging function to print out a chain of trees . */
96 debug_tree_chain (tree t
)
98 struct pointer_set_t
*seen
= pointer_set_create ();
102 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
103 fprintf (stderr
, " ");
105 if (pointer_set_insert (seen
, t
))
107 fprintf (stderr
, "... [cycled back to ");
108 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
109 fprintf (stderr
, "]");
113 fprintf (stderr
, "\n");
115 pointer_set_destroy (seen
);
118 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
120 print_generic_decl (FILE *file
, tree decl
, int flags
)
122 maybe_init_pretty_print (file
);
123 print_declaration (&buffer
, decl
, 2, flags
);
124 pp_write_text_to_stream (&buffer
);
127 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
128 to show in the dump. See TDF_* in dumpfile.h. */
131 print_generic_stmt (FILE *file
, tree t
, int flags
)
133 maybe_init_pretty_print (file
);
134 dump_generic_node (&buffer
, t
, 0, flags
, true);
135 pp_newline_and_flush (&buffer
);
138 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
139 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
143 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
147 maybe_init_pretty_print (file
);
149 for (i
= 0; i
< indent
; i
++)
151 dump_generic_node (&buffer
, t
, indent
, flags
, true);
152 pp_newline_and_flush (&buffer
);
155 /* Print a single expression T on file FILE. FLAGS specifies details to show
156 in the dump. See TDF_* in dumpfile.h. */
159 print_generic_expr (FILE *file
, tree t
, int flags
)
161 maybe_init_pretty_print (file
);
162 dump_generic_node (&buffer
, t
, 0, flags
, false);
166 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
170 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
172 if (DECL_NAME (node
))
174 if ((flags
& TDF_ASMNAME
) && DECL_ASSEMBLER_NAME_SET_P (node
))
175 pp_tree_identifier (buffer
, DECL_ASSEMBLER_NAME (node
));
177 pp_tree_identifier (buffer
, DECL_NAME (node
));
179 if ((flags
& TDF_UID
) || DECL_NAME (node
) == NULL_TREE
)
181 if (TREE_CODE (node
) == LABEL_DECL
&& LABEL_DECL_UID (node
) != -1)
182 pp_printf (buffer
, "L.%d", (int) LABEL_DECL_UID (node
));
183 else if (TREE_CODE (node
) == DEBUG_EXPR_DECL
)
185 if (flags
& TDF_NOUID
)
186 pp_string (buffer
, "D#xxxx");
188 pp_printf (buffer
, "D#%i", DEBUG_TEMP_UID (node
));
192 char c
= TREE_CODE (node
) == CONST_DECL
? 'C' : 'D';
193 if (flags
& TDF_NOUID
)
194 pp_printf (buffer
, "%c.xxxx", c
);
196 pp_printf (buffer
, "%c.%u", c
, DECL_UID (node
));
199 if ((flags
& TDF_ALIAS
) && DECL_PT_UID (node
) != DECL_UID (node
))
201 if (flags
& TDF_NOUID
)
202 pp_printf (buffer
, "ptD.xxxx");
204 pp_printf (buffer
, "ptD.%u", DECL_PT_UID (node
));
208 /* Like the above, but used for pretty printing function calls. */
211 dump_function_name (pretty_printer
*buffer
, tree node
, int flags
)
213 if (TREE_CODE (node
) == NOP_EXPR
)
214 node
= TREE_OPERAND (node
, 0);
215 if (DECL_NAME (node
) && (flags
& TDF_ASMNAME
) == 0)
216 pp_string (buffer
, lang_hooks
.decl_printable_name (node
, 1));
218 dump_decl_name (buffer
, node
, flags
);
221 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
222 FLAGS are as in dump_generic_node. */
225 dump_function_declaration (pretty_printer
*buffer
, tree node
,
228 bool wrote_arg
= false;
232 pp_left_paren (buffer
);
234 /* Print the argument types. */
235 arg
= TYPE_ARG_TYPES (node
);
236 while (arg
&& arg
!= void_list_node
&& arg
!= error_mark_node
)
244 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
245 arg
= TREE_CHAIN (arg
);
248 /* Drop the trailing void_type_node if we had any previous argument. */
249 if (arg
== void_list_node
&& !wrote_arg
)
250 pp_string (buffer
, "void");
251 /* Properly dump vararg function types. */
252 else if (!arg
&& wrote_arg
)
253 pp_string (buffer
, ", ...");
254 /* Avoid printing any arg for unprototyped functions. */
256 pp_right_paren (buffer
);
259 /* Dump the domain associated with an array. */
262 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
264 pp_left_bracket (buffer
);
267 tree min
= TYPE_MIN_VALUE (domain
);
268 tree max
= TYPE_MAX_VALUE (domain
);
271 && integer_zerop (min
)
272 && host_integerp (max
, 0))
273 pp_wide_integer (buffer
, TREE_INT_CST_LOW (max
) + 1);
277 dump_generic_node (buffer
, min
, spc
, flags
, false);
280 dump_generic_node (buffer
, max
, spc
, flags
, false);
284 pp_string (buffer
, "<unknown>");
285 pp_right_bracket (buffer
);
289 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
290 dump_generic_node. */
293 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
297 switch (OMP_CLAUSE_CODE (clause
))
299 case OMP_CLAUSE_PRIVATE
:
302 case OMP_CLAUSE_SHARED
:
305 case OMP_CLAUSE_FIRSTPRIVATE
:
306 name
= "firstprivate";
308 case OMP_CLAUSE_LASTPRIVATE
:
309 name
= "lastprivate";
311 case OMP_CLAUSE_COPYIN
:
314 case OMP_CLAUSE_COPYPRIVATE
:
315 name
= "copyprivate";
318 pp_string (buffer
, name
);
319 pp_left_paren (buffer
);
320 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
322 pp_right_paren (buffer
);
325 case OMP_CLAUSE_REDUCTION
:
326 pp_string (buffer
, "reduction(");
327 pp_string (buffer
, op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
329 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
331 pp_right_paren (buffer
);
335 pp_string (buffer
, "if(");
336 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
338 pp_right_paren (buffer
);
341 case OMP_CLAUSE_NUM_THREADS
:
342 pp_string (buffer
, "num_threads(");
343 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
345 pp_right_paren (buffer
);
348 case OMP_CLAUSE_NOWAIT
:
349 pp_string (buffer
, "nowait");
351 case OMP_CLAUSE_ORDERED
:
352 pp_string (buffer
, "ordered");
355 case OMP_CLAUSE_DEFAULT
:
356 pp_string (buffer
, "default(");
357 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
359 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
361 case OMP_CLAUSE_DEFAULT_SHARED
:
362 pp_string (buffer
, "shared");
364 case OMP_CLAUSE_DEFAULT_NONE
:
365 pp_string (buffer
, "none");
367 case OMP_CLAUSE_DEFAULT_PRIVATE
:
368 pp_string (buffer
, "private");
370 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE
:
371 pp_string (buffer
, "firstprivate");
376 pp_right_paren (buffer
);
379 case OMP_CLAUSE_SCHEDULE
:
380 pp_string (buffer
, "schedule(");
381 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
383 case OMP_CLAUSE_SCHEDULE_STATIC
:
384 pp_string (buffer
, "static");
386 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
387 pp_string (buffer
, "dynamic");
389 case OMP_CLAUSE_SCHEDULE_GUIDED
:
390 pp_string (buffer
, "guided");
392 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
393 pp_string (buffer
, "runtime");
395 case OMP_CLAUSE_SCHEDULE_AUTO
:
396 pp_string (buffer
, "auto");
401 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
404 dump_generic_node (buffer
,
405 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
408 pp_right_paren (buffer
);
411 case OMP_CLAUSE_UNTIED
:
412 pp_string (buffer
, "untied");
415 case OMP_CLAUSE_COLLAPSE
:
416 pp_string (buffer
, "collapse(");
417 dump_generic_node (buffer
,
418 OMP_CLAUSE_COLLAPSE_EXPR (clause
),
420 pp_right_paren (buffer
);
423 case OMP_CLAUSE_FINAL
:
424 pp_string (buffer
, "final(");
425 dump_generic_node (buffer
, OMP_CLAUSE_FINAL_EXPR (clause
),
427 pp_right_paren (buffer
);
430 case OMP_CLAUSE_MERGEABLE
:
431 pp_string (buffer
, "mergeable");
435 /* Should never happen. */
436 dump_generic_node (buffer
, clause
, spc
, flags
, false);
442 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
443 dump_generic_node. */
446 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
454 dump_omp_clause (buffer
, clause
, spc
, flags
);
455 clause
= OMP_CLAUSE_CHAIN (clause
);
463 /* Dump location LOC to BUFFER. */
466 dump_location (pretty_printer
*buffer
, location_t loc
)
468 expanded_location xloc
= expand_location (loc
);
470 pp_left_bracket (buffer
);
473 pp_string (buffer
, xloc
.file
);
474 pp_string (buffer
, " : ");
476 pp_decimal_int (buffer
, xloc
.line
);
477 pp_string (buffer
, "] ");
481 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
482 dump_generic_node. */
485 dump_block_node (pretty_printer
*buffer
, tree block
, int spc
, int flags
)
489 pp_printf (buffer
, "BLOCK #%d ", BLOCK_NUMBER (block
));
491 if (flags
& TDF_ADDRESS
)
492 pp_printf (buffer
, "[%p] ", (void *) block
);
494 if (BLOCK_ABSTRACT (block
))
495 pp_string (buffer
, "[abstract] ");
497 if (TREE_ASM_WRITTEN (block
))
498 pp_string (buffer
, "[written] ");
500 if (flags
& TDF_SLIM
)
503 if (BLOCK_SOURCE_LOCATION (block
))
504 dump_location (buffer
, BLOCK_SOURCE_LOCATION (block
));
506 newline_and_indent (buffer
, spc
+ 2);
508 if (BLOCK_SUPERCONTEXT (block
))
510 pp_string (buffer
, "SUPERCONTEXT: ");
511 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (block
), 0,
512 flags
| TDF_SLIM
, false);
513 newline_and_indent (buffer
, spc
+ 2);
516 if (BLOCK_SUBBLOCKS (block
))
518 pp_string (buffer
, "SUBBLOCKS: ");
519 for (t
= BLOCK_SUBBLOCKS (block
); t
; t
= BLOCK_CHAIN (t
))
521 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
522 pp_string (buffer
, " ");
524 newline_and_indent (buffer
, spc
+ 2);
527 if (BLOCK_CHAIN (block
))
529 pp_string (buffer
, "SIBLINGS: ");
530 for (t
= BLOCK_CHAIN (block
); t
; t
= BLOCK_CHAIN (t
))
532 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
533 pp_string (buffer
, " ");
535 newline_and_indent (buffer
, spc
+ 2);
538 if (BLOCK_VARS (block
))
540 pp_string (buffer
, "VARS: ");
541 for (t
= BLOCK_VARS (block
); t
; t
= TREE_CHAIN (t
))
543 dump_generic_node (buffer
, t
, 0, flags
, false);
544 pp_string (buffer
, " ");
546 newline_and_indent (buffer
, spc
+ 2);
549 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block
)) > 0)
552 vec
<tree
, va_gc
> *nlv
= BLOCK_NONLOCALIZED_VARS (block
);
554 pp_string (buffer
, "NONLOCALIZED_VARS: ");
555 FOR_EACH_VEC_ELT (*nlv
, i
, t
)
557 dump_generic_node (buffer
, t
, 0, flags
, false);
558 pp_string (buffer
, " ");
560 newline_and_indent (buffer
, spc
+ 2);
563 if (BLOCK_ABSTRACT_ORIGIN (block
))
565 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
566 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (block
), 0,
567 flags
| TDF_SLIM
, false);
568 newline_and_indent (buffer
, spc
+ 2);
571 if (BLOCK_FRAGMENT_ORIGIN (block
))
573 pp_string (buffer
, "FRAGMENT_ORIGIN: ");
574 dump_generic_node (buffer
, BLOCK_FRAGMENT_ORIGIN (block
), 0,
575 flags
| TDF_SLIM
, false);
576 newline_and_indent (buffer
, spc
+ 2);
579 if (BLOCK_FRAGMENT_CHAIN (block
))
581 pp_string (buffer
, "FRAGMENT_CHAIN: ");
582 for (t
= BLOCK_FRAGMENT_CHAIN (block
); t
; t
= BLOCK_FRAGMENT_CHAIN (t
))
584 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
585 pp_string (buffer
, " ");
587 newline_and_indent (buffer
, spc
+ 2);
592 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
593 indent. FLAGS specifies details to show in the dump (see TDF_* in
594 dumpfile.h). If IS_STMT is true, the object printed is considered
595 to be a statement and it is terminated by ';' if appropriate. */
598 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
607 if (node
== NULL_TREE
)
610 is_expr
= EXPR_P (node
);
612 if (is_stmt
&& (flags
& TDF_STMTADDR
))
613 pp_printf (buffer
, "<&%p> ", (void *)node
);
615 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
616 dump_location (buffer
, EXPR_LOCATION (node
));
618 code
= TREE_CODE (node
);
622 pp_string (buffer
, "<<< error >>>");
625 case IDENTIFIER_NODE
:
626 pp_tree_identifier (buffer
, node
);
630 while (node
&& node
!= error_mark_node
)
632 if (TREE_PURPOSE (node
))
634 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
637 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
638 node
= TREE_CHAIN (node
);
639 if (node
&& TREE_CODE (node
) == TREE_LIST
)
648 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
654 if (TREE_VEC_LENGTH (node
) > 0)
656 size_t len
= TREE_VEC_LENGTH (node
);
657 for (i
= 0; i
< len
- 1; i
++)
659 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
664 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
673 case FIXED_POINT_TYPE
:
679 unsigned int quals
= TYPE_QUALS (node
);
680 enum tree_code_class tclass
;
682 if (quals
& TYPE_QUAL_CONST
)
683 pp_string (buffer
, "const ");
684 else if (quals
& TYPE_QUAL_VOLATILE
)
685 pp_string (buffer
, "volatile ");
686 else if (quals
& TYPE_QUAL_RESTRICT
)
687 pp_string (buffer
, "restrict ");
689 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
691 pp_string (buffer
, "<address-space-");
692 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
693 pp_string (buffer
, "> ");
696 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
698 if (tclass
== tcc_declaration
)
700 if (DECL_NAME (node
))
701 dump_decl_name (buffer
, node
, flags
);
703 pp_string (buffer
, "<unnamed type decl>");
705 else if (tclass
== tcc_type
)
707 if (TYPE_NAME (node
))
709 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
710 pp_tree_identifier (buffer
, TYPE_NAME (node
));
711 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
712 && DECL_NAME (TYPE_NAME (node
)))
713 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
715 pp_string (buffer
, "<unnamed type>");
717 else if (TREE_CODE (node
) == VECTOR_TYPE
)
719 pp_string (buffer
, "vector");
720 pp_left_paren (buffer
);
721 pp_wide_integer (buffer
, TYPE_VECTOR_SUBPARTS (node
));
722 pp_string (buffer
, ") ");
723 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
725 else if (TREE_CODE (node
) == INTEGER_TYPE
)
727 if (TYPE_PRECISION (node
) == CHAR_TYPE_SIZE
)
728 pp_string (buffer
, (TYPE_UNSIGNED (node
)
731 else if (TYPE_PRECISION (node
) == SHORT_TYPE_SIZE
)
732 pp_string (buffer
, (TYPE_UNSIGNED (node
)
735 else if (TYPE_PRECISION (node
) == INT_TYPE_SIZE
)
736 pp_string (buffer
, (TYPE_UNSIGNED (node
)
739 else if (TYPE_PRECISION (node
) == LONG_TYPE_SIZE
)
740 pp_string (buffer
, (TYPE_UNSIGNED (node
)
743 else if (TYPE_PRECISION (node
) == LONG_LONG_TYPE_SIZE
)
744 pp_string (buffer
, (TYPE_UNSIGNED (node
)
745 ? "unsigned long long"
746 : "signed long long"));
747 else if (TYPE_PRECISION (node
) >= CHAR_TYPE_SIZE
748 && exact_log2 (TYPE_PRECISION (node
)) != -1)
750 pp_string (buffer
, (TYPE_UNSIGNED (node
) ? "uint" : "int"));
751 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
752 pp_string (buffer
, "_t");
756 pp_string (buffer
, (TYPE_UNSIGNED (node
)
757 ? "<unnamed-unsigned:"
758 : "<unnamed-signed:"));
759 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
760 pp_string (buffer
, ">");
763 else if (TREE_CODE (node
) == COMPLEX_TYPE
)
765 pp_string (buffer
, "__complex__ ");
766 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
768 else if (TREE_CODE (node
) == REAL_TYPE
)
770 pp_string (buffer
, "<float:");
771 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
772 pp_string (buffer
, ">");
774 else if (TREE_CODE (node
) == FIXED_POINT_TYPE
)
776 pp_string (buffer
, "<fixed-point-");
777 pp_string (buffer
, TYPE_SATURATING (node
) ? "sat:" : "nonsat:");
778 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
779 pp_string (buffer
, ">");
781 else if (TREE_CODE (node
) == VOID_TYPE
)
782 pp_string (buffer
, "void");
784 pp_string (buffer
, "<unnamed type>");
791 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
793 if (TREE_TYPE (node
) == NULL
)
795 pp_string (buffer
, str
);
796 pp_string (buffer
, "<null type>");
798 else if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
800 tree fnode
= TREE_TYPE (node
);
802 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
804 pp_left_paren (buffer
);
805 pp_string (buffer
, str
);
806 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
807 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
808 else if (flags
& TDF_NOUID
)
809 pp_printf (buffer
, "<Txxxx>");
811 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
813 pp_right_paren (buffer
);
814 dump_function_declaration (buffer
, fnode
, spc
, flags
);
818 unsigned int quals
= TYPE_QUALS (node
);
820 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
822 pp_string (buffer
, str
);
824 if (quals
& TYPE_QUAL_CONST
)
825 pp_string (buffer
, " const");
826 if (quals
& TYPE_QUAL_VOLATILE
)
827 pp_string (buffer
, " volatile");
828 if (quals
& TYPE_QUAL_RESTRICT
)
829 pp_string (buffer
, " restrict");
831 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
833 pp_string (buffer
, " <address-space-");
834 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
835 pp_string (buffer
, ">");
838 if (TYPE_REF_CAN_ALIAS_ALL (node
))
839 pp_string (buffer
, " {ref-all}");
849 if (integer_zerop (TREE_OPERAND (node
, 1))
850 /* Dump the types of INTEGER_CSTs explicitly, for we can't
851 infer them and MEM_ATTR caching will share MEM_REFs
852 with differently-typed op0s. */
853 && TREE_CODE (TREE_OPERAND (node
, 0)) != INTEGER_CST
854 /* Released SSA_NAMES have no TREE_TYPE. */
855 && TREE_TYPE (TREE_OPERAND (node
, 0)) != NULL_TREE
856 /* Same pointer types, but ignoring POINTER_TYPE vs.
858 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 0)))
859 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))
860 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 0)))
861 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 1))))
862 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 0)))
863 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 1))))
864 /* Same value types ignoring qualifiers. */
865 && (TYPE_MAIN_VARIANT (TREE_TYPE (node
))
867 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))))
869 if (TREE_CODE (TREE_OPERAND (node
, 0)) != ADDR_EXPR
)
871 pp_string (buffer
, "*");
872 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
876 dump_generic_node (buffer
,
877 TREE_OPERAND (TREE_OPERAND (node
, 0), 0),
884 pp_string (buffer
, "MEM[");
885 pp_string (buffer
, "(");
886 ptype
= TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node
, 1)));
887 dump_generic_node (buffer
, ptype
,
888 spc
, flags
| TDF_SLIM
, false);
889 pp_string (buffer
, ")");
890 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
892 if (!integer_zerop (TREE_OPERAND (node
, 1)))
894 pp_string (buffer
, " + ");
895 dump_generic_node (buffer
, TREE_OPERAND (node
, 1),
898 pp_string (buffer
, "]");
905 const char *sep
= "";
908 pp_string (buffer
, "MEM[");
910 if (TREE_CODE (TMR_BASE (node
)) == ADDR_EXPR
)
912 pp_string (buffer
, sep
);
914 pp_string (buffer
, "symbol: ");
915 dump_generic_node (buffer
, TREE_OPERAND (TMR_BASE (node
), 0),
920 pp_string (buffer
, sep
);
922 pp_string (buffer
, "base: ");
923 dump_generic_node (buffer
, TMR_BASE (node
), spc
, flags
, false);
925 tmp
= TMR_INDEX2 (node
);
928 pp_string (buffer
, sep
);
930 pp_string (buffer
, "base: ");
931 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
933 tmp
= TMR_INDEX (node
);
936 pp_string (buffer
, sep
);
938 pp_string (buffer
, "index: ");
939 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
941 tmp
= TMR_STEP (node
);
944 pp_string (buffer
, sep
);
946 pp_string (buffer
, "step: ");
947 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
949 tmp
= TMR_OFFSET (node
);
952 pp_string (buffer
, sep
);
954 pp_string (buffer
, "offset: ");
955 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
957 pp_string (buffer
, "]");
965 /* Print the innermost component type. */
966 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
967 tmp
= TREE_TYPE (tmp
))
969 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
971 /* Print the dimensions. */
972 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
973 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
979 case QUAL_UNION_TYPE
:
981 unsigned int quals
= TYPE_QUALS (node
);
983 if (quals
& TYPE_QUAL_CONST
)
984 pp_string (buffer
, "const ");
985 if (quals
& TYPE_QUAL_VOLATILE
)
986 pp_string (buffer
, "volatile ");
988 /* Print the name of the structure. */
989 if (TREE_CODE (node
) == RECORD_TYPE
)
990 pp_string (buffer
, "struct ");
991 else if (TREE_CODE (node
) == UNION_TYPE
)
992 pp_string (buffer
, "union ");
994 if (TYPE_NAME (node
))
995 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
996 else if (!(flags
& TDF_SLIM
))
997 /* FIXME: If we eliminate the 'else' above and attempt
998 to show the fields for named types, we may get stuck
999 following a cycle of pointers to structs. The alleged
1000 self-reference check in print_struct_decl will not detect
1001 cycles involving more than one pointer or struct type. */
1002 print_struct_decl (buffer
, node
, spc
, flags
);
1011 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
1013 /* In the case of a pointer, one may want to divide by the
1014 size of the pointed-to type. Unfortunately, this not
1015 straightforward. The C front-end maps expressions
1020 in such a way that the two INTEGER_CST nodes for "5" have
1021 different values but identical types. In the latter
1022 case, the 5 is multiplied by sizeof (int) in c-common.c
1023 (pointer_int_sum) to convert it to a byte address, and
1024 yet the type of the node is left unchanged. Argh. What
1025 is consistent though is that the number value corresponds
1026 to bytes (UNITS) offset.
1028 NB: Neither of the following divisors can be trivially
1029 used to recover the original literal:
1031 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1032 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1033 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1034 pp_string (buffer
, "B"); /* pseudo-unit */
1036 else if (host_integerp (node
, 0))
1037 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1038 else if (host_integerp (node
, 1))
1039 pp_unsigned_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1043 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (val
);
1044 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (val
);
1046 if (tree_int_cst_sgn (val
) < 0)
1049 high
= ~high
+ !low
;
1052 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
1054 sprintf (pp_buffer (buffer
)->digit_buffer
,
1055 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
1056 (unsigned HOST_WIDE_INT
) high
, low
);
1057 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
1062 /* Code copied from print_node. */
1065 if (TREE_OVERFLOW (node
))
1066 pp_string (buffer
, " overflow");
1068 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1069 d
= TREE_REAL_CST (node
);
1070 if (REAL_VALUE_ISINF (d
))
1071 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
1072 else if (REAL_VALUE_ISNAN (d
))
1073 pp_string (buffer
, " Nan");
1077 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
1078 pp_string (buffer
, string
);
1083 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
1084 pp_string (buffer
, "0x");
1085 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
1086 output_formatted_integer (buffer
, "%02x", *p
++);
1095 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
1096 pp_string (buffer
, string
);
1101 pp_string (buffer
, "__complex__ (");
1102 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
1103 pp_string (buffer
, ", ");
1104 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
1105 pp_string (buffer
, ")");
1109 pp_string (buffer
, "\"");
1110 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
1111 pp_string (buffer
, "\"");
1117 pp_string (buffer
, "{ ");
1118 for (i
= 0; i
< VECTOR_CST_NELTS (node
); ++i
)
1121 pp_string (buffer
, ", ");
1122 dump_generic_node (buffer
, VECTOR_CST_ELT (node
, i
),
1125 pp_string (buffer
, " }");
1131 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1133 if (TREE_CODE (node
) == METHOD_TYPE
)
1135 if (TYPE_METHOD_BASETYPE (node
))
1136 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
1139 pp_string (buffer
, "<null method basetype>");
1140 pp_string (buffer
, "::");
1142 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1143 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1144 else if (flags
& TDF_NOUID
)
1145 pp_printf (buffer
, "<Txxxx>");
1147 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1148 dump_function_declaration (buffer
, node
, spc
, flags
);
1153 dump_decl_name (buffer
, node
, flags
);
1157 if (DECL_NAME (node
))
1158 dump_decl_name (buffer
, node
, flags
);
1159 else if (LABEL_DECL_UID (node
) != -1)
1160 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1163 if (flags
& TDF_NOUID
)
1164 pp_string (buffer
, "<D.xxxx>");
1166 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1171 if (DECL_IS_BUILTIN (node
))
1173 /* Don't print the declaration of built-in types. */
1176 if (DECL_NAME (node
))
1177 dump_decl_name (buffer
, node
, flags
);
1178 else if (TYPE_NAME (TREE_TYPE (node
)) != node
)
1180 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1181 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1182 && TYPE_METHODS (TREE_TYPE (node
)))
1184 /* The type is a c++ class: all structures have at least
1186 pp_string (buffer
, "class ");
1187 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1192 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1193 ? "union" : "struct "));
1194 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1198 pp_string (buffer
, "<anon>");
1204 case DEBUG_EXPR_DECL
:
1205 case NAMESPACE_DECL
:
1206 dump_decl_name (buffer
, node
, flags
);
1210 pp_string (buffer
, "<retval>");
1214 op0
= TREE_OPERAND (node
, 0);
1217 && (TREE_CODE (op0
) == INDIRECT_REF
1218 || (TREE_CODE (op0
) == MEM_REF
1219 && TREE_CODE (TREE_OPERAND (op0
, 0)) != ADDR_EXPR
1220 && integer_zerop (TREE_OPERAND (op0
, 1))
1221 /* Dump the types of INTEGER_CSTs explicitly, for we
1222 can't infer them and MEM_ATTR caching will share
1223 MEM_REFs with differently-typed op0s. */
1224 && TREE_CODE (TREE_OPERAND (op0
, 0)) != INTEGER_CST
1225 /* Released SSA_NAMES have no TREE_TYPE. */
1226 && TREE_TYPE (TREE_OPERAND (op0
, 0)) != NULL_TREE
1227 /* Same pointer types, but ignoring POINTER_TYPE vs.
1229 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1230 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1231 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1232 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1233 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1234 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1235 /* Same value types ignoring qualifiers. */
1236 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0
))
1237 == TYPE_MAIN_VARIANT
1238 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))))))
1240 op0
= TREE_OPERAND (op0
, 0);
1243 if (op_prio (op0
) < op_prio (node
))
1244 pp_left_paren (buffer
);
1245 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1246 if (op_prio (op0
) < op_prio (node
))
1247 pp_right_paren (buffer
);
1248 pp_string (buffer
, str
);
1249 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1250 op0
= component_ref_field_offset (node
);
1251 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1253 pp_string (buffer
, "{off: ");
1254 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1255 pp_right_brace (buffer
);
1260 pp_string (buffer
, "BIT_FIELD_REF <");
1261 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1262 pp_string (buffer
, ", ");
1263 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1264 pp_string (buffer
, ", ");
1265 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1266 pp_string (buffer
, ">");
1270 case ARRAY_RANGE_REF
:
1271 op0
= TREE_OPERAND (node
, 0);
1272 if (op_prio (op0
) < op_prio (node
))
1273 pp_left_paren (buffer
);
1274 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1275 if (op_prio (op0
) < op_prio (node
))
1276 pp_right_paren (buffer
);
1277 pp_left_bracket (buffer
);
1278 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1279 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1280 pp_string (buffer
, " ...");
1281 pp_right_bracket (buffer
);
1283 op0
= array_ref_low_bound (node
);
1284 op1
= array_ref_element_size (node
);
1286 if (!integer_zerop (op0
)
1287 || TREE_OPERAND (node
, 2)
1288 || TREE_OPERAND (node
, 3))
1290 pp_string (buffer
, "{lb: ");
1291 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1292 pp_string (buffer
, " sz: ");
1293 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1294 pp_right_brace (buffer
);
1300 unsigned HOST_WIDE_INT ix
;
1302 bool is_struct_init
= false;
1303 bool is_array_init
= false;
1304 double_int curidx
= double_int_zero
;
1305 pp_left_brace (buffer
);
1306 if (TREE_CLOBBER_P (node
))
1307 pp_string (buffer
, "CLOBBER");
1308 else if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1309 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1310 is_struct_init
= true;
1311 else if (TREE_CODE (TREE_TYPE (node
)) == ARRAY_TYPE
1312 && TYPE_DOMAIN (TREE_TYPE (node
))
1313 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)))
1314 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
))))
1317 tree minv
= TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)));
1318 is_array_init
= true;
1319 curidx
= tree_to_double_int (minv
);
1321 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1328 dump_generic_node (buffer
, field
, spc
, flags
, false);
1331 else if (is_array_init
1332 && (TREE_CODE (field
) != INTEGER_CST
1333 || tree_to_double_int (field
) != curidx
))
1335 pp_left_bracket (buffer
);
1336 if (TREE_CODE (field
) == RANGE_EXPR
)
1338 dump_generic_node (buffer
, TREE_OPERAND (field
, 0), spc
,
1340 pp_string (buffer
, " ... ");
1341 dump_generic_node (buffer
, TREE_OPERAND (field
, 1), spc
,
1343 if (TREE_CODE (TREE_OPERAND (field
, 1)) == INTEGER_CST
)
1344 curidx
= tree_to_double_int (TREE_OPERAND (field
, 1));
1347 dump_generic_node (buffer
, field
, spc
, flags
, false);
1348 if (TREE_CODE (field
) == INTEGER_CST
)
1349 curidx
= tree_to_double_int (field
);
1350 pp_string (buffer
, "]=");
1354 curidx
+= double_int_one
;
1355 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1356 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1357 val
= TREE_OPERAND (val
, 0);
1358 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1359 dump_decl_name (buffer
, val
, flags
);
1361 dump_generic_node (buffer
, val
, spc
, flags
, false);
1362 if (ix
!= vec_safe_length (CONSTRUCTOR_ELTS (node
)) - 1)
1368 pp_right_brace (buffer
);
1375 if (flags
& TDF_SLIM
)
1377 pp_string (buffer
, "<COMPOUND_EXPR>");
1381 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1382 spc
, flags
, !(flags
& TDF_SLIM
));
1383 if (flags
& TDF_SLIM
)
1384 newline_and_indent (buffer
, spc
);
1391 for (tp
= &TREE_OPERAND (node
, 1);
1392 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1393 tp
= &TREE_OPERAND (*tp
, 1))
1395 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1396 spc
, flags
, !(flags
& TDF_SLIM
));
1397 if (flags
& TDF_SLIM
)
1398 newline_and_indent (buffer
, spc
);
1406 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1410 case STATEMENT_LIST
:
1412 tree_stmt_iterator si
;
1415 if (flags
& TDF_SLIM
)
1417 pp_string (buffer
, "<STATEMENT_LIST>");
1421 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1424 newline_and_indent (buffer
, spc
);
1427 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1434 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1439 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1444 pp_string (buffer
, "TARGET_EXPR <");
1445 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1448 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1449 pp_greater (buffer
);
1453 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1458 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1460 pp_string (buffer
, "if (");
1461 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1462 pp_right_paren (buffer
);
1463 /* The lowered cond_exprs should always be printed in full. */
1464 if (COND_EXPR_THEN (node
)
1465 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1466 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1467 && COND_EXPR_ELSE (node
)
1468 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1469 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1472 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1474 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1476 pp_string (buffer
, " else ");
1477 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1481 else if (!(flags
& TDF_SLIM
))
1483 /* Output COND_EXPR_THEN. */
1484 if (COND_EXPR_THEN (node
))
1486 newline_and_indent (buffer
, spc
+2);
1487 pp_left_brace (buffer
);
1488 newline_and_indent (buffer
, spc
+4);
1489 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1491 newline_and_indent (buffer
, spc
+2);
1492 pp_right_brace (buffer
);
1495 /* Output COND_EXPR_ELSE. */
1496 if (COND_EXPR_ELSE (node
)
1497 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1499 newline_and_indent (buffer
, spc
);
1500 pp_string (buffer
, "else");
1501 newline_and_indent (buffer
, spc
+2);
1502 pp_left_brace (buffer
);
1503 newline_and_indent (buffer
, spc
+4);
1504 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1506 newline_and_indent (buffer
, spc
+2);
1507 pp_right_brace (buffer
);
1514 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1516 pp_question (buffer
);
1518 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1522 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1527 pp_left_brace (buffer
);
1528 if (!(flags
& TDF_SLIM
))
1530 if (BIND_EXPR_VARS (node
))
1532 pp_newline (buffer
);
1534 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= DECL_CHAIN (op0
))
1536 print_declaration (buffer
, op0
, spc
+2, flags
);
1537 pp_newline (buffer
);
1541 newline_and_indent (buffer
, spc
+2);
1542 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1543 newline_and_indent (buffer
, spc
);
1544 pp_right_brace (buffer
);
1550 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1552 /* Print parameters. */
1554 pp_left_paren (buffer
);
1557 call_expr_arg_iterator iter
;
1558 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1560 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1561 if (more_call_expr_args_p (&iter
))
1568 if (CALL_EXPR_VA_ARG_PACK (node
))
1570 if (call_expr_nargs (node
) > 0)
1575 pp_string (buffer
, "__builtin_va_arg_pack ()");
1577 pp_right_paren (buffer
);
1579 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1582 pp_string (buffer
, " [static-chain: ");
1583 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1584 pp_right_bracket (buffer
);
1587 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1588 pp_string (buffer
, " [return slot optimization]");
1589 if (CALL_EXPR_TAILCALL (node
))
1590 pp_string (buffer
, " [tail call]");
1593 case WITH_CLEANUP_EXPR
:
1597 case CLEANUP_POINT_EXPR
:
1598 pp_string (buffer
, "<<cleanup_point ");
1599 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1600 pp_string (buffer
, ">>");
1603 case PLACEHOLDER_EXPR
:
1604 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1605 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1606 pp_greater (buffer
);
1609 /* Binary arithmetic and logic expressions. */
1610 case WIDEN_SUM_EXPR
:
1611 case WIDEN_MULT_EXPR
:
1613 case MULT_HIGHPART_EXPR
:
1615 case POINTER_PLUS_EXPR
:
1617 case TRUNC_DIV_EXPR
:
1619 case FLOOR_DIV_EXPR
:
1620 case ROUND_DIV_EXPR
:
1621 case TRUNC_MOD_EXPR
:
1623 case FLOOR_MOD_EXPR
:
1624 case ROUND_MOD_EXPR
:
1626 case EXACT_DIV_EXPR
:
1631 case VEC_LSHIFT_EXPR
:
1632 case VEC_RSHIFT_EXPR
:
1633 case WIDEN_LSHIFT_EXPR
:
1637 case TRUTH_ANDIF_EXPR
:
1638 case TRUTH_ORIF_EXPR
:
1639 case TRUTH_AND_EXPR
:
1641 case TRUTH_XOR_EXPR
:
1655 case UNORDERED_EXPR
:
1657 const char *op
= op_symbol (node
);
1658 op0
= TREE_OPERAND (node
, 0);
1659 op1
= TREE_OPERAND (node
, 1);
1661 /* When the operands are expressions with less priority,
1662 keep semantics of the tree representation. */
1663 if (op_prio (op0
) <= op_prio (node
))
1665 pp_left_paren (buffer
);
1666 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1667 pp_right_paren (buffer
);
1670 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1673 pp_string (buffer
, op
);
1676 /* When the operands are expressions with less priority,
1677 keep semantics of the tree representation. */
1678 if (op_prio (op1
) <= op_prio (node
))
1680 pp_left_paren (buffer
);
1681 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1682 pp_right_paren (buffer
);
1685 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1689 /* Unary arithmetic and logic expressions. */
1692 case TRUTH_NOT_EXPR
:
1694 case PREDECREMENT_EXPR
:
1695 case PREINCREMENT_EXPR
:
1697 if (TREE_CODE (node
) == ADDR_EXPR
1698 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1699 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1700 ; /* Do not output '&' for strings and function pointers. */
1702 pp_string (buffer
, op_symbol (node
));
1704 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1706 pp_left_paren (buffer
);
1707 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1708 pp_right_paren (buffer
);
1711 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1714 case POSTDECREMENT_EXPR
:
1715 case POSTINCREMENT_EXPR
:
1716 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1718 pp_left_paren (buffer
);
1719 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1720 pp_right_paren (buffer
);
1723 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1724 pp_string (buffer
, op_symbol (node
));
1728 pp_string (buffer
, "MIN_EXPR <");
1729 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1730 pp_string (buffer
, ", ");
1731 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1732 pp_greater (buffer
);
1736 pp_string (buffer
, "MAX_EXPR <");
1737 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1738 pp_string (buffer
, ", ");
1739 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1740 pp_greater (buffer
);
1744 pp_string (buffer
, "ABS_EXPR <");
1745 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1746 pp_greater (buffer
);
1753 case ADDR_SPACE_CONVERT_EXPR
:
1754 case FIXED_CONVERT_EXPR
:
1755 case FIX_TRUNC_EXPR
:
1758 type
= TREE_TYPE (node
);
1759 op0
= TREE_OPERAND (node
, 0);
1760 if (type
!= TREE_TYPE (op0
))
1762 pp_left_paren (buffer
);
1763 dump_generic_node (buffer
, type
, spc
, flags
, false);
1764 pp_string (buffer
, ") ");
1766 if (op_prio (op0
) < op_prio (node
))
1767 pp_left_paren (buffer
);
1768 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1769 if (op_prio (op0
) < op_prio (node
))
1770 pp_right_paren (buffer
);
1773 case VIEW_CONVERT_EXPR
:
1774 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1775 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1776 pp_string (buffer
, ">(");
1777 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1778 pp_right_paren (buffer
);
1782 pp_string (buffer
, "((");
1783 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1784 pp_string (buffer
, "))");
1787 case NON_LVALUE_EXPR
:
1788 pp_string (buffer
, "NON_LVALUE_EXPR <");
1789 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1790 pp_greater (buffer
);
1794 pp_string (buffer
, "SAVE_EXPR <");
1795 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1796 pp_greater (buffer
);
1800 pp_string (buffer
, "COMPLEX_EXPR <");
1801 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1802 pp_string (buffer
, ", ");
1803 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1804 pp_string (buffer
, ">");
1808 pp_string (buffer
, "CONJ_EXPR <");
1809 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1810 pp_string (buffer
, ">");
1814 pp_string (buffer
, "REALPART_EXPR <");
1815 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1816 pp_string (buffer
, ">");
1820 pp_string (buffer
, "IMAGPART_EXPR <");
1821 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1822 pp_string (buffer
, ">");
1826 pp_string (buffer
, "VA_ARG_EXPR <");
1827 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1828 pp_string (buffer
, ">");
1831 case TRY_FINALLY_EXPR
:
1832 case TRY_CATCH_EXPR
:
1833 pp_string (buffer
, "try");
1834 newline_and_indent (buffer
, spc
+2);
1835 pp_string (buffer
, "{");
1836 newline_and_indent (buffer
, spc
+4);
1837 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1838 newline_and_indent (buffer
, spc
+2);
1839 pp_string (buffer
, "}");
1840 newline_and_indent (buffer
, spc
);
1842 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1843 newline_and_indent (buffer
, spc
+2);
1844 pp_string (buffer
, "{");
1845 newline_and_indent (buffer
, spc
+4);
1846 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1847 newline_and_indent (buffer
, spc
+2);
1848 pp_string (buffer
, "}");
1853 pp_string (buffer
, "catch (");
1854 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1855 pp_string (buffer
, ")");
1856 newline_and_indent (buffer
, spc
+2);
1857 pp_string (buffer
, "{");
1858 newline_and_indent (buffer
, spc
+4);
1859 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1860 newline_and_indent (buffer
, spc
+2);
1861 pp_string (buffer
, "}");
1865 case EH_FILTER_EXPR
:
1866 pp_string (buffer
, "<<<eh_filter (");
1867 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1868 pp_string (buffer
, ")>>>");
1869 newline_and_indent (buffer
, spc
+2);
1870 pp_string (buffer
, "{");
1871 newline_and_indent (buffer
, spc
+4);
1872 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1873 newline_and_indent (buffer
, spc
+2);
1874 pp_string (buffer
, "}");
1879 op0
= TREE_OPERAND (node
, 0);
1880 /* If this is for break or continue, don't bother printing it. */
1881 if (DECL_NAME (op0
))
1883 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1884 if (strcmp (name
, "break") == 0
1885 || strcmp (name
, "continue") == 0)
1888 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1890 if (DECL_NONLOCAL (op0
))
1891 pp_string (buffer
, " [non-local]");
1895 pp_string (buffer
, "while (1)");
1896 if (!(flags
& TDF_SLIM
))
1898 newline_and_indent (buffer
, spc
+2);
1899 pp_left_brace (buffer
);
1900 newline_and_indent (buffer
, spc
+4);
1901 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1902 newline_and_indent (buffer
, spc
+2);
1903 pp_right_brace (buffer
);
1909 pp_string (buffer
, "// predicted ");
1910 if (PREDICT_EXPR_OUTCOME (node
))
1911 pp_string (buffer
, "likely by ");
1913 pp_string (buffer
, "unlikely by ");
1914 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
1915 pp_string (buffer
, " predictor.");
1919 pp_string (buffer
, "return");
1920 op0
= TREE_OPERAND (node
, 0);
1924 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1925 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
1928 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1933 pp_string (buffer
, "if (");
1934 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1935 pp_string (buffer
, ") break");
1939 pp_string (buffer
, "switch (");
1940 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1941 pp_right_paren (buffer
);
1942 if (!(flags
& TDF_SLIM
))
1944 newline_and_indent (buffer
, spc
+2);
1945 pp_left_brace (buffer
);
1946 if (SWITCH_BODY (node
))
1948 newline_and_indent (buffer
, spc
+4);
1949 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1954 tree vec
= SWITCH_LABELS (node
);
1955 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1956 for (i
= 0; i
< n
; ++i
)
1958 tree elt
= TREE_VEC_ELT (vec
, i
);
1959 newline_and_indent (buffer
, spc
+4);
1962 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1963 pp_string (buffer
, " goto ");
1964 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1966 pp_semicolon (buffer
);
1969 pp_string (buffer
, "case ???: goto ???;");
1972 newline_and_indent (buffer
, spc
+2);
1973 pp_right_brace (buffer
);
1979 op0
= GOTO_DESTINATION (node
);
1980 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1982 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1983 if (strcmp (name
, "break") == 0
1984 || strcmp (name
, "continue") == 0)
1986 pp_string (buffer
, name
);
1990 pp_string (buffer
, "goto ");
1991 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1995 pp_string (buffer
, "__asm__");
1996 if (ASM_VOLATILE_P (node
))
1997 pp_string (buffer
, " __volatile__");
1998 pp_left_paren (buffer
);
1999 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
2001 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
2003 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
2004 if (ASM_CLOBBERS (node
))
2007 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
2009 pp_string (buffer
, ")");
2012 case CASE_LABEL_EXPR
:
2013 if (CASE_LOW (node
) && CASE_HIGH (node
))
2015 pp_string (buffer
, "case ");
2016 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
2017 pp_string (buffer
, " ... ");
2018 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
2020 else if (CASE_LOW (node
))
2022 pp_string (buffer
, "case ");
2023 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
2026 pp_string (buffer
, "default");
2031 pp_string (buffer
, "OBJ_TYPE_REF(");
2032 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
2033 pp_semicolon (buffer
);
2034 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
2036 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
2037 pp_right_paren (buffer
);
2041 if (SSA_NAME_IDENTIFIER (node
))
2042 dump_generic_node (buffer
, SSA_NAME_IDENTIFIER (node
),
2044 pp_string (buffer
, "_");
2045 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
2046 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
2047 pp_string (buffer
, "(ab)");
2048 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
2049 pp_string (buffer
, "(D)");
2052 case WITH_SIZE_EXPR
:
2053 pp_string (buffer
, "WITH_SIZE_EXPR <");
2054 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2055 pp_string (buffer
, ", ");
2056 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2057 pp_string (buffer
, ">");
2061 pp_string (buffer
, "ASSERT_EXPR <");
2062 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
2063 pp_string (buffer
, ", ");
2064 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
2065 pp_string (buffer
, ">");
2069 pp_string (buffer
, "scev_known");
2072 case SCEV_NOT_KNOWN
:
2073 pp_string (buffer
, "scev_not_known");
2076 case POLYNOMIAL_CHREC
:
2077 pp_string (buffer
, "{");
2078 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
2079 pp_string (buffer
, ", +, ");
2080 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
2081 pp_string (buffer
, "}_");
2082 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
2086 case REALIGN_LOAD_EXPR
:
2087 pp_string (buffer
, "REALIGN_LOAD <");
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
, " VEC_COND_EXPR < ");
2098 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2099 pp_string (buffer
, " , ");
2100 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2101 pp_string (buffer
, " , ");
2102 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2103 pp_string (buffer
, " > ");
2107 pp_string (buffer
, " VEC_PERM_EXPR < ");
2108 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2109 pp_string (buffer
, " , ");
2110 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2111 pp_string (buffer
, " , ");
2112 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2113 pp_string (buffer
, " > ");
2117 pp_string (buffer
, " DOT_PROD_EXPR < ");
2118 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2119 pp_string (buffer
, ", ");
2120 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2121 pp_string (buffer
, ", ");
2122 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2123 pp_string (buffer
, " > ");
2126 case WIDEN_MULT_PLUS_EXPR
:
2127 pp_string (buffer
, " WIDEN_MULT_PLUS_EXPR < ");
2128 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2129 pp_string (buffer
, ", ");
2130 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2131 pp_string (buffer
, ", ");
2132 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2133 pp_string (buffer
, " > ");
2136 case WIDEN_MULT_MINUS_EXPR
:
2137 pp_string (buffer
, " WIDEN_MULT_MINUS_EXPR < ");
2138 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2139 pp_string (buffer
, ", ");
2140 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2141 pp_string (buffer
, ", ");
2142 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2143 pp_string (buffer
, " > ");
2147 pp_string (buffer
, " FMA_EXPR < ");
2148 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2149 pp_string (buffer
, ", ");
2150 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2151 pp_string (buffer
, ", ");
2152 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2153 pp_string (buffer
, " > ");
2157 pp_string (buffer
, "#pragma omp parallel");
2158 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
2161 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
2163 newline_and_indent (buffer
, spc
+ 2);
2164 pp_left_brace (buffer
);
2165 newline_and_indent (buffer
, spc
+ 4);
2166 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
2167 newline_and_indent (buffer
, spc
+ 2);
2168 pp_right_brace (buffer
);
2174 pp_string (buffer
, "#pragma omp task");
2175 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
2179 pp_string (buffer
, "#pragma omp for");
2180 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
2182 if (!(flags
& TDF_SLIM
))
2186 if (OMP_FOR_PRE_BODY (node
))
2188 newline_and_indent (buffer
, spc
+ 2);
2189 pp_left_brace (buffer
);
2191 newline_and_indent (buffer
, spc
);
2192 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
2196 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
2199 newline_and_indent (buffer
, spc
);
2200 pp_string (buffer
, "for (");
2201 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
2203 pp_string (buffer
, "; ");
2204 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
2206 pp_string (buffer
, "; ");
2207 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
2209 pp_string (buffer
, ")");
2211 if (OMP_FOR_BODY (node
))
2213 newline_and_indent (buffer
, spc
+ 2);
2214 pp_left_brace (buffer
);
2215 newline_and_indent (buffer
, spc
+ 4);
2216 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
2218 newline_and_indent (buffer
, spc
+ 2);
2219 pp_right_brace (buffer
);
2221 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
2222 if (OMP_FOR_PRE_BODY (node
))
2225 newline_and_indent (buffer
, spc
+ 2);
2226 pp_right_brace (buffer
);
2233 pp_string (buffer
, "#pragma omp sections");
2234 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2238 pp_string (buffer
, "#pragma omp section");
2242 pp_string (buffer
, "#pragma omp master");
2246 pp_string (buffer
, "#pragma omp ordered");
2250 pp_string (buffer
, "#pragma omp critical");
2251 if (OMP_CRITICAL_NAME (node
))
2254 pp_left_paren (buffer
);
2255 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2257 pp_right_paren (buffer
);
2262 pp_string (buffer
, "#pragma omp atomic");
2263 newline_and_indent (buffer
, spc
+ 2);
2264 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2268 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2271 case OMP_ATOMIC_READ
:
2272 pp_string (buffer
, "#pragma omp atomic read");
2273 newline_and_indent (buffer
, spc
+ 2);
2274 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2278 case OMP_ATOMIC_CAPTURE_OLD
:
2279 case OMP_ATOMIC_CAPTURE_NEW
:
2280 pp_string (buffer
, "#pragma omp atomic capture");
2281 newline_and_indent (buffer
, spc
+ 2);
2282 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2286 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2290 pp_string (buffer
, "#pragma omp single");
2291 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2295 dump_omp_clause (buffer
, node
, spc
, flags
);
2299 case TRANSACTION_EXPR
:
2300 if (TRANSACTION_EXPR_OUTER (node
))
2301 pp_string (buffer
, "__transaction_atomic [[outer]]");
2302 else if (TRANSACTION_EXPR_RELAXED (node
))
2303 pp_string (buffer
, "__transaction_relaxed");
2305 pp_string (buffer
, "__transaction_atomic");
2306 if (!(flags
& TDF_SLIM
) && TRANSACTION_EXPR_BODY (node
))
2308 newline_and_indent (buffer
, spc
);
2309 pp_left_brace (buffer
);
2310 newline_and_indent (buffer
, spc
+ 2);
2311 dump_generic_node (buffer
, TRANSACTION_EXPR_BODY (node
),
2312 spc
+ 2, flags
, false);
2313 newline_and_indent (buffer
, spc
);
2314 pp_right_brace (buffer
);
2319 case REDUC_MAX_EXPR
:
2320 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2321 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2322 pp_string (buffer
, " > ");
2325 case REDUC_MIN_EXPR
:
2326 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2327 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2328 pp_string (buffer
, " > ");
2331 case REDUC_PLUS_EXPR
:
2332 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2333 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2334 pp_string (buffer
, " > ");
2337 case VEC_WIDEN_MULT_HI_EXPR
:
2338 case VEC_WIDEN_MULT_LO_EXPR
:
2339 case VEC_WIDEN_MULT_EVEN_EXPR
:
2340 case VEC_WIDEN_MULT_ODD_EXPR
:
2341 case VEC_WIDEN_LSHIFT_HI_EXPR
:
2342 case VEC_WIDEN_LSHIFT_LO_EXPR
:
2344 for (str
= tree_code_name
[code
]; *str
; str
++)
2345 pp_character (buffer
, TOUPPER (*str
));
2346 pp_string (buffer
, " < ");
2347 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2348 pp_string (buffer
, ", ");
2349 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2350 pp_string (buffer
, " > ");
2353 case VEC_UNPACK_HI_EXPR
:
2354 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2355 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2356 pp_string (buffer
, " > ");
2359 case VEC_UNPACK_LO_EXPR
:
2360 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2361 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2362 pp_string (buffer
, " > ");
2365 case VEC_UNPACK_FLOAT_HI_EXPR
:
2366 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2367 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2368 pp_string (buffer
, " > ");
2371 case VEC_UNPACK_FLOAT_LO_EXPR
:
2372 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2373 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2374 pp_string (buffer
, " > ");
2377 case VEC_PACK_TRUNC_EXPR
:
2378 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2379 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2380 pp_string (buffer
, ", ");
2381 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2382 pp_string (buffer
, " > ");
2385 case VEC_PACK_SAT_EXPR
:
2386 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2387 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2388 pp_string (buffer
, ", ");
2389 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2390 pp_string (buffer
, " > ");
2393 case VEC_PACK_FIX_TRUNC_EXPR
:
2394 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2395 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2396 pp_string (buffer
, ", ");
2397 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2398 pp_string (buffer
, " > ");
2402 dump_block_node (buffer
, node
, spc
, flags
);
2409 if (is_stmt
&& is_expr
)
2410 pp_semicolon (buffer
);
2415 /* Print the declaration of a variable. */
2418 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2422 if (TREE_CODE (t
) == TYPE_DECL
)
2423 pp_string (buffer
, "typedef ");
2425 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2426 pp_string (buffer
, "register ");
2428 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2429 pp_string (buffer
, "extern ");
2430 else if (TREE_STATIC (t
))
2431 pp_string (buffer
, "static ");
2433 /* Print the type and name. */
2434 if (TREE_TYPE (t
) && TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2438 /* Print array's type. */
2439 tmp
= TREE_TYPE (t
);
2440 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2441 tmp
= TREE_TYPE (tmp
);
2442 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2444 /* Print variable's name. */
2446 dump_generic_node (buffer
, t
, spc
, flags
, false);
2448 /* Print the dimensions. */
2449 tmp
= TREE_TYPE (t
);
2450 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2452 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2453 tmp
= TREE_TYPE (tmp
);
2456 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2458 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2460 dump_decl_name (buffer
, t
, flags
);
2461 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2465 /* Print type declaration. */
2466 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2468 /* Print variable's name. */
2470 dump_generic_node (buffer
, t
, spc
, flags
, false);
2473 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2475 pp_string (buffer
, " __asm__ ");
2476 pp_left_paren (buffer
);
2477 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2478 pp_right_paren (buffer
);
2481 /* The initial value of a function serves to determine whether the function
2482 is declared or defined. So the following does not apply to function
2484 if (TREE_CODE (t
) != FUNCTION_DECL
)
2486 /* Print the initial value. */
2487 if (DECL_INITIAL (t
))
2492 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2496 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2498 pp_string (buffer
, " [value-expr: ");
2499 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2500 pp_right_bracket (buffer
);
2503 pp_semicolon (buffer
);
2507 /* Prints a structure: name, fields, and methods.
2508 FIXME: Still incomplete. */
2511 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2513 /* Print the name of the structure. */
2514 if (TYPE_NAME (node
))
2517 if (TREE_CODE (node
) == RECORD_TYPE
)
2518 pp_string (buffer
, "struct ");
2519 else if ((TREE_CODE (node
) == UNION_TYPE
2520 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2521 pp_string (buffer
, "union ");
2523 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2526 /* Print the contents of the structure. */
2527 pp_newline (buffer
);
2529 pp_left_brace (buffer
);
2530 pp_newline (buffer
);
2532 /* Print the fields of the structure. */
2535 tmp
= TYPE_FIELDS (node
);
2538 /* Avoid to print recursively the structure. */
2539 /* FIXME : Not implemented correctly...,
2540 what about the case when we have a cycle in the contain graph? ...
2541 Maybe this could be solved by looking at the scope in which the
2542 structure was declared. */
2543 if (TREE_TYPE (tmp
) != node
2544 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2545 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2547 print_declaration (buffer
, tmp
, spc
+2, flags
);
2548 pp_newline (buffer
);
2550 tmp
= DECL_CHAIN (tmp
);
2554 pp_right_brace (buffer
);
2557 /* Return the priority of the operator CODE.
2559 From lowest to highest precedence with either left-to-right (L-R)
2560 or right-to-left (R-L) associativity]:
2563 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2575 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2576 15 [L-R] fn() [] -> .
2578 unary +, - and * have higher precedence than the corresponding binary
2582 op_code_prio (enum tree_code code
)
2599 case TRUTH_ORIF_EXPR
:
2602 case TRUTH_AND_EXPR
:
2603 case TRUTH_ANDIF_EXPR
:
2610 case TRUTH_XOR_EXPR
:
2627 case UNORDERED_EXPR
:
2638 case VEC_WIDEN_LSHIFT_HI_EXPR
:
2639 case VEC_WIDEN_LSHIFT_LO_EXPR
:
2640 case WIDEN_LSHIFT_EXPR
:
2643 case WIDEN_SUM_EXPR
:
2645 case POINTER_PLUS_EXPR
:
2649 case VEC_WIDEN_MULT_HI_EXPR
:
2650 case VEC_WIDEN_MULT_LO_EXPR
:
2651 case WIDEN_MULT_EXPR
:
2653 case WIDEN_MULT_PLUS_EXPR
:
2654 case WIDEN_MULT_MINUS_EXPR
:
2656 case MULT_HIGHPART_EXPR
:
2657 case TRUNC_DIV_EXPR
:
2659 case FLOOR_DIV_EXPR
:
2660 case ROUND_DIV_EXPR
:
2662 case EXACT_DIV_EXPR
:
2663 case TRUNC_MOD_EXPR
:
2665 case FLOOR_MOD_EXPR
:
2666 case ROUND_MOD_EXPR
:
2670 case TRUTH_NOT_EXPR
:
2672 case POSTINCREMENT_EXPR
:
2673 case POSTDECREMENT_EXPR
:
2674 case PREINCREMENT_EXPR
:
2675 case PREDECREMENT_EXPR
:
2681 case FIX_TRUNC_EXPR
:
2687 case ARRAY_RANGE_REF
:
2691 /* Special expressions. */
2697 case REDUC_MAX_EXPR
:
2698 case REDUC_MIN_EXPR
:
2699 case REDUC_PLUS_EXPR
:
2700 case VEC_LSHIFT_EXPR
:
2701 case VEC_RSHIFT_EXPR
:
2702 case VEC_UNPACK_HI_EXPR
:
2703 case VEC_UNPACK_LO_EXPR
:
2704 case VEC_UNPACK_FLOAT_HI_EXPR
:
2705 case VEC_UNPACK_FLOAT_LO_EXPR
:
2706 case VEC_PACK_TRUNC_EXPR
:
2707 case VEC_PACK_SAT_EXPR
:
2711 /* Return an arbitrarily high precedence to avoid surrounding single
2712 VAR_DECLs in ()s. */
2717 /* Return the priority of the operator OP. */
2720 op_prio (const_tree op
)
2722 enum tree_code code
;
2727 code
= TREE_CODE (op
);
2728 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2729 return op_prio (TREE_OPERAND (op
, 0));
2731 return op_code_prio (code
);
2734 /* Return the symbol associated with operator CODE. */
2737 op_symbol_code (enum tree_code code
)
2745 case TRUTH_ORIF_EXPR
:
2748 case TRUTH_AND_EXPR
:
2749 case TRUTH_ANDIF_EXPR
:
2755 case TRUTH_XOR_EXPR
:
2765 case UNORDERED_EXPR
:
2811 case VEC_LSHIFT_EXPR
:
2814 case VEC_RSHIFT_EXPR
:
2817 case WIDEN_LSHIFT_EXPR
:
2820 case POINTER_PLUS_EXPR
:
2826 case REDUC_PLUS_EXPR
:
2829 case WIDEN_SUM_EXPR
:
2832 case WIDEN_MULT_EXPR
:
2835 case MULT_HIGHPART_EXPR
:
2845 case TRUTH_NOT_EXPR
:
2852 case TRUNC_DIV_EXPR
:
2859 case FLOOR_DIV_EXPR
:
2862 case ROUND_DIV_EXPR
:
2865 case EXACT_DIV_EXPR
:
2868 case TRUNC_MOD_EXPR
:
2874 case FLOOR_MOD_EXPR
:
2877 case ROUND_MOD_EXPR
:
2880 case PREDECREMENT_EXPR
:
2883 case PREINCREMENT_EXPR
:
2886 case POSTDECREMENT_EXPR
:
2889 case POSTINCREMENT_EXPR
:
2899 return "<<< ??? >>>";
2903 /* Return the symbol associated with operator OP. */
2906 op_symbol (const_tree op
)
2908 return op_symbol_code (TREE_CODE (op
));
2911 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2912 the gimple_call_fn of a GIMPLE_CALL. */
2915 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
2919 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2920 op0
= TREE_OPERAND (op0
, 0);
2923 switch (TREE_CODE (op0
))
2928 dump_function_name (buffer
, op0
, flags
);
2934 op0
= TREE_OPERAND (op0
, 0);
2938 pp_string (buffer
, "(");
2939 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
2940 pp_string (buffer
, ") ? ");
2941 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
2942 pp_string (buffer
, " : ");
2943 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
2947 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2948 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
2950 dump_generic_node (buffer
, op0
, 0, flags
, false);
2954 if (integer_zerop (TREE_OPERAND (op0
, 1)))
2956 op0
= TREE_OPERAND (op0
, 0);
2963 dump_generic_node (buffer
, op0
, 0, flags
, false);
2971 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2974 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2984 pp_string (buffer
, "\\b");
2988 pp_string (buffer
, "\\f");
2992 pp_string (buffer
, "\\n");
2996 pp_string (buffer
, "\\r");
3000 pp_string (buffer
, "\\t");
3004 pp_string (buffer
, "\\v");
3008 pp_string (buffer
, "\\\\");
3012 pp_string (buffer
, "\\\"");
3016 pp_string (buffer
, "\\'");
3019 /* No need to handle \0; the loop terminates on \0. */
3022 pp_string (buffer
, "\\1");
3026 pp_string (buffer
, "\\2");
3030 pp_string (buffer
, "\\3");
3034 pp_string (buffer
, "\\4");
3038 pp_string (buffer
, "\\5");
3042 pp_string (buffer
, "\\6");
3046 pp_string (buffer
, "\\7");
3050 pp_character (buffer
, str
[0]);
3058 maybe_init_pretty_print (FILE *file
)
3062 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
3063 pp_needs_newline (&buffer
) = true;
3064 pp_translate_identifiers (&buffer
) = false;
3068 buffer
.buffer
->stream
= file
;
3072 newline_and_indent (pretty_printer
*buffer
, int spc
)
3074 pp_newline (buffer
);
3078 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3079 it can also be used in front ends.
3080 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3084 percent_K_format (text_info
*text
)
3086 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
3087 gcc_assert (text
->locus
!= NULL
);
3088 *text
->locus
= EXPR_LOCATION (t
);
3089 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
3090 block
= TREE_BLOCK (t
);
3091 *pp_ti_abstract_origin (text
) = NULL
;
3093 && TREE_CODE (block
) == BLOCK
3094 && BLOCK_ABSTRACT_ORIGIN (block
))
3096 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
3098 while (TREE_CODE (ao
) == BLOCK
3099 && BLOCK_ABSTRACT_ORIGIN (ao
)
3100 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
3101 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
3103 if (TREE_CODE (ao
) == FUNCTION_DECL
)
3105 *pp_ti_abstract_origin (text
) = block
;
3108 block
= BLOCK_SUPERCONTEXT (block
);
3112 /* Print the identifier ID to PRETTY-PRINTER. */
3115 pp_base_tree_identifier (pretty_printer
*pp
, tree id
)
3117 if (pp_translate_identifiers (pp
))
3119 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
3120 pp_append_text (pp
, text
, text
+ strlen (text
));
3123 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
3124 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));
3127 /* A helper function that is used to dump function information before the
3131 dump_function_header (FILE *dump_file
, tree fdecl
, int flags
)
3133 const char *dname
, *aname
;
3134 struct cgraph_node
*node
= cgraph_get_node (fdecl
);
3135 struct function
*fun
= DECL_STRUCT_FUNCTION (fdecl
);
3137 dname
= lang_hooks
.decl_printable_name (fdecl
, 2);
3139 if (DECL_ASSEMBLER_NAME_SET_P (fdecl
))
3140 aname
= (IDENTIFIER_POINTER
3141 (DECL_ASSEMBLER_NAME (fdecl
)));
3143 aname
= "<unset-asm-name>";
3145 fprintf (dump_file
, "\n;; Function %s (%s, funcdef_no=%d",
3146 dname
, aname
, fun
->funcdef_no
);
3147 if (!(flags
& TDF_NOUID
))
3148 fprintf (dump_file
, ", decl_uid=%d", DECL_UID (fdecl
));
3151 fprintf (dump_file
, ", symbol_order=%d)%s\n\n", node
->symbol
.order
,
3152 node
->frequency
== NODE_FREQUENCY_HOT
3154 : node
->frequency
== NODE_FREQUENCY_UNLIKELY_EXECUTED
3155 ? " (unlikely executed)"
3156 : node
->frequency
== NODE_FREQUENCY_EXECUTED_ONCE
3157 ? " (executed once)"
3161 fprintf (dump_file
, ")\n\n");