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 #include "id_map.h"
00048
00049 #include "opt_etable.h"
00050 #include "opt_htable.h"
00051 #include "opt_ssa.h"
00052 #include "opt_mu_chi.h"
00053 #include "opt_fold.h"
00054 #include "tracing.h"
00055
00056 #include "opt_config.h"
00057
00058
00059 class E_VER_INFO {
00060 private:
00061 EXP_OCCURS *_avail_def;
00062
00063 #if Is_True_On
00064 UINT32 _occ_count;
00065 BOOL _redefined;
00066 #endif
00067
00068 public:
00069 E_VER_INFO(void)
00070 {
00071 _avail_def = NULL;
00072
00073 #if Is_True_On
00074 _occ_count = 0;
00075 _redefined = FALSE;
00076 #endif
00077 }
00078
00079 ~E_VER_INFO(void) { }
00080
00081 void Set_avail_def(EXP_OCCURS *const avail_def)
00082 { _avail_def = avail_def; }
00083
00084 EXP_OCCURS *Avail_def(void) const { return _avail_def; }
00085
00086 #if Is_True_On
00087 void Set_occ_count(const UINT32 occ_count)
00088 { _occ_count = occ_count; }
00089
00090 UINT32 Inc_occ_count(const UINT32 increment = 1)
00091 { return _occ_count = _occ_count + increment; }
00092
00093 UINT32 Occ_count(void) const { return _occ_count; }
00094
00095 void Set_redefined(void)
00096 { _redefined = TRUE; }
00097
00098 BOOL Redefined(void) const { return _redefined; }
00099 #endif
00100 };
00101
00102
00103 class E_VER_TAB {
00104 private:
00105 const BOOL _tracing;
00106 E_VER_INFO *_e_ver_tab;
00107 MEM_POOL *_pool;
00108
00109 #if Is_True_On
00110 const UINT32 _n_versions;
00111 #endif
00112
00113 public:
00114 E_VER_TAB( MEM_POOL *pool,
00115 const UINT32 n_versions,
00116 const BOOL tracing) :
00117 #if Is_True_On
00118 _n_versions(n_versions),
00119 #endif
00120 _tracing(tracing), _pool(pool)
00121 {
00122 _e_ver_tab = CXX_NEW_ARRAY(E_VER_INFO, n_versions, _pool);
00123 }
00124
00125 ~E_VER_TAB(void) { CXX_DELETE_ARRAY(_e_ver_tab, _pool); }
00126
00127 void Set_avail_def(const IDTYPE e_version,
00128 EXP_OCCURS *const avail_def)
00129 {
00130 Is_True(e_version < _n_versions, ("e_version out of range"));
00131 _e_ver_tab[e_version].Set_avail_def(avail_def);
00132 }
00133
00134 EXP_OCCURS *Avail_def(const IDTYPE e_version)
00135 {
00136 Is_True(e_version < _n_versions, ("e_version out of range"));
00137 return _e_ver_tab[e_version].Avail_def();
00138 }
00139
00140
00141 void Note_version_use(const IDTYPE e_version,
00142 const UINT32 increment = 1)
00143 {
00144 #if Is_True_On
00145 Inc_occ_count(e_version, increment);
00146 #endif
00147 FmtAssert(Avail_def(e_version) != NULL,
00148 ("E_VER_TAB: E-version %d has no available definition",
00149 e_version));
00150 Is_True((Occ_count(e_version) > 1) ||
00151 (Avail_def(e_version)->Occ_kind() ==
00152 EXP_OCCURS::OCC_PHI_OCCUR),
00153 ("E_VER_TAB: E-version %d: inconsistent occurrence count",
00154 e_version));
00155
00156
00157
00158 if (Avail_def(e_version)->Occ_kind() ==
00159 EXP_OCCURS::OCC_REAL_OCCUR) {
00160 Avail_def(e_version)->Set_save_to_temp();
00161 }
00162 }
00163
00164 void Set_real_avail_def(const IDTYPE e_version,
00165 EXP_OCCURS *const avail_def)
00166 {
00167 #if Is_True_On
00168 if (Avail_def(e_version) != NULL) {
00169 Set_redefined(e_version);
00170 }
00171 Set_occ_count(e_version, 1);
00172 #endif
00173 Set_avail_def(e_version, avail_def);
00174 }
00175
00176 BOOL Tracing() const
00177 { return _tracing; }
00178
00179 #if Is_True_On
00180 void Set_occ_count(const IDTYPE e_version,
00181 const UINT32 occ_count)
00182 {
00183 Is_True(e_version < _n_versions, ("e_version out of range"));
00184 _e_ver_tab[e_version].Set_occ_count(occ_count);
00185 }
00186
00187 UINT32 Inc_occ_count(const IDTYPE e_version,
00188 const UINT32 increment = 1)
00189 {
00190 Is_True(e_version < _n_versions, ("e_version out of range"));
00191 return _e_ver_tab[e_version].Inc_occ_count(increment);
00192 }
00193
00194 UINT32 Occ_count(const IDTYPE e_version) const
00195 {
00196 Is_True(e_version < _n_versions, ("e_version out of range"));
00197 return _e_ver_tab[e_version].Occ_count();
00198 }
00199
00200 void Set_redefined(const IDTYPE e_version)
00201 {
00202 _e_ver_tab[e_version].Set_redefined();
00203 }
00204
00205 BOOL Redefined(const IDTYPE e_version) const
00206 {
00207 return _e_ver_tab[e_version].Redefined();
00208 }
00209
00210 UINT32 N_versions(void) const
00211 { return _n_versions; }
00212 #endif
00213 };