[llvm] r204542 - [TableGen] Don't assert, produce an error, when an instruction has too few operands

Hal Finkel hfinkel at anl.gov
Sat Mar 22 04:33:35 PDT 2014


Author: hfinkel
Date: Sat Mar 22 06:33:32 2014
New Revision: 204542

URL: http://llvm.org/viewvc/llvm-project?rev=204542&view=rev
Log:
[TableGen] Don't assert, produce an error, when an instruction has too few operands

When an instruction's operand list does not have a sufficient number of
operands to match with all of the variables that contribute to its
encoding, instead of asserting inside a call to getSubOperandNumber, produce an
informative error.

Modified:
    llvm/trunk/utils/TableGen/CodeEmitterGen.cpp

Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.cpp?rev=204542&r1=204541&r2=204542&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeEmitterGen.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Sat Mar 22 06:33:32 2014
@@ -107,9 +107,20 @@ AddCodeToMergeInOperand(Record *R, BitsI
     while (NumberedOp < NumberOps &&
            (CGI.Operands.isFlatOperandNotEmitted(NumberedOp) ||
               (NamedOpIndices.size() && NamedOpIndices.count(
-                CGI.Operands.getSubOperandNumber(NumberedOp).first))))
+                CGI.Operands.getSubOperandNumber(NumberedOp).first)))) {
       ++NumberedOp;
 
+      if (NumberedOp >= CGI.Operands.back().MIOperandNo +
+                        CGI.Operands.back().MINumOperands) {
+        errs() << "Too few operands in record " << R->getName() <<
+                  " (no match for variable " << VarName << "):\n";
+        errs() << *R;
+        errs() << '\n';
+
+        return;
+      }
+    }
+
     OpIdx = NumberedOp++;
   }
   





More information about the llvm-commits mailing list