IPCPProcData.hGo to the documentation of this file.00001
00002 #ifndef _IPCP_PROC_DATA_H
00003 #define _IPCP_PROC_DATA_H
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "../Listable.h"
00021 #include "../Collection/Map.h"
00022 #include "../Collection/RefMap.h"
00023 #include "../Collection/Set.h"
00024 #include "../Collection/RefSet.h"
00025 #include "../Collection/RefList.h"
00026 #include "../Symbol/Symbol.h"
00027 #include "../Expression/Expression.h"
00028 #include "../Statement/Statement.h"
00029 #include "../Statement/AssignmentStmt.h"
00030 #include "../String.h"
00031 #include "../Boolean.h"
00032
00033 #include "IPCPConstants.h"
00034 #include "constant.h"
00035
00036 class ProgramUnit;
00037 class InterProcConstProp;
00038 class IPCPProcData;
00039 class JumpFunction;
00040 class ReturnJumpFunction;
00041
00042 class IPCPCallData : public Listable {
00043 public:
00044 IPCPCallData(IPCPProcData *called_pgm_data);
00045 IPCPCallData(const IPCPCallData &other);
00046 virtual ~IPCPCallData();
00047
00048 inline const IPCPProcData *data_ref() const;
00049 inline void data_ref(IPCPProcData *data);
00050
00051
00052
00053 inline Boolean jump_function_valid() const;
00054 inline const JumpFunction &jump_function() const;
00055 void jump_function(JumpFunction *jump_func);
00056
00057
00058
00059
00060
00061
00062
00063
00064 void add_constant_set(IPCPConstants *constants,
00065 const List<Expression> ¶m_values);
00066
00067
00068 void compute_rtoporder(int &max_visited_elems);
00069
00070
00071
00072 virtual Listable *listable_clone() const;
00073 virtual void print(ostream &o) const;
00074 virtual int structures_OK() const;
00075
00076
00077 private:
00078 IPCPProcData *_called_pgm_data;
00079 JumpFunction *_jump_function;
00080 };
00081
00082 class IPCPProcData : public Listable {
00083 public:
00084 IPCPProcData(ProgramUnit &pgm, InterProcConstProp &ipcp,
00085 const Statement &entry, int debug = 0);
00086
00087
00088
00089
00090
00091
00092 IPCPProcData(ProgramUnit &cloned_proc,
00093 const Statement &clone_entry,
00094 IPCPProcData &orig_proc_data);
00095
00096
00097
00098
00099
00100 virtual ~IPCPProcData();
00101
00102 inline ProgramUnit &pgm();
00103
00104
00105 inline const Statement &entry() const;
00106
00107
00108 const IPCPCallData *call_data(const Statement &call_site) const;
00109
00110
00111
00112
00113
00114 inline const RefSet<Symbol> &used_global_vars() const;
00115
00116
00117
00118 inline const RefSet<Symbol> &usable_global_vars() const;
00119
00120
00121
00122
00123 RefSet<Symbol> *local_vars(const RefSet<Symbol> &vars) const;
00124
00125
00126
00127 inline const RefList<Symbol> ¶m_list() const;
00128
00129
00130
00131 inline const Symbol *return_var() const;
00132
00133
00134
00135 inline const Boolean is_called_externally() const;
00136
00137
00138
00139
00140 inline void called_externally();
00141
00142
00143 void create_return_jump_function(Map<Symbol, Expression> *old_const_mods,
00144 Map<Symbol, Expression> *new_consts);
00145
00146
00147
00148
00149 void create_jump_function(const Statement &call_site,
00150 Map<Symbol, Expression> *old_const_mods,
00151 Map<Symbol, Expression> *new_consts,
00152 List<Expression> *actuals);
00153
00154
00155
00156
00157 inline const ReturnJumpFunction &return_jump_function() const;
00158
00159
00160
00161
00162
00163 const RefList<Symbol> *call_formals(const Statement &call_site) const;
00164
00165
00166
00167 Map<Symbol,Expression> *local_old_const_mods(const Statement &call_site,
00168 const ReturnJumpFunction &jump_function) const;
00169
00170
00171
00172
00173
00174
00175 Map<Symbol,Expression> *local_new_consts(const Statement &call_site,
00176 const ReturnJumpFunction &jump_function) const;
00177
00178
00179
00180
00181
00182 void add_constant_set(IPCPConstants *constants,
00183 const List<Expression> ¶m_values);
00184
00185
00186 inline const List<IPCPConstants> &const_sets() const;
00187
00188
00189 void transfer_const_set(IPCPConstants &constants, IPCPProcData &other);
00190
00191
00192
00193
00194
00195
00196
00197 void add_consts_to_pgm(const IPCPConstants &consts);
00198
00199
00200
00201
00202 void add_consts_to_pgm();
00203
00204
00205
00206
00207 void build_jump_functions(int debug = 0);
00208
00209
00210
00211
00212
00213
00214
00215
00216 void propagate_constants(PC_UNREACH_BOOL remove_unreachable,
00217 int debug = 0);
00218
00219
00220
00221
00222
00223
00224
00225
00226 void expand_all_substituted();
00227
00228
00229
00230 void make_consts_sets_old();
00231
00232
00233
00234 Boolean have_consts_sets_changed() const;
00235
00236
00237
00238 inline int rtoporder() const;
00239
00240
00241
00242 void init_rtoporder();
00243
00244
00245
00246 void compute_rtoporder(int &max_visited_elems);
00247
00248
00249
00250 void add_maymods();
00251
00252
00253
00254 virtual void print(ostream &o, Boolean pretty_print) const;
00255
00256
00257
00258 virtual Listable *listable_clone() const;
00259 virtual void print(ostream &o) const;
00260 virtual int structures_OK() const;
00261
00262
00263 private:
00264 ProgramUnit *_pgm_ref;
00265 InterProcConstProp *_ipcp_ref;
00266 const Statement *_entry;
00267 Database<String, IPCPCallData> _call_data;
00268
00269 RefSet<Symbol> _used_global_vars;
00270
00271 RefSet<Symbol> _usable_global_vars;
00272
00273 RefMap<Symbol, Symbol> _local_to_global_vars;
00274
00275 RefMap<Symbol, Symbol> _global_to_local_vars;
00276
00277 RefList<Symbol> _param_list;
00278
00279 const Symbol *_return_var;
00280 ReturnJumpFunction *_return_jump_function;
00281
00282 List<IPCPConstants> _consts_sets;
00283 List<IPCPConstants> _old_consts_sets;
00284 int _rtoporder;
00285 Boolean _called_externally;
00286
00287
00288
00289 void _mark_external_func_calls(const Expression &expr);
00290 void _init_call_sites();
00291 const Symbol &_convert_local_to_global(const Symbol &local_var,
00292 const char *global_namespace);
00293 void _init_params();
00294 void _add_params_to_set(RefSet<Symbol> &vars) const;
00295 void _init_usable_global_vars();
00296 void _add_refs_to_globals(const RefSet<Expression> &refs);
00297 void _init_used_global_vars();
00298 RefSet<Symbol> *_candidates() const;
00299 Boolean _contains_local_vars(const Expression &expr) const;
00300 Boolean _contains_local_vars(const Expression &expr,
00301 const RefList<Symbol> &caller_formals) const;
00302 void _filter_out_local_vars(Map<Symbol, Expression> &var_mods) const;
00303 void _filter_out_local_vars(Map<Symbol, Expression> &var_mods,
00304 const RefList<Symbol> &caller_formals) const;
00305 void _rename_locals_to_globals(Expression &expr) const;
00306 void _rename_locals_to_globals(Map<Symbol,Expression> &var_mods) const;
00307 void _rename_locals_to_globals(List<Expression> &expr_list) const;
00308 void _rename_globals_to_locals(Expression &expr) const;
00309 void _rename_globals_to_locals(Map<Symbol,Expression> &var_mods) const;
00310 Map<Symbol,Expression> *_local_consts(const IPCPConstants &consts) const;
00311 void _update_call_site(const char *call_site_tag,
00312 IPCPProcData &new_call_proc_data);
00313 Expression *_expr_del_global_substituted(Expression *expr);
00314 void _del_global_substituted();
00315 };
00316
00317
00318
00319
00320
00321 inline const IPCPProcData *
00322 IPCPCallData::data_ref() const
00323 {
00324 return _called_pgm_data;
00325 }
00326
00327 inline void
00328 IPCPCallData::data_ref(IPCPProcData *data)
00329 {
00330 _called_pgm_data = data;
00331 }
00332
00333 inline Boolean
00334 IPCPCallData::jump_function_valid() const
00335 {
00336 return _jump_function != 0;
00337 }
00338
00339 inline const JumpFunction &
00340 IPCPCallData::jump_function() const
00341 {
00342 p_assert(_jump_function,
00343 "IPCPCallData::_jump_function(): Jump function was not initialized.");
00344 return *_jump_function;
00345 }
00346
00347 inline ProgramUnit &
00348 IPCPProcData::pgm()
00349 {
00350 return *_pgm_ref;
00351 }
00352
00353 inline const Statement &
00354 IPCPProcData::entry() const
00355 {
00356 return *_entry;
00357 }
00358
00359 inline const RefSet<Symbol> &
00360 IPCPProcData::used_global_vars() const
00361 {
00362 return _used_global_vars;
00363 }
00364
00365 inline const RefSet<Symbol> &
00366 IPCPProcData::usable_global_vars() const
00367 {
00368 return _usable_global_vars;
00369 }
00370
00371 inline const RefList<Symbol> &
00372 IPCPProcData::param_list() const
00373 {
00374 return _param_list;
00375 }
00376
00377 inline const Symbol *
00378 IPCPProcData::return_var() const
00379 {
00380 return _return_var;
00381 }
00382
00383 inline const ReturnJumpFunction &
00384 IPCPProcData::return_jump_function() const
00385 {
00386 p_assert(_return_jump_function,
00387 "IPCPProcData::_return_jump_function(): Return jump function was not initialized.");
00388 return *_return_jump_function;
00389 }
00390
00391 inline const List<IPCPConstants> &
00392 IPCPProcData::const_sets() const
00393 {
00394 return _consts_sets;
00395 }
00396
00397 inline int
00398 IPCPProcData::rtoporder() const
00399 {
00400 return _rtoporder;
00401 }
00402
00403 inline const Boolean
00404 IPCPProcData::is_called_externally() const
00405 {
00406 return _called_externally;
00407 }
00408
00409 inline void
00410 IPCPProcData::called_externally()
00411 {
00412 _called_externally = True;
00413 }
00414
00415 #endif
|