Thumb parsing and encoding for RSB.
authorJim Grosbach <grosbach@apple.com>
Mon, 22 Aug 2011 23:47:13 +0000 (23:47 +0000)
committerJim Grosbach <grosbach@apple.com>
Mon, 22 Aug 2011 23:47:13 +0000 (23:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138308 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/AsmParser/ARMAsmParser.cpp
test/MC/ARM/basic-thumb-instructions.s

index 1ca3e1d120be581520c194c2e2a6c60e34c79a8f..6bb59d4fa9e98a8a36a9453f725e5ee19b3086fc 100644 (file)
@@ -3029,6 +3029,19 @@ bool ARMAsmParser::ParseInstruction(StringRef Name, SMLoc NameLoc,
       delete Op;
     }
   }
+  // Similarly, the Thumb1 "RSB" instruction has a literal "#0" on the
+  // end. Convert it to a token here.
+  if (Mnemonic == "rsb" && isThumb() && Operands.size() == 6 &&
+      static_cast<ARMOperand*>(Operands[5])->isImm()) {
+    ARMOperand *Op = static_cast<ARMOperand*>(Operands[5]);
+    const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Op->getImm());
+    if (CE && CE->getValue() == 0) {
+      Operands.erase(Operands.begin() + 5);
+      Operands.push_back(ARMOperand::CreateToken("#0", Op->getStartLoc()));
+      delete Op;
+    }
+  }
+
   return false;
 }
 
index 2fc050b1d3baeb3bb7ad0c74e4da83e4753b8766..d7b902bcda057857dee698c9f04f9b7f02717831 100644 (file)
@@ -399,3 +399,11 @@ _func:
         rors r2, r7
 
 @ CHECK: rors  r2, r7                  @ encoding: [0xfa,0x41]
+
+
+@------------------------------------------------------------------------------
+@ RSB
+@------------------------------------------------------------------------------
+        rsbs r1, r3, #0
+
+       rsbs    r1, r3, #0              @ encoding: [0x59,0x42]