ManagerReachConstsStandard.hpp

Go to the documentation of this file.
00001 
00015 #ifndef ReachConstsManagerStandard_h
00016 #define ReachConstsManagerStandard_h
00017 
00018 //--------------------------------------------------------------------
00019 // OpenAnalysis headers
00020 #include <OpenAnalysis/Utils/OA_ptr.hpp>
00021 #include <OpenAnalysis/IRInterface/ReachConstsIRInterface.hpp>
00022 #include <OpenAnalysis/ReachConsts/ReachConstsStandard.hpp>
00023 
00024 #include <OpenAnalysis/CFG/CFGInterface.hpp>
00025 //#include <OpenAnalysis/CFG/CFGStandard.hpp>
00026 
00027 #include <OpenAnalysis/Alias/Interface.hpp>
00028 
00029 #include <OpenAnalysis/DataFlow/CFGDFProblem.hpp>
00030 #include <OpenAnalysis/DataFlow/IRHandleDataFlowSet.hpp>
00031 #include <OpenAnalysis/SideEffect/InterSideEffectInterface.hpp>
00032 
00033 
00034 #include <OpenAnalysis/IRInterface/ConstValBasicInterface.hpp>
00035 #include <OpenAnalysis/ExprTree/EvalToConstVisitor.hpp>
00036 #include <OpenAnalysis/DataFlow/CFGDFSolver.hpp>
00037 #include <OpenAnalysis/DataFlow/LocDFSet.hpp>
00038 
00039 
00040 namespace OA {
00041   namespace ReachConsts {
00042 
00043 
00049 class ManagerReachConstsStandard 
00050     : private DataFlow::CFGDFProblem { 
00051       //??? eventually public OA::AnnotationManager
00052 public:
00053   ManagerReachConstsStandard(OA_ptr<ReachConstsIRInterface> _ir);
00054   ~ManagerReachConstsStandard () {}
00055 
00056   OA_ptr<ReachConstsStandard> performAnalysis(ProcHandle, 
00057         OA_ptr<CFG::CFGInterface> cfg, OA_ptr<Alias::Interface> alias,
00058         OA_ptr<SideEffect::InterSideEffectInterface> interSE,
00059         DataFlow::DFPImplement algorithm);
00060 
00061   //--------------------------------------------------------
00062   // For use within InterMPICFGDFProblem
00063   // DESIGN Note:  Not in CFGDFProblem because Managers inherit
00064   // from CFGDFProblem privately and I don't know if I want to
00065   // switch that to public.  See 406 in C++ book.
00066   // Note that these methods get a ptr to the DataFlowSet
00067   // and therefore any changes made will be noticed next time
00068   // performAnalysis is called.
00069   //--------------------------------------------------------
00070   // Shifted to CFGDFProblem */
00071   // 
00072   //OA_ptr<DataFlow::DataFlowSet> getInSet(OA_ptr<CFG::Interface::Node> node)
00073   //  { return mNodeInSetMap[node]; }
00074   //OA_ptr<DataFlow::DataFlowSet> getOutSet(OA_ptr<CFG::Interface::Node> node)
00075   //  { return mNodeOutSetMap[node]; }
00076 
00077   //------------------------------------------------------------------
00078   // Implementing the callbacks for CFGDFProblem
00079   // The DataFlowSet subclass used is ConstDefSet
00080   //------------------------------------------------------------------
00081 private:
00082   OA_ptr<DataFlow::DataFlowSet>  initializeTop();
00083 
00084   OA_ptr<DataFlow::DataFlowSet>  initializeBottom();
00085 
00087   void initializeTopAndBottom();
00088   
00089 
00090   void initializeNode(OA_ptr<CFG::NodeInterface> n);
00092   OA_ptr<DataFlow::DataFlowSet>
00093             initializeNodeIN(OA_ptr<CFG::NodeInterface> n);
00094   OA_ptr<DataFlow::DataFlowSet>
00095             initializeNodeOUT(OA_ptr<CFG::NodeInterface> n);
00096 
00097   
00098   OA_ptr<DataFlow::DataFlowSet> 
00099   meet (OA_ptr<DataFlow::DataFlowSet> set1, 
00100         OA_ptr<DataFlow::DataFlowSet> set2); 
00101 
00102   OA_ptr<DataFlow::DataFlowSet> 
00103   transfer(OA_ptr<DataFlow::DataFlowSet> in, OA::StmtHandle stmt); 
00104 
00105   //------------------------------------------------------------------
00106   // Helper routines for the callbacks
00107   //------------------------------------------------------------------
00108   
00111   void setUseMemRef2Const(StmtHandle stmt, const ConstDefSet& in);
00112 
00115   void setDefMemRef2Const(StmtHandle stmt, const ConstDefSet& in);
00116 
00117   enum MeetOp {
00118     CD1toBOTTOM,CD2toBOTTOM,BOTHtoBOTTOM,CD1toVALUECD2,CD2toVALUECD1,NOTHING
00119   };
00120 
00122   MeetOp getMustMeetOp(OA_ptr<ConstDef> cd1, OA_ptr<ConstDef> cd2);
00123 
00125   MeetOp getMayOnlyMeetOp(OA_ptr<ConstDef> cd1, OA_ptr<ConstDef> cd2);
00126 
00127 private: // member variables
00128 
00129   OA_ptr<ReachConstsIRInterface> mIR;
00130   ProcHandle mProc;
00131   OA_ptr<Alias::Interface> mAlias;
00132   std::map<StmtHandle,std::set<OA_ptr<Location> > > mStmtMayDefMap;
00133   std::map<StmtHandle,std::set<OA_ptr<Location> > > mStmtMustDefMap;
00134   OA_ptr<ConstDefSet> mAllTop;
00135   OA_ptr<ConstDefSet> mAllBottom;
00136   OA_ptr<CFG::CFGInterface> mCFG;
00137   OA_ptr<SideEffect::InterSideEffectInterface> mInterSE;
00138   OA_ptr<ReachConstsStandard> mRCS;
00139  // Added by PLM 07/26/06
00140   OA_ptr<DataFlow::CFGDFSolver> mSolver;
00141  
00142    };
00143 
00144   } // end of ReachConsts namespace
00145 } // end of OA namespace
00146 
00147 #endif