1 /* Prints out tree in human readable form - GCC
2 Copyright (C) 1990-2014 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 "print-rtl.h"
28 #include "stor-layout.h"
30 #include "langhooks.h"
31 #include "tree-iterator.h"
32 #include "diagnostic.h"
33 #include "gimple-pretty-print.h" /* FIXME */
36 #include "tree-dump.h"
38 #include "wide-int-print.h"
40 /* Define the hash table of nodes already seen.
41 Such nodes are not repeated; brief cross-references are used. */
51 static struct bucket
**table
;
53 /* Print PREFIX and ADDR to FILE. */
55 dump_addr (FILE *file
, const char *prefix
, const void *addr
)
57 if (flag_dump_noaddr
|| flag_dump_unnumbered
)
58 fprintf (file
, "%s#", prefix
);
60 fprintf (file
, "%s" HOST_PTR_PRINTF
, prefix
, addr
);
63 /* Print a node in brief fashion, with just the code, address and name. */
66 print_node_brief (FILE *file
, const char *prefix
, const_tree node
, int indent
)
68 enum tree_code_class tclass
;
73 tclass
= TREE_CODE_CLASS (TREE_CODE (node
));
75 /* Always print the slot this node is in, and its code, address and
79 fprintf (file
, "%s <%s", prefix
, get_tree_code_name (TREE_CODE (node
)));
80 dump_addr (file
, " ", node
);
82 if (tclass
== tcc_declaration
)
85 fprintf (file
, " %s", IDENTIFIER_POINTER (DECL_NAME (node
)));
86 else if (TREE_CODE (node
) == LABEL_DECL
87 && LABEL_DECL_UID (node
) != -1)
89 if (dump_flags
& TDF_NOUID
)
90 fprintf (file
, " L.xxxx");
92 fprintf (file
, " L.%d", (int) LABEL_DECL_UID (node
));
96 if (dump_flags
& TDF_NOUID
)
97 fprintf (file
, " %c.xxxx",
98 TREE_CODE (node
) == CONST_DECL
? 'C' : 'D');
100 fprintf (file
, " %c.%u",
101 TREE_CODE (node
) == CONST_DECL
? 'C' : 'D',
105 else if (tclass
== tcc_type
)
107 if (TYPE_NAME (node
))
109 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
110 fprintf (file
, " %s", IDENTIFIER_POINTER (TYPE_NAME (node
)));
111 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
112 && DECL_NAME (TYPE_NAME (node
)))
113 fprintf (file
, " %s",
114 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node
))));
116 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
117 fprintf (file
, " address-space-%d", TYPE_ADDR_SPACE (node
));
119 if (TREE_CODE (node
) == IDENTIFIER_NODE
)
120 fprintf (file
, " %s", IDENTIFIER_POINTER (node
));
122 /* We might as well always print the value of an integer or real. */
123 if (TREE_CODE (node
) == INTEGER_CST
)
125 if (TREE_OVERFLOW (node
))
126 fprintf (file
, " overflow");
129 print_dec (node
, file
, TYPE_SIGN (TREE_TYPE (node
)));
131 if (TREE_CODE (node
) == REAL_CST
)
135 if (TREE_OVERFLOW (node
))
136 fprintf (file
, " overflow");
138 d
= TREE_REAL_CST (node
);
139 if (REAL_VALUE_ISINF (d
))
140 fprintf (file
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
141 else if (REAL_VALUE_ISNAN (d
))
142 fprintf (file
, " Nan");
146 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
147 fprintf (file
, " %s", string
);
150 if (TREE_CODE (node
) == FIXED_CST
)
155 if (TREE_OVERFLOW (node
))
156 fprintf (file
, " overflow");
158 f
= TREE_FIXED_CST (node
);
159 fixed_to_decimal (string
, &f
, sizeof (string
));
160 fprintf (file
, " %s", string
);
167 indent_to (FILE *file
, int column
)
171 /* Since this is the long way, indent to desired column. */
173 fprintf (file
, "\n");
174 for (i
= 0; i
< column
; i
++)
178 /* Print the node NODE in full on file FILE, preceded by PREFIX,
179 starting in column INDENT. */
182 print_node (FILE *file
, const char *prefix
, tree node
, int indent
)
186 enum machine_mode mode
;
187 enum tree_code_class tclass
;
190 expanded_location xloc
;
196 code
= TREE_CODE (node
);
197 tclass
= TREE_CODE_CLASS (code
);
199 /* Don't get too deep in nesting. If the user wants to see deeper,
200 it is easy to use the address of a lowest-level node
201 as an argument in another call to debug_tree. */
205 print_node_brief (file
, prefix
, node
, indent
);
209 if (indent
> 8 && (tclass
== tcc_type
|| tclass
== tcc_declaration
))
211 print_node_brief (file
, prefix
, node
, indent
);
215 /* It is unsafe to look at any other fields of an ERROR_MARK node. */
216 if (code
== ERROR_MARK
)
218 print_node_brief (file
, prefix
, node
, indent
);
222 /* Allow this function to be called if the table is not there. */
225 hash
= ((uintptr_t) node
) % HASH_SIZE
;
227 /* If node is in the table, just mention its address. */
228 for (b
= table
[hash
]; b
; b
= b
->next
)
231 print_node_brief (file
, prefix
, node
, indent
);
235 /* Add this node to the table. */
236 b
= XNEW (struct bucket
);
238 b
->next
= table
[hash
];
242 /* Indent to the specified column, since this is the long form. */
243 indent_to (file
, indent
);
245 /* Print the slot this node is in, and its code, and address. */
246 fprintf (file
, "%s <%s", prefix
, get_tree_code_name (code
));
247 dump_addr (file
, " ", node
);
249 /* Print the name, if any. */
250 if (tclass
== tcc_declaration
)
252 if (DECL_NAME (node
))
253 fprintf (file
, " %s", IDENTIFIER_POINTER (DECL_NAME (node
)));
254 else if (code
== LABEL_DECL
255 && LABEL_DECL_UID (node
) != -1)
257 if (dump_flags
& TDF_NOUID
)
258 fprintf (file
, " L.xxxx");
260 fprintf (file
, " L.%d", (int) LABEL_DECL_UID (node
));
264 if (dump_flags
& TDF_NOUID
)
265 fprintf (file
, " %c.xxxx", code
== CONST_DECL
? 'C' : 'D');
267 fprintf (file
, " %c.%u", code
== CONST_DECL
? 'C' : 'D',
271 else if (tclass
== tcc_type
)
273 if (TYPE_NAME (node
))
275 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
276 fprintf (file
, " %s", IDENTIFIER_POINTER (TYPE_NAME (node
)));
277 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
278 && DECL_NAME (TYPE_NAME (node
)))
279 fprintf (file
, " %s",
280 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node
))));
283 if (code
== IDENTIFIER_NODE
)
284 fprintf (file
, " %s", IDENTIFIER_POINTER (node
));
286 if (code
== INTEGER_CST
)
289 print_node_brief (file
, "type", TREE_TYPE (node
), indent
+ 4);
291 else if (CODE_CONTAINS_STRUCT (code
, TS_TYPED
))
293 print_node (file
, "type", TREE_TYPE (node
), indent
+ 4);
294 if (TREE_TYPE (node
))
295 indent_to (file
, indent
+ 3);
298 if (!TYPE_P (node
) && TREE_SIDE_EFFECTS (node
))
299 fputs (" side-effects", file
);
301 if (TYPE_P (node
) ? TYPE_READONLY (node
) : TREE_READONLY (node
))
302 fputs (" readonly", file
);
303 if (TYPE_P (node
) && TYPE_ATOMIC (node
))
304 fputs (" atomic", file
);
305 if (!TYPE_P (node
) && TREE_CONSTANT (node
))
306 fputs (" constant", file
);
307 else if (TYPE_P (node
) && TYPE_SIZES_GIMPLIFIED (node
))
308 fputs (" sizes-gimplified", file
);
310 if (TYPE_P (node
) && !ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node
)))
311 fprintf (file
, " address-space-%d", TYPE_ADDR_SPACE (node
));
313 if (TREE_ADDRESSABLE (node
))
314 fputs (" addressable", file
);
315 if (TREE_THIS_VOLATILE (node
))
316 fputs (" volatile", file
);
317 if (TREE_ASM_WRITTEN (node
))
318 fputs (" asm_written", file
);
319 if (TREE_USED (node
))
320 fputs (" used", file
);
321 if (TREE_NOTHROW (node
))
322 fputs (TYPE_P (node
) ? " align-ok" : " nothrow", file
);
323 if (TREE_PUBLIC (node
))
324 fputs (" public", file
);
325 if (TREE_PRIVATE (node
))
326 fputs (" private", file
);
327 if (TREE_PROTECTED (node
))
328 fputs (" protected", file
);
329 if (TREE_STATIC (node
))
330 fputs (" static", file
);
331 if (TREE_DEPRECATED (node
))
332 fputs (" deprecated", file
);
333 if (TREE_VISITED (node
))
334 fputs (" visited", file
);
336 if (code
!= TREE_VEC
&& code
!= INTEGER_CST
&& code
!= SSA_NAME
)
338 if (TREE_LANG_FLAG_0 (node
))
339 fputs (" tree_0", file
);
340 if (TREE_LANG_FLAG_1 (node
))
341 fputs (" tree_1", file
);
342 if (TREE_LANG_FLAG_2 (node
))
343 fputs (" tree_2", file
);
344 if (TREE_LANG_FLAG_3 (node
))
345 fputs (" tree_3", file
);
346 if (TREE_LANG_FLAG_4 (node
))
347 fputs (" tree_4", file
);
348 if (TREE_LANG_FLAG_5 (node
))
349 fputs (" tree_5", file
);
350 if (TREE_LANG_FLAG_6 (node
))
351 fputs (" tree_6", file
);
354 /* DECL_ nodes have additional attributes. */
356 switch (TREE_CODE_CLASS (code
))
358 case tcc_declaration
:
359 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_COMMON
))
361 if (DECL_UNSIGNED (node
))
362 fputs (" unsigned", file
);
363 if (DECL_IGNORED_P (node
))
364 fputs (" ignored", file
);
365 if (DECL_ABSTRACT (node
))
366 fputs (" abstract", file
);
367 if (DECL_EXTERNAL (node
))
368 fputs (" external", file
);
369 if (DECL_NONLOCAL (node
))
370 fputs (" nonlocal", file
);
372 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_WITH_VIS
))
374 if (DECL_WEAK (node
))
375 fputs (" weak", file
);
376 if (DECL_IN_SYSTEM_HEADER (node
))
377 fputs (" in_system_header", file
);
379 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_WRTL
)
380 && code
!= LABEL_DECL
381 && code
!= FUNCTION_DECL
382 && DECL_REGISTER (node
))
383 fputs (" regdecl", file
);
385 if (code
== TYPE_DECL
&& TYPE_DECL_SUPPRESS_DEBUG (node
))
386 fputs (" suppress-debug", file
);
388 if (code
== FUNCTION_DECL
389 && DECL_FUNCTION_SPECIFIC_TARGET (node
))
390 fputs (" function-specific-target", file
);
391 if (code
== FUNCTION_DECL
392 && DECL_FUNCTION_SPECIFIC_OPTIMIZATION (node
))
393 fputs (" function-specific-opt", file
);
394 if (code
== FUNCTION_DECL
&& DECL_DECLARED_INLINE_P (node
))
395 fputs (" autoinline", file
);
396 if (code
== FUNCTION_DECL
&& DECL_BUILT_IN (node
))
397 fputs (" built-in", file
);
398 if (code
== FUNCTION_DECL
&& DECL_STATIC_CHAIN (node
))
399 fputs (" static-chain", file
);
400 if (TREE_CODE (node
) == FUNCTION_DECL
&& decl_is_tm_clone (node
))
401 fputs (" tm-clone", file
);
403 if (code
== FIELD_DECL
&& DECL_PACKED (node
))
404 fputs (" packed", file
);
405 if (code
== FIELD_DECL
&& DECL_BIT_FIELD (node
))
406 fputs (" bit-field", file
);
407 if (code
== FIELD_DECL
&& DECL_NONADDRESSABLE_P (node
))
408 fputs (" nonaddressable", file
);
410 if (code
== LABEL_DECL
&& EH_LANDING_PAD_NR (node
))
411 fprintf (file
, " landing-pad:%d", EH_LANDING_PAD_NR (node
));
413 if (code
== VAR_DECL
&& DECL_IN_TEXT_SECTION (node
))
414 fputs (" in-text-section", file
);
415 if (code
== VAR_DECL
&& DECL_IN_CONSTANT_POOL (node
))
416 fputs (" in-constant-pool", file
);
417 if (code
== VAR_DECL
&& DECL_COMMON (node
))
418 fputs (" common", file
);
419 if (code
== VAR_DECL
&& DECL_THREAD_LOCAL_P (node
))
421 enum tls_model kind
= DECL_TLS_MODEL (node
);
424 case TLS_MODEL_GLOBAL_DYNAMIC
:
425 fputs (" tls-global-dynamic", file
);
427 case TLS_MODEL_LOCAL_DYNAMIC
:
428 fputs (" tls-local-dynamic", file
);
430 case TLS_MODEL_INITIAL_EXEC
:
431 fputs (" tls-initial-exec", file
);
433 case TLS_MODEL_LOCAL_EXEC
:
434 fputs (" tls-local-exec", file
);
441 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_COMMON
))
443 if (DECL_VIRTUAL_P (node
))
444 fputs (" virtual", file
);
445 if (DECL_PRESERVE_P (node
))
446 fputs (" preserve", file
);
447 if (DECL_LANG_FLAG_0 (node
))
448 fputs (" decl_0", file
);
449 if (DECL_LANG_FLAG_1 (node
))
450 fputs (" decl_1", file
);
451 if (DECL_LANG_FLAG_2 (node
))
452 fputs (" decl_2", file
);
453 if (DECL_LANG_FLAG_3 (node
))
454 fputs (" decl_3", file
);
455 if (DECL_LANG_FLAG_4 (node
))
456 fputs (" decl_4", file
);
457 if (DECL_LANG_FLAG_5 (node
))
458 fputs (" decl_5", file
);
459 if (DECL_LANG_FLAG_6 (node
))
460 fputs (" decl_6", file
);
461 if (DECL_LANG_FLAG_7 (node
))
462 fputs (" decl_7", file
);
464 mode
= DECL_MODE (node
);
465 fprintf (file
, " %s", GET_MODE_NAME (mode
));
468 if ((code
== VAR_DECL
|| code
== PARM_DECL
|| code
== RESULT_DECL
)
469 && DECL_BY_REFERENCE (node
))
470 fputs (" passed-by-reference", file
);
472 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_WITH_VIS
) && DECL_DEFER_OUTPUT (node
))
473 fputs (" defer-output", file
);
476 xloc
= expand_location (DECL_SOURCE_LOCATION (node
));
477 fprintf (file
, " file %s line %d col %d", xloc
.file
, xloc
.line
,
480 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_COMMON
))
482 print_node (file
, "size", DECL_SIZE (node
), indent
+ 4);
483 print_node (file
, "unit size", DECL_SIZE_UNIT (node
), indent
+ 4);
485 if (code
!= FUNCTION_DECL
|| DECL_BUILT_IN (node
))
486 indent_to (file
, indent
+ 3);
488 if (DECL_USER_ALIGN (node
))
489 fprintf (file
, " user");
491 fprintf (file
, " align %d", DECL_ALIGN (node
));
492 if (code
== FIELD_DECL
)
493 fprintf (file
, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED
,
494 DECL_OFFSET_ALIGN (node
));
496 if (code
== FUNCTION_DECL
&& DECL_BUILT_IN (node
))
498 if (DECL_BUILT_IN_CLASS (node
) == BUILT_IN_MD
)
499 fprintf (file
, " built-in BUILT_IN_MD %d", DECL_FUNCTION_CODE (node
));
501 fprintf (file
, " built-in %s:%s",
502 built_in_class_names
[(int) DECL_BUILT_IN_CLASS (node
)],
503 built_in_names
[(int) DECL_FUNCTION_CODE (node
)]);
506 if (code
== FIELD_DECL
)
508 print_node (file
, "offset", DECL_FIELD_OFFSET (node
), indent
+ 4);
509 print_node (file
, "bit offset", DECL_FIELD_BIT_OFFSET (node
),
511 if (DECL_BIT_FIELD_TYPE (node
))
512 print_node (file
, "bit_field_type", DECL_BIT_FIELD_TYPE (node
),
516 print_node_brief (file
, "context", DECL_CONTEXT (node
), indent
+ 4);
518 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_COMMON
))
520 print_node_brief (file
, "attributes",
521 DECL_ATTRIBUTES (node
), indent
+ 4);
522 if (code
!= PARM_DECL
)
523 print_node_brief (file
, "initial", DECL_INITIAL (node
),
526 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_WRTL
))
528 print_node_brief (file
, "abstract_origin",
529 DECL_ABSTRACT_ORIGIN (node
), indent
+ 4);
531 if (CODE_CONTAINS_STRUCT (code
, TS_DECL_NON_COMMON
))
533 print_node (file
, "arguments", DECL_ARGUMENT_FLD (node
), indent
+ 4);
534 print_node (file
, "result", DECL_RESULT_FLD (node
), indent
+ 4);
537 lang_hooks
.print_decl (file
, node
, indent
);
539 if (DECL_RTL_SET_P (node
))
541 indent_to (file
, indent
+ 4);
542 print_rtl (file
, DECL_RTL (node
));
545 if (code
== PARM_DECL
)
547 print_node (file
, "arg-type", DECL_ARG_TYPE (node
), indent
+ 4);
549 if (DECL_INCOMING_RTL (node
) != 0)
551 indent_to (file
, indent
+ 4);
552 fprintf (file
, "incoming-rtl ");
553 print_rtl (file
, DECL_INCOMING_RTL (node
));
556 else if (code
== FUNCTION_DECL
557 && DECL_STRUCT_FUNCTION (node
) != 0)
559 indent_to (file
, indent
+ 4);
560 dump_addr (file
, "struct-function ", DECL_STRUCT_FUNCTION (node
));
563 if ((code
== VAR_DECL
|| code
== PARM_DECL
)
564 && DECL_HAS_VALUE_EXPR_P (node
))
565 print_node (file
, "value-expr", DECL_VALUE_EXPR (node
), indent
+ 4);
567 /* Print the decl chain only if decl is at second level. */
569 print_node (file
, "chain", TREE_CHAIN (node
), indent
+ 4);
571 print_node_brief (file
, "chain", TREE_CHAIN (node
), indent
+ 4);
575 if (TYPE_UNSIGNED (node
))
576 fputs (" unsigned", file
);
578 if (TYPE_NO_FORCE_BLK (node
))
579 fputs (" no-force-blk", file
);
581 if (TYPE_STRING_FLAG (node
))
582 fputs (" string-flag", file
);
584 if (TYPE_NEEDS_CONSTRUCTING (node
))
585 fputs (" needs-constructing", file
);
587 /* The transparent-union flag is used for different things in
589 if ((code
== UNION_TYPE
|| code
== RECORD_TYPE
)
590 && TYPE_TRANSPARENT_AGGR (node
))
591 fputs (" transparent-aggr", file
);
592 else if (code
== ARRAY_TYPE
593 && TYPE_NONALIASED_COMPONENT (node
))
594 fputs (" nonaliased-component", file
);
596 if (TYPE_PACKED (node
))
597 fputs (" packed", file
);
599 if (TYPE_RESTRICT (node
))
600 fputs (" restrict", file
);
602 if (TYPE_LANG_FLAG_0 (node
))
603 fputs (" type_0", file
);
604 if (TYPE_LANG_FLAG_1 (node
))
605 fputs (" type_1", file
);
606 if (TYPE_LANG_FLAG_2 (node
))
607 fputs (" type_2", file
);
608 if (TYPE_LANG_FLAG_3 (node
))
609 fputs (" type_3", file
);
610 if (TYPE_LANG_FLAG_4 (node
))
611 fputs (" type_4", file
);
612 if (TYPE_LANG_FLAG_5 (node
))
613 fputs (" type_5", file
);
614 if (TYPE_LANG_FLAG_6 (node
))
615 fputs (" type_6", file
);
617 mode
= TYPE_MODE (node
);
618 fprintf (file
, " %s", GET_MODE_NAME (mode
));
620 print_node (file
, "size", TYPE_SIZE (node
), indent
+ 4);
621 print_node (file
, "unit size", TYPE_SIZE_UNIT (node
), indent
+ 4);
622 indent_to (file
, indent
+ 3);
624 if (TYPE_USER_ALIGN (node
))
625 fprintf (file
, " user");
627 fprintf (file
, " align %d symtab %d alias set " HOST_WIDE_INT_PRINT_DEC
,
628 TYPE_ALIGN (node
), TYPE_SYMTAB_ADDRESS (node
),
629 (HOST_WIDE_INT
) TYPE_ALIAS_SET (node
));
631 if (TYPE_STRUCTURAL_EQUALITY_P (node
))
632 fprintf (file
, " structural equality");
634 dump_addr (file
, " canonical type ", TYPE_CANONICAL (node
));
636 print_node (file
, "attributes", TYPE_ATTRIBUTES (node
), indent
+ 4);
638 if (INTEGRAL_TYPE_P (node
) || code
== REAL_TYPE
639 || code
== FIXED_POINT_TYPE
)
641 fprintf (file
, " precision %d", TYPE_PRECISION (node
));
642 print_node_brief (file
, "min", TYPE_MIN_VALUE (node
), indent
+ 4);
643 print_node_brief (file
, "max", TYPE_MAX_VALUE (node
), indent
+ 4);
646 if (code
== ENUMERAL_TYPE
)
647 print_node (file
, "values", TYPE_VALUES (node
), indent
+ 4);
648 else if (code
== ARRAY_TYPE
)
649 print_node (file
, "domain", TYPE_DOMAIN (node
), indent
+ 4);
650 else if (code
== VECTOR_TYPE
)
651 fprintf (file
, " nunits %d", (int) TYPE_VECTOR_SUBPARTS (node
));
652 else if (code
== RECORD_TYPE
653 || code
== UNION_TYPE
654 || code
== QUAL_UNION_TYPE
)
655 print_node (file
, "fields", TYPE_FIELDS (node
), indent
+ 4);
656 else if (code
== FUNCTION_TYPE
657 || code
== METHOD_TYPE
)
659 if (TYPE_METHOD_BASETYPE (node
))
660 print_node_brief (file
, "method basetype",
661 TYPE_METHOD_BASETYPE (node
), indent
+ 4);
662 print_node (file
, "arg-types", TYPE_ARG_TYPES (node
), indent
+ 4);
664 else if (code
== OFFSET_TYPE
)
665 print_node_brief (file
, "basetype", TYPE_OFFSET_BASETYPE (node
),
668 if (TYPE_CONTEXT (node
))
669 print_node_brief (file
, "context", TYPE_CONTEXT (node
), indent
+ 4);
671 lang_hooks
.print_type (file
, node
, indent
);
673 if (TYPE_POINTER_TO (node
) || TREE_CHAIN (node
))
674 indent_to (file
, indent
+ 3);
676 print_node_brief (file
, "pointer_to_this", TYPE_POINTER_TO (node
),
678 print_node_brief (file
, "reference_to_this", TYPE_REFERENCE_TO (node
),
680 print_node_brief (file
, "chain", TREE_CHAIN (node
), indent
+ 4);
690 if (code
== BIND_EXPR
)
692 print_node (file
, "vars", TREE_OPERAND (node
, 0), indent
+ 4);
693 print_node (file
, "body", TREE_OPERAND (node
, 1), indent
+ 4);
694 print_node (file
, "block", TREE_OPERAND (node
, 2), indent
+ 4);
697 if (code
== CALL_EXPR
)
699 call_expr_arg_iterator iter
;
701 print_node (file
, "fn", CALL_EXPR_FN (node
), indent
+ 4);
702 print_node (file
, "static_chain", CALL_EXPR_STATIC_CHAIN (node
),
705 FOR_EACH_CALL_EXPR_ARG (arg
, iter
, node
)
708 sprintf (temp
, "arg %d", i
);
709 print_node (file
, temp
, arg
, indent
+ 4);
715 len
= TREE_OPERAND_LENGTH (node
);
717 for (i
= 0; i
< len
; i
++)
721 sprintf (temp
, "arg %d", i
);
722 print_node (file
, temp
, TREE_OPERAND (node
, i
), indent
+ 4);
725 if (CODE_CONTAINS_STRUCT (code
, TS_COMMON
))
726 print_node (file
, "chain", TREE_CHAIN (node
), indent
+ 4);
730 case tcc_exceptional
:
734 if (TREE_OVERFLOW (node
))
735 fprintf (file
, " overflow");
738 print_dec (node
, file
, TYPE_SIGN (TREE_TYPE (node
)));
745 if (TREE_OVERFLOW (node
))
746 fprintf (file
, " overflow");
748 d
= TREE_REAL_CST (node
);
749 if (REAL_VALUE_ISINF (d
))
750 fprintf (file
, REAL_VALUE_NEGATIVE (d
) ? " -Inf" : " Inf");
751 else if (REAL_VALUE_ISNAN (d
))
752 fprintf (file
, " Nan");
756 real_to_decimal (string
, &d
, sizeof (string
), 0, 1);
757 fprintf (file
, " %s", string
);
767 if (TREE_OVERFLOW (node
))
768 fprintf (file
, " overflow");
770 f
= TREE_FIXED_CST (node
);
771 fixed_to_decimal (string
, &f
, sizeof (string
));
772 fprintf (file
, " %s", string
);
781 for (i
= 0; i
< VECTOR_CST_NELTS (node
); ++i
)
783 sprintf (buf
, "elt%u: ", i
);
784 print_node (file
, buf
, VECTOR_CST_ELT (node
, i
), indent
+ 4);
790 print_node (file
, "real", TREE_REALPART (node
), indent
+ 4);
791 print_node (file
, "imag", TREE_IMAGPART (node
), indent
+ 4);
796 const char *p
= TREE_STRING_POINTER (node
);
797 int i
= TREE_STRING_LENGTH (node
);
802 if (ch
>= ' ' && ch
< 127)
805 fprintf (file
, "\\%03o", ch
& 0xFF);
811 case IDENTIFIER_NODE
:
812 lang_hooks
.print_identifier (file
, node
, indent
);
816 print_node (file
, "purpose", TREE_PURPOSE (node
), indent
+ 4);
817 print_node (file
, "value", TREE_VALUE (node
), indent
+ 4);
818 print_node (file
, "chain", TREE_CHAIN (node
), indent
+ 4);
822 len
= TREE_VEC_LENGTH (node
);
823 for (i
= 0; i
< len
; i
++)
824 if (TREE_VEC_ELT (node
, i
))
827 sprintf (temp
, "elt %d", i
);
828 print_node (file
, temp
, TREE_VEC_ELT (node
, i
), indent
+ 4);
834 unsigned HOST_WIDE_INT cnt
;
836 len
= vec_safe_length (CONSTRUCTOR_ELTS (node
));
837 fprintf (file
, " lngt %d", len
);
838 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node
),
841 print_node (file
, "idx", index
, indent
+ 4);
842 print_node (file
, "val", value
, indent
+ 4);
848 dump_addr (file
, " head ", node
->stmt_list
.head
);
849 dump_addr (file
, " tail ", node
->stmt_list
.tail
);
850 fprintf (file
, " stmts");
852 tree_stmt_iterator i
;
853 for (i
= tsi_start (node
); !tsi_end_p (i
); tsi_next (&i
))
855 /* Not printing the addresses of the (not-a-tree)
856 'struct tree_stmt_list_node's. */
857 dump_addr (file
, " ", tsi_stmt (i
));
859 fprintf (file
, "\n");
860 for (i
= tsi_start (node
); !tsi_end_p (i
); tsi_next (&i
))
862 /* Not printing the addresses of the (not-a-tree)
863 'struct tree_stmt_list_node's. */
864 print_node (file
, "stmt", tsi_stmt (i
), indent
+ 4);
870 print_node (file
, "vars", BLOCK_VARS (node
), indent
+ 4);
871 print_node (file
, "supercontext", BLOCK_SUPERCONTEXT (node
),
873 print_node (file
, "subblocks", BLOCK_SUBBLOCKS (node
), indent
+ 4);
874 print_node (file
, "chain", BLOCK_CHAIN (node
), indent
+ 4);
875 print_node (file
, "abstract_origin",
876 BLOCK_ABSTRACT_ORIGIN (node
), indent
+ 4);
880 print_node_brief (file
, "var", SSA_NAME_VAR (node
), indent
+ 4);
881 fprintf (file
, "def_stmt ");
882 print_gimple_stmt (file
, SSA_NAME_DEF_STMT (node
), indent
+ 4, 0);
884 indent_to (file
, indent
+ 4);
885 fprintf (file
, "version %u", SSA_NAME_VERSION (node
));
886 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node
))
887 fprintf (file
, " in-abnormal-phi");
888 if (SSA_NAME_IN_FREE_LIST (node
))
889 fprintf (file
, " in-free-list");
891 if (SSA_NAME_PTR_INFO (node
))
893 indent_to (file
, indent
+ 3);
894 if (SSA_NAME_PTR_INFO (node
))
895 dump_addr (file
, " ptr-info ", SSA_NAME_PTR_INFO (node
));
902 fprintf (file
, " %s",
903 omp_clause_code_name
[OMP_CLAUSE_CODE (node
)]);
904 for (i
= 0; i
< omp_clause_num_ops
[OMP_CLAUSE_CODE (node
)]; i
++)
906 indent_to (file
, indent
+ 4);
907 fprintf (file
, "op %d:", i
);
908 print_node_brief (file
, "", OMP_CLAUSE_OPERAND (node
, i
), 0);
913 case OPTIMIZATION_NODE
:
914 cl_optimization_print (file
, indent
+ 4, TREE_OPTIMIZATION (node
));
917 case TARGET_OPTION_NODE
:
918 cl_target_option_print (file
, indent
+ 4, TREE_TARGET_OPTION (node
));
921 fprintf (file
, " imported declaration");
922 print_node_brief (file
, "associated declaration",
923 IMPORTED_DECL_ASSOCIATED_DECL (node
),
928 if (EXCEPTIONAL_CLASS_P (node
))
929 lang_hooks
.print_xnode (file
, node
, indent
);
936 if (EXPR_HAS_LOCATION (node
))
938 expanded_location xloc
= expand_location (EXPR_LOCATION (node
));
939 indent_to (file
, indent
+4);
940 fprintf (file
, "%s:%d:%d", xloc
.file
, xloc
.line
, xloc
.column
);
947 /* Print the node NODE on standard error, for debugging.
948 Most nodes referred to by this one are printed recursively
949 down to a depth of six. */
952 debug_tree (tree node
)
954 table
= XCNEWVEC (struct bucket
*, HASH_SIZE
);
955 print_node (stderr
, "", node
, 0);
962 debug_raw (const tree_node
&ref
)
964 debug_tree (const_cast <tree
> (&ref
));
968 debug_raw (const tree_node
*ptr
)
973 fprintf (stderr
, "<nil>\n");
977 dump_tree_via_hooks (const tree_node
*ptr
, int options
)
980 lang_hooks
.print_decl (stderr
, const_cast <tree_node
*> (ptr
), 0);
981 else if (TYPE_P (ptr
))
982 lang_hooks
.print_type (stderr
, const_cast <tree_node
*> (ptr
), 0);
983 else if (TREE_CODE (ptr
) == IDENTIFIER_NODE
)
984 lang_hooks
.print_identifier (stderr
, const_cast <tree_node
*> (ptr
), 0);
986 print_generic_expr (stderr
, const_cast <tree_node
*> (ptr
), options
);
987 fprintf (stderr
, "\n");
991 debug (const tree_node
&ref
)
993 dump_tree_via_hooks (&ref
, 0);
997 debug (const tree_node
*ptr
)
1002 fprintf (stderr
, "<nil>\n");
1006 debug_verbose (const tree_node
&ref
)
1008 dump_tree_via_hooks (&ref
, TDF_VERBOSE
);
1012 debug_verbose (const tree_node
*ptr
)
1015 debug_verbose (*ptr
);
1017 fprintf (stderr
, "<nil>\n");
1021 debug_head (const tree_node
&ref
)
1027 debug_head (const tree_node
*ptr
)
1032 fprintf (stderr
, "<nil>\n");
1036 debug_body (const tree_node
&ref
)
1038 if (TREE_CODE (&ref
) == FUNCTION_DECL
)
1039 dump_function_to_file (const_cast <tree_node
*> (&ref
), stderr
, 0);
1045 debug_body (const tree_node
*ptr
)
1050 fprintf (stderr
, "<nil>\n");
1053 /* Print the vector of trees VEC on standard error, for debugging.
1054 Most nodes referred to by this one are printed recursively
1055 down to a depth of six. */
1058 debug_raw (vec
<tree
, va_gc
> &ref
)
1063 /* Print the slot this node is in, and its code, and address. */
1064 fprintf (stderr
, "<VEC");
1065 dump_addr (stderr
, " ", ref
.address ());
1067 FOR_EACH_VEC_ELT (ref
, ix
, elt
)
1069 fprintf (stderr
, "elt %d ", ix
);
1075 debug (vec
<tree
, va_gc
> &ref
)
1080 /* Print the slot this node is in, and its code, and address. */
1081 fprintf (stderr
, "<VEC");
1082 dump_addr (stderr
, " ", ref
.address ());
1084 FOR_EACH_VEC_ELT (ref
, ix
, elt
)
1086 fprintf (stderr
, "elt %d ", ix
);
1092 debug (vec
<tree
, va_gc
> *ptr
)
1097 fprintf (stderr
, "<nil>\n");
1101 debug_raw (vec
<tree
, va_gc
> *ptr
)
1106 fprintf (stderr
, "<nil>\n");
1110 debug_vec_tree (vec
<tree
, va_gc
> *vec
)