This is the mail archive of the
mailing list for the GCC project.
Re: question about registers that are set on entry to a function.
- From: Kenneth Zadeck <zadeck at naturalbridge dot com>
- To: Ian Lance Taylor <ian at airs dot com>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, GCC <gcc at gcc dot gnu dot org>, "Berlin, Daniel" <dberlin at dberlin dot org>
- Date: Thu, 05 Jan 2006 16:17:08 -0500
- Subject: Re: question about registers that are set on entry to a function.
- References: <43BD70E7.email@example.com> <firstname.lastname@example.org>
Ian Lance Taylor wrote:
Kenneth Zadeck <email@example.com> writes:You do not have to sugar coat it, I can handle the truth.
1) Do you believe that this code could be correct?
This all seems doable. I can spin a better version of this.
2) Most of the paragraphs are protected by either reload_completed or
epilogue_completed (which has a comment at the its point of
declaration that it is true for both the prologue and epilogue). Is
it true that after these epochs, that there will really be code in the
first basic block that will def these registers? I.e. are any of them
implicitly set before the function is called so I will not find a def?
This isn't quite accurate. When the RTL is initially generated, for
any values passed in parameters you will see at the start of the
(set (pseudo-reg) (param-reg))
That is, parameter handling is independent of the prologue/epilogue
code, and thus independent of epilogue_completed. If you want to
declare that all FUNCTION_ARG_REGNO_P registers are live, you should
do that regardless of epilogue_completed.
Actually FUNCTION_ARG_REGNO_P is not enough. It returns true for
outgoing function registers. On a target with register windows, at
the start of the function you need to apply INCOMING_REGNO to each
register for which FUNCTION_ARG_REGNO_P returns true.
The prologue code which is set up when epilogue_completed is true is
code which sets up the stack frame and saves the callee saved
registers on the stack. So when epilogue_completed is true, then at
the start of the function you will probably want to treat as live
every callee saved register for which regs_ever_live is true. For
some targets the frame pointer will be live on function entry, for
others it is initialized by the prologue if necessary.
Assuming that PIC_OFFSET_TABLE_REGNUM is defined isn't always going to
be correct, although it may not matter. On some targets, e.g., i386,
the register will be defined by the prologue code anyhow.
Is the right thing to do to define a target hook for this that defaults
to doing nothing and we only define it in those places where necessary
or should I add a few other macros to the ports as necessary and just
check to see if they are defined? I have noticed that there are several
macros that are only used on a single port.
3) Am I missing any classes of registers?
For complete accuracy, there are probably going to be some target
specific registers which need to be handled, unfortunately. For
example, on MIPS, with -mabicalls (which is the default on GNU/Linux),
$25 is live on function entry. It holds the address of the function,
and is used to initialize $28, which is PIC_OFFSET_TABLE_REGNUM. I
don't think there is any target independent way of getting at that
I will look into this also.
It is also worth noting that rather than assuming that all
FUNCTION_ARG_REGNO_P registers are live, you could use
FUNCTION_ARG/FUNCTION_ARG_ADVANCE to walk through the parameters and
determine precisely which ones are live. I don't know whether that
will make a significant difference for the rest of the code, though.