lightning
[Top][All Lists]
Advanced

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

Re: [Lightning] Feature Request: Allow patching of st(x)i and ld(x)i


From: Paulo César Pereira de Andrade
Subject: Re: [Lightning] Feature Request: Allow patching of st(x)i and ld(x)i
Date: Tue, 3 Sep 2019 14:01:32 -0300

Em ter, 3 de set de 2019 às 12:32, Marc Nieper-Wißkirchen
<address@hidden> escreveu:

 Hi Marc,

> > > >   Patches for ldi* and sti* are mostly pointless, because it would mean 
> > > > the
> > > > address is not known while generating jit, but before calling 
> > > > jit_emit().
> > >
> > > This is exactly the case here. My code generator, which calls GNU
> > > lightning, handles literals (of the source language) by storing their
> > > addresses in a table, which is malloc'd. The size of the table is not
> > > known until all code has been generated (that is, just before the call
> > > to jit_emit). Therefore, the table cannot be malloc'd before and its
> > > absolute address is not known before. However, needs to reference
> > > entries in the table, so I have to patch it when the table has been
> > > malloc'd.
> > >
> > > Currently, I do something like:
> > >
> > > lbl = jit_movi (JIT_R0, 0);
> > > jit_ldr (JIT_R1, JIT_R0);
> > > ...
> > > jit_patch_abs (lbl, table_pointer + offset);
> > > jit_emit ();
> > >
> > > What I want to do is:
> > >
> > > lbl = jit_ldi (JIT_R1, 0);
> > > ...
> > > jit_patch_abs (lbl, table_pointer + offset);
> > > jit_emit ();
> >
> >   Ok. This is a trivial patch. Still untested, but very unlikely to
> > have issues. Please give some feedback on the attached patch.
>
> I have tried the patch and it works here (x86_64).

  Ok. I will commit it. The patch is good to have as it allows semantic
use the same way as patching movi.
  Note that it will still internally become a movi(..), ldr(...) pair on
 a very large amount of inputs.
  For x86_64 it will be a direct load from memory only if the address can
be 32 bit signed extended to a 64 bit address.
  For several other ports the value will be far smaller, for example, could
need to be the first 16k bytes or similar value.
  Usually the best approach would be to have a base register, and then use
ldxi with a constant offset. But that could mean keeping a register
exclusively for the base pointer of global the data.

> Thanks a lot!
>
> Marc

Thanks,
Paulo



reply via email to

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