1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
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"
27 #include "diagnostic.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 "fixed-value.h"
36 #include "value-prof.h"
38 /* Local functions, macros and variables. */
39 static int op_prio (tree
);
40 static const char *op_symbol (tree
);
41 static void pretty_print_string (pretty_printer
*, const char*);
42 static void print_call_name (pretty_printer
*, tree
);
43 static void newline_and_indent (pretty_printer
*, int);
44 static void maybe_init_pretty_print (FILE *);
45 static void print_declaration (pretty_printer
*, tree
, int, int);
46 static void print_struct_decl (pretty_printer
*, tree
, int, int);
47 static void do_niy (pretty_printer
*, tree
);
48 static void dump_vops (pretty_printer
*, tree
, int, int);
49 static void dump_generic_bb_buff (pretty_printer
*, basic_block
, int, int);
51 #define INDENT(SPACE) do { \
52 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
54 #define NIY do_niy(buffer,node)
56 #define PRINT_FUNCTION_NAME(NODE) pp_printf \
57 (buffer, "%s", TREE_CODE (NODE) == NOP_EXPR ? \
58 lang_hooks.decl_printable_name (TREE_OPERAND (NODE, 0), 1) : \
59 lang_hooks.decl_printable_name (NODE, 1))
61 static pretty_printer buffer
;
62 static int initialized
= 0;
64 /* Try to print something for an unknown tree code. */
67 do_niy (pretty_printer
*buffer
, tree node
)
71 pp_string (buffer
, "<<< Unknown tree: ");
72 pp_string (buffer
, tree_code_name
[(int) TREE_CODE (node
)]);
76 len
= TREE_OPERAND_LENGTH (node
);
77 for (i
= 0; i
< len
; ++i
)
79 newline_and_indent (buffer
, 2);
80 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0, false);
84 pp_string (buffer
, " >>>\n");
88 debug_generic_expr (tree t
)
90 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
91 fprintf (stderr
, "\n");
95 debug_generic_stmt (tree t
)
97 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
98 fprintf (stderr
, "\n");
102 debug_tree_chain (tree t
)
106 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
107 fprintf(stderr
, " ");
110 fprintf (stderr
, "\n");
113 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
115 print_generic_decl (FILE *file
, tree decl
, int flags
)
117 maybe_init_pretty_print (file
);
118 print_declaration (&buffer
, decl
, 2, flags
);
119 pp_write_text_to_stream (&buffer
);
122 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
123 to show in the dump. See TDF_* in tree.h. */
126 print_generic_stmt (FILE *file
, tree t
, int flags
)
128 maybe_init_pretty_print (file
);
129 dump_generic_node (&buffer
, t
, 0, flags
, true);
133 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
134 to show in the dump. See TDF_* in tree.h. The output is indented by
138 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
142 maybe_init_pretty_print (file
);
144 for (i
= 0; i
< indent
; i
++)
146 dump_generic_node (&buffer
, t
, indent
, flags
, true);
150 /* Print a single expression T on file FILE. FLAGS specifies details to show
151 in the dump. See TDF_* in tree.h. */
154 print_generic_expr (FILE *file
, tree t
, int flags
)
156 maybe_init_pretty_print (file
);
157 dump_generic_node (&buffer
, t
, 0, flags
, false);
160 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
164 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
169 pp_tree_identifier (buffer
, DECL_NAME (t
));
170 if ((flags
& TDF_UID
)
171 || DECL_NAME (t
) == NULL_TREE
)
173 if (TREE_CODE (t
) == LABEL_DECL
174 && LABEL_DECL_UID (t
) != -1)
175 pp_printf (buffer
, "L." HOST_WIDE_INT_PRINT_DEC
,
179 char c
= TREE_CODE (t
) == CONST_DECL
? 'C' : 'D';
180 pp_printf (buffer
, "%c.%u", c
, DECL_UID (t
));
185 /* Like the above, but used for pretty printing function calls. */
188 dump_function_name (pretty_printer
*buffer
, tree node
)
190 if (DECL_NAME (node
))
191 PRINT_FUNCTION_NAME (node
);
193 dump_decl_name (buffer
, node
, 0);
196 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
197 FLAGS are as in dump_generic_node. */
200 dump_function_declaration (pretty_printer
*buffer
, tree node
,
203 bool wrote_arg
= false;
207 pp_character (buffer
, '(');
209 /* Print the argument types. The last element in the list is a VOID_TYPE.
210 The following avoids printing the last element. */
211 arg
= TYPE_ARG_TYPES (node
);
212 while (arg
&& TREE_CHAIN (arg
) && arg
!= error_mark_node
)
215 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
216 arg
= TREE_CHAIN (arg
);
217 if (TREE_CHAIN (arg
) && TREE_CODE (TREE_CHAIN (arg
)) == TREE_LIST
)
219 pp_character (buffer
, ',');
225 pp_string (buffer
, "void");
227 pp_character (buffer
, ')');
230 /* Dump the domain associated with an array. */
233 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
235 pp_character (buffer
, '[');
238 tree min
= TYPE_MIN_VALUE (domain
);
239 tree max
= TYPE_MAX_VALUE (domain
);
242 && integer_zerop (min
)
243 && host_integerp (max
, 0))
244 pp_wide_integer (buffer
, TREE_INT_CST_LOW (max
) + 1);
248 dump_generic_node (buffer
, min
, spc
, flags
, false);
249 pp_character (buffer
, ':');
251 dump_generic_node (buffer
, max
, spc
, flags
, false);
255 pp_string (buffer
, "<unknown>");
256 pp_character (buffer
, ']');
260 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
261 dump_generic_node. */
264 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
268 switch (OMP_CLAUSE_CODE (clause
))
270 case OMP_CLAUSE_PRIVATE
:
273 case OMP_CLAUSE_SHARED
:
276 case OMP_CLAUSE_FIRSTPRIVATE
:
277 name
= "firstprivate";
279 case OMP_CLAUSE_LASTPRIVATE
:
280 name
= "lastprivate";
282 case OMP_CLAUSE_COPYIN
:
285 case OMP_CLAUSE_COPYPRIVATE
:
286 name
= "copyprivate";
289 pp_string (buffer
, name
);
290 pp_character (buffer
, '(');
291 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
293 pp_character (buffer
, ')');
296 case OMP_CLAUSE_REDUCTION
:
297 pp_string (buffer
, "reduction(");
298 pp_string (buffer
, op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
299 pp_character (buffer
, ':');
300 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
302 pp_character (buffer
, ')');
306 pp_string (buffer
, "if(");
307 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
309 pp_character (buffer
, ')');
312 case OMP_CLAUSE_NUM_THREADS
:
313 pp_string (buffer
, "num_threads(");
314 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
316 pp_character (buffer
, ')');
319 case OMP_CLAUSE_NOWAIT
:
320 pp_string (buffer
, "nowait");
322 case OMP_CLAUSE_ORDERED
:
323 pp_string (buffer
, "ordered");
326 case OMP_CLAUSE_DEFAULT
:
327 pp_string (buffer
, "default(");
328 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
330 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
332 case OMP_CLAUSE_DEFAULT_SHARED
:
333 pp_string (buffer
, "shared");
335 case OMP_CLAUSE_DEFAULT_NONE
:
336 pp_string (buffer
, "none");
338 case OMP_CLAUSE_DEFAULT_PRIVATE
:
339 pp_string (buffer
, "private");
344 pp_character (buffer
, ')');
347 case OMP_CLAUSE_SCHEDULE
:
348 pp_string (buffer
, "schedule(");
349 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
351 case OMP_CLAUSE_SCHEDULE_STATIC
:
352 pp_string (buffer
, "static");
354 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
355 pp_string (buffer
, "dynamic");
357 case OMP_CLAUSE_SCHEDULE_GUIDED
:
358 pp_string (buffer
, "guided");
360 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
361 pp_string (buffer
, "runtime");
366 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
368 pp_character (buffer
, ',');
369 dump_generic_node (buffer
,
370 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
373 pp_character (buffer
, ')');
377 /* Should never happen. */
378 dump_generic_node (buffer
, clause
, spc
, flags
, false);
384 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
385 dump_generic_node. */
388 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
396 dump_omp_clause (buffer
, clause
, spc
, flags
);
397 clause
= OMP_CLAUSE_CHAIN (clause
);
405 /* Dump the set of decls SYMS. BUFFER, SPC and FLAGS are as in
406 dump_generic_node. */
409 dump_symbols (pretty_printer
*buffer
, bitmap syms
, int flags
)
415 pp_string (buffer
, "NIL");
418 pp_string (buffer
, " { ");
420 EXECUTE_IF_SET_IN_BITMAP (syms
, 0, i
, bi
)
422 tree sym
= referenced_var_lookup (i
);
423 dump_generic_node (buffer
, sym
, 0, flags
, false);
424 pp_string (buffer
, " ");
427 pp_string (buffer
, "}");
432 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of indent.
433 FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h).
434 If IS_STMT is true, the object printed is considered to be a statement
435 and it is terminated by ';' if appropriate. */
438 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
446 if (node
== NULL_TREE
)
449 is_expr
= EXPR_P (node
) || GIMPLE_STMT_P (node
);
451 /* We use has_stmt_ann because CALL_EXPR can be both an expression
452 and a statement, and we have no guarantee that it will have a
453 stmt_ann when it is used as an RHS expression. stmt_ann will assert
454 if you call it on something with a non-stmt annotation attached. */
455 if (TREE_CODE (node
) != ERROR_MARK
456 && is_gimple_stmt (node
)
457 && (flags
& (TDF_VOPS
|TDF_MEMSYMS
))
458 && has_stmt_ann (node
)
459 && TREE_CODE (node
) != PHI_NODE
)
460 dump_vops (buffer
, node
, spc
, flags
);
462 if (is_stmt
&& (flags
& TDF_STMTADDR
))
463 pp_printf (buffer
, "<&%p> ", (void *)node
);
465 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
467 expanded_location xloc
= expand_location (EXPR_LOCATION (node
));
468 pp_character (buffer
, '[');
471 pp_string (buffer
, xloc
.file
);
472 pp_string (buffer
, " : ");
474 pp_decimal_int (buffer
, xloc
.line
);
475 pp_string (buffer
, "] ");
478 switch (TREE_CODE (node
))
481 pp_string (buffer
, "<<< error >>>");
484 case IDENTIFIER_NODE
:
485 pp_tree_identifier (buffer
, node
);
489 while (node
&& node
!= error_mark_node
)
491 if (TREE_PURPOSE (node
))
493 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
496 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
497 node
= TREE_CHAIN (node
);
498 if (node
&& TREE_CODE (node
) == TREE_LIST
)
500 pp_character (buffer
, ',');
507 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
512 if (TREE_VEC_LENGTH (node
) > 0)
514 size_t len
= TREE_VEC_LENGTH (node
);
515 for (i
= 0; i
< len
- 1; i
++)
517 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
519 pp_character (buffer
, ',');
522 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
531 case FIXED_POINT_TYPE
:
537 unsigned int quals
= TYPE_QUALS (node
);
538 enum tree_code_class
class;
540 if (quals
& TYPE_QUAL_CONST
)
541 pp_string (buffer
, "const ");
542 else if (quals
& TYPE_QUAL_VOLATILE
)
543 pp_string (buffer
, "volatile ");
544 else if (quals
& TYPE_QUAL_RESTRICT
)
545 pp_string (buffer
, "restrict ");
547 class = TREE_CODE_CLASS (TREE_CODE (node
));
549 if (class == tcc_declaration
)
551 if (DECL_NAME (node
))
552 dump_decl_name (buffer
, node
, flags
);
554 pp_string (buffer
, "<unnamed type decl>");
556 else if (class == tcc_type
)
558 if (TYPE_NAME (node
))
560 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
561 pp_tree_identifier (buffer
, TYPE_NAME (node
));
562 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
563 && DECL_NAME (TYPE_NAME (node
)))
564 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
566 pp_string (buffer
, "<unnamed type>");
568 else if (TREE_CODE (node
) == VECTOR_TYPE
)
570 pp_string (buffer
, "vector ");
571 dump_generic_node (buffer
, TREE_TYPE (node
),
574 else if (TREE_CODE (node
) == INTEGER_TYPE
)
576 pp_string (buffer
, (TYPE_UNSIGNED (node
)
577 ? "<unnamed-unsigned:"
578 : "<unnamed-signed:"));
579 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
580 pp_string (buffer
, ">");
583 pp_string (buffer
, "<unnamed type>");
590 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
592 if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
594 tree fnode
= TREE_TYPE (node
);
596 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
598 pp_character (buffer
, '(');
599 pp_string (buffer
, str
);
600 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
601 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
603 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
605 pp_character (buffer
, ')');
606 dump_function_declaration (buffer
, fnode
, spc
, flags
);
610 unsigned int quals
= TYPE_QUALS (node
);
612 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
614 pp_string (buffer
, str
);
616 if (quals
& TYPE_QUAL_CONST
)
617 pp_string (buffer
, " const");
618 else if (quals
& TYPE_QUAL_VOLATILE
)
619 pp_string (buffer
, "volatile");
620 else if (quals
& TYPE_QUAL_RESTRICT
)
621 pp_string (buffer
, " restrict");
623 if (TYPE_REF_CAN_ALIAS_ALL (node
))
624 pp_string (buffer
, " {ref-all}");
633 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)), flags
);
634 pp_string (buffer
, "::");
639 const char *sep
= "";
642 pp_string (buffer
, "MEM[");
644 tmp
= TMR_SYMBOL (node
);
647 pp_string (buffer
, sep
);
649 pp_string (buffer
, "symbol: ");
650 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
652 tmp
= TMR_BASE (node
);
655 pp_string (buffer
, sep
);
657 pp_string (buffer
, "base: ");
658 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
660 tmp
= TMR_INDEX (node
);
663 pp_string (buffer
, sep
);
665 pp_string (buffer
, "index: ");
666 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
668 tmp
= TMR_STEP (node
);
671 pp_string (buffer
, sep
);
673 pp_string (buffer
, "step: ");
674 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
676 tmp
= TMR_OFFSET (node
);
679 pp_string (buffer
, sep
);
681 pp_string (buffer
, "offset: ");
682 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
684 pp_string (buffer
, "]");
685 if (flags
& TDF_DETAILS
)
687 pp_string (buffer
, "{");
688 dump_generic_node (buffer
, TMR_ORIGINAL (node
), spc
, flags
,
690 pp_string (buffer
, "}");
699 /* Print the innermost component type. */
700 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
701 tmp
= TREE_TYPE (tmp
))
703 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
705 /* Print the dimensions. */
706 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
707 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
713 case QUAL_UNION_TYPE
:
714 /* Print the name of the structure. */
715 if (TREE_CODE (node
) == RECORD_TYPE
)
716 pp_string (buffer
, "struct ");
717 else if (TREE_CODE (node
) == UNION_TYPE
)
718 pp_string (buffer
, "union ");
720 if (TYPE_NAME (node
))
721 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
723 print_struct_decl (buffer
, node
, spc
, flags
);
731 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
733 /* In the case of a pointer, one may want to divide by the
734 size of the pointed-to type. Unfortunately, this not
735 straightforward. The C front-end maps expressions
740 in such a way that the two INTEGER_CST nodes for "5" have
741 different values but identical types. In the latter
742 case, the 5 is multiplied by sizeof (int) in c-common.c
743 (pointer_int_sum) to convert it to a byte address, and
744 yet the type of the node is left unchanged. Argh. What
745 is consistent though is that the number value corresponds
746 to bytes (UNITS) offset.
748 NB: Neither of the following divisors can be trivially
749 used to recover the original literal:
751 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
752 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
753 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
754 pp_string (buffer
, "B"); /* pseudo-unit */
756 else if (! host_integerp (node
, 0))
759 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (val
);
760 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (val
);
762 if (tree_int_cst_sgn (val
) < 0)
764 pp_character (buffer
, '-');
768 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
770 sprintf (pp_buffer (buffer
)->digit_buffer
,
771 HOST_WIDE_INT_PRINT_DOUBLE_HEX
, high
, low
);
772 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
775 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
779 /* Code copied from print_node. */
782 if (TREE_OVERFLOW (node
))
783 pp_string (buffer
, " overflow");
785 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
786 d
= TREE_REAL_CST (node
);
787 if (REAL_VALUE_ISINF (d
))
788 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
789 else if (REAL_VALUE_ISNAN (d
))
790 pp_string (buffer
, " Nan");
794 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
795 pp_string (buffer
, string
);
800 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
801 pp_string (buffer
, "0x");
802 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
803 output_formatted_integer (buffer
, "%02x", *p
++);
812 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
813 pp_string (buffer
, string
);
818 pp_string (buffer
, "__complex__ (");
819 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
820 pp_string (buffer
, ", ");
821 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
822 pp_string (buffer
, ")");
826 pp_string (buffer
, "\"");
827 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
828 pp_string (buffer
, "\"");
834 pp_string (buffer
, "{ ");
835 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
837 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
, false);
838 if (TREE_CHAIN (elt
))
839 pp_string (buffer
, ", ");
841 pp_string (buffer
, " }");
850 dump_decl_name (buffer
, node
, flags
);
854 if (DECL_NAME (node
))
855 dump_decl_name (buffer
, node
, flags
);
856 else if (LABEL_DECL_UID (node
) != -1)
857 pp_printf (buffer
, "<L" HOST_WIDE_INT_PRINT_DEC
">",
858 LABEL_DECL_UID (node
));
860 pp_printf (buffer
, "<D%u>", DECL_UID (node
));
864 if (DECL_IS_BUILTIN (node
))
866 /* Don't print the declaration of built-in types. */
869 if (DECL_NAME (node
))
870 dump_decl_name (buffer
, node
, flags
);
873 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
874 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
875 && TYPE_METHODS (TREE_TYPE (node
)))
877 /* The type is a c++ class: all structures have at least
879 pp_string (buffer
, "class ");
880 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
885 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
886 ? "union" : "struct "));
887 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
892 case SYMBOL_MEMORY_TAG
:
893 case NAME_MEMORY_TAG
:
894 case STRUCT_FIELD_TAG
:
899 case MEMORY_PARTITION_TAG
:
900 dump_decl_name (buffer
, node
, flags
);
904 pp_string (buffer
, "<retval>");
908 op0
= TREE_OPERAND (node
, 0);
910 if (TREE_CODE (op0
) == INDIRECT_REF
)
912 op0
= TREE_OPERAND (op0
, 0);
915 if (op_prio (op0
) < op_prio (node
))
916 pp_character (buffer
, '(');
917 dump_generic_node (buffer
, op0
, spc
, flags
, false);
918 if (op_prio (op0
) < op_prio (node
))
919 pp_character (buffer
, ')');
920 pp_string (buffer
, str
);
921 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
923 if (TREE_CODE (op0
) != VALUE_HANDLE
)
925 op0
= component_ref_field_offset (node
);
926 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
928 pp_string (buffer
, "{off: ");
929 dump_generic_node (buffer
, op0
, spc
, flags
, false);
930 pp_character (buffer
, '}');
936 pp_string (buffer
, "BIT_FIELD_REF <");
937 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
938 pp_string (buffer
, ", ");
939 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
940 pp_string (buffer
, ", ");
941 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
942 pp_string (buffer
, ">");
946 case ARRAY_RANGE_REF
:
947 op0
= TREE_OPERAND (node
, 0);
948 if (op_prio (op0
) < op_prio (node
))
949 pp_character (buffer
, '(');
950 dump_generic_node (buffer
, op0
, spc
, flags
, false);
951 if (op_prio (op0
) < op_prio (node
))
952 pp_character (buffer
, ')');
953 pp_character (buffer
, '[');
954 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
955 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
956 pp_string (buffer
, " ...");
957 pp_character (buffer
, ']');
959 op0
= array_ref_low_bound (node
);
960 op1
= array_ref_element_size (node
);
962 if (!integer_zerop (op0
)
963 || TREE_OPERAND (node
, 2)
964 || TREE_OPERAND (node
, 3))
966 pp_string (buffer
, "{lb: ");
967 dump_generic_node (buffer
, op0
, spc
, flags
, false);
968 pp_string (buffer
, " sz: ");
969 dump_generic_node (buffer
, op1
, spc
, flags
, false);
970 pp_character (buffer
, '}');
976 unsigned HOST_WIDE_INT ix
;
978 bool is_struct_init
= FALSE
;
979 pp_character (buffer
, '{');
980 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
981 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
982 is_struct_init
= TRUE
;
983 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
985 if (field
&& is_struct_init
)
987 pp_character (buffer
, '.');
988 dump_generic_node (buffer
, field
, spc
, flags
, false);
989 pp_string (buffer
, "=");
991 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
992 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
993 val
= TREE_OPERAND (val
, 0);
994 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
995 dump_decl_name (buffer
, val
, flags
);
997 dump_generic_node (buffer
, val
, spc
, flags
, false);
998 if (ix
!= VEC_length (constructor_elt
, CONSTRUCTOR_ELTS (node
)) - 1)
1000 pp_character (buffer
, ',');
1004 pp_character (buffer
, '}');
1011 if (flags
& TDF_SLIM
)
1013 pp_string (buffer
, "<COMPOUND_EXPR>");
1017 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1018 spc
, flags
, !(flags
& TDF_SLIM
));
1019 if (flags
& TDF_SLIM
)
1020 newline_and_indent (buffer
, spc
);
1023 pp_character (buffer
, ',');
1027 for (tp
= &TREE_OPERAND (node
, 1);
1028 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1029 tp
= &TREE_OPERAND (*tp
, 1))
1031 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1032 spc
, flags
, !(flags
& TDF_SLIM
));
1033 if (flags
& TDF_SLIM
)
1034 newline_and_indent (buffer
, spc
);
1037 pp_character (buffer
, ',');
1042 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1046 case STATEMENT_LIST
:
1048 tree_stmt_iterator si
;
1051 if (flags
& TDF_SLIM
)
1053 pp_string (buffer
, "<STATEMENT_LIST>");
1057 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1060 newline_and_indent (buffer
, spc
);
1063 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1069 case GIMPLE_MODIFY_STMT
:
1071 dump_generic_node (buffer
, GENERIC_TREE_OPERAND (node
, 0), spc
, flags
,
1074 pp_character (buffer
, '=');
1075 if (TREE_CODE (node
) == GIMPLE_MODIFY_STMT
1076 && MOVE_NONTEMPORAL (node
))
1077 pp_string (buffer
, "{nt}");
1079 dump_generic_node (buffer
, GENERIC_TREE_OPERAND (node
, 1), spc
, flags
,
1084 pp_string (buffer
, "TARGET_EXPR <");
1085 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1086 pp_character (buffer
, ',');
1088 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1089 pp_character (buffer
, '>');
1093 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1098 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1100 pp_string (buffer
, "if (");
1101 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1102 pp_character (buffer
, ')');
1103 /* The lowered cond_exprs should always be printed in full. */
1104 if (COND_EXPR_THEN (node
)
1105 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1106 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1107 && COND_EXPR_ELSE (node
)
1108 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1109 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1112 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1114 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1116 pp_string (buffer
, " else ");
1117 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1121 else if (!(flags
& TDF_SLIM
))
1123 /* Output COND_EXPR_THEN. */
1124 if (COND_EXPR_THEN (node
))
1126 newline_and_indent (buffer
, spc
+2);
1127 pp_character (buffer
, '{');
1128 newline_and_indent (buffer
, spc
+4);
1129 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1131 newline_and_indent (buffer
, spc
+2);
1132 pp_character (buffer
, '}');
1135 /* Output COND_EXPR_ELSE. */
1136 if (COND_EXPR_ELSE (node
)
1137 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1139 newline_and_indent (buffer
, spc
);
1140 pp_string (buffer
, "else");
1141 newline_and_indent (buffer
, spc
+2);
1142 pp_character (buffer
, '{');
1143 newline_and_indent (buffer
, spc
+4);
1144 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1146 newline_and_indent (buffer
, spc
+2);
1147 pp_character (buffer
, '}');
1154 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1156 pp_character (buffer
, '?');
1158 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1160 pp_character (buffer
, ':');
1162 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1167 pp_character (buffer
, '{');
1168 if (!(flags
& TDF_SLIM
))
1170 if (BIND_EXPR_VARS (node
))
1172 pp_newline (buffer
);
1174 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= TREE_CHAIN (op0
))
1176 print_declaration (buffer
, op0
, spc
+2, flags
);
1177 pp_newline (buffer
);
1181 newline_and_indent (buffer
, spc
+2);
1182 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1183 newline_and_indent (buffer
, spc
);
1184 pp_character (buffer
, '}');
1190 print_call_name (buffer
, node
);
1192 /* Print parameters. */
1194 pp_character (buffer
, '(');
1197 call_expr_arg_iterator iter
;
1198 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1200 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1201 if (more_call_expr_args_p (&iter
))
1203 pp_character (buffer
, ',');
1208 pp_character (buffer
, ')');
1210 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1213 pp_string (buffer
, " [static-chain: ");
1214 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1215 pp_character (buffer
, ']');
1218 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1219 pp_string (buffer
, " [return slot optimization]");
1220 if (CALL_EXPR_TAILCALL (node
))
1221 pp_string (buffer
, " [tail call]");
1224 case WITH_CLEANUP_EXPR
:
1228 case CLEANUP_POINT_EXPR
:
1229 pp_string (buffer
, "<<cleanup_point ");
1230 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1231 pp_string (buffer
, ">>");
1234 case PLACEHOLDER_EXPR
:
1235 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1236 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1237 pp_character (buffer
, '>');
1240 /* Binary arithmetic and logic expressions. */
1241 case WIDEN_SUM_EXPR
:
1242 case WIDEN_MULT_EXPR
:
1245 case POINTER_PLUS_EXPR
:
1247 case TRUNC_DIV_EXPR
:
1249 case FLOOR_DIV_EXPR
:
1250 case ROUND_DIV_EXPR
:
1251 case TRUNC_MOD_EXPR
:
1253 case FLOOR_MOD_EXPR
:
1254 case ROUND_MOD_EXPR
:
1256 case EXACT_DIV_EXPR
:
1261 case VEC_LSHIFT_EXPR
:
1262 case VEC_RSHIFT_EXPR
:
1266 case TRUTH_ANDIF_EXPR
:
1267 case TRUTH_ORIF_EXPR
:
1268 case TRUTH_AND_EXPR
:
1270 case TRUTH_XOR_EXPR
:
1284 case UNORDERED_EXPR
:
1286 const char *op
= op_symbol (node
);
1287 op0
= TREE_OPERAND (node
, 0);
1288 op1
= TREE_OPERAND (node
, 1);
1290 /* When the operands are expressions with less priority,
1291 keep semantics of the tree representation. */
1292 if (op_prio (op0
) <= op_prio (node
))
1294 pp_character (buffer
, '(');
1295 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1296 pp_character (buffer
, ')');
1299 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1302 pp_string (buffer
, op
);
1305 /* When the operands are expressions with less priority,
1306 keep semantics of the tree representation. */
1307 if (op_prio (op1
) <= op_prio (node
))
1309 pp_character (buffer
, '(');
1310 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1311 pp_character (buffer
, ')');
1314 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1318 /* Unary arithmetic and logic expressions. */
1321 case TRUTH_NOT_EXPR
:
1323 case PREDECREMENT_EXPR
:
1324 case PREINCREMENT_EXPR
:
1325 case ALIGN_INDIRECT_REF
:
1326 case MISALIGNED_INDIRECT_REF
:
1328 if (TREE_CODE (node
) == ADDR_EXPR
1329 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1330 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1331 ; /* Do not output '&' for strings and function pointers. */
1333 pp_string (buffer
, op_symbol (node
));
1335 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1337 pp_character (buffer
, '(');
1338 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1339 pp_character (buffer
, ')');
1342 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1344 if (TREE_CODE (node
) == MISALIGNED_INDIRECT_REF
)
1346 pp_string (buffer
, "{misalignment: ");
1347 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1348 pp_character (buffer
, '}');
1352 case POSTDECREMENT_EXPR
:
1353 case POSTINCREMENT_EXPR
:
1354 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1356 pp_character (buffer
, '(');
1357 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1358 pp_character (buffer
, ')');
1361 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1362 pp_string (buffer
, op_symbol (node
));
1366 pp_string (buffer
, "MIN_EXPR <");
1367 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1368 pp_string (buffer
, ", ");
1369 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1370 pp_character (buffer
, '>');
1374 pp_string (buffer
, "MAX_EXPR <");
1375 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1376 pp_string (buffer
, ", ");
1377 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1378 pp_character (buffer
, '>');
1382 pp_string (buffer
, "ABS_EXPR <");
1383 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1384 pp_character (buffer
, '>');
1391 case FIXED_CONVERT_EXPR
:
1392 case FIX_TRUNC_EXPR
:
1396 type
= TREE_TYPE (node
);
1397 op0
= TREE_OPERAND (node
, 0);
1398 if (type
!= TREE_TYPE (op0
))
1400 pp_character (buffer
, '(');
1401 dump_generic_node (buffer
, type
, spc
, flags
, false);
1402 pp_string (buffer
, ") ");
1404 if (op_prio (op0
) < op_prio (node
))
1405 pp_character (buffer
, '(');
1406 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1407 if (op_prio (op0
) < op_prio (node
))
1408 pp_character (buffer
, ')');
1411 case VIEW_CONVERT_EXPR
:
1412 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1413 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1414 pp_string (buffer
, ">(");
1415 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1416 pp_character (buffer
, ')');
1419 case NON_LVALUE_EXPR
:
1420 pp_string (buffer
, "NON_LVALUE_EXPR <");
1421 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1422 pp_character (buffer
, '>');
1426 pp_string (buffer
, "SAVE_EXPR <");
1427 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1428 pp_character (buffer
, '>');
1432 pp_string (buffer
, "COMPLEX_EXPR <");
1433 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1434 pp_string (buffer
, ", ");
1435 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1436 pp_string (buffer
, ">");
1440 pp_string (buffer
, "CONJ_EXPR <");
1441 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1442 pp_string (buffer
, ">");
1446 pp_string (buffer
, "REALPART_EXPR <");
1447 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1448 pp_string (buffer
, ">");
1452 pp_string (buffer
, "IMAGPART_EXPR <");
1453 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1454 pp_string (buffer
, ">");
1458 pp_string (buffer
, "VA_ARG_EXPR <");
1459 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1460 pp_string (buffer
, ">");
1463 case TRY_FINALLY_EXPR
:
1464 case TRY_CATCH_EXPR
:
1465 pp_string (buffer
, "try");
1466 newline_and_indent (buffer
, spc
+2);
1467 pp_string (buffer
, "{");
1468 newline_and_indent (buffer
, spc
+4);
1469 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1470 newline_and_indent (buffer
, spc
+2);
1471 pp_string (buffer
, "}");
1472 newline_and_indent (buffer
, spc
);
1474 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1475 newline_and_indent (buffer
, spc
+2);
1476 pp_string (buffer
, "{");
1477 newline_and_indent (buffer
, spc
+4);
1478 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1479 newline_and_indent (buffer
, spc
+2);
1480 pp_string (buffer
, "}");
1485 pp_string (buffer
, "catch (");
1486 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1487 pp_string (buffer
, ")");
1488 newline_and_indent (buffer
, spc
+2);
1489 pp_string (buffer
, "{");
1490 newline_and_indent (buffer
, spc
+4);
1491 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1492 newline_and_indent (buffer
, spc
+2);
1493 pp_string (buffer
, "}");
1497 case EH_FILTER_EXPR
:
1498 pp_string (buffer
, "<<<eh_filter (");
1499 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1500 pp_string (buffer
, ")>>>");
1501 newline_and_indent (buffer
, spc
+2);
1502 pp_string (buffer
, "{");
1503 newline_and_indent (buffer
, spc
+4);
1504 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1505 newline_and_indent (buffer
, spc
+2);
1506 pp_string (buffer
, "}");
1510 case CHANGE_DYNAMIC_TYPE_EXPR
:
1511 pp_string (buffer
, "<<<change_dynamic_type (");
1512 dump_generic_node (buffer
, CHANGE_DYNAMIC_TYPE_NEW_TYPE (node
), spc
+ 2,
1514 pp_string (buffer
, ") ");
1515 dump_generic_node (buffer
, CHANGE_DYNAMIC_TYPE_LOCATION (node
), spc
+ 2,
1517 pp_string (buffer
, ")>>>");
1522 op0
= TREE_OPERAND (node
, 0);
1523 /* If this is for break or continue, don't bother printing it. */
1524 if (DECL_NAME (op0
))
1526 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1527 if (strcmp (name
, "break") == 0
1528 || strcmp (name
, "continue") == 0)
1531 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1532 pp_character (buffer
, ':');
1533 if (DECL_NONLOCAL (op0
))
1534 pp_string (buffer
, " [non-local]");
1538 pp_string (buffer
, "<<<exception object>>>");
1542 pp_string (buffer
, "<<<filter object>>>");
1546 pp_string (buffer
, "while (1)");
1547 if (!(flags
& TDF_SLIM
))
1549 newline_and_indent (buffer
, spc
+2);
1550 pp_character (buffer
, '{');
1551 newline_and_indent (buffer
, spc
+4);
1552 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1553 newline_and_indent (buffer
, spc
+2);
1554 pp_character (buffer
, '}');
1560 pp_string (buffer
, "return");
1561 op0
= TREE_OPERAND (node
, 0);
1565 if (TREE_CODE (op0
) == MODIFY_EXPR
1566 || TREE_CODE (op0
) == GIMPLE_MODIFY_STMT
)
1567 dump_generic_node (buffer
, GENERIC_TREE_OPERAND (op0
, 1),
1570 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1575 pp_string (buffer
, "if (");
1576 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1577 pp_string (buffer
, ") break");
1581 pp_string (buffer
, "switch (");
1582 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1583 pp_character (buffer
, ')');
1584 if (!(flags
& TDF_SLIM
))
1586 newline_and_indent (buffer
, spc
+2);
1587 pp_character (buffer
, '{');
1588 if (SWITCH_BODY (node
))
1590 newline_and_indent (buffer
, spc
+4);
1591 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1596 tree vec
= SWITCH_LABELS (node
);
1597 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1598 for (i
= 0; i
< n
; ++i
)
1600 tree elt
= TREE_VEC_ELT (vec
, i
);
1601 newline_and_indent (buffer
, spc
+4);
1604 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1605 pp_string (buffer
, " goto ");
1606 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1608 pp_semicolon (buffer
);
1611 pp_string (buffer
, "case ???: goto ???;");
1614 newline_and_indent (buffer
, spc
+2);
1615 pp_character (buffer
, '}');
1621 op0
= GOTO_DESTINATION (node
);
1622 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1624 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1625 if (strcmp (name
, "break") == 0
1626 || strcmp (name
, "continue") == 0)
1628 pp_string (buffer
, name
);
1632 pp_string (buffer
, "goto ");
1633 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1637 pp_string (buffer
, "resx ");
1638 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1642 pp_string (buffer
, "__asm__");
1643 if (ASM_VOLATILE_P (node
))
1644 pp_string (buffer
, " __volatile__");
1645 pp_character (buffer
, '(');
1646 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1647 pp_character (buffer
, ':');
1648 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1649 pp_character (buffer
, ':');
1650 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1651 if (ASM_CLOBBERS (node
))
1653 pp_character (buffer
, ':');
1654 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1656 pp_string (buffer
, ")");
1659 case CASE_LABEL_EXPR
:
1660 if (CASE_LOW (node
) && CASE_HIGH (node
))
1662 pp_string (buffer
, "case ");
1663 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1664 pp_string (buffer
, " ... ");
1665 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1667 else if (CASE_LOW (node
))
1669 pp_string (buffer
, "case ");
1670 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1673 pp_string (buffer
, "default ");
1674 pp_character (buffer
, ':');
1678 pp_string (buffer
, "OBJ_TYPE_REF(");
1679 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1680 pp_character (buffer
, ';');
1681 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1682 pp_character (buffer
, '-');
1683 pp_character (buffer
, '>');
1684 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
1685 pp_character (buffer
, ')');
1692 dump_generic_node (buffer
, PHI_RESULT (node
), spc
, flags
, false);
1693 pp_string (buffer
, " = PHI <");
1694 for (i
= 0; i
< PHI_NUM_ARGS (node
); i
++)
1696 dump_generic_node (buffer
, PHI_ARG_DEF (node
, i
), spc
, flags
, false);
1697 pp_string (buffer
, "(");
1698 pp_decimal_int (buffer
, PHI_ARG_EDGE (node
, i
)->src
->index
);
1699 pp_string (buffer
, ")");
1700 if (i
< PHI_NUM_ARGS (node
) - 1)
1701 pp_string (buffer
, ", ");
1703 pp_string (buffer
, ">");
1705 if (stmt_references_memory_p (node
) && (flags
& TDF_MEMSYMS
))
1706 dump_symbols (buffer
, STORED_SYMS (node
), flags
);
1711 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
1712 pp_string (buffer
, "_");
1713 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1714 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
1715 pp_string (buffer
, "(ab)");
1716 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
1717 pp_string (buffer
, "(D)");
1720 case WITH_SIZE_EXPR
:
1721 pp_string (buffer
, "WITH_SIZE_EXPR <");
1722 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1723 pp_string (buffer
, ", ");
1724 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1725 pp_string (buffer
, ">");
1729 pp_printf (buffer
, "VH.%d", VALUE_HANDLE_ID (node
));
1733 pp_string (buffer
, "ASSERT_EXPR <");
1734 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
1735 pp_string (buffer
, ", ");
1736 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
1737 pp_string (buffer
, ">");
1741 pp_string (buffer
, "scev_known");
1744 case SCEV_NOT_KNOWN
:
1745 pp_string (buffer
, "scev_not_known");
1748 case POLYNOMIAL_CHREC
:
1749 pp_string (buffer
, "{");
1750 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
1751 pp_string (buffer
, ", +, ");
1752 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
1753 pp_string (buffer
, "}_");
1754 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
1758 case REALIGN_LOAD_EXPR
:
1759 pp_string (buffer
, "REALIGN_LOAD <");
1760 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1761 pp_string (buffer
, ", ");
1762 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1763 pp_string (buffer
, ", ");
1764 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1765 pp_string (buffer
, ">");
1769 pp_string (buffer
, " VEC_COND_EXPR < ");
1770 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1771 pp_string (buffer
, " , ");
1772 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1773 pp_string (buffer
, " , ");
1774 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1775 pp_string (buffer
, " > ");
1779 pp_string (buffer
, " DOT_PROD_EXPR < ");
1780 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1781 pp_string (buffer
, ", ");
1782 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1783 pp_string (buffer
, ", ");
1784 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1785 pp_string (buffer
, " > ");
1789 pp_string (buffer
, "#pragma omp parallel");
1790 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
1791 if (OMP_PARALLEL_FN (node
))
1793 pp_string (buffer
, " [child fn: ");
1794 dump_generic_node (buffer
, OMP_PARALLEL_FN (node
), spc
, flags
, false);
1796 pp_string (buffer
, " (");
1798 if (OMP_PARALLEL_DATA_ARG (node
))
1799 dump_generic_node (buffer
, OMP_PARALLEL_DATA_ARG (node
), spc
, flags
,
1802 pp_string (buffer
, "???");
1804 pp_string (buffer
, ")]");
1808 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
1810 newline_and_indent (buffer
, spc
+ 2);
1811 pp_character (buffer
, '{');
1812 newline_and_indent (buffer
, spc
+ 4);
1813 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
1814 newline_and_indent (buffer
, spc
+ 2);
1815 pp_character (buffer
, '}');
1821 pp_string (buffer
, "#pragma omp for");
1822 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
1824 if (!(flags
& TDF_SLIM
))
1826 if (OMP_FOR_PRE_BODY (node
))
1828 newline_and_indent (buffer
, spc
+ 2);
1829 pp_character (buffer
, '{');
1831 newline_and_indent (buffer
, spc
);
1832 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
1835 newline_and_indent (buffer
, spc
);
1836 pp_string (buffer
, "for (");
1837 dump_generic_node (buffer
, OMP_FOR_INIT (node
), spc
, flags
, false);
1838 pp_string (buffer
, "; ");
1839 dump_generic_node (buffer
, OMP_FOR_COND (node
), spc
, flags
, false);
1840 pp_string (buffer
, "; ");
1841 dump_generic_node (buffer
, OMP_FOR_INCR (node
), spc
, flags
, false);
1842 pp_string (buffer
, ")");
1843 if (OMP_FOR_BODY (node
))
1845 newline_and_indent (buffer
, spc
+ 2);
1846 pp_character (buffer
, '{');
1847 newline_and_indent (buffer
, spc
+ 4);
1848 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
1850 newline_and_indent (buffer
, spc
+ 2);
1851 pp_character (buffer
, '}');
1853 if (OMP_FOR_PRE_BODY (node
))
1856 newline_and_indent (buffer
, spc
+ 2);
1857 pp_character (buffer
, '}');
1864 pp_string (buffer
, "#pragma omp sections");
1865 if (OMP_SECTIONS_CONTROL (node
))
1867 pp_string (buffer
, " <");
1868 dump_generic_node (buffer
, OMP_SECTIONS_CONTROL (node
), spc
,
1870 pp_string (buffer
, ">");
1872 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
1875 case OMP_SECTIONS_SWITCH
:
1876 pp_string (buffer
, "OMP_SECTIONS_SWITCH");
1881 pp_string (buffer
, "#pragma omp section");
1885 pp_string (buffer
, "#pragma omp master");
1889 pp_string (buffer
, "#pragma omp ordered");
1893 pp_string (buffer
, "#pragma omp critical");
1894 if (OMP_CRITICAL_NAME (node
))
1897 pp_character (buffer
, '(');
1898 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
1900 pp_character (buffer
, ')');
1905 pp_string (buffer
, "#pragma omp atomic");
1906 newline_and_indent (buffer
, spc
+ 2);
1907 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1909 pp_character (buffer
, '=');
1911 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1915 pp_string (buffer
, "#pragma omp single");
1916 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
1920 pp_string (buffer
, "OMP_RETURN");
1921 if (OMP_RETURN_NOWAIT (node
))
1922 pp_string (buffer
, " [nowait]");
1927 pp_string (buffer
, "OMP_CONTINUE <");
1928 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1929 pp_string (buffer
, " <- ");
1930 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1931 pp_string (buffer
, ">");
1936 dump_omp_clause (buffer
, node
, spc
, flags
);
1940 case REDUC_MAX_EXPR
:
1941 pp_string (buffer
, " REDUC_MAX_EXPR < ");
1942 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1943 pp_string (buffer
, " > ");
1946 case REDUC_MIN_EXPR
:
1947 pp_string (buffer
, " REDUC_MIN_EXPR < ");
1948 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1949 pp_string (buffer
, " > ");
1952 case REDUC_PLUS_EXPR
:
1953 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
1954 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1955 pp_string (buffer
, " > ");
1958 case VEC_WIDEN_MULT_HI_EXPR
:
1959 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
1960 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1961 pp_string (buffer
, ", ");
1962 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1963 pp_string (buffer
, " > ");
1966 case VEC_WIDEN_MULT_LO_EXPR
:
1967 pp_string (buffer
, " VEC_WIDEN_MULT_LO_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
, " > ");
1974 case VEC_UNPACK_HI_EXPR
:
1975 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
1976 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1977 pp_string (buffer
, " > ");
1980 case VEC_UNPACK_LO_EXPR
:
1981 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
1982 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1983 pp_string (buffer
, " > ");
1986 case VEC_UNPACK_FLOAT_HI_EXPR
:
1987 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
1988 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1989 pp_string (buffer
, " > ");
1992 case VEC_UNPACK_FLOAT_LO_EXPR
:
1993 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
1994 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1995 pp_string (buffer
, " > ");
1998 case VEC_PACK_TRUNC_EXPR
:
1999 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2000 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2001 pp_string (buffer
, ", ");
2002 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2003 pp_string (buffer
, " > ");
2006 case VEC_PACK_SAT_EXPR
:
2007 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2008 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2009 pp_string (buffer
, ", ");
2010 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2011 pp_string (buffer
, " > ");
2014 case VEC_PACK_FIX_TRUNC_EXPR
:
2015 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2016 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2017 pp_string (buffer
, ", ");
2018 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2019 pp_string (buffer
, " > ");
2025 pp_string (buffer
, "BLOCK");
2027 if (BLOCK_ABSTRACT (node
))
2028 pp_string (buffer
, " [abstract]");
2030 if (TREE_ASM_WRITTEN (node
))
2031 pp_string (buffer
, " [written]");
2033 newline_and_indent (buffer
, spc
+ 2);
2035 if (BLOCK_SUPERCONTEXT (node
))
2037 pp_string (buffer
, "SUPERCONTEXT: ");
2038 if (TREE_CODE (BLOCK_SUPERCONTEXT (node
)) == BLOCK
)
2039 pp_printf (buffer
, "BLOCK %p",
2040 (void *)BLOCK_SUPERCONTEXT (node
));
2042 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (node
), 0, flags
,
2044 newline_and_indent (buffer
, spc
+ 2);
2047 if (BLOCK_SUBBLOCKS (node
))
2049 pp_string (buffer
, "SUBBLOCKS: ");
2050 for (t
= BLOCK_SUBBLOCKS (node
); t
; t
= BLOCK_CHAIN (t
))
2051 pp_printf (buffer
, "%p ", (void *)t
);
2052 newline_and_indent (buffer
, spc
+ 2);
2055 if (BLOCK_VARS (node
))
2057 pp_string (buffer
, "VARS: ");
2058 for (t
= BLOCK_VARS (node
); t
; t
= TREE_CHAIN (t
))
2060 dump_generic_node (buffer
, t
, 0, flags
, false);
2061 pp_string (buffer
, " ");
2063 newline_and_indent (buffer
, spc
+ 2);
2066 if (BLOCK_ABSTRACT_ORIGIN (node
))
2068 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
2069 if (TREE_CODE (BLOCK_ABSTRACT_ORIGIN (node
)) == BLOCK
)
2070 pp_printf (buffer
, "BLOCK %p",
2071 (void *)BLOCK_ABSTRACT_ORIGIN (node
));
2073 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (node
), 0, flags
,
2075 newline_and_indent (buffer
, spc
+ 2);
2080 case VEC_EXTRACT_EVEN_EXPR
:
2081 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2082 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2083 pp_string (buffer
, ", ");
2084 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2085 pp_string (buffer
, " > ");
2088 case VEC_EXTRACT_ODD_EXPR
:
2089 pp_string (buffer
, " VEC_EXTRACT_ODD_EXPR < ");
2090 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2091 pp_string (buffer
, ", ");
2092 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2093 pp_string (buffer
, " > ");
2096 case VEC_INTERLEAVE_HIGH_EXPR
:
2097 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_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
, " > ");
2104 case VEC_INTERLEAVE_LOW_EXPR
:
2105 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2106 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2107 pp_string (buffer
, ", ");
2108 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2109 pp_string (buffer
, " > ");
2116 if (is_stmt
&& is_expr
)
2117 pp_semicolon (buffer
);
2119 /* If we're building a diagnostic, the formatted text will be written
2120 into BUFFER's stream by the caller; otherwise, write it now. */
2121 if (!(flags
& TDF_DIAGNOSTIC
))
2122 pp_write_text_to_stream (buffer
);
2127 /* Print the declaration of a variable. */
2130 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2134 if (TREE_CODE (t
) == TYPE_DECL
)
2135 pp_string (buffer
, "typedef ");
2137 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2138 pp_string (buffer
, "register ");
2140 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2141 pp_string (buffer
, "extern ");
2142 else if (TREE_STATIC (t
))
2143 pp_string (buffer
, "static ");
2145 /* Print the type and name. */
2146 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2150 /* Print array's type. */
2151 tmp
= TREE_TYPE (t
);
2152 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2153 tmp
= TREE_TYPE (tmp
);
2154 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2156 /* Print variable's name. */
2158 dump_generic_node (buffer
, t
, spc
, flags
, false);
2160 /* Print the dimensions. */
2161 tmp
= TREE_TYPE (t
);
2162 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2164 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2165 tmp
= TREE_TYPE (tmp
);
2168 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2170 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2172 dump_decl_name (buffer
, t
, flags
);
2173 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2177 /* Print type declaration. */
2178 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2180 /* Print variable's name. */
2182 dump_generic_node (buffer
, t
, spc
, flags
, false);
2185 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2187 pp_string (buffer
, " __asm__ ");
2188 pp_character (buffer
, '(');
2189 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2190 pp_character (buffer
, ')');
2193 /* The initial value of a function serves to determine wether the function
2194 is declared or defined. So the following does not apply to function
2196 if (TREE_CODE (t
) != FUNCTION_DECL
)
2198 /* Print the initial value. */
2199 if (DECL_INITIAL (t
))
2202 pp_character (buffer
, '=');
2204 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2208 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2210 pp_string (buffer
, " [value-expr: ");
2211 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2212 pp_character (buffer
, ']');
2215 pp_character (buffer
, ';');
2219 /* Prints a structure: name, fields, and methods.
2220 FIXME: Still incomplete. */
2223 print_struct_decl (pretty_printer
*buffer
, tree node
, int spc
, int flags
)
2225 /* Print the name of the structure. */
2226 if (TYPE_NAME (node
))
2229 if (TREE_CODE (node
) == RECORD_TYPE
)
2230 pp_string (buffer
, "struct ");
2231 else if ((TREE_CODE (node
) == UNION_TYPE
2232 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2233 pp_string (buffer
, "union ");
2235 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2238 /* Print the contents of the structure. */
2239 pp_newline (buffer
);
2241 pp_character (buffer
, '{');
2242 pp_newline (buffer
);
2244 /* Print the fields of the structure. */
2247 tmp
= TYPE_FIELDS (node
);
2250 /* Avoid to print recursively the structure. */
2251 /* FIXME : Not implemented correctly...,
2252 what about the case when we have a cycle in the contain graph? ...
2253 Maybe this could be solved by looking at the scope in which the
2254 structure was declared. */
2255 if (TREE_TYPE (tmp
) != node
2256 || (TREE_CODE (TREE_TYPE (tmp
)) == POINTER_TYPE
2257 && TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2259 print_declaration (buffer
, tmp
, spc
+2, flags
);
2260 pp_newline (buffer
);
2262 tmp
= TREE_CHAIN (tmp
);
2266 pp_character (buffer
, '}');
2269 /* Return the priority of the operator OP.
2271 From lowest to highest precedence with either left-to-right (L-R)
2272 or right-to-left (R-L) associativity]:
2275 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2287 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2288 15 [L-R] fn() [] -> .
2290 unary +, - and * have higher precedence than the corresponding binary
2299 switch (TREE_CODE (op
))
2307 case GIMPLE_MODIFY_STMT
:
2315 case TRUTH_ORIF_EXPR
:
2318 case TRUTH_AND_EXPR
:
2319 case TRUTH_ANDIF_EXPR
:
2326 case TRUTH_XOR_EXPR
:
2343 case UNORDERED_EXPR
:
2356 case WIDEN_SUM_EXPR
:
2358 case POINTER_PLUS_EXPR
:
2362 case VEC_WIDEN_MULT_HI_EXPR
:
2363 case VEC_WIDEN_MULT_LO_EXPR
:
2364 case WIDEN_MULT_EXPR
:
2367 case TRUNC_DIV_EXPR
:
2369 case FLOOR_DIV_EXPR
:
2370 case ROUND_DIV_EXPR
:
2372 case EXACT_DIV_EXPR
:
2373 case TRUNC_MOD_EXPR
:
2375 case FLOOR_MOD_EXPR
:
2376 case ROUND_MOD_EXPR
:
2379 case TRUTH_NOT_EXPR
:
2381 case POSTINCREMENT_EXPR
:
2382 case POSTDECREMENT_EXPR
:
2383 case PREINCREMENT_EXPR
:
2384 case PREDECREMENT_EXPR
:
2386 case ALIGN_INDIRECT_REF
:
2387 case MISALIGNED_INDIRECT_REF
:
2393 case FIX_TRUNC_EXPR
:
2399 case ARRAY_RANGE_REF
:
2403 /* Special expressions. */
2409 case REDUC_MAX_EXPR
:
2410 case REDUC_MIN_EXPR
:
2411 case REDUC_PLUS_EXPR
:
2412 case VEC_LSHIFT_EXPR
:
2413 case VEC_RSHIFT_EXPR
:
2414 case VEC_UNPACK_HI_EXPR
:
2415 case VEC_UNPACK_LO_EXPR
:
2416 case VEC_UNPACK_FLOAT_HI_EXPR
:
2417 case VEC_UNPACK_FLOAT_LO_EXPR
:
2418 case VEC_PACK_TRUNC_EXPR
:
2419 case VEC_PACK_SAT_EXPR
:
2423 case NON_LVALUE_EXPR
:
2424 return op_prio (TREE_OPERAND (op
, 0));
2427 /* Return an arbitrarily high precedence to avoid surrounding single
2428 VAR_DECLs in ()s. */
2434 /* Return the symbol associated with operator CODE. */
2437 op_symbol_code (enum tree_code code
)
2442 case GIMPLE_MODIFY_STMT
:
2446 case TRUTH_ORIF_EXPR
:
2449 case TRUTH_AND_EXPR
:
2450 case TRUTH_ANDIF_EXPR
:
2456 case TRUTH_XOR_EXPR
:
2466 case UNORDERED_EXPR
:
2512 case VEC_LSHIFT_EXPR
:
2515 case VEC_RSHIFT_EXPR
:
2518 case POINTER_PLUS_EXPR
:
2524 case REDUC_PLUS_EXPR
:
2527 case WIDEN_SUM_EXPR
:
2530 case WIDEN_MULT_EXPR
:
2540 case TRUTH_NOT_EXPR
:
2547 case ALIGN_INDIRECT_REF
:
2550 case MISALIGNED_INDIRECT_REF
:
2553 case TRUNC_DIV_EXPR
:
2560 case FLOOR_DIV_EXPR
:
2563 case ROUND_DIV_EXPR
:
2566 case EXACT_DIV_EXPR
:
2569 case TRUNC_MOD_EXPR
:
2575 case FLOOR_MOD_EXPR
:
2578 case ROUND_MOD_EXPR
:
2581 case PREDECREMENT_EXPR
:
2584 case PREINCREMENT_EXPR
:
2587 case POSTDECREMENT_EXPR
:
2590 case POSTINCREMENT_EXPR
:
2600 return "<<< ??? >>>";
2604 /* Return the symbol associated with operator OP. */
2609 return op_symbol_code (TREE_CODE (op
));
2612 /* Prints the name of a CALL_EXPR. */
2615 print_call_name (pretty_printer
*buffer
, tree node
)
2619 gcc_assert (TREE_CODE (node
) == CALL_EXPR
);
2621 op0
= CALL_EXPR_FN (node
);
2623 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2624 op0
= TREE_OPERAND (op0
, 0);
2626 switch (TREE_CODE (op0
))
2630 dump_function_name (buffer
, op0
);
2636 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2640 pp_string (buffer
, "(");
2641 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2642 pp_string (buffer
, ") ? ");
2643 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, 0, false);
2644 pp_string (buffer
, " : ");
2645 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, 0, false);
2649 /* The function is a pointer contained in a structure. */
2650 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == INDIRECT_REF
||
2651 TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2652 dump_function_name (buffer
, TREE_OPERAND (op0
, 1));
2654 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2656 We can have several levels of structures and a function
2657 pointer inside. This is not implemented yet... */
2662 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2663 dump_function_name (buffer
, TREE_OPERAND (op0
, 0));
2665 dump_generic_node (buffer
, op0
, 0, 0, false);
2670 dump_generic_node (buffer
, op0
, 0, 0, false);
2678 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2681 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2691 pp_string (buffer
, "\\b");
2695 pp_string (buffer
, "\\f");
2699 pp_string (buffer
, "\\n");
2703 pp_string (buffer
, "\\r");
2707 pp_string (buffer
, "\\t");
2711 pp_string (buffer
, "\\v");
2715 pp_string (buffer
, "\\\\");
2719 pp_string (buffer
, "\\\"");
2723 pp_string (buffer
, "\\'");
2726 /* No need to handle \0; the loop terminates on \0. */
2729 pp_string (buffer
, "\\1");
2733 pp_string (buffer
, "\\2");
2737 pp_string (buffer
, "\\3");
2741 pp_string (buffer
, "\\4");
2745 pp_string (buffer
, "\\5");
2749 pp_string (buffer
, "\\6");
2753 pp_string (buffer
, "\\7");
2757 pp_character (buffer
, str
[0]);
2765 maybe_init_pretty_print (FILE *file
)
2769 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
2770 pp_needs_newline (&buffer
) = true;
2774 buffer
.buffer
->stream
= file
;
2778 newline_and_indent (pretty_printer
*buffer
, int spc
)
2780 pp_newline (buffer
);
2786 dump_vops (pretty_printer
*buffer
, tree stmt
, int spc
, int flags
)
2788 struct voptype_d
*vdefs
;
2789 struct voptype_d
*vuses
;
2792 if (!ssa_operands_active () || !stmt_references_memory_p (stmt
))
2795 /* Even if the statement doesn't have virtual operators yet, it may
2796 contain symbol information (this happens before aliases have been
2798 if ((flags
& TDF_MEMSYMS
)
2799 && VUSE_OPS (stmt
) == NULL
2800 && VDEF_OPS (stmt
) == NULL
)
2802 if (LOADED_SYMS (stmt
))
2804 pp_string (buffer
, "# LOADS: ");
2805 dump_symbols (buffer
, LOADED_SYMS (stmt
), flags
);
2806 newline_and_indent (buffer
, spc
);
2809 if (STORED_SYMS (stmt
))
2811 pp_string (buffer
, "# STORES: ");
2812 dump_symbols (buffer
, STORED_SYMS (stmt
), flags
);
2813 newline_and_indent (buffer
, spc
);
2819 vuses
= VUSE_OPS (stmt
);
2822 pp_string (buffer
, "# VUSE <");
2824 n
= VUSE_NUM (vuses
);
2825 for (i
= 0; i
< n
; i
++)
2827 dump_generic_node (buffer
, VUSE_OP (vuses
, i
), spc
+ 2, flags
, false);
2829 pp_string (buffer
, ", ");
2832 pp_string (buffer
, ">");
2834 if (flags
& TDF_MEMSYMS
)
2835 dump_symbols (buffer
, LOADED_SYMS (stmt
), flags
);
2837 newline_and_indent (buffer
, spc
);
2838 vuses
= vuses
->next
;
2841 vdefs
= VDEF_OPS (stmt
);
2844 pp_string (buffer
, "# ");
2845 dump_generic_node (buffer
, VDEF_RESULT (vdefs
), spc
+ 2, flags
, false);
2846 pp_string (buffer
, " = VDEF <");
2848 n
= VDEF_NUM (vdefs
);
2849 for (i
= 0; i
< n
; i
++)
2851 dump_generic_node (buffer
, VDEF_OP (vdefs
, i
), spc
+ 2, flags
, 0);
2853 pp_string (buffer
, ", ");
2856 pp_string (buffer
, ">");
2858 if ((flags
& TDF_MEMSYMS
) && vdefs
->next
== NULL
)
2859 dump_symbols (buffer
, STORED_SYMS (stmt
), flags
);
2861 newline_and_indent (buffer
, spc
);
2862 vdefs
= vdefs
->next
;
2867 /* Dumps basic block BB to FILE with details described by FLAGS and
2868 indented by INDENT spaces. */
2871 dump_generic_bb (FILE *file
, basic_block bb
, int indent
, int flags
)
2873 maybe_init_pretty_print (file
);
2874 dump_generic_bb_buff (&buffer
, bb
, indent
, flags
);
2878 /* Dumps header of basic block BB to buffer BUFFER indented by INDENT
2879 spaces and details described by flags. */
2882 dump_bb_header (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
2888 if (flags
& TDF_BLOCKS
)
2891 pp_string (buffer
, "# BLOCK ");
2892 pp_decimal_int (buffer
, bb
->index
);
2895 pp_string (buffer
, " freq:");
2896 pp_decimal_int (buffer
, bb
->frequency
);
2900 pp_string (buffer
, " count:");
2901 pp_widest_integer (buffer
, bb
->count
);
2904 if (flags
& TDF_LINENO
)
2906 block_stmt_iterator bsi
;
2908 for (bsi
= bsi_start (bb
); !bsi_end_p (bsi
); bsi_next (&bsi
))
2909 if (get_lineno (bsi_stmt (bsi
)) != -1)
2911 pp_string (buffer
, ", starting at line ");
2912 pp_decimal_int (buffer
, get_lineno (bsi_stmt (bsi
)));
2916 newline_and_indent (buffer
, indent
);
2918 pp_string (buffer
, "# PRED:");
2919 pp_write_text_to_stream (buffer
);
2920 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
2921 if (flags
& TDF_SLIM
)
2923 pp_string (buffer
, " ");
2924 if (e
->src
== ENTRY_BLOCK_PTR
)
2925 pp_string (buffer
, "ENTRY");
2927 pp_decimal_int (buffer
, e
->src
->index
);
2930 dump_edge_info (buffer
->buffer
->stream
, e
, 0);
2931 pp_newline (buffer
);
2935 stmt
= first_stmt (bb
);
2936 if (!stmt
|| TREE_CODE (stmt
) != LABEL_EXPR
)
2938 INDENT (indent
- 2);
2939 pp_string (buffer
, "<bb ");
2940 pp_decimal_int (buffer
, bb
->index
);
2941 pp_string (buffer
, ">:");
2942 pp_newline (buffer
);
2945 pp_write_text_to_stream (buffer
);
2946 check_bb_profile (bb
, buffer
->buffer
->stream
);
2949 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2953 dump_bb_end (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
2959 pp_string (buffer
, "# SUCC:");
2960 pp_write_text_to_stream (buffer
);
2961 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
2962 if (flags
& TDF_SLIM
)
2964 pp_string (buffer
, " ");
2965 if (e
->dest
== EXIT_BLOCK_PTR
)
2966 pp_string (buffer
, "EXIT");
2968 pp_decimal_int (buffer
, e
->dest
->index
);
2971 dump_edge_info (buffer
->buffer
->stream
, e
, 1);
2972 pp_newline (buffer
);
2975 /* Dump PHI nodes of basic block BB to BUFFER with details described
2976 by FLAGS and indented by INDENT spaces. */
2979 dump_phi_nodes (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
2981 tree phi
= phi_nodes (bb
);
2985 for (; phi
; phi
= PHI_CHAIN (phi
))
2987 if (is_gimple_reg (PHI_RESULT (phi
)) || (flags
& TDF_VOPS
))
2990 pp_string (buffer
, "# ");
2991 dump_generic_node (buffer
, phi
, indent
, flags
, false);
2992 pp_newline (buffer
);
2998 /* Dump jump to basic block BB that is represented implicitly in the cfg
3002 pp_cfg_jump (pretty_printer
*buffer
, basic_block bb
)
3006 stmt
= first_stmt (bb
);
3008 pp_string (buffer
, "goto <bb ");
3009 pp_decimal_int (buffer
, bb
->index
);
3010 pp_string (buffer
, ">");
3011 if (stmt
&& TREE_CODE (stmt
) == LABEL_EXPR
)
3013 pp_string (buffer
, " (");
3014 dump_generic_node (buffer
, LABEL_EXPR_LABEL (stmt
), 0, 0, false);
3015 pp_string (buffer
, ")");
3017 pp_semicolon (buffer
);
3020 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
3021 by INDENT spaces, with details given by FLAGS. */
3024 dump_implicit_edges (pretty_printer
*buffer
, basic_block bb
, int indent
,
3031 stmt
= last_stmt (bb
);
3032 if (stmt
&& TREE_CODE (stmt
) == COND_EXPR
)
3034 edge true_edge
, false_edge
;
3036 /* When we are emitting the code or changing CFG, it is possible that
3037 the edges are not yet created. When we are using debug_bb in such
3038 a situation, we do not want it to crash. */
3039 if (EDGE_COUNT (bb
->succs
) != 2)
3041 extract_true_false_edges_from_block (bb
, &true_edge
, &false_edge
);
3043 INDENT (indent
+ 2);
3044 pp_cfg_jump (buffer
, true_edge
->dest
);
3045 newline_and_indent (buffer
, indent
);
3046 pp_string (buffer
, "else");
3047 newline_and_indent (buffer
, indent
+ 2);
3048 pp_cfg_jump (buffer
, false_edge
->dest
);
3049 pp_newline (buffer
);
3053 /* If there is a fallthru edge, we may need to add an artificial goto to the
3055 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
3056 if (e
->flags
& EDGE_FALLTHRU
)
3058 if (e
&& e
->dest
!= bb
->next_bb
)
3062 if ((flags
& TDF_LINENO
)
3063 #ifdef USE_MAPPED_LOCATION
3064 && e
->goto_locus
!= UNKNOWN_LOCATION
3070 expanded_location goto_xloc
;
3071 #ifdef USE_MAPPED_LOCATION
3072 goto_xloc
= expand_location (e
->goto_locus
);
3074 goto_xloc
= *e
->goto_locus
;
3076 pp_character (buffer
, '[');
3079 pp_string (buffer
, goto_xloc
.file
);
3080 pp_string (buffer
, " : ");
3082 pp_decimal_int (buffer
, goto_xloc
.line
);
3083 pp_string (buffer
, "] ");
3086 pp_cfg_jump (buffer
, e
->dest
);
3087 pp_newline (buffer
);
3091 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
3092 indented by INDENT spaces. */
3095 dump_generic_bb_buff (pretty_printer
*buffer
, basic_block bb
,
3096 int indent
, int flags
)
3098 block_stmt_iterator bsi
;
3100 int label_indent
= indent
- 2;
3102 if (label_indent
< 0)
3105 dump_bb_header (buffer
, bb
, indent
, flags
);
3107 dump_phi_nodes (buffer
, bb
, indent
, flags
);
3109 for (bsi
= bsi_start (bb
); !bsi_end_p (bsi
); bsi_next (&bsi
))
3113 stmt
= bsi_stmt (bsi
);
3115 curr_indent
= TREE_CODE (stmt
) == LABEL_EXPR
? label_indent
: indent
;
3117 INDENT (curr_indent
);
3118 dump_generic_node (buffer
, stmt
, curr_indent
, flags
, true);
3119 pp_newline (buffer
);
3120 dump_histograms_for_stmt (cfun
, buffer
->buffer
->stream
, stmt
);
3123 dump_implicit_edges (buffer
, bb
, indent
, flags
);
3125 if (flags
& TDF_BLOCKS
)
3126 dump_bb_end (buffer
, bb
, indent
, flags
);