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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [print-tree.c] - Blame information for rev 280

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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