| Polaris: GSAFullRangeData.h Source File | ||
|
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members
GSAFullRangeData.hGo to the documentation of this file.00001 #ifndef _GSA_FULL_RANGE_DATA_H 00002 #define _GSA_FULL_RANGE_DATA_H 00003 /// 00004 /// file GSAFullRangeData.h 00005 /// 00006 /// \class GSAFullRangeData 00007 /// \brief WorkSpace for propagate ranges 00008 /// \defgroup Polaris 00009 /// \ingroup Polaris 00010 /// Range 00011 /// \see GSAFullRangeData.h 00012 /// \see GSAFullRangeData.h 00013 /// \see GSAFullRangeData.cc 00014 /// 00015 /// \endcode 00016 /// \section Overview Overview 00017 /// This class holds an assortment of temporary data associated with 00018 /// a particular statement for the GSAFullRangesDict Constructor List 00019 /// 00020 #ifdef POLARIS_GNU_PRAGMAS 00021 #pragma interface 00022 #endif 00023 /// 00024 #include "../Collection/Element.h" 00025 #include "../Collection/Map.h" 00026 #include "../Collection/RefMap.h" 00027 #include "../Collection/RefList.h" 00028 #include "../Symbol/Symbol.h" 00029 #include "../Statement/Statement.h" 00030 #include "../Expression/Expression.h" 00031 /// 00032 #include "RangeAccessor.h" 00033 /// 00034 class GSAFullRangeDict; 00035 class GSAFullRangeData; 00036 class GSAControlRangeDict; 00037 00038 class GSARangeOrData : public Listable { 00039 public: 00040 inline GSARangeOrData(const Expression *range_ref); 00041 inline GSARangeOrData(GSAFullRangeData &data); 00042 inline GSARangeOrData(const GSARangeOrData &other); 00043 inline virtual ~GSARangeOrData(); 00044 00045 inline bool is_range() const; 00046 ///< Return true if the object is a range. 00047 00048 inline bool is_data() const; 00049 ///< Return true if the object is a GSAFullRangeData object. 00050 00051 inline const Expression *range_ref() const; 00052 ///< Return the range stored in this object. Will p_assert 00053 ///< out if it isn't a range. 00054 00055 inline GSAFullRangeData &data(); 00056 ///< Return the GSAFullRangeData object stored in this object. 00057 ///< Will p_assert out if it isn't a GSAFullRangeData object. 00058 00059 inline virtual Listable *listable_clone() const; 00060 virtual void print(ostream &o) const; 00061 inline virtual int structures_OK() const; 00062 ///< Functions required by Listable. 00063 private: 00064 bool _is_range; 00065 union { 00066 const Expression *_range_ref; 00067 GSAFullRangeData *_data_ref; 00068 }; 00069 }; 00070 00071 class GSAFullRangeData : public Listable { 00072 public: 00073 bool is_phi_stmt; ///< true if my stmt is a phi assignment. 00074 bool is_poisoned; ///< true if my range is an overly conservative 00075 ///< value because it couldn't be computed 00076 ///< because one of the ranges it needed was 00077 ///< being computed by an earlier invocation 00078 ///< of GSAFullRangeDict::_get_data_range_ref(). 00079 bool needs_iteration; ///< Either myself or one of the ranges I 00080 ///< use need iteration to a fixed point to 00081 ///< compute my/its value. 00082 bool needs_widening; ///< One of my ranges I access is a back-edge. 00083 ///< So my range will need to be widened to 00084 ///< guarantee termination. 00085 bool are_all_args_defined; 00086 ///< Were all my phi-function argument's ranges 00087 ///< defined when I last computed my range. 00088 bool union_arg_ranges; ///< When performing the union() method, 00089 ///< union the ranges of my arguments rather 00090 ///< than the arguments themselves. 00091 RefList<Symbol> args; ///< List of all my arguments, in the preferred 00092 ///< order in which they should be visited. 00093 Map<Symbol,GSARangeOrData> arg_ranges_or_data; 00094 ///< The ranges or data for each of my 00095 ///< Phi-function's arguments. 00096 RefMap<Symbol,Statement> arg_preds; 00097 ///< The preceding statement for the entering 00098 ///< control flow edge labeled with the given arg 00099 int toporder; ///< Topological order value. 00100 int num_updates; ///< Number of times method update() was called 00101 RefSet<GSAFullRangeData> users; 00102 ///< The data objects that depend on my value. 00103 bool computed; ///< Has my range been completely computed. 00104 int df_order; ///< Depth first order value. 00105 int low_link; ///< Lowest df order of myself or my children. 00106 00107 GSAFullRangeData(const Statement &stmt, int timestamp, 00108 GSAFullRangeDict &range_dict, int debug = 0); 00109 GSAFullRangeData(const GSAFullRangeData &other); 00110 virtual inline ~GSAFullRangeData(); 00111 00112 inline int timestamp() const; 00113 ///< Return the timestamp of myself. The timestamp is used to discern 00114 ///< different invocations of GSAFullRangeDict::_get_data_range_ref(), 00115 ///< so as to avoid infinite loops by poisoning GSAFullRangeData objects. 00116 00117 inline const Statement &stmt() const; 00118 ///< Return the statement this object is associated with. 00119 00120 inline const Expression *range_ref() const; 00121 ///< Return the current value for the range for this statement. 00122 00123 inline Expression *grab_range(); 00124 ///< Grab and return the current value for the range for this statement. 00125 00126 bool update(bool in_widening_phase = true); 00127 ///< Update my range and bool state flags using the ranges and 00128 ///< state flags of my phi-function's arguments. 00129 ///< Return true if the update caused a change in my data. 00130 00131 RefSet<GSAFullRangeData> *succs() const; 00132 ///< Return all GSAFullRangeData objects that I am dependent upon 00133 ///< to compute my value and have the same timestamp as myself. 00134 00135 virtual Listable *listable_clone() const; 00136 virtual void print(ostream &o) const; 00137 virtual int structures_OK() const; 00138 ///< Functions required by Listable. 00139 00140 private: 00141 int _timestamp; ///< Timestamp for this object. 00142 const Statement *_stmt_ref; ///< Statement which this workspace belongs to. 00143 RangeAccessor _accessor; ///< Accessor of all ranges for this stmt. 00144 GSAControlRangeDict *_control_ranges_ref; 00145 ///< Control ranges for the program. 00146 Element<Expression> _range; ///< Current computed range for this statement. 00147 int _debug_level; ///< Debug level for this class. 00148 00149 Expression *_arg_full_range(const Symbol &arg); 00150 Expression *_union_args(bool &new_all_args_are_defined); 00151 }; 00152 00153 00154 00155 ///< inline functions 00156 00157 inline 00158 GSARangeOrData::GSARangeOrData(const Expression *range) 00159 { 00160 _is_range = true; 00161 _range_ref = range; 00162 } 00163 00164 inline 00165 GSARangeOrData::GSARangeOrData(GSAFullRangeData &data) 00166 { 00167 _is_range = false; 00168 _data_ref = &data; 00169 } 00170 00171 inline 00172 GSARangeOrData::GSARangeOrData(const GSARangeOrData &other) 00173 { 00174 _is_range = other._is_range; 00175 _range_ref = other._range_ref; 00176 ///< _data_ref = other._data_ref; 00177 } 00178 00179 inline 00180 GSARangeOrData::~GSARangeOrData() 00181 { 00182 ///< Nothing to do. 00183 } 00184 00185 inline bool 00186 GSARangeOrData::is_range() const 00187 { 00188 return _is_range; 00189 } 00190 00191 inline bool 00192 GSARangeOrData::is_data() const 00193 { 00194 return ! _is_range; 00195 } 00196 00197 inline const Expression * 00198 GSARangeOrData::range_ref() const 00199 { 00200 p_assert(_is_range, "GSARangeORData object does not contain a range object."); 00201 return _range_ref; 00202 } 00203 00204 inline GSAFullRangeData & 00205 GSARangeOrData::data() 00206 { 00207 p_assert(! _is_range, "GSARangeORData object does not contain a GSAFullRangeData object."); 00208 return *_data_ref; 00209 } 00210 00211 inline Listable * 00212 GSARangeOrData::listable_clone() const 00213 { 00214 return new GSARangeOrData(*this); 00215 } 00216 00217 inline int 00218 GSARangeOrData::structures_OK() const 00219 { 00220 return 1; 00221 } 00222 00223 inline 00224 GSAFullRangeData::~GSAFullRangeData() 00225 { 00226 ///< Nothing to do 00227 } 00228 00229 inline const Statement & 00230 GSAFullRangeData::stmt() const 00231 { 00232 return *_stmt_ref; 00233 } 00234 00235 inline int 00236 GSAFullRangeData::timestamp() const 00237 { 00238 return _timestamp; 00239 } 00240 00241 inline const Expression * 00242 GSAFullRangeData::range_ref() const 00243 { 00244 return _range.valid() ? &(*_range) : 0; 00245 } 00246 00247 inline Expression * 00248 GSAFullRangeData::grab_range() 00249 { 00250 return _range.valid() ? _range.grab() : 0; 00251 } 00252 00253 #endif 00254 00255 |
||
|