mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
- Doxygenize comments
- Add new method to dominatorset: properlyDominates - Add synonmys for operator[] to classes so that pointers to dominator information can be used more easily. - Add API's to update dominator information git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3585 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f9bbe214fd
commit
0c5d27e4a1
@ -67,28 +67,46 @@ public:
|
|||||||
inline const_iterator find(BasicBlock* B) const { return Doms.find(B); }
|
inline const_iterator find(BasicBlock* B) const { return Doms.find(B); }
|
||||||
inline iterator find(BasicBlock* B) { return Doms.find(B); }
|
inline iterator find(BasicBlock* B) { return Doms.find(B); }
|
||||||
|
|
||||||
// getDominators - Return the set of basic blocks that dominate the specified
|
|
||||||
// block.
|
/// getDominators - Return the set of basic blocks that dominate the specified
|
||||||
//
|
/// block.
|
||||||
|
///
|
||||||
inline const DomSetType &getDominators(BasicBlock *BB) const {
|
inline const DomSetType &getDominators(BasicBlock *BB) const {
|
||||||
const_iterator I = find(BB);
|
const_iterator I = find(BB);
|
||||||
assert(I != end() && "BB not in function!");
|
assert(I != end() && "BB not in function!");
|
||||||
return I->second;
|
return I->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dominates - Return true if A dominates B.
|
/// dominates - Return true if A dominates B.
|
||||||
//
|
///
|
||||||
inline bool dominates(BasicBlock *A, BasicBlock *B) const {
|
inline bool dominates(BasicBlock *A, BasicBlock *B) const {
|
||||||
return getDominators(B).count(A) != 0;
|
return getDominators(B).count(A) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// print - Convert to human readable form
|
/// properlyDominates - Return true if A dominates B and A != B.
|
||||||
|
///
|
||||||
|
bool properlyDominates(BasicBlock *A, BasicBlock *B) const {
|
||||||
|
return dominates(A, B) && A != B;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// print - Convert to human readable form
|
||||||
virtual void print(std::ostream &OS) const;
|
virtual void print(std::ostream &OS) const;
|
||||||
|
|
||||||
// dominates - Return true if A dominates B. This performs the special checks
|
/// dominates - Return true if A dominates B. This performs the special
|
||||||
// neccesary if A and B are in the same basic block.
|
/// checks neccesary if A and B are in the same basic block.
|
||||||
//
|
///
|
||||||
bool dominates(Instruction *A, Instruction *B) const;
|
bool dominates(Instruction *A, Instruction *B) const;
|
||||||
|
|
||||||
|
//===--------------------------------------------------------------------===//
|
||||||
|
// API to update (Post)DominatorSet information based on modifications to
|
||||||
|
// the CFG...
|
||||||
|
|
||||||
|
/// addBasicBlock - Call to update the dominator set with information about a
|
||||||
|
/// new block that was inserted into the function.
|
||||||
|
void addBasicBlock(BasicBlock *BB, const DomSetType &Dominators) {
|
||||||
|
assert(find(BB) == end() && "Block already in DominatorSet!");
|
||||||
|
Doms.insert(std::make_pair(BB, Dominators));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -135,10 +153,28 @@ public:
|
|||||||
// node returns null, because it does not have an immediate dominator.
|
// node returns null, because it does not have an immediate dominator.
|
||||||
//
|
//
|
||||||
inline BasicBlock *operator[](BasicBlock *BB) const {
|
inline BasicBlock *operator[](BasicBlock *BB) const {
|
||||||
|
return get(BB);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get() - Synonym for operator[].
|
||||||
|
inline BasicBlock *get(BasicBlock *BB) const {
|
||||||
std::map<BasicBlock*, BasicBlock*>::const_iterator I = IDoms.find(BB);
|
std::map<BasicBlock*, BasicBlock*>::const_iterator I = IDoms.find(BB);
|
||||||
return I != IDoms.end() ? I->second : 0;
|
return I != IDoms.end() ? I->second : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===--------------------------------------------------------------------===//
|
||||||
|
// API to update Immediate(Post)Dominators information based on modifications
|
||||||
|
// to the CFG...
|
||||||
|
|
||||||
|
/// addNewBlock - Add a new block to the CFG, with the specified immediate
|
||||||
|
/// dominator.
|
||||||
|
///
|
||||||
|
void addNewBlock(BasicBlock *BB, BasicBlock *IDom) {
|
||||||
|
assert(get(BB) == 0 && "BasicBlock already in idom info!");
|
||||||
|
IDoms[BB] = IDom;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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;
|
||||||
};
|
};
|
||||||
@ -182,6 +218,7 @@ public:
|
|||||||
class Node2 : public std::vector<Node*> {
|
class Node2 : public std::vector<Node*> {
|
||||||
friend class DominatorTree;
|
friend class DominatorTree;
|
||||||
friend class PostDominatorTree;
|
friend class PostDominatorTree;
|
||||||
|
friend class DominatorTreeBase;
|
||||||
BasicBlock *TheNode;
|
BasicBlock *TheNode;
|
||||||
Node2 *IDom;
|
Node2 *IDom;
|
||||||
public:
|
public:
|
||||||
@ -210,12 +247,33 @@ public:
|
|||||||
|
|
||||||
virtual void releaseMemory() { reset(); }
|
virtual void releaseMemory() { reset(); }
|
||||||
|
|
||||||
inline Node *operator[](BasicBlock *BB) const {
|
/// getNode - return the (Post)DominatorTree node for the specified basic
|
||||||
|
/// block. This is the same as using operator[] on this class.
|
||||||
|
///
|
||||||
|
inline Node *getNode(BasicBlock *BB) const {
|
||||||
NodeMapType::const_iterator i = Nodes.find(BB);
|
NodeMapType::const_iterator i = Nodes.find(BB);
|
||||||
return (i != Nodes.end()) ? i->second : 0;
|
return (i != Nodes.end()) ? i->second : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// print - Convert to human readable form
|
inline Node *operator[](BasicBlock *BB) const {
|
||||||
|
return getNode(BB);
|
||||||
|
}
|
||||||
|
|
||||||
|
// API to update (Post)DominatorTree information based on modifications to
|
||||||
|
// the CFG...
|
||||||
|
|
||||||
|
/// createNewNode - Add a new node to the dominator tree information. This
|
||||||
|
/// creates a new node as a child of IDomNode, linking it into the children
|
||||||
|
/// list of the immediate dominator.
|
||||||
|
///
|
||||||
|
Node *createNewNode(BasicBlock *BB, Node *IDomNode) {
|
||||||
|
assert(getNode(BB) == 0 && "Block already in dominator tree!");
|
||||||
|
Node *New = Nodes[BB] = new Node(BB, IDomNode);
|
||||||
|
if (IDomNode) IDomNode->addChild(New);
|
||||||
|
return New;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// print - Convert to human readable form
|
||||||
virtual void print(std::ostream &OS) const;
|
virtual void print(std::ostream &OS) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user