00001
00016 #ifndef DUGManagerStandard_h
00017 #define DUGManagerStandard_h
00018
00019
00020
00021 #include <OpenAnalysis/IRInterface/DUGIRInterface.hpp>
00022 #include <OpenAnalysis/Utils/OA_ptr.hpp>
00023 #include <OpenAnalysis/ExprTree/ExprTree.hpp>
00024 #include <OpenAnalysis/CFG/EachCFGInterface.hpp>
00025 #include <OpenAnalysis/CFG/CFGInterface.hpp>
00026 #include <OpenAnalysis/SideEffect/InterSideEffectStandard.hpp>
00027 #include <OpenAnalysis/SideEffect/ManagerInterSideEffectStandard.hpp>
00028 #include <OpenAnalysis/Location/Locations.hpp>
00029 #include <OpenAnalysis/Activity/DepDFSet.hpp>
00030 #include <OpenAnalysis/CSFIActivity/DUGStandard.hpp>
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 namespace OA {
00043 namespace DUG {
00044
00050 class ManagerDUGStandard {
00051 public:
00052 ManagerDUGStandard(OA_ptr<DUGIRInterface> _ir,
00053 OA_ptr<Activity::ActivityIRInterface> _air);
00054 ~ManagerDUGStandard () {}
00055
00056 OA_ptr<DUGStandard> performAnalysis( OA_ptr<IRProcIterator>,
00057 OA_ptr<DataFlow::ParamBindings>,
00058 OA_ptr<OA::CallGraph::CallGraphInterface>);
00059
00060 void transitiveClosureDepMatrix(OA_ptr<OA::CallGraph::CallGraphInterface>);
00061
00062 private:
00063
00064 bool stmt_has_call(StmtHandle stmt);
00065
00066 void insertEdge(SymHandle, SymHandle, EdgeType, CallHandle, ProcHandle, ProcHandle, ProcHandle);
00067 void labelCallRetEdges(StmtHandle, ProcHandle);
00068 void labelUseDefEdges(StmtHandle, ProcHandle);
00069 void collectIndependentSyms( ProcHandle);
00070 void collectDependentSyms( ProcHandle);
00071
00072 void setDepMatrix(ProcHandle, SymHandle, SymHandle);
00073 void transitiveClosure(ProcHandle proc);
00074 void edgesBetweenActuals(ProcHandle proc);
00075
00076 void setDepMatrix4Globals(SymHandle, SymHandle, ProcHandle);
00077 bool isPathThruOtherProcs(SymHandle, SymHandle, ProcHandle);
00078 bool isOutgoingToOtherProcs(SymHandle, ProcHandle);
00079 bool isIncomingFromOtherProcs(SymHandle, ProcHandle);
00080 bool hasEdgesToOtherProc(SymHandle, ProcHandle);
00081 bool hasEdgesFromOtherProc(SymHandle, ProcHandle);
00082 bool isLocal(SymHandle, ProcHandle);
00083
00084 private:
00085
00086 OA_ptr<DUGIRInterface> mIR;
00087 OA_ptr<Activity::ActivityIRInterface> mActIR;
00088 OA_ptr<DUGStandard> mDUG;
00089 OA_ptr<DataFlow::ParamBindings> mParamBind;
00090
00091
00092 std::map<ProcHandle,
00093 std::map<SymHandle,
00094 std::map<SymHandle, bool> > > mProcToMatrix;
00095 std::map<ProcHandle, std::set<SymHandle> > mProcToSymSet;
00096
00097 std::map<EdgeType, std::map<SymHandle,
00098 std::map<SymHandle, bool> > > mMatrix;
00099
00100
00101
00102 std::map<ProcHandle, std::set<CallHandle> > mProcToCallsiteSet;
00103
00104 std::map<ProcHandle, std::set<SymHandle> > mProcToFormalSet;
00105
00106 std::map<CallHandle,
00107 std::map<SymHandle,
00108 std::set<SymHandle> > > mFormalToActualMap;
00109
00110 std::map<CallHandle, ProcHandle> mCallsiteToProc;
00111
00112
00113
00114 std::set<ProcHandle> mProcsOfInterest;
00115 };
00116
00118
00119 class IndepLocVisitor : public virtual LocationVisitor {
00120 public:
00121
00122 IndepLocVisitor(OA_ptr<DUGStandard> dug,
00123 ProcHandle proc,
00124 std::set<ProcHandle> ProcsOfInterest,
00125 OA_ptr<DUGIRInterface> ir
00126 )
00127 : mDUG(dug), mProc(proc), mProcsOfInterest(ProcsOfInterest), mIR(ir)
00128 { }
00129 ~IndepLocVisitor() { }
00130
00131 void visitNamedLoc(NamedLoc& loc);
00132 void visitUnnamedLoc(UnnamedLoc& loc);
00133 void visitInvisibleLoc(InvisibleLoc& loc);
00134 void visitUnknownLoc(UnknownLoc& loc);
00135 void visitLocSubSet(LocSubSet& loc);
00136
00137 std::set<ProcHandle> getmProcsOfInterest()
00138 {
00139 return mProcsOfInterest;
00140 }
00141 private:
00142 OA_ptr<DUGStandard> mDUG;
00143 ProcHandle mProc;
00144 std::set<ProcHandle> mProcsOfInterest;
00145 OA_ptr<DUGIRInterface> mIR;
00146
00147 };
00148
00149 class depLocVisitor : public virtual LocationVisitor {
00150 public:
00151 depLocVisitor(OA_ptr<DUGStandard> dug,
00152 ProcHandle proc,
00153 std::set<ProcHandle> ProcsOfInterest ,
00154 OA_ptr<DUGIRInterface> ir
00155 )
00156 : mDUG(dug), mProc(proc), mProcsOfInterest(ProcsOfInterest), mIR(ir)
00157 { }
00158 ~depLocVisitor() {}
00159
00160 void visitNamedLoc(NamedLoc& loc);
00161 void visitUnnamedLoc(UnnamedLoc& loc);
00162 void visitInvisibleLoc(InvisibleLoc& loc);
00163 void visitUnknownLoc(UnknownLoc& loc);
00164 void visitLocSubSet(LocSubSet& loc);
00165 std::set<ProcHandle> getmProcsOfInterest()
00166 {
00167 return mProcsOfInterest;
00168 }
00169
00170 private:
00171 OA_ptr<DUGStandard> mDUG;
00172 ProcHandle mProc;
00173 std::set<ProcHandle> mProcsOfInterest;
00174 OA_ptr<DUGIRInterface> mIR;
00175 };
00176
00177
00178
00179 }
00180 }
00181
00182 #endif