DepDFSet.hpp

Go to the documentation of this file.
00001 
00016 #ifndef DepDDFSet_h
00017 #define DepDDFSet_h
00018 
00019 #include <iostream>
00020 #include <map>
00021 
00022 // abstract interface that this class implements
00023 #include <OpenAnalysis/DataFlow/DataFlowSet.hpp>
00024 #include <OpenAnalysis/Location/Locations.hpp>
00025 #include <OpenAnalysis/DataFlow/LocDFSet.hpp>
00026 
00027 namespace OA {
00028   namespace Activity {
00029 
00030 class DepIterator;
00031 
00036     class DepDFSet : public virtual DataFlow::DataFlowSet,
00037                      public virtual Annotation {
00038 public:
00039   DepDFSet();
00041   DepDFSet(const DepDFSet &other); 
00042   ~DepDFSet() {}
00043 
00045   DepDFSet& operator=(const DepDFSet &other);
00046 
00047   //*****************************************************************
00048   // DataFlowSet Interface Implementation
00049   //*****************************************************************
00050   OA_ptr<DataFlow::DataFlowSet> clone();
00051   
00052   // param for these can't be const because will have to 
00053   // dynamic cast to specific subclass
00054   bool operator ==(DataFlow::DataFlowSet &other) const;
00055 
00056   bool operator !=(DataFlow::DataFlowSet &other) const;
00057 
00058   //*****************************************************************
00059   // Methods specific to DepDFSet
00060   //*****************************************************************
00061 
00062   
00064   DepDFSet& setUnion(DataFlow::DataFlowSet &other);
00065 
00067   DepDFSet& compose(DataFlow::DataFlowSet &other);
00068   //OA_ptr<DepDFSet> compose(OA_ptr<DepDFSet> other);
00069 
00071   OA_ptr<DepIterator> getDepIterator() const;
00072 
00075   OA_ptr<LocIterator> getDefsIterator(const OA_ptr<Location> use) const;
00076 
00079   OA_ptr<LocIterator> getUsesIterator(OA_ptr<Location> def) const;
00080 
00082 //  DepDFSet& setIntersect(DepDFSet &other);
00083 
00084 //  DepDFSet& setDifference(DepDFSet &other);
00085 
00086   //*****************************************************************
00087   // Annotation Interface
00088   //*****************************************************************
00089   void output(OA::IRHandlesIRInterface& ir);
00090 
00091   //*****************************************************************
00092   // Output
00093   //*****************************************************************
00094 
00095   void dump(std::ostream &os, OA_ptr<IRHandlesIRInterface> ir);
00096   void dump(std::ostream &os);
00097   void dump(std::ostream &os) const;
00098 
00099   //*****************************************************************
00100   // Construction
00101   //*****************************************************************
00102   
00103   void insertDep(OA_ptr<Location> use, OA_ptr<Location> def);
00104 
00107   void removeImplicitDep(OA_ptr<Location> use, OA_ptr<Location> def);
00108 
00109   typedef std::map<OA_ptr<Location>,OA_ptr<DataFlow::LocDFSet> >
00110       LocToLocDFSetMap;
00111   
00115   bool isImplicitRemoved(const OA_ptr<Location> loc) const;
00116 
00117 
00118 private:
00121   //void makeImplicitExplicit();
00122   //bool mMakeImplicitExplicitMemoized;
00123 
00124   friend class DepIterator;
00125 
00126   // It is implicitly assumed that dep <a,a> is in each DepDFSet
00127   // for all locations.  This is a set of locations where this
00128   // implicit dep has been removed with removeImplicitDep.
00129   // If <a,a> is then explicitly inserted with insertDep, then
00130   // anything that overlaps with a will be removed from this set
00131   OA_ptr<DataFlow::LocDFSet> mImplicitRemoves;
00132 
00133   LocToLocDFSetMap mUseToDefsMap;
00134   LocToLocDFSetMap mDefToUsesMap;
00135 
00136   // maintain sets of the uses and defs as well
00137   OA_ptr<DataFlow::LocDFSet> mUses;
00138   OA_ptr<DataFlow::LocDFSet> mDefs;
00139 
00140 };
00141 
00142 class DepIterator {
00143   public:
00144     DepIterator(OA_ptr<DepDFSet> dfSet) : mDFSet(dfSet) 
00145       { mIter = mDFSet->mUseToDefsMap.begin(); 
00146         if (mIter!=mDFSet->mUseToDefsMap.end()) {
00147           mDefIter = new DataFlow::LocDFSetIterator(*(mIter->second));
00148           while (!mDefIter->isValid() && mIter!=mDFSet->mUseToDefsMap.end()) {
00149             mIter++;
00150             mDefIter = new DataFlow::LocDFSetIterator(*(mIter->second));
00151           }
00152         }
00153       }
00154     virtual ~DepIterator() {}
00155 
00156     OA_ptr<Location> use() const 
00157       { return mIter->first; }
00158     OA_ptr<Location> def() const
00159       { return mDefIter->current(); }
00160 
00161     bool isValid() const
00162       { if (mIter!=mDFSet->mUseToDefsMap.end() && mDefIter->isValid())
00163           { return true; } else { return false; }
00164       }
00165                     
00166     void operator++()
00167       {
00168         (*mDefIter)++;
00169         while (!mDefIter->isValid() && mIter!=mDFSet->mUseToDefsMap.end()) {
00170             mIter++;
00171             if (mIter!=mDFSet->mUseToDefsMap.end()) {
00172                 mDefIter = new DataFlow::LocDFSetIterator(*(mIter->second));
00173             }
00174         }
00175       }
00176 
00177     void operator++(int) { ++*this; }
00178 
00179   private:
00180     OA_ptr<DepDFSet> mDFSet;
00181     DepDFSet::LocToLocDFSetMap::const_iterator mIter;
00182     OA_ptr<LocIterator> mDefIter;
00183 
00184 };
00185 
00186   } // end of DataFlow namespace
00187 } // end of OA namespace
00188 
00189 #endif

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