1/* Prints out tree in human readable form - GNU C-compiler
2 Copyright (C) 1990, 91, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING. If not, write to
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
20
21
22#include "config.h"
23#include "system.h"
24#include "tree.h"
25
26extern char *mode_name[];
27
28void print_node ();
29void indent_to ();
30
31/* Define the hash table of nodes already seen.
32 Such nodes are not repeated; brief cross-references are used. */
33
34#define HASH_SIZE 37
35
36struct bucket
37{
38 tree node;
39 struct bucket *next;
40};
41
42static struct bucket **table;
43
44/* Print the node NODE on standard error, for debugging.
45 Most nodes referred to by this one are printed recursively
46 down to a depth of six. */
47
48void
49debug_tree (node)
50 tree node;
51{
52 char *object = (char *) oballoc (0);
53
54 table = (struct bucket **) oballoc (HASH_SIZE * sizeof (struct bucket *));
55 bzero ((char *) table, HASH_SIZE * sizeof (struct bucket *));
56 print_node (stderr, "", node, 0);
57 table = 0;
58 obfree (object);
59 fprintf (stderr, "\n");
60}
61
62/* Print a node in brief fashion, with just the code, address and name. */
63
64void
65print_node_brief (file, prefix, node, indent)
66 FILE *file;
67 char *prefix;
68 tree node;
69 int indent;
70{
71 char class;
72
73 if (node == 0)
74 return;
75
76 class = TREE_CODE_CLASS (TREE_CODE (node));
77
78 /* Always print the slot this node is in, and its code, address and
79 name if any. */
80 if (indent > 0)
81 fprintf (file, " ");
82 fprintf (file, "%s <%s ", prefix, tree_code_name[(int) TREE_CODE (node)]);
83 fprintf (file, HOST_PTR_PRINTF, (char *) node);
84
85 if (class == 'd')
86 {
87 if (DECL_NAME (node))
88 fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
89 }
90 else if (class == 't')
91 {
92 if (TYPE_NAME (node))
93 {
94 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
95 fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
96 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
97 && DECL_NAME (TYPE_NAME (node)))
98 fprintf (file, " %s",
99 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
100 }
101 }
102 if (TREE_CODE (node) == IDENTIFIER_NODE)
103 fprintf (file, " %s", IDENTIFIER_POINTER (node));
104 /* We might as well always print the value of an integer. */
105 if (TREE_CODE (node) == INTEGER_CST)
106 {
107 if (TREE_CONSTANT_OVERFLOW (node))
108 fprintf (file, " overflow");
109
110 fprintf (file, " ");
111 if (TREE_INT_CST_HIGH (node) == 0)
112 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, TREE_INT_CST_LOW (node));
113 else if (TREE_INT_CST_HIGH (node) == -1
114 && TREE_INT_CST_LOW (node) != 0)
115 {
116 fprintf (file, "-");
117 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED,
118 -TREE_INT_CST_LOW (node));
119 }
120 else
121 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
122 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
123 }
124 if (TREE_CODE (node) == REAL_CST)
125 {
126 REAL_VALUE_TYPE d;
127
128 if (TREE_OVERFLOW (node))
129 fprintf (file, " overflow");
130
131#if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
132 d = TREE_REAL_CST (node);
133 if (REAL_VALUE_ISINF (d))
134 fprintf (file, " Inf");
135 else if (REAL_VALUE_ISNAN (d))
136 fprintf (file, " Nan");
137 else
138 {
139 char string[100];
140
141 REAL_VALUE_TO_DECIMAL (d, "%e", string);
142 fprintf (file, " %s", string);
143 }
144#else
145 {
146 int i;
147 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
148 fprintf (file, " 0x");
149 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
150 fprintf (file, "%02x", *p++);
151 fprintf (file, "");
152 }
153#endif
154 }
155
156 fprintf (file, ">");
157}
158
159void
160indent_to (file, column)
161 FILE *file;
162 int column;
163{
164 int i;
165
166 /* Since this is the long way, indent to desired column. */
167 if (column > 0)
168 fprintf (file, "\n");
169 for (i = 0; i < column; i++)
170 fprintf (file, " ");
171}
172
173/* Print the node NODE in full on file FILE, preceded by PREFIX,
174 starting in column INDENT. */
175
176void
177print_node (file, prefix, node, indent)
178 FILE *file;
179 char *prefix;
180 tree node;
181 int indent;
182{
183 int hash;
184 struct bucket *b;
185 enum machine_mode mode;
186 char class;
187 int len;
188 int first_rtl;
189 int i;
190
191 if (node == 0)
192 return;
193
194 class = TREE_CODE_CLASS (TREE_CODE (node));
195
196 /* Don't get too deep in nesting. If the user wants to see deeper,
197 it is easy to use the address of a lowest-level node
198 as an argument in another call to debug_tree. */
199
200 if (indent > 24)
201 {
202 print_node_brief (file, prefix, node, indent);
203 return;
204 }
205
206 if (indent > 8 && (class == 't' || class == 'd'))
207 {
208 print_node_brief (file, prefix, node, indent);
209 return;
210 }
211
212 /* It is unsafe to look at any other filds of an ERROR_MARK node. */
213 if (TREE_CODE (node) == ERROR_MARK)
214 {
215 print_node_brief (file, prefix, node, indent);
216 return;
217 }
218
219 hash = ((unsigned long) node) % HASH_SIZE;
220
221 /* If node is in the table, just mention its address. */
222 for (b = table[hash]; b; b = b->next)
223 if (b->node == node)
224 {
225 print_node_brief (file, prefix, node, indent);
226 return;
227 }
228
229 /* Add this node to the table. */
230 b = (struct bucket *) oballoc (sizeof (struct bucket));
231 b->node = node;
232 b->next = table[hash];
233 table[hash] = b;
234
235 /* Indent to the specified column, since this is the long form. */
236 indent_to (file, indent);
237
238 /* Print the slot this node is in, and its code, and address. */
239 fprintf (file, "%s <%s ", prefix, tree_code_name[(int) TREE_CODE (node)]);
240 fprintf (file, HOST_PTR_PRINTF, (char *) node);
241
242 /* Print the name, if any. */
243 if (class == 'd')
244 {
245 if (DECL_NAME (node))
246 fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
247 }
248 else if (class == 't')
249 {
250 if (TYPE_NAME (node))
251 {
252 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
253 fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
254 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
255 && DECL_NAME (TYPE_NAME (node)))
256 fprintf (file, " %s",
257 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
258 }
259 }
260 if (TREE_CODE (node) == IDENTIFIER_NODE)
261 fprintf (file, " %s", IDENTIFIER_POINTER (node));
262
263 if (TREE_CODE (node) == INTEGER_CST)
264 {
265 if (indent <= 4)
266 print_node_brief (file, "type", TREE_TYPE (node), indent + 4);
267 }
268 else
269 {
270 print_node (file, "type", TREE_TYPE (node), indent + 4);
271 if (TREE_TYPE (node))
272 indent_to (file, indent + 3);
273
274 print_obstack_name ((char *) node, file, "");
275 indent_to (file, indent + 3);
276 }
277
278 /* If a permanent object is in the wrong obstack, or the reverse, warn. */
279 if (object_permanent_p (node) != TREE_PERMANENT (node))
280 {
281 if (TREE_PERMANENT (node))
282 fputs (" !!permanent object in non-permanent obstack!!", file);
283 else
284 fputs (" !!non-permanent object in permanent obstack!!", file);
285 indent_to (file, indent + 3);
286 }
287
288 if (TREE_SIDE_EFFECTS (node))
289 fputs (" side-effects", file);
290 if (TREE_READONLY (node))
291 fputs (" readonly", file);
292 if (TREE_CONSTANT (node))
293 fputs (" constant", file);
294 if (TREE_ADDRESSABLE (node))
295 fputs (" addressable", file);
296 if (TREE_THIS_VOLATILE (node))
297 fputs (" volatile", file);
298 if (TREE_UNSIGNED (node))
299 fputs (" unsigned", file);
300 if (TREE_ASM_WRITTEN (node))
301 fputs (" asm_written", file);
302 if (TREE_USED (node))
303 fputs (" used", file);
304 if (TREE_RAISES (node))
305 fputs (" raises", file);
306 if (TREE_PERMANENT (node))
307 fputs (" permanent", file);
308 if (TREE_PUBLIC (node))
309 fputs (" public", file);
310 if (TREE_STATIC (node))
311 fputs (" static", file);
312 if (TREE_LANG_FLAG_0 (node))
313 fputs (" tree_0", file);
314 if (TREE_LANG_FLAG_1 (node))
315 fputs (" tree_1", file);
316 if (TREE_LANG_FLAG_2 (node))
317 fputs (" tree_2", file);
318 if (TREE_LANG_FLAG_3 (node))
319 fputs (" tree_3", file);
320 if (TREE_LANG_FLAG_4 (node))
321 fputs (" tree_4", file);
322 if (TREE_LANG_FLAG_5 (node))
323 fputs (" tree_5", file);
324 if (TREE_LANG_FLAG_6 (node))
325 fputs (" tree_6", file);
326
327 /* DECL_ nodes have additional attributes. */
328
329 switch (TREE_CODE_CLASS (TREE_CODE (node)))
330 {
331 case 'd':
332 mode = DECL_MODE (node);
333
334 if (DECL_IGNORED_P (node))
335 fputs (" ignored", file);
336 if (DECL_ABSTRACT (node))
337 fputs (" abstract", file);
338 if (DECL_IN_SYSTEM_HEADER (node))
339 fputs (" in_system_header", file);
340 if (DECL_COMMON (node))
341 fputs (" common", file);
342 if (DECL_EXTERNAL (node))
343 fputs (" external", file);
344 if (DECL_REGISTER (node))
345 fputs (" regdecl", file);
346 if (DECL_PACKED (node))
347 fputs (" packed", file);
348 if (DECL_NONLOCAL (node))
349 fputs (" nonlocal", file);
350 if (DECL_INLINE (node))
351 fputs (" inline", file);
352
353 if (TREE_CODE (node) == TYPE_DECL && TYPE_DECL_SUPPRESS_DEBUG (node))
354 fputs (" suppress-debug", file);
355
356 if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN (node))
357 fputs (" built-in", file);
358 if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN_NONANSI (node))
359 fputs (" built-in-nonansi", file);
360
361 if (TREE_CODE (node) == FIELD_DECL && DECL_BIT_FIELD (node))
362 fputs (" bit-field", file);
363 if (TREE_CODE (node) == LABEL_DECL && DECL_TOO_LATE (node))
364 fputs (" too-late", file);
365 if (TREE_CODE (node) == VAR_DECL && DECL_IN_TEXT_SECTION (node))
366 fputs (" in-text-section", file);
367
368 if (DECL_VIRTUAL_P (node))
369 fputs (" virtual", file);
370 if (DECL_DEFER_OUTPUT (node))
371 fputs (" defer-output", file);
372 if (DECL_TRANSPARENT_UNION (node))
373 fputs (" transparent-union", file);
374
375 if (DECL_LANG_FLAG_0 (node))
376 fputs (" decl_0", file);
377 if (DECL_LANG_FLAG_1 (node))
378 fputs (" decl_1", file);
379 if (DECL_LANG_FLAG_2 (node))
380 fputs (" decl_2", file);
381 if (DECL_LANG_FLAG_3 (node))
382 fputs (" decl_3", file);
383 if (DECL_LANG_FLAG_4 (node))
384 fputs (" decl_4", file);
385 if (DECL_LANG_FLAG_5 (node))
386 fputs (" decl_5", file);
387 if (DECL_LANG_FLAG_6 (node))
388 fputs (" decl_6", file);
389 if (DECL_LANG_FLAG_7 (node))
390 fputs (" decl_7", file);
391
392 fprintf (file, " %s", mode_name[(int) mode]);
393
394 fprintf (file, " file %s line %d",
395 DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
396
397 print_node (file, "size", DECL_SIZE (node), indent + 4);
398 indent_to (file, indent + 3);
399 if (TREE_CODE (node) != FUNCTION_DECL)
400 fprintf (file, " align %d", DECL_ALIGN (node));
401 else if (DECL_INLINE (node))
402 fprintf (file, " frame_size %d", DECL_FRAME_SIZE (node));
403 else if (DECL_BUILT_IN (node))
404 fprintf (file, " built-in code %d", DECL_FUNCTION_CODE (node));
405 if (TREE_CODE (node) == FIELD_DECL)
406 print_node (file, "bitpos", DECL_FIELD_BITPOS (node), indent + 4);
407 print_node_brief (file, "context", DECL_CONTEXT (node), indent + 4);
408 print_node_brief (file, "machine_attributes", DECL_MACHINE_ATTRIBUTES (node), indent + 4);
409 print_node_brief (file, "abstract_origin",
410 DECL_ABSTRACT_ORIGIN (node), indent + 4);
411
412 print_node (file, "arguments", DECL_ARGUMENTS (node), indent + 4);
413 print_node (file, "result", DECL_RESULT (node), indent + 4);
414 print_node_brief (file, "initial", DECL_INITIAL (node), indent + 4);
415
416 print_lang_decl (file, node, indent);
417
418 if (DECL_RTL (node) != 0)
419 {
420 indent_to (file, indent + 4);
421 print_rtl (file, DECL_RTL (node));
422 }
423
424 if (DECL_SAVED_INSNS (node) != 0)
425 {
426 indent_to (file, indent + 4);
427 if (TREE_CODE (node) == PARM_DECL)
428 {
429 fprintf (file, "incoming-rtl ");
430 print_rtl (file, DECL_INCOMING_RTL (node));
431 }
432 else if (TREE_CODE (node) == FUNCTION_DECL)
433 {
434 fprintf (file, "saved-insns ");
435 fprintf (file, HOST_PTR_PRINTF,
436 (char *) DECL_SAVED_INSNS (node));
437 }
438 }
439
440 /* Print the decl chain only if decl is at second level. */
441 if (indent == 4)
442 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
443 else
444 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
445 break;
446
447 case 't':
448 if (TYPE_NO_FORCE_BLK (node))
449 fputs (" no-force-blk", file);
450 if (TYPE_STRING_FLAG (node))
451 fputs (" string-flag", file);
452 if (TYPE_NEEDS_CONSTRUCTING (node))
453 fputs (" needs-constructing", file);
454 if (TYPE_TRANSPARENT_UNION (node))
455 fputs (" transparent-union", file);
456 if (TYPE_PACKED (node))
457 fputs (" packed", file);
458
459 if (TYPE_LANG_FLAG_0 (node))
460 fputs (" type_0", file);
461 if (TYPE_LANG_FLAG_1 (node))
462 fputs (" type_1", file);
463 if (TYPE_LANG_FLAG_2 (node))
464 fputs (" type_2", file);
465 if (TYPE_LANG_FLAG_3 (node))
466 fputs (" type_3", file);
467 if (TYPE_LANG_FLAG_4 (node))
468 fputs (" type_4", file);
469 if (TYPE_LANG_FLAG_5 (node))
470 fputs (" type_5", file);
471 if (TYPE_LANG_FLAG_6 (node))
472 fputs (" type_6", file);
473
474 mode = TYPE_MODE (node);
475 fprintf (file, " %s", mode_name[(int) mode]);
476
477 print_node (file, "size", TYPE_SIZE (node), indent + 4);
478 indent_to (file, indent + 3);
479
480 fprintf (file, " align %d", TYPE_ALIGN (node));
481 fprintf (file, " symtab %d", TYPE_SYMTAB_ADDRESS (node));
482 fprintf (file, " alias set %d", TYPE_ALIAS_SET (node));
483
484 print_node (file, "attributes", TYPE_ATTRIBUTES (node), indent + 4);
485
486 if (TREE_CODE (node) == ARRAY_TYPE || TREE_CODE (node) == SET_TYPE)
487 print_node (file, "domain", TYPE_DOMAIN (node), indent + 4);
488 else if (TREE_CODE (node) == INTEGER_TYPE
489 || TREE_CODE (node) == BOOLEAN_TYPE
490 || TREE_CODE (node) == CHAR_TYPE)
491 {
492 fprintf (file, " precision %d", TYPE_PRECISION (node));
493 print_node (file, "min", TYPE_MIN_VALUE (node), indent + 4);
494 print_node (file, "max", TYPE_MAX_VALUE (node), indent + 4);
495 }
496 else if (TREE_CODE (node) == ENUMERAL_TYPE)
497 {
498 fprintf (file, " precision %d", TYPE_PRECISION (node));
499 print_node (file, "min", TYPE_MIN_VALUE (node), indent + 4);
500 print_node (file, "max", TYPE_MAX_VALUE (node), indent + 4);
501 print_node (file, "values", TYPE_VALUES (node), indent + 4);
502 }
503 else if (TREE_CODE (node) == REAL_TYPE)
504 fprintf (file, " precision %d", TYPE_PRECISION (node));
505 else if (TREE_CODE (node) == RECORD_TYPE
506 || TREE_CODE (node) == UNION_TYPE
507 || TREE_CODE (node) == QUAL_UNION_TYPE)
508 print_node (file, "fields", TYPE_FIELDS (node), indent + 4);
509 else if (TREE_CODE (node) == FUNCTION_TYPE || TREE_CODE (node) == METHOD_TYPE)
510 {
511 if (TYPE_METHOD_BASETYPE (node))
512 print_node_brief (file, "method basetype", TYPE_METHOD_BASETYPE (node), indent + 4);
513 print_node (file, "arg-types", TYPE_ARG_TYPES (node), indent + 4);
514 }
515 if (TYPE_CONTEXT (node))
516 print_node_brief (file, "context", TYPE_CONTEXT (node), indent + 4);
517
518 print_lang_type (file, node, indent);
519
520 if (TYPE_POINTER_TO (node) || TREE_CHAIN (node))
521 indent_to (file, indent + 3);
522 print_node_brief (file, "pointer_to_this", TYPE_POINTER_TO (node), indent + 4);
523 print_node_brief (file, "reference_to_this", TYPE_REFERENCE_TO (node), indent + 4);
524 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
525 break;
526
527 case 'b':
528 print_node (file, "vars", BLOCK_VARS (node), indent + 4);
529 print_node (file, "tags", BLOCK_TYPE_TAGS (node), indent + 4);
530 print_node (file, "supercontext", BLOCK_SUPERCONTEXT (node), indent + 4);
531 print_node (file, "subblocks", BLOCK_SUBBLOCKS (node), indent + 4);
532 print_node (file, "chain", BLOCK_CHAIN (node), indent + 4);
533 print_node (file, "abstract_origin",
534 BLOCK_ABSTRACT_ORIGIN (node), indent + 4);
535 return;
536
537 case 'e':
538 case '<':
539 case '1':
540 case '2':
541 case 'r':
542 case 's':
543 if (TREE_CODE (node) == BIND_EXPR)
544 {
545 print_node (file, "vars", TREE_OPERAND (node, 0), indent + 4);
546 print_node (file, "body", TREE_OPERAND (node, 1), indent + 4);
547 print_node (file, "block", TREE_OPERAND (node, 2), indent + 4);
548 return;
549 }
550
551 len = tree_code_length[(int) TREE_CODE (node)];
552 /* Some nodes contain rtx's, not trees,
553 after a certain point. Print the rtx's as rtx's. */
554 first_rtl = first_rtl_op (TREE_CODE (node));
555 for (i = 0; i < len; i++)
556 {
557 if (i >= first_rtl)
558 {
559 indent_to (file, indent + 4);
560 fprintf (file, "rtl %d ", i);
561 if (TREE_OPERAND (node, i))
562 print_rtl (file, (struct rtx_def *) TREE_OPERAND (node, i));
563 else
564 fprintf (file, "(nil)");
565 fprintf (file, "\n");
566 }
567 else
568 {
569 char temp[10];
570
571 sprintf (temp, "arg %d", i);
572 print_node (file, temp, TREE_OPERAND (node, i), indent + 4);
573 }
574 }
575
576 if (TREE_CODE (node) == EXPR_WITH_FILE_LOCATION)
577 {
578 indent_to (file, indent+4);
579 fprintf (file, "%s:%d:%d",
580 (EXPR_WFL_FILENAME_NODE (node ) ?
581 EXPR_WFL_FILENAME (node) : "(no file info)"),
582 EXPR_WFL_LINENO (node), EXPR_WFL_COLNO (node));
583 }
584 break;
585
586 case 'c':
587 case 'x':
588 switch (TREE_CODE (node))
589 {
590 case INTEGER_CST:
591 if (TREE_CONSTANT_OVERFLOW (node))
592 fprintf (file, " overflow");
593
594 fprintf (file, " ");
595 if (TREE_INT_CST_HIGH (node) == 0)
596 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED,
597 TREE_INT_CST_LOW (node));
598 else if (TREE_INT_CST_HIGH (node) == -1
599 && TREE_INT_CST_LOW (node) != 0)
600 {
601 fprintf (file, "-");
602 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED,
603 -TREE_INT_CST_LOW (node));
604 }
605 else
606 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
607 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
608 break;
609
610 case REAL_CST:
611 {
612 REAL_VALUE_TYPE d;
613
614 if (TREE_OVERFLOW (node))
615 fprintf (file, " overflow");
616
617#if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
618 d = TREE_REAL_CST (node);
619 if (REAL_VALUE_ISINF (d))
620 fprintf (file, " Inf");
621 else if (REAL_VALUE_ISNAN (d))
622 fprintf (file, " Nan");
623 else
624 {
625 char string[100];
626
627 REAL_VALUE_TO_DECIMAL (d, "%e", string);
628 fprintf (file, " %s", string);
629 }
630#else
631 {
632 int i;
633 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
634 fprintf (file, " 0x");
635 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
636 fprintf (file, "%02x", *p++);
637 fprintf (file, "");
638 }
639#endif
640 }
641 break;
642
643 case COMPLEX_CST:
644 print_node (file, "real", TREE_REALPART (node), indent + 4);
645 print_node (file, "imag", TREE_IMAGPART (node), indent + 4);
646 break;
647
648 case STRING_CST:
649 fprintf (file, " \"%s\"", TREE_STRING_POINTER (node));
650 /* Print the chain at second level. */
651 if (indent == 4)
652 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
653 else
654 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
655 break;
656
657 case IDENTIFIER_NODE:
658 print_lang_identifier (file, node, indent);
659 break;
660
661 case TREE_LIST:
662 print_node (file, "purpose", TREE_PURPOSE (node), indent + 4);
663 print_node (file, "value", TREE_VALUE (node), indent + 4);
664 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
665 break;
666
667 case TREE_VEC:
668 len = TREE_VEC_LENGTH (node);
669 for (i = 0; i < len; i++)
670 if (TREE_VEC_ELT (node, i))
671 {
672 char temp[10];
673 sprintf (temp, "elt %d", i);
674 indent_to (file, indent + 4);
675 print_node_brief (file, temp, TREE_VEC_ELT (node, i), 0);
676 }
677 break;
678
679 case OP_IDENTIFIER:
680 print_node (file, "op1", TREE_PURPOSE (node), indent + 4);
681 print_node (file, "op2", TREE_VALUE (node), indent + 4);
682 break;
683
684 default:
685 if (TREE_CODE_CLASS (TREE_CODE (node)) == 'x')
686 lang_print_xnode (file, node, indent);
687 break;
688 }
689
690 break;
691 }
692
693 fprintf (file, ">");
694}
2 Copyright (C) 1990, 91, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING. If not, write to
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
20
21
22#include "config.h"
23#include "system.h"
24#include "tree.h"
25
26extern char *mode_name[];
27
28void print_node ();
29void indent_to ();
30
31/* Define the hash table of nodes already seen.
32 Such nodes are not repeated; brief cross-references are used. */
33
34#define HASH_SIZE 37
35
36struct bucket
37{
38 tree node;
39 struct bucket *next;
40};
41
42static struct bucket **table;
43
44/* Print the node NODE on standard error, for debugging.
45 Most nodes referred to by this one are printed recursively
46 down to a depth of six. */
47
48void
49debug_tree (node)
50 tree node;
51{
52 char *object = (char *) oballoc (0);
53
54 table = (struct bucket **) oballoc (HASH_SIZE * sizeof (struct bucket *));
55 bzero ((char *) table, HASH_SIZE * sizeof (struct bucket *));
56 print_node (stderr, "", node, 0);
57 table = 0;
58 obfree (object);
59 fprintf (stderr, "\n");
60}
61
62/* Print a node in brief fashion, with just the code, address and name. */
63
64void
65print_node_brief (file, prefix, node, indent)
66 FILE *file;
67 char *prefix;
68 tree node;
69 int indent;
70{
71 char class;
72
73 if (node == 0)
74 return;
75
76 class = TREE_CODE_CLASS (TREE_CODE (node));
77
78 /* Always print the slot this node is in, and its code, address and
79 name if any. */
80 if (indent > 0)
81 fprintf (file, " ");
82 fprintf (file, "%s <%s ", prefix, tree_code_name[(int) TREE_CODE (node)]);
83 fprintf (file, HOST_PTR_PRINTF, (char *) node);
84
85 if (class == 'd')
86 {
87 if (DECL_NAME (node))
88 fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
89 }
90 else if (class == 't')
91 {
92 if (TYPE_NAME (node))
93 {
94 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
95 fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
96 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
97 && DECL_NAME (TYPE_NAME (node)))
98 fprintf (file, " %s",
99 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
100 }
101 }
102 if (TREE_CODE (node) == IDENTIFIER_NODE)
103 fprintf (file, " %s", IDENTIFIER_POINTER (node));
104 /* We might as well always print the value of an integer. */
105 if (TREE_CODE (node) == INTEGER_CST)
106 {
107 if (TREE_CONSTANT_OVERFLOW (node))
108 fprintf (file, " overflow");
109
110 fprintf (file, " ");
111 if (TREE_INT_CST_HIGH (node) == 0)
112 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, TREE_INT_CST_LOW (node));
113 else if (TREE_INT_CST_HIGH (node) == -1
114 && TREE_INT_CST_LOW (node) != 0)
115 {
116 fprintf (file, "-");
117 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED,
118 -TREE_INT_CST_LOW (node));
119 }
120 else
121 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
122 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
123 }
124 if (TREE_CODE (node) == REAL_CST)
125 {
126 REAL_VALUE_TYPE d;
127
128 if (TREE_OVERFLOW (node))
129 fprintf (file, " overflow");
130
131#if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
132 d = TREE_REAL_CST (node);
133 if (REAL_VALUE_ISINF (d))
134 fprintf (file, " Inf");
135 else if (REAL_VALUE_ISNAN (d))
136 fprintf (file, " Nan");
137 else
138 {
139 char string[100];
140
141 REAL_VALUE_TO_DECIMAL (d, "%e", string);
142 fprintf (file, " %s", string);
143 }
144#else
145 {
146 int i;
147 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
148 fprintf (file, " 0x");
149 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
150 fprintf (file, "%02x", *p++);
151 fprintf (file, "");
152 }
153#endif
154 }
155
156 fprintf (file, ">");
157}
158
159void
160indent_to (file, column)
161 FILE *file;
162 int column;
163{
164 int i;
165
166 /* Since this is the long way, indent to desired column. */
167 if (column > 0)
168 fprintf (file, "\n");
169 for (i = 0; i < column; i++)
170 fprintf (file, " ");
171}
172
173/* Print the node NODE in full on file FILE, preceded by PREFIX,
174 starting in column INDENT. */
175
176void
177print_node (file, prefix, node, indent)
178 FILE *file;
179 char *prefix;
180 tree node;
181 int indent;
182{
183 int hash;
184 struct bucket *b;
185 enum machine_mode mode;
186 char class;
187 int len;
188 int first_rtl;
189 int i;
190
191 if (node == 0)
192 return;
193
194 class = TREE_CODE_CLASS (TREE_CODE (node));
195
196 /* Don't get too deep in nesting. If the user wants to see deeper,
197 it is easy to use the address of a lowest-level node
198 as an argument in another call to debug_tree. */
199
200 if (indent > 24)
201 {
202 print_node_brief (file, prefix, node, indent);
203 return;
204 }
205
206 if (indent > 8 && (class == 't' || class == 'd'))
207 {
208 print_node_brief (file, prefix, node, indent);
209 return;
210 }
211
212 /* It is unsafe to look at any other filds of an ERROR_MARK node. */
213 if (TREE_CODE (node) == ERROR_MARK)
214 {
215 print_node_brief (file, prefix, node, indent);
216 return;
217 }
218
219 hash = ((unsigned long) node) % HASH_SIZE;
220
221 /* If node is in the table, just mention its address. */
222 for (b = table[hash]; b; b = b->next)
223 if (b->node == node)
224 {
225 print_node_brief (file, prefix, node, indent);
226 return;
227 }
228
229 /* Add this node to the table. */
230 b = (struct bucket *) oballoc (sizeof (struct bucket));
231 b->node = node;
232 b->next = table[hash];
233 table[hash] = b;
234
235 /* Indent to the specified column, since this is the long form. */
236 indent_to (file, indent);
237
238 /* Print the slot this node is in, and its code, and address. */
239 fprintf (file, "%s <%s ", prefix, tree_code_name[(int) TREE_CODE (node)]);
240 fprintf (file, HOST_PTR_PRINTF, (char *) node);
241
242 /* Print the name, if any. */
243 if (class == 'd')
244 {
245 if (DECL_NAME (node))
246 fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
247 }
248 else if (class == 't')
249 {
250 if (TYPE_NAME (node))
251 {
252 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
253 fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
254 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
255 && DECL_NAME (TYPE_NAME (node)))
256 fprintf (file, " %s",
257 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
258 }
259 }
260 if (TREE_CODE (node) == IDENTIFIER_NODE)
261 fprintf (file, " %s", IDENTIFIER_POINTER (node));
262
263 if (TREE_CODE (node) == INTEGER_CST)
264 {
265 if (indent <= 4)
266 print_node_brief (file, "type", TREE_TYPE (node), indent + 4);
267 }
268 else
269 {
270 print_node (file, "type", TREE_TYPE (node), indent + 4);
271 if (TREE_TYPE (node))
272 indent_to (file, indent + 3);
273
274 print_obstack_name ((char *) node, file, "");
275 indent_to (file, indent + 3);
276 }
277
278 /* If a permanent object is in the wrong obstack, or the reverse, warn. */
279 if (object_permanent_p (node) != TREE_PERMANENT (node))
280 {
281 if (TREE_PERMANENT (node))
282 fputs (" !!permanent object in non-permanent obstack!!", file);
283 else
284 fputs (" !!non-permanent object in permanent obstack!!", file);
285 indent_to (file, indent + 3);
286 }
287
288 if (TREE_SIDE_EFFECTS (node))
289 fputs (" side-effects", file);
290 if (TREE_READONLY (node))
291 fputs (" readonly", file);
292 if (TREE_CONSTANT (node))
293 fputs (" constant", file);
294 if (TREE_ADDRESSABLE (node))
295 fputs (" addressable", file);
296 if (TREE_THIS_VOLATILE (node))
297 fputs (" volatile", file);
298 if (TREE_UNSIGNED (node))
299 fputs (" unsigned", file);
300 if (TREE_ASM_WRITTEN (node))
301 fputs (" asm_written", file);
302 if (TREE_USED (node))
303 fputs (" used", file);
304 if (TREE_RAISES (node))
305 fputs (" raises", file);
306 if (TREE_PERMANENT (node))
307 fputs (" permanent", file);
308 if (TREE_PUBLIC (node))
309 fputs (" public", file);
310 if (TREE_STATIC (node))
311 fputs (" static", file);
312 if (TREE_LANG_FLAG_0 (node))
313 fputs (" tree_0", file);
314 if (TREE_LANG_FLAG_1 (node))
315 fputs (" tree_1", file);
316 if (TREE_LANG_FLAG_2 (node))
317 fputs (" tree_2", file);
318 if (TREE_LANG_FLAG_3 (node))
319 fputs (" tree_3", file);
320 if (TREE_LANG_FLAG_4 (node))
321 fputs (" tree_4", file);
322 if (TREE_LANG_FLAG_5 (node))
323 fputs (" tree_5", file);
324 if (TREE_LANG_FLAG_6 (node))
325 fputs (" tree_6", file);
326
327 /* DECL_ nodes have additional attributes. */
328
329 switch (TREE_CODE_CLASS (TREE_CODE (node)))
330 {
331 case 'd':
332 mode = DECL_MODE (node);
333
334 if (DECL_IGNORED_P (node))
335 fputs (" ignored", file);
336 if (DECL_ABSTRACT (node))
337 fputs (" abstract", file);
338 if (DECL_IN_SYSTEM_HEADER (node))
339 fputs (" in_system_header", file);
340 if (DECL_COMMON (node))
341 fputs (" common", file);
342 if (DECL_EXTERNAL (node))
343 fputs (" external", file);
344 if (DECL_REGISTER (node))
345 fputs (" regdecl", file);
346 if (DECL_PACKED (node))
347 fputs (" packed", file);
348 if (DECL_NONLOCAL (node))
349 fputs (" nonlocal", file);
350 if (DECL_INLINE (node))
351 fputs (" inline", file);
352
353 if (TREE_CODE (node) == TYPE_DECL && TYPE_DECL_SUPPRESS_DEBUG (node))
354 fputs (" suppress-debug", file);
355
356 if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN (node))
357 fputs (" built-in", file);
358 if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN_NONANSI (node))
359 fputs (" built-in-nonansi", file);
360
361 if (TREE_CODE (node) == FIELD_DECL && DECL_BIT_FIELD (node))
362 fputs (" bit-field", file);
363 if (TREE_CODE (node) == LABEL_DECL && DECL_TOO_LATE (node))
364 fputs (" too-late", file);
365 if (TREE_CODE (node) == VAR_DECL && DECL_IN_TEXT_SECTION (node))
366 fputs (" in-text-section", file);
367
368 if (DECL_VIRTUAL_P (node))
369 fputs (" virtual", file);
370 if (DECL_DEFER_OUTPUT (node))
371 fputs (" defer-output", file);
372 if (DECL_TRANSPARENT_UNION (node))
373 fputs (" transparent-union", file);
374
375 if (DECL_LANG_FLAG_0 (node))
376 fputs (" decl_0", file);
377 if (DECL_LANG_FLAG_1 (node))
378 fputs (" decl_1", file);
379 if (DECL_LANG_FLAG_2 (node))
380 fputs (" decl_2", file);
381 if (DECL_LANG_FLAG_3 (node))
382 fputs (" decl_3", file);
383 if (DECL_LANG_FLAG_4 (node))
384 fputs (" decl_4", file);
385 if (DECL_LANG_FLAG_5 (node))
386 fputs (" decl_5", file);
387 if (DECL_LANG_FLAG_6 (node))
388 fputs (" decl_6", file);
389 if (DECL_LANG_FLAG_7 (node))
390 fputs (" decl_7", file);
391
392 fprintf (file, " %s", mode_name[(int) mode]);
393
394 fprintf (file, " file %s line %d",
395 DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
396
397 print_node (file, "size", DECL_SIZE (node), indent + 4);
398 indent_to (file, indent + 3);
399 if (TREE_CODE (node) != FUNCTION_DECL)
400 fprintf (file, " align %d", DECL_ALIGN (node));
401 else if (DECL_INLINE (node))
402 fprintf (file, " frame_size %d", DECL_FRAME_SIZE (node));
403 else if (DECL_BUILT_IN (node))
404 fprintf (file, " built-in code %d", DECL_FUNCTION_CODE (node));
405 if (TREE_CODE (node) == FIELD_DECL)
406 print_node (file, "bitpos", DECL_FIELD_BITPOS (node), indent + 4);
407 print_node_brief (file, "context", DECL_CONTEXT (node), indent + 4);
408 print_node_brief (file, "machine_attributes", DECL_MACHINE_ATTRIBUTES (node), indent + 4);
409 print_node_brief (file, "abstract_origin",
410 DECL_ABSTRACT_ORIGIN (node), indent + 4);
411
412 print_node (file, "arguments", DECL_ARGUMENTS (node), indent + 4);
413 print_node (file, "result", DECL_RESULT (node), indent + 4);
414 print_node_brief (file, "initial", DECL_INITIAL (node), indent + 4);
415
416 print_lang_decl (file, node, indent);
417
418 if (DECL_RTL (node) != 0)
419 {
420 indent_to (file, indent + 4);
421 print_rtl (file, DECL_RTL (node));
422 }
423
424 if (DECL_SAVED_INSNS (node) != 0)
425 {
426 indent_to (file, indent + 4);
427 if (TREE_CODE (node) == PARM_DECL)
428 {
429 fprintf (file, "incoming-rtl ");
430 print_rtl (file, DECL_INCOMING_RTL (node));
431 }
432 else if (TREE_CODE (node) == FUNCTION_DECL)
433 {
434 fprintf (file, "saved-insns ");
435 fprintf (file, HOST_PTR_PRINTF,
436 (char *) DECL_SAVED_INSNS (node));
437 }
438 }
439
440 /* Print the decl chain only if decl is at second level. */
441 if (indent == 4)
442 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
443 else
444 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
445 break;
446
447 case 't':
448 if (TYPE_NO_FORCE_BLK (node))
449 fputs (" no-force-blk", file);
450 if (TYPE_STRING_FLAG (node))
451 fputs (" string-flag", file);
452 if (TYPE_NEEDS_CONSTRUCTING (node))
453 fputs (" needs-constructing", file);
454 if (TYPE_TRANSPARENT_UNION (node))
455 fputs (" transparent-union", file);
456 if (TYPE_PACKED (node))
457 fputs (" packed", file);
458
459 if (TYPE_LANG_FLAG_0 (node))
460 fputs (" type_0", file);
461 if (TYPE_LANG_FLAG_1 (node))
462 fputs (" type_1", file);
463 if (TYPE_LANG_FLAG_2 (node))
464 fputs (" type_2", file);
465 if (TYPE_LANG_FLAG_3 (node))
466 fputs (" type_3", file);
467 if (TYPE_LANG_FLAG_4 (node))
468 fputs (" type_4", file);
469 if (TYPE_LANG_FLAG_5 (node))
470 fputs (" type_5", file);
471 if (TYPE_LANG_FLAG_6 (node))
472 fputs (" type_6", file);
473
474 mode = TYPE_MODE (node);
475 fprintf (file, " %s", mode_name[(int) mode]);
476
477 print_node (file, "size", TYPE_SIZE (node), indent + 4);
478 indent_to (file, indent + 3);
479
480 fprintf (file, " align %d", TYPE_ALIGN (node));
481 fprintf (file, " symtab %d", TYPE_SYMTAB_ADDRESS (node));
482 fprintf (file, " alias set %d", TYPE_ALIAS_SET (node));
483
484 print_node (file, "attributes", TYPE_ATTRIBUTES (node), indent + 4);
485
486 if (TREE_CODE (node) == ARRAY_TYPE || TREE_CODE (node) == SET_TYPE)
487 print_node (file, "domain", TYPE_DOMAIN (node), indent + 4);
488 else if (TREE_CODE (node) == INTEGER_TYPE
489 || TREE_CODE (node) == BOOLEAN_TYPE
490 || TREE_CODE (node) == CHAR_TYPE)
491 {
492 fprintf (file, " precision %d", TYPE_PRECISION (node));
493 print_node (file, "min", TYPE_MIN_VALUE (node), indent + 4);
494 print_node (file, "max", TYPE_MAX_VALUE (node), indent + 4);
495 }
496 else if (TREE_CODE (node) == ENUMERAL_TYPE)
497 {
498 fprintf (file, " precision %d", TYPE_PRECISION (node));
499 print_node (file, "min", TYPE_MIN_VALUE (node), indent + 4);
500 print_node (file, "max", TYPE_MAX_VALUE (node), indent + 4);
501 print_node (file, "values", TYPE_VALUES (node), indent + 4);
502 }
503 else if (TREE_CODE (node) == REAL_TYPE)
504 fprintf (file, " precision %d", TYPE_PRECISION (node));
505 else if (TREE_CODE (node) == RECORD_TYPE
506 || TREE_CODE (node) == UNION_TYPE
507 || TREE_CODE (node) == QUAL_UNION_TYPE)
508 print_node (file, "fields", TYPE_FIELDS (node), indent + 4);
509 else if (TREE_CODE (node) == FUNCTION_TYPE || TREE_CODE (node) == METHOD_TYPE)
510 {
511 if (TYPE_METHOD_BASETYPE (node))
512 print_node_brief (file, "method basetype", TYPE_METHOD_BASETYPE (node), indent + 4);
513 print_node (file, "arg-types", TYPE_ARG_TYPES (node), indent + 4);
514 }
515 if (TYPE_CONTEXT (node))
516 print_node_brief (file, "context", TYPE_CONTEXT (node), indent + 4);
517
518 print_lang_type (file, node, indent);
519
520 if (TYPE_POINTER_TO (node) || TREE_CHAIN (node))
521 indent_to (file, indent + 3);
522 print_node_brief (file, "pointer_to_this", TYPE_POINTER_TO (node), indent + 4);
523 print_node_brief (file, "reference_to_this", TYPE_REFERENCE_TO (node), indent + 4);
524 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
525 break;
526
527 case 'b':
528 print_node (file, "vars", BLOCK_VARS (node), indent + 4);
529 print_node (file, "tags", BLOCK_TYPE_TAGS (node), indent + 4);
530 print_node (file, "supercontext", BLOCK_SUPERCONTEXT (node), indent + 4);
531 print_node (file, "subblocks", BLOCK_SUBBLOCKS (node), indent + 4);
532 print_node (file, "chain", BLOCK_CHAIN (node), indent + 4);
533 print_node (file, "abstract_origin",
534 BLOCK_ABSTRACT_ORIGIN (node), indent + 4);
535 return;
536
537 case 'e':
538 case '<':
539 case '1':
540 case '2':
541 case 'r':
542 case 's':
543 if (TREE_CODE (node) == BIND_EXPR)
544 {
545 print_node (file, "vars", TREE_OPERAND (node, 0), indent + 4);
546 print_node (file, "body", TREE_OPERAND (node, 1), indent + 4);
547 print_node (file, "block", TREE_OPERAND (node, 2), indent + 4);
548 return;
549 }
550
551 len = tree_code_length[(int) TREE_CODE (node)];
552 /* Some nodes contain rtx's, not trees,
553 after a certain point. Print the rtx's as rtx's. */
554 first_rtl = first_rtl_op (TREE_CODE (node));
555 for (i = 0; i < len; i++)
556 {
557 if (i >= first_rtl)
558 {
559 indent_to (file, indent + 4);
560 fprintf (file, "rtl %d ", i);
561 if (TREE_OPERAND (node, i))
562 print_rtl (file, (struct rtx_def *) TREE_OPERAND (node, i));
563 else
564 fprintf (file, "(nil)");
565 fprintf (file, "\n");
566 }
567 else
568 {
569 char temp[10];
570
571 sprintf (temp, "arg %d", i);
572 print_node (file, temp, TREE_OPERAND (node, i), indent + 4);
573 }
574 }
575
576 if (TREE_CODE (node) == EXPR_WITH_FILE_LOCATION)
577 {
578 indent_to (file, indent+4);
579 fprintf (file, "%s:%d:%d",
580 (EXPR_WFL_FILENAME_NODE (node ) ?
581 EXPR_WFL_FILENAME (node) : "(no file info)"),
582 EXPR_WFL_LINENO (node), EXPR_WFL_COLNO (node));
583 }
584 break;
585
586 case 'c':
587 case 'x':
588 switch (TREE_CODE (node))
589 {
590 case INTEGER_CST:
591 if (TREE_CONSTANT_OVERFLOW (node))
592 fprintf (file, " overflow");
593
594 fprintf (file, " ");
595 if (TREE_INT_CST_HIGH (node) == 0)
596 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED,
597 TREE_INT_CST_LOW (node));
598 else if (TREE_INT_CST_HIGH (node) == -1
599 && TREE_INT_CST_LOW (node) != 0)
600 {
601 fprintf (file, "-");
602 fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED,
603 -TREE_INT_CST_LOW (node));
604 }
605 else
606 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
607 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
608 break;
609
610 case REAL_CST:
611 {
612 REAL_VALUE_TYPE d;
613
614 if (TREE_OVERFLOW (node))
615 fprintf (file, " overflow");
616
617#if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
618 d = TREE_REAL_CST (node);
619 if (REAL_VALUE_ISINF (d))
620 fprintf (file, " Inf");
621 else if (REAL_VALUE_ISNAN (d))
622 fprintf (file, " Nan");
623 else
624 {
625 char string[100];
626
627 REAL_VALUE_TO_DECIMAL (d, "%e", string);
628 fprintf (file, " %s", string);
629 }
630#else
631 {
632 int i;
633 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
634 fprintf (file, " 0x");
635 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
636 fprintf (file, "%02x", *p++);
637 fprintf (file, "");
638 }
639#endif
640 }
641 break;
642
643 case COMPLEX_CST:
644 print_node (file, "real", TREE_REALPART (node), indent + 4);
645 print_node (file, "imag", TREE_IMAGPART (node), indent + 4);
646 break;
647
648 case STRING_CST:
649 fprintf (file, " \"%s\"", TREE_STRING_POINTER (node));
650 /* Print the chain at second level. */
651 if (indent == 4)
652 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
653 else
654 print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
655 break;
656
657 case IDENTIFIER_NODE:
658 print_lang_identifier (file, node, indent);
659 break;
660
661 case TREE_LIST:
662 print_node (file, "purpose", TREE_PURPOSE (node), indent + 4);
663 print_node (file, "value", TREE_VALUE (node), indent + 4);
664 print_node (file, "chain", TREE_CHAIN (node), indent + 4);
665 break;
666
667 case TREE_VEC:
668 len = TREE_VEC_LENGTH (node);
669 for (i = 0; i < len; i++)
670 if (TREE_VEC_ELT (node, i))
671 {
672 char temp[10];
673 sprintf (temp, "elt %d", i);
674 indent_to (file, indent + 4);
675 print_node_brief (file, temp, TREE_VEC_ELT (node, i), 0);
676 }
677 break;
678
679 case OP_IDENTIFIER:
680 print_node (file, "op1", TREE_PURPOSE (node), indent + 4);
681 print_node (file, "op2", TREE_VALUE (node), indent + 4);
682 break;
683
684 default:
685 if (TREE_CODE_CLASS (TREE_CODE (node)) == 'x')
686 lang_print_xnode (file, node, indent);
687 break;
688 }
689
690 break;
691 }
692
693 fprintf (file, ">");
694}