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"
28 #include "diagnostic.h"
31 #include "tree-flow.h"
32 #include "langhooks.h"
33 #include "tree-iterator.h"
34 #include "tree-chrec.h"
35 #include "tree-pass.h"
36 #include "fixed-value.h"
37 #include "value-prof.h"
39 /* Local functions, macros and variables. */
40 static int op_prio (const_tree
);
41 static const char *op_symbol (const_tree
);
42 static void pretty_print_string (pretty_printer
*, const char*);
43 static void print_call_name (pretty_printer
*, const_tree
);
44 static void newline_and_indent (pretty_printer
*, int);
45 static void maybe_init_pretty_print (FILE *);
46 static void print_declaration (pretty_printer
*, tree
, int, int);
47 static void print_struct_decl (pretty_printer
*, const_tree
, int, int);
48 static void do_niy (pretty_printer
*, const_tree
);
49 static void dump_vops (pretty_printer
*, tree
, int, int);
50 static void dump_generic_bb_buff (pretty_printer
*, basic_block
, int, int);
52 #define INDENT(SPACE) do { \
53 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
55 #define NIY do_niy(buffer,node)
57 #define PRINT_FUNCTION_NAME(NODE) pp_printf \
58 (buffer, "%s", TREE_CODE (NODE) == NOP_EXPR ? \
59 lang_hooks.decl_printable_name (TREE_OPERAND (NODE, 0), 1) : \
60 lang_hooks.decl_printable_name (NODE, 1))
62 static pretty_printer buffer
;
63 static int initialized
= 0;
65 /* Try to print something for an unknown tree code. */
68 do_niy (pretty_printer
*buffer
, const_tree node
)
72 pp_string (buffer
, "<<< Unknown tree: ");
73 pp_string (buffer
, tree_code_name
[(int) TREE_CODE (node
)]);
77 len
= TREE_OPERAND_LENGTH (node
);
78 for (i
= 0; i
< len
; ++i
)
80 newline_and_indent (buffer
, 2);
81 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0, false);
85 pp_string (buffer
, " >>>\n");
88 /* Debugging function to print out a generic expression. */
91 debug_generic_expr (tree t
)
93 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
94 fprintf (stderr
, "\n");
97 /* Debugging function to print out a generic statement. */
100 debug_generic_stmt (tree t
)
102 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
103 fprintf (stderr
, "\n");
106 /* Debugging function to print out a chain of trees . */
109 debug_tree_chain (tree t
)
113 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
114 fprintf(stderr
, " ");
117 fprintf (stderr
, "\n");
120 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
122 print_generic_decl (FILE *file
, tree decl
, int flags
)
124 maybe_init_pretty_print (file
);
125 print_declaration (&buffer
, decl
, 2, flags
);
126 pp_write_text_to_stream (&buffer
);
129 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
130 to show in the dump. See TDF_* in tree.h. */
133 print_generic_stmt (FILE *file
, tree t
, int flags
)
135 maybe_init_pretty_print (file
);
136 dump_generic_node (&buffer
, t
, 0, flags
, true);
140 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
141 to show in the dump. See TDF_* in tree.h. The output is indented by
145 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
149 maybe_init_pretty_print (file
);
151 for (i
= 0; i
< indent
; i
++)
153 dump_generic_node (&buffer
, t
, indent
, flags
, true);
157 /* Print a single expression T on file FILE. FLAGS specifies details to show
158 in the dump. See TDF_* in tree.h. */
161 print_generic_expr (FILE *file
, tree t
, int flags
)
163 maybe_init_pretty_print (file
);
164 dump_generic_node (&buffer
, t
, 0, flags
, false);
167 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
171 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
176 pp_tree_identifier (buffer
, DECL_NAME (t
));
177 if ((flags
& TDF_UID
)
178 || DECL_NAME (t
) == NULL_TREE
)
180 if (TREE_CODE (t
) == LABEL_DECL
181 && LABEL_DECL_UID (t
) != -1)
182 pp_printf (buffer
, "L.%d", (int) LABEL_DECL_UID (t
));
185 char c
= TREE_CODE (t
) == CONST_DECL
? 'C' : 'D';
186 pp_printf (buffer
, "%c.%u", c
, DECL_UID (t
));
191 /* Like the above, but used for pretty printing function calls. */
194 dump_function_name (pretty_printer
*buffer
, tree node
)
196 if (DECL_NAME (node
))
197 PRINT_FUNCTION_NAME (node
);
199 dump_decl_name (buffer
, node
, 0);
202 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
203 FLAGS are as in dump_generic_node. */
206 dump_function_declaration (pretty_printer
*buffer
, tree node
,
209 bool wrote_arg
= false;
213 pp_character (buffer
, '(');
215 /* Print the argument types. The last element in the list is a VOID_TYPE.
216 The following avoids printing the last element. */
217 arg
= TYPE_ARG_TYPES (node
);
218 while (arg
&& TREE_CHAIN (arg
) && arg
!= error_mark_node
)
221 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
222 arg
= TREE_CHAIN (arg
);
223 if (TREE_CHAIN (arg
) && TREE_CODE (TREE_CHAIN (arg
)) == TREE_LIST
)
225 pp_character (buffer
, ',');
231 pp_string (buffer
, "void");
233 pp_character (buffer
, ')');
236 /* Dump the domain associated with an array. */
239 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
241 pp_character (buffer
, '[');
244 tree min
= TYPE_MIN_VALUE (domain
);
245 tree max
= TYPE_MAX_VALUE (domain
);
248 && integer_zerop (min
)
249 && host_integerp (max
, 0))
250 pp_wide_integer (buffer
, TREE_INT_CST_LOW (max
) + 1);
254 dump_generic_node (buffer
, min
, spc
, flags
, false);
255 pp_character (buffer
, ':');
257 dump_generic_node (buffer
, max
, spc
, flags
, false);
261 pp_string (buffer
, "<unknown>");
262 pp_character (buffer
, ']');
266 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
267 dump_generic_node. */
270 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
274 switch (OMP_CLAUSE_CODE (clause
))
276 case OMP_CLAUSE_PRIVATE
:
279 case OMP_CLAUSE_SHARED
:
282 case OMP_CLAUSE_FIRSTPRIVATE
:
283 name
= "firstprivate";
285 case OMP_CLAUSE_LASTPRIVATE
:
286 name
= "lastprivate";
288 case OMP_CLAUSE_COPYIN
:
291 case OMP_CLAUSE_COPYPRIVATE
:
292 name
= "copyprivate";
295 pp_string (buffer
, name
);
296 pp_character (buffer
, '(');
297 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
299 pp_character (buffer
, ')');
302 case OMP_CLAUSE_REDUCTION
:
303 pp_string (buffer
, "reduction(");
304 pp_string (buffer
, op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
305 pp_character (buffer
, ':');
306 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
308 pp_character (buffer
, ')');
312 pp_string (buffer
, "if(");
313 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
315 pp_character (buffer
, ')');
318 case OMP_CLAUSE_NUM_THREADS
:
319 pp_string (buffer
, "num_threads(");
320 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
322 pp_character (buffer
, ')');
325 case OMP_CLAUSE_NOWAIT
:
326 pp_string (buffer
, "nowait");
328 case OMP_CLAUSE_ORDERED
:
329 pp_string (buffer
, "ordered");
332 case OMP_CLAUSE_DEFAULT
:
333 pp_string (buffer
, "default(");
334 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
336 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
338 case OMP_CLAUSE_DEFAULT_SHARED
:
339 pp_string (buffer
, "shared");
341 case OMP_CLAUSE_DEFAULT_NONE
:
342 pp_string (buffer
, "none");
344 case OMP_CLAUSE_DEFAULT_PRIVATE
:
345 pp_string (buffer
, "private");
350 pp_character (buffer
, ')');
353 case OMP_CLAUSE_SCHEDULE
:
354 pp_string (buffer
, "schedule(");
355 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
357 case OMP_CLAUSE_SCHEDULE_STATIC
:
358 pp_string (buffer
, "static");
360 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
361 pp_string (buffer
, "dynamic");
363 case OMP_CLAUSE_SCHEDULE_GUIDED
:
364 pp_string (buffer
, "guided");
366 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
367 pp_string (buffer
, "runtime");
372 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
374 pp_character (buffer
, ',');
375 dump_generic_node (buffer
,
376 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
379 pp_character (buffer
, ')');
383 /* Should never happen. */
384 dump_generic_node (buffer
, clause
, spc
, flags
, false);
390 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
391 dump_generic_node. */
394 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
402 dump_omp_clause (buffer
, clause
, spc
, flags
);
403 clause
= OMP_CLAUSE_CHAIN (clause
);
411 /* Dump the set of decls SYMS. BUFFER, SPC and FLAGS are as in
412 dump_generic_node. */
415 dump_symbols (pretty_printer
*buffer
, bitmap syms
, int flags
)
421 pp_string (buffer
, "NIL");
424 pp_string (buffer
, " { ");
426 EXECUTE_IF_SET_IN_BITMAP (syms
, 0, i
, bi
)
428 tree sym
= referenced_var_lookup (i
);
429 dump_generic_node (buffer
, sym
, 0, flags
, false);
430 pp_string (buffer
, " ");
433 pp_string (buffer
, "}");
438 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of indent.
439 FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h).
440 If IS_STMT is true, the object printed is considered to be a statement
441 and it is terminated by ';' if appropriate. */
444 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
452 if (node
== NULL_TREE
)
455 is_expr
= EXPR_P (node
) || GIMPLE_STMT_P (node
);
457 /* We use has_stmt_ann because CALL_EXPR can be both an expression
458 and a statement, and we have no guarantee that it will have a
459 stmt_ann when it is used as an RHS expression. stmt_ann will assert
460 if you call it on something with a non-stmt annotation attached. */
461 if (TREE_CODE (node
) != ERROR_MARK
462 && is_gimple_stmt (node
)
463 && (flags
& (TDF_VOPS
|TDF_MEMSYMS
))
464 && has_stmt_ann (node
)
465 && TREE_CODE (node
) != PHI_NODE
)
466 dump_vops (buffer
, node
, spc
, flags
);
468 if (is_stmt
&& (flags
& TDF_STMTADDR
))
469 pp_printf (buffer
, "<&%p> ", (void *)node
);
471 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
473 expanded_location xloc
= expand_location (EXPR_LOCATION (node
));
474 pp_character (buffer
, '[');
477 pp_string (buffer
, xloc
.file
);
478 pp_string (buffer
, " : ");
480 pp_decimal_int (buffer
, xloc
.line
);
481 pp_string (buffer
, "] ");
484 switch (TREE_CODE (node
))
487 pp_string (buffer
, "<<< error >>>");
490 case IDENTIFIER_NODE
:
491 pp_tree_identifier (buffer
, node
);
495 while (node
&& node
!= error_mark_node
)
497 if (TREE_PURPOSE (node
))
499 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
502 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
503 node
= TREE_CHAIN (node
);
504 if (node
&& TREE_CODE (node
) == TREE_LIST
)
506 pp_character (buffer
, ',');
513 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
518 if (TREE_VEC_LENGTH (node
) > 0)
520 size_t len
= TREE_VEC_LENGTH (node
);
521 for (i
= 0; i
< len
- 1; i
++)
523 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
525 pp_character (buffer
, ',');
528 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
537 case FIXED_POINT_TYPE
:
543 unsigned int quals
= TYPE_QUALS (node
);
544 enum tree_code_class
class;
546 if (quals
& TYPE_QUAL_CONST
)
547 pp_string (buffer
, "const ");
548 else if (quals
& TYPE_QUAL_VOLATILE
)
549 pp_string (buffer
, "volatile ");
550 else if (quals
& TYPE_QUAL_RESTRICT
)
551 pp_string (buffer
, "restrict ");
553 class = TREE_CODE_CLASS (TREE_CODE (node
));
555 if (class == tcc_declaration
)
557 if (DECL_NAME (node
))
558 dump_decl_name (buffer
, node
, flags
);
560 pp_string (buffer
, "<unnamed type decl>");
562 else if (class == tcc_type
)
564 if (TYPE_NAME (node
))
566 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
567 pp_tree_identifier (buffer
, TYPE_NAME (node
));
568 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
569 && DECL_NAME (TYPE_NAME (node
)))
570 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
572 pp_string (buffer
, "<unnamed type>");
574 else if (TREE_CODE (node
) == VECTOR_TYPE
)
576 pp_string (buffer
, "vector ");
577 dump_generic_node (buffer
, TREE_TYPE (node
),
580 else if (TREE_CODE (node
) == INTEGER_TYPE
)
582 pp_string (buffer
, (TYPE_UNSIGNED (node
)
583 ? "<unnamed-unsigned:"
584 : "<unnamed-signed:"));
585 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
586 pp_string (buffer
, ">");
589 pp_string (buffer
, "<unnamed type>");
596 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
598 if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
600 tree fnode
= TREE_TYPE (node
);
602 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
604 pp_character (buffer
, '(');
605 pp_string (buffer
, str
);
606 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
607 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
609 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
611 pp_character (buffer
, ')');
612 dump_function_declaration (buffer
, fnode
, spc
, flags
);
616 unsigned int quals
= TYPE_QUALS (node
);
618 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
620 pp_string (buffer
, str
);
622 if (quals
& TYPE_QUAL_CONST
)
623 pp_string (buffer
, " const");
624 if (quals
& TYPE_QUAL_VOLATILE
)
625 pp_string (buffer
, " volatile");
626 if (quals
& TYPE_QUAL_RESTRICT
)
627 pp_string (buffer
, " restrict");
629 if (TYPE_REF_CAN_ALIAS_ALL (node
))
630 pp_string (buffer
, " {ref-all}");
639 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)), flags
);
640 pp_string (buffer
, "::");
645 const char *sep
= "";
648 pp_string (buffer
, "MEM[");
650 tmp
= TMR_SYMBOL (node
);
653 pp_string (buffer
, sep
);
655 pp_string (buffer
, "symbol: ");
656 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
658 tmp
= TMR_BASE (node
);
661 pp_string (buffer
, sep
);
663 pp_string (buffer
, "base: ");
664 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
666 tmp
= TMR_INDEX (node
);
669 pp_string (buffer
, sep
);
671 pp_string (buffer
, "index: ");
672 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
674 tmp
= TMR_STEP (node
);
677 pp_string (buffer
, sep
);
679 pp_string (buffer
, "step: ");
680 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
682 tmp
= TMR_OFFSET (node
);
685 pp_string (buffer
, sep
);
687 pp_string (buffer
, "offset: ");
688 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
690 pp_string (buffer
, "]");
691 if (flags
& TDF_DETAILS
)
693 pp_string (buffer
, "{");
694 dump_generic_node (buffer
, TMR_ORIGINAL (node
), spc
, flags
,
696 pp_string (buffer
, "}");
705 /* Print the innermost component type. */
706 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
707 tmp
= TREE_TYPE (tmp
))
709 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
711 /* Print the dimensions. */
712 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
713 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
719 case QUAL_UNION_TYPE
:
721 unsigned int quals
= TYPE_QUALS (node
);
723 if (quals
& TYPE_QUAL_CONST
)
724 pp_string (buffer
, "const ");
725 if (quals
& TYPE_QUAL_VOLATILE
)
726 pp_string (buffer
, "volatile ");
728 /* Print the name of the structure. */
729 if (TREE_CODE (node
) == RECORD_TYPE
)
730 pp_string (buffer
, "struct ");
731 else if (TREE_CODE (node
) == UNION_TYPE
)
732 pp_string (buffer
, "union ");
734 if (TYPE_NAME (node
))
735 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
737 print_struct_decl (buffer
, node
, spc
, flags
);
746 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
748 /* In the case of a pointer, one may want to divide by the
749 size of the pointed-to type. Unfortunately, this not
750 straightforward. The C front-end maps expressions
755 in such a way that the two INTEGER_CST nodes for "5" have
756 different values but identical types. In the latter
757 case, the 5 is multiplied by sizeof (int) in c-common.c
758 (pointer_int_sum) to convert it to a byte address, and
759 yet the type of the node is left unchanged. Argh. What
760 is consistent though is that the number value corresponds
761 to bytes (UNITS) offset.
763 NB: Neither of the following divisors can be trivially
764 used to recover the original literal:
766 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
767 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
768 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
769 pp_string (buffer
, "B"); /* pseudo-unit */
771 else if (! host_integerp (node
, 0))
774 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (val
);
775 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (val
);
777 if (tree_int_cst_sgn (val
) < 0)
779 pp_character (buffer
, '-');
783 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
785 sprintf (pp_buffer (buffer
)->digit_buffer
,
786 HOST_WIDE_INT_PRINT_DOUBLE_HEX
, high
, low
);
787 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
790 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
794 /* Code copied from print_node. */
797 if (TREE_OVERFLOW (node
))
798 pp_string (buffer
, " overflow");
800 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
801 d
= TREE_REAL_CST (node
);
802 if (REAL_VALUE_ISINF (d
))
803 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
804 else if (REAL_VALUE_ISNAN (d
))
805 pp_string (buffer
, " Nan");
809 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
810 pp_string (buffer
, string
);
815 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
816 pp_string (buffer
, "0x");
817 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
818 output_formatted_integer (buffer
, "%02x", *p
++);
827 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
828 pp_string (buffer
, string
);
833 pp_string (buffer
, "__complex__ (");
834 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
835 pp_string (buffer
, ", ");
836 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
837 pp_string (buffer
, ")");
841 pp_string (buffer
, "\"");
842 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
843 pp_string (buffer
, "\"");
849 pp_string (buffer
, "{ ");
850 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
852 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
, false);
853 if (TREE_CHAIN (elt
))
854 pp_string (buffer
, ", ");
856 pp_string (buffer
, " }");
865 dump_decl_name (buffer
, node
, flags
);
869 if (DECL_NAME (node
))
870 dump_decl_name (buffer
, node
, flags
);
871 else if (LABEL_DECL_UID (node
) != -1)
872 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
874 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
878 if (DECL_IS_BUILTIN (node
))
880 /* Don't print the declaration of built-in types. */
883 if (DECL_NAME (node
))
884 dump_decl_name (buffer
, node
, flags
);
887 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
888 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
889 && TYPE_METHODS (TREE_TYPE (node
)))
891 /* The type is a c++ class: all structures have at least
893 pp_string (buffer
, "class ");
894 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
899 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
900 ? "union" : "struct "));
901 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
906 case SYMBOL_MEMORY_TAG
:
907 case NAME_MEMORY_TAG
:
908 case STRUCT_FIELD_TAG
:
913 case MEMORY_PARTITION_TAG
:
914 dump_decl_name (buffer
, node
, flags
);
918 pp_string (buffer
, "<retval>");
922 op0
= TREE_OPERAND (node
, 0);
924 if (TREE_CODE (op0
) == INDIRECT_REF
)
926 op0
= TREE_OPERAND (op0
, 0);
929 if (op_prio (op0
) < op_prio (node
))
930 pp_character (buffer
, '(');
931 dump_generic_node (buffer
, op0
, spc
, flags
, false);
932 if (op_prio (op0
) < op_prio (node
))
933 pp_character (buffer
, ')');
934 pp_string (buffer
, str
);
935 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
937 if (TREE_CODE (op0
) != VALUE_HANDLE
)
939 op0
= component_ref_field_offset (node
);
940 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
942 pp_string (buffer
, "{off: ");
943 dump_generic_node (buffer
, op0
, spc
, flags
, false);
944 pp_character (buffer
, '}');
950 pp_string (buffer
, "BIT_FIELD_REF <");
951 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
952 pp_string (buffer
, ", ");
953 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
954 pp_string (buffer
, ", ");
955 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
956 pp_string (buffer
, ">");
960 case ARRAY_RANGE_REF
:
961 op0
= TREE_OPERAND (node
, 0);
962 if (op_prio (op0
) < op_prio (node
))
963 pp_character (buffer
, '(');
964 dump_generic_node (buffer
, op0
, spc
, flags
, false);
965 if (op_prio (op0
) < op_prio (node
))
966 pp_character (buffer
, ')');
967 pp_character (buffer
, '[');
968 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
969 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
970 pp_string (buffer
, " ...");
971 pp_character (buffer
, ']');
973 op0
= array_ref_low_bound (node
);
974 op1
= array_ref_element_size (node
);
976 if (!integer_zerop (op0
)
977 || TREE_OPERAND (node
, 2)
978 || TREE_OPERAND (node
, 3))
980 pp_string (buffer
, "{lb: ");
981 dump_generic_node (buffer
, op0
, spc
, flags
, false);
982 pp_string (buffer
, " sz: ");
983 dump_generic_node (buffer
, op1
, spc
, flags
, false);
984 pp_character (buffer
, '}');
990 unsigned HOST_WIDE_INT ix
;
992 bool is_struct_init
= FALSE
;
993 pp_character (buffer
, '{');
994 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
995 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
996 is_struct_init
= TRUE
;
997 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
999 if (field
&& is_struct_init
)
1001 pp_character (buffer
, '.');
1002 dump_generic_node (buffer
, field
, spc
, flags
, false);
1003 pp_string (buffer
, "=");
1005 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1006 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1007 val
= TREE_OPERAND (val
, 0);
1008 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1009 dump_decl_name (buffer
, val
, flags
);
1011 dump_generic_node (buffer
, val
, spc
, flags
, false);
1012 if (ix
!= VEC_length (constructor_elt
, CONSTRUCTOR_ELTS (node
)) - 1)
1014 pp_character (buffer
, ',');
1018 pp_character (buffer
, '}');
1025 if (flags
& TDF_SLIM
)
1027 pp_string (buffer
, "<COMPOUND_EXPR>");
1031 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1032 spc
, flags
, !(flags
& TDF_SLIM
));
1033 if (flags
& TDF_SLIM
)
1034 newline_and_indent (buffer
, spc
);
1037 pp_character (buffer
, ',');
1041 for (tp
= &TREE_OPERAND (node
, 1);
1042 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1043 tp
= &TREE_OPERAND (*tp
, 1))
1045 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1046 spc
, flags
, !(flags
& TDF_SLIM
));
1047 if (flags
& TDF_SLIM
)
1048 newline_and_indent (buffer
, spc
);
1051 pp_character (buffer
, ',');
1056 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1060 case STATEMENT_LIST
:
1062 tree_stmt_iterator si
;
1065 if (flags
& TDF_SLIM
)
1067 pp_string (buffer
, "<STATEMENT_LIST>");
1071 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1074 newline_and_indent (buffer
, spc
);
1077 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1083 case GIMPLE_MODIFY_STMT
:
1085 dump_generic_node (buffer
, GENERIC_TREE_OPERAND (node
, 0), spc
, flags
,
1088 pp_character (buffer
, '=');
1089 if (TREE_CODE (node
) == GIMPLE_MODIFY_STMT
1090 && MOVE_NONTEMPORAL (node
))
1091 pp_string (buffer
, "{nt}");
1092 if (TREE_CODE (node
) == GIMPLE_MODIFY_STMT
)
1095 if ((ann
= stmt_ann (node
))
1096 && ann
->has_volatile_ops
)
1097 pp_string (buffer
, "{v}");
1100 dump_generic_node (buffer
, GENERIC_TREE_OPERAND (node
, 1), spc
, flags
,
1105 pp_string (buffer
, "TARGET_EXPR <");
1106 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1107 pp_character (buffer
, ',');
1109 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1110 pp_character (buffer
, '>');
1114 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1119 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1121 pp_string (buffer
, "if (");
1122 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1123 pp_character (buffer
, ')');
1124 /* The lowered cond_exprs should always be printed in full. */
1125 if (COND_EXPR_THEN (node
)
1126 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1127 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1128 && COND_EXPR_ELSE (node
)
1129 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1130 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1133 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1135 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1137 pp_string (buffer
, " else ");
1138 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1142 else if (!(flags
& TDF_SLIM
))
1144 /* Output COND_EXPR_THEN. */
1145 if (COND_EXPR_THEN (node
))
1147 newline_and_indent (buffer
, spc
+2);
1148 pp_character (buffer
, '{');
1149 newline_and_indent (buffer
, spc
+4);
1150 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1152 newline_and_indent (buffer
, spc
+2);
1153 pp_character (buffer
, '}');
1156 /* Output COND_EXPR_ELSE. */
1157 if (COND_EXPR_ELSE (node
)
1158 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1160 newline_and_indent (buffer
, spc
);
1161 pp_string (buffer
, "else");
1162 newline_and_indent (buffer
, spc
+2);
1163 pp_character (buffer
, '{');
1164 newline_and_indent (buffer
, spc
+4);
1165 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1167 newline_and_indent (buffer
, spc
+2);
1168 pp_character (buffer
, '}');
1175 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1177 pp_character (buffer
, '?');
1179 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1181 pp_character (buffer
, ':');
1183 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1188 pp_character (buffer
, '{');
1189 if (!(flags
& TDF_SLIM
))
1191 if (BIND_EXPR_VARS (node
))
1193 pp_newline (buffer
);
1195 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= TREE_CHAIN (op0
))
1197 print_declaration (buffer
, op0
, spc
+2, flags
);
1198 pp_newline (buffer
);
1202 newline_and_indent (buffer
, spc
+2);
1203 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1204 newline_and_indent (buffer
, spc
);
1205 pp_character (buffer
, '}');
1211 print_call_name (buffer
, node
);
1213 /* Print parameters. */
1215 pp_character (buffer
, '(');
1218 call_expr_arg_iterator iter
;
1219 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1221 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1222 if (more_call_expr_args_p (&iter
))
1224 pp_character (buffer
, ',');
1229 if (CALL_EXPR_VA_ARG_PACK (node
))
1231 if (call_expr_nargs (node
) > 0)
1233 pp_character (buffer
, ',');
1236 pp_string (buffer
, "__builtin_va_arg_pack ()");
1238 pp_character (buffer
, ')');
1240 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1243 pp_string (buffer
, " [static-chain: ");
1244 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1245 pp_character (buffer
, ']');
1248 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1249 pp_string (buffer
, " [return slot optimization]");
1250 if (CALL_EXPR_TAILCALL (node
))
1251 pp_string (buffer
, " [tail call]");
1254 case WITH_CLEANUP_EXPR
:
1258 case CLEANUP_POINT_EXPR
:
1259 pp_string (buffer
, "<<cleanup_point ");
1260 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1261 pp_string (buffer
, ">>");
1264 case PLACEHOLDER_EXPR
:
1265 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1266 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1267 pp_character (buffer
, '>');
1270 /* Binary arithmetic and logic expressions. */
1271 case WIDEN_SUM_EXPR
:
1272 case WIDEN_MULT_EXPR
:
1275 case POINTER_PLUS_EXPR
:
1277 case TRUNC_DIV_EXPR
:
1279 case FLOOR_DIV_EXPR
:
1280 case ROUND_DIV_EXPR
:
1281 case TRUNC_MOD_EXPR
:
1283 case FLOOR_MOD_EXPR
:
1284 case ROUND_MOD_EXPR
:
1286 case EXACT_DIV_EXPR
:
1291 case VEC_LSHIFT_EXPR
:
1292 case VEC_RSHIFT_EXPR
:
1296 case TRUTH_ANDIF_EXPR
:
1297 case TRUTH_ORIF_EXPR
:
1298 case TRUTH_AND_EXPR
:
1300 case TRUTH_XOR_EXPR
:
1314 case UNORDERED_EXPR
:
1316 const char *op
= op_symbol (node
);
1317 op0
= TREE_OPERAND (node
, 0);
1318 op1
= TREE_OPERAND (node
, 1);
1320 /* When the operands are expressions with less priority,
1321 keep semantics of the tree representation. */
1322 if (op_prio (op0
) <= op_prio (node
))
1324 pp_character (buffer
, '(');
1325 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1326 pp_character (buffer
, ')');
1329 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1332 pp_string (buffer
, op
);
1335 /* When the operands are expressions with less priority,
1336 keep semantics of the tree representation. */
1337 if (op_prio (op1
) <= op_prio (node
))
1339 pp_character (buffer
, '(');
1340 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1341 pp_character (buffer
, ')');
1344 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1348 /* Unary arithmetic and logic expressions. */
1351 case TRUTH_NOT_EXPR
:
1353 case PREDECREMENT_EXPR
:
1354 case PREINCREMENT_EXPR
:
1355 case ALIGN_INDIRECT_REF
:
1356 case MISALIGNED_INDIRECT_REF
:
1358 if (TREE_CODE (node
) == ADDR_EXPR
1359 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1360 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1361 ; /* Do not output '&' for strings and function pointers. */
1363 pp_string (buffer
, op_symbol (node
));
1365 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1367 pp_character (buffer
, '(');
1368 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1369 pp_character (buffer
, ')');
1372 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1374 if (TREE_CODE (node
) == MISALIGNED_INDIRECT_REF
)
1376 pp_string (buffer
, "{misalignment: ");
1377 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1378 pp_character (buffer
, '}');
1382 case POSTDECREMENT_EXPR
:
1383 case POSTINCREMENT_EXPR
:
1384 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1386 pp_character (buffer
, '(');
1387 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1388 pp_character (buffer
, ')');
1391 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1392 pp_string (buffer
, op_symbol (node
));
1396 pp_string (buffer
, "MIN_EXPR <");
1397 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1398 pp_string (buffer
, ", ");
1399 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1400 pp_character (buffer
, '>');
1404 pp_string (buffer
, "MAX_EXPR <");
1405 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1406 pp_string (buffer
, ", ");
1407 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1408 pp_character (buffer
, '>');
1412 pp_string (buffer
, "ABS_EXPR <");
1413 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1414 pp_character (buffer
, '>');
1421 case FIXED_CONVERT_EXPR
:
1422 case FIX_TRUNC_EXPR
:
1426 type
= TREE_TYPE (node
);
1427 op0
= TREE_OPERAND (node
, 0);
1428 if (type
!= TREE_TYPE (op0
))
1430 pp_character (buffer
, '(');
1431 dump_generic_node (buffer
, type
, spc
, flags
, false);
1432 pp_string (buffer
, ") ");
1434 if (op_prio (op0
) < op_prio (node
))
1435 pp_character (buffer
, '(');
1436 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1437 if (op_prio (op0
) < op_prio (node
))
1438 pp_character (buffer
, ')');
1441 case VIEW_CONVERT_EXPR
:
1442 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1443 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1444 pp_string (buffer
, ">(");
1445 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1446 pp_character (buffer
, ')');
1449 case NON_LVALUE_EXPR
:
1450 pp_string (buffer
, "NON_LVALUE_EXPR <");
1451 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1452 pp_character (buffer
, '>');
1456 pp_string (buffer
, "SAVE_EXPR <");
1457 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1458 pp_character (buffer
, '>');
1462 pp_string (buffer
, "COMPLEX_EXPR <");
1463 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1464 pp_string (buffer
, ", ");
1465 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1466 pp_string (buffer
, ">");
1470 pp_string (buffer
, "CONJ_EXPR <");
1471 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1472 pp_string (buffer
, ">");
1476 pp_string (buffer
, "REALPART_EXPR <");
1477 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1478 pp_string (buffer
, ">");
1482 pp_string (buffer
, "IMAGPART_EXPR <");
1483 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1484 pp_string (buffer
, ">");
1488 pp_string (buffer
, "VA_ARG_EXPR <");
1489 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1490 pp_string (buffer
, ">");
1493 case TRY_FINALLY_EXPR
:
1494 case TRY_CATCH_EXPR
:
1495 pp_string (buffer
, "try");
1496 newline_and_indent (buffer
, spc
+2);
1497 pp_string (buffer
, "{");
1498 newline_and_indent (buffer
, spc
+4);
1499 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1500 newline_and_indent (buffer
, spc
+2);
1501 pp_string (buffer
, "}");
1502 newline_and_indent (buffer
, spc
);
1504 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1505 newline_and_indent (buffer
, spc
+2);
1506 pp_string (buffer
, "{");
1507 newline_and_indent (buffer
, spc
+4);
1508 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1509 newline_and_indent (buffer
, spc
+2);
1510 pp_string (buffer
, "}");
1515 pp_string (buffer
, "catch (");
1516 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1517 pp_string (buffer
, ")");
1518 newline_and_indent (buffer
, spc
+2);
1519 pp_string (buffer
, "{");
1520 newline_and_indent (buffer
, spc
+4);
1521 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1522 newline_and_indent (buffer
, spc
+2);
1523 pp_string (buffer
, "}");
1527 case EH_FILTER_EXPR
:
1528 pp_string (buffer
, "<<<eh_filter (");
1529 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1530 pp_string (buffer
, ")>>>");
1531 newline_and_indent (buffer
, spc
+2);
1532 pp_string (buffer
, "{");
1533 newline_and_indent (buffer
, spc
+4);
1534 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1535 newline_and_indent (buffer
, spc
+2);
1536 pp_string (buffer
, "}");
1540 case CHANGE_DYNAMIC_TYPE_EXPR
:
1541 pp_string (buffer
, "<<<change_dynamic_type (");
1542 dump_generic_node (buffer
, CHANGE_DYNAMIC_TYPE_NEW_TYPE (node
), spc
+ 2,
1544 pp_string (buffer
, ") ");
1545 dump_generic_node (buffer
, CHANGE_DYNAMIC_TYPE_LOCATION (node
), spc
+ 2,
1547 pp_string (buffer
, ")>>>");
1552 op0
= TREE_OPERAND (node
, 0);
1553 /* If this is for break or continue, don't bother printing it. */
1554 if (DECL_NAME (op0
))
1556 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1557 if (strcmp (name
, "break") == 0
1558 || strcmp (name
, "continue") == 0)
1561 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1562 pp_character (buffer
, ':');
1563 if (DECL_NONLOCAL (op0
))
1564 pp_string (buffer
, " [non-local]");
1568 pp_string (buffer
, "<<<exception object>>>");
1572 pp_string (buffer
, "<<<filter object>>>");
1576 pp_string (buffer
, "while (1)");
1577 if (!(flags
& TDF_SLIM
))
1579 newline_and_indent (buffer
, spc
+2);
1580 pp_character (buffer
, '{');
1581 newline_and_indent (buffer
, spc
+4);
1582 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1583 newline_and_indent (buffer
, spc
+2);
1584 pp_character (buffer
, '}');
1590 pp_string (buffer
, "return");
1591 op0
= TREE_OPERAND (node
, 0);
1595 if (TREE_CODE (op0
) == MODIFY_EXPR
1596 || TREE_CODE (op0
) == GIMPLE_MODIFY_STMT
)
1597 dump_generic_node (buffer
, GENERIC_TREE_OPERAND (op0
, 1),
1600 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1605 pp_string (buffer
, "if (");
1606 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1607 pp_string (buffer
, ") break");
1611 pp_string (buffer
, "switch (");
1612 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1613 pp_character (buffer
, ')');
1614 if (!(flags
& TDF_SLIM
))
1616 newline_and_indent (buffer
, spc
+2);
1617 pp_character (buffer
, '{');
1618 if (SWITCH_BODY (node
))
1620 newline_and_indent (buffer
, spc
+4);
1621 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1626 tree vec
= SWITCH_LABELS (node
);
1627 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1628 for (i
= 0; i
< n
; ++i
)
1630 tree elt
= TREE_VEC_ELT (vec
, i
);
1631 newline_and_indent (buffer
, spc
+4);
1634 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1635 pp_string (buffer
, " goto ");
1636 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1638 pp_semicolon (buffer
);
1641 pp_string (buffer
, "case ???: goto ???;");
1644 newline_and_indent (buffer
, spc
+2);
1645 pp_character (buffer
, '}');
1651 op0
= GOTO_DESTINATION (node
);
1652 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1654 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1655 if (strcmp (name
, "break") == 0
1656 || strcmp (name
, "continue") == 0)
1658 pp_string (buffer
, name
);
1662 pp_string (buffer
, "goto ");
1663 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1667 pp_string (buffer
, "resx ");
1668 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1672 pp_string (buffer
, "__asm__");
1673 if (ASM_VOLATILE_P (node
))
1674 pp_string (buffer
, " __volatile__");
1675 pp_character (buffer
, '(');
1676 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1677 pp_character (buffer
, ':');
1678 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1679 pp_character (buffer
, ':');
1680 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1681 if (ASM_CLOBBERS (node
))
1683 pp_character (buffer
, ':');
1684 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1686 pp_string (buffer
, ")");
1689 case CASE_LABEL_EXPR
:
1690 if (CASE_LOW (node
) && CASE_HIGH (node
))
1692 pp_string (buffer
, "case ");
1693 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1694 pp_string (buffer
, " ... ");
1695 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1697 else if (CASE_LOW (node
))
1699 pp_string (buffer
, "case ");
1700 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1703 pp_string (buffer
, "default ");
1704 pp_character (buffer
, ':');
1708 pp_string (buffer
, "OBJ_TYPE_REF(");
1709 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1710 pp_character (buffer
, ';');
1711 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1712 pp_character (buffer
, '-');
1713 pp_character (buffer
, '>');
1714 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
1715 pp_character (buffer
, ')');
1722 dump_generic_node (buffer
, PHI_RESULT (node
), spc
, flags
, false);
1723 pp_string (buffer
, " = PHI <");
1724 for (i
= 0; i
< PHI_NUM_ARGS (node
); i
++)
1726 dump_generic_node (buffer
, PHI_ARG_DEF (node
, i
), spc
, flags
, false);
1727 pp_string (buffer
, "(");
1728 pp_decimal_int (buffer
, PHI_ARG_EDGE (node
, i
)->src
->index
);
1729 pp_string (buffer
, ")");
1730 if (i
< PHI_NUM_ARGS (node
) - 1)
1731 pp_string (buffer
, ", ");
1733 pp_string (buffer
, ">");
1735 if (stmt_references_memory_p (node
) && (flags
& TDF_MEMSYMS
))
1736 dump_symbols (buffer
, STORED_SYMS (node
), flags
);
1741 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
1742 pp_string (buffer
, "_");
1743 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1744 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
1745 pp_string (buffer
, "(ab)");
1746 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
1747 pp_string (buffer
, "(D)");
1750 case WITH_SIZE_EXPR
:
1751 pp_string (buffer
, "WITH_SIZE_EXPR <");
1752 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1753 pp_string (buffer
, ", ");
1754 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1755 pp_string (buffer
, ">");
1759 pp_printf (buffer
, "VH.%d", VALUE_HANDLE_ID (node
));
1763 pp_string (buffer
, "ASSERT_EXPR <");
1764 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
1765 pp_string (buffer
, ", ");
1766 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
1767 pp_string (buffer
, ">");
1771 pp_string (buffer
, "scev_known");
1774 case SCEV_NOT_KNOWN
:
1775 pp_string (buffer
, "scev_not_known");
1778 case POLYNOMIAL_CHREC
:
1779 pp_string (buffer
, "{");
1780 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
1781 pp_string (buffer
, ", +, ");
1782 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
1783 pp_string (buffer
, "}_");
1784 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
1788 case REALIGN_LOAD_EXPR
:
1789 pp_string (buffer
, "REALIGN_LOAD <");
1790 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1791 pp_string (buffer
, ", ");
1792 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1793 pp_string (buffer
, ", ");
1794 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1795 pp_string (buffer
, ">");
1799 pp_string (buffer
, " VEC_COND_EXPR < ");
1800 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1801 pp_string (buffer
, " , ");
1802 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1803 pp_string (buffer
, " , ");
1804 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1805 pp_string (buffer
, " > ");
1809 pp_string (buffer
, " DOT_PROD_EXPR < ");
1810 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1811 pp_string (buffer
, ", ");
1812 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1813 pp_string (buffer
, ", ");
1814 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1815 pp_string (buffer
, " > ");
1819 pp_string (buffer
, "#pragma omp parallel");
1820 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
1821 if (OMP_PARALLEL_FN (node
))
1823 pp_string (buffer
, " [child fn: ");
1824 dump_generic_node (buffer
, OMP_PARALLEL_FN (node
), spc
, flags
, false);
1826 pp_string (buffer
, " (");
1828 if (OMP_PARALLEL_DATA_ARG (node
))
1829 dump_generic_node (buffer
, OMP_PARALLEL_DATA_ARG (node
), spc
, flags
,
1832 pp_string (buffer
, "???");
1834 pp_string (buffer
, ")]");
1838 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
1840 newline_and_indent (buffer
, spc
+ 2);
1841 pp_character (buffer
, '{');
1842 newline_and_indent (buffer
, spc
+ 4);
1843 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
1844 newline_and_indent (buffer
, spc
+ 2);
1845 pp_character (buffer
, '}');
1851 pp_string (buffer
, "#pragma omp for");
1852 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
1854 if (!(flags
& TDF_SLIM
))
1856 if (OMP_FOR_PRE_BODY (node
))
1858 newline_and_indent (buffer
, spc
+ 2);
1859 pp_character (buffer
, '{');
1861 newline_and_indent (buffer
, spc
);
1862 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
1865 newline_and_indent (buffer
, spc
);
1866 pp_string (buffer
, "for (");
1867 dump_generic_node (buffer
, OMP_FOR_INIT (node
), spc
, flags
, false);
1868 pp_string (buffer
, "; ");
1869 dump_generic_node (buffer
, OMP_FOR_COND (node
), spc
, flags
, false);
1870 pp_string (buffer
, "; ");
1871 dump_generic_node (buffer
, OMP_FOR_INCR (node
), spc
, flags
, false);
1872 pp_string (buffer
, ")");
1873 if (OMP_FOR_BODY (node
))
1875 newline_and_indent (buffer
, spc
+ 2);
1876 pp_character (buffer
, '{');
1877 newline_and_indent (buffer
, spc
+ 4);
1878 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
1880 newline_and_indent (buffer
, spc
+ 2);
1881 pp_character (buffer
, '}');
1883 if (OMP_FOR_PRE_BODY (node
))
1886 newline_and_indent (buffer
, spc
+ 2);
1887 pp_character (buffer
, '}');
1894 pp_string (buffer
, "#pragma omp sections");
1895 if (OMP_SECTIONS_CONTROL (node
))
1897 pp_string (buffer
, " <");
1898 dump_generic_node (buffer
, OMP_SECTIONS_CONTROL (node
), spc
,
1900 pp_string (buffer
, ">");
1902 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
1905 case OMP_SECTIONS_SWITCH
:
1906 pp_string (buffer
, "OMP_SECTIONS_SWITCH");
1911 pp_string (buffer
, "#pragma omp section");
1915 pp_string (buffer
, "#pragma omp master");
1919 pp_string (buffer
, "#pragma omp ordered");
1923 pp_string (buffer
, "#pragma omp critical");
1924 if (OMP_CRITICAL_NAME (node
))
1927 pp_character (buffer
, '(');
1928 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
1930 pp_character (buffer
, ')');
1935 pp_string (buffer
, "#pragma omp atomic");
1936 newline_and_indent (buffer
, spc
+ 2);
1937 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1939 pp_character (buffer
, '=');
1941 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1944 case OMP_ATOMIC_LOAD
:
1945 pp_string (buffer
, "#pragma omp atomic_load");
1946 newline_and_indent (buffer
, spc
+ 2);
1947 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1949 pp_character (buffer
, '=');
1951 pp_character (buffer
, '*');
1952 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1955 case OMP_ATOMIC_STORE
:
1956 pp_string (buffer
, "#pragma omp atomic_store (");
1957 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1958 pp_character (buffer
, ')');
1962 pp_string (buffer
, "#pragma omp single");
1963 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
1967 pp_string (buffer
, "OMP_RETURN");
1968 if (OMP_RETURN_NOWAIT (node
))
1969 pp_string (buffer
, " [nowait]");
1974 pp_string (buffer
, "OMP_CONTINUE <");
1975 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1976 pp_string (buffer
, " <- ");
1977 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1978 pp_string (buffer
, ">");
1983 dump_omp_clause (buffer
, node
, spc
, flags
);
1987 case REDUC_MAX_EXPR
:
1988 pp_string (buffer
, " REDUC_MAX_EXPR < ");
1989 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1990 pp_string (buffer
, " > ");
1993 case REDUC_MIN_EXPR
:
1994 pp_string (buffer
, " REDUC_MIN_EXPR < ");
1995 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1996 pp_string (buffer
, " > ");
1999 case REDUC_PLUS_EXPR
:
2000 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2001 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2002 pp_string (buffer
, " > ");
2005 case VEC_WIDEN_MULT_HI_EXPR
:
2006 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
2007 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2008 pp_string (buffer
, ", ");
2009 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2010 pp_string (buffer
, " > ");
2013 case VEC_WIDEN_MULT_LO_EXPR
:
2014 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
2015 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2016 pp_string (buffer
, ", ");
2017 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2018 pp_string (buffer
, " > ");
2021 case VEC_UNPACK_HI_EXPR
:
2022 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2023 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2024 pp_string (buffer
, " > ");
2027 case VEC_UNPACK_LO_EXPR
:
2028 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2029 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2030 pp_string (buffer
, " > ");
2033 case VEC_UNPACK_FLOAT_HI_EXPR
:
2034 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2035 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2036 pp_string (buffer
, " > ");
2039 case VEC_UNPACK_FLOAT_LO_EXPR
:
2040 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2041 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2042 pp_string (buffer
, " > ");
2045 case VEC_PACK_TRUNC_EXPR
:
2046 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2047 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2048 pp_string (buffer
, ", ");
2049 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2050 pp_string (buffer
, " > ");
2053 case VEC_PACK_SAT_EXPR
:
2054 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2055 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2056 pp_string (buffer
, ", ");
2057 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2058 pp_string (buffer
, " > ");
2061 case VEC_PACK_FIX_TRUNC_EXPR
:
2062 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2063 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2064 pp_string (buffer
, ", ");
2065 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2066 pp_string (buffer
, " > ");
2072 pp_string (buffer
, "BLOCK");
2074 if (BLOCK_ABSTRACT (node
))
2075 pp_string (buffer
, " [abstract]");
2077 if (TREE_ASM_WRITTEN (node
))
2078 pp_string (buffer
, " [written]");
2080 newline_and_indent (buffer
, spc
+ 2);
2082 if (BLOCK_SUPERCONTEXT (node
))
2084 pp_string (buffer
, "SUPERCONTEXT: ");
2085 if (TREE_CODE (BLOCK_SUPERCONTEXT (node
)) == BLOCK
)
2086 pp_printf (buffer
, "BLOCK %p",
2087 (void *)BLOCK_SUPERCONTEXT (node
));
2089 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (node
), 0, flags
,
2091 newline_and_indent (buffer
, spc
+ 2);
2094 if (BLOCK_SUBBLOCKS (node
))
2096 pp_string (buffer
, "SUBBLOCKS: ");
2097 for (t
= BLOCK_SUBBLOCKS (node
); t
; t
= BLOCK_CHAIN (t
))
2098 pp_printf (buffer
, "%p ", (void *)t
);
2099 newline_and_indent (buffer
, spc
+ 2);
2102 if (BLOCK_VARS (node
))
2104 pp_string (buffer
, "VARS: ");
2105 for (t
= BLOCK_VARS (node
); t
; t
= TREE_CHAIN (t
))
2107 dump_generic_node (buffer
, t
, 0, flags
, false);
2108 pp_string (buffer
, " ");
2110 newline_and_indent (buffer
, spc
+ 2);
2113 if (BLOCK_ABSTRACT_ORIGIN (node
))
2115 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
2116 if (TREE_CODE (BLOCK_ABSTRACT_ORIGIN (node
)) == BLOCK
)
2117 pp_printf (buffer
, "BLOCK %p",
2118 (void *)BLOCK_ABSTRACT_ORIGIN (node
));
2120 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (node
), 0, flags
,
2122 newline_and_indent (buffer
, spc
+ 2);
2127 case VEC_EXTRACT_EVEN_EXPR
:
2128 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2129 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2130 pp_string (buffer
, ", ");
2131 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2132 pp_string (buffer
, " > ");
2135 case VEC_EXTRACT_ODD_EXPR
:
2136 pp_string (buffer
, " VEC_EXTRACT_ODD_EXPR < ");
2137 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2138 pp_string (buffer
, ", ");
2139 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2140 pp_string (buffer
, " > ");
2143 case VEC_INTERLEAVE_HIGH_EXPR
:
2144 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_EXPR < ");
2145 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2146 pp_string (buffer
, ", ");
2147 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2148 pp_string (buffer
, " > ");
2151 case VEC_INTERLEAVE_LOW_EXPR
:
2152 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2153 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2154 pp_string (buffer
, ", ");
2155 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2156 pp_string (buffer
, " > ");
2163 if (is_stmt
&& is_expr
)
2164 pp_semicolon (buffer
);
2166 /* If we're building a diagnostic, the formatted text will be written
2167 into BUFFER's stream by the caller; otherwise, write it now. */
2168 if (!(flags
& TDF_DIAGNOSTIC
))
2169 pp_write_text_to_stream (buffer
);
2174 /* Print the declaration of a variable. */
2177 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2181 if (TREE_CODE (t
) == TYPE_DECL
)
2182 pp_string (buffer
, "typedef ");
2184 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2185 pp_string (buffer
, "register ");
2187 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2188 pp_string (buffer
, "extern ");
2189 else if (TREE_STATIC (t
))
2190 pp_string (buffer
, "static ");
2192 /* Print the type and name. */
2193 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2197 /* Print array's type. */
2198 tmp
= TREE_TYPE (t
);
2199 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2200 tmp
= TREE_TYPE (tmp
);
2201 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2203 /* Print variable's name. */
2205 dump_generic_node (buffer
, t
, spc
, flags
, false);
2207 /* Print the dimensions. */
2208 tmp
= TREE_TYPE (t
);
2209 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2211 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2212 tmp
= TREE_TYPE (tmp
);
2215 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2217 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2219 dump_decl_name (buffer
, t
, flags
);
2220 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2224 /* Print type declaration. */
2225 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2227 /* Print variable's name. */
2229 dump_generic_node (buffer
, t
, spc
, flags
, false);
2232 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2234 pp_string (buffer
, " __asm__ ");
2235 pp_character (buffer
, '(');
2236 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2237 pp_character (buffer
, ')');
2240 /* The initial value of a function serves to determine wether the function
2241 is declared or defined. So the following does not apply to function
2243 if (TREE_CODE (t
) != FUNCTION_DECL
)
2245 /* Print the initial value. */
2246 if (DECL_INITIAL (t
))
2249 pp_character (buffer
, '=');
2251 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2255 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2257 pp_string (buffer
, " [value-expr: ");
2258 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2259 pp_character (buffer
, ']');
2262 pp_character (buffer
, ';');
2266 /* Prints a structure: name, fields, and methods.
2267 FIXME: Still incomplete. */
2270 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2272 /* Print the name of the structure. */
2273 if (TYPE_NAME (node
))
2276 if (TREE_CODE (node
) == RECORD_TYPE
)
2277 pp_string (buffer
, "struct ");
2278 else if ((TREE_CODE (node
) == UNION_TYPE
2279 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2280 pp_string (buffer
, "union ");
2282 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2285 /* Print the contents of the structure. */
2286 pp_newline (buffer
);
2288 pp_character (buffer
, '{');
2289 pp_newline (buffer
);
2291 /* Print the fields of the structure. */
2294 tmp
= TYPE_FIELDS (node
);
2297 /* Avoid to print recursively the structure. */
2298 /* FIXME : Not implemented correctly...,
2299 what about the case when we have a cycle in the contain graph? ...
2300 Maybe this could be solved by looking at the scope in which the
2301 structure was declared. */
2302 if (TREE_TYPE (tmp
) != node
2303 || (TREE_CODE (TREE_TYPE (tmp
)) == POINTER_TYPE
2304 && TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2306 print_declaration (buffer
, tmp
, spc
+2, flags
);
2307 pp_newline (buffer
);
2309 tmp
= TREE_CHAIN (tmp
);
2313 pp_character (buffer
, '}');
2316 /* Return the priority of the operator OP.
2318 From lowest to highest precedence with either left-to-right (L-R)
2319 or right-to-left (R-L) associativity]:
2322 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2334 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2335 15 [L-R] fn() [] -> .
2337 unary +, - and * have higher precedence than the corresponding binary
2341 op_prio (const_tree op
)
2346 switch (TREE_CODE (op
))
2354 case GIMPLE_MODIFY_STMT
:
2362 case TRUTH_ORIF_EXPR
:
2365 case TRUTH_AND_EXPR
:
2366 case TRUTH_ANDIF_EXPR
:
2373 case TRUTH_XOR_EXPR
:
2390 case UNORDERED_EXPR
:
2403 case WIDEN_SUM_EXPR
:
2405 case POINTER_PLUS_EXPR
:
2409 case VEC_WIDEN_MULT_HI_EXPR
:
2410 case VEC_WIDEN_MULT_LO_EXPR
:
2411 case WIDEN_MULT_EXPR
:
2414 case TRUNC_DIV_EXPR
:
2416 case FLOOR_DIV_EXPR
:
2417 case ROUND_DIV_EXPR
:
2419 case EXACT_DIV_EXPR
:
2420 case TRUNC_MOD_EXPR
:
2422 case FLOOR_MOD_EXPR
:
2423 case ROUND_MOD_EXPR
:
2426 case TRUTH_NOT_EXPR
:
2428 case POSTINCREMENT_EXPR
:
2429 case POSTDECREMENT_EXPR
:
2430 case PREINCREMENT_EXPR
:
2431 case PREDECREMENT_EXPR
:
2433 case ALIGN_INDIRECT_REF
:
2434 case MISALIGNED_INDIRECT_REF
:
2440 case FIX_TRUNC_EXPR
:
2446 case ARRAY_RANGE_REF
:
2450 /* Special expressions. */
2456 case REDUC_MAX_EXPR
:
2457 case REDUC_MIN_EXPR
:
2458 case REDUC_PLUS_EXPR
:
2459 case VEC_LSHIFT_EXPR
:
2460 case VEC_RSHIFT_EXPR
:
2461 case VEC_UNPACK_HI_EXPR
:
2462 case VEC_UNPACK_LO_EXPR
:
2463 case VEC_UNPACK_FLOAT_HI_EXPR
:
2464 case VEC_UNPACK_FLOAT_LO_EXPR
:
2465 case VEC_PACK_TRUNC_EXPR
:
2466 case VEC_PACK_SAT_EXPR
:
2470 case NON_LVALUE_EXPR
:
2471 return op_prio (TREE_OPERAND (op
, 0));
2474 /* Return an arbitrarily high precedence to avoid surrounding single
2475 VAR_DECLs in ()s. */
2481 /* Return the symbol associated with operator CODE. */
2484 op_symbol_code (enum tree_code code
)
2489 case GIMPLE_MODIFY_STMT
:
2493 case TRUTH_ORIF_EXPR
:
2496 case TRUTH_AND_EXPR
:
2497 case TRUTH_ANDIF_EXPR
:
2503 case TRUTH_XOR_EXPR
:
2513 case UNORDERED_EXPR
:
2559 case VEC_LSHIFT_EXPR
:
2562 case VEC_RSHIFT_EXPR
:
2565 case POINTER_PLUS_EXPR
:
2571 case REDUC_PLUS_EXPR
:
2574 case WIDEN_SUM_EXPR
:
2577 case WIDEN_MULT_EXPR
:
2587 case TRUTH_NOT_EXPR
:
2594 case ALIGN_INDIRECT_REF
:
2597 case MISALIGNED_INDIRECT_REF
:
2600 case TRUNC_DIV_EXPR
:
2607 case FLOOR_DIV_EXPR
:
2610 case ROUND_DIV_EXPR
:
2613 case EXACT_DIV_EXPR
:
2616 case TRUNC_MOD_EXPR
:
2622 case FLOOR_MOD_EXPR
:
2625 case ROUND_MOD_EXPR
:
2628 case PREDECREMENT_EXPR
:
2631 case PREINCREMENT_EXPR
:
2634 case POSTDECREMENT_EXPR
:
2637 case POSTINCREMENT_EXPR
:
2647 return "<<< ??? >>>";
2651 /* Return the symbol associated with operator OP. */
2654 op_symbol (const_tree op
)
2656 return op_symbol_code (TREE_CODE (op
));
2659 /* Prints the name of a CALL_EXPR. */
2662 print_call_name (pretty_printer
*buffer
, const_tree node
)
2666 gcc_assert (TREE_CODE (node
) == CALL_EXPR
);
2668 op0
= CALL_EXPR_FN (node
);
2670 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2671 op0
= TREE_OPERAND (op0
, 0);
2673 switch (TREE_CODE (op0
))
2677 dump_function_name (buffer
, op0
);
2683 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2687 pp_string (buffer
, "(");
2688 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2689 pp_string (buffer
, ") ? ");
2690 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, 0, false);
2691 pp_string (buffer
, " : ");
2692 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, 0, false);
2696 /* The function is a pointer contained in a structure. */
2697 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == INDIRECT_REF
||
2698 TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2699 dump_function_name (buffer
, TREE_OPERAND (op0
, 1));
2701 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2703 We can have several levels of structures and a function
2704 pointer inside. This is not implemented yet... */
2709 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2710 dump_function_name (buffer
, TREE_OPERAND (op0
, 0));
2712 dump_generic_node (buffer
, op0
, 0, 0, false);
2717 dump_generic_node (buffer
, op0
, 0, 0, false);
2725 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2728 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2738 pp_string (buffer
, "\\b");
2742 pp_string (buffer
, "\\f");
2746 pp_string (buffer
, "\\n");
2750 pp_string (buffer
, "\\r");
2754 pp_string (buffer
, "\\t");
2758 pp_string (buffer
, "\\v");
2762 pp_string (buffer
, "\\\\");
2766 pp_string (buffer
, "\\\"");
2770 pp_string (buffer
, "\\'");
2773 /* No need to handle \0; the loop terminates on \0. */
2776 pp_string (buffer
, "\\1");
2780 pp_string (buffer
, "\\2");
2784 pp_string (buffer
, "\\3");
2788 pp_string (buffer
, "\\4");
2792 pp_string (buffer
, "\\5");
2796 pp_string (buffer
, "\\6");
2800 pp_string (buffer
, "\\7");
2804 pp_character (buffer
, str
[0]);
2812 maybe_init_pretty_print (FILE *file
)
2816 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
2817 pp_needs_newline (&buffer
) = true;
2821 buffer
.buffer
->stream
= file
;
2825 newline_and_indent (pretty_printer
*buffer
, int spc
)
2827 pp_newline (buffer
);
2833 dump_vops (pretty_printer
*buffer
, tree stmt
, int spc
, int flags
)
2835 struct voptype_d
*vdefs
;
2836 struct voptype_d
*vuses
;
2839 if (!ssa_operands_active () || !stmt_references_memory_p (stmt
))
2842 /* Even if the statement doesn't have virtual operators yet, it may
2843 contain symbol information (this happens before aliases have been
2845 if ((flags
& TDF_MEMSYMS
)
2846 && VUSE_OPS (stmt
) == NULL
2847 && VDEF_OPS (stmt
) == NULL
)
2849 if (LOADED_SYMS (stmt
))
2851 pp_string (buffer
, "# LOADS: ");
2852 dump_symbols (buffer
, LOADED_SYMS (stmt
), flags
);
2853 newline_and_indent (buffer
, spc
);
2856 if (STORED_SYMS (stmt
))
2858 pp_string (buffer
, "# STORES: ");
2859 dump_symbols (buffer
, STORED_SYMS (stmt
), flags
);
2860 newline_and_indent (buffer
, spc
);
2866 vuses
= VUSE_OPS (stmt
);
2869 pp_string (buffer
, "# VUSE <");
2871 n
= VUSE_NUM (vuses
);
2872 for (i
= 0; i
< n
; i
++)
2874 dump_generic_node (buffer
, VUSE_OP (vuses
, i
), spc
+ 2, flags
, false);
2876 pp_string (buffer
, ", ");
2879 pp_string (buffer
, ">");
2881 if (flags
& TDF_MEMSYMS
)
2882 dump_symbols (buffer
, LOADED_SYMS (stmt
), flags
);
2884 newline_and_indent (buffer
, spc
);
2885 vuses
= vuses
->next
;
2888 vdefs
= VDEF_OPS (stmt
);
2891 pp_string (buffer
, "# ");
2892 dump_generic_node (buffer
, VDEF_RESULT (vdefs
), spc
+ 2, flags
, false);
2893 pp_string (buffer
, " = VDEF <");
2895 n
= VDEF_NUM (vdefs
);
2896 for (i
= 0; i
< n
; i
++)
2898 dump_generic_node (buffer
, VDEF_OP (vdefs
, i
), spc
+ 2, flags
, 0);
2900 pp_string (buffer
, ", ");
2903 pp_string (buffer
, ">");
2905 if ((flags
& TDF_MEMSYMS
) && vdefs
->next
== NULL
)
2906 dump_symbols (buffer
, STORED_SYMS (stmt
), flags
);
2908 newline_and_indent (buffer
, spc
);
2909 vdefs
= vdefs
->next
;
2914 /* Dumps basic block BB to FILE with details described by FLAGS and
2915 indented by INDENT spaces. */
2918 dump_generic_bb (FILE *file
, basic_block bb
, int indent
, int flags
)
2920 maybe_init_pretty_print (file
);
2921 dump_generic_bb_buff (&buffer
, bb
, indent
, flags
);
2925 /* Dumps header of basic block BB to buffer BUFFER indented by INDENT
2926 spaces and details described by flags. */
2929 dump_bb_header (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
2935 if (flags
& TDF_BLOCKS
)
2938 pp_string (buffer
, "# BLOCK ");
2939 pp_decimal_int (buffer
, bb
->index
);
2942 pp_string (buffer
, " freq:");
2943 pp_decimal_int (buffer
, bb
->frequency
);
2947 pp_string (buffer
, " count:");
2948 pp_widest_integer (buffer
, bb
->count
);
2951 if (flags
& TDF_LINENO
)
2953 block_stmt_iterator bsi
;
2955 for (bsi
= bsi_start (bb
); !bsi_end_p (bsi
); bsi_next (&bsi
))
2956 if (get_lineno (bsi_stmt (bsi
)) != -1)
2958 pp_string (buffer
, ", starting at line ");
2959 pp_decimal_int (buffer
, get_lineno (bsi_stmt (bsi
)));
2963 newline_and_indent (buffer
, indent
);
2965 pp_string (buffer
, "# PRED:");
2966 pp_write_text_to_stream (buffer
);
2967 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
2968 if (flags
& TDF_SLIM
)
2970 pp_string (buffer
, " ");
2971 if (e
->src
== ENTRY_BLOCK_PTR
)
2972 pp_string (buffer
, "ENTRY");
2974 pp_decimal_int (buffer
, e
->src
->index
);
2977 dump_edge_info (buffer
->buffer
->stream
, e
, 0);
2978 pp_newline (buffer
);
2982 stmt
= first_stmt (bb
);
2983 if (!stmt
|| TREE_CODE (stmt
) != LABEL_EXPR
)
2985 INDENT (indent
- 2);
2986 pp_string (buffer
, "<bb ");
2987 pp_decimal_int (buffer
, bb
->index
);
2988 pp_string (buffer
, ">:");
2989 pp_newline (buffer
);
2992 pp_write_text_to_stream (buffer
);
2993 check_bb_profile (bb
, buffer
->buffer
->stream
);
2996 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
3000 dump_bb_end (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
3006 pp_string (buffer
, "# SUCC:");
3007 pp_write_text_to_stream (buffer
);
3008 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
3009 if (flags
& TDF_SLIM
)
3011 pp_string (buffer
, " ");
3012 if (e
->dest
== EXIT_BLOCK_PTR
)
3013 pp_string (buffer
, "EXIT");
3015 pp_decimal_int (buffer
, e
->dest
->index
);
3018 dump_edge_info (buffer
->buffer
->stream
, e
, 1);
3019 pp_newline (buffer
);
3022 /* Dump PHI nodes of basic block BB to BUFFER with details described
3023 by FLAGS and indented by INDENT spaces. */
3026 dump_phi_nodes (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
3028 tree phi
= phi_nodes (bb
);
3032 for (; phi
; phi
= PHI_CHAIN (phi
))
3034 if (is_gimple_reg (PHI_RESULT (phi
)) || (flags
& TDF_VOPS
))
3037 pp_string (buffer
, "# ");
3038 dump_generic_node (buffer
, phi
, indent
, flags
, false);
3039 pp_newline (buffer
);
3045 /* Dump jump to basic block BB that is represented implicitly in the cfg
3049 pp_cfg_jump (pretty_printer
*buffer
, basic_block bb
)
3053 stmt
= first_stmt (bb
);
3055 pp_string (buffer
, "goto <bb ");
3056 pp_decimal_int (buffer
, bb
->index
);
3057 pp_string (buffer
, ">");
3058 if (stmt
&& TREE_CODE (stmt
) == LABEL_EXPR
)
3060 pp_string (buffer
, " (");
3061 dump_generic_node (buffer
, LABEL_EXPR_LABEL (stmt
), 0, 0, false);
3062 pp_string (buffer
, ")");
3064 pp_semicolon (buffer
);
3067 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
3068 by INDENT spaces, with details given by FLAGS. */
3071 dump_implicit_edges (pretty_printer
*buffer
, basic_block bb
, int indent
,
3078 stmt
= last_stmt (bb
);
3079 if (stmt
&& TREE_CODE (stmt
) == COND_EXPR
)
3081 edge true_edge
, false_edge
;
3083 /* When we are emitting the code or changing CFG, it is possible that
3084 the edges are not yet created. When we are using debug_bb in such
3085 a situation, we do not want it to crash. */
3086 if (EDGE_COUNT (bb
->succs
) != 2)
3088 extract_true_false_edges_from_block (bb
, &true_edge
, &false_edge
);
3090 INDENT (indent
+ 2);
3091 pp_cfg_jump (buffer
, true_edge
->dest
);
3092 newline_and_indent (buffer
, indent
);
3093 pp_string (buffer
, "else");
3094 newline_and_indent (buffer
, indent
+ 2);
3095 pp_cfg_jump (buffer
, false_edge
->dest
);
3096 pp_newline (buffer
);
3100 /* If there is a fallthru edge, we may need to add an artificial goto to the
3102 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
3103 if (e
->flags
& EDGE_FALLTHRU
)
3105 if (e
&& e
->dest
!= bb
->next_bb
)
3109 if ((flags
& TDF_LINENO
)
3110 #ifdef USE_MAPPED_LOCATION
3111 && e
->goto_locus
!= UNKNOWN_LOCATION
3117 expanded_location goto_xloc
;
3118 #ifdef USE_MAPPED_LOCATION
3119 goto_xloc
= expand_location (e
->goto_locus
);
3121 goto_xloc
= *e
->goto_locus
;
3123 pp_character (buffer
, '[');
3126 pp_string (buffer
, goto_xloc
.file
);
3127 pp_string (buffer
, " : ");
3129 pp_decimal_int (buffer
, goto_xloc
.line
);
3130 pp_string (buffer
, "] ");
3133 pp_cfg_jump (buffer
, e
->dest
);
3134 pp_newline (buffer
);
3138 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
3139 indented by INDENT spaces. */
3142 dump_generic_bb_buff (pretty_printer
*buffer
, basic_block bb
,
3143 int indent
, int flags
)
3145 block_stmt_iterator bsi
;
3147 int label_indent
= indent
- 2;
3149 if (label_indent
< 0)
3152 dump_bb_header (buffer
, bb
, indent
, flags
);
3154 dump_phi_nodes (buffer
, bb
, indent
, flags
);
3156 for (bsi
= bsi_start (bb
); !bsi_end_p (bsi
); bsi_next (&bsi
))
3160 stmt
= bsi_stmt (bsi
);
3162 curr_indent
= TREE_CODE (stmt
) == LABEL_EXPR
? label_indent
: indent
;
3164 INDENT (curr_indent
);
3165 dump_generic_node (buffer
, stmt
, curr_indent
, flags
, true);
3166 pp_newline (buffer
);
3167 dump_histograms_for_stmt (cfun
, buffer
->buffer
->stream
, stmt
);
3170 dump_implicit_edges (buffer
, bb
, indent
, flags
);
3172 if (flags
& TDF_BLOCKS
)
3173 dump_bb_end (buffer
, bb
, indent
, flags
);