mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
target/riscv: vector widening floating-point add/subtract instructions
Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20200701152549.1218-32-zhiwei_liu@c-sky.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
ce2a0343f4
commit
eeffab2ec1
4 changed files with 257 additions and 0 deletions
|
@ -1901,3 +1901,152 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
|
|||
GEN_OPFVF_TRANS(vfadd_vf, opfvf_check)
|
||||
GEN_OPFVF_TRANS(vfsub_vf, opfvf_check)
|
||||
GEN_OPFVF_TRANS(vfrsub_vf, opfvf_check)
|
||||
|
||||
/* Vector Widening Floating-Point Add/Subtract Instructions */
|
||||
static bool opfvv_widen_check(DisasContext *s, arg_rmrr *a)
|
||||
{
|
||||
return (vext_check_isa_ill(s) &&
|
||||
vext_check_overlap_mask(s, a->rd, a->vm, true) &&
|
||||
vext_check_reg(s, a->rd, true) &&
|
||||
vext_check_reg(s, a->rs2, false) &&
|
||||
vext_check_reg(s, a->rs1, false) &&
|
||||
vext_check_overlap_group(a->rd, 2 << s->lmul, a->rs2,
|
||||
1 << s->lmul) &&
|
||||
vext_check_overlap_group(a->rd, 2 << s->lmul, a->rs1,
|
||||
1 << s->lmul) &&
|
||||
(s->lmul < 0x3) && (s->sew < 0x3) && (s->sew != 0));
|
||||
}
|
||||
|
||||
/* OPFVV with WIDEN */
|
||||
#define GEN_OPFVV_WIDEN_TRANS(NAME, CHECK) \
|
||||
static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
|
||||
{ \
|
||||
if (CHECK(s, a)) { \
|
||||
uint32_t data = 0; \
|
||||
static gen_helper_gvec_4_ptr * const fns[2] = { \
|
||||
gen_helper_##NAME##_h, gen_helper_##NAME##_w, \
|
||||
}; \
|
||||
TCGLabel *over = gen_new_label(); \
|
||||
gen_set_rm(s, 7); \
|
||||
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \
|
||||
\
|
||||
data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \
|
||||
data = FIELD_DP32(data, VDATA, VM, a->vm); \
|
||||
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
|
||||
tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
|
||||
vreg_ofs(s, a->rs1), \
|
||||
vreg_ofs(s, a->rs2), cpu_env, 0, \
|
||||
s->vlen / 8, data, fns[s->sew - 1]); \
|
||||
gen_set_label(over); \
|
||||
return true; \
|
||||
} \
|
||||
return false; \
|
||||
}
|
||||
|
||||
GEN_OPFVV_WIDEN_TRANS(vfwadd_vv, opfvv_widen_check)
|
||||
GEN_OPFVV_WIDEN_TRANS(vfwsub_vv, opfvv_widen_check)
|
||||
|
||||
static bool opfvf_widen_check(DisasContext *s, arg_rmrr *a)
|
||||
{
|
||||
return (vext_check_isa_ill(s) &&
|
||||
vext_check_overlap_mask(s, a->rd, a->vm, true) &&
|
||||
vext_check_reg(s, a->rd, true) &&
|
||||
vext_check_reg(s, a->rs2, false) &&
|
||||
vext_check_overlap_group(a->rd, 2 << s->lmul, a->rs2,
|
||||
1 << s->lmul) &&
|
||||
(s->lmul < 0x3) && (s->sew < 0x3) && (s->sew != 0));
|
||||
}
|
||||
|
||||
/* OPFVF with WIDEN */
|
||||
#define GEN_OPFVF_WIDEN_TRANS(NAME) \
|
||||
static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
|
||||
{ \
|
||||
if (opfvf_widen_check(s, a)) { \
|
||||
uint32_t data = 0; \
|
||||
static gen_helper_opfvf *const fns[2] = { \
|
||||
gen_helper_##NAME##_h, gen_helper_##NAME##_w, \
|
||||
}; \
|
||||
gen_set_rm(s, 7); \
|
||||
data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \
|
||||
data = FIELD_DP32(data, VDATA, VM, a->vm); \
|
||||
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
|
||||
return opfvf_trans(a->rd, a->rs1, a->rs2, data, \
|
||||
fns[s->sew - 1], s); \
|
||||
} \
|
||||
return false; \
|
||||
}
|
||||
|
||||
GEN_OPFVF_WIDEN_TRANS(vfwadd_vf)
|
||||
GEN_OPFVF_WIDEN_TRANS(vfwsub_vf)
|
||||
|
||||
static bool opfwv_widen_check(DisasContext *s, arg_rmrr *a)
|
||||
{
|
||||
return (vext_check_isa_ill(s) &&
|
||||
vext_check_overlap_mask(s, a->rd, a->vm, true) &&
|
||||
vext_check_reg(s, a->rd, true) &&
|
||||
vext_check_reg(s, a->rs2, true) &&
|
||||
vext_check_reg(s, a->rs1, false) &&
|
||||
vext_check_overlap_group(a->rd, 2 << s->lmul, a->rs1,
|
||||
1 << s->lmul) &&
|
||||
(s->lmul < 0x3) && (s->sew < 0x3) && (s->sew != 0));
|
||||
}
|
||||
|
||||
/* WIDEN OPFVV with WIDEN */
|
||||
#define GEN_OPFWV_WIDEN_TRANS(NAME) \
|
||||
static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
|
||||
{ \
|
||||
if (opfwv_widen_check(s, a)) { \
|
||||
uint32_t data = 0; \
|
||||
static gen_helper_gvec_4_ptr * const fns[2] = { \
|
||||
gen_helper_##NAME##_h, gen_helper_##NAME##_w, \
|
||||
}; \
|
||||
TCGLabel *over = gen_new_label(); \
|
||||
gen_set_rm(s, 7); \
|
||||
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \
|
||||
\
|
||||
data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \
|
||||
data = FIELD_DP32(data, VDATA, VM, a->vm); \
|
||||
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
|
||||
tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
|
||||
vreg_ofs(s, a->rs1), \
|
||||
vreg_ofs(s, a->rs2), cpu_env, 0, \
|
||||
s->vlen / 8, data, fns[s->sew - 1]); \
|
||||
gen_set_label(over); \
|
||||
return true; \
|
||||
} \
|
||||
return false; \
|
||||
}
|
||||
|
||||
GEN_OPFWV_WIDEN_TRANS(vfwadd_wv)
|
||||
GEN_OPFWV_WIDEN_TRANS(vfwsub_wv)
|
||||
|
||||
static bool opfwf_widen_check(DisasContext *s, arg_rmrr *a)
|
||||
{
|
||||
return (vext_check_isa_ill(s) &&
|
||||
vext_check_overlap_mask(s, a->rd, a->vm, true) &&
|
||||
vext_check_reg(s, a->rd, true) &&
|
||||
vext_check_reg(s, a->rs2, true) &&
|
||||
(s->lmul < 0x3) && (s->sew < 0x3) && (s->sew != 0));
|
||||
}
|
||||
|
||||
/* WIDEN OPFVF with WIDEN */
|
||||
#define GEN_OPFWF_WIDEN_TRANS(NAME) \
|
||||
static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
|
||||
{ \
|
||||
if (opfwf_widen_check(s, a)) { \
|
||||
uint32_t data = 0; \
|
||||
static gen_helper_opfvf *const fns[2] = { \
|
||||
gen_helper_##NAME##_h, gen_helper_##NAME##_w, \
|
||||
}; \
|
||||
gen_set_rm(s, 7); \
|
||||
data = FIELD_DP32(data, VDATA, MLEN, s->mlen); \
|
||||
data = FIELD_DP32(data, VDATA, VM, a->vm); \
|
||||
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
|
||||
return opfvf_trans(a->rd, a->rs1, a->rs2, data, \
|
||||
fns[s->sew - 1], s); \
|
||||
} \
|
||||
return false; \
|
||||
}
|
||||
|
||||
GEN_OPFWF_WIDEN_TRANS(vfwadd_wf)
|
||||
GEN_OPFWF_WIDEN_TRANS(vfwsub_wf)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue