From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:45778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq5B1-0005Mk-Oc for qemu-devel@nongnu.org; Wed, 25 Jan 2012 10:54:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rq5Av-0001mY-VX for qemu-devel@nongnu.org; Wed, 25 Jan 2012 10:54:23 -0500 Received: from mail-gx0-f173.google.com ([209.85.161.173]:47227) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq5Av-0001mU-MK for qemu-devel@nongnu.org; Wed, 25 Jan 2012 10:54:17 -0500 Received: by ggnr1 with SMTP id r1so2372919ggn.4 for ; Wed, 25 Jan 2012 07:54:17 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 25 Jan 2012 10:54:16 -0500 Message-ID: From: Xin Tong Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] TCG register allocator List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel I have a bug, it segfaults when executing a translation blocks. when i disable block chaining, the bug disappears. However, with block chaining, i do not know which translation block jumps to the code which caused the segfault. I want to reserve a register and use it to record the last translation block executed. So at entry, i assign the translation blocks address to the register and when the segfault happens, I can get the last translation block executed. Thanks On Wed, Jan 25, 2012 at 10:49 AM, Peter Maydell wrote: > On 25 January 2012 15:42, Xin Tong wrote: >> I tried to reserve a register in target-i386 with this code >> >> target-i386/translate.c =A0 =A0tb_env =3D tcg_global_reg_new_ptr(TCG_ARE= G1, "env"); > > Why do you want to define a second global which holds the environment > variable? Just use TCG_AREG0 for that. > >> i386/tcg-target.h =A0 =A0 =A0 =A0 #define TCG_AREG1 TCG_REG_R13 >> >> i386/tcg-target.c =A0 =A0 =A0 =A0 tcg_out_movi(s, TCG_TYPE_PTR, TCG_AREG= 1, args[0]); >> >> But when i looked into the dynamically generated code, the place which >> i use TCG_AREG1 becomes RBP and RBP is not reserved either. > > If the reason you're trying to reserve a register is so you can use > it as a temporary in tcg-target.c's codegen, then reserve it in > tcg_target_init(). (But x86-32 is very short on registers as it is, > so really it would be much better not to...) > > -- PMM