From: Glauber Costa <gcosta@redhat.com>
To: qemu-devel@nongnu.org
Cc: kvm-devel@lists.sourceforge.net
Subject: [Qemu-devel] [PATCH 04/10] ppc: replace code inside ifdef with generic function
Date: Fri, 25 Apr 2008 00:23:04 -0300 [thread overview]
Message-ID: <12090938052239-git-send-email-gcosta@redhat.com> (raw)
In-Reply-To: <12090938023558-git-send-email-gcosta@redhat.com>
this patch replaced code inside specific ifdef in translate-all.c
with a generic architecture-implemented function. This leads to a
cleaner and more modular code in the generic part.
---
target-ppc/translate.c | 42 ++++++++++++++++++++++++++++++++++++++++++
translate-all.c | 40 +---------------------------------------
2 files changed, 43 insertions(+), 39 deletions(-)
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index c9530eb..6f7d16c 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -6344,3 +6344,45 @@ int gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 1);
}
+
+void gen_pc_load(CPUState *env, TranslationBlock *tb,
+ unsigned long searched_pc, int pc_pos, void *puc)
+{
+ int type, c;
+ /* for PPC, we need to look at the micro operation to get the
+ * access type */
+ env->nip = gen_opc_pc[pc_pos];
+ c = gen_opc_buf[pc_pos];
+ switch(c) {
+#if defined(CONFIG_USER_ONLY)
+#define CASE3(op)\
+ case INDEX_op_ ## op ## _raw
+#else
+#define CASE3(op)\
+ case INDEX_op_ ## op ## _user:\
+ case INDEX_op_ ## op ## _kernel:\
+ case INDEX_op_ ## op ## _hypv
+#endif
+
+ CASE3(stfd):
+ CASE3(stfs):
+ CASE3(lfd):
+ CASE3(lfs):
+ type = ACCESS_FLOAT;
+ break;
+ CASE3(lwarx):
+ type = ACCESS_RES;
+ break;
+ CASE3(stwcx):
+ type = ACCESS_RES;
+ break;
+ CASE3(eciwx):
+ CASE3(ecowx):
+ type = ACCESS_EXT;
+ break;
+ default:
+ type = ACCESS_INT;
+ break;
+ }
+ env->access_type = type;
+}
diff --git a/translate-all.c b/translate-all.c
index 92c8f1c..66f03e1 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -200,45 +200,7 @@ int cpu_restore_state(TranslationBlock *tb,
#elif defined(TARGET_SPARC)
gen_pc_load(env, tb, searched_pc, j, puc);
#elif defined(TARGET_PPC)
- {
- int type, c;
- /* for PPC, we need to look at the micro operation to get the
- access type */
- env->nip = gen_opc_pc[j];
- c = gen_opc_buf[j];
- switch(c) {
-#if defined(CONFIG_USER_ONLY)
-#define CASE3(op)\
- case INDEX_op_ ## op ## _raw
-#else
-#define CASE3(op)\
- case INDEX_op_ ## op ## _user:\
- case INDEX_op_ ## op ## _kernel:\
- case INDEX_op_ ## op ## _hypv
-#endif
-
- CASE3(stfd):
- CASE3(stfs):
- CASE3(lfd):
- CASE3(lfs):
- type = ACCESS_FLOAT;
- break;
- CASE3(lwarx):
- type = ACCESS_RES;
- break;
- CASE3(stwcx):
- type = ACCESS_RES;
- break;
- CASE3(eciwx):
- CASE3(ecowx):
- type = ACCESS_EXT;
- break;
- default:
- type = ACCESS_INT;
- break;
- }
- env->access_type = type;
- }
+ gen_pc_load(env, tb, searched_pc, j, puc);
#elif defined(TARGET_M68K)
env->pc = gen_opc_pc[j];
#elif defined(TARGET_MIPS)
--
1.5.0.6
next prev parent reply other threads:[~2008-04-25 3:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-25 3:23 [Qemu-devel] [PATCH 0/10] Factorize code in translate.c Glauber Costa
2008-04-25 3:23 ` [Qemu-devel] [PATCH 01/10] i386: replace code inside ifdef with generic function Glauber Costa
2008-04-25 3:23 ` [Qemu-devel] [PATCH 02/10] arm: " Glauber Costa
2008-04-25 3:23 ` [Qemu-devel] [PATCH 03/10] sparc: " Glauber Costa
2008-04-25 3:23 ` Glauber Costa [this message]
2008-04-25 3:23 ` [Qemu-devel] [PATCH 05/10] m68k: " Glauber Costa
2008-04-25 3:23 ` [Qemu-devel] [PATCH 06/10] mips: " Glauber Costa
2008-04-25 3:23 ` [Qemu-devel] [PATCH 07/10] alpha: " Glauber Costa
2008-04-25 3:23 ` [Qemu-devel] [PATCH 08/10] sh4: " Glauber Costa
2008-04-25 3:23 ` [Qemu-devel] [PATCH 09/10] cris: " Glauber Costa
2008-04-25 3:23 ` [Qemu-devel] [PATCH 10/10] remove arch-specific ifdefs from translate-all.c Glauber Costa
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=12090938052239-git-send-email-gcosta@redhat.com \
--to=gcosta@redhat.com \
--cc=kvm-devel@lists.sourceforge.net \
--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).