forked from davidmalcolm/gcc-python-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgcc-tree.c
258 lines (217 loc) · 7.52 KB
/
gcc-tree.c
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/*
Copyright 2012 David Malcolm <dmalcolm@redhat.com>
Copyright 2012 Red Hat, Inc.
This is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
<http://www.gnu.org/licenses/>.
*/
#include "gcc-common.h"
#include "gcc-tree.h"
#include "ggc.h"
#include "gcc-internal.h"
#include <assert.h>
#include "tree.h"
/*
Trees
*/
/* gcc_tree */
GCC_IMPLEMENT_PUBLIC_API (void) gcc_tree_mark_in_use (gcc_tree node)
{
/* Mark the underlying object (recursing into its fields): */
gt_ggc_mx_tree_node (node.inner);
}
GCC_IMPLEMENT_PRIVATE_API (struct gcc_tree)
gcc_private_make_tree (tree inner)
{
struct gcc_tree result;
/* FIXME: type-checking */
result.inner = inner;
return result;
}
GCC_IMPLEMENT_PRIVATE_API (struct gcc_block)
gcc_private_make_block (tree inner)
{
struct gcc_block result;
result.inner = BLOCK_CHECK (inner);
return result;
}
/* gcc_binary */
GCC_IMPLEMENT_PUBLIC_API (void) gcc_binary_mark_in_use (gcc_binary node);
GCC_IMPLEMENT_PUBLIC_API(gcc_location)
gcc_binary_get_location(gcc_binary node)
{
return gcc_private_make_location (EXPR_LOCATION (node.inner));
}
GCC_IMPLEMENT_PUBLIC_API (gcc_bitwise_and_expr)
gcc_binary_as_gcc_bitwise_and_expr (gcc_binary node);
GCC_IMPLEMENT_PUBLIC_API (gcc_bitwise_ior_expr)
gcc_binary_as_gcc_bitwise_ior_expr (gcc_binary node);
GCC_IMPLEMENT_PUBLIC_API (gcc_bitwise_xor_expr)
gcc_binary_as_gcc_bitwise_xor_expr (gcc_binary node);
/* gcc_bitwise_and_expr */
GCC_IMPLEMENT_PUBLIC_API (void)
gcc_bitwise_and_expr_mark_in_use (gcc_bitwise_and_expr node);
/* gcc_bitwise_ior_expr */
GCC_IMPLEMENT_PUBLIC_API (void)
gcc_bitwise_ior_expr_mark_in_use (gcc_bitwise_ior_expr node);
/* gcc_bitwise_xor_expr */
GCC_IMPLEMENT_PUBLIC_API (void)
gcc_bitwise_xor_expr_mark_in_use (gcc_bitwise_xor_expr node);
/* gcc_block */
GCC_IMPLEMENT_PUBLIC_API (void)
gcc_block_mark_in_use (gcc_block node);
/***************************************************************************
gcc_comparison
**************************************************************************/
GCC_IMPLEMENT_PUBLIC_API(gcc_location)
gcc_comparison_get_location(gcc_comparison node)
{
return gcc_private_make_location (EXPR_LOCATION (node.inner));
}
/***************************************************************************
gcc_expression
**************************************************************************/
GCC_IMPLEMENT_PUBLIC_API(gcc_location)
gcc_expression_get_location(gcc_expression node)
{
return gcc_private_make_location (EXPR_LOCATION (node.inner));
}
/***************************************************************************
gcc_addr_expr
**************************************************************************/
GCC_IMPLEMENT_PUBLIC_API(gcc_tree)
gcc_addr_expr_get_operand(gcc_addr_expr node)
{
return gcc_private_make_tree (TREE_OPERAND (node.inner, 0));
}
/***************************************************************************
gcc_reference
**************************************************************************/
GCC_IMPLEMENT_PUBLIC_API(gcc_location)
gcc_reference_get_location(gcc_reference node)
{
return gcc_private_make_location (EXPR_LOCATION (node.inner));
}
/***************************************************************************
gcc_array_ref
**************************************************************************/
GCC_IMPLEMENT_PUBLIC_API(gcc_tree)
gcc_array_ref_get_array(gcc_array_ref node)
{
return gcc_private_make_tree(TREE_OPERAND(node.inner, 0));
}
GCC_IMPLEMENT_PUBLIC_API(gcc_tree)
gcc_array_ref_get_index(gcc_array_ref node)
{
return gcc_private_make_tree(TREE_OPERAND(node.inner, 1));
}
/***************************************************************************
gcc_component_ref
**************************************************************************/
GCC_IMPLEMENT_PUBLIC_API(gcc_tree)
gcc_component_ref_get_target(gcc_component_ref node)
{
return gcc_private_make_tree (TREE_OPERAND (node.inner, 0));
}
GCC_IMPLEMENT_PUBLIC_API(gcc_tree)
gcc_component_ref_get_field(gcc_component_ref node)
{
return gcc_private_make_tree (TREE_OPERAND (node.inner, 1));
}
/***************************************************************************
gcc_mem_ref
**************************************************************************/
GCC_IMPLEMENT_PUBLIC_API(gcc_tree)
gcc_mem_ref_get_operand(gcc_mem_ref node)
{
return gcc_private_make_tree (TREE_OPERAND (node.inner, 0));
}
/***************************************************************************
gcc_ssa_name
**************************************************************************/
GCC_IMPLEMENT_PUBLIC_API (gcc_tree) gcc_ssa_name_get_var (gcc_ssa_name node)
{
return gcc_private_make_tree (SSA_NAME_VAR (node.inner));
}
GCC_IMPLEMENT_PUBLIC_API (gcc_gimple)
gcc_ssa_name_get_def_stmt (gcc_ssa_name node)
{
return gcc_private_make_gimple (SSA_NAME_DEF_STMT (node.inner));
}
GCC_IMPLEMENT_PUBLIC_API (int) gcc_ssa_name_get_version (gcc_ssa_name node)
{
return SSA_NAME_VERSION (node.inner);
}
/***************************************************************************
gcc_statement
**************************************************************************/
GCC_IMPLEMENT_PUBLIC_API (void)
gcc_statement_mark_in_use (gcc_statement node);
GCC_IMPLEMENT_PUBLIC_API(gcc_location)
gcc_statement_get_location(gcc_statement node)
{
return gcc_private_make_location (EXPR_LOCATION (node.inner));
}
/***************************************************************************
gcc_case_label_expr
**************************************************************************/
GCC_IMPLEMENT_PRIVATE_API (struct gcc_case_label_expr)
gcc_private_make_case_label_expr (tree inner)
{
struct gcc_case_label_expr result;
/* FIXME: type-checking */
result.inner = inner;
return result;
}
GCC_IMPLEMENT_PUBLIC_API (gcc_tree)
gcc_case_label_expr_get_low (gcc_case_label_expr node)
{
return gcc_private_make_tree (CASE_LOW (node.inner));
}
GCC_IMPLEMENT_PUBLIC_API (gcc_tree)
gcc_case_label_expr_get_high (gcc_case_label_expr node)
{
return gcc_private_make_tree (CASE_HIGH (node.inner));
}
GCC_IMPLEMENT_PUBLIC_API (gcc_label_decl)
gcc_case_label_expr_get_target (gcc_case_label_expr node)
{
return
gcc_tree_as_gcc_label_decl (gcc_private_make_tree
(CASE_LABEL (node.inner)));
}
/***************************************************************************
gcc_unary
**************************************************************************/
GCC_IMPLEMENT_PUBLIC_API(gcc_location)
gcc_unary_get_location(gcc_unary node)
{
return gcc_private_make_location (EXPR_LOCATION (node.inner));
}
GCC_IMPLEMENT_PUBLIC_API(gcc_tree)
gcc_unary_get_operand(gcc_unary node)
{
return gcc_private_make_tree (TREE_OPERAND (node.inner, 0));
}
/***************************************************************************
gcc_vlexp
**************************************************************************/
GCC_IMPLEMENT_PUBLIC_API(gcc_location)
gcc_vlexp_get_location(gcc_vlexp node)
{
return gcc_private_make_location (EXPR_LOCATION (node.inner));
}
/*
Local variables:
c-basic-offset: 2
indent-tabs-mode: nil
End:
*/