| Polaris: RangeDict.h Source File | ||
|
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members
RangeDict.hGo to the documentation of this file.00001 #ifndef _RANGE_DICT_H 00002 #define _RANGE_DICT_H 00003 /// 00004 /// file RangeDict.h 00005 /// 00006 /// \class RangeDict 00007 /// \brief Collection of ranges for entire program 00008 /// \defgroup Polaris 00009 /// \ingroup Polaris 00010 /// Range 00011 /// \see RangeDict.h 00012 /// \see RangeDict.h 00013 /// \see RangeDict.cc 00014 /// 00015 /// \endcode 00016 /// \section Overview Overview 00017 /// A RangeDict object is the main repository for variable 00018 /// ranges for a program units. Range dictionaries are 00019 /// responsible for holding the variable ranges for each statement 00020 /// in the given program unit. They are also responsible for 00021 /// generating these ranges. 00022 /// 00023 /// \endcode 00024 /// \section Description Description 00025 /// A RangeDict object is a repository of the variable constraints 00026 /// for all points of a program unit. However, it does not offer any 00027 /// public interface for accessing these constraints. Instead, 00028 /// such accesses are done through RangeAccessor objects. 00029 /// RangeAccessor objects also provide methods to perform 00030 /// comparisons using the constraints in a RangeDict object. 00031 /// See RangeAccessor.h for more details. 00032 /// 00033 /// RangeDict objects are an abstract class. Subclasses must 00034 /// implement the data structures that hold these constraints, and 00035 /// provide a Constructor that determines these constraints from a 00036 /// program unit. 00037 /// 00038 /// Essentially, a RangeDict object is expected to be a mapping 00039 /// between (variable/statement) pairs and symbolic lower bound, upper 00040 /// bound pairs called ranges (see RangeExpr). If a variable V has the 00041 /// range [L:U], then the constraint L <= V <= U holds for variable V. 00042 /// A variable can have at most one range. If a variable does not have 00043 /// a range, it is assumed that there are no constraints for that 00044 /// variable. Mapping a variable V to an expression E is equivalent to 00045 /// assigning it the range [E:E]. Mapping a variable V to an omega 00046 /// expression is equivalent to assigning it to the unconstrained range 00047 /// [-Infty:Infty], which is equivalent to deleting the variable from 00048 /// the RangeDict. 00049 /// 00050 #include "../Listable.h" 00051 #include "../Symtab.h" 00052 #include "../Collection/RefSet.h" 00053 /// 00054 class Statement; 00055 class Symbol; 00056 class Expression; 00057 class StmtList; 00058 class StmtRanges; 00059 00060 class RangeDict : public Listable { 00061 friend class RangeAccessor; 00062 friend class AbstractAccess; 00063 public: 00064 RangeDict(Symtab &symtab); 00065 RangeDict(const RangeDict &other); 00066 virtual ~RangeDict(); 00067 00068 virtual RangeDict &operator = (const RangeDict &other); 00069 ///< Completely copy the contents of the other range dictionary 00070 ///< into myself. 00071 00072 const Symtab &symtab() const; 00073 ///< Return the symbol table associated with myself 00074 00075 virtual StmtRanges & _s_ranges(String & tag); 00076 ///< Return a reference to the StmtRanges object associated with 00077 ///< the given statement tag. 00078 00079 virtual void pretty_print(ostream & out, 00080 const Statement &stmt) const = 0; 00081 virtual void pretty_print(ostream & out, 00082 const StmtList &stmts) const; 00083 ///< Print out the range dictionary in a more user-readable 00084 ///< manner. 00085 00086 protected: 00087 virtual void _set_range(const Symbol &var, const Statement &stmt, 00088 Expression *range) = 0; 00089 ///< Set the given variable to the given range. 00090 00091 virtual void _del_range(const Symbol &var, const Statement &stmt) = 0; 00092 ///< Delete the range associated with the given variable. 00093 00094 virtual const Expression *_get_range_ref(const Symbol &var, 00095 const Statement &stmt) = 0; 00096 ///< Return the range associated with the given variable. If the 00097 ///< variable doesn't have an associated range, return 0; 00098 00099 private: 00100 Symtab *_symtab_ref; ///< Symbol table of program unit. 00101 00102 void _add_intrinsic(const char *intrin_name); 00103 }; 00104 00105 #endif |
||
|