auto_LivenessStandard.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #ifndef LivenessStandard_hpp
00008 #define LivenessStandard_hpp
00009
00010 #include <cassert>
00011 #include <iostream>
00012 #include <map>
00013 #include <set>
00014 #include <vector>
00015 #include <OpenAnalysis/Utils/OA_ptr.hpp>
00016 #include <OpenAnalysis/IRInterface/IRHandles.hpp>
00017 #include <OpenAnalysis/IRInterface/LivenessIRInterface.hpp>
00018 #include <OpenAnalysis/OABase/Annotation.hpp>
00019 #include <OpenAnalysis/Utils/GenOutputTool.hpp>
00020 #include <OpenAnalysis/Location/Location.hpp>
00021 #include <OpenAnalysis/DataFlow/DFAGenDFSet.hpp>
00022 #include <OpenAnalysis/Utils/Util.hpp>
00023
00024 namespace OA {
00025 namespace Liveness {
00026
00027 typedef DataFlow::DFAGenDFSet<OA_ptr<Location> > LivenessDFSet;
00028
00029 class LivenessStandard : public virtual Annotation {
00030 public:
00031 LivenessStandard(ProcHandle p, OA_ptr<LivenessIRInterface> _ir) {
00032 mIR = _ir;
00033 mExitLiveness = new LivenessDFSet();
00034 }
00035 ~LivenessStandard() {}
00036
00037 LivenessDFSet::iterator getLivenessIterator(StmtHandle s);
00038
00039 LivenessDFSet::iterator getExitLivenessIterator();
00040
00041 void insert(StmtHandle s, OA_ptr<Location> val) {
00042 if(mLiveness[s].ptrEqual(0)) {
00043 mLiveness[s] = new LivenessDFSet();
00044 }
00045 mLiveness[s]->insert(val);
00046 }
00047
00048 void insertExit(OA_ptr<Location> val) {
00049 mExitLiveness->insert(val);
00050 }
00051
00052 OA_ptr<LivenessDFSet> getLivenessSet(StmtHandle s) {
00053 map<StmtHandle, OA_ptr<LivenessDFSet> >::iterator element =
00054 mLiveness.find(s);
00055
00056 if(element == mLiveness.end()) {
00057 mLiveness[s] = new LivenessDFSet();
00058 element = mLiveness.find(s);
00059 }
00060
00061 return (*element).second;
00062 }
00063
00064 void output(IRHandlesIRInterface& pIR);
00065
00066 void dump(std::ostream& os, OA_ptr<IRHandlesIRInterface> ir);
00067
00068 private:
00069 map<StmtHandle, OA_ptr<LivenessDFSet> > mLiveness;
00070 OA_ptr<LivenessDFSet> mExitLiveness;
00071 OA_ptr<LivenessIRInterface> mIR;
00072 };
00073
00074 }
00075 }
00076
00077 #endif
00078