Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
target/loongarch: Implement LSX fpu fcvt instructions
This patch includes:
- VFCVT{L/H}.{S.H/D.S};
- VFCVT.{H.S/S.D};
- VFRINT[{RNE/RZ/RP/RM}].{S/D};
- VFTINT[{RNE/RZ/RP/RM}].{W.S/L.D};
- VFTINT[RZ].{WU.S/LU.D};
- VFTINT[{RNE/RZ/RP/RM}].W.D;
- VFTINT[{RNE/RZ/RP/RM}]{L/H}.L.S;
- VFFINT.{S.W/D.L}[U];
- VFFINT.S.L, VFFINT{L/H}.D.W.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20230504122810.4094787-35-gaosong@loongson.cn>
  • Loading branch information
gaosong-loongson committed May 6, 2023
1 parent aca6747 commit 399665d
Show file tree
Hide file tree
Showing 5 changed files with 600 additions and 0 deletions.
56 changes: 56 additions & 0 deletions target/loongarch/disas.c
Expand Up @@ -1348,3 +1348,59 @@ INSN_LSX(vfrecip_s, vv)
INSN_LSX(vfrecip_d, vv)
INSN_LSX(vfrsqrt_s, vv)
INSN_LSX(vfrsqrt_d, vv)

INSN_LSX(vfcvtl_s_h, vv)
INSN_LSX(vfcvth_s_h, vv)
INSN_LSX(vfcvtl_d_s, vv)
INSN_LSX(vfcvth_d_s, vv)
INSN_LSX(vfcvt_h_s, vvv)
INSN_LSX(vfcvt_s_d, vvv)

INSN_LSX(vfrint_s, vv)
INSN_LSX(vfrint_d, vv)
INSN_LSX(vfrintrm_s, vv)
INSN_LSX(vfrintrm_d, vv)
INSN_LSX(vfrintrp_s, vv)
INSN_LSX(vfrintrp_d, vv)
INSN_LSX(vfrintrz_s, vv)
INSN_LSX(vfrintrz_d, vv)
INSN_LSX(vfrintrne_s, vv)
INSN_LSX(vfrintrne_d, vv)

INSN_LSX(vftint_w_s, vv)
INSN_LSX(vftint_l_d, vv)
INSN_LSX(vftintrm_w_s, vv)
INSN_LSX(vftintrm_l_d, vv)
INSN_LSX(vftintrp_w_s, vv)
INSN_LSX(vftintrp_l_d, vv)
INSN_LSX(vftintrz_w_s, vv)
INSN_LSX(vftintrz_l_d, vv)
INSN_LSX(vftintrne_w_s, vv)
INSN_LSX(vftintrne_l_d, vv)
INSN_LSX(vftint_wu_s, vv)
INSN_LSX(vftint_lu_d, vv)
INSN_LSX(vftintrz_wu_s, vv)
INSN_LSX(vftintrz_lu_d, vv)
INSN_LSX(vftint_w_d, vvv)
INSN_LSX(vftintrm_w_d, vvv)
INSN_LSX(vftintrp_w_d, vvv)
INSN_LSX(vftintrz_w_d, vvv)
INSN_LSX(vftintrne_w_d, vvv)
INSN_LSX(vftintl_l_s, vv)
INSN_LSX(vftinth_l_s, vv)
INSN_LSX(vftintrml_l_s, vv)
INSN_LSX(vftintrmh_l_s, vv)
INSN_LSX(vftintrpl_l_s, vv)
INSN_LSX(vftintrph_l_s, vv)
INSN_LSX(vftintrzl_l_s, vv)
INSN_LSX(vftintrzh_l_s, vv)
INSN_LSX(vftintrnel_l_s, vv)
INSN_LSX(vftintrneh_l_s, vv)

INSN_LSX(vffint_s_w, vv)
INSN_LSX(vffint_s_wu, vv)
INSN_LSX(vffint_d_l, vv)
INSN_LSX(vffint_d_lu, vv)
INSN_LSX(vffintl_d_w, vv)
INSN_LSX(vffinth_d_w, vv)
INSN_LSX(vffint_s_l, vvv)
56 changes: 56 additions & 0 deletions target/loongarch/helper.h
Expand Up @@ -558,3 +558,59 @@ DEF_HELPER_3(vfrecip_s, void, env, i32, i32)
DEF_HELPER_3(vfrecip_d, void, env, i32, i32)
DEF_HELPER_3(vfrsqrt_s, void, env, i32, i32)
DEF_HELPER_3(vfrsqrt_d, void, env, i32, i32)

