Fix encoding for tBcc with immediate offset operand.
authorOwen Anderson <resistor@mac.com>
Wed, 31 Aug 2011 20:26:14 +0000 (20:26 +0000)
committerOwen Anderson <resistor@mac.com>
Wed, 31 Aug 2011 20:26:14 +0000 (20:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138889 91177308-0d34-0410-b5e6-96231b3b80d8

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

index f6b8af87b546689b93a7b521e1562f89c6493dc8..69ec197af517a722fee2f09c2fb740c810125432 100644 (file)
@@ -522,7 +522,11 @@ getThumbBRTargetOpValue(const MCInst &MI, unsigned OpIdx,
 uint32_t ARMMCCodeEmitter::
 getThumbBCCTargetOpValue(const MCInst &MI, unsigned OpIdx,
                          SmallVectorImpl<MCFixup> &Fixups) const {
-  return ::getBranchTargetOpValue(MI, OpIdx, ARM::fixup_arm_thumb_bcc, Fixups);
+  const MCOperand MO = MI.getOperand(OpIdx);
+  if (MO.isExpr())
+    return ::getBranchTargetOpValue(MI, OpIdx, ARM::fixup_arm_thumb_bcc,
+                                    Fixups);
+  return (MO.getImm() >> 1);
 }
 
 /// getThumbCBTargetOpValue - Return encoding info for Thumb branch target.
index cd4471e884c04a4ff323cff6f0790b8e7cd8a93b..0fa52b098746505cdc37ef468fef34da26f2fe77 100644 (file)
@@ -114,6 +114,8 @@ _func:
         beq _bar
         b       #1838
         b       #-420
+        beq     #336
+        beq     #160
 
 @ CHECK: b     _baz                    @ encoding: [A,0xe0'A']
              @   fixup A - offset: 0, value: _baz, kind: fixup_arm_thumb_br
@@ -121,6 +123,8 @@ _func:
              @   fixup A - offset: 0, value: _bar, kind: fixup_arm_thumb_bcc
 @ CHECK: b       #1838                   @ encoding: [0x97,0xe3]
 @ CHECK: b       #-420                   @ encoding: [0x2e,0xe7]
+@ CHECK: beq     #336                    @ encoding: [0xa8,0xd0]
+@ CHECK: beq     #160                    @ encoding: [0x50,0xd0]
 
 @------------------------------------------------------------------------------
 @ BL/BLX