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 #include "ipl_reorder.h"
00034 #include "mempool.h"
00035 #include "cxx_memory.h"
00036
00037 MEM_POOL reorder_ipl_pool;
00038 PTR_TO_TY_VECTOR *Ptr_to_ty_vector;
00039 TY_TO_FLDNUM_MAP *local_cands;
00040
00041
00042 void Comput_flatten_flds(mUINT32 ty_index,mUINT32 &field_id)
00043 {
00044 FLD_IDX start_fld_idx=Ty_tab[ty_index].u1.fld;
00045 #ifdef KEY // check for 0-sized structs
00046 if (start_fld_idx == FLD_IDX_ZERO)
00047 return;
00048 #endif
00049 for(;;start_fld_idx++){
00050 TY_IDX cur_idx= Fld_Table[start_fld_idx].type;
00051 field_id++;
00052 if(Ty_Table[cur_idx].kind==KIND_STRUCT){
00053 Comput_flatten_flds( cur_idx>>8,field_id);
00054 }
00055 if(Fld_Table[start_fld_idx].flags & FLD_LAST_FIELD)
00056 break;
00057 }
00058 return;
00059 }
00060
00061 void Preprocess_struct_access(void)
00062 {
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 TY_TAB::iterator iter;
00078 BOOL propagate;
00079 TY_TO_FLDNUM_MAP ::const_iterator iter_cand;
00080 PTR_TO_TY item;
00081 mUINT32 point_to, flatten_flds,struct_index,ty_index;
00082 TY *ty;
00083 MEM_POOL_Initialize(&reorder_ipl_pool,"reorder_ipl_pool",TRUE);
00084 MEM_POOL_Push (&reorder_ipl_pool);
00085
00086 Ptr_to_ty_vector=CXX_NEW(PTR_TO_TY_VECTOR(),&reorder_ipl_pool);
00087 local_cands=CXX_NEW(TY_TO_FLDNUM_MAP(20),&reorder_ipl_pool);
00088
00089 UINT size=Ty_tab.size();
00090 UINT i,j;
00091 for(i=1,j=1,iter=Ty_tab.begin();iter!=Ty_tab.end();iter++,i++)
00092 {
00093 if((*iter).kind==KIND_STRUCT&& ((*iter).size>=cache_block)){
00094 flatten_flds=0;
00095 struct_index=iter.Index();
00096 Comput_flatten_flds(struct_index,flatten_flds);
00097 if(flatten_flds>=min_fld_num_reorder &&
00098 iter->size>cache_block){
00099 #ifdef KEY
00100 local_cands->insert(std::make_pair(struct_index,flatten_flds));
00101 #else
00102 local_cands->insert(make_pair(struct_index,flatten_flds));
00103 #endif // KEY
00104 }
00105 else continue;
00106 }
00107 else if((*iter).kind==KIND_POINTER){
00108
00109
00110
00111 ty_index=iter.Index();
00112 TY_IDX point_to_ty=TY_pointed(*iter)>>8;
00113 iter_cand=local_cands->find(point_to_ty);
00114 if (iter_cand==local_cands->end ())
00115 continue;
00116 #ifdef KEY
00117 local_cands->insert(std::make_pair(ty_index,0));
00118 #else
00119 local_cands->insert(make_pair(ty_index,0));
00120 #endif // KEY
00121 item.ty_index=ty_index;
00122 item.pt_index=point_to_ty;
00123 Ptr_to_ty_vector->push_back(item);
00124 }
00125 }
00126 return;
00127 }
00128