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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [cp/] [dump.c] - Blame information for rev 733

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 710 jeremybenn
/* Tree-dumping functionality for intermediate representation.
2
   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2010
3
   Free Software Foundation, Inc.
4
   Written by Mark Mitchell <mark@codesourcery.com>
5
 
6
This file is part of GCC.
7
 
8
GCC is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 3, or (at your option)
11
any later version.
12
 
13
GCC is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
GNU General Public License 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
#include "config.h"
23
#include "system.h"
24
#include "coretypes.h"
25
#include "tm.h"
26
#include "tree.h"
27
#include "cp-tree.h"
28
#include "tree-dump.h"
29
 
30
static void dump_access (dump_info_p, tree);
31
 
32
static void dump_op (dump_info_p, tree);
33
 
34
/* Dump a representation of the accessibility information associated
35
   with T.  */
36
 
37
static void
38
dump_access (dump_info_p di, tree t)
39
{
40
  if (TREE_PROTECTED(t))
41
    dump_string_field (di, "accs", "prot");
42
  else if (TREE_PRIVATE(t))
43
    dump_string_field (di, "accs", "priv");
44
  else
45
    dump_string_field (di, "accs", "pub");
46
}
47
 
48
/* Dump a representation of the specific operator for an overloaded
49
   operator associated with node t.  */
50
 
51
static void
52
dump_op (dump_info_p di, tree t)
53
{
54
  switch (DECL_OVERLOADED_OPERATOR_P (t)) {
55
    case NEW_EXPR:
56
      dump_string (di, "new");
57
      break;
58
    case VEC_NEW_EXPR:
59
      dump_string (di, "vecnew");
60
      break;
61
    case DELETE_EXPR:
62
      dump_string (di, "delete");
63
      break;
64
    case VEC_DELETE_EXPR:
65
      dump_string (di, "vecdelete");
66
      break;
67
    case UNARY_PLUS_EXPR:
68
      dump_string (di, "pos");
69
      break;
70
    case NEGATE_EXPR:
71
      dump_string (di, "neg");
72
      break;
73
    case ADDR_EXPR:
74
      dump_string (di, "addr");
75
      break;
76
    case INDIRECT_REF:
77
      dump_string(di, "deref");
78
      break;
79
    case BIT_NOT_EXPR:
80
      dump_string(di, "not");
81
      break;
82
    case TRUTH_NOT_EXPR:
83
      dump_string(di, "lnot");
84
      break;
85
    case PREINCREMENT_EXPR:
86
      dump_string(di, "preinc");
87
      break;
88
    case PREDECREMENT_EXPR:
89
      dump_string(di, "predec");
90
      break;
91
    case PLUS_EXPR:
92
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
93
        dump_string (di, "plusassign");
94
      else
95
        dump_string(di, "plus");
96
      break;
97
    case MINUS_EXPR:
98
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
99
        dump_string (di, "minusassign");
100
      else
101
        dump_string(di, "minus");
102
      break;
103
    case MULT_EXPR:
104
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
105
        dump_string (di, "multassign");
106
      else
107
        dump_string (di, "mult");
108
      break;
109
    case TRUNC_DIV_EXPR:
110
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
111
        dump_string (di, "divassign");
112
      else
113
        dump_string (di, "div");
114
      break;
115
    case TRUNC_MOD_EXPR:
116
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
117
         dump_string (di, "modassign");
118
      else
119
        dump_string (di, "mod");
120
      break;
121
    case BIT_AND_EXPR:
122
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
123
        dump_string (di, "andassign");
124
      else
125
        dump_string (di, "and");
126
      break;
127
    case BIT_IOR_EXPR:
128
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
129
        dump_string (di, "orassign");
130
      else
131
        dump_string (di, "or");
132
      break;
133
    case BIT_XOR_EXPR:
134
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
135
        dump_string (di, "xorassign");
136
      else
137
        dump_string (di, "xor");
138
      break;
139
    case LSHIFT_EXPR:
140
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
141
        dump_string (di, "lshiftassign");
142
      else
143
        dump_string (di, "lshift");
144
      break;
145
    case RSHIFT_EXPR:
146
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
147
        dump_string (di, "rshiftassign");
148
      else
149
        dump_string (di, "rshift");
150
      break;
151
    case EQ_EXPR:
152
      dump_string (di, "eq");
153
      break;
154
    case NE_EXPR:
155
      dump_string (di, "ne");
156
      break;
157
    case LT_EXPR:
158
      dump_string (di, "lt");
159
      break;
160
    case GT_EXPR:
161
      dump_string (di, "gt");
162
      break;
163
    case LE_EXPR:
164
      dump_string (di, "le");
165
      break;
166
    case GE_EXPR:
167
      dump_string (di, "ge");
168
      break;
169
    case TRUTH_ANDIF_EXPR:
170
      dump_string (di, "land");
171
      break;
172
    case TRUTH_ORIF_EXPR:
173
      dump_string (di, "lor");
174
      break;
175
    case COMPOUND_EXPR:
176
      dump_string (di, "compound");
177
      break;
178
    case MEMBER_REF:
179
      dump_string (di, "memref");
180
      break;
181
    case COMPONENT_REF:
182
      dump_string (di, "ref");
183
      break;
184
    case ARRAY_REF:
185
      dump_string (di, "subs");
186
      break;
187
    case POSTINCREMENT_EXPR:
188
      dump_string (di, "postinc");
189
      break;
190
    case POSTDECREMENT_EXPR:
191
      dump_string (di, "postdec");
192
      break;
193
    case CALL_EXPR:
194
      dump_string (di, "call");
195
      break;
196
    case NOP_EXPR:
197
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
198
        dump_string (di, "assign");
199
      break;
200
    default:
201
      break;
202
  }
203
}
204
 
