1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
3 2011 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 "tree-pretty-print.h"
30 #include "tree-flow.h"
31 #include "langhooks.h"
32 #include "tree-iterator.h"
33 #include "tree-chrec.h"
34 #include "tree-pass.h"
35 #include "value-prof.h"
38 /* Local functions, macros and variables. */
39 static const char *op_symbol (const_tree
);
40 static void pretty_print_string (pretty_printer
*, const char*);
41 static void newline_and_indent (pretty_printer
*, int);
42 static void maybe_init_pretty_print (FILE *);
43 static void print_struct_decl (pretty_printer
*, const_tree
, int, int);
44 static void do_niy (pretty_printer
*, const_tree
);
46 #define INDENT(SPACE) do { \
47 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
49 #define NIY do_niy(buffer,node)
51 static pretty_printer buffer
;
52 static int initialized
= 0;
54 /* Try to print something for an unknown tree code. */
57 do_niy (pretty_printer
*buffer
, const_tree node
)
61 pp_string (buffer
, "<<< Unknown tree: ");
62 pp_string (buffer
, tree_code_name
[(int) TREE_CODE (node
)]);
66 len
= TREE_OPERAND_LENGTH (node
);
67 for (i
= 0; i
< len
; ++i
)
69 newline_and_indent (buffer
, 2);
70 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0, false);
74 pp_string (buffer
, " >>>");
77 /* Debugging function to print out a generic expression. */
80 debug_generic_expr (tree t
)
82 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
83 fprintf (stderr
, "\n");
86 /* Debugging function to print out a generic statement. */
89 debug_generic_stmt (tree t
)
91 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
92 fprintf (stderr
, "\n");
95 /* Debugging function to print out a chain of trees . */
98 debug_tree_chain (tree t
)
100 struct pointer_set_t
*seen
= pointer_set_create ();
104 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
105 fprintf (stderr
, " ");
107 if (pointer_set_insert (seen
, t
))
109 fprintf (stderr
, "... [cycled back to ");
110 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
111 fprintf (stderr
, "]");
115 fprintf (stderr
, "\n");
117 pointer_set_destroy (seen
);
120 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
122 print_generic_decl (FILE *file
, tree decl
, int flags
)
124 maybe_init_pretty_print (file
);
125 print_declaration (&buffer
, decl
, 2, flags
);
126 pp_write_text_to_stream (&buffer
);
129 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
130 to show in the dump. See TDF_* in tree-pass.h. */
133 print_generic_stmt (FILE *file
, tree t
, int flags
)
135 maybe_init_pretty_print (file
);
136 dump_generic_node (&buffer
, t
, 0, flags
, true);
140 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
141 to show in the dump. See TDF_* in tree-pass.h. The output is indented by
145 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
149 maybe_init_pretty_print (file
);
151 for (i
= 0; i
< indent
; i
++)
153 dump_generic_node (&buffer
, t
, indent
, flags
, true);
157 /* Print a single expression T on file FILE. FLAGS specifies details to show
158 in the dump. See TDF_* in tree-pass.h. */
161 print_generic_expr (FILE *file
, tree t
, int flags
)
163 maybe_init_pretty_print (file
);
164 dump_generic_node (&buffer
, t
, 0, flags
, false);
167 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
171 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
173 if (DECL_NAME (node
))
175 if ((flags
& TDF_ASMNAME
) && DECL_ASSEMBLER_NAME_SET_P (node
))
176 pp_tree_identifier (buffer
, DECL_ASSEMBLER_NAME (node
));
178 pp_tree_identifier (buffer
, DECL_NAME (node
));
180 if ((flags
& TDF_UID
) || DECL_NAME (node
) == NULL_TREE
)
182 if (TREE_CODE (node
) == LABEL_DECL
&& LABEL_DECL_UID (node
) != -1)
183 pp_printf (buffer
, "L.%d", (int) LABEL_DECL_UID (node
));
184 else if (TREE_CODE (node
) == DEBUG_EXPR_DECL
)
186 if (flags
& TDF_NOUID
)
187 pp_string (buffer
, "D#xxxx");
189 pp_printf (buffer
, "D#%i", DEBUG_TEMP_UID (node
));
193 char c
= TREE_CODE (node
) == CONST_DECL
? 'C' : 'D';
194 if (flags
& TDF_NOUID
)
195 pp_printf (buffer
, "%c.xxxx", c
);
197 pp_printf (buffer
, "%c.%u", c
, DECL_UID (node
));
200 if ((flags
& TDF_ALIAS
) && DECL_PT_UID (node
) != DECL_UID (node
))
202 if (flags
& TDF_NOUID
)
203 pp_printf (buffer
, "ptD.xxxx");
205 pp_printf (buffer
, "ptD.%u", DECL_PT_UID (node
));
209 /* Like the above, but used for pretty printing function calls. */
212 dump_function_name (pretty_printer
*buffer
, tree node
, int flags
)
214 if (TREE_CODE (node
) == NOP_EXPR
)
215 node
= TREE_OPERAND (node
, 0);
216 if (DECL_NAME (node
) && (flags
& TDF_ASMNAME
) == 0)
217 pp_string (buffer
, lang_hooks
.decl_printable_name (node
, 1));
219 dump_decl_name (buffer
, node
, flags
);
222 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
223 FLAGS are as in dump_generic_node. */
226 dump_function_declaration (pretty_printer
*buffer
, tree node
,
229 bool wrote_arg
= false;
233 pp_character (buffer
, '(');
235 /* Print the argument types. */
236 arg
= TYPE_ARG_TYPES (node
);
237 while (arg
&& arg
!= void_list_node
&& arg
!= error_mark_node
)
241 pp_character (buffer
, ',');
245 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
246 arg
= TREE_CHAIN (arg
);
249 /* Drop the trailing void_type_node if we had any previous argument. */
250 if (arg
== void_list_node
&& !wrote_arg
)
251 pp_string (buffer
, "void");
252 /* Properly dump vararg function types. */
253 else if (!arg
&& wrote_arg
)
254 pp_string (buffer
, ", ...");
255 /* Avoid printing any arg for unprototyped functions. */
257 pp_character (buffer
, ')');
260 /* Dump the domain associated with an array. */
263 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
265 pp_character (buffer
, '[');
268 tree min
= TYPE_MIN_VALUE (domain
);
269 tree max
= TYPE_MAX_VALUE (domain
);
272 && integer_zerop (min
)
273 && host_integerp (max
, 0))
274 pp_wide_integer (buffer
, TREE_INT_CST_LOW (max
) + 1);
278 dump_generic_node (buffer
, min
, spc
, flags
, false);
279 pp_character (buffer
, ':');
281 dump_generic_node (buffer
, max
, spc
, flags
, false);
285 pp_string (buffer
, "<unknown>");
286 pp_character (buffer
, ']');
290 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
291 dump_generic_node. */
294 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
298 switch (OMP_CLAUSE_CODE (clause
))
300 case OMP_CLAUSE_PRIVATE
:
303 case OMP_CLAUSE_SHARED
:
306 case OMP_CLAUSE_FIRSTPRIVATE
:
307 name
= "firstprivate";
309 case OMP_CLAUSE_LASTPRIVATE
:
310 name
= "lastprivate";
312 case OMP_CLAUSE_COPYIN
:
315 case OMP_CLAUSE_COPYPRIVATE
:
316 name
= "copyprivate";
319 pp_string (buffer
, name
);
320 pp_character (buffer
, '(');
321 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
323 pp_character (buffer
, ')');
326 case OMP_CLAUSE_REDUCTION
:
327 pp_string (buffer
, "reduction(");
328 pp_string (buffer
, op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
329 pp_character (buffer
, ':');
330 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
332 pp_character (buffer
, ')');
336 pp_string (buffer
, "if(");
337 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
339 pp_character (buffer
, ')');
342 case OMP_CLAUSE_NUM_THREADS
:
343 pp_string (buffer
, "num_threads(");
344 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
346 pp_character (buffer
, ')');
349 case OMP_CLAUSE_NOWAIT
:
350 pp_string (buffer
, "nowait");
352 case OMP_CLAUSE_ORDERED
:
353 pp_string (buffer
, "ordered");
356 case OMP_CLAUSE_DEFAULT
:
357 pp_string (buffer
, "default(");
358 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
360 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
362 case OMP_CLAUSE_DEFAULT_SHARED
:
363 pp_string (buffer
, "shared");
365 case OMP_CLAUSE_DEFAULT_NONE
:
366 pp_string (buffer
, "none");
368 case OMP_CLAUSE_DEFAULT_PRIVATE
:
369 pp_string (buffer
, "private");
371 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE
:
372 pp_string (buffer
, "firstprivate");
377 pp_character (buffer
, ')');
380 case OMP_CLAUSE_SCHEDULE
:
381 pp_string (buffer
, "schedule(");
382 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
384 case OMP_CLAUSE_SCHEDULE_STATIC
:
385 pp_string (buffer
, "static");
387 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
388 pp_string (buffer
, "dynamic");
390 case OMP_CLAUSE_SCHEDULE_GUIDED
:
391 pp_string (buffer
, "guided");
393 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
394 pp_string (buffer
, "runtime");
396 case OMP_CLAUSE_SCHEDULE_AUTO
:
397 pp_string (buffer
, "auto");
402 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
404 pp_character (buffer
, ',');
405 dump_generic_node (buffer
,
406 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
409 pp_character (buffer
, ')');
412 case OMP_CLAUSE_UNTIED
:
413 pp_string (buffer
, "untied");
416 case OMP_CLAUSE_COLLAPSE
:
417 pp_string (buffer
, "collapse(");
418 dump_generic_node (buffer
,
419 OMP_CLAUSE_COLLAPSE_EXPR (clause
),
421 pp_character (buffer
, ')');
424 case OMP_CLAUSE_FINAL
:
425 pp_string (buffer
, "final(");
426 dump_generic_node (buffer
, OMP_CLAUSE_FINAL_EXPR (clause
),
428 pp_character (buffer
, ')');
431 case OMP_CLAUSE_MERGEABLE
:
432 pp_string (buffer
, "mergeable");
436 /* Should never happen. */
437 dump_generic_node (buffer
, clause
, spc
, flags
, false);
443 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
444 dump_generic_node. */
447 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
455 dump_omp_clause (buffer
, clause
, spc
, flags
);
456 clause
= OMP_CLAUSE_CHAIN (clause
);
464 /* Dump location LOC to BUFFER. */
467 dump_location (pretty_printer
*buffer
, location_t loc
)
469 expanded_location xloc
= expand_location (loc
);
471 pp_character (buffer
, '[');
474 pp_string (buffer
, xloc
.file
);
475 pp_string (buffer
, " : ");
477 pp_decimal_int (buffer
, xloc
.line
);
478 pp_string (buffer
, "] ");
482 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
483 dump_generic_node. */
486 dump_block_node (pretty_printer
*buffer
, tree block
, int spc
, int flags
)
490 pp_printf (buffer
, "BLOCK #%d ", BLOCK_NUMBER (block
));
492 if (flags
& TDF_ADDRESS
)
493 pp_printf (buffer
, "[%p] ", (void *) block
);
495 if (BLOCK_ABSTRACT (block
))
496 pp_string (buffer
, "[abstract] ");
498 if (TREE_ASM_WRITTEN (block
))
499 pp_string (buffer
, "[written] ");
501 if (flags
& TDF_SLIM
)
504 if (BLOCK_SOURCE_LOCATION (block
))
505 dump_location (buffer
, BLOCK_SOURCE_LOCATION (block
));
507 newline_and_indent (buffer
, spc
+ 2);
509 if (BLOCK_SUPERCONTEXT (block
))
511 pp_string (buffer
, "SUPERCONTEXT: ");
512 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (block
), 0,
513 flags
| TDF_SLIM
, false);
514 newline_and_indent (buffer
, spc
+ 2);
517 if (BLOCK_SUBBLOCKS (block
))
519 pp_string (buffer
, "SUBBLOCKS: ");
520 for (t
= BLOCK_SUBBLOCKS (block
); t
; t
= BLOCK_CHAIN (t
))
522 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
523 pp_string (buffer
, " ");
525 newline_and_indent (buffer
, spc
+ 2);
528 if (BLOCK_CHAIN (block
))
530 pp_string (buffer
, "SIBLINGS: ");
531 for (t
= BLOCK_CHAIN (block
); t
; t
= BLOCK_CHAIN (t
))
533 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
534 pp_string (buffer
, " ");
536 newline_and_indent (buffer
, spc
+ 2);
539 if (BLOCK_VARS (block
))
541 pp_string (buffer
, "VARS: ");
542 for (t
= BLOCK_VARS (block
); t
; t
= TREE_CHAIN (t
))
544 dump_generic_node (buffer
, t
, 0, flags
, false);
545 pp_string (buffer
, " ");
547 newline_and_indent (buffer
, spc
+ 2);
550 if (VEC_length (tree
, BLOCK_NONLOCALIZED_VARS (block
)) > 0)
553 VEC(tree
,gc
) *nlv
= BLOCK_NONLOCALIZED_VARS (block
);
555 pp_string (buffer
, "NONLOCALIZED_VARS: ");
556 FOR_EACH_VEC_ELT (tree
, nlv
, i
, t
)
558 dump_generic_node (buffer
, t
, 0, flags
, false);
559 pp_string (buffer
, " ");
561 newline_and_indent (buffer
, spc
+ 2);
564 if (BLOCK_ABSTRACT_ORIGIN (block
))
566 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
567 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (block
), 0,
568 flags
| TDF_SLIM
, false);
569 newline_and_indent (buffer
, spc
+ 2);
572 if (BLOCK_FRAGMENT_ORIGIN (block
))
574 pp_string (buffer
, "FRAGMENT_ORIGIN: ");
575 dump_generic_node (buffer
, BLOCK_FRAGMENT_ORIGIN (block
), 0,
576 flags
| TDF_SLIM
, false);
577 newline_and_indent (buffer
, spc
+ 2);
580 if (BLOCK_FRAGMENT_CHAIN (block
))
582 pp_string (buffer
, "FRAGMENT_CHAIN: ");
583 for (t
= BLOCK_FRAGMENT_CHAIN (block
); t
; t
= BLOCK_FRAGMENT_CHAIN (t
))
585 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
586 pp_string (buffer
, " ");
588 newline_and_indent (buffer
, spc
+ 2);
593 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
594 indent. FLAGS specifies details to show in the dump (see TDF_* in
595 tree-pass.h). If IS_STMT is true, the object printed is considered
596 to be a statement and it is terminated by ';' if appropriate. */
599 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
607 if (node
== NULL_TREE
)
610 is_expr
= EXPR_P (node
);
612 if (is_stmt
&& (flags
& TDF_STMTADDR
))
613 pp_printf (buffer
, "<&%p> ", (void *)node
);
615 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
616 dump_location (buffer
, EXPR_LOCATION (node
));
618 switch (TREE_CODE (node
))
621 pp_string (buffer
, "<<< error >>>");
624 case IDENTIFIER_NODE
:
625 pp_tree_identifier (buffer
, node
);
629 while (node
&& node
!= error_mark_node
)
631 if (TREE_PURPOSE (node
))
633 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
636 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
637 node
= TREE_CHAIN (node
);
638 if (node
&& TREE_CODE (node
) == TREE_LIST
)
640 pp_character (buffer
, ',');
647 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
653 if (TREE_VEC_LENGTH (node
) > 0)
655 size_t len
= TREE_VEC_LENGTH (node
);
656 for (i
= 0; i
< len
- 1; i
++)
658 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
660 pp_character (buffer
, ',');
663 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
672 case FIXED_POINT_TYPE
:
678 unsigned int quals
= TYPE_QUALS (node
);
679 enum tree_code_class tclass
;
681 if (quals
& TYPE_QUAL_CONST
)
682 pp_string (buffer
, "const ");
683 else if (quals
& TYPE_QUAL_VOLATILE
)
684 pp_string (buffer
, "volatile ");
685 else if (quals
& TYPE_QUAL_RESTRICT
)
686 pp_string (buffer
, "restrict ");
688 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
690 pp_string (buffer
, "<address-space-");
691 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
692 pp_string (buffer
, "> ");
695 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
697 if (tclass
== tcc_declaration
)
699 if (DECL_NAME (node
))
700 dump_decl_name (buffer
, node
, flags
);
702 pp_string (buffer
, "<unnamed type decl>");
704 else if (tclass
== tcc_type
)
706 if (TYPE_NAME (node
))
708 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
709 pp_tree_identifier (buffer
, TYPE_NAME (node
));
710 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
711 && DECL_NAME (TYPE_NAME (node
)))
712 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
714 pp_string (buffer
, "<unnamed type>");
716 else if (TREE_CODE (node
) == VECTOR_TYPE
)
718 pp_string (buffer
, "vector");
719 pp_character (buffer
, '(');
720 pp_wide_integer (buffer
, TYPE_VECTOR_SUBPARTS (node
));
721 pp_string (buffer
, ") ");
722 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
724 else if (TREE_CODE (node
) == INTEGER_TYPE
)
726 pp_string (buffer
, (TYPE_UNSIGNED (node
)
727 ? "<unnamed-unsigned:"
728 : "<unnamed-signed:"));
729 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
730 pp_string (buffer
, ">");
732 else if (TREE_CODE (node
) == COMPLEX_TYPE
)
734 pp_string (buffer
, "__complex__ ");
735 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
737 else if (TREE_CODE (node
) == REAL_TYPE
)
739 pp_string (buffer
, "<float:");
740 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
741 pp_string (buffer
, ">");
743 else if (TREE_CODE (node
) == FIXED_POINT_TYPE
)
745 pp_string (buffer
, "<fixed-point-");
746 pp_string (buffer
, TYPE_SATURATING (node
) ? "sat:" : "nonsat:");
747 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
748 pp_string (buffer
, ">");
750 else if (TREE_CODE (node
) == VOID_TYPE
)
751 pp_string (buffer
, "void");
753 pp_string (buffer
, "<unnamed type>");
760 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
762 if (TREE_TYPE (node
) == NULL
)
764 pp_string (buffer
, str
);
765 pp_string (buffer
, "<null type>");
767 else if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
769 tree fnode
= TREE_TYPE (node
);
771 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
773 pp_character (buffer
, '(');
774 pp_string (buffer
, str
);
775 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
776 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
777 else if (flags
& TDF_NOUID
)
778 pp_printf (buffer
, "<Txxxx>");
780 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
782 pp_character (buffer
, ')');
783 dump_function_declaration (buffer
, fnode
, spc
, flags
);
787 unsigned int quals
= TYPE_QUALS (node
);
789 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
791 pp_string (buffer
, str
);
793 if (quals
& TYPE_QUAL_CONST
)
794 pp_string (buffer
, " const");
795 if (quals
& TYPE_QUAL_VOLATILE
)
796 pp_string (buffer
, " volatile");
797 if (quals
& TYPE_QUAL_RESTRICT
)
798 pp_string (buffer
, " restrict");
800 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
802 pp_string (buffer
, " <address-space-");
803 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
804 pp_string (buffer
, ">");
807 if (TYPE_REF_CAN_ALIAS_ALL (node
))
808 pp_string (buffer
, " {ref-all}");
818 if (integer_zerop (TREE_OPERAND (node
, 1))
819 /* Dump the types of INTEGER_CSTs explicitly, for we can't
820 infer them and MEM_ATTR caching will share MEM_REFs
821 with differently-typed op0s. */
822 && TREE_CODE (TREE_OPERAND (node
, 0)) != INTEGER_CST
823 /* Released SSA_NAMES have no TREE_TYPE. */
824 && TREE_TYPE (TREE_OPERAND (node
, 0)) != NULL_TREE
825 /* Same pointer types, but ignoring POINTER_TYPE vs.
827 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 0)))
828 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))
829 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 0)))
830 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 1))))
831 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 0)))
832 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 1))))
833 /* Same value types ignoring qualifiers. */
834 && (TYPE_MAIN_VARIANT (TREE_TYPE (node
))
836 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))))
838 if (TREE_CODE (TREE_OPERAND (node
, 0)) != ADDR_EXPR
)
840 pp_string (buffer
, "*");
841 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
845 dump_generic_node (buffer
,
846 TREE_OPERAND (TREE_OPERAND (node
, 0), 0),
853 pp_string (buffer
, "MEM[");
854 pp_string (buffer
, "(");
855 ptype
= TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node
, 1)));
856 dump_generic_node (buffer
, ptype
,
857 spc
, flags
| TDF_SLIM
, false);
858 pp_string (buffer
, ")");
859 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
861 if (!integer_zerop (TREE_OPERAND (node
, 1)))
863 pp_string (buffer
, " + ");
864 dump_generic_node (buffer
, TREE_OPERAND (node
, 1),
867 pp_string (buffer
, "]");
874 const char *sep
= "";
877 pp_string (buffer
, "MEM[");
879 if (TREE_CODE (TMR_BASE (node
)) == ADDR_EXPR
)
881 pp_string (buffer
, sep
);
883 pp_string (buffer
, "symbol: ");
884 dump_generic_node (buffer
, TREE_OPERAND (TMR_BASE (node
), 0),
889 pp_string (buffer
, sep
);
891 pp_string (buffer
, "base: ");
892 dump_generic_node (buffer
, TMR_BASE (node
), spc
, flags
, false);
894 tmp
= TMR_INDEX2 (node
);
897 pp_string (buffer
, sep
);
899 pp_string (buffer
, "base: ");
900 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
902 tmp
= TMR_INDEX (node
);
905 pp_string (buffer
, sep
);
907 pp_string (buffer
, "index: ");
908 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
910 tmp
= TMR_STEP (node
);
913 pp_string (buffer
, sep
);
915 pp_string (buffer
, "step: ");
916 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
918 tmp
= TMR_OFFSET (node
);
921 pp_string (buffer
, sep
);
923 pp_string (buffer
, "offset: ");
924 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
926 pp_string (buffer
, "]");
934 /* Print the innermost component type. */
935 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
936 tmp
= TREE_TYPE (tmp
))
938 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
940 /* Print the dimensions. */
941 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
942 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
948 case QUAL_UNION_TYPE
:
950 unsigned int quals
= TYPE_QUALS (node
);
952 if (quals
& TYPE_QUAL_CONST
)
953 pp_string (buffer
, "const ");
954 if (quals
& TYPE_QUAL_VOLATILE
)
955 pp_string (buffer
, "volatile ");
957 /* Print the name of the structure. */
958 if (TREE_CODE (node
) == RECORD_TYPE
)
959 pp_string (buffer
, "struct ");
960 else if (TREE_CODE (node
) == UNION_TYPE
)
961 pp_string (buffer
, "union ");
963 if (TYPE_NAME (node
))
964 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
965 else if (!(flags
& TDF_SLIM
))
966 /* FIXME: If we eliminate the 'else' above and attempt
967 to show the fields for named types, we may get stuck
968 following a cycle of pointers to structs. The alleged
969 self-reference check in print_struct_decl will not detect
970 cycles involving more than one pointer or struct type. */
971 print_struct_decl (buffer
, node
, spc
, flags
);
980 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
982 /* In the case of a pointer, one may want to divide by the
983 size of the pointed-to type. Unfortunately, this not
984 straightforward. The C front-end maps expressions
989 in such a way that the two INTEGER_CST nodes for "5" have
990 different values but identical types. In the latter
991 case, the 5 is multiplied by sizeof (int) in c-common.c
992 (pointer_int_sum) to convert it to a byte address, and
993 yet the type of the node is left unchanged. Argh. What
994 is consistent though is that the number value corresponds
995 to bytes (UNITS) offset.
997 NB: Neither of the following divisors can be trivially
998 used to recover the original literal:
1000 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1001 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1002 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1003 pp_string (buffer
, "B"); /* pseudo-unit */
1005 else if (! host_integerp (node
, 0))
1008 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (val
);
1009 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (val
);
1011 if (tree_int_cst_sgn (val
) < 0)
1013 pp_character (buffer
, '-');
1014 high
= ~high
+ !low
;
1017 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
1019 sprintf (pp_buffer (buffer
)->digit_buffer
,
1020 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
1021 (unsigned HOST_WIDE_INT
) high
, low
);
1022 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
1025 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1029 /* Code copied from print_node. */
1032 if (TREE_OVERFLOW (node
))
1033 pp_string (buffer
, " overflow");
1035 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1036 d
= TREE_REAL_CST (node
);
1037 if (REAL_VALUE_ISINF (d
))
1038 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
1039 else if (REAL_VALUE_ISNAN (d
))
1040 pp_string (buffer
, " Nan");
1044 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
1045 pp_string (buffer
, string
);
1050 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
1051 pp_string (buffer
, "0x");
1052 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
1053 output_formatted_integer (buffer
, "%02x", *p
++);
1062 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
1063 pp_string (buffer
, string
);
1068 pp_string (buffer
, "__complex__ (");
1069 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
1070 pp_string (buffer
, ", ");
1071 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
1072 pp_string (buffer
, ")");
1076 pp_string (buffer
, "\"");
1077 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
1078 pp_string (buffer
, "\"");
1084 pp_string (buffer
, "{ ");
1085 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
1087 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
, false);
1088 if (TREE_CHAIN (elt
))
1089 pp_string (buffer
, ", ");
1091 pp_string (buffer
, " }");
1097 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1099 if (TREE_CODE (node
) == METHOD_TYPE
)
1101 if (TYPE_METHOD_BASETYPE (node
))
1102 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
1105 pp_string (buffer
, "<null method basetype>");
1106 pp_string (buffer
, "::");
1108 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1109 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1110 else if (flags
& TDF_NOUID
)
1111 pp_printf (buffer
, "<Txxxx>");
1113 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1114 dump_function_declaration (buffer
, node
, spc
, flags
);
1119 dump_decl_name (buffer
, node
, flags
);
1123 if (DECL_NAME (node
))
1124 dump_decl_name (buffer
, node
, flags
);
1125 else if (LABEL_DECL_UID (node
) != -1)
1126 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1129 if (flags
& TDF_NOUID
)
1130 pp_string (buffer
, "<D.xxxx>");
1132 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1137 if (DECL_IS_BUILTIN (node
))
1139 /* Don't print the declaration of built-in types. */
1142 if (DECL_NAME (node
))
1143 dump_decl_name (buffer
, node
, flags
);
1144 else if (TYPE_NAME (TREE_TYPE (node
)) != node
)
1146 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1147 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1148 && TYPE_METHODS (TREE_TYPE (node
)))
1150 /* The type is a c++ class: all structures have at least
1152 pp_string (buffer
, "class ");
1153 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1158 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1159 ? "union" : "struct "));
1160 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1164 pp_string (buffer
, "<anon>");
1170 case DEBUG_EXPR_DECL
:
1171 case NAMESPACE_DECL
:
1172 dump_decl_name (buffer
, node
, flags
);
1176 pp_string (buffer
, "<retval>");
1180 op0
= TREE_OPERAND (node
, 0);
1183 && (TREE_CODE (op0
) == INDIRECT_REF
1184 || (TREE_CODE (op0
) == MEM_REF
1185 && TREE_CODE (TREE_OPERAND (op0
, 0)) != ADDR_EXPR
1186 && integer_zerop (TREE_OPERAND (op0
, 1))
1187 /* Dump the types of INTEGER_CSTs explicitly, for we
1188 can't infer them and MEM_ATTR caching will share
1189 MEM_REFs with differently-typed op0s. */
1190 && TREE_CODE (TREE_OPERAND (op0
, 0)) != INTEGER_CST
1191 /* Released SSA_NAMES have no TREE_TYPE. */
1192 && TREE_TYPE (TREE_OPERAND (op0
, 0)) != NULL_TREE
1193 /* Same pointer types, but ignoring POINTER_TYPE vs.
1195 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1196 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1197 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1198 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1199 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1200 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1201 /* Same value types ignoring qualifiers. */
1202 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0
))
1203 == TYPE_MAIN_VARIANT
1204 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))))))
1206 op0
= TREE_OPERAND (op0
, 0);
1209 if (op_prio (op0
) < op_prio (node
))
1210 pp_character (buffer
, '(');
1211 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1212 if (op_prio (op0
) < op_prio (node
))
1213 pp_character (buffer
, ')');
1214 pp_string (buffer
, str
);
1215 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1216 op0
= component_ref_field_offset (node
);
1217 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1219 pp_string (buffer
, "{off: ");
1220 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1221 pp_character (buffer
, '}');
1226 pp_string (buffer
, "BIT_FIELD_REF <");
1227 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1228 pp_string (buffer
, ", ");
1229 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1230 pp_string (buffer
, ", ");
1231 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1232 pp_string (buffer
, ">");
1236 case ARRAY_RANGE_REF
:
1237 op0
= TREE_OPERAND (node
, 0);
1238 if (op_prio (op0
) < op_prio (node
))
1239 pp_character (buffer
, '(');
1240 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1241 if (op_prio (op0
) < op_prio (node
))
1242 pp_character (buffer
, ')');
1243 pp_character (buffer
, '[');
1244 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1245 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1246 pp_string (buffer
, " ...");
1247 pp_character (buffer
, ']');
1249 op0
= array_ref_low_bound (node
);
1250 op1
= array_ref_element_size (node
);
1252 if (!integer_zerop (op0
)
1253 || TREE_OPERAND (node
, 2)
1254 || TREE_OPERAND (node
, 3))
1256 pp_string (buffer
, "{lb: ");
1257 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1258 pp_string (buffer
, " sz: ");
1259 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1260 pp_character (buffer
, '}');
1266 unsigned HOST_WIDE_INT ix
;
1268 bool is_struct_init
= false;
1269 bool is_array_init
= false;
1270 double_int curidx
= double_int_zero
;
1271 pp_character (buffer
, '{');
1272 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1273 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1274 is_struct_init
= true;
1275 else if (TREE_CODE (TREE_TYPE (node
)) == ARRAY_TYPE
1276 && TYPE_DOMAIN (TREE_TYPE (node
))
1277 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)))
1278 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
))))
1281 tree minv
= TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)));
1282 is_array_init
= true;
1283 curidx
= tree_to_double_int (minv
);
1285 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1291 pp_character (buffer
, '.');
1292 dump_generic_node (buffer
, field
, spc
, flags
, false);
1293 pp_character (buffer
, '=');
1295 else if (is_array_init
1296 && (TREE_CODE (field
) != INTEGER_CST
1297 || !double_int_equal_p (tree_to_double_int (field
),
1300 pp_character (buffer
, '[');
1301 if (TREE_CODE (field
) == RANGE_EXPR
)
1303 dump_generic_node (buffer
, TREE_OPERAND (field
, 0), spc
,
1305 pp_string (buffer
, " ... ");
1306 dump_generic_node (buffer
, TREE_OPERAND (field
, 1), spc
,
1308 if (TREE_CODE (TREE_OPERAND (field
, 1)) == INTEGER_CST
)
1309 curidx
= tree_to_double_int (TREE_OPERAND (field
, 1));
1312 dump_generic_node (buffer
, field
, spc
, flags
, false);
1313 if (TREE_CODE (field
) == INTEGER_CST
)
1314 curidx
= tree_to_double_int (field
);
1315 pp_string (buffer
, "]=");
1319 curidx
= double_int_add (curidx
, double_int_one
);
1320 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1321 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1322 val
= TREE_OPERAND (val
, 0);
1323 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1324 dump_decl_name (buffer
, val
, flags
);
1326 dump_generic_node (buffer
, val
, spc
, flags
, false);
1327 if (ix
!= VEC_length (constructor_elt
, CONSTRUCTOR_ELTS (node
)) - 1)
1329 pp_character (buffer
, ',');
1333 pp_character (buffer
, '}');
1340 if (flags
& TDF_SLIM
)
1342 pp_string (buffer
, "<COMPOUND_EXPR>");
1346 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1347 spc
, flags
, !(flags
& TDF_SLIM
));
1348 if (flags
& TDF_SLIM
)
1349 newline_and_indent (buffer
, spc
);
1352 pp_character (buffer
, ',');
1356 for (tp
= &TREE_OPERAND (node
, 1);
1357 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1358 tp
= &TREE_OPERAND (*tp
, 1))
1360 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1361 spc
, flags
, !(flags
& TDF_SLIM
));
1362 if (flags
& TDF_SLIM
)
1363 newline_and_indent (buffer
, spc
);
1366 pp_character (buffer
, ',');
1371 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1375 case STATEMENT_LIST
:
1377 tree_stmt_iterator si
;
1380 if (flags
& TDF_SLIM
)
1382 pp_string (buffer
, "<STATEMENT_LIST>");
1386 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1389 newline_and_indent (buffer
, spc
);
1392 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1399 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1402 pp_character (buffer
, '=');
1403 if (TREE_CODE (node
) == MODIFY_EXPR
1404 && MOVE_NONTEMPORAL (node
))
1405 pp_string (buffer
, "{nt}");
1407 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1412 pp_string (buffer
, "TARGET_EXPR <");
1413 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1414 pp_character (buffer
, ',');
1416 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1417 pp_character (buffer
, '>');
1421 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1426 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1428 pp_string (buffer
, "if (");
1429 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1430 pp_character (buffer
, ')');
1431 /* The lowered cond_exprs should always be printed in full. */
1432 if (COND_EXPR_THEN (node
)
1433 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1434 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1435 && COND_EXPR_ELSE (node
)
1436 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1437 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1440 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1442 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1444 pp_string (buffer
, " else ");
1445 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1449 else if (!(flags
& TDF_SLIM
))
1451 /* Output COND_EXPR_THEN. */
1452 if (COND_EXPR_THEN (node
))
1454 newline_and_indent (buffer
, spc
+2);
1455 pp_character (buffer
, '{');
1456 newline_and_indent (buffer
, spc
+4);
1457 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1459 newline_and_indent (buffer
, spc
+2);
1460 pp_character (buffer
, '}');
1463 /* Output COND_EXPR_ELSE. */
1464 if (COND_EXPR_ELSE (node
)
1465 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1467 newline_and_indent (buffer
, spc
);
1468 pp_string (buffer
, "else");
1469 newline_and_indent (buffer
, spc
+2);
1470 pp_character (buffer
, '{');
1471 newline_and_indent (buffer
, spc
+4);
1472 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1474 newline_and_indent (buffer
, spc
+2);
1475 pp_character (buffer
, '}');
1482 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1484 pp_character (buffer
, '?');
1486 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1488 pp_character (buffer
, ':');
1490 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1495 pp_character (buffer
, '{');
1496 if (!(flags
& TDF_SLIM
))
1498 if (BIND_EXPR_VARS (node
))
1500 pp_newline (buffer
);
1502 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= DECL_CHAIN (op0
))
1504 print_declaration (buffer
, op0
, spc
+2, flags
);
1505 pp_newline (buffer
);
1509 newline_and_indent (buffer
, spc
+2);
1510 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1511 newline_and_indent (buffer
, spc
);
1512 pp_character (buffer
, '}');
1518 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1520 /* Print parameters. */
1522 pp_character (buffer
, '(');
1525 call_expr_arg_iterator iter
;
1526 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1528 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1529 if (more_call_expr_args_p (&iter
))
1531 pp_character (buffer
, ',');
1536 if (CALL_EXPR_VA_ARG_PACK (node
))
1538 if (call_expr_nargs (node
) > 0)
1540 pp_character (buffer
, ',');
1543 pp_string (buffer
, "__builtin_va_arg_pack ()");
1545 pp_character (buffer
, ')');
1547 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1550 pp_string (buffer
, " [static-chain: ");
1551 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1552 pp_character (buffer
, ']');
1555 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1556 pp_string (buffer
, " [return slot optimization]");
1557 if (CALL_EXPR_TAILCALL (node
))
1558 pp_string (buffer
, " [tail call]");
1561 case WITH_CLEANUP_EXPR
:
1565 case CLEANUP_POINT_EXPR
:
1566 pp_string (buffer
, "<<cleanup_point ");
1567 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1568 pp_string (buffer
, ">>");
1571 case PLACEHOLDER_EXPR
:
1572 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1573 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1574 pp_character (buffer
, '>');
1577 /* Binary arithmetic and logic expressions. */
1578 case WIDEN_SUM_EXPR
:
1579 case WIDEN_MULT_EXPR
:
1582 case POINTER_PLUS_EXPR
:
1584 case TRUNC_DIV_EXPR
:
1586 case FLOOR_DIV_EXPR
:
1587 case ROUND_DIV_EXPR
:
1588 case TRUNC_MOD_EXPR
:
1590 case FLOOR_MOD_EXPR
:
1591 case ROUND_MOD_EXPR
:
1593 case EXACT_DIV_EXPR
:
1598 case VEC_LSHIFT_EXPR
:
1599 case VEC_RSHIFT_EXPR
:
1603 case TRUTH_ANDIF_EXPR
:
1604 case TRUTH_ORIF_EXPR
:
1605 case TRUTH_AND_EXPR
:
1607 case TRUTH_XOR_EXPR
:
1621 case UNORDERED_EXPR
:
1623 const char *op
= op_symbol (node
);
1624 op0
= TREE_OPERAND (node
, 0);
1625 op1
= TREE_OPERAND (node
, 1);
1627 /* When the operands are expressions with less priority,
1628 keep semantics of the tree representation. */
1629 if (op_prio (op0
) <= op_prio (node
))
1631 pp_character (buffer
, '(');
1632 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1633 pp_character (buffer
, ')');
1636 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1639 pp_string (buffer
, op
);
1642 /* When the operands are expressions with less priority,
1643 keep semantics of the tree representation. */
1644 if (op_prio (op1
) <= op_prio (node
))
1646 pp_character (buffer
, '(');
1647 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1648 pp_character (buffer
, ')');
1651 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1655 /* Unary arithmetic and logic expressions. */
1658 case TRUTH_NOT_EXPR
:
1660 case PREDECREMENT_EXPR
:
1661 case PREINCREMENT_EXPR
:
1663 if (TREE_CODE (node
) == ADDR_EXPR
1664 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1665 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1666 ; /* Do not output '&' for strings and function pointers. */
1668 pp_string (buffer
, op_symbol (node
));
1670 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1672 pp_character (buffer
, '(');
1673 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1674 pp_character (buffer
, ')');
1677 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1680 case POSTDECREMENT_EXPR
:
1681 case POSTINCREMENT_EXPR
:
1682 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1684 pp_character (buffer
, '(');
1685 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1686 pp_character (buffer
, ')');
1689 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1690 pp_string (buffer
, op_symbol (node
));
1694 pp_string (buffer
, "MIN_EXPR <");
1695 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1696 pp_string (buffer
, ", ");
1697 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1698 pp_character (buffer
, '>');
1702 pp_string (buffer
, "MAX_EXPR <");
1703 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1704 pp_string (buffer
, ", ");
1705 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1706 pp_character (buffer
, '>');
1710 pp_string (buffer
, "ABS_EXPR <");
1711 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1712 pp_character (buffer
, '>');
1719 case ADDR_SPACE_CONVERT_EXPR
:
1720 case FIXED_CONVERT_EXPR
:
1721 case FIX_TRUNC_EXPR
:
1724 type
= TREE_TYPE (node
);
1725 op0
= TREE_OPERAND (node
, 0);
1726 if (type
!= TREE_TYPE (op0
))
1728 pp_character (buffer
, '(');
1729 dump_generic_node (buffer
, type
, spc
, flags
, false);
1730 pp_string (buffer
, ") ");
1732 if (op_prio (op0
) < op_prio (node
))
1733 pp_character (buffer
, '(');
1734 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1735 if (op_prio (op0
) < op_prio (node
))
1736 pp_character (buffer
, ')');
1739 case VIEW_CONVERT_EXPR
:
1740 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1741 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1742 pp_string (buffer
, ">(");
1743 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1744 pp_character (buffer
, ')');
1748 pp_string (buffer
, "((");
1749 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1750 pp_string (buffer
, "))");
1753 case NON_LVALUE_EXPR
:
1754 pp_string (buffer
, "NON_LVALUE_EXPR <");
1755 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1756 pp_character (buffer
, '>');
1760 pp_string (buffer
, "SAVE_EXPR <");
1761 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1762 pp_character (buffer
, '>');
1766 pp_string (buffer
, "COMPLEX_EXPR <");
1767 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1768 pp_string (buffer
, ", ");
1769 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1770 pp_string (buffer
, ">");
1774 pp_string (buffer
, "CONJ_EXPR <");
1775 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1776 pp_string (buffer
, ">");
1780 pp_string (buffer
, "REALPART_EXPR <");
1781 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1782 pp_string (buffer
, ">");
1786 pp_string (buffer
, "IMAGPART_EXPR <");
1787 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1788 pp_string (buffer
, ">");
1792 pp_string (buffer
, "VA_ARG_EXPR <");
1793 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1794 pp_string (buffer
, ">");
1797 case TRY_FINALLY_EXPR
:
1798 case TRY_CATCH_EXPR
:
1799 pp_string (buffer
, "try");
1800 newline_and_indent (buffer
, spc
+2);
1801 pp_string (buffer
, "{");
1802 newline_and_indent (buffer
, spc
+4);
1803 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1804 newline_and_indent (buffer
, spc
+2);
1805 pp_string (buffer
, "}");
1806 newline_and_indent (buffer
, spc
);
1808 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1809 newline_and_indent (buffer
, spc
+2);
1810 pp_string (buffer
, "{");
1811 newline_and_indent (buffer
, spc
+4);
1812 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1813 newline_and_indent (buffer
, spc
+2);
1814 pp_string (buffer
, "}");
1819 pp_string (buffer
, "catch (");
1820 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1821 pp_string (buffer
, ")");
1822 newline_and_indent (buffer
, spc
+2);
1823 pp_string (buffer
, "{");
1824 newline_and_indent (buffer
, spc
+4);
1825 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1826 newline_and_indent (buffer
, spc
+2);
1827 pp_string (buffer
, "}");
1831 case EH_FILTER_EXPR
:
1832 pp_string (buffer
, "<<<eh_filter (");
1833 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1834 pp_string (buffer
, ")>>>");
1835 newline_and_indent (buffer
, spc
+2);
1836 pp_string (buffer
, "{");
1837 newline_and_indent (buffer
, spc
+4);
1838 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1839 newline_and_indent (buffer
, spc
+2);
1840 pp_string (buffer
, "}");
1845 op0
= TREE_OPERAND (node
, 0);
1846 /* If this is for break or continue, don't bother printing it. */
1847 if (DECL_NAME (op0
))
1849 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1850 if (strcmp (name
, "break") == 0
1851 || strcmp (name
, "continue") == 0)
1854 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1855 pp_character (buffer
, ':');
1856 if (DECL_NONLOCAL (op0
))
1857 pp_string (buffer
, " [non-local]");
1861 pp_string (buffer
, "while (1)");
1862 if (!(flags
& TDF_SLIM
))
1864 newline_and_indent (buffer
, spc
+2);
1865 pp_character (buffer
, '{');
1866 newline_and_indent (buffer
, spc
+4);
1867 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1868 newline_and_indent (buffer
, spc
+2);
1869 pp_character (buffer
, '}');
1875 pp_string (buffer
, "// predicted ");
1876 if (PREDICT_EXPR_OUTCOME (node
))
1877 pp_string (buffer
, "likely by ");
1879 pp_string (buffer
, "unlikely by ");
1880 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
1881 pp_string (buffer
, " predictor.");
1885 pp_string (buffer
, "return");
1886 op0
= TREE_OPERAND (node
, 0);
1890 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1891 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
1894 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1899 pp_string (buffer
, "if (");
1900 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1901 pp_string (buffer
, ") break");
1905 pp_string (buffer
, "switch (");
1906 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1907 pp_character (buffer
, ')');
1908 if (!(flags
& TDF_SLIM
))
1910 newline_and_indent (buffer
, spc
+2);
1911 pp_character (buffer
, '{');
1912 if (SWITCH_BODY (node
))
1914 newline_and_indent (buffer
, spc
+4);
1915 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1920 tree vec
= SWITCH_LABELS (node
);
1921 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1922 for (i
= 0; i
< n
; ++i
)
1924 tree elt
= TREE_VEC_ELT (vec
, i
);
1925 newline_and_indent (buffer
, spc
+4);
1928 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1929 pp_string (buffer
, " goto ");
1930 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1932 pp_semicolon (buffer
);
1935 pp_string (buffer
, "case ???: goto ???;");
1938 newline_and_indent (buffer
, spc
+2);
1939 pp_character (buffer
, '}');
1945 op0
= GOTO_DESTINATION (node
);
1946 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1948 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1949 if (strcmp (name
, "break") == 0
1950 || strcmp (name
, "continue") == 0)
1952 pp_string (buffer
, name
);
1956 pp_string (buffer
, "goto ");
1957 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1961 pp_string (buffer
, "__asm__");
1962 if (ASM_VOLATILE_P (node
))
1963 pp_string (buffer
, " __volatile__");
1964 pp_character (buffer
, '(');
1965 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1966 pp_character (buffer
, ':');
1967 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1968 pp_character (buffer
, ':');
1969 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1970 if (ASM_CLOBBERS (node
))
1972 pp_character (buffer
, ':');
1973 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1975 pp_string (buffer
, ")");
1978 case CASE_LABEL_EXPR
:
1979 if (CASE_LOW (node
) && CASE_HIGH (node
))
1981 pp_string (buffer
, "case ");
1982 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1983 pp_string (buffer
, " ... ");
1984 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1986 else if (CASE_LOW (node
))
1988 pp_string (buffer
, "case ");
1989 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1992 pp_string (buffer
, "default");
1993 pp_character (buffer
, ':');
1997 pp_string (buffer
, "OBJ_TYPE_REF(");
1998 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1999 pp_character (buffer
, ';');
2000 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
2001 pp_character (buffer
, '-');
2002 pp_character (buffer
, '>');
2003 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
2004 pp_character (buffer
, ')');
2008 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
2009 pp_string (buffer
, "_");
2010 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
2011 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
2012 pp_string (buffer
, "(ab)");
2013 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
2014 pp_string (buffer
, "(D)");
2017 case WITH_SIZE_EXPR
:
2018 pp_string (buffer
, "WITH_SIZE_EXPR <");
2019 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2020 pp_string (buffer
, ", ");
2021 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2022 pp_string (buffer
, ">");
2026 pp_string (buffer
, "ASSERT_EXPR <");
2027 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
2028 pp_string (buffer
, ", ");
2029 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
2030 pp_string (buffer
, ">");
2034 pp_string (buffer
, "scev_known");
2037 case SCEV_NOT_KNOWN
:
2038 pp_string (buffer
, "scev_not_known");
2041 case POLYNOMIAL_CHREC
:
2042 pp_string (buffer
, "{");
2043 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
2044 pp_string (buffer
, ", +, ");
2045 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
2046 pp_string (buffer
, "}_");
2047 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
2051 case REALIGN_LOAD_EXPR
:
2052 pp_string (buffer
, "REALIGN_LOAD <");
2053 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2054 pp_string (buffer
, ", ");
2055 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2056 pp_string (buffer
, ", ");
2057 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2058 pp_string (buffer
, ">");
2062 pp_string (buffer
, " VEC_COND_EXPR < ");
2063 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2064 pp_string (buffer
, " , ");
2065 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2066 pp_string (buffer
, " , ");
2067 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2068 pp_string (buffer
, " > ");
2072 pp_string (buffer
, " DOT_PROD_EXPR < ");
2073 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2074 pp_string (buffer
, ", ");
2075 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2076 pp_string (buffer
, ", ");
2077 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2078 pp_string (buffer
, " > ");
2081 case WIDEN_MULT_PLUS_EXPR
:
2082 pp_string (buffer
, " WIDEN_MULT_PLUS_EXPR < ");
2083 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2084 pp_string (buffer
, ", ");
2085 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2086 pp_string (buffer
, ", ");
2087 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2088 pp_string (buffer
, " > ");
2091 case WIDEN_MULT_MINUS_EXPR
:
2092 pp_string (buffer
, " WIDEN_MULT_MINUS_EXPR < ");
2093 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2094 pp_string (buffer
, ", ");
2095 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2096 pp_string (buffer
, ", ");
2097 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2098 pp_string (buffer
, " > ");
2102 pp_string (buffer
, " FMA_EXPR < ");
2103 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2104 pp_string (buffer
, ", ");
2105 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2106 pp_string (buffer
, ", ");
2107 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2108 pp_string (buffer
, " > ");
2112 pp_string (buffer
, "#pragma omp parallel");
2113 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
2116 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
2118 newline_and_indent (buffer
, spc
+ 2);
2119 pp_character (buffer
, '{');
2120 newline_and_indent (buffer
, spc
+ 4);
2121 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
2122 newline_and_indent (buffer
, spc
+ 2);
2123 pp_character (buffer
, '}');
2129 pp_string (buffer
, "#pragma omp task");
2130 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
2134 pp_string (buffer
, "#pragma omp for");
2135 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
2137 if (!(flags
& TDF_SLIM
))
2141 if (OMP_FOR_PRE_BODY (node
))
2143 newline_and_indent (buffer
, spc
+ 2);
2144 pp_character (buffer
, '{');
2146 newline_and_indent (buffer
, spc
);
2147 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
2151 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
2154 newline_and_indent (buffer
, spc
);
2155 pp_string (buffer
, "for (");
2156 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
2158 pp_string (buffer
, "; ");
2159 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
2161 pp_string (buffer
, "; ");
2162 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
2164 pp_string (buffer
, ")");
2166 if (OMP_FOR_BODY (node
))
2168 newline_and_indent (buffer
, spc
+ 2);
2169 pp_character (buffer
, '{');
2170 newline_and_indent (buffer
, spc
+ 4);
2171 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
2173 newline_and_indent (buffer
, spc
+ 2);
2174 pp_character (buffer
, '}');
2176 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
2177 if (OMP_FOR_PRE_BODY (node
))
2180 newline_and_indent (buffer
, spc
+ 2);
2181 pp_character (buffer
, '}');
2188 pp_string (buffer
, "#pragma omp sections");
2189 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2193 pp_string (buffer
, "#pragma omp section");
2197 pp_string (buffer
, "#pragma omp master");
2201 pp_string (buffer
, "#pragma omp ordered");
2205 pp_string (buffer
, "#pragma omp critical");
2206 if (OMP_CRITICAL_NAME (node
))
2209 pp_character (buffer
, '(');
2210 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2212 pp_character (buffer
, ')');
2217 pp_string (buffer
, "#pragma omp atomic");
2218 newline_and_indent (buffer
, spc
+ 2);
2219 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2221 pp_character (buffer
, '=');
2223 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2226 case OMP_ATOMIC_READ
:
2227 pp_string (buffer
, "#pragma omp atomic read");
2228 newline_and_indent (buffer
, spc
+ 2);
2229 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2233 case OMP_ATOMIC_CAPTURE_OLD
:
2234 case OMP_ATOMIC_CAPTURE_NEW
:
2235 pp_string (buffer
, "#pragma omp atomic capture");
2236 newline_and_indent (buffer
, spc
+ 2);
2237 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2239 pp_character (buffer
, '=');
2241 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2245 pp_string (buffer
, "#pragma omp single");
2246 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2250 dump_omp_clause (buffer
, node
, spc
, flags
);
2254 case REDUC_MAX_EXPR
:
2255 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2256 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2257 pp_string (buffer
, " > ");
2260 case REDUC_MIN_EXPR
:
2261 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2262 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2263 pp_string (buffer
, " > ");
2266 case REDUC_PLUS_EXPR
:
2267 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2268 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2269 pp_string (buffer
, " > ");
2272 case VEC_WIDEN_MULT_HI_EXPR
:
2273 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
2274 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2275 pp_string (buffer
, ", ");
2276 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2277 pp_string (buffer
, " > ");
2280 case VEC_WIDEN_MULT_LO_EXPR
:
2281 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
2282 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2283 pp_string (buffer
, ", ");
2284 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2285 pp_string (buffer
, " > ");
2288 case VEC_UNPACK_HI_EXPR
:
2289 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2290 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2291 pp_string (buffer
, " > ");
2294 case VEC_UNPACK_LO_EXPR
:
2295 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2296 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2297 pp_string (buffer
, " > ");
2300 case VEC_UNPACK_FLOAT_HI_EXPR
:
2301 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2302 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2303 pp_string (buffer
, " > ");
2306 case VEC_UNPACK_FLOAT_LO_EXPR
:
2307 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2308 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2309 pp_string (buffer
, " > ");
2312 case VEC_PACK_TRUNC_EXPR
:
2313 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2314 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2315 pp_string (buffer
, ", ");
2316 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2317 pp_string (buffer
, " > ");
2320 case VEC_PACK_SAT_EXPR
:
2321 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2322 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2323 pp_string (buffer
, ", ");
2324 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2325 pp_string (buffer
, " > ");
2328 case VEC_PACK_FIX_TRUNC_EXPR
:
2329 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2330 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2331 pp_string (buffer
, ", ");
2332 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2333 pp_string (buffer
, " > ");
2337 dump_block_node (buffer
, node
, spc
, flags
);
2340 case VEC_EXTRACT_EVEN_EXPR
:
2341 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2342 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2343 pp_string (buffer
, ", ");
2344 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2345 pp_string (buffer
, " > ");
2348 case VEC_EXTRACT_ODD_EXPR
:
2349 pp_string (buffer
, " VEC_EXTRACT_ODD_EXPR < ");
2350 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2351 pp_string (buffer
, ", ");
2352 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2353 pp_string (buffer
, " > ");
2356 case VEC_INTERLEAVE_HIGH_EXPR
:
2357 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_EXPR < ");
2358 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2359 pp_string (buffer
, ", ");
2360 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2361 pp_string (buffer
, " > ");
2364 case VEC_INTERLEAVE_LOW_EXPR
:
2365 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2366 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2367 pp_string (buffer
, ", ");
2368 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2369 pp_string (buffer
, " > ");
2376 if (is_stmt
&& is_expr
)
2377 pp_semicolon (buffer
);
2379 /* If we're building a diagnostic, the formatted text will be written
2380 into BUFFER's stream by the caller; otherwise, write it now. */
2381 if (!(flags
& TDF_DIAGNOSTIC
))
2382 pp_write_text_to_stream (buffer
);
2387 /* Print the declaration of a variable. */
2390 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2394 if (TREE_CODE (t
) == TYPE_DECL
)
2395 pp_string (buffer
, "typedef ");
2397 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2398 pp_string (buffer
, "register ");
2400 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2401 pp_string (buffer
, "extern ");
2402 else if (TREE_STATIC (t
))
2403 pp_string (buffer
, "static ");
2405 /* Print the type and name. */
2406 if (TREE_TYPE (t
) && TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2410 /* Print array's type. */
2411 tmp
= TREE_TYPE (t
);
2412 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2413 tmp
= TREE_TYPE (tmp
);
2414 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2416 /* Print variable's name. */
2418 dump_generic_node (buffer
, t
, spc
, flags
, false);
2420 /* Print the dimensions. */
2421 tmp
= TREE_TYPE (t
);
2422 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2424 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2425 tmp
= TREE_TYPE (tmp
);
2428 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2430 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2432 dump_decl_name (buffer
, t
, flags
);
2433 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2437 /* Print type declaration. */
2438 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2440 /* Print variable's name. */
2442 dump_generic_node (buffer
, t
, spc
, flags
, false);
2445 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2447 pp_string (buffer
, " __asm__ ");
2448 pp_character (buffer
, '(');
2449 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2450 pp_character (buffer
, ')');
2453 /* The initial value of a function serves to determine whether the function
2454 is declared or defined. So the following does not apply to function
2456 if (TREE_CODE (t
) != FUNCTION_DECL
)
2458 /* Print the initial value. */
2459 if (DECL_INITIAL (t
))
2462 pp_character (buffer
, '=');
2464 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2468 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2470 pp_string (buffer
, " [value-expr: ");
2471 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2472 pp_character (buffer
, ']');
2475 pp_character (buffer
, ';');
2479 /* Prints a structure: name, fields, and methods.
2480 FIXME: Still incomplete. */
2483 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2485 /* Print the name of the structure. */
2486 if (TYPE_NAME (node
))
2489 if (TREE_CODE (node
) == RECORD_TYPE
)
2490 pp_string (buffer
, "struct ");
2491 else if ((TREE_CODE (node
) == UNION_TYPE
2492 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2493 pp_string (buffer
, "union ");
2495 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2498 /* Print the contents of the structure. */
2499 pp_newline (buffer
);
2501 pp_character (buffer
, '{');
2502 pp_newline (buffer
);
2504 /* Print the fields of the structure. */
2507 tmp
= TYPE_FIELDS (node
);
2510 /* Avoid to print recursively the structure. */
2511 /* FIXME : Not implemented correctly...,
2512 what about the case when we have a cycle in the contain graph? ...
2513 Maybe this could be solved by looking at the scope in which the
2514 structure was declared. */
2515 if (TREE_TYPE (tmp
) != node
2516 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2517 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2519 print_declaration (buffer
, tmp
, spc
+2, flags
);
2520 pp_newline (buffer
);
2522 tmp
= DECL_CHAIN (tmp
);
2526 pp_character (buffer
, '}');
2529 /* Return the priority of the operator CODE.
2531 From lowest to highest precedence with either left-to-right (L-R)
2532 or right-to-left (R-L) associativity]:
2535 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2547 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2548 15 [L-R] fn() [] -> .
2550 unary +, - and * have higher precedence than the corresponding binary
2554 op_code_prio (enum tree_code code
)
2571 case TRUTH_ORIF_EXPR
:
2574 case TRUTH_AND_EXPR
:
2575 case TRUTH_ANDIF_EXPR
:
2582 case TRUTH_XOR_EXPR
:
2599 case UNORDERED_EXPR
:
2612 case WIDEN_SUM_EXPR
:
2614 case POINTER_PLUS_EXPR
:
2618 case VEC_WIDEN_MULT_HI_EXPR
:
2619 case VEC_WIDEN_MULT_LO_EXPR
:
2620 case WIDEN_MULT_EXPR
:
2622 case WIDEN_MULT_PLUS_EXPR
:
2623 case WIDEN_MULT_MINUS_EXPR
:
2625 case TRUNC_DIV_EXPR
:
2627 case FLOOR_DIV_EXPR
:
2628 case ROUND_DIV_EXPR
:
2630 case EXACT_DIV_EXPR
:
2631 case TRUNC_MOD_EXPR
:
2633 case FLOOR_MOD_EXPR
:
2634 case ROUND_MOD_EXPR
:
2638 case TRUTH_NOT_EXPR
:
2640 case POSTINCREMENT_EXPR
:
2641 case POSTDECREMENT_EXPR
:
2642 case PREINCREMENT_EXPR
:
2643 case PREDECREMENT_EXPR
:
2649 case FIX_TRUNC_EXPR
:
2655 case ARRAY_RANGE_REF
:
2659 /* Special expressions. */
2665 case REDUC_MAX_EXPR
:
2666 case REDUC_MIN_EXPR
:
2667 case REDUC_PLUS_EXPR
:
2668 case VEC_LSHIFT_EXPR
:
2669 case VEC_RSHIFT_EXPR
:
2670 case VEC_UNPACK_HI_EXPR
:
2671 case VEC_UNPACK_LO_EXPR
:
2672 case VEC_UNPACK_FLOAT_HI_EXPR
:
2673 case VEC_UNPACK_FLOAT_LO_EXPR
:
2674 case VEC_PACK_TRUNC_EXPR
:
2675 case VEC_PACK_SAT_EXPR
:
2679 /* Return an arbitrarily high precedence to avoid surrounding single
2680 VAR_DECLs in ()s. */
2685 /* Return the priority of the operator OP. */
2688 op_prio (const_tree op
)
2690 enum tree_code code
;
2695 code
= TREE_CODE (op
);
2696 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2697 return op_prio (TREE_OPERAND (op
, 0));
2699 return op_code_prio (code
);
2702 /* Return the symbol associated with operator CODE. */
2705 op_symbol_code (enum tree_code code
)
2713 case TRUTH_ORIF_EXPR
:
2716 case TRUTH_AND_EXPR
:
2717 case TRUTH_ANDIF_EXPR
:
2723 case TRUTH_XOR_EXPR
:
2733 case UNORDERED_EXPR
:
2779 case VEC_LSHIFT_EXPR
:
2782 case VEC_RSHIFT_EXPR
:
2785 case POINTER_PLUS_EXPR
:
2791 case REDUC_PLUS_EXPR
:
2794 case WIDEN_SUM_EXPR
:
2797 case WIDEN_MULT_EXPR
:
2807 case TRUTH_NOT_EXPR
:
2814 case TRUNC_DIV_EXPR
:
2821 case FLOOR_DIV_EXPR
:
2824 case ROUND_DIV_EXPR
:
2827 case EXACT_DIV_EXPR
:
2830 case TRUNC_MOD_EXPR
:
2836 case FLOOR_MOD_EXPR
:
2839 case ROUND_MOD_EXPR
:
2842 case PREDECREMENT_EXPR
:
2845 case PREINCREMENT_EXPR
:
2848 case POSTDECREMENT_EXPR
:
2851 case POSTINCREMENT_EXPR
:
2861 return "<<< ??? >>>";
2865 /* Return the symbol associated with operator OP. */
2868 op_symbol (const_tree op
)
2870 return op_symbol_code (TREE_CODE (op
));
2873 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2874 the gimple_call_fn of a GIMPLE_CALL. */
2877 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
2881 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2882 op0
= TREE_OPERAND (op0
, 0);
2885 switch (TREE_CODE (op0
))
2890 dump_function_name (buffer
, op0
, flags
);
2896 op0
= TREE_OPERAND (op0
, 0);
2900 pp_string (buffer
, "(");
2901 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
2902 pp_string (buffer
, ") ? ");
2903 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
2904 pp_string (buffer
, " : ");
2905 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
2909 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2910 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
2912 dump_generic_node (buffer
, op0
, 0, flags
, false);
2916 if (integer_zerop (TREE_OPERAND (op0
, 1)))
2918 op0
= TREE_OPERAND (op0
, 0);
2925 dump_generic_node (buffer
, op0
, 0, flags
, false);
2933 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2936 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2946 pp_string (buffer
, "\\b");
2950 pp_string (buffer
, "\\f");
2954 pp_string (buffer
, "\\n");
2958 pp_string (buffer
, "\\r");
2962 pp_string (buffer
, "\\t");
2966 pp_string (buffer
, "\\v");
2970 pp_string (buffer
, "\\\\");
2974 pp_string (buffer
, "\\\"");
2978 pp_string (buffer
, "\\'");
2981 /* No need to handle \0; the loop terminates on \0. */
2984 pp_string (buffer
, "\\1");
2988 pp_string (buffer
, "\\2");
2992 pp_string (buffer
, "\\3");
2996 pp_string (buffer
, "\\4");
3000 pp_string (buffer
, "\\5");
3004 pp_string (buffer
, "\\6");
3008 pp_string (buffer
, "\\7");
3012 pp_character (buffer
, str
[0]);
3020 maybe_init_pretty_print (FILE *file
)
3024 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
3025 pp_needs_newline (&buffer
) = true;
3026 pp_translate_identifiers (&buffer
) = false;
3030 buffer
.buffer
->stream
= file
;
3034 newline_and_indent (pretty_printer
*buffer
, int spc
)
3036 pp_newline (buffer
);
3040 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3041 it can also be used in front ends.
3042 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3046 percent_K_format (text_info
*text
)
3048 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
3049 gcc_assert (text
->locus
!= NULL
);
3050 *text
->locus
= EXPR_LOCATION (t
);
3051 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
3052 block
= TREE_BLOCK (t
);
3053 *pp_ti_abstract_origin (text
) = NULL
;
3055 && TREE_CODE (block
) == BLOCK
3056 && BLOCK_ABSTRACT_ORIGIN (block
))
3058 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
3060 while (TREE_CODE (ao
) == BLOCK
3061 && BLOCK_ABSTRACT_ORIGIN (ao
)
3062 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
3063 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
3065 if (TREE_CODE (ao
) == FUNCTION_DECL
)
3067 *pp_ti_abstract_origin (text
) = block
;
3070 block
= BLOCK_SUPERCONTEXT (block
);
3074 /* Print the identifier ID to PRETTY-PRINTER. */
3077 pp_base_tree_identifier (pretty_printer
*pp
, tree id
)
3079 if (pp_translate_identifiers (pp
))
3081 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
3082 pp_append_text (pp
, text
, text
+ strlen (text
));
3085 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
3086 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));
3089 /* A helper function that is used to dump function information before the
3093 dump_function_header (FILE *dump_file
, tree fdecl
, int flags
)
3095 const char *dname
, *aname
;
3096 struct cgraph_node
*node
= cgraph_get_node (fdecl
);
3097 struct function
*fun
= DECL_STRUCT_FUNCTION (fdecl
);
3099 dname
= lang_hooks
.decl_printable_name (fdecl
, 2);
3101 if (DECL_ASSEMBLER_NAME_SET_P (fdecl
))
3102 aname
= (IDENTIFIER_POINTER
3103 (DECL_ASSEMBLER_NAME (fdecl
)));
3105 aname
= "<unset-asm-name>";
3107 fprintf (dump_file
, "\n;; Function %s (%s, funcdef_no=%d",
3108 dname
, aname
, fun
->funcdef_no
);
3109 if (!(flags
& TDF_NOUID
))
3110 fprintf (dump_file
, ", decl_uid=%d", DECL_UID (fdecl
));
3113 fprintf (dump_file
, ", cgraph_uid=%d)%s\n\n", node
->uid
,
3114 node
->frequency
== NODE_FREQUENCY_HOT
3116 : node
->frequency
== NODE_FREQUENCY_UNLIKELY_EXECUTED
3117 ? " (unlikely executed)"
3118 : node
->frequency
== NODE_FREQUENCY_EXECUTED_ONCE
3119 ? " (executed once)"
3123 fprintf (dump_file
, ")\n\n");