ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DefUseAnalysisAbstract.h
Go to the documentation of this file.
1 /******************************************
2  * Category: DFA
3  * DefUse Analysis Declaration (per Function)
4  * created by tps in Feb 2007
5  *****************************************/
6 
7 #ifndef __DefUseAnalysisAbstractPF_HXX_LOADED__
8 #define __DefUseAnalysisAbstractPF_HXX_LOADED__
9 
10 //#include "rose.h"
11 #include "support.h"
12 #include <virtualCFG.h>
13 #include <cfgToDot.h>
14 #include <list>
15 #include "filteredCFG.h"
16 #include "DFAFilter.h"
17 #include "DefUseAnalysis.h"
18 #include "dfaToDot.h"
19 #include <string>
20 
22  protected:
23  // debugging -------------------------
24  bool DEBUG_MODE;
26 
27  // reference to DFA ------------------
29 
30  // typedef std::multimap < SgInitializedName* , SgNode* > multitype;
31  typedef std::vector < std::pair < SgInitializedName* , SgNode* > > multitype;
32  typedef std::map< SgNode* , multitype > tabletype;
35 
36  std::set <SgNode*> doNotVisitMap;
37  std::map <SgNode*, bool> nodeChangedMap;
38 
39  // searching -------------------------
40  bool searchMulti(const multitype* multi, SgInitializedName* initName);
41  // bool searchMulti(const multitype* multi, SgInitializedName* initName, SgNode* node);
42  bool searchVector(std::vector <filteredCFGNodeType> done,
43  filteredCFGNodeType cfgNode);
44 
46 
48  bool isDoubleExactEntry(const multitype* multi,
49  SgInitializedName* name, SgNode* sgNode);
50 
51  bool checkElementsForEquality(const multitype* t1, const multitype* t2);
52 
53  /**********************************************************
54  * For a CFG Node, follow the two incoming edges and get
55  * the other node (than theNodeBefore)
56  *********************************************************/
57  template <typename T>
58  SgNode* getOtherInNode(T cfgNode, SgNode* oneNode){
59  SgNode* otherNode = NULL;
60  std::vector<filteredCFGEdgeType > in_edges = cfgNode.inEdges();
61  for (std::vector<filteredCFGEdgeType >::const_iterator i = in_edges.begin(); i != in_edges.end(); ++i) {
62  filteredCFGEdgeType filterEdge = *i;
63  T filterNode = filterEdge.source();
64  if (filterNode.getNode()!=oneNode)
65  otherNode = filterNode.getNode();
66  }
67  if (DEBUG_MODE_EXTRA)
68  std::cout << "getOtherInNode:: other: " << otherNode << " previous: " <<
69  oneNode << " size of in: " << in_edges.size() << std::endl;
70  return otherNode;
71  }
72 
73  /**********************************************************
74  * get the incoming node of a cfg edge
75  *********************************************************/
76  template <typename T>
77  SgNode* getCFGPredNode(T cfgNode){
78  SgNode* node = NULL;
79  std::vector<filteredCFGEdgeType > in_edges = cfgNode.inEdges();
80  for (std::vector<filteredCFGEdgeType >::const_iterator i = in_edges.begin(); i != in_edges.end(); ++i) {
81  filteredCFGEdgeType filterEdge = *i;
82  node = filterEdge.source().getNode();
83  }
84  return node;
85  }
86 
87  /**********************************************************
88  * print the values of a vector
89  *********************************************************/
90  template <typename T >
91  void printCFGVector(std::vector< T > worklist) {
92  int pos = 0;
93  std::cout << "\n!! Worklist : " ;
94  for (typename std::vector<T >::iterator i = worklist.begin(); i != worklist.end(); ++i, pos++) {
95  T node = *i;
96  std::cout << " - " << node.toStringForDebugging();
97  }
98  std::cout << std::endl;
99  }
100 
101  /*
102  template <typename T> void printCFGVector(std::vector<T > worklist);
103  template <typename T> SgNode* getCFGPredNode(T cfgNode);
104  template <typename T> SgNode* getOtherInNode(T source, SgNode* oneNode);
105  */
106 
107  public:
109  doNotVisitMap.clear();
110  nodeChangedMap.clear();
111  };
113  virtual FilteredCFGNode < IsDFAFilter > run(SgFunctionDefinition* function, bool& abortme)=0;
114 
115 };
116 
117 #endif
118