From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NiDvJ-0001Jm-5Q for qemu-devel@nongnu.org; Thu, 18 Feb 2010 16:28:37 -0500 Received: from [199.232.76.173] (port=58902 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NiDvI-0001JP-RU for qemu-devel@nongnu.org; Thu, 18 Feb 2010 16:28:36 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NiDvH-0005Pw-Np for qemu-devel@nongnu.org; Thu, 18 Feb 2010 16:28:36 -0500 Received: from mail-pz0-f194.google.com ([209.85.222.194]:64951) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NiDvH-0005Pj-82 for qemu-devel@nongnu.org; Thu, 18 Feb 2010 16:28:35 -0500 Received: by pzk32 with SMTP id 32so557683pzk.4 for ; Thu, 18 Feb 2010 13:28:34 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1266524723-21572-2-git-send-email-pbonzini@redhat.com> References: <1266524723-21572-1-git-send-email-pbonzini@redhat.com> <1266524723-21572-2-git-send-email-pbonzini@redhat.com> From: Blue Swirl Date: Thu, 18 Feb 2010 23:28:14 +0200 Message-ID: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [PATCH v2 2/2] get rid of hostregs_helper.h List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org Thanks, applied both. On Thu, Feb 18, 2010 at 10:25 PM, Paolo Bonzini wrote= : > Since b567b38 (target-arm: remove T0 and T1, 2009-10-16) the only global > register that is used is AREG0, so the complexity of hostregs_helper.h > is unused. =C2=A0Use regular assignments and a compiler optimization barr= ier. > > Signed-off-by: Paolo Bonzini > --- > =C2=A0 =C2=A0 =C2=A0 =C2=A0v1->v2: added QEMU prefix to BUILD_BUG_ON > > =C2=A0cpu-exec.c =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 15 +++++++----- > =C2=A0hostregs_helper.h | =C2=A0 61 -------------------------------------= ---------------- > =C2=A0qemu-common.h =C2=A0 =C2=A0 | =C2=A0 =C2=A02 + > =C2=A03 files changed, 11 insertions(+), 67 deletions(-) > =C2=A0delete mode 100644 hostregs_helper.h > > diff --git a/cpu-exec.c b/cpu-exec.c > index 6a290fd..ab6defc 100644 > --- a/cpu-exec.c > +++ b/cpu-exec.c > @@ -210,8 +210,7 @@ static void cpu_handle_debug_exception(CPUState *env) > > =C2=A0int cpu_exec(CPUState *env1) > =C2=A0{ > -#define DECLARE_HOST_REGS 1 > -#include "hostregs_helper.h" > + =C2=A0 =C2=A0host_reg_t saved_env_reg; > =C2=A0 =C2=A0 int ret, interrupt_request; > =C2=A0 =C2=A0 TranslationBlock *tb; > =C2=A0 =C2=A0 uint8_t *tc_ptr; > @@ -222,9 +221,12 @@ int cpu_exec(CPUState *env1) > > =C2=A0 =C2=A0 cpu_single_env =3D env1; > > - =C2=A0 =C2=A0/* first we save global registers */ > -#define SAVE_HOST_REGS 1 > -#include "hostregs_helper.h" > + =C2=A0 =C2=A0/* the access to env below is actually saving the global r= egister's > + =C2=A0 =C2=A0 =C2=A0 value, so that files not including target-xyz/exec= .h are free to > + =C2=A0 =C2=A0 =C2=A0 use it. =C2=A0*/ > + =C2=A0 =C2=A0QEMU_BUILD_BUG_ON (sizeof (saved_env_reg) !=3D sizeof (env= )); > + =C2=A0 =C2=A0saved_env_reg =3D (host_reg_t) env; > + =C2=A0 =C2=A0asm(""); > =C2=A0 =C2=A0 env =3D env1; > > =C2=A0#if defined(TARGET_I386) > @@ -669,7 +671,8 @@ int cpu_exec(CPUState *env1) > =C2=A0#endif > > =C2=A0 =C2=A0 /* restore global registers */ > -#include "hostregs_helper.h" > + =C2=A0 =C2=A0asm(""); > + =C2=A0 =C2=A0env =3D (void *) saved_env_reg; > > =C2=A0 =C2=A0 /* fail safe : never use cpu_single_env outside cpu_exec() = */ > =C2=A0 =C2=A0 cpu_single_env =3D NULL; > diff --git a/hostregs_helper.h b/hostregs_helper.h > deleted file mode 100644 > index 3a0bece..0000000 > --- a/hostregs_helper.h > +++ /dev/null > @@ -1,61 +0,0 @@ > -/* > - * =C2=A0Save/restore host registers. > - * > - * =C2=A0Copyright (c) 2007 CodeSourcery > - * > - * This library is free software; you can redistribute it and/or > - * modify it under the terms of the GNU Lesser General Public > - * License as published by the Free Software Foundation; either > - * version 2 of the License, or (at your option) any later version. > - * > - * This library is distributed in the hope that it will be useful, > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =C2=A0See the GN= U > - * Lesser General Public License for more details. > - * > - * You should have received a copy of the GNU Lesser General Public > - * License along with this library; if not, see . > - */ > - > -/* The GCC global register variable extension is used to reserve some > - =C2=A0 host registers for use by generated code. =C2=A0However only the= core parts of > - =C2=A0 the translation engine are compiled with these settings. =C2=A0W= e must manually > - =C2=A0 save/restore these registers when called from regular code. > - =C2=A0 It is not sufficient to save/restore T0 et. al. as these may be = declared > - =C2=A0 with a datatype smaller than the actual register. =C2=A0*/ > - > -#if defined(DECLARE_HOST_REGS) > - > -#define DO_REG(REG) =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=A0register host_reg_t reg_AREG##REG asm(AREG##REG); =C2=A0\ > - =C2=A0 =C2=A0volatile host_reg_t saved_AREG##REG; > - > -#elif defined(SAVE_HOST_REGS) > - > -#define DO_REG(REG) =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__asm__ __volatile__ ("" : "=3Dr" (reg_AREG##REG)); =C2=A0= \ > - =C2=A0 =C2=A0saved_AREG##REG =3D reg_AREG##REG; > - > -#else > - > -#define DO_REG(REG) =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=A0reg_AREG##REG =3D saved_AREG##REG; =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \ > - =C2=A0 =C2=A0__asm__ __volatile__ ("" : : "r" (reg_AREG##REG)); > - > -#endif > - > -#ifdef AREG0 > -DO_REG(0) > -#endif > - > -#ifdef AREG1 > -DO_REG(1) > -#endif > - > -#ifdef AREG2 > -DO_REG(2) > -#endif > - > -#undef SAVE_HOST_REGS > -#undef DECLARE_HOST_REGS > -#undef DO_REG > diff --git a/qemu-common.h b/qemu-common.h > index b09f717..a98fccd 100644 > --- a/qemu-common.h > +++ b/qemu-common.h > @@ -11,6 +11,8 @@ > =C2=A0#define QEMU_WARN_UNUSED_RESULT > =C2=A0#endif > > +#define QEMU_BUILD_BUG_ON(x) typedef char __build_bug_on__##__LINE__[(x)= ?-1:1]; > + > =C2=A0/* Hack around the mess dyngen-exec.h causes: We need QEMU_NORETURN= in files that > =C2=A0 =C2=A0cannot include the following headers without conflicts. This= condition has > =C2=A0 =C2=A0to be removed once dyngen is gone. */ > -- > 1.6.6 > >