summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2011-08-30 22:03:20 +0000
committerOwen Anderson <resistor@mac.com>2011-08-30 22:03:20 +0000
commit543c89fb15b6846731cadca904cffe411c19196a (patch)
treef0dc794694f73c90fbeb3e698ec94a1aec0aa3bc
parent1732c2ebf665a541ce277518749021538752c452 (diff)
downloadbcm5719-llvm-543c89fb15b6846731cadca904cffe411c19196a.tar.gz
bcm5719-llvm-543c89fb15b6846731cadca904cffe411c19196a.zip
Fix encoding of Thumb1 B instructions with immediate offsets, which is necessary for round-tripping.
llvm-svn: 138834
-rw-r--r--llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp5
-rw-r--r--llvm/test/MC/ARM/basic-thumb-instructions.s5
2 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp
index a800b369bc2..b798a3c226d 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp
@@ -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.
diff --git a/llvm/test/MC/ARM/basic-thumb-instructions.s b/llvm/test/MC/ARM/basic-thumb-instructions.s
index d44ffeb7b7c..0e9eebdb110 100644
--- a/llvm/test/MC/ARM/basic-thumb-instructions.s
+++ b/llvm/test/MC/ARM/basic-thumb-instructions.s
@@ -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
OpenPOWER on IntegriCloud