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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 710 jeremybenn
/* Convert language-specific tree expression to rtl instructions,
2
   for GNU compiler.
3
   Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4
   2000, 2001, 2002, 2003, 2004, 2007, 2010 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
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
 
23
#include "config.h"
24
#include "system.h"
25
#include "coretypes.h"
26
#include "tm.h"
27
#include "tree.h"
28
#include "flags.h"
29
#include "cp-tree.h"
30
#include "tm_p.h"
31
 
32
/* Expand C++-specific constants.  Currently, this means PTRMEM_CST.  */
33
 
34
tree
35
cplus_expand_constant (tree cst)
36
{
37
  switch (TREE_CODE (cst))
38
    {
39
    case PTRMEM_CST:
40
      {
41
        tree type = TREE_TYPE (cst);
42
        tree member;
43
 
44
        /* Find the member.  */
45
        member = PTRMEM_CST_MEMBER (cst);
46
 
47
        if (TREE_CODE (member) == FIELD_DECL)
48
          {
49
            /* Find the offset for the field.  */
50
            cst = byte_position (member);
51
            while (!same_type_p (DECL_CONTEXT (member),
52
                                 TYPE_PTRMEM_CLASS_TYPE (type)))
53
              {
54
                /* The MEMBER must have been nestled within an
55
                   anonymous aggregate contained in TYPE.  Find the
56
                   anonymous aggregate.  */
57
                member = lookup_anon_field (TYPE_PTRMEM_CLASS_TYPE (type),
58
                                            DECL_CONTEXT (member));
59
                cst = size_binop (PLUS_EXPR, cst, byte_position (member));
60
              }
61
            cst = fold (build_nop (type, cst));
62
          }
63
        else
64
          {
65
            tree delta;
66
            tree pfn;
67
 
68
            expand_ptrmemfunc_cst (cst, &delta, &pfn);
69
            cst = build_ptrmemfunc1 (type, delta, pfn);
70
          }
71
      }
72
      break;
73
 
74
    default:
75
      /* There's nothing to do.  */
76
      break;
77
    }
78
 
79
  return cst;
80
}
81
 
82
/* Called whenever an expression is used
83
   in a rvalue context.  */
84
 
85
tree
86
mark_rvalue_use (tree expr)
87
{
88
  mark_exp_read (expr);
89
  return expr;
90
}
91
 
92
/* Called whenever an expression is used
93
   in a lvalue context.  */
94
 
95
tree
96
mark_lvalue_use (tree expr)
97
{
98
  mark_exp_read (expr);
99
  return expr;
100
}
101
 
102
/* Called whenever an expression is used in a type use context.  */
103
 
104
tree
105
mark_type_use (tree expr)
106
{
107
  mark_exp_read (expr);
108
  return expr;
109
}
110
 
111
/* Mark EXP as read, not just set, for set but not used -Wunused
112
   warning purposes.  */
113
 
114
void
115
mark_exp_read (tree exp)
116
{
117
  if (exp == NULL)
118
    return;
119
 
120
  switch (TREE_CODE (exp))
121
    {
122
    case VAR_DECL:
123
    case PARM_DECL:
124
      DECL_READ_P (exp) = 1;
125
      break;
126
    case ARRAY_REF:
127
    case COMPONENT_REF:
128
    case MODIFY_EXPR:
129
    case REALPART_EXPR:
130
    case IMAGPART_EXPR:
131
    CASE_CONVERT:
132
    case ADDR_EXPR:
133
    case INDIRECT_REF:
134
      mark_exp_read (TREE_OPERAND (exp, 0));
135
      break;
136
    case COMPOUND_EXPR:
137
      mark_exp_read (TREE_OPERAND (exp, 1));
138
      break;
139
    case COND_EXPR:
140
      if (TREE_OPERAND (exp, 1))
141
        mark_exp_read (TREE_OPERAND (exp, 1));
142
      if (TREE_OPERAND (exp, 2))
143
        mark_exp_read (TREE_OPERAND (exp, 2));
144
      break;
145
    default:
146
      break;
147
    }
148
}
149
 

powered by: WebSVN 2.1.0

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