|
From: | Andreas Färber |
Subject: | Re: [Qemu-devel] TCG is hard to understand! |
Date: | Thu, 10 Dec 2009 23:21:21 +0100 |
Hi, Am 10.12.2009 um 17:44 schrieb Jun Koi:
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]); // 4gen_helper_lldt (cpu_tmp2_i32); // 5This is quite confused. I understand 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??
Line 4 generates code to truncate the value from the source associated with cpu_T[0] and put it into the destination associated with cpu_tmp2_i32, which may be a general-purpose register on PowerPC for instance (i.e., not an address). The connection between line 4 and 5 is that cpu_tmp2_i32 has as its value the same identifier (sort of a handle), allowing TCG internal code to lookup its location.
Btw if the code confuses you, cpu_T[n] is actually a leftover from the dyngen to TCG conversion. Feel free to provide patches replacing the remaining occurrences by individual local TCG variables if it helps your understanding. :)
Andreas
[Prev in Thread] | Current Thread | [Next in Thread] |