From patchwork Sun Mar 25 22:27:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148605 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 77CE4B6EF4 for ; Mon, 26 Mar 2012 10:10:49 +1100 (EST) Received: from localhost ([::1]:60875 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBvwP-0005P4-15 for incoming@patchwork.ozlabs.org; Sun, 25 Mar 2012 18:29:37 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBvvi-0003nf-3P for qemu-devel@nongnu.org; Sun, 25 Mar 2012 18:28:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SBvvg-0007wj-E3 for qemu-devel@nongnu.org; Sun, 25 Mar 2012 18:28:53 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:37809) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBvvg-0007uM-5M for qemu-devel@nongnu.org; Sun, 25 Mar 2012 18:28:52 -0400 Received: by mail-pb0-f45.google.com with SMTP id uo5so6347922pbc.4 for ; Sun, 25 Mar 2012 15:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=QfiOMl2k1WVfUzdAqf6tb+pboy5+FA6q5hE7R9zKgB8=; b=tS7Bbdns7akTcwlSaB/bn5tw+0Rf6vbRwBxabjar6Wm1a2lup07W8Jl984XQ8bS0O7 DfZwM5pwagHi4rvIFgUyfViIqzvNM+aootRy+NTDPvzVvSjpu190SHu/ePsvWSrAVAvl ma+afy+tFkFtNC5lv5Z/dKewiHhZdHxp/FgOFHTRufyrw9FMnhXTn3xVOzupJMKUNWKr 14k2nvhS9gA6boBTzmRoC4LS0MayP35VBS/sniNXnRuhdyHi70Nh6X0fC4eOW/CVRGBU bF3amirxmBefc5GZcWmvZ7f1e1exQEyA0mY0ks3tcsGMZx9mVcgyvfwqtAq+JaQLQXkS nMDg== Received: by 10.68.238.3 with SMTP id vg3mr47422515pbc.140.1332714531333; Sun, 25 Mar 2012 15:28:51 -0700 (PDT) Received: from pebble.com ([173.160.232.49]) by mx.google.com with ESMTPS id l4sm11018797pbl.27.2012.03.25.15.28.50 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 25 Mar 2012 15:28:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 25 Mar 2012 15:27:51 -0700 Message-Id: <1332714477-30079-10-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1332714477-30079-1-git-send-email-rth@twiddle.net> References: <1332714477-30079-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Blue Swirl Subject: [Qemu-devel] [PATCH 09/15] tcg-sparc: Do not use a global register for AREG0. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Richard Henderson --- dyngen-exec.h | 20 +++++++++++--------- exec.c | 16 ++++++++++++++-- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/dyngen-exec.h b/dyngen-exec.h index 65fcb43..d673f9f 100644 --- a/dyngen-exec.h +++ b/dyngen-exec.h @@ -41,13 +41,8 @@ #elif defined(__mips__) #define AREG0 "s0" #elif defined(__sparc__) -#ifdef CONFIG_SOLARIS -#define AREG0 "g2" -#elif HOST_LONG_BITS == 64 -#define AREG0 "g5" -#else -#define AREG0 "g6" -#endif +/* Don't use a global register. Working around glibc clobbering these + global registers is more trouble than just using TLS. */ #elif defined(__s390__) #define AREG0 "r10" #elif defined(__alpha__) @@ -62,12 +57,19 @@ #error unsupported CPU #endif -#if defined(AREG0) +#ifdef AREG0 register CPUArchState *env asm(AREG0); #else -/* TODO: Try env = cpu_single_env. */ +/* It's tempting to #define env cpu_single_cpu, but that runs afoul of + the other macro usage in target-foo/helper.h. Instead use an alias. + That has to happen where cpu_single_cpu is defined, so just a + declaration here. */ +#ifdef __linux__ +extern __thread CPUArchState *env; +#else extern CPUArchState *env; #endif +#endif /* AREG0 */ #endif /* !CONFIG_TCG_PASS_AREG0 */ #endif /* !defined(__DYNGEN_EXEC_H__) */ diff --git a/exec.c b/exec.c index 6731ab8..d84caa5 100644 --- a/exec.c +++ b/exec.c @@ -124,9 +124,21 @@ static MemoryRegion io_mem_subpage_ram; #endif CPUArchState *first_cpu; -/* current CPU in the current thread. It is only valid inside - cpu_exec() */ + +/* Current CPU in the current thread. It is only valid inside cpu_exec(). */ DEFINE_TLS(CPUArchState *,cpu_single_env); + +/* In dyngen-exec.h, without AREG0, we fall back to an alias to cpu_single_env. + We can't actually tell from here whether that's needed or not, but it does + not hurt to go ahead and make the declaration. */ +#ifndef CONFIG_TCG_PASS_AREG0 +extern +#ifdef __linux__ + __thread +#endif + CPUArchState *env __attribute__((alias("tls__cpu_single_env"))); +#endif /* CONFIG_TCG_PASS_AREG0 */ + /* 0 = Do not count executed instructions. 1 = Precise instruction counting. 2 = Adaptive rate instruction counting. */