Mercurial > hg > CbC > CbC_gcc
annotate gcc/tree-data-ref.h @ 103:edcadcec937d
modify __rectype
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 23 Mar 2012 17:11:33 +0900 |
parents | f6334be47118 |
children | 04ced10e8804 |
rev | line source |
---|---|
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1 /* Data references and dependences detectors. |
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
|
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
0 | 3 Free Software Foundation, Inc. |
4 Contributed by Sebastian Pop <pop@cri.ensmp.fr> | |
5 | |
6 This file is part of GCC. | |
7 | |
8 GCC is free software; you can redistribute it and/or modify it under | |
9 the terms of the GNU General Public License as published by the Free | |
10 Software Foundation; either version 3, or (at your option) any later | |
11 version. | |
12 | |
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 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 #ifndef GCC_TREE_DATA_REF_H | |
23 #define GCC_TREE_DATA_REF_H | |
24 | |
25 #include "graphds.h" | |
26 #include "omega.h" | |
27 #include "tree-chrec.h" | |
28 | |
29 /* | |
30 innermost_loop_behavior describes the evolution of the address of the memory | |
31 reference in the innermost enclosing loop. The address is expressed as | |
32 BASE + STEP * # of iteration, and base is further decomposed as the base | |
33 pointer (BASE_ADDRESS), loop invariant offset (OFFSET) and | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
34 constant offset (INIT). Examples, in loop nest |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
35 |
0 | 36 for (i = 0; i < 100; i++) |
37 for (j = 3; j < 100; j++) | |
38 | |
39 Example 1 Example 2 | |
40 data-ref a[j].b[i][j] *(p + x + 16B + 4B * j) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
41 |
0 | 42 |
43 innermost_loop_behavior | |
44 base_address &a p | |
45 offset i * D_i x | |
46 init 3 * D_j + offsetof (b) 28 | |
47 step D_j 4 | |
48 | |
49 */ | |
50 struct innermost_loop_behavior | |
51 { | |
52 tree base_address; | |
53 tree offset; | |
54 tree init; | |
55 tree step; | |
56 | |
57 /* Alignment information. ALIGNED_TO is set to the largest power of two | |
58 that divides OFFSET. */ | |
59 tree aligned_to; | |
60 }; | |
61 | |
62 /* Describes the evolutions of indices of the memory reference. The indices | |
63 are indices of the ARRAY_REFs and the operands of INDIRECT_REFs. | |
64 For ARRAY_REFs, BASE_OBJECT is the reference with zeroed indices | |
65 (note that this reference does not have to be valid, if zero does not | |
66 belong to the range of the array; hence it is not recommended to use | |
67 BASE_OBJECT in any code generation). For INDIRECT_REFs, the address is | |
68 set to the loop-invariant part of the address of the object, except for | |
69 the constant offset. For the examples above, | |
70 | |
71 base_object: a[0].b[0][0] *(p + x + 4B * j_0) | |
72 indices: {j_0, +, 1}_2 {16, +, 4}_2 | |
73 {i_0, +, 1}_1 | |
74 {j_0, +, 1}_2 | |
75 */ | |
76 | |
77 struct indices | |
78 { | |
79 /* The object. */ | |
80 tree base_object; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
81 |
0 | 82 /* A list of chrecs. Access functions of the indices. */ |
83 VEC(tree,heap) *access_fns; | |
84 }; | |
85 | |
86 struct dr_alias | |
87 { | |
88 /* The alias information that should be used for new pointers to this | |
89 location. SYMBOL_TAG is either a DECL or a SYMBOL_MEMORY_TAG. */ | |
90 struct ptr_info_def *ptr_info; | |
91 | |
92 /* The set of virtual operands corresponding to this memory reference, | |
93 serving as a description of the alias information for the memory | |
94 reference. This could be eliminated if we had alias oracle. */ | |
95 bitmap vops; | |
96 }; | |
97 | |
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
|
98 /* An integer vector. A vector formally consists of an element of a vector |
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
|
99 space. A vector space is a set that is closed under vector addition |
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
|
100 and scalar multiplication. In this vector space, an element is a list of |
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
|
101 integers. */ |
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
|
102 typedef int *lambda_vector; |
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
|
103 DEF_VEC_P(lambda_vector); |
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
|
104 DEF_VEC_ALLOC_P(lambda_vector,heap); |
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
|
105 DEF_VEC_ALLOC_P(lambda_vector,gc); |
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
|
106 |
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
|
107 /* An integer matrix. A matrix consists of m vectors of length n (IE |
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
|
108 all vectors are the same length). */ |
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
|
109 typedef lambda_vector *lambda_matrix; |
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
|
110 |
0 | 111 /* Each vector of the access matrix represents a linear access |
112 function for a subscript. First elements correspond to the | |
113 leftmost indices, ie. for a[i][j] the first vector corresponds to | |
114 the subscript in "i". The elements of a vector are relative to | |
115 the loop nests in which the data reference is considered, | |
116 i.e. the vector is relative to the SCoP that provides the context | |
117 in which this data reference occurs. | |
118 | |
119 For example, in | |
120 | |
121 | loop_1 | |
122 | loop_2 | |
123 | a[i+3][2*j+n-1] | |
124 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
125 if "i" varies in loop_1 and "j" varies in loop_2, the access |
0 | 126 matrix with respect to the loop nest {loop_1, loop_2} is: |
127 | |
128 | loop_1 loop_2 param_n cst | |
129 | 1 0 0 3 | |
130 | 0 2 1 -1 | |
131 | |
132 whereas the access matrix with respect to loop_2 considers "i" as | |
133 a parameter: | |
134 | |
135 | loop_2 param_i param_n cst | |
136 | 0 1 0 3 | |
137 | 2 0 1 -1 | |
138 */ | |
139 struct access_matrix | |
140 { | |
141 VEC (loop_p, heap) *loop_nest; | |
142 int nb_induction_vars; | |
143 VEC (tree, heap) *parameters; | |
144 VEC (lambda_vector, gc) *matrix; | |
145 }; | |
146 | |
147 #define AM_LOOP_NEST(M) (M)->loop_nest | |
148 #define AM_NB_INDUCTION_VARS(M) (M)->nb_induction_vars | |
149 #define AM_PARAMETERS(M) (M)->parameters | |
150 #define AM_MATRIX(M) (M)->matrix | |
151 #define AM_NB_PARAMETERS(M) (VEC_length (tree, AM_PARAMETERS(M))) | |
152 #define AM_CONST_COLUMN_INDEX(M) (AM_NB_INDUCTION_VARS (M) + AM_NB_PARAMETERS (M)) | |
153 #define AM_NB_COLUMNS(M) (AM_NB_INDUCTION_VARS (M) + AM_NB_PARAMETERS (M) + 1) | |
154 #define AM_GET_SUBSCRIPT_ACCESS_VECTOR(M, I) VEC_index (lambda_vector, AM_MATRIX (M), I) | |
155 #define AM_GET_ACCESS_MATRIX_ELEMENT(M, I, J) AM_GET_SUBSCRIPT_ACCESS_VECTOR (M, I)[J] | |
156 | |
157 /* Return the column in the access matrix of LOOP_NUM. */ | |
158 | |
159 static inline int | |
160 am_vector_index_for_loop (struct access_matrix *access_matrix, int loop_num) | |
161 { | |
162 int i; | |
163 loop_p l; | |
164 | |
165 for (i = 0; VEC_iterate (loop_p, AM_LOOP_NEST (access_matrix), i, l); i++) | |
166 if (l->num == loop_num) | |
167 return i; | |
168 | |
169 gcc_unreachable(); | |
170 } | |
171 | |
172 int access_matrix_get_index_for_parameter (tree, struct access_matrix *); | |
173 | |
174 struct data_reference | |
175 { | |
176 /* A pointer to the statement that contains this DR. */ | |
177 gimple stmt; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
178 |
0 | 179 /* A pointer to the memory reference. */ |
180 tree ref; | |
181 | |
182 /* Auxiliary info specific to a pass. */ | |
183 void *aux; | |
184 | |
185 /* True when the data reference is in RHS of a stmt. */ | |
186 bool is_read; | |
187 | |
188 /* Behavior of the memory reference in the innermost loop. */ | |
189 struct innermost_loop_behavior innermost; | |
190 | |
191 /* Subscripts of this data reference. */ | |
192 struct indices indices; | |
193 | |
194 /* Alias information for the data reference. */ | |
195 struct dr_alias alias; | |
196 | |
197 /* Matrix representation for the data access functions. */ | |
198 struct access_matrix *access_matrix; | |
199 }; | |
200 | |
201 #define DR_STMT(DR) (DR)->stmt | |
202 #define DR_REF(DR) (DR)->ref | |
203 #define DR_BASE_OBJECT(DR) (DR)->indices.base_object | |
204 #define DR_ACCESS_FNS(DR) (DR)->indices.access_fns | |
205 #define DR_ACCESS_FN(DR, I) VEC_index (tree, DR_ACCESS_FNS (DR), I) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
206 #define DR_NUM_DIMENSIONS(DR) VEC_length (tree, DR_ACCESS_FNS (DR)) |
0 | 207 #define DR_IS_READ(DR) (DR)->is_read |
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
|
208 #define DR_IS_WRITE(DR) (!DR_IS_READ (DR)) |
0 | 209 #define DR_BASE_ADDRESS(DR) (DR)->innermost.base_address |
210 #define DR_OFFSET(DR) (DR)->innermost.offset | |
211 #define DR_INIT(DR) (DR)->innermost.init | |
212 #define DR_STEP(DR) (DR)->innermost.step | |
213 #define DR_PTR_INFO(DR) (DR)->alias.ptr_info | |
214 #define DR_ALIGNED_TO(DR) (DR)->innermost.aligned_to | |
215 #define DR_ACCESS_MATRIX(DR) (DR)->access_matrix | |
216 | |
217 typedef struct data_reference *data_reference_p; | |
218 DEF_VEC_P(data_reference_p); | |
219 DEF_VEC_ALLOC_P (data_reference_p, heap); | |
220 | |
221 enum data_dependence_direction { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
222 dir_positive, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
223 dir_negative, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
224 dir_equal, |
0 | 225 dir_positive_or_negative, |
226 dir_positive_or_equal, | |
227 dir_negative_or_equal, | |
228 dir_star, | |
229 dir_independent | |
230 }; | |
231 | |
232 /* The description of the grid of iterations that overlap. At most | |
233 two loops are considered at the same time just now, hence at most | |
234 two functions are needed. For each of the functions, we store | |
235 the vector of coefficients, f[0] + x * f[1] + y * f[2] + ..., | |
236 where x, y, ... are variables. */ | |
237 | |
238 #define MAX_DIM 2 | |
239 | |
240 /* Special values of N. */ | |
241 #define NO_DEPENDENCE 0 | |
242 #define NOT_KNOWN (MAX_DIM + 1) | |
243 #define CF_NONTRIVIAL_P(CF) ((CF)->n != NO_DEPENDENCE && (CF)->n != NOT_KNOWN) | |
244 #define CF_NOT_KNOWN_P(CF) ((CF)->n == NOT_KNOWN) | |
245 #define CF_NO_DEPENDENCE_P(CF) ((CF)->n == NO_DEPENDENCE) | |
246 | |
247 typedef VEC (tree, heap) *affine_fn; | |
248 | |
249 typedef struct | |
250 { | |
251 unsigned n; | |
252 affine_fn fns[MAX_DIM]; | |
253 } conflict_function; | |
254 | |
255 /* What is a subscript? Given two array accesses a subscript is the | |
256 tuple composed of the access functions for a given dimension. | |
257 Example: Given A[f1][f2][f3] and B[g1][g2][g3], there are three | |
258 subscripts: (f1, g1), (f2, g2), (f3, g3). These three subscripts | |
259 are stored in the data_dependence_relation structure under the form | |
260 of an array of subscripts. */ | |
261 | |
262 struct subscript | |
263 { | |
264 /* A description of the iterations for which the elements are | |
265 accessed twice. */ | |
266 conflict_function *conflicting_iterations_in_a; | |
267 conflict_function *conflicting_iterations_in_b; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
268 |
0 | 269 /* This field stores the information about the iteration domain |
270 validity of the dependence relation. */ | |
271 tree last_conflict; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
272 |
0 | 273 /* Distance from the iteration that access a conflicting element in |
274 A to the iteration that access this same conflicting element in | |
275 B. The distance is a tree scalar expression, i.e. a constant or a | |
276 symbolic expression, but certainly not a chrec function. */ | |
277 tree distance; | |
278 }; | |
279 | |
280 typedef struct subscript *subscript_p; | |
281 DEF_VEC_P(subscript_p); | |
282 DEF_VEC_ALLOC_P (subscript_p, heap); | |
283 | |
284 #define SUB_CONFLICTS_IN_A(SUB) SUB->conflicting_iterations_in_a | |
285 #define SUB_CONFLICTS_IN_B(SUB) SUB->conflicting_iterations_in_b | |
286 #define SUB_LAST_CONFLICT(SUB) SUB->last_conflict | |
287 #define SUB_DISTANCE(SUB) SUB->distance | |
288 | |
289 /* A data_dependence_relation represents a relation between two | |
290 data_references A and B. */ | |
291 | |
292 struct data_dependence_relation | |
293 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
294 |
0 | 295 struct data_reference *a; |
296 struct data_reference *b; | |
297 | |
298 /* A "yes/no/maybe" field for the dependence relation: | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
299 |
0 | 300 - when "ARE_DEPENDENT == NULL_TREE", there exist a dependence |
301 relation between A and B, and the description of this relation | |
302 is given in the SUBSCRIPTS array, | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
303 |
0 | 304 - when "ARE_DEPENDENT == chrec_known", there is no dependence and |
305 SUBSCRIPTS is empty, | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
306 |
0 | 307 - when "ARE_DEPENDENT == chrec_dont_know", there may be a dependence, |
308 but the analyzer cannot be more specific. */ | |
309 tree are_dependent; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
310 |
0 | 311 /* For each subscript in the dependence test, there is an element in |
312 this array. This is the attribute that labels the edge A->B of | |
313 the data_dependence_relation. */ | |
314 VEC (subscript_p, heap) *subscripts; | |
315 | |
316 /* The analyzed loop nest. */ | |
317 VEC (loop_p, heap) *loop_nest; | |
318 | |
319 /* The classic direction vector. */ | |
320 VEC (lambda_vector, heap) *dir_vects; | |
321 | |
322 /* The classic distance vector. */ | |
323 VEC (lambda_vector, heap) *dist_vects; | |
324 | |
325 /* An index in loop_nest for the innermost loop that varies for | |
326 this data dependence relation. */ | |
327 unsigned inner_loop; | |
328 | |
329 /* Is the dependence reversed with respect to the lexicographic order? */ | |
330 bool reversed_p; | |
331 | |
332 /* When the dependence relation is affine, it can be represented by | |
333 a distance vector. */ | |
334 bool affine_p; | |
335 | |
336 /* Set to true when the dependence relation is on the same data | |
337 access. */ | |
338 bool self_reference_p; | |
339 }; | |
340 | |
341 typedef struct data_dependence_relation *ddr_p; | |
342 DEF_VEC_P(ddr_p); | |
343 DEF_VEC_ALLOC_P(ddr_p,heap); | |
344 | |
345 #define DDR_A(DDR) DDR->a | |
346 #define DDR_B(DDR) DDR->b | |
347 #define DDR_AFFINE_P(DDR) DDR->affine_p | |
348 #define DDR_ARE_DEPENDENT(DDR) DDR->are_dependent | |
349 #define DDR_SUBSCRIPTS(DDR) DDR->subscripts | |
350 #define DDR_SUBSCRIPT(DDR, I) VEC_index (subscript_p, DDR_SUBSCRIPTS (DDR), I) | |
351 #define DDR_NUM_SUBSCRIPTS(DDR) VEC_length (subscript_p, DDR_SUBSCRIPTS (DDR)) | |
352 | |
353 #define DDR_LOOP_NEST(DDR) DDR->loop_nest | |
354 /* The size of the direction/distance vectors: the number of loops in | |
355 the loop nest. */ | |
356 #define DDR_NB_LOOPS(DDR) (VEC_length (loop_p, DDR_LOOP_NEST (DDR))) | |
357 #define DDR_INNER_LOOP(DDR) DDR->inner_loop | |
358 #define DDR_SELF_REFERENCE(DDR) DDR->self_reference_p | |
359 | |
360 #define DDR_DIST_VECTS(DDR) ((DDR)->dist_vects) | |
361 #define DDR_DIR_VECTS(DDR) ((DDR)->dir_vects) | |
362 #define DDR_NUM_DIST_VECTS(DDR) \ | |
363 (VEC_length (lambda_vector, DDR_DIST_VECTS (DDR))) | |
364 #define DDR_NUM_DIR_VECTS(DDR) \ | |
365 (VEC_length (lambda_vector, DDR_DIR_VECTS (DDR))) | |
366 #define DDR_DIR_VECT(DDR, I) \ | |
367 VEC_index (lambda_vector, DDR_DIR_VECTS (DDR), I) | |
368 #define DDR_DIST_VECT(DDR, I) \ | |
369 VEC_index (lambda_vector, DDR_DIST_VECTS (DDR), I) | |
370 #define DDR_REVERSED_P(DDR) DDR->reversed_p | |
371 | |
372 | |
373 | |
374 /* Describes a location of a memory reference. */ | |
375 | |
376 typedef struct data_ref_loc_d | |
377 { | |
378 /* Position of the memory reference. */ | |
379 tree *pos; | |
380 | |
381 /* True if the memory reference is read. */ | |
382 bool is_read; | |
383 } data_ref_loc; | |
384 | |
385 DEF_VEC_O (data_ref_loc); | |
386 DEF_VEC_ALLOC_O (data_ref_loc, heap); | |
387 | |
388 bool get_references_in_stmt (gimple, VEC (data_ref_loc, heap) **); | |
389 bool dr_analyze_innermost (struct data_reference *); | |
390 extern bool compute_data_dependences_for_loop (struct loop *, bool, | |
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
|
391 VEC (loop_p, heap) **, |
0 | 392 VEC (data_reference_p, heap) **, |
393 VEC (ddr_p, heap) **); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
394 extern bool compute_data_dependences_for_bb (basic_block, bool, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
395 VEC (data_reference_p, heap) **, |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
396 VEC (ddr_p, heap) **); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
397 extern tree find_data_references_in_loop (struct loop *, |
0 | 398 VEC (data_reference_p, heap) **); |
399 extern void print_direction_vector (FILE *, lambda_vector, int); | |
400 extern void print_dir_vectors (FILE *, VEC (lambda_vector, heap) *, int); | |
401 extern void print_dist_vectors (FILE *, VEC (lambda_vector, heap) *, int); | |
402 extern void dump_subscript (FILE *, struct subscript *); | |
403 extern void dump_ddrs (FILE *, VEC (ddr_p, heap) *); | |
404 extern void dump_dist_dir_vectors (FILE *, VEC (ddr_p, heap) *); | |
405 extern void dump_data_reference (FILE *, struct data_reference *); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
406 extern void debug_data_reference (struct data_reference *); |
0 | 407 extern void dump_data_references (FILE *, VEC (data_reference_p, heap) *); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
408 extern void debug_data_references (VEC (data_reference_p, heap) *); |
0 | 409 extern void debug_data_dependence_relation (struct data_dependence_relation *); |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
410 extern void dump_data_dependence_relation (FILE *, |
0 | 411 struct data_dependence_relation *); |
412 extern void dump_data_dependence_relations (FILE *, VEC (ddr_p, heap) *); | |
413 extern void debug_data_dependence_relations (VEC (ddr_p, heap) *); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
414 extern void dump_data_dependence_direction (FILE *, |
0 | 415 enum data_dependence_direction); |
416 extern void free_dependence_relation (struct data_dependence_relation *); | |
417 extern void free_dependence_relations (VEC (ddr_p, heap) *); | |
418 extern void free_data_ref (data_reference_p); | |
419 extern void free_data_refs (VEC (data_reference_p, heap) *); | |
420 extern bool find_data_references_in_stmt (struct loop *, gimple, | |
421 VEC (data_reference_p, heap) **); | |
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
|
422 extern bool graphite_find_data_references_in_stmt (loop_p, loop_p, gimple, |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
423 VEC (data_reference_p, heap) **); |
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
|
424 struct data_reference *create_data_ref (loop_p, loop_p, tree, gimple, bool); |
0 | 425 extern bool find_loop_nest (struct loop *, VEC (loop_p, heap) **); |
426 extern void compute_all_dependences (VEC (data_reference_p, heap) *, | |
427 VEC (ddr_p, heap) **, VEC (loop_p, heap) *, | |
428 bool); | |
429 | |
430 extern void create_rdg_vertices (struct graph *, VEC (gimple, heap) *); | |
431 extern bool dr_may_alias_p (const struct data_reference *, | |
432 const struct data_reference *); | |
433 | |
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
|
434 |
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
|
435 /* Return true when the base objects of data references A and B are |
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
|
436 the same memory object. */ |
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
|
437 |
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
|
438 static inline bool |
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
|
439 same_data_refs_base_objects (data_reference_p a, data_reference_p b) |
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
|
440 { |
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
|
441 return DR_NUM_DIMENSIONS (a) == DR_NUM_DIMENSIONS (b) |
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
|
442 && operand_equal_p (DR_BASE_OBJECT (a), DR_BASE_OBJECT (b), 0); |
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
|
443 } |
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
|
444 |
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
|
445 /* Return true when the data references A and B are accessing the same |
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
|
446 memory object with the same access functions. */ |
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
|
447 |
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
|
448 static inline bool |
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
|
449 same_data_refs (data_reference_p a, data_reference_p b) |
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
|
450 { |
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
|
451 unsigned int i; |
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
|
452 |
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
|
453 /* The references are exactly the same. */ |
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
|
454 if (operand_equal_p (DR_REF (a), DR_REF (b), 0)) |
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
|
455 return true; |
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
|
456 |
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
|
457 if (!same_data_refs_base_objects (a, b)) |
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
|
458 return false; |
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
|
459 |
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
|
460 for (i = 0; i < DR_NUM_DIMENSIONS (a); i++) |
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
|
461 if (!eq_evolutions_p (DR_ACCESS_FN (a, i), DR_ACCESS_FN (b, i))) |
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
|
462 return false; |
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
|
463 |
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
|
464 return true; |
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
|
465 } |
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
|
466 |
0 | 467 /* Return true when the DDR contains two data references that have the |
468 same access functions. */ | |
469 | |
470 static inline bool | |
471 same_access_functions (const struct data_dependence_relation *ddr) | |
472 { | |
473 unsigned i; | |
474 | |
475 for (i = 0; i < DDR_NUM_SUBSCRIPTS (ddr); i++) | |
476 if (!eq_evolutions_p (DR_ACCESS_FN (DDR_A (ddr), i), | |
477 DR_ACCESS_FN (DDR_B (ddr), i))) | |
478 return false; | |
479 | |
480 return true; | |
481 } | |
482 | |
483 /* Return true when DDR is an anti-dependence relation. */ | |
484 | |
485 static inline bool | |
486 ddr_is_anti_dependent (ddr_p ddr) | |
487 { | |
488 return (DDR_ARE_DEPENDENT (ddr) == NULL_TREE | |
489 && DR_IS_READ (DDR_A (ddr)) | |
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
|
490 && DR_IS_WRITE (DDR_B (ddr)) |
0 | 491 && !same_access_functions (ddr)); |
492 } | |
493 | |
494 /* Return true when DEPENDENCE_RELATIONS contains an anti-dependence. */ | |
495 | |
496 static inline bool | |
497 ddrs_have_anti_deps (VEC (ddr_p, heap) *dependence_relations) | |
498 { | |
499 unsigned i; | |
500 ddr_p ddr; | |
501 | |
502 for (i = 0; VEC_iterate (ddr_p, dependence_relations, i, ddr); i++) | |
503 if (ddr_is_anti_dependent (ddr)) | |
504 return true; | |
505 | |
506 return false; | |
507 } | |
508 | |
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
|
509 /* Returns the dependence level for a vector DIST of size LENGTH. |
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
|
510 LEVEL = 0 means a lexicographic dependence, i.e. a dependence due |
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
|
511 to the sequence of statements, not carried by any loop. */ |
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
|
512 |
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
|
513 static inline unsigned |
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
|
514 dependence_level (lambda_vector dist_vect, int length) |
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
|
515 { |
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
|
516 int i; |
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
|
517 |
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
|
518 for (i = 0; i < length; i++) |
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
|
519 if (dist_vect[i] != 0) |
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
|
520 return i + 1; |
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
|
521 |
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
|
522 return 0; |
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
|
523 } |
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
|
524 |
0 | 525 /* Return the dependence level for the DDR relation. */ |
526 | |
527 static inline unsigned | |
528 ddr_dependence_level (ddr_p ddr) | |
529 { | |
530 unsigned vector; | |
531 unsigned level = 0; | |
532 | |
533 if (DDR_DIST_VECTS (ddr)) | |
534 level = dependence_level (DDR_DIST_VECT (ddr, 0), DDR_NB_LOOPS (ddr)); | |
535 | |
536 for (vector = 1; vector < DDR_NUM_DIST_VECTS (ddr); vector++) | |
537 level = MIN (level, dependence_level (DDR_DIST_VECT (ddr, vector), | |
538 DDR_NB_LOOPS (ddr))); | |
539 return level; | |
540 } | |
541 | |
542 | |
543 | |
544 /* A Reduced Dependence Graph (RDG) vertex representing a statement. */ | |
545 typedef struct rdg_vertex | |
546 { | |
547 /* The statement represented by this vertex. */ | |
548 gimple stmt; | |
549 | |
550 /* True when the statement contains a write to memory. */ | |
551 bool has_mem_write; | |
552 | |
553 /* True when the statement contains a read from memory. */ | |
554 bool has_mem_reads; | |
555 } *rdg_vertex_p; | |
556 | |
557 #define RDGV_STMT(V) ((struct rdg_vertex *) ((V)->data))->stmt | |
558 #define RDGV_HAS_MEM_WRITE(V) ((struct rdg_vertex *) ((V)->data))->has_mem_write | |
559 #define RDGV_HAS_MEM_READS(V) ((struct rdg_vertex *) ((V)->data))->has_mem_reads | |
560 #define RDG_STMT(RDG, I) RDGV_STMT (&(RDG->vertices[I])) | |
561 #define RDG_MEM_WRITE_STMT(RDG, I) RDGV_HAS_MEM_WRITE (&(RDG->vertices[I])) | |
562 #define RDG_MEM_READS_STMT(RDG, I) RDGV_HAS_MEM_READS (&(RDG->vertices[I])) | |
563 | |
564 void dump_rdg_vertex (FILE *, struct graph *, int); | |
565 void debug_rdg_vertex (struct graph *, int); | |
566 void dump_rdg_component (FILE *, struct graph *, int, bitmap); | |
567 void debug_rdg_component (struct graph *, int); | |
568 void dump_rdg (FILE *, struct graph *); | |
569 void debug_rdg (struct graph *); | |
570 int rdg_vertex_for_stmt (struct graph *, gimple); | |
571 | |
572 /* Data dependence type. */ | |
573 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
574 enum rdg_dep_type |
0 | 575 { |
576 /* Read After Write (RAW). */ | |
577 flow_dd = 'f', | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
578 |
0 | 579 /* Write After Read (WAR). */ |
580 anti_dd = 'a', | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
581 |
0 | 582 /* Write After Write (WAW). */ |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
583 output_dd = 'o', |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
584 |
0 | 585 /* Read After Read (RAR). */ |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
586 input_dd = 'i' |
0 | 587 }; |
588 | |
589 /* Dependence information attached to an edge of the RDG. */ | |
590 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
591 typedef struct rdg_edge |
0 | 592 { |
593 /* Type of the dependence. */ | |
594 enum rdg_dep_type type; | |
595 | |
596 /* Levels of the dependence: the depth of the loops that carry the | |
597 dependence. */ | |
598 unsigned level; | |
599 | |
600 /* Dependence relation between data dependences, NULL when one of | |
601 the vertices is a scalar. */ | |
602 ddr_p relation; | |
603 } *rdg_edge_p; | |
604 | |
605 #define RDGE_TYPE(E) ((struct rdg_edge *) ((E)->data))->type | |
606 #define RDGE_LEVEL(E) ((struct rdg_edge *) ((E)->data))->level | |
607 #define RDGE_RELATION(E) ((struct rdg_edge *) ((E)->data))->relation | |
608 | |
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
|
609 struct graph *build_rdg (struct loop *, |
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
|
610 VEC (loop_p, heap) **, |
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
|
611 VEC (ddr_p, heap) **, |
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
|
612 VEC (data_reference_p, heap) **); |
0 | 613 struct graph *build_empty_rdg (int); |
614 void free_rdg (struct graph *); | |
615 | |
616 /* Return the index of the variable VAR in the LOOP_NEST array. */ | |
617 | |
618 static inline int | |
619 index_in_loop_nest (int var, VEC (loop_p, heap) *loop_nest) | |
620 { | |
621 struct loop *loopi; | |
622 int var_index; | |
623 | |
624 for (var_index = 0; VEC_iterate (loop_p, loop_nest, var_index, loopi); | |
625 var_index++) | |
626 if (loopi->num == var) | |
627 break; | |
628 | |
629 return var_index; | |
630 } | |
631 | |
632 void stores_from_loop (struct loop *, VEC (gimple, heap) **); | |
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
|
633 void stores_zero_from_loop (struct loop *, VEC (gimple, heap) **); |
0 | 634 void remove_similar_memory_refs (VEC (gimple, heap) **); |
635 bool rdg_defs_used_in_other_loops_p (struct graph *, int); | |
636 bool have_similar_memory_accesses (gimple, gimple); | |
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
|
637 bool stmt_with_adjacent_zero_store_dr_p (gimple); |
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
|
638 |
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
|
639 /* Returns true when STRIDE is equal in absolute value to the size of |
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
|
640 the unit type of TYPE. */ |
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
|
641 |
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
|
642 static inline bool |
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
|
643 stride_of_unit_type_p (tree stride, tree type) |
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
|
644 { |
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
|
645 return tree_int_cst_equal (fold_unary (ABS_EXPR, TREE_TYPE (stride), |
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
|
646 stride), |
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
|
647 TYPE_SIZE_UNIT (type)); |
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
|
648 } |
0 | 649 |
650 /* Determines whether RDG vertices V1 and V2 access to similar memory | |
651 locations, in which case they have to be in the same partition. */ | |
652 | |
653 static inline bool | |
654 rdg_has_similar_memory_accesses (struct graph *rdg, int v1, int v2) | |
655 { | |
656 return have_similar_memory_accesses (RDG_STMT (rdg, v1), | |
657 RDG_STMT (rdg, v2)); | |
658 } | |
659 | |
660 /* In tree-data-ref.c */ | |
661 void split_constant_offset (tree , tree *, tree *); | |
662 | |
663 /* Strongly connected components of the reduced data dependence graph. */ | |
664 | |
665 typedef struct rdg_component | |
666 { | |
667 int num; | |
668 VEC (int, heap) *vertices; | |
669 } *rdgc; | |
670 | |
671 DEF_VEC_P (rdgc); | |
672 DEF_VEC_ALLOC_P (rdgc, heap); | |
673 | |
674 DEF_VEC_P (bitmap); | |
675 DEF_VEC_ALLOC_P (bitmap, heap); | |
676 | |
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
|
677 /* Compute the greatest common divisor of a VECTOR of SIZE numbers. */ |
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
|
678 |
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
|
679 static inline int |
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
|
680 lambda_vector_gcd (lambda_vector vector, int size) |
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
|
681 { |
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
|
682 int i; |
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
|
683 int gcd1 = 0; |
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
|
684 |
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
|
685 if (size > 0) |
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
|
686 { |
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
|
687 gcd1 = vector[0]; |
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
|
688 for (i = 1; i < size; i++) |
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
|
689 gcd1 = gcd (gcd1, vector[i]); |
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
|
690 } |
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
|
691 return gcd1; |
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
|
692 } |
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
|
693 |
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
|
694 /* Allocate a new vector of given SIZE. */ |
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
|
695 |
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
|
696 static inline lambda_vector |
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
|
697 lambda_vector_new (int size) |
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
|
698 { |
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
|
699 return (lambda_vector) ggc_alloc_cleared_atomic (sizeof (int) * size); |
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
|
700 } |
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
|
701 |
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
|
702 /* Clear out vector VEC1 of length SIZE. */ |
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
|
703 |
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
|
704 static inline void |
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
|
705 lambda_vector_clear (lambda_vector vec1, int size) |
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
|
706 { |
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
|
707 memset (vec1, 0, size * sizeof (*vec1)); |
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
|
708 } |
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
|
709 |
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
|
710 /* Returns true when the vector V is lexicographically positive, in |
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
|
711 other words, when the first nonzero element is positive. */ |
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
|
712 |
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
|
713 static inline bool |
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
|
714 lambda_vector_lexico_pos (lambda_vector v, |
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
|
715 unsigned n) |
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
|
716 { |
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
|
717 unsigned i; |
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
|
718 for (i = 0; i < n; i++) |
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
|
719 { |
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
|
720 if (v[i] == 0) |
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
|
721 continue; |
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
|
722 if (v[i] < 0) |
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
|
723 return false; |
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
|
724 if (v[i] > 0) |
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
|
725 return true; |
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
|
726 } |
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
|
727 return true; |
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
|
728 } |
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
|
729 |
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
|
730 /* Return true if vector VEC1 of length SIZE is the zero vector. */ |
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
|
731 |
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
|
732 static inline bool |
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
|
733 lambda_vector_zerop (lambda_vector vec1, int size) |
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
|
734 { |
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
|
735 int i; |
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
|
736 for (i = 0; i < size; i++) |
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
|
737 if (vec1[i] != 0) |
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
|
738 return false; |
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
|
739 return true; |
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
|
740 } |
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
|
741 |
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
|
742 /* Allocate a matrix of M rows x N cols. */ |
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
|
743 |
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
|
744 static inline lambda_matrix |
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
|
745 lambda_matrix_new (int m, int n, struct obstack *lambda_obstack) |
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
|
746 { |
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
|
747 lambda_matrix mat; |
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
|
748 int i; |
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
|
749 |
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
|
750 mat = (lambda_matrix) obstack_alloc (lambda_obstack, |
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
|
751 sizeof (lambda_vector *) * m); |
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
|
752 |
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
|
753 for (i = 0; i < m; i++) |
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
|
754 mat[i] = lambda_vector_new (n); |
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
|
755 |
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
|
756 return mat; |
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
|
757 } |
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
|
758 |
0 | 759 #endif /* GCC_TREE_DATA_REF_H */ |