diff options
author | Evan Cheng <evan.cheng@apple.com> | 2006-11-03 03:05:24 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2006-11-03 03:05:24 +0000 |
commit | c5fc57dcaeac6b479fb15b9e1f4aca0845141006 (patch) | |
tree | 3c582a1003c47a18849e8c9ddb398c1326458a1e /lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | bf105c842450d3308d024be203ddd533f37051ec (diff) |
Added isPredecessor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31409 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index c2ee956fff..fe33ff5ed4 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -2563,6 +2563,29 @@ bool SDNode::isOperand(SDNode *N) const { return false; } +static void findPredecessor(SDNode *N, const SDNode *P, bool &found, + std::set<SDNode *> &Visited) { + if (found || !Visited.insert(N).second) + return; + + for (unsigned i = 0, e = N->getNumOperands(); !found && i != e; ++i) { + SDNode *Op = N->getOperand(i).Val; + if (Op == P) { + found = true; + return; + } + findPredecessor(Op, P, found, Visited); + } +} + +// isPredecessor - Return true if this node is a predecessor of N. +bool SDNode::isPredecessor(SDNode *N) const { + std::set<SDNode *> Visited; + bool found = false; + findPredecessor(N, this, found, Visited); + return found; +} + uint64_t SDNode::getConstantOperandVal(unsigned Num) const { assert(Num < NumOperands && "Invalid child # of SDNode!"); return cast<ConstantSDNode>(OperandList[Num])->getValue(); |