added cpu_model parameter to cpu_init()
[qemu] / target-sh4 / translate.c
index 5b35cf2..8d5e99e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  SH4 translation
- * 
+ *
  *  Copyright (c) 2005 Samuel Tardieu
  *
  * This library is free software; you can redistribute it and/or
@@ -141,7 +141,7 @@ void cpu_sh4_reset(CPUSH4State * env)
     env->mmucr = 0;
 }
 
-CPUSH4State *cpu_sh4_init(void)
+CPUSH4State *cpu_sh4_init(const char *cpu_model)
 {
     CPUSH4State *env;
 
@@ -277,7 +277,7 @@ void decode_opc(DisasContext * ctx)
     case 0x0038:               /* ldtlb */
        assert(0);              /* XXXXX */
        return;
-    case 0x004b:               /* rte */
+    case 0x002b:               /* rte */
        CHECK_NOT_DELAY_SLOT gen_op_rte();
        ctx->flags |= DELAY_SLOT;
        ctx->delayed_pc = (uint32_t) - 1;
@@ -647,11 +647,8 @@ void decode_opc(DisasContext * ctx)
        gen_op_movl_rN_T0(REG(B7_4));
        gen_op_xor_T0_rN(REG(B11_8));
        return;
-    case 0xf00c:               /* fmov {F,D,X}Rm,{F,D,X}Rn */
-       if (ctx->fpscr & FPSCR_PR) {
-           gen_op_fmov_drN_DT0(XREG(B7_4));
-           gen_op_fmov_DT0_drN(XREG(B11_8));
-       } else if (ctx->fpscr & FPSCR_SZ) {
+    case 0xf00c: /* fmov {F,D,X}Rm,{F,D,X}Rn - FPSCR: Nothing */
+       if (ctx->fpscr & FPSCR_SZ) {
            if (ctx->opcode & 0x0110)
                break; /* illegal instruction */
            gen_op_fmov_drN_DT0(DREG(B7_4));
@@ -661,12 +658,8 @@ void decode_opc(DisasContext * ctx)
            gen_op_fmov_FT0_frN(FREG(B11_8));
        }
        return;
-    case 0xf00a:               /* fmov {F,D,X}Rm,@Rn */
-       if (ctx->fpscr & FPSCR_PR) {
-           gen_op_fmov_drN_DT0(XREG(B7_4));
-           gen_op_movl_rN_T1(REG(B11_8));
-           gen_op_stfq_DT0_T1(ctx);
-       } else if (ctx->fpscr & FPSCR_SZ) {
+    case 0xf00a: /* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */
+       if (ctx->fpscr & FPSCR_SZ) {
            if (ctx->opcode & 0x0010)
                break; /* illegal instruction */
            gen_op_fmov_drN_DT0(DREG(B7_4));
@@ -678,12 +671,8 @@ void decode_opc(DisasContext * ctx)
            gen_op_stfl_FT0_T1(ctx);
        }
        return;
-    case 0xf008:               /* fmov @Rm,{F,D,X}Rn */
-       if (ctx->fpscr & FPSCR_PR) {
-           gen_op_movl_rN_T0(REG(B7_4));
-           gen_op_ldfq_T0_DT0(ctx);
-           gen_op_fmov_DT0_drN(XREG(B11_8));
-       } else if (ctx->fpscr & FPSCR_SZ) {
+    case 0xf008: /* fmov @Rm,{F,D,X}Rn - FPSCR: Nothing */
+       if (ctx->fpscr & FPSCR_SZ) {
            if (ctx->opcode & 0x0100)
                break; /* illegal instruction */
            gen_op_movl_rN_T0(REG(B7_4));
@@ -695,13 +684,8 @@ void decode_opc(DisasContext * ctx)
            gen_op_fmov_FT0_frN(FREG(B11_8));
        }
        return;
-    case 0xf009:               /* fmov @Rm+,{F,D,X}Rn */
-       if (ctx->fpscr & FPSCR_PR) {
-           gen_op_movl_rN_T0(REG(B7_4));
-           gen_op_ldfq_T0_DT0(ctx);
-           gen_op_fmov_DT0_drN(XREG(B11_8));
-           gen_op_inc8_rN(REG(B7_4));
-       } else if (ctx->fpscr & FPSCR_SZ) {
+    case 0xf009: /* fmov @Rm+,{F,D,X}Rn - FPSCR: Nothing */
+       if (ctx->fpscr & FPSCR_SZ) {
            if (ctx->opcode & 0x0100)
                break; /* illegal instruction */
            gen_op_movl_rN_T0(REG(B7_4));
@@ -715,13 +699,8 @@ void decode_opc(DisasContext * ctx)
            gen_op_inc4_rN(REG(B7_4));
        }
        return;
-    case 0xf00b:               /* fmov {F,D,X}Rm,@-Rn */
-       if (ctx->fpscr & FPSCR_PR) {
-           gen_op_dec8_rN(REG(B11_8));
-           gen_op_fmov_drN_DT0(XREG(B7_4));
-           gen_op_movl_rN_T1(REG(B11_8));
-           gen_op_stfq_DT0_T1(ctx);
-       } else if (ctx->fpscr & FPSCR_SZ) {
+    case 0xf00b: /* fmov {F,D,X}Rm,@-Rn - FPSCR: Nothing */
+       if (ctx->fpscr & FPSCR_SZ) {
            if (ctx->opcode & 0x0100)
                break; /* illegal instruction */
            gen_op_dec8_rN(REG(B11_8));
@@ -735,13 +714,8 @@ void decode_opc(DisasContext * ctx)
            gen_op_stfl_FT0_T1(ctx);
        }
        return;
-    case 0xf006:               /* fmov @(R0,Rm),{F,D,X}Rm */
-       if (ctx->fpscr & FPSCR_PR) {
-           gen_op_movl_rN_T0(REG(B7_4));
-           gen_op_add_rN_T0(REG(0));
-           gen_op_ldfq_T0_DT0(ctx);
-           gen_op_fmov_DT0_drN(XREG(B11_8));
-       } else if (ctx->fpscr & FPSCR_SZ) {
+    case 0xf006: /* fmov @(R0,Rm),{F,D,X}Rm - FPSCR: Nothing */
+       if (ctx->fpscr & FPSCR_SZ) {
            if (ctx->opcode & 0x0100)
                break; /* illegal instruction */
            gen_op_movl_rN_T0(REG(B7_4));
@@ -755,13 +729,8 @@ void decode_opc(DisasContext * ctx)
            gen_op_fmov_FT0_frN(FREG(B11_8));
        }
        return;
-    case 0xf007:               /* fmov {F,D,X}Rn,@(R0,Rn) */
-       if (ctx->fpscr & FPSCR_PR) {
-           gen_op_fmov_drN_DT0(XREG(B7_4));
-           gen_op_movl_rN_T1(REG(B11_8));
-           gen_op_add_rN_T1(REG(0));
-           gen_op_stfq_DT0_T1(ctx);
-       } else if (ctx->fpscr & FPSCR_SZ) {
+    case 0xf007: /* fmov {F,D,X}Rn,@(R0,Rn) - FPSCR: Nothing */
+       if (ctx->fpscr & FPSCR_SZ) {
            if (ctx->opcode & 0x0010)
                break; /* illegal instruction */
            gen_op_fmov_drN_DT0(DREG(B7_4));
@@ -775,12 +744,12 @@ void decode_opc(DisasContext * ctx)
            gen_op_stfl_FT0_T1(ctx);
        }
        return;
-    case 0xf000:               /* fadd Rm,Rn */
-    case 0xf001:               /* fsub Rm,Rn */
-    case 0xf002:               /* fmul Rm,Rn */
-    case 0xf003:               /* fdiv Rm,Rn */
-    case 0xf004:               /* fcmp/eq Rm,Rn */
-    case 0xf005:               /* fcmp/gt Rm,Rn */
+    case 0xf000: /* fadd Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */
+    case 0xf001: /* fsub Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */
+    case 0xf002: /* fmul Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */
+    case 0xf003: /* fdiv Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */
+    case 0xf004: /* fcmp/eq Rm,Rn - FPSCR: R[PR,Enable.V]/W[Cause,Flag] */
+    case 0xf005: /* fcmp/gt Rm,Rn - FPSCR: R[PR,Enable.V]/W[Cause,Flag] */
        if (ctx->fpscr & FPSCR_PR) {
            if (ctx->opcode & 0x0110)
                break; /* illegal instruction */
@@ -910,10 +879,10 @@ void decode_opc(DisasContext * ctx)
        gen_op_stw_T0_T1(ctx);
        return;
     case 0x8400:               /* mov.b @(disp,Rn),R0 */
-       gen_op_movl_rN_T0(REG(0));
-       gen_op_movl_rN_T1(REG(B7_4));
-       gen_op_addl_imm_T1(B3_0);
-       gen_op_stb_T0_T1(ctx);
+       gen_op_movl_rN_T0(REG(B7_4));
+       gen_op_addl_imm_T0(B3_0);
+       gen_op_ldb_T0_T0(ctx);
+       gen_op_movl_T0_rN(REG(0));
        return;
     case 0x8500:               /* mov.w @(disp,Rn),R0 */
        gen_op_movl_rN_T0(REG(B7_4));
@@ -1121,15 +1090,15 @@ void decode_opc(DisasContext * ctx)
     case 0x401b:               /* tas.b @Rn */
        gen_op_tasb_rN(REG(B11_8));
        return;
-    case 0xf00d:               /* fsts FPUL,FRn */
+    case 0xf00d: /* fsts FPUL,FRn - FPSCR: Nothing */
        gen_op_movl_fpul_FT0();
        gen_op_fmov_FT0_frN(FREG(B11_8));
        return;
-    case 0xf01d:               /* flds FRm.FPUL */
+    case 0xf01d: /* flds FRm,FPUL - FPSCR: Nothing */
        gen_op_fmov_frN_FT0(FREG(B11_8));
        gen_op_movl_FT0_fpul();
        return;
-    case 0xf02d:               /* float FPUL,FRn/DRn */
+    case 0xf02d: /* float FPUL,FRn/DRn - FPSCR: R[PR,Enable.I]/W[Cause,Flag] */
        if (ctx->fpscr & FPSCR_PR) {
            if (ctx->opcode & 0x0100)
                break; /* illegal instruction */
@@ -1141,7 +1110,7 @@ void decode_opc(DisasContext * ctx)
            gen_op_fmov_FT0_frN(FREG(B11_8));
        }
        return;
-    case 0xf03d:               /* ftrc FRm/DRm,FPUL */
+    case 0xf03d: /* ftrc FRm/DRm,FPUL - FPSCR: R[PR,Enable.V]/W[Cause,Flag] */
        if (ctx->fpscr & FPSCR_PR) {
            if (ctx->opcode & 0x0100)
                break; /* illegal instruction */
@@ -1153,14 +1122,14 @@ void decode_opc(DisasContext * ctx)
            gen_op_ftrc_FT();
        }
        return;
-    case 0xf08d:               /* fldi0 FRn */
+    case 0xf08d: /* fldi0 FRn - FPSCR: R[PR] */
        if (!(ctx->fpscr & FPSCR_PR)) {
            gen_op_movl_imm_T0(0);
            gen_op_fmov_T0_frN(FREG(B11_8));
            return;
        }
        break;
-    case 0xf09d:               /* fldi1 FRn */
+    case 0xf09d: /* fldi1 FRn - FPSCR: R[PR] */
        if (!(ctx->fpscr & FPSCR_PR)) {
            gen_op_movl_imm_T0(0x3f800000);
            gen_op_fmov_T0_frN(FREG(B11_8));
@@ -1273,7 +1242,6 @@ gen_intermediate_code_internal(CPUState * env, TranslationBlock * tb,
         ii++;
         while (ii <= i)
             gen_opc_instr_start[ii++] = 0;
-        tb->size = 0;
     } else {
         tb->size = ctx.pc - pc_start;
     }