implement 680x0 FPU (part 5)
cover implement 680x0 FPU (part 5)
Implement fcosh, fsinh, ftanh, fatanh, facos, fasin, fatan, fsincos, fcos, fsin, ftan.
This is the last series to implement FPU instructions for 680x0...
As previously, all the floatx80 functions are copied from "Previous", the NeXT Computer Emulator, and written by Andreas Grabher.
I did not improve or clean up the code, it's a simple port of Andreas' work from "Previous".
I think this series will need some improvemants in the future:
for intance sin and cos functions can be merged in sincos function (and we have unmodified "adjn" variable in floatx80_cos() and floatx80_sin() that can be removed otherwise).
"Previous" code I have ported to QEMU can be found in (r844):
http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/
"Previous" code is a C implementation of m68040 assembly language functions found in ($NetBSD: copyright.s,v 1.2 1994/10/26 07:48:57 cgd Exp)
https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/m68k/fpsp/
All the original work is under SoftFloat-2a license, and additional work under BSD license or GPL-v2-or-later license.
All softfloat new functions are added in target/m68k as they are derived from m68k code.
I have compared results of these instructions from a real m68040 and from QEMU, and they match (sincos differs [1] because in QEMU we compute it as sin and cos, and on m68040 sin and cos results differ also with sincos results. It looks like a rounding problem, perhaps a bug in m68040 FPU? or in my test program?)
I know this will need more work, but for the moment I only would like to provide these new instructions to the maintream of QEMU.
[1] Example:
sincos -6.125952 -> (0.156586, 0.987664)
QEMU:
sincos c0010000c407cd1182c2bb27 -> 3ffc0000a05812beea449a4d
3ffe0000fcd791d65887d19a
sin c0010000c407cd1182c2bb27 -> 3ffc0000a05812beea449a4d
cos c0010000c407cd1182c2bb27 -> 3ffe0000fcd791d65887d19a
m68040:
sincos c0010000c407cd1182c2bb27 -> 3ffc0000a05812beea449a4d
3ffe0000fcd791d65887d199 <<--
sin c0010000c407cd1182c2bb27 -> 3ffc0000a05812beea449a4d
cos c0010000c407cd1182c2bb27 -> 3ffe0000fcd791d65887d19a
test program is basically:
register long double a, sin, cos, pi;
long double step;
asm("fmovecr #0, %0" : "=f" (pi));
step = pi / 1024;
for (a = -2*pi; a <= 2*pi; a+= step) {
asm("fsincos.x %2, %0, %1" : "=f" (cos), "=f" (sin) : "f" (a));
print_result(a, sin, cos);
asm("fsin.x %1, %0" : "=f" (sin) : "f" (a));
asm("fcos.x %1, %0" : "=f" (cos) : "f" (a));
print_result(a, sin, cos);
}Laurent Vivier (11):
target/m68k: implement ftan
target/m68k: implement fsin
target/m68k: implement fcos
target/m68k: implement fsincos
target/m68k: implement fatan
target/m68k: implement fasin
target/m68k: implement facos
target/m68k: implement fatanh
target/m68k: implement ftanh
target/m68k: implement fsinh
target/m68k: implement fcosh
target/m68k/fpu_helper.c | 61 ++ target/m68k/helper.h | 11 + target/m68k/softfloat.c | 1637 +++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 11 + target/m68k/softfloat_fpsp_tables.h | 267 ++++++ target/m68k/translate.c | 38 + 6 files changed, 2025 insertions(+)
Signature · 1 line
2.14.3
PATCH 1/11 target/m68k: implement ftan
Using a local m68k floatx80_tan()
[copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
--- target/m68k/fpu_helper.c | 5 + target/m68k/helper.h | 1 + target/m68k/softfloat.c | 210 ++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/softfloat_fpsp_tables.h | 136 +++++++++++++++++++++++ target/m68k/translate.c | 3 + 6 files changed, 356 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -592,3 +592,8 @@ void HELPER(ftentox)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_tentox (val->d, &env->fp_status); } + +void HELPER (ftan )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_tan (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -75,6 +75,7 @@ DEF_HELPER_3(flog2, void, env, fp, fp) DEF_HELPER_3(fetox, void, env, fp, fp) DEF_HELPER_3(ftwotox, void, env, fp, fp) DEF_HELPER_3(ftentox, void, env, fp, fp) +DEF_HELPER_3(ftan, void, env, fp, fp) DEF_HELPER_3(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c +210 -0
213 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -34,4 +34,5 @@ floatx80 floatx80_log2(floatx80 a, float_status *status);floatx80 floatx80_etox (floatx80 a,float_status *status);floatx80 floatx80_twotox (floatx80 a,float_status *status);floatx80 floatx80_tentox (floatx80 a,float_status *status); +floatx80 floatx80_tan (floatx80 a,float_status *status);#endif
target/m68k/softfloat_fpsp_tables.h +136 -0
140 lines not on this page · raw message
target/m68k/translate.c +3 -0
@@ -5057,6 +5057,9 @@ DISAS_INSN(fpu)case 0x06 :/* flognp1 */ gen_helper_flognp1 (cpu_env, cpu_dest, cpu_src);break ; +case 0x0f :/* ftan */ +gen_helper_ftan (cpu_env, cpu_dest, cpu_src); +break ;case 0x10 :/* fetox */ gen_helper_fetox (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 2/11 target/m68k: implement fsin
In reply to Laurent VivierUsing a local m68k floatx80_sin()
[copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
--- target/m68k/fpu_helper.c | 5 + target/m68k/helper.h | 1 + target/m68k/softfloat.c | 247 +++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/translate.c | 3 + 5 files changed, 257 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -597,3 +597,8 @@ void HELPER(ftan)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_tan (val->d, &env->fp_status); } + +void HELPER (fsin )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_sin (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -76,6 +76,7 @@ DEF_HELPER_3(fetox, void, env, fp, fp) DEF_HELPER_3(ftwotox, void, env, fp, fp) DEF_HELPER_3(ftentox, void, env, fp, fp) DEF_HELPER_3(ftan, void, env, fp, fp) +DEF_HELPER_3(fsin, void, env, fp, fp) DEF_HELPER_3(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c +247 -0
250 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -35,4 +35,5 @@ floatx80 floatx80_etox(floatx80 a, float_status *status);floatx80 floatx80_twotox (floatx80 a,float_status *status);floatx80 floatx80_tentox (floatx80 a,float_status *status);floatx80 floatx80_tan (floatx80 a,float_status *status); +floatx80 floatx80_sin (floatx80 a,float_status *status);#endif
target/m68k/translate.c +3 -0
@@ -5057,6 +5057,9 @@ DISAS_INSN(fpu)case 0x06 :/* flognp1 */ gen_helper_flognp1 (cpu_env, cpu_dest, cpu_src);break ; +case 0x0e :/* fsin */ +gen_helper_fsin (cpu_env, cpu_dest, cpu_src); +break ;case 0x0f :/* ftan */ gen_helper_ftan (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 3/11 target/m68k: implement fcos
In reply to Laurent VivierUsing a local m68k floatx80_cos()
[copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
--- target/m68k/fpu_helper.c | 5 + target/m68k/helper.h | 1 + target/m68k/softfloat.c | 244 +++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/translate.c | 3 + 5 files changed, 254 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -602,3 +602,8 @@ void HELPER(fsin)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_sin (val->d, &env->fp_status); } + +void HELPER (fcos )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_cos (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -77,6 +77,7 @@ DEF_HELPER_3(ftwotox, void, env, fp, fp) DEF_HELPER_3(ftentox, void, env, fp, fp) DEF_HELPER_3(ftan, void, env, fp, fp) DEF_HELPER_3(fsin, void, env, fp, fp) +DEF_HELPER_3(fcos, void, env, fp, fp) DEF_HELPER_3(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c +244 -0
247 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -36,4 +36,5 @@ floatx80 floatx80_twotox(floatx80 a, float_status *status);floatx80 floatx80_tentox (floatx80 a,float_status *status);floatx80 floatx80_tan (floatx80 a,float_status *status);floatx80 floatx80_sin (floatx80 a,float_status *status); +floatx80 floatx80_cos (floatx80 a,float_status *status);#endif
target/m68k/translate.c +3 -0
@@ -5099,6 +5099,9 @@ DISAS_INSN(fpu)case 0x5e :/* fdneg */ gen_helper_fdneg (cpu_env, cpu_dest, cpu_src);break ; +case 0x1d :/* fcos */ +gen_helper_fcos (cpu_env, cpu_dest, cpu_src); +break ;case 0x1e :/* fgetexp */ gen_helper_fgetexp (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 4/11 target/m68k: implement fsincos
In reply to Laurent Vivierusing floatx80_sin() and floatx80_cos()
--- target/m68k/fpu_helper.c | 11 +++++++++++ target/m68k/helper.h | 1 + target/m68k/translate.c | 8 ++++++++ 3 files changed, 20 insertions(+)
target/m68k/fpu_helper.c +11 -0
@@ -607,3 +607,14 @@ void HELPER(fcos)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_cos (val->d, &env->fp_status); } + +void HELPER (fsincos )(CPUM68KState *env,FPReg *res0,FPReg *res1,FPReg *val) +{ +floatx80 a = val->d; +/* If res0 and res1 specify the same floating-point data register, +* the sine result is stored in the register, and the cosine +* result is discarded. +*/ + res1->d =floatx80_cos (a, &env->fp_status); + res0->d =floatx80_sin (a, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -78,6 +78,7 @@ DEF_HELPER_3(ftentox, void, env, fp, fp) DEF_HELPER_3(ftan, void, env, fp, fp) DEF_HELPER_3(fsin, void, env, fp, fp) DEF_HELPER_3(fcos, void, env, fp, fp) +DEF_HELPER_4(fsincos, void, env, fp, fp, fp) DEF_HELPER_3(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/translate.c +8 -0
@@ -5159,6 +5159,14 @@ DISAS_INSN(fpu)case 0x6c :/* fdsub */ gen_helper_fdsub (cpu_env, cpu_dest, cpu_src, cpu_dest);break ; +case 0x30 :case 0x31 :case 0x32 : +case 0x33 :case 0x34 :case 0x35 : +case 0x36 :case 0x37 : { +TCGv_ptr cpu_dest2 =gen_fp_ptr (REG (ext,0 )); +gen_helper_fsincos (cpu_env, cpu_dest, cpu_dest2, cpu_src); +tcg_temp_free_ptr (cpu_dest2); + } +break ;case 0x38 :/* fcmp */ gen_helper_fcmp (cpu_env, cpu_src, cpu_dest);return ;
Signature · 1 line
2.14.3
PATCH 5/11 target/m68k: implement fatan
In reply to Laurent VivierUsing a local m68k floatx80_atan()
[copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
--- target/m68k/fpu_helper.c | 5 + target/m68k/helper.h | 1 + target/m68k/softfloat.c | 200 ++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/softfloat_fpsp_tables.h | 131 +++++++++++++++++++++++ target/m68k/translate.c | 3 + 6 files changed, 341 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -618,3 +618,8 @@ void HELPER(fsincos)(CPUM68KState *env, FPReg *res0, FPReg *res1, FPReg *val) res1->d =floatx80_cos (a, &env->fp_status); res0->d =floatx80_sin (a, &env->fp_status); } + +void HELPER (fatan )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_atan (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -79,6 +79,7 @@ DEF_HELPER_3(ftan, void, env, fp, fp) DEF_HELPER_3(fsin, void, env, fp, fp) DEF_HELPER_3(fcos, void, env, fp, fp) DEF_HELPER_4(fsincos, void, env, fp, fp, fp) +DEF_HELPER_3(fatan, void, env, fp, fp) DEF_HELPER_3(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c +200 -0
209 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -37,4 +37,5 @@ floatx80 floatx80_tentox(floatx80 a, float_status *status);floatx80 floatx80_tan (floatx80 a,float_status *status);floatx80 floatx80_sin (floatx80 a,float_status *status);floatx80 floatx80_cos (floatx80 a,float_status *status); +floatx80 floatx80_atan (floatx80 a,float_status *status);#endif
target/m68k/softfloat_fpsp_tables.h +131 -0
135 lines not on this page · raw message
target/m68k/translate.c +3 -0
@@ -5057,6 +5057,9 @@ DISAS_INSN(fpu)case 0x06 :/* flognp1 */ gen_helper_flognp1 (cpu_env, cpu_dest, cpu_src);break ; +case 0x0a :/* fatan */ +gen_helper_fatan (cpu_env, cpu_dest, cpu_src); +break ;case 0x0e :/* fsin */ gen_helper_fsin (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 6/11 target/m68k: implement fasin
In reply to Laurent VivierUsing a local m68k floatx80_asin()
[copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
--- target/m68k/fpu_helper.c | 5 ++++ target/m68k/helper.h | 1 + target/m68k/softfloat.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/translate.c | 3 +++ 5 files changed, 75 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -623,3 +623,8 @@ void HELPER(fatan)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_atan (val->d, &env->fp_status); } + +void HELPER (fasin )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_asin (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -80,6 +80,7 @@ DEF_HELPER_3(fsin, void, env, fp, fp) DEF_HELPER_3(fcos, void, env, fp, fp) DEF_HELPER_4(fsincos, void, env, fp, fp, fp) DEF_HELPER_3(fatan, void, env, fp, fp) +DEF_HELPER_3(fasin, void, env, fp, fp) DEF_HELPER_3(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c +65 -0
68 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -38,4 +38,5 @@ floatx80 floatx80_tan(floatx80 a, float_status *status);floatx80 floatx80_sin (floatx80 a,float_status *status);floatx80 floatx80_cos (floatx80 a,float_status *status);floatx80 floatx80_atan (floatx80 a,float_status *status); +floatx80 floatx80_asin (floatx80 a,float_status *status);#endif
target/m68k/translate.c +3 -0
@@ -5060,6 +5060,9 @@ DISAS_INSN(fpu)case 0x0a :/* fatan */ gen_helper_fatan (cpu_env, cpu_dest, cpu_src);break ; +case 0x0c :/* fasin */ +gen_helper_fasin (cpu_env, cpu_dest, cpu_src); +break ;case 0x0e :/* fsin */ gen_helper_fsin (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 7/11 target/m68k: implement facos
In reply to Laurent VivierUsing a local m68k floatx80_acos()
[copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
--- target/m68k/fpu_helper.c | 5 ++++ target/m68k/helper.h | 1 + target/m68k/softfloat.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/translate.c | 3 +++ 5 files changed, 80 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -628,3 +628,8 @@ void HELPER(fasin)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_asin (val->d, &env->fp_status); } + +void HELPER (facos )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_acos (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -81,6 +81,7 @@ DEF_HELPER_3(fcos, void, env, fp, fp) DEF_HELPER_4(fsincos, void, env, fp, fp, fp) DEF_HELPER_3(fatan, void, env, fp, fp) DEF_HELPER_3(fasin, void, env, fp, fp) +DEF_HELPER_3(facos, void, env, fp, fp) DEF_HELPER_3(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c +70 -0
79 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -39,4 +39,5 @@ floatx80 floatx80_sin(floatx80 a, float_status *status);floatx80 floatx80_cos (floatx80 a,float_status *status);floatx80 floatx80_atan (floatx80 a,float_status *status);floatx80 floatx80_asin (floatx80 a,float_status *status); +floatx80 floatx80_acos (floatx80 a,float_status *status);#endif
target/m68k/translate.c +3 -0
@@ -5105,6 +5105,9 @@ DISAS_INSN(fpu)case 0x5e :/* fdneg */ gen_helper_fdneg (cpu_env, cpu_dest, cpu_src);break ; +case 0x1c :/* facos */ +gen_helper_facos (cpu_env, cpu_dest, cpu_src); +break ;case 0x1d :/* fcos */ gen_helper_fcos (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 8/11 target/m68k: implement fatanh
In reply to Laurent VivierUsing a local m68k floatx80_atanh()
[copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
--- target/m68k/fpu_helper.c | 5 ++++ target/m68k/helper.h | 1 + target/m68k/softfloat.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/translate.c | 3 +++ 5 files changed, 75 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -633,3 +633,8 @@ void HELPER(facos)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_acos (val->d, &env->fp_status); } + +void HELPER (fatanh )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_atanh (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -82,6 +82,7 @@ DEF_HELPER_4(fsincos, void, env, fp, fp, fp) DEF_HELPER_3(fatan, void, env, fp, fp) DEF_HELPER_3(fasin, void, env, fp, fp) DEF_HELPER_3(facos, void, env, fp, fp) +DEF_HELPER_3(fatanh, void, env, fp, fp) DEF_HELPER_3(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c +65 -0
68 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -40,4 +40,5 @@ floatx80 floatx80_cos(floatx80 a, float_status *status);floatx80 floatx80_atan (floatx80 a,float_status *status);floatx80 floatx80_asin (floatx80 a,float_status *status);floatx80 floatx80_acos (floatx80 a,float_status *status); +floatx80 floatx80_atanh (floatx80 a,float_status *status);#endif
target/m68k/translate.c +3 -0
@@ -5063,6 +5063,9 @@ DISAS_INSN(fpu)case 0x0c :/* fasin */ gen_helper_fasin (cpu_env, cpu_dest, cpu_src);break ; +case 0x0d :/* fatanh */ +gen_helper_fatanh (cpu_env, cpu_dest, cpu_src); +break ;case 0x0e :/* fsin */ gen_helper_fsin (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 9/11 target/m68k: implement ftanh
In reply to Laurent VivierUsing local m68k floatx80_tanh() and floatx80_etoxm1() [copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
--- target/m68k/fpu_helper.c | 5 + target/m68k/helper.h | 1 + target/m68k/softfloat.c | 366 +++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 2 + target/m68k/translate.c | 3 + 5 files changed, 377 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -638,3 +638,8 @@ void HELPER(fatanh)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_atanh (val->d, &env->fp_status); } + +void HELPER (ftanh )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_tanh (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -83,6 +83,7 @@ DEF_HELPER_3(fatan, void, env, fp, fp) DEF_HELPER_3(fasin, void, env, fp, fp) DEF_HELPER_3(facos, void, env, fp, fp) DEF_HELPER_3(fatanh, void, env, fp, fp) +DEF_HELPER_3(ftanh, void, env, fp, fp) DEF_HELPER_3(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c +366 -0
369 lines not on this page · raw message
target/m68k/softfloat.h +2 -0
@@ -41,4 +41,6 @@ floatx80 floatx80_atan(floatx80 a, float_status *status);floatx80 floatx80_asin (floatx80 a,float_status *status);floatx80 floatx80_acos (floatx80 a,float_status *status);floatx80 floatx80_atanh (floatx80 a,float_status *status); +floatx80 floatx80_etoxm1 (floatx80 a,float_status *status); +floatx80 floatx80_tanh (floatx80 a,float_status *status);#endif
target/m68k/translate.c +3 -0
@@ -5057,6 +5057,9 @@ DISAS_INSN(fpu)case 0x06 :/* flognp1 */ gen_helper_flognp1 (cpu_env, cpu_dest, cpu_src);break ; +case 0x09 :/* ftanh */ +gen_helper_ftanh (cpu_env, cpu_dest, cpu_src); +break ;case 0x0a :/* fatan */ gen_helper_fatan (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 10/11 target/m68k: implement fsinh
In reply to Laurent VivierUsing a local m68k floatx80_sinh()
[copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
--- target/m68k/fpu_helper.c | 5 +++ target/m68k/helper.h | 1 + target/m68k/softfloat.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/translate.c | 3 ++ 5 files changed, 99 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -643,3 +643,8 @@ void HELPER(ftanh)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_tanh (val->d, &env->fp_status); } + +void HELPER (fsinh )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_sinh (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -84,6 +84,7 @@ DEF_HELPER_3(fasin, void, env, fp, fp) DEF_HELPER_3(facos, void, env, fp, fp) DEF_HELPER_3(fatanh, void, env, fp, fp) DEF_HELPER_3(ftanh, void, env, fp, fp) +DEF_HELPER_3(fsinh, void, env, fp, fp) DEF_HELPER_3(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c +89 -0
92 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -43,4 +43,5 @@ floatx80 floatx80_acos(floatx80 a, float_status *status);floatx80 floatx80_atanh (floatx80 a,float_status *status);floatx80 floatx80_etoxm1 (floatx80 a,float_status *status);floatx80 floatx80_tanh (floatx80 a,float_status *status); +floatx80 floatx80_sinh (floatx80 a,float_status *status);#endif
target/m68k/translate.c +3 -0
@@ -5042,6 +5042,9 @@ DISAS_INSN(fpu)case 1 :/* fint */ gen_helper_firound (cpu_env, cpu_dest, cpu_src);break ; +case 2 :/* fsinh */ +gen_helper_fsinh (cpu_env, cpu_dest, cpu_src); +break ;case 3 :/* fintrz */ gen_helper_fitrunc (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 11/11 target/m68k: implement fcosh
In reply to Laurent VivierUsing a local m68k floatx80_cosh()
[copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.]
--- target/m68k/fpu_helper.c | 5 +++ target/m68k/helper.h | 1 + target/m68k/softfloat.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/translate.c | 3 ++ 5 files changed, 91 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -648,3 +648,8 @@ void HELPER(fsinh)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_sinh (val->d, &env->fp_status); } + +void HELPER (fcosh )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_cosh (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -85,6 +85,7 @@ DEF_HELPER_3(facos, void, env, fp, fp) DEF_HELPER_3(fatanh, void, env, fp, fp) DEF_HELPER_3(ftanh, void, env, fp, fp) DEF_HELPER_3(fsinh, void, env, fp, fp) +DEF_HELPER_3(fcosh, void, env, fp, fp) DEF_HELPER_3(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c +81 -0
84 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -44,4 +44,5 @@ floatx80 floatx80_atanh(floatx80 a, float_status *status);floatx80 floatx80_etoxm1 (floatx80 a,float_status *status);floatx80 floatx80_tanh (floatx80 a,float_status *status);floatx80 floatx80_sinh (floatx80 a,float_status *status); +floatx80 floatx80_cosh (floatx80 a,float_status *status);#endif
target/m68k/translate.c +3 -0
@@ -5105,6 +5105,9 @@ DISAS_INSN(fpu)case 0x5c :/* fdabs */ gen_helper_fdabs (cpu_env, cpu_dest, cpu_src);break ; +case 0x19 :/* fcosh */ +gen_helper_fcosh (cpu_env, cpu_dest, cpu_src); +break ;case 0x1a :/* fneg */ gen_helper_fneg (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
Quoted 20 lines · Laurent Vivier
I have compared results of these instructions from a real m68040 and from QEMU, and they match (sincos differs [1] because in QEMU we compute it as sin and cos, and on m68040 sin and cos results differ also with sincos results. It looks like a rounding problem, perhaps a bug in m68040 FPU? or in my test program?)
I know this will need more work, but for the moment I only would like to provide these new instructions to the maintream of QEMU.
[1] Example:
sincos -6.125952 -> (0.156586, 0.987664)
QEMU:
sincos
c0010000c407cd1182c2bb27->3ffc0000a05812beea449a4d3ffe0000fcd791d65887d19asin
c0010000c407cd1182c2bb27->3ffc0000a05812beea449a4d
cosc0010000c407cd1182c2bb27->3ffe0000fcd791d65887d19a
Quoted 6 lines
m68040:
sincos
c0010000c407cd1182c2bb27->3ffc0000a05812beea449a4d3ffe0000fcd791d65887d199 <<--sin
c0010000c407cd1182c2bb27->3ffc0000a05812beea449a4d
cosc0010000c407cd1182c2bb27->3ffe0000fcd791d65887d19a
Wow, this does seem like a processor bug.
Anyway, I've looked through the patch set and nothing stands out,
r~