target/riscv: support vector extension v0.9
cover target/riscv: support vector extension v0.9
From: Frank Chang <[email protected]>
This patchset implements the vector extension v0.9 for RISC-V on QEMU.
This patchset is sent as RFC because RVV v0.9 is still in draft state. However, as RVV v1.0 should be ratified soon and there shouldn't be critical changes between RVV v1.0 and RVV v0.9. We would like to have the community to review RVV v0.9 implementations. Once RVV v1.0 is ratified, we will then upgrade to RVV v1.0.
You can change the cpu argument: vext_spec to v0.9 (i.e. vext_spec=v0.9) to run with RVV v0.9 instructions.
Chih-Min Chao (2):
fpu: fix float16 nan check
fpu: add api to handle alternative sNaN propagation
Frank Chang (58):
target/riscv: fix rsub gvec tcg_assert_listed_vecop assertion target/riscv: correct the gvec IR called in gen_vec_rsub16_i64() target/riscv: fix return value of do_opivx_widen() target/riscv: fix vill bit index in vtype register target/riscv: remove vsll.vi, vsrl.vi, vsra.vi insns from using gvec target/riscv: rvv-0.9: remove MLEN calculations target/riscv: rvv-0.9: add fractional LMUL, VTA and VMA target/riscv: rvv-0.9: update check functions target/riscv: rvv-0.9: configure instructions target/riscv: rvv-0.9: stride load and store instructions target/riscv: rvv-0.9: index load and store instructions target/riscv: rvv-0.9: fix address index overflow bug of indexed
load/store insns
target/riscv: rvv-0.9: fault-only-first unit stride load target/riscv: rvv-0.9: amo operations
target/riscv: rvv-0.9: load/store whole register instructions target/riscv: rvv-0.9: update vext_max_elems() for load/store insns target/riscv: rvv-0.9: take fractional LMUL into vector max elements
calculation
target/riscv: rvv-0.9: floating-point square-root instruction target/riscv: rvv-0.9: floating-point classify instructions target/riscv: rvv-0.9: mask population count instruction target/riscv: rvv-0.9: find-first-set mask bit instruction target/riscv: rvv-0.9: set-X-first mask bit instructions target/riscv: rvv-0.9: iota instruction
target/riscv: rvv-0.9: element index instruction target/riscv: rvv-0.9: integer scalar move instructions target/riscv: rvv-0.9: floating-point scalar move instructions target/riscv: rvv-0.9: whole register move instructions target/riscv: rvv-0.9: integer extension instructions target/riscv: rvv-0.9: single-width averaging add and subtract
instructions
target/riscv: rvv-0.9: integer add-with-carry/subtract-with-borrow target/riscv: rvv-0.9: narrowing integer right shift instructions target/riscv: rvv-0.9: widening integer multiply-add instructions target/riscv: rvv-0.9: quad-widening integer multiply-add instructions target/riscv: rvv-0.9: integer merge and move instructions target/riscv: rvv-0.9: single-width saturating add and subtract
instructions
target/riscv: rvv-0.9: integer comparison instructions target/riscv: rvv-0.9: floating-point compare instructions target/riscv: rvv-0.9: single-width integer reduction instructions target/riscv: rvv-0.9: widening integer reduction instructions target/riscv: rvv-0.9: mask-register logical instructions target/riscv: rvv-0.9: register gather instructions target/riscv: rvv-0.9: slide instructions
target/riscv: rvv-0.9: floating-point slide instructions target/riscv: rvv-0.9: narrowing fixed-point clip instructions target/riscv: rvv-0.9: floating-point move instructions target/riscv: rvv-0.9: floating-point/integer type-convert
instructions
target/riscv: rvv-0.9: single-width floating-point reduction target/riscv: rvv-0.9: widening floating-point reduction instructions target/riscv: rvv-0.9: single-width scaling shift instructions target/riscv: rvv-0.9: remove widening saturating scaled multiply-add target/riscv: rvv-0.9: remove vmford.vv and vmford.vf target/riscv: rvv-0.9: remove integer extract instruction target/riscv: rvv-0.9: floating-point min/max instructions target/riscv: rvv-0.9: widening floating-point/integer type-convert target/riscv: rvv-0.9: narrowing floating-point/integer type-convert
softfloat: add fp16 and uint8/int8 interconvert functions target/riscv: use softfloat lib float16 comparison functions target/riscv: bump to RVV 0.9
Kito Cheng (1):
fpu: implement full set compare for fp16
LIU Zhiwei (4):
target/riscv: rvv-0.9: add vcsr register target/riscv: rvv-0.9: add vector context status target/riscv: rvv-0.9: update mstatus_vs by tb_flags target/riscv: rvv-0.9: add vlenb register
fpu/softfloat-specialize.inc.c | 4 +- fpu/softfloat.c | 342 +++- include/fpu/softfloat.h | 22 + target/riscv/cpu.c | 9 +- target/riscv/cpu.h | 68 +- target/riscv/cpu_bits.h | 9 + target/riscv/cpu_helper.c | 13 + target/riscv/csr.c | 53 +- target/riscv/helper.h | 507 +++-- target/riscv/insn32-64.decode | 18 +- target/riscv/insn32.decode | 282 +-- target/riscv/insn_trans/trans_rvv.inc.c | 2468 ++++++++++++++--------- target/riscv/internals.h | 18 +- target/riscv/translate.c | 43 +- target/riscv/vector_helper.c | 2349 +++++++++++---------- 15 files changed, 3833 insertions(+), 2372 deletions(-)
--
2.17.1
RFC 1/65 target/riscv: fix rsub gvec tcg_assert_listed_vecop assertion
From: Frank Chang <[email protected]>
gvec should provide vecop_list to avoid:
"tcg_tcg_assert_listed_vecop: code should not be reached bug" assertion.
--- target/riscv/insn_trans/trans_rvv.inc.c | 5 +++++ 1 file changed, 5 insertions(+)
target/riscv/insn_trans/trans_rvv.inc.c +5 -0
@@ -958,22 +958,27 @@ static void gen_rsub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)static void tcg_gen_gvec_rsubs (unsigned vece,uint32_t dofs,uint32_t aofs,TCGv_i64 c,uint32_t oprsz,uint32_t maxsz) { +static const TCGOpcode vecop_list[] = { INDEX_op_sub_vec,0 };static const GVecGen2s rsub_op[4 ] = { { .fni8 = gen_vec_rsub8_i64, .fniv = gen_rsub_vec, .fno = gen_helper_vec_rsubs8, + .opt_opc = vecop_list, .vece =MO_8 }, { .fni8 = gen_vec_rsub16_i64, .fniv = gen_rsub_vec, .fno = gen_helper_vec_rsubs16, + .opt_opc = vecop_list, .vece =MO_16 }, { .fni4 = gen_rsub_i32, .fniv = gen_rsub_vec, .fno = gen_helper_vec_rsubs32, + .opt_opc = vecop_list, .vece =MO_32 }, { .fni8 = gen_rsub_i64, .fniv = gen_rsub_vec, .fno = gen_helper_vec_rsubs64, + .opt_opc = vecop_list, .prefer_i64 =TCG_TARGET_REG_BITS ==64 , .vece =MO_64 }, };
Signature · 1 line
2.17.1
Re: [RFC 01/65] target/riscv: fix rsub gvec tcg_assert_listed_vecop assertion
Quoted 9 lines · On 7/10/20 3:48 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
gvec should provide
vecop_listto avoid:
"tcg_tcg_assert_listed_vecop: code should not be reached bug" assertion.Signed-off-by Frank Chang <[email protected]>--- target/riscv/insn_trans/trans_rvv.inc.c | 5 +++++ 1 file changed, 5 insertions(+)
Alistair, this one should be queued for 5.1 as a bug fix.
r~
Re: [RFC 01/65] target/riscv: fix rsub gvec tcg_assert_listed_vecop assertion
Quoted 7 lines · Richard Henderson
Quoted 5 lines · On 7/10/20 3:48 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
gvec should provide
vecop_listto avoid:
"tcg_tcg_assert_listed_vecop: code should not be reached bug" assertion.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Frank Chang <[email protected]>--- target/riscv/insn_trans/trans_rvv.inc.c | 5 +++++ 1 file changed, 5 insertions(+)Reviewed-by Richard Henderson <[email protected]>Alistair, this one should be queued for 5.1 as a bug fix.
Thanks for reviewing these. I have applied the first 4 to my PR for 5.1.
Alistair
Quoted 4 lines
r~
RFC 2/65 target/riscv: correct the gvec IR called in gen_vec_rsub16_i64()
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn_trans/trans_rvv.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/insn_trans/trans_rvv.inc.c +1 -1
@@ -937,7 +937,7 @@ static void gen_vec_rsub8_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b)static void gen_vec_rsub16_i64 (TCGv_i64 d,TCGv_i64 a,TCGv_i64 b) { -tcg_gen_vec_sub8_i64 (d, b, a); +tcg_gen_vec_sub16_i64 (d, b, a); }static void gen_rsub_i32 (TCGv_i32 ret,TCGv_i32 arg1,TCGv_i32 arg2)
Signature · 1 line
2.17.1
Re: [RFC 02/65] target/riscv: correct the gvec IR called in gen_vec_rsub16_i64()
Quoted 6 lines · On 7/10/20 3:48 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>--- target/riscv/insn_trans/trans_rvv.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Alistair, this one should be queued for 5.1 as a bug fix.
r~
RFC 3/65 target/riscv: fix return value of do_opivx_widen()
In reply to [email protected]From: Frank Chang <[email protected]>
do_opivx_widen() should return false if check function returns false.
--- target/riscv/insn_trans/trans_rvv.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/insn_trans/trans_rvv.inc.c +1 -1
@@ -1151,7 +1151,7 @@ static bool do_opivx_widen(DisasContext *s, arg_rmrr *a,if (opivx_widen_check (s, a)) {return opivx_trans (a->rd, a->rs1, a->rs2, a->vm, fn, s); } -return true; +return false; }#define GEN_OPIVX_WIDEN_TRANS (NAME ) \
Signature · 1 line
2.17.1
Re: [RFC 03/65] target/riscv: fix return value of do_opivx_widen()
Quoted 8 lines · On 7/10/20 3:48 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
do_opivx_widen()should return false if check function returns false.Signed-off-by Frank Chang <[email protected]>--- target/riscv/insn_trans/trans_rvv.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Alistair, this one should be queued for 5.1 as a bug fix.
r~
RFC 4/65 target/riscv: fix vill bit index in vtype register
In reply to [email protected]From: Frank Chang <[email protected]>
vill bit is at vtype[XLEN-1].
--- target/riscv/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/cpu.h +1 -1
@@ -98,7 +98,7 @@ FIELD(VTYPE, VLMUL, 0, 2) FIELD(VTYPE, VSEW, 2, 3) FIELD(VTYPE, VEDIV, 5, 2) FIELD(VTYPE, RESERVED, 7, sizeof(target_ulong) * 8 - 9) -FIELD(VTYPE, VILL, sizeof(target_ulong) * 8 - 2, 1) +FIELD(VTYPE, VILL, sizeof(target_ulong) * 8 - 1, 1)struct CPURISCVState {target_ulong gpr[32 ];
Signature · 1 line
2.17.1
Re: [RFC 04/65] target/riscv: fix vill bit index in vtype register
Quoted 8 lines · On 7/10/20 3:48 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
vill bit is at vtype[XLEN-1].
Signed-off-by Frank Chang <[email protected]>--- target/riscv/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Alistair, this one should be queued for 5.1 as a bug fix.
r~
RFC 5/65 target/riscv: remove vsll.vi, vsrl.vi, vsra.vi insns from using gvec
In reply to [email protected]From: Frank Chang <[email protected]>
vsll.vi, vsrl.vi, vsra.vi cannot use shli gvec as it requires the shift immediate value to be within the range: [0.. SEW bits]. Otherwise, it will hit the assertion:tcg_debug_assert(shift >= 0 && shift < (8 << vece));
However, RVV spec does not have such constraint, therefore we have to use helper functions instead.
--- target/riscv/insn_trans/trans_rvv.inc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +3 -3
@@ -1427,9 +1427,9 @@ GEN_OPIVX_GVEC_SHIFT_TRANS(vsll_vx, shls) GEN_OPIVX_GVEC_SHIFT_TRANS(vsrl_vx, shrs) GEN_OPIVX_GVEC_SHIFT_TRANS(vsra_vx, sars) -GEN_OPIVI_GVEC_TRANS(vsll_vi, 1, vsll_vx, shli) -GEN_OPIVI_GVEC_TRANS(vsrl_vi, 1, vsrl_vx, shri) -GEN_OPIVI_GVEC_TRANS (vsra_vi,1 , vsra_vx, sari) +GEN_OPIVI_TRANS(vsll_vi, 1, vsll_vx, opivx_check) +GEN_OPIVI_TRANS(vsrl_vi, 1, vsrl_vx, opivx_check) +GEN_OPIVI_TRANS (vsra_vi,1 , vsra_vx, opivx_check) /* Vector Narrowing Integer Right Shift Instructions */static bool opivv_narrow_check (DisasContext *s,arg_rmrr *a)
Signature · 1 line
2.17.1
Re: [RFC 05/65] target/riscv: remove vsll.vi, vsrl.vi, vsra.vi insns from using gvec
Quoted 9 lines · On 7/10/20 3:48 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
vsll.vi, vsrl.vi, vsra.vi cannot use shli gvec as it requires the shift immediate value to be within the range: [0.. SEW bits]. Otherwise, it will hit the assertion:
tcg_debug_assert(shift >= 0 && shift < (8 << vece));However, RVV spec does not have such constraint, therefore we have to use helper functions instead.
Why do you say that? It does have such a constraint:
# Only the low lg2(SEW) bits are read to obtain the shift amount from a register value.
While that only talks about the register value, I sincerely doubt that the same truncation does not actually apply to immediates.
And if the entire immediate value does apply, the manual should certainly specify what should happen in that case. And at present it doesn't.
It seems to me the bug is the bare use of GEN_OPIVI_GVEC_TRANS and thence do_opivi_gvec. The ZX parameter should be extended to more than just "zero vs sign-extend", it should have an option for truncating the immediate to s->sew.
r~
Re: [RFC 05/65] target/riscv: remove vsll.vi, vsrl.vi, vsra.vi insns from using gvec
Quoted 23 lines · Richard Henderson
Quoted 9 lines · On 7/10/20 3:48 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
vsll.vi, vsrl.vi, vsra.vi cannot use shli gvec as it requires the shift immediate value to be within the range: [0.. SEW bits]. Otherwise, it will hit the assertion:
tcg_debug_assert(shift >= 0 && shift < (8 << vece));However, RVV spec does not have such constraint, therefore we have to use helper functions instead.
Why do you say that? It does have such a constraint:
# Only the low lg2(SEW) bits are read to obtain the shift amount from a register value.
While that only talks about the register value, I sincerely doubt that the same
truncation does not actually apply to immediates.And if the entire immediate value does apply, the manual should certainly specify what should happen in that case. And at present it doesn't.
Quoted 9 lines
It seems to me the bug is the bare use of
GEN_OPIVI_GVEC_TRANSand thencedo_opivi_gvec. The ZX parameter should be extended to more than just "zero vs
sign-extend", it should have an option for truncating the immediate tos->sew.r~
The latest spec specified:
Only the low *lg2(SEW) bits* are read to obtain the shift amount from a *register
value*.
The *immediate* is treated as an *unsigned shift amount*, with a *maximum shift amount of 31*.
Looks like the shift amount in the immediate value is not relevant with SEW setting.
If so, is it better to just use do_opivi_gvec() and implement the logic by our own rather than using gvec IR?
Frank Chang
Re: [RFC 05/65] target/riscv: remove vsll.vi, vsrl.vi, vsra.vi insns from using gvec
Quoted 42 lines · Frank Chang
On Sat, Jul 11, 2020 at 12:27 AM Richard Henderson <[email protected] <mailto:[email protected]>> wrote:
On 7/10/20 3:48 AM, [email protected] <mailto:[email protected]> wrote:
> From: Frank Chang <[email protected] <mailto:[email protected]>>
>
> vsll.vi <http://vsll.vi>, vsrl.vi <http://vsrl.vi>, vsra.vi
<http://vsra.vi> cannot use shli gvec as it requires the > shift immediate value to be within the range: [0.. SEW bits]. > Otherwise, it will hit the assertion:
>tcg_debug_assert(shift >= 0 && shift < (8 << vece)); >
> However, RVV spec does not have such constraint, therefore we have to
> use helper functions instead.Why do you say that? It does have such a constraint:
# Only the low lg2(SEW) bits are read to obtain the shift amount from a
register value.While that only talks about the register value, I sincerely doubt that the same
truncation does not actually apply to immediates.And if the entire immediate value does apply, the manual should certainly
specify what should happen in that case. And at present it doesn't.It seems to me the bug is the bare use of
GEN_OPIVI_GVEC_TRANSand thence
do_opivi_gvec. The ZX parameter should be extended to more than just "zero vs
sign-extend", it should have an option for truncating the immediate tos->sew.r~
Quoted 7 lines
The latest spec specified:
Only the low *lg2(SEW) bits* are read to obtain the shift amount from a *register value*. The *immediate* is treated as an *unsigned shift amount*, with a *maximum shift amount of 31*.
Looks like the shift amount in the immediate value is not relevant with SEW setting.
If so, is it better to just usedo_opivi_gvec()and implement the logic by our own rather than using gvec IR?
In my opinion, it doesn't matter to truncate the immediate to s->sew before calling the gvec IR, whether the constraint of immediate exits or not.
Zhiwei
Quoted 2 lines
Frank Chang
Re: [RFC 05/65] target/riscv: remove vsll.vi, vsrl.vi, vsra.vi insns from using gvec
Quoted 53 lines · LIU Zhiwei
On 2020/7/14 10:59, Frank Chang wrote:
Quoted 23 lines · Richard Henderson
Quoted 9 lines · On 7/10/20 3:48 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
vsll.vi, vsrl.vi, vsra.vi cannot use shli gvec as it requires the shift immediate value to be within the range: [0.. SEW bits]. Otherwise, it will hit the assertion:
tcg_debug_assert(shift >= 0 && shift < (8 << vece));However, RVV spec does not have such constraint, therefore we have to use helper functions instead.
Why do you say that? It does have such a constraint:
# Only the low lg2(SEW) bits are read to obtain the shift amount from a register value.
While that only talks about the register value, I sincerely doubt that the same
truncation does not actually apply to immediates.And if the entire immediate value does apply, the manual should certainly specify what should happen in that case. And at present it doesn't.
Quoted 9 lines
It seems to me the bug is the bare use of
GEN_OPIVI_GVEC_TRANSand thencedo_opivi_gvec. The ZX parameter should be extended to more than just "zero vs
sign-extend", it should have an option for truncating the immediate tos->sew.r~
The latest spec specified:
Only the low *lg2(SEW) bits* are read to obtain the shift amount from a *register value*.
The *immediate* is treated as an *unsigned shift amount*, with a *maximum shift amount of 31*.Looks like the shift amount in the immediate value is not relevant with SEW setting.
If so, is it better to just usedo_opivi_gvec()and implement the logic by our own rather than using gvec IR?
Quoted 11 lines
In my opinion, it doesn't matter to truncate the immediate to
s->sewbefore calling the gvec IR,
whether the constraint of immediate exits or not.Zhiwei
Frank Chang
The current issue I've encountered is the test like:
*vsetvli t0,t0,e8,m1,tu,mu,d1*
*vsll.vi <http://vsll.vi> v30, v30, 27*
where the SEW is 8 (i.e. vece = 0), but the immediate value is: 27. The instruction doesn't violate the requirement specified in spec as its value is less then 31.
However, it can't pass *tcg_debug_assert(shift >= 0 && shift < (8 << vece));* assertion if tcg debug option is enabled.
Frank Chang
Re: [RFC 05/65] target/riscv: remove vsll.vi, vsrl.vi, vsra.vi insns from using gvec
In reply to Frank ChangQuoted 6 lines · Frank Chang
The latest spec specified:
Only the low *lg2(SEW) bits* are read to obtain the shift amount from a *register value*.
The *immediate* is treated as an *unsigned shift amount*, with a *maximum shift amount of 31*.
Which, I hope you will agree is underspecified, and should be reported as a bug in the manual.
Quoted 2 lines
Looks like the shift amount in the immediate value is not relevant with SEW setting.
How can it not be? It is when the value comes from a register...
Quoted 2 lines
If so, is it better to just use
do_opivi_gvec()and implement the logic by our own rather than using gvec IR?
No, it is not. What is the logic you would apply on your own? There should be a right answer.
If the answer is that out-of-range shift produces zero, which some architectures use, then you can look at the immediate value, see that you must supply zero, and then fill the vector with zeros from translate. You need not call a helper to perform N shifts when you know the result a-priori.
If the answer is that shift values are truncated, which riscv uses *everywhere else*, then you should truncate the immediate value during translate.
r~
Re: [RFC 05/65] target/riscv: remove vsll.vi, vsrl.vi, vsra.vi insns from using gvec
Quoted 6 lines · Richard Henderson
Quoted 5 lines · Frank Chang
The latest spec specified:
Only the low *lg2(SEW) bits* are read to obtain the shift amount from a *register value*.
The *immediate* is treated as an *unsigned shift amount*, with a
Quoted 7 lines
*maximum shift
Quoted 1 line
amount of 31*.
Which, I hope you will agree is underspecified, and should be reported as a bug
in the manual.
Yes, you're correct.
I found out I missed the MASK part in GEN_VEXT_SHIFT_VV() macro, which this macro is shared between OPIVV and OPIVI format of instructions. So the same masking methodology should be applied to shift amounts coming from both register and immediate value.
Spike also does something like:
*vs2 >> (zimm5 & (sew - 1) & 0x1f);* for SEW = 8.
I think spec is kind of misleading to the reader by the way it expresses.
Quoted 7 lines
Quoted 2 lines
Looks like the shift amount in the immediate value is not relevant with
SEW
Quoted 1 line
setting.
How can it not be? It is when the value comes from a register...
Quoted 8 lines
Quoted 1 line
If so, is it better to just use
do_opivi_gvec()and implement the logicby our
Quoted 1 line
own rather than using gvec IR?
No, it is not. What is the logic you would apply on your own? There should be
a right answer.
I was talking about just calling GEN_OPIVI_TRANS() to generate the helper functions
defined in vector_helper.c as what I'm doing in the original patch. But as long as the immediate value should also apply *lg2(SEW) bits* truncating,
I think I should update GEN_OPIVI_GVEC_TRANS() to utilize gvec IR.
Quoted 8 lines
If the answer is that out-of-range shift produces zero, which some architectures use, then you can look at the immediate value, see that you must
supply zero, and then fill the vector with zeros from translate. You need not
call a helper to perform N shifts when you know the result a-priori.
Quoted 4 lines
If the answer is that shift values are truncated, which riscv uses *everywhere
else*, then you should truncate the immediate value during translate.
I think vsll.vi, vsrl.vi and vsra.vi truncate the out-of-range shift as other riscv instructions.
I will double confirm that, thanks for the advice.
Frank Chang
Quoted 4 lines
r~
Re: [RFC 05/65] target/riscv: remove vsll.vi, vsrl.vi, vsra.vi insns from using gvec
Quoted 55 lines · Frank Chang
On Tue, Jul 14, 2020 at 9:21 PM Richard Henderson <[email protected] <mailto:[email protected]>> wrote:
On 7/13/20 7:59 PM, Frank Chang wrote:
> The latest spec specified:
>
> Only the low *lg2(SEW) bits* are read to obtain the shift amount from a
> *register value*.
> The *immediate* is treated as an *unsigned shift amount*, with a *maximum shift
> amount of 31*.Which, I hope you will agree is underspecified, and should be reported as a bug
in the manual.Yes, you're correct.
I found out I missed the MASK part in GEN_VEXT_SHIFT_VV() macro,
which this macro is shared between OPIVV and OPIVI format of instructions.
So the same masking methodology should be applied to shift amounts coming from both register and immediate value. Spike also does something like:
/vs2 >> (zimm5 & (sew - 1) & 0x1f);/ for SEW = 8.I think spec is kind of misleading to the reader by the way it expresses.
Quoted 1 line
Looks like the shift amount in the immediate value is not
relevant with SEW
> setting.How can it not be? It is when the value comes from a register...
> If so, is it better to just use
do_opivi_gvec()and implement the logic by our
> own rather than using gvec IR?No, it is not. What is the logic you would apply on your own? There should be
a right answer.I was talking about just calling
GEN_OPIVI_TRANS()to generate the helper functions defined invector_helper.cas what I'm doing in the original patch. But as long as the immediate value should also apply *lg2(SEW) bits* truncating, I think I should updateGEN_OPIVI_GVEC_TRANS()to utilize gvec IR.If the answer is that out-of-range shift produces zero, which some architectures use, then you can look at the immediate value, see that you must
supply zero, and then fill the vector with zeros from translate. You need not
call a helper to perform N shifts when you know the result a-priori.
Quoted 8 lines
If the answer is that shift values are truncated, which riscv uses *everywhere
else*, then you should truncate the immediate value during translate.I think vsll.vi <http://vsll.vi>, vsrl.vi <http://vsrl.vi> and vsra.vi <http://vsra.vi> truncate the out-of-range shift as other riscv instructions. I will double confirm that, thanks for the advice.
Perhaps the reason is that the assembler can't identify if an imm is legal according to log(SEW), because the assembler can't get the SEW.
To make more compliance with assembler directly users' intuition, just let the imm encoding to insn as itself(truncate to 31) and work as itself.
Zhiwei
Quoted 6 lines
Frank Chang
r~
RFC 6/65 target/riscv: rvv-0.9: add vcsr register
In reply to [email protected]From: LIU Zhiwei <[email protected]>
--- target/riscv/cpu_bits.h | 7 +++++++ target/riscv/csr.c | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+)
target/riscv/cpu_bits.h +7 -0
@@ -60,9 +60,16 @@#define CSR_VSTART 0x008#define CSR_VXSAT 0x009#define CSR_VXRM 0x00a +#define CSR_VCSR 0x00f#define CSR_VL 0xc20#define CSR_VTYPE 0xc21 +/* VCSR fields */ +#define VCSR_VXSAT_SHIFT 0 +#define VCSR_VXSAT (0x1 << VCSR_VXSAT_SHIFT) +#define VCSR_VXRM_SHIFT 1 +#define VCSR_VXRM (0x3 << VCSR_VXRM_SHIFT) +/* User Timers and Counters */ #define CSR_CYCLE 0xc00#define CSR_TIME 0xc01
target/riscv/csr.c +21 -0
@@ -238,6 +238,26 @@ static int write_vstart(CPURISCVState *env, int csrno, target_ulong val)return 0 ; } +static int read_vcsr (CPURISCVState *env,int csrno,target_ulong *val) +{ + *val = (env->vxrm <<VCSR_VXRM_SHIFT ) | (env->vxsat <<VCSR_VXSAT_SHIFT ); +return 0 ; +} + +static int write_vcsr (CPURISCVState *env,int csrno,target_ulong val) +{ +#if !defined(CONFIG_USER_ONLY ) +if (!env->debugger && !riscv_cpu_vector_enabled (env)) { +return -1 ; + } + env->mstatus |=MSTATUS_VS ; +#endif + + env->vxrm = (val &VCSR_VXRM ) >>VCSR_VXRM_SHIFT ; + env->vxsat = (val &VCSR_VXSAT ) >>VCSR_VXSAT_SHIFT ; +return 0 ; +} +/* User Timers and Counters */ static int read_instret (CPURISCVState *env,int csrno,target_ulong *val) {
@@ -1255,6 +1275,7 @@ static riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_VSTART] = { vs, read_vstart, write_vstart }, [CSR_VXSAT] = { vs, read_vxsat, write_vxsat }, [CSR_VXRM] = { vs, read_vxrm, write_vxrm }, + [CSR_VCSR] = { vs, read_vcsr, write_vcsr }, [CSR_VL] = { vs, read_vl }, [CSR_VTYPE] = { vs, read_vtype }, /* User Timers and Counters */
Signature · 1 line
2.17.1
Re: [RFC 06/65] target/riscv: rvv-0.9: add vcsr register
Quoted 1 line · On 7/10/20 3:48 AM, [email protected] wrote:
+ [
CSR_VCSR] = { vs,read_vcsr,write_vcsr},
As long as you have the vext_spec argument, you need a separate vs_0_9 predicate function, so that this csr is not available to VEXT_VERSION_0_07_1.
r~
RFC 7/65 target/riscv: rvv-0.9: add vector context status
In reply to [email protected]From: LIU Zhiwei <[email protected]>
--- target/riscv/cpu.h | 4 ++ target/riscv/cpu_bits.h | 1 + target/riscv/cpu_helper.c | 13 ++++++ target/riscv/csr.c | 25 ++++++++++- target/riscv/insn_trans/trans_rvv.inc.c | 57 +++++++++++++++++++++---- target/riscv/translate.c | 32 ++++++++++++++ 6 files changed, 123 insertions(+), 9 deletions(-)
target/riscv/cpu.h +4 -0
@@ -317,6 +317,7 @@ int riscv_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);int riscv_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);bool riscv_cpu_exec_interrupt (CPUState *cs,int interrupt_request);bool riscv_cpu_fp_enabled (CPURISCVState *env); +bool riscv_cpu_vector_enabled (CPURISCVState *env);bool riscv_cpu_virt_enabled (CPURISCVState *env);void riscv_cpu_set_virt_enabled (CPURISCVState *env,bool enable);bool riscv_cpu_force_hs_excep_enabled (CPURISCVState *env);
@@ -415,6 +416,9 @@ static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,if (riscv_cpu_fp_enabled (env)) { flags |= env->mstatus &MSTATUS_FS ; } +if (riscv_cpu_vector_enabled (env)) { + flags |= env->mstatus &MSTATUS_VS ; + }#endif *pflags = flags; }
target/riscv/cpu_bits.h +1 -0
@@ -376,6 +376,7 @@#define MSTATUS_SPP 0x00000100#define MSTATUS_MPP 0x00001800#define MSTATUS_FS 0x00006000 +#define MSTATUS_VS 0x00000600#define MSTATUS_XS 0x00018000#define MSTATUS_MPRV 0x00020000#define MSTATUS_PUM 0x00040000/* until: priv-1.9.1 */
target/riscv/cpu_helper.c +13 -0
@@ -108,6 +108,19 @@ bool riscv_cpu_fp_enabled(CPURISCVState *env)return false; } +/* Return true is vector support is currently enabled */ +bool riscv_cpu_vector_enabled (CPURISCVState *env) +{ +if (env->mstatus &MSTATUS_VS ) { +if (riscv_cpu_virt_enabled (env) && !(env->mstatus_hs &MSTATUS_VS )) { +return false; + } +return true; + } + +return false; +} +void riscv_cpu_swap_hypervisor_regs (CPURISCVState *env) { target_ulong mstatus_mask = MSTATUS_MXR | MSTATUS_SUM | MSTATUS_FS |
target/riscv/csr.c +24 -1
@@ -180,6 +180,7 @@ static int write_fcsr(CPURISCVState *env, int csrno, target_ulong val) return -1; } env->mstatus |=MSTATUS_FS ; + env->mstatus |=MSTATUS_VS ;#endif env->frm = (val &FSR_RD ) >>FSR_RD_SHIFT ;if (vs (env, csrno) >=0 ) {
@@ -210,6 +211,13 @@ static int read_vxrm(CPURISCVState *env, int csrno, target_ulong *val)static int write_vxrm (CPURISCVState *env,int csrno,target_ulong val) { +#if !defined(CONFIG_USER_ONLY ) +if (!env->debugger && !riscv_cpu_vector_enabled (env)) { +return -1 ; + } + env->mstatus |=MSTATUS_VS ; +#endif + env->vxrm = val;return 0 ; }
@@ -222,6 +230,13 @@ static int read_vxsat(CPURISCVState *env, int csrno, target_ulong *val)static int write_vxsat (CPURISCVState *env,int csrno,target_ulong val) { +#if !defined(CONFIG_USER_ONLY ) +if (!env->debugger && !riscv_cpu_vector_enabled (env)) { +return -1 ; + } + env->mstatus |=MSTATUS_VS ; +#endif + env->vxsat = val;return 0 ; }
@@ -234,6 +249,13 @@ static int read_vstart(CPURISCVState *env, int csrno, target_ulong *val)static int write_vstart (CPURISCVState *env,int csrno,target_ulong val) { +#if !defined(CONFIG_USER_ONLY ) +if (!env->debugger && !riscv_cpu_vector_enabled (env)) { +return -1 ; + } + env->mstatus |=MSTATUS_VS ; +#endif + env->vstart = val;return 0 ; }
@@ -420,7 +442,7 @@ static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val) mask =MSTATUS_SIE |MSTATUS_SPIE |MSTATUS_MIE |MSTATUS_MPIE |MSTATUS_SPP |MSTATUS_FS |MSTATUS_MPRV |MSTATUS_SUM |MSTATUS_MPP |MSTATUS_MXR |MSTATUS_TVM |MSTATUS_TSR | -MSTATUS_TW ; +MSTATUS_TW |MSTATUS_VS ;#if defined(TARGET_RISCV64 )/* * RV32: MPV and MTL are not in mstatus. The current plan is to
@@ -432,6 +454,7 @@ static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val) mstatus = (mstatus & ~mask) | (val & mask); dirty = ((mstatus &MSTATUS_FS ) ==MSTATUS_FS ) | + ((mstatus &MSTATUS_VS ) ==MSTATUS_VS ) | ((mstatus &MSTATUS_XS ) ==MSTATUS_XS ); mstatus =set_field (mstatus,MSTATUS_SD , dirty); env->mstatus = mstatus;
target/riscv/insn_trans/trans_rvv.inc.c +49 -8
259 lines not on this page · raw message
target/riscv/translate.c +32 -0
@@ -47,6 +47,7 @@ typedef struct DisasContext {bool virt_enabled;uint32_t opcode;uint32_t mstatus_fs; +uint32_t mstatus_vs;uint32_t misa;uint32_t mem_idx;/* Remember the rounding mode encoded in the previous fp instruction,
@@ -416,6 +417,37 @@ static void mark_fs_dirty(DisasContext *ctx)static inline void mark_fs_dirty (DisasContext *ctx) { }#endif +#ifndef CONFIG_USER_ONLY +/* The states of mstatus_vs are: +* 0 = disabled, 1 = initial, 2 = clean, 3 = dirty +* We will have already diagnosed disabled state, +* and need to turn initial/clean into dirty. +*/ +static void mark_vs_dirty (DisasContext *ctx) +{ +TCGv tmp; +if (ctx->mstatus_vs ==MSTATUS_VS ) { +return ; + } +/* Remember the state change for the rest of the TB. */ + ctx->mstatus_vs =MSTATUS_VS ; + + tmp =tcg_temp_new (); +tcg_gen_ld_tl (tmp, cpu_env, offsetof(CPURISCVState , mstatus)); +tcg_gen_ori_tl (tmp, tmp,MSTATUS_VS |MSTATUS_SD ); +tcg_gen_st_tl (tmp, cpu_env, offsetof(CPURISCVState , mstatus)); + +if (ctx->virt_enabled) { +tcg_gen_ld_tl (tmp, cpu_env, offsetof(CPURISCVState , mstatus_hs)); +tcg_gen_ori_tl (tmp, tmp,MSTATUS_VS |MSTATUS_SD ); +tcg_gen_st_tl (tmp, cpu_env, offsetof(CPURISCVState , mstatus_hs)); + } +tcg_temp_free (tmp); +} +#else +static inline void mark_vs_dirty (DisasContext *ctx) { } +#endif +#if !defined(TARGET_RISCV64 )static void gen_fp_load (DisasContext *ctx,uint32_t opc,int rd,int rs1,target_long imm)
Signature · 1 line
2.17.1
Re: [RFC 07/65] target/riscv: rvv-0.9: add vector context status
target/riscv/cpu_bits.h line 380
Quoted 8 lines · On 7/10/20 3:48 AM, [email protected] wrote:
target/riscv/cpu_bits.h +1
-0@@ -376,6 +376,7 @@#define MSTATUS_SPP 0x00000100#define MSTATUS_MPP 0x00001800#define MSTATUS_FS 0x00006000 +#define MSTATUS_VS 0x00000600#define MSTATUS_XS 0x00018000
Please sort VS up below SPP, so that the bits are in order.
target/riscv/cpu_bits.h static int write_fcsr(CPURISCVState *env, int csrno, target_ulong val) · line 186
Quoted 8 lines
target/riscv/cpu_bits.h +1
-0@@ -180,6 +180,7 @@ static int write_fcsr(CPURISCVState *env, int csrno, target_ulong val) return -1; } env->mstatus |=MSTATUS_FS ; + env->mstatus |=MSTATUS_VS ;#endif env->frm = (val &FSR_RD ) >>FSR_RD_SHIFT ;if (vs (env, csrno) >=0 ) {
Does rvv 0.9 still have the vector fields in FCSR, or are they only present in the new VCSR?
target/riscv/cpu_bits.h static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val) · line 445
Quoted 6 lines
target/riscv/cpu_bits.h +1
-1@@ -420,7 +442,7 @@ static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val) mask =MSTATUS_SIE |MSTATUS_SPIE |MSTATUS_MIE |MSTATUS_MPIE |MSTATUS_SPP |MSTATUS_FS |MSTATUS_MPRV |MSTATUS_SUM |MSTATUS_MPP |MSTATUS_MXR |MSTATUS_TVM |MSTATUS_TSR | -MSTATUS_TW ; +MSTATUS_TW |MSTATUS_VS ;
Since 0.7.1 does not have the VS field, you might want to force VS to dirty in the written mstatus. Correspondingly, you should remove VS from the returned mstatus in read_mstatus.
You appear to be missing a change to riscv_cpu_swap_hypervisor_regs.
That makes all of the riscv_cpu_vector_enabled checks return true for 0.7.1, which afaik is correct.
target/riscv/cpu_bits.h static bool ld_us_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq) · line 255
Quoted 8 lines
target/riscv/cpu_bits.h +3
-1@@ -245,7 +250,9 @@ static bool ld_us_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq) data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); data =FIELD_DP32 (data,VDATA ,NF , a->nf); -return ldst_us_trans (a->rd, a->rs1, data, fn, s); + ret =ldst_us_trans (a->rd, a->rs1, data, fn, s); +mark_vs_dirty (s); +return ret;
Just push the mark_vs_dirty call into ldst_us_trans.
target/riscv/cpu_bits.h static bool ld_stride_op(DisasContext *s, arg_rnfvm *a, uint8_t seq) · line 395
Quoted 8 lines
target/riscv/cpu_bits.h +3
-1@@ -382,7 +390,9 @@ static bool ld_stride_op(DisasContext *s, arg_rnfvm *a, uint8_t seq) data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); data =FIELD_DP32 (data,VDATA ,NF , a->nf); -return ldst_stride_trans (a->rd, a->rs1, a->rs2, data, fn, s); + ret =ldst_stride_trans (a->rd, a->rs1, a->rs2, data, fn, s); +mark_vs_dirty (s); +return ret;
Likewise.
target/riscv/cpu_bits.h static bool ld_index_op(DisasContext *s, arg_rnfvm *a, uint8_t seq) · line 526
Quoted 8 lines
target/riscv/cpu_bits.h +3
-1@@ -510,7 +521,9 @@ static bool ld_index_op(DisasContext *s, arg_rnfvm *a, uint8_t seq) data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); data =FIELD_DP32 (data,VDATA ,NF , a->nf); -return ldst_index_trans (a->rd, a->rs1, a->rs2, data, fn, s); + ret =ldst_index_trans (a->rd, a->rs1, a->rs2, data, fn, s); +mark_vs_dirty (s); +return ret;
Likewise.
target/riscv/cpu_bits.h static bool ldff_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq) · line 650
Quoted 7 lines
target/riscv/cpu_bits.h +2
-1@@ -632,7 +646,9 @@ static bool ldff_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq) data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); data =FIELD_DP32 (data,VDATA ,NF , a->nf); -return ldff_trans (a->rd, a->rs1, data, fn, s); + ret =ldff_trans (a->rd, a->rs1, data, fn, s); +mark_vs_dirty (s);
Likewise.
target/riscv/cpu_bits.h static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq) · line 763
Quoted 8 lines
target/riscv/cpu_bits.h +3
-1@@ -741,7 +758,9 @@ static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq) data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); data =FIELD_DP32 (data,VDATA ,WD , a->wd); -return amo_trans (a->rd, a->rs1, a->rs2, data, fn, s); + ret =amo_trans (a->rd, a->rs1, a->rs2, data, fn, s); +mark_vs_dirty (s); +return ret;
Likewise.
target/riscv/cpu_bits.h do_opivx_gvec(DisasContext *s, arg_rmrr *a, GVecGen2sFn *gvec_fn, · line 940
Quoted 11 lines
target/riscv/cpu_bits.h +4
-1@@ -911,9 +932,12 @@ do_opivx_gvec(DisasContext *s, arg_rmrr *a, GVecGen2sFn *gvec_fn,tcg_temp_free_i64 (src1);tcg_temp_free (tmp); +mark_vs_dirty (s);return true; } -return opivx_trans (a->rd, a->rs1, a->rs2, a->vm, fn, s); + ret =opivx_trans (a->rd, a->rs1, a->rs2, a->vm, fn, s); +mark_vs_dirty (s); +return ret;
Likewise. And more.
target/riscv/translate.c typedef struct DisasContext { · line 50
Quoted 9 lines
target/riscv/translate.c +1
-0@@ -47,6 +47,7 @@ typedef struct DisasContext {bool virt_enabled;uint32_t opcode;uint32_t mstatus_fs; +uint32_t mstatus_vs;
Missing a change to riscv_tr_init_disas_context to initialize this.
r~
Re: [RFC 07/65] target/riscv: rvv-0.9: add vector context status
In reply to [email protected]Quoted 4 lines · On 7/10/20 3:48 AM, [email protected] wrote:
From: LIU Zhiwei <[email protected]>
Signed-off-by LIU Zhiwei <[email protected]>Signed-off-by Frank Chang <[email protected]>
Quoted 8 lines
--- target/riscv/cpu.h | 4 ++ target/riscv/cpu_bits.h | 1 + target/riscv/cpu_helper.c | 13 ++++++ target/riscv/csr.c | 25 ++++++++++- target/riscv/insn_trans/trans_rvv.inc.c | 57 +++++++++++++++++++++---- target/riscv/translate.c | 32 ++++++++++++++ 6 files changed, 123 insertions(+), 9 deletions(-)
BTW, I think this should be split.
One patch for the csr.c changes, another for the translate changes.
r~
RFC 8/65 target/riscv: rvv-0.9: update mstatus_vs by tb_flags
In reply to [email protected]From: LIU Zhiwei <[email protected]>
--- target/riscv/cpu.h | 2 ++ target/riscv/translate.c | 1 + 2 files changed, 3 insertions(+)
target/riscv/cpu.h +2 -0
@@ -361,6 +361,7 @@ void riscv_cpu_set_fflags(CPURISCVState *env, target_ulong);#define TB_FLAGS_MMU_MASK 3#define TB_FLAGS_MSTATUS_FS MSTATUS_FS +#define TB_FLAGS_MSTATUS_VS MSTATUS_VStypedef CPURISCVState CPUArchState ;typedef RISCVCPU ArchCPU ;
@@ -411,6 +412,7 @@ static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,#ifdef CONFIG_USER_ONLY flags |=TB_FLAGS_MSTATUS_FS ; + flags |=TB_FLAGS_MSTATUS_VS ;#else flags |=cpu_mmu_index (env,0 );if (riscv_cpu_fp_enabled (env)) {
target/riscv/translate.c +1 -0
@@ -796,6 +796,7 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->pc_succ_insn = ctx->base.pc_first; ctx->mem_idx = tb_flags &TB_FLAGS_MMU_MASK ; ctx->mstatus_fs = tb_flags &TB_FLAGS_MSTATUS_FS ; + ctx->mstatus_vs = tb_flags &TB_FLAGS_MSTATUS_VS ; ctx->priv_ver = env->priv_ver;#if !defined(CONFIG_USER_ONLY )if (riscv_has_ext (env,RVH )) {
Signature · 1 line
2.17.1
Re: [RFC 08/65] target/riscv: rvv-0.9: update mstatus_vs by tb_flags
Quoted 8 lines · On 7/10/20 3:48 AM, [email protected] wrote:
From: LIU Zhiwei <[email protected]>
Signed-off-by LIU Zhiwei <[email protected]>Signed-off-by Frank Chang <[email protected]>--- target/riscv/cpu.h | 2 ++ target/riscv/translate.c | 1 + 2 files changed, 3 insertions(+)
This belongs with the second half of the previous patch, the translate portion.
r~
Quoted 34 lines
target/riscv/cpu.h +2
-0@@ -361,6 +361,7 @@ void riscv_cpu_set_fflags(CPURISCVState *env, target_ulong);#define TB_FLAGS_MMU_MASK 3#define TB_FLAGS_MSTATUS_FS MSTATUS_FS +#define TB_FLAGS_MSTATUS_VS MSTATUS_VStypedef CPURISCVState CPUArchState ;typedef RISCVCPU ArchCPU ;@@ -411,6 +412,7 @@ static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,#ifdef CONFIG_USER_ONLY flags |=TB_FLAGS_MSTATUS_FS ; + flags |=TB_FLAGS_MSTATUS_VS ;#else flags |=cpu_mmu_index (env,0 );if (riscv_cpu_fp_enabled (env)) {target/riscv/translate.c +1
-0@@ -796,6 +796,7 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->pc_succ_insn = ctx->base.pc_first; ctx->mem_idx = tb_flags &TB_FLAGS_MMU_MASK ; ctx->mstatus_fs = tb_flags &TB_FLAGS_MSTATUS_FS ; + ctx->mstatus_vs = tb_flags &TB_FLAGS_MSTATUS_VS ; ctx->priv_ver = env->priv_ver;#if !defined(CONFIG_USER_ONLY )if (riscv_has_ext (env,RVH )) {
RFC 9/65 target/riscv: rvv-0.9: add vlenb register
In reply to [email protected]From: LIU Zhiwei <[email protected]>
--- target/riscv/cpu.c | 1 + target/riscv/cpu.h | 1 + target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 7 +++++++ 4 files changed, 10 insertions(+)
target/riscv/cpu.c +1 -0
@@ -317,6 +317,7 @@ static void riscv_cpu_reset(DeviceState *dev) env->mstatus &= ~(MSTATUS_MIE |MSTATUS_MPRV ); env->mcause =0 ; env->pc = env->resetvec; + env->vlenb = cpu->cfg.vlen >>3 ;#endif cs->exception_index =EXCP_NONE ; env->load_res =-1 ;
target/riscv/cpu.h +1 -0
@@ -111,6 +111,7 @@ struct CPURISCVState {target_ulong vl;target_ulong vstart;target_ulong vtype; +target_ulong vlenb;target_ulong pc;target_ulong load_res;
target/riscv/cpu_bits.h +1 -0
@@ -63,6 +63,7 @@#define CSR_VCSR 0x00f#define CSR_VL 0xc20#define CSR_VTYPE 0xc21 +#define CSR_VLENB 0xc22/* VCSR fields */ #define VCSR_VXSAT_SHIFT 0
target/riscv/csr.c +7 -0
@@ -197,6 +197,12 @@ static int read_vtype(CPURISCVState *env, int csrno, target_ulong *val)return 0 ; } +static int read_vlenb (CPURISCVState *env,int csrno,target_ulong *val) +{ + *val = env->vlenb; +return 0 ; +} +static int read_vl (CPURISCVState *env,int csrno,target_ulong *val) { *val = env->vl;
@@ -1301,6 +1307,7 @@ static riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_VCSR] = { vs, read_vcsr, write_vcsr }, [CSR_VL] = { vs, read_vl }, [CSR_VTYPE] = { vs, read_vtype }, + [CSR_VLENB] = { vs, read_vlenb }, /* User Timers and Counters */ [CSR_CYCLE] = { ctr, read_instret }, [CSR_INSTRET] = { ctr, read_instret },
Signature · 1 line
2.17.1
Re: [RFC 09/65] target/riscv: rvv-0.9: add vlenb register
Quoted 17 lines · On 7/10/20 3:48 AM, [email protected] wrote:
target/riscv/cpu.c +1
-0@@ -317,6 +317,7 @@ static void riscv_cpu_reset(DeviceState *dev) env->mstatus &= ~(MSTATUS_MIE |MSTATUS_MPRV ); env->mcause =0 ; env->pc = env->resetvec; + env->vlenb = cpu->cfg.vlen >>3 ;#endif cs->exception_index =EXCP_NONE ; env->load_res =-1 ;target/riscv/cpu.h +0
-0
target/riscv/cpu.h struct CPURISCVState { · line 114
Quoted 4 lines
target/riscv/cpu.h +1
-0@@ -111,6 +111,7 @@ struct CPURISCVState {target_ulong vl;target_ulong vstart;target_ulong vtype; +target_ulong vlenb;
I don't see that you need this. The field is read-only, so the read_vlenb function can just return
env_archcpu(env)->cfg.vlen >> 3
directly.
r~
RFC 10/65 target/riscv: rvv-0.9: remove MLEN calculations
In reply to [email protected]From: Frank Chang <[email protected]>
As in RVV 0.9 design, MLEN is hardcoded with value 1 (Section 4.5). Thus, remove all MLEN related calculations.
--- target/riscv/insn_trans/trans_rvv.inc.c | 44 +---- target/riscv/internals.h | 9 +- target/riscv/translate.c | 2 - target/riscv/vector_helper.c | 252 ++++++++++-------------- 4 files changed, 116 insertions(+), 191 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +7 -37
@@ -246,7 +246,6 @@ static bool ld_us_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq)return false; } - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); data =FIELD_DP32 (data,VDATA ,NF , a->nf);
@@ -301,7 +300,6 @@ static bool st_us_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq)return false; } - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); data =FIELD_DP32 (data,VDATA ,NF , a->nf);
@@ -386,7 +384,6 @@ static bool ld_stride_op(DisasContext *s, arg_rnfvm *a, uint8_t seq)return false; } - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); data =FIELD_DP32 (data,VDATA ,NF , a->nf);
@@ -427,15 +424,15 @@ static bool st_stride_op(DisasContext *s, arg_rnfvm *a, uint8_t seq) gen_helper_vsse_v_w, gen_helper_vsse_v_d } }; - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); - data =FIELD_DP32 (data,VDATA ,VM , a->vm); - data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); - data =FIELD_DP32 (data,VDATA ,NF , a->nf); - fn = fns[seq][s->sew]; + fn = fns[seq];if (fn ==NULL ) {return false; } + data =FIELD_DP32 (data,VDATA ,VM , a->vm); + data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); + data =FIELD_DP32 (data,VDATA ,NF , a->nf); +return ldst_stride_trans (a->rd, a->rs1, a->rs2, data, fn, s); }
@@ -517,7 +514,6 @@ static bool ld_index_op(DisasContext *s, arg_rnfvm *a, uint8_t seq)return false; } - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); data =FIELD_DP32 (data,VDATA ,NF , a->nf);
@@ -563,7 +559,6 @@ static bool st_index_op(DisasContext *s, arg_rnfvm *a, uint8_t seq)return false; } - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); data =FIELD_DP32 (data,VDATA ,NF , a->nf);
@@ -642,7 +637,6 @@ static bool ldff_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq)return false; } - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); data =FIELD_DP32 (data,VDATA ,NF , a->nf);
@@ -754,7 +748,6 @@ static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq) } } - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); data =FIELD_DP32 (data,VDATA ,WD , a->wd);
@@ -835,7 +828,6 @@ do_opivv_gvec(DisasContext *s, arg_rmrr *a, GVecGen3Fn *gvec_fn, }else {uint32_t data =0 ; - 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),
@@ -881,7 +873,6 @@ static bool opivx_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, uint32_t vm, src1 =tcg_temp_new ();gen_get_gpr (src1, rs1); - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); data =FIELD_DP32 (data,VDATA ,VM , vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); desc =tcg_const_i32 (simd_desc (0 , s->vlen /8 , data));
@@ -1032,7 +1023,6 @@ static bool opivi_trans(uint32_t vd, uint32_t imm, uint32_t vs2, uint32_t vm, }else { src1 =tcg_const_tl (sextract64 (imm,0 ,5 )); } - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); data =FIELD_DP32 (data,VDATA ,VM , vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); desc =tcg_const_i32 (simd_desc (0 , s->vlen /8 , data));
@@ -1130,7 +1120,6 @@ static bool do_opivv_widen(DisasContext *s, arg_rmrr *a,TCGLabel *over =gen_new_label ();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),
@@ -1219,7 +1208,6 @@ static bool do_opiwv_widen(DisasContext *s, arg_rmrr *a,TCGLabel *over =gen_new_label ();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),
@@ -1298,7 +1286,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \TCGLabel *over =gen_new_label (); \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), \
@@ -1489,7 +1476,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \TCGLabel *over =gen_new_label (); \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), \
@@ -1855,7 +1841,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \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), \
@@ -1927,7 +1912,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ gen_helper_##NAME##_d, \ }; \ 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, \
@@ -1968,7 +1952,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \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), \
@@ -2006,7 +1989,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ 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, \
@@ -2043,7 +2025,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \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), \
@@ -2079,7 +2060,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ 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, \
@@ -2159,7 +2139,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \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_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
@@ -2300,7 +2279,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \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_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
@@ -2349,7 +2327,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \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_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
@@ -2412,7 +2389,6 @@ static bool trans_##NAME(DisasContext *s, arg_r *a) \TCGLabel *over =gen_new_label (); \tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over); \ \ - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); \ 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), \
@@ -2441,7 +2417,6 @@ static bool trans_vmpopc_m(DisasContext *s, arg_rmr *a)TCGv dst;TCGv_i32 desc;uint32_t data =0 ; - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul);
@@ -2473,7 +2448,6 @@ static bool trans_vmfirst_m(DisasContext *s, arg_rmr *a)TCGv dst;TCGv_i32 desc;uint32_t data =0 ; - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); data =FIELD_DP32 (data,VDATA ,VM , a->vm); data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul);
@@ -2509,7 +2483,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \TCGLabel *over =gen_new_label (); \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_3_ptr(vreg_ofs(s, a->rd), \
@@ -2536,7 +2509,6 @@ static bool trans_viota_m(DisasContext *s, arg_viota_m *a)TCGLabel *over =gen_new_label ();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);static gen_helper_gvec_3_ptr *const fns[4 ] = {
@@ -2562,7 +2534,6 @@ static bool trans_vid_v(DisasContext *s, arg_vid_v *a)TCGLabel *over =gen_new_label ();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);static gen_helper_gvec_2_ptr *const fns[4 ] = {
@@ -2850,7 +2821,7 @@ static bool trans_vrgather_vx(DisasContext *s, arg_rmrr *a) }if (a->vm && s->vl_eq_vlmax) { -int vlmax = s->vlen / s->mlen; +int vlmax = s->vlen;TCGv_i64 dest =tcg_temp_new_i64 ();if (a->rs1 ==0 ) {
@@ -2881,7 +2852,7 @@ static bool trans_vrgather_vi(DisasContext *s, arg_rmrr *a) }if (a->vm && s->vl_eq_vlmax) { -if (a->rs1 >= s->vlen / s->mlen) { +if (a->rs1 >= s->vlen) {tcg_gen_gvec_dup_imm (SEW64 ,vreg_ofs (s, a->rd),MAXSZ (s),MAXSZ (s),0 ); }else {
@@ -2921,7 +2892,6 @@ static bool trans_vcompress_vm(DisasContext *s, arg_r *a)TCGLabel *over =gen_new_label ();tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over); - data =FIELD_DP32 (data,VDATA ,MLEN , s->mlen); 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),
target/riscv/internals.h +4 -5
@@ -22,11 +22,10 @@#include "hw/registerfields.h" /* share data between vector helpers and decode code */ -FIELD(VDATA, MLEN, 0, 8) -FIELD(VDATA, VM, 8, 1) -FIELD(VDATA, LMUL, 9, 2) -FIELD(VDATA, NF, 11, 4) -FIELD (VDATA ,WD ,11 ,1 ) +FIELD(VDATA, VM, 0, 1) +FIELD(VDATA, LMUL, 1, 3) +FIELD(VDATA, NF, 4, 4) +FIELD (VDATA ,WD ,4 ,1 ) /* float point classify helpers */target_ulong fclass_h (uint64_t frs1);
target/riscv/translate.c +0 -2
@@ -62,7 +62,6 @@ typedef struct DisasContext {uint8_t lmul;uint8_t sew;uint16_t vlen; -uint16_t mlen;bool vl_eq_vlmax; } DisasContext;
@@ -824,7 +823,6 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->vill =FIELD_EX32 (tb_flags,TB_FLAGS ,VILL ); ctx->sew =FIELD_EX32 (tb_flags,TB_FLAGS ,SEW ); ctx->lmul =FIELD_EX32 (tb_flags,TB_FLAGS ,LMUL ); - ctx->mlen =1 << (ctx->sew +3 - ctx->lmul); ctx->vl_eq_vlmax =FIELD_EX32 (tb_flags,TB_FLAGS ,VL_EQ_VLMAX ); }
target/riscv/vector_helper.c +105 -147
865 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC 10/65] target/riscv: rvv-0.9: remove MLEN calculations
Quoted 5 lines · On 7/10/20 3:48 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
As in RVV 0.9 design, MLEN is hardcoded with value 1 (Section 4.5). Thus, remove all MLEN related calculations.
Quoted 7 lines
Signed-off-by Frank Chang <[email protected]>--- target/riscv/insn_trans/trans_rvv.inc.c | 44 +---- target/riscv/internals.h | 9 +- target/riscv/translate.c | 2 - target/riscv/vector_helper.c | 252 ++++++++++-------------- 4 files changed, 116 insertions(+), 191 deletions(-)
You can't do this until you remove 0.7.1 support.
r~
RFC 11/65 target/riscv: rvv-0.9: add fractional LMUL, VTA and VMA
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/cpu.h | 25 +++- target/riscv/insn_trans/trans_rvv.inc.c | 79 ++++++++++- target/riscv/internals.h | 13 +- target/riscv/translate.c | 8 ++ target/riscv/vector_helper.c | 166 +++++++++++++++++------- 5 files changed, 232 insertions(+), 59 deletions(-)
target/riscv/cpu.h +19 -6
@@ -96,8 +96,11 @@ typedef struct CPURISCVState CPURISCVState; FIELD(VTYPE, VLMUL, 0, 2) FIELD(VTYPE, VSEW, 2, 3) -FIELD(VTYPE, VEDIV, 5, 2) -FIELD(VTYPE, RESERVED, 7, sizeof(target_ulong) * 8 - 9) +FIELD(VTYPE, VFLMUL, 5, 1) +FIELD(VTYPE, VTA, 6, 1) +FIELD(VTYPE, VMA, 7, 1) +FIELD(VTYPE, VEDIV, 8, 2) +FIELD(VTYPE, RESERVED, 10, sizeof(target_ulong) * 8 - 11) FIELD(VTYPE, VILL, sizeof(target_ulong) * 8 - 1, 1)struct CPURISCVState {
@@ -369,9 +372,13 @@ typedef RISCVCPU ArchCPU;#include "exec/cpu-all.h" FIELD(TB_FLAGS, VL_EQ_VLMAX, 2, 1) -FIELD(TB_FLAGS, LMUL, 3, 2) -FIELD(TB_FLAGS, SEW, 5, 3) -FIELD (TB_FLAGS ,VILL ,8 ,1 ) +FIELD(TB_FLAGS, LMUL, 3, 3) +FIELD (TB_FLAGS ,SEW ,6 ,3 ) +/* Skip MSTATUS_VS (0x600) fields */ +FIELD(TB_FLAGS, VTA, 11, 1) +FIELD (TB_FLAGS ,VMA ,12 ,1 ) +/* Skip MSTATUS_VS (0x6000) fields */ +FIELD (TB_FLAGS ,VILL ,15 ,1 )/* * A simplification for VLMAX
@@ -400,12 +407,18 @@ static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,if (riscv_has_ext (env,RVV )) {uint32_t vlmax =vext_get_vlmax (env_archcpu (env), env->vtype);bool vl_eq_vlmax = (env->vstart ==0 ) && (vlmax == env->vl); + flags =FIELD_DP32 (flags,TB_FLAGS ,VILL ,FIELD_EX64 (env->vtype,VTYPE ,VILL )); flags =FIELD_DP32 (flags,TB_FLAGS ,SEW ,FIELD_EX64 (env->vtype,VTYPE ,VSEW )); flags =FIELD_DP32 (flags,TB_FLAGS ,LMUL , -FIELD_EX64 (env->vtype,VTYPE ,VLMUL )); + (FIELD_EX64 (env->vtype,VTYPE ,VFLMUL ) <<2 ) + |FIELD_EX64 (env->vtype,VTYPE ,VLMUL )); + flags =FIELD_DP32 (flags,TB_FLAGS ,VTA , +FIELD_EX64 (env->vtype,VTYPE ,VTA )); + flags =FIELD_DP32 (flags,TB_FLAGS ,VMA , +FIELD_EX64 (env->vtype,VTYPE ,VMA )); flags =FIELD_DP32 (flags,TB_FLAGS ,VL_EQ_VLMAX , vl_eq_vlmax); }else { flags =FIELD_DP32 (flags,TB_FLAGS ,VILL ,1 );
target/riscv/insn_trans/trans_rvv.inc.c +76 -3
283 lines not on this page · raw message
target/riscv/internals.h +11 -2
@@ -24,8 +24,11 @@/* share data between vector helpers and decode code */ FIELD(VDATA, VM, 0, 1) FIELD(VDATA, LMUL, 1, 3) -FIELD(VDATA, NF, 4, 4) -FIELD (VDATA ,WD ,4 ,1 ) +FIELD(VDATA, SEW, 4, 3) +FIELD(VDATA, VTA, 7, 1) +FIELD(VDATA, VMA, 8, 1) +FIELD(VDATA, NF, 9, 4) +FIELD (VDATA ,WD ,9 ,1 ) /* float point classify helpers */target_ulong fclass_h (uint64_t frs1);
@@ -37,4 +40,10 @@ target_ulong fclass_d(uint64_t frs1);#define SEW32 2#define SEW64 3 +/* table to convert fractional LMUL value */ +static const float flmul_table[8 ] = { +1 ,2 ,4 ,8 ,/* LMUL */ +-1 ,/* reserved */ +0.125 ,0.25 ,0.5 /* fractional LMUL */ +};#endif
target/riscv/translate.c +8 -0
@@ -60,6 +60,11 @@ typedef struct DisasContext {/* vector extension */ bool vill;uint8_t lmul; +float flmul; +uint8_t eew; +float emul; +uint8_t vta; +uint8_t vma;uint8_t sew;uint16_t vlen;bool vl_eq_vlmax;
@@ -823,6 +828,9 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->vill =FIELD_EX32 (tb_flags,TB_FLAGS ,VILL ); ctx->sew =FIELD_EX32 (tb_flags,TB_FLAGS ,SEW ); ctx->lmul =FIELD_EX32 (tb_flags,TB_FLAGS ,LMUL ); + ctx->flmul = flmul_table[ctx->lmul]; + ctx->vta =FIELD_EX32 (tb_flags,TB_FLAGS ,VTA ); + ctx->vma =FIELD_EX32 (tb_flags,TB_FLAGS ,VMA ); ctx->vl_eq_vlmax =FIELD_EX32 (tb_flags,TB_FLAGS ,VL_EQ_VLMAX ); }
target/riscv/vector_helper.c +118 -48
636 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC 11/65] target/riscv: rvv-0.9: add fractional LMUL, VTA and VMA
target/riscv/vector_helper.c static void vext_clear(void *tail, uint32_t cnt, uint32_t tot) · line 185
Quoted 10 lines · On 7/10/20 3:48 AM, [email protected] wrote:
target/riscv/vector_helper.c +6
-1-static void vext_clear (void *tail,uint32_t cnt,uint32_t tot) +static void vext_clear (void *tail,uint32_t vta,uint32_t cnt,uint32_t tot) { +/* tail element undisturbed */ +if (vta ==0 ) { +return ; + } +memset (tail,0 , tot - cnt); }
First, this patch is doing too much. LMUL should definitely be split from VTA/VMA; they are not functionally related.
Second, it would be in-spec to simply do nothing for VTA/VMA, except validate their setting within VTYPE.
Third, the spec talks about setting "agnostic" values to 1s, not 0s as you are doing here. So there's definitely something wrong.
r~
RFC 12/65 target/riscv: rvv-0.9: update check functions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn_trans/trans_rvv.inc.c | 507 ++++++++++++++---------- 1 file changed, 308 insertions(+), 199 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +308 -199
@@ -19,6 +19,59 @@#include "tcg/tcg-gvec-desc.h" #include "internals.h" +#define NVPR 32 + +#define require (x) if (unlikely(!(x))) { return false; } +#define require_align (val, pos) require(is_aligned(val, pos)) + +/* Destination vector register group cannot overlap source mask register. */ +#define require_vm (vm, rd) do { if (vm == 0) require(rd != 0); } while (0) + +#define require_noover (astart, asize, bstart, bsize) \ + require(!is_overlapped(astart, asize, bstart, bsize)) +#define require_noover_widen (astart, asize, bstart, bsize) \ + require(!is_overlapped_widen(astart, asize, bstart, bsize)) + +#define REQUIRE_RVV do { \ + if (s->mstatus_vs == 0) \ + return false; \ +} while (0) + +static inline bool is_aligned (const unsigned val,const unsigned pos) +{ +return pos ? (val & (pos -1 )) ==0 : true; +} + +static inline bool is_overlapped (const int astart,int asize, +const int bstart,int bsize) +{ + asize = asize ==0 ?1 : asize; + bsize = bsize ==0 ?1 : bsize; + +const int aend = astart + asize; +const int bend = bstart + bsize; + +return MAX (aend, bend) -MIN (astart, bstart) < asize + bsize; +} + +static inline bool is_overlapped_widen (const int astart,int asize, +const int bstart,int bsize) +{ + asize = asize ==0 ?1 : asize; + bsize = bsize ==0 ?1 : bsize; + +const int aend = astart + asize; +const int bend = bstart + bsize; + +if (astart < bstart && +is_overlapped (astart, asize, bstart, bsize) && + !is_overlapped (astart, asize, bstart + bsize, bsize)) { +return false; + }else { +return MAX (aend, bend) -MIN (astart, bstart) < asize + bsize; + } +} +static bool trans_vsetvl (DisasContext *ctx,arg_vsetvl *a) {TCGv s1, s2, dst;
@@ -103,29 +156,121 @@ static bool vext_check_isa_ill(DisasContext *s) }/* -* There are two rules check here. +* Check function for vector instruction with format: +* single-width result and single-width sources (SEW = SEW op SEW) +* +* is_vs1: indicates whether insn[19:15] is a vs1 field or not. +*/ +#define VEXT_CHECK_SSS (s, rd, rs1, rs2, vm, is_vs1) do { \ + require_vm(vm, rd); \ + if (s->flmul > 1) { \ + require_align(rd, s->flmul); \ + require_align(rs2, s->flmul); \ + if (is_vs1) { \ + require_align(rs1, s->flmul); \ + } \ + } \ +} while (0) + +/* +* Check function for maskable vector instruction with format: +* single-width result and single-width sources (SEW = SEW op SEW) * -* 1. Vector register numbers are multiples of LMUL. (Section 3.2) +* is_vs1: indicates whether insn[19:15] is a vs1 field or not. +*/ +#define VEXT_CHECK_MSS (s, rd, rs1, rs2, is_vs1) do { \ + if (rd != rs2) { \ + require_noover(rd, 1, rs2, s->flmul); \ + } \ + require_align(rs2, s->flmul); \ + if (is_vs1) { \ + if (rd != rs1) { \ + require_noover(rd, 1, rs1, s->flmul); \ + } \ + require_align(rs1, s->flmul); \ + } \ +} while (0) + +/* Common check function for vector widening instructions */ +#define VEXT_WIDE_CHECK_COMMON (s, rd, vm) do { \ + require(s->flmul <= 4); \ + require(s->sew < 3); \ + require_align(rd, s->flmul * 2); \ + require_vm(vm, rd); \ +} while (0) + +/* Common check function for vector narrowing instructions */ +#define VEXT_NARROW_CHECK_COMMON (s, rd, rs2, vm) do { \ + require(s->flmul <= 4); \ + require(s->sew < 3); \ + require_align(rs2, s->flmul * 2); \ + require_align(rd, s->flmul); \ + require_vm(vm, rd); \ +} while (0) + +/* +* Check function for vector instruction with format: +* double-width result and single-width sources (2*SEW = SEW op SEW) * -* 2. For all widening instructions, the destination LMUL value must also be -* a supported LMUL value. (Section 11.2) +* is_vs1: indicates whether insn[19:15] is a vs1 field or not. */ -static bool vext_check_reg (DisasContext *s,uint32_t reg,bool widen) -{ -/* -* The destination vector register group results are arranged as if both -* SEW and LMUL were at twice their current settings. (Section 11.2). -*/ -int legal = widen ?2 << s->lmul :1 << s->lmul; +#define VEXT_CHECK_DSS (s, rd, rs1, rs2, vm, is_vs1) do { \ + VEXT_WIDE_CHECK_COMMON(s, rd, vm); \ + require_align(rs2, s->flmul); \ + if (s->flmul < 1) { \ + require_noover(rd, s->flmul * 2, rs2, s->flmul); \ + } else { \ + require_noover_widen(rd, s->flmul * 2, rs2, s->flmul); \ + } \ + if (is_vs1) { \ + require_align(rs1, s->flmul); \ + if (s->flmul < 1) { \ + require_noover(rd, s->flmul * 2, rs1, s->flmul); \ + } else { \ + require_noover_widen(rd, s->flmul * 2, rs1, s->flmul); \ + } \ + } \ +} while (0) -return !((s->lmul ==0x3 && widen) || (reg % legal)); -} +/* +* Check function for vector instruction with format: +* double-width result and double-width source1 and single-width +* source2 (2*SEW = 2*SEW op SEW) +* +* is_vs1: indicates whether insn[19:15] is a vs1 field or not. +*/ +#define VEXT_CHECK_DDS (s, rd, rs1, rs2, vm, is_vs1) do { \ + VEXT_WIDE_CHECK_COMMON(s, rd, vm); \ + require_align(rs2, s->flmul * 2); \ + if (is_vs1) { \ + require_align(rs1, s->flmul); \ + if (s->flmul < 1) { \ + require_noover(rd, s->flmul * 2, rs1, s->flmul); \ + } else { \ + require_noover_widen(rd, s->flmul * 2, rs1, s->flmul); \ + } \ + } \ +} while (0)/* -* There are two rules check here. +* Check function for vector instruction with format: +* single-width result and double-width source1 and single-width +* source2 (SEW = 2*SEW op SEW) * -* 1. The destination vector register group for a masked vector instruction can -* only overlap the source mask register (v0) when LMUL=1. (Section 5.3) +* is_vs1: indicates whether insn[19:15] is a vs1 field or not. +*/ +#define VEXT_CHECK_SDS (s, rd, rs1, rs2, vm, is_vs1) do { \ + VEXT_NARROW_CHECK_COMMON(s, rd, rs2, vm); \ + if (rd != rs2) { \ + require_noover(rd, s->flmul, rs2, s->flmul * 2); \ + } \ + if (is_vs1) { \ + require_align(rs1, s->flmul); \ + } \ +} while (0) + +/* +* Check function for vector reduction instructions * * 2. In widen instructions and some other insturctions, like vslideup.vx, * there is no need to check whether LMUL=1.
@@ -136,20 +281,14 @@ static bool vext_check_overlap_mask(DisasContext *s, uint32_t vd, bool vm,return (vm !=0 || vd !=0 ) || (!force && (s->lmul ==0 )); } -/* The LMUL setting must be such that LMUL * NFIELDS <= 8. (Section 7.8) */ -static bool vext_check_nf (DisasContext *s,uint32_t nf) -{ -return (1 << s->lmul) * nf <=8 ; -} -/* -* The destination vector register group cannot overlap a source vector register -* group of a different element width. (Section 11.2) +* In cpu_get_tb_cpu_state(), set VILL if RVV was not present. +* So RVV is also be checked in this function. */ -static inline bool vext_check_overlap_group (int rd,int dlen,int rs,int slen) -{ -return ((rd >= rs + slen) || (rs >= rd + dlen)); -} +#define VEXT_CHECK_ISA_ILL (s) do { \ + require(!s->vill) \ +} while (0) +/* common translation macro */ #define GEN_VEXT_TRANS (NAME ,SEQ ,ARGTYPE ,OP ,CHECK ) \ static bool trans_##NAME(DisasContext *s, arg_##ARGTYPE *a)\
@@ -824,11 +963,10 @@ GEN_VEXT_TRANS(vamomaxud_v, 17, rwdvm, amo_op, amo_check)static bool opivv_check (DisasContext *s,arg_rmrr *a) { -return (vext_check_isa_ill (s) && -vext_check_overlap_mask (s, a->rd, a->vm, false) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs2, false) && -vext_check_reg (s, a->rs1, false)); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_SSS (s, a->rd, a->rs1, a->rs2, a->vm, true); +return true; } typedef void GVecGen3Fn(unsigned, uint32_t, uint32_t,
@@ -922,10 +1060,10 @@ static bool opivx_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, uint32_t vm,static bool opivx_check (DisasContext *s,arg_rmrr *a) { -return (vext_check_isa_ill (s) && -vext_check_overlap_mask (s, a->rd, a->vm, false) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs2, false)); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_SSS (s, a->rd, a->rs1, a->rs2, a->vm, false); +return true; } typedef void GVecGen2sFn(unsigned, uint32_t, uint32_t, TCGv_i64,
@@ -1129,16 +1267,10 @@ GEN_OPIVI_GVEC_TRANS(vrsub_vi, 0, vrsub_vx, rsubi)/* OPIVV with WIDEN */ static bool opivv_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 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_DSS (s, a->rd, a->rs1, a->rs2, a->vm, true); +return true; } static bool do_opivv_widen(DisasContext *s, arg_rmrr *a,
@@ -1185,13 +1317,10 @@ GEN_OPIVV_WIDEN_TRANS(vwsub_vv, opivv_widen_check)/* OPIVX with WIDEN */ static bool opivx_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 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_DSS (s, a->rd, a->rs1, a->rs2, a->vm, false); +return true; } static bool do_opivx_widen(DisasContext *s, arg_rmrr *a,
@@ -1222,14 +1351,10 @@ GEN_OPIVX_WIDEN_TRANS(vwsub_vx)/* WIDEN OPIVV with WIDEN */ static bool opiwv_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 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_DDS (s, a->rd, a->rs1, a->rs2, a->vm, true); +return true; } static bool do_opiwv_widen(DisasContext *s, arg_rmrr *a,
@@ -1274,11 +1399,10 @@ GEN_OPIWV_WIDEN_TRANS(vwsub_wv)/* WIDEN OPIVX with WIDEN */ static bool opiwx_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 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_DDS (s, a->rd, a->rs1, a->rs2, a->vm, false); +return true; } static bool do_opiwx_widen(DisasContext *s, arg_rmrr *a,
@@ -1341,11 +1465,11 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \*/ static bool opivv_vadc_check (DisasContext *s,arg_rmrr *a) { -return (vext_check_isa_ill (s) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs2, false) && -vext_check_reg (s, a->rs1, false) && - ((a->rd !=0 ) || (s->lmul ==0 ))); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +require (a->rd !=0 ); +VEXT_CHECK_SSS (s, a->rd, a->rs1, a->rs2, a->vm, true); +return true; }GEN_OPIVV_TRANS (vadc_vvm, opivv_vadc_check)
@@ -1357,11 +1481,10 @@ GEN_OPIVV_TRANS(vsbc_vvm, opivv_vadc_check)*/ static bool opivv_vmadc_check (DisasContext *s,arg_rmrr *a) { -return (vext_check_isa_ill (s) && -vext_check_reg (s, a->rs2, false) && -vext_check_reg (s, a->rs1, false) && -vext_check_overlap_group (a->rd,1 , a->rs1,1 << s->lmul) && -vext_check_overlap_group (a->rd,1 , a->rs2,1 << s->lmul)); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_MSS (s, a->rd, a->rs1, a->rs2, true); +return true; }GEN_OPIVV_TRANS (vmadc_vvm, opivv_vmadc_check)
@@ -1369,10 +1492,11 @@ GEN_OPIVV_TRANS(vmsbc_vvm, opivv_vmadc_check)static bool opivx_vadc_check (DisasContext *s,arg_rmrr *a) { -return (vext_check_isa_ill (s) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs2, false) && - ((a->rd !=0 ) || (s->lmul ==0 ))); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +require (a->rd !=0 ); +VEXT_CHECK_SSS (s, a->rd, a->rs1, a->rs2, a->vm, false); +return true; }/* OPIVX without GVEC IR */
@@ -1395,9 +1519,10 @@ GEN_OPIVX_TRANS(vsbc_vxm, opivx_vadc_check)static bool opivx_vmadc_check (DisasContext *s,arg_rmrr *a) { -return (vext_check_isa_ill (s) && -vext_check_reg (s, a->rs2, false) && -vext_check_overlap_group (a->rd,1 , a->rs2,1 << s->lmul)); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_MSS (s, a->rd, a->rs1, a->rs2, false); +return true; }GEN_OPIVX_TRANS (vmadc_vxm, opivx_vmadc_check)
@@ -1488,14 +1613,10 @@ GEN_OPIVI_TRANS(vsra_vi, 1, vsra_vx, opivx_check)/* Vector Narrowing Integer Right Shift Instructions */ static bool opivv_narrow_check (DisasContext *s,arg_rmrr *a) { -return (vext_check_isa_ill (s) && -vext_check_overlap_mask (s, a->rd, a->vm, false) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs2, true) && -vext_check_reg (s, a->rs1, false) && -vext_check_overlap_group (a->rd,1 << s->lmul, a->rs2, -2 << s->lmul) && - (s->lmul <0x3 ) && (s->sew <0x3 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_SDS (s, a->rd, a->rs1, a->rs2, a->vm, true); +return true; }/* OPIVV with NARROW */
@@ -1531,13 +1652,10 @@ GEN_OPIVV_NARROW_TRANS(vnsrl_vv)static bool opivx_narrow_check (DisasContext *s,arg_rmrr *a) { -return (vext_check_isa_ill (s) && -vext_check_overlap_mask (s, a->rd, a->vm, false) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs2, true) && -vext_check_overlap_group (a->rd,1 << s->lmul, a->rs2, -2 << s->lmul) && - (s->lmul <0x3 ) && (s->sew <0x3 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_SDS (s, a->rd, a->rs1, a->rs2, a->vm, false); +return true; }/* OPIVX with NARROW */
@@ -1585,13 +1703,12 @@ GEN_OPIVI_NARROW_TRANS(vnsrl_vi, 1, vnsrl_vx)*/ static bool opivv_cmp_check (DisasContext *s,arg_rmrr *a) { -return (vext_check_isa_ill (s) && -vext_check_reg (s, a->rs2, false) && -vext_check_reg (s, a->rs1, false) && - ((vext_check_overlap_group (a->rd,1 , a->rs1,1 << s->lmul) && -vext_check_overlap_group (a->rd,1 , a->rs2,1 << s->lmul)) || - (s->lmul ==0 ))); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_MSS (s, a->rd, a->rs1, a->rs2, true); +return true; } + GEN_OPIVV_TRANS(vmseq_vv, opivv_cmp_check) GEN_OPIVV_TRANS(vmsne_vv, opivv_cmp_check)GEN_OPIVV_TRANS (vmsltu_vv, opivv_cmp_check)
@@ -1601,10 +1718,10 @@ GEN_OPIVV_TRANS(vmsle_vv, opivv_cmp_check)static bool opivx_cmp_check (DisasContext *s,arg_rmrr *a) { -return (vext_check_isa_ill (s) && -vext_check_reg (s, a->rs2, false) && - (vext_check_overlap_group (a->rd,1 , a->rs2,1 << s->lmul) || - (s->lmul ==0 ))); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_MSS (s, a->rd, a->rs1, a->rs2, false); +return true; }GEN_OPIVX_TRANS (vmseq_vx, opivx_cmp_check)
@@ -1863,12 +1980,11 @@ GEN_OPIVI_NARROW_TRANS(vnclip_vi, 1, vnclip_vx)*/ static bool opfvv_check (DisasContext *s,arg_rmrr *a) { -return (vext_check_isa_ill (s) && -vext_check_overlap_mask (s, a->rd, a->vm, false) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs2, false) && -vext_check_reg (s, a->rs1, false) && - (s->sew !=0 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_SSS (s, a->rd, a->rs1, a->rs2, a->vm, true); +require (s->sew !=0 ); +return true; }/* OPFVV without GVEC IR */
@@ -1934,17 +2050,17 @@ static bool opfvf_trans(uint32_t vd, uint32_t rs1, uint32_t vs2,return true; } -static bool opfvf_check (DisasContext *s,arg_rmrr *a) -{/* * If the current SEW does not correspond to a supported IEEE floating-point * type, an illegal instruction exception is raised */ -return (vext_check_isa_ill (s) && -vext_check_overlap_mask (s, a->rd, a->vm, false) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs2, false) && - (s->sew !=0 )); +static bool opfvf_check (DisasContext *s,arg_rmrr *a) +{ +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_SSS (s, a->rd, a->rs1, a->rs2, a->vm, false); +require (s->sew !=0 ); +return true; }/* OPFVF without GVEC IR */
@@ -1976,16 +2092,11 @@ 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 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_DSS (s, a->rd, a->rs1, a->rs2, a->vm, true); +require (s->sew !=0 ); +return true; }/* OPFVV with WIDEN */
@@ -2021,13 +2132,11 @@ 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 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_DSS (s, a->rd, a->rs1, a->rs2, a->vm, false); +require (s->sew !=0 ); +return true; }/* OPFVF with WIDEN */
@@ -2055,14 +2164,11 @@ 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 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_DDS (s, a->rd, a->rs1, a->rs2, a->vm, true); +require (s->sew !=0 ); +return true; }/* WIDEN OPFVV with WIDEN */
@@ -2098,11 +2204,11 @@ 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 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_DDS (s, a->rd, a->rs1, a->rs2, a->vm, false); +require (s->sew !=0 ); +return true; }/* WIDEN OPFVF with WIDEN */
@@ -2175,11 +2281,12 @@ GEN_OPFVF_WIDEN_TRANS(vfwnmsac_vf)*/ static bool opfv_check (DisasContext *s,arg_rmr *a) { -return (vext_check_isa_ill (s) && -vext_check_overlap_mask (s, a->rd, a->vm, false) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs2, false) && - (s->sew !=0 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +/* OPFV instructions ignore vs1 check */ +VEXT_CHECK_SSS (s, a->rd,0 , a->rs2, a->vm, false); +require (s->sew !=0 ); +return true; }#define GEN_OPFV_TRANS (NAME ,CHECK ) \
@@ -2229,13 +2336,11 @@ GEN_OPFVF_TRANS(vfsgnjx_vf, opfvf_check)/* Vector Floating-Point Compare Instructions */ static bool opfvv_cmp_check (DisasContext *s,arg_rmrr *a) { -return (vext_check_isa_ill (s) && -vext_check_reg (s, a->rs2, false) && -vext_check_reg (s, a->rs1, false) && - (s->sew !=0 ) && - ((vext_check_overlap_group (a->rd,1 , a->rs1,1 << s->lmul) && -vext_check_overlap_group (a->rd,1 , a->rs2,1 << s->lmul)) || - (s->lmul ==0 ))); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_MSS (s, a->rd, a->rs1, a->rs2, true); +require (s->sew !=0 ); +return true; }GEN_OPFVV_TRANS (vmfeq_vv, opfvv_cmp_check)
@@ -2246,11 +2351,11 @@ GEN_OPFVV_TRANS(vmford_vv, opfvv_cmp_check)static bool opfvf_cmp_check (DisasContext *s,arg_rmrr *a) { -return (vext_check_isa_ill (s) && -vext_check_reg (s, a->rs2, false) && - (s->sew !=0 ) && - (vext_check_overlap_group (a->rd,1 , a->rs2,1 << s->lmul) || - (s->lmul ==0 ))); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_MSS (s, a->rd, a->rs1, a->rs2, false); +require (s->sew !=0 ); +return true; }GEN_OPFVF_TRANS (vmfeq_vf, opfvf_cmp_check)
@@ -2316,13 +2421,12 @@ GEN_OPFV_TRANS(vfcvt_f_x_v, opfv_check)*/ static bool opfv_widen_check (DisasContext *s,arg_rmr *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 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +/* OPFV widening instructions ignore vs1 check */ +VEXT_CHECK_DSS (s, a->rd,0 , a->rs2, a->vm, false); +require (s->sew !=0 ); +return true; }#define GEN_OPFV_WIDEN_TRANS (NAME ) \
@@ -2366,13 +2470,12 @@ GEN_OPFV_WIDEN_TRANS(vfwcvt_f_f_v)*/ static bool opfv_narrow_check (DisasContext *s,arg_rmr *a) { -return (vext_check_isa_ill (s) && -vext_check_overlap_mask (s, a->rd, a->vm, false) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs2, true) && -vext_check_overlap_group (a->rd,1 << s->lmul, a->rs2, -2 << s->lmul) && - (s->lmul <0x3 ) && (s->sew <0x3 ) && (s->sew !=0 )); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +/* OPFV narrowing instructions ignore vs1 check */ +VEXT_CHECK_SDS (s, a->rd,0 , a->rs2, a->vm, false); +require (s->sew !=0 ); +return true; }#define GEN_OPFV_NARROW_TRANS (NAME ) \
@@ -2865,23 +2968,27 @@ GEN_OPIVI_TRANS(vslidedown_vi, 1, vslidedown_vx, opivx_check)/* Vector Register Gather Instruction */ static bool vrgather_vv_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, false) && -vext_check_reg (s, a->rs1, false) && -vext_check_reg (s, a->rs2, false) && - (a->rd != a->rs2) && (a->rd != a->rs1)); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +require_align (a->rd, s->flmul); +require_align (a->rs1, s->flmul); +require_align (a->rs2, s->flmul); +require (a->rd != a->rs2 && a->rd != a->rs1); +require_vm (a->vm, a->rd); +return true; } GEN_OPIVV_TRANS(vrgather_vv, vrgather_vv_check)static bool vrgather_vx_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, false) && -vext_check_reg (s, a->rs2, false) && - (a->rd != a->rs2)); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +require_align (a->rd, s->flmul); +require_align (a->rs2, s->flmul); +require (a->rd != a->rs2); +require_vm (a->vm, a->rd); +return true; }/* vrgather.vx vd, vs2, rs1, vm # vd[i] = (x[rs1] >= VLMAX) ? 0 : vs2[rs1] */
@@ -2945,11 +3052,13 @@ static bool trans_vrgather_vi(DisasContext *s, arg_rmrr *a)/* Vector Compress Instruction */ static bool vcompress_vm_check (DisasContext *s,arg_r *a) { -return (vext_check_isa_ill (s) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs2, false) && -vext_check_overlap_group (a->rd,1 << s->lmul, a->rs1,1 ) && - (a->rd != a->rs2)); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +require_align (a->rd, s->flmul); +require_align (a->rs2, s->flmul); +require (a->rd != a->rs2); +require_noover (a->rd, s->flmul, a->rs1,1 ); +return true; }static bool trans_vcompress_vm (DisasContext *s,arg_r *a)
Signature · 1 line
2.17.1
Re: [RFC 12/65] target/riscv: rvv-0.9: update check functions
target/riscv/insn_trans/trans_rvv.inc.c line 38
Quoted 4 lines · On 7/10/20 3:48 AM, [email protected] wrote:
target/riscv/insn_trans/trans_rvv.inc.c +4
-0+#define REQUIRE_RVV do { \ + if (s->mstatus_vs == 0) \ + return false; \ +} while (0)
You've used this macro already back in patch 7. I guess it should not have been there? Or this bit belongs there, one or the other.
I think this patch requires a description and justification. I have no idea why you are replacing
target/riscv/insn_trans/trans_rvv.inc.c GEN_VEXT_TRANS(vamomaxud_v, 17, rwdvm, amo_op, amo_check) · line 831
Quoted 5 lines
target/riscv/insn_trans/trans_rvv.inc.c +0
-5-return (vext_check_isa_ill (s) && -vext_check_overlap_mask (s, a->rd, a->vm, false) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs2, false) && -vext_check_reg (s, a->rs1, false));
with invisible returns
target/riscv/insn_trans/trans_rvv.inc.c GEN_VEXT_TRANS(vamomaxud_v, 17, rwdvm, amo_op, amo_check) · line 969
Quoted 4 lines
target/riscv/insn_trans/trans_rvv.inc.c +4
-0+REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_SSS (s, a->rd, a->rs1, a->rs2, a->vm, true); +return true;
r~
Re: [RFC 12/65] target/riscv: rvv-0.9: update check functions
Quoted 9 lines · Richard Henderson
target/riscv/insn_trans/trans_rvv.inc.c line 38
Quoted 4 lines · On 7/10/20 3:48 AM, [email protected] wrote:
target/riscv/insn_trans/trans_rvv.inc.c +4
-0+#define REQUIRE_RVV do { \ + if (s->mstatus_vs == 0) \ + return false; \ +} while (0)You've used this macro already back in patch 7. I guess it should not have been there? Or this bit belongs there, one or the other.
Quoted 4 lines
I think this patch requires a description and justification. I have no idea
why you are replacing
Yes, this change should be moved to patch 7.
Quoted 9 lines
target/riscv/insn_trans/trans_rvv.inc.c GEN_VEXT_TRANS(vamomaxud_v, 17, rwdvm, amo_op, amo_check) · line 831
Quoted 6 lines
target/riscv/insn_trans/trans_rvv.inc.c +0
-5-return (vext_check_isa_ill (s) && -vext_check_overlap_mask (s, a->rd, a->vm, false) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs2, false) && -vext_check_reg (s, a->rs1, false));with invisible returns
Quoted 8 lines
target/riscv/insn_trans/trans_rvv.inc.c GEN_VEXT_TRANS(vamomaxud_v, 17, rwdvm, amo_op, amo_check) · line 969
Quoted 4 lines
target/riscv/insn_trans/trans_rvv.inc.c +4
-0+REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_SSS (s, a->rd, a->rs1, a->rs2, a->vm, true); +return true;r~
You're right, I will resend the patches with more description and justification.
Frank Chang
RFC 13/65 target/riscv: rvv-0.9: configure instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 2 +- target/riscv/insn_trans/trans_rvv.inc.c | 52 ++++++++++++------------- target/riscv/vector_helper.c | 38 ++++++++++++------ 3 files changed, 53 insertions(+), 39 deletions(-)
target/riscv/helper.h +1 -1
@@ -83,7 +83,7 @@ DEF_HELPER_1(hyp_tlb_flush, void, env)#endif /* Vector functions */ -DEF_HELPER_3(vsetvl, tl, env, tl, tl) +DEF_HELPER_5(vsetvl, tl, env, i32, i32, tl, tl) DEF_HELPER_5(vlb_v_b, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vlb_v_b_mask, void, ptr, ptr, tl, env, i32)DEF_HELPER_5 (vlb_v_h, void, ptr, ptr, tl, env, i32)
target/riscv/insn_trans/trans_rvv.inc.c +25 -27
89 lines not on this page · raw message
target/riscv/vector_helper.c +27 -11
@@ -26,33 +26,49 @@#include "internals.h" #include <math.h> -target_ulong HELPER (vsetvl )(CPURISCVState *env,target_ulong s1, -target_ulong s2) +target_ulong HELPER (vsetvl )(CPURISCVState *env,uint32_t rd,uint32_t rs1, +target_ulong s1,target_ulong s2) { -int vlmax, vl; +int vlmax; +int vl =0 ; +RISCVCPU *cpu =env_archcpu (env);uint16_t sew =8 <<FIELD_EX64 (s2,VTYPE ,VSEW );uint8_t ediv =FIELD_EX64 (s2,VTYPE ,VEDIV );bool vill =FIELD_EX64 (s2,VTYPE ,VILL ); + vlmax =vext_get_vlmax (cpu, s2);target_ulong reserved =FIELD_EX64 (s2,VTYPE ,RESERVED ); -if ((sew > cpu->cfg.elen) || vill || (ediv !=0 ) || (reserved !=0 )) { +uint64_t lmul = (FIELD_EX64 (s2,VTYPE ,VFLMUL ) <<2 ) + |FIELD_EX64 (s2,VTYPE ,VLMUL ); +float vflmul = flmul_table[lmul]; + +if ((sew > cpu->cfg.elen) + || vill + || vflmul < ((float )sew / cpu->cfg.elen) + || (ediv !=0 ) + || (reserved !=0 )) {/* only set vill bit. */ env->vtype =FIELD_DP64 (0 ,VTYPE ,VILL ,1 ); - env->vl =0 ; - env->vstart =0 ;return 0 ; } - vlmax =vext_get_vlmax (cpu, s2); -if (s1 <= vlmax) { - vl = s1; - }else { +/* set vl */ +if (rd ==0 && rs1 ==0 ) { +/* keep existing vl */ + vl = env->vl > vlmax ? vlmax : env->vl; + }else if (rd !=0 && rs1 ==0 ) { +/* set vl to vlmax */ vl = vlmax; + }else if (rs1 !=0 ) { +/* normal stripmining */ + vl = s1 > vlmax ? vlmax : s1; } - env->vl = vl; + env->vtype = s2; env->vstart =0 ; + env->vl = vl; +return vl; }
Signature · 1 line
2.17.1
Re: [RFC 13/65] target/riscv: rvv-0.9: configure instructions
target/riscv/insn_trans/trans_rvv.inc.c static inline bool is_overlapped_widen(const int astart, int asize, · line 75
Quoted 2 lines · On 7/10/20 3:48 AM, [email protected] wrote:
target/riscv/insn_trans/trans_rvv.inc.c +1
-1-static bool trans_vsetvl (DisasContext *ctx,arg_vsetvl *a) +static bool trans_vsetvl (DisasContext *s,arg_vsetvl *a)
Do not mix this change with anything else.
Review
Quoted 2 lines
(quoted diff) +2
-0+ rd = tcg_const_i32(a->rd); + rs1 = tcg_const_i32(a->rs1);
Any time you put a register number into a tcg const, there's probably a better way to do things.
target/riscv/insn_trans/trans_rvv.inc.c static inline bool is_overlapped_widen(const int astart, int asize, · line 94
Quoted 8 lines
target/riscv/insn_trans/trans_rvv.inc.c +0
-8-/* Using x0 as the rs1 register specifier, encodes an infinite AVL */ -if (a->rs1 ==0 ) { -/* As the mask is at least one bit, RV_VLEN_MAX is >= VLMAX */ - s1 =tcg_const_tl (RV_VLEN_MAX ); - }else { - s1 =tcg_temp_new (); -gen_get_gpr (s1, a->rs1); - }
E.g. this code should be kept, and add
if (a->rd == 0 && a->rs1 == 0) {
s1 = tcg_temp_new();
tcg_gen_mov_tl(s1, cpu_vl);
} else ...target/riscv/vector_helper.c line 54
Quoted 11 lines
target/riscv/vector_helper.c +5
-2+if ((sew > cpu->cfg.elen) + || vill + || vflmul < ((float )sew / cpu->cfg.elen) + || (ediv !=0 ) + || (reserved !=0 )) {/* only set vill bit. */ env->vtype =FIELD_DP64 (0 ,VTYPE ,VILL ,1 ); - env->vl =0 ; - env->vstart =0 ;return 0 ; }
You do need to check 0.7.1 so long as it's supported.
r~
Re: [RFC 13/65] target/riscv: rvv-0.9: configure instructions
Quoted 5 lines · Richard Henderson
target/riscv/insn_trans/trans_rvv.inc.c static inline bool is_overlapped_widen(const int astart, int asize, · line 75
Quoted 2 lines · On 7/10/20 3:48 AM, [email protected] wrote:
target/riscv/insn_trans/trans_rvv.inc.c +1
-1-static bool trans_vsetvl (DisasContext *ctx,arg_vsetvl *a) +static bool trans_vsetvl (DisasContext *s,arg_vsetvl *a)Do not mix this change with anything else.
OK~
---
Frank Chang
Quoted 18 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ rd = tcg_const_i32(a->rd); + rs1 = tcg_const_i32(a->rs1);Any time you put a register number into a tcg const, there's probably a better
way to do things.Quoted 1 line
- /* Using x0 as the rs1 register specifier, encodes an infinite AVL
*/
target/riscv/insn_trans/trans_rvv.inc.c static inline bool is_overlapped_widen(const int astart, int asize, · line 94
Quoted 7 lines
target/riscv/insn_trans/trans_rvv.inc.c +0
-7-if (a->rs1 ==0 ) { -/* As the mask is at least one bit, RV_VLEN_MAX is >= VLMAX */ - s1 =tcg_const_tl (RV_VLEN_MAX ); - }else { - s1 =tcg_temp_new (); -gen_get_gpr (s1, a->rs1); - }
Quoted 7 lines
E.g. this code should be kept, and add
if (a->rd == 0 && a->rs1 == 0) { s1 = tcg_temp_new(); tcg_gen_mov_tl(s1, cpu_vl); } else ...
OK~
Quoted 13 lines
target/riscv/vector_helper.c line 54
Quoted 12 lines
target/riscv/vector_helper.c +5
-2+if ((sew > cpu->cfg.elen) + || vill + || vflmul < ((float )sew / cpu->cfg.elen) + || (ediv !=0 ) + || (reserved !=0 )) {/* only set vill bit. */ env->vtype =FIELD_DP64 (0 ,VTYPE ,VILL ,1 ); - env->vl =0 ; - env->vstart =0 ;return 0 ; }
Quoted 5 lines
You do need to check 0.7.1 so long as it's supported.
r~
Will drop 0.7.1 support in my first patch to prevent the confusion.
Frank Chang
RFC 14/65 target/riscv: rvv-0.9: stride load and store instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 129 +++------------ target/riscv/insn32.decode | 43 +++-- target/riscv/insn_trans/trans_rvv.inc.c | 206 ++++++++++-------------- target/riscv/vector_helper.c | 175 ++++++-------------- 4 files changed, 171 insertions(+), 382 deletions(-)
target/riscv/helper.h +24 -105
@@ -84,111 +84,30 @@ DEF_HELPER_1(hyp_tlb_flush, void, env)/* Vector functions */ DEF_HELPER_5(vsetvl, tl, env, i32, i32, tl, tl) -DEF_HELPER_5(vlb_v_b, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlb_v_b_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlb_v_h, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlb_v_h_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlb_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlb_v_w_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlb_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlb_v_d_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlh_v_h, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlh_v_h_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlh_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlh_v_w_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlh_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlh_v_d_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlw_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlw_v_w_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlw_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlw_v_d_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vle_v_b, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vle_v_b_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vle_v_h, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vle_v_h_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vle_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vle_v_w_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vle_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vle_v_d_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbu_v_b, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbu_v_b_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbu_v_h, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbu_v_h_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbu_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbu_v_w_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbu_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbu_v_d_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlhu_v_h, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlhu_v_h_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlhu_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlhu_v_w_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlhu_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlhu_v_d_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlwu_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlwu_v_w_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlwu_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlwu_v_d_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsb_v_b, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsb_v_b_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsb_v_h, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsb_v_h_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsb_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsb_v_w_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsb_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsb_v_d_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsh_v_h, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsh_v_h_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsh_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsh_v_w_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsh_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsh_v_d_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsw_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsw_v_w_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsw_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vsw_v_d_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vse_v_b, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vse_v_b_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vse_v_h, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vse_v_h_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vse_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vse_v_w_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vse_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vse_v_d_mask, void, ptr, ptr, tl, env, i32) -DEF_HELPER_6(vlsb_v_b, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlsb_v_h, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlsb_v_w, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlsb_v_d, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlsh_v_h, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlsh_v_w, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlsh_v_d, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlsw_v_w, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlsw_v_d, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlse_v_b, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlse_v_h, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlse_v_w, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlse_v_d, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlsbu_v_b, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlsbu_v_h, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlsbu_v_w, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlsbu_v_d, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlshu_v_h, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlshu_v_w, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlshu_v_d, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlswu_v_w, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlswu_v_d, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vssb_v_b, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vssb_v_h, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vssb_v_w, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vssb_v_d, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vssh_v_h, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vssh_v_w, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vssh_v_d, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vssw_v_w, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vssw_v_d, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vsse_v_b, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vsse_v_h, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vsse_v_w, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vsse_v_d, void, ptr, ptr, tl, tl, env, i32) +DEF_HELPER_5(vle8_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vle16_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vle32_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vle64_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vle8_v_mask, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vle16_v_mask, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vle32_v_mask, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vle64_v_mask, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vse8_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vse16_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vse32_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vse64_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vse8_v_mask, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vse16_v_mask, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vse32_v_mask, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vse64_v_mask, void, ptr, ptr, tl, env, i32) +DEF_HELPER_6(vlse8_v, void, ptr, ptr, tl, tl, env, i32) +DEF_HELPER_6(vlse16_v, void, ptr, ptr, tl, tl, env, i32) +DEF_HELPER_6(vlse32_v, void, ptr, ptr, tl, tl, env, i32) +DEF_HELPER_6(vlse64_v, void, ptr, ptr, tl, tl, env, i32) +DEF_HELPER_6(vsse8_v, void, ptr, ptr, tl, tl, env, i32) +DEF_HELPER_6(vsse16_v, void, ptr, ptr, tl, tl, env, i32) +DEF_HELPER_6(vsse32_v, void, ptr, ptr, tl, tl, env, i32) +DEF_HELPER_6(vsse64_v, void, ptr, ptr, tl, tl, env, i32) DEF_HELPER_6(vlxb_v_b, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vlxb_v_h, void, ptr, ptr, tl, ptr, env, i32)DEF_HELPER_6 (vlxb_v_w, void, ptr, ptr, tl, ptr, env, i32)
target/riscv/insn32.decode +20 -23
55 lines not on this page · raw message
target/riscv/insn_trans/trans_rvv.inc.c +81 -125
287 lines not on this page · raw message
target/riscv/vector_helper.c +46 -129
279 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC 14/65] target/riscv: rvv-0.9: stride load and store instructions
target/riscv/insn32.decode hfence_vvma 0010001 ..... ..... 000 00000 1110011 @hfence_vvma · line 234
Quoted 4 lines · On 7/10/20 3:48 AM, [email protected] wrote:
# *** Vector loads and stores are encoded within LOADFP/STORE-FP ***
target/riscv/insn32.decode +0
-3-vlb_v ... 100 . 00000 ..... 000 ..... 0000111 @r2_nfvm -vlh_v ... 100 . 00000 ..... 101 ..... 0000111 @r2_nfvm -vlw_v ... 100 . 00000 ..... 110 ..... 0000111 @r2_nfvm
Again, something you can't do until 0.7.1 is not supported.
If you don't want to simultaneously support 0.7.1 and 0.9/1.0, then you should simply remove 0.7.1 in the first patch, so that there's no confusion.
Is the rest of it mostly renaming? You should definitely expand on what you're doing within each patch description. A description of what has changed in the spec since 0.7.1 will help the reviewer validate that you've gotten all of the corner cases.
I am going to stop reviewing this patch series now, as I expect that most of the remaining patches will have similar comments.
r~
Re: [RFC 14/65] target/riscv: rvv-0.9: stride load and store instructions
Quoted 20 lines · Richard Henderson
target/riscv/insn32.decode hfence_vvma 0010001 ..... ..... 000 00000 1110011 @hfence_vvma · line 234
Quoted 4 lines · On 7/10/20 3:48 AM, [email protected] wrote:
# *** Vector loads and stores are encoded within LOADFP/STORE-FP ***
target/riscv/insn32.decode +0
-3-vlb_v ... 100 . 00000 ..... 000 ..... 0000111 @r2_nfvm -vlh_v ... 100 . 00000 ..... 101 ..... 0000111 @r2_nfvm -vlw_v ... 100 . 00000 ..... 110 ..... 0000111 @r2_nfvmAgain, something you can't do until 0.7.1 is not supported.
If you don't want to simultaneously support 0.7.1 and 0.9/1.0, then you should
simply remove 0.7.1 in the first patch, so that there's no confusion.Is the rest of it mostly renaming? You should definitely expand on what you're
doing within each patch description. A description of what has changed in the
spec since 0.7.1 will help the reviewer validate that you've gotten all of the
corner cases.
Quoted 7 lines
I am going to stop reviewing this patch series now, as I expect that most of
the remaining patches will have similar comments.r~
Thanks for the reviews.
I will rearrange my commits as what you suggest and add more comments in my next patchset.
--
Frank Chang
RFC 15/65 target/riscv: rvv-0.9: index load and store instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 67 +++++----- target/riscv/insn32.decode | 21 ++-- target/riscv/insn_trans/trans_rvv.inc.c | 156 +++++++++++++++--------- target/riscv/vector_helper.c | 84 ++++++------- 4 files changed, 183 insertions(+), 145 deletions(-)
target/riscv/helper.h +32 -35
@@ -108,41 +108,38 @@ DEF_HELPER_6(vsse8_v, void, ptr, ptr, tl, tl, env, i32) DEF_HELPER_6(vsse16_v, void, ptr, ptr, tl, tl, env, i32) DEF_HELPER_6(vsse32_v, void, ptr, ptr, tl, tl, env, i32) DEF_HELPER_6(vsse64_v, void, ptr, ptr, tl, tl, env, i32) -DEF_HELPER_6(vlxb_v_b, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxb_v_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxb_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxb_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxh_v_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxh_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxh_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxw_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxw_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxe_v_b, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxe_v_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxe_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxe_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxbu_v_b, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxbu_v_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxbu_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxbu_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxhu_v_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxhu_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxhu_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxwu_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vlxwu_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vsxb_v_b, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vsxb_v_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vsxb_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vsxb_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vsxh_v_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vsxh_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vsxh_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vsxw_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vsxw_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vsxe_v_b, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vsxe_v_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vsxe_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vsxe_v_d, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei8_8_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei8_16_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei8_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei8_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei16_8_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei16_16_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei16_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei16_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei32_8_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei32_16_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei32_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei32_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei64_8_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei64_16_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei64_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vlxei64_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei8_8_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei8_16_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei8_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei8_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei16_8_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei16_16_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei16_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei16_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei32_8_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei32_16_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei32_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei32_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei64_8_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei64_16_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei64_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vsxei64_64_v, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_5(vlbff_v_b, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vlbff_v_h, void, ptr, ptr, tl, env, i32)DEF_HELPER_5 (vlbff_v_w, void, ptr, ptr, tl, env, i32)
target/riscv/insn32.decode +10 -11
@@ -257,18 +257,17 @@ vlbuff_v ... 000 . 10000 ..... 000 ..... 0000111 @r2_nfvm vlhuff_v ... 000 . 10000 ..... 101 ..... 0000111 @r2_nfvm vlwuff_v ... 000 . 10000 ..... 110 ..... 0000111 @r2_nfvm -vlxb_v ... 111 . ..... ..... 000 ..... 0000111 @r_nfvm -vlxh_v ... 111 . ..... ..... 101 ..... 0000111 @r_nfvm -vlxw_v ... 111 . ..... ..... 110 ..... 0000111 @r_nfvm -vlxe_v ... 011 . ..... ..... 111 ..... 0000111 @r_nfvm -vlxbu_v ... 011 . ..... ..... 000 ..... 0000111 @r_nfvm -vlxhu_v ... 011 . ..... ..... 101 ..... 0000111 @r_nfvm -vlxwu_v ... 011 . ..... ..... 110 ..... 0000111 @r_nfvm +# Vector indexed load insns. +vlxei8_v ... 011 . ..... ..... 000 ..... 0000111 @r_nfvm +vlxei16_v ... 011 . ..... ..... 101 ..... 0000111 @r_nfvm +vlxei32_v ... 011 . ..... ..... 110 ..... 0000111 @r_nfvm +vlxei64_v ... 011 . ..... ..... 111 ..... 0000111 @r_nfvm + # Vector ordered-indexed and unordered-indexed store insns. -vsxb_v ... -11 . ..... ..... 000 ..... 0100111 @r_nfvm -vsxh_v ... -11 . ..... ..... 101 ..... 0100111 @r_nfvm -vsxw_v ... -11 . ..... ..... 110 ..... 0100111 @r_nfvm -vsxe_v ... -11 . ..... ..... 111 ..... 0100111 @r_nfvm +vsxei8_v ... 0-1 . ..... ..... 000 ..... 0100111 @r_nfvm +vsxei16_v ... 0-1 . ..... ..... 101 ..... 0100111 @r_nfvm +vsxei32_v ... 0-1 . ..... ..... 110 ..... 0100111 @r_nfvm +vsxei64_v ... 0-1 . ..... ..... 111 ..... 0100111 @r_nfvm #*** Vector AMO operations are encoded under the standard AMO major opcode *** vamoswapw_v 00001 . . ..... ..... 110 ..... 0101111 @r_wdvm
target/riscv/insn_trans/trans_rvv.inc.c +101 -55
196 lines not on this page · raw message
target/riscv/vector_helper.c +40 -44
122 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 16/65 target/riscv: rvv-0.9: fix address index overflow bug of indexed load/store insns
In reply to [email protected]From: Frank Chang <[email protected]>
Replace ETYPE from signed int to unsigned int to prevent index overflow issue, which would lead to wrong index address.
--- target/riscv/vector_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/riscv/vector_helper.c +4 -4
@@ -456,10 +456,10 @@ static target_ulong NAME(target_ulong base, \return (base + *((ETYPE *)vs2 +H (idx))); \ } -GEN_VEXT_GET_INDEX_ADDR(idx_b, int8_t, H1) -GEN_VEXT_GET_INDEX_ADDR(idx_h, int16_t, H2) -GEN_VEXT_GET_INDEX_ADDR(idx_w, int32_t, H4) -GEN_VEXT_GET_INDEX_ADDR(idx_d, int64_t, H8) +GEN_VEXT_GET_INDEX_ADDR(idx_b, uint8_t, H1) +GEN_VEXT_GET_INDEX_ADDR(idx_h, uint16_t, H2) +GEN_VEXT_GET_INDEX_ADDR(idx_w, uint32_t, H4) +GEN_VEXT_GET_INDEX_ADDR(idx_d, uint64_t, H8) static inline void vext_ldst_index(void *vd, void *v0, target_ulong base,
Signature · 1 line
2.17.1
RFC 17/65 target/riscv: rvv-0.9: fault-only-first unit stride load
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 27 +++--------- target/riscv/insn32.decode | 14 +++---- target/riscv/insn_trans/trans_rvv.inc.c | 31 ++++---------- target/riscv/vector_helper.c | 56 +++++++++---------------- 4 files changed, 38 insertions(+), 90 deletions(-)
target/riscv/helper.h +5 -22
@@ -140,28 +140,11 @@ DEF_HELPER_6(vsxei64_8_v, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vsxei64_16_v, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vsxei64_32_v, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vsxei64_64_v, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_5(vlbff_v_b, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbff_v_h, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbff_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbff_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlhff_v_h, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlhff_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlhff_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlwff_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlwff_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vleff_v_b, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vleff_v_h, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vleff_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vleff_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbuff_v_b, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbuff_v_h, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbuff_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlbuff_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlhuff_v_h, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlhuff_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlhuff_v_d, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlwuff_v_w, void, ptr, ptr, tl, env, i32) -DEF_HELPER_5(vlwuff_v_d, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vle8ff_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vle16ff_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vle32ff_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vle64ff_v, void, ptr, ptr, tl, env, i32) +#ifdef TARGET_RISCV64 DEF_HELPER_6(vamoswapw_v_d, void, ptr, ptr, tl, ptr, env, i32)DEF_HELPER_6 (vamoswapd_v_d, void, ptr, ptr, tl, ptr, env, i32)
target/riscv/insn32.decode +6 -8
@@ -249,14 +249,6 @@ vsse16_v ... 010 . ..... ..... 101 ..... 0100111 @r_nfvm vsse32_v ... 010 . ..... ..... 110 ..... 0100111 @r_nfvm vsse64_v ... 010 . ..... ..... 111 ..... 0100111 @r_nfvm -vlbff_v ... 100 . 10000 ..... 000 ..... 0000111 @r2_nfvm -vlhff_v ... 100 . 10000 ..... 101 ..... 0000111 @r2_nfvm -vlwff_v ... 100 . 10000 ..... 110 ..... 0000111 @r2_nfvm -vleff_v ... 000 . 10000 ..... 111 ..... 0000111 @r2_nfvm -vlbuff_v ... 000 . 10000 ..... 000 ..... 0000111 @r2_nfvm -vlhuff_v ... 000 . 10000 ..... 101 ..... 0000111 @r2_nfvm -vlwuff_v ... 000 . 10000 ..... 110 ..... 0000111 @r2_nfvm - # Vector indexed load insns. vlxei8_v ... 011 . ..... ..... 000 ..... 0000111 @r_nfvm vlxei16_v ... 011 . ..... ..... 101 ..... 0000111 @r_nfvm
@@ -269,6 +261,12 @@ vsxei16_v ... 0-1 . ..... ..... 101 ..... 0100111 @r_nfvm vsxei32_v ... 0-1 . ..... ..... 110 ..... 0100111 @r_nfvm vsxei64_v ... 0-1 . ..... ..... 111 ..... 0100111 @r_nfvm +# Vector unit-stride fault-only-first load insns. +vle8ff_v ... 000 . 10000 ..... 000 ..... 0000111 @r2_nfvm +vle16ff_v ... 000 . 10000 ..... 101 ..... 0000111 @r2_nfvm +vle32ff_v ... 000 . 10000 ..... 110 ..... 0000111 @r2_nfvm +vle64ff_v ... 000 . 10000 ..... 111 ..... 0000111 @r2_nfvm + #*** Vector AMO operations are encoded under the standard AMO major opcode *** vamoswapw_v 00001 . . ..... ..... 110 ..... 0101111 @r_wdvm vamoaddw_v 00000 . . ..... ..... 110 ..... 0101111 @r_wdvm
target/riscv/insn_trans/trans_rvv.inc.c +8 -23
@@ -771,25 +771,13 @@ static bool ldff_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq) {uint32_t data =0 ;gen_helper_ldst_us *fn; -static gen_helper_ldst_us *const fns[7 ][4 ] = { - { gen_helper_vlbff_v_b, gen_helper_vlbff_v_h, - gen_helper_vlbff_v_w, gen_helper_vlbff_v_d }, - {NULL , gen_helper_vlhff_v_h, - gen_helper_vlhff_v_w, gen_helper_vlhff_v_d }, - {NULL ,NULL , - gen_helper_vlwff_v_w, gen_helper_vlwff_v_d }, - { gen_helper_vleff_v_b, gen_helper_vleff_v_h, - gen_helper_vleff_v_w, gen_helper_vleff_v_d }, - { gen_helper_vlbuff_v_b, gen_helper_vlbuff_v_h, - gen_helper_vlbuff_v_w, gen_helper_vlbuff_v_d }, - {NULL , gen_helper_vlhuff_v_h, - gen_helper_vlhuff_v_w, gen_helper_vlhuff_v_d }, - {NULL ,NULL , - gen_helper_vlwuff_v_w, gen_helper_vlwuff_v_d } +static gen_helper_ldst_us *const fns[4 ] = { + gen_helper_vle8ff_v, gen_helper_vle16ff_v, + gen_helper_vle32ff_v, gen_helper_vle64ff_v };bool ret; - fn = fns[seq][s->sew]; + fn = fns[seq];if (fn ==NULL ) {return false; }
@@ -805,13 +793,10 @@ static bool ldff_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq)return ret; } -GEN_VEXT_TRANS(vlbff_v, 0, r2nfvm, ldff_op, ld_us_check) -GEN_VEXT_TRANS(vlhff_v, 1, r2nfvm, ldff_op, ld_us_check) -GEN_VEXT_TRANS(vlwff_v, 2, r2nfvm, ldff_op, ld_us_check) -GEN_VEXT_TRANS(vleff_v, 3, r2nfvm, ldff_op, ld_us_check) -GEN_VEXT_TRANS(vlbuff_v, 4, r2nfvm, ldff_op, ld_us_check) -GEN_VEXT_TRANS(vlhuff_v, 5, r2nfvm, ldff_op, ld_us_check) -GEN_VEXT_TRANS (vlwuff_v,6 , r2nfvm, ldff_op, ld_us_check) +GEN_VEXT_TRANS(vle8ff_v, 8, 0, r2nfvm, ldff_op, ld_us_check) +GEN_VEXT_TRANS(vle16ff_v, 16, 1, r2nfvm, ldff_op, ld_us_check) +GEN_VEXT_TRANS(vle32ff_v, 32, 2, r2nfvm, ldff_op, ld_us_check) +GEN_VEXT_TRANS (vle64ff_v,64 ,3 , r2nfvm, ldff_op, ld_us_check)/* *** vector atomic operation
target/riscv/vector_helper.c +19 -37
93 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 18/65 target/riscv: rvv-0.9: amo operations
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 100 ++++++++--- target/riscv/insn32-64.decode | 18 +- target/riscv/insn32.decode | 36 +++- target/riscv/insn_trans/trans_rvv.inc.c | 191 +++++++++++++------- target/riscv/vector_helper.c | 228 ++++++++++++++++-------- 5 files changed, 388 insertions(+), 185 deletions(-)
target/riscv/helper.h +72 -28
@@ -145,36 +145,80 @@ DEF_HELPER_5(vle16ff_v, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vle32ff_v, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vle64ff_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_6(vamoswapei8_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoswapei8_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoswapei16_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoswapei16_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoswapei32_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoswapei32_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoaddei8_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoaddei8_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoaddei16_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoaddei16_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoaddei32_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoaddei32_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoxorei8_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoxorei8_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoxorei16_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoxorei16_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoxorei32_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoxorei32_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoandei8_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoandei8_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoandei16_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoandei16_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoandei32_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoandei32_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoorei8_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoorei8_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoorei16_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoorei16_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoorei32_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoorei32_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominei8_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominei8_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominei16_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominei16_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominei32_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominei32_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxei8_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxei8_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxei16_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxei16_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxei32_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxei32_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominuei8_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominuei8_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominuei16_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominuei16_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominuei32_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominuei32_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxuei8_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxuei8_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxuei16_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxuei16_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxuei32_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxuei32_64_v, void, ptr, ptr, tl, ptr, env, i32)#ifdef TARGET_RISCV64 -DEF_HELPER_6(vamoswapw_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamoswapd_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamoaddw_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamoaddd_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamoxorw_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamoxord_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamoandw_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamoandd_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamoorw_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamoord_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamominw_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamomind_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamomaxw_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamomaxd_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamominuw_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamominud_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamomaxuw_v_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamomaxud_v_d, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoswapei64_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoswapei64_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoaddei64_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoaddei64_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoxorei64_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoxorei64_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoandei64_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoandei64_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoorei64_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamoorei64_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominei64_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominei64_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxei64_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxei64_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominuei64_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamominuei64_64_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxuei64_32_v, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vamomaxuei64_64_v, void, ptr, ptr, tl, ptr, env, i32)#endif -DEF_HELPER_6(vamoswapw_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamoaddw_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamoxorw_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamoandw_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamoorw_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamominw_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamomaxw_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamominuw_v_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vamomaxuw_v_w, void, ptr, ptr, tl, ptr, env, i32) - DEF_HELPER_6(vadd_vv_b, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32)DEF_HELPER_6 (vadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32)
target/riscv/insn32-64.decode +9 -9
@@ -58,15 +58,15 @@ amominu_d 11000 . . ..... ..... 011 ..... 0101111 @atom_st amomaxu_d 11100 . . ..... ..... 011 ..... 0101111 @atom_st #*** Vector AMO operations (in addition to Zvamo) *** -vamoswapd_v 00001 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamoaddd_v 00000 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamoxord_v 00100 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamoandd_v 01100 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamoord_v 01000 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamomind_v 10000 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamomaxd_v 10100 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamominud_v 11000 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamomaxud_v 11100 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamoswapei64_v 00001 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamoaddei64_v 00000 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamoxorei64_v 00100 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamoandei64_v 01100 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamoorei64_v 01000 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamominei64_v 10000 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamomaxei64_v 10100 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamominuei64_v 11000 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamomaxuei64_v 11100 . . ..... ..... 111 ..... 0101111 @r_wdvm # *** RV64F Standard Extension (in addition to RV32F) *** fcvt_l_s 1100000 00010 ..... ... ..... 1010011 @r2_rm
target/riscv/insn32.decode +27 -9
@@ -268,15 +268,33 @@ vle32ff_v ... 000 . 10000 ..... 110 ..... 0000111 @r2_nfvm vle64ff_v ... 000 . 10000 ..... 111 ..... 0000111 @r2_nfvm #*** Vector AMO operations are encoded under the standard AMO major opcode *** -vamoswapw_v 00001 . . ..... ..... 110 ..... 0101111 @r_wdvm -vamoaddw_v 00000 . . ..... ..... 110 ..... 0101111 @r_wdvm -vamoxorw_v 00100 . . ..... ..... 110 ..... 0101111 @r_wdvm -vamoandw_v 01100 . . ..... ..... 110 ..... 0101111 @r_wdvm -vamoorw_v 01000 . . ..... ..... 110 ..... 0101111 @r_wdvm -vamominw_v 10000 . . ..... ..... 110 ..... 0101111 @r_wdvm -vamomaxw_v 10100 . . ..... ..... 110 ..... 0101111 @r_wdvm -vamominuw_v 11000 . . ..... ..... 110 ..... 0101111 @r_wdvm -vamomaxuw_v 11100 . . ..... ..... 110 ..... 0101111 @r_wdvm +vamoswapei8_v 00001 . . ..... ..... 000 ..... 0101111 @r_wdvm +vamoswapei16_v 00001 . . ..... ..... 101 ..... 0101111 @r_wdvm +vamoswapei32_v 00001 . . ..... ..... 110 ..... 0101111 @r_wdvm +vamoaddei8_v 00000 . . ..... ..... 000 ..... 0101111 @r_wdvm +vamoaddei16_v 00000 . . ..... ..... 101 ..... 0101111 @r_wdvm +vamoaddei32_v 00000 . . ..... ..... 110 ..... 0101111 @r_wdvm +vamoxorei8_v 00100 . . ..... ..... 000 ..... 0101111 @r_wdvm +vamoxorei16_v 00100 . . ..... ..... 101 ..... 0101111 @r_wdvm +vamoxorei32_v 00100 . . ..... ..... 110 ..... 0101111 @r_wdvm +vamoandei8_v 01100 . . ..... ..... 000 ..... 0101111 @r_wdvm +vamoandei16_v 01100 . . ..... ..... 101 ..... 0101111 @r_wdvm +vamoandei32_v 01100 . . ..... ..... 110 ..... 0101111 @r_wdvm +vamoorei8_v 01000 . . ..... ..... 000 ..... 0101111 @r_wdvm +vamoorei16_v 01000 . . ..... ..... 101 ..... 0101111 @r_wdvm +vamoorei32_v 01000 . . ..... ..... 110 ..... 0101111 @r_wdvm +vamominei8_v 10000 . . ..... ..... 000 ..... 0101111 @r_wdvm +vamominei16_v 10000 . . ..... ..... 101 ..... 0101111 @r_wdvm +vamominei32_v 10000 . . ..... ..... 110 ..... 0101111 @r_wdvm +vamomaxei8_v 10100 . . ..... ..... 000 ..... 0101111 @r_wdvm +vamomaxei16_v 10100 . . ..... ..... 101 ..... 0101111 @r_wdvm +vamomaxei32_v 10100 . . ..... ..... 110 ..... 0101111 @r_wdvm +vamominuei8_v 11000 . . ..... ..... 000 ..... 0101111 @r_wdvm +vamominuei16_v 11000 . . ..... ..... 101 ..... 0101111 @r_wdvm +vamominuei32_v 11000 . . ..... ..... 110 ..... 0101111 @r_wdvm +vamomaxuei8_v 11100 . . ..... ..... 000 ..... 0101111 @r_wdvm +vamomaxuei16_v 11100 . . ..... ..... 101 ..... 0101111 @r_wdvm +vamomaxuei32_v 11100 . . ..... ..... 110 ..... 0101111 @r_wdvm # *** new major opcode OP-V *** vadd_vv 000000 . ..... ..... 000 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvv.inc.c +126 -65
227 lines not on this page · raw message
target/riscv/vector_helper.c +154 -74
280 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 19/65 target/riscv: rvv-0.9: load/store whole register instructions
In reply to [email protected]From: Frank Chang <[email protected]>
Add the following instructions:
* vl1r.v
* vs1r.v
--- target/riscv/helper.h | 3 ++ target/riscv/insn32.decode | 4 ++ target/riscv/insn_trans/trans_rvv.inc.c | 55 +++++++++++++++++++++++++ target/riscv/vector_helper.c | 46 +++++++++++++++++++++ 4 files changed, 108 insertions(+)
target/riscv/helper.h +3 -0
@@ -145,6 +145,9 @@ DEF_HELPER_5(vle16ff_v, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vle32ff_v, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vle64ff_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_4(vl1r_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vs1r_v, void, ptr, tl, env, i32) + DEF_HELPER_6(vamoswapei8_32_v, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vamoswapei8_64_v, void, ptr, ptr, tl, ptr, env, i32)DEF_HELPER_6 (vamoswapei16_32_v, void, ptr, ptr, tl, ptr, env, i32)
target/riscv/insn32.decode +4 -0
@@ -267,6 +267,10 @@ vle16ff_v ... 000 . 10000 ..... 101 ..... 0000111 @r2_nfvm vle32ff_v ... 000 . 10000 ..... 110 ..... 0000111 @r2_nfvm vle64ff_v ... 000 . 10000 ..... 111 ..... 0000111 @r2_nfvm +# Vector whole register insns +vl1r_v 000 000 1 01000 ..... 000 ..... 0000111 @r2 +vs1r_v 000 000 1 01000 ..... 000 ..... 0100111 @r2 + #*** Vector AMO operations are encoded under the standard AMO major opcode *** vamoswapei8_v 00001 . . ..... ..... 000 ..... 0101111 @r_wdvm vamoswapei16_v 00001 . . ..... ..... 101 ..... 0101111 @r_wdvm
target/riscv/insn_trans/trans_rvv.inc.c +55 -0
61 lines not on this page · raw message
target/riscv/vector_helper.c +46 -0
52 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 20/65 target/riscv: rvv-0.9: update vext_max_elems() for load/store insns
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/vector_helper.c | 118 ++++++++++++++++++++--------------- 1 file changed, 68 insertions(+), 50 deletions(-)
target/riscv/vector_helper.c +68 -50
@@ -129,14 +129,32 @@ static inline uint32_t vext_vma(uint32_t desc) }/* -* Get vector group length in bytes. Its range is [64, 2048]. -* -* As simd_desc support at most 256, the max vlen is 512 bits. -* So vlen in bytes is encoded as maxsz. +* Get the maximum number of elements can be operated. */ -static inline uint32_t vext_maxsz (uint32_t desc) +static inline uint32_t vext_max_elems (uint32_t desc,uint32_t esz,bool is_ldst) { -return simd_maxsz (desc) <<vext_lmul (desc); +/* +* As simd_desc support at most 256, the max vlen is 512 bits, +* so vlen in bytes (vlenb) is encoded as maxsz. +*/ +uint32_t vlenb =simd_maxsz (desc); + +if (is_ldst) { +/* +* Vector load/store instructions have the EEW encoded +* directly in the instructions. The maximum vector size is +* calculated with EMUL rather than LMUL. +*/ +uint32_t eew = esz <<3 ; +uint32_t sew =vext_sew (desc); +float flmul =vext_vflmul (desc); +float emul = (float )eew / sew * flmul; +uint32_t emul_r = emul <1 ?1 : emul; +return vlenb * emul_r / esz; + }else { +/* Return VLMAX */ +return vlenb *vext_vflmul (desc) / esz; + } }/*
@@ -296,7 +314,7 @@ vext_ldst_stride(void *vd, void *v0, target_ulong base, {uint32_t i, k;uint32_t nf =vext_nf (desc); -uint32_t vlmax =vext_maxsz (desc) / esz; +uint32_t max_elems =vext_max_elems (desc, esz, true);uint32_t vta =vext_vta (desc);/* probe every access*/
@@ -314,15 +332,15 @@ vext_ldst_stride(void *vd, void *v0, target_ulong base, }while (k < nf) {target_ulong addr = base + stride * i + k * esz; -ldst_elem (env, addr, i + k * vlmax, vd, ra); +ldst_elem (env, addr, i + k * max_elems, vd, ra); k++; } }/* clear tail elements */ if (clear_elem) {for (k =0 ; k < nf; k++) { -clear_elem (vd, vta, env->vl + k * vlmax, - env->vl * esz, vlmax * esz); +clear_elem (vd, vta, env->vl + k * max_elems, + env->vl * esz, max_elems * esz); } } }
@@ -371,7 +389,7 @@ vext_ldst_us(void *vd, target_ulong base, CPURISCVState *env, uint32_t desc, {uint32_t i, k;uint32_t nf =vext_nf (desc); -uint32_t vlmax =vext_maxsz (desc) / esz; +uint32_t max_elems =vext_max_elems (desc, esz, true);uint32_t vta =vext_vta (desc);/* probe every access */
@@ -381,15 +399,15 @@ vext_ldst_us(void *vd, target_ulong base, CPURISCVState *env, uint32_t desc, k =0 ;while (k < nf) {target_ulong addr = base + (i * nf + k) * esz; -ldst_elem (env, addr, i + k * vlmax, vd, ra); +ldst_elem (env, addr, i + k * max_elems, vd, ra); k++; } }/* clear tail elements */ if (clear_elem) {for (k =0 ; k < nf; k++) { -clear_elem (vd, vta, env->vl + k * vlmax, - env->vl * esz, vlmax * esz); +clear_elem (vd, vta, env->vl + k * max_elems, + env->vl * esz, max_elems * esz); } } }
@@ -472,7 +490,7 @@ vext_ldst_index(void *vd, void *v0, target_ulong base,uint32_t i, k;uint32_t nf =vext_nf (desc);uint32_t vm =vext_vm (desc); -uint32_t vlmax =vext_maxsz (desc) / esz; +uint32_t max_elems =vext_max_elems (desc, esz, true);uint32_t vta =vext_vta (desc);/* probe every access*/
@@ -491,15 +509,15 @@ vext_ldst_index(void *vd, void *v0, target_ulong base, }while (k < nf) {abi_ptr addr =get_index_addr (base, i, vs2) + k * esz; -ldst_elem (env, addr, i + k * vlmax, vd, ra); +ldst_elem (env, addr, i + k * max_elems, vd, ra); k++; } }/* clear tail elements */ if (clear_elem) {for (k =0 ; k < nf; k++) { -clear_elem (vd, vta, env->vl + k * vlmax, - env->vl * esz, vlmax * esz); +clear_elem (vd, vta, env->vl + k * max_elems, + env->vl * esz, max_elems * esz); } } }
@@ -570,7 +588,7 @@ vext_ldff(void *vd, void *v0, target_ulong base,uint32_t i, k, vl =0 ;uint32_t nf =vext_nf (desc);uint32_t vm =vext_vm (desc); -uint32_t vlmax =vext_maxsz (desc) / esz; +uint32_t max_elems =vext_max_elems (desc, esz, true);uint32_t vta =vext_vta (desc);target_ulong addr, offset, remain;
@@ -622,7 +640,7 @@ ProbeSuccess: }while (k < nf) {target_ulong addr = base + (i * nf + k) * esz; -ldst_elem (env, addr, i + k * vlmax, vd, ra); +ldst_elem (env, addr, i + k * max_elems, vd, ra); k++; } }
@@ -631,8 +649,8 @@ ProbeSuccess:return ; }for (k =0 ; k < nf; k++) { -clear_elem (vd, vta, env->vl + k * vlmax, - env->vl * esz, vlmax * esz); +clear_elem (vd, vta, env->vl + k * max_elems, + env->vl * esz, max_elems * esz); } }
@@ -659,7 +677,7 @@ vext_ldst_whole(void *vd, target_ulong base, CPURISCVState *env, uint32_t desc, {uint32_t i, k;uint32_t nf =vext_nf (desc); -uint32_t vlmax =vext_maxsz (desc) / esz; +uint32_t max_elems =vext_max_elems (desc, esz, true);/* probe every access */ probe_pages (env, base, env->vlenb * nf * esz, ra, access_type);
@@ -669,7 +687,7 @@ vext_ldst_whole(void *vd, target_ulong base, CPURISCVState *env, uint32_t desc, k =0 ;while (k < nf) {target_ulong addr = base + (i * nf + k) * esz; -ldst_elem (env, addr, i + k * vlmax, vd, ra); +ldst_elem (env, addr, i + k * max_elems, vd, ra); k++; } }
@@ -812,7 +830,7 @@ vext_amo_noatomic(void *vs3, void *v0, target_ulong base,target_long addr;uint32_t wd =vext_wd (desc);uint32_t vm =vext_vm (desc); -uint32_t vlmax =vext_maxsz (desc) / esz; +uint32_t vlmax =vext_max_elems (desc, esz, false);uint32_t vta =vext_vta (desc);for (i =0 ; i < env->vl; i++) {
@@ -983,7 +1001,7 @@ static void do_vext_vv(void *vd, void *v0, void *vs1, void *vs2, uint32_t esz, uint32_t dsz, opivv2_fn *fn, clear_fn *clearfn) { - uint32_t vlmax = vext_maxsz(desc) / esz; + uint32_t vlmax = vext_max_elems(desc, esz, false);uint32_t vm =vext_vm (desc);uint32_t vta =vext_vta (desc);uint32_t vl = env->vl;
@@ -995,7 +1013,7 @@ static void do_vext_vv(void *vd, void *v0, void *vs1, void *vs2, }fn (vd, vs1, vs2, i); } -clearfn (vd, vta, vl, vl * dsz, vlmax * dsz); +clearfn (vd, vta, vl, vl * dsz, vlmax * dsz); }/* generate the helpers for OPIVV */
@@ -1048,7 +1066,7 @@ static void do_vext_vx(void *vd, void *v0, target_long s1, void *vs2, uint32_t esz, uint32_t dsz, opivx2_fn fn, clear_fn *clearfn) { - uint32_t vlmax = vext_maxsz(desc) / esz; + uint32_t vlmax = vext_max_elems(desc, esz, false);uint32_t vm =vext_vm (desc);uint32_t vta =vext_vta (desc);uint32_t vl = env->vl;
@@ -1060,7 +1078,7 @@ static void do_vext_vx(void *vd, void *v0, target_long s1, void *vs2, }fn (vd, s1, vs2, i); } -clearfn (vd, vta, vl, vl * dsz, vlmax * dsz); +clearfn (vd, vta, vl, vl * dsz, vlmax * dsz); }/* generate the helpers for OPIVX */
@@ -1247,7 +1265,7 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ { \uint32_t vl = env->vl; \uint32_t esz =sizeof (ETYPE ); \ -uint32_t vlmax =vext_maxsz (desc) / esz; \ +uint32_t vlmax =vext_max_elems (desc, esz, false); \uint32_t vta =vext_vta (desc); \uint32_t i; \ \
@@ -1277,7 +1295,7 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \ { \uint32_t vl = env->vl; \uint32_t esz =sizeof (ETYPE ); \ -uint32_t vlmax =vext_maxsz (desc) / esz; \ +uint32_t vlmax =vext_max_elems (desc, esz, false); \uint32_t vta =vext_vta (desc); \uint32_t i; \ \
@@ -1339,7 +1357,7 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1, \ void *vs2, CPURISCVState *env, uint32_t desc) \ { \ uint32_t vl = env->vl; \ -uint32_t vlmax =vext_maxsz (desc) /sizeof (ETYPE ); \ +uint32_t vlmax =vext_max_elems (desc,sizeof (ETYPE ), false);\uint32_t i; \ \for (i =0 ; i < vl; i++) { \
@@ -1427,7 +1445,7 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, \uint32_t vm =vext_vm (desc); \uint32_t vl = env->vl; \uint32_t esz =sizeof (TS1 ); \ -uint32_t vlmax =vext_maxsz (desc) / esz; \ +uint32_t vlmax =vext_max_elems (desc, esz, false); \uint32_t vta =vext_vta (desc); \uint32_t i; \ \
@@ -1465,7 +1483,7 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1, \uint32_t vm =vext_vm (desc); \uint32_t vl = env->vl; \uint32_t esz =sizeof (TD ); \ -uint32_t vlmax =vext_maxsz (desc) / esz; \ +uint32_t vlmax =vext_max_elems (desc, esz, false); \uint32_t vta =vext_vta (desc); \uint32_t i; \ \
@@ -2108,7 +2126,7 @@ void HELPER(NAME)(void *vd, void *vs1, CPURISCVState *env, \ { \uint32_t vl = env->vl; \uint32_t esz =sizeof (ETYPE ); \ -uint32_t vlmax =vext_maxsz (desc) / esz; \ +uint32_t vlmax =vext_max_elems (desc, esz, false); \uint32_t vta =vext_vta (desc); \uint32_t i; \ \
@@ -2130,7 +2148,7 @@ void HELPER(NAME)(void *vd, uint64_t s1, CPURISCVState *env, \ { \uint32_t vl = env->vl; \uint32_t esz =sizeof (ETYPE ); \ -uint32_t vlmax =vext_maxsz (desc) / esz; \ +uint32_t vlmax =vext_max_elems (desc, esz, false); \uint32_t vta =vext_vta (desc); \uint32_t i; \ \
@@ -2151,7 +2169,7 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ { \uint32_t vl = env->vl; \uint32_t esz =sizeof (ETYPE ); \ -uint32_t vlmax =vext_maxsz (desc) / esz; \ +uint32_t vlmax =vext_max_elems (desc, esz, false); \uint32_t vta =vext_vta (desc); \uint32_t i; \ \
@@ -2173,7 +2191,7 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1, \ { \uint32_t vl = env->vl; \uint32_t esz =sizeof (ETYPE ); \ -uint32_t vlmax =vext_maxsz (desc) / esz; \ +uint32_t vlmax =vext_max_elems (desc, esz, false); \uint32_t vta =vext_vta (desc); \uint32_t i; \ \
@@ -2234,7 +2252,7 @@ vext_vv_rm_2(void *vd, void *v0, void *vs1, void *vs2, uint32_t desc, uint32_t esz, uint32_t dsz, opivv2_rm_fn *fn, clear_fn *clearfn) { - uint32_t vlmax = vext_maxsz(desc) / esz; + uint32_t vlmax = vext_max_elems(desc, esz, false);uint32_t vm =vext_vm (desc);uint32_t vta =vext_vta (desc);uint32_t vl = env->vl;
@@ -2354,7 +2372,7 @@ vext_vx_rm_2(void *vd, void *v0, target_long s1, void *vs2, uint32_t desc, uint32_t esz, uint32_t dsz, opivx2_rm_fn *fn, clear_fn *clearfn) { - uint32_t vlmax = vext_maxsz(desc) / esz; + uint32_t vlmax = vext_max_elems(desc, esz, false);uint32_t vm =vext_vm (desc);uint32_t vta =vext_vta (desc);uint32_t vl = env->vl;
@@ -3258,7 +3276,7 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, \ void *vs2, CPURISCVState *env, \ uint32_t desc) \ { \ - uint32_t vlmax = vext_maxsz(desc) / ESZ; \ + uint32_t vlmax = vext_max_elems(desc, ESZ, false); \uint32_t vm =vext_vm (desc); \uint32_t vta =vext_vta (desc); \uint32_t vl = env->vl; \
@@ -3293,7 +3311,7 @@ void HELPER(NAME)(void *vd, void *v0, uint64_t s1, \ void *vs2, CPURISCVState *env, \ uint32_t desc) \ { \ - uint32_t vlmax = vext_maxsz(desc) / ESZ; \ + uint32_t vlmax = vext_max_elems(desc, ESZ, false); \uint32_t vm =vext_vm (desc); \uint32_t vta =vext_vta (desc); \uint32_t vl = env->vl; \
@@ -3864,7 +3882,7 @@ static void do_##NAME(void *vd, void *vs2, int i, \void HELPER (NAME )(void *vd,void *v0,void *vs2, \CPURISCVState *env,uint32_t desc) \ { \ -uint32_t vlmax =vext_maxsz (desc) /ESZ ; \ +uint32_t vlmax =vext_max_elems (desc,ESZ , false); \uint32_t vm =vext_vm (desc); \uint32_t vta =vext_vta (desc); \uint32_t vl = env->vl; \
@@ -4041,7 +4059,7 @@ void HELPER(NAME)(void *vd, void *v0, uint64_t s1, void *vs2, \ { \uint32_t vm =vext_vm (desc); \uint32_t vl = env->vl; \ -uint32_t vlmax =vext_maxsz (desc) /sizeof (ETYPE ); \ +uint32_t vlmax =vext_max_elems (desc,sizeof (ETYPE ), false); \uint32_t i; \ \for (i =0 ; i < vl; i++) { \
@@ -4185,7 +4203,7 @@ static void do_##NAME(void *vd, void *vs2, int i) \void HELPER (NAME )(void *vd,void *v0,void *vs2, \CPURISCVState *env,uint32_t desc) \ { \ -uint32_t vlmax =vext_maxsz (desc) /ESZ ; \ +uint32_t vlmax =vext_max_elems (desc,ESZ , false); \uint32_t vm =vext_vm (desc); \uint32_t vta =vext_vta (desc); \uint32_t vl = env->vl; \
@@ -4272,7 +4290,7 @@ void HELPER(NAME)(void *vd, void *v0, uint64_t s1, void *vs2, \uint32_t vm =vext_vm (desc); \uint32_t vl = env->vl; \uint32_t esz =sizeof (ETYPE ); \ -uint32_t vlmax =vext_maxsz (desc) / esz; \ +uint32_t vlmax =vext_max_elems (desc, esz, false); \uint32_t vta =vext_vta (desc); \uint32_t i; \ \
@@ -4772,7 +4790,7 @@ GEN_VEXT_VID_V(vid_v_d, uint64_t, H8, clearq)void HELPER (NAME )(void *vd,void *v0,target_ulong s1,void *vs2, \CPURISCVState *env,uint32_t desc) \ { \ -uint32_t vlmax =env_archcpu (env)->cfg.vlen; \ +uint32_t vlmax =vext_max_elems (desc,sizeof (ETYPE ), false); \uint32_t vm =vext_vm (desc); \uint32_t vta =vext_vta (desc); \uint32_t vl = env->vl; \
@@ -4882,7 +4900,7 @@ GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_d, uint64_t, H8, clearq)void HELPER (NAME )(void *vd,void *v0,void *vs1,void *vs2, \CPURISCVState *env,uint32_t desc) \ { \ -uint32_t vlmax =env_archcpu (env)->cfg.vlen; \ +uint32_t vlmax =vext_max_elems (desc,sizeof (ETYPE ), false); \uint32_t vm =vext_vm (desc); \uint32_t vta =vext_vta (desc); \uint32_t vl = env->vl; \
@@ -4912,7 +4930,7 @@ GEN_VEXT_VRGATHER_VV(vrgather_vv_d, uint64_t, H8, clearq)void HELPER (NAME )(void *vd,void *v0,target_ulong s1,void *vs2, \CPURISCVState *env,uint32_t desc) \ { \ -uint32_t vlmax =env_archcpu (env)->cfg.vlen; \ +uint32_t vlmax =vext_max_elems (desc,sizeof (ETYPE ), false); \uint32_t vm =vext_vm (desc); \uint32_t vta =vext_vta (desc); \uint32_t vl = env->vl; \
@@ -4942,7 +4960,7 @@ GEN_VEXT_VRGATHER_VX(vrgather_vx_d, uint64_t, H8, clearq)void HELPER (NAME )(void *vd,void *v0,void *vs1,void *vs2, \CPURISCVState *env,uint32_t desc) \ { \ -uint32_t vlmax =env_archcpu (env)->cfg.vlen; \ +uint32_t vlmax =vext_max_elems (desc,sizeof (ETYPE ), false); \uint32_t vta =vext_vta (desc); \uint32_t vl = env->vl; \uint32_t num =0 , i; \
Signature · 1 line
2.17.1
RFC 21/65 target/riscv: rvv-0.9: take fractional LMUL into vector max elements calculation
In reply to [email protected]From: Frank Chang <[email protected]>
Update vext_get_vlmax() and MAXSZ() to take fractional LMUL into calculation for RVV 0.9.
--- target/riscv/cpu.h | 32 +++++++++++++++---------- target/riscv/insn_trans/trans_rvv.inc.c | 11 ++++++++- 2 files changed, 29 insertions(+), 14 deletions(-)
target/riscv/cpu.h +19 -13
@@ -25,6 +25,8 @@#include "exec/cpu-defs.h" #include "fpu/softfloat-types.h" +#include "internals.h" +#define TCG_GUEST_DEFAULT_MO 0#define TYPE_RISCV_CPU "riscv-cpu"
@@ -380,20 +382,14 @@ FIELD(TB_FLAGS, VMA, 12, 1)/* Skip MSTATUS_VS (0x6000) fields */ FIELD(TB_FLAGS, VILL, 15, 1) -/* -* A simplification for VLMAX -* = (1 << LMUL) * VLEN / (8 * (1 << SEW)) -* = (VLEN << LMUL) / (8 << SEW) -* = (VLEN << LMUL) >> (SEW + 3) -* = VLEN >> (SEW + 3 - LMUL) - */static inline uint32_t vext_get_vlmax (RISCVCPU *cpu,target_ulong vtype) {uint8_t sew, lmul; - sew =FIELD_EX64 (vtype,VTYPE ,VSEW ); - lmul =FIELD_EX64 (vtype,VTYPE ,VLMUL ); -return cpu->cfg.vlen >> (sew +3 - lmul); + lmul = (FIELD_EX64 (vtype,VTYPE ,VFLMUL ) <<2 ) + |FIELD_EX64 (vtype,VTYPE ,VLMUL ); +float flmul = flmul_table[lmul]; +return cpu->cfg.vlen * flmul / (1 << (sew +3 )); } static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
@@ -405,13 +401,23 @@ static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, *cs_base =0 ;if (riscv_has_ext (env,RVV )) { +/* +* If env->vl equals to VLMAX, we can use generic vector operation +* expanders (GVEC) to accerlate the vector operations. +* However, as LMUL could be a fractional number. The maximum +* vector size can be operated might be less than 8 bytes, +* which is not supported by GVEC. So we set vl_eq_vlmax flag to true +* only when maxsz >= 8 bytes. +*/ uint32_t vlmax =vext_get_vlmax (env_archcpu (env), env->vtype); -bool vl_eq_vlmax = (env->vstart ==0 ) && (vlmax == env->vl); +uint32_t sew =FIELD_EX64 (env->vtype,VTYPE ,VSEW ); +uint32_t maxsz = vlmax * (1 << sew); +bool vl_eq_vlmax = (env->vstart ==0 ) && (vlmax == env->vl) + && (maxsz >=8 ); flags =FIELD_DP32 (flags,TB_FLAGS ,VILL ,FIELD_EX64 (env->vtype,VTYPE ,VILL )); - flags =FIELD_DP32 (flags,TB_FLAGS ,SEW , -FIELD_EX64 (env->vtype,VTYPE ,VSEW )); + flags =FIELD_DP32 (flags,TB_FLAGS ,SEW , sew); flags =FIELD_DP32 (flags,TB_FLAGS ,LMUL , (FIELD_EX64 (env->vtype,VTYPE ,VFLMUL ) <<2 ) |FIELD_EX64 (env->vtype,VTYPE ,VLMUL ));
target/riscv/insn_trans/trans_rvv.inc.c +10 -1
@@ -1060,7 +1060,16 @@ GEN_VEXT_TRANS(vamomaxuei64_v, 64, 8, rwdvm, amo_op, amo_check)/* *** Vector Integer Arithmetic Instructions */ -#define MAXSZ (s) (s->vlen >> (3 - s->lmul)) + +/* +* MAXSZ returns the maximum vector size can be operated in bytes, +* which is used in GVEC IR when vl_eq_vlmax flag is set to true +* to accerlate vector operation. +*/ +static inline uint32_t MAXSZ (DisasContext *s) +{ +return (s->vlen >>3 ) * s->flmul; +}static bool opivv_check (DisasContext *s,arg_rmrr *a) {
Signature · 1 line
2.17.1
RFC 22/65 target/riscv: rvv-0.9: floating-point square-root instruction
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn32.decode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/insn32.decode +1 -1
@@ -509,7 +509,7 @@ vfwmsac_vv 111110 . ..... ..... 001 ..... 1010111 @r_vm vfwmsac_vf 111110 . ..... ..... 101 ..... 1010111 @r_vm vfwnmsac_vv 111111 . ..... ..... 001 ..... 1010111 @r_vm vfwnmsac_vf 111111 . ..... ..... 101 ..... 1010111 @r_vm -vfsqrt_v 100011 . ..... 00000 001 ..... 1010111 @r2_vm +vfsqrt_v 010011 . ..... 00000 001 ..... 1010111 @r2_vm vfmin_vv 000100 . ..... ..... 001 ..... 1010111 @r_vm vfmin_vf 000100 . ..... ..... 101 ..... 1010111 @r_vm vfmax_vv 000110 . ..... ..... 001 ..... 1010111 @r_vm
Signature · 1 line
2.17.1
RFC 23/65 target/riscv: rvv-0.9: floating-point classify instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn32.decode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/insn32.decode +1 -1
@@ -532,7 +532,7 @@ vmfgt_vf 011101 . ..... ..... 101 ..... 1010111 @r_vm vmfge_vf 011111 . ..... ..... 101 ..... 1010111 @r_vm vmford_vv 011010 . ..... ..... 001 ..... 1010111 @r_vm vmford_vf 011010 . ..... ..... 101 ..... 1010111 @r_vm -vfclass_v 100011 . ..... 10000 001 ..... 1010111 @r2_vm +vfclass_v 010011 . ..... 10000 001 ..... 1010111 @r2_vm vfmerge_vfm 010111 0 ..... ..... 101 ..... 1010111 @r_vm_0 vfmv_v_f 010111 1 00000 ..... 101 ..... 1010111 @r2 vfcvt_xu_f_v 100010 . ..... 00000 001 ..... 1010111 @r2_vm
Signature · 1 line
2.17.1
RFC 24/65 target/riscv: rvv-0.9: mask population count instruction
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 2 +- target/riscv/insn32.decode | 2 +- target/riscv/insn_trans/trans_rvv.inc.c | 51 +++++++++++++------------ target/riscv/vector_helper.c | 6 +-- 4 files changed, 31 insertions(+), 30 deletions(-)
target/riscv/helper.h +1 -1
@@ -1048,7 +1048,7 @@ DEF_HELPER_6(vmnor_mm, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmornot_mm, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmxnor_mm, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_4(vmpopc_m, tl, ptr, ptr, env, i32) +DEF_HELPER_4(vpopc_m, tl, ptr, ptr, env, i32)DEF_HELPER_4 (vmfirst_m, tl, ptr, ptr, env, i32)
target/riscv/insn32.decode +1 -1
@@ -573,7 +573,7 @@ vmor_mm 011010 - ..... ..... 010 ..... 1010111 @r vmnor_mm 011110 - ..... ..... 010 ..... 1010111 @r vmornot_mm 011100 - ..... ..... 010 ..... 1010111 @r vmxnor_mm 011111 - ..... ..... 010 ..... 1010111 @r -vmpopc_m 010100 . ..... ----- 010 ..... 1010111 @r2_vm +vpopc_m 010000 . ..... 10000 010 ..... 1010111 @r2_vm vmfirst_m 010101 . ..... ----- 010 ..... 1010111 @r2_vm vmsbf_m 010110 . ..... 00001 010 ..... 1010111 @r2_vm vmsif_m 010110 . ..... 00011 010 ..... 1010111 @r2_vm
target/riscv/insn_trans/trans_rvv.inc.c +26 -25
62 lines not on this page · raw message
target/riscv/vector_helper.c +3 -3
@@ -4629,9 +4629,9 @@ GEN_VEXT_MASK_VV(vmnor_mm, DO_NOR) GEN_VEXT_MASK_VV(vmornot_mm, DO_ORNOT)GEN_VEXT_MASK_VV (vmxnor_mm,DO_XNOR ) -/* Vector mask population count vmpopc */ -target_ulong HELPER (vmpopc_m )(void *v0,void *vs2,CPURISCVState *env, -uint32_t desc) +/* Vector mask population count vpopc */ +target_ulong HELPER (vpopc_m )(void *v0,void *vs2,CPURISCVState *env, +uint32_t desc) {target_ulong cnt =0 ;uint32_t vm =vext_vm (desc);
Signature · 1 line
2.17.1
RFC 25/65 target/riscv: rvv-0.9: find-first-set mask bit instruction
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 2 +- target/riscv/insn32.decode | 2 +- target/riscv/insn_trans/trans_rvv.inc.c | 49 +++++++++++++------------ target/riscv/vector_helper.c | 6 +-- 4 files changed, 30 insertions(+), 29 deletions(-)
target/riscv/helper.h +1 -1
@@ -1050,7 +1050,7 @@ DEF_HELPER_6(vmxnor_mm, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_4(vpopc_m, tl, ptr, ptr, env, i32) -DEF_HELPER_4(vmfirst_m, tl, ptr, ptr, env, i32) +DEF_HELPER_4(vfirst_m, tl, ptr, ptr, env, i32) DEF_HELPER_5(vmsbf_m, void, ptr, ptr, ptr, env, i32)DEF_HELPER_5 (vmsif_m, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +1 -1
@@ -574,7 +574,7 @@ vmnor_mm 011110 - ..... ..... 010 ..... 1010111 @r vmornot_mm 011100 - ..... ..... 010 ..... 1010111 @r vmxnor_mm 011111 - ..... ..... 010 ..... 1010111 @r vpopc_m 010000 . ..... 10000 010 ..... 1010111 @r2_vm -vmfirst_m 010101 . ..... ----- 010 ..... 1010111 @r2_vm +vfirst_m 010000 . ..... 10001 010 ..... 1010111 @r2_vm vmsbf_m 010110 . ..... 00001 010 ..... 1010111 @r2_vm vmsif_m 010110 . ..... 00011 010 ..... 1010111 @r2_vm vmsof_m 010110 . ..... 00010 010 ..... 1010111 @r2_vm
target/riscv/insn_trans/trans_rvv.inc.c +25 -24
60 lines not on this page · raw message
target/riscv/vector_helper.c +3 -3
@@ -4648,9 +4648,9 @@ target_ulong HELPER(vpopc_m)(void *v0, void *vs2, CPURISCVState *env,return cnt; } -/* vmfirst find-first-set mask bit*/ -target_ulong HELPER (vmfirst_m )(void *v0,void *vs2,CPURISCVState *env, -uint32_t desc) +/* vfirst find-first-set mask bit*/ +target_ulong HELPER (vfirst_m )(void *v0,void *vs2,CPURISCVState *env, +uint32_t desc) {uint32_t vm =vext_vm (desc);uint32_t vl = env->vl;
Signature · 1 line
2.17.1
RFC 26/65 target/riscv: rvv-0.9: set-X-first mask bit instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn32.decode | 6 ++--- target/riscv/insn_trans/trans_rvv.inc.c | 32 +++++++++++++------------ target/riscv/vector_helper.c | 4 ---- 3 files changed, 20 insertions(+), 22 deletions(-)
target/riscv/insn32.decode +3 -3
@@ -575,9 +575,9 @@ vmornot_mm 011100 - ..... ..... 010 ..... 1010111 @r vmxnor_mm 011111 - ..... ..... 010 ..... 1010111 @r vpopc_m 010000 . ..... 10000 010 ..... 1010111 @r2_vm vfirst_m 010000 . ..... 10001 010 ..... 1010111 @r2_vm -vmsbf_m 010110 . ..... 00001 010 ..... 1010111 @r2_vm -vmsif_m 010110 . ..... 00011 010 ..... 1010111 @r2_vm -vmsof_m 010110 . ..... 00010 010 ..... 1010111 @r2_vm +vmsbf_m 010100 . ..... 00001 010 ..... 1010111 @r2_vm +vmsif_m 010100 . ..... 00011 010 ..... 1010111 @r2_vm +vmsof_m 010100 . ..... 00010 010 ..... 1010111 @r2_vm viota_m 010110 . ..... 10000 010 ..... 1010111 @r2_vm vid_v 010110 . 00000 10001 010 ..... 1010111 @r1_vm vext_x_v 001100 1 ..... ..... 010 ..... 1010111 @r
target/riscv/insn_trans/trans_rvv.inc.c +17 -15
@@ -2758,22 +2758,24 @@ static bool trans_vfirst_m(DisasContext *s, arg_rmr *a)#define GEN_M_TRANS (NAME ) \ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ { \ - if (vext_check_isa_ill(s)) { \ - uint32_t data = 0; \ - gen_helper_gvec_3_ptr *fn = gen_helper_##NAME; \ - TCGLabel *over = gen_new_label(); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ + REQUIRE_RVV; \ + VEXT_CHECK_ISA_ILL(s); \ + require_vm(a->vm, a->rd); \ + require(a->rd != a->rs2); \ \ - data = FIELD_DP32(data, VDATA, VM, a->vm); \ - data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ - data = FIELD_DP32(data, VDATA, VMA, s->vma); \ - tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), \ - vreg_ofs(s, 0), vreg_ofs(s, a->rs2), \ - cpu_env, 0, s->vlen / 8, data, fn); \ - gen_set_label(over); \ - return true; \ - } \ - return false; \ + uint32_t data = 0; \ + gen_helper_gvec_3_ptr *fn = gen_helper_##NAME; \ + TCGLabel *over = gen_new_label(); \ + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ + \ + data = FIELD_DP32(data, VDATA, VM, a->vm); \ + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ + data = FIELD_DP32(data, VDATA, VMA, s->vma); \ + tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), \ + vreg_ofs(s, 0), vreg_ofs(s, a->rs2), \ + cpu_env, 0, s->vlen / 8, data, fn); \ + gen_set_label(over); \ + return true; \ }GEN_M_TRANS (vmsbf_m)
target/riscv/vector_helper.c +0 -4
@@ -4675,7 +4675,6 @@ enum set_mask_type {static void vmsetm (void *vd,void *v0,void *vs2,CPURISCVState *env,uint32_t desc,enum set_mask_type type) { -uint32_t vlmax =env_archcpu (env)->cfg.vlen;uint32_t vm =vext_vm (desc);uint32_t vl = env->vl;int i;
@@ -4705,9 +4704,6 @@ static void vmsetm(void *vd, void *v0, void *vs2, CPURISCVState *env, } } } -for (; i < vlmax; i++) { -vext_set_elem_mask (vd, i,0 ); - } } void HELPER(vmsbf_m)(void *vd, void *v0, void *vs2, CPURISCVState *env,
Signature · 1 line
2.17.1
RFC 27/65 target/riscv: rvv-0.9: iota instruction
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn32.decode | 2 +- target/riscv/insn_trans/trans_rvv.inc.c | 44 ++++++++++++------------- target/riscv/vector_helper.c | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-)
target/riscv/insn32.decode +1 -1
@@ -578,7 +578,7 @@ vfirst_m 010000 . ..... 10001 010 ..... 1010111 @r2_vm vmsbf_m 010100 . ..... 00001 010 ..... 1010111 @r2_vm vmsif_m 010100 . ..... 00011 010 ..... 1010111 @r2_vm vmsof_m 010100 . ..... 00010 010 ..... 1010111 @r2_vm -viota_m 010110 . ..... 10000 010 ..... 1010111 @r2_vm +viota_m 010100 . ..... 10000 010 ..... 1010111 @r2_vm vid_v 010110 . 00000 10001 010 ..... 1010111 @r1_vm vext_x_v 001100 1 ..... ..... 010 ..... 1010111 @r vmv_s_x 001101 1 00000 ..... 110 ..... 1010111 @r2
target/riscv/insn_trans/trans_rvv.inc.c +22 -22
51 lines not on this page · raw message
target/riscv/vector_helper.c +1 -1
@@ -4748,7 +4748,7 @@ void HELPER(NAME)(void *vd, void *v0, void *vs2, CPURISCVState *env, \CLEAR_FN (vd, vta, vl, vl *sizeof (ETYPE ), vlmax *sizeof (ETYPE )); \ } -GEN_VEXT_VIOTA_M(viota_m_b, uint8_t, H1, clearb) +GEN_VEXT_VIOTA_M(viota_m_b, uint8_t, H1, clearb) GEN_VEXT_VIOTA_M(viota_m_h, uint16_t, H2, clearh) GEN_VEXT_VIOTA_M(viota_m_w, uint32_t, H4, clearl)GEN_VEXT_VIOTA_M (viota_m_d, uint64_t,H8 , clearq)
Signature · 1 line
2.17.1
RFC 28/65 target/riscv: rvv-0.9: element index instruction
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn32.decode | 2 +- target/riscv/insn_trans/trans_rvv.inc.c | 40 ++++++++++++------------- 2 files changed, 21 insertions(+), 21 deletions(-)
target/riscv/insn32.decode +1 -1
@@ -579,7 +579,7 @@ vmsbf_m 010100 . ..... 00001 010 ..... 1010111 @r2_vm vmsif_m 010100 . ..... 00011 010 ..... 1010111 @r2_vm vmsof_m 010100 . ..... 00010 010 ..... 1010111 @r2_vm viota_m 010100 . ..... 10000 010 ..... 1010111 @r2_vm -vid_v 010110 . 00000 10001 010 ..... 1010111 @r1_vm +vid_v 010100 . 00000 10001 010 ..... 1010111 @r1_vm vext_x_v 001100 1 ..... ..... 010 ..... 1010111 @r vmv_s_x 001101 1 00000 ..... 110 ..... 1010111 @r2 vfmv_f_s 001100 1 ..... 00000 001 ..... 1010111 @r2rd
target/riscv/insn_trans/trans_rvv.inc.c +20 -20
@@ -2813,27 +2813,27 @@ static bool trans_viota_m(DisasContext *s, arg_viota_m *a)/* Vector Element Index Instruction */ static bool trans_vid_v (DisasContext *s,arg_vid_v *a) { -if (vext_check_isa_ill (s) && -vext_check_reg (s, a->rd, false) && -vext_check_overlap_mask (s, a->rd, a->vm, false)) { -uint32_t data =0 ; -TCGLabel *over =gen_new_label (); -tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +require_align (a->rd, s->flmul); +require_vm (a->vm, a->rd); - data =FIELD_DP32 (data,VDATA ,VM , a->vm); - data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); - data =FIELD_DP32 (data,VDATA ,VTA , s->vta); - data =FIELD_DP32 (data,VDATA ,VMA , s->vma); -static gen_helper_gvec_2_ptr *const fns[4 ] = { - gen_helper_vid_v_b, gen_helper_vid_v_h, - gen_helper_vid_v_w, gen_helper_vid_v_d, - }; -tcg_gen_gvec_2_ptr (vreg_ofs (s, a->rd),vreg_ofs (s,0 ), - cpu_env,0 , s->vlen /8 , data, fns[s->sew]); -gen_set_label (over); -return true; - } -return false; +uint32_t data =0 ; +TCGLabel *over =gen_new_label (); +tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over); + + data =FIELD_DP32 (data,VDATA ,VM , a->vm); + data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); + data =FIELD_DP32 (data,VDATA ,VTA , s->vta); + data =FIELD_DP32 (data,VDATA ,VMA , s->vma); +static gen_helper_gvec_2_ptr *const fns[4 ] = { + gen_helper_vid_v_b, gen_helper_vid_v_h, + gen_helper_vid_v_w, gen_helper_vid_v_d, + }; +tcg_gen_gvec_2_ptr (vreg_ofs (s, a->rd),vreg_ofs (s,0 ), + cpu_env,0 , s->vlen /8 , data, fns[s->sew]); +gen_set_label (over); +return true; }/*
Signature · 1 line
2.17.1
RFC 29/65 target/riscv: rvv-0.9: integer scalar move instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn32.decode | 3 +- target/riscv/insn_trans/trans_rvv.inc.c | 59 +++++++++++++++++-------- 2 files changed, 43 insertions(+), 19 deletions(-)
target/riscv/insn32.decode +2 -1
@@ -580,8 +580,9 @@ vmsif_m 010100 . ..... 00011 010 ..... 1010111 @r2_vm vmsof_m 010100 . ..... 00010 010 ..... 1010111 @r2_vm viota_m 010100 . ..... 10000 010 ..... 1010111 @r2_vm vid_v 010100 . 00000 10001 010 ..... 1010111 @r1_vm +vmv_x_s 010000 1 ..... 00000 010 ..... 1010111 @r2rd +vmv_s_x 010000 1 00000 ..... 110 ..... 1010111 @r2 vext_x_v 001100 1 ..... ..... 010 ..... 1010111 @r -vmv_s_x 001101 1 00000 ..... 110 ..... 1010111 @r2 vfmv_f_s 001100 1 ..... 00000 001 ..... 1010111 @r2rd vfmv_s_f 001101 1 00000 ..... 101 ..... 1010111 @r2 vslideup_vx 001110 . ..... ..... 100 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvv.inc.c +41 -18
71 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 30/65 target/riscv: rvv-0.9: floating-point scalar move instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn32.decode | 4 +- target/riscv/insn_trans/trans_rvv.inc.c | 66 ++++++++++++------------- 2 files changed, 35 insertions(+), 35 deletions(-)
target/riscv/insn32.decode +2 -2
@@ -583,8 +583,8 @@ vid_v 010100 . 00000 10001 010 ..... 1010111 @r1_vm vmv_x_s 010000 1 ..... 00000 010 ..... 1010111 @r2rd vmv_s_x 010000 1 00000 ..... 110 ..... 1010111 @r2 vext_x_v 001100 1 ..... ..... 010 ..... 1010111 @r -vfmv_f_s 001100 1 ..... 00000 001 ..... 1010111 @r2rd -vfmv_s_f 001101 1 00000 ..... 101 ..... 1010111 @r2 +vfmv_f_s 010000 1 ..... 00000 001 ..... 1010111 @r2rd +vfmv_s_f 010000 1 00000 ..... 101 ..... 1010111 @r2 vslideup_vx 001110 . ..... ..... 100 ..... 1010111 @r_vm vslideup_vi 001110 . ..... ..... 011 ..... 1010111 @r_vm vslide1up_vx 001110 . ..... ..... 110 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvv.inc.c +33 -33
83 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 31/65 target/riscv: rvv-0.9: whole register move instructions
In reply to [email protected]From: Frank Chang <[email protected]>
Add the following instructions:
* vmv1r.v
* vmv2r.v
* vmv4r.v
* vmv8r.v
--- target/riscv/insn32.decode | 4 ++++ target/riscv/insn_trans/trans_rvv.inc.c | 26 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+)
target/riscv/insn32.decode +4 -0
@@ -595,6 +595,10 @@ vrgather_vv 001100 . ..... ..... 000 ..... 1010111 @r_vm vrgather_vx 001100 . ..... ..... 100 ..... 1010111 @r_vm vrgather_vi 001100 . ..... ..... 011 ..... 1010111 @r_vm vcompress_vm 010111 - ..... ..... 010 ..... 1010111 @r +vmv1r_v 100111 1 ..... 00000 011 ..... 1010111 @r2rd +vmv2r_v 100111 1 ..... 00001 011 ..... 1010111 @r2rd +vmv4r_v 100111 1 ..... 00011 011 ..... 1010111 @r2rd +vmv8r_v 100111 1 ..... 00111 011 ..... 1010111 @r2rd vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm vsetvl 1000000 ..... ..... 111 ..... 1010111 @r
target/riscv/insn_trans/trans_rvv.inc.c +26 -0
@@ -3221,3 +3221,29 @@ static bool trans_vcompress_vm(DisasContext *s, arg_r *a) }return false; } + +/* +* Whole Vector Register Move Instructions ignore vtype and vl setting. +* Thus, we don't need to check vill bit. (Section 17.6) +*/ +#define GEN_VMV_WHOLE_TRANS (NAME ,LEN ) \ +static bool trans_##NAME(DisasContext *s, arg_##NAME * a) \ +{ \ + REQUIRE_RVV; \ + require((a->rd & ((LEN) - 1)) == 0); \ + require((a->rs2 & ((LEN) - 1)) == 0); \ + \ + for (int i = 0; i < LEN; ++i) { \ +/* EEW = 8 */ \ +tcg_gen_gvec_mov (8 ,vreg_ofs (s, a->rd + i), \ +vreg_ofs (s, a->rs2 + i), \ + s->vlen /8 , s->vlen /8 ); \ + } \ +mark_vs_dirty (s); \ +return true; \ +} + +GEN_VMV_WHOLE_TRANS(vmv1r_v, 1) +GEN_VMV_WHOLE_TRANS(vmv2r_v, 2) +GEN_VMV_WHOLE_TRANS(vmv4r_v, 4) +GEN_VMV_WHOLE_TRANS (vmv8r_v,8 )
Signature · 1 line
2.17.1
RFC 32/65 target/riscv: rvv-0.9: integer extension instructions
In reply to [email protected]From: Frank Chang <[email protected]>
Add the following instructions:
* vzext.vf2
* vzext.vf4
* vzext.vf8
* vsext.vf2
* vsext.vf4
* vsext.vf8
--- target/riscv/helper.h | 14 ++++ target/riscv/insn32.decode | 8 +++ target/riscv/insn_trans/trans_rvv.inc.c | 94 +++++++++++++++++++++++++ target/riscv/vector_helper.c | 34 +++++++++ 4 files changed, 150 insertions(+)
target/riscv/helper.h +14 -0
@@ -1096,3 +1096,17 @@ DEF_HELPER_6(vcompress_vm_b, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vcompress_vm_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vcompress_vm_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vcompress_vm_d, void, ptr, ptr, ptr, ptr, env, i32) + +DEF_HELPER_5(vzext_vf2_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vzext_vf2_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vzext_vf2_d, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vzext_vf4_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vzext_vf4_d, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vzext_vf8_d, void, ptr, ptr, ptr, env, i32) + +DEF_HELPER_5(vsext_vf2_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vsext_vf2_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vsext_vf2_d, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vsext_vf4_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vsext_vf4_d, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5 (vsext_vf8_d, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +8 -0
@@ -600,5 +600,13 @@ vmv2r_v 100111 1 ..... 00001 011 ..... 1010111 @r2rd vmv4r_v 100111 1 ..... 00011 011 ..... 1010111 @r2rd vmv8r_v 100111 1 ..... 00111 011 ..... 1010111 @r2rd +# Vector Integer Extension +vzext_vf2 010010 . ..... 00110 010 ..... 1010111 @r2_vm +vzext_vf4 010010 . ..... 00100 010 ..... 1010111 @r2_vm +vzext_vf8 010010 . ..... 00010 010 ..... 1010111 @r2_vm +vsext_vf2 010010 . ..... 00111 010 ..... 1010111 @r2_vm +vsext_vf4 010010 . ..... 00101 010 ..... 1010111 @r2_vm +vsext_vf8 010010 . ..... 00011 010 ..... 1010111 @r2_vm + vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm vsetvl 1000000 ..... ..... 111 ..... 1010111 @r
target/riscv/insn_trans/trans_rvv.inc.c +94 -0
103 lines not on this page · raw message
target/riscv/vector_helper.c +34 -0
@@ -4976,3 +4976,37 @@ GEN_VEXT_VCOMPRESS_VM(vcompress_vm_b, uint8_t, H1, clearb) GEN_VEXT_VCOMPRESS_VM(vcompress_vm_h, uint16_t, H2, clearh) GEN_VEXT_VCOMPRESS_VM(vcompress_vm_w, uint32_t, H4, clearl)GEN_VEXT_VCOMPRESS_VM (vcompress_vm_d, uint64_t,H8 , clearq) + +/* Vector Integer Extension */ +#define GEN_VEXT_INT_EXT (NAME ,ETYPE ,DTYPE ,HD ,HS1 ,CLEAR_FN ) \ +void HELPER(NAME)(void *vd, void *v0, void *vs2, \ + CPURISCVState *env, uint32_t desc) \ +{ \ + uint32_t vlmax = vext_max_elems(desc, sizeof(ETYPE), false); \ + uint32_t vta = vext_vta(desc); \ + uint32_t vl = env->vl; \ + uint32_t vm = vext_vm(desc); \ + uint32_t i; \ + \ + for (i = 0; i < vl; i++) { \ + if (!vm && !vext_elem_mask(v0, i)) { \ + continue; \ + } \ + *((ETYPE *)vd + HD(i)) = *((DTYPE *)vs2 + HS1(i)); \ + } \ + CLEAR_FN(vd, vta, vl, vl * sizeof(ETYPE), vlmax * sizeof(ETYPE)); \ +} + +GEN_VEXT_INT_EXT(vzext_vf2_h, uint16_t, uint8_t, H2, H1, clearh) +GEN_VEXT_INT_EXT(vzext_vf2_w, uint32_t, uint16_t, H4, H2, clearl) +GEN_VEXT_INT_EXT(vzext_vf2_d, uint64_t, uint32_t, H8, H4, clearq) +GEN_VEXT_INT_EXT(vzext_vf4_w, uint32_t, uint8_t, H4, H1, clearl) +GEN_VEXT_INT_EXT(vzext_vf4_d, uint64_t, uint16_t, H8, H2, clearq) +GEN_VEXT_INT_EXT(vzext_vf8_d, uint64_t, uint8_t, H8, H1, clearq) + +GEN_VEXT_INT_EXT(vsext_vf2_h, int16_t, int8_t, H2, H1, clearh) +GEN_VEXT_INT_EXT(vsext_vf2_w, int32_t, int16_t, H4, H2, clearl) +GEN_VEXT_INT_EXT(vsext_vf2_d, int64_t, int32_t, H8, H4, clearq) +GEN_VEXT_INT_EXT(vsext_vf4_w, int32_t, int8_t, H4, H1, clearl) +GEN_VEXT_INT_EXT(vsext_vf4_d, int64_t, int16_t, H8, H2, clearq) +GEN_VEXT_INT_EXT (vsext_vf8_d, int64_t, int8_t,H8 ,H1 , clearq)
Signature · 1 line
2.17.1
RFC 33/65 target/riscv: rvv-0.9: single-width averaging add and subtract instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 16 ++++++ target/riscv/insn32.decode | 13 +++-- target/riscv/insn_trans/trans_rvv.inc.c | 5 +- target/riscv/vector_helper.c | 74 +++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 6 deletions(-)
target/riscv/helper.h +16 -0
@@ -676,18 +676,34 @@ DEF_HELPER_6(vaadd_vv_b, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vaadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vaadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vaadd_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vaaddu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vaaddu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vaaddu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vaaddu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vasub_vv_b, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vasub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vasub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vasub_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vasubu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vasubu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vasubu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vasubu_vv_d, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vaadd_vx_b, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vaadd_vx_h, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vaadd_vx_w, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vaadd_vx_d, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vaaddu_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vaaddu_vx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vaaddu_vx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vaaddu_vx_d, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vasub_vx_b, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vasub_vx_h, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vasub_vx_w, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vasub_vx_d, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vasubu_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vasubu_vx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vasubu_vx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vasubu_vx_d, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vsmul_vv_b, void, ptr, ptr, ptr, ptr, env, i32)DEF_HELPER_6 (vsmul_vv_h, void, ptr, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +8 -5
@@ -439,11 +439,14 @@ vssubu_vv 100010 . ..... ..... 000 ..... 1010111 @r_vm vssubu_vx 100010 . ..... ..... 100 ..... 1010111 @r_vm vssub_vv 100011 . ..... ..... 000 ..... 1010111 @r_vm vssub_vx 100011 . ..... ..... 100 ..... 1010111 @r_vm -vaadd_vv 100100 . ..... ..... 000 ..... 1010111 @r_vm -vaadd_vx 100100 . ..... ..... 100 ..... 1010111 @r_vm -vaadd_vi 100100 . ..... ..... 011 ..... 1010111 @r_vm -vasub_vv 100110 . ..... ..... 000 ..... 1010111 @r_vm -vasub_vx 100110 . ..... ..... 100 ..... 1010111 @r_vm +vaadd_vv 001001 . ..... ..... 010 ..... 1010111 @r_vm +vaadd_vx 001001 . ..... ..... 110 ..... 1010111 @r_vm +vaaddu_vv 001000 . ..... ..... 010 ..... 1010111 @r_vm +vaaddu_vx 001000 . ..... ..... 110 ..... 1010111 @r_vm +vasub_vv 001011 . ..... ..... 010 ..... 1010111 @r_vm +vasub_vx 001011 . ..... ..... 110 ..... 1010111 @r_vm +vasubu_vv 001010 . ..... ..... 010 ..... 1010111 @r_vm +vasubu_vx 001010 . ..... ..... 110 ..... 1010111 @r_vm vsmul_vv 100111 . ..... ..... 000 ..... 1010111 @r_vm vsmul_vx 100111 . ..... ..... 100 ..... 1010111 @r_vm vwsmaccu_vv 111100 . ..... ..... 000 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvv.inc.c +4 -1
@@ -2062,10 +2062,13 @@ GEN_OPIVI_TRANS(vsadd_vi, 0, vsadd_vx, opivx_check)/* Vector Single-Width Averaging Add and Subtract */ GEN_OPIVV_TRANS(vaadd_vv, opivv_check) +GEN_OPIVV_TRANS(vaaddu_vv, opivv_check) GEN_OPIVV_TRANS(vasub_vv, opivv_check) +GEN_OPIVV_TRANS(vasubu_vv, opivv_check) GEN_OPIVX_TRANS(vaadd_vx, opivx_check) +GEN_OPIVX_TRANS(vaaddu_vx, opivx_check) GEN_OPIVX_TRANS(vasub_vx, opivx_check) -GEN_OPIVI_TRANS (vaadd_vi,0 , vaadd_vx, opivx_check) +GEN_OPIVX_TRANS (vasubu_vx, opivx_check) /* Vector Single-Width Fractional Multiply with Rounding and Saturation */GEN_OPIVV_TRANS (vsmul_vv, opivv_check)
target/riscv/vector_helper.c +74 -0
86 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 34/65 target/riscv: rvv-0.9: integer add-with-carry/subtract-with-borrow
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn32.decode | 20 +++++----- target/riscv/insn_trans/trans_rvv.inc.c | 2 +- target/riscv/vector_helper.c | 50 ++++++++++++++----------- 3 files changed, 40 insertions(+), 32 deletions(-)
target/riscv/insn32.decode +10 -10
@@ -324,16 +324,16 @@ vwsubu_wv 110110 . ..... ..... 010 ..... 1010111 @r_vm vwsubu_wx 110110 . ..... ..... 110 ..... 1010111 @r_vm vwsub_wv 110111 . ..... ..... 010 ..... 1010111 @r_vm vwsub_wx 110111 . ..... ..... 110 ..... 1010111 @r_vm -vadc_vvm 010000 1 ..... ..... 000 ..... 1010111 @r_vm_1 -vadc_vxm 010000 1 ..... ..... 100 ..... 1010111 @r_vm_1 -vadc_vim 010000 1 ..... ..... 011 ..... 1010111 @r_vm_1 -vmadc_vvm 010001 1 ..... ..... 000 ..... 1010111 @r_vm_1 -vmadc_vxm 010001 1 ..... ..... 100 ..... 1010111 @r_vm_1 -vmadc_vim 010001 1 ..... ..... 011 ..... 1010111 @r_vm_1 -vsbc_vvm 010010 1 ..... ..... 000 ..... 1010111 @r_vm_1 -vsbc_vxm 010010 1 ..... ..... 100 ..... 1010111 @r_vm_1 -vmsbc_vvm 010011 1 ..... ..... 000 ..... 1010111 @r_vm_1 -vmsbc_vxm 010011 1 ..... ..... 100 ..... 1010111 @r_vm_1 +vadc_vvm 010000 0 ..... ..... 000 ..... 1010111 @r_vm_1 +vadc_vxm 010000 0 ..... ..... 100 ..... 1010111 @r_vm_1 +vadc_vim 010000 0 ..... ..... 011 ..... 1010111 @r_vm_1 +vmadc_vvm 010001 . ..... ..... 000 ..... 1010111 @r_vm +vmadc_vxm 010001 . ..... ..... 100 ..... 1010111 @r_vm +vmadc_vim 010001 . ..... ..... 011 ..... 1010111 @r_vm +vsbc_vvm 010010 0 ..... ..... 000 ..... 1010111 @r_vm_1 +vsbc_vxm 010010 0 ..... ..... 100 ..... 1010111 @r_vm_1 +vmsbc_vvm 010011 . ..... ..... 000 ..... 1010111 @r_vm +vmsbc_vxm 010011 . ..... ..... 100 ..... 1010111 @r_vm vand_vv 001001 . ..... ..... 000 ..... 1010111 @r_vm vand_vx 001001 . ..... ..... 100 ..... 1010111 @r_vm vand_vi 001001 . ..... ..... 011 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvv.inc.c +1 -1
@@ -1588,7 +1588,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \/* * For vadc and vsbc, an illegal instruction exception is raised if the -* destination vector register is v0 and LMUL > 1. (Section 12.3) +* destination vector register is v0 and LMUL > 1. (Section 12.4) */ static bool opivv_vadc_check (DisasContext *s,arg_rmrr *a) {
target/riscv/vector_helper.c +29 -21
70 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 35/65 target/riscv: rvv-0.9: narrowing integer right shift instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 24 ++++++++++---------- target/riscv/insn32.decode | 12 +++++----- target/riscv/insn_trans/trans_rvv.inc.c | 30 ++++++++++++------------- target/riscv/vector_helper.c | 24 ++++++++++---------- 4 files changed, 45 insertions(+), 45 deletions(-)
target/riscv/helper.h +12 -12
@@ -379,18 +379,18 @@ DEF_HELPER_6(vsra_vx_h, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vsra_vx_w, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vsra_vx_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vnsrl_vv_b, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vnsrl_vv_h, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vnsrl_vv_w, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vnsra_vv_b, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vnsra_vv_h, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vnsra_vv_w, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vnsrl_vx_b, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vnsrl_vx_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vnsrl_vx_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vnsra_vx_b, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vnsra_vx_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vnsra_vx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vnsrl_wv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vnsrl_wv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vnsrl_wv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vnsra_wv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vnsra_wv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vnsra_wv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vnsrl_wx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vnsrl_wx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vnsrl_wx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vnsra_wx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vnsra_wx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vnsra_wx_w, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vmseq_vv_b, void, ptr, ptr, ptr, ptr, env, i32)DEF_HELPER_6 (vmseq_vv_h, void, ptr, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +6 -6
@@ -352,12 +352,12 @@ vsrl_vi 101000 . ..... ..... 011 ..... 1010111 @r_vm vsra_vv 101001 . ..... ..... 000 ..... 1010111 @r_vm vsra_vx 101001 . ..... ..... 100 ..... 1010111 @r_vm vsra_vi 101001 . ..... ..... 011 ..... 1010111 @r_vm -vnsrl_vv 101100 . ..... ..... 000 ..... 1010111 @r_vm -vnsrl_vx 101100 . ..... ..... 100 ..... 1010111 @r_vm -vnsrl_vi 101100 . ..... ..... 011 ..... 1010111 @r_vm -vnsra_vv 101101 . ..... ..... 000 ..... 1010111 @r_vm -vnsra_vx 101101 . ..... ..... 100 ..... 1010111 @r_vm -vnsra_vi 101101 . ..... ..... 011 ..... 1010111 @r_vm +vnsrl_wv 101100 . ..... ..... 000 ..... 1010111 @r_vm +vnsrl_wx 101100 . ..... ..... 100 ..... 1010111 @r_vm +vnsrl_wi 101100 . ..... ..... 011 ..... 1010111 @r_vm +vnsra_wv 101101 . ..... ..... 000 ..... 1010111 @r_vm +vnsra_wx 101101 . ..... ..... 100 ..... 1010111 @r_vm +vnsra_wi 101101 . ..... ..... 011 ..... 1010111 @r_vm vmseq_vv 011000 . ..... ..... 000 ..... 1010111 @r_vm vmseq_vx 011000 . ..... ..... 100 ..... 1010111 @r_vm vmseq_vi 011000 . ..... ..... 011 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvv.inc.c +15 -15
@@ -1738,7 +1738,7 @@ GEN_OPIVI_TRANS(vsrl_vi, 1, vsrl_vx, opivx_check)GEN_OPIVI_TRANS (vsra_vi,1 , vsra_vx, opivx_check) /* Vector Narrowing Integer Right Shift Instructions */ -static bool opivv_narrow_check (DisasContext *s,arg_rmrr *a) +static bool opiwv_narrow_check (DisasContext *s,arg_rmrr *a) {REQUIRE_RVV ;VEXT_CHECK_ISA_ILL (s);
@@ -1747,10 +1747,10 @@ static bool opivv_narrow_check(DisasContext *s, arg_rmrr *a) }/* OPIVV with NARROW */ -#define GEN_OPIVV_NARROW_TRANS (NAME ) \ +#define GEN_OPIWV_NARROW_TRANS (NAME ) \ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ { \ - if (opivv_narrow_check(s, a)) { \ + if (opiwv_narrow_check(s, a)) { \ uint32_t data = 0; \ static gen_helper_gvec_4_ptr * const fns[3] = { \ gen_helper_##NAME##_b, \
@@ -1774,10 +1774,10 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ } \return false; \ } -GEN_OPIVV_NARROW_TRANS (vnsra_vv) -GEN_OPIVV_NARROW_TRANS (vnsrl_vv ) +GEN_OPIWV_NARROW_TRANS (vnsra_wv) +GEN_OPIWV_NARROW_TRANS (vnsrl_wv ) -static boolopivx_narrow_check (DisasContext *s, arg_rmrr *a) +static boolopiwx_narrow_check (DisasContext *s, arg_rmrr *a) {REQUIRE_RVV ;VEXT_CHECK_ISA_ILL (s);
@@ -1786,10 +1786,10 @@ static bool opivx_narrow_check(DisasContext *s, arg_rmrr *a) }/* OPIVX with NARROW */ -#define GEN_OPIVX_NARROW_TRANS (NAME ) \ +#define GEN_OPIWX_NARROW_TRANS (NAME ) \ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ { \ - if (opivx_narrow_check(s, a)) { \ + if (opiwx_narrow_check(s, a)) { \ static gen_helper_opivx * const fns[3] = { \ gen_helper_##NAME##_b, \ gen_helper_##NAME##_h, \
@@ -1800,14 +1800,14 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \return false; \ } -GEN_OPIVX_NARROW_TRANS(vnsra_vx) -GEN_OPIVX_NARROW_TRANS(vnsrl_vx) +GEN_OPIWX_NARROW_TRANS(vnsra_wx) +GEN_OPIWX_NARROW_TRANS(vnsrl_wx) -/* OPIVI with NARROW */ -#define GEN_OPIVI_NARROW_TRANS (NAME ,ZX ,OPIVX ) \ +/* OPIWI with NARROW */ +#define GEN_OPIWI_NARROW_TRANS (NAME ,ZX ,OPIVX ) \ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ { \ - if (opivx_narrow_check(s, a)) { \ + if (opiwx_narrow_check(s, a)) { \ static gen_helper_opivx * const fns[3] = { \ gen_helper_##OPIVX##_b, \ gen_helper_##OPIVX##_h, \
@@ -1819,8 +1819,8 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \return false; \ } -GEN_OPIVI_NARROW_TRANS(vnsra_vi, 1, vnsra_vx) -GEN_OPIVI_NARROW_TRANS (vnsrl_vi,1 , vnsrl_vx) +GEN_OPIWI_NARROW_TRANS(vnsra_wi, 1, vnsra_wx) +GEN_OPIWI_NARROW_TRANS (vnsrl_wi,1 , vnsrl_wx)/* Vector Integer Comparison Instructions */ /*
target/riscv/vector_helper.c +12 -12
@@ -1521,18 +1521,18 @@ GEN_VEXT_SHIFT_VX(vsra_vx_w, int32_t, int32_t, H4, H4, DO_SRL, 0x1f, clearl)GEN_VEXT_SHIFT_VX (vsra_vx_d, int64_t, int64_t,H8 ,H8 ,DO_SRL ,0x3f , clearq) /* Vector Narrowing Integer Right Shift Instructions */ -GEN_VEXT_SHIFT_VV(vnsrl_vv_b, uint8_t, uint16_t, H1, H2, DO_SRL, 0xf, clearb) -GEN_VEXT_SHIFT_VV(vnsrl_vv_h, uint16_t, uint32_t, H2, H4, DO_SRL, 0x1f, clearh) -GEN_VEXT_SHIFT_VV(vnsrl_vv_w, uint32_t, uint64_t, H4, H8, DO_SRL, 0x3f, clearl) -GEN_VEXT_SHIFT_VV(vnsra_vv_b, uint8_t, int16_t, H1, H2, DO_SRL, 0xf, clearb) -GEN_VEXT_SHIFT_VV(vnsra_vv_h, uint16_t, int32_t, H2, H4, DO_SRL, 0x1f, clearh) -GEN_VEXT_SHIFT_VV(vnsra_vv_w, uint32_t, int64_t, H4, H8, DO_SRL, 0x3f, clearl) -GEN_VEXT_SHIFT_VX(vnsrl_vx_b, uint8_t, uint16_t, H1, H2, DO_SRL, 0xf, clearb) -GEN_VEXT_SHIFT_VX(vnsrl_vx_h, uint16_t, uint32_t, H2, H4, DO_SRL, 0x1f, clearh) -GEN_VEXT_SHIFT_VX(vnsrl_vx_w, uint32_t, uint64_t, H4, H8, DO_SRL, 0x3f, clearl) -GEN_VEXT_SHIFT_VX(vnsra_vx_b, int8_t, int16_t, H1, H2, DO_SRL, 0xf, clearb) -GEN_VEXT_SHIFT_VX(vnsra_vx_h, int16_t, int32_t, H2, H4, DO_SRL, 0x1f, clearh) -GEN_VEXT_SHIFT_VX (vnsra_vx_w, int32_t, int64_t,H4 ,H8 ,DO_SRL ,0x3f , clearl) +GEN_VEXT_SHIFT_VV(vnsrl_wv_b, uint8_t, uint16_t, H1, H2, DO_SRL, 0xf, clearb) +GEN_VEXT_SHIFT_VV(vnsrl_wv_h, uint16_t, uint32_t, H2, H4, DO_SRL, 0x1f, clearh) +GEN_VEXT_SHIFT_VV(vnsrl_wv_w, uint32_t, uint64_t, H4, H8, DO_SRL, 0x3f, clearl) +GEN_VEXT_SHIFT_VV(vnsra_wv_b, uint8_t, int16_t, H1, H2, DO_SRL, 0xf, clearb) +GEN_VEXT_SHIFT_VV(vnsra_wv_h, uint16_t, int32_t, H2, H4, DO_SRL, 0x1f, clearh) +GEN_VEXT_SHIFT_VV(vnsra_wv_w, uint32_t, int64_t, H4, H8, DO_SRL, 0x3f, clearl) +GEN_VEXT_SHIFT_VX(vnsrl_wx_b, uint8_t, uint16_t, H1, H2, DO_SRL, 0xf, clearb) +GEN_VEXT_SHIFT_VX(vnsrl_wx_h, uint16_t, uint32_t, H2, H4, DO_SRL, 0x1f, clearh) +GEN_VEXT_SHIFT_VX(vnsrl_wx_w, uint32_t, uint64_t, H4, H8, DO_SRL, 0x3f, clearl) +GEN_VEXT_SHIFT_VX(vnsra_wx_b, int8_t, int16_t, H1, H2, DO_SRL, 0xf, clearb) +GEN_VEXT_SHIFT_VX(vnsra_wx_h, int16_t, int32_t, H2, H4, DO_SRL, 0x1f, clearh) +GEN_VEXT_SHIFT_VX (vnsra_wx_w, int32_t, int64_t,H4 ,H8 ,DO_SRL ,0x3f , clearl) /* Vector Integer Comparison Instructions */#define DO_MSEQ (N ,M ) (N == M)
Signature · 1 line
2.17.1
RFC 36/65 target/riscv: rvv-0.9: widening integer multiply-add instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn32.decode | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/riscv/insn32.decode +3 -3
@@ -420,9 +420,9 @@ vwmaccu_vv 111100 . ..... ..... 010 ..... 1010111 @r_vm vwmaccu_vx 111100 . ..... ..... 110 ..... 1010111 @r_vm vwmacc_vv 111101 . ..... ..... 010 ..... 1010111 @r_vm vwmacc_vx 111101 . ..... ..... 110 ..... 1010111 @r_vm -vwmaccsu_vv 111110 . ..... ..... 010 ..... 1010111 @r_vm -vwmaccsu_vx 111110 . ..... ..... 110 ..... 1010111 @r_vm -vwmaccus_vx 111111 . ..... ..... 110 ..... 1010111 @r_vm +vwmaccsu_vv 111111 . ..... ..... 010 ..... 1010111 @r_vm +vwmaccsu_vx 111111 . ..... ..... 110 ..... 1010111 @r_vm +vwmaccus_vx 111110 . ..... ..... 110 ..... 1010111 @r_vm vmv_v_v 010111 1 00000 ..... 000 ..... 1010111 @r2 vmv_v_x 010111 1 00000 ..... 100 ..... 1010111 @r2 vmv_v_i 010111 1 00000 ..... 011 ..... 1010111 @r2
Signature · 1 line
2.17.1
RFC 37/65 target/riscv: rvv-0.9: quad-widening integer multiply-add instructions
In reply to [email protected]From: Frank Chang <[email protected]>
Add the following instructions:
* vqmaccu.vv
* vqmaccu.vx
* vqmacc.vv
* vqmacc.vx
* vqmaccsu.vv
* vqmaccsu.vx
* vqmaccus.vx
--- target/riscv/helper.h | 15 +++++ target/riscv/insn32.decode | 7 ++ target/riscv/insn_trans/trans_rvv.inc.c | 85 ++++++++++++++++++++++++- target/riscv/vector_helper.c | 40 ++++++++++++ 4 files changed, 146 insertions(+), 1 deletion(-)
target/riscv/helper.h +15 -0
@@ -622,6 +622,21 @@ DEF_HELPER_6(vwmaccus_vx_b, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vwmaccus_vx_h, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vwmaccus_vx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vqmaccu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vqmaccu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vqmacc_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vqmacc_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vqmaccsu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vqmaccsu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vqmaccu_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vqmaccu_vx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vqmacc_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vqmacc_vx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vqmaccsu_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vqmaccsu_vx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vqmaccus_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vqmaccus_vx_h, void, ptr, ptr, tl, ptr, env, i32) + DEF_HELPER_6(vmerge_vvm_b, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmerge_vvm_h, void, ptr, ptr, ptr, ptr, env, i32)DEF_HELPER_6 (vmerge_vvm_w, void, ptr, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +7 -0
@@ -423,6 +423,13 @@ vwmacc_vx 111101 . ..... ..... 110 ..... 1010111 @r_vm vwmaccsu_vv 111111 . ..... ..... 010 ..... 1010111 @r_vm vwmaccsu_vx 111111 . ..... ..... 110 ..... 1010111 @r_vm vwmaccus_vx 111110 . ..... ..... 110 ..... 1010111 @r_vm +vqmaccu_vv 111100 . ..... ..... 000 ..... 1010111 @r_vm +vqmaccu_vx 111100 . ..... ..... 100 ..... 1010111 @r_vm +vqmacc_vv 111101 . ..... ..... 000 ..... 1010111 @r_vm +vqmacc_vx 111101 . ..... ..... 100 ..... 1010111 @r_vm +vqmaccsu_vv 111111 . ..... ..... 000 ..... 1010111 @r_vm +vqmaccsu_vx 111111 . ..... ..... 100 ..... 1010111 @r_vm +vqmaccus_vx 111110 . ..... ..... 100 ..... 1010111 @r_vm vmv_v_v 010111 1 00000 ..... 000 ..... 1010111 @r2 vmv_v_x 010111 1 00000 ..... 100 ..... 1010111 @r2 vmv_v_i 010111 1 00000 ..... 011 ..... 1010111 @r2
target/riscv/insn_trans/trans_rvv.inc.c +84 -1
97 lines not on this page · raw message
target/riscv/vector_helper.c +40 -0
@@ -2127,6 +2127,46 @@ GEN_VEXT_VX(vwmaccus_vx_b, 1, 2, clearh) GEN_VEXT_VX(vwmaccus_vx_h, 2, 4, clearl)GEN_VEXT_VX (vwmaccus_vx_w,4 ,8 , clearq) +/* Vector Quad-Widening Integer Multiply-Add Instructions */ +#define QOP_UUU_B uint32_t, uint8_t, uint8_t, uint32_t, uint32_t +#define QOP_UUU_H uint64_t, uint16_t, uint16_t, uint64_t, uint64_t +#define QOP_SSS_B int32_t, int8_t, int8_t, int32_t, int32_t +#define QOP_SSS_H int64_t, int16_t, int16_t, int64_t, int64_t +#define QOP_SUS_B int32_t, uint8_t, int8_t, uint32_t, int32_t +#define QOP_SUS_H int64_t, uint16_t, int16_t, uint64_t, int64_t +#define QOP_SSU_B int32_t, int8_t, uint8_t, int32_t, uint32_t +#define QOP_SSU_H int64_t, int16_t, uint16_t, int64_t, uint64_t + +RVVCALL(OPIVV3, vqmaccu_vv_b, QOP_UUU_B, H4, H1, H1, DO_MACC) +RVVCALL(OPIVV3, vqmaccu_vv_h, QOP_UUU_H, H8, H2, H2, DO_MACC) +RVVCALL(OPIVV3, vqmacc_vv_b, QOP_SSS_B, H4, H1, H1, DO_MACC) +RVVCALL(OPIVV3, vqmacc_vv_h, QOP_SSS_H, H8, H2, H2, DO_MACC) +RVVCALL(OPIVV3, vqmaccsu_vv_b, QOP_SSU_B, H4, H1, H1, DO_MACC) +RVVCALL(OPIVV3, vqmaccsu_vv_h, QOP_SSU_H, H8, H2, H2, DO_MACC) +GEN_VEXT_VV(vqmaccu_vv_b, 1, 4, clearl) +GEN_VEXT_VV(vqmaccu_vv_h, 2, 8, clearq) +GEN_VEXT_VV(vqmacc_vv_b, 1, 4, clearl) +GEN_VEXT_VV(vqmacc_vv_h, 2, 8, clearq) +GEN_VEXT_VV(vqmaccsu_vv_b, 1, 4, clearl) +GEN_VEXT_VV(vqmaccsu_vv_h, 2, 8, clearq) + +RVVCALL(OPIVX3, vqmaccu_vx_b, QOP_UUU_B, H4, H1, DO_MACC) +RVVCALL(OPIVX3, vqmaccu_vx_h, QOP_UUU_H, H8, H2, DO_MACC) +RVVCALL(OPIVX3, vqmacc_vx_b, QOP_SSS_B, H4, H1, DO_MACC) +RVVCALL(OPIVX3, vqmacc_vx_h, QOP_SSS_H, H8, H2, DO_MACC) +RVVCALL(OPIVX3, vqmaccsu_vx_b, QOP_SSU_B, H4, H1, DO_MACC) +RVVCALL(OPIVX3, vqmaccsu_vx_h, QOP_SSU_H, H8, H2, DO_MACC) +RVVCALL(OPIVX3, vqmaccus_vx_b, QOP_SUS_B, H4, H1, DO_MACC) +RVVCALL(OPIVX3, vqmaccus_vx_h, QOP_SUS_H, H8, H2, DO_MACC) +GEN_VEXT_VX(vqmaccu_vx_b, 1, 4, clearl) +GEN_VEXT_VX(vqmaccu_vx_h, 2, 8, clearq) +GEN_VEXT_VX(vqmacc_vx_b, 1, 4, clearl) +GEN_VEXT_VX(vqmacc_vx_h, 2, 8, clearq) +GEN_VEXT_VX(vqmaccsu_vx_b, 1, 4, clearl) +GEN_VEXT_VX(vqmaccsu_vx_h, 2, 8, clearq) +GEN_VEXT_VX(vqmaccus_vx_b, 1, 4, clearl) +GEN_VEXT_VX (vqmaccus_vx_h,2 ,8 , clearq) + /* Vector Integer Merge and Move Instructions */#define GEN_VEXT_VMV_VV (NAME ,ETYPE ,H ,CLEAR_FN ) \ void HELPER(NAME)(void *vd, void *vs1, CPURISCVState *env, \
Signature · 1 line
2.17.1
RFC 38/65 target/riscv: rvv-0.9: integer merge and move instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn_trans/trans_rvv.inc.c | 179 ++++++++++++------------ 1 file changed, 90 insertions(+), 89 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +90 -89
@@ -2008,121 +2008,122 @@ GEN_OPIVX_QUAD_WIDEN_TRANS(vqmacc_vx)GEN_OPIVX_QUAD_WIDEN_TRANS (vqmaccsu_vx)GEN_OPIVX_QUAD_WIDEN_TRANS (vqmaccus_vx ) +/* Vector Integer Move Instructions */ static booltrans_vmv_v_v (DisasContext *s, arg_vmv_v_v *a) { -if (vext_check_isa_ill (s) && -vext_check_reg (s, a->rd, false) && -vext_check_reg (s, a->rs1, false)) { +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +/* vmv.v.v has rs2 = 0 and vm = 1 */ +VEXT_CHECK_SSS (s, a->rd, a->rs1,0 ,1 , true); -if (s->vl_eq_vlmax) { -tcg_gen_gvec_mov (s->sew,vreg_ofs (s, a->rd), -vreg_ofs (s, a->rs1), -MAXSZ (s),MAXSZ (s)); - }else { -uint32_t data =0 ; - data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); - data =FIELD_DP32 (data,VDATA ,VTA , s->vta); -static gen_helper_gvec_2_ptr *const fns[4 ] = { - gen_helper_vmv_v_v_b, gen_helper_vmv_v_v_h, - gen_helper_vmv_v_v_w, gen_helper_vmv_v_v_d, - }; -TCGLabel *over =gen_new_label (); -tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over); +if (s->vl_eq_vlmax) { +tcg_gen_gvec_mov (s->sew,vreg_ofs (s, a->rd), +vreg_ofs (s, a->rs1), +MAXSZ (s),MAXSZ (s)); + }else { +uint32_t data =0 ; + data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); + data =FIELD_DP32 (data,VDATA ,VTA , s->vta); +static gen_helper_gvec_2_ptr *const fns[4 ] = { + gen_helper_vmv_v_v_b, gen_helper_vmv_v_v_h, + gen_helper_vmv_v_v_w, gen_helper_vmv_v_v_d, + }; +TCGLabel *over =gen_new_label (); +tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over); -tcg_gen_gvec_2_ptr (vreg_ofs (s, a->rd),vreg_ofs (s, a->rs1), - cpu_env,0 , s->vlen /8 , data, fns[s->sew]); -gen_set_label (over); - } -return true; +tcg_gen_gvec_2_ptr (vreg_ofs (s, a->rd),vreg_ofs (s, a->rs1), + cpu_env,0 , s->vlen /8 , data, fns[s->sew]); +gen_set_label (over); } -return false; +return true; }typedef void gen_helper_vmv_vx (TCGv_ptr ,TCGv_i64 ,TCGv_env ,TCGv_i32 );static bool trans_vmv_v_x (DisasContext *s,arg_vmv_v_x *a) { -if (vext_check_isa_ill (s) && -vext_check_reg (s, a->rd, false)) { - -TCGv s1; -TCGLabel *over =gen_new_label (); -tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +/* vmv.v.x has rs2 = 0 and vm = 1 */ +VEXT_CHECK_SSS (s, a->rd, a->rs1,0 ,1 , false); - s1 =tcg_temp_new (); -gen_get_gpr (s1, a->rs1); +TCGv s1; +TCGLabel *over =gen_new_label (); +tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over); -if (s->vl_eq_vlmax) { -tcg_gen_gvec_dup_tl (s->sew,vreg_ofs (s, a->rd), -MAXSZ (s),MAXSZ (s), s1); - }else { -TCGv_i32 desc ; -TCGv_i64 s1_i64 =tcg_temp_new_i64 (); -TCGv_ptr dest =tcg_temp_new_ptr (); -uint32_t data =0 ; - data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); - data =FIELD_DP32 (data,VDATA ,VTA , s->vta); -static gen_helper_vmv_vx *const fns[4 ] = { - gen_helper_vmv_v_x_b, gen_helper_vmv_v_x_h, - gen_helper_vmv_v_x_w, gen_helper_vmv_v_x_d, - }; + s1 =tcg_temp_new (); +gen_get_gpr (s1, a->rs1); -tcg_gen_ext_tl_i64 (s1_i64, s1); - desc =tcg_const_i32 (simd_desc (0 , s->vlen /8 , data)); -tcg_gen_addi_ptr (dest, cpu_env,vreg_ofs (s, a->rd)); - fns[s->sew](dest, s1_i64, cpu_env, desc); +if (s->vl_eq_vlmax) { +tcg_gen_gvec_dup_tl (s->sew,vreg_ofs (s, a->rd), +MAXSZ (s),MAXSZ (s), s1); + }else { +TCGv_i32 desc ; +TCGv_i64 s1_i64 =tcg_temp_new_i64 (); +TCGv_ptr dest =tcg_temp_new_ptr (); +uint32_t data =0 ; + data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); + data =FIELD_DP32 (data,VDATA ,VTA , s->vta); +static gen_helper_vmv_vx *const fns[4 ] = { + gen_helper_vmv_v_x_b, gen_helper_vmv_v_x_h, + gen_helper_vmv_v_x_w, gen_helper_vmv_v_x_d, + }; -tcg_temp_free_ptr (dest); -tcg_temp_free_i32 (desc); -tcg_temp_free_i64 (s1_i64); - } +tcg_gen_ext_tl_i64 (s1_i64, s1); + desc =tcg_const_i32 (simd_desc (0 , s->vlen /8 , data)); +tcg_gen_addi_ptr (dest, cpu_env,vreg_ofs (s, a->rd)); + fns[s->sew](dest, s1_i64, cpu_env, desc); -tcg_temp_free (s1); -gen_set_label (over); -return true; +tcg_temp_free_ptr (dest); +tcg_temp_free_i32 (desc); +tcg_temp_free_i64 (s1_i64); } -return false; + +tcg_temp_free (s1); +gen_set_label (over); +return true; }static bool trans_vmv_v_i (DisasContext *s,arg_vmv_v_i *a) { -if (vext_check_isa_ill (s) && -vext_check_reg (s, a->rd, false)) { +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +/* vmv.v.i has rs2 = 0 and vm = 1 */ +VEXT_CHECK_SSS (s, a->rd, a->rs1,0 ,1 , false); -int64_t simm =sextract64 (a->rs1,0 ,5 ); -if (s->vl_eq_vlmax) { -tcg_gen_gvec_dup_imm (s->sew,vreg_ofs (s, a->rd), -MAXSZ (s),MAXSZ (s), simm); - }else { -TCGv_i32 desc; -TCGv_i64 s1; -TCGv_ptr dest; -uint32_t data =0 ; - data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); - data =FIELD_DP32 (data,VDATA ,VTA , s->vta); - data =FIELD_DP32 (data,VDATA ,VMA , s->vma); -static gen_helper_vmv_vx *const fns[4 ] = { - gen_helper_vmv_v_x_b, gen_helper_vmv_v_x_h, - gen_helper_vmv_v_x_w, gen_helper_vmv_v_x_d, - }; -TCGLabel *over =gen_new_label (); -tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over); +int64_t simm =sextract64 (a->rs1,0 ,5 ); +if (s->vl_eq_vlmax) { +tcg_gen_gvec_dup_imm (s->sew,vreg_ofs (s, a->rd), +MAXSZ (s),MAXSZ (s), simm); + }else { +TCGv_i32 desc; +TCGv_i64 s1; +TCGv_ptr dest; +uint32_t data =0 ; + data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); + data =FIELD_DP32 (data,VDATA ,VTA , s->vta); + data =FIELD_DP32 (data,VDATA ,VMA , s->vma); +static gen_helper_vmv_vx *const fns[4 ] = { + gen_helper_vmv_v_x_b, gen_helper_vmv_v_x_h, + gen_helper_vmv_v_x_w, gen_helper_vmv_v_x_d, + }; +TCGLabel *over =gen_new_label (); +tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over); - s1 =tcg_const_i64 (simm); - dest =tcg_temp_new_ptr (); - desc =tcg_const_i32 (simd_desc (0 , s->vlen /8 , data)); -tcg_gen_addi_ptr (dest, cpu_env,vreg_ofs (s, a->rd)); - fns[s->sew](dest, s1, cpu_env, desc); + s1 =tcg_const_i64 (simm); + dest =tcg_temp_new_ptr (); + desc =tcg_const_i32 (simd_desc (0 , s->vlen /8 , data)); +tcg_gen_addi_ptr (dest, cpu_env,vreg_ofs (s, a->rd)); + fns[s->sew](dest, s1, cpu_env, desc); -tcg_temp_free_ptr (dest); -tcg_temp_free_i32 (desc); -tcg_temp_free_i64 (s1); -gen_set_label (over); - } -return true; +tcg_temp_free_ptr (dest); +tcg_temp_free_i32 (desc); +tcg_temp_free_i64 (s1); +gen_set_label (over); } -return false; +return true; } +/* Vector Integer Merge Instructions */ GEN_OPIVV_TRANS(vmerge_vvm, opivv_vadc_check) GEN_OPIVX_TRANS(vmerge_vxm, opivx_vadc_check)GEN_OPIVI_TRANS (vmerge_vim,0 , vmerge_vxm, opivx_vadc_check)
Signature · 1 line
2.17.1
RFC 39/65 target/riscv: rvv-0.9: single-width saturating add and subtract instructions
In reply to [email protected]From: Frank Chang <[email protected]>
Sign-extend vsaddu.vi immediate value.
--- target/riscv/insn_trans/trans_rvv.inc.c | 2 +- target/riscv/vector_helper.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +1 -1
@@ -2141,7 +2141,7 @@ GEN_OPIVX_TRANS(vsaddu_vx, opivx_check) GEN_OPIVX_TRANS(vsadd_vx, opivx_check) GEN_OPIVX_TRANS(vssubu_vx, opivx_check) GEN_OPIVX_TRANS(vssub_vx, opivx_check) -GEN_OPIVI_TRANS(vsaddu_vi, 1, vsaddu_vx, opivx_check) +GEN_OPIVI_TRANS(vsaddu_vi, 0, vsaddu_vx, opivx_check)GEN_OPIVI_TRANS (vsadd_vi,0 , vsadd_vx, opivx_check)/* Vector Single-Width Averaging Add and Subtract */
target/riscv/vector_helper.c +1 -1
@@ -2324,7 +2324,7 @@ vext_vv_rm_2(void *vd, void *v0, void *vs1, void *vs2,break ; } -clearfn (vd, vta, vl, vl * dsz, vlmax * dsz); +clearfn (vd, vta, vl, vl * dsz, vlmax * dsz); }/* generate helpers for fixed point instructions with OPIVV format */
Signature · 1 line
2.17.1
RFC 40/65 target/riscv: rvv-0.9: integer comparison instructions
In reply to [email protected]From: Frank Chang <[email protected]>
Sign-extend vmselu.vi and vmsgtu.vi immediate values.
--- target/riscv/insn_trans/trans_rvv.inc.c | 4 +- target/riscv/vector_helper.c | 86 +++++++++++++------------ 2 files changed, 48 insertions(+), 42 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +2 -2
@@ -1889,9 +1889,9 @@ GEN_OPIVX_TRANS(vmsgt_vx, opivx_cmp_check) GEN_OPIVI_TRANS(vmseq_vi, 0, vmseq_vx, opivx_cmp_check) GEN_OPIVI_TRANS(vmsne_vi, 0, vmsne_vx, opivx_cmp_check) -GEN_OPIVI_TRANS(vmsleu_vi, 1, vmsleu_vx, opivx_cmp_check) +GEN_OPIVI_TRANS(vmsleu_vi, 0, vmsleu_vx, opivx_cmp_check) GEN_OPIVI_TRANS(vmsle_vi, 0, vmsle_vx, opivx_cmp_check) -GEN_OPIVI_TRANS(vmsgtu_vi, 1, vmsgtu_vx, opivx_cmp_check) +GEN_OPIVI_TRANS(vmsgtu_vi, 0, vmsgtu_vx, opivx_cmp_check)GEN_OPIVI_TRANS (vmsgt_vi,0 , vmsgt_vx, opivx_cmp_check)/* Vector Integer Min/Max Instructions */
target/riscv/vector_helper.c +46 -40
98 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 41/65 target/riscv: rvv-0.9: floating-point compare instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/vector_helper.c | 52 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 23 deletions(-)
target/riscv/vector_helper.c +29 -23
@@ -4148,27 +4148,30 @@ GEN_VEXT_VF(vfsgnjx_vf_w, 4, 4, clearl)GEN_VEXT_VF (vfsgnjx_vf_d,8 ,8 , clearq) /* Vector Floating-Point Compare Instructions */ -#define GEN_VEXT_CMP_VV_ENV (NAME ,ETYPE ,H ,DO_OP ) \ -void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ - CPURISCVState *env, uint32_t desc) \ -{ \ - uint32_t vm = vext_vm(desc); \ - uint32_t vl = env->vl; \ - uint32_t vlmax = vext_maxsz(desc) / sizeof(ETYPE); \ - uint32_t i; \ - \ - for (i = 0; i < vl; i++) { \ - ETYPE s1 = *((ETYPE *)vs1 + H(i)); \ - ETYPE s2 = *((ETYPE *)vs2 + H(i)); \ - if (!vm && !vext_elem_mask(v0, i)) { \ - continue; \ - } \ - vext_set_elem_mask(vd, i, \ - DO_OP(s2, s1, &env->fp_status)); \ - } \ - for (; i < vlmax; i++) { \ - vext_set_elem_mask(vd, i, 0); \ - } \ +#define GEN_VEXT_CMP_VV_ENV (NAME ,ETYPE ,H ,DO_OP ) \ +void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ + CPURISCVState *env, uint32_t desc) \ +{ \ + uint32_t vm = vext_vm(desc); \ + uint32_t vl = env->vl; \ + uint32_t vlmax = vext_max_elems(desc, sizeof(ETYPE), false); \ + uint32_t vta = vext_vta(desc); \ + uint32_t i; \ + \ + for (i = 0; i < vl; i++) { \ + ETYPE s1 = *((ETYPE *)vs1 + H(i)); \ + ETYPE s2 = *((ETYPE *)vs2 + H(i)); \ + if (!vm && !vext_elem_mask(v0, i)) { \ + continue; \ + } \ + vext_set_elem_mask(vd, i, \ + DO_OP(s2, s1, &env->fp_status)); \ + } \ + if (vta == 1) { \ + for (; i < vlmax; i++) { \ + vext_set_elem_mask(vd, i, 0); \ + } \ + } \ }static bool float16_eq_quiet (uint16_t a,uint16_t b,float_status *s)
@@ -4188,6 +4191,7 @@ void HELPER(NAME)(void *vd, void *v0, uint64_t s1, void *vs2, \uint32_t vm =vext_vm (desc); \uint32_t vl = env->vl; \uint32_t vlmax =vext_max_elems (desc,sizeof (ETYPE ), false); \ +uint32_t vta =vext_vta (desc); \uint32_t i; \ \for (i =0 ; i < vl; i++) { \
@@ -4198,8 +4202,10 @@ void HELPER(NAME)(void *vd, void *v0, uint64_t s1, void *vs2, \vext_set_elem_mask (vd, i, \DO_OP (s2, (ETYPE )s1, &env->fp_status)); \ } \ -for (; i < vlmax; i++) { \ -vext_set_elem_mask (vd, i,0 ); \ +if (vta ==1 ) { \ +for (; i < vlmax; i++) { \ +vext_set_elem_mask (vd, i,0 ); \ + } \ } \ }
Signature · 1 line
2.17.1
RFC 42/65 target/riscv: rvv-0.9: single-width integer reduction instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn_trans/trans_rvv.inc.c | 21 ++++---- target/riscv/vector_helper.c | 69 ++++++++++++------------- 2 files changed, 45 insertions(+), 45 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +12 -9
@@ -368,16 +368,16 @@ static uint32_t vreg_ofs(DisasContext *s, int reg) }while (0 )/* -* Check function for vector reduction instructions +* Check function for vector reduction instructions. * -* 2. In widen instructions and some other insturctions, like vslideup.vx, -* there is no need to check whether LMUL=1. +* TODO: Check vstart == 0 */ -static bool vext_check_overlap_mask(DisasContext *s, uint32_t vd, bool vm, -bool force) -{ -return (vm !=0 || vd !=0 ) || (!force && (s->lmul ==0 )); -} +#define VEXT_CHECK_REDUCTION (s, rs2, is_wide) do { \ + if (is_wide) { \ + require(s->sew < 3); \ + } \ + require_align(rs2, s->flmul) \ +} while (0)/* * Check function for vector integer extension instructions.
@@ -2731,7 +2731,10 @@ GEN_OPFV_NARROW_TRANS(vfncvt_f_f_v)/* Vector Single-Width Integer Reduction Instructions */ static bool reduction_check (DisasContext *s,arg_rmrr *a) { -return vext_check_isa_ill (s) &&vext_check_reg (s, a->rs2, false); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_REDUCTION (s, a->rs2, false); +return true; }GEN_OPIVV_TRANS (vredsum_vs, reduction_check)
target/riscv/vector_helper.c +33 -36
104 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 43/65 target/riscv: rvv-0.9: widening integer reduction instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn_trans/trans_rvv.inc.c | 12 ++++++++++-- target/riscv/vector_helper.c | 12 ++++++------ 2 files changed, 16 insertions(+), 8 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +10 -2
@@ -2747,8 +2747,16 @@ GEN_OPIVV_TRANS(vredor_vs, reduction_check)GEN_OPIVV_TRANS (vredxor_vs, reduction_check) /* Vector Widening Integer Reduction Instructions */ -GEN_OPIVV_WIDEN_TRANS(vwredsum_vs, reduction_check) -GEN_OPIVV_WIDEN_TRANS (vwredsumu_vs, reduction_check) +static bool reduction_widen_check (DisasContext *s,arg_rmrr *a) +{ +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_REDUCTION (s, a->rs2, true); +return true; +} + +GEN_OPIVV_WIDEN_TRANS(vwredsum_vs, reduction_widen_check) +GEN_OPIVV_WIDEN_TRANS (vwredsumu_vs, reduction_widen_check) /* Vector Single-Width Floating-Point Reduction Instructions */GEN_OPFVV_TRANS (vfredsum_vs, reduction_check)
target/riscv/vector_helper.c +6 -6
@@ -4627,14 +4627,14 @@ GEN_VEXT_RED(vredxor_vs_d, int64_t, int64_t, H8, H8, DO_XOR)/* Vector Widening Integer Reduction Instructions */ /* signed sum reduction into double-width accumulator */ -GEN_VEXT_RED(vwredsum_vs_b, int16_t, int8_t, H2, H1, DO_ADD, clearh) -GEN_VEXT_RED(vwredsum_vs_h, int32_t, int16_t, H4, H2, DO_ADD, clearl) -GEN_VEXT_RED (vwredsum_vs_w, int64_t, int32_t,H8 ,H4 ,DO_ADD , clearq) +GEN_VEXT_RED(vwredsum_vs_b, int16_t, int8_t, H2, H1, DO_ADD) +GEN_VEXT_RED(vwredsum_vs_h, int32_t, int16_t, H4, H2, DO_ADD) +GEN_VEXT_RED (vwredsum_vs_w, int64_t, int32_t,H8 ,H4 ,DO_ADD ) /* Unsigned sum reduction into double-width accumulator */ -GEN_VEXT_RED(vwredsumu_vs_b, uint16_t, uint8_t, H2, H1, DO_ADD, clearh) -GEN_VEXT_RED(vwredsumu_vs_h, uint32_t, uint16_t, H4, H2, DO_ADD, clearl) -GEN_VEXT_RED (vwredsumu_vs_w, uint64_t, uint32_t,H8 ,H4 ,DO_ADD , clearq) +GEN_VEXT_RED(vwredsumu_vs_b, uint16_t, uint8_t, H2, H1, DO_ADD) +GEN_VEXT_RED(vwredsumu_vs_h, uint32_t, uint16_t, H4, H2, DO_ADD) +GEN_VEXT_RED (vwredsumu_vs_w, uint64_t, uint32_t,H8 ,H4 ,DO_ADD ) /* Vector Single-Width Floating-Point Reduction Instructions */#define GEN_VEXT_FRED (NAME ,TD ,TS2 ,HD ,HS2 ,OP ,CLEAR_FN )\
Signature · 1 line
2.17.1
RFC 44/65 target/riscv: rvv-0.9: mask-register logical instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn_trans/trans_rvv.inc.c | 30 ++++++++++++------------- target/riscv/vector_helper.c | 7 ++++-- 2 files changed, 20 insertions(+), 17 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +15 -15
@@ -2774,22 +2774,22 @@ GEN_OPFVV_WIDEN_TRANS(vfwredsum_vs, reduction_check)#define GEN_MM_TRANS (NAME ) \ static bool trans_##NAME(DisasContext *s, arg_r *a) \ { \ - if (vext_check_isa_ill(s)) { \ - uint32_t data = 0; \ - gen_helper_gvec_4_ptr *fn = gen_helper_##NAME; \ - TCGLabel *over = gen_new_label(); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ + REQUIRE_RVV; \ + VEXT_CHECK_ISA_ILL(s); \ \ - data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ - data = FIELD_DP32(data, VDATA, VMA, s->vma); \ - 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, fn); \ - gen_set_label(over); \ - return true; \ - } \ - return false; \ + uint32_t data = 0; \ + gen_helper_gvec_4_ptr *fn = gen_helper_##NAME; \ + TCGLabel *over = gen_new_label(); \ + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ + \ + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ + data = FIELD_DP32(data, VDATA, VMA, s->vma); \ + 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, fn); \ + gen_set_label(over); \ + return true; \ }GEN_MM_TRANS (vmand_mm)
target/riscv/vector_helper.c +5 -2
@@ -4731,6 +4731,7 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, \ uint32_t desc) \ { \uint32_t vlmax =env_archcpu (env)->cfg.vlen; \ +uint32_t vta =vext_vta (desc); \uint32_t vl = env->vl; \uint32_t i; \int a, b; \
@@ -4740,8 +4741,10 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, \ b =vext_elem_mask (vs2, i); \vext_set_elem_mask (vd, i,OP (b, a)); \ } \ -for (; i < vlmax; i++) { \ -vext_set_elem_mask (vd, i,0 ); \ +if (vta ==1 ) { \ +for (; i < vlmax; i++) { \ +vext_set_elem_mask (vd, i,0 ); \ + } \ } \ }
Signature · 1 line
2.17.1
RFC 45/65 target/riscv: rvv-0.9: register gather instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn_trans/trans_rvv.inc.c | 33 +++++++++++++++++-------- 1 file changed, 23 insertions(+), 10 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +23 -10
@@ -2958,17 +2958,29 @@ static bool trans_vid_v(DisasContext *s, arg_vid_v *a)/* Integer Extract Instruction */ static void load_element (TCGv_i64 dest,TCGv_ptr base, -int ofs,int sew) +int ofs,int sew,bool sign) {switch (sew) {case MO_8 : -tcg_gen_ld8u_i64 (dest, base, ofs); +if (!sign) { +tcg_gen_ld8u_i64 (dest, base, ofs); + }else { +tcg_gen_ld8s_i64 (dest, base, ofs); + }break ;case MO_16 : -tcg_gen_ld16u_i64 (dest, base, ofs); +if (!sign) { +tcg_gen_ld16u_i64 (dest, base, ofs); + }else { +tcg_gen_ld16s_i64 (dest, base, ofs); + }break ;case MO_32 : -tcg_gen_ld32u_i64 (dest, base, ofs); +if (!sign) { +tcg_gen_ld32u_i64 (dest, base, ofs); + }else { +tcg_gen_ld32s_i64 (dest, base, ofs); + }break ;case MO_64 :tcg_gen_ld_i64 (dest, base, ofs);
@@ -3023,7 +3035,7 @@ static void vec_element_loadx(DisasContext *s, TCGv_i64 dest,/* Perform the load. */ load_element (dest, base, -vreg_ofs (s, vreg), s->sew); +vreg_ofs (s, vreg), s->sew, false);tcg_temp_free_ptr (base);tcg_temp_free_i32 (ofs);
@@ -3041,9 +3053,9 @@ static void vec_element_loadx(DisasContext *s, TCGv_i64 dest, }static void vec_element_loadi (DisasContext *s,TCGv_i64 dest, -int vreg,int idx) +int vreg,int idx,bool sign) { -load_element (dest, cpu_env,endian_ofs (s, vreg, idx), s->sew); +load_element (dest, cpu_env,endian_ofs (s, vreg, idx), s->sew, sign); }static bool trans_vext_x_v (DisasContext *s,arg_r *a)
@@ -3251,11 +3263,11 @@ static bool trans_vrgather_vx(DisasContext *s, arg_rmrr *a) }if (a->vm && s->vl_eq_vlmax) { -int vlmax = s->vlen; +int vlmax = s->vlen * s->flmul / (1 << (s->sew +3 ));TCGv_i64 dest =tcg_temp_new_i64 ();if (a->rs1 ==0 ) { -vec_element_loadi (s, dest, a->rs2,0 ); +vec_element_loadi (s, dest, a->rs2,0 , false); }else {vec_element_loadx (s, dest, a->rs2, cpu_gpr[a->rs1], vlmax); }
@@ -3282,7 +3294,8 @@ static bool trans_vrgather_vi(DisasContext *s, arg_rmrr *a) }if (a->vm && s->vl_eq_vlmax) { -if (a->rs1 >= s->vlen) { +int vlmax = s->vlen * s->flmul / (1 << (s->sew +3 )); +if (a->rs1 >= vlmax) {tcg_gen_gvec_dup_imm (SEW64 ,vreg_ofs (s, a->rd),MAXSZ (s),MAXSZ (s),0 ); }else {
Signature · 1 line
2.17.1
RFC 46/65 target/riscv: rvv-0.9: slide instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn_trans/trans_rvv.inc.c | 35 ++++++++--- target/riscv/vector_helper.c | 83 +++++++++++-------------- 2 files changed, 64 insertions(+), 54 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +27 -8
@@ -379,6 +379,18 @@ static uint32_t vreg_ofs(DisasContext *s, int reg) require_align(rs2, s->flmul) \ }while (0 ) +/* +* Check function for vector slide instructions. + */ +#define VEXT_CHECK_SLIDE (s, rd, rs2, vm, is_over) do { \ + require_align(rs2, s->flmul); \ + require_align(rd, s->flmul); \ + require_vm(vm, rd); \ + if (is_over) { \ + require(rd != rs2); \ + } \ +} while (0) +/* * Check function for vector integer extension instructions. */
@@ -3214,20 +3226,27 @@ static bool trans_vfmv_s_f(DisasContext *s, arg_vfmv_s_f *a)/* Vector Slide Instructions */ static bool slideup_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, false) && -vext_check_reg (s, a->rs2, false) && - (a->rd != a->rs2)); +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_SLIDE (s, a->rd, a->rs2, a->vm, true); +return true; } GEN_OPIVX_TRANS(vslideup_vx, slideup_check) GEN_OPIVX_TRANS(vslide1up_vx, slideup_check) GEN_OPIVI_TRANS(vslideup_vi, 1, vslideup_vx, slideup_check) -GEN_OPIVX_TRANS(vslidedown_vx, opivx_check) -GEN_OPIVX_TRANS(vslide1down_vx, opivx_check) -GEN_OPIVI_TRANS (vslidedown_vi,1 , vslidedown_vx, opivx_check) +static bool slidedown_check (DisasContext *s,arg_rmrr *a) +{ +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +VEXT_CHECK_SLIDE (s, a->rd, a->rs2, a->vm, false); +return true; +} + +GEN_OPIVX_TRANS(vslidedown_vx, slidedown_check) +GEN_OPIVX_TRANS(vslide1down_vx, slidedown_check) +GEN_OPIVI_TRANS (vslidedown_vi,1 , vslidedown_vx, slidedown_check) /* Vector Register Gather Instruction */static bool vrgather_vv_check (DisasContext *s,arg_rmrr *a)
target/riscv/vector_helper.c +37 -46
137 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 47/65 target/riscv: rvv-0.9: floating-point slide instructions
In reply to [email protected]From: Frank Chang <[email protected]>
Add the following instructions:
* vfslide1up.vf
* vfslide1down.vf
--- target/riscv/helper.h | 7 ++++ target/riscv/insn32.decode | 2 + target/riscv/insn_trans/trans_rvv.inc.c | 4 ++ target/riscv/vector_helper.c | 51 +++++++++++++++++++++++++ 4 files changed, 64 insertions(+)
target/riscv/helper.h +7 -0
@@ -1114,6 +1114,13 @@ DEF_HELPER_6(vslide1down_vx_h, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vslide1down_vx_w, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vslide1down_vx_d, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vfslide1up_vf_h, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfslide1up_vf_w, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfslide1up_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfslide1down_vf_h, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfslide1down_vf_w, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfslide1down_vf_d, void, ptr, ptr, i64, ptr, env, i32) + DEF_HELPER_6(vrgather_vv_b, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vrgather_vv_h, void, ptr, ptr, ptr, ptr, env, i32)DEF_HELPER_6 (vrgather_vv_w, void, ptr, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +2 -0
@@ -530,6 +530,8 @@ vfsgnjn_vv 001001 . ..... ..... 001 ..... 1010111 @r_vm vfsgnjn_vf 001001 . ..... ..... 101 ..... 1010111 @r_vm vfsgnjx_vv 001010 . ..... ..... 001 ..... 1010111 @r_vm vfsgnjx_vf 001010 . ..... ..... 101 ..... 1010111 @r_vm +vfslide1up_vf 001110 . ..... ..... 101 ..... 1010111 @r_vm +vfslide1down_vf 001111 . ..... ..... 101 ..... 1010111 @r_vm vmfeq_vv 011000 . ..... ..... 001 ..... 1010111 @r_vm vmfeq_vf 011000 . ..... ..... 101 ..... 1010111 @r_vm vmfne_vv 011100 . ..... ..... 001 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvv.inc.c +4 -0
@@ -3248,6 +3248,10 @@ GEN_OPIVX_TRANS(vslidedown_vx, slidedown_check) GEN_OPIVX_TRANS(vslide1down_vx, slidedown_check)GEN_OPIVI_TRANS (vslidedown_vi,1 , vslidedown_vx, slidedown_check) +/* Vector Floating-Point Slide Instructions */ +GEN_OPFVF_TRANS(vfslide1up_vf, slideup_check) +GEN_OPFVF_TRANS (vfslide1down_vf, slidedown_check) + /* Vector Register Gather Instruction */static bool vrgather_vv_check (DisasContext *s,arg_rmrr *a) {
target/riscv/vector_helper.c +51 -0
57 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 48/65 target/riscv: rvv-0.9: narrowing fixed-point clip instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 24 ++++++------ target/riscv/insn32.decode | 12 +++--- target/riscv/insn_trans/trans_rvv.inc.c | 12 +++--- target/riscv/vector_helper.c | 52 ++++++++++++------------- 4 files changed, 50 insertions(+), 50 deletions(-)
target/riscv/helper.h +12 -12
@@ -768,18 +768,18 @@ DEF_HELPER_6(vssra_vx_h, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vssra_vx_w, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vssra_vx_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vnclip_vv_b, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vnclip_vv_h, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vnclip_vv_w, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vnclipu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vnclipu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vnclipu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vnclipu_vx_b, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vnclipu_vx_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vnclipu_vx_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vnclip_vx_b, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vnclip_vx_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vnclip_vx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vnclip_wv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vnclip_wv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vnclip_wv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vnclipu_wv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vnclipu_wv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vnclipu_wv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vnclipu_wx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vnclipu_wx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vnclipu_wx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vnclip_wx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vnclip_wx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vnclip_wx_w, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vfadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32)DEF_HELPER_6 (vfadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +6 -6
@@ -469,12 +469,12 @@ vssrl_vi 101010 . ..... ..... 011 ..... 1010111 @r_vm vssra_vv 101011 . ..... ..... 000 ..... 1010111 @r_vm vssra_vx 101011 . ..... ..... 100 ..... 1010111 @r_vm vssra_vi 101011 . ..... ..... 011 ..... 1010111 @r_vm -vnclipu_vv 101110 . ..... ..... 000 ..... 1010111 @r_vm -vnclipu_vx 101110 . ..... ..... 100 ..... 1010111 @r_vm -vnclipu_vi 101110 . ..... ..... 011 ..... 1010111 @r_vm -vnclip_vv 101111 . ..... ..... 000 ..... 1010111 @r_vm -vnclip_vx 101111 . ..... ..... 100 ..... 1010111 @r_vm -vnclip_vi 101111 . ..... ..... 011 ..... 1010111 @r_vm +vnclipu_wv 101110 . ..... ..... 000 ..... 1010111 @r_vm +vnclipu_wx 101110 . ..... ..... 100 ..... 1010111 @r_vm +vnclipu_wi 101110 . ..... ..... 011 ..... 1010111 @r_vm +vnclip_wv 101111 . ..... ..... 000 ..... 1010111 @r_vm +vnclip_wx 101111 . ..... ..... 100 ..... 1010111 @r_vm +vnclip_wi 101111 . ..... ..... 011 ..... 1010111 @r_vm vfadd_vv 000000 . ..... ..... 001 ..... 1010111 @r_vm vfadd_vf 000000 . ..... ..... 101 ..... 1010111 @r_vm vfsub_vv 000010 . ..... ..... 001 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvv.inc.c +6 -6
@@ -2188,12 +2188,12 @@ GEN_OPIVI_TRANS(vssrl_vi, 1, vssrl_vx, opivx_check)GEN_OPIVI_TRANS (vssra_vi,0 , vssra_vx, opivx_check) /* Vector Narrowing Fixed-Point Clip Instructions */ -GEN_OPIVV_NARROW_TRANS(vnclipu_vv) -GEN_OPIVV_NARROW_TRANS(vnclip_vv) -GEN_OPIVX_NARROW_TRANS(vnclipu_vx) -GEN_OPIVX_NARROW_TRANS(vnclip_vx) -GEN_OPIVI_NARROW_TRANS(vnclipu_vi, 1, vnclipu_vx) -GEN_OPIVI_NARROW_TRANS(vnclip_vi, 1, vnclip_vx) +GEN_OPIWV_NARROW_TRANS(vnclipu_wv) +GEN_OPIWV_NARROW_TRANS(vnclip_wv) +GEN_OPIWX_NARROW_TRANS(vnclipu_wx) +GEN_OPIWX_NARROW_TRANS(vnclip_wx) +GEN_OPIWI_NARROW_TRANS(vnclipu_wi, 1, vnclipu_wx) +GEN_OPIWI_NARROW_TRANS(vnclip_wi, 1, vnclip_wx)/* *** Vector Float Point Arithmetic Instructions
target/riscv/vector_helper.c +26 -26
71 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 49/65 target/riscv: rvv-0.9: floating-point move instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn_trans/trans_rvv.inc.c | 57 ++++++++++++------------- 1 file changed, 28 insertions(+), 29 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +28 -29
@@ -2600,37 +2600,36 @@ GEN_OPFVF_TRANS(vfmerge_vfm, opfvf_check)static bool trans_vfmv_v_f (DisasContext *s,arg_vfmv_v_f *a) { -if (vext_check_isa_ill (s) && -vext_check_reg (s, a->rd, false) && - (s->sew !=0 )) { +REQUIRE_RVV ; +VEXT_CHECK_ISA_ILL (s); +require_align (a->rd, s->flmul); +require (s->sew !=0 ); -if (s->vl_eq_vlmax) { -tcg_gen_gvec_dup_i64 (s->sew,vreg_ofs (s, a->rd), -MAXSZ (s),MAXSZ (s), cpu_fpr[a->rs1]); - }else { -TCGv_ptr dest; -TCGv_i32 desc; -uint32_t data =FIELD_DP32 (0 ,VDATA ,LMUL , s->lmul); -static gen_helper_vmv_vx *const fns[3 ] = { - gen_helper_vmv_v_x_h, - gen_helper_vmv_v_x_w, - gen_helper_vmv_v_x_d, - }; -TCGLabel *over =gen_new_label (); -tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over); - - dest =tcg_temp_new_ptr (); - desc =tcg_const_i32 (simd_desc (0 , s->vlen /8 , data)); -tcg_gen_addi_ptr (dest, cpu_env,vreg_ofs (s, a->rd)); - fns[s->sew -1 ](dest, cpu_fpr[a->rs1], cpu_env, desc); - -tcg_temp_free_ptr (dest); -tcg_temp_free_i32 (desc); -gen_set_label (over); - } -return true; +if (s->vl_eq_vlmax) { +tcg_gen_gvec_dup_i64 (s->sew,vreg_ofs (s, a->rd), +MAXSZ (s),MAXSZ (s), cpu_fpr[a->rs1]); + }else { +TCGv_ptr dest; +TCGv_i32 desc; +uint32_t data =FIELD_DP32 (0 ,VDATA ,LMUL , s->lmul); +static gen_helper_vmv_vx *const fns[3 ] = { + gen_helper_vmv_v_x_h, + gen_helper_vmv_v_x_w, + gen_helper_vmv_v_x_d, + }; +TCGLabel *over =gen_new_label (); +tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over); + + dest =tcg_temp_new_ptr (); + desc =tcg_const_i32 (simd_desc (0 , s->vlen /8 , data)); +tcg_gen_addi_ptr (dest, cpu_env,vreg_ofs (s, a->rd)); + fns[s->sew -1 ](dest, cpu_fpr[a->rs1], cpu_env, desc); + +tcg_temp_free_ptr (dest); +tcg_temp_free_i32 (desc); +gen_set_label (over); } -return false; +return true; }/* Single-Width Floating-Point/Integer Type-Convert Instructions */
Signature · 1 line
2.17.1
RFC 50/65 target/riscv: rvv-0.9: floating-point/integer type-convert instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 6 ++++ target/riscv/insn32.decode | 11 ++++--- target/riscv/insn_trans/trans_rvv.inc.c | 2 ++ target/riscv/vector_helper.c | 38 +++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 4 deletions(-)
target/riscv/helper.h +6 -0
@@ -994,6 +994,12 @@ DEF_HELPER_5(vfcvt_f_xu_v_d, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfcvt_f_x_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfcvt_f_x_v_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfcvt_f_x_v_d, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfcvt_rtz_xu_f_v_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfcvt_rtz_xu_f_v_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfcvt_rtz_xu_f_v_d, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfcvt_rtz_x_f_v_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfcvt_rtz_x_f_v_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfcvt_rtz_x_f_v_d, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_xu_f_v_h, void, ptr, ptr, ptr, env, i32)DEF_HELPER_5 (vfwcvt_xu_f_v_w, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +7 -4
@@ -547,10 +547,13 @@ vmford_vf 011010 . ..... ..... 101 ..... 1010111 @r_vm vfclass_v 010011 . ..... 10000 001 ..... 1010111 @r2_vm vfmerge_vfm 010111 0 ..... ..... 101 ..... 1010111 @r_vm_0 vfmv_v_f 010111 1 00000 ..... 101 ..... 1010111 @r2 -vfcvt_xu_f_v 100010 . ..... 00000 001 ..... 1010111 @r2_vm -vfcvt_x_f_v 100010 . ..... 00001 001 ..... 1010111 @r2_vm -vfcvt_f_xu_v 100010 . ..... 00010 001 ..... 1010111 @r2_vm -vfcvt_f_x_v 100010 . ..... 00011 001 ..... 1010111 @r2_vm + +vfcvt_xu_f_v 010010 . ..... 00000 001 ..... 1010111 @r2_vm +vfcvt_x_f_v 010010 . ..... 00001 001 ..... 1010111 @r2_vm +vfcvt_f_xu_v 010010 . ..... 00010 001 ..... 1010111 @r2_vm +vfcvt_f_x_v 010010 . ..... 00011 001 ..... 1010111 @r2_vm +vfcvt_rtz_xu_f_v 010010 . ..... 00110 001 ..... 1010111 @r2_vm +vfcvt_rtz_x_f_v 010010 . ..... 00111 001 ..... 1010111 @r2_vm vfwcvt_xu_f_v 100010 . ..... 01000 001 ..... 1010111 @r2_vm vfwcvt_x_f_v 100010 . ..... 01001 001 ..... 1010111 @r2_vm vfwcvt_f_xu_v 100010 . ..... 01010 001 ..... 1010111 @r2_vm
target/riscv/insn_trans/trans_rvv.inc.c +2 -0
@@ -2637,6 +2637,8 @@ GEN_OPFV_TRANS(vfcvt_xu_f_v, opfv_check) GEN_OPFV_TRANS(vfcvt_x_f_v, opfv_check) GEN_OPFV_TRANS(vfcvt_f_xu_v, opfv_check) GEN_OPFV_TRANS(vfcvt_f_x_v, opfv_check) +GEN_OPFV_TRANS(vfcvt_rtz_xu_f_v, opfv_check) +GEN_OPFV_TRANS (vfcvt_rtz_x_f_v, opfv_check)/* Widening Floating-Point/Integer Type-Convert Instructions */
target/riscv/vector_helper.c +38 -0
@@ -4473,6 +4473,44 @@ GEN_VEXT_V_ENV(vfcvt_f_x_v_h, 2, 2, clearh) GEN_VEXT_V_ENV(vfcvt_f_x_v_w, 4, 4, clearl) GEN_VEXT_V_ENV(vfcvt_f_x_v_d, 8, 8, clearq) +#define FCVT_RTZ_F_V (STYPE ,DTYPE ) \ +static DTYPE##_t STYPE##_to_##DTYPE##_rtz(STYPE a, float_status * s) \ +{ \ + signed char frm = s->float_rounding_mode; \ + s->float_rounding_mode = float_round_to_zero; \ + DTYPE##_t result = STYPE##_to_##DTYPE(a, s); \ + s->float_rounding_mode = frm; \ + return result; \ +} + +/* +* vfcvt.rtz.xu.f.v vd, vs2, vm +* Convert float to unsigned integer, truncating. +*/ +FCVT_RTZ_F_V(float16, uint16) +FCVT_RTZ_F_V(float32, uint32) +FCVT_RTZ_F_V(float64, uint64) +RVVCALL(OPFVV1, vfcvt_rtz_xu_f_v_h, OP_UU_H, H2, H2, float16_to_uint16_rtz) +RVVCALL(OPFVV1, vfcvt_rtz_xu_f_v_w, OP_UU_W, H4, H4, float32_to_uint32_rtz) +RVVCALL(OPFVV1, vfcvt_rtz_xu_f_v_d, OP_UU_D, H8, H8, float64_to_uint64_rtz) +GEN_VEXT_V_ENV(vfcvt_rtz_xu_f_v_h, 2, 2, clearh) +GEN_VEXT_V_ENV(vfcvt_rtz_xu_f_v_w, 4, 4, clearl) +GEN_VEXT_V_ENV (vfcvt_rtz_xu_f_v_d,8 ,8 , clearq) + +/* +* vfcvt.rtz.x.f.v vd, vs2, vm +* Convert float to signed integer, truncating. + */ +FCVT_RTZ_F_V(float16, int16) +FCVT_RTZ_F_V(float32, int32) +FCVT_RTZ_F_V(float64, int64) +RVVCALL(OPFVV1, vfcvt_rtz_x_f_v_h, OP_UU_H, H2, H2, float16_to_int16_rtz) +RVVCALL(OPFVV1, vfcvt_rtz_x_f_v_w, OP_UU_W, H4, H4, float32_to_int32_rtz) +RVVCALL(OPFVV1, vfcvt_rtz_x_f_v_d, OP_UU_D, H8, H8, float64_to_int64_rtz) +GEN_VEXT_V_ENV(vfcvt_rtz_x_f_v_h, 2, 2, clearh) +GEN_VEXT_V_ENV(vfcvt_rtz_x_f_v_w, 4, 4, clearl) +GEN_VEXT_V_ENV (vfcvt_rtz_x_f_v_d,8 ,8 , clearq) +/* Widening Floating-Point/Integer Type-Convert Instructions */ /* (TD, T2, TX2) */#define WOP_UU_H uint32_t, uint16_t, uint16_t
Signature · 1 line
2.17.1
RFC 51/65 target/riscv: rvv-0.9: single-width floating-point reduction
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 3 + target/riscv/insn32.decode | 3 +- target/riscv/insn_trans/trans_rvv.inc.c | 1 + target/riscv/vector_helper.c | 144 +++++++++++++++++++----- 4 files changed, 120 insertions(+), 31 deletions(-)
target/riscv/helper.h +3 -0
@@ -1066,6 +1066,9 @@ DEF_HELPER_6(vwredsum_vs_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfredsum_vs_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfredsum_vs_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfredsum_vs_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfredosum_vs_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfredosum_vs_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfredosum_vs_d, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfredmax_vs_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfredmax_vs_w, void, ptr, ptr, ptr, ptr, env, i32)DEF_HELPER_6 (vfredmax_vs_d, void, ptr, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +2 -1
@@ -575,7 +575,8 @@ vredmax_vs 000111 . ..... ..... 010 ..... 1010111 @r_vm vwredsumu_vs 110000 . ..... ..... 000 ..... 1010111 @r_vm vwredsum_vs 110001 . ..... ..... 000 ..... 1010111 @r_vm # Vector ordered and unordered reduction sum -vfredsum_vs 0000-1 . ..... ..... 001 ..... 1010111 @r_vm +vfredsum_vs 000001 . ..... ..... 001 ..... 1010111 @r_vm +vfredosum_vs 000011 . ..... ..... 001 ..... 1010111 @r_vm vfredmin_vs 000101 . ..... ..... 001 ..... 1010111 @r_vm vfredmax_vs 000111 . ..... ..... 001 ..... 1010111 @r_vm # Vector widening ordered and unordered float reduction sum
target/riscv/insn_trans/trans_rvv.inc.c +1 -0
@@ -2773,6 +2773,7 @@ GEN_OPIVV_WIDEN_TRANS(vwredsumu_vs, reduction_widen_check)/* Vector Single-Width Floating-Point Reduction Instructions */ GEN_OPFVV_TRANS(vfredsum_vs, reduction_check) +GEN_OPFVV_TRANS(vfredosum_vs, reduction_check) GEN_OPFVV_TRANS(vfredmax_vs, reduction_check)GEN_OPFVV_TRANS (vfredmin_vs, reduction_check)
target/riscv/vector_helper.c +114 -30
157 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 52/65 target/riscv: rvv-0.9: widening floating-point reduction instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 2 + target/riscv/insn32.decode | 3 +- target/riscv/insn_trans/trans_rvv.inc.c | 3 +- target/riscv/vector_helper.c | 67 ++++++++++++++++++++++++- 4 files changed, 71 insertions(+), 4 deletions(-)
target/riscv/helper.h +2 -0
@@ -1078,6 +1078,8 @@ DEF_HELPER_6(vfredmin_vs_d, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwredsum_vs_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwredsum_vs_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfwredosum_vs_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfwredosum_vs_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmand_mm, void, ptr, ptr, ptr, ptr, env, i32)DEF_HELPER_6 (vmnand_mm, void, ptr, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +2 -1
@@ -580,7 +580,8 @@ vfredosum_vs 000011 . ..... ..... 001 ..... 1010111 @r_vm vfredmin_vs 000101 . ..... ..... 001 ..... 1010111 @r_vm vfredmax_vs 000111 . ..... ..... 001 ..... 1010111 @r_vm # Vector widening ordered and unordered float reduction sum -vfwredsum_vs 1100-1 . ..... ..... 001 ..... 1010111 @r_vm +vfwredsum_vs 110001 . ..... ..... 001 ..... 1010111 @r_vm +vfwredosum_vs 110011 . ..... ..... 001 ..... 1010111 @r_vm vmand_mm 011001 - ..... ..... 010 ..... 1010111 @r vmnand_mm 011101 - ..... ..... 010 ..... 1010111 @r vmandnot_mm 011000 - ..... ..... 010 ..... 1010111 @r
target/riscv/insn_trans/trans_rvv.inc.c +2 -1
@@ -2778,7 +2778,8 @@ GEN_OPFVV_TRANS(vfredmax_vs, reduction_check)GEN_OPFVV_TRANS (vfredmin_vs, reduction_check) /* Vector Widening Floating-Point Reduction Instructions */ -GEN_OPFVV_WIDEN_TRANS (vfwredsum_vs, reduction_check) +GEN_OPFVV_WIDEN_TRANS(vfwredsum_vs, reduction_widen_check) +GEN_OPFVV_WIDEN_TRANS (vfwredosum_vs, reduction_widen_check)/* *** Vector Mask Operations
target/riscv/vector_helper.c +65 -2
103 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 53/65 target/riscv: rvv-0.9: single-width scaling shift instructions
In reply to [email protected]From: Frank Chang <[email protected]>
Zero-extend vssra.vi immediate value.
--- target/riscv/insn_trans/trans_rvv.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/insn_trans/trans_rvv.inc.c +1 -1
@@ -2185,7 +2185,7 @@ GEN_OPIVV_TRANS(vssra_vv, opivv_check) GEN_OPIVX_TRANS(vssrl_vx, opivx_check) GEN_OPIVX_TRANS(vssra_vx, opivx_check) GEN_OPIVI_TRANS(vssrl_vi, 1, vssrl_vx, opivx_check) -GEN_OPIVI_TRANS (vssra_vi,0 , vssra_vx, opivx_check) +GEN_OPIVI_TRANS (vssra_vi,1 , vssra_vx, opivx_check) /* Vector Narrowing Fixed-Point Clip Instructions */GEN_OPIWV_NARROW_TRANS (vnclipu_wv)
Signature · 1 line
2.17.1
RFC 54/65 target/riscv: rvv-0.9: remove widening saturating scaled multiply-add
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 22 --- target/riscv/insn32.decode | 7 - target/riscv/insn_trans/trans_rvv.inc.c | 9 -- target/riscv/vector_helper.c | 205 ------------------------ 4 files changed, 243 deletions(-)
target/riscv/helper.h +0 -22
@@ -729,28 +729,6 @@ DEF_HELPER_6(vsmul_vx_h, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vsmul_vx_w, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vsmul_vx_d, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vwsmaccu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vwsmaccu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vwsmaccu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vwsmacc_vv_b, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vwsmacc_vv_h, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vwsmacc_vv_w, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vwsmaccsu_vv_b, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vwsmaccsu_vv_h, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vwsmaccsu_vv_w, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vwsmaccu_vx_b, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vwsmaccu_vx_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vwsmaccu_vx_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vwsmacc_vx_b, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vwsmacc_vx_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vwsmacc_vx_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vwsmaccsu_vx_b, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vwsmaccsu_vx_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vwsmaccsu_vx_w, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vwsmaccus_vx_b, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vwsmaccus_vx_h, void, ptr, ptr, tl, ptr, env, i32) -DEF_HELPER_6(vwsmaccus_vx_w, void, ptr, ptr, tl, ptr, env, i32) - DEF_HELPER_6(vssrl_vv_b, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vssrl_vv_h, void, ptr, ptr, ptr, ptr, env, i32)DEF_HELPER_6 (vssrl_vv_w, void, ptr, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +0 -7
@@ -456,13 +456,6 @@ vasubu_vv 001010 . ..... ..... 010 ..... 1010111 @r_vm vasubu_vx 001010 . ..... ..... 110 ..... 1010111 @r_vm vsmul_vv 100111 . ..... ..... 000 ..... 1010111 @r_vm vsmul_vx 100111 . ..... ..... 100 ..... 1010111 @r_vm -vwsmaccu_vv 111100 . ..... ..... 000 ..... 1010111 @r_vm -vwsmaccu_vx 111100 . ..... ..... 100 ..... 1010111 @r_vm -vwsmacc_vv 111101 . ..... ..... 000 ..... 1010111 @r_vm -vwsmacc_vx 111101 . ..... ..... 100 ..... 1010111 @r_vm -vwsmaccsu_vv 111110 . ..... ..... 000 ..... 1010111 @r_vm -vwsmaccsu_vx 111110 . ..... ..... 100 ..... 1010111 @r_vm -vwsmaccus_vx 111111 . ..... ..... 100 ..... 1010111 @r_vm vssrl_vv 101010 . ..... ..... 000 ..... 1010111 @r_vm vssrl_vx 101010 . ..... ..... 100 ..... 1010111 @r_vm vssrl_vi 101010 . ..... ..... 011 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvv.inc.c +0 -9
@@ -2170,15 +2170,6 @@ GEN_OPIVX_TRANS(vasubu_vx, opivx_check) GEN_OPIVV_TRANS(vsmul_vv, opivv_check)GEN_OPIVX_TRANS (vsmul_vx, opivx_check) -/* Vector Widening Saturating Scaled Multiply-Add */ -GEN_OPIVV_WIDEN_TRANS(vwsmaccu_vv, opivv_widen_check) -GEN_OPIVV_WIDEN_TRANS(vwsmacc_vv, opivv_widen_check) -GEN_OPIVV_WIDEN_TRANS(vwsmaccsu_vv, opivv_widen_check) -GEN_OPIVX_WIDEN_TRANS(vwsmaccu_vx) -GEN_OPIVX_WIDEN_TRANS(vwsmacc_vx) -GEN_OPIVX_WIDEN_TRANS(vwsmaccsu_vx) -GEN_OPIVX_WIDEN_TRANS(vwsmaccus_vx) - /* Vector Single-Width Scaling Shift Instructions */ GEN_OPIVV_TRANS(vssrl_vv, opivv_check)GEN_OPIVV_TRANS (vssra_vv, opivv_check)
target/riscv/vector_helper.c +0 -205
211 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 55/65 target/riscv: rvv-0.9: remove vmford.vv and vmford.vf
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 6 ------ target/riscv/insn32.decode | 2 -- target/riscv/insn_trans/trans_rvv.inc.c | 2 -- target/riscv/vector_helper.c | 13 ------------- 4 files changed, 23 deletions(-)
target/riscv/helper.h +0 -6
@@ -945,12 +945,6 @@ DEF_HELPER_6(vmfgt_vf_d, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfge_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfge_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfge_vf_d, void, ptr, ptr, i64, ptr, env, i32) -DEF_HELPER_6(vmford_vv_h, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vmford_vv_w, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vmford_vv_d, void, ptr, ptr, ptr, ptr, env, i32) -DEF_HELPER_6(vmford_vf_h, void, ptr, ptr, i64, ptr, env, i32) -DEF_HELPER_6(vmford_vf_w, void, ptr, ptr, i64, ptr, env, i32) -DEF_HELPER_6(vmford_vf_d, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_5(vfclass_v_h, void, ptr, ptr, ptr, env, i32)DEF_HELPER_5 (vfclass_v_w, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +0 -2
@@ -535,8 +535,6 @@ vmfle_vv 011001 . ..... ..... 001 ..... 1010111 @r_vm vmfle_vf 011001 . ..... ..... 101 ..... 1010111 @r_vm vmfgt_vf 011101 . ..... ..... 101 ..... 1010111 @r_vm vmfge_vf 011111 . ..... ..... 101 ..... 1010111 @r_vm -vmford_vv 011010 . ..... ..... 001 ..... 1010111 @r_vm -vmford_vf 011010 . ..... ..... 101 ..... 1010111 @r_vm vfclass_v 010011 . ..... 10000 001 ..... 1010111 @r2_vm vfmerge_vfm 010111 0 ..... ..... 101 ..... 1010111 @r_vm_0 vfmv_v_f 010111 1 00000 ..... 101 ..... 1010111 @r2
target/riscv/insn_trans/trans_rvv.inc.c +0 -2
@@ -2564,7 +2564,6 @@ GEN_OPFVV_TRANS(vmfeq_vv, opfvv_cmp_check) GEN_OPFVV_TRANS(vmfne_vv, opfvv_cmp_check) GEN_OPFVV_TRANS(vmflt_vv, opfvv_cmp_check) GEN_OPFVV_TRANS(vmfle_vv, opfvv_cmp_check) -GEN_OPFVV_TRANS(vmford_vv, opfvv_cmp_check)static bool opfvf_cmp_check (DisasContext *s,arg_rmrr *a) {
@@ -2581,7 +2580,6 @@ GEN_OPFVF_TRANS(vmflt_vf, opfvf_cmp_check) GEN_OPFVF_TRANS(vmfle_vf, opfvf_cmp_check) GEN_OPFVF_TRANS(vmfgt_vf, opfvf_cmp_check)GEN_OPFVF_TRANS (vmfge_vf, opfvf_cmp_check) -GEN_OPFVF_TRANS (vmford_vf, opfvf_cmp_check) /* Vector Floating-Point Classify Instruction */GEN_OPFV_TRANS (vfclass_v, opfv_check)
target/riscv/vector_helper.c +0 -13
@@ -4107,19 +4107,6 @@ GEN_VEXT_CMP_VF(vmfge_vf_h, uint16_t, H2, vmfge16) GEN_VEXT_CMP_VF(vmfge_vf_w, uint32_t, H4, vmfge32)GEN_VEXT_CMP_VF (vmfge_vf_d, uint64_t,H8 , vmfge64) -static bool float16_unordered_quiet (uint16_t a,uint16_t b,float_status *s) -{ -FloatRelation compare =float16_compare_quiet (a, b, s); -return compare == float_relation_unordered; -} - -GEN_VEXT_CMP_VV_ENV(vmford_vv_h, uint16_t, H2, !float16_unordered_quiet) -GEN_VEXT_CMP_VV_ENV(vmford_vv_w, uint32_t, H4, !float32_unordered_quiet) -GEN_VEXT_CMP_VV_ENV(vmford_vv_d, uint64_t, H8, !float64_unordered_quiet) -GEN_VEXT_CMP_VF(vmford_vf_h, uint16_t, H2, !float16_unordered_quiet) -GEN_VEXT_CMP_VF(vmford_vf_w, uint32_t, H4, !float32_unordered_quiet) -GEN_VEXT_CMP_VF (vmford_vf_d, uint64_t,H8 , !float64_unordered_quiet) - /* Vector Floating-Point Classify Instruction */#define OPIVV1 (NAME ,TD ,T2 ,TX2 ,HD ,HS2 ,OP ) \ static void do_##NAME(void *vd, void *vs2, int i) \
Signature · 1 line
2.17.1
RFC 56/65 target/riscv: rvv-0.9: remove integer extract instruction
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn32.decode | 1 - target/riscv/insn_trans/trans_rvv.inc.c | 23 ----------------------- 2 files changed, 24 deletions(-)
target/riscv/insn32.decode +0 -1
@@ -590,7 +590,6 @@ viota_m 010100 . ..... 10000 010 ..... 1010111 @r2_vm vid_v 010100 . 00000 10001 010 ..... 1010111 @r1_vm vmv_x_s 010000 1 ..... 00000 010 ..... 1010111 @r2rd vmv_s_x 010000 1 00000 ..... 110 ..... 1010111 @r2 -vext_x_v 001100 1 ..... ..... 010 ..... 1010111 @r vfmv_f_s 010000 1 ..... 00000 001 ..... 1010111 @r2rd vfmv_s_f 010000 1 00000 ..... 101 ..... 1010111 @r2 vslideup_vx 001110 . ..... ..... 100 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvv.inc.c +0 -23
@@ -2959,8 +2959,6 @@ static bool trans_vid_v(DisasContext *s, arg_vid_v *a)*** Vector Permutation Instructions */ -/* Integer Extract Instruction */ -static void load_element (TCGv_i64 dest,TCGv_ptr base,int ofs,int sew,bool sign) {
@@ -3062,27 +3060,6 @@ static void vec_element_loadi(DisasContext *s, TCGv_i64 dest,load_element (dest, cpu_env,endian_ofs (s, vreg, idx), s->sew, sign); } -static bool trans_vext_x_v (DisasContext *s,arg_r *a) -{ -TCGv_i64 tmp =tcg_temp_new_i64 (); -TCGv dest =tcg_temp_new (); - -if (a->rs1 ==0 ) { -/* Special case vmv.x.s rd, vs2. */ -vec_element_loadi (s, tmp, a->rs2,0 ); - }else { -/* This instruction ignores LMUL and vector register groups */ -int vlmax = s->vlen >> (3 + s->sew); -vec_element_loadx (s, tmp, a->rs2, cpu_gpr[a->rs1], vlmax); - } -tcg_gen_trunc_i64_tl (dest, tmp); -gen_set_gpr (a->rd, dest); - -tcg_temp_free (dest); -tcg_temp_free_i64 (tmp); -return true; -} -/* Integer Scalar Move Instruction */ static void store_element(TCGv_i64 val, TCGv_ptr base,
Signature · 1 line
2.17.1
RFC 57/65 target/riscv: rvv-0.9: floating-point min/max instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/vector_helper.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
target/riscv/vector_helper.c +12 -12
@@ -3831,28 +3831,28 @@ GEN_VEXT_V_ENV(vfsqrt_v_w, 4, 4, clearl)GEN_VEXT_V_ENV (vfsqrt_v_d,8 ,8 , clearq) /* Vector Floating-Point MIN/MAX Instructions */ -RVVCALL(OPFVV2, vfmin_vv_h, OP_UUU_H, H2, H2, H2, float16_minnum) -RVVCALL(OPFVV2, vfmin_vv_w, OP_UUU_W, H4, H4, H4, float32_minnum) -RVVCALL(OPFVV2, vfmin_vv_d, OP_UUU_D, H8, H8, H8, float64_minnum) +RVVCALL(OPFVV2, vfmin_vv_h, OP_UUU_H, H2, H2, H2, float16_minnum_noprop) +RVVCALL(OPFVV2, vfmin_vv_w, OP_UUU_W, H4, H4, H4, float32_minnum_noprop) +RVVCALL(OPFVV2, vfmin_vv_d, OP_UUU_D, H8, H8, H8, float64_minnum_noprop) GEN_VEXT_VV_ENV(vfmin_vv_h, 2, 2, clearh) GEN_VEXT_VV_ENV(vfmin_vv_w, 4, 4, clearl) GEN_VEXT_VV_ENV(vfmin_vv_d, 8, 8, clearq) -RVVCALL(OPFVF2, vfmin_vf_h, OP_UUU_H, H2, H2, float16_minnum) -RVVCALL(OPFVF2, vfmin_vf_w, OP_UUU_W, H4, H4, float32_minnum) -RVVCALL(OPFVF2, vfmin_vf_d, OP_UUU_D, H8, H8, float64_minnum) +RVVCALL(OPFVF2, vfmin_vf_h, OP_UUU_H, H2, H2, float16_minnum_noprop) +RVVCALL(OPFVF2, vfmin_vf_w, OP_UUU_W, H4, H4, float32_minnum_noprop) +RVVCALL(OPFVF2, vfmin_vf_d, OP_UUU_D, H8, H8, float64_minnum_noprop) GEN_VEXT_VF(vfmin_vf_h, 2, 2, clearh) GEN_VEXT_VF(vfmin_vf_w, 4, 4, clearl) GEN_VEXT_VF(vfmin_vf_d, 8, 8, clearq) -RVVCALL(OPFVV2, vfmax_vv_h, OP_UUU_H, H2, H2, H2, float16_maxnum) -RVVCALL(OPFVV2, vfmax_vv_w, OP_UUU_W, H4, H4, H4, float32_maxnum) -RVVCALL(OPFVV2, vfmax_vv_d, OP_UUU_D, H8, H8, H8, float64_maxnum) +RVVCALL(OPFVV2, vfmax_vv_h, OP_UUU_H, H2, H2, H2, float16_maxnum_noprop) +RVVCALL(OPFVV2, vfmax_vv_w, OP_UUU_W, H4, H4, H4, float32_maxnum_noprop) +RVVCALL(OPFVV2, vfmax_vv_d, OP_UUU_D, H8, H8, H8, float64_maxnum_noprop) GEN_VEXT_VV_ENV(vfmax_vv_h, 2, 2, clearh) GEN_VEXT_VV_ENV(vfmax_vv_w, 4, 4, clearl) GEN_VEXT_VV_ENV(vfmax_vv_d, 8, 8, clearq) -RVVCALL(OPFVF2, vfmax_vf_h, OP_UUU_H, H2, H2, float16_maxnum) -RVVCALL(OPFVF2, vfmax_vf_w, OP_UUU_W, H4, H4, float32_maxnum) -RVVCALL(OPFVF2, vfmax_vf_d, OP_UUU_D, H8, H8, float64_maxnum) +RVVCALL(OPFVF2, vfmax_vf_h, OP_UUU_H, H2, H2, float16_maxnum_noprop) +RVVCALL(OPFVF2, vfmax_vf_w, OP_UUU_W, H4, H4, float32_maxnum_noprop) +RVVCALL(OPFVF2, vfmax_vf_d, OP_UUU_D, H8, H8, float64_maxnum_noprop) GEN_VEXT_VF(vfmax_vf_h, 2, 2, clearh) GEN_VEXT_VF(vfmax_vf_w, 4, 4, clearl)GEN_VEXT_VF (vfmax_vf_d,8 ,8 , clearq)
Signature · 1 line
2.17.1
Re: [RFC 57/65] target/riscv: rvv-0.9: floating-point min/max instructions
Quoted 12 lines · [email protected] writes:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>--- target/riscv/vector_helper.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)target/riscv/vector_helper.c +0
-0
target/riscv/vector_helper.c GEN_VEXT_V_ENV(vfsqrt_v_w, 4, 4, clearl) · line 3837
Quoted 10 lines
target/riscv/vector_helper.c +3
-3@@ -3831,28 +3831,28 @@ GEN_VEXT_V_ENV(vfsqrt_v_w, 4, 4, clearl)GEN_VEXT_V_ENV (vfsqrt_v_d,8 ,8 , clearq) /* Vector Floating-Point MIN/MAX Instructions */ -RVVCALL(OPFVV2, vfmin_vv_h, OP_UUU_H, H2, H2, H2, float16_minnum) -RVVCALL(OPFVV2, vfmin_vv_w, OP_UUU_W, H4, H4, H4, float32_minnum) -RVVCALL (OPFVV2 , vfmin_vv_d,OP_UUU_D ,H8 ,H8 ,H8 , float64_minnum) +RVVCALL(OPFVV2, vfmin_vv_h, OP_UUU_H, H2, H2, H2, float16_minnum_noprop) +RVVCALL(OPFVV2, vfmin_vv_w, OP_UUU_W, H4, H4, H4, float32_minnum_noprop) +RVVCALL (OPFVV2 , vfmin_vv_d,OP_UUU_D ,H8 ,H8 ,H8 , float64_minnum_noprop)
This patch breaks bisection because you don't introduce this into softfloat until later. You should always ensure each step can build and run - practically this means the softfloat changes should be at the beginning of the series.
Quoted 31 lines
target/riscv/vector_helper.c +9
-9GEN_VEXT_VV_ENV(vfmin_vv_h, 2, 2, clearh) GEN_VEXT_VV_ENV(vfmin_vv_w, 4, 4, clearl) GEN_VEXT_VV_ENV(vfmin_vv_d, 8, 8, clearq) -RVVCALL(OPFVF2, vfmin_vf_h, OP_UUU_H, H2, H2, float16_minnum) -RVVCALL(OPFVF2, vfmin_vf_w, OP_UUU_W, H4, H4, float32_minnum) -RVVCALL(OPFVF2, vfmin_vf_d, OP_UUU_D, H8, H8, float64_minnum) +RVVCALL(OPFVF2, vfmin_vf_h, OP_UUU_H, H2, H2, float16_minnum_noprop) +RVVCALL(OPFVF2, vfmin_vf_w, OP_UUU_W, H4, H4, float32_minnum_noprop) +RVVCALL(OPFVF2, vfmin_vf_d, OP_UUU_D, H8, H8, float64_minnum_noprop) GEN_VEXT_VF(vfmin_vf_h, 2, 2, clearh) GEN_VEXT_VF(vfmin_vf_w, 4, 4, clearl) GEN_VEXT_VF(vfmin_vf_d, 8, 8, clearq) -RVVCALL(OPFVV2, vfmax_vv_h, OP_UUU_H, H2, H2, H2, float16_maxnum) -RVVCALL(OPFVV2, vfmax_vv_w, OP_UUU_W, H4, H4, H4, float32_maxnum) -RVVCALL(OPFVV2, vfmax_vv_d, OP_UUU_D, H8, H8, H8, float64_maxnum) +RVVCALL(OPFVV2, vfmax_vv_h, OP_UUU_H, H2, H2, H2, float16_maxnum_noprop) +RVVCALL(OPFVV2, vfmax_vv_w, OP_UUU_W, H4, H4, H4, float32_maxnum_noprop) +RVVCALL(OPFVV2, vfmax_vv_d, OP_UUU_D, H8, H8, H8, float64_maxnum_noprop) GEN_VEXT_VV_ENV(vfmax_vv_h, 2, 2, clearh) GEN_VEXT_VV_ENV(vfmax_vv_w, 4, 4, clearl) GEN_VEXT_VV_ENV(vfmax_vv_d, 8, 8, clearq) -RVVCALL(OPFVF2, vfmax_vf_h, OP_UUU_H, H2, H2, float16_maxnum) -RVVCALL(OPFVF2, vfmax_vf_w, OP_UUU_W, H4, H4, float32_maxnum) -RVVCALL(OPFVF2, vfmax_vf_d, OP_UUU_D, H8, H8, float64_maxnum) +RVVCALL(OPFVF2, vfmax_vf_h, OP_UUU_H, H2, H2, float16_maxnum_noprop) +RVVCALL(OPFVF2, vfmax_vf_w, OP_UUU_W, H4, H4, float32_maxnum_noprop) +RVVCALL(OPFVF2, vfmax_vf_d, OP_UUU_D, H8, H8, float64_maxnum_noprop) GEN_VEXT_VF(vfmax_vf_h, 2, 2, clearh)GEN_VEXT_VF (vfmax_vf_w,4 ,4 , clearl)
GEN_VEXT_VF(vfmax_vf_d, 8, 8, clearq)
Signature · 1 line
Alex Bennée
RFC 58/65 target/riscv: rvv-0.9: widening floating-point/integer type-convert
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 6 ++++ target/riscv/insn32.decode | 13 +++++--- target/riscv/insn_trans/trans_rvv.inc.c | 44 +++++++++++++++++++++++-- target/riscv/vector_helper.c | 29 +++++++++++++++- 4 files changed, 84 insertions(+), 8 deletions(-)
target/riscv/helper.h +6 -0
@@ -977,12 +977,18 @@ DEF_HELPER_5(vfwcvt_xu_f_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_xu_f_v_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_x_f_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_x_f_v_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfwcvt_f_xu_v_b, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_xu_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_xu_v_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfwcvt_f_x_v_b, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_x_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_x_v_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_f_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_f_v_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfwcvt_rtz_xu_f_v_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfwcvt_rtz_xu_f_v_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfwcvt_rtz_x_f_v_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfwcvt_rtz_x_f_v_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfncvt_xu_f_v_h, void, ptr, ptr, ptr, env, i32)DEF_HELPER_5 (vfncvt_xu_f_v_w, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +8 -5
@@ -545,11 +545,14 @@ vfcvt_f_xu_v 010010 . ..... 00010 001 ..... 1010111 @r2_vm vfcvt_f_x_v 010010 . ..... 00011 001 ..... 1010111 @r2_vm vfcvt_rtz_xu_f_v 010010 . ..... 00110 001 ..... 1010111 @r2_vm vfcvt_rtz_x_f_v 010010 . ..... 00111 001 ..... 1010111 @r2_vm -vfwcvt_xu_f_v 100010 . ..... 01000 001 ..... 1010111 @r2_vm -vfwcvt_x_f_v 100010 . ..... 01001 001 ..... 1010111 @r2_vm -vfwcvt_f_xu_v 100010 . ..... 01010 001 ..... 1010111 @r2_vm -vfwcvt_f_x_v 100010 . ..... 01011 001 ..... 1010111 @r2_vm -vfwcvt_f_f_v 100010 . ..... 01100 001 ..... 1010111 @r2_vm + +vfwcvt_xu_f_v 010010 . ..... 01000 001 ..... 1010111 @r2_vm +vfwcvt_x_f_v 010010 . ..... 01001 001 ..... 1010111 @r2_vm +vfwcvt_f_xu_v 010010 . ..... 01010 001 ..... 1010111 @r2_vm +vfwcvt_f_x_v 010010 . ..... 01011 001 ..... 1010111 @r2_vm +vfwcvt_f_f_v 010010 . ..... 01100 001 ..... 1010111 @r2_vm +vfwcvt_rtz_xu_f_v 010010 . ..... 01110 001 ..... 1010111 @r2_vm +vfwcvt_rtz_x_f_v 010010 . ..... 01111 001 ..... 1010111 @r2_vm vfncvt_xu_f_v 100010 . ..... 10000 001 ..... 1010111 @r2_vm vfncvt_x_f_v 100010 . ..... 10001 001 ..... 1010111 @r2_vm vfncvt_f_xu_v 100010 . ..... 10010 001 ..... 1010111 @r2_vm
target/riscv/insn_trans/trans_rvv.inc.c +42 -2
51 lines not on this page · raw message
target/riscv/vector_helper.c +28 -1
@@ -4295,6 +4295,7 @@ GEN_VEXT_V_ENV(vfcvt_rtz_x_f_v_d, 8, 8, clearq)/* Widening Floating-Point/Integer Type-Convert Instructions */ /* (TD, T2, TX2) */ +#define WOP_UU_B uint16_t, uint8_t, uint8_t#define WOP_UU_H uint32_t, uint16_t, uint16_t#define WOP_UU_W uint64_t, uint32_t, uint32_t/* vfwcvt.xu.f.v vd, vs2, vm # Convert float to double-width unsigned integer.*/
@@ -4310,19 +4311,45 @@ GEN_VEXT_V_ENV(vfwcvt_x_f_v_h, 2, 4, clearl)GEN_VEXT_V_ENV (vfwcvt_x_f_v_w,4 ,8 , clearq) /* vfwcvt.f.xu.v vd, vs2, vm # Convert unsigned integer to double-width float */ +RVVCALL(OPFVV1, vfwcvt_f_xu_v_b, WOP_UU_B, H2, H1, uint8_to_float16) RVVCALL(OPFVV1, vfwcvt_f_xu_v_h, WOP_UU_H, H4, H2, uint16_to_float32) RVVCALL(OPFVV1, vfwcvt_f_xu_v_w, WOP_UU_W, H8, H4, uint32_to_float64) +GEN_VEXT_V_ENV(vfwcvt_f_xu_v_b, 1, 2, clearh) GEN_VEXT_V_ENV(vfwcvt_f_xu_v_h, 2, 4, clearl)GEN_VEXT_V_ENV (vfwcvt_f_xu_v_w,4 ,8 , clearq) /* vfwcvt.f.x.v vd, vs2, vm # Convert integer to double-width float. */ +RVVCALL(OPFVV1, vfwcvt_f_x_v_b, WOP_UU_B, H2, H1, int8_to_float16) RVVCALL(OPFVV1, vfwcvt_f_x_v_h, WOP_UU_H, H4, H2, int16_to_float32) RVVCALL(OPFVV1, vfwcvt_f_x_v_w, WOP_UU_W, H8, H4, int32_to_float64) +GEN_VEXT_V_ENV(vfwcvt_f_x_v_b, 1, 2, clearh) GEN_VEXT_V_ENV(vfwcvt_f_x_v_h, 2, 4, clearl)GEN_VEXT_V_ENV (vfwcvt_f_x_v_w,4 ,8 , clearq)/* -* vfwcvt.f.f.v vd, vs2, vm # +* vfwcvt.rtz.xu.f.v vd, vs2, vm +* Convert float to double-width unsigned integer, truncating + */ +FCVT_RTZ_F_V(float16, uint32) +FCVT_RTZ_F_V(float32, uint64) +RVVCALL(OPFVV1, vfwcvt_rtz_xu_f_v_h, WOP_UU_H, H4, H2, float16_to_uint32_rtz) +RVVCALL(OPFVV1, vfwcvt_rtz_xu_f_v_w, WOP_UU_W, H8, H4, float32_to_uint64_rtz) +GEN_VEXT_V_ENV(vfwcvt_rtz_xu_f_v_h, 2, 4, clearl) +GEN_VEXT_V_ENV (vfwcvt_rtz_xu_f_v_w,4 ,8 , clearq) + +/* +* vfwcvt.rtz.x.f.v vd, vs2, vm +* Convert float to double-width signed integer, truncating. + */ +FCVT_RTZ_F_V(float16, int32) +FCVT_RTZ_F_V(float32, int64) +RVVCALL(OPFVV1, vfwcvt_rtz_x_f_v_h, WOP_UU_H, H4, H2, float16_to_int32_rtz) +RVVCALL(OPFVV1, vfwcvt_rtz_x_f_v_w, WOP_UU_W, H8, H4, float32_to_int64_rtz) +GEN_VEXT_V_ENV(vfwcvt_rtz_x_f_v_h, 2, 4, clearl) +GEN_VEXT_V_ENV (vfwcvt_rtz_x_f_v_w,4 ,8 , clearq) + +/* +* vfwcvt.f.f.v vd, vs2, vm * Convert single-width float to double-width float. */static uint32_t vfwcvtffv16 (uint16_t a,float_status *s)
Signature · 1 line
2.17.1
RFC 59/65 target/riscv: rvv-0.9: narrowing floating-point/integer type-convert
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/helper.h | 30 +++++--- target/riscv/insn32.decode | 15 ++-- target/riscv/insn_trans/trans_rvv.inc.c | 50 +++++++++++-- target/riscv/vector_helper.c | 99 ++++++++++++++++++++----- 4 files changed, 154 insertions(+), 40 deletions(-)
target/riscv/helper.h +20 -10
@@ -990,16 +990,26 @@ DEF_HELPER_5(vfwcvt_rtz_xu_f_v_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_rtz_x_f_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_rtz_x_f_v_w, void, ptr, ptr, ptr, env, i32) -DEF_HELPER_5(vfncvt_xu_f_v_h, void, ptr, ptr, ptr, env, i32) -DEF_HELPER_5(vfncvt_xu_f_v_w, void, ptr, ptr, ptr, env, i32) -DEF_HELPER_5(vfncvt_x_f_v_h, void, ptr, ptr, ptr, env, i32) -DEF_HELPER_5(vfncvt_x_f_v_w, void, ptr, ptr, ptr, env, i32) -DEF_HELPER_5(vfncvt_f_xu_v_h, void, ptr, ptr, ptr, env, i32) -DEF_HELPER_5(vfncvt_f_xu_v_w, void, ptr, ptr, ptr, env, i32) -DEF_HELPER_5(vfncvt_f_x_v_h, void, ptr, ptr, ptr, env, i32) -DEF_HELPER_5(vfncvt_f_x_v_w, void, ptr, ptr, ptr, env, i32) -DEF_HELPER_5(vfncvt_f_f_v_h, void, ptr, ptr, ptr, env, i32) -DEF_HELPER_5(vfncvt_f_f_v_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_xu_f_w_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_xu_f_w_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_xu_f_w_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_x_f_w_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_x_f_w_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_x_f_w_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_f_xu_w_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_f_xu_w_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_f_x_w_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_f_x_w_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_f_f_w_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_f_f_w_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_rod_f_f_w_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_rod_f_f_w_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_rtz_xu_f_w_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_rtz_xu_f_w_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_rtz_xu_f_w_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_rtz_x_f_w_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_rtz_x_f_w_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_rtz_x_f_w_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vredsum_vs_b, void, ptr, ptr, ptr, ptr, env, i32)DEF_HELPER_6 (vredsum_vs_h, void, ptr, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +10 -5
@@ -553,11 +553,16 @@ vfwcvt_f_x_v 010010 . ..... 01011 001 ..... 1010111 @r2_vm vfwcvt_f_f_v 010010 . ..... 01100 001 ..... 1010111 @r2_vm vfwcvt_rtz_xu_f_v 010010 . ..... 01110 001 ..... 1010111 @r2_vm vfwcvt_rtz_x_f_v 010010 . ..... 01111 001 ..... 1010111 @r2_vm -vfncvt_xu_f_v 100010 . ..... 10000 001 ..... 1010111 @r2_vm -vfncvt_x_f_v 100010 . ..... 10001 001 ..... 1010111 @r2_vm -vfncvt_f_xu_v 100010 . ..... 10010 001 ..... 1010111 @r2_vm -vfncvt_f_x_v 100010 . ..... 10011 001 ..... 1010111 @r2_vm -vfncvt_f_f_v 100010 . ..... 10100 001 ..... 1010111 @r2_vm + +vfncvt_xu_f_w 010010 . ..... 10000 001 ..... 1010111 @r2_vm +vfncvt_x_f_w 010010 . ..... 10001 001 ..... 1010111 @r2_vm +vfncvt_f_xu_w 010010 . ..... 10010 001 ..... 1010111 @r2_vm +vfncvt_f_x_w 010010 . ..... 10011 001 ..... 1010111 @r2_vm +vfncvt_f_f_w 010010 . ..... 10100 001 ..... 1010111 @r2_vm +vfncvt_rod_f_f_w 010010 . ..... 10101 001 ..... 1010111 @r2_vm +vfncvt_rtz_xu_f_w 010010 . ..... 10110 001 ..... 1010111 @r2_vm +vfncvt_rtz_x_f_w 010010 . ..... 10111 001 ..... 1010111 @r2_vm + vredsum_vs 000000 . ..... ..... 010 ..... 1010111 @r_vm vredand_vs 000001 . ..... ..... 010 ..... 1010111 @r_vm vredor_vs 000010 . ..... ..... 010 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvv.inc.c +45 -5
56 lines not on this page · raw message
target/riscv/vector_helper.c +79 -20
126 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC 60/65 softfloat: add fp16 and uint8/int8 interconvert functions
In reply to [email protected]From: Frank Chang <[email protected]>
--- fpu/softfloat.c | 34 ++++++++++++++++++++++++++++++++++ include/fpu/softfloat.h | 8 ++++++++ 2 files changed, 42 insertions(+)
fpu/softfloat.c +34 -0
@@ -2109,6 +2109,13 @@ static int64_t round_to_int_and_pack(FloatParts in, FloatRoundMode rmode, } } +int8_t float16_to_int8_scalbn (float16 a,FloatRoundMode rmode,int scale, +float_status *s) +{ +return round_to_int_and_pack (float16_unpack_canonical (a, s), + rmode, scale,INT8_MIN ,INT8_MAX , s); +} +int16_t float16_to_int16_scalbn (float16 a,FloatRoundMode rmode,int scale,float_status *s) {
@@ -2172,6 +2179,11 @@ int64_t float64_to_int64_scalbn(float64 a, FloatRoundMode rmode, int scale, rmode, scale, INT64_MIN, INT64_MAX, s); } +int8_t float16_to_int8 (float16 a,float_status *s) +{ +return float16_to_int8_scalbn (a, s->float_rounding_mode,0 , s); +} +int16_t float16_to_int16 (float16 a,float_status *s) {return float16_to_int16_scalbn (a, s->float_rounding_mode,0 , s);
@@ -2322,6 +2334,13 @@ static uint64_t round_to_uint_and_pack(FloatParts in, FloatRoundMode rmode, } } +uint8_t float16_to_uint8_scalbn (float16 a,FloatRoundMode rmode,int scale, +float_status *s) +{ +return round_to_uint_and_pack (float16_unpack_canonical (a, s), + rmode, scale,UINT8_MAX , s); +} +uint16_t float16_to_uint16_scalbn (float16 a,FloatRoundMode rmode,int scale,float_status *s) {
@@ -2385,6 +2404,11 @@ uint64_t float64_to_uint64_scalbn(float64 a, FloatRoundMode rmode, int scale, rmode, scale, UINT64_MAX, s); } +uint8_t float16_to_uint8 (float16 a,float_status *s) +{ +return float16_to_uint8_scalbn (a, s->float_rounding_mode,0 , s); +} +uint16_t float16_to_uint16 (float16 a,float_status *s) {return float16_to_uint16_scalbn (a, s->float_rounding_mode,0 , s);
@@ -2539,6 +2563,11 @@ float16 int16_to_float16(int16_t a, float_status *status)return int64_to_float16_scalbn (a,0 , status); } +float16 int8_to_float16 (int8_t a,float_status *status) +{ +return int64_to_float16_scalbn (a,0 , status); +} +float32 int64_to_float32_scalbn (int64_t a,int scale,float_status *status) {FloatParts pa =int_to_float (a, scale, status);
@@ -2664,6 +2693,11 @@ float16 uint16_to_float16(uint16_t a, float_status *status)return uint64_to_float16_scalbn (a,0 , status); } +float16 uint8_to_float16 (uint8_t a,float_status *status) +{ +return uint64_to_float16_scalbn (a,0 , status); +} +float32 uint64_to_float32_scalbn (uint64_t a,int scale,float_status *status) {FloatParts pa =uint_to_float (a, scale, status);
include/fpu/softfloat.h +8 -0
@@ -136,9 +136,11 @@ float16 uint16_to_float16_scalbn(uint16_t a, int, float_status *status);float16 uint32_to_float16_scalbn (uint32_t a,int ,float_status *status);float16 uint64_to_float16_scalbn (uint64_t a,int ,float_status *status); +float16 int8_to_float16 (int8_t a,float_status *status);float16 int16_to_float16 (int16_t a,float_status *status);float16 int32_to_float16 (int32_t a,float_status *status);float16 int64_to_float16 (int64_t a,float_status *status); +float16 uint8_to_float16 (uint8_t a,float_status *status);float16 uint16_to_float16 (uint16_t a,float_status *status);float16 uint32_to_float16 (uint32_t a,float_status *status);float16 uint64_to_float16 (uint64_t a,float_status *status);
@@ -187,10 +189,13 @@ float32 float16_to_float32(float16, bool ieee, float_status *status);float16 float64_to_float16 (float64 a,bool ieee,float_status *status);float64 float16_to_float64 (float16 a,bool ieee,float_status *status); +int8_t float16_to_int8_scalbn (float16 ,FloatRoundMode ,int , +float_status *status);int16_t float16_to_int16_scalbn (float16 ,FloatRoundMode ,int ,float_status *);int32_t float16_to_int32_scalbn (float16 ,FloatRoundMode ,int ,float_status *);int64_t float16_to_int64_scalbn (float16 ,FloatRoundMode ,int ,float_status *); +int8_t float16_to_int8 (float16 ,float_status *status);int16_t float16_to_int16 (float16 ,float_status *status);int32_t float16_to_int32 (float16 ,float_status *status);int64_t float16_to_int64 (float16 ,float_status *status);
@@ -199,6 +204,8 @@ int16_t float16_to_int16_round_to_zero(float16, float_status *status);int32_t float16_to_int32_round_to_zero (float16 ,float_status *status);int64_t float16_to_int64_round_to_zero (float16 ,float_status *status); +uint8_t float16_to_uint8_scalbn (float16 a,FloatRoundMode , +int ,float_status *status);uint16_t float16_to_uint16_scalbn (float16 a,FloatRoundMode ,int ,float_status *status); uint32_t float16_to_uint32_scalbn(float16 a, FloatRoundMode,
@@ -206,6 +213,7 @@ uint32_t float16_to_uint32_scalbn(float16 a, FloatRoundMode,uint64_t float16_to_uint64_scalbn (float16 a,FloatRoundMode ,int ,float_status *status); +uint8_t float16_to_uint8 (float16 a,float_status *status);uint16_t float16_to_uint16 (float16 a,float_status *status);uint32_t float16_to_uint32 (float16 a,float_status *status);uint64_t float16_to_uint64 (float16 a,float_status *status);
Signature · 1 line
2.17.1
Re: [RFC 60/65] softfloat: add fp16 and uint8/int8 interconvert functions
Quoted 3 lines · [email protected] writes:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>
Did I miss the rest of the series somewhere?
Otherwise this looks fine to me:
Signature · 1 line
Alex Bennée
Re: [RFC 60/65] softfloat: add fp16 and uint8/int8 interconvert functions
Quoted 7 lines · Alex Bennée
Quoted 3 lines · [email protected] writes:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>
Quoted 7 lines
Did I miss the rest of the series somewhere?
Otherwise this looks fine to me:
Reviewed-by Alex Bennée <[email protected]>If you mean float16 to uint8 and int8 conversion functions, this commit is
everything.
I think I just cc the mail based on *scripts/get_maintainer.pl
<http://get_maintainer.pl>*, so probably didn't send the whole series to everyone.
--
Frank Chang
Quoted 3 lines
--
Alex Bennée
Re: [RFC 60/65] softfloat: add fp16 and uint8/int8 interconvert functions
Quoted 13 lines · Frank Chang
Quoted 11 lines · Alex Bennée
Quoted 3 lines · [email protected] writes:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>Did I miss the rest of the series somewhere?
Otherwise this looks fine to me:
Quoted 7 lines
Quoted 3 lines
Reviewed-by Alex Bennée <[email protected]>If you mean float16 to uint8 and int8 conversion functions, this commit is
everything.
I think I just cc the mail based on*scripts/get_maintainer.pl
<http://get_maintainer.pl>*, so probably didn't send the whole series to everyone.
Usually I see the rest of the thread from the mailing list. I can't see:
In-Reply-To: <[email protected]>
References: <[email protected]>
on any of the qemu mailing lists.
Signature · 1 line
Alex Bennée
Re: [RFC 60/65] softfloat: add fp16 and uint8/int8 interconvert functions
Quoted 28 lines · Alex Bennée
Quoted 1 line · Frank Chang
On Fri, Jul 10, 2020 at 8:07 PM Alex Bennée <[email protected]>
Quoted 8 lines · wrote:
Quoted 8 lines
Quoted 3 lines · [email protected] writes:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>Quoted 7 lines
Quoted 7 lines
Did I miss the rest of the series somewhere?
Otherwise this looks fine to me:
Reviewed-by Alex Bennée <[email protected]>If you mean float16 to uint8 and int8 conversion functions, this commit
is
Quoted 4 lines
everything.
I think I just cc the mail based on*scripts/get_maintainer.pl
<http://get_maintainer.pl>*, so probably didn't send the whole series to everyone.Usually I see the rest of the thread from the mailing list. I can't see:
Quoted 8 lines
In-Reply-To: <[email protected]>
References: <[email protected]>on any of the qemu mailing lists.
--
Alex Bennée
The rest of the patches are coming out:
https://patchew.org/QEMU/[email protected]/
Not sure what caused the delay...
--
Frank Chang
Re: [RFC 60/65] softfloat: add fp16 and uint8/int8 interconvert functions
Quoted 35 lines · Frank Chang
Quoted 33 lines · Alex Bennée
Quoted 1 line · Frank Chang
On Fri, Jul 10, 2020 at 8:07 PM Alex Bennée <[email protected]>
Quoted 8 lines · wrote:
Quoted 8 lines
Quoted 3 lines · [email protected] writes:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>Quoted 7 lines
Quoted 7 lines
Did I miss the rest of the series somewhere?
Otherwise this looks fine to me:
Reviewed-by Alex Bennée <[email protected]>If you mean float16 to uint8 and int8 conversion functions, this commit
is
Quoted 4 lines
everything.
I think I just cc the mail based on*scripts/get_maintainer.pl
<http://get_maintainer.pl>*, so probably didn't send the whole series to everyone.Usually I see the rest of the thread from the mailing list. I can't see:
In-Reply-To: <[email protected]>
References: <[email protected]>on any of the qemu mailing lists.
Quoted 7 lines
Quoted 3 lines
--
Alex BennéeThe rest of the patches are coming out:
https://patchew.org/QEMU/[email protected]/
Not sure what caused the delay...
Ahh the mailing list is still chugging a bit it seems.
Signature · 1 line
Alex Bennée
RFC 61/65 fpu: fix float16 nan check
In reply to [email protected]From: Chih-Min Chao <[email protected]>
16 15 10 0
|sign | exp | mantissa |qNaN x 11111 1x_xxxx_xxxx
The mask should check exp + msb of mantissa
--- fpu/softfloat-specialize.inc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fpu/softfloat-specialize.inc.c +2 -2
@@ -254,7 +254,7 @@ bool float16_is_quiet_nan(float16 a_, float_status *status)if (snan_bit_is_one (status)) {return (((a >>9 ) &0x3F ) ==0x3E ) && (a &0x1FF ); }else { -return ((a & ~0x8000 ) >=0x7C80 ); +return ((a & ~0x8000 ) >=0x7E00 ); }#endif }
@@ -271,7 +271,7 @@ bool float16_is_signaling_nan(float16 a_, float_status *status)#else uint16_t a =float16_val (a_);if (snan_bit_is_one (status)) { -return ((a & ~0x8000 ) >=0x7C80 ); +return ((a & ~0x8000 ) >=0x7E00 ); }else {return (((a >>9 ) &0x3F ) ==0x3E ) && (a &0x1FF ); }
Signature · 1 line
2.17.1
RFC 62/65 fpu: add api to handle alternative sNaN propagation
In reply to [email protected]From: Chih-Min Chao <[email protected]>
--- fpu/softfloat.c | 68 +++++++++++++++++++++++++---------------- include/fpu/softfloat.h | 6 ++++ 2 files changed, 48 insertions(+), 26 deletions(-)
fpu/softfloat.c +42 -26
@@ -2777,23 +2777,32 @@ float64 uint16_to_float64(uint16_t a, float_status *status)* and minNumMag() from the IEEE-754 2008. */ static FloatParts minmax_floats (FloatParts a,FloatParts b,bool ismin, -bool ieee,bool ismag,float_status *s) +bool ieee,bool ismag,bool issnan_prop, +float_status *s) {if (unlikely (is_nan (a.cls) ||is_nan (b.cls))) {if (ieee) {/* Takes two floating-point values `a' and `b', one of * which is a NaN, and returns the appropriate NaN * result. If either `a' or `b' is a signaling NaN, -* the invalid exception is raised. +* the invalid exception is raised but the NaN +* propagation is 'shall'. */ if (is_snan (a.cls) ||is_snan (b.cls)) { -return pick_nan (a, b, s); - }else if (is_nan (a.cls) && !is_nan (b.cls)) { +if (issnan_prop) { +pick_nan (a, b, s); + }else { +return pick_nan (a, b, s); + } + } + +if (is_nan (a.cls) && !is_nan (b.cls)) {return b; }else if (is_nan (b.cls) && !is_nan (a.cls)) {return a; } } +return pick_nan (a, b, s); }else {int a_exp, b_exp;
@@ -2847,37 +2856,44 @@ static FloatParts minmax_floats(FloatParts a, FloatParts b, bool ismin, } } -#define MINMAX (sz, name, ismin, isiee, ismag) \ +#define MINMAX (sz, name, ismin, isiee, ismag, issnan_prop) \ float ## sz float ## sz ## _ ## name(float ## sz a, float ## sz b, \ float_status *s) \ { \ FloatParts pa = float ## sz ## _unpack_canonical(a, s); \ FloatParts pb = float ## sz ## _unpack_canonical(b, s); \ - FloatParts pr = minmax_floats(pa, pb, ismin, isiee, ismag, s); \ + FloatParts pr = minmax_floats(pa, pb, ismin, isiee, ismag, \ + issnan_prop, s); \ \ return float ## sz ## _round_pack_canonical(pr, s); \ } -MINMAX(16, min, true, false, false) -MINMAX(16, minnum, true, true, false) -MINMAX(16, minnummag, true, true, true) -MINMAX(16, max, false, false, false) -MINMAX(16, maxnum, false, true, false) -MINMAX(16, maxnummag, false, true, true) - -MINMAX(32, min, true, false, false) -MINMAX(32, minnum, true, true, false) -MINMAX(32, minnummag, true, true, true) -MINMAX(32, max, false, false, false) -MINMAX(32, maxnum, false, true, false) -MINMAX(32, maxnummag, false, true, true) - -MINMAX(64, min, true, false, false) -MINMAX(64, minnum, true, true, false) -MINMAX(64, minnummag, true, true, true) -MINMAX(64, max, false, false, false) -MINMAX(64, maxnum, false, true, false) -MINMAX(64, maxnummag, false, true, true) +MINMAX(16, min, true, false, false, false) +MINMAX(16, minnum, true, true, false, false) +MINMAX(16, minnum_noprop, true, true, false, true) +MINMAX(16, minnummag, true, true, true, false) +MINMAX(16, max, false, false, false, false) +MINMAX(16, maxnum, false, true, false, false) +MINMAX(16, maxnum_noprop, false, true, false, true) +MINMAX(16, maxnummag, false, true, true, false) + +MINMAX(32, min, true, false, false, false) +MINMAX(32, minnum, true, true, false, false) +MINMAX(32, minnum_noprop, true, true, false, true) +MINMAX(32, minnummag, true, true, true, false) +MINMAX(32, max, false, false, false, false) +MINMAX(32, maxnum, false, true, false, false) +MINMAX(32, maxnum_noprop, false, true, false, true) +MINMAX(32, maxnummag, false, true, true, false) + +MINMAX(64, min, true, false, false, false) +MINMAX(64, minnum, true, true, false, false) +MINMAX(64, minnum_noprop, true, true, false, true) +MINMAX(64, minnummag, true, true, true, false) +MINMAX(64, max, false, false, false, false) +MINMAX(64, maxnum, false, true, false, false) +MINMAX(64, maxnum_noprop, false, true, false, true) +MINMAX(64, maxnummag, false, true, true, false)#undef MINMAX
include/fpu/softfloat.h +6 -0
@@ -239,6 +239,8 @@ float16 float16_minnum(float16, float16, float_status *status);float16 float16_maxnum (float16 ,float16 ,float_status *status);float16 float16_minnummag (float16 ,float16 ,float_status *status);float16 float16_maxnummag (float16 ,float16 ,float_status *status); +float16 float16_minnum_noprop (float16 ,float16 ,float_status *status); +float16 float16_maxnum_noprop (float16 ,float16 ,float_status *status);float16 float16_sqrt (float16 ,float_status *status);FloatRelation float16_compare (float16 ,float16 ,float_status *status);FloatRelation float16_compare_quiet (float16 ,float16 ,float_status *status);
@@ -359,6 +361,8 @@ float32 float32_minnum(float32, float32, float_status *status);float32 float32_maxnum (float32 ,float32 ,float_status *status);float32 float32_minnummag (float32 ,float32 ,float_status *status);float32 float32_maxnummag (float32 ,float32 ,float_status *status); +float32 float32_minnum_noprop (float32 ,float32 ,float_status *status); +float32 float32_maxnum_noprop (float32 ,float32 ,float_status *status);bool float32_is_quiet_nan (float32 ,float_status *status);bool float32_is_signaling_nan (float32 ,float_status *status);float32 float32_silence_nan (float32 ,float_status *status);
@@ -548,6 +552,8 @@ float64 float64_minnum(float64, float64, float_status *status);float64 float64_maxnum (float64 ,float64 ,float_status *status);float64 float64_minnummag (float64 ,float64 ,float_status *status);float64 float64_maxnummag (float64 ,float64 ,float_status *status); +float64 float64_minnum_noprop (float64 ,float64 ,float_status *status); +float64 float64_maxnum_noprop (float64 ,float64 ,float_status *status);bool float64_is_quiet_nan (float64 a,float_status *status);bool float64_is_signaling_nan (float64 ,float_status *status);float64 float64_silence_nan (float64 ,float_status *status);
Signature · 1 line
2.17.1
Re: [RFC 62/65] fpu: add api to handle alternative sNaN propagation
Quoted 25 lines · [email protected] writes:
From: Chih-Min Chao <[email protected]>
Signed-off-by Chih-Min Chao <[email protected]>Signed-off-by Frank Chang <[email protected]>--- fpu/softfloat.c | 68 +++++++++++++++++++++++++---------------- include/fpu/softfloat.h | 6 ++++ 2 files changed, 48 insertions(+), 26 deletions(-)fpu/softfloat.c +2
-1@@ -2777,23 +2777,32 @@ float64 uint16_to_float64(uint16_t a, float_status *status)* and minNumMag() from the IEEE-754 2008. */ static FloatParts minmax_floats (FloatParts a,FloatParts b,bool ismin, -bool ieee,bool ismag,float_status *s) +bool ieee,bool ismag,bool issnan_prop, +float_status *s) {if (unlikely (is_nan (a.cls) ||is_nan (b.cls))) {if (ieee) {/* Takes two floating-point values `a' and `b', one of * which is a NaN, and returns the appropriate NaN
fpu/softfloat.c float64 uint16_to_float64(uint16_t a, float_status *status) · line 2793
Quoted 10 lines
fpu/softfloat.c +4
-3* result. If either `a' or `b' is a signaling NaN, -* the invalid exception is raised. +* the invalid exception is raised but the NaN +* propagation is 'shall'. */ if (is_snan (a.cls) ||is_snan (b.cls)) { -return pick_nan (a, b, s); - }else if (is_nan (a.cls) && !is_nan (b.cls)) { +if (issnan_prop) { +pick_nan (a, b, s);
This looks funky to me because you don't actually pick a nan - are you just using this for side effects?
I'm also confused by the fact the new helpers have the prototype noprop which implies no propagation yes the bool flag is true and named issnan_prop which implies it should propagate.
I think we need a clearer problem statement in the commit of what you are trying to achieve here. I suspect it might be worth splitting the flag setting from pick_nan to it's own mini helper if that is all we want to do in this case.
fpu/softfloat.c float64 uint16_to_float64(uint16_t a, float_status *status) · line 2805
Quoted 12 lines
fpu/softfloat.c +7
-0+ }else { +return pick_nan (a, b, s); + } + } + +if (is_nan (a.cls) && !is_nan (b.cls)) {return b; }else if (is_nan (b.cls) && !is_nan (a.cls)) {return a; } } +
nit: stray space
Quoted 101 lines
fpu/softfloat.c +29
-22return pick_nan (a, b, s); }else {int a_exp, b_exp;@@ -2847,37 +2856,44 @@ static FloatParts minmax_floats(FloatParts a, FloatParts b, bool ismin, } } -#define MINMAX (sz, name, ismin, isiee, ismag) \ +#define MINMAX (sz, name, ismin, isiee, ismag, issnan_prop) \ float ## sz float ## sz ## _ ## name(float ## sz a, float ## sz b, \ float_status *s) \ { \ FloatParts pa = float ## sz ## _unpack_canonical(a, s); \ FloatParts pb = float ## sz ## _unpack_canonical(b, s); \ - FloatParts pr = minmax_floats(pa, pb, ismin, isiee, ismag, s); \ + FloatParts pr = minmax_floats(pa, pb, ismin, isiee, ismag, \ + issnan_prop, s); \ \ return float ## sz ## _round_pack_canonical(pr, s); \ } -MINMAX(16, min, true, false, false) -MINMAX(16, minnum, true, true, false) -MINMAX(16, minnummag, true, true, true) -MINMAX(16, max, false, false, false) -MINMAX(16, maxnum, false, true, false) -MINMAX(16, maxnummag, false, true, true) - -MINMAX(32, min, true, false, false) -MINMAX(32, minnum, true, true, false) -MINMAX(32, minnummag, true, true, true) -MINMAX(32, max, false, false, false) -MINMAX(32, maxnum, false, true, false) -MINMAX(32, maxnummag, false, true, true) - -MINMAX(64, min, true, false, false) -MINMAX(64, minnum, true, true, false) -MINMAX(64, minnummag, true, true, true) -MINMAX(64, max, false, false, false) -MINMAX(64, maxnum, false, true, false) -MINMAX(64, maxnummag, false, true, true) +MINMAX(16, min, true, false, false, false) +MINMAX(16, minnum, true, true, false, false) +MINMAX(16, minnum_noprop, true, true, false, true) +MINMAX(16, minnummag, true, true, true, false) +MINMAX(16, max, false, false, false, false) +MINMAX(16, maxnum, false, true, false, false) +MINMAX(16, maxnum_noprop, false, true, false, true) +MINMAX(16, maxnummag, false, true, true, false) + +MINMAX(32, min, true, false, false, false) +MINMAX(32, minnum, true, true, false, false) +MINMAX(32, minnum_noprop, true, true, false, true) +MINMAX(32, minnummag, true, true, true, false) +MINMAX(32, max, false, false, false, false) +MINMAX(32, maxnum, false, true, false, false) +MINMAX(32, maxnum_noprop, false, true, false, true) +MINMAX(32, maxnummag, false, true, true, false) + +MINMAX(64, min, true, false, false, false) +MINMAX(64, minnum, true, true, false, false) +MINMAX(64, minnum_noprop, true, true, false, true) +MINMAX(64, minnummag, true, true, true, false) +MINMAX(64, max, false, false, false, false) +MINMAX(64, maxnum, false, true, false, false) +MINMAX(64, maxnum_noprop, false, true, false, true) +MINMAX(64, maxnummag, false, true, true, false)#undef MINMAXinclude/fpu/softfloat.h +6
-0@@ -239,6 +239,8 @@ float16 float16_minnum(float16, float16, float_status *status);float16 float16_maxnum (float16 ,float16 ,float_status *status);float16 float16_minnummag (float16 ,float16 ,float_status *status);float16 float16_maxnummag (float16 ,float16 ,float_status *status); +float16 float16_minnum_noprop (float16 ,float16 ,float_status *status); +float16 float16_maxnum_noprop (float16 ,float16 ,float_status *status);float16 float16_sqrt (float16 ,float_status *status);FloatRelation float16_compare (float16 ,float16 ,float_status *status);FloatRelation float16_compare_quiet (float16 ,float16 ,float_status *status);@@ -359,6 +361,8 @@ float32 float32_minnum(float32, float32, float_status *status);float32 float32_maxnum (float32 ,float32 ,float_status *status);float32 float32_minnummag (float32 ,float32 ,float_status *status);float32 float32_maxnummag (float32 ,float32 ,float_status *status); +float32 float32_minnum_noprop (float32 ,float32 ,float_status *status); +float32 float32_maxnum_noprop (float32 ,float32 ,float_status *status);bool float32_is_quiet_nan (float32 ,float_status *status);bool float32_is_signaling_nan (float32 ,float_status *status);float32 float32_silence_nan (float32 ,float_status *status);@@ -548,6 +552,8 @@ float64 float64_minnum(float64, float64, float_status *status);float64 float64_maxnum (float64 ,float64 ,float_status *status);float64 float64_minnummag (float64 ,float64 ,float_status *status);float64 float64_maxnummag (float64 ,float64 ,float_status *status); +float64 float64_minnum_noprop (float64 ,float64 ,float_status *status); +float64 float64_maxnum_noprop (float64 ,float64 ,float_status *status);bool float64_is_quiet_nan (float64 a,float_status *status);bool float64_is_signaling_nan (float64 ,float_status *status);float64 float64_silence_nan (float64 ,float_status *status);
Signature · 1 line
Alex Bennée
Re: [RFC 62/65] fpu: add api to handle alternative sNaN propagation
Quoted 177 lines · Alex Bennée
fpu/softfloat.c float64 uint16_to_float64(uint16_t a,
Quoted 14 lines · [email protected] writes:
From: Chih-Min Chao <[email protected]>
Signed-off-by Chih-Min Chao <[email protected]>Signed-off-by Frank Chang <[email protected]>--- fpu/softfloat.c | 68 +++++++++++++++++++++++++---------------- include/fpu/softfloat.h | 6 ++++ 2 files changed, 48 insertions(+), 26 deletions(-)fpu/softfloat.c +0
-0@@ -2777,23 +2777,32 @@ float64 uint16_to_float64(uint16_t a,
float_status*status)Quoted 11 lines
fpu/softfloat.c +2
-1* and minNumMag() from the IEEE-754 2008. */ static FloatParts minmax_floats (FloatParts a,FloatParts b,bool ismin, -bool ieee,bool ismag,float_status *s) +bool ieee,bool ismag,bool issnan_prop, +float_status *s) {if (unlikely (is_nan (a.cls) ||is_nan (b.cls))) {if (ieee) {/* Takes two floating-point values `a' and `b', one of * which is a NaN, and returns the appropriate NaN fpu/softfloat.c float64 uint16_to_float64(uint16_t a, float_status *status) · line 2793
Quoted 10 lines
fpu/softfloat.c +4
-3* result. If either `a' or `b' is a signaling NaN, -* the invalid exception is raised. +* the invalid exception is raised but the NaN +* propagation is 'shall'. */ if (is_snan (a.cls) ||is_snan (b.cls)) { -return pick_nan (a, b, s); - }else if (is_nan (a.cls) && !is_nan (b.cls)) { +if (issnan_prop) { +pick_nan (a, b, s);This looks funky to me because you don't actually pick a nan - are you just using this for side effects?
I'm also confused by the fact the new helpers have the prototype noprop which implies no propagation yes the bool flag is true and named
issnan_propwhich implies it should propagate.I think we need a clearer problem statement in the commit of what you are trying to achieve here. I suspect it might be worth splitting the flag setting from
pick_nanto it's own mini helper if that is all we want to do in this case.fpu/softfloat.c float64 uint16_to_float64(uint16_t a, float_status *status) · line 2805
Quoted 12 lines
fpu/softfloat.c +7
-0+ }else { +return pick_nan (a, b, s); + } + } + +if (is_nan (a.cls) && !is_nan (b.cls)) {return b; }else if (is_nan (b.cls) && !is_nan (a.cls)) {return a; } } +nit: stray space
fpu/softfloat.c static FloatParts minmax_floats(FloatParts a,
Quoted 4 lines
fpu/softfloat.c +0
-0return pick_nan (a, b, s); }else {int a_exp, b_exp;@@ -2847,37 +2856,44 @@ static FloatParts minmax_floats(FloatParts a,FloatParts b, bool ismin,
fpu/softfloat.c static FloatParts minmax_floats(FloatParts a, · line 2850
Quoted 4 lines
fpu/softfloat.c +0
-1} } -#define MINMAX (sz, name, ismin, isiee, ismag)\
fpu/softfloat.c static FloatParts minmax_floats(FloatParts a, · line 2859
Quoted 1 line
fpu/softfloat.c +1
-0+#define MINMAX (sz, name, ismin, isiee, ismag, issnan_prop)\
fpu/softfloat.c static FloatParts minmax_floats(FloatParts a, · line 2860
Quoted 1 line
fpu/softfloat.c +0
-0float ## sz float ## sz ## _ ## name(float ## sz a, float ## sz b,\
fpu/softfloat.c static FloatParts minmax_floats(FloatParts a, · line 2861
Quoted 1 line
fpu/softfloat.c +0
-0float_status *s)\
fpu/softfloat.c static FloatParts minmax_floats(FloatParts a, · line 2862
Quoted 1 line
fpu/softfloat.c +0
-0{\
fpu/softfloat.c static FloatParts minmax_floats(FloatParts a, · line 2863
Quoted 1 line
fpu/softfloat.c +0
-0FloatParts pa = float ## sz ## _unpack_canonical(a, s);\
fpu/softfloat.c static FloatParts minmax_floats(FloatParts a, · line 2864
Quoted 1 line
fpu/softfloat.c +0
-0FloatParts pb = float ## sz ## _unpack_canonical(b, s);\
fpu/softfloat.c static FloatParts minmax_floats(FloatParts a, · line 2856
Quoted 1 line
fpu/softfloat.c +0
-1-FloatParts pr =minmax_floats (pa, pb, ismin, isiee, ismag, s);\
fpu/softfloat.c static FloatParts minmax_floats(FloatParts a, · line 2865
Quoted 1 line
fpu/softfloat.c +1
-0+ FloatParts pr = minmax_floats(pa, pb, ismin, isiee, ismag,\
fpu/softfloat.c static FloatParts minmax_floats(FloatParts a, · line 2866
Quoted 1 line
fpu/softfloat.c +1
-0+ issnan_prop, s);\
Quoted 1 line
\
Quoted 1 line
return float ## sz ## _round_pack_canonical(pr, s);\
include/fpu/softfloat.h float16 float16_minnum(float16, float16,
Quoted 56 lines
}
fpu/softfloat.c +26
-20-MINMAX(16, min, true, false, false) -MINMAX(16, minnum, true, true, false) -MINMAX(16, minnummag, true, true, true) -MINMAX(16, max, false, false, false) -MINMAX(16, maxnum, false, true, false) -MINMAX(16, maxnummag, false, true, true) - -MINMAX(32, min, true, false, false) -MINMAX(32, minnum, true, true, false) -MINMAX(32, minnummag, true, true, true) -MINMAX(32, max, false, false, false) -MINMAX(32, maxnum, false, true, false) -MINMAX(32, maxnummag, false, true, true) - -MINMAX(64, min, true, false, false) -MINMAX(64, minnum, true, true, false) -MINMAX(64, minnummag, true, true, true) -MINMAX(64, max, false, false, false) -MINMAX(64, maxnum, false, true, false) -MINMAX(64, maxnummag, false, true, true) +MINMAX(16, min, true, false, false, false) +MINMAX(16, minnum, true, true, false, false) +MINMAX(16, minnum_noprop, true, true, false, true) +MINMAX(16, minnummag, true, true, true, false) +MINMAX(16, max, false, false, false, false) +MINMAX(16, maxnum, false, true, false, false) +MINMAX(16, maxnum_noprop, false, true, false, true) +MINMAX(16, maxnummag, false, true, true, false) + +MINMAX(32, min, true, false, false, false) +MINMAX(32, minnum, true, true, false, false) +MINMAX(32, minnum_noprop, true, true, false, true) +MINMAX(32, minnummag, true, true, true, false) +MINMAX(32, max, false, false, false, false) +MINMAX(32, maxnum, false, true, false, false) +MINMAX(32, maxnum_noprop, false, true, false, true) +MINMAX(32, maxnummag, false, true, true, false) + +MINMAX(64, min, true, false, false, false) +MINMAX(64, minnum, true, true, false, false) +MINMAX(64, minnum_noprop, true, true, false, true) +MINMAX(64, minnummag, true, true, true, false) +MINMAX(64, max, false, false, false, false) +MINMAX(64, maxnum, false, true, false, false) +MINMAX(64, maxnum_noprop, false, true, false, true) +MINMAX(64, maxnummag, false, true, true, false)#undef MINMAXinclude/fpu/softfloat.h +0
-0@@ -239,6 +239,8 @@ float16 float16_minnum(float16, float16,
float_status*status);include/fpu/softfloat.h float16 float16_minnum(float16, float16, float_status *status);
Quoted 8 lines
include/fpu/softfloat.h +2
-0float16 float16_maxnum (float16 ,float16 ,float_status *status);float16 float16_minnummag (float16 ,float16 ,float_status *status);float16 float16_maxnummag (float16 ,float16 ,float_status *status); +float16 float16_minnum_noprop (float16 ,float16 ,float_status *status); +float16 float16_maxnum_noprop (float16 ,float16 ,float_status *status);float16 float16_sqrt (float16 ,float_status *status);FloatRelation float16_compare (float16 ,float16 ,float_status *status); FloatRelation float16_compare_quiet(float16, float16, float_status*status);
include/fpu/softfloat.h float32 float32_minnum(float32, float32,
Quoted 1 line
include/fpu/softfloat.h +0
-0@@ -359,6 +361,8 @@ float32 float32_minnum(float32, float32,
float_status*status);include/fpu/softfloat.h float64 float64_minnum(float64, float64,
Quoted 9 lines
include/fpu/softfloat.h +2
-0float32 float32_maxnum (float32 ,float32 ,float_status *status);float32 float32_minnummag (float32 ,float32 ,float_status *status);float32 float32_maxnummag (float32 ,float32 ,float_status *status); +float32 float32_minnum_noprop (float32 ,float32 ,float_status *status); +float32 float32_maxnum_noprop (float32 ,float32 ,float_status *status);bool float32_is_quiet_nan (float32 ,float_status *status);bool float32_is_signaling_nan (float32 ,float_status *status);float32 float32_silence_nan (float32 ,float_status *status);@@ -548,6 +552,8 @@ float64 float64_minnum(float64, float64,
float_status*status);
Quoted 13 lines
include/fpu/softfloat.h float64 float64_minnum(float64, float64, float_status *status); · line 559
Quoted 8 lines
include/fpu/softfloat.h +2
-0float64 float64_maxnum (float64 ,float64 ,float_status *status);float64 float64_minnummag (float64 ,float64 ,float_status *status);float64 float64_maxnummag (float64 ,float64 ,float_status *status); +float64 float64_minnum_noprop (float64 ,float64 ,float_status *status); +float64 float64_maxnum_noprop (float64 ,float64 ,float_status *status);bool float64_is_quiet_nan (float64 a,float_status *status);bool float64_is_signaling_nan (float64 ,float_status *status);float64 float64_silence_nan (float64 ,float_status *status);--
Alex Bennée
Hi Alex,
1.
This patch comes from the change of sNaN propagation implementation of riscv floating spec.
Take following as example,
fmin.s ft0, ft1, ft2.
For spec 2.2, the sNaN handling for fmin and fmax is
if ft1 is sNaN or ft2 is sNaN
a. set the invalid flag
b. ft0 is canonical NaN
ref:
https://github.com/riscv/riscv-isa-manual/releases/tag/riscv-user-2.2
section 8.3
"For FMIN and FMAX, if at least one input is a signaling
NaN, or if both inputs are quiet NaNs,
the result is the canonical NaN. If one operand is a quiet
NaN and the other is not a NaN, the
result is the non-NaN operand.
For spec 20191213, the behavior is changed to
if ft1 or ft2 is sNaN and the other is non-NaN
a. set the invalid flag
b. ft0 is set to non-NaN source
ref:
https://github.com/riscv/riscv-isa-manual/releases/tag/Ratified-IMAFDQC
section 11.6
"If both inputs are NaNs, the result is
the canonical NaN. If only one operand is a NaN, the result
is the non-NaN operand. Signaling
NaN inputs set the invalid operation exception flag, even
when the result is not NaN."
2.
As you guess, the patch takes the side effect of pick_nan. The pick_nan does two works
a. set invalid flag if input is sNaN
b. return correct NaN number by configuration
for one possible case, one operand is sNaN and the other is non-NaN, the
patch does
a. pick_nan to set invalid_flag but doesn't use the return
value)
b. return non-NaN
for the other case, both operands are sNaN, the patch does
a. pick_nan to set_invalid_flag
b pick_nan to return NaN value
Is it better to separate the "set invalid flag" part from pick_nan to make it concrete ?
3.
The parameter naming is misleading and will be fix in next separated softfloat patch.
Thanks
Chih-Min Chao
RFC 63/65 fpu: implement full set compare for fp16
In reply to [email protected]From: Kito Cheng <[email protected]>
--- fpu/softfloat.c | 240 ++++++++++++++++++++++++++++++++++++++++ include/fpu/softfloat.h | 8 ++ 2 files changed, 248 insertions(+)
fpu/softfloat.c +240 -0
@@ -401,6 +401,34 @@ float64_gen2(float64 xa, float64 xb, float_status *s,return soft (ua.s, ub.s, s); } +/*---------------------------------------------------------------------------- +| Returns the fraction bits of the half-precision floating-point value `a'. +*----------------------------------------------------------------------------*/ + +static inline uint32_t extractFloat16Frac (float16 a) +{ +return float16_val (a) &0x3ff ; +} + +/*---------------------------------------------------------------------------- +| Returns the exponent bits of the half-precision floating-point value `a'. +*----------------------------------------------------------------------------*/ + +static inline int extractFloat16Exp (float16 a) +{ +return (float16_val (a) >>10 ) &0x1f ; +} + +/*---------------------------------------------------------------------------- +| Returns the sign bit of the half-precision floating-point value `a'. +*----------------------------------------------------------------------------*/ + +static inline bool extractFloat16Sign (float16 a) +{ +return float16_val (a) >>15 ; +} + +/*---------------------------------------------------------------------------- | Returns the fraction bits of the single-precision floating-point value `a'. *----------------------------------------------------------------------------*/
@@ -5006,6 +5034,218 @@ float64 float64_log2(float64 a, float_status *status)return normalizeRoundAndPackFloat64 (zSign,0x408 , zSig, status); } +/*---------------------------------------------------------------------------- +| Returns 1 if the half-precision floating-point value `a' is equal to +| the corresponding value `b', and 0 otherwise. The invalid exception is +| raised if either operand is a NaN. Otherwise, the comparison is performed +| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. +*----------------------------------------------------------------------------*/ + +int float16_eq (float16 a,float16 b,float_status *status) +{ +uint16_t av, bv; + a =float16_squash_input_denormal (a, status); + b =float16_squash_input_denormal (b, status); + +if (((extractFloat16Exp (a) ==0x1F ) &&extractFloat16Frac (a)) + || ((extractFloat16Exp (b) ==0x1F ) &&extractFloat16Frac (b))) { +float_raise (float_flag_invalid, status); +return 0 ; + } + av =float16_val (a); + bv =float16_val (b); +return (av == bv) || ((uint16_t ) ((av | bv) <<1 ) ==0 ); +} + +/*---------------------------------------------------------------------------- +| Returns 1 if the half-precision floating-point value `a' is less than +| or equal to the corresponding value `b', and 0 otherwise. The invalid +| exception is raised if either operand is a NaN. The comparison is performed +| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. +*----------------------------------------------------------------------------*/ + +int float16_le (float16 a,float16 b,float_status *status) +{ +bool aSign, bSign; +uint16_t av, bv; + a =float16_squash_input_denormal (a, status); + b =float16_squash_input_denormal (b, status); + +if (((extractFloat16Exp (a) ==0x1F ) &&extractFloat16Frac (a)) + || ((extractFloat16Exp (b) ==0x1F ) &&extractFloat16Frac (b))) { +float_raise (float_flag_invalid, status); +return 0 ; + } + aSign =extractFloat16Sign (a); + bSign =extractFloat16Sign (b); + av =float16_val (a); + bv =float16_val (b); +if (aSign != bSign) { +return aSign || ((uint16_t ) ((av | bv) <<1 ) ==0 ); + } +return (av == bv) || (aSign ^ (av < bv)); +} + +/*---------------------------------------------------------------------------- +| Returns 1 if the half-precision floating-point value `a' is less than +| the corresponding value `b', and 0 otherwise. The invalid exception is +| raised if either operand is a NaN. The comparison is performed according +| to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. +*----------------------------------------------------------------------------*/ + +int float16_lt (float16 a,float16 b,float_status *status) +{ +bool aSign, bSign; +uint16_t av, bv; + a =float16_squash_input_denormal (a, status); + b =float16_squash_input_denormal (b, status); + +if (((extractFloat16Exp (a) ==0x1F ) &&extractFloat16Frac (a)) + || ((extractFloat16Exp (b) ==0x1F ) &&extractFloat16Frac (b))) { +float_raise (float_flag_invalid, status); +return 0 ; + } + aSign =extractFloat16Sign (a); + bSign =extractFloat16Sign (b); + av =float16_val (a); + bv =float16_val (b); +if (aSign != bSign) { +return aSign && ((uint16_t ) ((av | bv) <<1 ) !=0 ); + } +return (av != bv) && (aSign ^ (av < bv)); +} + +/*---------------------------------------------------------------------------- +| Returns 1 if the half-precision floating-point values `a' and `b' cannot +| be compared, and 0 otherwise. The invalid exception is raised if either +| operand is a NaN. The comparison is performed according to the IEC/IEEE +| Standard for Binary Floating-Point Arithmetic. +*----------------------------------------------------------------------------*/ + +int float16_unordered (float16 a,float16 b,float_status *status) +{ + a =float16_squash_input_denormal (a, status); + b =float16_squash_input_denormal (b, status); + +if (((extractFloat16Exp (a) ==0x1F ) &&extractFloat16Frac (a)) + || ((extractFloat16Exp (b) ==0x1F ) &&extractFloat16Frac (b))) { +float_raise (float_flag_invalid, status); +return 1 ; + } +return 0 ; +} + +/*---------------------------------------------------------------------------- +| Returns 1 if the half-precision floating-point value `a' is equal to +| the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an +| exception. The comparison is performed according to the IEC/IEEE Standard +| for Binary Floating-Point Arithmetic. +*----------------------------------------------------------------------------*/ + +int float16_eq_quiet (float16 a,float16 b,float_status *status) +{ + a =float16_squash_input_denormal (a, status); + b =float16_squash_input_denormal (b, status); + +if (((extractFloat16Exp (a) ==0x1F ) &&extractFloat16Frac (a)) + || ((extractFloat16Exp (b) ==0x1F ) &&extractFloat16Frac (b))) { +if (float16_is_signaling_nan (a, status) + ||float16_is_signaling_nan (b, status)) { +float_raise (float_flag_invalid, status); + } +return 0 ; + } +return (float16_val (a) ==float16_val (b)) || + ((uint16_t ) ((float16_val (a) |float16_val (b)) <<1 ) ==0 ); +} + +/*---------------------------------------------------------------------------- +| Returns 1 if the half-precision floating-point value `a' is less than or +| equal to the corresponding value `b', and 0 otherwise. Quiet NaNs do not +| cause an exception. Otherwise, the comparison is performed according to the +| IEC/IEEE Standard for Binary Floating-Point Arithmetic. +*----------------------------------------------------------------------------*/ + +int float16_le_quiet (float16 a,float16 b,float_status *status) +{ +bool aSign, bSign; +uint16_t av, bv; + a =float16_squash_input_denormal (a, status); + b =float16_squash_input_denormal (b, status); + +if (((extractFloat16Exp (a) ==0x1F ) &&extractFloat16Frac (a)) + || ((extractFloat16Exp (b) ==0x1F ) &&extractFloat16Frac (b))) { +if (float16_is_signaling_nan (a, status) + ||float16_is_signaling_nan (b, status)) { +float_raise (float_flag_invalid, status); + } +return 0 ; + } + aSign =extractFloat16Sign (a); + bSign =extractFloat16Sign (b); + av =float16_val (a); + bv =float16_val (b); +if (aSign != bSign) { +return aSign || ((uint16_t ) ((av | bv) <<1 ) ==0 ); + } +return (av == bv) || (aSign ^ (av < bv)); +} + +/*---------------------------------------------------------------------------- +| Returns 1 if the half-precision floating-point value `a' is less than +| the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an +| exception. Otherwise, the comparison is performed according to the IEC/IEEE +| Standard for Binary Floating-Point Arithmetic. +*----------------------------------------------------------------------------*/ + +int float16_lt_quiet (float16 a,float16 b,float_status *status) +{ +bool aSign, bSign; +uint16_t av, bv; + a =float16_squash_input_denormal (a, status); + b =float16_squash_input_denormal (b, status); + +if (((extractFloat16Exp (a) ==0x1F ) &&extractFloat16Frac (a)) + || ((extractFloat16Exp (b) ==0x1F ) &&extractFloat16Frac (b))) { +if (float16_is_signaling_nan (a, status) + ||float16_is_signaling_nan (b, status)) { +float_raise (float_flag_invalid, status); + } +return 0 ; + } + aSign =extractFloat16Sign (a); + bSign =extractFloat16Sign (b); + av =float16_val (a); + bv =float16_val (b); +if (aSign != bSign) { +return aSign && ((uint16_t ) ((av | bv) <<1 ) !=0 ); + } +return (av != bv) && (aSign ^ (av < bv)); +} + +/*---------------------------------------------------------------------------- +| Returns 1 if the half-precision floating-point values `a' and `b' cannot +| be compared, and 0 otherwise. Quiet NaNs do not cause an exception. The +| comparison is performed according to the IEC/IEEE Standard for Binary +| Floating-Point Arithmetic. +*----------------------------------------------------------------------------*/ + +int float16_unordered_quiet (float16 a,float16 b,float_status *status) +{ + a =float16_squash_input_denormal (a, status); + b =float16_squash_input_denormal (b, status); + +if (((extractFloat16Exp (a) ==0x1F ) &&extractFloat16Frac (a)) + || ((extractFloat16Exp (b) ==0x1F ) &&extractFloat16Frac (b))) { +if (float16_is_signaling_nan (a, status) + ||float16_is_signaling_nan (b, status)) { +float_raise (float_flag_invalid, status); + } +return 1 ; + } +return 0 ; +} +/*---------------------------------------------------------------------------- | Returns the result of converting the extended double-precision floating- | point value `a' to the 32-bit two's complement integer format. The
include/fpu/softfloat.h +8 -0
@@ -244,6 +244,14 @@ float16 float16_maxnum_noprop(float16, float16, float_status *status);float16 float16_sqrt (float16 ,float_status *status);FloatRelation float16_compare (float16 ,float16 ,float_status *status);FloatRelation float16_compare_quiet (float16 ,float16 ,float_status *status); +int float16_eq (float16 ,float16 ,float_status *status); +int float16_le (float16 ,float16 ,float_status *status); +int float16_lt (float16 ,float16 ,float_status *status); +int float16_unordered (float16 ,float16 ,float_status *status); +int float16_eq_quiet (float16 ,float16 ,float_status *status); +int float16_le_quiet (float16 ,float16 ,float_status *status); +int float16_lt_quiet (float16 ,float16 ,float_status *status); +int float16_unordered_quiet (float16 ,float16 ,float_status *status);bool float16_is_quiet_nan (float16 ,float_status *status);bool float16_is_signaling_nan (float16 ,float_status *status);
Signature · 1 line
2.17.1
Re: [RFC 63/65] fpu: implement full set compare for fp16
Quoted 5 lines · [email protected] writes:
From: Kito Cheng <[email protected]>
Signed-off-by Kito Cheng <[email protected]>Signed-off-by Chih-Min Chao <[email protected]>Signed-off-by Frank Chang <[email protected]>
NACK I'm afraid. What's wrong with the exiting float_compare support?
Even if you did want to bring in aliases for these functions within softfloat itself the correct way would be to use the decomposed float_compare support for a bunch of stubs and not restore the old style error prone bit masking code.
Quoted 11 lines
--- fpu/softfloat.c | 240 ++++++++++++++++++++++++++++++++++++++++ include/fpu/softfloat.h | 8 ++ 2 files changed, 248 insertions(+)fpu/softfloat.c +0
-0@@ -401,6 +401,34 @@ float64_gen2(float64 xa, float64 xb, float_status *s,return soft (ua.s, ub.s, s);
fpu/softfloat.c float64_gen2(float64 xa, float64 xb, float_status *s, · line 411
Quoted 10 lines
fpu/softfloat.c +8
-0} +/*---------------------------------------------------------------------------- +| Returns the fraction bits of the half-precision floating-point value `a'. +*----------------------------------------------------------------------------*/ + +static inline uint32_t extractFloat16Frac (float16 a) +{ +return float16_val (a) &0x3ff ; +}
For example you'll notice this function was deleted in e6b405fe00
Signature · 1 line
Alex Bennée
Re: [RFC 63/65] fpu: implement full set compare for fp16
Quoted 8 lines · Alex Bennée
Quoted 5 lines · [email protected] writes:
From: Kito Cheng <[email protected]>
Signed-off-by Kito Cheng <[email protected]>Signed-off-by Chih-Min Chao <[email protected]>Signed-off-by Frank Chang <[email protected]>
Quoted 6 lines
NACK I'm afraid. What's wrong with the exiting
float_comparesupport?Even if you did want to bring in aliases for these functions within softfloat itself the correct way would be to use the decomposed
float_comparesupport for a bunch of stubs and not restore the old style error prone bit masking code.
In fact see the example float32_eq inline function in the softfloat.h header.
Signature · 1 line
Alex Bennée
Re: [RFC 63/65] fpu: implement full set compare for fp16
Quoted 18 lines · Alex Bennée
Quoted 8 lines · Alex Bennée
Quoted 5 lines · [email protected] writes:
From: Kito Cheng <[email protected]>
Signed-off-by Kito Cheng <[email protected]>Signed-off-by Chih-Min Chao <[email protected]>Signed-off-by Frank Chang <[email protected]>Quoted 6 lines
NACK I'm afraid. What's wrong with the exiting
float_comparesupport?Even if you did want to bring in aliases for these functions within softfloat itself the correct way would be to use the decomposed
float_comparesupport for a bunch of stubs and not restore the old style error prone bit masking code.
Quoted 6 lines
In fact see the example
float32_eqinline function in thesoftfloat.hheader.--
Alex Bennée
Hi Alex,
Thanks for the suggestion of using wrong and old implementation and this part will be refined in next separated softfloat PR.
Thanks
Chih-Min Chao
RFC 64/65 target/riscv: use softfloat lib float16 comparison functions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/vector_helper.c | 19 ------------------- 1 file changed, 19 deletions(-)
target/riscv/vector_helper.c +0 -19
@@ -3969,12 +3969,6 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ } \ } -static bool float16_eq_quiet (uint16_t a,uint16_t b,float_status *s) -{ -FloatRelation compare =float16_compare_quiet (a, b, s); -return compare == float_relation_equal; -} - GEN_VEXT_CMP_VV_ENV(vmfeq_vv_h, uint16_t, H2, float16_eq_quiet) GEN_VEXT_CMP_VV_ENV(vmfeq_vv_w, uint32_t, H4, float32_eq_quiet)GEN_VEXT_CMP_VV_ENV (vmfeq_vv_d, uint64_t,H8 , float64_eq_quiet)
@@ -4033,12 +4027,6 @@ GEN_VEXT_CMP_VF(vmfne_vf_h, uint16_t, H2, vmfne16) GEN_VEXT_CMP_VF(vmfne_vf_w, uint32_t, H4, vmfne32) GEN_VEXT_CMP_VF(vmfne_vf_d, uint64_t, H8, vmfne64) -static bool float16_lt (uint16_t a,uint16_t b,float_status *s) -{ -FloatRelation compare =float16_compare (a, b, s); -return compare == float_relation_less; -} - GEN_VEXT_CMP_VV_ENV(vmflt_vv_h, uint16_t, H2, float16_lt) GEN_VEXT_CMP_VV_ENV(vmflt_vv_w, uint32_t, H4, float32_lt)GEN_VEXT_CMP_VV_ENV (vmflt_vv_d, uint64_t,H8 , float64_lt)
@@ -4046,13 +4034,6 @@ GEN_VEXT_CMP_VF(vmflt_vf_h, uint16_t, H2, float16_lt) GEN_VEXT_CMP_VF(vmflt_vf_w, uint32_t, H4, float32_lt) GEN_VEXT_CMP_VF(vmflt_vf_d, uint64_t, H8, float64_lt) -static bool float16_le (uint16_t a,uint16_t b,float_status *s) -{ -FloatRelation compare =float16_compare (a, b, s); -return compare == float_relation_less || - compare == float_relation_equal; -} - GEN_VEXT_CMP_VV_ENV(vmfle_vv_h, uint16_t, H2, float16_le) GEN_VEXT_CMP_VV_ENV(vmfle_vv_w, uint32_t, H4, float32_le)GEN_VEXT_CMP_VV_ENV (vmfle_vv_d, uint64_t,H8 , float64_le)
Signature · 1 line
2.17.1
RFC 65/65 target/riscv: bump to RVV 0.9
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/cpu.c | 8 ++++---- target/riscv/cpu.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)
target/riscv/cpu.c +4 -4
@@ -340,7 +340,7 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)CPURISCVState *env = &cpu->env;RISCVCPUClass *mcc =RISCV_CPU_GET_CLASS (dev);int priv_version =PRIV_VERSION_1_11_0 ; -int vext_version =VEXT_VERSION_0_07_1 ; +int vext_version =VEXT_VERSION_0_09_0 ;target_ulong target_misa =0 ;Error *local_err =NULL ;
@@ -456,8 +456,8 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)return ; }if (cpu->cfg.vext_spec) { -if (!g_strcmp0 (cpu->cfg.vext_spec,"v0.7.1" )) { - vext_version =VEXT_VERSION_0_07_1 ; +if (!g_strcmp0 (cpu->cfg.vext_spec,"v0.9" )) { + vext_version =VEXT_VERSION_0_09_0 ; }else { error_setg(errp, "Unsupported vector spec version '%s'",
@@ -466,7 +466,7 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) } }else {qemu_log ("vector verison is not specified, " -"use the default value v0.7.1\n" ); +"use the default value v0.9\n" ); }set_vext_version (env, vext_version); }
target/riscv/cpu.h +1 -1
@@ -81,7 +81,7 @@ enum {#define PRIV_VERSION_1_10_0 0x00011000#define PRIV_VERSION_1_11_0 0x00011100 -#define VEXT_VERSION_0_07_1 0x00000701 +#define VEXT_VERSION_0_09_0 0x00000900#define TRANSLATE_PMP_FAIL 2#define TRANSLATE_FAIL 1
Signature · 1 line
2.17.1
Quoted 5 lines · On Fri, Jul 10, 2020 at 5:59 AM <[email protected]> wrote:
From: Frank Chang <[email protected]>
This patchset implements the vector extension v0.9 for RISC-V on QEMU.
Quoted 8 lines
This patchset is sent as RFC because RVV v0.9 is still in draft state. However, as RVV v1.0 should be ratified soon and there shouldn't be critical changes between RVV v1.0 and RVV v0.9. We would like to have the community to review RVV v0.9 implementations. Once RVV v1.0 is ratified, we will then upgrade to RVV v1.0.
You can change the cpu argument:
vext_specto v0.9 (i.e. vext_spec=v0.9) to run with RVV v0.9 instructions.
Hello,
First off thanks for the patches!
QEMU has a policy of accepting draft specs as experimental. We currently support the v0.7.1 Vector extension for example, so this does not need to be an RFC and can be a full patch series that can be merged into master.
I have applied the first few patches (PR should be out next week) and they should be in the QEMU 5.1 release. QEMU is currently in a freeze so I won't be able to merge this series for 5.1. In saying that please feel free to continue to send patches to the list, they can still be reviewed.
In general we would need to gracefully handle extension upgrades and maintain backwards compatibility. This same principle doesn't apply to experimental features though (such as the vector extension) so you are free to remove support for the v0.7.1. For users who want v0.7.1 support they can always use the QEMU 5.1. release. Just make sure that your series does not break bisectability.
Thanks again for the patches!
Alistair
Quoted 100 lines
Chih-Min Chao (2):
fpu: fix float16 nan check
fpu: add api to handle alternative sNaN propagationFrank Chang (58):
target/riscv: fix rsub gvectcg_assert_listed_vecopassertion target/riscv: correct the gvec IR called ingen_vec_rsub16_i64()target/riscv: fix return value ofdo_opivx_widen()target/riscv: fix vill bit index in vtype register target/riscv: remove vsll.vi, vsrl.vi, vsra.vi insns from using gvec target/riscv: rvv-0.9: remove MLEN calculations target/riscv: rvv-0.9: add fractional LMUL, VTA and VMA target/riscv: rvv-0.9: update check functions target/riscv: rvv-0.9: configure instructions target/riscv: rvv-0.9: stride load and store instructions target/riscv: rvv-0.9: index load and store instructions target/riscv: rvv-0.9: fix address index overflow bug of indexed
load/store insns
target/riscv: rvv-0.9: fault-only-first unit stride load target/riscv: rvv-0.9: amo operations
target/riscv: rvv-0.9: load/store whole register instructions target/riscv: rvv-0.9: updatevext_max_elems()for load/store insns target/riscv: rvv-0.9: take fractional LMUL into vector max elements
calculation
target/riscv: rvv-0.9: floating-point square-root instruction target/riscv: rvv-0.9: floating-point classify instructions target/riscv: rvv-0.9: mask population count instruction target/riscv: rvv-0.9: find-first-set mask bit instruction target/riscv: rvv-0.9: set-X-first mask bit instructions target/riscv: rvv-0.9: iota instruction
target/riscv: rvv-0.9: element index instruction target/riscv: rvv-0.9: integer scalar move instructions target/riscv: rvv-0.9: floating-point scalar move instructions target/riscv: rvv-0.9: whole register move instructions target/riscv: rvv-0.9: integer extension instructions target/riscv: rvv-0.9: single-width averaging add and subtract
instructions
target/riscv: rvv-0.9: integer add-with-carry/subtract-with-borrow target/riscv: rvv-0.9: narrowing integer right shift instructions target/riscv: rvv-0.9: widening integer multiply-add instructions target/riscv: rvv-0.9: quad-widening integer multiply-add instructions target/riscv: rvv-0.9: integer merge and move instructions target/riscv: rvv-0.9: single-width saturating add and subtract
instructions
target/riscv: rvv-0.9: integer comparison instructions target/riscv: rvv-0.9: floating-point compare instructions target/riscv: rvv-0.9: single-width integer reduction instructions target/riscv: rvv-0.9: widening integer reduction instructions target/riscv: rvv-0.9: mask-register logical instructions target/riscv: rvv-0.9: register gather instructions target/riscv: rvv-0.9: slide instructions
target/riscv: rvv-0.9: floating-point slide instructions target/riscv: rvv-0.9: narrowing fixed-point clip instructions target/riscv: rvv-0.9: floating-point move instructions target/riscv: rvv-0.9: floating-point/integer type-convert
instructions
target/riscv: rvv-0.9: single-width floating-point reduction target/riscv: rvv-0.9: widening floating-point reduction instructions target/riscv: rvv-0.9: single-width scaling shift instructions target/riscv: rvv-0.9: remove widening saturating scaled multiply-add target/riscv: rvv-0.9: remove vmford.vv and vmford.vf target/riscv: rvv-0.9: remove integer extract instruction target/riscv: rvv-0.9: floating-point min/max instructions target/riscv: rvv-0.9: widening floating-point/integer type-convert target/riscv: rvv-0.9: narrowing floating-point/integer type-convert
softfloat: add fp16 and uint8/int8 interconvert functions target/riscv: use softfloat lib float16 comparison functions target/riscv: bump to RVV 0.9Kito Cheng (1):
fpu: implement full set compare for fp16LIU Zhiwei (4):
target/riscv: rvv-0.9: add vcsr register target/riscv: rvv-0.9: add vector context status target/riscv: rvv-0.9: updatemstatus_vsbytb_flagstarget/riscv: rvv-0.9: add vlenb registerfpu/softfloat-specialize.inc.c | 4 +- fpu/softfloat.c | 342 +++- include/fpu/softfloat.h | 22 + target/riscv/cpu.c | 9 +- target/riscv/cpu.h | 68 +- target/riscv/cpu_bits.h | 9 + target/riscv/cpu_helper.c | 13 + target/riscv/csr.c | 53 +- target/riscv/helper.h | 507 +++-- target/riscv/insn32-64.decode | 18 +- target/riscv/insn32.decode | 282 +-- target/riscv/insn_trans/trans_rvv.inc.c | 2468 ++++++++++++++--------- target/riscv/internals.h | 18 +- target/riscv/translate.c | 43 +- target/riscv/vector_helper.c | 2349 +++++++++++---------- 15 files changed, 3833 insertions(+), 2372 deletions(-)--
2.17.1
Quoted 37 lines · Alistair Francis
Quoted 5 lines · On Fri, Jul 10, 2020 at 5:59 AM <[email protected]> wrote:
From: Frank Chang <[email protected]>
This patchset implements the vector extension v0.9 for RISC-V on QEMU.
Quoted 8 lines
This patchset is sent as RFC because RVV v0.9 is still in draft state. However, as RVV v1.0 should be ratified soon and there shouldn't be critical changes between RVV v1.0 and RVV v0.9. We would like to have the community to review RVV v0.9 implementations. Once RVV v1.0 is ratified, we will then upgrade to RVV v1.0.
You can change the cpu argument:
vext_specto v0.9 (i.e. vext_spec=v0.9) to run with RVV v0.9 instructions.Hello,
First off thanks for the patches!
QEMU has a policy of accepting draft specs as experimental. We currently support the v0.7.1 Vector extension for example, so this does not need to be an RFC and can be a full patch series that can be merged into master.
I have applied the first few patches (PR should be out next week) and they should be in the QEMU 5.1 release. QEMU is currently in a freeze so I won't be able to merge this series for 5.1. In saying that please feel free to continue to send patches to the list, they can still be reviewed.
In general we would need to gracefully handle extension upgrades and maintain backwards compatibility. This same principle doesn't apply to experimental features though (such as the vector extension) so you are free to remove support for the v0.7.1. For users who want v0.7.1 support they can always use the QEMU 5.1. release. Just make sure that your series does not break bisectability.
Quoted 4 lines
Thanks again for the patches!
Alistair
Hi Alistair,
Thanks for the review.
Currently I would prefer to drop 0.7.1 support because I don't know if there's
a good way to keep both 0.7.1 and 0.9 opcodes. I'm afraid it would cause the encoding overlap while compiling with decodetree.
Does decodetree support any feature for multi-version opcodes? Or if it can use something like C macros to compile with the opcodes by the vspec
user assigned? If there's any good way to keep both versions, then I can try to rearrange
my codes to support both vspecs.
Otherwise, I'll keep on my current approach to drop the support of v0.7.1 as the way
Richard has mentioned:
*If you don't want to simultaneously support 0.7.1 and 0.9/1.0, then you should*
*simply remove 0.7.1 in the first patch, so that there's no confusion.*
Any suggestion would be appreciated.
Thanks
--
Frank Chang
Quoted 101 lines
Quoted 100 lines
Chih-Min Chao (2):
fpu: fix float16 nan check
fpu: add api to handle alternative sNaN propagationFrank Chang (58):
target/riscv: fix rsub gvectcg_assert_listed_vecopassertion target/riscv: correct the gvec IR called ingen_vec_rsub16_i64()target/riscv: fix return value ofdo_opivx_widen()target/riscv: fix vill bit index in vtype register target/riscv: remove vsll.vi, vsrl.vi, vsra.vi insns from using gvec target/riscv: rvv-0.9: remove MLEN calculations target/riscv: rvv-0.9: add fractional LMUL, VTA and VMA target/riscv: rvv-0.9: update check functions target/riscv: rvv-0.9: configure instructions target/riscv: rvv-0.9: stride load and store instructions target/riscv: rvv-0.9: index load and store instructions target/riscv: rvv-0.9: fix address index overflow bug of indexed
load/store insns
target/riscv: rvv-0.9: fault-only-first unit stride load target/riscv: rvv-0.9: amo operations
target/riscv: rvv-0.9: load/store whole register instructions target/riscv: rvv-0.9: updatevext_max_elems()for load/store insns target/riscv: rvv-0.9: take fractional LMUL into vector max elements
calculation
target/riscv: rvv-0.9: floating-point square-root instruction target/riscv: rvv-0.9: floating-point classify instructions target/riscv: rvv-0.9: mask population count instruction target/riscv: rvv-0.9: find-first-set mask bit instruction target/riscv: rvv-0.9: set-X-first mask bit instructions target/riscv: rvv-0.9: iota instruction
target/riscv: rvv-0.9: element index instruction target/riscv: rvv-0.9: integer scalar move instructions target/riscv: rvv-0.9: floating-point scalar move instructions target/riscv: rvv-0.9: whole register move instructions target/riscv: rvv-0.9: integer extension instructions target/riscv: rvv-0.9: single-width averaging add and subtract
instructions
target/riscv: rvv-0.9: integer add-with-carry/subtract-with-borrow target/riscv: rvv-0.9: narrowing integer right shift instructions target/riscv: rvv-0.9: widening integer multiply-add instructions target/riscv: rvv-0.9: quad-widening integer multiply-add instructions target/riscv: rvv-0.9: integer merge and move instructions target/riscv: rvv-0.9: single-width saturating add and subtract
instructions
target/riscv: rvv-0.9: integer comparison instructions target/riscv: rvv-0.9: floating-point compare instructions target/riscv: rvv-0.9: single-width integer reduction instructions target/riscv: rvv-0.9: widening integer reduction instructions target/riscv: rvv-0.9: mask-register logical instructions target/riscv: rvv-0.9: register gather instructions target/riscv: rvv-0.9: slide instructions
target/riscv: rvv-0.9: floating-point slide instructions target/riscv: rvv-0.9: narrowing fixed-point clip instructions target/riscv: rvv-0.9: floating-point move instructions target/riscv: rvv-0.9: floating-point/integer type-convert
instructions
target/riscv: rvv-0.9: single-width floating-point reduction target/riscv: rvv-0.9: widening floating-point reduction instructions target/riscv: rvv-0.9: single-width scaling shift instructions target/riscv: rvv-0.9: remove widening saturating scaled multiply-add target/riscv: rvv-0.9: remove vmford.vv and vmford.vf target/riscv: rvv-0.9: remove integer extract instruction target/riscv: rvv-0.9: floating-point min/max instructions target/riscv: rvv-0.9: widening floating-point/integer type-convert target/riscv: rvv-0.9: narrowing floating-point/integer type-convert
softfloat: add fp16 and uint8/int8 interconvert functions target/riscv: use softfloat lib float16 comparison functions target/riscv: bump to RVV 0.9Kito Cheng (1):
fpu: implement full set compare for fp16LIU Zhiwei (4):
target/riscv: rvv-0.9: add vcsr register target/riscv: rvv-0.9: add vector context status target/riscv: rvv-0.9: updatemstatus_vsbytb_flagstarget/riscv: rvv-0.9: add vlenb registerfpu/softfloat-specialize.inc.c | 4 +- fpu/softfloat.c | 342 +++- include/fpu/softfloat.h | 22 + target/riscv/cpu.c | 9 +- target/riscv/cpu.h | 68 +- target/riscv/cpu_bits.h | 9 + target/riscv/cpu_helper.c | 13 + target/riscv/csr.c | 53 +- target/riscv/helper.h | 507 +++-- target/riscv/insn32-64.decode | 18 +- target/riscv/insn32.decode | 282 +-- target/riscv/insn_trans/trans_rvv.inc.c | 2468 ++++++++++++++--------- target/riscv/internals.h | 18 +- target/riscv/translate.c | 43 +- target/riscv/vector_helper.c | 2349 +++++++++++---------- 15 files changed, 3833 insertions(+), 2372 deletions(-)--
2.17.1
Quoted 45 lines · Frank Chang
Quoted 38 lines · Alistair Francis
Quoted 5 lines · On Fri, Jul 10, 2020 at 5:59 AM <[email protected]> wrote:
From: Frank Chang <[email protected]>
This patchset implements the vector extension v0.9 for RISC-V on QEMU.
Quoted 8 lines
This patchset is sent as RFC because RVV v0.9 is still in draft state. However, as RVV v1.0 should be ratified soon and there shouldn't be critical changes between RVV v1.0 and RVV v0.9. We would like to have the community to review RVV v0.9 implementations. Once RVV v1.0 is ratified, we will then upgrade to RVV v1.0.
You can change the cpu argument:
vext_specto v0.9 (i.e. vext_spec=v0.9) to run with RVV v0.9 instructions.Hello,
First off thanks for the patches!
QEMU has a policy of accepting draft specs as experimental. We currently support the v0.7.1 Vector extension for example, so this does not need to be an RFC and can be a full patch series that can be merged into master.
I have applied the first few patches (PR should be out next week) and they should be in the QEMU 5.1 release. QEMU is currently in a freeze so I won't be able to merge this series for 5.1. In saying that please feel free to continue to send patches to the list, they can still be reviewed.
In general we would need to gracefully handle extension upgrades and maintain backwards compatibility. This same principle doesn't apply to experimental features though (such as the vector extension) so you are free to remove support for the v0.7.1. For users who want v0.7.1 support they can always use the QEMU 5.1. release. Just make sure that your series does not break bisectability.
Quoted 3 lines
Thanks again for the patches!
Alistair
Quoted 7 lines
Hi Alistair,
Thanks for the review.
Currently I would prefer to drop 0.7.1 support because I don't know if there's a good way to keep both 0.7.1 and 0.9 opcodes. I'm afraid it would cause the encoding overlap while compiling with decodetree.
That's fine. The plan was always to only support one version of a draft extension (and none when the final spec is frozen).
Quoted 2 lines
Does decodetree support any feature for multi-version opcodes?
I'm not sure, but we don't want to deal with the maintenance burden of two draft extensions anyway.
Quoted 8 lines
Or if it can use something like C macros to compile with the opcodes by the vspec user assigned? If there's any good way to keep both versions, then I can try to rearrange my codes to support both vspecs.
Otherwise, I'll keep on my current approach to drop the support of v0.7.1 as the way Richard has mentioned:
If you don't want to simultaneously support 0.7.1 and 0.9/1.0, then you should simply remove 0.7.1 in the first patch, so that there's no confusion.
That sounds good :)
Alistair
Quoted 108 lines
Any suggestion would be appreciated.
Thanks
--
Frank ChangQuoted 101 lines
Quoted 101 lines
Chih-Min Chao (2):
fpu: fix float16 nan check
fpu: add api to handle alternative sNaN propagationFrank Chang (58):
target/riscv: fix rsub gvectcg_assert_listed_vecopassertion target/riscv: correct the gvec IR called ingen_vec_rsub16_i64()target/riscv: fix return value ofdo_opivx_widen()target/riscv: fix vill bit index in vtype register target/riscv: remove vsll.vi, vsrl.vi, vsra.vi insns from using gvec target/riscv: rvv-0.9: remove MLEN calculations target/riscv: rvv-0.9: add fractional LMUL, VTA and VMA target/riscv: rvv-0.9: update check functions target/riscv: rvv-0.9: configure instructions target/riscv: rvv-0.9: stride load and store instructions target/riscv: rvv-0.9: index load and store instructions target/riscv: rvv-0.9: fix address index overflow bug of indexed
load/store insns
target/riscv: rvv-0.9: fault-only-first unit stride load target/riscv: rvv-0.9: amo operations
target/riscv: rvv-0.9: load/store whole register instructions target/riscv: rvv-0.9: updatevext_max_elems()for load/store insns target/riscv: rvv-0.9: take fractional LMUL into vector max elements
calculation
target/riscv: rvv-0.9: floating-point square-root instruction target/riscv: rvv-0.9: floating-point classify instructions target/riscv: rvv-0.9: mask population count instruction target/riscv: rvv-0.9: find-first-set mask bit instruction target/riscv: rvv-0.9: set-X-first mask bit instructions target/riscv: rvv-0.9: iota instruction
target/riscv: rvv-0.9: element index instruction target/riscv: rvv-0.9: integer scalar move instructions target/riscv: rvv-0.9: floating-point scalar move instructions target/riscv: rvv-0.9: whole register move instructions target/riscv: rvv-0.9: integer extension instructions target/riscv: rvv-0.9: single-width averaging add and subtract
instructions
target/riscv: rvv-0.9: integer add-with-carry/subtract-with-borrow target/riscv: rvv-0.9: narrowing integer right shift instructions target/riscv: rvv-0.9: widening integer multiply-add instructions target/riscv: rvv-0.9: quad-widening integer multiply-add instructions target/riscv: rvv-0.9: integer merge and move instructions target/riscv: rvv-0.9: single-width saturating add and subtract
instructions
target/riscv: rvv-0.9: integer comparison instructions target/riscv: rvv-0.9: floating-point compare instructions target/riscv: rvv-0.9: single-width integer reduction instructions target/riscv: rvv-0.9: widening integer reduction instructions target/riscv: rvv-0.9: mask-register logical instructions target/riscv: rvv-0.9: register gather instructions target/riscv: rvv-0.9: slide instructions
target/riscv: rvv-0.9: floating-point slide instructions target/riscv: rvv-0.9: narrowing fixed-point clip instructions target/riscv: rvv-0.9: floating-point move instructions target/riscv: rvv-0.9: floating-point/integer type-convert
instructions
target/riscv: rvv-0.9: single-width floating-point reduction target/riscv: rvv-0.9: widening floating-point reduction instructions target/riscv: rvv-0.9: single-width scaling shift instructions target/riscv: rvv-0.9: remove widening saturating scaled multiply-add target/riscv: rvv-0.9: remove vmford.vv and vmford.vf target/riscv: rvv-0.9: remove integer extract instruction target/riscv: rvv-0.9: floating-point min/max instructions target/riscv: rvv-0.9: widening floating-point/integer type-convert target/riscv: rvv-0.9: narrowing floating-point/integer type-convert
softfloat: add fp16 and uint8/int8 interconvert functions target/riscv: use softfloat lib float16 comparison functions target/riscv: bump to RVV 0.9Kito Cheng (1):
fpu: implement full set compare for fp16LIU Zhiwei (4):
target/riscv: rvv-0.9: add vcsr register target/riscv: rvv-0.9: add vector context status target/riscv: rvv-0.9: updatemstatus_vsbytb_flagstarget/riscv: rvv-0.9: add vlenb registerfpu/softfloat-specialize.inc.c | 4 +- fpu/softfloat.c | 342 +++- include/fpu/softfloat.h | 22 + target/riscv/cpu.c | 9 +- target/riscv/cpu.h | 68 +- target/riscv/cpu_bits.h | 9 + target/riscv/cpu_helper.c | 13 + target/riscv/csr.c | 53 +- target/riscv/helper.h | 507 +++-- target/riscv/insn32-64.decode | 18 +- target/riscv/insn32.decode | 282 +-- target/riscv/insn_trans/trans_rvv.inc.c | 2468 ++++++++++++++--------- target/riscv/internals.h | 18 +- target/riscv/translate.c | 43 +- target/riscv/vector_helper.c | 2349 +++++++++++---------- 15 files changed, 3833 insertions(+), 2372 deletions(-)--
2.17.1
Quoted 5 lines · Frank Chang
Does decodetree support any feature for multi-version opcodes?
Or if it can use something like C macros to compile with the opcodes by the vspec user assigned? If there's any good way to keep both versions, then I can try to rearrange
my codes to support both vspecs.
There is a way, using { } to indicate where overlap is allowed. The trans_* functions checks the ISA version, and return false. Which causes the next matching overlapping pattern to be used, etc. Have a look at some of the ARM decodetree files.
But since Alisair is happy dropping 0.7.1 support, we should do that. It will be cleaner not to have to retain the backward compatibility.
r~
Quoted 16 lines · Richard Henderson
Quoted 2 lines · Frank Chang
Does decodetree support any feature for multi-version opcodes? Or if it can use something like C macros to compile with the opcodes by
the vspec
Quoted 1 line
user assigned? If there's any good way to keep both versions, then I can
try to
Quoted 2 lines
rearrange
my codes to support both vspecs.There is a way, using { } to indicate where overlap is allowed. The trans_*
functions checks the ISA version, and return false. Which causes the next matching overlapping pattern to be used, etc. Have a look at some of the ARM
decodetree files.
Quoted 7 lines
But since Alisair is happy dropping 0.7.1 support, we should do that. It will
be cleaner not to have to retain the backward compatibility.r~
That makes sense to me.
Thanks to Alisair and Richard's feedback.
Frank Chang