00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GCC_TREE_DATA_REF_H
00023 #define GCC_TREE_DATA_REF_H
00024
00025 #include "lambda.h"
00026
00046 struct first_location_in_loop
00047 {
00048 tree base_address;
00049 tree offset;
00050 tree init;
00051 tree step;
00052
00053 VEC(tree,heap) *access_fns;
00054
00055 };
00056
00057 struct base_object_info
00058 {
00059
00060 tree base_object;
00061
00062
00063 VEC(tree,heap) *access_fns;
00064 };
00065
00066 enum data_ref_type {
00067 ARRAY_REF_TYPE,
00068 POINTER_REF_TYPE
00069 };
00070
00071 struct data_reference
00072 {
00073
00074 tree stmt;
00075
00076
00077 tree ref;
00078
00079
00080 int aux;
00081
00082
00083 bool is_read;
00084
00085
00086 struct first_location_in_loop first_location;
00087
00088
00089 struct base_object_info object_info;
00090
00091
00092
00093
00094
00095
00096 tree memtag;
00097 struct ptr_info_def *ptr_info;
00098 subvar_t subvars;
00099
00100
00101
00102 tree misalignment;
00103
00104 tree aligned_to;
00105
00106
00107 enum data_ref_type type;
00108 };
00109
00110 typedef struct data_reference *data_reference_p;
00111 DEF_VEC_P(data_reference_p);
00112 DEF_VEC_ALLOC_P (data_reference_p, heap);
00113
00114 #define DR_STMT(DR) (DR)->stmt
00115 #define DR_REF(DR) (DR)->ref
00116 #define DR_BASE_OBJECT(DR) (DR)->object_info.base_object
00117 #define DR_TYPE(DR) (DR)->type
00118 #define DR_ACCESS_FNS(DR)\
00119 (DR_TYPE(DR) == ARRAY_REF_TYPE ? \
00120 (DR)->object_info.access_fns : (DR)->first_location.access_fns)
00121 #define DR_ACCESS_FN(DR, I) VEC_index (tree, DR_ACCESS_FNS (DR), I)
00122 #define DR_NUM_DIMENSIONS(DR) VEC_length (tree, DR_ACCESS_FNS (DR))
00123 #define DR_IS_READ(DR) (DR)->is_read
00124 #define DR_BASE_ADDRESS(DR) (DR)->first_location.base_address
00125 #define DR_OFFSET(DR) (DR)->first_location.offset
00126 #define DR_INIT(DR) (DR)->first_location.init
00127 #define DR_STEP(DR) (DR)->first_location.step
00128 #define DR_MEMTAG(DR) (DR)->memtag
00129 #define DR_ALIGNED_TO(DR) (DR)->aligned_to
00130 #define DR_OFFSET_MISALIGNMENT(DR) (DR)->misalignment
00131 #define DR_PTR_INFO(DR) (DR)->ptr_info
00132 #define DR_SUBVARS(DR) (DR)->subvars
00133
00134 #define DR_ACCESS_FNS_ADDR(DR) \
00135 (DR_TYPE(DR) == ARRAY_REF_TYPE ? \
00136 &((DR)->object_info.access_fns) : &((DR)->first_location.access_fns))
00137 #define DR_SET_ACCESS_FNS(DR, ACC_FNS) \
00138 { \
00139 if (DR_TYPE(DR) == ARRAY_REF_TYPE) \
00140 (DR)->object_info.access_fns = ACC_FNS; \
00141 else \
00142 (DR)->first_location.access_fns = ACC_FNS; \
00143 }
00144 #define DR_FREE_ACCESS_FNS(DR) \
00145 { \
00146 if (DR_TYPE(DR) == ARRAY_REF_TYPE) \
00147 VEC_free (tree, heap, (DR)->object_info.access_fns); \
00148 else \
00149 VEC_free (tree, heap, (DR)->first_location.access_fns); \
00150 }
00151
00152 enum data_dependence_direction {
00153 dir_positive,
00154 dir_negative,
00155 dir_equal,
00156 dir_positive_or_negative,
00157 dir_positive_or_equal,
00158 dir_negative_or_equal,
00159 dir_star,
00160 dir_independent
00161 };
00162
00163
00164
00165
00166
00167
00168
00169
00170 struct subscript
00171 {
00172
00173
00174 tree conflicting_iterations_in_a;
00175 tree conflicting_iterations_in_b;
00176
00177
00178
00179 tree last_conflict;
00180
00181
00182
00183
00184
00185 tree distance;
00186 };
00187
00188 typedef struct subscript *subscript_p;
00189 DEF_VEC_P(subscript_p);
00190 DEF_VEC_ALLOC_P (subscript_p, heap);
00191
00192 #define SUB_CONFLICTS_IN_A(SUB) SUB->conflicting_iterations_in_a
00193 #define SUB_CONFLICTS_IN_B(SUB) SUB->conflicting_iterations_in_b
00194 #define SUB_LAST_CONFLICT(SUB) SUB->last_conflict
00195 #define SUB_DISTANCE(SUB) SUB->distance
00196
00197 typedef struct loop *loop_p;
00198 DEF_VEC_P(loop_p);
00199 DEF_VEC_ALLOC_P (loop_p, heap);
00200
00201
00202
00203
00204 struct data_dependence_relation
00205 {
00206
00207 struct data_reference *a;
00208 struct data_reference *b;
00209
00210
00211
00212 bool affine_p;
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 tree are_dependent;
00226
00227
00228
00229
00230 VEC (subscript_p, heap) *subscripts;
00231
00232
00233 VEC (loop_p, heap) *loop_nest;
00234
00235
00236 VEC (lambda_vector, heap) *dir_vects;
00237
00238
00239 VEC (lambda_vector, heap) *dist_vects;
00240 };
00241
00242 typedef struct data_dependence_relation *ddr_p;
00243 DEF_VEC_P(ddr_p);
00244 DEF_VEC_ALLOC_P(ddr_p,heap);
00245
00246 #define DDR_A(DDR) DDR->a
00247 #define DDR_B(DDR) DDR->b
00248 #define DDR_AFFINE_P(DDR) DDR->affine_p
00249 #define DDR_ARE_DEPENDENT(DDR) DDR->are_dependent
00250 #define DDR_SUBSCRIPTS(DDR) DDR->subscripts
00251 #define DDR_SUBSCRIPT(DDR, I) VEC_index (subscript_p, DDR_SUBSCRIPTS (DDR), I)
00252 #define DDR_NUM_SUBSCRIPTS(DDR) VEC_length (subscript_p, DDR_SUBSCRIPTS (DDR))
00253
00254 #define DDR_LOOP_NEST(DDR) DDR->loop_nest
00255
00256
00257 #define DDR_NB_LOOPS(DDR) (VEC_length (loop_p, DDR_LOOP_NEST (DDR)))
00258
00259 #define DDR_DIST_VECTS(DDR) ((DDR)->dist_vects)
00260 #define DDR_DIR_VECTS(DDR) ((DDR)->dir_vects)
00261 #define DDR_NUM_DIST_VECTS(DDR) \
00262 (VEC_length (lambda_vector, DDR_DIST_VECTS (DDR)))
00263 #define DDR_NUM_DIR_VECTS(DDR) \
00264 (VEC_length (lambda_vector, DDR_DIR_VECTS (DDR)))
00265 #define DDR_DIR_VECT(DDR, I) \
00266 VEC_index (lambda_vector, DDR_DIR_VECTS (DDR), I)
00267 #define DDR_DIST_VECT(DDR, I) \
00268 VEC_index (lambda_vector, DDR_DIST_VECTS (DDR), I)
00269
00270
00271
00272 extern tree find_data_references_in_loop (struct loop *,
00273 VEC (data_reference_p, heap) **);
00274 extern void compute_data_dependences_for_loop (struct loop *, bool,
00275 VEC (data_reference_p, heap) **,
00276 VEC (ddr_p, heap) **);
00277 extern void print_direction_vector (FILE *, lambda_vector, int);
00278 extern void print_dir_vectors (FILE *, VEC (lambda_vector, heap) *, int);
00279 extern void print_dist_vectors (FILE *, VEC (lambda_vector, heap) *, int);
00280 extern void dump_subscript (FILE *, struct subscript *);
00281 extern void dump_ddrs (FILE *, VEC (ddr_p, heap) *);
00282 extern void dump_dist_dir_vectors (FILE *, VEC (ddr_p, heap) *);
00283 extern void dump_data_reference (FILE *, struct data_reference *);
00284 extern void dump_data_references (FILE *, VEC (data_reference_p, heap) *);
00285 extern void debug_data_dependence_relation (struct data_dependence_relation *);
00286 extern void dump_data_dependence_relation (FILE *,
00287 struct data_dependence_relation *);
00288 extern void dump_data_dependence_relations (FILE *, VEC (ddr_p, heap) *);
00289 extern void dump_data_dependence_direction (FILE *,
00290 enum data_dependence_direction);
00291 extern void free_dependence_relation (struct data_dependence_relation *);
00292 extern void free_dependence_relations (VEC (ddr_p, heap) *);
00293 extern void free_data_refs (VEC (data_reference_p, heap) *);
00294 extern struct data_reference *analyze_array (tree, tree, bool);
00295 extern void estimate_iters_using_array (tree, tree);
00296
00297
00298
00299
00300 static inline int
00301 index_in_loop_nest (int var, VEC (loop_p, heap) *loop_nest)
00302 {
00303 struct loop *loopi;
00304 int var_index;
00305
00306 for (var_index = 0; VEC_iterate (loop_p, loop_nest, var_index, loopi);
00307 var_index++)
00308 if (loopi->num == var)
00309 break;
00310
00311 return var_index;
00312 }
00313
00314
00315 bool lambda_transform_legal_p (lambda_trans_matrix, int, VEC (ddr_p, heap) *);
00316
00317 #endif