qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jun Koi <junkoi2004@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] TCG is hard to understand!
Date: Fri, 11 Dec 2009 01:44:52 +0900	[thread overview]
Message-ID: <fdaac4d50912100844g33d8bf07g4826869dcc2d0258@mail.gmail.com> (raw)

Hi,

I am trying to understand how TCG works. For example, I look at the
LLDT insn on x86.

In target-i386/translate.c, we translate LLDT to TCG code, like below:


static TCGv_i32 cpu_tmp2_i32;                                      // 1
...
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);   // 2
gen_jmp_im(pc_start - s->cs_base);                                // 3
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);                // 4
gen_helper_lldt(cpu_tmp2_i32);                                       // 5


This is quite confused. I understand that:

- In line (2), we retrieve the operand and save it into cpu_T[0].

- Line (3) generates jump code, but I dont understand why we need that ????

- Line (4) generate the code to copy cpu_T[0] to the (local) variable
cpu_tmp2_i32.
However, as tcg_gen_trunc_tl_i32() put the *value* of that variable,
but not its *address*, into the generated code, I dont see how next
line (5) can generate code that use the same variable.
Clearly there is no connection between cpu_tmp2_i32 on line (4) and
line (5), so how the generated code works here??

Thanks a lot,
Jun

             reply	other threads:[~2009-12-10 16:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-10 16:44 Jun Koi [this message]
2009-12-10 22:21 ` [Qemu-devel] TCG is hard to understand! Andreas Färber
2009-12-11  2:34   ` Jun Koi
2009-12-11  3:02     ` Alexander Graf
2009-12-11  3:18       ` Jun Koi
2009-12-11  7:36         ` Laurent Desnogues
2009-12-11  8:40           ` Jun Koi

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=fdaac4d50912100844g33d8bf07g4826869dcc2d0258@mail.gmail.com \
    --to=junkoi2004@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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).