aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-tree-core.h
blob: 247a3f5de2d6068bbbf916655327fdb836b21726 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

#ifndef GIMPLE_CORE_H
#define GIMPLE_CORE_H


class GimpleExpr;
// This class accesses parts of trees that are common to all tree types.
// All methods other than comparisons are protected forcing inheriting
// classes to provide their own iterface.  This will ensure that any future  
// implementations of those classes will have any required methods exposed
// directly in that class.

class TreeBase {
  public:
    friend bool operator== (const TreeBase&, const TreeBase&);
    friend bool operator!= (const TreeBase&, const TreeBase&);
    friend bool operator== (const TreeBase&, const tree&);
    friend bool operator!= (const TreeBase&, const tree&);
    friend bool operator== (const tree&, const TreeBase&);
    friend bool operator!= (const tree&, const TreeBase&);
    operator bool() const { return Tree != NULL_TREE; }
    bool operator!() const { return Tree == NULL_TREE; }
  protected:
    tree Tree;
    inline TreeBase ()  { Tree = NULL; }
    inline TreeBase (const tree t) { Tree = t; }
    inline operator tree () const { return Tree; }
    inline TreeBase& operator= (const tree t) { Tree = t; return *this;}

    enum tree_code TreeCode () const;
    void SetTreeCode (enum tree_code);
};

class GimpleType : public TreeBase
{
  protected:
    inline void type_check() const 
			       { if (Tree) TREE_CLASS_CHECK (Tree, tcc_type); }
  public:
    inline GimpleType () : TreeBase () { }
    inline GimpleType (const tree t) : TreeBase (t) { type_check(); }
    inline operator tree () const { return Tree; }
    inline GimpleType& operator= (const tree t) 
				     { Tree = t; type_check (); return *this;}
    GimpleType type() const;
    enum tree_code code () const;
    bool pointer_type_p () const;
    bool type_unsigned () const;
    enum machine_mode type_mode () const;
};


class GimpleIdentifier : public TreeBase
{
  protected:
    inline void ident_check() const { if (Tree) IDENTIFIER_NODE_CHECK (Tree); }
  public:
    inline GimpleIdentifier () : TreeBase () { }
    inline GimpleIdentifier (const tree t) : TreeBase (t) { ident_check(); }
    inline operator tree () const { return Tree; }
    inline GimpleIdentifier& operator= (const tree t) 
				     { Tree = t; ident_check (); return *this;}
  
};

class GimpleValue : public TreeBase
{
  protected:
  public:
    inline GimpleValue () : TreeBase ()  { }
    inline GimpleValue (const tree t) : TreeBase (t) { }
    inline GimpleValue (const GimpleValue& v) : TreeBase (v.Tree) { }
    inline operator tree() const { return Tree; }
    inline GimpleValue& operator= (const tree t) 
				       { Tree = t; return *this;}
    inline GimpleValue& operator= (const GimpleValue& v) 
				       { Tree = v; return *this;}

    enum tree_code code () const;
    void set_code (enum tree_code);
    GimpleType type() const;
    void set_type (GimpleType);
    void strip_nops();
    GimpleValue value_operand(const int i) const;
    location_t expr_location() const;
    template <typename T> inline T as_a() const;
};

class GimpleDecl : public GimpleValue
{
  protected:
    tree tree_type();
    inline void decl_check() const
			{ if (Tree) TREE_CLASS_CHECK (Tree, tcc_declaration); }
  
  public:
    inline GimpleDecl () : GimpleValue()  { }
    inline GimpleDecl (const tree t) : GimpleValue (t) { decl_check(); }
    inline GimpleDecl (const GimpleValue& v) : GimpleValue (v) { decl_check(); }
    inline GimpleDecl (const GimpleDecl& d) : GimpleValue (d) { }
    inline GimpleDecl& operator= (const tree t) 
		   { GimpleValue::operator= (t); decl_check (); return *this;}
    inline GimpleDecl& operator= (const GimpleValue& v) 
		   { GimpleValue::operator= (v); decl_check (); return *this;}
    inline GimpleDecl& operator= (const GimpleDecl& d) 
		   { GimpleValue::operator= (d); return *this;}

    GimpleIdentifier decl_name() const;
    GimpleDecl decl_abstract_origin () const;
    bool decl_from_inline () const;
    bool readonly () const;
    bool decl_ignored_p () const;
    bool decl_external () const;
    bool decl_visibility_specified() const;
    bool decl_comdat() const;

    bool decl_static() const;
    bool decl_public() const;
    bool decl_asm_written() const;
};

class SSADecl : public GimpleValue
{
  protected:
    inline void SSANameCheck () const { if (Tree) SSA_NAME_CHECK (Tree); }
  public:
    inline SSADecl () : GimpleValue () { }
    inline SSADecl (const tree t) : GimpleValue (t) { SSANameCheck(); }
    inline SSADecl (const GimpleValue& d) : GimpleValue (d) { SSANameCheck(); }
    inline SSADecl (const SSADecl& n) : GimpleValue (n) { }
    inline SSADecl& operator= (const tree t) 
	      { GimpleValue::operator= (t); SSANameCheck(); return *this; }
    inline SSADecl& operator= (const GimpleValue &d) 
	      { GimpleValue::operator= (d); SSANameCheck(); return *this; }
    inline SSADecl& operator= (const SSADecl &n) 
	      { GimpleValue::operator= (n); return *this; }

    unsigned int ssa_name_version () const;
    void set_ssa_name_version(unsigned int);
    GimpleDecl ssa_name_var () const ;
    void set_ssa_name_var (GimpleDecl);
    GimpleIdentifier ssa_name_identifier () const;
    void set_ssa_name_identifier (GimpleIdentifier);
    gimple ssa_name_def_stmt () const;
    void set_ssa_name_def_stmt (gimple);
    struct ptr_info_def *ssa_name_ptr_info () const;
    void set_ssa_name_ptr_info (struct ptr_info_def *);
    bool ssa_name_in_free_list () const;
    void set_ssa_name_in_free_list (bool);
    bool ssa_name_is_default_def () const;
    void set_ssa_name_is_default_def (bool);
    struct ssa_use_operand_d * ssa_name_imm_use_node_ptr () const;
    bool ssa_name_occurs_in_abnormal_phi () const;
    bool ssa_name_same_base (const SSADecl& n) const;
};



inline bool 
operator== (const TreeBase& t1, const tree& t2) 
{ return t1.Tree == t2; }

inline bool 
operator!= (const TreeBase& t1, const tree& t2) 
{ return t1.Tree != t2; }

inline bool 
operator== (const TreeBase& t1, const TreeBase& t2) 
{ return t1.Tree == t2.Tree; }

inline bool 
operator!= (const TreeBase& t1, const TreeBase& t2) 
{ return t1.Tree != t2.Tree; }

inline bool 
operator== (const tree& t1, const TreeBase& t2) 
{ return t1 == t2.Tree; }

inline bool 
operator!= (const tree& t1, const TreeBase& t2) 
{ return t1 != t2.Tree; }


#endif