* configure.ac: If the compiler supports -Qunused-arguments, use
[official-gcc.git] / gcc / print-tree.c
blob9563e4dfaec7c759405d54b82122b26891a32336
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
9 version.
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
14 for more details.
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/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "tree.h"
26 #include "varasm.h"
27 #include "print-rtl.h"
28 #include "stor-layout.h"
29 #include "ggc.h"
30 #include "langhooks.h"
31 #include "tree-iterator.h"
32 #include "diagnostic.h"
33 #include "gimple-pretty-print.h" /* FIXME */
34 #include "cgraph.h"
35 #include "tree-cfg.h"
36 #include "tree-dump.h"
37 #include "dumpfile.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. */
43 #define HASH_SIZE 37
45 struct bucket
47 tree node;
48 struct bucket *next;
51 static struct bucket **table;
53 /* Print PREFIX and ADDR to FILE. */
54 void
55 dump_addr (FILE *file, const char *prefix, const void *addr)
57 if (flag_dump_noaddr || flag_dump_unnumbered)
58 fprintf (file, "%s#", prefix);
59 else
60 fprintf (file, "%s" HOST_PTR_PRINTF, prefix, addr);
63 /* Print a node in brief fashion, with just the code, address and name. */
65 void
66 print_node_brief (FILE *file, const char *prefix, const_tree node, int indent)
68 enum tree_code_class tclass;
70 if (node == 0)
71 return;
73 tclass = TREE_CODE_CLASS (TREE_CODE (node));
75 /* Always print the slot this node is in, and its code, address and
76 name if any. */
77 if (indent > 0)
78 fprintf (file, " ");
79 fprintf (file, "%s <%s", prefix, get_tree_code_name (TREE_CODE (node)));
80 dump_addr (file, " ", node);
82 if (tclass == tcc_declaration)
84 if (DECL_NAME (node))
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");
91 else
92 fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
94 else
96 if (dump_flags & TDF_NOUID)
97 fprintf (file, " %c.xxxx",
98 TREE_CODE (node) == CONST_DECL ? 'C' : 'D');
99 else
100 fprintf (file, " %c.%u",
101 TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
102 DECL_UID (node));
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");
128 fprintf (file, " ");
129 print_dec (node, file, TYPE_SIGN (TREE_TYPE (node)));
131 if (TREE_CODE (node) == REAL_CST)
133 REAL_VALUE_TYPE d;
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");
143 else
145 char string[60];
146 real_to_decimal (string, &d, sizeof (string), 0, 1);
147 fprintf (file, " %s", string);
150 if (TREE_CODE (node) == FIXED_CST)
152 FIXED_VALUE_TYPE f;
153 char string[60];
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);
163 fprintf (file, ">");
166 void
167 indent_to (FILE *file, int column)
169 int i;
171 /* Since this is the long way, indent to desired column. */
172 if (column > 0)
173 fprintf (file, "\n");
174 for (i = 0; i < column; i++)
175 fprintf (file, " ");
178 /* Print the node NODE in full on file FILE, preceded by PREFIX,
179 starting in column INDENT. */
181 void
182 print_node (FILE *file, const char *prefix, tree node, int indent)
184 int hash;
185 struct bucket *b;
186 enum machine_mode mode;
187 enum tree_code_class tclass;
188 int len;
189 int i;
190 expanded_location xloc;
191 enum tree_code code;
193 if (node == 0)
194 return;
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. */
203 if (indent > 24)
205 print_node_brief (file, prefix, node, indent);
206 return;
209 if (indent > 8 && (tclass == tcc_type || tclass == tcc_declaration))
211 print_node_brief (file, prefix, node, indent);
212 return;
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);
219 return;
222 /* Allow this function to be called if the table is not there. */
223 if (table)
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)
229 if (b->node == node)
231 print_node_brief (file, prefix, node, indent);
232 return;
235 /* Add this node to the table. */
236 b = XNEW (struct bucket);
237 b->node = node;
238 b->next = table[hash];
239 table[hash] = b;
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");
259 else
260 fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
262 else
264 if (dump_flags & TDF_NOUID)
265 fprintf (file, " %c.xxxx", code == CONST_DECL ? 'C' : 'D');
266 else
267 fprintf (file, " %c.%u", code == CONST_DECL ? 'C' : 'D',
268 DECL_UID (node));
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)
288 if (indent <= 4)
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_P (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 fputs (" ", file);
422 fputs (tls_model_names[DECL_TLS_MODEL (node)], file);
425 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
427 if (DECL_VIRTUAL_P (node))
428 fputs (" virtual", file);
429 if (DECL_PRESERVE_P (node))
430 fputs (" preserve", file);
431 if (DECL_LANG_FLAG_0 (node))
432 fputs (" decl_0", file);
433 if (DECL_LANG_FLAG_1 (node))
434 fputs (" decl_1", file);
435 if (DECL_LANG_FLAG_2 (node))
436 fputs (" decl_2", file);
437 if (DECL_LANG_FLAG_3 (node))
438 fputs (" decl_3", file);
439 if (DECL_LANG_FLAG_4 (node))
440 fputs (" decl_4", file);
441 if (DECL_LANG_FLAG_5 (node))
442 fputs (" decl_5", file);
443 if (DECL_LANG_FLAG_6 (node))
444 fputs (" decl_6", file);
445 if (DECL_LANG_FLAG_7 (node))
446 fputs (" decl_7", file);
448 mode = DECL_MODE (node);
449 fprintf (file, " %s", GET_MODE_NAME (mode));
452 if ((code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL)
453 && DECL_BY_REFERENCE (node))
454 fputs (" passed-by-reference", file);
456 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS) && DECL_DEFER_OUTPUT (node))
457 fputs (" defer-output", file);
460 xloc = expand_location (DECL_SOURCE_LOCATION (node));
461 fprintf (file, " file %s line %d col %d", xloc.file, xloc.line,
462 xloc.column);
464 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
466 print_node (file, "size", DECL_SIZE (node), indent + 4);
467 print_node (file, "unit size", DECL_SIZE_UNIT (node), indent + 4);
469 if (code != FUNCTION_DECL || DECL_BUILT_IN (node))
470 indent_to (file, indent + 3);
472 if (DECL_USER_ALIGN (node))
473 fprintf (file, " user");
475 fprintf (file, " align %d", DECL_ALIGN (node));
476 if (code == FIELD_DECL)
477 fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED,
478 DECL_OFFSET_ALIGN (node));
480 if (code == FUNCTION_DECL && DECL_BUILT_IN (node))
482 if (DECL_BUILT_IN_CLASS (node) == BUILT_IN_MD)
483 fprintf (file, " built-in BUILT_IN_MD %d", DECL_FUNCTION_CODE (node));
484 else
485 fprintf (file, " built-in %s:%s",
486 built_in_class_names[(int) DECL_BUILT_IN_CLASS (node)],
487 built_in_names[(int) DECL_FUNCTION_CODE (node)]);
490 if (code == FIELD_DECL)
492 print_node (file, "offset", DECL_FIELD_OFFSET (node), indent + 4);
493 print_node (file, "bit offset", DECL_FIELD_BIT_OFFSET (node),
494 indent + 4);
495 if (DECL_BIT_FIELD_TYPE (node))
496 print_node (file, "bit_field_type", DECL_BIT_FIELD_TYPE (node),
497 indent + 4);
500 print_node_brief (file, "context", DECL_CONTEXT (node), indent + 4);
502 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
504 print_node_brief (file, "attributes",
505 DECL_ATTRIBUTES (node), indent + 4);
506 if (code != PARM_DECL)
507 print_node_brief (file, "initial", DECL_INITIAL (node),
508 indent + 4);
510 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL))
512 print_node_brief (file, "abstract_origin",
513 DECL_ABSTRACT_ORIGIN (node), indent + 4);
515 if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
517 print_node (file, "result", DECL_RESULT_FLD (node), indent + 4);
520 lang_hooks.print_decl (file, node, indent);
522 if (DECL_RTL_SET_P (node))
524 indent_to (file, indent + 4);
525 print_rtl (file, DECL_RTL (node));
528 if (code == PARM_DECL)
530 print_node (file, "arg-type", DECL_ARG_TYPE (node), indent + 4);
532 if (DECL_INCOMING_RTL (node) != 0)
534 indent_to (file, indent + 4);
535 fprintf (file, "incoming-rtl ");
536 print_rtl (file, DECL_INCOMING_RTL (node));
539 else if (code == FUNCTION_DECL
540 && DECL_STRUCT_FUNCTION (node) != 0)
542 print_node (file, "arguments", DECL_ARGUMENTS (node), indent + 4);
543 indent_to (file, indent + 4);
544 dump_addr (file, "struct-function ", DECL_STRUCT_FUNCTION (node));
547 if ((code == VAR_DECL || code == PARM_DECL)
548 && DECL_HAS_VALUE_EXPR_P (node))
549 print_node (file, "value-expr", DECL_VALUE_EXPR (node), indent + 4);
551 /* Print the decl chain only if decl is at second level. */
552 if (indent == 4)
553 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
554 else
555 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
556 break;
558 case tcc_type:
559 if (TYPE_UNSIGNED (node))
560 fputs (" unsigned", file);
562 if (TYPE_NO_FORCE_BLK (node))
563 fputs (" no-force-blk", file);
565 if (TYPE_STRING_FLAG (node))
566 fputs (" string-flag", file);
568 if (TYPE_NEEDS_CONSTRUCTING (node))
569 fputs (" needs-constructing", file);
571 /* The transparent-union flag is used for different things in
572 different nodes. */
573 if ((code == UNION_TYPE || code == RECORD_TYPE)
574 && TYPE_TRANSPARENT_AGGR (node))
575 fputs (" transparent-aggr", file);
576 else if (code == ARRAY_TYPE
577 && TYPE_NONALIASED_COMPONENT (node))
578 fputs (" nonaliased-component", file);
580 if (TYPE_PACKED (node))
581 fputs (" packed", file);
583 if (TYPE_RESTRICT (node))
584 fputs (" restrict", file);
586 if (TYPE_LANG_FLAG_0 (node))
587 fputs (" type_0", file);
588 if (TYPE_LANG_FLAG_1 (node))
589 fputs (" type_1", file);
590 if (TYPE_LANG_FLAG_2 (node))
591 fputs (" type_2", file);
592 if (TYPE_LANG_FLAG_3 (node))
593 fputs (" type_3", file);
594 if (TYPE_LANG_FLAG_4 (node))
595 fputs (" type_4", file);
596 if (TYPE_LANG_FLAG_5 (node))
597 fputs (" type_5", file);
598 if (TYPE_LANG_FLAG_6 (node))
599 fputs (" type_6", file);
601 mode = TYPE_MODE (node);
602 fprintf (file, " %s", GET_MODE_NAME (mode));
604 print_node (file, "size", TYPE_SIZE (node), indent + 4);
605 print_node (file, "unit size", TYPE_SIZE_UNIT (node), indent + 4);
606 indent_to (file, indent + 3);
608 if (TYPE_USER_ALIGN (node))
609 fprintf (file, " user");
611 fprintf (file, " align %d symtab %d alias set " HOST_WIDE_INT_PRINT_DEC,
612 TYPE_ALIGN (node), TYPE_SYMTAB_ADDRESS (node),
613 (HOST_WIDE_INT) TYPE_ALIAS_SET (node));
615 if (TYPE_STRUCTURAL_EQUALITY_P (node))
616 fprintf (file, " structural equality");
617 else
618 dump_addr (file, " canonical type ", TYPE_CANONICAL (node));
620 print_node (file, "attributes", TYPE_ATTRIBUTES (node), indent + 4);
622 if (INTEGRAL_TYPE_P (node) || code == REAL_TYPE
623 || code == FIXED_POINT_TYPE)
625 fprintf (file, " precision %d", TYPE_PRECISION (node));
626 print_node_brief (file, "min", TYPE_MIN_VALUE (node), indent + 4);
627 print_node_brief (file, "max", TYPE_MAX_VALUE (node), indent + 4);
630 if (code == ENUMERAL_TYPE)
631 print_node (file, "values", TYPE_VALUES (node), indent + 4);
632 else if (code == ARRAY_TYPE)
633 print_node (file, "domain", TYPE_DOMAIN (node), indent + 4);
634 else if (code == VECTOR_TYPE)
635 fprintf (file, " nunits %d", (int) TYPE_VECTOR_SUBPARTS (node));
636 else if (code == RECORD_TYPE
637 || code == UNION_TYPE
638 || code == QUAL_UNION_TYPE)
639 print_node (file, "fields", TYPE_FIELDS (node), indent + 4);
640 else if (code == FUNCTION_TYPE
641 || code == METHOD_TYPE)
643 if (TYPE_METHOD_BASETYPE (node))
644 print_node_brief (file, "method basetype",
645 TYPE_METHOD_BASETYPE (node), indent + 4);
646 print_node (file, "arg-types", TYPE_ARG_TYPES (node), indent + 4);
648 else if (code == OFFSET_TYPE)
649 print_node_brief (file, "basetype", TYPE_OFFSET_BASETYPE (node),
650 indent + 4);
652 if (TYPE_CONTEXT (node))
653 print_node_brief (file, "context", TYPE_CONTEXT (node), indent + 4);
655 lang_hooks.print_type (file, node, indent);
657 if (TYPE_POINTER_TO (node) || TREE_CHAIN (node))
658 indent_to (file, indent + 3);
660 print_node_brief (file, "pointer_to_this", TYPE_POINTER_TO (node),
661 indent + 4);
662 print_node_brief (file, "reference_to_this", TYPE_REFERENCE_TO (node),
663 indent + 4);
664 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
665 break;
667 case tcc_expression:
668 case tcc_comparison:
669 case tcc_unary:
670 case tcc_binary:
671 case tcc_reference:
672 case tcc_statement:
673 case tcc_vl_exp:
674 if (code == BIND_EXPR)
676 print_node (file, "vars", TREE_OPERAND (node, 0), indent + 4);
677 print_node (file, "body", TREE_OPERAND (node, 1), indent + 4);
678 print_node (file, "block", TREE_OPERAND (node, 2), indent + 4);
679 break;
681 if (code == CALL_EXPR)
683 call_expr_arg_iterator iter;
684 tree arg;
685 print_node (file, "fn", CALL_EXPR_FN (node), indent + 4);
686 print_node (file, "static_chain", CALL_EXPR_STATIC_CHAIN (node),
687 indent + 4);
688 i = 0;
689 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
691 char temp[10];
692 sprintf (temp, "arg %d", i);
693 print_node (file, temp, arg, indent + 4);
694 i++;
697 else
699 len = TREE_OPERAND_LENGTH (node);
701 for (i = 0; i < len; i++)
703 char temp[10];
705 sprintf (temp, "arg %d", i);
706 print_node (file, temp, TREE_OPERAND (node, i), indent + 4);
709 if (CODE_CONTAINS_STRUCT (code, TS_COMMON))
710 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
711 break;
713 case tcc_constant:
714 case tcc_exceptional:
715 switch (code)
717 case INTEGER_CST:
718 if (TREE_OVERFLOW (node))
719 fprintf (file, " overflow");
721 fprintf (file, " ");
722 print_dec (node, file, TYPE_SIGN (TREE_TYPE (node)));
723 break;
725 case REAL_CST:
727 REAL_VALUE_TYPE d;
729 if (TREE_OVERFLOW (node))
730 fprintf (file, " overflow");
732 d = TREE_REAL_CST (node);
733 if (REAL_VALUE_ISINF (d))
734 fprintf (file, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
735 else if (REAL_VALUE_ISNAN (d))
736 fprintf (file, " Nan");
737 else
739 char string[64];
740 real_to_decimal (string, &d, sizeof (string), 0, 1);
741 fprintf (file, " %s", string);
744 break;
746 case FIXED_CST:
748 FIXED_VALUE_TYPE f;
749 char string[64];
751 if (TREE_OVERFLOW (node))
752 fprintf (file, " overflow");
754 f = TREE_FIXED_CST (node);
755 fixed_to_decimal (string, &f, sizeof (string));
756 fprintf (file, " %s", string);
758 break;
760 case VECTOR_CST:
762 char buf[10];
763 unsigned i;
765 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
767 sprintf (buf, "elt%u: ", i);
768 print_node (file, buf, VECTOR_CST_ELT (node, i), indent + 4);
771 break;
773 case COMPLEX_CST:
774 print_node (file, "real", TREE_REALPART (node), indent + 4);
775 print_node (file, "imag", TREE_IMAGPART (node), indent + 4);
776 break;
778 case STRING_CST:
780 const char *p = TREE_STRING_POINTER (node);
781 int i = TREE_STRING_LENGTH (node);
782 fputs (" \"", file);
783 while (--i >= 0)
785 char ch = *p++;
786 if (ch >= ' ' && ch < 127)
787 putc (ch, file);
788 else
789 fprintf (file, "\\%03o", ch & 0xFF);
791 fputc ('\"', file);
793 break;
795 case IDENTIFIER_NODE:
796 lang_hooks.print_identifier (file, node, indent);
797 break;
799 case TREE_LIST:
800 print_node (file, "purpose", TREE_PURPOSE (node), indent + 4);
801 print_node (file, "value", TREE_VALUE (node), indent + 4);
802 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
803 break;
805 case TREE_VEC:
806 len = TREE_VEC_LENGTH (node);
807 for (i = 0; i < len; i++)
808 if (TREE_VEC_ELT (node, i))
810 char temp[10];
811 sprintf (temp, "elt %d", i);
812 print_node (file, temp, TREE_VEC_ELT (node, i), indent + 4);
814 break;
816 case CONSTRUCTOR:
818 unsigned HOST_WIDE_INT cnt;
819 tree index, value;
820 len = vec_safe_length (CONSTRUCTOR_ELTS (node));
821 fprintf (file, " lngt %d", len);
822 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node),
823 cnt, index, value)
825 print_node (file, "idx", index, indent + 4);
826 print_node (file, "val", value, indent + 4);
829 break;
831 case STATEMENT_LIST:
832 dump_addr (file, " head ", node->stmt_list.head);
833 dump_addr (file, " tail ", node->stmt_list.tail);
834 fprintf (file, " stmts");
836 tree_stmt_iterator i;
837 for (i = tsi_start (node); !tsi_end_p (i); tsi_next (&i))
839 /* Not printing the addresses of the (not-a-tree)
840 'struct tree_stmt_list_node's. */
841 dump_addr (file, " ", tsi_stmt (i));
843 fprintf (file, "\n");
844 for (i = tsi_start (node); !tsi_end_p (i); tsi_next (&i))
846 /* Not printing the addresses of the (not-a-tree)
847 'struct tree_stmt_list_node's. */
848 print_node (file, "stmt", tsi_stmt (i), indent + 4);
851 break;
853 case BLOCK:
854 print_node (file, "vars", BLOCK_VARS (node), indent + 4);
855 print_node (file, "supercontext", BLOCK_SUPERCONTEXT (node),
856 indent + 4);
857 print_node (file, "subblocks", BLOCK_SUBBLOCKS (node), indent + 4);
858 print_node (file, "chain", BLOCK_CHAIN (node), indent + 4);
859 print_node (file, "abstract_origin",
860 BLOCK_ABSTRACT_ORIGIN (node), indent + 4);
861 break;
863 case SSA_NAME:
864 print_node_brief (file, "var", SSA_NAME_VAR (node), indent + 4);
865 fprintf (file, "def_stmt ");
866 print_gimple_stmt (file, SSA_NAME_DEF_STMT (node), indent + 4, 0);
868 indent_to (file, indent + 4);
869 fprintf (file, "version %u", SSA_NAME_VERSION (node));
870 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
871 fprintf (file, " in-abnormal-phi");
872 if (SSA_NAME_IN_FREE_LIST (node))
873 fprintf (file, " in-free-list");
875 if (SSA_NAME_PTR_INFO (node))
877 indent_to (file, indent + 3);
878 if (SSA_NAME_PTR_INFO (node))
879 dump_addr (file, " ptr-info ", SSA_NAME_PTR_INFO (node));
881 break;
883 case OMP_CLAUSE:
885 int i;
886 fprintf (file, " %s",
887 omp_clause_code_name[OMP_CLAUSE_CODE (node)]);
888 for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (node)]; i++)
890 indent_to (file, indent + 4);
891 fprintf (file, "op %d:", i);
892 print_node_brief (file, "", OMP_CLAUSE_OPERAND (node, i), 0);
895 break;
897 case OPTIMIZATION_NODE:
898 cl_optimization_print (file, indent + 4, TREE_OPTIMIZATION (node));
899 break;
901 case TARGET_OPTION_NODE:
902 cl_target_option_print (file, indent + 4, TREE_TARGET_OPTION (node));
903 break;
904 case IMPORTED_DECL:
905 fprintf (file, " imported declaration");
906 print_node_brief (file, "associated declaration",
907 IMPORTED_DECL_ASSOCIATED_DECL (node),
908 indent + 4);
909 break;
911 default:
912 if (EXCEPTIONAL_CLASS_P (node))
913 lang_hooks.print_xnode (file, node, indent);
914 break;
917 break;
920 if (EXPR_HAS_LOCATION (node))
922 expanded_location xloc = expand_location (EXPR_LOCATION (node));
923 indent_to (file, indent+4);
924 fprintf (file, "%s:%d:%d", xloc.file, xloc.line, xloc.column);
927 fprintf (file, ">");
931 /* Print the node NODE on standard error, for debugging.
932 Most nodes referred to by this one are printed recursively
933 down to a depth of six. */
935 DEBUG_FUNCTION void
936 debug_tree (tree node)
938 table = XCNEWVEC (struct bucket *, HASH_SIZE);
939 print_node (stderr, "", node, 0);
940 free (table);
941 table = 0;
942 putc ('\n', stderr);
945 DEBUG_FUNCTION void
946 debug_raw (const tree_node &ref)
948 debug_tree (const_cast <tree> (&ref));
951 DEBUG_FUNCTION void
952 debug_raw (const tree_node *ptr)
954 if (ptr)
955 debug_raw (*ptr);
956 else
957 fprintf (stderr, "<nil>\n");
960 static void
961 dump_tree_via_hooks (const tree_node *ptr, int options)
963 if (DECL_P (ptr))
964 lang_hooks.print_decl (stderr, const_cast <tree_node*> (ptr), 0);
965 else if (TYPE_P (ptr))
966 lang_hooks.print_type (stderr, const_cast <tree_node*> (ptr), 0);
967 else if (TREE_CODE (ptr) == IDENTIFIER_NODE)
968 lang_hooks.print_identifier (stderr, const_cast <tree_node*> (ptr), 0);
969 else
970 print_generic_expr (stderr, const_cast <tree_node*> (ptr), options);
971 fprintf (stderr, "\n");
974 DEBUG_FUNCTION void
975 debug (const tree_node &ref)
977 dump_tree_via_hooks (&ref, 0);
980 DEBUG_FUNCTION void
981 debug (const tree_node *ptr)
983 if (ptr)
984 debug (*ptr);
985 else
986 fprintf (stderr, "<nil>\n");
989 DEBUG_FUNCTION void
990 debug_verbose (const tree_node &ref)
992 dump_tree_via_hooks (&ref, TDF_VERBOSE);
995 DEBUG_FUNCTION void
996 debug_verbose (const tree_node *ptr)
998 if (ptr)
999 debug_verbose (*ptr);
1000 else
1001 fprintf (stderr, "<nil>\n");
1004 DEBUG_FUNCTION void
1005 debug_head (const tree_node &ref)
1007 debug (ref);
1010 DEBUG_FUNCTION void
1011 debug_head (const tree_node *ptr)
1013 if (ptr)
1014 debug_head (*ptr);
1015 else
1016 fprintf (stderr, "<nil>\n");
1019 DEBUG_FUNCTION void
1020 debug_body (const tree_node &ref)
1022 if (TREE_CODE (&ref) == FUNCTION_DECL)
1023 dump_function_to_file (const_cast <tree_node*> (&ref), stderr, 0);
1024 else
1025 debug (ref);
1028 DEBUG_FUNCTION void
1029 debug_body (const tree_node *ptr)
1031 if (ptr)
1032 debug_body (*ptr);
1033 else
1034 fprintf (stderr, "<nil>\n");
1037 /* Print the vector of trees VEC on standard error, for debugging.
1038 Most nodes referred to by this one are printed recursively
1039 down to a depth of six. */
1041 DEBUG_FUNCTION void
1042 debug_raw (vec<tree, va_gc> &ref)
1044 tree elt;
1045 unsigned ix;
1047 /* Print the slot this node is in, and its code, and address. */
1048 fprintf (stderr, "<VEC");
1049 dump_addr (stderr, " ", ref.address ());
1051 FOR_EACH_VEC_ELT (ref, ix, elt)
1053 fprintf (stderr, "elt %d ", ix);
1054 debug_raw (elt);
1058 DEBUG_FUNCTION void
1059 debug (vec<tree, va_gc> &ref)
1061 tree elt;
1062 unsigned ix;
1064 /* Print the slot this node is in, and its code, and address. */
1065 fprintf (stderr, "<VEC");
1066 dump_addr (stderr, " ", ref.address ());
1068 FOR_EACH_VEC_ELT (ref, ix, elt)
1070 fprintf (stderr, "elt %d ", ix);
1071 debug (elt);
1075 DEBUG_FUNCTION void
1076 debug (vec<tree, va_gc> *ptr)
1078 if (ptr)
1079 debug (*ptr);
1080 else
1081 fprintf (stderr, "<nil>\n");
1084 DEBUG_FUNCTION void
1085 debug_raw (vec<tree, va_gc> *ptr)
1087 if (ptr)
1088 debug_raw (*ptr);
1089 else
1090 fprintf (stderr, "<nil>\n");
1093 DEBUG_FUNCTION void
1094 debug_vec_tree (vec<tree, va_gc> *vec)
1096 debug_raw (vec);