target/m68k: add explicit single and double precision operations (part 2)

Add fsabs, fdabs, fsneg, fdneg, fsmove and fdmove.

The value is converted using the new floatx80_round() function.

Backports commit 77bdb2292492fafc4bc0fbb4d8c44fdd0ef1fa8e from qemu
This commit is contained in:
Laurent Vivier 2018-03-03 21:01:17 -05:00 committed by Lioncash
parent 1d5e30f30c
commit 50b639098c
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
3 changed files with 74 additions and 8 deletions

View file

@ -178,6 +178,20 @@ void HELPER(set_fpcr)(CPUM68KState *env, uint32_t val)
set_floatx80_rounding_precision(old, &env->fp_status); \
} while (0)
void HELPER(fsround)(CPUM68KState *env, FPReg *res, FPReg *val)
{
PREC_BEGIN(32);
res->d = floatx80_round(val->d, &env->fp_status);
PREC_END();
}
void HELPER(fdround)(CPUM68KState *env, FPReg *res, FPReg *val)
{
PREC_BEGIN(64);
res->d = floatx80_round(val->d, &env->fp_status);
PREC_END();
}
void HELPER(fsqrt)(CPUM68KState *env, FPReg *res, FPReg *val)
{
res->d = floatx80_sqrt(val->d, &env->fp_status);
@ -199,12 +213,40 @@ void HELPER(fdsqrt)(CPUM68KState *env, FPReg *res, FPReg *val)
void HELPER(fabs)(CPUM68KState *env, FPReg *res, FPReg *val)
{
res->d = floatx80_abs(val->d);
res->d = floatx80_round(floatx80_abs(val->d), &env->fp_status);
}
void HELPER(fchs)(CPUM68KState *env, FPReg *res, FPReg *val)
void HELPER(fsabs)(CPUM68KState *env, FPReg *res, FPReg *val)
{
res->d = floatx80_chs(val->d);
PREC_BEGIN(32);
res->d = floatx80_round(floatx80_abs(val->d), &env->fp_status);
PREC_END();
}
void HELPER(fdabs)(CPUM68KState *env, FPReg *res, FPReg *val)
{
PREC_BEGIN(64);
res->d = floatx80_round(floatx80_abs(val->d), &env->fp_status);
PREC_END();
}
void HELPER(fneg)(CPUM68KState *env, FPReg *res, FPReg *val)
{
res->d = floatx80_round(floatx80_chs(val->d), &env->fp_status);
}
void HELPER(fsneg)(CPUM68KState *env, FPReg *res, FPReg *val)
{
PREC_BEGIN(32);
res->d = floatx80_round(floatx80_chs(val->d), &env->fp_status);
PREC_END();
}
void HELPER(fdneg)(CPUM68KState *env, FPReg *res, FPReg *val)
{
PREC_BEGIN(64);
res->d = floatx80_round(floatx80_chs(val->d), &env->fp_status);
PREC_END();
}
void HELPER(fadd)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)

View file

@ -25,13 +25,19 @@ DEF_HELPER_2(redf32, f32, env, fp)
DEF_HELPER_2(redf64, f64, env, fp)
DEF_HELPER_2(reds32, s32, env, fp)
DEF_HELPER_3(fsround, void, env, fp, fp)
DEF_HELPER_3(fdround, void, env, fp, fp)
DEF_HELPER_3(firound, void, env, fp, fp)
DEF_HELPER_3(fitrunc, void, env, fp, fp)
DEF_HELPER_3(fsqrt, void, env, fp, fp)
DEF_HELPER_3(fssqrt, void, env, fp, fp)
DEF_HELPER_3(fdsqrt, void, env, fp, fp)
DEF_HELPER_3(fabs, void, env, fp, fp)
DEF_HELPER_3(fchs, void, env, fp, fp)
DEF_HELPER_3(fsabs, void, env, fp, fp)
DEF_HELPER_3(fdabs, void, env, fp, fp)
DEF_HELPER_3(fneg, void, env, fp, fp)
DEF_HELPER_3(fsneg, void, env, fp, fp)
DEF_HELPER_3(fdneg, void, env, fp, fp)
DEF_HELPER_4(fadd, void, env, fp, fp, fp)
DEF_HELPER_4(fsadd, void, env, fp, fp, fp)
DEF_HELPER_4(fdadd, void, env, fp, fp, fp)

View file

@ -4772,9 +4772,15 @@ DISAS_INSN(fpu)
}
cpu_dest = gen_fp_ptr(s, REG(ext, 7));
switch (opmode) {
case 0: case 0x40: case 0x44: /* fmove */
case 0: /* fmove */
gen_fp_move(s, cpu_dest, cpu_src);
break;
case 0x40: /* fsmove */
gen_helper_fsround(tcg_ctx, tcg_ctx->cpu_env, cpu_dest, cpu_src);
break;
case 0x44: /* fdmove */
gen_helper_fdround(tcg_ctx, tcg_ctx->cpu_env, cpu_dest, cpu_src);
break;
case 1: /* fint */
gen_helper_firound(tcg_ctx, tcg_ctx->cpu_env, cpu_dest, cpu_src);
break;
@ -4790,11 +4796,23 @@ DISAS_INSN(fpu)
case 0x45: /* fdsqrt */
gen_helper_fdsqrt(tcg_ctx, tcg_ctx->cpu_env, cpu_dest, cpu_src);
break;
case 0x18: case 0x58: case 0x5c: /* fabs */
case 0x18: /* fabs */
gen_helper_fabs(tcg_ctx, tcg_ctx->cpu_env, cpu_dest, cpu_src);
break;
case 0x1a: case 0x5a: case 0x5e: /* fneg */
gen_helper_fchs(tcg_ctx, tcg_ctx->cpu_env, cpu_dest, cpu_src);
case 0x58: /* fsabs */
gen_helper_fsabs(tcg_ctx, tcg_ctx->cpu_env, cpu_dest, cpu_src);
break;
case 0x5c: /* fdabs */
gen_helper_fdabs(tcg_ctx, tcg_ctx->cpu_env, cpu_dest, cpu_src);
break;
case 0x1a: /* fneg */
gen_helper_fneg(tcg_ctx, tcg_ctx->cpu_env, cpu_dest, cpu_src);
break;
case 0x5a: /* fsneg */
gen_helper_fsneg(tcg_ctx, tcg_ctx->cpu_env, cpu_dest, cpu_src);
break;
case 0x5e: /* fdneg */
gen_helper_fdneg(tcg_ctx, tcg_ctx->cpu_env, cpu_dest, cpu_src);
break;
case 0x20: /* fdiv */
gen_helper_fdiv(tcg_ctx, tcg_ctx->cpu_env, cpu_dest, cpu_src, cpu_dest);