OSDN Git Service

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