Commit 06dca6a7c1acd2301cbf5fe06d6cda2833c958be

Authored by aurel32
1 parent 6527f6ea

target-ppc: convert dcr load/store to TCG

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5893 c046a42c-6fe2-441c-8c8c-71466251a162
target-ppc/helper.h
@@ -181,4 +181,7 @@ DEF_HELPER_2(divo, tl, tl, tl) @@ -181,4 +181,7 @@ DEF_HELPER_2(divo, tl, tl, tl)
181 DEF_HELPER_2(divs, tl, tl, tl) 181 DEF_HELPER_2(divs, tl, tl, tl)
182 DEF_HELPER_2(divso, tl, tl, tl) 182 DEF_HELPER_2(divso, tl, tl, tl)
183 183
  184 +DEF_HELPER_1(load_dcr, tl, tl);
  185 +DEF_HELPER_2(store_dcr, void, tl, tl);
  186 +
184 #include "def-helper.h" 187 #include "def-helper.h"
target-ppc/op.c
@@ -349,18 +349,6 @@ void OPPROTO op_POWER_mfsri (void) @@ -349,18 +349,6 @@ void OPPROTO op_POWER_mfsri (void)
349 #endif 349 #endif
350 350
351 /* PowerPC 4xx specific micro-ops */ 351 /* PowerPC 4xx specific micro-ops */
352 -void OPPROTO op_load_dcr (void)  
353 -{  
354 - do_load_dcr();  
355 - RETURN();  
356 -}  
357 -  
358 -void OPPROTO op_store_dcr (void)  
359 -{  
360 - do_store_dcr();  
361 - RETURN();  
362 -}  
363 -  
364 #if !defined(CONFIG_USER_ONLY) 352 #if !defined(CONFIG_USER_ONLY)
365 void OPPROTO op_440_tlbre (void) 353 void OPPROTO op_440_tlbre (void)
366 { 354 {
target-ppc/op_helper.c
@@ -1756,9 +1756,9 @@ target_ulong helper_602_mfrom (target_ulong arg) @@ -1756,9 +1756,9 @@ target_ulong helper_602_mfrom (target_ulong arg)
1756 /* Embedded PowerPC specific helpers */ 1756 /* Embedded PowerPC specific helpers */
1757 1757
1758 /* XXX: to be improved to check access rights when in user-mode */ 1758 /* XXX: to be improved to check access rights when in user-mode */
1759 -void do_load_dcr (void) 1759 +target_ulong helper_load_dcr (target_ulong dcrn)
1760 { 1760 {
1761 - target_ulong val; 1761 + target_ulong val = 0;
1762 1762
1763 if (unlikely(env->dcr_env == NULL)) { 1763 if (unlikely(env->dcr_env == NULL)) {
1764 if (loglevel != 0) { 1764 if (loglevel != 0) {
@@ -1766,18 +1766,17 @@ void do_load_dcr (void) @@ -1766,18 +1766,17 @@ void do_load_dcr (void)
1766 } 1766 }
1767 raise_exception_err(env, POWERPC_EXCP_PROGRAM, 1767 raise_exception_err(env, POWERPC_EXCP_PROGRAM,
1768 POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL); 1768 POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL);
1769 - } else if (unlikely(ppc_dcr_read(env->dcr_env, T0, &val) != 0)) { 1769 + } else if (unlikely(ppc_dcr_read(env->dcr_env, dcrn, &val) != 0)) {
1770 if (loglevel != 0) { 1770 if (loglevel != 0) {
1771 fprintf(logfile, "DCR read error %d %03x\n", (int)T0, (int)T0); 1771 fprintf(logfile, "DCR read error %d %03x\n", (int)T0, (int)T0);
1772 } 1772 }
1773 raise_exception_err(env, POWERPC_EXCP_PROGRAM, 1773 raise_exception_err(env, POWERPC_EXCP_PROGRAM,
1774 POWERPC_EXCP_INVAL | POWERPC_EXCP_PRIV_REG); 1774 POWERPC_EXCP_INVAL | POWERPC_EXCP_PRIV_REG);
1775 - } else {  
1776 - T0 = val;  
1777 } 1775 }
  1776 + return val;
1778 } 1777 }
1779 1778
1780 -void do_store_dcr (void) 1779 +void helper_store_dcr (target_ulong dcrn, target_ulong val)
1781 { 1780 {
1782 if (unlikely(env->dcr_env == NULL)) { 1781 if (unlikely(env->dcr_env == NULL)) {
1783 if (loglevel != 0) { 1782 if (loglevel != 0) {
@@ -1785,7 +1784,7 @@ void do_store_dcr (void) @@ -1785,7 +1784,7 @@ void do_store_dcr (void)
1785 } 1784 }
1786 raise_exception_err(env, POWERPC_EXCP_PROGRAM, 1785 raise_exception_err(env, POWERPC_EXCP_PROGRAM,
1787 POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL); 1786 POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL);
1788 - } else if (unlikely(ppc_dcr_write(env->dcr_env, T0, T1) != 0)) { 1787 + } else if (unlikely(ppc_dcr_write(env->dcr_env, dcrn, val) != 0)) {
1789 if (loglevel != 0) { 1788 if (loglevel != 0) {
1790 fprintf(logfile, "DCR write error %d %03x\n", (int)T0, (int)T0); 1789 fprintf(logfile, "DCR write error %d %03x\n", (int)T0, (int)T0);
1791 } 1790 }
target-ppc/op_helper.h
@@ -41,8 +41,6 @@ void do_440_tlbwe (int word); @@ -41,8 +41,6 @@ void do_440_tlbwe (int word);
41 #endif 41 #endif
42 42
43 /* PowerPC 4xx specific helpers */ 43 /* PowerPC 4xx specific helpers */
44 -void do_load_dcr (void);  
45 -void do_store_dcr (void);  
46 #if !defined(CONFIG_USER_ONLY) 44 #if !defined(CONFIG_USER_ONLY)
47 void do_4xx_tlbre_lo (void); 45 void do_4xx_tlbre_lo (void);
48 void do_4xx_tlbre_hi (void); 46 void do_4xx_tlbre_hi (void);
target-ppc/translate.c
@@ -5625,15 +5625,16 @@ GEN_HANDLER(mfdcr, 0x1F, 0x03, 0x0A, 0x00000001, PPC_DCR) @@ -5625,15 +5625,16 @@ GEN_HANDLER(mfdcr, 0x1F, 0x03, 0x0A, 0x00000001, PPC_DCR)
5625 #if defined(CONFIG_USER_ONLY) 5625 #if defined(CONFIG_USER_ONLY)
5626 GEN_EXCP_PRIVREG(ctx); 5626 GEN_EXCP_PRIVREG(ctx);
5627 #else 5627 #else
5628 - uint32_t dcrn = SPR(ctx->opcode);  
5629 - 5628 + TCGv dcrn;
5630 if (unlikely(!ctx->supervisor)) { 5629 if (unlikely(!ctx->supervisor)) {
5631 GEN_EXCP_PRIVREG(ctx); 5630 GEN_EXCP_PRIVREG(ctx);
5632 return; 5631 return;
5633 } 5632 }
5634 - tcg_gen_movi_tl(cpu_T[0], dcrn);  
5635 - gen_op_load_dcr();  
5636 - tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); 5633 + /* NIP cannot be restored if the memory exception comes from an helper */
  5634 + gen_update_nip(ctx, ctx->nip - 4);
  5635 + dcrn = tcg_const_tl(SPR(ctx->opcode));
  5636 + gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], dcrn);
  5637 + tcg_temp_free(dcrn);
5637 #endif 5638 #endif
5638 } 5639 }
5639 5640
@@ -5643,15 +5644,16 @@ GEN_HANDLER(mtdcr, 0x1F, 0x03, 0x0E, 0x00000001, PPC_DCR) @@ -5643,15 +5644,16 @@ GEN_HANDLER(mtdcr, 0x1F, 0x03, 0x0E, 0x00000001, PPC_DCR)
5643 #if defined(CONFIG_USER_ONLY) 5644 #if defined(CONFIG_USER_ONLY)
5644 GEN_EXCP_PRIVREG(ctx); 5645 GEN_EXCP_PRIVREG(ctx);
5645 #else 5646 #else
5646 - uint32_t dcrn = SPR(ctx->opcode);  
5647 - 5647 + TCGv dcrn;
5648 if (unlikely(!ctx->supervisor)) { 5648 if (unlikely(!ctx->supervisor)) {
5649 GEN_EXCP_PRIVREG(ctx); 5649 GEN_EXCP_PRIVREG(ctx);
5650 return; 5650 return;
5651 } 5651 }
5652 - tcg_gen_movi_tl(cpu_T[0], dcrn);  
5653 - tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);  
5654 - gen_op_store_dcr(); 5652 + /* NIP cannot be restored if the memory exception comes from an helper */
  5653 + gen_update_nip(ctx, ctx->nip - 4);
  5654 + dcrn = tcg_const_tl(SPR(ctx->opcode));
  5655 + gen_helper_store_dcr(dcrn, cpu_gpr[rS(ctx->opcode)]);
  5656 + tcg_temp_free(dcrn);
