Check in tree-dce enh to trunk
[official-gcc.git] / gcc / print-tree.c
blob3b34f89d41c1df55b292ede44ff36404d51a808a
1 /* Prints out tree in human readable form - GCC
2 Copyright (C) 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
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
10 version.
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
15 for more details.
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/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "tree.h"
27 #include "real.h"
28 #include "fixed-value.h"
29 #include "ggc.h"
30 #include "langhooks.h"
31 #include "tree-iterator.h"
32 #include "tree-flow.h"
34 /* Define the hash table of nodes already seen.
35 Such nodes are not repeated; brief cross-references are used. */
37 #define HASH_SIZE 37
39 struct bucket
41 tree node;
42 struct bucket *next;
45 static struct bucket **table;
47 /* Print the node NODE on standard error, for debugging.
48 Most nodes referred to by this one are printed recursively
49 down to a depth of six. */
51 void
52 debug_tree (tree node)
54 table = XCNEWVEC (struct bucket *, HASH_SIZE);
55 print_node (stderr, "", node, 0);
56 free (table);
57 table = 0;
58 putc ('\n', stderr);
61 /* Print PREFIX and ADDR to FILE. */
62 void
63 dump_addr (FILE *file, const char *prefix, const void *addr)
65 if (flag_dump_noaddr || flag_dump_unnumbered)
66 fprintf (file, "%s#", prefix);
67 else
68 fprintf (file, "%s%p", prefix, addr);
71 /* Print a node in brief fashion, with just the code, address and name. */
73 void
74 print_node_brief (FILE *file, const char *prefix, const_tree node, int indent)
76 enum tree_code_class class;
78 if (node == 0)
79 return;
81 class = TREE_CODE_CLASS (TREE_CODE (node));
83 /* Always print the slot this node is in, and its code, address and
84 name if any. */
85 if (indent > 0)
86 fprintf (file, " ");
87 fprintf (file, "%s <%s", prefix, tree_code_name[(int) TREE_CODE (node)]);
88 dump_addr (file, " ", node);
90 if (class == tcc_declaration)
92 if (DECL_NAME (node))
93 fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
94 else if (TREE_CODE (node) == LABEL_DECL
95 && LABEL_DECL_UID (node) != -1)
96 fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
97 else
98 fprintf (file, " %c.%u", TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
99 DECL_UID (node));
101 else if (class == tcc_type)
103 if (TYPE_NAME (node))
105 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
106 fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
107 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
108 && DECL_NAME (TYPE_NAME (node)))
109 fprintf (file, " %s",
110 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
113 if (TREE_CODE (node) == IDENTIFIER_NODE)
114 fprintf (file, " %s", IDENTIFIER_POINTER (node));
116 /* We might as well always print the value of an integer or real. */
117 if (TREE_CODE (node) == INTEGER_CST)
119 if (TREE_OVERFLOW (node))
120 fprintf (file, " overflow");
122 fprintf (file, " ");
123 if (TREE_INT_CST_HIGH (node) == 0)
124 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, TREE_INT_CST_LOW (node));
125 else if (TREE_INT_CST_HIGH (node) == -1
126 && TREE_INT_CST_LOW (node) != 0)
127 fprintf (file, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
128 -TREE_INT_CST_LOW (node));
129 else
130 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
131 (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (node),
132 (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (node));
134 if (TREE_CODE (node) == REAL_CST)
136 REAL_VALUE_TYPE d;
138 if (TREE_OVERFLOW (node))
139 fprintf (file, " overflow");
141 d = TREE_REAL_CST (node);
142 if (REAL_VALUE_ISINF (d))
143 fprintf (file, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
144 else if (REAL_VALUE_ISNAN (d))
145 fprintf (file, " Nan");
146 else
148 char string[60];
149 real_to_decimal (string, &d, sizeof (string), 0, 1);
150 fprintf (file, " %s", string);
153 if (TREE_CODE (node) == FIXED_CST)
155 FIXED_VALUE_TYPE f;
156 char string[60];
158 if (TREE_OVERFLOW (node))
159 fprintf (file, " overflow");
161 f = TREE_FIXED_CST (node);
162 fixed_to_decimal (string, &f, sizeof (string));
163 fprintf (file, " %s", string);
166 fprintf (file, ">");
169 void
170 indent_to (FILE *file, int column)
172 int i;
174 /* Since this is the long way, indent to desired column. */
175 if (column > 0)
176 fprintf (file, "\n");
177 for (i = 0; i < column; i++)
178 fprintf (file, " ");
181 /* Print the node NODE in full on file FILE, preceded by PREFIX,
182 starting in column INDENT. */
184 void
185 print_node (FILE *file, const char *prefix, tree node, int indent)
187 int hash;
188 struct bucket *b;
189 enum machine_mode mode;
190 enum tree_code_class class;
191 int len;
192 int i;
193 expanded_location xloc;
194 enum tree_code code;
196 if (node == 0)
197 return;
199 code = TREE_CODE (node);
200 class = TREE_CODE_CLASS (code);
202 /* Don't get too deep in nesting. If the user wants to see deeper,
203 it is easy to use the address of a lowest-level node
204 as an argument in another call to debug_tree. */
206 if (indent > 24)
208 print_node_brief (file, prefix, node, indent);
209 return;
212 if (indent > 8 && (class == tcc_type || class == tcc_declaration))
214 print_node_brief (file, prefix, node, indent);
215 return;
218 /* It is unsafe to look at any other fields of an ERROR_MARK node. */
219 if (TREE_CODE (node) == ERROR_MARK)
221 print_node_brief (file, prefix, node, indent);
222 return;
225 /* Allow this function to be called if the table is not there. */
226 if (table)
228 hash = ((unsigned long) node) % HASH_SIZE;
230 /* If node is in the table, just mention its address. */
231 for (b = table[hash]; b; b = b->next)
232 if (b->node == node)
234 print_node_brief (file, prefix, node, indent);
235 return;
238 /* Add this node to the table. */
239 b = XNEW (struct bucket);
240 b->node = node;
241 b->next = table[hash];
242 table[hash] = b;
245 /* Indent to the specified column, since this is the long form. */
246 indent_to (file, indent);
248 /* Print the slot this node is in, and its code, and address. */
249 fprintf (file, "%s <%s", prefix, tree_code_name[(int) TREE_CODE (node)]);
250 dump_addr (file, " ", node);
252 /* Print the name, if any. */
253 if (class == tcc_declaration)
255 if (DECL_NAME (node))
256 fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
257 else if (TREE_CODE (node) == LABEL_DECL
258 && LABEL_DECL_UID (node) != -1)
259 fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
260 else
261 fprintf (file, " %c.%u", TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
262 DECL_UID (node));
264 else if (class == tcc_type)
266 if (TYPE_NAME (node))
268 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
269 fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
270 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
271 && DECL_NAME (TYPE_NAME (node)))
272 fprintf (file, " %s",
273 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
276 if (TREE_CODE (node) == IDENTIFIER_NODE)
277 fprintf (file, " %s", IDENTIFIER_POINTER (node));
279 if (TREE_CODE (node) == INTEGER_CST)
281 if (indent <= 4)
282 print_node_brief (file, "type", TREE_TYPE (node), indent + 4);
284 else if (!GIMPLE_TUPLE_P (node))
286 print_node (file, "type", TREE_TYPE (node), indent + 4);
287 if (TREE_TYPE (node))
288 indent_to (file, indent + 3);
291 if (!TYPE_P (node) && TREE_SIDE_EFFECTS (node))
292 fputs (" side-effects", file);
294 if (TYPE_P (node) ? TYPE_READONLY (node) : TREE_READONLY (node))
295 fputs (" readonly", file);
296 if (!TYPE_P (node) && TREE_CONSTANT (node))
297 fputs (" constant", file);
298 else if (TYPE_P (node) && TYPE_SIZES_GIMPLIFIED (node))
299 fputs (" sizes-gimplified", file);
301 if (TREE_ADDRESSABLE (node))
302 fputs (" addressable", file);
303 if (TREE_THIS_VOLATILE (node))
304 fputs (" volatile", file);
305 if (TREE_ASM_WRITTEN (node))
306 fputs (" asm_written", file);
307 if (TREE_USED (node))
308 fputs (" used", file);
309 if (TREE_NOTHROW (node))
310 fputs (TYPE_P (node) ? " align-ok" : " nothrow", file);
311 if (TREE_PUBLIC (node))
312 fputs (" public", file);
313 if (TREE_PRIVATE (node))
314 fputs (" private", file);
315 if (TREE_PROTECTED (node))
316 fputs (" protected", file);
317 if (TREE_STATIC (node))
318 fputs (" static", file);
319 if (TREE_DEPRECATED (node))
320 fputs (" deprecated", file);
321 if (TREE_VISITED (node))
322 fputs (" visited", file);
323 if (TREE_LANG_FLAG_0 (node))
324 fputs (" tree_0", file);
325 if (TREE_LANG_FLAG_1 (node))
326 fputs (" tree_1", file);
327 if (TREE_LANG_FLAG_2 (node))
328 fputs (" tree_2", file);
329 if (TREE_LANG_FLAG_3 (node))
330 fputs (" tree_3", file);
331 if (TREE_LANG_FLAG_4 (node))
332 fputs (" tree_4", file);
333 if (TREE_LANG_FLAG_5 (node))
334 fputs (" tree_5", file);
335 if (TREE_LANG_FLAG_6 (node))
336 fputs (" tree_6", file);
338 /* DECL_ nodes have additional attributes. */
340 switch (TREE_CODE_CLASS (TREE_CODE (node)))
342 case tcc_declaration:
343 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
345 if (DECL_UNSIGNED (node))
346 fputs (" unsigned", file);
347 if (DECL_IGNORED_P (node))
348 fputs (" ignored", file);
349 if (DECL_ABSTRACT (node))
350 fputs (" abstract", file);
351 if (DECL_EXTERNAL (node))
352 fputs (" external", file);
353 if (DECL_NONLOCAL (node))
354 fputs (" nonlocal", file);
356 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
358 if (DECL_WEAK (node))
359 fputs (" weak", file);
360 if (DECL_IN_SYSTEM_HEADER (node))
361 fputs (" in_system_header", file);
363 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL)
364 && TREE_CODE (node) != LABEL_DECL
365 && TREE_CODE (node) != FUNCTION_DECL
366 && DECL_REGISTER (node))
367 fputs (" regdecl", file);
369 if (TREE_CODE (node) == TYPE_DECL && TYPE_DECL_SUPPRESS_DEBUG (node))
370 fputs (" suppress-debug", file);
372 if (TREE_CODE (node) == FUNCTION_DECL && DECL_INLINE (node))
373 fputs (DECL_DECLARED_INLINE_P (node) ? " inline" : " autoinline", file);
374 if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN (node))
375 fputs (" built-in", file);
376 if (TREE_CODE (node) == FUNCTION_DECL && DECL_NO_STATIC_CHAIN (node))
377 fputs (" no-static-chain", file);
379 if (TREE_CODE (node) == FIELD_DECL && DECL_PACKED (node))
380 fputs (" packed", file);
381 if (TREE_CODE (node) == FIELD_DECL && DECL_BIT_FIELD (node))
382 fputs (" bit-field", file);
383 if (TREE_CODE (node) == FIELD_DECL && DECL_NONADDRESSABLE_P (node))
384 fputs (" nonaddressable", file);
386 if (TREE_CODE (node) == LABEL_DECL && DECL_ERROR_ISSUED (node))
387 fputs (" error-issued", file);
389 if (TREE_CODE (node) == VAR_DECL && DECL_IN_TEXT_SECTION (node))
390 fputs (" in-text-section", file);
391 if (TREE_CODE (node) == VAR_DECL && DECL_COMMON (node))
392 fputs (" common", file);
393 if (TREE_CODE (node) == VAR_DECL && DECL_THREAD_LOCAL_P (node))
395 enum tls_model kind = DECL_TLS_MODEL (node);
396 switch (kind)
398 case TLS_MODEL_GLOBAL_DYNAMIC:
399 fputs (" tls-global-dynamic", file);
400 break;
401 case TLS_MODEL_LOCAL_DYNAMIC:
402 fputs (" tls-local-dynamic", file);
403 break;
404 case TLS_MODEL_INITIAL_EXEC:
405 fputs (" tls-initial-exec", file);
406 break;
407 case TLS_MODEL_LOCAL_EXEC:
408 fputs (" tls-local-exec", file);
409 break;
410 default:
411 gcc_unreachable ();
415 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
417 if (DECL_VIRTUAL_P (node))
418 fputs (" virtual", file);
419 if (DECL_PRESERVE_P (node))
420 fputs (" preserve", file);
421 if (DECL_NO_TBAA_P (node))
422 fputs (" no-tbaa", file);
423 if (DECL_LANG_FLAG_0 (node))
424 fputs (" decl_0", file);
425 if (DECL_LANG_FLAG_1 (node))
426 fputs (" decl_1", file);
427 if (DECL_LANG_FLAG_2 (node))
428 fputs (" decl_2", file);
429 if (DECL_LANG_FLAG_3 (node))
430 fputs (" decl_3", file);
431 if (DECL_LANG_FLAG_4 (node))
432 fputs (" decl_4", file);
433 if (DECL_LANG_FLAG_5 (node))
434 fputs (" decl_5", file);
435 if (DECL_LANG_FLAG_6 (node))
436 fputs (" decl_6", file);
437 if (DECL_LANG_FLAG_7 (node))
438 fputs (" decl_7", file);
440 mode = DECL_MODE (node);
441 fprintf (file, " %s", GET_MODE_NAME (mode));
444 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS) && DECL_DEFER_OUTPUT (node))
445 fputs (" defer-output", file);
448 xloc = expand_location (DECL_SOURCE_LOCATION (node));
449 fprintf (file, " file %s line %d col %d", xloc.file, xloc.line,
450 xloc.column);
452 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
454 print_node (file, "size", DECL_SIZE (node), indent + 4);
455 print_node (file, "unit size", DECL_SIZE_UNIT (node), indent + 4);
457 if (TREE_CODE (node) != FUNCTION_DECL
458 || DECL_INLINE (node) || DECL_BUILT_IN (node))
459 indent_to (file, indent + 3);
461 if (DECL_USER_ALIGN (node))
462 fprintf (file, " user");
464 fprintf (file, " align %d", DECL_ALIGN (node));
465 if (TREE_CODE (node) == FIELD_DECL)
466 fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED,
467 DECL_OFFSET_ALIGN (node));
469 if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN (node))
471 if (DECL_BUILT_IN_CLASS (node) == BUILT_IN_MD)
472 fprintf (file, " built-in BUILT_IN_MD %d", DECL_FUNCTION_CODE (node));
473 else
474 fprintf (file, " built-in %s:%s",
475 built_in_class_names[(int) DECL_BUILT_IN_CLASS (node)],
476 built_in_names[(int) DECL_FUNCTION_CODE (node)]);
479 if (DECL_POINTER_ALIAS_SET_KNOWN_P (node))
480 fprintf (file, " alias set " HOST_WIDE_INT_PRINT_DEC,
481 (HOST_WIDE_INT) DECL_POINTER_ALIAS_SET (node));
483 if (TREE_CODE (node) == FIELD_DECL)
485 print_node (file, "offset", DECL_FIELD_OFFSET (node), indent + 4);
486 print_node (file, "bit offset", DECL_FIELD_BIT_OFFSET (node),
487 indent + 4);
488 if (DECL_BIT_FIELD_TYPE (node))
489 print_node (file, "bit_field_type", DECL_BIT_FIELD_TYPE (node),
490 indent + 4);
493 print_node_brief (file, "context", DECL_CONTEXT (node), indent + 4);
495 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
497 print_node_brief (file, "attributes",
498 DECL_ATTRIBUTES (node), indent + 4);
499 print_node_brief (file, "initial", DECL_INITIAL (node), indent + 4);
501 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL))
503 print_node_brief (file, "abstract_origin",
504 DECL_ABSTRACT_ORIGIN (node), indent + 4);
506 if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
508 print_node (file, "arguments", DECL_ARGUMENT_FLD (node), indent + 4);
509 print_node (file, "result", DECL_RESULT_FLD (node), indent + 4);
512 lang_hooks.print_decl (file, node, indent);
514 if (DECL_RTL_SET_P (node))
516 indent_to (file, indent + 4);
517 print_rtl (file, DECL_RTL (node));
520 if (TREE_CODE (node) == PARM_DECL)
522 print_node (file, "arg-type", DECL_ARG_TYPE (node), indent + 4);
524 if (DECL_INCOMING_RTL (node) != 0)
526 indent_to (file, indent + 4);
527 fprintf (file, "incoming-rtl ");
528 print_rtl (file, DECL_INCOMING_RTL (node));
531 else if (TREE_CODE (node) == FUNCTION_DECL
532 && DECL_STRUCT_FUNCTION (node) != 0)
534 indent_to (file, indent + 4);
535 dump_addr (file, "saved-insns ", DECL_STRUCT_FUNCTION (node));
538 if ((TREE_CODE (node) == VAR_DECL || TREE_CODE (node) == PARM_DECL)
539 && DECL_HAS_VALUE_EXPR_P (node))
540 print_node (file, "value-expr", DECL_VALUE_EXPR (node), indent + 4);
542 /* Print the decl chain only if decl is at second level. */
543 if (indent == 4)
544 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
545 else
546 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
547 break;
549 case tcc_type:
550 if (TYPE_UNSIGNED (node))
551 fputs (" unsigned", file);
553 /* The no-force-blk flag is used for different things in
554 different types. */
555 if ((TREE_CODE (node) == RECORD_TYPE
556 || TREE_CODE (node) == UNION_TYPE
557 || TREE_CODE (node) == QUAL_UNION_TYPE)
558 && TYPE_NO_FORCE_BLK (node))
559 fputs (" no-force-blk", file);
560 else if (TREE_CODE (node) == INTEGER_TYPE
561 && TYPE_IS_SIZETYPE (node))
562 fputs (" sizetype", file);
564 if (TYPE_STRING_FLAG (node))
565 fputs (" string-flag", file);
566 if (TYPE_NEEDS_CONSTRUCTING (node))
567 fputs (" needs-constructing", file);
569 /* The transparent-union flag is used for different things in
570 different nodes. */
571 if (TREE_CODE (node) == UNION_TYPE && TYPE_TRANSPARENT_UNION (node))
572 fputs (" transparent-union", file);
573 else if (TREE_CODE (node) == ARRAY_TYPE
574 && TYPE_NONALIASED_COMPONENT (node))
575 fputs (" nonaliased-component", file);
577 if (TYPE_PACKED (node))
578 fputs (" packed", file);
580 if (TYPE_RESTRICT (node))
581 fputs (" restrict", file);
583 if (TYPE_LANG_FLAG_0 (node))
584 fputs (" type_0", file);
585 if (TYPE_LANG_FLAG_1 (node))
586 fputs (" type_1", file);
587 if (TYPE_LANG_FLAG_2 (node))
588 fputs (" type_2", file);
589 if (TYPE_LANG_FLAG_3 (node))
590 fputs (" type_3", file);
591 if (TYPE_LANG_FLAG_4 (node))
592 fputs (" type_4", file);
593 if (TYPE_LANG_FLAG_5 (node))
594 fputs (" type_5", file);
595 if (TYPE_LANG_FLAG_6 (node))
596 fputs (" type_6", file);
598 mode = TYPE_MODE (node);
599 fprintf (file, " %s", GET_MODE_NAME (mode));
601 print_node (file, "size", TYPE_SIZE (node), indent + 4);
602 print_node (file, "unit size", TYPE_SIZE_UNIT (node), indent + 4);
603 indent_to (file, indent + 3);
605 if (TYPE_USER_ALIGN (node))
606 fprintf (file, " user");
608 fprintf (file, " align %d symtab %d alias set " HOST_WIDE_INT_PRINT_DEC,
609 TYPE_ALIGN (node), TYPE_SYMTAB_ADDRESS (node),
610 (HOST_WIDE_INT) TYPE_ALIAS_SET (node));
612 if (TYPE_STRUCTURAL_EQUALITY_P (node))
613 fprintf (file, " structural equality");
614 else
615 dump_addr (file, " canonical type ", TYPE_CANONICAL (node));
617 print_node (file, "attributes", TYPE_ATTRIBUTES (node), indent + 4);
619 if (INTEGRAL_TYPE_P (node) || TREE_CODE (node) == REAL_TYPE
620 || TREE_CODE (node) == FIXED_POINT_TYPE)
622 fprintf (file, " precision %d", TYPE_PRECISION (node));
623 print_node_brief (file, "min", TYPE_MIN_VALUE (node), indent + 4);
624 print_node_brief (file, "max", TYPE_MAX_VALUE (node), indent + 4);
627 if (TREE_CODE (node) == ENUMERAL_TYPE)
628 print_node (file, "values", TYPE_VALUES (node), indent + 4);
629 else if (TREE_CODE (node) == ARRAY_TYPE)
630 print_node (file, "domain", TYPE_DOMAIN (node), indent + 4);
631 else if (TREE_CODE (node) == VECTOR_TYPE)
632 fprintf (file, " nunits %d", (int) TYPE_VECTOR_SUBPARTS (node));
633 else if (TREE_CODE (node) == RECORD_TYPE
634 || TREE_CODE (node) == UNION_TYPE
635 || TREE_CODE (node) == QUAL_UNION_TYPE)
636 print_node (file, "fields", TYPE_FIELDS (node), indent + 4);
637 else if (TREE_CODE (node) == FUNCTION_TYPE
638 || TREE_CODE (node) == METHOD_TYPE)
640 if (TYPE_METHOD_BASETYPE (node))
641 print_node_brief (file, "method basetype",
642 TYPE_METHOD_BASETYPE (node), indent + 4);
643 print_node (file, "arg-types", TYPE_ARG_TYPES (node), indent + 4);
645 else if (TREE_CODE (node) == OFFSET_TYPE)
646 print_node_brief (file, "basetype", TYPE_OFFSET_BASETYPE (node),
647 indent + 4);
649 if (TYPE_CONTEXT (node))
650 print_node_brief (file, "context", TYPE_CONTEXT (node), indent + 4);
652 lang_hooks.print_type (file, node, indent);
654 if (TYPE_POINTER_TO (node) || TREE_CHAIN (node))
655 indent_to (file, indent + 3);
657 print_node_brief (file, "pointer_to_this", TYPE_POINTER_TO (node),
658 indent + 4);
659 print_node_brief (file, "reference_to_this", TYPE_REFERENCE_TO (node),
660 indent + 4);
661 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
662 break;
664 case tcc_expression:
665 case tcc_comparison:
666 case tcc_unary:
667 case tcc_binary:
668 case tcc_reference:
669 case tcc_statement:
670 case tcc_vl_exp:
671 if (TREE_CODE (node) == BIND_EXPR)
673 print_node (file, "vars", TREE_OPERAND (node, 0), indent + 4);
674 print_node (file, "body", TREE_OPERAND (node, 1), indent + 4);
675 print_node (file, "block", TREE_OPERAND (node, 2), indent + 4);
676 break;
678 if (TREE_CODE (node) == CALL_EXPR)
680 call_expr_arg_iterator iter;
681 tree arg;
682 print_node (file, "fn", CALL_EXPR_FN (node), indent + 4);
683 print_node (file, "static_chain", CALL_EXPR_STATIC_CHAIN (node),
684 indent + 4);
685 i = 0;
686 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
688 char temp[10];
689 sprintf (temp, "arg %d", i);
690 print_node (file, temp, arg, indent + 4);
691 i++;
694 else
696 len = TREE_OPERAND_LENGTH (node);
698 for (i = 0; i < len; i++)
700 char temp[10];
702 sprintf (temp, "arg %d", i);
703 print_node (file, temp, TREE_OPERAND (node, i), indent + 4);
706 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
707 break;
709 case tcc_gimple_stmt:
710 len = TREE_CODE_LENGTH (TREE_CODE (node));
712 for (i = 0; i < len; i++)
714 char temp[10];
716 sprintf (temp, "arg %d", i);
717 print_node (file, temp, GIMPLE_STMT_OPERAND (node, i), indent + 4);
719 break;
721 case tcc_constant:
722 case tcc_exceptional:
723 switch (TREE_CODE (node))
725 case INTEGER_CST:
726 if (TREE_OVERFLOW (node))
727 fprintf (file, " overflow");
729 fprintf (file, " ");
730 if (TREE_INT_CST_HIGH (node) == 0)
731 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED,
732 TREE_INT_CST_LOW (node));
733 else if (TREE_INT_CST_HIGH (node) == -1
734 && TREE_INT_CST_LOW (node) != 0)
735 fprintf (file, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
736 -TREE_INT_CST_LOW (node));
737 else
738 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
739 (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (node),
740 (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (node));
741 break;
743 case REAL_CST:
745 REAL_VALUE_TYPE d;
747 if (TREE_OVERFLOW (node))
748 fprintf (file, " overflow");
750 d = TREE_REAL_CST (node);
751 if (REAL_VALUE_ISINF (d))
752 fprintf (file, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
753 else if (REAL_VALUE_ISNAN (d))
754 fprintf (file, " Nan");
755 else
757 char string[64];
758 real_to_decimal (string, &d, sizeof (string), 0, 1);
759 fprintf (file, " %s", string);
762 break;
764 case FIXED_CST:
766 FIXED_VALUE_TYPE f;
767 char string[64];
769 if (TREE_OVERFLOW (node))
770 fprintf (file, " overflow");
772 f = TREE_FIXED_CST (node);
773 fixed_to_decimal (string, &f, sizeof (string));
774 fprintf (file, " %s", string);
776 break;
778 case VECTOR_CST:
780 tree vals = TREE_VECTOR_CST_ELTS (node);
781 char buf[10];
782 tree link;
783 int i;
785 i = 0;
786 for (link = vals; link; link = TREE_CHAIN (link), ++i)
788 sprintf (buf, "elt%d: ", i);
789 print_node (file, buf, TREE_VALUE (link), indent + 4);
792 break;
794 case COMPLEX_CST:
795 print_node (file, "real", TREE_REALPART (node), indent + 4);
796 print_node (file, "imag", TREE_IMAGPART (node), indent + 4);
797 break;
799 case STRING_CST:
801 const char *p = TREE_STRING_POINTER (node);
802 int i = TREE_STRING_LENGTH (node);
803 fputs (" \"", file);
804 while (--i >= 0)
806 char ch = *p++;
807 if (ch >= ' ' && ch < 127)
808 putc (ch, file);
809 else
810 fprintf(file, "\\%03o", ch & 0xFF);
812 fputc ('\"', file);
814 /* Print the chain at second level. */
815 if (indent == 4)
816 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
817 else
818 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
819 break;
821 case IDENTIFIER_NODE:
822 lang_hooks.print_identifier (file, node, indent);
823 break;
825 case TREE_LIST:
826 print_node (file, "purpose", TREE_PURPOSE (node), indent + 4);
827 print_node (file, "value", TREE_VALUE (node), indent + 4);
828 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
829 break;
831 case TREE_VEC:
832 len = TREE_VEC_LENGTH (node);
833 for (i = 0; i < len; i++)
834 if (TREE_VEC_ELT (node, i))
836 char temp[10];
837 sprintf (temp, "elt %d", i);
838 indent_to (file, indent + 4);
839 print_node_brief (file, temp, TREE_VEC_ELT (node, i), 0);
841 break;
843 case CONSTRUCTOR:
845 unsigned HOST_WIDE_INT cnt;
846 tree index, value;
847 len = VEC_length (constructor_elt, CONSTRUCTOR_ELTS (node));
848 fprintf (file, " lngt %d", len);
849 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node),
850 cnt, index, value)
852 print_node (file, "idx", index, indent + 4);
853 print_node (file, "val", value, indent + 4);
856 break;
858 case STATEMENT_LIST:
859 dump_addr (file, " head ", node->stmt_list.head);
860 dump_addr (file, " tail ", node->stmt_list.tail);
861 fprintf (file, " stmts");
863 tree_stmt_iterator i;
864 for (i = tsi_start (node); !tsi_end_p (i); tsi_next (&i))
866 /* Not printing the addresses of the (not-a-tree)
867 'struct tree_stmt_list_node's. */
868 dump_addr (file, " ", tsi_stmt (i));
870 fprintf (file, "\n");
871 for (i = tsi_start (node); !tsi_end_p (i); tsi_next (&i))
873 /* Not printing the addresses of the (not-a-tree)
874 'struct tree_stmt_list_node's. */
875 print_node (file, "stmt", tsi_stmt (i), indent + 4);
878 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
879 break;
881 case BLOCK:
882 print_node (file, "vars", BLOCK_VARS (node), indent + 4);
883 print_node (file, "supercontext", BLOCK_SUPERCONTEXT (node),
884 indent + 4);
885 print_node (file, "subblocks", BLOCK_SUBBLOCKS (node), indent + 4);
886 print_node (file, "chain", BLOCK_CHAIN (node), indent + 4);
887 print_node (file, "abstract_origin",
888 BLOCK_ABSTRACT_ORIGIN (node), indent + 4);
889 break;
891 case SSA_NAME:
892 print_node_brief (file, "var", SSA_NAME_VAR (node), indent + 4);
893 print_node_brief (file, "def_stmt",
894 SSA_NAME_DEF_STMT (node), indent + 4);
896 indent_to (file, indent + 4);
897 fprintf (file, "version %u", SSA_NAME_VERSION (node));
898 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
899 fprintf (file, " in-abnormal-phi");
900 if (SSA_NAME_IN_FREE_LIST (node))
901 fprintf (file, " in-free-list");
903 if (SSA_NAME_PTR_INFO (node)
904 || SSA_NAME_VALUE (node))
906 indent_to (file, indent + 3);
907 if (SSA_NAME_PTR_INFO (node))
908 dump_addr (file, " ptr-info ", SSA_NAME_PTR_INFO (node));
909 if (SSA_NAME_VALUE (node))
910 dump_addr (file, " value ", SSA_NAME_VALUE (node));
912 break;
914 case PHI_NODE:
915 print_node (file, "result", PHI_RESULT (node), indent + 4);
916 for (i = 0; i < PHI_NUM_ARGS (node); i++)
917 print_node (file, "arg", PHI_ARG_DEF (node, i), indent + 4);
918 break;
920 case OMP_CLAUSE:
922 int i;
923 fprintf (file, " %s",
924 omp_clause_code_name[OMP_CLAUSE_CODE (node)]);
925 for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (node)]; i++)
927 indent_to (file, indent + 4);
928 fprintf (file, "op %d:", i);
929 print_node_brief (file, "", OMP_CLAUSE_OPERAND (node, i), 0);
932 break;
934 default:
935 if (EXCEPTIONAL_CLASS_P (node))
936 lang_hooks.print_xnode (file, node, indent);
937 break;
940 break;
943 if (EXPR_HAS_LOCATION (node))
945 expanded_location xloc = expand_location (EXPR_LOCATION (node));
946 indent_to (file, indent+4);
947 fprintf (file, "%s:%d:%d", xloc.file, xloc.line, xloc.column);
950 fprintf (file, ">");