From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: Blue Swirl <blauwirbel@gmail.com>
Subject: [Qemu-devel] [PATCH 09/15] tcg-sparc: Do not use a global register for AREG0.
Date: Sun, 25 Mar 2012 15:27:51 -0700 [thread overview]
Message-ID: <1332714477-30079-10-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1332714477-30079-1-git-send-email-rth@twiddle.net>
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
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. */
--
1.7.7.6
next prev parent reply other threads:[~2012-03-25 22:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-25 22:27 [Qemu-devel] [PATCH 00/15] tcg-sparc improvments Richard Henderson
2012-03-25 22:27 ` [Qemu-devel] [PATCH 01/15] tcg-sparc: Hack in qemu_ld/st64 for 32-bit Richard Henderson
2012-03-25 22:27 ` [Qemu-devel] [PATCH 02/15] tcg-sparc: Fix ADDX opcode Richard Henderson
2012-03-25 22:27 ` [Qemu-devel] [PATCH 03/15] tcg-sparc: Assume v9 cpu always, i.e. force v8plus in 32-bit mode Richard Henderson
2012-03-25 22:27 ` [Qemu-devel] [PATCH 04/15] tcg-sparc: Fix qemu_ld/st to handle 32-bit host Richard Henderson
2012-03-25 22:27 ` [Qemu-devel] [PATCH 05/15] tcg-sparc: Simplify qemu_ld/st direct memory paths Richard Henderson
2012-03-25 22:27 ` [Qemu-devel] [PATCH 06/15] tcg-sparc: Support GUEST_BASE Richard Henderson
2012-03-25 22:27 ` [Qemu-devel] [PATCH 07/15] tcg-sparc: Steamline qemu_ld/st more Richard Henderson
2012-03-25 22:27 ` [Qemu-devel] [PATCH 08/15] Avoid declaring the env variable at all if CONFIG_TCG_PASS_AREG0 Richard Henderson
2012-03-26 16:26 ` Blue Swirl
2012-03-26 16:31 ` Richard Henderson
2012-03-25 22:27 ` Richard Henderson [this message]
2012-03-26 16:31 ` [Qemu-devel] [PATCH 09/15] tcg-sparc: Do not use a global register for AREG0 Blue Swirl
2012-03-26 16:52 ` Richard Henderson
2012-03-26 17:22 ` Blue Swirl
2012-03-25 22:27 ` [Qemu-devel] [PATCH 10/15] tcg-sparc: Change AREG0 in generated code to %i0 Richard Henderson
2012-03-25 22:27 ` [Qemu-devel] [PATCH 11/15] tcg-sparc: Clean up cruft stemming from attempts to use global registers Richard Henderson
2012-03-25 22:27 ` [Qemu-devel] [PATCH 12/15] tcg-sparc: Mask shift immediates to avoid illegal insns Richard Henderson
2012-03-25 22:27 ` [Qemu-devel] [PATCH 13/15] tcg-sparc: Use defines for temporaries Richard Henderson
2012-03-26 16:38 ` Blue Swirl
2012-03-25 22:27 ` [Qemu-devel] [PATCH 14/15] tcg-sparc: Add %g/%o registers to alloc_order Richard Henderson
2012-03-25 22:27 ` [Qemu-devel] [PATCH 15/15] tcg-sparc: Fix and enable direct TB chaining Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1332714477-30079-10-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).