ICFGDFSolver.hpp

Go to the documentation of this file.
00001 
00020 #ifndef ICFGDFSolver_H
00021 #define ICFGDFSolver_H
00022 
00023 #include <OpenAnalysis/Utils/OA_ptr.hpp>
00024 //#include <OpenAnalysis/DataFlow/DGraphIterativeDFP.hpp>
00025 #include <OpenAnalysis/DataFlow/DGraphSolverDFP.hpp>
00026 #include <OpenAnalysis/DataFlow/DataFlowSet.hpp>
00027 #include <OpenAnalysis/DataFlow/ICFGDFProblem.hpp>
00028 #include <OpenAnalysis/ICFG/ICFGInterface.hpp>
00029 //#include <OpenAnalysis/IRInterface/CFGIRInterface.hpp>
00030 #include <map>
00031 
00032 namespace OA {
00033   namespace DataFlow {
00034 
00035   
00036 //*********************************************************************
00037 // class ICFGDFSolver
00038 //*********************************************************************
00039 class ICFGDFSolver  : private DataFlow::DGraphSolverDFP {
00040 public:
00041   typedef enum { Forward, Backward } DFDirectionType;
00042 
00043 private:
00044   OA_ptr<DataFlowSet> mTop;
00045   //OA_ptr<DataFlowSet> mBottom;
00046   DFDirectionType mDirection;
00047 
00048 public:
00049   //--------------------------------------------------------
00050   // constructor/destructor
00051   //--------------------------------------------------------
00052   ICFGDFSolver(DFDirectionType pDirection, ICFGDFProblem& prob);
00053   virtual ~ICFGDFSolver() {}
00054 
00057   void solve(OA_ptr<ICFG::ICFGInterface> icfg, DFPImplement algorithm);
00058 
00059   //---------------------------------
00060   // access to DGraphIterativeDFP info
00061   //---------------------------------
00062   int getNumIter() { return afterSolve_getNumIter(); }
00063 
00064 private:
00065   //========================================================
00066   // implementation of DGraphIterativeDFP callbacks
00067   // These are implemented in ICFGDFSolver.cpp for a CFG.
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   
00081   //--------------------------------------------------------
00082   // finalization upcalls
00083   //--------------------------------------------------------
00084   void finalizeNode(OA_ptr<DGraph::NodeInterface> node);
00085 
00086 
00092   OA_ptr<DataFlowSet> transfer(OA_ptr<DataFlowSet> in, 
00093                                OA_ptr<DGraph::NodeInterface> n);
00094 
00095   //--------------------------------------------------------
00096   // debugging
00097   //--------------------------------------------------------
00098 public:
00099   void dump(std::ostream& os, OA_ptr<IRHandlesIRInterface> ir);
00100 
00101 protected:
00102   //std::map<OA::StmtHandle,DataFlowSet*> mStmtInSetMap;
00103   //std::map<OA::StmtHandle,DataFlowSet*> mStmtOutSetMap;
00104   std::map<OA_ptr<ICFG::NodeInterface>,
00105            OA_ptr<DataFlowSet> > mNodeInSetMap;
00106   std::map<OA_ptr<ICFG::NodeInterface>,
00107            OA_ptr<DataFlowSet> > mNodeOutSetMap;
00108 
00109   // whether or not the node has had the transfer function applied
00110   // to all statements at least once
00111   std::map<OA_ptr<ICFG::NodeInterface>,bool> mNodeInitTransApp;
00112 
00113   ICFGDFProblem& mDFProb;
00114 
00115 };
00116 
00117   } // end of DataFlow namespace
00118 }  // end of OA namespace
00119 
00120 #endif

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