EquivSets.hpp

Go to the documentation of this file.
00001 
00015 #ifndef AliasEquivSets_H
00016 #define AliasEquivSets_H
00017 
00018 #include <cassert>
00019 #include <iostream>
00020 #include <set>
00021 #include <vector>
00022 #include <queue>
00023 #include <map>
00024 
00025 #include <OpenAnalysis/Utils/OA_ptr.hpp>
00026 #include <OpenAnalysis/Utils/OutputBuilder.hpp>
00027 #include <OpenAnalysis/IRInterface/IRHandles.hpp>
00028 #include <OpenAnalysis/Alias/Interface.hpp>
00029 #include <OpenAnalysis/MemRefExpr/MemRefExpr.hpp>
00030 #include <OpenAnalysis/Location/Locations.hpp>
00031 #include <OpenAnalysis/Utils/GenOutputTool.hpp>
00032 
00033 namespace OA {
00034   namespace Alias {
00035 
00036 typedef std::set<MemRefHandle> MemRefSet;
00037 typedef std::set<OA_ptr<Location> > LocSet;
00038 
00039 
00041 class EquivSetsMemRefIter : public MemRefIterator {
00042 public:
00043   EquivSetsMemRefIter(OA_ptr<MemRefSet> pSet) : mSet(pSet) 
00044     { mIter = mSet->begin(); }
00045   ~EquivSetsMemRefIter() { }
00046 
00047   MemRefHandle current() const { return *mIter; }
00048   bool isValid()  const { return (mIter != mSet->end()); }
00049         
00050   void operator++() { if (mIter!=mSet->end()) ++mIter; }
00051 
00052   void reset() { mIter = mSet->begin(); }
00053 
00054 private:
00055   OA_ptr<MemRefSet>  mSet;
00056   MemRefSet::iterator mIter;
00057 };
00058 
00059 
00066 class EquivSets : public virtual Annotation, public Alias::Interface {
00067   public:
00068     EquivSets();
00069     ~EquivSets() {}
00070 
00071     static const int SET_ID_NONE = -1; 
00072 
00074     AliasResultType alias(MemRefHandle ref1, 
00075                           MemRefHandle ref2);
00076 
00078     OA_ptr<LocIterator> getMayLocs(MemRefHandle ref);
00079 
00082     OA_ptr<LocIterator> getMustLocs(MemRefHandle ref);
00083 
00085     OA_ptr<LocIterator> getMayLocs(MemRefExpr &ref, ProcHandle proc);
00086 
00088     OA_ptr<LocIterator> getMustLocs(MemRefExpr &ref, ProcHandle proc);
00089 
00092     OA_ptr<MemRefIterator> getMemRefIter();
00093 
00094     //*****************************************************************
00095     // Info methods unique to Alias::EquivSets
00096     //*****************************************************************
00097 
00098     //*****************************************************************
00099     // Construction methods 
00100     //*****************************************************************
00101 
00104     void addLocation(OA_ptr<Location> pLoc, ProcHandle proc, int equivSet);
00105     
00107     OA_ptr<LocIterator> getLocIterator(ProcHandle proc, int equivSet); 
00108 
00110     OA_ptr<std::map<int,OA_ptr<LocSet> > > getIdToLocSetMap(ProcHandle proc);
00111 
00116     void mapMemRefToEquivSet(MemRefHandle ref, int equivSetId);
00117 
00121     void mapMemRefToEquivSet(OA_ptr<MemRefExpr> ref, int setId);
00122 
00124     void mapMemRefToProc(MemRefHandle ref, ProcHandle proc);
00125 
00128     void mapAllToUnknown();
00129 
00130     //*****************************************************************
00131     // Output
00132     //*****************************************************************
00133 
00134     void output(OA::IRHandlesIRInterface& ir);
00135 
00138     void dump(std::ostream& os, OA_ptr<IRHandlesIRInterface> ir);
00139 
00140   private:
00141 OUTPUT
00142     // data members
00143       // the procedure each mem ref appears within
00144 GENOUT   std::map<MemRefHandle,ProcHandle> mMemRefToProc;
00145 
00146       // mapping of memory reference handles to equiv sets
00147       // can be mapped to multiple because can be mapped to
00148       // multiple MREs
00149 GENOUT   std::map<MemRefHandle,std::set<int> > mMemRefToSets;
00150 
00151        // each procedure will have a set of locations associated
00152        // with each equivset
00153 GENOUT    std::map<ProcHandle,std::map<int,std::set<OA_ptr<Location> > > > 
00154        mProcNSetToLocs;
00155 
00156     // the location set a MemRefExpr maps to
00157     GENOUT std::map<OA_ptr<MemRefExpr>,int> mMREToIdMap;  
00158 
00159 };
00160 
00161   } // end of Alias namespace
00162 } // end of OA namespace
00163 
00164 #endif
00165 

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