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
00061
00062 #ifndef opt_emit_INCLUDED
00063 #define opt_emit_INCLUDED "opt_emit.h"
00064 #ifdef _KEEP_RCS_ID
00065 static char *opt_emitrcs_id = opt_emit_INCLUDED"$Revision$";
00066 #endif
00067
00068 #ifndef cxx_base_INCLUDED
00069 #include "cxx_base.h"
00070 #endif
00071 #ifndef opt_htable_INCLUDED
00072 #include "opt_htable.h"
00073 #endif
00074 #ifndef optimizer_INCLUDED
00075 #include "optimizer.h"
00076 #endif
00077 #include "region_util.h"
00078
00079 class ALIAS_MANAGER;
00080 class ALIAS_RULE;
00081 class CFG;
00082 class CODEREP;
00083 class DU_MANAGER;
00084 class E_REGION;
00085 class OPT_STAB;
00086 class RVI;
00087 class VER_LIST;
00088
00089 class EMITTER {
00090 private:
00091 CFG *_cfg;
00092 CODEMAP *_htable;
00093 OPT_STAB *_opt_stab;
00094 ALIAS_MANAGER *_alias_mgr;
00095 DU_MANAGER *_du_mgr;
00096 WN *_opt_func;
00097 MEM_POOL *_loc_pool;
00098 MEM_POOL *_mem_pool;
00099 OPT_PHASE _opt_phase;
00100 BOOL _has_do_loop;
00101 BOOL _trace;
00102
00103 STMTREP *_rgn_entry_stmt;
00104
00105 CODEREP_LIST_CONTAINER _copy_list;
00106
00107 WN_MAP _wn_to_cr_map;
00108
00109 STACK<E_REGION *> _region_stack;
00110
00111 ID_MAP<IDTYPE, INT32> _preg_renumbering_map;
00112
00113 EMITTER(const EMITTER&);
00114 EMITTER& operator = (const EMITTER&);
00115
00116
00117 void Generate_entry_copy(BB_NODE *);
00118 void Raise_func_entry(BB_NODE*, BB_NODE*);
00119 BOOL Raise_altentry(BB_NODE*);
00120 BOOL Can_raise_to_scf(BB_NODE*);
00121
00122
00123
00124
00125 void Add_defs_use( DU_MANAGER *, STMTREP *, WN * );
00126
00127
00128 void Compute_use_def_var( DU_MANAGER *, CODEREP *, WN *, BB_NODE * );
00129 void Compute_use_def_expr( DU_MANAGER *, WN *, BB_NODE * );
00130 void Compute_use_def_stmt( DU_MANAGER *, WN *, BB_NODE * );
00131 void Compute_use_def_zero_ver( DU_MANAGER * );
00132 void Compute_use_def_zero_version_var( DU_MANAGER *, CODEREP *, WN *, BB_NODE *, BB_NODE * );
00133
00134 void Compute_incomplete_defs( DU_MANAGER *du_mgr, CODEREP *cr );
00135
00136 void Compute_use_def(DU_MANAGER *);
00137 void Collect_IPA_summary(DU_MANAGER *, WN *);
00138
00139
00140 public:
00141 EMITTER(MEM_POOL *lpool,
00142 MEM_POOL *gpool,
00143 OPT_PHASE opt_phase);
00144 ~EMITTER(void);
00145
00146 OPT_STAB *Opt_stab(void) const { return _opt_stab; }
00147 MEM_POOL *Loc_pool(void) const { return _loc_pool; }
00148 MEM_POOL *Mem_pool(void) const { return _mem_pool; }
00149 CFG *Cfg(void) const { return _cfg; }
00150 CODEMAP *Htable(void) const { return _htable; }
00151 ALIAS_MANAGER *Alias_Mgr(void) const { return _alias_mgr; }
00152 DU_MANAGER *Du_Mgr(void) const { return _du_mgr; }
00153 WN_MAP *Wn_to_cr_map(void) { return &_wn_to_cr_map; }
00154 void Set_has_do_loop(void) { _has_do_loop = TRUE; }
00155 BOOL Has_do_loop(void) const { return _has_do_loop; }
00156 BOOL Trace(void) const { return _trace; }
00157 BOOL For_preopt(void) const { return _opt_phase !=
00158 MAINOPT_PHASE; }
00159 BOOL For_mainopt(void) const { return _opt_phase ==
00160 MAINOPT_PHASE; }
00161 STACK<E_REGION *> *Region_stack(void) { return &_region_stack; }
00162
00163 ID_MAP<IDTYPE, INT32> &Preg_renumbering_map(void)
00164 { return _preg_renumbering_map; }
00165
00166 void Gen_wn(BB_NODE *f, BB_NODE *l);
00167 BOOL Verify(WN *wn);
00168 WN *Emit(COMP_UNIT *cu,
00169 DU_MANAGER *du_mgr,
00170 ALIAS_MANAGER *alias_mgr);
00171
00172
00173 void Connect_sr_wn( STMTREP *stmtrep, WN *wn );
00174 void Connect_cr_wn( CODEREP *coderep, WN *wn );
00175 void Duplicate_sr_cr_connections( WN *old_wn, WN *new_wn );
00176
00177
00178 BOOL Gen_lno_info(void) { return FALSE; }
00179 BOOL Do_rvi(void) { return FALSE; }
00180 RVI *Rvi(void) const { return NULL; };
00181 WN *Build_loop_info(BB_NODE *) { return NULL; }
00182
00183
00184 void Set_region_entry_stmt(STMTREP *s)
00185 { Is_True(s != NULL,("EMITTER::Set_region_entry_stmt, NULL"));
00186 _rgn_entry_stmt = s; }
00187 STMTREP *Region_entry_stmt(void)
00188 { Is_True(_rgn_entry_stmt != NULL,("EMITTER::Region_entry_stmt, NULL"));
00189 return _rgn_entry_stmt; }
00190
00191 };
00192
00193 void Detect_invalid_doloops(COMP_UNIT *);
00194
00195
00196 enum {
00197 WOPT_GOTO_CONVERSION_FINISHED = 0x2,
00198 WOPT_TAIL_RECUR_FINISHED = 0x4,
00199 };
00200
00201 #endif // opt_emit_INCLUDED