qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] TCG register allocator


From: Peter Maydell
Subject: Re: [Qemu-devel] TCG register allocator
Date: Wed, 25 Jan 2012 15:19:01 +0000

On 25 January 2012 14:24, Xin Tong <address@hidden> wrote:
> I am wondering how tcg reg alloc works. Specifically, how do i reserve
> a register only for one specific purpose. R14 on tcg i386 is reserved
> to point to the cpustate strcuture.  it is assigned in the prologue,
> but what code makes sure that it is not clobbered in the middle of a
> TB ?

target-i386/translate.c:optimize_flags_init() calls:
    cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");

which tells TCG that this register always has this value in it.
TCG will then ensure that it doesn't try to use that register
when it's doing allocation later. This is done by having
tcg_global_reg_new_internal() call:
    tcg_regset_set_reg(s->reserved_regs, reg);

We also add a register to the reserved_regs set in tcg/i386/tcg-target.c:
tcg_target_init():
     tcg_regset_set_reg(s->reserved_regs, TCG_REG_CALL_STACK);

because attempting to allocate a value into ESP would be a bad idea :-)

-- PMM



reply via email to

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