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 #ifndef anl_varlist_INCLUDED
00038 #define anl_varlist_INCLUDED
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 #include "array_set.h"
00059
00060 class ANL_FUNC_ENTRY;
00061
00062 #define ANL_VAR_READ 0x00000001
00063 #define ANL_VAR_WRITTEN 0x00000002
00064
00065
00066 class ANL_VAR
00067 {
00068 private:
00069 ST *_st;
00070 ANL_VAR *_alias;
00071 UINT32 _status;
00072
00073 public:
00074
00075
00076
00077 ANL_VAR(): _st(NULL), _alias(this), _status(0) {}
00078 ANL_VAR(ST *st): _st(st), _alias(this), _status(0) {}
00079
00080
00081
00082
00083 INT32 Id() const {return (_st==NULL? 0 : ST_st_idx(_st));}
00084 BOOL operator==(const ANL_VAR &v) const {return Id() == v.Id();}
00085 BOOL operator!=(const ANL_VAR &v) const {return Id() != v.Id();}
00086 BOOL operator<(const ANL_VAR &v) const {return Id() < v.Id();}
00087 BOOL operator<=(const ANL_VAR &v) const {return Id() <= v.Id();}
00088 BOOL operator>(const ANL_VAR &v) const {return Id() > v.Id();}
00089 BOOL operator>=(const ANL_VAR &v) const {return Id() >= v.Id();}
00090
00091 BOOL Is_Read() {return ((_status & ANL_VAR_READ) != 0);}
00092 BOOL Is_Written() {return ((_status & ANL_VAR_WRITTEN) != 0);}
00093
00094
00095
00096
00097 ANL_VAR &operator=(const ANL_VAR &v)
00098 {
00099 _st = v._st;
00100 _status = v._status;
00101 return *this;
00102 }
00103
00104 void Set_Name_Alias(ANL_VAR *var);
00105
00106 void Set_Read() {_status = (_status | ANL_VAR_READ);}
00107 void Set_Written() {_status = (_status | ANL_VAR_WRITTEN);}
00108
00109 void Reset_References();
00110
00111
00112
00113
00114 void Write(ANL_CBUF *cbuf, ANL_FUNC_ENTRY *_func_entry);
00115
00116 };
00117
00118
00119 class ANL_VARLIST
00120 {
00121 private:
00122
00123 ARRAY_SET<ANL_VAR*> _vlist;
00124 ANL_FUNC_ENTRY *_func_entry;
00125 MEM_POOL *_pool;
00126
00127 mUINT32 _Binary_Search(INT32 id, mUINT32 from, mUINT32 till);
00128
00129 UINT32 _Get_Io_Item_Lda_Access_Status(WN *io_item);
00130
00131 UINT32 _Get_Lda_Access_Status(WN *lda);
00132
00133 public:
00134
00135
00136
00137 ANL_VARLIST(MEM_POOL *pool, ANL_FUNC_ENTRY *func_entry):
00138 _vlist(pool),
00139 _pool(pool),
00140 _func_entry(func_entry)
00141 {}
00142
00143 ~ANL_VARLIST()
00144 {
00145 for (INT i = 0; i < _vlist.Size(); i++)
00146 CXX_DELETE(_vlist.Indexed_Get(i), _pool);
00147 }
00148
00149
00150
00151
00152 ANL_VAR *Find(ST *st);
00153 ANL_VAR *Find_or_Insert(ST *st);
00154
00155
00156
00157
00158 void Insert_Var_Refs(WN *subtree);
00159
00160
00161
00162
00163 void Write(ANL_CBUF *cbuf, INT64 construct_id);
00164
00165
00166 };
00167
00168 #endif