205
bool
206
cp_dump_tree (void* dump_info, tree t)
207
{
208
  enum tree_code code;
209
  dump_info_p di = (dump_info_p) dump_info;
210
 
211
  /* Figure out what kind of node this is.  */
212
  code = TREE_CODE (t);
213
 
214
  if (DECL_P (t))
215
    {
216
      if (DECL_LANG_SPECIFIC (t) && DECL_LANGUAGE (t) != lang_cplusplus)
217
        dump_string_field (di, "lang", language_to_string (DECL_LANGUAGE (t)));
218
    }
219
 
220
  switch (code)
221
    {
222
    case IDENTIFIER_NODE:
223
      if (IDENTIFIER_OPNAME_P (t))
224
        {
225
          dump_string_field (di, "note", "operator");
226
          return true;
227
        }
228
      else if (IDENTIFIER_TYPENAME_P (t))
229
        {
230
          dump_child ("tynm", TREE_TYPE (t));
231
          return true;
232
        }
233
      break;
234
 
235
    case OFFSET_TYPE:
236
      dump_string_field (di, "note", "ptrmem");
237
      dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t));
238
      dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t));
239
      return true;
240
 
241
    case RECORD_TYPE:
242
      if (TYPE_PTRMEMFUNC_P (t))
243
        {
244
          dump_string_field (di, "note", "ptrmem");
245
          dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t));
246
          dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t));
247
          return true;
248
        }
249
      /* Fall through.  */
250
 
251
    case UNION_TYPE:
252
      /* Is it a type used as a base? */
253
      if (TYPE_CONTEXT (t) && TREE_CODE (TYPE_CONTEXT (t)) == TREE_CODE (t)
254
          && CLASSTYPE_AS_BASE (TYPE_CONTEXT (t)) == t)
255
        {
256
          dump_child ("bfld", TYPE_CONTEXT (t));
257
          return true;
258
        }
259
 
260
      if (! MAYBE_CLASS_TYPE_P (t))
261
        break;
262
 
263
      dump_child ("vfld", TYPE_VFIELD (t));
264
      if (CLASSTYPE_TEMPLATE_SPECIALIZATION(t))
265
        dump_string(di, "spec");
266
 
267
      if (!dump_flag (di, TDF_SLIM, t) && TYPE_BINFO (t))
