From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RUgtR-0007qV-7u for qemu-devel@nongnu.org; Sun, 27 Nov 2011 10:43:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RUgtQ-0006r0-32 for qemu-devel@nongnu.org; Sun, 27 Nov 2011 10:43:49 -0500 Received: from mail-qy0-f173.google.com ([209.85.216.173]:51235) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RUgtP-0006qw-Vs for qemu-devel@nongnu.org; Sun, 27 Nov 2011 10:43:48 -0500 Received: by qyl38 with SMTP id 38so3193006qyl.4 for ; Sun, 27 Nov 2011 07:43:47 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <4ED24545.1060902@suse.de> <4ED24EF7.4050704@suse.de> Date: Sun, 27 Nov 2011 15:43:47 +0000 Message-ID: From: Peter Maydell Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] cpu_regs in target-i386 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Xin Tong Cc: =?UTF-8?Q?Andreas_F=C3=A4rber?= , qemu-devel On 27 November 2011 15:23, Xin Tong wrote: > =C2=A0cpu_regs[15] =3D tcg_global_mem_new_i64(TCG_AREG0, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0of= fsetof(CPUState, regs[15]), "r15"); > =C2=A0printf("offsetof(CPUState, regs[15]) is %ld\n", offsetof(CPUState, = regs[15])); > output is cpu_regs[15] is 20, offsetof(CPUState, regs[15]) is 120, > should not cpu_regs[15] =3D=3D 120 ? No. tcg_global_mem_new_i64() returns a TCGv, which is (as far as code in translate.c is concerned) an opaque reference which can be passed to other TCG functions to cause code to be emitted which uses that value (eg "add this value to something else"). So conceptually it represents "the value at the memory location at (TCG_AREG0 + some offset)". If you then use this TCGv in a tcg_gen_add_i64() we will generate code to load the value from memory and add it. (TCG values can also be "the value stored in this fixed native register" (used basically only for the cpu_env pointer itself) or "a temporary value which TCG is free to allocate to a register as it likes" (the most common).) [The implementation is that it is an index into an array of all the TCGv values TCG knows about, which is why it's a small integer.] -- PMM