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 #ifndef opt_region_emit_INCLUDED
00057 #define opt_region_emit_INCLUDED "opt_region_emit.h"
00058 #ifdef _KEEP_RCS_ID
00059 static char *opt_region_emitrcs_id = opt_region_emit_INCLUDED"$Revision$";
00060 #endif
00061
00062 class ALIAS_MANAGER;
00063 class BB_NODE;
00064 class CHI_LIST;
00065 class MU_LIST;
00066 class OPT_STAB;
00067 class CFG;
00068
00069 typedef struct region_id RID;
00070
00071 #ifndef defs_INCLUDED
00072 #include "defs.h"
00073 #endif
00074
00075 #ifndef cxx_template_INCLUDED
00076 #include "cxx_template.h"
00077 #endif
00078
00079 #ifndef wn_INCLUDED
00080 #include "wn.h"
00081 #endif
00082
00083
00084
00085 class E_REGION {
00086 friend class EMITTER;
00087
00088 BB_NODE *_region_start;
00089 BB_NODE *_region_end;
00090 WN *_prev_wn;
00091
00092
00093 E_REGION(void);
00094 E_REGION(const E_REGION&);
00095 E_REGION& operator = (const E_REGION&);
00096
00097 public:
00098 E_REGION( BB_NODE *region_start, BB_NODE *region_end, WN *prev_wn=NULL ) :
00099 _region_start(region_start),
00100 _region_end(region_end),
00101 _prev_wn(prev_wn) { }
00102
00103 BB_NODE *Region_start(void) const { return _region_start; }
00104 BB_NODE *Region_end(void) const { return _region_end; }
00105 WN *Prev_wn(void) const { return _prev_wn; }
00106 void Set_prev_wn(WN *wn) { _prev_wn = wn; }
00107 };
00108
00109
00110
00111
00112
00113 class PRUNE_BOUND {
00114 private:
00115 CFG *_cfg;
00116 OPT_STAB *_opt_stab;
00117 RID *_rid;
00118 BS *_modset;
00119 BS *_useset;
00120 BOOL _trace;
00121 MEM_POOL _lpool;
00122
00123 PRUNE_BOUND& operator = (const PRUNE_BOUND&);
00124
00125 BOOL Trace(void) { return _trace; }
00126 void Prune_boundary_sets(void);
00127
00128
00129 void Collect_mod_use_sets(BB_NODE *bb);
00130 void Useset_stmt(STMTREP *stmt);
00131 void Useset_expr(CODEREP *cr);
00132
00133
00134 void REGION_remove_from_bound(AUX_ID aux_id, BOOL outset);
00135
00136 public:
00137 PRUNE_BOUND(CFG *cfg, OPT_STAB *opt_stab) : _cfg(cfg), _opt_stab(opt_stab)
00138 { _trace = Get_Trace(TP_REGION, TT_REGION_WOPT_DEBUG) ||
00139 Get_Trace(TP_REGION, TT_REGION_BOUND_DEBUG) ||
00140 Get_Trace(TP_GLOBOPT, ALIAS_DUMP_FLAG);
00141 _rid = _cfg->Rid();
00142
00143 OPT_POOL_Initialize(&_lpool, "REGION prune boundary set", FALSE, -1);
00144 OPT_POOL_Push(&_lpool, -1);
00145 INT32 size = opt_stab->Lastidx() + 1;
00146
00147 _modset = BS_Create_Empty(size, &_lpool);
00148 _useset = BS_Create_Empty(size, &_lpool);
00149
00150 _modset = BS_ClearD(_modset);
00151 _useset = BS_ClearD(_useset);
00152
00153 Prune_boundary_sets();
00154 }
00155
00156 ~PRUNE_BOUND(void)
00157 {
00158 OPT_POOL_Pop(&_lpool, -1);
00159 OPT_POOL_Delete(&_lpool, -1);
00160 }
00161 };
00162
00163
00164
00165 extern void REGION_live_in_from_chi(RID *rid,
00166 CHI_LIST *clist,
00167 OPT_STAB *opt_stab,
00168 ALIAS_MANAGER *alias_mgr);
00169
00170 extern void REGION_live_out_from_mu(RID *rid,
00171 MU_LIST *mlist,
00172 OPT_STAB *opt_stab,
00173 ALIAS_MANAGER *alias_mgr);
00174
00175 extern void Push_region(STACK<E_REGION *> *stk,
00176 BB_NODE *start_region,
00177 MEM_POOL *pool);
00178
00179 extern WN *Pop_region(STACK<E_REGION *> *stk, WN *first_wn, WN *last_wn,
00180 REGION_LEVEL rgn_level, OPT_STAB *opt_stab);
00181
00182
00183 #endif // opt_region_emit_INCLUDED