DEF_HELPER_3(vfcvtl_s_h, void, env, i32, i32)
DEF_HELPER_3(vfcvth_s_h, void, env, i32, i32)
DEF_HELPER_3(vfcvtl_d_s, void, env, i32, i32)
DEF_HELPER_3(vfcvth_d_s, void, env, i32, i32)
DEF_HELPER_4(vfcvt_h_s, void, env, i32, i32, i32)
DEF_HELPER_4(vfcvt_s_d, void, env, i32, i32, i32)

DEF_HELPER_3(vfrintrne_s, void, env, i32, i32)
DEF_HELPER_3(vfrintrne_d, void, env, i32, i32)
DEF_HELPER_3(vfrintrz_s, void, env, i32, i32)
DEF_HELPER_3(vfrintrz_d, void, env, i32, i32)
DEF_HELPER_3(vfrintrp_s, void, env, i32, i32)
DEF_HELPER_3(vfrintrp_d, void, env, i32, i32)
DEF_HELPER_3(vfrintrm_s, void, env, i32, i32)
DEF_HELPER_3(vfrintrm_d, void, env, i32, i32)
DEF_HELPER_3(vfrint_s, void, env, i32, i32)
DEF_HELPER_3(vfrint_d, void, env, i32, i32)

DEF_HELPER_3(vftintrne_w_s, void, env, i32, i32)
DEF_HELPER_3(vftintrne_l_d, void, env, i32, i32)
DEF_HELPER_3(vftintrz_w_s, void, env, i32, i32)
DEF_HELPER_3(vftintrz_l_d, void, env, i32, i32)
DEF_HELPER_3(vftintrp_w_s, void, env, i32, i32)
DEF_HELPER_3(vftintrp_l_d, void, env, i32, i32)
DEF_HELPER_3(vftintrm_w_s, void, env, i32, i32)
DEF_HELPER_3(vftintrm_l_d, void, env, i32, i32)
DEF_HELPER_3(vftint_w_s, void, env, i32, i32)
DEF_HELPER_3(vftint_l_d, void, env, i32, i32)
DEF_HELPER_3(vftintrz_wu_s, void, env, i32, i32)
DEF_HELPER_3(vftintrz_lu_d, void, env, i32, i32)
DEF_HELPER_3(vftint_wu_s, void, env, i32, i32)
DEF_HELPER_3(vftint_lu_d, void, env, i32, i32)
DEF_HELPER_4(vftintrne_w_d, void, env, i32, i32, i32)
DEF_HELPER_4(vftintrz_w_d, void, env, i32, i32, i32)
DEF_HELPER_4(vftintrp_w_d, void, env, i32, i32, i32)
DEF_HELPER_4(vftintrm_w_d, void, env, i32, i32, i32)
DEF_HELPER_4(vftint_w_d, void, env, i32, i32, i32)
DEF_HELPER_3(vftintrnel_l_s, void, env, i32, i32)
DEF_HELPER_3(vftintrneh_l_s, void, env, i32, i32)
DEF_HELPER_3(vftintrzl_l_s, void, env, i32, i32)
DEF_HELPER_3(vftintrzh_l_s, void, env, i32, i32)
DEF_HELPER_3(vftintrpl_l_s, void, env, i32, i32)
DEF_HELPER_3(vftintrph_l_s, void, env, i32, i32)
DEF_HELPER_3(vftintrml_l_s, void, env, i32, i32)
DEF_HELPER_3(vftintrmh_l_s, void, env, i32, i32)
DEF_HELPER_3(vftintl_l_s, void, env, i32, i32)
DEF_HELPER_3(vftinth_l_s, void, env, i32, i32)

DEF_HELPER_3(vffint_s_w, void, env, i32, i32)
DEF_HELPER_3(vffint_d_l, void, env, i32, i32)
DEF_HELPER_3(vffint_s_wu, void, env, i32, i32)
DEF_HELPER_3(vffint_d_lu, void, env, i32, i32)
DEF_HELPER_3(vffintl_d_w, void, env, i32, i32)
DEF_HELPER_3(vffinth_d_w, void, env, i32, i32)
DEF_HELPER_4(vffint_s_l, void, env, i32, i32, i32)
56 changes: 56 additions & 0 deletions target/loongarch/insn_trans/trans_lsx.c.inc
Expand Up @@ -3476,3 +3476,59 @@ TRANS(vfrecip_s, gen_vv, gen_helper_vfrecip_s)
TRANS(vfrecip_d, gen_vv, gen_helper_vfrecip_d)
TRANS(vfrsqrt_s, gen_vv, gen_helper_vfrsqrt_s)
TRANS(vfrsqrt_d, gen_vv, gen_helper_vfrsqrt_d)

