Polaris: AIRangeDict.h Source File

AIRangeDict.h

Go to the documentation of this file.
00001 #ifndef _AI_RANGE_DICT_H
00002 #define _AI_RANGE_DICT_H
00003 ///
00004 /// file AIRangeDict.h
00005 ///
00006 /// \class AIRangeDict 
00007 /// \brief Collection of ranges that were generated by abstract interpretation
00008 /// \defgroup Polaris
00009 /// \ingroup Polaris
00010 ///  Range
00011 /// \see AIRangeDict.h
00012 /// \see AIRangeDict.h
00013 /// \see AIRangeDict.cc
00014 ///
00015 /// \endcode
00016 /// \section Overview Overview
00017 /// A AIRangeDict object is a repository for variable
00018 /// ranges for a program unit.  AI stands for Abstract Interpretation,
00019 /// which is the method used to generate these ranges from the given
00020 /// program unit.
00021 ///
00022 /// \endcode
00023 /// \section Description Description
00024 /// A AIRangeDict object is a repository of the variable ranges
00025 /// for all points of a program unit.  Abstract interpretation is
00026 /// used to compute these ranges.  Abstract interpretation is a
00027 /// generalization of data flow analysis techniques.  It computes the
00028 /// ranges by "executing" the given program unit at compile time,
00029 /// by following the control flow paths of the program, updating the
00030 /// current ranges to reflect the side effects of the statements
00031 /// encountered along these paths, until a fixed point is reached.
00032 /// See Blume and Eigenmann, "Symbolic Range Propagation", for more
00033 /// details.
00034 ///
00035 /// The computed ranges are stored in a collection of StmtRanges
00036 /// objects.  Each StmtRanges object holds all the variable constraints
00037 /// for a single Statement in the program.  
00038 ///
00039 /// \endcode
00040 /// \section Switches Switches
00041 /// By setting "range_block" to 1, the AIRangeDict constructor
00042 /// would automatically clear all ranges whenever it sees a BEGIN
00043 /// BLOCK or END BLOCK assertion when it is computing ranges.
00044 /// This switch should approximate the ranges computed for uninlined
00045 /// programs when run on a partially or fully inlined program.
00046 /// Basically, this switch causes the AIRangeDict to compute less
00047 /// accurate ranges for the sake of speed and memory used.
00048 ///
00049 /// Setting switch "pc_call_mods" to 1 causes the AIRangeDict
00050 /// constructor to assume that subroutine and function calls only
00051 /// modify thier arguments.  That is, global varaibles and subroutine
00052 /// parameters are assumed to be unmodified by a subroutine call unless
00053 /// they also appear in that call's arguments.  Results in more
00054 /// accurate ranges.  May also result in incorrect ranges, if this
00055 /// assumption does not hold in actuality.
00056 ///
00057 /// \endcode
00058 /// \section Known Known bugs or limitations
00059 /// AIRangeDict objects can consume large amounts of time and large
00060 /// amounts of memory.  This is because the time and space requirements
00061 /// are O(V*S), where S is the number of statements in a program and
00062 /// V is the number of integer variables in a program.  (In actuality,
00063 /// V can be improved to be the average number of integer variables
00064 /// that have constraints.)
00065 ///
00066 #include "../Collection/Database.h"
00067 #include "../String.h"
00068 ///
00069 #include "RangeDict.h"
00070 #include "StmtRanges.h"
00071 ///
00072 class AIRangeDict : public RangeDict {
00073 friend class AbstractAccess;
00074 public:
00075     AIRangeDict(ProgramUnit &pgm, int debug = 0);
00076     AIRangeDict(const AIRangeDict &other);
00077     virtual ~AIRangeDict();
00078 
00079     virtual AIRangeDict &operator = (const AIRangeDict &other);
00080     ///< Completely copy the contents of the other range dictionary
00081     ///< into myself.
00082 
00083     RefSet<Symbol> *range_vars(const String & tag) const;
00084     ///< Return the set of variables that have ranges for a 
00085     ///< particular statement.
00086 
00087     virtual StmtRanges & _s_ranges(const String & tag);
00088     ///< Return a reference to the StmtRanges object associated with
00089     ///< the given statement tag.
00090 
00091     Expression * elim_known_facts(const String &, Expression *);
00092     ///< Accept a statement tag and a conditional expression
00093     ///< and use the range dictionary attached to the Statement
00094     ///< to eliminate tests from the conditional which are 
00095     ///< known to be true within the dictionary.  Works for 
00096     ///< Fortran logical operators (.LE., .GT., etc) and for 
00097     ///< MIN and MAX.
00098 
00099     virtual void print(ostream & o) const;
00100     ///< Print out the range dictionary.  This operation is
00101     ///< essentially just a dump of the data structures of the
00102     ///< range dictionary.
00103 
00104     virtual void pretty_print(ostream & o, const Statement &stmt) const;
00105     ///< Print out the range dictionary in a more user-readable
00106     ///< manner.
00107 
00108     virtual Listable *listable_clone(void) const;
00109     virtual int structures_OK() const;
00110     ///< Methods required by Listable
00111 
00112 protected:
00113     virtual void _set_range(const Symbol &var, const Statement &stmt,
00114                     Expression *range);
00115     ///< Set the given variable to the given range.
00116   
00117     virtual void _del_range(const Symbol &var, const Statement &stmt);
00118     ///< Delete the range associated with the given variable.
00119 
00120     virtual const Expression *_get_range_ref(const Symbol &var,
00121                                  const Statement &stmt);
00122     ///< Return the range associated with the given variable.  If the
00123     ///< variable doesn't have an associated range, return 0;
00124 
00125 private:
00126     Database<String,StmtRanges> _stmt_ranges;
00127 
00128     void _add_safe_cond_ranges(const ProgramUnit &pgm);
00129 
00130     void _generate_map(const ProgramUnit &pgm);
00131 
00132 };
00133 
00134 #endif
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:05:36 2005