This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Dynamic FUNCTION_OUTGOING_VALUE?


On Thu, 2003-09-18 at 04:05, Alexandre Courbot wrote:
> i.e. the result of a function is directly put into the destination operand. So 
> it is not a fixed place, and being obliged to use a fixed place with GCC I 
> get suboptimal code.

Function return is a two part process.  There is the place where the
callee stores it at the end of the function.  And there is the place
where the caller looks for it after the function call.

Since these are two different functions, the only way the communication
can work is if you use a fixed register, or if you pass the address of a
stack slot from the caller to the callee.  Storing a return value into a
stack slot is less efficient than using a register in most cases, so a
fixed register is usually the best approach.

Using a pseudo on the other hand makes no sense.  The callee will store
into a pseudo at the end of the function, and the optimizer will delete
it as unused.  The caller will look for a value in a different pseudo,
but nothing will be there, because there is no way for the callee to
store into a pseudo in the caller.

If your target perhaps has a way to take the address of a register, and
pass it to a callee to use for the return value, then it could make
sense to use any register for the return value.  This would be a novel
concept for gcc, and code would have to be written to support it.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]