target/arm: First slice of MVE implementation
cover target/arm: First slice of MVE implementation
This patchseries provides an initial slice of the MVE implementation. (MVE is "vector instructions for M-profile", also known as Helium).
This is not complete support by a long way -- it covers only about 35% of the decode patterns for MVE, and it implements only the slow-path "we need predication, drop out to a helper function" versions of insns. I send it out for two reasons:
* if there's something I need to change about the general structure or the way I'm implementing insns, I want to know now rather than after I've implemented the other two thirds of the ISA
* if I hold onto the whole patchset until I've got a complete MVE implementation it'll be 150+ patches, 10000 lines of code, and a nightmare to code review
The series covers:
* framework for MVE decode, including infrastructure for handling predication, PSR.ECI, etc
* tail-predication forms of low-overhead-loop insns (LCTP, WLSTP, LETP)
* basic (non-gather) loads and stores
* pretty much all the integer 2-operand vector and scalar insns
* most of the integer 1-operand insns
* a handful of other insns
(Unfortunately the v8M Arm ARM does not provide a nice neatly separated list of encodings the way the SVE2 XML does. I ended up just pulling all the decode patterns out of the Arm ARM insn descriptions and then hand-sorting them into what looked like common formats. So the insns implemented aren't following a 100% logical order.)
As noted above, the implementation here is purely the slow-path fully-generic "call helpers that can handle predication". I do want to implement a fast-path for "we know we have no predication, so we can generate inline vector code", but I'd like to do that as a series of followup patches once the main MVE code has landed. That will (a) make it easier to review, I hope (b) mean we get to "at least functional" MVE quicker and (c) allow people to bisect any regressions to the "add fastpath" patch.
Almost nothing in this patchseries is "live code", because no CPU sets the ID register bits to turn on MVE. The exception is the handling of PSR.ECI/ICI, which is enabled at least as far as the ICI bits go for M-profile CPUs (thus fixing the missing corner-case requirement that trying to execute a non-continuable insn with non-zero ICI should fault).
My view is that if these patches get through code review we're better off with them in upstream git rather than outside it; open to arguments to the contrary.
Patch 1 is RTH's recently posted tcg_remove_ops_after() patch, which we need for the PSR.ECI handling (which indeed is the justification for having that new function in the first place).
You can also get this patchset here:
https://git.linaro.org/people/peter.maydell/qemu-arm.git mve-drop-1
thanks
-- PMM
Peter Maydell (54):
target/arm: Enable FPSCR.QC bit for MVE
target/arm: Handle VPR semantics in existing code target/arm: Add handling for PSR.ECI/ICI
target/arm: Let vfp_access_check() handle late NOCP checks target/arm: Implement MVE LCTP
target/arm: Implement MVE WLSTP insn
target/arm: Implement MVE DLSTP
target/arm: Implement MVE LETP insn
target/arm: Add framework for MVE decode
target/arm: Implement MVE VLDR/VSTR (non-widening forms) target/arm: Implement widening/narrowing MVE VLDR/VSTR insns target/arm: Implement MVE VCLZ
target/arm: Implement MVE VCLS
bitops.h: Provide hswap32(), hswap64(), wswap64() swapping operations target/arm: Implement MVE VREV16, VREV32, VREV64 target/arm: Implement MVE VMVN (register)
target/arm: Implement MVE VABS
target/arm: Implement MVE VNEG
target/arm: Implement MVE VDUP
target/arm: Implement MVE VAND, VBIC, VORR, VORN, VEOR target/arm: Implement MVE VADD, VSUB, VMUL
target/arm: Implement MVE VMULH
target/arm: Implement MVE VRMULH
target/arm: Implement MVE VMAX, VMIN
target/arm: Implement MVE VABD
target/arm: Implement MVE VHADD, VHSUB
target/arm: Implement MVE VMULL
target/arm: Implement MVE VMLALDAV
target/arm: Implement MVE VMLSLDAV
include/qemu/int128.h: Add function to create Int128 from int64_t target/arm: Implement MVE VRMLALDAVH, VRMLSLDAVH target/arm: Implement MVE VADD (scalar)
target/arm: Implement MVE VSUB, VMUL (scalar)
target/arm: Implement MVE VHADD, VHSUB (scalar) target/arm: Implement MVE VBRSR
target/arm: Implement MVE VPST
target/arm: Implement MVE VQADD and VQSUB
target/arm: Implement MVE VQDMULH and VQRDMULH (scalar) target/arm: Implement MVE VQDMULL scalar
target/arm: Implement MVE VQDMULH, VQRDMULH (vector) target/arm: Implement MVE VQADD, VQSUB (vector) target/arm: Implement MVE VQSHL (vector)
target/arm: Implement MVE VQRSHL
target/arm: Implement MVE VSHL insn
target/arm: Implement MVE VRSHL
target/arm: Implement MVE VQDMLADH and VQRDMLADH target/arm: Implement MVE VQDMLSDH and VQRDMLSDH target/arm: Implement MVE VQDMULL (vector)
target/arm: Implement MVE VRHADD
target/arm: Implement MVE VADC, VSBC
target/arm: Implement MVE VCADD
target/arm: Implement MVE VHCADD
target/arm: Implement MVE VADDV
target/arm: Make VMOV scalar <-> gpreg beatwise for MVE
Richard Henderson (1):
tcg: Introduce tcg_remove_ops_after
include/qemu/bitops.h | 29 + include/qemu/int128.h | 10 + include/tcg/tcg.h | 1 + target/arm/helper-mve.h | 357 +++++++++ target/arm/helper.h | 2 + target/arm/internals.h | 11 + target/arm/translate-a32.h | 4 + target/arm/translate.h | 19 + target/arm/mve.decode | 261 +++++++ target/arm/t32.decode | 15 +- target/arm/m_helper.c | 54 +- target/arm/mve_helper.c | 1343 +++++++++++++++++++++++++++++++++ target/arm/sve_helper.c | 20 - target/arm/translate-m-nocp.c | 16 +- target/arm/translate-mve.c | 865 +++++++++++++++++++++ target/arm/translate-vfp.c | 152 +++- target/arm/translate.c | 301 +++++++- target/arm/vfp_helper.c | 3 +- tcg/tcg.c | 13 + target/arm/meson.build | 3 + 20 files changed, 3408 insertions(+), 71 deletions(-) create mode 100644 target/arm/helper-mve.h create mode 100644 target/arm/mve.decode create mode 100644 target/arm/mve_helper.c create mode 100644 target/arm/translate-mve.c
Signature · 1 line
2.20.1
PATCH 1/55 tcg: Introduce tcg_remove_ops_after
From: Richard Henderson <[email protected]>
Introduce a function to remove everything emitted since a given point.
Message-id: [email protected]
--- include/tcg/tcg.h | 1 + tcg/tcg.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)
include/tcg/tcg.h +1 -0
@@ -1081,6 +1081,7 @@ TCGOp *tcg_emit_op(TCGOpcode opc);void tcg_op_remove (TCGContext *s,TCGOp *op);TCGOp *tcg_op_insert_before (TCGContext *s,TCGOp *op,TCGOpcode opc);TCGOp *tcg_op_insert_after (TCGContext *s,TCGOp *op,TCGOpcode opc); +void tcg_remove_ops_after (TCGOp *op);void tcg_optimize (TCGContext *s);
tcg/tcg.c +13 -0
@@ -2649,6 +2649,19 @@ void tcg_op_remove(TCGContext *s, TCGOp *op)#endif } +void tcg_remove_ops_after (TCGOp *op) +{ +TCGContext *s = tcg_ctx; + +while (true) { +TCGOp *last =tcg_last_op (); +if (last == op) { +return ; + } +tcg_op_remove (s, last); + } +} +static TCGOp *tcg_op_alloc (TCGOpcode opc) {TCGContext *s = tcg_ctx;
Signature · 1 line
2.20.1
PATCH 2/55 target/arm: Enable FPSCR.QC bit for MVE
In reply to Peter MaydellMVE has an FPSCR.QC bit similar to the A-profile Neon one; when MVE is implemented make the bit writeable, both in the generic "load and store FPSCR" helper functions and in the code for handling the NZCVQC sysreg which we had previously left as "TODO when we implement MVE".
--- target/arm/translate-vfp.c | 32 +++++++++++++++++++++++--------- target/arm/vfp_helper.c | 3 ++- 2 files changed, 25 insertions(+), 10 deletions(-)
target/arm/translate-vfp.c +23 -9
@@ -784,10 +784,19 @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, {TCGv_i32 fpscr; tmp =loadfn (s, opaque); -/* -* TODO: when we implement MVE, write the QC bit. -* For non-MVE, QC is RES0. -*/ +if (dc_isar_feature (aa32_mve, s)) { +/* QC is only present for MVE; otherwise RES0 */ +TCGv_i32 qc =tcg_temp_new_i32 (); +TCGv_i32 zero; +tcg_gen_andi_i32 (qc, tmp,FPCR_QC ); +store_cpu_field (qc, vfp.qc[0 ]); + zero =tcg_const_i32 (0 ); +store_cpu_field (zero, vfp.qc[1 ]); + zero =tcg_const_i32 (0 ); +store_cpu_field (zero, vfp.qc[2 ]); + zero =tcg_const_i32 (0 ); +store_cpu_field (zero, vfp.qc[3 ]); + }tcg_gen_andi_i32 (tmp, tmp,FPCR_NZCV_MASK ); fpscr =load_cpu_field (vfp.xregs[ARM_VFP_FPSCR ]);tcg_gen_andi_i32 (fpscr, fpscr, ~FPCR_NZCV_MASK );
@@ -869,6 +878,11 @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno,break ; } +if (regno ==ARM_VFP_FPSCR_NZCVQC && !dc_isar_feature (aa32_mve, s)) { +/* QC is RES0 without MVE, so NZCVQC simplifies to NZCV */ + regno =QEMU_VFP_FPSCR_NZCV ; + } +switch (regno) {case ARM_VFP_FPSCR : tmp =tcg_temp_new_i32 ();
@@ -876,11 +890,11 @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno,storefn (s, opaque, tmp);break ;case ARM_VFP_FPSCR_NZCVQC : -/* -* TODO: MVE has a QC bit, which we probably won't store -* in the xregs[] field. For non-MVE, where QC is RES0, -* we can just fall through to the FPSCR_NZCV case. -*/ + tmp =tcg_temp_new_i32 (); +gen_helper_vfp_get_fpscr (tmp, cpu_env); +tcg_gen_andi_i32 (tmp, tmp,FPCR_NZCVQC_MASK ); +storefn (s, opaque, tmp); +break ;case QEMU_VFP_FPSCR_NZCV :/* * Read just NZCV; this is a special case to avoid the
target/arm/vfp_helper.c +2 -1
@@ -220,7 +220,8 @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) FPCR_LTPSIZE_LENGTH); } -if (arm_feature (env,ARM_FEATURE_NEON )) { +if (arm_feature (env,ARM_FEATURE_NEON ) || +cpu_isar_feature (aa32_mve, cpu)) {/* * The bit we set within fpscr_q is arbitrary; the register as a * whole being zero/non-zero is what counts.
Signature · 1 line
2.20.1
Re: [PATCH 02/55] target/arm: Enable FPSCR.QC bit for MVE
Quoted 26 lines · Peter Maydell
MVE has an FPSCR.QC bit similar to the A-profile Neon one; when MVE is implemented make the bit writeable, both in the generic "load and store FPSCR" helper functions and in the code for handling the NZCVQC sysreg which we had previously left as "TODO when we implement MVE".
Signed-off-by Peter Maydell <[email protected]>--- target/arm/translate-vfp.c | 32 +++++++++++++++++++++++--------- target/arm/vfp_helper.c | 3 ++- 2 files changed, 25 insertions(+), 10 deletions(-)target/arm/translate-vfp.c +3
-4@@ -784,10 +784,19 @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, {TCGv_i32 fpscr; tmp =loadfn (s, opaque); -/* -* TODO: when we implement MVE, write the QC bit. -* For non-MVE, QC is RES0. -*/ +if (dc_isar_feature (aa32_mve, s)) { +/* QC is only present for MVE; otherwise RES0 */ +TCGv_i32 qc =tcg_temp_new_i32 ();
target/arm/translate-vfp.c static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, · line 799
Quoted 10 lines
target/arm/translate-vfp.c +10
-0+TCGv_i32 zero; +tcg_gen_andi_i32 (qc, tmp,FPCR_QC ); +store_cpu_field (qc, vfp.qc[0 ]); + zero =tcg_const_i32 (0 ); +store_cpu_field (zero, vfp.qc[1 ]); + zero =tcg_const_i32 (0 ); +store_cpu_field (zero, vfp.qc[2 ]); + zero =tcg_const_i32 (0 ); +store_cpu_field (zero, vfp.qc[3 ]); + }
Ok I guess. You could store the same i32 into all elements:
tcg_gen_gvec_dup_i32(MO_32, offsetof(CPUARMState, vfp.qc),
16, 16, qc);Either way,
r~
PATCH 3/55 target/arm: Handle VPR semantics in existing code
In reply to Peter MaydellWhen MVE is supported, the VPR register has a place on the exception stack frame in a previously reserved slot just above the FPSCR. It must also be zeroed in various situations when we invalidate FPU context.
Update the code which handles the stack frames (exception entry and exit code, VLLDM, and VLSTM) to save/restore VPR.
Update code which invalidates FP registers (mostly also exception entry and exit code, but also VSCCLRM and the code in full_vfp_access_check() that corresponds to the ExecuteFPCheck() pseudocode) to zero VPR.
--- target/arm/m_helper.c | 54 +++++++++++++++++++++++++++++------ target/arm/translate-m-nocp.c | 5 +++- target/arm/translate-vfp.c | 9 ++++-- 3 files changed, 57 insertions(+), 11 deletions(-)
target/arm/m_helper.c +46 -8
@@ -378,7 +378,7 @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env)uint32_t shi =extract64 (dn,32 ,32 );if (i >=16 ) { - faddr +=8 ;/* skip the slot for the FPSCR */ + faddr +=8 ;/* skip the slot for the FPSCR/VPR */ } stacked_ok = stacked_ok && v7m_stack_write(cpu, faddr, slo, mmu_idx, STACK_LAZYFP) &&
@@ -388,6 +388,11 @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env) stacked_ok = stacked_ok &&v7m_stack_write (cpu, fpcar +0x40 ,vfp_get_fpscr (env), mmu_idx,STACK_LAZYFP ); +if (cpu_isar_feature (aa32_mve, cpu)) { + stacked_ok = stacked_ok && +v7m_stack_write (cpu, fpcar +0x44 , + env->v7m.vpr, mmu_idx,STACK_LAZYFP ); + } }/*
@@ -410,16 +415,19 @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env) env->v7m.fpccr[is_secure] &= ~R_V7M_FPCCR_LSPACT_MASK ;if (ts) { -/* Clear s0 to s31 and the FPSCR */ +/* Clear s0 to s31 and the FPSCR and VPR */ int i;for (i =0 ; i <32 ; i +=2 ) { *aa32_vfp_dreg (env, i /2 ) =0 ; }vfp_set_fpscr (env,0 ); +if (cpu_isar_feature (aa32_mve, cpu)) { + env->v7m.vpr =0 ; + } }/* -* Otherwise s0 to s15 and FPSCR are UNKNOWN; we choose to leave them +* Otherwise s0 to s15, FPSCR and VPR are UNKNOWN; we choose to leave them * unchanged. */ }
@@ -1044,6 +1052,7 @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr,void HELPER (v7m_vlstm )(CPUARMState *env,uint32_t fptr) {/* fptr is the value of Rn, the frame pointer we store the FP regs to */ +ARMCPU *cpu =env_archcpu (env);bool s = env->v7m.fpccr[M_REG_S ] &R_V7M_FPCCR_S_MASK ;bool lspact = env->v7m.fpccr[s] &R_V7M_FPCCR_LSPACT_MASK ;uintptr_t ra =GETPC ();
@@ -1092,9 +1101,12 @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)cpu_stl_data_ra (env, faddr +4 , shi, ra); }cpu_stl_data_ra (env, fptr +0x40 ,vfp_get_fpscr (env), ra); +if (cpu_isar_feature (aa32_mve, cpu)) { +cpu_stl_data_ra (env, fptr +0x44 , env->v7m.vpr, ra); + }/* -* If TS is 0 then s0 to s15 and FPSCR are UNKNOWN; we choose to +* If TS is 0 then s0 to s15, FPSCR and VPR are UNKNOWN; we choose to * leave them unchanged, matching our choice in v7m_preserve_fp_state. */ if (ts) {
@@ -1102,6 +1114,9 @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr) *aa32_vfp_dreg (env, i /2 ) =0 ; }vfp_set_fpscr (env,0 ); +if (cpu_isar_feature (aa32_mve, cpu)) { + env->v7m.vpr =0 ; + } } }else {v7m_update_fpccr (env, fptr, false);
@@ -1112,6 +1127,7 @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)void HELPER (v7m_vlldm )(CPUARMState *env,uint32_t fptr) { +ARMCPU *cpu =env_archcpu (env);uintptr_t ra =GETPC ();/* fptr is the value of Rn, the frame pointer we load the FP regs from */
@@ -1144,7 +1160,7 @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)uint32_t faddr = fptr +4 * i;if (i >=16 ) { - faddr +=8 ;/* skip the slot for the FPSCR */ + faddr +=8 ;/* skip the slot for the FPSCR and VPR */ } slo =cpu_ldl_data_ra (env, faddr, ra);
@@ -1155,6 +1171,9 @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) } fpscr =cpu_ldl_data_ra (env, fptr +0x40 , ra);vfp_set_fpscr (env, fpscr); +if (cpu_isar_feature (aa32_mve, cpu)) { + env->v7m.vpr =cpu_ldl_data_ra (env, fptr +0x44 , ra); + } } env->v7m.control[M_REG_S ] |=R_V7M_CONTROL_FPCA_MASK ;
@@ -1298,7 +1317,7 @@ static bool v7m_push_stack(ARMCPU *cpu)uint32_t shi =extract64 (dn,32 ,32 );if (i >=16 ) { - faddr +=8 ;/* skip the slot for the FPSCR */ + faddr +=8 ;/* skip the slot for the FPSCR and VPR */ } stacked_ok = stacked_ok && v7m_stack_write(cpu, faddr, slo,
@@ -1309,11 +1328,19 @@ static bool v7m_push_stack(ARMCPU *cpu) stacked_ok = stacked_ok &&v7m_stack_write (cpu, frameptr +0x60 ,vfp_get_fpscr (env), mmu_idx,STACK_NORMAL ); +if (cpu_isar_feature (aa32_mve, cpu)) { + stacked_ok = stacked_ok && +v7m_stack_write (cpu, frameptr +0x64 , + env->v7m.vpr, mmu_idx,STACK_NORMAL ); + }if (cpacr_pass) {for (i =0 ; i < ((framesize ==0xa8 ) ?32 :16 ); i +=2 ) { *aa32_vfp_dreg (env, i /2 ) =0 ; }vfp_set_fpscr (env,0 ); +if (cpu_isar_feature (aa32_mve, cpu)) { + env->v7m.vpr =0 ; + } } }else {/* Lazy stacking enabled, save necessary info to stack later */
@@ -1536,13 +1563,16 @@ static void do_v7m_exception_exit(ARMCPU *cpu)v7m_exception_taken (cpu, excret, true, false); } } -/* Clear s0..s15 and FPSCR; TODO also VPR when MVE is implemented */ +/* Clear s0..s15, FPSCR and VPR */ int i;for (i =0 ; i <16 ; i +=2 ) { *aa32_vfp_dreg (env, i /2 ) =0 ; }vfp_set_fpscr (env,0 ); +if (cpu_isar_feature (aa32_mve, cpu)) { + env->v7m.vpr =0 ; + } } }
@@ -1771,7 +1801,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu)uint32_t faddr = frameptr +0x20 +4 * i;if (i >=16 ) { - faddr +=8 ;/* Skip the slot for the FPSCR */ + faddr +=8 ;/* Skip the slot for the FPSCR and VPR */ } pop_ok = pop_ok &&
@@ -1790,6 +1820,11 @@ static void do_v7m_exception_exit(ARMCPU *cpu)if (pop_ok) {vfp_set_fpscr (env, fpscr); } +if (cpu_isar_feature (aa32_mve, cpu)) { + pop_ok = pop_ok && +v7m_stack_read (cpu, &env->v7m.vpr, + frameptr +0x64 , mmu_idx); + }if (!pop_ok) {/* * These regs are 0 if security extension present;
@@ -1799,6 +1834,9 @@ static void do_v7m_exception_exit(ARMCPU *cpu) *aa32_vfp_dreg (env, i /2 ) =0 ; }vfp_set_fpscr (env,0 ); +if (cpu_isar_feature (aa32_mve, cpu)) { + env->v7m.vpr =0 ; + } } } }
target/arm/translate-m-nocp.c +4 -1
@@ -173,7 +173,10 @@ static bool trans_VSCCLRM(DisasContext *s, arg_VSCCLRM *a) btmreg++; }assert (btmreg == topreg +1 ); -/* TODO: when MVE is implemented, zero VPR here */ +if (dc_isar_feature (aa32_mve, s)) { +TCGv_i32 z32 =tcg_const_i32 (0 ); +store_cpu_field (z32, v7m.vpr); + }return true; }
target/arm/translate-vfp.c +7 -2
@@ -180,8 +180,8 @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled)if (s->v7m_new_fp_ctxt_needed) {/* -* Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA -* and the FPSCR. +* Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA, +* the FPSCR, and VPR. */ TCGv_i32 control, fpscr;uint32_t bits =R_V7M_CONTROL_FPCA_MASK ;
@@ -189,6 +189,11 @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) fpscr =load_cpu_field (v7m.fpdscr[s->v8m_secure]);gen_helper_vfp_set_fpscr (cpu_env, fpscr);tcg_temp_free_i32 (fpscr); +if (dc_isar_feature (aa32_mve, s)) { +TCGv_i32 z32 =tcg_const_i32 (0 ); +store_cpu_field (z32, v7m.vpr); + } +/* * We don't need to arrange to end the TB, because the only * parts of FPSCR which we cache in the TB flags are the VECLEN
Signature · 1 line
2.20.1
Re: [PATCH 03/55] target/arm: Handle VPR semantics in existing code
Quoted 5 lines · Peter Maydell
target/arm/m_helper.c +0
-1@@ -410,16 +415,19 @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env) env->v7m.fpccr[is_secure] &= ~R_V7M_FPCCR_LSPACT_MASK ;if (ts) { -/* Clear s0 to s31 and the FPSCR */
target/arm/m_helper.c void HELPER(v7m_preserve_fp_state)(CPUARMState *env) · line 427
Quoted 10 lines
target/arm/m_helper.c +4
-0+/* Clear s0 to s31 and the FPSCR and VPR */ int i;for (i =0 ; i <32 ; i +=2 ) { *aa32_vfp_dreg (env, i /2 ) =0 ; }vfp_set_fpscr (env,0 ); +if (cpu_isar_feature (aa32_mve, cpu)) { + env->v7m.vpr =0 ; + }
If the vpr does not exist without mve, is it cleaner to simply set vpr unconditionally?
Either way it looks good.
r~
Re: [PATCH 03/55] target/arm: Handle VPR semantics in existing code
Quoted 10 lines · Richard Henderson
Quoted 8 lines · Peter Maydell
target/arm/m_helper.c +1
-1@@ -410,16 +415,19 @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env) env->v7m.fpccr[is_secure] &= ~R_V7M_FPCCR_LSPACT_MASK ;if (ts) { -/* Clear s0 to s31 and the FPSCR */ +/* Clear s0 to s31 and the FPSCR and VPR */ int i;
Quoted 10 lines
target/arm/m_helper.c void HELPER(v7m_preserve_fp_state)(CPUARMState *env) · line 427
Quoted 7 lines
target/arm/m_helper.c +3
-0for (i =0 ; i <32 ; i +=2 ) { *aa32_vfp_dreg (env, i /2 ) =0 ; }vfp_set_fpscr (env,0 ); +if (cpu_isar_feature (aa32_mve, cpu)) { + env->v7m.vpr =0 ; + }If the vpr does not exist without mve, is it cleaner to simply set vpr unconditionally?
I thought about that, but in the end went for the condition, just to preserve the parallelism with the places where we do need the condition. There didn't seem to me to be much in it.
-- PMM
PATCH 4/55 target/arm: Add handling for PSR.ECI/ICI
In reply to Peter MaydellOn A-profile, PSR bits [15:10][26:25] are always the IT state bits. On M-profile, some of the reserved encodings of the IT state are used to instead indicate partial progress through instructions that were interrupted partway through by an exception and can be resumed.
These resumable instructions fall into two categories:
(1) load/store multiple instructions, where these bits are called "ICI" and specify the register in the ldm/stm list where execution should resume. (Specifically: LDM, STM, VLDM, VSTM, VLLDM, VLSTM, CLRM, VSCCLRM.)
(2) MVE instructions subject to beatwise execution, where these bits are called "ECI" and specify which beats in this and possibly also the following MVE insn have been executed.
There are also a few insns (LE, LETP, and BKPT) which do not use the ICI/ECI bits but must leave them alone.
Otherwise, we should raise an INVSTATE UsageFault for any attempt to execute an insn with non-zero ICI/ECI bits.
So far we have been able to ignore ECI/ICI, because the architecture allows the IMPDEF choice of "always restart load/store multiple from the beginning regardless of ICI state", so the only thing we have been missing is that we don't raise the INVSTATE fault for bad guest code. However, MVE requires that we honour ECI bits and do not rexecute beats of an insn that have already been executed.
Add the support in the decoder for handling ECI/ICI:
* identify the ECI/ICI case in the CONDEXEC TB flags
* when a load/store multiple insn succeeds, it updates the ECI/ICI state (both in DisasContext and in the CPU state), and sets a flag to say that the ECI/ICI state was handled
* if we find that the insn we just decoded did not handle the ECI/ICI state, we delete all the code that we just generated for it and instead emit the code to raise the INVFAULT. This allows us to avoid having to update every non-MVE non-LDM/STM insn to make it check for "is ECI/ICI set?".
We continue with our existing IMPDEF choice of not caring about the ICI state for the load/store multiples and simply restarting them from the beginning. Because we don't allow interrupts in the middle of an insn, the only way we would see this state is if the guest set ICI manually on return from an exception handler, so it's a corner case which doesn't merit optimisation.
ICI update for LDM/STM is simple -- it always zeroes the state. ECI update for MVE beatwise insns will be a little more complex, since the ECI state may include information for the following insn.
--- target/arm/translate-a32.h | 1 + target/arm/translate.h | 9 +++ target/arm/translate-m-nocp.c | 11 ++++ target/arm/translate-vfp.c | 6 ++ target/arm/translate.c | 113 ++++++++++++++++++++++++++++++++-- 5 files changed, 135 insertions(+), 5 deletions(-)
target/arm/translate-a32.h +1 -0
@@ -44,6 +44,7 @@ long vfp_reg_offset(bool dp, unsigned reg);long neon_full_reg_offset (unsigned reg);long neon_element_offset (int reg,int element,MemOp memop);void gen_rev16 (TCGv_i32 dest,TCGv_i32 var); +void clear_eci_state (DisasContext *s);static inline TCGv_i32 load_cpu_offset (int offset) {
target/arm/translate.h +9 -0
@@ -21,6 +21,15 @@ typedef struct DisasContext {/* Thumb-2 conditional execution bits. */ int condexec_mask;int condexec_cond; +/* M-profile ECI/ICI exception-continuable instruction state */ +int eci; +/* +* trans_ functions for insns which are continuable should set this true +* after decode (ie after any UNDEF checks) +*/ +bool eci_handled; +/* TCG op to rewind to if this turns out to be an invalid ECI state */ +TCGOp *insn_eci_rewind;int thumb;int sctlr_b;MemOp be_data;
target/arm/translate-m-nocp.c +11 -0
@@ -75,8 +75,12 @@ static bool trans_VLLDM_VLSTM(DisasContext *s, arg_VLLDM_VLSTM *a)unallocated_encoding (s);return true; } + + s->eci_handled = true; +/* If no fpu, NOP. */ if (!dc_isar_feature (aa32_vfp, s)) { +clear_eci_state (s);return true; }
@@ -88,6 +92,8 @@ static bool trans_VLLDM_VLSTM(DisasContext *s, arg_VLLDM_VLSTM *a) }tcg_temp_free_i32 (fptr); +clear_eci_state (s); +/* End the TB, because we have updated FP control bits */ s->base.is_jmp =DISAS_UPDATE_EXIT ;return true;
@@ -110,8 +116,11 @@ static bool trans_VSCCLRM(DisasContext *s, arg_VSCCLRM *a)return true; } + s->eci_handled = true; +if (!dc_isar_feature (aa32_vfp_simd, s)) {/* NOP if we have neither FP nor MVE */ +clear_eci_state (s);return true; }
@@ -177,6 +186,8 @@ static bool trans_VSCCLRM(DisasContext *s, arg_VSCCLRM *a)TCGv_i32 z32 =tcg_const_i32 (0 );store_cpu_field (z32, v7m.vpr); } + +clear_eci_state (s);return true; }
target/arm/translate-vfp.c +6 -0
@@ -1564,6 +1564,8 @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a)return false; } + s->eci_handled = true; +if (!vfp_access_check (s)) {return true; }
@@ -1613,6 +1615,7 @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a)tcg_temp_free_i32 (addr); } +clear_eci_state (s);return true; }
@@ -1647,6 +1650,8 @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a)return false; } + s->eci_handled = true; +if (!vfp_access_check (s)) {return true; }
@@ -1703,6 +1708,7 @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a)tcg_temp_free_i32 (addr); } +clear_eci_state (s);return true; }
target/arm/translate.c +108 -5
192 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 04/55] target/arm: Add handling for PSR.ECI/ICI
target/arm/translate.c static inline bool is_singlestepping(DisasContext *s) · line 320
Quoted 9 lines · Peter Maydell
target/arm/translate.c +9
-0+void clear_eci_state (DisasContext *s) +{ +/* +* Clear any ECI/ICI state: used when a load multiple/store +* multiple insn executes. +*/ +if (s->eci) { +TCGv_i32 tmp =tcg_temp_new_i32 (); +tcg_gen_movi_i32 (tmp,0 );
tcg_const_i32 or preferably tcg_constant_i32.
Quoted 11 lines
target/arm/translate.c +11
-0+/* +* the CONDEXEC TB flags are CPSR bits [15:10][26:25]. On A-profile this +* is always the IT bits. On M-profile, some of the reserved encodings +* of IT are used instead to indicate either ICI or ECI, which +* indicate partial progress of a restartable insn that was interrupted +* partway through by an exception: +* * if CONDEXEC[3:0] != 0b0000 : CONDEXEC is IT bits +* * if CONDEXEC[3:0] == 0b0000 : CONDEXEC is ICI or ECI bits +* In all cases CONDEXEC == 0 means "not in IT block or restartable +* insn, behave normally". +*/
target/arm/translate.c static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) · line 8826
Quoted 10 lines
target/arm/translate.c +10
-0+if (condexec &0xf ) { + dc->condexec_mask = (condexec &0xf ) <<1 ; + dc->condexec_cond = condexec >>4 ; + dc->eci =0 ; + }else { + dc->condexec_mask =0 ; + dc->condexec_cond =0 ; +if (arm_feature (env,ARM_FEATURE_M )) { + dc->eci = condexec >>4 ; + }
This else leaves eci uninitialized.
Quoted 24 lines
dc->insn = insn;target/arm/translate.c +22
-0+if (dc->eci) { +/* +* For M-profile continuable instructions, ECI/ICI handling +* falls into these cases: +* - interrupt-continuable instructions +* These are the various load/store multiple insns (both +* integer and fp). The ICI bits indicate the register +* where the load/store can resume. We make the IMPDEF +* choice to always do "instruction restart", ie ignore +* the ICI value and always execute the ldm/stm from the +* start. So all we need to do is zero PSR.ICI if the +* insn executes. +* - MVE instructions subject to beat-wise execution +* Here the ECI bits indicate which beats have already been +* executed, and we must honour this. Each insn of this +* type will handle it correctly. We will update PSR.ECI +* in the helper function for the insn (some ECI values +* mean that the following insn also has been partially +* executed). +* - Special cases which don't advance ECI +* The insns LE, LETP and BKPT leave the ECI/ICI state +* bits untouched.
target/arm/translate.c static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) · line 9158
Quoted 10 lines
target/arm/translate.c +10
-0+* - all other insns (the common case) +* Non-zero ECI/ICI means an INVSTATE UsageFault. +* We place a rewind-marker here. Insns in the previous +* three categories will set a flag in the DisasContext. +* If the flag isn't set after we call disas_thumb_insn() +* or disas_thumb2_insn() then we know we have a "some other +* insn" case. We will rewind to the marker (ie throwing away +* all the generated code) and instead emit "take exception". +*/ + dc->eci_handled = false;
This should be done in arm_tr_init_disas_context, I think, unconditionally, next to eci.
Quoted 1 line
+
dc->insn_eci_rewind=tcg_last_op();
I believe that this is identical to dc->insn_start. Certainly there does not seem to be any possibility of any opcodes emitted in between.
If you think we should use a different field, then initialize it to null next to eci/eci_handled.
r~
Re: [PATCH 04/55] target/arm: Add handling for PSR.ECI/ICI
Quoted 13 lines · Richard Henderson
target/arm/translate.c static inline bool is_singlestepping(DisasContext *s) · line 320
Quoted 9 lines · Peter Maydell
target/arm/translate.c +9
-0+void clear_eci_state (DisasContext *s) +{ +/* +* Clear any ECI/ICI state: used when a load multiple/store +* multiple insn executes. +*/ +if (s->eci) { +TCGv_i32 tmp =tcg_temp_new_i32 (); +tcg_gen_movi_i32 (tmp,0 );
tcg_const_i32or preferablytcg_constant_i32.
I'll use tcg_const_i32(), yep. (I think I copied this absent-mindedly from some of the existing code in translate.c that uses tcg_gen_movi_i32().) Can't use tcg_constant_i32() because store_cpu_field() wants to tcg_temp_free_i32() its argument.
Quoted 11 lines
target/arm/translate.c static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) · line 8826
Quoted 10 lines
target/arm/translate.c +10
-0+if (condexec &0xf ) { + dc->condexec_mask = (condexec &0xf ) <<1 ; + dc->condexec_cond = condexec >>4 ; + dc->eci =0 ; + }else { + dc->condexec_mask =0 ; + dc->condexec_cond =0 ; +if (arm_feature (env,ARM_FEATURE_M )) { + dc->eci = condexec >>4 ; + }
Quoted 1 line
This else leaves eci uninitialized.
Strictly speaking it doesn't, because gen_intermediate_code zero-initializes the DisasContext with a "{ }" struct initializer. But it's clearer to explicitly initialize here I guess. Fixed.
Quoted 35 lines
Quoted 24 lines
dc->insn = insn;target/arm/translate.c +22
-0+if (dc->eci) { +/* +* For M-profile continuable instructions, ECI/ICI handling +* falls into these cases: +* - interrupt-continuable instructions +* These are the various load/store multiple insns (both +* integer and fp). The ICI bits indicate the register +* where the load/store can resume. We make the IMPDEF +* choice to always do "instruction restart", ie ignore +* the ICI value and always execute the ldm/stm from the +* start. So all we need to do is zero PSR.ICI if the +* insn executes. +* - MVE instructions subject to beat-wise execution +* Here the ECI bits indicate which beats have already been +* executed, and we must honour this. Each insn of this +* type will handle it correctly. We will update PSR.ECI +* in the helper function for the insn (some ECI values +* mean that the following insn also has been partially +* executed). +* - Special cases which don't advance ECI +* The insns LE, LETP and BKPT leave the ECI/ICI state +* bits untouched. target/arm/translate.c static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) · line 9158
Quoted 10 lines
target/arm/translate.c +10
-0+* - all other insns (the common case) +* Non-zero ECI/ICI means an INVSTATE UsageFault. +* We place a rewind-marker here. Insns in the previous +* three categories will set a flag in the DisasContext. +* If the flag isn't set after we call disas_thumb_insn() +* or disas_thumb2_insn() then we know we have a "some other +* insn" case. We will rewind to the marker (ie throwing away +* all the generated code) and instead emit "take exception". +*/ + dc->eci_handled = false;
Quoted 7 lines
This should be done in
arm_tr_init_disas_context, I think, unconditionally, next to eci.Quoted 1 line
+
dc->insn_eci_rewind=tcg_last_op();I believe that this is identical to
dc->insn_start. Certainly there does not seem to be any possibility of any opcodes emitted in between.
There's quite a wide separation between where we set insn_start and here (we set insn_start in arm_tr_insn_start, then there's whatever the accel/tcg framework chooses to do between the insn_start callback and the translate_insn callback, then the arm_pre_translate_insn() code). So I felt that a separate pointer was easier to reason about.
In fact, looking again at the accel/tcg code, if we rewind to insn_start that will delete any code emitted by the breakpoint_check hook, anything emitted by plugin_gen_insn_start(), and anything emitted by gen_io_start() if this is a CF_LAST_IO insn. I think we want to keep all of those.
Quoted 2 lines
If you think we should use a different field, then initialize it to null next to eci/eci_handled.
Done.
-- PMM
Re: [PATCH 04/55] target/arm: Add handling for PSR.ECI/ICI
Quoted 2 lines · Peter Maydell
Can't use
tcg_constant_i32()becausestore_cpu_field()wants totcg_temp_free_i32()its argument.
Yes you can. I thought I documented somewhere that constant is silently ignored by free. Oh dear, now I see that I have conflicting docs -- will fix.
Quoted 5 lines
In fact, looking again at the accel/tcg code, if we rewind to
insn_startthat will delete any code emitted by thebreakpoint_checkhook, anything emitted byplugin_gen_insn_start(), and anything emitted bygen_io_start()if this is aCF_LAST_IOinsn. I think we want to keep all of those.
Hmm. I guess BP_CPU does say DISAS_TOO_MANY for execute only one more insn, and the plugin stuff. Good point.
r~
PATCH 5/55 target/arm: Let vfp_access_check() handle late NOCP checks
In reply to Peter MaydellIn commit a3494d4671797c we reworked the M-profile handling of its checks for when the NOCP exception should be raised because the FPU is disabled, so that (in line with the architecture) the NOCP check is done early over a large range of the encoding space, and takes precedence over UNDEF exceptions. As part of this, we removed the code from full_vfp_access_check() which raised an exception there for M-profile with the FPU disabled, because it was no longer reachable.
For MVE, some instructions which are outside the "coprocessor space" region of the encoding space must nonetheless do "is the FPU enabled" checks and possibly raise a NOCP exception. (In particular this covers the MVE-specific low-overhead branch insns LCTP, DLSTP and WLSTP.) To support these insns, reinstate the code in full_vfp_access_check(), so that their trans functions can call vfp_access_check() and get the correct behaviour.
--- target/arm/translate-vfp.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
target/arm/translate-vfp.c +15 -5
@@ -143,11 +143,21 @@ static void gen_preserve_fp_state(DisasContext *s)static bool full_vfp_access_check (DisasContext *s,bool ignore_vfp_enabled) {if (s->fp_excp_el) { -/* M-profile handled this earlier, in disas_m_nocp() */ -assert (!arm_dc_feature (s,ARM_FEATURE_M )); -gen_exception_insn (s, s->pc_curr,EXCP_UDEF , -syn_fp_access_trap (1 ,0xe , false), - s->fp_excp_el); +if (arm_dc_feature (s,ARM_FEATURE_M )) { +/* +* M-profile mostly catches the "FPU disabled" case early, in +* disas_m_nocp(), but a few insns (eg LCTP, WLSTP, DLSTP) +* which do coprocessor-checks are outside the large ranges of +* the encoding space handled by the patterns in m-nocp.decode, +* and for them we may need to raise NOCP here. +*/ +gen_exception_insn (s, s->pc_curr,EXCP_NOCP , +syn_uncategorized (), s->fp_excp_el); + }else { +gen_exception_insn (s, s->pc_curr,EXCP_UDEF , +syn_fp_access_trap (1 ,0xe , false), + s->fp_excp_el); + }return false; }
Signature · 1 line
2.20.1
Re: [PATCH 05/55] target/arm: Let vfp_access_check() handle late NOCP checks
Quoted 16 lines · Peter Maydell
In commit
a3494d4671797cwe reworked the M-profile handling of its checks for when the NOCP exception should be raised because the FPU is disabled, so that (in line with the architecture) the NOCP check is done early over a large range of the encoding space, and takes precedence over UNDEF exceptions. As part of this, we removed the code fromfull_vfp_access_check()which raised an exception there for M-profile with the FPU disabled, because it was no longer reachable.For MVE, some instructions which are outside the "coprocessor space" region of the encoding space must nonetheless do "is the FPU enabled" checks and possibly raise a NOCP exception. (In particular this covers the MVE-specific low-overhead branch insns LCTP, DLSTP and WLSTP.) To support these insns, reinstate the code in
full_vfp_access_check(), so that their trans functions can callvfp_access_check()and get the correct behaviour.
Quoted 4 lines
Signed-off-by Peter Maydell<[email protected]>--- target/arm/translate-vfp.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
r~
PATCH 6/55 target/arm: Implement MVE LCTP
In reply to Peter MaydellImplement the MVE LCTP instruction.
We put its decode and implementation with the other low-overhead-branch insns because although it is only present if MVE is implemented it is logically in the same group as the other LOB insns.
--- target/arm/t32.decode | 2 ++ target/arm/translate.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+)
target/arm/t32.decode +2 -0
@@ -674,5 +674,7 @@ BL 1111 0. .......... 11.1 ............ @branch24 DLS 1111 0 0000 100 rn:4 1110 0000 0000 0001 WLS 1111 0 0000 100 rn:4 1100 . .......... 1 imm=%lob_imm LE 1111 0 0000 0 f:1 0 1111 1100 . .......... 1 imm=%lob_imm + + LCTP 1111 0 0000 000 1111 1110 0000 0000 0001 ] }
target/arm/translate.c +24 -0
@@ -8192,6 +8192,30 @@ static bool trans_LE(DisasContext *s, arg_LE *a)return true; } +static bool trans_LCTP (DisasContext *s,arg_LCTP *a) +{ +/* +* M-profile Loop Clear with Tail Predication. Since our implementation +* doesn't cache branch information, all we need to do is reset +* FPSCR.LTPSIZE to 4. +*/ +TCGv_i32 ltpsize; + +if (!dc_isar_feature (aa32_lob, s) || + !dc_isar_feature (aa32_mve, s)) { +return false; + } + +if (!vfp_access_check (s)) { +return true; + } + + ltpsize =tcg_const_i32 (4 ); +store_cpu_field (ltpsize, v7m.ltpsize); +return true; +} + +static bool op_tbranch (DisasContext *s,arg_tbranch *a,bool half) {TCGv_i32 addr, tmp;
Signature · 1 line
2.20.1
Re: [PATCH 06/55] target/arm: Implement MVE LCTP
Quoted 7 lines · Peter Maydell
Implement the MVE LCTP instruction.
We put its decode and implementation with the other low-overhead-branch insns because although it is only present if MVE is implemented it is logically in the same group as the other LOB insns.
Quoted 5 lines
Signed-off-by Peter Maydell<[email protected]>--- target/arm/t32.decode | 2 ++ target/arm/translate.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+)
r~
PATCH 7/55 target/arm: Implement MVE WLSTP insn
In reply to Peter MaydellImplement the MVE WLSTP insn; this is like the existing WLS insn, except that it specifies a size value which is used to set FPSCR.LTPSIZE.
--- target/arm/t32.decode | 8 ++++++-- target/arm/translate.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-)
target/arm/t32.decode +6 -2
@@ -672,8 +672,12 @@ BL 1111 0. .......... 11.1 ............ @branch24 %lob_imm 1:10 11:1 !function=times_2 DLS 1111 0 0000 100 rn:4 1110 0000 0000 0001 - WLS 1111 0 0000 100 rn:4 1100 . .......... 1 imm=%lob_imm - LE 1111 0 0000 0 f:1 0 1111 1100 . .......... 1 imm=%lob_imm + WLS 1111 0 0000 100 rn:4 1100 . .......... 1 imm=%lob_imm size=4 + { + # This is WLSTP + WLS 1111 0 0000 0 size:2 rn:4 1100 . .......... 1 imm=%lob_imm + LE 1111 0 0000 0 f:1 0 1111 1100 . .......... 1 imm=%lob_imm + } LCTP 1111 0 0000 000 1111 1110 0000 0000 0001 ]
target/arm/translate.c +35 -1
@@ -8135,7 +8135,11 @@ static bool trans_WLS(DisasContext *s, arg_WLS *a)return false; }if (a->rn ==13 || a->rn ==15 ) { -/* CONSTRAINED UNPREDICTABLE: we choose to UNDEF */ +/* +* For WLSTP rn == 15 is a related encoding (LE); the +* other cases caught by this condition are all +* CONSTRAINED UNPREDICTABLE: we choose to UNDEF +*/ return false; }if (s->condexec_mask) {
@@ -8148,10 +8152,40 @@ static bool trans_WLS(DisasContext *s, arg_WLS *a)*/ return false; } +if (a->size !=4 ) { +/* WLSTP */ +if (!dc_isar_feature (aa32_mve, s)) { +return false; + } +/* +* We need to check that the FPU is enabled here, but mustn't +* call vfp_access_check() to do that because we don't want to +* do the lazy state preservation in the "loop count is zero" case. +* Do the check-and-raise-exception by hand. +*/ +if (s->fp_excp_el) { +gen_exception_insn (s, s->pc_curr,EXCP_NOCP , +syn_uncategorized (), s->fp_excp_el); + } + } + nextlabel =gen_new_label ();tcg_gen_brcondi_i32 (TCG_COND_EQ , cpu_R[a->rn],0 , nextlabel); tmp =load_reg (s, a->rn);store_reg (s,14 , tmp); +if (a->size !=4 ) { +/* +* WLSTP: set FPSCR.LTPSIZE. This requires that we do the +* lazy state preservation, new FP context creation, etc, +* that vfp_access_check() does. We know that the actual +* access check will succeed (ie it won't generate code that +* throws an exception) because we did that check by hand earlier. +*/ +bool ok =vfp_access_check (s); +assert (ok); + tmp =tcg_const_i32 (a->size); +store_cpu_field (tmp, v7m.ltpsize); + }gen_jmp_tb (s, s->base.pc_next,1 );gen_set_label (nextlabel);
Signature · 1 line
2.20.1
Re: [PATCH 07/55] target/arm: Implement MVE WLSTP insn
target/arm/t32.decode BL 1111 0. .......... 11.1 ............ @branch24 · line 680
Quoted 6 lines · Peter Maydell
target/arm/t32.decode +6
-0+ WLS 1111 0 0000 100 rn:4 1100 . .......... 1 imm=%lob_imm size=4 + { + # This is WLSTP + WLS 1111 0 0000 0 size:2 rn:4 1100 . .......... 1 imm=%lob_imm + LE 1111 0 0000 0 f:1 0 1111 1100 . .......... 1 imm=%lob_imm + }
I guess it doesn't matter, but I'd swap these two, as LE is the more specific encoding.
Quoted 9 lines
target/arm/translate.c +5
-0@@ -8148,10 +8152,40 @@ static bool trans_WLS(DisasContext *s, arg_WLS *a)*/ return false; } +if (a->size !=4 ) { +/* WLSTP */ +if (!dc_isar_feature (aa32_mve, s)) { +return false; + }
target/arm/translate.c static bool trans_WLS(DisasContext *s, arg_WLS *a) · line 8169
Quoted 10 lines
target/arm/translate.c +10
-0+/* +* We need to check that the FPU is enabled here, but mustn't +* call vfp_access_check() to do that because we don't want to +* do the lazy state preservation in the "loop count is zero" case. +* Do the check-and-raise-exception by hand. +*/ +if (s->fp_excp_el) { +gen_exception_insn (s, s->pc_curr,EXCP_NOCP , +syn_uncategorized (), s->fp_excp_el); + }
Surely return true here...
target/arm/translate.c static bool trans_WLS(DisasContext *s, arg_WLS *a) · line 8185
Quoted 10 lines
target/arm/translate.c +10
-0+if (a->size !=4 ) { +/* +* WLSTP: set FPSCR.LTPSIZE. This requires that we do the +* lazy state preservation, new FP context creation, etc, +* that vfp_access_check() does. We know that the actual +* access check will succeed (ie it won't generate code that +* throws an exception) because we did that check by hand earlier. +*/ +bool ok =vfp_access_check (s); +assert (ok);
... otherwise this assert will trigger.
r~
r~
PATCH 8/55 target/arm: Implement MVE DLSTP
In reply to Peter MaydellImplement the MVE DLSTP insn; this is like the existing DLS insn, except that it must do an FPU access check and it sets LTPSIZE to the value specified in the insn.
--- target/arm/t32.decode | 9 ++++++--- target/arm/translate.c | 23 +++++++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-)
target/arm/t32.decode +6 -3
@@ -671,14 +671,17 @@ BL 1111 0. .......... 11.1 ............ @branch24 # LE and WLS immediate %lob_imm 1:10 11:1 !function=times_2 - DLS 1111 0 0000 100 rn:4 1110 0000 0000 0001 + DLS 1111 0 0000 100 rn:4 1110 0000 0000 0001 size=4 WLS 1111 0 0000 100 rn:4 1100 . .......... 1 imm=%lob_imm size=4 { # This is WLSTP WLS 1111 0 0000 0 size:2 rn:4 1100 . .......... 1 imm=%lob_imm LE 1111 0 0000 0 f:1 0 1111 1100 . .......... 1 imm=%lob_imm } - - LCTP 1111 0 0000 000 1111 1110 0000 0000 0001 + { + # This is DLSTP + DLS 1111 0 0000 0 size:2 rn:4 1110 0000 0000 0001 + LCTP 1111 0 0000 000 1111 1110 0000 0000 0001 + } ] }
target/arm/translate.c +21 -2
@@ -8115,13 +8115,32 @@ static bool trans_DLS(DisasContext *s, arg_DLS *a)return false; }if (a->rn ==13 || a->rn ==15 ) { -/* CONSTRAINED UNPREDICTABLE: we choose to UNDEF */ +/* +* For DLSTP rn == 15 is a related encoding (LCTP); the +* other cases caught by this condition are all +* CONSTRAINED UNPREDICTABLE: we choose to UNDEF +*/ return false; } -/* Not a while loop, no tail predication: just set LR to the count */ +if (a->size !=4 ) { +/* DLSTP */ +if (!dc_isar_feature (aa32_mve, s)) { +return false; + } +if (!vfp_access_check (s)) { +return true; + } + } + +/* Not a while loop: set LR to the count, and set LTPSIZE for DLSTP */ tmp =load_reg (s, a->rn);store_reg (s,14 , tmp); +if (a->size !=4 ) { +/* DLSTP: set FPSCR.LTPSIZE */ + tmp =tcg_const_i32 (a->size); +store_cpu_field (tmp, v7m.ltpsize); + }return true; }
Signature · 1 line
2.20.1
Re: [PATCH 08/55] target/arm: Implement MVE DLSTP
target/arm/t32.decode BL 1111 0. .......... 11.1 ............ @branch24 · line 685
Quoted 5 lines · Peter Maydell
target/arm/t32.decode +5
-0+ { + # This is DLSTP + DLS 1111 0 0000 0 size:2 rn:4 1110 0000 0000 0001 + LCTP 1111 0 0000 000 1111 1110 0000 0000 0001 + }
Same comment with LCTP being the more specific encoding. Either way,
r~
PATCH 9/55 target/arm: Implement MVE LETP insn
In reply to Peter MaydellImplement the MVE LETP insn. This is like the existing LE loop-end insn, but it must perform an FPU-enabled check, and on loop-exit it resets LTPSIZE to 4.
To accommodate the requirement to do something on loop-exit, we drop the use of condlabel and instead manage both the TB exits manually, in the same way we already do in trans_WLS().
The other MVE-specific change to the LE insn is that we must raise an INVSTATE UsageFault insn if LTPSIZE is not 4.
---
This amounts to a complete rewrite of trans_LE()...
--- target/arm/t32.decode | 2 +- target/arm/translate.c | 104 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 97 insertions(+), 9 deletions(-)
target/arm/t32.decode +1 -1
@@ -676,7 +676,7 @@ BL 1111 0. .......... 11.1 ............ @branch24 { # This is WLSTP WLS 1111 0 0000 0 size:2 rn:4 1100 . .......... 1 imm=%lob_imm - LE 1111 0 0000 0 f:1 0 1111 1100 . .......... 1 imm=%lob_imm + LE 1111 0 0000 0 f:1 tp:1 1111 1100 . .......... 1 imm=%lob_imm } { # This is DLSTP
target/arm/translate.c +96 -8
121 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 09/55] target/arm: Implement MVE LETP insn
Quoted 11 lines · Peter Maydell
Implement the MVE LETP insn. This is like the existing LE loop-end insn, but it must perform an FPU-enabled check, and on loop-exit it resets LTPSIZE to 4.
To accommodate the requirement to do something on loop-exit, we drop the use of condlabel and instead manage both the TB exits manually, in the same way we already do in
trans_WLS().The other MVE-specific change to the LE insn is that we must raise an INVSTATE UsageFault insn if LTPSIZE is not 4.
Quoted 7 lines
Signed-off-by Peter Maydell<[email protected]>---
This amounts to a complete rewrite oftrans_LE()...--- target/arm/t32.decode | 2 +- target/arm/translate.c | 104 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 97 insertions(+), 9 deletions(-)
r~
PATCH 10/55 target/arm: Add framework for MVE decode
In reply to Peter MaydellAdd the framework for decoding MVE insns, with the necessary new files and the meson.build rules, but no actual content yet.
--- target/arm/translate-a32.h | 1 + target/arm/mve.decode | 20 ++++++++++++++++++++ target/arm/translate-mve.c | 29 +++++++++++++++++++++++++++++ target/arm/translate.c | 1 + target/arm/meson.build | 2 ++ 5 files changed, 53 insertions(+) create mode 100644 target/arm/mve.decode create mode 100644 target/arm/translate-mve.c
target/arm/translate-a32.h +1 -0
@@ -22,6 +22,7 @@/* Prototypes for autogenerated disassembler functions */ bool disas_m_nocp (DisasContext *dc,uint32_t insn); +bool disas_mve (DisasContext *dc,uint32_t insn);bool disas_vfp (DisasContext *s,uint32_t insn);bool disas_vfp_uncond (DisasContext *s,uint32_t insn);bool disas_neon_dp (DisasContext *s,uint32_t insn);
target/arm/mve.decode new file +20 -0
@@ -0,0 +1,20 @@ +# M-profile MVE instruction descriptions +# +# Copyright (c) 2021 Linaro, Ltd +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see <http://www.gnu.org/licenses/>. + +# +# This file is processed by scripts/decodetree.py +#
target/arm/translate-mve.c new file +29 -0
@@ -0,0 +1,29 @@ +/* +* ARM translation: M-profile MVE instructions + +* Copyright (c) 2021 Linaro, Ltd. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include "tcg/tcg-op.h" +#include "tcg/tcg-op-gvec.h" +#include "exec/exec-all.h" +#include "exec/gen-icount.h" +#include "translate.h" +#include "translate-a32.h" + +/* Include the generated decoder */ +#include "decode-mve.c.inc"
target/arm/translate.c +1 -0
@@ -8919,6 +8919,7 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)if (disas_t32 (s, insn) ||disas_vfp_uncond (s, insn) ||disas_neon_shared (s, insn) || +disas_mve (s, insn) || ((insn >>28 ) ==0xe &&disas_vfp (s, insn))) {return ; }
target/arm/meson.build +2 -0
@@ -6,6 +6,7 @@ gen = [ decodetree.process('vfp.decode', extra_args: '--decode=disas_vfp'), decodetree.process('vfp-uncond.decode', extra_args: '--decode=disas_vfp_uncond'), decodetree.process('m-nocp.decode', extra_args: '--decode=disas_m_nocp'), + decodetree.process('mve.decode', extra_args: '--decode=disas_mve'), decodetree.process('a32.decode', extra_args: '--static-decode=disas_a32'), decodetree.process('a32-uncond.decode', extra_args: '--static-decode=disas_a32_uncond'), decodetree.process('t32.decode', extra_args: '--static-decode=disas_t32'),
@@ -27,6 +28,7 @@ arm_ss.add(files( 'tlb_helper.c', 'translate.c', 'translate-m-nocp.c', + 'translate-mve.c', 'translate-neon.c', 'translate-vfp.c', 'vec_helper.c',
Signature · 1 line
2.20.1
Re: [PATCH 10/55] target/arm: Add framework for MVE decode
Quoted 11 lines · Peter Maydell
Add the framework for decoding MVE insns, with the necessary new files and the meson.build rules, but no actual content yet.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/translate-a32.h | 1 + target/arm/mve.decode | 20 ++++++++++++++++++++ target/arm/translate-mve.c | 29 +++++++++++++++++++++++++++++ target/arm/translate.c | 1 + target/arm/meson.build | 2 ++ 5 files changed, 53 insertions(+)
Quoted 2 lines
create mode 100644 target/arm/mve.decode
create mode 100644target/arm/translate-mve.c
r~
PATCH 11/55 target/arm: Implement MVE VLDR/VSTR (non-widening forms)
In reply to Peter MaydellImplement the forms of the MVE VLDR and VSTR insns which perform non-widening loads of bytes, halfwords or words from memory into vector elements of the same width (encodings T5, T6, T7).
(At the moment we know for MVE and M-profile in general that vfp_access_check() can never return false, but we include the conventional return-true-on-failure check for consistency with non-M-profile translation code.)
---
target/arm/{translate-mve.c => helper-mve.h} | 21 +--
target/arm/helper.h | 2 +
target/arm/internals.h | 11 ++
target/arm/mve.decode | 22 +++
target/arm/mve_helper.c | 188 +++++++++++++++++++
target/arm/translate-mve.c | 124 +++++++++++-
target/arm/meson.build | 1 +
7 files changed, 355 insertions(+), 14 deletions(-)
copy target/arm/{translate-mve.c => helper-mve.h} (61%)
create mode 100644 target/arm/mve_helper.ctarget/arm/helper-mve.h renamed from target/arm/translate-mve.c +8 -13
@@ -1,6 +1,6 @@/* -* ARM translation: M-profile MVE instructions - +* M-profile MVE specific helper definitions +* * Copyright (c) 2021 Linaro, Ltd. * * This library is free software; you can redistribute it and/or
@@ -16,14 +16,9 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ - -#include "qemu/osdep.h" -#include "tcg/tcg-op.h" -#include "tcg/tcg-op-gvec.h" -#include "exec/exec-all.h" -#include "exec/gen-icount.h" -#include "translate.h" -#include "translate-a32.h" - -/* Include the generated decoder */ -#include "decode-mve.c.inc" +DEF_HELPER_FLAGS_3(mve_vldrb, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vldrh, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vldrw, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vstrb, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vstrh, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3 (mve_vstrw,TCG_CALL_NO_WG , void, env, ptr, i32)
target/arm/helper.h +2 -0
@@ -1019,3 +1019,5 @@ DEF_HELPER_FLAGS_6(gvec_bfmlal_idx, TCG_CALL_NO_RWG,#include "helper-a64.h" #include "helper-sve.h" #endif + +#include "helper-mve.h"
target/arm/internals.h +11 -0
@@ -1202,4 +1202,15 @@ static inline uint64_t useronly_maybe_clean_ptr(uint32_t desc, uint64_t ptr) return ptr; } +/* Values for M-profile PSR.ECI for MVE insns */ +enum MVEECIState { +ECI_NONE =0 ,/* No completed beats */ +ECI_A0 =1 ,/* Completed: A0 */ +ECI_A0A1 =2 ,/* Completed: A0, A1 */ +/* 3 is reserved */ +ECI_A0A1A2 =4 ,/* Completed: A0, A1, A2 */ +ECI_A0A1A2B0 =5 ,/* Completed: A0, A1, A2, B0 */ +/* All other values reserved */ +}; +#endif
target/arm/mve.decode +22 -0
@@ -18,3 +18,25 @@ # # This file is processed by scripts/decodetree.py # + +%qd 22:1 13:3 + +&vldr_vstr rn qd imm p a w size l + +@vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd + +# Vector loads and stores + +# Non-widening loads/stores (P=0 W=0 is 'related encoding') +VLDR_VSTR 1110110 0 a:1 . 1 . .... ... 111100 ....... @vldr_vstr \ + size=0 p=0 w=1 +VLDR_VSTR 1110110 0 a:1 . 1 . .... ... 111101 ....... @vldr_vstr \ + size=1 p=0 w=1 +VLDR_VSTR 1110110 0 a:1 . 1 . .... ... 111110 ....... @vldr_vstr \ + size=2 p=0 w=1 +VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111100 ....... @vldr_vstr \ + size=0 p=1 +VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ + size=1 p=1 +VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ + size=2 p=1
target/arm/mve_helper.c new file +188 -0
188 lines not on this page · raw message
target/arm/translate-mve.c +123 -1
132 lines not on this page · raw message
target/arm/meson.build +1 -0
@@ -23,6 +23,7 @@ arm_ss.add(files( 'helper.c', 'iwmmxt_helper.c', 'm_helper.c', + 'mve_helper.c', 'neon_helper.c', 'op_helper.c', 'tlb_helper.c',
Signature · 1 line
2.20.1
Re: [PATCH 11/55] target/arm: Implement MVE VLDR/VSTR (non-widening forms)
Quoted 11 lines · Peter Maydell
target/arm/mve_helper.c new file +11
-0+static uint16_t mve_element_mask (CPUARMState *env) +{ +/* +* Return the mask of which elements in the MVE vector should be +* updated. This is a combination of multiple things: +* (1) by default, we update every lane in the vector +* (2) VPT predication stores its state in the VPR register; +* (3) low-overhead-branch tail predication will mask out part +* the vector on the final iteration of the loop +* (4) if EPSR.ECI is set then we must execute only some beats +* of the insn
target/arm/mve_helper.c line 61
Quoted 10 lines
target/arm/mve_helper.c new file +10
-0+* We combine all these into a 16-bit result with the same semantics +* as VPR.P0: 0 to mask the lane, 1 if it is active. +* 8-bit vector ops will look at all bits of the result; +* 16-bit ops will look at bits 0, 2, 4, ...; +* 32-bit ops will look at bits 0, 4, 8 and 12. +* Compare pseudocode GetCurInstrBeat(), though that only returns +* the 4-bit slice of the mask corresponding to a single beat. +*/ +uint16_t mask =extract32 (env->v7m.vpr,R_V7M_VPR_P0_SHIFT , +R_V7M_VPR_P0_LENGTH );
Any reason you're not using FIELD_EX32 and and FIELD_DP32 so far in this file?
target/arm/mve_helper.c line 149
Quoted 6 lines
target/arm/mve_helper.c new file +6
-0+#define DO_VLDR (OP ,ESIZE ,LDTYPE ,TYPE ,H ) \ + void HELPER(mve_##OP)(CPUARMState *env, void *vd, uint32_t addr) \ + { \ + TYPE *d = vd; \ + uint16_t mask = mve_element_mask(env); \ + unsigned b, e; \
esize is redundant with sizeof(type); perhaps just make it a local variable?
target/arm/translate-mve.c line 4
Quoted 10 lines
target/arm/translate-mve.c +1
-1@@ -1,6 +1,6 @@/* * ARM translation: M-profile MVE instructions - +* * Copyright (c) 2021 Linaro, Ltd.
Is this just diff silliness? I see that it has decided that helper-mve.h is a rename from translate-mve.c...
target/arm/translate-mve.c line 92
Quoted 13 lines
target/arm/translate-mve.c +13
-0+static bool do_ldst (DisasContext *s,arg_VLDR_VSTR *a,MVEGenLdStFn *fn) +{ +TCGv_i32 addr; +uint32_t offset; +TCGv_ptr qreg; + +if (!dc_isar_feature (aa32_mve, s)) { +return false; + } + +if (a->qd >7 || !fn) { +return false; + }
It's a funny old decode,
if D then UNDEFINED.
d = D:Qd,
Is the spec forward looking to more than 7 Q registers? It's tempting to just drop the D:Qd from the decode...
target/arm/translate-mve.c line 138
Quoted 3 lines
target/arm/translate-mve.c +3
-0+static bool trans_VLDR_VSTR (DisasContext *s,arg_VLDR_VSTR *a) +{ +MVEGenLdStFn *ldfns[] = {
static MVEGenLdStFn * const ldfns
Quoted 1 line
+ MVEGenLdStFn *stfns[] = {
Likewise, though...
Quoted 1 line
+ return
do_ldst(s, a, a->l ? ldfns[a->size] : stfns[a->size]);
... just put em together into a two-dimensional array, with a->l as the second index?
r~
Re: [PATCH 11/55] target/arm: Implement MVE VLDR/VSTR (non-widening forms)
Quoted 7 lines · Richard Henderson
target/arm/translate-mve.c line 138
Quoted 4 lines
target/arm/translate-mve.c +3
-0+static bool trans_VLDR_VSTR (DisasContext *s,arg_VLDR_VSTR *a) +{ + MVEGenLdStFn *ldfns[] = {static MVEGenLdStFn * const ldfns
Quoted 7 lines
Quoted 1 line
+ MVEGenLdStFn *stfns[] = {
Likewise, though...
Quoted 1 line
+ return
do_ldst(s, a, a->l ? ldfns[a->size] : stfns[a->size]);... just put em together into a two-dimensional array, with
a->las the second index?
... or separate VLDR from VSTR.
r~
Re: [PATCH 11/55] target/arm: Implement MVE VLDR/VSTR (non-widening forms)
In reply to Richard HendersonQuoted 17 lines · Richard Henderson
Quoted 15 lines · Peter Maydell
target/arm/mve_helper.c new file +15
-0+static uint16_t mve_element_mask (CPUARMState *env) +{ +/* +* Return the mask of which elements in the MVE vector should be +* updated. This is a combination of multiple things: +* (1) by default, we update every lane in the vector +* (2) VPT predication stores its state in the VPR register; +* (3) low-overhead-branch tail predication will mask out part +* the vector on the final iteration of the loop +* (4) if EPSR.ECI is set then we must execute only some beats +* of the insn +* We combine all these into a 16-bit result with the same semantics +* as VPR.P0: 0 to mask the lane, 1 if it is active. +* 8-bit vector ops will look at all bits of the result; +* 16-bit ops will look at bits 0, 2, 4, ...;
Quoted 8 lines
target/arm/mve_helper.c line 61
Quoted 6 lines
target/arm/mve_helper.c new file +6
-0+* 32-bit ops will look at bits 0, 4, 8 and 12. +* Compare pseudocode GetCurInstrBeat(), though that only returns +* the 4-bit slice of the mask corresponding to a single beat. +*/ +uint16_t mask =extract32 (env->v7m.vpr,R_V7M_VPR_P0_SHIFT , +R_V7M_VPR_P0_LENGTH );Any reason you're not using
FIELD_EX32and andFIELD_DP32so far in this file?
Just habit, really, I think.
Quoted 9 lines
target/arm/mve_helper.c line 149
Quoted 6 lines
target/arm/mve_helper.c new file +6
-0+#define DO_VLDR (OP ,ESIZE ,LDTYPE ,TYPE ,H ) \ + void HELPER(mve_##OP)(CPUARMState *env, void *vd, uint32_t addr) \ + { \ + TYPE *d = vd; \ + uint16_t mask = mve_element_mask(env); \ + unsigned b, e; \esize is redundant with sizeof(type); perhaps just make it a local variable?
Quoted 13 lines
target/arm/translate-mve.c line 4
Quoted 10 lines
target/arm/translate-mve.c +1
-1@@ -1,6 +1,6 @@/* * ARM translation: M-profile MVE instructions - +* * Copyright (c) 2021 Linaro, Ltd. Is this just diff silliness? I see that it has decided that
helper-mve.his a rename fromtranslate-mve.c...
Not sure. I fixed at least one similar issue before sending, I guess I missed this one.
Quoted 16 lines
target/arm/translate-mve.c line 92
Quoted 13 lines
target/arm/translate-mve.c +13
-0+static bool do_ldst (DisasContext *s,arg_VLDR_VSTR *a,MVEGenLdStFn *fn) +{ +TCGv_i32 addr; +uint32_t offset; +TCGv_ptr qreg; + +if (!dc_isar_feature (aa32_mve, s)) { +return false; + } + +if (a->qd >7 || !fn) { +return false; + }It's a funny old decode,
Quoted 5 lines
if D then UNDEFINED.
d = D:Qd,Is the spec forward looking to more than 7 Q registers? It's tempting to just drop the D:Qd from the decode...
I don't know, but looking at the decode it certainly seems like the door is being left open to Q8..Q15. Other signs of this include the existence of the VFPSmallRegisterBank() function and the way that VLLDM and VLSTM have T2 encodings whose only difference from the T1 encodings is that you can specify registers up to D31. Decoding D:Qd and then doing the range check seemed more in line with the spirit of this, though of course leaving the D=1 UNDEF to decodetree works too. (Some insns really do only use 3 bit register fields without the extra D bit, so if we left all the fields 3 bit and later needed to handle Q8..Q15 we'd have to go through everything to work out which type of insn it was.)
Quoted 6 lines
target/arm/translate-mve.c line 138
Quoted 3 lines
target/arm/translate-mve.c +3
-0+static bool trans_VLDR_VSTR (DisasContext *s,arg_VLDR_VSTR *a) +{ +MVEGenLdStFn *ldfns[] = {static MVEGenLdStFn * const ldfns
Quoted 8 lines
Quoted 1 line
+ MVEGenLdStFn *stfns[] = {
Likewise, though...
Quoted 1 line
+ return
do_ldst(s, a, a->l ? ldfns[a->size] : stfns[a->size]);... just put em together into a two-dimensional array, with
a->las the second index?
Yeah. (I was being a bit lazy because I can never remember which way round the initializers go in a 2D array :-)
-- PMM
Re: [PATCH 11/55] target/arm: Implement MVE VLDR/VSTR (non-widening forms)
Quoted 10 lines · Peter Maydell
Quoted 2 lines
Is the spec forward looking to more than 7 Q registers? It's tempting to just drop the D:Qd from the decode...
I don't know, but looking at the decode it certainly seems like the door is being left open to Q8..Q15. Other signs of this include the existence of the
VFPSmallRegisterBank()function and the way that VLLDM and VLSTM have T2 encodings whose only difference from the T1 encodings is that you can specify registers up to D31. Decoding D:Qd and then doing the range check seemed more in line with the spirit of this...
I agree. We should leave the decode in place.
Do you think it's worthwhile adding a single hook for the register range check now? E.g.
if (!mve_check_qreg_bank(s, a->qd | a->qn | a->qm)) {
return false;
}static bool mve_check_qreg_bank(DisasContext *s, int qmask)
{
/*
* See VFPSmallRegisterBank, always true for armv8.1-m.
* So only Q0...Q7 are supported.
*/
return qmask < 8;
}And, as needed, another one for dregs.
r~
Re: [PATCH 11/55] target/arm: Implement MVE VLDR/VSTR (non-widening forms)
In reply to Richard HendersonQuoted 10 lines · Richard Henderson
target/arm/mve_helper.c line 149
Quoted 6 lines · Peter Maydell
target/arm/mve_helper.c new file +6
-0+#define DO_VLDR (OP ,ESIZE ,LDTYPE ,TYPE ,H ) \ + void HELPER(mve_##OP)(CPUARMState *env, void *vd, uint32_t addr) \ + { \ + TYPE *d = vd; \ + uint16_t mask = mve_element_mask(env); \ + unsigned b, e; \esize is redundant with sizeof(type); perhaps just make it a local variable?
That's OK here, but not for most of the other macros, where we need ESIZE as a macro argument so we can do mask_to_bytemask##ESIZE.
-- PMM
PATCH 12/55 target/arm: Implement widening/narrowing MVE VLDR/VSTR insns
In reply to Peter MaydellImplement the variants of MVE VLDR (encodings T1, T2) which perform "widening" loads where bytes or halfwords are loaded from memory and zero or sign-extended into halfword or word length vector elements, and the narrowing MVE VSTR (encodings T1, T2) where bytes or halfwords are stored from halfword or word elements.
--- target/arm/helper-mve.h | 10 ++++++++++ target/arm/mve.decode | 25 +++++++++++++++++++++++-- target/arm/mve_helper.c | 10 ++++++++++ target/arm/translate-mve.c | 18 ++++++++++++++++++ 4 files changed, 61 insertions(+), 2 deletions(-)
target/arm/helper-mve.h +10 -0
@@ -22,3 +22,13 @@ DEF_HELPER_FLAGS_3(mve_vldrw, TCG_CALL_NO_WG, void, env, ptr, i32) DEF_HELPER_FLAGS_3(mve_vstrb, TCG_CALL_NO_WG, void, env, ptr, i32) DEF_HELPER_FLAGS_3(mve_vstrh, TCG_CALL_NO_WG, void, env, ptr, i32) DEF_HELPER_FLAGS_3(mve_vstrw, TCG_CALL_NO_WG, void, env, ptr, i32) + +DEF_HELPER_FLAGS_3(mve_vldrb_sh, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vldrb_sw, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vldrb_uh, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vldrb_uw, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vldrh_sw, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vldrh_uw, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vstrb_h, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vstrb_w, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3 (mve_vstrh_w,TCG_CALL_NO_WG , void, env, ptr, i32)
target/arm/mve.decode +23 -2
@@ -21,12 +21,33 @@ %qd 22:1 13:3 -&vldr_vstr rn qd imm p a w size l +&vldr_vstr rn qd imm p a w size l u -@vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd +@vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 +# Note that both Rn and Qd are 3 bits only (no D bit) +@vldst_wn ... u:1 ... . . . . l:1 . rn:3 qd:3 . ... .. imm:7 &vldr_vstr # Vector loads and stores +# Widening loads and narrowing stores: +# for these P=0 W=0 is 'related encoding'; sz=11 is 'related encoding' +# This means we need to expand out to multiple patterns for P, W, SZ. +# For stores the U bit must be 0 but we catch that in the trans_ function. +# The naming scheme here is "VLDSTB_H == in-memory byte load/store to/from +# signed halfword element in register", etc. +VLDSTB_H 111 . 110 0 a:1 0 1 . 0 ... ... 0 111 01 ....... @vldst_wn \ + p=0 w=1 size=1 +VLDSTB_H 111 . 110 1 a:1 0 w:1 . 0 ... ... 0 111 01 ....... @vldst_wn \ + p=1 size=1 +VLDSTB_W 111 . 110 0 a:1 0 1 . 0 ... ... 0 111 10 ....... @vldst_wn \ + p=0 w=1 size=2 +VLDSTB_W 111 . 110 1 a:1 0 w:1 . 0 ... ... 0 111 10 ....... @vldst_wn \ + p=1 size=2 +VLDSTH_W 111 . 110 0 a:1 0 1 . 1 ... ... 0 111 10 ....... @vldst_wn \ + p=0 w=1 size=2 +VLDSTH_W 111 . 110 1 a:1 0 w:1 . 1 ... ... 0 111 10 ....... @vldst_wn \ + p=1 size=2 + # Non-widening loads/stores (P=0 W=0 is 'related encoding') VLDR_VSTR 1110110 0 a:1 . 1 . .... ... 111100 ....... @vldr_vstr \ size=0 p=0 w=1
target/arm/mve_helper.c +10 -0
@@ -180,9 +180,19 @@ DO_VLDR(vldrb, 1, ldub, uint8_t, H1) DO_VLDR(vldrh, 2, lduw, uint16_t, H2) DO_VLDR(vldrw, 4, ldl, uint32_t, H4) +DO_VLDR(vldrb_sh, 2, ldsb, int16_t, H2) +DO_VLDR(vldrb_sw, 4, ldsb, int32_t, H4) +DO_VLDR(vldrb_uh, 2, ldub, uint16_t, H2) +DO_VLDR(vldrb_uw, 4, ldub, uint32_t, H4) +DO_VLDR(vldrh_sw, 4, ldsw, int32_t, H4) +DO_VLDR(vldrh_uw, 4, lduw, uint32_t, H4) + DO_VSTR(vstrb, 1, stb, uint8_t, H1) DO_VSTR(vstrh, 2, stw, uint16_t, H2) DO_VSTR(vstrw, 4, stl, uint32_t, H4) +DO_VSTR(vstrb_h, 2, stb, int16_t, H2) +DO_VSTR(vstrb_w, 4, stb, int32_t, H4) +DO_VSTR(vstrh_w, 4, stw, int32_t, H4)#undef DO_VLDR#undef DO_VSTR
target/arm/translate-mve.c +18 -0
@@ -149,3 +149,21 @@ static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a) };return do_ldst (s, a, a->l ? ldfns[a->size] : stfns[a->size]); } + +#define DO_VLDST_WIDE_NARROW (OP ,SLD ,ULD ,ST ) \ + static bool trans_##OP(DisasContext *s, arg_VLDR_VSTR *a) \ + { \ + MVEGenLdStFn *ldfns[] = { \ + gen_helper_mve_##SLD, \ + gen_helper_mve_##ULD, \ + }; \ + MVEGenLdStFn *stfns[] = { \ + gen_helper_mve_##ST, \ + NULL, \ + }; \ + return do_ldst(s, a, a->l ? ldfns[a->u] : stfns[a->u]); \ + } + +DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h) +DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w) +DO_VLDST_WIDE_NARROW (VLDSTH_W , vldrh_sw, vldrh_uw, vstrh_w)
Signature · 1 line
2.20.1
Re: [PATCH 12/55] target/arm: Implement widening/narrowing MVE VLDR/VSTR insns
target/arm/translate-mve.c static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a) · line 165
Quoted 13 lines · Peter Maydell
target/arm/translate-mve.c +13
-0+#define DO_VLDST_WIDE_NARROW (OP ,SLD ,ULD ,ST ) \ + static bool trans_##OP(DisasContext *s, arg_VLDR_VSTR *a) \ + { \ + MVEGenLdStFn *ldfns[] = { \ + gen_helper_mve_##SLD, \ + gen_helper_mve_##ULD, \ + }; \ + MVEGenLdStFn *stfns[] = { \ + gen_helper_mve_##ST, \ + NULL, \ + }; \ + return do_ldst(s, a, a->l ? ldfns[a->u] : stfns[a->u]); \ + }
static const on the arrays, or array, as before.
Otherwise,
r~
PATCH 13/55 target/arm: Implement MVE VCLZ
In reply to Peter MaydellImplement the MVE VCLZ insn (and the necessary machinery for MVE 1-input vector ops).
Note that for non-load instructions predication is always performed at a byte level granularity regardless of element size (R_ZLSJ), and so the masking logic here differs from that used in the VLDR and VSTR helpers.
--- target/arm/helper-mve.h | 4 ++++ target/arm/mve.decode | 8 +++++++ target/arm/mve_helper.c | 48 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 43 ++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+)
target/arm/helper-mve.h +4 -0
@@ -32,3 +32,7 @@ DEF_HELPER_FLAGS_3(mve_vldrh_uw, TCG_CALL_NO_WG, void, env, ptr, i32) DEF_HELPER_FLAGS_3(mve_vstrb_h, TCG_CALL_NO_WG, void, env, ptr, i32) DEF_HELPER_FLAGS_3(mve_vstrb_w, TCG_CALL_NO_WG, void, env, ptr, i32) DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) + +DEF_HELPER_FLAGS_3(mve_vclzb, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vclzh, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3 (mve_vclzw,TCG_CALL_NO_WG , void, env, ptr, ptr)
target/arm/mve.decode +8 -0
@@ -20,13 +20,17 @@ # %qd 22:1 13:3 +%qm 5:1 1:3 &vldr_vstr rn qd imm p a w size l u +&1op qd qm size @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 # Note that both Rn and Qd are 3 bits only (no D bit) @vldst_wn ... u:1 ... . . . . l:1 . rn:3 qd:3 . ... .. imm:7 &vldr_vstr +@1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm + # Vector loads and stores # Widening loads and narrowing stores:
@@ -61,3 +65,7 @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ size=1 p=1 VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ size=2 p=1 + +# Vector miscellaneous + +VCLZ 1111 1111 1 . 11 .. 00 ... 0 0100 11 . 0 ... 0 @1op
target/arm/mve_helper.c +48 -0
51 lines not on this page · raw message
target/arm/translate-mve.c +43 -0
52 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 13/55] target/arm: Implement MVE VCLZ
Quoted 80 lines · Peter Maydell
Implement the MVE VCLZ insn (and the necessary machinery for MVE 1-input vector ops).
Note that for non-load instructions predication is always performed at a byte level granularity regardless of element size (
R_ZLSJ), and so the masking logic here differs from that used in the VLDR and VSTR helpers.Signed-off-by Peter Maydell <[email protected]>--- target/arm/helper-mve.h | 4 ++++ target/arm/mve.decode | 8 +++++++ target/arm/mve_helper.c | 48 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 43 ++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+)target/arm/helper-mve.h +4
-0@@ -32,3 +32,7 @@ DEF_HELPER_FLAGS_3(mve_vldrh_uw, TCG_CALL_NO_WG, void, env, ptr, i32) DEF_HELPER_FLAGS_3(mve_vstrb_h, TCG_CALL_NO_WG, void, env, ptr, i32) DEF_HELPER_FLAGS_3(mve_vstrb_w, TCG_CALL_NO_WG, void, env, ptr, i32) DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) + +DEF_HELPER_FLAGS_3(mve_vclzb, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vclzh, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3 (mve_vclzw,TCG_CALL_NO_WG , void, env, ptr, ptr)target/arm/mve.decode +8
-0@@ -20,13 +20,17 @@ # %qd 22:1 13:3 +%qm 5:1 1:3 &vldr_vstr rn qd imm p a w size l u +&1op qd qm size @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 # Note that both Rn and Qd are 3 bits only (no D bit) @vldst_wn ... u:1 ... . . . . l:1 . rn:3 qd:3 . ... .. imm:7 &vldr_vstr +@1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm + # Vector loads and stores # Widening loads and narrowing stores:@@ -61,3 +65,7 @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ size=1 p=1 VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ size=2 p=1 + +# Vector miscellaneous + +VCLZ 1111 1111 1 . 11 .. 00 ... 0 0100 11 . 0 ... 0 @1optarget/arm/mve_helper.c +14
-0@@ -196,3 +196,51 @@ DO_VSTR(vstrh_w, 4, stw, int32_t, H4)#undef DO_VLDR#undef DO_VSTR + +/* +* Take the bottom bits of mask (which is 1 bit per lane) and +* convert to a mask which has 1s in each byte which is predicated. +*/ +static uint8_t mask_to_bytemask1 (uint16_t mask) +{ +return (mask &1 ) ?0xff :0 ; +} + +static uint16_t mask_to_bytemask2 (uint16_t mask) +{ +static const uint16_t masks[] = {0x0000 ,0x00ff ,0xff00 ,0xffff }; +return masks[mask &3 ];
target/arm/mve_helper.c DO_VSTR(vstrh_w, 4, stw, int32_t, H4) · line 222
Quoted 10 lines
target/arm/mve_helper.c +10
-0+} + +static uint32_t mask_to_bytemask4 (uint16_t mask) +{ +static const uint32_t masks[] = { +0x00000000 ,0x000000ff ,0x0000ff00 ,0x0000ffff , +0x00ff0000 ,0x00ff00ff ,0x00ffff00 ,0x00ffffff , +0xff000000 ,0xff0000ff ,0xff00ff00 ,0xff00ffff , +0xffff0000 ,0xffff00ff ,0xffffff00 ,0xffffffff , + };
I'll note that
(1) the values for the mask_to_bytemask2 array overlap the first 4 values of the mask_to_bytemask4 array, and
(2) both of these overlap with the larger
static inline uint64_t expand_pred_b(uint8_t byte)
from SVE. It'd be nice to share the storage, whatever the actual functional interface into the array.
target/arm/mve_helper.c DO_VSTR(vstrh_w, 4, stw, int32_t, H4) · line 234
Quoted 9 lines
target/arm/mve_helper.c +9
-0+#define DO_1OP (OP ,ESIZE ,TYPE ,H ,FN ) \ + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ + { \ + TYPE *d = vd, *m = vm; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + TYPE r = FN(m[H(e)]); \ + uint64_t bytemask = mask_to_bytemask##ESIZE(mask); \
Why uint64_t and not TYPE? Or uint32_t?
target/arm/mve_helper.c DO_VSTR(vstrh_w, 4, stw, int32_t, H4) · line 238
Quoted 7 lines
target/arm/mve_helper.c +7
-0+if (!mve_eci_check (s)) { +return true; + } + +if (!vfp_access_check (s)) { +return true; + }
Not the first instance, but is it worth saving 4 lines per and combining these into one IF?
target/arm/mve_helper.c DO_VSTR(vstrh_w, 4, stw, int32_t, H4) · line 242
Quoted 4 lines
target/arm/mve_helper.c +4
-0+#define DO_1OP (INSN ,FN ) \ + static bool trans_##INSN(DisasContext *s, arg_1op *a) \ + { \ + MVEGenOneOpFn *fns[] = { \
static const.
r~
Re: [PATCH 13/55] target/arm: Implement MVE VCLZ
Quoted 42 lines · Richard Henderson
Quoted 24 lines · Peter Maydell
Implement the MVE VCLZ insn (and the necessary machinery for MVE 1-input vector ops).
Note that for non-load instructions predication is always performed at a byte level granularity regardless of element size (
R_ZLSJ), and so the masking logic here differs from that used in the VLDR and VSTR helpers.Signed-off-by Peter Maydell <[email protected]>target/arm/mve_helper.c +14
-0+ +/* +* Take the bottom bits of mask (which is 1 bit per lane) and +* convert to a mask which has 1s in each byte which is predicated. +*/ +static uint8_t mask_to_bytemask1 (uint16_t mask) +{ +return (mask &1 ) ?0xff :0 ; +} + +static uint16_t mask_to_bytemask2 (uint16_t mask) +{ +static const uint16_t masks[] = {0x0000 ,0x00ff ,0xff00 ,0xffff }; +return masks[mask &3 ];target/arm/mve_helper.c DO_VSTR(vstrh_w, 4, stw, int32_t, H4) · line 222
Quoted 10 lines
target/arm/mve_helper.c +10
-0+} + +static uint32_t mask_to_bytemask4 (uint16_t mask) +{ +static const uint32_t masks[] = { +0x00000000 ,0x000000ff ,0x0000ff00 ,0x0000ffff , +0x00ff0000 ,0x00ff00ff ,0x00ffff00 ,0x00ffffff , +0xff000000 ,0xff0000ff ,0xff00ff00 ,0xff00ffff , +0xffff0000 ,0xffff00ff ,0xffffff00 ,0xffffffff , + };I'll note that
(1) the values for the
mask_to_bytemask2array overlap the first 4 values of themask_to_bytemask4array, and
Quoted 6 lines
(2) both of these overlap with the larger
static inline
uint64_texpand_pred_b(uint8_t byte)from SVE. It'd be nice to share the storage, whatever the actual functional interface into the array.
Yeah, I guess so. I didn't really feel like trying to abstract that out...
Quoted 11 lines
target/arm/mve_helper.c DO_VSTR(vstrh_w, 4, stw, int32_t, H4) · line 234
Quoted 9 lines
target/arm/mve_helper.c +9
-0+#define DO_1OP (OP ,ESIZE ,TYPE ,H ,FN ) \ + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ + { \ + TYPE *d = vd, *m = vm; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + TYPE r = FN(m[H(e)]); \ + uint64_t bytemask = mask_to_bytemask##ESIZE(mask); \Why
uint64_tand not TYPE? Oruint32_t?
A later patch adds the mask_to_bytemask8(), so I wanted a type that was definitely unsigned (so TYPE isn't any good) and which was definitely big enough for 64 bits.
Quoted 10 lines
target/arm/translate-mve.c static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a) · line 189
Quoted 7 lines
target/arm/translate-mve.c +7
-0+if (!mve_eci_check (s)) { +return true; + } + +if (!vfp_access_check (s)) { +return true; + }Not the first instance, but is it worth saving 4 lines per and combining these into one IF?
Yes, I think so.
-- PMM
Re: [PATCH 13/55] target/arm: Implement MVE VCLZ
Quoted 10 lines · Peter Maydell
Quoted 10 lines
Quoted 9 lines
target/arm/mve_helper.c +9
-0+#define DO_1OP (OP ,ESIZE ,TYPE ,H ,FN ) \ + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ + { \ + TYPE *d = vd, *m = vm; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + TYPE r = FN(m[H(e)]); \ + uint64_t bytemask = mask_to_bytemask##ESIZE(mask); \
Quoted 5 lines
Quoted 1 line
Why
uint64_tand not TYPE? Oruint32_t?A later patch adds the
mask_to_bytemask8(), so I wanted a type that was definitely unsigned (so TYPE isn't any good) and which was definitely big enough for 64 bits.
Hmm. I was just concerned about the unnecessary type extension involved.
What about changing the interface. Not to return a mask as you do here, but to perform the entire merge operation. E.g.
static uint8_t mergemask1(uint8_t d, uint8_t r, uint16_t mask)
{
return mask & 1 ? r : d;
}static uint16_t mergemask2(uint16_t d, uint16_t r, uint16_t mask)
{
uint16_t bmask = array_whotsit[mask & 3];
return (d & ~bmask) | (r & bmask);
}etc.
Or maybe with a pointer argument for D, so that the load+store is done there as well. In which case you could use QEMU_GENERIC to select the function invoked, instead of using token pasting everywhere. E.g.
static void mergemask_ub(uint8_t *d, uint8_r, uint16_t mask)
{
if (mask & 1) {
*d = r;
}
}static void mergemask_sb(int8_t *d, int8_r, uint16_t mask)
{
mergemask_ub((uint8_t *)d, r, mask);
}static void mergemask_uh(uint16_t *d, uint16_r, uint16_t mask)
{
uint16_t bmask = array_whotsit[mask & 3];
*d = (*d & ~bmask) | (r & bmask);
}...
#define mergemask(D, R, M) \
QEMU_GENERIC(D, (uint8_t *, mergemask_ub), \
(int8_t *, mergemask_sb), \
... )BTW, now that we're at minimal gcc 7, I think we can shift to -std=gnu11 so that we can drop QEMU_GENERIC and just use _Generic, which is much easier to read than the above, and will give better error messages for missing cases. Anyway...
Which takes your boilerplate down to
target/arm/mve_helper.c DO_VSTR(vstrh_w, 4, stw, int32_t, H4) · line 239
Quoted 10 lines
target/arm/mve_helper.c +10
-0+#define DO_1OP (OP ,ESIZE ,TYPE ,H ,FN ) \ + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ + { \ + TYPE *d = vd, *m = vm; \ + uint16_t mask = mve_element_mask(env); \ + for (unsigned e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + mergemask(&d[H(e)], FN(m[H(e)]), mask); \ + } \ + mve_advance_vpt(env); \ + }
which looks pretty tidy to me.
r~
PATCH 14/55 target/arm: Implement MVE VCLS
In reply to Peter MaydellImplement the MVE VCLS insn.
--- target/arm/helper-mve.h | 4 ++++ target/arm/mve.decode | 1 + target/arm/mve_helper.c | 7 +++++++ target/arm/translate-mve.c | 1 + 4 files changed, 13 insertions(+)
target/arm/helper-mve.h +4 -0
@@ -33,6 +33,10 @@ DEF_HELPER_FLAGS_3(mve_vstrb_h, TCG_CALL_NO_WG, void, env, ptr, i32) DEF_HELPER_FLAGS_3(mve_vstrb_w, TCG_CALL_NO_WG, void, env, ptr, i32) DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vclsb, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vclsh, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vclsw, TCG_CALL_NO_WG, void, env, ptr, ptr) + DEF_HELPER_FLAGS_3(mve_vclzb, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vclzh, TCG_CALL_NO_WG, void, env, ptr, ptr)DEF_HELPER_FLAGS_3 (mve_vclzw,TCG_CALL_NO_WG , void, env, ptr, ptr)
target/arm/mve.decode +1 -0
@@ -68,4 +68,5 @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ # Vector miscellaneous +VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op VCLZ 1111 1111 1 . 11 .. 00 ... 0 0100 11 . 0 ... 0 @1op
target/arm/mve_helper.c +7 -0
@@ -238,6 +238,13 @@ static uint32_t mask_to_bytemask4(uint16_t mask)mve_advance_vpt (env); \ } +#define DO_CLS_B (N ) (clrsb32(N) - 24) +#define DO_CLS_H (N ) (clrsb32(N) - 16) + +DO_1OP(vclsb, 1, int8_t, H1, DO_CLS_B) +DO_1OP(vclsh, 2, int16_t, H2, DO_CLS_H) +DO_1OP(vclsw, 4, int32_t, H4, clrsb32) +#define DO_CLZ_B (N ) (clz32(N) - 24)#define DO_CLZ_H (N ) (clz32(N) - 16)
target/arm/translate-mve.c +1 -0
@@ -210,3 +210,4 @@ static bool do_1op(DisasContext *s, arg_1op *a, MVEGenOneOpFn fn) } DO_1OP(VCLZ, vclz) +DO_1OP (VCLS , vcls)
Signature · 1 line
2.20.1
Re: [PATCH 14/55] target/arm: Implement MVE VCLS
Quoted 9 lines · Peter Maydell
Implement the MVE VCLS insn.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 4 ++++ target/arm/mve.decode | 1 + target/arm/mve_helper.c | 7 +++++++ target/arm/translate-mve.c | 1 + 4 files changed, 13 insertions(+)
r~
PATCH 15/55 bitops.h: Provide hswap32(), hswap64(), wswap64() swapping operations
In reply to Peter MaydellCurrently the ARM SVE helper code defines locally some utility functions for swapping 16-bit halfwords within 32-bit or 64-bit values and for swapping 32-bit words within 64-bit values, parallel to the byte-swapping bswap16/32/64 functions.
We want these also for the ARM MVE code, and they're potentially generally useful for other targets, so move them to bitops.h. (We don't put them in bswap.h with the bswap* functions because they are implemented in terms of the rotate operations also defined in bitops.h, and including bitops.h from bswap.h seems better avoided.)
--- include/qemu/bitops.h | 29 +++++++++++++++++++++++++++++ target/arm/sve_helper.c | 20 -------------------- 2 files changed, 29 insertions(+), 20 deletions(-)
include/qemu/bitops.h +29 -0
@@ -291,6 +291,35 @@ static inline uint64_t ror64(uint64_t word, unsigned int shift)return (word >> shift) | (word << ((64 - shift) &63 )); } +/** +* hswap32 - swap 16-bit halfwords within a 32-bit value +* @h: value to swap +*/ +static inline uint32_t hswap32 (uint32_t h) +{ +return rol32 (h,16 ); +} + +/** +* hswap64 - swap 16-bit halfwords within a 64-bit value +* @h: value to swap +*/ +static inline uint64_t hswap64 (uint64_t h) +{ +uint64_t m =0x0000ffff0000ffffull ; + h =rol64 (h,32 ); +return ((h & m) <<16 ) | ((h >>16 ) & m); +} + +/** +* wswap64 - swap 32-bit words within a 64-bit value +* @h: value to swap +*/ +static inline uint64_t wswap64 (uint64_t h) +{ +return rol64 (h,32 ); +} +/** * extract32: * @value: the value to extract the bit field from
target/arm/sve_helper.c +0 -20
@@ -247,26 +247,6 @@ static inline uint64_t expand_pred_s(uint8_t byte)return word[byte &0x11 ]; } -/* Swap 16-bit words within a 32-bit word. */ -static inline uint32_t hswap32 (uint32_t h) -{ -return rol32 (h,16 ); -} - -/* Swap 16-bit words within a 64-bit word. */ -static inline uint64_t hswap64 (uint64_t h) -{ -uint64_t m =0x0000ffff0000ffffull ; - h =rol64 (h,32 ); -return ((h & m) <<16 ) | ((h >>16 ) & m); -} - -/* Swap 32-bit words within a 64-bit word. */ -static inline uint64_t wswap64 (uint64_t h) -{ -return rol64 (h,32 ); -} -#define LOGICAL_PPPP (NAME ,FUNC ) \ void HELPER(NAME)(void *vd, void *vn, void *vm, void *vg, uint32_t desc) \ { \
Signature · 1 line
2.20.1
Re: [PATCH 15/55] bitops.h: Provide hswap32(), hswap64(), wswap64() swapping operations
Quoted 12 lines · Peter Maydell
Currently the ARM SVE helper code defines locally some utility functions for swapping 16-bit halfwords within 32-bit or 64-bit values and for swapping 32-bit words within 64-bit values, parallel to the byte-swapping bswap16/32/64 functions.
We want these also for the ARM MVE code, and they're potentially generally useful for other targets, so move them to
bitops.h. (We don't put them inbswap.hwith the bswap* functions because they are implemented in terms of the rotate operations also defined inbitops.h, and includingbitops.hfrombswap.hseems better avoided.)
Quoted 5 lines
Signed-off-by Peter Maydell <[email protected]>--- include/qemu/bitops.h | 29 +++++++++++++++++++++++++++++ target/arm/sve_helper.c | 20 -------------------- 2 files changed, 29 insertions(+), 20 deletions(-)
Re: [PATCH 15/55] bitops.h: Provide hswap32(), hswap64(), wswap64() swapping operations
In reply to Peter MaydellQuoted 12 lines · Peter Maydell
Currently the ARM SVE helper code defines locally some utility functions for swapping 16-bit halfwords within 32-bit or 64-bit values and for swapping 32-bit words within 64-bit values, parallel to the byte-swapping bswap16/32/64 functions.
We want these also for the ARM MVE code, and they're potentially generally useful for other targets, so move them to
bitops.h. (We don't put them inbswap.hwith the bswap* functions because they are implemented in terms of the rotate operations also defined inbitops.h, and includingbitops.hfrombswap.hseems better avoided.)
Quoted 5 lines
Signed-off-by Peter Maydell<[email protected]>--- include/qemu/bitops.h | 29 +++++++++++++++++++++++++++++ target/arm/sve_helper.c | 20 -------------------- 2 files changed, 29 insertions(+), 20 deletions(-)
r~
PATCH 16/55 target/arm: Implement MVE VREV16, VREV32, VREV64
In reply to Peter MaydellImplement the MVE instructions VREV16, VREV32 and VREV64.
--- target/arm/helper-mve.h | 7 +++++++ target/arm/mve.decode | 4 ++++ target/arm/mve_helper.c | 13 +++++++++++++ target/arm/translate-mve.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+)
target/arm/helper-mve.h +7 -0
@@ -40,3 +40,10 @@ DEF_HELPER_FLAGS_3(mve_vclsw, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vclzb, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vclzh, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vclzw, TCG_CALL_NO_WG, void, env, ptr, ptr) + +DEF_HELPER_FLAGS_3(mve_vrev16b, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vrev32b, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vrev32h, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vrev64b, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vrev64h, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3 (mve_vrev64w,TCG_CALL_NO_WG , void, env, ptr, ptr)
target/arm/mve.decode +4 -0
@@ -70,3 +70,7 @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op VCLZ 1111 1111 1 . 11 .. 00 ... 0 0100 11 . 0 ... 0 @1op + +VREV16 1111 1111 1 . 11 .. 00 ... 0 0001 01 . 0 ... 0 @1op +VREV32 1111 1111 1 . 11 .. 00 ... 0 0000 11 . 0 ... 0 @1op +VREV64 1111 1111 1 . 11 .. 00 ... 0 0000 01 . 0 ... 0 @1op
target/arm/mve_helper.c +13 -0
@@ -223,6 +223,12 @@ static uint32_t mask_to_bytemask4(uint16_t mask)return masks[mask &0xf ]; } +static uint64_t mask_to_bytemask8 (uint16_t mask) +{ +return mask_to_bytemask4 (mask) | + ((uint64_t )mask_to_bytemask4 (mask >>4 ) <<32 ); +} +#define DO_1OP (OP ,ESIZE ,TYPE ,H ,FN ) \ void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ { \
@@ -251,3 +257,10 @@ DO_1OP(vclsw, 4, int32_t, H4, clrsb32) DO_1OP(vclzb, 1, uint8_t, H1, DO_CLZ_B) DO_1OP(vclzh, 2, uint16_t, H2, DO_CLZ_H) DO_1OP(vclzw, 4, uint32_t, H4, clz32) + +DO_1OP(vrev16b, 2, uint16_t, H2, bswap16) +DO_1OP(vrev32b, 4, uint32_t, H4, bswap32) +DO_1OP(vrev32h, 4, uint32_t, H4, hswap32) +DO_1OP(vrev64b, 8, uint64_t, , bswap64) +DO_1OP(vrev64h, 8, uint64_t, , hswap64) +DO_1OP(vrev64w, 8, uint64_t, , wswap64)
target/arm/translate-mve.c +33 -0
@@ -211,3 +211,36 @@ static bool do_1op(DisasContext *s, arg_1op *a, MVEGenOneOpFn fn) DO_1OP(VCLZ, vclz) DO_1OP(VCLS, vcls) + +static bool trans_VREV16 (DisasContext *s,arg_1op *a) +{ +MVEGenOneOpFn *fns[] = { + gen_helper_mve_vrev16b, +NULL , +NULL , +NULL , + }; +return do_1op (s, a, fns[a->size]); +} + +static bool trans_VREV32 (DisasContext *s,arg_1op *a) +{ +MVEGenOneOpFn *fns[] = { + gen_helper_mve_vrev32b, + gen_helper_mve_vrev32h, +NULL , +NULL , + }; +return do_1op (s, a, fns[a->size]); +} + +static bool trans_VREV64 (DisasContext *s,arg_1op *a) +{ +MVEGenOneOpFn *fns[] = { + gen_helper_mve_vrev64b, + gen_helper_mve_vrev64h, + gen_helper_mve_vrev64w, +NULL , + }; +return do_1op (s, a, fns[a->size]); +}
Signature · 1 line
2.20.1
Re: [PATCH 16/55] target/arm: Implement MVE VREV16, VREV32, VREV64
target/arm/mve_helper.c static uint32_t mask_to_bytemask4(uint16_t mask) · line 230
Quoted 5 lines · Peter Maydell
target/arm/mve_helper.c +5
-0+static uint64_t mask_to_bytemask8 (uint16_t mask) +{ +return mask_to_bytemask4 (mask) | + ((uint64_t )mask_to_bytemask4 (mask >>4 ) <<32 ); +}
Again, suggest to share the array from expand_pred_b.
target/arm/mve_helper.c DO_1OP(vclsw, 4, int32_t, H4, clrsb32) · line 266
Quoted 6 lines
target/arm/mve_helper.c +6
-0+DO_1OP(vrev16b, 2, uint16_t, H2, bswap16) +DO_1OP(vrev32b, 4, uint32_t, H4, bswap32) +DO_1OP(vrev32h, 4, uint32_t, H4, hswap32) +DO_1OP(vrev64b, 8, uint64_t, , bswap64) +DO_1OP(vrev64h, 8, uint64_t, , hswap64) +DO_1OP(vrev64w, 8, uint64_t, , wswap64)
I've started to wonder if we shouldn't add a no-op H8, just so we don't have the empty argument for checkpatch to complain about.
And in this particular case I suppose we could H##ESIZE, which would then negate my earlier suggestion for using sizeof.
Quoted 1 line
+ MVEGenOneOpFn *fns[] = {
static const, etc.
r~
PATCH 17/55 target/arm: Implement MVE VMVN (register)
In reply to Peter MaydellImplement the MVE VMVN(register) operation. Note that for predication this operation is byte-by-byte.
--- target/arm/helper-mve.h | 2 ++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 4 ++++ target/arm/translate-mve.c | 5 +++++ 4 files changed, 14 insertions(+)
target/arm/helper-mve.h +2 -0
@@ -47,3 +47,5 @@ DEF_HELPER_FLAGS_3(mve_vrev32h, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vrev64b, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vrev64h, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vrev64w, TCG_CALL_NO_WG, void, env, ptr, ptr) + +DEF_HELPER_FLAGS_3 (mve_vmvn,TCG_CALL_NO_WG , void, env, ptr, ptr)
target/arm/mve.decode +3 -0
@@ -30,6 +30,7 @@ @vldst_wn ... u:1 ... . . . . l:1 . rn:3 qd:3 . ... .. imm:7 &vldr_vstr @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm +@1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 # Vector loads and stores
@@ -74,3 +75,5 @@ VCLZ 1111 1111 1 . 11 .. 00 ... 0 0100 11 . 0 ... 0 @1op VREV16 1111 1111 1 . 11 .. 00 ... 0 0001 01 . 0 ... 0 @1op VREV32 1111 1111 1 . 11 .. 00 ... 0 0000 11 . 0 ... 0 @1op VREV64 1111 1111 1 . 11 .. 00 ... 0 0000 01 . 0 ... 0 @1op + +VMVN 1111 1111 1 . 11 00 00 ... 0 0101 11 . 0 ... 0 @1op_nosz
target/arm/mve_helper.c +4 -0
@@ -264,3 +264,7 @@ DO_1OP(vrev32h, 4, uint32_t, H4, hswap32) DO_1OP(vrev64b, 8, uint64_t, , bswap64) DO_1OP(vrev64h, 8, uint64_t, , hswap64) DO_1OP(vrev64w, 8, uint64_t, , wswap64) + +#define DO_NOT (N ) (~(N)) + +DO_1OP (vmvn,1 , uint8_t,H1 ,DO_NOT )
target/arm/translate-mve.c +5 -0
@@ -244,3 +244,8 @@ static bool trans_VREV64(DisasContext *s, arg_1op *a) };return do_1op (s, a, fns[a->size]); } + +static bool trans_VMVN (DisasContext *s,arg_1op *a) +{ +return do_1op (s, a, gen_helper_mve_vmvn); +}
Signature · 1 line
2.20.1
Re: [PATCH 17/55] target/arm: Implement MVE VMVN (register)
Quoted 1 line · Peter Maydell
+DO_1OP(vmvn, 1,
uint8_t, H1,DO_NOT)
This is a logical operation; you might as well perform in uint64_t.
Otherwise,
r~
PATCH 18/55 target/arm: Implement MVE VABS
In reply to Peter MaydellImplement the MVE VABS functions (both integer and floating point).
--- target/arm/helper-mve.h | 6 ++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 10 ++++++++++ target/arm/translate-mve.c | 15 +++++++++++++++ 4 files changed, 34 insertions(+)
target/arm/helper-mve.h +6 -0
@@ -49,3 +49,9 @@ DEF_HELPER_FLAGS_3(mve_vrev64h, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vrev64w, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vmvn, TCG_CALL_NO_WG, void, env, ptr, ptr) + +DEF_HELPER_FLAGS_3(mve_vabsb, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vabsh, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vabsw, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vfabsh, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3 (mve_vfabss,TCG_CALL_NO_WG , void, env, ptr, ptr)
target/arm/mve.decode +3 -0
@@ -77,3 +77,6 @@ VREV32 1111 1111 1 . 11 .. 00 ... 0 0000 11 . 0 ... 0 @1op VREV64 1111 1111 1 . 11 .. 00 ... 0 0000 01 . 0 ... 0 @1op VMVN 1111 1111 1 . 11 00 00 ... 0 0101 11 . 0 ... 0 @1op_nosz + +VABS 1111 1111 1 . 11 .. 01 ... 0 0011 01 . 0 ... 0 @1op +VABS_fp 1111 1111 1 . 11 .. 01 ... 0 0111 01 . 0 ... 0 @1op
target/arm/mve_helper.c +10 -0
@@ -268,3 +268,13 @@ DO_1OP(vrev64w, 8, uint64_t, , wswap64)#define DO_NOT (N ) (~(N)) DO_1OP(vmvn, 1, uint8_t, H1, DO_NOT) + +#define DO_ABS (N ) ((N) < 0 ? -(N) : (N)) +#define DO_FABS (N ) (N & ((__typeof(N))-1 >> 1)) + +DO_1OP(vabsb, 1, int8_t, H1, DO_ABS) +DO_1OP(vabsh, 2, int16_t, H2, DO_ABS) +DO_1OP(vabsw, 4, int32_t, H4, DO_ABS) + +DO_1OP(vfabsh, 2, uint16_t, H2, DO_FABS) +DO_1OP (vfabss,4 , uint32_t,H4 ,DO_FABS )
target/arm/translate-mve.c +15 -0
@@ -211,6 +211,7 @@ static bool do_1op(DisasContext *s, arg_1op *a, MVEGenOneOpFn fn) DO_1OP(VCLZ, vclz) DO_1OP(VCLS, vcls) +DO_1OP(VABS, vabs)static bool trans_VREV16 (DisasContext *s,arg_1op *a) {
@@ -249,3 +250,17 @@ static bool trans_VMVN(DisasContext *s, arg_1op *a) {return do_1op (s, a, gen_helper_mve_vmvn); } + +static bool trans_VABS_fp (DisasContext *s,arg_1op *a) +{ +MVEGenOneOpFn *fns[] = { +NULL , + gen_helper_mve_vfabsh, + gen_helper_mve_vfabss, +NULL , + }; +if (!dc_isar_feature (aa32_mve_fp, s)) { +return false; + } +return do_1op (s, a, fns[a->size]); +}
Signature · 1 line
2.20.1
Re: [PATCH 18/55] target/arm: Implement MVE VABS
target/arm/mve_helper.c DO_1OP(vrev64w, 8, uint64_t, , wswap64) · line 280
Quoted 2 lines · Peter Maydell
target/arm/mve_helper.c +2
-0+DO_1OP(vfabsh, 2, uint16_t, H2, DO_FABS) +DO_1OP (vfabss,4 , uint32_t,H4 ,DO_FABS )
Could just as plausibly be done on uint64_t.
#define DO_FABSH(N) ((N) & dup_const(MO_16, 0x7fff)) #define DO_FABSS(N) ((N) & dup_const(MO_32, 0x7fffffff))
Quoted 1 line
+ MVEGenOneOpFn *fns[] = {
static const
r~
PATCH 19/55 target/arm: Implement MVE VNEG
In reply to Peter MaydellImplement the MVE VNEG insn (both integer and floating point forms).
--- target/arm/helper-mve.h | 6 ++++++ target/arm/mve.decode | 2 ++ target/arm/mve_helper.c | 10 ++++++++++ target/arm/translate-mve.c | 15 +++++++++++++++ 4 files changed, 33 insertions(+)
target/arm/helper-mve.h +6 -0
@@ -55,3 +55,9 @@ DEF_HELPER_FLAGS_3(mve_vabsh, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vabsw, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vfabsh, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vfabss, TCG_CALL_NO_WG, void, env, ptr, ptr) + +DEF_HELPER_FLAGS_3(mve_vnegb, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3(mve_vfnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) +DEF_HELPER_FLAGS_3 (mve_vfnegs,TCG_CALL_NO_WG , void, env, ptr, ptr)
target/arm/mve.decode +2 -0
@@ -80,3 +80,5 @@ VMVN 1111 1111 1 . 11 00 00 ... 0 0101 11 . 0 ... 0 @1op_nosz VABS 1111 1111 1 . 11 .. 01 ... 0 0011 01 . 0 ... 0 @1op VABS_fp 1111 1111 1 . 11 .. 01 ... 0 0111 01 . 0 ... 0 @1op +VNEG 1111 1111 1 . 11 .. 01 ... 0 0011 11 . 0 ... 0 @1op +VNEG_fp 1111 1111 1 . 11 .. 01 ... 0 0111 11 . 0 ... 0 @1op
target/arm/mve_helper.c +10 -0
@@ -278,3 +278,13 @@ DO_1OP(vabsw, 4, int32_t, H4, DO_ABS) DO_1OP(vfabsh, 2, uint16_t, H2, DO_FABS) DO_1OP(vfabss, 4, uint32_t, H4, DO_FABS) + +#define DO_NEG (N ) (-(N)) +#define DO_FNEG (N ) ((N) ^ ~((__typeof(N))-1 >> 1)) + +DO_1OP(vnegb, 1, int8_t, H1, DO_NEG) +DO_1OP(vnegh, 2, int16_t, H2, DO_NEG) +DO_1OP(vnegw, 4, int32_t, H4, DO_NEG) + +DO_1OP(vfnegh, 2, uint16_t, H2, DO_FNEG) +DO_1OP (vfnegs,4 , uint32_t,H4 ,DO_FNEG )
target/arm/translate-mve.c +15 -0
@@ -212,6 +212,7 @@ static bool do_1op(DisasContext *s, arg_1op *a, MVEGenOneOpFn fn) DO_1OP(VCLZ, vclz) DO_1OP(VCLS, vcls) DO_1OP(VABS, vabs) +DO_1OP(VNEG, vneg)static bool trans_VREV16 (DisasContext *s,arg_1op *a) {
@@ -264,3 +265,17 @@ static bool trans_VABS_fp(DisasContext *s, arg_1op *a) }return do_1op (s, a, fns[a->size]); } + +static bool trans_VNEG_fp (DisasContext *s,arg_1op *a) +{ +MVEGenOneOpFn *fns[] = { +NULL , + gen_helper_mve_vfnegh, + gen_helper_mve_vfnegs, +NULL , + }; +if (!dc_isar_feature (aa32_mve_fp, s)) { +return false; + } +return do_1op (s, a, fns[a->size]); +}
Signature · 1 line
2.20.1
Re: [PATCH 19/55] target/arm: Implement MVE VNEG
target/arm/mve_helper.c DO_1OP(vabsw, 4, int32_t, H4, DO_ABS) · line 290
Quoted 9 lines · Peter Maydell
target/arm/mve_helper.c +9
-0+#define DO_NEG (N ) (-(N)) +#define DO_FNEG (N ) ((N) ^ ~((__typeof(N))-1 >> 1)) + +DO_1OP(vnegb, 1, int8_t, H1, DO_NEG) +DO_1OP(vnegh, 2, int16_t, H2, DO_NEG) +DO_1OP(vnegw, 4, int32_t, H4, DO_NEG) + +DO_1OP(vfnegh, 2, uint16_t, H2, DO_FNEG) +DO_1OP (vfnegs,4 , uint32_t,H4 ,DO_FNEG )
Similar comments to abs. Otherwise,
r~
PATCH 20/55 target/arm: Implement MVE VDUP
In reply to Peter MaydellImplement the MVE VDUP insn, which duplicates a value from a general-purpose register into every lane of a vector register (subject to predication).
--- target/arm/helper-mve.h | 4 ++++ target/arm/mve.decode | 10 +++++++++ target/arm/mve_helper.c | 18 ++++++++++++++++ target/arm/translate-mve.c | 43 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+)
target/arm/helper-mve.h +4 -0
@@ -33,6 +33,10 @@ DEF_HELPER_FLAGS_3(mve_vstrb_h, TCG_CALL_NO_WG, void, env, ptr, i32) DEF_HELPER_FLAGS_3(mve_vstrb_w, TCG_CALL_NO_WG, void, env, ptr, i32) DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vdupb, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vduph, TCG_CALL_NO_WG, void, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vdupw, TCG_CALL_NO_WG, void, env, ptr, i32) + DEF_HELPER_FLAGS_3(mve_vclsb, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vclsh, TCG_CALL_NO_WG, void, env, ptr, ptr)DEF_HELPER_FLAGS_3 (mve_vclsw,TCG_CALL_NO_WG , void, env, ptr, ptr)
target/arm/mve.decode +10 -0
@@ -21,6 +21,7 @@ %qd 22:1 13:3 %qm 5:1 1:3 +%qn 7:1 17:3 &vldr_vstr rn qd imm p a w size l u &1op qd qm size
@@ -82,3 +83,12 @@ VABS 1111 1111 1 . 11 .. 01 ... 0 0011 01 . 0 ... 0 @1op VABS_fp 1111 1111 1 . 11 .. 01 ... 0 0111 01 . 0 ... 0 @1op VNEG 1111 1111 1 . 11 .. 01 ... 0 0011 11 . 0 ... 0 @1op VNEG_fp 1111 1111 1 . 11 .. 01 ... 0 0111 11 . 0 ... 0 @1op + +&vdup qd rt size +# Qd is in the fields usually named Qn +@vdup .... .... . . .. ... . rt:4 .... . . . . .... qd=%qn &vdup + +# B and E bits encode size, which we decode here to the usual size values +VDUP 1110 1110 1 1 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=0 +VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 1 1 0000 @vdup size=1 +VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2
target/arm/mve_helper.c +18 -0
@@ -229,6 +229,24 @@ static uint64_t mask_to_bytemask8(uint16_t mask) ((uint64_t )mask_to_bytemask4 (mask >>4 ) <<32 ); } +#define DO_VDUP (OP ,ESIZE ,TYPE ,H ) \ + void HELPER(mve_##OP)(CPUARMState *env, void *vd, uint32_t val) \ + { \ + TYPE *d = vd; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + uint64_t bytemask = mask_to_bytemask##ESIZE(mask); \ + d[H(e)] &= ~bytemask; \ + d[H(e)] |= (val & bytemask); \ + } \ + mve_advance_vpt(env); \ + } + +DO_VDUP(vdupb, 1, uint8_t, H1) +DO_VDUP(vduph, 2, uint16_t, H2) +DO_VDUP(vdupw, 4, uint32_t, H4) +#define DO_1OP (OP ,ESIZE ,TYPE ,H ,FN ) \ void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ { \
target/arm/translate-mve.c +43 -0
49 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 20/55] target/arm: Implement MVE VDUP
Quoted 7 lines · Peter Maydell
target/arm/mve_helper.c +7
-0+#define DO_VDUP (OP ,ESIZE ,TYPE ,H ) \ + void HELPER(mve_##OP)(CPUARMState *env, void *vd, uint32_t val) \ + { \ + TYPE *d = vd; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \
target/arm/mve_helper.c static uint64_t mask_to_bytemask8(uint16_t mask) · line 248
Quoted 10 lines
target/arm/mve_helper.c +10
-0+ uint64_t bytemask = mask_to_bytemask##ESIZE(mask); \ + d[H(e)] &= ~bytemask; \ + d[H(e)] |= (val & bytemask); \ + } \ + mve_advance_vpt(env); \ + } + +DO_VDUP(vdupb, 1, uint8_t, H1) +DO_VDUP(vduph, 2, uint16_t, H2) +DO_VDUP (vdupw,4 , uint32_t,H4 )
Hmm. I think the masking should be done at either uint32_t or uint64_t. Doing it byte-by-byte is wasteful.
Whether you want to do the replication in tcg (I can export gen_dup_i32 from tcg-op-gvec.c) and have one helper, or do the replication here e.g.
static void do_vdup(CPUARMState *env, void *vd, uint64_t val); void helper(mve_vdupb)(CPUARMState *env, void *vd, uint32_t val)
{
do_vdup(env, vd, dup_const(MO_8, val));
}r~
Re: [PATCH 20/55] target/arm: Implement MVE VDUP
Quoted 14 lines · Richard Henderson
Quoted 12 lines · Peter Maydell
target/arm/mve_helper.c +12
-0+#define DO_VDUP (OP ,ESIZE ,TYPE ,H ) \ + void HELPER(mve_##OP)(CPUARMState *env, void *vd, uint32_t val) \ + { \ + TYPE *d = vd; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + uint64_t bytemask = mask_to_bytemask##ESIZE(mask); \ + d[H(e)] &= ~bytemask; \ + d[H(e)] |= (val & bytemask); \ + } \ + mve_advance_vpt(env); \
Quoted 8 lines
target/arm/mve_helper.c static uint64_t mask_to_bytemask8(uint16_t mask) · line 248
Quoted 5 lines
target/arm/mve_helper.c +5
-0+ } + +DO_VDUP(vdupb, 1, uint8_t, H1) +DO_VDUP(vduph, 2, uint16_t, H2) +DO_VDUP (vdupw,4 , uint32_t,H4 )Hmm. I think the masking should be done at either
uint32_toruint64_t. Doing it byte-by-byte is wasteful.
Mmm. I think some of this structure is holdover from an initial misinterpretation
of the spec that all these ops looked at the predicate bit for the LS byte of the element to see if the entire element was acted upon, in which case you do need to work element-by-element with the right size. (This is actually true for some operations, but mostly the predicate bits do bytewise masking and can give you a partial chunk of a result element, as here.)
-- PMM
Re: [PATCH 20/55] target/arm: Implement MVE VDUP
Quoted 7 lines · Peter Maydell
Mmm. I think some of this structure is holdover from an initial misinterpretation
of the spec that all these ops looked at the predicate bit for the LS byte of the element to see if the entire element was acted upon, in which case you do need to work element-by-element with the right size. (This is actually true for some operations, but mostly the predicate bits do bytewise masking and can give you a partial chunk of a result element, as here.)
Even if the operation did look at specific predicate bits, that simply puts it in line with SVE, which is quite happy with expand_pred_[bhsd].
r~
PATCH 21/55 target/arm: Implement MVE VAND, VBIC, VORR, VORN, VEOR
In reply to Peter MaydellImplement the MVE vector logical operations operating on two registers.
--- target/arm/helper-mve.h | 6 ++++++ target/arm/mve.decode | 9 +++++++++ target/arm/mve_helper.c | 28 ++++++++++++++++++++++++++ target/arm/translate-mve.c | 41 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+)
target/arm/helper-mve.h +6 -0
@@ -65,3 +65,9 @@ DEF_HELPER_FLAGS_3(mve_vnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vfnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) DEF_HELPER_FLAGS_3(mve_vfnegs, TCG_CALL_NO_WG, void, env, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vand, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vbic, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vorr, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vorn, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4 (mve_veor,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr)
target/arm/mve.decode +9 -0
@@ -25,6 +25,7 @@ &vldr_vstr rn qd imm p a w size l u &1op qd qm size +&2op qd qm qn size @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 # Note that both Rn and Qd are 3 bits only (no D bit)
@@ -32,6 +33,7 @@ @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 +@2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 # Vector loads and stores
@@ -68,6 +70,13 @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ size=2 p=1 +# Vector 2-op +VAND 1110 1111 0 . 00 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz +VBIC 1110 1111 0 . 01 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz +VORR 1110 1111 0 . 10 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz +VORN 1110 1111 0 . 11 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz +VEOR 1111 1111 0 . 00 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +28 -0
@@ -306,3 +306,31 @@ DO_1OP(vnegw, 4, int32_t, H4, DO_NEG) DO_1OP(vfnegh, 2, uint16_t, H2, DO_FNEG) DO_1OP(vfnegs, 4, uint32_t, H4, DO_FNEG) + +#define DO_2OP (OP ,ESIZE ,TYPE ,H ,FN ) \ + void HELPER(glue(mve_, OP))(CPUARMState *env, \ + void *vd, void *vn, void *vm) \ + { \ + TYPE *d = vd, *n = vn, *m = vm; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + TYPE r = FN(n[H(e)], m[H(e)]); \ + uint64_t bytemask = mask_to_bytemask##ESIZE(mask); \ + d[H(e)] &= ~bytemask; \ + d[H(e)] |= (r & bytemask); \ + } \ + mve_advance_vpt(env); \ + } + +#define DO_AND (N ,M ) ((N) & (M)) +#define DO_BIC (N ,M ) ((N) & ~(M)) +#define DO_ORR (N ,M ) ((N) | (M)) +#define DO_ORN (N ,M ) ((N) | ~(M)) +#define DO_EOR (N ,M ) ((N) ^ (M)) + +DO_2OP(vand, 1, uint8_t, H1, DO_AND) +DO_2OP(vbic, 1, uint8_t, H1, DO_BIC) +DO_2OP(vorr, 1, uint8_t, H1, DO_ORR) +DO_2OP(vorn, 1, uint8_t, H1, DO_ORN) +DO_2OP (veor,1 , uint8_t,H1 ,DO_EOR )
target/arm/translate-mve.c +41 -0
50 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 21/55] target/arm: Implement MVE VAND, VBIC, VORR, VORN, VEOR
target/arm/mve_helper.c DO_1OP(vnegw, 4, int32_t, H4, DO_NEG) · line 336
Quoted 5 lines · Peter Maydell
target/arm/mve_helper.c +5
-0+DO_2OP(vand, 1, uint8_t, H1, DO_AND) +DO_2OP(vbic, 1, uint8_t, H1, DO_BIC) +DO_2OP(vorr, 1, uint8_t, H1, DO_ORR) +DO_2OP(vorn, 1, uint8_t, H1, DO_ORN) +DO_2OP (veor,1 , uint8_t,H1 ,DO_EOR )
Again, logicals should use uint64_t.
Otherwise,
r~
PATCH 22/55 target/arm: Implement MVE VADD, VSUB, VMUL
In reply to Peter MaydellImplement the MVE VADD, VSUB and VMUL insns.
--- target/arm/helper-mve.h | 12 ++++++++++++ target/arm/mve.decode | 5 +++++ target/arm/mve_helper.c | 14 ++++++++++++++ target/arm/translate-mve.c | 16 ++++++++++++++++ 4 files changed, 47 insertions(+)
target/arm/helper-mve.h +12 -0
@@ -71,3 +71,15 @@ DEF_HELPER_FLAGS_4(mve_vbic, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vorr, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vorn, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vaddb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vaddw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vsubb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vsubh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vsubw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vmulb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmulh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4 (mve_vmulw,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr)
target/arm/mve.decode +5 -0
@@ -33,6 +33,7 @@ @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 +@2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 # Vector loads and stores
@@ -77,6 +78,10 @@ VORR 1110 1111 0 . 10 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz VORN 1110 1111 0 . 11 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz VEOR 1111 1111 0 . 00 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz +VADD 1110 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op +VSUB 1111 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op +VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +14 -0
@@ -323,6 +323,12 @@ DO_1OP(vfnegs, 4, uint32_t, H4, DO_FNEG)mve_advance_vpt (env); \ } +/* provide unsigned 2-op helpers for all sizes */ +#define DO_2OP_U (OP ,FN ) \ + DO_2OP(OP##b, 1, uint8_t, H1, FN) \ + DO_2OP(OP##h, 2, uint16_t, H2, FN) \ + DO_2OP(OP##w, 4, uint32_t, H4, FN) +#define DO_AND (N ,M ) ((N) & (M))#define DO_BIC (N ,M ) ((N) & ~(M))#define DO_ORR (N ,M ) ((N) | (M))
@@ -334,3 +340,11 @@ DO_2OP(vbic, 1, uint8_t, H1, DO_BIC) DO_2OP(vorr, 1, uint8_t, H1, DO_ORR) DO_2OP(vorn, 1, uint8_t, H1, DO_ORN) DO_2OP(veor, 1, uint8_t, H1, DO_EOR) + +#define DO_ADD (N ,M ) ((N) + (M)) +#define DO_SUB (N ,M ) ((N) - (M)) +#define DO_MUL (N ,M ) ((N) * (M)) + +DO_2OP_U(vadd, DO_ADD) +DO_2OP_U(vsub, DO_SUB) +DO_2OP_U (vmul,DO_MUL )
target/arm/translate-mve.c +16 -0
@@ -363,3 +363,19 @@ DO_LOGIC(VBIC, gen_helper_mve_vbic) DO_LOGIC(VORR, gen_helper_mve_vorr) DO_LOGIC(VORN, gen_helper_mve_vorn) DO_LOGIC(VEOR, gen_helper_mve_veor) + +#define DO_2OP (INSN ,FN ) \ + static bool trans_##INSN(DisasContext *s, arg_2op *a) \ + { \ + MVEGenTwoOpFn *fns[] = { \ + gen_helper_mve_##FN##b, \ + gen_helper_mve_##FN##h, \ + gen_helper_mve_##FN##w, \ + NULL, \ + }; \ + return do_2op(s, a, fns[a->size]); \ + } + +DO_2OP(VADD, vadd) +DO_2OP(VSUB, vsub) +DO_2OP (VMUL , vmul)
Signature · 1 line
2.20.1
Re: [PATCH 22/55] target/arm: Implement MVE VADD, VSUB, VMUL
target/arm/translate-mve.c DO_LOGIC(VBIC, gen_helper_mve_vbic) · line 370
Quoted 4 lines · Peter Maydell
target/arm/translate-mve.c +4
-0+#define DO_2OP (INSN ,FN ) \ + static bool trans_##INSN(DisasContext *s, arg_2op *a) \ + { \ + MVEGenTwoOpFn *fns[] = { \
static const, otherwise,
r~
PATCH 23/55 target/arm: Implement MVE VMULH
In reply to Peter MaydellImplement the MVE VMULH insn, which performs a vector multiply and returns the high half of the result.
--- target/arm/helper-mve.h | 7 +++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 26 ++++++++++++++++++++++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 38 insertions(+)
target/arm/helper-mve.h +7 -0
@@ -83,3 +83,10 @@ DEF_HELPER_FLAGS_4(mve_vsubw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vmulb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vmulh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vmulw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vmulhsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmulhsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmulhsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmulhub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmulhuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4 (mve_vmulhuw,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr)
target/arm/mve.decode +3 -0
@@ -82,6 +82,9 @@ VADD 1110 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op VSUB 1111 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op +VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op +VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +26 -0
@@ -348,3 +348,29 @@ DO_2OP(veor, 1, uint8_t, H1, DO_EOR) DO_2OP_U(vadd, DO_ADD) DO_2OP_U(vsub, DO_SUB)DO_2OP_U (vmul,DO_MUL ) + +/* +* Because the computation type is at least twice as large as required, +* these work for both signed and unsigned source types. + */ +static inline uint8_t do_mulh_b (int32_t n,int32_t m) +{ +return (n * m) >>8 ; +} + +static inline uint16_t do_mulh_h (int32_t n,int32_t m) +{ +return (n * m) >>16 ; +} + +static inline uint32_t do_mulh_w (int64_t n,int64_t m) +{ +return (n * m) >>32 ; +} + +DO_2OP(vmulhsb, 1, int8_t, H1, do_mulh_b) +DO_2OP(vmulhsh, 2, int16_t, H2, do_mulh_h) +DO_2OP(vmulhsw, 4, int32_t, H4, do_mulh_w) +DO_2OP(vmulhub, 1, uint8_t, H1, do_mulh_b) +DO_2OP(vmulhuh, 2, uint16_t, H2, do_mulh_h) +DO_2OP (vmulhuw,4 , uint32_t,H4 , do_mulh_w)
target/arm/translate-mve.c +2 -0
@@ -379,3 +379,5 @@ DO_LOGIC(VEOR, gen_helper_mve_veor) DO_2OP(VADD, vadd) DO_2OP(VSUB, vsub) DO_2OP(VMUL, vmul) +DO_2OP(VMULH_S, vmulhs) +DO_2OP (VMULH_U , vmulhu)
Signature · 1 line
2.20.1
Re: [PATCH 23/55] target/arm: Implement MVE VMULH
Quoted 10 lines · Peter Maydell
Implement the MVE VMULH insn, which performs a vector multiply and returns the high half of the result.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 7 +++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 26 ++++++++++++++++++++++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 38 insertions(+)
r~
PATCH 24/55 target/arm: Implement MVE VRMULH
In reply to Peter MaydellImplement the MVE VRMULH insn, which performs a rounding multiply and then returns the high half.
--- target/arm/helper-mve.h | 7 +++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 22 ++++++++++++++++++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 34 insertions(+)
target/arm/helper-mve.h +7 -0
@@ -90,3 +90,10 @@ DEF_HELPER_FLAGS_4(mve_vmulhsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vmulhub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vmulhuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vmulhuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vrmulhsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrmulhsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrmulhsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrmulhub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrmulhuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4 (mve_vrmulhuw,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr)
target/arm/mve.decode +3 -0
@@ -85,6 +85,9 @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op +VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op +VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +22 -0
@@ -368,9 +368,31 @@ static inline uint32_t do_mulh_w(int64_t n, int64_t m)return (n * m) >>32 ; } +static inline uint8_t do_rmulh_b (int32_t n,int32_t m) +{ +return (n * m + (1U <<7 )) >>8 ; +} + +static inline uint16_t do_rmulh_h (int32_t n,int32_t m) +{ +return (n * m + (1U <<15 )) >>16 ; +} + +static inline uint32_t do_rmulh_w (int64_t n,int64_t m) +{ +return (n * m + (1U <<31 )) >>32 ; +} + DO_2OP(vmulhsb, 1, int8_t, H1, do_mulh_b) DO_2OP(vmulhsh, 2, int16_t, H2, do_mulh_h) DO_2OP(vmulhsw, 4, int32_t, H4, do_mulh_w) DO_2OP(vmulhub, 1, uint8_t, H1, do_mulh_b) DO_2OP(vmulhuh, 2, uint16_t, H2, do_mulh_h) DO_2OP(vmulhuw, 4, uint32_t, H4, do_mulh_w) + +DO_2OP(vrmulhsb, 1, int8_t, H1, do_rmulh_b) +DO_2OP(vrmulhsh, 2, int16_t, H2, do_rmulh_h) +DO_2OP(vrmulhsw, 4, int32_t, H4, do_rmulh_w) +DO_2OP(vrmulhub, 1, uint8_t, H1, do_rmulh_b) +DO_2OP(vrmulhuh, 2, uint16_t, H2, do_rmulh_h) +DO_2OP (vrmulhuw,4 , uint32_t,H4 , do_rmulh_w)
target/arm/translate-mve.c +2 -0
@@ -381,3 +381,5 @@ DO_2OP(VSUB, vsub) DO_2OP(VMUL, vmul) DO_2OP(VMULH_S, vmulhs) DO_2OP(VMULH_U, vmulhu) +DO_2OP(VRMULH_S, vrmulhs) +DO_2OP (VRMULH_U , vrmulhu)
Signature · 1 line
2.20.1
Re: [PATCH 24/55] target/arm: Implement MVE VRMULH
Quoted 10 lines · Peter Maydell
Implement the MVE VRMULH insn, which performs a rounding multiply and then returns the high half.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 7 +++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 22 ++++++++++++++++++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 34 insertions(+)
r~
PATCH 25/55 target/arm: Implement MVE VMAX, VMIN
In reply to Peter MaydellImplement the MVE VMAX and VMIN insns.
--- target/arm/helper-mve.h | 14 ++++++++++++++ target/arm/mve.decode | 5 +++++ target/arm/mve_helper.c | 14 ++++++++++++++ target/arm/translate-mve.c | 4 ++++ 4 files changed, 37 insertions(+)
target/arm/helper-mve.h +14 -0
@@ -97,3 +97,17 @@ DEF_HELPER_FLAGS_4(mve_vrmulhsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vrmulhub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vrmulhuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vrmulhuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vmaxsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmaxsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmaxsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmaxub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmaxuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmaxuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vminsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vminsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vminsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vminub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vminuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4 (mve_vminuw,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr)
target/arm/mve.decode +5 -0
@@ -88,6 +88,11 @@ VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op +VMAX_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op +VMAX_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op +VMIN_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 1 ... 0 @2op +VMIN_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 1 ... 0 @2op + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +14 -0
@@ -329,6 +329,12 @@ DO_1OP(vfnegs, 4, uint32_t, H4, DO_FNEG) DO_2OP(OP##h, 2, uint16_t, H2, FN) \ DO_2OP(OP##w, 4, uint32_t, H4, FN) +/* provide signed 2-op helpers for all sizes */ +#define DO_2OP_S (OP ,FN ) \ + DO_2OP(OP##b, 1, int8_t, H1, FN) \ + DO_2OP(OP##h, 2, int16_t, H2, FN) \ + DO_2OP(OP##w, 4, int32_t, H4, FN) +#define DO_AND (N ,M ) ((N) & (M))#define DO_BIC (N ,M ) ((N) & ~(M))#define DO_ORR (N ,M ) ((N) | (M))
@@ -396,3 +402,11 @@ DO_2OP(vrmulhsw, 4, int32_t, H4, do_rmulh_w) DO_2OP(vrmulhub, 1, uint8_t, H1, do_rmulh_b) DO_2OP(vrmulhuh, 2, uint16_t, H2, do_rmulh_h) DO_2OP(vrmulhuw, 4, uint32_t, H4, do_rmulh_w) + +#define DO_MAX (N ,M ) ((N) >= (M) ? (N) : (M)) +#define DO_MIN (N ,M ) ((N) >= (M) ? (M) : (N)) + +DO_2OP_S(vmaxs, DO_MAX) +DO_2OP_U(vmaxu, DO_MAX) +DO_2OP_S(vmins, DO_MIN) +DO_2OP_U (vminu,DO_MIN )
target/arm/translate-mve.c +4 -0
@@ -383,3 +383,7 @@ DO_2OP(VMULH_S, vmulhs) DO_2OP(VMULH_U, vmulhu) DO_2OP(VRMULH_S, vrmulhs) DO_2OP(VRMULH_U, vrmulhu) +DO_2OP(VMAX_S, vmaxs) +DO_2OP(VMAX_U, vmaxu) +DO_2OP(VMIN_S, vmins) +DO_2OP (VMIN_U , vminu)
Signature · 1 line
2.20.1
Re: [PATCH 25/55] target/arm: Implement MVE VMAX, VMIN
Quoted 9 lines · Peter Maydell
Implement the MVE VMAX and VMIN insns.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 14 ++++++++++++++ target/arm/mve.decode | 5 +++++ target/arm/mve_helper.c | 14 ++++++++++++++ target/arm/translate-mve.c | 4 ++++ 4 files changed, 37 insertions(+)
r~
PATCH 26/55 target/arm: Implement MVE VABD
In reply to Peter MaydellImplement the MVE VABD insn.
--- target/arm/helper-mve.h | 7 +++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 5 +++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 17 insertions(+)
target/arm/helper-mve.h +7 -0
@@ -111,3 +111,10 @@ DEF_HELPER_FLAGS_4(mve_vminsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vminub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vminuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vminuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vabdsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vabdsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vabdsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vabdub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vabduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4 (mve_vabduw,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr)
target/arm/mve.decode +3 -0
@@ -93,6 +93,9 @@ VMAX_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op VMIN_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 1 ... 0 @2op VMIN_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 1 ... 0 @2op +VABD_S 111 0 1111 0 . .. ... 0 ... 0 0111 . 1 . 0 ... 0 @2op +VABD_U 111 1 1111 0 . .. ... 0 ... 0 0111 . 1 . 0 ... 0 @2op + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +5 -0
@@ -410,3 +410,8 @@ DO_2OP_S(vmaxs, DO_MAX) DO_2OP_U(vmaxu, DO_MAX) DO_2OP_S(vmins, DO_MIN) DO_2OP_U(vminu, DO_MIN) + +#define DO_ABD (N ,M ) ((N) >= (M) ? (N) - (M) : (M) - (N)) + +DO_2OP_S(vabds, DO_ABD) +DO_2OP_U (vabdu,DO_ABD )
target/arm/translate-mve.c +2 -0
@@ -387,3 +387,5 @@ DO_2OP(VMAX_S, vmaxs) DO_2OP(VMAX_U, vmaxu) DO_2OP(VMIN_S, vmins) DO_2OP(VMIN_U, vminu) +DO_2OP(VABD_S, vabds) +DO_2OP (VABD_U , vabdu)
Signature · 1 line
2.20.1
Re: [PATCH 26/55] target/arm: Implement MVE VABD
Quoted 9 lines · Peter Maydell
Implement the MVE VABD insn.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 7 +++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 5 +++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 17 insertions(+)
r~
PATCH 27/55 target/arm: Implement MVE VHADD, VHSUB
In reply to Peter MaydellImplement MVE VHADD and VHSUB insns, which perform an addition or subtraction and then halve the result.
--- target/arm/helper-mve.h | 14 ++++++++++++++ target/arm/mve.decode | 5 +++++ target/arm/mve_helper.c | 25 +++++++++++++++++++++++++ target/arm/translate-mve.c | 4 ++++ 4 files changed, 48 insertions(+)
target/arm/helper-mve.h +14 -0
@@ -118,3 +118,17 @@ DEF_HELPER_FLAGS_4(mve_vabdsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vabdub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vabduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vabduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vhaddsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhaddsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhaddsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhaddub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhadduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhadduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vhsubsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhsubsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhsubsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhsubub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhsubuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4 (mve_vhsubuw,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr)
target/arm/mve.decode +5 -0
@@ -96,6 +96,11 @@ VMIN_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 1 ... 0 @2op VABD_S 111 0 1111 0 . .. ... 0 ... 0 0111 . 1 . 0 ... 0 @2op VABD_U 111 1 1111 0 . .. ... 0 ... 0 0111 . 1 . 0 ... 0 @2op +VHADD_S 111 0 1111 0 . .. ... 0 ... 0 0000 . 1 . 0 ... 0 @2op +VHADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 0 ... 0 @2op +VHSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op +VHSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +25 -0
@@ -415,3 +415,28 @@ DO_2OP_U(vminu, DO_MIN) DO_2OP_S(vabds, DO_ABD) DO_2OP_U(vabdu, DO_ABD) + +static inline uint32_t do_vhadd_u (uint32_t n,uint32_t m) +{ +return ((uint64_t )n + m) >>1 ; +} + +static inline int32_t do_vhadd_s (int32_t n,int32_t m) +{ +return ((int64_t )n + m) >>1 ; +} + +static inline uint32_t do_vhsub_u (uint32_t n,uint32_t m) +{ +return ((uint64_t )n - m) >>1 ; +} + +static inline int32_t do_vhsub_s (int32_t n,int32_t m) +{ +return ((int64_t )n - m) >>1 ; +} + +DO_2OP_S(vhadds, do_vhadd_s) +DO_2OP_U(vhaddu, do_vhadd_u) +DO_2OP_S(vhsubs, do_vhsub_s) +DO_2OP_U (vhsubu, do_vhsub_u)
target/arm/translate-mve.c +4 -0
@@ -389,3 +389,7 @@ DO_2OP(VMIN_S, vmins) DO_2OP(VMIN_U, vminu) DO_2OP(VABD_S, vabds) DO_2OP(VABD_U, vabdu) +DO_2OP(VHADD_S, vhadds) +DO_2OP(VHADD_U, vhaddu) +DO_2OP(VHSUB_S, vhsubs) +DO_2OP (VHSUB_U , vhsubu)
Signature · 1 line
2.20.1
Re: [PATCH 27/55] target/arm: Implement MVE VHADD, VHSUB
Quoted 67 lines · Peter Maydell
Implement MVE VHADD and VHSUB insns, which perform an addition or subtraction and then halve the result.
Signed-off-by Peter Maydell <[email protected]>--- target/arm/helper-mve.h | 14 ++++++++++++++ target/arm/mve.decode | 5 +++++ target/arm/mve_helper.c | 25 +++++++++++++++++++++++++ target/arm/translate-mve.c | 4 ++++ 4 files changed, 48 insertions(+)target/arm/helper-mve.h +14
-0@@ -118,3 +118,17 @@ DEF_HELPER_FLAGS_4(mve_vabdsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vabdub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vabduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vabduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vhaddsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhaddsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhaddsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhaddub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhadduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhadduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vhsubsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhsubsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhsubsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhsubub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhsubuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4 (mve_vhsubuw,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr)target/arm/mve.decode +5
-0@@ -96,6 +96,11 @@ VMIN_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 1 ... 0 @2op VABD_S 111 0 1111 0 . .. ... 0 ... 0 0111 . 1 . 0 ... 0 @2op VABD_U 111 1 1111 0 . .. ... 0 ... 0 0111 . 1 . 0 ... 0 @2op +VHADD_S 111 0 1111 0 . .. ... 0 ... 0 0000 . 1 . 0 ... 0 @2op +VHADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 0 ... 0 @2op +VHSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op +VHSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1optarget/arm/mve_helper.c +10
-0@@ -415,3 +415,28 @@ DO_2OP_U(vminu, DO_MIN) DO_2OP_S(vabds, DO_ABD) DO_2OP_U(vabdu, DO_ABD) + +static inline uint32_t do_vhadd_u (uint32_t n,uint32_t m) +{ +return ((uint64_t )n + m) >>1 ; +} + +static inline int32_t do_vhadd_s (int32_t n,int32_t m) +{ +return ((int64_t )n + m) >>1 ; +}
target/arm/mve_helper.c DO_2OP_U(vminu, DO_MIN) · line 437
Quoted 10 lines
target/arm/mve_helper.c +10
-0+ +static inline uint32_t do_vhsub_u (uint32_t n,uint32_t m) +{ +return ((uint64_t )n - m) >>1 ; +} + +static inline int32_t do_vhsub_s (int32_t n,int32_t m) +{ +return ((int64_t )n - m) >>1 ; +}
Use 64-bit inputs and you don't need to replicate these for signed/unsigned. But either way,
r~
PATCH 28/55 target/arm: Implement MVE VMULL
In reply to Peter MaydellImplement the MVE VMULL insn, which multiplies two single width integer elements to produce a double width result.
--- target/arm/helper-mve.h | 14 ++++++++++++++ target/arm/mve.decode | 5 +++++ target/arm/mve_helper.c | 35 +++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 4 ++++ 4 files changed, 58 insertions(+)
target/arm/helper-mve.h +14 -0
@@ -132,3 +132,17 @@ DEF_HELPER_FLAGS_4(mve_vhsubsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vhsubub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vhsubuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vhsubuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vmullbsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmullbsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmullbsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmullbub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmullbuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmullbuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vmulltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmulltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmulltsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmulltub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vmulltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4 (mve_vmulltuw,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr)
target/arm/mve.decode +5 -0
@@ -101,6 +101,11 @@ VHADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 0 ... 0 @2op VHSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op VHSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op +VMULL_BS 111 0 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op +VMULL_BU 111 1 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op +VMULL_TS 111 0 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op +VMULL_TU 111 1 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +35 -0
@@ -335,6 +335,27 @@ DO_1OP(vfnegs, 4, uint32_t, H4, DO_FNEG) DO_2OP(OP##h, 2, int16_t, H2, FN) \ DO_2OP(OP##w, 4, int32_t, H4, FN) +/* +* "Long" operations where two half-sized inputs (taken from either the +* top or the bottom of the input vector) produce a double-width result. +* Here TYPE and H are for the input, and LESIZE, LTYPE, LH for the output. +*/ +#define DO_2OP_L (OP ,TOP ,TYPE ,H ,LESIZE ,LTYPE ,LH ,FN ) \ + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, void *vm) \ + { \ + LTYPE *d = vd; \ + TYPE *n = vn, *m = vm; \ + uint16_t mask = mve_element_mask(env); \ + unsigned le; \ + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ + LTYPE r = FN((LTYPE)n[H(le * 2 + TOP)], m[H(le * 2 + TOP)]); \ + uint64_t bytemask = mask_to_bytemask##LESIZE(mask); \ + d[LH(le)] &= ~bytemask; \ + d[LH(le)] |= (r & bytemask); \ + } \ + mve_advance_vpt(env); \ + } +#define DO_AND (N ,M ) ((N) & (M))#define DO_BIC (N ,M ) ((N) & ~(M))#define DO_ORR (N ,M ) ((N) | (M))
@@ -355,6 +376,20 @@ DO_2OP_U(vadd, DO_ADD) DO_2OP_U(vsub, DO_SUB) DO_2OP_U(vmul, DO_MUL) +DO_2OP_L(vmullbsb, 0, int8_t, H1, 2, int16_t, H2, DO_MUL) +DO_2OP_L(vmullbsh, 0, int16_t, H2, 4, int32_t, H4, DO_MUL) +DO_2OP_L(vmullbsw, 0, int32_t, H4, 8, int64_t, , DO_MUL) +DO_2OP_L(vmullbub, 0, uint8_t, H1, 2, uint16_t, H2, DO_MUL) +DO_2OP_L(vmullbuh, 0, uint16_t, H2, 4, uint32_t, H4, DO_MUL) +DO_2OP_L(vmullbuw, 0, uint32_t, H4, 8, uint64_t, , DO_MUL) + +DO_2OP_L(vmulltsb, 1, int8_t, H1, 2, int16_t, H2, DO_MUL) +DO_2OP_L(vmulltsh, 1, int16_t, H2, 4, int32_t, H4, DO_MUL) +DO_2OP_L(vmulltsw, 1, int32_t, H4, 8, int64_t, , DO_MUL) +DO_2OP_L(vmulltub, 1, uint8_t, H1, 2, uint16_t, H2, DO_MUL) +DO_2OP_L(vmulltuh, 1, uint16_t, H2, 4, uint32_t, H4, DO_MUL) +DO_2OP_L(vmulltuw, 1, uint32_t, H4, 8, uint64_t, , DO_MUL) +/* * Because the computation type is at least twice as large as required, * these work for both signed and unsigned source types.
target/arm/translate-mve.c +4 -0
@@ -393,3 +393,7 @@ DO_2OP(VHADD_S, vhadds) DO_2OP(VHADD_U, vhaddu) DO_2OP(VHSUB_S, vhsubs) DO_2OP(VHSUB_U, vhsubu) +DO_2OP(VMULL_BS, vmullbs) +DO_2OP(VMULL_BU, vmullbu) +DO_2OP(VMULL_TS, vmullts) +DO_2OP (VMULL_TU , vmulltu)
Signature · 1 line
2.20.1
Re: [PATCH 28/55] target/arm: Implement MVE VMULL
Quoted 10 lines · Peter Maydell
Implement the MVE VMULL insn, which multiplies two single width integer elements to produce a double width result.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 14 ++++++++++++++ target/arm/mve.decode | 5 +++++ target/arm/mve_helper.c | 35 +++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 4 ++++ 4 files changed, 58 insertions(+)
r~
PATCH 29/55 target/arm: Implement MVE VMLALDAV
In reply to Peter MaydellImplement the MVE VMLALDAV insn, which multiplies pairs of integer elements, accumulating them into a 64-bit result in a pair of general-purpose registers.
--- target/arm/helper-mve.h | 8 +++ target/arm/translate.h | 10 ++++ target/arm/mve.decode | 15 ++++++ target/arm/mve_helper.c | 32 ++++++++++++ target/arm/translate-mve.c | 100 +++++++++++++++++++++++++++++++++++++ 5 files changed, 165 insertions(+)
target/arm/helper-mve.h +8 -0
@@ -146,3 +146,11 @@ DEF_HELPER_FLAGS_4(mve_vmulltsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vmulltub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vmulltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vmulltuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) +DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) +DEF_HELPER_FLAGS_4(mve_vmlaldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) +DEF_HELPER_FLAGS_4(mve_vmlaldavxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) + +DEF_HELPER_FLAGS_4(mve_vmlaldavuh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) +DEF_HELPER_FLAGS_4 (mve_vmlaldavuw,TCG_CALL_NO_WG , i64, env, ptr, ptr, i64)
target/arm/translate.h +10 -0
@@ -136,6 +136,11 @@ static inline int negate(DisasContext *s, int x)return -x; } +static inline int plus_1 (DisasContext *s,int x) +{ +return x +1 ; +} +static inline int plus_2 (DisasContext *s,int x) {return x +2 ;
@@ -151,6 +156,11 @@ static inline int times_4(DisasContext *s, int x)return x *4 ; } +static inline int times_2_plus_1 (DisasContext *s,int x) +{ +return x *2 +1 ; +} +static inline int arm_dc_feature (DisasContext *dc,int feature) {return (dc->features & (1ULL << feature)) !=0 ;
target/arm/mve.decode +15 -0
@@ -130,3 +130,18 @@ VNEG_fp 1111 1111 1 . 11 .. 01 ... 0 0111 11 . 0 ... 0 @1op VDUP 1110 1110 1 1 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=0 VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 1 1 0000 @vdup size=1 VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 + +# multiply-add long dual accumulate +# rdahi: bits [3:1] from insn, bit 0 is 1 +# rdalo: bits [3:1] from insn, bit 0 is 0 +%rdahi 20:3 !function=times_2_plus_1 +%rdalo 13:3 !function=times_2 +# size bit is 0 for 16 bit, 1 for 32 bit +%size_16 16:1 !function=plus_1 + +&vmlaldav rdahi rdalo size qn qm x a + +@vmlaldav .... .... . ... ... . ... . .... .... qm:3 . \ + qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav +VMLALDAV_S 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav +VMLALDAV_U 1111 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav
target/arm/mve_helper.c +32 -0
@@ -475,3 +475,35 @@ DO_2OP_S(vhadds, do_vhadd_s) DO_2OP_U(vhaddu, do_vhadd_u) DO_2OP_S(vhsubs, do_vhsub_s)DO_2OP_U (vhsubu, do_vhsub_u) + + +/* +* Multiply add long dual accumulate ops. + */ +#define DO_LDAV (OP ,ESIZE ,TYPE ,H ,XCHG ,EVENACC ,ODDACC ) \ + uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ + void *vm, uint64_t a) \ + { \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + TYPE *n = vn, *m = vm; \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + if (mask & 1) { \ + if (e & 1) { \ + a ODDACC (int64_t)n[H(e - 1 * XCHG)] * m[H(e)]; \ + } else { \ + a EVENACC (int64_t)n[H(e + 1 * XCHG)] * m[H(e)]; \ + } \ + } \ + } \ + mve_advance_vpt(env); \ + return a; \ + } + +DO_LDAV(vmlaldavsh, 2, int16_t, H2, false, +=, +=) +DO_LDAV(vmlaldavxsh, 2, int16_t, H2, true, +=, +=) +DO_LDAV(vmlaldavsw, 4, int32_t, H4, false, +=, +=) +DO_LDAV(vmlaldavxsw, 4, int32_t, H4, true, +=, +=) + +DO_LDAV(vmlaldavuh, 2, uint16_t, H2, false, +=, +=) +DO_LDAV(vmlaldavuw, 4, uint32_t, H4, false, +=, +=)
target/arm/translate-mve.c +100 -0
115 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 29/55] target/arm: Implement MVE VMLALDAV
Quoted 4 lines · Peter Maydell
Implement the MVE VMLALDAV insn, which multiplies pairs of integer elements, accumulating them into a 64-bit result in a pair of general-purpose registers.
Quoted 8 lines
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 8 +++ target/arm/translate.h | 10 ++++ target/arm/mve.decode | 15 ++++++ target/arm/mve_helper.c | 32 ++++++++++++ target/arm/translate-mve.c | 100 +++++++++++++++++++++++++++++++++++++ 5 files changed, 165 insertions(+)
r~
Re: [PATCH 29/55] target/arm: Implement MVE VMLALDAV
In reply to Peter Maydelltarget/arm/translate-mve.c DO_2OP(VMULL_BS, vmullbs) · line 481
Quoted 3 lines · Peter Maydell
target/arm/translate-mve.c +3
-0+static bool trans_VMLALDAV_S (DisasContext *s,arg_vmlaldav *a) +{ +MVEGenDualAccOpFn *fns[4 ][2 ] = {
static const, otherwise,
r~
PATCH 30/55 target/arm: Implement MVE VMLSLDAV
In reply to Peter MaydellImplement the MVE insn VMLSLDAV, which multiplies source elements, alternately adding and subtracting them, and accumulates into a 64-bit result in a pair of general purpose registers.
--- target/arm/helper-mve.h | 5 +++++ target/arm/mve.decode | 2 ++ target/arm/mve_helper.c | 5 +++++ target/arm/translate-mve.c | 11 +++++++++++ 4 files changed, 23 insertions(+)
target/arm/helper-mve.h +5 -0
@@ -154,3 +154,8 @@ DEF_HELPER_FLAGS_4(mve_vmlaldavxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) DEF_HELPER_FLAGS_4(mve_vmlaldavuh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) DEF_HELPER_FLAGS_4(mve_vmlaldavuw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) + +DEF_HELPER_FLAGS_4(mve_vmlsldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) +DEF_HELPER_FLAGS_4(mve_vmlsldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) +DEF_HELPER_FLAGS_4(mve_vmlsldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) +DEF_HELPER_FLAGS_4 (mve_vmlsldavxsw,TCG_CALL_NO_WG , i64, env, ptr, ptr, i64)
target/arm/mve.decode +2 -0
@@ -145,3 +145,5 @@ VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav VMLALDAV_S 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav VMLALDAV_U 1111 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav + +VMLSLDAV 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav
target/arm/mve_helper.c +5 -0
@@ -507,3 +507,8 @@ DO_LDAV(vmlaldavxsw, 4, int32_t, H4, true, +=, +=) DO_LDAV(vmlaldavuh, 2, uint16_t, H2, false, +=, +=) DO_LDAV(vmlaldavuw, 4, uint32_t, H4, false, +=, +=) + +DO_LDAV(vmlsldavsh, 2, int16_t, H2, false, +=, -=) +DO_LDAV(vmlsldavxsh, 2, int16_t, H2, true, +=, -=) +DO_LDAV(vmlsldavsw, 4, int32_t, H4, false, +=, -=) +DO_LDAV(vmlsldavxsw, 4, int32_t, H4, true, +=, -=)
target/arm/translate-mve.c +11 -0
@@ -497,3 +497,14 @@ static bool trans_VMLALDAV_U(DisasContext *s, arg_vmlaldav *a) };return do_long_dual_acc (s, a, fns[a->size][a->x]); } + +static bool trans_VMLSLDAV (DisasContext *s,arg_vmlaldav *a) +{ +MVEGenDualAccOpFn *fns[4 ][2 ] = { + {NULL ,NULL }, + { gen_helper_mve_vmlsldavsh, gen_helper_mve_vmlsldavxsh }, + { gen_helper_mve_vmlsldavsw, gen_helper_mve_vmlsldavxsw }, + {NULL ,NULL }, + }; +return do_long_dual_acc (s, a, fns[a->size][a->x]); +}
Signature · 1 line
2.20.1
Re: [PATCH 30/55] target/arm: Implement MVE VMLSLDAV
target/arm/translate-mve.c static bool trans_VMLALDAV_U(DisasContext *s, arg_vmlaldav *a) · line 503
Quoted 3 lines · Peter Maydell
target/arm/translate-mve.c +3
-0+static bool trans_VMLSLDAV (DisasContext *s,arg_vmlaldav *a) +{ +MVEGenDualAccOpFn *fns[4 ][2 ] = {
static const, otherwise,
r~
PATCH 31/55 include/qemu/int128.h: Add function to create Int128 from int64_t
In reply to Peter Maydellint128_make64() creates an Int128 from an unsigned 64 bit value; add a function int128_makes64() creating an Int128 from a signed 64 bit value.
--- include/qemu/int128.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/qemu/int128.h +10 -0
@@ -11,6 +11,11 @@ static inline Int128 int128_make64(uint64_t a)return a; } +static inline Int128 int128_makes64 (int64_t a) +{ +return a; +} +static inline Int128 int128_make128 (uint64_t lo,uint64_t hi) {return (__uint128_t )hi <<64 | lo;
@@ -167,6 +172,11 @@ static inline Int128 int128_make64(uint64_t a)return (Int128 ) { a,0 }; } +static inline Int128 int128_makes64 (int64_t a) +{ +return (Int128 ) { a, a >>63 }; +} +static inline Int128 int128_make128 (uint64_t lo,uint64_t hi) {return (Int128 ) { lo, hi };
Signature · 1 line
2.20.1
Re: [PATCH 31/55] include/qemu/int128.h: Add function to create Int128 from int64_t
Quoted 14 lines · Peter Maydell
int128_make64()creates an Int128 from an unsigned 64 bit value; add a functionint128_makes64()creating an Int128 from a signed 64 bit value.Signed-off-by Peter Maydell <[email protected]>--- include/qemu/int128.h | 10 ++++++++++ 1 file changed, 10 insertions(+)include/qemu/int128.h +0
-0
include/qemu/int128.h static inline Int128 int128_make64(uint64_t a) · line 16
Quoted 6 lines
include/qemu/int128.h +3
-0@@ -11,6 +11,11 @@ static inline Int128 int128_make64(uint64_t a)return a; } +static inline Int128 int128_makes64 (int64_t a) +{ +return (Int128 ) { a, a >>63 };
This file would be easier to review using explicit field names:
return (Int128) { .lo = a, .hi = a >> 63 };Also, maybe we could rename int128_makeX -> int128_make_uX before introducing int128_make_sX.
Regardless:
Quoted 6 lines
include/qemu/int128.h +2
-0+} +static inline Int128 int128_make128 (uint64_t lo,uint64_t hi) {return (Int128 ) { lo, hi };
Re: [PATCH 31/55] include/qemu/int128.h: Add function to create Int128 from int64_t
In reply to Peter MaydellQuoted 8 lines · Peter Maydell
int128_make64()creates an Int128 from an unsigned 64 bit value; add a functionint128_makes64()creating an Int128 from a signed 64 bit value.Signed-off-by Peter Maydell<[email protected]>--- include/qemu/int128.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
r~
PATCH 32/55 target/arm: Implement MVE VRMLALDAVH, VRMLSLDAVH
In reply to Peter MaydellImplement the MVE VRMLALDAVH and VRMLSLDAVH insns, which accumulate the results of a rounded multiply of pairs of elements into a 72-bit accumulator, returning the top 64 bits in a pair of general purpose registers.
--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 7 +++++++ target/arm/mve_helper.c | 35 +++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 24 ++++++++++++++++++++++++ 4 files changed, 74 insertions(+)
target/arm/helper-mve.h +8 -0
@@ -159,3 +159,11 @@ DEF_HELPER_FLAGS_4(mve_vmlsldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) DEF_HELPER_FLAGS_4(mve_vmlsldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) DEF_HELPER_FLAGS_4(mve_vmlsldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) DEF_HELPER_FLAGS_4(mve_vmlsldavxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) + +DEF_HELPER_FLAGS_4(mve_vrmlaldavhsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) +DEF_HELPER_FLAGS_4(mve_vrmlaldavhxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) + +DEF_HELPER_FLAGS_4(mve_vrmlaldavhuw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) + +DEF_HELPER_FLAGS_4(mve_vrmlsldavhsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) +DEF_HELPER_FLAGS_4 (mve_vrmlsldavhxsw,TCG_CALL_NO_WG , i64, env, ptr, ptr, i64)
target/arm/mve.decode +7 -0
@@ -143,7 +143,14 @@ VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 @vmlaldav .... .... . ... ... . ... . .... .... qm:3 . \ qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav +@vmlaldav_nosz .... .... . ... ... . ... . .... .... qm:3 . \ + qn=%qn rdahi=%rdahi rdalo=%rdalo size=0 &vmlaldav VMLALDAV_S 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav VMLALDAV_U 1111 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav VMLSLDAV 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav + +VRMLALDAVH_S 1110 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz +VRMLALDAVH_U 1111 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz + +VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_nosz
target/arm/mve_helper.c +35 -0
@@ -18,6 +18,7 @@*/ #include "qemu/osdep.h" +#include "qemu/int128.h" #include "cpu.h" #include "internals.h" #include "exec/helper-proto.h"
@@ -512,3 +513,37 @@ DO_LDAV(vmlsldavsh, 2, int16_t, H2, false, +=, -=) DO_LDAV(vmlsldavxsh, 2, int16_t, H2, true, +=, -=) DO_LDAV(vmlsldavsw, 4, int32_t, H4, false, +=, -=) DO_LDAV(vmlsldavxsw, 4, int32_t, H4, true, +=, -=) + +/* +* Rounding multiply add long dual accumulate high: we must keep +* a 72-bit internal accumulator value and return the top 64 bits. + */ +#define DO_LDAVH (OP ,ESIZE ,TYPE ,H ,XCHG ,EVENACC ,ODDACC ,TO128 ) \ + uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ + void *vm, uint64_t a) \ + { \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + TYPE *n = vn, *m = vm; \ + Int128 acc = TO128(a); \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + if (mask & 1) { \ + if (e & 1) { \ + acc = ODDACC(acc, TO128(n[H(e - 1 * XCHG)] * m[H(e)])); \ + } else { \ + acc = EVENACC(acc, TO128(n[H(e + 1 * XCHG)] * m[H(e)])); \ + } \ + acc = int128_add(acc, 1 << 7); \ + } \ + } \ + mve_advance_vpt(env); \ + return int128_getlo(int128_rshift(acc, 8)); \ + } + +DO_LDAVH(vrmlaldavhsw, 4, int32_t, H4, false, int128_add, int128_add, int128_makes64) +DO_LDAVH(vrmlaldavhxsw, 4, int32_t, H4, true, int128_add, int128_add, int128_makes64) + +DO_LDAVH(vrmlaldavhuw, 4, uint32_t, H4, false, int128_add, int128_add, int128_make64) + +DO_LDAVH(vrmlsldavhsw, 4, int32_t, H4, false, int128_add, int128_sub, int128_makes64) +DO_LDAVH (vrmlsldavhxsw,4 , int32_t,H4 , true, int128_add, int128_sub, int128_makes64)
target/arm/translate-mve.c +24 -0
@@ -508,3 +508,27 @@ static bool trans_VMLSLDAV(DisasContext *s, arg_vmlaldav *a) };return do_long_dual_acc (s, a, fns[a->size][a->x]); } + +static bool trans_VRMLALDAVH_S (DisasContext *s,arg_vmlaldav *a) +{ +MVEGenDualAccOpFn *fns[] = { + gen_helper_mve_vrmlaldavhsw, gen_helper_mve_vrmlaldavhxsw, + }; +return do_long_dual_acc (s, a, fns[a->x]); +} + +static bool trans_VRMLALDAVH_U (DisasContext *s,arg_vmlaldav *a) +{ +MVEGenDualAccOpFn *fns[] = { + gen_helper_mve_vrmlaldavhuw,NULL , + }; +return do_long_dual_acc (s, a, fns[a->x]); +} + +static bool trans_VRMLSLDAVH (DisasContext *s,arg_vmlaldav *a) +{ +MVEGenDualAccOpFn *fns[] = { + gen_helper_mve_vrmlsldavhsw, gen_helper_mve_vrmlsldavhxsw, + }; +return do_long_dual_acc (s, a, fns[a->x]); +}
Signature · 1 line
2.20.1
Re: [PATCH 32/55] target/arm: Implement MVE VRMLALDAVH, VRMLSLDAVH
target/arm/mve_helper.c DO_LDAV(vmlsldavsh, 2, int16_t, H2, false, +=, -=) · line 528
Quoted 8 lines · Peter Maydell
target/arm/mve_helper.c +8
-0+#define DO_LDAVH (OP ,ESIZE ,TYPE ,H ,XCHG ,EVENACC ,ODDACC ,TO128 ) \ + uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ + void *vm, uint64_t a) \ + { \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + TYPE *n = vn, *m = vm; \ + Int128 acc = TO128(a); \
This seems to miss the << 8.
Which suggests that the whole thing can be done without Int128:
target/arm/mve_helper.c DO_LDAV(vmlsldavsh, 2, int16_t, H2, false, +=, -=) · line 532
Quoted 4 lines
target/arm/mve_helper.c +4
-0+for (e =0 ; e <16 /ESIZE ; e++, mask >>=ESIZE ) { \ +if (mask &1 ) { \ +if (e &1 ) { \ + acc =ODDACC (acc,TO128 (n[H (e -1 *XCHG )] * m[H (e)])); \
tmp = n * m; tmp = (tmp >> 8) + ((tmp >> 7) & 1); acc ODDACC tmp;
target/arm/translate-mve.c static bool trans_VMLSLDAV(DisasContext *s, arg_vmlaldav *a) · line 514
Quoted 3 lines
target/arm/translate-mve.c +3
-0+static bool trans_VRMLALDAVH_S (DisasContext *s,arg_vmlaldav *a) +{ +MVEGenDualAccOpFn *fns[] = {
static const, etc.
r~
Re: [PATCH 32/55] target/arm: Implement MVE VRMLALDAVH, VRMLSLDAVH
Quoted 11 lines · Richard Henderson
target/arm/mve_helper.c DO_LDAV(vmlsldavsh, 2, int16_t, H2, false, +=, -=) · line 528
Quoted 8 lines · Peter Maydell
target/arm/mve_helper.c +8
-0+#define DO_LDAVH (OP ,ESIZE ,TYPE ,H ,XCHG ,EVENACC ,ODDACC ,TO128 ) \ + uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ + void *vm, uint64_t a) \ + { \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + TYPE *n = vn, *m = vm; \ + Int128 acc = TO128(a); \
Quoted 1 line
This seems to miss the << 8.
Oops, yes it does.
Quoted 10 lines
Which suggests that the whole thing can be done without Int128:
target/arm/mve_helper.c DO_LDAV(vmlsldavsh, 2, int16_t, H2, false, +=, -=) · line 532
Quoted 4 lines
target/arm/mve_helper.c +4
-0+for (e =0 ; e <16 /ESIZE ; e++, mask >>=ESIZE ) { \ +if (mask &1 ) { \ +if (e &1 ) { \ + acc =ODDACC (acc,TO128 (n[H (e -1 *XCHG )] * m[H (e)])); \tmp = n * m; tmp = (tmp >> 8) + ((tmp >> 7) & 1); acc ODDACC tmp;
I'm not sure about this suggestion though. It throws away all of the bottom 7 bits of the product, but because we're iterating through this 4 times and adding (potentially) four of these products together, those bottom 7 bits in the 4 products might be able to add together to become significant enough to affect the final result.
-- PMM
PATCH 33/55 target/arm: Implement MVE VADD (scalar)
In reply to Peter MaydellImplement the scalar form of the MVE VADD insn. This takes the scalar operand from a general purpose register.
--- target/arm/helper-mve.h | 4 ++++ target/arm/mve.decode | 7 ++++++ target/arm/mve_helper.c | 25 +++++++++++++++++++ target/arm/translate-mve.c | 49 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+)
target/arm/helper-mve.h +4 -0
@@ -147,6 +147,10 @@ DEF_HELPER_FLAGS_4(mve_vmulltub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vmulltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vmulltuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64)DEF_HELPER_FLAGS_4 (mve_vmlaldavxsh,TCG_CALL_NO_WG , i64, env, ptr, ptr, i64)
target/arm/mve.decode +7 -0
@@ -26,6 +26,7 @@ &vldr_vstr rn qd imm p a w size l u &1op qd qm size &2op qd qm qn size +&2scalar qd qn rm size @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 # Note that both Rn and Qd are 3 bits only (no D bit)
@@ -36,6 +37,8 @@ @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 +@2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn + # Vector loads and stores # Widening loads and narrowing stores:
@@ -154,3 +157,7 @@ VRMLALDAVH_S 1110 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_no VRMLALDAVH_U 1111 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_nosz + +# Scalar operations + +VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar
target/arm/mve_helper.c +25 -0
@@ -478,6 +478,31 @@ DO_2OP_S(vhsubs, do_vhsub_s) DO_2OP_U(vhsubu, do_vhsub_u) +#define DO_2OP_SCALAR (OP ,ESIZE ,TYPE ,H ,FN ) \ + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ + uint32_t rm) \ + { \ + TYPE *d = vd, *n = vn; \ + TYPE m = rm; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + TYPE r = FN(n[H(e)], m); \ + uint64_t bytemask = mask_to_bytemask##ESIZE(mask); \ + d[H(e)] &= ~bytemask; \ + d[H(e)] |= (r & bytemask); \ + } \ + mve_advance_vpt(env); \ + } + +/* provide unsigned 2-op scalar helpers for all sizes */ +#define DO_2OP_SCALAR_U (OP ,FN ) \ + DO_2OP_SCALAR(OP##b, 1, uint8_t, H1, FN) \ + DO_2OP_SCALAR(OP##h, 2, uint16_t, H2, FN) \ + DO_2OP_SCALAR(OP##w, 4, uint32_t, H4, FN) + +DO_2OP_SCALAR_U (vadd_scalar,DO_ADD ) +/* * Multiply add long dual accumulate ops. */
target/arm/translate-mve.c +49 -0
61 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 33/55] target/arm: Implement MVE VADD (scalar)
Quoted 10 lines · Peter Maydell
Implement the scalar form of the MVE VADD insn. This takes the scalar operand from a general purpose register.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 4 ++++ target/arm/mve.decode | 7 ++++++ target/arm/mve_helper.c | 25 +++++++++++++++++++ target/arm/translate-mve.c | 49 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+)
Quoted 1 line
+ MVEGenTwoOpScalarFn *fns[] = { \
static const, which I will quit mentioning.
r~
PATCH 34/55 target/arm: Implement MVE VSUB, VMUL (scalar)
In reply to Peter MaydellImplement the scalar forms of the MVE VSUB and VMUL insns.
--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 2 ++ target/arm/mve_helper.c | 2 ++ target/arm/translate-mve.c | 2 ++ 4 files changed, 14 insertions(+)
target/arm/helper-mve.h +8 -0
@@ -151,6 +151,14 @@ DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vsub_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vsub_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vsub_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + +DEF_HELPER_FLAGS_4(mve_vmul_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vmul_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vmul_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64)DEF_HELPER_FLAGS_4 (mve_vmlaldavxsh,TCG_CALL_NO_WG , i64, env, ptr, ptr, i64)
target/arm/mve.decode +2 -0
@@ -161,3 +161,5 @@ VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_no # Scalar operations VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar +VSUB_scalar 1110 1110 0 . .. ... 1 ... 1 1111 . 100 .... @2scalar +VMUL_scalar 1110 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar
target/arm/mve_helper.c +2 -0
@@ -502,6 +502,8 @@ DO_2OP_U(vhsubu, do_vhsub_u) DO_2OP_SCALAR(OP##w, 4, uint32_t, H4, FN) DO_2OP_SCALAR_U(vadd_scalar, DO_ADD) +DO_2OP_SCALAR_U(vsub_scalar, DO_SUB) +DO_2OP_SCALAR_U (vmul_scalar,DO_MUL )/* * Multiply add long dual accumulate ops.
target/arm/translate-mve.c +2 -0
@@ -463,6 +463,8 @@ static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, } DO_2OP_SCALAR(VADD_scalar, vadd_scalar) +DO_2OP_SCALAR(VSUB_scalar, vsub_scalar) +DO_2OP_SCALAR(VMUL_scalar, vmul_scalar)static bool do_long_dual_acc (DisasContext *s,arg_vmlaldav *a,MVEGenDualAccOpFn *fn)
Signature · 1 line
2.20.1
Re: [PATCH 34/55] target/arm: Implement MVE VSUB, VMUL (scalar)
Quoted 9 lines · Peter Maydell
Implement the scalar forms of the MVE VSUB and VMUL insns.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 2 ++ target/arm/mve_helper.c | 2 ++ target/arm/translate-mve.c | 2 ++ 4 files changed, 14 insertions(+)
r~
PATCH 35/55 target/arm: Implement MVE VHADD, VHSUB (scalar)
In reply to Peter MaydellImplement the scalar variants of the MVE VHADD and VHSUB insns.
--- target/arm/helper-mve.h | 16 ++++++++++++++++ target/arm/mve.decode | 4 ++++ target/arm/mve_helper.c | 8 ++++++++ target/arm/translate-mve.c | 4 ++++ 4 files changed, 32 insertions(+)
target/arm/helper-mve.h +16 -0
@@ -159,6 +159,22 @@ DEF_HELPER_FLAGS_4(mve_vmul_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vmul_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vmul_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vhadds_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vhadds_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vhadds_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + +DEF_HELPER_FLAGS_4(mve_vhaddu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vhaddu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vhaddu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + +DEF_HELPER_FLAGS_4(mve_vhsubs_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vhsubs_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vhsubs_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + +DEF_HELPER_FLAGS_4(mve_vhsubu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vhsubu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vhsubu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64)DEF_HELPER_FLAGS_4 (mve_vmlaldavxsh,TCG_CALL_NO_WG , i64, env, ptr, ptr, i64)
target/arm/mve.decode +4 -0
@@ -163,3 +163,7 @@ VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_no VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar VSUB_scalar 1110 1110 0 . .. ... 1 ... 1 1111 . 100 .... @2scalar VMUL_scalar 1110 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar +VHADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar +VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar +VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar +VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar
target/arm/mve_helper.c +8 -0
@@ -500,10 +500,18 @@ DO_2OP_U(vhsubu, do_vhsub_u) DO_2OP_SCALAR(OP##b, 1, uint8_t, H1, FN) \ DO_2OP_SCALAR(OP##h, 2, uint16_t, H2, FN) \ DO_2OP_SCALAR(OP##w, 4, uint32_t, H4, FN) +#define DO_2OP_SCALAR_S (OP ,FN ) \ + DO_2OP_SCALAR(OP##b, 1, int8_t, H1, FN) \ + DO_2OP_SCALAR(OP##h, 2, int16_t, H2, FN) \ + DO_2OP_SCALAR(OP##w, 4, int32_t, H4, FN) DO_2OP_SCALAR_U(vadd_scalar, DO_ADD) DO_2OP_SCALAR_U(vsub_scalar, DO_SUB) DO_2OP_SCALAR_U(vmul_scalar, DO_MUL) +DO_2OP_SCALAR_S(vhadds_scalar, do_vhadd_s) +DO_2OP_SCALAR_U(vhaddu_scalar, do_vhadd_u) +DO_2OP_SCALAR_S(vhsubs_scalar, do_vhsub_s) +DO_2OP_SCALAR_U (vhsubu_scalar, do_vhsub_u)/* * Multiply add long dual accumulate ops.
target/arm/translate-mve.c +4 -0
@@ -465,6 +465,10 @@ static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, DO_2OP_SCALAR(VADD_scalar, vadd_scalar) DO_2OP_SCALAR(VSUB_scalar, vsub_scalar) DO_2OP_SCALAR(VMUL_scalar, vmul_scalar) +DO_2OP_SCALAR(VHADD_S_scalar, vhadds_scalar) +DO_2OP_SCALAR(VHADD_U_scalar, vhaddu_scalar) +DO_2OP_SCALAR(VHSUB_S_scalar, vhsubs_scalar) +DO_2OP_SCALAR(VHSUB_U_scalar, vhsubu_scalar)static bool do_long_dual_acc (DisasContext *s,arg_vmlaldav *a,MVEGenDualAccOpFn *fn)
Signature · 1 line
2.20.1
Re: [PATCH 35/55] target/arm: Implement MVE VHADD, VHSUB (scalar)
Quoted 9 lines · Peter Maydell
Implement the scalar variants of the MVE VHADD and VHSUB insns.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 16 ++++++++++++++++ target/arm/mve.decode | 4 ++++ target/arm/mve_helper.c | 8 ++++++++ target/arm/translate-mve.c | 4 ++++ 4 files changed, 32 insertions(+)
r~
PATCH 36/55 target/arm: Implement MVE VBRSR
In reply to Peter MaydellImplement the MVE VBRSR insn, which reverses a specified number of bits in each element, setting the rest to zero.
--- target/arm/helper-mve.h | 4 ++++ target/arm/mve.decode | 1 + target/arm/mve_helper.c | 43 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 1 + 4 files changed, 49 insertions(+)
target/arm/helper-mve.h +4 -0
@@ -175,6 +175,10 @@ DEF_HELPER_FLAGS_4(mve_vhsubu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vhsubu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vhsubu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vbrsrb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vbrsrh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vbrsrw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64)DEF_HELPER_FLAGS_4 (mve_vmlaldavxsh,TCG_CALL_NO_WG , i64, env, ptr, ptr, i64)
target/arm/mve.decode +1 -0
@@ -167,3 +167,4 @@ VHADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar +VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar
target/arm/mve_helper.c +43 -0
49 lines not on this page · raw message
target/arm/translate-mve.c +1 -0
@@ -469,6 +469,7 @@ DO_2OP_SCALAR(VHADD_S_scalar, vhadds_scalar) DO_2OP_SCALAR(VHADD_U_scalar, vhaddu_scalar) DO_2OP_SCALAR(VHSUB_S_scalar, vhsubs_scalar) DO_2OP_SCALAR(VHSUB_U_scalar, vhsubu_scalar) +DO_2OP_SCALAR(VBRSR, vbrsr)static bool do_long_dual_acc (DisasContext *s,arg_vmlaldav *a,MVEGenDualAccOpFn *fn)
Signature · 1 line
2.20.1
Re: [PATCH 36/55] target/arm: Implement MVE VBRSR
Quoted 10 lines · Peter Maydell
Implement the MVE VBRSR insn, which reverses a specified number of bits in each element, setting the rest to zero.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 4 ++++ target/arm/mve.decode | 1 + target/arm/mve_helper.c | 43 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 1 + 4 files changed, 49 insertions(+)
What an interesting operation combination. I wonder what dsp loop kernel it goes with...
r~
PATCH 37/55 target/arm: Implement MVE VPST
In reply to Peter MaydellImplement the MVE VPST insn, which sets the predicate mask fields in the VPR to the immediate value encoded in the insn.
--- target/arm/mve.decode | 4 +++ target/arm/translate-mve.c | 59 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
target/arm/mve.decode +4 -0
@@ -168,3 +168,7 @@ VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar + +# Predicate operations +%mask_22_13 22:1 13:3 +VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13
target/arm/translate-mve.c +59 -0
62 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 37/55] target/arm: Implement MVE VPST
Quoted 8 lines · Peter Maydell
Implement the MVE VPST insn, which sets the predicate mask fields in the VPR to the immediate value encoded in the insn.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/mve.decode | 4 +++ target/arm/translate-mve.c | 59 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
r~
PATCH 38/55 target/arm: Implement MVE VQADD and VQSUB
In reply to Peter MaydellImplement the MVE VQADD and VQSUB insns, which perform saturating addition of a scalar to each element. Note that individual bytes of each result element are used or discarded according to the predicate mask, but FPSCR.QC is only set if the predicate mask for the lowest byte of the element is set.
--- target/arm/helper-mve.h | 16 ++++++++++ target/arm/mve.decode | 5 +++ target/arm/mve_helper.c | 62 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 4 +++ 4 files changed, 87 insertions(+)
target/arm/helper-mve.h +16 -0
@@ -175,6 +175,22 @@ DEF_HELPER_FLAGS_4(mve_vhsubu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vhsubu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vhsubu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqadds_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqadds_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqadds_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + +DEF_HELPER_FLAGS_4(mve_vqaddu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqaddu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqaddu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + +DEF_HELPER_FLAGS_4(mve_vqsubs_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqsubs_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqsubs_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + +DEF_HELPER_FLAGS_4(mve_vqsubu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqsubu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqsubu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + DEF_HELPER_FLAGS_4(mve_vbrsrb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vbrsrh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)DEF_HELPER_FLAGS_4 (mve_vbrsrw,TCG_CALL_NO_WG , void, env, ptr, ptr, i32)
target/arm/mve.decode +5 -0
@@ -167,6 +167,11 @@ VHADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar + +VQADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 110 .... @2scalar +VQADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 110 .... @2scalar +VQSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar +VQSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar # Predicate operations
target/arm/mve_helper.c +62 -0
80 lines not on this page · raw message
target/arm/translate-mve.c +4 -0
@@ -469,6 +469,10 @@ DO_2OP_SCALAR(VHADD_S_scalar, vhadds_scalar) DO_2OP_SCALAR(VHADD_U_scalar, vhaddu_scalar) DO_2OP_SCALAR(VHSUB_S_scalar, vhsubs_scalar) DO_2OP_SCALAR(VHSUB_U_scalar, vhsubu_scalar) +DO_2OP_SCALAR(VQADD_S_scalar, vqadds_scalar) +DO_2OP_SCALAR(VQADD_U_scalar, vqaddu_scalar) +DO_2OP_SCALAR(VQSUB_S_scalar, vqsubs_scalar) +DO_2OP_SCALAR(VQSUB_U_scalar, vqsubu_scalar) DO_2OP_SCALAR(VBRSR, vbrsr) static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a,
Signature · 1 line
2.20.1
Re: [PATCH 38/55] target/arm: Implement MVE VQADD and VQSUB
Quoted 10 lines · Peter Maydell
target/arm/mve_helper.c +10
-0+#define DO_2OP_SAT_SCALAR (OP ,ESIZE ,TYPE ,H ,FN ) \ + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ + uint32_t rm) \ + { \ + TYPE *d = vd, *n = vn; \ + TYPE m = rm; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + bool sat = false; \
target/arm/mve_helper.c DO_2OP_U(vhsubu, do_vhsub_u) · line 544
Quoted 10 lines
target/arm/mve_helper.c +10
-0+TYPE r =FN (n[H (e)], m, &sat); \ + uint64_t bytemask = mask_to_bytemask##ESIZE(mask); \ + d[H (e)] &= ~bytemask; \ + d[H (e)] |= (r & bytemask); \ +if (sat && (mask &1 )) { \ + env->vfp.qc[0 ] =1 ; \ + } \ + } \ +mve_advance_vpt (env); \ + }
Perhaps slightly better as
bool qc = false;
qc |= sat & mask & 1;
if (qc) {
env->vfp.qc[0] = qc;
}Maybe reverse the store into &sat (set false if no saturation), and init as
bool sat = mask & 1;
Though if you choose not to exploit this kind of conditional store, perhaps it would be better to fully set *s within do_sat_bhw. That is, do not rely on initialization to false outside the subroutine.
Which you choose,
r~
PATCH 39/55 target/arm: Implement MVE VQDMULH and VQRDMULH (scalar)
In reply to Peter MaydellImplement the MVE VQDMULH and VQRDMULH scalar insns, which multiply elements by the scalar, double, possibly round, take the high half and saturate.
--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 25 +++++++++++++++++++++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 38 insertions(+)
target/arm/helper-mve.h +8 -0
@@ -191,6 +191,14 @@ DEF_HELPER_FLAGS_4(mve_vqsubu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vqsubu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vqsubu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqdmulh_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqdmulh_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqdmulh_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + +DEF_HELPER_FLAGS_4(mve_vqrdmulh_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqrdmulh_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqrdmulh_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + DEF_HELPER_FLAGS_4(mve_vbrsrb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vbrsrh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)DEF_HELPER_FLAGS_4 (mve_vbrsrw,TCG_CALL_NO_WG , void, env, ptr, ptr, i32)
target/arm/mve.decode +3 -0
@@ -174,6 +174,9 @@ VQSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar VQSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar +VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar +VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar + # Predicate operations %mask_22_13 22:1 13:3 VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13
target/arm/mve_helper.c +25 -0
@@ -505,6 +505,24 @@ static inline int32_t do_sat_bhw(int64_t val, int64_t min, int64_t max, bool *s)#define DO_UQSUB_H (n, m, s) do_sat_bhw((int64_t)n - m, 0, UINT16_MAX, s)#define DO_UQSUB_W (n, m, s) do_sat_bhw((int64_t)n - m, 0, UINT32_MAX, s) +/* +* For QDMULH and QRDMULH we simplify "double and shift by esize" into +* "shift by esize-1", adjusting the QRDMULH rounding constant to match. +*/ +#define DO_QDMULH_B (n, m, s) do_sat_bhw(((int64_t)n * m) >> 7, \ + INT8_MIN, INT8_MAX, s) +#define DO_QDMULH_H (n, m, s) do_sat_bhw(((int64_t)n * m) >> 15, \ + INT16_MIN, INT16_MAX, s) +#define DO_QDMULH_W (n, m, s) do_sat_bhw(((int64_t)n * m) >> 31, \ + INT32_MIN, INT32_MAX, s) + +#define DO_QRDMULH_B (n, m, s) do_sat_bhw(((int64_t)n * m + (1 << 6)) >> 7, \ + INT8_MIN, INT8_MAX, s) +#define DO_QRDMULH_H (n, m, s) do_sat_bhw(((int64_t)n * m + (1 << 14)) >> 15, \ + INT16_MIN, INT16_MAX, s) +#define DO_QRDMULH_W (n, m, s) do_sat_bhw(((int64_t)n * m + (1 << 30)) >> 31, \ + INT32_MIN, INT32_MAX, s) +#define DO_2OP_SCALAR (OP ,ESIZE ,TYPE ,H ,FN ) \ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ uint32_t rm) \
@@ -575,6 +593,13 @@ DO_2OP_SAT_SCALAR(vqsubs_scalarb, 1, int8_t, H1, DO_SQSUB_B) DO_2OP_SAT_SCALAR(vqsubs_scalarh, 2, int16_t, H2, DO_SQSUB_H) DO_2OP_SAT_SCALAR(vqsubs_scalarw, 4, int32_t, H4, DO_SQSUB_W) +DO_2OP_SAT_SCALAR(vqdmulh_scalarb, 1, int8_t, H1, DO_QDMULH_B) +DO_2OP_SAT_SCALAR(vqdmulh_scalarh, 2, int16_t, H2, DO_QDMULH_H) +DO_2OP_SAT_SCALAR(vqdmulh_scalarw, 4, int32_t, H4, DO_QDMULH_W) +DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, H1, DO_QRDMULH_B) +DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, H2, DO_QRDMULH_H) +DO_2OP_SAT_SCALAR(vqrdmulh_scalarw, 4, int32_t, H4, DO_QRDMULH_W) +static inline uint32_t do_vbrsrb (uint32_t n,uint32_t m) { m &=0xff ;
target/arm/translate-mve.c +2 -0
@@ -473,6 +473,8 @@ DO_2OP_SCALAR(VQADD_S_scalar, vqadds_scalar) DO_2OP_SCALAR(VQADD_U_scalar, vqaddu_scalar) DO_2OP_SCALAR(VQSUB_S_scalar, vqsubs_scalar) DO_2OP_SCALAR(VQSUB_U_scalar, vqsubu_scalar) +DO_2OP_SCALAR(VQDMULH_scalar, vqdmulh_scalar) +DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) DO_2OP_SCALAR(VBRSR, vbrsr) static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a,
Signature · 1 line
2.20.1
Re: [PATCH 39/55] target/arm: Implement MVE VQDMULH and VQRDMULH (scalar)
Quoted 11 lines · Peter Maydell
Implement the MVE VQDMULH and VQRDMULH scalar insns, which multiply elements by the scalar, double, possibly round, take the high half and saturate.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 25 +++++++++++++++++++++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 38 insertions(+)
r~
PATCH 40/55 target/arm: Implement MVE VQDMULL scalar
In reply to Peter MaydellImplement the MVE VQDMULL scalar insn. This multiplies the top or bottom half of each element by the scalar, doubles and saturates to a double-width result.
Note that this encoding overlaps with VQADD and VQSUB; it uses what in VQADD and VQSUB would be the 'size=0b11' encoding.
--- target/arm/helper-mve.h | 5 +++ target/arm/mve.decode | 23 +++++++++++--- target/arm/mve_helper.c | 65 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 30 ++++++++++++++++++ 4 files changed, 119 insertions(+), 4 deletions(-)
target/arm/helper-mve.h +5 -0
@@ -203,6 +203,11 @@ DEF_HELPER_FLAGS_4(mve_vbrsrb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vbrsrh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vbrsrw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) + DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64)DEF_HELPER_FLAGS_4 (mve_vmlaldavxsh,TCG_CALL_NO_WG , i64, env, ptr, ptr, i64)
target/arm/mve.decode +19 -4
@@ -23,6 +23,9 @@ %qm 5:1 1:3 %qn 7:1 17:3 +# VQDMULL has size in bit 28: 0 for 16 bit, 1 for 32 bit +%size_28 28:1 !function=plus_1 + &vldr_vstr rn qd imm p a w size l u &1op qd qm size &2op qd qm qn size
@@ -38,6 +41,7 @@ @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 @2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn +@2scalar_nosz .... .... .... .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn # Vector loads and stores
@@ -168,15 +172,26 @@ VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar -VQADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 110 .... @2scalar -VQADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 110 .... @2scalar -VQSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar -VQSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar +{ + VQADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 110 .... @2scalar + VQADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 110 .... @2scalar + VQDMULLB_scalar 111 . 1110 0 . 11 ... 0 ... 0 1111 . 110 .... @2scalar_nosz \ + size=%size_28 +} + +{ + VQSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar + VQSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar + VQDMULLT_scalar 111 . 1110 0 . 11 ... 0 ... 1 1111 . 110 .... @2scalar_nosz \ + size=%size_28 +} + VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar + # Predicate operations %mask_22_13 22:1 13:3 VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13
target/arm/mve_helper.c +65 -0
71 lines not on this page · raw message
target/arm/translate-mve.c +30 -0
@@ -477,6 +477,36 @@ DO_2OP_SCALAR(VQDMULH_scalar, vqdmulh_scalar) DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) DO_2OP_SCALAR(VBRSR, vbrsr) +static bool trans_VQDMULLB_scalar (DisasContext *s,arg_2scalar *a) +{ +MVEGenTwoOpScalarFn *fns[] = { +NULL , + gen_helper_mve_vqdmullb_scalarh, + gen_helper_mve_vqdmullb_scalarw, +NULL , + }; +if (a->qd == a->qn && a->size ==MO_32 ) { +/* UNPREDICTABLE; we choose to undef */ +return false; + } +return do_2op_scalar (s, a, fns[a->size]); +} + +static bool trans_VQDMULLT_scalar (DisasContext *s,arg_2scalar *a) +{ +MVEGenTwoOpScalarFn *fns[] = { +NULL , + gen_helper_mve_vqdmullt_scalarh, + gen_helper_mve_vqdmullt_scalarw, +NULL , + }; +if (a->qd == a->qn && a->size ==MO_32 ) { +/* UNPREDICTABLE; we choose to undef */ +return false; + } +return do_2op_scalar (s, a, fns[a->size]); +} +static bool do_long_dual_acc (DisasContext *s,arg_vmlaldav *a,MVEGenDualAccOpFn *fn) {
Signature · 1 line
2.20.1
Re: [PATCH 40/55] target/arm: Implement MVE VQDMULL scalar
Quoted 7 lines · Peter Maydell
Implement the MVE VQDMULL scalar insn. This multiplies the top or bottom half of each element by the scalar, doubles and saturates to a double-width result.
Note that this encoding overlaps with VQADD and VQSUB; it uses what in VQADD and VQSUB would be the 'size=0b11' encoding.
Quoted 7 lines
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 5 +++ target/arm/mve.decode | 23 +++++++++++--- target/arm/mve_helper.c | 65 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 30 ++++++++++++++++++ 4 files changed, 119 insertions(+), 4 deletions(-)
r~
PATCH 41/55 target/arm: Implement MVE VQDMULH, VQRDMULH (vector)
In reply to Peter MaydellImplement the vector forms of the MVE VQDMULH and VQRDMULH insns.
--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 27 +++++++++++++++++++++++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 40 insertions(+)
target/arm/helper-mve.h +8 -0
@@ -147,6 +147,14 @@ DEF_HELPER_FLAGS_4(mve_vmulltub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vmulltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vmulltuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmulhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmulhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmulhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vqrdmulhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrdmulhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrdmulhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)DEF_HELPER_FLAGS_4 (mve_vadd_scalarw,TCG_CALL_NO_WG , void, env, ptr, ptr, i32)
target/arm/mve.decode +3 -0
@@ -113,6 +113,9 @@ VMULL_BU 111 1 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op VMULL_TS 111 0 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op VMULL_TU 111 1 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op +VQDMULH 1110 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op +VQRDMULH 1111 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +27 -0
@@ -357,6 +357,25 @@ DO_1OP(vfnegs, 4, uint32_t, H4, DO_FNEG)mve_advance_vpt (env); \ } +#define DO_2OP_SAT (OP ,ESIZE ,TYPE ,H ,FN ) \ + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, void *vm) \ + { \ + TYPE *d = vd, *n = vn, *m = vm; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + bool sat = false; \ + TYPE r = FN(n[H(e)], m[H(e)], &sat); \ + uint64_t bytemask = mask_to_bytemask##ESIZE(mask); \ + d[H(e)] &= ~bytemask; \ + d[H(e)] |= (r & bytemask); \ + if (sat && (mask & 1)) { \ + env->vfp.qc[0] = 1; \ + } \ + } \ + mve_advance_vpt(env); \ + } +#define DO_AND (N ,M ) ((N) & (M))#define DO_BIC (N ,M ) ((N) & ~(M))#define DO_ORR (N ,M ) ((N) | (M))
@@ -523,6 +542,14 @@ static inline int32_t do_sat_bhw(int64_t val, int64_t min, int64_t max, bool *s)#define DO_QRDMULH_W (n, m, s) do_sat_bhw(((int64_t)n * m + (1 << 30)) >> 31, \ INT32_MIN, INT32_MAX, s) +DO_2OP_SAT(vqdmulhb, 1, int8_t, H1, DO_QDMULH_B) +DO_2OP_SAT(vqdmulhh, 2, int16_t, H2, DO_QDMULH_H) +DO_2OP_SAT(vqdmulhw, 4, int32_t, H4, DO_QDMULH_W) + +DO_2OP_SAT(vqrdmulhb, 1, int8_t, H1, DO_QRDMULH_B) +DO_2OP_SAT(vqrdmulhh, 2, int16_t, H2, DO_QRDMULH_H) +DO_2OP_SAT(vqrdmulhw, 4, int32_t, H4, DO_QRDMULH_W) +#define DO_2OP_SCALAR (OP ,ESIZE ,TYPE ,H ,FN ) \ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ uint32_t rm) \
target/arm/translate-mve.c +2 -0
@@ -415,6 +415,8 @@ DO_2OP(VMULL_BS, vmullbs) DO_2OP(VMULL_BU, vmullbu) DO_2OP(VMULL_TS, vmullts) DO_2OP(VMULL_TU, vmulltu) +DO_2OP(VQDMULH, vqdmulh) +DO_2OP(VQRDMULH, vqrdmulh)static bool do_2op_scalar (DisasContext *s,arg_2scalar *a,MVEGenTwoOpScalarFn fn)
Signature · 1 line
2.20.1
Re: [PATCH 41/55] target/arm: Implement MVE VQDMULH, VQRDMULH (vector)
Quoted 9 lines · Peter Maydell
Implement the vector forms of the MVE VQDMULH and VQRDMULH insns.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 27 +++++++++++++++++++++++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 40 insertions(+)
r~
PATCH 42/55 target/arm: Implement MVE VQADD, VQSUB (vector)
In reply to Peter MaydellImplement the vector forms of the MVE VQADD and VQSUB insns.
--- target/arm/helper-mve.h | 16 ++++++++++++++++ target/arm/mve.decode | 5 +++++ target/arm/mve_helper.c | 14 ++++++++++++++ target/arm/translate-mve.c | 4 ++++ 4 files changed, 39 insertions(+)
target/arm/helper-mve.h +16 -0
@@ -155,6 +155,22 @@ DEF_HELPER_FLAGS_4(mve_vqrdmulhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqrdmulhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqrdmulhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqaddsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqaddsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqaddsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vqaddub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqadduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqadduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vqsubsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqsubsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqsubsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vqsubub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqsubuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqsubuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)DEF_HELPER_FLAGS_4 (mve_vadd_scalarw,TCG_CALL_NO_WG , void, env, ptr, ptr, i32)
target/arm/mve.decode +5 -0
@@ -116,6 +116,11 @@ VMULL_TU 111 1 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op VQDMULH 1110 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op VQRDMULH 1111 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op +VQADD_S 111 0 1111 0 . .. ... 0 ... 0 0000 . 1 . 1 ... 0 @2op +VQADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 1 ... 0 @2op +VQSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op +VQSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +14 -0
@@ -550,6 +550,20 @@ DO_2OP_SAT(vqrdmulhb, 1, int8_t, H1, DO_QRDMULH_B) DO_2OP_SAT(vqrdmulhh, 2, int16_t, H2, DO_QRDMULH_H) DO_2OP_SAT(vqrdmulhw, 4, int32_t, H4, DO_QRDMULH_W) +DO_2OP_SAT(vqaddub, 1, uint8_t, H1, DO_UQADD_B) +DO_2OP_SAT(vqadduh, 2, uint16_t, H2, DO_UQADD_H) +DO_2OP_SAT(vqadduw, 4, uint32_t, H4, DO_UQADD_W) +DO_2OP_SAT(vqaddsb, 1, int8_t, H1, DO_SQADD_B) +DO_2OP_SAT(vqaddsh, 2, int16_t, H2, DO_SQADD_H) +DO_2OP_SAT(vqaddsw, 4, int32_t, H4, DO_SQADD_W) + +DO_2OP_SAT(vqsubub, 1, uint8_t, H1, DO_UQSUB_B) +DO_2OP_SAT(vqsubuh, 2, uint16_t, H2, DO_UQSUB_H) +DO_2OP_SAT(vqsubuw, 4, uint32_t, H4, DO_UQSUB_W) +DO_2OP_SAT(vqsubsb, 1, int8_t, H1, DO_SQSUB_B) +DO_2OP_SAT(vqsubsh, 2, int16_t, H2, DO_SQSUB_H) +DO_2OP_SAT(vqsubsw, 4, int32_t, H4, DO_SQSUB_W) +#define DO_2OP_SCALAR (OP ,ESIZE ,TYPE ,H ,FN ) \ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ uint32_t rm) \
target/arm/translate-mve.c +4 -0
@@ -417,6 +417,10 @@ DO_2OP(VMULL_TS, vmullts) DO_2OP(VMULL_TU, vmulltu) DO_2OP(VQDMULH, vqdmulh) DO_2OP(VQRDMULH, vqrdmulh) +DO_2OP(VQADD_S, vqadds) +DO_2OP(VQADD_U, vqaddu) +DO_2OP(VQSUB_S, vqsubs) +DO_2OP(VQSUB_U, vqsubu)static bool do_2op_scalar (DisasContext *s,arg_2scalar *a,MVEGenTwoOpScalarFn fn)
Signature · 1 line
2.20.1
Re: [PATCH 42/55] target/arm: Implement MVE VQADD, VQSUB (vector)
Quoted 10 lines · Peter Maydell
Implement the vector forms of the MVE VQADD and VQSUB insns.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 16 ++++++++++++++++ target/arm/mve.decode | 5 +++++ target/arm/mve_helper.c | 14 ++++++++++++++ target/arm/translate-mve.c | 4 ++++ 4 files changed, 39 insertions(+)
r~
PATCH 43/55 target/arm: Implement MVE VQSHL (vector)
In reply to Peter MaydellImplement the MVE VQSHL insn (encoding T4, which is the vector-shift-by-vector version).
The DO_SQSHL_OP and DO_UQSHL_OP macros here are derived from the neon_helper.c code for qshl_u{8,16,32} and qshl_s{8,16,32}.
--- target/arm/helper-mve.h | 8 +++++ target/arm/mve.decode | 12 +++++++ target/arm/mve_helper.c | 73 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 95 insertions(+)
target/arm/helper-mve.h +8 -0
@@ -171,6 +171,14 @@ DEF_HELPER_FLAGS_4(mve_vqsubub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqsubuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqsubuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqshlsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqshlsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqshlsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vqshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)DEF_HELPER_FLAGS_4 (mve_vadd_scalarw,TCG_CALL_NO_WG , void, env, ptr, ptr, i32)
target/arm/mve.decode +12 -0
@@ -40,6 +40,15 @@ @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 +# The _rev suffix indicates that Vn and Vm are reversed. This is +# the case for shifts. In the Arm ARM these insns are documented +# with the Vm and Vn fields in their usual places, but in the +# assembly the operands are listed "backwards", ie in the order +# Qd, Qm, Qn where other insns use Qd, Qn, Qm. For QEMU we choose +# to consider Vm and Vn as being in different fields in the insn. +# This gives us consistency with A64 and Neon. +@2op_rev .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qn qn=%qm + @2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn @2scalar_nosz .... .... .... .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn
@@ -121,6 +130,9 @@ VQADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 1 ... 0 @2op VQSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op VQSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op +VQSHL_S 111 0 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev +VQSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +73 -0
85 lines not on this page · raw message
target/arm/translate-mve.c +2 -0
@@ -421,6 +421,8 @@ DO_2OP(VQADD_S, vqadds) DO_2OP(VQADD_U, vqaddu) DO_2OP(VQSUB_S, vqsubs) DO_2OP(VQSUB_U, vqsubu) +DO_2OP(VQSHL_S, vqshls) +DO_2OP(VQSHL_U, vqshlu)static bool do_2op_scalar (DisasContext *s,arg_2scalar *a,MVEGenTwoOpScalarFn fn)
Signature · 1 line
2.20.1
Re: [PATCH 43/55] target/arm: Implement MVE VQSHL (vector)
Quoted 5 lines · Peter Maydell
Implement the MVE VQSHL insn (encoding T4, which is the vector-shift-by-vector version).
The
DO_SQSHL_OPandDO_UQSHL_OPmacros here are derived from theneon_helper.ccode for qshl_u{8,16,32} and qshl_s{8,16,32}.
Ah, from before the sve2 merge, and associated cleanup. There are now helper functions in vec_internal.h for this.
The decode looks fine.
r~
Re: [PATCH 43/55] target/arm: Implement MVE VQSHL (vector)
Quoted 10 lines · Richard Henderson
Quoted 5 lines · Peter Maydell
Implement the MVE VQSHL insn (encoding T4, which is the vector-shift-by-vector version).
The
DO_SQSHL_OPandDO_UQSHL_OPmacros here are derived from theneon_helper.ccode for qshl_u{8,16,32} and qshl_s{8,16,32}.Ah, from before the sve2 merge, and associated cleanup. There are now helper functions in
vec_internal.hfor this.
Ah, that's helpful. Annoyingly, the helper wants to take a uint32_t* for the "write to this when saturating" argument, and I have a bool*...
-- PMM
PATCH 44/55 target/arm: Implement MVE VQRSHL
In reply to Peter MaydellImplement the MV VQRSHL (vector) insn. Again, the code to perform the actual shifts is borrowed from neon_helper.c.
--- target/arm/helper-mve.h | 8 +++ target/arm/mve.decode | 3 + target/arm/mve_helper.c | 127 +++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 2 + 4 files changed, 140 insertions(+)
target/arm/helper-mve.h +8 -0
@@ -179,6 +179,14 @@ DEF_HELPER_FLAGS_4(mve_vqshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrshlsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrshlsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrshlsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vqrshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)DEF_HELPER_FLAGS_4 (mve_vadd_scalarw,TCG_CALL_NO_WG , void, env, ptr, ptr, i32)
target/arm/mve.decode +3 -0
@@ -133,6 +133,9 @@ VQSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op VQSHL_S 111 0 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev VQSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev +VQRSHL_S 111 0 1111 0 . .. ... 0 ... 0 0101 . 1 . 1 ... 0 @2op_rev +VQRSHL_U 111 1 1111 0 . .. ... 0 ... 0 0101 . 1 . 1 ... 0 @2op_rev + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +127 -0
133 lines not on this page · raw message
target/arm/translate-mve.c +2 -0
@@ -423,6 +423,8 @@ DO_2OP(VQSUB_S, vqsubs) DO_2OP(VQSUB_U, vqsubu) DO_2OP(VQSHL_S, vqshls) DO_2OP(VQSHL_U, vqshlu) +DO_2OP(VQRSHL_S, vqrshls) +DO_2OP(VQRSHL_U, vqrshlu)static bool do_2op_scalar (DisasContext *s,arg_2scalar *a,MVEGenTwoOpScalarFn fn)
Signature · 1 line
2.20.1
Re: [PATCH 44/55] target/arm: Implement MVE VQRSHL
Quoted 2 lines · Peter Maydell
Implement the MV VQRSHL (vector) insn. Again, the code to perform the actual shifts is borrowed from
neon_helper.c.
Again, there are helpers in vec_internal.h now.
Otherwise,
r~
PATCH 45/55 target/arm: Implement MVE VSHL insn
In reply to Peter MaydellImplement the MVE VSHL insn (vector form).
--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 30 ++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 43 insertions(+)
target/arm/helper-mve.h +8 -0
@@ -171,6 +171,14 @@ DEF_HELPER_FLAGS_4(mve_vqsubub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqsubuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqsubuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vshlsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vshlsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vshlsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + DEF_HELPER_FLAGS_4(mve_vqshlsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqshlsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr)DEF_HELPER_FLAGS_4 (mve_vqshlsw,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr)
target/arm/mve.decode +3 -0
@@ -130,6 +130,9 @@ VQADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 1 ... 0 @2op VQSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op VQSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op +VSHL_S 111 0 1111 0 . .. ... 0 ... 0 0100 . 1 . 0 ... 0 @2op_rev +VSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 0 ... 0 @2op_rev + VQSHL_S 111 0 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev VQSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev
target/arm/mve_helper.c +30 -0
@@ -508,6 +508,36 @@ DO_2OP_U(vhaddu, do_vhadd_u) DO_2OP_S(vhsubs, do_vhsub_s) DO_2OP_U(vhsubu, do_vhsub_u) +static inline uint32_t do_ushl (uint32_t n,int8_t shift,int esize) +{ +if (shift >= esize || shift <= -esize) { +return 0 ; + }else if (shift <0 ) { +return n >> -shift; + }else { +return n << shift; + } +} + +static inline int32_t do_sshl (int32_t n,int8_t shift,int esize) +{ +if (shift >= esize) { +return 0 ; + }else if (shift <= -esize) { +return n >> (esize -1 ); + }else if (shift <0 ) { +return n >> -shift; + }else { +return n << shift; + } +} + +#define DO_VSHLS (N ,M ) do_sshl(N, M, sizeof(N) * 8) +#define DO_VSHLU (N ,M ) do_ushl(N, M, sizeof(N) * 8) + +DO_2OP_S(vshls, DO_VSHLS) +DO_2OP_U(vshlu, DO_VSHLU) +static inline int32_t do_sat_bhw (int64_t val,int64_t min,int64_t max,bool *s) {if (val > max) {
target/arm/translate-mve.c +2 -0
@@ -421,6 +421,8 @@ DO_2OP(VQADD_S, vqadds) DO_2OP(VQADD_U, vqaddu) DO_2OP(VQSUB_S, vqsubs) DO_2OP(VQSUB_U, vqsubu) +DO_2OP(VSHL_S, vshls) +DO_2OP(VSHL_U, vshlu) DO_2OP(VQSHL_S, vqshls) DO_2OP(VQSHL_U, vqshlu)DO_2OP (VQRSHL_S , vqrshls)
Signature · 1 line
2.20.1
Re: [PATCH 45/55] target/arm: Implement MVE VSHL insn
target/arm/mve_helper.c DO_2OP_U(vhaddu, do_vhadd_u) · line 520
Quoted 10 lines · Peter Maydell
target/arm/mve_helper.c +10
-0+static inline uint32_t do_ushl (uint32_t n,int8_t shift,int esize) +{ +if (shift >= esize || shift <= -esize) { +return 0 ; + }else if (shift <0 ) { +return n >> -shift; + }else { +return n << shift; + } +}
Current form uses the helpers.
#define NEON_FN(dest, src1, src2) \
(dest = do_uqrshl_bhs(src1, (int8_t)src2, 16, false, NULL))NEON_VOP(shl_u16, neon_u16, 2)
#undef NEON_FN
etc. Otherwise,
r~
PATCH 46/55 target/arm: Implement MVE VRSHL
In reply to Peter MaydellImplement the MVE VRSHL insn (vector form).
--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 36 ++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 49 insertions(+)
target/arm/helper-mve.h +8 -0
@@ -179,6 +179,14 @@ DEF_HELPER_FLAGS_4(mve_vshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrshlsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrshlsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrshlsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vrshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + DEF_HELPER_FLAGS_4(mve_vqshlsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqshlsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr)DEF_HELPER_FLAGS_4 (mve_vqshlsw,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr)
target/arm/mve.decode +3 -0
@@ -133,6 +133,9 @@ VQSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op VSHL_S 111 0 1111 0 . .. ... 0 ... 0 0100 . 1 . 0 ... 0 @2op_rev VSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 0 ... 0 @2op_rev +VRSHL_S 111 0 1111 0 . .. ... 0 ... 0 0101 . 1 . 0 ... 0 @2op_rev +VRSHL_U 111 1 1111 0 . .. ... 0 ... 0 0101 . 1 . 0 ... 0 @2op_rev + VQSHL_S 111 0 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev VQSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev
target/arm/mve_helper.c +36 -0
@@ -538,6 +538,42 @@ static inline int32_t do_sshl(int32_t n, int8_t shift, int esize) DO_2OP_S(vshls, DO_VSHLS) DO_2OP_U(vshlu, DO_VSHLU) +static inline uint32_t do_urshl (uint32_t n,int8_t shift,int esize) +{ +if (shift >= esize || shift < -esize) { +return 0 ; + }else if (shift == -esize) { +return n >> (-esize -1 ); + }else if (shift <0 ) { +/* Use 64 bit intermediate: adding the rounding const might overflow */ +uint64_t r = (uint64_t )n + (1 << (-1 - shift)); +return r >> -shift; + }else { +return n << shift; + } +} + +static inline int32_t do_srshl (int32_t n,int8_t shift,int esize) +{ +if (shift >= esize || shift <= -esize) { +return 0 ; + }else if (shift == -esize) { +return n >> (-esize -1 ); + }else if (shift <0 ) { +/* Use 64 bit intermediate: adding the rounding const might overflow */ +int64_t r = (int64_t )n + (1 << (-1 - shift)); +return r >> -shift; + }else { +return n << shift; + } +} + +#define DO_VRSHLS (N ,M ) do_srshl(N, M, sizeof(N) * 8) +#define DO_VRSHLU (N ,M ) do_urshl(N, M, sizeof(N) * 8) + +DO_2OP_S(vrshls, DO_VRSHLS) +DO_2OP_U(vrshlu, DO_VRSHLU) +static inline int32_t do_sat_bhw (int64_t val,int64_t min,int64_t max,bool *s) {if (val > max) {
target/arm/translate-mve.c +2 -0
@@ -423,6 +423,8 @@ DO_2OP(VQSUB_S, vqsubs) DO_2OP(VQSUB_U, vqsubu) DO_2OP(VSHL_S, vshls) DO_2OP(VSHL_U, vshlu) +DO_2OP(VRSHL_S, vrshls) +DO_2OP(VRSHL_U, vrshlu) DO_2OP(VQSHL_S, vqshls) DO_2OP(VQSHL_U, vqshlu)DO_2OP (VQRSHL_S , vqrshls)
Signature · 1 line
2.20.1
Re: [PATCH 46/55] target/arm: Implement MVE VRSHL
Quoted 9 lines · Peter Maydell
Implement the MVE VRSHL insn (vector form).
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 36 ++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 49 insertions(+)
Similarly use vec_internal.h. Otherwise,
r~
PATCH 47/55 target/arm: Implement MVE VQDMLADH and VQRDMLADH
In reply to Peter MaydellImplement the MVE VQDMLADH and VQRDMLADH insns. These multiply elements, and then add pairs of products, double, possibly round, saturate and return the high half of the result.
--- target/arm/helper-mve.h | 16 +++++++ target/arm/mve.decode | 5 +++ target/arm/mve_helper.c | 87 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 4 ++ 4 files changed, 112 insertions(+)
target/arm/helper-mve.h +16 -0
@@ -203,6 +203,22 @@ DEF_HELPER_FLAGS_4(mve_vqrshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqrshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqrshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmladhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmladhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmladhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vqdmladhxb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmladhxh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmladhxw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vqrdmladhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrdmladhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrdmladhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vqrdmladhxb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrdmladhxh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrdmladhxw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)DEF_HELPER_FLAGS_4 (mve_vadd_scalarw,TCG_CALL_NO_WG , void, env, ptr, ptr, i32)
target/arm/mve.decode +5 -0
@@ -142,6 +142,11 @@ VQSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev VQRSHL_S 111 0 1111 0 . .. ... 0 ... 0 0101 . 1 . 1 ... 0 @2op_rev VQRSHL_U 111 1 1111 0 . .. ... 0 ... 0 0101 . 1 . 1 ... 0 @2op_rev +VQDMLADH 1110 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 0 @2op +VQDMLADHX 1110 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 0 @2op +VQRDMLADH 1110 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 1 @2op +VQRDMLADHX 1110 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +87 -0
93 lines not on this page · raw message
target/arm/translate-mve.c +4 -0
@@ -429,6 +429,10 @@ DO_2OP(VQSHL_S, vqshls) DO_2OP(VQSHL_U, vqshlu) DO_2OP(VQRSHL_S, vqrshls) DO_2OP(VQRSHL_U, vqrshlu) +DO_2OP(VQDMLADH, vqdmladh) +DO_2OP(VQDMLADHX, vqdmladhx) +DO_2OP(VQRDMLADH, vqrdmladh) +DO_2OP(VQRDMLADHX, vqrdmladhx)static bool do_2op_scalar (DisasContext *s,arg_2scalar *a,MVEGenTwoOpScalarFn fn)
Signature · 1 line
2.20.1
Re: [PATCH 47/55] target/arm: Implement MVE VQDMLADH and VQRDMLADH
Quoted 11 lines · Peter Maydell
target/arm/mve_helper.c +11
-0+static int32_t do_vqdmladh_w (int32_t a,int32_t b,int32_t c,int32_t d, +int round,bool *sat) +{ +int64_t m1 = (int64_t )a * b; +int64_t m2 = (int64_t )c * d; +int64_t r; +/* +* Architecturally we should do the entire add, double, round +* and then check for saturation. We do three saturating adds, +* but we need to be careful about the order. If the first +* m1 + m2 saturates then it's impossible for the *2+rc to
target/arm/mve_helper.c DO_2OP_SAT(vqrshlsb, 1, int8_t, H1, DO_SQRSHL_OP) · line 899
Quoted 10 lines
target/arm/mve_helper.c +10
-0+* bring it back into the non-saturated range. However, if +* m1 + m2 is negative then it's possible that doing the doubling +* would take the intermediate result below INT64_MAX and the +* addition of the rounding constant then brings it back in range. +* So we add half the rounding constant before doubling rather +* than adding the rounding constant after the doubling. +*/ +if (sadd64_overflow (m1, m2, &r) || +sadd64_overflow (r, (round <<30 ), &r) || +sadd64_overflow (r, r, &r)) {
Ooh, ahh, an operation that doesn't even exist in SVE2. Nice use of the new interface, btw.
r~
PATCH 48/55 target/arm: Implement MVE VQDMLSDH and VQRDMLSDH
In reply to Peter MaydellImplement the MVE VQDMLSDH and VQRDMLSDH insns, which are like VQDMLADH and VQRDMLADH except that products are subtracted rather than added.
--- target/arm/helper-mve.h | 16 ++++++++++++++ target/arm/mve.decode | 5 +++++ target/arm/mve_helper.c | 44 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 4 ++++ 4 files changed, 69 insertions(+)
target/arm/helper-mve.h +16 -0
@@ -219,6 +219,22 @@ DEF_HELPER_FLAGS_4(mve_vqrdmladhxb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqrdmladhxh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqrdmladhxw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmlsdhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmlsdhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmlsdhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vqdmlsdhxb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmlsdhxh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmlsdhxw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vqrdmlsdhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrdmlsdhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrdmlsdhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vqrdmlsdhxb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrdmlsdhxh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqrdmlsdhxw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)DEF_HELPER_FLAGS_4 (mve_vadd_scalarw,TCG_CALL_NO_WG , void, env, ptr, ptr, i32)
target/arm/mve.decode +5 -0
@@ -147,6 +147,11 @@ VQDMLADHX 1110 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 0 @2op VQRDMLADH 1110 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 1 @2op VQRDMLADHX 1110 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op +VQDMLSDH 1111 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 0 @2op +VQDMLSDHX 1111 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 0 @2op +VQRDMLSDH 1111 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 1 @2op +VQRDMLSDHX 1111 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +44 -0
56 lines not on this page · raw message
target/arm/translate-mve.c +4 -0
@@ -433,6 +433,10 @@ DO_2OP(VQDMLADH, vqdmladh) DO_2OP(VQDMLADHX, vqdmladhx) DO_2OP(VQRDMLADH, vqrdmladh) DO_2OP(VQRDMLADHX, vqrdmladhx) +DO_2OP(VQDMLSDH, vqdmlsdh) +DO_2OP(VQDMLSDHX, vqdmlsdhx) +DO_2OP(VQRDMLSDH, vqrdmlsdh) +DO_2OP(VQRDMLSDHX, vqrdmlsdhx)static bool do_2op_scalar (DisasContext *s,arg_2scalar *a,MVEGenTwoOpScalarFn fn)
Signature · 1 line
2.20.1
Re: [PATCH 48/55] target/arm: Implement MVE VQDMLSDH and VQRDMLSDH
Quoted 11 lines · Peter Maydell
Implement the MVE VQDMLSDH and VQRDMLSDH insns, which are like VQDMLADH and VQRDMLADH except that products are subtracted rather than added.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 16 ++++++++++++++ target/arm/mve.decode | 5 +++++ target/arm/mve_helper.c | 44 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 4 ++++ 4 files changed, 69 insertions(+)
r~
PATCH 49/55 target/arm: Implement MVE VQDMULL (vector)
In reply to Peter MaydellImplement the vector form of the MVE VQDMULL insn.
--- target/arm/helper-mve.h | 5 +++++ target/arm/mve.decode | 5 +++++ target/arm/mve_helper.c | 30 ++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+)
target/arm/helper-mve.h +5 -0
@@ -235,6 +235,11 @@ DEF_HELPER_FLAGS_4(mve_vqrdmlsdhxb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqrdmlsdhxh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqrdmlsdhxw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmullbh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmullbw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmullth, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vqdmulltw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)DEF_HELPER_FLAGS_4 (mve_vadd_scalarw,TCG_CALL_NO_WG , void, env, ptr, ptr, i32)
target/arm/mve.decode +5 -0
@@ -39,6 +39,8 @@ @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 +@2op_sz28 .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn \ + size=%size_28 # The _rev suffix indicates that Vn and Vm are reversed. This is # the case for shifts. In the Arm ARM these insns are documented
@@ -152,6 +154,9 @@ VQDMLSDHX 1111 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 0 @2op VQRDMLSDH 1111 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 1 @2op VQRDMLSDHX 1111 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op +VQDMULLB 111 . 1110 0 . 11 ... 0 ... 0 1111 . 0 . 0 ... 1 @2op_sz28 +VQDMULLT 111 . 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 1 @2op_sz28 + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +30 -0
@@ -1103,6 +1103,36 @@ DO_2OP_SAT_SCALAR_L(vqdmullt_scalarh, 1, int16_t, H2, 4, int32_t, H4, \ DO_2OP_SAT_SCALAR_L(vqdmullt_scalarw, 1, int32_t, H4, 8, int64_t, , \ do_qdmullw,SATMASK32 ) +/* +* Long saturating ops + */ +#define DO_2OP_SAT_L (OP ,TOP ,TYPE ,H ,LESIZE ,LTYPE ,LH ,FN ,SATMASK ) \ + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ + void *vm) \ + { \ + LTYPE *d = vd; \ + TYPE *n = vn, *m = vm; \ + uint16_t mask = mve_element_mask(env); \ + unsigned le; \ + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ + bool sat = false; \ + LTYPE op1 = n[H(le * 2 + TOP)], op2 = m[H(le * 2 + TOP)]; \ + LTYPE r = FN(op1, op2, &sat); \ + uint64_t bytemask = mask_to_bytemask##LESIZE(mask); \ + d[LH(le)] &= ~bytemask; \ + d[LH(le)] |= (r & bytemask); \ + if (sat && (mask & SATMASK)) { \ + env->vfp.qc[0] = 1; \ + } \ + } \ + mve_advance_vpt(env); \ + } + +DO_2OP_SAT_L(vqdmullbh, 0, int16_t, H2, 4, int32_t, H4, do_qdmullh, SATMASK16B) +DO_2OP_SAT_L(vqdmullbw, 0, int32_t, H4, 8, int64_t, , do_qdmullw, SATMASK32) +DO_2OP_SAT_L(vqdmullth, 1, int16_t, H2, 4, int32_t, H4, do_qdmullh, SATMASK16T) +DO_2OP_SAT_L(vqdmulltw, 1, int32_t, H4, 8, int64_t, , do_qdmullw, SATMASK32) +static inline uint32_t do_vbrsrb (uint32_t n,uint32_t m) { m &=0xff ;
target/arm/translate-mve.c +30 -0
@@ -438,6 +438,36 @@ DO_2OP(VQDMLSDHX, vqdmlsdhx) DO_2OP(VQRDMLSDH, vqrdmlsdh) DO_2OP(VQRDMLSDHX, vqrdmlsdhx) +static bool trans_VQDMULLB (DisasContext *s,arg_2op *a) +{ +MVEGenTwoOpFn *fns[] = { +NULL , + gen_helper_mve_vqdmullbh, + gen_helper_mve_vqdmullbw, +NULL , + }; +if (a->size ==MO_32 && (a->qd == a->qm || a->qd == a->qn)) { +/* UNPREDICTABLE; we choose to undef */ +return false; + } +return do_2op (s, a, fns[a->size]); +} + +static bool trans_VQDMULLT (DisasContext *s,arg_2op *a) +{ +MVEGenTwoOpFn *fns[] = { +NULL , + gen_helper_mve_vqdmullth, + gen_helper_mve_vqdmulltw, +NULL , + }; +if (a->size ==MO_32 && (a->qd == a->qm || a->qd == a->qn)) { +/* UNPREDICTABLE; we choose to undef */ +return false; + } +return do_2op (s, a, fns[a->size]); +} +static bool do_2op_scalar (DisasContext *s,arg_2scalar *a,MVEGenTwoOpScalarFn fn) {
Signature · 1 line
2.20.1
Re: [PATCH 49/55] target/arm: Implement MVE VQDMULL (vector)
target/arm/mve.decode line 43
Quoted 7 lines · Peter Maydell
+++ b/target/arm/mve.decode
target/arm/mve.decode +2
-0@@ -39,6 +39,8 @@ @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 +@2op_sz28 .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn \ + size=%size_28
Move this back to VQDMULL[BT]_scalar, I think.
Otherwise,
r~
Re: [PATCH 49/55] target/arm: Implement MVE VQDMULL (vector)
Quoted 11 lines · Richard Henderson
target/arm/mve.decode line 43
Quoted 7 lines · Peter Maydell
+++ b/target/arm/mve.decode
target/arm/mve.decode +2
-0@@ -39,6 +39,8 @@ @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 +@2op_sz28 .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn \ + size=%size_28Move this back to VQDMULL[BT]_scalar, I think.
Why? VQDMULL[BT]_scalar uses an entirely different format (as a scalar it uses the &2scalar arg struct with an rm field for the gp register).
-- PMM
Re: [PATCH 49/55] target/arm: Implement MVE VQDMULL (vector)
Quoted 14 lines · Peter Maydell
Quoted 11 lines · Richard Henderson
target/arm/mve.decode line 43
Quoted 7 lines · Peter Maydell
+++ b/target/arm/mve.decode
target/arm/mve.decode +2
-0@@ -39,6 +39,8 @@ @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 +@2op_sz28 .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn \ + size=%size_28Move this back to VQDMULL[BT]_scalar, I think.
Quoted 3 lines
Why? VQDMULL[BT]_scalar uses an entirely different format (as a scalar it uses the &2scalar arg struct with an rm field for the gp register).
Oops, mis-read the @2op vs @2scalar. Sorry.
r~
PATCH 50/55 target/arm: Implement MVE VRHADD
In reply to Peter MaydellImplement the MVE VRHADD insn, which performs a rounded halving addition.
--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 6 ++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 19 insertions(+)
target/arm/helper-mve.h +8 -0
@@ -240,6 +240,14 @@ DEF_HELPER_FLAGS_4(mve_vqdmullbw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqdmullth, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vqdmulltw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrhaddsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrhaddsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrhaddsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vrhaddub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrhadduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vrhadduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)DEF_HELPER_FLAGS_4 (mve_vadd_scalarw,TCG_CALL_NO_WG , void, env, ptr, ptr, i32)
target/arm/mve.decode +3 -0
@@ -157,6 +157,9 @@ VQRDMLSDHX 1111 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op VQDMULLB 111 . 1110 0 . 11 ... 0 ... 0 1111 . 0 . 0 ... 1 @2op_sz28 VQDMULLT 111 . 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 1 @2op_sz28 +VRHADD_S 111 0 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op +VRHADD_U 111 1 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +6 -0
@@ -574,6 +574,12 @@ static inline int32_t do_srshl(int32_t n, int8_t shift, int esize) DO_2OP_S(vrshls, DO_VRSHLS) DO_2OP_U(vrshlu, DO_VRSHLU) +#define DO_RHADD_S (N ,M ) (((int64_t)(N) + (M) + 1) >> 1) +#define DO_RHADD_U (N ,M ) (((uint64_t)(N) + (M) + 1) >> 1) + +DO_2OP_S(vrhadds, DO_RHADD_S) +DO_2OP_U(vrhaddu, DO_RHADD_U) +static inline int32_t do_sat_bhw (int64_t val,int64_t min,int64_t max,bool *s) {if (val > max) {
target/arm/translate-mve.c +2 -0
@@ -437,6 +437,8 @@ DO_2OP(VQDMLSDH, vqdmlsdh) DO_2OP(VQDMLSDHX, vqdmlsdhx) DO_2OP(VQRDMLSDH, vqrdmlsdh) DO_2OP(VQRDMLSDHX, vqrdmlsdhx) +DO_2OP(VRHADD_S, vrhadds) +DO_2OP(VRHADD_U, vrhaddu)static bool trans_VQDMULLB (DisasContext *s,arg_2op *a) {
Signature · 1 line
2.20.1
Re: [PATCH 50/55] target/arm: Implement MVE VRHADD
Quoted 10 lines · Peter Maydell
Implement the MVE VRHADD insn, which performs a rounded halving addition.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 3 +++ target/arm/mve_helper.c | 6 ++++++ target/arm/translate-mve.c | 2 ++ 4 files changed, 19 insertions(+)
r~
PATCH 51/55 target/arm: Implement MVE VADC, VSBC
In reply to Peter MaydellImplement the MVE VADC and VSBC insns. These perform an add-with-carry or subtract-with-carry of the 32-bit elements in each lane of the input vectors, where the carry-out of each add is the carry-in of the next. The initial carry input is either 1 or is from FPSCR.C; the carry out at the end is written back to FPSCR.C.
--- target/arm/helper-mve.h | 3 ++ target/arm/mve.decode | 6 ++++ target/arm/mve_helper.c | 30 +++++++++++++++++ target/arm/translate-mve.c | 69 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+)
target/arm/helper-mve.h +3 -0
@@ -248,6 +248,9 @@ DEF_HELPER_FLAGS_4(mve_vrhaddub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vrhadduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vrhadduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_5(mve_vadc, TCG_CALL_NO_WG, i32, env, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(mve_vsbc, TCG_CALL_NO_WG, i32, env, ptr, ptr, ptr, i32) + DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)DEF_HELPER_FLAGS_4 (mve_vadd_scalarw,TCG_CALL_NO_WG , void, env, ptr, ptr, i32)
target/arm/mve.decode +6 -0
@@ -30,6 +30,7 @@ &1op qd qm size &2op qd qm qn size &2scalar qd qn rm size +&vadc qd qm qn i @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 # Note that both Rn and Qd are 3 bits only (no D bit)
@@ -42,6 +43,8 @@ @2op_sz28 .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn \ size=%size_28 +@vadc .... .... .... .... ... i:1 .... .... .... &vadc qd=%qd qm=%qm qn=%qn + # The _rev suffix indicates that Vn and Vm are reversed. This is # the case for shifts. In the Arm ARM these insns are documented # with the Vm and Vn fields in their usual places, but in the
@@ -160,6 +163,9 @@ VQDMULLT 111 . 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 1 @2op_sz28 VRHADD_S 111 0 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op VRHADD_U 111 1 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op +VADC 1110 1110 0 . 11 ... 0 ... . 1111 . 0 . 0 ... 0 @vadc +VSBC 1111 1110 0 . 11 ... 0 ... . 1111 . 0 . 0 ... 0 @vadc + # Vector miscellaneous VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op
target/arm/mve_helper.c +30 -0
@@ -580,6 +580,36 @@ DO_2OP_U(vrshlu, DO_VRSHLU) DO_2OP_S(vrhadds, DO_RHADD_S) DO_2OP_U(vrhaddu, DO_RHADD_U) +#define DO_VADC (OP ,INV ) \ + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ + void *vn, void *vm, uint32_t nzcv) \ + { \ + uint32_t *d = vd, *n = vn, *m = vm; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + int carry = (nzcv & FPCR_C) ? 1 : 0; \ +/* If we do no additions at all the flags are preserved */ \ +bool updates_flags = (mask &0x1111 ) !=0 ; \ +for (e =0 ; e <16 /4 ; e++, mask >>=4 ) { \ +uint64_t r = (uint64_t )n[H4 (e)] +INV (m[H4 (e)]) + carry; \ +if (mask &1 ) { \ + carry = r >>32 ; \ + } \ +uint64_t bytemask =mask_to_bytemask4 (mask); \ + d[H4 (e)] &= ~bytemask; \ + d[H4 (e)] |= (r & bytemask); \ + } \ +mve_advance_vpt (env); \ +if (updates_flags) { \ + nzcv = carry ?FPCR_C :0 ; \ + } \ +return nzcv; \ + } + +/* VSBC differs only in inverting op2 before the additiona */ +DO_VADC(vadc, ) +DO_VADC(vsbc, DO_NOT) + static inline int32_t do_sat_bhw(int64_t val, int64_t min, int64_t max, bool *s) { if (val > max) {
target/arm/translate-mve.c +69 -0
78 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 51/55] target/arm: Implement MVE VADC, VSBC
Quoted 25 lines · Peter Maydell
target/arm/mve_helper.c +25
-0+#define DO_VADC (OP ,INV ) \ + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ + void *vn, void *vm, uint32_t nzcv) \ + { \ + uint32_t *d = vd, *n = vn, *m = vm; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + int carry = (nzcv & FPCR_C) ? 1 : 0; \ +/* If we do no additions at all the flags are preserved */ \ +bool updates_flags = (mask &0x1111 ) !=0 ; \ +for (e =0 ; e <16 /4 ; e++, mask >>=4 ) { \ +uint64_t r = (uint64_t )n[H4 (e)] +INV (m[H4 (e)]) + carry; \ +if (mask &1 ) { \ + carry = r >>32 ; \ + } \ +uint64_t bytemask =mask_to_bytemask4 (mask); \ + d[H4 (e)] &= ~bytemask; \ + d[H4 (e)] |= (r & bytemask); \ + } \ +mve_advance_vpt (env); \ +if (updates_flags) { \ + nzcv = carry ?FPCR_C :0 ; \ + } \ +return nzcv; \ + }
...
Quoted 12 lines
target/arm/translate-mve.c +12
-0+/* +* This insn is subject to beat-wise execution. Partial execution +* of an I=1 (initial carry input fixed) insn which does not +* execute the first beat must start with the current FPSCR.NZCV +* value, not the fixed constant input. +*/ +if (a->i && !mve_skip_first_beat (s)) { +/* Carry input is 0 (VADCI) or 1 (VSBCI), NZV zeroed */ + nzcv =tcg_const_i32 (fixed_carry); + }else { +/* Carry input from existing NZCV flag values */ + nzcv =load_cpu_field (vfp.xregs[ARM_VFP_FPSCR ]);
target/arm/translate-mve.c static bool trans_VPST(DisasContext *s, arg_VPST *a) · line 791
Quoted 10 lines
target/arm/translate-mve.c +10
-0+tcg_gen_andi_i32 (nzcv, nzcv,FPCR_NZCV_MASK ); + } + qd =mve_qreg_ptr (a->qd); + qn =mve_qreg_ptr (a->qn); + qm =mve_qreg_ptr (a->qm); +fn (nzcv, cpu_env, qd, qn, qm, nzcv); + fpscr =load_cpu_field (vfp.xregs[ARM_VFP_FPSCR ]); +tcg_gen_andi_i32 (fpscr, fpscr, ~FPCR_NZCV_MASK ); +tcg_gen_or_i32 (fpscr, fpscr, nzcv); +store_cpu_field (fpscr, vfp.xregs[ARM_VFP_FPSCR ]);
Hmm. It seems like you're having to work extra hard in tcg to extract and store nzcv.
How about four helper functions instead of 2. E.g.
static void do_vadc(CPUARMState *env, uint32_t *d,
uint32_t *n, uint32_t *m,
uint32_t inv, uint32_t carry_in,
bool update_flags)
{
uint16_t mask = mve_element_mask(env);
unsigned e;
/* If any additions trigger, we will update flags. */
if (mask & 0x1111) {
update_flags = true;
}
for (e = 0; e < 16 / 4; e++, mask >>= 4) {
uint32_t bmask = mask_to_bytemask4(mask);
uint64_t r = carry_in;
r += n[H4(e)];
r += m[H4(e)] ^ inv;
if (mask & 1) {
carry_in = r >> 32;
}
d[H4(e)] = (d[H4(e)] & ~bmask) | ((uint32_t)r & bmask);
}
if (update_flags) {
/* Store C, clear NZV. */
env->vfp.xregs[ARM_VFP_FPSCR] &= ~FPCR_NZCV_MASK;
env->vfp.xregs[ARM_VFP_FPSCR] |= carry_in * FPCR_C;
}
mve_advance_vpt(env); }void HELPER(mve_vadc)(CPUARMState *env, void *vd,
void *vn, void *vm)
{
bool carry_in = env->vfp.xregs[ARM_VFP_FPSCR] & FPCR_C;
do_vadc(env, vd, vn, vm, 0, carry_in, false);
}void HELPER(mve_vsbc)(CPUARMState *env, void *vd,
void *vn, void *vm)
{
bool carry_in = env->vfp.xregs[ARM_VFP_FPSCR] & FPCR_C;
do_vadc(env, vd, vn, vm, -1, carry_in, false);
}void HELPER(mve_vadci)(CPUARMState *env, void *vd,
void *vn, void *vm)
{
do_vadc(env, vd, vn, vm, 0, 0, true);
}void HELPER(mve_vsbci)(CPUARMState *env, void *vd,
void *vn, void *vm)
{
do_vadc(env, vd, vn, vm, -1, 1, true);
}r~
PATCH 52/55 target/arm: Implement MVE VCADD
In reply to Peter MaydellImplement the MVE VCADD insn, which performs a complex add with rotate. Note that the size=0b11 encoding is VSBC.
The architecture grants some leeway for the "destination and Vm source overlap" case for the size MO_32 case, but we choose not to make use of it, instead always calculating all 16 bytes worth of results before setting the destination register.
--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 7 ++++++- target/arm/mve_helper.c | 31 +++++++++++++++++++++++++++++++ target/arm/translate-mve.c | 7 +++++++ 4 files changed, 52 insertions(+), 1 deletion(-)
target/arm/helper-mve.h +8 -0
@@ -251,6 +251,14 @@ DEF_HELPER_FLAGS_4(mve_vrhadduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_5(mve_vadc, TCG_CALL_NO_WG, i32, env, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_5(mve_vsbc, TCG_CALL_NO_WG, i32, env, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(mve_vcadd90b, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vcadd90h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vcadd90w, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vcadd270b, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vcadd270h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vcadd270w, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)DEF_HELPER_FLAGS_4 (mve_vadd_scalarw,TCG_CALL_NO_WG , void, env, ptr, ptr, i32)
target/arm/mve.decode +6 -1
@@ -164,7 +164,12 @@ VRHADD_S 111 0 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op VRHADD_U 111 1 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op VADC 1110 1110 0 . 11 ... 0 ... . 1111 . 0 . 0 ... 0 @vadc -VSBC 1111 1110 0 . 11 ... 0 ... . 1111 . 0 . 0 ... 0 @vadc + +{ + VCADD90 1111 1110 0 . .. ... 0 ... 0 1111 . 0 . 0 ... 0 @2op + VCADD270 1111 1110 0 . .. ... 0 ... 1 1111 . 0 . 0 ... 0 @2op + VSBC 1111 1110 0 . 11 ... 0 ... . 1111 . 0 . 0 ... 0 @vadc +} # Vector miscellaneous
target/arm/mve_helper.c +31 -0
@@ -610,6 +610,37 @@ DO_2OP_U(vrhaddu, DO_RHADD_U) DO_VADC(vadc, ) DO_VADC(vsbc, DO_NOT) +#define DO_VCADD(OP, ESIZE, TYPE, H, FN0, FN1) \ + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, void *vm) \ + { \ + TYPE *d = vd, *n = vn, *m = vm; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + TYPE r[16 / ESIZE]; \ + /* Calculate all results first to avoid overwriting inputs */ \ + for (e = 0; e < 16 / ESIZE; e++) { \ + if (!(e & 1)) { \ + r[e] = FN0(n[H(e)], m[H(e + 1)]); \ + } else { \ + r[e] = FN1(n[H(e)], m[H(e - 1)]); \ + } \ + } \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + uint64_t bytemask = mask_to_bytemask##ESIZE(mask); \ + d[H(e)] &= ~bytemask; \ + d[H(e)] |= (r[e] & bytemask); \ + } \ + mve_advance_vpt(env); \ + } + +#define DO_VCADD_ALL(OP, FN0, FN1) \ + DO_VCADD(OP##b, 1, int8_t, H1, FN0, FN1) \ + DO_VCADD(OP##h, 2, int16_t, H1, FN0, FN1) \ + DO_VCADD(OP##w, 4, int32_t, H1, FN0, FN1) + +DO_VCADD_ALL(vcadd90, DO_SUB, DO_ADD) +DO_VCADD_ALL(vcadd270, DO_ADD, DO_SUB) + static inline int32_t do_sat_bhw(int64_t val, int64_t min, int64_t max, bool *s) { if (val > max) {
target/arm/translate-mve.c +7 -0
@@ -440,6 +440,13 @@ DO_2OP(VQRDMLSDH, vqrdmlsdh) DO_2OP(VQRDMLSDHX, vqrdmlsdhx) DO_2OP(VRHADD_S, vrhadds)DO_2OP (VRHADD_U , vrhaddu) +/* +* VCADD Qd == Qm at size MO_32 is UNPREDICTABLE; we choose not to diagnose +* so we can reuse the DO_2OP macro. (Our implementation calculates the +* "expected" results in this case.) + */ +DO_2OP(VCADD90, vcadd90) +DO_2OP(VCADD270, vcadd270)static bool trans_VQDMULLB (DisasContext *s,arg_2op *a) {
Signature · 1 line
2.20.1
Re: [PATCH 52/55] target/arm: Implement MVE VCADD
Quoted 12 lines · Peter Maydell
target/arm/mve_helper.c +12
-0+#define DO_VCADD (OP ,ESIZE ,TYPE ,H ,FN0 ,FN1 ) \ + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, void *vm) \ + { \ + TYPE *d = vd, *n = vn, *m = vm; \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + TYPE r[16 / ESIZE]; \ +/* Calculate all results first to avoid overwriting inputs */ \ +for (e =0 ; e <16 /ESIZE ; e++) { \ +if (!(e &1 )) { \ + r[e] =FN0 (n[H (e)], m[H (e +1 )]); \ + }else { \
target/arm/mve_helper.c DO_2OP_U(vrhaddu, DO_RHADD_U) · line 634
Quoted 10 lines
target/arm/mve_helper.c +10
-0+ r[e] =FN1 (n[H (e)], m[H (e -1 )]); \ + } \ + } \ +for (e =0 ; e <16 /ESIZE ; e++, mask >>=ESIZE ) { \ + uint64_t bytemask = mask_to_bytemask##ESIZE(mask); \ + d[H (e)] &= ~bytemask; \ + d[H (e)] |= (r[e] & bytemask); \ + } \ +mve_advance_vpt (env); \ + }
I guess this is ok. You could unroll the loop once, so that you compute only even+odd results before writeback.
Quoted 5 lines
+/*
+ * VCADD Qd == Qm at sizeMO_32is UNPREDICTABLE; we choose not to diagnose
+ * so we can reuse theDO_2OPmacro. (Our implementation calculates the
+ * "expected" results in this case.)
+ */
You've done this elsewhere, though.
Either way,
r~
Re: [PATCH 52/55] target/arm: Implement MVE VCADD
Quoted 8 lines · Richard Henderson
Quoted 5 lines · Peter Maydell
+/*
+ * VCADD Qd == Qm at sizeMO_32is UNPREDICTABLE; we choose not to diagnose
+ * so we can reuse theDO_2OPmacro. (Our implementation calculates the
+ * "expected" results in this case.)
+ */You've done this elsewhere, though.
Yeah, because in those cases the op had to have its own hand-written trans_ function for other reasons so the check was easy to add. Hence the comment about why this particular case doesn't do that.
Quoted 2 lines
Either way,
Reviewed-by Richard Henderson <[email protected]>
thanks
-- PMM
PATCH 53/55 target/arm: Implement MVE VHCADD
In reply to Peter MaydellImplement the MVE VHCADD insn, which is similar to VCADD but performs a halving step. This one overlaps with VADC.
--- target/arm/helper-mve.h | 8 ++++++++ target/arm/mve.decode | 6 +++++- target/arm/mve_helper.c | 5 +++++ target/arm/translate-mve.c | 4 +++- 4 files changed, 21 insertions(+), 2 deletions(-)
target/arm/helper-mve.h +8 -0
@@ -259,6 +259,14 @@ DEF_HELPER_FLAGS_4(mve_vcadd270b, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vcadd270h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) DEF_HELPER_FLAGS_4(mve_vcadd270w, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhcadd90b, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhcadd90h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhcadd90w, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + +DEF_HELPER_FLAGS_4(mve_vhcadd270b, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhcadd270h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) +DEF_HELPER_FLAGS_4(mve_vhcadd270w, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) + DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)DEF_HELPER_FLAGS_4 (mve_vadd_scalarw,TCG_CALL_NO_WG , void, env, ptr, ptr, i32)
target/arm/mve.decode +5 -1
@@ -163,7 +163,11 @@ VQDMULLT 111 . 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 1 @2op_sz28 VRHADD_S 111 0 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op VRHADD_U 111 1 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op -VADC 1110 1110 0 . 11 ... 0 ... . 1111 . 0 . 0 ... 0 @vadc +{ + VHCADD90 1110 1110 0 . .. ... 0 ... 0 1111 . 0 . 0 ... 0 @2op + VHCADD270 1110 1110 0 . .. ... 0 ... 1 1111 . 0 . 0 ... 0 @2op + VADC 1110 1110 0 . 11 ... 0 ... . 1111 . 0 . 0 ... 0 @vadc +} { VCADD90 1111 1110 0 . .. ... 0 ... 0 1111 . 0 . 0 ... 0 @2op
target/arm/mve_helper.c +5 -0
@@ -638,8 +638,13 @@ DO_VADC(vsbc, DO_NOT) DO_VCADD(OP##h, 2, int16_t, H1, FN0, FN1) \ DO_VCADD(OP##w, 4, int32_t, H1, FN0, FN1) +#define DO_HADD (N ,M ) (((int64_t)(N) + (int64_t)(M)) >> 1) +#define DO_HSUB (N ,M ) (((int64_t)(N) - (int64_t)(M)) >> 1) + DO_VCADD_ALL(vcadd90, DO_SUB, DO_ADD) DO_VCADD_ALL(vcadd270, DO_ADD, DO_SUB) +DO_VCADD_ALL(vhcadd90, DO_HSUB, DO_HADD) +DO_VCADD_ALL(vhcadd270, DO_HADD, DO_HSUB)static inline int32_t do_sat_bhw (int64_t val,int64_t min,int64_t max,bool *s) {
target/arm/translate-mve.c +3 -1
@@ -443,10 +443,12 @@ DO_2OP(VRHADD_U, vrhaddu)/* * VCADD Qd == Qm at size MO_32 is UNPREDICTABLE; we choose not to diagnose * so we can reuse the DO_2OP macro. (Our implementation calculates the -* "expected" results in this case.) +* "expected" results in this case.) Similarly for VHCADD. */ DO_2OP(VCADD90, vcadd90) DO_2OP(VCADD270, vcadd270) +DO_2OP(VHCADD90, vhcadd90) +DO_2OP(VHCADD270, vhcadd270)static bool trans_VQDMULLB (DisasContext *s,arg_2op *a) {
Signature · 1 line
2.20.1
Re: [PATCH 53/55] target/arm: Implement MVE VHCADD
target/arm/mve_helper.c DO_VADC(vsbc, DO_NOT) · line 642
Quoted 2 lines · Peter Maydell
target/arm/mve_helper.c +2
-0+#define DO_HADD (N ,M ) (((int64_t)(N) + (int64_t)(M)) >> 1) +#define DO_HSUB (N ,M ) (((int64_t)(N) - (int64_t)(M)) >> 1)
You've already got do_vhadd_[us] defined from vadd[su]...
r~
PATCH 54/55 target/arm: Implement MVE VADDV
In reply to Peter MaydellImplement the MVE VADDV insn, which performs an addition across vector lanes.
--- target/arm/helper-mve.h | 7 ++++++ target/arm/mve.decode | 2 ++ target/arm/mve_helper.c | 24 +++++++++++++++++++ target/arm/translate-mve.c | 48 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+)
target/arm/helper-mve.h +7 -0
@@ -348,3 +348,10 @@ DEF_HELPER_FLAGS_4(mve_vrmlaldavhuw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) DEF_HELPER_FLAGS_4(mve_vrmlsldavhsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) DEF_HELPER_FLAGS_4(mve_vrmlsldavhxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) + +DEF_HELPER_FLAGS_3(mve_vaddvsb, TCG_CALL_NO_WG, i32, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vaddvub, TCG_CALL_NO_WG, i32, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) +DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) +DEF_HELPER_FLAGS_3 (mve_vaddvuw,TCG_CALL_NO_WG , i32, env, ptr, i32)
target/arm/mve.decode +2 -0
@@ -253,6 +253,8 @@ VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar +# Vector add across vector +VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo # Predicate operations %mask_22_13 22:1 13:3
target/arm/mve_helper.c +24 -0
@@ -1317,3 +1317,27 @@ DO_LDAVH(vrmlaldavhuw, 4, uint32_t, H4, false, int128_add, int128_add, int128_ma DO_LDAVH(vrmlsldavhsw, 4, int32_t, H4, false, int128_add, int128_sub, int128_makes64)DO_LDAVH (vrmlsldavhxsw,4 , int32_t,H4 , true, int128_add, int128_sub, int128_makes64) + +/* Vector add across vector */ +#define DO_VADDV (OP ,ESIZE ,TYPE ,H ) \ + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ + uint32_t ra) \ + { \ + uint16_t mask = mve_element_mask(env); \ + unsigned e; \ + TYPE *m = vm; \ + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ + if (mask & 1) { \ + ra += m[H(e)]; \ + } \ + } \ + mve_advance_vpt(env); \ + return ra; \ + } \ + +DO_VADDV(vaddvsb, 1, uint8_t, H1) +DO_VADDV(vaddvsh, 2, uint16_t, H2) +DO_VADDV(vaddvsw, 4, uint32_t, H4) +DO_VADDV(vaddvub, 1, uint8_t, H1) +DO_VADDV(vaddvuh, 2, uint16_t, H2) +DO_VADDV (vaddvuw,4 , uint32_t,H4 )
target/arm/translate-mve.c +48 -0
57 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 54/55] target/arm: Implement MVE VADDV
Quoted 10 lines · Peter Maydell
Implement the MVE VADDV insn, which performs an addition across vector lanes.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/helper-mve.h | 7 ++++++ target/arm/mve.decode | 2 ++ target/arm/mve_helper.c | 24 +++++++++++++++++++ target/arm/translate-mve.c | 48 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+)
r~
PATCH 55/55 target/arm: Make VMOV scalar <-> gpreg beatwise for MVE
In reply to Peter MaydellIn a CPU with MVE, the VMOV (vector lane to general-purpose register) and VMOV (general-purpose register to vector lane) insns are not predicated, but they are subject to beatwise execution if they are not in an IT block.
Since our implementation always executes all 4 beats in one tick, this means only that we need to handle PSR.ECI:
* we must do the usual check for bad ECI state
* we must advance ECI state if the insn succeeds
* if ECI says we should not be executing the beat corresponding to the lane of the vector register being accessed then we should skip performing the move
Note that if PSR.ECI is non-zero then we cannot be in an IT block.
--- target/arm/translate-a32.h | 2 + target/arm/translate-mve.c | 4 +- target/arm/translate-vfp.c | 85 +++++++++++++++++++++++++++++++++++--- 3 files changed, 83 insertions(+), 8 deletions(-)
target/arm/translate-a32.h +2 -0
@@ -46,6 +46,8 @@ long neon_full_reg_offset(unsigned reg);long neon_element_offset (int reg,int element,MemOp memop);void gen_rev16 (TCGv_i32 dest,TCGv_i32 var);void clear_eci_state (DisasContext *s); +bool mve_eci_check (DisasContext *s); +void mve_update_eci (DisasContext *s);static inline TCGv_i32 load_cpu_offset (int offset) {
target/arm/translate-mve.c +2 -2
@@ -49,7 +49,7 @@ static TCGv_ptr mve_qreg_ptr(unsigned reg)return ret; } -static bool mve_eci_check (DisasContext *s) +bool mve_eci_check (DisasContext *s) {/* * This is a beatwise insn: check that ECI is valid (not a
@@ -72,7 +72,7 @@ static bool mve_eci_check(DisasContext *s) } } -static void mve_update_eci (DisasContext *s) +void mve_update_eci (DisasContext *s) {/* * The helper function will always update the CPUState field,
target/arm/translate-vfp.c +79 -6
113 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 55/55] target/arm: Make VMOV scalar <-> gpreg beatwise for MVE
target/arm/translate-vfp.c static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) · line 643
Quoted 7 lines · Peter Maydell
target/arm/translate-vfp.c +7
-0+if (dc_isar_feature (aa32_mve, s)) { +TCGv_i32 eci; + +mve_update_eci (s); + eci =tcg_const_i32 (s->eci <<4 ); +store_cpu_field (eci, condexec_bits); + }
I think it would be handy to package this up into an mve_update_and_store_eci function. There are 3 copies, including the previous in VPST.
Otherwise,
r~
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [PATCH 00/55] target/arm: First slice of MVE implementation
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
e6bde0c target/arm: Make VMOV scalar <-> gpreg beatwise for MVE 46ab47a target/arm: Implement MVE VADDV
8c6a715 target/arm: Implement MVE VHCADD
ee4a883 target/arm: Implement MVE VCADD
d6d031c target/arm: Implement MVE VADC, VSBC
f2abf78 target/arm: Implement MVE VRHADD
f59e727 target/arm: Implement MVE VQDMULL (vector)
b5a1e75 target/arm: Implement MVE VQDMLSDH and VQRDMLSDH
2a85a42 target/arm: Implement MVE VQDMLADH and VQRDMLADH
c631126 target/arm: Implement MVE VRSHL
96c9251 target/arm: Implement MVE VSHL insn
6617f9d target/arm: Implement MVE VQRSHL
ea1d028 target/arm: Implement MVE VQSHL (vector)
7f5704f target/arm: Implement MVE VQADD, VQSUB (vector)
fe87207 target/arm: Implement MVE VQDMULH, VQRDMULH (vector) fae9d05 target/arm: Implement MVE VQDMULL scalar
3dde42e target/arm: Implement MVE VQDMULH and VQRDMULH (scalar) ad46ffc target/arm: Implement MVE VQADD and VQSUB
eb22856 target/arm: Implement MVE VPST
110b41d target/arm: Implement MVE VBRSR
b92e1c2 target/arm: Implement MVE VHADD, VHSUB (scalar)
bd4a331 target/arm: Implement MVE VSUB, VMUL (scalar)
ddbfc63 target/arm: Implement MVE VADD (scalar)
1722cbe target/arm: Implement MVE VRMLALDAVH, VRMLSLDAVH
53fa7e7 include/qemu/int128.h: Add function to create Int128 from int64_t 6ba3e6f target/arm: Implement MVE VMLSLDAV
34c471e target/arm: Implement MVE VMLALDAV
5faff7d target/arm: Implement MVE VMULL
7c4e6a2 target/arm: Implement MVE VHADD, VHSUB
fe67781 target/arm: Implement MVE VABD
1f8942c target/arm: Implement MVE VMAX, VMIN
0097a91 target/arm: Implement MVE VRMULH
8649950 target/arm: Implement MVE VMULH
7af4e69 target/arm: Implement MVE VADD, VSUB, VMUL
ac5934b target/arm: Implement MVE VAND, VBIC, VORR, VORN, VEOR ff0cfd3 target/arm: Implement MVE VDUP
2f66a74 target/arm: Implement MVE VNEG
0482da4 target/arm: Implement MVE VABS
60d8fd8 target/arm: Implement MVE VMVN (register)
1eaba2f target/arm: Implement MVE VREV16, VREV32, VREV64
ace7aae bitops.h: Provide hswap32(), hswap64(), wswap64() swapping operations d6bed53 target/arm: Implement MVE VCLS
22d128d target/arm: Implement MVE VCLZ
c1690b6 target/arm: Implement widening/narrowing MVE VLDR/VSTR insns a08b6b5 target/arm: Implement MVE VLDR/VSTR (non-widening forms) 3679c9d target/arm: Add framework for MVE decode
22dd9b5 target/arm: Implement MVE LETP insn
b8d39cd target/arm: Implement MVE DLSTP
63e6f6d target/arm: Implement MVE WLSTP insn
8261501 target/arm: Implement MVE LCTP
f77f199 target/arm: Let vfp_access_check() handle late NOCP checks 192982d target/arm: Add handling for PSR.ECI/ICI
c578a8f target/arm: Handle VPR semantics in existing code
7620752 target/arm: Enable FPSCR.QC bit for MVE
df2cbf9 tcg: Introduce tcg_remove_ops_after
=== OUTPUT BEGIN ===
1/55 Checking commit df2cbf927c33 (tcg: Introduce tcg_remove_ops_after)
2/55 Checking commit 7620752e8687 (target/arm: Enable FPSCR.QC bit for MVE) 3/55 Checking commit c578a8fc03b3 (target/arm: Handle VPR semantics in existing code) 4/55 Checking commit 192982d41d0b (target/arm: Add handling for PSR.ECI/ICI) 5/55 Checking commit f77f199bec23 (target/arm: Let vfp_access_check() handle late NOCP checks) 6/55 Checking commit 8261501d3a71 (target/arm: Implement MVE LCTP)
7/55 Checking commit 63e6f6d469dd (target/arm: Implement MVE WLSTP insn)
8/55 Checking commit b8d39cd81fc0 (target/arm: Implement MVE DLSTP)
9/55 Checking commit 22dd9b506bd5 (target/arm: Implement MVE LETP insn)
10/55 Checking commit 3679c9dc0348 (target/arm: Add framework for MVE decode)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#41:
new file mode 100644
total: 0 errors, 1 warnings, 77 lines checked
Patch 10/55 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
11/55 Checking commit a08b6b59eba3 (target/arm: Implement MVE VLDR/VSTR (non-widening forms))
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#29:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #285: FILE: target/arm/mve_helper.c:150:
+ /* \
total: 0 errors, 2 warnings, 396 lines checked
Patch 11/55 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
12/55 Checking commit c1690b678167 (target/arm: Implement widening/narrowing MVE VLDR/VSTR insns) 13/55 Checking commit 22d128d956e2 (target/arm: Implement MVE VCLZ)
ERROR: spaces required around that '*' (ctx:WxV)
#139: FILE: target/arm/translate-mve.c:172:
+static bool do_1op(DisasContext *s, arg_1op *a, MVEGenOneOpFn fn)
^
ERROR: spaces required around that '*' (ctx:WxV)
#168: FILE: target/arm/translate-mve.c:201:
+ static bool trans_##INSN(DisasContext *s, arg_1op *a) \
^total: 2 errors, 0 warnings, 134 lines checked
Patch 13/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
14/55 Checking commit d6bed5354490 (target/arm: Implement MVE VCLS)
15/55 Checking commit ace7aae7c151 (bitops.h: Provide hswap32(), hswap64(), wswap64() swapping operations) 16/55 Checking commit 1eaba2f5eb33 (target/arm: Implement MVE VREV16, VREV32, VREV64)
ERROR: spaces required around that '*' (ctx:WxV)
#82: FILE: target/arm/translate-mve.c:215:
+static bool trans_VREV16(DisasContext *s, arg_1op *a)
^
total: 1 errors, 0 warnings, 75 lines checked
Patch 16/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
17/55 Checking commit 60d8fd8cecf2 (target/arm: Implement MVE VMVN (register)) 18/55 Checking commit 0482da461163 (target/arm: Implement MVE VABS)
ERROR: spaces required around that '-' (ctx:VxV)
#53: FILE: target/arm/mve_helper.c:273:
+#define DO_FABS(N) (N & ((__typeof(N))-1 >> 1))
^
total: 1 errors, 0 warnings, 52 lines checked
Patch 18/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
19/55 Checking commit 2f66a740d4f3 (target/arm: Implement MVE VNEG)
ERROR: spaces required around that '-' (ctx:VxV)
#52: FILE: target/arm/mve_helper.c:283:
+#define DO_FNEG(N) ((N) ^ ~((__typeof(N))-1 >> 1))
^
total: 1 errors, 0 warnings, 51 lines checked
Patch 19/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
20/55 Checking commit ff0cfd392e9a (target/arm: Implement MVE VDUP)
ERROR: spaces required around that '*' (ctx:WxV)
#97: FILE: target/arm/translate-mve.c:172:
+static bool trans_VDUP(DisasContext *s, arg_VDUP *a)
^
total: 1 errors, 0 warnings, 102 lines checked
Patch 20/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
21/55 Checking commit ac5934badd3b (target/arm: Implement MVE VAND, VBIC, VORR, VORN, VEOR) 22/55 Checking commit 7af4e691edf5 (target/arm: Implement MVE VADD, VSUB, VMUL) 23/55 Checking commit 864995039f4b (target/arm: Implement MVE VMULH)
24/55 Checking commit 0097a91b701e (target/arm: Implement MVE VRMULH)
25/55 Checking commit 1f8942c64026 (target/arm: Implement MVE VMAX, VMIN) 26/55 Checking commit fe67781e01b8 (target/arm: Implement MVE VABD)
27/55 Checking commit 7c4e6a230416 (target/arm: Implement MVE VHADD, VHSUB) 28/55 Checking commit 5faff7d64e24 (target/arm: Implement MVE VMULL)
WARNING: line over 80 characters
#71: FILE: target/arm/mve_helper.c:344:
+ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, void *vm) \
total: 0 errors, 1 warnings, 82 lines checked
Patch 28/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
29/55 Checking commit 34c471ee2b2a (target/arm: Implement MVE VMLALDAV)
ERROR: space prohibited between function name and open parenthesis '(' #83: FILE: target/arm/mve_helper.c:493:
+ a ODDACC (int64_t)n[H(e - 1 * XCHG)] * m[H(e)]; \
ERROR: space prohibited between function name and open parenthesis '(' #85: FILE: target/arm/mve_helper.c:495:
+ a EVENACC (int64_t)n[H(e + 1 * XCHG)] * m[H(e)]; \
ERROR: spaces required around that '+=' (ctx:WxB) #93: FILE: target/arm/mve_helper.c:503:
+DO_LDAV(vmlaldavsh, 2, int16_t, H2, false, +=, +=)
^
ERROR: spaces required around that '+=' (ctx:WxB) #94: FILE: target/arm/mve_helper.c:504:
+DO_LDAV(vmlaldavxsh, 2, int16_t, H2, true, +=, +=)
^
ERROR: spaces required around that '+=' (ctx:WxB) #95: FILE: target/arm/mve_helper.c:505:
+DO_LDAV(vmlaldavsw, 4, int32_t, H4, false, +=, +=)
^
ERROR: spaces required around that '+=' (ctx:WxB) #96: FILE: target/arm/mve_helper.c:506:
+DO_LDAV(vmlaldavxsw, 4, int32_t, H4, true, +=, +=)
^
ERROR: spaces required around that '+=' (ctx:WxB) #98: FILE: target/arm/mve_helper.c:508:
+DO_LDAV(vmlaldavuh, 2, uint16_t, H2, false, +=, +=)
^
ERROR: spaces required around that '+=' (ctx:WxB) #99: FILE: target/arm/mve_helper.c:509:
+DO_LDAV(vmlaldavuw, 4, uint32_t, H4, false, +=, +=)
^
WARNING: line over 80 characters
#108: FILE: target/arm/translate-mve.c:34:
+typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64);
ERROR: spaces required around that '*' (ctx:WxV) #140: FILE: target/arm/translate-mve.c:418:
+static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a,
^
total: 9 errors, 1 warnings, 201 lines checked
Patch 29/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
30/55 Checking commit 6ba3e6f73795 (target/arm: Implement MVE VMLSLDAV)
ERROR: spaces required around that '-=' (ctx:WxB)
#52: FILE: target/arm/mve_helper.c:511:
+DO_LDAV(vmlsldavsh, 2, int16_t, H2, false, +=, -=)
^
ERROR: spaces required around that '-=' (ctx:WxB) #53: FILE: target/arm/mve_helper.c:512:
+DO_LDAV(vmlsldavxsh, 2, int16_t, H2, true, +=, -=)
^
ERROR: spaces required around that '-=' (ctx:WxB) #54: FILE: target/arm/mve_helper.c:513:
+DO_LDAV(vmlsldavsw, 4, int32_t, H4, false, +=, -=)
^
ERROR: spaces required around that '-=' (ctx:WxB) #55: FILE: target/arm/mve_helper.c:514:
+DO_LDAV(vmlsldavxsw, 4, int32_t, H4, true, +=, -=)
^
total: 4 errors, 0 warnings, 35 lines checked
Patch 30/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
31/55 Checking commit 53fa7e73f80e (include/qemu/int128.h: Add function to create Int128 from int64_t) 32/55 Checking commit 1722cbe910a5 (target/arm: Implement MVE VRMLALDAVH, VRMLSLDAVH)
WARNING: line over 80 characters
#99: FILE: target/arm/mve_helper.c:543:
+DO_LDAVH(vrmlaldavhsw, 4, int32_t, H4, false, int128_add, int128_add, int128_makes64)
WARNING: line over 80 characters
#100: FILE: target/arm/mve_helper.c:544:
+DO_LDAVH(vrmlaldavhxsw, 4, int32_t, H4, true, int128_add, int128_add, int128_makes64)
WARNING: line over 80 characters
#102: FILE: target/arm/mve_helper.c:546:
+DO_LDAVH(vrmlaldavhuw, 4, uint32_t, H4, false, int128_add, int128_add, int128_make64)
WARNING: line over 80 characters
#104: FILE: target/arm/mve_helper.c:548:
+DO_LDAVH(vrmlsldavhsw, 4, int32_t, H4, false, int128_add, int128_sub, int128_makes64)
WARNING: line over 80 characters
#105: FILE: target/arm/mve_helper.c:549:
+DO_LDAVH(vrmlsldavhxsw, 4, int32_t, H4, true, int128_add, int128_sub, int128_makes64)
total: 0 errors, 5 warnings, 96 lines checked
Patch 32/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
33/55 Checking commit ddbfc63b7af0 (target/arm: Implement MVE VADD (scalar))
ERROR: spaces required around that '*' (ctx:WxV)
#115: FILE: target/arm/translate-mve.c:419:
+static bool do_2op_scalar(DisasContext *s, arg_2scalar *a,
^
ERROR: spaces required around that '*' (ctx:WxV)
#150: FILE: target/arm/translate-mve.c:454:
+ static bool trans_##INSN(DisasContext *s, arg_2scalar *a) \
^total: 2 errors, 0 warnings, 124 lines checked
Patch 33/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
34/55 Checking commit bd4a331cf4ad (target/arm: Implement MVE VSUB, VMUL (scalar)) 35/55 Checking commit b92e1c20de21 (target/arm: Implement MVE VHADD, VHSUB (scalar)) 36/55 Checking commit 110b41d919be (target/arm: Implement MVE VBRSR)
37/55 Checking commit eb2285611568 (target/arm: Implement MVE VPST)
38/55 Checking commit ad46ffc66649 (target/arm: Implement MVE VQADD and VQSUB) 39/55 Checking commit 3dde42e4527d (target/arm: Implement MVE VQDMULH and VQRDMULH (scalar))
WARNING: line over 80 characters
#28: FILE: target/arm/helper-mve.h:194:
+DEF_HELPER_FLAGS_4(mve_vqdmulh_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
WARNING: line over 80 characters
#29: FILE: target/arm/helper-mve.h:195:
+DEF_HELPER_FLAGS_4(mve_vqdmulh_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
WARNING: line over 80 characters
#30: FILE: target/arm/helper-mve.h:196:
+DEF_HELPER_FLAGS_4(mve_vqdmulh_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
WARNING: line over 80 characters
#32: FILE: target/arm/helper-mve.h:198:
+DEF_HELPER_FLAGS_4(mve_vqrdmulh_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
WARNING: line over 80 characters
#33: FILE: target/arm/helper-mve.h:199:
+DEF_HELPER_FLAGS_4(mve_vqrdmulh_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
WARNING: line over 80 characters
#34: FILE: target/arm/helper-mve.h:200:
+DEF_HELPER_FLAGS_4(mve_vqrdmulh_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
total: 0 errors, 6 warnings, 68 lines checked
Patch 39/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
40/55 Checking commit fae9d0559093 (target/arm: Implement MVE VQDMULL scalar)
WARNING: line over 80 characters
#31: FILE: target/arm/helper-mve.h:206:
+DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
WARNING: line over 80 characters
#32: FILE: target/arm/helper-mve.h:207:
+DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
WARNING: line over 80 characters
#33: FILE: target/arm/helper-mve.h:208:
+DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
WARNING: line over 80 characters
#34: FILE: target/arm/helper-mve.h:209:
+DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
ERROR: spaces required around that '*' (ctx:WxV)
#176: FILE: target/arm/translate-mve.c:480:
+static bool trans_VQDMULLB_scalar(DisasContext *s, arg_2scalar *a)
^
total: 1 errors, 4 warnings, 164 lines checked
Patch 40/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
41/55 Checking commit fe872077b91c (target/arm: Implement MVE VQDMULH, VQRDMULH (vector))
WARNING: line over 80 characters
#60: FILE: target/arm/mve_helper.c:361:
+ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, void *vm) \
total: 0 errors, 1 warnings, 70 lines checked
Patch 41/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
42/55 Checking commit 7f5704ffde05 (target/arm: Implement MVE VQADD, VQSUB (vector)) 43/55 Checking commit ea1d0281b67d (target/arm: Implement MVE VQSHL (vector)) 44/55 Checking commit 6617f9dafe1e (target/arm: Implement MVE VQRSHL) 45/55 Checking commit 96c9251bdef5 (target/arm: Implement MVE VSHL insn) 46/55 Checking commit c6311264aa0c (target/arm: Implement MVE VRSHL) 47/55 Checking commit 2a85a4276f80 (target/arm: Implement MVE VQDMLADH and VQRDMLADH)
ERROR: "foo * bar" should be "foo *bar"
#106: FILE: target/arm/mve_helper.c:868:
+ int64_t r = ((int64_t)a * b + (int64_t)c * d) * 2 + (round << 7);
ERROR: "foo * bar" should be "foo *bar"
#113: FILE: target/arm/mve_helper.c:875:
+ int64_t r = ((int64_t)a * b + (int64_t)c * d) * 2 + (round << 15);
ERROR: "foo * bar" should be "foo *bar"
#120: FILE: target/arm/mve_helper.c:882:
+ int64_t m1 = (int64_t)a * b;
total: 3 errors, 0 warnings, 136 lines checked
Patch 47/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
48/55 Checking commit b5a1e7581977 (target/arm: Implement MVE VQDMLSDH and VQRDMLSDH)
ERROR: "foo * bar" should be "foo *bar"
#74: FILE: target/arm/mve_helper.c:909:
+ int64_t r = ((int64_t)a * b - (int64_t)c * d) * 2 + (round << 7);
ERROR: "foo * bar" should be "foo *bar"
#81: FILE: target/arm/mve_helper.c:916:
+ int64_t r = ((int64_t)a * b - (int64_t)c * d) * 2 + (round << 15);
ERROR: "foo * bar" should be "foo *bar"
#88: FILE: target/arm/mve_helper.c:923:
+ int64_t m1 = (int64_t)a * b;
total: 3 errors, 0 warnings, 99 lines checked
Patch 48/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
49/55 Checking commit f59e7278e2a7 (target/arm: Implement MVE VQDMULL (vector)) 50/55 Checking commit f2abf7866196 (target/arm: Implement MVE VRHADD) 51/55 Checking commit d6d031c60c1d (target/arm: Implement MVE VADC, VSBC)
WARNING: Block comments use a leading /* on a separate line
#83: FILE: target/arm/mve_helper.c:591:
+ /* If we do no additions at all the flags are preserved */ \
ERROR: space prohibited before that close parenthesis ')' #102: FILE: target/arm/mve_helper.c:610:
+DO_VADC(vadc, )
WARNING: line over 80 characters
#116: FILE: target/arm/translate-mve.c:36:
+typedef void MVEGenADCFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32);
total: 1 errors, 2 warnings, 147 lines checked
Patch 51/55 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
52/55 Checking commit ee4a8833b853 (target/arm: Implement MVE VCADD)
WARNING: line over 80 characters
#70: FILE: target/arm/mve_helper.c:614:
+ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, void *vm) \
WARNING: Block comments use a leading /* on a separate line #76: FILE: target/arm/mve_helper.c:620:
+ /* Calculate all results first to avoid overwriting inputs */ \
total: 0 errors, 2 warnings, 77 lines checked
Patch 52/55 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
53/55 Checking commit 8c6a715db76c (target/arm: Implement MVE VHCADD)
54/55 Checking commit 46ab47ae5365 (target/arm: Implement MVE VADDV)
55/55 Checking commit e6bde0cf767c (target/arm: Make VMOV scalar <-> gpreg beatwise for MVE) === OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]