[llvm-commits] [llvm] r145885 - in /llvm/trunk: lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp test/MC/MachO/relax-thumb2-branches.s
Jim Grosbach
grosbach at apple.com
Mon Dec 5 17:08:19 PST 2011
Author: grosbach
Date: Mon Dec 5 19:08:19 2011
New Revision: 145885
URL: http://llvm.org/viewvc/llvm-project?rev=145885&view=rev
Log:
Fix ARM handling of tBcc branch relaxation.
rdar://10069056
Added:
llvm/trunk/test/MC/MachO/relax-thumb2-branches.s
Modified:
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp?rev=145885&r1=145884&r2=145885&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp Mon Dec 5 19:08:19 2011
@@ -146,11 +146,13 @@
uint64_t Value,
const MCInstFragment *DF,
const MCAsmLayout &Layout) const {
- // FIXME: This isn't correct for ARM. Just moving the "generic" logic
- // into the targets for now.
+ // Relaxing tBcc to t2Bcc. tBcc has a signed 9-bit displacement with the
+ // low bit being an implied zero. There's an implied +4 offset for the
+ // branch, so we adjust the other way here to determine what's
+ // encodable.
//
// Relax if the value is too big for a (signed) i8.
- return int64_t(Value) != int64_t(int8_t(Value));
+ return int64_t((Value - 4)>>1) != int64_t(int8_t((Value - 4)>>1));
}
void ARMAsmBackend::RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
Added: llvm/trunk/test/MC/MachO/relax-thumb2-branches.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/relax-thumb2-branches.s?rev=145885&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/relax-thumb2-branches.s (added)
+++ llvm/trunk/test/MC/MachO/relax-thumb2-branches.s Mon Dec 5 19:08:19 2011
@@ -0,0 +1,14 @@
+@ RUN: llvm-mc -triple=thumbv7-apple-darwin -show-encoding %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s
+
+ ble Lfoo @ wide encoding
+
+ .space 258
+Lfoo:
+ nop
+
+ ble Lbaz @ narrow encoding
+ .space 256
+Lbaz:
+
+@ CHECK: '_section_data', '40f38180
+@ CHECK: 000000bf 7fdd
More information about the llvm-commits
mailing list