qemu-discuss
[Top][All Lists]
Advanced

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

Re: Generating host code in TCG mode


From: Peter Maydell
Subject: Re: Generating host code in TCG mode
Date: Sun, 19 Mar 2023 16:44:34 +0000

On Sat, 18 Mar 2023 at 23:54, 沈梦姣 <shen.mengjiao3@icloud.com> wrote:
>
>
> Thanks Peter
>
> > 在 2023年3月19日,上午2:52,Peter Maydell <peter.maydell@linaro.org> 写道:
> >
> > On Fri, 17 Mar 2023 at 21:01, 沈梦姣 <shen.mengjiao3@icloud.com> wrote:
> >> TCG knows what registers may be clobbered by a call into
> >> host C code (this is set up in the tcg_target_call_clobber_regs
> >> regset by code in tcg_target_init()), so the register allocator
> >> will either avoid using those registers
> >>
> >> Look at tcg_target_reg_alloc_order in i386 host, it has these
> >> clobber registers though it first allocates callee saved registers.
> >
> > Yes, that's the sensible order to allocate in.
> >
> >> for values that must
> >> be preserved across the call, or else it will spill them to
> >> memory.
> >>
> >> I didn’t see these clobber registers being saved to memory
> >> before call/jmp Host C code in i386(x86-64) host, and copy
> >> these memory value back to these registers
> >
> > If they were not saved to memory, then there must not have
> > been a 'live' value in them in the example you were looking
> > at.
> > If TCG didn't correctly handle registers that are clobbered
> > by calls, then it would not work at all.
> Yes, but it will be helpful if someone provides some hints though I’m still 
> reviewing the code. Thanks

I'm not sure what hints you want here. I've told you what the
mechanism is that QEMU uses to work with registers that are
trashed by calls to host C functions. If you think you see
somewhere where a register isn't being saved and it needs
to be, then the most likely possibility is that you've misread
the debug log, and in fact TCG does not need the value in that
register at that point in execution.

-- PMM



reply via email to

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