[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/10] i386: replace code inside ifdef with generic
From: |
Glauber Costa |
Subject: |
[Qemu-devel] [PATCH 01/10] i386: replace code inside ifdef with generic function |
Date: |
Fri, 25 Apr 2008 00:23:01 -0300 |
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.
---
exec-all.h | 3 +++
target-i386/translate.c | 23 +++++++++++++++++++++++
translate-all.c | 22 +---------------------
3 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/exec-all.h b/exec-all.h
index 62b8191..3ce8242 100644
--- a/exec-all.h
+++ b/exec-all.h
@@ -61,6 +61,9 @@ extern int loglevel;
int gen_intermediate_code(CPUState *env, struct TranslationBlock *tb);
int gen_intermediate_code_pc(CPUState *env, struct TranslationBlock *tb);
+void gen_pc_load(CPUState *env, struct TranslationBlock *tb,
+ unsigned long searched_pc, int pc_pos, void *puc);
+
unsigned long code_gen_max_block_size(void);
void cpu_gen_init(void);
int cpu_gen_code(CPUState *env, struct TranslationBlock *tb,
diff --git a/target-i386/translate.c b/target-i386/translate.c
index 356ceff..895d14b 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -6832,3 +6832,26 @@ int gen_intermediate_code_pc(CPUState *env,
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 cc_op;
+#ifdef DEBUG_DISAS
+ if (loglevel & CPU_LOG_TB_OP) {
+ int i;
+ fprintf(logfile, "RESTORE:\n");
+ for(i = 0;i <= pc_pos; i++) {
+ if (gen_opc_instr_start[i]) {
+ fprintf(logfile, "0x%04x: " TARGET_FMT_lx "\n", i,
gen_opc_pc[i]);
+ }
+ }
+ fprintf(logfile, "spc=0x%08lx pc_pos=0x%x eip=" TARGET_FMT_lx "
cs_base=%x\n",
+ searched_pc, pc_pos, gen_opc_pc[pc_pos] - tb->cs_base,
+ (uint32_t)tb->cs_base);
+ }
+#endif
+ env->eip = gen_opc_pc[pc_pos] - tb->cs_base;
+ cc_op = gen_opc_cc_op[pc_pos];
+ if (cc_op != CC_OP_DYNAMIC)
+ env->cc_op = cc_op;
+}
diff --git a/translate-all.c b/translate-all.c
index 6a273a8..73e1d67 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -194,27 +194,7 @@ int cpu_restore_state(TranslationBlock *tb,
while (gen_opc_instr_start[j] == 0)
j--;
#if defined(TARGET_I386)
- {
- int cc_op;
-#ifdef DEBUG_DISAS
- if (loglevel & CPU_LOG_TB_OP) {
- int i;
- fprintf(logfile, "RESTORE:\n");
- for(i=0;i<=j; i++) {
- if (gen_opc_instr_start[i]) {
- fprintf(logfile, "0x%04x: " TARGET_FMT_lx "\n", i,
gen_opc_pc[i]);
- }
- }
- fprintf(logfile, "spc=0x%08lx j=0x%x eip=" TARGET_FMT_lx "
cs_base=%x\n",
- searched_pc, j, gen_opc_pc[j] - tb->cs_base,
- (uint32_t)tb->cs_base);
- }
-#endif
- env->eip = gen_opc_pc[j] - tb->cs_base;
- cc_op = gen_opc_cc_op[j];
- if (cc_op != CC_OP_DYNAMIC)
- env->cc_op = cc_op;
- }
+ gen_pc_load(env, tb, searched_pc, j, puc);
#elif defined(TARGET_ARM)
env->regs[15] = gen_opc_pc[j];
#elif defined(TARGET_SPARC)
--
1.5.0.6
- [Qemu-devel] [PATCH 0/10] Factorize code in translate.c, Glauber Costa, 2008/04/24
- [Qemu-devel] [PATCH 01/10] i386: replace code inside ifdef with generic function,
Glauber Costa <=
- [Qemu-devel] [PATCH 02/10] arm: replace code inside ifdef with generic function, Glauber Costa, 2008/04/24
- [Qemu-devel] [PATCH 03/10] sparc: replace code inside ifdef with generic function, Glauber Costa, 2008/04/24
- [Qemu-devel] [PATCH 04/10] ppc: replace code inside ifdef with generic function, Glauber Costa, 2008/04/24
- [Qemu-devel] [PATCH 05/10] m68k: replace code inside ifdef with generic function, Glauber Costa, 2008/04/24
- [Qemu-devel] [PATCH 06/10] mips: replace code inside ifdef with generic function, Glauber Costa, 2008/04/24
- [Qemu-devel] [PATCH 07/10] alpha: replace code inside ifdef with generic function, Glauber Costa, 2008/04/24
- [Qemu-devel] [PATCH 08/10] sh4: replace code inside ifdef with generic function, Glauber Costa, 2008/04/24
- [Qemu-devel] [PATCH 09/10] cris: replace code inside ifdef with generic function, Glauber Costa, 2008/04/24
- [Qemu-devel] [PATCH 10/10] remove arch-specific ifdefs from translate-all.c, Glauber Costa, 2008/04/24