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