ARM diagnostic when 's' suffix on mnemonic that can't set flags.
authorJim Grosbach <grosbach@apple.com>
Thu, 14 Jul 2011 22:04:21 +0000 (22:04 +0000)
committerJim Grosbach <grosbach@apple.com>
Thu, 14 Jul 2011 22:04:21 +0000 (22:04 +0000)
For example, "mlss r0, r1, r2, r3".

The MLS instruction does not have a flag-setting variant.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135203 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/AsmParser/ARMAsmParser.cpp
test/MC/ARM/diagnostics.s

index bdcdd7966ebd80da8d660148952c704bd3cb066f..a4741270c7a5f0eecd8c53fd1092d5084e78de32 100644 (file)
@@ -2071,20 +2071,22 @@ bool ARMAsmParser::ParseInstruction(StringRef Name, SMLoc NameLoc,
   bool CanAcceptCarrySet, CanAcceptPredicationCode;
   GetMnemonicAcceptInfo(Head, CanAcceptCarrySet, CanAcceptPredicationCode);
 
+  // If we had a carry-set on an instruction that can't do that, issue an
+  // error.
+  if (!CanAcceptCarrySet && CarrySetting) {
+    Parser.EatToEndOfStatement();
+    return Error(NameLoc, "instruction '" + Head +
+                 "' can not set flags, but 's' suffix specified");
+  }
+
   // Add the carry setting operand, if necessary.
   //
   // FIXME: It would be awesome if we could somehow invent a location such that
   // match errors on this operand would print a nice diagnostic about how the
   // 's' character in the mnemonic resulted in a CCOut operand.
-  if (CanAcceptCarrySet) {
+  if (CanAcceptCarrySet)
     Operands.push_back(ARMOperand::CreateCCOut(CarrySetting ? ARM::CPSR : 0,
                                                NameLoc));
-  } else {
-    // This mnemonic can't ever accept a carry set, but the user wrote one (or
-    // misspelled another mnemonic).
-
-    // FIXME: Issue a nice error.
-  }
 
   // Add the predication code operand, if necessary.
   if (CanAcceptPredicationCode) {
index 7a9d85e9449272ca57c4c59138748f9058f7b024..4537a0ff6dff5c8404da00e360c8e2d4631da134 100644 (file)
@@ -3,6 +3,12 @@
 
 @ Check for various assembly diagnostic messages on invalid input.
 
+@ 's' bit on an instruction that can't accept it.
+        mlss r1, r2, r3, r4
+@ CHECK-ERRORS: error: instruction 'mls' can not set flags,
+@ CHECK-ERRORS: but 's' suffix specified
+
+
         @ Out of range shift immediate values.
         adc r1, r2, r3, lsl #invalid
         adc r4, r5, r6, lsl #-1