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