#endif
}
-template<class NodeT, class GraphT>
-void Calculate(DominatorTreeBase<typename GraphT::NodeType>& DT, Function& F) {
+template<class FuncT, class NodeT>
+void Calculate(DominatorTreeBase<typename GraphTraits<NodeT>::NodeType>& DT,
+ FuncT& F) {
+ typedef GraphTraits<NodeT> GraphT;
+
// Step #1: Number blocks in depth-first order and initialize variables used
// in later stages of the algorithm.
unsigned N = 0;
/// DominatorTree - Calculate the immediate dominator tree for a function.
///
-template<class N, class GraphT>
-void Calculate(DominatorTreeBase<typename GraphT::NodeType>& DT,
- Function& F);
+template<class FuncT, class N>
+void Calculate(DominatorTreeBase<typename GraphTraits<N>::NodeType>& DT,
+ FuncT& F);
template<class NodeT>
class DominatorTreeBase : public DominatorBase<NodeT> {
typename GraphT::NodeType* V,
unsigned N);
- template<class N, class GraphT>
- friend void Calculate(DominatorTreeBase<typename GraphT::NodeType>& DT,
- Function& F);
+ template<class FuncT, class N>
+ friend void Calculate(DominatorTreeBase<typename GraphTraits<N>::NodeType>& DT,
+ FuncT& F);
/// updateDFSNumbers - Assign In and Out numbers to the nodes while walking
/// dominator tree in dfs order.
public:
/// recalculate - compute a dominator tree for the given function
- void recalculate(Function& F) {
+ template<class FT>
+ void recalculate(FT& F) {
if (!this->IsPostDominators) {
reset();
this->DomTreeNodes[&F.getEntryBlock()] = 0;
this->Vertex.push_back(0);
- Calculate<NodeT*, GraphTraits<NodeT*> >(*this, F);
+ Calculate<FT, NodeT*>(*this, F);
updateDFSNumbers();
} else {
this->Vertex.push_back(0);
- Calculate<Inverse<NodeT*>, GraphTraits<Inverse<NodeT*> > >(*this, F);
+ Calculate<FT, Inverse<NodeT*> >(*this, F);
}
}
};