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_prop_INCLUDED
00048 #define opt_prop_INCLUDED "opt_prop.h"
00049
00050 #ifdef _KEEP_RCS_ID
00051 static char *opt_proprcs_id = opt_prop_INCLUDED"$Revision$";
00052 #endif
00053
00054
00055 class CFG;
00056 class BB_NODE;
00057 class OPT_STAB;
00058 class CODEMAP;
00059 class CODEREP;
00060
00061
00062
00063
00064
00065 enum PROP_THRU_PHI_PREFERENCE {
00066 EITHER_SIDE,
00067 LEFT_SIDE,
00068 RIGHT_SIDE,
00069 };
00070
00071 class COPYPROP {
00072 private:
00073 OPT_STAB *_opt_stab;
00074 CFG *_cfg;
00075 CODEMAP *_htable;
00076 MEM_POOL *_loc_pool;
00077 BOOL _disabled;
00078 DYN_ARRAY<CODEREP *> _visited_vec;
00079 DYN_ARRAY<CODEREP *> _rehashed_vec;
00080
00081 DYN_ARRAY<CODEREP *> _rehashed_to_vec;
00082
00083 BOOL _past_ret_reg_def;
00084
00085
00086 OPT_STAB *Opt_stab(void)const { return _opt_stab; }
00087 CFG *Cfg(void) const { return _cfg; }
00088 CODEMAP *Htable(void) const { return _htable; }
00089 MEM_POOL *Loc_pool(void)const { return _loc_pool; }
00090
00091 void Add_visited_node(CODEREP *x) { _visited_vec[_visited_vec.Newidx()] = x; }
00092 void Add_rehashed_node(CODEREP *x, CODEREP *y) {
00093 _rehashed_vec[_rehashed_vec.Newidx()] = x;
00094 _rehashed_to_vec[_rehashed_to_vec.Newidx()] = y; }
00095
00096 COPYPROP(void);
00097 COPYPROP(const COPYPROP&);
00098 COPYPROP& operator = (const COPYPROP&);
00099
00100 PROPAGATABILITY Propagatable(CODEREP *x, BOOL chk_inverse,
00101 AUX_ID propagating_var, BOOL icopy_phase,
00102 BOOL inside_cse, INT32 *height,INT32*weight,
00103 BOOL in_array, BB_NODE *curbb );
00104 CODEREP *Copy_propagate_cr(CODEREP *x, BB_NODE *curbb,
00105 BOOL inside_cse, BOOL in_array, BOOL no_complex_preg = FALSE);
00106 void Copy_propagate_stmt(STMTREP *stmt, BB_NODE *bb);
00107 BOOL Var_has_as_value_on_the_other_path(CODEREP *var, CODEREP *value,
00108 BOOL var_on_left, BB_NODE *bb);
00109 BOOL Propagatable_thru_phis(CODEREP *lexp, CODEREP *rexp, BB_NODE *bb,
00110 CODEREP *phi_simp_var,
00111 PROP_THRU_PHI_PREFERENCE *pref);
00112 CODEREP *Rehash_thru_phis(CODEREP *cr, BB_NODE *bb);
00113 CODEREP *Strictly_identical_phi_opnd(PHI_NODE *phi, BB_NODE *bb);
00114 CODEREP *Identical_phi_opnd(PHI_NODE *phi, BB_NODE *bb);
00115 INT32 Invertible_occurrences(CODEREP *var, CODEREP *cr);
00116 BOOL Is_function_of_itself(STMTREP *stmt, OPT_STAB *sym);
00117 BOOL Is_function_of_cur(CODEREP *var, CODEREP *cur_var);
00118 CODEREP *Form_inverse(CODEREP *v, CODEREP *x, CODEREP *forming_x);
00119 CODEREP *Rehash_inverted_expr(CODEREP *x, BOOL icopy_phase);
00120 BB_NODE *Propagated_to_loop_branch(BB_NODE *srcbb, BB_NODE *destbb);
00121 CODEREP *Get_node_rehashed_to(CODEREP *x);
00122 CODEREP *Prop_const_init_scalar(CODEREP *x, AUX_ID var_aux_id);
00123 void Fix_identity_assignment(STMTREP *);
00124
00125 public:
00126 COPYPROP( CODEMAP *htable, OPT_STAB *opt_stab, CFG *cfg, MEM_POOL *lpool):
00127 _opt_stab(opt_stab), _htable(htable), _cfg(cfg), _loc_pool(lpool),
00128 _visited_vec(lpool), _rehashed_vec(lpool), _rehashed_to_vec(lpool)
00129 { _disabled = FALSE; _past_ret_reg_def = FALSE;
00130 }
00131 ~COPYPROP(void) { _visited_vec.Free_array();
00132 _rehashed_vec.Free_array();
00133 _rehashed_to_vec.Free_array(); }
00134
00135 void Unvisit_nodes(void);
00136 CODEREP *Prop_var(CODEREP *x, BB_NODE *curbb, BOOL icopy_phase,
00137 BOOL inside_cse, BOOL in_array, BOOL no_complex_preg = FALSE);
00138 CODEREP *Prop_ivar(CODEREP *x, BB_NODE *curbb, BOOL icopy_phase,
00139 BOOL inside_cse, BOOL in_array, BOOL no_complex_preg = FALSE);
00140 void Copy_propagate(BB_NODE *bb);
00141
00142 BOOL Disabled(void) const { return _disabled; }
00143 void Set_disabled(void) { _disabled = TRUE; }
00144 void Reset_disabled(void) { _disabled = FALSE; }
00145 BOOL Past_ret_reg_def(void) const { return _past_ret_reg_def; }
00146 void Set_past_ret_reg_def(void) { _past_ret_reg_def = TRUE; }
00147 void Reset_past_ret_reg_def(void) { _past_ret_reg_def = FALSE; }
00148 };
00149
00150 #endif // opt_prop_INCLUDED