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 (TREE_CODE (node
) == NOP_EXPR
)
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
,
899 case FIXED_POINT_TYPE
:
905 unsigned int quals
= TYPE_QUALS (node
);
906 enum tree_code_class tclass
;
908 if (quals
& TYPE_QUAL_ATOMIC
)
909 pp_string (buffer
, "atomic ");
910 if (quals
& TYPE_QUAL_CONST
)
911 pp_string (buffer
, "const ");
912 else if (quals
& TYPE_QUAL_VOLATILE
)
913 pp_string (buffer
, "volatile ");
914 else if (quals
& TYPE_QUAL_RESTRICT
)
915 pp_string (buffer
, "restrict ");
917 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
919 pp_string (buffer
, "<address-space-");
920 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
921 pp_string (buffer
, "> ");
924 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
926 if (tclass
== tcc_declaration
)
928 if (DECL_NAME (node
))
929 dump_decl_name (buffer
, node
, flags
);
931 pp_string (buffer
, "<unnamed type decl>");
933 else if (tclass
== tcc_type
)
935 if (TYPE_NAME (node
))
937 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
938 pp_tree_identifier (buffer
, TYPE_NAME (node
));
939 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
940 && DECL_NAME (TYPE_NAME (node
)))
941 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
943 pp_string (buffer
, "<unnamed type>");
945 else if (TREE_CODE (node
) == VECTOR_TYPE
)
947 pp_string (buffer
, "vector");
948 pp_left_paren (buffer
);
949 pp_wide_integer (buffer
, TYPE_VECTOR_SUBPARTS (node
));
950 pp_string (buffer
, ") ");
951 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
953 else if (TREE_CODE (node
) == INTEGER_TYPE
)
955 if (TYPE_PRECISION (node
) == CHAR_TYPE_SIZE
)
956 pp_string (buffer
, (TYPE_UNSIGNED (node
)
959 else if (TYPE_PRECISION (node
) == SHORT_TYPE_SIZE
)
960 pp_string (buffer
, (TYPE_UNSIGNED (node
)
963 else if (TYPE_PRECISION (node
) == INT_TYPE_SIZE
)
964 pp_string (buffer
, (TYPE_UNSIGNED (node
)
967 else if (TYPE_PRECISION (node
) == LONG_TYPE_SIZE
)
968 pp_string (buffer
, (TYPE_UNSIGNED (node
)
971 else if (TYPE_PRECISION (node
) == LONG_LONG_TYPE_SIZE
)
972 pp_string (buffer
, (TYPE_UNSIGNED (node
)
973 ? "unsigned long long"
974 : "signed long long"));
975 else if (TYPE_PRECISION (node
) >= CHAR_TYPE_SIZE
976 && exact_log2 (TYPE_PRECISION (node
)) != -1)
978 pp_string (buffer
, (TYPE_UNSIGNED (node
) ? "uint" : "int"));
979 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
980 pp_string (buffer
, "_t");
984 pp_string (buffer
, (TYPE_UNSIGNED (node
)
985 ? "<unnamed-unsigned:"
986 : "<unnamed-signed:"));
987 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
991 else if (TREE_CODE (node
) == COMPLEX_TYPE
)
993 pp_string (buffer
, "__complex__ ");
994 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
996 else if (TREE_CODE (node
) == REAL_TYPE
)
998 pp_string (buffer
, "<float:");
999 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
1000 pp_greater (buffer
);
1002 else if (TREE_CODE (node
) == FIXED_POINT_TYPE
)
1004 pp_string (buffer
, "<fixed-point-");
1005 pp_string (buffer
, TYPE_SATURATING (node
) ? "sat:" : "nonsat:");
1006 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
1007 pp_greater (buffer
);
1009 else if (TREE_CODE (node
) == VOID_TYPE
)
1010 pp_string (buffer
, "void");
1012 pp_string (buffer
, "<unnamed type>");
1018 case REFERENCE_TYPE
:
1019 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
1021 if (TREE_TYPE (node
) == NULL
)
1023 pp_string (buffer
, str
);
1024 pp_string (buffer
, "<null type>");
1026 else if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
1028 tree fnode
= TREE_TYPE (node
);
1030 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
1032 pp_left_paren (buffer
);
1033 pp_string (buffer
, str
);
1034 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1035 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1036 else if (flags
& TDF_NOUID
)
1037 pp_printf (buffer
, "<Txxxx>");
1039 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1041 pp_right_paren (buffer
);
1042 dump_function_declaration (buffer
, fnode
, spc
, flags
);
1046 unsigned int quals
= TYPE_QUALS (node
);
1048 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1050 pp_string (buffer
, str
);
1052 if (quals
& TYPE_QUAL_CONST
)
1053 pp_string (buffer
, " const");
1054 if (quals
& TYPE_QUAL_VOLATILE
)
1055 pp_string (buffer
, " volatile");
1056 if (quals
& TYPE_QUAL_RESTRICT
)
1057 pp_string (buffer
, " restrict");
1059 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
1061 pp_string (buffer
, " <address-space-");
1062 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
1063 pp_greater (buffer
);
1066 if (TYPE_REF_CAN_ALIAS_ALL (node
))
1067 pp_string (buffer
, " {ref-all}");
1077 if (integer_zerop (TREE_OPERAND (node
, 1))
1078 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1079 infer them and MEM_ATTR caching will share MEM_REFs
1080 with differently-typed op0s. */
1081 && TREE_CODE (TREE_OPERAND (node
, 0)) != INTEGER_CST
1082 /* Released SSA_NAMES have no TREE_TYPE. */
1083 && TREE_TYPE (TREE_OPERAND (node
, 0)) != NULL_TREE
1084 /* Same pointer types, but ignoring POINTER_TYPE vs.
1086 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 0)))
1087 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))
1088 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 0)))
1089 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 1))))
1090 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 0)))
1091 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 1))))
1092 /* Same value types ignoring qualifiers. */
1093 && (TYPE_MAIN_VARIANT (TREE_TYPE (node
))
1094 == TYPE_MAIN_VARIANT
1095 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))))
1097 if (TREE_CODE (TREE_OPERAND (node
, 0)) != ADDR_EXPR
)
1100 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1104 dump_generic_node (buffer
,
1105 TREE_OPERAND (TREE_OPERAND (node
, 0), 0),
1112 pp_string (buffer
, "MEM[");
1113 pp_left_paren (buffer
);
1114 ptype
= TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node
, 1)));
1115 dump_generic_node (buffer
, ptype
,
1116 spc
, flags
| TDF_SLIM
, false);
1117 pp_right_paren (buffer
);
1118 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1120 if (!integer_zerop (TREE_OPERAND (node
, 1)))
1122 pp_string (buffer
, " + ");
1123 dump_generic_node (buffer
, TREE_OPERAND (node
, 1),
1126 pp_right_bracket (buffer
);
1131 case TARGET_MEM_REF
:
1133 const char *sep
= "";
1136 pp_string (buffer
, "MEM[");
1138 if (TREE_CODE (TMR_BASE (node
)) == ADDR_EXPR
)
1140 pp_string (buffer
, sep
);
1142 pp_string (buffer
, "symbol: ");
1143 dump_generic_node (buffer
, TREE_OPERAND (TMR_BASE (node
), 0),
1148 pp_string (buffer
, sep
);
1150 pp_string (buffer
, "base: ");
1151 dump_generic_node (buffer
, TMR_BASE (node
), spc
, flags
, false);
1153 tmp
= TMR_INDEX2 (node
);
1156 pp_string (buffer
, sep
);
1158 pp_string (buffer
, "base: ");
1159 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1161 tmp
= TMR_INDEX (node
);
1164 pp_string (buffer
, sep
);
1166 pp_string (buffer
, "index: ");
1167 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1169 tmp
= TMR_STEP (node
);
1172 pp_string (buffer
, sep
);
1174 pp_string (buffer
, "step: ");
1175 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1177 tmp
= TMR_OFFSET (node
);
1180 pp_string (buffer
, sep
);
1182 pp_string (buffer
, "offset: ");
1183 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1185 pp_right_bracket (buffer
);
1193 /* Print the innermost component type. */
1194 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
1195 tmp
= TREE_TYPE (tmp
))
1197 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1199 /* Print the dimensions. */
1200 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
1201 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
1207 case QUAL_UNION_TYPE
:
1209 unsigned int quals
= TYPE_QUALS (node
);
1211 if (quals
& TYPE_QUAL_ATOMIC
)
1212 pp_string (buffer
, "atomic ");
1213 if (quals
& TYPE_QUAL_CONST
)
1214 pp_string (buffer
, "const ");
1215 if (quals
& TYPE_QUAL_VOLATILE
)
1216 pp_string (buffer
, "volatile ");
1218 /* Print the name of the structure. */
1219 if (TREE_CODE (node
) == RECORD_TYPE
)
1220 pp_string (buffer
, "struct ");
1221 else if (TREE_CODE (node
) == UNION_TYPE
)
1222 pp_string (buffer
, "union ");
1224 if (TYPE_NAME (node
))
1225 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
1226 else if (!(flags
& TDF_SLIM
))
1227 /* FIXME: If we eliminate the 'else' above and attempt
1228 to show the fields for named types, we may get stuck
1229 following a cycle of pointers to structs. The alleged
1230 self-reference check in print_struct_decl will not detect
1231 cycles involving more than one pointer or struct type. */
1232 print_struct_decl (buffer
, node
, spc
, flags
);
1241 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
1243 /* In the case of a pointer, one may want to divide by the
1244 size of the pointed-to type. Unfortunately, this not
1245 straightforward. The C front-end maps expressions
1250 in such a way that the two INTEGER_CST nodes for "5" have
1251 different values but identical types. In the latter
1252 case, the 5 is multiplied by sizeof (int) in c-common.c
1253 (pointer_int_sum) to convert it to a byte address, and
1254 yet the type of the node is left unchanged. Argh. What
1255 is consistent though is that the number value corresponds
1256 to bytes (UNITS) offset.
1258 NB: Neither of the following divisors can be trivially
1259 used to recover the original literal:
1261 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1262 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1263 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1264 pp_string (buffer
, "B"); /* pseudo-unit */
1266 else if (tree_fits_shwi_p (node
))
1267 pp_wide_integer (buffer
, tree_to_shwi (node
));
1268 else if (tree_fits_uhwi_p (node
))
1269 pp_unsigned_wide_integer (buffer
, tree_to_uhwi (node
));
1272 wide_int val
= node
;
1274 if (wi::neg_p (val
, TYPE_SIGN (TREE_TYPE (node
))))
1279 print_hex (val
, pp_buffer (buffer
)->digit_buffer
);
1280 pp_string (buffer
, pp_buffer (buffer
)->digit_buffer
);
1282 if (TREE_OVERFLOW (node
))
1283 pp_string (buffer
, "(OVF)");
1287 /* Code copied from print_node. */
1290 if (TREE_OVERFLOW (node
))
1291 pp_string (buffer
, " overflow");
1293 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1294 d
= TREE_REAL_CST (node
);
1295 if (REAL_VALUE_ISINF (d
))
1296 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
1297 else if (REAL_VALUE_ISNAN (d
))
1298 pp_string (buffer
, " Nan");
1302 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
1303 pp_string (buffer
, string
);
1308 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
1309 pp_string (buffer
, "0x");
1310 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
1311 output_formatted_integer (buffer
, "%02x", *p
++);
1320 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
1321 pp_string (buffer
, string
);
1326 pp_string (buffer
, "__complex__ (");
1327 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
1328 pp_string (buffer
, ", ");
1329 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
1330 pp_right_paren (buffer
);
1334 pp_string (buffer
, "\"");
1335 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
1336 pp_string (buffer
, "\"");
1342 pp_string (buffer
, "{ ");
1343 for (i
= 0; i
< VECTOR_CST_NELTS (node
); ++i
)
1346 pp_string (buffer
, ", ");
1347 dump_generic_node (buffer
, VECTOR_CST_ELT (node
, i
),
1350 pp_string (buffer
, " }");
1356 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1358 if (TREE_CODE (node
) == METHOD_TYPE
)
1360 if (TYPE_METHOD_BASETYPE (node
))
1361 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
1364 pp_string (buffer
, "<null method basetype>");
1365 pp_colon_colon (buffer
);
1367 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1368 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1369 else if (flags
& TDF_NOUID
)
1370 pp_printf (buffer
, "<Txxxx>");
1372 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1373 dump_function_declaration (buffer
, node
, spc
, flags
);
1378 dump_decl_name (buffer
, node
, flags
);
1382 if (DECL_NAME (node
))
1383 dump_decl_name (buffer
, node
, flags
);
1384 else if (LABEL_DECL_UID (node
) != -1)
1385 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1388 if (flags
& TDF_NOUID
)
1389 pp_string (buffer
, "<D.xxxx>");
1391 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1396 if (DECL_IS_BUILTIN (node
))
1398 /* Don't print the declaration of built-in types. */
1401 if (DECL_NAME (node
))
1402 dump_decl_name (buffer
, node
, flags
);
1403 else if (TYPE_NAME (TREE_TYPE (node
)) != node
)
1405 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1406 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1407 && TYPE_METHODS (TREE_TYPE (node
)))
1409 /* The type is a c++ class: all structures have at least
1411 pp_string (buffer
, "class ");
1412 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1417 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1418 ? "union" : "struct "));
1419 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1423 pp_string (buffer
, "<anon>");
1429 case DEBUG_EXPR_DECL
:
1430 case NAMESPACE_DECL
:
1432 dump_decl_name (buffer
, node
, flags
);
1436 pp_string (buffer
, "<retval>");
1440 op0
= TREE_OPERAND (node
, 0);
1443 && (TREE_CODE (op0
) == INDIRECT_REF
1444 || (TREE_CODE (op0
) == MEM_REF
1445 && TREE_CODE (TREE_OPERAND (op0
, 0)) != ADDR_EXPR
1446 && integer_zerop (TREE_OPERAND (op0
, 1))
1447 /* Dump the types of INTEGER_CSTs explicitly, for we
1448 can't infer them and MEM_ATTR caching will share
1449 MEM_REFs with differently-typed op0s. */
1450 && TREE_CODE (TREE_OPERAND (op0
, 0)) != INTEGER_CST
1451 /* Released SSA_NAMES have no TREE_TYPE. */
1452 && TREE_TYPE (TREE_OPERAND (op0
, 0)) != NULL_TREE
1453 /* Same pointer types, but ignoring POINTER_TYPE vs.
1455 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1456 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1457 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1458 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1459 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1460 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1461 /* Same value types ignoring qualifiers. */
1462 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0
))
1463 == TYPE_MAIN_VARIANT
1464 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))))))
1466 op0
= TREE_OPERAND (op0
, 0);
1469 if (op_prio (op0
) < op_prio (node
))
1470 pp_left_paren (buffer
);
1471 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1472 if (op_prio (op0
) < op_prio (node
))
1473 pp_right_paren (buffer
);
1474 pp_string (buffer
, str
);
1475 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1476 op0
= component_ref_field_offset (node
);
1477 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1479 pp_string (buffer
, "{off: ");
1480 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1481 pp_right_brace (buffer
);
1486 pp_string (buffer
, "BIT_FIELD_REF <");
1487 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1488 pp_string (buffer
, ", ");
1489 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1490 pp_string (buffer
, ", ");
1491 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1492 pp_greater (buffer
);
1496 case ARRAY_RANGE_REF
:
1497 op0
= TREE_OPERAND (node
, 0);
1498 if (op_prio (op0
) < op_prio (node
))
1499 pp_left_paren (buffer
);
1500 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1501 if (op_prio (op0
) < op_prio (node
))
1502 pp_right_paren (buffer
);
1503 pp_left_bracket (buffer
);
1504 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1505 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1506 pp_string (buffer
, " ...");
1507 pp_right_bracket (buffer
);
1509 op0
= array_ref_low_bound (node
);
1510 op1
= array_ref_element_size (node
);
1512 if (!integer_zerop (op0
)
1513 || TREE_OPERAND (node
, 2)
1514 || TREE_OPERAND (node
, 3))
1516 pp_string (buffer
, "{lb: ");
1517 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1518 pp_string (buffer
, " sz: ");
1519 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1520 pp_right_brace (buffer
);
1526 unsigned HOST_WIDE_INT ix
;
1528 bool is_struct_init
= false;
1529 bool is_array_init
= false;
1531 pp_left_brace (buffer
);
1532 if (TREE_CLOBBER_P (node
))
1533 pp_string (buffer
, "CLOBBER");
1534 else if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1535 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1536 is_struct_init
= true;
1537 else if (TREE_CODE (TREE_TYPE (node
)) == ARRAY_TYPE
1538 && TYPE_DOMAIN (TREE_TYPE (node
))
1539 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)))
1540 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
))))
1543 tree minv
= TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)));
1544 is_array_init
= true;
1545 curidx
= wi::to_widest (minv
);
1547 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1554 dump_generic_node (buffer
, field
, spc
, flags
, false);
1557 else if (is_array_init
1558 && (TREE_CODE (field
) != INTEGER_CST
1559 || curidx
!= wi::to_widest (field
)))
1561 pp_left_bracket (buffer
);
1562 if (TREE_CODE (field
) == RANGE_EXPR
)
1564 dump_generic_node (buffer
, TREE_OPERAND (field
, 0), spc
,
1566 pp_string (buffer
, " ... ");
1567 dump_generic_node (buffer
, TREE_OPERAND (field
, 1), spc
,
1569 if (TREE_CODE (TREE_OPERAND (field
, 1)) == INTEGER_CST
)
1570 curidx
= wi::to_widest (TREE_OPERAND (field
, 1));
1573 dump_generic_node (buffer
, field
, spc
, flags
, false);
1574 if (TREE_CODE (field
) == INTEGER_CST
)
1575 curidx
= wi::to_widest (field
);
1576 pp_string (buffer
, "]=");
1581 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1582 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1583 val
= TREE_OPERAND (val
, 0);
1584 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1585 dump_decl_name (buffer
, val
, flags
);
1587 dump_generic_node (buffer
, val
, spc
, flags
, false);
1588 if (ix
!= vec_safe_length (CONSTRUCTOR_ELTS (node
)) - 1)
1594 pp_right_brace (buffer
);
1601 if (flags
& TDF_SLIM
)
1603 pp_string (buffer
, "<COMPOUND_EXPR>");
1607 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1608 spc
, flags
, !(flags
& TDF_SLIM
));
1609 if (flags
& TDF_SLIM
)
1610 newline_and_indent (buffer
, spc
);
1617 for (tp
= &TREE_OPERAND (node
, 1);
1618 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1619 tp
= &TREE_OPERAND (*tp
, 1))
1621 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1622 spc
, flags
, !(flags
& TDF_SLIM
));
1623 if (flags
& TDF_SLIM
)
1624 newline_and_indent (buffer
, spc
);
1632 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1636 case STATEMENT_LIST
:
1638 tree_stmt_iterator si
;
1641 if (flags
& TDF_SLIM
)
1643 pp_string (buffer
, "<STATEMENT_LIST>");
1647 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1650 newline_and_indent (buffer
, spc
);
1653 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1660 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1665 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1670 pp_string (buffer
, "TARGET_EXPR <");
1671 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1674 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1675 pp_greater (buffer
);
1679 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1684 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1686 pp_string (buffer
, "if (");
1687 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1688 pp_right_paren (buffer
);
1689 /* The lowered cond_exprs should always be printed in full. */
1690 if (COND_EXPR_THEN (node
)
1691 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1692 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1693 && COND_EXPR_ELSE (node
)
1694 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1695 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1698 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1700 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1702 pp_string (buffer
, " else ");
1703 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1707 else if (!(flags
& TDF_SLIM
))
1709 /* Output COND_EXPR_THEN. */
1710 if (COND_EXPR_THEN (node
))
1712 newline_and_indent (buffer
, spc
+2);
1713 pp_left_brace (buffer
);
1714 newline_and_indent (buffer
, spc
+4);
1715 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1717 newline_and_indent (buffer
, spc
+2);
1718 pp_right_brace (buffer
);
1721 /* Output COND_EXPR_ELSE. */
1722 if (COND_EXPR_ELSE (node
)
1723 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1725 newline_and_indent (buffer
, spc
);
1726 pp_string (buffer
, "else");
1727 newline_and_indent (buffer
, spc
+2);
1728 pp_left_brace (buffer
);
1729 newline_and_indent (buffer
, spc
+4);
1730 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1732 newline_and_indent (buffer
, spc
+2);
1733 pp_right_brace (buffer
);
1740 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1742 pp_question (buffer
);
1744 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1748 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1753 pp_left_brace (buffer
);
1754 if (!(flags
& TDF_SLIM
))
1756 if (BIND_EXPR_VARS (node
))
1758 pp_newline (buffer
);
1760 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= DECL_CHAIN (op0
))
1762 print_declaration (buffer
, op0
, spc
+2, flags
);
1763 pp_newline (buffer
);
1767 newline_and_indent (buffer
, spc
+2);
1768 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1769 newline_and_indent (buffer
, spc
);
1770 pp_right_brace (buffer
);
1776 if (CALL_EXPR_FN (node
) != NULL_TREE
)
1777 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1779 pp_string (buffer
, internal_fn_name (CALL_EXPR_IFN (node
)));
1781 /* Print parameters. */
1783 pp_left_paren (buffer
);
1786 call_expr_arg_iterator iter
;
1787 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1789 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1790 if (more_call_expr_args_p (&iter
))
1797 if (CALL_EXPR_VA_ARG_PACK (node
))
1799 if (call_expr_nargs (node
) > 0)
1804 pp_string (buffer
, "__builtin_va_arg_pack ()");
1806 pp_right_paren (buffer
);
1808 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1811 pp_string (buffer
, " [static-chain: ");
1812 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1813 pp_right_bracket (buffer
);
1816 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1817 pp_string (buffer
, " [return slot optimization]");
1818 if (CALL_EXPR_TAILCALL (node
))
1819 pp_string (buffer
, " [tail call]");
1822 case WITH_CLEANUP_EXPR
:
1826 case CLEANUP_POINT_EXPR
:
1827 pp_string (buffer
, "<<cleanup_point ");
1828 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1829 pp_string (buffer
, ">>");
1832 case PLACEHOLDER_EXPR
:
1833 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1834 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1835 pp_greater (buffer
);
1838 /* Binary arithmetic and logic expressions. */
1839 case WIDEN_SUM_EXPR
:
1840 case WIDEN_MULT_EXPR
:
1842 case MULT_HIGHPART_EXPR
:
1844 case POINTER_PLUS_EXPR
:
1846 case TRUNC_DIV_EXPR
:
1848 case FLOOR_DIV_EXPR
:
1849 case ROUND_DIV_EXPR
:
1850 case TRUNC_MOD_EXPR
:
1852 case FLOOR_MOD_EXPR
:
1853 case ROUND_MOD_EXPR
:
1855 case EXACT_DIV_EXPR
:
1860 case VEC_RSHIFT_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_RSHIFT_EXPR
:
3041 case VEC_UNPACK_HI_EXPR
:
3042 case VEC_UNPACK_LO_EXPR
:
3043 case VEC_UNPACK_FLOAT_HI_EXPR
:
3044 case VEC_UNPACK_FLOAT_LO_EXPR
:
3045 case VEC_PACK_TRUNC_EXPR
:
3046 case VEC_PACK_SAT_EXPR
:
3050 /* Return an arbitrarily high precedence to avoid surrounding single
3051 VAR_DECLs in ()s. */
3056 /* Return the priority of the operator OP. */
3059 op_prio (const_tree op
)
3061 enum tree_code code
;
3066 code
= TREE_CODE (op
);
3067 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
3068 return op_prio (TREE_OPERAND (op
, 0));
3070 return op_code_prio (code
);
3073 /* Return the symbol associated with operator CODE. */
3076 op_symbol_code (enum tree_code code
)
3084 case TRUTH_ORIF_EXPR
:
3087 case TRUTH_AND_EXPR
:
3088 case TRUTH_ANDIF_EXPR
:
3094 case TRUTH_XOR_EXPR
:
3104 case UNORDERED_EXPR
:
3150 case VEC_RSHIFT_EXPR
:
3153 case WIDEN_LSHIFT_EXPR
:
3156 case POINTER_PLUS_EXPR
:
3162 case REDUC_PLUS_EXPR
:
3165 case WIDEN_SUM_EXPR
:
3168 case WIDEN_MULT_EXPR
:
3171 case MULT_HIGHPART_EXPR
:
3181 case TRUTH_NOT_EXPR
:
3188 case TRUNC_DIV_EXPR
:
3195 case FLOOR_DIV_EXPR
:
3198 case ROUND_DIV_EXPR
:
3201 case EXACT_DIV_EXPR
:
3204 case TRUNC_MOD_EXPR
:
3210 case FLOOR_MOD_EXPR
:
3213 case ROUND_MOD_EXPR
:
3216 case PREDECREMENT_EXPR
:
3219 case PREINCREMENT_EXPR
:
3222 case POSTDECREMENT_EXPR
:
3225 case POSTINCREMENT_EXPR
:
3235 return "<<< ??? >>>";
3239 /* Return the symbol associated with operator OP. */
3242 op_symbol (const_tree op
)
3244 return op_symbol_code (TREE_CODE (op
));
3247 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3248 the gimple_call_fn of a GIMPLE_CALL. */
3251 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
3255 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
3256 op0
= TREE_OPERAND (op0
, 0);
3259 switch (TREE_CODE (op0
))
3264 dump_function_name (buffer
, op0
, flags
);
3270 op0
= TREE_OPERAND (op0
, 0);
3274 pp_left_paren (buffer
);
3275 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
3276 pp_string (buffer
, ") ? ");
3277 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
3278 pp_string (buffer
, " : ");
3279 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
3283 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
3284 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
3286 dump_generic_node (buffer
, op0
, 0, flags
, false);
3290 if (integer_zerop (TREE_OPERAND (op0
, 1)))
3292 op0
= TREE_OPERAND (op0
, 0);
3299 dump_generic_node (buffer
, op0
, 0, flags
, false);
3307 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3310 pretty_print_string (pretty_printer
*buffer
, const char *str
)
3320 pp_string (buffer
, "\\b");
3324 pp_string (buffer
, "\\f");
3328 pp_string (buffer
, "\\n");
3332 pp_string (buffer
, "\\r");
3336 pp_string (buffer
, "\\t");
3340 pp_string (buffer
, "\\v");
3344 pp_string (buffer
, "\\\\");
3348 pp_string (buffer
, "\\\"");
3352 pp_string (buffer
, "\\'");
3355 /* No need to handle \0; the loop terminates on \0. */
3358 pp_string (buffer
, "\\1");
3362 pp_string (buffer
, "\\2");
3366 pp_string (buffer
, "\\3");
3370 pp_string (buffer
, "\\4");
3374 pp_string (buffer
, "\\5");
3378 pp_string (buffer
, "\\6");
3382 pp_string (buffer
, "\\7");
3386 pp_character (buffer
, str
[0]);
3394 maybe_init_pretty_print (FILE *file
)
3398 new (&buffer
) pretty_printer ();
3399 pp_needs_newline (&buffer
) = true;
3400 pp_translate_identifiers (&buffer
) = false;
3404 buffer
.buffer
->stream
= file
;
3408 newline_and_indent (pretty_printer
*buffer
, int spc
)
3410 pp_newline (buffer
);
3414 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3415 it can also be used in front ends.
3416 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3420 percent_K_format (text_info
*text
)
3422 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
3423 gcc_assert (text
->locus
!= NULL
);
3424 *text
->locus
= EXPR_LOCATION (t
);
3425 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
3426 block
= TREE_BLOCK (t
);
3427 *pp_ti_abstract_origin (text
) = NULL
;
3431 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3432 representing the outermost block of an inlined function.
3433 So walk the BLOCK tree until we hit such a scope. */
3435 && TREE_CODE (block
) == BLOCK
)
3437 if (inlined_function_outer_scope_p (block
))
3439 *pp_ti_abstract_origin (text
) = block
;
3442 block
= BLOCK_SUPERCONTEXT (block
);
3448 && TREE_CODE (block
) == BLOCK
3449 && BLOCK_ABSTRACT_ORIGIN (block
))
3451 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
3453 while (TREE_CODE (ao
) == BLOCK
3454 && BLOCK_ABSTRACT_ORIGIN (ao
)
3455 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
3456 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
3458 if (TREE_CODE (ao
) == FUNCTION_DECL
)
3460 *pp_ti_abstract_origin (text
) = block
;
3463 block
= BLOCK_SUPERCONTEXT (block
);
3467 /* Print the identifier ID to PRETTY-PRINTER. */
3470 pp_tree_identifier (pretty_printer
*pp
, tree id
)
3472 if (pp_translate_identifiers (pp
))
3474 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
3475 pp_append_text (pp
, text
, text
+ strlen (text
));
3478 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
3479 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));
3482 /* A helper function that is used to dump function information before the
3486 dump_function_header (FILE *dump_file
, tree fdecl
, int flags
)
3488 const char *dname
, *aname
;
3489 struct cgraph_node
*node
= cgraph_node::get (fdecl
);
3490 struct function
*fun
= DECL_STRUCT_FUNCTION (fdecl
);
3492 dname
= lang_hooks
.decl_printable_name (fdecl
, 2);
3494 if (DECL_ASSEMBLER_NAME_SET_P (fdecl
))
3495 aname
= (IDENTIFIER_POINTER
3496 (DECL_ASSEMBLER_NAME (fdecl
)));
3498 aname
= "<unset-asm-name>";
3500 fprintf (dump_file
, "\n;; Function %s (%s, funcdef_no=%d",
3501 dname
, aname
, fun
->funcdef_no
);
3502 if (!(flags
& TDF_NOUID
))
3503 fprintf (dump_file
, ", decl_uid=%d", DECL_UID (fdecl
));
3506 fprintf (dump_file
, ", cgraph_uid=%d", node
->uid
);
3507 fprintf (dump_file
, ", symbol_order=%d)%s\n\n", node
->order
,
3508 node
->frequency
== NODE_FREQUENCY_HOT
3510 : node
->frequency
== NODE_FREQUENCY_UNLIKELY_EXECUTED
3511 ? " (unlikely executed)"
3512 : node
->frequency
== NODE_FREQUENCY_EXECUTED_ONCE
3513 ? " (executed once)"
3517 fprintf (dump_file
, ")\n\n");
3520 /* Dump double_int D to pretty_printer PP. UNS is true
3521 if D is unsigned and false otherwise. */
3523 pp_double_int (pretty_printer
*pp
, double_int d
, bool uns
)
3526 pp_wide_integer (pp
, d
.low
);
3527 else if (d
.fits_uhwi ())
3528 pp_unsigned_wide_integer (pp
, d
.low
);
3531 unsigned HOST_WIDE_INT low
= d
.low
;
3532 HOST_WIDE_INT high
= d
.high
;
3533 if (!uns
&& d
.is_negative ())
3536 high
= ~high
+ !low
;
3539 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3541 sprintf (pp_buffer (pp
)->digit_buffer
,
3542 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
3543 (unsigned HOST_WIDE_INT
) high
, low
);
3544 pp_string (pp
, pp_buffer (pp
)->digit_buffer
);