[PATCH] D46305: [MC][ARM] Correct Thumb BL instruction range

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 1 04:17:56 PDT 2018


peter.smith created this revision.
peter.smith added reviewers: olista01, fhahn, t.p.northover, rengolin.
Herald added a reviewer: javed.absar.
Herald added subscribers: chrib, kristof.beyls.

The Thumb BL range is +- either 16 Megabytes or 4 Megabytes depending on whether the CPU supports Thumb2 or the v8-m baseline ops. The existing check for BL range is incorrectly set at +- 32 Megabytes. This change corrects the higher range and uses the lower range if the featurebits don't have the necessary support for it.

The ranges for the branch instructions can be found in https://developer.arm.com/docs/ddi0406/c/arm-architecture-reference-manual-armv7-a-and-armv7-r-edition
For version C (latest) the higher range can be found in A4.3 Branch instructions
For the shorter range search for "BL and BLX (immediate) instructions, before ARMv6T2", this also applies to ARMv6M.

I note that there isn't a range check for BLX, but as far as I can tell, the shouldForceRelocation() always generates an external relocation for this case.
There are also no range checks for B.W and Bcc.W, I have a follow up patch that adds checks for these that I'll post shortly.


https://reviews.llvm.org/D46305

Files:
  lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  test/MC/ARM/thumb-branches.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46305.144689.patch
Type: text/x-patch
Size: 3500 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180501/cd49807b/attachment.bin>


More information about the llvm-commits mailing list