From 47b88e1ae43e58896a94eb3086f90cc65389d69b Mon Sep 17 00:00:00 2001 From: HeiHuDie <1042519051@qq.com> Date: Fri, 22 Nov 2024 15:36:22 +0800 Subject: [PATCH] fix(zfh): fix fsgn src unbox --- src/engine/interpreter/fp.c | 4 ++++ src/isa/riscv64/instr/rvzfh/exec.h | 14 +++----------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/engine/interpreter/fp.c b/src/engine/interpreter/fp.c index a68420ea3..aef8b712e 100644 --- a/src/engine/interpreter/fp.c +++ b/src/engine/interpreter/fp.c @@ -99,6 +99,10 @@ def_rtl(fpcall, rtlreg_t *dest, const rtlreg_t *src1, const rtlreg_t *src2, uint case FPCALL_LT: *dest = f16_lt(fsrc1, fsrc2); break; case FPCALL_EQ: *dest = f16_eq(fsrc1, fsrc2); break; + case FPCALL_SGNJ: *dest = fsgnj16(fsrc1, fsrc2, false, false); break; + case FPCALL_SGNJN: *dest = fsgnj16(fsrc1, fsrc2, true, false); break; + case FPCALL_SGNJX: *dest = fsgnj16(fsrc1, fsrc2, false, true); break; + case FPCALL_I32ToF: *dest = my_i32_to_f16 (*src1).v; break; case FPCALL_U32ToF: *dest = my_ui32_to_f16(*src1).v; break; case FPCALL_I64ToF: *dest = my_i64_to_f16 (*src1).v; break; diff --git a/src/isa/riscv64/instr/rvzfh/exec.h b/src/isa/riscv64/instr/rvzfh/exec.h index 19e9948f7..31d6fadec 100644 --- a/src/isa/riscv64/instr/rvzfh/exec.h +++ b/src/isa/riscv64/instr/rvzfh/exec.h @@ -151,25 +151,17 @@ def_EHelper(fcvt_lu_h) { def_EHelper(fsgnjh) { - rtl_andi(s, s0, dsrc1, ~F16_SIGN); - rtl_andi(s, ddest, dsrc2, F16_SIGN); - rtl_or(s, ddest, s0, ddest); + rtl_hostcall(s, HOSTCALL_FP, ddest, dsrc1, dsrc2, FPCALL_CMD(FPCALL_SGNJ, FPCALL_W16)); rtl_fsr(s, ddest, ddest, FPCALL_W16); } def_EHelper(fsgnjnh) { - rtl_andi(s, s0, dsrc1, ~F16_SIGN); - rtl_xori(s, ddest, dsrc2, F16_SIGN); - rtl_andi(s, ddest, ddest, F16_SIGN); - rtl_or(s, ddest, s0, ddest); + rtl_hostcall(s, HOSTCALL_FP, ddest, dsrc1, dsrc2, FPCALL_CMD(FPCALL_SGNJN, FPCALL_W16)); rtl_fsr(s, ddest, ddest, FPCALL_W16); } def_EHelper(fsgnjxh) { - rtl_andi(s, s0, dsrc1, ~F16_SIGN); - rtl_xor(s, ddest, dsrc1, dsrc2); - rtl_andi(s, ddest, ddest, F16_SIGN); - rtl_or(s, ddest, s0, ddest); + rtl_hostcall(s, HOSTCALL_FP, ddest, dsrc1, dsrc2, FPCALL_CMD(FPCALL_SGNJX, FPCALL_W16)); rtl_fsr(s, ddest, ddest, FPCALL_W16); }