Polaris: IPCPConstants.h Source File

IPCPConstants.h

Go to the documentation of this file.
00001 ///
00002 #ifndef _IPCP_CONSTANTS_H
00003 #define _IPCP_CONSTANTS_H
00004 ///
00005 /// file IPCPConstants.h
00006 ///
00007 /// \class IPCPConstants 
00008 /// \brief Holds the constants for the entry of a single proc.
00009 /// \defgroup Polaris
00010 /// \ingroup Polaris
00011 ///  Constant
00012 /// \see IPCPConstants.h
00013 /// \see IPCPConstants.h
00014 ///
00015 /// \endcode
00016 /// \section Overview Overview
00017 /// This class holds all parameter and global constants at the entry of
00018 /// a single program unit.
00019 ///
00020 #include "../Listable.h"
00021 #include "../Collection/Map.h"
00022 #include "../Collection/Set.h"
00023 #include "../Collection/RefSet.h"
00024 #include "../Symbol/Symbol.h"
00025 #include "../Expression/Expression.h"
00026 #include "../String.h"
00027 #include "../Array.h"
00028 ///
00029 class AliasSets;
00030 class IPCPConstants;
00031 class IPCPProcData;
00032 
00033 class CallSite : public Listable {
00034 public:
00035     CallSite(const IPCPConstants *caller_consts_ref, const char *call_tag);
00036     CallSite(const CallSite &other);
00037     virtual ~CallSite();
00038 
00039     inline const IPCPConstants *caller_consts_ref() const;
00040     ///< Return the set of constants for the calling routine.
00041 
00042     inline const String &call_tag() const;
00043     ///< Return the statement tag of the call site in the calling
00044     ///< routine.
00045 
00046     virtual Listable *listable_clone() const;
00047     virtual void print(ostream &o) const;
00048     virtual int structures_OK() const;
00049     ///< Functions required by Listable.
00050 
00051 private:
00052     const IPCPConstants *_caller_consts_ref;
00053     String _call_tag;
00054 };
00055 
00056 class IPCPConstants : public Listable {
00057 public:
00058     IPCPProcData *proc_data_ref; ///< Reference to the IPCPProcData object
00059                  ///< that owns me.
00060 
00061     IPCPConstants();
00062     IPCPConstants(Map<Symbol, Expression> *constants, AliasSets *alias_sets);
00063     IPCPConstants(const IPCPConstants &other);
00064     virtual ~IPCPConstants();
00065 
00066     int operator == (const IPCPConstants &other) const;
00067     inline int operator != (const IPCPConstants &other) const;
00068     ///< Return true (false) if my constant values equals the other
00069     ///< object's constant values.
00070 
00071     inline const Map<Symbol,Expression> &constants() const;
00072     ///< Return the set of constants.
00073 
00074     inline AliasSets &alias_sets();
00075     ///< Return the sets of aliased variables associated with
00076     ///< this set of constants.
00077 
00078     inline const Set<CallSite> &invocation_sites() const;
00079     ///< Return the call sites of all routines that called the procedure
00080     ///< that produced my set of constants.
00081 
00082     void add_invocation_site(CallSite *invocation_site);
00083     ///< Add the given call site to the set of invocation sites.
00084 
00085     void merge_invocation_sites(IPCPConstants *other);
00086     ///< Merge all the invocation sites in the other object with
00087     ///< my invocation sites, then delete the other object.
00088 
00089     void filter_out_vars_not_in_set(const RefSet<Symbol> &keepable_lhs_vars,
00090                     const RefSet<Symbol> &keepable_rhs_vars);
00091     ///< Remove any constants for variables in the set or whose
00092     ///< constant expressions contains variables not in the sets.
00093 
00094     virtual void print(ostream &o) const;
00095     ///< Print out all fields in my object.
00096 
00097     virtual void print_constants(ostream &o) const;
00098     ///< Print out the set of constants stored within myself.
00099 
00100     virtual Listable *listable_clone() const;
00101     virtual int structures_OK() const;
00102     ///< Functions required by Listable.
00103 
00104 private:
00105     Map<Symbol,Expression> *_constants;
00106     AliasSets *_alias_sets;
00107     Set<CallSite> _invocation_sites;
00108     IPCPProcData *_proc_data;
00109 
00110     void _add_used_vars_to_set(RefSet<Symbol> &vars,
00111                    const Expression &expr);
00112     void _const_order1(Map<Symbol,IntElem> &const_order,
00113                int &num_labeled_consts, const Symbol &var) const;
00114     void _const_order1(Map<Symbol,IntElem> &const_order,
00115                int &num_labeled_consts, const Expression &expr) const;
00116 };
00117 
00118 
00119 ///< inline implementations
00120 
00121 
00122 inline const IPCPConstants *
00123 CallSite::caller_consts_ref() const
00124 {
00125     return _caller_consts_ref;
00126 }
00127 
00128 inline const String &
00129 CallSite::call_tag() const
00130 {
00131     return _call_tag;
00132 }
00133 
00134 inline int
00135 IPCPConstants::operator != (const IPCPConstants &other) const
00136 {
00137     return ! (*this == other);
00138 }
00139 
00140 inline const Map<Symbol,Expression> &
00141 IPCPConstants::constants() const
00142 {
00143     return *_constants;
00144 }
00145 
00146 inline AliasSets &
00147 IPCPConstants::alias_sets()
00148 {
00149     return *_alias_sets;
00150 }
00151 
00152 inline const Set<CallSite> &
00153 IPCPConstants::invocation_sites() const
00154 {
00155     return _invocation_sites;
00156 }
00157 
00158 #endif
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:05:56 2005