ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LivenessAnalysis.h
Go to the documentation of this file.
1 /******************************************
2  * Category: DFA
3  * Liveness Analysis Declaration
4  * created by tps in Nov 2008
5  *****************************************/
6 
7 #ifndef __LivenessAnalysis_HXX_LOADED__
8 #define __LivenessAnalysis_HXX_LOADED__
9 #include <string>
10 
11 #include "filteredCFG.h"
12 #include "DefUseAnalysis.h"
13 #include "support.h"
14 
15 #include "DefUseAnalysisAbstract.h"
16 
18  private:
20  bool DEBUG_MODE;
21 
23  void printInAndOut(SgNode* sgNode);
24 
25  bool abort;
26  int counter;
27  std::map<SgNode*, std::vector<SgInitializedName*> > in;
28  std::map<SgNode*, std::vector<SgInitializedName*> > out;
29 
31  // std::map<SgNode*,int> breakPointForWhile;
32  //std::set<SgNode*> breakPointForWhileNode;
35 
36  template <typename T> bool defuse(T cfgNode, bool *unhandled);
37  std::map<SgNode*,int> visited;
38  template <typename T> bool hasANodeAboveCurrentChanged(T source);
39 
40  template <class T> void getAllNodesBelow(T source,
41  std::vector<T>& visited);
42  template <class T> void getAllNodesAbove(T source, std::vector<T>& visited);
44 
45  public:
46  LivenessAnalysis(bool debug, DefUseAnalysis* dfa_p){
47  dfa=dfa_p;
48  DEBUG_MODE=debug;
49  DEBUG_MODE_EXTRA=false;
50  breakPointForWhile=0;
51  breakPointForWhileNode=NULL;
52 
53  };
54  virtual ~LivenessAnalysis() {}
55 
56  SgFunctionDefinition* getFunction(SgNode* node);
57  int getNumberOfNodesVisited();
58  // Run liveness analysis on the entire project
59  //bool run(bool debug=false);
60  // Run liveness analysis for a single function
62  std::vector<SgInitializedName*> getIn(SgNode* sgNode) { return in[sgNode];}
63  std::vector<SgInitializedName*> getOut(SgNode* sgNode) { return out[sgNode];}
64  int getVisited(SgNode* n) {return visited[n];}
65 
66  void setIn(SgNode* sgNode, std::vector<SgInitializedName*> vec) { in[sgNode]= vec;}
67  void setOut(SgNode* sgNode, std::vector<SgInitializedName*> vec ) { out[sgNode]=vec;}
68 
69 
70  // used by ASTTraversals
71  template <class T> T merge_no_dups( T& v1, T& v2);
72  void fixupStatementsINOUT(SgFunctionDefinition* funcDecl);
73 };
74 
75 #endif