support vector extension v1.0
v4 cover support vector extension v1.0
From: Frank Chang <[email protected]>
This patchset implements the vector extension v1.0 for RISC-V on QEMU.
This patchset is sent as RFC because RVV v1.0 is still in draft state. v2 patchset was sent for RVV v0.9 and bumped to RVV v1.0 since v3 patchset.
The port is available here:
https://github.com/sifive/qemu/tree/rvv-1.0-upstream-v4
You can change the cpu argument: vext_spec to v1.0 (i.e. vext_spec=v1.0) to run with RVV v1.0 instructions.
Note: This patchset depends on two other patchsets listed in Based-on
section below so it might not able to be built unless those two patchsets are applied.
Changelog:
v4
* remove explicit float flmul variable in DisasContext.
* replace floating-point calculations with shift operations to improve performance.
* relax RV_VLEN_MAX to 512-bits.
v3
* apply nan-box helpers from Richard Henderson.
* remove fp16 api changes as they are sent independently in another pathcset by Chih-Min Chao.
* remove all tail elements clear functions as tail elements can retain unchanged for either VTA set to undisturbed or agnostic.
* add fp16 nan-box check generator function.
* add floating-point rounding mode enum.
* replace flmul arithmetic with shifts to avoid floating-point conversions.
* add Zvqmac extension.
* replace gdbstub vector register xml files with dynamic generator.
* bumped to RVV v1.0.
* RVV v1.0 related changes:
* add vl<nf>re<eew>.v and vs<nf>r.v vector whole register load/store instructions
* add vrgatherei16 instruction.
* rearranged bits in vtype to make vlmul bits into a contiguous field.
v2
* drop v0.7.1 support.
* replace invisible return check macros with functions.
* move mark_vs_dirty() to translators.
* add SSTATUS_VS flag for s-mode.
* nan-box scalar fp register for floating-point operations.
* add gdbstub files for vector registers to allow system-mode debugging with GDB.
Based-on: <[email protected]/>
Based-on: <[email protected]/>
Frank Chang (62):
target/riscv: drop vector 0.7.1 and add 1.0 support target/riscv: Use FIELD_EX32() to extract wd field target/riscv: rvv-1.0: introduce writable misa.v field target/riscv: rvv-1.0: remove rvv related codes from fcsr registers target/riscv: rvv-1.0: check MSTATUS_VS when accessing vector csr
registers
target/riscv: rvv-1.0: remove MLEN calculations target/riscv: rvv-1.0: add fractional LMUL
target/riscv: rvv-1.0: add VMA and VTA
target/riscv: rvv-1.0: update check functions target/riscv: introduce more imm value modes in translator functions target/riscv: rvv:1.0: add translation-time nan-box helper function target/riscv: rvv-1.0: configure instructions target/riscv: rvv-1.0: stride load and store instructions target/riscv: rvv-1.0: index load and store instructions target/riscv: rvv-1.0: fix address index overflow bug of indexed
load/store insns
target/riscv: rvv-1.0: fault-only-first unit stride load target/riscv: rvv-1.0: amo operations
target/riscv: rvv-1.0: load/store whole register instructions target/riscv: rvv-1.0: update vext_max_elems() for load/store insns target/riscv: rvv-1.0: take fractional LMUL into vector max elements
calculation
target/riscv: rvv-1.0: floating-point square-root instruction target/riscv: rvv-1.0: floating-point classify instructions target/riscv: rvv-1.0: mask population count instruction target/riscv: rvv-1.0: find-first-set mask bit instruction target/riscv: rvv-1.0: set-X-first mask bit instructions target/riscv: rvv-1.0: iota instruction
target/riscv: rvv-1.0: element index instruction target/riscv: rvv-1.0: allow load element with sign-extended target/riscv: rvv-1.0: register gather instructions target/riscv: rvv-1.0: integer scalar move instructions target/riscv: rvv-1.0: floating-point move instruction target/riscv: rvv-1.0: floating-point scalar move instructions target/riscv: rvv-1.0: whole register move instructions target/riscv: rvv-1.0: integer extension instructions target/riscv: rvv-1.0: single-width averaging add and subtract
instructions
target/riscv: rvv-1.0: single-width bit shift instructions target/riscv: rvv-1.0: integer add-with-carry/subtract-with-borrow target/riscv: rvv-1.0: narrowing integer right shift instructions target/riscv: rvv-1.0: widening integer multiply-add instructions target/riscv: rvv-1.0: add Zvqmac extension
target/riscv: rvv-1.0: quad-widening integer multiply-add instructions target/riscv: rvv-1.0: single-width saturating add and subtract
instructions
target/riscv: rvv-1.0: integer comparison instructions target/riscv: use softfloat lib float16 comparison functions target/riscv: rvv-1.0: floating-point compare instructions target/riscv: rvv-1.0: mask-register logical instructions target/riscv: rvv-1.0: slide instructions
target/riscv: rvv-1.0: floating-point slide instructions target/riscv: rvv-1.0: narrowing fixed-point clip instructions target/riscv: rvv-1.0: single-width floating-point reduction target/riscv: rvv-1.0: widening floating-point reduction instructions target/riscv: rvv-1.0: single-width scaling shift instructions target/riscv: rvv-1.0: remove widening saturating scaled multiply-add target/riscv: rvv-1.0: remove vmford.vv and vmford.vf target/riscv: rvv-1.0: remove integer extract instruction target/riscv: rvv-1.0: floating-point min/max instructions target/riscv: introduce floating-point rounding mode enum target/riscv: rvv-1.0: floating-point/integer type-convert
instructions
target/riscv: rvv-1.0: widening floating-point/integer type-convert target/riscv: add "set round to odd" rounding mode helper function target/riscv: rvv-1.0: narrowing floating-point/integer type-convert target/riscv: rvv-1.0: relax RV_VLEN_MAX to 512-bits
Greentime Hu (2):
target/riscv: rvv-1.0: add vlenb register target/riscv: gdb: support vector registers for rv32
Hsiangkai Wang (2):
target/riscv: gdb: modify gdb csr xml file to align with csr register
map
target/riscv: gdb: support vector registers for rv64
LIU Zhiwei (4):
target/riscv: rvv-1.0: add mstatus VS field target/riscv: rvv-1.0: add sstatus VS field target/riscv: rvv-1.0: add translation-time vector context status target/riscv: rvv-1.0: add vcsr register
gdb-xml/riscv-32bit-csr.xml | 18 +- gdb-xml/riscv-64bit-csr.xml | 18 +- target/riscv/cpu.c | 12 +- target/riscv/cpu.h | 97 +- target/riscv/cpu_bits.h | 10 + target/riscv/cpu_helper.c | 16 +- target/riscv/csr.c | 73 +- target/riscv/fpu_helper.c | 17 +- target/riscv/gdbstub.c | 126 +- target/riscv/helper.h | 523 ++-- target/riscv/insn32-64.decode | 18 +- target/riscv/insn32.decode | 295 +- target/riscv/insn_trans/trans_rvv.inc.c | 2366 ++++++++++------ target/riscv/internals.h | 19 +- target/riscv/translate.c | 68 +- target/riscv/vector_helper.c | 3269 +++++++++++------------ 16 files changed, 4051 insertions(+), 2894 deletions(-)
--
2.17.1
RFC v4 1/70 target/riscv: drop vector 0.7.1 and add 1.0 support
From: Frank Chang <[email protected]>
--- target/riscv/cpu.c | 10 +++++----- target/riscv/cpu.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
target/riscv/cpu.c +5 -5
@@ -339,7 +339,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_1_00_0 ;target_ulong target_misa =0 ;Error *local_err =NULL ;
@@ -455,8 +455,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,"v1.0" )) { + vext_version =VEXT_VERSION_1_00_0 ; }else { error_setg(errp, "Unsupported vector spec version '%s'",
@@ -464,8 +464,8 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)return ; } }else { -qemu_log ("vector verison is not specified, " -"use the default value v0.7.1\n" ); +qemu_log ("vector version is not specified, " +"use the default value v1.0\n" ); }set_vext_version (env, vext_version); }
target/riscv/cpu.h +1 -1
@@ -79,7 +79,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_1_00_0 0x00010000#define TRANSLATE_PMP_FAIL 2#define TRANSLATE_FAIL 1
Signature · 1 line
2.17.1
RFC v4 2/70 target/riscv: Use FIELD_EX32() to extract wd field
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/vector_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/vector_helper.c +1 -1
@@ -98,7 +98,7 @@ static inline uint32_t vext_lmul(uint32_t desc)static uint32_t vext_wd (uint32_t desc) { -return (simd_data (desc) >>11 ) &0x1 ; +return FIELD_EX32 (simd_data (desc),VDATA ,WD ); }/*
Signature · 1 line
2.17.1
RFC v4 3/70 target/riscv: rvv-1.0: add mstatus VS field
In reply to [email protected]From: LIU Zhiwei <[email protected]>
--- target/riscv/cpu.h | 6 ++++++ target/riscv/cpu_bits.h | 1 + target/riscv/cpu_helper.c | 16 +++++++++++++++- target/riscv/csr.c | 25 ++++++++++++++++++++++++- 4 files changed, 46 insertions(+), 2 deletions(-)
target/riscv/cpu.h +6 -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);
@@ -360,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 ;
@@ -410,11 +412,15 @@ 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)) { 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
@@ -367,6 +367,7 @@#define MSTATUS_SPIE 0x00000020#define MSTATUS_MPIE 0x00000080#define MSTATUS_SPP 0x00000100 +#define MSTATUS_VS 0x00000600#define MSTATUS_MPP 0x00001800#define MSTATUS_FS 0x00006000#define MSTATUS_XS 0x00018000
target/riscv/cpu_helper.c +15 -1
@@ -108,10 +108,24 @@ 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 | -MSTATUS_SPP |MSTATUS_SPIE |MSTATUS_SIE ; +MSTATUS_SPP |MSTATUS_SPIE |MSTATUS_SIE | +MSTATUS_VS ;bool current_virt =riscv_cpu_virt_enabled (env);g_assert (riscv_has_ext (env,RVH ));
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 ; }
@@ -400,7 +422,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
@@ -412,6 +434,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;
Signature · 1 line
2.17.1
RFC v4 4/70 target/riscv: rvv-1.0: add sstatus VS field
In reply to [email protected]From: LIU Zhiwei <[email protected]>
--- target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
target/riscv/cpu_bits.h +1 -0
@@ -422,6 +422,7 @@#define SSTATUS_UPIE 0x00000010#define SSTATUS_SPIE 0x00000020#define SSTATUS_SPP 0x00000100 +#define SSTATUS_VS 0x00000600#define SSTATUS_FS 0x00006000#define SSTATUS_XS 0x00018000#define SSTATUS_PUM 0x00040000/* until: priv-1.9.1 */
target/riscv/csr.c +1 -1
@@ -365,7 +365,7 @@ static const target_ulong delegable_excps = (1ULL << (RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT ));static const target_ulong sstatus_v1_10_mask =SSTATUS_SIE |SSTATUS_SPIE |SSTATUS_UIE |SSTATUS_UPIE |SSTATUS_SPP |SSTATUS_FS |SSTATUS_XS | -SSTATUS_SUM |SSTATUS_MXR |SSTATUS_SD ; +SSTATUS_SUM |SSTATUS_MXR |SSTATUS_SD |SSTATUS_VS ;static const target_ulong sip_writable_mask =SIP_SSIP |MIP_USIP |MIP_UEIP ;static const target_ulong hip_writable_mask =MIP_VSSIP |MIP_VSTIP |MIP_VSEIP ;static const target_ulong vsip_writable_mask =MIP_VSSIP ;
Signature · 1 line
2.17.1
RFC v4 5/70 target/riscv: rvv-1.0: introduce writable misa.v field
In reply to [email protected]From: Frank Chang <[email protected]>
Implementations may have a writable misa.v field. Analogous to the way in which the floating-point unit is handled, the mstatus.vs field may exist even if misa.v is clear.
--- target/riscv/csr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/csr.c +1 -1
@@ -494,7 +494,7 @@ static int write_misa(CPURISCVState *env, int csrno, target_ulong val) val &= env->misa_mask;/* Mask extensions that are not supported by QEMU */ - val &= (RVI |RVE |RVM |RVA |RVF |RVD |RVC |RVS |RVU ); + val &= (RVI |RVE |RVM |RVA |RVF |RVD |RVC |RVS |RVU |RVV );/* 'D' depends on 'F', so clear 'D' if 'F' is not present */ if ((val &RVD ) && !(val &RVF )) {
Signature · 1 line
2.17.1
RFC v4 6/70 target/riscv: rvv-1.0: add translation-time vector context status
In reply to [email protected]From: LIU Zhiwei <[email protected]>
--- target/riscv/insn_trans/trans_rvv.inc.c | 69 ++++++++++++++++++++----- target/riscv/translate.c | 33 ++++++++++++ 2 files changed, 90 insertions(+), 12 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +57 -12
@@ -48,6 +48,7 @@ static bool trans_vsetvl(DisasContext *ctx, arg_vsetvl *a)tcg_temp_free (s1);tcg_temp_free (s2);tcg_temp_free (dst); +mark_vs_dirty (ctx);return true; }
@@ -78,6 +79,7 @@ static bool trans_vsetvli(DisasContext *ctx, arg_vsetvli *a)tcg_temp_free (s1);tcg_temp_free (s2);tcg_temp_free (dst); +mark_vs_dirty (ctx);return true; }
@@ -163,7 +165,8 @@ typedef void gen_helper_ldst_us(TCGv_ptr, TCGv_ptr, TCGv, TCGv_env, TCGv_i32);static bool ldst_us_trans (uint32_t vd,uint32_t rs1,uint32_t data, -gen_helper_ldst_us *fn,DisasContext *s) +gen_helper_ldst_us *fn,DisasContext *s, +bool is_store) {TCGv_ptr dest, mask;TCGv base;
@@ -195,6 +198,9 @@ static bool ldst_us_trans(uint32_t vd, uint32_t rs1, uint32_t data,tcg_temp_free_ptr (mask);tcg_temp_free (base);tcg_temp_free_i32 (desc); +if (!is_store) { +mark_vs_dirty (s); + }gen_set_label (over);return true; }
@@ -245,7 +251,7 @@ 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); +return ldst_us_trans (a->rd, a->rs1, data, fn, s, false); }static bool ld_us_check (DisasContext *s,arg_r2nfvm * a)
@@ -298,7 +304,7 @@ static bool st_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); +return ldst_us_trans (a->rd, a->rs1, data, fn, s, true); }static bool st_us_check (DisasContext *s,arg_r2nfvm * a)
@@ -321,7 +327,7 @@ typedef void gen_helper_ldst_stride(TCGv_ptr, TCGv_ptr, TCGv,static bool ldst_stride_trans (uint32_t vd,uint32_t rs1,uint32_t rs2,uint32_t data,gen_helper_ldst_stride *fn, -DisasContext *s) +DisasContext *s,bool is_store) {TCGv_ptr dest, mask;TCGv base, stride;
@@ -348,6 +354,9 @@ static bool ldst_stride_trans(uint32_t vd, uint32_t rs1, uint32_t rs2,tcg_temp_free (base);tcg_temp_free (stride);tcg_temp_free_i32 (desc); +if (!is_store) { +mark_vs_dirty (s); + }gen_set_label (over);return true; }
@@ -382,7 +391,7 @@ 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); +return ldst_stride_trans (a->rd, a->rs1, a->rs2, data, fn, s, false); }static bool ld_stride_check (DisasContext *s,arg_rnfvm * a)
@@ -426,7 +435,7 @@ static bool st_stride_op(DisasContext *s, arg_rnfvm *a, uint8_t seq)return false; } -return ldst_stride_trans (a->rd, a->rs1, a->rs2, data, fn, s); +return ldst_stride_trans (a->rd, a->rs1, a->rs2, data, fn, s, true); }static bool st_stride_check (DisasContext *s,arg_rnfvm * a)
@@ -449,7 +458,7 @@ typedef void gen_helper_ldst_index(TCGv_ptr, TCGv_ptr, TCGv,static bool ldst_index_trans (uint32_t vd,uint32_t rs1,uint32_t vs2,uint32_t data,gen_helper_ldst_index *fn, -DisasContext *s) +DisasContext *s,bool is_store) {TCGv_ptr dest, mask, index;TCGv base;
@@ -476,6 +485,9 @@ static bool ldst_index_trans(uint32_t vd, uint32_t rs1, uint32_t vs2,tcg_temp_free_ptr (index);tcg_temp_free (base);tcg_temp_free_i32 (desc); +if (!is_store) { +mark_vs_dirty (s); + }gen_set_label (over);return true; }
@@ -510,7 +522,7 @@ 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); +return ldst_index_trans (a->rd, a->rs1, a->rs2, data, fn, s, false); }/*
@@ -562,7 +574,7 @@ static bool st_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); +return ldst_index_trans (a->rd, a->rs1, a->rs2, data, fn, s, true); }static bool st_index_check (DisasContext *s,arg_rnfvm * a)
@@ -606,6 +618,7 @@ static bool ldff_trans(uint32_t vd, uint32_t rs1, uint32_t data,tcg_temp_free_ptr (mask);tcg_temp_free (base);tcg_temp_free_i32 (desc); +mark_vs_dirty (s);gen_set_label (over);return true; }
@@ -685,6 +698,7 @@ static bool amo_trans(uint32_t vd, uint32_t rs1, uint32_t vs2,tcg_temp_free_ptr (index);tcg_temp_free (base);tcg_temp_free_i32 (desc); +mark_vs_dirty (s);gen_set_label (over);return true; }
@@ -832,6 +846,7 @@ do_opivv_gvec(DisasContext *s, arg_rmrr *a, GVecGen3Fn *gvec_fn,vreg_ofs (s, a->rs1),vreg_ofs (s, a->rs2), cpu_env, 0, s->vlen / 8, data, fn); } +mark_vs_dirty (s);gen_set_label (over);return true; }
@@ -886,6 +901,7 @@ static bool opivx_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, uint32_t vm,tcg_temp_free_ptr (src2);tcg_temp_free (src1);tcg_temp_free_i32 (desc); +mark_vs_dirty (s);gen_set_label (over);return true; }
@@ -920,6 +936,7 @@ 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);
@@ -1033,6 +1050,7 @@ static bool opivi_trans(uint32_t vd, uint32_t imm, uint32_t vs2, uint32_t vm,tcg_temp_free_ptr (src2);tcg_temp_free (src1);tcg_temp_free_i32 (desc); +mark_vs_dirty (s);gen_set_label (over);return true; }
@@ -1056,10 +1074,10 @@ do_opivi_gvec(DisasContext *s, arg_rmrr *a, GVecGen2iFn *gvec_fn,gvec_fn (s->sew,vreg_ofs (s, a->rd),vreg_ofs (s, a->rs2),sextract64 (a->rs1,0 ,5 ),MAXSZ (s),MAXSZ (s)); } - }else { -return opivi_trans (a->rd, a->rs1, a->rs2, a->vm, fn, s, zx); +mark_vs_dirty (s); +return true; } -return true; +return opivi_trans (a->rd, a->rs1, a->rs2, a->vm, fn, s, zx); }/* OPIVI with GVEC IR */
@@ -1120,6 +1138,7 @@ static bool do_opivv_widen(DisasContext *s, arg_rmrr *a,vreg_ofs (s, a->rs2), cpu_env,0 , s->vlen /8 , data, fn); +mark_vs_dirty (s);gen_set_label (over);return true; }
@@ -1207,6 +1226,7 @@ static bool do_opiwv_widen(DisasContext *s, arg_rmrr *a,vreg_ofs (s, a->rs1),vreg_ofs (s, a->rs2), cpu_env, 0, s->vlen / 8, data, fn); +mark_vs_dirty (s);gen_set_label (over);return true; }
@@ -1285,6 +1305,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \vreg_ofs (s, a->rs1), \vreg_ofs (s, a->rs2), cpu_env,0 , \ s->vlen / 8, data, fns[s->sew]); \ +mark_vs_dirty (s); \gen_set_label (over); \return true; \ } \
@@ -1416,6 +1437,7 @@ do_opivx_gvec_shift(DisasContext *s, arg_rmrr *a, GVecGen2sFn32 *gvec_fn,tcg_temp_free_i32 (src1);tcg_temp_free (tmp); +mark_vs_dirty (s);return true; }return opivx_trans (a->rd, a->rs1, a->rs2, a->vm, fn, s);
@@ -1474,6 +1496,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \vreg_ofs (s, a->rs1), \vreg_ofs (s, a->rs2), cpu_env,0 , \ s->vlen / 8, data, fns[s->sew]); \ +mark_vs_dirty (s); \gen_set_label (over); \return true; \ } \
@@ -1657,6 +1680,7 @@ static bool trans_vmv_v_v(DisasContext *s, arg_vmv_v_v *a) cpu_env, 0, s->vlen / 8, data, fns[s->sew]);gen_set_label (over); } +mark_vs_dirty (s);return true; }return false;
@@ -1699,6 +1723,7 @@ static bool trans_vmv_v_x(DisasContext *s, arg_vmv_v_x *a) }tcg_temp_free (s1); +mark_vs_dirty (s);gen_set_label (over);return true; }
@@ -1714,6 +1739,7 @@ static bool trans_vmv_v_i(DisasContext *s, arg_vmv_v_i *a)if (s->vl_eq_vlmax) {tcg_gen_gvec_dup_imm (s->sew,vreg_ofs (s, a->rd),MAXSZ (s),MAXSZ (s), simm); +mark_vs_dirty (s); }else {TCGv_i32 desc;TCGv_i64 s1;
@@ -1735,6 +1761,7 @@ static bool trans_vmv_v_i(DisasContext *s, arg_vmv_v_i *a)tcg_temp_free_ptr (dest);tcg_temp_free_i32 (desc);tcg_temp_free_i64 (s1); +mark_vs_dirty (s);gen_set_label (over); }return true;
@@ -1839,6 +1866,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \vreg_ofs (s, a->rs1), \vreg_ofs (s, a->rs2), cpu_env,0 , \ s->vlen / 8, data, fns[s->sew - 1]); \ +mark_vs_dirty (s); \gen_set_label (over); \return true; \ } \
@@ -1874,6 +1902,7 @@ static bool opfvf_trans(uint32_t vd, uint32_t rs1, uint32_t vs2,tcg_temp_free_ptr (mask);tcg_temp_free_ptr (src2);tcg_temp_free_i32 (desc); +mark_vs_dirty (s);gen_set_label (over);return true; }
@@ -1951,6 +1980,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \vreg_ofs (s, a->rs1), \vreg_ofs (s, a->rs2), cpu_env,0 , \ s->vlen / 8, data, fns[s->sew - 1]); \ +mark_vs_dirty (s); \gen_set_label (over); \return true; \ } \
@@ -2025,6 +2055,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \vreg_ofs (s, a->rs1), \vreg_ofs (s, a->rs2), cpu_env,0 , \ s->vlen / 8, data, fns[s->sew - 1]); \ +mark_vs_dirty (s); \gen_set_label (over); \return true; \ } \
@@ -2139,6 +2170,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \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, fns[s->sew -1 ]); \ +mark_vs_dirty (s); \gen_set_label (over); \return true; \ } \
@@ -2211,6 +2243,7 @@ static bool trans_vfmv_v_f(DisasContext *s, arg_vfmv_v_f *a)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]); +mark_vs_dirty (s); }else {TCGv_ptr dest;TCGv_i32 desc;
@@ -2230,6 +2263,7 @@ static bool trans_vfmv_v_f(DisasContext *s, arg_vfmv_v_f *a)tcg_temp_free_ptr (dest);tcg_temp_free_i32 (desc); +mark_vs_dirty (s);gen_set_label (over); }return true;
@@ -2279,6 +2313,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \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, fns[s->sew -1 ]); \ +mark_vs_dirty (s); \gen_set_label (over); \return true; \ } \
@@ -2327,6 +2362,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \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, fns[s->sew -1 ]); \ +mark_vs_dirty (s); \gen_set_label (over); \return true; \ } \
@@ -2389,6 +2425,7 @@ static bool trans_##NAME(DisasContext *s, arg_r *a) \vreg_ofs (s, a->rs1), \vreg_ofs (s, a->rs2), cpu_env,0 , \ s->vlen / 8, data, fn); \ +mark_vs_dirty (s); \gen_set_label (over); \return true; \ } \
@@ -2486,6 +2523,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \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); \ +mark_vs_dirty (s); \gen_set_label (over); \return true; \ } \
@@ -2517,6 +2555,7 @@ static bool trans_viota_m(DisasContext *s, arg_viota_m *a)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, fns[s->sew]); +mark_vs_dirty (s);gen_set_label (over);return true; }
@@ -2542,6 +2581,7 @@ static bool trans_vid_v(DisasContext *s, arg_vid_v *a) };tcg_gen_gvec_2_ptr (vreg_ofs (s, a->rd),vreg_ofs (s,0 ), cpu_env,0 , s->vlen /8 , data, fns[s->sew]); +mark_vs_dirty (s);gen_set_label (over);return true; }
@@ -2717,6 +2757,7 @@ static bool trans_vmv_s_x(DisasContext *s, arg_vmv_s_x *a)tcg_gen_extu_tl_i64 (t1, cpu_gpr[a->rs1]);vec_element_storei (s, a->rd,0 , t1);tcg_temp_free_i64 (t1); +mark_vs_dirty (s); done:gen_set_label (over);return true;
@@ -2767,6 +2808,7 @@ static bool trans_vfmv_s_f(DisasContext *s, arg_vfmv_s_f *a) }vec_element_storei (s, a->rd,0 , t1);tcg_temp_free_i64 (t1); +mark_vs_dirty (s);gen_set_label (over);return true; }
@@ -2833,6 +2875,7 @@ static bool trans_vrgather_vx(DisasContext *s, arg_rmrr *a)tcg_gen_gvec_dup_i64 (s->sew,vreg_ofs (s, a->rd),MAXSZ (s),MAXSZ (s), dest);tcg_temp_free_i64 (dest); +mark_vs_dirty (s); }else {static gen_helper_opivx *const fns[4 ] = { gen_helper_vrgather_vx_b, gen_helper_vrgather_vx_h,
@@ -2859,6 +2902,7 @@ static bool trans_vrgather_vi(DisasContext *s, arg_rmrr *a)endian_ofs (s, a->rs2, a->rs1), MAXSZ(s), MAXSZ(s)); } +mark_vs_dirty (s); }else {static gen_helper_opivx *const fns[4 ] = { gen_helper_vrgather_vx_b, gen_helper_vrgather_vx_h,
@@ -2895,6 +2939,7 @@ static bool trans_vcompress_vm(DisasContext *s, arg_r *a)tcg_gen_gvec_4_ptr (vreg_ofs (s, a->rd),vreg_ofs (s,0 ),vreg_ofs (s, a->rs1),vreg_ofs (s, a->rs2), cpu_env,0 , s->vlen /8 , data, fns[s->sew]); +mark_vs_dirty (s);gen_set_label (over);return true; }
target/riscv/translate.c +33 -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,
@@ -445,6 +446,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)
@@ -793,6 +825,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
RFC v4 7/70 target/riscv: rvv-1.0: remove rvv related codes from fcsr registers
In reply to [email protected]From: Frank Chang <[email protected]>
* Remove VXRM and VXSAT fields from FCSR register as they are only presented in VCSR register.
* Remove RVV loose check in fs() predicate function.
--- target/riscv/csr.c | 13 ------------- 1 file changed, 13 deletions(-)
target/riscv/csr.c +0 -13
@@ -46,10 +46,6 @@ void riscv_set_csr_ops(int csrno, riscv_csr_operations *ops)static int fs (CPURISCVState *env,int csrno) {#if !defined(CONFIG_USER_ONLY ) -/* loose check condition for fcsr in vector extension */ -if ((csrno ==CSR_FCSR ) && (env->misa &RVV )) { -return 0 ; - }if (!env->debugger && !riscv_cpu_fp_enabled (env)) {return -1 ; }
@@ -166,10 +162,6 @@ static int read_fcsr(CPURISCVState *env, int csrno, target_ulong *val)#endif *val = (riscv_cpu_get_fflags (env) <<FSR_AEXC_SHIFT ) | (env->frm <<FSR_RD_SHIFT ); -if (vs (env, csrno) >=0 ) { - *val |= (env->vxrm <<FSR_VXRM_SHIFT ) - | (env->vxsat <<FSR_VXSAT_SHIFT ); - }return 0 ; }
@@ -180,13 +172,8 @@ 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 ) { - env->vxrm = (val &FSR_VXRM ) >>FSR_VXRM_SHIFT ; - env->vxsat = (val &FSR_VXSAT ) >>FSR_VXSAT_SHIFT ; - }riscv_cpu_set_fflags (env, (val &FSR_AEXC ) >>FSR_AEXC_SHIFT );return 0 ; }
Signature · 1 line
2.17.1
Re: [RFC v4 07/70] target/riscv: rvv-1.0: remove rvv related codes from fcsr registers
Quoted 10 lines · On 8/17/20 1:48 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
* Remove VXRM and VXSAT fields from FCSR register as they are only presented in VCSR register.
* Remove RVV loose check infs()predicate function.Signed-off-by Frank Chang <[email protected]>--- target/riscv/csr.c | 13 ------------- 1 file changed, 13 deletions(-)
r~
RFC v4 8/70 target/riscv: rvv-1.0: 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
@@ -247,6 +247,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) {
@@ -1265,6 +1285,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
RFC v4 9/70 target/riscv: rvv-1.0: add vlenb register
In reply to [email protected]From: Greentime Hu <[email protected]>
--- target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 7 +++++++ 2 files changed, 8 insertions(+)
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
@@ -184,6 +184,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_archcpu (env)->cfg.vlen >>3 ; +return 0 ; +} +static int read_vl (CPURISCVState *env,int csrno,target_ulong *val) { *val = env->vl;
@@ -1288,6 +1294,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
RFC v4 10/70 target/riscv: rvv-1.0: check MSTATUS_VS when accessing vector csr registers
In reply to [email protected]From: Frank Chang <[email protected]>
If VS field is off, accessing vector csr registers should raise an illegal-instruction exception.
--- target/riscv/csr.c | 5 +++++ 1 file changed, 5 insertions(+)
target/riscv/csr.c +5 -0
@@ -56,6 +56,11 @@ static int fs(CPURISCVState *env, int csrno)static int vs (CPURISCVState *env,int csrno) {if (env->misa &RVV ) { +#if !defined(CONFIG_USER_ONLY ) +if (!env->debugger && !riscv_cpu_vector_enabled (env)) { +return -1 ; + } +#endif return 0 ; }return -1 ;
Signature · 1 line
2.17.1
RFC v4 11/70 target/riscv: rvv-1.0: remove MLEN calculations
In reply to [email protected]From: Frank Chang <[email protected]>
As in RVV 1.0 design, MLEN is hardcoded with value 1 (Section 4.5). Thus, remove all MLEN related calculations.
--- target/riscv/insn_trans/trans_rvv.inc.c | 35 +--- target/riscv/internals.h | 9 +- target/riscv/translate.c | 2 - target/riscv/vector_helper.c | 250 ++++++++++-------------- 4 files changed, 110 insertions(+), 186 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +2 -33
@@ -247,7 +247,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);
@@ -300,7 +299,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);
@@ -387,7 +385,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);
@@ -426,7 +423,6 @@ 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);
@@ -518,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);
@@ -570,7 +565,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);
@@ -649,7 +643,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);
@@ -760,7 +753,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);
@@ -839,7 +831,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),
@@ -885,7 +876,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));
@@ -1034,7 +1024,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 +1119,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 +1207,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 +1285,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 +1475,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), \
@@ -1859,7 +1844,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), \
@@ -1932,7 +1916,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, \
@@ -1973,7 +1956,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), \
@@ -2011,7 +1993,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, \
@@ -2048,7 +2029,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), \
@@ -2084,7 +2064,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, \
@@ -2164,7 +2143,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), \
@@ -2307,7 +2285,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), \
@@ -2356,7 +2333,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), \
@@ -2419,7 +2395,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), \
@@ -2449,7 +2424,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);
@@ -2481,7 +2455,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);
@@ -2517,7 +2490,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), \
@@ -2545,7 +2517,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 ] = {
@@ -2572,7 +2543,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 ] = {
@@ -2863,7 +2833,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 ) {
@@ -2894,7 +2864,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 {
@@ -2934,7 +2904,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;
@@ -853,7 +852,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 +104 -146
857 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC v4 12/70 target/riscv: rvv-1.0: add fractional LMUL
In reply to [email protected]From: Frank Chang <[email protected]>
Introduce the concepts of fractional LMUL for RVV 1.0. In RVV 1.0, LMUL bits are contiguous in vtype register.
--- target/riscv/cpu.h | 15 ++++++++------- target/riscv/translate.c | 16 ++++++++++++++-- target/riscv/vector_helper.c | 16 ++++++++++++++-- 3 files changed, 36 insertions(+), 11 deletions(-)
target/riscv/cpu.h +8 -7
@@ -94,10 +94,10 @@ typedef struct CPURISCVState CPURISCVState;#define RV_VLEN_MAX 256 -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, VLMUL, 0, 3) +FIELD(VTYPE, VSEW, 3, 3) +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 {
@@ -368,9 +368,10 @@ 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 ,VILL ,11 ,1 )/* * A simplification for VLMAX
target/riscv/translate.c +14 -2
@@ -59,7 +59,19 @@ typedef struct DisasContext {bool ext_ifencei;/* vector extension */ bool vill; -uint8_t lmul; +/* +* Encode LMUL to lmul as follows: +* LMUL vlmul lmul +* 1 000 0 +* 2 001 1 +* 4 010 2 +* 8 011 3 +* - 100 - +* 1/8 101 -3 +* 1/4 110 -2 +* 1/2 111 -1 +*/ +int8_t lmul;uint8_t sew;uint16_t vlen;bool vl_eq_vlmax;
@@ -851,7 +863,7 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->vlen = cpu->cfg.vlen; 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->lmul =sextract32 (FIELD_EX32 (tb_flags,TB_FLAGS ,LMUL ),0 ,3 ); ctx->vl_eq_vlmax =FIELD_EX32 (tb_flags,TB_FLAGS ,VL_EQ_VLMAX ); }
target/riscv/vector_helper.c +14 -2
@@ -86,9 +86,21 @@ static inline uint32_t vext_vm(uint32_t desc)return FIELD_EX32 (simd_data (desc),VDATA ,VM ); } -static inline uint32_t vext_lmul (uint32_t desc) +/* +* Encode LMUL to lmul as following: +* LMUL vlmul lmul +* 1 000 0 +* 2 001 1 +* 4 010 2 +* 8 011 3 +* - 100 - +* 1/8 101 -3 +* 1/4 110 -2 +* 1/2 111 -1 +*/ +static inline int32_t vext_lmul (uint32_t desc) { -return FIELD_EX32 (simd_data (desc),VDATA ,LMUL ); +return sextract32 (FIELD_EX32 (simd_data (desc),VDATA ,LMUL ),0 ,3 ); }static uint32_t vext_wd (uint32_t desc)
Signature · 1 line
2.17.1
Re: [RFC v4 12/70] target/riscv: rvv-1.0: add fractional LMUL
Quoted 11 lines · On 8/17/20 1:48 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Introduce the concepts of fractional LMUL for RVV 1.0. In RVV 1.0, LMUL bits are contiguous in vtype register.
Signed-off-by Frank Chang <[email protected]>--- target/riscv/cpu.h | 15 ++++++++------- target/riscv/translate.c | 16 ++++++++++++++-- target/riscv/vector_helper.c | 16 ++++++++++++++-- 3 files changed, 36 insertions(+), 11 deletions(-)
r~
RFC v4 13/70 target/riscv: rvv-1.0: add VMA and VTA
In reply to [email protected]From: Frank Chang <[email protected]>
Introduce vma and vta fields in vtype register.
According to RVV 1.0 spec (section 3.3.3):
When a set is marked agnostic, the corresponding set of destination elements in any vector or mask destination operand can either retain the value they previously held, or are overwritten with 1s.
So, either vta/vma is set to undisturbed or agnostic, it's legal to retain the inactive masked-off elements and tail elements' original values unchanged. Therefore, besides declaring vta/vma fields in vtype register, also remove all the tail elements clean functions in this commit.
--- target/riscv/cpu.h | 2 + target/riscv/vector_helper.c | 1927 ++++++++++++++++------------------ 2 files changed, 891 insertions(+), 1038 deletions(-)
target/riscv/cpu.h +2 -0
@@ -96,6 +96,8 @@ typedef struct CPURISCVState CPURISCVState; FIELD(VTYPE, VLMUL, 0, 3) FIELD(VTYPE, VSEW, 3, 3) +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 )
target/riscv/vector_helper.c +889 -1038
2,992 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.17.1
Part of the diff is not shown here. View the raw message.
RFC v4 14/70 target/riscv: rvv-1.0: update check functions
In reply to [email protected]From: Frank Chang <[email protected]>
Update check functions with RVV 1.0 rules.
--- target/riscv/insn_trans/trans_rvv.inc.c | 708 ++++++++++++++++-------- 1 file changed, 476 insertions(+), 232 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +476 -232
@@ -19,11 +19,79 @@#include "tcg/tcg-gvec-desc.h" #include "internals.h" +#define NVPR 32 + +static inline bool is_aligned (const uint8_t val,const uint8_t pos) +{ +return pos ? (val & (pos -1 )) ==0 : true; +} + +static inline bool is_overlapped (const uint8_t astart,uint8_t asize, +const uint8_t bstart,uint8_t 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 uint8_t astart,uint8_t asize, +const uint8_t bstart,uint8_t 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 require_rvv (DisasContext *s) +{ +if (s->mstatus_vs ==0 ) { +return false; + } +return true; +} + +/* Destination vector register group cannot overlap source mask register. */ +static bool require_vm (int vm,int rd) +{ +return (vm !=0 || rd !=0 ); +} + +static bool require_align (const uint8_t val,const uint8_t pos) +{ +return is_aligned (val, pos); +} + +static bool require_noover (const uint8_t astart,const uint8_t asize, +const uint8_t bstart,const uint8_t bsize) +{ +return !is_overlapped (astart, asize, bstart, bsize); +} + +static bool require_noover_widen (const uint8_t astart,const uint8_t asize, +const uint8_t bstart,const uint8_t bsize) +{ +return !is_overlapped_widen (astart, asize, bstart, bsize); +} +static bool trans_vsetvl (DisasContext *ctx,arg_vsetvl *a) {TCGv s1, s2, dst; -if (!has_ext (ctx,RVV )) { +if (!require_rvv (ctx) || !has_ext (ctx,RVV )) {return false; }
@@ -56,7 +124,7 @@ static bool trans_vsetvli(DisasContext *ctx, arg_vsetvli *a) {TCGv s1, s2, dst; -if (!has_ext (ctx,RVV )) { +if (!require_rvv (ctx) || !has_ext (ctx,RVV )) {return false; }
@@ -101,53 +169,266 @@ 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) * -* 1. Vector register numbers are multiples of LMUL. (Section 3.2) +* is_vs1: indicates whether insn[19:15] is a vs1 field or not. * -* 2. For all widening instructions, the destination LMUL value must also be -* a supported LMUL value. (Section 11.2) +* Rules to be checked here: +* 1. Destination vector register group for a masked vector +* instruction cannot overlap the source mask register (v0). +* (Section 5.3) +* 2. Destination vector register number is multiples of LMUL. +* (Section 3.3.2) +* 3. Source (vs2, vs1) vector register number are multiples of LMUL. +* (Section 3.3.2) */ -static bool vext_check_reg (DisasContext *s,uint32_t reg,bool widen) +static bool vext_check_sss (DisasContext *s,int vd,int vs1, +int vs2,int vm,bool is_vs1) +{ +bool ret =require_vm (vm, vd); +if (s->lmul >0 ) { + ret &=require_align (vd,1 << s->lmul) && +require_align (vs2,1 << s->lmul); +if (is_vs1) { + ret &=require_align (vs1,1 << s->lmul); + } + } +return ret; +} + +/* +* Check function for maskable 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. +* +* Rules to be checked here: +* 1. Source (vs2, vs1) vector register number are multiples of LMUL. +* (Section 3.3.2) +* 2. Destination vector register cannot overlap a source vector +* register (vs2, vs1) group. +* (Section 5.2) +*/ +static bool vext_check_mss (DisasContext *s,int vd,int vs1, +int vs2,bool is_vs1) { -/* -* 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; +bool ret =require_align (vs2,1 << s->lmul); +if (vd != vs2) { + ret &=require_noover (vd,1 , vs2,1 << s->lmul); + } +if (is_vs1) { +if (vd != vs1) { + ret &=require_noover (vd,1 , vs1,1 << s->lmul); + } + ret &=require_align (vs1,1 << s->lmul); + } +return ret; +} -return !((s->lmul ==0x3 && widen) || (reg % legal)); +/* +* Common check function for vector widening instructions +* of double-width result (2*SEW). +* +* Rules to be checked here: +* 1. The largest vector register group used by an instruction +* can not be greater than 8 vector registers (Section 5.2): +* => LMUL < 8. +* => SEW < 64. +* 2. Destination vector register number is multiples of 2 * LMUL. +* (Section 3.3.2, 11.2) +* 3. Destination vector register group for a masked vector +* instruction cannot overlap the source mask register (v0). +* (Section 5.3) +*/ +static bool vext_wide_check_common (DisasContext *s,int vd,int vm) +{ +return (s->lmul <=2 ) && + (s->sew <3 ) && +require_align (vd,1 << (s->lmul +1 )) && +require_vm (vm, vd); }/* -* There are two rules check here. +* Common check function for vector narrowing instructions +* of single-width result (SEW) and double-width source (2*SEW). +* +* Rules to be checked here: +* 1. The largest vector register group used by an instruction +* can not be greater than 8 vector registers (Section 5.2): +* => LMUL < 8. +* => SEW < 64. +* 2. Source vector register number is multiples of 2 * LMUL. +* (Section 3.3.2, 11.3) +* 3. Destination vector register number is multiples of LMUL. +* (Section 3.3.2, 11.3) +* 4. Destination vector register group for a masked vector +* instruction cannot overlap the source mask register (v0). +* (Section 5.3) +*/ +static bool vext_narrow_check_common (DisasContext *s,int vd,int vs2, +int vm) +{ +return (s->lmul <=2 ) && + (s->sew <3 ) && +require_align (vs2,1 << (s->lmul +1 )) && +require_align (vd,1 << s->lmul) && +require_vm (vm, vd); +} + +/* +* Check function for vector instruction with format: +* double-width result and single-width sources (2*SEW = 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. * -* 2. In widen instructions and some other insturctions, like vslideup.vx, -* there is no need to check whether LMUL=1. +* Rules to be checked here: +* 1. All rules in defined in widen common rules are applied. +* 2. Source (vs2, vs1) vector register number are multiples of LMUL. +* (Section 3.3.2) +* 3. Destination vector register cannot overlap a source vector +* register (vs2, vs1) group. +* (Section 5.2) */ -static bool vext_check_overlap_mask (DisasContext *s,uint32_t vd,bool vm, -bool force) +static bool vext_check_dss (DisasContext *s,int vd,int vs1,int vs2, +int vm,bool is_vs1) { -return (vm !=0 || vd !=0 ) || (!force && (s->lmul ==0 )); +bool ret = (vext_wide_check_common (s, vd, vm) && +require_align (vs2,1 << s->lmul)); +if (s->lmul <0 ) { + ret &=require_noover (vd,1 << (s->lmul +1 ), vs2,1 << s->lmul); + }else { + ret &=require_noover_widen (vd,1 << (s->lmul +1 ), vs2,1 << s->lmul); + } +if (is_vs1) { + ret &=require_align (vs1,1 << s->lmul); +if (s->lmul <0 ) { + ret &=require_noover (vd,1 << (s->lmul +1 ), vs1,1 << s->lmul); + }else { + ret &=require_noover_widen (vd,1 << (s->lmul +1 ), + vs1,1 << s->lmul); + } + } +return ret; } -/* The LMUL setting must be such that LMUL * NFIELDS <= 8. (Section 7.8) */ -static bool vext_check_nf (DisasContext *s,uint32_t nf) +/* +* 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. +* +* Rules to be checked here: +* 1. All rules in defined in widen common rules are applied. +* 2. Source 1 (vs2) vector register number is multiples of 2 * LMUL. +* (Section 3.3.2) +* 3. Source 2 (vs1) vector register number is multiples of LMUL. +* (Section 3.3.2) +* 4. Destination vector register cannot overlap a source vector +* register (vs1) group. +* (Section 5.2) +*/ +static bool vext_check_dds (DisasContext *s,int vd,int vs1,int vs2, +int vm,bool is_vs1) +{ +bool ret = (vext_wide_check_common (s, vd, vm) && +require_align (vs2,1 << (s->lmul +1 ))); +if (is_vs1) { + ret &=require_align (vs1,1 << s->lmul); +if (s->lmul <0 ) { + ret &=require_noover (vd,1 << (s->lmul +1 ), vs1,1 << s->lmul); + }else { + ret &=require_noover_widen (vd,1 << (s->lmul +1 ), + vs1,1 << s->lmul); + } + } +return ret; +} + +/* +* Check function for vector instruction with format: +* single-width result and double-width source 1 and single-width +* source 2 (SEW = 2*SEW op SEW) +* +* is_vs1: indicates whether insn[19:15] is a vs1 field or not. +* +* Rules to be checked here: +* 1. All rules in defined in narrow common rules are applied. +* 2. Destination vector register cannot overlap a source vector +* register (vs2) group. +* (Section 5.2) +* 3. Source 2 (vs1) vector register number is multiples of LMUL. +* (Section 3.3.2) +*/ +static bool vext_check_sds (DisasContext *s,int vd,int vs1,int vs2, +int vm,bool is_vs1) { -return (1 << s->lmul) * nf <=8 ; +bool ret =vext_narrow_check_common (s, vd, vs2, vm); +if (vd != vs2) { + ret &=require_noover (vd,1 << s->lmul, vs2,1 << (s->lmul +1 )); + } +if (is_vs1) { + ret &=require_align (vs1,1 << s->lmul); + } +return ret; }/* -* The destination vector register group cannot overlap a source vector register -* group of a different element width. (Section 11.2) +* Check function for vector reduction instructions. +* +* Rules to be checked here: +* 1. Source 1 (vs2) vector register number is multiples of LMUL. +* (Section 3.3.2) +* 2. For widening reduction instructions, SEW < 64. +* +* TODO: Check vstart == 0 */ -static inline bool vext_check_overlap_group (int rd,int dlen,int rs,int slen) +static bool vext_check_reduction (DisasContext *s,int vs2,bool is_wide) { -return ((rd >= rs + slen) || (rs >= rd + dlen)); +bool ret =require_align (vs2,1 << s->lmul); +if (is_wide) { + ret &= s->sew <3 ; + } +return ret; } + +/* +* Check function for vector slide instructions. +* +* Rules to be checked here: +* 1. Source 1 (vs2) vector register number is multiples of LMUL. +* (Section 3.3.2) +* 2. Destination vector register number is multiples of LMUL. +* (Section 3.3.2) +* 3. Destination vector register group for a masked vector +* instruction cannot overlap the source mask register (v0). +* (Section 5.3) +* 4. The destination vector register group for vslideup, vslide1up, +* vfslide1up, cannot overlap the source vector register (vs2) group. +* (Section 5.2, 17.3.1, 17.3.3) +*/ +static bool vext_check_slide (DisasContext *s,int vd,int vs2, +int vm,bool is_over) +{ +bool ret =require_align (vs2,1 << s->lmul) && +require_align (vd,1 << s->lmul) && +require_vm (vm, vd); +if (is_over) { + ret &= (vd != vs2); + } +return ret; +} + +/* +* In cpu_get_tb_cpu_state(), set VILL if RVV was not present. +* So RVV is also be checked in this function. +*/ +static bool vext_check_isa_ill (DisasContext *s) +{ +return !s->vill; +} +/* common translation macro */ #define GEN_VEXT_TRANS (NAME ,SEQ ,ARGTYPE ,OP ,CHECK ) \ static bool trans_##NAME(DisasContext *s, arg_##ARGTYPE *a)\
@@ -803,11 +1084,9 @@ 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)); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_sss (s, a->rd, a->rs1, a->rs2, a->vm, true); } typedef void GVecGen3Fn(unsigned, uint32_t, uint32_t,
@@ -898,10 +1177,9 @@ 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)); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_sss (s, a->rd, a->rs1, a->rs2, a->vm, false); } typedef void GVecGen2sFn(unsigned, uint32_t, uint32_t, TCGv_i64,
@@ -1098,16 +1376,9 @@ 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_dss (s, a->rd, a->rs1, a->rs2, a->vm, true); } static bool do_opivv_widen(DisasContext *s, arg_rmrr *a,
@@ -1152,13 +1423,9 @@ 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_dss (s, a->rd, a->rs1, a->rs2, a->vm, false); } static bool do_opivx_widen(DisasContext *s, arg_rmrr *a,
@@ -1189,14 +1456,9 @@ 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_dds (s, a->rd, a->rs1, a->rs2, a->vm, true); } static bool do_opiwv_widen(DisasContext *s, arg_rmrr *a,
@@ -1239,11 +1501,9 @@ 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_dds (s, a->rd, a->rs1, a->rs2, a->vm, false); } static bool do_opiwx_widen(DisasContext *s, arg_rmrr *a,
@@ -1304,11 +1564,10 @@ 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 ))); +return require_rvv (s) && +vext_check_isa_ill (s) && + (a->rd !=0 ) && +vext_check_sss (s, a->rd, a->rs1, a->rs2, a->vm, true); }GEN_OPIVV_TRANS (vadc_vvm, opivv_vadc_check)
@@ -1320,11 +1579,9 @@ 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)); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_mss (s, a->rd, a->rs1, a->rs2, true); }GEN_OPIVV_TRANS (vmadc_vvm, opivv_vmadc_check)
@@ -1332,10 +1589,10 @@ 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 ))); +return require_rvv (s) && +vext_check_isa_ill (s) && + (a->rd !=0 ) && +vext_check_sss (s, a->rd, a->rs1, a->rs2, a->vm, false); }/* OPIVX without GVEC IR */
@@ -1358,9 +1615,9 @@ 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)); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_mss (s, a->rd, a->rs1, a->rs2, false); }GEN_OPIVX_TRANS (vmadc_vxm, opivx_vmadc_check)
@@ -1451,14 +1708,9 @@ GEN_OPIVI_GVEC_TRANS(vsra_vi, 1, vsra_vx, sari)/* 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_sds (s, a->rd, a->rs1, a->rs2, a->vm, true); }/* OPIVV with NARROW */
@@ -1492,13 +1744,9 @@ 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_sds (s, a->rd, a->rs1, a->rs2, a->vm, false); }/* OPIVX with NARROW */
@@ -1546,13 +1794,11 @@ 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 ))); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_mss (s, a->rd, a->rs1, a->rs2, 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)
@@ -1562,10 +1808,9 @@ 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 ))); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_mss (s, a->rd, a->rs1, a->rs2, false); }GEN_OPIVX_TRANS (vmseq_vx, opivx_cmp_check)
@@ -1644,10 +1889,10 @@ GEN_OPIVX_WIDEN_TRANS(vwmaccus_vx)/* Vector Integer Merge and Move Instructions */ static bool trans_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)) { - +if (require_rvv (s) && +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),
@@ -1674,9 +1919,10 @@ static bool trans_vmv_v_v(DisasContext *s, arg_vmv_v_v *a)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)) { - +if (require_rvv (s) && +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)) {TCGv s1;TCGLabel *over =gen_new_label ();tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over);
@@ -1717,9 +1963,10 @@ static bool trans_vmv_v_x(DisasContext *s, arg_vmv_v_x *a)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)) { - +if (require_rvv (s) && +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),
@@ -1821,12 +2068,10 @@ 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_sss (s, a->rd, a->rs1, a->rs2, a->vm, true) && + (s->sew !=0 ); }/* OPFVV without GVEC IR */
@@ -1891,17 +2136,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) +{ +return require_rvv (s) && +has_ext (s,RVF ) && +vext_check_isa_ill (s) && +vext_check_sss (s, a->rd, a->rs1, a->rs2, a->vm, false) && + (s->sew !=0 ); }/* OPFVF without GVEC IR */
@@ -1931,16 +2176,10 @@ 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_dss (s, a->rd, a->rs1, a->rs2, a->vm, true) && + (s->sew !=0 ); }/* OPFVV with WIDEN */
@@ -1974,13 +2213,10 @@ 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_dss (s, a->rd, a->rs1, a->rs2, a->vm, false) && + (s->sew !=0 ); }/* OPFVF with WIDEN */
@@ -2006,14 +2242,10 @@ 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_dds (s, a->rd, a->rs1, a->rs2, a->vm, true) && + (s->sew !=0 ); }/* WIDEN OPFVV with WIDEN */
@@ -2047,11 +2279,10 @@ 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_dds (s, a->rd, a->rs1, a->rs2, a->vm, false) && + (s->sew !=0 ); }/* WIDEN OPFVF with WIDEN */
@@ -2122,11 +2353,11 @@ 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +/* OPFV instructions ignore vs1 check */ +vext_check_sss (s, a->rd,0 , a->rs2, a->vm, false) && + (s->sew !=0 ); }#define GEN_OPFV_TRANS (NAME ,CHECK ) \
@@ -2174,13 +2405,10 @@ 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 ))); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_mss (s, a->rd, a->rs1, a->rs2, true) && + (s->sew !=0 ); }GEN_OPFVV_TRANS (vmfeq_vv, opfvv_cmp_check)
@@ -2191,11 +2419,10 @@ 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 ))); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_mss (s, a->rd, a->rs1, a->rs2, false) && + (s->sew !=0 ); }GEN_OPFVF_TRANS (vmfeq_vf, opfvf_cmp_check)
@@ -2214,10 +2441,10 @@ 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) && +if (require_rvv (s) && +vext_check_isa_ill (s) && +require_align (a->rd,1 << s->lmul) && (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]);
@@ -2263,13 +2490,11 @@ 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +/* OPFV widening instructions ignore vs1 check */ +vext_check_dss (s, a->rd,0 , a->rs2, a->vm, false) && + (s->sew !=0 ); }#define GEN_OPFV_WIDEN_TRANS (NAME ) \
@@ -2311,13 +2536,11 @@ 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 )); +return require_rvv (s) && +vext_check_isa_ill (s) && +/* OPFV narrowing instructions ignore vs1 check */ +vext_check_sds (s, a->rd,0 , a->rs2, a->vm, false) && + (s->sew !=0 ); }#define GEN_OPFV_NARROW_TRANS (NAME ) \
@@ -2357,7 +2580,9 @@ 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); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_reduction (s, a->rs2, false); }GEN_OPIVV_TRANS (vredsum_vs, reduction_check)
@@ -2370,8 +2595,15 @@ 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) +{ +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_reduction (s, a->rs2, 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)
@@ -2419,7 +2651,8 @@ GEN_MM_TRANS(vmxnor_mm)/* Vector mask population count vmpopc */ static bool trans_vmpopc_m (DisasContext *s,arg_rmr *a) { -if (vext_check_isa_ill (s)) { +if (require_rvv (s) && +vext_check_isa_ill (s)) {TCGv_ptr src2, mask;TCGv dst;TCGv_i32 desc;
@@ -2450,7 +2683,8 @@ static bool trans_vmpopc_m(DisasContext *s, arg_rmr *a)/* vmfirst find-first-set mask bit */ static bool trans_vmfirst_m (DisasContext *s,arg_rmr *a) { -if (vext_check_isa_ill (s)) { +if (require_rvv (s) && +vext_check_isa_ill (s)) {TCGv_ptr src2, mask;TCGv dst;TCGv_i32 desc;
@@ -2509,10 +2743,11 @@ GEN_M_TRANS(vmsof_m)/* Vector Iota Instruction */ static bool trans_viota_m (DisasContext *s,arg_viota_m *a) { -if (vext_check_isa_ill (s) && -vext_check_reg (s, a->rd, false) && -vext_check_overlap_group (a->rd,1 << s->lmul, a->rs2,1 ) && - (a->vm !=0 || a->rd !=0 )) { +if (require_rvv (s) && +vext_check_isa_ill (s) && +require_noover (a->rd,1 << s->lmul, a->rs2,1 ) && +require_vm (a->vm, a->rd) && +require_align (a->rd,1 << s->lmul)) {uint32_t data =0 ;TCGLabel *over =gen_new_label ();tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over);
@@ -2536,9 +2771,10 @@ 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)) { +if (require_rvv (s) && +vext_check_isa_ill (s) && +require_align (a->rd,1 << s->lmul) && +require_vm (a->vm, a->rd)) {uint32_t data =0 ;TCGLabel *over =gen_new_label ();tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over);
@@ -2788,41 +3024,48 @@ 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)); +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_slide (s, a->rd, a->rs2, a->vm, 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) +{ +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_slide (s, a->rd, a->rs2, a->vm, false); +} + +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) { -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)); +return require_rvv (s) && +vext_check_isa_ill (s) && +require_align (a->rd,1 << s->lmul) && +require_align (a->rs1,1 << s->lmul) && +require_align (a->rs2,1 << s->lmul) && + (a->rd != a->rs2 && a->rd != a->rs1) && +require_vm (a->vm, a->rd); } 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)); +return require_rvv (s) && +vext_check_isa_ill (s) && +require_align (a->rd,1 << s->lmul) && +require_align (a->rs2,1 << s->lmul) && + (a->rd != a->rs2) && +require_vm (a->vm, a->rd); }/* vrgather.vx vd, vs2, rs1, vm # vd[i] = (x[rs1] >= VLMAX) ? 0 : vs2[rs1] */
@@ -2886,11 +3129,12 @@ 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)); +return require_rvv (s) && +vext_check_isa_ill (s) && +require_align (a->rd,1 << s->lmul) && +require_align (a->rs2,1 << s->lmul) && + (a->rd != a->rs2) && +require_noover (a->rd,1 << s->lmul, a->rs1,1 ); }static bool trans_vcompress_vm (DisasContext *s,arg_r *a)
Signature · 1 line
2.17.1
Re: [RFC v4 14/70] target/riscv: rvv-1.0: update check functions
target/riscv/insn_trans/trans_rvv.inc.c line 27
Quoted 4 lines · On 8/17/20 1:48 AM, [email protected] wrote:
target/riscv/insn_trans/trans_rvv.inc.c +4
-0+static inline bool is_aligned (const uint8_t val,const uint8_t pos) +{ +return pos ? (val & (pos -1 )) ==0 : true; +}
The truncation to uint8_t from int is odd. Can we drop all of that and just use int?
Looking at the uses, I think that you should pass lmul directly instead of requiring the callers to all compute 1 << lmul, and also verify that lmul is positive.
That change makes this function look like
return lmul <= 0 || extract32(val, 0, lmul) == 0;
target/riscv/insn_trans/trans_rvv.inc.c line 33
Quoted 5 lines
target/riscv/insn_trans/trans_rvv.inc.c +5
-0+static inline bool is_overlapped (const uint8_t astart,uint8_t asize, +const uint8_t bstart,uint8_t bsize) +{ + asize = asize ==0 ?1 : asize; + bsize = bsize ==0 ?1 : bsize;
This looks odd. Again, I think passing in lmul would be better than size. Then compute size here locally:
int asize = amul <= 0 ? 1 : 1 << amul;
target/riscv/insn_trans/trans_rvv.inc.c line 42
Quoted 9 lines
target/riscv/insn_trans/trans_rvv.inc.c +9
-0+ +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 uint8_t astart,uint8_t asize, +const uint8_t bstart,uint8_t bsize)
This needs more comments, I think. It's not obvious why this is (or needs to be) different from is_overlapped.
I think you're trying to implement the
* destination eew smaller than source eew,
and overlap is allowed at the beginning.
* destination eew larger than source eew,
and overlap is allowed at the end.
rule from section 5.2. But since you're not comparing asize vs bsize, that's not what you're doing.
Anyway, I think all of these rules can be put into require_noover, and there need not be a separate require_noover_widen.
target/riscv/insn_trans/trans_rvv.inc.c line 64
Quoted 6 lines
target/riscv/insn_trans/trans_rvv.inc.c +6
-0+static bool require_rvv (DisasContext *s) +{ +if (s->mstatus_vs ==0 ) { +return false; + } +return true;
return s->mstatus_vs != 0;
target/riscv/insn_trans/trans_rvv.inc.c static bool vext_check_isa_ill(DisasContext *s) · line 198
Quoted 13 lines
target/riscv/insn_trans/trans_rvv.inc.c +13
-0+static bool vext_check_sss (DisasContext *s,int vd,int vs1, +int vs2,int vm,bool is_vs1) +{ +bool ret =require_vm (vm, vd); +if (s->lmul >0 ) { + ret &=require_align (vd,1 << s->lmul) && +require_align (vs2,1 << s->lmul); +if (is_vs1) { + ret &=require_align (vs1,1 << s->lmul); + } + } +return ret; +}
I think this (and similar function taking is_vs1) should be split. All callers pass a constant value, and thus can just as easily call a different function.
Perhaps
static bool vext_check_ss(DisasContext *s, int vd,
int vs2, int vm)
{
return (require_vm(vm, vd) &&
require_align(vd, s->lmul) &&
require_align(vs2, s->lmul));
}static bool vext_check_sss(DisasContext *s, int vd, int vs1,
int vs2, int vm)
{
return (vext_check_ss(s, vd, vs2, vm) &&
require_align(vs1, s->lmul));
}Quoted 18 lines
target/riscv/insn_trans/trans_rvv.inc.c +17
-0+/* +* Check function for maskable 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. +* +* Rules to be checked here: +* 1. Source (vs2, vs1) vector register number are multiples of LMUL. +* (Section 3.3.2) +* 2. Destination vector register cannot overlap a source vector +* register (vs2, vs1) group. +* (Section 5.2) +*/ +static bool vext_check_mss (DisasContext *s,int vd,int vs1, +int vs2,bool is_vs1) { +bool ret =require_align (vs2,1 << s->lmul); +if (vd != vs2) {
target/riscv/insn_trans/trans_rvv.inc.c static bool vext_check_isa_ill(DisasContext *s) · line 227
Quoted 10 lines
target/riscv/insn_trans/trans_rvv.inc.c +10
-0+ ret &=require_noover (vd,1 , vs2,1 << s->lmul); + } +if (is_vs1) { +if (vd != vs1) { + ret &=require_noover (vd,1 , vs1,1 << s->lmul); + } + ret &=require_align (vs1,1 << s->lmul); + } +return ret; +}
If require_noover implements all of the overlap rules, as suggested, this simplifies to
static bool vext_check_ms(DisasContext *s, int vd, int vs2)
{
return (require_align(vs2, s->lmul) &&
require_noover(vd, 0, vs2, s->lmul);
}static bool vext_check_mss(DisasContext *s, int vd,
int vs1, int vs2)
{
return (vext_check_ms(s, vd, vs2) &&
require_align(vs1, s->lmul) &&
require_noover(vd, 0, vs1, s->lmul));
}Quoted 9 lines
target/riscv/insn_trans/trans_rvv.inc.c +9
-0+/* +* Common check function for vector widening instructions +* of double-width result (2*SEW). +* +* Rules to be checked here: +* 1. The largest vector register group used by an instruction +* can not be greater than 8 vector registers (Section 5.2): +* => LMUL < 8. +* => SEW < 64.
target/riscv/insn_trans/trans_rvv.inc.c static bool vext_check_isa_ill(DisasContext *s) · line 247
Quoted 10 lines
target/riscv/insn_trans/trans_rvv.inc.c +10
-0+* 2. Destination vector register number is multiples of 2 * LMUL. +* (Section 3.3.2, 11.2) +* 3. Destination vector register group for a masked vector +* instruction cannot overlap the source mask register (v0). +* (Section 5.3) +*/ +static bool vext_wide_check_common (DisasContext *s,int vd,int vm) +{ +return (s->lmul <=2 ) && + (s->sew < 3) &&
Use MO_64 here for clarity.
target/riscv/insn_trans/trans_rvv.inc.c static bool vext_check_isa_ill(DisasContext *s) · line 273
Quoted 5 lines
target/riscv/insn_trans/trans_rvv.inc.c +5
-0+static bool vext_narrow_check_common (DisasContext *s,int vd,int vs2, +int vm) +{ +return (s->lmul <=2 ) && + (s->sew < 3) &&
Likewise.
Quoted 14 lines
target/riscv/insn_trans/trans_rvv.inc.c +11
-0+/* +* Check function for vector instruction with format: +* double-width result and single-width sources (2*SEW = SEW op SEW) * +* is_vs1: indicates whether insn[19:15] is a vs1 field or not. * +* Rules to be checked here: +* 1. All rules in defined in widen common rules are applied. +* 2. Source (vs2, vs1) vector register number are multiples of LMUL. +* (Section 3.3.2) +* 3. Destination vector register cannot overlap a source vector +* register (vs2, vs1) group. +* (Section 5.2) */
target/riscv/insn_trans/trans_rvv.inc.c static bool vext_check_isa_ill(DisasContext *s) · line 302
Quoted 10 lines
target/riscv/insn_trans/trans_rvv.inc.c +9
-0+static bool vext_check_dss (DisasContext *s,int vd,int vs1,int vs2, +int vm,bool is_vs1) { +bool ret = (vext_wide_check_common (s, vd, vm) && +require_align (vs2,1 << s->lmul)); +if (s->lmul <0 ) { + ret &=require_noover (vd,1 << (s->lmul +1 ), vs2,1 << s->lmul); + }else { + ret &=require_noover_widen (vd,1 << (s->lmul +1 ), vs2,1 << s->lmul); + }
This is buggy, with (1 << negative_number), and is exactly why I think require_noover needs to be passed the emul of each operand and implement all of the rules.
This should just be
static bool vext_check_ds(DisasContext *s, int vd, int vs2)
{
return (vext_wide_check_common(s, vd, vm) &&
require_align(vs2, s->lmul) &&
require_noover(vd, s->lmul + 1, vs2, s->lmul));
}static bool vext_check_dss(DisasContext *s, int vd,
int vs1, int vs2)
{
return (vext_check_ds(s, vd, vs2) &&
require_align(vs1, s->lmul) &&
require_noover(vd, s->lmul + 1, vs1, s->lmul));
}static bool vext_check_dds(DisasContext *s, int vd,
int vs1, int vs2)
{
return (vext_check_ds(s, vd, vs1) &&
require_align(vs2, s->lmul + 1) &&
require_noover(vd, s->lmul + 1, vs1, s->lmul + 1));
}Quoted 10 lines
/*
+ * Check function for vector reduction instructions.
+ *
+ * Rules to be checked here:
+ * 1. Source 1 (vs2) vector register number is multiples of LMUL.
+ * (Section 3.3.2)
+ * 2. For widening reduction instructions, SEW < 64.
+ *
+ * TODO: Check vstart == 0
*/
target/riscv/insn_trans/trans_rvv.inc.c static bool vext_check_isa_ill(DisasContext *s) · line 394
Quoted 8 lines
target/riscv/insn_trans/trans_rvv.inc.c +6
-0+static bool vext_check_reduction (DisasContext *s,int vs2,bool is_wide) { +bool ret =require_align (vs2,1 << s->lmul); +if (is_wide) { + ret &= s->sew <3 ; + } +return ret; }
Again, should be split. But in this case probably into the only callers...
target/riscv/insn_trans/trans_rvv.inc.c GEN_OPIVV_TRANS(vredor_vs, reduction_check) · line 2603
Quoted 6 lines
target/riscv/insn_trans/trans_rvv.inc.c +6
-0+static bool reduction_widen_check (DisasContext *s,arg_rmrr *a) +{ +return require_rvv (s) && +vext_check_isa_ill (s) && +vext_check_reduction (s, a->rs2, true); +}
This could simplify to
return reduction_check(s, a) && s->sew < MO_64;
r~
RFC v4 15/70 target/riscv: introduce more imm value modes in translator functions
In reply to [email protected]From: Frank Chang <[email protected]>
Immediate value in translator function is extended not only zero-extended and sign-extended but with more modes to be applicable with multiple formats of vector instructions.
* IMM_ZX: Zero-extended * IMM_SX: Sign-extended * IMM_TRUNC_SEW: Truncate to log(SEW) bit
* IMM_TRUNC_2SEW: Truncate to log(2*SEW) bit
--- target/riscv/insn_trans/trans_rvv.inc.c | 115 ++++++++++++++---------- 1 file changed, 66 insertions(+), 49 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +66 -49
@@ -1283,8 +1283,32 @@ static void tcg_gen_gvec_rsubs(unsigned vece, uint32_t dofs, uint32_t aofs, GEN_OPIVX_GVEC_TRANS(vrsub_vx, rsubs) +typedef enum { +IMM_ZX ,/* Zero-extended */ +IMM_SX ,/* Sign-extended */ +IMM_TRUNC_SEW ,/* Truncate to log(SEW) bits */ +IMM_TRUNC_2SEW ,/* Truncate to log(2*SEW) bits */ +}imm_mode_t ; + +static int64_t extract_imm (DisasContext *s,uint32_t imm,imm_mode_t imm_mode) +{ +switch (imm_mode) { +case IMM_ZX : +return extract64 (imm,0 ,5 ); +case IMM_SX : +return sextract64 (imm,0 ,5 ); +case IMM_TRUNC_SEW : +return extract64 (imm,0 , s->sew +3 ); +case IMM_TRUNC_2SEW : +return extract64 (imm,0 , s->sew +4 ); +default : +g_assert_not_reached (); + } +} +static bool opivi_trans (uint32_t vd,uint32_t imm,uint32_t vs2,uint32_t vm, -gen_helper_opivx *fn,DisasContext *s,int zx) +gen_helper_opivx *fn,DisasContext *s, +imm_mode_t imm_mode) {TCGv_ptr dest, src2, mask;TCGv src1;
@@ -1297,11 +1321,8 @@ static bool opivi_trans(uint32_t vd, uint32_t imm, uint32_t vs2, uint32_t vm, dest =tcg_temp_new_ptr (); mask =tcg_temp_new_ptr (); src2 =tcg_temp_new_ptr (); -if (zx) { - src1 =tcg_const_tl (imm); - }else { - src1 =tcg_const_tl (sextract64 (imm,0 ,5 )); - } + src1 =tcg_const_tl (extract_imm (s, imm, imm_mode)); + 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));
@@ -1327,28 +1348,23 @@ typedef void GVecGen2iFn(unsigned, uint32_t, uint32_t, int64_t,static inline bool do_opivi_gvec (DisasContext *s,arg_rmrr *a,GVecGen2iFn *gvec_fn, -gen_helper_opivx *fn,int zx) +gen_helper_opivx *fn,imm_mode_t imm_mode) {if (!opivx_check (s, a)) {return false; }if (a->vm && s->vl_eq_vlmax) { -if (zx) { -gvec_fn (s->sew,vreg_ofs (s, a->rd),vreg_ofs (s, a->rs2), -extract64 (a->rs1,0 ,5 ),MAXSZ (s),MAXSZ (s)); - }else { -gvec_fn (s->sew,vreg_ofs (s, a->rd),vreg_ofs (s, a->rs2), -sextract64 (a->rs1,0 ,5 ),MAXSZ (s),MAXSZ (s)); - } +gvec_fn (s->sew,vreg_ofs (s, a->rd),vreg_ofs (s, a->rs2), +extract_imm (s, a->rs1, imm_mode),MAXSZ (s),MAXSZ (s));mark_vs_dirty (s);return true; } -return opivi_trans (a->rd, a->rs1, a->rs2, a->vm, fn, s, zx); +return opivi_trans (a->rd, a->rs1, a->rs2, a->vm, fn, s, imm_mode); }/* OPIVI with GVEC IR */ -#define GEN_OPIVI_GVEC_TRANS (NAME ,ZX ,OPIVX ,SUF ) \ +#define GEN_OPIVI_GVEC_TRANS (NAME ,IMM_MODE ,OPIVX ,SUF ) \ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ { \ static gen_helper_opivx * const fns[4] = { \
@@ -1356,10 +1372,10 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ gen_helper_##OPIVX##_w, gen_helper_##OPIVX##_d, \ }; \ return do_opivi_gvec(s, a, tcg_gen_gvec_##SUF, \ - fns[s->sew], ZX); \ + fns[s->sew], IMM_MODE); \ } -GEN_OPIVI_GVEC_TRANS(vadd_vi, 0, vadd_vx, addi) +GEN_OPIVI_GVEC_TRANS(vadd_vi, IMM_SX, vadd_vx, addi)static void tcg_gen_gvec_rsubi (unsigned vece,uint32_t dofs,uint32_t aofs,int64_t c,uint32_t oprsz,uint32_t maxsz)
@@ -1369,7 +1385,7 @@ static void tcg_gen_gvec_rsubi(unsigned vece, uint32_t dofs, uint32_t aofs,tcg_temp_free_i64 (tmp); } -GEN_OPIVI_GVEC_TRANS (vrsub_vi,0 , vrsub_vx, rsubi) +GEN_OPIVI_GVEC_TRANS (vrsub_vi,IMM_SX , vrsub_vx, rsubi)/* Vector Widening Integer Add/Subtract */
@@ -1624,7 +1640,7 @@ GEN_OPIVX_TRANS(vmadc_vxm, opivx_vmadc_check)GEN_OPIVX_TRANS (vmsbc_vxm, opivx_vmadc_check) /* OPIVI without GVEC IR */ -#define GEN_OPIVI_TRANS (NAME ,ZX ,OPIVX ,CHECK ) \ +#define GEN_OPIVI_TRANS (NAME ,IMM_MODE ,OPIVX ,CHECK ) \ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ { \ if (CHECK(s, a)) { \
@@ -1633,13 +1649,13 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ gen_helper_##OPIVX##_w, gen_helper_##OPIVX##_d, \ }; \ return opivi_trans(a->rd, a->rs1, a->rs2, a->vm, \ - fns[s->sew], s, ZX); \ + fns[s->sew], s, IMM_MODE); \ } \ return false; \ } -GEN_OPIVI_TRANS(vadc_vim, 0, vadc_vxm, opivx_vadc_check) -GEN_OPIVI_TRANS (vmadc_vim,0 , vmadc_vxm, opivx_vmadc_check) +GEN_OPIVI_TRANS(vadc_vim, IMM_SX, vadc_vxm, opivx_vadc_check) +GEN_OPIVI_TRANS (vmadc_vim,IMM_SX , vmadc_vxm, opivx_vmadc_check) /* Vector Bitwise Logical Instructions */GEN_OPIVV_GVEC_TRANS (vand_vv, and)
@@ -1648,9 +1664,9 @@ GEN_OPIVV_GVEC_TRANS(vxor_vv, xor) GEN_OPIVX_GVEC_TRANS(vand_vx, ands) GEN_OPIVX_GVEC_TRANS(vor_vx, ors) GEN_OPIVX_GVEC_TRANS(vxor_vx, xors) -GEN_OPIVI_GVEC_TRANS(vand_vi, 0, vand_vx, andi) -GEN_OPIVI_GVEC_TRANS(vor_vi, 0, vor_vx, ori) -GEN_OPIVI_GVEC_TRANS (vxor_vi,0 , vxor_vx, xori) +GEN_OPIVI_GVEC_TRANS(vand_vi, IMM_SX, vand_vx, andi) +GEN_OPIVI_GVEC_TRANS(vor_vi, IMM_SX, vor_vx, ori) +GEN_OPIVI_GVEC_TRANS (vxor_vi,IMM_SX , vxor_vx, xori) /* Vector Single-Width Bit Shift Instructions */GEN_OPIVV_GVEC_TRANS (vsll_vv, shlv)
@@ -1701,9 +1717,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_GVEC_TRANS(vsll_vi, IMM_ZX, vsll_vx, shli) +GEN_OPIVI_GVEC_TRANS(vsrl_vi, IMM_ZX, vsrl_vx, shri) +GEN_OPIVI_GVEC_TRANS (vsra_vi,IMM_ZX , vsra_vx, sari) /* Vector Narrowing Integer Right Shift Instructions */static bool opivv_narrow_check (DisasContext *s,arg_rmrr *a)
@@ -1768,7 +1784,7 @@ GEN_OPIVX_NARROW_TRANS(vnsra_vx)GEN_OPIVX_NARROW_TRANS (vnsrl_vx) /* OPIVI with NARROW */ -#define GEN_OPIVI_NARROW_TRANS (NAME ,ZX ,OPIVX ) \ +#define GEN_OPIVI_NARROW_TRANS (NAME ,IMM_MODE ,OPIVX ) \ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ { \ if (opivx_narrow_check(s, a)) { \
@@ -1778,13 +1794,13 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ gen_helper_##OPIVX##_w, \ }; \ return opivi_trans(a->rd, a->rs1, a->rs2, a->vm, \ - fns[s->sew], s, ZX); \ + fns[s->sew], s, IMM_MODE); \ } \ return false; \ } -GEN_OPIVI_NARROW_TRANS(vnsra_vi, 1, vnsra_vx) -GEN_OPIVI_NARROW_TRANS (vnsrl_vi,1 , vnsrl_vx) +GEN_OPIVI_NARROW_TRANS(vnsra_vi, IMM_ZX, vnsra_vx) +GEN_OPIVI_NARROW_TRANS (vnsrl_vi,IMM_ZX , vnsrl_vx)/* Vector Integer Comparison Instructions */ /*
@@ -1822,12 +1838,12 @@ GEN_OPIVX_TRANS(vmsle_vx, opivx_cmp_check) GEN_OPIVX_TRANS(vmsgtu_vx, opivx_cmp_check) 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(vmsle_vi, 0, vmsle_vx, opivx_cmp_check) -GEN_OPIVI_TRANS(vmsgtu_vi, 1, vmsgtu_vx, opivx_cmp_check) -GEN_OPIVI_TRANS (vmsgt_vi,0 , vmsgt_vx, opivx_cmp_check) +GEN_OPIVI_TRANS(vmseq_vi, IMM_SX, vmseq_vx, opivx_cmp_check) +GEN_OPIVI_TRANS(vmsne_vi, IMM_SX, vmsne_vx, opivx_cmp_check) +GEN_OPIVI_TRANS(vmsleu_vi, IMM_ZX, vmsleu_vx, opivx_cmp_check) +GEN_OPIVI_TRANS(vmsle_vi, IMM_SX, vmsle_vx, opivx_cmp_check) +GEN_OPIVI_TRANS(vmsgtu_vi, IMM_ZX, vmsgtu_vx, opivx_cmp_check) +GEN_OPIVI_TRANS (vmsgt_vi,IMM_SX , vmsgt_vx, opivx_cmp_check) /* Vector Integer Min/Max Instructions */GEN_OPIVV_GVEC_TRANS (vminu_vv, umin)
@@ -2003,7 +2019,7 @@ static bool trans_vmv_v_i(DisasContext *s, arg_vmv_v_i *a) 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) +GEN_OPIVI_TRANS (vmerge_vim,IMM_SX , vmerge_vxm, opivx_vadc_check)/* *** Vector Fixed-Point Arithmetic Instructions
@@ -2018,8 +2034,8 @@ 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 (vsadd_vi,0 , vsadd_vx, opivx_check) +GEN_OPIVI_TRANS(vsaddu_vi, IMM_ZX, vsaddu_vx, opivx_check) +GEN_OPIVI_TRANS (vsadd_vi,IMM_SX , vsadd_vx, opivx_check) /* Vector Single-Width Averaging Add and Subtract */GEN_OPIVV_TRANS (vaadd_vv, opivv_check)
@@ -2046,16 +2062,16 @@ GEN_OPIVV_TRANS(vssrl_vv, opivv_check) 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(vssrl_vi, IMM_ZX, vssrl_vx, opivx_check) +GEN_OPIVI_TRANS (vssra_vi,IMM_SX , 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_OPIVI_NARROW_TRANS(vnclipu_vi, IMM_ZX, vnclipu_vx) +GEN_OPIVI_NARROW_TRANS(vnclip_vi, IMM_ZX, vnclip_vx)/* *** Vector Float Point Arithmetic Instructions
@@ -3031,7 +3047,7 @@ static bool slideup_check(DisasContext *s, arg_rmrr *a) 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_OPIVI_TRANS(vslideup_vi, IMM_ZX, vslideup_vx, slideup_check)static bool slidedown_check (DisasContext *s,arg_rmrr *a) {
@@ -3042,7 +3058,7 @@ static bool slidedown_check(DisasContext *s, arg_rmrr *a) GEN_OPIVX_TRANS(vslidedown_vx, slidedown_check) GEN_OPIVX_TRANS(vslide1down_vx, slidedown_check) -GEN_OPIVI_TRANS (vslidedown_vi,1 , vslidedown_vx, slidedown_check) +GEN_OPIVI_TRANS (vslidedown_vi,IMM_ZX , vslidedown_vx, slidedown_check) /* Vector Register Gather Instruction */static bool vrgather_vv_check (DisasContext *s,arg_rmrr *a)
@@ -3121,7 +3137,8 @@ static bool trans_vrgather_vi(DisasContext *s, arg_rmrr *a) gen_helper_vrgather_vx_b, gen_helper_vrgather_vx_h, gen_helper_vrgather_vx_w, gen_helper_vrgather_vx_d }; -return opivi_trans (a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s,1 ); +return opivi_trans (a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], + s,IMM_ZX ); }return true; }
Signature · 1 line
2.17.1
Re: [RFC v4 15/70] target/riscv: introduce more imm value modes in translator functions
Quoted 9 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Immediate value in translator function is extended not only zero-extended and sign-extended but with more modes to be applicable with multiple formats of vector instructions.
* IMM_ZX: Zero-extended * IMM_SX: Sign-extended * IMM_TRUNC_SEW: Truncate to log(SEW) bit
Quoted 6 lines
*
IMM_TRUNC_2SEW: Truncate tolog(2*SEW)bitSigned-off-by Frank Chang <[email protected]>--- target/riscv/insn_trans/trans_rvv.inc.c | 115 ++++++++++++++---------- 1 file changed, 66 insertions(+), 49 deletions(-)
r~
RFC v4 16/70 target/riscv: rvv:1.0: add translation-time nan-box helper function
In reply to [email protected]From: Frank Chang <[email protected]>
* Add fp16 nan-box check generator function, if a 16-bit input is not properly nanboxed, then the input is replaced with the default qnan.
* Add do_nanbox() helper function to utilize gen_check_nanbox_X() to generate the NaN-boxed floating-point values based on SEW setting.
* Apply nanbox helper in opfvf_trans
--- target/riscv/insn_trans/trans_rvv.inc.c | 35 ++++++++++++++++++++++++- target/riscv/translate.c | 10 +++++++ 2 files changed, 44 insertions(+), 1 deletion(-)
target/riscv/insn_trans/trans_rvv.inc.c +34 -1
@@ -2076,6 +2076,33 @@ GEN_OPIVI_NARROW_TRANS(vnclip_vi, IMM_ZX, vnclip_vx)/* *** Vector Float Point Arithmetic Instructions */ + +/* +* As RVF-only cpus always have values NaN-boxed to 64-bits, +* RVF and RVD can be treated equally. +* We don't have to deal with the cases of: SEW > FLEN. +* +* If SEW < FLEN, check whether input fp register is a valid +* NaN-boxed value, in which case the least-significant SEW bits +* of the f regsiter are used, else the canonical NaN value is used. +*/ +static void do_nanbox (DisasContext *s,TCGv_i64 out,TCGv_i64 in) +{ +switch (s->sew) { +case 1 : +gen_check_nanbox_h (out, in); +break ; +case 2 : +gen_check_nanbox_s (out, in); +break ; +case 3 : +tcg_gen_mov_i64 (out, in); +break ; +default : +g_assert_not_reached (); + } +} +/* Vector Single-Width Floating-Point Add/Subtract Instructions */ /*
@@ -2128,6 +2155,7 @@ static bool opfvf_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, {TCGv_ptr dest, src2, mask;TCGv_i32 desc; +TCGv_i64 t1;TCGLabel *over =gen_new_label ();tcg_gen_brcondi_tl (TCG_COND_EQ , cpu_vl,0 , over);
@@ -2141,12 +2169,17 @@ static bool opfvf_trans(uint32_t vd, uint32_t rs1, uint32_t vs2,tcg_gen_addi_ptr (src2, cpu_env,vreg_ofs (s, vs2));tcg_gen_addi_ptr (mask, cpu_env,vreg_ofs (s,0 )); -fn (dest, mask, cpu_fpr[rs1], src2, cpu_env, desc); +/* NaN-box f[rs1] */ + t1 =tcg_temp_new_i64 (); +do_nanbox (s, t1, cpu_fpr[rs1]); + +fn (dest, mask, t1, src2, cpu_env, desc);tcg_temp_free_ptr (dest);tcg_temp_free_ptr (mask);tcg_temp_free_ptr (src2);tcg_temp_free_i32 (desc); +tcg_temp_free_i64 (t1);mark_vs_dirty (s);gen_set_label (over);return true;
target/riscv/translate.c +10 -0
@@ -121,6 +121,16 @@ static void gen_nanbox_s(TCGv_i64 out, TCGv_i64 in)* * Here, the result is always nan-boxed, even the canonical nan. */ +static void gen_check_nanbox_h (TCGv_i64 out,TCGv_i64 in) +{ +TCGv_i64 t_max =tcg_const_i64 (0xffffffffffff0000ull ); +TCGv_i64 t_nan =tcg_const_i64 (0xffffffffffff7e00ull ); + +tcg_gen_movcond_i64 (TCG_COND_GEU , out, in, t_max, in, t_nan); +tcg_temp_free_i64 (t_max); +tcg_temp_free_i64 (t_nan); +} +static void gen_check_nanbox_s (TCGv_i64 out,TCGv_i64 in) {TCGv_i64 t_max =tcg_const_i64 (0xffffffff00000000ull );
Signature · 1 line
2.17.1
Re: [RFC v4 16/70] target/riscv: rvv:1.0: add translation-time nan-box helper function
Quoted 8 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
* Add fp16 nan-box check generator function, if a 16-bit input is not properly nanboxed, then the input is replaced with the default qnan.
* Adddo_nanbox()helper function to utilizegen_check_nanbox_X()to generate the NaN-boxed floating-point values based on SEW setting.
* Apply nanbox helper inopfvf_trans
Quoted 5 lines
Signed-off-by Frank Chang <[email protected]>--- target/riscv/insn_trans/trans_rvv.inc.c | 35 ++++++++++++++++++++++++- target/riscv/translate.c | 10 +++++++ 2 files changed, 44 insertions(+), 1 deletion(-)
r~
RFC v4 17/70 target/riscv: rvv-1.0: configure 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 | 14 +++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +8 -4
@@ -98,8 +98,10 @@ static bool trans_vsetvl(DisasContext *ctx, arg_vsetvl *a) s2 =tcg_temp_new (); dst =tcg_temp_new (); -/* Using x0 as the rs1 register specifier, encodes an infinite AVL */ -if (a->rs1 ==0 ) { +if (a->rd ==0 && a->rs1 ==0 ) { + s1 =tcg_temp_new (); +tcg_gen_mov_tl (s1, cpu_vl); + }else 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 {
@@ -131,8 +133,10 @@ static bool trans_vsetvli(DisasContext *ctx, arg_vsetvli *a) s2 =tcg_const_tl (a->zimm); dst =tcg_temp_new (); -/* Using x0 as the rs1 register specifier, encodes an infinite AVL */ -if (a->rs1 ==0 ) { +if (a->rd ==0 && a->rs1 ==0 ) { + s1 =tcg_temp_new (); +tcg_gen_mov_tl (s1, cpu_vl); + }else 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 {
target/riscv/vector_helper.c +13 -1
@@ -31,12 +31,24 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, {int vlmax, vl;RISCVCPU *cpu =env_archcpu (env); +uint64_t lmul =FIELD_EX64 (s2,VTYPE ,VLMUL );uint16_t sew =8 <<FIELD_EX64 (s2,VTYPE ,VSEW );uint8_t ediv =FIELD_EX64 (s2,VTYPE ,VEDIV );bool vill =FIELD_EX64 (s2,VTYPE ,VILL );target_ulong reserved =FIELD_EX64 (s2,VTYPE ,RESERVED ); -if ((sew > cpu->cfg.elen) || vill || (ediv !=0 ) || (reserved !=0 )) { +if (lmul &4 ) { +/* Fractional LMUL. */ +if (lmul ==4 || + cpu->cfg.elen >> (8 - lmul) < sew) { + vill = true; + } + } + +if ((sew > cpu->cfg.elen) + || vill + || (ediv !=0 ) + || (reserved !=0 )) {/* only set vill bit. */ env->vtype =FIELD_DP64 (0 ,VTYPE ,VILL ,1 ); env->vl =0 ;
Signature · 1 line
2.17.1
Re: [RFC v4 17/70] target/riscv: rvv-1.0: configure instructions
Quoted 41 lines · On Mon, Aug 17, 2020 at 4:50 PM <[email protected]> wrote:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- target/riscv/insn_trans/trans_rvv.inc.c | 12 ++++++++---- target/riscv/vector_helper.c | 14 +++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-)target/riscv/insn_trans/trans_rvv.inc.c +4
-2@@ -98,8 +98,10 @@ static bool trans_vsetvl(DisasContext *ctx, arg_vsetvl *a) s2 =tcg_temp_new (); dst =tcg_temp_new (); -/* Using x0 as the rs1 register specifier, encodes an infinite AVL */ -if (a->rs1 ==0 ) { +if (a->rd ==0 && a->rs1 ==0 ) { + s1 =tcg_temp_new (); +tcg_gen_mov_tl (s1, cpu_vl); + }else 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 {target/riscv/insn_trans/trans_rvv.inc.c +4
-2@@ -131,8 +133,10 @@ static bool trans_vsetvli(DisasContext *ctx, arg_vsetvli *a) s2 =tcg_const_tl (a->zimm); dst =tcg_temp_new (); -/* Using x0 as the rs1 register specifier, encodes an infinite AVL */ -if (a->rs1 ==0 ) { +if (a->rd ==0 && a->rs1 ==0 ) { + s1 =tcg_temp_new (); +tcg_gen_mov_tl (s1, cpu_vl); + }else if (a->rs1 ==0 ) {/* As the mask is at least one bit, RV_VLEN_MAX is >= VLMAX */ s1 =tcg_const_tl (RV_VLEN_MAX );
Quoted 8 lines
} else {
s1 = tcg_temp_new();
gen_get_gpr(s1, a->rs1);
}
gen_helper_vsetvl(dst, cpu_env, s1, s2);
gen_set_gpr(a->rd, dst);
gen_goto_tb(ctx, 0, ctx->pc_succ_insn);trans_vsetvli() uses gen_goto_tb() to save the computation in the link to the next TB.
I know there was a discussion about this back in RVV v0.7.1:
https://patchew.org/QEMU/[email protected]/[email protected]/
However, we had encountered an issue that looked like it was caused by the linked TB.
The code snippet which cause the issue is:
00000000000104a8 <loop>: 104a8: 0122ffd7 vsetvli t6,t0,e32,m4,tu,mu,d1 104ac: 02036407 vle32.v v8,(t1) 104b0: 028a0a57 vadd.vv v20,v8,v20 104b4:41f282b3 sub t0,t0,t6 104b8: 002f9893 slli a7,t6,0x2 104bc: 9346 add t1,t1,a7 104be: fe0295e3 bnez t0,104a8 <loop> 104c2: 012f7057 vsetvli zero,t5,e32,m4,tu,mu,d1
.....
If $t0 is given with the value, e.g. 68.
<loop> is expected to process 32 elements in each iteration. That's it, the env->vl after vsetvli at 0x104a8 in each iteration would be:
1st iteration: 32 (remaining elements to be processed: 68 - 32 = 36) 2nd iteration: 32 (remaining elements to be processed: 36 - 32 = 4) 3rd iteration: 4 (remaining elements to be processed: 4 - 4 = 0, will leave <loop> after 0x104be)
vadd.vv at 0x104b0 is implemented with gvec for acceleration:
if (a->vm && s->vl_eq_vlmax) {
gvec_fn(s->sew, vreg_ofs(s, a->rd),
vreg_ofs(s, a->rs2), vreg_ofs(s, a->rs1),
MAXSZ(s), MAXSZ(s));
} else {
uint32_t data = 0;
data = FIELD_DP32(data, VDATA, VM, a->vm);
data = FIELD_DP32(data, VDATA, LMUL, s->lmul);
tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0),
vreg_ofs(s, a->rs1), vreg_ofs(s, a->rs2),
cpu_env, 0, s->vlen / 8, data, fn);
}gvec function is used when a->vm and s->vl_eq_vlmax are both true. However, s->vl_eq_vlmax, for the above case, is only true in 1st and 2nd iterations.
In third iteration, env->vl is 4 which is not equal to vlmax = 32. But as the TB where vadd.vv resides are already linked with vsetvli's TB, it won't be retranslated and still use the same gvec function in the third iteration.
The total elemented being proceeded would be: 32 + 32 + 32 = 96, instead of 68.
I'm wondering under such conditions, is it still correct to use gen_goto_tb() here?
Or we should use lookup_and_goto_ptr() as in trans_vsetvl() to not link the TBs.
P.S. We also notice that this issue won't happen when debugging with GDB becauseuse_goto_tb() in gen_goto_tb() will return false when GDB is connected and lookup_and_goto_ptr() will be called instead.
Frank Chang
Quoted 36 lines
ctx->base.is_jmp = DISAS_NORETURN;target/riscv/vector_helper.c +13
-1@@ -31,12 +31,24 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env,target_ulong s1, { int vlmax, vl;RISCVCPU *cpu =env_archcpu (env); +uint64_t lmul =FIELD_EX64 (s2,VTYPE ,VLMUL );uint16_t sew =8 <<FIELD_EX64 (s2,VTYPE ,VSEW );uint8_t ediv =FIELD_EX64 (s2,VTYPE ,VEDIV );bool vill =FIELD_EX64 (s2,VTYPE ,VILL );target_ulong reserved =FIELD_EX64 (s2,VTYPE ,RESERVED ); -if ((sew > cpu->cfg.elen) || vill || (ediv !=0 ) || (reserved !=0 )) { +if (lmul &4 ) { +/* Fractional LMUL. */ +if (lmul ==4 || + cpu->cfg.elen >> (8 - lmul) < sew) { + vill = true; + } + } + +if ((sew > cpu->cfg.elen) + || vill + || (ediv !=0 ) + || (reserved !=0 )) {/* only set vill bit. */ env->vtype =FIELD_DP64 (0 ,VTYPE ,VILL ,1 );env->vl = 0;--
2.17.1
Re: [RFC v4 17/70] target/riscv: rvv-1.0: configure instructions
Quoted 48 lines · Frank Chang
trans_vsetvli()usesgen_goto_tb()to save the computation in the link to the next TB.
I know there was a discussion about this back in RVV v0.7.1:
https://patchew.org/QEMU/[email protected]/[email protected]/However, we had encountered an issue that looked like it was caused by the linked TB.
The code snippet which cause the issue is:
00000000000104a8<loop>: 104a8:0122ffd7vsetvli t6,t0,e32,m4,tu,mu,d1 104ac:
02036407 vle32.v v8,(t1) 104b0:028a0a57vadd.vv v20,v8,v20 104b4:41f282b3sub t0,t0,t6 104b8:002f9893slli a7,t6,0x2 104bc: 9346 add t1,t1,a7 104be:fe0295e3bnez t0,104a8 <loop> 104c2:012f7057vsetvli zero,t5,e32,m4,tu,mu,d1
.....If $t0 is given with the value, e.g. 68.
<loop> is expected to process 32 elements in each iteration. That's it, theenv->vlafter vsetvli at0x104a8in each iteration would be:
1st iteration: 32 (remaining elements to be processed: 68 - 32 = 36) 2nd iteration: 32 (remaining elements to be processed: 36 - 32 = 4) 3rd iteration: 4 (remaining elements to be processed: 4 - 4 = 0, will leave <loop> after0x104be)vadd.vv at
0x104b0is implemented with gvec for acceleration:if (
a->vm&&s->vl_eq_vlmax) {gvec_fn(s->sew, vreg_ofs(s, a->rd), vreg_ofs(s, a->rs2), vreg_ofs(s, a->rs1), MAXSZ(s), MAXSZ(s));
} else {
uint32_tdata = 0;data =
FIELD_DP32(data, VDATA, VM, a->vm);
data =FIELD_DP32(data, VDATA, LMUL, s->lmul); tcg_gen_gvec_4_ptr(vreg_ofs(s,a->rd),vreg_ofs(s, 0),vreg_ofs(s, a->rs1),vreg_ofs(s, a->rs2),cpu_env, 0,s->vlen/ 8, data, fn); }gvec function is used when
a->vmands->vl_eq_vlmaxare both true. However,s->vl_eq_vlmax, for the above case, is only true in 1st and 2nd iterations.
In third iteration,env->vlis 4 which is not equal to vlmax = 32. But as the TB where vadd.vv resides are already linked with vsetvli's TB, it won't be retranslated and still use the same gvec function in the third iteration.
The total elemented being proceeded would be: 32 + 32 + 32 = 96, instead of 68.
Quoted 2 lines
I'm wondering under such conditions, is it still correct to use
gen_goto_tb()here? Or we should uselookup_and_goto_ptr()as intrans_vsetvl()to not link the TBs.
You're correct -- because of vl_eq_vlmax we can't use goto_tb when using a variable input.
It would be possible when using xN,x0 for VLMAX, or x0,x0 for reuse of the current vl, but I doubt it's worth special-casing that.
I wonder if the goto_tb conversation happened before we introduced vl_eq_vlmax and forgot to re-evaluate, or if I just missed that in the first place. Anyway, thanks for finding this.
r~
Re: [RFC v4 17/70] target/riscv: rvv-1.0: configure instructions
Quoted 70 lines · Richard Henderson
Quoted 1 line · Frank Chang
trans_vsetvli()usesgen_goto_tb()to save the computation in the linkto the
Quoted 3 lines
next TB.
I know there was a discussion about this back in RVV v0.7.1:https://patchew.org/QEMU/[email protected]/[email protected]/
Quoted 2 lines
However, we had encountered an issue that looked like it was caused by
the
Quoted 4 lines
linked TB.
The code snippet which cause the issue is:
00000000000104a8<loop>: 104a8:0122ffd7vsetvli t6,t0,e32,m4,tu,mu,d1104ac:
Quoted 1 line
02036407 vle32.v v8,(t1) 104b0:
028a0a57vadd.vv v20,v8,v20 104b4:
41f282b3subQuoted 2 lines
t0,t0,t6 104b8:
002f9893slli a7,t6,0x2 104bc: 9346 add t1,t1,a7 104be:fe0295e3bnez t0,104a8 <loop> 104c2:012f7057vsetvlizero,t5,e32,m4,tu,mu,d1
Quoted 5 lines
.....
If $t0 is given with the value, e.g. 68.
<loop> is expected to process 32 elements in each iteration. That's it, theenv->vlafter vsetvli at0x104a8in each iteration wouldbe:
Quoted 3 lines
1st iteration: 32 (remaining elements to be processed: 68 - 32 = 36) 2nd iteration: 32 (remaining elements to be processed: 36 - 32 = 4) 3rd iteration: 4 (remaining elements to be processed: 4 - 4 = 0, will
leave
Quoted 18 lines
<loop> after
0x104be)vadd.vv at
0x104b0is implemented with gvec for acceleration:if (a->vm && s->vl_eq_vlmax) { gvec_fn(s->sew, vreg_ofs(s, a->rd), vreg_ofs(s, a->rs2), vreg_ofs(s, a->rs1), MAXSZ(s), MAXSZ(s)); } else { uint32_t data = 0; data = FIELD_DP32(data, VDATA, VM, a->vm); data = FIELD_DP32(data, VDATA, LMUL, s->lmul); tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), vreg_ofs(s, a->rs1), vreg_ofs(s, a->rs2), cpu_env, 0, s->vlen / 8, data, fn); }Quoted 6 lines
gvec function is used when
a->vmands->vl_eq_vlmaxare both true. However,s->vl_eq_vlmax, for the above case, is only true in 1st and 2nd iterations.
In third iteration,env->vlis 4 which is not equal to vlmax = 32. But as the TB where vadd.vv resides are already linked with vsetvli's TB, it won't be retranslated and still use the same gvec function in thethird
Quoted 2 lines
iteration.
The total elemented being proceeded would be: 32 + 32 + 32 = 96, insteadof 68.
Quoted 2 lines
I'm wondering under such conditions, is it still correct to use
gen_goto_tb()here?Quoted 1 line
Or we should use
lookup_and_goto_ptr()as intrans_vsetvl()to not linkthe TBs.
You're correct -- because of
vl_eq_vlmaxwe can't usegoto_tbwhen using a variable input.It would be possible when using xN,x0 for VLMAX, or x0,x0 for reuse of the current vl, but I doubt it's worth special-casing that.
Quoted 8 lines
I wonder if the
goto_tbconversation happened before we introducedvl_eq_vlmax
and forgot to re-evaluate, or if I just missed that in the first place. Anyway, thanks for finding this.r~
Thanks Richard, I'll include the fix in my next version patchset.
Frank Chang
RFC v4 18/70 target/riscv: rvv-1.0: 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 | 221 +++++++++++------------- target/riscv/vector_helper.c | 188 ++++++-------------- 4 files changed, 192 insertions(+), 389 deletions(-)
target/riscv/helper.h +24 -105
@@ -84,111 +84,30 @@ DEF_HELPER_1(hyp_tlb_flush, void, env)/* Vector functions */ DEF_HELPER_3(vsetvl, tl, env, 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 +97 -124
307 lines not on this page · raw message
target/riscv/vector_helper.c +51 -137
286 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC v4 18/70] target/riscv: rvv-1.0: stride load and store instructions
Quoted 12 lines · On 8/17/20 1:49 AM, [email protected] wrote:
/*
+ * Vector unit-stride, strided, unit-stride segment, strided segment
+ * store check function.
+ *
+ * Rules to be checked here:
+ * 1. EMUL must within the range: 1/8 <= EMUL <= 8. (Section 7.3)
+ * 2. Destination vector register number is multiples of EMUL.
+ * (Section 3.3.2, 7.3)
+ * 3. The EMUL setting must be such that EMUL * NFIELDS ≤ 8. (Section 7.8)
+ * 4. Vector register numbers accessed by the segment load or store
+ * cannot increment past 31. (Section 7.8)
+ */
target/riscv/insn_trans/trans_rvv.inc.c static uint32_t vreg_ofs(DisasContext *s, int reg) · line 180
Quoted 3 lines
target/riscv/insn_trans/trans_rvv.inc.c +3
-0+static bool vext_check_store (DisasContext *s,int vd,int nf,uint8_t eew) +{ +int8_t emul =ctzl (eew) - (s->sew +3 ) + s->lmul;
I think eew should be passed as log, as MemOp and MO_{8,16,32,64} constants. This is already the scale used by sew.
target/riscv/insn_trans/trans_rvv.inc.c static bool vext_check_isa_ill(DisasContext *s) · line 478
Quoted 7 lines
target/riscv/insn_trans/trans_rvv.inc.c +7
-0+#define GEN_VEXT_TRANS (NAME ,EEW ,SEQ ,ARGTYPE ,OP ,CHECK ) \ +static bool trans_##NAME(DisasContext *s, arg_##ARGTYPE * a) \ +{ \ + if (CHECK(s, a, EEW)) { \ + return OP(s, a, SEQ); \ + } \ + return false; \
That also makes EEW and SEQ identical, so that...
target/riscv/insn_trans/trans_rvv.inc.c static bool ld_stride_op(DisasContext *s, arg_rnfvm *a, uint8_t seq) · line 672
Quoted 4 lines
target/riscv/insn_trans/trans_rvv.inc.c +4
-0+GEN_VEXT_TRANS(vlse8_v, 8, 0, rnfvm, ld_stride_op, ld_stride_check) +GEN_VEXT_TRANS(vlse16_v, 16, 1, rnfvm, ld_stride_op, ld_stride_check) +GEN_VEXT_TRANS(vlse32_v, 32, 2, rnfvm, ld_stride_op, ld_stride_check) +GEN_VEXT_TRANS (vlse64_v,64 ,3 , rnfvm, ld_stride_op, ld_stride_check)
... this does not need to replicate those constants.
target/riscv/vector_helper.c static inline int vext_elem_mask(void *v0, int index) · line 194
Quoted 11 lines
target/riscv/vector_helper.c +2
-2-#define GEN_VEXT_LD_ELEM (NAME ,MTYPE ,ETYPE ,H ,LDSUF ) \ +#define GEN_VEXT_LD_ELEM (NAME ,ETYPE ,H ,LDSUF ) \ static void NAME(CPURISCVState *env, abi_ptr addr, \ uint32_t idx, void *vd, uintptr_t retaddr)\ { \ - MTYPE data; \ + ETYPE data; \ ETYPE *cur = ((ETYPE *)vd + H(idx)); \ data = cpu_##LDSUF##_data_ra(env, addr, retaddr); \ *cur = data; \ } \
Since there's no extension to be done between MTYPE and ETYPE anymore, you can also drop the "data" variable completely and store directly into *cur.
r~
RFC v4 19/70 target/riscv: rvv-1.0: 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 | 193 ++++++++++++++++-------- target/riscv/vector_helper.c | 89 ++++++----- 4 files changed, 214 insertions(+), 156 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 +130 -63
236 lines not on this page · raw message
target/riscv/vector_helper.c +42 -47
124 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC v4 19/70] target/riscv: rvv-1.0: index load and store instructions
target/riscv/insn_trans/trans_rvv.inc.c static bool vext_check_load(DisasContext *s, int vd, int nf, int vm, · line 228
Quoted 12 lines · On 8/17/20 1:49 AM, [email protected] wrote:
target/riscv/insn_trans/trans_rvv.inc.c +10
-1+static bool vext_check_st_index (DisasContext *s,int vd,int vs2,int nf, +uint8_t eew) { -return !s->vill; +uint8_t lmul_r = s->lmul <0 ?0 : s->lmul; +int8_t emul =ctzl (eew) - (s->sew +3 ) + s->lmul; +return (emul >=-3 && emul <=3 ) && +require_align (vs2,1 << emul) && +require_align (vd,1 << s->lmul) && + ((nf << lmul_r) <= (NVPR /4 ) && + (vd + (nf << lmul_r)) <=NVPR ); +}
Same comments wrt EEW as the last patch.
It wouldn't hurt to extract something like
static bool require_nf(int vd, int nf, int lmul)
{
int size = nf << MAX(lmul, 0);
return size <= 8 && vd + size <= 32;
}in the previous patch as well.
r~
RFC v4 20/70 target/riscv: rvv-1.0: 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
@@ -363,10 +363,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
Re: [RFC v4 20/70] target/riscv: rvv-1.0: fix address index overflow bug of indexed load/store insns
Quoted 9 lines · On 8/17/20 1:49 AM, [email protected] wrote:
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.
Signed-off-by Frank Chang <[email protected]>--- target/riscv/vector_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
r~
RFC v4 21/70 target/riscv: rvv-1.0: 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
@@ -946,24 +946,12 @@ 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 }; - fn = fns[seq][s->sew]; + fn = fns[seq];if (fn ==NULL ) {return false; }
@@ -974,13 +962,10 @@ static bool ldff_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq)return ldff_trans (a->rd, a->rs1, data, fn, s); } -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
Re: [RFC v4 21/70] target/riscv: rvv-1.0: fault-only-first unit stride load
Quoted 9 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Signed-off-by 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(-)
r~
RFC v4 22/70 target/riscv: rvv-1.0: 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 | 220 ++++++++++++++-------- target/riscv/vector_helper.c | 232 ++++++++++++++++-------- 5 files changed, 407 insertions(+), 199 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 +143 -77
248 lines not on this page · raw message
target/riscv/vector_helper.c +156 -76
281 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC v4 22/70] target/riscv: rvv-1.0: amo operations
Quoted 17 lines · On 8/17/20 1:49 AM, [email protected] wrote:
target/riscv/insn_trans/trans_rvv.inc.c +17
-0+static bool vext_check_amo (DisasContext *s,int vd,int vs2, +int wd,int vm,uint8_t eew) +{ +int8_t emul =ctzl (eew) - (s->sew +3 ) + s->lmul; +bool ret =has_ext (s,RVA ) && + (1 << s->sew >=4 ) && + (1 << s->sew <=sizeof (target_ulong)) && + (eew <= (sizeof (target_ulong) <<3 )) && +require_align (vd,1 << s->lmul) && +require_align (vs2,1 << emul) && + (emul >=-3 && emul <=3 ); +if (wd) { + ret &=require_vm (vm, vd); +if (eew > (1 << (s->sew +3 ))) { +if (vd != vs2) { + ret &=require_noover (vd,1 << s->lmul, vs2,1 << emul); + }
target/riscv/insn_trans/trans_rvv.inc.c static bool vext_check_ld_index(DisasContext *s, int vd, int vs2, · line 318
Quoted 10 lines
target/riscv/insn_trans/trans_rvv.inc.c +10
-0+ }else if (eew < (1 << (s->sew +3 ))) { +if (emul <0 ) { + ret &=require_noover (vd,1 << s->lmul, vs2,1 << emul); + }else { + ret &=require_noover_widen (vd,1 << s->lmul, vs2,1 << emul); + } + } + } +return ret; +}
Same comments for EEW and require_noover.
r~
RFC v4 23/70 target/riscv: rvv-1.0: load/store whole register instructions
In reply to [email protected]From: Frank Chang <[email protected]>
Add the following instructions:
* vl<nf>re<eew>.v
* vs<nf>r.v
--- target/riscv/helper.h | 21 ++++++++ target/riscv/insn32.decode | 22 ++++++++ target/riscv/insn_trans/trans_rvv.inc.c | 72 +++++++++++++++++++++++++ target/riscv/vector_helper.c | 65 ++++++++++++++++++++++ 4 files changed, 180 insertions(+)
target/riscv/helper.h +21 -0
@@ -145,6 +145,27 @@ 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(vl1re8_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl1re16_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl1re32_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl1re64_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl2re8_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl2re16_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl2re32_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl2re64_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl4re8_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl4re16_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl4re32_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl4re64_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl8re8_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl8re16_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl8re32_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vl8re64_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vs1r_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vs2r_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vs4r_v, void, ptr, tl, env, i32) +DEF_HELPER_4(vs8r_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 +22 -0
@@ -267,6 +267,28 @@ 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 +vl1re8_v 000 000 1 01000 ..... 000 ..... 0000111 @r2 +vl1re16_v 000 000 1 01000 ..... 101 ..... 0000111 @r2 +vl1re32_v 000 000 1 01000 ..... 110 ..... 0000111 @r2 +vl1re64_v 000 000 1 01000 ..... 111 ..... 0000111 @r2 +vl2re8_v 001 000 1 01000 ..... 000 ..... 0000111 @r2 +vl2re16_v 001 000 1 01000 ..... 101 ..... 0000111 @r2 +vl2re32_v 001 000 1 01000 ..... 110 ..... 0000111 @r2 +vl2re64_v 001 000 1 01000 ..... 111 ..... 0000111 @r2 +vl4re8_v 011 000 1 01000 ..... 000 ..... 0000111 @r2 +vl4re16_v 011 000 1 01000 ..... 101 ..... 0000111 @r2 +vl4re32_v 011 000 1 01000 ..... 110 ..... 0000111 @r2 +vl4re64_v 011 000 1 01000 ..... 111 ..... 0000111 @r2 +vl8re8_v 111 000 1 01000 ..... 000 ..... 0000111 @r2 +vl8re16_v 111 000 1 01000 ..... 101 ..... 0000111 @r2 +vl8re32_v 111 000 1 01000 ..... 110 ..... 0000111 @r2 +vl8re64_v 111 000 1 01000 ..... 111 ..... 0000111 @r2 +vs1r_v 000 000 1 01000 ..... 000 ..... 0100111 @r2 +vs2r_v 001 000 1 01000 ..... 000 ..... 0100111 @r2 +vs4r_v 011 000 1 01000 ..... 000 ..... 0100111 @r2 +vs8r_v 111 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 +72 -0
78 lines not on this page · raw message
target/riscv/vector_helper.c +65 -0
71 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC v4 23/70] target/riscv: rvv-1.0: load/store whole register instructions
Quoted 8 lines · On 8/17/20 1:49 AM, [email protected] wrote:
target/riscv/insn_trans/trans_rvv.inc.c +8
-0+/* +* load and store whole register instructions ignore vtype and vl setting. +* Thus, we don't need to check vill bit. (Section 7.9) +*/ +#define GEN_LDST_WHOLE_TRANS (NAME ,EEW ,ARGTYPE ,ARG_NF ,IS_STORE ) \ +static bool trans_##NAME(DisasContext *s, arg_##ARGTYPE * a) \ +{ \ + if (require_rvv(s) && \
target/riscv/insn_trans/trans_rvv.inc.c GEN_VEXT_TRANS(vle16ff_v, 16, 1, r2nfvm, ldff_op, ld_us_check) · line 1067
Quoted 10 lines
target/riscv/insn_trans/trans_rvv.inc.c +10
-0+ QEMU_IS_ALIGNED(a->rd, ARG_NF)) { \ +uint32_t data =0 ; \ +bool ret; \ + data =FIELD_DP32 (data,VDATA ,NF ,ARG_NF ); \ + ret = ldst_whole_trans(a->rd, a->rs1, data, gen_helper_##NAME, \ + s,IS_STORE ); \ +return ret; \ + } \ +return false; \ +}
Decodetree is intentionally organized such that ARGTYPE = NAME. There's no point in duplicating that. Move everything besides the call to ldst_whole_trans into ldst_whole_trans.
r~
RFC v4 24/70 target/riscv: rvv-1.0: update vext_max_elems() for load/store insns
In reply to [email protected]From: Frank Chang <[email protected]>
Unlike other vector instructions, load/store vector instructions return the maximum vector size calculated with EMUL.
For other vector instructions, return VLMAX as the maximum vector size.
--- target/riscv/insn_trans/trans_rvv.inc.c | 57 +++++++++++----- target/riscv/vector_helper.c | 90 ++++++++++++++----------- 2 files changed, 88 insertions(+), 59 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +39 -18
@@ -583,11 +583,17 @@ static bool vext_check_isa_ill(DisasContext *s) static bool trans_##NAME(DisasContext *s, arg_##ARGTYPE * a) \ { \ if (CHECK(s, a, EEW)) { \ - return OP(s, a, SEQ); \ + return OP(s, a, EEW, SEQ); \ } \ return false; \ } +static uint8_t vext_get_emul (DisasContext *s,uint8_t eew) +{ +int8_t emul =ctzl (eew) - (s->sew +3 ) + s->lmul; +return emul <0 ?0 : emul; +} +/* *** unit stride load and store */
@@ -611,7 +617,7 @@ static bool ldst_us_trans(uint32_t vd, uint32_t rs1, uint32_t data,/* * As simd_desc supports at most 256 bytes, and in this implementation, -* the max vector group length is 2048 bytes. So split it into two parts. +* the max vector group length is 1024 bytes. So split it into two parts. * * The first part is vlen in bytes, encoded in maxsz of simd_desc. * The second part is lmul, encoded in data of simd_desc.
@@ -635,7 +641,7 @@ static bool ldst_us_trans(uint32_t vd, uint32_t rs1, uint32_t data,return true; } -static bool ld_us_op (DisasContext *s,arg_r2nfvm *a,uint8_t seq) +static bool ld_us_op (DisasContext *s,arg_r2nfvm *a,uint8_t eew,uint8_t seq) {uint32_t data =0 ;gen_helper_ldst_us *fn;
@@ -653,8 +659,14 @@ static bool ld_us_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq)return false; } +/* +* Vector load/store instructions have the EEW encoded +* directly in the instructions. The maximum vector size is +* calculated with EMUL rather than LMUL. +*/ +uint8_t emul =vext_get_emul (s, eew); data =FIELD_DP32 (data,VDATA ,VM , a->vm); - data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); + data =FIELD_DP32 (data,VDATA ,LMUL , emul); data =FIELD_DP32 (data,VDATA ,NF , a->nf);return ldst_us_trans (a->rd, a->rs1, data, fn, s, false); }
@@ -671,7 +683,7 @@ GEN_VEXT_TRANS(vle16_v, 16, 1, r2nfvm, ld_us_op, ld_us_check) GEN_VEXT_TRANS(vle32_v, 32, 2, r2nfvm, ld_us_op, ld_us_check) GEN_VEXT_TRANS(vle64_v, 64, 3, r2nfvm, ld_us_op, ld_us_check) -static bool st_us_op (DisasContext *s,arg_r2nfvm *a,uint8_t seq) +static bool st_us_op (DisasContext *s,arg_r2nfvm *a,uint8_t eew,uint8_t seq) {uint32_t data =0 ;gen_helper_ldst_us *fn;
@@ -689,8 +701,9 @@ static bool st_us_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq)return false; } +uint8_t emul =vext_get_emul (s, eew); data =FIELD_DP32 (data,VDATA ,VM , a->vm); - data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); + data =FIELD_DP32 (data,VDATA ,LMUL , emul); data =FIELD_DP32 (data,VDATA ,NF , a->nf);return ldst_us_trans (a->rd, a->rs1, data, fn, s, true); }
@@ -749,7 +762,8 @@ static bool ldst_stride_trans(uint32_t vd, uint32_t rs1, uint32_t rs2,return true; } -static bool ld_stride_op (DisasContext *s,arg_rnfvm *a,uint8_t seq) +static bool ld_stride_op (DisasContext *s,arg_rnfvm *a,uint8_t eew, +uint8_t seq) {uint32_t data =0 ;gen_helper_ldst_stride *fn;
@@ -763,8 +777,9 @@ static bool ld_stride_op(DisasContext *s, arg_rnfvm *a, uint8_t seq)return false; } +uint8_t emul =vext_get_emul (s, eew); data =FIELD_DP32 (data,VDATA ,VM , a->vm); - data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); + data =FIELD_DP32 (data,VDATA ,LMUL , emul); data =FIELD_DP32 (data,VDATA ,NF , a->nf);return ldst_stride_trans (a->rd, a->rs1, a->rs2, data, fn, s, false); }
@@ -781,7 +796,8 @@ GEN_VEXT_TRANS(vlse16_v, 16, 1, rnfvm, ld_stride_op, ld_stride_check) GEN_VEXT_TRANS(vlse32_v, 32, 2, rnfvm, ld_stride_op, ld_stride_check) GEN_VEXT_TRANS(vlse64_v, 64, 3, rnfvm, ld_stride_op, ld_stride_check) -static bool st_stride_op (DisasContext *s,arg_rnfvm *a,uint8_t seq) +static bool st_stride_op (DisasContext *s,arg_rnfvm *a,uint8_t eew, +uint8_t seq) {uint32_t data =0 ;gen_helper_ldst_stride *fn;
@@ -791,8 +807,9 @@ static bool st_stride_op(DisasContext *s, arg_rnfvm *a, uint8_t seq) gen_helper_vsse32_v, gen_helper_vsse64_v }; +uint8_t emul =vext_get_emul (s, eew); data =FIELD_DP32 (data,VDATA ,VM , a->vm); - data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); + data =FIELD_DP32 (data,VDATA ,LMUL , emul); data =FIELD_DP32 (data,VDATA ,NF , a->nf); fn = fns[seq];if (fn ==NULL ) {
@@ -856,7 +873,7 @@ static bool ldst_index_trans(uint32_t vd, uint32_t rs1, uint32_t vs2,return true; } -static bool ld_index_op (DisasContext *s,arg_rnfvm *a,uint8_t seq) +static bool ld_index_op (DisasContext *s,arg_rnfvm *a,uint8_t eew,uint8_t seq) {uint32_t data =0 ;gen_helper_ldst_index *fn;
@@ -889,8 +906,9 @@ static bool ld_index_op(DisasContext *s, arg_rnfvm *a, uint8_t seq) fn = fns[seq][s->sew]; +uint8_t emul =vext_get_emul (s,1 << (s->sew +3 )); data =FIELD_DP32 (data,VDATA ,VM , a->vm); - data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); + data =FIELD_DP32 (data,VDATA ,LMUL , emul); data =FIELD_DP32 (data,VDATA ,NF , a->nf);return ldst_index_trans (a->rd, a->rs1, a->rs2, data, fn, s, false); }
@@ -907,7 +925,7 @@ GEN_VEXT_TRANS(vlxei16_v, 16, 1, rnfvm, ld_index_op, ld_index_check) GEN_VEXT_TRANS(vlxei32_v, 32, 2, rnfvm, ld_index_op, ld_index_check) GEN_VEXT_TRANS(vlxei64_v, 64, 3, rnfvm, ld_index_op, ld_index_check) -static bool st_index_op (DisasContext *s,arg_rnfvm *a,uint8_t seq) +static bool st_index_op (DisasContext *s,arg_rnfvm *a,uint8_t eew,uint8_t seq) {uint32_t data =0 ;gen_helper_ldst_index *fn;
@@ -940,8 +958,9 @@ static bool st_index_op(DisasContext *s, arg_rnfvm *a, uint8_t seq) fn = fns[seq][s->sew]; +uint8_t emul =vext_get_emul (s,1 << (s->sew +3 )); data =FIELD_DP32 (data,VDATA ,VM , a->vm); - data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); + data =FIELD_DP32 (data,VDATA ,LMUL , emul); data =FIELD_DP32 (data,VDATA ,NF , a->nf);return ldst_index_trans (a->rd, a->rs1, a->rs2, data, fn, s, true); }
@@ -991,7 +1010,7 @@ static bool ldff_trans(uint32_t vd, uint32_t rs1, uint32_t data,return true; } -static bool ldff_op (DisasContext *s,arg_r2nfvm *a,uint8_t seq) +static bool ldff_op (DisasContext *s,arg_r2nfvm *a,uint8_t eew,uint8_t seq) {uint32_t data =0 ;gen_helper_ldst_us *fn;
@@ -1005,8 +1024,9 @@ static bool ldff_op(DisasContext *s, arg_r2nfvm *a, uint8_t seq)return false; } +uint8_t emul =vext_get_emul (s, eew); data =FIELD_DP32 (data,VDATA ,VM , a->vm); - data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); + data =FIELD_DP32 (data,VDATA ,LMUL , emul); data =FIELD_DP32 (data,VDATA ,NF , a->nf);return ldff_trans (a->rd, a->rs1, data, fn, s); }
@@ -1127,7 +1147,7 @@ static bool amo_trans(uint32_t vd, uint32_t rs1, uint32_t vs2,return true; } -static bool amo_op (DisasContext *s,arg_rwdvm *a,uint8_t seq) +static bool amo_op (DisasContext *s,arg_rwdvm *a,uint8_t eew,uint8_t seq) {uint32_t data =0 ;gen_helper_amo *fn;
@@ -1187,8 +1207,9 @@ static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq)return false; } +uint8_t emul =vext_get_emul (s, eew); data =FIELD_DP32 (data,VDATA ,VM , a->vm); - data =FIELD_DP32 (data,VDATA ,LMUL , s->lmul); + data =FIELD_DP32 (data,VDATA ,LMUL , emul); data =FIELD_DP32 (data,VDATA ,WD , a->wd);return amo_trans (a->rd, a->rs1, a->rs2, data, fn, s); }
target/riscv/vector_helper.c +49 -41
270 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC v4 24/70] target/riscv: rvv-1.0: update vext_max_elems() for load/store insns
target/riscv/insn_trans/trans_rvv.inc.c static bool vext_check_isa_ill(DisasContext *s) · line 595
Quoted 5 lines · On 8/17/20 1:49 AM, [email protected] wrote:
target/riscv/insn_trans/trans_rvv.inc.c +5
-0+static uint8_t vext_get_emul (DisasContext *s,uint8_t eew) +{ +int8_t emul =ctzl (eew) - (s->sew +3 ) + s->lmul; +return emul <0 ?0 : emul; +}
Same comment about EEW being encoded as MemOp to match SEW.
r~
RFC v4 25/70 target/riscv: rvv-1.0: 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 1.0.
--- target/riscv/cpu.h | 43 ++++++++++++++++++------- target/riscv/insn_trans/trans_rvv.inc.c | 12 ++++++- 2 files changed, 42 insertions(+), 13 deletions(-)
target/riscv/cpu.h +31 -12
@@ -376,18 +376,27 @@ FIELD(TB_FLAGS, SEW, 6, 3)FIELD (TB_FLAGS ,VILL ,11 ,1 )/* -* A simplification for VLMAX -* = (1 << LMUL) * VLEN / (8 * (1 << SEW)) -* = (VLEN << LMUL) / (8 << SEW) -* = (VLEN << LMUL) >> (SEW + 3) -* = VLEN >> (SEW + 3 - LMUL) +* Encode LMUL to lmul as follows: +* LMUL vlmul lmul +* 1 000 0 +* 2 001 1 +* 4 010 2 +* 8 011 3 +* - 100 - +* 1/8 101 -3 +* 1/4 110 -2 +* 1/2 111 -1 +* +* then, we can calculate VLMAX = vlen >> (vsew + 3 - lmul) +* e.g. vlen = 256 bits, SEW = 16, LMUL = 1/8 +* => VLMAX = vlen >> (1 + 3 - (-3)) +* = 256 >> 7 +* = 2 */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 ); +uint8_t sew =FIELD_EX64 (vtype,VTYPE ,VSEW ); +int8_t lmul =sextract32 (FIELD_EX64 (vtype,VTYPE ,VLMUL ),0 ,3 );return cpu->cfg.vlen >> (sew +3 - lmul); }
@@ -400,12 +409,22 @@ 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 << 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 ,VLMUL )); flags =FIELD_DP32 (flags,TB_FLAGS ,VL_EQ_VLMAX , vl_eq_vlmax);
target/riscv/insn_trans/trans_rvv.inc.c +11 -1
@@ -1268,7 +1268,17 @@ GEN_VEXT_TRANS(vamomaxuei64_v, 64, 35, 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) +{ +int scale = s->lmul -3 ; +return scale <0 ? s->vlen >> -scale : s->vlen << scale; +}static bool opivv_check (DisasContext *s,arg_rmrr *a) {
Signature · 1 line
2.17.1
Re: [RFC v4 25/70] target/riscv: rvv-1.0: take fractional LMUL into vector max elements calculation
Quoted 10 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Update
vext_get_vlmax()andMAXSZ()to take fractional LMUL into calculation for RVV 1.0.Signed-off-by Frank Chang <[email protected]>--- target/riscv/cpu.h | 43 ++++++++++++++++++------- target/riscv/insn_trans/trans_rvv.inc.c | 12 ++++++- 2 files changed, 42 insertions(+), 13 deletions(-)
r~
RFC v4 26/70 target/riscv: rvv-1.0: 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
@@ -527,7 +527,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 v4 27/70 target/riscv: rvv-1.0: 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
@@ -550,7 +550,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 v4 28/70 target/riscv: rvv-1.0: 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 | 7 ++++--- target/riscv/vector_helper.c | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-)
target/riscv/helper.h +1 -1
@@ -1066,7 +1066,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
@@ -591,7 +591,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 +4 -3
@@ -2895,8 +2895,8 @@ GEN_MM_TRANS(vmnor_mm)GEN_MM_TRANS (vmornot_mm)GEN_MM_TRANS (vmxnor_mm ) -/* Vector mask population count vmpopc */ -static booltrans_vmpopc_m (DisasContext *s, arg_rmr *a) +/* Vector mask population count vpopc */ +static booltrans_vpopc_m (DisasContext *s, arg_rmr *a) {if (require_rvv (s) &&vext_check_isa_ill (s)) {
@@ -2915,13 +2915,14 @@ static bool trans_vmpopc_m(DisasContext *s, arg_rmr *a)tcg_gen_addi_ptr (src2, cpu_env,vreg_ofs (s, a->rs2));tcg_gen_addi_ptr (mask, cpu_env,vreg_ofs (s,0 )); -gen_helper_vmpopc_m (dst, mask, src2, cpu_env, desc); +gen_helper_vpopc_m (dst, mask, src2, cpu_env, desc);gen_set_gpr (a->rd, dst);tcg_temp_free_ptr (mask);tcg_temp_free_ptr (src2);tcg_temp_free (dst);tcg_temp_free_i32 (desc); +return true; }return false;
target/riscv/vector_helper.c +3 -3
@@ -4447,9 +4447,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 v4 29/70 target/riscv: rvv-1.0: 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 | 4 ++-- target/riscv/vector_helper.c | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-)
target/riscv/helper.h +1 -1
@@ -1068,7 +1068,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
@@ -592,7 +592,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 +2 -2
@@ -2929,7 +2929,7 @@ static bool trans_vpopc_m(DisasContext *s, arg_rmr *a) }/* vmfirst find-first-set mask bit */ -static bool trans_vmfirst_m (DisasContext *s,arg_rmr *a) +static bool trans_vfirst_m (DisasContext *s,arg_rmr *a) {if (require_rvv (s) &&vext_check_isa_ill (s)) {
@@ -2948,7 +2948,7 @@ static bool trans_vmfirst_m(DisasContext *s, arg_rmr *a)tcg_gen_addi_ptr (src2, cpu_env,vreg_ofs (s, a->rs2));tcg_gen_addi_ptr (mask, cpu_env,vreg_ofs (s,0 )); -gen_helper_vmfirst_m (dst, mask, src2, cpu_env, desc); +gen_helper_vfirst_m (dst, mask, src2, cpu_env, desc);gen_set_gpr (a->rd, dst);tcg_temp_free_ptr (mask);
target/riscv/vector_helper.c +3 -3
@@ -4466,9 +4466,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 v4 30/70 target/riscv: rvv-1.0: 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 | 5 ++++- target/riscv/vector_helper.c | 4 ---- 3 files changed, 7 insertions(+), 8 deletions(-)
target/riscv/insn32.decode +3 -3
@@ -593,9 +593,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 +4 -1
@@ -2966,7 +2966,10 @@ 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)) { \ + if (require_rvv(s) && \ + vext_check_isa_ill(s) && \ + require_vm(a->vm, a->rd) && \ + (a->rd != a->rs2)) { \ uint32_t data = 0; \ gen_helper_gvec_3_ptr *fn = gen_helper_##NAME; \ TCGLabel *over = gen_new_label(); \
target/riscv/vector_helper.c +0 -4
@@ -4493,7 +4493,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;
@@ -4523,9 +4522,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 v4 31/70 target/riscv: rvv-1.0: iota 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
@@ -596,7 +596,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
Signature · 1 line
2.17.1
RFC v4 32/70 target/riscv: rvv-1.0: element index 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
@@ -597,7 +597,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
Signature · 1 line
2.17.1
RFC v4 33/70 target/riscv: rvv-1.0: allow load element with sign-extended
In reply to [email protected]From: Frank Chang <[email protected]>
For some vector instructions (e.g. vmv.s.x), the element is loaded with sign-extended.
--- target/riscv/insn_trans/trans_rvv.inc.c | 32 +++++++++++++++++-------- 1 file changed, 22 insertions(+), 10 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +22 -10
@@ -3052,17 +3052,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);
@@ -3117,7 +3129,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);
@@ -3135,9 +3147,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)
@@ -3147,7 +3159,7 @@ static bool trans_vext_x_v(DisasContext *s, arg_r *a)if (a->rs1 ==0 ) {/* Special case vmv.x.s rd, vs2. */ -vec_element_loadi (s, tmp, a->rs2,0 ); +vec_element_loadi (s, tmp, a->rs2,0 , false); }else {/* This instruction ignores LMUL and vector register groups */ int vlmax = s->vlen >> (3 + s->sew);
@@ -3229,7 +3241,7 @@ static bool trans_vfmv_f_s(DisasContext *s, arg_vfmv_f_s *a) (s->mstatus_fs != 0) && (s->sew != 0)) {unsigned int len =8 << s->sew; -vec_element_loadi (s, cpu_fpr[a->rd], a->rs2,0 ); +vec_element_loadi (s, cpu_fpr[a->rd], a->rs2,0 , false);if (len <64 ) {tcg_gen_ori_i64 (cpu_fpr[a->rd], cpu_fpr[a->rd],MAKE_64BIT_MASK (len,64 - len));
@@ -3331,7 +3343,7 @@ static bool trans_vrgather_vx(DisasContext *s, arg_rmrr *a)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); }
Signature · 1 line
2.17.1
RFC v4 34/70 target/riscv: rvv-1.0: register gather instructions
In reply to [email protected]From: Frank Chang <[email protected]>
* Add vrgatherei16.vv instruction.
--- target/riscv/helper.h | 4 ++++ target/riscv/insn32.decode | 1 + target/riscv/insn_trans/trans_rvv.inc.c | 21 +++++++++++++++++++-- target/riscv/vector_helper.c | 23 ++++++++++++++--------- 4 files changed, 38 insertions(+), 11 deletions(-)
target/riscv/helper.h +4 -0
@@ -1105,6 +1105,10 @@ 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) DEF_HELPER_6(vrgather_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vrgatherei16_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vrgatherei16_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vrgatherei16_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vrgatherei16_vv_d, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vrgather_vx_b, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vrgather_vx_h, void, ptr, ptr, tl, ptr, env, i32)DEF_HELPER_6 (vrgather_vx_w, void, ptr, ptr, tl, ptr, env, i32)
target/riscv/insn32.decode +1 -0
@@ -609,6 +609,7 @@ vslidedown_vx 001111 . ..... ..... 100 ..... 1010111 @r_vm vslidedown_vi 001111 . ..... ..... 011 ..... 1010111 @r_vm vslide1down_vx 001111 . ..... ..... 110 ..... 1010111 @r_vm vrgather_vv 001100 . ..... ..... 000 ..... 1010111 @r_vm +vrgatherei16_vv 001110 . ..... ..... 000 ..... 1010111 @r_vm vrgather_vx 001100 . ..... ..... 100 ..... 1010111 @r_vm vrgather_vi 001100 . ..... ..... 011 ..... 1010111 @r_vm vcompress_vm 010111 - ..... ..... 010 ..... 1010111 @r
target/riscv/insn_trans/trans_rvv.inc.c +19 -2
@@ -3319,7 +3319,21 @@ static bool vrgather_vv_check(DisasContext *s, arg_rmrr *a)require_vm (a->vm, a->rd); } +static bool vrgatherei16_vv_check (DisasContext *s,arg_rmrr *a) +{ +int8_t emul =4 - (s->sew +3 ) + s->lmul; +return require_rvv (s) && +vext_check_isa_ill (s) && + (emul >=-3 && emul <=3 ) && +require_align (a->rd,1 << s->lmul) && +require_align (a->rs1,1 << emul) && +require_align (a->rs2,1 << s->lmul) && + (a->rd != a->rs2 && a->rd != a->rs1) && +require_vm (a->vm, a->rd); +} + GEN_OPIVV_TRANS(vrgather_vv, vrgather_vv_check) +GEN_OPIVV_TRANS(vrgatherei16_vv, vrgatherei16_vv_check)static bool vrgather_vx_check (DisasContext *s,arg_rmrr *a) {
@@ -3339,7 +3353,8 @@ static bool trans_vrgather_vx(DisasContext *s, arg_rmrr *a) }if (a->vm && s->vl_eq_vlmax) { -int vlmax = s->vlen; +int scale = s->lmul - (s->sew +3 ); +int vlmax = scale <0 ? s->vlen >> -scale : s->vlen << scale;TCGv_i64 dest =tcg_temp_new_i64 ();if (a->rs1 ==0 ) {
@@ -3370,7 +3385,9 @@ static bool trans_vrgather_vi(DisasContext *s, arg_rmrr *a) }if (a->vm && s->vl_eq_vlmax) { -if (a->rs1 >= s->vlen) { +int scale = s->lmul - (s->sew +3 ); +int vlmax = scale <0 ? s->vlen >> -scale : s->vlen << scale; +if (a->rs1 >= vlmax) {tcg_gen_gvec_dup_imm (SEW64 ,vreg_ofs (s, a->rd),MAXSZ (s),MAXSZ (s),0 ); }else {
target/riscv/vector_helper.c +14 -9
@@ -4693,11 +4693,11 @@ GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_w, uint32_t, H4)GEN_VEXT_VSLIDE1DOWN_VX (vslide1down_vx_d, uint64_t,H8 ) /* Vector Register Gather Instruction */ -#define GEN_VEXT_VRGATHER_VV (NAME ,ETYPE ,H ) \ +#define GEN_VEXT_VRGATHER_VV (NAME ,TS1 ,TS2 ,HS1 ,HS2 ) \ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ CPURISCVState *env, uint32_t desc) \ { \ - uint32_t vlmax = vext_max_elems(desc, ctzl(sizeof(ETYPE))); \ + uint32_t vlmax = vext_max_elems(desc, ctzl(sizeof(TS1))); \ uint32_t vm = vext_vm(desc); \ uint32_t vl = env->vl; \ uint32_t index, i; \
@@ -4706,20 +4706,25 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \if (!vm && !vext_elem_mask (v0, i)) { \continue ; \ } \ - index = *((ETYPE *)vs1 +H (i)); \ + index = *((TS1 *)vs1 +HS1 (i)); \if (index >= vlmax) { \ - *((ETYPE *)vd +H (i)) =0 ; \ + *((TS2 *)vd +HS2 (i)) =0 ; \ }else { \ - *((ETYPE *)vd +H (i)) = *((ETYPE *)vs2 +H (index)); \ + *((TS2 *)vd +HS2 (i)) = *((TS2 *)vs2 +HS2 (index)); \ } \ } \ }/* vd[i] = (vs1[i] >= VLMAX) ? 0 : vs2[vs1[i]]; */ -GEN_VEXT_VRGATHER_VV(vrgather_vv_b, uint8_t, H1) -GEN_VEXT_VRGATHER_VV(vrgather_vv_h, uint16_t, H2) -GEN_VEXT_VRGATHER_VV(vrgather_vv_w, uint32_t, H4) -GEN_VEXT_VRGATHER_VV(vrgather_vv_d, uint64_t, H8) +GEN_VEXT_VRGATHER_VV(vrgather_vv_b, uint8_t, uint8_t, H1, H1) +GEN_VEXT_VRGATHER_VV(vrgather_vv_h, uint16_t, uint16_t, H2, H2) +GEN_VEXT_VRGATHER_VV(vrgather_vv_w, uint32_t, uint32_t, H4, H4) +GEN_VEXT_VRGATHER_VV(vrgather_vv_d, uint64_t, uint64_t, H8, H8) + +GEN_VEXT_VRGATHER_VV(vrgatherei16_vv_b, uint16_t, uint8_t, H2, H1) +GEN_VEXT_VRGATHER_VV(vrgatherei16_vv_h, uint16_t, uint16_t, H2, H2) +GEN_VEXT_VRGATHER_VV(vrgatherei16_vv_w, uint16_t, uint32_t, H2, H4) +GEN_VEXT_VRGATHER_VV(vrgatherei16_vv_d, uint16_t, uint64_t, H2, H8)#define GEN_VEXT_VRGATHER_VX (NAME ,ETYPE ,H ) \ void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \
Signature · 1 line
2.17.1
Re: [RFC v4 34/70] target/riscv: rvv-1.0: register gather instructions
target/riscv/insn_trans/trans_rvv.inc.c static bool vrgather_vv_check(DisasContext *s, arg_rmrr *a) · line 3324
Quoted 3 lines · On 8/17/20 1:49 AM, [email protected] wrote:
target/riscv/insn_trans/trans_rvv.inc.c +3
-0+static bool vrgatherei16_vv_check (DisasContext *s,arg_rmrr *a) +{ +int8_t emul =4 - (s->sew +3 ) + s->lmul;
Similarly for EEW elsewhere. This should be
int emul = MO_16 - s->sew + s->lmul;
target/riscv/insn_trans/trans_rvv.inc.c static bool trans_vrgather_vx(DisasContext *s, arg_rmrr *a) · line 3357
Quoted 7 lines
target/riscv/insn_trans/trans_rvv.inc.c +2
-1@@ -3339,7 +3353,8 @@ static bool trans_vrgather_vx(DisasContext *s, arg_rmrr *a) }if (a->vm && s->vl_eq_vlmax) { -int vlmax = s->vlen; +int scale = s->lmul - (s->sew +3 ); +int vlmax = scale <0 ? s->vlen >> -scale : s->vlen << scale;
Isn't this what s->vlen is already computed as?
target/riscv/vector_helper.c GEN_VEXT_VSLIDE1DOWN_VX(vslide1down_vx_w, uint32_t, H4) · line 4700
Quoted 6 lines
target/riscv/vector_helper.c +2
-1+#define GEN_VEXT_VRGATHER_VV (NAME ,TS1 ,TS2 ,HS1 ,HS2 ) \ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ CPURISCVState *env, uint32_t desc) \ { \ -uint32_t vlmax =vext_max_elems (desc,ctzl (sizeof (ETYPE ))); \ + uint32_t vlmax = vext_max_elems(desc, ctzl(sizeof(TS1))); \
Surely you can't just use TS1? For vrgatherei16_vv_[wd], the maximum number of elements is still bound by TS2.
r~
RFC v4 35/70 target/riscv: rvv-1.0: integer scalar move instructions
In reply to [email protected]From: Frank Chang <[email protected]>
* Remove "vmv.s.x: dothing if rs1 == 0" constraint.
* Add vmv.x.s instruction.
--- target/riscv/insn32.decode | 3 +- target/riscv/insn_trans/trans_rvv.inc.c | 45 ++++++++++++++++++++----- 2 files changed, 39 insertions(+), 9 deletions(-)
target/riscv/insn32.decode +2 -1
@@ -598,8 +598,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 +37 -8
64 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC v4 36/70 target/riscv: rvv-1.0: floating-point move instruction
In reply to [email protected]From: Frank Chang <[email protected]>
NaN-boxed the scalar floating-point register based on RVV 1.0's rules.
--- target/riscv/insn_trans/trans_rvv.inc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +9 -2
@@ -2689,12 +2689,17 @@ GEN_OPFVF_TRANS(vfmerge_vfm, opfvf_check)static bool trans_vfmv_v_f (DisasContext *s,arg_vfmv_v_f *a) {if (require_rvv (s) && +has_ext (s,RVF ) &&vext_check_isa_ill (s) &&require_align (a->rd,1 << s->lmul) && (s->sew !=0 )) { +TCGv_i64 t1 =tcg_temp_local_new_i64 (); +/* NaN-box f[rs1] */ +do_nanbox (s, t1, cpu_fpr[a->rs1]); +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]); +MAXSZ (s),MAXSZ (s), t1);mark_vs_dirty (s); }else {TCGv_ptr dest;
@@ -2711,13 +2716,15 @@ static bool trans_vfmv_v_f(DisasContext *s, arg_vfmv_v_f *a) 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); + + fns[s->sew -1 ](dest, t1, cpu_env, desc);tcg_temp_free_ptr (dest);tcg_temp_free_i32 (desc);mark_vs_dirty (s);gen_set_label (over); } +tcg_temp_free_i64 (t1);return true; }return false;
Signature · 1 line
2.17.1
Re: [RFC v4 36/70] target/riscv: rvv-1.0: floating-point move instruction
target/riscv/insn_trans/trans_rvv.inc.c GEN_OPFVF_TRANS(vfmerge_vfm, opfvf_check) · line 2698
Quoted 10 lines · On 8/17/20 1:49 AM, [email protected] wrote:
static bool
trans_vfmv_v_f(DisasContext *s, arg_vfmv_v_f *a){ if (require_rvv(s) &&target/riscv/insn_trans/trans_rvv.inc.c +4
-0+ has_ext(s, RVF) && vext_check_isa_ill(s) && require_align(a->rd, 1 << s->lmul) && (s->sew != 0)) { +TCGv_i64 t1 =tcg_temp_local_new_i64 (); +/* NaN-box f[rs1] */ +do_nanbox (s, t1, cpu_fpr[a->rs1]);
Don't you need to check
s->sew == MO_64 ? has_ext(s, RVD) : has_ext(s, RVF)
?
It might be worth folding that into it's own helper function, which also incorporates the s->sew != 0 check. E.g.
static bool require_rvf(Disascontext *s)
{
switch (s->sew) {
case MO_16:
case MO_32:
return has_ext(s, RVF);
case MO_64:
return has_ext(s, RVD);
default:
return false;
}
}target/riscv/insn_trans/trans_rvv.inc.c GEN_OPFVF_TRANS(vfmerge_vfm, opfvf_check) · line 2705
Quoted 11 lines
target/riscv/insn_trans/trans_rvv.inc.c +5
-1+TCGv_i64 t1 =tcg_temp_local_new_i64 (); +/* NaN-box f[rs1] */ +do_nanbox (s, t1, cpu_fpr[a->rs1]); +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]); +MAXSZ (s),MAXSZ (s), t1);mark_vs_dirty (s); }else {TCGv_ptr dest;
Recall that local temps get written to the stack at branches.
You should avoid the local temp by computing do_nanbox on both arms of this IF.
In the else branch, do_nanbox should be after the brcond.
r~
Re: [RFC v4 36/70] target/riscv: rvv-1.0: floating-point move instruction
Quoted 12 lines · Richard Henderson
static bool
require_rvf(Disascontext *s){ switch (s->sew) { case MO_16: case MO_32: return has_ext(s, RVF); case MO_64: return has_ext(s, RVD); default: return false; } }
Oh, and check mstatus_fs here too. Which is missing in trans_vfmv_v_f, btw.
r~
RFC v4 37/70 target/riscv: rvv-1.0: floating-point scalar move instructions
In reply to [email protected]From: Frank Chang <[email protected]>
NaN-boxed the scalar floating-point register based on RVV 1.0's rules.
--- target/riscv/insn32.decode | 4 +-- target/riscv/insn_trans/trans_rvv.inc.c | 42 ++++++++++++++----------- 2 files changed, 25 insertions(+), 21 deletions(-)
target/riscv/insn32.decode +2 -2
@@ -601,8 +601,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 +23 -19
62 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC v4 37/70] target/riscv: rvv-1.0: floating-point scalar move instructions
Quoted 9 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
NaN-boxed the scalar floating-point register based on RVV 1.0's rules.
Signed-off-by Frank Chang <[email protected]>--- target/riscv/insn32.decode | 4 +-- target/riscv/insn_trans/trans_rvv.inc.c | 42 ++++++++++++++----------- 2 files changed, 25 insertions(+), 21 deletions(-)
Needs require_rvf(), as discussed vs the previous patch,
Otherwise,
r~
RFC v4 38/70 target/riscv: rvv-1.0: 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 | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
target/riscv/insn32.decode +4 -0
@@ -614,6 +614,10 @@ vrgatherei16_vv 001110 . ..... ..... 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 +25 -0
@@ -3479,3 +3479,28 @@ 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) \ +{ \ + if (require_rvv(s) && \ + QEMU_IS_ALIGNED(a->rd, LEN) && \ + QEMU_IS_ALIGNED(a->rs2, LEN)) { \ +/* EEW = 8 */ \ +tcg_gen_gvec_mov (MO_8 ,vreg_ofs (s, a->rd), \ +vreg_ofs (s, a->rs2), \ + s->vlen /8 *LEN , s->vlen /8 *LEN ); \ +mark_vs_dirty (s); \ +return true; \ + } \ +return false; \ +} + +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
Re: [RFC v4 38/70] target/riscv: rvv-1.0: whole register move instructions
Quoted 9 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Add the following instructions:
* vmv1r.v
* vmv2r.v
* vmv4r.v
* vmv8r.v
Quoted 5 lines
Signed-off-by Frank Chang <[email protected]>--- target/riscv/insn32.decode | 4 ++++ target/riscv/insn_trans/trans_rvv.inc.c | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
r~
RFC v4 39/70 target/riscv: rvv-1.0: 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 | 86 +++++++++++++++++++++++++ target/riscv/vector_helper.c | 31 +++++++++ 4 files changed, 139 insertions(+)
target/riscv/helper.h +14 -0
@@ -1118,3 +1118,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
@@ -619,5 +619,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 +86 -0
89 lines not on this page · raw message
target/riscv/vector_helper.c +31 -0
@@ -4775,3 +4775,34 @@ GEN_VEXT_VCOMPRESS_VM(vcompress_vm_b, uint8_t, H1) GEN_VEXT_VCOMPRESS_VM(vcompress_vm_h, uint16_t, H2) GEN_VEXT_VCOMPRESS_VM(vcompress_vm_w, uint32_t, H4)GEN_VEXT_VCOMPRESS_VM (vcompress_vm_d, uint64_t,H8 ) + +/* Vector Integer Extension */ +#define GEN_VEXT_INT_EXT (NAME ,ETYPE ,DTYPE ,HD ,HS1 ) \ +void HELPER(NAME)(void *vd, void *v0, void *vs2, \ + CPURISCVState *env, uint32_t 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)); \ + } \ +} + +GEN_VEXT_INT_EXT(vzext_vf2_h, uint16_t, uint8_t, H2, H1) +GEN_VEXT_INT_EXT(vzext_vf2_w, uint32_t, uint16_t, H4, H2) +GEN_VEXT_INT_EXT(vzext_vf2_d, uint64_t, uint32_t, H8, H4) +GEN_VEXT_INT_EXT(vzext_vf4_w, uint32_t, uint8_t, H4, H1) +GEN_VEXT_INT_EXT(vzext_vf4_d, uint64_t, uint16_t, H8, H2) +GEN_VEXT_INT_EXT(vzext_vf8_d, uint64_t, uint8_t, H8, H1) + +GEN_VEXT_INT_EXT(vsext_vf2_h, int16_t, int8_t, H2, H1) +GEN_VEXT_INT_EXT(vsext_vf2_w, int32_t, int16_t, H4, H2) +GEN_VEXT_INT_EXT(vsext_vf2_d, int64_t, int32_t, H8, H4) +GEN_VEXT_INT_EXT(vsext_vf4_w, int32_t, int8_t, H4, H1) +GEN_VEXT_INT_EXT(vsext_vf4_d, int64_t, int16_t, H8, H2) +GEN_VEXT_INT_EXT (vsext_vf8_d, int64_t, int8_t,H8 ,H1 )
Signature · 1 line
2.17.1
RFC v4 40/70 target/riscv: rvv-1.0: single-width averaging add and subtract instructions
In reply to [email protected]From: Frank Chang <[email protected]>
Add the following instructions:
* vaaddu.vv
* vaaddu.vx
* vasubu.vv
* vasubu.vx
Remove the following instructions:
* vadd.vi
--- 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
@@ -694,18 +694,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
@@ -457,11 +457,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
@@ -2237,10 +2237,13 @@ GEN_OPIVI_TRANS(vsadd_vi, IMM_SX, 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
Re: [RFC v4 40/70] target/riscv: rvv-1.0: single-width averaging add and subtract instructions
Quoted 13 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Add the following instructions:
* vaaddu.vv
* vaaddu.vx
* vasubu.vv
* vasubu.vxRemove the following instructions:
* vadd.vi
Quoted 7 lines
Signed-off-by 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(-)
r~
RFC v4 41/70 target/riscv: rvv-1.0: single-width bit shift instructions
In reply to [email protected]From: Frank Chang <[email protected]>
Truncate vsll.vi, vsrl.vi, vsra.vi's immediate values to lg2(SEW) bits.
--- 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
@@ -1915,9 +1915,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, IMM_ZX, vsll_vx, shli) -GEN_OPIVI_GVEC_TRANS(vsrl_vi, IMM_ZX, vsrl_vx, shri) -GEN_OPIVI_GVEC_TRANS (vsra_vi,IMM_ZX , vsra_vx, sari) +GEN_OPIVI_GVEC_TRANS(vsll_vi, IMM_TRUNC_SEW, vsll_vx, shli) +GEN_OPIVI_GVEC_TRANS(vsrl_vi, IMM_TRUNC_SEW, vsrl_vx, shri) +GEN_OPIVI_GVEC_TRANS (vsra_vi,IMM_TRUNC_SEW , vsra_vx, sari) /* Vector Narrowing Integer Right Shift Instructions */static bool opivv_narrow_check (DisasContext *s,arg_rmrr *a)
Signature · 1 line
2.17.1
RFC v4 42/70 target/riscv: rvv-1.0: integer add-with-carry/subtract-with-borrow
In reply to [email protected]From: Frank Chang <[email protected]>
Clear tail elements only if VTA is agnostic.
--- target/riscv/insn32.decode | 20 ++++++++++---------- target/riscv/insn_trans/trans_rvv.inc.c | 2 +- target/riscv/vector_helper.c | 14 ++++---------- 3 files changed, 15 insertions(+), 21 deletions(-)
target/riscv/insn32.decode +10 -10
@@ -342,16 +342,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
@@ -1774,7 +1774,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 +4 -10
@@ -1205,19 +1205,16 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ CPURISCVState *env, uint32_t desc) \ { \uint32_t vl = env->vl; \ -uint32_t vlmax =vext_maxsz (desc) /sizeof (ETYPE ); \ +uint32_t vm =vext_vm (desc); \uint32_t i; \ \for (i =0 ; i < vl; i++) { \ETYPE s1 = *((ETYPE *)vs1 +H (i)); \ETYPE s2 = *((ETYPE *)vs2 +H (i)); \ -uint8_t carry =vext_elem_mask (v0, i); \ +uint8_t carry = !vm ?vext_elem_mask (v0, i) :0 ; \ \vext_set_elem_mask (vd, i,DO_OP (s2, s1, carry)); \ } \ -for (; i < vlmax; i++) { \ -vext_set_elem_mask (vd, i,0 ); \ - } \ }GEN_VEXT_VMADC_VVM (vmadc_vvm_b, uint8_t,H1 ,DO_MADC )
@@ -1235,19 +1232,16 @@ 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_max_elems (desc,ctzl (sizeof (ETYPE ))); \ +uint32_t vm =vext_vm (desc); \uint32_t i; \ \for (i =0 ; i < vl; i++) { \ETYPE s2 = *((ETYPE *)vs2 +H (i)); \ -uint8_t carry =vext_elem_mask (v0, i); \ +uint8_t carry = !vm ?vext_elem_mask (v0, i) :0 ; \ \vext_set_elem_mask (vd, i, \DO_OP (s2, (ETYPE )(target_long )s1, carry)); \ } \ -for (; i < vlmax; i++) { \ -vext_set_elem_mask (vd, i,0 ); \ - } \ }GEN_VEXT_VMADC_VXM (vmadc_vxm_b, uint8_t,H1 ,DO_MADC )
Signature · 1 line
2.17.1
Re: [RFC v4 42/70] target/riscv: rvv-1.0: integer add-with-carry/subtract-with-borrow
Quoted 10 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Clear tail elements only if VTA is agnostic.
Signed-off-by Frank Chang <[email protected]>--- target/riscv/insn32.decode | 20 ++++++++++---------- target/riscv/insn_trans/trans_rvv.inc.c | 2 +- target/riscv/vector_helper.c | 14 ++++---------- 3 files changed, 15 insertions(+), 21 deletions(-)
The patch description is wrong, but the code is correct.
One nit:
Review
Quoted 2 lines
(quoted diff) +1
-1- uint8_t carry = vext_elem_mask(v0, i); \ + uint8_t carry = !vm ? vext_elem_mask(v0, i) : 0; \
ETYPE carry = !vm && vext_elem_mask(v0, i);
r~
RFC v4 43/70 target/riscv: rvv-1.0: 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
@@ -397,18 +397,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
@@ -370,12 +370,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
@@ -1920,7 +1920,7 @@ GEN_OPIVI_GVEC_TRANS(vsrl_vi, IMM_TRUNC_SEW, vsrl_vx, shri)GEN_OPIVI_GVEC_TRANS (vsra_vi,IMM_TRUNC_SEW , vsra_vx, sari) /* 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) {return require_rvv (s) && vext_check_isa_ill(s) &&
@@ -1928,10 +1928,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, \
@@ -1953,10 +1953,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) {return require_rvv (s) && vext_check_isa_ill(s) &&
@@ -1964,10 +1964,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, \
@@ -1978,14 +1978,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 ,IMM_MODE ,OPIVX ) \ +/* OPIWI with NARROW */ +#define GEN_OPIWI_NARROW_TRANS (NAME ,IMM_MODE ,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, \
@@ -1997,8 +1997,8 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \return false; \ } -GEN_OPIVI_NARROW_TRANS(vnsra_vi, IMM_ZX, vnsra_vx) -GEN_OPIVI_NARROW_TRANS (vnsrl_vi,IMM_ZX , vnsrl_vx) +GEN_OPIWI_NARROW_TRANS(vnsra_wi, IMM_ZX, vnsra_wx) +GEN_OPIWI_NARROW_TRANS (vnsrl_wi,IMM_ZX , vnsrl_wx)/* Vector Integer Comparison Instructions */ /*
target/riscv/vector_helper.c +12 -12
@@ -1377,18 +1377,18 @@ GEN_VEXT_SHIFT_VX(vsra_vx_w, int32_t, int32_t, H4, H4, DO_SRL, 0x1f)GEN_VEXT_SHIFT_VX (vsra_vx_d, int64_t, int64_t,H8 ,H8 ,DO_SRL ,0x3f ) /* Vector Narrowing Integer Right Shift Instructions */ -GEN_VEXT_SHIFT_VV(vnsrl_vv_b, uint8_t, uint16_t, H1, H2, DO_SRL, 0xf) -GEN_VEXT_SHIFT_VV(vnsrl_vv_h, uint16_t, uint32_t, H2, H4, DO_SRL, 0x1f) -GEN_VEXT_SHIFT_VV(vnsrl_vv_w, uint32_t, uint64_t, H4, H8, DO_SRL, 0x3f) -GEN_VEXT_SHIFT_VV(vnsra_vv_b, uint8_t, int16_t, H1, H2, DO_SRL, 0xf) -GEN_VEXT_SHIFT_VV(vnsra_vv_h, uint16_t, int32_t, H2, H4, DO_SRL, 0x1f) -GEN_VEXT_SHIFT_VV(vnsra_vv_w, uint32_t, int64_t, H4, H8, DO_SRL, 0x3f) -GEN_VEXT_SHIFT_VX(vnsrl_vx_b, uint8_t, uint16_t, H1, H2, DO_SRL, 0xf) -GEN_VEXT_SHIFT_VX(vnsrl_vx_h, uint16_t, uint32_t, H2, H4, DO_SRL, 0x1f) -GEN_VEXT_SHIFT_VX(vnsrl_vx_w, uint32_t, uint64_t, H4, H8, DO_SRL, 0x3f) -GEN_VEXT_SHIFT_VX(vnsra_vx_b, int8_t, int16_t, H1, H2, DO_SRL, 0xf) -GEN_VEXT_SHIFT_VX(vnsra_vx_h, int16_t, int32_t, H2, H4, DO_SRL, 0x1f) -GEN_VEXT_SHIFT_VX (vnsra_vx_w, int32_t, int64_t,H4 ,H8 ,DO_SRL ,0x3f ) +GEN_VEXT_SHIFT_VV(vnsrl_wv_b, uint8_t, uint16_t, H1, H2, DO_SRL, 0xf) +GEN_VEXT_SHIFT_VV(vnsrl_wv_h, uint16_t, uint32_t, H2, H4, DO_SRL, 0x1f) +GEN_VEXT_SHIFT_VV(vnsrl_wv_w, uint32_t, uint64_t, H4, H8, DO_SRL, 0x3f) +GEN_VEXT_SHIFT_VV(vnsra_wv_b, uint8_t, int16_t, H1, H2, DO_SRL, 0xf) +GEN_VEXT_SHIFT_VV(vnsra_wv_h, uint16_t, int32_t, H2, H4, DO_SRL, 0x1f) +GEN_VEXT_SHIFT_VV(vnsra_wv_w, uint32_t, int64_t, H4, H8, DO_SRL, 0x3f) +GEN_VEXT_SHIFT_VX(vnsrl_wx_b, uint8_t, uint16_t, H1, H2, DO_SRL, 0xf) +GEN_VEXT_SHIFT_VX(vnsrl_wx_h, uint16_t, uint32_t, H2, H4, DO_SRL, 0x1f) +GEN_VEXT_SHIFT_VX(vnsrl_wx_w, uint32_t, uint64_t, H4, H8, DO_SRL, 0x3f) +GEN_VEXT_SHIFT_VX(vnsra_wx_b, int8_t, int16_t, H1, H2, DO_SRL, 0xf) +GEN_VEXT_SHIFT_VX(vnsra_wx_h, int16_t, int32_t, H2, H4, DO_SRL, 0x1f) +GEN_VEXT_SHIFT_VX (vnsra_wx_w, int32_t, int64_t,H4 ,H8 ,DO_SRL ,0x3f ) /* Vector Integer Comparison Instructions */#define DO_MSEQ (N ,M ) (N == M)
Signature · 1 line
2.17.1
RFC v4 44/70 target/riscv: rvv-1.0: 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
@@ -438,9 +438,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 v4 45/70 target/riscv: rvv-1.0: add Zvqmac extension
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/cpu.c | 1 + target/riscv/cpu.h | 1 + target/riscv/translate.c | 2 ++ 3 files changed, 4 insertions(+)
target/riscv/cpu.c +1 -0
@@ -512,6 +512,7 @@ static Property riscv_cpu_properties[] = {DEFINE_PROP_BOOL ("Counters" ,RISCVCPU , cfg.ext_counters, true),DEFINE_PROP_BOOL ("Zifencei" ,RISCVCPU , cfg.ext_ifencei, true),DEFINE_PROP_BOOL ("Zicsr" ,RISCVCPU , cfg.ext_icsr, true), +DEFINE_PROP_BOOL ("Zvqmac" ,RISCVCPU , cfg.ext_vqmac, true),DEFINE_PROP_STRING ("priv_spec" ,RISCVCPU , cfg.priv_spec),DEFINE_PROP_STRING ("vext_spec" ,RISCVCPU , cfg.vext_spec), DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128),
target/riscv/cpu.h +1 -0
@@ -285,6 +285,7 @@ typedef struct RISCVCPU {bool ext_counters;bool ext_ifencei;bool ext_icsr; +bool ext_vqmac;char *priv_spec;char *user_spec;
target/riscv/translate.c +2 -0
@@ -75,6 +75,7 @@ typedef struct DisasContext {uint8_t sew;uint16_t vlen;bool vl_eq_vlmax; +bool ext_vqmac; } DisasContext;#ifdef TARGET_RISCV64
@@ -870,6 +871,7 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->misa = env->misa; ctx->frm =-1 ;/* unknown rounding mode */ ctx->ext_ifencei = cpu->cfg.ext_ifencei; + ctx->ext_vqmac = cpu->cfg.ext_vqmac; ctx->vlen = cpu->cfg.vlen; ctx->vill =FIELD_EX32 (tb_flags,TB_FLAGS ,VILL ); ctx->sew =FIELD_EX32 (tb_flags,TB_FLAGS ,SEW );
Signature · 1 line
2.17.1
Re: [RFC v4 45/70] target/riscv: rvv-1.0: add Zvqmac extension
Quoted 8 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>--- target/riscv/cpu.c | 1 + target/riscv/cpu.h | 1 + target/riscv/translate.c | 2 ++ 3 files changed, 4 insertions(+)
r~
Re: [RFC v4 45/70] target/riscv: rvv-1.0: add Zvqmac extension
Quoted 11 lines · Richard Henderson
Quoted 8 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>--- target/riscv/cpu.c | 1 + target/riscv/cpu.h | 1 + target/riscv/translate.c | 2 ++ 3 files changed, 4 insertions(+)Reviewed-by Richard Henderson <[email protected]>
On second thought, the current manual says
# This is only a proposal for a future extension after v1.0 and might change substantially before ratifcation.
and does not even include the opcodes for these.
I think we should focus on 1.0 and drop this extension for now.
r~
RFC v4 46/70 target/riscv: rvv-1.0: 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 | 109 ++++++++++++++++++++++++ target/riscv/vector_helper.c | 40 +++++++++ 4 files changed, 171 insertions(+)
target/riscv/helper.h +15 -0
@@ -640,6 +640,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
@@ -441,6 +441,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 +109 -0
127 lines not on this page · raw message
target/riscv/vector_helper.c +40 -0
@@ -1983,6 +1983,46 @@ GEN_VEXT_VX(vwmaccus_vx_b, 1, 2) GEN_VEXT_VX(vwmaccus_vx_h, 2, 4)GEN_VEXT_VX (vwmaccus_vx_w,4 ,8 ) +/* 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) +GEN_VEXT_VV(vqmaccu_vv_h, 2, 8) +GEN_VEXT_VV(vqmacc_vv_b, 1, 4) +GEN_VEXT_VV(vqmacc_vv_h, 2, 8) +GEN_VEXT_VV(vqmaccsu_vv_b, 1, 4) +GEN_VEXT_VV(vqmaccsu_vv_h, 2, 8) + +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) +GEN_VEXT_VX(vqmaccu_vx_h, 2, 8) +GEN_VEXT_VX(vqmacc_vx_b, 1, 4) +GEN_VEXT_VX(vqmacc_vx_h, 2, 8) +GEN_VEXT_VX(vqmaccsu_vx_b, 1, 4) +GEN_VEXT_VX(vqmaccsu_vx_h, 2, 8) +GEN_VEXT_VX(vqmaccus_vx_b, 1, 4) +GEN_VEXT_VX (vqmaccus_vx_h,2 ,8 ) + /* Vector Integer Merge and Move Instructions */#define GEN_VEXT_VMV_VV (NAME ,ETYPE ,H ) \ void HELPER(NAME)(void *vd, void *vs1, CPURISCVState *env, \
Signature · 1 line
2.17.1
Re: [RFC v4 46/70] target/riscv: rvv-1.0: quad-widening integer multiply-add instructions
Quoted 12 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Add the following instructions:
* vqmaccu.vv
* vqmaccu.vx
* vqmacc.vv
* vqmacc.vx
* vqmaccsu.vv
* vqmaccsu.vx
* vqmaccus.vx
Quoted 7 lines
Signed-off-by Frank Chang <[email protected]>--- target/riscv/helper.h | 15 ++++ target/riscv/insn32.decode | 7 ++ target/riscv/insn_trans/trans_rvv.inc.c | 109 ++++++++++++++++++++++++ target/riscv/vector_helper.c | 40 +++++++++ 4 files changed, 171 insertions(+)
As mentioned, let's table this one for now.
r~
RFC v4 47/70 target/riscv: rvv-1.0: 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 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/insn_trans/trans_rvv.inc.c +1 -1
@@ -2341,7 +2341,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, IMM_ZX, vsaddu_vx, opivx_check) +GEN_OPIVI_TRANS(vsaddu_vi, IMM_SX, vsaddu_vx, opivx_check)GEN_OPIVI_TRANS (vsadd_vi,IMM_SX , vsadd_vx, opivx_check)/* Vector Single-Width Averaging Add and Subtract */
Signature · 1 line
2.17.1
Re: [RFC v4 47/70] target/riscv: rvv-1.0: single-width saturating add and subtract instructions
Quoted 8 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Sign-extend vsaddu.vi immediate value.
Signed-off-by Frank Chang <[email protected]>--- target/riscv/insn_trans/trans_rvv.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
RFC v4 48/70 target/riscv: rvv-1.0: integer comparison instructions
In reply to [email protected]From: Frank Chang <[email protected]>
* Sign-extend vmselu.vi and vmsgtu.vi immediate values.
* Remove "set tail elements to zeros" as tail elements can be unchanged for either VTA to have undisturbed or agnostic setting.
--- target/riscv/insn_trans/trans_rvv.inc.c | 4 ++-- target/riscv/vector_helper.c | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +2 -2
@@ -2090,9 +2090,9 @@ GEN_OPIVX_TRANS(vmsgt_vx, opivx_cmp_check) GEN_OPIVI_TRANS(vmseq_vi, IMM_SX, vmseq_vx, opivx_cmp_check) GEN_OPIVI_TRANS(vmsne_vi, IMM_SX, vmsne_vx, opivx_cmp_check) -GEN_OPIVI_TRANS(vmsleu_vi, IMM_ZX, vmsleu_vx, opivx_cmp_check) +GEN_OPIVI_TRANS(vmsleu_vi, IMM_SX, vmsleu_vx, opivx_cmp_check) GEN_OPIVI_TRANS(vmsle_vi, IMM_SX, vmsle_vx, opivx_cmp_check) -GEN_OPIVI_TRANS(vmsgtu_vi, IMM_ZX, vmsgtu_vx, opivx_cmp_check) +GEN_OPIVI_TRANS(vmsgtu_vi, IMM_SX, vmsgtu_vx, opivx_cmp_check)GEN_OPIVI_TRANS (vmsgt_vi,IMM_SX , vmsgt_vx, opivx_cmp_check)/* Vector Integer Min/Max Instructions */
target/riscv/vector_helper.c +0 -8
@@ -1403,7 +1403,6 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ { \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++) { \
@@ -1414,9 +1413,6 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ } \vext_set_elem_mask (vd, i,DO_OP (s2, s1)); \ } \ -for (; i < vlmax; i++) { \ -vext_set_elem_mask (vd, i,0 ); \ - } \ }GEN_VEXT_CMP_VV (vmseq_vv_b, uint8_t,H1 ,DO_MSEQ )
@@ -1455,7 +1451,6 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \ { \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++) { \
@@ -1466,9 +1461,6 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \vext_set_elem_mask (vd, i, \DO_OP (s2, (ETYPE )(target_long )s1)); \ } \ -for (; i < vlmax; i++) { \ -vext_set_elem_mask (vd, i,0 ); \ - } \ }GEN_VEXT_CMP_VX (vmseq_vx_b, uint8_t,H1 ,DO_MSEQ )
Signature · 1 line
2.17.1
Re: [RFC v4 48/70] target/riscv: rvv-1.0: integer comparison instructions
Quoted 11 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
* Sign-extend vmselu.vi and vmsgtu.vi immediate values.
* Remove "set tail elements to zeros" as tail elements can be unchanged for either VTA to have undisturbed or agnostic setting.Signed-off-by Frank Chang <[email protected]>--- target/riscv/insn_trans/trans_rvv.inc.c | 4 ++-- target/riscv/vector_helper.c | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-)
r~
RFC v4 49/70 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
@@ -3980,12 +3980,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)
@@ -4041,12 +4035,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)
@@ -4054,13 +4042,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 v4 50/70 target/riscv: rvv-1.0: floating-point compare instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/vector_helper.c | 8 -------- 1 file changed, 8 deletions(-)
target/riscv/vector_helper.c +0 -8
@@ -3963,7 +3963,6 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ { \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++) { \
@@ -3975,9 +3974,6 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \vext_set_elem_mask (vd, i, \DO_OP (s2, s1, &env->fp_status)); \ } \ -for (; i < vlmax; i++) { \ -vext_set_elem_mask (vd, i,0 ); \ - } \ }GEN_VEXT_CMP_VV_ENV (vmfeq_vv_h, uint16_t,H2 , float16_eq_quiet)
@@ -3990,7 +3986,6 @@ 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,ctzl (sizeof (ETYPE ))); \uint32_t i; \ \for (i =0 ; i < vl; i++) { \
@@ -4001,9 +3996,6 @@ 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 ); \ - } \ }GEN_VEXT_CMP_VF (vmfeq_vf_h, uint16_t,H2 , float16_eq_quiet)
Signature · 1 line
2.17.1
Re: [RFC v4 50/70] target/riscv: rvv-1.0: floating-point compare instructions
Quoted 6 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>--- target/riscv/vector_helper.c | 8 -------- 1 file changed, 8 deletions(-)
r~
RFC v4 51/70 target/riscv: rvv-1.0: mask-register logical instructions
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/insn_trans/trans_rvv.inc.c | 3 ++- target/riscv/vector_helper.c | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +2 -1
@@ -2987,7 +2987,8 @@ 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)) { \ + if (require_rvv(s) && \ + vext_check_isa_ill(s)) { \ uint32_t data = 0; \ gen_helper_gvec_4_ptr *fn = gen_helper_##NAME; \ TCGLabel *over = gen_new_label(); \
target/riscv/vector_helper.c +0 -4
@@ -4490,7 +4490,6 @@ 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 vl = env->vl; \uint32_t i; \int a, b; \
@@ -4500,9 +4499,6 @@ 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 ); \ - } \ }#define DO_NAND (N ,M ) (!(N & M))
Signature · 1 line
2.17.1
Re: [RFC v4 51/70] target/riscv: rvv-1.0: mask-register logical instructions
Quoted 7 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>--- target/riscv/insn_trans/trans_rvv.inc.c | 3 ++- target/riscv/vector_helper.c | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-)
r~
RFC v4 52/70 target/riscv: rvv-1.0: slide instructions
In reply to [email protected]From: Frank Chang <[email protected]>
* Remove clear function from helper functions as the tail elements are unchanged in RVV 1.0.
--- target/riscv/vector_helper.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
target/riscv/vector_helper.c +12 -7
@@ -4689,17 +4689,22 @@ GEN_VEXT_VSLIDEUP_VX(vslideup_vx_d, uint64_t, H8)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,ctzl (sizeof (ETYPE ))); \uint32_t vm =vext_vm (desc); \uint32_t vl = env->vl; \ -target_ulong offset = s1, i; \ +target_ulong i_max, i; \ \ -for (i =0 ; i < vl; ++i) { \ -target_ulong j = i + offset; \ -if (!vm && !vext_elem_mask (v0, i)) { \ -continue ; \ + i_max =MIN (s1 < vlmax ? vlmax - s1 :0 , vl); \ +for (i =0 ; i < i_max; ++i) { \ +if (vm ||vext_elem_mask (v0, i)) { \ + *((ETYPE *)vd +H (i)) = *((ETYPE *)vs2 +H (i + s1)); \ + } \ + } \ + \ +for (i = i_max; i < vl; ++i) { \ +if (vm ||vext_elem_mask (v0, i)) { \ + *((ETYPE *)vd +H (i)) =0 ; \ } \ - *((ETYPE *)vd +H (i)) = j >= vlmax ?0 : *((ETYPE *)vs2 +H (j)); \ } \ }
Signature · 1 line
2.17.1
Re: [RFC v4 52/70] target/riscv: rvv-1.0: slide instructions
Quoted 9 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
* Remove clear function from helper functions as the tail elements are unchanged in RVV 1.0.
Signed-off-by Frank Chang <[email protected]>--- target/riscv/vector_helper.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
r~
RFC v4 53/70 target/riscv: rvv-1.0: 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 | 141 ++++++++++++++++-------- 4 files changed, 109 insertions(+), 45 deletions(-)
target/riscv/helper.h +7 -0
@@ -1132,6 +1132,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
@@ -548,6 +548,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
@@ -3460,6 +3460,10 @@ GEN_OPIVX_TRANS(vslidedown_vx, slidedown_check) GEN_OPIVX_TRANS(vslide1down_vx, slidedown_check)GEN_OPIVI_TRANS (vslidedown_vi,IMM_ZX , 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 +96 -45
153 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC v4 53/70] target/riscv: rvv-1.0: floating-point slide instructions
target/riscv/helper.h DEF_HELPER_6(vslide1down_vx_h, void, ptr, ptr, tl, ptr, env, i32) · line 1140
Quoted 6 lines · On 8/17/20 1:49 AM, [email protected] wrote:
target/riscv/helper.h +6
-0+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)
You shouldn't need any new helpers.
The fp scalar argument can be passed to the existing helpers.
The manual doesn't explicitly say, but I assume the fp scalar needs to be nan-boxed (for sew > flen), or checked (for sew < flen), just like the scalar move instructions.
r~
Re: [RFC v4 53/70] target/riscv: rvv-1.0: floating-point slide instructions
Quoted 10 lines · Richard Henderson
target/riscv/helper.h DEF_HELPER_6(vslide1down_vx_h, void, ptr, ptr, tl, ptr, env, i32) · line 1140
Quoted 6 lines · On 8/17/20 1:49 AM, [email protected] wrote:
target/riscv/helper.h +6
-0+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)You shouldn't need any new helpers.
Quoted 2 lines
The fp scalar argument can be passed to the existing helpers.
I'm happy to reuse vslide1up_vx helper functions.
However, opfvf_trans() takes helper prototype of:
*typedef void gen_helper_opfvf(TCGv_ptr, TCGv_ptr, TCGv_i64, TCGv_ptr,
TCGv_env, TCGv_i32);*
but vslide1up_vx helper function's prototype is:
*typedef void gen_helper_opivx(TCGv_ptr, TCGv_ptr, TCGv, TCGv_ptr,
TCGv_env, TCGv_i32);*
The third argument has different types, not sure if it's worth it to sync them
all to TCGv_i64.
But I'm afraid it would require more effort than keeping them in different helper functions.
Frank Chang
Quoted 8 lines
The manual doesn't explicitly say, but I assume the fp scalar needs to be nan-boxed (for sew > flen), or checked (for sew < flen), just like the scalar
move instructions.r~
Re: [RFC v4 53/70] target/riscv: rvv-1.0: floating-point slide instructions
Quoted 11 lines · Frank Chang
I'm happy to reuse
vslide1up_vxhelper functions.However, opfvf_trans() takes helper prototype of:
/typedef voidgen_helper_opfvf(TCGv_ptr, TCGv_ptr, TCGv_i64, TCGv_ptr, TCGv_env, TCGv_i32);/
butvslide1up_vxhelper function's prototype is:
/typedef voidgen_helper_opivx(TCGv_ptr, TCGv_ptr, TCGv, TCGv_ptr, TCGv_env, TCGv_i32);/The third argument has different types, not sure if it's worth it to sync them all to TCGv_i64.
Ah, yes.
It could be useful to always widen to TCGv_i64 -- that's what gvec does in general. But I certainly won't insist.
r~
RFC v4 54/70 target/riscv: rvv-1.0: 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
@@ -786,18 +786,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
@@ -487,12 +487,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
@@ -2376,12 +2376,12 @@ GEN_OPIVI_TRANS(vssrl_vi, IMM_ZX, vssrl_vx, opivx_check)GEN_OPIVI_TRANS (vssra_vi,IMM_SX , 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, IMM_ZX, vnclipu_vx) -GEN_OPIVI_NARROW_TRANS(vnclip_vi, IMM_ZX, 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, IMM_ZX, vnclipu_wx) +GEN_OPIWI_NARROW_TRANS(vnclip_wi, IMM_ZX, 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 v4 55/70 target/riscv: rvv-1.0: single-width floating-point reduction
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/vector_helper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
target/riscv/vector_helper.c +6 -6
@@ -4432,14 +4432,14 @@ GEN_VEXT_FRED(vfredsum_vs_w, uint32_t, uint32_t, H4, H4, float32_add)GEN_VEXT_FRED (vfredsum_vs_d, uint64_t, uint64_t,H8 ,H8 , float64_add) /* Maximum value */ -GEN_VEXT_FRED(vfredmax_vs_h, uint16_t, uint16_t, H2, H2, float16_maxnum) -GEN_VEXT_FRED(vfredmax_vs_w, uint32_t, uint32_t, H4, H4, float32_maxnum) -GEN_VEXT_FRED (vfredmax_vs_d, uint64_t, uint64_t,H8 ,H8 , float64_maxnum) +GEN_VEXT_FRED(vfredmax_vs_h, uint16_t, uint16_t, H2, H2, float16_maxnum_noprop) +GEN_VEXT_FRED(vfredmax_vs_w, uint32_t, uint32_t, H4, H4, float32_maxnum_noprop) +GEN_VEXT_FRED (vfredmax_vs_d, uint64_t, uint64_t,H8 ,H8 , float64_maxnum_noprop) /* Minimum value */ -GEN_VEXT_FRED(vfredmin_vs_h, uint16_t, uint16_t, H2, H2, float16_minnum) -GEN_VEXT_FRED(vfredmin_vs_w, uint32_t, uint32_t, H4, H4, float32_minnum) -GEN_VEXT_FRED (vfredmin_vs_d, uint64_t, uint64_t,H8 ,H8 , float64_minnum) +GEN_VEXT_FRED(vfredmin_vs_h, uint16_t, uint16_t, H2, H2, float16_minnum_noprop) +GEN_VEXT_FRED(vfredmin_vs_w, uint32_t, uint32_t, H4, H4, float32_minnum_noprop) +GEN_VEXT_FRED (vfredmin_vs_d, uint64_t, uint64_t,H8 ,H8 , float64_minnum_noprop)/* Vector Widening Floating-Point Reduction Instructions */ /* Unordered reduce 2*SEW = 2*SEW + sum(promote(SEW)) */
Signature · 1 line
2.17.1
Re: [RFC v4 55/70] target/riscv: rvv-1.0: single-width floating-point reduction
Quoted 6 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>--- target/riscv/vector_helper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
The one sentence in the manual is quite poor for this, and needs improvement:
Quoted 2 lines
Floating-point max and min reductions should return the same final> value and raise the same exception flags regardless of operation order.
It doesn't actually say anything about the way in which we've implemented the *_noprop functions.
Anyway,
r~
Re: [RFC v4 55/70] target/riscv: rvv-1.0: single-width floating-point reduction
Quoted 2 lines · Richard Henderson
It doesn't actually say anything about the way in which we've implemented the
*_nopropfunctions.
Ho hum. It seems v2.2 has changed fmin/fmax for the fpu as well.
We really should fix that too...
r~
Re: [RFC v4 55/70] target/riscv: rvv-1.0: single-width floating-point reduction
Quoted 13 lines · Richard Henderson
Quoted 1 line · Richard Henderson
It doesn't actually say anything about the way in which we've
implemented the
Quoted 1 line
*_nopropfunctions.Ho hum. It seems v2.2 has changed fmin/fmax for the fpu as well.
We really should fix that too...
r~
The noprop is implemented in below patch and could be applied to scalar part
https://patchew.org/QEMU/[email protected]/
Chih-Min Chao
RFC v4 56/70 target/riscv: rvv-1.0: widening floating-point reduction instructions
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
@@ -2977,7 +2977,7 @@ 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)/* *** Vector Mask Operations
Signature · 1 line
2.17.1
Re: [RFC v4 56/70] target/riscv: rvv-1.0: widening floating-point reduction instructions
Quoted 6 lines · On 8/17/20 1:49 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(-)
r~
RFC v4 57/70 target/riscv: rvv-1.0: single-width scaling shift instructions
In reply to [email protected]From: Frank Chang <[email protected]>
log(SEW) truncate vssra.vi immediate value.
--- target/riscv/insn_trans/trans_rvv.inc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/riscv/insn_trans/trans_rvv.inc.c +2 -2
@@ -2372,8 +2372,8 @@ GEN_OPIVV_TRANS(vssrl_vv, opivv_check) 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, IMM_ZX, vssrl_vx, opivx_check) -GEN_OPIVI_TRANS (vssra_vi,IMM_SX , vssra_vx, opivx_check) +GEN_OPIVI_TRANS(vssrl_vi, IMM_TRUNC_SEW, vssrl_vx, opivx_check) +GEN_OPIVI_TRANS (vssra_vi,IMM_TRUNC_SEW , vssra_vx, opivx_check) /* Vector Narrowing Fixed-Point Clip Instructions */GEN_OPIWV_NARROW_TRANS (vnclipu_wv)
Signature · 1 line
2.17.1
Re: [RFC v4 57/70] target/riscv: rvv-1.0: single-width scaling shift instructions
Quoted 8 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
log(SEW) truncate vssra.vi immediate value.
Signed-off-by Frank Chang <[email protected]>--- target/riscv/insn_trans/trans_rvv.inc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
r~
RFC v4 58/70 target/riscv: rvv-1.0: 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
@@ -747,28 +747,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
@@ -474,13 +474,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
@@ -2358,15 +2358,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 v4 59/70 target/riscv: rvv-1.0: 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
@@ -963,12 +963,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
@@ -553,8 +553,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
@@ -2765,7 +2765,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) {
@@ -2781,7 +2780,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
@@ -3883,19 +3883,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 v4 60/70 target/riscv: rvv-1.0: 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
@@ -603,7 +603,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
@@ -3158,8 +3158,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) {
@@ -3261,27 +3259,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 , false); - }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 v4 61/70 target/riscv: rvv-1.0: 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
@@ -3640,28 +3640,28 @@ GEN_VEXT_V_ENV(vfsqrt_v_w, 4, 4)GEN_VEXT_V_ENV (vfsqrt_v_d,8 ,8 ) /* 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) GEN_VEXT_VV_ENV(vfmin_vv_w, 4, 4) GEN_VEXT_VV_ENV(vfmin_vv_d, 8, 8) -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) GEN_VEXT_VF(vfmin_vf_w, 4, 4) GEN_VEXT_VF(vfmin_vf_d, 8, 8) -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) GEN_VEXT_VV_ENV(vfmax_vv_w, 4, 4) GEN_VEXT_VV_ENV(vfmax_vv_d, 8, 8) -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) GEN_VEXT_VF(vfmax_vf_w, 4, 4)GEN_VEXT_VF (vfmax_vf_d,8 ,8 )
Signature · 1 line
2.17.1
Re: [RFC v4 61/70] target/riscv: rvv-1.0: floating-point min/max instructions
Quoted 6 lines · On 8/17/20 1:49 AM, [email protected] wrote:
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(-)
r~
RFC v4 62/70 target/riscv: introduce floating-point rounding mode enum
In reply to [email protected]From: Frank Chang <[email protected]>
--- target/riscv/fpu_helper.c | 12 ++++++------ target/riscv/insn_trans/trans_rvv.inc.c | 18 +++++++++--------- target/riscv/internals.h | 9 +++++++++ 3 files changed, 24 insertions(+), 15 deletions(-)
target/riscv/fpu_helper.c +6 -6
@@ -55,23 +55,23 @@ void helper_set_rounding_mode(CPURISCVState *env, uint32_t rm) {int softrm; -if (rm ==7 ) { +if (rm ==FRM_DYN ) { rm = env->frm; }switch (rm) { -case 0 : +case FRM_RNE : softrm = float_round_nearest_even;break ; -case 1 : +case FRM_RTZ : softrm = float_round_to_zero;break ; -case 2 : +case FRM_RDN : softrm = float_round_down;break ; -case 3 : +case FRM_RUP : softrm = float_round_up;break ; -case 4 : +case FRM_RMM : softrm = float_round_ties_away;break ;default :
target/riscv/insn_trans/trans_rvv.inc.c +9 -9
@@ -2430,7 +2430,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ gen_helper_##NAME##_d, \ }; \ TCGLabel *over = gen_new_label(); \ - gen_set_rm(s, 7); \ + gen_set_rm(s, FRM_DYN); \ tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -2510,7 +2510,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ gen_helper_##NAME##_w, \ gen_helper_##NAME##_d, \ }; \ - gen_set_rm(s, 7); \ + gen_set_rm(s, FRM_DYN); \ 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, \
@@ -2542,7 +2542,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ gen_helper_##NAME##_h, gen_helper_##NAME##_w, \ }; \ TCGLabel *over = gen_new_label(); \ - gen_set_rm(s, 7); \ + gen_set_rm(s, FRM_DYN); \ tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -2578,7 +2578,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ static gen_helper_opfvf *const fns[2] = { \ gen_helper_##NAME##_h, gen_helper_##NAME##_w, \ }; \ - gen_set_rm(s, 7); \ + gen_set_rm(s, FRM_DYN); \ 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, \
@@ -2608,7 +2608,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ gen_helper_##NAME##_h, gen_helper_##NAME##_w, \ }; \ TCGLabel *over = gen_new_label(); \ - gen_set_rm(s, 7); \ + gen_set_rm(s, FRM_DYN); \ tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -2644,7 +2644,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ static gen_helper_opfvf *const fns[2] = { \ gen_helper_##NAME##_h, gen_helper_##NAME##_w, \ }; \ - gen_set_rm(s, 7); \ + gen_set_rm(s, FRM_DYN); \ 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, \
@@ -2721,7 +2721,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ gen_helper_##NAME##_d, \ }; \ TCGLabel *over = gen_new_label(); \ - gen_set_rm(s, 7); \ + gen_set_rm(s, FRM_DYN); \ tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -2862,7 +2862,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ gen_helper_##NAME##_w, \ }; \ TCGLabel *over = gen_new_label(); \ - gen_set_rm(s, 7); \ + gen_set_rm(s, FRM_DYN); \ tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -2908,7 +2908,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ gen_helper_##NAME##_w, \ }; \ TCGLabel *over = gen_new_label(); \ - gen_set_rm(s, 7); \ + gen_set_rm(s, FRM_DYN); \ tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
target/riscv/internals.h +9 -0
@@ -37,6 +37,15 @@ target_ulong fclass_d(uint64_t frs1);#define SEW32 2#define SEW64 3 +enum { +FRM_RNE =0 ,/* Round to Nearest, ties to Even */ +FRM_RTZ =1 ,/* Round towards Zero */ +FRM_RDN =2 ,/* Round Down */ +FRM_RUP =3 ,/* Round Up */ +FRM_RMM =4 ,/* Round to Nearest, ties to Max Magnitude */ +FRM_DYN =7 ,/* Dynamic rounding mode */ +}; +static inline uint64_t nanbox_s (float32 f) {return f |MAKE_64BIT_MASK (32 ,32 );
Signature · 1 line
2.17.1
Re: [RFC v4 62/70] target/riscv: introduce floating-point rounding mode enum
Quoted 8 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
Signed-off-by Frank Chang <[email protected]>--- target/riscv/fpu_helper.c | 12 ++++++------ target/riscv/insn_trans/trans_rvv.inc.c | 18 +++++++++--------- target/riscv/internals.h | 9 +++++++++ 3 files changed, 24 insertions(+), 15 deletions(-)
r~
RFC v4 63/70 target/riscv: rvv-1.0: floating-point/integer type-convert instructions
In reply to [email protected]From: Frank Chang <[email protected]>
Add the following instructions:
* vfcvt.rtz.xu.f.v
* vfcvt.rtz.x.f.v
Also adjust GEN_OPFV_TRANS() to accept multiple floating-point rounding modes.
--- target/riscv/helper.h | 6 ++++++ target/riscv/insn32.decode | 11 +++++++---- target/riscv/insn_trans/trans_rvv.inc.c | 18 ++++++++++-------- target/riscv/vector_helper.c | 22 ++++++++++++++++++++++ 4 files changed, 45 insertions(+), 12 deletions(-)
target/riscv/helper.h +6 -0
@@ -984,6 +984,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
@@ -556,10 +556,13 @@ vmfge_vf 011111 . ..... ..... 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 +10 -8
@@ -2710,7 +2710,7 @@ static bool opfv_check(DisasContext *s, arg_rmr *a) (s->sew !=0 ); } -#define GEN_OPFV_TRANS (NAME ,CHECK ) \ +#define GEN_OPFV_TRANS (NAME ,CHECK ,FRM ) \ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ { \ if (CHECK(s, a)) { \
@@ -2721,7 +2721,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ gen_helper_##NAME##_d, \ }; \ TCGLabel *over = gen_new_label(); \ - gen_set_rm(s, FRM_DYN); \ + gen_set_rm(s, FRM); \ tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -2736,7 +2736,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \return false; \ } -GEN_OPFV_TRANS (vfsqrt_v, opfv_check) +GEN_OPFV_TRANS (vfsqrt_v, opfv_check,FRM_DYN ) /* Vector Floating-Point MIN/MAX Instructions */GEN_OPFVV_TRANS (vfmin_vv, opfvv_check)
@@ -2782,7 +2782,7 @@ GEN_OPFVF_TRANS(vmfgt_vf, opfvf_cmp_check)GEN_OPFVF_TRANS (vmfge_vf, opfvf_cmp_check) /* Vector Floating-Point Classify Instruction */ -GEN_OPFV_TRANS (vfclass_v, opfv_check) +GEN_OPFV_TRANS (vfclass_v, opfv_check,FRM_DYN ) /* Vector Floating-Point Merge Instruction */GEN_OPFVF_TRANS (vfmerge_vfm, opfvf_check)
@@ -2832,10 +2832,12 @@ static bool trans_vfmv_v_f(DisasContext *s, arg_vfmv_v_f *a) }/* Single-Width Floating-Point/Integer Type-Convert Instructions */ -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_xu_f_v, opfv_check, FRM_DYN) +GEN_OPFV_TRANS(vfcvt_x_f_v, opfv_check, FRM_DYN) +GEN_OPFV_TRANS(vfcvt_f_xu_v, opfv_check, FRM_DYN) +GEN_OPFV_TRANS(vfcvt_f_x_v, opfv_check, FRM_DYN) +GEN_OPFV_TRANS(vfcvt_rtz_xu_f_v, opfv_check, FRM_RTZ) +GEN_OPFV_TRANS (vfcvt_rtz_x_f_v, opfv_check,FRM_RTZ )/* Widening Floating-Point/Integer Type-Convert Instructions */
target/riscv/vector_helper.c +22 -0
@@ -4024,6 +4024,28 @@ GEN_VEXT_V_ENV(vfcvt_f_x_v_h, 2, 2) GEN_VEXT_V_ENV(vfcvt_f_x_v_w, 4, 4)GEN_VEXT_V_ENV (vfcvt_f_x_v_d,8 ,8 ) +/* +* vfcvt.rtz.xu.f.v vd, vs2, vm +* Convert float to unsigned integer, truncating. + */ +RVVCALL(OPFVV1, vfcvt_rtz_xu_f_v_h, OP_UU_H, H2, H2, float16_to_uint16) +RVVCALL(OPFVV1, vfcvt_rtz_xu_f_v_w, OP_UU_W, H4, H4, float32_to_uint32) +RVVCALL(OPFVV1, vfcvt_rtz_xu_f_v_d, OP_UU_D, H8, H8, float64_to_uint64) +GEN_VEXT_V_ENV(vfcvt_rtz_xu_f_v_h, 2, 2) +GEN_VEXT_V_ENV(vfcvt_rtz_xu_f_v_w, 4, 4) +GEN_VEXT_V_ENV (vfcvt_rtz_xu_f_v_d,8 ,8 ) + +/* +* vfcvt.rtz.x.f.v vd, vs2, vm +* Convert float to signed integer, truncating. + */ +RVVCALL(OPFVV1, vfcvt_rtz_x_f_v_h, OP_UU_H, H2, H2, float16_to_int16) +RVVCALL(OPFVV1, vfcvt_rtz_x_f_v_w, OP_UU_W, H4, H4, float32_to_int32) +RVVCALL(OPFVV1, vfcvt_rtz_x_f_v_d, OP_UU_D, H8, H8, float64_to_int64) +GEN_VEXT_V_ENV(vfcvt_rtz_x_f_v_h, 2, 2) +GEN_VEXT_V_ENV(vfcvt_rtz_x_f_v_w, 4, 4) +GEN_VEXT_V_ENV (vfcvt_rtz_x_f_v_d,8 ,8 ) +/* 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
Re: [RFC v4 63/70] target/riscv: rvv-1.0: floating-point/integer type-convert instructions
target/riscv/helper.h DEF_HELPER_5(vfcvt_f_xu_v_d, void, ptr, ptr, ptr, env, i32) · line 992
Quoted 6 lines · On 8/17/20 1:49 AM, [email protected] wrote:
target/riscv/helper.h +6
-0+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)
You do not need any of these new helpers, because...
target/riscv/insn_trans/trans_rvv.inc.c static bool trans_vfmv_v_f(DisasContext *s, arg_vfmv_v_f *a) · line 2840
Quoted 2 lines
target/riscv/insn_trans/trans_rvv.inc.c +2
-0+GEN_OPFV_TRANS(vfcvt_rtz_xu_f_v, opfv_check, FRM_RTZ) +GEN_OPFV_TRANS (vfcvt_rtz_x_f_v, opfv_check,FRM_RTZ )
You get to set round-to-zero mode here. Of course, the macro used will need to change...
r~
RFC v4 64/70 target/riscv: rvv-1.0: widening floating-point/integer type-convert
In reply to [email protected]From: Frank Chang <[email protected]>
Add the following instructions:
* vfwcvt.rtz.xu.f.v
* vfwcvt.rtz.x.f.v
Also adjust GEN_OPFV_WIDEN_TRANS() to accept multiple floating-point rounding modes.
--- target/riscv/helper.h | 6 +++ target/riscv/insn32.decode | 13 ++++--- target/riscv/insn_trans/trans_rvv.inc.c | 50 +++++++++++++++++++++---- target/riscv/vector_helper.c | 25 ++++++++++++- 4 files changed, 81 insertions(+), 13 deletions(-)
target/riscv/helper.h +6 -0
@@ -995,12 +995,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
@@ -563,11 +563,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 +43 -7
68 lines not on this page · raw message
target/riscv/vector_helper.c +24 -1
@@ -4048,6 +4048,7 @@ GEN_VEXT_V_ENV(vfcvt_rtz_x_f_v_d, 8, 8)/* 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.*/
@@ -4063,19 +4064,41 @@ GEN_VEXT_V_ENV(vfwcvt_x_f_v_h, 2, 4)GEN_VEXT_V_ENV (vfwcvt_x_f_v_w,4 ,8 ) /* 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) GEN_VEXT_V_ENV(vfwcvt_f_xu_v_h, 2, 4)GEN_VEXT_V_ENV (vfwcvt_f_xu_v_w,4 ,8 ) /* 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) GEN_VEXT_V_ENV(vfwcvt_f_x_v_h, 2, 4)GEN_VEXT_V_ENV (vfwcvt_f_x_v_w,4 ,8 )/* -* vfwcvt.f.f.v vd, vs2, vm # +* vfwcvt.rtz.xu.f.v vd, vs2, vm +* Convert float to double-width unsigned integer, truncating + */ +RVVCALL(OPFVV1, vfwcvt_rtz_xu_f_v_h, WOP_UU_H, H4, H2, float16_to_uint32) +RVVCALL(OPFVV1, vfwcvt_rtz_xu_f_v_w, WOP_UU_W, H8, H4, float32_to_uint64) +GEN_VEXT_V_ENV(vfwcvt_rtz_xu_f_v_h, 2, 4) +GEN_VEXT_V_ENV (vfwcvt_rtz_xu_f_v_w,4 ,8 ) + +/* +* vfwcvt.rtz.x.f.v vd, vs2, vm +* Convert float to double-width signed integer, truncating. + */ +RVVCALL(OPFVV1, vfwcvt_rtz_x_f_v_h, WOP_UU_H, H4, H2, float16_to_int32) +RVVCALL(OPFVV1, vfwcvt_rtz_x_f_v_w, WOP_UU_W, H8, H4, float32_to_int64) +GEN_VEXT_V_ENV(vfwcvt_rtz_x_f_v_h, 2, 4) +GEN_VEXT_V_ENV (vfwcvt_rtz_x_f_v_w,4 ,8 ) + +/* +* 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
Re: [RFC v4 64/70] target/riscv: rvv-1.0: widening floating-point/integer type-convert
Quoted 6 lines · On 8/17/20 1:49 AM, [email protected] wrote:
target/riscv/helper.h +1
-0@@ -995,12 +995,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)
target/riscv/helper.h DEF_HELPER_5(vfwcvt_xu_f_v_h, void, ptr, ptr, ptr, env, i32) · line 1009
Quoted 10 lines
target/riscv/helper.h +5
-0DEF_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)
Similarly, these last 4 helpers are not required.
r~
RFC v4 65/70 target/riscv: add "set round to odd" rounding mode helper function
In reply to [email protected]From: Frank Chang <[email protected]>
helper_set_rounding_mode() is responsible for SIGILL, and "round to odd" should be an interface private to translation, so add a new independent helper_set_rod_rounding_mode().
--- target/riscv/fpu_helper.c | 5 +++++ target/riscv/helper.h | 1 + target/riscv/internals.h | 1 + target/riscv/translate.c | 5 +++++ 4 files changed, 12 insertions(+)
target/riscv/fpu_helper.c +5 -0
@@ -81,6 +81,11 @@ void helper_set_rounding_mode(CPURISCVState *env, uint32_t rm)set_float_rounding_mode (softrm, &env->fp_status); } +void helper_set_rod_rounding_mode (CPURISCVState *env) +{ +set_float_rounding_mode (float_round_to_odd, &env->fp_status); +} +static uint64_t do_fmadd_s (CPURISCVState *env,uint64_t rs1,uint64_t rs2,uint64_t rs3,int flags) {
target/riscv/helper.h +1 -0
@@ -3,6 +3,7 @@ DEF_HELPER_2(raise_exception, noreturn, env, i32)/* Floating Point - rounding mode */ DEF_HELPER_FLAGS_2(set_rounding_mode, TCG_CALL_NO_WG, void, env, i32) +DEF_HELPER_FLAGS_1 (set_rod_rounding_mode,TCG_CALL_NO_WG , void, env) /* Floating Point - fused */DEF_HELPER_FLAGS_4 (fmadd_s,TCG_CALL_NO_RWG , i64, env, i64, i64, i64)
target/riscv/internals.h +1 -0
@@ -44,6 +44,7 @@ enum {FRM_RUP =3 ,/* Round Up */ FRM_RMM =4 ,/* Round to Nearest, ties to Max Magnitude */ FRM_DYN =7 ,/* Dynamic rounding mode */ + FRM_ROD = 8, /* Round to Odd */ };static inline uint64_t nanbox_s (float32 f)
target/riscv/translate.c +5 -0
@@ -30,6 +30,7 @@#include "exec/log.h" #include "instmap.h" +#include "internals.h" /* global register indices */ static TCGv cpu_gpr[32 ], cpu_pc, cpu_vl;
@@ -584,6 +585,10 @@ static void gen_set_rm(DisasContext *ctx, int rm)return ; } ctx->frm = rm; +if (rm ==FRM_ROD ) { +gen_helper_set_rod_rounding_mode (cpu_env); +return ; + } t0 =tcg_const_i32 (rm);gen_helper_set_rounding_mode (cpu_env, t0);tcg_temp_free_i32 (t0);
Signature · 1 line
2.17.1
Re: [RFC v4 65/70] target/riscv: add "set round to odd" rounding mode helper function
Quoted 13 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
helper_set_rounding_mode()is responsible for SIGILL, and "round to odd" should be an interface private to translation, so add a new independenthelper_set_rod_rounding_mode().Signed-off-by Frank Chang <[email protected]>--- target/riscv/fpu_helper.c | 5 +++++ target/riscv/helper.h | 1 + target/riscv/internals.h | 1 + target/riscv/translate.c | 5 +++++ 4 files changed, 12 insertions(+)
...
target/riscv/internals.h enum { · line 48
Quoted 6 lines
target/riscv/internals.h +1
-0@@ -44,6 +44,7 @@ enum {FRM_RUP =3 ,/* Round Up */ FRM_RMM =4 ,/* Round to Nearest, ties to Max Magnitude */ FRM_DYN =7 ,/* Dynamic rounding mode */ + FRM_ROD = 8, /* Round to Odd */ };
This needs a comment, or a rename, to indicate that it is private to qemu.
Otherwise,
r~
RFC v4 66/70 target/riscv: rvv-1.0: 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 | 51 ++++++++++++++--- target/riscv/vector_helper.c | 76 ++++++++++++++++++------- 4 files changed, 130 insertions(+), 42 deletions(-)
target/riscv/helper.h +20 -10
@@ -1009,16 +1009,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
@@ -571,11 +571,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 +44 -7
69 lines not on this page · raw message
target/riscv/vector_helper.c +56 -20
97 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC v4 66/70] target/riscv: rvv-1.0: narrowing floating-point/integer type-convert
target/riscv/helper.h DEF_HELPER_5(vfwcvt_rtz_xu_f_v_w, void, ptr, ptr, ptr, env, i32) · line 1031
Quoted 8 lines · On 8/17/20 1:49 AM, [email protected] wrote:
target/riscv/helper.h +8
-0+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)
These helpers are redundant with the ones that don't specify rounding mode, because you already handled that in the translator.
r~
RFC v4 67/70 target/riscv: rvv-1.0: relax RV_VLEN_MAX to 512-bits
In reply to [email protected]From: Frank Chang <[email protected]>
As GVEC only supports MAXSZ and OPRSZ in the range of: [8..256] bytes and LMUL could be a fractional number. The maximum vector size can be operated might be less than 8 bytes or larger than 256 bytes. Skip to use GVEC if maximum vector size <= 8 or >= 256 bytes.
--
Maybe to relax the limitations of MAXSZ or OPRSZ would be a better approach.
--- target/riscv/cpu.h | 13 +++++++------ target/riscv/insn_trans/trans_rvv.inc.c | 2 +- target/riscv/vector_helper.c | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-)
target/riscv/cpu.h +7 -6
@@ -92,7 +92,7 @@ typedef struct CPURISCVState CPURISCVState;#include "pmp.h" -#define RV_VLEN_MAX 256 +#define RV_VLEN_MAX 512 FIELD(VTYPE, VLMUL, 0, 3)FIELD (VTYPE ,VSEW ,3 ,3 )
@@ -413,16 +413,17 @@ static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,/* * 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. +* However, as GVEC only supports MAXSZ and OPRSZ in the range of: +* [8..256] bytes and LMUL could be a fractional number. The maximum +* vector size can be operated might be less than 8 bytes or +* larger than 256 bytes. So we set vl_eq_vlmax flag to true only +* when maxsz >= 8 bytes and <= 256 bytes. */ uint32_t vlmax =vext_get_vlmax (env_archcpu (env), env->vtype);uint32_t sew =FIELD_EX64 (env->vtype,VTYPE ,VSEW );uint32_t maxsz = vlmax << sew;bool vl_eq_vlmax = (env->vstart ==0 ) && (vlmax == env->vl) - && (maxsz >=8 ); + && (maxsz >=8 ) && (maxsz <=256 ); flags =FIELD_DP32 (flags,TB_FLAGS ,VILL ,FIELD_EX64 (env->vtype,VTYPE ,VILL )); flags =FIELD_DP32 (flags,TB_FLAGS ,SEW , sew);
target/riscv/insn_trans/trans_rvv.inc.c +1 -1
@@ -669,7 +669,7 @@ static bool ldst_us_trans(uint32_t vd, uint32_t rs1, uint32_t data,/* * As simd_desc supports at most 256 bytes, and in this implementation, -* the max vector group length is 1024 bytes. So split it into two parts. +* the max vector group length is 2048 bytes. So split it into two parts. * * The first part is vlen in bytes, encoded in maxsz of simd_desc. * The second part is lmul, encoded in data of simd_desc.
target/riscv/vector_helper.c +1 -1
@@ -129,7 +129,7 @@ static uint32_t vext_wd(uint32_t desc)static inline uint32_t vext_max_elems (uint32_t desc,uint32_t esz) {/* -* As simd_desc support at most 256 bytes, the max vlen is 256 bits. +* As simd_desc support at most 256 bytes, the max vlen is 512 bits. * so vlen in bytes (vlenb) is encoded as maxsz. */ uint32_t vlenb =simd_maxsz (desc);
Signature · 1 line
2.17.1
Re: [RFC v4 67/70] target/riscv: rvv-1.0: relax RV_VLEN_MAX to 512-bits
Quoted 7 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Frank Chang <[email protected]>
As GVEC only supports MAXSZ and OPRSZ in the range of: [8..256] bytes and LMUL could be a fractional number. The maximum vector size can be operated might be less than 8 bytes or larger than 256 bytes. Skip to use GVEC if maximum vector size <= 8 or >= 256 bytes.
Quoted 5 lines
Signed-off-by Frank Chang <[email protected]>--
Maybe to relax the limitations of MAXSZ or OPRSZ would be a better approach.
I would definitely like to improve gvec to handle any actual vector length that you need. With VLEN=512 (bits) and LMUL=8, that gives you 512 byte vectors. Is that the limit of what you need, or did you want to go higher?
There will have to be some maximum supported by tcg, though. It's probably worth having an assert somewhere.
Perhaps something like
/*
* RV_LEN_MAX (bits) / 8 (bits-per-byte) * 8 (LMUL)
* = RV_LEN_MAX (bytes)
*
* should be less than the number of bytes supported by gvec. */QEMU_BUILD_BUG_ON(RV_VLEN_MAX > (8 << SIMD_MAXSZ_BITS));
Perhaps placed in in vector_helper.c, so that cpu.h does not have to include "tcg/tcg-gvec-desc.h".
However... simply increasing the number of bits in SIMD_MAXSZ_BITS and SIMD_OPRSZ_BITS will break Arm SVE -- we need 20 bits in simd_data(), and that's exactly what we have at present.
If we can come up with a more compact encoding of oprsz/maxsz, that would be ideal. Otherwise, I need to compress the data currently stored in simd_data().
-----
I suppose one point here is that for RISC-V, oprsz always equals maxsz. So we've effectively wasted 5 bits. Moreover, that's also true for Arm SVE.
However, Arm AdvSIMD, the older vector isa, will have oprsz == 8 or oprsz ==
16. Since the vector registers overlap, maxsz is the SVE vector length, and the area in between oprsz and maxsz is cleared.
If we ever merge the x86_64 AVX2 patches from last year's GSoC, and then expand on that to implement AVX512, then we would have oprsz == 16 or oprsz == 32, with maxsz == 64.
Perhaps we could reduce the generality of oprsz, and compress it into 2 bits:
0b00 -> 8
0b01 -> 16
0b10 -> 32
0b11 -> maxsz
Now we have 3 bits we can move over to the maxsz field, which will let us represent 8 * 256 or 2048 byte vectors.
Thoughts?
r~
RFC v4 68/70 target/riscv: gdb: modify gdb csr xml file to align with csr register map
In reply to [email protected]From: Hsiangkai Wang <[email protected]>
--- gdb-xml/riscv-32bit-csr.xml | 11 ++++++----- gdb-xml/riscv-64bit-csr.xml | 11 ++++++----- target/riscv/gdbstub.c | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-)
gdb-xml/riscv-32bit-csr.xml +6 -5
@@ -110,6 +110,8 @@ <reg name="mcause" bitsize="32"/> <reg name="mtval" bitsize="32"/> <reg name="mip" bitsize="32"/> + <reg name="mtinst" bitsize="32"/> + <reg name="mtval2" bitsize="32"/> <reg name="pmpcfg0" bitsize="32"/> <reg name="pmpcfg1" bitsize="32"/> <reg name="pmpcfg2" bitsize="32"/>
@@ -232,12 +234,11 @@ <reg name="hedeleg" bitsize="32"/> <reg name="hideleg" bitsize="32"/> <reg name="hie" bitsize="32"/> - <reg name="htvec" bitsize="32"/> - <reg name="hscratch" bitsize="32"/> - <reg name="hepc" bitsize="32"/> - <reg name="hcause" bitsize="32"/> - <reg name="hbadaddr" bitsize="32"/> + <reg name="hcounteren" bitsize="32"/> + <reg name="htval" bitsize="32"/> <reg name="hip" bitsize="32"/> + <reg name="htinst" bitsize="32"/> + <reg name="hgatp" bitsize="32"/> <reg name="mbase" bitsize="32"/> <reg name="mbound" bitsize="32"/> <reg name="mibase" bitsize="32"/>
gdb-xml/riscv-64bit-csr.xml +6 -5
@@ -110,6 +110,8 @@ <reg name="mcause" bitsize="64"/> <reg name="mtval" bitsize="64"/> <reg name="mip" bitsize="64"/> + <reg name="mtinst" bitsize="64"/> + <reg name="mtval2" bitsize="64"/> <reg name="pmpcfg0" bitsize="64"/> <reg name="pmpcfg1" bitsize="64"/> <reg name="pmpcfg2" bitsize="64"/>
@@ -232,12 +234,11 @@ <reg name="hedeleg" bitsize="64"/> <reg name="hideleg" bitsize="64"/> <reg name="hie" bitsize="64"/> - <reg name="htvec" bitsize="64"/> - <reg name="hscratch" bitsize="64"/> - <reg name="hepc" bitsize="64"/> - <reg name="hcause" bitsize="64"/> - <reg name="hbadaddr" bitsize="64"/> + <reg name="hcounteren" bitsize="64"/> + <reg name="htval" bitsize="64"/> <reg name="hip" bitsize="64"/> + <reg name="htinst" bitsize="64"/> + <reg name="hgatp" bitsize="64"/> <reg name="mbase" bitsize="64"/> <reg name="mbound" bitsize="64"/> <reg name="mibase" bitsize="64"/>
target/riscv/gdbstub.c +2 -2
@@ -418,13 +418,13 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) }#if defined(TARGET_RISCV32 )gdb_register_coprocessor (cs, riscv_gdb_get_csr, riscv_gdb_set_csr, -240 ,"riscv-32bit-csr.xml" ,0 ); +241 ,"riscv-32bit-csr.xml" ,0 );gdb_register_coprocessor (cs, riscv_gdb_get_virtual, riscv_gdb_set_virtual,1 ,"riscv-32bit-virtual.xml" ,0 );#elif defined(TARGET_RISCV64 )gdb_register_coprocessor (cs, riscv_gdb_get_csr, riscv_gdb_set_csr, -240 ,"riscv-64bit-csr.xml" ,0 ); +241 ,"riscv-64bit-csr.xml" ,0 );gdb_register_coprocessor (cs, riscv_gdb_get_virtual, riscv_gdb_set_virtual,1 ,"riscv-64bit-virtual.xml" ,0 );
Signature · 1 line
2.17.1
Re: [RFC v4 68/70] target/riscv: gdb: modify gdb csr xml file to align with csr register map
Quoted 9 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Hsiangkai Wang <[email protected]>
Signed-off-by Hsiangkai Wang <[email protected]>Signed-off-by Frank Chang <[email protected]>--- gdb-xml/riscv-32bit-csr.xml | 11 ++++++----- gdb-xml/riscv-64bit-csr.xml | 11 ++++++----- target/riscv/gdbstub.c | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-)
Looks ok, from a quick glance.
I do think that this could stand to be auto-generated as well, from an extended csr_ops table. Extended in that you'd want to include the name and the isa bit to which the register applies.
I'll let Alistair weigh in on this. But either way,
r~
RFC v4 69/70 target/riscv: gdb: support vector registers for rv64
In reply to [email protected]From: Hsiangkai Wang <[email protected]>
--- gdb-xml/riscv-64bit-csr.xml | 7 ++ target/riscv/cpu.c | 1 + target/riscv/cpu.h | 25 +++++++ target/riscv/gdbstub.c | 126 +++++++++++++++++++++++++++++++++++- 4 files changed, 157 insertions(+), 2 deletions(-)
gdb-xml/riscv-64bit-csr.xml +7 -0
@@ -248,4 +248,11 @@ <reg name="mucounteren" bitsize="64"/> <reg name="mscounteren" bitsize="64"/> <reg name="mhcounteren" bitsize="64"/> + <reg name="vstart" bitsize="64" group="vector"/> + <reg name="vxsat" bitsize="64" group="vector"/> + <reg name="vxrm" bitsize="64" group="vector"/> + <reg name="vcsr" bitsize="64" group="vector"/> + <reg name="vl" bitsize="64" group="vector"/> + <reg name="vtype" bitsize="64" group="vector"/> + <reg name="vlenb" bitsize="64" group="vector"/> </feature>
target/riscv/cpu.c +1 -0
@@ -548,6 +548,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)#elif defined(TARGET_RISCV64 ) cc->gdb_core_xml_file ="riscv-64bit-cpu.xml" ;#endif + cc->gdb_get_dynamic_xml = riscv_gdb_get_dynamic_xml; cc->gdb_stop_before_watchpoint = true; cc->disas_set_info = riscv_cpu_disas_set_info;#ifndef CONFIG_USER_ONLY
target/riscv/cpu.h +25 -0
@@ -102,6 +102,16 @@ FIELD(VTYPE, VEDIV, 8, 2) FIELD(VTYPE, RESERVED, 10, sizeof(target_ulong) * 8 - 11)FIELD (VTYPE ,VILL ,sizeof (target_ulong) *8 -1 ,1 ) +/** +* DynamicGDBXMLInfo: +* @desc: Contains the XML descriptions. +* @num: Number of the registers in this XML seen by GDB. + */ +typedef struct DynamicGDBXMLInfo { +char *desc; +int num; +}DynamicGDBXMLInfo ; +struct CPURISCVState {target_ulong gpr[32 ];uint64_t fpr[32 ];/* assume both F and D extensions */
@@ -295,6 +305,8 @@ typedef struct RISCVCPU {bool mmu;bool pmp; } cfg; + +DynamicGDBXMLInfo dyn_vreg_xml; }RISCVCPU ;static inline int riscv_has_ext (CPURISCVState *env,target_ulong ext)
@@ -485,6 +497,19 @@ typedef struct {void riscv_get_csr_ops (int csrno,riscv_csr_operations *ops);void riscv_set_csr_ops (int csrno,riscv_csr_operations *ops); +/* +* Helpers to dynamically generates XML descriptions of the +* vector registers. Returns the number of registers in each set. +*/ +int ricsv_gen_dynamic_vector_xml (CPUState *cpu,int base_reg); + +/* +* Returns the dynamically generated XML for the gdb stub. +* Returns a pointer to the XML contents for the specified XML file or NULL +* if the XML name doesn't match the predefined one. +*/ +const char *riscv_gdb_get_dynamic_xml (CPUState *cpu,const char *xmlname); +void riscv_cpu_register_gdb_regs_for_features (CPUState *cs);#endif /* RISCV_CPU_H */
target/riscv/gdbstub.c +124 -2
159 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC v4 69/70] target/riscv: gdb: support vector registers for rv64
gdb-xml/riscv-64bit-csr.xml line 257
Quoted 12 lines · On 8/17/20 1:49 AM, [email protected] wrote:
+++
b/gdb-xml/riscv-64bit-csr.xmlgdb-xml/riscv-64bit-csr.xml +7
-0@@ -248,4 +248,11 @@ <reg name="mucounteren" bitsize="64"/> <reg name="mscounteren" bitsize="64"/> <reg name="mhcounteren" bitsize="64"/> + <reg name="vstart" bitsize="64" group="vector"/> + <reg name="vxsat" bitsize="64" group="vector"/> + <reg name="vxrm" bitsize="64" group="vector"/> + <reg name="vcsr" bitsize="64" group="vector"/> + <reg name="vl" bitsize="64" group="vector"/> + <reg name="vtype" bitsize="64" group="vector"/> + <reg name="vlenb" bitsize="64" group="vector"/>
Just because these are csr's doesn't mean they're unrelated to RVV. I would think that ideally they would be in the (generated) RVV-related xml file.
But I'm certainly not a gdb expert. So if that doesn't work, fine, leave it as is.
However, if you leave these in the csr section, I think the next patch has to be folded in, because you've already included
target/riscv/gdbstub.c void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) · line 533
Quoted 4 lines
target/riscv/gdbstub.c +0
-0#if defined(TARGET_RISCV32 )gdb_register_coprocessor(cs,
riscv_gdb_get_csr,riscv_gdb_set_csr,target/riscv/gdbstub.c +1
-1- 241, "riscv-32bit-csr.xml", 0); + 248, "riscv-32bit-csr.xml", 0);
... this.
That said, the actual dynamic xml looks fine.
r~
RFC v4 70/70 target/riscv: gdb: support vector registers for rv32
In reply to [email protected]From: Greentime Hu <[email protected]>
This patch adds vector support for rv32 gdb. It allows gdb client to access vector registers correctly.
--- gdb-xml/riscv-32bit-csr.xml | 7 +++++++ 1 file changed, 7 insertions(+)
gdb-xml/riscv-32bit-csr.xml +7 -0
@@ -248,4 +248,11 @@ <reg name="mucounteren" bitsize="32"/> <reg name="mscounteren" bitsize="32"/> <reg name="mhcounteren" bitsize="32"/> + <reg name="vstart" bitsize="32" group="vector"/> + <reg name="vxsat" bitsize="32" group="vector"/> + <reg name="vxrm" bitsize="32" group="vector"/> + <reg name="vcsr" bitsize="32" group="vector"/> + <reg name="vl" bitsize="32" group="vector"/> + <reg name="vtype" bitsize="32" group="vector"/> + <reg name="vlenb" bitsize="32" group="vector"/> </feature>
Signature · 1 line
2.17.1
Re: [RFC v4 70/70] target/riscv: gdb: support vector registers for rv32
Quoted 18 lines · On 8/17/20 1:49 AM, [email protected] wrote:
From: Greentime Hu <[email protected]>
This patch adds vector support for rv32 gdb. It allows gdb client to access vector registers correctly.
Signed-off-by Greentime Hu <[email protected]>Signed-off-by Frank Chang <[email protected]>--- gdb-xml/riscv-32bit-csr.xml | 7 +++++++ 1 file changed, 7 insertions(+)gdb-xml/riscv-32bit-csr.xml +0
-0@@ -248,4 +248,11 @@ <reg name="mucounteren" bitsize="32"/>
gdb-xml/riscv-32bit-csr.xml line 258
Quoted 10 lines
gdb-xml/riscv-32bit-csr.xml +7
-0<reg name="mscounteren" bitsize="32"/> <reg name="mhcounteren" bitsize="32"/> + <reg name="vstart" bitsize="32" group="vector"/> + <reg name="vxsat" bitsize="32" group="vector"/> + <reg name="vxrm" bitsize="32" group="vector"/> + <reg name="vcsr" bitsize="32" group="vector"/> + <reg name="vl" bitsize="32" group="vector"/> + <reg name="vtype" bitsize="32" group="vector"/> + <reg name="vlenb" bitsize="32" group="vector"/> </feature>
As per comments in the previous patch, needs squashing.
r~
Quoted 160 lines · On Mon, Aug 17, 2020 at 4:50 PM <[email protected]> wrote:
From: Frank Chang <[email protected]>
This patchset implements the vector extension v1.0 for RISC-V on QEMU.
This patchset is sent as RFC because RVV v1.0 is still in draft state. v2 patchset was sent for RVV v0.9 and bumped to RVV v1.0 since v3 patchset.
The port is available here:
https://github.com/sifive/qemu/tree/rvv-1.0-upstream-v4You can change the cpu argument:
vext_specto v1.0 (i.e. vext_spec=v1.0) to run with RVV v1.0 instructions.Note: This patchset depends on two other patchsets listed in Based-on
section below so it might not able to be built unless those two patchsets are applied.Changelog:
v4
* remove explicit float flmul variable in DisasContext.
* replace floating-point calculations with shift operations to improve performance.
* relaxRV_VLEN_MAXto 512-bits.v3
* apply nan-box helpers from Richard Henderson.
* remove fp16 api changes as they are sent independently in another pathcset by Chih-Min Chao.
* remove all tail elements clear functions as tail elements can retain unchanged for either VTA set to undisturbed or agnostic.
* add fp16 nan-box check generator function.
* add floating-point rounding mode enum.
* replace flmul arithmetic with shifts to avoid floating-point conversions.
* add Zvqmac extension.
* replace gdbstub vector register xml files with dynamic generator.
* bumped to RVV v1.0.
* RVV v1.0 related changes:
* add vl<nf>re<eew>.v and vs<nf>r.v vector whole register load/store instructions
* add vrgatherei16 instruction.
* rearranged bits in vtype to make vlmul bits into a contiguous field.v2
* drop v0.7.1 support.
* replace invisible return check macros with functions.
* movemark_vs_dirty()to translators.
* addSSTATUS_VSflag for s-mode.
* nan-box scalar fp register for floating-point operations.
* add gdbstub files for vector registers to allow system-mode debugging with GDB.Based-on: <[email protected]/>
Based-on: <[email protected]/>Frank Chang (62):
target/riscv: drop vector 0.7.1 and add 1.0 support target/riscv: UseFIELD_EX32()to extract wd field target/riscv: rvv-1.0: introduce writable misa.v field target/riscv: rvv-1.0: remove rvv related codes from fcsr registers target/riscv: rvv-1.0: checkMSTATUS_VSwhen accessing vector csr
registers
target/riscv: rvv-1.0: remove MLEN calculations target/riscv: rvv-1.0: add fractional LMUL
target/riscv: rvv-1.0: add VMA and VTA
target/riscv: rvv-1.0: update check functions target/riscv: introduce more imm value modes in translator functions target/riscv: rvv:1.0: add translation-time nan-box helper function target/riscv: rvv-1.0: configure instructions target/riscv: rvv-1.0: stride load and store instructions target/riscv: rvv-1.0: index load and store instructions target/riscv: rvv-1.0: fix address index overflow bug of indexed
load/store insns
target/riscv: rvv-1.0: fault-only-first unit stride load target/riscv: rvv-1.0: amo operations
target/riscv: rvv-1.0: load/store whole register instructions target/riscv: rvv-1.0: updatevext_max_elems()for load/store insns target/riscv: rvv-1.0: take fractional LMUL into vector max elements
calculation
target/riscv: rvv-1.0: floating-point square-root instruction target/riscv: rvv-1.0: floating-point classify instructions target/riscv: rvv-1.0: mask population count instruction target/riscv: rvv-1.0: find-first-set mask bit instruction target/riscv: rvv-1.0: set-X-first mask bit instructions target/riscv: rvv-1.0: iota instruction
target/riscv: rvv-1.0: element index instruction target/riscv: rvv-1.0: allow load element with sign-extended target/riscv: rvv-1.0: register gather instructions target/riscv: rvv-1.0: integer scalar move instructions target/riscv: rvv-1.0: floating-point move instruction target/riscv: rvv-1.0: floating-point scalar move instructions target/riscv: rvv-1.0: whole register move instructions target/riscv: rvv-1.0: integer extension instructions target/riscv: rvv-1.0: single-width averaging add and subtract
instructions
target/riscv: rvv-1.0: single-width bit shift instructions target/riscv: rvv-1.0: integer add-with-carry/subtract-with-borrow target/riscv: rvv-1.0: narrowing integer right shift instructions target/riscv: rvv-1.0: widening integer multiply-add instructions target/riscv: rvv-1.0: add Zvqmac extension
target/riscv: rvv-1.0: quad-widening integer multiply-add instructions target/riscv: rvv-1.0: single-width saturating add and subtract
instructions
target/riscv: rvv-1.0: integer comparison instructions target/riscv: use softfloat lib float16 comparison functions target/riscv: rvv-1.0: floating-point compare instructions target/riscv: rvv-1.0: mask-register logical instructions target/riscv: rvv-1.0: slide instructions
target/riscv: rvv-1.0: floating-point slide instructions target/riscv: rvv-1.0: narrowing fixed-point clip instructions target/riscv: rvv-1.0: single-width floating-point reduction target/riscv: rvv-1.0: widening floating-point reduction instructions target/riscv: rvv-1.0: single-width scaling shift instructions target/riscv: rvv-1.0: remove widening saturating scaled multiply-add target/riscv: rvv-1.0: remove vmford.vv and vmford.vf target/riscv: rvv-1.0: remove integer extract instruction target/riscv: rvv-1.0: floating-point min/max instructions target/riscv: introduce floating-point rounding mode enum target/riscv: rvv-1.0: floating-point/integer type-convert
instructions
target/riscv: rvv-1.0: widening floating-point/integer type-convert target/riscv: add "set round to odd" rounding mode helper function target/riscv: rvv-1.0: narrowing floating-point/integer type-convert target/riscv: rvv-1.0: relaxRV_VLEN_MAXto 512-bitsGreentime Hu (2):
target/riscv: rvv-1.0: add vlenb register target/riscv: gdb: support vector registers for rv32Hsiangkai Wang (2):
target/riscv: gdb: modify gdb csr xml file to align with csr register
map
target/riscv: gdb: support vector registers for rv64LIU Zhiwei (4):
target/riscv: rvv-1.0: add mstatus VS field target/riscv: rvv-1.0: add sstatus VS field target/riscv: rvv-1.0: add translation-time vector context status target/riscv: rvv-1.0: add vcsr registergdb-xml/riscv-32bit-csr.xml | 18 +- gdb-xml/riscv-64bit-csr.xml | 18 +- target/riscv/cpu.c | 12 +- target/riscv/cpu.h | 97 +- target/riscv/cpu_bits.h | 10 + target/riscv/cpu_helper.c | 16 +- target/riscv/csr.c | 73 +- target/riscv/fpu_helper.c | 17 +- target/riscv/gdbstub.c | 126 +- target/riscv/helper.h | 523 ++-- target/riscv/insn32-64.decode | 18 +- target/riscv/insn32.decode | 295 +- target/riscv/insn_trans/trans_rvv.inc.c | 2366 ++++++++++------ target/riscv/internals.h | 19 +- target/riscv/translate.c | 68 +- target/riscv/vector_helper.c | 3269 +++++++++++------------ 16 files changed, 4051 insertions(+), 2894 deletions(-)
Quoted 4 lines
--
2.17.1
ping~
Quoted 163 lines · Frank Chang
Quoted 161 lines · On Mon, Aug 17, 2020 at 4:50 PM <[email protected]> wrote:
From: Frank Chang <[email protected]>
This patchset implements the vector extension v1.0 for RISC-V on QEMU.
This patchset is sent as RFC because RVV v1.0 is still in draft state. v2 patchset was sent for RVV v0.9 and bumped to RVV v1.0 since v3 patchset.
The port is available here:
https://github.com/sifive/qemu/tree/rvv-1.0-upstream-v4You can change the cpu argument:
vext_specto v1.0 (i.e. vext_spec=v1.0) to run with RVV v1.0 instructions.Note: This patchset depends on two other patchsets listed in Based-on
section below so it might not able to be built unless those two patchsets are applied.Changelog:
v4
* remove explicit float flmul variable in DisasContext.
* replace floating-point calculations with shift operations to improve performance.
* relaxRV_VLEN_MAXto 512-bits.v3
* apply nan-box helpers from Richard Henderson.
* remove fp16 api changes as they are sent independently in another pathcset by Chih-Min Chao.
* remove all tail elements clear functions as tail elements can retain unchanged for either VTA set to undisturbed or agnostic.
* add fp16 nan-box check generator function.
* add floating-point rounding mode enum.
* replace flmul arithmetic with shifts to avoid floating-point conversions.
* add Zvqmac extension.
* replace gdbstub vector register xml files with dynamic generator.
* bumped to RVV v1.0.
* RVV v1.0 related changes:
* add vl<nf>re<eew>.v and vs<nf>r.v vector whole register load/store instructions
* add vrgatherei16 instruction.
* rearranged bits in vtype to make vlmul bits into a contiguous field.v2
* drop v0.7.1 support.
* replace invisible return check macros with functions.
* movemark_vs_dirty()to translators.
* addSSTATUS_VSflag for s-mode.
* nan-box scalar fp register for floating-point operations.
* add gdbstub files for vector registers to allow system-mode debugging with GDB.Based-on: <[email protected]/>
Based-on: <[email protected]/>Frank Chang (62):
target/riscv: drop vector 0.7.1 and add 1.0 support target/riscv: UseFIELD_EX32()to extract wd field target/riscv: rvv-1.0: introduce writable misa.v field target/riscv: rvv-1.0: remove rvv related codes from fcsr registers target/riscv: rvv-1.0: checkMSTATUS_VSwhen accessing vector csr
registers
target/riscv: rvv-1.0: remove MLEN calculations target/riscv: rvv-1.0: add fractional LMUL
target/riscv: rvv-1.0: add VMA and VTA
target/riscv: rvv-1.0: update check functions target/riscv: introduce more imm value modes in translator functions target/riscv: rvv:1.0: add translation-time nan-box helper function target/riscv: rvv-1.0: configure instructions target/riscv: rvv-1.0: stride load and store instructions target/riscv: rvv-1.0: index load and store instructions target/riscv: rvv-1.0: fix address index overflow bug of indexed
load/store insns
target/riscv: rvv-1.0: fault-only-first unit stride load target/riscv: rvv-1.0: amo operations
target/riscv: rvv-1.0: load/store whole register instructions target/riscv: rvv-1.0: updatevext_max_elems()for load/store insns target/riscv: rvv-1.0: take fractional LMUL into vector max elements
calculation
target/riscv: rvv-1.0: floating-point square-root instruction target/riscv: rvv-1.0: floating-point classify instructions target/riscv: rvv-1.0: mask population count instruction target/riscv: rvv-1.0: find-first-set mask bit instruction target/riscv: rvv-1.0: set-X-first mask bit instructions target/riscv: rvv-1.0: iota instruction
target/riscv: rvv-1.0: element index instruction target/riscv: rvv-1.0: allow load element with sign-extended target/riscv: rvv-1.0: register gather instructions target/riscv: rvv-1.0: integer scalar move instructions target/riscv: rvv-1.0: floating-point move instruction target/riscv: rvv-1.0: floating-point scalar move instructions target/riscv: rvv-1.0: whole register move instructions target/riscv: rvv-1.0: integer extension instructions target/riscv: rvv-1.0: single-width averaging add and subtract
instructions
target/riscv: rvv-1.0: single-width bit shift instructions target/riscv: rvv-1.0: integer add-with-carry/subtract-with-borrow target/riscv: rvv-1.0: narrowing integer right shift instructions target/riscv: rvv-1.0: widening integer multiply-add instructions target/riscv: rvv-1.0: add Zvqmac extension
target/riscv: rvv-1.0: quad-widening integer multiply-add instructions target/riscv: rvv-1.0: single-width saturating add and subtract
instructions
target/riscv: rvv-1.0: integer comparison instructions target/riscv: use softfloat lib float16 comparison functions target/riscv: rvv-1.0: floating-point compare instructions target/riscv: rvv-1.0: mask-register logical instructions target/riscv: rvv-1.0: slide instructions
target/riscv: rvv-1.0: floating-point slide instructions target/riscv: rvv-1.0: narrowing fixed-point clip instructions target/riscv: rvv-1.0: single-width floating-point reduction target/riscv: rvv-1.0: widening floating-point reduction instructions target/riscv: rvv-1.0: single-width scaling shift instructions target/riscv: rvv-1.0: remove widening saturating scaled multiply-add target/riscv: rvv-1.0: remove vmford.vv and vmford.vf target/riscv: rvv-1.0: remove integer extract instruction target/riscv: rvv-1.0: floating-point min/max instructions target/riscv: introduce floating-point rounding mode enum target/riscv: rvv-1.0: floating-point/integer type-convert
instructions
target/riscv: rvv-1.0: widening floating-point/integer type-convert target/riscv: add "set round to odd" rounding mode helper function target/riscv: rvv-1.0: narrowing floating-point/integer type-convert target/riscv: rvv-1.0: relaxRV_VLEN_MAXto 512-bitsGreentime Hu (2):
target/riscv: rvv-1.0: add vlenb register target/riscv: gdb: support vector registers for rv32Hsiangkai Wang (2):
target/riscv: gdb: modify gdb csr xml file to align with csr register
map
target/riscv: gdb: support vector registers for rv64LIU Zhiwei (4):
target/riscv: rvv-1.0: add mstatus VS field target/riscv: rvv-1.0: add sstatus VS field target/riscv: rvv-1.0: add translation-time vector context status target/riscv: rvv-1.0: add vcsr registergdb-xml/riscv-32bit-csr.xml | 18 +- gdb-xml/riscv-64bit-csr.xml | 18 +- target/riscv/cpu.c | 12 +- target/riscv/cpu.h | 97 +- target/riscv/cpu_bits.h | 10 + target/riscv/cpu_helper.c | 16 +- target/riscv/csr.c | 73 +- target/riscv/fpu_helper.c | 17 +- target/riscv/gdbstub.c | 126 +- target/riscv/helper.h | 523 ++-- target/riscv/insn32-64.decode | 18 +- target/riscv/insn32.decode | 295 +- target/riscv/insn_trans/trans_rvv.inc.c | 2366 ++++++++++------ target/riscv/internals.h | 19 +- target/riscv/translate.c | 68 +- target/riscv/vector_helper.c | 3269 +++++++++++------------ 16 files changed, 4051 insertions(+), 2894 deletions(-)
Quoted 5 lines
Quoted 3 lines
--
2.17.1ping~
I wasn't really following too closely, but didn't Richard give comments?
Alistair
Quoted 170 lines · Alistair Francis
Quoted 9 lines · Frank Chang
Quoted 7 lines · On Mon, Aug 17, 2020 at 4:50 PM <[email protected]> wrote:
From: Frank Chang <[email protected]>
This patchset implements the vector extension v1.0 for RISC-V on QEMU.
This patchset is sent as RFC because RVV v1.0 is still in draft state. v2 patchset was sent for RVV v0.9 and bumped to RVV v1.0 since v3
patchset.
Quoted 158 lines
Quoted 157 lines
The port is available here:
https://github.com/sifive/qemu/tree/rvv-1.0-upstream-v4You can change the cpu argument:
vext_specto v1.0 (i.e. vext_spec=v1.0) to run with RVV v1.0 instructions.Note: This patchset depends on two other patchsets listed in Based-on
section below so it might not able to be built unless those two patchsets are applied.Changelog:
v4
* remove explicit float flmul variable in DisasContext.
* replace floating-point calculations with shift operations to improve performance.
* relaxRV_VLEN_MAXto 512-bits.v3
* apply nan-box helpers from Richard Henderson.
* remove fp16 api changes as they are sent independently in another pathcset by Chih-Min Chao.
* remove all tail elements clear functions as tail elements can retain unchanged for either VTA set to undisturbed or agnostic.
* add fp16 nan-box check generator function.
* add floating-point rounding mode enum.
* replace flmul arithmetic with shifts to avoid floating-point conversions.
* add Zvqmac extension.
* replace gdbstub vector register xml files with dynamic generator.
* bumped to RVV v1.0.
* RVV v1.0 related changes:
* add vl<nf>re<eew>.v and vs<nf>r.v vector whole register load/store instructions
* add vrgatherei16 instruction.
* rearranged bits in vtype to make vlmul bits into a contiguous field.v2
* drop v0.7.1 support.
* replace invisible return check macros with functions.
* movemark_vs_dirty()to translators.
* addSSTATUS_VSflag for s-mode.
* nan-box scalar fp register for floating-point operations.
* add gdbstub files for vector registers to allow system-mode debugging with GDB.Based-on: <[email protected]/>
Based-on: <[email protected]/>Frank Chang (62):
target/riscv: drop vector 0.7.1 and add 1.0 support target/riscv: UseFIELD_EX32()to extract wd field target/riscv: rvv-1.0: introduce writable misa.v field target/riscv: rvv-1.0: remove rvv related codes from fcsr registers target/riscv: rvv-1.0: checkMSTATUS_VSwhen accessing vector csr
registers
target/riscv: rvv-1.0: remove MLEN calculations target/riscv: rvv-1.0: add fractional LMUL
target/riscv: rvv-1.0: add VMA and VTA
target/riscv: rvv-1.0: update check functions target/riscv: introduce more imm value modes in translator functions target/riscv: rvv:1.0: add translation-time nan-box helper function target/riscv: rvv-1.0: configure instructions target/riscv: rvv-1.0: stride load and store instructions target/riscv: rvv-1.0: index load and store instructions target/riscv: rvv-1.0: fix address index overflow bug of indexed
load/store insns
target/riscv: rvv-1.0: fault-only-first unit stride load target/riscv: rvv-1.0: amo operations
target/riscv: rvv-1.0: load/store whole register instructions target/riscv: rvv-1.0: updatevext_max_elems()for load/store insns target/riscv: rvv-1.0: take fractional LMUL into vector max elements
calculation
target/riscv: rvv-1.0: floating-point square-root instruction target/riscv: rvv-1.0: floating-point classify instructions target/riscv: rvv-1.0: mask population count instruction target/riscv: rvv-1.0: find-first-set mask bit instruction target/riscv: rvv-1.0: set-X-first mask bit instructions target/riscv: rvv-1.0: iota instruction
target/riscv: rvv-1.0: element index instruction target/riscv: rvv-1.0: allow load element with sign-extended target/riscv: rvv-1.0: register gather instructions target/riscv: rvv-1.0: integer scalar move instructions target/riscv: rvv-1.0: floating-point move instruction target/riscv: rvv-1.0: floating-point scalar move instructions target/riscv: rvv-1.0: whole register move instructions target/riscv: rvv-1.0: integer extension instructions target/riscv: rvv-1.0: single-width averaging add and subtract
instructions
target/riscv: rvv-1.0: single-width bit shift instructions target/riscv: rvv-1.0: integer add-with-carry/subtract-with-borrow target/riscv: rvv-1.0: narrowing integer right shift instructions target/riscv: rvv-1.0: widening integer multiply-add instructions target/riscv: rvv-1.0: add Zvqmac extension
target/riscv: rvv-1.0: quad-widening integer multiply-add instructions target/riscv: rvv-1.0: single-width saturating add and subtract
instructions
target/riscv: rvv-1.0: integer comparison instructions target/riscv: use softfloat lib float16 comparison functions target/riscv: rvv-1.0: floating-point compare instructions target/riscv: rvv-1.0: mask-register logical instructions target/riscv: rvv-1.0: slide instructions
target/riscv: rvv-1.0: floating-point slide instructions target/riscv: rvv-1.0: narrowing fixed-point clip instructions target/riscv: rvv-1.0: single-width floating-point reduction target/riscv: rvv-1.0: widening floating-point reduction instructions target/riscv: rvv-1.0: single-width scaling shift instructions target/riscv: rvv-1.0: remove widening saturating scaled multiply-add target/riscv: rvv-1.0: remove vmford.vv and vmford.vf target/riscv: rvv-1.0: remove integer extract instruction target/riscv: rvv-1.0: floating-point min/max instructions target/riscv: introduce floating-point rounding mode enum target/riscv: rvv-1.0: floating-point/integer type-convert
instructions
target/riscv: rvv-1.0: widening floating-point/integer type-convert target/riscv: add "set round to odd" rounding mode helper function target/riscv: rvv-1.0: narrowing floating-point/integer type-convert target/riscv: rvv-1.0: relaxRV_VLEN_MAXto 512-bitsGreentime Hu (2):
target/riscv: rvv-1.0: add vlenb register target/riscv: gdb: support vector registers for rv32Hsiangkai Wang (2):
target/riscv: gdb: modify gdb csr xml file to align with csr register
map
target/riscv: gdb: support vector registers for rv64LIU Zhiwei (4):
target/riscv: rvv-1.0: add mstatus VS field target/riscv: rvv-1.0: add sstatus VS field target/riscv: rvv-1.0: add translation-time vector context status target/riscv: rvv-1.0: add vcsr registergdb-xml/riscv-32bit-csr.xml | 18 +- gdb-xml/riscv-64bit-csr.xml | 18 +- target/riscv/cpu.c | 12 +- target/riscv/cpu.h | 97 +- target/riscv/cpu_bits.h | 10 + target/riscv/cpu_helper.c | 16 +- target/riscv/csr.c | 73 +- target/riscv/fpu_helper.c | 17 +- target/riscv/gdbstub.c | 126 +- target/riscv/helper.h | 523 ++-- target/riscv/insn32-64.decode | 18 +- target/riscv/insn32.decode | 295 +- target/riscv/insn_trans/trans_rvv.inc.c | 2366 ++++++++++------ target/riscv/internals.h | 19 +- target/riscv/translate.c | 68 +- target/riscv/vector_helper.c | 3269 +++++++++++------------ 16 files changed, 4051 insertions(+), 2894 deletions(-)--
2.17.1
Quoted 6 lines
Quoted 1 line
ping~
I wasn't really following too closely, but didn't Richard give comments?
Alistair
Yeah, they were given in v3 patchset and I've made the changes based on Richard's comments in this v4 patchset.
Frank Chang
Quoted 173 lines · Frank Chang
Quoted 171 lines · Alistair Francis
Quoted 168 lines · Frank Chang
Quoted 161 lines · On Mon, Aug 17, 2020 at 4:50 PM <[email protected]> wrote:
From: Frank Chang <[email protected]>
This patchset implements the vector extension v1.0 for RISC-V on QEMU.
This patchset is sent as RFC because RVV v1.0 is still in draft state. v2 patchset was sent for RVV v0.9 and bumped to RVV v1.0 since v3 patchset.
The port is available here:
https://github.com/sifive/qemu/tree/rvv-1.0-upstream-v4You can change the cpu argument:
vext_specto v1.0 (i.e. vext_spec=v1.0) to run with RVV v1.0 instructions.Note: This patchset depends on two other patchsets listed in Based-on
section below so it might not able to be built unless those two patchsets are applied.Changelog:
v4
* remove explicit float flmul variable in DisasContext.
* replace floating-point calculations with shift operations to improve performance.
* relaxRV_VLEN_MAXto 512-bits.v3
* apply nan-box helpers from Richard Henderson.
* remove fp16 api changes as they are sent independently in another pathcset by Chih-Min Chao.
* remove all tail elements clear functions as tail elements can retain unchanged for either VTA set to undisturbed or agnostic.
* add fp16 nan-box check generator function.
* add floating-point rounding mode enum.
* replace flmul arithmetic with shifts to avoid floating-point conversions.
* add Zvqmac extension.
* replace gdbstub vector register xml files with dynamic generator.
* bumped to RVV v1.0.
* RVV v1.0 related changes:
* add vl<nf>re<eew>.v and vs<nf>r.v vector whole register load/store instructions
* add vrgatherei16 instruction.
* rearranged bits in vtype to make vlmul bits into a contiguous field.v2
* drop v0.7.1 support.
* replace invisible return check macros with functions.
* movemark_vs_dirty()to translators.
* addSSTATUS_VSflag for s-mode.
* nan-box scalar fp register for floating-point operations.
* add gdbstub files for vector registers to allow system-mode debugging with GDB.Based-on: <[email protected]/>
Based-on: <[email protected]/>Frank Chang (62):
target/riscv: drop vector 0.7.1 and add 1.0 support target/riscv: UseFIELD_EX32()to extract wd field target/riscv: rvv-1.0: introduce writable misa.v field target/riscv: rvv-1.0: remove rvv related codes from fcsr registers target/riscv: rvv-1.0: checkMSTATUS_VSwhen accessing vector csr
registers
target/riscv: rvv-1.0: remove MLEN calculations target/riscv: rvv-1.0: add fractional LMUL
target/riscv: rvv-1.0: add VMA and VTA
target/riscv: rvv-1.0: update check functions target/riscv: introduce more imm value modes in translator functions target/riscv: rvv:1.0: add translation-time nan-box helper function target/riscv: rvv-1.0: configure instructions target/riscv: rvv-1.0: stride load and store instructions target/riscv: rvv-1.0: index load and store instructions target/riscv: rvv-1.0: fix address index overflow bug of indexed
load/store insns
target/riscv: rvv-1.0: fault-only-first unit stride load target/riscv: rvv-1.0: amo operations
target/riscv: rvv-1.0: load/store whole register instructions target/riscv: rvv-1.0: updatevext_max_elems()for load/store insns target/riscv: rvv-1.0: take fractional LMUL into vector max elements
calculation
target/riscv: rvv-1.0: floating-point square-root instruction target/riscv: rvv-1.0: floating-point classify instructions target/riscv: rvv-1.0: mask population count instruction target/riscv: rvv-1.0: find-first-set mask bit instruction target/riscv: rvv-1.0: set-X-first mask bit instructions target/riscv: rvv-1.0: iota instruction
target/riscv: rvv-1.0: element index instruction target/riscv: rvv-1.0: allow load element with sign-extended target/riscv: rvv-1.0: register gather instructions target/riscv: rvv-1.0: integer scalar move instructions target/riscv: rvv-1.0: floating-point move instruction target/riscv: rvv-1.0: floating-point scalar move instructions target/riscv: rvv-1.0: whole register move instructions target/riscv: rvv-1.0: integer extension instructions target/riscv: rvv-1.0: single-width averaging add and subtract
instructions
target/riscv: rvv-1.0: single-width bit shift instructions target/riscv: rvv-1.0: integer add-with-carry/subtract-with-borrow target/riscv: rvv-1.0: narrowing integer right shift instructions target/riscv: rvv-1.0: widening integer multiply-add instructions target/riscv: rvv-1.0: add Zvqmac extension
target/riscv: rvv-1.0: quad-widening integer multiply-add instructions target/riscv: rvv-1.0: single-width saturating add and subtract
instructions
target/riscv: rvv-1.0: integer comparison instructions target/riscv: use softfloat lib float16 comparison functions target/riscv: rvv-1.0: floating-point compare instructions target/riscv: rvv-1.0: mask-register logical instructions target/riscv: rvv-1.0: slide instructions
target/riscv: rvv-1.0: floating-point slide instructions target/riscv: rvv-1.0: narrowing fixed-point clip instructions target/riscv: rvv-1.0: single-width floating-point reduction target/riscv: rvv-1.0: widening floating-point reduction instructions target/riscv: rvv-1.0: single-width scaling shift instructions target/riscv: rvv-1.0: remove widening saturating scaled multiply-add target/riscv: rvv-1.0: remove vmford.vv and vmford.vf target/riscv: rvv-1.0: remove integer extract instruction target/riscv: rvv-1.0: floating-point min/max instructions target/riscv: introduce floating-point rounding mode enum target/riscv: rvv-1.0: floating-point/integer type-convert
instructions
target/riscv: rvv-1.0: widening floating-point/integer type-convert target/riscv: add "set round to odd" rounding mode helper function target/riscv: rvv-1.0: narrowing floating-point/integer type-convert target/riscv: rvv-1.0: relaxRV_VLEN_MAXto 512-bitsGreentime Hu (2):
target/riscv: rvv-1.0: add vlenb register target/riscv: gdb: support vector registers for rv32Hsiangkai Wang (2):
target/riscv: gdb: modify gdb csr xml file to align with csr register
map
target/riscv: gdb: support vector registers for rv64LIU Zhiwei (4):
target/riscv: rvv-1.0: add mstatus VS field target/riscv: rvv-1.0: add sstatus VS field target/riscv: rvv-1.0: add translation-time vector context status target/riscv: rvv-1.0: add vcsr registergdb-xml/riscv-32bit-csr.xml | 18 +- gdb-xml/riscv-64bit-csr.xml | 18 +- target/riscv/cpu.c | 12 +- target/riscv/cpu.h | 97 +- target/riscv/cpu_bits.h | 10 + target/riscv/cpu_helper.c | 16 +- target/riscv/csr.c | 73 +- target/riscv/fpu_helper.c | 17 +- target/riscv/gdbstub.c | 126 +- target/riscv/helper.h | 523 ++-- target/riscv/insn32-64.decode | 18 +- target/riscv/insn32.decode | 295 +- target/riscv/insn_trans/trans_rvv.inc.c | 2366 ++++++++++------ target/riscv/internals.h | 19 +- target/riscv/translate.c | 68 +- target/riscv/vector_helper.c | 3269 +++++++++++------------ 16 files changed, 4051 insertions(+), 2894 deletions(-)Quoted 3 lines
--
2.17.1ping~
Quoted 7 lines
Quoted 3 lines
I wasn't really following too closely, but didn't Richard give comments?
Alistair
Yeah, they were given in v3 patchset and I've made the changes based on Richard's comments in this v4 patchset.
Ah ok. I missed that while I was on holidays.
Did you want to wait until the v1.0 spec is released or have the draft extensions merged?
Alistair
Quoted 2 lines
Frank Chang
Quoted 198 lines · Alistair Francis
Quoted 2 lines · Frank Chang
On Thu, Aug 27, 2020 at 12:56 AM Alistair Francis <[email protected]>
Quoted 2 lines · wrote:
Quoted 2 lines
On Tue, Aug 25, 2020 at 1:29 AM Frank Chang <[email protected]>
Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines · On Mon, Aug 17, 2020 at 4:50 PM <[email protected]> wrote:
Quoted 4 lines
From: Frank Chang <[email protected]>
This patchset implements the vector extension v1.0 for RISC-V on
QEMU.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
This patchset is sent as RFC because RVV v1.0 is still in draft
state.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
v2 patchset was sent for RVV v0.9 and bumped to RVV v1.0 since v3
patchset.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
The port is available here:
https://github.com/sifive/qemu/tree/rvv-1.0-upstream-v4You can change the cpu argument:
vext_specto v1.0 (i.e.vext_spec=v1.0)
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
to run with RVV v1.0 instructions.
Note: This patchset depends on two other patchsets listed in Based-on
section below so it might not able to be built unless those two patchsets are applied.Changelog:
v4
* remove explicit float flmul variable in DisasContext.
* replace floating-point calculations with shift operations to improve performance.
* relaxRV_VLEN_MAXto 512-bits.v3
* apply nan-box helpers from Richard Henderson.
* remove fp16 api changes as they are sent independently in another pathcset by Chih-Min Chao.
* remove all tail elements clear functions as tail elements can retain unchanged for either VTA set to undisturbed or agnostic.
* add fp16 nan-box check generator function.
* add floating-point rounding mode enum.
* replace flmul arithmetic with shifts to avoid floating-point conversions.
* add Zvqmac extension.
* replace gdbstub vector register xml files with dynamic generator.
* bumped to RVV v1.0.
* RVV v1.0 related changes:
* add vl<nf>re<eew>.v and vs<nf>r.v vector whole register load/store instructions
* add vrgatherei16 instruction.
* rearranged bits in vtype to make vlmul bits into a contiguous field.v2
* drop v0.7.1 support.
* replace invisible return check macros with functions.
* movemark_vs_dirty()to translators.
* addSSTATUS_VSflag for s-mode.
* nan-box scalar fp register for floating-point operations.
* add gdbstub files for vector registers to allow system-mode debugging with GDB.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Based-on: <[email protected]/>
Based-on: <Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Frank Chang (62):
target/riscv: drop vector 0.7.1 and add 1.0 support target/riscv: UseFIELD_EX32()to extract wd field target/riscv: rvv-1.0: introduce writable misa.v field target/riscv: rvv-1.0: remove rvv related codes from fcsr registers target/riscv: rvv-1.0: checkMSTATUS_VSwhen accessing vector csr
registers
target/riscv: rvv-1.0: remove MLEN calculations target/riscv: rvv-1.0: add fractional LMUL
target/riscv: rvv-1.0: add VMA and VTA
target/riscv: rvv-1.0: update check functions target/riscv: introduce more imm value modes in translatorfunctions
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
target/riscv: rvv:1.0: add translation-time nan-box helper function target/riscv: rvv-1.0: configure instructions target/riscv: rvv-1.0: stride load and store instructions target/riscv: rvv-1.0: index load and store instructions target/riscv: rvv-1.0: fix address index overflow bug of indexed
load/store insns
target/riscv: rvv-1.0: fault-only-first unit stride load target/riscv: rvv-1.0: amo operations
target/riscv: rvv-1.0: load/store whole register instructions target/riscv: rvv-1.0: updatevext_max_elems()for load/store insns target/riscv: rvv-1.0: take fractional LMUL into vector maxelements
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
calculation
target/riscv: rvv-1.0: floating-point square-root instruction target/riscv: rvv-1.0: floating-point classify instructions target/riscv: rvv-1.0: mask population count instruction target/riscv: rvv-1.0: find-first-set mask bit instruction target/riscv: rvv-1.0: set-X-first mask bit instructions target/riscv: rvv-1.0: iota instruction target/riscv: rvv-1.0: element index instruction target/riscv: rvv-1.0: allow load element with sign-extended target/riscv: rvv-1.0: register gather instructions target/riscv: rvv-1.0: integer scalar move instructions target/riscv: rvv-1.0: floating-point move instruction target/riscv: rvv-1.0: floating-point scalar move instructions target/riscv: rvv-1.0: whole register move instructions target/riscv: rvv-1.0: integer extension instructionsQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
target/riscv: rvv-1.0: single-width averaging add and subtract
instructions
target/riscv: rvv-1.0: single-width bit shift instructions target/riscv: rvv-1.0: integer add-with-carry/subtract-with-borrow target/riscv: rvv-1.0: narrowing integer right shift instructions target/riscv: rvv-1.0: widening integer multiply-add instructions target/riscv: rvv-1.0: add Zvqmac extension target/riscv: rvv-1.0: quad-widening integer multiply-addinstructions
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
target/riscv: rvv-1.0: single-width saturating add and subtract
instructions
target/riscv: rvv-1.0: integer comparison instructions target/riscv: use softfloat lib float16 comparison functions target/riscv: rvv-1.0: floating-point compare instructions target/riscv: rvv-1.0: mask-register logical instructions target/riscv: rvv-1.0: slide instructions target/riscv: rvv-1.0: floating-point slide instructions target/riscv: rvv-1.0: narrowing fixed-point clip instructions target/riscv: rvv-1.0: single-width floating-point reduction target/riscv: rvv-1.0: widening floating-point reductioninstructions
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
target/riscv: rvv-1.0: single-width scaling shift instructions target/riscv: rvv-1.0: remove widening saturating scaled
multiply-add
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
target/riscv: rvv-1.0: remove vmford.vv and vmford.vf target/riscv: rvv-1.0: remove integer extract instruction target/riscv: rvv-1.0: floating-point min/max instructions target/riscv: introduce floating-point rounding mode enum target/riscv: rvv-1.0: floating-point/integer type-convert
instructions
target/riscv: rvv-1.0: widening floating-point/integer type-convert target/riscv: add "set round to odd" rounding mode helper function target/riscv: rvv-1.0: narrowing floating-point/integertype-convert
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
target/riscv: rvv-1.0: relax
RV_VLEN_MAXto 512-bitsGreentime Hu (2):
target/riscv: rvv-1.0: add vlenb register target/riscv: gdb: support vector registers for rv32Hsiangkai Wang (2):
target/riscv: gdb: modify gdb csr xml file to align with csrregister
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
map
target/riscv: gdb: support vector registers for rv64LIU Zhiwei (4):
target/riscv: rvv-1.0: add mstatus VS field target/riscv: rvv-1.0: add sstatus VS field target/riscv: rvv-1.0: add translation-time vector context status target/riscv: rvv-1.0: add vcsr registerQuoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
gdb-xml/riscv-32bit-csr.xml | 18 +- gdb-xml/riscv-64bit-csr.xml | 18 +- target/riscv/cpu.c | 12 +- target/riscv/cpu.h | 97 +- target/riscv/cpu_bits.h | 10 + target/riscv/cpu_helper.c | 16 +- target/riscv/csr.c | 73 +- target/riscv/fpu_helper.c | 17 +-Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
target/riscv/gdbstub.c | 126 +- target/riscv/helper.h | 523 ++-- target/riscv/insn32-64.decode | 18 +- target/riscv/insn32.decode | 295 +- target/riscv/insn_trans/trans_rvv.inc.c | 2366 ++++++++++------ target/riscv/internals.h | 19 +- target/riscv/translate.c | 68 +- target/riscv/vector_helper.c | 3269+++++++++++------------
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
16 files changed, 4051 insertions(+), 2894 deletions(-)--
2.17.1ping~
Quoted 7 lines
Quoted 3 lines
I wasn't really following too closely, but didn't Richard give comments?
Alistair
Yeah, they were given in v3 patchset and I've made the changes based on Richard's comments in this v4 patchset.
Quoted 10 lines
Ah ok. I missed that while I was on holidays.
Did you want to wait until the v1.0 spec is released or have the draft extensions merged?
Alistair
Quoted 2 lines
Frank Chang
I'm okay to wait until v1.0 spec. is released as I'm just sending RFC patchset for now. As far as I know there are still couple of instructions not implemented for RVV v1.0 yet (e.g. *vfrsqrt7.v* and *vfrece7.v*). Not sure what else is going to be changed before v1.0 spec. is ratified.
However, it would still be nice if someone can take a look of current patches so it might speed up the process to get these patches merged into mainline once v1.0 spec. is released.
Thanks,
Frank Chang
Quoted 193 lines · Frank Chang
Quoted 191 lines · Alistair Francis
Quoted 173 lines · Frank Chang
Quoted 171 lines · Alistair Francis
Quoted 168 lines · Frank Chang
Quoted 161 lines · On Mon, Aug 17, 2020 at 4:50 PM <[email protected]> wrote:
From: Frank Chang <[email protected]>
This patchset implements the vector extension v1.0 for RISC-V on QEMU.
This patchset is sent as RFC because RVV v1.0 is still in draft state. v2 patchset was sent for RVV v0.9 and bumped to RVV v1.0 since v3 patchset.
The port is available here:
https://github.com/sifive/qemu/tree/rvv-1.0-upstream-v4You can change the cpu argument:
vext_specto v1.0 (i.e. vext_spec=v1.0) to run with RVV v1.0 instructions.Note: This patchset depends on two other patchsets listed in Based-on
section below so it might not able to be built unless those two patchsets are applied.Changelog:
v4
* remove explicit float flmul variable in DisasContext.
* replace floating-point calculations with shift operations to improve performance.
* relaxRV_VLEN_MAXto 512-bits.v3
* apply nan-box helpers from Richard Henderson.
* remove fp16 api changes as they are sent independently in another pathcset by Chih-Min Chao.
* remove all tail elements clear functions as tail elements can retain unchanged for either VTA set to undisturbed or agnostic.
* add fp16 nan-box check generator function.
* add floating-point rounding mode enum.
* replace flmul arithmetic with shifts to avoid floating-point conversions.
* add Zvqmac extension.
* replace gdbstub vector register xml files with dynamic generator.
* bumped to RVV v1.0.
* RVV v1.0 related changes:
* add vl<nf>re<eew>.v and vs<nf>r.v vector whole register load/store instructions
* add vrgatherei16 instruction.
* rearranged bits in vtype to make vlmul bits into a contiguous field.v2
* drop v0.7.1 support.
* replace invisible return check macros with functions.
* movemark_vs_dirty()to translators.
* addSSTATUS_VSflag for s-mode.
* nan-box scalar fp register for floating-point operations.
* add gdbstub files for vector registers to allow system-mode debugging with GDB.Based-on: <[email protected]/>
Based-on: <[email protected]/>Frank Chang (62):
target/riscv: drop vector 0.7.1 and add 1.0 support target/riscv: UseFIELD_EX32()to extract wd field target/riscv: rvv-1.0: introduce writable misa.v field target/riscv: rvv-1.0: remove rvv related codes from fcsr registers target/riscv: rvv-1.0: checkMSTATUS_VSwhen accessing vector csr
registers
target/riscv: rvv-1.0: remove MLEN calculations target/riscv: rvv-1.0: add fractional LMUL
target/riscv: rvv-1.0: add VMA and VTA
target/riscv: rvv-1.0: update check functions target/riscv: introduce more imm value modes in translator functions target/riscv: rvv:1.0: add translation-time nan-box helper function target/riscv: rvv-1.0: configure instructions target/riscv: rvv-1.0: stride load and store instructions target/riscv: rvv-1.0: index load and store instructions target/riscv: rvv-1.0: fix address index overflow bug of indexed
load/store insns
target/riscv: rvv-1.0: fault-only-first unit stride load target/riscv: rvv-1.0: amo operations
target/riscv: rvv-1.0: load/store whole register instructions target/riscv: rvv-1.0: updatevext_max_elems()for load/store insns target/riscv: rvv-1.0: take fractional LMUL into vector max elements
calculation
target/riscv: rvv-1.0: floating-point square-root instruction target/riscv: rvv-1.0: floating-point classify instructions target/riscv: rvv-1.0: mask population count instruction target/riscv: rvv-1.0: find-first-set mask bit instruction target/riscv: rvv-1.0: set-X-first mask bit instructions target/riscv: rvv-1.0: iota instruction
target/riscv: rvv-1.0: element index instruction target/riscv: rvv-1.0: allow load element with sign-extended target/riscv: rvv-1.0: register gather instructions target/riscv: rvv-1.0: integer scalar move instructions target/riscv: rvv-1.0: floating-point move instruction target/riscv: rvv-1.0: floating-point scalar move instructions target/riscv: rvv-1.0: whole register move instructions target/riscv: rvv-1.0: integer extension instructions target/riscv: rvv-1.0: single-width averaging add and subtract
instructions
target/riscv: rvv-1.0: single-width bit shift instructions target/riscv: rvv-1.0: integer add-with-carry/subtract-with-borrow target/riscv: rvv-1.0: narrowing integer right shift instructions target/riscv: rvv-1.0: widening integer multiply-add instructions target/riscv: rvv-1.0: add Zvqmac extension
target/riscv: rvv-1.0: quad-widening integer multiply-add instructions target/riscv: rvv-1.0: single-width saturating add and subtract
instructions
target/riscv: rvv-1.0: integer comparison instructions target/riscv: use softfloat lib float16 comparison functions target/riscv: rvv-1.0: floating-point compare instructions target/riscv: rvv-1.0: mask-register logical instructions target/riscv: rvv-1.0: slide instructions
target/riscv: rvv-1.0: floating-point slide instructions target/riscv: rvv-1.0: narrowing fixed-point clip instructions target/riscv: rvv-1.0: single-width floating-point reduction target/riscv: rvv-1.0: widening floating-point reduction instructions target/riscv: rvv-1.0: single-width scaling shift instructions target/riscv: rvv-1.0: remove widening saturating scaled multiply-add target/riscv: rvv-1.0: remove vmford.vv and vmford.vf target/riscv: rvv-1.0: remove integer extract instruction target/riscv: rvv-1.0: floating-point min/max instructions target/riscv: introduce floating-point rounding mode enum target/riscv: rvv-1.0: floating-point/integer type-convert
instructions
target/riscv: rvv-1.0: widening floating-point/integer type-convert target/riscv: add "set round to odd" rounding mode helper function target/riscv: rvv-1.0: narrowing floating-point/integer type-convert target/riscv: rvv-1.0: relaxRV_VLEN_MAXto 512-bitsGreentime Hu (2):
target/riscv: rvv-1.0: add vlenb register target/riscv: gdb: support vector registers for rv32Hsiangkai Wang (2):
target/riscv: gdb: modify gdb csr xml file to align with csr register
map
target/riscv: gdb: support vector registers for rv64LIU Zhiwei (4):
target/riscv: rvv-1.0: add mstatus VS field target/riscv: rvv-1.0: add sstatus VS field target/riscv: rvv-1.0: add translation-time vector context status target/riscv: rvv-1.0: add vcsr registergdb-xml/riscv-32bit-csr.xml | 18 +- gdb-xml/riscv-64bit-csr.xml | 18 +- target/riscv/cpu.c | 12 +- target/riscv/cpu.h | 97 +- target/riscv/cpu_bits.h | 10 + target/riscv/cpu_helper.c | 16 +- target/riscv/csr.c | 73 +- target/riscv/fpu_helper.c | 17 +- target/riscv/gdbstub.c | 126 +- target/riscv/helper.h | 523 ++-- target/riscv/insn32-64.decode | 18 +- target/riscv/insn32.decode | 295 +- target/riscv/insn_trans/trans_rvv.inc.c | 2366 ++++++++++------ target/riscv/internals.h | 19 +- target/riscv/translate.c | 68 +- target/riscv/vector_helper.c | 3269 +++++++++++------------ 16 files changed, 4051 insertions(+), 2894 deletions(-)Quoted 3 lines
--
2.17.1ping~
Quoted 7 lines
Quoted 3 lines
I wasn't really following too closely, but didn't Richard give comments?
Alistair
Yeah, they were given in v3 patchset and I've made the changes based on Richard's comments in this v4 patchset.
Ah ok. I missed that while I was on holidays.
Did you want to wait until the v1.0 spec is released or have the draft extensions merged?
Alistair
Quoted 1 line
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Frank Chang
I'm okay to wait until v1.0 spec. is released as I'm just sending RFC patchset for now. As far as I know there are still couple of instructions not implemented for RVV v1.0 yet (e.g. vfrsqrt7.v and vfrece7.v). Not sure what else is going to be changed before v1.0 spec. is ratified.
You don't have to wait. We will be happy to replace the v0.7.1 version with 0.9.0. I think the community will find that useful.
Quoted 4 lines
However, it would still be nice if someone can take a look of current patches so it might speed up the process to get these patches merged into mainline once v1.0 spec. is released.
The RISC-V port is very low on reviewers. It will take a chunk of my time to review it as I don't closely follow the Vector work. If it's just an RFC I don't think I can dedicate that much time. I already have a large backlog I'm trying to get through.
Alistair
Quoted 3 lines
Thanks,
Frank Chang