Code for RTL register eliminations.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
Contributed by Vladimir Makarov <vmakarov@redhat.com>.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>.
Eliminable registers (like a soft argument or frame pointer) are
widely used in RTL. These eliminable registers should be replaced
by real hard registers (like the stack pointer or hard frame
pointer) plus some offset. The offsets usually change whenever the
stack is expanded. We know the final offsets only at the very end
of LRA.
Within LRA, we usually keep the RTL in such a state that the
eliminable registers can be replaced by just the corresponding hard
register (without any offset). To achieve this we should add the
initial elimination offset at the beginning of LRA and update the
offsets whenever the stack is expanded. We need to do this before
every constraint pass because the choice of offset often affects
whether a particular address or memory constraint is satisfied.
We keep RTL code at most time in such state that the virtual
registers can be changed by just the corresponding hard registers
(with zero offsets) and we have the right RTL code. To achieve this
we should add initial offset at the beginning of LRA work and update
offsets after each stack expanding. But actually we update virtual
registers to the same virtual registers + corresponding offsets
before every constraint pass because it affects constraint
satisfaction (e.g. an address displacement became too big for some
target).
The final change of eliminable registers to the corresponding hard
registers are done at the very end of LRA when there were no change
in offsets anymore:
fp + 42 => sp + 42
This structure is used to record information about hard register
eliminations.