TRANS(vfcvtl_s_h, gen_vv, gen_helper_vfcvtl_s_h)
TRANS(vfcvth_s_h, gen_vv, gen_helper_vfcvth_s_h)
TRANS(vfcvtl_d_s, gen_vv, gen_helper_vfcvtl_d_s)
TRANS(vfcvth_d_s, gen_vv, gen_helper_vfcvth_d_s)
TRANS(vfcvt_h_s, gen_vvv, gen_helper_vfcvt_h_s)
TRANS(vfcvt_s_d, gen_vvv, gen_helper_vfcvt_s_d)

TRANS(vfrintrne_s, gen_vv, gen_helper_vfrintrne_s)
TRANS(vfrintrne_d, gen_vv, gen_helper_vfrintrne_d)
TRANS(vfrintrz_s, gen_vv, gen_helper_vfrintrz_s)
TRANS(vfrintrz_d, gen_vv, gen_helper_vfrintrz_d)
TRANS(vfrintrp_s, gen_vv, gen_helper_vfrintrp_s)
TRANS(vfrintrp_d, gen_vv, gen_helper_vfrintrp_d)
TRANS(vfrintrm_s, gen_vv, gen_helper_vfrintrm_s)
TRANS(vfrintrm_d, gen_vv, gen_helper_vfrintrm_d)
TRANS(vfrint_s, gen_vv, gen_helper_vfrint_s)
TRANS(vfrint_d, gen_vv, gen_helper_vfrint_d)

TRANS(vftintrne_w_s, gen_vv, gen_helper_vftintrne_w_s)
TRANS(vftintrne_l_d, gen_vv, gen_helper_vftintrne_l_d)
TRANS(vftintrz_w_s, gen_vv, gen_helper_vftintrz_w_s)
TRANS(vftintrz_l_d, gen_vv, gen_helper_vftintrz_l_d)
TRANS(vftintrp_w_s, gen_vv, gen_helper_vftintrp_w_s)
TRANS(vftintrp_l_d, gen_vv, gen_helper_vftintrp_l_d)
TRANS(vftintrm_w_s, gen_vv, gen_helper_vftintrm_w_s)
TRANS(vftintrm_l_d, gen_vv, gen_helper_vftintrm_l_d)
TRANS(vftint_w_s, gen_vv, gen_helper_vftint_w_s)
TRANS(vftint_l_d, gen_vv, gen_helper_vftint_l_d)
TRANS(vftintrz_wu_s, gen_vv, gen_helper_vftintrz_wu_s)
TRANS(vftintrz_lu_d, gen_vv, gen_helper_vftintrz_lu_d)
TRANS(vftint_wu_s, gen_vv, gen_helper_vftint_wu_s)
TRANS(vftint_lu_d, gen_vv, gen_helper_vftint_lu_d)
TRANS(vftintrne_w_d, gen_vvv, gen_helper_vftintrne_w_d)
TRANS(vftintrz_w_d, gen_vvv, gen_helper_vftintrz_w_d)
TRANS(vftintrp_w_d, gen_vvv, gen_helper_vftintrp_w_d)
TRANS(vftintrm_w_d, gen_vvv, gen_helper_vftintrm_w_d)
TRANS(vftint_w_d, gen_vvv, gen_helper_vftint_w_d)
TRANS(vftintrnel_l_s, gen_vv, gen_helper_vftintrnel_l_s)
TRANS(vftintrneh_l_s, gen_vv, gen_helper_vftintrneh_l_s)
TRANS(vftintrzl_l_s, gen_vv, gen_helper_vftintrzl_l_s)
TRANS(vftintrzh_l_s, gen_vv, gen_helper_vftintrzh_l_s)
TRANS(vftintrpl_l_s, gen_vv, gen_helper_vftintrpl_l_s)
TRANS(vftintrph_l_s, gen_vv, gen_helper_vftintrph_l_s)
TRANS(vftintrml_l_s, gen_vv, gen_helper_vftintrml_l_s)
TRANS(vftintrmh_l_s, gen_vv, gen_helper_vftintrmh_l_s)
TRANS(vftintl_l_s, gen_vv, gen_helper_vftintl_l_s)
TRANS(vftinth_l_s, gen_vv, gen_helper_vftinth_l_s)

TRANS(vffint_s_w, gen_vv, gen_helper_vffint_s_w)
TRANS(vffint_d_l, gen_vv, gen_helper_vffint_d_l)
TRANS(vffint_s_wu, gen_vv, gen_helper_vffint_s_wu)
TRANS(vffint_d_lu, gen_vv, gen_helper_vffint_d_lu)
TRANS(vffintl_d_w, gen_vv, gen_helper_vffintl_d_w)
TRANS(vffinth_d_w, gen_vv, gen_helper_vffinth_d_w)
TRANS(vffint_s_l, gen_vvv, gen_helper_vffint_s_l)
56 changes: 56 additions & 0 deletions target/loongarch/insns.decode
Expand Up @@ -1046,3 +1046,59 @@ vfrecip_s 0111 00101001 11001 11101 ..... ..... @vv
vfrecip_d 0111 00101001 11001 11110 ..... ..... @vv
vfrsqrt_s 0111 00101001 11010 00001 ..... ..... @vv
vfrsqrt_d 0111 00101001 11010 00010 ..... ..... @vv

