[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Lightning] Register liveness analysis and spilling
From: |
Basile Starynkevitch |
Subject: |
Re: [Lightning] Register liveness analysis and spilling |
Date: |
Sun, 3 Sep 2017 18:52:32 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 09/03/2017 05:18 PM, Marc Nieper-Wißkirchen wrote:
When generating lightning instructions from higher level code, scratch
registers are sometimes needed (for example, to code a move from
memory to memory).
The generating code could analyze which registers do not contain live
data and use those as scratch registers (if there are none, it has to
spill some registers).
Browsing through the lighting source code it seems that lightning
already contains some liveness analysis and some spilling algorithm.
It would be great if some interface to this could be offered to user
code, for example by offering two "virtual registers" that are
emulated by overlaying them to real registers (that are either dead or
spilled during the live time of the virtual registers).
On some ports, e.g. the AMD64 port, these virtual registers could, in
fact, be real registers like RSI or RDI most of the time, which are
usually only used for arguments to C procedure calls, and are wasted
otherwise.
If you want real (and costly) optimizations, GNU lightning is perhaps
not the best JIT library. In that case, consider instead libgccjit (see
https://gcc.gnu.org/onlinedocs/jit/ for more) or LLVM (see
http://llvm.org/ ...). Of course, the generated code would run faster,
but the generation time (actually some compilation) would be slower.
Alternatively, emit C code into a temporary file, compile it into some
plugin, then use plugin loading facilities like dlopen (on POSIX).
Cheers
--
Basile STARYNKEVITCH == http://starynkevitch.net/Basile
opinions are mine only - les opinions sont seulement miennes
Bourg La Reine, France