Fix encoding of Thumb1 B instructions with immediate offsets, which is necessary...
authorOwen Anderson <resistor@mac.com>
Tue, 30 Aug 2011 22:03:20 +0000 (22:03 +0000)
committerOwen Anderson <resistor@mac.com>
Tue, 30 Aug 2011 22:03:20 +0000 (22:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138834 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp
test/MC/ARM/basic-thumb-instructions.s

index a800b369bc29d0f383ca6d5c67efc6c6f5167745..b798a3c226d75993fbb996c07d39311d525cf8c8 100644 (file)
@@ -484,7 +484,10 @@ getThumbBLXTargetOpValue(const MCInst &MI, unsigned OpIdx,
 uint32_t ARMMCCodeEmitter::
 getThumbBRTargetOpValue(const MCInst &MI, unsigned OpIdx,
                         SmallVectorImpl<MCFixup> &Fixups) const {
-  return ::getBranchTargetOpValue(MI, OpIdx, ARM::fixup_arm_thumb_br, Fixups);
+  const MCOperand MO = MI.getOperand(OpIdx);
+  if (MO.isExpr())
+    return ::getBranchTargetOpValue(MI, OpIdx, ARM::fixup_arm_thumb_br, Fixups);
+  return (MO.getImm() >> 1);
 }
 
 /// getThumbBCCTargetOpValue - Return encoding info for Thumb branch target.
index d44ffeb7b7c20b25ae275bb26913fe374426ba0b..0e9eebdb110b11ea693581288f3f492cf5b185c5 100644 (file)
@@ -105,12 +105,15 @@ _func:
 @------------------------------------------------------------------------------
         b _baz
         beq _bar
+        b       #1838
+        b       #-420
 
 @ CHECK: b     _baz                    @ encoding: [A,0xe0'A']
              @   fixup A - offset: 0, value: _baz, kind: fixup_arm_thumb_br
 @ CHECK: beq   _bar                    @ encoding: [A,0xd0]
              @   fixup A - offset: 0, value: _bar, kind: fixup_arm_thumb_bcc
-
+@ CHECK: b       #1838                   @ encoding: [0x97,0xe3]
+@ CHECK: b       #-420                   @ encoding: [0x2e,0xe7]
 
 @------------------------------------------------------------------------------
 @ BICS