00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214 #ifndef pf_loop_INCLUDED
00215 #define pf_loop_INCLUDED
00216
00217 #include "defs.h"
00218 #include "cxx_memory.h"
00219 #include "cxx_template.h"
00220 #include "wn.h"
00221 #include "lnopt_main.h"
00222 #include "pf_common.h"
00223 #include "pf_cache.h"
00224
00225 class PF_BASE_ARRAY;
00226 class PF_LOOPNODE;
00227
00228
00229 class PF_LOOPNODE;
00230
00231 class PF_SPLIT_VECTOR {
00232 mINT16 _depth;
00233 mINT16 _count;
00234 mINT16 *_vec;
00235 PF_LOOPNODE* _loopnode;
00236
00237
00238
00239
00240
00241
00242
00243 PF_SPLIT_VECTOR (const PF_SPLIT_VECTOR&);
00244 PF_SPLIT_VECTOR* operator= (const PF_SPLIT_VECTOR&);
00245 public:
00246 PF_SPLIT_VECTOR () {
00247 _depth = _count = 0;
00248 _vec = NULL;
00249 _loopnode = NULL;
00250 }
00251 PF_SPLIT_VECTOR (mINT16 depth,
00252 mINT16 count,
00253 mINT16* vec,
00254 PF_LOOPNODE* loopnode) {
00255 _depth = depth;
00256 _count = count;
00257 _vec = vec;
00258 _loopnode = loopnode;
00259 }
00260 void Copy (PF_SPLIT_VECTOR* split_vec) {
00261 _depth = split_vec->_depth;
00262 _count = split_vec->_count;
00263 _vec = split_vec->_vec;
00264 _loopnode = split_vec->_loopnode;
00265 }
00266
00267 BOOL Empty () {
00268 if (_vec == NULL) return TRUE;
00269 for (INT i=0; i<_depth; i++)
00270 if (_vec[i] > 1) return FALSE;
00271 return TRUE;
00272 }
00273 void Update (PF_SPLIT_VECTOR* split_vec) {
00274 if (split_vec == NULL) return;
00275 Is_True (split_vec->_vec,
00276 ("Split_vec: Update - got an empty split_vec\n"));
00277
00278 INT i;
00279 for (i=0; i<split_vec->_depth-1; i++)
00280 if (split_vec->_vec[i] != 0) break;
00281 if (i == (split_vec->_depth-1)) {
00282 Is_True (FALSE, ("split_vec:Update - got an empty vector\n"));
00283 CXX_DELETE (split_vec, PF_mpool);
00284 return;
00285 }
00286
00287
00288 if (Empty()) {
00289 Is_True (FALSE, ("split_vec: update - why am i empty?\n"));
00290 return;
00291 }
00292
00293 if (split_vec->_depth < _depth) {
00294 CXX_DELETE (split_vec, PF_mpool);
00295 return;
00296 }
00297 if ((split_vec->_depth > _depth) ||
00298 (split_vec->_count > _count)) {
00299
00300 Copy (split_vec);
00301 CXX_DELETE (split_vec, PF_mpool);
00302 return;
00303 }
00304 }
00305 PF_LOOPNODE* Get_Loop () const { return _loopnode; }
00306 mINT16 Get_Depth () const { return _depth; }
00307 mINT16 *Get_Vector () const { return _vec; }
00308 void Print (FILE* fp) {
00309 if (Empty())
00310 fprintf (fp, "Split vector is Empty\n");
00311 else {
00312 fprintf (fp, "Split Vector: depth - %d, count - %d, loopnode - 0x%p, Vector - ",
00313 _depth, _count, _loopnode);
00314 for (INT i=0; i<_depth; i++) fprintf (fp, " %3d ", _vec[i]);
00315 fprintf (fp, "\n");
00316 }
00317 }
00318 };
00319
00320
00321 typedef STACK<PF_LOOPNODE*> PF_LOOPNODE_DA;
00322 typedef STACK<PF_BASE_ARRAY*> PF_BASE_ARRAY_DA;
00323
00324 class PF_LOOPNODE {
00325 PF_LOOPNODE *_parent;
00326 PF_LOOPNODE_DA _child;
00327 PF_BASE_ARRAY_DA _bases;
00328 WN *_code;
00329 INT _num_bad;
00330 mINT16 _depth;
00331 mINT16 _volume_confidence;
00332
00333
00334
00335
00336
00337
00338
00339
00340 PF_VOLUME _single_iter;
00341 PF_VOLUME _total_iter;
00342 INT _manual_volume;
00343
00344
00345
00346 PF_LOCLOOP _locloop;
00347 mINT16 _split_num;
00348
00349 PF_SPLIT_VECTOR* _split_vec;
00350
00351 void Add_Ref (WN* wn_array);
00352 void Process_Refs (const WN* wn);
00353 PF_VOLUME Volume_For_Outer (mINT16 depth);
00354 PF_SPLIT_VECTOR* Find_Split_Vector ();
00355
00356 PF_LOOPNODE (void);
00357 PF_LOOPNODE (const PF_LOOPNODE&);
00358 PF_LOOPNODE* operator= (const PF_LOOPNODE&);
00359 public:
00360 PF_LOOPNODE (PF_LOOPNODE *parent, WN *code, mINT16 depth) :
00361 _child(PF_mpool), _bases(PF_mpool) {
00362 _parent = parent;
00363 _code = code;
00364 _num_bad = 0;
00365 _depth = depth;
00366 _volume_confidence = 3;
00367 _manual_volume = 0;
00368 _split_vec = NULL;
00369 _split_num = 0;
00370 }
00371 ~PF_LOOPNODE ();
00372 void Add_Child (PF_LOOPNODE *childnode) {
00373 _child.Push (childnode);
00374 }
00375 INT Num_Children () { return _child.Elements(); }
00376 PF_LOOPNODE *Get_Child (INT i) { return _child.Bottom_nth(i); }
00377 void Process_Loop ();
00378 void Build_Base_LGs ();
00379 PF_VOLUME Volume ();
00380 PF_VOLUME Volume_Within_While (WN* while_wn);
00381 void Find_Loc_Loops (PF_LOCLOOP locloop);
00382 void Process_PU_Volume () {
00383 for (INT i=0; i<_child.Elements(); i++) _child.Bottom_nth(i)->Volume ();
00384 }
00385
00386 DO_LOOP_INFO* Get_LoopInfo () {
00387 DO_LOOP_INFO* dli = (DO_LOOP_INFO *) WN_MAP_Get(LNO_Info_Map, _code);
00388 FmtAssert(dli, ("Get_LoopInfo(): Unmarked do loop\n"));
00389 return dli;
00390 }
00391
00392 void Gen_Prefetch (PF_SPLIT_VECTOR*);
00393 void Process_Prefetch () {
00394 for (INT i=0; i<_child.Elements(); i++)
00395 _child.Bottom_nth(i)->Gen_Prefetch(NULL);
00396 }
00397 void Split_Loops (PF_SPLIT_VECTOR* split_vec);
00398 void Process_Loc_Loops () {
00399 PF_LOCLOOP tmp;
00400 for (INT i=0; i<_child.Elements(); i++) {
00401 _child.Bottom_nth(i)->Find_Loc_Loops (tmp);
00402 }
00403 }
00404 mINT16 Get_Depth () const { return _depth; }
00405 PF_LOOPNODE *Get_Parent () const { return _parent; }
00406 PF_LOCLOOP Get_locloop () const { return _locloop; }
00407 mINT16 Get_Confidence () const { return _volume_confidence; }
00408 PF_VOLUME Get_Total () const { return _total_iter; }
00409 WN *Get_Code () const { return _code; }
00410 void Print (FILE *fp);
00411 void Print_Structure ();
00412 void Print_Volume ();
00413 void Print_Splits ();
00414 };
00415
00416 extern mINT16 Loop_Confidence (DO_LOOP_INFO* dli);
00417 #if defined(TARG_X8664) || defined(TARG_IA64) //introduced by bug 10953
00418 extern WN *Simple_Invariant_Stride_Access(WN *array, WN *loop);
00419 #endif
00420
00421 #endif // pf_loop_INCLUDED