summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-11-03 03:05:24 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-11-03 03:05:24 +0000
commitc176f038b917826ba07d2434f2a4569eb4ea1bc9 (patch)
tree06d54305d68eebb56042935d54ef61e3f16f46ea /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent299022d514d7285a17195c6c82a47afc9e8c7c37 (diff)
downloadbcm5719-llvm-c176f038b917826ba07d2434f2a4569eb4ea1bc9.tar.gz
bcm5719-llvm-c176f038b917826ba07d2434f2a4569eb4ea1bc9.zip
Added isPredecessor.
llvm-svn: 31409
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index c2ee956fff2..fe33ff5ed4a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/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();
OpenPOWER on IntegriCloud