Fix disassembly of Thumb2 LDRSH with a #-0 offset.
authorOwen Anderson <resistor@mac.com>
Fri, 16 Sep 2011 21:08:33 +0000 (21:08 +0000)
committerOwen Anderson <resistor@mac.com>
Fri, 16 Sep 2011 21:08:33 +0000 (21:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139943 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/Disassembler/ARMDisassembler.cpp
lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
test/MC/Disassembler/ARM/thumb2.txt

index 685b921b4ed58136e64b9277376cb79d3528831d..2818e77afc9e27847328905a6e9a46365d19f040 100644 (file)
@@ -2731,7 +2731,10 @@ static DecodeStatus DecodeT2AddrModeImm0_1020s4(llvm::MCInst &Inst,unsigned Val,
 static DecodeStatus DecodeT2Imm8(llvm::MCInst &Inst, unsigned Val,
                          uint64_t Address, const void *Decoder) {
   int imm = Val & 0xFF;
-  if (!(Val & 0x100)) imm *= -1;
+  if (Val == 0)
+    imm = INT32_MIN;
+  else if (!(Val & 0x100))
+    imm *= -1;
   Inst.addOperand(MCOperand::CreateImm(imm));
 
   return MCDisassembler::Success;
index 0a0f1d07b53cf658f2e9a64def67dae189687946..0cae47762739d5536fc1ac2f36a5aa8e3acbfd00 100644 (file)
@@ -802,7 +802,9 @@ void ARMInstPrinter::printT2AddrModeImm8Operand(const MCInst *MI,
 
   int32_t OffImm = (int32_t)MO2.getImm();
   // Don't print +0.
-  if (OffImm < 0)
+  if (OffImm == INT32_MIN)
+    O << ", #-0";
+  else if (OffImm < 0)
     O << ", #-" << -OffImm;
   else if (OffImm > 0)
     O << ", #" << OffImm;
index bf1328afe058108331d3fcfa921a440fb172483b..dea590e5943710d6c2740b233eb0155f12a07306 100644 (file)
 # CHECK: ldrsh.w r5, [r6, #33]
 # CHECK: ldrsh.w r5, [r6, #257]
 # CHECK: ldrsh.w lr, [r7, #257]
+# CHECK: ldrsh r10, [r5, #-0]
 
 0x35 0xf9 0x04 0x5c
 0xb6 0xf9 0x20 0x50
 0xb6 0xf9 0x21 0x50
 0xb6 0xf9 0x01 0x51
 0xb7 0xf9 0x01 0xe1
-
+0x35 0xf9 0x00 0xac
 
 #------------------------------------------------------------------------------
 # LDRSH(register)