Fixed a bug in disassembly of STR_POST, where the immediate is the second operand...
authorJohnny Chen <johnny.chen@apple.com>
Sat, 2 Apr 2011 02:24:54 +0000 (02:24 +0000)
committerJohnny Chen <johnny.chen@apple.com>
Sat, 2 Apr 2011 02:24:54 +0000 (02:24 +0000)
instead of the second operand in addrmode_imm12.

rdar://problem/9225289

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

lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp
test/MC/Disassembler/ARM/arm-tests.txt

index 884a056ef5df863953413c7a3733f12edfef3eee..27683e397517a4cc7ee85134f89053aa1105d8e6 100644 (file)
@@ -1098,12 +1098,20 @@ static bool DisassembleLdStFrm(MCInst &MI, unsigned Opcode, uint32_t insn,
       OpIdx += 1;
     }
 
-    // Disassemble the 12-bit immediate offset, which is the second operand in
-    // $addrmode_imm12 => (ops GPR:$base, i32imm:$offsimm).
-    // 
     unsigned Imm12 = slice(insn, 11, 0);
-    int Offset = AddrOpcode == ARM_AM::add ? 1 * Imm12 : -1 * Imm12;
-    MI.addOperand(MCOperand::CreateImm(Offset));
+    if (Opcode == ARM::LDRBi12 || Opcode == ARM::LDRi12 ||
+        Opcode == ARM::STRBi12 || Opcode == ARM::STRi12) {
+      // Disassemble the 12-bit immediate offset, which is the second operand in
+      // $addrmode_imm12 => (ops GPR:$base, i32imm:$offsimm).    
+      int Offset = AddrOpcode == ARM_AM::add ? 1 * Imm12 : -1 * Imm12;
+      MI.addOperand(MCOperand::CreateImm(Offset));
+    } else {
+      // Disassemble the 12-bit immediate offset, which is the second operand in
+      // $am2offset => (ops GPR, i32imm).
+      unsigned Offset = ARM_AM::getAM2Opc(AddrOpcode, Imm12, ARM_AM::no_shift,
+                                          IndexMode);
+      MI.addOperand(MCOperand::CreateImm(Offset));
+    }
     OpIdx += 1;
   } else {
     // The opcode ARM::LDRT actually corresponds to both Encoding A1 and A2 of
index c66f8ce9688688cf11ef3464790f2aef6d17b2ab..8a8bcdde932fd3c4114be8ff5668551656d2b0d0 100644 (file)
 
 # CHECK:       adcshi  r10, r8, r0, asr r3
 0x50 0xa3 0xb8 0x80
+
+# CHECK:       streq   r1, [sp], #-1567
+0x1f 0x16 0xd 0x4