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"
31 #include "gimple-expr.h"
35 #include "plugin-api.h"
38 #include "hard-reg-set.h"
43 #include "langhooks.h"
44 #include "tree-iterator.h"
45 #include "tree-chrec.h"
47 #include "value-prof.h"
48 #include "wide-int-print.h"
49 #include "internal-fn.h"
51 #include <new> // For placement-new.
53 /* Local functions, macros and variables. */
54 static const char *op_symbol (const_tree
);
55 static void pretty_print_string (pretty_printer
*, const char*);
56 static void newline_and_indent (pretty_printer
*, int);
57 static void maybe_init_pretty_print (FILE *);
58 static void print_struct_decl (pretty_printer
*, const_tree
, int, int);
59 static void do_niy (pretty_printer
*, const_tree
);
61 #define INDENT(SPACE) do { \
62 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
64 #define NIY do_niy (buffer, node)
66 static pretty_printer buffer
;
67 static int initialized
= 0;
69 /* Try to print something for an unknown tree code. */
72 do_niy (pretty_printer
*buffer
, const_tree node
)
76 pp_string (buffer
, "<<< Unknown tree: ");
77 pp_string (buffer
, get_tree_code_name (TREE_CODE (node
)));
81 len
= TREE_OPERAND_LENGTH (node
);
82 for (i
= 0; i
< len
; ++i
)
84 newline_and_indent (buffer
, 2);
85 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0, false);
89 pp_string (buffer
, " >>>");
92 /* Debugging function to print out a generic expression. */
95 debug_generic_expr (tree t
)
97 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
98 fprintf (stderr
, "\n");
101 /* Debugging function to print out a generic statement. */
104 debug_generic_stmt (tree t
)
106 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
107 fprintf (stderr
, "\n");
110 /* Debugging function to print out a chain of trees . */
113 debug_tree_chain (tree t
)
119 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
120 fprintf (stderr
, " ");
124 fprintf (stderr
, "... [cycled back to ");
125 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
126 fprintf (stderr
, "]");
130 fprintf (stderr
, "\n");
133 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
135 print_generic_decl (FILE *file
, tree decl
, int flags
)
137 maybe_init_pretty_print (file
);
138 print_declaration (&buffer
, decl
, 2, flags
);
139 pp_write_text_to_stream (&buffer
);
142 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
143 to show in the dump. See TDF_* in dumpfile.h. */
146 print_generic_stmt (FILE *file
, tree t
, int flags
)
148 maybe_init_pretty_print (file
);
149 dump_generic_node (&buffer
, t
, 0, flags
, true);
150 pp_newline_and_flush (&buffer
);
153 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
154 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
158 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
162 maybe_init_pretty_print (file
);
164 for (i
= 0; i
< indent
; i
++)
166 dump_generic_node (&buffer
, t
, indent
, flags
, true);
167 pp_newline_and_flush (&buffer
);
170 /* Print a single expression T on file FILE. FLAGS specifies details to show
171 in the dump. See TDF_* in dumpfile.h. */
174 print_generic_expr (FILE *file
, tree t
, int flags
)
176 maybe_init_pretty_print (file
);
177 dump_generic_node (&buffer
, t
, 0, flags
, false);
181 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
185 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
187 if (DECL_NAME (node
))
189 if ((flags
& TDF_ASMNAME
) && DECL_ASSEMBLER_NAME_SET_P (node
))
190 pp_tree_identifier (buffer
, DECL_ASSEMBLER_NAME (node
));
192 pp_tree_identifier (buffer
, DECL_NAME (node
));
194 if ((flags
& TDF_UID
) || DECL_NAME (node
) == NULL_TREE
)
196 if (TREE_CODE (node
) == LABEL_DECL
&& LABEL_DECL_UID (node
) != -1)
197 pp_printf (buffer
, "L.%d", (int) LABEL_DECL_UID (node
));
198 else if (TREE_CODE (node
) == DEBUG_EXPR_DECL
)
200 if (flags
& TDF_NOUID
)
201 pp_string (buffer
, "D#xxxx");
203 pp_printf (buffer
, "D#%i", DEBUG_TEMP_UID (node
));
207 char c
= TREE_CODE (node
) == CONST_DECL
? 'C' : 'D';
208 if (flags
& TDF_NOUID
)
209 pp_printf (buffer
, "%c.xxxx", c
);
211 pp_printf (buffer
, "%c.%u", c
, DECL_UID (node
));
214 if ((flags
& TDF_ALIAS
) && DECL_PT_UID (node
) != DECL_UID (node
))
216 if (flags
& TDF_NOUID
)
217 pp_printf (buffer
, "ptD.xxxx");
219 pp_printf (buffer
, "ptD.%u", DECL_PT_UID (node
));
223 /* Like the above, but used for pretty printing function calls. */
226 dump_function_name (pretty_printer
*buffer
, tree node
, int flags
)
228 if (CONVERT_EXPR_P (node
))
229 node
= TREE_OPERAND (node
, 0);
230 if (DECL_NAME (node
) && (flags
& TDF_ASMNAME
) == 0)
231 pp_string (buffer
, lang_hooks
.decl_printable_name (node
, 1));
233 dump_decl_name (buffer
, node
, flags
);
236 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
237 FLAGS are as in dump_generic_node. */
240 dump_function_declaration (pretty_printer
*buffer
, tree node
,
243 bool wrote_arg
= false;
247 pp_left_paren (buffer
);
249 /* Print the argument types. */
250 arg
= TYPE_ARG_TYPES (node
);
251 while (arg
&& arg
!= void_list_node
&& arg
!= error_mark_node
)
259 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
260 arg
= TREE_CHAIN (arg
);
263 /* Drop the trailing void_type_node if we had any previous argument. */
264 if (arg
== void_list_node
&& !wrote_arg
)
265 pp_string (buffer
, "void");
266 /* Properly dump vararg function types. */
267 else if (!arg
&& wrote_arg
)
268 pp_string (buffer
, ", ...");
269 /* Avoid printing any arg for unprototyped functions. */
271 pp_right_paren (buffer
);
274 /* Dump the domain associated with an array. */
277 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
279 pp_left_bracket (buffer
);
282 tree min
= TYPE_MIN_VALUE (domain
);
283 tree max
= TYPE_MAX_VALUE (domain
);
286 && integer_zerop (min
)
287 && tree_fits_shwi_p (max
))
288 pp_wide_integer (buffer
, tree_to_shwi (max
) + 1);
292 dump_generic_node (buffer
, min
, spc
, flags
, false);
295 dump_generic_node (buffer
, max
, spc
, flags
, false);
299 pp_string (buffer
, "<unknown>");
300 pp_right_bracket (buffer
);
304 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
305 dump_generic_node. */
308 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
312 switch (OMP_CLAUSE_CODE (clause
))
314 case OMP_CLAUSE_PRIVATE
:
317 case OMP_CLAUSE_SHARED
:
320 case OMP_CLAUSE_FIRSTPRIVATE
:
321 name
= "firstprivate";
323 case OMP_CLAUSE_LASTPRIVATE
:
324 name
= "lastprivate";
326 case OMP_CLAUSE_COPYIN
:
329 case OMP_CLAUSE_COPYPRIVATE
:
330 name
= "copyprivate";
332 case OMP_CLAUSE_UNIFORM
:
335 case OMP_CLAUSE__LOOPTEMP_
:
339 pp_string (buffer
, name
);
340 pp_left_paren (buffer
);
341 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
343 pp_right_paren (buffer
);
346 case OMP_CLAUSE_REDUCTION
:
347 pp_string (buffer
, "reduction(");
348 if (OMP_CLAUSE_REDUCTION_CODE (clause
) != ERROR_MARK
)
351 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
354 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
356 pp_right_paren (buffer
);
360 pp_string (buffer
, "if(");
361 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
363 pp_right_paren (buffer
);
366 case OMP_CLAUSE_NUM_THREADS
:
367 pp_string (buffer
, "num_threads(");
368 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
370 pp_right_paren (buffer
);
373 case OMP_CLAUSE__CILK_FOR_COUNT_
:
374 pp_string (buffer
, "_Cilk_for_count_(");
375 dump_generic_node (buffer
, OMP_CLAUSE_OPERAND (clause
, 0),
377 pp_right_paren (buffer
);
380 case OMP_CLAUSE_NOWAIT
:
381 pp_string (buffer
, "nowait");
383 case OMP_CLAUSE_ORDERED
:
384 pp_string (buffer
, "ordered");
387 case OMP_CLAUSE_DEFAULT
:
388 pp_string (buffer
, "default(");
389 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
391 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
393 case OMP_CLAUSE_DEFAULT_SHARED
:
394 pp_string (buffer
, "shared");
396 case OMP_CLAUSE_DEFAULT_NONE
:
397 pp_string (buffer
, "none");
399 case OMP_CLAUSE_DEFAULT_PRIVATE
:
400 pp_string (buffer
, "private");
402 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE
:
403 pp_string (buffer
, "firstprivate");
408 pp_right_paren (buffer
);
411 case OMP_CLAUSE_SCHEDULE
:
412 pp_string (buffer
, "schedule(");
413 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
415 case OMP_CLAUSE_SCHEDULE_STATIC
:
416 pp_string (buffer
, "static");
418 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
419 pp_string (buffer
, "dynamic");
421 case OMP_CLAUSE_SCHEDULE_GUIDED
:
422 pp_string (buffer
, "guided");
424 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
425 pp_string (buffer
, "runtime");
427 case OMP_CLAUSE_SCHEDULE_AUTO
:
428 pp_string (buffer
, "auto");
430 case OMP_CLAUSE_SCHEDULE_CILKFOR
:
431 pp_string (buffer
, "cilk-for grain");
436 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
439 dump_generic_node (buffer
, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
442 pp_right_paren (buffer
);
445 case OMP_CLAUSE_UNTIED
:
446 pp_string (buffer
, "untied");
449 case OMP_CLAUSE_COLLAPSE
:
450 pp_string (buffer
, "collapse(");
451 dump_generic_node (buffer
, OMP_CLAUSE_COLLAPSE_EXPR (clause
),
453 pp_right_paren (buffer
);
456 case OMP_CLAUSE_FINAL
:
457 pp_string (buffer
, "final(");
458 dump_generic_node (buffer
, OMP_CLAUSE_FINAL_EXPR (clause
),
460 pp_right_paren (buffer
);
463 case OMP_CLAUSE_MERGEABLE
:
464 pp_string (buffer
, "mergeable");
467 case OMP_CLAUSE_LINEAR
:
468 pp_string (buffer
, "linear(");
469 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
472 dump_generic_node (buffer
, OMP_CLAUSE_LINEAR_STEP (clause
),
474 pp_right_paren (buffer
);
477 case OMP_CLAUSE_ALIGNED
:
478 pp_string (buffer
, "aligned(");
479 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
481 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause
))
484 dump_generic_node (buffer
, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause
),
487 pp_right_paren (buffer
);
490 case OMP_CLAUSE_DEPEND
:
491 pp_string (buffer
, "depend(");
492 switch (OMP_CLAUSE_DEPEND_KIND (clause
))
494 case OMP_CLAUSE_DEPEND_IN
:
495 pp_string (buffer
, "in");
497 case OMP_CLAUSE_DEPEND_OUT
:
498 pp_string (buffer
, "out");
500 case OMP_CLAUSE_DEPEND_INOUT
:
501 pp_string (buffer
, "inout");
507 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
509 pp_right_paren (buffer
);
513 pp_string (buffer
, "map(");
514 switch (OMP_CLAUSE_MAP_KIND (clause
))
516 case OMP_CLAUSE_MAP_ALLOC
:
517 case OMP_CLAUSE_MAP_POINTER
:
518 pp_string (buffer
, "alloc");
520 case OMP_CLAUSE_MAP_TO
:
521 case OMP_CLAUSE_MAP_TO_PSET
:
522 pp_string (buffer
, "to");
524 case OMP_CLAUSE_MAP_FROM
:
525 pp_string (buffer
, "from");
527 case OMP_CLAUSE_MAP_TOFROM
:
528 pp_string (buffer
, "tofrom");
534 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
537 if (OMP_CLAUSE_SIZE (clause
))
539 if (OMP_CLAUSE_CODE (clause
) == OMP_CLAUSE_MAP
540 && OMP_CLAUSE_MAP_KIND (clause
) == OMP_CLAUSE_MAP_POINTER
)
541 pp_string (buffer
, " [pointer assign, bias: ");
542 else if (OMP_CLAUSE_CODE (clause
) == OMP_CLAUSE_MAP
543 && OMP_CLAUSE_MAP_KIND (clause
) == OMP_CLAUSE_MAP_TO_PSET
)
544 pp_string (buffer
, " [pointer set, len: ");
546 pp_string (buffer
, " [len: ");
547 dump_generic_node (buffer
, OMP_CLAUSE_SIZE (clause
),
549 pp_right_bracket (buffer
);
551 pp_right_paren (buffer
);
554 case OMP_CLAUSE_FROM
:
555 pp_string (buffer
, "from(");
556 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
558 goto print_clause_size
;
561 pp_string (buffer
, "to(");
562 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
564 goto print_clause_size
;
566 case OMP_CLAUSE_NUM_TEAMS
:
567 pp_string (buffer
, "num_teams(");
568 dump_generic_node (buffer
, OMP_CLAUSE_NUM_TEAMS_EXPR (clause
),
570 pp_right_paren (buffer
);
573 case OMP_CLAUSE_THREAD_LIMIT
:
574 pp_string (buffer
, "thread_limit(");
575 dump_generic_node (buffer
, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause
),
577 pp_right_paren (buffer
);
580 case OMP_CLAUSE_DEVICE
:
581 pp_string (buffer
, "device(");
582 dump_generic_node (buffer
, OMP_CLAUSE_DEVICE_ID (clause
),
584 pp_right_paren (buffer
);
587 case OMP_CLAUSE_DIST_SCHEDULE
:
588 pp_string (buffer
, "dist_schedule(static");
589 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause
))
592 dump_generic_node (buffer
,
593 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause
),
596 pp_right_paren (buffer
);
599 case OMP_CLAUSE_PROC_BIND
:
600 pp_string (buffer
, "proc_bind(");
601 switch (OMP_CLAUSE_PROC_BIND_KIND (clause
))
603 case OMP_CLAUSE_PROC_BIND_MASTER
:
604 pp_string (buffer
, "master");
606 case OMP_CLAUSE_PROC_BIND_CLOSE
:
607 pp_string (buffer
, "close");
609 case OMP_CLAUSE_PROC_BIND_SPREAD
:
610 pp_string (buffer
, "spread");
615 pp_right_paren (buffer
);
618 case OMP_CLAUSE_SAFELEN
:
619 pp_string (buffer
, "safelen(");
620 dump_generic_node (buffer
, OMP_CLAUSE_SAFELEN_EXPR (clause
),
622 pp_right_paren (buffer
);
625 case OMP_CLAUSE_SIMDLEN
:
626 pp_string (buffer
, "simdlen(");
627 dump_generic_node (buffer
, OMP_CLAUSE_SIMDLEN_EXPR (clause
),
629 pp_right_paren (buffer
);
632 case OMP_CLAUSE__SIMDUID_
:
633 pp_string (buffer
, "_simduid_(");
634 dump_generic_node (buffer
, OMP_CLAUSE__SIMDUID__DECL (clause
),
636 pp_right_paren (buffer
);
639 case OMP_CLAUSE_INBRANCH
:
640 pp_string (buffer
, "inbranch");
642 case OMP_CLAUSE_NOTINBRANCH
:
643 pp_string (buffer
, "notinbranch");
646 pp_string (buffer
, "for");
648 case OMP_CLAUSE_PARALLEL
:
649 pp_string (buffer
, "parallel");
651 case OMP_CLAUSE_SECTIONS
:
652 pp_string (buffer
, "sections");
654 case OMP_CLAUSE_TASKGROUP
:
655 pp_string (buffer
, "taskgroup");
659 /* Should never happen. */
660 dump_generic_node (buffer
, clause
, spc
, flags
, false);
666 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
667 dump_generic_node. */
670 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
678 dump_omp_clause (buffer
, clause
, spc
, flags
);
679 clause
= OMP_CLAUSE_CHAIN (clause
);
687 /* Dump location LOC to BUFFER. */
690 dump_location (pretty_printer
*buffer
, location_t loc
)
692 expanded_location xloc
= expand_location (loc
);
694 pp_left_bracket (buffer
);
697 pp_string (buffer
, xloc
.file
);
698 pp_string (buffer
, ":");
700 pp_decimal_int (buffer
, xloc
.line
);
702 pp_decimal_int (buffer
, xloc
.column
);
703 pp_string (buffer
, "] ");
707 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
708 dump_generic_node. */
711 dump_block_node (pretty_printer
*buffer
, tree block
, int spc
, int flags
)
715 pp_printf (buffer
, "BLOCK #%d ", BLOCK_NUMBER (block
));
717 if (flags
& TDF_ADDRESS
)
718 pp_printf (buffer
, "[%p] ", (void *) block
);
720 if (BLOCK_ABSTRACT (block
))
721 pp_string (buffer
, "[abstract] ");
723 if (TREE_ASM_WRITTEN (block
))
724 pp_string (buffer
, "[written] ");
726 if (flags
& TDF_SLIM
)
729 if (BLOCK_SOURCE_LOCATION (block
))
730 dump_location (buffer
, BLOCK_SOURCE_LOCATION (block
));
732 newline_and_indent (buffer
, spc
+ 2);
734 if (BLOCK_SUPERCONTEXT (block
))
736 pp_string (buffer
, "SUPERCONTEXT: ");
737 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (block
), 0,
738 flags
| TDF_SLIM
, false);
739 newline_and_indent (buffer
, spc
+ 2);
742 if (BLOCK_SUBBLOCKS (block
))
744 pp_string (buffer
, "SUBBLOCKS: ");
745 for (t
= BLOCK_SUBBLOCKS (block
); t
; t
= BLOCK_CHAIN (t
))
747 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
750 newline_and_indent (buffer
, spc
+ 2);
753 if (BLOCK_CHAIN (block
))
755 pp_string (buffer
, "SIBLINGS: ");
756 for (t
= BLOCK_CHAIN (block
); t
; t
= BLOCK_CHAIN (t
))
758 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
761 newline_and_indent (buffer
, spc
+ 2);
764 if (BLOCK_VARS (block
))
766 pp_string (buffer
, "VARS: ");
767 for (t
= BLOCK_VARS (block
); t
; t
= TREE_CHAIN (t
))
769 dump_generic_node (buffer
, t
, 0, flags
, false);
772 newline_and_indent (buffer
, spc
+ 2);
775 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block
)) > 0)
778 vec
<tree
, va_gc
> *nlv
= BLOCK_NONLOCALIZED_VARS (block
);
780 pp_string (buffer
, "NONLOCALIZED_VARS: ");
781 FOR_EACH_VEC_ELT (*nlv
, i
, t
)
783 dump_generic_node (buffer
, t
, 0, flags
, false);
786 newline_and_indent (buffer
, spc
+ 2);
789 if (BLOCK_ABSTRACT_ORIGIN (block
))
791 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
792 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (block
), 0,
793 flags
| TDF_SLIM
, false);
794 newline_and_indent (buffer
, spc
+ 2);
797 if (BLOCK_FRAGMENT_ORIGIN (block
))
799 pp_string (buffer
, "FRAGMENT_ORIGIN: ");
800 dump_generic_node (buffer
, BLOCK_FRAGMENT_ORIGIN (block
), 0,
801 flags
| TDF_SLIM
, false);
802 newline_and_indent (buffer
, spc
+ 2);
805 if (BLOCK_FRAGMENT_CHAIN (block
))
807 pp_string (buffer
, "FRAGMENT_CHAIN: ");
808 for (t
= BLOCK_FRAGMENT_CHAIN (block
); t
; t
= BLOCK_FRAGMENT_CHAIN (t
))
810 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
813 newline_and_indent (buffer
, spc
+ 2);
818 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
819 indent. FLAGS specifies details to show in the dump (see TDF_* in
820 dumpfile.h). If IS_STMT is true, the object printed is considered
821 to be a statement and it is terminated by ';' if appropriate. */
824 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
833 if (node
== NULL_TREE
)
836 is_expr
= EXPR_P (node
);
838 if (is_stmt
&& (flags
& TDF_STMTADDR
))
839 pp_printf (buffer
, "<&%p> ", (void *)node
);
841 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
842 dump_location (buffer
, EXPR_LOCATION (node
));
844 code
= TREE_CODE (node
);
848 pp_string (buffer
, "<<< error >>>");
851 case IDENTIFIER_NODE
:
852 pp_tree_identifier (buffer
, node
);
856 while (node
&& node
!= error_mark_node
)
858 if (TREE_PURPOSE (node
))
860 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
863 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
864 node
= TREE_CHAIN (node
);
865 if (node
&& TREE_CODE (node
) == TREE_LIST
)
874 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
880 if (TREE_VEC_LENGTH (node
) > 0)
882 size_t len
= TREE_VEC_LENGTH (node
);
883 for (i
= 0; i
< len
- 1; i
++)
885 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
890 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
897 case POINTER_BOUNDS_TYPE
:
900 case FIXED_POINT_TYPE
:
906 unsigned int quals
= TYPE_QUALS (node
);
907 enum tree_code_class tclass
;
909 if (quals
& TYPE_QUAL_ATOMIC
)
910 pp_string (buffer
, "atomic ");
911 if (quals
& TYPE_QUAL_CONST
)
912 pp_string (buffer
, "const ");
913 else if (quals
& TYPE_QUAL_VOLATILE
)
914 pp_string (buffer
, "volatile ");
915 else if (quals
& TYPE_QUAL_RESTRICT
)
916 pp_string (buffer
, "restrict ");
918 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
920 pp_string (buffer
, "<address-space-");
921 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
922 pp_string (buffer
, "> ");
925 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
927 if (tclass
== tcc_declaration
)
929 if (DECL_NAME (node
))
930 dump_decl_name (buffer
, node
, flags
);
932 pp_string (buffer
, "<unnamed type decl>");
934 else if (tclass
== tcc_type
)
936 if (TYPE_NAME (node
))
938 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
939 pp_tree_identifier (buffer
, TYPE_NAME (node
));
940 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
941 && DECL_NAME (TYPE_NAME (node
)))
942 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
944 pp_string (buffer
, "<unnamed type>");
946 else if (TREE_CODE (node
) == VECTOR_TYPE
)
948 pp_string (buffer
, "vector");
949 pp_left_paren (buffer
);
950 pp_wide_integer (buffer
, TYPE_VECTOR_SUBPARTS (node
));
951 pp_string (buffer
, ") ");
952 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
954 else if (TREE_CODE (node
) == INTEGER_TYPE
)
956 if (TYPE_PRECISION (node
) == CHAR_TYPE_SIZE
)
957 pp_string (buffer
, (TYPE_UNSIGNED (node
)
960 else if (TYPE_PRECISION (node
) == SHORT_TYPE_SIZE
)
961 pp_string (buffer
, (TYPE_UNSIGNED (node
)
964 else if (TYPE_PRECISION (node
) == INT_TYPE_SIZE
)
965 pp_string (buffer
, (TYPE_UNSIGNED (node
)
968 else if (TYPE_PRECISION (node
) == LONG_TYPE_SIZE
)
969 pp_string (buffer
, (TYPE_UNSIGNED (node
)
972 else if (TYPE_PRECISION (node
) == LONG_LONG_TYPE_SIZE
)
973 pp_string (buffer
, (TYPE_UNSIGNED (node
)
974 ? "unsigned long long"
975 : "signed long long"));
976 else if (TYPE_PRECISION (node
) >= CHAR_TYPE_SIZE
977 && exact_log2 (TYPE_PRECISION (node
)) != -1)
979 pp_string (buffer
, (TYPE_UNSIGNED (node
) ? "uint" : "int"));
980 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
981 pp_string (buffer
, "_t");
985 pp_string (buffer
, (TYPE_UNSIGNED (node
)
986 ? "<unnamed-unsigned:"
987 : "<unnamed-signed:"));
988 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
992 else if (TREE_CODE (node
) == COMPLEX_TYPE
)
994 pp_string (buffer
, "__complex__ ");
995 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
997 else if (TREE_CODE (node
) == REAL_TYPE
)
999 pp_string (buffer
, "<float:");
1000 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
1001 pp_greater (buffer
);
1003 else if (TREE_CODE (node
) == FIXED_POINT_TYPE
)
1005 pp_string (buffer
, "<fixed-point-");
1006 pp_string (buffer
, TYPE_SATURATING (node
) ? "sat:" : "nonsat:");
1007 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
1008 pp_greater (buffer
);
1010 else if (TREE_CODE (node
) == VOID_TYPE
)
1011 pp_string (buffer
, "void");
1013 pp_string (buffer
, "<unnamed type>");
1019 case REFERENCE_TYPE
:
1020 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
1022 if (TREE_TYPE (node
) == NULL
)
1024 pp_string (buffer
, str
);
1025 pp_string (buffer
, "<null type>");
1027 else if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
1029 tree fnode
= TREE_TYPE (node
);
1031 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
1033 pp_left_paren (buffer
);
1034 pp_string (buffer
, str
);
1035 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1036 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1037 else if (flags
& TDF_NOUID
)
1038 pp_printf (buffer
, "<Txxxx>");
1040 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1042 pp_right_paren (buffer
);
1043 dump_function_declaration (buffer
, fnode
, spc
, flags
);
1047 unsigned int quals
= TYPE_QUALS (node
);
1049 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1051 pp_string (buffer
, str
);
1053 if (quals
& TYPE_QUAL_CONST
)
1054 pp_string (buffer
, " const");
1055 if (quals
& TYPE_QUAL_VOLATILE
)
1056 pp_string (buffer
, " volatile");
1057 if (quals
& TYPE_QUAL_RESTRICT
)
1058 pp_string (buffer
, " restrict");
1060 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
1062 pp_string (buffer
, " <address-space-");
1063 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
1064 pp_greater (buffer
);
1067 if (TYPE_REF_CAN_ALIAS_ALL (node
))
1068 pp_string (buffer
, " {ref-all}");
1078 if (integer_zerop (TREE_OPERAND (node
, 1))
1079 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1080 infer them and MEM_ATTR caching will share MEM_REFs
1081 with differently-typed op0s. */
1082 && TREE_CODE (TREE_OPERAND (node
, 0)) != INTEGER_CST
1083 /* Released SSA_NAMES have no TREE_TYPE. */
1084 && TREE_TYPE (TREE_OPERAND (node
, 0)) != NULL_TREE
1085 /* Same pointer types, but ignoring POINTER_TYPE vs.
1087 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 0)))
1088 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))
1089 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 0)))
1090 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 1))))
1091 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 0)))
1092 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 1))))
1093 /* Same value types ignoring qualifiers. */
1094 && (TYPE_MAIN_VARIANT (TREE_TYPE (node
))
1095 == TYPE_MAIN_VARIANT
1096 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))))
1098 if (TREE_CODE (TREE_OPERAND (node
, 0)) != ADDR_EXPR
)
1101 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1105 dump_generic_node (buffer
,
1106 TREE_OPERAND (TREE_OPERAND (node
, 0), 0),
1113 pp_string (buffer
, "MEM[");
1114 pp_left_paren (buffer
);
1115 ptype
= TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node
, 1)));
1116 dump_generic_node (buffer
, ptype
,
1117 spc
, flags
| TDF_SLIM
, false);
1118 pp_right_paren (buffer
);
1119 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1121 if (!integer_zerop (TREE_OPERAND (node
, 1)))
1123 pp_string (buffer
, " + ");
1124 dump_generic_node (buffer
, TREE_OPERAND (node
, 1),
1127 pp_right_bracket (buffer
);
1132 case TARGET_MEM_REF
:
1134 const char *sep
= "";
1137 pp_string (buffer
, "MEM[");
1139 if (TREE_CODE (TMR_BASE (node
)) == ADDR_EXPR
)
1141 pp_string (buffer
, sep
);
1143 pp_string (buffer
, "symbol: ");
1144 dump_generic_node (buffer
, TREE_OPERAND (TMR_BASE (node
), 0),
1149 pp_string (buffer
, sep
);
1151 pp_string (buffer
, "base: ");
1152 dump_generic_node (buffer
, TMR_BASE (node
), spc
, flags
, false);
1154 tmp
= TMR_INDEX2 (node
);
1157 pp_string (buffer
, sep
);
1159 pp_string (buffer
, "base: ");
1160 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1162 tmp
= TMR_INDEX (node
);
1165 pp_string (buffer
, sep
);
1167 pp_string (buffer
, "index: ");
1168 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1170 tmp
= TMR_STEP (node
);
1173 pp_string (buffer
, sep
);
1175 pp_string (buffer
, "step: ");
1176 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1178 tmp
= TMR_OFFSET (node
);
1181 pp_string (buffer
, sep
);
1183 pp_string (buffer
, "offset: ");
1184 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1186 pp_right_bracket (buffer
);
1194 /* Print the innermost component type. */
1195 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
1196 tmp
= TREE_TYPE (tmp
))
1198 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1200 /* Print the dimensions. */
1201 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
1202 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
1208 case QUAL_UNION_TYPE
:
1210 unsigned int quals
= TYPE_QUALS (node
);
1212 if (quals
& TYPE_QUAL_ATOMIC
)
1213 pp_string (buffer
, "atomic ");
1214 if (quals
& TYPE_QUAL_CONST
)
1215 pp_string (buffer
, "const ");
1216 if (quals
& TYPE_QUAL_VOLATILE
)
1217 pp_string (buffer
, "volatile ");
1219 /* Print the name of the structure. */
1220 if (TREE_CODE (node
) == RECORD_TYPE
)
1221 pp_string (buffer
, "struct ");
1222 else if (TREE_CODE (node
) == UNION_TYPE
)
1223 pp_string (buffer
, "union ");
1225 if (TYPE_NAME (node
))
1226 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
1227 else if (!(flags
& TDF_SLIM
))
1228 /* FIXME: If we eliminate the 'else' above and attempt
1229 to show the fields for named types, we may get stuck
1230 following a cycle of pointers to structs. The alleged
1231 self-reference check in print_struct_decl will not detect
1232 cycles involving more than one pointer or struct type. */
1233 print_struct_decl (buffer
, node
, spc
, flags
);
1242 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
1244 /* In the case of a pointer, one may want to divide by the
1245 size of the pointed-to type. Unfortunately, this not
1246 straightforward. The C front-end maps expressions
1251 in such a way that the two INTEGER_CST nodes for "5" have
1252 different values but identical types. In the latter
1253 case, the 5 is multiplied by sizeof (int) in c-common.c
1254 (pointer_int_sum) to convert it to a byte address, and
1255 yet the type of the node is left unchanged. Argh. What
1256 is consistent though is that the number value corresponds
1257 to bytes (UNITS) offset.
1259 NB: Neither of the following divisors can be trivially
1260 used to recover the original literal:
1262 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1263 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1264 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1265 pp_string (buffer
, "B"); /* pseudo-unit */
1267 else if (tree_fits_shwi_p (node
))
1268 pp_wide_integer (buffer
, tree_to_shwi (node
));
1269 else if (tree_fits_uhwi_p (node
))
1270 pp_unsigned_wide_integer (buffer
, tree_to_uhwi (node
));
1273 wide_int val
= node
;
1275 if (wi::neg_p (val
, TYPE_SIGN (TREE_TYPE (node
))))
1280 print_hex (val
, pp_buffer (buffer
)->digit_buffer
);
1281 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
1283 if (TREE_OVERFLOW (node
))
1284 pp_string (buffer
, "(OVF)");
1288 /* Code copied from print_node. */
1291 if (TREE_OVERFLOW (node
))
1292 pp_string (buffer
, " overflow");
1294 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1295 d
= TREE_REAL_CST (node
);
1296 if (REAL_VALUE_ISINF (d
))
1297 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
1298 else if (REAL_VALUE_ISNAN (d
))
1299 pp_string (buffer
, " Nan");
1303 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
1304 pp_string (buffer
, string
);
1309 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
1310 pp_string (buffer
, "0x");
1311 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
1312 output_formatted_integer (buffer
, "%02x", *p
++);
1321 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
1322 pp_string (buffer
, string
);
1327 pp_string (buffer
, "__complex__ (");
1328 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
1329 pp_string (buffer
, ", ");
1330 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
1331 pp_right_paren (buffer
);
1335 pp_string (buffer
, "\"");
1336 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
1337 pp_string (buffer
, "\"");
1343 pp_string (buffer
, "{ ");
1344 for (i
= 0; i
< VECTOR_CST_NELTS (node
); ++i
)
1347 pp_string (buffer
, ", ");
1348 dump_generic_node (buffer
, VECTOR_CST_ELT (node
, i
),
1351 pp_string (buffer
, " }");
1357 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1359 if (TREE_CODE (node
) == METHOD_TYPE
)
1361 if (TYPE_METHOD_BASETYPE (node
))
1362 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
1365 pp_string (buffer
, "<null method basetype>");
1366 pp_colon_colon (buffer
);
1368 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1369 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1370 else if (flags
& TDF_NOUID
)
1371 pp_printf (buffer
, "<Txxxx>");
1373 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1374 dump_function_declaration (buffer
, node
, spc
, flags
);
1379 dump_decl_name (buffer
, node
, flags
);
1383 if (DECL_NAME (node
))
1384 dump_decl_name (buffer
, node
, flags
);
1385 else if (LABEL_DECL_UID (node
) != -1)
1386 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1389 if (flags
& TDF_NOUID
)
1390 pp_string (buffer
, "<D.xxxx>");
1392 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1397 if (DECL_IS_BUILTIN (node
))
1399 /* Don't print the declaration of built-in types. */
1402 if (DECL_NAME (node
))
1403 dump_decl_name (buffer
, node
, flags
);
1404 else if (TYPE_NAME (TREE_TYPE (node
)) != node
)
1406 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1407 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1408 && TYPE_METHODS (TREE_TYPE (node
)))
1410 /* The type is a c++ class: all structures have at least
1412 pp_string (buffer
, "class ");
1413 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1418 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1419 ? "union" : "struct "));
1420 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1424 pp_string (buffer
, "<anon>");
1430 case DEBUG_EXPR_DECL
:
1431 case NAMESPACE_DECL
:
1433 dump_decl_name (buffer
, node
, flags
);
1437 pp_string (buffer
, "<retval>");
1441 op0
= TREE_OPERAND (node
, 0);
1444 && (TREE_CODE (op0
) == INDIRECT_REF
1445 || (TREE_CODE (op0
) == MEM_REF
1446 && TREE_CODE (TREE_OPERAND (op0
, 0)) != ADDR_EXPR
1447 && integer_zerop (TREE_OPERAND (op0
, 1))
1448 /* Dump the types of INTEGER_CSTs explicitly, for we
1449 can't infer them and MEM_ATTR caching will share
1450 MEM_REFs with differently-typed op0s. */
1451 && TREE_CODE (TREE_OPERAND (op0
, 0)) != INTEGER_CST
1452 /* Released SSA_NAMES have no TREE_TYPE. */
1453 && TREE_TYPE (TREE_OPERAND (op0
, 0)) != NULL_TREE
1454 /* Same pointer types, but ignoring POINTER_TYPE vs.
1456 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1457 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1458 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1459 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1460 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1461 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1462 /* Same value types ignoring qualifiers. */
1463 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0
))
1464 == TYPE_MAIN_VARIANT
1465 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))))))
1467 op0
= TREE_OPERAND (op0
, 0);
1470 if (op_prio (op0
) < op_prio (node
))
1471 pp_left_paren (buffer
);
1472 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1473 if (op_prio (op0
) < op_prio (node
))
1474 pp_right_paren (buffer
);
1475 pp_string (buffer
, str
);
1476 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1477 op0
= component_ref_field_offset (node
);
1478 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1480 pp_string (buffer
, "{off: ");
1481 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1482 pp_right_brace (buffer
);
1487 pp_string (buffer
, "BIT_FIELD_REF <");
1488 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1489 pp_string (buffer
, ", ");
1490 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1491 pp_string (buffer
, ", ");
1492 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1493 pp_greater (buffer
);
1497 case ARRAY_RANGE_REF
:
1498 op0
= TREE_OPERAND (node
, 0);
1499 if (op_prio (op0
) < op_prio (node
))
1500 pp_left_paren (buffer
);
1501 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1502 if (op_prio (op0
) < op_prio (node
))
1503 pp_right_paren (buffer
);
1504 pp_left_bracket (buffer
);
1505 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1506 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1507 pp_string (buffer
, " ...");
1508 pp_right_bracket (buffer
);
1510 op0
= array_ref_low_bound (node
);
1511 op1
= array_ref_element_size (node
);
1513 if (!integer_zerop (op0
)
1514 || TREE_OPERAND (node
, 2)
1515 || TREE_OPERAND (node
, 3))
1517 pp_string (buffer
, "{lb: ");
1518 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1519 pp_string (buffer
, " sz: ");
1520 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1521 pp_right_brace (buffer
);
1527 unsigned HOST_WIDE_INT ix
;
1529 bool is_struct_init
= false;
1530 bool is_array_init
= false;
1532 pp_left_brace (buffer
);
1533 if (TREE_CLOBBER_P (node
))
1534 pp_string (buffer
, "CLOBBER");
1535 else if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1536 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1537 is_struct_init
= true;
1538 else if (TREE_CODE (TREE_TYPE (node
)) == ARRAY_TYPE
1539 && TYPE_DOMAIN (TREE_TYPE (node
))
1540 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)))
1541 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
))))
1544 tree minv
= TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)));
1545 is_array_init
= true;
1546 curidx
= wi::to_widest (minv
);
1548 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1555 dump_generic_node (buffer
, field
, spc
, flags
, false);
1558 else if (is_array_init
1559 && (TREE_CODE (field
) != INTEGER_CST
1560 || curidx
!= wi::to_widest (field
)))
1562 pp_left_bracket (buffer
);
1563 if (TREE_CODE (field
) == RANGE_EXPR
)
1565 dump_generic_node (buffer
, TREE_OPERAND (field
, 0), spc
,
1567 pp_string (buffer
, " ... ");
1568 dump_generic_node (buffer
, TREE_OPERAND (field
, 1), spc
,
1570 if (TREE_CODE (TREE_OPERAND (field
, 1)) == INTEGER_CST
)
1571 curidx
= wi::to_widest (TREE_OPERAND (field
, 1));
1574 dump_generic_node (buffer
, field
, spc
, flags
, false);
1575 if (TREE_CODE (field
) == INTEGER_CST
)
1576 curidx
= wi::to_widest (field
);
1577 pp_string (buffer
, "]=");
1582 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1583 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1584 val
= TREE_OPERAND (val
, 0);
1585 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1586 dump_decl_name (buffer
, val
, flags
);
1588 dump_generic_node (buffer
, val
, spc
, flags
, false);
1589 if (ix
!= vec_safe_length (CONSTRUCTOR_ELTS (node
)) - 1)
1595 pp_right_brace (buffer
);
1602 if (flags
& TDF_SLIM
)
1604 pp_string (buffer
, "<COMPOUND_EXPR>");
1608 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1609 spc
, flags
, !(flags
& TDF_SLIM
));
1610 if (flags
& TDF_SLIM
)
1611 newline_and_indent (buffer
, spc
);
1618 for (tp
= &TREE_OPERAND (node
, 1);
1619 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1620 tp
= &TREE_OPERAND (*tp
, 1))
1622 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1623 spc
, flags
, !(flags
& TDF_SLIM
));
1624 if (flags
& TDF_SLIM
)
1625 newline_and_indent (buffer
, spc
);
1633 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1637 case STATEMENT_LIST
:
1639 tree_stmt_iterator si
;
1642 if (flags
& TDF_SLIM
)
1644 pp_string (buffer
, "<STATEMENT_LIST>");
1648 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1651 newline_and_indent (buffer
, spc
);
1654 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1661 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1666 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1671 pp_string (buffer
, "TARGET_EXPR <");
1672 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1675 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1676 pp_greater (buffer
);
1680 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1685 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1687 pp_string (buffer
, "if (");
1688 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1689 pp_right_paren (buffer
);
1690 /* The lowered cond_exprs should always be printed in full. */
1691 if (COND_EXPR_THEN (node
)
1692 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1693 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1694 && COND_EXPR_ELSE (node
)
1695 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1696 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1699 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1701 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1703 pp_string (buffer
, " else ");
1704 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1708 else if (!(flags
& TDF_SLIM
))
1710 /* Output COND_EXPR_THEN. */
1711 if (COND_EXPR_THEN (node
))
1713 newline_and_indent (buffer
, spc
+2);
1714 pp_left_brace (buffer
);
1715 newline_and_indent (buffer
, spc
+4);
1716 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1718 newline_and_indent (buffer
, spc
+2);
1719 pp_right_brace (buffer
);
1722 /* Output COND_EXPR_ELSE. */
1723 if (COND_EXPR_ELSE (node
)
1724 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1726 newline_and_indent (buffer
, spc
);
1727 pp_string (buffer
, "else");
1728 newline_and_indent (buffer
, spc
+2);
1729 pp_left_brace (buffer
);
1730 newline_and_indent (buffer
, spc
+4);
1731 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1733 newline_and_indent (buffer
, spc
+2);
1734 pp_right_brace (buffer
);
1741 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1743 pp_question (buffer
);
1745 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1749 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1754 pp_left_brace (buffer
);
1755 if (!(flags
& TDF_SLIM
))
1757 if (BIND_EXPR_VARS (node
))
1759 pp_newline (buffer
);
1761 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= DECL_CHAIN (op0
))
1763 print_declaration (buffer
, op0
, spc
+2, flags
);
1764 pp_newline (buffer
);
1768 newline_and_indent (buffer
, spc
+2);
1769 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1770 newline_and_indent (buffer
, spc
);
1771 pp_right_brace (buffer
);
1777 if (CALL_EXPR_FN (node
) != NULL_TREE
)
1778 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1780 pp_string (buffer
, internal_fn_name (CALL_EXPR_IFN (node
)));
1782 /* Print parameters. */
1784 pp_left_paren (buffer
);
1787 call_expr_arg_iterator iter
;
1788 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1790 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1791 if (more_call_expr_args_p (&iter
))
1798 if (CALL_EXPR_VA_ARG_PACK (node
))
1800 if (call_expr_nargs (node
) > 0)
1805 pp_string (buffer
, "__builtin_va_arg_pack ()");
1807 pp_right_paren (buffer
);
1809 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1812 pp_string (buffer
, " [static-chain: ");
1813 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1814 pp_right_bracket (buffer
);
1817 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1818 pp_string (buffer
, " [return slot optimization]");
1819 if (CALL_EXPR_TAILCALL (node
))
1820 pp_string (buffer
, " [tail call]");
1823 case WITH_CLEANUP_EXPR
:
1827 case CLEANUP_POINT_EXPR
:
1828 pp_string (buffer
, "<<cleanup_point ");
1829 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1830 pp_string (buffer
, ">>");
1833 case PLACEHOLDER_EXPR
:
1834 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1835 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1836 pp_greater (buffer
);
1839 /* Binary arithmetic and logic expressions. */
1840 case WIDEN_SUM_EXPR
:
1841 case WIDEN_MULT_EXPR
:
1843 case MULT_HIGHPART_EXPR
:
1845 case POINTER_PLUS_EXPR
:
1847 case TRUNC_DIV_EXPR
:
1849 case FLOOR_DIV_EXPR
:
1850 case ROUND_DIV_EXPR
:
1851 case TRUNC_MOD_EXPR
:
1853 case FLOOR_MOD_EXPR
:
1854 case ROUND_MOD_EXPR
:
1856 case EXACT_DIV_EXPR
:
1861 case WIDEN_LSHIFT_EXPR
:
1865 case TRUTH_ANDIF_EXPR
:
1866 case TRUTH_ORIF_EXPR
:
1867 case TRUTH_AND_EXPR
:
1869 case TRUTH_XOR_EXPR
:
1883 case UNORDERED_EXPR
:
1885 const char *op
= op_symbol (node
);
1886 op0
= TREE_OPERAND (node
, 0);
1887 op1
= TREE_OPERAND (node
, 1);
1889 /* When the operands are expressions with less priority,
1890 keep semantics of the tree representation. */
1891 if (op_prio (op0
) <= op_prio (node
))
1893 pp_left_paren (buffer
);
1894 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1895 pp_right_paren (buffer
);
1898 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1901 pp_string (buffer
, op
);
1904 /* When the operands are expressions with less priority,
1905 keep semantics of the tree representation. */
1906 if (op_prio (op1
) <= op_prio (node
))
1908 pp_left_paren (buffer
);
1909 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1910 pp_right_paren (buffer
);
1913 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1917 /* Unary arithmetic and logic expressions. */
1920 case TRUTH_NOT_EXPR
:
1922 case PREDECREMENT_EXPR
:
1923 case PREINCREMENT_EXPR
:
1925 if (TREE_CODE (node
) == ADDR_EXPR
1926 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1927 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1928 ; /* Do not output '&' for strings and function pointers. */
1930 pp_string (buffer
, op_symbol (node
));
1932 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1934 pp_left_paren (buffer
);
1935 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1936 pp_right_paren (buffer
);
1939 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1942 case POSTDECREMENT_EXPR
:
1943 case POSTINCREMENT_EXPR
:
1944 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1946 pp_left_paren (buffer
);
1947 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1948 pp_right_paren (buffer
);
1951 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1952 pp_string (buffer
, op_symbol (node
));
1956 pp_string (buffer
, "MIN_EXPR <");
1957 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1958 pp_string (buffer
, ", ");
1959 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1960 pp_greater (buffer
);
1964 pp_string (buffer
, "MAX_EXPR <");
1965 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1966 pp_string (buffer
, ", ");
1967 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1968 pp_greater (buffer
);
1972 pp_string (buffer
, "ABS_EXPR <");
1973 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1974 pp_greater (buffer
);
1981 case ADDR_SPACE_CONVERT_EXPR
:
1982 case FIXED_CONVERT_EXPR
:
1983 case FIX_TRUNC_EXPR
:
1986 type
= TREE_TYPE (node
);
1987 op0
= TREE_OPERAND (node
, 0);
1988 if (type
!= TREE_TYPE (op0
))
1990 pp_left_paren (buffer
);
1991 dump_generic_node (buffer
, type
, spc
, flags
, false);
1992 pp_string (buffer
, ") ");
1994 if (op_prio (op0
) < op_prio (node
))
1995 pp_left_paren (buffer
);
1996 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1997 if (op_prio (op0
) < op_prio (node
))
1998 pp_right_paren (buffer
);
2001 case VIEW_CONVERT_EXPR
:
2002 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
2003 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
2004 pp_string (buffer
, ">(");
2005 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2006 pp_right_paren (buffer
);
2010 pp_string (buffer
, "((");
2011 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2012 pp_string (buffer
, "))");
2015 case NON_LVALUE_EXPR
:
2016 pp_string (buffer
, "NON_LVALUE_EXPR <");
2017 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2018 pp_greater (buffer
);
2022 pp_string (buffer
, "SAVE_EXPR <");
2023 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2024 pp_greater (buffer
);
2028 pp_string (buffer
, "COMPLEX_EXPR <");
2029 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2030 pp_string (buffer
, ", ");
2031 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2032 pp_greater (buffer
);
2036 pp_string (buffer
, "CONJ_EXPR <");
2037 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2038 pp_greater (buffer
);
2042 pp_string (buffer
, "REALPART_EXPR <");
2043 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2044 pp_greater (buffer
);
2048 pp_string (buffer
, "IMAGPART_EXPR <");
2049 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2050 pp_greater (buffer
);
2054 pp_string (buffer
, "VA_ARG_EXPR <");
2055 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2056 pp_greater (buffer
);
2059 case TRY_FINALLY_EXPR
:
2060 case TRY_CATCH_EXPR
:
2061 pp_string (buffer
, "try");
2062 newline_and_indent (buffer
, spc
+2);
2063 pp_left_brace (buffer
);
2064 newline_and_indent (buffer
, spc
+4);
2065 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
2066 newline_and_indent (buffer
, spc
+2);
2067 pp_right_brace (buffer
);
2068 newline_and_indent (buffer
, spc
);
2070 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
2071 newline_and_indent (buffer
, spc
+2);
2072 pp_left_brace (buffer
);
2073 newline_and_indent (buffer
, spc
+4);
2074 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
2075 newline_and_indent (buffer
, spc
+2);
2076 pp_right_brace (buffer
);
2081 pp_string (buffer
, "catch (");
2082 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
2083 pp_right_paren (buffer
);
2084 newline_and_indent (buffer
, spc
+2);
2085 pp_left_brace (buffer
);
2086 newline_and_indent (buffer
, spc
+4);
2087 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
2088 newline_and_indent (buffer
, spc
+2);
2089 pp_right_brace (buffer
);
2093 case EH_FILTER_EXPR
:
2094 pp_string (buffer
, "<<<eh_filter (");
2095 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
2096 pp_string (buffer
, ")>>>");
2097 newline_and_indent (buffer
, spc
+2);
2098 pp_left_brace (buffer
);
2099 newline_and_indent (buffer
, spc
+4);
2100 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
2101 newline_and_indent (buffer
, spc
+2);
2102 pp_right_brace (buffer
);
2107 op0
= TREE_OPERAND (node
, 0);
2108 /* If this is for break or continue, don't bother printing it. */
2109 if (DECL_NAME (op0
))
2111 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
2112 if (strcmp (name
, "break") == 0
2113 || strcmp (name
, "continue") == 0)
2116 dump_generic_node (buffer
, op0
, spc
, flags
, false);
2118 if (DECL_NONLOCAL (op0
))
2119 pp_string (buffer
, " [non-local]");
2123 pp_string (buffer
, "while (1)");
2124 if (!(flags
& TDF_SLIM
))
2126 newline_and_indent (buffer
, spc
+2);
2127 pp_left_brace (buffer
);
2128 newline_and_indent (buffer
, spc
+4);
2129 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
2130 newline_and_indent (buffer
, spc
+2);
2131 pp_right_brace (buffer
);
2137 pp_string (buffer
, "// predicted ");
2138 if (PREDICT_EXPR_OUTCOME (node
))
2139 pp_string (buffer
, "likely by ");
2141 pp_string (buffer
, "unlikely by ");
2142 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
2143 pp_string (buffer
, " predictor.");
2147 pp_string (buffer
, "ANNOTATE_EXPR <");
2148 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2149 switch ((enum annot_expr_kind
) TREE_INT_CST_LOW (TREE_OPERAND (node
, 1)))
2151 case annot_expr_ivdep_kind
:
2152 pp_string (buffer
, ", ivdep");
2154 case annot_expr_no_vector_kind
:
2155 pp_string (buffer
, ", no-vector");
2157 case annot_expr_vector_kind
:
2158 pp_string (buffer
, ", vector");
2163 pp_greater (buffer
);
2167 pp_string (buffer
, "return");
2168 op0
= TREE_OPERAND (node
, 0);
2172 if (TREE_CODE (op0
) == MODIFY_EXPR
)
2173 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
2176 dump_generic_node (buffer
, op0
, spc
, flags
, false);
2181 pp_string (buffer
, "if (");
2182 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2183 pp_string (buffer
, ") break");
2187 pp_string (buffer
, "switch (");
2188 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
2189 pp_right_paren (buffer
);
2190 if (!(flags
& TDF_SLIM
))
2192 newline_and_indent (buffer
, spc
+2);
2193 pp_left_brace (buffer
);
2194 if (SWITCH_BODY (node
))
2196 newline_and_indent (buffer
, spc
+4);
2197 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
2202 tree vec
= SWITCH_LABELS (node
);
2203 size_t i
, n
= TREE_VEC_LENGTH (vec
);
2204 for (i
= 0; i
< n
; ++i
)
2206 tree elt
= TREE_VEC_ELT (vec
, i
);
2207 newline_and_indent (buffer
, spc
+4);
2210 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
2211 pp_string (buffer
, " goto ");
2212 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
2214 pp_semicolon (buffer
);
2217 pp_string (buffer
, "case ???: goto ???;");
2220 newline_and_indent (buffer
, spc
+2);
2221 pp_right_brace (buffer
);
2227 op0
= GOTO_DESTINATION (node
);
2228 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
2230 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
2231 if (strcmp (name
, "break") == 0
2232 || strcmp (name
, "continue") == 0)
2234 pp_string (buffer
, name
);
2238 pp_string (buffer
, "goto ");
2239 dump_generic_node (buffer
, op0
, spc
, flags
, false);
2243 pp_string (buffer
, "__asm__");
2244 if (ASM_VOLATILE_P (node
))
2245 pp_string (buffer
, " __volatile__");
2246 pp_left_paren (buffer
);
2247 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
2249 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
2251 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
2252 if (ASM_CLOBBERS (node
))
2255 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
2257 pp_right_paren (buffer
);
2260 case CASE_LABEL_EXPR
:
2261 if (CASE_LOW (node
) && CASE_HIGH (node
))
2263 pp_string (buffer
, "case ");
2264 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
2265 pp_string (buffer
, " ... ");
2266 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
2268 else if (CASE_LOW (node
))
2270 pp_string (buffer
, "case ");
2271 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
2274 pp_string (buffer
, "default");
2279 pp_string (buffer
, "OBJ_TYPE_REF(");
2280 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
2281 pp_semicolon (buffer
);
2282 if (!(flags
& TDF_SLIM
) && virtual_method_call_p (node
))
2284 pp_string (buffer
, "(");
2285 dump_generic_node (buffer
, obj_type_ref_class (node
), spc
, flags
, false);
2286 pp_string (buffer
, ")");
2288 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
2290 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
2291 pp_right_paren (buffer
);
2295 if (SSA_NAME_IDENTIFIER (node
))
2296 dump_generic_node (buffer
, SSA_NAME_IDENTIFIER (node
),
2298 pp_underscore (buffer
);
2299 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
2300 if (SSA_NAME_IS_DEFAULT_DEF (node
))
2301 pp_string (buffer
, "(D)");
2302 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
2303 pp_string (buffer
, "(ab)");
2306 case WITH_SIZE_EXPR
:
2307 pp_string (buffer
, "WITH_SIZE_EXPR <");
2308 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2309 pp_string (buffer
, ", ");
2310 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2311 pp_greater (buffer
);
2315 pp_string (buffer
, "ASSERT_EXPR <");
2316 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
2317 pp_string (buffer
, ", ");
2318 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
2319 pp_greater (buffer
);
2323 pp_string (buffer
, "scev_known");
2326 case SCEV_NOT_KNOWN
:
2327 pp_string (buffer
, "scev_not_known");
2330 case POLYNOMIAL_CHREC
:
2331 pp_left_brace (buffer
);
2332 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
2333 pp_string (buffer
, ", +, ");
2334 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
2335 pp_string (buffer
, "}_");
2336 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
2340 case REALIGN_LOAD_EXPR
:
2341 pp_string (buffer
, "REALIGN_LOAD <");
2342 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2343 pp_string (buffer
, ", ");
2344 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2345 pp_string (buffer
, ", ");
2346 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2347 pp_greater (buffer
);
2351 pp_string (buffer
, " VEC_COND_EXPR < ");
2352 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2353 pp_string (buffer
, " , ");
2354 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2355 pp_string (buffer
, " , ");
2356 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2357 pp_string (buffer
, " > ");
2361 pp_string (buffer
, " VEC_PERM_EXPR < ");
2362 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2363 pp_string (buffer
, " , ");
2364 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2365 pp_string (buffer
, " , ");
2366 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2367 pp_string (buffer
, " > ");
2371 pp_string (buffer
, " DOT_PROD_EXPR < ");
2372 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2373 pp_string (buffer
, ", ");
2374 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2375 pp_string (buffer
, ", ");
2376 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2377 pp_string (buffer
, " > ");
2380 case WIDEN_MULT_PLUS_EXPR
:
2381 pp_string (buffer
, " WIDEN_MULT_PLUS_EXPR < ");
2382 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2383 pp_string (buffer
, ", ");
2384 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2385 pp_string (buffer
, ", ");
2386 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2387 pp_string (buffer
, " > ");
2390 case WIDEN_MULT_MINUS_EXPR
:
2391 pp_string (buffer
, " WIDEN_MULT_MINUS_EXPR < ");
2392 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2393 pp_string (buffer
, ", ");
2394 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2395 pp_string (buffer
, ", ");
2396 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2397 pp_string (buffer
, " > ");
2401 pp_string (buffer
, " FMA_EXPR < ");
2402 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2403 pp_string (buffer
, ", ");
2404 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2405 pp_string (buffer
, ", ");
2406 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2407 pp_string (buffer
, " > ");
2411 pp_string (buffer
, "#pragma omp parallel");
2412 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
2415 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
2417 newline_and_indent (buffer
, spc
+ 2);
2418 pp_left_brace (buffer
);
2419 newline_and_indent (buffer
, spc
+ 4);
2420 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
2421 newline_and_indent (buffer
, spc
+ 2);
2422 pp_right_brace (buffer
);
2428 pp_string (buffer
, "#pragma omp task");
2429 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
2433 pp_string (buffer
, "#pragma omp for");
2437 pp_string (buffer
, "#pragma omp simd");
2441 pp_string (buffer
, "#pragma simd");
2445 /* This label points one line after dumping the clauses.
2446 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2447 parameters are printed out. */
2448 goto dump_omp_loop_cilk_for
;
2450 case OMP_DISTRIBUTE
:
2451 pp_string (buffer
, "#pragma omp distribute");
2455 pp_string (buffer
, "#pragma omp teams");
2456 dump_omp_clauses (buffer
, OMP_TEAMS_CLAUSES (node
), spc
, flags
);
2459 case OMP_TARGET_DATA
:
2460 pp_string (buffer
, "#pragma omp target data");
2461 dump_omp_clauses (buffer
, OMP_TARGET_DATA_CLAUSES (node
), spc
, flags
);
2465 pp_string (buffer
, "#pragma omp target");
2466 dump_omp_clauses (buffer
, OMP_TARGET_CLAUSES (node
), spc
, flags
);
2469 case OMP_TARGET_UPDATE
:
2470 pp_string (buffer
, "#pragma omp target update");
2471 dump_omp_clauses (buffer
, OMP_TARGET_UPDATE_CLAUSES (node
), spc
, flags
);
2476 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
2478 dump_omp_loop_cilk_for
:
2479 if (!(flags
& TDF_SLIM
))
2483 if (OMP_FOR_PRE_BODY (node
))
2485 if (TREE_CODE (node
) == CILK_FOR
)
2486 pp_string (buffer
, " ");
2488 newline_and_indent (buffer
, spc
+ 2);
2489 pp_left_brace (buffer
);
2491 newline_and_indent (buffer
, spc
);
2492 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
2495 if (OMP_FOR_INIT (node
))
2498 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
2501 if (TREE_CODE (node
) != CILK_FOR
|| OMP_FOR_PRE_BODY (node
))
2502 newline_and_indent (buffer
, spc
);
2503 if (TREE_CODE (node
) == CILK_FOR
)
2504 pp_string (buffer
, "_Cilk_for (");
2506 pp_string (buffer
, "for (");
2507 dump_generic_node (buffer
,
2508 TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
2510 pp_string (buffer
, "; ");
2511 dump_generic_node (buffer
,
2512 TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
2514 pp_string (buffer
, "; ");
2515 dump_generic_node (buffer
,
2516 TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
2518 pp_right_paren (buffer
);
2520 if (TREE_CODE (node
) == CILK_FOR
)
2521 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
2523 if (OMP_FOR_BODY (node
))
2525 newline_and_indent (buffer
, spc
+ 2);
2526 pp_left_brace (buffer
);
2527 newline_and_indent (buffer
, spc
+ 4);
2528 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
2530 newline_and_indent (buffer
, spc
+ 2);
2531 pp_right_brace (buffer
);
2533 if (OMP_FOR_INIT (node
))
2534 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
2535 if (OMP_FOR_PRE_BODY (node
))
2538 newline_and_indent (buffer
, spc
+ 2);
2539 pp_right_brace (buffer
);
2546 pp_string (buffer
, "#pragma omp sections");
2547 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2551 pp_string (buffer
, "#pragma omp section");
2555 pp_string (buffer
, "#pragma omp master");
2559 pp_string (buffer
, "#pragma omp taskgroup");
2563 pp_string (buffer
, "#pragma omp ordered");
2567 pp_string (buffer
, "#pragma omp critical");
2568 if (OMP_CRITICAL_NAME (node
))
2571 pp_left_paren (buffer
);
2572 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2574 pp_right_paren (buffer
);
2579 pp_string (buffer
, "#pragma omp atomic");
2580 if (OMP_ATOMIC_SEQ_CST (node
))
2581 pp_string (buffer
, " seq_cst");
2582 newline_and_indent (buffer
, spc
+ 2);
2583 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2587 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2590 case OMP_ATOMIC_READ
:
2591 pp_string (buffer
, "#pragma omp atomic read");
2592 if (OMP_ATOMIC_SEQ_CST (node
))
2593 pp_string (buffer
, " seq_cst");
2594 newline_and_indent (buffer
, spc
+ 2);
2595 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2599 case OMP_ATOMIC_CAPTURE_OLD
:
2600 case OMP_ATOMIC_CAPTURE_NEW
:
2601 pp_string (buffer
, "#pragma omp atomic capture");
2602 if (OMP_ATOMIC_SEQ_CST (node
))
2603 pp_string (buffer
, " seq_cst");
2604 newline_and_indent (buffer
, spc
+ 2);
2605 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2609 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2613 pp_string (buffer
, "#pragma omp single");
2614 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2618 dump_omp_clause (buffer
, node
, spc
, flags
);
2622 case TRANSACTION_EXPR
:
2623 if (TRANSACTION_EXPR_OUTER (node
))
2624 pp_string (buffer
, "__transaction_atomic [[outer]]");
2625 else if (TRANSACTION_EXPR_RELAXED (node
))
2626 pp_string (buffer
, "__transaction_relaxed");
2628 pp_string (buffer
, "__transaction_atomic");
2629 if (!(flags
& TDF_SLIM
) && TRANSACTION_EXPR_BODY (node
))
2631 newline_and_indent (buffer
, spc
);
2632 pp_left_brace (buffer
);
2633 newline_and_indent (buffer
, spc
+ 2);
2634 dump_generic_node (buffer
, TRANSACTION_EXPR_BODY (node
),
2635 spc
+ 2, flags
, false);
2636 newline_and_indent (buffer
, spc
);
2637 pp_right_brace (buffer
);
2642 case REDUC_MAX_EXPR
:
2643 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2644 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2645 pp_string (buffer
, " > ");
2648 case REDUC_MIN_EXPR
:
2649 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2650 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2651 pp_string (buffer
, " > ");
2654 case REDUC_PLUS_EXPR
:
2655 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2656 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2657 pp_string (buffer
, " > ");
2660 case VEC_WIDEN_MULT_HI_EXPR
:
2661 case VEC_WIDEN_MULT_LO_EXPR
:
2662 case VEC_WIDEN_MULT_EVEN_EXPR
:
2663 case VEC_WIDEN_MULT_ODD_EXPR
:
2664 case VEC_WIDEN_LSHIFT_HI_EXPR
:
2665 case VEC_WIDEN_LSHIFT_LO_EXPR
:
2667 for (str
= get_tree_code_name (code
); *str
; str
++)
2668 pp_character (buffer
, TOUPPER (*str
));
2669 pp_string (buffer
, " < ");
2670 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2671 pp_string (buffer
, ", ");
2672 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2673 pp_string (buffer
, " > ");
2676 case VEC_UNPACK_HI_EXPR
:
2677 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2678 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2679 pp_string (buffer
, " > ");
2682 case VEC_UNPACK_LO_EXPR
:
2683 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2684 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2685 pp_string (buffer
, " > ");
2688 case VEC_UNPACK_FLOAT_HI_EXPR
:
2689 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2690 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2691 pp_string (buffer
, " > ");
2694 case VEC_UNPACK_FLOAT_LO_EXPR
:
2695 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2696 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2697 pp_string (buffer
, " > ");
2700 case VEC_PACK_TRUNC_EXPR
:
2701 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2702 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2703 pp_string (buffer
, ", ");
2704 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2705 pp_string (buffer
, " > ");
2708 case VEC_PACK_SAT_EXPR
:
2709 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2710 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2711 pp_string (buffer
, ", ");
2712 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2713 pp_string (buffer
, " > ");
2716 case VEC_PACK_FIX_TRUNC_EXPR
:
2717 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2718 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2719 pp_string (buffer
, ", ");
2720 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2721 pp_string (buffer
, " > ");
2725 dump_block_node (buffer
, node
, spc
, flags
);
2728 case CILK_SPAWN_STMT
:
2729 pp_string (buffer
, "_Cilk_spawn ");
2730 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2733 case CILK_SYNC_STMT
:
2734 pp_string (buffer
, "_Cilk_sync");
2741 if (is_stmt
&& is_expr
)
2742 pp_semicolon (buffer
);
2747 /* Print the declaration of a variable. */
2750 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2754 if (TREE_CODE(t
) == NAMELIST_DECL
)
2756 pp_string(buffer
, "namelist ");
2757 dump_decl_name (buffer
, t
, flags
);
2758 pp_semicolon (buffer
);
2762 if (TREE_CODE (t
) == TYPE_DECL
)
2763 pp_string (buffer
, "typedef ");
2765 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2766 pp_string (buffer
, "register ");
2768 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2769 pp_string (buffer
, "extern ");
2770 else if (TREE_STATIC (t
))
2771 pp_string (buffer
, "static ");
2773 /* Print the type and name. */
2774 if (TREE_TYPE (t
) && TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2778 /* Print array's type. */
2779 tmp
= TREE_TYPE (t
);
2780 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2781 tmp
= TREE_TYPE (tmp
);
2782 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2784 /* Print variable's name. */
2786 dump_generic_node (buffer
, t
, spc
, flags
, false);
2788 /* Print the dimensions. */
2789 tmp
= TREE_TYPE (t
);
2790 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2792 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2793 tmp
= TREE_TYPE (tmp
);
2796 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2798 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2800 dump_decl_name (buffer
, t
, flags
);
2801 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2805 /* Print type declaration. */
2806 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2808 /* Print variable's name. */
2810 dump_generic_node (buffer
, t
, spc
, flags
, false);
2813 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2815 pp_string (buffer
, " __asm__ ");
2816 pp_left_paren (buffer
);
2817 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2818 pp_right_paren (buffer
);
2821 /* The initial value of a function serves to determine whether the function
2822 is declared or defined. So the following does not apply to function
2824 if (TREE_CODE (t
) != FUNCTION_DECL
)
2826 /* Print the initial value. */
2827 if (DECL_INITIAL (t
))
2832 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2836 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2838 pp_string (buffer
, " [value-expr: ");
2839 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2840 pp_right_bracket (buffer
);
2843 pp_semicolon (buffer
);
2847 /* Prints a structure: name, fields, and methods.
2848 FIXME: Still incomplete. */
2851 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2853 /* Print the name of the structure. */
2854 if (TYPE_NAME (node
))
2857 if (TREE_CODE (node
) == RECORD_TYPE
)
2858 pp_string (buffer
, "struct ");
2859 else if ((TREE_CODE (node
) == UNION_TYPE
2860 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2861 pp_string (buffer
, "union ");
2863 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2866 /* Print the contents of the structure. */
2867 pp_newline (buffer
);
2869 pp_left_brace (buffer
);
2870 pp_newline (buffer
);
2872 /* Print the fields of the structure. */
2875 tmp
= TYPE_FIELDS (node
);
2878 /* Avoid to print recursively the structure. */
2879 /* FIXME : Not implemented correctly...,
2880 what about the case when we have a cycle in the contain graph? ...
2881 Maybe this could be solved by looking at the scope in which the
2882 structure was declared. */
2883 if (TREE_TYPE (tmp
) != node
2884 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2885 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2887 print_declaration (buffer
, tmp
, spc
+2, flags
);
2888 pp_newline (buffer
);
2890 tmp
= DECL_CHAIN (tmp
);
2894 pp_right_brace (buffer
);
2897 /* Return the priority of the operator CODE.
2899 From lowest to highest precedence with either left-to-right (L-R)
2900 or right-to-left (R-L) associativity]:
2903 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2915 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2916 15 [L-R] fn() [] -> .
2918 unary +, - and * have higher precedence than the corresponding binary
2922 op_code_prio (enum tree_code code
)
2939 case TRUTH_ORIF_EXPR
:
2942 case TRUTH_AND_EXPR
:
2943 case TRUTH_ANDIF_EXPR
:
2950 case TRUTH_XOR_EXPR
:
2967 case UNORDERED_EXPR
:
2978 case VEC_WIDEN_LSHIFT_HI_EXPR
:
2979 case VEC_WIDEN_LSHIFT_LO_EXPR
:
2980 case WIDEN_LSHIFT_EXPR
:
2983 case WIDEN_SUM_EXPR
:
2985 case POINTER_PLUS_EXPR
:
2989 case VEC_WIDEN_MULT_HI_EXPR
:
2990 case VEC_WIDEN_MULT_LO_EXPR
:
2991 case WIDEN_MULT_EXPR
:
2993 case WIDEN_MULT_PLUS_EXPR
:
2994 case WIDEN_MULT_MINUS_EXPR
:
2996 case MULT_HIGHPART_EXPR
:
2997 case TRUNC_DIV_EXPR
:
2999 case FLOOR_DIV_EXPR
:
3000 case ROUND_DIV_EXPR
:
3002 case EXACT_DIV_EXPR
:
3003 case TRUNC_MOD_EXPR
:
3005 case FLOOR_MOD_EXPR
:
3006 case ROUND_MOD_EXPR
:
3010 case TRUTH_NOT_EXPR
:
3012 case POSTINCREMENT_EXPR
:
3013 case POSTDECREMENT_EXPR
:
3014 case PREINCREMENT_EXPR
:
3015 case PREDECREMENT_EXPR
:
3021 case FIX_TRUNC_EXPR
:
3027 case ARRAY_RANGE_REF
:
3031 /* Special expressions. */
3037 case REDUC_MAX_EXPR
:
3038 case REDUC_MIN_EXPR
:
3039 case REDUC_PLUS_EXPR
:
3040 case VEC_UNPACK_HI_EXPR
:
3041 case VEC_UNPACK_LO_EXPR
:
3042 case VEC_UNPACK_FLOAT_HI_EXPR
:
3043 case VEC_UNPACK_FLOAT_LO_EXPR
:
3044 case VEC_PACK_TRUNC_EXPR
:
3045 case VEC_PACK_SAT_EXPR
:
3049 /* Return an arbitrarily high precedence to avoid surrounding single
3050 VAR_DECLs in ()s. */
3055 /* Return the priority of the operator OP. */
3058 op_prio (const_tree op
)
3060 enum tree_code code
;
3065 code
= TREE_CODE (op
);
3066 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
3067 return op_prio (TREE_OPERAND (op
, 0));
3069 return op_code_prio (code
);
3072 /* Return the symbol associated with operator CODE. */
3075 op_symbol_code (enum tree_code code
)
3083 case TRUTH_ORIF_EXPR
:
3086 case TRUTH_AND_EXPR
:
3087 case TRUTH_ANDIF_EXPR
:
3093 case TRUTH_XOR_EXPR
:
3103 case UNORDERED_EXPR
:
3149 case WIDEN_LSHIFT_EXPR
:
3152 case POINTER_PLUS_EXPR
:
3158 case REDUC_PLUS_EXPR
:
3161 case WIDEN_SUM_EXPR
:
3164 case WIDEN_MULT_EXPR
:
3167 case MULT_HIGHPART_EXPR
:
3177 case TRUTH_NOT_EXPR
:
3184 case TRUNC_DIV_EXPR
:
3191 case FLOOR_DIV_EXPR
:
3194 case ROUND_DIV_EXPR
:
3197 case EXACT_DIV_EXPR
:
3200 case TRUNC_MOD_EXPR
:
3206 case FLOOR_MOD_EXPR
:
3209 case ROUND_MOD_EXPR
:
3212 case PREDECREMENT_EXPR
:
3215 case PREINCREMENT_EXPR
:
3218 case POSTDECREMENT_EXPR
:
3221 case POSTINCREMENT_EXPR
:
3231 return "<<< ??? >>>";
3235 /* Return the symbol associated with operator OP. */
3238 op_symbol (const_tree op
)
3240 return op_symbol_code (TREE_CODE (op
));
3243 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3244 the gimple_call_fn of a GIMPLE_CALL. */
3247 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
3251 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
3252 op0
= TREE_OPERAND (op0
, 0);
3255 switch (TREE_CODE (op0
))
3260 dump_function_name (buffer
, op0
, flags
);
3266 op0
= TREE_OPERAND (op0
, 0);
3270 pp_left_paren (buffer
);
3271 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
3272 pp_string (buffer
, ") ? ");
3273 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
3274 pp_string (buffer
, " : ");
3275 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
3279 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
3280 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
3282 dump_generic_node (buffer
, op0
, 0, flags
, false);
3286 if (integer_zerop (TREE_OPERAND (op0
, 1)))
3288 op0
= TREE_OPERAND (op0
, 0);
3295 dump_generic_node (buffer
, op0
, 0, flags
, false);
3303 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3306 pretty_print_string (pretty_printer
*buffer
, const char *str
)
3316 pp_string (buffer
, "\\b");
3320 pp_string (buffer
, "\\f");
3324 pp_string (buffer
, "\\n");
3328 pp_string (buffer
, "\\r");
3332 pp_string (buffer
, "\\t");
3336 pp_string (buffer
, "\\v");
3340 pp_string (buffer
, "\\\\");
3344 pp_string (buffer
, "\\\"");
3348 pp_string (buffer
, "\\'");
3351 /* No need to handle \0; the loop terminates on \0. */
3354 pp_string (buffer
, "\\1");
3358 pp_string (buffer
, "\\2");
3362 pp_string (buffer
, "\\3");
3366 pp_string (buffer
, "\\4");
3370 pp_string (buffer
, "\\5");
3374 pp_string (buffer
, "\\6");
3378 pp_string (buffer
, "\\7");
3382 pp_character (buffer
, str
[0]);
3390 maybe_init_pretty_print (FILE *file
)
3394 new (&buffer
) pretty_printer ();
3395 pp_needs_newline (&buffer
) = true;
3396 pp_translate_identifiers (&buffer
) = false;
3400 buffer
.buffer
->stream
= file
;
3404 newline_and_indent (pretty_printer
*buffer
, int spc
)
3406 pp_newline (buffer
);
3410 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3411 it can also be used in front ends.
3412 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3416 percent_K_format (text_info
*text
)
3418 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
3419 gcc_assert (text
->locus
!= NULL
);
3420 *text
->locus
= EXPR_LOCATION (t
);
3421 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
3422 block
= TREE_BLOCK (t
);
3423 *pp_ti_abstract_origin (text
) = NULL
;
3427 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3428 representing the outermost block of an inlined function.
3429 So walk the BLOCK tree until we hit such a scope. */
3431 && TREE_CODE (block
) == BLOCK
)
3433 if (inlined_function_outer_scope_p (block
))
3435 *pp_ti_abstract_origin (text
) = block
;
3438 block
= BLOCK_SUPERCONTEXT (block
);
3444 && TREE_CODE (block
) == BLOCK
3445 && BLOCK_ABSTRACT_ORIGIN (block
))
3447 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
3449 while (TREE_CODE (ao
) == BLOCK
3450 && BLOCK_ABSTRACT_ORIGIN (ao
)
3451 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
3452 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
3454 if (TREE_CODE (ao
) == FUNCTION_DECL
)
3456 *pp_ti_abstract_origin (text
) = block
;
3459 block
= BLOCK_SUPERCONTEXT (block
);
3463 /* Print the identifier ID to PRETTY-PRINTER. */
3466 pp_tree_identifier (pretty_printer
*pp
, tree id
)
3468 if (pp_translate_identifiers (pp
))
3470 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
3471 pp_append_text (pp
, text
, text
+ strlen (text
));
3474 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
3475 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));
3478 /* A helper function that is used to dump function information before the
3482 dump_function_header (FILE *dump_file
, tree fdecl
, int flags
)
3484 const char *dname
, *aname
;
3485 struct cgraph_node
*node
= cgraph_node::get (fdecl
);
3486 struct function
*fun
= DECL_STRUCT_FUNCTION (fdecl
);
3488 dname
= lang_hooks
.decl_printable_name (fdecl
, 2);
3490 if (DECL_ASSEMBLER_NAME_SET_P (fdecl
))
3491 aname
= (IDENTIFIER_POINTER
3492 (DECL_ASSEMBLER_NAME (fdecl
)));
3494 aname
= "<unset-asm-name>";
3496 fprintf (dump_file
, "\n;; Function %s (%s, funcdef_no=%d",
3497 dname
, aname
, fun
->funcdef_no
);
3498 if (!(flags
& TDF_NOUID
))
3499 fprintf (dump_file
, ", decl_uid=%d", DECL_UID (fdecl
));
3502 fprintf (dump_file
, ", cgraph_uid=%d", node
->uid
);
3503 fprintf (dump_file
, ", symbol_order=%d)%s\n\n", node
->order
,
3504 node
->frequency
== NODE_FREQUENCY_HOT
3506 : node
->frequency
== NODE_FREQUENCY_UNLIKELY_EXECUTED
3507 ? " (unlikely executed)"
3508 : node
->frequency
== NODE_FREQUENCY_EXECUTED_ONCE
3509 ? " (executed once)"
3513 fprintf (dump_file
, ")\n\n");
3516 /* Dump double_int D to pretty_printer PP. UNS is true
3517 if D is unsigned and false otherwise. */
3519 pp_double_int (pretty_printer
*pp
, double_int d
, bool uns
)
3522 pp_wide_integer (pp
, d
.low
);
3523 else if (d
.fits_uhwi ())
3524 pp_unsigned_wide_integer (pp
, d
.low
);
3527 unsigned HOST_WIDE_INT low
= d
.low
;
3528 HOST_WIDE_INT high
= d
.high
;
3529 if (!uns
&& d
.is_negative ())
3532 high
= ~high
+ !low
;
3535 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3537 sprintf (pp_buffer (pp
)->digit_buffer
,
3538 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
3539 (unsigned HOST_WIDE_INT
) high
, low
);
3540 pp_string (pp
, pp_buffer (pp
)->digit_buffer
);