diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-12-02 07:16:45 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-12-02 07:16:45 +0000 |
| commit | 9c1b5027e77f0abe03e28ae85fac0f3c4c2d1b3f (patch) | |
| tree | 7916b6859ce8a77552fd505cf5a5c94fe8a1ef90 /llvm/lib | |
| parent | 0cdc0bbb8a2b9c3ea044c1bffb0565032ce9e80c (diff) | |
| download | bcm5719-llvm-9c1b5027e77f0abe03e28ae85fac0f3c4c2d1b3f.tar.gz bcm5719-llvm-9c1b5027e77f0abe03e28ae85fac0f3c4c2d1b3f.zip | |
add a little helper function that does PHI translation.
llvm-svn: 60405
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/VMCore/Value.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Value.cpp b/llvm/lib/VMCore/Value.cpp index 0976a745991..1b023e2feea 100644 --- a/llvm/lib/VMCore/Value.cpp +++ b/llvm/lib/VMCore/Value.cpp @@ -358,6 +358,19 @@ Value *Value::getUnderlyingObject() { 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 //===----------------------------------------------------------------------===// |

