[Top][All Lists]

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

Re: [Lightning] setarg

From: Ludovic Courtès
Subject: Re: [Lightning] setarg
Date: Wed, 07 Feb 2007 09:21:36 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)


Christoph Bäni <address@hidden> writes:

> in almost any programming language, you're able to write to
> the parameters of a function (although it's not their primary
> purpose).
> a simple example would be:
> void n_times(int n) {
>       while (n-- > 0) {
>               printf("hello world\n");
>       }
> }
> in this example, the parameter is written (by the "--" decrement in
> the head of the wile loop).
> so i can't understand, why there is no jit_setarg() in ligntning as
> it would be needed to compiler such functions!

I believe it cannot easily be done without breaking architecture- and
ABI-independence (and I wonder whether it's really useful ;-)).
Currently, one already has to use `jit_getarg' in order to work with
function arguments (this abstraction is needed because parameter passing
is architecture- and ABI-specific).  So I guess that for the same reason
we have `jit_getarg', we can't have `jit_setarg' that modifies arguments
"in place".

That said, you can very much do something like:

  jit_getarg_i (JIT_R0, my_arg);
  jit_movi_i (JIT_R0, 777);

which is effectively quite similar to:

  my_func (int my_arg)
    my_arg = 777;


reply via email to

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