s390x/tcg: Vector Instruction Support Part 4
v2 cover s390x/tcg: Vector Instruction Support Part 4
This is the final part of vector instruction support for s390x.
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 already found and fixed some stack overflow protection issues (stfle instruction). I still see random rpm database corruptions and rpmbuild doesn't work correctly (looks like another stack protection issue).
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.
v1 -> v2:
- get rid of make_float64() and float64_val().
- fixed two cc calculation issues (thanks Richard)
- Rework "VECTOR FP COMPARE (EQUAL|HIGH|HIGH OR EQUAL)"
- Rework "VECTOR FP MULTIPLY AND (ADD|SUBTRACT)"
- Use gvec expansion in "s390x/tcg: Implement VECTOR FP PERFORM SIGN OPERATION"
David Hildenbrand (22):
s390x/tcg: Store only the necessary amount of doublewords for STFLE 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
target/s390x/Makefile.objs | 1 + target/s390x/cpu.c | 3 + target/s390x/cpu.h | 1 + target/s390x/excp_helper.c | 15 + target/s390x/fpu_helper.c | 4 +- target/s390x/gen-features.c | 1 + target/s390x/helper.h | 46 +++ target/s390x/insn-data.def | 45 +++ target/s390x/internal.h | 4 + target/s390x/misc_helper.c | 8 +- target/s390x/tcg_s390x.h | 2 + target/s390x/translate_vx.inc.c | 284 +++++++++++++++ target/s390x/vec_fpu_helper.c | 625 ++++++++++++++++++++++++++++++++ 13 files changed, 1036 insertions(+), 3 deletions(-) create mode 100644 target/s390x/vec_fpu_helper.c
Signature · 1 line
2.21.0
PATCH v2 1/22 s390x/tcg: Store only the necessary amount of doublewords for STFLE
The PoP (z14, 7-382) says:
Doublewords to the right of the doubleword in which the highest-numbered facility bit is assigned for a model may or may not be stored.
However, stack protection in certain binaries can't deal with that. "gzip" example code:
f1b4: a7 08 00 03 lhi %r0,3 f1b8: b2 b0 f0 a0 stfle 160(%r15) f1bc: e3 20 f0 b2 00 90 llgc %r2,178(%r15) f1c2: c0 2b 00 00 00 01 nilf %r2,1 f1c8: b2 4f 00 10 ear %r1,%a0 f1cc: b9 14 00 22 lgfr %r2,%r2 f1d0: eb 11 00 20 00 0d sllg %r1,%r1,32 f1d6: b2 4f 00 11 ear %r1,%a1 f1da: d5 07 f0 b8 10 28 clc 184(8,%r15),40(%r1) f1e0: a7 74 00 06 jne f1ec <file_read@@Base+0x1bc> f1e4: eb ef f1 30 00 04 lmg %r14,%r15,304(%r15) f1ea: 07 fe br %r14 f1ec: c0 e5 ff ff 9d 6e brasl %r14,2cc8 <__stack_chk_fail@plt>
In QEMU, we currently have:
max_bytes = 24
the code asks for (3 + 1) doublewords == 32 bytes.
If we write 32 bytes instead of only 24, and return "2 + 1" doublewords ("one less than the number of doulewords needed to contain all of the
facility bits"), the example code detects a stack corruption.
In my opinion, the code is wrong. However, it seems to work fine on real machines. So let's limit storing to the minimum of the requested and the maximum doublewords.
--- target/s390x/misc_helper.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
target/s390x/misc_helper.c +7 -1
@@ -678,7 +678,13 @@ uint32_t HELPER(stfle)(CPUS390XState *env, uint64_t addr)prepare_stfl (); max_bytes =ROUND_UP (used_stfl_bytes,8 ); -for (i =0 ; i < count_bytes; ++i) { + +/* +* The PoP says that doublewords beyond the highest-numbered facility +* bit may or may not be stored. However, existing hardware appears to +* not store the words, and existing software depend on that. +*/ +for (i =0 ; i <MIN (count_bytes, max_bytes); ++i) {cpu_stb_data_ra (env, addr + i, stfl_bytes[i], ra); }
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH v2 01/22] s390x/tcg: Store only the necessary amount of doublewords for STFLE
Quoted 52 lines · David Hildenbrand
The PoP (z14, 7-382) says:
Doublewords to the right of the doubleword in which the highest-numbered facility bit is assigned for a model may or may not be stored.However, stack protection in certain binaries can't deal with that. "gzip" example code:
f1b4: a7 08 00 03 lhi %r0,3 f1b8: b2 b0 f0 a0 stfle 160(%r15) f1bc: e3 20 f0 b2 00 90 llgc %r2,178(%r15) f1c2: c0 2b 00 00 00 01 nilf %r2,1 f1c8: b2 4f 00 10 ear %r1,%a0 f1cc: b9 14 00 22 lgfr %r2,%r2 f1d0: eb 11 00 20 00 0d sllg %r1,%r1,32 f1d6: b2 4f 00 11 ear %r1,%a1 f1da: d5 07 f0 b8 10 28 clc 184(8,%r15),40(%r1) f1e0: a7 74 00 06 jne f1ec <file_read@@Base+0x1bc> f1e4: eb ef f1 30 00 04 lmg %r14,%r15,304(%r15) f1ea: 07 fe br %r14 f1ec: c0 e5 ff ff 9d 6e brasl %r14,2cc8 <__stack_chk_fail@plt>In QEMU, we currently have:
max_bytes = 24the code asks for (3 + 1) doublewords == 32 bytes.
If we write 32 bytes instead of only 24, and return "2 + 1" doublewords ("one less than the number of doulewords needed to contain all of the
facility bits"), the example code detects a stack corruption.In my opinion, the code is wrong. However, it seems to work fine on real machines. So let's limit storing to the minimum of the requested and the maximum doublewords.
Cc Stefan Liebler <[email protected]>Cc Andreas Krebbel <[email protected]>Reviewed-by Richard Henderson <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/misc_helper.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)target/s390x/misc_helper.c +0
-1@@ -678,7 +678,13 @@ uint32_t HELPER(stfle)(CPUS390XState *env, uint64_t addr)prepare_stfl (); max_bytes =ROUND_UP (used_stfl_bytes,8 ); -for (i =0 ; i < count_bytes; ++i) {
target/s390x/misc_helper.c uint32_t HELPER(stfle)(CPUS390XState *env, uint64_t addr) · line 690
Quoted 10 lines
target/s390x/misc_helper.c +7
-0+ +/* +* The PoP says that doublewords beyond the highest-numbered facility +* bit may or may not be stored. However, existing hardware appears to +* not store the words, and existing software depend on that. +*/ +for (i =0 ; i <MIN (count_bytes, max_bytes); ++i) {cpu_stb_data_ra (env, addr + i, stfl_bytes[i], ra); }
Not intended to be included in this series, please ignore :)
Signature · 3 lines
Thanks, David / dhildenb
PATCH v2 2/22 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.21.0
PATCH v2 3/22 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.21.0
Re: [Qemu-devel] [PATCH v2 03/22] s390x/tcg: Export float_comp_to_cc() and float(32|64|128)_dcmask()
Quoted 8 lines · David Hildenbrand
Vector floating-point instructions will require these functions, so allow to use them from other files.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/fpu_helper.c | 4 ++-- target/s390x/internal.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-)
r~
PATCH v2 4/22 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.21.0
PATCH v2 5/22 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 =s390_vec_read_element64 (v1,0 ); +const float64 b =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.21.0
PATCH v2 6/22 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 | 104 ++++++++++++++++++++++++++++++++ 4 files changed, 173 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 +104 -0
107 lines not on this page · raw message
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH v2 06/22] s390x/tcg: Implement VECTOR FP COMPARE (EQUAL|HIGH|HIGH OR EQUAL)
Quoted 213 lines · David Hildenbrand
Provide for all three instructions all four combinations of cc bit and s bit.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 12 ++++ target/s390x/insn-data.def | 6 ++ target/s390x/translate_vx.inc.c | 51 ++++++++++++++++ target/s390x/vec_fpu_helper.c | 104 ++++++++++++++++++++++++++++++++ 4 files changed, 173 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@@ -2588,3 +2588,54 @@ static DisasJumpType op_wfc(DisasContext *s, DisasOps *o)set_cc_static (s);return DISAS_NEXT ; } + +static DisasJumpType op_vfc (DisasContext *s,DisasOps *o) +{ +const uint8_t fpf =get_field (s->fields, m4); +const uint8_t m5 =get_field (s->fields, m5); +const uint8_t m6 =get_field (s->fields, m6); +const bool se =extract32 (m5,3 ,1 ); +const bool cs =extract32 (m6,0 ,1 ); +gen_helper_gvec_3_ptr *fn; + +if (fpf !=FPF_LONG ||extract32 (m5,0 ,3 ) ||extract32 (m6,1 ,3 )) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +if (cs) { +switch (s->fields->op2) { +case 0xe8 : + fn = se ? gen_helper_gvec_vfce64s_cc : gen_helper_gvec_vfce64_cc; +break ; +case 0xeb : + fn = se ? gen_helper_gvec_vfch64s_cc : gen_helper_gvec_vfch64_cc; +break ; +case 0xea : + fn = se ? gen_helper_gvec_vfche64s_cc : gen_helper_gvec_vfche64_cc; +break ; +default : +g_assert_not_reached (); + } + }else { +switch (s->fields->op2) { +case 0xe8 : + fn = se ? gen_helper_gvec_vfce64s : gen_helper_gvec_vfce64; +break ; +case 0xeb : + fn = se ? gen_helper_gvec_vfch64s : gen_helper_gvec_vfch64; +break ; +case 0xea : + fn = se ? gen_helper_gvec_vfche64s : gen_helper_gvec_vfche64; +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); +if (cs) { +set_cc_static (s); + } +return DISAS_NEXT ; +}target/s390x/vec_fpu_helper.c +94
-0@@ -149,3 +149,107 @@ void HELPER(gvec_wfk64)(const void *v1, const void *v2, CPUS390XState *env, { env->cc_op =wfc64 (v1, v2, env, true,GETPC ()); } + +typedef int (*vfc64_fn )(float64 a,float64 b,float_status *status); +static int vfc64 (S390Vector *v1,const S390Vector *v2,const S390Vector *v3, +CPUS390XState *env,bool s,vfc64_fn fn,uintptr_t retaddr) +{ +uint8_t vxc, vec_exc =0 ; +S390Vector tmp = {}; +int match =0 ; +int i; + +for (i =0 ; i <2 ; i++) { +const float64 a =s390_vec_read_element64 (v2, i); +const float64 b =s390_vec_read_element64 (v3, i); + +/* swap the order of the parameters, so we can use existing functions */ +if (fn (b, a, &env->fpu_status)) { + match++; +s390_vec_write_element64 (&tmp, i,-1ull ); + } + vxc =check_ieee_exc (env, i, false, &vec_exc); +if (s || vxc) { +break ; + } + } + +handle_ieee_exc (env, vxc, vec_exc, retaddr); + *v1 = tmp; +if (match) { +return s || match ==2 ?0 :1 ; + } +return 3 ; +} + +void HELPER (gvec_vfce64 )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vfc64 (v1, v2, v3, env, false, float64_eq_quiet,GETPC ()); +} + +void HELPER (gvec_vfce64s )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vfc64 (v1, v2, v3, env, true, float64_eq_quiet,GETPC ()); +} + +void HELPER (gvec_vfce64_cc )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ + env->cc_op =vfc64 (v1, v2, v3, env, false, float64_eq_quiet,GETPC ()); +} + +void HELPER (gvec_vfce64s_cc )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ + env->cc_op =vfc64 (v1, v2, v3, env, true, float64_eq_quiet,GETPC ()); +} + +void HELPER (gvec_vfch64 )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vfc64 (v1, v2, v3, env, false, float64_lt_quiet,GETPC ()); +} + +void HELPER (gvec_vfch64s )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vfc64 (v1, v2, v3, env, true, float64_lt_quiet,GETPC ()); +} + +void HELPER (gvec_vfch64_cc )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ + env->cc_op =vfc64 (v1, v2, v3, env, false, float64_lt_quiet,GETPC ()); +} + +void HELPER (gvec_vfch64s_cc )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ + env->cc_op =vfc64 (v1, v2, v3, env, true, float64_lt_quiet,GETPC ()); +} + +void HELPER (gvec_vfche64 )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vfc64 (v1, v2, v3, env, false, float64_le_quiet,GETPC ()); +} + +void HELPER (gvec_vfche64s )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vfc64 (v1, v2, v3, env, true, float64_le_quiet,GETPC ()); +} + +void HELPER(gvec_vfche64_cc)(void *v1, const void *v2, const void *v3,
target/s390x/vec_fpu_helper.c void HELPER(gvec_wfk64)(const void *v1, const void *v2, CPUS390XState *env, · line 255
Quoted 10 lines
target/s390x/vec_fpu_helper.c +10
-0+ CPUS390XState *env, uint32_t desc) +{ + env->cc_op =vfc64 (v1, v2, v3, env, false, float64_le_quiet,GETPC ()); +} + +void HELPER (gvec_vfche64s_cc )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ + env->cc_op =vfc64 (v1, v2, v3, env, true, float64_le_quiet,GETPC ()); +}
Richard, still want to review this patch? I'm planning to send a pull request soon.
Signature · 3 lines
Thanks, David / dhildenb
Richard Henderson
Reviewed-byRe: [Qemu-devel] [PATCH v2 06/22] s390x/tcg: Implement VECTOR FP COMPARE (EQUAL|HIGH|HIGH OR EQUAL)
Quoted 219 lines · David Hildenbrand
Quoted 218 lines · David Hildenbrand
Provide for all three instructions all four combinations of cc bit and s bit.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 12 ++++ target/s390x/insn-data.def | 6 ++ target/s390x/translate_vx.inc.c | 51 ++++++++++++++++ target/s390x/vec_fpu_helper.c | 104 ++++++++++++++++++++++++++++++++ 4 files changed, 173 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@@ -2588,3 +2588,54 @@ static DisasJumpType op_wfc(DisasContext *s, DisasOps *o)set_cc_static (s);return DISAS_NEXT ; } + +static DisasJumpType op_vfc (DisasContext *s,DisasOps *o) +{ +const uint8_t fpf =get_field (s->fields, m4); +const uint8_t m5 =get_field (s->fields, m5); +const uint8_t m6 =get_field (s->fields, m6); +const bool se =extract32 (m5,3 ,1 ); +const bool cs =extract32 (m6,0 ,1 ); +gen_helper_gvec_3_ptr *fn; + +if (fpf !=FPF_LONG ||extract32 (m5,0 ,3 ) ||extract32 (m6,1 ,3 )) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +if (cs) { +switch (s->fields->op2) { +case 0xe8 : + fn = se ? gen_helper_gvec_vfce64s_cc : gen_helper_gvec_vfce64_cc; +break ; +case 0xeb : + fn = se ? gen_helper_gvec_vfch64s_cc : gen_helper_gvec_vfch64_cc; +break ; +case 0xea : + fn = se ? gen_helper_gvec_vfche64s_cc : gen_helper_gvec_vfche64_cc; +break ; +default : +g_assert_not_reached (); + } + }else { +switch (s->fields->op2) { +case 0xe8 : + fn = se ? gen_helper_gvec_vfce64s : gen_helper_gvec_vfce64; +break ; +case 0xeb : + fn = se ? gen_helper_gvec_vfch64s : gen_helper_gvec_vfch64; +break ; +case 0xea : + fn = se ? gen_helper_gvec_vfche64s : gen_helper_gvec_vfche64; +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); +if (cs) { +set_cc_static (s); + } +return DISAS_NEXT ; +}target/s390x/vec_fpu_helper.c +100
-0@@ -149,3 +149,107 @@ void HELPER(gvec_wfk64)(const void *v1, const void *v2, CPUS390XState *env, { env->cc_op =wfc64 (v1, v2, env, true,GETPC ()); } + +typedef int (*vfc64_fn )(float64 a,float64 b,float_status *status); +static int vfc64 (S390Vector *v1,const S390Vector *v2,const S390Vector *v3, +CPUS390XState *env,bool s,vfc64_fn fn,uintptr_t retaddr) +{ +uint8_t vxc, vec_exc =0 ; +S390Vector tmp = {}; +int match =0 ; +int i; + +for (i =0 ; i <2 ; i++) { +const float64 a =s390_vec_read_element64 (v2, i); +const float64 b =s390_vec_read_element64 (v3, i); + +/* swap the order of the parameters, so we can use existing functions */ +if (fn (b, a, &env->fpu_status)) { + match++; +s390_vec_write_element64 (&tmp, i,-1ull ); + } + vxc =check_ieee_exc (env, i, false, &vec_exc); +if (s || vxc) { +break ; + } + } + +handle_ieee_exc (env, vxc, vec_exc, retaddr); + *v1 = tmp; +if (match) { +return s || match ==2 ?0 :1 ; + } +return 3 ; +} + +void HELPER (gvec_vfce64 )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vfc64 (v1, v2, v3, env, false, float64_eq_quiet,GETPC ()); +} + +void HELPER (gvec_vfce64s )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vfc64 (v1, v2, v3, env, true, float64_eq_quiet,GETPC ()); +} + +void HELPER (gvec_vfce64_cc )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ + env->cc_op =vfc64 (v1, v2, v3, env, false, float64_eq_quiet,GETPC ()); +} + +void HELPER (gvec_vfce64s_cc )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ + env->cc_op =vfc64 (v1, v2, v3, env, true, float64_eq_quiet,GETPC ()); +} + +void HELPER (gvec_vfch64 )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vfc64 (v1, v2, v3, env, false, float64_lt_quiet,GETPC ()); +} + +void HELPER (gvec_vfch64s )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vfc64 (v1, v2, v3, env, true, float64_lt_quiet,GETPC ()); +} + +void HELPER (gvec_vfch64_cc )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ + env->cc_op =vfc64 (v1, v2, v3, env, false, float64_lt_quiet,GETPC ()); +} + +void HELPER (gvec_vfch64s_cc )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ + env->cc_op =vfc64 (v1, v2, v3, env, true, float64_lt_quiet,GETPC ()); +} + +void HELPER (gvec_vfche64 )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vfc64 (v1, v2, v3, env, false, float64_le_quiet,GETPC ()); +} + +void HELPER (gvec_vfche64s )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ +vfc64 (v1, v2, v3, env, true, float64_le_quiet,GETPC ()); +} + +void HELPER (gvec_vfche64_cc )(void *v1,const void *v2,const void *v3, +CPUS390XState *env,uint32_t desc) +{ + env->cc_op =vfc64 (v1, v2, v3, env, false, float64_le_quiet,GETPC ()); +} + +void HELPER(gvec_vfche64s_cc)(void *v1, const void *v2, const void *v3,
Quoted 9 lines
target/s390x/vec_fpu_helper.c void HELPER(gvec_wfk64)(const void *v1, const void *v2, CPUS390XState *env, · line 255
Quoted 5 lines
target/s390x/vec_fpu_helper.c +4
-0+ CPUS390XState *env, uint32_t desc) +{ + env->cc_op =vfc64 (v1, v2, v3, env, true, float64_le_quiet,GETPC ()); +}Richard, still want to review this patch? I'm planning to send a pull request soon.
Somehow I bypassed this one. Anyway,
r~
PATCH v2 7/22 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.21.0
PATCH v2 8/22 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
@@ -300,3 +300,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 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.21.0
PATCH v2 9/22 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
@@ -323,3 +323,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 (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.21.0
PATCH v2 10/22 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
@@ -346,3 +346,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 (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.21.0
PATCH v2 11/22 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
@@ -369,3 +369,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_div (a, 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.21.0
PATCH v2 12/22 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
@@ -386,3 +386,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_round_to_int (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.21.0
PATCH v2 13/22 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 | 35 +++++++++++++++++++++++++++++++++ 4 files changed, 58 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 +35 -0
@@ -409,3 +409,38 @@ 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 =s390_vec_read_element32 (v2, i *2 ); +const uint64_t ret =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.21.0
PATCH v2 14/22 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.21.0
PATCH v2 15/22 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
@@ -487,3 +487,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_mul (a, 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.21.0
PATCH v2 16/22 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 | 48 +++++++++++++++++++++++++++++++++ 4 files changed, 79 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 +48 -0
51 lines not on this page · raw message
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH v2 16/22] s390x/tcg: Implement VECTOR FP MULTIPLY AND (ADD|SUBTRACT)
Quoted 7 lines · David Hildenbrand
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 4 +++ target/s390x/insn-data.def | 4 +++ target/s390x/translate_vx.inc.c | 23 ++++++++++++++++ target/s390x/vec_fpu_helper.c | 48 +++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+)
r~
PATCH v2 17/22 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 | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 54 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 +52 -0
55 lines not on this page · raw message
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH v2 17/22] s390x/tcg: Implement VECTOR FP PERFORM SIGN OPERATION
Quoted 7 lines · David Hildenbrand
The only FP instruction we can implement without an helper.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
r~
[Qemu-devel] [PATCH v2 23/22] 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.21.0
PATCH v2 18/22 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
@@ -2779,3 +2779,22 @@ static DisasJumpType op_vfpso(DisasContext *s, DisasOps *o) }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
@@ -552,3 +552,20 @@ void HELPER(gvec_vfms64s)(void *v1, const void *v2, const void *v3, {vfma64 (v1, v2, v3, v4, env, true, float_muladd_negate_c,GETPC ()); } + +static uint64_t vfsq64 (uint64_t a,float_status *s) +{ +return float64_sqrt (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.21.0
PATCH v2 19/22 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
@@ -569,3 +569,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_sub (a, 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.21.0
PATCH v2 20/22 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 | 37 +++++++++++++++++++++++++++++++++ 4 files changed, 62 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
@@ -2801,3 +2801,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 +37 -0
@@ -586,3 +586,40 @@ 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 =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) { +return s || match ==2 ?0 :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.21.0
PATCH v2 21/22 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.21.0
Re: [Qemu-devel] [PATCH v2 21/22] s390x/tcg: Allow linux-user to use vector instructions
Le 03/06/2019 à 11:06, David Hildenbrand a écrit :
Quoted 15 lines
Once we unlock
S390_FEAT_VECTORfor TCG, we want linux-user to be able to make use of it.Reviewed-by Richard Henderson <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/cpu.c | 3 +++ 1 file changed, 3 insertions(+)target/s390x/cpu.c +0
-0
target/s390x/cpu.c static void s390_cpu_full_reset(CPUState *s) · line 153
Quoted 9 lines
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 */
Re: [Qemu-devel] [PATCH v2 21/22] s390x/tcg: Allow linux-user to use vector instructions
In reply to David HildenbrandLe 03/06/2019 à 11:06, David Hildenbrand a écrit :
Quoted 15 lines
Once we unlock
S390_FEAT_VECTORfor TCG, we want linux-user to be able to make use of it.Reviewed-by Richard Henderson <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/cpu.c | 3 +++ 1 file changed, 3 insertions(+)target/s390x/cpu.c +0
-0
target/s390x/cpu.c static void s390_cpu_full_reset(CPUState *s) · line 153
Quoted 9 lines
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 */
Do we need to add some hwcaps in linux-user/elfload.c (HWCAP_S390_VXRS, HWCAP_S390_VXRS_EXT,...)?
Thanks,
Laurent
Re: [Qemu-devel] [PATCH v2 21/22] s390x/tcg: Allow linux-user to use vector instructions
Quoted 23 lines · Laurent Vivier
Le 03/06/2019 à 11:06, David Hildenbrand a écrit :
Quoted 22 lines
Once we unlock
S390_FEAT_VECTORfor TCG, we want linux-user to be able to make use of it.Reviewed-by Richard Henderson <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- 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
Quoted 5 lines
target/s390x/cpu.c static void s390_cpu_full_reset(CPUState *s) · line 153
Quoted 2 lines
target/s390x/cpu.c +0
-0/* architectured initial value for Breaking-Event-Address register */ Do we need to add some hwcaps in
linux-user/elfload.c(HWCAP_S390_VXRS,HWCAP_S390_VXRS_EXT,...)?
Good point, I will look into this. Thanks!
Quoted 4 lines
Thanks,
Laurent
Signature · 3 lines
Thanks, David / dhildenb
PATCH v2 22/22 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.21.0
Quoted 65 lines · David Hildenbrand
This is the final part of vector instruction support for s390x.
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 already found and fixed some stack overflow protection issues (stfle instruction). I still see random rpm database corruptions and rpmbuild doesn't work correctly (looks like another stack protection issue).
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.
v1 -> v2:
- get rid ofmake_float64()andfloat64_val().
- fixed two cc calculation issues (thanks Richard)
- Rework "VECTOR FP COMPARE (EQUAL|HIGH|HIGH OR EQUAL)"
- Rework "VECTOR FP MULTIPLY AND (ADD|SUBTRACT)"
- Use gvec expansion in "s390x/tcg: Implement VECTOR FP PERFORM SIGN OPERATION"Cc Denys Vlasenko <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Pino Toscano <[email protected]>David Hildenbrand (22):
s390x/tcg: Store only the necessary amount of doublewords for STFLE 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
Quoted 16 lines
target/s390x/Makefile.objs | 1 + target/s390x/cpu.c | 3 + target/s390x/cpu.h | 1 + target/s390x/excp_helper.c | 15 + target/s390x/fpu_helper.c | 4 +- target/s390x/gen-features.c | 1 + target/s390x/helper.h | 46 +++ target/s390x/insn-data.def | 45 +++ target/s390x/internal.h | 4 + target/s390x/misc_helper.c | 8 +- target/s390x/tcg_s390x.h | 2 + target/s390x/translate_vx.inc.c | 284 +++++++++++++++ target/s390x/vec_fpu_helper.c | 625 ++++++++++++++++++++++++++++++++ 13 files changed, 1036 insertions(+), 3 deletions(-) create mode 100644 target/s390x/vec_fpu_helper.c
Still tired, the unchanged patch
"[PATCH v1 23/23] s390x: Bump the "qemu" CPU model up to a stripped-down z13"
is missing from this series (already reviewed by Richard)
Signature · 3 lines
Thanks, David / dhildenb