1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
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"
40 /* Local functions, macros and variables. */
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_struct_decl (pretty_printer
*, const_tree
, int, int);
47 static void do_niy (pretty_printer
*, const_tree
);
49 #define INDENT(SPACE) do { \
50 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
52 #define NIY do_niy(buffer,node)
54 #define PRINT_FUNCTION_NAME(NODE) pp_printf \
55 (buffer, "%s", TREE_CODE (NODE) == NOP_EXPR ? \
56 lang_hooks.decl_printable_name (TREE_OPERAND (NODE, 0), 1) : \
57 lang_hooks.decl_printable_name (NODE, 1))
59 static pretty_printer buffer
;
60 static int initialized
= 0;
62 /* Try to print something for an unknown tree code. */
65 do_niy (pretty_printer
*buffer
, const_tree node
)
69 pp_string (buffer
, "<<< Unknown tree: ");
70 pp_string (buffer
, tree_code_name
[(int) TREE_CODE (node
)]);
74 len
= TREE_OPERAND_LENGTH (node
);
75 for (i
= 0; i
< len
; ++i
)
77 newline_and_indent (buffer
, 2);
78 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0, false);
82 pp_string (buffer
, " >>>\n");
85 /* Debugging function to print out a generic expression. */
88 debug_generic_expr (tree t
)
90 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
91 fprintf (stderr
, "\n");
94 /* Debugging function to print out a generic statement. */
97 debug_generic_stmt (tree t
)
99 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
100 fprintf (stderr
, "\n");
103 /* Debugging function to print out a chain of trees . */
106 debug_tree_chain (tree t
)
110 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
111 fprintf(stderr
, " ");
114 fprintf (stderr
, "\n");
117 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
119 print_generic_decl (FILE *file
, tree decl
, int flags
)
121 maybe_init_pretty_print (file
);
122 print_declaration (&buffer
, decl
, 2, flags
);
123 pp_write_text_to_stream (&buffer
);
126 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
127 to show in the dump. See TDF_* in tree-pass.h. */
130 print_generic_stmt (FILE *file
, tree t
, int flags
)
132 maybe_init_pretty_print (file
);
133 dump_generic_node (&buffer
, t
, 0, flags
, true);
137 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
138 to show in the dump. See TDF_* in tree-pass.h. The output is indented by
142 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
146 maybe_init_pretty_print (file
);
148 for (i
= 0; i
< indent
; i
++)
150 dump_generic_node (&buffer
, t
, indent
, flags
, true);
154 /* Print a single expression T on file FILE. FLAGS specifies details to show
155 in the dump. See TDF_* in tree-pass.h. */
158 print_generic_expr (FILE *file
, tree t
, int flags
)
160 maybe_init_pretty_print (file
);
161 dump_generic_node (&buffer
, t
, 0, flags
, false);
164 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
168 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
173 pp_tree_identifier (buffer
, DECL_NAME (t
));
174 if ((flags
& TDF_UID
)
175 || DECL_NAME (t
) == NULL_TREE
)
177 if (TREE_CODE (t
) == LABEL_DECL
178 && LABEL_DECL_UID (t
) != -1)
179 pp_printf (buffer
, "L.%d", (int) LABEL_DECL_UID (t
));
182 char c
= TREE_CODE (t
) == CONST_DECL
? 'C' : 'D';
183 pp_printf (buffer
, "%c.%u", c
, DECL_UID (t
));
188 /* Like the above, but used for pretty printing function calls. */
191 dump_function_name (pretty_printer
*buffer
, tree node
)
193 if (DECL_NAME (node
))
194 PRINT_FUNCTION_NAME (node
);
196 dump_decl_name (buffer
, node
, 0);
199 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
200 FLAGS are as in dump_generic_node. */
203 dump_function_declaration (pretty_printer
*buffer
, tree node
,
206 bool wrote_arg
= false;
210 pp_character (buffer
, '(');
212 /* Print the argument types. The last element in the list is a VOID_TYPE.
213 The following avoids printing the last element. */
214 arg
= TYPE_ARG_TYPES (node
);
215 while (arg
&& TREE_CHAIN (arg
) && arg
!= error_mark_node
)
218 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
219 arg
= TREE_CHAIN (arg
);
220 if (TREE_CHAIN (arg
) && TREE_CODE (TREE_CHAIN (arg
)) == TREE_LIST
)
222 pp_character (buffer
, ',');
228 pp_string (buffer
, "void");
230 pp_character (buffer
, ')');
233 /* Dump the domain associated with an array. */
236 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
238 pp_character (buffer
, '[');
241 tree min
= TYPE_MIN_VALUE (domain
);
242 tree max
= TYPE_MAX_VALUE (domain
);
245 && integer_zerop (min
)
246 && host_integerp (max
, 0))
247 pp_wide_integer (buffer
, TREE_INT_CST_LOW (max
) + 1);
251 dump_generic_node (buffer
, min
, spc
, flags
, false);
252 pp_character (buffer
, ':');
254 dump_generic_node (buffer
, max
, spc
, flags
, false);
258 pp_string (buffer
, "<unknown>");
259 pp_character (buffer
, ']');
263 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
264 dump_generic_node. */
267 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
271 switch (OMP_CLAUSE_CODE (clause
))
273 case OMP_CLAUSE_PRIVATE
:
276 case OMP_CLAUSE_SHARED
:
279 case OMP_CLAUSE_FIRSTPRIVATE
:
280 name
= "firstprivate";
282 case OMP_CLAUSE_LASTPRIVATE
:
283 name
= "lastprivate";
285 case OMP_CLAUSE_COPYIN
:
288 case OMP_CLAUSE_COPYPRIVATE
:
289 name
= "copyprivate";
292 pp_string (buffer
, name
);
293 pp_character (buffer
, '(');
294 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
296 pp_character (buffer
, ')');
299 case OMP_CLAUSE_REDUCTION
:
300 pp_string (buffer
, "reduction(");
301 pp_string (buffer
, op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
302 pp_character (buffer
, ':');
303 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
305 pp_character (buffer
, ')');
309 pp_string (buffer
, "if(");
310 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
312 pp_character (buffer
, ')');
315 case OMP_CLAUSE_NUM_THREADS
:
316 pp_string (buffer
, "num_threads(");
317 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
319 pp_character (buffer
, ')');
322 case OMP_CLAUSE_NOWAIT
:
323 pp_string (buffer
, "nowait");
325 case OMP_CLAUSE_ORDERED
:
326 pp_string (buffer
, "ordered");
329 case OMP_CLAUSE_DEFAULT
:
330 pp_string (buffer
, "default(");
331 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
333 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
335 case OMP_CLAUSE_DEFAULT_SHARED
:
336 pp_string (buffer
, "shared");
338 case OMP_CLAUSE_DEFAULT_NONE
:
339 pp_string (buffer
, "none");
341 case OMP_CLAUSE_DEFAULT_PRIVATE
:
342 pp_string (buffer
, "private");
344 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE
:
345 pp_string (buffer
, "firstprivate");
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");
369 case OMP_CLAUSE_SCHEDULE_AUTO
:
370 pp_string (buffer
, "auto");
375 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
377 pp_character (buffer
, ',');
378 dump_generic_node (buffer
,
379 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
382 pp_character (buffer
, ')');
385 case OMP_CLAUSE_UNTIED
:
386 pp_string (buffer
, "untied");
389 case OMP_CLAUSE_COLLAPSE
:
390 pp_string (buffer
, "collapse(");
391 dump_generic_node (buffer
,
392 OMP_CLAUSE_COLLAPSE_EXPR (clause
),
394 pp_character (buffer
, ')');
398 /* Should never happen. */
399 dump_generic_node (buffer
, clause
, spc
, flags
, false);
405 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
406 dump_generic_node. */
409 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
417 dump_omp_clause (buffer
, clause
, spc
, flags
);
418 clause
= OMP_CLAUSE_CHAIN (clause
);
426 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
427 indent. FLAGS specifies details to show in the dump (see TDF_* in
428 tree-pass.h). If IS_STMT is true, the object printed is considered
429 to be a statement and it is terminated by ';' if appropriate. */
432 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
440 if (node
== NULL_TREE
)
443 is_expr
= EXPR_P (node
);
445 if (is_stmt
&& (flags
& TDF_STMTADDR
))
446 pp_printf (buffer
, "<&%p> ", (void *)node
);
448 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
450 expanded_location xloc
= expand_location (EXPR_LOCATION (node
));
451 pp_character (buffer
, '[');
454 pp_string (buffer
, xloc
.file
);
455 pp_string (buffer
, " : ");
457 pp_decimal_int (buffer
, xloc
.line
);
458 pp_string (buffer
, "] ");
461 switch (TREE_CODE (node
))
464 pp_string (buffer
, "<<< error >>>");
467 case IDENTIFIER_NODE
:
468 pp_tree_identifier (buffer
, node
);
472 while (node
&& node
!= error_mark_node
)
474 if (TREE_PURPOSE (node
))
476 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
479 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
480 node
= TREE_CHAIN (node
);
481 if (node
&& TREE_CODE (node
) == TREE_LIST
)
483 pp_character (buffer
, ',');
490 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
495 if (TREE_VEC_LENGTH (node
) > 0)
497 size_t len
= TREE_VEC_LENGTH (node
);
498 for (i
= 0; i
< len
- 1; i
++)
500 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
502 pp_character (buffer
, ',');
505 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
514 case FIXED_POINT_TYPE
:
520 unsigned int quals
= TYPE_QUALS (node
);
521 enum tree_code_class tclass
;
523 if (quals
& TYPE_QUAL_CONST
)
524 pp_string (buffer
, "const ");
525 else if (quals
& TYPE_QUAL_VOLATILE
)
526 pp_string (buffer
, "volatile ");
527 else if (quals
& TYPE_QUAL_RESTRICT
)
528 pp_string (buffer
, "restrict ");
530 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
532 if (tclass
== tcc_declaration
)
534 if (DECL_NAME (node
))
535 dump_decl_name (buffer
, node
, flags
);
537 pp_string (buffer
, "<unnamed type decl>");
539 else if (tclass
== tcc_type
)
541 if (TYPE_NAME (node
))
543 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
544 pp_tree_identifier (buffer
, TYPE_NAME (node
));
545 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
546 && DECL_NAME (TYPE_NAME (node
)))
547 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
549 pp_string (buffer
, "<unnamed type>");
551 else if (TREE_CODE (node
) == VECTOR_TYPE
)
553 pp_string (buffer
, "vector ");
554 dump_generic_node (buffer
, TREE_TYPE (node
),
557 else if (TREE_CODE (node
) == INTEGER_TYPE
)
559 pp_string (buffer
, (TYPE_UNSIGNED (node
)
560 ? "<unnamed-unsigned:"
561 : "<unnamed-signed:"));
562 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
563 pp_string (buffer
, ">");
566 pp_string (buffer
, "<unnamed type>");
573 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
575 if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
577 tree fnode
= TREE_TYPE (node
);
579 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
581 pp_character (buffer
, '(');
582 pp_string (buffer
, str
);
583 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
584 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
586 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
588 pp_character (buffer
, ')');
589 dump_function_declaration (buffer
, fnode
, spc
, flags
);
593 unsigned int quals
= TYPE_QUALS (node
);
595 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
597 pp_string (buffer
, str
);
599 if (quals
& TYPE_QUAL_CONST
)
600 pp_string (buffer
, " const");
601 if (quals
& TYPE_QUAL_VOLATILE
)
602 pp_string (buffer
, " volatile");
603 if (quals
& TYPE_QUAL_RESTRICT
)
604 pp_string (buffer
, " restrict");
606 if (TYPE_REF_CAN_ALIAS_ALL (node
))
607 pp_string (buffer
, " {ref-all}");
616 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)), flags
);
617 pp_string (buffer
, "::");
622 const char *sep
= "";
625 pp_string (buffer
, "MEM[");
627 tmp
= TMR_SYMBOL (node
);
630 pp_string (buffer
, sep
);
632 pp_string (buffer
, "symbol: ");
633 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
635 tmp
= TMR_BASE (node
);
638 pp_string (buffer
, sep
);
640 pp_string (buffer
, "base: ");
641 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
643 tmp
= TMR_INDEX (node
);
646 pp_string (buffer
, sep
);
648 pp_string (buffer
, "index: ");
649 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
651 tmp
= TMR_STEP (node
);
654 pp_string (buffer
, sep
);
656 pp_string (buffer
, "step: ");
657 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
659 tmp
= TMR_OFFSET (node
);
662 pp_string (buffer
, sep
);
664 pp_string (buffer
, "offset: ");
665 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
667 pp_string (buffer
, "]");
668 if (flags
& TDF_DETAILS
)
670 pp_string (buffer
, "{");
671 dump_generic_node (buffer
, TMR_ORIGINAL (node
), spc
, flags
,
673 pp_string (buffer
, "}");
682 /* Print the innermost component type. */
683 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
684 tmp
= TREE_TYPE (tmp
))
686 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
688 /* Print the dimensions. */
689 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
690 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
696 case QUAL_UNION_TYPE
:
698 unsigned int quals
= TYPE_QUALS (node
);
700 if (quals
& TYPE_QUAL_CONST
)
701 pp_string (buffer
, "const ");
702 if (quals
& TYPE_QUAL_VOLATILE
)
703 pp_string (buffer
, "volatile ");
705 /* Print the name of the structure. */
706 if (TREE_CODE (node
) == RECORD_TYPE
)
707 pp_string (buffer
, "struct ");
708 else if (TREE_CODE (node
) == UNION_TYPE
)
709 pp_string (buffer
, "union ");
711 if (TYPE_NAME (node
))
712 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
714 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))
751 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (val
);
752 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (val
);
754 if (tree_int_cst_sgn (val
) < 0)
756 pp_character (buffer
, '-');
760 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
762 sprintf (pp_buffer (buffer
)->digit_buffer
,
763 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
764 (unsigned HOST_WIDE_INT
) high
, low
);
765 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
768 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
772 /* Code copied from print_node. */
775 if (TREE_OVERFLOW (node
))
776 pp_string (buffer
, " overflow");
778 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
779 d
= TREE_REAL_CST (node
);
780 if (REAL_VALUE_ISINF (d
))
781 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
782 else if (REAL_VALUE_ISNAN (d
))
783 pp_string (buffer
, " Nan");
787 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
788 pp_string (buffer
, string
);
793 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
794 pp_string (buffer
, "0x");
795 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
796 output_formatted_integer (buffer
, "%02x", *p
++);
805 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
806 pp_string (buffer
, string
);
811 pp_string (buffer
, "__complex__ (");
812 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
813 pp_string (buffer
, ", ");
814 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
815 pp_string (buffer
, ")");
819 pp_string (buffer
, "\"");
820 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
821 pp_string (buffer
, "\"");
827 pp_string (buffer
, "{ ");
828 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
830 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
, false);
831 if (TREE_CHAIN (elt
))
832 pp_string (buffer
, ", ");
834 pp_string (buffer
, " }");
843 dump_decl_name (buffer
, node
, flags
);
847 if (DECL_NAME (node
))
848 dump_decl_name (buffer
, node
, flags
);
849 else if (LABEL_DECL_UID (node
) != -1)
850 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
852 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
856 if (DECL_IS_BUILTIN (node
))
858 /* Don't print the declaration of built-in types. */
861 if (DECL_NAME (node
))
862 dump_decl_name (buffer
, node
, flags
);
865 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
866 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
867 && TYPE_METHODS (TREE_TYPE (node
)))
869 /* The type is a c++ class: all structures have at least
871 pp_string (buffer
, "class ");
872 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
877 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
878 ? "union" : "struct "));
879 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
884 case SYMBOL_MEMORY_TAG
:
885 case NAME_MEMORY_TAG
:
890 case MEMORY_PARTITION_TAG
:
891 dump_decl_name (buffer
, node
, flags
);
895 pp_string (buffer
, "<retval>");
899 op0
= TREE_OPERAND (node
, 0);
901 if (TREE_CODE (op0
) == INDIRECT_REF
)
903 op0
= TREE_OPERAND (op0
, 0);
906 if (op_prio (op0
) < op_prio (node
))
907 pp_character (buffer
, '(');
908 dump_generic_node (buffer
, op0
, spc
, flags
, false);
909 if (op_prio (op0
) < op_prio (node
))
910 pp_character (buffer
, ')');
911 pp_string (buffer
, str
);
912 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
913 op0
= component_ref_field_offset (node
);
914 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
916 pp_string (buffer
, "{off: ");
917 dump_generic_node (buffer
, op0
, spc
, flags
, false);
918 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 || TREE_OPERAND (node
, 2)
951 || TREE_OPERAND (node
, 3))
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);
1057 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1060 pp_character (buffer
, '=');
1061 if (TREE_CODE (node
) == MODIFY_EXPR
1062 && MOVE_NONTEMPORAL (node
))
1063 pp_string (buffer
, "{nt}");
1065 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1070 pp_string (buffer
, "TARGET_EXPR <");
1071 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1072 pp_character (buffer
, ',');
1074 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1075 pp_character (buffer
, '>');
1079 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1084 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1086 pp_string (buffer
, "if (");
1087 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1088 pp_character (buffer
, ')');
1089 /* The lowered cond_exprs should always be printed in full. */
1090 if (COND_EXPR_THEN (node
)
1091 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1092 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1093 && COND_EXPR_ELSE (node
)
1094 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1095 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1098 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1100 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1102 pp_string (buffer
, " else ");
1103 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1107 else if (!(flags
& TDF_SLIM
))
1109 /* Output COND_EXPR_THEN. */
1110 if (COND_EXPR_THEN (node
))
1112 newline_and_indent (buffer
, spc
+2);
1113 pp_character (buffer
, '{');
1114 newline_and_indent (buffer
, spc
+4);
1115 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1117 newline_and_indent (buffer
, spc
+2);
1118 pp_character (buffer
, '}');
1121 /* Output COND_EXPR_ELSE. */
1122 if (COND_EXPR_ELSE (node
)
1123 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1125 newline_and_indent (buffer
, spc
);
1126 pp_string (buffer
, "else");
1127 newline_and_indent (buffer
, spc
+2);
1128 pp_character (buffer
, '{');
1129 newline_and_indent (buffer
, spc
+4);
1130 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1132 newline_and_indent (buffer
, spc
+2);
1133 pp_character (buffer
, '}');
1140 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1142 pp_character (buffer
, '?');
1144 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1146 pp_character (buffer
, ':');
1148 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1153 pp_character (buffer
, '{');
1154 if (!(flags
& TDF_SLIM
))
1156 if (BIND_EXPR_VARS (node
))
1158 pp_newline (buffer
);
1160 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= TREE_CHAIN (op0
))
1162 print_declaration (buffer
, op0
, spc
+2, flags
);
1163 pp_newline (buffer
);
1167 newline_and_indent (buffer
, spc
+2);
1168 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1169 newline_and_indent (buffer
, spc
);
1170 pp_character (buffer
, '}');
1176 print_call_name (buffer
, node
);
1178 /* Print parameters. */
1180 pp_character (buffer
, '(');
1183 call_expr_arg_iterator iter
;
1184 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1186 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1187 if (more_call_expr_args_p (&iter
))
1189 pp_character (buffer
, ',');
1194 if (CALL_EXPR_VA_ARG_PACK (node
))
1196 if (call_expr_nargs (node
) > 0)
1198 pp_character (buffer
, ',');
1201 pp_string (buffer
, "__builtin_va_arg_pack ()");
1203 pp_character (buffer
, ')');
1205 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1208 pp_string (buffer
, " [static-chain: ");
1209 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1210 pp_character (buffer
, ']');
1213 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1214 pp_string (buffer
, " [return slot optimization]");
1215 if (CALL_EXPR_TAILCALL (node
))
1216 pp_string (buffer
, " [tail call]");
1219 case WITH_CLEANUP_EXPR
:
1223 case CLEANUP_POINT_EXPR
:
1224 pp_string (buffer
, "<<cleanup_point ");
1225 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1226 pp_string (buffer
, ">>");
1229 case PLACEHOLDER_EXPR
:
1230 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1231 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1232 pp_character (buffer
, '>');
1235 /* Binary arithmetic and logic expressions. */
1236 case WIDEN_SUM_EXPR
:
1237 case WIDEN_MULT_EXPR
:
1240 case POINTER_PLUS_EXPR
:
1242 case TRUNC_DIV_EXPR
:
1244 case FLOOR_DIV_EXPR
:
1245 case ROUND_DIV_EXPR
:
1246 case TRUNC_MOD_EXPR
:
1248 case FLOOR_MOD_EXPR
:
1249 case ROUND_MOD_EXPR
:
1251 case EXACT_DIV_EXPR
:
1256 case VEC_LSHIFT_EXPR
:
1257 case VEC_RSHIFT_EXPR
:
1261 case TRUTH_ANDIF_EXPR
:
1262 case TRUTH_ORIF_EXPR
:
1263 case TRUTH_AND_EXPR
:
1265 case TRUTH_XOR_EXPR
:
1279 case UNORDERED_EXPR
:
1281 const char *op
= op_symbol (node
);
1282 op0
= TREE_OPERAND (node
, 0);
1283 op1
= TREE_OPERAND (node
, 1);
1285 /* When the operands are expressions with less priority,
1286 keep semantics of the tree representation. */
1287 if (op_prio (op0
) <= op_prio (node
))
1289 pp_character (buffer
, '(');
1290 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1291 pp_character (buffer
, ')');
1294 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1297 pp_string (buffer
, op
);
1300 /* When the operands are expressions with less priority,
1301 keep semantics of the tree representation. */
1302 if (op_prio (op1
) <= op_prio (node
))
1304 pp_character (buffer
, '(');
1305 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1306 pp_character (buffer
, ')');
1309 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1313 /* Unary arithmetic and logic expressions. */
1316 case TRUTH_NOT_EXPR
:
1318 case PREDECREMENT_EXPR
:
1319 case PREINCREMENT_EXPR
:
1320 case ALIGN_INDIRECT_REF
:
1321 case MISALIGNED_INDIRECT_REF
:
1323 if (TREE_CODE (node
) == ADDR_EXPR
1324 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1325 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1326 ; /* Do not output '&' for strings and function pointers. */
1328 pp_string (buffer
, op_symbol (node
));
1330 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1332 pp_character (buffer
, '(');
1333 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1334 pp_character (buffer
, ')');
1337 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1339 if (TREE_CODE (node
) == MISALIGNED_INDIRECT_REF
)
1341 pp_string (buffer
, "{misalignment: ");
1342 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1343 pp_character (buffer
, '}');
1347 case POSTDECREMENT_EXPR
:
1348 case POSTINCREMENT_EXPR
:
1349 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1351 pp_character (buffer
, '(');
1352 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1353 pp_character (buffer
, ')');
1356 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1357 pp_string (buffer
, op_symbol (node
));
1361 pp_string (buffer
, "MIN_EXPR <");
1362 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1363 pp_string (buffer
, ", ");
1364 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1365 pp_character (buffer
, '>');
1369 pp_string (buffer
, "MAX_EXPR <");
1370 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1371 pp_string (buffer
, ", ");
1372 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1373 pp_character (buffer
, '>');
1377 pp_string (buffer
, "ABS_EXPR <");
1378 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1379 pp_character (buffer
, '>');
1386 case FIXED_CONVERT_EXPR
:
1387 case FIX_TRUNC_EXPR
:
1390 type
= TREE_TYPE (node
);
1391 op0
= TREE_OPERAND (node
, 0);
1392 if (type
!= TREE_TYPE (op0
))
1394 pp_character (buffer
, '(');
1395 dump_generic_node (buffer
, type
, spc
, flags
, false);
1396 pp_string (buffer
, ") ");
1398 if (op_prio (op0
) < op_prio (node
))
1399 pp_character (buffer
, '(');
1400 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1401 if (op_prio (op0
) < op_prio (node
))
1402 pp_character (buffer
, ')');
1405 case VIEW_CONVERT_EXPR
:
1406 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1407 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1408 pp_string (buffer
, ">(");
1409 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1410 pp_character (buffer
, ')');
1414 pp_string (buffer
, "((");
1415 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1416 pp_string (buffer
, "))");
1419 case NON_LVALUE_EXPR
:
1420 pp_string (buffer
, "NON_LVALUE_EXPR <");
1421 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1422 pp_character (buffer
, '>');
1426 pp_string (buffer
, "SAVE_EXPR <");
1427 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1428 pp_character (buffer
, '>');
1432 pp_string (buffer
, "COMPLEX_EXPR <");
1433 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1434 pp_string (buffer
, ", ");
1435 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1436 pp_string (buffer
, ">");
1440 pp_string (buffer
, "CONJ_EXPR <");
1441 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1442 pp_string (buffer
, ">");
1446 pp_string (buffer
, "REALPART_EXPR <");
1447 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1448 pp_string (buffer
, ">");
1452 pp_string (buffer
, "IMAGPART_EXPR <");
1453 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1454 pp_string (buffer
, ">");
1458 pp_string (buffer
, "VA_ARG_EXPR <");
1459 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1460 pp_string (buffer
, ">");
1463 case TRY_FINALLY_EXPR
:
1464 case TRY_CATCH_EXPR
:
1465 pp_string (buffer
, "try");
1466 newline_and_indent (buffer
, spc
+2);
1467 pp_string (buffer
, "{");
1468 newline_and_indent (buffer
, spc
+4);
1469 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1470 newline_and_indent (buffer
, spc
+2);
1471 pp_string (buffer
, "}");
1472 newline_and_indent (buffer
, spc
);
1474 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1475 newline_and_indent (buffer
, spc
+2);
1476 pp_string (buffer
, "{");
1477 newline_and_indent (buffer
, spc
+4);
1478 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1479 newline_and_indent (buffer
, spc
+2);
1480 pp_string (buffer
, "}");
1485 pp_string (buffer
, "catch (");
1486 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1487 pp_string (buffer
, ")");
1488 newline_and_indent (buffer
, spc
+2);
1489 pp_string (buffer
, "{");
1490 newline_and_indent (buffer
, spc
+4);
1491 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1492 newline_and_indent (buffer
, spc
+2);
1493 pp_string (buffer
, "}");
1497 case EH_FILTER_EXPR
:
1498 pp_string (buffer
, "<<<eh_filter (");
1499 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1500 pp_string (buffer
, ")>>>");
1501 newline_and_indent (buffer
, spc
+2);
1502 pp_string (buffer
, "{");
1503 newline_and_indent (buffer
, spc
+4);
1504 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1505 newline_and_indent (buffer
, spc
+2);
1506 pp_string (buffer
, "}");
1510 case CHANGE_DYNAMIC_TYPE_EXPR
:
1511 pp_string (buffer
, "<<<change_dynamic_type (");
1512 dump_generic_node (buffer
, CHANGE_DYNAMIC_TYPE_NEW_TYPE (node
), spc
+ 2,
1514 pp_string (buffer
, ") ");
1515 dump_generic_node (buffer
, CHANGE_DYNAMIC_TYPE_LOCATION (node
), spc
+ 2,
1517 pp_string (buffer
, ")>>>");
1522 op0
= TREE_OPERAND (node
, 0);
1523 /* If this is for break or continue, don't bother printing it. */
1524 if (DECL_NAME (op0
))
1526 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1527 if (strcmp (name
, "break") == 0
1528 || strcmp (name
, "continue") == 0)
1531 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1532 pp_character (buffer
, ':');
1533 if (DECL_NONLOCAL (op0
))
1534 pp_string (buffer
, " [non-local]");
1538 pp_string (buffer
, "<<<exception object>>>");
1542 pp_string (buffer
, "<<<filter object>>>");
1546 pp_string (buffer
, "while (1)");
1547 if (!(flags
& TDF_SLIM
))
1549 newline_and_indent (buffer
, spc
+2);
1550 pp_character (buffer
, '{');
1551 newline_and_indent (buffer
, spc
+4);
1552 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1553 newline_and_indent (buffer
, spc
+2);
1554 pp_character (buffer
, '}');
1560 pp_string (buffer
, "// predicted ");
1561 if (PREDICT_EXPR_OUTCOME (node
))
1562 pp_string (buffer
, "likely by ");
1564 pp_string (buffer
, "unlikely by ");
1565 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
1566 pp_string (buffer
, " predictor.");
1570 pp_string (buffer
, "return");
1571 op0
= TREE_OPERAND (node
, 0);
1575 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1576 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
1579 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1584 pp_string (buffer
, "if (");
1585 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1586 pp_string (buffer
, ") break");
1590 pp_string (buffer
, "switch (");
1591 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1592 pp_character (buffer
, ')');
1593 if (!(flags
& TDF_SLIM
))
1595 newline_and_indent (buffer
, spc
+2);
1596 pp_character (buffer
, '{');
1597 if (SWITCH_BODY (node
))
1599 newline_and_indent (buffer
, spc
+4);
1600 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1605 tree vec
= SWITCH_LABELS (node
);
1606 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1607 for (i
= 0; i
< n
; ++i
)
1609 tree elt
= TREE_VEC_ELT (vec
, i
);
1610 newline_and_indent (buffer
, spc
+4);
1613 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1614 pp_string (buffer
, " goto ");
1615 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1617 pp_semicolon (buffer
);
1620 pp_string (buffer
, "case ???: goto ???;");
1623 newline_and_indent (buffer
, spc
+2);
1624 pp_character (buffer
, '}');
1630 op0
= GOTO_DESTINATION (node
);
1631 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1633 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1634 if (strcmp (name
, "break") == 0
1635 || strcmp (name
, "continue") == 0)
1637 pp_string (buffer
, name
);
1641 pp_string (buffer
, "goto ");
1642 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1646 pp_string (buffer
, "resx ");
1647 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1651 pp_string (buffer
, "__asm__");
1652 if (ASM_VOLATILE_P (node
))
1653 pp_string (buffer
, " __volatile__");
1654 pp_character (buffer
, '(');
1655 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1656 pp_character (buffer
, ':');
1657 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1658 pp_character (buffer
, ':');
1659 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1660 if (ASM_CLOBBERS (node
))
1662 pp_character (buffer
, ':');
1663 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1665 pp_string (buffer
, ")");
1668 case CASE_LABEL_EXPR
:
1669 if (CASE_LOW (node
) && CASE_HIGH (node
))
1671 pp_string (buffer
, "case ");
1672 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1673 pp_string (buffer
, " ... ");
1674 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1676 else if (CASE_LOW (node
))
1678 pp_string (buffer
, "case ");
1679 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1682 pp_string (buffer
, "default");
1683 pp_character (buffer
, ':');
1687 pp_string (buffer
, "OBJ_TYPE_REF(");
1688 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1689 pp_character (buffer
, ';');
1690 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1691 pp_character (buffer
, '-');
1692 pp_character (buffer
, '>');
1693 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
1694 pp_character (buffer
, ')');
1698 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
1699 pp_string (buffer
, "_");
1700 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
1701 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
1702 pp_string (buffer
, "(ab)");
1703 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
1704 pp_string (buffer
, "(D)");
1707 case WITH_SIZE_EXPR
:
1708 pp_string (buffer
, "WITH_SIZE_EXPR <");
1709 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1710 pp_string (buffer
, ", ");
1711 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1712 pp_string (buffer
, ">");
1716 pp_string (buffer
, "ASSERT_EXPR <");
1717 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
1718 pp_string (buffer
, ", ");
1719 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
1720 pp_string (buffer
, ">");
1724 pp_string (buffer
, "scev_known");
1727 case SCEV_NOT_KNOWN
:
1728 pp_string (buffer
, "scev_not_known");
1731 case POLYNOMIAL_CHREC
:
1732 pp_string (buffer
, "{");
1733 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
1734 pp_string (buffer
, ", +, ");
1735 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
1736 pp_string (buffer
, "}_");
1737 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
1741 case REALIGN_LOAD_EXPR
:
1742 pp_string (buffer
, "REALIGN_LOAD <");
1743 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1744 pp_string (buffer
, ", ");
1745 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1746 pp_string (buffer
, ", ");
1747 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1748 pp_string (buffer
, ">");
1752 pp_string (buffer
, " VEC_COND_EXPR < ");
1753 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1754 pp_string (buffer
, " , ");
1755 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1756 pp_string (buffer
, " , ");
1757 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1758 pp_string (buffer
, " > ");
1762 pp_string (buffer
, " DOT_PROD_EXPR < ");
1763 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1764 pp_string (buffer
, ", ");
1765 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1766 pp_string (buffer
, ", ");
1767 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1768 pp_string (buffer
, " > ");
1772 pp_string (buffer
, "#pragma omp parallel");
1773 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
1776 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
1778 newline_and_indent (buffer
, spc
+ 2);
1779 pp_character (buffer
, '{');
1780 newline_and_indent (buffer
, spc
+ 4);
1781 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
1782 newline_and_indent (buffer
, spc
+ 2);
1783 pp_character (buffer
, '}');
1789 pp_string (buffer
, "#pragma omp task");
1790 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
1794 pp_string (buffer
, "#pragma omp for");
1795 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
1797 if (!(flags
& TDF_SLIM
))
1801 if (OMP_FOR_PRE_BODY (node
))
1803 newline_and_indent (buffer
, spc
+ 2);
1804 pp_character (buffer
, '{');
1806 newline_and_indent (buffer
, spc
);
1807 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
1811 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
1814 newline_and_indent (buffer
, spc
);
1815 pp_string (buffer
, "for (");
1816 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
1818 pp_string (buffer
, "; ");
1819 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
1821 pp_string (buffer
, "; ");
1822 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
1824 pp_string (buffer
, ")");
1826 if (OMP_FOR_BODY (node
))
1828 newline_and_indent (buffer
, spc
+ 2);
1829 pp_character (buffer
, '{');
1830 newline_and_indent (buffer
, spc
+ 4);
1831 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
1833 newline_and_indent (buffer
, spc
+ 2);
1834 pp_character (buffer
, '}');
1836 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
1837 if (OMP_FOR_PRE_BODY (node
))
1840 newline_and_indent (buffer
, spc
+ 2);
1841 pp_character (buffer
, '}');
1848 pp_string (buffer
, "#pragma omp sections");
1849 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
1853 pp_string (buffer
, "#pragma omp section");
1857 pp_string (buffer
, "#pragma omp master");
1861 pp_string (buffer
, "#pragma omp ordered");
1865 pp_string (buffer
, "#pragma omp critical");
1866 if (OMP_CRITICAL_NAME (node
))
1869 pp_character (buffer
, '(');
1870 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
1872 pp_character (buffer
, ')');
1877 pp_string (buffer
, "#pragma omp atomic");
1878 newline_and_indent (buffer
, spc
+ 2);
1879 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1881 pp_character (buffer
, '=');
1883 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1887 pp_string (buffer
, "#pragma omp single");
1888 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
1892 dump_omp_clause (buffer
, node
, spc
, flags
);
1896 case REDUC_MAX_EXPR
:
1897 pp_string (buffer
, " REDUC_MAX_EXPR < ");
1898 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1899 pp_string (buffer
, " > ");
1902 case REDUC_MIN_EXPR
:
1903 pp_string (buffer
, " REDUC_MIN_EXPR < ");
1904 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1905 pp_string (buffer
, " > ");
1908 case REDUC_PLUS_EXPR
:
1909 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
1910 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1911 pp_string (buffer
, " > ");
1914 case VEC_WIDEN_MULT_HI_EXPR
:
1915 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
1916 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1917 pp_string (buffer
, ", ");
1918 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1919 pp_string (buffer
, " > ");
1922 case VEC_WIDEN_MULT_LO_EXPR
:
1923 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
1924 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1925 pp_string (buffer
, ", ");
1926 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1927 pp_string (buffer
, " > ");
1930 case VEC_UNPACK_HI_EXPR
:
1931 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
1932 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1933 pp_string (buffer
, " > ");
1936 case VEC_UNPACK_LO_EXPR
:
1937 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
1938 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1939 pp_string (buffer
, " > ");
1942 case VEC_UNPACK_FLOAT_HI_EXPR
:
1943 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
1944 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1945 pp_string (buffer
, " > ");
1948 case VEC_UNPACK_FLOAT_LO_EXPR
:
1949 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
1950 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1951 pp_string (buffer
, " > ");
1954 case VEC_PACK_TRUNC_EXPR
:
1955 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
1956 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1957 pp_string (buffer
, ", ");
1958 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1959 pp_string (buffer
, " > ");
1962 case VEC_PACK_SAT_EXPR
:
1963 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
1964 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1965 pp_string (buffer
, ", ");
1966 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1967 pp_string (buffer
, " > ");
1970 case VEC_PACK_FIX_TRUNC_EXPR
:
1971 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
1972 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1973 pp_string (buffer
, ", ");
1974 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1975 pp_string (buffer
, " > ");
1981 pp_string (buffer
, "BLOCK");
1983 if (BLOCK_ABSTRACT (node
))
1984 pp_string (buffer
, " [abstract]");
1986 if (TREE_ASM_WRITTEN (node
))
1987 pp_string (buffer
, " [written]");
1989 newline_and_indent (buffer
, spc
+ 2);
1991 if (BLOCK_SUPERCONTEXT (node
))
1993 pp_string (buffer
, "SUPERCONTEXT: ");
1994 if (TREE_CODE (BLOCK_SUPERCONTEXT (node
)) == BLOCK
)
1995 pp_printf (buffer
, "BLOCK %p",
1996 (void *)BLOCK_SUPERCONTEXT (node
));
1998 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (node
), 0, flags
,
2000 newline_and_indent (buffer
, spc
+ 2);
2003 if (BLOCK_SUBBLOCKS (node
))
2005 pp_string (buffer
, "SUBBLOCKS: ");
2006 for (t
= BLOCK_SUBBLOCKS (node
); t
; t
= BLOCK_CHAIN (t
))
2007 pp_printf (buffer
, "%p ", (void *)t
);
2008 newline_and_indent (buffer
, spc
+ 2);
2011 if (BLOCK_VARS (node
))
2013 pp_string (buffer
, "VARS: ");
2014 for (t
= BLOCK_VARS (node
); t
; t
= TREE_CHAIN (t
))
2016 dump_generic_node (buffer
, t
, 0, flags
, false);
2017 pp_string (buffer
, " ");
2019 newline_and_indent (buffer
, spc
+ 2);
2022 if (BLOCK_ABSTRACT_ORIGIN (node
))
2024 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
2025 if (TREE_CODE (BLOCK_ABSTRACT_ORIGIN (node
)) == BLOCK
)
2026 pp_printf (buffer
, "BLOCK %p",
2027 (void *)BLOCK_ABSTRACT_ORIGIN (node
));
2029 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (node
), 0, flags
,
2031 newline_and_indent (buffer
, spc
+ 2);
2036 case VEC_EXTRACT_EVEN_EXPR
:
2037 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2038 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2039 pp_string (buffer
, ", ");
2040 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2041 pp_string (buffer
, " > ");
2044 case VEC_EXTRACT_ODD_EXPR
:
2045 pp_string (buffer
, " VEC_EXTRACT_ODD_EXPR < ");
2046 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2047 pp_string (buffer
, ", ");
2048 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2049 pp_string (buffer
, " > ");
2052 case VEC_INTERLEAVE_HIGH_EXPR
:
2053 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_EXPR < ");
2054 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2055 pp_string (buffer
, ", ");
2056 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2057 pp_string (buffer
, " > ");
2060 case VEC_INTERLEAVE_LOW_EXPR
:
2061 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2062 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2063 pp_string (buffer
, ", ");
2064 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2065 pp_string (buffer
, " > ");
2072 if (is_stmt
&& is_expr
)
2073 pp_semicolon (buffer
);
2075 /* If we're building a diagnostic, the formatted text will be written
2076 into BUFFER's stream by the caller; otherwise, write it now. */
2077 if (!(flags
& TDF_DIAGNOSTIC
))
2078 pp_write_text_to_stream (buffer
);
2083 /* Print the declaration of a variable. */
2086 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2090 if (TREE_CODE (t
) == TYPE_DECL
)
2091 pp_string (buffer
, "typedef ");
2093 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2094 pp_string (buffer
, "register ");
2096 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2097 pp_string (buffer
, "extern ");
2098 else if (TREE_STATIC (t
))
2099 pp_string (buffer
, "static ");
2101 /* Print the type and name. */
2102 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2106 /* Print array's type. */
2107 tmp
= TREE_TYPE (t
);
2108 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2109 tmp
= TREE_TYPE (tmp
);
2110 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2112 /* Print variable's name. */
2114 dump_generic_node (buffer
, t
, spc
, flags
, false);
2116 /* Print the dimensions. */
2117 tmp
= TREE_TYPE (t
);
2118 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2120 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2121 tmp
= TREE_TYPE (tmp
);
2124 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2126 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2128 dump_decl_name (buffer
, t
, flags
);
2129 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2133 /* Print type declaration. */
2134 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2136 /* Print variable's name. */
2138 dump_generic_node (buffer
, t
, spc
, flags
, false);
2141 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2143 pp_string (buffer
, " __asm__ ");
2144 pp_character (buffer
, '(');
2145 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2146 pp_character (buffer
, ')');
2149 /* The initial value of a function serves to determine whether the function
2150 is declared or defined. So the following does not apply to function
2152 if (TREE_CODE (t
) != FUNCTION_DECL
)
2154 /* Print the initial value. */
2155 if (DECL_INITIAL (t
))
2158 pp_character (buffer
, '=');
2160 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2164 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2166 pp_string (buffer
, " [value-expr: ");
2167 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2168 pp_character (buffer
, ']');
2171 pp_character (buffer
, ';');
2175 /* Prints a structure: name, fields, and methods.
2176 FIXME: Still incomplete. */
2179 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2181 /* Print the name of the structure. */
2182 if (TYPE_NAME (node
))
2185 if (TREE_CODE (node
) == RECORD_TYPE
)
2186 pp_string (buffer
, "struct ");
2187 else if ((TREE_CODE (node
) == UNION_TYPE
2188 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2189 pp_string (buffer
, "union ");
2191 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2194 /* Print the contents of the structure. */
2195 pp_newline (buffer
);
2197 pp_character (buffer
, '{');
2198 pp_newline (buffer
);
2200 /* Print the fields of the structure. */
2203 tmp
= TYPE_FIELDS (node
);
2206 /* Avoid to print recursively the structure. */
2207 /* FIXME : Not implemented correctly...,
2208 what about the case when we have a cycle in the contain graph? ...
2209 Maybe this could be solved by looking at the scope in which the
2210 structure was declared. */
2211 if (TREE_TYPE (tmp
) != node
2212 || (TREE_CODE (TREE_TYPE (tmp
)) == POINTER_TYPE
2213 && TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2215 print_declaration (buffer
, tmp
, spc
+2, flags
);
2216 pp_newline (buffer
);
2218 tmp
= TREE_CHAIN (tmp
);
2222 pp_character (buffer
, '}');
2225 /* Return the priority of the operator CODE.
2227 From lowest to highest precedence with either left-to-right (L-R)
2228 or right-to-left (R-L) associativity]:
2231 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2243 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2244 15 [L-R] fn() [] -> .
2246 unary +, - and * have higher precedence than the corresponding binary
2250 op_code_prio (enum tree_code code
)
2267 case TRUTH_ORIF_EXPR
:
2270 case TRUTH_AND_EXPR
:
2271 case TRUTH_ANDIF_EXPR
:
2278 case TRUTH_XOR_EXPR
:
2295 case UNORDERED_EXPR
:
2308 case WIDEN_SUM_EXPR
:
2310 case POINTER_PLUS_EXPR
:
2314 case VEC_WIDEN_MULT_HI_EXPR
:
2315 case VEC_WIDEN_MULT_LO_EXPR
:
2316 case WIDEN_MULT_EXPR
:
2319 case TRUNC_DIV_EXPR
:
2321 case FLOOR_DIV_EXPR
:
2322 case ROUND_DIV_EXPR
:
2324 case EXACT_DIV_EXPR
:
2325 case TRUNC_MOD_EXPR
:
2327 case FLOOR_MOD_EXPR
:
2328 case ROUND_MOD_EXPR
:
2331 case TRUTH_NOT_EXPR
:
2333 case POSTINCREMENT_EXPR
:
2334 case POSTDECREMENT_EXPR
:
2335 case PREINCREMENT_EXPR
:
2336 case PREDECREMENT_EXPR
:
2338 case ALIGN_INDIRECT_REF
:
2339 case MISALIGNED_INDIRECT_REF
:
2344 case FIX_TRUNC_EXPR
:
2350 case ARRAY_RANGE_REF
:
2354 /* Special expressions. */
2360 case REDUC_MAX_EXPR
:
2361 case REDUC_MIN_EXPR
:
2362 case REDUC_PLUS_EXPR
:
2363 case VEC_LSHIFT_EXPR
:
2364 case VEC_RSHIFT_EXPR
:
2365 case VEC_UNPACK_HI_EXPR
:
2366 case VEC_UNPACK_LO_EXPR
:
2367 case VEC_UNPACK_FLOAT_HI_EXPR
:
2368 case VEC_UNPACK_FLOAT_LO_EXPR
:
2369 case VEC_PACK_TRUNC_EXPR
:
2370 case VEC_PACK_SAT_EXPR
:
2374 /* Return an arbitrarily high precedence to avoid surrounding single
2375 VAR_DECLs in ()s. */
2380 /* Return the priority of the operator OP. */
2383 op_prio (const_tree op
)
2385 enum tree_code code
;
2390 code
= TREE_CODE (op
);
2391 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2392 return op_prio (TREE_OPERAND (op
, 0));
2394 return op_code_prio (code
);
2397 /* Return the symbol associated with operator CODE. */
2400 op_symbol_code (enum tree_code code
)
2408 case TRUTH_ORIF_EXPR
:
2411 case TRUTH_AND_EXPR
:
2412 case TRUTH_ANDIF_EXPR
:
2418 case TRUTH_XOR_EXPR
:
2428 case UNORDERED_EXPR
:
2474 case VEC_LSHIFT_EXPR
:
2477 case VEC_RSHIFT_EXPR
:
2480 case POINTER_PLUS_EXPR
:
2486 case REDUC_PLUS_EXPR
:
2489 case WIDEN_SUM_EXPR
:
2492 case WIDEN_MULT_EXPR
:
2502 case TRUTH_NOT_EXPR
:
2509 case ALIGN_INDIRECT_REF
:
2512 case MISALIGNED_INDIRECT_REF
:
2515 case TRUNC_DIV_EXPR
:
2522 case FLOOR_DIV_EXPR
:
2525 case ROUND_DIV_EXPR
:
2528 case EXACT_DIV_EXPR
:
2531 case TRUNC_MOD_EXPR
:
2537 case FLOOR_MOD_EXPR
:
2540 case ROUND_MOD_EXPR
:
2543 case PREDECREMENT_EXPR
:
2546 case PREINCREMENT_EXPR
:
2549 case POSTDECREMENT_EXPR
:
2552 case POSTINCREMENT_EXPR
:
2562 return "<<< ??? >>>";
2566 /* Return the symbol associated with operator OP. */
2569 op_symbol (const_tree op
)
2571 return op_symbol_code (TREE_CODE (op
));
2574 /* Prints the name of a CALL_EXPR. */
2577 print_call_name (pretty_printer
*buffer
, const_tree node
)
2581 gcc_assert (TREE_CODE (node
) == CALL_EXPR
);
2583 op0
= CALL_EXPR_FN (node
);
2585 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2586 op0
= TREE_OPERAND (op0
, 0);
2588 switch (TREE_CODE (op0
))
2592 dump_function_name (buffer
, op0
);
2598 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2602 pp_string (buffer
, "(");
2603 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2604 pp_string (buffer
, ") ? ");
2605 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, 0, false);
2606 pp_string (buffer
, " : ");
2607 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, 0, false);
2611 /* The function is a pointer contained in a structure. */
2612 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == INDIRECT_REF
||
2613 TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2614 dump_function_name (buffer
, TREE_OPERAND (op0
, 1));
2616 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, 0, false);
2618 We can have several levels of structures and a function
2619 pointer inside. This is not implemented yet... */
2624 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2625 dump_function_name (buffer
, TREE_OPERAND (op0
, 0));
2627 dump_generic_node (buffer
, op0
, 0, 0, false);
2632 dump_generic_node (buffer
, op0
, 0, 0, false);
2640 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2643 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2653 pp_string (buffer
, "\\b");
2657 pp_string (buffer
, "\\f");
2661 pp_string (buffer
, "\\n");
2665 pp_string (buffer
, "\\r");
2669 pp_string (buffer
, "\\t");
2673 pp_string (buffer
, "\\v");
2677 pp_string (buffer
, "\\\\");
2681 pp_string (buffer
, "\\\"");
2685 pp_string (buffer
, "\\'");
2688 /* No need to handle \0; the loop terminates on \0. */
2691 pp_string (buffer
, "\\1");
2695 pp_string (buffer
, "\\2");
2699 pp_string (buffer
, "\\3");
2703 pp_string (buffer
, "\\4");
2707 pp_string (buffer
, "\\5");
2711 pp_string (buffer
, "\\6");
2715 pp_string (buffer
, "\\7");
2719 pp_character (buffer
, str
[0]);
2727 maybe_init_pretty_print (FILE *file
)
2731 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
2732 pp_needs_newline (&buffer
) = true;
2736 buffer
.buffer
->stream
= file
;
2740 newline_and_indent (pretty_printer
*buffer
, int spc
)
2742 pp_newline (buffer
);