LocDFSet.hpp

Go to the documentation of this file.
00001 
00015 #ifndef LocDFSet_H
00016 #define LocDFSet_H
00017 
00018 #include <iostream>
00019 #include <set>
00020 #include <algorithm>
00021 #include <iterator>
00022 
00023 // abstract interface that this class implements
00024 #include <OpenAnalysis/DataFlow/DataFlowSet.hpp>
00025 
00026 #include <OpenAnalysis/Location/Locations.hpp>
00027 #include <OpenAnalysis/Location/LocationVisitor.hpp>
00028 #include <OpenAnalysis/DataFlow/CalleeToCallerVisitor.hpp>
00029 #include <OpenAnalysis/ExprTree/EvalToMemRefVisitor.hpp>
00030 #include <OpenAnalysis/ExprTree/MemRefsVisitor.hpp>
00031 
00032 namespace OA {
00033   namespace DataFlow {
00034 
00035 class LocDFSet : public virtual DataFlowSet, public virtual Annotation {
00036 public:
00037   LocDFSet();
00038   LocDFSet(const LocDFSet &other);
00039   ~LocDFSet() {}
00040 
00041 
00042   OA_ptr<DataFlowSet> clone();
00043   
00044   // param for these can't be const because will have to 
00045   // dynamic cast to specific subclass
00046   bool operator ==(DataFlowSet &other) const;
00047 
00048   bool operator !=(DataFlowSet &other) const;
00049 
00050   LocDFSet& setUnion(DataFlowSet &other);
00051 
00052   LocDFSet& setIntersect(LocDFSet &other);
00053 
00054   LocDFSet& setDifference(LocDFSet &other);
00055 
00056   void dump(std::ostream &os);
00057 
00058   void dump(std::ostream &os, OA_ptr<IRHandlesIRInterface> ir);
00059   
00060   //========================================================
00061   // Annotation Interface
00062   //========================================================
00063   void output(OA::IRHandlesIRInterface& ir);
00064 
00065   //========================================================
00066   // methods specific to LocDFSet
00067   //========================================================
00068   
00069   void insert(OA_ptr<Location> loc);
00070   void remove(OA_ptr<Location> loc);
00071 
00073   bool empty();
00074   
00076   bool hasLoc(OA_ptr<Location> loc);
00077 
00080   bool hasOverlapLoc(OA_ptr<Location> loc);
00081 
00083   OA_ptr<LocIterator> getLocIterator();
00084 
00086   OA_ptr<LocIterator> getOverlapLocIterator(OA_ptr<Location> loc);
00087 
00092   OA_ptr<LocDFSet> callerToCallee(ProcHandle caller, CallHandle call, 
00093           ProcHandle callee,
00094           OA_ptr<Alias::InterAliasInterface> interAlias,
00095           OA_ptr<ParamBindings> paramBind,
00096           OA_ptr<CalleeToCallerVisitorIRInterface> ir);
00097 
00102   OA_ptr<LocDFSet> callerToCalleeTransitive(ProcHandle caller, 
00103           CallHandle call, ProcHandle callee,
00104           OA_ptr<Alias::InterAliasInterface> interAlias,
00105           OA_ptr<ParamBindings> paramBind,
00106           OA_ptr<CalleeToCallerVisitorIRInterface> ir);
00107 
00112   OA_ptr<LocDFSet> calleeToCaller(ProcHandle callee, CallHandle call, 
00113           ProcHandle caller,
00114           OA_ptr<Alias::InterAliasInterface> interAlias,
00115           OA_ptr<ParamBindings> paramBind,
00116           OA_ptr<CalleeToCallerVisitorIRInterface> ir);
00117 
00122   OA_ptr<LocDFSet> calleeToCallerTransitive(ProcHandle callee, 
00123           CallHandle call, ProcHandle caller,
00124           OA_ptr<Alias::InterAliasInterface> interAlias,
00125           OA_ptr<ParamBindings> paramBind,
00126           OA_ptr<CalleeToCallerVisitorIRInterface> ir);
00127  
00133   OA_ptr<LocDFSet> callerToCalleeNot(ProcHandle caller, CallHandle call, 
00134           ProcHandle callee,
00135           OA_ptr<Alias::InterAliasInterface> interAlias,
00136           OA_ptr<ParamBindings> paramBind,
00137           OA_ptr<CalleeToCallerVisitorIRInterface> ir);
00138 
00139  protected:
00140   friend class LocDFSetIterator;
00141 
00142   // maintaining the locations in a set and also in sets based on their
00143   // base location, will always keep set up-to-date,
00144   // will memoize mapping of base locations to sets of locs when it
00145   // is needed for routines like mayOverlap
00146   OA_ptr<LocSet> mSetPtr;
00147 
00148   //-------------------------------------------------------
00149   // Data structures and code for making this faster
00150   //-------------------------------------------------------
00151 private:
00152   // all part of map to make using LocDFSet quicker, especially
00153   // hasOverlapLoc and getOverlapLocIterator
00154   bool mBaseLocToSetMapValid;
00155   bool mHasUnknownLoc;
00156   OA_ptr<LocSet> mInvLocs;    // separate set of invisible locations
00157   // mapping for base named and unnamed locs to set of locations that
00158   // may overlap with each, doing mapping based on IRHandle for speed
00159   std::map<IRHandle,OA_ptr<LocSet> > mBaseLocToSetMap;
00160 
00161   void updateMap();
00162   void removeFromMap(OA_ptr<Location> loc);
00163   void addToMap(OA_ptr<Location> loc);
00164   void associateWithBaseHandle(IRHandle baseHandle, OA_ptr<Location> loc);
00165   void disassociateWithBaseHandle(IRHandle baseHandle, OA_ptr<Location> loc);
00166   bool setHasOverlapLoc(OA_ptr<Location> loc, OA_ptr<LocSet> aSet);
00167   OA_ptr<LocDFSet>  overlapLocSet(OA_ptr<Location> loc, OA_ptr<LocSet> aSet);
00168 
00169   OA_ptr<CalleeToCallerVisitorIRInterface> mIR;
00170 };
00171 
00173 class LocDFSetIterator : public LocSetIterator {
00174 public:
00175   LocDFSetIterator(LocDFSet& pDFSet) 
00176       : LocSetIterator(pDFSet.mSetPtr) {}
00177   ~LocDFSetIterator() { }
00178 };
00179 
00180 
00181 
00182   } // end of DataFlow namespace
00183 } // end of OA namespace
00184 
00185 #endif

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