[GAS/ARM] Fix expansion of ldr pseudo instruction
authorThomas Preud'homme <thomas.preudhomme@arm.com>
Mon, 24 Apr 2017 13:49:48 +0000 (14:49 +0100)
committerThomas Preud'homme <thomas.preudhomme@arm.com>
Mon, 24 Apr 2017 13:51:24 +0000 (14:51 +0100)
commit534455547021f3262fa60d32cabb626af01692a3
tree56f3cfbe134996bbf893b8b65630b79705313db1
parent8b353c47b70568ab9f0cfd619b7a19e931c2b0c8
[GAS/ARM] Fix expansion of ldr pseudo instruction

The LDR rX, =cst pseudo-instruction suffers from two issues for loading
integer constants in Thumb mode:

- movs is used if the constant and register can be encoded using that
  instruction which leads to unexpected behavior due to its flag-setting
  behavior
- mov.w, movw and mvn are used for r13 (sp) and r15 (pc) but these
  encoding are marked as UNPREDICTABLE

This patch fixes those issues and update testing accordingly.

2017-04-24  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gas/
* config/tc-arm.c (move_or_literal_pool): Remove code generating MOVS.
Forbid MOV.W and MOVW if destination is SP or PC.
* testsuite/gas/arm/thumb2_ldr_immediate_highregs_armv6t2.s: Explain
expectation of LDR not generating a MOVS for low registers and small
constants.  Add tests of MOVW generation.
* testsuite/gas/arm/thumb2_ldr_immediate_highregs_armv6t2.d: Update
expected disassembly.
gas/ChangeLog
gas/config/tc-arm.c
gas/testsuite/gas/arm/thumb2_ldr_immediate_highregs_armv6t2.d
gas/testsuite/gas/arm/thumb2_ldr_immediate_highregs_armv6t2.s