From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JpEcE-0006Qa-Qp for qemu-devel@nongnu.org; Thu, 24 Apr 2008 23:28:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JpEcD-0006PR-VN for qemu-devel@nongnu.org; Thu, 24 Apr 2008 23:28:50 -0400 Received: from [199.232.76.173] (port=42085 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JpEcD-0006P3-MH for qemu-devel@nongnu.org; Thu, 24 Apr 2008 23:28:49 -0400 Received: from mx1.redhat.com ([66.187.233.31]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JpEcD-0000qd-9R for qemu-devel@nongnu.org; Thu, 24 Apr 2008 23:28:49 -0400 From: Glauber Costa Date: Fri, 25 Apr 2008 00:23:04 -0300 Message-Id: <12090938052239-git-send-email-gcosta@redhat.com> In-Reply-To: <12090938023558-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> <12090938023558-git-send-email-gcosta@redhat.com> Subject: [Qemu-devel] [PATCH 04/10] ppc: 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-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