DepStandard.cpp

Go to the documentation of this file.
00001 
00015 #include "DepStandard.hpp"
00016 #include <Utils/Util.hpp>
00017 
00018 namespace OA {
00019   namespace Activity {
00020 
00021 static bool debug = false;
00022 
00023 
00024 //*****************************************************************
00025 // Interface Implementation
00026 //*****************************************************************
00027     
00032 OA_ptr<LocIterator> 
00033 DepStandard::getMayDefIterator(StmtHandle stmt, const OA_ptr<Location> use)
00034 {
00035     OA_DEBUG_CTRL_MACRO("DEBUG_DepStandard:ALL", debug);
00036     if (mDepDFSet[stmt].ptrEqual(0)) {
00037         mDepDFSet[stmt] = new DepDFSet;
00038     }
00039     return mDepDFSet[stmt]->getDefsIterator(use);
00040 }
00041 
00048 OA_ptr<LocIterator> 
00049 DepStandard::getDiffUseIterator(StmtHandle stmt, OA_ptr<Location> def)
00050 {
00051     if (mDepDFSet[stmt].ptrEqual(0)) {
00052         mDepDFSet[stmt] = new DepDFSet;
00053     }
00054     if (debug) {
00055         mDepDFSet[stmt]->dump(std::cout);
00056     }
00057     return mDepDFSet[stmt]->getUsesIterator(def);
00058 }
00059     
00062 OA_ptr<LocIterator> DepStandard::getMustDefIterator(StmtHandle stmt)
00063 {
00064   OA_ptr<LocSetIterator> retval;
00065   if (mMustDefMap[stmt].ptrEqual(0)) {
00066     OA_ptr<LocSet> emptySet; emptySet = new LocSet;
00067     retval = new LocSetIterator(emptySet);  
00068   } else {
00069     retval = new LocSetIterator(mMustDefMap[stmt]); 
00070   }
00071   return retval;
00072 }
00073 
00074 
00075 //*****************************************************************
00076 // Construction methods
00077 //*****************************************************************
00078 
00080 void DepStandard::insertDepForStmt(StmtHandle stmt, 
00081                                    OA_ptr<Location> use,
00082                                    OA_ptr<Location> def)
00083 {
00084     assert(!use.ptrEqual(0));
00085     assert(!def.ptrEqual(0));
00086 
00087     // first make sure there is a DepDFSet for the given stmt
00088     if (mDepDFSet[stmt].ptrEqual(0)) {
00089         mDepDFSet[stmt] = new DepDFSet;
00090     }
00091 
00092     // then insert the dependence
00093     mDepDFSet[stmt]->insertDep(use,def);
00094 }
00095 
00097 void DepStandard::insertMustDefForStmt(StmtHandle stmt, 
00098                                        OA_ptr<Location> def)
00099 {
00100     if (mMustDefMap[stmt].ptrEqual(0)) {
00101         mMustDefMap[stmt] = new LocSet;
00102     }
00103     mMustDefMap[stmt]->insert(def);
00104  }
00105  
00106 //*****************************************************************
00107 // Output
00108 //*****************************************************************
00109 void DepStandard::dump(std::ostream& os, OA_ptr<IRHandlesIRInterface> ir)
00110 {
00111     std::cout << "====================== Dep" << std::endl;
00112 
00113     OA_ptr<LocIterator> locIterPtr;
00114     std::map<StmtHandle,OA_ptr<LocSet> >::iterator mapIter;
00115 
00116     std::cout << "MustDefMap = " << std::endl;
00117     for (mapIter=mMustDefMap.begin(); mapIter!=mMustDefMap.end(); mapIter++) {
00118         std::cout << "\tstmt = " << ir->toString(mapIter->first) << std::endl;
00119         locIterPtr = getMustDefIterator(mapIter->first);
00120         for ( ; locIterPtr->isValid(); (*locIterPtr)++ ) {
00121             std::cout << "\t\t";
00122             locIterPtr->current()->dump(std::cout,ir);
00123             std::cout << std::endl;
00124         }
00125     }
00126     std::cout << "DepDFSets = " << std::endl;
00127     std::map<StmtHandle,OA_ptr<DepDFSet> >::iterator mapIter2;
00128     for (mapIter2=mDepDFSet.begin(); mapIter2!=mDepDFSet.end(); mapIter2++) {
00129         std::cout << "\tstmt = " << ir->toString(mapIter2->first) << std::endl;
00130         if (!mDepDFSet[mapIter2->first].ptrEqual(NULL)) {
00131             OA_ptr<DepDFSet> depDFSet = mapIter2->second;
00132             depDFSet->dump(os,ir);
00133         }
00134     }
00135 
00136     std::cout << std::endl;
00137 }
00138 
00139   } // end of Activity namespace
00140 } // end of OA namespace

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