OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [print-tree.c] - Blame information for rev 12

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.