Polaris: SSAFullRangeData.h Source File

SSAFullRangeData.h

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