summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-28 08:48:47 +0000
committerChris Lattner <sabre@nondot.org>2010-03-28 08:48:47 +0000
commit135091bd9dd749b6bf731697b2371b77be5bdf5f (patch)
treec75a1cd9a044194e819c96e0e9560884242ade3b /llvm/utils/TableGen/CodeGenDAGPatterns.cpp
parentb7c48433df8d441c633aa416d52fa9d7ed259a2c (diff)
downloadbcm5719-llvm-135091bd9dd749b6bf731697b2371b77be5bdf5f.tar.gz
bcm5719-llvm-135091bd9dd749b6bf731697b2371b77be5bdf5f.zip
improve type checking of SDNode operand count. This rejects all cases
where an incorrect number of operands is provided to an sdnode instead of just a few cases. llvm-svn: 99761
Diffstat (limited to 'llvm/utils/TableGen/CodeGenDAGPatterns.cpp')
-rw-r--r--llvm/utils/TableGen/CodeGenDAGPatterns.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
index 4375adfdf69..84a041b1946 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -586,13 +586,6 @@ static TreePatternNode *getOperandNum(unsigned OpNo, TreePatternNode *N,
bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
const SDNodeInfo &NodeInfo,
TreePattern &TP) const {
- // Check that the number of operands is sane. Negative operands -> varargs.
- if (NodeInfo.getNumOperands() >= 0) {
- if (N->getNumChildren() != (unsigned)NodeInfo.getNumOperands())
- TP.error(N->getOperator()->getName() + " node requires exactly " +
- itostr(NodeInfo.getNumOperands()) + " operands!");
- }
-
unsigned ResNo = 0; // The result number being referenced.
TreePatternNode *NodeToApply = getOperandNum(OperandNo, N, NodeInfo, ResNo);
@@ -1238,6 +1231,12 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
if (getOperator()->isSubClassOf("SDNode")) {
const SDNodeInfo &NI = CDP.getSDNodeInfo(getOperator());
+ // Check that the number of operands is sane. Negative operands -> varargs.
+ if (NI.getNumOperands() >= 0 &&
+ getNumChildren() != (unsigned)NI.getNumOperands())
+ TP.error(getOperator()->getName() + " node requires exactly " +
+ itostr(NI.getNumOperands()) + " operands!");
+
bool MadeChange = NI.ApplyTypeConstraints(this, TP);
for (unsigned i = 0, e = getNumChildren(); i != e; ++i)
MadeChange |= getChild(i)->ApplyTypeConstraints(TP, NotRegisters);
@@ -1469,7 +1468,7 @@ TreePatternNode *TreePattern::ParseTreePattern(Init *TheInit, StringRef OpName){
// Input argument?
TreePatternNode *Res = new TreePatternNode(DI, 1);
- if (R->getName() == "node") {
+ if (R->getName() == "node" && !OpName.empty()) {
if (OpName.empty())
error("'node' argument requires a name to match with operand list");
Args.push_back(OpName);
OpenPOWER on IntegriCloud