Polaris: PropRangeWS.h Source File

PropRangeWS.h

Go to the documentation of this file.
00001 #ifndef _PROP_RANGE_WS_H
00002 #define _PROP_RANGE_WS_H
00003 ///
00004 /// file PropRangeWS.h
00005 ///
00006 /// \class PropRangeWS 
00007 /// \brief WorkSpace for propagate ranges
00008 /// \defgroup Polaris
00009 /// \ingroup Polaris
00010 ///  Range
00011 /// \see PropRangeWS.h
00012 /// \see PropRangeWS.h
00013 /// \see PropRangeWS.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 AIRangesDict Constructor.
00019 ///
00020 #include "../WorkSpace.h"
00021 #include "../Symbol/Symbol.h"
00022 #include "../Statement/Statement.h"
00023 #include "../Collection/List.h"
00024 #include "../Collection/RefSet.h"
00025 ///
00026 #include "PropRangeEdge.h"
00027 #include "StmtRanges.h"
00028 ///
00029 class PropRangeWS : public WorkSpace {
00030 public:
00031     PropRangeWS(unsigned long pass_tag, const Statement &stmt);
00032     PropRangeWS(const PropRangeWS &other);
00033     virtual ~PropRangeWS();
00034 
00035     inline RefSet<Symbol> &mod_set() const;
00036     ///< Return the set of variables modified by this statement.
00037 
00038     inline const RefSet<Symbol> *loop_variants_ref() const;
00039     void loop_variants(RefSet<Symbol> *lv);
00040     ///< Access the set of variables that vary within the body of this
00041     ///< loop.
00042 
00043     inline int num_visits() const;
00044     ///< Return the number of visits made to this WorkSpace's Statement
00045     ///< by the iterative portion of the constant propagation pass.
00046 
00047     inline void incr_num_visits();
00048     ///< Increment the number of visits by one.
00049 
00050     inline RefSet<PropRangeEdge> &pred() const;
00051     ///< Return the predecessors in the flow graph of this WorkSpace's
00052     ///< Statement.  This set should be a superset of the statement's
00053     ///< pred set.
00054 
00055     inline List<PropRangeEdge> &succ() const;
00056     ///< Return the successors in the flow graph of this WorkSpace's
00057     ///< Statement.  This set should be a superset of the statement's
00058     ///< succ set.  Unlike the pred operator, the workspace owns its
00059     ///< successor edges.
00060 
00061     inline bool needs_widening() const;
00062     inline void needs_widening(bool nw);
00063     ///< Reference the needs_widening field.  Should be set to true if
00064     ///< the Workspace's constraint dictionary may eventually need to
00065     ///< have the widening operator applied to it.
00066 
00067     inline bool use_widener() const;
00068     inline void use_widener(bool uw);
00069     ///< Reference the use_widener field.  Should be set to true if
00070     ///< the Workspace's constraint dictionary must have the widening
00071     ///< operator applied to it.  (use_widener == true should imply
00072     ///< needs_widening == true)
00073 
00074     inline StmtRanges *ranges_ref() const;
00075     inline StmtRanges *grab_ranges();
00076     void ranges(StmtRanges *c);
00077     ///< Access the Workspace's constraint dictionary.  The ranges
00078     ///< in this dictionary is valid just before WorkSpace's statement
00079     ///< is executed.
00080 
00081     inline bool visited() const;
00082     inline void visited(bool v);
00083     ///< Reference the visited field.  Has no relation to num_visits.
00084 
00085     inline int toporder() const;
00086     inline void toporder(int val);
00087     ///< Reference the toporder field.
00088 
00089     inline virtual Listable *listable_clone() const;
00090     virtual void print(ostream &o) const;
00091     virtual int structures_OK() const;
00092     ///< Functions required by Listable.
00093 
00094 private:
00095     RefSet<Symbol> _mod_set;     ///< Set of variables that are modified.
00096     RefSet<Symbol> *_loop_variants; ///< Set of variant vars for this loop.
00097     StmtRanges *_ranges;     ///< Mapping of vars to their ranges
00098     RefSet<PropRangeEdge> _pred; ///< Predecessor in the flow graph
00099     List<PropRangeEdge> _succ;   ///< Successors in the flow graph
00100     int _num_visits;         ///< Number of visits made to this node.
00101     bool _visited;       ///< True if visited by _calc_rpostorder
00102     int _toporder;       ///< Reverse topological sort ordering
00103     bool _needs_widening;    ///< Ranges eventually needs widener
00104     bool _use_widener;   ///< Use widener on ranges
00105 
00106     void _add_to_mod_set(const RefSet<Expression> &refs);
00107 };
00108 
00109 
00110 ///< inline functions
00111 
00112 inline RefSet<Symbol> &
00113 PropRangeWS::mod_set() const
00114 {
00115     return (RefSet<Symbol> &) _mod_set;
00116 }
00117 
00118 inline const RefSet<Symbol> *
00119 PropRangeWS::loop_variants_ref() const
00120 {
00121     return _loop_variants;
00122 }
00123 
00124 inline int
00125 PropRangeWS::num_visits() const
00126 {
00127     return _num_visits;
00128 }
00129 
00130 inline void
00131 PropRangeWS::incr_num_visits()
00132 {
00133     ++_num_visits;
00134 }
00135 
00136 inline RefSet<PropRangeEdge> &
00137 PropRangeWS::pred() const
00138 {
00139     return (RefSet<PropRangeEdge> &) _pred;
00140 }
00141 
00142 inline List<PropRangeEdge> &
00143 PropRangeWS::succ() const
00144 {
00145     return (List<PropRangeEdge> &) _succ;
00146 }
00147 
00148 inline bool
00149 PropRangeWS::visited() const
00150 {
00151     return _visited;
00152 }
00153 
00154 inline void
00155 PropRangeWS::visited(bool v)
00156 {
00157     _visited = v;
00158 }
00159 
00160 inline bool
00161 PropRangeWS::needs_widening() const
00162 {
00163     return _needs_widening;
00164 }
00165 
00166 inline void
00167 PropRangeWS::needs_widening(bool nw)
00168 {
00169     _needs_widening = nw;
00170 }
00171 
00172 inline bool
00173 PropRangeWS::use_widener() const
00174 {
00175     return (int) _use_widener && (int) _needs_widening;
00176 }
00177 
00178 inline void
00179 PropRangeWS::use_widener(bool uw)
00180 {
00181     _use_widener = uw;
00182 }
00183 
00184 inline int
00185 PropRangeWS::toporder() const
00186 {
00187     return _toporder;
00188 }
00189 
00190 inline void
00191 PropRangeWS::toporder(int val)
00192 {
00193     _toporder = val;
00194 }
00195 
00196 inline StmtRanges *
00197 PropRangeWS::ranges_ref() const
00198 {
00199     return (StmtRanges *) _ranges;
00200 }
00201 
00202 inline StmtRanges *
00203 PropRangeWS::grab_ranges()
00204 {
00205     StmtRanges *c = _ranges;
00206     _ranges = 0;
00207     return c;
00208 }
00209 
00210 inline Listable *
00211 PropRangeWS::listable_clone() const
00212 {
00213     return new PropRangeWS(*this);
00214 }
00215 
00216 #endif
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:06:03 2005