OSDN Git Service

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