Polaris: GSAFullRangeDict.h Source File

GSAFullRangeDict.h

Go to the documentation of this file.
00001 #ifndef _GSA_FULL_RANGE_DICT_H
00002 #define _GSA_FULL_RANGE_DICT_H
00003 ///
00004 /// file GSAFullRangeDict.h
00005 ///
00006 /// \class GSAFullRangeDict 
00007 /// \brief Collection of ranges extracted from GSA program's control flow
00008 /// \defgroup Polaris
00009 /// \ingroup Polaris
00010 ///  Range
00011 /// \see GSAFullRangeDict.h
00012 /// \see GSAFullRangeDict.h
00013 /// \see GSAFullRangeDict.cc
00014 ///
00015 /// \endcode
00016 /// \section Overview Overview
00017 /// An GSAFullRangeDict object is a repository for variable
00018 /// ranges for a program unit in GSA form.  Ranges derived from
00019 /// both data flow and control flow are collected, (unlike
00020 /// GSAControlRangeDict.h).
00021 ///
00022 /// \endcode
00023 /// \section Description Description
00024 /// An GSAFullRangeDict object is a repository of the variable
00025 /// ranges for all points of a program unit in GSA form.  These ranges
00026 /// are extracted from the data flow and control flow of the program;
00027 /// that is, they are taken from IF conditional tests, DO statements,
00028 /// and CSRD$ ASSERT statements, assignment statements, and phi
00029 /// statements.
00030 ///
00031 /// GSAFullRangeDict objects are demand-driven.  That is, they
00032 /// compute the ranges for a particular statement only when they
00033 /// are asked for.  If instead, the user wishes to have all the
00034 /// program unit's ranges to be computed at once, the user can
00035 /// call the touch() method..
00036 ///
00037 /// The algorithm for computing the ranges of a program on demand
00038 /// using GSA form can be found in Blume and Eigenmann, "Demand-
00039 /// Driven Symbolic Range Propagation".
00040 ///
00041 #ifdef POLARIS_GNU_PRAGMAS
00042 #pragma interface
00043 #endif
00044 ///
00045 #include "../Collection/Map.h"
00046 #include "../Collection/RefMap.h"
00047 #include "../Collection/Database.h"
00048 #include "../Symbol/Symbol.h"
00049 #include "../Expression/Expression.h"
00050 #include "../Statement/Statement.h"
00051 #include "../Array.h"
00052 #include "../String.h"
00053 #include "../IntElem.h"
00054 ///
00055 #include "RangeDict.h"
00056 #include "GSAControlRangeDict.h"
00057 #include "GSAFullRangeData.h"
00058 #include "ExprSet.h"
00059 ///
00060 class IntSet;
00061 
00062 class GSAFullRangeDict : public RangeDict {
00063     friend class GSAFullRangeData;
00064 public:
00065     GSAFullRangeDict(ProgramUnit &pgm, int debug = 0);
00066     virtual ~GSAFullRangeDict();
00067 
00068     void touch();
00069     ///< Force this object to compute the ranges for each statement
00070     ///< in the program unit.
00071 
00072     void control_touch();
00073     ///< Force this object to compute the ranges for each statement
00074     ///< in the program unit.  Only ranges derived from control flow
00075     ///< is touched.
00076 
00077     void data_touch();
00078     ///< Force this object to compute the ranges for each statement
00079     ///< in the program unit.  Only ranges derived from data flow
00080     ///< is touched.  (However, touching these data ranges may
00081     ///< cause some control ranges to be computed.)
00082 
00083     void clear();
00084     ///< Clear all saved data and control ranges stored within myself.
00085 
00086     void clear_ranges();
00087     ///< Clear all saved data and control ranges stored within myself.
00088     ///< Like clear() except some control range information is still
00089     ///< kept.
00090 
00091     GSAControlRangeDict &control_range_dict();
00092     ///< Return my control range dictionary.
00093 
00094     int num_data_ranges() const;
00095     ///< Return the number of data ranges created since my construction
00096     ///< or the last call to clear().
00097 
00098     int num_poisoned_ranges() const;
00099     ///< Return the number of poisoned ranges created during the
00100     ///< last invocation of _get_range_ref().
00101 
00102     virtual void print(ostream & o) const;
00103     ///< Print out the range dictionary.  This operation is
00104     ///< essentially just a dump of the data structures of the
00105     ///< range dictionary.
00106 
00107     virtual void pretty_print(ostream & o, const Statement &stmt) const;
00108     ///< Print out the range dictionary in a more user-readable
00109     ///< manner.
00110 
00111     virtual Listable *listable_clone(void) const;
00112     virtual int structures_OK() const;
00113     ///< Methods required by Listable
00114 
00115 protected:
00116     virtual void _set_range(const Symbol &var, const Statement &stmt,
00117                     Expression *range);
00118     ///< Not implemented.  Will p_assert if called.
00119 
00120     virtual void _del_range(const Symbol &var, const Statement &stmt);
00121     ///< Not implemented.  Will p_assert if called.
00122 
00123     virtual const Expression *_get_range_ref(const Symbol &var,
00124                                  const Statement &stmt);
00125     ///< Return the range associated with the given variable.  If the
00126     ///< variable doesn't have an associated range, return 0;
00127 
00128 private:
00129     ProgramUnit *_pgm_ref;      ///< Program unit for this range dict.
00130     Database<String, IntElem> *_stmt_toporder;
00131                                 ///< Topological ordering of the pgm's stmts.
00132     ExprSet _range_values;      ///< All the values that ranges may take.
00133     Map<Statement, RefMap<Symbol, Expression> > _pgm_ranges;
00134                                 ///< Variable ranges for each statement
00135                                 ///< in the program.
00136     GSAControlRangeDict _control_ranges;
00137                                 ///< The control ranges of the program.
00138     Map<Symbol, Expression> _data_ranges;
00139                                 ///< Data ranges holding for each statement.
00140     ExprSet _poisoned_ranges;
00141                                 ///< Poisoned ranges holding for each
00142                                 ///< statement.  Used only as a receptacle
00143                                 ///< for ownership of the poisoned ranges,
00144                                 ///< which are temporary.
00145     Map<Symbol, GSAFullRangeData> _pending_ranges;
00146                                 ///< Info on ranges currently being computed.
00147     int _timestamp;             ///< Timestamp indicating current invocation
00148                                 ///< of _get_data_range_ref().
00149     int _num_poisoned_ranges;   ///< Number of poisoned ranges created
00150                 ///< during last call to _get_range_ref.
00151 
00152     const Expression &_ins_data_range(const Symbol &var, Expression *range);
00153     void _order_args(GSAFullRangeData &data) const;
00154     GSAFullRangeData *_create_data(const Statement &stmt, int &df_num,
00155                                    RefList<GSAFullRangeData> &scc_node_stack);
00156     void _mark_data_as_computed(GSAFullRangeData &data);
00157     void _commit_data(GSAFullRangeData &data);
00158     void _delete_data(GSAFullRangeData &data);
00159     GSARangeOrData _probe_data_ranges(const Symbol &var, int &df_num,
00160                                       RefList<GSAFullRangeData> &scc_node_stack);
00161     void _calc_iter_order1(GSAFullRangeData &data,
00162                            RefList<GSAFullRangeData> &iter_order_list);
00163     Array<GSAFullRangeData *> *_calc_iter_order(GSAFullRangeData &root_node);
00164     void _iterate_to_fixed_point_phase(const Array<GSAFullRangeData *> &toporder_to_stmt,
00165                                        const IntSet &start_stmts,
00166                                        bool widening_phase);
00167     void _iterate_to_fixed_point(GSAFullRangeData &root_node);
00168     const Expression *_get_data_range_ref(const Symbol &var,
00169                                           bool &is_poisoned);
00170 };
00171 
00172 #endif
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:05:54 2005