qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Xin Tong <xerox.time.tech@gmail.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] TCG register allocator
Date: Wed, 25 Jan 2012 15:19:01 +0000	[thread overview]
Message-ID: <CAFEAcA8Zq4JMa4=mqR+onRr_oQituGMHQrVeRtmSisRV1mJosw@mail.gmail.com> (raw)
In-Reply-To: <CALKntY0Th9pyw5Wn1n-jh9Of3Ud8z7ibkZSKm_QrnYSmqLW3zw@mail.gmail.com>

On 25 January 2012 14:24, Xin Tong <xerox.time.tech@gmail.com> 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	other threads:[~2012-01-25 15:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-25 14:24 [Qemu-devel] TCG register allocator Xin Tong
2012-01-25 15:19 ` Peter Maydell [this message]
2012-01-25 15:42   ` Xin Tong
2012-01-25 15:49     ` Peter Maydell
2012-01-25 15:54       ` Xin Tong
2012-01-25 15:55         ` Xin Tong
2012-01-25 16:22           ` Peter Maydell
2012-01-25 18:58             ` Xin Tong
2012-01-25 19:10               ` Xin Tong
2012-01-25 19:18                 ` James Greensky
2012-01-25 19:19                   ` Xin Tong
2012-01-25 19:23                 ` Peter Maydell
2012-01-25 19:25                   ` Xin Tong
2012-01-25 19:33                     ` Peter Maydell
2012-01-31  3:09               ` 陳韋任
2012-01-25 16:03         ` Max Filippov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFEAcA8Zq4JMa4=mqR+onRr_oQituGMHQrVeRtmSisRV1mJosw@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=xerox.time.tech@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).