Re: Return value address (Kamal R. Prasad)
21 Sep 2004 22:18:28 -0400

          From comp.compilers

Related articles
Return value address (2004-09-07)
Re: Return value address (Christoph Neubauer) (2004-09-08)
Re: Return value address (2004-09-13)
Re: Return value address (2004-09-14)
Re: Return value address (Christoph Neubauer) (2004-09-21)
Re: Return value address (2004-09-21)
| List of all articles for this month |

From: (Kamal R. Prasad)
Newsgroups: comp.compilers
Date: 21 Sep 2004 22:18:28 -0400
References: 04-09-054 04-09-069 04-09-100
Keywords: code
Posted-Date: 21 Sep 2004 22:18:28 EDT (Nicola Musatti) wrote in message news:04-09-100...
> "Christoph Neubauer" <> wrote
> > What about a stack model, that allocates:
> >
> > r allways at 0
> > arguments starting at 4
> > local variables afterwards
> > temp variables afterwards
> In my ignorance I thought that just about every compiler worked in
> this way, except maybe when return value and arguments are directly
> allocated into registers. Are there reasons to do otherwise?

If you can use registers instead of a stack, that speeds up things.
MIPS (and PowerPC) has 4 registers for arguments (and the rest go on
stack). The argument registers are not used for any other purpose
[i.e. save them before calling another procedure]. When a procedure is
called, it saves the registers it wants to use onto stack and then
uses it -and that way, you have the speed of registers and don't end
up creating copies of unused registers.

> > [It also seemed to me that the obvious solution is for the caller to
> > allocate the return value cell. -John]

Yes -the caller creates space for the return value and writes a return
address onto stack, and the callee writes the return value and does a
jmp to the specified return address.

> Wouldn't this also give the opportunity to optimize it away, e.g. by
> directly using the variable to which the function result is assigned?

Not sure I understand. Could you also clarify whether the compiler is
going to generate binary machine code or something else?


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.