target/mips: Add MAC2008 support
PATCH 1/1 target/mips: Add MAC2008 support
MAC2008 was introduced in MIPS Release 3 but removed in MIPS Release 5. However, there are some processors implemented this feature. some Ingenic MCU can config MAC2008 status runtime while whole Loongson-64 family are MAC2008 only.
FCSR.MAC2008 bit indicates FMA family of instructions on these processors have fused behavior, similiar to FMA in Release 6, so we can reuse helpers with them.
--- target/mips/cpu.h | 1 + target/mips/fpu_helper.c | 61 +++++++++++++++++++++------------ target/mips/helper.h | 12 +++---- target/mips/translate.c | 74 +++++++++++++++++++++++++++++++++------- 4 files changed, 107 insertions(+), 41 deletions(-)
target/mips/cpu.h +1 -0
@@ -63,6 +63,7 @@ struct CPUMIPSFPUContext {uint32_t fcr31_rw_bitmask;uint32_t fcr31;#define FCR31_FS 24 +#define FCR31_MAC2008 20#define FCR31_ABS2008 19#define FCR31_NAN2008 18#define SET_FP_COND (num, env) do { ((env).fcr31) |= \
target/mips/fpu_helper.c +40 -21
80 lines not on this page · raw message
target/mips/helper.h +4 -8
@@ -232,13 +232,6 @@ DEF_HELPER_3(float_mulr_ps, i64, env, i64, i64) DEF_HELPER_FLAGS_2(float_class_s, TCG_CALL_NO_RWG_SE, i32, env, i32) DEF_HELPER_FLAGS_2(float_class_d, TCG_CALL_NO_RWG_SE, i64, env, i64) -#define FOP_PROTO (op) \ -DEF_HELPER_4(float_ ## op ## _s, i32, env, i32, i32, i32) \ -DEF_HELPER_4(float_ ## op ## _d, i64, env, i64, i64, i64) -FOP_PROTO(maddf) -FOP_PROTO(msubf) -#undef FOP_PROTO -#define FOP_PROTO (op) \ DEF_HELPER_3(float_ ## op ## _s, i32, env, i32, i32) \ DEF_HELPER_3(float_ ## op ## _d, i64, env, i64, i64)
@@ -305,7 +298,10 @@ FOP_PROTO(rsqrt2)#define FOP_PROTO (op) \ DEF_HELPER_4(float_ ## op ## _s, i32, env, i32, i32, i32) \ DEF_HELPER_4(float_ ## op ## _d, i64, env, i64, i64, i64) \ -DEF_HELPER_4(float_ ## op ## _ps, i64, env, i64, i64, i64) +DEF_HELPER_4(float_ ## op ## _ps, i64, env, i64, i64, i64) \ +DEF_HELPER_4(float_ ## op ## f_s, i32, env, i32, i32, i32) \ +DEF_HELPER_4(float_ ## op ## f_d, i64, env, i64, i64, i64) \ +DEF_HELPER_4(float_ ## op ## f_ps, i64, env, i64, i64, i64) FOP_PROTO(madd) FOP_PROTO(msub) FOP_PROTO(nmadd)
target/mips/translate.c +62 -12
158 lines not on this page · raw message
Signature · 1 line
2.26.0.rc2
target/mips/translate.c static void gen_flt3_arith(DisasContext *ctx, uint32_t opc, · line 12784
Quoted 7 lines · Jiaxun Yang
target/mips/translate.c +5
-1-gen_helper_float_madd_s (fp2, cpu_env, fp0, fp1, fp2); +if (ctx->mac2008) { +gen_helper_float_madd_s (fp2, cpu_env, fp0, fp1, fp2); + }else { +gen_helper_float_maddf_s (fp2, cpu_env, fp0, fp1, fp2); + }
Surely this test is backward, that mac2008 invokes maddf.
r~
于 2020年3月29日 GMT+08:00 上午3:09:16, Richard Henderson <[email protected]> 写到:
Quoted 12 lines · Jiaxun Yang
target/mips/translate.c static void gen_flt3_arith(DisasContext *ctx, uint32_t opc,
Quoted 3 lines
target/mips/translate.c +2
-1-gen_helper_float_madd_s (fp2, cpu_env, fp0, fp1, fp2); +if (ctx->mac2008) { + gen_helper_float_madd_s(fp2, cpu_env, fp0, fp1,fp2);
Review
Quoted 2 lines
(quoted diff) +2
-0+ } else { + gen_helper_float_maddf_s(fp2, cpu_env, fp0, fp1,fp2);
Quoted 2 lines
+ }
Surely this test is backward, that mac2008 invokes maddf.
Sorry for my stupid fault.
Will fix in v2.
Quoted 3 lines
r~
Signature · 1 line
Jiaxun Yang