LinearityMatrixStandard.hpp

Go to the documentation of this file.
00001 
00015 //--------------------------------------------------------------------
00016 //--------------------------------------------------------------------
00017 
00018 #ifndef _LINEARITYMATRIX_H
00019 #define _LINEARITYMATRIX_H
00020 
00021 //--------------------------------------------------------------------
00022 // STL headers
00023 #include <iostream>
00024 #include <map>
00025 #include <set>
00026 #include <list>
00027 
00028 // Local headers
00029 #include "LinearityPair.hpp"
00030 #include "LinearityDepsSet.hpp"
00031 
00032 //OpenAnalysis headers
00033 #include <OpenAnalysis/Utils/OA_ptr.hpp>
00034 #include <OpenAnalysis/Location/Locations.hpp>
00035 #include <OpenAnalysis/Linearity/Interface.hpp>
00036 #include <OpenAnalysis/OABase/Annotation.hpp>
00037 #include <OpenAnalysis/Utils/GenOutputTool.hpp>
00038 #include <OpenAnalysis/DataFlow/DataFlowSet.hpp>
00039 
00041 namespace OA {
00042   namespace Linearity {
00043 
00044 // Keep in mind that the default should be LCLASS_NODEP.
00045 // You probably don't want to store that for all var pairs.
00046 // Just store info for the ones that aren't that.
00047 class LinearityMatrix : public virtual DataFlow::DataFlowSet,
00048                         public virtual Linearity::Interface,
00049                         public virtual Annotation {
00050     public:
00051         LinearityMatrix() {
00052            mLMmap = new std::map<OA_ptr<Location> ,OA_ptr<std::set<OA_ptr<LinearityPair> > > >;
00053         }
00054 
00055         // num is the number of variables to maintain linearity
00056         // relationships amongst
00057         LinearityMatrix(int num) {
00058            mLMmap = new std::map<OA_ptr<Location> ,OA_ptr<std::set<OA_ptr<LinearityPair> > > >;
00059         }
00060 
00061   //LinearityMatrix(const LinearityMatrix &other) : mLMmap(other.mLMmap) {
00062           // go create an empty mLMmap, and populate it with the cloned contents
00063           // of other.mLMmap.  (make sure that the clones of the contents are
00064           // really making clones)
00065         LinearityMatrix(const LinearityMatrix &other) {
00066           mLMmap = new std::map<OA_ptr<Location> ,OA_ptr<std::set<OA_ptr<LinearityPair> > > >;
00067           // iterate through other.mLMmap and 
00068           std::map<OA_ptr<Location> ,OA_ptr<std::set<OA_ptr<LinearityPair> > > >::iterator mapIter;
00069           mapIter = other.mLMmap->begin();
00070           for (; mapIter!=other.mLMmap->end(); mapIter++) {
00071             OA_ptr<Location> loc = mapIter->first;
00072             OA_ptr<std::set<OA_ptr<LinearityPair> > > lpSet = mapIter->second;
00073             OA_ptr<std::set<OA_ptr<LinearityPair> > > cplpSet;
00074             cplpSet = new std::set<OA_ptr<LinearityPair> >;
00075             std::set<OA_ptr<LinearityPair> >::iterator setIter;
00076             setIter = lpSet->begin();
00077             for (; setIter!=lpSet->end(); setIter++) {
00078               OA_ptr<LinearityPair> lp = *setIter;
00079               OA_ptr<LinearityPair> cplp;
00080               cplp = new LinearityPair(lp->getVar1(),lp->getVar2(),lp->getLClass());
00081               cplpSet->insert(cplp);
00082             }
00083             (*mLMmap)[loc]=cplpSet;
00084           }
00085             
00086 
00087         }
00088 
00089         // When calculating DEPS, we need to iterate over
00090         // all the pairs where a particular variable is
00091         // the first var in the pair.
00092         //      ie. <<v,w>, class> in IN(b) for a particular v
00093         OA_ptr<LinearityPairIterator> getPairIteratorForVar( OA_ptr<Location> v );
00094 
00095         void putLPSet(OA_ptr<Location> v, OA_ptr<std::set<OA_ptr<LinearityPair> > >lpSet); 
00096                 
00097         void putLPair(OA_ptr<LinearityPair> lp);
00098 
00099         OA_ptr<DataFlow::DataFlowSet> clone();
00100             
00101         // meet operation between two LinearityMatrix objects
00102         // For now go ahead and create a new LinearityMatrix
00103         // for the result, the result represent the meet between
00104         // the dataflow sets.
00105         OA_ptr<LinearityMatrix> meet( OA_ptr<LinearityMatrix> other, IRHandlesIRInterface& pIR );
00106         OA_ptr<LinearityMatrix> meet( DataFlowSet &other, IRHandlesIRInterface& pIR );
00107       
00108         //putDepsSet
00109         //Uses the AbstractVar v and uses the instance of deps
00110         //to call deps->convert function in order to store the
00111         //linearity pairs back to the Map for a specific v. 
00112         void putDepsSet(OA_ptr<Location> v, OA_ptr<LinearityDepsSet> deps);
00113         
00114         //getDepSet
00115         //Uses AbstractVar v to locate all the Sets of LinearityPairs
00116         //that Map to v. It then iterates over all the pairs where
00117         //the particular variable v is the first var in the pair and
00118         //creates a VarClassPair to insert into the DEPS set. 
00119         //NOTE: Use this when you Union what you had.
00120         //      ie. {<v,linear> } U {<w,class> | <<v,w>,class> E IN(b)
00121         OA_ptr<LinearityDepsSet> getDepsSet(OA_ptr<Location> v);
00122         
00123         //getMap
00124         OA_ptr<std::map<OA_ptr<Location> ,OA_ptr<std::set<OA_ptr<LinearityPair> > > > > getMap(); 
00125         
00126         void output();
00127         
00128         void output(IRHandlesIRInterface& pIR);
00129 
00130         void dump(std::ostream &os) {}
00131 
00132         void dump(std::ostream& os, OA_ptr<IRHandlesIRInterface> ir);
00133 
00134         //OA_ptr<LinearityMatrix> operator=( OA_ptr<LinearityMatrix> other );
00135         LinearityMatrix& operator=(const LinearityMatrix& other);
00136 
00137         bool operator ==(DataFlow::DataFlowSet &other) const;
00138 
00139         bool operator !=(DataFlow::DataFlowSet &other) const;
00140 
00141         bool operator ==(const LinearityMatrix& other) const;
00142         
00143     private:
00144     //Map an AbstractVar <v> with a set of VarClassPair <w,class>
00145     OA_ptr<std::map<OA_ptr<Location> ,OA_ptr<std::set<OA_ptr<LinearityPair> > > > > mLMmap;
00146     std::map<OA_ptr<Location> ,OA_ptr<std::set<OA_ptr<LinearityPair> > > >::iterator mIter;
00147 
00148 };     
00149 
00150   } // end of namespace Linearity
00151 } // end of namespace OA
00152 
00153 
00154 #endif
00155 

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