On 2010-09-07, at 10:58 AM, chevalma@iro.umontreal.ca wrote:
I'm not necessarily suggesting we use the call and ret instructions. I simply believe that on an 8 register machine, we want to keep as many registers available as we can. If we reserve 3, 4 or even 5 of them, it seems to me like that would almost guarantee that spills occur in any non-trivial function, thereby defeating the goal of avoiding memory operations. Since the return address is only used once at the end of a function call, it seems like a logical candidate to spill.
On another note... So far, we've been discussing going caller-save, ~2 argument registers for function calls. Perhaps we ought to consider a different model, where we pass the return address as a hidden argument in a register, and as many call arguments in registers as we can manage... And let the callee spill the return address and arguments if necessary. The return address probably shouldn't be a reserved, never spilled register, and if we can get away with passing 4-6 arguments in registers (especially on x86-64), that could be effective.
That's what I was assuming all along! We definitely don't want to reserve a register for the return address for the duration of the called function. Even the context register can be spilled if we are clever about it (but in our first prototype we should probably reserve a register for the context register and argument count).
Marc