From 0b59225fe1ab91a20b81430b34bc4157a7471591 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 14 Sep 2005 21:59:34 +0000 Subject: [PATCH] check that there are no unexpected operands git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23359 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/DAGISelEmitter.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index 085f7d2dae5..d83faceaee8 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -803,21 +803,29 @@ void DAGISelEmitter::ParseAndResolveInstructions() { InstResults.erase(OpName); } - // Loop over the inputs next. + // Loop over the inputs next. Make a copy of InstInputs so we can destroy + // the copy while we're checking the inputs. + std::map InstInputsCheck(InstInputs); + for (unsigned i = NumResults, e = CGI.OperandList.size(); i != e; ++i) { const std::string &OpName = CGI.OperandList[i].Name; if (OpName.empty()) I->error("Operand #" + utostr(i) + " in operands list has no name!"); - if (!InstInputs.count(OpName)) + if (!InstInputsCheck.count(OpName)) I->error("Operand $" + OpName + " does not appear in the instruction pattern"); - TreePatternNode *InVal = InstInputs[OpName]; + TreePatternNode *InVal = InstInputsCheck[OpName]; + InstInputsCheck.erase(OpName); if (CGI.OperandList[i].Ty != InVal->getType()) I->error("Operand $" + OpName + "'s type disagrees between the operand and pattern"); } + if (!InstInputsCheck.empty()) + I->error("Input operand $" + InstInputsCheck.begin()->first + + " occurs in pattern but not in operands list!"); + unsigned NumOperands = CGI.OperandList.size()-NumResults; DEBUG(I->dump());