Fix encoding of PC-relative Thumb1 LDR's when using immediate offsets instead of labels.

llvm-svn: 138835
This commit is contained in:
Owen Anderson 2011-08-30 22:10:03 +00:00
parent 543c89fb15
commit d16fb43b1f
2 changed files with 8 additions and 2 deletions

View File

@ -930,7 +930,10 @@ getAddrModeISOpValue(const MCInst &MI, unsigned OpIdx,
uint32_t ARMMCCodeEmitter::
getAddrModePCOpValue(const MCInst &MI, unsigned OpIdx,
SmallVectorImpl<MCFixup> &Fixups) const {
return ::getBranchTargetOpValue(MI, OpIdx, ARM::fixup_arm_thumb_cp, Fixups);
const MCOperand MO = MI.getOperand(OpIdx);
if (MO.isExpr())
return ::getBranchTargetOpValue(MI, OpIdx, ARM::fixup_arm_thumb_cp, Fixups);
return (MO.getImm() >> 2);
}
/// getAddrMode5OpValue - Return encoding info for 'reg +/- imm10' operand.

View File

@ -224,10 +224,13 @@ _func:
@ LDR (literal)
@------------------------------------------------------------------------------
ldr r1, _foo
ldr r3, #604
ldr r3, #368
@ CHECK: ldr r1, _foo @ encoding: [A,0x49]
@ fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_cp
@ CHECK: ldr r3, #604 @ encoding: [0x97,0x4b]
@ CHECK: ldr r3, #368 @ encoding: [0x5c,0x4b]
@------------------------------------------------------------------------------
@ LDR (register)