268
        {
269
          int i;
270
          tree binfo;
271
          tree base_binfo;
272
 
273
          for (binfo = TYPE_BINFO (t), i = 0;
274
               BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
275
            {
276
              dump_child ("base", BINFO_TYPE (base_binfo));
277
              if (BINFO_VIRTUAL_P (base_binfo))
278
                dump_string_field (di, "spec", "virt");
279
              dump_access (di, base_binfo);
280
            }
281
        }
282
      break;
283
 
284
    case FIELD_DECL:
285
      dump_access (di, t);
286
      if (DECL_MUTABLE_P (t))
287
        dump_string_field (di, "spec", "mutable");
288
      break;
289
 
290
    case VAR_DECL:
291
      if (TREE_CODE (CP_DECL_CONTEXT (t)) == RECORD_TYPE)
292
        dump_access (di, t);
293
      if (TREE_STATIC (t) && !TREE_PUBLIC (t))
294
        dump_string_field (di, "link", "static");
295
      break;
296
 
297
    case FUNCTION_DECL:
298
      if (!DECL_THUNK_P (t))
299
        {
300
          if (DECL_OVERLOADED_OPERATOR_P (t)) {
301
            dump_string_field (di, "note", "operator");
302
            dump_op (di, t);
303
          }
304
          if (DECL_FUNCTION_MEMBER_P (t))
305
            {
306
              dump_string_field (di, "note", "member");
307
              dump_access (di, t);
308
            }
309
          if (DECL_PURE_VIRTUAL_P (t))
310
            dump_string_field (di, "spec", "pure");
311
          if (DECL_VIRTUAL_P (t))
312
            dump_string_field (di, "spec", "virt");
313
          if (DECL_CONSTRUCTOR_P (t))
314
            dump_string_field (di, "note", "constructor");
315
          if (DECL_DESTRUCTOR_P (t))
316
            dump_string_field (di, "note", "destructor");
317
          if (DECL_CONV_FN_P (t))
318
            dump_string_field (di, "note", "conversion");
319
          if (DECL_GLOBAL_CTOR_P (t))
320
            dump_string_field (di, "note", "global init");
321
          if (DECL_GLOBAL_DTOR_P (t))
322
            dump_string_field (di, "note", "global fini");
323
          if (DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t))
324
            dump_string_field (di, "note", "pseudo tmpl");
325
        }
326
      else
327
        {
328
          tree virt = THUNK_VIRTUAL_OFFSET (t);
329
 
330
          dump_string_field (di, "note", "thunk");
331
          if (DECL_THIS_THUNK_P (t))
332
            dump_string_field (di, "note", "this adjusting");
333
          else
334
            {
335
              dump_string_field (di, "note", "result adjusting");
336
              if (virt)
337
                virt = BINFO_VPTR_FIELD (virt);
338
            }
339
          dump_int (di, "fixd", THUNK_FIXED_OFFSET (t));
340
          if (virt)
341
            dump_int (di, "virt", tree_low_cst (virt, 0));
342
          dump_child ("fn", DECL_INITIAL (t));
343
        }
344
      break;
345
 
346
    case NAMESPACE_DECL:
347
      if (DECL_NAMESPACE_ALIAS (t))
348
        dump_child ("alis", DECL_NAMESPACE_ALIAS (t));
349
      else if (!dump_flag (di, TDF_SLIM, t))
350
        dump_child ("dcls", cp_namespace_decls (t));
351
      break;
352
 
353
    case TEMPLATE_DECL:
354
      dump_child ("rslt", DECL_TEMPLATE_RESULT (t));
355
      dump_child ("inst", DECL_TEMPLATE_INSTANTIATIONS (t));
356
      dump_child ("spcs", DECL_TEMPLATE_SPECIALIZATIONS (t));
357
      dump_child ("prms", DECL_TEMPLATE_PARMS (t));
358
      break;
359
 
360
    case OVERLOAD:
361
      dump_child ("crnt", OVL_CURRENT (t));
362
      dump_child ("chan", OVL_CHAIN (t));
363
      break;
364
 
365
    case TRY_BLOCK:
366
      dump_stmt (di, t);
367
      if (CLEANUP_P (t))
368
        dump_string_field (di, "note", "cleanup");
369
      dump_child ("body", TRY_STMTS (t));
370
      dump_child ("hdlr", TRY_HANDLERS (t));
371
      break;
372
 
373
    case EH_SPEC_BLOCK:
374
      dump_stmt (di, t);
375
      dump_child ("body", EH_SPEC_STMTS (t));
376
      dump_child ("raises", EH_SPEC_RAISES (t));
377
      break;
378
 
