diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-01-12 18:37:47 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-01-12 18:37:47 +0000 |
| commit | 40e7982c2c3d1f3b2e7f42006cf500773268b9f7 (patch) | |
| tree | 5c54146473fecbdddae6140b0a4b095eadf540f5 /llvm/lib/CodeGen | |
| parent | 373e8f5607352eb1022509fd6cc76162874dc7ff (diff) | |
| download | bcm5719-llvm-40e7982c2c3d1f3b2e7f42006cf500773268b9f7.tar.gz bcm5719-llvm-40e7982c2c3d1f3b2e7f42006cf500773268b9f7.zip | |
New method
llvm-svn: 19517
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 1996880e4ba..3f598fd8b32 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -833,6 +833,39 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, } } +/// hasNUsesOfValue - Return true if there are exactly NUSES uses of the +/// indicated value. This method ignores uses of other values defined by this +/// operation. +bool SDNode::hasNUsesOfValue(unsigned NUses, unsigned Value) { + assert(Value < getNumValues() && "Bad value!"); + + // If there is only one value, this is easy. + if (getNumValues() == 1) + return use_size() == NUses; + if (Uses.size() < NUses) return false; + + SDOperand TheValue(this, Value); + + std::set<SDNode*> UsersHandled; + + for (std::vector<SDNode*>::iterator UI = Uses.begin(), E = Uses.end(); + UI != E; ++UI) { + SDNode *User = *UI; + if (User->getNumOperands() == 1 || + UsersHandled.insert(User).second) // First time we've seen this? + for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) + if (User->getOperand(i) == TheValue) { + if (NUses == 0) + return false; // too many uses + --NUses; + } + } + + // Found exactly the right number of uses? + return NUses == 0; +} + + const char *SDNode::getOperationName() const { switch (getOpcode()) { default: return "<<Unknown>>"; |

