lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Lightning] Order of function arguments on mips


From: Paulo César Pereira de Andrade
Subject: Re: [Lightning] Order of function arguments on mips
Date: Wed, 20 Oct 2010 19:11:48 -0200

Em 20 de outubro de 2010 16:09, Paolo Bonzini <address@hidden> escreveu:
> On 10/20/2010 09:35 AM, Paulo César Pereira de Andrade wrote:
>>
>> Em 20 de outubro de 2010 04:32, Paolo Bonzini<address@hidden>  escreveu:
>>>
>>> On 10/20/2010 02:32 AM, Paulo César Pereira de Andrade wrote:
>>>>
>>>>   What you suggest to avoid minimal problems with lightning?
>>>>
>>>> _jit_prepare("dfii")
>>>> to be understood as:
>>>> <unkown_return_type>    function(double, float, int, int);
>>>
>>> While it is a bit long, maybe
>>>
>>>  jit_prepare_d(1);
>>>  jit_prepare_f(1);
>>>  jit_prepare_i(2);
>>>
>>> would "just work"?
>>
>>   If there are no jit_pusharg calls in between, it could be an
>> option.
>
> Yes, however you need space in _jit to store the offsets, because these are
> computed from the first argument while the arguments are pushed starting
> from the last.
>
> Suppose you have
>
>       prepare_p 1
>       prepare_d 1
>       prepare_i 1
>       prepare_d 1
>       prepare_i 1
>
> At this point you know that the space on the stack will be 40 bytes, and the
> "next offset" is 36.
>
> Then...
>
>>     prepare 3
>>     prepare_d 2
>>         movi_i %r0 4
>
> ... this decrements the next offset by 4, and places "4" at $sp[32-35].
>
>>         pusharg_i %r0
>>         movi_d %f0 3.0
>>         pusharg_d %f0
>
> ... this decrements the next offset by 8, places "3.0" and $sp[24].
>
>>        movi_i %r0 2
>>        pusharg_i %r0
>
> Now there's no way (without storing all the offsets) to know if the next
> argument should be at 20-23 or 16-19.
>
> With the full list of arguments stored in _jit, it can work.  I prefer this
> to your proposal (a string like "pdidi"), because anyway the offsets have to
> be computed (you cannot just use the format stirng in pusharg_x).  The
> format string can be implemented in your assembler or in general at a higher
> layer than lightning.

  I also did not like much the idea of a string, but it is not that
bad of an idea,
and would require minimal changes to existing code, but that is a big barrier,
at least not as big as telling everybody that now arguments are pushed from
left to right (what is possible/easy/trivial on x86 with my alternate logic
to build stack frames) :-)

  What I "just" did was to limit to 256 arguments (could be 8192 words but
use less space and use an statically allocated buffer). This way, it has a
pointer to the instruction just before "doing something" to push the argument.
It is not pretty, but it works with some basic tests with mixed int/double
arguments and calls to printf; still need to check floats mixed with doubles.

  This should be an issue only for mips32 (I need to get a system running
in 64 bits mode to make sure tough).

> Paolo

Paulo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]