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 #ifndef opt_bdce_INCLUDED
00048 #define opt_bdce_INCLUDED "opt_bdce.h"
00049
00050 #ifdef _KEEP_RCS_ID
00051 static char *opt_bdcercs_id = opt_bdce_INCLUDED"$Revision$";
00052 #endif
00053
00054
00055 class BITWISE_DCE {
00056 private:
00057 OPT_STAB *_opt_stab;
00058 CFG *_cfg;
00059 CODEMAP *_htable;
00060 MEM_POOL *_loc_pool;
00061 BOOL _copy_propagate;
00062
00063 BOOL _tracing;
00064 UINT64 *_livebits;
00065
00066 UINT _livebits_size;
00067 UINT8 *_usecnt;
00068
00069 BB_NODE_SET *_cd_bbs;
00070
00071 BB_NODE_SET *_live_bbs;
00072
00073
00074 OPT_STAB *Opt_stab(void)const { return _opt_stab; }
00075 CFG *Cfg(void) const { return _cfg; }
00076 CODEMAP *Htable(void) const { return _htable; }
00077 MEM_POOL *Loc_pool(void)const { return _loc_pool; }
00078 BOOL Tracing(void) const { return _tracing; }
00079 UINT64 Livebits(CODEREP *cr) const {
00080 if (cr->Coderep_id() >= _livebits_size)
00081 return UINT64_MAX;
00082 return _livebits[cr->Coderep_id()]; }
00083
00084 BOOL More_bits_live(CODEREP *cr, UINT64 live_bits) const
00085 { return (live_bits & ~_livebits[cr->Coderep_id()]) != 0; }
00086 void Union_livebits(CODEREP *cr, UINT64 live_bits)
00087 { _livebits[cr->Coderep_id()] |= live_bits; }
00088 UINT8 Usecnt(CODEREP *cr) const {
00089 Is_True(cr->Coderep_id() < _livebits_size,
00090 ("BITWISE_DCE::Usecnt: index out of range"));
00091 return _usecnt[cr->Coderep_id()]; }
00092
00093 void IncUsecnt(CODEREP *cr) const
00094 { if (_usecnt[cr->Coderep_id()] < 2)
00095 _usecnt[cr->Coderep_id()]++; }
00096 BB_NODE_SET *Cd_bbs(void) const { return _cd_bbs; }
00097 BB_NODE_SET *Live_bbs(void) const { return _live_bbs; }
00098
00099 BITWISE_DCE(void);
00100 BITWISE_DCE(const BITWISE_DCE&);
00101 BITWISE_DCE& operator = (const BITWISE_DCE&);
00102
00103 void Initialize_stmts_dead(void);
00104 BOOL Operators_without_dependency(OPERATOR opr);
00105 UINT64 Bitmask_of_size(UINT64);
00106 UINT64 Fill_lower_bits(UINT64);
00107 UINT64 Bits_in_type(MTYPE);
00108 UINT64 Bits_in_coderep_result(CODEREP *);
00109 UINT64 Bits_in_var(CODEREP *);
00110 void Mark_stmt_live(STMTREP *);
00111 void Mark_entire_var_live(CODEREP *, BOOL);
00112 void Mark_var_bits_live(CODEREP *, UINT64, BOOL);
00113 void Mark_tree_bits_live(CODEREP *, UINT64, BOOL);
00114 void Find_and_mark_cd_branch_live(BB_NODE *);
00115 void Make_bb_live(BB_NODE *);
00116 void Find_and_mark_return_live(BB_NODE *);
00117 BOOL Redundant_cvtl(BOOL, INT32, INT32, CODEREP *);
00118 void Mark_willnotexit_stmts_live(BB_NODE *);
00119 CODEREP *Copy_propagate(CODEREP *, STMTREP *);
00120 CODEREP *Delete_cvtls(CODEREP *, STMTREP *);
00121 void Delete_dead_nodes(void);
00122 void Print_nodes_with_dead_bits(FILE *);
00123 void Print_node_usecnts(FILE *);
00124 void Print_livebits(INT32);
00125 #if defined(TARG_SL)
00126 void Repair_Injured_AuxIntrnOP (void);
00127 #endif
00128
00129 public:
00130 BITWISE_DCE( CODEMAP *htable, OPT_STAB *opt_stab, CFG *cfg, MEM_POOL *lpool,
00131 BOOL copy_propagate ):
00132 _opt_stab(opt_stab), _htable(htable), _cfg(cfg), _loc_pool(lpool),
00133 _copy_propagate(copy_propagate)
00134 {
00135 _livebits = (UINT64 *) CXX_NEW_ARRAY(UINT64, _htable->Coderep_id_cnt(),
00136 _loc_pool);
00137 _livebits_size = _htable->Coderep_id_cnt();
00138 _usecnt = (UINT8 *) CXX_NEW_ARRAY(UINT8, _htable->Coderep_id_cnt(),
00139 _loc_pool);
00140 BZERO(_livebits, _htable->Coderep_id_cnt() * sizeof(UINT64));
00141 BZERO(_usecnt, _htable->Coderep_id_cnt() * sizeof(UINT8));
00142
00143 _cd_bbs = (BB_NODE_SET *) CXX_NEW(BB_NODE_SET(_cfg->Last_bb_id()+1, _cfg,
00144 _loc_pool, BBNS_EMPTY), _loc_pool);
00145 _live_bbs = (BB_NODE_SET *)CXX_NEW(BB_NODE_SET(_cfg->Last_bb_id()+1, _cfg,
00146 _loc_pool, BBNS_EMPTY), _loc_pool);
00147
00148 _tracing = Get_Trace(TP_GLOBOPT, DCE_DUMP_FLAG);
00149 }
00150 ~BITWISE_DCE(void) {
00151 }
00152
00153 void Bitwise_dce(void);
00154 };
00155
00156 #endif // opt_bdce_INCLUDED