From 721cb1fde07423fd1905338d443172a8028ad634 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Wed, 31 Aug 2011 20:26:14 +0000 Subject: [PATCH] Fix encoding for tBcc with immediate offset operand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138889 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp | 6 +++++- test/MC/ARM/basic-thumb-instructions.s | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp b/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp index f6b8af87b54..69ec197af51 100644 --- a/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp +++ b/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp @@ -522,7 +522,11 @@ getThumbBRTargetOpValue(const MCInst &MI, unsigned OpIdx, uint32_t ARMMCCodeEmitter:: getThumbBCCTargetOpValue(const MCInst &MI, unsigned OpIdx, SmallVectorImpl &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. diff --git a/test/MC/ARM/basic-thumb-instructions.s b/test/MC/ARM/basic-thumb-instructions.s index cd4471e884c..0fa52b09874 100644 --- a/test/MC/ARM/basic-thumb-instructions.s +++ b/test/MC/ARM/basic-thumb-instructions.s @@ -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 -- 2.34.1