ManagerLinearityStandard.cpp

Go to the documentation of this file.
00001 // standard headers
00002 
00003 #ifdef NO_STD_CHEADERS
00004 # include <stdlib.h>
00005 # include <string.h>
00006 # include <assert.h>
00007 #else
00008 # include <cstdlib>
00009 # include <cstring>
00010 # include <cassert>
00011 using namespace std; // For compatibility with non-std C headers
00012 #endif
00013 
00014 #include <iostream>
00015 using std::ostream;
00016 using std::endl;
00017 using std::cout;
00018 using std::cerr;
00019 #include <list>
00020 #include <set>
00021 #include <map>
00022 
00023 // Local headers
00024 #include "ManagerLinearityStandard.hpp"
00025 
00026 //using namespace OA;
00027 namespace OA {
00028   namespace Linearity {
00029 
00030 static bool debug = false;
00031 
00032 ManagerLinearity::ManagerLinearity(OA_ptr<LinearityIRInterface> _ir) : mIR(_ir)
00033 {
00034    mSolver = new DataFlow::CFGDFSolver(DataFlow::CFGDFSolver::Forward,*this);
00035 }
00036 
00037 OA_ptr<DataFlow::DataFlowSet> ManagerLinearity::initializeTop()
00038 {
00039     OA_ptr<LinearityMatrix>  retval;
00040     retval = new LinearityMatrix;
00041     return retval;
00042 }
00043      
00044 OA_ptr<DataFlow::DataFlowSet> ManagerLinearity::initializeBottom()
00045 {
00046     OA_ptr<LinearityMatrix>  retval;
00047     retval = new LinearityMatrix;
00048     return retval;
00049 }
00050 
00051 OA_ptr<DataFlow::DataFlowSet>
00052 ManagerLinearity::initializeNodeIN(OA_ptr<CFG::NodeInterface> n)
00053 {
00054     OA_ptr<LinearityMatrix>  retval;
00055     retval = new LinearityMatrix;
00056     return retval;
00057 }
00058 
00059 OA_ptr<DataFlow::DataFlowSet>
00060 ManagerLinearity::initializeNodeOUT(OA_ptr<CFG::NodeInterface> n)
00061 {
00062     OA_ptr<LinearityMatrix>  retval;
00063     retval = new LinearityMatrix;
00064     return retval;
00065 }
00066 
00067 OA_ptr<Linearity::LinearityMatrix> ManagerLinearity::performAnalysis(
00068                                         ProcHandle proc,
00069                                         OA_ptr<CFG::CFGInterface> cfg,
00070                                         OA_ptr<Alias::Interface> alias,
00071                                         OA_ptr<DataFlow::ParamBindings> paramBind, DataFlow::DFPImplement algorithm)
00072 {
00073     mProc = proc;
00074 
00075     mLM = new LinearityMatrix;
00076 
00077     mCFG = cfg;
00078 
00079     mAlias = alias;
00080 
00081     mParamBind = paramBind;
00082 
00083     mExitNode = cfg->getExit();
00084 
00085     mSolver->solve(cfg,algorithm);
00086 
00087     OA_ptr<DataFlow::DataFlowSet> exitclone = mSolver->getOutSet(mExitNode);
00088     exitclone = exitclone->clone();
00089     mLM = exitclone.convert<LinearityMatrix>();
00090    
00091 
00092 /*
00093   TestCase1:
00094                                   *********
00095                                   * Entry *
00096                                   *********
00097                                       |
00098                                       v
00099                                   *********
00100                                   * a=0.0 *
00101                                   * b=0.0 *
00102                                   * c=0.0 *
00103                                   *********
00104                                       |
00105                                       V
00106                                   *********
00107                                   * a = b *
00108                                   * c = a *
00109                                   *********
00110                                       |
00111                                       v
00112                                   *********
00113                                   * Exit  *
00114                                   *********
00115  *
00116  * START of TestCase1: 
00117  */
00118 /*
00119 std::cout <<"  TestCase1:\n";
00120 std::cout <<"                                  *********\n";
00121 std::cout <<"                             * Entry *\n";
00122 std::cout <<"                             *********\n";
00123 std::cout <<"                                      |\n";
00124 std::cout <<"                                      v\n";
00125 std::cout <<"                                  *********\n";
00126 std::cout <<"                                  * a=0.0 *\n";
00127 std::cout <<"                                  * b=0.0 *\n";
00128 std::cout <<"                                  * c=0.0 *\n";
00129 std::cout <<"                                  *********\n";
00130 std::cout <<"                                      |\n";
00131 std::cout <<"                                      V\n";
00132 std::cout <<"                                  *********\n";
00133 std::cout <<"                                  * a = b *\n";
00134 std::cout <<"                                  * c = a *\n";
00135 std::cout <<"                                  *********\n";
00136 std::cout <<"                                      |\n";
00137 std::cout <<"                                      v\n";
00138 std::cout <<"                                  *********\n";
00139 std::cout <<"                             * Exit  *\n";
00140 std::cout <<"                             *********\n";
00141 
00142 std::cout <<"  START of TestCase1: WORKING    \n";
00143 
00144 
00145 //OA_ptr<LinearityMatrix> LM; LM = new LinearityMatrix;
00146 mLM = new LinearityMatrix;
00147 OA_ptr<LinearityDepsSet> deps;
00148 
00149 //Variables ->
00150 OA_ptr<Location> a; a = new NamedLoc(SymHandle((irhandle_t)'a'),true);
00151 OA_ptr<Location> b; b = new NamedLoc(SymHandle((irhandle_t)'b'),true);
00152 OA_ptr<Location> c; c = new NamedLoc(SymHandle((irhandle_t)'c'),true);  
00153 
00154 //c->dump(std::cout, mIR);
00155 
00156 //e = 0.0 //a = 0.0
00157 deps = new LinearityDepsSet(0.0);
00158 //Insert Assignment to LinearityMatrix and its DEPS
00159 //a = e //NODEP
00160 mLM->putDepsSet(a,deps); //{<<v,w>,T>|v,w E V}
00161 
00162 //e = 0.0 //b = 0.0
00163 deps = new LinearityDepsSet(0.0);
00164 //Insert Assignment to LinearityMatrix and its DEPS
00165 //b = e //NODEP
00166 mLM->putDepsSet(b,deps); //{<<v,w>,T>|v,w E V}
00167 
00168 //e = 0.0 //c = 0.0
00169 deps = new LinearityDepsSet(0.0);
00170 //Insert Assignment to LinearityMatrix and its DEPS
00171 //c = e //NODEP
00172 mLM->putDepsSet(c,deps); //{<<v,w>,T>|v,w E V}
00173 
00174 OA_ptr<LinearityDepsSet> depb, depc;
00175 deps = new LinearityDepsSet(a,mLM->getDepsSet(a));
00176 depb = new LinearityDepsSet(b,mLM->getDepsSet(b));
00177 //a = b
00178 mLM->putDepsSet(a,depb);
00179 
00180 deps = new LinearityDepsSet(a,mLM->getDepsSet(a));
00181 depc = new LinearityDepsSet(c,mLM->getDepsSet(c));
00182 //c = a
00183 mLM->putDepsSet(c,deps);
00184 
00185 std::cout << "LM Contains:\n";
00186 mLM->output();
00187 */
00188 /*
00189  * END of TestCase1 
00190  */
00191 
00192 return mLM;
00193 }
00194 
00195 
00196 OA_ptr<DataFlow::DataFlowSet> 
00197 ManagerLinearity::meet (OA_ptr<DataFlow::DataFlowSet> set1orig, 
00198                        OA_ptr<DataFlow::DataFlowSet> set2orig)
00199 {
00200 
00201     OA_ptr<DataFlow::DataFlowSet> set1clone = set1orig->clone(); 
00202     OA_ptr<DataFlow::DataFlowSet> set2clone = set2orig->clone(); 
00203     OA_ptr<LinearityMatrix> set1 = set1clone.convert<LinearityMatrix>();
00204     OA_ptr<LinearityMatrix> set2 = set2clone.convert<LinearityMatrix>();
00205 
00206     if (debug) {
00207         std::cout << "ManagerLinearityStandard::meet" << std::endl;
00208         std::cout << "\tset1 = ";
00209         set1->dump(std::cout,mIR);
00210         std::cout << ", set2 = ";
00211         set2->dump(std::cout,mIR);
00212     }
00213        
00214     OA_ptr<LinearityMatrix> retval; retval = new LinearityMatrix;
00215     retval = set1->meet(set2, *mIR);
00216     if (debug) {
00217         std::cout << std::endl << "\tretval set = ";
00218         retval->dump(std::cout,mIR);
00219         std::cout << std::endl;
00220     }
00221        
00222     return retval;
00223 }
00224 
00226 //
00227 OA_ptr<DataFlow::DataFlowSet> 
00228 ManagerLinearity::transfer(OA_ptr<DataFlow::DataFlowSet> in, OA::StmtHandle stmt) 
00229 {
00230     OA_ptr<DataFlow::DataFlowSet> inclone = in->clone();
00231     OA_ptr<LinearityMatrix> inRecast = inclone.convert<LinearityMatrix>();
00232 
00233     if (debug) {
00234       std::cout << "Top of Transfer==\n";
00235       inRecast->output(*mIR);
00236     }
00237 
00238     OA_ptr<AssignPairIterator> espIterPtr
00239             = mIR->getAssignPairIterator(stmt);
00240 
00241     if(!espIterPtr.ptrEqual(0)) {
00242 
00243         for ( ; espIterPtr->isValid(); ++(*espIterPtr)) {
00244            // unbundle pair
00245            MemRefHandle mref = espIterPtr->currentTarget();
00246            ExprHandle expr = espIterPtr->currentSource();
00247         
00248            // getExpression Tree
00249            OA_ptr<ExprTree> eTreePtr = mIR->getExprTree(expr);
00250 
00251            if (debug) {
00252              std::cout << "Expression Tree:\n";
00253              eTreePtr->output(*mIR);
00254            }
00255            // get deps by evaluating expression tree
00256            //LinearityLocsVisitor linearityVisitor(mIR,mLM,mAlias,mParamBind);
00257            LinearityLocsVisitor linearityVisitor(mIR,inRecast,mAlias,mParamBind);
00258            eTreePtr->acceptVisitor(linearityVisitor);
00259 
00260            //std::cout << "\n===============================================";
00261            //std::cout << "\nLinearityVisitor.getDepsSet() -> ExprTree Visit\n";
00262            //linearityVisitor.getDepsSet()->output(*mIR);
00263            //std::cout << "\n===============================================\n";           
00264            // for each MayLoc(MustLoc??), include into the inSet with
00265            // the new depsset.
00266            OA_ptr<LocIterator> lIterPtr = mAlias->getMayLocs(mref);
00267            for ( ; lIterPtr->isValid() ; ++(*lIterPtr)) {
00268              OA_ptr<Location> lPtr = lIterPtr->current();
00269              //mLM->putDepsSet(lPtr,linearityVisitor.getDepsSet());
00270              inRecast->putDepsSet(lPtr,linearityVisitor.getDepsSet());
00271            }
00272         }
00273     }
00274 
00275     if (debug) {
00276       std::cout << "Bottom of Transfer:::\n";
00277       inRecast->output(*mIR);
00278     }
00279 
00280     return inRecast;
00281 
00282 }
00283 
00284 OA_ptr<Linearity::LinearityMatrix> ManagerLinearity::performAnalysis2(SymHandle sym)
00285 {
00286 
00287 /* 
00288   TestCase2:
00289   
00290                                   *********
00291                                   * Entry *
00292                                   *********
00293                                       ;
00294                                   *********
00295                                   * a=0.0 *
00296                                   * f=0.0 *
00297                                   *********           
00298                                       ;<------------------
00299                                   *************          |
00300                                   * if (i<=N) *          |
00301                                   *************          |
00302                         |-----------;                    |
00303                         |       *********************    |
00304                         |       * a = a + x[i]*x[i] *    |
00305                         |       * t = sin(a)        *    |
00306                         |       * f = f + t         *    |
00307                         |       *********************    |
00308                         |             ;------------------|
00309                         |
00310                         |
00311                         |         *********
00312                         --------->* Exit  *
00313                                   *********  
00314   
00315  *
00316  * START of TestCase2: 
00317  */
00318 
00319 std::cout <<"  TestCase2:\n";
00320 std::cout <<"  \n";
00321 std::cout <<"                             *********\n";
00322 std::cout <<"                             * Entry *\n";
00323 std::cout <<"                             *********\n";
00324 std::cout <<"                                 ;\n";
00325 std::cout <<"                             *********\n";
00326 std::cout <<"                             * a=0.0 *\n";
00327 std::cout <<"                             * f=0.0 *\n";
00328 std::cout <<"                             *********    \n";       
00329 std::cout <<"                                 ;<------------------\n";
00330 std::cout <<"                             *************          |\n";
00331 std::cout <<"                             * if (i<=N) *          |\n";
00332 std::cout <<"                             *************          |\n";
00333 std::cout <<"                   |-----------;                    |\n";
00334 std::cout <<"                   |       *********************    |\n";
00335 std::cout <<"                   |       * a = a + x[i]*x[i] *    |\n";
00336 std::cout <<"                   |       * t = sin(a)        *    |\n";
00337 std::cout <<"                   |       * f = f + t         *    |\n";
00338 std::cout <<"                   |       *********************    |\n";
00339 std::cout <<"                   |             ;------------------|\n";
00340 std::cout <<"                        |\n";
00341 std::cout <<"                        |\n";
00342 std::cout <<"                   |         *********\n";
00343 std::cout <<"                   --------->* Exit  *\n";
00344 std::cout <<"                             *********  \n";
00345   
00346 
00347 std::cout <<"  START of TestCase2: NOTWORKING \n";
00348     
00349 /*
00350 OA_ptr<LinearityMatrix> LM; LM = new LinearityMatrix;
00351 OA_ptr<LinearityDepsSet> deps;
00352 
00353 //Variables ->
00354 OA_ptr<AbstractVar> a; a = new SimpleAbstractVar('a');
00355 OA_ptr<AbstractVar> f; f = new SimpleAbstractVar('f');
00356 OA_ptr<AbstractVar> x; x = new SimpleAbstractVar('x');  
00357 OA_ptr<AbstractVar> t; t = new SimpleAbstractVar('t');
00358 
00359 //e = 0.0 //a = 0.0
00360 deps = new LinearityDepsSet(0.0);
00361 //Insert Assignment to LinearityMatrix and its DEPS
00362 //a = e //NODEP
00363 LM->putDepsSet(a,deps); //{<<v,w>,T>|v,w E V}
00364 
00365 //e = 0.0 //f = 0.0
00366 deps = new LinearityDepsSet(0.0);
00367 //Insert Assignment to LM and its DEPS
00368 //f = e //NODEP
00369 LM->putDepsSet(f,deps); //{<<v,w>,T>|v,w E V}
00370     
00371     //TODO: Meet LM (IN) with (OUT) of This Block
00372     //LM->meet(LM2);
00373     //LinearityMatrix *LM2 = new LinearityMatrix(5);
00374     
00375     //e = a + x[i] * x[i] //a = e
00376     /* Expression Tree for e
00377                +
00378               / \
00379              a   *
00380                 / \
00381              x[i] x[i] */
00382 /*OA_ptr<LinearityDepsSet> depx, mult, add;
00383 deps = new LinearityDepsSet(a,LM->getDepsSet(a));
00384 depx = new LinearityDepsSet(x,LM->getDepsSet(x));
00385 mult = depx->multdiv(depx);
00386 add = deps->addsub(mult);
00387 //Insert Assigment to LM and its DEPS
00388 //a = e
00389 LM->putDepsSet(a,add);
00390 
00391 
00392 //e = sin(a) //t = sin(a)
00393 OA_ptr<LinearityDepsSet> sin;
00394 deps = new LinearityDepsSet(a,LM->getDepsSet(a));
00395 sin = deps->func(deps);
00396 //Insert Assignment to LM and its DEPS
00397 //t = e
00398 LM->putDepsSet(t,sin);
00399     
00400     //e = f + t //f = f + t
00401     /* Expression Tree for e
00402                +
00403               / \
00404              f   t */
00405 /*OA_ptr<LinearityDepsSet> dept;
00406 deps = new LinearityDepsSet(f,LM->getDepsSet(f));
00407 dept = new LinearityDepsSet(t,LM->getDepsSet(t));
00408 add = deps->addsub(dept);
00409 //Insert Assignment to LM and its DEPS
00410 //f = e
00411 LM->putDepsSet(f,add);
00412 
00413 std::cout << "LM Contains:\n";
00414 LM->output();
00415 */
00416 /*
00417  * END of TestCase2 
00418  */
00419 }
00420 
00421 OA_ptr<Linearity::LinearityMatrix> ManagerLinearity::performAnalysis3(ProcHandle proc,
00422                                                 OA_ptr<CFG::CFGInterface> cfg,
00423                                                 OA_ptr<Alias::Interface> alias,
00424                                                 OA_ptr<DataFlow::ParamBindings> paramBind)
00425 {
00426 
00427 /* 
00428   TestCase3:
00429                                     *********
00430                                     * Entry *
00431                                     *********
00432                                         |
00433                                         v
00434                                   ***************
00435                                   * a=0.0       *
00436                                   * b=0.0       *
00437                                   * c=0.0       *
00438                                   * d=0.0       *
00439                                   * a = a + x*x *
00440                                   ***************           
00441                                         |
00442                                         v
00443                                   ***************          
00444                                   * if (a > 10) *          
00445                                   ***************          
00446                   ________true__________|__________false_______
00447                  |                                             |
00448                  v                                             v
00449              *********                                 *****************    
00450              * i = 0 *                                 * c = c + x + 2 *
00451              *********                                 *****************        
00452                  |                                             |
00453                  v<-------------                               |
00454            **************      |                               |
00455            * if (i<=10) *      |                               |
00456            **************      |                               |
00457     --false------|             |                               |
00458     |            v             |                               |
00459     |   *********************  |                               |
00460     |   * a = a + y[i]      *  |                               |
00461     |   * b = b + y[i] + a  *  |                               |
00462     |   * c = c/(sin(y[i])) *  |                               |
00463     |   * i = i + 1         *  |                               |
00464     |   *********************  |                               |
00465     |           |______________|                               |
00466     |                                                          |
00467     |------------------------------->|<-------------------------
00468                                      v
00469                              ********************
00470                              * d = c + pow(x,1) *
00471                              ********************
00472                                      |
00473                                      v
00474                                  *********
00475                                  * Exit  *
00476                                  *********  
00477   
00478  *
00479  * START of TestCase3: 
00480  */
00481 
00482 std::cout <<"  TestCase3:\n";
00483 std::cout <<"                                    *********\n";
00484 std::cout <<"                               * Entry *\n";
00485 std::cout <<"                               *********\n";
00486 std::cout <<"                                   |\n";
00487 std::cout <<"                                        v\n";
00488 std::cout <<"                             ***************\n";
00489 std::cout <<"                             * a=0.0       *\n";
00490 std::cout <<"                             * b=0.0       *\n";
00491 std::cout <<"                                  * c=0.0       *\n";
00492 std::cout <<"                                  * d=0.0       *\n";
00493 std::cout <<"                                  * a = a + x*x *\n";
00494 std::cout <<"                             ***************           \n";
00495 std::cout <<"                                   |\n";
00496 std::cout <<"                                        v\n";
00497 std::cout <<"                                  ***************          \n";
00498 std::cout <<"                             * if (a > 10) *          \n";
00499 std::cout <<"                             ***************         \n"; 
00500 std::cout <<"                  ________true__________|__________false_______\n";
00501 std::cout <<"                 |                                             |\n";
00502 std::cout <<"                 v                                             v\n";
00503 std::cout <<"             *********                                 *****************    \n";
00504 std::cout <<"             * i = 0 *                                 * c = c + x + 2 *\n";
00505 std::cout <<"             *********                                 *****************        \n";
00506 std::cout <<"                 |                                             |\n";
00507 std::cout <<"                 v<-------------                               |\n";
00508 std::cout <<"      **************      |                               |\n";
00509 std::cout <<"      * if (i<=10) *      |                               |\n";
00510 std::cout <<"      **************      |                               |\n";
00511 std::cout <<"    --false------|             |                               |\n";
00512 std::cout <<"    |            v             |                               |\n";
00513 std::cout <<"    |   *********************  |                               |\n";
00514 std::cout <<"    |   * a = a + y[i]      *  |                               |\n";
00515 std::cout <<"    |   * b = b + y[i] + a  *  |                               |\n";
00516 std::cout <<"    |   * c = c/(sin(y[i])) *  |                               |\n";
00517 std::cout <<"    |   * i = i + 1         *  |                               |\n";
00518 std::cout <<"    |   *********************  |                               |\n";
00519 std::cout <<"    |           |______________|                               |\n";
00520 std::cout <<"    |                                                          |\n";
00521 std::cout <<"    |------------------------------->|<-------------------------\n";
00522 std::cout <<"                                     v\n";
00523 std::cout <<"                             ********************\n";
00524 std::cout <<"                             * d = c + pow(x,1) *\n";
00525 std::cout <<"                             ********************\n";
00526 std::cout <<"                                     |\n";
00527 std::cout <<"                                     v\n";
00528 std::cout <<"                                 *********\n";
00529 std::cout <<"                            * Exit  *\n";
00530 std::cout <<"                            *********  \n";
00531 
00532 std::cout <<"\nSTART of TestCase3: WORKING\n\n";
00533 
00534 
00535 
00536 OA_ptr<LinearityMatrix> LM1; LM1 = new LinearityMatrix;
00537 OA_ptr<LinearityDepsSet> deps;
00538 
00539 //Variables ->
00540 OA_ptr<Location> a; a = new NamedLoc(SymHandle((irhandle_t)'a'),true);
00541 OA_ptr<Location> b; b = new NamedLoc(SymHandle((irhandle_t)'b'),true);
00542 OA_ptr<Location> c; c = new NamedLoc(SymHandle((irhandle_t)'c'),true);  
00543 OA_ptr<Location> d; d = new NamedLoc(SymHandle((irhandle_t)'d'),true);
00544 OA_ptr<Location> x; x = new NamedLoc(SymHandle((irhandle_t)'x'),true);
00545 OA_ptr<Location> y; y = new NamedLoc(SymHandle((irhandle_t)'y'),true);  
00546 OA_ptr<Location> i; i = new NamedLoc(SymHandle((irhandle_t)'i'),true);  
00547 
00548 //e = 0.0 //a = 0.0
00549 deps = new LinearityDepsSet(0.0);
00550 //Insert Assignment to LinearityMatrix and its DEPS
00551 //a = e //NODEP
00552 LM1->putDepsSet(a,deps); //{<<v,w>,T>|v,w E V}
00553 
00554 //e = 0.0 //b = 0.0
00555 deps = new LinearityDepsSet(0.0);
00556 //Insert Assignment to LM and its DEPS
00557 //b = e //NODEP
00558 LM1->putDepsSet(b,deps); //{<<v,w>,T>|v,w E V}
00559 
00560 //e = 0.0 //c = 0.0
00561 deps = new LinearityDepsSet(0.0);
00562 //Insert Assignment to LinearityMatrix and its DEPS
00563 //c = e //NODEP
00564 LM1->putDepsSet(c,deps); //{<<v,w>,T>|v,w E V}
00565 
00566 //e = 0.0 //d = 0.0
00567 deps = new LinearityDepsSet(0.0);
00568 //Insert Assignment to LM and its DEPS
00569 //d = e //NODEP
00570 LM1->putDepsSet(d,deps); //{<<v,w>,T>|v,w E V}
00571 
00572 
00573 //e = a + x * x //a = e
00574 /* Expression Tree for e
00575                +
00576               / \
00577              a   *
00578                 / \
00579                x   x */
00580 OA_ptr<LinearityDepsSet> depx, mult, add;
00581 deps = new LinearityDepsSet(a,LM1->getDepsSet(a));
00582 depx = new LinearityDepsSet(x,LM1->getDepsSet(x));
00583 mult = depx->multdiv(depx);
00584 add = deps->addsub(mult);
00585 //Insert Assignment to LM and its DEPS
00586 //a = e
00587 LM1->putDepsSet(a,add);
00588 
00589 
00590 //if (a > 10) True:LM, False:LM2
00591 OA_ptr<LinearityMatrix> LM2; LM2 = new LinearityMatrix;
00592 LM2 = LM1;
00593 
00594 //TRUE:
00595    //e = 0.0 //i = 0.0
00596    deps = new LinearityDepsSet(0.0);
00597    //Insert Assignment to LinearityMatrix and its DEPS
00598    //i = e //NODEP
00599    LM1->putDepsSet(i,deps); //{<<v,w>,T>|v,w E V}
00600 
00601    //e = a + y[i] //a = a + y[i]
00602    /* Expression Tree for e
00603               +
00604              / \
00605             a   y */
00606    OA_ptr<LinearityDepsSet> depy;
00607    deps = new LinearityDepsSet(a,LM1->getDepsSet(a));
00608    depy = new LinearityDepsSet(y,LM1->getDepsSet(y));
00609    add = deps->addsub(depy);
00610    //Insert Assignment to LM and its DEPS
00611    //a = e
00612    LM1->putDepsSet(a,add);
00613    //e = b + y[i] + a //b = b + y[i] + a
00614    /* Expression Tree for e
00615              +
00616             / \
00617            b   +
00618               / \
00619            y[i]  a */
00620    OA_ptr<LinearityDepsSet> depb, add2;
00621    depb = new LinearityDepsSet(b,LM1->getDepsSet(b));
00622    depy = new LinearityDepsSet(y,LM1->getDepsSet(y));
00623    deps = new LinearityDepsSet(a,LM1->getDepsSet(a));
00624    add = depy->addsub(deps);
00625    add2 = depb->addsub(add);
00626    //Insert Assignment to LM and its DEPS
00627    //b = e
00628    LM1->putDepsSet(b,add2);
00629    //e = c/(sin(y[i])) //c = c/(sin(y[i]))
00630    /* Expression Tree for e
00631               /
00632              / \ 
00633             c  sin()
00634                 |
00635                y[i]*/
00636    OA_ptr<LinearityDepsSet> depc, div, sin;
00637    depy = new LinearityDepsSet(y,LM1->getDepsSet(y));
00638    depc = new LinearityDepsSet(c,LM1->getDepsSet(c));
00639    sin = depy->func(depy);
00640    div = depc->multdiv(sin);
00641    //Insert Assignment to LM and its DEPS
00642    //c = e
00643    LM1->putDepsSet(c,div);
00644 
00645    //e = i + 1 //i = i + 1
00646    OA_ptr<LinearityDepsSet> depi;
00647    depi = new LinearityDepsSet(i,LM1->getDepsSet(i));
00648    add = depi->anyopk(); //Constant Addition
00649    //Insert Assignment to LM and its DEPS
00650    //i = e
00651    LM1->putDepsSet(i,add);
00652 
00653 //FALSE:
00654    //e = c + x + 2 //c = c + x + 2
00655    /* Expression Tree for e
00656               +
00657              / \
00658             c   +
00659                / \
00660               x   2 */
00661    depx = new LinearityDepsSet(x,LM2->getDepsSet(x));
00662    depc = new LinearityDepsSet(c,LM2->getDepsSet(c));
00663    add = depx->anyopk(); //Constant Addition
00664    add2 = depc->addsub(add);
00665    //Insert Assignment to LM and its DEPS
00666    //c = e
00667    LM2->putDepsSet(c,add2);
00668 
00669 //MEET:
00670 mLM = new LinearityMatrix;
00671 //mLM = LM1->meet(LM2);
00672 
00673 //e = c + pow(x,1) //d = c + pow(x,1)
00674 /* Expression Tree for e
00675               +
00676              / \
00677             c   ^
00678                / \
00679               x   1 */
00680 OA_ptr<LinearityDepsSet> depp;
00681 depc = new LinearityDepsSet(c,mLM->getDepsSet(c));
00682 depx = new LinearityDepsSet(x,mLM->getDepsSet(x));
00683 depp = depx->power1(depx);
00684 add = depc->addsub(depp);
00685 //Insert Assignment to LM and its DEPS
00686 //d = e
00687 mLM->putDepsSet(d,add);
00688 
00689 /*
00690  * END of TestCase3 
00691  */
00692 
00693 return mLM;
00694 }
00695 
00696 
00697   } // end of Linearity namespace
00698 } // end of OA namespace
00699