comparison gcc/tree-ssa-operands.h @ 55:77e2b8dfacca gcc-4.4.5

update it from 4.4.3 to 4.5.0
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Fri, 12 Feb 2010 23:39:51 +0900
parents a06113de4d67
children b7f97abdc517
comparison
equal deleted inserted replaced
52:c156f1bd5cd9 55:77e2b8dfacca
28 28
29 /* This represents a pointer to a USE operand. */ 29 /* This represents a pointer to a USE operand. */
30 typedef ssa_use_operand_t *use_operand_p; 30 typedef ssa_use_operand_t *use_operand_p;
31 31
32 /* NULL operand types. */ 32 /* NULL operand types. */
33 #define NULL_USE_OPERAND_P NULL 33 #define NULL_USE_OPERAND_P ((use_operand_p)NULL)
34 #define NULL_DEF_OPERAND_P NULL 34 #define NULL_DEF_OPERAND_P ((def_operand_p)NULL)
35 35
36 /* This represents the DEF operands of a stmt. */ 36 /* This represents the DEF operands of a stmt. */
37 struct def_optype_d 37 struct def_optype_d
38 { 38 {
39 struct def_optype_d *next; 39 struct def_optype_d *next;
40 tree *def_ptr; 40 tree *def_ptr;
41 }; 41 };
42 typedef struct def_optype_d *def_optype_p; 42 typedef struct def_optype_d *def_optype_p;
43 43
44 /* This represents the USE operands of a stmt. */ 44 /* This represents the USE operands of a stmt. */
45 struct use_optype_d 45 struct use_optype_d
46 { 46 {
47 struct use_optype_d *next; 47 struct use_optype_d *next;
48 struct ssa_use_operand_d use_ptr; 48 struct ssa_use_operand_d use_ptr;
49 }; 49 };
50 typedef struct use_optype_d *use_optype_p; 50 typedef struct use_optype_d *use_optype_p;
51 51
52 typedef struct vuse_element_d
53 {
54 tree use_var;
55 struct ssa_use_operand_d use_ptr;
56 } vuse_element_t;
57
58 typedef struct vuse_vec_d
59 {
60 unsigned int num_vuse;
61 vuse_element_t uses[1];
62 } vuse_vec_t;
63 typedef struct vuse_vec_d *vuse_vec_p;
64
65 #define VUSE_VECT_NUM_ELEM(V) (V).num_vuse
66 #define VUSE_VECT_ELEMENT_NC(V,X) (V).uses[(X)]
67 #define VUSE_ELEMENT_PTR_NC(V,X) (&(VUSE_VECT_ELEMENT_NC ((V),(X)).use_ptr))
68 #define VUSE_ELEMENT_VAR_NC(V,X) (VUSE_VECT_ELEMENT_NC ((V),(X)).use_var)
69
70 #ifdef ENABLE_CHECKING
71 #define VUSE_VECT_ELEMENT(V,X) \
72 (gcc_assert (((unsigned int) (X)) < VUSE_VECT_NUM_ELEM (V)), \
73 VUSE_VECT_ELEMENT_NC (V,X))
74
75 #define VUSE_ELEMENT_PTR(V,X) \
76 (gcc_assert (((unsigned int) (X)) < VUSE_VECT_NUM_ELEM (V)), \
77 VUSE_ELEMENT_PTR_NC (V, X))
78
79 #define SET_VUSE_VECT_ELEMENT(V,X,N) \
80 (gcc_assert (((unsigned int) (X)) < VUSE_VECT_NUM_ELEM (V)), \
81 VUSE_VECT_ELEMENT_NC (V,X) = (N))
82
83 #define SET_VUSE_ELEMENT_VAR(V,X,N) \
84 (gcc_assert (((unsigned int) (X)) < VUSE_VECT_NUM_ELEM (V)), \
85 VUSE_VECT_ELEMENT_NC ((V),(X)).use_var = (N))
86
87 #define SET_VUSE_ELEMENT_PTR(V,X,N) \
88 (gcc_assert (((unsigned int) (X)) < VUSE_VECT_NUM_ELEM (V)), \
89 VUSE_ELEMENT_PTR_NC (V, X) = (N))
90 #else
91 #define VUSE_VECT_ELEMENT(V,X) VUSE_VECT_ELEMENT_NC(V,X)
92 #define VUSE_ELEMENT_PTR(V,X) VUSE_ELEMENT_PTR_NC(V,X)
93 #define SET_VUSE_VECT_ELEMENT(V,X,N) VUSE_VECT_ELEMENT_NC(V,X) = (N)
94 #define SET_VUSE_ELEMENT_PTR(V,X,N) VUSE_ELEMENT_PTR_NC(V,X) = (N)
95 #define SET_VUSE_ELEMENT_VAR(V,X,N) VUSE_VECT_ELEMENT_NC ((V),(X)).use_var = (N)
96 #endif
97
98 #define VUSE_ELEMENT_VAR(V,X) (VUSE_VECT_ELEMENT ((V),(X)).use_var)
99
100 /* This represents the virtual ops of a stmt. */
101 struct voptype_d
102 {
103 struct voptype_d *next;
104 tree def_var;
105 vuse_vec_t usev;
106 };
107 typedef struct voptype_d *voptype_p;
108
109 /* This structure represents a variable sized buffer which is allocated by the 52 /* This structure represents a variable sized buffer which is allocated by the
110 operand memory manager. Operands are suballocated out of this block. The 53 operand memory manager. Operands are suballocated out of this block. The
111 MEM array varies in size. */ 54 MEM array varies in size. */
112 55
113 struct ssa_operand_memory_d GTY((chain_next("%h.next"))) 56 struct GTY((chain_next("%h.next"))) ssa_operand_memory_d {
114 {
115 struct ssa_operand_memory_d *next; 57 struct ssa_operand_memory_d *next;
116 char mem[1]; 58 char mem[1];
117 }; 59 };
118 60
119 /* Number of different size free buckets for virtual operands. */
120 #define NUM_VOP_FREE_BUCKETS 29
121
122 /* Per-function operand caches. */ 61 /* Per-function operand caches. */
123 struct ssa_operands GTY(()) { 62 struct GTY(()) ssa_operands {
124 struct ssa_operand_memory_d *operand_memory; 63 struct ssa_operand_memory_d *operand_memory;
125 unsigned operand_memory_index; 64 unsigned operand_memory_index;
126 /* Current size of the operand memory buffer. */ 65 /* Current size of the operand memory buffer. */
127 unsigned int ssa_operand_mem_size; 66 unsigned int ssa_operand_mem_size;
128 67
129 bool ops_active; 68 bool ops_active;
130 69
131 struct def_optype_d * GTY ((skip (""))) free_defs; 70 struct def_optype_d * GTY ((skip (""))) free_defs;
132 struct use_optype_d * GTY ((skip (""))) free_uses; 71 struct use_optype_d * GTY ((skip (""))) free_uses;
133 struct voptype_d * GTY ((skip (""))) vop_free_buckets[NUM_VOP_FREE_BUCKETS]; 72 };
134 VEC(tree,heap) * GTY ((skip (""))) mpt_table; 73
135 };
136
137 /* This represents the operand cache for a stmt. */
138 struct stmt_operands_d
139 {
140 /* Statement operands. */
141 struct def_optype_d * def_ops;
142 struct use_optype_d * use_ops;
143
144 /* Virtual operands (VDEF, VUSE). */
145 struct voptype_d * vdef_ops;
146 struct voptype_d * vuse_ops;
147
148 /* Sets of memory symbols loaded and stored. */
149 bitmap stores;
150 bitmap loads;
151 };
152
153 typedef struct stmt_operands_d *stmt_operands_p;
154
155 #define USE_FROM_PTR(PTR) get_use_from_ptr (PTR) 74 #define USE_FROM_PTR(PTR) get_use_from_ptr (PTR)
156 #define DEF_FROM_PTR(PTR) get_def_from_ptr (PTR) 75 #define DEF_FROM_PTR(PTR) get_def_from_ptr (PTR)
157 #define SET_USE(USE, V) set_ssa_use_from_ptr (USE, V) 76 #define SET_USE(USE, V) set_ssa_use_from_ptr (USE, V)
158 #define SET_DEF(DEF, V) ((*(DEF)) = (V)) 77 #define SET_DEF(DEF, V) ((*(DEF)) = (V))
159 78
162 #define USE_OP_PTR(OP) (&((OP)->use_ptr)) 81 #define USE_OP_PTR(OP) (&((OP)->use_ptr))
163 #define USE_OP(OP) (USE_FROM_PTR (USE_OP_PTR (OP))) 82 #define USE_OP(OP) (USE_FROM_PTR (USE_OP_PTR (OP)))
164 83
165 #define DEF_OP_PTR(OP) ((OP)->def_ptr) 84 #define DEF_OP_PTR(OP) ((OP)->def_ptr)
166 #define DEF_OP(OP) (DEF_FROM_PTR (DEF_OP_PTR (OP))) 85 #define DEF_OP(OP) (DEF_FROM_PTR (DEF_OP_PTR (OP)))
167
168 #define VUSE_OP_PTR(OP,X) VUSE_ELEMENT_PTR ((OP)->usev, (X))
169 #define VUSE_OP(OP,X) VUSE_ELEMENT_VAR ((OP)->usev, (X))
170 #define SET_VUSE_OP(OP,X,N) SET_VUSE_ELEMENT_VAR ((OP)->usev, (X), (N))
171 #define VUSE_NUM(OP) VUSE_VECT_NUM_ELEM ((OP)->usev)
172 #define VUSE_VECT(OP) &((OP)->usev)
173
174 #define VDEF_RESULT_PTR(OP) (&((OP)->def_var))
175 #define VDEF_RESULT(OP) ((OP)->def_var)
176 #define VDEF_OP_PTR(OP,X) VUSE_OP_PTR (OP, X)
177 #define VDEF_OP(OP,X) VUSE_OP (OP, X)
178 #define SET_VDEF_OP(OP,X,N) SET_VUSE_OP (OP, X, N)
179 #define VDEF_NUM(OP) VUSE_VECT_NUM_ELEM ((OP)->usev)
180 #define VDEF_VECT(OP) &((OP)->usev)
181 86
182 #define PHI_RESULT_PTR(PHI) gimple_phi_result_ptr (PHI) 87 #define PHI_RESULT_PTR(PHI) gimple_phi_result_ptr (PHI)
183 #define PHI_RESULT(PHI) DEF_FROM_PTR (PHI_RESULT_PTR (PHI)) 88 #define PHI_RESULT(PHI) DEF_FROM_PTR (PHI_RESULT_PTR (PHI))
184 #define SET_PHI_RESULT(PHI, V) SET_DEF (PHI_RESULT_PTR (PHI), (V)) 89 #define SET_PHI_RESULT(PHI, V) SET_DEF (PHI_RESULT_PTR (PHI), (V))
185 90
198 extern void fini_ssa_operands (void); 103 extern void fini_ssa_operands (void);
199 extern void update_stmt_operands (gimple); 104 extern void update_stmt_operands (gimple);
200 extern void free_stmt_operands (gimple); 105 extern void free_stmt_operands (gimple);
201 extern bool verify_imm_links (FILE *f, tree var); 106 extern bool verify_imm_links (FILE *f, tree var);
202 107
203 extern void copy_virtual_operands (gimple, gimple);
204 extern int operand_build_cmp (const void *, const void *);
205 extern void create_ssa_artificial_load_stmt (gimple, gimple, bool);
206
207 extern void dump_immediate_uses (FILE *file); 108 extern void dump_immediate_uses (FILE *file);
208 extern void dump_immediate_uses_for (FILE *file, tree var); 109 extern void dump_immediate_uses_for (FILE *file, tree var);
209 extern void debug_immediate_uses (void); 110 extern void debug_immediate_uses (void);
210 extern void debug_immediate_uses_for (tree var); 111 extern void debug_immediate_uses_for (tree var);
211 extern void dump_decl_set (FILE *, bitmap); 112 extern void dump_decl_set (FILE *, bitmap);
212 extern void debug_decl_set (bitmap); 113 extern void debug_decl_set (bitmap);
213 114
214 extern bool ssa_operands_active (void); 115 extern bool ssa_operands_active (void);
215 116
216 extern void push_stmt_changes (gimple *); 117 extern void unlink_stmt_vdef (gimple);
217 extern void pop_stmt_changes (gimple *);
218 extern void discard_stmt_changes (gimple *);
219 void add_to_addressable_set (tree, bitmap *);
220 118
221 enum ssa_op_iter_type { 119 enum ssa_op_iter_type {
222 ssa_op_iter_none = 0, 120 ssa_op_iter_none = 0,
223 ssa_op_iter_tree, 121 ssa_op_iter_tree,
224 ssa_op_iter_use, 122 ssa_op_iter_use,
225 ssa_op_iter_def, 123 ssa_op_iter_def
226 ssa_op_iter_vdef 124 };
227 }; 125
228 126 /* This structure is used in the operand iterator loops. It contains the
229 /* This structure is used in the operand iterator loops. It contains the
230 items required to determine which operand is retrieved next. During 127 items required to determine which operand is retrieved next. During
231 optimization, this structure is scalarized, and any unused fields are 128 optimization, this structure is scalarized, and any unused fields are
232 optimized away, resulting in little overhead. */ 129 optimized away, resulting in little overhead. */
233 130
234 typedef struct ssa_operand_iterator_d 131 typedef struct ssa_operand_iterator_d
235 { 132 {
133 bool done;
134 enum ssa_op_iter_type iter_type;
236 def_optype_p defs; 135 def_optype_p defs;
237 use_optype_p uses; 136 use_optype_p uses;
238 voptype_p vuses;
239 voptype_p vdefs;
240 voptype_p mayuses;
241 enum ssa_op_iter_type iter_type;
242 int phi_i; 137 int phi_i;
243 int num_phi; 138 int num_phi;
244 gimple phi_stmt; 139 gimple phi_stmt;
245 bool done;
246 unsigned int vuse_index;
247 unsigned int mayuse_index;
248 } ssa_op_iter; 140 } ssa_op_iter;
249 141
250 /* These flags are used to determine which operands are returned during 142 /* These flags are used to determine which operands are returned during
251 execution of the loop. */ 143 execution of the loop. */
252 #define SSA_OP_USE 0x01 /* Real USE operands. */ 144 #define SSA_OP_USE 0x01 /* Real USE operands. */
253 #define SSA_OP_DEF 0x02 /* Real DEF operands. */ 145 #define SSA_OP_DEF 0x02 /* Real DEF operands. */
254 #define SSA_OP_VUSE 0x04 /* VUSE operands. */ 146 #define SSA_OP_VUSE 0x04 /* VUSE operands. */
255 #define SSA_OP_VMAYUSE 0x08 /* USE portion of VDEFS. */ 147 #define SSA_OP_VDEF 0x08 /* VDEF operands. */
256 #define SSA_OP_VDEF 0x10 /* DEF portion of VDEFS. */
257 148
258 /* These are commonly grouped operand flags. */ 149 /* These are commonly grouped operand flags. */
259 #define SSA_OP_VIRTUAL_USES (SSA_OP_VUSE | SSA_OP_VMAYUSE) 150 #define SSA_OP_VIRTUAL_USES (SSA_OP_VUSE)
260 #define SSA_OP_VIRTUAL_DEFS (SSA_OP_VDEF) 151 #define SSA_OP_VIRTUAL_DEFS (SSA_OP_VDEF)
261 #define SSA_OP_ALL_VIRTUALS (SSA_OP_VIRTUAL_USES | SSA_OP_VIRTUAL_DEFS) 152 #define SSA_OP_ALL_VIRTUALS (SSA_OP_VIRTUAL_USES | SSA_OP_VIRTUAL_DEFS)
262 #define SSA_OP_ALL_USES (SSA_OP_VIRTUAL_USES | SSA_OP_USE) 153 #define SSA_OP_ALL_USES (SSA_OP_VIRTUAL_USES | SSA_OP_USE)
263 #define SSA_OP_ALL_DEFS (SSA_OP_VIRTUAL_DEFS | SSA_OP_DEF) 154 #define SSA_OP_ALL_DEFS (SSA_OP_VIRTUAL_DEFS | SSA_OP_DEF)
264 #define SSA_OP_ALL_OPERANDS (SSA_OP_ALL_USES | SSA_OP_ALL_DEFS) 155 #define SSA_OP_ALL_OPERANDS (SSA_OP_ALL_USES | SSA_OP_ALL_DEFS)
265 156
266 /* This macro executes a loop over the operands of STMT specified in FLAG, 157 /* This macro executes a loop over the operands of STMT specified in FLAG,
267 returning each operand as a 'tree' in the variable TREEVAR. ITER is an 158 returning each operand as a 'tree' in the variable TREEVAR. ITER is an
268 ssa_op_iter structure used to control the loop. */ 159 ssa_op_iter structure used to control the loop. */
269 #define FOR_EACH_SSA_TREE_OPERAND(TREEVAR, STMT, ITER, FLAGS) \ 160 #define FOR_EACH_SSA_TREE_OPERAND(TREEVAR, STMT, ITER, FLAGS) \
270 for (TREEVAR = op_iter_init_tree (&(ITER), STMT, FLAGS); \ 161 for (TREEVAR = op_iter_init_tree (&(ITER), STMT, FLAGS); \
271 !op_iter_done (&(ITER)); \ 162 !op_iter_done (&(ITER)); \
272 TREEVAR = op_iter_next_tree (&(ITER))) 163 TREEVAR = op_iter_next_tree (&(ITER)))
273 164
274 /* This macro executes a loop over the operands of STMT specified in FLAG, 165 /* This macro executes a loop over the operands of STMT specified in FLAG,
275 returning each operand as a 'use_operand_p' in the variable USEVAR. 166 returning each operand as a 'use_operand_p' in the variable USEVAR.
276 ITER is an ssa_op_iter structure used to control the loop. */ 167 ITER is an ssa_op_iter structure used to control the loop. */
277 #define FOR_EACH_SSA_USE_OPERAND(USEVAR, STMT, ITER, FLAGS) \ 168 #define FOR_EACH_SSA_USE_OPERAND(USEVAR, STMT, ITER, FLAGS) \
278 for (USEVAR = op_iter_init_use (&(ITER), STMT, FLAGS); \ 169 for (USEVAR = op_iter_init_use (&(ITER), STMT, FLAGS); \
279 !op_iter_done (&(ITER)); \ 170 !op_iter_done (&(ITER)); \
280 USEVAR = op_iter_next_use (&(ITER))) 171 USEVAR = op_iter_next_use (&(ITER)))
281 172
282 /* This macro executes a loop over the operands of STMT specified in FLAG, 173 /* This macro executes a loop over the operands of STMT specified in FLAG,
283 returning each operand as a 'def_operand_p' in the variable DEFVAR. 174 returning each operand as a 'def_operand_p' in the variable DEFVAR.
284 ITER is an ssa_op_iter structure used to control the loop. */ 175 ITER is an ssa_op_iter structure used to control the loop. */
285 #define FOR_EACH_SSA_DEF_OPERAND(DEFVAR, STMT, ITER, FLAGS) \ 176 #define FOR_EACH_SSA_DEF_OPERAND(DEFVAR, STMT, ITER, FLAGS) \
286 for (DEFVAR = op_iter_init_def (&(ITER), STMT, FLAGS); \ 177 for (DEFVAR = op_iter_init_def (&(ITER), STMT, FLAGS); \
287 !op_iter_done (&(ITER)); \ 178 !op_iter_done (&(ITER)); \
288 DEFVAR = op_iter_next_def (&(ITER))) 179 DEFVAR = op_iter_next_def (&(ITER)))
289
290 /* This macro executes a loop over the VDEF operands of STMT. The def
291 and use vector for each VDEF is returned in DEFVAR and USEVECT.
292 ITER is an ssa_op_iter structure used to control the loop. */
293 #define FOR_EACH_SSA_VDEF_OPERAND(DEFVAR, USEVECT, STMT, ITER) \
294 for (op_iter_init_vdef (&(ITER), STMT, &(USEVECT), &(DEFVAR)); \
295 !op_iter_done (&(ITER)); \
296 op_iter_next_vdef (&(USEVECT), &(DEFVAR), &(ITER)))
297 180
298 /* This macro will execute a loop over all the arguments of a PHI which 181 /* This macro will execute a loop over all the arguments of a PHI which
299 match FLAGS. A use_operand_p is always returned via USEVAR. FLAGS 182 match FLAGS. A use_operand_p is always returned via USEVAR. FLAGS
300 can be either SSA_OP_USE or SSA_OP_VIRTUAL_USES or SSA_OP_ALL_USES. */ 183 can be either SSA_OP_USE or SSA_OP_VIRTUAL_USES or SSA_OP_ALL_USES. */
301 #define FOR_EACH_PHI_ARG(USEVAR, STMT, ITER, FLAGS) \ 184 #define FOR_EACH_PHI_ARG(USEVAR, STMT, ITER, FLAGS) \
319 for ((DEFVAR) = (gimple_code (STMT) == GIMPLE_PHI \ 202 for ((DEFVAR) = (gimple_code (STMT) == GIMPLE_PHI \
320 ? op_iter_init_phidef (&(ITER), STMT, FLAGS) \ 203 ? op_iter_init_phidef (&(ITER), STMT, FLAGS) \
321 : op_iter_init_def (&(ITER), STMT, FLAGS)); \ 204 : op_iter_init_def (&(ITER), STMT, FLAGS)); \
322 !op_iter_done (&(ITER)); \ 205 !op_iter_done (&(ITER)); \
323 (DEFVAR) = op_iter_next_def (&(ITER))) 206 (DEFVAR) = op_iter_next_def (&(ITER)))
324 207
325 /* This macro returns an operand in STMT as a tree if it is the ONLY 208 /* This macro returns an operand in STMT as a tree if it is the ONLY
326 operand matching FLAGS. If there are 0 or more than 1 operand matching 209 operand matching FLAGS. If there are 0 or more than 1 operand matching
327 FLAGS, then NULL_TREE is returned. */ 210 FLAGS, then NULL_TREE is returned. */
328 #define SINGLE_SSA_TREE_OPERAND(STMT, FLAGS) \ 211 #define SINGLE_SSA_TREE_OPERAND(STMT, FLAGS) \
329 single_ssa_tree_operand (STMT, FLAGS) 212 single_ssa_tree_operand (STMT, FLAGS)
330 213
331 /* This macro returns an operand in STMT as a use_operand_p if it is the ONLY 214 /* This macro returns an operand in STMT as a use_operand_p if it is the ONLY
332 operand matching FLAGS. If there are 0 or more than 1 operand matching 215 operand matching FLAGS. If there are 0 or more than 1 operand matching
333 FLAGS, then NULL_USE_OPERAND_P is returned. */ 216 FLAGS, then NULL_USE_OPERAND_P is returned. */
334 #define SINGLE_SSA_USE_OPERAND(STMT, FLAGS) \ 217 #define SINGLE_SSA_USE_OPERAND(STMT, FLAGS) \
335 single_ssa_use_operand (STMT, FLAGS) 218 single_ssa_use_operand (STMT, FLAGS)
336 219
337 /* This macro returns an operand in STMT as a def_operand_p if it is the ONLY 220 /* This macro returns an operand in STMT as a def_operand_p if it is the ONLY
338 operand matching FLAGS. If there are 0 or more than 1 operand matching 221 operand matching FLAGS. If there are 0 or more than 1 operand matching
339 FLAGS, then NULL_DEF_OPERAND_P is returned. */ 222 FLAGS, then NULL_DEF_OPERAND_P is returned. */
340 #define SINGLE_SSA_DEF_OPERAND(STMT, FLAGS) \ 223 #define SINGLE_SSA_DEF_OPERAND(STMT, FLAGS) \
341 single_ssa_def_operand (STMT, FLAGS) 224 single_ssa_def_operand (STMT, FLAGS)