ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG.h
Go to the documentation of this file.
1 /*
2  * File: PDG.h
3  * Author: Cong Hou [hou_cong@gatech.edu]
4  */
5 
6 #ifndef ___________PDG_H__________
7 #define ___________PDG_H__________
8 
9 #include "cong_staticCFG.h"
10 
11 namespace SDG
12 {
13 
14 
15 typedef std::vector<SgInitializedName*> VarName;
16 
17 struct PDGNode
18 {
19  bool isEntry;
21 };
22 
23 
25 
28 struct PDGEdge
29 {
30  //typedef std::vector<SgInitializedName*> VarName;
31 
32  enum EdgeType
33  {
36  };
37 
40 
41  /**************************************************************************/
42  // Control dependence
43 
46 
49 
50  /**************************************************************************/
51 
52 
53 
54  /**************************************************************************/
55  // Data dependence
56 
58  std::set<VarName> varNames;
59 
60  /**************************************************************************/
61 
63  //CDGEdge cdEdge;
64 
66  //DDGEdge ddEdge;
67 
69  //std::set<VarName> varNames;
70 };
71 
72 class ProgramDependenceGraph : public boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS,
73 StaticCFG::CFGNodePtr, PDGEdge >
74 {
75  public:
76  typedef boost::graph_traits<ProgramDependenceGraph>::vertex_descriptor Vertex;
77  typedef boost::graph_traits<ProgramDependenceGraph>::edge_descriptor Edge;
78 
79  protected:
82  typedef CFG::Edge CFGEdge;
83 
84 
88 
89  public:
92 
95  {
96  build(cfg);
97  }
98 
101  {
103  build(cfg);
104  }
105 
107  void build(const CFG& cfg);
108 
110  void toDot(const std::string& filename) const;
111 
112  Vertex getEntry() const { return entry_; }
113 
114  protected:
115 
117  const std::map<CFGVertex, Vertex>& cfgVerticesToPdgVertices,
118  const CFG& cfg);
119 
121  const std::map<CFGVertex, Vertex>& cfgVerticesToPdgVertices,
122  const CFG& cfg);
123 
125  void writeGraphNode(std::ostream& out, const Vertex& node) const
126  {
127  if (node == entry_)
128  {
129  out << "[label=\"ENTRY\"]";
130  }
131  else
132  StaticCFG::writeCFGNode(out, *(*this)[node]);
133  }
134 
136  void writeGraphEdge(std::ostream& out, const Edge& edge) const;
137 };
138 
139 
140 
141 } // end of namespace SystemDependenceGraph
142 
143 
144 
145 #endif /* ___________PDG_H__________ */
146