lightning
[Top][All Lists]
Advanced

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

Re: Patching jit_movi


From: Paulo César Pereira de Andrade
Subject: Re: Patching jit_movi
Date: Thu, 1 Dec 2022 14:54:58 -0300

Em qui., 1 de dez. de 2022 às 11:45, Marc Nieper-Wißkirchen
<marc.nieper+gnu@gmail.com> escreveu:

  Hi Marc,

> Currently,  the constant in jit_movi is ignored when we patch it with a label.

  Branches do not even receive an argument, as it must be patched.
This is because branches not patched are so uncommon it is not a
reason to force all others to have an ignored argument.

  For jit_movi it is a special pattern. Internally there is a mix of movi and
movi_p, where the '_p' suffix means the value is not used..

> Could we change this so that the constant is retained as an additive offset?
>
> My code currently looks like
>
> jit_patch_at (jit_movi (JIT_R0, 0), node);
> jit_addi (JIT_R0, JIT_R0, tag);

  Not certain if I understand the usage. But probably it can be done
with some other construct.

  Please provide a more complete example usage.

  Is it creating a jump target?

> It would be preferable if I could write:
>
> jit_patch_at  (jit_movi (JIT_R0, tag));

  If the current point in jit generation is the equivalent of tag as
a label, you can write:

jit_patch(jit_movi(JIT_R0, 0));

what will cause it to move to JIT_R0 the instruction pointer just after
the movi. For example, mimic'ing with check/lightning:

.disasm
.code
    movi %r0 implicit_label
implicit_label:
    addi %r0 %r0 1

and with --enable-devel-disassembler output:

    movi %rax 0x1fc5650
    0x7f412f201000    movabs $0x7f412f201010,%rax
L0: %rax
    0x7f412f20100a    nopw   0x0(%rax,%rax,1)
    #note x.tst:4
    addi %rax %rax 0x1
# :x.tst:4
    0x7f412f201010    add    $0x1,%rax

  Note that for check/lightning I did need to explicitly add the
'implicit_label' but in C code it is not required.

> Thanks,
>
> Marc

Thanks!
Paulo



reply via email to

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