Go to the documentation of this file.00001
00015 #include "SideEffectStandard.hpp"
00016
00017 namespace OA {
00018 namespace SideEffect{
00019
00020 static bool debug = false;
00021
00022
00023
00024
00025
00026
00027 SideEffectStandard::SideEffectStandard()
00028 { OA_DEBUG_CTRL_MACRO("DEBUG_SideEffectStandard:ALL", debug);
00029
00030 mUnknownLocSet = new LocSet;
00031 OA_ptr<Location> uLoc;
00032
00033
00034 uLoc = new UnknownLoc();
00035 mUnknownLocSet->insert(uLoc);
00036 }
00037
00038 OA_ptr<LocIterator> SideEffectStandard::getLMODIterator()
00039 {
00040 OA_ptr<LocSetIterator> retval;
00041 if (mLMODSet.ptrEqual(0)) {
00042
00043 retval = new LocSetIterator(mUnknownLocSet);
00044 } else {
00045 retval = new LocSetIterator(mLMODSet);
00046 }
00047 return retval;
00048 }
00049
00050 OA_ptr<LocIterator> SideEffectStandard::getMODIterator()
00051 {
00052 OA_ptr<LocSetIterator> retval;
00053 if (mMODSet.ptrEqual(0)) {
00054
00055 retval = new LocSetIterator(mUnknownLocSet);
00056 } else {
00057 retval = new LocSetIterator(mMODSet);
00058 }
00059 return retval;
00060 }
00061
00066 OA_ptr<LocIterator> SideEffectStandard::getLDEFIterator()
00067 {
00068 OA_ptr<LocSetIterator> retval;
00069 if (mLDEFSet.ptrEqual(0)) {
00070 OA_ptr<LocSet> retSet; retSet = new LocSet;
00071 retval = new LocSetIterator(retSet);
00072 } else {
00073 retval = new LocSetIterator(mLDEFSet);
00074 }
00075 return retval;
00076 }
00077
00082 OA_ptr<LocIterator> SideEffectStandard::getDEFIterator()
00083 {
00084 OA_ptr<LocSetIterator> retval;
00085 if (mDEFSet.ptrEqual(0)) {
00086 OA_ptr<LocSet> retSet; retSet = new LocSet;
00087 retval = new LocSetIterator(retSet);
00088 } else {
00089 retval = new LocSetIterator(mDEFSet);
00090 }
00091 return retval;
00092 }
00093
00094 OA_ptr<LocIterator> SideEffectStandard::getLUSEIterator()
00095 {
00096 OA_ptr<LocSetIterator> retval;
00097 if (mLUSESet.ptrEqual(0)) {
00098
00099 retval = new LocSetIterator(mUnknownLocSet);
00100 } else {
00101 retval = new LocSetIterator(mLUSESet);
00102 }
00103 return retval;
00104 }
00105
00106 OA_ptr<LocIterator> SideEffectStandard::getUSEIterator()
00107 {
00108 OA_ptr<LocSetIterator> retval;
00109 if (mUSESet.ptrEqual(0)) {
00110
00111 retval = new LocSetIterator(mUnknownLocSet);
00112 } else {
00113 retval = new LocSetIterator(mUSESet);
00114 }
00115 return retval;
00116 }
00117
00118 OA_ptr<LocIterator> SideEffectStandard::getLREFIterator()
00119 {
00120 OA_ptr<LocSetIterator> retval;
00121 if (mLREFSet.ptrEqual(0)) {
00122
00123 retval = new LocSetIterator(mUnknownLocSet);
00124 } else {
00125 retval = new LocSetIterator(mLREFSet);
00126 }
00127 return retval;
00128 }
00129
00130 OA_ptr<LocIterator> SideEffectStandard::getREFIterator()
00131 {
00132 OA_ptr<LocSetIterator> retval;
00133 if (mREFSet.ptrEqual(0)) {
00134
00135 retval = new LocSetIterator(mUnknownLocSet);
00136 } else {
00137 retval = new LocSetIterator(mREFSet);
00138 }
00139 return retval;
00140 }
00141
00142
00143
00144
00146 bool SideEffectStandard::inLMOD(OA_ptr<Location> loc)
00147 {
00148 if (mLMODSet.ptrEqual(0)) {
00149 return false;
00150 } else {
00151 LocSet::iterator pos = mLMODSet->find(loc);
00152 return pos != mLMODSet->end();
00153 }
00154 }
00155
00157 bool SideEffectStandard::inMOD(OA_ptr<Location> loc)
00158 {
00159 if (mMODSet.ptrEqual(0)) {
00160 return false;
00161 } else {
00162 LocSet::iterator pos = mMODSet->find(loc);
00163 return pos != mMODSet->end();
00164 }
00165 }
00166
00168 bool SideEffectStandard::inLDEF(OA_ptr<Location> loc)
00169 {
00170 if (mLDEFSet.ptrEqual(0)) {
00171 return false;
00172 } else {
00173 LocSet::iterator pos = mLDEFSet->find(loc);
00174 return pos != mLDEFSet->end();
00175 }
00176 }
00177
00179 bool SideEffectStandard::inDEF(OA_ptr<Location> loc)
00180 {
00181 if (mDEFSet.ptrEqual(0)) {
00182 return false;
00183 } else {
00184 LocSet::iterator pos = mDEFSet->find(loc);
00185 return pos != mDEFSet->end();
00186 }
00187 }
00188
00190 bool SideEffectStandard::inLUSE(OA_ptr<Location> loc)
00191 {
00192 if (mLUSESet.ptrEqual(0)) {
00193 return false;
00194 } else {
00195 LocSet::iterator pos = mLUSESet->find(loc);
00196 return pos != mLUSESet->end();
00197 }
00198 }
00199
00201 bool SideEffectStandard::inUSE(OA_ptr<Location> loc)
00202 {
00203 if (mUSESet.ptrEqual(0)) {
00204 return false;
00205 } else {
00206 LocSet::iterator pos = mUSESet->find(loc);
00207 return pos != mUSESet->end();
00208 }
00209 }
00210
00212 bool SideEffectStandard::inLREF(OA_ptr<Location> loc)
00213 {
00214 if (mLREFSet.ptrEqual(0)) {
00215 return false;
00216 } else {
00217 LocSet::iterator pos = mLREFSet->find(loc);
00218 return pos != mLREFSet->end();
00219 }
00220 }
00221
00223 bool SideEffectStandard::inREF(OA_ptr<Location> loc)
00224 {
00225 if (mREFSet.ptrEqual(0)) {
00226 return false;
00227 } else {
00228 LocSet::iterator pos = mREFSet->find(loc);
00229 return pos != mREFSet->end();
00230 }
00231 }
00232
00233
00234
00235
00237 void SideEffectStandard::insertLMOD(OA_ptr<Location> loc)
00238 {
00239 if (mLMODSet.ptrEqual(0)) {
00240 mLMODSet = new LocSet;
00241 }
00242 mLMODSet->insert(loc);
00243 }
00244
00246 void SideEffectStandard::insertMOD(OA_ptr<Location> loc)
00247 {
00248 if (debug) {
00249 std::cout << "SideEffectStandard::insertMOD: loc = ";
00250 loc->dump(std::cout);
00251 }
00252 if (mMODSet.ptrEqual(0)) {
00253 mMODSet = new LocSet;
00254 if (debug) {
00255 std::cout << "SideEffectStandard::insertMOD: creating new LocSet"
00256 << std::endl;
00257 }
00258 }
00259 mMODSet->insert(loc);
00260 }
00261
00263 void SideEffectStandard::insertLDEF(OA_ptr<Location> loc)
00264 {
00265 if (mLDEFSet.ptrEqual(0)) {
00266 mLDEFSet = new LocSet;
00267 }
00268 mLDEFSet->insert(loc);
00269 }
00270
00272 void SideEffectStandard::insertDEF(OA_ptr<Location> loc)
00273 {
00274 if (mDEFSet.ptrEqual(0)) {
00275 mDEFSet = new LocSet;
00276 }
00277 mDEFSet->insert(loc);
00278 }
00279
00281 void SideEffectStandard::insertLUSE(OA_ptr<Location> loc)
00282 {
00283 if (mLUSESet.ptrEqual(0)) {
00284 mLUSESet = new LocSet;
00285 }
00286 if (debug) {
00287 std::cout << "LUseLocation insert = ";
00288 loc->dump(std::cout);
00289 }
00290
00291 mLUSESet->insert(loc);
00292
00293 }
00294
00296 void SideEffectStandard::insertUSE(OA_ptr<Location> loc)
00297 {
00298 if (mUSESet.ptrEqual(0)) {
00299 mUSESet = new LocSet;
00300 }
00301 if (debug) {
00302 std::cout << "UseLocation insert = ";
00303 loc->dump(std::cout);
00304 }
00305
00306 mUSESet->insert(loc);
00307
00308 if(debug)
00309 {
00310 LocSetIterator USElocIter(mUSESet);
00311 for (; USElocIter.isValid(); ++USElocIter) {
00312 OA_ptr<Location> loc = USElocIter.current();
00313 std::cout << "UseLocCompare";
00314 loc->dump(std::cout);
00315 std::cout << std::endl;
00316 }
00317 }
00318 }
00319
00321 void SideEffectStandard::insertLREF(OA_ptr<Location> loc)
00322 {
00323 if (mLREFSet.ptrEqual(0)) {
00324 mLREFSet = new LocSet;
00325 }
00326 mLREFSet->insert(loc);
00327 }
00328
00330 void SideEffectStandard::insertREF(OA_ptr<Location> loc)
00331 {
00332 if (mREFSet.ptrEqual(0)) {
00333 mREFSet = new LocSet;
00334 }
00335 mREFSet->insert(loc);
00336 }
00337
00338
00340 void SideEffectStandard::emptyLMOD()
00341 {
00342 mLMODSet = new LocSet;
00343 }
00344
00346 void SideEffectStandard::emptyMOD()
00347 {
00348 mMODSet = new LocSet;
00349 }
00350
00352 void SideEffectStandard::emptyLDEF()
00353 {
00354 mLDEFSet = new LocSet;
00355 }
00356
00358 void SideEffectStandard::emptyDEF()
00359 {
00360 mDEFSet = new LocSet;
00361 }
00362
00364 void SideEffectStandard::emptyLUSE()
00365 {
00366 mLUSESet = new LocSet;
00367 }
00368
00370 void SideEffectStandard::emptyUSE()
00371 {
00372 mUSESet = new LocSet;
00373 }
00374
00376 void SideEffectStandard::emptyLREF()
00377 {
00378 mLREFSet = new LocSet;
00379 }
00380
00382 void SideEffectStandard::emptyREF()
00383 {
00384 mREFSet = new LocSet;
00385 }
00386
00387
00388
00389
00390
00391
00392 void SideEffectStandard::dump(std::ostream& os, OA_ptr<IRHandlesIRInterface> ir)
00393 {
00394 std::cout << "====================== SideEffect" << std::endl;
00395
00396 OA_ptr<LocIterator> locIterPtr;
00397
00398 std::cout << "\tLMOD = ";
00399 locIterPtr = getLMODIterator();
00400 for ( ; locIterPtr->isValid(); (*locIterPtr)++ ) {
00401 locIterPtr->current()->dump(std::cout,ir);
00402 }
00403 std::cout << "\tMOD = ";
00404 locIterPtr = getMODIterator();
00405 for ( ; locIterPtr->isValid(); (*locIterPtr)++ ) {
00406 locIterPtr->current()->dump(std::cout,ir);
00407 }
00408 std::cout << std::endl;
00409
00410 std::cout << "\tLDEF = ";
00411 locIterPtr = getLDEFIterator();
00412 for ( ; locIterPtr->isValid(); (*locIterPtr)++ ) {
00413 locIterPtr->current()->dump(std::cout,ir);
00414 }
00415 std::cout << "\tDEF = ";
00416 locIterPtr = getDEFIterator();
00417 for ( ; locIterPtr->isValid(); (*locIterPtr)++ ) {
00418 locIterPtr->current()->dump(std::cout,ir);
00419 }
00420 std::cout << std::endl;
00421
00422 std::cout << "\tLUSE = ";
00423 locIterPtr = getLUSEIterator();
00424 for ( ; locIterPtr->isValid(); (*locIterPtr)++ ) {
00425 locIterPtr->current()->dump(std::cout,ir);
00426 }
00427 std::cout << "\tUSE = ";
00428 locIterPtr = getUSEIterator();
00429 for ( ; locIterPtr->isValid(); (*locIterPtr)++ ) {
00430 locIterPtr->current()->dump(std::cout,ir);
00431 }
00432 std::cout << std::endl;
00433
00434 std::cout << "\tLREF = ";
00435 locIterPtr = getLREFIterator();
00436 for ( ; locIterPtr->isValid(); (*locIterPtr)++ ) {
00437 locIterPtr->current()->dump(std::cout,ir);
00438 }
00439 std::cout << "\tREF = ";
00440 locIterPtr = getREFIterator();
00441 for ( ; locIterPtr->isValid(); (*locIterPtr)++ ) {
00442 locIterPtr->current()->dump(std::cout,ir);
00443 }
00444 std::cout << std::endl;
00445
00446 }
00447
00448 }
00449 }