vfcvtl_s_h 0111 00101001 11011 11010 ..... ..... @vv
vfcvth_s_h 0111 00101001 11011 11011 ..... ..... @vv
vfcvtl_d_s 0111 00101001 11011 11100 ..... ..... @vv
vfcvth_d_s 0111 00101001 11011 11101 ..... ..... @vv
vfcvt_h_s 0111 00010100 01100 ..... ..... ..... @vvv
vfcvt_s_d 0111 00010100 01101 ..... ..... ..... @vvv

vfrint_s 0111 00101001 11010 01101 ..... ..... @vv
vfrint_d 0111 00101001 11010 01110 ..... ..... @vv
vfrintrm_s 0111 00101001 11010 10001 ..... ..... @vv
vfrintrm_d 0111 00101001 11010 10010 ..... ..... @vv
vfrintrp_s 0111 00101001 11010 10101 ..... ..... @vv
vfrintrp_d 0111 00101001 11010 10110 ..... ..... @vv
vfrintrz_s 0111 00101001 11010 11001 ..... ..... @vv
vfrintrz_d 0111 00101001 11010 11010 ..... ..... @vv
vfrintrne_s 0111 00101001 11010 11101 ..... ..... @vv
vfrintrne_d 0111 00101001 11010 11110 ..... ..... @vv

vftint_w_s 0111 00101001 11100 01100 ..... ..... @vv
vftint_l_d 0111 00101001 11100 01101 ..... ..... @vv
vftintrm_w_s 0111 00101001 11100 01110 ..... ..... @vv
vftintrm_l_d 0111 00101001 11100 01111 ..... ..... @vv
vftintrp_w_s 0111 00101001 11100 10000 ..... ..... @vv
vftintrp_l_d 0111 00101001 11100 10001 ..... ..... @vv
vftintrz_w_s 0111 00101001 11100 10010 ..... ..... @vv
vftintrz_l_d 0111 00101001 11100 10011 ..... ..... @vv
vftintrne_w_s 0111 00101001 11100 10100 ..... ..... @vv
vftintrne_l_d 0111 00101001 11100 10101 ..... ..... @vv
vftint_wu_s 0111 00101001 11100 10110 ..... ..... @vv
vftint_lu_d 0111 00101001 11100 10111 ..... ..... @vv
vftintrz_wu_s 0111 00101001 11100 11100 ..... ..... @vv
vftintrz_lu_d 0111 00101001 11100 11101 ..... ..... @vv
vftint_w_d 0111 00010100 10011 ..... ..... ..... @vvv
vftintrm_w_d 0111 00010100 10100 ..... ..... ..... @vvv
vftintrp_w_d 0111 00010100 10101 ..... ..... ..... @vvv
vftintrz_w_d 0111 00010100 10110 ..... ..... ..... @vvv
vftintrne_w_d 0111 00010100 10111 ..... ..... ..... @vvv
vftintl_l_s 0111 00101001 11101 00000 ..... ..... @vv
vftinth_l_s 0111 00101001 11101 00001 ..... ..... @vv
vftintrml_l_s 0111 00101001 11101 00010 ..... ..... @vv
vftintrmh_l_s 0111 00101001 11101 00011 ..... ..... @vv
vftintrpl_l_s 0111 00101001 11101 00100 ..... ..... @vv
vftintrph_l_s 0111 00101001 11101 00101 ..... ..... @vv
vftintrzl_l_s 0111 00101001 11101 00110 ..... ..... @vv
vftintrzh_l_s 0111 00101001 11101 00111 ..... ..... @vv
vftintrnel_l_s 0111 00101001 11101 01000 ..... ..... @vv
vftintrneh_l_s 0111 00101001 11101 01001 ..... ..... @vv

vffint_s_w 0111 00101001 11100 00000 ..... ..... @vv
vffint_s_wu 0111 00101001 11100 00001 ..... ..... @vv
vffint_d_l 0111 00101001 11100 00010 ..... ..... @vv
vffint_d_lu 0111 00101001 11100 00011 ..... ..... @vv
vffintl_d_w 0111 00101001 11100 00100 ..... ..... @vv
vffinth_d_w 0111 00101001 11100 00101 ..... ..... @vv
vffint_s_l 0111 00010100 10000 ..... ..... ..... @vvv

0 comments on commit 399665d

Please sign in to comment.