Mercurial > hg > CbC > CbC_gcc
annotate gcc/tree-ssa-sccvn.h @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 1830386684a0 |
children |
rev | line source |
---|---|
0 | 1 /* Tree SCC value numbering |
145 | 2 Copyright (C) 2007-2020 Free Software Foundation, Inc. |
0 | 3 Contributed by Daniel Berlin <dberlin@dberlin.org> |
4 | |
5 This file is part of GCC. | |
6 | |
7 GCC is free software; you can redistribute it and/or modify | |
8 under the terms of the GNU General Public License as published by | |
9 the Free Software Foundation; either version 3 of the License, or | |
10 (at your option) any later version. | |
11 | |
12 GCC is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GCC; see the file COPYING3. If not see | |
19 <http://www.gnu.org/licenses/>. */ | |
20 | |
21 #ifndef TREE_SSA_SCCVN_H | |
22 #define TREE_SSA_SCCVN_H | |
23 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
24 /* In tree-ssa-sccvn.c */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
25 bool expressions_equal_p (tree, tree); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
26 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
27 |
0 | 28 /* TOP of the VN lattice. */ |
29 extern tree VN_TOP; | |
30 | |
131 | 31 /* A predicated value. */ |
32 struct vn_pval | |
33 { | |
34 vn_pval *next; | |
35 /* The value of the expression this is attached to is RESULT in | |
36 case the expression is computed dominated by one of the blocks | |
37 in valid_dominated_by_p. */ | |
38 tree result; | |
39 unsigned n; | |
40 int valid_dominated_by_p[1]; | |
41 }; | |
42 | |
0 | 43 /* N-ary operations in the hashtable consist of length operands, an |
44 opcode, and a type. Result is the value number of the operation, | |
45 and hashcode is stored to avoid having to calculate it | |
46 repeatedly. */ | |
47 | |
48 typedef struct vn_nary_op_s | |
49 { | |
131 | 50 vn_nary_op_s *next; |
51 vn_nary_op_s *unwind_to; | |
0 | 52 /* Unique identify that all expressions with the same value have. */ |
53 unsigned int value_id; | |
54 ENUM_BITFIELD(tree_code) opcode : 16; | |
55 unsigned length : 16; | |
56 hashval_t hashcode; | |
131 | 57 unsigned predicated_values : 1; |
58 union { | |
59 /* If ! predicated_values this is the value of the expression. */ | |
60 tree result; | |
61 /* If predicated_values this is a list of values of the expression. */ | |
62 vn_pval *values; | |
63 } u; | |
0 | 64 tree type; |
111 | 65 tree op[1]; |
0 | 66 } *vn_nary_op_t; |
67 typedef const struct vn_nary_op_s *const_vn_nary_op_t; | |
68 | |
111 | 69 /* Return the size of a vn_nary_op_t with LENGTH operands. */ |
70 | |
71 static inline size_t | |
72 sizeof_vn_nary_op (unsigned int length) | |
73 { | |
74 return sizeof (struct vn_nary_op_s) + sizeof (tree) * length - sizeof (tree); | |
75 } | |
76 | |
0 | 77 /* Phi nodes in the hashtable consist of their non-VN_TOP phi |
78 arguments, and the basic block the phi is in. Result is the value | |
79 number of the operation, and hashcode is stored to avoid having to | |
80 calculate it repeatedly. Phi nodes not in the same block are never | |
81 considered equivalent. */ | |
82 | |
83 typedef struct vn_phi_s | |
84 { | |
131 | 85 vn_phi_s *next; |
0 | 86 /* Unique identifier that all expressions with the same value have. */ |
87 unsigned int value_id; | |
88 hashval_t hashcode; | |
89 basic_block block; | |
111 | 90 /* Controlling condition lhs/rhs. */ |
91 tree cclhs; | |
92 tree ccrhs; | |
93 tree type; | |
0 | 94 tree result; |
131 | 95 /* The number of args is determined by EDGE_COUT (block->preds). */ |
96 tree phiargs[1]; | |
0 | 97 } *vn_phi_t; |
98 typedef const struct vn_phi_s *const_vn_phi_t; | |
99 | |
100 /* Reference operands only exist in reference operations structures. | |
101 They consist of an opcode, type, and some number of operands. For | |
102 a given opcode, some, all, or none of the operands may be used. | |
103 The operands are there to store the information that makes up the | |
104 portion of the addressing calculation that opcode performs. */ | |
105 | |
106 typedef struct vn_reference_op_struct | |
107 { | |
111 | 108 ENUM_BITFIELD(tree_code) opcode : 16; |
109 /* Dependence info, used for [TARGET_]MEM_REF only. */ | |
110 unsigned short clique; | |
111 unsigned short base; | |
112 unsigned reverse : 1; | |
113 /* For storing TYPE_ALIGN for array ref element size computation. */ | |
114 unsigned align : 6; | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
115 /* Constant offset this op adds or -1 if it is variable. */ |
131 | 116 poly_int64_pod off; |
0 | 117 tree type; |
118 tree op0; | |
119 tree op1; | |
120 tree op2; | |
121 } vn_reference_op_s; | |
122 typedef vn_reference_op_s *vn_reference_op_t; | |
123 typedef const vn_reference_op_s *const_vn_reference_op_t; | |
124 | |
111 | 125 inline unsigned |
126 vn_ref_op_align_unit (vn_reference_op_t op) | |
127 { | |
128 return op->align ? ((unsigned)1 << (op->align - 1)) / BITS_PER_UNIT : 0; | |
129 } | |
0 | 130 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
131 /* A reference operation in the hashtable is representation as |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
132 the vuse, representing the memory state at the time of |
0 | 133 the operation, and a collection of operands that make up the |
134 addressing calculation. If two vn_reference_t's have the same set | |
135 of operands, they access the same memory location. We also store | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
136 the resulting value number, and the hashcode. */ |
0 | 137 |
138 typedef struct vn_reference_s | |
139 { | |
131 | 140 vn_reference_s *next; |
0 | 141 /* Unique identifier that all expressions with the same value have. */ |
142 unsigned int value_id; | |
143 hashval_t hashcode; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
144 tree vuse; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
145 alias_set_type set; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
146 tree type; |
111 | 147 vec<vn_reference_op_s> operands; |
0 | 148 tree result; |
111 | 149 tree result_vdef; |
0 | 150 } *vn_reference_t; |
151 typedef const struct vn_reference_s *const_vn_reference_t; | |
152 | |
153 typedef struct vn_constant_s | |
154 { | |
155 unsigned int value_id; | |
156 hashval_t hashcode; | |
157 tree constant; | |
158 } *vn_constant_t; | |
159 | |
111 | 160 enum vn_kind { VN_NONE, VN_CONSTANT, VN_NARY, VN_REFERENCE, VN_PHI }; |
161 enum vn_kind vn_get_stmt_kind (gimple *); | |
162 | |
163 /* Hash the type TYPE using bits that distinguishes it in the | |
164 types_compatible_p sense. */ | |
165 | |
166 static inline hashval_t | |
167 vn_hash_type (tree type) | |
168 { | |
169 return (INTEGRAL_TYPE_P (type) | |
170 + (INTEGRAL_TYPE_P (type) | |
171 ? TYPE_PRECISION (type) + TYPE_UNSIGNED (type) : 0)); | |
172 } | |
173 | |
0 | 174 /* Hash the constant CONSTANT with distinguishing type incompatible |
175 constants in the types_compatible_p sense. */ | |
176 | |
177 static inline hashval_t | |
178 vn_hash_constant_with_type (tree constant) | |
179 { | |
111 | 180 inchash::hash hstate; |
181 inchash::add_expr (constant, hstate); | |
182 hstate.merge_hash (vn_hash_type (TREE_TYPE (constant))); | |
183 return hstate.end (); | |
0 | 184 } |
185 | |
186 /* Compare the constants C1 and C2 with distinguishing type incompatible | |
187 constants in the types_compatible_p sense. */ | |
188 | |
189 static inline bool | |
190 vn_constant_eq_with_type (tree c1, tree c2) | |
191 { | |
192 return (expressions_equal_p (c1, c2) | |
193 && types_compatible_p (TREE_TYPE (c1), TREE_TYPE (c2))); | |
194 } | |
195 | |
145 | 196 /* Instead of having a local availability lattice for each basic-block |
197 and availability at X defined as union of the local availabilities | |
198 at X and its dominators we're turning this upside down and track | |
199 availability per value given values are usually made available at very | |
200 few points. | |
201 So we have a chain of LOCATION, LEADER entries where LOCATION is | |
202 specifying the basic-block LEADER is made available for VALUE. | |
203 We prepend to this chain in RPO order thus for iteration we can simply | |
204 remove the last entries. | |
205 LOCATION is the basic-block index and LEADER is its SSA name version. */ | |
206 struct vn_avail | |
207 { | |
208 vn_avail *next; | |
209 /* The basic-block LEADER is made available. */ | |
210 int location; | |
211 /* The LEADER for the value we are chained on. */ | |
212 int leader; | |
213 }; | |
214 | |
0 | 215 typedef struct vn_ssa_aux |
216 { | |
131 | 217 /* SSA name this vn_ssa_aux is associated with in the lattice. */ |
218 tree name; | |
0 | 219 /* Value number. This may be an SSA name or a constant. */ |
220 tree valnum; | |
111 | 221 /* Statements to insert if needs_insertion is true. */ |
222 gimple_seq expr; | |
223 | |
145 | 224 /* AVAIL entries, last in RPO order is first. This is only tracked |
225 for SSA names also serving as values (NAME == VALNUM). */ | |
226 vn_avail *avail; | |
227 | |
0 | 228 /* Unique identifier that all expressions with the same value have. */ |
229 unsigned int value_id; | |
230 | |
131 | 231 /* Whether the SSA_NAME has been processed at least once. */ |
0 | 232 unsigned visited : 1; |
233 | |
234 /* Whether the SSA_NAME has no defining statement and thus an | |
235 insertion of such with EXPR as definition is required before | |
236 a use can be created of it. */ | |
237 unsigned needs_insertion : 1; | |
238 } *vn_ssa_aux_t; | |
239 | |
111 | 240 enum vn_lookup_kind { VN_NOWALK, VN_WALK, VN_WALKREWRITE }; |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
241 |
0 | 242 /* Return the value numbering info for an SSA_NAME. */ |
111 | 243 bool has_VN_INFO (tree); |
0 | 244 extern vn_ssa_aux_t VN_INFO (tree); |
245 tree vn_get_expr_for (tree); | |
111 | 246 void scc_vn_restore_ssa_info (void); |
247 tree vn_nary_op_lookup_stmt (gimple *, vn_nary_op_t *); | |
0 | 248 tree vn_nary_op_lookup_pieces (unsigned int, enum tree_code, |
111 | 249 tree, tree *, vn_nary_op_t *); |
0 | 250 vn_nary_op_t vn_nary_op_insert_pieces (unsigned int, enum tree_code, |
111 | 251 tree, tree *, tree, unsigned int); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
252 bool ao_ref_init_from_vn_reference (ao_ref *, alias_set_type, tree, |
111 | 253 vec<vn_reference_op_s> ); |
254 vec<vn_reference_op_s> vn_reference_operands_for_lookup (tree); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
255 tree vn_reference_lookup_pieces (tree, alias_set_type, tree, |
111 | 256 vec<vn_reference_op_s> , |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
63
diff
changeset
|
257 vn_reference_t *, vn_lookup_kind); |
145 | 258 tree vn_reference_lookup (tree, tree, vn_lookup_kind, vn_reference_t *, bool, |
259 tree * = NULL); | |
111 | 260 void vn_reference_lookup_call (gcall *, vn_reference_t *, vn_reference_t); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
261 vn_reference_t vn_reference_insert_pieces (tree, alias_set_type, tree, |
111 | 262 vec<vn_reference_op_s> , |
0 | 263 tree, unsigned int); |
264 | |
111 | 265 bool vn_nary_op_eq (const_vn_nary_op_t const vno1, |
266 const_vn_nary_op_t const vno2); | |
0 | 267 bool vn_nary_may_trap (vn_nary_op_t); |
145 | 268 bool vn_reference_may_trap (vn_reference_t); |
111 | 269 bool vn_reference_eq (const_vn_reference_t const, const_vn_reference_t const); |
0 | 270 unsigned int get_max_value_id (void); |
271 unsigned int get_next_value_id (void); | |
272 unsigned int get_constant_value_id (tree); | |
273 unsigned int get_or_alloc_constant_value_id (tree); | |
274 bool value_id_constant_p (unsigned int); | |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
275 tree fully_constant_vn_reference_p (vn_reference_t); |
111 | 276 tree vn_nary_simplify (vn_nary_op_t); |
277 | |
131 | 278 unsigned do_rpo_vn (function *, edge, bitmap); |
279 void run_rpo_vn (vn_lookup_kind); | |
280 unsigned eliminate_with_rpo_vn (bitmap); | |
281 void free_rpo_vn (void); | |
111 | 282 |
131 | 283 /* Valueize NAME if it is an SSA name, otherwise just return it. This hook |
284 is initialized by run_scc_vn. */ | |
285 extern tree (*vn_valueize) (tree); | |
111 | 286 |
131 | 287 /* Context that valueization should operate on. */ |
288 extern basic_block vn_context_bb; | |
111 | 289 |
290 | |
0 | 291 #endif /* TREE_SSA_SCCVN_H */ |