Go to the documentation of this file.00001
00016 #include "LinearityDepsSet.hpp"
00017 using namespace OA;
00019 namespace OA {
00020 namespace Linearity {
00021
00022
00023
00024
00025
00026 LinearityDepsSet::LinearityDepsSet()
00027 {
00028 vcSet= new std::set<OA_ptr<VarClassPair> >;
00029 }
00030
00031
00032
00033
00034 LinearityDepsSet::LinearityDepsSet(double)
00035 {
00036 vcSet= new std::set<OA_ptr<VarClassPair> >;
00037 }
00038
00039
00040
00041
00042
00043 LinearityDepsSet::LinearityDepsSet(OA_ptr<Location> v, OA_ptr<LinearityDepsSet> deps)
00044 {
00045
00046 vcSet= new std::set<OA_ptr<VarClassPair> >;
00047
00048 LinearityClass lc(LinearityClass::LCLASS_LINEAR);
00049
00050 OA_ptr<VarClassPair> vcp;
00051 vcp = new VarClassPair(v,lc);
00052
00053
00054 deps->insert(vcp);
00055 vcSet = deps->getSet();
00056 }
00057
00058
00059
00060
00061
00062
00063
00064 OA_ptr<LinearityDepsSet> LinearityDepsSet::multdiv(OA_ptr<LinearityDepsSet> deps)
00065 {
00066
00067
00068 OA_ptr<LinearityDepsSet> retval;
00069 retval = new LinearityDepsSet;
00070
00071
00072 LinearityClass lc(LinearityClass::LCLASS_NONLINEAR);
00073
00074
00075 OA_ptr<VarClassPairIterator> thisIter;
00076 thisIter = new VarClassPairIterator(vcSet);
00077
00078 OA_ptr<VarClassPairIterator> otherIter;
00079 otherIter = deps->getVarClassPairIterator();
00080
00081 OA_ptr<VarClassPair> vcp;
00082
00083 for ( ; thisIter->isValid(); (*thisIter)++){
00084
00085
00086 vcp = new VarClassPair(thisIter->current()->getVar(),lc);
00087 retval->insert(vcp);
00088 }
00089 for ( ; otherIter->isValid(); (*otherIter)++){
00090
00091
00092 vcp = new VarClassPair(otherIter->current()->getVar(),lc);
00093 retval->insert(vcp);
00094 }
00095
00096
00097 return retval;
00098 }
00099
00100
00101
00102
00103
00104
00105 OA_ptr<LinearityDepsSet> LinearityDepsSet::addsub(OA_ptr<LinearityDepsSet> deps)
00106 {
00107
00108
00109
00110
00111 OA_ptr<LinearityDepsSet> retval;
00112 retval = new LinearityDepsSet;
00113
00114 retval = deps;
00115
00116
00117 OA_ptr<VarClassPairIterator> thisIter;
00118 thisIter = new VarClassPairIterator(vcSet);
00119
00120 OA_ptr<VarClassPairIterator> otherIter;
00121 otherIter = deps->getVarClassPairIterator();
00122
00123 OA_ptr<VarClassPair> vcp;
00124
00125 for ( ; thisIter->isValid(); (*thisIter)++){
00126
00127 OA_ptr<VarClassPair> vcthis;
00128 vcthis = thisIter->current();
00129
00130 otherIter->findIter(vcthis);
00131
00132
00133 if (otherIter->isValid()){
00134 OA_ptr<VarClassPair> vcother;
00135 vcother = otherIter->current();
00136
00137
00138
00139 LinearityClass lc = vcthis->getLClass().meet(vcother->getLClass());
00140 vcp = new VarClassPair(vcother->getVar(),lc);
00141 retval->erase(vcp);
00142 retval->insert(vcp);
00143 } else {
00144 retval->insert(vcthis);
00145 }
00146 }
00147
00148
00149
00150 return retval;
00151 }
00152
00153
00154
00155
00156
00157 OA_ptr<LinearityDepsSet> LinearityDepsSet::func(OA_ptr<LinearityDepsSet> deps)
00158 {
00159
00160
00161 OA_ptr<LinearityDepsSet> retval;
00162 retval = new LinearityDepsSet;
00163
00164
00165 LinearityClass lc(LinearityClass::LCLASS_NONLINEAR);
00166
00167
00168
00169
00170
00171 OA_ptr<VarClassPairIterator> otherIter;
00172 otherIter = deps->getVarClassPairIterator();
00173
00174 OA_ptr<VarClassPair> vcp;
00175
00176
00177
00178
00179
00180
00181
00182 for ( ; otherIter->isValid(); (*otherIter)++){
00183
00184
00185 vcp = new VarClassPair(otherIter->current()->getVar(),lc);
00186 retval->insert(vcp);
00187 }
00188
00189
00190 return retval;
00191 }
00192
00193
00194
00195
00196
00197
00198 OA_ptr<LinearityDepsSet> LinearityDepsSet::power1(OA_ptr<LinearityDepsSet> deps)
00199 {
00200
00201 OA_ptr<LinearityDepsSet> retval;
00202 retval = new LinearityDepsSet;
00203
00204
00205 LinearityClass lc1(LinearityClass::LCLASS_LINEAR);
00206
00207
00208 OA_ptr<VarClassPairIterator> otherIter;
00209 otherIter = deps->getVarClassPairIterator();
00210
00211 OA_ptr<VarClassPair> vcp;
00212
00213 for ( ; otherIter->isValid(); (*otherIter)++){
00214
00215
00216 LinearityClass lc = lc1.meet(otherIter->current()->getLClass());
00217 vcp = new VarClassPair(otherIter->current()->getVar(),lc);
00218 retval->insert(vcp);
00219 }
00220
00221 return retval;
00222 }
00223
00224
00225
00226
00227
00228
00229 OA_ptr<LinearityDepsSet> LinearityDepsSet::powerk(OA_ptr<LinearityDepsSet> deps)
00230 {
00231
00232 OA_ptr<LinearityDepsSet> retval;
00233 retval = new LinearityDepsSet;
00234
00235
00236 LinearityClass lc1(LinearityClass::LCLASS_NONLINEAR);
00237
00238
00239 OA_ptr<VarClassPairIterator> otherIter;
00240 otherIter = deps->getVarClassPairIterator();
00241
00242 OA_ptr<VarClassPair> vcp;
00243
00244 for ( ; otherIter->isValid(); (*otherIter)++){
00245
00246
00247 LinearityClass lc = lc1.meet(otherIter->current()->getLClass());
00248 vcp = new VarClassPair(otherIter->current()->getVar(),lc);
00249 retval->insert(vcp);
00250 }
00251
00252 return retval;
00253 }
00254
00255
00256
00257
00258
00259
00260 OA_ptr<LinearityDepsSet> LinearityDepsSet::anyopk()
00261 {
00262
00263 OA_ptr<LinearityDepsSet> retval;
00264 retval = new LinearityDepsSet;
00265
00266
00267 LinearityClass lc1(LinearityClass::LCLASS_LINEAR);
00268
00269
00270 OA_ptr<VarClassPairIterator> thisIter;
00271 thisIter = new VarClassPairIterator(vcSet);
00272
00273 OA_ptr<VarClassPair> vcp;
00274
00275 for ( ; thisIter->isValid(); (*thisIter)++){
00276
00277
00278 LinearityClass lc = lc1.meet(thisIter->current()->getLClass());
00279 vcp = new VarClassPair(thisIter->current()->getVar(),lc);
00280 retval->insert(vcp);
00281 }
00282
00283 return retval;
00284 }
00285
00286
00287
00288
00289
00290
00291 OA_ptr<LinearityDepsSet> LinearityDepsSet::linear()
00292 {
00293
00294 OA_ptr<LinearityDepsSet> retval;
00295 retval = new LinearityDepsSet;
00296
00297
00298 LinearityClass lc1(LinearityClass::LCLASS_LINEAR);
00299
00300
00301 OA_ptr<VarClassPairIterator> thisIter;
00302 thisIter = new VarClassPairIterator(vcSet);
00303
00304 OA_ptr<VarClassPair> vcp;
00305
00306 for ( ; thisIter->isValid(); (*thisIter)++){
00307
00308
00309 LinearityClass lc = lc1.meet(thisIter->current()->getLClass());
00310 vcp = new VarClassPair(thisIter->current()->getVar(),lc);
00311 retval->insert(vcp);
00312 }
00313
00314 return retval;
00315 }
00316
00317
00318
00319
00320
00321
00322 OA_ptr<LinearityDepsSet> LinearityDepsSet::nonlinear()
00323 {
00324
00325 OA_ptr<LinearityDepsSet> retval;
00326 retval = new LinearityDepsSet;
00327
00328
00329 LinearityClass lc1(LinearityClass::LCLASS_NONLINEAR);
00330
00331
00332 OA_ptr<VarClassPairIterator> thisIter;
00333 thisIter = new VarClassPairIterator(vcSet);
00334
00335 OA_ptr<VarClassPair> vcp;
00336
00337 for ( ; thisIter->isValid(); (*thisIter)++){
00338
00339
00340 LinearityClass lc = lc1.meet(thisIter->current()->getLClass());
00341 vcp = new VarClassPair(thisIter->current()->getVar(),lc);
00342 retval->insert(vcp);
00343 }
00344
00345 return retval;
00346 }
00347
00348
00349
00350 OA_ptr<LinearityDepsSet> LinearityDepsSet::meet( OA_ptr<LinearityDepsSet> other )
00351 {
00352
00353 OA_ptr<LinearityDepsSet> result;
00354 result = new LinearityDepsSet();
00355
00356
00357 if (other.ptrEqual(0)) {
00358 assert(0);
00359 }
00360 result = other;
00361
00362
00363 OA_ptr<VarClassPairIterator> thisIter;
00364 thisIter = new VarClassPairIterator(vcSet);
00365
00366 OA_ptr<VarClassPairIterator> vcIter;
00367 vcIter = other->getVarClassPairIterator();
00368
00369
00370 for( ; thisIter->isValid(); (*thisIter)++)
00371 {
00372 OA_ptr<VarClassPair> vcthis;
00373 vcthis = thisIter->current();
00374
00375 vcIter->findIter(vcthis);
00376
00377
00378 if (vcIter->isValid())
00379 {
00380 OA_ptr<VarClassPair> vcp;
00381 vcp = vcIter->current();
00382
00383
00384 LinearityClass lc = vcthis->getLClass().meet(vcp->getLClass());
00385 if (lc == vcthis->getLClass()) { result->insert(vcthis); }
00386 else { result->insert(vcp); }
00387 } else {
00388
00389 result->insert(vcthis);
00390 }
00391 }
00392 return result;
00393 }
00394
00395 void LinearityDepsSet::insert(OA_ptr<VarClassPair> vcp)
00396 {
00397 vcSet->insert(vcp);
00398 }
00399
00400 void LinearityDepsSet::erase(OA_ptr<VarClassPair> vcp)
00401 {
00402 vcSet->erase(vcp);
00403 }
00404
00405
00406 OA_ptr<VarClassPairIterator> LinearityDepsSet::getVarClassPairIterator( )
00407 {
00408
00409 OA_ptr<VarClassPairIterator> retval;
00410 retval = new VarClassPairIterator(vcSet);
00411 return retval;
00412 }
00413
00414
00415
00416 OA_ptr<std::set<OA_ptr<LinearityPair> > > LinearityDepsSet::convertToLinearityPair(OA_ptr<Location> v)
00417 {
00418 OA_ptr<std::set<OA_ptr<LinearityPair> > > result;
00419 result = new std::set<OA_ptr<LinearityPair> >;
00420 OA_ptr<VarClassPairIterator> ldsIter;
00421 ldsIter = new VarClassPairIterator(vcSet);
00422
00423 for ( ;ldsIter->isValid();(*ldsIter)++) {
00424 OA_ptr<VarClassPair> vcPair = ldsIter->current();
00425
00426 OA_ptr<LinearityPair> lp;
00427 lp = new LinearityPair(v,vcPair->getVar(),vcPair->getLClass());
00428
00429 result->insert(lp);
00430 }
00431 return result;
00432 }
00433
00434 void LinearityDepsSet::output(IRHandlesIRInterface& ir) {
00435
00436 sOutBuild->objStart("LinearityDepsSet");
00437 sOutBuild->listStart();
00438
00439 OA_ptr<VarClassPairIterator> thisIter;
00440 thisIter = new VarClassPairIterator(vcSet);
00441 for ( ; thisIter->isValid(); (*thisIter)++)
00442 {
00443 OA_ptr<VarClassPair> vcthis;
00444 vcthis = thisIter->current();
00445 sOutBuild->listItemStart();
00446 vcthis->output(ir);
00447 sOutBuild->listItemEnd();
00448
00449
00450
00451
00452
00453
00454 }
00455 sOutBuild->listEnd();
00456 sOutBuild->objEnd("LinearityDepsSet");
00457 }
00458
00459 OA_ptr<std::set<OA_ptr<VarClassPair> > > LinearityDepsSet::getSet()
00460 {
00461 return vcSet;
00462 }
00463
00464 LinearityDepsSet& LinearityDepsSet::operator= (const LinearityDepsSet& other)
00465 {
00466 vcSet = other.vcSet;
00467 return *this;
00468 }
00469
00470 OA_ptr<LinearityDepsSet> LinearityDepsSet::operator=( OA_ptr<LinearityDepsSet> other )
00471 {
00472 std::cout << "\n\nCALLING DEPS OPERATOR=\n-=-=-=-=-=-=-=-=-=-==-=-=-=-=-\n\n";
00473 (*vcSet) = *(other->getSet());
00474 }
00475
00476 }
00477 }
00478