5655 #endif 5657 #endif
5656 } 5658 }
5657 5659
@@ -5666,9 +5668,9 @@ GEN_HANDLER(mfdcrx, 0x1F, 0x03, 0x08, 0x00000000, PPC_DCRX) @@ -5666,9 +5668,9 @@ GEN_HANDLER(mfdcrx, 0x1F, 0x03, 0x08, 0x00000000, PPC_DCRX)
5666 GEN_EXCP_PRIVREG(ctx); 5668 GEN_EXCP_PRIVREG(ctx);
5667 return; 5669 return;
5668 } 5670 }
5669 - tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);  
5670 - gen_op_load_dcr();  
5671 - tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); 5671 + /* NIP cannot be restored if the memory exception comes from an helper */
  5672 + gen_update_nip(ctx, ctx->nip - 4);
  5673 + gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
5672 /* Note: Rc update flag set leads to undefined state of Rc0 */ 5674 /* Note: Rc update flag set leads to undefined state of Rc0 */
5673 #endif 5675 #endif
5674 } 5676 }
@@ -5684,9 +5686,9 @@ GEN_HANDLER(mtdcrx, 0x1F, 0x03, 0x0C, 0x00000000, PPC_DCRX) @@ -5684,9 +5686,9 @@ GEN_HANDLER(mtdcrx, 0x1F, 0x03, 0x0C, 0x00000000, PPC_DCRX)
5684 GEN_EXCP_PRIVREG(ctx); 5686 GEN_EXCP_PRIVREG(ctx);
5685 return; 5687 return;
5686 } 5688 }
5687 - tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);  
5688 - tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);  
5689 - gen_op_store_dcr(); 5689 + /* NIP cannot be restored if the memory exception comes from an helper */
  5690 + gen_update_nip(ctx, ctx->nip - 4);
  5691 + gen_helper_store_dcr(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
5690 /* Note: Rc update flag set leads to undefined state of Rc0 */ 5692 /* Note: Rc update flag set leads to undefined state of Rc0 */
5691 #endif 5693 #endif
5692 } 5694 }
@@ -5694,18 +5696,18 @@ GEN_HANDLER(mtdcrx, 0x1F, 0x03, 0x0C, 0x00000000, PPC_DCRX) @@ -5694,18 +5696,18 @@ GEN_HANDLER(mtdcrx, 0x1F, 0x03, 0x0C, 0x00000000, PPC_DCRX)
5694 /* mfdcrux (PPC 460) : user-mode access to DCR */ 5696 /* mfdcrux (PPC 460) : user-mode access to DCR */
5695 GEN_HANDLER(mfdcrux, 0x1F, 0x03, 0x09, 0x00000000, PPC_DCRUX) 5697 GEN_HANDLER(mfdcrux, 0x1F, 0x03, 0x09, 0x00000000, PPC_DCRUX)
5696 { 5698 {
5697 - tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);  
5698 - gen_op_load_dcr();  
5699 - tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_T[0]); 5699 + /* NIP cannot be restored if the memory exception comes from an helper */
  5700 + gen_update_nip(ctx, ctx->nip - 4);
  5701 + gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
5700 /* Note: Rc update flag set leads to undefined state of Rc0 */ 5702 /* Note: Rc update flag set leads to undefined state of Rc0 */
5701 } 5703 }
5702 5704
5703 /* mtdcrux (PPC 460) : user-mode access to DCR */ 5705 /* mtdcrux (PPC 460) : user-mode access to DCR */
5704 GEN_HANDLER(mtdcrux, 0x1F, 0x03, 0x0D, 0x00000000, PPC_DCRUX) 5706 GEN_HANDLER(mtdcrux, 0x1F, 0x03, 0x0D, 0x00000000, PPC_DCRUX)
5705 { 5707 {
5706 - tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rA(ctx->opcode)]);  
5707 - tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rS(ctx->opcode)]);  
5708 - gen_op_store_dcr(); 5708 + /* NIP cannot be restored if the memory exception comes from an helper */
  5709 + gen_update_nip(ctx, ctx->nip - 4);
  5710 + gen_helper_store_dcr(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
5709 /* Note: Rc update flag set leads to undefined state of Rc0 */ 5711 /* Note: Rc update flag set leads to undefined state of Rc0 */
5710 } 5712 }
5711 5713