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 #ifndef ipl_summary_INCLUDED
00061 #define ipl_summary_INCLUDED
00062
00063 #ifndef language_INCLUDED
00064 #include "language.h"
00065 #endif // language_INCLUDED
00066
00067 #ifndef opcode_INCLUDED
00068 #include "opcode.h"
00069 #endif // opcode_INCLUDED
00070
00071 #if 0 // SC
00072 #ifndef tracing_INCLUDED
00073 #include "tracing.h"
00074 #endif // tracing_INCLUDED
00075 #endif
00076
00077 #ifndef xstats_INCLUDED
00078 #include "xstats.h"
00079 #endif // xstats_INCLUDED
00080
00081 #ifndef cxx_template_INCLUDED
00082 #include "cxx_template.h"
00083 #endif
00084
00085 #if 0 // SC
00086 #ifndef fb_whirl_INCLUDED
00087 #include "fb_whirl.h"
00088 #endif
00089
00090 #include <search.h>
00091 #ifndef mempool_INCLUDED
00092 #include "mempool.h"
00093 #endif
00094 #endif // SC
00095
00096 #define IPA_SUMMARY_REVISION 29//will later to 29:0
00097 #define IPA_SUMMARY_MINOR_REVISION 0
00098
00099
00100
00101 #define TT_IPL_IPA 0x01
00102 #define TT_IPL_MODREF 0x02
00103 #define TT_IPL_VERBOSE 0x04
00104 #define TT_IPL_SECTION 0x08
00105 #define TT_IPL_EXCOST 0x10
00106 #define TT_IPL_SIMPLIFY 0x20
00107 #define TT_IPL_SUMMARY 0x40
00108
00109 struct IPC_GLOBAL_IDX_MAP;
00110
00112
00113
00114
00115
00117
00118
00119
00120 class SUMMARY_FILE_HEADER
00121 {
00122 private:
00123
00124
00125 mINT32 _version_number;
00126 mINT32 _minor_version_number;
00127
00128
00129 Elf64_Word _symbol_offset, _proc_offset, _feedback_offset;
00130 Elf64_Word _callsite_offset, _stmt_offset, _ctrl_dep_offset;
00131 Elf64_Word _formal_offset, _actual_offset;
00132 Elf64_Word _value_offset, _expr_offset, _phi_offset, _chi_offset;
00133 Elf64_Word _global_offset;
00134 Elf64_Word _common_offset, _common_shape_offset;
00135 Elf64_Word _struct_access_offset;
00136 #ifdef KEY
00137 Elf64_Word _ty_info_offset;
00138 #endif
00139
00140
00141 Elf64_Word _scalar_node_offset, _cfg_node_offset, _regions_array_offset;
00142 Elf64_Word _projected_region_offset;
00143 Elf64_Word _projected_array_offset, _term_array_offset;
00144 Elf64_Word _ivar_global_offset, _ivar_offset, _loopinfo_offset;
00145 Elf64_Word _global_stid_offset;
00146
00147
00148 mINT32 _symbol_size, _proc_size, _feedback_size;
00149 mINT32 _callsite_size, _stmt_size, _ctrl_dep_size;
00150 mINT32 _formal_size, _actual_size;
00151 mINT32 _value_size, _expr_size, _phi_size, _chi_size, _global_size;
00152 mINT32 _common_size, _common_shape_size, _global_stid_size;
00153 mINT32 _struct_access_size;
00154 #ifdef KEY
00155 mINT32 _ty_info_size;
00156 #endif
00157
00158
00159 mINT32 _scalar_node_size, _cfg_node_size, _regions_array_size;
00160 mINT32 _projected_region_size;
00161 mINT32 _projected_array_size, _term_array_size;
00162 mINT32 _ivar_global_size, _ivar_size, _loopinfo_size;
00163
00164
00165 mINT32 _symbol_entry_size, _proc_entry_size, _feedback_entry_size;
00166 mINT32 _callsite_entry_size, _stmt_entry_size, _ctrl_dep_entry_size;
00167 mINT32 _formal_entry_size, _actual_entry_size;
00168 mINT32 _value_entry_size, _expr_entry_size, _phi_entry_size;
00169 mINT32 _chi_entry_size, _global_entry_size;
00170 mINT32 _common_entry_size, _common_shape_entry_size, _global_stid_entry_size;
00171 mUINT32 _struct_access_entry_size;
00172 #ifdef KEY
00173 mUINT32 _ty_info_entry_size;
00174 #endif
00175
00176 mINT32 _scalar_node_entry_size, _cfg_node_entry_size;
00177 mINT32 _regions_array_entry_size;
00178 mINT32 _projected_region_entry_size;
00179 mINT32 _projected_array_entry_size, _term_array_entry_size;
00180 mINT32 _ivar_global_entry_size, _ivar_entry_size, _loopinfo_entry_size;
00181
00182 mUINT8 _opt_level;
00183 mBOOL _run_autopar;
00184
00185 public:
00186
00187 SUMMARY_FILE_HEADER() {
00188 bzero(this, sizeof(SUMMARY_FILE_HEADER));
00189 };
00190
00191 void Set_version_number(mINT32 i) { _version_number = i;};
00192 void Set_minor_version_number(mINT32 i) {_minor_version_number = i;};
00193 void Set_symbol_offset(Elf64_Word s) { _symbol_offset = s; };
00194 void Set_proc_offset(Elf64_Word s) { _proc_offset = s;};
00195 void Set_feedback_offset(Elf64_Word s) { _feedback_offset = s;};
00196 void Set_callsite_offset(Elf64_Word s) { _callsite_offset = s;};
00197 void Set_stmt_offset(Elf64_Word s) { _stmt_offset = s;};
00198 void Set_ctrl_dep_offset(Elf64_Word s) { _ctrl_dep_offset = s;};
00199 void Set_formal_offset(Elf64_Word s) { _formal_offset = s;};
00200 void Set_actual_offset(Elf64_Word s) { _actual_offset = s;};
00201 void Set_value_offset(Elf64_Word s) { _value_offset = s;};
00202 void Set_expr_offset(Elf64_Word s) { _expr_offset = s;};
00203 void Set_phi_offset(Elf64_Word s) { _phi_offset = s;};
00204 void Set_chi_offset(Elf64_Word s) { _chi_offset = s;};
00205 void Set_global_offset(Elf64_Word s) { _global_offset = s;};
00206 void Set_common_offset(Elf64_Word s) { _common_offset = s;};
00207 void Set_common_shape_offset(Elf64_Word s) { _common_shape_offset = s;};
00208 void Set_global_stid_offset(Elf64_Word s) { _global_stid_offset = s;};
00209 void Set_struct_access_offset(Elf64_Word s) { _struct_access_offset = s;};
00210 #ifdef KEY
00211 void Set_ty_info_offset(Elf64_Word s) { _ty_info_offset = s;};
00212 #endif
00213
00214
00215 void Set_opt_level(mUINT8 opt_level) { _opt_level = opt_level;};
00216
00217
00218 void Set_scalar_node_offset(Elf64_Word s) { _scalar_node_offset = s;};
00219 void Set_cfg_node_offset(Elf64_Word s) { _cfg_node_offset = s;};
00220 void Set_regions_array_offset(Elf64_Word s){ _regions_array_offset = s;};
00221 void Set_projected_region_offset(Elf64_Word s)
00222 { _projected_region_offset = s ;};
00223 void Set_projected_array_offset(Elf64_Word s)
00224 { _projected_array_offset = s;};
00225 void Set_term_array_offset(Elf64_Word s)
00226 { _term_array_offset = s;};
00227 void Set_ivar_global_offset(Elf64_Word s)
00228 {_ivar_global_offset = s; };
00229 void Set_ivar_offset(Elf64_Word s )
00230 {_ivar_offset = s; };
00231 void Set_loopinfo_offset(Elf64_Word s )
00232 {_loopinfo_offset = s; };
00233
00234 void Set_symbol_size(mINT32 s) { _symbol_size = s; };
00235 void Set_proc_size(mINT32 s) { _proc_size = s;};
00236 void Set_feedback_size(mINT32 s) { _feedback_size = s;};
00237 void Set_callsite_size(mINT32 s) { _callsite_size = s;};
00238 void Set_stmt_size(mINT32 s) { _stmt_size = s;};
00239 void Set_ctrl_dep_size(mINT32 s) { _ctrl_dep_size = s;};
00240 void Set_formal_size(mINT32 s) { _formal_size = s;};
00241 void Set_actual_size(mINT32 s) { _actual_size = s;};
00242 void Set_value_size(mINT32 s) { _value_size = s;};
00243 void Set_expr_size(mINT32 s) { _expr_size = s;};
00244 void Set_phi_size(mINT32 s) { _phi_size = s;};
00245 void Set_chi_size(mINT32 s) { _chi_size = s;};
00246 void Set_global_size(mINT32 s) { _global_size = s;};
00247 void Set_common_size(mINT32 s) { _common_size = s;};
00248 void Set_common_shape_size(mINT32 s) { _common_shape_size =
00249 s;};
00250 void Set_global_stid_size(mINT32 s) { _global_stid_size =
00251 s;};
00252 void Set_struct_access_size(mINT32 s) { _struct_access_size = s;};
00253 #ifdef KEY
00254 void Set_ty_info_size(mINT32 s) { _ty_info_size = s;};
00255 #endif
00256
00257
00258 void Set_scalar_node_size(mINT32 s) { _scalar_node_size = s;};
00259 void Set_cfg_node_size(mINT32 s) { _cfg_node_size = s; };
00260 void Set_regions_array_size(mINT32 s) { _regions_array_size = s;};
00261 void Set_projected_region_size(mINT32 s)
00262 { _projected_region_size = s ;};
00263 void Set_projected_array_size(mINT32 s) { _projected_array_size = s;};
00264 void Set_term_array_size(mINT32 s) { _term_array_size = s;};
00265 void Set_ivar_global_size(mINT32 s) {_ivar_global_size = s;};
00266 void Set_ivar_size(mINT32 s) {_ivar_size = s;};
00267 void Set_loopinfo_size(mINT32 s) {_loopinfo_size = s;};
00268
00269 void Set_symbol_entry_size(mINT32 s) { _symbol_entry_size = s; };
00270
00271 void Set_proc_entry_size(mINT32 s) { _proc_entry_size = s;};
00272 void Set_feedback_entry_size(mINT32 s) { _feedback_entry_size = s;};
00273 void Set_callsite_entry_size(mINT32 s) { _callsite_entry_size = s;};
00274 void Set_stmt_entry_size(mINT32 s) { _stmt_entry_size = s;};
00275 void Set_ctrl_dep_entry_size(mINT32 s) { _ctrl_dep_entry_size = s;};
00276 void Set_formal_entry_size(mINT32 s) { _formal_entry_size = s;};
00277 void Set_actual_entry_size(mINT32 s) { _actual_entry_size = s;};
00278 void Set_value_entry_size(mINT32 s) { _value_entry_size = s;};
00279 void Set_expr_entry_size(mINT32 s) { _expr_entry_size = s;};
00280 void Set_phi_entry_size(mINT32 s) { _phi_entry_size = s;};
00281 void Set_chi_entry_size(mINT32 s) { _chi_entry_size = s;};
00282 void Set_global_entry_size(mINT32 s) { _global_entry_size = s;};
00283 void Set_common_entry_size(mINT32 s) { _common_entry_size = s;};
00284 void Set_common_shape_entry_size(mINT32 s) {
00285 _common_shape_entry_size = s;};
00286 void Set_global_stid_entry_size(mINT32 s) {
00287 _global_stid_entry_size = s;};
00288 void Set_struct_access_entry_size(mINT32 s) {
00289 _struct_access_entry_size = s;};
00290 #ifdef KEY
00291 void Set_ty_info_entry_size(mINT32 s) { _ty_info_entry_size = s;};
00292 #endif
00293
00294 void Set_scalar_node_entry_size(mINT32 s) { _scalar_node_entry_size = s;};
00295 void Set_cfg_node_entry_size(mINT32 s) {_cfg_node_entry_size = s;};
00296 void Set_regions_array_entry_size(mINT32 s)
00297 { _regions_array_entry_size = s;};
00298 void Set_projected_region_entry_size(mINT32 s)
00299 { _projected_region_entry_size = s ;};
00300 void Set_projected_array_entry_size(mINT32 s)
00301 { _projected_array_entry_size = s;};
00302 void Set_term_array_entry_size(mINT32 s)
00303 { _term_array_entry_size = s;};
00304 void Set_ivar_global_entry_size(mINT32 s)
00305 { _ivar_global_entry_size = s;};
00306 void Set_ivar_entry_size(mINT32 s)
00307 { _ivar_entry_size = s; };
00308 void Set_loopinfo_entry_size(mINT32 s)
00309 { _loopinfo_entry_size = s; };
00310
00311 Elf64_Word Get_symbol_offset() const { return _symbol_offset;};
00312 Elf64_Word Get_proc_offset() const { return _proc_offset;};
00313 Elf64_Word Get_feedback_offset() const{ return _feedback_offset;};
00314 Elf64_Word Get_callsite_offset() const{ return _callsite_offset;};
00315 Elf64_Word Get_stmt_offset() const { return _stmt_offset;};
00316 Elf64_Word Get_ctrl_dep_offset() const{ return _ctrl_dep_offset;};
00317 Elf64_Word Get_formal_offset() const { return _formal_offset;};
00318 Elf64_Word Get_actual_offset() const { return _actual_offset;};
00319 Elf64_Word Get_value_offset() const { return _value_offset;};
00320 Elf64_Word Get_expr_offset() const { return _expr_offset;};
00321 Elf64_Word Get_phi_offset() const { return _phi_offset;};
00322 Elf64_Word Get_chi_offset() const { return _chi_offset;};
00323 Elf64_Word Get_global_offset() const { return _global_offset;};
00324 Elf64_Word Get_common_offset() const { return _common_offset;};
00325 Elf64_Word Get_common_shape_offset() const { return _common_shape_offset;};
00326 Elf64_Word Get_global_stid_offset() const { return _global_stid_offset;};
00327 Elf64_Word Get_struct_access_offset() const { return _struct_access_offset;};
00328 #ifdef KEY
00329 Elf64_Word Get_ty_info_offset() const { return _ty_info_offset;};
00330 #endif
00331
00332 mUINT8 Get_opt_level() const { return _opt_level;};
00333
00334
00335 Elf64_Word Get_cfg_node_offset() const { return _cfg_node_offset;};
00336 Elf64_Word Get_regions_array_offset() const
00337 { return _regions_array_offset; };
00338 Elf64_Word Get_projected_region_offset() const
00339 { return _projected_region_offset;};
00340 Elf64_Word Get_projected_array_offset() const
00341 { return _projected_array_offset; };
00342 Elf64_Word Get_term_array_offset() const
00343 { return _term_array_offset;};
00344 Elf64_Word Get_ivar_global_offset() const
00345 { return _ivar_global_offset; };
00346 Elf64_Word Get_ivar_offset() const
00347 { return _ivar_offset; };
00348 Elf64_Word Get_loopinfo_offset() const
00349 { return _loopinfo_offset; };
00350 Elf64_Word Get_scalar_offset() const
00351 { return _scalar_node_offset; };
00352
00353 mINT32 Get_version_number() const { return _version_number;};
00354 mINT32 Get_minor_version_number() const { return _minor_version_number;};
00355 mINT32 Get_symbol_size() const { return _symbol_size;};
00356 mINT32 Get_proc_size() const { return _proc_size;};
00357 mINT32 Get_feedback_size() const { return _feedback_size;};
00358 mINT32 Get_callsite_size() const { return _callsite_size;};
00359 mINT32 Get_stmt_size() const { return _stmt_size;};
00360 mINT32 Get_ctrl_dep_size() const { return _ctrl_dep_size;};
00361 mINT32 Get_formal_size() const { return _formal_size;};
00362 mINT32 Get_actual_size() const { return _actual_size;};
00363 mINT32 Get_value_size() const { return _value_size;};
00364 mINT32 Get_expr_size() const { return _expr_size;};
00365 mINT32 Get_phi_size() const { return _phi_size;};
00366 mINT32 Get_chi_size() const { return _chi_size;};
00367 mINT32 Get_global_size() const { return _global_size;};
00368 mINT32 Get_common_size() const { return _common_size;};
00369 mINT32 Get_common_shape_size() const { return _common_shape_size;};
00370 mINT32 Get_global_stid_size() const { return _global_stid_size;};
00371 mINT32 Get_struct_access_size() const { return _struct_access_size;};
00372 #ifdef KEY
00373 mINT32 Get_ty_info_size() const { return _ty_info_size;};
00374 #endif
00375
00376
00377 mINT32 Get_scalar_node_size() const { return _scalar_node_size; };
00378 mINT32 Get_cfg_node_size() const { return _cfg_node_size; };
00379 mINT32 Get_regions_array_size() const { return _regions_array_size;};
00380 mINT32 Get_projected_region_size() const
00381 { return _projected_region_size;};
00382 mINT32 Get_projected_array_size() const { return _projected_array_size;};
00383 mINT32 Get_term_array_size() const { return _term_array_size;};
00384 mINT32 Get_ivar_global_size() const {return _ivar_global_size;};
00385 mINT32 Get_ivar_size() const { return _ivar_size; };
00386 mINT32 Get_loopinfo_size() const { return _loopinfo_size; };
00387
00388 mINT32 Get_symbol_entry_size() { return _symbol_entry_size;};
00389 mINT32 Get_proc_entry_size() {return _proc_entry_size;};
00390 mINT32 Get_feedback_entry_size() {return _feedback_entry_size;};
00391 mINT32 Get_callsite_entry_size() {return _callsite_entry_size;};
00392 mINT32 Get_stmt_entry_size() {return _stmt_entry_size;};
00393 mINT32 Get_ctrl_dep_entry_size() {return _ctrl_dep_entry_size;};
00394 mINT32 Get_formal_entry_size() {return _formal_entry_size;};
00395 mINT32 Get_actual_entry_size() {return _actual_entry_size;};
00396 mINT32 Get_value_entry_size() {return _value_entry_size;};
00397 mINT32 Get_expr_entry_size() {return _expr_entry_size;};
00398 mINT32 Get_phi_entry_size() {return _phi_entry_size;};
00399 mINT32 Get_chi_entry_size() {return _chi_entry_size;};
00400 mINT32 Get_global_entry_size() { return _global_entry_size;};
00401 mINT32 Get_common_entry_size() { return _common_entry_size;};
00402 mINT32 Get_common_shape_entry_size() { return _common_shape_entry_size;};
00403 mINT32 Get_struct_access_entry_size() { return _struct_access_entry_size;};
00404 #ifdef KEY
00405 mINT32 Get_ty_info_entry_size() { return _ty_info_entry_size;};
00406 #endif
00407
00408 mINT32 Get_scalar_node_entry_size() const {
00409 return _scalar_node_entry_size ;};
00410 mINT32 Get_cfg_node_entry_size() const { return _cfg_node_entry_size ;};
00411 mINT32 Get_regions_array_entry_size() const {
00412 return _regions_array_entry_size;};
00413 mINT32 Get_projected_region_entry_size() const
00414 { return _projected_region_entry_size;};
00415 mINT32 Get_projected_array_entry_size() const {
00416 return _projected_array_entry_size;};
00417 mINT32 Get_term_array_entry_size() const
00418 { return _term_array_entry_size;};
00419 mINT32 Get_ivar_global_entry_size() const
00420 { return _ivar_global_entry_size;};
00421 mINT32 Get_ivar_entry_size() const
00422 { return _ivar_entry_size;};
00423 mINT32 Get_loopinfo_entry_size() const
00424 { return _loopinfo_entry_size;};
00425 mINT32 Get_global_stid_entry_size() const
00426 { return _global_stid_entry_size;};
00427
00428 BOOL Run_AutoPar() const { return _run_autopar; }
00429 void Set_AutoPar() { _run_autopar = TRUE; }
00430
00431 };
00432
00433
00434
00435
00436
00437 class SUMMARY_PROCEDURE
00438 {
00439 private:
00440
00441 mINT32 _symbol_index;
00442 mINT32 _callsite_index;
00443 mINT32 _ctrl_dep_index;
00444 mINT32 _formal_index;
00445 mINT32 _global_index;
00446 mINT32 _common_index;
00447 mINT32 _feedback_index;
00448
00449 mINT32 _array_section_index;
00450 mINT32 _array_section_count;
00451 mINT32 _ex_value_index;
00452 mINT32 _ex_value_count;
00453 mINT32 _ex_expr_index;
00454 mINT32 _ex_expr_count;
00455
00456 mUINT32 _state;
00457
00458 #ifdef KEY // bug 10289
00459 mUINT32 _bb_count;
00460 mUINT32 _stmt_count;
00461 mUINT32 _call_count;
00462 #else
00463 mUINT16 _bb_count;
00464 mUINT16 _stmt_count;
00465 mUINT16 _call_count;
00466 #endif
00467
00468 mUINT16 _alt_entry_count;
00469
00470 #ifdef KEY // bug 10289
00471 mUINT32 _callsite_count;
00472 #else
00473 mUINT16 _callsite_count;
00474 #endif
00475 mUINT16 _ctrl_dep_count;
00476 mUINT16 _formal_count;
00477 mUINT16 _global_count;
00478 mUINT16 _common_count;
00479
00480
00481 #define PROC_MAY_INLINE 0x00000001
00482 #define PROC_MUST_INLINE 0x00000002
00483 #define PROC_NO_INLINE 0x00000004
00484 #define PROC_VARARGS 0x00000008
00485 #define PROC_ALT_ENTRY 0x00000010
00486 #define PROC_HAS_ALT_ENTRY 0x00000020
00487 #define PROC_HAS_PSTATIC 0x00000040
00488 #define PROC_NO_DELETE 0x00000080
00489 #define PROC_BLOCK_DATA 0x00000100
00490 #define PROC_DMOD_DREF 0x00000200
00491 #define PROC_EXC_SCOPE 0x00000400
00492 #define PROC_HAS_UNSTRUCTURED_CPROP 0x00000800
00493 #define PROC_HAS_ADDR_TAKEN_RESET 0x00001000
00494 #define PROC_HAS_PU_FREQ 0x00002000
00495 #define PROC_HAS_FORMAL_PRAGMA 0x00004000
00496 #define PROC_HAS_PARALLEL_PRAGMA 0x00008000
00497 #define PROC_HAS_PARALLEL_REGION_PRAGMA 0x00010000
00498 #define PROC_HAS_FSTATIC 0x00020000
00499 #define PROC_USE_LOWERED_RETURN_PREG 0x00040000 // should be removed by 7.3
00500 #ifdef KEY
00501 #define PROC_HAS_SIDE_EFFECT 0x00080000
00502 #else
00503
00504 #endif
00505 #define PROC_HAS_UNKNOWN_CALLS 0x00100000 // this PU has unknown calls
00506 #define PROC_HAS_INCOMPLETE_ARRAY_INFO 0x00200000
00507 #define PROC_HAS_MP_NEEDS_LNO 0x00400000 // this PU's local symtab has
00508
00509 #define PROC_HAS_EXC_TRY_REGION 0x00800000 // does it have a try region?
00510 #ifdef KEY
00511 #define PROC_HAS_PRAGMA_SIDE_EFFECT 0x01000000 // this PU's contains pragma
00512 #else
00513 #define PROC_HAS_SIDE_EFFECT 0x01000000 // this PU's contains pragma
00514 #endif
00515
00516 #define PROC_HAS_MESSY_REGIONS 0x02000000 // messy PROJECTED_REGIONs
00517 #define PROC_HAS_EARLY_RETURNS 0x04000000 // has RETURN stmts not
00518
00519 #define PROC_HAS_VAR_DIM_ARRAY 0x08000000 // has variable-dimensioned
00520
00521
00522 #define PROC_HAS_NOINLINE_PARALLEL_PRAGMA 0x10000000 // not inline PUs with
00523
00524
00525
00526
00527 #define PROC_HAS_PDO_PRAGMA 0x20000000 // TY_is_non_pod set for
00528
00529 #define PROC_NEVER_INVOKED 0x40000000 // INLINING_TUNING
00530 LANGUAGE _l;
00531
00532 public:
00533
00534
00535
00536 void Set_size (UINT16 bb, UINT16 stmt, UINT16 call) {
00537 _bb_count = bb;
00538 _stmt_count = stmt;
00539 _call_count = call;
00540 }
00541
00542 UINT16 Get_bb_count () const { return _bb_count; }
00543 UINT16 Get_stmt_count () const { return _stmt_count; }
00544 UINT16 Get_call_count () const { return _call_count; }
00545
00546 void Set_altentry_count (mUINT16 a) { _alt_entry_count = a;}
00547 mUINT16 Get_altentry_count () const { return _alt_entry_count;}
00548
00549
00550 void Set_symbol_index (INT32 s) { _symbol_index = s; }
00551 INT32 Get_symbol_index () const { return _symbol_index; }
00552
00553 #ifdef KEY
00554 void Set_bb_count (UINT16 bbs) { _bb_count = bbs; }
00555 void Set_stmt_count (UINT16 stmts) { _stmt_count = stmts; }
00556 void Set_call_count (UINT16 calls) { _call_count = calls; }
00557
00558
00559
00560 void Set_callsite_index (mINT32 c) { _callsite_index = c;}
00561 mINT32 Get_callsite_index () const { return _callsite_index;}
00562
00563 void Set_ctrl_dep_index (mINT32 c) { _ctrl_dep_index = c;}
00564 mINT32 Get_ctrl_dep_index () const { return _ctrl_dep_index;}
00565
00566 void Set_formal_index (mINT32 f) { _formal_index = f;}
00567 mINT32 Get_formal_index () const { return _formal_index;}
00568 #else
00569 void Set_callsite_index (mUINT16 c) { _callsite_index = c;}
00570 mUINT16 Get_callsite_index () const { return _callsite_index;}
00571
00572 void Set_ctrl_dep_index (mUINT16 c) { _ctrl_dep_index = c;}
00573 mUINT16 Get_ctrl_dep_index () const { return _ctrl_dep_index;}
00574
00575 void Set_formal_index (mUINT16 f) { _formal_index = f;}
00576 mUINT16 Get_formal_index () const { return _formal_index;}
00577 #endif
00578
00579 void Set_global_index (INT g) { _global_index = g;}
00580 INT Get_global_index() const { return _global_index;}
00581
00582 void Set_common_index (INT32 i) { _common_index = i;}
00583 INT32 Get_common_index () const { return _common_index; }
00584
00585 void Set_feedback_index (INT32 i) { _feedback_index = i; }
00586 INT32 Get_feedback_index () const { return _feedback_index; }
00587
00588 void Set_array_section_index (INT32 i) { _array_section_index = i;}
00589 INT32 Get_array_section_index () const {return _array_section_index; }
00590
00591 void Set_callsite_count (mUINT16 c) { _callsite_count = c;}
00592 UINT16 Get_callsite_count () const { return _callsite_count;}
00593
00594 void Set_ctrl_dep_count (mUINT16 c) { _ctrl_dep_count = c;}
00595 UINT16 Get_ctrl_dep_count () const { return _ctrl_dep_count;}
00596
00597 void Set_formal_count (mUINT16 cnt) { _formal_count = cnt;}
00598 mUINT16 Get_formal_count () const { return _formal_count;}
00599
00600 void Set_global_count (INT g) { _global_count = g;}
00601 INT Get_global_count () const { return _global_count;}
00602
00603 void Set_common_count (INT32 i) { _common_count = i;}
00604 INT32 Get_common_count () const { return _common_count;}
00605
00606 void Set_array_section_count (INT32 i) { _array_section_count = i;}
00607 INT32 Get_array_section_count () const { return
00608 _array_section_count;}
00609
00610 INT32 Get_ex_value_index() const { return _ex_value_index;}
00611 INT32 Get_ex_expr_index() const { return _ex_expr_index;}
00612 void Set_ex_value_index(INT32 i) { _ex_value_index = i;}
00613 void Set_ex_expr_index(INT32 i) { _ex_expr_index = i;}
00614
00615 INT32 Get_ex_value_count() const { return _ex_value_count;}
00616 INT32 Get_ex_expr_count() const { return _ex_expr_count;}
00617 void Set_ex_value_count(INT32 i) { _ex_value_count = i;}
00618 void Set_ex_expr_count(INT32 i) { _ex_expr_count = i;}
00619
00620 UINT32 Get_state () const { return _state; }
00621
00622 void Set_has_unstructured_cflow() { _state |=
00623 PROC_HAS_UNSTRUCTURED_CPROP; }
00624 BOOL Has_unstructured_cflow() const { return (_state &
00625 PROC_HAS_UNSTRUCTURED_CPROP); }
00626
00627 void Set_may_inline () { _state |= PROC_MAY_INLINE; }
00628 BOOL Is_may_inline () const { return (_state & PROC_MAY_INLINE); }
00629
00630 void Set_must_inline () { _state |= PROC_MUST_INLINE; }
00631 BOOL Is_must_inline () const { return (_state & PROC_MUST_INLINE); }
00632
00633 void Set_no_inline () { _state |= PROC_NO_INLINE;}
00634 BOOL Is_no_inline() const { return (_state & PROC_NO_INLINE);}
00635
00636 void Set_is_varargs() { _state |= PROC_VARARGS;}
00637 BOOL Is_varargs() const { return (_state & PROC_VARARGS);}
00638
00639 void Set_alt_entry() { _state |= PROC_ALT_ENTRY;}
00640 BOOL Is_alt_entry() const { return (_state & PROC_ALT_ENTRY);}
00641
00642 void Set_has_alt_entry() { _state |= PROC_HAS_ALT_ENTRY;}
00643 BOOL Has_alt_entry() const { return (_state & PROC_HAS_ALT_ENTRY);}
00644
00645 void Set_has_pstatic() { _state |= PROC_HAS_PSTATIC;}
00646 void Reset_has_pstatics() { _state &= ~PROC_HAS_PSTATIC; }
00647 BOOL Has_pstatic() const { return (_state & PROC_HAS_PSTATIC);}
00648
00649 void Set_no_delete() { _state |= PROC_NO_DELETE;}
00650 BOOL Is_no_delete() const { return (_state & PROC_NO_DELETE);}
00651
00652 void Set_block_data() { _state |= PROC_BLOCK_DATA;}
00653 BOOL Is_block_data() const { return (_state & PROC_BLOCK_DATA);}
00654
00655 void Set_direct_mod_ref() { _state |= PROC_DMOD_DREF; }
00656 BOOL Is_direct_mod_ref() const { return _state & PROC_DMOD_DREF;}
00657
00658 void Set_exc_inline() { _state |= PROC_EXC_SCOPE;}
00659 BOOL Is_exc_inline() const { return _state & PROC_EXC_SCOPE;}
00660
00661 void Set_has_addr_taken_reset() { _state |= PROC_HAS_ADDR_TAKEN_RESET; }
00662 BOOL Has_addr_taken_reset() const { return (_state & PROC_HAS_ADDR_TAKEN_RESET); }
00663
00664 void Set_has_PU_freq () { _state |= PROC_HAS_PU_FREQ; }
00665 BOOL Has_PU_freq () const { return _state & PROC_HAS_PU_FREQ; }
00666 void Clear_has_PU_freq () { _state &= ~PROC_HAS_PU_FREQ; }
00667
00668
00669
00670 void Set_Never_Invoked () { _state |= PROC_NEVER_INVOKED; }
00671 BOOL Is_Never_Invoked() const { return _state & PROC_NEVER_INVOKED; }
00672 void Clear_Never_Invoked () { _state &= ~PROC_HAS_PU_FREQ; }
00673
00674
00675 void Set_has_formal_pragma() { _state |= PROC_HAS_FORMAL_PRAGMA;}
00676 BOOL Has_formal_pragma() const { return _state & PROC_HAS_FORMAL_PRAGMA;}
00677
00678 void Set_has_parallel_pragma() { _state |= PROC_HAS_PARALLEL_PRAGMA;}
00679 BOOL Has_parallel_pragma() const { return _state & PROC_HAS_PARALLEL_PRAGMA;}
00680
00681 void Set_has_parallel_region_pragma() { _state |= PROC_HAS_PARALLEL_REGION_PRAGMA;}
00682 BOOL Has_parallel_region_pragma() const { return _state & PROC_HAS_PARALLEL_REGION_PRAGMA;}
00683
00684 void Set_has_noinline_parallel_pragma() { _state |= PROC_HAS_NOINLINE_PARALLEL_PRAGMA;}
00685 BOOL Has_noinline_parallel_pragma() const { return _state & PROC_HAS_NOINLINE_PARALLEL_PRAGMA;}
00686
00687 void Set_has_pdo_pragma() { _state |= PROC_HAS_PDO_PRAGMA;}
00688 BOOL Has_pdo_pragma() const { return _state & PROC_HAS_PDO_PRAGMA;}
00689
00690 void Set_has_fstatic () { _state |= PROC_HAS_FSTATIC; }
00691 BOOL Has_fstatic() const { return (_state & PROC_HAS_FSTATIC); }
00692
00693 void Set_use_lowered_return_preg () { _state |=
00694 PROC_USE_LOWERED_RETURN_PREG;
00695 }
00696 BOOL Use_lowered_return_preg () const { return _state & PROC_USE_LOWERED_RETURN_PREG; }
00697
00698 void Set_has_unknown_calls () { _state |= PROC_HAS_UNKNOWN_CALLS; }
00699 BOOL Has_unknown_calls () const { return _state & PROC_HAS_UNKNOWN_CALLS; }
00700
00701 void Set_has_incomplete_array_info ()
00702 { _state |= PROC_HAS_INCOMPLETE_ARRAY_INFO; }
00703 BOOL Has_incomplete_array_info () const
00704 { return _state & PROC_HAS_INCOMPLETE_ARRAY_INFO; }
00705
00706 void Set_has_mp_needs_lno () { _state |= PROC_HAS_MP_NEEDS_LNO; }
00707 BOOL Has_mp_needs_lno () const { return _state & PROC_HAS_MP_NEEDS_LNO; }
00708
00709 void Set_exc_try() { _state |= PROC_HAS_EXC_TRY_REGION;};
00710 BOOL Has_exc_try() const { return _state &
00711 PROC_HAS_EXC_TRY_REGION; };
00712
00713 #ifdef KEY
00714 void Set_has_pragma_side_effect () { _state |= PROC_HAS_PRAGMA_SIDE_EFFECT; }
00715 BOOL Has_pragma_side_effect () const { return _state & PROC_HAS_PRAGMA_SIDE_EFFECT; }
00716 #endif
00717 void Set_has_side_effect () { _state |= PROC_HAS_SIDE_EFFECT; }
00718 BOOL Has_side_effect () const { return _state & PROC_HAS_SIDE_EFFECT; }
00719
00720 void Set_has_messy_regions () { _state |= PROC_HAS_MESSY_REGIONS; }
00721 BOOL Has_messy_regions () const { return _state & PROC_HAS_MESSY_REGIONS; }
00722
00723 void Set_has_early_returns () { _state |= PROC_HAS_EARLY_RETURNS; }
00724 BOOL Has_early_returns() const { return (_state & PROC_HAS_EARLY_RETURNS); }
00725
00726 void Set_has_var_dim_array () { _state |= PROC_HAS_VAR_DIM_ARRAY; }
00727 BOOL Has_var_dim_array() const { return (_state & PROC_HAS_VAR_DIM_ARRAY); }
00728
00729 void Set_lang (LANGUAGE lang) { _l = lang; }
00730 LANGUAGE Get_lang() const { return _l; }
00731
00732
00733
00734
00735 void Init (void) {
00736 bzero (this, sizeof(SUMMARY_PROCEDURE));
00737 _bb_count = MIN (PU_WN_BB_Cnt, UINT16_MAX);
00738 _stmt_count = MIN (PU_WN_Stmt_Cnt, UINT16_MAX);
00739
00740 #if (defined(_STANDALONE_INLINER) || defined(_LIGHTWEIGHT_INLINER))
00741 PU_WN_BB_Cnt = 0;
00742 PU_WN_Stmt_Cnt = 0;
00743 #endif // _STANDALONE_INLINER
00744 }
00745
00746 void Incr_altentry_count () { _alt_entry_count++;}
00747 void Incr_call_count () { _call_count++; }
00748 void Incr_callsite_count () { _callsite_count++; }
00749
00750 void Decr_call_count () { _call_count--; }
00751 void Decr_callsite_count () { _callsite_count--; }
00752
00753
00754 void Print ( FILE *fp, INT32 i ) const;
00755 void Trace ( INT32 i ) const;
00756 void Print_array ( FILE *fp, INT32 size ) const;
00757 void Trace_array ( INT32 size ) const;
00758 void WB_Print(FILE* fp, INT procedure_index, const char* name,
00759 INT fancy_level);
00760
00761 };
00762
00763
00764
00765
00766 class SUMMARY_FEEDBACK
00767 {
00768 private:
00769
00770 FB_FREQ _cycle_count;
00771 FB_FREQ _frequency;
00772 mUINT16 _effective_bb_count;
00773 mUINT16 _effective_stmt_count;
00774 UINT16 _wn_count;
00775 FB_FREQ _cycle_count_2;
00776 #ifdef KEY
00777 UINT64 _func_runtime_addr;
00778
00779 #endif
00780
00781 public:
00782
00783
00784
00785
00786 void Set_wn_count (UINT16 count) { _wn_count = count;}
00787 UINT16 Get_wn_count () const { return _wn_count; }
00788 void Inc_wn_count (UINT16 count){ _wn_count += count;}
00789
00790 void Set_cycle_count_2 (FB_FREQ count) { _cycle_count_2 = count; };
00791 FB_FREQ Get_cycle_count_2 () const { return _cycle_count_2; };
00792 void Inc_cycle_count_2 (FB_FREQ count) { _cycle_count_2 += count; }
00793
00794
00795 void Set_cycle_count (FB_FREQ count) { _cycle_count = count; };
00796 FB_FREQ Get_cycle_count () const { return _cycle_count; };
00797 void Inc_cycle_count (FB_FREQ count) { _cycle_count += count; }
00798
00799 void Set_frequency_count (FB_FREQ freq ) { _frequency = freq; };
00800 FB_FREQ Get_frequency_count () const { return _frequency; };
00801
00802 void Set_effective_bb_count (UINT16 count) { _effective_bb_count = count;}
00803 UINT16 Get_effective_bb_count () const { return _effective_bb_count; }
00804 void Inc_effective_bb_count (UINT16 count){ _effective_bb_count += count;}
00805
00806 void Set_effective_stmt_count (UINT16 count) {
00807 _effective_stmt_count = count;
00808 }
00809 UINT16 Get_effective_stmt_count () const {
00810 return _effective_stmt_count;
00811 }
00812 void Inc_effective_stmt_count (UINT16 count) {
00813 _effective_stmt_count += count;
00814 }
00815
00816 #ifdef KEY
00817 void Set_func_runtime_addr (UINT64 addr) {
00818 _func_runtime_addr = addr;
00819 }
00820 UINT64 Get_func_runtime_addr () const {
00821 return _func_runtime_addr;
00822 }
00823 #endif
00824
00825
00826
00827 void Init () { bzero (this, sizeof(SUMMARY_FEEDBACK)); }
00828
00829
00830 void Print (FILE *f) const;
00831 void Print_array (FILE *f, INT32 size) const;
00832 void WB_Print(FILE* fp, INT feedback_index);
00833
00834 };
00835
00836
00837
00838
00839
00840 class SUMMARY_CALLSITE
00841 {
00842 #define IPL_FUNC_PTR 0x01
00843 #define IPL_INTRINSIC_FUNC 0x02
00844 #define IPL_HAS_CALLSITE_FREQ 0x04
00845
00846
00847 #define IPL_CALL_MUST_INLINE 0x08
00848 #define IPL_CALL_NO_INLINE 0x10
00849
00850 #ifdef KEY
00851 #define IPL_ICALL_TARGET 0x20
00852 #endif
00853
00854 #define IPL_IN_CASE_CLAUSE 0x40
00855 #define IPL_IS_VIRTUAL_CALL 0x80
00856
00857 private:
00858
00859 union {
00860 WN* w;
00861
00862 mINT32 _map_id;
00863
00864 mUINT64 _targ_runtime_addr;
00865
00866 } u1;
00867
00868 union {
00869 mINT32 _symbol_index;
00870 mINT32 _value_index;
00871
00872 } u2;
00873
00874 mINT32 _actual_index;
00875 mUINT16 _par_count;
00876
00877 mUINT16 _state;
00878 FB_FREQ _frequency;
00879 mUINT16 _callsite_id;
00880 mUINT16 _loopnest;
00881 #ifdef KEY
00882 float _probability;
00883 #endif
00884 TYPE_ID _return_type;
00885
00886 TY_IDX _virtual_class;
00887 mUINT32 _vtable_offset;
00888 mUINT64 _vptr_offset;
00889
00890 public:
00891
00892
00893
00894 void Set_wn (WN* w) { u1.w = w;}
00895 WN* Get_wn () const { return u1.w; }
00896
00897 void Set_map_id (mINT32 map_id) { u1._map_id = map_id;}
00898 INT32 Get_map_id () const { return u1._map_id;}
00899
00900 #ifdef KEY
00901 void Set_targ_runtime_addr (mUINT64 addr) { u1._targ_runtime_addr = addr;}
00902 mUINT64 Get_targ_runtime_addr () const { return u1._targ_runtime_addr;}
00903 #endif
00904
00905 void Set_symbol_index (mINT32 s) {
00906 Is_True (!Is_func_ptr (),
00907 ("Symbol index not allowed for indirect callsite"));
00908 u2._symbol_index = s;
00909 }
00910 INT32 Get_symbol_index (void) const {
00911 Is_True (!Is_func_ptr (),
00912 ("Symbol index not allowed for indirect callsite"));
00913 return u2._symbol_index;
00914 }
00915
00916 void Set_value_index (INT32 s) {
00917 Is_True (Is_func_ptr (),
00918 ("Value index for indirect callsite only"));
00919 u2._value_index = s;
00920 }
00921 INT32 Get_value_index (void) const {
00922 Is_True (Is_func_ptr (),
00923 ("Value index for indirect callsite only"));
00924 return u2._value_index;
00925 }
00926
00927 void Set_actual_index (mINT32 a) { _actual_index = a; }
00928 INT Get_actual_index () const { return _actual_index; }
00929
00930 void Set_param_count (mUINT16 par_count) { _par_count = par_count; }
00931 mUINT16 Get_param_count () const { return _par_count;};
00932
00933 void Set_func_ptr () { _state |= IPL_FUNC_PTR; }
00934 BOOL Is_func_ptr () const { return (_state & IPL_FUNC_PTR); }
00935 void Reset_func_ptr () { _state &= ~IPL_FUNC_PTR; }
00936
00937 #ifdef KEY
00938 void Set_icall_target () { _state |= IPL_ICALL_TARGET; }
00939 void Reset_icall_target () { _state &= ~IPL_ICALL_TARGET; }
00940 BOOL Is_icall_target () const { return (_state & IPL_ICALL_TARGET); }
00941
00942 void Set_probability (float p) { _probability = p; }
00943 float Get_probability () const { return _probability; }
00944 #endif
00945
00946 BOOL Is_in_case_clause (void) const { return (_state & IPL_IN_CASE_CLAUSE); }
00947 void Set_in_case_clause (void) { _state |= IPL_IN_CASE_CLAUSE; }
00948
00949 void Set_intrinsic() { _state |= IPL_INTRINSIC_FUNC; }
00950 BOOL Is_intrinsic() const { return _state & IPL_INTRINSIC_FUNC; };
00951 void Set_callsite_freq () { _state |= IPL_HAS_CALLSITE_FREQ;}
00952 BOOL Has_callsite_freq () const { return _state & IPL_HAS_CALLSITE_FREQ; }
00953
00954
00955 void Set_must_inline () { _state |= IPL_CALL_MUST_INLINE; }
00956 BOOL Is_must_inline () const { return _state & IPL_CALL_MUST_INLINE;}
00957
00958
00959 void Set_no_inline () { _state |= IPL_CALL_NO_INLINE;}
00960 BOOL Is_no_inline () const { return _state & IPL_CALL_NO_INLINE;}
00961
00962 void Set_frequency_count (FB_FREQ freq) { _frequency = freq; }
00963 FB_FREQ Get_frequency_count () const { return _frequency; }
00964
00965 void Set_callsite_id (mUINT16 c) { _callsite_id = c; }
00966 mUINT16 Get_callsite_id() const { return _callsite_id; }
00967
00968 void Set_loopnest (UINT16 c) { _loopnest = c; }
00969 mUINT16 Get_loopnest () const { return _loopnest; }
00970
00971 void Set_return_type (TYPE_ID return_type) { _return_type = return_type;}
00972 TYPE_ID Get_return_type () const { return _return_type;}
00973
00974 void Set_virtual_class(TY_IDX func) { _virtual_class = func; }
00975 TY_IDX Get_virtual_class() { return _virtual_class; }
00976
00977 void Set_vtable_offset(UINT32 offset) { _vtable_offset = offset; }
00978 UINT32 Get_vtable_offset() { return _vtable_offset; }
00979
00980 void Set_vptr_offset(UINT64 ofst) { _vptr_offset = ofst; }
00981 UINT64 Get_vptr_offset() { return _vptr_offset; }
00982
00983 void Set_is_virtual_call() { _state |= IPL_IS_VIRTUAL_CALL; }
00984 BOOL Is_virtual_call() { return _state & IPL_IS_VIRTUAL_CALL; }
00985
00986
00987
00988
00989 void Init () {
00990 bzero (this, sizeof(SUMMARY_CALLSITE));
00991 }
00992
00993
00994 void Print ( FILE *fp ) const;
00995 void Trace ( void ) const;
00996 void Print_array ( FILE *fp, INT32 size ) const;
00997 void Trace_array ( INT32 size ) const;
00998 void WB_Print(FILE* fp, INT callsite_index, const char* name, const char* func_name);
00999
01000 };
01001
01002
01003
01004
01005
01006
01007 class SUMMARY_FORMAL
01008 {
01009 private:
01010 mINT32 _symbol_index;
01011
01012
01013 #define IPL_FORMAL_REF_PARM 0x01 // if this is a reference argument
01014 #define IPL_FORMAL_VAR_DIM_ARRAY 0x02 // if this is a variable-dim array
01015 #ifdef KEY
01016 #define IPL_FORMAL_LOOP_INDEX 0x04 // ref_parm used as a loop index,
01017
01018 #endif
01019
01020 mINT16 _flags;
01021
01022 mINT16 _position;
01023 mINT32 _region_index;
01024
01025
01026 mINT32 _machine_type;
01027
01028 TY_IDX _ty;
01029 public:
01030
01031
01032
01033 void Set_symbol_index (INT32 s) { _symbol_index = s; }
01034 mINT32 Get_symbol_index () const { return _symbol_index; }
01035
01036 void Set_region_index(mINT32 region_index) { _region_index = region_index;}
01037 mINT32 Get_region_index() const { return _region_index;}
01038
01039 void Set_is_ref_parm () { _flags |= IPL_FORMAL_REF_PARM; }
01040 BOOL Is_ref_parm () const { return (_flags & IPL_FORMAL_REF_PARM); }
01041
01042 void Set_is_var_dim_array () { _flags |= IPL_FORMAL_VAR_DIM_ARRAY; }
01043 BOOL Is_var_dim_array () const { return (_flags & IPL_FORMAL_VAR_DIM_ARRAY); }
01044
01045 #ifdef KEY
01046 void Set_is_loop_index () { _flags |= IPL_FORMAL_LOOP_INDEX; }
01047 BOOL Is_loop_index () const { return (_flags & IPL_FORMAL_LOOP_INDEX); }
01048 #endif
01049
01050 void Set_position (mINT32 position) { _position = position;}
01051 mINT32 Get_position () const { return _position;};
01052
01053 void Set_machine_type(TYPE_ID machine_type)
01054 { _machine_type = machine_type;}
01055 TYPE_ID Get_machine_type() const {return _machine_type;}
01056
01057 void Set_ty(TY_IDX ty) { _ty = ty;}
01058 TY_IDX Get_ty() const { return _ty;};
01059
01060
01061
01062 void Process(WN*, INT, INT);
01063
01064
01065 void Print ( FILE *fp ) const;
01066 void Trace ( void ) const;
01067 void Print_array ( FILE *fp, INT32 size ) const;
01068 void Trace_array ( INT32 size ) const;
01069 void WB_Print(FILE* fp, INT formal_index, const char* name, const char* func_name);
01070
01071 };
01072
01073
01074
01075
01076
01077 class SUMMARY_STID
01078 {
01079 private:
01080 mINT32 _symbol_index;
01081 mUINT32 _array_subscript;
01082 mINT32 _value_index : 29;
01083 mUINT32 _always_executed : 1;
01084 mUINT32 _array_assignment : 1;
01085 mUINT32 _const_subscript : 1;
01086
01087 public:
01088
01089 void Set_symbol_index (mINT32 idx) { _symbol_index = idx; }
01090 mINT32 Get_symbol_index () const { return _symbol_index; }
01091
01092 void Set_value_index (mINT32 val_idx) { _value_index = val_idx; }
01093 mINT32 Get_value_index () const { return _value_index; }
01094
01095 void Set_array_subscript (mUINT32 idx) { _array_subscript = idx; }
01096 mUINT32 Get_array_subscript () const { return _array_subscript; }
01097
01098 void Set_always_executed () { _always_executed = 1; }
01099 BOOL Is_always_executed () const { return _always_executed; }
01100
01101 void Set_array_assignment () { _array_assignment = 1; }
01102 BOOL Is_array_assignment () const { return _array_assignment; }
01103
01104 void Set_constant_subscript () { _const_subscript = 1; }
01105 BOOL Has_constant_subscript () const { return _const_subscript; }
01106
01107
01108
01109 void Init () {
01110 _symbol_index = -1;
01111 _array_subscript = 0;
01112 _value_index = -1;
01113 _always_executed = 0;
01114 _array_assignment = 0;
01115 _const_subscript = 0;
01116 }
01117
01118
01119 void Print ( FILE* fp, INT32 id ) const;
01120 void Trace ( INT32 id ) const;
01121 void Print_array ( FILE* fp, INT32 size ) const;
01122 void Trace_array ( INT32 size ) const;
01123 void WB_Print(FILE* fp, INT stid_index, const char* name, const char* func_name);
01124
01125 };
01126
01127
01128
01129
01130
01131
01132 typedef enum ipa_pass_type
01133 {
01134 PASS_UNKNOWN = 0,
01135
01136 PASS_LDID = 1,
01137 PASS_LOAD = 2,
01138 PASS_MLOAD = 3,
01139 PASS_LDA = 4,
01140 PASS_ARRAY_SECTION = 5,
01141 #ifdef KEY
01142 PASS_ARRAY = 6,
01143 #endif
01144 } IPA_PASS_TYPE;
01145
01146
01147
01148
01149 class SUMMARY_ACTUAL
01150 {
01151 private:
01152 mINT32 _symbol_index;
01153 mINT32 _value_index : 24;
01154 IPA_PASS_TYPE _pass_type : 8;
01155 mINT32 _index;
01156
01157 TY_IDX _ty;
01158 BOOL _is_value_parm;
01159
01160 public:
01161
01162
01163
01164 void Set_symbol_index (INT32 s) { _symbol_index = s; }
01165 INT32 Get_symbol_index () const { return _symbol_index; }
01166
01167 void Set_value_index (INT32 v) { _value_index = v; }
01168 INT32 Get_value_index () const { return _value_index; }
01169
01170 void Set_pass_type (IPA_PASS_TYPE p) { _pass_type = p; }
01171 IPA_PASS_TYPE Get_pass_type () const { return _pass_type; }
01172
01173 void Set_index(INT32 a) { _index = a;}
01174 INT32 Get_index() const { return _index;}
01175
01176 void Set_ty(TY_IDX ty) { _ty = ty;}
01177 TY_IDX Get_ty() const { return _ty;}
01178
01179 void Set_is_value_parm() { _is_value_parm = TRUE;}
01180 BOOL Is_value_parm() const { return _is_value_parm;}
01181
01182
01183
01184 void Init () {
01185 _symbol_index = -1;
01186 _value_index = -1;
01187 _pass_type = PASS_UNKNOWN;
01188 _index = -1;
01189 _ty = 0;
01190 _is_value_parm = FALSE;
01191 }
01192
01193
01194 const char *Pass_type_name (void) const;
01195
01196 void Print (FILE *f, INT32 position) const;
01197
01198 void Print_array (FILE *f, INT32 size) const;
01199
01200 #if 0 // SC
01201 void Trace (INT32 id) const { Print (TFile, id); }
01202 #else
01203 void Trace (INT32 id, FILE* f=stdout) const { Print (f, id); }
01204 #endif
01205 void WB_Print(FILE* fp, INT actual_index, const char* name, const char* func_name);
01206
01207 };
01208
01209
01210 class SUMMARY_SYMBOL;
01211
01212 enum IPA_CONST_TYPE {
01213
01214 VALUE_UNKNOWN = 0,
01215 VALUE_INT_CONST = 1,
01216 VALUE_TWO_CONSTS = 2,
01217 VALUE_CONST = 3,
01218 VALUE_FORMAL = 4,
01219 VALUE_GLOBAL = 5,
01220 VALUE_SYMBOL = 6,
01221 VALUE_EXPR = 7,
01222 VALUE_PHI = 8,
01223 VALUE_CHI = 9,
01224
01225 VALUE_CALLSITE = 10,
01226
01227 VALUE_NOT_CONST = 11,
01228 };
01229
01230
01231
01232
01233
01234 class SUMMARY_VALUE
01235 {
01236 private:
01237
01238 union {
01239 mINT64 _int_const;
01240
01241 struct {
01242 mINT32 val1;
01243 mINT32 val2;
01244 } _two_values;
01245
01246 struct {
01247 ST_IDX _const_st_idx;
01248 TCON_IDX _tcon_idx;
01249
01250
01251 } _const_st;
01252
01253 mINT32 _formal_index;
01254
01255
01256
01257
01258 struct {
01259 mINT32 _global_index;
01260
01261
01262
01263
01264 ST_IDX _global_st_idx;
01265
01266
01267 } _global;
01268
01269 mINT32 _symbol_index;
01270
01271
01272
01273
01274 mINT32 _expr_index;
01275
01276 mINT32 _phi_index;
01277
01278 mINT32 _chi_index;
01279
01280 mINT32 _callsite_index;
01281
01282 } _const_value;
01283
01284
01285
01286 mTYPE_ID _mtype;
01287 mTYPE_ID _target_mtype;
01288
01289
01290
01291
01292 IPA_CONST_TYPE _const_type : 8;
01293
01294
01295 mBOOL _merged_const_st_idx : 1;
01296
01297
01298
01299 mBOOL _remove_param : 1;
01300
01301
01302
01303
01304
01305
01306 mBOOL _addr_of : 1;
01307
01308
01309
01310
01311
01312 mBOOL _convertible_to_global : 1;
01313
01314
01315 mBOOL _is_trip_count : 1;
01316
01317
01318
01319 mBOOL _is_global_st_idx : 1;
01320
01321
01322
01323
01324 const char *Const_type_name (void) const;
01325
01326 public:
01327
01328
01329
01330 void Set_mtype (TYPE_ID m) { _mtype = m; }
01331 TYPE_ID Get_mtype () const { return _mtype; }
01332
01333 void Set_target_mtype (TYPE_ID m) { _target_mtype = m; }
01334 TYPE_ID Target_mtype () const { return _target_mtype; }
01335
01336 IPA_CONST_TYPE Get_const_type () const { return _const_type; }
01337
01338 void Set_unknown () { _const_type = VALUE_UNKNOWN; }
01339 BOOL Is_unknown () const { return _const_type == VALUE_UNKNOWN; }
01340
01341 void Set_int_const () { _const_type = VALUE_INT_CONST; }
01342 BOOL Is_int_const () const { return _const_type == VALUE_INT_CONST; }
01343
01344 void Set_two_consts () { _const_type = VALUE_TWO_CONSTS; }
01345 BOOL Is_two_consts () const { return _const_type == VALUE_TWO_CONSTS; }
01346
01347 void Set_const_st () { _const_type = VALUE_CONST; }
01348 BOOL Is_const_st () const { return _const_type == VALUE_CONST; }
01349
01350 void Set_formal () { _const_type = VALUE_FORMAL; }
01351 BOOL Is_formal () const { return _const_type == VALUE_FORMAL; }
01352
01353 void Set_global () { _const_type = VALUE_GLOBAL; }
01354 BOOL Is_global () const { return _const_type == VALUE_GLOBAL; }
01355
01356 void Set_symbol () { _const_type = VALUE_SYMBOL; }
01357 BOOL Is_symbol () const { return _const_type == VALUE_SYMBOL; }
01358
01359 void Set_expr () { _const_type = VALUE_EXPR; }
01360 BOOL Is_expr () const { return _const_type == VALUE_EXPR; }
01361
01362 void Set_phi () { _const_type = VALUE_PHI; }
01363 BOOL Is_phi () const { return _const_type == VALUE_PHI; }
01364
01365 void Set_chi () { _const_type = VALUE_CHI; }
01366 BOOL Is_chi () const { return _const_type == VALUE_CHI; }
01367
01368 void Set_not_const () { _const_type = VALUE_NOT_CONST; }
01369 BOOL Is_not_const () const { return _const_type == VALUE_NOT_CONST; }
01370
01371 void Set_callsite () { _const_type = VALUE_CALLSITE; }
01372 BOOL Is_callsite () const { return _const_type == VALUE_CALLSITE; }
01373
01374
01375 BOOL Is_constant () const {
01376 switch (_const_type) {
01377 case VALUE_INT_CONST:
01378 case VALUE_CONST:
01379 return TRUE;
01380 case VALUE_FORMAL:
01381 case VALUE_GLOBAL:
01382 case VALUE_SYMBOL:
01383 if (_addr_of)
01384 return TRUE;
01385 default:
01386 return FALSE;
01387 }
01388 }
01389
01390 void Set_int_const_value (INT64 v) { _const_value._int_const = v; }
01391 INT64 Get_int_const_value () const { return _const_value._int_const; }
01392
01393 void Set_two_values (INT32 val1, INT32 val2) {
01394 _const_value._two_values.val1 = val1;
01395 _const_value._two_values.val2 = val2;
01396 }
01397 INT32 Get_first_of_two_values () const {
01398 return _const_value._two_values.val1;
01399 }
01400 INT32 Get_second_of_two_values () const {
01401 return _const_value._two_values.val2;
01402 }
01403
01404 void Set_const_st_idx (ST_IDX st_idx, TCON_IDX tcon_idx = 0) {
01405 _const_value._const_st._const_st_idx = st_idx;
01406 _const_value._const_st._tcon_idx = tcon_idx;
01407 }
01408 ST_IDX Get_const_st_idx () const {
01409 return _const_value._const_st._const_st_idx;
01410 }
01411
01412 void Set_tcon_idx (TCON_IDX tcon_idx) {
01413 _const_value._const_st._const_st_idx = 0;
01414 _const_value._const_st._tcon_idx = tcon_idx;
01415 }
01416 TCON_IDX Get_tcon_idx () const {
01417 return _const_value._const_st._tcon_idx;
01418 }
01419
01420 void Set_formal_index (INT32 _f) { _const_value._formal_index = _f; }
01421 INT32 Get_formal_index () const { return _const_value._formal_index; }
01422
01423 void Set_global_index (INT32 _g) {
01424 _const_value._global._global_index = _g;
01425 }
01426 INT32 Get_global_index () const {
01427 return _const_value._global._global_index;
01428 }
01429
01430 void Set_global_st_idx (ST_IDX _g) {
01431 _const_value._global._global_st_idx = _g;
01432 }
01433 ST_IDX Get_global_st_idx () const {
01434 return _const_value._global._global_st_idx;
01435 }
01436
01437 void Set_symbol_index (INT32 _g) { _const_value._symbol_index = _g; }
01438 INT32 Get_symbol_index () const { return _const_value._symbol_index; }
01439
01440 void Set_expr_index (INT32 _e) { _const_value._expr_index = _e; }
01441 INT32 Get_expr_index () const { return _const_value._expr_index; }
01442
01443 void Set_phi_index (INT32 _p) { _const_value._phi_index = _p; }
01444 INT32 Get_phi_index () const { return _const_value._phi_index; }
01445
01446 void Set_chi_index (INT32 k) { _const_value._chi_index = k; }
01447 INT32 Get_chi_index () const { return _const_value._chi_index; }
01448
01449 void Set_callsite_index (INT32 k) { _const_value._callsite_index = k; }
01450 INT32 Get_callsite_index () const { return _const_value._callsite_index; }
01451
01452 void Set_merged_const_st_idx () { _merged_const_st_idx = TRUE; }
01453 BOOL Is_merged_const_st_idx () const { return _merged_const_st_idx; }
01454
01455 void Remove_param () { _remove_param = TRUE; }
01456 void Reset_remove_param () { _remove_param = FALSE; }
01457 BOOL Is_remove_param () const { return _remove_param; }
01458
01459 void Set_is_addr_of () { _addr_of = TRUE; }
01460 void Clear_is_addr_of () { _addr_of = FALSE; }
01461 BOOL Is_addr_of () const { return _addr_of; }
01462
01463 void Set_convertible_to_global () { _convertible_to_global = TRUE; }
01464 void Clear_convertible_to_global () { _convertible_to_global = FALSE; }
01465 BOOL Is_convertible_to_global () const { return _convertible_to_global; }
01466
01467 BOOL Is_trip_count() const { return _is_trip_count; }
01468 void Clear_is_trip_count() { _is_trip_count = FALSE; }
01469 void Set_is_trip_count() { _is_trip_count = TRUE; }
01470
01471 BOOL Is_global_st_idx() const { return _is_global_st_idx; }
01472 void Clear_is_global_st_idx() { _is_global_st_idx = FALSE; }
01473 void Set_is_global_st_idx() { _is_global_st_idx = TRUE; }
01474
01475
01476
01477 void Init () { bzero (this, sizeof(SUMMARY_VALUE)); }
01478
01479
01480 void Print_const_value (FILE *f, const SUMMARY_SYMBOL* symbol = NULL) const;
01481
01482 void Print (FILE *, INT32) const;
01483
01484 void Print_array (FILE *, INT32) const;
01485 #if 0 // SC
01486 void Trace (INT32 id) const { Print (TFile, id); }
01487 #else
01488 void Trace (INT32 id, FILE* f=stdout) const { Print (f, id); }
01489 #endif
01490 void WB_Print(FILE* fp, INT value_index);
01491 BOOL Equal(SUMMARY_VALUE* sv);
01492
01493 };
01494
01495
01496
01497 class SUMMARY_PHI
01498 {
01499 private:
01500 enum PHI_VALUE_TYPE {
01501 PHI_UNKNOWN = 0,
01502 PHI_VALUE = 1,
01503 PHI_EXPR = 2,
01504 PHI_PHI = 3,
01505 PHI_CHI = 4,
01506 };
01507
01508 struct {
01509 mINT32 _cd_index : 24;
01510 mBOOL _branch : 8;
01511 mINT32 _node_index : 24;
01512
01513 PHI_VALUE_TYPE _type : 8;
01514
01515 } kids[2];
01516
01517 public:
01518
01519
01520
01521 void Set_value (INT kid) { kids[kid]._type = PHI_VALUE; }
01522 BOOL Is_value (INT kid) const { return kids[kid]._type == PHI_VALUE; }
01523
01524 void Set_expr (INT kid) { kids[kid]._type = PHI_EXPR; }
01525 BOOL Is_expr (INT kid) const { return kids[kid]._type == PHI_EXPR; }
01526
01527 void Set_phi (INT kid) { kids[kid]._type = PHI_PHI; }
01528 BOOL Is_phi (INT kid) const { return kids[kid]._type == PHI_PHI; }
01529
01530 void Set_chi (INT kid) { kids[kid]._type = PHI_CHI; }
01531 BOOL Is_chi (INT kid) const { return kids[kid]._type == PHI_CHI; }
01532
01533 void Set_ctrl_dep_index (INT kid, INT idx) { kids[kid]._cd_index = idx; }
01534 INT Get_ctrl_dep_index (INT kid) const { return kids[kid]._cd_index; }
01535
01536 void Set_branch (INT kid, BOOL br) { kids[kid]._branch = br; }
01537 BOOL Get_branch (INT kid) const { return kids[kid]._branch; }
01538
01539 void Set_node_index (INT kid, INT idx){ kids[kid]._node_index = idx; }
01540 INT Get_node_index (INT kid) const { return kids[kid]._node_index; }
01541
01542
01543
01544 void Init () { bzero (this, sizeof(SUMMARY_PHI)); }
01545
01546
01547
01548 void Print (FILE *f) const;
01549 void Print_array (FILE *f, INT32 size) const;
01550 void WB_Print(FILE* fp, INT phi_index);
01551
01552 };
01553
01554
01555
01556 class SUMMARY_CHI
01557 {
01558 private:
01559 mINT32 _call_index;
01560 mINT32 _symbol_index;
01561
01562
01563 enum CHI_TYPE {
01564 CHI_UNKNOWN = 0,
01565 CHI_VALUE = 1,
01566 CHI_PHI = 2,
01567 CHI_EXPR = 3,
01568 CHI_CHI = 4,
01569 };
01570
01571 mINT32 _node_index : 24;
01572
01573
01574
01575
01576 mINT32 _type : 8;
01577
01578 public:
01579
01580
01581
01582 void Set_call_index (INT idx) { _call_index = idx; }
01583 INT32 Get_call_index () const { return _call_index; }
01584
01585 void Set_symbol_index (INT idx) { _symbol_index = idx; }
01586 INT32 Get_symbol_index () const { return _symbol_index ; }
01587
01588 void Set_chi_value () { _type = CHI_VALUE; }
01589 BOOL Is_chi_value () const { return _type == CHI_VALUE; }
01590
01591 void Set_chi_phi () { _type = CHI_PHI; }
01592 BOOL Is_chi_phi () const { return _type == CHI_PHI; }
01593
01594 void Set_chi_expr () { _type = CHI_EXPR; }
01595 BOOL Is_chi_expr () const { return _type == CHI_EXPR; }
01596
01597 void Set_chi_chi () { _type = CHI_CHI; }
01598 BOOL Is_chi_chi () const { return _type == CHI_CHI; }
01599
01600 void Set_node_index (INT idx) { _node_index = idx; }
01601 INT32 Get_node_index () const { return _node_index; }
01602
01603
01604
01605 void Init () { _call_index = _symbol_index = -1; }
01606
01607 void Print (FILE *f) const;
01608
01609 void Print_array (FILE *f, INT32 size) const;
01610 void WB_Print(FILE* fp, INT chi_index, const char* name, const char* func_name);
01611
01612 };
01613
01614
01615
01616
01617
01618
01619 class SUMMARY_EXPR
01620 {
01621 private:
01622 enum IDX_TYPE {
01623 EXPR_UNKNOWN = 0,
01624 EXPR_VALUE = 1,
01625 EXPR_PHI = 2,
01626 EXPR_EXPR = 3,
01627 EXPR_CHI = 4,
01628 };
01629
01630 union {
01631
01632
01633 struct {
01634 mINT64 _const_value;
01635
01636 mINT32 _node_index : 24;
01637
01638 IDX_TYPE _type : 6;
01639
01640 mINT32 _kid : 2;
01641
01642 } _s1;
01643
01644
01645 struct {
01646 mINT32 _node_index : 24;
01647
01648 IDX_TYPE _type : 8;
01649 } _s2[2];
01650 } _u;
01651
01652 OPCODE _opcode : 20;
01653
01654 mINT32 _pad : 2;
01655
01656 mBOOL _is_trip_count : 1;
01657 mBOOL _has_const_operand : 1;
01658
01659 mTYPE_ID _mtype: 8;
01660
01661 public:
01662
01663
01664
01665 void Set_has_const_operand () { _has_const_operand = TRUE; }
01666 void Clear_has_const_operand () { _has_const_operand = FALSE; }
01667 BOOL Has_const_operand () const { return _has_const_operand; }
01668
01669 BOOL Is_trip_count() const { return _is_trip_count; }
01670 void Clear_is_trip_count() { _is_trip_count = FALSE; }
01671 void Set_is_trip_count() { _is_trip_count = TRUE; }
01672
01673 void Set_kid (INT kid) {
01674 if (_has_const_operand)
01675 _u._s1._kid = kid;
01676 }
01677 INT Get_kid () const {
01678 if (_has_const_operand)
01679 return _u._s1._kid;
01680 else
01681 return -1;
01682 }
01683
01684 void Set_expr_unknown () {
01685 _has_const_operand = TRUE;
01686 _u._s1._type = EXPR_UNKNOWN;
01687 }
01688 BOOL Is_expr_unknown () const {
01689 return (_has_const_operand == TRUE && _u._s1._type == EXPR_UNKNOWN);
01690 }
01691
01692 void Set_expr_value (INT kid) {
01693 if (_has_const_operand) {
01694 _u._s1._type = EXPR_VALUE;
01695 _u._s1._kid = kid;
01696 } else
01697 _u._s2[kid]._type = EXPR_VALUE;
01698 }
01699 BOOL Is_expr_value (INT kid) const {
01700 if (_has_const_operand)
01701 return _u._s1._type == EXPR_VALUE;
01702 else
01703 return _u._s2[kid]._type == EXPR_VALUE;
01704 }
01705
01706 void Set_expr_phi (INT kid) {
01707 if (_has_const_operand) {
01708 _u._s1._type = EXPR_PHI;
01709 _u._s1._kid = kid;
01710 } else
01711 _u._s2[kid]._type = EXPR_PHI;
01712 }
01713 BOOL Is_expr_phi (INT kid) const {
01714 if (_has_const_operand)
01715 return _u._s1._type == EXPR_PHI;
01716 else
01717 return _u._s2[kid]._type == EXPR_PHI;
01718 }
01719
01720 void Set_expr_expr (INT kid) {
01721 if (_has_const_operand) {
01722 _u._s1._type = EXPR_EXPR;
01723 _u._s1._kid = kid;
01724 } else
01725 _u._s2[kid]._type = EXPR_EXPR;
01726 }
01727 BOOL Is_expr_expr (INT kid) const {
01728 if (_has_const_operand)
01729 return _u._s1._type == EXPR_EXPR;
01730 else
01731 return _u._s2[kid]._type == EXPR_EXPR;
01732 }
01733
01734 void Set_expr_chi (INT kid) {
01735 if (_has_const_operand) {
01736 _u._s1._type = EXPR_CHI;
01737 _u._s1._kid = kid;
01738 } else
01739 _u._s2[kid]._type = EXPR_CHI;
01740 }
01741 BOOL Is_expr_chi (INT kid) const {
01742 if (_has_const_operand)
01743 return _u._s1._type == EXPR_CHI;
01744 else
01745 return _u._s2[kid]._type == EXPR_CHI;
01746 }
01747
01748 void Set_const_value (INT64 _v) { _u._s1._const_value = _v; }
01749 INT64 Get_const_value () const { return _u._s1._const_value; }
01750
01751 void Set_node_index (INT kid, INT32 _n) {
01752 if (_has_const_operand)
01753 _u._s1._node_index = _n;
01754 else
01755 _u._s2[kid]._node_index = _n;
01756 }
01757 INT32 Get_node_index (INT kid) const {
01758 if (_has_const_operand)
01759 return _u._s1._node_index;
01760 else
01761 return _u._s2[kid]._node_index;
01762 }
01763
01764 void Set_opcode (OPCODE _op) { _opcode = _op; }
01765 OPCODE Get_opcode () const { return _opcode; }
01766
01767 void Set_mtype (TYPE_ID _t) { _mtype = _t; }
01768 TYPE_ID Get_mtype () const { return _mtype; }
01769
01770
01771
01772 void Init () { bzero (this, sizeof(SUMMARY_EXPR)); }
01773
01774 void Print_node (FILE *f, INT kid = 0) const;
01775
01776 void Print (FILE *f) const;
01777
01778 void Print_array (FILE *f, INT32 size) const;
01779
01780 void Node(FILE* fp, INT kid);
01781 void WB_Print(FILE* fp, INT expr_index);
01782 BOOL Is_Canonical_Constant(DYN_ARRAY<SUMMARY_VALUE>* sv);
01783 INT64 Canonical_Constant_Value(DYN_ARRAY<SUMMARY_VALUE>* sv);
01784 BOOL Equal(SUMMARY_EXPR* sx);
01785 BOOL Equal_Node(INT kid, SUMMARY_EXPR* sx);
01786
01787 };
01788
01789
01790
01791 class SUMMARY_STMT
01792 {
01793 private:
01794
01795 union {
01796 mINT32 _node_index;
01797
01798
01799 WN *_wn;
01800 mINT32 _map_id;
01801 } u1;
01802
01803 enum {
01804 STMT_EXPR = 1,
01805 STMT_VAR = 2,
01806 STMT_CALL = 3,
01807 STMT_CD = 4,
01808 STMT_ARRAY_REF = 6,
01809 STMT_STID = 7,
01810 } _stmt_type : 8;
01811
01812
01813 mUINT8 _ref_count;
01814 mUINT8 _write_count;
01815 mUINT8 _addr_taken_count;
01816
01817 public:
01818
01819
01820
01821 BOOL Is_expr () const { return _stmt_type == STMT_EXPR; }
01822 BOOL Is_var () const { return _stmt_type == STMT_VAR; }
01823 BOOL Is_call () const { return _stmt_type == STMT_CALL; }
01824 BOOL Is_cond () const { return _stmt_type == STMT_CD; }
01825 BOOL Is_array_ref () const { return _stmt_type == STMT_ARRAY_REF; }
01826 BOOL Is_stid() const { return _stmt_type == STMT_STID;};
01827
01828 void Set_expr_index (INT32 idx) {
01829 _stmt_type = STMT_EXPR;
01830 u1._node_index = idx;
01831 }
01832
01833 INT32 Get_expr_index () const {
01834 return !(_stmt_type == STMT_EXPR) ? -1 : u1._node_index;
01835 }
01836
01837 void Set_var_index (INT32 idx) {
01838 _stmt_type = STMT_VAR;
01839 u1._node_index = idx;
01840 }
01841
01842 INT32 Get_var_index () const {
01843 return !(_stmt_type == STMT_VAR) ? -1 : u1._node_index;
01844 }
01845
01846 void Set_call_index (INT32 idx) {
01847 _stmt_type = STMT_CALL;
01848 u1._node_index = idx;
01849 }
01850
01851 INT32 Get_call_index () const {
01852 return !(_stmt_type == STMT_CALL) ? -1 : u1._node_index;
01853 }
01854
01855 void Set_cond_index (INT32 idx) {
01856 _stmt_type = STMT_CD;
01857 u1._node_index = idx;
01858 }
01859
01860 INT32 Get_cond_index () const {
01861 return !(_stmt_type == STMT_CD) ? -1 : u1._node_index;
01862 }
01863
01864 void Set_array_ref_wn (WN *w) {
01865 _stmt_type = STMT_ARRAY_REF;
01866 u1._wn = w;
01867 }
01868 WN *Get_array_ref_wn () const {
01869 return !(_stmt_type == STMT_ARRAY_REF) ? 0 : u1._wn;
01870 }
01871
01872 void Set_array_ref_map_id (mINT32 map_id) {
01873 _stmt_type = STMT_ARRAY_REF;
01874 u1._map_id = map_id;
01875 }
01876 INT32 Get_array_ref_map_id () const {
01877 return !(_stmt_type == STMT_ARRAY_REF) ? 0 : u1._map_id;
01878 }
01879
01880 void Set_stid_index (INT32 idx) {
01881 _stmt_type = STMT_STID;
01882 u1._node_index = idx;
01883 }
01884
01885 INT32 Get_stid_index () const {
01886 return !(_stmt_type == STMT_STID) ? -1 : u1._node_index;
01887 }
01888
01889 void Set_ref_count (UINT8 count) { _ref_count = count; }
01890 UINT8 Get_ref_count () const { return _ref_count; }
01891
01892 void Set_write_count (UINT8 count) { _write_count = count; }
01893 UINT8 Get_write_count () const { return _write_count; }
01894
01895 void Set_addr_taken_count (UINT8 count) { _addr_taken_count = count; }
01896 UINT8 Get_addr_taken_count () const { return _addr_taken_count; }
01897
01898
01899
01900 void Init () { bzero (this, sizeof(SUMMARY_STMT)); }
01901
01902
01903
01904 void Print (FILE *f) const;
01905 void Print_array (FILE *f, INT32 size) const;
01906 void WB_Print(FILE* fp, INT stmt_index, const char* name, const char* func_name);
01907
01908 };
01909
01910
01911 class SUMMARY_CONTROL_DEPENDENCE
01912 {
01913 private:
01914
01915 union {
01916 WN *_w;
01917 mINT32 _map_id;
01918 } u1;
01919
01920 union {
01921 mINT32 _expr_index;
01922 mINT32 _do_loop_index;
01923 } u2;
01924
01925 mINT32 _true_stmt_index;
01926
01927
01928 mINT32 _false_stmt_index : 24;
01929
01930 enum {
01931 CD_IF = 0,
01932 CD_DO_LOOP = 1,
01933 CD_ENTRY = 2,
01934 } _cd_type : 8;
01935
01936 mINT16 _true_count, _false_count;
01937
01938 public:
01939
01940
01941
01942 void Set_wn (WN *w) { u1._w = w; }
01943 WN *Get_wn () const { return u1._w; }
01944
01945 void Set_map_id (mINT32 map_id) { u1._map_id = map_id; }
01946 INT32 Get_map_id () const { return u1._map_id; }
01947
01948 void Set_expr_index (INT32 idx) { u2._expr_index = idx; }
01949 INT32 Get_expr_index () const { return u2._expr_index; }
01950
01951 void Set_do_loop_index (INT32 idx) { u2._do_loop_index = idx; }
01952 INT32 Get_do_loop_index () const { return u2._do_loop_index; }
01953
01954 void Set_true_stmt_index (INT32 idx) { _true_stmt_index = idx; }
01955 INT32 Get_true_stmt_index () const { return _true_stmt_index;}
01956
01957 void Set_false_stmt_index (INT32 idx) { _false_stmt_index = idx; }
01958 INT32 Get_false_stmt_index () const { return _false_stmt_index;}
01959
01960 void Set_if_stmt () { _cd_type = CD_IF; }
01961 BOOL Is_if_stmt () const { return _cd_type == CD_IF; }
01962
01963 void Set_do_loop () { _cd_type = CD_DO_LOOP; }
01964 BOOL Is_do_loop () const { return _cd_type == CD_DO_LOOP; }
01965
01966 void Set_entry () { _cd_type = CD_ENTRY; }
01967 BOOL Is_entry () const { return _cd_type == CD_ENTRY; }
01968
01969 void Set_true_count (INT32 count) { _true_count = count; }
01970 INT32 Get_true_count () const { return _true_count; }
01971
01972 void Set_false_count (INT32 count) { _false_count = count; }
01973 INT32 Get_false_count () const { return _false_count; }
01974
01975
01976
01977 void Init () { bzero (this, sizeof(SUMMARY_CONTROL_DEPENDENCE)); }
01978
01979
01980
01981 void Print (FILE *f) const;
01982 void Print_array (FILE *f, INT32 size) const;
01983 void WB_Print(FILE* fp, INT control_index);
01984
01985 };
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995 class SUMMARY_SYMBOL
01996 {
01997
01998 private:
01999
02000 union {
02001 struct {
02002 mINT32 _findex;
02003 mINT32 _addr_count;
02004 } s;
02005 mINT64 _const_value;
02006
02007 struct {
02008 mINT32 _common_index;
02009 mINT32 _common_shape_index;
02010 } c;
02011 } u1;
02012
02013 union {
02014 mINT32 _cur_addr_count;
02015 ST_IDX _st_idx_func;
02016 } u2;
02017
02018 ST_IDX st_idx;
02019
02020 mUINT32 _type : 8;
02021 mUINT32 _state : 8;
02022 mUINT32 _modref : 16;
02023 mTYPE_ID _btype;
02024
02025 public:
02026
02027 void Set_findex (INT findex) { u1.s._findex = findex;};
02028 mINT32 Get_findex() const { return u1.s._findex;};
02029
02030 void Set_common_index(INT index) { u1.c._common_index = index;};
02031 mINT32 Get_common_index() const { return
02032 u1.c._common_index;};
02033
02034 void Set_common_shape_index(INT index) { u1.c._common_shape_index
02035 = index;};
02036 mINT32 Get_common_shape_index() const { return
02037 u1.c._common_shape_index;};
02038
02039
02040
02041 void Incr_addr_count() { u1.s._addr_count++;};
02042 mINT32 Get_addr_count() const { return u1.s._addr_count;};
02043
02044 void Set_const_value (INT64 value) { u1._const_value = value; };
02045 void Clear_const_value () { u1._const_value = 0; };
02046 INT64 Get_const_value () const { return u1._const_value; };
02047
02048 void Set_st_idx (ST_IDX stid) { st_idx = stid; }
02049 ST_IDX St_idx () const { return st_idx; }
02050
02051
02052 void Reset_cur_addr_passed_count() { u2._cur_addr_count = 0;};
02053 void Incr_cur_addr_passed_count() { u2._cur_addr_count++;};
02054 mINT32 Get_cur_addr_passed_count() const { return u2._cur_addr_count;};
02055
02056 ST_IDX Get_st_idx_func() const { return u2._st_idx_func;};
02057 void Set_st_idx_func(ST_IDX st_idx) { u2._st_idx_func = st_idx;};
02058
02059
02060 #define IPL_LOCAL_SYMBOL 0x01
02061 #define IPL_STATIC_SYMBOL 0x02
02062 #define IPL_FORMAL_SYMBOL 0x04
02063 #define IPL_COMMON_ELT_SYMBOL 0x08
02064 #define IPL_COMMON_BLOCK_SYMBOL 0x10
02065 #define IPL_FUNCTION_SYMBOL 0x20
02066 #define IPL_OPTIONAL_SYMBOL 0x40
02067 #define IPL_ARRAY_SYMBOL 0x80
02068
02069
02070 void Set_local() { _type |= IPL_LOCAL_SYMBOL; }
02071 BOOL Is_local() const { return _type & IPL_LOCAL_SYMBOL; }
02072 BOOL Is_global() const { return (_type & IPL_LOCAL_SYMBOL) == 0; }
02073
02074 void Set_static() { _type |= IPL_STATIC_SYMBOL; }
02075 BOOL Is_static() const { return _type & IPL_STATIC_SYMBOL; }
02076
02077 BOOL Is_formal() const { return _type & IPL_FORMAL_SYMBOL; }
02078 void Set_formal() { _type |= IPL_FORMAL_SYMBOL; }
02079
02080 BOOL Is_common() const { return _type & IPL_COMMON_ELT_SYMBOL; }
02081 void Set_common() { _type |= IPL_COMMON_ELT_SYMBOL;};
02082
02083 BOOL Is_common_block() const { return _type & IPL_COMMON_BLOCK_SYMBOL; }
02084 void Set_common_block() { _type |= IPL_COMMON_BLOCK_SYMBOL;};
02085
02086 BOOL Is_function() const { return _type & IPL_FUNCTION_SYMBOL; }
02087 void Set_function() { _type |= IPL_FUNCTION_SYMBOL; }
02088
02089 BOOL Is_optional() const { return _type & IPL_OPTIONAL_SYMBOL; }
02090 void Set_optional() { _type |= IPL_OPTIONAL_SYMBOL; }
02091
02092 void Set_array() { _type |= IPL_ARRAY_SYMBOL; }
02093 BOOL Is_array() const { return _type & IPL_ARRAY_SYMBOL; }
02094 BOOL Is_scalar() const { return (_type & IPL_ARRAY_SYMBOL) == 0; }
02095
02096
02097 #define IPL_ADDR_SAVED 0x01 // ST_addr_taken_and_saved
02098 #define IPL_ADDR_F90_TARGET 0x02 // ST_is_f90_target
02099 #define IPL_ADDR_PASSED 0x04 // ST_addr_taken_and_passed
02100 #define IPL_ADDR_PASSED_INLINE 0x08 // the address passed for
02101
02102
02103 #define IPL_USED_IN_ARRAY_SECTION 0x10 // symbol used in array section summary
02104 #define IPL_COMMON_IO_NO_PAD 0x20 // common in i/o statement: don't pad
02105 #define IPL_COMMON_READ_NO_CPROP 0x40 // common read in: no common cprop
02106
02107
02108 void Set_addr_saved() { _state |= IPL_ADDR_SAVED; }
02109 BOOL Is_addr_saved() const { return _state & IPL_ADDR_SAVED; }
02110
02111 void Set_addr_f90_target() { _state |= IPL_ADDR_F90_TARGET; }
02112 BOOL Is_addr_f90_target() const { return _state & IPL_ADDR_F90_TARGET; }
02113
02114 void Set_addr_passed() { _state |= IPL_ADDR_PASSED; }
02115 void Reset_addr_passed() { _state &= ~IPL_ADDR_PASSED; }
02116 BOOL Is_addr_passed() const { return _state & IPL_ADDR_PASSED; }
02117
02118 void Set_addr_passed_inliner() { _state |= IPL_ADDR_PASSED_INLINE; }
02119 BOOL Is_addr_passed_inliner() { return _state & IPL_ADDR_PASSED_INLINE; }
02120
02121 void Set_used_in_array_section() { _state |= IPL_USED_IN_ARRAY_SECTION; }
02122 BOOL Used_in_array_section() const { return _state & IPL_USED_IN_ARRAY_SECTION; }
02123
02124 void Set_common_io_no_pad() { _state |= IPL_COMMON_IO_NO_PAD; }
02125 BOOL Common_io_no_pad() const { return _state & IPL_COMMON_IO_NO_PAD; }
02126
02127 void Set_common_read_no_cprop() { _state |= IPL_COMMON_READ_NO_CPROP; }
02128 BOOL Common_read_no_cprop() const { return _state & IPL_COMMON_READ_NO_CPROP; }
02129
02130
02131 #define IPL_IMOD 1 // 0x01 indirect mod, i.e. *p
02132 #define IPL_DMOD 2 // 0x02 direct mod, i.e. p
02133 #define IPL_IREF 4 // 0x04 indirect ref, i.e. *p
02134 #define IPL_DREF 8 // 0x08 direct ref, i.e. p
02135 #define IPL_AREF 16 // 0x10 address ref, i.e. &p
02136 #define IPL_IKILL 32 // 0x20 indirect kill, i.e. *p
02137 #define IPL_DKILL 64 // 0x40 direct kill, i.e. p
02138 #define IPL_CMOD 128 // 0x80 direct assignment of a constant
02139 #define IPL_MODCOUNT 256 // 0x100 mod count is non-zero
02140 #define IPL_PARM 512 // 0x200 passed as a parameter to a
02141
02142 #define IPL_COPY_REF 1024 // 0x400 ref types that will be used by
02143
02144 #define IPL_CDREF_PREG_ONLY 2048 // 0x800 cref or dref only because the LDID
02145
02146
02147
02148 #define IPL_REF 61 // 0x3d any ref, i.e. p, *p, or &p
02149
02150 #define IPL_MODREF_ANY 127 // 0x7f any mod or ref
02151
02152
02153 void Set_imod() { _modref = _modref | IPL_IMOD;};
02154 BOOL Is_imod() const { return _modref & IPL_IMOD;};
02155 void Set_dmod() { _modref = _modref | IPL_DMOD;};
02156 BOOL Is_dmod() const { return _modref & IPL_DMOD;};
02157 void Set_iref() { _modref = _modref | IPL_IREF;};
02158 BOOL Is_iref() const { return _modref & IPL_IREF;};
02159 void Set_aref() { _modref = _modref | IPL_AREF;};
02160 BOOL Is_aref() const { return _modref & IPL_AREF;};
02161 void Set_dref() { _modref = _modref | IPL_DREF;};
02162 BOOL Is_dref() const { return _modref & IPL_DREF;};
02163 void Set_cref() { _modref = _modref | IPL_COPY_REF;};
02164 BOOL Is_cref() const { return _modref & IPL_COPY_REF;};
02165 void Set_cdref_preg_only() { _modref = _modref | IPL_CDREF_PREG_ONLY;}
02166 BOOL Is_cdref_preg_only() const { return _modref & IPL_CDREF_PREG_ONLY;}
02167
02168
02169 void Set_ikill() { _modref = _modref | IPL_IKILL;};
02170 BOOL Is_ikill() const { return _modref & IPL_IKILL;};
02171 void Set_dkill() { _modref = _modref | IPL_DKILL;};
02172 BOOL Is_dkill() const { return _modref & IPL_DKILL;};
02173
02174 void Set_cmod() { _modref |= IPL_CMOD; };
02175 void Clear_cmod() { _modref &= ~IPL_CMOD; };
02176 BOOL Is_cmod() const { return _modref & IPL_CMOD; };
02177
02178 void Set_modcount() { _modref |= IPL_MODCOUNT; };
02179 void Clear_modcount() { _modref &= ~IPL_MODCOUNT; };
02180 BOOL Is_modcount() const { return _modref & IPL_MODCOUNT; };
02181
02182 BOOL Is_parm() const { return _modref & IPL_PARM;};
02183 void Set_parm() { _modref |= IPL_PARM;};
02184
02185
02186 BOOL Is_ref() const { return _modref & IPL_REF;};
02187
02188 BOOL Is_modref() const { return _modref & IPL_MODREF_ANY;};
02189
02190
02191 void Set_btype (mTYPE_ID b) { _btype = b;};
02192 mTYPE_ID Get_btype() const { return _btype;};
02193
02194
02195
02196
02197 void Init () { bzero (this, sizeof(SUMMARY_SYMBOL)); }
02198
02199
02200
02201 const char * Get_Name ( void ) const;
02202 void Print ( FILE *fp , INT id = -1, char* symbol_name = NULL,
02203 char* function_name = NULL) const;
02204 void WB_Print(FILE* fp, INT symbol_index, BOOL is_list, const char* name,
02205 const char* func_name, INT fancy_level);
02206 void Trace ( void ) const;
02207 void Print_array ( FILE *fp, INT32 size,
02208 DYN_ARRAY<char*>* symbol_names = NULL,
02209 DYN_ARRAY<char*>* function_names = NULL) const;
02210 void Trace_array ( INT32 size ) const;
02211
02212 };
02213
02214
02215
02216
02217
02218
02219
02220 class SUMMARY_GLOBAL {
02221
02222 private:
02223
02224 mINT32 _symbol_index;
02225 mINT32 _refcount;
02226 mINT32 _modcount;
02227 mUINT16 _modref;
02228
02229 public:
02230
02231
02232
02233 void Set_symbol_index ( mINT32 s ) { _symbol_index = s; };
02234 INT32 Get_symbol_index () const { return _symbol_index; };
02235
02236 void Inc_refcount () { _refcount++; };
02237 mINT32 Get_refcount () const { return _refcount; };
02238
02239 void Inc_modcount () { _modcount++; };
02240 mINT32 Get_modcount () const { return _modcount; };
02241
02242 void Set_imod () { _modref |= IPL_IMOD;};
02243 BOOL Is_imod() const { return _modref & IPL_IMOD;};
02244
02245 void Set_dmod() { _modref |= IPL_DMOD;};
02246 BOOL Is_dmod() const { return _modref & IPL_DMOD;};
02247
02248 void Set_iref() { _modref |= IPL_IREF;};
02249 BOOL Is_iref() const { return _modref & IPL_IREF;};
02250
02251 void Set_dref() {_modref |= IPL_DREF;};
02252 BOOL Is_dref() const { return _modref & IPL_DREF;};
02253
02254 void Set_aref() { _modref |= IPL_AREF;};
02255 BOOL Is_aref() const { return _modref & IPL_AREF;};
02256
02257
02258 void Set_ikill() { _modref |= IPL_IKILL;};
02259 BOOL Is_ikill() const { return _modref & IPL_IKILL;};
02260
02261 void Set_dkill() { _modref |= IPL_DKILL;}
02262 BOOL Is_dkill() const { return _modref & IPL_DKILL;};
02263
02264
02265 BOOL Is_ref() const { return _modref & IPL_REF;};
02266
02267
02268 BOOL Is_modref() const { return _modref & IPL_MODREF_ANY;};
02269
02270
02271
02272
02273 void Init (void) { bzero (this, sizeof(SUMMARY_GLOBAL));}
02274
02275
02276 void Print ( FILE *fp ) const;
02277 void Trace ( void ) const;
02278 void Print_array ( FILE *fp, INT32 size ) const;
02279 void Trace_array ( INT32 size ) const;
02280 void WB_Print(FILE* fp, INT global_index);
02281
02282 };
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293 class SUMMARY_COMMON
02294 {
02295 private:
02296 mINT32 _symbol_index;
02297 mINT32 _common_shape_index;
02298 mUINT16 _common_shape_count;
02299
02300 mUINT16 _state;
02301 #define IPL_COMMON_BAD_EQUIV 0x1 // equivalences to common blocks
02302 #define IPL_COMMON_IS_INIT 0x2 // common has been initialized
02303 #define IPL_COMMON_BAD_SPLIT_EQUIV 0x4 // equivalences to common for
02304
02305 #define IPL_COMMON_SPLIT 0x8 // during IPA phase set to true if we
02306
02307 #define IPL_COMMON_CONSISTENT 16 // are the commons consistent?
02308 #define IPL_HAS_CONST_ARRAY 32 // has array elements that are
02309
02310 #define IPL_IS_BOTTOM 64 // unknown values may be assigned to it
02311
02312
02313
02314 #define IPL_HAS_UNSTRUCTURED_FLOW_WITH_ASSIGN 128
02315 #define IPL_HAS_IMOD 256 // has been indirectly modified via
02316
02317 #define IPL_HAS_EQUIVALENCES 512 // this common HAS equivalences
02318
02319 public:
02320
02321
02322 void Set_symbol_index ( INT32 s ) { _symbol_index = s; };
02323 INT32 Get_symbol_index () const { return _symbol_index; };
02324
02325 void Set_common_shape_index (mINT32 i) { _common_shape_index = i;};
02326 mINT32 Get_common_shape_index () const { return _common_shape_index;};
02327
02328 void Set_common_shape_count (mINT32 i) { _common_shape_count = i;};
02329 mINT32 Get_common_shape_count() const { return _common_shape_count;};
02330
02331 void Set_has_bad_equiv() { _state |= IPL_COMMON_BAD_EQUIV;};
02332 mBOOL Has_bad_equiv() const { return _state & IPL_COMMON_BAD_EQUIV;};
02333
02334 void Set_is_initialized() { _state |= IPL_COMMON_IS_INIT;};
02335 mBOOL Is_initialized() const {return _state & IPL_COMMON_IS_INIT;};
02336
02337 void Set_has_bad_split_equiv() { _state |= IPL_COMMON_BAD_SPLIT_EQUIV;};
02338 mBOOL Has_bad_split_equiv() const { return _state & IPL_COMMON_BAD_SPLIT_EQUIV;};
02339
02340 void Set_has_array_constants() { _state |= IPL_HAS_CONST_ARRAY;};
02341 mBOOL Has_array_constants () const { return _state &
02342 IPL_HAS_CONST_ARRAY; };
02343
02344 INT16 Is_bottom () const { return _state & IPL_IS_BOTTOM;};
02345 void Set_bottom() { _state |= IPL_IS_BOTTOM;};
02346
02347
02348 void Set_need_split() { _state |= IPL_COMMON_SPLIT;};
02349 mBOOL Need_split() const { return _state & IPL_COMMON_SPLIT;};
02350
02351 void Set_is_consistent() { _state |= IPL_COMMON_CONSISTENT;};
02352 INT16 Is_consistent() const { return _state & IPL_COMMON_CONSISTENT;};
02353
02354 void Set_has_unstructured_cflow()
02355 { _state |= IPL_HAS_UNSTRUCTURED_FLOW_WITH_ASSIGN;};
02356
02357 INT16 Has_unstructured_cflow() const
02358 { return _state & IPL_HAS_UNSTRUCTURED_FLOW_WITH_ASSIGN;};
02359
02360 void Set_imod() { _state |= IPL_HAS_IMOD;};
02361 INT16 Is_imod() const { return _state & IPL_HAS_IMOD;};
02362
02363 void Set_has_equivalences() { _state |= IPL_HAS_EQUIVALENCES;};
02364 INT16 Has_equivalences() const { return _state & IPL_HAS_EQUIVALENCES;};
02365
02366
02367 void Init () { bzero (this, sizeof(SUMMARY_COMMON)); }
02368
02369 void Print_array(FILE *fp, INT32 size) const;
02370 void Trace_array(INT32 size) const ;
02371 void Print(FILE *f, INT32 id) const;
02372 void Trace(INT32) const;
02373 void WB_Print(FILE* fp, INT common_index);
02374
02375 };
02376
02377
02378
02379
02380 class SUMMARY_COMMON_SHAPE
02381 {
02382 private:
02383 union {
02384 mINT64 _offset;
02385 struct {
02386 mINT32 _upper;
02387 mINT32 _lower;
02388 } _bounds;
02389 } _u1;
02390
02391 union {
02392 mINT32 _stride;
02393 mINT32 _value_index;
02394 SUMMARY_VALUE* _value;
02395 } _u2;
02396
02397 mINT32 _symbol_index;
02398 mINT32 _element_size;
02399 mINT16 _dim_count;
02400
02401 #define IPL_IS_KIND_ARRAY 0x01
02402 #define IPL_IS_KIND_SCALAR 0x02
02403 #define IPL_IS_SYMBOLIC_BOUNDS 0x04
02404 #define IPL_HAS_CONST_VALUE 0x08
02405 #define IPL_NOT_CONST_VALUE 0x10
02406
02407 mINT16 _state;
02408
02409 public:
02410
02411 void Set_dim_count(INT32 i ) { _dim_count = i;};
02412 INT32 Get_dim_count() const { return _dim_count;};
02413
02414 INT32 Get_symbol_index() const { return _symbol_index; };
02415 void Set_symbol_index(INT32 i) { _symbol_index = i;};
02416
02417 void Set_upper (INT32 i) { _u1._bounds._upper = i;};
02418 INT32 Get_upper() const { return _u1._bounds._upper;};
02419
02420 void Set_lower(INT32 i) { _u1._bounds._lower = i;};
02421 INT32 Get_lower() const { return _u1._bounds._lower;};
02422
02423 void Set_stride(INT32 i) { _u2._stride = i;};
02424 INT32 Get_stride() const { return _u2._stride;};
02425
02426 void Set_value_index(INT32 i) { _u2._value_index = i;};
02427 INT32 Get_value_index() const { return _u2._value_index;};
02428
02429 void Set_value(SUMMARY_VALUE* val) { _u2._value = val;};
02430 SUMMARY_VALUE *Get_value() const { return _u2._value;};
02431
02432 void Set_all_sizes (INT32 upper, INT32 lower, INT32 stride) {
02433 _u1._bounds._upper = upper;
02434 _u1._bounds._lower = lower;
02435 _u2._stride = stride;
02436 }
02437
02438 void Set_element_size (INT32 i) {_element_size = i;};
02439 INT32 Get_element_size() const { return _element_size;};
02440
02441 INT64 Get_offset() const { return _u1._offset;};
02442 void Set_offset(INT64 ofst) { _u1._offset = ofst; };
02443
02444 void Set_is_kind_array() { _state |= IPL_IS_KIND_ARRAY;};
02445 BOOL Is_kind_array() const { return _state & IPL_IS_KIND_ARRAY;};
02446
02447 void Set_is_kind_scalar() { _state |= IPL_IS_KIND_SCALAR;};
02448 BOOL Is_kind_scalar() const { return _state & IPL_IS_KIND_SCALAR;};
02449
02450 void Set_symbolic() { _state |= IPL_IS_SYMBOLIC_BOUNDS;};
02451 BOOL Is_symbolic_bounds() const { return _state & IPL_IS_SYMBOLIC_BOUNDS;};
02452
02453 void Set_has_const() { _state |= IPL_HAS_CONST_VALUE;};
02454 void Reset_has_const() { _state &= ~IPL_HAS_CONST_VALUE;};
02455 BOOL Is_const() const { return _state & IPL_HAS_CONST_VALUE;};
02456
02457 void Set_not_const() { _state |= IPL_NOT_CONST_VALUE;};
02458 void Reset_not_const() { _state &= ~IPL_NOT_CONST_VALUE; };
02459 BOOL Is_not_const() const { return _state & IPL_NOT_CONST_VALUE;};
02460
02461
02462 void Init () {
02463 bzero(this, sizeof(SUMMARY_COMMON_SHAPE));
02464 Set_symbol_index(-1);
02465 }
02466
02467 BOOL operator == (const SUMMARY_COMMON_SHAPE &c) const {
02468 return ((c.Get_upper() == _u1._bounds._upper) &&
02469 (c.Get_lower() == _u1._bounds._lower) &&
02470 (c.Get_stride() == _u2._stride) &&
02471 (c.Get_element_size() == _element_size) &&
02472 (c.Get_dim_count() == _dim_count));
02473 }
02474
02475 void Print_array(FILE *fp, INT32 size) const;
02476 void Trace_array(INT32 size) const ;
02477 void Print(FILE *f, INT32 id) const;
02478 void Trace(INT32) const;
02479 void WB_Print(FILE* fp, INT common_shape_index);
02480
02481 };
02482
02483
02484
02485
02486 struct STRUCT_ACCESS{
02487
02488
02489
02490 mUINT32 field_id;
02491 mUINT64 count;
02492 };
02493
02494 inline INT Cmp_FLD_COUNT1(const void *p1,const void*p2){
02495 STRUCT_ACCESS* t1,*t2;
02496 t1=(STRUCT_ACCESS*)p1;
02497 t2=(STRUCT_ACCESS*)p2;
02498 if ( t1->count <t2->count )
02499 return 1;
02500 else if ( t1->count >t2->count )
02501 return -1;
02502 else
02503 return 0;
02504 };
02505
02506
02507 class SUMMARY_STRUCT_ACCESS
02508 {
02509 struct Cmp_FLD_COUNT{
02510 bool operator() (const STRUCT_ACCESS &t1,const STRUCT_ACCESS &t2) const{
02511 if ( t1.count <t2.count )
02512 return 1;
02513 else if ( t1.count >t2.count )
02514 return -1;
02515 else
02516 return 0;
02517 };
02518 };
02519 #define max_hot_num 8
02520 private:
02521 MEM_POOL *_mem;
02522 mUINT32 _ty;
02523 mUINT32 _flatten_flds;
02524 union{
02525 STRUCT_ACCESS hot_fld[max_hot_num];
02526 STRUCT_ACCESS* flds;
02527 }_u;
02528 public:
02529
02530
02531
02532 void Set_ty(mUINT32 ty) { _ty = ty; }
02533 mUINT32 Get_ty() const { return _ty;};
02534 mUINT64 Get_hot_fld(mUINT32 hot_num)const {return _u.hot_fld[hot_num].count;}
02535 mUINT32 Get_hot_fld_id(mUINT32 hot_num)const {return _u.hot_fld[hot_num].field_id;}
02536
02537 void Set_flatten_flds(mUINT32 flatten_flds) {_flatten_flds=flatten_flds;}
02538 mUINT32 Get_flatten_flds() const { return _flatten_flds;};
02539 void Inc_fld_count(mUINT32 fld_id, mUINT64 add_count)
02540 #ifdef KEY // bug 5372
02541 {_u.flds[fld_id-1].count+=add_count;};
02542 #else
02543 {_u.flds[fld_id].count+=add_count;};
02544 #endif
02545 #if 0 // SC
02546 char* Get_ty_name (void) const { TY& ty=Ty_tab[_ty];
02547 return Index_To_Str(ty.name_idx); }
02548
02549 void Set_hot_fld (void)
02550 {
02551 mUINT32 flds;
02552 UINT i,num=Get_flatten_flds();
02553 FmtAssert(num>=1,
02554 ("in Set_hot_fld() type fld_num>=1!\n"));
02555
02556 STRUCT_ACCESS *old,*hot;
02557 old=_u.flds;
02558 hot=_u.hot_fld;
02559 for(i=0;i<num;i++)
02560 old[i].field_id=i+1;
02561 qsort( old,num, sizeof(STRUCT_ACCESS), Cmp_FLD_COUNT1);
02562
02563 if(num>max_hot_num)
02564 num=max_hot_num;
02565 for(i=0;i<num;i++)
02566 hot[i]=old[i];
02567 return;
02568 }
02569
02570 void Set_hot_fld_array(INT32 size)
02571 { INT i;
02572 for ( i=0; i<size; ++i )
02573 this[i].Set_hot_fld ();
02574 };
02575 #endif // SC
02576
02577
02578
02579 void Init (mUINT32 ty_index,mUINT32 flatten_flds,MEM_POOL * mem){
02580 bzero(this, sizeof(SUMMARY_STRUCT_ACCESS));
02581 _mem=mem;
02582 Set_ty(ty_index);
02583 Set_flatten_flds(flatten_flds);
02584 _u.flds= (STRUCT_ACCESS*)MEM_POOL_Alloc_P(_mem,
02585 sizeof(STRUCT_ACCESS)*flatten_flds,
02586 TRUE,NULL);
02587 #ifndef KEY
02588 fprintf(stderr,"new summary: type%d, \n",ty_index);
02589 #endif // !KEY
02590 }
02591
02592
02593
02594
02595
02596 void Print ( FILE *fp ,INT32 id) const;
02597 void Trace ( INT32 id ) const;
02598 void Print_array ( FILE *fp, INT32 size ) const;
02599 void Trace_array ( INT32 size ) const;
02600 void WB_Print(FILE* fp, INT fld_access_index);
02601
02602 };
02603
02604 #ifdef KEY
02605 class SUMMARY_TY_INFO
02606 {
02607 private:
02608 TY_IDX _ty;
02609 mUINT32 _flags;
02610
02611 #define IPL_TY_NO_SPLIT 0x00000001
02612
02613 public:
02614
02615 void Set_ty (TY_IDX type) { _ty = type; }
02616 TY_IDX Get_ty (void) const { return _ty; }
02617
02618 void Set_ty_no_split (void) { _flags |= IPL_TY_NO_SPLIT; }
02619 BOOL Is_ty_no_split (void) const { return _flags & IPL_TY_NO_SPLIT; }
02620
02621 void Init (void) { bzero (this, sizeof(SUMMARY_TY_INFO)); }
02622 void Print_array(FILE *fp, INT32 size) const;
02623 void Trace_array(INT32 size) const ;
02624 void Print(FILE *f) const;
02625 void Trace(void) const;
02626 };
02627 #endif
02628
02629 extern SUMMARY_SYMBOL *Ipl_Summary_Symbol;
02630 extern BOOL IPA_Trace_Mod_Ref;
02631 extern char Modref_Buf[];
02632
02633 #endif
02634