From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JpEc9-0006Jg-N2 for qemu-devel@nongnu.org; Thu, 24 Apr 2008 23:28:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JpEc8-0006IW-Jp for qemu-devel@nongnu.org; Thu, 24 Apr 2008 23:28:44 -0400 Received: from [199.232.76.173] (port=42083 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JpEc8-0006IF-An for qemu-devel@nongnu.org; Thu, 24 Apr 2008 23:28:44 -0400 Received: from mx1.redhat.com ([66.187.233.31]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JpEc7-0000ph-UT for qemu-devel@nongnu.org; Thu, 24 Apr 2008 23:28:44 -0400 From: Glauber Costa Date: Fri, 25 Apr 2008 00:23:03 -0300 Message-Id: <12090938023558-git-send-email-gcosta@redhat.com> In-Reply-To: <12090937991633-git-send-email-gcosta@redhat.com> References: <12090937903925-git-send-email-gcosta@redhat.com> <12090937962588-git-send-email-gcosta@redhat.com> <12090937991633-git-send-email-gcosta@redhat.com> Subject: [Qemu-devel] [PATCH 03/10] sparc: replace code inside ifdef with generic function Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kvm-devel@lists.sourceforge.net 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-sparc/translate.c | 20 ++++++++++++++++++++ translate-all.c | 18 +----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 90d9278..6edf64d 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -4659,3 +4659,23 @@ void gen_intermediate_code_init(CPUSPARCState *env) gregnames[i]); } } + +void gen_pc_load(CPUState *env, TranslationBlock *tb, + unsigned long searched_pc, int pc_pos, void *puc) +{ + target_ulong npc; + env->pc = gen_opc_pc[pc_pos]; + npc = gen_opc_npc[pc_pos]; + if (npc == 1) { + /* dynamic NPC: already stored */ + } else if (npc == 2) { + target_ulong t2 = (target_ulong)(unsigned long)puc; + /* jump PC: use T2 and the jump targets of the translation */ + if (t2) + env->npc = gen_opc_jump_pc[0]; + else + env->npc = gen_opc_jump_pc[1]; + } else { + env->npc = npc; + } +} diff --git a/translate-all.c b/translate-all.c index e688318..92c8f1c 100644 --- a/translate-all.c +++ b/translate-all.c @@ -198,23 +198,7 @@ int cpu_restore_state(TranslationBlock *tb, #elif defined(TARGET_ARM) gen_pc_load(env, tb, searched_pc, j, puc); #elif defined(TARGET_SPARC) - { - target_ulong npc; - env->pc = gen_opc_pc[j]; - npc = gen_opc_npc[j]; - if (npc == 1) { - /* dynamic NPC: already stored */ - } else if (npc == 2) { - target_ulong t2 = (target_ulong)(unsigned long)puc; - /* jump PC: use T2 and the jump targets of the translation */ - if (t2) - env->npc = gen_opc_jump_pc[0]; - else - env->npc = gen_opc_jump_pc[1]; - } else { - env->npc = npc; - } - } + gen_pc_load(env, tb, searched_pc, j, puc); #elif defined(TARGET_PPC) { int type, c; -- 1.5.0.6