1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
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 2, 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 COPYING. If not, write to the Free
20 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
25 #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 "value-prof.h"
38 /* Local functions, macros and variables. */
39 static int op_prio (tree
);
40 static const char *op_symbol_1 (enum tree_code
);
41 static const char *op_symbol (tree
);
42 static void pretty_print_string (pretty_printer
*, const char*);
43 static void print_call_name (pretty_printer
*, 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
*, tree
, int, int);
48 static void do_niy (pretty_printer
*, 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
, tree node
)
72 pp_string (buffer
, "<<< Unknown tree: ");
73 pp_string (buffer
, tree_code_name
[(int) TREE_CODE (node
)]);
77 len
= TREE_CODE_LENGTH (TREE_CODE (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");
89 debug_generic_expr (tree t
)
91 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
92 fprintf (stderr
, "\n");
96 debug_generic_stmt (tree t
)
98 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
99 fprintf (stderr
, "\n");
103 debug_tree_chain (tree t
)
107 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
108 fprintf(stderr
, " ");
111 fprintf (stderr
, "\n");
114 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
116 print_generic_decl (FILE *file
, tree decl
, int flags
)
118 maybe_init_pretty_print (file
);
119 print_declaration (&buffer
, decl
, 2, flags
);
120 pp_write_text_to_stream (&buffer
);
123 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
124 to show in the dump. See TDF_* in tree.h. */
127 print_generic_stmt (FILE *file
, tree t
, int flags
)
129 maybe_init_pretty_print (file
);
130 dump_generic_node (&buffer
, t
, 0, flags
, true);
134 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
135 to show in the dump. See TDF_* in tree.h. The output is indented by
139 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
143 maybe_init_pretty_print (file
);
145 for (i
= 0; i
< indent
; i
++)
147 dump_generic_node (&buffer
, t
, indent
, flags
, true);
151 /* Print a single expression T on file FILE. FLAGS specifies details to show
152 in the dump. See TDF_* in tree.h. */
155 print_generic_expr (FILE *file
, tree t
, int flags
)
157 maybe_init_pretty_print (file
);
158 dump_generic_node (&buffer
, t
, 0, flags
, false);
161 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
165 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
170 pp_tree_identifier (buffer
, DECL_NAME (t
));
171 if ((flags
& TDF_UID
)
172 || DECL_NAME (t
) == NULL_TREE
)
174 if (TREE_CODE (t
) == LABEL_DECL
175 && LABEL_DECL_UID (t
) != -1)
176 pp_printf (buffer
, "L." HOST_WIDE_INT_PRINT_DEC
,
180 char c
= TREE_CODE (t
) == CONST_DECL
? 'C' : 'D';
181 pp_printf (buffer
, "%c.%u", c
, DECL_UID (t
));
186 /* Like the above, but used for pretty printing function calls. */
189 dump_function_name (pretty_printer
*buffer
, tree node
)
191 if (DECL_NAME (node
))
192 PRINT_FUNCTION_NAME (node
);
194 dump_decl_name (buffer
, node
, 0);
197 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
198 FLAGS are as in dump_generic_node. */
201 dump_function_declaration (pretty_printer
*buffer
, tree node
,
204 bool wrote_arg
= false;
208 pp_character (buffer
, '(');
210 /* Print the argument types. The last element in the list is a VOID_TYPE.
211 The following avoids printing the last element. */
212 arg
= TYPE_ARG_TYPES (node
);
213 while (arg
&& TREE_CHAIN (arg
) && arg
!= error_mark_node
)
216 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
217 arg
= TREE_CHAIN (arg
);
218 if (TREE_CHAIN (arg
) && TREE_CODE (TREE_CHAIN (arg
)) == TREE_LIST
)
220 pp_character (buffer
, ',');
226 pp_string (buffer
, "void");
228 pp_character (buffer
, ')');
231 /* Dump the domain associated with an array. */
234 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
236 pp_character (buffer
, '[');
239 tree min
= TYPE_MIN_VALUE (domain
);
240 tree max
= TYPE_MAX_VALUE (domain
);
243 && integer_zerop (min
)
244 && host_integerp (max
, 0))
245 pp_wide_integer (buffer
, TREE_INT_CST_LOW (max
) + 1);
249 dump_generic_node (buffer
, min
, spc
, flags
, false);
250 pp_character (buffer
, ':');
252 dump_generic_node (buffer
, max
, spc
, flags
, false);
256 pp_string (buffer
, "<unknown>");
257 pp_character (buffer
, ']');
261 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
262 dump_generic_node. */
265 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
269 switch (OMP_CLAUSE_CODE (clause
))
271 case OMP_CLAUSE_PRIVATE
:
274 case OMP_CLAUSE_SHARED
:
277 case OMP_CLAUSE_FIRSTPRIVATE
:
278 name
= "firstprivate";
280 case OMP_CLAUSE_LASTPRIVATE
:
281 name
= "lastprivate";
283 case OMP_CLAUSE_COPYIN
:
286 case OMP_CLAUSE_COPYPRIVATE
:
287 name
= "copyprivate";
290 pp_string (buffer
, name
);
291 pp_character (buffer
, '(');
292 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
294 pp_character (buffer
, ')');
297 case OMP_CLAUSE_REDUCTION
:
298 pp_string (buffer
, "reduction(");
299 pp_string (buffer
, op_symbol_1 (OMP_CLAUSE_REDUCTION_CODE (clause
)));
300 pp_character (buffer
, ':');
301 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
303 pp_character (buffer
, ')');
307 pp_string (buffer
, "if(");
308 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
310 pp_character (buffer
, ')');
313 case OMP_CLAUSE_NUM_THREADS
:
314 pp_string (buffer
, "num_threads(");
315 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
317 pp_character (buffer
, ')');
320 case OMP_CLAUSE_NOWAIT
:
321 pp_string (buffer
, "nowait");
323 case OMP_CLAUSE_ORDERED
:
324 pp_string (buffer
, "ordered");
327 case OMP_CLAUSE_DEFAULT
:
328 pp_string (buffer
, "default(");
329 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
331 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
333 case OMP_CLAUSE_DEFAULT_SHARED
:
334 pp_string (buffer
, "shared");
336 case OMP_CLAUSE_DEFAULT_NONE
:
337 pp_string (buffer
, "none");
339 case OMP_CLAUSE_DEFAULT_PRIVATE
:
340 pp_string (buffer
, "private");
345 pp_character (buffer
, ')');
348 case OMP_CLAUSE_SCHEDULE
:
349 pp_string (buffer
, "schedule(");
350 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
352 case OMP_CLAUSE_SCHEDULE_STATIC
:
353 pp_string (buffer
, "static");
355 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
356 pp_string (buffer
, "dynamic");
358 case OMP_CLAUSE_SCHEDULE_GUIDED
:
359 pp_string (buffer
, "guided");
361 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
362 pp_string (buffer
, "runtime");
367 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
369 pp_character (buffer
, ',');
370 dump_generic_node (buffer
,
371 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
374 pp_character (buffer
, ')');
378 /* Should never happen. */
379 dump_generic_node (buffer
, clause
, spc
, flags
, false);
385 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
386 dump_generic_node. */
389 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
397 dump_omp_clause (buffer
, clause
, spc
, flags
);
398 clause
= OMP_CLAUSE_CHAIN (clause
);
406 /* Dump the set of decls SYMS. BUFFER, SPC and FLAGS are as in
407 dump_generic_node. */
410 dump_symbols (pretty_printer
*buffer
, bitmap syms
, int flags
)
416 pp_string (buffer
, "NIL");
419 pp_string (buffer
, " { ");
421 EXECUTE_IF_SET_IN_BITMAP (syms
, 0, i
, bi
)
423 tree sym
= referenced_var_lookup (i
);
424 dump_generic_node (buffer
, sym
, 0, flags
, false);
425 pp_string (buffer
, " ");
428 pp_string (buffer
, "}");
433 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of indent.
434 FLAGS specifies details to show in the dump (see TDF_* in tree.h). If
435 IS_STMT is true, the object printed is considered to be a statement
436 and it is terminated by ';' if appropriate. */
439 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
447 if (node
== NULL_TREE
)
450 is_expr
= EXPR_P (node
) || GIMPLE_STMT_P (node
);
452 /* We use has_stmt_ann because CALL_EXPR can be both an expression
453 and a statement, and we have no guarantee that it will have a
454 stmt_ann when it is used as an RHS expression. stmt_ann will assert
455 if you call it on something with a non-stmt annotation attached. */
456 if (TREE_CODE (node
) != ERROR_MARK
457 && is_gimple_stmt (node
)
458 && (flags
& (TDF_VOPS
|TDF_MEMSYMS
))
459 && has_stmt_ann (node
)
460 && TREE_CODE (node
) != PHI_NODE
)
461 dump_vops (buffer
, node
, spc
, flags
);
463 if (is_stmt
&& (flags
& TDF_STMTADDR
))
464 pp_printf (buffer
, "<&%p> ", (void *)node
);
466 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
468 expanded_location xloc
= expand_location (EXPR_LOCATION (node
));
469 pp_character (buffer
, '[');
472 pp_string (buffer
, xloc
.file
);
473 pp_string (buffer
, " : ");
475 pp_decimal_int (buffer
, xloc
.line
);
476 pp_string (buffer
, "] ");
479 switch (TREE_CODE (node
))
482 pp_string (buffer
, "<<< error >>>");
485 case IDENTIFIER_NODE
:
486 pp_tree_identifier (buffer
, node
);
490 while (node
&& node
!= error_mark_node
)
492 if (TREE_PURPOSE (node
))
494 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
497 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
498 node
= TREE_CHAIN (node
);
499 if (node
&& TREE_CODE (node
) == TREE_LIST
)
501 pp_character (buffer
, ',');
508 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
513 if (TREE_VEC_LENGTH (node
) > 0)
515 size_t len
= TREE_VEC_LENGTH (node
);
516 for (i
= 0; i
< len
- 1; i
++)
518 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
520 pp_character (buffer
, ',');
523 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
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
),
575 pp_string (buffer
, "<unnamed type>");
582 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
584 if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
586 tree fnode
= TREE_TYPE (node
);
588 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
590 pp_character (buffer
, '(');
591 pp_string (buffer
, str
);
592 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
593 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
595 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
597 pp_character (buffer
, ')');
598 dump_function_declaration (buffer
, fnode
, spc
, flags
);
602 unsigned int quals
= TYPE_QUALS (node
);
604 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
606 pp_string (buffer
, str
);
608 if (quals
& TYPE_QUAL_CONST
)
609 pp_string (buffer
, " const");
610 else if (quals
& TYPE_QUAL_VOLATILE
)
611 pp_string (buffer
, "volatile");
612 else if (quals
& TYPE_QUAL_RESTRICT
)
613 pp_string (buffer
, " restrict");
615 if (TYPE_REF_CAN_ALIAS_ALL (node
))
616 pp_string (buffer
, " {ref-all}");
625 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)), flags
);
626 pp_string (buffer
, "::");
631 const char *sep
= "";
634 pp_string (buffer
, "MEM[");
636 tmp
= TMR_SYMBOL (node
);
639 pp_string (buffer
, sep
);
641 pp_string (buffer
, "symbol: ");
642 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
644 tmp
= TMR_BASE (node
);
647 pp_string (buffer
, sep
);
649 pp_string (buffer
, "base: ");
650 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
652 tmp
= TMR_INDEX (node
);
655 pp_string (buffer
, sep
);
657 pp_string (buffer
, "index: ");
658 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
660 tmp
= TMR_STEP (node
);
663 pp_string (buffer
, sep
);
665 pp_string (buffer
, "step: ");
666 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
668 tmp
= TMR_OFFSET (node
);
671 pp_string (buffer
, sep
);
673 pp_string (buffer
, "offset: ");
674 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
676 pp_string (buffer
, "]");
677 if (flags
& TDF_DETAILS
)
679 pp_string (buffer
, "{");
680 dump_generic_node (buffer
, TMR_ORIGINAL (node
), spc
, flags
,
682 pp_string (buffer
, "}");
691 /* Print the innermost component type. */
692 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
693 tmp
= TREE_TYPE (tmp
))
695 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
697 /* Print the dimensions. */
698 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
699 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
705 case QUAL_UNION_TYPE
:
706 /* Print the name of the structure. */
707 if (TREE_CODE (node
) == RECORD_TYPE
)
708 pp_string (buffer
, "struct ");
709 else if (TREE_CODE (node
) == UNION_TYPE
)
710 pp_string (buffer
, "union ");
712 if (TYPE_NAME (node
))
713 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
715 print_struct_decl (buffer
, node
, spc
, flags
);
723 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
725 /* In the case of a pointer, one may want to divide by the
726 size of the pointed-to type. Unfortunately, this not
727 straightforward. The C front-end maps expressions
732 in such a way that the two INTEGER_CST nodes for "5" have
733 different values but identical types. In the latter
734 case, the 5 is multiplied by sizeof (int) in c-common.c
735 (pointer_int_sum) to convert it to a byte address, and
736 yet the type of the node is left unchanged. Argh. What
737 is consistent though is that the number value corresponds
738 to bytes (UNITS) offset.
740 NB: Neither of the following divisors can be trivially
741 used to recover the original literal:
743 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
744 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
745 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
746 pp_string (buffer
, "B"); /* pseudo-unit */
748 else if (! host_integerp (node
, 0))
752 if (tree_int_cst_sgn (val
) < 0)
754 pp_character (buffer
, '-');
755 val
= build_int_cst_wide (NULL_TREE
,
756 -TREE_INT_CST_LOW (val
),
757 ~TREE_INT_CST_HIGH (val
)
758 + !TREE_INT_CST_LOW (val
));
760 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
763 sprintf (pp_buffer (buffer
)->digit_buffer
, HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
764 TREE_INT_CST_HIGH (val
),
765 TREE_INT_CST_LOW (val
));
766 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
770 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
774 /* Code copied from print_node. */
777 if (TREE_OVERFLOW (node
))
778 pp_string (buffer
, " overflow");
780 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
781 d
= TREE_REAL_CST (node
);
782 if (REAL_VALUE_ISINF (d
))
783 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
784 else if (REAL_VALUE_ISNAN (d
))
785 pp_string (buffer
, " Nan");
789 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
790 pp_string (buffer
, string
);
795 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
796 pp_string (buffer
, "0x");
797 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
798 output_formatted_integer (buffer
, "%02x", *p
++);
805 pp_string (buffer
, "__complex__ (");
806 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
807 pp_string (buffer
, ", ");
808 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
809 pp_string (buffer
, ")");
813 pp_string (buffer
, "\"");
814 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
815 pp_string (buffer
, "\"");
821 pp_string (buffer
, "{ ");
822 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
824 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
, false);
825 if (TREE_CHAIN (elt
))
826 pp_string (buffer
, ", ");
828 pp_string (buffer
, " }");
837 dump_decl_name (buffer
, node
, flags
);
841 if (DECL_NAME (node
))
842 dump_decl_name (buffer
, node
, flags
);
843 else if (LABEL_DECL_UID (node
) != -1)
844 pp_printf (buffer
, "<L" HOST_WIDE_INT_PRINT_DEC
">",
845 LABEL_DECL_UID (node
));
847 pp_printf (buffer
, "<D%u>", DECL_UID (node
));
851 if (DECL_IS_BUILTIN (node
))
853 /* Don't print the declaration of built-in types. */
856 if (DECL_NAME (node
))
857 dump_decl_name (buffer
, node
, flags
);
860 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
861 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
862 && TYPE_METHODS (TREE_TYPE (node
)))
864 /* The type is a c++ class: all structures have at least
866 pp_string (buffer
, "class ");
867 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
872 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
873 ? "union" : "struct "));
874 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
879 case SYMBOL_MEMORY_TAG
:
880 case NAME_MEMORY_TAG
:
881 case STRUCT_FIELD_TAG
:
886 case MEMORY_PARTITION_TAG
:
887 dump_decl_name (buffer
, node
, flags
);
891 pp_string (buffer
, "<retval>");
895 op0
= TREE_OPERAND (node
, 0);
897 if (TREE_CODE (op0
) == INDIRECT_REF
)
899 op0
= TREE_OPERAND (op0
, 0);
902 if (op_prio (op0
) < op_prio (node
))
903 pp_character (buffer
, '(');
904 dump_generic_node (buffer
, op0
, spc
, flags
, false);
905 if (op_prio (op0
) < op_prio (node
))
906 pp_character (buffer
, ')');
907 pp_string (buffer
, str
);
908 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
910 if (TREE_CODE (op0
) != VALUE_HANDLE
)
912 op0
= component_ref_field_offset (node
);
913 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
915 pp_string (buffer
, "{off: ");
916 dump_generic_node (buffer
, op0
, spc
, flags
, false);
917 pp_character (buffer
, '}');
923 pp_string (buffer
, "BIT_FIELD_REF <");
924 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
925 pp_string (buffer
, ", ");
926 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
927 pp_string (buffer
, ", ");
928 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
929 pp_string (buffer
, ">");
933 case ARRAY_RANGE_REF
:
934 op0
= TREE_OPERAND (node
, 0);
935 if (op_prio (op0
) < op_prio (node
))
936 pp_character (buffer
, '(');
937 dump_generic_node (buffer
, op0
, spc
, flags
, false);
938 if (op_prio (op0
) < op_prio (node
))
939 pp_character (buffer
, ')');
940 pp_character (buffer
, '[');
941 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
942 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
943 pp_string (buffer
, " ...");
944 pp_character (buffer
, ']');
946 op0
= array_ref_low_bound (node
);
947 op1
= array_ref_element_size (node
);
949 if (!integer_zerop (op0
)
950 || (TYPE_SIZE_UNIT (TREE_TYPE (node
))
951 && !operand_equal_p (op1
, TYPE_SIZE_UNIT (TREE_TYPE (node
)), 0)))
953 pp_string (buffer
, "{lb: ");
954 dump_generic_node (buffer
, op0
, spc
, flags
, false);
955 pp_string (buffer
, " sz: ");
956 dump_generic_node (buffer
, op1
, spc
, flags
, false);
957 pp_character (buffer
, '}');
963 unsigned HOST_WIDE_INT ix
;
965 bool is_struct_init
= FALSE
;
966 pp_character (buffer
, '{');
967 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
968 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
969 is_struct_init
= TRUE
;
970 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
972 if (field
&& is_struct_init
)
974 pp_character (buffer
, '.');
975 dump_generic_node (buffer
, field
, spc
, flags
, false);
976 pp_string (buffer
, "=");
978 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
979 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
980 val
= TREE_OPERAND (val
, 0);
981 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
982 dump_decl_name (buffer
, val
, flags
);
984 dump_generic_node (buffer
, val
, spc
, flags
, false);
985 if (ix
!= VEC_length (constructor_elt
, CONSTRUCTOR_ELTS (node
)) - 1)
987 pp_character (buffer
, ',');
991 pp_character (buffer
, '}');
998 if (flags
& TDF_SLIM
)
1000 pp_string (buffer
, "<COMPOUND_EXPR>");
1004 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1005 spc
, flags
, !(flags
& TDF_SLIM
));
1006 if (flags
& TDF_SLIM
)
1007 newline_and_indent (buffer
, spc
);
1010 pp_character (buffer
, ',');
1014 for (tp
= &TREE_OPERAND (node
, 1);
1015 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1016 tp
= &TREE_OPERAND (*tp
, 1))
1018 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1019 spc
, flags
, !(flags
& TDF_SLIM
));
1020 if (flags
& TDF_SLIM
)
1021 newline_and_indent (buffer
, spc
);
1024 pp_character (buffer
, ',');
1029 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1033 case STATEMENT_LIST
:
1035 tree_stmt_iterator si
;
1038 if (flags
& TDF_SLIM
)
1040 pp_string (buffer
, "<STATEMENT_LIST>");
1044 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1047 newline_and_indent (buffer
, spc
);
1050 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1056 case GIMPLE_MODIFY_STMT
:
1058 dump_generic_node (buffer
, GENERIC_TREE_OPERAND (node
, 0), spc
, flags
,
1061 pp_character (buffer
, '=');
1063 dump_generic_node (buffer
, GENERIC_TREE_OPERAND (node
, 1), spc
, flags
,
1068 pp_string (buffer
, "TARGET_EXPR <");
1069 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1070 pp_character (buffer
, ',');
1072 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1073 pp_character (buffer
, '>');
1077 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1082 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1084 pp_string (buffer
, "if (");
1085 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1086 pp_character (buffer
, ')');
1087 /* The lowered cond_exprs should always be printed in full. */
1088 if (COND_EXPR_THEN (node
)
1089 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1090 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1091 && COND_EXPR_ELSE (node
)
1092 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1093 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1096 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1098 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1100 pp_string (buffer
, " else ");
1101 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1105 else if (!(flags
& TDF_SLIM
))
1107 /* Output COND_EXPR_THEN. */
1108 if (COND_EXPR_THEN (node
))
1110 newline_and_indent (buffer
, spc
+2);
1111 pp_character (buffer
, '{');
1112 newline_and_indent (buffer
, spc
+4);
1113 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1115 newline_and_indent (buffer
, spc
+2);
1116 pp_character (buffer
, '}');
1119 /* Output COND_EXPR_ELSE. */
1120 if (COND_EXPR_ELSE (node
)
1121 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1123 newline_and_indent (buffer
, spc
);
1124 pp_string (buffer
, "else");
1125 newline_and_indent (buffer
, spc
+2);
1126 pp_character (buffer
, '{');
1127 newline_and_indent (buffer
, spc
+4);
1128 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1130 newline_and_indent (buffer
, spc
+2);
1131 pp_character (buffer
, '}');
1138 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1140 pp_character (buffer
, '?');
1142 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1144 pp_character (buffer
, ':');
1146 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1151 pp_character (buffer
, '{');
1152 if (!(flags
& TDF_SLIM
))
1154 if (BIND_EXPR_VARS (node
))
1156 pp_newline (buffer
);
1158 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= TREE_CHAIN (op0
))
1160 print_declaration (buffer
, op0
, spc
+2, flags
);
1161 pp_newline (buffer
);
1165 newline_and_indent (buffer
, spc
+2);
1166 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1167 newline_and_indent (buffer
, spc
);
1168 pp_character (buffer
, '}');
1174 print_call_name (buffer
, node
);
1176 /* Print parameters. */
1178 pp_character (buffer
, '(');
1179 op1
= TREE_OPERAND (node
, 1);
1181 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1182 pp_character (buffer
, ')');
1184 op1
= TREE_OPERAND (node
, 2);
1187 pp_string (buffer
, " [static-chain: ");
1188 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1189 pp_character (buffer
, ']');
1192 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1193 pp_string (buffer
, " [return slot optimization]");
1194 if (CALL_EXPR_TAILCALL (node
))
1195 pp_string (buffer
, " [tail call]");
1198 case WITH_CLEANUP_EXPR
:
1202 case CLEANUP_POINT_EXPR
:
1203 pp_string (buffer
, "<<cleanup_point ");
1204 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1205 pp_string (buffer
, ">>");
1208 case PLACEHOLDER_EXPR
:
1209 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1210 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1211 pp_character (buffer
, '>');
1214 /* Binary arithmetic and logic expressions. */
1215 case WIDEN_SUM_EXPR
:
1216 case WIDEN_MULT_EXPR
:
1220 case TRUNC_DIV_EXPR
:
1222 case FLOOR_DIV_EXPR
:
1223 case ROUND_DIV_EXPR
:
1224 case TRUNC_MOD_EXPR
:
1226 case FLOOR_MOD_EXPR
:
1227 case ROUND_MOD_EXPR
:
1229 case EXACT_DIV_EXPR
:
1234 case VEC_LSHIFT_EXPR
:
1235 case VEC_RSHIFT_EXPR
:
1239 case TRUTH_ANDIF_EXPR
:
1240 case TRUTH_ORIF_EXPR
:
1241 case TRUTH_AND_EXPR
:
1243 case TRUTH_XOR_EXPR
:
1257 case UNORDERED_EXPR
:
1259 const char *op
= op_symbol (node
);
1260 op0
= TREE_OPERAND (node
, 0);
1261 op1
= TREE_OPERAND (node
, 1);
1263 /* When the operands are expressions with less priority,
1264 keep semantics of the tree representation. */
1265 if (op_prio (op0
) < op_prio (node
))
1267 pp_character (buffer
, '(');
1268 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1269 pp_character (buffer
, ')');
1272 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1275 pp_string (buffer
, op
);
1278 /* When the operands are expressions with less priority,
1279 keep semantics of the tree representation. */
1280 if (op_prio (op1
) < op_prio (node
))
1282 pp_character (buffer
, '(');
1283 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1284 pp_character (buffer
, ')');
1287 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1291 /* Unary arithmetic and logic expressions. */
1294 case TRUTH_NOT_EXPR
:
1296 case PREDECREMENT_EXPR
:
1297 case PREINCREMENT_EXPR
:
1298 case ALIGN_INDIRECT_REF
:
1299 case MISALIGNED_INDIRECT_REF
:
1301 if (TREE_CODE (node
) == ADDR_EXPR
1302 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1303 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1304 ; /* Do not output '&' for strings and function pointers. */
1306 pp_string (buffer
, op_symbol (node
));
1308 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1310 pp_character (buffer
, '(');
1311 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1312 pp_character (buffer
, ')');
1315 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1317 if (TREE_CODE (node
) == MISALIGNED_INDIRECT_REF
)
1319 pp_string (buffer
, "{misalignment: ");
1320 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1321 pp_character (buffer
, '}');
1325 case POSTDECREMENT_EXPR
:
1326 case POSTINCREMENT_EXPR
:
1327 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1329 pp_character (buffer
, '(');
1330 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1331 pp_character (buffer
, ')');
1334 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1335 pp_string (buffer
, op_symbol (node
));
1339 pp_string (buffer
, "MIN_EXPR <");
1340 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1341 pp_string (buffer
, ", ");
1342 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1343 pp_character (buffer
, '>');
1347 pp_string (buffer
, "MAX_EXPR <");
1348 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1349 pp_string (buffer
, ", ");
1350 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1351 pp_character (buffer
, '>');
1355 pp_string (buffer
, "ABS_EXPR <");
1356 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1357 pp_character (buffer
, '>');
1364 case FIX_TRUNC_EXPR
:
1368 type
= TREE_TYPE (node
);
1369 op0
= TREE_OPERAND (node
, 0);
1370 if (type
!= TREE_TYPE (op0
))
1372 pp_character (buffer
, '(');
1373 dump_generic_node (buffer
, type
, spc
, flags
, false);
1374 pp_string (buffer
, ") ");
1376 if (op_prio (op0
) < op_prio (node
))
1377 pp_character (buffer
, '(');
1378 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1379 if (op_prio (op0
) < op_prio (node
))
1380 pp_character (buffer
, ')');
1383 case VIEW_CONVERT_EXPR
:
1384 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1385 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1386 pp_string (buffer
, ">(");
1387 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1388 pp_character (buffer
, ')');
1391 case NON_LVALUE_EXPR
:
1392 pp_string (buffer
, "NON_LVALUE_EXPR <");
1393 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1394 pp_character (buffer
, '>');
1398 pp_string (buffer
, "SAVE_EXPR <");
1399 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1400 pp_character (buffer
, '>');
1404 pp_string (buffer
, "COMPLEX_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_string (buffer
, ">");
1412 pp_string (buffer
, "CONJ_EXPR <");
1413 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1414 pp_string (buffer
, ">");
1418 pp_string (buffer
, "REALPART_EXPR <");
1419 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1420 pp_string (buffer
, ">");
1424 pp_string (buffer
, "IMAGPART_EXPR <");
1425 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1426 pp_string (buffer
, ">");
1430 pp_string (buffer
, "VA_ARG_EXPR <");
1431 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1432 pp_string (buffer
, ">");
1435 case TRY_FINALLY_EXPR
:
1436 case TRY_CATCH_EXPR
:
1437 pp_string (buffer
, "try");
1438 newline_and_indent (buffer
, spc
+2);
1439 pp_string (buffer
, "{");
1440 newline_and_indent (buffer
, spc
+4);
1441 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1442 newline_and_indent (buffer
, spc
+2);
1443 pp_string (buffer
, "}");
1444 newline_and_indent (buffer
, spc
);
1446 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1447 newline_and_indent (buffer
, spc
+2);
1448 pp_string (buffer
, "{");
1449 newline_and_indent (buffer
, spc
+4);
1450 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1451 newline_and_indent (buffer
, spc
+2);
1452 pp_string (buffer
, "}");
1457 pp_string (buffer
, "catch (");
1458 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1459 pp_string (buffer
, ")");
1460 newline_and_indent (buffer
, spc
+2);
1461 pp_string (buffer
, "{");
1462 newline_and_indent (buffer
, spc
+4);
1463 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1464 newline_and_indent (buffer
, spc
+2);
1465 pp_string (buffer
, "}");
1469 case EH_FILTER_EXPR
:
1470 pp_string (buffer
, "<<<eh_filter (");
1471 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1472 pp_string (buffer
, ")>>>");
1473 newline_and_indent (buffer
, spc
+2);
1474 pp_string (buffer
, "{");
1475 newline_and_indent (buffer
, spc
+4);
1476 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1477 newline_and_indent (buffer
, spc
+2);
1478 pp_string (buffer
, "}");
1483 op0
= TREE_OPERAND (node
, 0);
1484 /* If this is for break or continue, don't bother printing it. */
1485 if (DECL_NAME (op0
))
1487 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1488 if (strcmp (name
, "break") == 0
1489 || strcmp (name
, "continue") == 0)
1492 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1493 pp_character (buffer
, ':');
1494 if (DECL_NONLOCAL (op0
))
1495 pp_string (buffer
, " [non-local]");
1499 pp_string (buffer
, "<<<exception object>>>");
1503 pp_string (buffer
, "<<<filter object>>>");
1507 pp_string (buffer
, "while (1)");
1508 if (!(flags
& TDF_SLIM
))
1510 newline_and_indent (buffer
, spc
+2);
1511 pp_character (buffer
, '{');
1512 newline_and_indent (buffer
, spc
+4);
1513 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1514 newline_and_indent (buffer
, spc
+2);
1515 pp_character (buffer
, '}');
1521 pp_string (buffer
, "return");
1522 op0
= TREE_OPERAND (node
, 0);
1526 if (TREE_CODE (op0
) == MODIFY_EXPR
1527 || TREE_CODE (op0
) == GIMPLE_MODIFY_STMT
)
1528 dump_generic_node (buffer
, GENERIC_TREE_OPERAND (op0
, 1),
1531 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1536 pp_string (buffer
, "if (");
1537 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1538 pp_string (buffer
, ") break");
1542 pp_string (buffer
, "switch (");
1543 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1544 pp_character (buffer
, ')');
1545 if (!(flags
& TDF_SLIM
))
1547 newline_and_indent (buffer
, spc
+2);
1548 pp_character (buffer
, '{');
1549 if (SWITCH_BODY (node
))
1551 newline_and_indent (buffer
, spc
+4);
1552 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1557 tree vec
= SWITCH_LABELS (node
);
1558 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1559 for (i
= 0; i
< n
; ++i
)
1561 tree elt
= TREE_VEC_ELT (vec
, i
);
1562 newline_and_indent (buffer
, spc
+4);
1565 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1566 pp_string (buffer
, " goto ");
1567 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1569 pp_semicolon (buffer
);
1572 pp_string (buffer
, "case ???: goto ???;");
1575 newline_and_indent (buffer
, spc
+2);
1576 pp_character (buffer
, '}');
1582 op0
= GOTO_DESTINATION (node
);
1583 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1585 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1586 if (strcmp (name
, "break") == 0
1587 || strcmp (name
, "continue") == 0)
1589 pp_string (buffer
, name
);
1593 pp_string (buffer
, "goto ");
1594 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1598 pp_string (buffer
, "resx ");
1599 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1603 pp_string (buffer
, "__asm__");
1604 if (ASM_VOLATILE_P (node
))
1605 pp_string (buffer
, " __volatile__");
1606 pp_character (buffer
, '(');
1607 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1608 pp_character (buffer
, ':');
1609 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1610 pp_character (buffer
, ':');
1611 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1612 if (ASM_CLOBBERS (node
))
1614 pp_character (buffer
, ':');
1615 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1617 pp_string (buffer
, ")");
1620 case CASE_LABEL_EXPR
:
1621 if (CASE_LOW (node
) && CASE_HIGH (node
))
1623 pp_string (buffer
, "case ");
1624 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1625 pp_string (buffer
, " ... ");
1626 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1628 else if (CASE_LOW (node
))
1630 pp_string (buffer
, "case ");
1631 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1634 pp_string (buffer
, "default ");
1635 pp_character (buffer
, ':');
1639 pp_string (buffer
, "OBJ_TYPE_REF(");
1640 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1641 pp_character (buffer
, ';');
1642 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1643 pp_character (buffer
, '-');
1644 pp_character (buffer
, '>');
1645 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
1646 pp_character (buffer
, ')');
1653 dump_generic_node (buffer
, PHI_RESULT (node
), spc
, flags
, false);
1654 pp_string (buffer
, " = PHI <");
1655 for (i
= 0; i
< PHI_NUM_ARGS (node
); i
++)
1657 dump_generic_node (buffer
, PHI_ARG_DEF (node
, i
), spc
, flags
, false);
1658 pp_string (buffer
, "(");
1659 pp_decimal_int (buffer
, PHI_ARG_EDGE (node
, i
)->src
->index
);
1660 pp_string (buffer
, ")");
1661 if (i
< PHI_NUM_ARGS (node
) - 1)
1662 pp_string (buffer
, ", ");
1664 pp_string (buffer
, ">");
1666 if (stmt_references_memory_p (node
) && (flags
& TDF_MEMSYMS
))
1667 dump_symbols (buffer
, STORED_SYMS (node
), flags
);
1672 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
1673 pp_string (buffer
, "_");
1674 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1675 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
1676 pp_string (buffer
, "(ab)");
1677 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
1678 pp_string (buffer
, "(D)");
1681 case WITH_SIZE_EXPR
:
1682 pp_string (buffer
, "WITH_SIZE_EXPR <");
1683 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1684 pp_string (buffer
, ", ");
1685 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1686 pp_string (buffer
, ">");
1690 pp_printf (buffer
, "VH.%d", VALUE_HANDLE_ID (node
));
1694 pp_string (buffer
, "ASSERT_EXPR <");
1695 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
1696 pp_string (buffer
, ", ");
1697 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
1698 pp_string (buffer
, ">");
1702 pp_string (buffer
, "scev_known");
1705 case SCEV_NOT_KNOWN
:
1706 pp_string (buffer
, "scev_not_known");
1709 case POLYNOMIAL_CHREC
:
1710 pp_string (buffer
, "{");
1711 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
1712 pp_string (buffer
, ", +, ");
1713 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
1714 pp_string (buffer
, "}_");
1715 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
1719 case REALIGN_LOAD_EXPR
:
1720 pp_string (buffer
, "REALIGN_LOAD <");
1721 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1722 pp_string (buffer
, ", ");
1723 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1724 pp_string (buffer
, ", ");
1725 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1726 pp_string (buffer
, ">");
1730 pp_string (buffer
, " VEC_COND_EXPR < ");
1731 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1732 pp_string (buffer
, " , ");
1733 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1734 pp_string (buffer
, " , ");
1735 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1736 pp_string (buffer
, " > ");
1740 pp_string (buffer
, " DOT_PROD_EXPR < ");
1741 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1742 pp_string (buffer
, ", ");
1743 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1744 pp_string (buffer
, ", ");
1745 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1746 pp_string (buffer
, " > ");
1750 pp_string (buffer
, "#pragma omp parallel");
1751 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
1752 if (OMP_PARALLEL_FN (node
))
1754 pp_string (buffer
, " [child fn: ");
1755 dump_generic_node (buffer
, OMP_PARALLEL_FN (node
), spc
, flags
, false);
1757 pp_string (buffer
, " (");
1759 if (OMP_PARALLEL_DATA_ARG (node
))
1760 dump_generic_node (buffer
, OMP_PARALLEL_DATA_ARG (node
), spc
, flags
,
1763 pp_string (buffer
, "???");
1765 pp_string (buffer
, ")]");
1769 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
1771 newline_and_indent (buffer
, spc
+ 2);
1772 pp_character (buffer
, '{');
1773 newline_and_indent (buffer
, spc
+ 4);
1774 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
1775 newline_and_indent (buffer
, spc
+ 2);
1776 pp_character (buffer
, '}');
1782 pp_string (buffer
, "#pragma omp for");
1783 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
1785 if (!(flags
& TDF_SLIM
))
1787 if (OMP_FOR_PRE_BODY (node
))
1789 newline_and_indent (buffer
, spc
+ 2);
1790 pp_character (buffer
, '{');
1792 newline_and_indent (buffer
, spc
);
1793 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
1796 newline_and_indent (buffer
, spc
);
1797 pp_string (buffer
, "for (");
1798 dump_generic_node (buffer
, OMP_FOR_INIT (node
), spc
, flags
, false);
1799 pp_string (buffer
, "; ");
1800 dump_generic_node (buffer
, OMP_FOR_COND (node
), spc
, flags
, false);
1801 pp_string (buffer
, "; ");
1802 dump_generic_node (buffer
, OMP_FOR_INCR (node
), spc
, flags
, false);
1803 pp_string (buffer
, ")");
1804 if (OMP_FOR_BODY (node
))
1806 newline_and_indent (buffer
, spc
+ 2);
1807 pp_character (buffer
, '{');
1808 newline_and_indent (buffer
, spc
+ 4);
1809 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
1811 newline_and_indent (buffer
, spc
+ 2);
1812 pp_character (buffer
, '}');
1814 if (OMP_FOR_PRE_BODY (node
))
1817 newline_and_indent (buffer
, spc
+ 2);
1818 pp_character (buffer
, '}');
1825 pp_string (buffer
, "#pragma omp sections");
1826 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
1830 pp_string (buffer
, "#pragma omp section");
1834 pp_string (buffer
, "#pragma omp master");
1838 pp_string (buffer
, "#pragma omp ordered");
1842 pp_string (buffer
, "#pragma omp critical");
1843 if (OMP_CRITICAL_NAME (node
))
1846 pp_character (buffer
, '(');
1847 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
1849 pp_character (buffer
, ')');
1854 pp_string (buffer
, "#pragma omp atomic");
1855 newline_and_indent (buffer
, spc
+ 2);
1856 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1858 pp_character (buffer
, '=');
1860 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1864 pp_string (buffer
, "#pragma omp single");
1865 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
1869 pp_string (buffer
, "OMP_RETURN");
1870 if (OMP_RETURN_NOWAIT (node
))
1871 pp_string (buffer
, " [nowait]");
1876 pp_string (buffer
, "OMP_CONTINUE");
1881 dump_omp_clause (buffer
, node
, spc
, flags
);
1885 case REDUC_MAX_EXPR
:
1886 pp_string (buffer
, " REDUC_MAX_EXPR < ");
1887 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1888 pp_string (buffer
, " > ");
1891 case REDUC_MIN_EXPR
:
1892 pp_string (buffer
, " REDUC_MIN_EXPR < ");
1893 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1894 pp_string (buffer
, " > ");
1897 case REDUC_PLUS_EXPR
:
1898 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
1899 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1900 pp_string (buffer
, " > ");
1903 case VEC_WIDEN_MULT_HI_EXPR
:
1904 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
1905 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1906 pp_string (buffer
, ", ");
1907 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1908 pp_string (buffer
, " > ");
1911 case VEC_WIDEN_MULT_LO_EXPR
:
1912 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
1913 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1914 pp_string (buffer
, ", ");
1915 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1916 pp_string (buffer
, " > ");
1919 case VEC_UNPACK_HI_EXPR
:
1920 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
1921 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1922 pp_string (buffer
, " > ");
1925 case VEC_UNPACK_LO_EXPR
:
1926 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
1927 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1928 pp_string (buffer
, " > ");
1931 case VEC_PACK_MOD_EXPR
:
1932 pp_string (buffer
, " VEC_PACK_MOD_EXPR < ");
1933 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1934 pp_string (buffer
, ", ");
1935 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1936 pp_string (buffer
, " > ");
1939 case VEC_PACK_SAT_EXPR
:
1940 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
1941 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1942 pp_string (buffer
, ", ");
1943 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1944 pp_string (buffer
, " > ");
1950 pp_string (buffer
, "BLOCK");
1952 if (BLOCK_ABSTRACT (node
))
1953 pp_string (buffer
, " [abstract]");
1955 if (TREE_ASM_WRITTEN (node
))
1956 pp_string (buffer
, " [written]");
1958 newline_and_indent (buffer
, spc
+ 2);
1960 if (BLOCK_SUPERCONTEXT (node
))
1962 pp_string (buffer
, "SUPERCONTEXT: ");
1963 if (TREE_CODE (BLOCK_SUPERCONTEXT (node
)) == BLOCK
)
1964 pp_printf (buffer
, "BLOCK %p",
1965 (void *)BLOCK_SUPERCONTEXT (node
));
1967 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (node
), 0, flags
,
1969 newline_and_indent (buffer
, spc
+ 2);
1972 if (BLOCK_SUBBLOCKS (node
))
1974 pp_string (buffer
, "SUBBLOCKS: ");
1975 for (t
= BLOCK_SUBBLOCKS (node
); t
; t
= BLOCK_CHAIN (t
))
1976 pp_printf (buffer
, "%p ", (void *)t
);
1977 newline_and_indent (buffer
, spc
+ 2);
1980 if (BLOCK_VARS (node
))
1982 pp_string (buffer
, "VARS: ");
1983 for (t
= BLOCK_VARS (node
); t
; t
= TREE_CHAIN (t
))
1985 dump_generic_node (buffer
, t
, 0, flags
, false);
1986 pp_string (buffer
, " ");
1988 newline_and_indent (buffer
, spc
+ 2);
1991 if (BLOCK_ABSTRACT_ORIGIN (node
))
1993 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
1994 if (TREE_CODE (BLOCK_ABSTRACT_ORIGIN (node
)) == BLOCK
)
1995 pp_printf (buffer
, "BLOCK %p",
1996 (void *)BLOCK_ABSTRACT_ORIGIN (node
));
1998 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (node
), 0, flags
,
2000 newline_and_indent (buffer
, spc
+ 2);
2005 case VEC_EXTRACT_EVEN_EXPR
:
2006 pp_string (buffer
, " VEC_EXTRACT_EVEN_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_EXTRACT_ODD_EXPR
:
2014 pp_string (buffer
, " VEC_EXTRACT_ODD_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_INTERLEAVE_HIGH_EXPR
:
2022 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_EXPR < ");
2023 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2024 pp_string (buffer
, ", ");
2025 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2026 pp_string (buffer
, " > ");
2029 case VEC_INTERLEAVE_LOW_EXPR
:
2030 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2031 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2032 pp_string (buffer
, ", ");
2033 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2034 pp_string (buffer
, " > ");
2041 if (is_stmt
&& is_expr
)
2042 pp_semicolon (buffer
);
2043 pp_write_text_to_stream (buffer
);
2048 /* Print the declaration of a variable. */
2051 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2055 if (TREE_CODE (t
) == TYPE_DECL
)
2056 pp_string (buffer
, "typedef ");
2058 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2059 pp_string (buffer
, "register ");
2061 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2062 pp_string (buffer
, "extern ");
2063 else if (TREE_STATIC (t
))
2064 pp_string (buffer
, "static ");
2066 /* Print the type and name. */
2067 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2071 /* Print array's type. */
2072 tmp
= TREE_TYPE (t
);
2073 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2074 tmp
= TREE_TYPE (tmp
);
2075 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2077 /* Print variable's name. */
2079 dump_generic_node (buffer
, t
, spc
, flags
, false);
2081 /* Print the dimensions. */
2082 tmp
= TREE_TYPE (t
);
2083 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2085 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2086 tmp
= TREE_TYPE (tmp
);
2089 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2091 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2093 dump_decl_name (buffer
, t
, flags
);
2094 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2098 /* Print type declaration. */
2099 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2101 /* Print variable's name. */
2103 dump_generic_node (buffer
, t
, spc
, flags
, false);
2106 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2108 pp_string (buffer
, " __asm__ ");
2109 pp_character (buffer
, '(');
2110 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2111 pp_character (buffer
, ')');
2114 /* The initial value of a function serves to determine wether the function
2115 is declared or defined. So the following does not apply to function
2117 if (TREE_CODE (t
) != FUNCTION_DECL
)
2119 /* Print the initial value. */
2120 if (DECL_INITIAL (t
))
2123 pp_character (buffer
, '=');
2125 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2129 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2131 pp_string (buffer
, " [value-expr: ");
2132 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2133 pp_character (buffer
, ']');
2136 pp_character (buffer
, ';');
2140 /* Prints a structure: name, fields, and methods.
2141 FIXME: Still incomplete. */
2144 print_struct_decl (pretty_printer
*buffer
, tree node
, int spc
, int flags
)
2146 /* Print the name of the structure. */
2147 if (TYPE_NAME (node
))
2150 if (TREE_CODE (node
) == RECORD_TYPE
)
2151 pp_string (buffer
, "struct ");
2152 else if ((TREE_CODE (node
) == UNION_TYPE
2153 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2154 pp_string (buffer
, "union ");
2156 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2159 /* Print the contents of the structure. */
2160 pp_newline (buffer
);
2162 pp_character (buffer
, '{');
2163 pp_newline (buffer
);
2165 /* Print the fields of the structure. */
2168 tmp
= TYPE_FIELDS (node
);
2171 /* Avoid to print recursively the structure. */
2172 /* FIXME : Not implemented correctly...,
2173 what about the case when we have a cycle in the contain graph? ...
2174 Maybe this could be solved by looking at the scope in which the
2175 structure was declared. */
2176 if (TREE_TYPE (tmp
) != node
2177 || (TREE_CODE (TREE_TYPE (tmp
)) == POINTER_TYPE
2178 && TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2180 print_declaration (buffer
, tmp
, spc
+2, flags
);
2181 pp_newline (buffer
);
2183 tmp
= TREE_CHAIN (tmp
);
2187 pp_character (buffer
, '}');
2190 /* Return the priority of the operator OP.
2192 From lowest to highest precedence with either left-to-right (L-R)
2193 or right-to-left (R-L) associativity]:
2196 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2208 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2209 15 [L-R] fn() [] -> .
2211 unary +, - and * have higher precedence than the corresponding binary
2220 switch (TREE_CODE (op
))
2228 case GIMPLE_MODIFY_STMT
:
2236 case TRUTH_ORIF_EXPR
:
2239 case TRUTH_AND_EXPR
:
2240 case TRUTH_ANDIF_EXPR
:
2247 case TRUTH_XOR_EXPR
:
2264 case UNORDERED_EXPR
:
2277 case WIDEN_SUM_EXPR
:
2282 case VEC_WIDEN_MULT_HI_EXPR
:
2283 case VEC_WIDEN_MULT_LO_EXPR
:
2284 case WIDEN_MULT_EXPR
:
2287 case TRUNC_DIV_EXPR
:
2289 case FLOOR_DIV_EXPR
:
2290 case ROUND_DIV_EXPR
:
2292 case EXACT_DIV_EXPR
:
2293 case TRUNC_MOD_EXPR
:
2295 case FLOOR_MOD_EXPR
:
2296 case ROUND_MOD_EXPR
:
2299 case TRUTH_NOT_EXPR
:
2301 case POSTINCREMENT_EXPR
:
2302 case POSTDECREMENT_EXPR
:
2303 case PREINCREMENT_EXPR
:
2304 case PREDECREMENT_EXPR
:
2306 case ALIGN_INDIRECT_REF
:
2307 case MISALIGNED_INDIRECT_REF
:
2313 case FIX_TRUNC_EXPR
:
2319 case ARRAY_RANGE_REF
:
2323 /* Special expressions. */
2329 case REDUC_MAX_EXPR
:
2330 case REDUC_MIN_EXPR
:
2331 case REDUC_PLUS_EXPR
:
2332 case VEC_LSHIFT_EXPR
:
2333 case VEC_RSHIFT_EXPR
:
2334 case VEC_UNPACK_HI_EXPR
:
2335 case VEC_UNPACK_LO_EXPR
:
2336 case VEC_PACK_MOD_EXPR
:
2337 case VEC_PACK_SAT_EXPR
:
2341 case NON_LVALUE_EXPR
:
2342 return op_prio (TREE_OPERAND (op
, 0));
2345 /* Return an arbitrarily high precedence to avoid surrounding single
2346 VAR_DECLs in ()s. */
2352 /* Return the symbol associated with operator OP. */
2355 op_symbol_1 (enum tree_code code
)
2360 case GIMPLE_MODIFY_STMT
:
2364 case TRUTH_ORIF_EXPR
:
2367 case TRUTH_AND_EXPR
:
2368 case TRUTH_ANDIF_EXPR
:
2374 case TRUTH_XOR_EXPR
:
2384 case UNORDERED_EXPR
:
2430 case VEC_LSHIFT_EXPR
:
2433 case VEC_RSHIFT_EXPR
:
2439 case REDUC_PLUS_EXPR
:
2442 case WIDEN_SUM_EXPR
:
2445 case WIDEN_MULT_EXPR
:
2455 case TRUTH_NOT_EXPR
:
2462 case ALIGN_INDIRECT_REF
:
2465 case MISALIGNED_INDIRECT_REF
:
2468 case TRUNC_DIV_EXPR
:
2475 case FLOOR_DIV_EXPR
:
2478 case ROUND_DIV_EXPR
:
2481 case EXACT_DIV_EXPR
:
2484 case TRUNC_MOD_EXPR
:
2490 case FLOOR_MOD_EXPR
:
2493 case ROUND_MOD_EXPR
:
2496 case PREDECREMENT_EXPR
:
2499 case PREINCREMENT_EXPR
:
2502 case POSTDECREMENT_EXPR
:
2505 case POSTINCREMENT_EXPR
:
2515 return "<<< ??? >>>";
2522 return op_symbol_1 (TREE_CODE (op
));
2525 /* Prints the name of a CALL_EXPR. */
2528 print_call_name (pretty_printer
*buffer
, tree node
)
2532 gcc_assert (TREE_CODE (node
) == CALL_EXPR
);
2534 op0
= TREE_OPERAND (node
, 0);
2536 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2537 op0
= TREE_OPERAND (op0
, 0);
2539 switch (TREE_CODE (op0
))
2543 dump_function_name (buffer
, op0
);
2549 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2553 pp_string (buffer
, "(");
2554 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2555 pp_string (buffer
, ") ? ");
2556 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, 0, false);
2557 pp_string (buffer
, " : ");
2558 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, 0, false);
2562 /* The function is a pointer contained in a structure. */
2563 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == INDIRECT_REF
||
2564 TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2565 dump_function_name (buffer
, TREE_OPERAND (op0
, 1));
2567 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2569 We can have several levels of structures and a function
2570 pointer inside. This is not implemented yet... */
2575 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2576 dump_function_name (buffer
, TREE_OPERAND (op0
, 0));
2578 dump_generic_node (buffer
, op0
, 0, 0, false);
2583 dump_generic_node (buffer
, op0
, 0, 0, false);
2591 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2594 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2604 pp_string (buffer
, "\\b");
2608 pp_string (buffer
, "\\f");
2612 pp_string (buffer
, "\\n");
2616 pp_string (buffer
, "\\r");
2620 pp_string (buffer
, "\\t");
2624 pp_string (buffer
, "\\v");
2628 pp_string (buffer
, "\\\\");
2632 pp_string (buffer
, "\\\"");
2636 pp_string (buffer
, "\\'");
2639 /* No need to handle \0; the loop terminates on \0. */
2642 pp_string (buffer
, "\\1");
2646 pp_string (buffer
, "\\2");
2650 pp_string (buffer
, "\\3");
2654 pp_string (buffer
, "\\4");
2658 pp_string (buffer
, "\\5");
2662 pp_string (buffer
, "\\6");
2666 pp_string (buffer
, "\\7");
2670 pp_character (buffer
, str
[0]);
2678 maybe_init_pretty_print (FILE *file
)
2682 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
2683 pp_needs_newline (&buffer
) = true;
2687 buffer
.buffer
->stream
= file
;
2691 newline_and_indent (pretty_printer
*buffer
, int spc
)
2693 pp_newline (buffer
);
2699 dump_vops (pretty_printer
*buffer
, tree stmt
, int spc
, int flags
)
2701 struct voptype_d
*vdefs
;
2702 struct voptype_d
*vuses
;
2705 if (!ssa_operands_active () || !stmt_references_memory_p (stmt
))
2708 /* Even if the statement doesn't have virtual operators yet, it may
2709 contain symbol information (this happens before aliases have been
2711 if ((flags
& TDF_MEMSYMS
)
2712 && VUSE_OPS (stmt
) == NULL
2713 && VDEF_OPS (stmt
) == NULL
)
2715 if (LOADED_SYMS (stmt
))
2717 pp_string (buffer
, "# LOADS: ");
2718 dump_symbols (buffer
, LOADED_SYMS (stmt
), flags
);
2719 newline_and_indent (buffer
, spc
);
2722 if (STORED_SYMS (stmt
))
2724 pp_string (buffer
, "# STORES: ");
2725 dump_symbols (buffer
, STORED_SYMS (stmt
), flags
);
2726 newline_and_indent (buffer
, spc
);
2732 vuses
= VUSE_OPS (stmt
);
2735 pp_string (buffer
, "# VUSE <");
2737 n
= VUSE_NUM (vuses
);
2738 for (i
= 0; i
< n
; i
++)
2740 dump_generic_node (buffer
, VUSE_OP (vuses
, i
), spc
+ 2, flags
, false);
2742 pp_string (buffer
, ", ");
2745 pp_string (buffer
, ">");
2747 if (flags
& TDF_MEMSYMS
)
2748 dump_symbols (buffer
, LOADED_SYMS (stmt
), flags
);
2750 newline_and_indent (buffer
, spc
);
2751 vuses
= vuses
->next
;
2754 vdefs
= VDEF_OPS (stmt
);
2757 pp_string (buffer
, "# ");
2758 dump_generic_node (buffer
, VDEF_RESULT (vdefs
), spc
+ 2, flags
, false);
2759 pp_string (buffer
, " = VDEF <");
2761 n
= VDEF_NUM (vdefs
);
2762 for (i
= 0; i
< n
; i
++)
2764 dump_generic_node (buffer
, VDEF_OP (vdefs
, i
), spc
+ 2, flags
, 0);
2766 pp_string (buffer
, ", ");
2769 pp_string (buffer
, ">");
2771 if ((flags
& TDF_MEMSYMS
) && vdefs
->next
== NULL
)
2772 dump_symbols (buffer
, STORED_SYMS (stmt
), flags
);
2774 newline_and_indent (buffer
, spc
);
2775 vdefs
= vdefs
->next
;
2780 /* Dumps basic block BB to FILE with details described by FLAGS and
2781 indented by INDENT spaces. */
2784 dump_generic_bb (FILE *file
, basic_block bb
, int indent
, int flags
)
2786 maybe_init_pretty_print (file
);
2787 dump_generic_bb_buff (&buffer
, bb
, indent
, flags
);
2791 /* Dumps header of basic block BB to buffer BUFFER indented by INDENT
2792 spaces and details described by flags. */
2795 dump_bb_header (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
2801 if (flags
& TDF_BLOCKS
)
2804 pp_string (buffer
, "# BLOCK ");
2805 pp_decimal_int (buffer
, bb
->index
);
2808 pp_string (buffer
, " freq:");
2809 pp_decimal_int (buffer
, bb
->frequency
);
2813 pp_string (buffer
, " count:");
2814 pp_widest_integer (buffer
, bb
->count
);
2817 if (flags
& TDF_LINENO
)
2819 block_stmt_iterator bsi
;
2821 for (bsi
= bsi_start (bb
); !bsi_end_p (bsi
); bsi_next (&bsi
))
2822 if (get_lineno (bsi_stmt (bsi
)) != -1)
2824 pp_string (buffer
, ", starting at line ");
2825 pp_decimal_int (buffer
, get_lineno (bsi_stmt (bsi
)));
2829 newline_and_indent (buffer
, indent
);
2831 pp_string (buffer
, "# PRED:");
2832 pp_write_text_to_stream (buffer
);
2833 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
2834 if (flags
& TDF_SLIM
)
2836 pp_string (buffer
, " ");
2837 if (e
->src
== ENTRY_BLOCK_PTR
)
2838 pp_string (buffer
, "ENTRY");
2840 pp_decimal_int (buffer
, e
->src
->index
);
2843 dump_edge_info (buffer
->buffer
->stream
, e
, 0);
2844 pp_newline (buffer
);
2848 stmt
= first_stmt (bb
);
2849 if (!stmt
|| TREE_CODE (stmt
) != LABEL_EXPR
)
2851 INDENT (indent
- 2);
2852 pp_string (buffer
, "<bb ");
2853 pp_decimal_int (buffer
, bb
->index
);
2854 pp_string (buffer
, ">:");
2855 pp_newline (buffer
);
2858 pp_write_text_to_stream (buffer
);
2859 check_bb_profile (bb
, buffer
->buffer
->stream
);
2862 /* Dumps end of basic block BB to buffer BUFFER indented by INDENT
2866 dump_bb_end (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
2872 pp_string (buffer
, "# SUCC:");
2873 pp_write_text_to_stream (buffer
);
2874 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
2875 if (flags
& TDF_SLIM
)
2877 pp_string (buffer
, " ");
2878 if (e
->dest
== EXIT_BLOCK_PTR
)
2879 pp_string (buffer
, "EXIT");
2881 pp_decimal_int (buffer
, e
->dest
->index
);
2884 dump_edge_info (buffer
->buffer
->stream
, e
, 1);
2885 pp_newline (buffer
);
2888 /* Dump PHI nodes of basic block BB to BUFFER with details described
2889 by FLAGS and indented by INDENT spaces. */
2892 dump_phi_nodes (pretty_printer
*buffer
, basic_block bb
, int indent
, int flags
)
2894 tree phi
= phi_nodes (bb
);
2898 for (; phi
; phi
= PHI_CHAIN (phi
))
2900 if (is_gimple_reg (PHI_RESULT (phi
)) || (flags
& TDF_VOPS
))
2903 pp_string (buffer
, "# ");
2904 dump_generic_node (buffer
, phi
, indent
, flags
, false);
2905 pp_newline (buffer
);
2911 /* Dump jump to basic block BB that is represented implicitly in the cfg
2915 pp_cfg_jump (pretty_printer
*buffer
, basic_block bb
)
2919 stmt
= first_stmt (bb
);
2921 pp_string (buffer
, "goto <bb ");
2922 pp_decimal_int (buffer
, bb
->index
);
2923 pp_string (buffer
, ">");
2924 if (stmt
&& TREE_CODE (stmt
) == LABEL_EXPR
)
2926 pp_string (buffer
, " (");
2927 dump_generic_node (buffer
, LABEL_EXPR_LABEL (stmt
), 0, 0, false);
2928 pp_string (buffer
, ")");
2930 pp_semicolon (buffer
);
2933 /* Dump edges represented implicitly in basic block BB to BUFFER, indented
2934 by INDENT spaces, with details given by FLAGS. */
2937 dump_implicit_edges (pretty_printer
*buffer
, basic_block bb
, int indent
,
2943 /* If there is a fallthru edge, we may need to add an artificial goto to the
2945 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
2946 if (e
->flags
& EDGE_FALLTHRU
)
2948 if (e
&& e
->dest
!= bb
->next_bb
)
2952 if ((flags
& TDF_LINENO
)
2953 #ifdef USE_MAPPED_LOCATION
2954 && e
->goto_locus
!= UNKNOWN_LOCATION
2960 expanded_location goto_xloc
;
2961 #ifdef USE_MAPPED_LOCATION
2962 goto_xloc
= expand_location (e
->goto_locus
);
2964 goto_xloc
= *e
->goto_locus
;
2966 pp_character (buffer
, '[');
2969 pp_string (buffer
, goto_xloc
.file
);
2970 pp_string (buffer
, " : ");
2972 pp_decimal_int (buffer
, goto_xloc
.line
);
2973 pp_string (buffer
, "] ");
2976 pp_cfg_jump (buffer
, e
->dest
);
2977 pp_newline (buffer
);
2981 /* Dumps basic block BB to buffer BUFFER with details described by FLAGS and
2982 indented by INDENT spaces. */
2985 dump_generic_bb_buff (pretty_printer
*buffer
, basic_block bb
,
2986 int indent
, int flags
)
2988 block_stmt_iterator bsi
;
2990 int label_indent
= indent
- 2;
2992 if (label_indent
< 0)
2995 dump_bb_header (buffer
, bb
, indent
, flags
);
2997 dump_phi_nodes (buffer
, bb
, indent
, flags
);
2999 for (bsi
= bsi_start (bb
); !bsi_end_p (bsi
); bsi_next (&bsi
))
3003 stmt
= bsi_stmt (bsi
);
3005 curr_indent
= TREE_CODE (stmt
) == LABEL_EXPR
? label_indent
: indent
;
3007 INDENT (curr_indent
);
3008 dump_generic_node (buffer
, stmt
, curr_indent
, flags
, true);
3009 pp_newline (buffer
);
3010 dump_histograms_for_stmt (cfun
, buffer
->buffer
->stream
, stmt
);
3013 dump_implicit_edges (buffer
, bb
, indent
, flags
);
3015 if (flags
& TDF_BLOCKS
)
3016 dump_bb_end (buffer
, bb
, indent
, flags
);