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"
40 #include "internal-fn.h"
42 #include <new> // For placement-new.
44 /* Local functions, macros and variables. */
45 static const char *op_symbol (const_tree
);
46 static void pretty_print_string (pretty_printer
*, const char*);
47 static void newline_and_indent (pretty_printer
*, int);
48 static void maybe_init_pretty_print (FILE *);
49 static void print_struct_decl (pretty_printer
*, const_tree
, int, int);
50 static void do_niy (pretty_printer
*, const_tree
);
52 #define INDENT(SPACE) do { \
53 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
55 #define NIY do_niy (buffer, node)
57 static pretty_printer buffer
;
58 static int initialized
= 0;
60 /* Try to print something for an unknown tree code. */
63 do_niy (pretty_printer
*buffer
, const_tree node
)
67 pp_string (buffer
, "<<< Unknown tree: ");
68 pp_string (buffer
, get_tree_code_name (TREE_CODE (node
)));
72 len
= TREE_OPERAND_LENGTH (node
);
73 for (i
= 0; i
< len
; ++i
)
75 newline_and_indent (buffer
, 2);
76 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0, false);
80 pp_string (buffer
, " >>>");
83 /* Debugging function to print out a generic expression. */
86 debug_generic_expr (tree t
)
88 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
89 fprintf (stderr
, "\n");
92 /* Debugging function to print out a generic statement. */
95 debug_generic_stmt (tree t
)
97 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
98 fprintf (stderr
, "\n");
101 /* Debugging function to print out a chain of trees . */
104 debug_tree_chain (tree t
)
106 struct pointer_set_t
*seen
= pointer_set_create ();
110 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
111 fprintf (stderr
, " ");
113 if (pointer_set_insert (seen
, t
))
115 fprintf (stderr
, "... [cycled back to ");
116 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
117 fprintf (stderr
, "]");
121 fprintf (stderr
, "\n");
123 pointer_set_destroy (seen
);
126 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
128 print_generic_decl (FILE *file
, tree decl
, int flags
)
130 maybe_init_pretty_print (file
);
131 print_declaration (&buffer
, decl
, 2, flags
);
132 pp_write_text_to_stream (&buffer
);
135 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
136 to show in the dump. See TDF_* in dumpfile.h. */
139 print_generic_stmt (FILE *file
, tree t
, int flags
)
141 maybe_init_pretty_print (file
);
142 dump_generic_node (&buffer
, t
, 0, flags
, true);
143 pp_newline_and_flush (&buffer
);
146 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
147 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
151 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
155 maybe_init_pretty_print (file
);
157 for (i
= 0; i
< indent
; i
++)
159 dump_generic_node (&buffer
, t
, indent
, flags
, true);
160 pp_newline_and_flush (&buffer
);
163 /* Print a single expression T on file FILE. FLAGS specifies details to show
164 in the dump. See TDF_* in dumpfile.h. */
167 print_generic_expr (FILE *file
, tree t
, int flags
)
169 maybe_init_pretty_print (file
);
170 dump_generic_node (&buffer
, t
, 0, flags
, false);
174 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
178 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
180 if (DECL_NAME (node
))
182 if ((flags
& TDF_ASMNAME
) && DECL_ASSEMBLER_NAME_SET_P (node
))
183 pp_tree_identifier (buffer
, DECL_ASSEMBLER_NAME (node
));
185 pp_tree_identifier (buffer
, DECL_NAME (node
));
187 if ((flags
& TDF_UID
) || DECL_NAME (node
) == NULL_TREE
)
189 if (TREE_CODE (node
) == LABEL_DECL
&& LABEL_DECL_UID (node
) != -1)
190 pp_printf (buffer
, "L.%d", (int) LABEL_DECL_UID (node
));
191 else if (TREE_CODE (node
) == DEBUG_EXPR_DECL
)
193 if (flags
& TDF_NOUID
)
194 pp_string (buffer
, "D#xxxx");
196 pp_printf (buffer
, "D#%i", DEBUG_TEMP_UID (node
));
200 char c
= TREE_CODE (node
) == CONST_DECL
? 'C' : 'D';
201 if (flags
& TDF_NOUID
)
202 pp_printf (buffer
, "%c.xxxx", c
);
204 pp_printf (buffer
, "%c.%u", c
, DECL_UID (node
));
207 if ((flags
& TDF_ALIAS
) && DECL_PT_UID (node
) != DECL_UID (node
))
209 if (flags
& TDF_NOUID
)
210 pp_printf (buffer
, "ptD.xxxx");
212 pp_printf (buffer
, "ptD.%u", DECL_PT_UID (node
));
216 /* Like the above, but used for pretty printing function calls. */
219 dump_function_name (pretty_printer
*buffer
, tree node
, int flags
)
221 if (TREE_CODE (node
) == NOP_EXPR
)
222 node
= TREE_OPERAND (node
, 0);
223 if (DECL_NAME (node
) && (flags
& TDF_ASMNAME
) == 0)
224 pp_string (buffer
, lang_hooks
.decl_printable_name (node
, 1));
226 dump_decl_name (buffer
, node
, flags
);
229 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
230 FLAGS are as in dump_generic_node. */
233 dump_function_declaration (pretty_printer
*buffer
, tree node
,
236 bool wrote_arg
= false;
240 pp_left_paren (buffer
);
242 /* Print the argument types. */
243 arg
= TYPE_ARG_TYPES (node
);
244 while (arg
&& arg
!= void_list_node
&& arg
!= error_mark_node
)
252 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
253 arg
= TREE_CHAIN (arg
);
256 /* Drop the trailing void_type_node if we had any previous argument. */
257 if (arg
== void_list_node
&& !wrote_arg
)
258 pp_string (buffer
, "void");
259 /* Properly dump vararg function types. */
260 else if (!arg
&& wrote_arg
)
261 pp_string (buffer
, ", ...");
262 /* Avoid printing any arg for unprototyped functions. */
264 pp_right_paren (buffer
);
267 /* Dump the domain associated with an array. */
270 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
272 pp_left_bracket (buffer
);
275 tree min
= TYPE_MIN_VALUE (domain
);
276 tree max
= TYPE_MAX_VALUE (domain
);
279 && integer_zerop (min
)
280 && tree_fits_shwi_p (max
))
281 pp_wide_integer (buffer
, tree_to_shwi (max
) + 1);
285 dump_generic_node (buffer
, min
, spc
, flags
, false);
288 dump_generic_node (buffer
, max
, spc
, flags
, false);
292 pp_string (buffer
, "<unknown>");
293 pp_right_bracket (buffer
);
297 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
298 dump_generic_node. */
301 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
305 switch (OMP_CLAUSE_CODE (clause
))
307 case OMP_CLAUSE_PRIVATE
:
310 case OMP_CLAUSE_SHARED
:
313 case OMP_CLAUSE_FIRSTPRIVATE
:
314 name
= "firstprivate";
316 case OMP_CLAUSE_LASTPRIVATE
:
317 name
= "lastprivate";
319 case OMP_CLAUSE_COPYIN
:
322 case OMP_CLAUSE_COPYPRIVATE
:
323 name
= "copyprivate";
325 case OMP_CLAUSE_UNIFORM
:
328 case OMP_CLAUSE__LOOPTEMP_
:
332 pp_string (buffer
, name
);
333 pp_left_paren (buffer
);
334 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
336 pp_right_paren (buffer
);
339 case OMP_CLAUSE_REDUCTION
:
340 pp_string (buffer
, "reduction(");
341 if (OMP_CLAUSE_REDUCTION_CODE (clause
) != ERROR_MARK
)
344 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
347 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
349 pp_right_paren (buffer
);
353 pp_string (buffer
, "if(");
354 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
356 pp_right_paren (buffer
);
359 case OMP_CLAUSE_NUM_THREADS
:
360 pp_string (buffer
, "num_threads(");
361 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
363 pp_right_paren (buffer
);
366 case OMP_CLAUSE_NOWAIT
:
367 pp_string (buffer
, "nowait");
369 case OMP_CLAUSE_ORDERED
:
370 pp_string (buffer
, "ordered");
373 case OMP_CLAUSE_DEFAULT
:
374 pp_string (buffer
, "default(");
375 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
377 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
379 case OMP_CLAUSE_DEFAULT_SHARED
:
380 pp_string (buffer
, "shared");
382 case OMP_CLAUSE_DEFAULT_NONE
:
383 pp_string (buffer
, "none");
385 case OMP_CLAUSE_DEFAULT_PRIVATE
:
386 pp_string (buffer
, "private");
388 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE
:
389 pp_string (buffer
, "firstprivate");
394 pp_right_paren (buffer
);
397 case OMP_CLAUSE_SCHEDULE
:
398 pp_string (buffer
, "schedule(");
399 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
401 case OMP_CLAUSE_SCHEDULE_STATIC
:
402 pp_string (buffer
, "static");
404 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
405 pp_string (buffer
, "dynamic");
407 case OMP_CLAUSE_SCHEDULE_GUIDED
:
408 pp_string (buffer
, "guided");
410 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
411 pp_string (buffer
, "runtime");
413 case OMP_CLAUSE_SCHEDULE_AUTO
:
414 pp_string (buffer
, "auto");
419 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
422 dump_generic_node (buffer
, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
425 pp_right_paren (buffer
);
428 case OMP_CLAUSE_UNTIED
:
429 pp_string (buffer
, "untied");
432 case OMP_CLAUSE_COLLAPSE
:
433 pp_string (buffer
, "collapse(");
434 dump_generic_node (buffer
, OMP_CLAUSE_COLLAPSE_EXPR (clause
),
436 pp_right_paren (buffer
);
439 case OMP_CLAUSE_FINAL
:
440 pp_string (buffer
, "final(");
441 dump_generic_node (buffer
, OMP_CLAUSE_FINAL_EXPR (clause
),
443 pp_right_paren (buffer
);
446 case OMP_CLAUSE_MERGEABLE
:
447 pp_string (buffer
, "mergeable");
450 case OMP_CLAUSE_LINEAR
:
451 pp_string (buffer
, "linear(");
452 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
455 dump_generic_node (buffer
, OMP_CLAUSE_LINEAR_STEP (clause
),
457 pp_right_paren (buffer
);
460 case OMP_CLAUSE_ALIGNED
:
461 pp_string (buffer
, "aligned(");
462 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
464 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause
))
467 dump_generic_node (buffer
, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause
),
470 pp_right_paren (buffer
);
473 case OMP_CLAUSE_DEPEND
:
474 pp_string (buffer
, "depend(");
475 switch (OMP_CLAUSE_DEPEND_KIND (clause
))
477 case OMP_CLAUSE_DEPEND_IN
:
478 pp_string (buffer
, "in");
480 case OMP_CLAUSE_DEPEND_OUT
:
481 pp_string (buffer
, "out");
483 case OMP_CLAUSE_DEPEND_INOUT
:
484 pp_string (buffer
, "inout");
490 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
492 pp_right_paren (buffer
);
496 pp_string (buffer
, "map(");
497 switch (OMP_CLAUSE_MAP_KIND (clause
))
499 case OMP_CLAUSE_MAP_ALLOC
:
500 case OMP_CLAUSE_MAP_POINTER
:
501 pp_string (buffer
, "alloc");
503 case OMP_CLAUSE_MAP_TO
:
504 case OMP_CLAUSE_MAP_TO_PSET
:
505 pp_string (buffer
, "to");
507 case OMP_CLAUSE_MAP_FROM
:
508 pp_string (buffer
, "from");
510 case OMP_CLAUSE_MAP_TOFROM
:
511 pp_string (buffer
, "tofrom");
517 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
520 if (OMP_CLAUSE_SIZE (clause
))
522 if (OMP_CLAUSE_CODE (clause
) == OMP_CLAUSE_MAP
523 && OMP_CLAUSE_MAP_KIND (clause
) == OMP_CLAUSE_MAP_POINTER
)
524 pp_string (buffer
, " [pointer assign, bias: ");
525 else if (OMP_CLAUSE_CODE (clause
) == OMP_CLAUSE_MAP
526 && OMP_CLAUSE_MAP_KIND (clause
) == OMP_CLAUSE_MAP_TO_PSET
)
527 pp_string (buffer
, " [pointer set, len: ");
529 pp_string (buffer
, " [len: ");
530 dump_generic_node (buffer
, OMP_CLAUSE_SIZE (clause
),
532 pp_right_bracket (buffer
);
534 pp_right_paren (buffer
);
537 case OMP_CLAUSE_FROM
:
538 pp_string (buffer
, "from(");
539 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
541 goto print_clause_size
;
544 pp_string (buffer
, "to(");
545 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
547 goto print_clause_size
;
549 case OMP_CLAUSE_NUM_TEAMS
:
550 pp_string (buffer
, "num_teams(");
551 dump_generic_node (buffer
, OMP_CLAUSE_NUM_TEAMS_EXPR (clause
),
553 pp_right_paren (buffer
);
556 case OMP_CLAUSE_THREAD_LIMIT
:
557 pp_string (buffer
, "thread_limit(");
558 dump_generic_node (buffer
, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause
),
560 pp_right_paren (buffer
);
563 case OMP_CLAUSE_DEVICE
:
564 pp_string (buffer
, "device(");
565 dump_generic_node (buffer
, OMP_CLAUSE_DEVICE_ID (clause
),
567 pp_right_paren (buffer
);
570 case OMP_CLAUSE_DIST_SCHEDULE
:
571 pp_string (buffer
, "dist_schedule(static");
572 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause
))
575 dump_generic_node (buffer
,
576 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause
),
579 pp_right_paren (buffer
);
582 case OMP_CLAUSE_PROC_BIND
:
583 pp_string (buffer
, "proc_bind(");
584 switch (OMP_CLAUSE_PROC_BIND_KIND (clause
))
586 case OMP_CLAUSE_PROC_BIND_MASTER
:
587 pp_string (buffer
, "master");
589 case OMP_CLAUSE_PROC_BIND_CLOSE
:
590 pp_string (buffer
, "close");
592 case OMP_CLAUSE_PROC_BIND_SPREAD
:
593 pp_string (buffer
, "spread");
598 pp_right_paren (buffer
);
601 case OMP_CLAUSE_SAFELEN
:
602 pp_string (buffer
, "safelen(");
603 dump_generic_node (buffer
, OMP_CLAUSE_SAFELEN_EXPR (clause
),
605 pp_right_paren (buffer
);
608 case OMP_CLAUSE_SIMDLEN
:
609 pp_string (buffer
, "simdlen(");
610 dump_generic_node (buffer
, OMP_CLAUSE_SIMDLEN_EXPR (clause
),
612 pp_right_paren (buffer
);
615 case OMP_CLAUSE__SIMDUID_
:
616 pp_string (buffer
, "_simduid_(");
617 dump_generic_node (buffer
, OMP_CLAUSE__SIMDUID__DECL (clause
),
619 pp_right_paren (buffer
);
622 case OMP_CLAUSE_INBRANCH
:
623 pp_string (buffer
, "inbranch");
625 case OMP_CLAUSE_NOTINBRANCH
:
626 pp_string (buffer
, "notinbranch");
629 pp_string (buffer
, "for");
631 case OMP_CLAUSE_PARALLEL
:
632 pp_string (buffer
, "parallel");
634 case OMP_CLAUSE_SECTIONS
:
635 pp_string (buffer
, "sections");
637 case OMP_CLAUSE_TASKGROUP
:
638 pp_string (buffer
, "taskgroup");
642 /* Should never happen. */
643 dump_generic_node (buffer
, clause
, spc
, flags
, false);
649 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
650 dump_generic_node. */
653 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
661 dump_omp_clause (buffer
, clause
, spc
, flags
);
662 clause
= OMP_CLAUSE_CHAIN (clause
);
670 /* Dump location LOC to BUFFER. */
673 dump_location (pretty_printer
*buffer
, location_t loc
)
675 expanded_location xloc
= expand_location (loc
);
677 pp_left_bracket (buffer
);
680 pp_string (buffer
, xloc
.file
);
681 pp_string (buffer
, " : ");
683 pp_decimal_int (buffer
, xloc
.line
);
684 pp_string (buffer
, "] ");
688 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
689 dump_generic_node. */
692 dump_block_node (pretty_printer
*buffer
, tree block
, int spc
, int flags
)
696 pp_printf (buffer
, "BLOCK #%d ", BLOCK_NUMBER (block
));
698 if (flags
& TDF_ADDRESS
)
699 pp_printf (buffer
, "[%p] ", (void *) block
);
701 if (BLOCK_ABSTRACT (block
))
702 pp_string (buffer
, "[abstract] ");
704 if (TREE_ASM_WRITTEN (block
))
705 pp_string (buffer
, "[written] ");
707 if (flags
& TDF_SLIM
)
710 if (BLOCK_SOURCE_LOCATION (block
))
711 dump_location (buffer
, BLOCK_SOURCE_LOCATION (block
));
713 newline_and_indent (buffer
, spc
+ 2);
715 if (BLOCK_SUPERCONTEXT (block
))
717 pp_string (buffer
, "SUPERCONTEXT: ");
718 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (block
), 0,
719 flags
| TDF_SLIM
, false);
720 newline_and_indent (buffer
, spc
+ 2);
723 if (BLOCK_SUBBLOCKS (block
))
725 pp_string (buffer
, "SUBBLOCKS: ");
726 for (t
= BLOCK_SUBBLOCKS (block
); t
; t
= BLOCK_CHAIN (t
))
728 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
731 newline_and_indent (buffer
, spc
+ 2);
734 if (BLOCK_CHAIN (block
))
736 pp_string (buffer
, "SIBLINGS: ");
737 for (t
= BLOCK_CHAIN (block
); t
; t
= BLOCK_CHAIN (t
))
739 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
742 newline_and_indent (buffer
, spc
+ 2);
745 if (BLOCK_VARS (block
))
747 pp_string (buffer
, "VARS: ");
748 for (t
= BLOCK_VARS (block
); t
; t
= TREE_CHAIN (t
))
750 dump_generic_node (buffer
, t
, 0, flags
, false);
753 newline_and_indent (buffer
, spc
+ 2);
756 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block
)) > 0)
759 vec
<tree
, va_gc
> *nlv
= BLOCK_NONLOCALIZED_VARS (block
);
761 pp_string (buffer
, "NONLOCALIZED_VARS: ");
762 FOR_EACH_VEC_ELT (*nlv
, i
, t
)
764 dump_generic_node (buffer
, t
, 0, flags
, false);
767 newline_and_indent (buffer
, spc
+ 2);
770 if (BLOCK_ABSTRACT_ORIGIN (block
))
772 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
773 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (block
), 0,
774 flags
| TDF_SLIM
, false);
775 newline_and_indent (buffer
, spc
+ 2);
778 if (BLOCK_FRAGMENT_ORIGIN (block
))
780 pp_string (buffer
, "FRAGMENT_ORIGIN: ");
781 dump_generic_node (buffer
, BLOCK_FRAGMENT_ORIGIN (block
), 0,
782 flags
| TDF_SLIM
, false);
783 newline_and_indent (buffer
, spc
+ 2);
786 if (BLOCK_FRAGMENT_CHAIN (block
))
788 pp_string (buffer
, "FRAGMENT_CHAIN: ");
789 for (t
= BLOCK_FRAGMENT_CHAIN (block
); t
; t
= BLOCK_FRAGMENT_CHAIN (t
))
791 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
794 newline_and_indent (buffer
, spc
+ 2);
799 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
800 indent. FLAGS specifies details to show in the dump (see TDF_* in
801 dumpfile.h). If IS_STMT is true, the object printed is considered
802 to be a statement and it is terminated by ';' if appropriate. */
805 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
814 if (node
== NULL_TREE
)
817 is_expr
= EXPR_P (node
);
819 if (is_stmt
&& (flags
& TDF_STMTADDR
))
820 pp_printf (buffer
, "<&%p> ", (void *)node
);
822 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
823 dump_location (buffer
, EXPR_LOCATION (node
));
825 code
= TREE_CODE (node
);
829 pp_string (buffer
, "<<< error >>>");
832 case IDENTIFIER_NODE
:
833 pp_tree_identifier (buffer
, node
);
837 while (node
&& node
!= error_mark_node
)
839 if (TREE_PURPOSE (node
))
841 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
844 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
845 node
= TREE_CHAIN (node
);
846 if (node
&& TREE_CODE (node
) == TREE_LIST
)
855 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
861 if (TREE_VEC_LENGTH (node
) > 0)
863 size_t len
= TREE_VEC_LENGTH (node
);
864 for (i
= 0; i
< len
- 1; i
++)
866 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
871 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
880 case FIXED_POINT_TYPE
:
886 unsigned int quals
= TYPE_QUALS (node
);
887 enum tree_code_class tclass
;
889 if (quals
& TYPE_QUAL_ATOMIC
)
890 pp_string (buffer
, "atomic ");
891 if (quals
& TYPE_QUAL_CONST
)
892 pp_string (buffer
, "const ");
893 else if (quals
& TYPE_QUAL_VOLATILE
)
894 pp_string (buffer
, "volatile ");
895 else if (quals
& TYPE_QUAL_RESTRICT
)
896 pp_string (buffer
, "restrict ");
898 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
900 pp_string (buffer
, "<address-space-");
901 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
902 pp_string (buffer
, "> ");
905 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
907 if (tclass
== tcc_declaration
)
909 if (DECL_NAME (node
))
910 dump_decl_name (buffer
, node
, flags
);
912 pp_string (buffer
, "<unnamed type decl>");
914 else if (tclass
== tcc_type
)
916 if (TYPE_NAME (node
))
918 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
919 pp_tree_identifier (buffer
, TYPE_NAME (node
));
920 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
921 && DECL_NAME (TYPE_NAME (node
)))
922 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
924 pp_string (buffer
, "<unnamed type>");
926 else if (TREE_CODE (node
) == VECTOR_TYPE
)
928 pp_string (buffer
, "vector");
929 pp_left_paren (buffer
);
930 pp_wide_integer (buffer
, TYPE_VECTOR_SUBPARTS (node
));
931 pp_string (buffer
, ") ");
932 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
934 else if (TREE_CODE (node
) == INTEGER_TYPE
)
936 if (TYPE_PRECISION (node
) == CHAR_TYPE_SIZE
)
937 pp_string (buffer
, (TYPE_UNSIGNED (node
)
940 else if (TYPE_PRECISION (node
) == SHORT_TYPE_SIZE
)
941 pp_string (buffer
, (TYPE_UNSIGNED (node
)
944 else if (TYPE_PRECISION (node
) == INT_TYPE_SIZE
)
945 pp_string (buffer
, (TYPE_UNSIGNED (node
)
948 else if (TYPE_PRECISION (node
) == LONG_TYPE_SIZE
)
949 pp_string (buffer
, (TYPE_UNSIGNED (node
)
952 else if (TYPE_PRECISION (node
) == LONG_LONG_TYPE_SIZE
)
953 pp_string (buffer
, (TYPE_UNSIGNED (node
)
954 ? "unsigned long long"
955 : "signed long long"));
956 else if (TYPE_PRECISION (node
) >= CHAR_TYPE_SIZE
957 && exact_log2 (TYPE_PRECISION (node
)) != -1)
959 pp_string (buffer
, (TYPE_UNSIGNED (node
) ? "uint" : "int"));
960 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
961 pp_string (buffer
, "_t");
965 pp_string (buffer
, (TYPE_UNSIGNED (node
)
966 ? "<unnamed-unsigned:"
967 : "<unnamed-signed:"));
968 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
972 else if (TREE_CODE (node
) == COMPLEX_TYPE
)
974 pp_string (buffer
, "__complex__ ");
975 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
977 else if (TREE_CODE (node
) == REAL_TYPE
)
979 pp_string (buffer
, "<float:");
980 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
983 else if (TREE_CODE (node
) == FIXED_POINT_TYPE
)
985 pp_string (buffer
, "<fixed-point-");
986 pp_string (buffer
, TYPE_SATURATING (node
) ? "sat:" : "nonsat:");
987 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
990 else if (TREE_CODE (node
) == VOID_TYPE
)
991 pp_string (buffer
, "void");
993 pp_string (buffer
, "<unnamed type>");
1000 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
1002 if (TREE_TYPE (node
) == NULL
)
1004 pp_string (buffer
, str
);
1005 pp_string (buffer
, "<null type>");
1007 else if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
1009 tree fnode
= TREE_TYPE (node
);
1011 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
1013 pp_left_paren (buffer
);
1014 pp_string (buffer
, str
);
1015 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1016 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1017 else if (flags
& TDF_NOUID
)
1018 pp_printf (buffer
, "<Txxxx>");
1020 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1022 pp_right_paren (buffer
);
1023 dump_function_declaration (buffer
, fnode
, spc
, flags
);
1027 unsigned int quals
= TYPE_QUALS (node
);
1029 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1031 pp_string (buffer
, str
);
1033 if (quals
& TYPE_QUAL_CONST
)
1034 pp_string (buffer
, " const");
1035 if (quals
& TYPE_QUAL_VOLATILE
)
1036 pp_string (buffer
, " volatile");
1037 if (quals
& TYPE_QUAL_RESTRICT
)
1038 pp_string (buffer
, " restrict");
1040 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
1042 pp_string (buffer
, " <address-space-");
1043 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
1044 pp_greater (buffer
);
1047 if (TYPE_REF_CAN_ALIAS_ALL (node
))
1048 pp_string (buffer
, " {ref-all}");
1058 if (integer_zerop (TREE_OPERAND (node
, 1))
1059 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1060 infer them and MEM_ATTR caching will share MEM_REFs
1061 with differently-typed op0s. */
1062 && TREE_CODE (TREE_OPERAND (node
, 0)) != INTEGER_CST
1063 /* Released SSA_NAMES have no TREE_TYPE. */
1064 && TREE_TYPE (TREE_OPERAND (node
, 0)) != NULL_TREE
1065 /* Same pointer types, but ignoring POINTER_TYPE vs.
1067 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 0)))
1068 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))
1069 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 0)))
1070 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 1))))
1071 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 0)))
1072 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 1))))
1073 /* Same value types ignoring qualifiers. */
1074 && (TYPE_MAIN_VARIANT (TREE_TYPE (node
))
1075 == TYPE_MAIN_VARIANT
1076 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))))
1078 if (TREE_CODE (TREE_OPERAND (node
, 0)) != ADDR_EXPR
)
1081 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1085 dump_generic_node (buffer
,
1086 TREE_OPERAND (TREE_OPERAND (node
, 0), 0),
1093 pp_string (buffer
, "MEM[");
1094 pp_left_paren (buffer
);
1095 ptype
= TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node
, 1)));
1096 dump_generic_node (buffer
, ptype
,
1097 spc
, flags
| TDF_SLIM
, false);
1098 pp_right_paren (buffer
);
1099 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1101 if (!integer_zerop (TREE_OPERAND (node
, 1)))
1103 pp_string (buffer
, " + ");
1104 dump_generic_node (buffer
, TREE_OPERAND (node
, 1),
1107 pp_right_bracket (buffer
);
1112 case TARGET_MEM_REF
:
1114 const char *sep
= "";
1117 pp_string (buffer
, "MEM[");
1119 if (TREE_CODE (TMR_BASE (node
)) == ADDR_EXPR
)
1121 pp_string (buffer
, sep
);
1123 pp_string (buffer
, "symbol: ");
1124 dump_generic_node (buffer
, TREE_OPERAND (TMR_BASE (node
), 0),
1129 pp_string (buffer
, sep
);
1131 pp_string (buffer
, "base: ");
1132 dump_generic_node (buffer
, TMR_BASE (node
), spc
, flags
, false);
1134 tmp
= TMR_INDEX2 (node
);
1137 pp_string (buffer
, sep
);
1139 pp_string (buffer
, "base: ");
1140 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1142 tmp
= TMR_INDEX (node
);
1145 pp_string (buffer
, sep
);
1147 pp_string (buffer
, "index: ");
1148 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1150 tmp
= TMR_STEP (node
);
1153 pp_string (buffer
, sep
);
1155 pp_string (buffer
, "step: ");
1156 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1158 tmp
= TMR_OFFSET (node
);
1161 pp_string (buffer
, sep
);
1163 pp_string (buffer
, "offset: ");
1164 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1166 pp_right_bracket (buffer
);
1174 /* Print the innermost component type. */
1175 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
1176 tmp
= TREE_TYPE (tmp
))
1178 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1180 /* Print the dimensions. */
1181 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
1182 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
1188 case QUAL_UNION_TYPE
:
1190 unsigned int quals
= TYPE_QUALS (node
);
1192 if (quals
& TYPE_QUAL_ATOMIC
)
1193 pp_string (buffer
, "atomic ");
1194 if (quals
& TYPE_QUAL_CONST
)
1195 pp_string (buffer
, "const ");
1196 if (quals
& TYPE_QUAL_VOLATILE
)
1197 pp_string (buffer
, "volatile ");
1199 /* Print the name of the structure. */
1200 if (TREE_CODE (node
) == RECORD_TYPE
)
1201 pp_string (buffer
, "struct ");
1202 else if (TREE_CODE (node
) == UNION_TYPE
)
1203 pp_string (buffer
, "union ");
1205 if (TYPE_NAME (node
))
1206 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
1207 else if (!(flags
& TDF_SLIM
))
1208 /* FIXME: If we eliminate the 'else' above and attempt
1209 to show the fields for named types, we may get stuck
1210 following a cycle of pointers to structs. The alleged
1211 self-reference check in print_struct_decl will not detect
1212 cycles involving more than one pointer or struct type. */
1213 print_struct_decl (buffer
, node
, spc
, flags
);
1222 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
1224 /* In the case of a pointer, one may want to divide by the
1225 size of the pointed-to type. Unfortunately, this not
1226 straightforward. The C front-end maps expressions
1231 in such a way that the two INTEGER_CST nodes for "5" have
1232 different values but identical types. In the latter
1233 case, the 5 is multiplied by sizeof (int) in c-common.c
1234 (pointer_int_sum) to convert it to a byte address, and
1235 yet the type of the node is left unchanged. Argh. What
1236 is consistent though is that the number value corresponds
1237 to bytes (UNITS) offset.
1239 NB: Neither of the following divisors can be trivially
1240 used to recover the original literal:
1242 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1243 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1244 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1245 pp_string (buffer
, "B"); /* pseudo-unit */
1247 else if (tree_fits_shwi_p (node
))
1248 pp_wide_integer (buffer
, tree_to_shwi (node
));
1249 else if (tree_fits_uhwi_p (node
))
1250 pp_unsigned_wide_integer (buffer
, tree_to_uhwi (node
));
1253 wide_int val
= node
;
1255 if (wi::neg_p (val
, TYPE_SIGN (TREE_TYPE (node
))))
1260 print_hex (val
, pp_buffer (buffer
)->digit_buffer
);
1261 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
1263 if (TREE_OVERFLOW (node
))
1264 pp_string (buffer
, "(OVF)");
1268 /* Code copied from print_node. */
1271 if (TREE_OVERFLOW (node
))
1272 pp_string (buffer
, " overflow");
1274 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1275 d
= TREE_REAL_CST (node
);
1276 if (REAL_VALUE_ISINF (d
))
1277 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
1278 else if (REAL_VALUE_ISNAN (d
))
1279 pp_string (buffer
, " Nan");
1283 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
1284 pp_string (buffer
, string
);
1289 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
1290 pp_string (buffer
, "0x");
1291 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
1292 output_formatted_integer (buffer
, "%02x", *p
++);
1301 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
1302 pp_string (buffer
, string
);
1307 pp_string (buffer
, "__complex__ (");
1308 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
1309 pp_string (buffer
, ", ");
1310 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
1311 pp_right_paren (buffer
);
1315 pp_string (buffer
, "\"");
1316 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
1317 pp_string (buffer
, "\"");
1323 pp_string (buffer
, "{ ");
1324 for (i
= 0; i
< VECTOR_CST_NELTS (node
); ++i
)
1327 pp_string (buffer
, ", ");
1328 dump_generic_node (buffer
, VECTOR_CST_ELT (node
, i
),
1331 pp_string (buffer
, " }");
1337 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1339 if (TREE_CODE (node
) == METHOD_TYPE
)
1341 if (TYPE_METHOD_BASETYPE (node
))
1342 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
1345 pp_string (buffer
, "<null method basetype>");
1346 pp_colon_colon (buffer
);
1348 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1349 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1350 else if (flags
& TDF_NOUID
)
1351 pp_printf (buffer
, "<Txxxx>");
1353 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1354 dump_function_declaration (buffer
, node
, spc
, flags
);
1359 dump_decl_name (buffer
, node
, flags
);
1363 if (DECL_NAME (node
))
1364 dump_decl_name (buffer
, node
, flags
);
1365 else if (LABEL_DECL_UID (node
) != -1)
1366 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1369 if (flags
& TDF_NOUID
)
1370 pp_string (buffer
, "<D.xxxx>");
1372 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1377 if (DECL_IS_BUILTIN (node
))
1379 /* Don't print the declaration of built-in types. */
1382 if (DECL_NAME (node
))
1383 dump_decl_name (buffer
, node
, flags
);
1384 else if (TYPE_NAME (TREE_TYPE (node
)) != node
)
1386 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1387 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1388 && TYPE_METHODS (TREE_TYPE (node
)))
1390 /* The type is a c++ class: all structures have at least
1392 pp_string (buffer
, "class ");
1393 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1398 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1399 ? "union" : "struct "));
1400 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1404 pp_string (buffer
, "<anon>");
1410 case DEBUG_EXPR_DECL
:
1411 case NAMESPACE_DECL
:
1413 dump_decl_name (buffer
, node
, flags
);
1417 pp_string (buffer
, "<retval>");
1421 op0
= TREE_OPERAND (node
, 0);
1424 && (TREE_CODE (op0
) == INDIRECT_REF
1425 || (TREE_CODE (op0
) == MEM_REF
1426 && TREE_CODE (TREE_OPERAND (op0
, 0)) != ADDR_EXPR
1427 && integer_zerop (TREE_OPERAND (op0
, 1))
1428 /* Dump the types of INTEGER_CSTs explicitly, for we
1429 can't infer them and MEM_ATTR caching will share
1430 MEM_REFs with differently-typed op0s. */
1431 && TREE_CODE (TREE_OPERAND (op0
, 0)) != INTEGER_CST
1432 /* Released SSA_NAMES have no TREE_TYPE. */
1433 && TREE_TYPE (TREE_OPERAND (op0
, 0)) != NULL_TREE
1434 /* Same pointer types, but ignoring POINTER_TYPE vs.
1436 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1437 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1438 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1439 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1440 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1441 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1442 /* Same value types ignoring qualifiers. */
1443 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0
))
1444 == TYPE_MAIN_VARIANT
1445 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))))))
1447 op0
= TREE_OPERAND (op0
, 0);
1450 if (op_prio (op0
) < op_prio (node
))
1451 pp_left_paren (buffer
);
1452 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1453 if (op_prio (op0
) < op_prio (node
))
1454 pp_right_paren (buffer
);
1455 pp_string (buffer
, str
);
1456 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1457 op0
= component_ref_field_offset (node
);
1458 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1460 pp_string (buffer
, "{off: ");
1461 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1462 pp_right_brace (buffer
);
1467 pp_string (buffer
, "BIT_FIELD_REF <");
1468 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1469 pp_string (buffer
, ", ");
1470 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1471 pp_string (buffer
, ", ");
1472 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1473 pp_greater (buffer
);
1477 case ARRAY_RANGE_REF
:
1478 op0
= TREE_OPERAND (node
, 0);
1479 if (op_prio (op0
) < op_prio (node
))
1480 pp_left_paren (buffer
);
1481 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1482 if (op_prio (op0
) < op_prio (node
))
1483 pp_right_paren (buffer
);
1484 pp_left_bracket (buffer
);
1485 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1486 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1487 pp_string (buffer
, " ...");
1488 pp_right_bracket (buffer
);
1490 op0
= array_ref_low_bound (node
);
1491 op1
= array_ref_element_size (node
);
1493 if (!integer_zerop (op0
)
1494 || TREE_OPERAND (node
, 2)
1495 || TREE_OPERAND (node
, 3))
1497 pp_string (buffer
, "{lb: ");
1498 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1499 pp_string (buffer
, " sz: ");
1500 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1501 pp_right_brace (buffer
);
1507 unsigned HOST_WIDE_INT ix
;
1509 bool is_struct_init
= false;
1510 bool is_array_init
= false;
1512 pp_left_brace (buffer
);
1513 if (TREE_CLOBBER_P (node
))
1514 pp_string (buffer
, "CLOBBER");
1515 else if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1516 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1517 is_struct_init
= true;
1518 else if (TREE_CODE (TREE_TYPE (node
)) == ARRAY_TYPE
1519 && TYPE_DOMAIN (TREE_TYPE (node
))
1520 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)))
1521 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
))))
1524 tree minv
= TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)));
1525 is_array_init
= true;
1526 curidx
= wi::to_widest (minv
);
1528 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1535 dump_generic_node (buffer
, field
, spc
, flags
, false);
1538 else if (is_array_init
1539 && (TREE_CODE (field
) != INTEGER_CST
1540 || curidx
!= wi::to_widest (field
)))
1542 pp_left_bracket (buffer
);
1543 if (TREE_CODE (field
) == RANGE_EXPR
)
1545 dump_generic_node (buffer
, TREE_OPERAND (field
, 0), spc
,
1547 pp_string (buffer
, " ... ");
1548 dump_generic_node (buffer
, TREE_OPERAND (field
, 1), spc
,
1550 if (TREE_CODE (TREE_OPERAND (field
, 1)) == INTEGER_CST
)
1551 curidx
= wi::to_widest (TREE_OPERAND (field
, 1));
1554 dump_generic_node (buffer
, field
, spc
, flags
, false);
1555 if (TREE_CODE (field
) == INTEGER_CST
)
1556 curidx
= wi::to_widest (field
);
1557 pp_string (buffer
, "]=");
1562 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1563 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1564 val
= TREE_OPERAND (val
, 0);
1565 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1566 dump_decl_name (buffer
, val
, flags
);
1568 dump_generic_node (buffer
, val
, spc
, flags
, false);
1569 if (ix
!= vec_safe_length (CONSTRUCTOR_ELTS (node
)) - 1)
1575 pp_right_brace (buffer
);
1582 if (flags
& TDF_SLIM
)
1584 pp_string (buffer
, "<COMPOUND_EXPR>");
1588 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1589 spc
, flags
, !(flags
& TDF_SLIM
));
1590 if (flags
& TDF_SLIM
)
1591 newline_and_indent (buffer
, spc
);
1598 for (tp
= &TREE_OPERAND (node
, 1);
1599 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1600 tp
= &TREE_OPERAND (*tp
, 1))
1602 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1603 spc
, flags
, !(flags
& TDF_SLIM
));
1604 if (flags
& TDF_SLIM
)
1605 newline_and_indent (buffer
, spc
);
1613 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1617 case STATEMENT_LIST
:
1619 tree_stmt_iterator si
;
1622 if (flags
& TDF_SLIM
)
1624 pp_string (buffer
, "<STATEMENT_LIST>");
1628 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1631 newline_and_indent (buffer
, spc
);
1634 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1641 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1646 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1651 pp_string (buffer
, "TARGET_EXPR <");
1652 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1655 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1656 pp_greater (buffer
);
1660 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1665 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1667 pp_string (buffer
, "if (");
1668 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1669 pp_right_paren (buffer
);
1670 /* The lowered cond_exprs should always be printed in full. */
1671 if (COND_EXPR_THEN (node
)
1672 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1673 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1674 && COND_EXPR_ELSE (node
)
1675 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1676 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1679 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1681 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1683 pp_string (buffer
, " else ");
1684 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1688 else if (!(flags
& TDF_SLIM
))
1690 /* Output COND_EXPR_THEN. */
1691 if (COND_EXPR_THEN (node
))
1693 newline_and_indent (buffer
, spc
+2);
1694 pp_left_brace (buffer
);
1695 newline_and_indent (buffer
, spc
+4);
1696 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1698 newline_and_indent (buffer
, spc
+2);
1699 pp_right_brace (buffer
);
1702 /* Output COND_EXPR_ELSE. */
1703 if (COND_EXPR_ELSE (node
)
1704 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1706 newline_and_indent (buffer
, spc
);
1707 pp_string (buffer
, "else");
1708 newline_and_indent (buffer
, spc
+2);
1709 pp_left_brace (buffer
);
1710 newline_and_indent (buffer
, spc
+4);
1711 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1713 newline_and_indent (buffer
, spc
+2);
1714 pp_right_brace (buffer
);
1721 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1723 pp_question (buffer
);
1725 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1729 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1734 pp_left_brace (buffer
);
1735 if (!(flags
& TDF_SLIM
))
1737 if (BIND_EXPR_VARS (node
))
1739 pp_newline (buffer
);
1741 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= DECL_CHAIN (op0
))
1743 print_declaration (buffer
, op0
, spc
+2, flags
);
1744 pp_newline (buffer
);
1748 newline_and_indent (buffer
, spc
+2);
1749 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1750 newline_and_indent (buffer
, spc
);
1751 pp_right_brace (buffer
);
1757 if (CALL_EXPR_FN (node
) != NULL_TREE
)
1758 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1760 pp_string (buffer
, internal_fn_name (CALL_EXPR_IFN (node
)));
1762 /* Print parameters. */
1764 pp_left_paren (buffer
);
1767 call_expr_arg_iterator iter
;
1768 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1770 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1771 if (more_call_expr_args_p (&iter
))
1778 if (CALL_EXPR_VA_ARG_PACK (node
))
1780 if (call_expr_nargs (node
) > 0)
1785 pp_string (buffer
, "__builtin_va_arg_pack ()");
1787 pp_right_paren (buffer
);
1789 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1792 pp_string (buffer
, " [static-chain: ");
1793 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1794 pp_right_bracket (buffer
);
1797 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1798 pp_string (buffer
, " [return slot optimization]");
1799 if (CALL_EXPR_TAILCALL (node
))
1800 pp_string (buffer
, " [tail call]");
1803 case WITH_CLEANUP_EXPR
:
1807 case CLEANUP_POINT_EXPR
:
1808 pp_string (buffer
, "<<cleanup_point ");
1809 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1810 pp_string (buffer
, ">>");
1813 case PLACEHOLDER_EXPR
:
1814 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1815 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1816 pp_greater (buffer
);
1819 /* Binary arithmetic and logic expressions. */
1820 case WIDEN_SUM_EXPR
:
1821 case WIDEN_MULT_EXPR
:
1823 case MULT_HIGHPART_EXPR
:
1825 case POINTER_PLUS_EXPR
:
1827 case TRUNC_DIV_EXPR
:
1829 case FLOOR_DIV_EXPR
:
1830 case ROUND_DIV_EXPR
:
1831 case TRUNC_MOD_EXPR
:
1833 case FLOOR_MOD_EXPR
:
1834 case ROUND_MOD_EXPR
:
1836 case EXACT_DIV_EXPR
:
1841 case VEC_LSHIFT_EXPR
:
1842 case VEC_RSHIFT_EXPR
:
1843 case WIDEN_LSHIFT_EXPR
:
1847 case TRUTH_ANDIF_EXPR
:
1848 case TRUTH_ORIF_EXPR
:
1849 case TRUTH_AND_EXPR
:
1851 case TRUTH_XOR_EXPR
:
1865 case UNORDERED_EXPR
:
1867 const char *op
= op_symbol (node
);
1868 op0
= TREE_OPERAND (node
, 0);
1869 op1
= TREE_OPERAND (node
, 1);
1871 /* When the operands are expressions with less priority,
1872 keep semantics of the tree representation. */
1873 if (op_prio (op0
) <= op_prio (node
))
1875 pp_left_paren (buffer
);
1876 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1877 pp_right_paren (buffer
);
1880 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1883 pp_string (buffer
, op
);
1886 /* When the operands are expressions with less priority,
1887 keep semantics of the tree representation. */
1888 if (op_prio (op1
) <= op_prio (node
))
1890 pp_left_paren (buffer
);
1891 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1892 pp_right_paren (buffer
);
1895 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1899 /* Unary arithmetic and logic expressions. */
1902 case TRUTH_NOT_EXPR
:
1904 case PREDECREMENT_EXPR
:
1905 case PREINCREMENT_EXPR
:
1907 if (TREE_CODE (node
) == ADDR_EXPR
1908 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1909 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1910 ; /* Do not output '&' for strings and function pointers. */
1912 pp_string (buffer
, op_symbol (node
));
1914 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1916 pp_left_paren (buffer
);
1917 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1918 pp_right_paren (buffer
);
1921 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1924 case POSTDECREMENT_EXPR
:
1925 case POSTINCREMENT_EXPR
:
1926 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1928 pp_left_paren (buffer
);
1929 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1930 pp_right_paren (buffer
);
1933 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1934 pp_string (buffer
, op_symbol (node
));
1938 pp_string (buffer
, "MIN_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
, "MAX_EXPR <");
1947 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1948 pp_string (buffer
, ", ");
1949 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1950 pp_greater (buffer
);
1954 pp_string (buffer
, "ABS_EXPR <");
1955 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1956 pp_greater (buffer
);
1963 case ADDR_SPACE_CONVERT_EXPR
:
1964 case FIXED_CONVERT_EXPR
:
1965 case FIX_TRUNC_EXPR
:
1968 type
= TREE_TYPE (node
);
1969 op0
= TREE_OPERAND (node
, 0);
1970 if (type
!= TREE_TYPE (op0
))
1972 pp_left_paren (buffer
);
1973 dump_generic_node (buffer
, type
, spc
, flags
, false);
1974 pp_string (buffer
, ") ");
1976 if (op_prio (op0
) < op_prio (node
))
1977 pp_left_paren (buffer
);
1978 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1979 if (op_prio (op0
) < op_prio (node
))
1980 pp_right_paren (buffer
);
1983 case VIEW_CONVERT_EXPR
:
1984 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1985 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1986 pp_string (buffer
, ">(");
1987 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1988 pp_right_paren (buffer
);
1992 pp_string (buffer
, "((");
1993 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1994 pp_string (buffer
, "))");
1997 case NON_LVALUE_EXPR
:
1998 pp_string (buffer
, "NON_LVALUE_EXPR <");
1999 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2000 pp_greater (buffer
);
2004 pp_string (buffer
, "SAVE_EXPR <");
2005 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2006 pp_greater (buffer
);
2010 pp_string (buffer
, "COMPLEX_EXPR <");
2011 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2012 pp_string (buffer
, ", ");
2013 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2014 pp_greater (buffer
);
2018 pp_string (buffer
, "CONJ_EXPR <");
2019 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2020 pp_greater (buffer
);
2024 pp_string (buffer
, "REALPART_EXPR <");
2025 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2026 pp_greater (buffer
);
2030 pp_string (buffer
, "IMAGPART_EXPR <");
2031 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2032 pp_greater (buffer
);
2036 pp_string (buffer
, "VA_ARG_EXPR <");
2037 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2038 pp_greater (buffer
);
2041 case TRY_FINALLY_EXPR
:
2042 case TRY_CATCH_EXPR
:
2043 pp_string (buffer
, "try");
2044 newline_and_indent (buffer
, spc
+2);
2045 pp_left_brace (buffer
);
2046 newline_and_indent (buffer
, spc
+4);
2047 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
2048 newline_and_indent (buffer
, spc
+2);
2049 pp_right_brace (buffer
);
2050 newline_and_indent (buffer
, spc
);
2052 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
2053 newline_and_indent (buffer
, spc
+2);
2054 pp_left_brace (buffer
);
2055 newline_and_indent (buffer
, spc
+4);
2056 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
2057 newline_and_indent (buffer
, spc
+2);
2058 pp_right_brace (buffer
);
2063 pp_string (buffer
, "catch (");
2064 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
2065 pp_right_paren (buffer
);
2066 newline_and_indent (buffer
, spc
+2);
2067 pp_left_brace (buffer
);
2068 newline_and_indent (buffer
, spc
+4);
2069 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
2070 newline_and_indent (buffer
, spc
+2);
2071 pp_right_brace (buffer
);
2075 case EH_FILTER_EXPR
:
2076 pp_string (buffer
, "<<<eh_filter (");
2077 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
2078 pp_string (buffer
, ")>>>");
2079 newline_and_indent (buffer
, spc
+2);
2080 pp_left_brace (buffer
);
2081 newline_and_indent (buffer
, spc
+4);
2082 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
2083 newline_and_indent (buffer
, spc
+2);
2084 pp_right_brace (buffer
);
2089 op0
= TREE_OPERAND (node
, 0);
2090 /* If this is for break or continue, don't bother printing it. */
2091 if (DECL_NAME (op0
))
2093 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
2094 if (strcmp (name
, "break") == 0
2095 || strcmp (name
, "continue") == 0)
2098 dump_generic_node (buffer
, op0
, spc
, flags
, false);
2100 if (DECL_NONLOCAL (op0
))
2101 pp_string (buffer
, " [non-local]");
2105 pp_string (buffer
, "while (1)");
2106 if (!(flags
& TDF_SLIM
))
2108 newline_and_indent (buffer
, spc
+2);
2109 pp_left_brace (buffer
);
2110 newline_and_indent (buffer
, spc
+4);
2111 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
2112 newline_and_indent (buffer
, spc
+2);
2113 pp_right_brace (buffer
);
2119 pp_string (buffer
, "// predicted ");
2120 if (PREDICT_EXPR_OUTCOME (node
))
2121 pp_string (buffer
, "likely by ");
2123 pp_string (buffer
, "unlikely by ");
2124 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
2125 pp_string (buffer
, " predictor.");
2129 pp_string (buffer
, "ANNOTATE_EXPR <");
2130 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2131 switch ((enum annot_expr_kind
) TREE_INT_CST_LOW (TREE_OPERAND (node
, 1)))
2133 case annot_expr_ivdep_kind
:
2134 pp_string (buffer
, ", ivdep");
2136 case annot_expr_no_vector_kind
:
2137 pp_string (buffer
, ", no-vector");
2139 case annot_expr_vector_kind
:
2140 pp_string (buffer
, ", vector");
2145 pp_greater (buffer
);
2149 pp_string (buffer
, "return");
2150 op0
= TREE_OPERAND (node
, 0);
2154 if (TREE_CODE (op0
) == MODIFY_EXPR
)
2155 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
2158 dump_generic_node (buffer
, op0
, spc
, flags
, false);
2163 pp_string (buffer
, "if (");
2164 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2165 pp_string (buffer
, ") break");
2169 pp_string (buffer
, "switch (");
2170 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
2171 pp_right_paren (buffer
);
2172 if (!(flags
& TDF_SLIM
))
2174 newline_and_indent (buffer
, spc
+2);
2175 pp_left_brace (buffer
);
2176 if (SWITCH_BODY (node
))
2178 newline_and_indent (buffer
, spc
+4);
2179 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
2184 tree vec
= SWITCH_LABELS (node
);
2185 size_t i
, n
= TREE_VEC_LENGTH (vec
);
2186 for (i
= 0; i
< n
; ++i
)
2188 tree elt
= TREE_VEC_ELT (vec
, i
);
2189 newline_and_indent (buffer
, spc
+4);
2192 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
2193 pp_string (buffer
, " goto ");
2194 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
2196 pp_semicolon (buffer
);
2199 pp_string (buffer
, "case ???: goto ???;");
2202 newline_and_indent (buffer
, spc
+2);
2203 pp_right_brace (buffer
);
2209 op0
= GOTO_DESTINATION (node
);
2210 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
2212 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
2213 if (strcmp (name
, "break") == 0
2214 || strcmp (name
, "continue") == 0)
2216 pp_string (buffer
, name
);
2220 pp_string (buffer
, "goto ");
2221 dump_generic_node (buffer
, op0
, spc
, flags
, false);
2225 pp_string (buffer
, "__asm__");
2226 if (ASM_VOLATILE_P (node
))
2227 pp_string (buffer
, " __volatile__");
2228 pp_left_paren (buffer
);
2229 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
2231 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
2233 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
2234 if (ASM_CLOBBERS (node
))
2237 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
2239 pp_right_paren (buffer
);
2242 case CASE_LABEL_EXPR
:
2243 if (CASE_LOW (node
) && CASE_HIGH (node
))
2245 pp_string (buffer
, "case ");
2246 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
2247 pp_string (buffer
, " ... ");
2248 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
2250 else if (CASE_LOW (node
))
2252 pp_string (buffer
, "case ");
2253 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
2256 pp_string (buffer
, "default");
2261 pp_string (buffer
, "OBJ_TYPE_REF(");
2262 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
2263 pp_semicolon (buffer
);
2264 if (!(flags
& TDF_SLIM
) && virtual_method_call_p (node
))
2266 pp_string (buffer
, "(");
2267 dump_generic_node (buffer
, obj_type_ref_class (node
), spc
, flags
, false);
2268 pp_string (buffer
, ")");
2270 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
2272 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
2273 pp_right_paren (buffer
);
2277 if (SSA_NAME_IDENTIFIER (node
))
2278 dump_generic_node (buffer
, SSA_NAME_IDENTIFIER (node
),
2280 pp_underscore (buffer
);
2281 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
2282 if (SSA_NAME_IS_DEFAULT_DEF (node
))
2283 pp_string (buffer
, "(D)");
2284 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
2285 pp_string (buffer
, "(ab)");
2288 case WITH_SIZE_EXPR
:
2289 pp_string (buffer
, "WITH_SIZE_EXPR <");
2290 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2291 pp_string (buffer
, ", ");
2292 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2293 pp_greater (buffer
);
2297 pp_string (buffer
, "ASSERT_EXPR <");
2298 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
2299 pp_string (buffer
, ", ");
2300 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
2301 pp_greater (buffer
);
2305 pp_string (buffer
, "scev_known");
2308 case SCEV_NOT_KNOWN
:
2309 pp_string (buffer
, "scev_not_known");
2312 case POLYNOMIAL_CHREC
:
2313 pp_left_brace (buffer
);
2314 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
2315 pp_string (buffer
, ", +, ");
2316 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
2317 pp_string (buffer
, "}_");
2318 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
2322 case REALIGN_LOAD_EXPR
:
2323 pp_string (buffer
, "REALIGN_LOAD <");
2324 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2325 pp_string (buffer
, ", ");
2326 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2327 pp_string (buffer
, ", ");
2328 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2329 pp_greater (buffer
);
2333 pp_string (buffer
, " VEC_COND_EXPR < ");
2334 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2335 pp_string (buffer
, " , ");
2336 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2337 pp_string (buffer
, " , ");
2338 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2339 pp_string (buffer
, " > ");
2343 pp_string (buffer
, " VEC_PERM_EXPR < ");
2344 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2345 pp_string (buffer
, " , ");
2346 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2347 pp_string (buffer
, " , ");
2348 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2349 pp_string (buffer
, " > ");
2353 pp_string (buffer
, " DOT_PROD_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
, ", ");
2358 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2359 pp_string (buffer
, " > ");
2362 case WIDEN_MULT_PLUS_EXPR
:
2363 pp_string (buffer
, " WIDEN_MULT_PLUS_EXPR < ");
2364 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2365 pp_string (buffer
, ", ");
2366 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2367 pp_string (buffer
, ", ");
2368 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2369 pp_string (buffer
, " > ");
2372 case WIDEN_MULT_MINUS_EXPR
:
2373 pp_string (buffer
, " WIDEN_MULT_MINUS_EXPR < ");
2374 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2375 pp_string (buffer
, ", ");
2376 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2377 pp_string (buffer
, ", ");
2378 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2379 pp_string (buffer
, " > ");
2383 pp_string (buffer
, " FMA_EXPR < ");
2384 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2385 pp_string (buffer
, ", ");
2386 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2387 pp_string (buffer
, ", ");
2388 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2389 pp_string (buffer
, " > ");
2393 pp_string (buffer
, "#pragma omp parallel");
2394 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
2397 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
2399 newline_and_indent (buffer
, spc
+ 2);
2400 pp_left_brace (buffer
);
2401 newline_and_indent (buffer
, spc
+ 4);
2402 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
2403 newline_and_indent (buffer
, spc
+ 2);
2404 pp_right_brace (buffer
);
2410 pp_string (buffer
, "#pragma omp task");
2411 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
2415 pp_string (buffer
, "#pragma omp for");
2419 pp_string (buffer
, "#pragma omp simd");
2423 pp_string (buffer
, "#pragma simd");
2426 case OMP_DISTRIBUTE
:
2427 pp_string (buffer
, "#pragma omp distribute");
2431 pp_string (buffer
, "#pragma omp teams");
2432 dump_omp_clauses (buffer
, OMP_TEAMS_CLAUSES (node
), spc
, flags
);
2435 case OMP_TARGET_DATA
:
2436 pp_string (buffer
, "#pragma omp target data");
2437 dump_omp_clauses (buffer
, OMP_TARGET_DATA_CLAUSES (node
), spc
, flags
);
2441 pp_string (buffer
, "#pragma omp target");
2442 dump_omp_clauses (buffer
, OMP_TARGET_CLAUSES (node
), spc
, flags
);
2445 case OMP_TARGET_UPDATE
:
2446 pp_string (buffer
, "#pragma omp target update");
2447 dump_omp_clauses (buffer
, OMP_TARGET_UPDATE_CLAUSES (node
), spc
, flags
);
2452 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
2454 if (!(flags
& TDF_SLIM
))
2458 if (OMP_FOR_PRE_BODY (node
))
2460 newline_and_indent (buffer
, spc
+ 2);
2461 pp_left_brace (buffer
);
2463 newline_and_indent (buffer
, spc
);
2464 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
2467 if (OMP_FOR_INIT (node
))
2470 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
2473 newline_and_indent (buffer
, spc
);
2474 pp_string (buffer
, "for (");
2475 dump_generic_node (buffer
,
2476 TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
2478 pp_string (buffer
, "; ");
2479 dump_generic_node (buffer
,
2480 TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
2482 pp_string (buffer
, "; ");
2483 dump_generic_node (buffer
,
2484 TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
2486 pp_right_paren (buffer
);
2489 if (OMP_FOR_BODY (node
))
2491 newline_and_indent (buffer
, spc
+ 2);
2492 pp_left_brace (buffer
);
2493 newline_and_indent (buffer
, spc
+ 4);
2494 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
2496 newline_and_indent (buffer
, spc
+ 2);
2497 pp_right_brace (buffer
);
2499 if (OMP_FOR_INIT (node
))
2500 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
2501 if (OMP_FOR_PRE_BODY (node
))
2504 newline_and_indent (buffer
, spc
+ 2);
2505 pp_right_brace (buffer
);
2512 pp_string (buffer
, "#pragma omp sections");
2513 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2517 pp_string (buffer
, "#pragma omp section");
2521 pp_string (buffer
, "#pragma omp master");
2525 pp_string (buffer
, "#pragma omp taskgroup");
2529 pp_string (buffer
, "#pragma omp ordered");
2533 pp_string (buffer
, "#pragma omp critical");
2534 if (OMP_CRITICAL_NAME (node
))
2537 pp_left_paren (buffer
);
2538 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2540 pp_right_paren (buffer
);
2545 pp_string (buffer
, "#pragma omp atomic");
2546 if (OMP_ATOMIC_SEQ_CST (node
))
2547 pp_string (buffer
, " seq_cst");
2548 newline_and_indent (buffer
, spc
+ 2);
2549 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2553 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2556 case OMP_ATOMIC_READ
:
2557 pp_string (buffer
, "#pragma omp atomic read");
2558 if (OMP_ATOMIC_SEQ_CST (node
))
2559 pp_string (buffer
, " seq_cst");
2560 newline_and_indent (buffer
, spc
+ 2);
2561 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2565 case OMP_ATOMIC_CAPTURE_OLD
:
2566 case OMP_ATOMIC_CAPTURE_NEW
:
2567 pp_string (buffer
, "#pragma omp atomic capture");
2568 if (OMP_ATOMIC_SEQ_CST (node
))
2569 pp_string (buffer
, " seq_cst");
2570 newline_and_indent (buffer
, spc
+ 2);
2571 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2575 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2579 pp_string (buffer
, "#pragma omp single");
2580 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2584 dump_omp_clause (buffer
, node
, spc
, flags
);
2588 case TRANSACTION_EXPR
:
2589 if (TRANSACTION_EXPR_OUTER (node
))
2590 pp_string (buffer
, "__transaction_atomic [[outer]]");
2591 else if (TRANSACTION_EXPR_RELAXED (node
))
2592 pp_string (buffer
, "__transaction_relaxed");
2594 pp_string (buffer
, "__transaction_atomic");
2595 if (!(flags
& TDF_SLIM
) && TRANSACTION_EXPR_BODY (node
))
2597 newline_and_indent (buffer
, spc
);
2598 pp_left_brace (buffer
);
2599 newline_and_indent (buffer
, spc
+ 2);
2600 dump_generic_node (buffer
, TRANSACTION_EXPR_BODY (node
),
2601 spc
+ 2, flags
, false);
2602 newline_and_indent (buffer
, spc
);
2603 pp_right_brace (buffer
);
2608 case REDUC_MAX_EXPR
:
2609 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2610 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2611 pp_string (buffer
, " > ");
2614 case REDUC_MIN_EXPR
:
2615 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2616 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2617 pp_string (buffer
, " > ");
2620 case REDUC_PLUS_EXPR
:
2621 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2622 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2623 pp_string (buffer
, " > ");
2626 case VEC_WIDEN_MULT_HI_EXPR
:
2627 case VEC_WIDEN_MULT_LO_EXPR
:
2628 case VEC_WIDEN_MULT_EVEN_EXPR
:
2629 case VEC_WIDEN_MULT_ODD_EXPR
:
2630 case VEC_WIDEN_LSHIFT_HI_EXPR
:
2631 case VEC_WIDEN_LSHIFT_LO_EXPR
:
2633 for (str
= get_tree_code_name (code
); *str
; str
++)
2634 pp_character (buffer
, TOUPPER (*str
));
2635 pp_string (buffer
, " < ");
2636 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2637 pp_string (buffer
, ", ");
2638 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2639 pp_string (buffer
, " > ");
2642 case VEC_UNPACK_HI_EXPR
:
2643 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2644 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2645 pp_string (buffer
, " > ");
2648 case VEC_UNPACK_LO_EXPR
:
2649 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2650 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2651 pp_string (buffer
, " > ");
2654 case VEC_UNPACK_FLOAT_HI_EXPR
:
2655 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2656 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2657 pp_string (buffer
, " > ");
2660 case VEC_UNPACK_FLOAT_LO_EXPR
:
2661 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2662 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2663 pp_string (buffer
, " > ");
2666 case VEC_PACK_TRUNC_EXPR
:
2667 pp_string (buffer
, " VEC_PACK_TRUNC_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_SAT_EXPR
:
2675 pp_string (buffer
, " VEC_PACK_SAT_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
, " > ");
2682 case VEC_PACK_FIX_TRUNC_EXPR
:
2683 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2684 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2685 pp_string (buffer
, ", ");
2686 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2687 pp_string (buffer
, " > ");
2691 dump_block_node (buffer
, node
, spc
, flags
);
2694 case CILK_SPAWN_STMT
:
2695 pp_string (buffer
, "_Cilk_spawn ");
2696 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2699 case CILK_SYNC_STMT
:
2700 pp_string (buffer
, "_Cilk_sync");
2707 if (is_stmt
&& is_expr
)
2708 pp_semicolon (buffer
);
2713 /* Print the declaration of a variable. */
2716 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2720 if (TREE_CODE(t
) == NAMELIST_DECL
)
2722 pp_string(buffer
, "namelist ");
2723 dump_decl_name (buffer
, t
, flags
);
2724 pp_semicolon (buffer
);
2728 if (TREE_CODE (t
) == TYPE_DECL
)
2729 pp_string (buffer
, "typedef ");
2731 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2732 pp_string (buffer
, "register ");
2734 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2735 pp_string (buffer
, "extern ");
2736 else if (TREE_STATIC (t
))
2737 pp_string (buffer
, "static ");
2739 /* Print the type and name. */
2740 if (TREE_TYPE (t
) && TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2744 /* Print array's type. */
2745 tmp
= TREE_TYPE (t
);
2746 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2747 tmp
= TREE_TYPE (tmp
);
2748 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2750 /* Print variable's name. */
2752 dump_generic_node (buffer
, t
, spc
, flags
, false);
2754 /* Print the dimensions. */
2755 tmp
= TREE_TYPE (t
);
2756 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2758 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2759 tmp
= TREE_TYPE (tmp
);
2762 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2764 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2766 dump_decl_name (buffer
, t
, flags
);
2767 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2771 /* Print type declaration. */
2772 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2774 /* Print variable's name. */
2776 dump_generic_node (buffer
, t
, spc
, flags
, false);
2779 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2781 pp_string (buffer
, " __asm__ ");
2782 pp_left_paren (buffer
);
2783 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2784 pp_right_paren (buffer
);
2787 /* The initial value of a function serves to determine whether the function
2788 is declared or defined. So the following does not apply to function
2790 if (TREE_CODE (t
) != FUNCTION_DECL
)
2792 /* Print the initial value. */
2793 if (DECL_INITIAL (t
))
2798 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2802 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2804 pp_string (buffer
, " [value-expr: ");
2805 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2806 pp_right_bracket (buffer
);
2809 pp_semicolon (buffer
);
2813 /* Prints a structure: name, fields, and methods.
2814 FIXME: Still incomplete. */
2817 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2819 /* Print the name of the structure. */
2820 if (TYPE_NAME (node
))
2823 if (TREE_CODE (node
) == RECORD_TYPE
)
2824 pp_string (buffer
, "struct ");
2825 else if ((TREE_CODE (node
) == UNION_TYPE
2826 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2827 pp_string (buffer
, "union ");
2829 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2832 /* Print the contents of the structure. */
2833 pp_newline (buffer
);
2835 pp_left_brace (buffer
);
2836 pp_newline (buffer
);
2838 /* Print the fields of the structure. */
2841 tmp
= TYPE_FIELDS (node
);
2844 /* Avoid to print recursively the structure. */
2845 /* FIXME : Not implemented correctly...,
2846 what about the case when we have a cycle in the contain graph? ...
2847 Maybe this could be solved by looking at the scope in which the
2848 structure was declared. */
2849 if (TREE_TYPE (tmp
) != node
2850 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2851 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2853 print_declaration (buffer
, tmp
, spc
+2, flags
);
2854 pp_newline (buffer
);
2856 tmp
= DECL_CHAIN (tmp
);
2860 pp_right_brace (buffer
);
2863 /* Return the priority of the operator CODE.
2865 From lowest to highest precedence with either left-to-right (L-R)
2866 or right-to-left (R-L) associativity]:
2869 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2881 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2882 15 [L-R] fn() [] -> .
2884 unary +, - and * have higher precedence than the corresponding binary
2888 op_code_prio (enum tree_code code
)
2905 case TRUTH_ORIF_EXPR
:
2908 case TRUTH_AND_EXPR
:
2909 case TRUTH_ANDIF_EXPR
:
2916 case TRUTH_XOR_EXPR
:
2933 case UNORDERED_EXPR
:
2944 case VEC_WIDEN_LSHIFT_HI_EXPR
:
2945 case VEC_WIDEN_LSHIFT_LO_EXPR
:
2946 case WIDEN_LSHIFT_EXPR
:
2949 case WIDEN_SUM_EXPR
:
2951 case POINTER_PLUS_EXPR
:
2955 case VEC_WIDEN_MULT_HI_EXPR
:
2956 case VEC_WIDEN_MULT_LO_EXPR
:
2957 case WIDEN_MULT_EXPR
:
2959 case WIDEN_MULT_PLUS_EXPR
:
2960 case WIDEN_MULT_MINUS_EXPR
:
2962 case MULT_HIGHPART_EXPR
:
2963 case TRUNC_DIV_EXPR
:
2965 case FLOOR_DIV_EXPR
:
2966 case ROUND_DIV_EXPR
:
2968 case EXACT_DIV_EXPR
:
2969 case TRUNC_MOD_EXPR
:
2971 case FLOOR_MOD_EXPR
:
2972 case ROUND_MOD_EXPR
:
2976 case TRUTH_NOT_EXPR
:
2978 case POSTINCREMENT_EXPR
:
2979 case POSTDECREMENT_EXPR
:
2980 case PREINCREMENT_EXPR
:
2981 case PREDECREMENT_EXPR
:
2987 case FIX_TRUNC_EXPR
:
2993 case ARRAY_RANGE_REF
:
2997 /* Special expressions. */
3003 case REDUC_MAX_EXPR
:
3004 case REDUC_MIN_EXPR
:
3005 case REDUC_PLUS_EXPR
:
3006 case VEC_LSHIFT_EXPR
:
3007 case VEC_RSHIFT_EXPR
:
3008 case VEC_UNPACK_HI_EXPR
:
3009 case VEC_UNPACK_LO_EXPR
:
3010 case VEC_UNPACK_FLOAT_HI_EXPR
:
3011 case VEC_UNPACK_FLOAT_LO_EXPR
:
3012 case VEC_PACK_TRUNC_EXPR
:
3013 case VEC_PACK_SAT_EXPR
:
3017 /* Return an arbitrarily high precedence to avoid surrounding single
3018 VAR_DECLs in ()s. */
3023 /* Return the priority of the operator OP. */
3026 op_prio (const_tree op
)
3028 enum tree_code code
;
3033 code
= TREE_CODE (op
);
3034 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
3035 return op_prio (TREE_OPERAND (op
, 0));
3037 return op_code_prio (code
);
3040 /* Return the symbol associated with operator CODE. */
3043 op_symbol_code (enum tree_code code
)
3051 case TRUTH_ORIF_EXPR
:
3054 case TRUTH_AND_EXPR
:
3055 case TRUTH_ANDIF_EXPR
:
3061 case TRUTH_XOR_EXPR
:
3071 case UNORDERED_EXPR
:
3117 case VEC_LSHIFT_EXPR
:
3120 case VEC_RSHIFT_EXPR
:
3123 case WIDEN_LSHIFT_EXPR
:
3126 case POINTER_PLUS_EXPR
:
3132 case REDUC_PLUS_EXPR
:
3135 case WIDEN_SUM_EXPR
:
3138 case WIDEN_MULT_EXPR
:
3141 case MULT_HIGHPART_EXPR
:
3151 case TRUTH_NOT_EXPR
:
3158 case TRUNC_DIV_EXPR
:
3165 case FLOOR_DIV_EXPR
:
3168 case ROUND_DIV_EXPR
:
3171 case EXACT_DIV_EXPR
:
3174 case TRUNC_MOD_EXPR
:
3180 case FLOOR_MOD_EXPR
:
3183 case ROUND_MOD_EXPR
:
3186 case PREDECREMENT_EXPR
:
3189 case PREINCREMENT_EXPR
:
3192 case POSTDECREMENT_EXPR
:
3195 case POSTINCREMENT_EXPR
:
3205 return "<<< ??? >>>";
3209 /* Return the symbol associated with operator OP. */
3212 op_symbol (const_tree op
)
3214 return op_symbol_code (TREE_CODE (op
));
3217 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3218 the gimple_call_fn of a GIMPLE_CALL. */
3221 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
3225 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
3226 op0
= TREE_OPERAND (op0
, 0);
3229 switch (TREE_CODE (op0
))
3234 dump_function_name (buffer
, op0
, flags
);
3240 op0
= TREE_OPERAND (op0
, 0);
3244 pp_left_paren (buffer
);
3245 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
3246 pp_string (buffer
, ") ? ");
3247 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
3248 pp_string (buffer
, " : ");
3249 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
3253 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
3254 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
3256 dump_generic_node (buffer
, op0
, 0, flags
, false);
3260 if (integer_zerop (TREE_OPERAND (op0
, 1)))
3262 op0
= TREE_OPERAND (op0
, 0);
3269 dump_generic_node (buffer
, op0
, 0, flags
, false);
3277 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3280 pretty_print_string (pretty_printer
*buffer
, const char *str
)
3290 pp_string (buffer
, "\\b");
3294 pp_string (buffer
, "\\f");
3298 pp_string (buffer
, "\\n");
3302 pp_string (buffer
, "\\r");
3306 pp_string (buffer
, "\\t");
3310 pp_string (buffer
, "\\v");
3314 pp_string (buffer
, "\\\\");
3318 pp_string (buffer
, "\\\"");
3322 pp_string (buffer
, "\\'");
3325 /* No need to handle \0; the loop terminates on \0. */
3328 pp_string (buffer
, "\\1");
3332 pp_string (buffer
, "\\2");
3336 pp_string (buffer
, "\\3");
3340 pp_string (buffer
, "\\4");
3344 pp_string (buffer
, "\\5");
3348 pp_string (buffer
, "\\6");
3352 pp_string (buffer
, "\\7");
3356 pp_character (buffer
, str
[0]);
3364 maybe_init_pretty_print (FILE *file
)
3368 new (&buffer
) pretty_printer ();
3369 pp_needs_newline (&buffer
) = true;
3370 pp_translate_identifiers (&buffer
) = false;
3374 buffer
.buffer
->stream
= file
;
3378 newline_and_indent (pretty_printer
*buffer
, int spc
)
3380 pp_newline (buffer
);
3384 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3385 it can also be used in front ends.
3386 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3390 percent_K_format (text_info
*text
)
3392 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
3393 gcc_assert (text
->locus
!= NULL
);
3394 *text
->locus
= EXPR_LOCATION (t
);
3395 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
3396 block
= TREE_BLOCK (t
);
3397 *pp_ti_abstract_origin (text
) = NULL
;
3401 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3402 representing the outermost block of an inlined function.
3403 So walk the BLOCK tree until we hit such a scope. */
3405 && TREE_CODE (block
) == BLOCK
)
3407 if (inlined_function_outer_scope_p (block
))
3409 *pp_ti_abstract_origin (text
) = block
;
3412 block
= BLOCK_SUPERCONTEXT (block
);
3418 && TREE_CODE (block
) == BLOCK
3419 && BLOCK_ABSTRACT_ORIGIN (block
))
3421 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
3423 while (TREE_CODE (ao
) == BLOCK
3424 && BLOCK_ABSTRACT_ORIGIN (ao
)
3425 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
3426 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
3428 if (TREE_CODE (ao
) == FUNCTION_DECL
)
3430 *pp_ti_abstract_origin (text
) = block
;
3433 block
= BLOCK_SUPERCONTEXT (block
);
3437 /* Print the identifier ID to PRETTY-PRINTER. */
3440 pp_tree_identifier (pretty_printer
*pp
, tree id
)
3442 if (pp_translate_identifiers (pp
))
3444 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
3445 pp_append_text (pp
, text
, text
+ strlen (text
));
3448 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
3449 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));
3452 /* A helper function that is used to dump function information before the
3456 dump_function_header (FILE *dump_file
, tree fdecl
, int flags
)
3458 const char *dname
, *aname
;
3459 struct cgraph_node
*node
= cgraph_node::get (fdecl
);
3460 struct function
*fun
= DECL_STRUCT_FUNCTION (fdecl
);
3462 dname
= lang_hooks
.decl_printable_name (fdecl
, 2);
3464 if (DECL_ASSEMBLER_NAME_SET_P (fdecl
))
3465 aname
= (IDENTIFIER_POINTER
3466 (DECL_ASSEMBLER_NAME (fdecl
)));
3468 aname
= "<unset-asm-name>";
3470 fprintf (dump_file
, "\n;; Function %s (%s, funcdef_no=%d",
3471 dname
, aname
, fun
->funcdef_no
);
3472 if (!(flags
& TDF_NOUID
))
3473 fprintf (dump_file
, ", decl_uid=%d", DECL_UID (fdecl
));
3476 fprintf (dump_file
, ", cgraph_uid=%d", node
->uid
);
3477 fprintf (dump_file
, ", symbol_order=%d)%s\n\n", node
->order
,
3478 node
->frequency
== NODE_FREQUENCY_HOT
3480 : node
->frequency
== NODE_FREQUENCY_UNLIKELY_EXECUTED
3481 ? " (unlikely executed)"
3482 : node
->frequency
== NODE_FREQUENCY_EXECUTED_ONCE
3483 ? " (executed once)"
3487 fprintf (dump_file
, ")\n\n");
3490 /* Dump double_int D to pretty_printer PP. UNS is true
3491 if D is unsigned and false otherwise. */
3493 pp_double_int (pretty_printer
*pp
, double_int d
, bool uns
)
3496 pp_wide_integer (pp
, d
.low
);
3497 else if (d
.fits_uhwi ())
3498 pp_unsigned_wide_integer (pp
, d
.low
);
3501 unsigned HOST_WIDE_INT low
= d
.low
;
3502 HOST_WIDE_INT high
= d
.high
;
3503 if (!uns
&& d
.is_negative ())
3506 high
= ~high
+ !low
;
3509 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3511 sprintf (pp_buffer (pp
)->digit_buffer
,
3512 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
3513 (unsigned HOST_WIDE_INT
) high
, low
);
3514 pp_string (pp
, pp_buffer (pp
)->digit_buffer
);