CFGDFSolver.hpp

Go to the documentation of this file.
00001 
00023 #ifndef CFGDFSolver_h
00024 #define CFGDFSolver_h
00025 
00026 #include <OpenAnalysis/Utils/OA_ptr.hpp>
00027 //#include <OpenAnalysis/DataFlow/DGraphIterativeDFP.hpp>
00028 #include <OpenAnalysis/DataFlow/DGraphSolverDFP.hpp>
00029 #include <OpenAnalysis/DataFlow/DataFlowSet.hpp>
00030 #include <OpenAnalysis/CFG/CFGInterface.hpp>
00031 #include <OpenAnalysis/IRInterface/CFGIRInterface.hpp>
00032 #include <OpenAnalysis/DataFlow/CFGDFProblem.hpp>
00033 #include <map>
00034 
00035 namespace OA {
00036   namespace DataFlow {
00037 
00038 //*********************************************************************
00039 // class CFGDFProblem
00040 //*********************************************************************
00041 //template <class DataFlowSet>
00042 class CFGDFSolver  : private DataFlow::DGraphSolverDFP {
00043 
00044 public:    
00045   typedef enum { Forward, Backward } DFDirectionType;
00046 
00047 private:  
00048   OA_ptr<DataFlowSet> mTop;
00049   //OA_ptr<DataFlowSet> mBottom;
00050   DFDirectionType mDirection;
00051 
00052 public:
00053   //--------------------------------------------------------
00054   // constructor/destructor
00055   //--------------------------------------------------------
00056   CFGDFSolver(DFDirectionType pDirection,  CFGDFProblem& prob);
00057   virtual ~CFGDFSolver() {}
00058 
00061   OA_ptr<DataFlowSet> solve(OA_ptr<CFG::CFGInterface> cfg, 
00062                             DFPImplement algorithm);
00063 
00064 public:
00065 // It should be private for CFGDFSolver  
00066     //--------------------------------------------------------
00067     // For use within InterMPICFGDFProblem
00068     // DESIGN Note:  Not in CFGDFProblem because Managers inherit
00069     // from CFGDFProblem privately and I don't know if I want to
00070     // switch that to public.  See 406 in C++ book.
00071     // Note that these methods get a ptr to the DataFlowSet
00072     // and therefore any changes made will be noticed next time
00073     // performAnalysis is called.
00074     //--------------------------------------------------------
00075     OA_ptr<DataFlow::DataFlowSet> getInSet(OA_ptr<CFG::NodeInterface> node)
00076                    { return mNodeInSetMap[node]; }
00077     OA_ptr<DataFlow::DataFlowSet> getOutSet(OA_ptr<CFG::NodeInterface> node)
00078                    { return mNodeOutSetMap[node]; }
00079                                 
00080 private:
00081   //========================================================
00082   // implementation of DGraphIterativeDFP callbacks
00083   // These are implemented in CFGDFProblem.cpp for a CFG.
00084   //========================================================
00085   
00086   //--------------------------------------------------------
00087   // initialization upcall 
00088   //--------------------------------------------------------
00089   void initialize(OA_ptr<DGraph::DGraphInterface> dg);
00090  
00091 
00092   //--------------------------------------------------------
00093   // solver upcalls
00094   //--------------------------------------------------------
00095   bool atDGraphNode(OA_ptr<DGraph::NodeInterface> node, 
00096                     DGraph::DGraphEdgeDirection pOrient);
00097   
00098   //--------------------------------------------------------
00099   // finalization upcalls
00100   //--------------------------------------------------------
00101   void finalizeNode(OA_ptr<DGraph::NodeInterface> node);
00102 
00103 
00109   OA_ptr<DataFlowSet> transfer(OA_ptr<DataFlowSet> in, 
00110                                OA_ptr<DGraph::NodeInterface> n);
00111 
00112   //--------------------------------------------------------
00113   // debugging
00114   //--------------------------------------------------------
00115 public:
00116   void dump(std::ostream& os, OA_ptr<IRHandlesIRInterface> ir);
00117 
00118 protected:
00119   //std::map<OA::StmtHandle,DataFlowSet*> mStmtInSetMap;
00120   //std::map<OA::StmtHandle,DataFlowSet*> mStmtOutSetMap;
00121   std::map<OA_ptr<CFG::NodeInterface>,OA_ptr<DataFlowSet> > mNodeInSetMap;
00122   std::map<OA_ptr<CFG::NodeInterface>,OA_ptr<DataFlowSet> > mNodeOutSetMap;
00123 
00124   // whether or not the node has had the transfer function applied
00125   // to all statements at least once
00126   std::map<OA_ptr<CFG::NodeInterface>,bool> mNodeInitTransApp;
00127   CFGDFProblem& mDFProb; 
00128 };
00129 
00130   } // end of DataFlow namespace
00131 }  // end of OA namespace
00132 
00133 #endif

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