[llvm] r201531 - Fix the arm assembler so that this malformed instruction:

Kevin Enderby enderby at apple.com
Mon Feb 17 13:45:28 PST 2014


Author: enderby
Date: Mon Feb 17 15:45:27 2014
New Revision: 201531

URL: http://llvm.org/viewvc/llvm-project?rev=201531&view=rev
Log:
Fix the arm assembler so that this malformed instruction:
    ldrd r6, r7 [r2, #15]
simply gives an error and does not triggers an assertion.

As Jim points out, the diagnostic is really strange here,
but fixing that would be more complicated. The missing
comma results in the parser expecting a construct like r2[2],
which is the vector index thing the error message is talking
about. That's not what the user intended, though, and there's
nothing else in the instruction that looks at all like a vector.
Yet more fallout from not having a real parser here and trying
to do context-free generic matching for addressing modes.

rdar://15097243

Added:
    llvm/trunk/test/MC/ARM/invalid-vector-index.s
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=201531&r1=201530&r2=201531&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Mon Feb 17 15:45:27 2014
@@ -2778,7 +2778,8 @@ int ARMAsmParser::tryParseShiftRegister(
                                SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
   SMLoc S = Parser.getTok().getLoc();
   const AsmToken &Tok = Parser.getTok();
-  assert(Tok.is(AsmToken::Identifier) && "Token is not an Identifier");
+  if (Tok.isNot(AsmToken::Identifier))
+    return -1; 
 
   std::string lowerCase = Tok.getString().lower();
   ARM_AM::ShiftOpc ShiftTy = StringSwitch<ARM_AM::ShiftOpc>(lowerCase)

Added: llvm/trunk/test/MC/ARM/invalid-vector-index.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/invalid-vector-index.s?rev=201531&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/invalid-vector-index.s (added)
+++ llvm/trunk/test/MC/ARM/invalid-vector-index.s Mon Feb 17 15:45:27 2014
@@ -0,0 +1,5 @@
+@ RUN: not llvm-mc -triple=armv7-apple-darwin < %s 2>&1 | FileCheck %s
+
+ldrd r6, r7 [r2, #15]
+
+@ CHECK: error: immediate value expected for vector index





More information about the llvm-commits mailing list