1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2014 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
26 #include "stor-layout.h"
28 #include "tree-pretty-print.h"
30 #include "pointer-set.h"
31 #include "gimple-expr.h"
33 #include "langhooks.h"
34 #include "tree-iterator.h"
35 #include "tree-chrec.h"
37 #include "value-prof.h"
40 #include <new> // For placement-new.
42 /* Local functions, macros and variables. */
43 static const char *op_symbol (const_tree
);
44 static void pretty_print_string (pretty_printer
*, const char*);
45 static void newline_and_indent (pretty_printer
*, int);
46 static void maybe_init_pretty_print (FILE *);
47 static void print_struct_decl (pretty_printer
*, const_tree
, int, int);
48 static void do_niy (pretty_printer
*, const_tree
);
50 #define INDENT(SPACE) do { \
51 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
53 #define NIY do_niy (buffer, node)
55 static pretty_printer buffer
;
56 static int initialized
= 0;
58 /* Try to print something for an unknown tree code. */
61 do_niy (pretty_printer
*buffer
, const_tree node
)
65 pp_string (buffer
, "<<< Unknown tree: ");
66 pp_string (buffer
, get_tree_code_name (TREE_CODE (node
)));
70 len
= TREE_OPERAND_LENGTH (node
);
71 for (i
= 0; i
< len
; ++i
)
73 newline_and_indent (buffer
, 2);
74 dump_generic_node (buffer
, TREE_OPERAND (node
, i
), 2, 0, false);
78 pp_string (buffer
, " >>>");
81 /* Debugging function to print out a generic expression. */
84 debug_generic_expr (tree t
)
86 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
87 fprintf (stderr
, "\n");
90 /* Debugging function to print out a generic statement. */
93 debug_generic_stmt (tree t
)
95 print_generic_stmt (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
);
96 fprintf (stderr
, "\n");
99 /* Debugging function to print out a chain of trees . */
102 debug_tree_chain (tree t
)
104 struct pointer_set_t
*seen
= pointer_set_create ();
108 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
109 fprintf (stderr
, " ");
111 if (pointer_set_insert (seen
, t
))
113 fprintf (stderr
, "... [cycled back to ");
114 print_generic_expr (stderr
, t
, TDF_VOPS
|TDF_MEMSYMS
|TDF_UID
);
115 fprintf (stderr
, "]");
119 fprintf (stderr
, "\n");
121 pointer_set_destroy (seen
);
124 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
126 print_generic_decl (FILE *file
, tree decl
, int flags
)
128 maybe_init_pretty_print (file
);
129 print_declaration (&buffer
, decl
, 2, flags
);
130 pp_write_text_to_stream (&buffer
);
133 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
134 to show in the dump. See TDF_* in dumpfile.h. */
137 print_generic_stmt (FILE *file
, tree t
, int flags
)
139 maybe_init_pretty_print (file
);
140 dump_generic_node (&buffer
, t
, 0, flags
, true);
141 pp_newline_and_flush (&buffer
);
144 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
145 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
149 print_generic_stmt_indented (FILE *file
, tree t
, int flags
, int indent
)
153 maybe_init_pretty_print (file
);
155 for (i
= 0; i
< indent
; i
++)
157 dump_generic_node (&buffer
, t
, indent
, flags
, true);
158 pp_newline_and_flush (&buffer
);
161 /* Print a single expression T on file FILE. FLAGS specifies details to show
162 in the dump. See TDF_* in dumpfile.h. */
165 print_generic_expr (FILE *file
, tree t
, int flags
)
167 maybe_init_pretty_print (file
);
168 dump_generic_node (&buffer
, t
, 0, flags
, false);
172 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
176 dump_decl_name (pretty_printer
*buffer
, tree node
, int flags
)
178 if (DECL_NAME (node
))
180 if ((flags
& TDF_ASMNAME
) && DECL_ASSEMBLER_NAME_SET_P (node
))
181 pp_tree_identifier (buffer
, DECL_ASSEMBLER_NAME (node
));
183 pp_tree_identifier (buffer
, DECL_NAME (node
));
185 if ((flags
& TDF_UID
) || DECL_NAME (node
) == NULL_TREE
)
187 if (TREE_CODE (node
) == LABEL_DECL
&& LABEL_DECL_UID (node
) != -1)
188 pp_printf (buffer
, "L.%d", (int) LABEL_DECL_UID (node
));
189 else if (TREE_CODE (node
) == DEBUG_EXPR_DECL
)
191 if (flags
& TDF_NOUID
)
192 pp_string (buffer
, "D#xxxx");
194 pp_printf (buffer
, "D#%i", DEBUG_TEMP_UID (node
));
198 char c
= TREE_CODE (node
) == CONST_DECL
? 'C' : 'D';
199 if (flags
& TDF_NOUID
)
200 pp_printf (buffer
, "%c.xxxx", c
);
202 pp_printf (buffer
, "%c.%u", c
, DECL_UID (node
));
205 if ((flags
& TDF_ALIAS
) && DECL_PT_UID (node
) != DECL_UID (node
))
207 if (flags
& TDF_NOUID
)
208 pp_printf (buffer
, "ptD.xxxx");
210 pp_printf (buffer
, "ptD.%u", DECL_PT_UID (node
));
214 /* Like the above, but used for pretty printing function calls. */
217 dump_function_name (pretty_printer
*buffer
, tree node
, int flags
)
219 if (TREE_CODE (node
) == NOP_EXPR
)
220 node
= TREE_OPERAND (node
, 0);
221 if (DECL_NAME (node
) && (flags
& TDF_ASMNAME
) == 0)
222 pp_string (buffer
, lang_hooks
.decl_printable_name (node
, 1));
224 dump_decl_name (buffer
, node
, flags
);
227 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
228 FLAGS are as in dump_generic_node. */
231 dump_function_declaration (pretty_printer
*buffer
, tree node
,
234 bool wrote_arg
= false;
238 pp_left_paren (buffer
);
240 /* Print the argument types. */
241 arg
= TYPE_ARG_TYPES (node
);
242 while (arg
&& arg
!= void_list_node
&& arg
!= error_mark_node
)
250 dump_generic_node (buffer
, TREE_VALUE (arg
), spc
, flags
, false);
251 arg
= TREE_CHAIN (arg
);
254 /* Drop the trailing void_type_node if we had any previous argument. */
255 if (arg
== void_list_node
&& !wrote_arg
)
256 pp_string (buffer
, "void");
257 /* Properly dump vararg function types. */
258 else if (!arg
&& wrote_arg
)
259 pp_string (buffer
, ", ...");
260 /* Avoid printing any arg for unprototyped functions. */
262 pp_right_paren (buffer
);
265 /* Dump the domain associated with an array. */
268 dump_array_domain (pretty_printer
*buffer
, tree domain
, int spc
, int flags
)
270 pp_left_bracket (buffer
);
273 tree min
= TYPE_MIN_VALUE (domain
);
274 tree max
= TYPE_MAX_VALUE (domain
);
277 && integer_zerop (min
)
278 && tree_fits_shwi_p (max
))
279 pp_wide_integer (buffer
, tree_to_shwi (max
) + 1);
283 dump_generic_node (buffer
, min
, spc
, flags
, false);
286 dump_generic_node (buffer
, max
, spc
, flags
, false);
290 pp_string (buffer
, "<unknown>");
291 pp_right_bracket (buffer
);
295 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
296 dump_generic_node. */
299 dump_omp_clause (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
303 switch (OMP_CLAUSE_CODE (clause
))
305 case OMP_CLAUSE_PRIVATE
:
308 case OMP_CLAUSE_SHARED
:
311 case OMP_CLAUSE_FIRSTPRIVATE
:
312 name
= "firstprivate";
314 case OMP_CLAUSE_LASTPRIVATE
:
315 name
= "lastprivate";
317 case OMP_CLAUSE_COPYIN
:
320 case OMP_CLAUSE_COPYPRIVATE
:
321 name
= "copyprivate";
323 case OMP_CLAUSE_UNIFORM
:
326 case OMP_CLAUSE__LOOPTEMP_
:
330 pp_string (buffer
, name
);
331 pp_left_paren (buffer
);
332 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
334 pp_right_paren (buffer
);
337 case OMP_CLAUSE_REDUCTION
:
338 pp_string (buffer
, "reduction(");
339 if (OMP_CLAUSE_REDUCTION_CODE (clause
) != ERROR_MARK
)
342 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause
)));
345 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
347 pp_right_paren (buffer
);
351 pp_string (buffer
, "if(");
352 dump_generic_node (buffer
, OMP_CLAUSE_IF_EXPR (clause
),
354 pp_right_paren (buffer
);
357 case OMP_CLAUSE_NUM_THREADS
:
358 pp_string (buffer
, "num_threads(");
359 dump_generic_node (buffer
, OMP_CLAUSE_NUM_THREADS_EXPR (clause
),
361 pp_right_paren (buffer
);
364 case OMP_CLAUSE_NOWAIT
:
365 pp_string (buffer
, "nowait");
367 case OMP_CLAUSE_ORDERED
:
368 pp_string (buffer
, "ordered");
371 case OMP_CLAUSE_DEFAULT
:
372 pp_string (buffer
, "default(");
373 switch (OMP_CLAUSE_DEFAULT_KIND (clause
))
375 case OMP_CLAUSE_DEFAULT_UNSPECIFIED
:
377 case OMP_CLAUSE_DEFAULT_SHARED
:
378 pp_string (buffer
, "shared");
380 case OMP_CLAUSE_DEFAULT_NONE
:
381 pp_string (buffer
, "none");
383 case OMP_CLAUSE_DEFAULT_PRIVATE
:
384 pp_string (buffer
, "private");
386 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE
:
387 pp_string (buffer
, "firstprivate");
392 pp_right_paren (buffer
);
395 case OMP_CLAUSE_SCHEDULE
:
396 pp_string (buffer
, "schedule(");
397 switch (OMP_CLAUSE_SCHEDULE_KIND (clause
))
399 case OMP_CLAUSE_SCHEDULE_STATIC
:
400 pp_string (buffer
, "static");
402 case OMP_CLAUSE_SCHEDULE_DYNAMIC
:
403 pp_string (buffer
, "dynamic");
405 case OMP_CLAUSE_SCHEDULE_GUIDED
:
406 pp_string (buffer
, "guided");
408 case OMP_CLAUSE_SCHEDULE_RUNTIME
:
409 pp_string (buffer
, "runtime");
411 case OMP_CLAUSE_SCHEDULE_AUTO
:
412 pp_string (buffer
, "auto");
417 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
))
420 dump_generic_node (buffer
, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause
),
423 pp_right_paren (buffer
);
426 case OMP_CLAUSE_UNTIED
:
427 pp_string (buffer
, "untied");
430 case OMP_CLAUSE_COLLAPSE
:
431 pp_string (buffer
, "collapse(");
432 dump_generic_node (buffer
, OMP_CLAUSE_COLLAPSE_EXPR (clause
),
434 pp_right_paren (buffer
);
437 case OMP_CLAUSE_FINAL
:
438 pp_string (buffer
, "final(");
439 dump_generic_node (buffer
, OMP_CLAUSE_FINAL_EXPR (clause
),
441 pp_right_paren (buffer
);
444 case OMP_CLAUSE_MERGEABLE
:
445 pp_string (buffer
, "mergeable");
448 case OMP_CLAUSE_LINEAR
:
449 pp_string (buffer
, "linear(");
450 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
453 dump_generic_node (buffer
, OMP_CLAUSE_LINEAR_STEP (clause
),
455 pp_right_paren (buffer
);
458 case OMP_CLAUSE_ALIGNED
:
459 pp_string (buffer
, "aligned(");
460 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
462 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause
))
465 dump_generic_node (buffer
, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause
),
468 pp_right_paren (buffer
);
471 case OMP_CLAUSE_DEPEND
:
472 pp_string (buffer
, "depend(");
473 switch (OMP_CLAUSE_DEPEND_KIND (clause
))
475 case OMP_CLAUSE_DEPEND_IN
:
476 pp_string (buffer
, "in");
478 case OMP_CLAUSE_DEPEND_OUT
:
479 pp_string (buffer
, "out");
481 case OMP_CLAUSE_DEPEND_INOUT
:
482 pp_string (buffer
, "inout");
488 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
490 pp_right_paren (buffer
);
494 pp_string (buffer
, "map(");
495 switch (OMP_CLAUSE_MAP_KIND (clause
))
497 case OMP_CLAUSE_MAP_ALLOC
:
498 case OMP_CLAUSE_MAP_POINTER
:
499 pp_string (buffer
, "alloc");
501 case OMP_CLAUSE_MAP_TO
:
502 pp_string (buffer
, "to");
504 case OMP_CLAUSE_MAP_FROM
:
505 pp_string (buffer
, "from");
507 case OMP_CLAUSE_MAP_TOFROM
:
508 pp_string (buffer
, "tofrom");
514 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
517 if (OMP_CLAUSE_SIZE (clause
))
519 if (OMP_CLAUSE_CODE (clause
) == OMP_CLAUSE_MAP
520 && OMP_CLAUSE_MAP_KIND (clause
) == OMP_CLAUSE_MAP_POINTER
)
521 pp_string (buffer
, " [pointer assign, bias: ");
523 pp_string (buffer
, " [len: ");
524 dump_generic_node (buffer
, OMP_CLAUSE_SIZE (clause
),
526 pp_right_bracket (buffer
);
528 pp_right_paren (buffer
);
531 case OMP_CLAUSE_FROM
:
532 pp_string (buffer
, "from(");
533 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
535 goto print_clause_size
;
538 pp_string (buffer
, "to(");
539 dump_generic_node (buffer
, OMP_CLAUSE_DECL (clause
),
541 goto print_clause_size
;
543 case OMP_CLAUSE_NUM_TEAMS
:
544 pp_string (buffer
, "num_teams(");
545 dump_generic_node (buffer
, OMP_CLAUSE_NUM_TEAMS_EXPR (clause
),
547 pp_right_paren (buffer
);
550 case OMP_CLAUSE_THREAD_LIMIT
:
551 pp_string (buffer
, "thread_limit(");
552 dump_generic_node (buffer
, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause
),
554 pp_right_paren (buffer
);
557 case OMP_CLAUSE_DEVICE
:
558 pp_string (buffer
, "device(");
559 dump_generic_node (buffer
, OMP_CLAUSE_DEVICE_ID (clause
),
561 pp_right_paren (buffer
);
564 case OMP_CLAUSE_DIST_SCHEDULE
:
565 pp_string (buffer
, "dist_schedule(static");
566 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause
))
569 dump_generic_node (buffer
,
570 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause
),
573 pp_right_paren (buffer
);
576 case OMP_CLAUSE_PROC_BIND
:
577 pp_string (buffer
, "proc_bind(");
578 switch (OMP_CLAUSE_PROC_BIND_KIND (clause
))
580 case OMP_CLAUSE_PROC_BIND_MASTER
:
581 pp_string (buffer
, "master");
583 case OMP_CLAUSE_PROC_BIND_CLOSE
:
584 pp_string (buffer
, "close");
586 case OMP_CLAUSE_PROC_BIND_SPREAD
:
587 pp_string (buffer
, "spread");
592 pp_right_paren (buffer
);
595 case OMP_CLAUSE_SAFELEN
:
596 pp_string (buffer
, "safelen(");
597 dump_generic_node (buffer
, OMP_CLAUSE_SAFELEN_EXPR (clause
),
599 pp_right_paren (buffer
);
602 case OMP_CLAUSE_SIMDLEN
:
603 pp_string (buffer
, "simdlen(");
604 dump_generic_node (buffer
, OMP_CLAUSE_SIMDLEN_EXPR (clause
),
606 pp_right_paren (buffer
);
609 case OMP_CLAUSE__SIMDUID_
:
610 pp_string (buffer
, "_simduid_(");
611 dump_generic_node (buffer
, OMP_CLAUSE__SIMDUID__DECL (clause
),
613 pp_right_paren (buffer
);
616 case OMP_CLAUSE_INBRANCH
:
617 pp_string (buffer
, "inbranch");
619 case OMP_CLAUSE_NOTINBRANCH
:
620 pp_string (buffer
, "notinbranch");
623 pp_string (buffer
, "for");
625 case OMP_CLAUSE_PARALLEL
:
626 pp_string (buffer
, "parallel");
628 case OMP_CLAUSE_SECTIONS
:
629 pp_string (buffer
, "sections");
631 case OMP_CLAUSE_TASKGROUP
:
632 pp_string (buffer
, "taskgroup");
636 /* Should never happen. */
637 dump_generic_node (buffer
, clause
, spc
, flags
, false);
643 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
644 dump_generic_node. */
647 dump_omp_clauses (pretty_printer
*buffer
, tree clause
, int spc
, int flags
)
655 dump_omp_clause (buffer
, clause
, spc
, flags
);
656 clause
= OMP_CLAUSE_CHAIN (clause
);
664 /* Dump location LOC to BUFFER. */
667 dump_location (pretty_printer
*buffer
, location_t loc
)
669 expanded_location xloc
= expand_location (loc
);
671 pp_left_bracket (buffer
);
674 pp_string (buffer
, xloc
.file
);
675 pp_string (buffer
, " : ");
677 pp_decimal_int (buffer
, xloc
.line
);
678 pp_string (buffer
, "] ");
682 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
683 dump_generic_node. */
686 dump_block_node (pretty_printer
*buffer
, tree block
, int spc
, int flags
)
690 pp_printf (buffer
, "BLOCK #%d ", BLOCK_NUMBER (block
));
692 if (flags
& TDF_ADDRESS
)
693 pp_printf (buffer
, "[%p] ", (void *) block
);
695 if (BLOCK_ABSTRACT (block
))
696 pp_string (buffer
, "[abstract] ");
698 if (TREE_ASM_WRITTEN (block
))
699 pp_string (buffer
, "[written] ");
701 if (flags
& TDF_SLIM
)
704 if (BLOCK_SOURCE_LOCATION (block
))
705 dump_location (buffer
, BLOCK_SOURCE_LOCATION (block
));
707 newline_and_indent (buffer
, spc
+ 2);
709 if (BLOCK_SUPERCONTEXT (block
))
711 pp_string (buffer
, "SUPERCONTEXT: ");
712 dump_generic_node (buffer
, BLOCK_SUPERCONTEXT (block
), 0,
713 flags
| TDF_SLIM
, false);
714 newline_and_indent (buffer
, spc
+ 2);
717 if (BLOCK_SUBBLOCKS (block
))
719 pp_string (buffer
, "SUBBLOCKS: ");
720 for (t
= BLOCK_SUBBLOCKS (block
); t
; t
= BLOCK_CHAIN (t
))
722 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
725 newline_and_indent (buffer
, spc
+ 2);
728 if (BLOCK_CHAIN (block
))
730 pp_string (buffer
, "SIBLINGS: ");
731 for (t
= BLOCK_CHAIN (block
); t
; t
= BLOCK_CHAIN (t
))
733 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
736 newline_and_indent (buffer
, spc
+ 2);
739 if (BLOCK_VARS (block
))
741 pp_string (buffer
, "VARS: ");
742 for (t
= BLOCK_VARS (block
); t
; t
= TREE_CHAIN (t
))
744 dump_generic_node (buffer
, t
, 0, flags
, false);
747 newline_and_indent (buffer
, spc
+ 2);
750 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block
)) > 0)
753 vec
<tree
, va_gc
> *nlv
= BLOCK_NONLOCALIZED_VARS (block
);
755 pp_string (buffer
, "NONLOCALIZED_VARS: ");
756 FOR_EACH_VEC_ELT (*nlv
, i
, t
)
758 dump_generic_node (buffer
, t
, 0, flags
, false);
761 newline_and_indent (buffer
, spc
+ 2);
764 if (BLOCK_ABSTRACT_ORIGIN (block
))
766 pp_string (buffer
, "ABSTRACT_ORIGIN: ");
767 dump_generic_node (buffer
, BLOCK_ABSTRACT_ORIGIN (block
), 0,
768 flags
| TDF_SLIM
, false);
769 newline_and_indent (buffer
, spc
+ 2);
772 if (BLOCK_FRAGMENT_ORIGIN (block
))
774 pp_string (buffer
, "FRAGMENT_ORIGIN: ");
775 dump_generic_node (buffer
, BLOCK_FRAGMENT_ORIGIN (block
), 0,
776 flags
| TDF_SLIM
, false);
777 newline_and_indent (buffer
, spc
+ 2);
780 if (BLOCK_FRAGMENT_CHAIN (block
))
782 pp_string (buffer
, "FRAGMENT_CHAIN: ");
783 for (t
= BLOCK_FRAGMENT_CHAIN (block
); t
; t
= BLOCK_FRAGMENT_CHAIN (t
))
785 dump_generic_node (buffer
, t
, 0, flags
| TDF_SLIM
, false);
788 newline_and_indent (buffer
, spc
+ 2);
793 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
794 indent. FLAGS specifies details to show in the dump (see TDF_* in
795 dumpfile.h). If IS_STMT is true, the object printed is considered
796 to be a statement and it is terminated by ';' if appropriate. */
799 dump_generic_node (pretty_printer
*buffer
, tree node
, int spc
, int flags
,
808 if (node
== NULL_TREE
)
811 is_expr
= EXPR_P (node
);
813 if (is_stmt
&& (flags
& TDF_STMTADDR
))
814 pp_printf (buffer
, "<&%p> ", (void *)node
);
816 if ((flags
& TDF_LINENO
) && EXPR_HAS_LOCATION (node
))
817 dump_location (buffer
, EXPR_LOCATION (node
));
819 code
= TREE_CODE (node
);
823 pp_string (buffer
, "<<< error >>>");
826 case IDENTIFIER_NODE
:
827 pp_tree_identifier (buffer
, node
);
831 while (node
&& node
!= error_mark_node
)
833 if (TREE_PURPOSE (node
))
835 dump_generic_node (buffer
, TREE_PURPOSE (node
), spc
, flags
, false);
838 dump_generic_node (buffer
, TREE_VALUE (node
), spc
, flags
, false);
839 node
= TREE_CHAIN (node
);
840 if (node
&& TREE_CODE (node
) == TREE_LIST
)
849 dump_generic_node (buffer
, BINFO_TYPE (node
), spc
, flags
, false);
855 if (TREE_VEC_LENGTH (node
) > 0)
857 size_t len
= TREE_VEC_LENGTH (node
);
858 for (i
= 0; i
< len
- 1; i
++)
860 dump_generic_node (buffer
, TREE_VEC_ELT (node
, i
), spc
, flags
,
865 dump_generic_node (buffer
, TREE_VEC_ELT (node
, len
- 1), spc
,
874 case FIXED_POINT_TYPE
:
880 unsigned int quals
= TYPE_QUALS (node
);
881 enum tree_code_class tclass
;
883 if (quals
& TYPE_QUAL_ATOMIC
)
884 pp_string (buffer
, "atomic ");
885 if (quals
& TYPE_QUAL_CONST
)
886 pp_string (buffer
, "const ");
887 else if (quals
& TYPE_QUAL_VOLATILE
)
888 pp_string (buffer
, "volatile ");
889 else if (quals
& TYPE_QUAL_RESTRICT
)
890 pp_string (buffer
, "restrict ");
892 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
894 pp_string (buffer
, "<address-space-");
895 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
896 pp_string (buffer
, "> ");
899 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
901 if (tclass
== tcc_declaration
)
903 if (DECL_NAME (node
))
904 dump_decl_name (buffer
, node
, flags
);
906 pp_string (buffer
, "<unnamed type decl>");
908 else if (tclass
== tcc_type
)
910 if (TYPE_NAME (node
))
912 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
913 pp_tree_identifier (buffer
, TYPE_NAME (node
));
914 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
915 && DECL_NAME (TYPE_NAME (node
)))
916 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
918 pp_string (buffer
, "<unnamed type>");
920 else if (TREE_CODE (node
) == VECTOR_TYPE
)
922 pp_string (buffer
, "vector");
923 pp_left_paren (buffer
);
924 pp_wide_integer (buffer
, TYPE_VECTOR_SUBPARTS (node
));
925 pp_string (buffer
, ") ");
926 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
928 else if (TREE_CODE (node
) == INTEGER_TYPE
)
930 if (TYPE_PRECISION (node
) == CHAR_TYPE_SIZE
)
931 pp_string (buffer
, (TYPE_UNSIGNED (node
)
934 else if (TYPE_PRECISION (node
) == SHORT_TYPE_SIZE
)
935 pp_string (buffer
, (TYPE_UNSIGNED (node
)
938 else if (TYPE_PRECISION (node
) == INT_TYPE_SIZE
)
939 pp_string (buffer
, (TYPE_UNSIGNED (node
)
942 else if (TYPE_PRECISION (node
) == LONG_TYPE_SIZE
)
943 pp_string (buffer
, (TYPE_UNSIGNED (node
)
946 else if (TYPE_PRECISION (node
) == LONG_LONG_TYPE_SIZE
)
947 pp_string (buffer
, (TYPE_UNSIGNED (node
)
948 ? "unsigned long long"
949 : "signed long long"));
950 else if (TYPE_PRECISION (node
) >= CHAR_TYPE_SIZE
951 && exact_log2 (TYPE_PRECISION (node
)) != -1)
953 pp_string (buffer
, (TYPE_UNSIGNED (node
) ? "uint" : "int"));
954 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
955 pp_string (buffer
, "_t");
959 pp_string (buffer
, (TYPE_UNSIGNED (node
)
960 ? "<unnamed-unsigned:"
961 : "<unnamed-signed:"));
962 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
966 else if (TREE_CODE (node
) == COMPLEX_TYPE
)
968 pp_string (buffer
, "__complex__ ");
969 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
971 else if (TREE_CODE (node
) == REAL_TYPE
)
973 pp_string (buffer
, "<float:");
974 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
977 else if (TREE_CODE (node
) == FIXED_POINT_TYPE
)
979 pp_string (buffer
, "<fixed-point-");
980 pp_string (buffer
, TYPE_SATURATING (node
) ? "sat:" : "nonsat:");
981 pp_decimal_int (buffer
, TYPE_PRECISION (node
));
984 else if (TREE_CODE (node
) == VOID_TYPE
)
985 pp_string (buffer
, "void");
987 pp_string (buffer
, "<unnamed type>");
994 str
= (TREE_CODE (node
) == POINTER_TYPE
? "*" : "&");
996 if (TREE_TYPE (node
) == NULL
)
998 pp_string (buffer
, str
);
999 pp_string (buffer
, "<null type>");
1001 else if (TREE_CODE (TREE_TYPE (node
)) == FUNCTION_TYPE
)
1003 tree fnode
= TREE_TYPE (node
);
1005 dump_generic_node (buffer
, TREE_TYPE (fnode
), spc
, flags
, false);
1007 pp_left_paren (buffer
);
1008 pp_string (buffer
, str
);
1009 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1010 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1011 else if (flags
& TDF_NOUID
)
1012 pp_printf (buffer
, "<Txxxx>");
1014 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1016 pp_right_paren (buffer
);
1017 dump_function_declaration (buffer
, fnode
, spc
, flags
);
1021 unsigned int quals
= TYPE_QUALS (node
);
1023 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1025 pp_string (buffer
, str
);
1027 if (quals
& TYPE_QUAL_CONST
)
1028 pp_string (buffer
, " const");
1029 if (quals
& TYPE_QUAL_VOLATILE
)
1030 pp_string (buffer
, " volatile");
1031 if (quals
& TYPE_QUAL_RESTRICT
)
1032 pp_string (buffer
, " restrict");
1034 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
1036 pp_string (buffer
, " <address-space-");
1037 pp_decimal_int (buffer
, TYPE_ADDR_SPACE (node
));
1038 pp_greater (buffer
);
1041 if (TYPE_REF_CAN_ALIAS_ALL (node
))
1042 pp_string (buffer
, " {ref-all}");
1052 if (integer_zerop (TREE_OPERAND (node
, 1))
1053 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1054 infer them and MEM_ATTR caching will share MEM_REFs
1055 with differently-typed op0s. */
1056 && TREE_CODE (TREE_OPERAND (node
, 0)) != INTEGER_CST
1057 /* Released SSA_NAMES have no TREE_TYPE. */
1058 && TREE_TYPE (TREE_OPERAND (node
, 0)) != NULL_TREE
1059 /* Same pointer types, but ignoring POINTER_TYPE vs.
1061 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 0)))
1062 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))
1063 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 0)))
1064 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node
, 1))))
1065 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 0)))
1066 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node
, 1))))
1067 /* Same value types ignoring qualifiers. */
1068 && (TYPE_MAIN_VARIANT (TREE_TYPE (node
))
1069 == TYPE_MAIN_VARIANT
1070 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node
, 1))))))
1072 if (TREE_CODE (TREE_OPERAND (node
, 0)) != ADDR_EXPR
)
1075 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1079 dump_generic_node (buffer
,
1080 TREE_OPERAND (TREE_OPERAND (node
, 0), 0),
1087 pp_string (buffer
, "MEM[");
1088 pp_left_paren (buffer
);
1089 ptype
= TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node
, 1)));
1090 dump_generic_node (buffer
, ptype
,
1091 spc
, flags
| TDF_SLIM
, false);
1092 pp_right_paren (buffer
);
1093 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1095 if (!integer_zerop (TREE_OPERAND (node
, 1)))
1097 pp_string (buffer
, " + ");
1098 dump_generic_node (buffer
, TREE_OPERAND (node
, 1),
1101 pp_right_bracket (buffer
);
1106 case TARGET_MEM_REF
:
1108 const char *sep
= "";
1111 pp_string (buffer
, "MEM[");
1113 if (TREE_CODE (TMR_BASE (node
)) == ADDR_EXPR
)
1115 pp_string (buffer
, sep
);
1117 pp_string (buffer
, "symbol: ");
1118 dump_generic_node (buffer
, TREE_OPERAND (TMR_BASE (node
), 0),
1123 pp_string (buffer
, sep
);
1125 pp_string (buffer
, "base: ");
1126 dump_generic_node (buffer
, TMR_BASE (node
), spc
, flags
, false);
1128 tmp
= TMR_INDEX2 (node
);
1131 pp_string (buffer
, sep
);
1133 pp_string (buffer
, "base: ");
1134 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1136 tmp
= TMR_INDEX (node
);
1139 pp_string (buffer
, sep
);
1141 pp_string (buffer
, "index: ");
1142 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1144 tmp
= TMR_STEP (node
);
1147 pp_string (buffer
, sep
);
1149 pp_string (buffer
, "step: ");
1150 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1152 tmp
= TMR_OFFSET (node
);
1155 pp_string (buffer
, sep
);
1157 pp_string (buffer
, "offset: ");
1158 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1160 pp_right_bracket (buffer
);
1168 /* Print the innermost component type. */
1169 for (tmp
= TREE_TYPE (node
); TREE_CODE (tmp
) == ARRAY_TYPE
;
1170 tmp
= TREE_TYPE (tmp
))
1172 dump_generic_node (buffer
, tmp
, spc
, flags
, false);
1174 /* Print the dimensions. */
1175 for (tmp
= node
; TREE_CODE (tmp
) == ARRAY_TYPE
; tmp
= TREE_TYPE (tmp
))
1176 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
1182 case QUAL_UNION_TYPE
:
1184 unsigned int quals
= TYPE_QUALS (node
);
1186 if (quals
& TYPE_QUAL_ATOMIC
)
1187 pp_string (buffer
, "atomic ");
1188 if (quals
& TYPE_QUAL_CONST
)
1189 pp_string (buffer
, "const ");
1190 if (quals
& TYPE_QUAL_VOLATILE
)
1191 pp_string (buffer
, "volatile ");
1193 /* Print the name of the structure. */
1194 if (TREE_CODE (node
) == RECORD_TYPE
)
1195 pp_string (buffer
, "struct ");
1196 else if (TREE_CODE (node
) == UNION_TYPE
)
1197 pp_string (buffer
, "union ");
1199 if (TYPE_NAME (node
))
1200 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, flags
, false);
1201 else if (!(flags
& TDF_SLIM
))
1202 /* FIXME: If we eliminate the 'else' above and attempt
1203 to show the fields for named types, we may get stuck
1204 following a cycle of pointers to structs. The alleged
1205 self-reference check in print_struct_decl will not detect
1206 cycles involving more than one pointer or struct type. */
1207 print_struct_decl (buffer
, node
, spc
, flags
);
1216 if (TREE_CODE (TREE_TYPE (node
)) == POINTER_TYPE
)
1218 /* In the case of a pointer, one may want to divide by the
1219 size of the pointed-to type. Unfortunately, this not
1220 straightforward. The C front-end maps expressions
1225 in such a way that the two INTEGER_CST nodes for "5" have
1226 different values but identical types. In the latter
1227 case, the 5 is multiplied by sizeof (int) in c-common.c
1228 (pointer_int_sum) to convert it to a byte address, and
1229 yet the type of the node is left unchanged. Argh. What
1230 is consistent though is that the number value corresponds
1231 to bytes (UNITS) offset.
1233 NB: Neither of the following divisors can be trivially
1234 used to recover the original literal:
1236 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1237 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1238 pp_wide_integer (buffer
, TREE_INT_CST_LOW (node
));
1239 pp_string (buffer
, "B"); /* pseudo-unit */
1242 pp_double_int (buffer
, tree_to_double_int (node
),
1243 TYPE_UNSIGNED (TREE_TYPE (node
)));
1244 if (TREE_OVERFLOW (node
))
1245 pp_string (buffer
, "(OVF)");
1249 /* Code copied from print_node. */
1252 if (TREE_OVERFLOW (node
))
1253 pp_string (buffer
, " overflow");
1255 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1256 d
= TREE_REAL_CST (node
);
1257 if (REAL_VALUE_ISINF (d
))
1258 pp_string (buffer
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
1259 else if (REAL_VALUE_ISNAN (d
))
1260 pp_string (buffer
, " Nan");
1264 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
1265 pp_string (buffer
, string
);
1270 unsigned char *p
= (unsigned char *) &TREE_REAL_CST (node
);
1271 pp_string (buffer
, "0x");
1272 for (i
= 0; i
< sizeof TREE_REAL_CST (node
); i
++)
1273 output_formatted_integer (buffer
, "%02x", *p
++);
1282 fixed_to_decimal (string
, TREE_FIXED_CST_PTR (node
), sizeof (string
));
1283 pp_string (buffer
, string
);
1288 pp_string (buffer
, "__complex__ (");
1289 dump_generic_node (buffer
, TREE_REALPART (node
), spc
, flags
, false);
1290 pp_string (buffer
, ", ");
1291 dump_generic_node (buffer
, TREE_IMAGPART (node
), spc
, flags
, false);
1292 pp_right_paren (buffer
);
1296 pp_string (buffer
, "\"");
1297 pretty_print_string (buffer
, TREE_STRING_POINTER (node
));
1298 pp_string (buffer
, "\"");
1304 pp_string (buffer
, "{ ");
1305 for (i
= 0; i
< VECTOR_CST_NELTS (node
); ++i
)
1308 pp_string (buffer
, ", ");
1309 dump_generic_node (buffer
, VECTOR_CST_ELT (node
, i
),
1312 pp_string (buffer
, " }");
1318 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1320 if (TREE_CODE (node
) == METHOD_TYPE
)
1322 if (TYPE_METHOD_BASETYPE (node
))
1323 dump_decl_name (buffer
, TYPE_NAME (TYPE_METHOD_BASETYPE (node
)),
1326 pp_string (buffer
, "<null method basetype>");
1327 pp_colon_colon (buffer
);
1329 if (TYPE_NAME (node
) && DECL_NAME (TYPE_NAME (node
)))
1330 dump_decl_name (buffer
, TYPE_NAME (node
), flags
);
1331 else if (flags
& TDF_NOUID
)
1332 pp_printf (buffer
, "<Txxxx>");
1334 pp_printf (buffer
, "<T%x>", TYPE_UID (node
));
1335 dump_function_declaration (buffer
, node
, spc
, flags
);
1340 dump_decl_name (buffer
, node
, flags
);
1344 if (DECL_NAME (node
))
1345 dump_decl_name (buffer
, node
, flags
);
1346 else if (LABEL_DECL_UID (node
) != -1)
1347 pp_printf (buffer
, "<L%d>", (int) LABEL_DECL_UID (node
));
1350 if (flags
& TDF_NOUID
)
1351 pp_string (buffer
, "<D.xxxx>");
1353 pp_printf (buffer
, "<D.%u>", DECL_UID (node
));
1358 if (DECL_IS_BUILTIN (node
))
1360 /* Don't print the declaration of built-in types. */
1363 if (DECL_NAME (node
))
1364 dump_decl_name (buffer
, node
, flags
);
1365 else if (TYPE_NAME (TREE_TYPE (node
)) != node
)
1367 if ((TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1368 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1369 && TYPE_METHODS (TREE_TYPE (node
)))
1371 /* The type is a c++ class: all structures have at least
1373 pp_string (buffer
, "class ");
1374 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1379 (TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
1380 ? "union" : "struct "));
1381 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1385 pp_string (buffer
, "<anon>");
1391 case DEBUG_EXPR_DECL
:
1392 case NAMESPACE_DECL
:
1393 dump_decl_name (buffer
, node
, flags
);
1397 pp_string (buffer
, "<retval>");
1401 op0
= TREE_OPERAND (node
, 0);
1404 && (TREE_CODE (op0
) == INDIRECT_REF
1405 || (TREE_CODE (op0
) == MEM_REF
1406 && TREE_CODE (TREE_OPERAND (op0
, 0)) != ADDR_EXPR
1407 && integer_zerop (TREE_OPERAND (op0
, 1))
1408 /* Dump the types of INTEGER_CSTs explicitly, for we
1409 can't infer them and MEM_ATTR caching will share
1410 MEM_REFs with differently-typed op0s. */
1411 && TREE_CODE (TREE_OPERAND (op0
, 0)) != INTEGER_CST
1412 /* Released SSA_NAMES have no TREE_TYPE. */
1413 && TREE_TYPE (TREE_OPERAND (op0
, 0)) != NULL_TREE
1414 /* Same pointer types, but ignoring POINTER_TYPE vs.
1416 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1417 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1418 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1419 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1420 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 0)))
1421 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0
, 1))))
1422 /* Same value types ignoring qualifiers. */
1423 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0
))
1424 == TYPE_MAIN_VARIANT
1425 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0
, 1))))))))
1427 op0
= TREE_OPERAND (op0
, 0);
1430 if (op_prio (op0
) < op_prio (node
))
1431 pp_left_paren (buffer
);
1432 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1433 if (op_prio (op0
) < op_prio (node
))
1434 pp_right_paren (buffer
);
1435 pp_string (buffer
, str
);
1436 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1437 op0
= component_ref_field_offset (node
);
1438 if (op0
&& TREE_CODE (op0
) != INTEGER_CST
)
1440 pp_string (buffer
, "{off: ");
1441 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1442 pp_right_brace (buffer
);
1447 pp_string (buffer
, "BIT_FIELD_REF <");
1448 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1449 pp_string (buffer
, ", ");
1450 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1451 pp_string (buffer
, ", ");
1452 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1453 pp_greater (buffer
);
1457 case ARRAY_RANGE_REF
:
1458 op0
= TREE_OPERAND (node
, 0);
1459 if (op_prio (op0
) < op_prio (node
))
1460 pp_left_paren (buffer
);
1461 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1462 if (op_prio (op0
) < op_prio (node
))
1463 pp_right_paren (buffer
);
1464 pp_left_bracket (buffer
);
1465 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1466 if (TREE_CODE (node
) == ARRAY_RANGE_REF
)
1467 pp_string (buffer
, " ...");
1468 pp_right_bracket (buffer
);
1470 op0
= array_ref_low_bound (node
);
1471 op1
= array_ref_element_size (node
);
1473 if (!integer_zerop (op0
)
1474 || TREE_OPERAND (node
, 2)
1475 || TREE_OPERAND (node
, 3))
1477 pp_string (buffer
, "{lb: ");
1478 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1479 pp_string (buffer
, " sz: ");
1480 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1481 pp_right_brace (buffer
);
1487 unsigned HOST_WIDE_INT ix
;
1489 bool is_struct_init
= false;
1490 bool is_array_init
= false;
1491 double_int curidx
= double_int_zero
;
1492 pp_left_brace (buffer
);
1493 if (TREE_CLOBBER_P (node
))
1494 pp_string (buffer
, "CLOBBER");
1495 else if (TREE_CODE (TREE_TYPE (node
)) == RECORD_TYPE
1496 || TREE_CODE (TREE_TYPE (node
)) == UNION_TYPE
)
1497 is_struct_init
= true;
1498 else if (TREE_CODE (TREE_TYPE (node
)) == ARRAY_TYPE
1499 && TYPE_DOMAIN (TREE_TYPE (node
))
1500 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)))
1501 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
))))
1504 tree minv
= TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node
)));
1505 is_array_init
= true;
1506 curidx
= tree_to_double_int (minv
);
1508 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
), ix
, field
, val
)
1515 dump_generic_node (buffer
, field
, spc
, flags
, false);
1518 else if (is_array_init
1519 && (TREE_CODE (field
) != INTEGER_CST
1520 || tree_to_double_int (field
) != curidx
))
1522 pp_left_bracket (buffer
);
1523 if (TREE_CODE (field
) == RANGE_EXPR
)
1525 dump_generic_node (buffer
, TREE_OPERAND (field
, 0), spc
,
1527 pp_string (buffer
, " ... ");
1528 dump_generic_node (buffer
, TREE_OPERAND (field
, 1), spc
,
1530 if (TREE_CODE (TREE_OPERAND (field
, 1)) == INTEGER_CST
)
1531 curidx
= tree_to_double_int (TREE_OPERAND (field
, 1));
1534 dump_generic_node (buffer
, field
, spc
, flags
, false);
1535 if (TREE_CODE (field
) == INTEGER_CST
)
1536 curidx
= tree_to_double_int (field
);
1537 pp_string (buffer
, "]=");
1541 curidx
+= double_int_one
;
1542 if (val
&& TREE_CODE (val
) == ADDR_EXPR
)
1543 if (TREE_CODE (TREE_OPERAND (val
, 0)) == FUNCTION_DECL
)
1544 val
= TREE_OPERAND (val
, 0);
1545 if (val
&& TREE_CODE (val
) == FUNCTION_DECL
)
1546 dump_decl_name (buffer
, val
, flags
);
1548 dump_generic_node (buffer
, val
, spc
, flags
, false);
1549 if (ix
!= vec_safe_length (CONSTRUCTOR_ELTS (node
)) - 1)
1555 pp_right_brace (buffer
);
1562 if (flags
& TDF_SLIM
)
1564 pp_string (buffer
, "<COMPOUND_EXPR>");
1568 dump_generic_node (buffer
, TREE_OPERAND (node
, 0),
1569 spc
, flags
, !(flags
& TDF_SLIM
));
1570 if (flags
& TDF_SLIM
)
1571 newline_and_indent (buffer
, spc
);
1578 for (tp
= &TREE_OPERAND (node
, 1);
1579 TREE_CODE (*tp
) == COMPOUND_EXPR
;
1580 tp
= &TREE_OPERAND (*tp
, 1))
1582 dump_generic_node (buffer
, TREE_OPERAND (*tp
, 0),
1583 spc
, flags
, !(flags
& TDF_SLIM
));
1584 if (flags
& TDF_SLIM
)
1585 newline_and_indent (buffer
, spc
);
1593 dump_generic_node (buffer
, *tp
, spc
, flags
, !(flags
& TDF_SLIM
));
1597 case STATEMENT_LIST
:
1599 tree_stmt_iterator si
;
1602 if (flags
& TDF_SLIM
)
1604 pp_string (buffer
, "<STATEMENT_LIST>");
1608 for (si
= tsi_start (node
); !tsi_end_p (si
); tsi_next (&si
))
1611 newline_and_indent (buffer
, spc
);
1614 dump_generic_node (buffer
, tsi_stmt (si
), spc
, flags
, true);
1621 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
,
1626 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
,
1631 pp_string (buffer
, "TARGET_EXPR <");
1632 dump_generic_node (buffer
, TARGET_EXPR_SLOT (node
), spc
, flags
, false);
1635 dump_generic_node (buffer
, TARGET_EXPR_INITIAL (node
), spc
, flags
, false);
1636 pp_greater (buffer
);
1640 print_declaration (buffer
, DECL_EXPR_DECL (node
), spc
, flags
);
1645 if (TREE_TYPE (node
) == NULL
|| TREE_TYPE (node
) == void_type_node
)
1647 pp_string (buffer
, "if (");
1648 dump_generic_node (buffer
, COND_EXPR_COND (node
), spc
, flags
, false);
1649 pp_right_paren (buffer
);
1650 /* The lowered cond_exprs should always be printed in full. */
1651 if (COND_EXPR_THEN (node
)
1652 && (IS_EMPTY_STMT (COND_EXPR_THEN (node
))
1653 || TREE_CODE (COND_EXPR_THEN (node
)) == GOTO_EXPR
)
1654 && COND_EXPR_ELSE (node
)
1655 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node
))
1656 || TREE_CODE (COND_EXPR_ELSE (node
)) == GOTO_EXPR
))
1659 dump_generic_node (buffer
, COND_EXPR_THEN (node
),
1661 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1663 pp_string (buffer
, " else ");
1664 dump_generic_node (buffer
, COND_EXPR_ELSE (node
),
1668 else if (!(flags
& TDF_SLIM
))
1670 /* Output COND_EXPR_THEN. */
1671 if (COND_EXPR_THEN (node
))
1673 newline_and_indent (buffer
, spc
+2);
1674 pp_left_brace (buffer
);
1675 newline_and_indent (buffer
, spc
+4);
1676 dump_generic_node (buffer
, COND_EXPR_THEN (node
), spc
+4,
1678 newline_and_indent (buffer
, spc
+2);
1679 pp_right_brace (buffer
);
1682 /* Output COND_EXPR_ELSE. */
1683 if (COND_EXPR_ELSE (node
)
1684 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node
)))
1686 newline_and_indent (buffer
, spc
);
1687 pp_string (buffer
, "else");
1688 newline_and_indent (buffer
, spc
+2);
1689 pp_left_brace (buffer
);
1690 newline_and_indent (buffer
, spc
+4);
1691 dump_generic_node (buffer
, COND_EXPR_ELSE (node
), spc
+4,
1693 newline_and_indent (buffer
, spc
+2);
1694 pp_right_brace (buffer
);
1701 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1703 pp_question (buffer
);
1705 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1709 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
1714 pp_left_brace (buffer
);
1715 if (!(flags
& TDF_SLIM
))
1717 if (BIND_EXPR_VARS (node
))
1719 pp_newline (buffer
);
1721 for (op0
= BIND_EXPR_VARS (node
); op0
; op0
= DECL_CHAIN (op0
))
1723 print_declaration (buffer
, op0
, spc
+2, flags
);
1724 pp_newline (buffer
);
1728 newline_and_indent (buffer
, spc
+2);
1729 dump_generic_node (buffer
, BIND_EXPR_BODY (node
), spc
+2, flags
, true);
1730 newline_and_indent (buffer
, spc
);
1731 pp_right_brace (buffer
);
1737 print_call_name (buffer
, CALL_EXPR_FN (node
), flags
);
1739 /* Print parameters. */
1741 pp_left_paren (buffer
);
1744 call_expr_arg_iterator iter
;
1745 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
1747 dump_generic_node (buffer
, arg
, spc
, flags
, false);
1748 if (more_call_expr_args_p (&iter
))
1755 if (CALL_EXPR_VA_ARG_PACK (node
))
1757 if (call_expr_nargs (node
) > 0)
1762 pp_string (buffer
, "__builtin_va_arg_pack ()");
1764 pp_right_paren (buffer
);
1766 op1
= CALL_EXPR_STATIC_CHAIN (node
);
1769 pp_string (buffer
, " [static-chain: ");
1770 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1771 pp_right_bracket (buffer
);
1774 if (CALL_EXPR_RETURN_SLOT_OPT (node
))
1775 pp_string (buffer
, " [return slot optimization]");
1776 if (CALL_EXPR_TAILCALL (node
))
1777 pp_string (buffer
, " [tail call]");
1780 case WITH_CLEANUP_EXPR
:
1784 case CLEANUP_POINT_EXPR
:
1785 pp_string (buffer
, "<<cleanup_point ");
1786 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1787 pp_string (buffer
, ">>");
1790 case PLACEHOLDER_EXPR
:
1791 pp_string (buffer
, "<PLACEHOLDER_EXPR ");
1792 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1793 pp_greater (buffer
);
1796 /* Binary arithmetic and logic expressions. */
1797 case WIDEN_SUM_EXPR
:
1798 case WIDEN_MULT_EXPR
:
1800 case MULT_HIGHPART_EXPR
:
1802 case POINTER_PLUS_EXPR
:
1804 case TRUNC_DIV_EXPR
:
1806 case FLOOR_DIV_EXPR
:
1807 case ROUND_DIV_EXPR
:
1808 case TRUNC_MOD_EXPR
:
1810 case FLOOR_MOD_EXPR
:
1811 case ROUND_MOD_EXPR
:
1813 case EXACT_DIV_EXPR
:
1818 case VEC_LSHIFT_EXPR
:
1819 case VEC_RSHIFT_EXPR
:
1820 case WIDEN_LSHIFT_EXPR
:
1824 case TRUTH_ANDIF_EXPR
:
1825 case TRUTH_ORIF_EXPR
:
1826 case TRUTH_AND_EXPR
:
1828 case TRUTH_XOR_EXPR
:
1842 case UNORDERED_EXPR
:
1844 const char *op
= op_symbol (node
);
1845 op0
= TREE_OPERAND (node
, 0);
1846 op1
= TREE_OPERAND (node
, 1);
1848 /* When the operands are expressions with less priority,
1849 keep semantics of the tree representation. */
1850 if (op_prio (op0
) <= op_prio (node
))
1852 pp_left_paren (buffer
);
1853 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1854 pp_right_paren (buffer
);
1857 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1860 pp_string (buffer
, op
);
1863 /* When the operands are expressions with less priority,
1864 keep semantics of the tree representation. */
1865 if (op_prio (op1
) <= op_prio (node
))
1867 pp_left_paren (buffer
);
1868 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1869 pp_right_paren (buffer
);
1872 dump_generic_node (buffer
, op1
, spc
, flags
, false);
1876 /* Unary arithmetic and logic expressions. */
1879 case TRUTH_NOT_EXPR
:
1881 case PREDECREMENT_EXPR
:
1882 case PREINCREMENT_EXPR
:
1884 if (TREE_CODE (node
) == ADDR_EXPR
1885 && (TREE_CODE (TREE_OPERAND (node
, 0)) == STRING_CST
1886 || TREE_CODE (TREE_OPERAND (node
, 0)) == FUNCTION_DECL
))
1887 ; /* Do not output '&' for strings and function pointers. */
1889 pp_string (buffer
, op_symbol (node
));
1891 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1893 pp_left_paren (buffer
);
1894 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1895 pp_right_paren (buffer
);
1898 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1901 case POSTDECREMENT_EXPR
:
1902 case POSTINCREMENT_EXPR
:
1903 if (op_prio (TREE_OPERAND (node
, 0)) < op_prio (node
))
1905 pp_left_paren (buffer
);
1906 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1907 pp_right_paren (buffer
);
1910 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1911 pp_string (buffer
, op_symbol (node
));
1915 pp_string (buffer
, "MIN_EXPR <");
1916 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1917 pp_string (buffer
, ", ");
1918 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1919 pp_greater (buffer
);
1923 pp_string (buffer
, "MAX_EXPR <");
1924 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1925 pp_string (buffer
, ", ");
1926 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1927 pp_greater (buffer
);
1931 pp_string (buffer
, "ABS_EXPR <");
1932 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1933 pp_greater (buffer
);
1940 case ADDR_SPACE_CONVERT_EXPR
:
1941 case FIXED_CONVERT_EXPR
:
1942 case FIX_TRUNC_EXPR
:
1945 type
= TREE_TYPE (node
);
1946 op0
= TREE_OPERAND (node
, 0);
1947 if (type
!= TREE_TYPE (op0
))
1949 pp_left_paren (buffer
);
1950 dump_generic_node (buffer
, type
, spc
, flags
, false);
1951 pp_string (buffer
, ") ");
1953 if (op_prio (op0
) < op_prio (node
))
1954 pp_left_paren (buffer
);
1955 dump_generic_node (buffer
, op0
, spc
, flags
, false);
1956 if (op_prio (op0
) < op_prio (node
))
1957 pp_right_paren (buffer
);
1960 case VIEW_CONVERT_EXPR
:
1961 pp_string (buffer
, "VIEW_CONVERT_EXPR<");
1962 dump_generic_node (buffer
, TREE_TYPE (node
), spc
, flags
, false);
1963 pp_string (buffer
, ">(");
1964 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1965 pp_right_paren (buffer
);
1969 pp_string (buffer
, "((");
1970 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1971 pp_string (buffer
, "))");
1974 case NON_LVALUE_EXPR
:
1975 pp_string (buffer
, "NON_LVALUE_EXPR <");
1976 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1977 pp_greater (buffer
);
1981 pp_string (buffer
, "SAVE_EXPR <");
1982 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1983 pp_greater (buffer
);
1987 pp_string (buffer
, "COMPLEX_EXPR <");
1988 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1989 pp_string (buffer
, ", ");
1990 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
1991 pp_greater (buffer
);
1995 pp_string (buffer
, "CONJ_EXPR <");
1996 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
1997 pp_greater (buffer
);
2001 pp_string (buffer
, "REALPART_EXPR <");
2002 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2003 pp_greater (buffer
);
2007 pp_string (buffer
, "IMAGPART_EXPR <");
2008 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2009 pp_greater (buffer
);
2013 pp_string (buffer
, "VA_ARG_EXPR <");
2014 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2015 pp_greater (buffer
);
2018 case TRY_FINALLY_EXPR
:
2019 case TRY_CATCH_EXPR
:
2020 pp_string (buffer
, "try");
2021 newline_and_indent (buffer
, spc
+2);
2022 pp_left_brace (buffer
);
2023 newline_and_indent (buffer
, spc
+4);
2024 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
+4, flags
, true);
2025 newline_and_indent (buffer
, spc
+2);
2026 pp_right_brace (buffer
);
2027 newline_and_indent (buffer
, spc
);
2029 (TREE_CODE (node
) == TRY_CATCH_EXPR
) ? "catch" : "finally");
2030 newline_and_indent (buffer
, spc
+2);
2031 pp_left_brace (buffer
);
2032 newline_and_indent (buffer
, spc
+4);
2033 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
+4, flags
, true);
2034 newline_and_indent (buffer
, spc
+2);
2035 pp_right_brace (buffer
);
2040 pp_string (buffer
, "catch (");
2041 dump_generic_node (buffer
, CATCH_TYPES (node
), spc
+2, flags
, false);
2042 pp_right_paren (buffer
);
2043 newline_and_indent (buffer
, spc
+2);
2044 pp_left_brace (buffer
);
2045 newline_and_indent (buffer
, spc
+4);
2046 dump_generic_node (buffer
, CATCH_BODY (node
), spc
+4, flags
, true);
2047 newline_and_indent (buffer
, spc
+2);
2048 pp_right_brace (buffer
);
2052 case EH_FILTER_EXPR
:
2053 pp_string (buffer
, "<<<eh_filter (");
2054 dump_generic_node (buffer
, EH_FILTER_TYPES (node
), spc
+2, flags
, false);
2055 pp_string (buffer
, ")>>>");
2056 newline_and_indent (buffer
, spc
+2);
2057 pp_left_brace (buffer
);
2058 newline_and_indent (buffer
, spc
+4);
2059 dump_generic_node (buffer
, EH_FILTER_FAILURE (node
), spc
+4, flags
, true);
2060 newline_and_indent (buffer
, spc
+2);
2061 pp_right_brace (buffer
);
2066 op0
= TREE_OPERAND (node
, 0);
2067 /* If this is for break or continue, don't bother printing it. */
2068 if (DECL_NAME (op0
))
2070 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
2071 if (strcmp (name
, "break") == 0
2072 || strcmp (name
, "continue") == 0)
2075 dump_generic_node (buffer
, op0
, spc
, flags
, false);
2077 if (DECL_NONLOCAL (op0
))
2078 pp_string (buffer
, " [non-local]");
2082 pp_string (buffer
, "while (1)");
2083 if (!(flags
& TDF_SLIM
))
2085 newline_and_indent (buffer
, spc
+2);
2086 pp_left_brace (buffer
);
2087 newline_and_indent (buffer
, spc
+4);
2088 dump_generic_node (buffer
, LOOP_EXPR_BODY (node
), spc
+4, flags
, true);
2089 newline_and_indent (buffer
, spc
+2);
2090 pp_right_brace (buffer
);
2096 pp_string (buffer
, "// predicted ");
2097 if (PREDICT_EXPR_OUTCOME (node
))
2098 pp_string (buffer
, "likely by ");
2100 pp_string (buffer
, "unlikely by ");
2101 pp_string (buffer
, predictor_name (PREDICT_EXPR_PREDICTOR (node
)));
2102 pp_string (buffer
, " predictor.");
2106 pp_string (buffer
, "ANNOTATE_EXPR <");
2107 switch ((enum annot_expr_kind
) TREE_INT_CST_LOW (TREE_OPERAND (node
, 1)))
2109 case annot_expr_ivdep_kind
:
2110 pp_string (buffer
, "ivdep, ");
2113 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2114 pp_greater (buffer
);
2118 pp_string (buffer
, "return");
2119 op0
= TREE_OPERAND (node
, 0);
2123 if (TREE_CODE (op0
) == MODIFY_EXPR
)
2124 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1),
2127 dump_generic_node (buffer
, op0
, spc
, flags
, false);
2132 pp_string (buffer
, "if (");
2133 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2134 pp_string (buffer
, ") break");
2138 pp_string (buffer
, "switch (");
2139 dump_generic_node (buffer
, SWITCH_COND (node
), spc
, flags
, false);
2140 pp_right_paren (buffer
);
2141 if (!(flags
& TDF_SLIM
))
2143 newline_and_indent (buffer
, spc
+2);
2144 pp_left_brace (buffer
);
2145 if (SWITCH_BODY (node
))
2147 newline_and_indent (buffer
, spc
+4);
2148 dump_generic_node (buffer
, SWITCH_BODY (node
), spc
+4, flags
,
2153 tree vec
= SWITCH_LABELS (node
);
2154 size_t i
, n
= TREE_VEC_LENGTH (vec
);
2155 for (i
= 0; i
< n
; ++i
)
2157 tree elt
= TREE_VEC_ELT (vec
, i
);
2158 newline_and_indent (buffer
, spc
+4);
2161 dump_generic_node (buffer
, elt
, spc
+4, flags
, false);
2162 pp_string (buffer
, " goto ");
2163 dump_generic_node (buffer
, CASE_LABEL (elt
), spc
+4,
2165 pp_semicolon (buffer
);
2168 pp_string (buffer
, "case ???: goto ???;");
2171 newline_and_indent (buffer
, spc
+2);
2172 pp_right_brace (buffer
);
2178 op0
= GOTO_DESTINATION (node
);
2179 if (TREE_CODE (op0
) != SSA_NAME
&& DECL_P (op0
) && DECL_NAME (op0
))
2181 const char *name
= IDENTIFIER_POINTER (DECL_NAME (op0
));
2182 if (strcmp (name
, "break") == 0
2183 || strcmp (name
, "continue") == 0)
2185 pp_string (buffer
, name
);
2189 pp_string (buffer
, "goto ");
2190 dump_generic_node (buffer
, op0
, spc
, flags
, false);
2194 pp_string (buffer
, "__asm__");
2195 if (ASM_VOLATILE_P (node
))
2196 pp_string (buffer
, " __volatile__");
2197 pp_left_paren (buffer
);
2198 dump_generic_node (buffer
, ASM_STRING (node
), spc
, flags
, false);
2200 dump_generic_node (buffer
, ASM_OUTPUTS (node
), spc
, flags
, false);
2202 dump_generic_node (buffer
, ASM_INPUTS (node
), spc
, flags
, false);
2203 if (ASM_CLOBBERS (node
))
2206 dump_generic_node (buffer
, ASM_CLOBBERS (node
), spc
, flags
, false);
2208 pp_right_paren (buffer
);
2211 case CASE_LABEL_EXPR
:
2212 if (CASE_LOW (node
) && CASE_HIGH (node
))
2214 pp_string (buffer
, "case ");
2215 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
2216 pp_string (buffer
, " ... ");
2217 dump_generic_node (buffer
, CASE_HIGH (node
), spc
, flags
, false);
2219 else if (CASE_LOW (node
))
2221 pp_string (buffer
, "case ");
2222 dump_generic_node (buffer
, CASE_LOW (node
), spc
, flags
, false);
2225 pp_string (buffer
, "default");
2230 pp_string (buffer
, "OBJ_TYPE_REF(");
2231 dump_generic_node (buffer
, OBJ_TYPE_REF_EXPR (node
), spc
, flags
, false);
2232 pp_semicolon (buffer
);
2233 if (!(flags
& TDF_SLIM
) && virtual_method_call_p (node
))
2235 pp_string (buffer
, "(");
2236 dump_generic_node (buffer
, obj_type_ref_class (node
), spc
, flags
, false);
2237 pp_string (buffer
, ")");
2239 dump_generic_node (buffer
, OBJ_TYPE_REF_OBJECT (node
), spc
, flags
, false);
2241 dump_generic_node (buffer
, OBJ_TYPE_REF_TOKEN (node
), spc
, flags
, false);
2242 pp_right_paren (buffer
);
2246 if (SSA_NAME_IDENTIFIER (node
))
2247 dump_generic_node (buffer
, SSA_NAME_IDENTIFIER (node
),
2249 pp_underscore (buffer
);
2250 pp_decimal_int (buffer
, SSA_NAME_VERSION (node
));
2251 if (SSA_NAME_IS_DEFAULT_DEF (node
))
2252 pp_string (buffer
, "(D)");
2253 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
2254 pp_string (buffer
, "(ab)");
2257 case WITH_SIZE_EXPR
:
2258 pp_string (buffer
, "WITH_SIZE_EXPR <");
2259 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2260 pp_string (buffer
, ", ");
2261 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2262 pp_greater (buffer
);
2266 pp_string (buffer
, "ASSERT_EXPR <");
2267 dump_generic_node (buffer
, ASSERT_EXPR_VAR (node
), spc
, flags
, false);
2268 pp_string (buffer
, ", ");
2269 dump_generic_node (buffer
, ASSERT_EXPR_COND (node
), spc
, flags
, false);
2270 pp_greater (buffer
);
2274 pp_string (buffer
, "scev_known");
2277 case SCEV_NOT_KNOWN
:
2278 pp_string (buffer
, "scev_not_known");
2281 case POLYNOMIAL_CHREC
:
2282 pp_left_brace (buffer
);
2283 dump_generic_node (buffer
, CHREC_LEFT (node
), spc
, flags
, false);
2284 pp_string (buffer
, ", +, ");
2285 dump_generic_node (buffer
, CHREC_RIGHT (node
), spc
, flags
, false);
2286 pp_string (buffer
, "}_");
2287 dump_generic_node (buffer
, CHREC_VAR (node
), spc
, flags
, false);
2291 case REALIGN_LOAD_EXPR
:
2292 pp_string (buffer
, "REALIGN_LOAD <");
2293 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2294 pp_string (buffer
, ", ");
2295 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2296 pp_string (buffer
, ", ");
2297 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2298 pp_greater (buffer
);
2302 pp_string (buffer
, " VEC_COND_EXPR < ");
2303 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2304 pp_string (buffer
, " , ");
2305 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2306 pp_string (buffer
, " , ");
2307 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2308 pp_string (buffer
, " > ");
2312 pp_string (buffer
, " VEC_PERM_EXPR < ");
2313 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2314 pp_string (buffer
, " , ");
2315 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2316 pp_string (buffer
, " , ");
2317 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2318 pp_string (buffer
, " > ");
2322 pp_string (buffer
, " DOT_PROD_EXPR < ");
2323 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2324 pp_string (buffer
, ", ");
2325 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2326 pp_string (buffer
, ", ");
2327 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2328 pp_string (buffer
, " > ");
2331 case WIDEN_MULT_PLUS_EXPR
:
2332 pp_string (buffer
, " WIDEN_MULT_PLUS_EXPR < ");
2333 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2334 pp_string (buffer
, ", ");
2335 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2336 pp_string (buffer
, ", ");
2337 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2338 pp_string (buffer
, " > ");
2341 case WIDEN_MULT_MINUS_EXPR
:
2342 pp_string (buffer
, " WIDEN_MULT_MINUS_EXPR < ");
2343 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2344 pp_string (buffer
, ", ");
2345 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2346 pp_string (buffer
, ", ");
2347 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2348 pp_string (buffer
, " > ");
2352 pp_string (buffer
, " FMA_EXPR < ");
2353 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2354 pp_string (buffer
, ", ");
2355 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2356 pp_string (buffer
, ", ");
2357 dump_generic_node (buffer
, TREE_OPERAND (node
, 2), spc
, flags
, false);
2358 pp_string (buffer
, " > ");
2362 pp_string (buffer
, "#pragma omp parallel");
2363 dump_omp_clauses (buffer
, OMP_PARALLEL_CLAUSES (node
), spc
, flags
);
2366 if (!(flags
& TDF_SLIM
) && OMP_BODY (node
))
2368 newline_and_indent (buffer
, spc
+ 2);
2369 pp_left_brace (buffer
);
2370 newline_and_indent (buffer
, spc
+ 4);
2371 dump_generic_node (buffer
, OMP_BODY (node
), spc
+ 4, flags
, false);
2372 newline_and_indent (buffer
, spc
+ 2);
2373 pp_right_brace (buffer
);
2379 pp_string (buffer
, "#pragma omp task");
2380 dump_omp_clauses (buffer
, OMP_TASK_CLAUSES (node
), spc
, flags
);
2384 pp_string (buffer
, "#pragma omp for");
2388 pp_string (buffer
, "#pragma omp simd");
2392 pp_string (buffer
, "#pragma simd");
2395 case OMP_DISTRIBUTE
:
2396 pp_string (buffer
, "#pragma omp distribute");
2400 pp_string (buffer
, "#pragma omp teams");
2401 dump_omp_clauses (buffer
, OMP_TEAMS_CLAUSES (node
), spc
, flags
);
2404 case OMP_TARGET_DATA
:
2405 pp_string (buffer
, "#pragma omp target data");
2406 dump_omp_clauses (buffer
, OMP_TARGET_DATA_CLAUSES (node
), spc
, flags
);
2410 pp_string (buffer
, "#pragma omp target");
2411 dump_omp_clauses (buffer
, OMP_TARGET_CLAUSES (node
), spc
, flags
);
2414 case OMP_TARGET_UPDATE
:
2415 pp_string (buffer
, "#pragma omp target update");
2416 dump_omp_clauses (buffer
, OMP_TARGET_UPDATE_CLAUSES (node
), spc
, flags
);
2421 dump_omp_clauses (buffer
, OMP_FOR_CLAUSES (node
), spc
, flags
);
2423 if (!(flags
& TDF_SLIM
))
2427 if (OMP_FOR_PRE_BODY (node
))
2429 newline_and_indent (buffer
, spc
+ 2);
2430 pp_left_brace (buffer
);
2432 newline_and_indent (buffer
, spc
);
2433 dump_generic_node (buffer
, OMP_FOR_PRE_BODY (node
),
2436 if (OMP_FOR_INIT (node
))
2439 for (i
= 0; i
< TREE_VEC_LENGTH (OMP_FOR_INIT (node
)); i
++)
2442 newline_and_indent (buffer
, spc
);
2443 pp_string (buffer
, "for (");
2444 dump_generic_node (buffer
,
2445 TREE_VEC_ELT (OMP_FOR_INIT (node
), i
),
2447 pp_string (buffer
, "; ");
2448 dump_generic_node (buffer
,
2449 TREE_VEC_ELT (OMP_FOR_COND (node
), i
),
2451 pp_string (buffer
, "; ");
2452 dump_generic_node (buffer
,
2453 TREE_VEC_ELT (OMP_FOR_INCR (node
), i
),
2455 pp_right_paren (buffer
);
2458 if (OMP_FOR_BODY (node
))
2460 newline_and_indent (buffer
, spc
+ 2);
2461 pp_left_brace (buffer
);
2462 newline_and_indent (buffer
, spc
+ 4);
2463 dump_generic_node (buffer
, OMP_FOR_BODY (node
), spc
+ 4, flags
,
2465 newline_and_indent (buffer
, spc
+ 2);
2466 pp_right_brace (buffer
);
2468 if (OMP_FOR_INIT (node
))
2469 spc
-= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node
)) - 2;
2470 if (OMP_FOR_PRE_BODY (node
))
2473 newline_and_indent (buffer
, spc
+ 2);
2474 pp_right_brace (buffer
);
2481 pp_string (buffer
, "#pragma omp sections");
2482 dump_omp_clauses (buffer
, OMP_SECTIONS_CLAUSES (node
), spc
, flags
);
2486 pp_string (buffer
, "#pragma omp section");
2490 pp_string (buffer
, "#pragma omp master");
2494 pp_string (buffer
, "#pragma omp taskgroup");
2498 pp_string (buffer
, "#pragma omp ordered");
2502 pp_string (buffer
, "#pragma omp critical");
2503 if (OMP_CRITICAL_NAME (node
))
2506 pp_left_paren (buffer
);
2507 dump_generic_node (buffer
, OMP_CRITICAL_NAME (node
), spc
,
2509 pp_right_paren (buffer
);
2514 pp_string (buffer
, "#pragma omp atomic");
2515 if (OMP_ATOMIC_SEQ_CST (node
))
2516 pp_string (buffer
, " seq_cst");
2517 newline_and_indent (buffer
, spc
+ 2);
2518 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2522 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2525 case OMP_ATOMIC_READ
:
2526 pp_string (buffer
, "#pragma omp atomic read");
2527 if (OMP_ATOMIC_SEQ_CST (node
))
2528 pp_string (buffer
, " seq_cst");
2529 newline_and_indent (buffer
, spc
+ 2);
2530 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2534 case OMP_ATOMIC_CAPTURE_OLD
:
2535 case OMP_ATOMIC_CAPTURE_NEW
:
2536 pp_string (buffer
, "#pragma omp atomic capture");
2537 if (OMP_ATOMIC_SEQ_CST (node
))
2538 pp_string (buffer
, " seq_cst");
2539 newline_and_indent (buffer
, spc
+ 2);
2540 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2544 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2548 pp_string (buffer
, "#pragma omp single");
2549 dump_omp_clauses (buffer
, OMP_SINGLE_CLAUSES (node
), spc
, flags
);
2553 dump_omp_clause (buffer
, node
, spc
, flags
);
2557 case TRANSACTION_EXPR
:
2558 if (TRANSACTION_EXPR_OUTER (node
))
2559 pp_string (buffer
, "__transaction_atomic [[outer]]");
2560 else if (TRANSACTION_EXPR_RELAXED (node
))
2561 pp_string (buffer
, "__transaction_relaxed");
2563 pp_string (buffer
, "__transaction_atomic");
2564 if (!(flags
& TDF_SLIM
) && TRANSACTION_EXPR_BODY (node
))
2566 newline_and_indent (buffer
, spc
);
2567 pp_left_brace (buffer
);
2568 newline_and_indent (buffer
, spc
+ 2);
2569 dump_generic_node (buffer
, TRANSACTION_EXPR_BODY (node
),
2570 spc
+ 2, flags
, false);
2571 newline_and_indent (buffer
, spc
);
2572 pp_right_brace (buffer
);
2577 case REDUC_MAX_EXPR
:
2578 pp_string (buffer
, " REDUC_MAX_EXPR < ");
2579 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2580 pp_string (buffer
, " > ");
2583 case REDUC_MIN_EXPR
:
2584 pp_string (buffer
, " REDUC_MIN_EXPR < ");
2585 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2586 pp_string (buffer
, " > ");
2589 case REDUC_PLUS_EXPR
:
2590 pp_string (buffer
, " REDUC_PLUS_EXPR < ");
2591 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2592 pp_string (buffer
, " > ");
2595 case VEC_WIDEN_MULT_HI_EXPR
:
2596 case VEC_WIDEN_MULT_LO_EXPR
:
2597 case VEC_WIDEN_MULT_EVEN_EXPR
:
2598 case VEC_WIDEN_MULT_ODD_EXPR
:
2599 case VEC_WIDEN_LSHIFT_HI_EXPR
:
2600 case VEC_WIDEN_LSHIFT_LO_EXPR
:
2602 for (str
= get_tree_code_name (code
); *str
; str
++)
2603 pp_character (buffer
, TOUPPER (*str
));
2604 pp_string (buffer
, " < ");
2605 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2606 pp_string (buffer
, ", ");
2607 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2608 pp_string (buffer
, " > ");
2611 case VEC_UNPACK_HI_EXPR
:
2612 pp_string (buffer
, " VEC_UNPACK_HI_EXPR < ");
2613 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2614 pp_string (buffer
, " > ");
2617 case VEC_UNPACK_LO_EXPR
:
2618 pp_string (buffer
, " VEC_UNPACK_LO_EXPR < ");
2619 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2620 pp_string (buffer
, " > ");
2623 case VEC_UNPACK_FLOAT_HI_EXPR
:
2624 pp_string (buffer
, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2625 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2626 pp_string (buffer
, " > ");
2629 case VEC_UNPACK_FLOAT_LO_EXPR
:
2630 pp_string (buffer
, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2631 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2632 pp_string (buffer
, " > ");
2635 case VEC_PACK_TRUNC_EXPR
:
2636 pp_string (buffer
, " VEC_PACK_TRUNC_EXPR < ");
2637 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2638 pp_string (buffer
, ", ");
2639 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2640 pp_string (buffer
, " > ");
2643 case VEC_PACK_SAT_EXPR
:
2644 pp_string (buffer
, " VEC_PACK_SAT_EXPR < ");
2645 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2646 pp_string (buffer
, ", ");
2647 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2648 pp_string (buffer
, " > ");
2651 case VEC_PACK_FIX_TRUNC_EXPR
:
2652 pp_string (buffer
, " VEC_PACK_FIX_TRUNC_EXPR < ");
2653 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2654 pp_string (buffer
, ", ");
2655 dump_generic_node (buffer
, TREE_OPERAND (node
, 1), spc
, flags
, false);
2656 pp_string (buffer
, " > ");
2660 dump_block_node (buffer
, node
, spc
, flags
);
2663 case CILK_SPAWN_STMT
:
2664 pp_string (buffer
, "_Cilk_spawn ");
2665 dump_generic_node (buffer
, TREE_OPERAND (node
, 0), spc
, flags
, false);
2668 case CILK_SYNC_STMT
:
2669 pp_string (buffer
, "_Cilk_sync");
2676 if (is_stmt
&& is_expr
)
2677 pp_semicolon (buffer
);
2682 /* Print the declaration of a variable. */
2685 print_declaration (pretty_printer
*buffer
, tree t
, int spc
, int flags
)
2689 if (TREE_CODE (t
) == TYPE_DECL
)
2690 pp_string (buffer
, "typedef ");
2692 if (CODE_CONTAINS_STRUCT (TREE_CODE (t
), TS_DECL_WRTL
) && DECL_REGISTER (t
))
2693 pp_string (buffer
, "register ");
2695 if (TREE_PUBLIC (t
) && DECL_EXTERNAL (t
))
2696 pp_string (buffer
, "extern ");
2697 else if (TREE_STATIC (t
))
2698 pp_string (buffer
, "static ");
2700 /* Print the type and name. */
2701 if (TREE_TYPE (t
) && TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2705 /* Print array's type. */
2706 tmp
= TREE_TYPE (t
);
2707 while (TREE_CODE (TREE_TYPE (tmp
)) == ARRAY_TYPE
)
2708 tmp
= TREE_TYPE (tmp
);
2709 dump_generic_node (buffer
, TREE_TYPE (tmp
), spc
, flags
, false);
2711 /* Print variable's name. */
2713 dump_generic_node (buffer
, t
, spc
, flags
, false);
2715 /* Print the dimensions. */
2716 tmp
= TREE_TYPE (t
);
2717 while (TREE_CODE (tmp
) == ARRAY_TYPE
)
2719 dump_array_domain (buffer
, TYPE_DOMAIN (tmp
), spc
, flags
);
2720 tmp
= TREE_TYPE (tmp
);
2723 else if (TREE_CODE (t
) == FUNCTION_DECL
)
2725 dump_generic_node (buffer
, TREE_TYPE (TREE_TYPE (t
)), spc
, flags
, false);
2727 dump_decl_name (buffer
, t
, flags
);
2728 dump_function_declaration (buffer
, TREE_TYPE (t
), spc
, flags
);
2732 /* Print type declaration. */
2733 dump_generic_node (buffer
, TREE_TYPE (t
), spc
, flags
, false);
2735 /* Print variable's name. */
2737 dump_generic_node (buffer
, t
, spc
, flags
, false);
2740 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HARD_REGISTER (t
))
2742 pp_string (buffer
, " __asm__ ");
2743 pp_left_paren (buffer
);
2744 dump_generic_node (buffer
, DECL_ASSEMBLER_NAME (t
), spc
, flags
, false);
2745 pp_right_paren (buffer
);
2748 /* The initial value of a function serves to determine whether the function
2749 is declared or defined. So the following does not apply to function
2751 if (TREE_CODE (t
) != FUNCTION_DECL
)
2753 /* Print the initial value. */
2754 if (DECL_INITIAL (t
))
2759 dump_generic_node (buffer
, DECL_INITIAL (t
), spc
, flags
, false);
2763 if (TREE_CODE (t
) == VAR_DECL
&& DECL_HAS_VALUE_EXPR_P (t
))
2765 pp_string (buffer
, " [value-expr: ");
2766 dump_generic_node (buffer
, DECL_VALUE_EXPR (t
), spc
, flags
, false);
2767 pp_right_bracket (buffer
);
2770 pp_semicolon (buffer
);
2774 /* Prints a structure: name, fields, and methods.
2775 FIXME: Still incomplete. */
2778 print_struct_decl (pretty_printer
*buffer
, const_tree node
, int spc
, int flags
)
2780 /* Print the name of the structure. */
2781 if (TYPE_NAME (node
))
2784 if (TREE_CODE (node
) == RECORD_TYPE
)
2785 pp_string (buffer
, "struct ");
2786 else if ((TREE_CODE (node
) == UNION_TYPE
2787 || TREE_CODE (node
) == QUAL_UNION_TYPE
))
2788 pp_string (buffer
, "union ");
2790 dump_generic_node (buffer
, TYPE_NAME (node
), spc
, 0, false);
2793 /* Print the contents of the structure. */
2794 pp_newline (buffer
);
2796 pp_left_brace (buffer
);
2797 pp_newline (buffer
);
2799 /* Print the fields of the structure. */
2802 tmp
= TYPE_FIELDS (node
);
2805 /* Avoid to print recursively the structure. */
2806 /* FIXME : Not implemented correctly...,
2807 what about the case when we have a cycle in the contain graph? ...
2808 Maybe this could be solved by looking at the scope in which the
2809 structure was declared. */
2810 if (TREE_TYPE (tmp
) != node
2811 && (TREE_CODE (TREE_TYPE (tmp
)) != POINTER_TYPE
2812 || TREE_TYPE (TREE_TYPE (tmp
)) != node
))
2814 print_declaration (buffer
, tmp
, spc
+2, flags
);
2815 pp_newline (buffer
);
2817 tmp
= DECL_CHAIN (tmp
);
2821 pp_right_brace (buffer
);
2824 /* Return the priority of the operator CODE.
2826 From lowest to highest precedence with either left-to-right (L-R)
2827 or right-to-left (R-L) associativity]:
2830 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2842 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2843 15 [L-R] fn() [] -> .
2845 unary +, - and * have higher precedence than the corresponding binary
2849 op_code_prio (enum tree_code code
)
2866 case TRUTH_ORIF_EXPR
:
2869 case TRUTH_AND_EXPR
:
2870 case TRUTH_ANDIF_EXPR
:
2877 case TRUTH_XOR_EXPR
:
2894 case UNORDERED_EXPR
:
2905 case VEC_WIDEN_LSHIFT_HI_EXPR
:
2906 case VEC_WIDEN_LSHIFT_LO_EXPR
:
2907 case WIDEN_LSHIFT_EXPR
:
2910 case WIDEN_SUM_EXPR
:
2912 case POINTER_PLUS_EXPR
:
2916 case VEC_WIDEN_MULT_HI_EXPR
:
2917 case VEC_WIDEN_MULT_LO_EXPR
:
2918 case WIDEN_MULT_EXPR
:
2920 case WIDEN_MULT_PLUS_EXPR
:
2921 case WIDEN_MULT_MINUS_EXPR
:
2923 case MULT_HIGHPART_EXPR
:
2924 case TRUNC_DIV_EXPR
:
2926 case FLOOR_DIV_EXPR
:
2927 case ROUND_DIV_EXPR
:
2929 case EXACT_DIV_EXPR
:
2930 case TRUNC_MOD_EXPR
:
2932 case FLOOR_MOD_EXPR
:
2933 case ROUND_MOD_EXPR
:
2937 case TRUTH_NOT_EXPR
:
2939 case POSTINCREMENT_EXPR
:
2940 case POSTDECREMENT_EXPR
:
2941 case PREINCREMENT_EXPR
:
2942 case PREDECREMENT_EXPR
:
2948 case FIX_TRUNC_EXPR
:
2954 case ARRAY_RANGE_REF
:
2958 /* Special expressions. */
2964 case REDUC_MAX_EXPR
:
2965 case REDUC_MIN_EXPR
:
2966 case REDUC_PLUS_EXPR
:
2967 case VEC_LSHIFT_EXPR
:
2968 case VEC_RSHIFT_EXPR
:
2969 case VEC_UNPACK_HI_EXPR
:
2970 case VEC_UNPACK_LO_EXPR
:
2971 case VEC_UNPACK_FLOAT_HI_EXPR
:
2972 case VEC_UNPACK_FLOAT_LO_EXPR
:
2973 case VEC_PACK_TRUNC_EXPR
:
2974 case VEC_PACK_SAT_EXPR
:
2978 /* Return an arbitrarily high precedence to avoid surrounding single
2979 VAR_DECLs in ()s. */
2984 /* Return the priority of the operator OP. */
2987 op_prio (const_tree op
)
2989 enum tree_code code
;
2994 code
= TREE_CODE (op
);
2995 if (code
== SAVE_EXPR
|| code
== NON_LVALUE_EXPR
)
2996 return op_prio (TREE_OPERAND (op
, 0));
2998 return op_code_prio (code
);
3001 /* Return the symbol associated with operator CODE. */
3004 op_symbol_code (enum tree_code code
)
3012 case TRUTH_ORIF_EXPR
:
3015 case TRUTH_AND_EXPR
:
3016 case TRUTH_ANDIF_EXPR
:
3022 case TRUTH_XOR_EXPR
:
3032 case UNORDERED_EXPR
:
3078 case VEC_LSHIFT_EXPR
:
3081 case VEC_RSHIFT_EXPR
:
3084 case WIDEN_LSHIFT_EXPR
:
3087 case POINTER_PLUS_EXPR
:
3093 case REDUC_PLUS_EXPR
:
3096 case WIDEN_SUM_EXPR
:
3099 case WIDEN_MULT_EXPR
:
3102 case MULT_HIGHPART_EXPR
:
3112 case TRUTH_NOT_EXPR
:
3119 case TRUNC_DIV_EXPR
:
3126 case FLOOR_DIV_EXPR
:
3129 case ROUND_DIV_EXPR
:
3132 case EXACT_DIV_EXPR
:
3135 case TRUNC_MOD_EXPR
:
3141 case FLOOR_MOD_EXPR
:
3144 case ROUND_MOD_EXPR
:
3147 case PREDECREMENT_EXPR
:
3150 case PREINCREMENT_EXPR
:
3153 case POSTDECREMENT_EXPR
:
3156 case POSTINCREMENT_EXPR
:
3166 return "<<< ??? >>>";
3170 /* Return the symbol associated with operator OP. */
3173 op_symbol (const_tree op
)
3175 return op_symbol_code (TREE_CODE (op
));
3178 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3179 the gimple_call_fn of a GIMPLE_CALL. */
3182 print_call_name (pretty_printer
*buffer
, tree node
, int flags
)
3186 if (TREE_CODE (op0
) == NON_LVALUE_EXPR
)
3187 op0
= TREE_OPERAND (op0
, 0);
3190 switch (TREE_CODE (op0
))
3195 dump_function_name (buffer
, op0
, flags
);
3201 op0
= TREE_OPERAND (op0
, 0);
3205 pp_left_paren (buffer
);
3206 dump_generic_node (buffer
, TREE_OPERAND (op0
, 0), 0, flags
, false);
3207 pp_string (buffer
, ") ? ");
3208 dump_generic_node (buffer
, TREE_OPERAND (op0
, 1), 0, flags
, false);
3209 pp_string (buffer
, " : ");
3210 dump_generic_node (buffer
, TREE_OPERAND (op0
, 2), 0, flags
, false);
3214 if (TREE_CODE (TREE_OPERAND (op0
, 0)) == VAR_DECL
)
3215 dump_function_name (buffer
, TREE_OPERAND (op0
, 0), flags
);
3217 dump_generic_node (buffer
, op0
, 0, flags
, false);
3221 if (integer_zerop (TREE_OPERAND (op0
, 1)))
3223 op0
= TREE_OPERAND (op0
, 0);
3230 dump_generic_node (buffer
, op0
, 0, flags
, false);
3238 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3241 pretty_print_string (pretty_printer
*buffer
, const char *str
)
3251 pp_string (buffer
, "\\b");
3255 pp_string (buffer
, "\\f");
3259 pp_string (buffer
, "\\n");
3263 pp_string (buffer
, "\\r");
3267 pp_string (buffer
, "\\t");
3271 pp_string (buffer
, "\\v");
3275 pp_string (buffer
, "\\\\");
3279 pp_string (buffer
, "\\\"");
3283 pp_string (buffer
, "\\'");
3286 /* No need to handle \0; the loop terminates on \0. */
3289 pp_string (buffer
, "\\1");
3293 pp_string (buffer
, "\\2");
3297 pp_string (buffer
, "\\3");
3301 pp_string (buffer
, "\\4");
3305 pp_string (buffer
, "\\5");
3309 pp_string (buffer
, "\\6");
3313 pp_string (buffer
, "\\7");
3317 pp_character (buffer
, str
[0]);
3325 maybe_init_pretty_print (FILE *file
)
3329 new (&buffer
) pretty_printer ();
3330 pp_needs_newline (&buffer
) = true;
3331 pp_translate_identifiers (&buffer
) = false;
3335 buffer
.buffer
->stream
= file
;
3339 newline_and_indent (pretty_printer
*buffer
, int spc
)
3341 pp_newline (buffer
);
3345 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3346 it can also be used in front ends.
3347 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3351 percent_K_format (text_info
*text
)
3353 tree t
= va_arg (*text
->args_ptr
, tree
), block
;
3354 gcc_assert (text
->locus
!= NULL
);
3355 *text
->locus
= EXPR_LOCATION (t
);
3356 gcc_assert (pp_ti_abstract_origin (text
) != NULL
);
3357 block
= TREE_BLOCK (t
);
3358 *pp_ti_abstract_origin (text
) = NULL
;
3360 && TREE_CODE (block
) == BLOCK
3361 && BLOCK_ABSTRACT_ORIGIN (block
))
3363 tree ao
= BLOCK_ABSTRACT_ORIGIN (block
);
3365 while (TREE_CODE (ao
) == BLOCK
3366 && BLOCK_ABSTRACT_ORIGIN (ao
)
3367 && BLOCK_ABSTRACT_ORIGIN (ao
) != ao
)
3368 ao
= BLOCK_ABSTRACT_ORIGIN (ao
);
3370 if (TREE_CODE (ao
) == FUNCTION_DECL
)
3372 *pp_ti_abstract_origin (text
) = block
;
3375 block
= BLOCK_SUPERCONTEXT (block
);
3379 /* Print the identifier ID to PRETTY-PRINTER. */
3382 pp_tree_identifier (pretty_printer
*pp
, tree id
)
3384 if (pp_translate_identifiers (pp
))
3386 const char *text
= identifier_to_locale (IDENTIFIER_POINTER (id
));
3387 pp_append_text (pp
, text
, text
+ strlen (text
));
3390 pp_append_text (pp
, IDENTIFIER_POINTER (id
),
3391 IDENTIFIER_POINTER (id
) + IDENTIFIER_LENGTH (id
));
3394 /* A helper function that is used to dump function information before the
3398 dump_function_header (FILE *dump_file
, tree fdecl
, int flags
)
3400 const char *dname
, *aname
;
3401 struct cgraph_node
*node
= cgraph_get_node (fdecl
);
3402 struct function
*fun
= DECL_STRUCT_FUNCTION (fdecl
);
3404 dname
= lang_hooks
.decl_printable_name (fdecl
, 2);
3406 if (DECL_ASSEMBLER_NAME_SET_P (fdecl
))
3407 aname
= (IDENTIFIER_POINTER
3408 (DECL_ASSEMBLER_NAME (fdecl
)));
3410 aname
= "<unset-asm-name>";
3412 fprintf (dump_file
, "\n;; Function %s (%s, funcdef_no=%d",
3413 dname
, aname
, fun
->funcdef_no
);
3414 if (!(flags
& TDF_NOUID
))
3415 fprintf (dump_file
, ", decl_uid=%d", DECL_UID (fdecl
));
3418 fprintf (dump_file
, ", symbol_order=%d)%s\n\n", node
->order
,
3419 node
->frequency
== NODE_FREQUENCY_HOT
3421 : node
->frequency
== NODE_FREQUENCY_UNLIKELY_EXECUTED
3422 ? " (unlikely executed)"
3423 : node
->frequency
== NODE_FREQUENCY_EXECUTED_ONCE
3424 ? " (executed once)"
3428 fprintf (dump_file
, ")\n\n");
3431 /* Dump double_int D to pretty_printer PP. UNS is true
3432 if D is unsigned and false otherwise. */
3434 pp_double_int (pretty_printer
*pp
, double_int d
, bool uns
)
3437 pp_wide_integer (pp
, d
.low
);
3438 else if (d
.fits_uhwi ())
3439 pp_unsigned_wide_integer (pp
, d
.low
);
3442 unsigned HOST_WIDE_INT low
= d
.low
;
3443 HOST_WIDE_INT high
= d
.high
;
3444 if (!uns
&& d
.is_negative ())
3447 high
= ~high
+ !low
;
3450 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3452 sprintf (pp_buffer (pp
)->digit_buffer
,
3453 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
3454 (unsigned HOST_WIDE_INT
) high
, low
);
3455 pp_string (pp
, pp_buffer (pp
)->digit_buffer
);