ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dominatorTreesAndDominanceFrontiers/DominatorTree.h
Go to the documentation of this file.
1 #ifndef _DOMINATORTREE_H_
2 #define _DOMINATORTREE_H_
3 
4 #include "ControlFlowGraph.h"
5 #include <GraphDotOutput.h>
6 #include <map>
7 
8 // DQ (12/30/2005): This is a Bad Bad thing to do (I can explain)
9 // it hides names in the global namespace and causes errors in
10 // otherwise valid and useful code. Where it is needed it should
11 // appear only in *.C files (and only ones not included for template
12 // instantiation reasons) else they effect user who use ROSE unexpectedly.
13 // using namespace std;
14 
15 // DQ (3/21/2006): Namespace introduced to hide redundent use of
16 // ControlFlowGraph class also found in:
17 // src/midend/programTransformation/partialRedundancyElimination
18 namespace DominatorTreesAndDominanceFrontiers {
19 
46 
47 public:
48 
50  enum Direction
51  {
52  PRE,
54  };
55 
56  DominatorTree(SgNode * head, Direction d = PRE);
57 
65  int getSize() {return _size;}
66 
68  int getDom(ControlNode * node) {return doms[node->getID(_iddir)];}
70  int getDom(int id) {return doms[id];}
71 
72  void printCFG();
73  void printDominators();
74 
75 
76 private:
77 
78  void _buildCFG(SgNode * head);
79  void _setupStructures();
80 
81  void _findDominators();
82  int _intersect(int f1, int f2);
85  bool _processNode(int i);
86 
89 
92 
99 
100  int _size;
101 
103  int * doms;
104 
105 };
106 
107 // end of namespace: DominatorTreesAndDominanceFrontiers
108  }
109 
110 #endif