mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
add a little helper function that does PHI translation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60405 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -242,6 +242,17 @@ public:
|
|||||||
const Value *getUnderlyingObject() const {
|
const Value *getUnderlyingObject() const {
|
||||||
return const_cast<Value*>(this)->getUnderlyingObject();
|
return const_cast<Value*>(this)->getUnderlyingObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// DoPHITranslation - If this value is a PHI node with CurBB as a its parent,
|
||||||
|
/// return the value in the PHI node corresponding to PredBB. If not, return
|
||||||
|
/// ourself. This is useful if you want to know the value something has in a
|
||||||
|
/// predecessor block.
|
||||||
|
Value *DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB);
|
||||||
|
|
||||||
|
const Value *DoPHITranslation(const BasicBlock *CurBB,
|
||||||
|
const BasicBlock *PredBB) const{
|
||||||
|
return const_cast<Value*>(this)->DoPHITranslation(CurBB, PredBB);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::ostream &operator<<(std::ostream &OS, const Value &V) {
|
inline std::ostream &operator<<(std::ostream &OS, const Value &V) {
|
||||||
|
@ -358,6 +358,19 @@ Value *Value::getUnderlyingObject() {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// DoPHITranslation - If this value is a PHI node with CurBB as a its parent,
|
||||||
|
/// return the value in the PHI node corresponding to PredBB. If not, return
|
||||||
|
/// ourself. This is useful if you want to know the value something has in a
|
||||||
|
/// predecessor block.
|
||||||
|
Value *Value::DoPHITranslation(const BasicBlock *CurBB,
|
||||||
|
const BasicBlock *PredBB) {
|
||||||
|
PHINode *PN = dyn_cast<PHINode>(this);
|
||||||
|
if (PN && PN->getParent() == CurBB)
|
||||||
|
return PN->getIncomingValueForBlock(PredBB);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// User Class
|
// User Class
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
Reference in New Issue
Block a user