| Polaris: SSAControlRangeDict.h Source File | ||
|
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members
SSAControlRangeDict.hGo to the documentation of this file.00001 #ifndef _SSA_CONTROL_RANGE_DICT_H 00002 #define _SSA_CONTROL_RANGE_DICT_H 00003 /// 00004 /// file SSAControlRangeDict.h 00005 /// 00006 /// \class SSAControlRangeDict 00007 /// \brief Collection of ranges extracted from SSA program's control flow 00008 /// \defgroup Polaris 00009 /// \ingroup Polaris 00010 /// Range 00011 /// \see SSAControlRangeDict.h 00012 /// \see SSAControlRangeDict.h 00013 /// \see SSAControlRangeDict.cc 00014 /// 00015 /// \endcode 00016 /// \section Overview Overview 00017 /// An SSAControlRangeDict object is a repository for variable 00018 /// ranges for a program unit in SSA form. Only those ranges that 00019 /// originate from FORTRAN control flow statements are collected. 00020 /// 00021 /// \endcode 00022 /// \section Description Description 00023 /// An SSAControlRangeDict object is a repository of the variable 00024 /// ranges for all points of a program unit in SSA form. These ranges 00025 /// are extracted from the control flow statements of the program; 00026 /// that is, they are taken from IF conditional tests, DO statements, 00027 /// and CSRD$ ASSERT statements. 00028 /// 00029 /// SSAControlRangeDict objects are demand-driven. That is, they 00030 /// compute the ranges for a particular statement only when they 00031 /// are asked for. If instead, the user wishes to have all the 00032 /// program unit's ranges to be computed at once, the user can 00033 /// call the touch() method. 00034 /// 00035 /// The algorithm for computing the ranges of a program on demand 00036 /// using SSA form can be found in Blume and Eigenmann, "Demand- 00037 /// Driven Symbolic Range Propagation". 00038 /// 00039 #include "Collection/Map.h" 00040 #include "Statement/Statement.h" 00041 /// 00042 #include "RangeDict.h" 00043 #include "SSAControlRangeData.h" 00044 #include "ExprSet.h" 00045 /// 00046 class Symbol; 00047 class Expression; 00048 class StmtRefRanges; 00049 class SSAProgramUnit; 00050 00051 class SSAControlRangeDict : public RangeDict { 00052 public: 00053 SSAControlRangeDict(SSAProgramUnit &pgm, int debug = 0); 00054 virtual ~SSAControlRangeDict(); 00055 00056 void touch(); 00057 ///< Force this object to compute the ranges for each statement 00058 ///< in the program unit. 00059 00060 void icdom_touch(); 00061 ///< Force each SSAControlRangeData object within myself to compute 00062 ///< its immediate control dominator. Not meant for external use. 00063 00064 const Statement &representative_stmt(const Statement &stmt) const; 00065 ///< Return a statement that has the same control ranges 00066 ///< as the given statement. 00067 00068 RefSet<Symbol> *range_vars(const Statement &stmt) const; 00069 ///< Return the set of variables that have constraints for the given 00070 ///< statement. 00071 00072 void stats(float &avg_num_icdoms, int &max_num_icdoms, int &tot_num_icdoms, 00073 float &avg_num_ranges, int &max_num_ranges, int &tot_num_ranges); 00074 ///< Compute statistics on the number of icdoms and the number of 00075 ///< computed ranges for each statement. 00076 00077 int num_computed_ranges() const; 00078 ///< Return the number of ranges that this object has computed so far. 00079 ///< This number is the sum of the number of ranges in each 00080 ///< range dictionary attached to an exiting control-flow edge. 00081 00082 void clear(); 00083 ///< Delete all saved information within myself for each of program's 00084 ///< statements. This would force myself 00085 ///< to recompute any ranges asked for in the future. 00086 00087 void clear_ranges(); 00088 ///< Delete all saved ranges within myself. This would force myself 00089 ///< to recompute any ranges asked for in the future. 00090 00091 virtual void print(ostream & o) const; 00092 ///< Print out the range dictionary. This operation is 00093 ///< essentially just a dump of the data structures of the 00094 ///< range dictionary. 00095 00096 virtual void pretty_print(ostream & o, const Statement &stmt) const; 00097 ///< Print out the range dictionary in a more user-readable 00098 ///< manner. 00099 00100 virtual Listable *listable_clone(void) const; 00101 virtual int structures_OK() const; 00102 ///< Methods required by Listable 00103 00104 protected: 00105 virtual void _set_range(const Symbol &var, const Statement &stmt, 00106 Expression *range); 00107 ///< Not implemented. Will p_assert if called. 00108 00109 virtual void _del_range(const Symbol &var, const Statement &stmt); 00110 ///< Not implemented. Will p_assert if called. 00111 00112 virtual const Expression *_get_range_ref(const Symbol &var, 00113 const Statement &stmt) ; 00114 ///< Return the range associated with the given variable. If the 00115 ///< variable doesn't have an associated range, return 0; 00116 00117 private: 00118 SSAProgramUnit *_pgm_ref; ///< Reference to my program unit. 00119 Map<Statement, SSAControlRangeData> _stmt_ranges; 00120 ///< Ranges holding for each statement. 00121 ExprSet _range_set; ///< All the ranges used in the program 00122 00123 void _init_stmt_ranges(ProgramUnit &pgm); 00124 void _init_idom(ProgramUnit &pgm); 00125 }; 00126 00127 #endif |
||
|