s390x/tcg: Vector Instruction Support Part 4
cover s390x/tcg: Vector Instruction Support Part 4
This is the final part of vector instruction support for s390x. It is based on part 2, which is will send a pull-request for to Conny soon.
Part 1: Vector Support Instructions
Part 2: Vector Integer Instructions
Part 3: Vector String Instructions
Part 4: Vector Floating-Point Instructions
The current state can be found at (kept updated):
https://github.com/davidhildenbrand/qemu/tree/vx
It is based on:
- [PATCH v2 0/5] s390x/tcg: Vector Instruction Support Part 3
- [PATCH v1 0/2] s390x: Fix vector register alignment
With the current state I can boot Linux kernel + user space compiled with SIMD support. This allows to boot distributions compiled exclusively for z13, requiring SIMD support. Also, it is now possible to build a complete kernel using rpmbuild as quite some issues have been sorted out.
While the current state works fine for me with RHEL 8, I am experiencing some issues with newer userspace versions (I suspect glibc). I'll have to look into the details first - could be a BUG in !vector instruction or a BUG in a vector instruction that was until now unused.
In this part, all Vector Floating-Point Instructions introduced with the "Vector Facility" are added. Also, the "qemu" model is changed to a z13 machine.
David Hildenbrand (23):
s390x: Use uint64_t for vector registers
s390x/tcg: Introduce tcg_s390_vector_exception() s390x/tcg: Export float_comp_to_cc() and float(32|64|128)_dcmask() s390x/tcg: Implement VECTOR FP ADD
s390x/tcg: Implement VECTOR FP COMPARE (AND SIGNAL) SCALAR s390x/tcg: Implement VECTOR FP COMPARE (EQUAL|HIGH|HIGH OR EQUAL) s390x/tcg: Implement VECTOR FP CONVERT FROM FIXED 64-BIT s390x/tcg: Implement VECTOR FP CONVERT FROM LOGICAL 64-BIT s390x/tcg: Implement VECTOR FP CONVERT TO FIXED 64-BIT s390x/tcg: Implement VECTOR FP CONVERT TO LOGICAL 64-BIT s390x/tcg: Implement VECTOR FP DIVIDE
s390x/tcg: Implement VECTOR LOAD FP INTEGER
s390x/tcg: Implement VECTOR LOAD LENGTHENED
s390x/tcg: Implement VECTOR LOAD ROUNDED
s390x/tcg: Implement VECTOR FP MULTIPLY
s390x/tcg: Implement VECTOR FP MULTIPLY AND (ADD|SUBTRACT) s390x/tcg: Implement VECTOR FP PERFORM SIGN OPERATION s390x/tcg: Implement VECTOR FP SQUARE ROOT
s390x/tcg: Implement VECTOR FP SUBTRACT
s390x/tcg: Implement VECTOR FP TEST DATA CLASS IMMEDIATE s390x/tcg: Allow linux-user to use vector instructions s390x/tcg: We support the Vector Facility
s390x: Bump the "qemu" CPU model up to a stripped-down z13
hw/s390x/s390-virtio-ccw.c | 2 + linux-user/s390x/signal.c | 4 +- target/s390x/Makefile.objs | 1 + target/s390x/arch_dump.c | 8 +- target/s390x/cpu.c | 3 + target/s390x/cpu.h | 5 +- target/s390x/cpu_models.c | 4 +- target/s390x/excp_helper.c | 21 +- target/s390x/fpu_helper.c | 4 +- target/s390x/gdbstub.c | 16 +- target/s390x/gen-features.c | 10 +- target/s390x/helper.c | 10 +- target/s390x/helper.h | 46 +++ target/s390x/insn-data.def | 45 +++ target/s390x/internal.h | 4 + target/s390x/kvm.c | 16 +- target/s390x/machine.c | 128 +++---- target/s390x/tcg_s390x.h | 2 + target/s390x/translate.c | 2 +- target/s390x/translate_vx.inc.c | 274 ++++++++++++++ target/s390x/vec_fpu_helper.c | 644 ++++++++++++++++++++++++++++++++ 21 files changed, 1145 insertions(+), 104 deletions(-) create mode 100644 target/s390x/vec_fpu_helper.c
Signature · 1 line
2.20.1
PATCH 1/23 s390x: Use uint64_t for vector registers
CPU_DoubleU is primarily used to reinterpret between integer and floats. We don't really need this functionality. So let's just keep it simple and use an uint64_t.
--- linux-user/s390x/signal.c | 4 +- target/s390x/arch_dump.c | 8 +-- target/s390x/cpu.h | 4 +- target/s390x/excp_helper.c | 6 +- target/s390x/gdbstub.c | 16 ++--- target/s390x/helper.c | 10 +-- target/s390x/kvm.c | 16 ++--- target/s390x/machine.c | 128 ++++++++++++++++++------------------- target/s390x/translate.c | 2 +- 9 files changed, 97 insertions(+), 97 deletions(-)
linux-user/s390x/signal.c +2 -2
@@ -123,7 +123,7 @@ static void save_sigregs(CPUS390XState *env, target_sigregs *sregs)*/ //save_fp_regs(¤t->thread.fp_regs); FIXME for (i =0 ; i <16 ; i++) { -__put_user (get_freg (env, i)->ll, &sregs->fpregs.fprs[i]); +__put_user (*get_freg (env, i), &sregs->fpregs.fprs[i]); } }
@@ -254,7 +254,7 @@ restore_sigregs(CPUS390XState *env, target_sigregs *sc)__get_user (env->aregs[i], &sc->regs.acrs[i]); }for (i =0 ; i <16 ; i++) { -__get_user (get_freg (env, i)->ll, &sc->fpregs.fprs[i]); +__get_user (*get_freg (env, i), &sc->fpregs.fprs[i]); }return err;
target/s390x/arch_dump.c +4 -4
@@ -104,7 +104,7 @@ static void s390x_write_elf64_fpregset(Note *note, S390CPU *cpu, int id) note->hdr.n_type =cpu_to_be32 (NT_FPREGSET ); note->contents.fpregset.fpc =cpu_to_be32 (cpu->env.fpc);for (i =0 ; i <=15 ; i++) { - note->contents.fpregset.fprs[i] =cpu_to_be64 (get_freg (cs, i)->ll); + note->contents.fpregset.fprs[i] =cpu_to_be64 (*get_freg (cs, i)); } }
@@ -114,7 +114,7 @@ static void s390x_write_elf64_vregslo(Note *note, S390CPU *cpu, int id) note->hdr.n_type =cpu_to_be32 (NT_S390_VXRS_LOW );for (i =0 ; i <=15 ; i++) { - note->contents.vregslo.vregs[i] =cpu_to_be64 (cpu->env.vregs[i][1 ].ll); + note->contents.vregslo.vregs[i] =cpu_to_be64 (cpu->env.vregs[i][1 ]); } }
@@ -127,8 +127,8 @@ static void s390x_write_elf64_vregshi(Note *note, S390CPU *cpu, int id) note->hdr.n_type =cpu_to_be32 (NT_S390_VXRS_HIGH );for (i =0 ; i <=15 ; i++) { - temp_vregshi->vregs[i][0 ] =cpu_to_be64 (cpu->env.vregs[i +16 ][0 ].ll); - temp_vregshi->vregs[i][1 ] =cpu_to_be64 (cpu->env.vregs[i +16 ][1 ].ll); + temp_vregshi->vregs[i][0 ] =cpu_to_be64 (cpu->env.vregs[i +16 ][0 ]); + temp_vregshi->vregs[i][1 ] =cpu_to_be64 (cpu->env.vregs[i +16 ][1 ]); } }
target/s390x/cpu.h +2 -2
@@ -66,7 +66,7 @@ struct CPUS390XState {* The floating point registers are part of the vector registers. * vregs[0][0] -> vregs[15][0] are 16 floating point registers */ - CPU_DoubleU vregs[32][2] QEMU_ALIGNED(16); /* vector registers */ + uint64_t vregs[32][2] QEMU_ALIGNED(16); /* vector registers */uint32_t aregs[16 ];/* access registers */ uint8_t riccb[64 ];/* runtime instrumentation control */ uint64_t gscb[4 ];/* guarded storage control */
@@ -153,7 +153,7 @@ struct CPUS390XState { }; -static inline CPU_DoubleU *get_freg (CPUS390XState *cs,int nr) +static inline uint64_t *get_freg (CPUS390XState *cs,int nr) {return &cs->vregs[nr][0 ]; }
target/s390x/excp_helper.c +3 -3
@@ -390,8 +390,8 @@ static int mchk_store_vregs(CPUS390XState *env, uint64_t mcesao) }for (i =0 ; i <32 ; i++) { - sa->vregs[i][0 ] =cpu_to_be64 (env->vregs[i][0 ].ll); - sa->vregs[i][1 ] =cpu_to_be64 (env->vregs[i][1 ].ll); + sa->vregs[i][0 ] =cpu_to_be64 (env->vregs[i][0 ]); + sa->vregs[i][1 ] =cpu_to_be64 (env->vregs[i][1 ]); }cpu_physical_memory_unmap (sa, len,1 , len);
@@ -429,7 +429,7 @@ static void do_mchk_interrupt(CPUS390XState *env) lowcore->ar_access_id =1 ;for (i =0 ; i <16 ; i++) { - lowcore->floating_pt_save_area[i] =cpu_to_be64 (get_freg (env, i)->ll); + lowcore->floating_pt_save_area[i] =cpu_to_be64 (*get_freg (env, i)); lowcore->gpregs_save_area[i] =cpu_to_be64 (env->regs[i]); lowcore->access_regs_save_area[i] =cpu_to_be32 (env->aregs[i]); lowcore->cregs_save_area[i] =cpu_to_be64 (env->cregs[i]);
target/s390x/gdbstub.c +8 -8
@@ -116,7 +116,7 @@ static int cpu_read_fp_reg(CPUS390XState *env, uint8_t *mem_buf, int n)case S390_FPC_REGNUM :return gdb_get_reg32 (mem_buf, env->fpc); case S390_F0_REGNUM ... S390_F15_REGNUM: -return gdb_get_reg64 (mem_buf,get_freg (env, n -S390_F0_REGNUM )->ll); +return gdb_get_reg64 (mem_buf, *get_freg (env, n -S390_F0_REGNUM ));default :return 0 ; }
@@ -129,7 +129,7 @@ static int cpu_write_fp_reg(CPUS390XState *env, uint8_t *mem_buf, int n) env->fpc =ldl_p (mem_buf);return 4 ; case S390_F0_REGNUM ... S390_F15_REGNUM: -get_freg (env, n -S390_F0_REGNUM )->ll =ldtul_p (mem_buf); + *get_freg (env, n -S390_F0_REGNUM ) =ldtul_p (mem_buf);return 8 ;default :return 0 ;
@@ -150,11 +150,11 @@ static int cpu_read_vreg(CPUS390XState *env, uint8_t *mem_buf, int n)switch (n) { case S390_V0L_REGNUM ... S390_V15L_REGNUM: - ret =gdb_get_reg64 (mem_buf, env->vregs[n][1 ].ll); + ret =gdb_get_reg64 (mem_buf, env->vregs[n][1 ]);break ; case S390_V16_REGNUM ... S390_V31_REGNUM: - ret =gdb_get_reg64 (mem_buf, env->vregs[n][0 ].ll); - ret +=gdb_get_reg64 (mem_buf +8 , env->vregs[n][1 ].ll); + ret =gdb_get_reg64 (mem_buf, env->vregs[n][0 ]); + ret +=gdb_get_reg64 (mem_buf +8 , env->vregs[n][1 ]);break ;default : ret =0 ;
@@ -167,11 +167,11 @@ static int cpu_write_vreg(CPUS390XState *env, uint8_t *mem_buf, int n) {switch (n) { case S390_V0L_REGNUM ... S390_V15L_REGNUM: - env->vregs[n][1 ].ll =ldtul_p (mem_buf +8 ); + env->vregs[n][1 ] =ldtul_p (mem_buf +8 );return 8 ; case S390_V16_REGNUM ... S390_V31_REGNUM: - env->vregs[n][0 ].ll =ldtul_p (mem_buf); - env->vregs[n][1 ].ll =ldtul_p (mem_buf +8 ); + env->vregs[n][0 ] =ldtul_p (mem_buf); + env->vregs[n][1 ] =ldtul_p (mem_buf +8 );return 16 ;default :return 0 ;
target/s390x/helper.c +5 -5
@@ -249,7 +249,7 @@ int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch)cpu_physical_memory_write (offsetof(LowCore , ar_access_id), &ar_id,1 ); }for (i =0 ; i <16 ; ++i) { - sa->fprs[i] =cpu_to_be64 (get_freg (&cpu->env, i)->ll); + sa->fprs[i] =cpu_to_be64 (*get_freg (&cpu->env, i)); }for (i =0 ; i <16 ; ++i) { sa->grs[i] =cpu_to_be64 (cpu->env.regs[i]);
@@ -299,8 +299,8 @@ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len)if (s390_has_feat (S390_FEAT_VECTOR )) {for (i =0 ; i <32 ; i++) { - sa->vregs[i][0 ] =cpu_to_be64 (cpu->env.vregs[i][0 ].ll); - sa->vregs[i][1 ] =cpu_to_be64 (cpu->env.vregs[i][1 ].ll); + sa->vregs[i][0 ] =cpu_to_be64 (cpu->env.vregs[i][0 ]); + sa->vregs[i][1 ] =cpu_to_be64 (cpu->env.vregs[i][1 ]); } }if (s390_has_feat (S390_FEAT_GUARDED_STORAGE ) && len >=ADTL_GS_MIN_SIZE ) {
@@ -341,13 +341,13 @@ void s390_cpu_dump_state(CPUState *cs, FILE *f, int flags)if (s390_has_feat (S390_FEAT_VECTOR )) {for (i =0 ; i <32 ; i++) {qemu_fprintf (f,"V%02d=%016" PRIx64"%016" PRIx64"%c" , - i, env->vregs[i][0 ].ll, env->vregs[i][1 ].ll, + i, env->vregs[i][0 ], env->vregs[i][1 ], i %2 ?'\n' :' ' ); } }else {for (i =0 ; i <16 ; i++) {qemu_fprintf (f,"F%02d=%016" PRIx64"%c" , - i,get_freg (env, i)->ll, + i, *get_freg (env, i), (i %4 ) ==3 ?'\n' :' ' ); } }
target/s390x/kvm.c +8 -8
@@ -418,21 +418,21 @@ int kvm_arch_put_registers(CPUState *cs, int level)if (can_sync_regs (cs,KVM_SYNC_VRS )) {for (i =0 ; i <32 ; i++) { - cs->kvm_run->s.regs.vrs[i][0 ] = env->vregs[i][0 ].ll; - cs->kvm_run->s.regs.vrs[i][1 ] = env->vregs[i][1 ].ll; + cs->kvm_run->s.regs.vrs[i][0 ] = env->vregs[i][0 ]; + cs->kvm_run->s.regs.vrs[i][1 ] = env->vregs[i][1 ]; } cs->kvm_run->s.regs.fpc = env->fpc; cs->kvm_run->kvm_dirty_regs |=KVM_SYNC_VRS ; }else if (can_sync_regs (cs,KVM_SYNC_FPRS )) {for (i =0 ; i <16 ; i++) { - cs->kvm_run->s.regs.fprs[i] =get_freg (env, i)->ll; + cs->kvm_run->s.regs.fprs[i] = *get_freg (env, i); } cs->kvm_run->s.regs.fpc = env->fpc; cs->kvm_run->kvm_dirty_regs |=KVM_SYNC_FPRS ; }else {/* Floating point */ for (i =0 ; i <16 ; i++) { - fpu.fprs[i] =get_freg (env, i)->ll; + fpu.fprs[i] = *get_freg (env, i); } fpu.fpc = env->fpc;
@@ -586,13 +586,13 @@ int kvm_arch_get_registers(CPUState *cs)/* Floating point and vector registers */ if (can_sync_regs (cs,KVM_SYNC_VRS )) {for (i =0 ; i <32 ; i++) { - env->vregs[i][0 ].ll = cs->kvm_run->s.regs.vrs[i][0 ]; - env->vregs[i][1 ].ll = cs->kvm_run->s.regs.vrs[i][1 ]; + env->vregs[i][0 ] = cs->kvm_run->s.regs.vrs[i][0 ]; + env->vregs[i][1 ] = cs->kvm_run->s.regs.vrs[i][1 ]; } env->fpc = cs->kvm_run->s.regs.fpc; }else if (can_sync_regs (cs,KVM_SYNC_FPRS )) {for (i =0 ; i <16 ; i++) { -get_freg (env, i)->ll = cs->kvm_run->s.regs.fprs[i]; +get_freg (env, i) = cs->kvm_run->s.regs.fprs[i]; } env->fpc = cs->kvm_run->s.regs.fpc; }else {
@@ -601,7 +601,7 @@ int kvm_arch_get_registers(CPUState *cs)return r; }for (i =0 ; i <16 ; i++) { -get_freg (env, i)->ll = fpu.fprs[i]; +get_freg (env, i) = fpu.fprs[i]; } env->fpc = fpu.fpc; }
target/s390x/machine.c +64 -64
140 lines not on this page · raw message
target/s390x/translate.c +1 -1
@@ -149,7 +149,7 @@ void s390x_translate_init(void)static inline int vec_full_reg_offset (uint8_t reg) {g_assert (reg <32 ); - return offsetof(CPUS390XState, vregs[reg][0].d); + return offsetof(CPUS390XState, vregs[reg][0]); }static inline int vec_reg_offset (uint8_t reg,uint8_t enr,TCGMemOp es)
Signature · 1 line
2.20.1
PATCH 2/23 s390x/tcg: Introduce tcg_s390_vector_exception()
In reply to David HildenbrandHandling is similar to data exceptions, however we can always store the VXC into the lowore and the FPC:
z14 PoP, 6-20, "Vector-Exception Code"
When a vector-processing exception causes a pro- gram interruption, a vector-exception code (VXC) is stored at location 147, and zeros are stored at loca- tions 144-146. The VXC is also placed in the DXC field of the floating-point-control (FPC) register if bit 45 of control register 0 is one. When bit 45 of control register 0 is zero and bit 46 of control register 0 is one, the DXC field of the FPC register and the con- tents of storage at location 147 are unpredictable.
--- target/s390x/cpu.h | 1 + target/s390x/excp_helper.c | 15 +++++++++++++++ target/s390x/tcg_s390x.h | 2 ++ 3 files changed, 18 insertions(+)
target/s390x/cpu.h +1 -0
@@ -215,6 +215,7 @@ extern const struct VMStateDescription vmstate_s390_cpu;#define PGM_SPECIAL_OP 0x0013#define PGM_OPERAND 0x0015#define PGM_TRACE_TABLE 0x0016 +#define PGM_VECTOR_PROCESSING 0x001b#define PGM_SPACE_SWITCH 0x001c#define PGM_HFP_SQRT 0x001d#define PGM_PC_TRANS_SPEC 0x001f
target/s390x/excp_helper.c +15 -0
@@ -62,6 +62,21 @@ void QEMU_NORETURN tcg_s390_data_exception(CPUS390XState *env, uint32_t dxc,tcg_s390_program_interrupt (env,PGM_DATA ,ILEN_AUTO , ra); } +void QEMU_NORETURN tcg_s390_vector_exception(CPUS390XState *env, uint32_t vxc, +uintptr_t ra) +{ +g_assert (vxc <=0xff ); +#if !defined(CONFIG_USER_ONLY ) +/* Always store the VXC into the lowcore, without AFP it is undefined */ +stl_phys (CPU (s390_env_get_cpu (env))->as, + env->psa + offsetof(LowCore , data_exc_code), vxc); +#endif + +/* Always store the VXC into the FPC, without AFP it is undefined */ + env->fpc =deposit32 (env->fpc,8 ,8 , vxc); +tcg_s390_program_interrupt (env,PGM_VECTOR_PROCESSING ,ILEN_AUTO , ra); +} +void HELPER (data_exception )(CPUS390XState *env,uint32_t dxc) {tcg_s390_data_exception (env, dxc,GETPC ());
target/s390x/tcg_s390x.h +2 -0
@@ -18,5 +18,7 @@ void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code, int ilen, uintptr_t ra); void QEMU_NORETURN tcg_s390_data_exception(CPUS390XState *env, uint32_t dxc,uintptr_t ra); +void QEMU_NORETURN tcg_s390_vector_exception(CPUS390XState *env, uint32_t vxc, +uintptr_t ra);#endif /* TCG_S390X_H */
Signature · 1 line
2.20.1
PATCH 3/23 s390x/tcg: Export float_comp_to_cc() and float(32|64|128)_dcmask()
In reply to David HildenbrandVector floating-point instructions will require these functions, so allow to use them from other files.
--- target/s390x/fpu_helper.c | 4 ++-- target/s390x/internal.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-)
target/s390x/fpu_helper.c +2 -2
@@ -112,7 +112,7 @@ static void handle_exceptions(CPUS390XState *env, bool XxC, uintptr_t retaddr) } } -static inline int float_comp_to_cc (CPUS390XState *env,int float_compare) +int float_comp_to_cc (CPUS390XState *env,int float_compare) {S390CPU *cpu =s390_env_get_cpu (env);
@@ -746,7 +746,7 @@ static inline uint16_t dcmask(int bit, bool neg) }#define DEF_FLOAT_DCMASK (_TYPE) \ -static uint16_t _TYPE##_dcmask(CPUS390XState *env, _TYPE f1) \ +uint16_t _TYPE##_dcmask(CPUS390XState *env, _TYPE f1) \ { \ const bool neg = _TYPE##_is_neg(f1); \ \
target/s390x/internal.h +4 -0
@@ -285,6 +285,10 @@ uint32_t set_cc_nz_f128(float128 v);uint8_t s390_softfloat_exc_to_ieee (unsigned int exc);int s390_swap_bfp_rounding_mode (CPUS390XState *env,int m3);void s390_restore_bfp_rounding_mode (CPUS390XState *env,int old_mode); +int float_comp_to_cc (CPUS390XState *env,int float_compare); +uint16_t float32_dcmask (CPUS390XState *env,float32 f1); +uint16_t float64_dcmask (CPUS390XState *env,float64 f1); +uint16_t float128_dcmask (CPUS390XState *env,float128 f1);/* gdbstub.c */
Signature · 1 line
2.20.1
PATCH 4/23 s390x/tcg: Implement VECTOR FP ADD
In reply to David Hildenbrand1. We'll reuse op_vfa() for similar instructions later, prepare for that.
2. We'll reuse vop64_3() for other instructions later.
3. Take care of modifying the vector register only if no trap happened.
- on traps, flags are not updated and no elements are modified
- traps don't modify the fpc flags
- without traps, all exceptions of all elements are merged
4. We'll reuse check_ieee_exc() later when we need the XxC flag.
We have to check for exceptions after processing each element. Provide separate handlers for single/all element processing. We'll do the same for all applicable FP instructions.
--- target/s390x/Makefile.objs | 1 + target/s390x/helper.h | 4 ++ target/s390x/insn-data.def | 5 ++ target/s390x/translate_vx.inc.c | 29 ++++++++ target/s390x/vec_fpu_helper.c | 119 ++++++++++++++++++++++++++++++++ 5 files changed, 158 insertions(+) create mode 100644 target/s390x/vec_fpu_helper.c
target/s390x/Makefile.objs +1 -0
@@ -2,6 +2,7 @@ obj-y += cpu.o cpu_models.o cpu_features.o gdbstub.o interrupt.o helper.o obj-$(CONFIG_TCG) += translate.o cc_helper.o excp_helper.o fpu_helper.o obj-$(CONFIG_TCG) += int_helper.o mem_helper.o misc_helper.o crypto_helper.o obj-$(CONFIG_TCG) += vec_helper.o vec_int_helper.o vec_string_helper.o +obj-$(CONFIG_TCG) += vec_fpu_helper.o obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o mmu_helper.o diag.o obj-$(CONFIG_SOFTMMU) += sigp.o obj-$(CONFIG_KVM) += kvm.o
target/s390x/helper.h +4 -0
@@ -249,6 +249,10 @@ DEF_HELPER_6(gvec_vstrc_cc_rt8, void, ptr, cptr, cptr, cptr, env, i32) DEF_HELPER_6(gvec_vstrc_cc_rt16, void, ptr, cptr, cptr, cptr, env, i32)DEF_HELPER_6 (gvec_vstrc_cc_rt32, void, ptr, cptr, cptr, cptr, env, i32) +/* === Vector Floating-Point Instructions */ +DEF_HELPER_FLAGS_5(gvec_vfa64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_5(gvec_vfa64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +#ifndef CONFIG_USER_ONLY DEF_HELPER_3(servc, i32, env, i64, i64)DEF_HELPER_4 (diag, void, env, i32, i32, i32)
target/s390x/insn-data.def +5 -0
@@ -1204,6 +1204,11 @@ /* VECTOR STRING RANGE COMPARE */ F(0xe78a, VSTRC, VRR_d, V, 0, 0, 0, 0, vstrc, 0, IF_VEC) +/* === Vector Floating-Point Instructions */ + +/* VECTOR FP ADD */ + F(0xe7e3, VFA, VRR_c, V, 0, 0, 0, 0, vfa, 0, IF_VEC) + #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */ E(0xb250, CSP, RRE, Z, r1_32u, ra2, r1_P, 0, csp, 0, MO_TEUL, IF_PRIV)
target/s390x/translate_vx.inc.c +29 -0
@@ -52,6 +52,11 @@#define ES_64 MO_64#define ES_128 4 +/* Floating-Point Format */ +#define FPF_SHORT 2 +#define FPF_LONG 3 +#define FPF_EXT 4 +static inline bool valid_vec_element (uint8_t enr,TCGMemOp es) {return !(enr & ~(NUM_VEC_ELEMENTS (es) -1 ));
@@ -2538,3 +2543,27 @@ static DisasJumpType op_vstrc(DisasContext *s, DisasOps *o) }return DISAS_NEXT ; } + +static DisasJumpType op_vfa (DisasContext *s,DisasOps *o) +{ +const uint8_t fpf =get_field (s->fields, m4); +const uint8_t m5 =get_field (s->fields, m5); +const bool se =extract32 (m5,3 ,1 ); +gen_helper_gvec_3_ptr *fn; + +if (fpf !=FPF_LONG ||extract32 (m5,0 ,3 )) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +switch (s->fields->op2) { +case 0xe3 : + fn = se ? gen_helper_gvec_vfa64s : gen_helper_gvec_vfa64; +break ; +default : +g_assert_not_reached (); + } +gen_gvec_3_ptr (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3), cpu_env,0 , fn); +return DISAS_NEXT ; +}
target/s390x/vec_fpu_helper.c new file +119 -0
119 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 04/23] s390x/tcg: Implement VECTOR FP ADD
target/s390x/vec_fpu_helper.c line 107
Quoted 4 lines · David Hildenbrand
target/s390x/vec_fpu_helper.c new file +4
-0+static uint64_t vfa64 (uint64_t a,uint64_t b,float_status *s) +{ +return float64_val (float64_add (make_float64 (a),make_float64 (b), s)); +}
You don't need either make_float64 or float64_val. I've been intending to strip them out entirely; we don't need to add new uses.
r~
Re: [Qemu-devel] [PATCH v1 04/23] s390x/tcg: Implement VECTOR FP ADD
Quoted 10 lines · Richard Henderson
target/s390x/vec_fpu_helper.c line 107
Quoted 4 lines · David Hildenbrand
target/s390x/vec_fpu_helper.c new file +4
-0+static uint64_t vfa64 (uint64_t a,uint64_t b,float_status *s) +{ +return float64_val (float64_add (make_float64 (a),make_float64 (b), s)); +}You don't need either
make_float64orfloat64_val. I've been intending to strip them out entirely; we don't need to add new uses.
Makes sense, I added them for consistency - will remove them.
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v1 04/23] s390x/tcg: Implement VECTOR FP ADD
In reply to David Hildenbrandtarget/s390x/vec_fpu_helper.c line 113
Quoted 5 lines · David Hildenbrand
target/s390x/vec_fpu_helper.c new file +5
-0+void HELPER (gvec_vfa64 )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vop64_3 (v1, v2, v3, env, false, vfa64,GETPC ()); +}
Given that make_float64 is banished, I guess you can pass float64_add here directly.
With that,
r~
PATCH 5/23 s390x/tcg: Implement VECTOR FP COMPARE (AND SIGNAL) SCALAR
In reply to David HildenbrandAs far as I can see, there is only a tiny difference.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 4 ++++ target/s390x/translate_vx.inc.c | 21 +++++++++++++++++++++ target/s390x/vec_fpu_helper.c | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+)
target/s390x/helper.h +2 -0
@@ -252,6 +252,8 @@ DEF_HELPER_6(gvec_vstrc_cc_rt32, void, ptr, cptr, cptr, cptr, env, i32)/* === Vector Floating-Point Instructions */ DEF_HELPER_FLAGS_5(gvec_vfa64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) DEF_HELPER_FLAGS_5(gvec_vfa64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_4(gvec_wfc64, void, cptr, cptr, env, i32) +DEF_HELPER_4(gvec_wfk64, void, cptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +4 -0
@@ -1208,6 +1208,10 @@ /* VECTOR FP ADD */ F(0xe7e3, VFA, VRR_c, V, 0, 0, 0, 0, vfa, 0, IF_VEC) +/* VECTOR FP COMPARE SCALAR */ + F(0xe7cb, WFC, VRR_a, V, 0, 0, 0, 0, wfc, 0, IF_VEC) +/* VECTOR FP COMPARE AND SIGNAL SCALAR */ + F(0xe7ca, WFK, VRR_a, V, 0, 0, 0, 0, wfc, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +21 -0
@@ -2567,3 +2567,24 @@ static DisasJumpType op_vfa(DisasContext *s, DisasOps *o) get_field(s->fields, v3), cpu_env, 0, fn);return DISAS_NEXT ; } + +static DisasJumpType op_wfc (DisasContext *s,DisasOps *o) +{ +const uint8_t fpf =get_field (s->fields, m3); +const uint8_t m4 =get_field (s->fields, m4); + +if (fpf !=FPF_LONG || m4) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +if (s->fields->op2 ==0xcb ) { +gen_gvec_2_ptr (get_field (s->fields, v1),get_field (s->fields, v2), + cpu_env,0 , gen_helper_gvec_wfc64); + }else { +gen_gvec_2_ptr (get_field (s->fields, v1),get_field (s->fields, v2), + cpu_env,0 , gen_helper_gvec_wfk64); + } +set_cc_static (s); +return DISAS_NEXT ; +}
target/s390x/vec_fpu_helper.c +32 -0
@@ -117,3 +117,35 @@ void HELPER(gvec_vfa64s)(void *v1, const void *v2, const void *v3, {vop64_3 (v1, v2, v3, env, true, vfa64,GETPC ()); } + +static int wfc64 (const S390Vector *v1,const S390Vector *v2, +CPUS390XState *env,bool signal,uintptr_t retaddr) +{ +/* only the zero-indexed elements are compared */ +const float64 a =make_float64 (s390_vec_read_element64 (v1,0 )); +const float64 b =make_float64 (s390_vec_read_element64 (v2,0 )); +uint8_t vxc, vec_exc =0 ; +int cmp; + +if (signal) { + cmp =float64_compare (a, b, &env->fpu_status); + }else { + cmp =float64_compare_quiet (a, b, &env->fpu_status); + } + vxc =check_ieee_exc (env,0 , false, &vec_exc); +handle_ieee_exc (env, vxc, vec_exc, retaddr); + +return float_comp_to_cc (env, cmp); +} + +void HELPER (gvec_wfc64 )(const void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ + env->cc_op =wfc64 (v1, v2, env, false,GETPC ()); +} + +void HELPER (gvec_wfk64 )(const void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ + env->cc_op =wfc64 (v1, v2, env, true,GETPC ()); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 05/23] s390x/tcg: Implement VECTOR FP COMPARE (AND SIGNAL) SCALAR
Quoted 9 lines · David Hildenbrand
As far as I can see, there is only a tiny difference.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 4 ++++ target/s390x/translate_vx.inc.c | 21 +++++++++++++++++++++ target/s390x/vec_fpu_helper.c | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+)
r~
PATCH 6/23 s390x/tcg: Implement VECTOR FP COMPARE (EQUAL|HIGH|HIGH OR EQUAL)
In reply to David HildenbrandProvide for all three instructions all four combinations of cc bit and s bit.
--- target/s390x/helper.h | 12 ++++ target/s390x/insn-data.def | 6 ++ target/s390x/translate_vx.inc.c | 51 +++++++++++++++ target/s390x/vec_fpu_helper.c | 107 ++++++++++++++++++++++++++++++++ 4 files changed, 176 insertions(+)
target/s390x/helper.h +12 -0
@@ -254,6 +254,18 @@ DEF_HELPER_FLAGS_5(gvec_vfa64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) DEF_HELPER_FLAGS_5(gvec_vfa64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) DEF_HELPER_4(gvec_wfc64, void, cptr, cptr, env, i32) DEF_HELPER_4(gvec_wfk64, void, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_5(gvec_vfce64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_5(gvec_vfce64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_5(gvec_vfce64_cc, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_5(gvec_vfce64s_cc, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_5(gvec_vfch64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_5(gvec_vfch64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_5(gvec_vfch64_cc, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_5(gvec_vfch64s_cc, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_5(gvec_vfche64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_5(gvec_vfche64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_5(gvec_vfche64_cc, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_5(gvec_vfche64s_cc, void, ptr, cptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +6 -0
@@ -1212,6 +1212,12 @@ F(0xe7cb, WFC, VRR_a, V, 0, 0, 0, 0, wfc, 0, IF_VEC) /* VECTOR FP COMPARE AND SIGNAL SCALAR */ F(0xe7ca, WFK, VRR_a, V, 0, 0, 0, 0, wfc, 0, IF_VEC) +/* VECTOR FP COMPARE EQUAL */ + F(0xe7e8, VFCE, VRR_c, V, 0, 0, 0, 0, vfc, 0, IF_VEC) +/* VECTOR FP COMPARE HIGH */ + F(0xe7eb, VFCH, VRR_c, V, 0, 0, 0, 0, vfc, 0, IF_VEC) +/* VECTOR FP COMPARE HIGH OR EQUAL */ + F(0xe7ea, VFCHE, VRR_c, V, 0, 0, 0, 0, vfc, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +51 -0
54 lines not on this page · raw message
target/s390x/vec_fpu_helper.c +107 -0
110 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 06/23] s390x/tcg: Implement VECTOR FP COMPARE (EQUAL|HIGH|HIGH OR EQUAL)
Quoted 6 lines · David Hildenbrand
target/s390x/vec_fpu_helper.c +6
-0+static int vfc64 (S390Vector *v1,const S390Vector *v2,const S390Vector *v3, +CPUS390XState *env,bool s,bool test_equal,bool test_high, +uintptr_t retaddr) +{ +uint8_t vxc, vec_exc =0 ; +S390Vector tmp = {};
target/s390x/vec_fpu_helper.c void HELPER(gvec_wfk64)(const void *v1, const void *v2, CPUS390XState *env, · line 168
Quoted 10 lines
target/s390x/vec_fpu_helper.c +10
-0+int match =0 ; +int i; + +for (i =0 ; i <2 ; i++) { +const float64 a =make_float64 (s390_vec_read_element64 (v2, i)); +const float64 b =make_float64 (s390_vec_read_element64 (v3, i)); +const int cmp =float64_compare_quiet (a, b, &env->fpu_status); + +if ((cmp == float_relation_equal && test_equal) || + (cmp == float_relation_greater && test_high)) {
It might be easier to pass in the comparison function instead of test_equal and test_high (float64_eq_quiet, float64_lt_quiet) and swap the arguments to turn lt into gt (not affecting eq).
This will let you pass float64_eq and float64_lt when it comes time to support the SQ bit for the vector-enhancment-1 facility.
Otherwise you'll have 3 bools passed in and a bit of a mess here.
target/s390x/vec_fpu_helper.c void HELPER(gvec_wfk64)(const void *v1, const void *v2, CPUS390XState *env, · line 181
Quoted 2 lines
target/s390x/vec_fpu_helper.c +2
-0+if (match == i +1 ) { +return 0 ;
This doesn't look right. How can match == 3,
with i == 2 when not exiting the loop early.
The vxc case is handled via longjmp, I think,
which leaves the S case to handle here.
Perhaps better as
if (match) {
return s || match == 2 ? 0 : 1;
}
return 3;r~
Re: [Qemu-devel] [PATCH v1 06/23] s390x/tcg: Implement VECTOR FP COMPARE (EQUAL|HIGH|HIGH OR EQUAL)
Quoted 22 lines · Richard Henderson
Quoted 6 lines · David Hildenbrand
target/s390x/vec_fpu_helper.c +6
-0+static int vfc64 (S390Vector *v1,const S390Vector *v2,const S390Vector *v3, +CPUS390XState *env,bool s,bool test_equal,bool test_high, +uintptr_t retaddr) +{ +uint8_t vxc, vec_exc =0 ; +S390Vector tmp = {};target/s390x/vec_fpu_helper.c void HELPER(gvec_wfk64)(const void *v1, const void *v2, CPUS390XState *env, · line 168
Quoted 10 lines
target/s390x/vec_fpu_helper.c +10
-0+int match =0 ; +int i; + +for (i =0 ; i <2 ; i++) { +const float64 a =make_float64 (s390_vec_read_element64 (v2, i)); +const float64 b =make_float64 (s390_vec_read_element64 (v3, i)); +const int cmp =float64_compare_quiet (a, b, &env->fpu_status); + +if ((cmp == float_relation_equal && test_equal) || + (cmp == float_relation_greater && test_high)) {It might be easier to pass in the comparison function instead of
test_equalandtest_high(float64_eq_quiet,float64_lt_quiet) and swap the arguments to turn lt into gt (not affecting eq).
Quoted 4 lines
This will let you pass
float64_eqandfloat64_ltwhen it comes time to support the SQ bit for the vector-enhancment-1 facility.Otherwise you'll have 3 bools passed in and a bit of a mess here.
Very good idea!
Quoted 11 lines
target/s390x/vec_fpu_helper.c void HELPER(gvec_wfk64)(const void *v1, const void *v2, CPUS390XState *env, · line 181
Quoted 4 lines
target/s390x/vec_fpu_helper.c +2
-0+if (match == i +1 ) { +return 0 ;This doesn't look right. How can match == 3,
with i == 2 when not exiting the loop early.The vxc case is handled via longjmp, I think,
which leaves the S case to handle here.
Quoted 6 lines
Perhaps better as
if (match) { return s || match == 2 ? 0 : 1; } return 3;
Yes indeed, thanks for catching this.
Quoted 4 lines
r~
Signature · 3 lines
Thanks, David / dhildenb
PATCH 7/23 s390x/tcg: Implement VECTOR FP CONVERT FROM FIXED 64-BIT
In reply to David Hildenbrand1. We'll reuse op_vcdg() for similar instructions later, prepare for that.
2. We'll reuse vop64_2() later for other instructions.
We have to mangle the erm (effective rounding mode) and the m4 into the simd_data(), and properly unmangle them again.
Make sure to restore the erm before triggering an exception.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 25 ++++++++++++++++++ target/s390x/vec_fpu_helper.c | 47 +++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+)
target/s390x/helper.h +2 -0
@@ -266,6 +266,8 @@ DEF_HELPER_FLAGS_5(gvec_vfche64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32 DEF_HELPER_FLAGS_5(gvec_vfche64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) DEF_HELPER_5(gvec_vfche64_cc, void, ptr, cptr, cptr, env, i32) DEF_HELPER_5(gvec_vfche64s_cc, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vcdg64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vcdg64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1218,6 +1218,8 @@ F(0xe7eb, VFCH, VRR_c, V, 0, 0, 0, 0, vfc, 0, IF_VEC) /* VECTOR FP COMPARE HIGH OR EQUAL */ F(0xe7ea, VFCHE, VRR_c, V, 0, 0, 0, 0, vfc, 0, IF_VEC) +/* VECTOR FP CONVERT FROM FIXED 64-BIT */ + F(0xe7c3, VCDG, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +25 -0
@@ -2639,3 +2639,28 @@ static DisasJumpType op_vfc(DisasContext *s, DisasOps *o) }return DISAS_NEXT ; } + +static DisasJumpType op_vcdg (DisasContext *s,DisasOps *o) +{ +const uint8_t fpf =get_field (s->fields, m3); +const uint8_t m4 =get_field (s->fields, m4); +const uint8_t erm =get_field (s->fields, m5); +const bool se =extract32 (m4,3 ,1 ); +gen_helper_gvec_2_ptr *fn; + +if (fpf !=FPF_LONG ||extract32 (m4,0 ,2 ) || erm >7 || erm ==2 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +switch (s->fields->op2) { +case 0xc3 : + fn = se ? gen_helper_gvec_vcdg64s : gen_helper_gvec_vcdg64; +break ; +default : +g_assert_not_reached (); + } +gen_gvec_2_ptr (get_field (s->fields, v1),get_field (s->fields, v2), cpu_env, +deposit32 (m4,4 ,4 , erm), fn); +return DISAS_NEXT ; +}
target/s390x/vec_fpu_helper.c +47 -0
56 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 07/23] s390x/tcg: Implement VECTOR FP CONVERT FROM FIXED 64-BIT
target/s390x/translate_vx.inc.c static DisasJumpType op_vfc(DisasContext *s, DisasOps *o) · line 2651
Quoted 9 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +9
-0+static DisasJumpType op_vcdg (DisasContext *s,DisasOps *o) +{ +const uint8_t fpf =get_field (s->fields, m3); +const uint8_t m4 =get_field (s->fields, m4); +const uint8_t erm =get_field (s->fields, m5); +const bool se =extract32 (m4,3 ,1 ); +gen_helper_gvec_2_ptr *fn; + +if (fpf !=FPF_LONG ||extract32 (m4,0 ,2 ) || erm >7 || erm ==2 ) {
Please split out the erm validity check. We have fpinst_extract_m34 doing some of this now; it would be a shame to replicate it more.
r~
Richard Henderson
Reviewed-byRe: [Qemu-devel] [PATCH v1 07/23] s390x/tcg: Implement VECTOR FP CONVERT FROM FIXED 64-BIT
Quoted 14 lines · Richard Henderson
target/s390x/translate_vx.inc.c static DisasJumpType op_vfc(DisasContext *s, DisasOps *o) · line 2651
Quoted 9 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +9
-0+static DisasJumpType op_vcdg (DisasContext *s,DisasOps *o) +{ +const uint8_t fpf =get_field (s->fields, m3); +const uint8_t m4 =get_field (s->fields, m4); +const uint8_t erm =get_field (s->fields, m5); +const bool se =extract32 (m4,3 ,1 ); +gen_helper_gvec_2_ptr *fn; + +if (fpf !=FPF_LONG ||extract32 (m4,0 ,2 ) || erm >7 || erm ==2 ) {Please split out the erm validity check. We have
fpinst_extract_m34doing some of this now; it would be a shame to replicate it more.
Hmm. Or perhaps you aren't replicating it because it's only used by these conversions, and both signed and unsigned go through this same function?
r~
Re: [Qemu-devel] [PATCH v1 07/23] s390x/tcg: Implement VECTOR FP CONVERT FROM FIXED 64-BIT
Quoted 16 lines · Richard Henderson
Quoted 14 lines · Richard Henderson
target/s390x/translate_vx.inc.c static DisasJumpType op_vfc(DisasContext *s, DisasOps *o) · line 2651
Quoted 9 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +9
-0+static DisasJumpType op_vcdg (DisasContext *s,DisasOps *o) +{ +const uint8_t fpf =get_field (s->fields, m3); +const uint8_t m4 =get_field (s->fields, m4); +const uint8_t erm =get_field (s->fields, m5); +const bool se =extract32 (m4,3 ,1 ); +gen_helper_gvec_2_ptr *fn; + +if (fpf !=FPF_LONG ||extract32 (m4,0 ,2 ) || erm >7 || erm ==2 ) {Please split out the erm validity check. We have
fpinst_extract_m34doing some of this now; it would be a shame to replicate it more.
Quoted 2 lines
Hmm. Or perhaps you aren't replicating it because it's only used by these conversions, and both signed and unsigned go through this same function?
Right, the check is only at one place in this file. Thanks!
Quoted 7 lines
Reviewed-by Richard Henderson <[email protected]>r~
Signature · 3 lines
Thanks, David / dhildenb
PATCH 8/23 s390x/tcg: Implement VECTOR FP CONVERT FROM LOGICAL 64-BIT
In reply to David Hildenbrand--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 23 +++++++++++++++++++++++ 4 files changed, 30 insertions(+)
target/s390x/helper.h +2 -0
@@ -268,6 +268,8 @@ DEF_HELPER_5(gvec_vfche64_cc, void, ptr, cptr, cptr, env, i32) DEF_HELPER_5(gvec_vfche64s_cc, void, ptr, cptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vcdg64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vcdg64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vcdlg64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vcdlg64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1220,6 +1220,8 @@ F(0xe7ea, VFCHE, VRR_c, V, 0, 0, 0, 0, vfc, 0, IF_VEC) /* VECTOR FP CONVERT FROM FIXED 64-BIT */ F(0xe7c3, VCDG, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) +/* VECTOR FP CONVERT FROM LOGICAL 64-BIT */ + F(0xe7c1, VCDLG, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +3 -0
@@ -2657,6 +2657,9 @@ static DisasJumpType op_vcdg(DisasContext *s, DisasOps *o)case 0xc3 : fn = se ? gen_helper_gvec_vcdg64s : gen_helper_gvec_vcdg64;break ; +case 0xc1 : + fn = se ? gen_helper_gvec_vcdlg64s : gen_helper_gvec_vcdlg64; +break ;default :g_assert_not_reached (); }
target/s390x/vec_fpu_helper.c +23 -0
@@ -303,3 +303,26 @@ void HELPER(gvec_vcdg64s)(void *v1, const void *v2, CPUS390XState *env,vop64_2 (v1, v2, env, true, XxC, erm, vcdg64,GETPC ()); } + +static uint64_t vcdlg64 (uint64_t a,float_status *s) +{ +return float64_val (uint64_to_float64 (a, s)); +} + +void HELPER (gvec_vcdlg64 )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +const uint8_t erm =extract32 (simd_data (desc),4 ,4 ); +const bool XxC =extract32 (simd_data (desc),2 ,1 ); + +vop64_2 (v1, v2, env, false, XxC, erm, vcdlg64,GETPC ()); +} + +void HELPER (gvec_vcdlg64s )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +const uint8_t erm =extract32 (simd_data (desc),4 ,4 ); +const bool XxC =extract32 (simd_data (desc),2 ,1 ); + +vop64_2 (v1, v2, env, true, XxC, erm, vcdlg64,GETPC ()); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 08/23] s390x/tcg: Implement VECTOR FP CONVERT FROM LOGICAL 64-BIT
Quoted 7 lines · David Hildenbrand
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 23 +++++++++++++++++++++++ 4 files changed, 30 insertions(+)
r~
PATCH 9/23 s390x/tcg: Implement VECTOR FP CONVERT TO FIXED 64-BIT
In reply to David Hildenbrand--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 23 +++++++++++++++++++++++ 4 files changed, 30 insertions(+)
target/s390x/helper.h +2 -0
@@ -270,6 +270,8 @@ DEF_HELPER_FLAGS_4(gvec_vcdg64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vcdg64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vcdlg64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vcdlg64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vcgd64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vcgd64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1222,6 +1222,8 @@ F(0xe7c3, VCDG, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) /* VECTOR FP CONVERT FROM LOGICAL 64-BIT */ F(0xe7c1, VCDLG, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) +/* VECTOR FP CONVERT TO FIXED 64-BIT */ + F(0xe7c2, VCGD, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +3 -0
@@ -2660,6 +2660,9 @@ static DisasJumpType op_vcdg(DisasContext *s, DisasOps *o)case 0xc1 : fn = se ? gen_helper_gvec_vcdlg64s : gen_helper_gvec_vcdlg64;break ; +case 0xc2 : + fn = se ? gen_helper_gvec_vcgd64s : gen_helper_gvec_vcgd64; +break ;default :g_assert_not_reached (); }
target/s390x/vec_fpu_helper.c +23 -0
@@ -326,3 +326,26 @@ void HELPER(gvec_vcdlg64s)(void *v1, const void *v2, CPUS390XState *env,vop64_2 (v1, v2, env, true, XxC, erm, vcdlg64,GETPC ()); } + +static uint64_t vcgd64 (uint64_t a,float_status *s) +{ +return float64_to_int64 (make_float64 (a), s); +} + +void HELPER (gvec_vcgd64 )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +const uint8_t erm =extract32 (simd_data (desc),4 ,4 ); +const bool XxC =extract32 (simd_data (desc),2 ,1 ); + +vop64_2 (v1, v2, env, false, XxC, erm, vcgd64,GETPC ()); +} + +void HELPER (gvec_vcgd64s )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +const uint8_t erm =extract32 (simd_data (desc),4 ,4 ); +const bool XxC =extract32 (simd_data (desc),2 ,1 ); + +vop64_2 (v1, v2, env, true, XxC, erm, vcgd64,GETPC ()); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 09/23] s390x/tcg: Implement VECTOR FP CONVERT TO FIXED 64-BIT
Quoted 7 lines · David Hildenbrand
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 23 +++++++++++++++++++++++ 4 files changed, 30 insertions(+)
r~
PATCH 10/23 s390x/tcg: Implement VECTOR FP CONVERT TO LOGICAL 64-BIT
In reply to David Hildenbrand--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 23 +++++++++++++++++++++++ 4 files changed, 30 insertions(+)
target/s390x/helper.h +2 -0
@@ -272,6 +272,8 @@ DEF_HELPER_FLAGS_4(gvec_vcdlg64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vcdlg64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vcgd64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vcgd64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vclgd64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vclgd64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1224,6 +1224,8 @@ F(0xe7c1, VCDLG, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) /* VECTOR FP CONVERT TO FIXED 64-BIT */ F(0xe7c2, VCGD, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) +/* VECTOR FP CONVERT TO LOGICAL 64-BIT */ + F(0xe7c0, VCLGD, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +3 -0
@@ -2663,6 +2663,9 @@ static DisasJumpType op_vcdg(DisasContext *s, DisasOps *o)case 0xc2 : fn = se ? gen_helper_gvec_vcgd64s : gen_helper_gvec_vcgd64;break ; +case 0xc0 : + fn = se ? gen_helper_gvec_vclgd64s : gen_helper_gvec_vclgd64; +break ;default :g_assert_not_reached (); }
target/s390x/vec_fpu_helper.c +23 -0
@@ -349,3 +349,26 @@ void HELPER(gvec_vcgd64s)(void *v1, const void *v2, CPUS390XState *env,vop64_2 (v1, v2, env, true, XxC, erm, vcgd64,GETPC ()); } + +static uint64_t vclgd64 (uint64_t a,float_status *s) +{ +return float64_to_uint64 (make_float64 (a), s); +} + +void HELPER (gvec_vclgd64 )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +const uint8_t erm =extract32 (simd_data (desc),4 ,4 ); +const bool XxC =extract32 (simd_data (desc),2 ,1 ); + +vop64_2 (v1, v2, env, false, XxC, erm, vclgd64,GETPC ()); +} + +void HELPER (gvec_vclgd64s )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +const uint8_t erm =extract32 (simd_data (desc),4 ,4 ); +const bool XxC =extract32 (simd_data (desc),2 ,1 ); + +vop64_2 (v1, v2, env, true, XxC, erm, vclgd64,GETPC ()); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 10/23] s390x/tcg: Implement VECTOR FP CONVERT TO LOGICAL 64-BIT
Quoted 7 lines · David Hildenbrand
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 23 +++++++++++++++++++++++ 4 files changed, 30 insertions(+)
r~
PATCH 11/23 s390x/tcg: Implement VECTOR FP DIVIDE
In reply to David HildenbrandWe can reuse most of the infrastructure added for VECTOR FP ADD.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 17 +++++++++++++++++ 4 files changed, 24 insertions(+)
target/s390x/helper.h +2 -0
@@ -274,6 +274,8 @@ DEF_HELPER_FLAGS_4(gvec_vcgd64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vcgd64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vclgd64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vclgd64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_5(gvec_vfd64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_5(gvec_vfd64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1226,6 +1226,8 @@ F(0xe7c2, VCGD, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) /* VECTOR FP CONVERT TO LOGICAL 64-BIT */ F(0xe7c0, VCLGD, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) +/* VECTOR FP DIVIDE */ + F(0xe7e5, VFD, VRR_c, V, 0, 0, 0, 0, vfa, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +3 -0
@@ -2560,6 +2560,9 @@ static DisasJumpType op_vfa(DisasContext *s, DisasOps *o)case 0xe3 : fn = se ? gen_helper_gvec_vfa64s : gen_helper_gvec_vfa64;break ; +case 0xe5 : + fn = se ? gen_helper_gvec_vfd64s : gen_helper_gvec_vfd64; +break ;default :g_assert_not_reached (); }
target/s390x/vec_fpu_helper.c +17 -0
@@ -372,3 +372,20 @@ void HELPER(gvec_vclgd64s)(void *v1, const void *v2, CPUS390XState *env,vop64_2 (v1, v2, env, true, XxC, erm, vclgd64,GETPC ()); } + +static uint64_t vfd64 (uint64_t a,uint64_t b,float_status *s) +{ +return float64_val (float64_div (make_float64 (a),make_float64 (b), s)); +} + +void HELPER (gvec_vfd64 )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vop64_3 (v1, v2, v3, env, false, vfd64,GETPC ()); +} + +void HELPER (gvec_vfd64s )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vop64_3 (v1, v2, v3, env, true, vfd64,GETPC ()); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 11/23] s390x/tcg: Implement VECTOR FP DIVIDE
Quoted 9 lines · David Hildenbrand
We can reuse most of the infrastructure added for VECTOR FP ADD.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 17 +++++++++++++++++ 4 files changed, 24 insertions(+)
r~
PATCH 12/23 s390x/tcg: Implement VECTOR LOAD FP INTEGER
In reply to David HildenbrandWe can reuse most of the infrastructure introduced for VECTOR FP CONVERT FROM FIXED 64-BIT and friends.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 23 +++++++++++++++++++++++ 4 files changed, 30 insertions(+)
target/s390x/helper.h +2 -0
@@ -276,6 +276,8 @@ DEF_HELPER_FLAGS_4(gvec_vclgd64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vclgd64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_5(gvec_vfd64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) DEF_HELPER_FLAGS_5(gvec_vfd64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vfi64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vfi64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1228,6 +1228,8 @@ F(0xe7c0, VCLGD, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) /* VECTOR FP DIVIDE */ F(0xe7e5, VFD, VRR_c, V, 0, 0, 0, 0, vfa, 0, IF_VEC) +/* VECTOR LOAD FP INTEGER */ + F(0xe7c7, VFI, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +3 -0
@@ -2669,6 +2669,9 @@ static DisasJumpType op_vcdg(DisasContext *s, DisasOps *o)case 0xc0 : fn = se ? gen_helper_gvec_vclgd64s : gen_helper_gvec_vclgd64;break ; +case 0xc7 : + fn = se ? gen_helper_gvec_vfi64s : gen_helper_gvec_vfi64; +break ;default :g_assert_not_reached (); }
target/s390x/vec_fpu_helper.c +23 -0
@@ -389,3 +389,26 @@ void HELPER(gvec_vfd64s)(void *v1, const void *v2, const void *v3, {vop64_3 (v1, v2, v3, env, true, vfd64,GETPC ()); } + +static uint64_t vfi64 (uint64_t a,float_status *s) +{ +return float64_val (float64_round_to_int (make_float64 (a), s)); +} + +void HELPER (gvec_vfi64 )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +const uint8_t erm =extract32 (simd_data (desc),4 ,4 ); +const bool XxC =extract32 (simd_data (desc),2 ,1 ); + +vop64_2 (v1, v2, env, false, XxC, erm, vfi64,GETPC ()); +} + +void HELPER (gvec_vfi64s )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +const uint8_t erm =extract32 (simd_data (desc),4 ,4 ); +const bool XxC =extract32 (simd_data (desc),2 ,1 ); + +vop64_2 (v1, v2, env, true, XxC, erm, vfi64,GETPC ()); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 12/23] s390x/tcg: Implement VECTOR LOAD FP INTEGER
Quoted 10 lines · David Hildenbrand
We can reuse most of the infrastructure introduced for VECTOR FP CONVERT FROM FIXED 64-BIT and friends.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 23 +++++++++++++++++++++++ 4 files changed, 30 insertions(+)
r~
PATCH 13/23 s390x/tcg: Implement VECTOR LOAD LENGTHENED
In reply to David HildenbrandTake care of reading/indicating the 32-bit elements.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 19 +++++++++++++++++ target/s390x/vec_fpu_helper.c | 36 +++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+)
target/s390x/helper.h +2 -0
@@ -278,6 +278,8 @@ DEF_HELPER_FLAGS_5(gvec_vfd64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) DEF_HELPER_FLAGS_5(gvec_vfd64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vfi64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vfi64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vfll32, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vfll32s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1230,6 +1230,8 @@ F(0xe7e5, VFD, VRR_c, V, 0, 0, 0, 0, vfa, 0, IF_VEC) /* VECTOR LOAD FP INTEGER */ F(0xe7c7, VFI, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) +/* VECTOR LOAD LENGTHENED */ + F(0xe7c4, VFLL, VRR_a, V, 0, 0, 0, 0, vfll, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +19 -0
@@ -2679,3 +2679,22 @@ static DisasJumpType op_vcdg(DisasContext *s, DisasOps *o) deposit32(m4, 4, 4, erm), fn);return DISAS_NEXT ; } + +static DisasJumpType op_vfll (DisasContext *s,DisasOps *o) +{ +const uint8_t fpf =get_field (s->fields, m3); +const uint8_t m4 =get_field (s->fields, m4); +gen_helper_gvec_2_ptr *fn = gen_helper_gvec_vfll32; + +if (fpf !=FPF_SHORT ||extract32 (m4,0 ,3 )) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +if (extract32 (m4,3 ,1 )) { + fn = gen_helper_gvec_vfll32s; + } +gen_gvec_2_ptr (get_field (s->fields, v1),get_field (s->fields, v2), cpu_env, +0 , fn); +return DISAS_NEXT ; +}
target/s390x/vec_fpu_helper.c +36 -0
@@ -412,3 +412,39 @@ void HELPER(gvec_vfi64s)(void *v1, const void *v2, CPUS390XState *env,vop64_2 (v1, v2, env, true, XxC, erm, vfi64,GETPC ()); } + +static void vfll32 (S390Vector *v1,const S390Vector *v2,CPUS390XState *env, +bool s,uintptr_t retaddr) +{ +uint8_t vxc, vec_exc =0 ; +S390Vector tmp = {}; +int i; + +for (i =0 ; i <2 ; i++) { +/* load from even element */ +const float32 a =make_float32 (s390_vec_read_element32 (v2, i *2 )); +const uint64_t ret =float64_val (float32_to_float64 (a, + &env->fpu_status)); + +s390_vec_write_element64 (&tmp, i, ret); +/* indicate the source element */ + vxc =check_ieee_exc (env, i *2 , false, &vec_exc); +if (s || vxc) { +break ; + } + } +handle_ieee_exc (env, vxc, vec_exc, retaddr); + *v1 = tmp; +} + +void HELPER (gvec_vfll32 )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +vfll32 (v1, v2, env, false,GETPC ()); +} + +void HELPER (gvec_vfll32s )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +vfll32 (v1, v2, env, true,GETPC ()); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 13/23] s390x/tcg: Implement VECTOR LOAD LENGTHENED
target/s390x/vec_fpu_helper.c void HELPER(gvec_vfi64s)(void *v1, const void *v2, CPUS390XState *env, · line 425
Quoted 3 lines · David Hildenbrand
target/s390x/vec_fpu_helper.c +3
-0+for (i =0 ; i <2 ; i++) { +/* load from even element */ +const float32 a =make_float32 (s390_vec_read_element32 (v2, i *2 ));
I suppose.
You could also reuse vop64_2 with
static uint64_t vfll(uint64_t a, float_status *s)
{
/* Even float32 are stored in the high half of each doubleword. */
return float32_to_float64(a >> 32, s);
}r~
Re: [Qemu-devel] [PATCH v1 13/23] s390x/tcg: Implement VECTOR LOAD LENGTHENED
Quoted 7 lines · Richard Henderson
target/s390x/vec_fpu_helper.c void HELPER(gvec_vfi64s)(void *v1, const void *v2, CPUS390XState *env, · line 425
Quoted 3 lines · David Hildenbrand
target/s390x/vec_fpu_helper.c +3
-0+for (i =0 ; i <2 ; i++) { +/* load from even element */ +const float32 a =make_float32 (s390_vec_read_element32 (v2, i *2 ));I suppose.
Quoted 8 lines
You could also reuse
vop64_2withstatic
uint64_tvfll(uint64_t a, float_status *s){ /* Even float32 are stored in the high half of each doubleword. */ return float32_to_float64(a >> 32, s); }
Then, I wouldn't be able to indicate the correct element index on exceptions via the vex (has to be the 32-bit index).
Thanks!
Quoted 3 lines
r~
Signature · 3 lines
Thanks, David / dhildenb
Richard Henderson
Reviewed-byRe: [Qemu-devel] [PATCH v1 13/23] s390x/tcg: Implement VECTOR LOAD LENGTHENED
Quoted 17 lines · David Hildenbrand
Quoted 7 lines · Richard Henderson
target/s390x/vec_fpu_helper.c void HELPER(gvec_vfi64s)(void *v1, const void *v2, CPUS390XState *env, · line 425
Quoted 3 lines · David Hildenbrand
target/s390x/vec_fpu_helper.c +3
-0+for (i =0 ; i <2 ; i++) { +/* load from even element */ +const float32 a =make_float32 (s390_vec_read_element32 (v2, i *2 ));I suppose.
Quoted 8 lines
You could also reuse
vop64_2withstatic
uint64_tvfll(uint64_t a, float_status *s){ /* Even float32 are stored in the high half of each doubleword. */ return float32_to_float64(a >> 32, s); }
Quoted 2 lines
Then, I wouldn't be able to indicate the correct element index on exceptions via the vex (has to be the 32-bit index).
Ah, tricky. Missed that detail.
r~
Re: [Qemu-devel] [PATCH v1 13/23] s390x/tcg: Implement VECTOR LOAD LENGTHENED
Quoted 18 lines · Richard Henderson
Quoted 17 lines · David Hildenbrand
Quoted 15 lines · Richard Henderson
target/s390x/vec_fpu_helper.c void HELPER(gvec_vfi64s)(void *v1, const void *v2, CPUS390XState *env, · line 425
Quoted 3 lines · David Hildenbrand
target/s390x/vec_fpu_helper.c +3
-0+for (i =0 ; i <2 ; i++) { +/* load from even element */ +const float32 a =make_float32 (s390_vec_read_element32 (v2, i *2 ));I suppose.
You could also reuse
vop64_2withstatic
uint64_tvfll(uint64_t a, float_status *s){ /* Even float32 are stored in the high half of each doubleword. */ return float32_to_float64(a >> 32, s); }
Quoted 2 lines
Quoted 2 lines
Then, I wouldn't be able to indicate the correct element index on exceptions via the vex (has to be the 32-bit index).
I guess we can later handle all type conversions (lower -> bigger) via this single function (passing the source size). Then we only need a second function for the other direction.
Thanks!
Quoted 8 lines
Ah, tricky. Missed that detail.
Reviewed-by Richard Henderson <[email protected]>r~
Signature · 3 lines
Thanks, David / dhildenb
PATCH 14/23 s390x/tcg: Implement VECTOR LOAD ROUNDED
In reply to David HildenbrandWe can reuse some of the infrastructure introduced for VECTOR FP CONVERT FROM FIXED 64-BIT and friends.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 43 +++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+)
target/s390x/helper.h +2 -0
@@ -280,6 +280,8 @@ DEF_HELPER_FLAGS_4(gvec_vfi64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vfi64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vfll32, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vfll32s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vflr64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vflr64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1232,6 +1232,8 @@ F(0xe7c7, VFI, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) /* VECTOR LOAD LENGTHENED */ F(0xe7c4, VFLL, VRR_a, V, 0, 0, 0, 0, vfll, 0, IF_VEC) +/* VECTOR LOAD ROUNDED */ + F(0xe7c5, VFLR, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +3 -0
@@ -2672,6 +2672,9 @@ static DisasJumpType op_vcdg(DisasContext *s, DisasOps *o)case 0xc7 : fn = se ? gen_helper_gvec_vfi64s : gen_helper_gvec_vfi64;break ; +case 0xc5 : + fn = se ? gen_helper_gvec_vflr64s : gen_helper_gvec_vflr64; +break ;default :g_assert_not_reached (); }
target/s390x/vec_fpu_helper.c +43 -0
46 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 14/23] s390x/tcg: Implement VECTOR LOAD ROUNDED
Quoted 10 lines · David Hildenbrand
We can reuse some of the infrastructure introduced for VECTOR FP CONVERT FROM FIXED 64-BIT and friends.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 43 +++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+)
r~
PATCH 15/23 s390x/tcg: Implement VECTOR FP MULTIPLY
In reply to David HildenbrandVery similar to VECTOR FP DIVIDE.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 17 +++++++++++++++++ 4 files changed, 24 insertions(+)
target/s390x/helper.h +2 -0
@@ -282,6 +282,8 @@ DEF_HELPER_FLAGS_4(gvec_vfll32, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vfll32s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vflr64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vflr64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_5(gvec_vfm64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_5(gvec_vfm64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1234,6 +1234,8 @@ F(0xe7c4, VFLL, VRR_a, V, 0, 0, 0, 0, vfll, 0, IF_VEC) /* VECTOR LOAD ROUNDED */ F(0xe7c5, VFLR, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) +/* VECTOR FP MULTIPLY */ + F(0xe7e7, VFM, VRR_c, V, 0, 0, 0, 0, vfa, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +3 -0
@@ -2563,6 +2563,9 @@ static DisasJumpType op_vfa(DisasContext *s, DisasOps *o)case 0xe5 : fn = se ? gen_helper_gvec_vfd64s : gen_helper_gvec_vfd64;break ; +case 0xe7 : + fn = se ? gen_helper_gvec_vfm64s : gen_helper_gvec_vfm64; +break ;default :g_assert_not_reached (); }
target/s390x/vec_fpu_helper.c +17 -0
@@ -491,3 +491,20 @@ void HELPER(gvec_vflr64s)(void *v1, const void *v2, CPUS390XState *env,vflr64 (v1, v2, env, true, XxC, erm,GETPC ()); } + +static uint64_t vfm64 (uint64_t a,uint64_t b,float_status *s) +{ +return float64_val (float64_mul (make_float64 (a),make_float64 (b), s)); +} + +void HELPER (gvec_vfm64 )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vop64_3 (v1, v2, v3, env, false, vfm64,GETPC ()); +} + +void HELPER (gvec_vfm64s )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vop64_3 (v1, v2, v3, env, true, vfm64,GETPC ()); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 15/23] s390x/tcg: Implement VECTOR FP MULTIPLY
Quoted 9 lines · David Hildenbrand
Very similar to VECTOR FP DIVIDE.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 17 +++++++++++++++++ 4 files changed, 24 insertions(+)
r~
PATCH 16/23 s390x/tcg: Implement VECTOR FP MULTIPLY AND (ADD|SUBTRACT)
In reply to David Hildenbrand--- target/s390x/helper.h | 4 +++ target/s390x/insn-data.def | 4 +++ target/s390x/translate_vx.inc.c | 23 +++++++++++++ target/s390x/vec_fpu_helper.c | 61 +++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+)
target/s390x/helper.h +4 -0
@@ -284,6 +284,10 @@ DEF_HELPER_FLAGS_4(gvec_vflr64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vflr64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_5(gvec_vfm64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) DEF_HELPER_FLAGS_5(gvec_vfm64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_6(gvec_vfma64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_6(gvec_vfma64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_6(gvec_vfms64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_6(gvec_vfms64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +4 -0
@@ -1236,6 +1236,10 @@ F(0xe7c5, VFLR, VRR_a, V, 0, 0, 0, 0, vcdg, 0, IF_VEC) /* VECTOR FP MULTIPLY */ F(0xe7e7, VFM, VRR_c, V, 0, 0, 0, 0, vfa, 0, IF_VEC) +/* VECTOR FP MULTIPLY AND ADD */ + F(0xe78f, VFMA, VRR_e, V, 0, 0, 0, 0, vfma, 0, IF_VEC) +/* VECTOR FP MULTIPLY AND SUBTRACT */ + F(0xe78e, VFMS, VRR_e, V, 0, 0, 0, 0, vfma, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +23 -0
@@ -2704,3 +2704,26 @@ static DisasJumpType op_vfll(DisasContext *s, DisasOps *o) 0, fn);return DISAS_NEXT ; } + +static DisasJumpType op_vfma (DisasContext *s,DisasOps *o) +{ +const uint8_t m5 =get_field (s->fields, m5); +const uint8_t fpf =get_field (s->fields, m6); +const bool se =extract32 (m5,3 ,1 ); +gen_helper_gvec_4_ptr *fn; + +if (fpf !=FPF_LONG ||extract32 (m5,0 ,3 )) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +if (s->fields->op2 ==0x8f ) { + fn = se ? gen_helper_gvec_vfma64s : gen_helper_gvec_vfma64; + }else { + fn = se ? gen_helper_gvec_vfms64s : gen_helper_gvec_vfms64; + } +gen_gvec_4_ptr (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3),get_field (s->fields, v4), cpu_env, +0 , fn); +return DISAS_NEXT ; +}
target/s390x/vec_fpu_helper.c +61 -0
70 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 16/23] s390x/tcg: Implement VECTOR FP MULTIPLY AND (ADD|SUBTRACT)
target/s390x/vec_fpu_helper.c static void vop64_3(S390Vector *v1, const S390Vector *v2, const S390Vector *v3, · line 133
Quoted 6 lines · David Hildenbrand
target/s390x/vec_fpu_helper.c +6
-0+typedef uint64_t (*vop64_4_fn )(uint64_t a,uint64_t b,uint64_t c, +float_status *s); +static void vop64_4 (S390Vector *v1,const S390Vector *v2,const S390Vector *v3, +const S390Vector *v4,CPUS390XState *env,bool s, +vop64_4_fn fn,uintptr_t retaddr) +{
Surely this is only going to be used for FMA/FMS.
Why not just pass in the float_muladd_* constant
to pass on to float64_muladd?
r~
Re: [Qemu-devel] [PATCH v1 16/23] s390x/tcg: Implement VECTOR FP MULTIPLY AND (ADD|SUBTRACT)
Quoted 11 lines · Richard Henderson
target/s390x/vec_fpu_helper.c static void vop64_3(S390Vector *v1, const S390Vector *v2, const S390Vector *v3, · line 133
Quoted 6 lines · David Hildenbrand
target/s390x/vec_fpu_helper.c +6
-0+typedef uint64_t (*vop64_4_fn )(uint64_t a,uint64_t b,uint64_t c, +float_status *s); +static void vop64_4 (S390Vector *v1,const S390Vector *v2,const S390Vector *v3, +const S390Vector *v4,CPUS390XState *env,bool s, +vop64_4_fn fn,uintptr_t retaddr) +{Surely this is only going to be used for FMA/FMS.
Why not just pass in the float_muladd_* constant
to pass on tofloat64_muladd?
I actually had something similar before, but makes sense, as this will really only be used for these functions.
Thanks!
Quoted 4 lines
r~
Signature · 3 lines
Thanks, David / dhildenb
Quoted 69 lines · David Hildenbrand
This is the final part of vector instruction support for s390x. It is based on part 2, which is will send a pull-request for to Conny soon.
Part 1: Vector Support Instructions
Part 2: Vector Integer Instructions
Part 3: Vector String Instructions
Part 4: Vector Floating-Point InstructionsThe current state can be found at (kept updated):
https://github.com/davidhildenbrand/qemu/tree/vxIt is based on:
- [PATCH v2 0/5] s390x/tcg: Vector Instruction Support Part 3
- [PATCH v1 0/2] s390x: Fix vector register alignmentWith the current state I can boot Linux kernel + user space compiled with SIMD support. This allows to boot distributions compiled exclusively for z13, requiring SIMD support. Also, it is now possible to build a complete kernel using rpmbuild as quite some issues have been sorted out.
While the current state works fine for me with RHEL 8, I am experiencing some issues with newer userspace versions (I suspect glibc). I'll have to look into the details first - could be a BUG in !vector instruction or a BUG in a vector instruction that was until now unused.
In this part, all Vector Floating-Point Instructions introduced with the "Vector Facility" are added. Also, the "qemu" model is changed to a z13 machine.
David Hildenbrand (23):
s390x: Useuint64_tfor vector registers
s390x/tcg: Introducetcg_s390_vector_exception()s390x/tcg: Exportfloat_comp_to_cc()and float(32|64|128)_dcmask() s390x/tcg: Implement VECTOR FP ADD
s390x/tcg: Implement VECTOR FP COMPARE (AND SIGNAL) SCALAR s390x/tcg: Implement VECTOR FP COMPARE (EQUAL|HIGH|HIGH OR EQUAL) s390x/tcg: Implement VECTOR FP CONVERT FROM FIXED 64-BIT s390x/tcg: Implement VECTOR FP CONVERT FROM LOGICAL 64-BIT s390x/tcg: Implement VECTOR FP CONVERT TO FIXED 64-BIT s390x/tcg: Implement VECTOR FP CONVERT TO LOGICAL 64-BIT s390x/tcg: Implement VECTOR FP DIVIDE
s390x/tcg: Implement VECTOR LOAD FP INTEGER
s390x/tcg: Implement VECTOR LOAD LENGTHENED
s390x/tcg: Implement VECTOR LOAD ROUNDED
s390x/tcg: Implement VECTOR FP MULTIPLY
s390x/tcg: Implement VECTOR FP MULTIPLY AND (ADD|SUBTRACT) s390x/tcg: Implement VECTOR FP PERFORM SIGN OPERATION s390x/tcg: Implement VECTOR FP SQUARE ROOT
s390x/tcg: Implement VECTOR FP SUBTRACT
s390x/tcg: Implement VECTOR FP TEST DATA CLASS IMMEDIATE s390x/tcg: Allow linux-user to use vector instructions s390x/tcg: We support the Vector Facility
s390x: Bump the "qemu" CPU model up to a stripped-down z13hw/s390x/s390-virtio-ccw.c | 2 + linux-user/s390x/signal.c | 4 +- target/s390x/Makefile.objs | 1 + target/s390x/arch_dump.c | 8 +- target/s390x/cpu.c | 3 + target/s390x/cpu.h | 5 +- target/s390x/cpu_models.c | 4 +- target/s390x/excp_helper.c | 21 +- target/s390x/fpu_helper.c | 4 +- target/s390x/gdbstub.c | 16 +- target/s390x/gen-features.c | 10 +- target/s390x/helper.c | 10 +- target/s390x/helper.h | 46 +++ target/s390x/insn-data.def | 45 +++ target/s390x/internal.h | 4 +
Quoted 9 lines
target/s390x/kvm.c | 16 +- target/s390x/machine.c | 128 +++---- target/s390x/tcg_s390x.h | 2 + target/s390x/translate.c | 2 +- target/s390x/translate_vx.inc.c | 274 ++++++++++++++ target/s390x/vec_fpu_helper.c | 644 ++++++++++++++++++++++++++++++++ 21 files changed, 1145 insertions(+), 104 deletions(-) create mode 100644 target/s390x/vec_fpu_helper.c
Nasty git "-identity" + manual "-cc" collision.
CC'ing some more people.
Signature · 3 lines
Thanks, David / dhildenb
PATCH 17/23 s390x/tcg: Implement VECTOR FP PERFORM SIGN OPERATION
In reply to David HildenbrandThe only FP instruction we can implement without an helper.
--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 42 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1240,6 +1240,8 @@ F(0xe78f, VFMA, VRR_e, V, 0, 0, 0, 0, vfma, 0, IF_VEC) /* VECTOR FP MULTIPLY AND SUBTRACT */ F(0xe78e, VFMS, VRR_e, V, 0, 0, 0, 0, vfma, 0, IF_VEC) +/* VECTOR FP PERFORM SIGN OPERATION */ + F(0xe7cc, VFPSO, VRR_a, V, 0, 0, 0, 0, vfpso, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +42 -0
45 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 17/23] s390x/tcg: Implement VECTOR FP PERFORM SIGN OPERATION
Quoted 31 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +31
-0+static DisasJumpType op_vfpso (DisasContext *s,DisasOps *o) +{ +const uint8_t fpf =get_field (s->fields, m3); +const uint8_t m4 =get_field (s->fields, m4); +const uint8_t m5 =get_field (s->fields, m5); +const bool se =extract32 (m4,3 ,1 ); +TCGv_i64 tmp; +int i; + +if (fpf !=FPF_LONG ||extract32 (m4,0 ,3 ) || m5 >2 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + + tmp =tcg_temp_new_i64 (); +for (i =0 ; i <2 ; i++) { +read_vec_element_i64 (tmp,get_field (s->fields, v2), i,ES_64 ); + +switch (m5) { +case 0 : +/* sign bit is inverted (complement) */ +tcg_gen_xori_i64 (tmp, tmp,1ull <<63 ); +break ; +case 1 : +/* sign bit is set to one (negative) */ +tcg_gen_ori_i64 (tmp, tmp,1ull <<63 ); +break ; +case 2 : +/* sign bit is set to zero (positive) */ +tcg_gen_andi_i64 (tmp, tmp, (1ull <<63 ) -1 ); +break ;
target/s390x/translate_vx.inc.c static DisasJumpType op_vfma(DisasContext *s, DisasOps *o) · line 2771
Quoted 10 lines
target/s390x/translate_vx.inc.c +10
-0+ } + +write_vec_element_i64 (tmp,get_field (s->fields, v1), i,ES_64 ); +if (se) { +break ; + } + } +tcg_temp_free_i64 (tmp); +return DISAS_NEXT ; +}
Better to use tcg_gen_gvec_{and,xor,or}i to do all of the elements at once. Won't work for FPF_EXTENDED, but much better for FPF_SINGLE, once they're supported.
r~
Re: [Qemu-devel] [PATCH v1 17/23] s390x/tcg: Implement VECTOR FP PERFORM SIGN OPERATION
Quoted 38 lines · Richard Henderson
Quoted 37 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +37
-0+static DisasJumpType op_vfpso (DisasContext *s,DisasOps *o) +{ +const uint8_t fpf =get_field (s->fields, m3); +const uint8_t m4 =get_field (s->fields, m4); +const uint8_t m5 =get_field (s->fields, m5); +const bool se =extract32 (m4,3 ,1 ); +TCGv_i64 tmp; +int i; + +if (fpf !=FPF_LONG ||extract32 (m4,0 ,3 ) || m5 >2 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + + tmp =tcg_temp_new_i64 (); +for (i =0 ; i <2 ; i++) { +read_vec_element_i64 (tmp,get_field (s->fields, v2), i,ES_64 ); + +switch (m5) { +case 0 : +/* sign bit is inverted (complement) */ +tcg_gen_xori_i64 (tmp, tmp,1ull <<63 ); +break ; +case 1 : +/* sign bit is set to one (negative) */ +tcg_gen_ori_i64 (tmp, tmp,1ull <<63 ); +break ; +case 2 : +/* sign bit is set to zero (positive) */ +tcg_gen_andi_i64 (tmp, tmp, (1ull <<63 ) -1 ); +break ; + } + +write_vec_element_i64 (tmp,get_field (s->fields, v1), i,ES_64 ); +if (se) { +break ; + }
Quoted 9 lines
target/s390x/translate_vx.inc.c static DisasJumpType op_vfma(DisasContext *s, DisasOps *o) · line 2771
Quoted 4 lines
target/s390x/translate_vx.inc.c +4
-0+ } +tcg_temp_free_i64 (tmp); +return DISAS_NEXT ; +}Better to use tcg_gen_gvec_{and,xor,or}i to do all of the elements at once. Won't work for
FPF_EXTENDED, but much better forFPF_SINGLE, once they're supported.
How could I miss that :)
Thanks!
Signature · 3 lines
Thanks, David / dhildenb
PATCH 18/23 s390x/tcg: Implement VECTOR FP SQUARE ROOT
In reply to David HildenbrandSimulate XxC=0 and ERM=0 (current mode), so we can use the existing helper function.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 19 +++++++++++++++++++ target/s390x/vec_fpu_helper.c | 17 +++++++++++++++++ 4 files changed, 40 insertions(+)
target/s390x/helper.h +2 -0
@@ -288,6 +288,8 @@ DEF_HELPER_FLAGS_6(gvec_vfma64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, cptr, env DEF_HELPER_FLAGS_6(gvec_vfma64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, cptr, env, i32) DEF_HELPER_FLAGS_6(gvec_vfms64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, cptr, env, i32) DEF_HELPER_FLAGS_6(gvec_vfms64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vfsq64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_4(gvec_vfsq64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1242,6 +1242,8 @@ F(0xe78e, VFMS, VRR_e, V, 0, 0, 0, 0, vfma, 0, IF_VEC) /* VECTOR FP PERFORM SIGN OPERATION */ F(0xe7cc, VFPSO, VRR_a, V, 0, 0, 0, 0, vfpso, 0, IF_VEC) +/* VECTOR FP SQUARE ROOT */ + F(0xe7ce, VFSQ, VRR_a, V, 0, 0, 0, 0, vfsq, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +19 -0
@@ -2769,3 +2769,22 @@ static DisasJumpType op_vfpso(DisasContext *s, DisasOps *o)tcg_temp_free_i64 (tmp);return DISAS_NEXT ; } + +static DisasJumpType op_vfsq (DisasContext *s,DisasOps *o) +{ +const uint8_t fpf =get_field (s->fields, m3); +const uint8_t m4 =get_field (s->fields, m4); +gen_helper_gvec_2_ptr *fn = gen_helper_gvec_vfsq64; + +if (fpf !=FPF_LONG ||extract32 (m4,0 ,3 )) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +if (extract32 (m4,3 ,1 )) { + fn = gen_helper_gvec_vfsq64s; + } +gen_gvec_2_ptr (get_field (s->fields, v1),get_field (s->fields, v2), cpu_env, +0 , fn); +return DISAS_NEXT ; +}
target/s390x/vec_fpu_helper.c +17 -0
@@ -569,3 +569,20 @@ void HELPER(gvec_vfms64s)(void *v1, const void *v2, const void *v3, {vop64_4 (v1, v2, v3, v4, env, true, vfms64,GETPC ()); } + +static uint64_t vfsq64 (uint64_t a,float_status *s) +{ +return float64_val (float64_sqrt (make_float64 (a), s)); +} + +void HELPER (gvec_vfsq64 )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +vop64_2 (v1, v2, env, false, false,0 , vfsq64,GETPC ()); +} + +void HELPER (gvec_vfsq64s )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +vop64_2 (v1, v2, env, true, false,0 , vfsq64,GETPC ()); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 18/23] s390x/tcg: Implement VECTOR FP SQUARE ROOT
Quoted 10 lines · David Hildenbrand
Simulate XxC=0 and ERM=0 (current mode), so we can use the existing helper function.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 19 +++++++++++++++++++ target/s390x/vec_fpu_helper.c | 17 +++++++++++++++++ 4 files changed, 40 insertions(+)
r~
PATCH 19/23 s390x/tcg: Implement VECTOR FP SUBTRACT
In reply to David HildenbrandSimilar to VECTOR FP ADD.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 17 +++++++++++++++++ 4 files changed, 24 insertions(+)
target/s390x/helper.h +2 -0
@@ -290,6 +290,8 @@ DEF_HELPER_FLAGS_6(gvec_vfms64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, cptr, env DEF_HELPER_FLAGS_6(gvec_vfms64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vfsq64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vfsq64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) +DEF_HELPER_FLAGS_5(gvec_vfs64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_FLAGS_5(gvec_vfs64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1244,6 +1244,8 @@ F(0xe7cc, VFPSO, VRR_a, V, 0, 0, 0, 0, vfpso, 0, IF_VEC) /* VECTOR FP SQUARE ROOT */ F(0xe7ce, VFSQ, VRR_a, V, 0, 0, 0, 0, vfsq, 0, IF_VEC) +/* VECTOR FP SUBTRACT */ + F(0xe7e2, VFS, VRR_c, V, 0, 0, 0, 0, vfa, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +3 -0
@@ -2566,6 +2566,9 @@ static DisasJumpType op_vfa(DisasContext *s, DisasOps *o)case 0xe7 : fn = se ? gen_helper_gvec_vfm64s : gen_helper_gvec_vfm64;break ; +case 0xe2 : + fn = se ? gen_helper_gvec_vfs64s : gen_helper_gvec_vfs64; +break ;default :g_assert_not_reached (); }
target/s390x/vec_fpu_helper.c +17 -0
@@ -586,3 +586,20 @@ void HELPER(gvec_vfsq64s)(void *v1, const void *v2, CPUS390XState *env, {vop64_2 (v1, v2, env, true, false,0 , vfsq64,GETPC ()); } + +static uint64_t vfs64 (uint64_t a,uint64_t b,float_status *s) +{ +return float64_val (float64_sub (make_float64 (a),make_float64 (b), s)); +} + +void HELPER (gvec_vfs64 )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vop64_3 (v1, v2, v3, env, false, vfs64,GETPC ()); +} + +void HELPER (gvec_vfs64s )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vop64_3 (v1, v2, v3, env, true, vfs64,GETPC ()); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 19/23] s390x/tcg: Implement VECTOR FP SUBTRACT
Quoted 9 lines · David Hildenbrand
Similar to VECTOR FP ADD.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 3 +++ target/s390x/vec_fpu_helper.c | 17 +++++++++++++++++ 4 files changed, 24 insertions(+)
r~
PATCH 20/23 s390x/tcg: Implement VECTOR FP TEST DATA CLASS IMMEDIATE
In reply to David HildenbrandWe can reuse float64_dcmask().
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 21 ++++++++++++++++++ target/s390x/vec_fpu_helper.c | 39 +++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+)
target/s390x/helper.h +2 -0
@@ -292,6 +292,8 @@ DEF_HELPER_FLAGS_4(gvec_vfsq64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vfsq64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_5(gvec_vfs64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) DEF_HELPER_FLAGS_5(gvec_vfs64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_4(gvec_vftci64, void, ptr, cptr, env, i32) +DEF_HELPER_4(gvec_vftci64s, void, ptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1246,6 +1246,8 @@ F(0xe7ce, VFSQ, VRR_a, V, 0, 0, 0, 0, vfsq, 0, IF_VEC) /* VECTOR FP SUBTRACT */ F(0xe7e2, VFS, VRR_c, V, 0, 0, 0, 0, vfa, 0, IF_VEC) +/* VECTOR FP TEST DATA CLASS IMMEDIATE */ + F(0xe74a, VFTCI, VRI_e, V, 0, 0, 0, 0, vftci, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +21 -0
@@ -2791,3 +2791,24 @@ static DisasJumpType op_vfsq(DisasContext *s, DisasOps *o) 0, fn);return DISAS_NEXT ; } + +static DisasJumpType op_vftci (DisasContext *s,DisasOps *o) +{ +const uint16_t i3 =get_field (s->fields, i3); +const uint8_t fpf =get_field (s->fields, m4); +const uint8_t m5 =get_field (s->fields, m5); +gen_helper_gvec_2_ptr *fn = gen_helper_gvec_vftci64; + +if (fpf !=FPF_LONG ||extract32 (m5,0 ,3 )) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +if (extract32 (m5,3 ,1 )) { + fn = gen_helper_gvec_vftci64s; + } +gen_gvec_2_ptr (get_field (s->fields, v1),get_field (s->fields, v2), cpu_env, + i3, fn); +set_cc_static (s); +return DISAS_NEXT ; +}
target/s390x/vec_fpu_helper.c +39 -0
@@ -603,3 +603,42 @@ void HELPER(gvec_vfs64s)(void *v1, const void *v2, const void *v3, {vop64_3 (v1, v2, v3, env, true, vfs64,GETPC ()); } + +static int vftci64 (S390Vector *v1,const S390Vector *v2,CPUS390XState *env, +bool s,uint16_t i3) +{ +int i, match =0 ; + +for (i =0 ; i <2 ; i++) { +float64 a =make_float64 (s390_vec_read_element64 (v2, i)); + +if (float64_dcmask (env, a) & i3) { + match++; +s390_vec_write_element64 (v1, i,-1ull ); + }else { +s390_vec_write_element64 (v1, i,0 ); + } +if (s) { +break ; + } + } + +if (match == i +1 ) { +return 0 ; + }else if (match) { +return 1 ; + } +return 3 ; +} + +void HELPER (gvec_vftci64 )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ + env->cc_op =vftci64 (v1, v2, env, false,simd_data (desc)); +} + +void HELPER (gvec_vftci64s )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ + env->cc_op =vftci64 (v1, v2, env, true,simd_data (desc)); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 20/23] s390x/tcg: Implement VECTOR FP TEST DATA CLASS IMMEDIATE
Quoted 88 lines · David Hildenbrand
We can reuse
float64_dcmask().Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 21 ++++++++++++++++++ target/s390x/vec_fpu_helper.c | 39 +++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+)target/s390x/helper.h +2
-0@@ -292,6 +292,8 @@ DEF_HELPER_FLAGS_4(gvec_vfsq64, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_4(gvec_vfsq64s, TCG_CALL_NO_WG, void, ptr, cptr, env, i32) DEF_HELPER_FLAGS_5(gvec_vfs64, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) DEF_HELPER_FLAGS_5(gvec_vfs64s, TCG_CALL_NO_WG, void, ptr, cptr, cptr, env, i32) +DEF_HELPER_4(gvec_vftci64, void, ptr, cptr, env, i32) +DEF_HELPER_4(gvec_vftci64s, void, ptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)target/s390x/insn-data.def +2
-0@@ -1246,6 +1246,8 @@ F(0xe7ce, VFSQ, VRR_a, V, 0, 0, 0, 0, vfsq, 0, IF_VEC) /* VECTOR FP SUBTRACT */ F(0xe7e2, VFS, VRR_c, V, 0, 0, 0, 0, vfa, 0, IF_VEC) +/* VECTOR FP TEST DATA CLASS IMMEDIATE */ + F(0xe74a, VFTCI, VRI_e, V, 0, 0, 0, 0, vftci, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */target/s390x/translate_vx.inc.c +21
-0@@ -2791,3 +2791,24 @@ static DisasJumpType op_vfsq(DisasContext *s, DisasOps *o) 0, fn);return DISAS_NEXT ; } + +static DisasJumpType op_vftci (DisasContext *s,DisasOps *o) +{ +const uint16_t i3 =get_field (s->fields, i3); +const uint8_t fpf =get_field (s->fields, m4); +const uint8_t m5 =get_field (s->fields, m5); +gen_helper_gvec_2_ptr *fn = gen_helper_gvec_vftci64; + +if (fpf !=FPF_LONG ||extract32 (m5,0 ,3 )) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +if (extract32 (m5,3 ,1 )) { + fn = gen_helper_gvec_vftci64s; + } +gen_gvec_2_ptr (get_field (s->fields, v1),get_field (s->fields, v2), cpu_env, + i3, fn); +set_cc_static (s); +return DISAS_NEXT ; +}target/s390x/vec_fpu_helper.c +15
-0@@ -603,3 +603,42 @@ void HELPER(gvec_vfs64s)(void *v1, const void *v2, const void *v3, {vop64_3 (v1, v2, v3, env, true, vfs64,GETPC ()); } + +static int vftci64 (S390Vector *v1,const S390Vector *v2,CPUS390XState *env, +bool s,uint16_t i3) +{ +int i, match =0 ; + +for (i =0 ; i <2 ; i++) { +float64 a =make_float64 (s390_vec_read_element64 (v2, i)); + +if (float64_dcmask (env, a) & i3) { + match++; +s390_vec_write_element64 (v1, i,-1ull ); + }else { +s390_vec_write_element64 (v1, i,0 ); + }
target/s390x/vec_fpu_helper.c void HELPER(gvec_vfs64s)(void *v1, const void *v2, const void *v3, · line 630
Quoted 10 lines
target/s390x/vec_fpu_helper.c +10
-0+if (s) { +break ; + } + } + +if (match == i +1 ) { +return 0 ; + }else if (match) { +return 1 ; + }
This is also wrong, similar to the other function.
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v1 20/23] s390x/tcg: Implement VECTOR FP TEST DATA CLASS IMMEDIATE
In reply to David HildenbrandQuoted 9 lines · David Hildenbrand
We can reuse
float64_dcmask().Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 21 ++++++++++++++++++ target/s390x/vec_fpu_helper.c | 39 +++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+)
Modulo the cc value, as discussed,
r~
PATCH 21/23 s390x/tcg: Allow linux-user to use vector instructions
In reply to David HildenbrandOnce we unlock S390_FEAT_VECTOR for TCG, we want linux-user to be able to make use of it.
--- target/s390x/cpu.c | 3 +++ 1 file changed, 3 insertions(+)
target/s390x/cpu.c +3 -0
@@ -145,6 +145,9 @@ static void s390_cpu_full_reset(CPUState *s)#if defined(CONFIG_USER_ONLY )/* user mode should always be allowed to use the full FPU */ env->cregs[0 ] |=CR0_AFP ; +if (s390_has_feat (S390_FEAT_VECTOR )) { + env->cregs[0 ] |=CR0_VECTOR ; + }#endif /* architectured initial value for Breaking-Event-Address register */
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 21/23] s390x/tcg: Allow linux-user to use vector instructions
Quoted 7 lines · David Hildenbrand
Once we unlock
S390_FEAT_VECTORfor TCG, we want linux-user to be able to make use of it.Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/cpu.c | 3 +++ 1 file changed, 3 insertions(+)
r~
PATCH 22/23 s390x/tcg: We support the Vector Facility
In reply to David HildenbrandLet's add it to the max model, so we can enable it.
--- target/s390x/gen-features.c | 1 + 1 file changed, 1 insertion(+)
target/s390x/gen-features.c +1 -0
@@ -702,6 +702,7 @@ static uint16_t qemu_LATEST[] = {static uint16_t qemu_MAX[] = {/* z13+ features */ S390_FEAT_STFLE_53 , +S390_FEAT_VECTOR ,/* generates a dependency warning, leave it out for now */ S390_FEAT_MSA_EXT_5 , };
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 22/23] s390x/tcg: We support the Vector Facility
Quoted 6 lines · David Hildenbrand
Let's add it to the max model, so we can enable it.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/gen-features.c | 1 + 1 file changed, 1 insertion(+)
r~
PATCH 23/23 s390x: Bump the "qemu" CPU model up to a stripped-down z13
In reply to David HildenbrandWe don't care about the other two missing base features:
- S390_FEAT_DFP_PACKED_CONVERSION
- S390_FEAT_GROUP_GEN13_PTFF
--- hw/s390x/s390-virtio-ccw.c | 2 ++ target/s390x/cpu_models.c | 4 ++-- target/s390x/gen-features.c | 11 +++++++---- 3 files changed, 11 insertions(+), 6 deletions(-)
hw/s390x/s390-virtio-ccw.c +2 -0
@@ -669,7 +669,9 @@ DEFINE_CCW_MACHINE(4_1, "4.1", true);static void ccw_machine_4_0_instance_options (MachineState *machine) { +static const S390FeatInit qemu_cpu_feat = {S390_FEAT_LIST_QEMU_V4_0 };ccw_machine_4_1_instance_options (machine); +s390_set_qemu_cpu_model (0x2827 ,12 ,2 , qemu_cpu_feat); }static void ccw_machine_4_0_class_options (MachineClass *mc)
target/s390x/cpu_models.c +2 -2
@@ -86,8 +86,8 @@ static S390CPUDef s390_cpu_defs[] = { CPUDEF_INIT(0x8562, 15, 1, 47, 0x08000000U, "gen15b", "IBM 8562 GA1"), }; -#define QEMU_MAX_CPU_TYPE 0x2827 -#define QEMU_MAX_CPU_GEN 12 +#define QEMU_MAX_CPU_TYPE 0x2964 +#define QEMU_MAX_CPU_GEN 13#define QEMU_MAX_CPU_EC_GA 2static const S390FeatInit qemu_max_cpu_feat_init = {S390_FEAT_LIST_QEMU_MAX };static S390FeatBitmap qemu_max_cpu_feat;
target/s390x/gen-features.c +7 -4
@@ -689,7 +689,7 @@ static uint16_t qemu_V3_1[] = { S390_FEAT_MSA_EXT_4, }; -static uint16_t qemu_LATEST[] = { +static uint16_t qemu_V4_0[] = {/* * Only BFP bits are implemented (HFP, DFP, PFPO and DIVIDE TO INTEGER not * implemented yet).
@@ -698,11 +698,13 @@ static uint16_t qemu_LATEST[] = { S390_FEAT_ZPCI, }; -/* add all new definitions before this point */ -static uint16_t qemu_MAX[] = { -/* z13+ features */ +static uint16_t qemu_LATEST[] = {S390_FEAT_STFLE_53 ,S390_FEAT_VECTOR , +}; + +/* add all new definitions before this point */ +static uint16_t qemu_MAX[] = {/* generates a dependency warning, leave it out for now */ S390_FEAT_MSA_EXT_5 , };
@@ -821,6 +823,7 @@ static FeatGroupDefSpec FeatGroupDef[] = {static FeatGroupDefSpec QemuFeatDef[] = {QEMU_FEAT_INITIALIZER (V2_11 ),QEMU_FEAT_INITIALIZER (V3_1 ), +QEMU_FEAT_INITIALIZER (V4_0 ),QEMU_FEAT_INITIALIZER (LATEST ),QEMU_FEAT_INITIALIZER (MAX ), };
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 23/23] s390x: Bump the "qemu" CPU model up to a stripped-down z13
Quoted 10 lines · David Hildenbrand
We don't care about the other two missing base features:
-S390_FEAT_DFP_PACKED_CONVERSION
-S390_FEAT_GROUP_GEN13_PTFFSigned-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 2 ++ target/s390x/cpu_models.c | 4 ++-- target/s390x/gen-features.c | 11 +++++++---- 3 files changed, 11 insertions(+), 6 deletions(-)
We should get around to supporting DFP at some point. The code is all there, used by target/ppc/.
r~
Re: [Qemu-devel] [PATCH v1 23/23] s390x: Bump the "qemu" CPU model up to a stripped-down z13
Quoted 12 lines · Richard Henderson
Quoted 10 lines · David Hildenbrand
We don't care about the other two missing base features:
-S390_FEAT_DFP_PACKED_CONVERSION
-S390_FEAT_GROUP_GEN13_PTFFSigned-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 2 ++ target/s390x/cpu_models.c | 4 ++-- target/s390x/gen-features.c | 11 +++++++---- 3 files changed, 11 insertions(+), 6 deletions(-)
Quoted 2 lines
We should get around to supporting DFP at some point. The code is all there, used by target/ppc/.
Cool, didn't know about that - will take a look once I have sme spare time. Are you aware of a HFP library?
Thanks!
Quoted 6 lines
Reviewed-by Richard Henderson <[email protected]>r~
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v1 23/23] s390x: Bump the "qemu" CPU model up to a stripped-down z13
Quoted 1 line · David Hildenbrand
Are you aware of a HFP library?
No. It might be possible to shoehorn into softfloat, because I *think* to can treat HFP as BFP with weird rounding. At least that's what I remember from my old college daze on the esa/390.
Otherwise we could maybe steal some code from Hercules. I see "OSI certified" and "Q public license" on the web page, which iirc is compatible.
r~
Re: [Qemu-devel] [PATCH v1 23/23] s390x: Bump the "qemu" CPU model up to a stripped-down z13
Quoted 10 lines · Richard Henderson
Quoted 1 line · David Hildenbrand
Are you aware of a HFP library?
No. It might be possible to shoehorn into softfloat, because I *think* to can treat HFP as BFP with weird rounding. At least that's what I remember from my old college daze on the esa/390.
Otherwise we could maybe steal some code from Hercules. I see "OSI certified" and "Q public license" on the web page, which iirc is compatible.
Right, they support it. Maybe a project for a cold winter evening ;)
Signature · 3 lines
Thanks, David / dhildenb
Quoted 2 lines · David Hildenbrand
This is the final part of vector instruction support for s390x. It is
based
Quoted 7 lines
on part 2, which is will send a pull-request for to Conny soon.
Part 1: Vector Support Instructions
Part 2: Vector Integer Instructions
Part 3: Vector String Instructions
Part 4: Vector Floating-Point Instructions
Congratulations on completing this complex task!
I followed your series (even though I did not make any comment), and I salute this addition to QEMU.
I would just ask you to provide me and others with the link to the detailed documentation on this matter - I had the hardest time trying to find it online.
Thanks in advance!
Aleksandar
Quoted 74 lines
The current state can be found at (kept updated):
https://github.com/davidhildenbrand/qemu/tree/vxIt is based on:
- [PATCH v2 0/5] s390x/tcg: Vector Instruction Support Part 3
- [PATCH v1 0/2] s390x: Fix vector register alignmentWith the current state I can boot Linux kernel + user space compiled with SIMD support. This allows to boot distributions compiled exclusively for z13, requiring SIMD support. Also, it is now possible to build a complete kernel using rpmbuild as quite some issues have been sorted out.
While the current state works fine for me with RHEL 8, I am experiencing some issues with newer userspace versions (I suspect glibc). I'll have to look into the details first - could be a BUG in !vector instruction or a BUG in a vector instruction that was until now unused.
In this part, all Vector Floating-Point Instructions introduced with the "Vector Facility" are added. Also, the "qemu" model is changed to a z13 machine.
David Hildenbrand (23):
s390x: Useuint64_tfor vector registers
s390x/tcg: Introducetcg_s390_vector_exception()s390x/tcg: Exportfloat_comp_to_cc()and float(32|64|128)_dcmask() s390x/tcg: Implement VECTOR FP ADD
s390x/tcg: Implement VECTOR FP COMPARE (AND SIGNAL) SCALAR s390x/tcg: Implement VECTOR FP COMPARE (EQUAL|HIGH|HIGH OR EQUAL) s390x/tcg: Implement VECTOR FP CONVERT FROM FIXED 64-BIT s390x/tcg: Implement VECTOR FP CONVERT FROM LOGICAL 64-BIT s390x/tcg: Implement VECTOR FP CONVERT TO FIXED 64-BIT s390x/tcg: Implement VECTOR FP CONVERT TO LOGICAL 64-BIT s390x/tcg: Implement VECTOR FP DIVIDE
s390x/tcg: Implement VECTOR LOAD FP INTEGER
s390x/tcg: Implement VECTOR LOAD LENGTHENED
s390x/tcg: Implement VECTOR LOAD ROUNDED
s390x/tcg: Implement VECTOR FP MULTIPLY
s390x/tcg: Implement VECTOR FP MULTIPLY AND (ADD|SUBTRACT) s390x/tcg: Implement VECTOR FP PERFORM SIGN OPERATION s390x/tcg: Implement VECTOR FP SQUARE ROOT
s390x/tcg: Implement VECTOR FP SUBTRACT
s390x/tcg: Implement VECTOR FP TEST DATA CLASS IMMEDIATE s390x/tcg: Allow linux-user to use vector instructions s390x/tcg: We support the Vector Facility
s390x: Bump the "qemu" CPU model up to a stripped-down z13hw/s390x/s390-virtio-ccw.c | 2 + linux-user/s390x/signal.c | 4 +- target/s390x/Makefile.objs | 1 + target/s390x/arch_dump.c | 8 +- target/s390x/cpu.c | 3 + target/s390x/cpu.h | 5 +- target/s390x/cpu_models.c | 4 +- target/s390x/excp_helper.c | 21 +- target/s390x/fpu_helper.c | 4 +- target/s390x/gdbstub.c | 16 +- target/s390x/gen-features.c | 10 +- target/s390x/helper.c | 10 +- target/s390x/helper.h | 46 +++ target/s390x/insn-data.def | 45 +++ target/s390x/internal.h | 4 + target/s390x/kvm.c | 16 +- target/s390x/machine.c | 128 +++---- target/s390x/tcg_s390x.h | 2 + target/s390x/translate.c | 2 +- target/s390x/translate_vx.inc.c | 274 ++++++++++++++ target/s390x/vec_fpu_helper.c | 644 ++++++++++++++++++++++++++++++++ 21 files changed, 1145 insertions(+), 104 deletions(-) create mode 100644 target/s390x/vec_fpu_helper.c--
2.20.1
Quoted 14 lines · Aleksandar Markovic
Quoted 2 lines · On May 31, 2019 12:48 PM, "David Hildenbrand" <[email protected]…
This is the final part of vector instruction support for s390x. It is
based
Quoted 7 lines
on part 2, which is will send a pull-request for to Conny soon.
Part 1: Vector Support Instructions Part 2: Vector Integer Instructions Part 3: Vector String Instructions Part 4: Vector Floating-Point Instructions
Quoted 4 lines
Congratulations on completing this complex task!
I followed your series (even though I did not make any comment), and I salute this addition to QEMU.
Thanks, glad to hear that this addition might be beneficial for others as well!
Quoted 4 lines
I would just ask you to provide me and others with the link to the detailed documentation on this matter - I had the hardest time trying to find it online.
So, the s390x architecture (including vector instructions) are described in the z/Architecture Principles of Operation. You can find the latest publication at [1].
Regarding TCG internals/vector instruction support ... well, most documentation is the code itself/implementing architectures. :)
Please let me know if you need more information.
Cheers!
[1]
https://www-01.ibm.com/support/docview.wss?uid=isg2b9de5f05a9d57819852571c500428f9a
Quoted 4 lines
Thanks in advance!
Aleksandar
Signature · 3 lines
Thanks, David / dhildenb