Mark as release
[official-gcc.git] / gcc / print-tree.c
blobb77623f71eba50acc792ffd6922928f33bff52dd
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, 2007 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 "ggc.h"
29 #include "langhooks.h"
30 #include "tree-iterator.h"
32 /* Define the hash table of nodes already seen.
33 Such nodes are not repeated; brief cross-references are used. */
35 #define HASH_SIZE 37
37 struct bucket
39 tree node;
40 struct bucket *next;
43 static struct bucket **table;
45 /* Print the node NODE on standard error, for debugging.
46 Most nodes referred to by this one are printed recursively
47 down to a depth of six. */
49 void
50 debug_tree (tree node)
52 table = XCNEWVEC (struct bucket *, HASH_SIZE);
53 print_node (stderr, "", node, 0);
54 free (table);
55 table = 0;
56 putc ('\n', stderr);
59 /* Print PREFIX and ADDR to FILE. */
60 void
61 dump_addr (FILE *file, const char *prefix, void *addr)
63 if (flag_dump_noaddr || flag_dump_unnumbered)
64 fprintf (file, "%s#", prefix);
65 else
66 fprintf (file, "%s%p", prefix, addr);
69 /* Print a node in brief fashion, with just the code, address and name. */
71 void
72 print_node_brief (FILE *file, const char *prefix, tree node, int indent)
74 enum tree_code_class class;
76 if (node == 0)
77 return;
79 class = TREE_CODE_CLASS (TREE_CODE (node));
81 /* Always print the slot this node is in, and its code, address and
82 name if any. */
83 if (indent > 0)
84 fprintf (file, " ");
85 fprintf (file, "%s <%s", prefix, tree_code_name[(int) TREE_CODE (node)]);
86 dump_addr (file, " ", node);
88 if (class == tcc_declaration)
90 if (DECL_NAME (node))
91 fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
92 else if (TREE_CODE (node) == LABEL_DECL
93 && LABEL_DECL_UID (node) != -1)
94 fprintf (file, " L." HOST_WIDE_INT_PRINT_DEC, LABEL_DECL_UID (node));
95 else
96 fprintf (file, " %c.%u", TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
97 DECL_UID (node));
99 else if (class == tcc_type)
101 if (TYPE_NAME (node))
103 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
104 fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
105 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
106 && DECL_NAME (TYPE_NAME (node)))
107 fprintf (file, " %s",
108 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
111 if (TREE_CODE (node) == IDENTIFIER_NODE)
112 fprintf (file, " %s", IDENTIFIER_POINTER (node));
114 /* We might as well always print the value of an integer or real. */
115 if (TREE_CODE (node) == INTEGER_CST)
117 if (TREE_CONSTANT_OVERFLOW (node))
118 fprintf (file, " overflow");
120 fprintf (file, " ");
121 if (TREE_INT_CST_HIGH (node) == 0)
122 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, TREE_INT_CST_LOW (node));
123 else if (TREE_INT_CST_HIGH (node) == -1
124 && TREE_INT_CST_LOW (node) != 0)
125 fprintf (file, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
126 -TREE_INT_CST_LOW (node));
127 else
128 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
129 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (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);
151 fprintf (file, ">");
154 void
155 indent_to (FILE *file, int column)
157 int i;
159 /* Since this is the long way, indent to desired column. */
160 if (column > 0)
161 fprintf (file, "\n");
162 for (i = 0; i < column; i++)
163 fprintf (file, " ");
166 /* Print the node NODE in full on file FILE, preceded by PREFIX,
167 starting in column INDENT. */
169 void
170 print_node (FILE *file, const char *prefix, tree node, int indent)
172 int hash;
173 struct bucket *b;
174 enum machine_mode mode;
175 enum tree_code_class class;
176 int len;
177 int i;
178 expanded_location xloc;
179 enum tree_code code;
181 if (node == 0)
182 return;
184 code = TREE_CODE (node);
185 class = TREE_CODE_CLASS (code);
187 /* Don't get too deep in nesting. If the user wants to see deeper,
188 it is easy to use the address of a lowest-level node
189 as an argument in another call to debug_tree. */
191 if (indent > 24)
193 print_node_brief (file, prefix, node, indent);
194 return;
197 if (indent > 8 && (class == tcc_type || class == tcc_declaration))
199 print_node_brief (file, prefix, node, indent);
200 return;
203 /* It is unsafe to look at any other fields of an ERROR_MARK node. */
204 if (TREE_CODE (node) == ERROR_MARK)
206 print_node_brief (file, prefix, node, indent);
207 return;
210 hash = ((unsigned long) node) % HASH_SIZE;
212 /* If node is in the table, just mention its address. */
213 for (b = table[hash]; b; b = b->next)
214 if (b->node == node)
216 print_node_brief (file, prefix, node, indent);
217 return;
220 /* Add this node to the table. */
221 b = XNEW (struct bucket);
222 b->node = node;
223 b->next = table[hash];
224 table[hash] = b;
226 /* Indent to the specified column, since this is the long form. */
227 indent_to (file, indent);
229 /* Print the slot this node is in, and its code, and address. */
230 fprintf (file, "%s <%s", prefix, tree_code_name[(int) TREE_CODE (node)]);
231 dump_addr (file, " ", node);
233 /* Print the name, if any. */
234 if (class == tcc_declaration)
236 if (DECL_NAME (node))
237 fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
238 else if (TREE_CODE (node) == LABEL_DECL
239 && LABEL_DECL_UID (node) != -1)
240 fprintf (file, " L." HOST_WIDE_INT_PRINT_DEC, LABEL_DECL_UID (node));
241 else
242 fprintf (file, " %c.%u", TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
243 DECL_UID (node));
245 else if (class == tcc_type)
247 if (TYPE_NAME (node))
249 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
250 fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
251 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
252 && DECL_NAME (TYPE_NAME (node)))
253 fprintf (file, " %s",
254 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
257 if (TREE_CODE (node) == IDENTIFIER_NODE)
258 fprintf (file, " %s", IDENTIFIER_POINTER (node));
260 if (TREE_CODE (node) == INTEGER_CST)
262 if (indent <= 4)
263 print_node_brief (file, "type", TREE_TYPE (node), indent + 4);
265 else
267 print_node (file, "type", TREE_TYPE (node), indent + 4);
268 if (TREE_TYPE (node))
269 indent_to (file, indent + 3);
272 if (!TYPE_P (node) && TREE_SIDE_EFFECTS (node))
273 fputs (" side-effects", file);
275 if (TYPE_P (node) ? TYPE_READONLY (node) : TREE_READONLY (node))
276 fputs (" readonly", file);
277 if (!TYPE_P (node) && TREE_CONSTANT (node))
278 fputs (" constant", file);
279 else if (TYPE_P (node) && TYPE_SIZES_GIMPLIFIED (node))
280 fputs (" sizes-gimplified", file);
282 if (TREE_INVARIANT (node))
283 fputs (" invariant", file);
284 if (TREE_ADDRESSABLE (node))
285 fputs (" addressable", file);
286 if (TREE_THIS_VOLATILE (node))
287 fputs (" volatile", file);
288 if (TREE_ASM_WRITTEN (node))
289 fputs (" asm_written", file);
290 if (TREE_USED (node))
291 fputs (" used", file);
292 if (TREE_NOTHROW (node))
293 fputs (TYPE_P (node) ? " align-ok" : " nothrow", file);
294 if (TREE_PUBLIC (node))
295 fputs (" public", file);
296 if (TREE_PRIVATE (node))
297 fputs (" private", file);
298 if (TREE_PROTECTED (node))
299 fputs (" protected", file);
300 if (TREE_STATIC (node))
301 fputs (" static", file);
302 if (TREE_DEPRECATED (node))
303 fputs (" deprecated", file);
304 if (TREE_VISITED (node))
305 fputs (" visited", file);
306 if (TREE_LANG_FLAG_0 (node))
307 fputs (" tree_0", file);
308 if (TREE_LANG_FLAG_1 (node))
309 fputs (" tree_1", file);
310 if (TREE_LANG_FLAG_2 (node))
311 fputs (" tree_2", file);
312 if (TREE_LANG_FLAG_3 (node))
313 fputs (" tree_3", file);
314 if (TREE_LANG_FLAG_4 (node))
315 fputs (" tree_4", file);
316 if (TREE_LANG_FLAG_5 (node))
317 fputs (" tree_5", file);
318 if (TREE_LANG_FLAG_6 (node))
319 fputs (" tree_6", file);
321 /* DECL_ nodes have additional attributes. */
323 switch (TREE_CODE_CLASS (TREE_CODE (node)))
325 case tcc_declaration:
326 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
328 if (DECL_UNSIGNED (node))
329 fputs (" unsigned", file);
330 if (DECL_IGNORED_P (node))
331 fputs (" ignored", file);
332 if (DECL_ABSTRACT (node))
333 fputs (" abstract", file);
334 if (DECL_EXTERNAL (node))
335 fputs (" external", file);
336 if (DECL_NONLOCAL (node))
337 fputs (" nonlocal", file);
339 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
341 if (DECL_WEAK (node))
342 fputs (" weak", file);
343 if (DECL_IN_SYSTEM_HEADER (node))
344 fputs (" in_system_header", file);
346 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL)
347 && TREE_CODE (node) != LABEL_DECL
348 && TREE_CODE (node) != FUNCTION_DECL
349 && DECL_REGISTER (node))
350 fputs (" regdecl", file);
352 if (TREE_CODE (node) == TYPE_DECL && TYPE_DECL_SUPPRESS_DEBUG (node))
353 fputs (" suppress-debug", file);
355 if (TREE_CODE (node) == FUNCTION_DECL && DECL_INLINE (node))
356 fputs (DECL_DECLARED_INLINE_P (node) ? " inline" : " autoinline", file);
357 if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN (node))
358 fputs (" built-in", file);
359 if (TREE_CODE (node) == FUNCTION_DECL && DECL_NO_STATIC_CHAIN (node))
360 fputs (" no-static-chain", file);
362 if (TREE_CODE (node) == FIELD_DECL && DECL_PACKED (node))
363 fputs (" packed", file);
364 if (TREE_CODE (node) == FIELD_DECL && DECL_BIT_FIELD (node))
365 fputs (" bit-field", file);
366 if (TREE_CODE (node) == FIELD_DECL && DECL_NONADDRESSABLE_P (node))
367 fputs (" nonaddressable", file);
369 if (TREE_CODE (node) == LABEL_DECL && DECL_ERROR_ISSUED (node))
370 fputs (" error-issued", file);
372 if (TREE_CODE (node) == VAR_DECL && DECL_IN_TEXT_SECTION (node))
373 fputs (" in-text-section", file);
374 if (TREE_CODE (node) == VAR_DECL && DECL_COMMON (node))
375 fputs (" common", file);
376 if (TREE_CODE (node) == VAR_DECL && DECL_THREAD_LOCAL_P (node))
378 enum tls_model kind = DECL_TLS_MODEL (node);
379 switch (kind)
381 case TLS_MODEL_GLOBAL_DYNAMIC:
382 fputs (" tls-global-dynamic", file);
383 break;
384 case TLS_MODEL_LOCAL_DYNAMIC:
385 fputs (" tls-local-dynamic", file);
386 break;
387 case TLS_MODEL_INITIAL_EXEC:
388 fputs (" tls-initial-exec", file);
389 break;
390 case TLS_MODEL_LOCAL_EXEC:
391 fputs (" tls-local-exec", file);
392 break;
393 default:
394 gcc_unreachable ();
398 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
400 if (DECL_VIRTUAL_P (node))
401 fputs (" virtual", file);
402 if (DECL_PRESERVE_P (node))
403 fputs (" preserve", file);
404 if (DECL_LANG_FLAG_0 (node))
405 fputs (" decl_0", file);
406 if (DECL_LANG_FLAG_1 (node))
407 fputs (" decl_1", file);
408 if (DECL_LANG_FLAG_2 (node))
409 fputs (" decl_2", file);
410 if (DECL_LANG_FLAG_3 (node))
411 fputs (" decl_3", file);
412 if (DECL_LANG_FLAG_4 (node))
413 fputs (" decl_4", file);
414 if (DECL_LANG_FLAG_5 (node))
415 fputs (" decl_5", file);
416 if (DECL_LANG_FLAG_6 (node))
417 fputs (" decl_6", file);
418 if (DECL_LANG_FLAG_7 (node))
419 fputs (" decl_7", file);
421 mode = DECL_MODE (node);
422 fprintf (file, " %s", GET_MODE_NAME (mode));
425 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS) && DECL_DEFER_OUTPUT (node))
426 fputs (" defer-output", file);
429 xloc = expand_location (DECL_SOURCE_LOCATION (node));
430 fprintf (file, " file %s line %d", xloc.file, xloc.line);
432 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
434 print_node (file, "size", DECL_SIZE (node), indent + 4);
435 print_node (file, "unit size", DECL_SIZE_UNIT (node), indent + 4);
437 if (TREE_CODE (node) != FUNCTION_DECL
438 || DECL_INLINE (node) || DECL_BUILT_IN (node))
439 indent_to (file, indent + 3);
441 if (TREE_CODE (node) != FUNCTION_DECL)
443 if (DECL_USER_ALIGN (node))
444 fprintf (file, " user");
446 fprintf (file, " align %d", DECL_ALIGN (node));
447 if (TREE_CODE (node) == FIELD_DECL)
448 fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED,
449 DECL_OFFSET_ALIGN (node));
451 else if (DECL_BUILT_IN (node))
453 if (DECL_BUILT_IN_CLASS (node) == BUILT_IN_MD)
454 fprintf (file, " built-in BUILT_IN_MD %d", DECL_FUNCTION_CODE (node));
455 else
456 fprintf (file, " built-in %s:%s",
457 built_in_class_names[(int) DECL_BUILT_IN_CLASS (node)],
458 built_in_names[(int) DECL_FUNCTION_CODE (node)]);
461 if (DECL_POINTER_ALIAS_SET_KNOWN_P (node))
462 fprintf (file, " alias set " HOST_WIDE_INT_PRINT_DEC,
463 DECL_POINTER_ALIAS_SET (node));
465 if (TREE_CODE (node) == FIELD_DECL)
467 print_node (file, "offset", DECL_FIELD_OFFSET (node), indent + 4);
468 print_node (file, "bit offset", DECL_FIELD_BIT_OFFSET (node),
469 indent + 4);
470 if (DECL_BIT_FIELD_TYPE (node))
471 print_node (file, "bit_field_type", DECL_BIT_FIELD_TYPE (node),
472 indent + 4);
475 print_node_brief (file, "context", DECL_CONTEXT (node), indent + 4);
477 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
479 print_node_brief (file, "attributes",
480 DECL_ATTRIBUTES (node), indent + 4);
481 print_node_brief (file, "initial", DECL_INITIAL (node), indent + 4);
483 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL))
485 print_node_brief (file, "abstract_origin",
486 DECL_ABSTRACT_ORIGIN (node), indent + 4);
488 if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
490 print_node (file, "arguments", DECL_ARGUMENT_FLD (node), indent + 4);
491 print_node (file, "result", DECL_RESULT_FLD (node), indent + 4);
494 lang_hooks.print_decl (file, node, indent);
496 if (DECL_RTL_SET_P (node))
498 indent_to (file, indent + 4);
499 print_rtl (file, DECL_RTL (node));
502 if (TREE_CODE (node) == PARM_DECL)
504 print_node (file, "arg-type", DECL_ARG_TYPE (node), indent + 4);
506 if (DECL_INCOMING_RTL (node) != 0)
508 indent_to (file, indent + 4);
509 fprintf (file, "incoming-rtl ");
510 print_rtl (file, DECL_INCOMING_RTL (node));
513 else if (TREE_CODE (node) == FUNCTION_DECL
514 && DECL_STRUCT_FUNCTION (node) != 0)
516 indent_to (file, indent + 4);
517 dump_addr (file, "saved-insns ", DECL_STRUCT_FUNCTION (node));
520 if ((TREE_CODE (node) == VAR_DECL || TREE_CODE (node) == PARM_DECL)
521 && DECL_HAS_VALUE_EXPR_P (node))
522 print_node (file, "value-expr", DECL_VALUE_EXPR (node), indent + 4);
524 if (TREE_CODE (node) == STRUCT_FIELD_TAG)
526 fprintf (file, " sft size " HOST_WIDE_INT_PRINT_DEC,
527 SFT_SIZE (node));
528 fprintf (file, " sft offset " HOST_WIDE_INT_PRINT_DEC,
529 SFT_OFFSET (node));
530 print_node_brief (file, "parent var", SFT_PARENT_VAR (node),
531 indent + 4);
533 /* Print the decl chain only if decl is at second level. */
534 if (indent == 4)
535 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
536 else
537 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
538 break;
540 case tcc_type:
541 if (TYPE_UNSIGNED (node))
542 fputs (" unsigned", file);
544 /* The no-force-blk flag is used for different things in
545 different types. */
546 if ((TREE_CODE (node) == RECORD_TYPE
547 || TREE_CODE (node) == UNION_TYPE
548 || TREE_CODE (node) == QUAL_UNION_TYPE)
549 && TYPE_NO_FORCE_BLK (node))
550 fputs (" no-force-blk", file);
551 else if (TREE_CODE (node) == INTEGER_TYPE
552 && TYPE_IS_SIZETYPE (node))
553 fputs (" sizetype", file);
554 else if (TREE_CODE (node) == FUNCTION_TYPE
555 && TYPE_RETURNS_STACK_DEPRESSED (node))
556 fputs (" returns-stack-depressed", file);
558 if (TYPE_STRING_FLAG (node))
559 fputs (" string-flag", file);
560 if (TYPE_NEEDS_CONSTRUCTING (node))
561 fputs (" needs-constructing", file);
563 /* The transparent-union flag is used for different things in
564 different nodes. */
565 if (TREE_CODE (node) == UNION_TYPE && TYPE_TRANSPARENT_UNION (node))
566 fputs (" transparent-union", file);
567 else if (TREE_CODE (node) == ARRAY_TYPE
568 && TYPE_NONALIASED_COMPONENT (node))
569 fputs (" nonaliased-component", file);
571 if (TYPE_PACKED (node))
572 fputs (" packed", file);
574 if (TYPE_RESTRICT (node))
575 fputs (" restrict", file);
577 if (TYPE_LANG_FLAG_0 (node))
578 fputs (" type_0", file);
579 if (TYPE_LANG_FLAG_1 (node))
580 fputs (" type_1", file);
581 if (TYPE_LANG_FLAG_2 (node))
582 fputs (" type_2", file);
583 if (TYPE_LANG_FLAG_3 (node))
584 fputs (" type_3", file);
585 if (TYPE_LANG_FLAG_4 (node))
586 fputs (" type_4", file);
587 if (TYPE_LANG_FLAG_5 (node))
588 fputs (" type_5", file);
589 if (TYPE_LANG_FLAG_6 (node))
590 fputs (" type_6", file);
592 mode = TYPE_MODE (node);
593 fprintf (file, " %s", GET_MODE_NAME (mode));
595 print_node (file, "size", TYPE_SIZE (node), indent + 4);
596 print_node (file, "unit size", TYPE_SIZE_UNIT (node), indent + 4);
597 indent_to (file, indent + 3);
599 if (TYPE_USER_ALIGN (node))
600 fprintf (file, " user");
602 fprintf (file, " align %d symtab %d alias set " HOST_WIDE_INT_PRINT_DEC,
603 TYPE_ALIGN (node), TYPE_SYMTAB_ADDRESS (node),
604 TYPE_ALIAS_SET (node));
606 print_node (file, "attributes", TYPE_ATTRIBUTES (node), indent + 4);
608 if (INTEGRAL_TYPE_P (node) || TREE_CODE (node) == REAL_TYPE)
610 fprintf (file, " precision %d", TYPE_PRECISION (node));
611 print_node_brief (file, "min", TYPE_MIN_VALUE (node), indent + 4);
612 print_node_brief (file, "max", TYPE_MAX_VALUE (node), indent + 4);
615 if (TREE_CODE (node) == ENUMERAL_TYPE)
616 print_node (file, "values", TYPE_VALUES (node), indent + 4);
617 else if (TREE_CODE (node) == ARRAY_TYPE)
618 print_node (file, "domain", TYPE_DOMAIN (node), indent + 4);
619 else if (TREE_CODE (node) == VECTOR_TYPE)
620 fprintf (file, " nunits %d", (int) TYPE_VECTOR_SUBPARTS (node));
621 else if (TREE_CODE (node) == RECORD_TYPE
622 || TREE_CODE (node) == UNION_TYPE
623 || TREE_CODE (node) == QUAL_UNION_TYPE)
624 print_node (file, "fields", TYPE_FIELDS (node), indent + 4);
625 else if (TREE_CODE (node) == FUNCTION_TYPE
626 || TREE_CODE (node) == METHOD_TYPE)
628 if (TYPE_METHOD_BASETYPE (node))
629 print_node_brief (file, "method basetype",
630 TYPE_METHOD_BASETYPE (node), indent + 4);
631 print_node (file, "arg-types", TYPE_ARG_TYPES (node), indent + 4);
633 else if (TREE_CODE (node) == OFFSET_TYPE)
634 print_node_brief (file, "basetype", TYPE_OFFSET_BASETYPE (node),
635 indent + 4);
637 if (TYPE_CONTEXT (node))
638 print_node_brief (file, "context", TYPE_CONTEXT (node), indent + 4);
640 lang_hooks.print_type (file, node, indent);
642 if (TYPE_POINTER_TO (node) || TREE_CHAIN (node))
643 indent_to (file, indent + 3);
645 print_node_brief (file, "pointer_to_this", TYPE_POINTER_TO (node),
646 indent + 4);
647 print_node_brief (file, "reference_to_this", TYPE_REFERENCE_TO (node),
648 indent + 4);
649 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
650 break;
652 case tcc_expression:
653 case tcc_comparison:
654 case tcc_unary:
655 case tcc_binary:
656 case tcc_reference:
657 case tcc_statement:
658 if (TREE_CODE (node) == BIT_FIELD_REF && BIT_FIELD_REF_UNSIGNED (node))
659 fputs (" unsigned", file);
660 if (TREE_CODE (node) == BIND_EXPR)
662 print_node (file, "vars", TREE_OPERAND (node, 0), indent + 4);
663 print_node (file, "body", TREE_OPERAND (node, 1), indent + 4);
664 print_node (file, "block", TREE_OPERAND (node, 2), indent + 4);
665 break;
668 len = TREE_CODE_LENGTH (TREE_CODE (node));
670 for (i = 0; i < len; i++)
672 char temp[10];
674 sprintf (temp, "arg %d", i);
675 print_node (file, temp, TREE_OPERAND (node, i), indent + 4);
678 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
679 break;
681 case tcc_constant:
682 case tcc_exceptional:
683 switch (TREE_CODE (node))
685 case INTEGER_CST:
686 if (TREE_CONSTANT_OVERFLOW (node))
687 fprintf (file, " overflow");
689 fprintf (file, " ");
690 if (TREE_INT_CST_HIGH (node) == 0)
691 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED,
692 TREE_INT_CST_LOW (node));
693 else if (TREE_INT_CST_HIGH (node) == -1
694 && TREE_INT_CST_LOW (node) != 0)
695 fprintf (file, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
696 -TREE_INT_CST_LOW (node));
697 else
698 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
699 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
700 break;
702 case REAL_CST:
704 REAL_VALUE_TYPE d;
706 if (TREE_OVERFLOW (node))
707 fprintf (file, " overflow");
709 d = TREE_REAL_CST (node);
710 if (REAL_VALUE_ISINF (d))
711 fprintf (file, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
712 else if (REAL_VALUE_ISNAN (d))
713 fprintf (file, " Nan");
714 else
716 char string[64];
717 real_to_decimal (string, &d, sizeof (string), 0, 1);
718 fprintf (file, " %s", string);
721 break;
723 case VECTOR_CST:
725 tree vals = TREE_VECTOR_CST_ELTS (node);
726 char buf[10];
727 tree link;
728 int i;
730 i = 0;
731 for (link = vals; link; link = TREE_CHAIN (link), ++i)
733 sprintf (buf, "elt%d: ", i);
734 print_node (file, buf, TREE_VALUE (link), indent + 4);
737 break;
739 case COMPLEX_CST:
740 print_node (file, "real", TREE_REALPART (node), indent + 4);
741 print_node (file, "imag", TREE_IMAGPART (node), indent + 4);
742 break;
744 case STRING_CST:
746 const char *p = TREE_STRING_POINTER (node);
747 int i = TREE_STRING_LENGTH (node);
748 fputs (" \"", file);
749 while (--i >= 0)
751 char ch = *p++;
752 if (ch >= ' ' && ch < 127)
753 putc (ch, file);
754 else
755 fprintf(file, "\\%03o", ch & 0xFF);
757 fputc ('\"', file);
759 /* Print the chain at second level. */
760 if (indent == 4)
761 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
762 else
763 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
764 break;
766 case IDENTIFIER_NODE:
767 lang_hooks.print_identifier (file, node, indent);
768 break;
770 case TREE_LIST:
771 print_node (file, "purpose", TREE_PURPOSE (node), indent + 4);
772 print_node (file, "value", TREE_VALUE (node), indent + 4);
773 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
774 break;
776 case TREE_VEC:
777 len = TREE_VEC_LENGTH (node);
778 for (i = 0; i < len; i++)
779 if (TREE_VEC_ELT (node, i))
781 char temp[10];
782 sprintf (temp, "elt %d", i);
783 indent_to (file, indent + 4);
784 print_node_brief (file, temp, TREE_VEC_ELT (node, i), 0);
786 break;
788 case STATEMENT_LIST:
789 dump_addr (file, " head ", node->stmt_list.head);
790 dump_addr (file, " tail ", node->stmt_list.tail);
791 fprintf (file, " stmts");
793 tree_stmt_iterator i;
794 for (i = tsi_start (node); !tsi_end_p (i); tsi_next (&i))
796 /* Not printing the addresses of the (not-a-tree)
797 'struct tree_stmt_list_node's. */
798 dump_addr (file, " ", tsi_stmt (i));
800 fprintf (file, "\n");
801 for (i = tsi_start (node); !tsi_end_p (i); tsi_next (&i))
803 /* Not printing the addresses of the (not-a-tree)
804 'struct tree_stmt_list_node's. */
805 print_node (file, "stmt", tsi_stmt (i), indent + 4);
808 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
809 break;
811 case BLOCK:
812 print_node (file, "vars", BLOCK_VARS (node), indent + 4);
813 print_node (file, "supercontext", BLOCK_SUPERCONTEXT (node),
814 indent + 4);
815 print_node (file, "subblocks", BLOCK_SUBBLOCKS (node), indent + 4);
816 print_node (file, "chain", BLOCK_CHAIN (node), indent + 4);
817 print_node (file, "abstract_origin",
818 BLOCK_ABSTRACT_ORIGIN (node), indent + 4);
819 break;
821 case SSA_NAME:
822 print_node_brief (file, "var", SSA_NAME_VAR (node), indent + 4);
823 print_node_brief (file, "def_stmt",
824 SSA_NAME_DEF_STMT (node), indent + 4);
826 indent_to (file, indent + 4);
827 fprintf (file, "version %u", SSA_NAME_VERSION (node));
828 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
829 fprintf (file, " in-abnormal-phi");
830 if (SSA_NAME_IN_FREE_LIST (node))
831 fprintf (file, " in-free-list");
833 if (SSA_NAME_PTR_INFO (node)
834 || SSA_NAME_VALUE (node))
836 indent_to (file, indent + 3);
837 if (SSA_NAME_PTR_INFO (node))
838 dump_addr (file, " ptr-info ", SSA_NAME_PTR_INFO (node));
839 if (SSA_NAME_VALUE (node))
840 dump_addr (file, " value ", SSA_NAME_VALUE (node));
842 break;
844 case OMP_CLAUSE:
846 int i;
847 fprintf (file, " %s",
848 omp_clause_code_name[OMP_CLAUSE_CODE (node)]);
849 for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (node)]; i++)
851 indent_to (file, indent + 4);
852 fprintf (file, "op %d:", i);
853 print_node_brief (file, "", OMP_CLAUSE_OPERAND (node, i), 0);
856 break;
858 default:
859 if (EXCEPTIONAL_CLASS_P (node))
860 lang_hooks.print_xnode (file, node, indent);
861 break;
864 break;
867 if (EXPR_HAS_LOCATION (node))
869 expanded_location xloc = expand_location (EXPR_LOCATION (node));
870 indent_to (file, indent+4);
871 fprintf (file, "%s:%d", xloc.file, xloc.line);
874 fprintf (file, ">");