target/m68k: implement 680x0 FPU (part 4)
cover target/m68k: implement 680x0 FPU (part 4)
Implement flognp1, flogn, flog10, flog2, fetox, ftwotox, ftentox
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".
"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/
floatx80_move() comes from WinUAE (3600b8):
https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp
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.
Laurent Vivier (8):
target/m68k: define floatx80_move()
target/m68k: implement flognp1
target/m68k: implement flogn
target/m68k: implement flog10
target/m68k: implement flog2
target/m68k: implement fetox
target/m68k: implement ftwotox
target/m68k: implement ftentox
target/m68k/fpu_helper.c | 35 ++ target/m68k/helper.h | 7 + target/m68k/softfloat.c | 1019 +++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 8 + target/m68k/softfloat_fpsp_tables.h | 374 +++++++++++++ target/m68k/translate.c | 21 + 6 files changed, 1464 insertions(+) create mode 100755 target/m68k/softfloat_fpsp_tables.h
Signature · 1 line
2.14.3
PATCH 1/8 target/m68k: define floatx80_move()
This functions is needed by upcoming m68k softfloat functions.
Source code copied for WinUAE (tag 3500) (The WinUAE file has been copied from QEMU and has the QEMU licensing notice)
--- target/m68k/softfloat.c | 27 +++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + 2 files changed, 28 insertions(+)
target/m68k/softfloat.c +27 -0
@@ -247,3 +247,30 @@ floatx80 floatx80_scale(floatx80 a, floatx80 b, float_status *status)return roundAndPackFloatx80 (status->floatx80_rounding_precision, aSign, aExp, aSig,0 , status); } + +floatx80 floatx80_move (floatx80 a,float_status *status) +{ +flag aSign; +int32_t aExp; +uint64_t aSig; + + aSig =extractFloatx80Frac (a); + aExp =extractFloatx80Exp (a); + aSign =extractFloatx80Sign (a); + +if (aExp ==0x7FFF ) { +if ((uint64_t )(aSig <<1 )) { +return propagateFloatx80NaNOneArg (a, status); + } +return a; + } +if (aExp ==0 ) { +if (aSig ==0 ) { +return a; + } +normalizeRoundAndPackFloatx80 (status->floatx80_rounding_precision, + aSign, aExp, aSig,0 , status); + } +return roundAndPackFloatx80 (status->floatx80_rounding_precision, aSign, + aExp, aSig,0 , status); +}
target/m68k/softfloat.h +1 -0
@@ -26,4 +26,5 @@ floatx80 floatx80_mod(floatx80 a, floatx80 b, float_status *status);floatx80 floatx80_getman (floatx80 a,float_status *status);floatx80 floatx80_getexp (floatx80 a,float_status *status);floatx80 floatx80_scale (floatx80 a,floatx80 b,float_status *status); +floatx80 floatx80_move (floatx80 a,float_status *status);#endif
Signature · 1 line
2.14.3
PATCH 2/8 target/m68k: implement flognp1
In reply to Laurent VivierUsing a local m68k floatx80_lognp1()
[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 | 216 ++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/softfloat_fpsp_tables.h | 154 +++++++++++++++++++++++++ target/m68k/translate.c | 3 + 6 files changed, 380 insertions(+) create mode 100755 target/m68k/softfloat_fpsp_tables.h
target/m68k/fpu_helper.c +5 -0
@@ -557,3 +557,8 @@ void HELPER(fscale)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) { res->d =floatx80_scale (val1->d, val0->d, &env->fp_status); } + +void HELPER (flognp1 )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_lognp1 (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -68,6 +68,7 @@ DEF_HELPER_4(frem, void, env, fp, fp, fp) DEF_HELPER_3(fgetexp, void, env, fp, fp) DEF_HELPER_3(fgetman, void, env, fp, fp) DEF_HELPER_4(fscale, void, env, fp, fp, fp) +DEF_HELPER_3(flognp1, 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 +216 -0
225 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -27,4 +27,5 @@ floatx80 floatx80_getman(floatx80 a, float_status *status);floatx80 floatx80_getexp (floatx80 a,float_status *status);floatx80 floatx80_scale (floatx80 a,floatx80 b,float_status *status);floatx80 floatx80_move (floatx80 a,float_status *status); +floatx80 floatx80_lognp1 (floatx80 a,float_status *status);#endif
target/m68k/softfloat_fpsp_tables.h new file +154 -0
154 lines not on this page · raw message
target/m68k/translate.c +3 -0
@@ -5054,6 +5054,9 @@ DISAS_INSN(fpu)case 0x45 :/* fdsqrt */ gen_helper_fdsqrt (cpu_env, cpu_dest, cpu_src);break ; +case 0x06 :/* flognp1 */ +gen_helper_flognp1 (cpu_env, cpu_dest, cpu_src); +break ;case 0x18 :/* fabs */ gen_helper_fabs (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 3/8 target/m68k: implement flogn
In reply to Laurent VivierUsing a local m68k floatx80_logn()
[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 | 168 +++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/translate.c | 3 + 5 files changed, 178 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -562,3 +562,8 @@ void HELPER(flognp1)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_lognp1 (val->d, &env->fp_status); } + +void HELPER (flogn )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_logn (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -69,6 +69,7 @@ DEF_HELPER_3(fgetexp, void, env, fp, fp) DEF_HELPER_3(fgetman, void, env, fp, fp) DEF_HELPER_4(fscale, void, env, fp, fp, fp) DEF_HELPER_3(flognp1, void, env, fp, fp) +DEF_HELPER_3(flogn, 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 +168 -0
171 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -28,4 +28,5 @@ floatx80 floatx80_getexp(floatx80 a, float_status *status);floatx80 floatx80_scale (floatx80 a,floatx80 b,float_status *status);floatx80 floatx80_move (floatx80 a,float_status *status);floatx80 floatx80_lognp1 (floatx80 a,float_status *status); +floatx80 floatx80_logn (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 0x14 :/* flogn */ +gen_helper_flogn (cpu_env, cpu_dest, cpu_src); +break ;case 0x18 :/* fabs */ gen_helper_fabs (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 4/8 target/m68k: implement flog10
In reply to Laurent VivierUsing a local m68k floatx80_log10()
[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 | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/translate.c | 3 +++ 5 files changed, 67 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -567,3 +567,8 @@ void HELPER(flogn)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_logn (val->d, &env->fp_status); } + +void HELPER (flog10 )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_log10 (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -70,6 +70,7 @@ DEF_HELPER_3(fgetman, void, env, fp, fp) DEF_HELPER_4(fscale, void, env, fp, fp, fp) DEF_HELPER_3(flognp1, void, env, fp, fp) DEF_HELPER_3(flogn, void, env, fp, fp) +DEF_HELPER_3(flog10, 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 +57 -0
60 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -29,4 +29,5 @@ floatx80 floatx80_scale(floatx80 a, floatx80 b, float_status *status);floatx80 floatx80_move (floatx80 a,float_status *status);floatx80 floatx80_lognp1 (floatx80 a,float_status *status);floatx80 floatx80_logn (floatx80 a,float_status *status); +floatx80 floatx80_log10 (floatx80 a,float_status *status);#endif
target/m68k/translate.c +3 -0
@@ -5060,6 +5060,9 @@ DISAS_INSN(fpu)case 0x14 :/* flogn */ gen_helper_flogn (cpu_env, cpu_dest, cpu_src);break ; +case 0x15 :/* flog10 */ +gen_helper_flog10 (cpu_env, cpu_dest, cpu_src); +break ;case 0x18 :/* fabs */ gen_helper_fabs (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 5/8 target/m68k: implement flog2
In reply to Laurent VivierUsing a local m68k floatx80_log2()
[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 | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/translate.c | 3 +++ 5 files changed, 77 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -572,3 +572,8 @@ void HELPER(flog10)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_log10 (val->d, &env->fp_status); } + +void HELPER (flog2 )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_log2 (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -71,6 +71,7 @@ DEF_HELPER_4(fscale, void, env, fp, fp, fp) DEF_HELPER_3(flognp1, void, env, fp, fp) DEF_HELPER_3(flogn, void, env, fp, fp) DEF_HELPER_3(flog10, void, env, fp, fp) +DEF_HELPER_3(flog2, 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 +67 -0
70 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -30,4 +30,5 @@ floatx80 floatx80_move(floatx80 a, float_status *status);floatx80 floatx80_lognp1 (floatx80 a,float_status *status);floatx80 floatx80_logn (floatx80 a,float_status *status);floatx80 floatx80_log10 (floatx80 a,float_status *status); +floatx80 floatx80_log2 (floatx80 a,float_status *status);#endif
target/m68k/translate.c +3 -0
@@ -5063,6 +5063,9 @@ DISAS_INSN(fpu)case 0x15 :/* flog10 */ gen_helper_flog10 (cpu_env, cpu_dest, cpu_src);break ; +case 0x16 :/* flog2 */ +gen_helper_flog2 (cpu_env, cpu_dest, cpu_src); +break ;case 0x18 :/* fabs */ gen_helper_fabs (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 6/8 target/m68k: implement fetox
In reply to Laurent VivierUsing a local m68k floatx80_etox()
[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 | 183 ++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/softfloat_fpsp_tables.h | 134 ++++++++++++++++++++++++++ target/m68k/translate.c | 3 + 6 files changed, 327 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -577,3 +577,8 @@ void HELPER(flog2)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_log2 (val->d, &env->fp_status); } + +void HELPER (fetox )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_etox (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -72,6 +72,7 @@ DEF_HELPER_3(flognp1, void, env, fp, fp) DEF_HELPER_3(flogn, void, env, fp, fp) DEF_HELPER_3(flog10, void, env, fp, fp) DEF_HELPER_3(flog2, void, env, fp, fp) +DEF_HELPER_3(fetox, 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 +183 -0
186 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -31,4 +31,5 @@ floatx80 floatx80_lognp1(floatx80 a, float_status *status);floatx80 floatx80_logn (floatx80 a,float_status *status);floatx80 floatx80_log10 (floatx80 a,float_status *status);floatx80 floatx80_log2 (floatx80 a,float_status *status); +floatx80 floatx80_etox (floatx80 a,float_status *status);#endif
target/m68k/softfloat_fpsp_tables.h +134 -0
138 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 0x10 :/* fetox */ +gen_helper_fetox (cpu_env, cpu_dest, cpu_src); +break ;case 0x14 :/* flogn */ gen_helper_flogn (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 7/8 target/m68k: implement ftwotox
In reply to Laurent VivierUsing a local m68k floatx80_twotox()
[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 | 148 ++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/softfloat_fpsp_tables.h | 86 +++++++++++++++++++++ target/m68k/translate.c | 3 + 6 files changed, 244 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -582,3 +582,8 @@ void HELPER(fetox)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_etox (val->d, &env->fp_status); } + +void HELPER (ftwotox )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_twotox (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -73,6 +73,7 @@ DEF_HELPER_3(flogn, void, env, fp, fp) DEF_HELPER_3(flog10, void, env, fp, fp) 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(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c +148 -0
151 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -32,4 +32,5 @@ floatx80 floatx80_logn(floatx80 a, float_status *status);floatx80 floatx80_log10 (floatx80 a,float_status *status);floatx80 floatx80_log2 (floatx80 a,float_status *status);floatx80 floatx80_etox (floatx80 a,float_status *status); +floatx80 floatx80_twotox (floatx80 a,float_status *status);#endif
target/m68k/softfloat_fpsp_tables.h +86 -0
90 lines not on this page · raw message
target/m68k/translate.c +3 -0
@@ -5060,6 +5060,9 @@ DISAS_INSN(fpu)case 0x10 :/* fetox */ gen_helper_fetox (cpu_env, cpu_dest, cpu_src);break ; +case 0x11 :/* ftwotox */ +gen_helper_ftwotox (cpu_env, cpu_dest, cpu_src); +break ;case 0x14 :/* flogn */ gen_helper_flogn (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3
PATCH 8/8 target/m68k: implement ftentox
In reply to Laurent VivierUsing a local m68k floatx80_tentox()
[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 | 153 +++++++++++++++++++++++++++++++++++++++++++++++ target/m68k/softfloat.h | 1 + target/m68k/translate.c | 3 + 5 files changed, 163 insertions(+)
target/m68k/fpu_helper.c +5 -0
@@ -587,3 +587,8 @@ void HELPER(ftwotox)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d =floatx80_twotox (val->d, &env->fp_status); } + +void HELPER (ftentox )(CPUM68KState *env,FPReg *res,FPReg *val) +{ + res->d =floatx80_tentox (val->d, &env->fp_status); +}
target/m68k/helper.h +1 -0
@@ -74,6 +74,7 @@ DEF_HELPER_3(flog10, void, env, fp, fp) 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(mac_move, void, env, i32, i32)DEF_HELPER_3 (macmulf, i64, env, i32, i32)
target/m68k/softfloat.c +153 -0
156 lines not on this page · raw message
target/m68k/softfloat.h +1 -0
@@ -33,4 +33,5 @@ floatx80 floatx80_log10(floatx80 a, float_status *status);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);#endif
target/m68k/translate.c +3 -0
@@ -5063,6 +5063,9 @@ DISAS_INSN(fpu)case 0x11 :/* ftwotox */ gen_helper_ftwotox (cpu_env, cpu_dest, cpu_src);break ; +case 0x12 :/* ftentox */ +gen_helper_ftentox (cpu_env, cpu_dest, cpu_src); +break ;case 0x14 :/* flogn */ gen_helper_flogn (cpu_env, cpu_dest, cpu_src);break ;
Signature · 1 line
2.14.3