CallGraphDFSolver.hpp

Go to the documentation of this file.
00001 
00026 #ifndef CallGraphDFSolver_h
00027 #define CallGraphDFSolver_h
00028 
00029 #include <OpenAnalysis/Utils/OA_ptr.hpp>
00030 //#include <OpenAnalysis/DataFlow/DGraphIterativeDFP.hpp>
00031 #include <OpenAnalysis/DataFlow/DGraphSolverDFP.hpp>
00032 #include <OpenAnalysis/DataFlow/DataFlowSet.hpp>
00033 #include <OpenAnalysis/DataFlow/CallGraphDFProblem.hpp>
00034 #include <OpenAnalysis/CallGraph/CallGraphInterface.hpp>
00035 #include <map>
00036 
00037 namespace OA {
00038   namespace DataFlow {
00039 
00040   
00041 //*********************************************************************
00042 // class CallGraphDFProblemNew
00043 //*********************************************************************
00044 class CallGraphDFSolver  : private DataFlow::DGraphSolverDFP {
00045 public:
00046   typedef enum { TopDown, BottomUp } CallGraphDirectionType;
00047 private:
00048   OA_ptr<DataFlowSet> mTop;
00049 //  OA_ptr<DataFlowSet> mBottom;
00050   CallGraphDirectionType mDirection;
00051 
00052 public:
00053   //--------------------------------------------------------
00054   // constructor/destructor
00055   //--------------------------------------------------------
00056   CallGraphDFSolver(CallGraphDirectionType pDirection, CallGraphDFProblem& prob);
00057   virtual ~CallGraphDFSolver() {}
00058 
00061   void solve(OA_ptr<CallGraph::CallGraphInterface> callGraph, 
00062                     DFPImplement algorithm);
00063 
00064   //========================================================
00065   // implementation of DGraphIterativeDFP callbacks
00066   // These are implemented in CallGraphDFProblem.cpp for a 
00067   // CallGraph.
00068   //========================================================
00069   
00070   //--------------------------------------------------------
00071   // initialization upcall 
00072   //--------------------------------------------------------
00073   void initialize(OA_ptr<DGraph::DGraphInterface> dg);
00074   
00075   //--------------------------------------------------------
00076   // solver upcalls
00077   //--------------------------------------------------------
00078   bool atDGraphNode(OA_ptr<DGraph::NodeInterface> node, 
00079                     DGraph::DGraphEdgeDirection pOrient);
00080   bool atDGraphEdge(OA_ptr<DGraph::EdgeInterface>, 
00081                     DGraph::DGraphEdgeDirection);
00082   
00083   //--------------------------------------------------------
00084   // finalization upcalls
00085   //--------------------------------------------------------
00086   void finalizeNode(OA_ptr<DGraph::NodeInterface> node);
00087   void finalizeEdge(OA_ptr<DGraph::EdgeInterface> edge);
00088 
00089 
00090   //--------------------------------------------------------
00091   // debugging
00092   //--------------------------------------------------------
00093 public:
00094   void dump(std::ostream& os, OA_ptr<IRHandlesIRInterface> ir);
00095 
00096 
00097 private:
00098   // In and Out in this context refer to the data-flow direction
00099   // which in the case of bottom-up is in the reverse direction
00100   // of edges in the graph
00101   std::map<OA_ptr<CallGraph::NodeInterface>,OA_ptr<DataFlowSet> > 
00102       mNodeOutSetMap;
00103   std::map<OA_ptr<CallGraph::NodeInterface>,OA_ptr<DataFlowSet> > 
00104       mNodeInSetMap;
00105   std::map<OA_ptr<CallGraph::EdgeInterface>,OA_ptr<DataFlowSet> > 
00106       mEdgeOutSetMap;
00107   std::map<OA_ptr<CallGraph::EdgeInterface>,OA_ptr<DataFlowSet> > 
00108       mEdgeInSetMap;
00109 
00110   // whether or not the node has had the transfer function applied
00111   // to all statements at least once
00112   std::map<OA_ptr<CallGraph::NodeInterface>,bool> mNodeInitTransApp;
00113 
00114   CallGraphDFProblem& mDFProb;
00115 };
00116 
00117   } // end of DataFlow namespace
00118 }  // end of OA namespace
00119 
00120 #endif

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