lightning
[Top][All Lists]
Advanced

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

Re: [PATCH] Add bswapr_us, bswapr_ui, and bswapr_ul API functions


From: Paulo César Pereira de Andrade
Subject: Re: [PATCH] Add bswapr_us, bswapr_ui, and bswapr_ul API functions
Date: Thu, 26 May 2022 12:21:24 -0300

Em qui., 26 de mai. de 2022 às 12:02, Paul Cercueil
<paul@crapouillou.net> escreveu:
>
> Hi Paulo,

  Hi Paul,

> Thanks for merging this.
>
> One thing I would like to add, is support for the "load/store with
> byte-inverted" opcode on PowerPC.
> Basically these patterns:
>
> ldxr_ui r0, r1, r2
> bswapr_ui r0, r0
>
> ldxr_us r0, r1, r2
> bswapr_us r0, r0
>
> bswapr_ui r2, r2
> stxr_i r0, r1, r2
>
> bswapr_us r2, r2
> stxr_s r0, r1, r2
>
> could be optimized using the lwbrx, lhbrx sthbrx and stwbrx opcodes
> respectively. The _i and _s variants, as well as immediate variants
> (ldxi, stxi) would also be optimized.
>
> I'm not really sure how to implement this. It would be a
> target-specific optimization, and Lightning doesn't really seem to
> support target-specific optimization passes right now.
>
> I believe I would need to call a simplify_ldxr_bswap() function in
> _simplify(), that's only implemented on PowerPC, which would set a
> custom code on the first instruction and remove (or NOP?) the following
> instructions?
>
> Thoughts?

  The proper place probably would be in jit_realize():

...
    jit_optimize();
   << add  preprocessor and call to target code, implemented in jit_$(arch).c
       or a new jit_$(arch)-opt.c or similar name >>>
    _jitc->realize = 1;
...

  This could be some standardized way, otherwise, just do a single pass
at start of _emit_code. Need some control variable to avoid multiple
passes, as _emit_code might be called more than once, if the figures
the buffer will be too small during code generation.

> Cheers,
> -Paul

Thanks!
Paulo



reply via email to

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