From patchwork Wed Feb 10 23:26:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 45072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BE3E3B7CE6 for ; Thu, 11 Feb 2010 10:32:16 +1100 (EST) Received: from localhost ([127.0.0.1]:33177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfM1b-00086V-QE for incoming@patchwork.ozlabs.org; Wed, 10 Feb 2010 18:31:15 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NfLwo-0005zO-Cy for qemu-devel@nongnu.org; Wed, 10 Feb 2010 18:26:18 -0500 Received: from [199.232.76.173] (port=58703 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfLwn-0005ys-R3 for qemu-devel@nongnu.org; Wed, 10 Feb 2010 18:26:17 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NfLwm-000473-K5 for qemu-devel@nongnu.org; Wed, 10 Feb 2010 18:26:17 -0500 Received: from mail-fx0-f223.google.com ([209.85.220.223]:63072) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NfLwm-000460-9c for qemu-devel@nongnu.org; Wed, 10 Feb 2010 18:26:16 -0500 Received: by mail-fx0-f223.google.com with SMTP id 23so604508fxm.2 for ; Wed, 10 Feb 2010 15:26:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:subject:date :message-id:x-mailer:in-reply-to:references; bh=8ATrGXUCRsooYz5qQOP1dD6haO0I6gcqIDkf/sSqW9Y=; b=Is/J/30BLRl622GDSQ/XFIfkxtJy52PLnteonUmejZRaCaNoRtHJvdp1fRs8Dwi7zS M96NLANr+BA0Ne/LkdWGUm9EpmO0nBF2YDu+I4VuHSdu5xOrAQNNV/5XBuwmoMpR0CuW 8uFyxscXxQNH4zfcpANAUghS1aH27muDIed10= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; b=goQmXgsZXA5St7rJFjCOdoffJYXPHzY3AQ3eEZUjHUnnqBFfr0gvmhlcSQ85CM3o6U yzqg37z7FnMJ5El5sEAQclL/UhDz3+XORPZ/B1l6SOQo4pFXNRdp3vM+6RubrCvOcryM kyEadR0lQA8IhfODF1wvfUk+T2dILyWammKl0= Received: by 10.223.2.149 with SMTP id 21mr1155253faj.49.1265844367337; Wed, 10 Feb 2010 15:26:07 -0800 (PST) Received: from localhost.localdomain ([85.93.118.17]) by mx.google.com with ESMTPS id p17sm554034fka.35.2010.02.10.15.26.06 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 10 Feb 2010 15:26:07 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 11 Feb 2010 00:26:02 +0100 Message-Id: <1265844362-29836-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1265844362-29836-1-git-send-email-pbonzini@redhat.com> References: <1265844362-29836-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 2/2] get rid of hostregs_helper.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Use regular assignments and a compiler optimization barrier. Signed-off-by: Paolo Bonzini --- cpu-exec.c | 15 +++++++----- hostregs_helper.h | 61 ----------------------------------------------------- qemu-common.h | 2 + 3 files changed, 11 insertions(+), 67 deletions(-) delete mode 100644 hostregs_helper.h diff --git a/cpu-exec.c b/cpu-exec.c index 0256edf..2553d1d 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -210,8 +210,7 @@ static void cpu_handle_debug_exception(CPUState *env) int cpu_exec(CPUState *env1) { -#define DECLARE_HOST_REGS 1 -#include "hostregs_helper.h" + host_reg_t saved_env_reg; int ret, interrupt_request; TranslationBlock *tb; uint8_t *tc_ptr; @@ -222,9 +221,12 @@ int cpu_exec(CPUState *env1) cpu_single_env = env1; - /* first we save global registers */ -#define SAVE_HOST_REGS 1 -#include "hostregs_helper.h" + /* the access to env below is actually saving the global register's + value, so that files not including target-xyz/exec.h are free to + use it. */ + BUILD_BUG_ON (sizeof (saved_env_reg) != sizeof (env)); + saved_env_reg = (host_reg_t) env; + asm(""); env = env1; #if defined(TARGET_I386) @@ -668,7 +670,8 @@ int cpu_exec(CPUState *env1) #endif /* restore global registers */ -#include "hostregs_helper.h" + asm(""); + env = (void *) saved_env_reg; /* fail safe : never use cpu_single_env outside cpu_exec() */ cpu_single_env = 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 @@ -/* - * Save/restore host registers. - * - * Copyright (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. See the GNU - * 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 - host registers for use by generated code. However only the core parts of - the translation engine are compiled with these settings. We must manually - save/restore these registers when called from regular code. - It is not sufficient to save/restore T0 et. al. as these may be declared - with a datatype smaller than the actual register. */ - -#if defined(DECLARE_HOST_REGS) - -#define DO_REG(REG) \ - register host_reg_t reg_AREG##REG asm(AREG##REG); \ - volatile host_reg_t saved_AREG##REG; - -#elif defined(SAVE_HOST_REGS) - -#define DO_REG(REG) \ - __asm__ __volatile__ ("" : "=r" (reg_AREG##REG)); \ - saved_AREG##REG = reg_AREG##REG; - -#else - -#define DO_REG(REG) \ - reg_AREG##REG = saved_AREG##REG; \ - __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..b791148 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -11,6 +11,8 @@ #define QEMU_WARN_UNUSED_RESULT #endif +#define BUILD_BUG_ON(x) typedef char __build_bug_on__##__LINE__[(x)?-1:1]; + /* Hack around the mess dyngen-exec.h causes: We need QEMU_NORETURN in files that cannot include the following headers without conflicts. This condition has to be removed once dyngen is gone. */