forked from OSchip/llvm-project
- Add methods to ImmediateDominators & DominatorTree to allow updates
- Make DominatorTree::Node not inherit from std::vector llvm-svn: 3938
This commit is contained in:
parent
9ff37c5265
commit
6561db0c12
|
@ -183,6 +183,14 @@ public:
|
||||||
IDoms[BB] = IDom;
|
IDoms[BB] = IDom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// setImmediateDominator - Update the immediate dominator information to
|
||||||
|
/// change the current immediate dominator for the specified block to another
|
||||||
|
/// block. This method requires that BB already have an IDom, otherwise just
|
||||||
|
/// use addNewBlock.
|
||||||
|
void setImmediateDominator(BasicBlock *BB, BasicBlock *NewIDom) {
|
||||||
|
assert(IDoms.find(BB) != IDoms.end() && "BB doesn't have idom yet!");
|
||||||
|
IDoms[BB] = NewIDom;
|
||||||
|
}
|
||||||
|
|
||||||
// print - Convert to human readable form
|
// print - Convert to human readable form
|
||||||
virtual void print(std::ostream &OS) const;
|
virtual void print(std::ostream &OS) const;
|
||||||
|
@ -224,16 +232,25 @@ protected:
|
||||||
void reset();
|
void reset();
|
||||||
typedef std::map<BasicBlock*, Node*> NodeMapType;
|
typedef std::map<BasicBlock*, Node*> NodeMapType;
|
||||||
public:
|
public:
|
||||||
class Node2 : public std::vector<Node*> {
|
class Node2 {
|
||||||
friend class DominatorTree;
|
friend class DominatorTree;
|
||||||
friend class PostDominatorTree;
|
friend class PostDominatorTree;
|
||||||
friend class DominatorTreeBase;
|
friend class DominatorTreeBase;
|
||||||
BasicBlock *TheNode;
|
BasicBlock *TheNode;
|
||||||
Node2 *IDom;
|
Node2 *IDom;
|
||||||
|
std::vector<Node*> Children;
|
||||||
public:
|
public:
|
||||||
|
typedef std::vector<Node*>::iterator iterator;
|
||||||
|
typedef std::vector<Node*>::const_iterator const_iterator;
|
||||||
|
|
||||||
|
iterator begin() { return Children.begin(); }
|
||||||
|
iterator end() { return Children.end(); }
|
||||||
|
const_iterator begin() const { return Children.begin(); }
|
||||||
|
const_iterator end() const { return Children.end(); }
|
||||||
|
|
||||||
inline BasicBlock *getNode() const { return TheNode; }
|
inline BasicBlock *getNode() const { return TheNode; }
|
||||||
inline Node2 *getIDom() const { return IDom; }
|
inline Node2 *getIDom() const { return IDom; }
|
||||||
inline const std::vector<Node*> &getChildren() const { return *this; }
|
inline const std::vector<Node*> &getChildren() const { return Children; }
|
||||||
|
|
||||||
// dominates - Returns true iff this dominates N. Note that this is not a
|
// dominates - Returns true iff this dominates N. Note that this is not a
|
||||||
// constant time operation!
|
// constant time operation!
|
||||||
|
@ -247,7 +264,9 @@ public:
|
||||||
private:
|
private:
|
||||||
inline Node2(BasicBlock *node, Node *iDom)
|
inline Node2(BasicBlock *node, Node *iDom)
|
||||||
: TheNode(node), IDom(iDom) {}
|
: TheNode(node), IDom(iDom) {}
|
||||||
inline Node2 *addChild(Node *C) { push_back(C); return C; }
|
inline Node2 *addChild(Node *C) { Children.push_back(C); return C; }
|
||||||
|
|
||||||
|
void setIDom(Node2 *NewIDom);
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -268,7 +287,7 @@ public:
|
||||||
return getNode(BB);
|
return getNode(BB);
|
||||||
}
|
}
|
||||||
|
|
||||||
// API to update (Post)DominatorTree information based on modifications to
|
//===--------------------------------------------------------------------===// // API to update (Post)DominatorTree information based on modifications to
|
||||||
// the CFG...
|
// the CFG...
|
||||||
|
|
||||||
/// createNewNode - Add a new node to the dominator tree information. This
|
/// createNewNode - Add a new node to the dominator tree information. This
|
||||||
|
@ -282,6 +301,14 @@ public:
|
||||||
return New;
|
return New;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// changeImmediateDominator - This method is used to update the dominator
|
||||||
|
/// tree information when a node's immediate dominator changes.
|
||||||
|
///
|
||||||
|
void changeImmediateDominator(Node *Node, Node *NewIDom) {
|
||||||
|
assert(Node && NewIDom && "Cannot change null node pointers!");
|
||||||
|
Node->setIDom(NewIDom);
|
||||||
|
}
|
||||||
|
|
||||||
/// print - Convert to human readable form
|
/// print - Convert to human readable form
|
||||||
virtual void print(std::ostream &OS) const;
|
virtual void print(std::ostream &OS) const;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue