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 #ifndef profile_aux_INCLUDED
00060 #define profile_aux_INCLUDED
00061
00062 #include <vector>
00063 #include <ext/hash_map>
00064 #include <fb_tnv.h>
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 struct Invoke_Profile {
00075 INT64 invoke_count;
00076 Invoke_Profile() : invoke_count(0) {}
00077 };
00078
00079
00080
00081
00082
00083
00084
00085 struct Branch_Profile {
00086 INT64 taken;
00087 INT64 not_taken;
00088 Branch_Profile() : taken(0), not_taken(0) {}
00089 };
00090
00091 #ifdef KEY
00092 #define TNV 10
00093
00094
00095
00096
00097
00098 struct Value_Profile {
00099 INT64 num_values;
00100 INT64 exe_counter;
00101 INT64 value[TNV];
00102 INT64 freq[TNV];
00103 Value_Profile() : num_values(0), exe_counter(0) {}
00104 };
00105
00106
00107
00108
00109
00110
00111 struct Value_FP_Bin_Profile {
00112 INT64 exe_counter;
00113 INT64 zopnd0;
00114 INT64 zopnd1;
00115 INT64 uopnd0;
00116 INT64 uopnd1;
00117 Value_FP_Bin_Profile() : exe_counter(0),
00118 zopnd0(0), zopnd1(0), uopnd0(0), uopnd1(0) {}
00119 };
00120 #endif
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 struct Compgoto_Profile {
00133 typedef vector<INT64> value_type;
00134 value_type targets_profile;
00135
00136 value_type& Get_Targets_Profile () {
00137 return targets_profile;
00138 }
00139
00140 INT32 size () const { return targets_profile.size (); }
00141 };
00142
00143
00144
00145
00146
00147 struct Short_Circuit_Profile {
00148 INT64 right_taken_count;
00149 INT64 neither_taken_count;
00150
00151 Short_Circuit_Profile() : right_taken_count(0), neither_taken_count(0) {}
00152 };
00153
00154
00155
00156
00157 struct Call_Profile {
00158 INT64 entry_count;
00159 INT64 exit_count;
00160
00161 Call_Profile() : entry_count(0), exit_count(0) {}
00162 };
00163
00164 struct Icall_Profile {
00165 FB_TNV fb_tnv;
00166 };
00167
00168
00169
00170
00171 struct Loop_Profile {
00172 INT64 invocation_count;
00173 INT64 total_trip_count;
00174 INT64 last_trip_count;
00175 INT64 min_trip_count;
00176 INT64 max_trip_count;
00177 INT64 num_zero_trips;
00178
00179 Loop_Profile () :
00180 invocation_count(0), total_trip_count(0), last_trip_count(0),
00181 min_trip_count(0), max_trip_count(0), num_zero_trips(0) {}
00182 };
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 struct Switch_Profile {
00197 typedef vector<INT64> value_type;
00198 value_type targets_profile;
00199 value_type targets_case_value;
00200 Switch_Profile() {}
00201
00202 value_type& Get_Targets_Profile() {
00203 return targets_profile;
00204 }
00205
00206 value_type& Get_Targets_Case_Value() {
00207 return targets_case_value;
00208 }
00209
00210 INT32 size () const { return targets_profile.size (); }
00211 };
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 typedef vector<Invoke_Profile> Invoke_Profile_Vector;
00225 typedef vector<Branch_Profile> Branch_Profile_Vector;
00226 typedef vector<Switch_Profile> Switch_Profile_Vector;
00227 typedef vector<Compgoto_Profile> Compgoto_Profile_Vector;
00228 typedef vector<Loop_Profile> Loop_Profile_Vector;
00229 typedef vector<Short_Circuit_Profile> Short_Circuit_Profile_Vector;
00230 typedef vector<Call_Profile> Call_Profile_Vector;
00231 typedef vector<Icall_Profile> Icall_Profile_Vector;
00232 #ifdef KEY
00233 typedef vector<Value_Profile> Value_Profile_Vector;
00234 typedef vector<Value_FP_Bin_Profile> Value_FP_Bin_Profile_Vector;
00235 #endif
00236
00237 struct PU_Profile_Handle {
00238 Invoke_Profile_Vector Invoke_Profile_Table;
00239 Branch_Profile_Vector Branch_Profile_Table;
00240 Switch_Profile_Vector Switch_Profile_Table;
00241 Compgoto_Profile_Vector Compgoto_Profile_Table;
00242 Loop_Profile_Vector Loop_Profile_Table;
00243 Short_Circuit_Profile_Vector Short_Circuit_Profile_Table;
00244 Call_Profile_Vector Call_Profile_Table;
00245 Icall_Profile_Vector Icall_Profile_Table;
00246 #ifdef KEY
00247 Value_Profile_Vector Value_Profile_Table;
00248 Value_FP_Bin_Profile_Vector Value_FP_Bin_Profile_Table;
00249 #endif
00250
00251 INT32 checksum;
00252 char *file_name;
00253 char *pu_name;
00254 INT32 pu_size;
00255 UINT64 runtime_fun_address;
00256
00257 PU_Profile_Handle() : checksum(0) {}
00258
00259 PU_Profile_Handle(char *fname, char *pname, long current_pc, INT32 pusize, INT32 c_sum) {
00260 checksum = c_sum;
00261 file_name = new char[strlen(fname) + 1];
00262 pu_name = new char[strlen(pname) + strlen("/") + strlen(fname) + 1];
00263 strcpy(file_name, fname);
00264 strcpy(pu_name, fname);
00265 strcat(pu_name,"/");
00266 strcat(pu_name,pname);
00267 pu_size = pusize;
00268 runtime_fun_address = current_pc;
00269 }
00270
00271 ~PU_Profile_Handle() {
00272 delete [] file_name;
00273 delete [] pu_name;
00274 }
00275
00276 Invoke_Profile_Vector& Get_Invoke_Table () {
00277 return Invoke_Profile_Table;
00278 }
00279
00280 Branch_Profile_Vector& Get_Branch_Table () {
00281 return Branch_Profile_Table;
00282 }
00283
00284 Switch_Profile_Vector& Get_Switch_Table () {
00285 return Switch_Profile_Table;
00286 }
00287
00288 Compgoto_Profile_Vector& Get_Compgoto_Table () {
00289 return Compgoto_Profile_Table;
00290 }
00291
00292 Loop_Profile_Vector& Get_Loop_Table () {
00293 return Loop_Profile_Table;
00294 }
00295
00296 Short_Circuit_Profile_Vector& Get_Short_Circuit_Table () {
00297 return Short_Circuit_Profile_Table;
00298 }
00299
00300 Call_Profile_Vector& Get_Call_Table () {
00301 return Call_Profile_Table;
00302 }
00303
00304 Icall_Profile_Vector& Get_Icall_Table () {
00305 return Icall_Profile_Table;
00306 }
00307
00308 #ifdef KEY
00309 Value_Profile_Vector& Get_Value_Table () {
00310 return Value_Profile_Table;
00311 }
00312
00313 Value_FP_Bin_Profile_Vector& Get_Value_FP_Bin_Table () {
00314 return Value_FP_Bin_Profile_Table;
00315 }
00316 #endif
00317
00318 void Set_file_name(char *s);
00319 void Set_pu_name(char *s);
00320 };
00321
00322 typedef PU_Profile_Handle * PU_PROFILE_HANDLE;
00323
00324
00325
00326
00327 typedef __gnu_cxx::hash_map<long, PU_PROFILE_HANDLE, __gnu_cxx::hash<long> > HASH_MAP;
00328
00329 extern HASH_MAP PU_Profile_Handle_Table;
00330
00331 #endif