]> git.ipfire.org Git - thirdparty/gcc.git/commit
arm: cleanup code in ldm_stm_operation_p; relax limits on ldm/stm
authorRichard Earnshaw <rearnsha@arm.com>
Thu, 19 Dec 2024 15:32:36 +0000 (15:32 +0000)
committerRichard Earnshaw <rearnsha@arm.com>
Wed, 5 Feb 2025 11:50:18 +0000 (11:50 +0000)
commitaead1d44b7df50c77ff63482f5548f237ff29033
treeb800a51ef673416d816882162f057c6b708ddf51
parentda88e7027a34a44de84f6d8d5a96d262c29080a7
arm: cleanup code in ldm_stm_operation_p; relax limits on ldm/stm

I needed to make some adjustments to this function to permit a push or
pop of a single register in thumb2 code, since ldm/stm can be a
two-byte instruction instead of 4.  Trying to read the code as it was
made me scratch my head as the logic was not very clear.  So this
patch cleans up the code somewhat, fixes a couple of minor bugs and
removes the limit of having to use multiple registers when using this
form of the instruction (the shape of this pattern is such that I
can't see it being generated automatically by the compiler, so there
should be no adverse affects of this).

Buglets fixed:
  - Validate that the first element contains RETURN if we're matching
    a return instruction.
  - Don't allow the base address register to be stored if saving regs
    and the address is being updated (this is unpredictable in the
    architecture).
  - Verify that the last register loaded in a RETURN insn is the PC.

gcc/
* config/arm/arm.cc (decompose_addr_for_ldm_stm): New function.
(ldm_stm_operation_p): Rework to clarify logic.  Allow single
registers to be pushed or popped using LDM/STM.
gcc/config/arm/arm.cc