[PATCH] D15442: Fix for pr24346: arm asm label calculation error in sub

Ting-Yuan Huang via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 10 23:52:25 PST 2015


laszio created this revision.
laszio added a reviewer: llvm-commits.
laszio added a subscriber: llvm-commits.
Herald added subscribers: rengolin, aemerson.

Some ARM instructions encode 32-bit immediates as a 8-bit integer (0-255)
and a 4-bit rotation (0-30, even) in its least significant 12 bits. The
original fixup, FK_Data_4, patches the instruction by the value bit-to-bit,
regardless of the encoding. For example, assuming the label L1 and L2 are
0x0 and 0x104 respectively, the following instruction:

add r0, r0, #(L2 - L1) ; expects 0x104, i.e., 260

would be assembled to the following, which adds 1 to r0, instead of 260:

e2800104  add r0, r0, #4, 2 ; equivalently 1

The new fixup kind fixup_arm_mod_imm takes care of the encoding:

e2800f41  add r0, r0, #260


http://reviews.llvm.org/D15442

Files:
  lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  lib/Target/ARM/MCTargetDesc/ARMFixupKinds.h
  lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp
  test/MC/ARM/arm_fixups.s
  test/MC/ARM/modified-immediate-fixup-error.s
  test/MC/ARM/modified-immediate-fixup.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15442.42503.patch
Type: text/x-patch
Size: 4636 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151211/e21291b1/attachment-0001.bin>


More information about the llvm-commits mailing list