DepDFSet.cpp

Go to the documentation of this file.
00001 
00015 #include "DepDFSet.hpp"
00016 #include <Utils/Util.hpp>
00017 
00018 namespace OA {
00019   namespace Activity {
00020 
00021 static bool debug = false;
00022 
00024 DepDFSet::DepDFSet() //: mMakeImplicitExplicitMemoized(false)
00025 {
00026     OA_DEBUG_CTRL_MACRO("DEBUG_DepDFSet:ALL", debug);
00027     mImplicitRemoves = new DataFlow::LocDFSet;
00028     mUses = new DataFlow::LocDFSet;
00029     mDefs = new DataFlow::LocDFSet;
00030 }
00031 
00033 DepDFSet::DepDFSet(const DepDFSet &other) //: mMakeImplicitExplicitMemoized(false)
00034 { 
00035     mImplicitRemoves = other.mImplicitRemoves;
00036     mUseToDefsMap = other.mUseToDefsMap;
00037     mDefToUsesMap = other.mDefToUsesMap;
00038     mDefs = other.mDefs;
00039     mUses = other.mUses;
00040 }
00041 
00043 DepDFSet& DepDFSet::operator=(const DepDFSet &other)
00044 {
00045     //mMakeImplicitExplicitMemoized = other.mMakeImplicitExplicitMemoized;
00046     mImplicitRemoves = other.mImplicitRemoves;
00047     mUseToDefsMap = other.mUseToDefsMap;
00048     mDefToUsesMap = other.mDefToUsesMap;
00049     mDefs = other.mDefs;
00050     mUses = other.mUses;
00051     return *this;
00052 }
00053 
00054 //*****************************************************************
00055 // DataFlowSet Interface Implementation
00056 //*****************************************************************
00057     
00058 OA_ptr<DataFlow::DataFlowSet> DepDFSet::clone()
00059 { 
00060     OA_ptr<DepDFSet> retval;
00061     retval = new DepDFSet(*this); 
00062     return retval; 
00063 }
00064 
00065 bool DepDFSet::operator==(DataFlow::DataFlowSet &other) const
00066 { 
00067     DepDFSet& recastOther = dynamic_cast<DepDFSet&>(other);
00068     bool retval = true;
00069 
00070     // make sure that each have their implicits made explicit
00071     // will have to copy our own because makeImplicitExplicit
00072     // changes the data-structure
00073     //DepDFSet copyThis = *this;
00074     //copyThis.makeImplicitExplicit();
00075     //recastOther.makeImplicitExplicit();
00076 
00077     if (mImplicitRemoves == recastOther.mImplicitRemoves
00078         && mUseToDefsMap == recastOther.mUseToDefsMap
00079         && mDefToUsesMap == recastOther.mDefToUsesMap) 
00080     {
00081         retval = true;
00082     } else {
00083         retval = false;
00084     }
00085 
00086     /*
00087     // make sure each dep pair in this is in other
00088     OA_ptr<DepIterator> depIter = getDepIterator();
00089     for ( ; depIter->isValid(); (*depIter)++ ) {
00090         OA_ptr<Location> use = depIter->use();
00091         OA_ptr<Location> def = depIter->def();
00092 
00093         bool found = false;
00094         OA_ptr<DepIterator> otherDepIter = recastOther.getDepIterator();
00095         for ( ; otherDepIter->isValid(); (*otherDepIter)++ ) {
00096             OA_ptr<Location> otherUse = otherDepIter->use();
00097             OA_ptr<Location> otherDef = otherDepIter->def();
00098 
00099             if (use==otherUse  && def==otherDef) {
00100                 found = true;
00101             }
00102         }
00103 
00104         if (!found) {
00105             retval = false;
00106         }
00107     }
00108     
00109     // make sure each dep pair in this is in other
00110     OA_ptr<DepIterator> otherDepIter = recastOther.getDepIterator();
00111     for ( ; otherDepIter->isValid(); (*otherDepIter)++ ) {
00112         OA_ptr<Location> otherUse = otherDepIter->use();
00113         OA_ptr<Location> otherDef = otherDepIter->def();
00114 
00115         bool found = false;
00116         OA_ptr<DepIterator> depIter = getDepIterator();
00117         for ( ; depIter->isValid(); (*depIter)++ ) {
00118             OA_ptr<Location> use = depIter->use();
00119             OA_ptr<Location> def = depIter->def();
00120 
00121             if (use==otherUse  && def==otherDef) {
00122                 found = true;
00123             }
00124         }
00125 
00126         if (!found) {
00127             retval = false;
00128         }
00129     }
00130 
00131     */
00132     if (debug) {
00133         std::cout << "operator= returning " <<  retval << std::endl;
00134     }
00135     return retval;
00136 
00137 }
00138 
00139 bool DepDFSet::operator!=(DataFlow::DataFlowSet &other) const
00140 {
00141     if (*this == other) {
00142         if (debug) { std::cout << "operator!= will return false" << std::endl; }
00143         return false;
00144     } else {
00145         if (debug) { std::cout << "operator!= will return true" << std::endl; }
00146         return true;
00147     }
00148 }
00149 
00150 //*****************************************************************
00151 // Methods specific to DepDFSet
00152 //*****************************************************************
00153 
00154 /*
00155 void DepDFSet::makeImplicitExplicit()
00156 {
00157     if (mMakeImplicitExplicitMemoized == true) { 
00158         return; 
00159     } else {
00160         mMakeImplicitExplicitMemoized = true;
00161     }
00162 
00163     // make all implicit deps that haven't been explicitly
00164     // removed explicit in the data-structure as well
00165     LocToLocDFSetMap::const_iterator mapIter;
00166     for (mapIter=mUseToDefsMap.begin(); mapIter!=mUseToDefsMap.end();
00167          mapIter++) 
00168     {
00169         if (! isImplicitRemoved(mapIter->first) ) {
00170             insertDep(mapIter->first,mapIter->first);
00171         }
00172     }
00173     for (mapIter=mDefToUsesMap.begin(); mapIter!=mDefToUsesMap.end();
00174          mapIter++) 
00175     {
00176         if (! isImplicitRemoved(mapIter->first) ) {
00177             insertDep(mapIter->first,mapIter->first);
00178         }
00179     }
00180 }
00181 */
00182 
00187 OA_ptr<DepIterator> DepDFSet::getDepIterator() const
00188 {
00189 
00190     // copy self and then create iterator for it
00191     OA_ptr<DepDFSet> setCopy; setCopy = new DepDFSet(*this);
00192     //setCopy->makeImplicitExplicit();
00193     OA_ptr<DepIterator> retval;
00194     retval = new DepIterator(setCopy);
00195     return retval;
00196 }
00197 
00198   
00199 OA_ptr<LocIterator> DepDFSet::getDefsIterator(const OA_ptr<Location> use) const
00200 {
00201     OA_ptr<DataFlow::LocDFSet> retSet;
00202     retSet = new DataFlow::LocDFSet();
00203 
00204     // get iterator over uses the given location overlaps with
00205     OA_ptr<LocIterator> useOverlapIter
00206         = mUses->getOverlapLocIterator(use);
00207     for ( ; useOverlapIter->isValid(); (*useOverlapIter)++ ) {
00208         OA_ptr<Location> loc = useOverlapIter->current();
00209 
00210         // iterator over associated defs
00211         LocToLocDFSetMap::const_iterator pos = mUseToDefsMap.find(loc);
00212         if (pos!=mUseToDefsMap.end()) {
00213             OA_ptr<LocIterator> locIter = pos->second->getLocIterator();
00214             for ( ; locIter->isValid(); (*locIter)++ ) {
00215                 retSet->insert(locIter->current());
00216             }
00217         }
00218     }
00219 
00220     // loop over sets that the use 
00221     /*
00222     LocToLocDFSetMap::const_iterator mapIter;
00223     for (mapIter=mUseToDefsMap.begin();
00224          mapIter!=mUseToDefsMap.end(); mapIter++ )
00225     {
00226         OA_ptr<Location> depuse = mapIter->first;
00227         if (depuse->mayOverlap(*use)) {
00228             OA_ptr<LocIterator> locIter = mapIter->second->getLocIterator();
00229             for ( ; locIter->isValid(); (*locIter)++ ) {
00230                 retSet->insert(locIter->current());
00231             }
00232         }
00233     }
00234     */
00235 
00236     // see if reflexive dep for use loc should be included,
00237     // only reason why it wouldn't is if use
00238     // is in the ImplicitRemoves
00239     // FIXME: ok could put hasMustOverlapLoc, but for now going with 
00240     // conservative assumption which means equivalenced symbols will get
00241     // short shrifted. insertDep if use==def makes same assumption.
00242     if (!mImplicitRemoves->hasLoc(use)) {
00243         retSet->insert(use);
00244     }
00245 
00246     // construct the iterator
00247     OA_ptr<DataFlow::LocDFSetIterator> retval;
00248     retval = new DataFlow::LocDFSetIterator(*retSet);
00249     return retval;
00250 }
00251   
00252 OA_ptr<LocIterator> DepDFSet::getUsesIterator(OA_ptr<Location> def) const
00253 {
00254     OA_ptr<DataFlow::LocDFSet> retSet;
00255     retSet = new DataFlow::LocDFSet();
00256 
00257     // get iterator over uses the given location overlaps with
00258     OA_ptr<LocIterator> defOverlapIter
00259         = mDefs->getOverlapLocIterator(def);
00260     for ( ; defOverlapIter->isValid(); (*defOverlapIter)++ ) {
00261         OA_ptr<Location> loc = defOverlapIter->current();
00262         if (debug) {
00263             std::cout << "getUsesIterator: loc = ";
00264             loc->dump(std::cout);
00265         }
00266 
00267         // iterator over associated deps
00268         LocToLocDFSetMap::const_iterator pos = mDefToUsesMap.find(loc);
00269         if (pos!=mDefToUsesMap.end()) {
00270             OA_ptr<LocIterator> locIter = pos->second->getLocIterator();
00271             for ( ; locIter->isValid(); (*locIter)++ ) {
00272                 retSet->insert(locIter->current());
00273             }
00274         }
00275     }
00276 
00277     /*
00278     LocToLocDFSetMap::const_iterator mapIter;
00279     for (mapIter=mDefToUsesMap.begin();
00280          mapIter!=mDefToUsesMap.end(); mapIter++ )
00281     {
00282         OA_ptr<Location> depdef = mapIter->first;
00283         if (depdef->mayOverlap(*def)) {
00284             OA_ptr<LocIterator> locIter = mapIter->second->getLocIterator();
00285             for ( ; locIter->isValid(); (*locIter)++ ) {
00286                 retSet->insert(locIter->current());
00287             }
00288         }
00289     }
00290     */
00291 
00292     // see if reflexive dep for def loc should be included,
00293     // only reason why it wouldn't is if def
00294     // is in the ImplicitRemoves
00295     // FIXME: ok could put hasMustOverlapLoc, but for now going with 
00296     // conservative assumption which means equivalenced symbols will get
00297     // short shrifted
00298     if (!mImplicitRemoves->hasLoc(def)) {
00299         retSet->insert(def);
00300     }
00301 
00302     OA_ptr<DataFlow::LocDFSetIterator> retval;
00303     retval = new DataFlow::LocDFSetIterator(*retSet);
00304     return retval;
00305 }
00306 
00310 DepDFSet& DepDFSet::setUnion(DataFlow::DataFlowSet &other)
00311 {
00312     DepDFSet& recastOther = dynamic_cast<DepDFSet&>(other);
00313     if (debug) {
00314         std::cout << "DepDFSet::setUnion" << std::endl;
00315     }
00316 
00317     // for each use in other
00318     LocToLocDFSetMap::const_iterator mapIter;
00319     for (mapIter=recastOther.mUseToDefsMap.begin();
00320          mapIter!=recastOther.mUseToDefsMap.end(); mapIter++ )
00321     {
00322         OA_ptr<Location> use = mapIter->first;
00323 
00324         // if this use is already in our map then just union it into
00325         // the associated defs location set
00326         // if not then will have to make a new LocDFSet and
00327         // then essentially do the same thing
00328         if (mUseToDefsMap[use].ptrEqual(0)) {
00329             mUseToDefsMap[use] = new DataFlow::LocDFSet;
00330         }
00331         *(mUseToDefsMap[use]) 
00332             = mUseToDefsMap[use]->setUnion(*(mapIter->second));
00333     }
00334     
00335     // for each def in other
00336     for (mapIter=recastOther.mDefToUsesMap.begin();
00337          mapIter!=recastOther.mDefToUsesMap.end(); mapIter++ )
00338     {
00339         OA_ptr<Location> def = mapIter->first;
00340 
00341         if (mDefToUsesMap[def].ptrEqual(0)) {
00342             mDefToUsesMap[def] = new DataFlow::LocDFSet;
00343         }
00344         mDefToUsesMap[def]->setUnion(*(mapIter->second));
00345     }
00346 
00347     // take on all of other's implicitRemoves that we already have
00348     mImplicitRemoves->setIntersect(*(recastOther.mImplicitRemoves));
00349 
00350     // union the uses and defs sets
00351     mUses->setUnion(*(recastOther.mUses));
00352     mDefs->setUnion(*(recastOther.mDefs));
00353 
00354     return *this;
00355 }
00356 
00357 
00360 bool DepDFSet::isImplicitRemoved(const OA_ptr<Location> loc) const
00361 {
00362     return mImplicitRemoves->hasLoc(loc);
00363 }
00364 
00383 DepDFSet& DepDFSet::compose(DataFlow::DataFlowSet &other)
00384 {
00385     DepDFSet& recastOther = dynamic_cast<DepDFSet&>(other);
00386     if (debug) {
00387         std::cout << "DepDFSet::compose" << std::endl;
00388         std::cout << "\t*this = ";
00389         dump(std::cout);
00390         std::cout << "\tother = ";
00391         recastOther.dump(std::cout);
00392     }
00393     
00394     OA_ptr<DepDFSet> tempDFSet;
00395     tempDFSet = new DepDFSet;
00396     
00397     // have to do these before do insertDeps because could be inserting
00398     // a dep that will take things out of the mImplicitRemoves set
00399     tempDFSet->mImplicitRemoves->setUnion(*(mImplicitRemoves)); 
00400     tempDFSet->mImplicitRemoves->setUnion(*(recastOther.mImplicitRemoves)); 
00401 
00402     // iterate over deps in this keying off the def
00403     // see if the def overlaps with anything in recastOther
00404     LocToLocDFSetMap::const_iterator mapIter;
00405     for (mapIter=mDefToUsesMap.begin();
00406          mapIter!=mDefToUsesMap.end(); mapIter++ )
00407     {
00408         OA_ptr<Location> def1 = mapIter->first;
00409         if (debug) {
00410             std::cout << "def1 = "; def1->dump(std::cout); 
00411             std::cout << std::endl;
00412         }
00413         OA_ptr<DataFlow::LocDFSet> use1Set = mapIter->second;
00414         if (debug) {
00415             std::cout << "use1Set = "; use1Set->dump(std::cout);
00416         }
00417 
00418         // get all the defs in use2,def2 where def1 overlaps with use2
00419         OA_ptr<LocIterator> def2Iter = recastOther.getDefsIterator(def1);
00420 
00421         // loop over all use1,def1 pairs
00422         OA_ptr<LocIterator> use1Iter = use1Set->getLocIterator();
00423         for ( ; use1Iter->isValid(); (*use1Iter)++ ) {
00424             OA_ptr<Location> use1 = use1Iter->current();
00425 
00426             // get all the defs in use2, def2 where def1 overlaps with use2
00427             for (def2Iter->reset(); def2Iter->isValid(); (*def2Iter)++ ) {
00428                 tempDFSet->insertDep(use1, def2Iter->current());
00429                 if (debug) {
00430                     std::cout << "inserting <use1,def2Iter->current> = "; 
00431                     use1->dump(std::cout); 
00432                     std::cout << " , ";
00433                     def2Iter->current()->dump(std::cout); 
00434                     std::cout << std::endl;
00435                 }
00436             }
00437 
00438             /*
00439             // as long as d,d has not been removed from recastOther,
00440             // where d overlaps def1, we should add use1,def1 to result
00441             // if it was removed but is explicitly in recastOther then
00442             // use1,def1 was correctly inserted into the result in above code
00443             // eg. x = x + y, x,x will be explictly in recastOther and
00444             // be an implicit that is removed due to the mustdef of x
00445             if (! recastOther.isImplicitRemoved(def1) ) {
00446                 tempDFSet->insertDep(use1,def1);
00447                 if (debug) {
00448                     std::cout << "inserting <use1,def1> = "; 
00449                     use1->dump(std::cout); 
00450                     std::cout << " , ";
00451                     def1->dump(std::cout); 
00452                     std::cout << std::endl;
00453                 }
00454             }
00455             */
00456         }
00457     }
00458 
00459     // iterate over deps in recastOther keying off the use
00460     // see if the use overlaps with anything in this
00461     // even if it doesn't insert dep pairs for use,def 
00462     // as long as use,use hasn't been removed from this
00463     for (mapIter=recastOther.mUseToDefsMap.begin();
00464          mapIter!=recastOther.mUseToDefsMap.end(); mapIter++ )
00465     {
00466         OA_ptr<Location> use2 = mapIter->first;
00467         if (debug) {
00468             std::cout << "use2 = "; use2->dump(std::cout); 
00469             std::cout << std::endl;
00470         }
00471         OA_ptr<DataFlow::LocDFSet> def2Set = mapIter->second;
00472         assert(!def2Set.ptrEqual(0));
00473         if (debug) {
00474             std::cout << "def2Set = ";
00475             def2Set->dump(std::cout);
00476         }
00477 
00478         OA_ptr<LocIterator> use1Iter = getUsesIterator(use2);
00479 
00480         // loop over all use2,def2 pairs
00481         OA_ptr<LocIterator> def2Iter = def2Set->getLocIterator();
00482         for ( ; def2Iter->isValid(); (*def2Iter)++ ) {
00483             OA_ptr<Location> def2 = def2Iter->current();
00484 
00485             // get all the uses in use1,def1 where def1 overlaps with use2
00486             for (use1Iter->reset(); use1Iter->isValid(); (*use1Iter)++ ) {
00487                 tempDFSet->insertDep(use1Iter->current(), def2);
00488                 if (debug) {
00489                     std::cout << "inserting <use1Iter->current,def2> = "; 
00490                     use1Iter->current()->dump(std::cout); 
00491                     std::cout << " , ";
00492                     def2->dump(std::cout); 
00493                     std::cout << std::endl;
00494                 }
00495             }
00496 
00497             /*
00498             // as long as u,u has not been removed from this,
00499             // where u overlaps use2, we should add use2,def2 to result
00500             if (! isImplicitRemoved(use2) ) {
00501                 tempDFSet->insertDep(use2,def2);
00502                 if (debug) {
00503                     std::cout << "inserting <use2,def2> = "; 
00504                     use2->dump(std::cout); 
00505                     std::cout << " , ";
00506                     def2->dump(std::cout); 
00507                     std::cout << std::endl;
00508                 }
00509             }
00510             */
00511         }
00512     }
00513 
00514     (*this) = *tempDFSet;
00515     if (debug) {
00516         std::cout << "\t*this = ";
00517         dump(std::cout);
00518     }
00519     
00520 
00521     return (*this);
00522 }
00523 
00530 /*
00531 DepDFSet& DepDFSet::setIntersect(DataFlowSet &other)
00532 {
00533     assert(0);
00534 }
00535 */
00536 
00537 //*****************************************************************
00538 // Output
00539 //*****************************************************************
00540 void DepDFSet::dump(std::ostream &os) 
00541 {
00542   /*  
00543     os << "\tmUseToDefsMap.size() = " << mUseToDefsMap.size() << std::endl;
00544     os << "\tmDefToUsesMap.size() = " << mDefToUsesMap.size() << std::endl;
00545    */ 
00546    
00547     os << "\tuses" << std::endl;
00548     // iterate over all uses
00549     std::map<OA_ptr<Location>,OA_ptr<DataFlow::LocDFSet> >::const_iterator 
00550         mapIter;
00551     for (mapIter=mUseToDefsMap.begin();
00552          mapIter!=mUseToDefsMap.end(); mapIter++ )
00553     {
00554         OA_ptr<Location> use = mapIter->first;
00555         OA_ptr<DataFlow::LocDFSet> locset = mapIter->second;
00556 
00557         os << "\t\t";
00558         use->dump(os);
00559         os << " ==> ";
00560         locset->dump(os);
00561         os << std::endl;
00562     }
00563     
00564     os << "\tdefs" << std::endl;
00565     // iterate over all defs
00566     for (mapIter=mDefToUsesMap.begin();
00567          mapIter!=mDefToUsesMap.end(); mapIter++ )
00568     {
00569         OA_ptr<Location> def = mapIter->first;
00570         OA_ptr<DataFlow::LocDFSet> locset = mapIter->second;
00571 
00572         os << "\t\t";
00573         def->dump(os);
00574         os << " ==> ";
00575         locset->dump(os);
00576         os << std::endl;
00577     }
00578    
00579     os << "\tmImplicitRemoves = ";
00580     mImplicitRemoves->dump(os);
00581   
00582     os << "\tmUses = ";
00583     mUses->dump(os);
00584   
00585     os << "\tmDefs = ";
00586     mDefs->dump(os);
00587 
00588 }
00589 
00590 void DepDFSet::dump(std::ostream &os) const
00591 {
00592    
00593 /*
00594     os << "\tmUseToDefsMap.size() = " << mUseToDefsMap.size() << std::endl;
00595     os << "\tmDefToUsesMap.size() = " << mDefToUsesMap.size() << std::endl;
00596 */
00597 
00598     os << "\tuses" << std::endl;
00599     // iterate over all uses
00600     std::map<OA_ptr<Location>,OA_ptr<DataFlow::LocDFSet> >::const_iterator 
00601         mapIter;
00602     for (mapIter=mUseToDefsMap.begin();
00603          mapIter!=mUseToDefsMap.end(); mapIter++ )
00604     {
00605         OA_ptr<Location> use = mapIter->first;
00606         OA_ptr<DataFlow::LocDFSet> locset = mapIter->second;
00607 
00608         os << "\t\t";
00609         use->dump(os);
00610         os << " ==> ";
00611         locset->dump(os);
00612         os << std::endl;
00613     }
00614     
00615     os << "\tdefs" << std::endl;
00616     // iterate over all defs
00617     for (mapIter=mDefToUsesMap.begin();
00618          mapIter!=mDefToUsesMap.end(); mapIter++ )
00619     {
00620         OA_ptr<Location> def = mapIter->first;
00621         OA_ptr<DataFlow::LocDFSet> locset = mapIter->second;
00622 
00623         os << "\t\t";
00624         def->dump(os);
00625         os << " ==> ";
00626         locset->dump(os);
00627         os << std::endl;
00628     }
00629    
00630     os << "\tmImplicitRemoves = ";
00631     mImplicitRemoves->dump(os);
00632   
00633     os << "\tmUses = ";
00634     mUses->dump(os);
00635   
00636     os << "\tmDefs = ";
00637     mDefs->dump(os);
00638 
00639  }
00640 
00641 
00642 void DepDFSet::dump(std::ostream &os, OA_ptr<IRHandlesIRInterface> ir) 
00643 {
00644 /*
00645     os << "\tmUseToDefsMap.size() = " << mUseToDefsMap.size() << std::endl;
00646     os << "\tmDefToUsesMap.size() = " << mDefToUsesMap.size() << std::endl;
00647 */
00648 
00649 
00650     os << "\tuses" << std::endl;
00651     // iterate over all uses
00652     std::map<OA_ptr<Location>,OA_ptr<DataFlow::LocDFSet> >::const_iterator mapIter;
00653     for (mapIter=mUseToDefsMap.begin();
00654          mapIter!=mUseToDefsMap.end(); mapIter++ )
00655     {
00656         OA_ptr<Location> use = mapIter->first;
00657         OA_ptr<DataFlow::LocDFSet> locset = mapIter->second;
00658 
00659         os << "\t\t";
00660         use->dump(os,ir);
00661         os << " ==> ";
00662         locset->dump(os,ir);
00663         os << std::endl;
00664     }
00665     
00666     os << "\tdefs" << std::endl;
00667     // iterate over all defs
00668     for (mapIter=mDefToUsesMap.begin();
00669          mapIter!=mDefToUsesMap.end(); mapIter++ )
00670     {
00671         OA_ptr<Location> def = mapIter->first;
00672         OA_ptr<DataFlow::LocDFSet> locset = mapIter->second;
00673 
00674         os << "\t\t";
00675         def->dump(os,ir);
00676         os << " ==> ";
00677         locset->dump(os,ir);
00678         os << std::endl;
00679     }
00680     
00681     // dump implicitRemoves
00682     os << "\tmImplicitRemoves = ";
00683     mImplicitRemoves->dump(os,ir); 
00684   
00685     os << "\tmUses = ";
00686     mUses->dump(os,ir);
00687   
00688     os << "\tmDefs = ";
00689     mDefs->dump(os,ir);
00690 
00691 }
00692 
00693 void DepDFSet::output(OA::IRHandlesIRInterface& ir) {
00694     
00695     // iterate over all uses
00696     sOutBuild->mapStart("mUseToDefsMap","UseLoc","DefLocSet");
00697     std::map<OA_ptr<Location>,OA_ptr<DataFlow::LocDFSet> >::const_iterator mapIter;
00698     for (mapIter=mUseToDefsMap.begin();
00699          mapIter!=mUseToDefsMap.end(); mapIter++ )
00700     {
00701         OA_ptr<Location> use = mapIter->first;
00702         OA_ptr<DataFlow::LocDFSet> locset = mapIter->second;
00703         sOutBuild->mapEntryStart();
00704           sOutBuild->mapKeyStart();
00705             use->output(ir);
00706           sOutBuild->mapKeyEnd();
00707           sOutBuild->mapValueStart();
00708             locset->output(ir);
00709           sOutBuild->mapValueEnd();
00710         sOutBuild->mapEntryEnd();
00711     }
00712     sOutBuild->mapEnd("mUseToDefsMap");
00713     
00714     // iterate over all defs
00715     sOutBuild->mapStart("mDefToUsesMap","DefLoc","UseLocSet");
00716     for (mapIter=mDefToUsesMap.begin();
00717          mapIter!=mDefToUsesMap.end(); mapIter++ )
00718     {
00719         OA_ptr<Location> def = mapIter->first;
00720         OA_ptr<DataFlow::LocDFSet> locset = mapIter->second;
00721         sOutBuild->mapEntryStart();
00722           sOutBuild->mapKeyStart();
00723             def->output(ir);
00724           sOutBuild->mapKeyEnd();
00725           sOutBuild->mapValueStart();
00726             locset->output(ir);
00727           sOutBuild->mapValueEnd();
00728         sOutBuild->mapEntryEnd();
00729     }
00730     sOutBuild->mapEnd("mDefToUsesMap");
00731 
00732     
00733     // dump implicitRemoves
00734     std::ostringstream label1;
00735     label1 << indt << "ImplicitRemoves:";
00736     sOutBuild->outputString( label1.str() );
00737     mImplicitRemoves->output(ir); 
00738 
00739     std::ostringstream label2;
00740     label2 << indt << "Uses:";
00741     sOutBuild->outputString( label2.str() );
00742     mUses->output(ir); 
00743 
00744     std::ostringstream label3;
00745     label3 << indt << "Defs:";
00746     sOutBuild->outputString( label3.str() );
00747     mDefs->output(ir); 
00748     
00749 }
00750 
00751 
00752 //*****************************************************************
00753 // Construction
00754 //*****************************************************************
00755   
00768 void DepDFSet::insertDep(OA_ptr<Location> use, OA_ptr<Location> def)
00769 {
00770     if (use==def) {
00771         mImplicitRemoves->remove(use);
00772 
00773     } else {
00774         if (mUseToDefsMap[use].ptrEqual(0)) {
00775             mUseToDefsMap[use] = new DataFlow::LocDFSet;
00776         }
00777         if (mDefToUsesMap[def].ptrEqual(0)) {
00778             mDefToUsesMap[def] = new DataFlow::LocDFSet;
00779         }
00780 
00781         mUseToDefsMap[use]->insert(def);
00782         mDefToUsesMap[def]->insert(use);
00783 
00784         mUses->insert(use);
00785         mDefs->insert(def);
00786     }
00787 }
00788 
00794 void DepDFSet::removeImplicitDep(OA_ptr<Location> use, OA_ptr<Location> def)
00795 {
00796 //    mMakeImplicitExplicitMemoized = false;
00797     // to be conservative only insert locations when the use and def must
00798     // overlap each other, sublocs that only have partial accuracy will
00799     // only may loc
00800     if (use->mustOverlap(*def)) {
00801         mImplicitRemoves->insert(use);
00802     }
00803 }
00804 
00805   } // end of Activity namespace
00806 } // end of OA namespace