ParamBindings.hpp

Go to the documentation of this file.
00001 
00016 #ifndef ParamBindings_h
00017 #define ParamBindings_h
00018 
00019 #include <iostream>
00020 #include <map>
00021 
00022 #include <OpenAnalysis/IRInterface/IRHandles.hpp>
00023 #include <OpenAnalysis/Utils/GenOutputTool.hpp>
00024 #include <OpenAnalysis/OABase/Annotation.hpp>
00025 #include <OpenAnalysis/ExprTree/ExprTree.hpp>
00026 
00027 namespace OA {
00028   namespace DataFlow {
00029 
00030 class ParamBindings : public virtual Annotation {
00031 public:
00032   ParamBindings() { }
00033   ~ParamBindings() {}
00034 
00036   MemRefHandle getCallerMemRef(CallHandle call, SymHandle calleeFormal);
00037 
00039   OA_ptr<MemRefHandleIterator> getActualIterator(CallHandle call);
00040 
00042   SymHandle getCalleeFormal(CallHandle call, MemRefHandle callerRef,
00043                             ProcHandle callee);
00044 
00046   OA_ptr<SymHandleIterator> getFormalIterator(ProcHandle proc);
00047 
00049   //bool isRefParam(SymHandle formal);
00050 
00052   OA_ptr<ExprHandleIterator> getActualExprHandleIterator(CallHandle call);
00053 
00055   OA_ptr<ExprTree> getActualExprTree(ExprHandle expr);
00056 
00058   ExprHandle getActualExprHandle(CallHandle call, SymHandle formal);
00059 
00060   //*****************************************************************
00061   // Output
00062   //*****************************************************************
00063   void output(IRHandlesIRInterface& ir);
00064 
00066   void dump(std::ostream& os, OA_ptr<IRHandlesIRInterface> ir);
00067   
00068   //*****************************************************************
00069   // Construction methods 
00070   //*****************************************************************
00071   void mapMemRefToFormal(CallHandle call, MemRefHandle ref, 
00072                          ProcHandle callee, SymHandle sym);
00073   //void setRefParam(SymHandle sym);
00074   void mapFormalToProc(SymHandle formal, ProcHandle proc);
00075   //void mapActualToCall(MemRefHandle actual, CallHandle call);
00076 
00077   void mapCallToExprList(CallHandle call,OA_ptr<std::list<ExprHandle> > elist);
00078   void mapExprToTree(ExprHandle act_expr, OA_ptr<ExprTree> etree);
00079   void mapFormalToExpr(CallHandle call, SymHandle formal, ExprHandle act_expr);
00080 
00081 private:
00082   OUTPUT
00083 
00084   GENOUT std::map<CallHandle,std::map<ProcHandle,std::map<MemRefHandle,SymHandle> > > 
00085       mCallerToCalleeMap;
00086   GENOUT std::map<CallHandle,std::map<SymHandle,MemRefHandle> > mCalleeToCallerMap;
00087   std::map<ProcHandle,OA_ptr<std::set<SymHandle> > > mProcToFormalSetMap;
00088   std::map<CallHandle,OA_ptr<std::set<MemRefHandle> > > mCallToActualSetMap;
00089   //std::map<SymHandle,bool> mIsRefParam;
00090 
00091   GENOUT std::map<CallHandle,OA_ptr<std::list<ExprHandle> > > mCallToExprListMap;
00092   GENOUT std::map<ExprHandle,OA_ptr<ExprTree> > mExprToTreeMap;
00093   GENOUT std::map<CallHandle,std::map<SymHandle,ExprHandle> > mCallToFormalToActualMap;
00094   
00095 
00097   class SymIterator : public virtual OA::SymHandleIterator,
00098                       public OA::IRHandleSetIterator<OA::SymHandle>
00099   {
00100   public:
00101     SymIterator(OA::OA_ptr<std::set<OA::SymHandle> > pSet) 
00102       : OA::IRHandleSetIterator<OA::SymHandle>(pSet) {}
00103     ~SymIterator() {}
00104 
00105     void operator++() { OA::IRHandleSetIterator<OA::SymHandle>::operator++(); }
00106     bool isValid() const
00107       { return OA::IRHandleSetIterator<OA::SymHandle>::isValid(); }
00108     OA::SymHandle current() const
00109       { return OA::IRHandleSetIterator<OA::SymHandle>::current(); }
00110     void reset() { OA::IRHandleSetIterator<OA::SymHandle>::reset(); }
00111   };
00112   
00114   class MemRefIterator : public virtual OA::MemRefHandleIterator,
00115                          public OA::IRHandleSetIterator<OA::MemRefHandle>
00116   {
00117   public:
00118     MemRefIterator(OA::OA_ptr<std::set<OA::MemRefHandle> > pList) 
00119       : OA::IRHandleSetIterator<OA::MemRefHandle>(pList) {}
00120     ~MemRefIterator() {}
00121 
00122     void operator++() { OA::IRHandleSetIterator<OA::MemRefHandle>::operator++(); }
00123     bool isValid() const
00124       { return OA::IRHandleSetIterator<OA::MemRefHandle>::isValid(); }
00125     OA::MemRefHandle current() const
00126       { return OA::IRHandleSetIterator<OA::MemRefHandle>::current(); }
00127     void reset() { OA::IRHandleSetIterator<OA::MemRefHandle>::reset(); }
00128   };
00129 
00131   class ExprIterator : public virtual OA::ExprHandleIterator,
00132                       public OA::IRHandleListIterator<OA::ExprHandle>
00133   {
00134   public:
00135     ExprIterator(OA::OA_ptr<std::list<OA::ExprHandle> > eList) 
00136       : OA::IRHandleListIterator<OA::ExprHandle>(eList) {}
00137     ~ExprIterator() {}
00138 
00139     void operator++() 
00140       { OA::IRHandleListIterator<OA::ExprHandle>::operator++(); }
00141     bool isValid() const
00142       { return OA::IRHandleListIterator<OA::ExprHandle>::isValid(); }
00143     OA::ExprHandle current() const
00144       { return OA::IRHandleListIterator<OA::ExprHandle>::current(); }
00145     void reset() { OA::IRHandleListIterator<OA::ExprHandle>::reset(); }
00146   };
00147   
00148 
00149 
00150 };
00151 
00152   } // end of DataFlow namespace
00153 } // end of OA namespace
00154 
00155 #endif

Generated on Sat Oct 31 05:21:25 2009 for OpenAnalysis by  doxygen 1.6.1