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 /* Same pointer types, but ignoring POINTER_TYPE vs.
825 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 0)))
826 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))
827 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 0)))
828 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 1))))
829 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 0)))
830 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 1))))
831 /* Same value types ignoring qualifiers. */
832 && (TYPE_MAIN_VARIANT (TREE_TYPE (node
))
834 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))))
836 if (TREE_CODE (TREE_OPERAND (node
, 0)) != ADDR_EXPR
)
838 pp_string (buffer
, "*");
839 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
843 dump_generic_node (buffer
,
844 TREE_OPERAND (TREE_OPERAND (node
, 0), 0),
851 pp_string (buffer
, "MEM[");
852 pp_string (buffer
, "(");
853 ptype
= TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node
, 1)));
854 dump_generic_node (buffer
, ptype
,
855 spc
, flags
| TDF_SLIM
, false);
856 pp_string (buffer
, ")");
857 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
859 if (!integer_zerop (TREE_OPERAND (node
, 1)))
861 pp_string (buffer
, " + ");
862 dump_generic_node (buffer
, TREE_OPERAND (node
, 1),
865 pp_string (buffer
, "]");
872 const char *sep
= "";
875 pp_string (buffer
, "MEM[");
877 if (TREE_CODE (TMR_BASE (node
)) == ADDR_EXPR
)
879 pp_string (buffer
, sep
);
881 pp_string (buffer
, "symbol: ");
882 dump_generic_node (buffer
, TREE_OPERAND (TMR_BASE (node
), 0),
887 pp_string (buffer
, sep
);
889 pp_string (buffer
, "base: ");
890 dump_generic_node (buffer
, TMR_BASE (node
), spc
, flags
, false);
892 tmp
= TMR_INDEX2 (node
);
895 pp_string (buffer
, sep
);
897 pp_string (buffer
, "base: ");
898 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
900 tmp
= TMR_INDEX (node
);
903 pp_string (buffer
, sep
);
905 pp_string (buffer
, "index: ");
906 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
908 tmp
= TMR_STEP (node
);
911 pp_string (buffer
, sep
);
913 pp_string (buffer
, "step: ");
914 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
916 tmp
= TMR_OFFSET (node
);
919 pp_string (buffer
, sep
);
921 pp_string (buffer
, "offset: ");
922 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
924 pp_string (buffer
, "]");
932 /* Print the innermost component type. */
933 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
934 tmp
= TREE_TYPE (tmp
))
936 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
938 /* Print the dimensions. */
939 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
940 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
946 case QUAL_UNION_TYPE
:
948 unsigned int quals
= TYPE_QUALS (node
);
950 if (quals
& TYPE_QUAL_CONST
)
951 pp_string (buffer
, "const ");
952 if (quals
& TYPE_QUAL_VOLATILE
)
953 pp_string (buffer
, "volatile ");
955 /* Print the name of the structure. */
956 if (TREE_CODE (node
) == RECORD_TYPE
)
957 pp_string (buffer
, "struct ");
958 else if (TREE_CODE (node
) == UNION_TYPE
)
959 pp_string (buffer
, "union ");
961 if (TYPE_NAME (node
))
962 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
963 else if (!(flags
& TDF_SLIM
))
964 /* FIXME: If we eliminate the 'else' above and attempt
965 to show the fields for named types, we may get stuck
966 following a cycle of pointers to structs. The alleged
967 self-reference check in print_struct_decl will not detect
968 cycles involving more than one pointer or struct type. */
969 print_struct_decl (buffer
, node
, spc
, flags
);
978 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
980 /* In the case of a pointer, one may want to divide by the
981 size of the pointed-to type. Unfortunately, this not
982 straightforward. The C front-end maps expressions
987 in such a way that the two INTEGER_CST nodes for "5" have
988 different values but identical types. In the latter
989 case, the 5 is multiplied by sizeof (int) in c-common.c
990 (pointer_int_sum) to convert it to a byte address, and
991 yet the type of the node is left unchanged. Argh. What
992 is consistent though is that the number value corresponds
993 to bytes (UNITS) offset.
995 NB: Neither of the following divisors can be trivially
996 used to recover the original literal:
998 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
999 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1000 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1001 pp_string (buffer
, "B"); /* pseudo-unit */
1003 else if (! host_integerp (node
, 0))
1006 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (val
);
1007 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (val
);
1009 if (tree_int_cst_sgn (val
) < 0)
1011 pp_character (buffer
, '-');
1012 high
= ~high
+ !low
;
1015 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
1017 sprintf (pp_buffer (buffer
)->digit_buffer
,
1018 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
1019 (unsigned HOST_WIDE_INT
) high
, low
);
1020 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
1023 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1027 /* Code copied from print_node. */
1030 if (TREE_OVERFLOW (node
))
1031 pp_string (buffer
, " overflow");
1033 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1034 d
= TREE_REAL_CST (node
);
1035 if (REAL_VALUE_ISINF (d
))
1036 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
1037 else if (REAL_VALUE_ISNAN (d
))
1038 pp_string (buffer
, " Nan");
1042 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
1043 pp_string (buffer
, string
);
1048 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
1049 pp_string (buffer
, "0x");
1050 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
1051 output_formatted_integer (buffer
, "%02x", *p
++);
1060 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
1061 pp_string (buffer
, string
);
1066 pp_string (buffer
, "__complex__ (");
1067 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
1068 pp_string (buffer
, ", ");
1069 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
1070 pp_string (buffer
, ")");
1074 pp_string (buffer
, "\"");
1075 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
1076 pp_string (buffer
, "\"");
1082 pp_string (buffer
, "{ ");
1083 for (elt
= TREE_VECTOR_CST_ELTS (node
); elt
; elt
= TREE_CHAIN (elt
))
1085 dump_generic_node (buffer
, TREE_VALUE (elt
), spc
, flags
, false);
1086 if (TREE_CHAIN (elt
))
1087 pp_string (buffer
, ", ");
1089 pp_string (buffer
, " }");
1095 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1097 if (TREE_CODE (node
) == METHOD_TYPE
)
1099 if (TYPE_METHOD_BASETYPE (node
))
1100 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
1103 pp_string (buffer
, "<null method basetype>");
1104 pp_string (buffer
, "::");
1106 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1107 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1108 else if (flags
& TDF_NOUID
)
1109 pp_printf (buffer
, "<Txxxx>");
1111 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1112 dump_function_declaration (buffer
, node
, spc
, flags
);
1117 dump_decl_name (buffer
, node
, flags
);
1121 if (DECL_NAME (node
))
1122 dump_decl_name (buffer
, node
, flags
);
1123 else if (LABEL_DECL_UID (node
) != -1)
1124 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1127 if (flags
& TDF_NOUID
)
1128 pp_string (buffer
, "<D.xxxx>");
1130 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1135 if (DECL_IS_BUILTIN (node
))
1137 /* Don't print the declaration of built-in types. */
1140 if (DECL_NAME (node
))
1141 dump_decl_name (buffer
, node
, flags
);
1142 else if (TYPE_NAME (TREE_TYPE (node
)) != node
)
1144 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1145 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1146 && TYPE_METHODS (TREE_TYPE (node
)))
1148 /* The type is a c++ class: all structures have at least
1150 pp_string (buffer
, "class ");
1151 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1156 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1157 ? "union" : "struct "));
1158 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1162 pp_string (buffer
, "<anon>");
1168 case DEBUG_EXPR_DECL
:
1169 case NAMESPACE_DECL
:
1170 dump_decl_name (buffer
, node
, flags
);
1174 pp_string (buffer
, "<retval>");
1178 op0
= TREE_OPERAND (node
, 0);
1181 && (TREE_CODE (op0
) == INDIRECT_REF
1182 || (TREE_CODE (op0
) == MEM_REF
1183 && TREE_CODE (TREE_OPERAND (op0
, 0)) != ADDR_EXPR
1184 && integer_zerop (TREE_OPERAND (op0
, 1))
1185 /* Dump the types of INTEGER_CSTs explicitly, for we
1186 can't infer them and MEM_ATTR caching will share
1187 MEM_REFs with differently-typed op0s. */
1188 && TREE_CODE (TREE_OPERAND (op0
, 0)) != INTEGER_CST
1189 /* Same pointer types, but ignoring POINTER_TYPE vs.
1191 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1192 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1193 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1194 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1195 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1196 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1197 /* Same value types ignoring qualifiers. */
1198 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0
))
1199 == TYPE_MAIN_VARIANT
1200 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))))))
1202 op0
= TREE_OPERAND (op0
, 0);
1205 if (op_prio (op0
) < op_prio (node
))
1206 pp_character (buffer
, '(');
1207 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1208 if (op_prio (op0
) < op_prio (node
))
1209 pp_character (buffer
, ')');
1210 pp_string (buffer
, str
);
1211 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1212 op0
= component_ref_field_offset (node
);
1213 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1215 pp_string (buffer
, "{off: ");
1216 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1217 pp_character (buffer
, '}');
1222 pp_string (buffer
, "BIT_FIELD_REF <");
1223 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1224 pp_string (buffer
, ", ");
1225 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1226 pp_string (buffer
, ", ");
1227 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1228 pp_string (buffer
, ">");
1232 case ARRAY_RANGE_REF
:
1233 op0
= TREE_OPERAND (node
, 0);
1234 if (op_prio (op0
) < op_prio (node
))
1235 pp_character (buffer
, '(');
1236 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1237 if (op_prio (op0
) < op_prio (node
))
1238 pp_character (buffer
, ')');
1239 pp_character (buffer
, '[');
1240 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1241 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1242 pp_string (buffer
, " ...");
1243 pp_character (buffer
, ']');
1245 op0
= array_ref_low_bound (node
);
1246 op1
= array_ref_element_size (node
);
1248 if (!integer_zerop (op0
)
1249 || TREE_OPERAND (node
, 2)
1250 || TREE_OPERAND (node
, 3))
1252 pp_string (buffer
, "{lb: ");
1253 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1254 pp_string (buffer
, " sz: ");
1255 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1256 pp_character (buffer
, '}');
1262 unsigned HOST_WIDE_INT ix
;
1264 bool is_struct_init
= false;
1265 bool is_array_init
= false;
1266 double_int curidx
= double_int_zero
;
1267 pp_character (buffer
, '{');
1268 if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1269 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1270 is_struct_init
= true;
1271 else if (TREE_CODE (TREE_TYPE (node
)) == ARRAY_TYPE
1272 && TYPE_DOMAIN (TREE_TYPE (node
))
1273 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)))
1274 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
))))
1277 tree minv
= TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)));
1278 is_array_init
= true;
1279 curidx
= tree_to_double_int (minv
);
1281 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1287 pp_character (buffer
, '.');
1288 dump_generic_node (buffer
, field
, spc
, flags
, false);
1289 pp_character (buffer
, '=');
1291 else if (is_array_init
1292 && (TREE_CODE (field
) != INTEGER_CST
1293 || !double_int_equal_p (tree_to_double_int (field
),
1296 pp_character (buffer
, '[');
1297 if (TREE_CODE (field
) == RANGE_EXPR
)
1299 dump_generic_node (buffer
, TREE_OPERAND (field
, 0), spc
,
1301 pp_string (buffer
, " ... ");
1302 dump_generic_node (buffer
, TREE_OPERAND (field
, 1), spc
,
1304 if (TREE_CODE (TREE_OPERAND (field
, 1)) == INTEGER_CST
)
1305 curidx
= tree_to_double_int (TREE_OPERAND (field
, 1));
1308 dump_generic_node (buffer
, field
, spc
, flags
, false);
1309 if (TREE_CODE (field
) == INTEGER_CST
)
1310 curidx
= tree_to_double_int (field
);
1311 pp_string (buffer
, "]=");
1315 curidx
= double_int_add (curidx
, double_int_one
);
1316 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1317 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1318 val
= TREE_OPERAND (val
, 0);
1319 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1320 dump_decl_name (buffer
, val
, flags
);
1322 dump_generic_node (buffer
, val
, spc
, flags
, false);
1323 if (ix
!= VEC_length (constructor_elt
, CONSTRUCTOR_ELTS (node
)) - 1)
1325 pp_character (buffer
, ',');
1329 pp_character (buffer
, '}');
1336 if (flags
& TDF_SLIM
)
1338 pp_string (buffer
, "<COMPOUND_EXPR>");
1342 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1343 spc
, flags
, !(flags
& TDF_SLIM
));
1344 if (flags
& TDF_SLIM
)
1345 newline_and_indent (buffer
, spc
);
1348 pp_character (buffer
, ',');
1352 for (tp
= &TREE_OPERAND (node
, 1);
1353 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1354 tp
= &TREE_OPERAND (*tp
, 1))
1356 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1357 spc
, flags
, !(flags
& TDF_SLIM
));
1358 if (flags
& TDF_SLIM
)
1359 newline_and_indent (buffer
, spc
);
1362 pp_character (buffer
, ',');
1367 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1371 case STATEMENT_LIST
:
1373 tree_stmt_iterator si
;
1376 if (flags
& TDF_SLIM
)
1378 pp_string (buffer
, "<STATEMENT_LIST>");
1382 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1385 newline_and_indent (buffer
, spc
);
1388 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1395 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1398 pp_character (buffer
, '=');
1399 if (TREE_CODE (node
) == MODIFY_EXPR
1400 && MOVE_NONTEMPORAL (node
))
1401 pp_string (buffer
, "{nt}");
1403 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1408 pp_string (buffer
, "TARGET_EXPR <");
1409 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1410 pp_character (buffer
, ',');
1412 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1413 pp_character (buffer
, '>');
1417 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1422 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1424 pp_string (buffer
, "if (");
1425 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1426 pp_character (buffer
, ')');
1427 /* The lowered cond_exprs should always be printed in full. */
1428 if (COND_EXPR_THEN (node
)
1429 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1430 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1431 && COND_EXPR_ELSE (node
)
1432 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1433 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1436 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1438 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1440 pp_string (buffer
, " else ");
1441 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1445 else if (!(flags
& TDF_SLIM
))
1447 /* Output COND_EXPR_THEN. */
1448 if (COND_EXPR_THEN (node
))
1450 newline_and_indent (buffer
, spc
+2);
1451 pp_character (buffer
, '{');
1452 newline_and_indent (buffer
, spc
+4);
1453 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1455 newline_and_indent (buffer
, spc
+2);
1456 pp_character (buffer
, '}');
1459 /* Output COND_EXPR_ELSE. */
1460 if (COND_EXPR_ELSE (node
)
1461 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1463 newline_and_indent (buffer
, spc
);
1464 pp_string (buffer
, "else");
1465 newline_and_indent (buffer
, spc
+2);
1466 pp_character (buffer
, '{');
1467 newline_and_indent (buffer
, spc
+4);
1468 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1470 newline_and_indent (buffer
, spc
+2);
1471 pp_character (buffer
, '}');
1478 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1480 pp_character (buffer
, '?');
1482 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1484 pp_character (buffer
, ':');
1486 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1491 pp_character (buffer
, '{');
1492 if (!(flags
& TDF_SLIM
))
1494 if (BIND_EXPR_VARS (node
))
1496 pp_newline (buffer
);
1498 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= DECL_CHAIN (op0
))
1500 print_declaration (buffer
, op0
, spc
+2, flags
);
1501 pp_newline (buffer
);
1505 newline_and_indent (buffer
, spc
+2);
1506 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1507 newline_and_indent (buffer
, spc
);
1508 pp_character (buffer
, '}');
1514 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1516 /* Print parameters. */
1518 pp_character (buffer
, '(');
1521 call_expr_arg_iterator iter
;
1522 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1524 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1525 if (more_call_expr_args_p (&iter
))
1527 pp_character (buffer
, ',');
1532 if (CALL_EXPR_VA_ARG_PACK (node
))
1534 if (call_expr_nargs (node
) > 0)
1536 pp_character (buffer
, ',');
1539 pp_string (buffer
, "__builtin_va_arg_pack ()");
1541 pp_character (buffer
, ')');
1543 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1546 pp_string (buffer
, " [static-chain: ");
1547 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1548 pp_character (buffer
, ']');
1551 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1552 pp_string (buffer
, " [return slot optimization]");
1553 if (CALL_EXPR_TAILCALL (node
))
1554 pp_string (buffer
, " [tail call]");
1557 case WITH_CLEANUP_EXPR
:
1561 case CLEANUP_POINT_EXPR
:
1562 pp_string (buffer
, "<<cleanup_point ");
1563 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1564 pp_string (buffer
, ">>");
1567 case PLACEHOLDER_EXPR
:
1568 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1569 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1570 pp_character (buffer
, '>');
1573 /* Binary arithmetic and logic expressions. */
1574 case WIDEN_SUM_EXPR
:
1575 case WIDEN_MULT_EXPR
:
1578 case POINTER_PLUS_EXPR
:
1580 case TRUNC_DIV_EXPR
:
1582 case FLOOR_DIV_EXPR
:
1583 case ROUND_DIV_EXPR
:
1584 case TRUNC_MOD_EXPR
:
1586 case FLOOR_MOD_EXPR
:
1587 case ROUND_MOD_EXPR
:
1589 case EXACT_DIV_EXPR
:
1594 case VEC_LSHIFT_EXPR
:
1595 case VEC_RSHIFT_EXPR
:
1599 case TRUTH_ANDIF_EXPR
:
1600 case TRUTH_ORIF_EXPR
:
1601 case TRUTH_AND_EXPR
:
1603 case TRUTH_XOR_EXPR
:
1617 case UNORDERED_EXPR
:
1619 const char *op
= op_symbol (node
);
1620 op0
= TREE_OPERAND (node
, 0);
1621 op1
= TREE_OPERAND (node
, 1);
1623 /* When the operands are expressions with less priority,
1624 keep semantics of the tree representation. */
1625 if (op_prio (op0
) <= op_prio (node
))
1627 pp_character (buffer
, '(');
1628 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1629 pp_character (buffer
, ')');
1632 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1635 pp_string (buffer
, op
);
1638 /* When the operands are expressions with less priority,
1639 keep semantics of the tree representation. */
1640 if (op_prio (op1
) <= op_prio (node
))
1642 pp_character (buffer
, '(');
1643 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1644 pp_character (buffer
, ')');
1647 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1651 /* Unary arithmetic and logic expressions. */
1654 case TRUTH_NOT_EXPR
:
1656 case PREDECREMENT_EXPR
:
1657 case PREINCREMENT_EXPR
:
1659 if (TREE_CODE (node
) == ADDR_EXPR
1660 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1661 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1662 ; /* Do not output '&' for strings and function pointers. */
1664 pp_string (buffer
, op_symbol (node
));
1666 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1668 pp_character (buffer
, '(');
1669 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1670 pp_character (buffer
, ')');
1673 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1676 case POSTDECREMENT_EXPR
:
1677 case POSTINCREMENT_EXPR
:
1678 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1680 pp_character (buffer
, '(');
1681 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1682 pp_character (buffer
, ')');
1685 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1686 pp_string (buffer
, op_symbol (node
));
1690 pp_string (buffer
, "MIN_EXPR <");
1691 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1692 pp_string (buffer
, ", ");
1693 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1694 pp_character (buffer
, '>');
1698 pp_string (buffer
, "MAX_EXPR <");
1699 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1700 pp_string (buffer
, ", ");
1701 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1702 pp_character (buffer
, '>');
1706 pp_string (buffer
, "ABS_EXPR <");
1707 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1708 pp_character (buffer
, '>');
1715 case ADDR_SPACE_CONVERT_EXPR
:
1716 case FIXED_CONVERT_EXPR
:
1717 case FIX_TRUNC_EXPR
:
1720 type
= TREE_TYPE (node
);
1721 op0
= TREE_OPERAND (node
, 0);
1722 if (type
!= TREE_TYPE (op0
))
1724 pp_character (buffer
, '(');
1725 dump_generic_node (buffer
, type
, spc
, flags
, false);
1726 pp_string (buffer
, ") ");
1728 if (op_prio (op0
) < op_prio (node
))
1729 pp_character (buffer
, '(');
1730 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1731 if (op_prio (op0
) < op_prio (node
))
1732 pp_character (buffer
, ')');
1735 case VIEW_CONVERT_EXPR
:
1736 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1737 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1738 pp_string (buffer
, ">(");
1739 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1740 pp_character (buffer
, ')');
1744 pp_string (buffer
, "((");
1745 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1746 pp_string (buffer
, "))");
1749 case NON_LVALUE_EXPR
:
1750 pp_string (buffer
, "NON_LVALUE_EXPR <");
1751 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1752 pp_character (buffer
, '>');
1756 pp_string (buffer
, "SAVE_EXPR <");
1757 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1758 pp_character (buffer
, '>');
1762 pp_string (buffer
, "COMPLEX_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
, ">");
1770 pp_string (buffer
, "CONJ_EXPR <");
1771 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1772 pp_string (buffer
, ">");
1776 pp_string (buffer
, "REALPART_EXPR <");
1777 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1778 pp_string (buffer
, ">");
1782 pp_string (buffer
, "IMAGPART_EXPR <");
1783 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1784 pp_string (buffer
, ">");
1788 pp_string (buffer
, "VA_ARG_EXPR <");
1789 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1790 pp_string (buffer
, ">");
1793 case TRY_FINALLY_EXPR
:
1794 case TRY_CATCH_EXPR
:
1795 pp_string (buffer
, "try");
1796 newline_and_indent (buffer
, spc
+2);
1797 pp_string (buffer
, "{");
1798 newline_and_indent (buffer
, spc
+4);
1799 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
1800 newline_and_indent (buffer
, spc
+2);
1801 pp_string (buffer
, "}");
1802 newline_and_indent (buffer
, spc
);
1804 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
1805 newline_and_indent (buffer
, spc
+2);
1806 pp_string (buffer
, "{");
1807 newline_and_indent (buffer
, spc
+4);
1808 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
1809 newline_and_indent (buffer
, spc
+2);
1810 pp_string (buffer
, "}");
1815 pp_string (buffer
, "catch (");
1816 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
1817 pp_string (buffer
, ")");
1818 newline_and_indent (buffer
, spc
+2);
1819 pp_string (buffer
, "{");
1820 newline_and_indent (buffer
, spc
+4);
1821 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
1822 newline_and_indent (buffer
, spc
+2);
1823 pp_string (buffer
, "}");
1827 case EH_FILTER_EXPR
:
1828 pp_string (buffer
, "<<<eh_filter (");
1829 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
1830 pp_string (buffer
, ")>>>");
1831 newline_and_indent (buffer
, spc
+2);
1832 pp_string (buffer
, "{");
1833 newline_and_indent (buffer
, spc
+4);
1834 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
1835 newline_and_indent (buffer
, spc
+2);
1836 pp_string (buffer
, "}");
1841 op0
= TREE_OPERAND (node
, 0);
1842 /* If this is for break or continue, don't bother printing it. */
1843 if (DECL_NAME (op0
))
1845 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1846 if (strcmp (name
, "break") == 0
1847 || strcmp (name
, "continue") == 0)
1850 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1851 pp_character (buffer
, ':');
1852 if (DECL_NONLOCAL (op0
))
1853 pp_string (buffer
, " [non-local]");
1857 pp_string (buffer
, "while (1)");
1858 if (!(flags
& TDF_SLIM
))
1860 newline_and_indent (buffer
, spc
+2);
1861 pp_character (buffer
, '{');
1862 newline_and_indent (buffer
, spc
+4);
1863 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
1864 newline_and_indent (buffer
, spc
+2);
1865 pp_character (buffer
, '}');
1871 pp_string (buffer
, "// predicted ");
1872 if (PREDICT_EXPR_OUTCOME (node
))
1873 pp_string (buffer
, "likely by ");
1875 pp_string (buffer
, "unlikely by ");
1876 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
1877 pp_string (buffer
, " predictor.");
1881 pp_string (buffer
, "return");
1882 op0
= TREE_OPERAND (node
, 0);
1886 if (TREE_CODE (op0
) == MODIFY_EXPR
)
1887 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
1890 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1895 pp_string (buffer
, "if (");
1896 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1897 pp_string (buffer
, ") break");
1901 pp_string (buffer
, "switch (");
1902 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
1903 pp_character (buffer
, ')');
1904 if (!(flags
& TDF_SLIM
))
1906 newline_and_indent (buffer
, spc
+2);
1907 pp_character (buffer
, '{');
1908 if (SWITCH_BODY (node
))
1910 newline_and_indent (buffer
, spc
+4);
1911 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
1916 tree vec
= SWITCH_LABELS (node
);
1917 size_t i
, n
= TREE_VEC_LENGTH (vec
);
1918 for (i
= 0; i
< n
; ++i
)
1920 tree elt
= TREE_VEC_ELT (vec
, i
);
1921 newline_and_indent (buffer
, spc
+4);
1924 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
1925 pp_string (buffer
, " goto ");
1926 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
1928 pp_semicolon (buffer
);
1931 pp_string (buffer
, "case ???: goto ???;");
1934 newline_and_indent (buffer
, spc
+2);
1935 pp_character (buffer
, '}');
1941 op0
= GOTO_DESTINATION (node
);
1942 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
1944 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
1945 if (strcmp (name
, "break") == 0
1946 || strcmp (name
, "continue") == 0)
1948 pp_string (buffer
, name
);
1952 pp_string (buffer
, "goto ");
1953 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1957 pp_string (buffer
, "__asm__");
1958 if (ASM_VOLATILE_P (node
))
1959 pp_string (buffer
, " __volatile__");
1960 pp_character (buffer
, '(');
1961 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
1962 pp_character (buffer
, ':');
1963 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
1964 pp_character (buffer
, ':');
1965 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
1966 if (ASM_CLOBBERS (node
))
1968 pp_character (buffer
, ':');
1969 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
1971 pp_string (buffer
, ")");
1974 case CASE_LABEL_EXPR
:
1975 if (CASE_LOW (node
) && CASE_HIGH (node
))
1977 pp_string (buffer
, "case ");
1978 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1979 pp_string (buffer
, " ... ");
1980 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
1982 else if (CASE_LOW (node
))
1984 pp_string (buffer
, "case ");
1985 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
1988 pp_string (buffer
, "default");
1989 pp_character (buffer
, ':');
1993 pp_string (buffer
, "OBJ_TYPE_REF(");
1994 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
1995 pp_character (buffer
, ';');
1996 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
1997 pp_character (buffer
, '-');
1998 pp_character (buffer
, '>');
1999 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
2000 pp_character (buffer
, ')');
2004 dump_generic_node (buffer
, SSA_NAME_VAR (node
), spc
, flags
, false);
2005 pp_string (buffer
, "_");
2006 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
2007 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
2008 pp_string (buffer
, "(ab)");
2009 else if (SSA_NAME_IS_DEFAULT_DEF (node
))
2010 pp_string (buffer
, "(D)");
2013 case WITH_SIZE_EXPR
:
2014 pp_string (buffer
, "WITH_SIZE_EXPR <");
2015 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2016 pp_string (buffer
, ", ");
2017 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2018 pp_string (buffer
, ">");
2022 pp_string (buffer
, "ASSERT_EXPR <");
2023 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
2024 pp_string (buffer
, ", ");
2025 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
2026 pp_string (buffer
, ">");
2030 pp_string (buffer
, "scev_known");
2033 case SCEV_NOT_KNOWN
:
2034 pp_string (buffer
, "scev_not_known");
2037 case POLYNOMIAL_CHREC
:
2038 pp_string (buffer
, "{");
2039 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
2040 pp_string (buffer
, ", +, ");
2041 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
2042 pp_string (buffer
, "}_");
2043 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
2047 case REALIGN_LOAD_EXPR
:
2048 pp_string (buffer
, "REALIGN_LOAD <");
2049 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2050 pp_string (buffer
, ", ");
2051 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2052 pp_string (buffer
, ", ");
2053 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2054 pp_string (buffer
, ">");
2058 pp_string (buffer
, " VEC_COND_EXPR < ");
2059 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2060 pp_string (buffer
, " , ");
2061 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2062 pp_string (buffer
, " , ");
2063 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2064 pp_string (buffer
, " > ");
2068 pp_string (buffer
, " DOT_PROD_EXPR < ");
2069 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2070 pp_string (buffer
, ", ");
2071 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2072 pp_string (buffer
, ", ");
2073 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2074 pp_string (buffer
, " > ");
2077 case WIDEN_MULT_PLUS_EXPR
:
2078 pp_string (buffer
, " WIDEN_MULT_PLUS_EXPR < ");
2079 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2080 pp_string (buffer
, ", ");
2081 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2082 pp_string (buffer
, ", ");
2083 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2084 pp_string (buffer
, " > ");
2087 case WIDEN_MULT_MINUS_EXPR
:
2088 pp_string (buffer
, " WIDEN_MULT_MINUS_EXPR < ");
2089 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2090 pp_string (buffer
, ", ");
2091 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2092 pp_string (buffer
, ", ");
2093 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2094 pp_string (buffer
, " > ");
2098 pp_string (buffer
, " FMA_EXPR < ");
2099 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2100 pp_string (buffer
, ", ");
2101 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2102 pp_string (buffer
, ", ");
2103 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2104 pp_string (buffer
, " > ");
2108 pp_string (buffer
, "#pragma omp parallel");
2109 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
2112 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
2114 newline_and_indent (buffer
, spc
+ 2);
2115 pp_character (buffer
, '{');
2116 newline_and_indent (buffer
, spc
+ 4);
2117 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
2118 newline_and_indent (buffer
, spc
+ 2);
2119 pp_character (buffer
, '}');
2125 pp_string (buffer
, "#pragma omp task");
2126 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
2130 pp_string (buffer
, "#pragma omp for");
2131 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
2133 if (!(flags
& TDF_SLIM
))
2137 if (OMP_FOR_PRE_BODY (node
))
2139 newline_and_indent (buffer
, spc
+ 2);
2140 pp_character (buffer
, '{');
2142 newline_and_indent (buffer
, spc
);
2143 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
2147 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
2150 newline_and_indent (buffer
, spc
);
2151 pp_string (buffer
, "for (");
2152 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
2154 pp_string (buffer
, "; ");
2155 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
2157 pp_string (buffer
, "; ");
2158 dump_generic_node (buffer
, TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
2160 pp_string (buffer
, ")");
2162 if (OMP_FOR_BODY (node
))
2164 newline_and_indent (buffer
, spc
+ 2);
2165 pp_character (buffer
, '{');
2166 newline_and_indent (buffer
, spc
+ 4);
2167 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
2169 newline_and_indent (buffer
, spc
+ 2);
2170 pp_character (buffer
, '}');
2172 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
2173 if (OMP_FOR_PRE_BODY (node
))
2176 newline_and_indent (buffer
, spc
+ 2);
2177 pp_character (buffer
, '}');
2184 pp_string (buffer
, "#pragma omp sections");
2185 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2189 pp_string (buffer
, "#pragma omp section");
2193 pp_string (buffer
, "#pragma omp master");
2197 pp_string (buffer
, "#pragma omp ordered");
2201 pp_string (buffer
, "#pragma omp critical");
2202 if (OMP_CRITICAL_NAME (node
))
2205 pp_character (buffer
, '(');
2206 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2208 pp_character (buffer
, ')');
2213 pp_string (buffer
, "#pragma omp atomic");
2214 newline_and_indent (buffer
, spc
+ 2);
2215 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2217 pp_character (buffer
, '=');
2219 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2222 case OMP_ATOMIC_READ
:
2223 pp_string (buffer
, "#pragma omp atomic read");
2224 newline_and_indent (buffer
, spc
+ 2);
2225 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2229 case OMP_ATOMIC_CAPTURE_OLD
:
2230 case OMP_ATOMIC_CAPTURE_NEW
:
2231 pp_string (buffer
, "#pragma omp atomic capture");
2232 newline_and_indent (buffer
, spc
+ 2);
2233 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2235 pp_character (buffer
, '=');
2237 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2241 pp_string (buffer
, "#pragma omp single");
2242 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2246 dump_omp_clause (buffer
, node
, spc
, flags
);
2250 case REDUC_MAX_EXPR
:
2251 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2252 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2253 pp_string (buffer
, " > ");
2256 case REDUC_MIN_EXPR
:
2257 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2258 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2259 pp_string (buffer
, " > ");
2262 case REDUC_PLUS_EXPR
:
2263 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2264 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2265 pp_string (buffer
, " > ");
2268 case VEC_WIDEN_MULT_HI_EXPR
:
2269 pp_string (buffer
, " VEC_WIDEN_MULT_HI_EXPR < ");
2270 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2271 pp_string (buffer
, ", ");
2272 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2273 pp_string (buffer
, " > ");
2276 case VEC_WIDEN_MULT_LO_EXPR
:
2277 pp_string (buffer
, " VEC_WIDEN_MULT_LO_EXPR < ");
2278 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2279 pp_string (buffer
, ", ");
2280 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2281 pp_string (buffer
, " > ");
2284 case VEC_UNPACK_HI_EXPR
:
2285 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2286 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2287 pp_string (buffer
, " > ");
2290 case VEC_UNPACK_LO_EXPR
:
2291 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2292 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2293 pp_string (buffer
, " > ");
2296 case VEC_UNPACK_FLOAT_HI_EXPR
:
2297 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2298 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2299 pp_string (buffer
, " > ");
2302 case VEC_UNPACK_FLOAT_LO_EXPR
:
2303 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2304 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2305 pp_string (buffer
, " > ");
2308 case VEC_PACK_TRUNC_EXPR
:
2309 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2310 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2311 pp_string (buffer
, ", ");
2312 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2313 pp_string (buffer
, " > ");
2316 case VEC_PACK_SAT_EXPR
:
2317 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2318 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2319 pp_string (buffer
, ", ");
2320 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2321 pp_string (buffer
, " > ");
2324 case VEC_PACK_FIX_TRUNC_EXPR
:
2325 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2326 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2327 pp_string (buffer
, ", ");
2328 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2329 pp_string (buffer
, " > ");
2333 dump_block_node (buffer
, node
, spc
, flags
);
2336 case VEC_EXTRACT_EVEN_EXPR
:
2337 pp_string (buffer
, " VEC_EXTRACT_EVEN_EXPR < ");
2338 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2339 pp_string (buffer
, ", ");
2340 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2341 pp_string (buffer
, " > ");
2344 case VEC_EXTRACT_ODD_EXPR
:
2345 pp_string (buffer
, " VEC_EXTRACT_ODD_EXPR < ");
2346 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2347 pp_string (buffer
, ", ");
2348 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2349 pp_string (buffer
, " > ");
2352 case VEC_INTERLEAVE_HIGH_EXPR
:
2353 pp_string (buffer
, " VEC_INTERLEAVE_HIGH_EXPR < ");
2354 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2355 pp_string (buffer
, ", ");
2356 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2357 pp_string (buffer
, " > ");
2360 case VEC_INTERLEAVE_LOW_EXPR
:
2361 pp_string (buffer
, " VEC_INTERLEAVE_LOW_EXPR < ");
2362 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2363 pp_string (buffer
, ", ");
2364 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2365 pp_string (buffer
, " > ");
2372 if (is_stmt
&& is_expr
)
2373 pp_semicolon (buffer
);
2375 /* If we're building a diagnostic, the formatted text will be written
2376 into BUFFER's stream by the caller; otherwise, write it now. */
2377 if (!(flags
& TDF_DIAGNOSTIC
))
2378 pp_write_text_to_stream (buffer
);
2383 /* Print the declaration of a variable. */
2386 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2390 if (TREE_CODE (t
) == TYPE_DECL
)
2391 pp_string (buffer
, "typedef ");
2393 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2394 pp_string (buffer
, "register ");
2396 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2397 pp_string (buffer
, "extern ");
2398 else if (TREE_STATIC (t
))
2399 pp_string (buffer
, "static ");
2401 /* Print the type and name. */
2402 if (TREE_TYPE (t
) && TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2406 /* Print array's type. */
2407 tmp
= TREE_TYPE (t
);
2408 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2409 tmp
= TREE_TYPE (tmp
);
2410 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2412 /* Print variable's name. */
2414 dump_generic_node (buffer
, t
, spc
, flags
, false);
2416 /* Print the dimensions. */
2417 tmp
= TREE_TYPE (t
);
2418 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2420 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2421 tmp
= TREE_TYPE (tmp
);
2424 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2426 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2428 dump_decl_name (buffer
, t
, flags
);
2429 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2433 /* Print type declaration. */
2434 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2436 /* Print variable's name. */
2438 dump_generic_node (buffer
, t
, spc
, flags
, false);
2441 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2443 pp_string (buffer
, " __asm__ ");
2444 pp_character (buffer
, '(');
2445 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2446 pp_character (buffer
, ')');
2449 /* The initial value of a function serves to determine whether the function
2450 is declared or defined. So the following does not apply to function
2452 if (TREE_CODE (t
) != FUNCTION_DECL
)
2454 /* Print the initial value. */
2455 if (DECL_INITIAL (t
))
2458 pp_character (buffer
, '=');
2460 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2464 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2466 pp_string (buffer
, " [value-expr: ");
2467 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2468 pp_character (buffer
, ']');
2471 pp_character (buffer
, ';');
2475 /* Prints a structure: name, fields, and methods.
2476 FIXME: Still incomplete. */
2479 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2481 /* Print the name of the structure. */
2482 if (TYPE_NAME (node
))
2485 if (TREE_CODE (node
) == RECORD_TYPE
)
2486 pp_string (buffer
, "struct ");
2487 else if ((TREE_CODE (node
) == UNION_TYPE
2488 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2489 pp_string (buffer
, "union ");
2491 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2494 /* Print the contents of the structure. */
2495 pp_newline (buffer
);
2497 pp_character (buffer
, '{');
2498 pp_newline (buffer
);
2500 /* Print the fields of the structure. */
2503 tmp
= TYPE_FIELDS (node
);
2506 /* Avoid to print recursively the structure. */
2507 /* FIXME : Not implemented correctly...,
2508 what about the case when we have a cycle in the contain graph? ...
2509 Maybe this could be solved by looking at the scope in which the
2510 structure was declared. */
2511 if (TREE_TYPE (tmp
) != node
2512 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2513 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2515 print_declaration (buffer
, tmp
, spc
+2, flags
);
2516 pp_newline (buffer
);
2518 tmp
= DECL_CHAIN (tmp
);
2522 pp_character (buffer
, '}');
2525 /* Return the priority of the operator CODE.
2527 From lowest to highest precedence with either left-to-right (L-R)
2528 or right-to-left (R-L) associativity]:
2531 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2543 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2544 15 [L-R] fn() [] -> .
2546 unary +, - and * have higher precedence than the corresponding binary
2550 op_code_prio (enum tree_code code
)
2567 case TRUTH_ORIF_EXPR
:
2570 case TRUTH_AND_EXPR
:
2571 case TRUTH_ANDIF_EXPR
:
2578 case TRUTH_XOR_EXPR
:
2595 case UNORDERED_EXPR
:
2608 case WIDEN_SUM_EXPR
:
2610 case POINTER_PLUS_EXPR
:
2614 case VEC_WIDEN_MULT_HI_EXPR
:
2615 case VEC_WIDEN_MULT_LO_EXPR
:
2616 case WIDEN_MULT_EXPR
:
2618 case WIDEN_MULT_PLUS_EXPR
:
2619 case WIDEN_MULT_MINUS_EXPR
:
2621 case TRUNC_DIV_EXPR
:
2623 case FLOOR_DIV_EXPR
:
2624 case ROUND_DIV_EXPR
:
2626 case EXACT_DIV_EXPR
:
2627 case TRUNC_MOD_EXPR
:
2629 case FLOOR_MOD_EXPR
:
2630 case ROUND_MOD_EXPR
:
2634 case TRUTH_NOT_EXPR
:
2636 case POSTINCREMENT_EXPR
:
2637 case POSTDECREMENT_EXPR
:
2638 case PREINCREMENT_EXPR
:
2639 case PREDECREMENT_EXPR
:
2645 case FIX_TRUNC_EXPR
:
2651 case ARRAY_RANGE_REF
:
2655 /* Special expressions. */
2661 case REDUC_MAX_EXPR
:
2662 case REDUC_MIN_EXPR
:
2663 case REDUC_PLUS_EXPR
:
2664 case VEC_LSHIFT_EXPR
:
2665 case VEC_RSHIFT_EXPR
:
2666 case VEC_UNPACK_HI_EXPR
:
2667 case VEC_UNPACK_LO_EXPR
:
2668 case VEC_UNPACK_FLOAT_HI_EXPR
:
2669 case VEC_UNPACK_FLOAT_LO_EXPR
:
2670 case VEC_PACK_TRUNC_EXPR
:
2671 case VEC_PACK_SAT_EXPR
:
2675 /* Return an arbitrarily high precedence to avoid surrounding single
2676 VAR_DECLs in ()s. */
2681 /* Return the priority of the operator OP. */
2684 op_prio (const_tree op
)
2686 enum tree_code code
;
2691 code
= TREE_CODE (op
);
2692 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2693 return op_prio (TREE_OPERAND (op
, 0));
2695 return op_code_prio (code
);
2698 /* Return the symbol associated with operator CODE. */
2701 op_symbol_code (enum tree_code code
)
2709 case TRUTH_ORIF_EXPR
:
2712 case TRUTH_AND_EXPR
:
2713 case TRUTH_ANDIF_EXPR
:
2719 case TRUTH_XOR_EXPR
:
2729 case UNORDERED_EXPR
:
2775 case VEC_LSHIFT_EXPR
:
2778 case VEC_RSHIFT_EXPR
:
2781 case POINTER_PLUS_EXPR
:
2787 case REDUC_PLUS_EXPR
:
2790 case WIDEN_SUM_EXPR
:
2793 case WIDEN_MULT_EXPR
:
2803 case TRUTH_NOT_EXPR
:
2810 case TRUNC_DIV_EXPR
:
2817 case FLOOR_DIV_EXPR
:
2820 case ROUND_DIV_EXPR
:
2823 case EXACT_DIV_EXPR
:
2826 case TRUNC_MOD_EXPR
:
2832 case FLOOR_MOD_EXPR
:
2835 case ROUND_MOD_EXPR
:
2838 case PREDECREMENT_EXPR
:
2841 case PREINCREMENT_EXPR
:
2844 case POSTDECREMENT_EXPR
:
2847 case POSTINCREMENT_EXPR
:
2857 return "<<< ??? >>>";
2861 /* Return the symbol associated with operator OP. */
2864 op_symbol (const_tree op
)
2866 return op_symbol_code (TREE_CODE (op
));
2869 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
2870 the gimple_call_fn of a GIMPLE_CALL. */
2873 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
2877 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
2878 op0
= TREE_OPERAND (op0
, 0);
2881 switch (TREE_CODE (op0
))
2886 dump_function_name (buffer
, op0
, flags
);
2892 op0
= TREE_OPERAND (op0
, 0);
2896 pp_string (buffer
, "(");
2897 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
2898 pp_string (buffer
, ") ? ");
2899 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
2900 pp_string (buffer
, " : ");
2901 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
2905 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
2906 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
2908 dump_generic_node (buffer
, op0
, 0, flags
, false);
2912 if (integer_zerop (TREE_OPERAND (op0
, 1)))
2914 op0
= TREE_OPERAND (op0
, 0);
2921 dump_generic_node (buffer
, op0
, 0, flags
, false);
2929 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
2932 pretty_print_string (pretty_printer
*buffer
, const char *str
)
2942 pp_string (buffer
, "\\b");
2946 pp_string (buffer
, "\\f");
2950 pp_string (buffer
, "\\n");
2954 pp_string (buffer
, "\\r");
2958 pp_string (buffer
, "\\t");
2962 pp_string (buffer
, "\\v");
2966 pp_string (buffer
, "\\\\");
2970 pp_string (buffer
, "\\\"");
2974 pp_string (buffer
, "\\'");
2977 /* No need to handle \0; the loop terminates on \0. */
2980 pp_string (buffer
, "\\1");
2984 pp_string (buffer
, "\\2");
2988 pp_string (buffer
, "\\3");
2992 pp_string (buffer
, "\\4");
2996 pp_string (buffer
, "\\5");
3000 pp_string (buffer
, "\\6");
3004 pp_string (buffer
, "\\7");
3008 pp_character (buffer
, str
[0]);
3016 maybe_init_pretty_print (FILE *file
)
3020 pp_construct (&buffer
, /* prefix */NULL
, /* line-width */0);
3021 pp_needs_newline (&buffer
) = true;
3022 pp_translate_identifiers (&buffer
) = false;
3026 buffer
.buffer
->stream
= file
;
3030 newline_and_indent (pretty_printer
*buffer
, int spc
)
3032 pp_newline (buffer
);
3036 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3037 it can also be used in front ends.
3038 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3042 percent_K_format (text_info
*text
)
3044 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
3045 gcc_assert (text
->locus
!= NULL
);
3046 *text
->locus
= EXPR_LOCATION (t
);
3047 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
3048 block
= TREE_BLOCK (t
);
3049 *pp_ti_abstract_origin (text
) = NULL
;
3051 && TREE_CODE (block
) == BLOCK
3052 && BLOCK_ABSTRACT_ORIGIN (block
))
3054 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
3056 while (TREE_CODE (ao
) == BLOCK
3057 && BLOCK_ABSTRACT_ORIGIN (ao
)
3058 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
3059 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
3061 if (TREE_CODE (ao
) == FUNCTION_DECL
)
3063 *pp_ti_abstract_origin (text
) = block
;
3066 block
= BLOCK_SUPERCONTEXT (block
);
3070 /* Print the identifier ID to PRETTY-PRINTER. */
3073 pp_base_tree_identifier (pretty_printer
*pp
, tree id
)
3075 if (pp_translate_identifiers (pp
))
3077 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
3078 pp_append_text (pp
, text
, text
+ strlen (text
));
3081 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
3082 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));
3085 /* A helper function that is used to dump function information before the
3089 dump_function_header (FILE *dump_file
, tree fdecl
, int flags
)
3091 const char *dname
, *aname
;
3092 struct cgraph_node
*node
= cgraph_get_node (fdecl
);
3093 struct function
*fun
= DECL_STRUCT_FUNCTION (fdecl
);
3095 dname
= lang_hooks
.decl_printable_name (fdecl
, 2);
3097 if (DECL_ASSEMBLER_NAME_SET_P (fdecl
))
3098 aname
= (IDENTIFIER_POINTER
3099 (DECL_ASSEMBLER_NAME (fdecl
)));
3101 aname
= "<unset-asm-name>";
3103 fprintf (dump_file
, "\n;; Function %s (%s, funcdef_no=%d",
3104 dname
, aname
, fun
->funcdef_no
);
3105 if (!(flags
& TDF_NOUID
))
3106 fprintf (dump_file
, ", decl_uid=%d", DECL_UID (fdecl
));
3109 fprintf (dump_file
, ", cgraph_uid=%d)%s\n\n", node
->uid
,
3110 node
->frequency
== NODE_FREQUENCY_HOT
3112 : node
->frequency
== NODE_FREQUENCY_UNLIKELY_EXECUTED
3113 ? " (unlikely executed)"
3114 : node
->frequency
== NODE_FREQUENCY_EXECUTED_ONCE
3115 ? " (executed once)"
3119 fprintf (dump_file
, ")\n\n");