lightning
[Top][All Lists]
Advanced

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

Re: [Lightning] Bytecode compiler


From: Paulo César Pereira de Andrade
Subject: Re: [Lightning] Bytecode compiler
Date: Wed, 29 Dec 2010 23:04:20 -0200

Em 29 de dezembro de 2010 14:08, Paolo Bonzini <address@hidden> escreveu:
>>>> o Left to right argument evaluation; when passing arguments
>>>>   in registers, right to left just make things harder than they
>>>>   should be and also unnatural
>>>
>>> This is fine.  Just allocate all space in jit_prepare and replace push with
>>> mov.
>>
>>  I started adding requirement for a "jit_putarg_x extension"
>> requirement in lightning, but I think it may not be the proper
>> approach, instead, it should build stack frames, and understand
>> the abi without using jit_arg_x and jit_getarg_x.
>>
>> This is because it really needs to know what arguments were
>> passed in registers so that it can spill them when making a
>> function call.

  I made an initial commit (22948d5) to attempt to start adding the
proper infrastructure to add function calls to the "cjit sample".
Disclaimer: the "cjit sample" is just a self learning tool, the goal
is to have an "intermediate representation" that can be used by
my other "hobby" project, that is a C/C++ like syntax, but
dynamically typed, garbage collected, language.

> Existing backends copy incoming arguments to callee-save registers.
> You can do the same.  You don't need putarg, existing opcodes are
> enough.

  The putarg idea was an attempt to make something as little intrusive
as possible, while the new code is somewhat intrusive and need to
know too much about the abi... in the new code it would now be required
something like:

o jit_movr_i_f, jit_movr_l_d, jit_movr_f_i and jit_movr_l_d or similarly
named interfaces, that would be used to move from/to grp/fpr registers.
But currently it is only really required by the mips abi. Also, in the
mips abi it could have special semantics, e.g. jit_movr_l_d would be
"_MTC1(r0, f0); _MTC1(r0+1, f0+1);" and jit_movr_d_l would be
"_MFC1(r0, f0); _MFC1(r0+1, f0+1);"

o jit_leave, that would be a minimal instruction, and map to "ret" in
  x86{,_64} and "jr $ra" in mips.

  Moving arguments to callee save registers probably would be a
better idea for variables explicitly declared as register, including
arguments, but some analysis could be done (currently basically
only count number of references) to choose the better use for
register variables.

> Paolo

Paulo



reply via email to

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