]> git.ipfire.org Git - thirdparty/gcc.git/commit
emit-rtl, lra: Move lra's emit_inc to emit-rtl.cc
authorAlex Coplan <alex.coplan@arm.com>
Fri, 15 Dec 2023 09:31:28 +0000 (09:31 +0000)
committerAlex Coplan <alex.coplan@arm.com>
Fri, 15 Dec 2023 09:35:45 +0000 (09:35 +0000)
commitbac33a522bb51e30729191e935f25c2b0a63e225
treec24f0468433e99b13bf8278159abd25bd1d982d8
parent91e9e8faea4086b3b8aef2355fc12c1559d425f6
emit-rtl, lra: Move lra's emit_inc to emit-rtl.cc

In PR112906 we ICE because we try to use force_reg to reload an
auto-increment address, but force_reg can't do this.

With the aim of fixing the PR by supporting reloading arbitrary
addresses in pre-RA splitters, this patch generalizes
lra-constraints.cc:emit_inc and makes it available to the rest of the
compiler by moving the generalized version to emit-rtl.cc.

We observe that the separate IN parameter to LRA's emit_inc is
redundant, since the function is static and is only (statically) called
once in lra-constraints.cc, with in == value.  As such, we drop the IN
parameter and simplify the code accordingly.

We wrap the emit_inc code in a virtual class to allow LRA to override
how reload pseudos are created, thereby preserving the existing LRA
behaviour as much as possible.

We then add a second (higher-level) routine to emit-rtl.cc,
force_reload_address, which can reload arbitrary addresses.  This uses
the generalized emit_inc code to handle the RTX_AUTOINC case.  The
second patch in this series uses force_reload_address to fix PR112906.

Since we intend to call address_reload_context::emit_autoinc from within
splitters, and the code lifted from LRA calls recog, we have to avoid
clobbering recog_data.  We do this by introducing a new RAII class for
saving/restoring recog_data on the stack.

gcc/ChangeLog:

PR target/112906
* emit-rtl.cc (address_reload_context::emit_autoinc): New.
(force_reload_address): New.
* emit-rtl.h (struct address_reload_context): Declare.
(force_reload_address): Declare.
* lra-constraints.cc (class lra_autoinc_reload_context): New.
(emit_inc): Drop IN parameter, invoke
code moved to emit-rtl.cc:address_reload_context::emit_autoinc.
(curr_insn_transform): Drop redundant IN parameter in call to
emit_inc.
* recog.h (class recog_data_saver): New.
gcc/emit-rtl.cc
gcc/emit-rtl.h
gcc/lra-constraints.cc
gcc/recog.h