target/m68k: add fmovecr

fmovecr moves a floating point constant from the
FPU ROM to a floating point register.

Backports commit 9d403660d91229922c2786e81c23cc9dd8e644f1 from qemu
This commit is contained in:
Laurent Vivier 2018-03-03 20:49:30 -05:00 committed by Lioncash
parent ed3e8ab460
commit 0b62df7f30
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
3 changed files with 59 additions and 1 deletions

View file

@ -23,6 +23,46 @@
#include "exec/helper-proto.h"
#include "exec/exec-all.h"
/* Undefined offsets may be different on various FPU.
* On 68040 they return 0.0 (floatx80_zero)
*/
static const floatx80 fpu_rom[128] = {
floatx80_pi, /* Pi */
{0, 0}, {0, 0},
{0, 0}, {0, 0}, {0, 0}, {0, 0},
{0, 0}, {0, 0}, {0, 0}, {0, 0},
make_floatx80(0x3ffd, 0x9a209a84fbcff798ULL), /* Log10(2) */
make_floatx80(0x4000, 0xadf85458a2bb4a9aULL), /* e */
make_floatx80(0x3fff, 0xb8aa3b295c17f0bcULL), /* Log2(e) */
make_floatx80(0x3ffd, 0xde5bd8a937287195ULL), /* Log10(e) */
floatx80_zero, /* Zero */
{0, 0}, {0, 0}, {0, 0}, {0, 0},
{0, 0}, {0, 0}, {0, 0}, {0, 0},
{0, 0}, {0, 0}, {0, 0}, {0, 0},
{0, 0}, {0, 0}, {0, 0}, {0, 0},
{0, 0}, {0, 0}, {0, 0}, {0, 0},
{0, 0}, {0, 0}, {0, 0}, {0, 0},
{0, 0}, {0, 0}, {0, 0}, {0, 0},
{0, 0}, {0, 0}, {0, 0}, {0, 0},
floatx80_ln2, /* ln(2) */
make_floatx80(0x4000, 0x935d8dddaaa8ac17ULL), /* ln(10) */
floatx80_one, /* 10^0 */
make_floatx80(0x4002, 0xa000000000000000ULL), /* 10^1 */
make_floatx80(0x4005, 0xc800000000000000ULL), /* 10^2 */
make_floatx80(0x400c, 0x9c40000000000000ULL), /* 10^4 */
make_floatx80(0x4019, 0xbebc200000000000ULL), /* 10^8 */
make_floatx80(0x4034, 0x8e1bc9bf04000000ULL), /* 10^16 */
make_floatx80(0x4069, 0x9dc5ada82b70b59eULL), /* 10^32 */
make_floatx80(0x40d3, 0xc2781f49ffcfa6d5ULL), /* 10^64 */
make_floatx80(0x41a8, 0x93ba47c980e98ce0ULL), /* 10^128 */
make_floatx80(0x4351, 0xaa7eebfb9df9de8eULL), /* 10^256 */
make_floatx80(0x46a3, 0xe319a0aea60e91c7ULL), /* 10^512 */
make_floatx80(0x4d48, 0xc976758681750c17ULL), /* 10^1024 */
make_floatx80(0x5a92, 0x9e8b3b5dc53d5de5ULL), /* 10^2048 */
make_floatx80(0x7525, 0xc46052028a20979bULL), /* 10^4096 */
};
int32_t HELPER(reds32)(CPUM68KState *env, FPReg *val)
{
return floatx80_to_int32(val->d, &env->fp_status);
@ -204,3 +244,9 @@ void HELPER(ftst)(CPUM68KState *env, FPReg *val)
}
env->fpsr = (env->fpsr & ~FPSR_CC_MASK) | cc;
}
void HELPER(fconst)(CPUM68KState *env, FPReg *val, uint32_t offset)
{
val->d = fpu_rom[offset];
}

View file

@ -37,6 +37,7 @@ DEF_HELPER_4(fdiv, void, env, fp, fp, fp)
DEF_HELPER_FLAGS_3(fcmp, TCG_CALL_NO_RWG, void, env, fp, fp)
DEF_HELPER_FLAGS_2(set_fpcr, TCG_CALL_NO_RWG, void, env, i32)
DEF_HELPER_FLAGS_2(ftst, TCG_CALL_NO_RWG, void, env, fp)
DEF_HELPER_3(fconst, void, env, fp, i32)
DEF_HELPER_3(mac_move, void, env, i32, i32)
DEF_HELPER_3(macmulf, i64, env, i32, i32)

View file

@ -4695,10 +4695,21 @@ DISAS_INSN(fpu)
ext = read_im16(env, s);
opmode = ext & 0x7f;
switch ((ext >> 13) & 7) {
case 0: case 2:
case 0:
break;
case 1:
goto undef;
case 2:
if (insn == 0xf200 && (ext & 0xfc00) == 0x5c00) {
/* fmovecr */
TCGv rom_offset = tcg_const_i32(tcg_ctx, opmode);
cpu_dest = gen_fp_ptr(s, REG(ext, 7));
gen_helper_fconst(tcg_ctx, tcg_ctx->cpu_env, cpu_dest, rom_offset);
tcg_temp_free_ptr(tcg_ctx, cpu_dest);
tcg_temp_free(tcg_ctx, rom_offset);
return;
}
break;
case 3: /* fmove out */
cpu_src = gen_fp_ptr(s, REG(ext, 7));
opsize = ext_opsize(ext, 10);