Polaris: JumpFunction.h Source File

JumpFunction.h

Go to the documentation of this file.
00001 ///
00002 #ifndef _JUMP_FUNCTION_H
00003 #define _JUMP_FUNCTION_H
00004 ///
00005 /// file JumpFunction.h
00006 ///
00007 /// \class JumpFunction 
00008 /// \brief Jump function for interprocedural constant propagation
00009 /// \defgroup Polaris
00010 /// \ingroup Polaris
00011 ///  Constant
00012 /// \see JumpFunction.h
00013 /// \see JumpFunction.h
00014 /// \see JumpFunction.cc
00015 ///
00016 /// \endcode
00017 /// \section Overview Overview
00018 /// This class is a map from subroutine parameters or globals to
00019 /// to functions that compute the new values of these parameters or globals.
00020 ///
00021 #include "../Listable.h"
00022 #include "../Collection/RefList.h"
00023 #include "../Collection/Map.h"
00024 #include "../Collection/RefSet.h"
00025 #include "../Symbol/Symbol.h"
00026 #include "../Expression/Expression.h"
00027 ///
00028 class AliasSets;
00029 class IPCPConstants;
00030 
00031 class ReturnJumpFunction : public Listable {
00032 public:
00033     ReturnJumpFunction(const RefList<Symbol> &param_list,
00034                const RefSet<Symbol> &used_global_vars,
00035                        Map<Symbol, Expression> *old_const_mods,
00036                        Map<Symbol, Expression> *new_consts);
00037     ReturnJumpFunction(const ReturnJumpFunction &other);
00038     virtual ~ReturnJumpFunction();
00039 
00040     Map<Symbol, Expression> *const_mods(const List<Expression> &param_values,
00041                     AliasSets &alias_sets) const;
00042     Map<Symbol, Expression> *const_mods(const List<Expression> &param_values) const;
00043     ///< Return a mapping from variables to their new constant values, given
00044     ///< the values of the parameters of the procedure that owns this jump
00045     ///< function.  These new constant values are symbolic expressions
00046     ///< in terms of the original values of the variables of the program.
00047     ///< A non-constant value is represented by an Omega expression.
00048     ///< If a variable is not in the returned mapping, that variable is not
00049     ///< modified.
00050 
00051     Map<Symbol, Expression> *new_consts(const List<Expression> &param_values,
00052                     AliasSets &alias_sets) const;
00053     Map<Symbol, Expression> *new_consts(const List<Expression> &param_values) const;
00054     ///< Return the set of new constants generated by this routine, given
00055     ///< the values of the parameters of the procedure that owns this jump
00056     ///< function.  These new constant values are symbolic expressions
00057     ///< in terms of symbolic global variables live at the current point.
00058 
00059     virtual Listable *listable_clone() const;
00060     virtual void print(ostream &o) const;
00061     virtual int structures_OK() const;
00062     ///< Functions required by Listable.
00063 
00064 protected:
00065     RefList<Symbol> _param_list;  ///< Names of all the procedure's arguments.
00066     RefSet<Symbol> _used_global_vars; ///< Used global variables.
00067 
00068 private:
00069     Map<Symbol, Expression> *_old_const_mods; 
00070                                   ///< Mapping from old constant values to
00071                                   ///< new constant values.
00072     Map<Symbol, Expression> *_new_consts;
00073                                   ///< New symbolic constants created by the
00074                                   ///< routine
00075 
00076     RefSet<Symbol> *_modified_aliases(AliasSets &alias_sets) const;
00077     void _eliminate_modified_aliases(Map<Symbol, Expression> &var_mods,
00078                      AliasSets &alias_sets) const;
00079     void _rename_formals(Map<Symbol, Expression> &var_mods,
00080              const List<Expression> &param_values) const;
00081     Map<Symbol, Expression> *_param_map(const List<Expression> &param_values) const;
00082 };
00083 
00084 class JumpFunction : public ReturnJumpFunction {
00085 public:
00086     JumpFunction(const RefList<Symbol> &param_list,
00087              const RefSet<Symbol> &used_global_vars,
00088                  Map<Symbol, Expression> *old_const_mods,
00089                  Map<Symbol, Expression> *new_consts);
00090     JumpFunction(const JumpFunction &other);
00091     virtual ~JumpFunction();
00092 
00093     IPCPConstants *constants(IPCPConstants &consts,
00094                  const List<Expression> &param_values) const;
00095     ///< Return a new set of constants generated from the given set of
00096     ///< constants and the given actual parameters for the call site.
00097     ///< Note: Externally, the given set of constants is not modified.
00098 
00099     virtual Listable *listable_clone() const;
00100 
00101 private:
00102     List<Expression> *_const_param_values(const Map<Symbol,Expression> &const_map) const;
00103 };
00104 
00105 ///< Description:
00106 ///< Return all the symbols in the given variable mapping.
00107 ///< (Why is this function needed?  Well, there is no KeyMutator class.
00108 ///< So to approximate one, we call this function to determine the
00109 ///< symbols in the map, then iterate over this set of symbols while
00110 ///< updating the map.)
00111 
00112 RefSet<Symbol> *modified_vars(const Map<Symbol, Expression> &var_mods);
00113 
00114 ///< Description:
00115 ///< Substitute all variables in the given expression and in the
00116 ///< substitution mapping with their mapped values.
00117 
00118 Expression *subst_vars_in_expr(Expression *expr,
00119                    const Map<Symbol, Expression> &subst_map);
00120 
00121 ///< Description:
00122 ///< Substitute the given variables in the expressions of the given map.
00123 
00124 void subst_vars_in_map(Map<Symbol, Expression> &var_mods,
00125                const Map<Symbol, Expression> &subst_map);
00126 
00127 #endif
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:05:57 2005