1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2014 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
26 #include "stor-layout.h"
28 #include "tree-pretty-print.h"
30 #include "pointer-set.h"
31 #include "gimple-expr.h"
33 #include "langhooks.h"
34 #include "tree-iterator.h"
35 #include "tree-chrec.h"
37 #include "value-prof.h"
39 #include "wide-int-print.h"
41 #include <new> // For placement-new.
43 /* Local functions, macros and variables. */
44 static const char *op_symbol (const_tree
);
45 static void pretty_print_string (pretty_printer
*, const char*);
46 static void newline_and_indent (pretty_printer
*, int);
47 static void maybe_init_pretty_print (FILE *);
48 static void print_struct_decl (pretty_printer
*, const_tree
, int, int);
49 static void do_niy (pretty_printer
*, const_tree
);
51 #define INDENT(SPACE) do { \
52 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
54 #define NIY do_niy (buffer, node)
56 static pretty_printer buffer
;
57 static int initialized
= 0;
59 /* Try to print something for an unknown tree code. */
62 do_niy (pretty_printer
*buffer
, const_tree node
)
66 pp_string (buffer
, "<<< Unknown tree: ");
67 pp_string (buffer
, get_tree_code_name (TREE_CODE (node
)));
71 len
= TREE_OPERAND_LENGTH (node
);
72 for (i
= 0; i
< len
; ++i
)
74 newline_and_indent (buffer
, 2);
75 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0, false);
79 pp_string (buffer
, " >>>");
82 /* Debugging function to print out a generic expression. */
85 debug_generic_expr (tree t
)
87 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
88 fprintf (stderr
, "\n");
91 /* Debugging function to print out a generic statement. */
94 debug_generic_stmt (tree t
)
96 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
97 fprintf (stderr
, "\n");
100 /* Debugging function to print out a chain of trees . */
103 debug_tree_chain (tree t
)
105 struct pointer_set_t
*seen
= pointer_set_create ();
109 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
110 fprintf (stderr
, " ");
112 if (pointer_set_insert (seen
, t
))
114 fprintf (stderr
, "... [cycled back to ");
115 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
116 fprintf (stderr
, "]");
120 fprintf (stderr
, "\n");
122 pointer_set_destroy (seen
);
125 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
127 print_generic_decl (FILE *file
, tree decl
, int flags
)
129 maybe_init_pretty_print (file
);
130 print_declaration (&buffer
, decl
, 2, flags
);
131 pp_write_text_to_stream (&buffer
);
134 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
135 to show in the dump. See TDF_* in dumpfile.h. */
138 print_generic_stmt (FILE *file
, tree t
, int flags
)
140 maybe_init_pretty_print (file
);
141 dump_generic_node (&buffer
, t
, 0, flags
, true);
142 pp_newline_and_flush (&buffer
);
145 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
146 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
150 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
154 maybe_init_pretty_print (file
);
156 for (i
= 0; i
< indent
; i
++)
158 dump_generic_node (&buffer
, t
, indent
, flags
, true);
159 pp_newline_and_flush (&buffer
);
162 /* Print a single expression T on file FILE. FLAGS specifies details to show
163 in the dump. See TDF_* in dumpfile.h. */
166 print_generic_expr (FILE *file
, tree t
, int flags
)
168 maybe_init_pretty_print (file
);
169 dump_generic_node (&buffer
, t
, 0, flags
, false);
173 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
177 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
179 if (DECL_NAME (node
))
181 if ((flags
& TDF_ASMNAME
) && DECL_ASSEMBLER_NAME_SET_P (node
))
182 pp_tree_identifier (buffer
, DECL_ASSEMBLER_NAME (node
));
184 pp_tree_identifier (buffer
, DECL_NAME (node
));
186 if ((flags
& TDF_UID
) || DECL_NAME (node
) == NULL_TREE
)
188 if (TREE_CODE (node
) == LABEL_DECL
&& LABEL_DECL_UID (node
) != -1)
189 pp_printf (buffer
, "L.%d", (int) LABEL_DECL_UID (node
));
190 else if (TREE_CODE (node
) == DEBUG_EXPR_DECL
)
192 if (flags
& TDF_NOUID
)
193 pp_string (buffer
, "D#xxxx");
195 pp_printf (buffer
, "D#%i", DEBUG_TEMP_UID (node
));
199 char c
= TREE_CODE (node
) == CONST_DECL
? 'C' : 'D';
200 if (flags
& TDF_NOUID
)
201 pp_printf (buffer
, "%c.xxxx", c
);
203 pp_printf (buffer
, "%c.%u", c
, DECL_UID (node
));
206 if ((flags
& TDF_ALIAS
) && DECL_PT_UID (node
) != DECL_UID (node
))
208 if (flags
& TDF_NOUID
)
209 pp_printf (buffer
, "ptD.xxxx");
211 pp_printf (buffer
, "ptD.%u", DECL_PT_UID (node
));
215 /* Like the above, but used for pretty printing function calls. */
218 dump_function_name (pretty_printer
*buffer
, tree node
, int flags
)
220 if (TREE_CODE (node
) == NOP_EXPR
)
221 node
= TREE_OPERAND (node
, 0);
222 if (DECL_NAME (node
) && (flags
& TDF_ASMNAME
) == 0)
223 pp_string (buffer
, lang_hooks
.decl_printable_name (node
, 1));
225 dump_decl_name (buffer
, node
, flags
);
228 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
229 FLAGS are as in dump_generic_node. */
232 dump_function_declaration (pretty_printer
*buffer
, tree node
,
235 bool wrote_arg
= false;
239 pp_left_paren (buffer
);
241 /* Print the argument types. */
242 arg
= TYPE_ARG_TYPES (node
);
243 while (arg
&& arg
!= void_list_node
&& arg
!= error_mark_node
)
251 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
252 arg
= TREE_CHAIN (arg
);
255 /* Drop the trailing void_type_node if we had any previous argument. */
256 if (arg
== void_list_node
&& !wrote_arg
)
257 pp_string (buffer
, "void");
258 /* Properly dump vararg function types. */
259 else if (!arg
&& wrote_arg
)
260 pp_string (buffer
, ", ...");
261 /* Avoid printing any arg for unprototyped functions. */
263 pp_right_paren (buffer
);
266 /* Dump the domain associated with an array. */
269 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
271 pp_left_bracket (buffer
);
274 tree min
= TYPE_MIN_VALUE (domain
);
275 tree max
= TYPE_MAX_VALUE (domain
);
278 && integer_zerop (min
)
279 && tree_fits_shwi_p (max
))
280 pp_wide_integer (buffer
, tree_to_shwi (max
) + 1);
284 dump_generic_node (buffer
, min
, spc
, flags
, false);
287 dump_generic_node (buffer
, max
, spc
, flags
, false);
291 pp_string (buffer
, "<unknown>");
292 pp_right_bracket (buffer
);
296 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
297 dump_generic_node. */
300 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
304 switch (OMP_CLAUSE_CODE (clause
))
306 case OMP_CLAUSE_PRIVATE
:
309 case OMP_CLAUSE_SHARED
:
312 case OMP_CLAUSE_FIRSTPRIVATE
:
313 name
= "firstprivate";
315 case OMP_CLAUSE_LASTPRIVATE
:
316 name
= "lastprivate";
318 case OMP_CLAUSE_COPYIN
:
321 case OMP_CLAUSE_COPYPRIVATE
:
322 name
= "copyprivate";
324 case OMP_CLAUSE_UNIFORM
:
327 case OMP_CLAUSE__LOOPTEMP_
:
331 pp_string (buffer
, name
);
332 pp_left_paren (buffer
);
333 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
335 pp_right_paren (buffer
);
338 case OMP_CLAUSE_REDUCTION
:
339 pp_string (buffer
, "reduction(");
340 if (OMP_CLAUSE_REDUCTION_CODE (clause
) != ERROR_MARK
)
343 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
346 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
348 pp_right_paren (buffer
);
352 pp_string (buffer
, "if(");
353 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
355 pp_right_paren (buffer
);
358 case OMP_CLAUSE_NUM_THREADS
:
359 pp_string (buffer
, "num_threads(");
360 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
362 pp_right_paren (buffer
);
365 case OMP_CLAUSE_NOWAIT
:
366 pp_string (buffer
, "nowait");
368 case OMP_CLAUSE_ORDERED
:
369 pp_string (buffer
, "ordered");
372 case OMP_CLAUSE_DEFAULT
:
373 pp_string (buffer
, "default(");
374 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
376 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
378 case OMP_CLAUSE_DEFAULT_SHARED
:
379 pp_string (buffer
, "shared");
381 case OMP_CLAUSE_DEFAULT_NONE
:
382 pp_string (buffer
, "none");
384 case OMP_CLAUSE_DEFAULT_PRIVATE
:
385 pp_string (buffer
, "private");
387 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE
:
388 pp_string (buffer
, "firstprivate");
393 pp_right_paren (buffer
);
396 case OMP_CLAUSE_SCHEDULE
:
397 pp_string (buffer
, "schedule(");
398 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
400 case OMP_CLAUSE_SCHEDULE_STATIC
:
401 pp_string (buffer
, "static");
403 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
404 pp_string (buffer
, "dynamic");
406 case OMP_CLAUSE_SCHEDULE_GUIDED
:
407 pp_string (buffer
, "guided");
409 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
410 pp_string (buffer
, "runtime");
412 case OMP_CLAUSE_SCHEDULE_AUTO
:
413 pp_string (buffer
, "auto");
418 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
421 dump_generic_node (buffer
, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
424 pp_right_paren (buffer
);
427 case OMP_CLAUSE_UNTIED
:
428 pp_string (buffer
, "untied");
431 case OMP_CLAUSE_COLLAPSE
:
432 pp_string (buffer
, "collapse(");
433 dump_generic_node (buffer
, OMP_CLAUSE_COLLAPSE_EXPR (clause
),
435 pp_right_paren (buffer
);
438 case OMP_CLAUSE_FINAL
:
439 pp_string (buffer
, "final(");
440 dump_generic_node (buffer
, OMP_CLAUSE_FINAL_EXPR (clause
),
442 pp_right_paren (buffer
);
445 case OMP_CLAUSE_MERGEABLE
:
446 pp_string (buffer
, "mergeable");
449 case OMP_CLAUSE_LINEAR
:
450 pp_string (buffer
, "linear(");
451 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
454 dump_generic_node (buffer
, OMP_CLAUSE_LINEAR_STEP (clause
),
456 pp_right_paren (buffer
);
459 case OMP_CLAUSE_ALIGNED
:
460 pp_string (buffer
, "aligned(");
461 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
463 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause
))
466 dump_generic_node (buffer
, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause
),
469 pp_right_paren (buffer
);
472 case OMP_CLAUSE_DEPEND
:
473 pp_string (buffer
, "depend(");
474 switch (OMP_CLAUSE_DEPEND_KIND (clause
))
476 case OMP_CLAUSE_DEPEND_IN
:
477 pp_string (buffer
, "in");
479 case OMP_CLAUSE_DEPEND_OUT
:
480 pp_string (buffer
, "out");
482 case OMP_CLAUSE_DEPEND_INOUT
:
483 pp_string (buffer
, "inout");
489 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
491 pp_right_paren (buffer
);
495 pp_string (buffer
, "map(");
496 switch (OMP_CLAUSE_MAP_KIND (clause
))
498 case OMP_CLAUSE_MAP_ALLOC
:
499 case OMP_CLAUSE_MAP_POINTER
:
500 pp_string (buffer
, "alloc");
502 case OMP_CLAUSE_MAP_TO
:
503 pp_string (buffer
, "to");
505 case OMP_CLAUSE_MAP_FROM
:
506 pp_string (buffer
, "from");
508 case OMP_CLAUSE_MAP_TOFROM
:
509 pp_string (buffer
, "tofrom");
515 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
518 if (OMP_CLAUSE_SIZE (clause
))
520 if (OMP_CLAUSE_CODE (clause
) == OMP_CLAUSE_MAP
521 && OMP_CLAUSE_MAP_KIND (clause
) == OMP_CLAUSE_MAP_POINTER
)
522 pp_string (buffer
, " [pointer assign, bias: ");
524 pp_string (buffer
, " [len: ");
525 dump_generic_node (buffer
, OMP_CLAUSE_SIZE (clause
),
527 pp_right_bracket (buffer
);
529 pp_right_paren (buffer
);
532 case OMP_CLAUSE_FROM
:
533 pp_string (buffer
, "from(");
534 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
536 goto print_clause_size
;
539 pp_string (buffer
, "to(");
540 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
542 goto print_clause_size
;
544 case OMP_CLAUSE_NUM_TEAMS
:
545 pp_string (buffer
, "num_teams(");
546 dump_generic_node (buffer
, OMP_CLAUSE_NUM_TEAMS_EXPR (clause
),
548 pp_right_paren (buffer
);
551 case OMP_CLAUSE_THREAD_LIMIT
:
552 pp_string (buffer
, "thread_limit(");
553 dump_generic_node (buffer
, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause
),
555 pp_right_paren (buffer
);
558 case OMP_CLAUSE_DEVICE
:
559 pp_string (buffer
, "device(");
560 dump_generic_node (buffer
, OMP_CLAUSE_DEVICE_ID (clause
),
562 pp_right_paren (buffer
);
565 case OMP_CLAUSE_DIST_SCHEDULE
:
566 pp_string (buffer
, "dist_schedule(static");
567 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause
))
570 dump_generic_node (buffer
,
571 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause
),
574 pp_right_paren (buffer
);
577 case OMP_CLAUSE_PROC_BIND
:
578 pp_string (buffer
, "proc_bind(");
579 switch (OMP_CLAUSE_PROC_BIND_KIND (clause
))
581 case OMP_CLAUSE_PROC_BIND_MASTER
:
582 pp_string (buffer
, "master");
584 case OMP_CLAUSE_PROC_BIND_CLOSE
:
585 pp_string (buffer
, "close");
587 case OMP_CLAUSE_PROC_BIND_SPREAD
:
588 pp_string (buffer
, "spread");
593 pp_right_paren (buffer
);
596 case OMP_CLAUSE_SAFELEN
:
597 pp_string (buffer
, "safelen(");
598 dump_generic_node (buffer
, OMP_CLAUSE_SAFELEN_EXPR (clause
),
600 pp_right_paren (buffer
);
603 case OMP_CLAUSE_SIMDLEN
:
604 pp_string (buffer
, "simdlen(");
605 dump_generic_node (buffer
, OMP_CLAUSE_SIMDLEN_EXPR (clause
),
607 pp_right_paren (buffer
);
610 case OMP_CLAUSE__SIMDUID_
:
611 pp_string (buffer
, "_simduid_(");
612 dump_generic_node (buffer
, OMP_CLAUSE__SIMDUID__DECL (clause
),
614 pp_right_paren (buffer
);
617 case OMP_CLAUSE_INBRANCH
:
618 pp_string (buffer
, "inbranch");
620 case OMP_CLAUSE_NOTINBRANCH
:
621 pp_string (buffer
, "notinbranch");
624 pp_string (buffer
, "for");
626 case OMP_CLAUSE_PARALLEL
:
627 pp_string (buffer
, "parallel");
629 case OMP_CLAUSE_SECTIONS
:
630 pp_string (buffer
, "sections");
632 case OMP_CLAUSE_TASKGROUP
:
633 pp_string (buffer
, "taskgroup");
637 /* Should never happen. */
638 dump_generic_node (buffer
, clause
, spc
, flags
, false);
644 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
645 dump_generic_node. */
648 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
656 dump_omp_clause (buffer
, clause
, spc
, flags
);
657 clause
= OMP_CLAUSE_CHAIN (clause
);
665 /* Dump location LOC to BUFFER. */
668 dump_location (pretty_printer
*buffer
, location_t loc
)
670 expanded_location xloc
= expand_location (loc
);
672 pp_left_bracket (buffer
);
675 pp_string (buffer
, xloc
.file
);
676 pp_string (buffer
, " : ");
678 pp_decimal_int (buffer
, xloc
.line
);
679 pp_string (buffer
, "] ");
683 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
684 dump_generic_node. */
687 dump_block_node (pretty_printer
*buffer
, tree block
, int spc
, int flags
)
691 pp_printf (buffer
, "BLOCK #%d ", BLOCK_NUMBER (block
));
693 if (flags
& TDF_ADDRESS
)
694 pp_printf (buffer
, "[%p] ", (void *) block
);
696 if (BLOCK_ABSTRACT (block
))
697 pp_string (buffer
, "[abstract] ");
699 if (TREE_ASM_WRITTEN (block
))
700 pp_string (buffer
, "[written] ");
702 if (flags
& TDF_SLIM
)
705 if (BLOCK_SOURCE_LOCATION (block
))
706 dump_location (buffer
, BLOCK_SOURCE_LOCATION (block
));
708 newline_and_indent (buffer
, spc
+ 2);
710 if (BLOCK_SUPERCONTEXT (block
))
712 pp_string (buffer
, "SUPERCONTEXT: ");
713 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (block
), 0,
714 flags
| TDF_SLIM
, false);
715 newline_and_indent (buffer
, spc
+ 2);
718 if (BLOCK_SUBBLOCKS (block
))
720 pp_string (buffer
, "SUBBLOCKS: ");
721 for (t
= BLOCK_SUBBLOCKS (block
); t
; t
= BLOCK_CHAIN (t
))
723 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
726 newline_and_indent (buffer
, spc
+ 2);
729 if (BLOCK_CHAIN (block
))
731 pp_string (buffer
, "SIBLINGS: ");
732 for (t
= BLOCK_CHAIN (block
); t
; t
= BLOCK_CHAIN (t
))
734 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
737 newline_and_indent (buffer
, spc
+ 2);
740 if (BLOCK_VARS (block
))
742 pp_string (buffer
, "VARS: ");
743 for (t
= BLOCK_VARS (block
); t
; t
= TREE_CHAIN (t
))
745 dump_generic_node (buffer
, t
, 0, flags
, false);
748 newline_and_indent (buffer
, spc
+ 2);
751 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block
)) > 0)
754 vec
<tree
, va_gc
> *nlv
= BLOCK_NONLOCALIZED_VARS (block
);
756 pp_string (buffer
, "NONLOCALIZED_VARS: ");
757 FOR_EACH_VEC_ELT (*nlv
, i
, t
)
759 dump_generic_node (buffer
, t
, 0, flags
, false);
762 newline_and_indent (buffer
, spc
+ 2);
765 if (BLOCK_ABSTRACT_ORIGIN (block
))
767 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
768 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (block
), 0,
769 flags
| TDF_SLIM
, false);
770 newline_and_indent (buffer
, spc
+ 2);
773 if (BLOCK_FRAGMENT_ORIGIN (block
))
775 pp_string (buffer
, "FRAGMENT_ORIGIN: ");
776 dump_generic_node (buffer
, BLOCK_FRAGMENT_ORIGIN (block
), 0,
777 flags
| TDF_SLIM
, false);
778 newline_and_indent (buffer
, spc
+ 2);
781 if (BLOCK_FRAGMENT_CHAIN (block
))
783 pp_string (buffer
, "FRAGMENT_CHAIN: ");
784 for (t
= BLOCK_FRAGMENT_CHAIN (block
); t
; t
= BLOCK_FRAGMENT_CHAIN (t
))
786 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
789 newline_and_indent (buffer
, spc
+ 2);
794 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
795 indent. FLAGS specifies details to show in the dump (see TDF_* in
796 dumpfile.h). If IS_STMT is true, the object printed is considered
797 to be a statement and it is terminated by ';' if appropriate. */
800 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
809 if (node
== NULL_TREE
)
812 is_expr
= EXPR_P (node
);
814 if (is_stmt
&& (flags
& TDF_STMTADDR
))
815 pp_printf (buffer
, "<&%p> ", (void *)node
);
817 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
818 dump_location (buffer
, EXPR_LOCATION (node
));
820 code
= TREE_CODE (node
);
824 pp_string (buffer
, "<<< error >>>");
827 case IDENTIFIER_NODE
:
828 pp_tree_identifier (buffer
, node
);
832 while (node
&& node
!= error_mark_node
)
834 if (TREE_PURPOSE (node
))
836 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
839 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
840 node
= TREE_CHAIN (node
);
841 if (node
&& TREE_CODE (node
) == TREE_LIST
)
850 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
856 if (TREE_VEC_LENGTH (node
) > 0)
858 size_t len
= TREE_VEC_LENGTH (node
);
859 for (i
= 0; i
< len
- 1; i
++)
861 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
866 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
875 case FIXED_POINT_TYPE
:
881 unsigned int quals
= TYPE_QUALS (node
);
882 enum tree_code_class tclass
;
884 if (quals
& TYPE_QUAL_ATOMIC
)
885 pp_string (buffer
, "atomic ");
886 if (quals
& TYPE_QUAL_CONST
)
887 pp_string (buffer
, "const ");
888 else if (quals
& TYPE_QUAL_VOLATILE
)
889 pp_string (buffer
, "volatile ");
890 else if (quals
& TYPE_QUAL_RESTRICT
)
891 pp_string (buffer
, "restrict ");
893 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
895 pp_string (buffer
, "<address-space-");
896 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
897 pp_string (buffer
, "> ");
900 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
902 if (tclass
== tcc_declaration
)
904 if (DECL_NAME (node
))
905 dump_decl_name (buffer
, node
, flags
);
907 pp_string (buffer
, "<unnamed type decl>");
909 else if (tclass
== tcc_type
)
911 if (TYPE_NAME (node
))
913 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
914 pp_tree_identifier (buffer
, TYPE_NAME (node
));
915 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
916 && DECL_NAME (TYPE_NAME (node
)))
917 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
919 pp_string (buffer
, "<unnamed type>");
921 else if (TREE_CODE (node
) == VECTOR_TYPE
)
923 pp_string (buffer
, "vector");
924 pp_left_paren (buffer
);
925 pp_wide_integer (buffer
, TYPE_VECTOR_SUBPARTS (node
));
926 pp_string (buffer
, ") ");
927 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
929 else if (TREE_CODE (node
) == INTEGER_TYPE
)
931 if (TYPE_PRECISION (node
) == CHAR_TYPE_SIZE
)
932 pp_string (buffer
, (TYPE_UNSIGNED (node
)
935 else if (TYPE_PRECISION (node
) == SHORT_TYPE_SIZE
)
936 pp_string (buffer
, (TYPE_UNSIGNED (node
)
939 else if (TYPE_PRECISION (node
) == INT_TYPE_SIZE
)
940 pp_string (buffer
, (TYPE_UNSIGNED (node
)
943 else if (TYPE_PRECISION (node
) == LONG_TYPE_SIZE
)
944 pp_string (buffer
, (TYPE_UNSIGNED (node
)
947 else if (TYPE_PRECISION (node
) == LONG_LONG_TYPE_SIZE
)
948 pp_string (buffer
, (TYPE_UNSIGNED (node
)
949 ? "unsigned long long"
950 : "signed long long"));
951 else if (TYPE_PRECISION (node
) >= CHAR_TYPE_SIZE
952 && exact_log2 (TYPE_PRECISION (node
)) != -1)
954 pp_string (buffer
, (TYPE_UNSIGNED (node
) ? "uint" : "int"));
955 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
956 pp_string (buffer
, "_t");
960 pp_string (buffer
, (TYPE_UNSIGNED (node
)
961 ? "<unnamed-unsigned:"
962 : "<unnamed-signed:"));
963 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
967 else if (TREE_CODE (node
) == COMPLEX_TYPE
)
969 pp_string (buffer
, "__complex__ ");
970 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
972 else if (TREE_CODE (node
) == REAL_TYPE
)
974 pp_string (buffer
, "<float:");
975 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
978 else if (TREE_CODE (node
) == FIXED_POINT_TYPE
)
980 pp_string (buffer
, "<fixed-point-");
981 pp_string (buffer
, TYPE_SATURATING (node
) ? "sat:" : "nonsat:");
982 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
985 else if (TREE_CODE (node
) == VOID_TYPE
)
986 pp_string (buffer
, "void");
988 pp_string (buffer
, "<unnamed type>");
995 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
997 if (TREE_TYPE (node
) == NULL
)
999 pp_string (buffer
, str
);
1000 pp_string (buffer
, "<null type>");
1002 else if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
1004 tree fnode
= TREE_TYPE (node
);
1006 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
1008 pp_left_paren (buffer
);
1009 pp_string (buffer
, str
);
1010 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1011 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1012 else if (flags
& TDF_NOUID
)
1013 pp_printf (buffer
, "<Txxxx>");
1015 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1017 pp_right_paren (buffer
);
1018 dump_function_declaration (buffer
, fnode
, spc
, flags
);
1022 unsigned int quals
= TYPE_QUALS (node
);
1024 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1026 pp_string (buffer
, str
);
1028 if (quals
& TYPE_QUAL_CONST
)
1029 pp_string (buffer
, " const");
1030 if (quals
& TYPE_QUAL_VOLATILE
)
1031 pp_string (buffer
, " volatile");
1032 if (quals
& TYPE_QUAL_RESTRICT
)
1033 pp_string (buffer
, " restrict");
1035 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
1037 pp_string (buffer
, " <address-space-");
1038 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
1039 pp_greater (buffer
);
1042 if (TYPE_REF_CAN_ALIAS_ALL (node
))
1043 pp_string (buffer
, " {ref-all}");
1053 if (integer_zerop (TREE_OPERAND (node
, 1))
1054 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1055 infer them and MEM_ATTR caching will share MEM_REFs
1056 with differently-typed op0s. */
1057 && TREE_CODE (TREE_OPERAND (node
, 0)) != INTEGER_CST
1058 /* Released SSA_NAMES have no TREE_TYPE. */
1059 && TREE_TYPE (TREE_OPERAND (node
, 0)) != NULL_TREE
1060 /* Same pointer types, but ignoring POINTER_TYPE vs.
1062 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 0)))
1063 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))
1064 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 0)))
1065 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 1))))
1066 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 0)))
1067 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 1))))
1068 /* Same value types ignoring qualifiers. */
1069 && (TYPE_MAIN_VARIANT (TREE_TYPE (node
))
1070 == TYPE_MAIN_VARIANT
1071 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))))
1073 if (TREE_CODE (TREE_OPERAND (node
, 0)) != ADDR_EXPR
)
1076 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1080 dump_generic_node (buffer
,
1081 TREE_OPERAND (TREE_OPERAND (node
, 0), 0),
1088 pp_string (buffer
, "MEM[");
1089 pp_left_paren (buffer
);
1090 ptype
= TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node
, 1)));
1091 dump_generic_node (buffer
, ptype
,
1092 spc
, flags
| TDF_SLIM
, false);
1093 pp_right_paren (buffer
);
1094 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1096 if (!integer_zerop (TREE_OPERAND (node
, 1)))
1098 pp_string (buffer
, " + ");
1099 dump_generic_node (buffer
, TREE_OPERAND (node
, 1),
1102 pp_right_bracket (buffer
);
1107 case TARGET_MEM_REF
:
1109 const char *sep
= "";
1112 pp_string (buffer
, "MEM[");
1114 if (TREE_CODE (TMR_BASE (node
)) == ADDR_EXPR
)
1116 pp_string (buffer
, sep
);
1118 pp_string (buffer
, "symbol: ");
1119 dump_generic_node (buffer
, TREE_OPERAND (TMR_BASE (node
), 0),
1124 pp_string (buffer
, sep
);
1126 pp_string (buffer
, "base: ");
1127 dump_generic_node (buffer
, TMR_BASE (node
), spc
, flags
, false);
1129 tmp
= TMR_INDEX2 (node
);
1132 pp_string (buffer
, sep
);
1134 pp_string (buffer
, "base: ");
1135 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1137 tmp
= TMR_INDEX (node
);
1140 pp_string (buffer
, sep
);
1142 pp_string (buffer
, "index: ");
1143 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1145 tmp
= TMR_STEP (node
);
1148 pp_string (buffer
, sep
);
1150 pp_string (buffer
, "step: ");
1151 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1153 tmp
= TMR_OFFSET (node
);
1156 pp_string (buffer
, sep
);
1158 pp_string (buffer
, "offset: ");
1159 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1161 pp_right_bracket (buffer
);
1169 /* Print the innermost component type. */
1170 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
1171 tmp
= TREE_TYPE (tmp
))
1173 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1175 /* Print the dimensions. */
1176 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
1177 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
1183 case QUAL_UNION_TYPE
:
1185 unsigned int quals
= TYPE_QUALS (node
);
1187 if (quals
& TYPE_QUAL_ATOMIC
)
1188 pp_string (buffer
, "atomic ");
1189 if (quals
& TYPE_QUAL_CONST
)
1190 pp_string (buffer
, "const ");
1191 if (quals
& TYPE_QUAL_VOLATILE
)
1192 pp_string (buffer
, "volatile ");
1194 /* Print the name of the structure. */
1195 if (TREE_CODE (node
) == RECORD_TYPE
)
1196 pp_string (buffer
, "struct ");
1197 else if (TREE_CODE (node
) == UNION_TYPE
)
1198 pp_string (buffer
, "union ");
1200 if (TYPE_NAME (node
))
1201 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
1202 else if (!(flags
& TDF_SLIM
))
1203 /* FIXME: If we eliminate the 'else' above and attempt
1204 to show the fields for named types, we may get stuck
1205 following a cycle of pointers to structs. The alleged
1206 self-reference check in print_struct_decl will not detect
1207 cycles involving more than one pointer or struct type. */
1208 print_struct_decl (buffer
, node
, spc
, flags
);
1217 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
1219 /* In the case of a pointer, one may want to divide by the
1220 size of the pointed-to type. Unfortunately, this not
1221 straightforward. The C front-end maps expressions
1226 in such a way that the two INTEGER_CST nodes for "5" have
1227 different values but identical types. In the latter
1228 case, the 5 is multiplied by sizeof (int) in c-common.c
1229 (pointer_int_sum) to convert it to a byte address, and
1230 yet the type of the node is left unchanged. Argh. What
1231 is consistent though is that the number value corresponds
1232 to bytes (UNITS) offset.
1234 NB: Neither of the following divisors can be trivially
1235 used to recover the original literal:
1237 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1238 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1239 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1240 pp_string (buffer
, "B"); /* pseudo-unit */
1242 else if (tree_fits_shwi_p (node
))
1243 pp_wide_integer (buffer
, tree_to_shwi (node
));
1244 else if (tree_fits_uhwi_p (node
))
1245 pp_unsigned_wide_integer (buffer
, tree_to_uhwi (node
));
1248 wide_int val
= node
;
1250 if (wi::neg_p (val
, TYPE_SIGN (TREE_TYPE (node
))))
1255 print_hex (val
, pp_buffer (buffer
)->digit_buffer
);
1256 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
1258 if (TREE_OVERFLOW (node
))
1259 pp_string (buffer
, "(OVF)");
1263 /* Code copied from print_node. */
1266 if (TREE_OVERFLOW (node
))
1267 pp_string (buffer
, " overflow");
1269 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1270 d
= TREE_REAL_CST (node
);
1271 if (REAL_VALUE_ISINF (d
))
1272 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
1273 else if (REAL_VALUE_ISNAN (d
))
1274 pp_string (buffer
, " Nan");
1278 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
1279 pp_string (buffer
, string
);
1284 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
1285 pp_string (buffer
, "0x");
1286 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
1287 output_formatted_integer (buffer
, "%02x", *p
++);
1296 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
1297 pp_string (buffer
, string
);
1302 pp_string (buffer
, "__complex__ (");
1303 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
1304 pp_string (buffer
, ", ");
1305 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
1306 pp_right_paren (buffer
);
1310 pp_string (buffer
, "\"");
1311 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
1312 pp_string (buffer
, "\"");
1318 pp_string (buffer
, "{ ");
1319 for (i
= 0; i
< VECTOR_CST_NELTS (node
); ++i
)
1322 pp_string (buffer
, ", ");
1323 dump_generic_node (buffer
, VECTOR_CST_ELT (node
, i
),
1326 pp_string (buffer
, " }");
1332 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1334 if (TREE_CODE (node
) == METHOD_TYPE
)
1336 if (TYPE_METHOD_BASETYPE (node
))
1337 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
1340 pp_string (buffer
, "<null method basetype>");
1341 pp_colon_colon (buffer
);
1343 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1344 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1345 else if (flags
& TDF_NOUID
)
1346 pp_printf (buffer
, "<Txxxx>");
1348 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1349 dump_function_declaration (buffer
, node
, spc
, flags
);
1354 dump_decl_name (buffer
, node
, flags
);
1358 if (DECL_NAME (node
))
1359 dump_decl_name (buffer
, node
, flags
);
1360 else if (LABEL_DECL_UID (node
) != -1)
1361 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1364 if (flags
& TDF_NOUID
)
1365 pp_string (buffer
, "<D.xxxx>");
1367 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1372 if (DECL_IS_BUILTIN (node
))
1374 /* Don't print the declaration of built-in types. */
1377 if (DECL_NAME (node
))
1378 dump_decl_name (buffer
, node
, flags
);
1379 else if (TYPE_NAME (TREE_TYPE (node
)) != node
)
1381 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1382 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1383 && TYPE_METHODS (TREE_TYPE (node
)))
1385 /* The type is a c++ class: all structures have at least
1387 pp_string (buffer
, "class ");
1388 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1393 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1394 ? "union" : "struct "));
1395 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1399 pp_string (buffer
, "<anon>");
1405 case DEBUG_EXPR_DECL
:
1406 case NAMESPACE_DECL
:
1408 dump_decl_name (buffer
, node
, flags
);
1412 pp_string (buffer
, "<retval>");
1416 op0
= TREE_OPERAND (node
, 0);
1419 && (TREE_CODE (op0
) == INDIRECT_REF
1420 || (TREE_CODE (op0
) == MEM_REF
1421 && TREE_CODE (TREE_OPERAND (op0
, 0)) != ADDR_EXPR
1422 && integer_zerop (TREE_OPERAND (op0
, 1))
1423 /* Dump the types of INTEGER_CSTs explicitly, for we
1424 can't infer them and MEM_ATTR caching will share
1425 MEM_REFs with differently-typed op0s. */
1426 && TREE_CODE (TREE_OPERAND (op0
, 0)) != INTEGER_CST
1427 /* Released SSA_NAMES have no TREE_TYPE. */
1428 && TREE_TYPE (TREE_OPERAND (op0
, 0)) != NULL_TREE
1429 /* Same pointer types, but ignoring POINTER_TYPE vs.
1431 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1432 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1433 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1434 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1435 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1436 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1437 /* Same value types ignoring qualifiers. */
1438 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0
))
1439 == TYPE_MAIN_VARIANT
1440 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))))))
1442 op0
= TREE_OPERAND (op0
, 0);
1445 if (op_prio (op0
) < op_prio (node
))
1446 pp_left_paren (buffer
);
1447 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1448 if (op_prio (op0
) < op_prio (node
))
1449 pp_right_paren (buffer
);
1450 pp_string (buffer
, str
);
1451 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1452 op0
= component_ref_field_offset (node
);
1453 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1455 pp_string (buffer
, "{off: ");
1456 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1457 pp_right_brace (buffer
);
1462 pp_string (buffer
, "BIT_FIELD_REF <");
1463 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1464 pp_string (buffer
, ", ");
1465 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1466 pp_string (buffer
, ", ");
1467 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1468 pp_greater (buffer
);
1472 case ARRAY_RANGE_REF
:
1473 op0
= TREE_OPERAND (node
, 0);
1474 if (op_prio (op0
) < op_prio (node
))
1475 pp_left_paren (buffer
);
1476 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1477 if (op_prio (op0
) < op_prio (node
))
1478 pp_right_paren (buffer
);
1479 pp_left_bracket (buffer
);
1480 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1481 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1482 pp_string (buffer
, " ...");
1483 pp_right_bracket (buffer
);
1485 op0
= array_ref_low_bound (node
);
1486 op1
= array_ref_element_size (node
);
1488 if (!integer_zerop (op0
)
1489 || TREE_OPERAND (node
, 2)
1490 || TREE_OPERAND (node
, 3))
1492 pp_string (buffer
, "{lb: ");
1493 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1494 pp_string (buffer
, " sz: ");
1495 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1496 pp_right_brace (buffer
);
1502 unsigned HOST_WIDE_INT ix
;
1504 bool is_struct_init
= false;
1505 bool is_array_init
= false;
1507 pp_left_brace (buffer
);
1508 if (TREE_CLOBBER_P (node
))
1509 pp_string (buffer
, "CLOBBER");
1510 else if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1511 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1512 is_struct_init
= true;
1513 else if (TREE_CODE (TREE_TYPE (node
)) == ARRAY_TYPE
1514 && TYPE_DOMAIN (TREE_TYPE (node
))
1515 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)))
1516 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
))))
1519 tree minv
= TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)));
1520 is_array_init
= true;
1521 curidx
= wi::to_widest (minv
);
1523 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1530 dump_generic_node (buffer
, field
, spc
, flags
, false);
1533 else if (is_array_init
1534 && (TREE_CODE (field
) != INTEGER_CST
1535 || curidx
!= wi::to_widest (field
)))
1537 pp_left_bracket (buffer
);
1538 if (TREE_CODE (field
) == RANGE_EXPR
)
1540 dump_generic_node (buffer
, TREE_OPERAND (field
, 0), spc
,
1542 pp_string (buffer
, " ... ");
1543 dump_generic_node (buffer
, TREE_OPERAND (field
, 1), spc
,
1545 if (TREE_CODE (TREE_OPERAND (field
, 1)) == INTEGER_CST
)
1546 curidx
= wi::to_widest (TREE_OPERAND (field
, 1));
1549 dump_generic_node (buffer
, field
, spc
, flags
, false);
1550 if (TREE_CODE (field
) == INTEGER_CST
)
1551 curidx
= wi::to_widest (field
);
1552 pp_string (buffer
, "]=");
1557 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1558 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1559 val
= TREE_OPERAND (val
, 0);
1560 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1561 dump_decl_name (buffer
, val
, flags
);
1563 dump_generic_node (buffer
, val
, spc
, flags
, false);
1564 if (ix
!= vec_safe_length (CONSTRUCTOR_ELTS (node
)) - 1)
1570 pp_right_brace (buffer
);
1577 if (flags
& TDF_SLIM
)
1579 pp_string (buffer
, "<COMPOUND_EXPR>");
1583 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1584 spc
, flags
, !(flags
& TDF_SLIM
));
1585 if (flags
& TDF_SLIM
)
1586 newline_and_indent (buffer
, spc
);
1593 for (tp
= &TREE_OPERAND (node
, 1);
1594 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1595 tp
= &TREE_OPERAND (*tp
, 1))
1597 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1598 spc
, flags
, !(flags
& TDF_SLIM
));
1599 if (flags
& TDF_SLIM
)
1600 newline_and_indent (buffer
, spc
);
1608 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1612 case STATEMENT_LIST
:
1614 tree_stmt_iterator si
;
1617 if (flags
& TDF_SLIM
)
1619 pp_string (buffer
, "<STATEMENT_LIST>");
1623 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1626 newline_and_indent (buffer
, spc
);
1629 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1636 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1641 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1646 pp_string (buffer
, "TARGET_EXPR <");
1647 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1650 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1651 pp_greater (buffer
);
1655 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1660 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1662 pp_string (buffer
, "if (");
1663 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1664 pp_right_paren (buffer
);
1665 /* The lowered cond_exprs should always be printed in full. */
1666 if (COND_EXPR_THEN (node
)
1667 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1668 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1669 && COND_EXPR_ELSE (node
)
1670 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1671 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1674 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1676 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1678 pp_string (buffer
, " else ");
1679 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1683 else if (!(flags
& TDF_SLIM
))
1685 /* Output COND_EXPR_THEN. */
1686 if (COND_EXPR_THEN (node
))
1688 newline_and_indent (buffer
, spc
+2);
1689 pp_left_brace (buffer
);
1690 newline_and_indent (buffer
, spc
+4);
1691 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1693 newline_and_indent (buffer
, spc
+2);
1694 pp_right_brace (buffer
);
1697 /* Output COND_EXPR_ELSE. */
1698 if (COND_EXPR_ELSE (node
)
1699 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1701 newline_and_indent (buffer
, spc
);
1702 pp_string (buffer
, "else");
1703 newline_and_indent (buffer
, spc
+2);
1704 pp_left_brace (buffer
);
1705 newline_and_indent (buffer
, spc
+4);
1706 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1708 newline_and_indent (buffer
, spc
+2);
1709 pp_right_brace (buffer
);
1716 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1718 pp_question (buffer
);
1720 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1724 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1729 pp_left_brace (buffer
);
1730 if (!(flags
& TDF_SLIM
))
1732 if (BIND_EXPR_VARS (node
))
1734 pp_newline (buffer
);
1736 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= DECL_CHAIN (op0
))
1738 print_declaration (buffer
, op0
, spc
+2, flags
);
1739 pp_newline (buffer
);
1743 newline_and_indent (buffer
, spc
+2);
1744 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1745 newline_and_indent (buffer
, spc
);
1746 pp_right_brace (buffer
);
1752 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1754 /* Print parameters. */
1756 pp_left_paren (buffer
);
1759 call_expr_arg_iterator iter
;
1760 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1762 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1763 if (more_call_expr_args_p (&iter
))
1770 if (CALL_EXPR_VA_ARG_PACK (node
))
1772 if (call_expr_nargs (node
) > 0)
1777 pp_string (buffer
, "__builtin_va_arg_pack ()");
1779 pp_right_paren (buffer
);
1781 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1784 pp_string (buffer
, " [static-chain: ");
1785 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1786 pp_right_bracket (buffer
);
1789 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1790 pp_string (buffer
, " [return slot optimization]");
1791 if (CALL_EXPR_TAILCALL (node
))
1792 pp_string (buffer
, " [tail call]");
1795 case WITH_CLEANUP_EXPR
:
1799 case CLEANUP_POINT_EXPR
:
1800 pp_string (buffer
, "<<cleanup_point ");
1801 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1802 pp_string (buffer
, ">>");
1805 case PLACEHOLDER_EXPR
:
1806 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1807 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1808 pp_greater (buffer
);
1811 /* Binary arithmetic and logic expressions. */
1812 case WIDEN_SUM_EXPR
:
1813 case WIDEN_MULT_EXPR
:
1815 case MULT_HIGHPART_EXPR
:
1817 case POINTER_PLUS_EXPR
:
1819 case TRUNC_DIV_EXPR
:
1821 case FLOOR_DIV_EXPR
:
1822 case ROUND_DIV_EXPR
:
1823 case TRUNC_MOD_EXPR
:
1825 case FLOOR_MOD_EXPR
:
1826 case ROUND_MOD_EXPR
:
1828 case EXACT_DIV_EXPR
:
1833 case VEC_LSHIFT_EXPR
:
1834 case VEC_RSHIFT_EXPR
:
1835 case WIDEN_LSHIFT_EXPR
:
1839 case TRUTH_ANDIF_EXPR
:
1840 case TRUTH_ORIF_EXPR
:
1841 case TRUTH_AND_EXPR
:
1843 case TRUTH_XOR_EXPR
:
1857 case UNORDERED_EXPR
:
1859 const char *op
= op_symbol (node
);
1860 op0
= TREE_OPERAND (node
, 0);
1861 op1
= TREE_OPERAND (node
, 1);
1863 /* When the operands are expressions with less priority,
1864 keep semantics of the tree representation. */
1865 if (op_prio (op0
) <= op_prio (node
))
1867 pp_left_paren (buffer
);
1868 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1869 pp_right_paren (buffer
);
1872 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1875 pp_string (buffer
, op
);
1878 /* When the operands are expressions with less priority,
1879 keep semantics of the tree representation. */
1880 if (op_prio (op1
) <= op_prio (node
))
1882 pp_left_paren (buffer
);
1883 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1884 pp_right_paren (buffer
);
1887 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1891 /* Unary arithmetic and logic expressions. */
1894 case TRUTH_NOT_EXPR
:
1896 case PREDECREMENT_EXPR
:
1897 case PREINCREMENT_EXPR
:
1899 if (TREE_CODE (node
) == ADDR_EXPR
1900 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1901 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1902 ; /* Do not output '&' for strings and function pointers. */
1904 pp_string (buffer
, op_symbol (node
));
1906 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1908 pp_left_paren (buffer
);
1909 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1910 pp_right_paren (buffer
);
1913 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1916 case POSTDECREMENT_EXPR
:
1917 case POSTINCREMENT_EXPR
:
1918 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1920 pp_left_paren (buffer
);
1921 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1922 pp_right_paren (buffer
);
1925 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1926 pp_string (buffer
, op_symbol (node
));
1930 pp_string (buffer
, "MIN_EXPR <");
1931 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1932 pp_string (buffer
, ", ");
1933 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1934 pp_greater (buffer
);
1938 pp_string (buffer
, "MAX_EXPR <");
1939 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1940 pp_string (buffer
, ", ");
1941 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1942 pp_greater (buffer
);
1946 pp_string (buffer
, "ABS_EXPR <");
1947 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1948 pp_greater (buffer
);
1955 case ADDR_SPACE_CONVERT_EXPR
:
1956 case FIXED_CONVERT_EXPR
:
1957 case FIX_TRUNC_EXPR
:
1960 type
= TREE_TYPE (node
);
1961 op0
= TREE_OPERAND (node
, 0);
1962 if (type
!= TREE_TYPE (op0
))
1964 pp_left_paren (buffer
);
1965 dump_generic_node (buffer
, type
, spc
, flags
, false);
1966 pp_string (buffer
, ") ");
1968 if (op_prio (op0
) < op_prio (node
))
1969 pp_left_paren (buffer
);
1970 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1971 if (op_prio (op0
) < op_prio (node
))
1972 pp_right_paren (buffer
);
1975 case VIEW_CONVERT_EXPR
:
1976 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1977 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1978 pp_string (buffer
, ">(");
1979 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1980 pp_right_paren (buffer
);
1984 pp_string (buffer
, "((");
1985 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1986 pp_string (buffer
, "))");
1989 case NON_LVALUE_EXPR
:
1990 pp_string (buffer
, "NON_LVALUE_EXPR <");
1991 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1992 pp_greater (buffer
);
1996 pp_string (buffer
, "SAVE_EXPR <");
1997 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1998 pp_greater (buffer
);
2002 pp_string (buffer
, "COMPLEX_EXPR <");
2003 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2004 pp_string (buffer
, ", ");
2005 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2006 pp_greater (buffer
);
2010 pp_string (buffer
, "CONJ_EXPR <");
2011 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2012 pp_greater (buffer
);
2016 pp_string (buffer
, "REALPART_EXPR <");
2017 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2018 pp_greater (buffer
);
2022 pp_string (buffer
, "IMAGPART_EXPR <");
2023 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2024 pp_greater (buffer
);
2028 pp_string (buffer
, "VA_ARG_EXPR <");
2029 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2030 pp_greater (buffer
);
2033 case TRY_FINALLY_EXPR
:
2034 case TRY_CATCH_EXPR
:
2035 pp_string (buffer
, "try");
2036 newline_and_indent (buffer
, spc
+2);
2037 pp_left_brace (buffer
);
2038 newline_and_indent (buffer
, spc
+4);
2039 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
2040 newline_and_indent (buffer
, spc
+2);
2041 pp_right_brace (buffer
);
2042 newline_and_indent (buffer
, spc
);
2044 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
2045 newline_and_indent (buffer
, spc
+2);
2046 pp_left_brace (buffer
);
2047 newline_and_indent (buffer
, spc
+4);
2048 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
2049 newline_and_indent (buffer
, spc
+2);
2050 pp_right_brace (buffer
);
2055 pp_string (buffer
, "catch (");
2056 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
2057 pp_right_paren (buffer
);
2058 newline_and_indent (buffer
, spc
+2);
2059 pp_left_brace (buffer
);
2060 newline_and_indent (buffer
, spc
+4);
2061 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
2062 newline_and_indent (buffer
, spc
+2);
2063 pp_right_brace (buffer
);
2067 case EH_FILTER_EXPR
:
2068 pp_string (buffer
, "<<<eh_filter (");
2069 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
2070 pp_string (buffer
, ")>>>");
2071 newline_and_indent (buffer
, spc
+2);
2072 pp_left_brace (buffer
);
2073 newline_and_indent (buffer
, spc
+4);
2074 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
2075 newline_and_indent (buffer
, spc
+2);
2076 pp_right_brace (buffer
);
2081 op0
= TREE_OPERAND (node
, 0);
2082 /* If this is for break or continue, don't bother printing it. */
2083 if (DECL_NAME (op0
))
2085 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
2086 if (strcmp (name
, "break") == 0
2087 || strcmp (name
, "continue") == 0)
2090 dump_generic_node (buffer
, op0
, spc
, flags
, false);
2092 if (DECL_NONLOCAL (op0
))
2093 pp_string (buffer
, " [non-local]");
2097 pp_string (buffer
, "while (1)");
2098 if (!(flags
& TDF_SLIM
))
2100 newline_and_indent (buffer
, spc
+2);
2101 pp_left_brace (buffer
);
2102 newline_and_indent (buffer
, spc
+4);
2103 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
2104 newline_and_indent (buffer
, spc
+2);
2105 pp_right_brace (buffer
);
2111 pp_string (buffer
, "// predicted ");
2112 if (PREDICT_EXPR_OUTCOME (node
))
2113 pp_string (buffer
, "likely by ");
2115 pp_string (buffer
, "unlikely by ");
2116 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
2117 pp_string (buffer
, " predictor.");
2121 pp_string (buffer
, "ANNOTATE_EXPR <");
2122 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2123 switch ((enum annot_expr_kind
) TREE_INT_CST_LOW (TREE_OPERAND (node
, 1)))
2125 case annot_expr_ivdep_kind
:
2126 pp_string (buffer
, ", ivdep");
2128 case annot_expr_no_vector_kind
:
2129 pp_string (buffer
, ", no-vector");
2131 case annot_expr_vector_kind
:
2132 pp_string (buffer
, ", vector");
2137 pp_greater (buffer
);
2141 pp_string (buffer
, "return");
2142 op0
= TREE_OPERAND (node
, 0);
2146 if (TREE_CODE (op0
) == MODIFY_EXPR
)
2147 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
2150 dump_generic_node (buffer
, op0
, spc
, flags
, false);
2155 pp_string (buffer
, "if (");
2156 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2157 pp_string (buffer
, ") break");
2161 pp_string (buffer
, "switch (");
2162 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
2163 pp_right_paren (buffer
);
2164 if (!(flags
& TDF_SLIM
))
2166 newline_and_indent (buffer
, spc
+2);
2167 pp_left_brace (buffer
);
2168 if (SWITCH_BODY (node
))
2170 newline_and_indent (buffer
, spc
+4);
2171 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
2176 tree vec
= SWITCH_LABELS (node
);
2177 size_t i
, n
= TREE_VEC_LENGTH (vec
);
2178 for (i
= 0; i
< n
; ++i
)
2180 tree elt
= TREE_VEC_ELT (vec
, i
);
2181 newline_and_indent (buffer
, spc
+4);
2184 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
2185 pp_string (buffer
, " goto ");
2186 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
2188 pp_semicolon (buffer
);
2191 pp_string (buffer
, "case ???: goto ???;");
2194 newline_and_indent (buffer
, spc
+2);
2195 pp_right_brace (buffer
);
2201 op0
= GOTO_DESTINATION (node
);
2202 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
2204 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
2205 if (strcmp (name
, "break") == 0
2206 || strcmp (name
, "continue") == 0)
2208 pp_string (buffer
, name
);
2212 pp_string (buffer
, "goto ");
2213 dump_generic_node (buffer
, op0
, spc
, flags
, false);
2217 pp_string (buffer
, "__asm__");
2218 if (ASM_VOLATILE_P (node
))
2219 pp_string (buffer
, " __volatile__");
2220 pp_left_paren (buffer
);
2221 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
2223 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
2225 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
2226 if (ASM_CLOBBERS (node
))
2229 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
2231 pp_right_paren (buffer
);
2234 case CASE_LABEL_EXPR
:
2235 if (CASE_LOW (node
) && CASE_HIGH (node
))
2237 pp_string (buffer
, "case ");
2238 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
2239 pp_string (buffer
, " ... ");
2240 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
2242 else if (CASE_LOW (node
))
2244 pp_string (buffer
, "case ");
2245 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
2248 pp_string (buffer
, "default");
2253 pp_string (buffer
, "OBJ_TYPE_REF(");
2254 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
2255 pp_semicolon (buffer
);
2256 if (!(flags
& TDF_SLIM
) && virtual_method_call_p (node
))
2258 pp_string (buffer
, "(");
2259 dump_generic_node (buffer
, obj_type_ref_class (node
), spc
, flags
, false);
2260 pp_string (buffer
, ")");
2262 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
2264 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
2265 pp_right_paren (buffer
);
2269 if (SSA_NAME_IDENTIFIER (node
))
2270 dump_generic_node (buffer
, SSA_NAME_IDENTIFIER (node
),
2272 pp_underscore (buffer
);
2273 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
2274 if (SSA_NAME_IS_DEFAULT_DEF (node
))
2275 pp_string (buffer
, "(D)");
2276 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
2277 pp_string (buffer
, "(ab)");
2280 case WITH_SIZE_EXPR
:
2281 pp_string (buffer
, "WITH_SIZE_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_greater (buffer
);
2289 pp_string (buffer
, "ASSERT_EXPR <");
2290 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
2291 pp_string (buffer
, ", ");
2292 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
2293 pp_greater (buffer
);
2297 pp_string (buffer
, "scev_known");
2300 case SCEV_NOT_KNOWN
:
2301 pp_string (buffer
, "scev_not_known");
2304 case POLYNOMIAL_CHREC
:
2305 pp_left_brace (buffer
);
2306 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
2307 pp_string (buffer
, ", +, ");
2308 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
2309 pp_string (buffer
, "}_");
2310 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
2314 case REALIGN_LOAD_EXPR
:
2315 pp_string (buffer
, "REALIGN_LOAD <");
2316 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2317 pp_string (buffer
, ", ");
2318 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2319 pp_string (buffer
, ", ");
2320 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2321 pp_greater (buffer
);
2325 pp_string (buffer
, " VEC_COND_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
, " , ");
2330 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2331 pp_string (buffer
, " > ");
2335 pp_string (buffer
, " VEC_PERM_EXPR < ");
2336 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2337 pp_string (buffer
, " , ");
2338 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2339 pp_string (buffer
, " , ");
2340 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2341 pp_string (buffer
, " > ");
2345 pp_string (buffer
, " DOT_PROD_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
, ", ");
2350 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2351 pp_string (buffer
, " > ");
2354 case WIDEN_MULT_PLUS_EXPR
:
2355 pp_string (buffer
, " WIDEN_MULT_PLUS_EXPR < ");
2356 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2357 pp_string (buffer
, ", ");
2358 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2359 pp_string (buffer
, ", ");
2360 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2361 pp_string (buffer
, " > ");
2364 case WIDEN_MULT_MINUS_EXPR
:
2365 pp_string (buffer
, " WIDEN_MULT_MINUS_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
, ", ");
2370 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2371 pp_string (buffer
, " > ");
2375 pp_string (buffer
, " FMA_EXPR < ");
2376 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2377 pp_string (buffer
, ", ");
2378 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2379 pp_string (buffer
, ", ");
2380 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2381 pp_string (buffer
, " > ");
2385 pp_string (buffer
, "#pragma omp parallel");
2386 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
2389 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
2391 newline_and_indent (buffer
, spc
+ 2);
2392 pp_left_brace (buffer
);
2393 newline_and_indent (buffer
, spc
+ 4);
2394 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
2395 newline_and_indent (buffer
, spc
+ 2);
2396 pp_right_brace (buffer
);
2402 pp_string (buffer
, "#pragma omp task");
2403 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
2407 pp_string (buffer
, "#pragma omp for");
2411 pp_string (buffer
, "#pragma omp simd");
2415 pp_string (buffer
, "#pragma simd");
2418 case OMP_DISTRIBUTE
:
2419 pp_string (buffer
, "#pragma omp distribute");
2423 pp_string (buffer
, "#pragma omp teams");
2424 dump_omp_clauses (buffer
, OMP_TEAMS_CLAUSES (node
), spc
, flags
);
2427 case OMP_TARGET_DATA
:
2428 pp_string (buffer
, "#pragma omp target data");
2429 dump_omp_clauses (buffer
, OMP_TARGET_DATA_CLAUSES (node
), spc
, flags
);
2433 pp_string (buffer
, "#pragma omp target");
2434 dump_omp_clauses (buffer
, OMP_TARGET_CLAUSES (node
), spc
, flags
);
2437 case OMP_TARGET_UPDATE
:
2438 pp_string (buffer
, "#pragma omp target update");
2439 dump_omp_clauses (buffer
, OMP_TARGET_UPDATE_CLAUSES (node
), spc
, flags
);
2444 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
2446 if (!(flags
& TDF_SLIM
))
2450 if (OMP_FOR_PRE_BODY (node
))
2452 newline_and_indent (buffer
, spc
+ 2);
2453 pp_left_brace (buffer
);
2455 newline_and_indent (buffer
, spc
);
2456 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
2459 if (OMP_FOR_INIT (node
))
2462 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
2465 newline_and_indent (buffer
, spc
);
2466 pp_string (buffer
, "for (");
2467 dump_generic_node (buffer
,
2468 TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
2470 pp_string (buffer
, "; ");
2471 dump_generic_node (buffer
,
2472 TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
2474 pp_string (buffer
, "; ");
2475 dump_generic_node (buffer
,
2476 TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
2478 pp_right_paren (buffer
);
2481 if (OMP_FOR_BODY (node
))
2483 newline_and_indent (buffer
, spc
+ 2);
2484 pp_left_brace (buffer
);
2485 newline_and_indent (buffer
, spc
+ 4);
2486 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
2488 newline_and_indent (buffer
, spc
+ 2);
2489 pp_right_brace (buffer
);
2491 if (OMP_FOR_INIT (node
))
2492 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
2493 if (OMP_FOR_PRE_BODY (node
))
2496 newline_and_indent (buffer
, spc
+ 2);
2497 pp_right_brace (buffer
);
2504 pp_string (buffer
, "#pragma omp sections");
2505 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2509 pp_string (buffer
, "#pragma omp section");
2513 pp_string (buffer
, "#pragma omp master");
2517 pp_string (buffer
, "#pragma omp taskgroup");
2521 pp_string (buffer
, "#pragma omp ordered");
2525 pp_string (buffer
, "#pragma omp critical");
2526 if (OMP_CRITICAL_NAME (node
))
2529 pp_left_paren (buffer
);
2530 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2532 pp_right_paren (buffer
);
2537 pp_string (buffer
, "#pragma omp atomic");
2538 if (OMP_ATOMIC_SEQ_CST (node
))
2539 pp_string (buffer
, " seq_cst");
2540 newline_and_indent (buffer
, spc
+ 2);
2541 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2545 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2548 case OMP_ATOMIC_READ
:
2549 pp_string (buffer
, "#pragma omp atomic read");
2550 if (OMP_ATOMIC_SEQ_CST (node
))
2551 pp_string (buffer
, " seq_cst");
2552 newline_and_indent (buffer
, spc
+ 2);
2553 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2557 case OMP_ATOMIC_CAPTURE_OLD
:
2558 case OMP_ATOMIC_CAPTURE_NEW
:
2559 pp_string (buffer
, "#pragma omp atomic capture");
2560 if (OMP_ATOMIC_SEQ_CST (node
))
2561 pp_string (buffer
, " seq_cst");
2562 newline_and_indent (buffer
, spc
+ 2);
2563 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2567 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2571 pp_string (buffer
, "#pragma omp single");
2572 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2576 dump_omp_clause (buffer
, node
, spc
, flags
);
2580 case TRANSACTION_EXPR
:
2581 if (TRANSACTION_EXPR_OUTER (node
))
2582 pp_string (buffer
, "__transaction_atomic [[outer]]");
2583 else if (TRANSACTION_EXPR_RELAXED (node
))
2584 pp_string (buffer
, "__transaction_relaxed");
2586 pp_string (buffer
, "__transaction_atomic");
2587 if (!(flags
& TDF_SLIM
) && TRANSACTION_EXPR_BODY (node
))
2589 newline_and_indent (buffer
, spc
);
2590 pp_left_brace (buffer
);
2591 newline_and_indent (buffer
, spc
+ 2);
2592 dump_generic_node (buffer
, TRANSACTION_EXPR_BODY (node
),
2593 spc
+ 2, flags
, false);
2594 newline_and_indent (buffer
, spc
);
2595 pp_right_brace (buffer
);
2600 case REDUC_MAX_EXPR
:
2601 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2602 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2603 pp_string (buffer
, " > ");
2606 case REDUC_MIN_EXPR
:
2607 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2608 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2609 pp_string (buffer
, " > ");
2612 case REDUC_PLUS_EXPR
:
2613 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2614 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2615 pp_string (buffer
, " > ");
2618 case VEC_WIDEN_MULT_HI_EXPR
:
2619 case VEC_WIDEN_MULT_LO_EXPR
:
2620 case VEC_WIDEN_MULT_EVEN_EXPR
:
2621 case VEC_WIDEN_MULT_ODD_EXPR
:
2622 case VEC_WIDEN_LSHIFT_HI_EXPR
:
2623 case VEC_WIDEN_LSHIFT_LO_EXPR
:
2625 for (str
= get_tree_code_name (code
); *str
; str
++)
2626 pp_character (buffer
, TOUPPER (*str
));
2627 pp_string (buffer
, " < ");
2628 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2629 pp_string (buffer
, ", ");
2630 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2631 pp_string (buffer
, " > ");
2634 case VEC_UNPACK_HI_EXPR
:
2635 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2636 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2637 pp_string (buffer
, " > ");
2640 case VEC_UNPACK_LO_EXPR
:
2641 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2642 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2643 pp_string (buffer
, " > ");
2646 case VEC_UNPACK_FLOAT_HI_EXPR
:
2647 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2648 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2649 pp_string (buffer
, " > ");
2652 case VEC_UNPACK_FLOAT_LO_EXPR
:
2653 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2654 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2655 pp_string (buffer
, " > ");
2658 case VEC_PACK_TRUNC_EXPR
:
2659 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2660 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2661 pp_string (buffer
, ", ");
2662 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2663 pp_string (buffer
, " > ");
2666 case VEC_PACK_SAT_EXPR
:
2667 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2668 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2669 pp_string (buffer
, ", ");
2670 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2671 pp_string (buffer
, " > ");
2674 case VEC_PACK_FIX_TRUNC_EXPR
:
2675 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2676 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2677 pp_string (buffer
, ", ");
2678 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2679 pp_string (buffer
, " > ");
2683 dump_block_node (buffer
, node
, spc
, flags
);
2686 case CILK_SPAWN_STMT
:
2687 pp_string (buffer
, "_Cilk_spawn ");
2688 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2691 case CILK_SYNC_STMT
:
2692 pp_string (buffer
, "_Cilk_sync");
2699 if (is_stmt
&& is_expr
)
2700 pp_semicolon (buffer
);
2705 /* Print the declaration of a variable. */
2708 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2712 if (TREE_CODE(t
) == NAMELIST_DECL
)
2714 pp_string(buffer
, "namelist ");
2715 dump_decl_name (buffer
, t
, flags
);
2716 pp_semicolon (buffer
);
2720 if (TREE_CODE (t
) == TYPE_DECL
)
2721 pp_string (buffer
, "typedef ");
2723 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2724 pp_string (buffer
, "register ");
2726 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2727 pp_string (buffer
, "extern ");
2728 else if (TREE_STATIC (t
))
2729 pp_string (buffer
, "static ");
2731 /* Print the type and name. */
2732 if (TREE_TYPE (t
) && TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2736 /* Print array's type. */
2737 tmp
= TREE_TYPE (t
);
2738 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2739 tmp
= TREE_TYPE (tmp
);
2740 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2742 /* Print variable's name. */
2744 dump_generic_node (buffer
, t
, spc
, flags
, false);
2746 /* Print the dimensions. */
2747 tmp
= TREE_TYPE (t
);
2748 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2750 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2751 tmp
= TREE_TYPE (tmp
);
2754 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2756 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2758 dump_decl_name (buffer
, t
, flags
);
2759 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2763 /* Print type declaration. */
2764 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2766 /* Print variable's name. */
2768 dump_generic_node (buffer
, t
, spc
, flags
, false);
2771 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2773 pp_string (buffer
, " __asm__ ");
2774 pp_left_paren (buffer
);
2775 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2776 pp_right_paren (buffer
);
2779 /* The initial value of a function serves to determine whether the function
2780 is declared or defined. So the following does not apply to function
2782 if (TREE_CODE (t
) != FUNCTION_DECL
)
2784 /* Print the initial value. */
2785 if (DECL_INITIAL (t
))
2790 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2794 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2796 pp_string (buffer
, " [value-expr: ");
2797 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2798 pp_right_bracket (buffer
);
2801 pp_semicolon (buffer
);
2805 /* Prints a structure: name, fields, and methods.
2806 FIXME: Still incomplete. */
2809 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2811 /* Print the name of the structure. */
2812 if (TYPE_NAME (node
))
2815 if (TREE_CODE (node
) == RECORD_TYPE
)
2816 pp_string (buffer
, "struct ");
2817 else if ((TREE_CODE (node
) == UNION_TYPE
2818 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2819 pp_string (buffer
, "union ");
2821 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2824 /* Print the contents of the structure. */
2825 pp_newline (buffer
);
2827 pp_left_brace (buffer
);
2828 pp_newline (buffer
);
2830 /* Print the fields of the structure. */
2833 tmp
= TYPE_FIELDS (node
);
2836 /* Avoid to print recursively the structure. */
2837 /* FIXME : Not implemented correctly...,
2838 what about the case when we have a cycle in the contain graph? ...
2839 Maybe this could be solved by looking at the scope in which the
2840 structure was declared. */
2841 if (TREE_TYPE (tmp
) != node
2842 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2843 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2845 print_declaration (buffer
, tmp
, spc
+2, flags
);
2846 pp_newline (buffer
);
2848 tmp
= DECL_CHAIN (tmp
);
2852 pp_right_brace (buffer
);
2855 /* Return the priority of the operator CODE.
2857 From lowest to highest precedence with either left-to-right (L-R)
2858 or right-to-left (R-L) associativity]:
2861 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2873 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2874 15 [L-R] fn() [] -> .
2876 unary +, - and * have higher precedence than the corresponding binary
2880 op_code_prio (enum tree_code code
)
2897 case TRUTH_ORIF_EXPR
:
2900 case TRUTH_AND_EXPR
:
2901 case TRUTH_ANDIF_EXPR
:
2908 case TRUTH_XOR_EXPR
:
2925 case UNORDERED_EXPR
:
2936 case VEC_WIDEN_LSHIFT_HI_EXPR
:
2937 case VEC_WIDEN_LSHIFT_LO_EXPR
:
2938 case WIDEN_LSHIFT_EXPR
:
2941 case WIDEN_SUM_EXPR
:
2943 case POINTER_PLUS_EXPR
:
2947 case VEC_WIDEN_MULT_HI_EXPR
:
2948 case VEC_WIDEN_MULT_LO_EXPR
:
2949 case WIDEN_MULT_EXPR
:
2951 case WIDEN_MULT_PLUS_EXPR
:
2952 case WIDEN_MULT_MINUS_EXPR
:
2954 case MULT_HIGHPART_EXPR
:
2955 case TRUNC_DIV_EXPR
:
2957 case FLOOR_DIV_EXPR
:
2958 case ROUND_DIV_EXPR
:
2960 case EXACT_DIV_EXPR
:
2961 case TRUNC_MOD_EXPR
:
2963 case FLOOR_MOD_EXPR
:
2964 case ROUND_MOD_EXPR
:
2968 case TRUTH_NOT_EXPR
:
2970 case POSTINCREMENT_EXPR
:
2971 case POSTDECREMENT_EXPR
:
2972 case PREINCREMENT_EXPR
:
2973 case PREDECREMENT_EXPR
:
2979 case FIX_TRUNC_EXPR
:
2985 case ARRAY_RANGE_REF
:
2989 /* Special expressions. */
2995 case REDUC_MAX_EXPR
:
2996 case REDUC_MIN_EXPR
:
2997 case REDUC_PLUS_EXPR
:
2998 case VEC_LSHIFT_EXPR
:
2999 case VEC_RSHIFT_EXPR
:
3000 case VEC_UNPACK_HI_EXPR
:
3001 case VEC_UNPACK_LO_EXPR
:
3002 case VEC_UNPACK_FLOAT_HI_EXPR
:
3003 case VEC_UNPACK_FLOAT_LO_EXPR
:
3004 case VEC_PACK_TRUNC_EXPR
:
3005 case VEC_PACK_SAT_EXPR
:
3009 /* Return an arbitrarily high precedence to avoid surrounding single
3010 VAR_DECLs in ()s. */
3015 /* Return the priority of the operator OP. */
3018 op_prio (const_tree op
)
3020 enum tree_code code
;
3025 code
= TREE_CODE (op
);
3026 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
3027 return op_prio (TREE_OPERAND (op
, 0));
3029 return op_code_prio (code
);
3032 /* Return the symbol associated with operator CODE. */
3035 op_symbol_code (enum tree_code code
)
3043 case TRUTH_ORIF_EXPR
:
3046 case TRUTH_AND_EXPR
:
3047 case TRUTH_ANDIF_EXPR
:
3053 case TRUTH_XOR_EXPR
:
3063 case UNORDERED_EXPR
:
3109 case VEC_LSHIFT_EXPR
:
3112 case VEC_RSHIFT_EXPR
:
3115 case WIDEN_LSHIFT_EXPR
:
3118 case POINTER_PLUS_EXPR
:
3124 case REDUC_PLUS_EXPR
:
3127 case WIDEN_SUM_EXPR
:
3130 case WIDEN_MULT_EXPR
:
3133 case MULT_HIGHPART_EXPR
:
3143 case TRUTH_NOT_EXPR
:
3150 case TRUNC_DIV_EXPR
:
3157 case FLOOR_DIV_EXPR
:
3160 case ROUND_DIV_EXPR
:
3163 case EXACT_DIV_EXPR
:
3166 case TRUNC_MOD_EXPR
:
3172 case FLOOR_MOD_EXPR
:
3175 case ROUND_MOD_EXPR
:
3178 case PREDECREMENT_EXPR
:
3181 case PREINCREMENT_EXPR
:
3184 case POSTDECREMENT_EXPR
:
3187 case POSTINCREMENT_EXPR
:
3197 return "<<< ??? >>>";
3201 /* Return the symbol associated with operator OP. */
3204 op_symbol (const_tree op
)
3206 return op_symbol_code (TREE_CODE (op
));
3209 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3210 the gimple_call_fn of a GIMPLE_CALL. */
3213 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
3217 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
3218 op0
= TREE_OPERAND (op0
, 0);
3221 switch (TREE_CODE (op0
))
3226 dump_function_name (buffer
, op0
, flags
);
3232 op0
= TREE_OPERAND (op0
, 0);
3236 pp_left_paren (buffer
);
3237 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
3238 pp_string (buffer
, ") ? ");
3239 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
3240 pp_string (buffer
, " : ");
3241 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
3245 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
3246 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
3248 dump_generic_node (buffer
, op0
, 0, flags
, false);
3252 if (integer_zerop (TREE_OPERAND (op0
, 1)))
3254 op0
= TREE_OPERAND (op0
, 0);
3261 dump_generic_node (buffer
, op0
, 0, flags
, false);
3269 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3272 pretty_print_string (pretty_printer
*buffer
, const char *str
)
3282 pp_string (buffer
, "\\b");
3286 pp_string (buffer
, "\\f");
3290 pp_string (buffer
, "\\n");
3294 pp_string (buffer
, "\\r");
3298 pp_string (buffer
, "\\t");
3302 pp_string (buffer
, "\\v");
3306 pp_string (buffer
, "\\\\");
3310 pp_string (buffer
, "\\\"");
3314 pp_string (buffer
, "\\'");
3317 /* No need to handle \0; the loop terminates on \0. */
3320 pp_string (buffer
, "\\1");
3324 pp_string (buffer
, "\\2");
3328 pp_string (buffer
, "\\3");
3332 pp_string (buffer
, "\\4");
3336 pp_string (buffer
, "\\5");
3340 pp_string (buffer
, "\\6");
3344 pp_string (buffer
, "\\7");
3348 pp_character (buffer
, str
[0]);
3356 maybe_init_pretty_print (FILE *file
)
3360 new (&buffer
) pretty_printer ();
3361 pp_needs_newline (&buffer
) = true;
3362 pp_translate_identifiers (&buffer
) = false;
3366 buffer
.buffer
->stream
= file
;
3370 newline_and_indent (pretty_printer
*buffer
, int spc
)
3372 pp_newline (buffer
);
3376 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3377 it can also be used in front ends.
3378 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3382 percent_K_format (text_info
*text
)
3384 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
3385 gcc_assert (text
->locus
!= NULL
);
3386 *text
->locus
= EXPR_LOCATION (t
);
3387 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
3388 block
= TREE_BLOCK (t
);
3389 *pp_ti_abstract_origin (text
) = NULL
;
3393 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3394 representing the outermost block of an inlined function.
3395 So walk the BLOCK tree until we hit such a scope. */
3397 && TREE_CODE (block
) == BLOCK
)
3399 if (inlined_function_outer_scope_p (block
))
3401 *pp_ti_abstract_origin (text
) = block
;
3404 block
= BLOCK_SUPERCONTEXT (block
);
3410 && TREE_CODE (block
) == BLOCK
3411 && BLOCK_ABSTRACT_ORIGIN (block
))
3413 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
3415 while (TREE_CODE (ao
) == BLOCK
3416 && BLOCK_ABSTRACT_ORIGIN (ao
)
3417 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
3418 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
3420 if (TREE_CODE (ao
) == FUNCTION_DECL
)
3422 *pp_ti_abstract_origin (text
) = block
;
3425 block
= BLOCK_SUPERCONTEXT (block
);
3429 /* Print the identifier ID to PRETTY-PRINTER. */
3432 pp_tree_identifier (pretty_printer
*pp
, tree id
)
3434 if (pp_translate_identifiers (pp
))
3436 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
3437 pp_append_text (pp
, text
, text
+ strlen (text
));
3440 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
3441 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));
3444 /* A helper function that is used to dump function information before the
3448 dump_function_header (FILE *dump_file
, tree fdecl
, int flags
)
3450 const char *dname
, *aname
;
3451 struct cgraph_node
*node
= cgraph_get_node (fdecl
);
3452 struct function
*fun
= DECL_STRUCT_FUNCTION (fdecl
);
3454 dname
= lang_hooks
.decl_printable_name (fdecl
, 2);
3456 if (DECL_ASSEMBLER_NAME_SET_P (fdecl
))
3457 aname
= (IDENTIFIER_POINTER
3458 (DECL_ASSEMBLER_NAME (fdecl
)));
3460 aname
= "<unset-asm-name>";
3462 fprintf (dump_file
, "\n;; Function %s (%s, funcdef_no=%d",
3463 dname
, aname
, fun
->funcdef_no
);
3464 if (!(flags
& TDF_NOUID
))
3465 fprintf (dump_file
, ", decl_uid=%d", DECL_UID (fdecl
));
3468 fprintf (dump_file
, ", symbol_order=%d)%s\n\n", node
->order
,
3469 node
->frequency
== NODE_FREQUENCY_HOT
3471 : node
->frequency
== NODE_FREQUENCY_UNLIKELY_EXECUTED
3472 ? " (unlikely executed)"
3473 : node
->frequency
== NODE_FREQUENCY_EXECUTED_ONCE
3474 ? " (executed once)"
3478 fprintf (dump_file
, ")\n\n");
3481 /* Dump double_int D to pretty_printer PP. UNS is true
3482 if D is unsigned and false otherwise. */
3484 pp_double_int (pretty_printer
*pp
, double_int d
, bool uns
)
3487 pp_wide_integer (pp
, d
.low
);
3488 else if (d
.fits_uhwi ())
3489 pp_unsigned_wide_integer (pp
, d
.low
);
3492 unsigned HOST_WIDE_INT low
= d
.low
;
3493 HOST_WIDE_INT high
= d
.high
;
3494 if (!uns
&& d
.is_negative ())
3497 high
= ~high
+ !low
;
3500 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3502 sprintf (pp_buffer (pp
)->digit_buffer
,
3503 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
3504 (unsigned HOST_WIDE_INT
) high
, low
);
3505 pp_string (pp
, pp_buffer (pp
)->digit_buffer
);