379
    case PTRMEM_CST:
380
      dump_child ("clas", PTRMEM_CST_CLASS (t));
381
      dump_child ("mbr", PTRMEM_CST_MEMBER (t));
382
      break;
383
 
384
    case THROW_EXPR:
385
      /* These nodes are unary, but do not have code class `1'.  */
386
      dump_child ("op 0", TREE_OPERAND (t, 0));
387
      break;
388
 
389
    case AGGR_INIT_EXPR:
390
      {
391
        int i = 0;
392
        tree arg;
393
        aggr_init_expr_arg_iterator iter;
394
        dump_int (di, "ctor", AGGR_INIT_VIA_CTOR_P (t));
395
        dump_child ("fn", AGGR_INIT_EXPR_FN (t));
396
        FOR_EACH_AGGR_INIT_EXPR_ARG (arg, iter, t)
397
          {
398
            char buffer[32];
399
            sprintf (buffer, "%u", i);
400
            dump_child (buffer, arg);
401
            i++;
402
          }
403
        dump_child ("decl", AGGR_INIT_EXPR_SLOT (t));
404
      }
405
      break;
406
 
407
    case HANDLER:
408
      dump_stmt (di, t);
409
      dump_child ("parm", HANDLER_PARMS (t));
410
      dump_child ("body", HANDLER_BODY (t));
411
      break;
412
 
413
    case MUST_NOT_THROW_EXPR:
414
      dump_stmt (di, t);
415
      dump_child ("body", TREE_OPERAND (t, 0));
416
      dump_child ("cond", MUST_NOT_THROW_COND (t));
417
      break;
418
 
419
    case USING_STMT:
420
      dump_stmt (di, t);
421
      dump_child ("nmsp", USING_STMT_NAMESPACE (t));
422
      break;
423
 
424
    case CLEANUP_STMT:
425
      dump_stmt (di, t);
426
      dump_child ("decl", CLEANUP_DECL (t));
427
      dump_child ("expr", CLEANUP_EXPR (t));
428
      dump_child ("body", CLEANUP_BODY (t));
429
      break;
430
 
431
    case IF_STMT:
432
      dump_stmt (di, t);
433
      dump_child ("cond", IF_COND (t));
434
      dump_child ("then", THEN_CLAUSE (t));
435
      dump_child ("else", ELSE_CLAUSE (t));
436
      break;
437
 
438
    case BREAK_STMT:
439
    case CONTINUE_STMT:
440
      dump_stmt (di, t);
441
      break;
442
 
443
    case DO_STMT:
444
      dump_stmt (di, t);
445
      dump_child ("body", DO_BODY (t));
446
      dump_child ("cond", DO_COND (t));
447
      break;
448
 
449
    case FOR_STMT:
450
      dump_stmt (di, t);
451
      dump_child ("init", FOR_INIT_STMT (t));
452
      dump_child ("cond", FOR_COND (t));
453
      dump_child ("expr", FOR_EXPR (t));
454
      dump_child ("body", FOR_BODY (t));
455
      break;
456
 
457
    case RANGE_FOR_STMT:
458
      dump_stmt (di, t);
459
      dump_child ("decl", RANGE_FOR_DECL (t));
460
      dump_child ("expr", RANGE_FOR_EXPR (t));
461
      dump_child ("body", RANGE_FOR_BODY (t));
462
      break;
463
 
464
    case SWITCH_STMT:
465
      dump_stmt (di, t);
466
      dump_child ("cond", SWITCH_STMT_COND (t));
467
      dump_child ("body", SWITCH_STMT_BODY (t));
468
      break;
469
 
470
    case WHILE_STMT:
471
      dump_stmt (di, t);
472
      dump_child ("cond", WHILE_COND (t));
473
      dump_child ("body", WHILE_BODY (t));
474
      break;
475
 
476
    case STMT_EXPR:
477
      dump_child ("stmt", STMT_EXPR_STMT (t));
478
      break;
479
 
480
    case EXPR_STMT:
481
      dump_stmt (di, t);
482
      dump_child ("expr", EXPR_STMT_EXPR (t));
483
      break;
484
 
485
    default:
486
      break;
487
    }
488
 
489
  return c_dump_tree (di, t);
490
}

powered by: WebSVN 2.1.0

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