1 /* Prints out tree in human readable form - GCC
2 Copyright (C) 1990-2019 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
27 #include "diagnostic.h"
29 #include "print-rtl.h"
30 #include "stor-layout.h"
31 #include "langhooks.h"
32 #include "tree-iterator.h"
33 #include "gimple-pretty-print.h" /* FIXME */
36 #include "print-tree.h"
38 /* Define the hash table of nodes already seen.
39 Such nodes are not repeated; brief cross-references are used. */
43 static hash_set
<tree
> *table
= NULL
;
45 /* Print PREFIX and ADDR to FILE. */
47 dump_addr (FILE *file
, const char *prefix
, const void *addr
)
49 if (flag_dump_noaddr
|| flag_dump_unnumbered
)
50 fprintf (file
, "%s#", prefix
);
52 fprintf (file
, "%s" HOST_PTR_PRINTF
, prefix
, addr
);
55 /* Print to FILE a NODE representing a REAL_CST constant, including
56 Infinity and NaN. Be verbose when BFRIEF is false. */
59 print_real_cst (FILE *file
, const_tree node
, bool brief
)
61 if (TREE_OVERFLOW (node
))
62 fprintf (file
, " overflow");
64 REAL_VALUE_TYPE d
= TREE_REAL_CST (node
);
65 if (REAL_VALUE_ISINF (d
))
66 fprintf (file
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
67 else if (REAL_VALUE_ISNAN (d
))
69 /* Print a NaN in the format [-][Q]NaN[(significand[exponent])]
70 where significand is a hexadecimal string that starts with
71 the 0x prefix followed by 0 if the number is not canonical
72 and a non-zero digit if it is, and exponent is decimal. */
74 const char *psig
= (const char *) d
.sig
;
75 for (unsigned i
= 0; i
!= sizeof d
.sig
; ++i
)
82 fprintf (file
, " %s%sNaN", d
.sign
? "-" : "",
83 d
.signalling
? "S" : "Q");
89 fprintf (file
, "(0x%s", d
.canonical
? "" : "0");
91 fprintf (file
, "(%s", d
.canonical
? "" : "0");
92 else if (!d
.canonical
)
94 fprintf (file
, "(0)");
100 for (unsigned i
= start
; i
!= sizeof d
.sig
; ++i
)
102 fprintf (file
, "%x", psig
[i
]);
104 fprintf (file
, "%02x", psig
[i
]);
108 fprintf (file
, "%se%u)", psig
[start
] ? "," : "", d
.uexp
);
109 else if (psig
[start
])
115 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
116 fprintf (file
, " %s", string
);
120 /* Print a node in brief fashion, with just the code, address and name. */
123 print_node_brief (FILE *file
, const char *prefix
, const_tree node
, int indent
)
125 enum tree_code_class tclass
;
130 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
132 /* Always print the slot this node is in, and its code, address and
136 fprintf (file
, "%s <%s", prefix
, get_tree_code_name (TREE_CODE (node
)));
137 dump_addr (file
, " ", node
);
139 if (tclass
== tcc_declaration
)
141 if (DECL_NAME (node
))
142 fprintf (file
, " %s", IDENTIFIER_POINTER (DECL_NAME (node
)));
143 else if (TREE_CODE (node
) == LABEL_DECL
144 && LABEL_DECL_UID (node
) != -1)
146 if (dump_flags
& TDF_NOUID
)
147 fprintf (file
, " L.xxxx");
149 fprintf (file
, " L.%d", (int) LABEL_DECL_UID (node
));
153 if (dump_flags
& TDF_NOUID
)
154 fprintf (file
, " %c.xxxx",
155 TREE_CODE (node
) == CONST_DECL
? 'C' : 'D');
157 fprintf (file
, " %c.%u",
158 TREE_CODE (node
) == CONST_DECL
? 'C' : 'D',
162 else if (tclass
== tcc_type
)
164 if (TYPE_NAME (node
))
166 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
167 fprintf (file
, " %s", IDENTIFIER_POINTER (TYPE_NAME (node
)));
168 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
169 && DECL_NAME (TYPE_NAME (node
)))
170 fprintf (file
, " %s",
171 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node
))));
173 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
174 fprintf (file
, " address-space-%d", TYPE_ADDR_SPACE (node
));
176 if (TREE_CODE (node
) == IDENTIFIER_NODE
)
177 fprintf (file
, " %s", IDENTIFIER_POINTER (node
));
179 /* We might as well always print the value of an integer or real. */
180 if (TREE_CODE (node
) == INTEGER_CST
)
182 if (TREE_OVERFLOW (node
))
183 fprintf (file
, " overflow");
186 print_dec (wi::to_wide (node
), file
, TYPE_SIGN (TREE_TYPE (node
)));
188 if (TREE_CODE (node
) == REAL_CST
)
189 print_real_cst (file
, node
, true);
190 if (TREE_CODE (node
) == FIXED_CST
)
195 if (TREE_OVERFLOW (node
))
196 fprintf (file
, " overflow");
198 f
= TREE_FIXED_CST (node
);
199 fixed_to_decimal (string
, &f
, sizeof (string
));
200 fprintf (file
, " %s", string
);
207 indent_to (FILE *file
, int column
)
211 /* Since this is the long way, indent to desired column. */
213 fprintf (file
, "\n");
214 for (i
= 0; i
< column
; i
++)
218 /* Print the node NODE in full on file FILE, preceded by PREFIX,
219 starting in column INDENT. */
222 print_node (FILE *file
, const char *prefix
, tree node
, int indent
,
223 bool brief_for_visited
)
226 enum tree_code_class tclass
;
229 expanded_location xloc
;
235 code
= TREE_CODE (node
);
237 /* It is unsafe to look at any other fields of a node with ERROR_MARK or
239 if (code
== ERROR_MARK
|| code
>= MAX_TREE_CODES
)
241 print_node_brief (file
, prefix
, node
, indent
);
245 tclass
= TREE_CODE_CLASS (code
);
247 /* Don't get too deep in nesting. If the user wants to see deeper,
248 it is easy to use the address of a lowest-level node
249 as an argument in another call to debug_tree. */
253 print_node_brief (file
, prefix
, node
, indent
);
257 if (indent
> 8 && (tclass
== tcc_type
|| tclass
== tcc_declaration
))
259 print_node_brief (file
, prefix
, node
, indent
);
263 /* Allow this function to be called if the table is not there. */
266 /* If node is in the table, just mention its address. */
267 if (table
->contains (node
) && brief_for_visited
)
269 print_node_brief (file
, prefix
, node
, indent
);
276 /* Indent to the specified column, since this is the long form. */
277 indent_to (file
, indent
);
279 /* Print the slot this node is in, and its code, and address. */
280 fprintf (file
, "%s <%s", prefix
, get_tree_code_name (code
));
281 dump_addr (file
, " ", node
);
283 /* Print the name, if any. */
284 if (tclass
== tcc_declaration
)
286 if (DECL_NAME (node
))
287 fprintf (file
, " %s", IDENTIFIER_POINTER (DECL_NAME (node
)));
288 else if (code
== LABEL_DECL
289 && LABEL_DECL_UID (node
) != -1)
291 if (dump_flags
& TDF_NOUID
)
292 fprintf (file
, " L.xxxx");
294 fprintf (file
, " L.%d", (int) LABEL_DECL_UID (node
));
298 if (dump_flags
& TDF_NOUID
)
299 fprintf (file
, " %c.xxxx", code
== CONST_DECL
? 'C' : 'D');
301 fprintf (file
, " %c.%u", code
== CONST_DECL
? 'C' : 'D',
305 else if (tclass
== tcc_type
)
307 if (TYPE_NAME (node
))
309 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
310 fprintf (file
, " %s", IDENTIFIER_POINTER (TYPE_NAME (node
)));
311 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
312 && DECL_NAME (TYPE_NAME (node
)))
313 fprintf (file
, " %s",
314 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node
))));
317 if (code
== IDENTIFIER_NODE
)
318 fprintf (file
, " %s", IDENTIFIER_POINTER (node
));
320 if (code
== INTEGER_CST
)
323 print_node_brief (file
, "type", TREE_TYPE (node
), indent
+ 4);
325 else if (CODE_CONTAINS_STRUCT (code
, TS_TYPED
))
327 print_node (file
, "type", TREE_TYPE (node
), indent
+ 4);
328 if (TREE_TYPE (node
))
329 indent_to (file
, indent
+ 3);
332 if (!TYPE_P (node
) && TREE_SIDE_EFFECTS (node
))
333 fputs (" side-effects", file
);
335 if (TYPE_P (node
) ? TYPE_READONLY (node
) : TREE_READONLY (node
))
336 fputs (" readonly", file
);
337 if (TYPE_P (node
) && TYPE_ATOMIC (node
))
338 fputs (" atomic", file
);
339 if (!TYPE_P (node
) && TREE_CONSTANT (node
))
340 fputs (" constant", file
);
341 else if (TYPE_P (node
) && TYPE_SIZES_GIMPLIFIED (node
))
342 fputs (" sizes-gimplified", file
);
344 if (TYPE_P (node
) && !ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
345 fprintf (file
, " address-space-%d", TYPE_ADDR_SPACE (node
));
347 if (TREE_ADDRESSABLE (node
))
348 fputs (" addressable", file
);
349 if (TREE_THIS_VOLATILE (node
))
350 fputs (" volatile", file
);
351 if (TREE_ASM_WRITTEN (node
))
352 fputs (" asm_written", file
);
353 if (TREE_USED (node
))
354 fputs (" used", file
);
355 if (TREE_NOTHROW (node
))
356 fputs (" nothrow", file
);
357 if (TREE_PUBLIC (node
))
358 fputs (" public", file
);
359 if (TREE_PRIVATE (node
))
360 fputs (" private", file
);
361 if (TREE_PROTECTED (node
))
362 fputs (" protected", file
);
363 if (TREE_STATIC (node
))
364 fputs (code
== CALL_EXPR
? " must-tail-call" : " static", file
);
365 if (TREE_DEPRECATED (node
))
366 fputs (" deprecated", file
);
367 if (TREE_VISITED (node
))
368 fputs (" visited", file
);
370 if (code
!= TREE_VEC
&& code
!= INTEGER_CST
&& code
!= SSA_NAME
)
372 if (TREE_LANG_FLAG_0 (node
))
373 fputs (" tree_0", file
);
374 if (TREE_LANG_FLAG_1 (node
))
375 fputs (" tree_1", file
);
376 if (TREE_LANG_FLAG_2 (node
))
377 fputs (" tree_2", file
);
378 if (TREE_LANG_FLAG_3 (node
))
379 fputs (" tree_3", file
);
380 if (TREE_LANG_FLAG_4 (node
))
381 fputs (" tree_4", file
);
382 if (TREE_LANG_FLAG_5 (node
))
383 fputs (" tree_5", file
);
384 if (TREE_LANG_FLAG_6 (node
))
385 fputs (" tree_6", file
);
388 /* DECL_ nodes have additional attributes. */
390 switch (TREE_CODE_CLASS (code
))
392 case tcc_declaration
:
393 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_COMMON
))
395 if (DECL_UNSIGNED (node
))
396 fputs (" unsigned", file
);
397 if (DECL_IGNORED_P (node
))
398 fputs (" ignored", file
);
399 if (DECL_ABSTRACT_P (node
))
400 fputs (" abstract", file
);
401 if (DECL_EXTERNAL (node
))
402 fputs (" external", file
);
403 if (DECL_NONLOCAL (node
))
404 fputs (" nonlocal", file
);
406 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_WITH_VIS
))
408 if (DECL_WEAK (node
))
409 fputs (" weak", file
);
410 if (DECL_IN_SYSTEM_HEADER (node
))
411 fputs (" in_system_header", file
);
413 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_WRTL
)
414 && code
!= LABEL_DECL
415 && code
!= FUNCTION_DECL
416 && DECL_REGISTER (node
))
417 fputs (" regdecl", file
);
419 if (code
== TYPE_DECL
&& TYPE_DECL_SUPPRESS_DEBUG (node
))
420 fputs (" suppress-debug", file
);
422 if (code
== FUNCTION_DECL
423 && DECL_FUNCTION_SPECIFIC_TARGET (node
))
424 fputs (" function-specific-target", file
);
425 if (code
== FUNCTION_DECL
426 && DECL_FUNCTION_SPECIFIC_OPTIMIZATION (node
))
427 fputs (" function-specific-opt", file
);
428 if (code
== FUNCTION_DECL
&& DECL_DECLARED_INLINE_P (node
))
429 fputs (" autoinline", file
);
430 if (code
== FUNCTION_DECL
&& DECL_UNINLINABLE (node
))
431 fputs (" uninlinable", file
);
432 if (code
== FUNCTION_DECL
&& fndecl_built_in_p (node
))
433 fputs (" built-in", file
);
434 if (code
== FUNCTION_DECL
&& DECL_STATIC_CHAIN (node
))
435 fputs (" static-chain", file
);
436 if (TREE_CODE (node
) == FUNCTION_DECL
&& decl_is_tm_clone (node
))
437 fputs (" tm-clone", file
);
439 if (code
== FIELD_DECL
&& DECL_PACKED (node
))
440 fputs (" packed", file
);
441 if (code
== FIELD_DECL
&& DECL_BIT_FIELD (node
))
442 fputs (" bit-field", file
);
443 if (code
== FIELD_DECL
&& DECL_NONADDRESSABLE_P (node
))
444 fputs (" nonaddressable", file
);
446 if (code
== LABEL_DECL
&& EH_LANDING_PAD_NR (node
))
447 fprintf (file
, " landing-pad:%d", EH_LANDING_PAD_NR (node
));
449 if (code
== VAR_DECL
&& DECL_IN_TEXT_SECTION (node
))
450 fputs (" in-text-section", file
);
451 if (code
== VAR_DECL
&& DECL_IN_CONSTANT_POOL (node
))
452 fputs (" in-constant-pool", file
);
453 if (code
== VAR_DECL
&& DECL_COMMON (node
))
454 fputs (" common", file
);
455 if ((code
== VAR_DECL
|| code
== PARM_DECL
) && DECL_READ_P (node
))
456 fputs (" read", file
);
457 if (code
== VAR_DECL
&& DECL_THREAD_LOCAL_P (node
))
460 fputs (tls_model_names
[DECL_TLS_MODEL (node
)], file
);
463 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_COMMON
))
465 if (DECL_VIRTUAL_P (node
))
466 fputs (" virtual", file
);
467 if (DECL_PRESERVE_P (node
))
468 fputs (" preserve", file
);
469 if (DECL_LANG_FLAG_0 (node
))
470 fputs (" decl_0", file
);
471 if (DECL_LANG_FLAG_1 (node
))
472 fputs (" decl_1", file
);
473 if (DECL_LANG_FLAG_2 (node
))
474 fputs (" decl_2", file
);
475 if (DECL_LANG_FLAG_3 (node
))
476 fputs (" decl_3", file
);
477 if (DECL_LANG_FLAG_4 (node
))
478 fputs (" decl_4", file
);
479 if (DECL_LANG_FLAG_5 (node
))
480 fputs (" decl_5", file
);
481 if (DECL_LANG_FLAG_6 (node
))
482 fputs (" decl_6", file
);
483 if (DECL_LANG_FLAG_7 (node
))
484 fputs (" decl_7", file
);
486 mode
= DECL_MODE (node
);
487 fprintf (file
, " %s", GET_MODE_NAME (mode
));
490 if ((code
== VAR_DECL
|| code
== PARM_DECL
|| code
== RESULT_DECL
)
491 && DECL_BY_REFERENCE (node
))
492 fputs (" passed-by-reference", file
);
494 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_WITH_VIS
) && DECL_DEFER_OUTPUT (node
))
495 fputs (" defer-output", file
);
498 xloc
= expand_location (DECL_SOURCE_LOCATION (node
));
499 fprintf (file
, " %s:%d:%d", xloc
.file
, xloc
.line
,
502 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_COMMON
))
504 print_node (file
, "size", DECL_SIZE (node
), indent
+ 4);
505 print_node (file
, "unit-size", DECL_SIZE_UNIT (node
), indent
+ 4);
507 if (code
!= FUNCTION_DECL
|| fndecl_built_in_p (node
))
508 indent_to (file
, indent
+ 3);
510 if (DECL_USER_ALIGN (node
))
511 fprintf (file
, " user");
513 fprintf (file
, " align:%d warn_if_not_align:%d",
514 DECL_ALIGN (node
), DECL_WARN_IF_NOT_ALIGN (node
));
515 if (code
== FIELD_DECL
)
516 fprintf (file
, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED
,
517 DECL_OFFSET_ALIGN (node
));
519 if (code
== FUNCTION_DECL
&& fndecl_built_in_p (node
))
521 if (DECL_BUILT_IN_CLASS (node
) == BUILT_IN_MD
)
522 fprintf (file
, " built-in: BUILT_IN_MD:%d", DECL_FUNCTION_CODE (node
));
524 fprintf (file
, " built-in: %s:%s",
525 built_in_class_names
[(int) DECL_BUILT_IN_CLASS (node
)],
526 built_in_names
[(int) DECL_FUNCTION_CODE (node
)]);
529 if (code
== FIELD_DECL
)
531 print_node (file
, "offset", DECL_FIELD_OFFSET (node
), indent
+ 4);
532 print_node (file
, "bit-offset", DECL_FIELD_BIT_OFFSET (node
),
534 if (DECL_BIT_FIELD_TYPE (node
))
535 print_node (file
, "bit_field_type", DECL_BIT_FIELD_TYPE (node
),
539 print_node_brief (file
, "context", DECL_CONTEXT (node
), indent
+ 4);
541 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_COMMON
))
543 print_node (file
, "attributes",
544 DECL_ATTRIBUTES (node
), indent
+ 4);
545 if (code
!= PARM_DECL
)
546 print_node_brief (file
, "initial", DECL_INITIAL (node
),
549 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_WRTL
))
551 print_node_brief (file
, "abstract_origin",
552 DECL_ABSTRACT_ORIGIN (node
), indent
+ 4);
554 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_NON_COMMON
))
556 print_node (file
, "result", DECL_RESULT_FLD (node
), indent
+ 4);
559 lang_hooks
.print_decl (file
, node
, indent
);
561 if (DECL_RTL_SET_P (node
))
563 indent_to (file
, indent
+ 4);
564 print_rtl (file
, DECL_RTL (node
));
567 if (code
== PARM_DECL
)
569 print_node (file
, "arg-type", DECL_ARG_TYPE (node
), indent
+ 4);
571 if (DECL_INCOMING_RTL (node
) != 0)
573 indent_to (file
, indent
+ 4);
574 fprintf (file
, "incoming-rtl ");
575 print_rtl (file
, DECL_INCOMING_RTL (node
));
578 else if (code
== FUNCTION_DECL
579 && DECL_STRUCT_FUNCTION (node
) != 0)
581 print_node (file
, "arguments", DECL_ARGUMENTS (node
), indent
+ 4);
582 indent_to (file
, indent
+ 4);
583 dump_addr (file
, "struct-function ", DECL_STRUCT_FUNCTION (node
));
586 if ((code
== VAR_DECL
|| code
== PARM_DECL
)
587 && DECL_HAS_VALUE_EXPR_P (node
))
588 print_node (file
, "value-expr", DECL_VALUE_EXPR (node
), indent
+ 4);
590 /* Print the decl chain only if decl is at second level. */
592 print_node (file
, "chain", TREE_CHAIN (node
), indent
+ 4);
594 print_node_brief (file
, "chain", TREE_CHAIN (node
), indent
+ 4);
598 if (TYPE_UNSIGNED (node
))
599 fputs (" unsigned", file
);
601 if (TYPE_NO_FORCE_BLK (node
))
602 fputs (" no-force-blk", file
);
604 if (code
== ARRAY_TYPE
&& TYPE_STRING_FLAG (node
))
605 fputs (" string-flag", file
);
607 if (TYPE_NEEDS_CONSTRUCTING (node
))
608 fputs (" needs-constructing", file
);
610 if ((code
== RECORD_TYPE
611 || code
== UNION_TYPE
612 || code
== QUAL_UNION_TYPE
613 || code
== ARRAY_TYPE
)
614 && TYPE_REVERSE_STORAGE_ORDER (node
))
615 fputs (" reverse-storage-order", file
);
617 if ((code
== RECORD_TYPE
618 || code
== UNION_TYPE
)
619 && TYPE_CXX_ODR_P (node
))
620 fputs (" cxx-odr-p", file
);
622 /* The transparent-union flag is used for different things in
624 if ((code
== UNION_TYPE
|| code
== RECORD_TYPE
)
625 && TYPE_TRANSPARENT_AGGR (node
))
626 fputs (" transparent-aggr", file
);
627 else if (code
== ARRAY_TYPE
628 && TYPE_NONALIASED_COMPONENT (node
))
629 fputs (" nonaliased-component", file
);
631 if (TYPE_PACKED (node
))
632 fputs (" packed", file
);
634 if (TYPE_RESTRICT (node
))
635 fputs (" restrict", file
);
637 if (TYPE_LANG_FLAG_0 (node
))
638 fputs (" type_0", file
);
639 if (TYPE_LANG_FLAG_1 (node
))
640 fputs (" type_1", file
);
641 if (TYPE_LANG_FLAG_2 (node
))
642 fputs (" type_2", file
);
643 if (TYPE_LANG_FLAG_3 (node
))
644 fputs (" type_3", file
);
645 if (TYPE_LANG_FLAG_4 (node
))
646 fputs (" type_4", file
);
647 if (TYPE_LANG_FLAG_5 (node
))
648 fputs (" type_5", file
);
649 if (TYPE_LANG_FLAG_6 (node
))
650 fputs (" type_6", file
);
651 if (TYPE_LANG_FLAG_7 (node
))
652 fputs (" type_7", file
);
654 mode
= TYPE_MODE (node
);
655 fprintf (file
, " %s", GET_MODE_NAME (mode
));
657 print_node (file
, "size", TYPE_SIZE (node
), indent
+ 4);
658 print_node (file
, "unit-size", TYPE_SIZE_UNIT (node
), indent
+ 4);
659 indent_to (file
, indent
+ 3);
661 if (TYPE_USER_ALIGN (node
))
662 fprintf (file
, " user");
664 fprintf (file
, " align:%d warn_if_not_align:%d symtab:%d alias-set "
665 HOST_WIDE_INT_PRINT_DEC
,
666 TYPE_ALIGN (node
), TYPE_WARN_IF_NOT_ALIGN (node
),
667 TYPE_SYMTAB_ADDRESS (node
),
668 (HOST_WIDE_INT
) TYPE_ALIAS_SET (node
));
670 if (TYPE_STRUCTURAL_EQUALITY_P (node
))
671 fprintf (file
, " structural-equality");
673 dump_addr (file
, " canonical-type ", TYPE_CANONICAL (node
));
675 print_node (file
, "attributes", TYPE_ATTRIBUTES (node
), indent
+ 4);
677 if (INTEGRAL_TYPE_P (node
) || code
== REAL_TYPE
678 || code
== FIXED_POINT_TYPE
)
680 fprintf (file
, " precision:%d", TYPE_PRECISION (node
));
681 print_node_brief (file
, "min", TYPE_MIN_VALUE (node
), indent
+ 4);
682 print_node_brief (file
, "max", TYPE_MAX_VALUE (node
), indent
+ 4);
685 if (code
== ENUMERAL_TYPE
)
686 print_node (file
, "values", TYPE_VALUES (node
), indent
+ 4);
687 else if (code
== ARRAY_TYPE
)
688 print_node (file
, "domain", TYPE_DOMAIN (node
), indent
+ 4);
689 else if (code
== VECTOR_TYPE
)
691 fprintf (file
, " nunits:");
692 print_dec (TYPE_VECTOR_SUBPARTS (node
), file
);
694 else if (code
== RECORD_TYPE
695 || code
== UNION_TYPE
696 || code
== QUAL_UNION_TYPE
)
697 print_node (file
, "fields", TYPE_FIELDS (node
), indent
+ 4);
698 else if (code
== FUNCTION_TYPE
699 || code
== METHOD_TYPE
)
701 if (TYPE_METHOD_BASETYPE (node
))
702 print_node_brief (file
, "method basetype",
703 TYPE_METHOD_BASETYPE (node
), indent
+ 4);
704 print_node (file
, "arg-types", TYPE_ARG_TYPES (node
), indent
+ 4);
706 else if (code
== OFFSET_TYPE
)
707 print_node_brief (file
, "basetype", TYPE_OFFSET_BASETYPE (node
),
710 if (TYPE_CONTEXT (node
))
711 print_node_brief (file
, "context", TYPE_CONTEXT (node
), indent
+ 4);
713 lang_hooks
.print_type (file
, node
, indent
);
715 if (TYPE_POINTER_TO (node
) || TREE_CHAIN (node
))
716 indent_to (file
, indent
+ 3);
718 print_node_brief (file
, "pointer_to_this", TYPE_POINTER_TO (node
),
720 print_node_brief (file
, "reference_to_this", TYPE_REFERENCE_TO (node
),
722 print_node_brief (file
, "chain", TREE_CHAIN (node
), indent
+ 4);
732 if (code
== BIND_EXPR
)
734 print_node (file
, "vars", TREE_OPERAND (node
, 0), indent
+ 4);
735 print_node (file
, "body", TREE_OPERAND (node
, 1), indent
+ 4);
736 print_node (file
, "block", TREE_OPERAND (node
, 2), indent
+ 4);
739 if (code
== CALL_EXPR
)
741 call_expr_arg_iterator iter
;
743 print_node (file
, "fn", CALL_EXPR_FN (node
), indent
+ 4);
744 print_node (file
, "static_chain", CALL_EXPR_STATIC_CHAIN (node
),
747 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
749 /* Buffer big enough to format a 32-bit UINT_MAX into, plus
752 sprintf (temp
, "arg:%u", i
);
753 print_node (file
, temp
, arg
, indent
+ 4);
759 len
= TREE_OPERAND_LENGTH (node
);
761 for (i
= 0; i
< len
; i
++)
763 /* Buffer big enough to format a 32-bit UINT_MAX into, plus
767 sprintf (temp
, "arg:%d", i
);
768 print_node (file
, temp
, TREE_OPERAND (node
, i
), indent
+ 4);
771 if (CODE_CONTAINS_STRUCT (code
, TS_COMMON
))
772 print_node (file
, "chain", TREE_CHAIN (node
), indent
+ 4);
776 case tcc_exceptional
:
780 if (TREE_OVERFLOW (node
))
781 fprintf (file
, " overflow");
784 print_dec (wi::to_wide (node
), file
, TYPE_SIGN (TREE_TYPE (node
)));
788 print_real_cst (file
, node
, false);
796 if (TREE_OVERFLOW (node
))
797 fprintf (file
, " overflow");
799 f
= TREE_FIXED_CST (node
);
800 fixed_to_decimal (string
, &f
, sizeof (string
));
801 fprintf (file
, " %s", string
);
807 /* Big enough for UINT_MAX plus the string below. */
810 fprintf (file
, " npatterns:%u nelts-per-pattern:%u",
811 VECTOR_CST_NPATTERNS (node
),
812 VECTOR_CST_NELTS_PER_PATTERN (node
));
813 unsigned int count
= vector_cst_encoded_nelts (node
);
814 for (unsigned int i
= 0; i
< count
; ++i
)
816 sprintf (buf
, "elt:%u: ", i
);
817 print_node (file
, buf
, VECTOR_CST_ENCODED_ELT (node
, i
),
824 print_node (file
, "real", TREE_REALPART (node
), indent
+ 4);
825 print_node (file
, "imag", TREE_IMAGPART (node
), indent
+ 4);
830 const char *p
= TREE_STRING_POINTER (node
);
831 int i
= TREE_STRING_LENGTH (node
);
836 if (ch
>= ' ' && ch
< 127)
839 fprintf (file
, "\\%03o", ch
& 0xFF);
848 for (unsigned int i
= 0; i
< NUM_POLY_INT_COEFFS
; ++i
)
850 snprintf (buf
, sizeof (buf
), "elt%u: ", i
);
851 print_node (file
, buf
, POLY_INT_CST_COEFF (node
, i
),
857 case IDENTIFIER_NODE
:
858 lang_hooks
.print_identifier (file
, node
, indent
);
862 print_node (file
, "purpose", TREE_PURPOSE (node
), indent
+ 4);
863 print_node (file
, "value", TREE_VALUE (node
), indent
+ 4);
864 print_node (file
, "chain", TREE_CHAIN (node
), indent
+ 4);
868 len
= TREE_VEC_LENGTH (node
);
869 fprintf (file
, " length:%d", len
);
870 for (i
= 0; i
< len
; i
++)
871 if (TREE_VEC_ELT (node
, i
))
873 /* Buffer big enough to format a 32-bit UINT_MAX into, plus
876 sprintf (temp
, "elt:%d", i
);
877 print_node (file
, temp
, TREE_VEC_ELT (node
, i
), indent
+ 4);
883 unsigned HOST_WIDE_INT cnt
;
885 len
= CONSTRUCTOR_NELTS (node
);
886 fprintf (file
, " length:%d", len
);
887 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
),
890 print_node (file
, "idx", index
, indent
+ 4, false);
891 print_node (file
, "val", value
, indent
+ 4, false);
897 dump_addr (file
, " head ", node
->stmt_list
.head
);
898 dump_addr (file
, " tail ", node
->stmt_list
.tail
);
899 fprintf (file
, " stmts");
901 tree_stmt_iterator i
;
902 for (i
= tsi_start (node
); !tsi_end_p (i
); tsi_next (&i
))
904 /* Not printing the addresses of the (not-a-tree)
905 'struct tree_stmt_list_node's. */
906 dump_addr (file
, " ", tsi_stmt (i
));
908 fprintf (file
, "\n");
909 for (i
= tsi_start (node
); !tsi_end_p (i
); tsi_next (&i
))
911 /* Not printing the addresses of the (not-a-tree)
912 'struct tree_stmt_list_node's. */
913 print_node (file
, "stmt", tsi_stmt (i
), indent
+ 4);
919 print_node (file
, "vars", BLOCK_VARS (node
), indent
+ 4);
920 print_node (file
, "supercontext", BLOCK_SUPERCONTEXT (node
),
922 print_node (file
, "subblocks", BLOCK_SUBBLOCKS (node
), indent
+ 4);
923 print_node (file
, "chain", BLOCK_CHAIN (node
), indent
+ 4);
924 print_node (file
, "abstract_origin",
925 BLOCK_ABSTRACT_ORIGIN (node
), indent
+ 4);
929 print_node_brief (file
, "var", SSA_NAME_VAR (node
), indent
+ 4);
930 indent_to (file
, indent
+ 4);
931 fprintf (file
, "def_stmt ");
933 pretty_printer buffer
;
934 buffer
.buffer
->stream
= file
;
935 pp_gimple_stmt_1 (&buffer
, SSA_NAME_DEF_STMT (node
), indent
+ 4,
940 indent_to (file
, indent
+ 4);
941 fprintf (file
, "version:%u", SSA_NAME_VERSION (node
));
942 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
943 fprintf (file
, " in-abnormal-phi");
944 if (SSA_NAME_IN_FREE_LIST (node
))
945 fprintf (file
, " in-free-list");
947 if (SSA_NAME_PTR_INFO (node
))
949 indent_to (file
, indent
+ 3);
950 if (SSA_NAME_PTR_INFO (node
))
951 dump_addr (file
, " ptr-info ", SSA_NAME_PTR_INFO (node
));
958 fprintf (file
, " %s",
959 omp_clause_code_name
[OMP_CLAUSE_CODE (node
)]);
960 for (i
= 0; i
< omp_clause_num_ops
[OMP_CLAUSE_CODE (node
)]; i
++)
962 indent_to (file
, indent
+ 4);
963 fprintf (file
, "op-%d:", i
);
964 print_node_brief (file
, "", OMP_CLAUSE_OPERAND (node
, i
), 0);
969 case OPTIMIZATION_NODE
:
970 cl_optimization_print (file
, indent
+ 4, TREE_OPTIMIZATION (node
));
973 case TARGET_OPTION_NODE
:
974 cl_target_option_print (file
, indent
+ 4, TREE_TARGET_OPTION (node
));
977 fprintf (file
, " imported-declaration");
978 print_node_brief (file
, "associated-declaration",
979 IMPORTED_DECL_ASSOCIATED_DECL (node
),
984 fprintf (file
, " bases:%d",
985 vec_safe_length (BINFO_BASE_BINFOS (node
)));
986 print_node_brief (file
, "offset", BINFO_OFFSET (node
), indent
+ 4);
987 print_node_brief (file
, "virtuals", BINFO_VIRTUALS (node
),
989 print_node_brief (file
, "inheritance-chain",
990 BINFO_INHERITANCE_CHAIN (node
),
995 if (EXCEPTIONAL_CLASS_P (node
))
996 lang_hooks
.print_xnode (file
, node
, indent
);
1003 if (EXPR_HAS_LOCATION (node
))
1005 expanded_location xloc
= expand_location (EXPR_LOCATION (node
));
1006 indent_to (file
, indent
+4);
1007 fprintf (file
, "%s:%d:%d", xloc
.file
, xloc
.line
, xloc
.column
);
1009 /* Print the range, if any */
1010 source_range r
= EXPR_LOCATION_RANGE (node
);
1013 xloc
= expand_location (r
.m_start
);
1014 fprintf (file
, " start: %s:%d:%d", xloc
.file
, xloc
.line
, xloc
.column
);
1018 fprintf (file
, " start: unknown");
1022 xloc
= expand_location (r
.m_finish
);
1023 fprintf (file
, " finish: %s:%d:%d", xloc
.file
, xloc
.line
, xloc
.column
);
1027 fprintf (file
, " finish: unknown");
1031 fprintf (file
, ">");
1035 /* Print the node NODE on standard error, for debugging.
1036 Most nodes referred to by this one are printed recursively
1037 down to a depth of six. */
1040 debug_tree (tree node
)
1042 table
= new hash_set
<tree
> (HASH_SIZE
);
1043 print_node (stderr
, "", node
, 0);
1046 putc ('\n', stderr
);
1050 debug_raw (const tree_node
&ref
)
1052 debug_tree (const_cast <tree
> (&ref
));
1056 debug_raw (const tree_node
*ptr
)
1061 fprintf (stderr
, "<nil>\n");
1065 dump_tree_via_hooks (const tree_node
*ptr
, dump_flags_t options
)
1068 lang_hooks
.print_decl (stderr
, const_cast <tree_node
*> (ptr
), 0);
1069 else if (TYPE_P (ptr
))
1070 lang_hooks
.print_type (stderr
, const_cast <tree_node
*> (ptr
), 0);
1071 else if (TREE_CODE (ptr
) == IDENTIFIER_NODE
)
1072 lang_hooks
.print_identifier (stderr
, const_cast <tree_node
*> (ptr
), 0);
1074 print_generic_expr (stderr
, const_cast <tree_node
*> (ptr
), options
);
1075 fprintf (stderr
, "\n");
1079 debug (const tree_node
&ref
)
1081 dump_tree_via_hooks (&ref
, TDF_NONE
);
1085 debug (const tree_node
*ptr
)
1090 fprintf (stderr
, "<nil>\n");
1094 debug_head (const tree_node
&ref
)
1100 debug_head (const tree_node
*ptr
)
1105 fprintf (stderr
, "<nil>\n");
1109 debug_body (const tree_node
&ref
)
1111 if (TREE_CODE (&ref
) == FUNCTION_DECL
)
1112 dump_function_to_file (const_cast <tree_node
*> (&ref
), stderr
, TDF_NONE
);
1118 debug_body (const tree_node
*ptr
)
1123 fprintf (stderr
, "<nil>\n");
1126 /* Print the vector of trees VEC on standard error, for debugging.
1127 Most nodes referred to by this one are printed recursively
1128 down to a depth of six. */
1131 debug_raw (vec
<tree
, va_gc
> &ref
)
1136 /* Print the slot this node is in, and its code, and address. */
1137 fprintf (stderr
, "<VEC");
1138 dump_addr (stderr
, " ", ref
.address ());
1140 FOR_EACH_VEC_ELT (ref
, ix
, elt
)
1142 fprintf (stderr
, "elt:%d ", ix
);
1148 debug_raw (vec
<tree
, va_gc
> *ptr
)
1153 fprintf (stderr
, "<nil>\n");
1159 print_node_brief (stderr
, "", t
, 0);
1162 DEFINE_DEBUG_VEC (tree
)
1163 DEFINE_DEBUG_HASH_SET (tree
)