From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIm8m-00029e-2L for qemu-devel@nongnu.org; Thu, 10 Dec 2009 11:45:20 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIm8h-00025P-0r for qemu-devel@nongnu.org; Thu, 10 Dec 2009 11:45:19 -0500 Received: from [199.232.76.173] (port=56293 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIm8g-00024x-HI for qemu-devel@nongnu.org; Thu, 10 Dec 2009 11:45:14 -0500 Received: from mail-pz0-f188.google.com ([209.85.222.188]:61378) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NIm8g-0002Eb-Fw for qemu-devel@nongnu.org; Thu, 10 Dec 2009 11:45:14 -0500 Received: by pzk26 with SMTP id 26so26125pzk.4 for ; Thu, 10 Dec 2009 08:45:12 -0800 (PST) MIME-Version: 1.0 From: Jun Koi Date: Fri, 11 Dec 2009 01:44:52 +0900 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 Subject: [Qemu-devel] TCG is hard to understand! List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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