diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 1ca3e1d120b..6bb59d4fa9e 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -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(Operands[5])->isImm()) { + ARMOperand *Op = static_cast(Operands[5]); + const MCConstantExpr *CE = dyn_cast(Op->getImm()); + if (CE && CE->getValue() == 0) { + Operands.erase(Operands.begin() + 5); + Operands.push_back(ARMOperand::CreateToken("#0", Op->getStartLoc())); + delete Op; + } + } + return false; } diff --git a/test/MC/ARM/basic-thumb-instructions.s b/test/MC/ARM/basic-thumb-instructions.s index 2fc050b1d3b..d7b902bcda0 100644 --- a/test/MC/ARM/basic-thumb-instructions.s +++ b/test/MC/ARM/basic-thumb-instructions.s @@ -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]