On Mon, 18 Jan 2010 13:55:16 -0500, Jean Christophe Beyler wrote: >I have a current issue on my port. Basically the stack is defined as follows : > >1) CALL_USED save area >2) Local variables >3) Caller arguments passed on the stack >4) 8 words to save arguments passed in registers, even if not passed > >Now, this was done because we have defined 8 output registers, >therefore zone (3) is not used except if we call a function with more >than 8 parameters. > >(4) is only used if we have va_arg functions that will then spill the >8 input registers on the stack and call the va_arg function. > >This is done, to my understanding for our ABI, because, in the case of >a va_arg function, we want the parameters consecutively store in >memory.
That's indeed a desirable property. >However, this brings me to 2 problems : > >1) If there are no va_arg function calls, there still is 8 words >wasted on the stack per function call still active on the stack. > >2) If there is an alloca, then GCC moves the stack pointer but without >trying to get back those 8 words or even the space for (3). > > >I am currently working on not having that wasted space. I see two options: > >1) Change the ABI to go closer to what I have seen in the MIPS port : > - The zone (4) is handled by the callee > - However, I'll still have the wasted space (4) when an alloca is used no ? Actually, zone (4) should just be deleted entirely from the ABI. That is, all the ABI should specify is that non-register arguments are in the caller's frame starting exactly at the stack pointer. For non-varargs calls, there's no waste. For varargs calls, the callee can allocate its frame and save the incoming register arguments at the top of its own frame, establishing the all-arguments-are-stored-consecutively property without burdening the caller or the ABI. An alloca() in the callee should just adjust the stack pointer and ignore the register arguments save area at the top of the frame. /Mikael