ARM Disassembler: sign extend branch immediates.
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 9 Aug 2011 22:02:50 +0000 (22:02 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 9 Aug 2011 22:02:50 +0000 (22:02 +0000)
Not sure about BLXi, but this is what the old disassembler did.

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

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

index 6087a6164ae87a9ba93fc5a65780b64de9cdd376..307ce88536914061868c22502b3efc0e3a579fde 100644 (file)
@@ -1214,11 +1214,11 @@ static bool DecodeBranchImmInstruction(llvm::MCInst &Inst, unsigned Insn,
   if (pred == 0xF) {
     Inst.setOpcode(ARM::BLXi);
     imm |= fieldFromInstruction32(Insn, 24, 1) << 1;
-    Inst.addOperand(MCOperand::CreateImm(imm));
+    Inst.addOperand(MCOperand::CreateImm(SignExtend32<26>(imm)));
     return true;
   }
 
-  Inst.addOperand(MCOperand::CreateImm(imm));
+  Inst.addOperand(MCOperand::CreateImm(SignExtend32<26>(imm)));
   if (!DecodePredicateOperand(Inst, pred, Address, Decoder)) return false;
 
   return true;
index 43e6e07557fa9a0387a765e6e2c0dbcb6975ca81..52cd112629702538a6653f97222c94d5bda87e81 100644 (file)
 # CHECK:       stc2    p2, cr4, [r9], {157}
 0x9d 0x42 0x89 0xfc
 
+# CHECK:       bne #-24
+0xfa 0xff 0xff 0x1a
+
 # CHECK:       blx     #60
 0x0f 0x00 0x00 0xfa