At 08:43 AM 10/29/2001 -0500, Gregor N. Purdy wrote:
>Dan --
>
>On Fri, 2001-10-26 at 16:38, Dan Sugalski wrote:
> > Okay, here are the conventions.
>
>Looks like I'm going to have to write some real logic in jakoc
>pretty soon...

Aaaaahhh! The horror! :-)

Seriously, the conventions are geared towards full-blown compilers with a 
reasonable register ordering module at the very least, which isn't 
unreasonable to expect for a language implementation. (And folks that want 
to fake out using a stack will probably work with the top few registers to 
avoid having to deal with parameter conflicts)

> > *) The callee is responsible for saving and restoring non-scratch registers
>
>Nice for callee since if its work fits into five regs of each type
>its not going to have to do any saves or restores. Caller, though, is
>going to have to vacate those regs. So, if caller got args in those
>regs and then calls anyone else, it has to move them from those regs (or
>save them).

Caller will only have to vacate those registers if they're being used and 
need to last past the call to the function. If the register assignment 
algorithm's clever (which is a big if) the lifetime of temporaries will 
keep function calls in mind.

> > *) The first five registers (I0-I4, S0-S4, P0-P4, N0-N4) are scratch 
> and do
> > not have to be preserved by the callee
>
>Still thinking about this... We are reducing the overall number of reg
>copies going on by adding these special cases. I just wish we had an
>approach that was both uniform (simple, no special cases) and fast too.

You, and me, and about a zillion other people. Generally speaking the 
choices are fast, uniform, and scalable. Choose two.

This is really only an issue for folks writing code generators by hand, and 
with 32 of each register type most people won't hit it. Plain parser 
add-ons will use the core code generator, so they won't need to worry about it.

> > *) The callee is responsible for making sure the stack is cleaned off.
>
>So, in the case of zero args, do we still push a zero on the stack to
>make a proper frame? I think yes...

If the function is listed as taking a variable number of args, yes. 
Functions marked as taking no args at all don't get anything put on the stack.

> >
> > Inbound args
> > ============
> > If the called subroutine has a fixed number of arguments, they will be
> > placed in the first five registers of the appropriate register types. 
> First
> > integer goes in I0, second in I1, and so on.
> >
> > If there are too many arguments of a particular type the overflow go on 
> the
> > stack. If there are a variable number of arguments, all the *non* fixed
> > args go on the stack.
>
>So for right now, just pretend that all Jako subroutines take a variable
>number of args.. :) (Until I get the time to write fully compatible
>conventions in jakoc, anyway).

That's fine. A perfectly workable solution.

>Can we have ops to inquire on the type of the topmost stack entry?

In the works, yep.

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to