diff options
| author | Owen Anderson <resistor@mac.com> | 2011-08-30 22:15:17 +0000 |
|---|---|---|
| committer | Owen Anderson <resistor@mac.com> | 2011-08-30 22:15:17 +0000 |
| commit | fdf3cd7f2bb8f86f7f445ae5d741d430480f0640 (patch) | |
| tree | 6064f35dbd072e4f5198727e0efd794ad9105dfd | |
| parent | 58298f028c942a2c181e0b801c98fac867656316 (diff) | |
| download | bcm5719-llvm-fdf3cd7f2bb8f86f7f445ae5d741d430480f0640.tar.gz bcm5719-llvm-fdf3cd7f2bb8f86f7f445ae5d741d430480f0640.zip | |
Fix encoding of CBZ/CBNZ Thumb2 instructions with immediate offsets rather than labels.
llvm-svn: 138837
| -rw-r--r-- | llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp | 5 | ||||
| -rw-r--r-- | llvm/test/MC/ARM/basic-thumb2-instructions.s | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp index ab2162cbebb..7cac54c610b 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp @@ -501,7 +501,10 @@ getThumbBCCTargetOpValue(const MCInst &MI, unsigned OpIdx, uint32_t ARMMCCodeEmitter:: getThumbCBTargetOpValue(const MCInst &MI, unsigned OpIdx, SmallVectorImpl<MCFixup> &Fixups) const { - return ::getBranchTargetOpValue(MI, OpIdx, ARM::fixup_arm_thumb_cb, Fixups); + const MCOperand MO = MI.getOperand(OpIdx); + if (MO.isExpr()) + return ::getBranchTargetOpValue(MI, OpIdx, ARM::fixup_arm_thumb_cb, Fixups); + return (MO.getImm() >> 1); } /// Return true if this branch has a non-always predication diff --git a/llvm/test/MC/ARM/basic-thumb2-instructions.s b/llvm/test/MC/ARM/basic-thumb2-instructions.s index 423e5bc3166..61d651472ee 100644 --- a/llvm/test/MC/ARM/basic-thumb2-instructions.s +++ b/llvm/test/MC/ARM/basic-thumb2-instructions.s @@ -38,6 +38,15 @@ _func: @ CHECK: adc r4, r2, #1664 @ encoding: [0x42,0xf5,0xd0,0x64] @------------------------------------------------------------------------------ +@ CBZ/CBNZ +@------------------------------------------------------------------------------ + cbnz r7, #6 + cbnz r7, #12 + +@ CHECK: cbnz r7, #6 @ encoding: [0x1f,0xb9] +@ CHECK: cbnz r7, #12 @ encoding: [0x37,0xb9] + +@------------------------------------------------------------------------------ @ IT @------------------------------------------------------------------------------ @ Test encodings of a few full IT blocks, not just the IT instruction |

