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_rvi_INCLUDED
00057 #define opt_rvi_INCLUDED "opt_rvi.h"
00058 #ifdef _KEEP_RCS_ID
00059 static char *opt_rvircs_id = opt_rvi_INCLUDED"$ $Revision: 1.2 $";
00060 #endif
00061
00062 #ifndef wn_INCLUDED
00063 #include "wn.h"
00064 #endif // wn_INCLUDED
00065 #ifndef mempool_INCLUDED
00066 #include "mempool.h"
00067 #endif // mempool_INCLUDED
00068
00069
00070 class ALIAS_MANAGER;
00071 class BB_NODE_SET;
00072 class CFG;
00073 class CHI_LIST;
00074 class IDX_32_SET;
00075 class MU_NODE;
00076 class MU_LIST;
00077 class OPT_STAB;
00078 class RVI_CTAB;
00079 class RVI_LR;
00080 class RVI_LR_LIST;
00081 class RVI_LRBB;
00082 class RVI_LRBB_LIST;
00083 class RVI_NODE;
00084 class RVI_NOMAP_LIST;
00085 class RVI_VTAB;
00086
00087
00088 class RVI {
00089 friend class RVI_EMIT;
00090 friend class RVI_LR;
00091 private:
00092 static const INT32 SET_SIZE_INCREMENT = 32;
00093 WN_MAP _mu_map;
00094 WN_MAP _chi_map;
00095 WN_MAP _bp_map;
00096 MEM_POOL _rvi_gpool;
00097 MEM_POOL *_rvi_gpoolp;
00098 MEM_POOL _rvi_ppool;
00099 MEM_POOL *_rvi_ppoolp;
00100 MEM_POOL _rvi_lpool;
00101 MEM_POOL *_rvi_lpoolp;
00102 BOOL _do_rvi;
00103 BOOL _do_base_lda;
00104 BOOL _unique_pregs;
00105 BOOL _tracing;
00106 IDX_32 _max_bitpos;
00107 IDX_32 _last_varbit;
00108 IDX_32 _init_set_size;
00109 RVI_CTAB *_rvi_ctab;
00110 RVI_VTAB *_rvi_vtab;
00111 CFG *_cfg;
00112 BB_NODE **_dfs_vec;
00113 INT _dfs_vec_size;
00114 OPT_STAB *_opt_stab;
00115 ALIAS_MANAGER *_alias_mgr;
00116 IDX_32_SET *_volatile_set;
00117
00118
00119
00120 struct {
00121 BB_NODE_SET *_load_top;
00122 BB_NODE_SET *_load_bot;
00123 BB_NODE_SET *_store_top;
00124 BB_NODE_SET *_store_iref;
00125 } _redundant;
00126
00127
00128
00129
00130
00131
00132 IDX_32 Max_bitpos(void) const
00133 { return _max_bitpos; }
00134 IDX_32 Next_bitpos(void)
00135 { return ++_max_bitpos; }
00136 IDX_32 Last_varbit(void) const
00137 { return _last_varbit; }
00138 IDX_32 Initial_set_size(void)
00139 { if ( _init_set_size <= _max_bitpos )
00140 _init_set_size = _max_bitpos+SET_SIZE_INCREMENT;
00141 return _init_set_size;
00142 }
00143
00144 BOOL Do_base_lda(void) const
00145 { return _do_base_lda; }
00146
00147 BOOL Unique_pregs(void) const
00148 { return _unique_pregs; }
00149
00150 BOOL Tracing(void) const
00151 { return _tracing; }
00152
00153
00154 WN_MAP Mu_map(void) const
00155 { return _mu_map; }
00156 IDX_32_SET *Get_mu_list( const WN *wn ) const
00157 { return (IDX_32_SET*)WN_MAP_Get( Mu_map(), wn ); }
00158
00159 BOOL Has_end_mu_list( const BB_NODE *bb ) const
00160 { return bb->Loc_mu_ref() != NULL; }
00161 IDX_32_SET *Bb_end_mu_list( const BB_NODE *bb ) const;
00162
00163
00164 WN_MAP Chi_map(void) const
00165 { return _chi_map; }
00166 IDX_32_SET *Get_chi_list( const WN *wn ) const
00167 { return (IDX_32_SET*)WN_MAP_Get( Chi_map(), wn ); }
00168
00169 BOOL Has_end_chi_list( const BB_NODE *bb ) const
00170 { return bb->Loc_chi_def() != NULL; }
00171 IDX_32_SET *Bb_end_chi_list( const BB_NODE *bb ) const;
00172
00173
00174 void Resize_sets( BB_NODE *bb, INT32 new_size ) const;
00175
00176
00177 WN_MAP Bp_map(void) const
00178 { return _bp_map; }
00179
00180 RVI_CTAB *Rvi_ctab(void) const
00181 { return _rvi_ctab; }
00182
00183 RVI_VTAB *Rvi_vtab(void) const
00184 { return _rvi_vtab; }
00185
00186 CFG *Cfg(void) const
00187 { return _cfg; }
00188
00189 BB_NODE *Dfs_vec( INT i ) const
00190 { return _dfs_vec[i]; }
00191 INT Dfs_vec_size( void ) const
00192 { return _dfs_vec_size; }
00193
00194
00195 OPT_STAB *Opt_stab( void ) const
00196 { return _opt_stab; }
00197
00198
00199 ALIAS_MANAGER *Alias_Mgr( void ) const
00200 { return _alias_mgr; }
00201
00202
00203 IDX_32_SET *Volatile_set( void ) const
00204 { return _volatile_set; }
00205
00206
00207
00208 BB_NODE_SET *Redundant_load_top( void ) const
00209 { return _redundant._load_top; }
00210 BB_NODE_SET *Redundant_load_bot( void ) const
00211 { return _redundant._load_bot; }
00212 BB_NODE_SET *Redundant_store_top( void ) const
00213 { return _redundant._store_top; }
00214 BB_NODE_SET *Redundant_store_iref( void ) const
00215 { return _redundant._store_iref; }
00216
00217 void Init_redundant( MEM_POOL *pool );
00218 void Clear_redundant( void ) const;
00219
00220
00221
00222
00223
00224
00225
00226 void Get_local_attributes( BOOL just_lda );
00227
00228 void Get_bb_local_attributes( BB_NODE *bb );
00229
00230 void Get_wn_local_attributes( BB_NODE *bb, WN *wn, BOOL *check_const);
00231
00232
00233 void Get_bb_local_lda_attributes( BB_NODE *bb );
00234
00235 void Get_wn_local_lda_attributes( BB_NODE *bb, WN *wn, BOOL *check_lda );
00236
00237
00238 void Get_dataflow_equations( void );
00239 void Get_forward_dataflow( void );
00240 void Get_backward_dataflow( void );
00241
00242
00243 void Get_lda_dataflow_equations( void );
00244 void Get_forward_lda_dataflow( void );
00245 void Get_backward_lda_dataflow( void );
00246
00247
00248
00249 BOOL Is_exit_block( const BB_NODE *bb ) const;
00250
00251
00252
00253 const IDX_32_SET *Global_vars( const BB_NODE *bb ) const;
00254
00255
00256
00257 RVI_NODE *Add_to_const_table( WN *wn );
00258
00259
00260 BOOL Is_base_lda( const WN *wn ) const;
00261
00262
00263 BOOL Is_const_candidate( const WN *parent, const WN *constant, INT whichkid ) const;
00264
00265
00266 BOOL Is_lda_candidate( const WN *parent, const WN *lda, INT whichkid ) const;
00267
00268
00269 BOOL Is_ldid_candidate( const WN *ldidwn ) const;
00270 BOOL Is_stid_candidate( const WN *stidwn ) const;
00271
00272
00273
00274 void Find_loops( void ) const;
00275
00276
00277
00278
00279 void Copy_dedicated_regs_to_pregs( void ) const;
00280
00281
00282
00283 void Set_callrel() const;
00284
00285
00286 void Build_live_ranges(RVI_NODE *rvi_node,MEM_POOL *pool ) const;
00287
00288 void Build_up_live_range( RVI_LR *live_range, BB_NODE *bb,
00289 RVI_LRBB_LIST *appearances,
00290 BB_NODE_SET *visited_bbs, MEM_POOL *pool ) const;
00291
00292
00293 void Analyze_live_range( RVI_LR *live_range ) const;
00294
00295
00296 enum RVI_INSERT {
00297 RVI_INS_TOP,
00298 RVI_INS_BEFORE_IREF,
00299 RVI_INS_PRECALL,
00300 RVI_INS_POSTCHI };
00301 void Insert_statement( BB_NODE *bb, WN *wn, RVI_INSERT insert ) const;
00302 void Insert_loads_stores( RVI_LR *live_range, RVI_NODE *node);
00303 void Annotate_load_store( BB_NODE *bb, RVI_NODE *node, INT32 preg );
00304 void Insert_load( RVI_LRBB *lrbb, WN *loadwn, RVI_LR *live_range ) const;
00305 void Insert_store( RVI_LRBB *lrbb, WN *storewn, RVI_LR *live_range ) const;
00306
00307
00308
00309 void Store_to_preg_cvtl(WN *store_wn, ST* preg_st,
00310 TY_IDX preg_ty, PREG_NUM preg_num) const;
00311
00312
00313
00314 void Store_to_preg_and_mem(BB_NODE *bb, WN *store_wn,
00315 ST* preg_st, TY_IDX preg_ty,
00316 PREG_NUM preg_num) const;
00317
00318
00319
00320 WN *Load_from_preg_cvtl(WN *wn, OPCODE load_opc) const;
00321
00322
00323 void Perform_variable_rvi( void );
00324
00325 void Perform_constant_rvi( void );
00326
00327 void Perform_variable_constant_rvi( RVI_NODE * );
00328 #if defined(TARG_SL)
00329 BOOL Is_Intrncall_Nth_Parm_Need_RVI(INTRINSIC, INT);
00330 #endif
00331
00332 WN *Perform_phase1( WN *wn );
00333 WN *Perform_phase2( WN *wn );
00334
00335
00336 WN *Emit( void ) const;
00337
00338 RVI(void);
00339 RVI(const RVI&);
00340 RVI& operator = (const RVI&);
00341
00342 public:
00343
00344 RVI( BOOL do_rvi, OPT_STAB *opt_stab, IDX_32 max_varbit, ALIAS_MANAGER *alias_mgr );
00345 ~RVI(void);
00346
00347
00348
00349
00350 MEM_POOL *Rvi_gpool(void) const
00351 { return _rvi_gpoolp; }
00352 MEM_POOL *Rvi_ppool(void) const
00353 { return _rvi_ppoolp; }
00354 MEM_POOL *Rvi_lpool(void) const
00355 { return _rvi_lpoolp; }
00356
00357
00358 BOOL Do_rvi(void) const
00359 { return _do_rvi; }
00360
00361
00362 void Map_mu_list ( WN *wn, MU_LIST *mu_list );
00363 void Map_mu_node ( WN *wn, MU_NODE *mu_node );
00364 void Map_chi_list( WN *wn, CHI_LIST *chi_list );
00365
00366
00367 void Map_bitpos( WN *wn, IDX_32 bitpos ) const
00368 { WN_MAP32_Set( Bp_map(), wn, bitpos ); }
00369
00370
00371
00372 IDX_32 Get_bitpos( const WN *wn ) const
00373 { IDX_32 bp = WN_MAP32_Get( Bp_map(), wn );
00374 return ( bp != 0 ? bp : ILLEGAL_BP );
00375 }
00376
00377
00378 BOOL Black_box( const OPCODE opc ) const
00379 { return OPCODE_is_black_box(opc) ||
00380
00381
00382
00383
00384 opc == OPC_ASM_STMT ||
00385 opc == OPC_EXC_SCOPE_BEGIN;
00386 }
00387
00388
00389 WN *Perform_RVI( WN *wn, ALIAS_MANAGER *alias );
00390 };
00391
00392 class PRE_RVI_HOOKS {
00393 private:
00394 IDX_32 _nbits;
00395 BOOL _tracing;
00396
00397 public:
00398 PRE_RVI_HOOKS(OPT_STAB *,
00399 CFG *,
00400 MEM_POOL *,
00401 BOOL);
00402
00403 BOOL Tracing(void) { return _tracing; }
00404
00405 void Setup_bitpos(OPT_STAB *, CODEREP *);
00406
00407 IDX_32 Nbits(void) { return _nbits; }
00408
00409 void Inc_nbits(void) { ++_nbits; }
00410 };
00411
00412 #endif // opt_rvi_INCLUDED