[llvm-commits] [llvm] r117611 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Chris Lattner sabre at nondot.org
Thu Oct 28 14:41:58 PDT 2010


Author: lattner
Date: Thu Oct 28 16:41:58 2010
New Revision: 117611

URL: http://llvm.org/viewvc/llvm-project?rev=117611&view=rev
Log:
give better error diagnostics, for example:

t.s:1:14: error: invalid operand for instruction
vldr.64	d17, [r0]   
       	     ^

instead of:

t.s:1:1: error: unrecognized instruction
vldr.64	d17, [r0]   
^


Modified:
    llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=117611&r1=117610&r2=117611&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Thu Oct 28 16:41:58 2010
@@ -759,14 +759,29 @@
                         MCStreamer &Out) {
   MCInst Inst;
   unsigned ErrorInfo;
-  if (MatchInstructionImpl(Operands, Inst, ErrorInfo) == Match_Success) {
+  switch (MatchInstructionImpl(Operands, Inst, ErrorInfo)) {
+  case Match_Success:
     Out.EmitInstruction(Inst);
     return false;
+      
+  case Match_MissingFeature:
+    Error(IDLoc, "instruction requires a CPU feature not currently enabled");
+    return true;
+  case Match_InvalidOperand: {
+    SMLoc ErrorLoc = IDLoc;
+    if (ErrorInfo != ~0U) {
+      if (ErrorInfo >= Operands.size())
+        return Error(IDLoc, "too few operands for instruction");
+      
+      ErrorLoc = ((ARMOperand*)Operands[ErrorInfo])->getStartLoc();
+      if (ErrorLoc == SMLoc()) ErrorLoc = IDLoc;
+    }
+    
+    return Error(ErrorLoc, "invalid operand for instruction");
+  }
+  case Match_MnemonicFail:
+    return Error(IDLoc, "unrecognized instruction mnemonic");
   }
-  
-  // FIXME: We should give nicer diagnostics about the exact failure.
-  Error(IDLoc, "unrecognized instruction");
-  return true;
 }
 
 





More information about the llvm-commits mailing list