OSDN Git Service

2005-06-30 Andrew Pinski <pinskia@physics.uc.edu>
[pf3gnuchains/gcc-fork.git] / gcc / print-tree.c
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 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
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 2, or (at your option) any later
10 version.
11
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.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301, USA.  */
21
22
23 #include "config.h"
24 #include "system.h"
25 #include "coretypes.h"
26 #include "tm.h"
27 #include "tree.h"
28 #include "real.h"
29 #include "ggc.h"
30 #include "langhooks.h"
31 #include "tree-iterator.h"
32
33 /* Define the hash table of nodes already seen.
34    Such nodes are not repeated; brief cross-references are used.  */
35
36 #define HASH_SIZE 37
37
38 struct bucket
39 {
40   tree node;
41   struct bucket *next;
42 };
43
44 static struct bucket **table;
45
46 /* Print the node NODE on standard error, for debugging.
47    Most nodes referred to by this one are printed recursively
48    down to a depth of six.  */
49
50 void
51 debug_tree (tree node)
52 {
53   table = xcalloc (HASH_SIZE, sizeof (struct bucket *));
54   print_node (stderr, "", node, 0);
55   free (table);
56   table = 0;
57   putc ('\n', stderr);
58 }
59
60 /* Print a node in brief fashion, with just the code, address and name.  */
61
62 void
63 print_node_brief (FILE *file, const char *prefix, tree node, int indent)
64 {
65   enum tree_code_class class;
66
67   if (node == 0)
68     return;
69
70   class = TREE_CODE_CLASS (TREE_CODE (node));
71
72   /* Always print the slot this node is in, and its code, address and
73      name if any.  */
74   if (indent > 0)
75     fprintf (file, " ");
76   fprintf (file, "%s <%s " HOST_PTR_PRINTF,
77            prefix, tree_code_name[(int) TREE_CODE (node)], (char *) node);
78
79   if (class == tcc_declaration)
80     {
81       if (DECL_NAME (node))
82         fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
83       else if (TREE_CODE (node) == LABEL_DECL
84                && LABEL_DECL_UID (node) != -1)
85         fprintf (file, " L." HOST_WIDE_INT_PRINT_DEC, LABEL_DECL_UID (node));
86       else
87         fprintf (file, " %c.%u", TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
88                  DECL_UID (node));
89     }
90   else if (class == tcc_type)
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
105   /* We might as well always print the value of an integer or real.  */
106   if (TREE_CODE (node) == INTEGER_CST)
107     {
108       if (TREE_CONSTANT_OVERFLOW (node))
109         fprintf (file, " overflow");
110
111       fprintf (file, " ");
112       if (TREE_INT_CST_HIGH (node) == 0)
113         fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, TREE_INT_CST_LOW (node));
114       else if (TREE_INT_CST_HIGH (node) == -1
115                && TREE_INT_CST_LOW (node) != 0)
116         fprintf (file, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
117                  -TREE_INT_CST_LOW (node));
118       else
119         fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
120                  TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
121     }
122   if (TREE_CODE (node) == REAL_CST)
123     {
124       REAL_VALUE_TYPE d;
125
126       if (TREE_OVERFLOW (node))
127         fprintf (file, " overflow");
128
129       d = TREE_REAL_CST (node);
130       if (REAL_VALUE_ISINF (d))
131         fprintf (file, " Inf");
132       else if (REAL_VALUE_ISNAN (d))
133         fprintf (file, " Nan");
134       else
135         {
136           char string[60];
137           real_to_decimal (string, &d, sizeof (string), 0, 1);
138           fprintf (file, " %s", string);
139         }
140     }
141
142   fprintf (file, ">");
143 }
144
145 void
146 indent_to (FILE *file, int column)
147 {
148   int i;
149
150   /* Since this is the long way, indent to desired column.  */
151   if (column > 0)
152     fprintf (file, "\n");
153   for (i = 0; i < column; i++)
154     fprintf (file, " ");
155 }
156 \f
157 /* Print the node NODE in full on file FILE, preceded by PREFIX,
158    starting in column INDENT.  */
159
160 void
161 print_node (FILE *file, const char *prefix, tree node, int indent)
162 {
163   int hash;
164   struct bucket *b;
165   enum machine_mode mode;
166   enum tree_code_class class;
167   int len;
168   int i;
169   expanded_location xloc;
170
171   if (node == 0)
172     return;
173
174   class = TREE_CODE_CLASS (TREE_CODE (node));
175
176   /* Don't get too deep in nesting.  If the user wants to see deeper,
177      it is easy to use the address of a lowest-level node
178      as an argument in another call to debug_tree.  */
179
180   if (indent > 24)
181     {
182       print_node_brief (file, prefix, node, indent);
183       return;
184     }
185
186   if (indent > 8 && (class == tcc_type || class == tcc_declaration))
187     {
188       print_node_brief (file, prefix, node, indent);
189       return;
190     }
191
192   /* It is unsafe to look at any other fields of an ERROR_MARK node.  */
193   if (TREE_CODE (node) == ERROR_MARK)
194     {
195       print_node_brief (file, prefix, node, indent);
196       return;
197     }
198
199   hash = ((unsigned long) node) % HASH_SIZE;
200
201   /* If node is in the table, just mention its address.  */
202   for (b = table[hash]; b; b = b->next)
203     if (b->node == node)
204       {
205         print_node_brief (file, prefix, node, indent);
206         return;
207       }
208
209   /* Add this node to the table.  */
210   b = xmalloc (sizeof (struct bucket));
211   b->node = node;
212   b->next = table[hash];
213   table[hash] = b;
214
215   /* Indent to the specified column, since this is the long form.  */
216   indent_to (file, indent);
217
218   /* Print the slot this node is in, and its code, and address.  */
219   fprintf (file, "%s <%s " HOST_PTR_PRINTF,
220            prefix, tree_code_name[(int) TREE_CODE (node)], (void *) node);
221
222   /* Print the name, if any.  */
223   if (class == tcc_declaration)
224     {
225       if (DECL_NAME (node))
226         fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
227       else if (TREE_CODE (node) == LABEL_DECL
228                && LABEL_DECL_UID (node) != -1)
229         fprintf (file, " L." HOST_WIDE_INT_PRINT_DEC, LABEL_DECL_UID (node));
230       else
231         fprintf (file, " %c.%u", TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
232                  DECL_UID (node));
233     }
234   else if (class == tcc_type)
235     {
236       if (TYPE_NAME (node))
237         {
238           if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
239             fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
240           else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
241                    && DECL_NAME (TYPE_NAME (node)))
242             fprintf (file, " %s",
243                      IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
244         }
245     }
246   if (TREE_CODE (node) == IDENTIFIER_NODE)
247     fprintf (file, " %s", IDENTIFIER_POINTER (node));
248
249   if (TREE_CODE (node) == INTEGER_CST)
250     {
251       if (indent <= 4)
252         print_node_brief (file, "type", TREE_TYPE (node), indent + 4);
253     }
254   else
255     {
256       print_node (file, "type", TREE_TYPE (node), indent + 4);
257       if (TREE_TYPE (node))
258         indent_to (file, indent + 3);
259     }
260
261   if (!TYPE_P (node) && TREE_SIDE_EFFECTS (node))
262     fputs (" side-effects", file);
263
264   if (TYPE_P (node) ? TYPE_READONLY (node) : TREE_READONLY (node))
265     fputs (" readonly", file);
266   if (!TYPE_P (node) && TREE_CONSTANT (node))
267     fputs (" constant", file);
268   else if (TYPE_P (node) && TYPE_SIZES_GIMPLIFIED (node))
269     fputs (" sizes-gimplified", file);
270
271   if (TREE_INVARIANT (node))
272     fputs (" invariant", file);
273   if (TREE_ADDRESSABLE (node))
274     fputs (" addressable", file);
275   if (TREE_THIS_VOLATILE (node))
276     fputs (" volatile", file);
277   if (TREE_ASM_WRITTEN (node))
278     fputs (" asm_written", file);
279   if (TREE_USED (node))
280     fputs (" used", file);
281   if (TREE_NOTHROW (node))
282     fputs (TYPE_P (node) ? " align-ok" : " nothrow", file);
283   if (TREE_PUBLIC (node))
284     fputs (" public", file);
285   if (TREE_PRIVATE (node))
286     fputs (" private", file);
287   if (TREE_PROTECTED (node))
288     fputs (" protected", file);
289   if (TREE_STATIC (node))
290     fputs (" static", file);
291   if (TREE_DEPRECATED (node))
292     fputs (" deprecated", file);
293   if (TREE_VISITED (node))
294     fputs (" visited", file);
295   if (TREE_LANG_FLAG_0 (node))
296     fputs (" tree_0", file);
297   if (TREE_LANG_FLAG_1 (node))
298     fputs (" tree_1", file);
299   if (TREE_LANG_FLAG_2 (node))
300     fputs (" tree_2", file);
301   if (TREE_LANG_FLAG_3 (node))
302     fputs (" tree_3", file);
303   if (TREE_LANG_FLAG_4 (node))
304     fputs (" tree_4", file);
305   if (TREE_LANG_FLAG_5 (node))
306     fputs (" tree_5", file);
307   if (TREE_LANG_FLAG_6 (node))
308     fputs (" tree_6", file);
309
310   /* DECL_ nodes have additional attributes.  */
311
312   switch (TREE_CODE_CLASS (TREE_CODE (node)))
313     {
314     case tcc_declaration:
315       mode = DECL_MODE (node);
316
317       if (DECL_UNSIGNED (node))
318         fputs (" unsigned", file);
319       if (DECL_IGNORED_P (node))
320         fputs (" ignored", file);
321       if (DECL_ABSTRACT (node))
322         fputs (" abstract", file);
323       if (DECL_IN_SYSTEM_HEADER (node))
324         fputs (" in_system_header", file);
325       if (DECL_COMMON (node))
326         fputs (" common", file);
327       if (DECL_EXTERNAL (node))
328         fputs (" external", file);
329       if (DECL_WEAK (node))
330         fputs (" weak", file);
331       if (DECL_REGISTER (node) && TREE_CODE (node) != FIELD_DECL
332           && TREE_CODE (node) != FUNCTION_DECL
333           && TREE_CODE (node) != LABEL_DECL)
334         fputs (" regdecl", file);
335       if (DECL_NONLOCAL (node))
336         fputs (" nonlocal", file);
337
338       if (TREE_CODE (node) == TYPE_DECL && TYPE_DECL_SUPPRESS_DEBUG (node))
339         fputs (" suppress-debug", file);
340
341       if (TREE_CODE (node) == FUNCTION_DECL && DECL_INLINE (node))
342         fputs (DECL_DECLARED_INLINE_P (node) ? " inline" : " autoinline", file);
343       if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN (node))
344         fputs (" built-in", file);
345       if (TREE_CODE (node) == FUNCTION_DECL && DECL_NO_STATIC_CHAIN (node))
346         fputs (" no-static-chain", file);
347
348       if (TREE_CODE (node) == FIELD_DECL && DECL_PACKED (node))
349         fputs (" packed", file);
350       if (TREE_CODE (node) == FIELD_DECL && DECL_BIT_FIELD (node))
351         fputs (" bit-field", file);
352       if (TREE_CODE (node) == FIELD_DECL && DECL_NONADDRESSABLE_P (node))
353         fputs (" nonaddressable", file);
354
355       if (TREE_CODE (node) == LABEL_DECL && DECL_ERROR_ISSUED (node))
356         fputs (" error-issued", file);
357
358       if (TREE_CODE (node) == VAR_DECL && DECL_IN_TEXT_SECTION (node))
359         fputs (" in-text-section", file);
360       if (TREE_CODE (node) == VAR_DECL && DECL_THREAD_LOCAL_P (node))
361         {
362           enum tls_model kind = DECL_TLS_MODEL (node);
363           switch (kind)
364             {
365               case TLS_MODEL_GLOBAL_DYNAMIC:
366                 fputs (" tls-global-dynamic", file);
367                 break;
368               case TLS_MODEL_LOCAL_DYNAMIC:
369                 fputs (" tls-local-dynamic", file);
370                 break;
371               case TLS_MODEL_INITIAL_EXEC:
372                 fputs (" tls-initial-exec", file);
373                 break;
374               case TLS_MODEL_LOCAL_EXEC:
375                 fputs (" tls-local-exec", file);
376                 break;
377               default:
378                 gcc_unreachable ();
379             }
380         }
381
382       if (TREE_CODE (node) == PARM_DECL && DECL_TRANSPARENT_UNION (node))
383         fputs (" transparent-union", file);
384
385       if (DECL_VIRTUAL_P (node))
386         fputs (" virtual", file);
387       if (DECL_DEFER_OUTPUT (node))
388         fputs (" defer-output", file);
389
390       if (DECL_PRESERVE_P (node))
391         fputs (" preserve", file);
392
393       if (DECL_LANG_FLAG_0 (node))
394         fputs (" decl_0", file);
395       if (DECL_LANG_FLAG_1 (node))
396         fputs (" decl_1", file);
397       if (DECL_LANG_FLAG_2 (node))
398         fputs (" decl_2", file);
399       if (DECL_LANG_FLAG_3 (node))
400         fputs (" decl_3", file);
401       if (DECL_LANG_FLAG_4 (node))
402         fputs (" decl_4", file);
403       if (DECL_LANG_FLAG_5 (node))
404         fputs (" decl_5", file);
405       if (DECL_LANG_FLAG_6 (node))
406         fputs (" decl_6", file);
407       if (DECL_LANG_FLAG_7 (node))
408         fputs (" decl_7", file);
409
410       fprintf (file, " %s", GET_MODE_NAME (mode));
411       xloc = expand_location (DECL_SOURCE_LOCATION (node));
412       fprintf (file, " file %s line %d", xloc.file, xloc.line);
413
414       print_node (file, "size", DECL_SIZE (node), indent + 4);
415       print_node (file, "unit size", DECL_SIZE_UNIT (node), indent + 4);
416
417       if (TREE_CODE (node) != FUNCTION_DECL
418           || DECL_INLINE (node) || DECL_BUILT_IN (node))
419         indent_to (file, indent + 3);
420
421       if (TREE_CODE (node) != FUNCTION_DECL)
422         {
423           if (DECL_USER_ALIGN (node))
424             fprintf (file, " user");
425
426           fprintf (file, " align %d", DECL_ALIGN (node));
427           if (TREE_CODE (node) == FIELD_DECL)
428             fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED,
429                      DECL_OFFSET_ALIGN (node));
430         }
431       else if (DECL_BUILT_IN (node))
432         {
433           if (DECL_BUILT_IN_CLASS (node) == BUILT_IN_MD)
434             fprintf (file, " built-in BUILT_IN_MD %d", DECL_FUNCTION_CODE (node));
435           else
436             fprintf (file, " built-in %s:%s",
437                      built_in_class_names[(int) DECL_BUILT_IN_CLASS (node)],
438                      built_in_names[(int) DECL_FUNCTION_CODE (node)]);
439         }
440
441       if (DECL_POINTER_ALIAS_SET_KNOWN_P (node))
442         fprintf (file, " alias set " HOST_WIDE_INT_PRINT_DEC,
443                  DECL_POINTER_ALIAS_SET (node));
444
445       if (TREE_CODE (node) == FIELD_DECL)
446         {
447           print_node (file, "offset", DECL_FIELD_OFFSET (node), indent + 4);
448           print_node (file, "bit offset", DECL_FIELD_BIT_OFFSET (node),
449                       indent + 4);
450         }
451
452       print_node_brief (file, "context", DECL_CONTEXT (node), indent + 4);
453       print_node_brief (file, "attributes",
454                         DECL_ATTRIBUTES (node), indent + 4);
455       print_node_brief (file, "abstract_origin",
456                         DECL_ABSTRACT_ORIGIN (node), indent + 4);
457
458       print_node (file, "arguments", DECL_ARGUMENTS (node), indent + 4);
459       print_node (file, "result", DECL_RESULT_FLD (node), indent + 4);
460       print_node_brief (file, "initial", DECL_INITIAL (node), indent + 4);
461
462       lang_hooks.print_decl (file, node, indent);
463
464       if (DECL_RTL_SET_P (node))
465         {
466           indent_to (file, indent + 4);
467           print_rtl (file, DECL_RTL (node));
468         }
469
470       if (TREE_CODE (node) == PARM_DECL)
471         {
472           print_node (file, "arg-type", DECL_ARG_TYPE (node), indent + 4);
473           print_node (file, "arg-type-as-written",
474                       DECL_ARG_TYPE_AS_WRITTEN (node), indent + 4);
475
476           if (DECL_INCOMING_RTL (node) != 0)
477             {
478               indent_to (file, indent + 4);
479               fprintf (file, "incoming-rtl ");
480               print_rtl (file, DECL_INCOMING_RTL (node));
481             }
482         }
483       else if (TREE_CODE (node) == FUNCTION_DECL
484                && DECL_STRUCT_FUNCTION (node) != 0)
485         {
486           indent_to (file, indent + 4);
487           fprintf (file, "saved-insns " HOST_PTR_PRINTF,
488                    (void *) DECL_STRUCT_FUNCTION (node));
489         }
490
491       /* Print the decl chain only if decl is at second level.  */
492       if (indent == 4)
493         print_node (file, "chain", TREE_CHAIN (node), indent + 4);
494       else
495         print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
496       break;
497
498     case tcc_type:
499       if (TYPE_UNSIGNED (node))
500         fputs (" unsigned", file);
501
502       /* The no-force-blk flag is used for different things in
503          different types.  */
504       if ((TREE_CODE (node) == RECORD_TYPE
505            || TREE_CODE (node) == UNION_TYPE
506            || TREE_CODE (node) == QUAL_UNION_TYPE)
507           && TYPE_NO_FORCE_BLK (node))
508         fputs (" no-force-blk", file);
509       else if (TREE_CODE (node) == INTEGER_TYPE
510                && TYPE_IS_SIZETYPE (node))
511         fputs (" sizetype", file);
512       else if (TREE_CODE (node) == FUNCTION_TYPE
513                && TYPE_RETURNS_STACK_DEPRESSED (node))
514         fputs (" returns-stack-depressed", file);
515
516       if (TYPE_STRING_FLAG (node))
517         fputs (" string-flag", file);
518       if (TYPE_NEEDS_CONSTRUCTING (node))
519         fputs (" needs-constructing", file);
520
521       /* The transparent-union flag is used for different things in
522          different nodes.  */
523       if (TREE_CODE (node) == UNION_TYPE && TYPE_TRANSPARENT_UNION (node))
524         fputs (" transparent-union", file);
525       else if (TREE_CODE (node) == ARRAY_TYPE
526                && TYPE_NONALIASED_COMPONENT (node))
527         fputs (" nonaliased-component", file);
528
529       if (TYPE_PACKED (node))
530         fputs (" packed", file);
531
532       if (TYPE_RESTRICT (node))
533         fputs (" restrict", file);
534
535       if (TYPE_LANG_FLAG_0 (node))
536         fputs (" type_0", file);
537       if (TYPE_LANG_FLAG_1 (node))
538         fputs (" type_1", file);
539       if (TYPE_LANG_FLAG_2 (node))
540         fputs (" type_2", file);
541       if (TYPE_LANG_FLAG_3 (node))
542         fputs (" type_3", file);
543       if (TYPE_LANG_FLAG_4 (node))
544         fputs (" type_4", file);
545       if (TYPE_LANG_FLAG_5 (node))
546         fputs (" type_5", file);
547       if (TYPE_LANG_FLAG_6 (node))
548         fputs (" type_6", file);
549
550       mode = TYPE_MODE (node);
551       fprintf (file, " %s", GET_MODE_NAME (mode));
552
553       print_node (file, "size", TYPE_SIZE (node), indent + 4);
554       print_node (file, "unit size", TYPE_SIZE_UNIT (node), indent + 4);
555       indent_to (file, indent + 3);
556
557       if (TYPE_USER_ALIGN (node))
558         fprintf (file, " user");
559
560       fprintf (file, " align %d symtab %d alias set " HOST_WIDE_INT_PRINT_DEC,
561                TYPE_ALIGN (node), TYPE_SYMTAB_ADDRESS (node),
562                TYPE_ALIAS_SET (node));
563
564       print_node (file, "attributes", TYPE_ATTRIBUTES (node), indent + 4);
565
566       if (INTEGRAL_TYPE_P (node) || TREE_CODE (node) == REAL_TYPE)
567         {
568           fprintf (file, " precision %d", TYPE_PRECISION (node));
569           print_node_brief (file, "min", TYPE_MIN_VALUE (node), indent + 4);
570           print_node_brief (file, "max", TYPE_MAX_VALUE (node), indent + 4);
571         }
572
573       if (TREE_CODE (node) == ENUMERAL_TYPE)
574         print_node (file, "values", TYPE_VALUES (node), indent + 4);
575       else if (TREE_CODE (node) == ARRAY_TYPE)
576         print_node (file, "domain", TYPE_DOMAIN (node), indent + 4);
577       else if (TREE_CODE (node) == VECTOR_TYPE)
578         fprintf (file, " nunits %d", (int) TYPE_VECTOR_SUBPARTS (node));
579       else if (TREE_CODE (node) == RECORD_TYPE
580                || TREE_CODE (node) == UNION_TYPE
581                || TREE_CODE (node) == QUAL_UNION_TYPE)
582         print_node (file, "fields", TYPE_FIELDS (node), indent + 4);
583       else if (TREE_CODE (node) == FUNCTION_TYPE
584                || TREE_CODE (node) == METHOD_TYPE)
585         {
586           if (TYPE_METHOD_BASETYPE (node))
587             print_node_brief (file, "method basetype",
588                               TYPE_METHOD_BASETYPE (node), indent + 4);
589           print_node (file, "arg-types", TYPE_ARG_TYPES (node), indent + 4);
590         }
591       else if (TREE_CODE (node) == OFFSET_TYPE)
592         print_node_brief (file, "basetype", TYPE_OFFSET_BASETYPE (node),
593                           indent + 4);
594
595       if (TYPE_CONTEXT (node))
596         print_node_brief (file, "context", TYPE_CONTEXT (node), indent + 4);
597
598       lang_hooks.print_type (file, node, indent);
599
600       if (TYPE_POINTER_TO (node) || TREE_CHAIN (node))
601         indent_to (file, indent + 3);
602
603       print_node_brief (file, "pointer_to_this", TYPE_POINTER_TO (node),
604                         indent + 4);
605       print_node_brief (file, "reference_to_this", TYPE_REFERENCE_TO (node),
606                         indent + 4);
607       print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
608       break;
609
610     case tcc_expression:
611     case tcc_comparison:
612     case tcc_unary:
613     case tcc_binary:
614     case tcc_reference:
615     case tcc_statement:
616       if (TREE_CODE (node) == BIT_FIELD_REF && BIT_FIELD_REF_UNSIGNED (node))
617         fputs (" unsigned", file);
618       if (TREE_CODE (node) == BIND_EXPR)
619         {
620           print_node (file, "vars", TREE_OPERAND (node, 0), indent + 4);
621           print_node (file, "body", TREE_OPERAND (node, 1), indent + 4);
622           print_node (file, "block", TREE_OPERAND (node, 2), indent + 4);
623           break;
624         }
625
626       len = TREE_CODE_LENGTH (TREE_CODE (node));
627
628       for (i = 0; i < len; i++)
629         {
630           char temp[10];
631
632           sprintf (temp, "arg %d", i);
633           print_node (file, temp, TREE_OPERAND (node, i), indent + 4);
634         }
635
636       print_node (file, "chain", TREE_CHAIN (node), indent + 4);
637       break;
638
639     case tcc_constant:
640     case tcc_exceptional:
641       switch (TREE_CODE (node))
642         {
643         case INTEGER_CST:
644           if (TREE_CONSTANT_OVERFLOW (node))
645             fprintf (file, " overflow");
646
647           fprintf (file, " ");
648           if (TREE_INT_CST_HIGH (node) == 0)
649             fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED,
650                      TREE_INT_CST_LOW (node));
651           else if (TREE_INT_CST_HIGH (node) == -1
652                    && TREE_INT_CST_LOW (node) != 0)
653             fprintf (file, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
654                      -TREE_INT_CST_LOW (node));
655           else
656             fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
657                      TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
658           break;
659
660         case REAL_CST:
661           {
662             REAL_VALUE_TYPE d;
663
664             if (TREE_OVERFLOW (node))
665               fprintf (file, " overflow");
666
667             d = TREE_REAL_CST (node);
668             if (REAL_VALUE_ISINF (d))
669               fprintf (file, " Inf");
670             else if (REAL_VALUE_ISNAN (d))
671               fprintf (file, " Nan");
672             else
673               {
674                 char string[64];
675                 real_to_decimal (string, &d, sizeof (string), 0, 1);
676                 fprintf (file, " %s", string);
677               }
678           }
679           break;
680
681         case VECTOR_CST:
682           {
683             tree vals = TREE_VECTOR_CST_ELTS (node);
684             char buf[10];
685             tree link;
686             int i;
687
688             i = 0;
689             for (link = vals; link; link = TREE_CHAIN (link), ++i)
690               {
691                 sprintf (buf, "elt%d: ", i);
692                 print_node (file, buf, TREE_VALUE (link), indent + 4);
693               }
694           }
695           break;
696
697         case COMPLEX_CST:
698           print_node (file, "real", TREE_REALPART (node), indent + 4);
699           print_node (file, "imag", TREE_IMAGPART (node), indent + 4);
700           break;
701
702         case STRING_CST:
703           {
704             const char *p = TREE_STRING_POINTER (node);
705             int i = TREE_STRING_LENGTH (node);
706             fputs (" \"", file);
707             while (--i >= 0)
708               {
709                 char ch = *p++;
710                 if (ch >= ' ' && ch < 127)
711                   putc (ch, file);
712                 else
713                   fprintf(file, "\\%03o", ch & 0xFF);
714               }
715             fputc ('\"', file);
716           }
717           /* Print the chain at second level.  */
718           if (indent == 4)
719             print_node (file, "chain", TREE_CHAIN (node), indent + 4);
720           else
721             print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
722           break;
723
724         case IDENTIFIER_NODE:
725           lang_hooks.print_identifier (file, node, indent);
726           break;
727
728         case TREE_LIST:
729           print_node (file, "purpose", TREE_PURPOSE (node), indent + 4);
730           print_node (file, "value", TREE_VALUE (node), indent + 4);
731           print_node (file, "chain", TREE_CHAIN (node), indent + 4);
732           break;
733
734         case TREE_VEC:
735           len = TREE_VEC_LENGTH (node);
736           for (i = 0; i < len; i++)
737             if (TREE_VEC_ELT (node, i))
738               {
739                 char temp[10];
740                 sprintf (temp, "elt %d", i);
741                 indent_to (file, indent + 4);
742                 print_node_brief (file, temp, TREE_VEC_ELT (node, i), 0);
743               }
744           break;
745
746         case STATEMENT_LIST:
747           fprintf (file, " head " HOST_PTR_PRINTF " tail " HOST_PTR_PRINTF " stmts",
748                    (void *) node->stmt_list.head, (void *) node->stmt_list.tail);
749           {
750             tree_stmt_iterator i;
751             for (i = tsi_start (node); !tsi_end_p (i); tsi_next (&i))
752               {
753                 /* Not printing the addresses of the (not-a-tree)
754                    'struct tree_stmt_list_node's.  */
755                 fprintf (file, " " HOST_PTR_PRINTF, (void *)tsi_stmt (i));
756               }
757             fprintf (file, "\n");
758             for (i = tsi_start (node); !tsi_end_p (i); tsi_next (&i))
759               {
760                 /* Not printing the addresses of the (not-a-tree)
761                    'struct tree_stmt_list_node's.  */
762                 print_node (file, "stmt", tsi_stmt (i), indent + 4);
763               }
764           }
765           print_node (file, "chain", TREE_CHAIN (node), indent + 4);
766           break;
767
768         case BLOCK:
769           print_node (file, "vars", BLOCK_VARS (node), indent + 4);
770           print_node (file, "supercontext", BLOCK_SUPERCONTEXT (node),
771                       indent + 4);
772           print_node (file, "subblocks", BLOCK_SUBBLOCKS (node), indent + 4);
773           print_node (file, "chain", BLOCK_CHAIN (node), indent + 4);
774           print_node (file, "abstract_origin",
775                       BLOCK_ABSTRACT_ORIGIN (node), indent + 4);
776           break;
777
778         case SSA_NAME:
779           print_node_brief (file, "var", SSA_NAME_VAR (node), indent + 4);
780           print_node_brief (file, "def_stmt",
781                             SSA_NAME_DEF_STMT (node), indent + 4);
782
783           indent_to (file, indent + 4);
784           fprintf (file, "version %u", SSA_NAME_VERSION (node));
785           if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
786             fprintf (file, " in-abnormal-phi");
787           if (SSA_NAME_IN_FREE_LIST (node))
788             fprintf (file, " in-free-list");
789
790           if (SSA_NAME_PTR_INFO (node)
791               || SSA_NAME_VALUE (node)
792               || SSA_NAME_AUX (node))
793             {
794               indent_to (file, indent + 3);
795               if (SSA_NAME_PTR_INFO (node))
796                 fprintf (file, " ptr-info %p",
797                          (void *) SSA_NAME_PTR_INFO (node));
798               if (SSA_NAME_VALUE (node))
799                 fprintf (file, " value %p",
800                          (void *) SSA_NAME_VALUE (node));
801               if (SSA_NAME_AUX (node))
802                 fprintf (file, " aux %p", SSA_NAME_AUX (node));
803             }
804           break;
805
806         default:
807           if (EXCEPTIONAL_CLASS_P (node))
808             lang_hooks.print_xnode (file, node, indent);
809           break;
810         }
811
812       break;
813     }
814
815   if (EXPR_HAS_LOCATION (node))
816     {
817       expanded_location xloc = expand_location (EXPR_LOCATION (node));
818       indent_to (file, indent+4);
819       fprintf (file, "%s:%d", xloc.file, xloc.line);
820     }
821
822   fprintf (file, ">");
823 }