From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L909i-00025C-TI for qemu-devel@nongnu.org; Sat, 06 Dec 2008 11:37:22 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L909g-00024B-R1 for qemu-devel@nongnu.org; Sat, 06 Dec 2008 11:37:22 -0500 Received: from [199.232.76.173] (port=57618 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L909g-00023x-F9 for qemu-devel@nongnu.org; Sat, 06 Dec 2008 11:37:20 -0500 Received: from savannah.gnu.org ([199.232.41.3]:50715 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L909g-0006a4-1o for qemu-devel@nongnu.org; Sat, 06 Dec 2008 11:37:20 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1L909f-0006cQ-IV for qemu-devel@nongnu.org; Sat, 06 Dec 2008 16:37:19 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1L909f-0006cM-6P for qemu-devel@nongnu.org; Sat, 06 Dec 2008 16:37:19 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Sat, 06 Dec 2008 16:37:19 +0000 Subject: [Qemu-devel] [5893] target-ppc: convert dcr load/store to TCG 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 Revision: 5893 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5893 Author: aurel32 Date: 2008-12-06 16:37:18 +0000 (Sat, 06 Dec 2008) Log Message: ----------- target-ppc: convert dcr load/store to TCG Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/target-ppc/helper.h trunk/target-ppc/op.c trunk/target-ppc/op_helper.c trunk/target-ppc/op_helper.h trunk/target-ppc/translate.c Modified: trunk/target-ppc/helper.h =================================================================== --- trunk/target-ppc/helper.h 2008-12-06 13:03:35 UTC (rev 5892) +++ trunk/target-ppc/helper.h 2008-12-06 16:37:18 UTC (rev 5893) @@ -181,4 +181,7 @@ DEF_HELPER_2(divs, tl, tl, tl) DEF_HELPER_2(divso, tl, tl, tl) +DEF_HELPER_1(load_dcr, tl, tl); +DEF_HELPER_2(store_dcr, void, tl, tl); + #include "def-helper.h" Modified: trunk/target-ppc/op.c =================================================================== --- trunk/target-ppc/op.c 2008-12-06 13:03:35 UTC (rev 5892) +++ trunk/target-ppc/op.c 2008-12-06 16:37:18 UTC (rev 5893) @@ -349,18 +349,6 @@ #endif /* PowerPC 4xx specific micro-ops */ -void OPPROTO op_load_dcr (void) -{ - do_load_dcr(); - RETURN(); -} - -void OPPROTO op_store_dcr (void) -{ - do_store_dcr(); - RETURN(); -} - #if !defined(CONFIG_USER_ONLY) void OPPROTO op_440_tlbre (void) { Modified: trunk/target-ppc/op_helper.c =================================================================== --- trunk/target-ppc/op_helper.c 2008-12-06 13:03:35 UTC (rev 5892) +++ trunk/target-ppc/op_helper.c 2008-12-06 16:37:18 UTC (rev 5893) @@ -1756,9 +1756,9 @@ /* Embedded PowerPC specific helpers */ /* XXX: to be improved to check access rights when in user-mode */ -void do_load_dcr (void) +target_ulong helper_load_dcr (target_ulong dcrn) { - target_ulong val; + target_ulong val = 0; if (unlikely(env->dcr_env == NULL)) { if (loglevel != 0) { @@ -1766,18 +1766,17 @@ } raise_exception_err(env, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL); - } else if (unlikely(ppc_dcr_read(env->dcr_env, T0, &val) != 0)) { + } else if (unlikely(ppc_dcr_read(env->dcr_env, dcrn, &val) != 0)) { if (loglevel != 0) { fprintf(logfile, "DCR read error %d %03x\n", (int)T0, (int)T0); } raise_exception_err(env, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_INVAL | POWERPC_EXCP_PRIV_REG); - } else { - T0 = val; } + return val; } -void do_store_dcr (void) +void helper_store_dcr (target_ulong dcrn, target_ulong val) { if (unlikely(env->dcr_env == NULL)) { if (loglevel != 0) { @@ -1785,7 +1784,7 @@ } raise_exception_err(env, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL); - } else if (unlikely(ppc_dcr_write(env->dcr_env, T0, T1) != 0)) { + } else if (unlikely(ppc_dcr_write(env->dcr_env, dcrn, val) != 0)) { if (loglevel != 0) { fprintf(logfile, "DCR write error %d %03x\n", (int)T0, (int)T0); } Modified: trunk/target-ppc/op_helper.h =================================================================== --- trunk/target-ppc/op_helper.h 2008-12-06 13:03:35 UTC (rev 5892) +++ trunk/target-ppc/op_helper.h 2008-12-06 16:37:18 UTC (rev 5893) @@ -41,8 +41,6 @@ #endif /* PowerPC 4xx specific helpers */ -void do_load_dcr (void); -void do_store_dcr (void); #if !defined(CONFIG_USER_ONLY) void do_4xx_tlbre_lo (void); void do_4xx_tlbre_hi (void); Modified: trunk/target-ppc/translate.c =================================================================== --- trunk/target-ppc/translate.c 2008-12-06 13:03:35 UTC (rev 5892) +++ trunk/target-ppc/translate.c 2008-12-06 16:37:18 UTC (rev 5893) @@ -5625,15 +5625,16 @@ #if defined(CONFIG_USER_ONLY) GEN_EXCP_PRIVREG(ctx); #else - uint32_t dcrn = SPR(ctx->opcode); - + TCGv dcrn; if (unlikely(!ctx->supervisor)) { GEN_EXCP_PRIVREG(ctx); return; } - tcg_gen_movi_tl(cpu_T[0], dcrn); - gen_op_load_dcr(); - tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); + /* NIP cannot be restored if the memory exception comes from an helper */ + gen_update_nip(ctx, ctx->nip - 4); + dcrn = tcg_const_tl(SPR(ctx->opcode)); + gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], dcrn); + tcg_temp_free(dcrn); #endif } @@ -5643,15 +5644,16 @@ #if defined(CONFIG_USER_ONLY) GEN_EXCP_PRIVREG(ctx); #else - uint32_t dcrn = SPR(ctx->opcode); - + TCGv dcrn; if (unlikely(!ctx->supervisor)) { GEN_EXCP_PRIVREG(ctx); return; } - tcg_gen_movi_tl(cpu_T[0], dcrn); - tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]); - gen_op_store_dcr(); + /* NIP cannot be restored if the memory exception comes from an helper */ + gen_update_nip(ctx, ctx->nip - 4); + dcrn = tcg_const_tl(SPR(ctx->opcode)); + gen_helper_store_dcr(dcrn, cpu_gpr[rS(ctx->opcode)]); + tcg_temp_free(dcrn); #endif } @@ -5666,9 +5668,9 @@ GEN_EXCP_PRIVREG(ctx); return; } - tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); - gen_op_load_dcr(); - tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); + /* NIP cannot be restored if the memory exception comes from an helper */ + gen_update_nip(ctx, ctx->nip - 4); + gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); /* Note: Rc update flag set leads to undefined state of Rc0 */ #endif } @@ -5684,9 +5686,9 @@ GEN_EXCP_PRIVREG(ctx); return; } - tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); - tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]); - gen_op_store_dcr(); + /* NIP cannot be restored if the memory exception comes from an helper */ + gen_update_nip(ctx, ctx->nip - 4); + gen_helper_store_dcr(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); /* Note: Rc update flag set leads to undefined state of Rc0 */ #endif } @@ -5694,18 +5696,18 @@ /* mfdcrux (PPC 460) : user-mode access to DCR */ GEN_HANDLER(mfdcrux, 0x1F, 0x03, 0x09, 0x00000000, PPC_DCRUX) { - tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); - gen_op_load_dcr(); - tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); + /* NIP cannot be restored if the memory exception comes from an helper */ + gen_update_nip(ctx, ctx->nip - 4); + gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); /* Note: Rc update flag set leads to undefined state of Rc0 */ } /* mtdcrux (PPC 460) : user-mode access to DCR */ GEN_HANDLER(mtdcrux, 0x1F, 0x03, 0x0D, 0x00000000, PPC_DCRUX) { - tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]); - tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]); - gen_op_store_dcr(); + /* NIP cannot be restored if the memory exception comes from an helper */ + gen_update_nip(ctx, ctx->nip - 4); + gen_helper_store_dcr(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); /* Note: Rc update flag set leads to undefined state of Rc0 */ }