Re: x86 TCG helpers clobbered registers

2020-12-08 Thread Stephane Duverger
On Tue, Dec 08, 2020 at 03:18:54PM -0600, Richard Henderson wrote: > As for modifying the fast path cases, the code is quite delicate, > and you run into problems with live registers. Which could be > worked around in each backend, but... why? Perhaps thinking that working at IR level would preve

Re: x86 TCG helpers clobbered registers

2020-12-08 Thread Richard Henderson
On 12/7/20 4:10 AM, Stephane Duverger wrote: > This leads me to that simple reflection: > > If we want to filter on every memory accesses, *out of the fast-path*, > the most natural place to do so would be in store_helper() and > load_helper() from accel/tcg/cputlb.c. By doing so, every target wou

Re: x86 TCG helpers clobbered registers

2020-12-07 Thread Stephane Duverger
On Sat, Dec 05, 2020 at 06:38:25AM -0600, Richard Henderson wrote: > The difference is that the slow path is aware that there are input registers > that are live, containing data (addrlo, addrhi, datalo, datahi), which must be > stored into the arguments for the slow path call. Those input registe

Re: x86 TCG helpers clobbered registers

2020-12-05 Thread Richard Henderson
On 12/4/20 7:34 PM, Stephane Duverger wrote: >> You can't just inject a call anywhere you like. If you add it at >> the IR level, then the rest of the compiler will see it and work >> properly. If you add the call in the middle of another operation, >> the compiler doesn't get to see it and Bad T

Re: x86 TCG helpers clobbered registers

2020-12-04 Thread Stephane Duverger
On Fri, Dec 04, 2020 at 01:35:55PM -0600, Richard Henderson wrote: Thank you Richard for your answer. I don't want to generate a debate, or defend the way I've done things initially. Really want to clarify these internals. Hope it will benefit to other QEMU enthusiasts. > You can't just inject a

Re: x86 TCG helpers clobbered registers

2020-12-04 Thread Richard Henderson
On 12/4/20 9:36 AM, Stephane Duverger wrote: > Hello, > > While looking at tcg/i386/tcg-target.c.inc:tcg_out_qemu_st(), I > discovered that the TCG generates a call to a store helper at the end > of the TB which is executed on TLB miss and get back to the remaining > translated ops. I tried to mim

x86 TCG helpers clobbered registers

2020-12-04 Thread Stephane Duverger
Hello, While looking at tcg/i386/tcg-target.c.inc:tcg_out_qemu_st(), I discovered that the TCG generates a call to a store helper at the end of the TB which is executed on TLB miss and get back to the remaining translated ops. I tried to mimick this behavior around the fast path (right between tcg