From 7982de167f89ddef8005d41c41627a2fa80f0966 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 3 Nov 2006 23:45:17 +0000 Subject: [PATCH] eliminate need for the NumMIOperands field in Operand. llvm-svn: 31432 --- llvm/utils/TableGen/CodeGenTarget.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/llvm/utils/TableGen/CodeGenTarget.cpp b/llvm/utils/TableGen/CodeGenTarget.cpp index 753651d950fd..9e45f2ea87a8 100644 --- a/llvm/utils/TableGen/CodeGenTarget.cpp +++ b/llvm/utils/TableGen/CodeGenTarget.cpp @@ -365,8 +365,20 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr) DagInit *MIOpInfo = 0; if (Rec->isSubClassOf("Operand")) { PrintMethod = Rec->getValueAsString("PrintMethod"); - NumOps = Rec->getValueAsInt("NumMIOperands"); MIOpInfo = Rec->getValueAsDag("MIOperandInfo"); + + // Verify that MIOpInfo has an 'ops' root value. + if (!dynamic_cast(MIOpInfo->getOperator()) || + dynamic_cast(MIOpInfo->getOperator()) + ->getDef()->getName() != "ops") + throw "Bad value for MIOperandInfo in operand '" + Rec->getName() + + "'\n"; + + // If we have MIOpInfo, then we have #operands equal to number of entries + // in MIOperandInfo. + if (unsigned NumArgs = MIOpInfo->getNumArgs()) + NumOps = NumArgs; + } else if (Rec->getName() == "variable_ops") { hasVariableNumberOfOperands = true; continue;