[llvm-commits] [llvm] r118327 - /llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
Chris Lattner
sabre at nondot.org
Fri Nov 5 23:54:39 PDT 2010
Author: lattner
Date: Sat Nov 6 01:54:38 2010
New Revision: 118327
URL: http://llvm.org/viewvc/llvm-project?rev=118327&view=rev
Log:
decode and validate instruction alias result definitions.
Modified:
llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.cpp?rev=118327&r1=118326&r2=118327&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenInstruction.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenInstruction.cpp Sat Nov 6 01:54:38 2010
@@ -400,4 +400,37 @@
throw TGError(R->getLoc(), "result of inst alias should be an instruction");
ResultInst = &T.getInstruction(DI->getDef());
+
+ // Check number of arguments in the result.
+ if (ResultInst->Operands.size() != Result->getNumArgs())
+ throw TGError(R->getLoc(), "result has " + utostr(Result->getNumArgs()) +
+ " arguments, but " + ResultInst->TheDef->getName() +
+ " instruction expects " + utostr(ResultInst->Operands.size())+
+ " operands!");
+
+ // Decode and validate the arguments of the result.
+ for (unsigned i = 0, e = Result->getNumArgs(); i != e; ++i) {
+ Init *Arg = Result->getArg(i);
+
+ // If the operand is a record, it must have a name, and the record type must
+ // match up with the instruction's argument type.
+ if (DefInit *ADI = dynamic_cast<DefInit*>(Arg)) {
+ if (Result->getArgName(i).empty())
+ throw TGError(R->getLoc(), "result argument #" + utostr(i) +
+ " must have a name!");
+
+ if (ADI->getDef() != ResultInst->Operands[i].Rec)
+ throw TGError(R->getLoc(), "result argument #" + utostr(i) +
+ " declared with class " + ADI->getDef()->getName() +
+ ", instruction operand is class " +
+ ResultInst->Operands[i].Rec->getName());
+
+ // Now that it is validated, add it.
+ ResultOperands.push_back(ResultOperand(Result->getArgName(i),
+ ADI->getDef()));
+ continue;
+ }
+
+ throw TGError(R->getLoc(), "result of inst alias has unknown operand type");
+ }
}
More information about the llvm-commits
mailing list