s390x/tcg: Vector Instruction Support Part 2
cover s390x/tcg: Vector Instruction Support Part 2
This is the second part of vector instruction support for s390x. It is based on the series soon to land upstream:
[PATCH 0/9] tcg: Add tcg_gen_extract2_{i32,i64}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
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.
In this part, all Vector Integer Instructions introduced with the "Vector Facility" are added. Some instructions part of the Vector Extension Facilities are also added.
David Hildenbrand (41):
tcg: Implement tcg_gen_gvec_3i()
s390x/tcg: Implement VECTOR ADD
s390x/tcg: Implement VECTOR ADD COMPUTE CARRY
s390x/tcg: Implement VECTOR ADD WITH CARRY
s390x/tcg: Implement VECTOR ADD WITH CARRY COMPUTE CARRY s390x/tcg: Implement VECTOR AND (WITH COMPLEMENT) s390x/tcg: Implement VECTOR AVERAGE
s390x/tcg: Implement VECTOR AVERAGE LOGICAL
s390x/tcg: Implement VECTOR CHECKSUM
s390x/tcg: Implement VECTOR ELEMENT COMPARE *
s390x/tcg: Implement VECTOR COMPARE *
s390x/tcg: Implement VECTOR COUNT LEADING ZEROS
s390x/tcg: Implement VECTOR COUNT TRAILING ZEROS s390x/tcg: Implement VECTOR EXCLUSIVE OR
s390x/tcg: Implement VECTOR GALOIS FIELD MULTIPLY SUM (AND ACCUMULATE) s390x/tcg: Implement VECTOR LOAD COMPLEMENT
s390x/tcg: Implement VECTOR LOAD POSITIVE
s390x/tcg: Implement VECTOR (MAXIMUM|MINIMUM) (LOGICAL) s390x/tcg: Implement VECTOR MULTIPLY AND ADD *
s390x/tcg: Implement VECTOR MULTIPLY *
s390x/tcg: Implement VECTOR NAND
s390x/tcg: Implement VECTOR NOR
s390x/tcg: Implement VECTOR NOT EXCLUSIVE OR
s390x/tcg: Implement VECTOR OR
s390x/tcg: Implement VECTOR OR WITH COMPLEMENT
s390x/tcg: Implement VECTOR POPULATION COUNT
s390x/tcg: Implement VECTOR ELEMENT ROTATE LEFT LOGICAL s390x/tcg: Implement VECTOR ELEMENT ROTATE AND INSERT UNDER MASK s390x/tcg: Implement VECTOR ELEMENT SHIFT
s390x/tcg: Implement VECTOR SHIFT LEFT (BY BYTE) s390x/tcg: Implement VECTOR SHIFT LEFT DOUBLE BY BYTE s390x/tcg: Implement VECTOR SHIFT RIGHT ARITHMETIC s390x/tcg: Implement VECTOR SHIFT RIGHT LOGICAL * s390x/tcg: Implement VECTOR SUBTRACT
s390x/tcg: Implement VECTOR SUBTRACT COMPUTE BORROW INDICATION s390x/tcg: Implement VECTOR SUBTRACT WITH BORROW INDICATION s390x/tcg: Implement VECTOR SUBTRACT WITH BORROW COMPUTE BORROW
INDICATION
s390x/tcg: Implement VECTOR SUM ACROSS DOUBLEWORD s390x/tcg: Implement VECTOR SUM ACROSS QUADWORD
s390x/tcg: Implement VECTOR SUM ACROSS WORD
s390x/tcg: Implement VECTOR TEST UNDER MASK
target/s390x/Makefile.objs | 2 +- target/s390x/cc_helper.c | 17 + target/s390x/helper.c | 1 + target/s390x/helper.h | 91 ++ target/s390x/insn-data.def | 137 +++ target/s390x/internal.h | 1 + target/s390x/translate.c | 2 + target/s390x/translate_vx.inc.c | 1393 +++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 839 +++++++++++++++++++ tcg/tcg-op-gvec.c | 139 +++ tcg/tcg-op-gvec.h | 24 + 11 files changed, 2645 insertions(+), 1 deletion(-) create mode 100644 target/s390x/vec_int_helper.c
Signature · 1 line
2.20.1
PATCH 1/41 tcg: Implement tcg_gen_gvec_3i()
Let's add tcg_gen_gvec_3i(), similar to tcg_gen_gvec_2i(), however without introducing "gen_helper_gvec_3i *fnoi", as it isn't needed for now.
--- tcg/tcg-op-gvec.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++ tcg/tcg-op-gvec.h | 24 ++++++++ 2 files changed, 163 insertions(+)
tcg/tcg-op-gvec.c +139 -0
@@ -663,6 +663,29 @@ static void expand_3_i32(uint32_t dofs, uint32_t aofs,tcg_temp_free_i32 (t0); } +static void expand_3i_i32 (uint32_t dofs,uint32_t aofs,uint32_t bofs, +uint32_t oprsz,int32_t c,bool load_dest, +void (*fni)(TCGv_i32 ,TCGv_i32 ,TCGv_i32 ,int32_t )) +{ +TCGv_i32 t0 =tcg_temp_new_i32 (); +TCGv_i32 t1 =tcg_temp_new_i32 (); +TCGv_i32 t2 =tcg_temp_new_i32 (); +uint32_t i; + +for (i =0 ; i < oprsz; i +=4 ) { +tcg_gen_ld_i32 (t0, cpu_env, aofs + i); +tcg_gen_ld_i32 (t1, cpu_env, bofs + i); +if (load_dest) { +tcg_gen_ld_i32 (t2, cpu_env, dofs + i); + } +fni (t2, t0, t1, c); +tcg_gen_st_i32 (t2, cpu_env, dofs + i); + } +tcg_temp_free_i32 (t0); +tcg_temp_free_i32 (t1); +tcg_temp_free_i32 (t2); +} +/* Expand OPSZ bytes worth of three-operand operations using i32 elements. */ static void expand_4_i32(uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t cofs, uint32_t oprsz, bool write_aofs,
@@ -770,6 +793,29 @@ static void expand_3_i64(uint32_t dofs, uint32_t aofs,tcg_temp_free_i64 (t0); } +static void expand_3i_i64 (uint32_t dofs,uint32_t aofs,uint32_t bofs, +uint32_t oprsz,int64_t c,bool load_dest, +void (*fni)(TCGv_i64 ,TCGv_i64 ,TCGv_i64 ,int64_t )) +{ +TCGv_i64 t0 =tcg_temp_new_i64 (); +TCGv_i64 t1 =tcg_temp_new_i64 (); +TCGv_i64 t2 =tcg_temp_new_i64 (); +uint32_t i; + +for (i =0 ; i < oprsz; i +=8 ) { +tcg_gen_ld_i64 (t0, cpu_env, aofs + i); +tcg_gen_ld_i64 (t1, cpu_env, bofs + i); +if (load_dest) { +tcg_gen_ld_i64 (t2, cpu_env, dofs + i); + } +fni (t2, t0, t1, c); +tcg_gen_st_i64 (t2, cpu_env, dofs + i); + } +tcg_temp_free_i64 (t0); +tcg_temp_free_i64 (t1); +tcg_temp_free_i64 (t2); +} +/* Expand OPSZ bytes worth of three-operand operations using i64 elements. */ static void expand_4_i64(uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t cofs, uint32_t oprsz, bool write_aofs,
@@ -883,6 +929,35 @@ static void expand_3_vec(unsigned vece, uint32_t dofs, uint32_t aofs,tcg_temp_free_vec (t0); } +/* +* Expand OPSZ bytes worth of three-vector operands and an immediate operand +* using host vectors. +*/ +static void expand_3i_vec (unsigned vece,uint32_t dofs,uint32_t aofs, +uint32_t bofs,uint32_t oprsz,uint32_t tysz, +TCGType type,int64_t c,bool load_dest, +void (*fni)(unsigned ,TCGv_vec ,TCGv_vec ,TCGv_vec , +int64_t )) +{ +TCGv_vec t0 =tcg_temp_new_vec (type); +TCGv_vec t1 =tcg_temp_new_vec (type); +TCGv_vec t2 =tcg_temp_new_vec (type); +uint32_t i; + +for (i =0 ; i < oprsz; i += tysz) { +tcg_gen_ld_vec (t0, cpu_env, aofs + i); +tcg_gen_ld_vec (t1, cpu_env, bofs + i); +if (load_dest) { +tcg_gen_ld_vec (t2, cpu_env, dofs + i); + } +fni (vece, t2, t0, t1, c); +tcg_gen_st_vec (t2, cpu_env, dofs + i); + } +tcg_temp_free_vec (t0); +tcg_temp_free_vec (t1); +tcg_temp_free_vec (t2); +} +/* Expand OPSZ bytes worth of four-operand operations using host vectors. */ static void expand_4_vec(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t cofs, uint32_t oprsz,
@@ -1174,6 +1249,70 @@ void tcg_gen_gvec_3(uint32_t dofs, uint32_t aofs, uint32_t bofs, } } +/* Expand a vector operation with three vectors and an immediate. */ +void tcg_gen_gvec_3i (uint32_t dofs,uint32_t aofs,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz,int64_t c, +const GVecGen3i *g) +{ +TCGType type; +uint32_t some; + +check_size_align (oprsz, maxsz, dofs | aofs | bofs); +check_overlap_3 (dofs, aofs, bofs, maxsz); + + type =0 ; +if (g->fniv) { + type =choose_vector_type (g->opc, g->vece, oprsz, g->prefer_i64); + } +switch (type) { +case TCG_TYPE_V256 : +/* +* Recall that ARM SVE allows vector sizes that are not a +* power of 2, but always a multiple of 16. The intent is +* that e.g. size == 80 would be expanded with 2x32 + 1x16. +*/ + some =QEMU_ALIGN_DOWN (oprsz,32 ); +expand_3i_vec (g->vece, dofs, aofs, bofs, some,32 ,TCG_TYPE_V256 , + c, g->load_dest, g->fniv); +if (some == oprsz) { +break ; + } + dofs += some; + aofs += some; + bofs += some; + oprsz -= some; + maxsz -= some; +/* fallthru */ +case TCG_TYPE_V128 : +expand_3i_vec (g->vece, dofs, aofs, bofs, oprsz,16 ,TCG_TYPE_V128 , + c, g->load_dest, g->fniv); +break ; +case TCG_TYPE_V64 : +expand_3i_vec (g->vece, dofs, aofs, bofs, oprsz,8 ,TCG_TYPE_V64 , + c, g->load_dest, g->fniv); +break ; + +case 0 : +if (g->fni8 &&check_size_impl (oprsz,8 )) { +expand_3i_i64 (dofs, aofs, bofs, oprsz, c, g->load_dest, g->fni8); + }else if (g->fni4 &&check_size_impl (oprsz,4 )) { +expand_3i_i32 (dofs, aofs, bofs, oprsz, c, g->load_dest, g->fni4); + }else { +assert (g->fno !=NULL ); +tcg_gen_gvec_3_ool (dofs, aofs, bofs, oprsz, maxsz, c, g->fno); +return ; + } +break ; + +default : +g_assert_not_reached (); + } + +if (oprsz < maxsz) { +expand_clr (dofs + oprsz, maxsz - oprsz); + } +} +/* Expand a vector four-operand operation. */ void tcg_gen_gvec_4 (uint32_t dofs,uint32_t aofs,uint32_t bofs,uint32_t cofs,uint32_t oprsz,uint32_t maxsz,const GVecGen4 *g)
tcg/tcg-op-gvec.h +24 -0
@@ -164,6 +164,27 @@ typedef struct {bool load_dest; } GVecGen3; +typedef struct { +/* +* Expand inline as a 64-bit or 32-bit integer. Only one of these will be +* non-NULL. +*/ +void (*fni8)(TCGv_i64 ,TCGv_i64 ,TCGv_i64 ,int64_t ); +void (*fni4)(TCGv_i32 ,TCGv_i32 ,TCGv_i32 ,int32_t ); +/* Expand inline with a host vector type. */ +void (*fniv)(unsigned ,TCGv_vec ,TCGv_vec ,TCGv_vec ,int64_t ); +/* Expand out-of-line helper w/descriptor, data in descriptor. */ +gen_helper_gvec_3 *fno; +/* The opcode, if any, to which this corresponds. */ +TCGOpcode opc; +/* The vector element size, if applicable. */ +uint8_t vece; +/* Prefer i64 to v64. */ +bool prefer_i64; +/* Load dest as a 3rd source operand. */ +bool load_dest; +}GVecGen3i ; + typedef struct { /* Expand inline as a 64-bit or 32-bit integer. Only one of these will be non-NULL. */
@@ -193,6 +214,9 @@ void tcg_gen_gvec_2s(uint32_t dofs, uint32_t aofs, uint32_t oprsz, uint32_t maxsz, TCGv_i64 c, const GVecGen2s *);void tcg_gen_gvec_3 (uint32_t dofs,uint32_t aofs,uint32_t bofs,uint32_t oprsz,uint32_t maxsz,const GVecGen3 *); +void tcg_gen_gvec_3i (uint32_t dofs,uint32_t aofs,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz,int64_t c, +const GVecGen3i *);void tcg_gen_gvec_4 (uint32_t dofs,uint32_t aofs,uint32_t bofs,uint32_t cofs,uint32_t oprsz,uint32_t maxsz,const GVecGen4 *);
Signature · 1 line
2.20.1
PATCH 2/41 s390x/tcg: Implement VECTOR ADD
In reply to David HildenbrandIntroduce two types of fancy new helpers that will be reused a couple of times
1. gen_gvec_fn_3: Call an existing tcg_gen_gvec_X function with 3 parameters, simplifying parameter passing
2. gen_gvec128_3_i64: Call a function that performs 128 bit calculations using two 64 bit values per vector.
Luckily, for VECTOR ADD we already have everything we need.
--- target/s390x/insn-data.def | 5 ++++ target/s390x/translate_vx.inc.c | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+)
target/s390x/insn-data.def +5 -0
@@ -1054,6 +1054,11 @@ /* VECTOR UNPACK LOGICAL LOW */ F(0xe7d4, VUPLL, VRR_a, V, 0, 0, 0, 0, vup, 0, IF_VEC) +/* === Vector Integer Instructions === */ + +/* VECTOR ADD */ + F(0xe7f3, VA, VRR_c, V, 0, 0, 0, 0, va, 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 +52 -0
61 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 02/41] s390x/tcg: Implement VECTOR ADD
Quoted 8 lines · David Hildenbrand
Introduce two types of fancy new helpers that will be reused a couple of times
1.
gen_gvec_fn_3: Call an existingtcg_gen_gvec_Xfunction with 3 parameters, simplifying parameter passing
2.gen_gvec128_3_i64: Call a function that performs 128 bit calculations using two 64 bit values per vector.
Quoted 7 lines
Luckily, for VECTOR ADD we already have everything we need.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 5 ++++ target/s390x/translate_vx.inc.c | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+)
r~
PATCH 3/41 s390x/tcg: Implement VECTOR ADD COMPUTE CARRY
In reply to David HildenbrandOnly 64 bit handling is really easy. 128 bit handling is performed via an ool handler, introducing s390_vec_add() that will be reused later.
8/16/32 bit handling is black magic inspired by gen_addv_mask(). If there is every a bug detected in there, throw it away and simply use ool helpers for 8/16 bit handling and something like 64 bit handling for 32 bit handling.
--- target/s390x/Makefile.objs | 2 +- target/s390x/helper.h | 3 ++ target/s390x/insn-data.def | 2 + target/s390x/translate_vx.inc.c | 74 +++++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 47 +++++++++++++++++++++ 5 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 target/s390x/vec_int_helper.c
target/s390x/Makefile.objs +1 -1
@@ -1,7 +1,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 +obj-$(CONFIG_TCG) += vec_helper.o vec_int_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 +3 -0
@@ -145,6 +145,9 @@ DEF_HELPER_5(gvec_vpkls_cc64, void, ptr, cptr, cptr, env, i32) DEF_HELPER_FLAGS_5(gvec_vperm, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32)DEF_HELPER_FLAGS_4 (vstl,TCG_CALL_NO_WG , void, env, cptr, i64, i64) +/* === Vector Integer Instructions === */ +DEF_HELPER_FLAGS_4(gvec_vacc128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, 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 +2 -0
@@ -1058,6 +1058,8 @@ /* VECTOR ADD */ F(0xe7f3, VA, VRR_c, V, 0, 0, 0, 0, va, 0, IF_VEC) +/* VECTOR ADD COMPUTE CARRY */ + F(0xe7f1, VACC, VRR_c, V, 0, 0, 0, 0, vacc, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +74 -0
83 lines not on this page · raw message
target/s390x/vec_int_helper.c new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 03/41] s390x/tcg: Implement VECTOR ADD COMPUTE CARRY
target/s390x/translate_vx.inc.c static DisasJumpType op_va(DisasContext *s, DisasOps *o) · line 1052
Quoted 7 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +7
-0+static const GVecGen3 g[5 ] = { + { .fni8 = gen_acc8_i64, }, + { .fni8 = gen_acc16_i64, }, + { .fni8 = gen_acc32_i64, }, + { .fni8 = gen_acc_i64, }, + { .fno = gen_helper_gvec_vacc128, }, + };
Vector versions of the first four are fairly simple too.
static void gen_acc_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) {
tcgv_vec t = tcg_temp_new_vec_matching(d);
tcg_gen_add_vec(vece, t, a, b);
tcg_gen_cmp_vec(TCG_COND_LTU, vece, d, r, a); /* produces -1 for carry */
tcg_gen_neg_vec(vece, d, d); /* convert to +1 for carry */
}
{ .fni8 = gen_acc8_i64,
.fniv = gen_acc_vec,
.opc = INDEX_op_cmp_vec,
.vece = MO_8 },
...
I'm surprised that you're expanding the 128-bit addition out-of-line. One possible expansion is
tcg_gen_add2_i64(tl, th, al, zero, bl, zero);
tcg_gen_add2_i64(tl, th, th, zero, ah, zero);
tcg_gen_add2_i64(tl, th, tl, th, bl, zero);
/* carry out in th */
r~
Re: [Qemu-devel] [PATCH v1 03/41] s390x/tcg: Implement VECTOR ADD COMPUTE CARRY
Quoted 20 lines · Richard Henderson
target/s390x/translate_vx.inc.c static DisasJumpType op_va(DisasContext *s, DisasOps *o) · line 1052
Quoted 7 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +7
-0+static const GVecGen3 g[5 ] = { + { .fni8 = gen_acc8_i64, }, + { .fni8 = gen_acc16_i64, }, + { .fni8 = gen_acc32_i64, }, + { .fni8 = gen_acc_i64, }, + { .fno = gen_helper_gvec_vacc128, }, + };Vector versions of the first four are fairly simple too.
static void
gen_acc_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b){
tcgv_vect =tcg_temp_new_vec_matching(d);
tcg_gen_add_vec(vece, t, a, b);
tcg_gen_cmp_vec(TCG_COND_LTU, vece, d, r, a); /* produces -1 for carry */
tcg_gen_neg_vec(vece, d, d); /* convert to +1 for carry */
}
Quoted 6 lines
{ .fni8 =
gen_acc8_i64,
.fniv =gen_acc_vec,
.opc =INDEX_op_cmp_vec,
.vece =MO_8},
...
Indeed, I didn't really explore vector operations yet. This is more compact than I expected :)
Quoted 8 lines
I'm surprised that you're expanding the 128-bit addition out-of-line. One possible expansion is
tcg_gen_add2_i64(tl, th, al, zero, bl, zero);
tcg_gen_add2_i64(tl, th, th, zero, ah, zero);
tcg_gen_add2_i64(tl, th, tl, th, bl, zero);
/* carry out in th */
Nice trick. Just so I get it right, the third line should actually be
tcg_gen_add2_i64(tl, th, tl, th, bh, zero);
right? Thanks!
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v1 03/41] s390x/tcg: Implement VECTOR ADD COMPUTE CARRY
Quoted 28 lines · David Hildenbrand
Quoted 20 lines · Richard Henderson
target/s390x/translate_vx.inc.c static DisasJumpType op_va(DisasContext *s, DisasOps *o) · line 1052
Quoted 7 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +7
-0+static const GVecGen3 g[5 ] = { + { .fni8 = gen_acc8_i64, }, + { .fni8 = gen_acc16_i64, }, + { .fni8 = gen_acc32_i64, }, + { .fni8 = gen_acc_i64, }, + { .fno = gen_helper_gvec_vacc128, }, + };Vector versions of the first four are fairly simple too.
static void
gen_acc_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b){
tcgv_vect =tcg_temp_new_vec_matching(d);
tcg_gen_add_vec(vece, t, a, b);
tcg_gen_cmp_vec(TCG_COND_LTU, vece, d, r, a); /* produces -1 for carry */
tcg_gen_neg_vec(vece, d, d); /* convert to +1 for carry */
}Quoted 6 lines
{ .fni8 =
gen_acc8_i64,
.fniv =gen_acc_vec,
.opc =INDEX_op_cmp_vec,
.vece =MO_8},
...
Quoted 2 lines
Indeed, I didn't really explore vector operations yet. This is more compact than I expected :)
:-)
That said, in implementing vector variable shifts today, I've come up with a representational problem here. You may want to hold off on these until I can address them.
Quoted 10 lines
Quoted 4 lines
tcg_gen_add2_i64(tl, th, al, zero, bl, zero);
tcg_gen_add2_i64(tl, th, th, zero, ah, zero);
tcg_gen_add2_i64(tl, th, tl, th, bl, zero);
/* carry out in th */Nice trick. Just so I get it right, the third line should actually be
tcg_gen_add2_i64(tl, th, tl, th, bh, zero);right? Thanks!
Oops, yes, typo indeed.
r~
Re: [Qemu-devel] [PATCH v1 03/41] s390x/tcg: Implement VECTOR ADD COMPUTE CARRY
Quoted 9 lines
Quoted 3 lines
Indeed, I didn't really explore vector operations yet. This is more compact than I expected :)
:-)
That said, in implementing vector variable shifts today, I've come up with a representational problem here. You may want to hold off on these until I can address them.
I assume you mean vector helpers *in general* in this file. Yes, we can add them later.
What exact problem are you dealing with?
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v1 03/41] s390x/tcg: Implement VECTOR ADD COMPUTE CARRY
Quoted 6 lines · David Hildenbrand
Quoted 6 lines
Quoted 3 lines
Indeed, I didn't really explore vector operations yet. This is more compact than I expected :)
:-)
Quoted 8 lines
Quoted 3 lines
That said, in implementing vector variable shifts today, I've come up with a representational problem here. You may want to hold off on these until I can address them.
I assume you mean vector helpers *in general* in this file. Yes, we can add them later.
What exact problem are you dealing with?
The .opc field lets you only specify one opcode which is optional in the backend on which you depend. In writing support for AArch64 USHL, I find that I needed 3 optional opcodes.
I'm thinking of a mass change whereby .opc becomes a pointer to an array with terminator. But then, for debugging purposes, I think I need to validate that array, so that it's not missing things that ought to be specified, but which happen to be supported by the current host.
r~
Re: [Qemu-devel] [PATCH v1 03/41] s390x/tcg: Implement VECTOR ADD COMPUTE CARRY
Quoted 11 lines · Richard Henderson
Quoted 10 lines · David Hildenbrand
Quoted 9 lines
Quoted 3 lines
Indeed, I didn't really explore vector operations yet. This is more compact than I expected :)
:-)
That said, in implementing vector variable shifts today, I've come up with a representational problem here. You may want to hold off on these until I can address them.
Quoted 8 lines
Quoted 4 lines
I assume you mean vector helpers *in general* in this file. Yes, we can add them later.
What exact problem are you dealing with?
The .opc field lets you only specify one opcode which is optional in the backend on which you depend. In writing support for AArch64 USHL, I find that I needed 3 optional opcodes.
I was asking myself this exact thing when looking at the opc field in the example you gave ("which instruction is one supposed to indicate here") :)
Quoted 5 lines
I'm thinking of a mass change whereby .opc becomes a pointer to an array with terminator. But then, for debugging purposes, I think I need to validate that array, so that it's not missing things that ought to be specified, but which happen to be supported by the current host.
Makes sense!
Signature · 3 lines
Thanks, David / dhildenb
PATCH 4/41 s390x/tcg: Implement VECTOR ADD WITH CARRY
In reply to David HildenbrandOnly slightly ugly, perform two additions. At least it is only supported for 128 bit elements.
Introduce gen_gvec128_4_i64() similar to gen_gvec128_3_i64().
--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 63 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1060,6 +1060,8 @@ F(0xe7f3, VA, VRR_c, V, 0, 0, 0, 0, va, 0, IF_VEC) /* VECTOR ADD COMPUTE CARRY */ F(0xe7f1, VACC, VRR_c, V, 0, 0, 0, 0, vacc, 0, IF_VEC) +/* VECTOR ADD WITH CARRY */ + F(0xe7bb, VAC, VRR_d, V, 0, 0, 0, 0, vac, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +63 -0
72 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 04/41] s390x/tcg: Implement VECTOR ADD WITH CARRY
Quoted 10 lines · David Hildenbrand
Only slightly ugly, perform two additions. At least it is only supported for 128 bit elements.
Introduce
gen_gvec128_4_i64()similar togen_gvec128_3_i64().Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 63 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+)
r~
PATCH 5/41 s390x/tcg: Implement VECTOR ADD WITH CARRY COMPUTE CARRY
In reply to David HildenbrandAgain, use a helper as calculating the carry is even more involved than for VECTOR ADD COMPUTE CARRY.
--- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 13 +++++++++++++ target/s390x/vec_int_helper.c | 16 ++++++++++++++++ 4 files changed, 32 insertions(+)
target/s390x/helper.h +1 -0
@@ -147,6 +147,7 @@ DEF_HELPER_FLAGS_4(vstl, TCG_CALL_NO_WG, void, env, cptr, i64, i64)/* === Vector Integer Instructions === */ DEF_HELPER_FLAGS_4(gvec_vacc128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vaccc128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1062,6 +1062,8 @@ F(0xe7f1, VACC, VRR_c, V, 0, 0, 0, 0, vacc, 0, IF_VEC) /* VECTOR ADD WITH CARRY */ F(0xe7bb, VAC, VRR_d, V, 0, 0, 0, 0, vac, 0, IF_VEC) +/* VECTOR ADD WITH CARRY COMPUTE CARRY */ + F(0xe7b9, VACCC, VRR_d, V, 0, 0, 0, 0, vaccc, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +13 -0
@@ -1122,3 +1122,16 @@ static DisasJumpType op_vac(DisasContext *s, DisasOps *o) get_field(s->fields, v4));return DISAS_NEXT ; } + +static DisasJumpType op_vaccc (DisasContext *s,DisasOps *o) +{ +if (get_field (s->fields, m5) !=ES_128 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +gen_gvec_4_ool (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3),get_field (s->fields, v4),0 , + gen_helper_gvec_vaccc128); +return DISAS_NEXT ; +}
target/s390x/vec_int_helper.c +16 -0
@@ -45,3 +45,19 @@ void HELPER(gvec_vacc128)(void *v1, const void *v2, const void *v3, dst->doubleword[0 ] =0 ; dst->doubleword[1 ] =s390_vec_add (&tmp, v2, v3); } + +void HELPER (gvec_vaccc128 )(void *v1,const void *v2,const void *v3, +const void *v4,uint32_t desc) +{ +const S390Vector old_carry = { + .doubleword[0 ] =0 , + .doubleword[1 ] = ((S390Vector *)v4)->doubleword[1 ] &1 , + }; +S390Vector tmp, *dst = v1; +bool carry; + + carry =s390_vec_add (&tmp, v2, v3); + carry |=s390_vec_add (&tmp, &tmp, &old_carry); + dst->doubleword[0 ] =0 ; + dst->doubleword[1 ] = carry; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 05/41] s390x/tcg: Implement VECTOR ADD WITH CARRY COMPUTE CARRY
target/s390x/translate_vx.inc.c static DisasJumpType op_vac(DisasContext *s, DisasOps *o) · line 1137
Quoted 12 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +12
-0+static DisasJumpType op_vaccc (DisasContext *s,DisasOps *o) +{ +if (get_field (s->fields, m5) !=ES_128 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +gen_gvec_4_ool (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3),get_field (s->fields, v4),0 , + gen_helper_gvec_vaccc128); +return DISAS_NEXT ; +}
An inline expansion could be
One possible expansion is
tcg_gen_andi_i64(tl, cl, 1);
tcg_gen_add2_i64(tl, th, tl, zero, al, zero);
tcg_gen_add2_i64(tl, th, tl, th, bl, zero);
tcg_gen_add2_i64(tl, th, th, zero, ah, zero);
tcg_gen_add2_i64(tl, th, tl, th, bl, zero);
/* carry out in th */
This is 8 insns for the addition vs the hw optimal 6, but we're not exactly an optimizing compiler either. ;-)
r~
Re: [Qemu-devel] [PATCH v1 05/41] s390x/tcg: Implement VECTOR ADD WITH CARRY COMPUTE CARRY
Quoted 25 lines · Richard Henderson
target/s390x/translate_vx.inc.c static DisasJumpType op_vac(DisasContext *s, DisasOps *o) · line 1137
Quoted 12 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +12
-0+static DisasJumpType op_vaccc (DisasContext *s,DisasOps *o) +{ +if (get_field (s->fields, m5) !=ES_128 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +gen_gvec_4_ool (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3),get_field (s->fields, v4),0 , + gen_helper_gvec_vaccc128); +return DISAS_NEXT ; +}An inline expansion could be
One possible expansion is
tcg_gen_andi_i64(tl, cl, 1);
tcg_gen_add2_i64(tl, th, tl, zero, al, zero);
tcg_gen_add2_i64(tl, th, tl, th, bl, zero);
tcg_gen_add2_i64(tl, th, th, zero, ah, zero);
tcg_gen_add2_i64(tl, th, tl, th, bl, zero);
/* carry out in th */
Quoted 3 lines
This is 8 insns for the addition vs the hw optimal 6, but we're not exactly an optimizing compiler either. ;-)
Yes, very nice! Thanks!
Quoted 3 lines
r~
Signature · 3 lines
Thanks, David / dhildenb
PATCH 6/41 s390x/tcg: Implement VECTOR AND (WITH COMPLEMENT)
In reply to David HildenbrandEasy, as we can reuse existing gvec helpers.
--- target/s390x/insn-data.def | 4 ++++ target/s390x/translate_vx.inc.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+)
target/s390x/insn-data.def +4 -0
@@ -1064,6 +1064,10 @@ F(0xe7bb, VAC, VRR_d, V, 0, 0, 0, 0, vac, 0, IF_VEC) /* VECTOR ADD WITH CARRY COMPUTE CARRY */ F(0xe7b9, VACCC, VRR_d, V, 0, 0, 0, 0, vaccc, 0, IF_VEC) +/* VECTOR AND */ + F(0xe768, VN, VRR_c, V, 0, 0, 0, 0, vn, 0, IF_VEC) +/* VECTOR AND WITH COMPLEMENT */ + F(0xe769, VNC, VRR_c, V, 0, 0, 0, 0, vnc, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +14 -0
@@ -1135,3 +1135,17 @@ static DisasJumpType op_vaccc(DisasContext *s, DisasOps *o) gen_helper_gvec_vaccc128);return DISAS_NEXT ; } + +static DisasJumpType op_vn (DisasContext *s,DisasOps *o) +{ +gen_gvec_fn_3 (and,ES_8 ,get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3)); +return DISAS_NEXT ; +} + +static DisasJumpType op_vnc (DisasContext *s,DisasOps *o) +{ +gen_gvec_fn_3 (andc,ES_8 ,get_field (s->fields, v1), +get_field (s->fields, v2),get_field (s->fields, v3)); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 06/41] s390x/tcg: Implement VECTOR AND (WITH COMPLEMENT)
Quoted 7 lines · David Hildenbrand
Easy, as we can reuse existing gvec helpers.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 4 ++++ target/s390x/translate_vx.inc.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+)
r~
PATCH 7/41 s390x/tcg: Implement VECTOR AVERAGE
In reply to David HildenbrandHandle 32/64-bit elements via gvec expansion and the 8/16 bits via ool helpers.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 63 +++++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 16 +++++++++ 4 files changed, 83 insertions(+)
target/s390x/helper.h +2 -0
@@ -148,6 +148,8 @@ DEF_HELPER_FLAGS_4(vstl, TCG_CALL_NO_WG, void, env, cptr, i64, i64)/* === Vector Integer Instructions === */ DEF_HELPER_FLAGS_4(gvec_vacc128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_5(gvec_vaccc128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vavg8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vavg16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1068,6 +1068,8 @@ F(0xe768, VN, VRR_c, V, 0, 0, 0, 0, vn, 0, IF_VEC) /* VECTOR AND WITH COMPLEMENT */ F(0xe769, VNC, VRR_c, V, 0, 0, 0, 0, vnc, 0, IF_VEC) +/* VECTOR AVERAGE */ + F(0xe7f2, VAVG, VRR_c, V, 0, 0, 0, 0, vavg, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +63 -0
72 lines not on this page · raw message
target/s390x/vec_int_helper.c +16 -0
@@ -61,3 +61,19 @@ void HELPER(gvec_vaccc128)(void *v1, const void *v2, const void *v3, dst->doubleword[0 ] =0 ; dst->doubleword[1 ] = carry; } + +#define DEF_VAVG (BITS ) \ +void HELPER(gvec_vavg##BITS)(void *v1, const void *v2, const void *v3, \ + uint32_t desc) \ +{ \ + int i; \ + \ + for (i = 0; i < (128 / BITS); i++) { \ + const int32_t a = (int##BITS##_t)s390_vec_read_element##BITS(v2, i); \ + const int32_t b = (int##BITS##_t)s390_vec_read_element##BITS(v3, i); \ + \ + s390_vec_write_element##BITS(v1, i, (a + b + 1) >> 1); \ + } \ +} +DEF_VAVG(8) +DEF_VAVG (16 )
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 07/41] s390x/tcg: Implement VECTOR AVERAGE
target/s390x/translate_vx.inc.c static DisasJumpType op_vnc(DisasContext *s, DisasOps *o) · line 1198
Quoted 3 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +3
-0+} +static DisasJumpType op_vavg (DisasContext *s,DisasOps *o) +{
Watch your spacing.
target/s390x/translate_vx.inc.c static DisasJumpType op_vnc(DisasContext *s, DisasOps *o) · line 1205
Quoted 6 lines
target/s390x/translate_vx.inc.c +6
-0+static const GVecGen3 g[4 ] = { + { .fno = gen_helper_gvec_vavg8, }, + { .fno = gen_helper_gvec_vavg16, }, + { .fni4 = gen_avg_i32, }, + { .fni8 = gen_avg_i64, }, + };
Pondering possible vector expansions. I think one possibility is
t1 = (a >> 1) + (b >> 1);
We still have the two "0.5 bits" to add back in, plus we round up by adding another 0.5. This means if either lsb is set, then we have carry in to the 1's bit. So:
t1 = t1 + ((a | b) & 1);
Which leads to
tcg_gen_sari_vec(vece, t0, a, 1); tcg_gen_sari_vec(vece, t1, b, 1); tcg_gen_or_vec(vece, t2, a, b); tcg_gen_add_vec(vece, t0, t0, t1); tcg_gen_dupi_vec(vece, t1, 1); tcg_gen_and_vec(vece, t2, t2, t1); tcg_gen_add_vec(vece, t0, t0, t2);
{ .fnv = gen_avg_vec,
.fno = gen_helper_gvec_vavg8,
.opc = INDEX_op_sari_vec },
But what you have here is correct and the above is mere optimization so,
r~
Re: [Qemu-devel] [PATCH v1 07/41] s390x/tcg: Implement VECTOR AVERAGE
Quoted 6 lines · Richard Henderson
target/s390x/translate_vx.inc.c static DisasJumpType op_vnc(DisasContext *s, DisasOps *o) · line 1198
Quoted 3 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +3
-0+} +static DisasJumpType op_vavg (DisasContext *s,DisasOps *o) +{Watch your spacing.
Whoops.
Quoted 29 lines
target/s390x/translate_vx.inc.c static DisasJumpType op_vnc(DisasContext *s, DisasOps *o) · line 1205
Quoted 8 lines
target/s390x/translate_vx.inc.c +6
-0+static const GVecGen3 g[4 ] = { + { .fno = gen_helper_gvec_vavg8, }, + { .fno = gen_helper_gvec_vavg16, }, + { .fni4 = gen_avg_i32, }, + { .fni8 = gen_avg_i64, }, + };Pondering possible vector expansions. I think one possibility is
t1 = (a >> 1) + (b >> 1);We still have the two "0.5 bits" to add back in, plus we round up by adding another 0.5. This means if either lsb is set, then we have carry in to the 1's bit. So:
t1 = t1 + ((a | b) & 1);Which leads to
tcg_gen_sari_vec(vece, t0, a, 1); tcg_gen_sari_vec(vece, t1, b, 1); tcg_gen_or_vec(vece, t2, a, b); tcg_gen_add_vec(vece, t0, t0, t1); tcg_gen_dupi_vec(vece, t1, 1); tcg_gen_and_vec(vece, t2, t2, t1); tcg_gen_add_vec(vece, t0, t0, t2);
Quoted 7 lines
{ .fnv =
gen_avg_vec,
.fno =gen_helper_gvec_vavg8,
.opc =INDEX_op_sari_vec},But what you have here is correct and the above is mere optimization so,
Reviewed-by Richard Henderson <[email protected]>
Looks sane, as discussed, let's handle vector expansions later.
Thanks!
Quoted 3 lines
r~
Signature · 3 lines
Thanks, David / dhildenb
PATCH 8/41 s390x/tcg: Implement VECTOR AVERAGE LOGICAL
In reply to David HildenbrandSimilar to VECTOR AVERAGE but without sign extension.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 48 +++++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 16 +++++++++++ 4 files changed, 68 insertions(+)
target/s390x/helper.h +2 -0
@@ -150,6 +150,8 @@ DEF_HELPER_FLAGS_4(gvec_vacc128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_5(gvec_vaccc128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vavg8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vavg16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vavgl8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vavgl16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1070,6 +1070,8 @@ F(0xe769, VNC, VRR_c, V, 0, 0, 0, 0, vnc, 0, IF_VEC) /* VECTOR AVERAGE */ F(0xe7f2, VAVG, VRR_c, V, 0, 0, 0, 0, vavg, 0, IF_VEC) +/* VECTOR AVERAGE LOGICAL */ + F(0xe7f0, VAVGL, VRR_c, V, 0, 0, 0, 0, vavgl, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +48 -0
51 lines not on this page · raw message
target/s390x/vec_int_helper.c +16 -0
@@ -77,3 +77,19 @@ void HELPER(gvec_vavg##BITS)(void *v1, const void *v2, const void *v3, \ } DEF_VAVG(8) DEF_VAVG(16) + +#define DEF_VAVGL (BITS ) \ +void HELPER(gvec_vavgl##BITS)(void *v1, const void *v2, const void *v3, \ + uint32_t desc) \ +{ \ + int i; \ + \ + for (i = 0; i < (128 / BITS); i++) { \ + const uint##BITS##_t a = s390_vec_read_element##BITS(v2, i); \ + const uint##BITS##_t b = s390_vec_read_element##BITS(v3, i); \ + \ + s390_vec_write_element##BITS(v1, i, (a + b + 1) >> 1); \ + } \ +} +DEF_VAVGL(8) +DEF_VAVGL (16 )
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 08/41] s390x/tcg: Implement VECTOR AVERAGE LOGICAL
Quoted 9 lines · David Hildenbrand
Similar to VECTOR AVERAGE but without sign extension.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 48 +++++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 16 +++++++++++ 4 files changed, 68 insertions(+)
The vector expansion for vavg applies here too, except with shri instead of sari. And of course you code is correct as-is.
r~
PATCH 9/41 s390x/tcg: Implement VECTOR CHECKSUM
In reply to David HildenbrandTime to introduce read_vec_element_i32 and write_vec_element_i32. Take proper care of properly adding the carry.
--- target/s390x/insn-data.def | 2 + target/s390x/translate_vx.inc.c | 67 +++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1072,6 +1072,8 @@ F(0xe7f2, VAVG, VRR_c, V, 0, 0, 0, 0, vavg, 0, IF_VEC) /* VECTOR AVERAGE LOGICAL */ F(0xe7f0, VAVGL, VRR_c, V, 0, 0, 0, 0, vavgl, 0, IF_VEC) +/* VECTOR CHECKSUM */ + F(0xe766, VCKSM, VRR_c, V, 0, 0, 0, 0, vcksm, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +67 -0
82 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 09/41] s390x/tcg: Implement VECTOR CHECKSUM
target/s390x/translate_vx.inc.c static DisasJumpType op_vavgl(DisasContext *s, DisasOps *o) · line 1324
Quoted 9 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +9
-0+read_vec_element_i32 (sum,get_field (s->fields, v3),1 ,ES_32 ); +for (i =0 ; i <4 ; i++) { +read_vec_element_i32 (tmp,get_field (s->fields, v2), i,ES_32 ); +tcg_gen_add_i32 (sum, sum, tmp); +tcg_gen_setcond_i32 (TCG_COND_LTU , tmp, sum, tmp); +tcg_gen_add_i32 (sum, sum, tmp); + } +zero_vec (get_field (s->fields, v1)); +write_vec_element_i32 (sum,get_field (s->fields, v1),1 ,ES_32 );
It seems like it should be possible to implement this with i64, and fold the carry around at the end -- 2 insns instead of 12 for managing carry. But I can't quite tell if that produces the same results.
You could use
tcg_gen_add2_i32(sum, tmp, sum, zero, tmp, zero); tcg_gen_add_i32(sum, sum, tmp);
instead of computing carry manually with setcond.
That said, your code exactly matches the language in the manual, so
r~
Re: [Qemu-devel] [PATCH v1 09/41] s390x/tcg: Implement VECTOR CHECKSUM
Quoted 11 lines · Richard Henderson
target/s390x/translate_vx.inc.c static DisasJumpType op_vavgl(DisasContext *s, DisasOps *o) · line 1324
Quoted 9 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +9
-0+read_vec_element_i32 (sum,get_field (s->fields, v3),1 ,ES_32 ); +for (i =0 ; i <4 ; i++) { +read_vec_element_i32 (tmp,get_field (s->fields, v2), i,ES_32 ); +tcg_gen_add_i32 (sum, sum, tmp); +tcg_gen_setcond_i32 (TCG_COND_LTU , tmp, sum, tmp); +tcg_gen_add_i32 (sum, sum, tmp); + } +zero_vec (get_field (s->fields, v1)); +write_vec_element_i32 (sum,get_field (s->fields, v1),1 ,ES_32 );
Quoted 3 lines
It seems like it should be possible to implement this with i64, and fold the carry around at the end -- 2 insns instead of 12 for managing carry. But I can't quite tell if that produces the same results.
I had the same in mind but also wasn't sure if it would produce the exact same result. Feels like it should.
Quoted 5 lines
You could use
tcg_gen_add2_i32(sum, tmp, sum, zero, tmp, zero);tcg_gen_add_i32(sum, sum, tmp);
That makes perfect sense, I will use that for now, thanks!
Quoted 10 lines
instead of computing carry manually with setcond.
That said, your code exactly matches the language in the manual, so
Reviewed-by Richard Henderson <[email protected]>r~
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v1 09/41] s390x/tcg: Implement VECTOR CHECKSUM
Quoted 6 lines · David Hildenbrand
Quoted 4 lines
You could use
tcg_gen_add2_i32(sum, tmp, sum, zero, tmp, zero);tcg_gen_add_i32(sum, sum, tmp);That makes perfect sense, I will use that for now, thanks!
Here's a funny one. We can do this in one operation:
tcg_gen_add2_i32(tmp, sum, sum, sum, tmp, tmp);
The lower (sum+tmp) carries into the upper (sum+tmp). We take the upper result and discard the lower.
r~
Re: [Qemu-devel] [PATCH v1 09/41] s390x/tcg: Implement VECTOR CHECKSUM
Quoted 11 lines · Richard Henderson
Quoted 6 lines · David Hildenbrand
Quoted 4 lines
You could use
tcg_gen_add2_i32(sum, tmp, sum, zero, tmp, zero);tcg_gen_add_i32(sum, sum, tmp);That makes perfect sense, I will use that for now, thanks!
Here's a funny one. We can do this in one operation:
tcg_gen_add2_i32(tmp, sum, sum, sum, tmp, tmp);
:D I had to look at it 10 times. Very nice trick.
Quoted 7 lines
The lower (sum+tmp) carries into the upper (sum+tmp). We take the upper result and discard the lower.
r~
Signature · 3 lines
Thanks, David / dhildenb
PATCH 10/41 s390x/tcg: Implement VECTOR ELEMENT COMPARE *
In reply to David HildenbrandFairly easy to implement, we can make use of the existing CC helpers cmps64 and cmpu64 - we siply have to sign extend the elements.
--- target/s390x/insn-data.def | 4 ++++ target/s390x/translate_vx.inc.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+)
target/s390x/insn-data.def +4 -0
@@ -1074,6 +1074,10 @@ F(0xe7f0, VAVGL, VRR_c, V, 0, 0, 0, 0, vavgl, 0, IF_VEC) /* VECTOR CHECKSUM */ F(0xe766, VCKSM, VRR_c, V, 0, 0, 0, 0, vcksm, 0, IF_VEC) +/* VECTOR ELEMENT COMPARE */ + F(0xe7db, VEC, VRR_a, V, 0, 0, 0, 0, vec, cmps64, IF_VEC) +/* VECTOR ELEMENT COMPARE LOGICAL */ + F(0xe7d9, VECL, VRR_a, V, 0, 0, 0, 0, vec, cmpu64, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +20 -0
@@ -1327,3 +1327,23 @@ static DisasJumpType op_vcksm(DisasContext *s, DisasOps *o)tcg_temp_free_i32 (sum);return DISAS_NEXT ; } + +static DisasJumpType op_vec (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m3); +const uint8_t enr =NUM_VEC_ELEMENTS (es) /2 -1 ; +const bool logical = s->fields->op2 ==0xd9 ; + +if (es >ES_64 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + + o->in1 =tcg_temp_new_i64 (); + o->in2 =tcg_temp_new_i64 (); +read_vec_element_i64 (o->in1,get_field (s->fields, v1), enr, + es | logical ?0 :MO_SIGN ); +read_vec_element_i64 (o->in2,get_field (s->fields, v2), enr, + es | logical ?0 :MO_SIGN ); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 10/41] s390x/tcg: Implement VECTOR ELEMENT COMPARE *
Quoted 1 line · David Hildenbrand
+ es | logical ? 0 :
MO_SIGN);
Incorrect operator precedence. You need:
es | (logical ? 0 : MO_SIGN)
or
logical ? es : es | MO_SIGN
And perhaps cse this expression into a temporary
and not replicate it between the two reads.
Otherwise,
r~
Re: [Qemu-devel] [PATCH v1 10/41] s390x/tcg: Implement VECTOR ELEMENT COMPARE *
Quoted 11 lines · Richard Henderson
Quoted 1 line · David Hildenbrand
+ es | logical ? 0 :
MO_SIGN);Incorrect operator precedence. You need:
es | (logical ? 0 :
MO_SIGN)or
logical ? es : es |
MO_SIGN
Quoted 9 lines
And perhaps cse this expression into a temporary
and not replicate it between the two reads.Otherwise,
Reviewed-by Richard Henderson <[email protected]>r~
Thanks, good catch! I'll do it like this
+static DisasJumpType op_vec(DisasContext *s, DisasOps *o) +{
+ uint8_t es = get_field(s->fields, m3);
+ const uint8_t enr = NUM_VEC_ELEMENTS(es) / 2 - 1;
+
+ if (es > ES_64) {
+ gen_program_exception(s, PGM_SPECIFICATION);
+ return DISAS_NORETURN;
+ }
+ if (s->fields->op2 == 0xdb) {
+ es |= MO_SIGN;
+ }
+
+ o->in1 = tcg_temp_new_i64(); + o->in2 = tcg_temp_new_i64(); + read_vec_element_i64(o->in1, get_field(s->fields, v1), enr, es); + read_vec_element_i64(o->in2, get_field(s->fields, v2), enr, es); + return DISAS_NEXT;
+}
Signature · 3 lines
Thanks, David / dhildenb
PATCH 11/41 s390x/tcg: Implement VECTOR COMPARE *
In reply to David HildenbrandTo carry out the comparison, we can reuse the existing gvec comparison function. In case the CC is to be computed, save the result vector and compute the CC lazily. The result is a vector consisting of all 1's for elements that matched and 0's for elements that didn't match.
--- target/s390x/cc_helper.c | 17 +++++++++++++++++ target/s390x/helper.c | 1 + target/s390x/insn-data.def | 6 ++++++ target/s390x/internal.h | 1 + target/s390x/translate.c | 1 + target/s390x/translate_vx.inc.c | 28 ++++++++++++++++++++++++++++ 6 files changed, 54 insertions(+)
target/s390x/cc_helper.c +17 -0
@@ -402,6 +402,20 @@ static uint32_t cc_calc_lcbb(uint64_t dst)return dst ==16 ?0 :3 ; } +static uint32_t cc_calc_vc (uint64_t low,uint64_t high) +{ +if (high ==-1ull && low ==-1ull ) { +/* all elements match */ +return 0 ; + }else if (high ==0 && low ==0 ) { +/* no elements match */ +return 3 ; + }else { +/* some elements but not all match */ +return 1 ; + } +} +static uint32_t do_calc_cc (CPUS390XState *env,uint32_t cc_op,uint64_t src,uint64_t dst,uint64_t vr) {
@@ -514,6 +528,9 @@ static uint32_t do_calc_cc(CPUS390XState *env, uint32_t cc_op,case CC_OP_LCBB : r =cc_calc_lcbb (dst);break ; +case CC_OP_VC : + r =cc_calc_vc (src, dst); +break ;case CC_OP_NZ_F32 : r =set_cc_nz_f32 (dst);
target/s390x/helper.c +1 -0
@@ -418,6 +418,7 @@ const char *cc_name(enum cc_op cc_op) [CC_OP_SLA_64] = "CC_OP_SLA_64", [CC_OP_FLOGR] = "CC_OP_FLOGR", [CC_OP_LCBB] = "CC_OP_LCBB", + [CC_OP_VC] = "CC_OP_VC", };return cc_names[cc_op];
target/s390x/insn-data.def +6 -0
@@ -1078,6 +1078,12 @@ F(0xe7db, VEC, VRR_a, V, 0, 0, 0, 0, vec, cmps64, IF_VEC) /* VECTOR ELEMENT COMPARE LOGICAL */ F(0xe7d9, VECL, VRR_a, V, 0, 0, 0, 0, vec, cmpu64, IF_VEC) +/* VECTOR COMPARE EQUAL */ + E(0xe7f8, VCEQ, VRR_b, V, 0, 0, 0, 0, vc, 0, TCG_COND_EQ, IF_VEC) +/* VECTOR COMPARE HIGH */ + E(0xe7fb, VCH, VRR_b, V, 0, 0, 0, 0, vc, 0, TCG_COND_GT, IF_VEC) +/* VECTOR COMPARE HIGH LOGICAL */ + E(0xe7f9, VCHL, VRR_b, V, 0, 0, 0, 0, vc, 0, TCG_COND_GTU, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/internal.h +1 -0
@@ -200,6 +200,7 @@ enum cc_op {CC_OP_SLA_64 ,/* Calculate shift left signed (64bit) */ CC_OP_FLOGR ,/* find leftmost one */ CC_OP_LCBB ,/* load count to block boundary */ +CC_OP_VC ,/* vector compare result */ CC_OP_MAX };
target/s390x/translate.c +1 -0
@@ -572,6 +572,7 @@ static void gen_op_calc_cc(DisasContext *s)case CC_OP_SLA_32 :case CC_OP_SLA_64 :case CC_OP_NZ_F128 : +case CC_OP_VC :/* 2 arguments */ gen_helper_calc_cc (cc_op, cpu_env, local_cc_op, cc_src, cc_dst, dummy);break ;
target/s390x/translate_vx.inc.c +28 -0
@@ -1347,3 +1347,31 @@ static DisasJumpType op_vec(DisasContext *s, DisasOps *o) es | logical ? 0 : MO_SIGN);return DISAS_NEXT ; } + +static DisasJumpType op_vc (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m4); +TCGCond cond = s->insn->data; + +if (es >ES_64 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +tcg_gen_gvec_cmp (cond, es, +vec_full_reg_offset (get_field (s->fields, v1)), +vec_full_reg_offset (get_field (s->fields, v2)), +vec_full_reg_offset (get_field (s->fields, v3)),16 ,16 ); +if (get_field (s->fields, m5) &0x1 ) { +TCGv_i64 low =tcg_temp_new_i64 (); +TCGv_i64 high =tcg_temp_new_i64 (); + +read_vec_element_i64 (high,get_field (s->fields, v1),0 ,ES_64 ); +read_vec_element_i64 (low,get_field (s->fields, v1),1 ,ES_64 ); +gen_op_update2_cc_i64 (s,CC_OP_VC , low, high); + +tcg_temp_free_i64 (low); +tcg_temp_free_i64 (high); + } +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 11/41] s390x/tcg: Implement VECTOR COMPARE *
Quoted 6 lines · David Hildenbrand
To carry out the comparison, we can reuse the existing gvec comparison function. In case the CC is to be computed, save the result vector and compute the CC lazily. The result is a vector consisting of all 1's for elements that matched and 0's for elements that didn't match.
Signed-off-by David Hildenbrand <[email protected]>
Quoted 8 lines
--- target/s390x/cc_helper.c | 17 +++++++++++++++++ target/s390x/helper.c | 1 + target/s390x/insn-data.def | 6 ++++++ target/s390x/internal.h | 1 + target/s390x/translate.c | 1 + target/s390x/translate_vx.inc.c | 28 ++++++++++++++++++++++++++++ 6 files changed, 54 insertions(+)
r~
PATCH 12/41 s390x/tcg: Implement VECTOR COUNT LEADING ZEROS
In reply to David HildenbrandFor 8/16, use the 32 bit variant and properly subtract the added leading zero bits.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 31 +++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 14 ++++++++++++++ 4 files changed, 49 insertions(+)
target/s390x/helper.h +2 -0
@@ -152,6 +152,8 @@ DEF_HELPER_FLAGS_4(gvec_vavg8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vavg16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vavgl8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vavgl16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_3(gvec_vclz8, TCG_CALL_NO_RWG, void, ptr, cptr, i32) +DEF_HELPER_FLAGS_3(gvec_vclz16, TCG_CALL_NO_RWG, void, ptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1084,6 +1084,8 @@ E(0xe7fb, VCH, VRR_b, V, 0, 0, 0, 0, vc, 0, TCG_COND_GT, IF_VEC) /* VECTOR COMPARE HIGH LOGICAL */ E(0xe7f9, VCHL, VRR_b, V, 0, 0, 0, 0, vc, 0, TCG_COND_GTU, IF_VEC) +/* VECTOR COUNT LEADING ZEROS */ + F(0xe753, VCLZ, VRR_a, V, 0, 0, 0, 0, vclz, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +31 -0
@@ -182,6 +182,9 @@ static void get_vec_element_ptr_i64(TCGv_ptr ptr, uint8_t reg, TCGv_i64 enr,tcg_temp_free_i64 (tmp); } +#define gen_gvec_2 (v1, v2, gen) \ + tcg_gen_gvec_2(vec_full_reg_offset(v1), vec_full_reg_offset(v2), \ + 16, 16, gen)#define gen_gvec_3 (v1, v2, v3, gen) \ tcg_gen_gvec_3(vec_full_reg_offset(v1), vec_full_reg_offset(v2), \ vec_full_reg_offset(v3), 16, 16, gen)
@@ -1375,3 +1378,31 @@ static DisasJumpType op_vc(DisasContext *s, DisasOps *o) }return DISAS_NEXT ; } + +static void gen_clz_i32 (TCGv_i32 d,TCGv_i32 a) +{ +tcg_gen_clzi_i32 (d, a,32 ); +} + +static void gen_clz_i64 (TCGv_i64 d,TCGv_i64 a) +{ +tcg_gen_clzi_i64 (d, a,64 ); +} + +static DisasJumpType op_vclz (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m3); +static const GVecGen2 g[4 ] = { + { .fno = gen_helper_gvec_vclz8, }, + { .fno = gen_helper_gvec_vclz16, }, + { .fni4 = gen_clz_i32, }, + { .fni8 = gen_clz_i64, }, + }; + +if (es >ES_64 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } +gen_gvec_2 (get_field (s->fields, v1),get_field (s->fields, v2), &g[es]); +return DISAS_NEXT ; +}
target/s390x/vec_int_helper.c +14 -0
@@ -93,3 +93,17 @@ void HELPER(gvec_vavgl##BITS)(void *v1, const void *v2, const void *v3, \ } DEF_VAVGL(8) DEF_VAVGL(16) + +#define DEF_VCLZ (BITS ) \ +void HELPER(gvec_vclz##BITS)(void *v1, const void *v2, uint32_t desc) \ +{ \ + int i; \ + \ + for (i = 0; i < (128 / BITS); i++) { \ + const uint##BITS##_t a = s390_vec_read_element##BITS(v2, i); \ + \ + s390_vec_write_element##BITS(v1, i, clz32(a) - 32 + BITS); \ + } \ +} +DEF_VCLZ(8) +DEF_VCLZ (16 )
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 12/41] s390x/tcg: Implement VECTOR COUNT LEADING ZEROS
Quoted 11 lines · David Hildenbrand
For 8/16, use the 32 bit variant and properly subtract the added leading zero bits.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 31 +++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 14 ++++++++++++++ 4 files changed, 49 insertions(+)
r~
PATCH 13/41 s390x/tcg: Implement VECTOR COUNT TRAILING ZEROS
In reply to David HildenbrandImplement it similar to VECTOR COUNT LEADING ZEROS.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 28 ++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 14 ++++++++++++++ 4 files changed, 46 insertions(+)
target/s390x/helper.h +2 -0
@@ -154,6 +154,8 @@ DEF_HELPER_FLAGS_4(gvec_vavgl8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vavgl16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_3(gvec_vclz8, TCG_CALL_NO_RWG, void, ptr, cptr, i32) DEF_HELPER_FLAGS_3(gvec_vclz16, TCG_CALL_NO_RWG, void, ptr, cptr, i32) +DEF_HELPER_FLAGS_3(gvec_vctz8, TCG_CALL_NO_RWG, void, ptr, cptr, i32) +DEF_HELPER_FLAGS_3(gvec_vctz16, TCG_CALL_NO_RWG, void, ptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1086,6 +1086,8 @@ E(0xe7f9, VCHL, VRR_b, V, 0, 0, 0, 0, vc, 0, TCG_COND_GTU, IF_VEC) /* VECTOR COUNT LEADING ZEROS */ F(0xe753, VCLZ, VRR_a, V, 0, 0, 0, 0, vclz, 0, IF_VEC) +/* VECTOR COUNT TRAILING ZEROS */ + F(0xe752, VCTZ, VRR_a, V, 0, 0, 0, 0, vctz, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +28 -0
@@ -1406,3 +1406,31 @@ static DisasJumpType op_vclz(DisasContext *s, DisasOps *o)gen_gvec_2 (get_field (s->fields, v1),get_field (s->fields, v2), &g[es]);return DISAS_NEXT ; } + +static void gen_ctz_i32 (TCGv_i32 d,TCGv_i32 a) +{ +tcg_gen_ctzi_i32 (d, a,32 ); +} + +static void gen_ctz_i64 (TCGv_i64 d,TCGv_i64 a) +{ +tcg_gen_ctzi_i64 (d, a,64 ); +} + +static DisasJumpType op_vctz (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m3); +static const GVecGen2 g[4 ] = { + { .fno = gen_helper_gvec_vctz8, }, + { .fno = gen_helper_gvec_vctz16, }, + { .fni4 = gen_ctz_i32, }, + { .fni8 = gen_ctz_i64, }, + }; + +if (es >ES_64 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } +gen_gvec_2 (get_field (s->fields, v1),get_field (s->fields, v2), &g[es]); +return DISAS_NEXT ; +}
target/s390x/vec_int_helper.c +14 -0
@@ -107,3 +107,17 @@ void HELPER(gvec_vclz##BITS)(void *v1, const void *v2, uint32_t desc) \ } DEF_VCLZ(8) DEF_VCLZ(16) + +#define DEF_VCTZ (BITS ) \ +void HELPER(gvec_vctz##BITS)(void *v1, const void *v2, uint32_t desc) \ +{ \ + int i; \ + \ + for (i = 0; i < (128 / BITS); i++) { \ + const uint##BITS##_t a = s390_vec_read_element##BITS(v2, i); \ + \ + s390_vec_write_element##BITS(v1, i, ctz32(a)); \ + } \ +} +DEF_VCTZ(8) +DEF_VCTZ (16 )
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 13/41] s390x/tcg: Implement VECTOR COUNT TRAILING ZEROS
Quoted 1 line · David Hildenbrand
+ s390_vec_write_element##BITS(v1, i, ctz32(a));
Wrong result for a == 0. You need a ? ctz32(a) : BITS.
r~
Re: [Qemu-devel] [PATCH v1 13/41] s390x/tcg: Implement VECTOR COUNT TRAILING ZEROS
Quoted 1 line · Richard Henderson
a ? ctz32(a) : BITS
Nice catch, thanks!
Signature · 3 lines
Thanks, David / dhildenb
PATCH 14/41 s390x/tcg: Implement VECTOR EXCLUSIVE OR
In reply to David HildenbrandEasy, we can reuse an existing gvec helper.
--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 7 +++++++ 2 files changed, 9 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1088,6 +1088,8 @@ F(0xe753, VCLZ, VRR_a, V, 0, 0, 0, 0, vclz, 0, IF_VEC) /* VECTOR COUNT TRAILING ZEROS */ F(0xe752, VCTZ, VRR_a, V, 0, 0, 0, 0, vctz, 0, IF_VEC) +/* VECTOR EXCLUSIVE OR */ + F(0xe76d, VX, VRR_c, V, 0, 0, 0, 0, vx, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +7 -0
@@ -1434,3 +1434,10 @@ static DisasJumpType op_vctz(DisasContext *s, DisasOps *o)gen_gvec_2 (get_field (s->fields, v1),get_field (s->fields, v2), &g[es]);return DISAS_NEXT ; } + +static DisasJumpType op_vx (DisasContext *s,DisasOps *o) +{ +gen_gvec_fn_3 (xor,ES_8 ,get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3)); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 14/41] s390x/tcg: Implement VECTOR EXCLUSIVE OR
Quoted 7 lines · David Hildenbrand
Easy, we can reuse an existing gvec helper.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 7 +++++++ 2 files changed, 9 insertions(+)
r~
PATCH 15/41 s390x/tcg: Implement VECTOR GALOIS FIELD MULTIPLY SUM (AND ACCUMULATE)
In reply to David HildenbrandA galois field multiplication in field 2 is like binary multiplication, however instead of doing ordinary binary additions, xor's are performed. So no carries are considered.
Implement all variants via helpers. s390_vec_sar() and s390_vec_shr() will be reused later on.
--- target/s390x/helper.h | 8 ++ target/s390x/insn-data.def | 4 + target/s390x/translate_vx.inc.c | 38 ++++++++ target/s390x/vec_int_helper.c | 168 ++++++++++++++++++++++++++++++++ 4 files changed, 218 insertions(+)
target/s390x/helper.h +8 -0
@@ -156,6 +156,14 @@ DEF_HELPER_FLAGS_3(gvec_vclz8, TCG_CALL_NO_RWG, void, ptr, cptr, i32) DEF_HELPER_FLAGS_3(gvec_vclz16, TCG_CALL_NO_RWG, void, ptr, cptr, i32) DEF_HELPER_FLAGS_3(gvec_vctz8, TCG_CALL_NO_RWG, void, ptr, cptr, i32) DEF_HELPER_FLAGS_3(gvec_vctz16, TCG_CALL_NO_RWG, void, ptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vgfm8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vgfm16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vgfm32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vgfm64, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vgfma8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vgfma16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vgfma32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vgfma64, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +4 -0
@@ -1090,6 +1090,10 @@ F(0xe752, VCTZ, VRR_a, V, 0, 0, 0, 0, vctz, 0, IF_VEC) /* VECTOR EXCLUSIVE OR */ F(0xe76d, VX, VRR_c, V, 0, 0, 0, 0, vx, 0, IF_VEC) +/* VECTOR GALOIS FIELD MULTIPLY SUM */ + F(0xe7b4, VGFM, VRR_c, V, 0, 0, 0, 0, vgfm, 0, IF_VEC) +/* VECTOR GALOIS FIELD MULTIPLY SUM AND ACCUMULATE */ + F(0xe7bc, VGFMA, VRR_d, V, 0, 0, 0, 0, vgfma, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +38 -0
@@ -1441,3 +1441,41 @@ static DisasJumpType op_vx(DisasContext *s, DisasOps *o) get_field(s->fields, v3));return DISAS_NEXT ; } + +static DisasJumpType op_vgfm (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m4); +static const GVecGen3 g[4 ] = { + { .fno = gen_helper_gvec_vgfm8, }, + { .fno = gen_helper_gvec_vgfm16, }, + { .fno = gen_helper_gvec_vgfm32, }, + { .fno = gen_helper_gvec_vgfm64, }, + }; + +if (es >ES_64 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } +gen_gvec_3 (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3), &g[es]); +return DISAS_NEXT ; +} + +static DisasJumpType op_vgfma (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m5); +static const GVecGen4 g[4 ] = { + { .fno = gen_helper_gvec_vgfma8, }, + { .fno = gen_helper_gvec_vgfma16, }, + { .fno = gen_helper_gvec_vgfma32, }, + { .fno = gen_helper_gvec_vgfma64, }, + }; + +if (es >ES_64 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } +gen_gvec_4 (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3),get_field (s->fields, v4), &g[es]); +return DISAS_NEXT ; +}
target/s390x/vec_int_helper.c +168 -0
177 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 15/41] s390x/tcg: Implement VECTOR GALOIS FIELD MULTIPLY SUM (AND ACCUMULATE)
Quoted 7 lines · David Hildenbrand
A galois field multiplication in field 2 is like binary multiplication, however instead of doing ordinary binary additions, xor's are performed. So no carries are considered.
Implement all variants via helpers.
s390_vec_sar()ands390_vec_shr()will be reused later on.
Quoted 7 lines
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 8 ++ target/s390x/insn-data.def | 4 + target/s390x/translate_vx.inc.c | 38 ++++++++ target/s390x/vec_int_helper.c | 168 ++++++++++++++++++++++++++++++++ 4 files changed, 218 insertions(+)
FYI, this is now the 4th copy of this operation.
arm: pmull
x86: pclmulqdq
ppc: vpmsum[bhwd]
We really should promote this to generic. But that can come later,
r~
Re: [Qemu-devel] [PATCH v1 15/41] s390x/tcg: Implement VECTOR GALOIS FIELD MULTIPLY SUM (AND ACCUMULATE)
Quoted 16 lines · Richard Henderson
Quoted 7 lines · David Hildenbrand
A galois field multiplication in field 2 is like binary multiplication, however instead of doing ordinary binary additions, xor's are performed. So no carries are considered.
Implement all variants via helpers.
s390_vec_sar()ands390_vec_shr()will be reused later on.Quoted 7 lines
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 8 ++ target/s390x/insn-data.def | 4 + target/s390x/translate_vx.inc.c | 38 ++++++++ target/s390x/vec_int_helper.c | 168 ++++++++++++++++++++++++++++++++ 4 files changed, 218 insertions(+)
Quoted 7 lines
FYI, this is now the 4th copy of this operation.
arm: pmull
x86: pclmulqdq
ppc: vpmsum[bhwd]We really should promote this to generic. But that can come later,
huh, I tried my best to search for anything related to galois, but seems like only s390x uses that terminology. :) Well at least I learned how it is supposed to be calculated.
Thanks!
Quoted 6 lines
Reviewed-by Richard Henderson <[email protected]>r~
Signature · 3 lines
Thanks, David / dhildenb
PATCH 16/41 s390x/tcg: Implement VECTOR LOAD COMPLEMENT
In reply to David HildenbrandWe can reuse an existing gvec helper for negating the values.
--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1094,6 +1094,8 @@ F(0xe7b4, VGFM, VRR_c, V, 0, 0, 0, 0, vgfm, 0, IF_VEC) /* VECTOR GALOIS FIELD MULTIPLY SUM AND ACCUMULATE */ F(0xe7bc, VGFMA, VRR_d, V, 0, 0, 0, 0, vgfma, 0, IF_VEC) +/* VECTOR LOAD COMPLEMENT */ + F(0xe7de, VLC, VRR_a, V, 0, 0, 0, 0, vlc, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +17 -0
@@ -209,6 +209,9 @@ static void get_vec_element_ptr_i64(TCGv_ptr ptr, uint8_t reg, TCGv_i64 enr, 16)#define gen_gvec_dup64i (v1, c) \ tcg_gen_gvec_dup64i(vec_full_reg_offset(v1), 16, 16, c) +#define gen_gvec_fn_2 (fn, es, v1, v2) \ + tcg_gen_gvec_##fn(es, vec_full_reg_offset(v1), vec_full_reg_offset(v2), \ + 16, 16)#define gen_gvec_fn_3 (fn, es, v1, v2, v3) \ tcg_gen_gvec_##fn(es, vec_full_reg_offset(v1), vec_full_reg_offset(v2), \ vec_full_reg_offset(v3), 16, 16)
@@ -1479,3 +1482,17 @@ static DisasJumpType op_vgfma(DisasContext *s, DisasOps *o) get_field(s->fields, v3), get_field(s->fields, v4), &g[es]);return DISAS_NEXT ; } + +static DisasJumpType op_vlc (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m3); + +if (es >ES_64 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +gen_gvec_fn_2 (neg,ES_8 ,get_field (s->fields, v1), +get_field (s->fields, v2)); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 16/41] s390x/tcg: Implement VECTOR LOAD COMPLEMENT
Quoted 7 lines · David Hildenbrand
We can reuse an existing gvec helper for negating the values.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+)
r~
PATCH 17/41 s390x/tcg: Implement VECTOR LOAD POSITIVE
In reply to David HildenbrandSimilar to VECTOR LOAD COMPLEMENT but unfortunately we don't have a gvec helper.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 40 +++++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 14 ++++++++++++ 4 files changed, 58 insertions(+)
target/s390x/helper.h +2 -0
@@ -164,6 +164,8 @@ DEF_HELPER_FLAGS_5(gvec_vgfma8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i3 DEF_HELPER_FLAGS_5(gvec_vgfma16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) DEF_HELPER_FLAGS_5(gvec_vgfma32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) DEF_HELPER_FLAGS_5(gvec_vgfma64, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_3(gvec_vlp8, TCG_CALL_NO_RWG, void, ptr, cptr, i32) +DEF_HELPER_FLAGS_3(gvec_vlp16, TCG_CALL_NO_RWG, void, ptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1096,6 +1096,8 @@ F(0xe7bc, VGFMA, VRR_d, V, 0, 0, 0, 0, vgfma, 0, IF_VEC) /* VECTOR LOAD COMPLEMENT */ F(0xe7de, VLC, VRR_a, V, 0, 0, 0, 0, vlc, 0, IF_VEC) +/* VECTOR LOAD POSITIVE */ + F(0xe7df, VLP, VRR_a, V, 0, 0, 0, 0, vlp, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +40 -0
@@ -1496,3 +1496,43 @@ static DisasJumpType op_vlc(DisasContext *s, DisasOps *o) get_field(s->fields, v2));return DISAS_NEXT ; } + +static void gen_lp_i32 (TCGv_i32 d,TCGv_i32 a) +{ +TCGv_i32 zero =tcg_const_i32 (0 ); +TCGv_i32 neg =tcg_temp_new_i32 (); + +tcg_gen_neg_i32 (neg, a); +tcg_gen_movcond_i32 (TCG_COND_LT , d, a, zero, neg, a); +tcg_temp_free_i32 (neg); +tcg_temp_free_i32 (zero); +} + +static void gen_lp_i64 (TCGv_i64 d,TCGv_i64 a) +{ +TCGv_i64 zero =tcg_const_i64 (0 ); +TCGv_i64 neg =tcg_temp_new_i64 (); + +tcg_gen_neg_i64 (neg, a); +tcg_gen_movcond_i64 (TCG_COND_LT , d, a, zero, neg, a); +tcg_temp_free_i64 (neg); +tcg_temp_free_i64 (zero); +} + +static DisasJumpType op_vlp (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m3); +static const GVecGen2 g[4 ] = { + { .fno = gen_helper_gvec_vlp8, }, + { .fno = gen_helper_gvec_vlp16, }, + { .fni4 = gen_lp_i32, }, + { .fni8 = gen_lp_i64, }, + }; + +if (es >ES_64 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } +gen_gvec_2 (get_field (s->fields, v1),get_field (s->fields, v2), &g[es]); +return DISAS_NEXT ; +}
target/s390x/vec_int_helper.c +14 -0
@@ -289,3 +289,17 @@ void HELPER(gvec_vgfma64)(void *v1, const void *v2, const void *v3,s390_vec_xor (&tmp1, &tmp1, &tmp2);s390_vec_xor (v1, &tmp1, v4); } + +#define DEF_VLP (BITS ) \ +void HELPER(gvec_vlp##BITS)(void *v1, const void *v2, uint32_t desc) \ +{ \ + int i; \ + \ + for (i = 0; i < (128 / BITS); i++) { \ + const int##BITS##_t a = s390_vec_read_element##BITS(v2, i); \ + \ + s390_vec_write_element##BITS(v1, i, a < 0 ? -a : a); \ + } \ +} +DEF_VLP(8) +DEF_VLP (16 )
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 17/41] s390x/tcg: Implement VECTOR LOAD POSITIVE
Quoted 10 lines · David Hildenbrand
Similar to VECTOR LOAD COMPLEMENT but unfortunately we don't have a gvec helper.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 40 +++++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 14 ++++++++++++ 4 files changed, 58 insertions(+)
I would be happy to add ABS as a gvec primitive, if you like. Expandable with MAX or CMP on hosts without ABS.
r~
Re: [Qemu-devel] [PATCH v1 17/41] s390x/tcg: Implement VECTOR LOAD POSITIVE
Quoted 12 lines · Richard Henderson
Quoted 10 lines · David Hildenbrand
Similar to VECTOR LOAD COMPLEMENT but unfortunately we don't have a gvec helper.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 40 +++++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 14 ++++++++++++ 4 files changed, 58 insertions(+)
Quoted 2 lines
I would be happy to add ABS as a gvec primitive, if you like. Expandable with MAX or CMP on hosts without ABS.
Sure, that would be great. Once you have that one implemented we can throw most of this stuff away (either before or after merging). Thanks!
Quoted 6 lines
Reviewed-by Richard Henderson <[email protected]>r~
Signature · 3 lines
Thanks, David / dhildenb
PATCH 18/41 s390x/tcg: Implement VECTOR (MAXIMUM|MINIMUM) (LOGICAL)
In reply to David HildenbrandLuckily, we already have gvec helpers for all four cases.
--- target/s390x/insn-data.def | 8 ++++++++ target/s390x/translate_vx.inc.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+)
target/s390x/insn-data.def +8 -0
@@ -1098,6 +1098,14 @@ F(0xe7de, VLC, VRR_a, V, 0, 0, 0, 0, vlc, 0, IF_VEC) /* VECTOR LOAD POSITIVE */ F(0xe7df, VLP, VRR_a, V, 0, 0, 0, 0, vlp, 0, IF_VEC) +/* VECTOR MAXIMUM */ + F(0xe7ff, VMX, VRR_c, V, 0, 0, 0, 0, vmx, 0, IF_VEC) +/* VECTOR MAXIMUM LOGICAL */ + F(0xe7fd, VMXL, VRR_c, V, 0, 0, 0, 0, vmx, 0, IF_VEC) +/* VECTOR MINIMUM */ + F(0xe7fe, VMN, VRR_c, V, 0, 0, 0, 0, vmx, 0, IF_VEC) +/* VECTOR MINIMUM LOGICAL */ + F(0xe7fc, VMNL, VRR_c, V, 0, 0, 0, 0, vmx, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +31 -0
@@ -1536,3 +1536,34 @@ static DisasJumpType op_vlp(DisasContext *s, DisasOps *o)gen_gvec_2 (get_field (s->fields, v1),get_field (s->fields, v2), &g[es]);return DISAS_NEXT ; } + +static DisasJumpType op_vmx (DisasContext *s,DisasOps *o) +{ +const uint8_t v1 =get_field (s->fields, v1); +const uint8_t v2 =get_field (s->fields, v2); +const uint8_t v3 =get_field (s->fields, v3); +const uint8_t es =get_field (s->fields, m4); + +if (es >ES_64 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +switch (s->fields->op2) { +case 0xff : +gen_gvec_fn_3 (smax, es, v1, v2, v3); +break ; +case 0xfd : +gen_gvec_fn_3 (umax, es, v1, v2, v3); +break ; +case 0xfe : +gen_gvec_fn_3 (smin, es, v1, v2, v3); +break ; +case 0xfc : +gen_gvec_fn_3 (umin, es, v1, v2, v3); +break ; +default : +g_assert_not_reached (); + } +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 18/41] s390x/tcg: Implement VECTOR (MAXIMUM|MINIMUM) (LOGICAL)
Quoted 7 lines · David Hildenbrand
Luckily, we already have gvec helpers for all four cases.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 8 ++++++++ target/s390x/translate_vx.inc.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+)
r~
PATCH 19/41 s390x/tcg: Implement VECTOR MULTIPLY AND ADD *
In reply to David HildenbrandQuite some variants to handle. At least handle some 32-bit element variants via gvec expansion (we could also handle 16/32-bit variants for ODD and EVEN easily via gvec expansion, but let's keep it simple for now).
--- target/s390x/helper.h | 18 +++++ target/s390x/insn-data.def | 14 ++++ target/s390x/translate_vx.inc.c | 122 +++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 123 ++++++++++++++++++++++++++++++++ 4 files changed, 277 insertions(+)
target/s390x/helper.h +18 -0
@@ -166,6 +166,24 @@ DEF_HELPER_FLAGS_5(gvec_vgfma32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i DEF_HELPER_FLAGS_5(gvec_vgfma64, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) DEF_HELPER_FLAGS_3(gvec_vlp8, TCG_CALL_NO_RWG, void, ptr, cptr, i32) DEF_HELPER_FLAGS_3(gvec_vlp16, TCG_CALL_NO_RWG, void, ptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmal8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmal16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmah8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmah16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmalh8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmalh16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmae8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmae16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmae32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmale8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmale16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmale32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmao8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmao16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmao32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmalo8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmalo16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vmalo32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +14 -0
@@ -1106,6 +1106,20 @@ F(0xe7fe, VMN, VRR_c, V, 0, 0, 0, 0, vmx, 0, IF_VEC) /* VECTOR MINIMUM LOGICAL */ F(0xe7fc, VMNL, VRR_c, V, 0, 0, 0, 0, vmx, 0, IF_VEC) +/* VECTOR MULTIPLY AND ADD LOW */ + F(0xe7aa, VMAL, VRR_d, V, 0, 0, 0, 0, vma, 0, IF_VEC) +/* VECTOR MULTIPLY AND ADD HIGH */ + F(0xe7ab, VMAH, VRR_d, V, 0, 0, 0, 0, vma, 0, IF_VEC) +/* VECTOR MULTIPLY AND ADD LOGICAL HIGH */ + F(0xe7a9, VMALH, VRR_d, V, 0, 0, 0, 0, vma, 0, IF_VEC) +/* VECTOR MULTIPLY AND ADD EVEN */ + F(0xe7ae, VMAE, VRR_d, V, 0, 0, 0, 0, vma, 0, IF_VEC) +/* VECTOR MULTIPLY AND ADD LOGICAL EVEN */ + F(0xe7ac, VMALE, VRR_d, V, 0, 0, 0, 0, vma, 0, IF_VEC) +/* VECTOR MULTIPLY AND ADD ODD */ + F(0xe7af, VMAO, VRR_d, V, 0, 0, 0, 0, vma, 0, IF_VEC) +/* VECTOR MULTIPLY AND ADD LOGICAL ODD */ + F(0xe7ad, VMALO, VRR_d, V, 0, 0, 0, 0, vma, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +122 -0
125 lines not on this page · raw message
target/s390x/vec_int_helper.c +123 -0
126 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 19/41] s390x/tcg: Implement VECTOR MULTIPLY AND ADD *
Quoted 5 lines · David Hildenbrand
Quite some variants to handle. At least handle some 32-bit element variants via gvec expansion (we could also handle 16/32-bit variants for ODD and EVEN easily via gvec expansion, but let's keep it simple for now).
Quoted 7 lines
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 18 +++++ target/s390x/insn-data.def | 14 ++++ target/s390x/translate_vx.inc.c | 122 +++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 123 ++++++++++++++++++++++++++++++++ 4 files changed, 277 insertions(+)
r~
PATCH 20/41 s390x/tcg: Implement VECTOR MULTIPLY *
In reply to David HildenbrandYet another set of variants. Implement it similar to VECTOR MULTIPLY AND ADD *. At least for one variant we have a gvec helper we can reuse.
--- target/s390x/helper.h | 16 +++++ target/s390x/insn-data.def | 14 +++++ target/s390x/translate_vx.inc.c | 100 ++++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 100 ++++++++++++++++++++++++++++++++ 4 files changed, 230 insertions(+)
target/s390x/helper.h +16 -0
@@ -184,6 +184,22 @@ DEF_HELPER_FLAGS_5(gvec_vmao32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i3 DEF_HELPER_FLAGS_5(gvec_vmalo8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) DEF_HELPER_FLAGS_5(gvec_vmalo16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) DEF_HELPER_FLAGS_5(gvec_vmalo32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vmh8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vmh16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vmlh8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vmlh16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vme8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vme16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vme32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vmle8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vmle16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vmle32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vmo8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vmo16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vmo32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vmlo8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vmlo16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vmlo32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +14 -0
@@ -1120,6 +1120,20 @@ F(0xe7af, VMAO, VRR_d, V, 0, 0, 0, 0, vma, 0, IF_VEC) /* VECTOR MULTIPLY AND ADD LOGICAL ODD */ F(0xe7ad, VMALO, VRR_d, V, 0, 0, 0, 0, vma, 0, IF_VEC) +/* VECTOR MULTIPLY HIGH */ + F(0xe7a3, VMH, VRR_c, V, 0, 0, 0, 0, vm, 0, IF_VEC) +/* VECTOR MULTIPLY LOGICAL HIGH */ + F(0xe7a1, VMLH, VRR_c, V, 0, 0, 0, 0, vm, 0, IF_VEC) +/* VECTOR MULTIPLY LOW */ + F(0xe7a2, VML, VRR_c, V, 0, 0, 0, 0, vm, 0, IF_VEC) +/* VECTOR MULTIPLY EVEN */ + F(0xe7a6, VME, VRR_c, V, 0, 0, 0, 0, vm, 0, IF_VEC) +/* VECTOR MULTIPLY LOGICAL EVEN */ + F(0xe7a4, VMLE, VRR_c, V, 0, 0, 0, 0, vm, 0, IF_VEC) +/* VECTOR MULTIPLY ODD */ + F(0xe7a7, VMO, VRR_c, V, 0, 0, 0, 0, vm, 0, IF_VEC) +/* VECTOR MULTIPLY LOGICAL ODD */ + F(0xe7a5, VMLO, VRR_c, V, 0, 0, 0, 0, vm, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +100 -0
103 lines not on this page · raw message
target/s390x/vec_int_helper.c +100 -0
103 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 20/41] s390x/tcg: Implement VECTOR MULTIPLY *
target/s390x/translate_vx.inc.c static DisasJumpType op_vma(DisasContext *s, DisasOps *o) · line 1701
Quoted 9 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +9
-0+static void gen_mh_i32 (TCGv_i32 d,TCGv_i32 a,TCGv_i32 b) +{ +TCGv_i64 t0 =tcg_temp_new_i64 (); +TCGv_i64 t1 =tcg_temp_new_i64 (); + +tcg_gen_ext_i32_i64 (t0, a); +tcg_gen_ext_i32_i64 (t1, b); +tcg_gen_mul_i64 (t0, t0, t1); +tcg_gen_extrh_i64_i32 (d, t0);
This is
tcg_gen_muls2_i32(tmp, d, a, b);
Similarly for mlh w/ mulu2.
Otherwise,
r~
Re: [Qemu-devel] [PATCH v1 20/41] s390x/tcg: Implement VECTOR MULTIPLY *
Quoted 1 line · Richard Henderson
Reviewed-by Richard Henderson <[email protected]>
Changed, thanks!
Signature · 3 lines
Thanks, David / dhildenb
PATCH 21/41 s390x/tcg: Implement VECTOR NAND
In reply to David HildenbrandPart of vector enhancements facility 1, but easy to implement.
--- target/s390x/insn-data.def | 2 ++ target/s390x/translate.c | 1 + target/s390x/translate_vx.inc.c | 7 +++++++ 3 files changed, 10 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1134,6 +1134,8 @@ F(0xe7a7, VMO, VRR_c, V, 0, 0, 0, 0, vm, 0, IF_VEC) /* VECTOR MULTIPLY LOGICAL ODD */ F(0xe7a5, VMLO, VRR_c, V, 0, 0, 0, 0, vm, 0, IF_VEC) +/* VECTOR NAND */ + F(0xe76e, VNN, VRR_c, VE, 0, 0, 0, 0, vnn, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate.c +1 -0
@@ -6099,6 +6099,7 @@ enum DisasInsnEnum {#define FAC_PCI S390_FEAT_ZPCI/* z/PCI facility */ #define FAC_AIS S390_FEAT_ADAPTER_INT_SUPPRESSION#define FAC_V S390_FEAT_VECTOR/* vector facility */ +#define FAC_VE S390_FEAT_VECTOR_ENH/* vector enhancements facility 1 */ static const DisasInsn insn_info[] = { #include "insn-data.def"
target/s390x/translate_vx.inc.c +7 -0
@@ -1789,3 +1789,10 @@ static DisasJumpType op_vm(DisasContext *s, DisasOps *o) get_field(s->fields, v3), fn);return DISAS_NEXT ; } + +static DisasJumpType op_vnn (DisasContext *s,DisasOps *o) +{ +gen_gvec_fn_3 (nand,ES_8 ,get_field (s->fields, v1), +get_field (s->fields, v2),get_field (s->fields, v3)); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 21/41] s390x/tcg: Implement VECTOR NAND
Quoted 8 lines · David Hildenbrand
Part of vector enhancements facility 1, but easy to implement.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 2 ++ target/s390x/translate.c | 1 + target/s390x/translate_vx.inc.c | 7 +++++++ 3 files changed, 10 insertions(+)
r~
PATCH 22/41 s390x/tcg: Implement VECTOR NOR
In reply to David Hildenbrand--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 7 +++++++ 2 files changed, 9 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1136,6 +1136,8 @@ F(0xe7a5, VMLO, VRR_c, V, 0, 0, 0, 0, vm, 0, IF_VEC) /* VECTOR NAND */ F(0xe76e, VNN, VRR_c, VE, 0, 0, 0, 0, vnn, 0, IF_VEC) +/* VECTOR NOR */ + F(0xe76b, VNO, VRR_c, V, 0, 0, 0, 0, vno, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +7 -0
@@ -1796,3 +1796,10 @@ static DisasJumpType op_vnn(DisasContext *s, DisasOps *o) get_field(s->fields, v2), get_field(s->fields, v3));return DISAS_NEXT ; } + +static DisasJumpType op_vno (DisasContext *s,DisasOps *o) +{ +gen_gvec_fn_3 (nor,ES_8 ,get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3)); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 22/41] s390x/tcg: Implement VECTOR NOR
Quoted 5 lines · David Hildenbrand
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 7 +++++++ 2 files changed, 9 insertions(+)
r~
PATCH 23/41 s390x/tcg: Implement VECTOR NOT EXCLUSIVE OR
In reply to David HildenbrandAgain, part of vector enhancement facility 1. The operation corresponds to an bitwise equality check.
--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 7 +++++++ 2 files changed, 9 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1138,6 +1138,8 @@ F(0xe76e, VNN, VRR_c, VE, 0, 0, 0, 0, vnn, 0, IF_VEC) /* VECTOR NOR */ F(0xe76b, VNO, VRR_c, V, 0, 0, 0, 0, vno, 0, IF_VEC) +/* VECTOR NOT EXCLUSIVE OR */ + F(0xe76c, VNX, VRR_c, VE, 0, 0, 0, 0, vnx, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +7 -0
@@ -1803,3 +1803,10 @@ static DisasJumpType op_vno(DisasContext *s, DisasOps *o) get_field(s->fields, v3));return DISAS_NEXT ; } + +static DisasJumpType op_vnx (DisasContext *s,DisasOps *o) +{ +gen_gvec_fn_3 (eqv,ES_8 ,get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3)); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 23/41] s390x/tcg: Implement VECTOR NOT EXCLUSIVE OR
Quoted 8 lines · David Hildenbrand
Again, part of vector enhancement facility 1. The operation corresponds to an bitwise equality check.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 7 +++++++ 2 files changed, 9 insertions(+)
r~
PATCH 24/41 s390x/tcg: Implement VECTOR OR
In reply to David HildenbrandReuse a gvec helper.
--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 7 +++++++ 2 files changed, 9 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1140,6 +1140,8 @@ F(0xe76b, VNO, VRR_c, V, 0, 0, 0, 0, vno, 0, IF_VEC) /* VECTOR NOT EXCLUSIVE OR */ F(0xe76c, VNX, VRR_c, VE, 0, 0, 0, 0, vnx, 0, IF_VEC) +/* VECTOR OR */ + F(0xe76a, VO, VRR_c, V, 0, 0, 0, 0, vo, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +7 -0
@@ -1810,3 +1810,10 @@ static DisasJumpType op_vnx(DisasContext *s, DisasOps *o) get_field(s->fields, v3));return DISAS_NEXT ; } + +static DisasJumpType op_vo (DisasContext *s,DisasOps *o) +{ +gen_gvec_fn_3 (or,ES_8 ,get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3)); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 24/41] s390x/tcg: Implement VECTOR OR
Quoted 7 lines · David Hildenbrand
Reuse a gvec helper.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 7 +++++++ 2 files changed, 9 insertions(+)
r~
PATCH 25/41 s390x/tcg: Implement VECTOR OR WITH COMPLEMENT
In reply to David HildenbrandAgain, vector enhancements facility 1 material.
--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 7 +++++++ 2 files changed, 9 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1142,6 +1142,8 @@ F(0xe76c, VNX, VRR_c, VE, 0, 0, 0, 0, vnx, 0, IF_VEC) /* VECTOR OR */ F(0xe76a, VO, VRR_c, V, 0, 0, 0, 0, vo, 0, IF_VEC) +/* VECTOR OR WITH COMPLEMENT */ + F(0xe76f, VOC, VRR_c, VE, 0, 0, 0, 0, voc, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +7 -0
@@ -1817,3 +1817,10 @@ static DisasJumpType op_vo(DisasContext *s, DisasOps *o) get_field(s->fields, v3));return DISAS_NEXT ; } + +static DisasJumpType op_voc (DisasContext *s,DisasOps *o) +{ +gen_gvec_fn_3 (orc,ES_8 ,get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3)); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 25/41] s390x/tcg: Implement VECTOR OR WITH COMPLEMENT
Quoted 7 lines · David Hildenbrand
Again, vector enhancements facility 1 material.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 7 +++++++ 2 files changed, 9 insertions(+)
r~
PATCH 26/41 s390x/tcg: Implement VECTOR POPULATION COUNT
In reply to David HildenbrandSimilar to VECTOR COUNT TRAILING ZEROES.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 19 +++++++++++++++++++ target/s390x/vec_int_helper.c | 14 ++++++++++++++ 4 files changed, 37 insertions(+)
target/s390x/helper.h +2 -0
@@ -200,6 +200,8 @@ DEF_HELPER_FLAGS_4(gvec_vmo32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vmlo8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vmlo16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vmlo32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_3(gvec_vpopct8, TCG_CALL_NO_RWG, void, ptr, cptr, i32) +DEF_HELPER_FLAGS_3(gvec_vpopct16, TCG_CALL_NO_RWG, void, ptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1144,6 +1144,8 @@ F(0xe76a, VO, VRR_c, V, 0, 0, 0, 0, vo, 0, IF_VEC) /* VECTOR OR WITH COMPLEMENT */ F(0xe76f, VOC, VRR_c, VE, 0, 0, 0, 0, voc, 0, IF_VEC) +/* VECTOR POPULATION COUNT */ + F(0xe750, VPOPCT, VRR_a, V, 0, 0, 0, 0, vpopct, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +19 -0
@@ -1824,3 +1824,22 @@ static DisasJumpType op_voc(DisasContext *s, DisasOps *o) get_field(s->fields, v3));return DISAS_NEXT ; } + +static DisasJumpType op_vpopct (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m3); +static const GVecGen2 g[4 ] = { + { .fno = gen_helper_gvec_vpopct8, }, + { .fno = gen_helper_gvec_vpopct16, }, + { .fni4 = tcg_gen_ctpop_i32, }, + { .fni8 = tcg_gen_ctpop_i64, }, + }; + +if (es >ES_64 || (es !=ES_8 && !s390_has_feat (S390_FEAT_VECTOR_ENH ))) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +gen_gvec_2 (get_field (s->fields, v1),get_field (s->fields, v2), &g[es]); +return DISAS_NEXT ; +}
target/s390x/vec_int_helper.c +14 -0
@@ -526,3 +526,17 @@ void HELPER(gvec_vmlo##BITS)(void *v1, const void *v2, const void *v3, \ DEF_VMLO(8, 16) DEF_VMLO(16, 32) DEF_VMLO(32, 64) + +#define DEF_VPOPCT (BITS ) \ +void HELPER(gvec_vpopct##BITS)(void *v1, const void *v2, uint32_t desc) \ +{ \ + int i; \ + \ + for (i = 0; i < (128 / BITS); i++) { \ + const uint##BITS##_t a = s390_vec_read_element##BITS(v2, i); \ + \ + s390_vec_write_element##BITS(v1, i, ctpop32(a)); \ + } \ +} +DEF_VPOPCT(8) +DEF_VPOPCT (16 )
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 26/41] s390x/tcg: Implement VECTOR POPULATION COUNT
Quoted 9 lines · David Hildenbrand
Similar to VECTOR COUNT TRAILING ZEROES.
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_int_helper.c | 14 ++++++++++++++ 4 files changed, 37 insertions(+)
r~
PATCH 27/41 s390x/tcg: Implement VECTOR ELEMENT ROTATE LEFT LOGICAL
In reply to David HildenbrandTake care of properly taking the modulo of the count. We might later want to come back and create a variant of VERLL where the base register is 0, resulting in an immediate.
--- target/s390x/helper.h | 4 +++ target/s390x/insn-data.def | 3 ++ target/s390x/translate_vx.inc.c | 60 +++++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 40 ++++++++++++++++++++++ 4 files changed, 107 insertions(+)
target/s390x/helper.h +4 -0
@@ -202,6 +202,10 @@ DEF_HELPER_FLAGS_4(gvec_vmlo16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vmlo32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_3(gvec_vpopct8, TCG_CALL_NO_RWG, void, ptr, cptr, i32) DEF_HELPER_FLAGS_3(gvec_vpopct16, TCG_CALL_NO_RWG, void, ptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_verllv8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_verllv16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_verll8, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_verll16, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +3 -0
@@ -1146,6 +1146,9 @@ F(0xe76f, VOC, VRR_c, VE, 0, 0, 0, 0, voc, 0, IF_VEC) /* VECTOR POPULATION COUNT */ F(0xe750, VPOPCT, VRR_a, V, 0, 0, 0, 0, vpopct, 0, IF_VEC) +/* VECTOR ELEMENT ROTATE LEFT LOGICAL */ + F(0xe773, VERLLV, VRR_c, V, 0, 0, 0, 0, verllv, 0, IF_VEC) + F(0xe733, VERLL, VRS_a, V, la2, 0, 0, 0, verll, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +60 -0
69 lines not on this page · raw message
target/s390x/vec_int_helper.c +40 -0
@@ -540,3 +540,43 @@ void HELPER(gvec_vpopct##BITS)(void *v1, const void *v2, uint32_t desc) \ } DEF_VPOPCT(8) DEF_VPOPCT(16) + +#define DEF_ROTL (BITS ) \ +static uint##BITS##_t rotl##BITS(uint##BITS##_t a, uint8_t count) \ +{ \ + count &= BITS - 1; \ + return (a << count) | (a >> (BITS - count)); \ +} +DEF_ROTL(8) +DEF_ROTL(16) + +#define DEF_VERLLV (BITS ) \ +void HELPER(gvec_verllv##BITS)(void *v1, const void *v2, const void *v3, \ + uint32_t desc) \ +{ \ + int i; \ + \ + for (i = 0; i < (128 / BITS); i++) { \ + const uint##BITS##_t a = s390_vec_read_element##BITS(v2, i); \ + const uint##BITS##_t b = s390_vec_read_element##BITS(v3, i); \ + \ + s390_vec_write_element##BITS(v1, i, rotl##BITS(a, b)); \ + } \ +} +DEF_VERLLV(8) +DEF_VERLLV(16) + +#define DEF_VERLL (BITS ) \ +void HELPER(gvec_verll##BITS)(void *v1, const void *v2, uint64_t count, \ + uint32_t desc) \ +{ \ + int i; \ + \ + for (i = 0; i < (128 / BITS); i++) { \ + const uint##BITS##_t a = s390_vec_read_element##BITS(v2, i); \ + \ + s390_vec_write_element##BITS(v1, i, rotl##BITS(a, count)); \ + } \ +} +DEF_VERLL(8) +DEF_VERLL (16 )
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 27/41] s390x/tcg: Implement VECTOR ELEMENT ROTATE LEFT LOGICAL
target/s390x/vec_int_helper.c void HELPER(gvec_vpopct##BITS)(void *v1, const void *v2, uint32_t desc) \ · line 551
Quoted 8 lines · David Hildenbrand
target/s390x/vec_int_helper.c +8
-0+#define DEF_ROTL (BITS ) \ +static uint##BITS##_t rotl##BITS(uint##BITS##_t a, uint8_t count) \ +{ \ + count &= BITS - 1; \ + return (a << count) | (a >> (BITS - count)); \ +} +DEF_ROTL(8) +DEF_ROTL (16 )
We already have rol8 and rol16 in <qemu/bitops.h> for this. Otherwise,
This does point out that I should go ahead and fill out the variable shift and rotate patterns in gvec...
r~
Re: [Qemu-devel] [PATCH v1 27/41] s390x/tcg: Implement VECTOR ELEMENT ROTATE LEFT LOGICAL
Quoted 13 lines · Richard Henderson
target/s390x/vec_int_helper.c void HELPER(gvec_vpopct##BITS)(void *v1, const void *v2, uint32_t desc) \ · line 551
Quoted 8 lines · David Hildenbrand
target/s390x/vec_int_helper.c +8
-0+#define DEF_ROTL (BITS ) \ +static uint##BITS##_t rotl##BITS(uint##BITS##_t a, uint8_t count) \ +{ \ + count &= BITS - 1; \ + return (a << count) | (a >> (BITS - count)); \ +} +DEF_ROTL(8) +DEF_ROTL (16 )We already have rol8 and rol16 in <
qemu/bitops.h> for this. Otherwise,
Thanks, missed these helpers!
Quoted 8 lines
Reviewed-by Richard Henderson <[email protected]>This does point out that I should go ahead and fill out the variable shift and rotate patterns in gvec...
r~
Signature · 3 lines
Thanks, David / dhildenb
PATCH 28/41 s390x/tcg: Implement VECTOR ELEMENT ROTATE AND INSERT UNDER MASK
In reply to David HildenbrandUse the new vector expansion for GVecGen3i. In the ool helpers, reuse the rotation funvtions introduced with VECTOR ELEMENT ROTATE LEFT LOGICAL.
--- target/s390x/helper.h | 2 ++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 53 +++++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 19 ++++++++++++ 4 files changed, 76 insertions(+)
target/s390x/helper.h +2 -0
@@ -206,6 +206,8 @@ DEF_HELPER_FLAGS_4(gvec_verllv8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_verllv16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_verll8, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_verll16, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_verim8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_verim16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1149,6 +1149,8 @@ /* VECTOR ELEMENT ROTATE LEFT LOGICAL */ F(0xe773, VERLLV, VRR_c, V, 0, 0, 0, 0, verllv, 0, IF_VEC) F(0xe733, VERLL, VRS_a, V, la2, 0, 0, 0, verll, 0, IF_VEC) +/* VECTOR ELEMENT ROTATE AND INSERT UNDER MASK */ + F(0xe772, VERIM, VRI_d, V, 0, 0, 0, 0, verim, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +53 -0
62 lines not on this page · raw message
target/s390x/vec_int_helper.c +19 -0
@@ -14,6 +14,7 @@#include "cpu.h" #include "vec.h" #include "exec/helper-proto.h" +#include "tcg/tcg-gvec-desc.h" /* * Add two 128 bit vectors, returning the carry.
@@ -580,3 +581,21 @@ void HELPER(gvec_verll##BITS)(void *v1, const void *v2, uint64_t count, \ } DEF_VERLL(8) DEF_VERLL(16) + +#define DEF_VERIM (BITS ) \ +void HELPER(gvec_verim##BITS)(void *v1, const void *v2, const void *v3, \ + uint32_t desc) \ +{ \ + const uint8_t count = simd_data(desc); \ + int i; \ + \ + for (i = 0; i < (128 / BITS); i++) { \ + const uint##BITS##_t a = s390_vec_read_element##BITS(v2, i); \ + const uint##BITS##_t mask = s390_vec_read_element##BITS(v3, i); \ + const uint##BITS##_t d = (a & ~mask) | (rotl##BITS(a, count) & mask); \ + \ + s390_vec_write_element##BITS(v1, i, d); \ + } \ +} +DEF_VERIM(8) +DEF_VERIM (16 )
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 28/41] s390x/tcg: Implement VECTOR ELEMENT ROTATE AND INSERT UNDER MASK
target/s390x/translate_vx.inc.c static DisasJumpType op_verll(DisasContext *s, DisasOps *o) · line 1918
Quoted 9 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +9
-0+static void gen_rim_i32 (TCGv_i32 d,TCGv_i32 a,TCGv_i32 b,int32_t c) +{ +TCGv_i32 t0 =tcg_temp_new_i32 (); +TCGv_i32 t1 =tcg_temp_new_i32 (); + +tcg_gen_andc_i32 (t0, a, b); +tcg_gen_rotli_i32 (t1, a, c &31 ); +tcg_gen_and_i32 (t1, t1, b); +tcg_gen_or_i32 (d, t0, t1);
The ANDC and ROTL look to be in the wrong order.
"For each bit in the third operand (b) that is one, the corresponding bit *of the rotated elements* in the second operand replaces the corresponding bit in the first operand".
I think you need
tcg_gen_rotli_i32(a, a, c & 31);
tcg_gen_and_i32(a, a, b);
tcg_gen_andc_i32(d, d, b);
tcg_gen_or_i32(d, d, a);with
{ .fni4 = gen_rim_32, .load_dest = true },
target/s390x/vec_int_helper.c void HELPER(gvec_verll##BITS)(void *v1, const void *v2, uint64_t count, \ · line 595
Quoted 3 lines
target/s390x/vec_int_helper.c +3
-0+ const uint##BITS##_t a = s390_vec_read_element##BITS(v2, i); \ + const uint##BITS##_t mask = s390_vec_read_element##BITS(v3, i); \ + const uint##BITS##_t d = (a & ~mask) | (rotl##BITS(a, count) & mask); \
Again, this seems to be missing the insert into "the first operand", i.e. loading from v1 as well.
r~
Re: [Qemu-devel] [PATCH v1 28/41] s390x/tcg: Implement VECTOR ELEMENT ROTATE AND INSERT UNDER MASK
Quoted 27 lines · Richard Henderson
target/s390x/translate_vx.inc.c static DisasJumpType op_verll(DisasContext *s, DisasOps *o) · line 1918
Quoted 9 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +9
-0+static void gen_rim_i32 (TCGv_i32 d,TCGv_i32 a,TCGv_i32 b,int32_t c) +{ +TCGv_i32 t0 =tcg_temp_new_i32 (); +TCGv_i32 t1 =tcg_temp_new_i32 (); + +tcg_gen_andc_i32 (t0, a, b); +tcg_gen_rotli_i32 (t1, a, c &31 ); +tcg_gen_and_i32 (t1, t1, b); +tcg_gen_or_i32 (d, t0, t1);The ANDC and ROTL look to be in the wrong order.
"For each bit in the third operand (b) that is one, the corresponding bit *of the rotated elements* in the second operand replaces the corresponding bit in the first operand".
I think you need
tcg_gen_rotli_i32(a, a, c & 31); tcg_gen_and_i32(a, a, b); tcg_gen_andc_i32(d, d, b); tcg_gen_or_i32(d, d, a);with
Quoted 8 lines
{ .fni4 =
gen_rim_32, .load_dest = true },target/s390x/vec_int_helper.c void HELPER(gvec_verll##BITS)(void *v1, const void *v2, uint64_t count, \ · line 595
Quoted 3 lines
target/s390x/vec_int_helper.c +3
-0+ const uint##BITS##_t a = s390_vec_read_element##BITS(v2, i); \ + const uint##BITS##_t mask = s390_vec_read_element##BITS(v3, i); \ + const uint##BITS##_t d = (a & ~mask) | (rotl##BITS(a, count) & mask); \Again, this seems to be missing the insert into "the first operand", i.e. loading from v1 as well.
Yes indeed, I misinterpreted/misread the PoP. Nice catch! (as usual, excellent review)
Quoted 4 lines
r~
Signature · 3 lines
Thanks, David / dhildenb
PATCH 29/41 s390x/tcg: Implement VECTOR ELEMENT SHIFT
In reply to David HildenbrandOnly for one special case we can reuse real gvec helpers. Mostly rely on oom helpers.
One important thing to take care of is always to properly mask of unused bits from the shift count.
--- target/s390x/helper.h | 18 +++++ target/s390x/insn-data.def | 9 +++ target/s390x/translate_vx.inc.c | 113 ++++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 99 ++++++++++++++++++++++++++++ 4 files changed, 239 insertions(+)
target/s390x/helper.h +18 -0
@@ -208,6 +208,24 @@ DEF_HELPER_FLAGS_4(gvec_verll8, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_verll16, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_verim8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_verim16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_veslv8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_veslv16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_veslv32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_veslv64, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vesrav8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vesrav16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vesrav32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vesrav64, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vesrlv8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vesrlv16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vesrlv32, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vesrlv64, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vesl8, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_vesl16, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_vesra8, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_vesra16, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_vesrl8, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_vesrl16, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +9 -0
@@ -1151,6 +1151,15 @@ F(0xe733, VERLL, VRS_a, V, la2, 0, 0, 0, verll, 0, IF_VEC) /* VECTOR ELEMENT ROTATE AND INSERT UNDER MASK */ F(0xe772, VERIM, VRI_d, V, 0, 0, 0, 0, verim, 0, IF_VEC) +/* VECTOR ELEMENT SHIFT LEFT */ + F(0xe770, VESLV, VRR_c, V, 0, 0, 0, 0, vesv, 0, IF_VEC) + F(0xe730, VESL, VRS_a, V, la2, 0, 0, 0, ves, 0, IF_VEC) +/* VECTOR ELEMENT SHIFT RIGHT ARITHMETIC */ + F(0xe77a, VESRAV, VRR_c, V, 0, 0, 0, 0, vesv, 0, IF_VEC) + F(0xe73a, VESRA, VRS_a, V, la2, 0, 0, 0, ves, 0, IF_VEC) +/* VECTOR ELEMENT SHIFT RIGHT LOGICAL */ + F(0xe778, VESRLV, VRR_c, V, 0, 0, 0, 0, vesv, 0, IF_VEC) + F(0xe738, VESRL, VRS_a, V, la2, 0, 0, 0, ves, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +113 -0
122 lines not on this page · raw message
target/s390x/vec_int_helper.c +99 -0
102 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 29/41] s390x/tcg: Implement VECTOR ELEMENT SHIFT
Quoted 6 lines · David Hildenbrand
Only for one special case we can reuse real gvec helpers. Mostly rely on oom helpers.
One important thing to take care of is always to properly mask of unused bits from the shift count.
Quoted 7 lines
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 18 +++++ target/s390x/insn-data.def | 9 +++ target/s390x/translate_vx.inc.c | 113 ++++++++++++++++++++++++++++++++ target/s390x/vec_int_helper.c | 99 ++++++++++++++++++++++++++++ 4 files changed, 239 insertions(+)
Again, I should fill out these in gvec...
r~
PATCH 30/41 s390x/tcg: Implement VECTOR SHIFT LEFT (BY BYTE)
In reply to David HildenbrandWe can reuse the existing 128-bit shift utility function.
--- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 4 ++++ target/s390x/translate_vx.inc.c | 20 ++++++++++++++++++++ target/s390x/vec_int_helper.c | 6 ++++++ 4 files changed, 31 insertions(+)
target/s390x/helper.h +1 -0
@@ -226,6 +226,7 @@ DEF_HELPER_FLAGS_4(gvec_vesra8, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vesra16, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vesrl8, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vesrl16, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_vsl, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +4 -0
@@ -1160,6 +1160,10 @@ /* VECTOR ELEMENT SHIFT RIGHT LOGICAL */ F(0xe778, VESRLV, VRR_c, V, 0, 0, 0, 0, vesv, 0, IF_VEC) F(0xe738, VESRL, VRS_a, V, la2, 0, 0, 0, ves, 0, IF_VEC) +/* VECTOR SHIFT LEFT */ + F(0xe774, VSL, VRR_c, V, 0, 0, 0, 0, vsl, 0, IF_VEC) +/* VECTOR SHIFT LEFT BY BYTE */ + F(0xe775, VSLB, VRR_c, V, 0, 0, 0, 0, vsl, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +20 -0
@@ -188,6 +188,9 @@ static void get_vec_element_ptr_i64(TCGv_ptr ptr, uint8_t reg, TCGv_i64 enr,#define gen_gvec_2s (v1, v2, c, gen) \ tcg_gen_gvec_2s(vec_full_reg_offset(v1), vec_full_reg_offset(v2), \ 16, 16, c, gen) +#define gen_gvec_2i_ool (v1, v2, c, data, fn) \ + tcg_gen_gvec_2i_ool(vec_full_reg_offset(v1), vec_full_reg_offset(v2), \ + c, 16, 16, data, fn)#define gen_gvec_3 (v1, v2, v3, gen) \ tcg_gen_gvec_3(vec_full_reg_offset(v1), vec_full_reg_offset(v2), \ vec_full_reg_offset(v3), 16, 16, gen)
@@ -2069,3 +2072,20 @@ static DisasJumpType op_ves(DisasContext *s, DisasOps *o)gen_gvec_2s (v1, v3, o->addr1, fn);return DISAS_NEXT ; } + +static DisasJumpType op_vsl (DisasContext *s,DisasOps *o) +{ +TCGv_i64 shift =tcg_temp_new_i64 (); + +read_vec_element_i64 (shift,get_field (s->fields, v3),7 ,ES_8 ); +if (s->fields->op2 ==0x74 ) { +tcg_gen_andi_i64 (shift, shift,0x7 ); + }else { +tcg_gen_andi_i64 (shift, shift,0x78 ); + } + +gen_gvec_2i_ool (get_field (s->fields, v1),get_field (s->fields, v2), + shift,0 , gen_helper_gvec_vsl); +tcg_temp_free_i64 (shift); +return DISAS_NEXT ; +}
target/s390x/vec_int_helper.c +6 -0
@@ -698,3 +698,9 @@ void HELPER(gvec_vesrl##BITS)(void *v1, const void *v3, uint64_t shift, \ } DEF_VESRL(8) DEF_VESRL(16) + +void HELPER (gvec_vsl )(void *v1,const void *v2,uint64_t count, +uint32_t desc) +{ +s390_vec_shl (v1, v2, count); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 30/41] s390x/tcg: Implement VECTOR SHIFT LEFT (BY BYTE)
Quoted 9 lines · David Hildenbrand
We can reuse the existing 128-bit shift utility function.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 4 ++++ target/s390x/translate_vx.inc.c | 20 ++++++++++++++++++++ target/s390x/vec_int_helper.c | 6 ++++++ 4 files changed, 31 insertions(+)
r~
PATCH 31/41 s390x/tcg: Implement VECTOR SHIFT LEFT DOUBLE BY BYTE
In reply to David HildenbrandImplement it via an ool helper. reusing the existing shift helpers. In case the starting index is 0, it is basically a copy of v2 to v1.
--- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 15 +++++++++++++++ target/s390x/vec_int_helper.c | 20 ++++++++++++++++++++ 4 files changed, 38 insertions(+)
target/s390x/helper.h +1 -0
@@ -227,6 +227,7 @@ DEF_HELPER_FLAGS_4(gvec_vesra16, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vesrl8, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vesrl16, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vsl, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_vsldb, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1164,6 +1164,8 @@ F(0xe774, VSL, VRR_c, V, 0, 0, 0, 0, vsl, 0, IF_VEC) /* VECTOR SHIFT LEFT BY BYTE */ F(0xe775, VSLB, VRR_c, V, 0, 0, 0, 0, vsl, 0, IF_VEC) +/* VECTOR SHIFT LEFT DOUBLE BY BYTE */ + F(0xe777, VSLDB, VRI_d, V, 0, 0, 0, 0, vsldb, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +15 -0
@@ -2089,3 +2089,18 @@ static DisasJumpType op_vsl(DisasContext *s, DisasOps *o)tcg_temp_free_i64 (shift);return DISAS_NEXT ; } + +static DisasJumpType op_vsldb (DisasContext *s,DisasOps *o) +{ +int src_idx =get_field (s->fields, i4) &0xf ; + +if (src_idx ==0 ) { +gen_gvec_mov (get_field (s->fields, v1),get_field (s->fields, v2)); + }else { +gen_gvec_3_ool (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3), src_idx, + gen_helper_gvec_vsldb); +return DISAS_NEXT ; + } +return DISAS_NEXT ; +}
target/s390x/vec_int_helper.c +20 -0
@@ -43,6 +43,13 @@ static bool s390_vec_is_zero(const S390Vector *v)return !v->doubleword[0 ] && !v->doubleword[1 ]; } +static void s390_vec_or (S390Vector *res,const S390Vector *a, +const S390Vector *b) +{ + res->doubleword[0 ] = a->doubleword[0 ] | b->doubleword[0 ]; + res->doubleword[1 ] = a->doubleword[1 ] | b->doubleword[1 ]; +} +static void s390_vec_xor (S390Vector *res,const S390Vector *a,const S390Vector *b) {
@@ -704,3 +711,16 @@ void HELPER(gvec_vsl)(void *v1, const void *v2, uint64_t count, {s390_vec_shl (v1, v2, count); } + +void HELPER (gvec_vsldb )(void *v1,const void *v2,const void *v3, +uint32_t desc) +{ +const uint8_t src_idx =simd_data (desc); +S390Vector t0; +S390Vector t1; + +g_assert (src_idx >0 && src_idx <16 ); +s390_vec_shl (&t0, v2, src_idx *8 ); +s390_vec_shr (&t1, v3,128 - src_idx *8 ); +s390_vec_or (v1, &t0, &t1); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 31/41] s390x/tcg: Implement VECTOR SHIFT LEFT DOUBLE BY BYTE
target/s390x/translate_vx.inc.c static DisasJumpType op_vsl(DisasContext *s, DisasOps *o) · line 2103
Quoted 11 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +11
-0+static DisasJumpType op_vsldb (DisasContext *s,DisasOps *o) +{ +int src_idx =get_field (s->fields, i4) &0xf ; + +if (src_idx ==0 ) { +gen_gvec_mov (get_field (s->fields, v1),get_field (s->fields, v2)); + }else { +gen_gvec_3_ool (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3), src_idx, + gen_helper_gvec_vsldb); +return DISAS_NEXT ;
You could also expand this inline using your new extract2 primitive.
int i4 = get_field(s->fields, i4);
int left_shift, right_shift;
left_shift = (i4 & 7) * 8;
right_shift = 64 - left_shift;
if ((i4 & 8) == 0) {
read_vec_element_i64(t0, get_field(s->fields, v2), 0, ES_64);
read_vec_element_i64(t1, get_field(s->fields, v2), 1, ES_64);
read_vec_element_i64(t2, get_field(s->fields, v3), 0, ES_64);
} else {
read_vec_element_i64(t0, get_field(s->fields, v2), 1, ES_64);
read_vec_element_i64(t1, get_field(s->fields, v3), 0, ES_64);
read_vec_element_i64(t2, get_field(s->fields, v3), 1, ES_64);
}
tcg_gen_extract2_i64(t0, t1, t0, right_shift);
tcg_gen_extract2_i64(t1, t2, t1, right_shift);
write_vec_element_i64(t0, get_field(s->fields, v1), 0, ES_64);
write_vec_element_i64(t1, get_field(s->fields, v1), 1, ES_64);r~
Re: [Qemu-devel] [PATCH v1 31/41] s390x/tcg: Implement VECTOR SHIFT LEFT DOUBLE BY BYTE
Quoted 24 lines · Richard Henderson
target/s390x/translate_vx.inc.c static DisasJumpType op_vsl(DisasContext *s, DisasOps *o) · line 2103
Quoted 11 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +11
-0+static DisasJumpType op_vsldb (DisasContext *s,DisasOps *o) +{ +int src_idx =get_field (s->fields, i4) &0xf ; + +if (src_idx ==0 ) { +gen_gvec_mov (get_field (s->fields, v1),get_field (s->fields, v2)); + }else { +gen_gvec_3_ool (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3), src_idx, + gen_helper_gvec_vsldb); +return DISAS_NEXT ;You could also expand this inline using your new extract2 primitive.
int i4 = get_field(s->fields, i4); int left_shift, right_shift; left_shift = (i4 & 7) * 8; right_shift = 64 - left_shift; if ((i4 & 8) == 0) { read_vec_element_i64(t0, get_field(s->fields, v2), 0, ES_64); read_vec_element_i64(t1, get_field(s->fields, v2), 1, ES_64);
Quoted 8 lines
read_vec_element_i64(t2, get_field(s->fields, v3), 0, ES_64);
} else {
read_vec_element_i64(t0, get_field(s->fields, v2), 1, ES_64);
read_vec_element_i64(t1, get_field(s->fields, v3), 0, ES_64);
read_vec_element_i64(t2, get_field(s->fields, v3), 1, ES_64);
}
tcg_gen_extract2_i64(t0, t1, t0, right_shift);
tcg_gen_extract2_i64(t1, t2, t1, right_shift);Trying to understand the magic, left_shift is really only used to to calculate right_shift, right?
Quoted 6 lines
write_vec_element_i64(t0, get_field(s->fields, v1), 0, ES_64); write_vec_element_i64(t1, get_field(s->fields, v1), 1, ES_64);r~
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v1 31/41] s390x/tcg: Implement VECTOR SHIFT LEFT DOUBLE BY BYTE
Quoted 34 lines · David Hildenbrand
Quoted 24 lines · Richard Henderson
target/s390x/translate_vx.inc.c static DisasJumpType op_vsl(DisasContext *s, DisasOps *o) · line 2103
Quoted 11 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +11
-0+static DisasJumpType op_vsldb (DisasContext *s,DisasOps *o) +{ +int src_idx =get_field (s->fields, i4) &0xf ; + +if (src_idx ==0 ) { +gen_gvec_mov (get_field (s->fields, v1),get_field (s->fields, v2)); + }else { +gen_gvec_3_ool (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3), src_idx, + gen_helper_gvec_vsldb); +return DISAS_NEXT ;You could also expand this inline using your new extract2 primitive.
int i4 = get_field(s->fields, i4); int left_shift, right_shift; left_shift = (i4 & 7) * 8; right_shift = 64 - left_shift; if ((i4 & 8) == 0) { read_vec_element_i64(t0, get_field(s->fields, v2), 0, ES_64); read_vec_element_i64(t1, get_field(s->fields, v2), 1, ES_64);Quoted 8 lines
read_vec_element_i64(t2, get_field(s->fields, v3), 0, ES_64); } else { read_vec_element_i64(t0, get_field(s->fields, v2), 1, ES_64); read_vec_element_i64(t1, get_field(s->fields, v3), 0, ES_64); read_vec_element_i64(t2, get_field(s->fields, v3), 1, ES_64); } tcg_gen_extract2_i64(t0, t1, t0, right_shift); tcg_gen_extract2_i64(t1, t2, t1, right_shift);
Quoted 2 lines
Trying to understand the magic,
left_shiftis really only used to to calculateright_shift, right?
Yes. I thought that was clearer as a separate step.
r~
PATCH 32/41 s390x/tcg: Implement VECTOR SHIFT RIGHT ARITHMETIC
In reply to David HildenbrandSimilar to VECTOR SHIFT LEFT ARITHMETIC. Add s390_vec_sar() similar to s390_vec_shr().
--- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 4 ++++ target/s390x/translate_vx.inc.c | 17 +++++++++++++++++ target/s390x/vec_int_helper.c | 26 ++++++++++++++++++++++++++ 4 files changed, 48 insertions(+)
target/s390x/helper.h +1 -0
@@ -228,6 +228,7 @@ DEF_HELPER_FLAGS_4(gvec_vesrl8, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vesrl16, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vsl, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vsldb, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vsra, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +4 -0
@@ -1166,6 +1166,10 @@ F(0xe775, VSLB, VRR_c, V, 0, 0, 0, 0, vsl, 0, IF_VEC) /* VECTOR SHIFT LEFT DOUBLE BY BYTE */ F(0xe777, VSLDB, VRI_d, V, 0, 0, 0, 0, vsldb, 0, IF_VEC) +/* VECTOR SHIFT RIGHT ARITHMETIC */ + F(0xe77e, VSRA, VRR_c, V, 0, 0, 0, 0, vsra, 0, IF_VEC) +/* VECTOR SHIFT RIGHT ARITHMETIC BY BYTE */ + F(0xe77f, VSRAB, VRR_c, V, 0, 0, 0, 0, vsra, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +17 -0
@@ -2104,3 +2104,20 @@ static DisasJumpType op_vsldb(DisasContext *s, DisasOps *o) }return DISAS_NEXT ; } + +static DisasJumpType op_vsra (DisasContext *s,DisasOps *o) +{ +TCGv_i64 shift =tcg_temp_new_i64 (); + +read_vec_element_i64 (shift,get_field (s->fields, v3),7 ,ES_8 ); +if (s->fields->op2 ==0x7e ) { +tcg_gen_andi_i64 (shift, shift,0x7 ); + }else { +tcg_gen_andi_i64 (shift, shift,0x78 ); + } + +gen_gvec_2i_ool (get_field (s->fields, v1),get_field (s->fields, v2), + shift,0 , gen_helper_gvec_vsra); +tcg_temp_free_i64 (shift); +return DISAS_NEXT ; +}
target/s390x/vec_int_helper.c +26 -0
@@ -78,6 +78,26 @@ static void s390_vec_shl(S390Vector *d, const S390Vector *a, uint64_t count) } } +static void s390_vec_sar (S390Vector *d,const S390Vector *a,uint64_t count) +{ +uint64_t tmp; + +if (count ==0 ) { + d->doubleword[0 ] = a->doubleword[0 ]; + d->doubleword[1 ] = a->doubleword[1 ]; + }else if (count ==64 ) { + d->doubleword[1 ] = a->doubleword[0 ]; + d->doubleword[0 ] =0 ; + }else if (count <64 ) { + tmp = a->doubleword[1 ] >> count; + d->doubleword[1 ] =deposit64 (tmp,64 - count, count, a->doubleword[0 ]); + d->doubleword[0 ] = (int64_t )a->doubleword[0 ] >> count; + }else { + d->doubleword[1 ] = (int64_t )a->doubleword[0 ] >> (count -64 ); + d->doubleword[0 ] =0 ; + } +} +static void s390_vec_shr (S390Vector *d,const S390Vector *a,uint64_t count) {uint64_t tmp;
@@ -724,3 +744,9 @@ void HELPER(gvec_vsldb)(void *v1, const void *v2, const void *v3,s390_vec_shr (&t1, v3,128 - src_idx *8 );s390_vec_or (v1, &t0, &t1); } + +void HELPER (gvec_vsra )(void *v1,const void *v2,uint64_t count, +uint32_t desc) +{ +s390_vec_sar (v1, v2, count); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 32/41] s390x/tcg: Implement VECTOR SHIFT RIGHT ARITHMETIC
Quoted 10 lines · David Hildenbrand
Similar to VECTOR SHIFT LEFT ARITHMETIC. Add
s390_vec_sar()similar tos390_vec_shr().Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 4 ++++ target/s390x/translate_vx.inc.c | 17 +++++++++++++++++ target/s390x/vec_int_helper.c | 26 ++++++++++++++++++++++++++ 4 files changed, 48 insertions(+)
r~
PATCH 33/41 s390x/tcg: Implement VECTOR SHIFT RIGHT LOGICAL *
In reply to David HildenbrandSimilar to VECTOR SHIFT RIGHT ARITHMETICAL.
--- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 4 ++++ target/s390x/translate_vx.inc.c | 17 +++++++++++++++++ target/s390x/vec_int_helper.c | 6 ++++++ 4 files changed, 28 insertions(+)
target/s390x/helper.h +1 -0
@@ -229,6 +229,7 @@ DEF_HELPER_FLAGS_4(gvec_vesrl16, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vsl, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vsldb, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vsra, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_vsrl, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +4 -0
@@ -1170,6 +1170,10 @@ F(0xe77e, VSRA, VRR_c, V, 0, 0, 0, 0, vsra, 0, IF_VEC) /* VECTOR SHIFT RIGHT ARITHMETIC BY BYTE */ F(0xe77f, VSRAB, VRR_c, V, 0, 0, 0, 0, vsra, 0, IF_VEC) +/* VECTOR SHIFT RIGHT LOGICAL */ + F(0xe77c, VSRL, VRR_c, V, 0, 0, 0, 0, vsrl, 0, IF_VEC) +/* VECTOR SHIFT RIGHT LOGICAL BY BYTE */ + F(0xe77d, VSRLB, VRR_c, V, 0, 0, 0, 0, vsrl, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +17 -0
@@ -2121,3 +2121,20 @@ static DisasJumpType op_vsra(DisasContext *s, DisasOps *o)tcg_temp_free_i64 (shift);return DISAS_NEXT ; } + +static DisasJumpType op_vsrl (DisasContext *s,DisasOps *o) +{ +TCGv_i64 shift =tcg_temp_new_i64 (); + +read_vec_element_i64 (shift,get_field (s->fields, v3),7 ,ES_8 ); +if (s->fields->op2 ==0x7c ) { +tcg_gen_andi_i64 (shift, shift,0x7 ); + }else { +tcg_gen_andi_i64 (shift, shift,0x78 ); + } + +gen_gvec_2i_ool (get_field (s->fields, v1),get_field (s->fields, v2), + shift,0 , gen_helper_gvec_vsrl); +tcg_temp_free_i64 (shift); +return DISAS_NEXT ; +}
target/s390x/vec_int_helper.c +6 -0
@@ -750,3 +750,9 @@ void HELPER(gvec_vsra)(void *v1, const void *v2, uint64_t count, {s390_vec_sar (v1, v2, count); } + +void HELPER (gvec_vsrl )(void *v1,const void *v2,uint64_t count, +uint32_t desc) +{ +s390_vec_shr (v1, v2, count); +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 33/41] s390x/tcg: Implement VECTOR SHIFT RIGHT LOGICAL *
Quoted 9 lines · David Hildenbrand
Similar to VECTOR SHIFT RIGHT ARITHMETICAL.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 4 ++++ target/s390x/translate_vx.inc.c | 17 +++++++++++++++++ target/s390x/vec_int_helper.c | 6 ++++++ 4 files changed, 28 insertions(+)
r~
PATCH 34/41 s390x/tcg: Implement VECTOR SUBTRACT
In reply to David HildenbrandWe can use tcg_gen_sub2_i64() to do 128-bit subtraction and otherwise existing gvec helpers.
--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1174,6 +1174,8 @@ F(0xe77c, VSRL, VRR_c, V, 0, 0, 0, 0, vsrl, 0, IF_VEC) /* VECTOR SHIFT RIGHT LOGICAL BY BYTE */ F(0xe77d, VSRLB, VRR_c, V, 0, 0, 0, 0, vsrl, 0, IF_VEC) +/* VECTOR SUBTRACT */ + F(0xe7f7, VS, VRR_c, V, 0, 0, 0, 0, vs, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +17 -0
@@ -2138,3 +2138,20 @@ static DisasJumpType op_vsrl(DisasContext *s, DisasOps *o)tcg_temp_free_i64 (shift);return DISAS_NEXT ; } + +static DisasJumpType op_vs (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m4); + +if (es >ES_128 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + }else if (es ==ES_128 ) { +gen_gvec128_3_i64 (tcg_gen_sub2_i64,get_field (s->fields, v1), +get_field (s->fields, v2),get_field (s->fields, v3)); +return DISAS_NEXT ; + } +gen_gvec_fn_3 (sub, es,get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3)); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 34/41] s390x/tcg: Implement VECTOR SUBTRACT
Quoted 8 lines · David Hildenbrand
We can use
tcg_gen_sub2_i64()to do 128-bit subtraction and otherwise existing gvec helpers.Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+)
r~
PATCH 35/41 s390x/tcg: Implement VECTOR SUBTRACT COMPUTE BORROW INDICATION
In reply to David HildenbrandLet's keep it simple for now and handle 8/16/128 bit elements via helpers. Especially for 8/16, we could come up with some bit tricks.
--- target/s390x/helper.h | 3 +++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 30 +++++++++++++++++++++ target/s390x/vec_int_helper.c | 47 +++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+)
target/s390x/helper.h +3 -0
@@ -230,6 +230,9 @@ DEF_HELPER_FLAGS_4(gvec_vsl, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vsldb, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vsra, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vsrl, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) +DEF_HELPER_FLAGS_4(gvec_vscbi8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vscbi16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_4(gvec_vscbi128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1176,6 +1176,8 @@ F(0xe77d, VSRLB, VRR_c, V, 0, 0, 0, 0, vsrl, 0, IF_VEC) /* VECTOR SUBTRACT */ F(0xe7f7, VS, VRR_c, V, 0, 0, 0, 0, vs, 0, IF_VEC) +/* VECTOR SUBTRACT COMPUTE BORROW INDICATION */ + F(0xe7f5, VSCBI, VRR_c, V, 0, 0, 0, 0, vscbi, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +30 -0
@@ -2155,3 +2155,33 @@ static DisasJumpType op_vs(DisasContext *s, DisasOps *o) get_field(s->fields, v3));return DISAS_NEXT ; } + +static void gen_scbi_i32 (TCGv_i32 d,TCGv_i32 a,TCGv_i32 b) +{ +tcg_gen_setcond_i32 (TCG_COND_LTU , d, a, b); +} + +static void gen_scbi_i64 (TCGv_i64 d,TCGv_i64 a,TCGv_i64 b) +{ +tcg_gen_setcond_i64 (TCG_COND_LTU , d, a, b); +} + +static DisasJumpType op_vscbi (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m4); +static const GVecGen3 g[5 ] = { + { .fno = gen_helper_gvec_vscbi8, }, + { .fno = gen_helper_gvec_vscbi16, }, + { .fni4 = gen_scbi_i32, }, + { .fni8 = gen_scbi_i64, }, + { .fno = gen_helper_gvec_vscbi128, }, + }; + +if (es >ES_128 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } +gen_gvec_3 (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3), &g[es]); +return DISAS_NEXT ; +}
target/s390x/vec_int_helper.c +47 -0
56 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 35/41] s390x/tcg: Implement VECTOR SUBTRACT COMPUTE BORROW INDICATION
Quoted 10 lines · David Hildenbrand
Let's keep it simple for now and handle 8/16/128 bit elements via helpers. Especially for 8/16, we could come up with some bit tricks.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/helper.h | 3 +++ target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 30 +++++++++++++++++++++ target/s390x/vec_int_helper.c | 47 +++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+)
Similar comments to add carry, really,
but what you have is not wrong.
r~
PATCH 36/41 s390x/tcg: Implement VECTOR SUBTRACT WITH BORROW INDICATION
In reply to David HildenbrandFairly easy as only 128-bit handling is required. Simply perform the subtraction and then subtract the borrow.
--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1178,6 +1178,8 @@ F(0xe7f7, VS, VRR_c, V, 0, 0, 0, 0, vs, 0, IF_VEC) /* VECTOR SUBTRACT COMPUTE BORROW INDICATION */ F(0xe7f5, VSCBI, VRR_c, V, 0, 0, 0, 0, vscbi, 0, IF_VEC) +/* VECTOR SUBTRACT WITH BORROW INDICATION */ + F(0xe7bf, VSBI, VRR_d, V, 0, 0, 0, 0, vsbi, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +27 -0
@@ -2185,3 +2185,30 @@ static DisasJumpType op_vscbi(DisasContext *s, DisasOps *o) get_field(s->fields, v3), &g[es]);return DISAS_NEXT ; } + +static void gen_sbi2_i64 (TCGv_i64 dl,TCGv_i64 dh,TCGv_i64 al,TCGv_i64 ah, +TCGv_i64 bl,TCGv_i64 bh,TCGv_i64 cl,TCGv_i64 ch) +{ +TCGv_i64 tl =tcg_temp_new_i64 (); +TCGv_i64 th =tcg_const_i64 (0 ); + +/* extract the borrow only */ +tcg_gen_extract_i64 (tl, cl,0 ,1 ); +tcg_gen_sub2_i64 (dl, dh, al, ah, bl, bh); +tcg_gen_sub2_i64 (dl, dh, dl, dh, tl, th); +tcg_temp_free_i64 (tl); +tcg_temp_free_i64 (th); +} + +static DisasJumpType op_vsbi (DisasContext *s,DisasOps *o) +{ +if (get_field (s->fields, m5) !=ES_128 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +gen_gvec128_4_i64 (gen_sbi2_i64,get_field (s->fields, v1), +get_field (s->fields, v2),get_field (s->fields, v3), +get_field (s->fields, v4)); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 36/41] s390x/tcg: Implement VECTOR SUBTRACT WITH BORROW INDICATION
Quoted 8 lines · David Hildenbrand
Fairly easy as only 128-bit handling is required. Simply perform the subtraction and then subtract the borrow.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
r~
PATCH 37/41 s390x/tcg: Implement VECTOR SUBTRACT WITH BORROW COMPUTE BORROW INDICATION
In reply to David HildenbrandReuse s390_vec_sub() to perform two 128-bit subtraction, calculating the borrow.
--- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 13 +++++++++++++ target/s390x/vec_int_helper.c | 16 ++++++++++++++++ 4 files changed, 32 insertions(+)
target/s390x/helper.h +1 -0
@@ -233,6 +233,7 @@ DEF_HELPER_FLAGS_4(gvec_vsrl, TCG_CALL_NO_RWG, void, ptr, cptr, i64, i32) DEF_HELPER_FLAGS_4(gvec_vscbi8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vscbi16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vscbi128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) +DEF_HELPER_FLAGS_5(gvec_vsbcbi128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1180,6 +1180,8 @@ F(0xe7f5, VSCBI, VRR_c, V, 0, 0, 0, 0, vscbi, 0, IF_VEC) /* VECTOR SUBTRACT WITH BORROW INDICATION */ F(0xe7bf, VSBI, VRR_d, V, 0, 0, 0, 0, vsbi, 0, IF_VEC) +/* VECTOR SUBTRACT WITH BORROW COMPUTE BORROW INDICATION */ + F(0xe7bd, VSBCBI, VRR_d, V, 0, 0, 0, 0, vsbcbi, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +13 -0
@@ -2212,3 +2212,16 @@ static DisasJumpType op_vsbi(DisasContext *s, DisasOps *o) get_field(s->fields, v4));return DISAS_NEXT ; } + +static DisasJumpType op_vsbcbi (DisasContext *s,DisasOps *o) +{ +if (get_field (s->fields, m5) !=ES_128 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +gen_gvec_4_ool (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3),get_field (s->fields, v4),0 , + gen_helper_gvec_vsbcbi128); +return DISAS_NEXT ; +}
target/s390x/vec_int_helper.c +16 -0
@@ -803,3 +803,19 @@ void HELPER(gvec_vscbi128)(void *v1, const void *v2, const void *v3, dst->doubleword[0 ] =0 ; dst->doubleword[1 ] =s390_vec_sub (&tmp, v2, v3); } + +void HELPER (gvec_vsbcbi128 )(void *v1,const void *v2,const void *v3, +const void *v4,uint32_t desc) +{ +const S390Vector old_borrow = { + .doubleword[0 ] =0 , + .doubleword[1 ] = ((S390Vector *)v4)->doubleword[1 ] &1 , + }; +S390Vector tmp, *dst = v1; +bool borrow; + + borrow =s390_vec_sub (&tmp, v2, v3); + borrow |=s390_vec_sub (&tmp, &tmp, &old_borrow); + dst->doubleword[0 ] =0 ; + dst->doubleword[1 ] = borrow; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 37/41] s390x/tcg: Implement VECTOR SUBTRACT WITH BORROW COMPUTE BORROW INDICATION
target/s390x/translate_vx.inc.c static DisasJumpType op_vsbi(DisasContext *s, DisasOps *o) · line 2227
Quoted 12 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +12
-0+static DisasJumpType op_vsbcbi (DisasContext *s,DisasOps *o) +{ +if (get_field (s->fields, m5) !=ES_128 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +gen_gvec_4_ool (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3),get_field (s->fields, v4),0 , + gen_helper_gvec_vsbcbi128); +return DISAS_NEXT ; +}
I'm sure this can be done similarly to add with carry compute carry, but it's harder to reason with sub2. Something like
tcg_gen_andi_i64(tl, cl, 1); tcg_gen_sub2_i64(tl, th, al, zero, tl, zero); tcg_gen_sub2_i64(tl, th, tl, th, bl, zero); tcg_gen_andi_i64(tl, th, 1); tcg_gen_sub2_i64(tl, th, ah, zero, tl, zero); tcg_gen_sub2_i64(tl, th, tl, th, bh, zero); tcg_gen_andi_i64(tl, th, 1); /* result in tl */
r~
Re: [Qemu-devel] [PATCH v1 37/41] s390x/tcg: Implement VECTOR SUBTRACT WITH BORROW COMPUTE BORROW INDICATION
Quoted 20 lines · Richard Henderson
target/s390x/translate_vx.inc.c static DisasJumpType op_vsbi(DisasContext *s, DisasOps *o) · line 2227
Quoted 12 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +12
-0+static DisasJumpType op_vsbcbi (DisasContext *s,DisasOps *o) +{ +if (get_field (s->fields, m5) !=ES_128 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + +gen_gvec_4_ool (get_field (s->fields, v1),get_field (s->fields, v2), +get_field (s->fields, v3),get_field (s->fields, v4),0 , + gen_helper_gvec_vsbcbi128); +return DISAS_NEXT ; +}Reviewed-by Richard Henderson <[email protected]>I'm sure this can be done similarly to add with carry compute carry, but it's harder to reason with sub2. Something like
Quoted 8 lines
tcg_gen_andi_i64(tl, cl, 1); tcg_gen_sub2_i64(tl, th, al, zero, tl, zero); tcg_gen_sub2_i64(tl, th, tl, th, bl, zero); tcg_gen_andi_i64(tl, th, 1); tcg_gen_sub2_i64(tl, th, ah, zero, tl, zero); tcg_gen_sub2_i64(tl, th, tl, th, bh, zero); tcg_gen_andi_i64(tl, th, 1); /* result in tl */
Indeed, looks good to me. The only thing to care about is to convert -1 to 1, so we get a proper borrow.
Thanks!
Signature · 3 lines
Thanks, David / dhildenb
PATCH 38/41 s390x/tcg: Implement VECTOR SUM ACROSS DOUBLEWORD
In reply to David HildenbrandPerform the calculations without a helper. Only 16 bit or 32 bit values have to be added.
--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1182,6 +1182,8 @@ F(0xe7bf, VSBI, VRR_d, V, 0, 0, 0, 0, vsbi, 0, IF_VEC) /* VECTOR SUBTRACT WITH BORROW COMPUTE BORROW INDICATION */ F(0xe7bd, VSBCBI, VRR_d, V, 0, 0, 0, 0, vsbcbi, 0, IF_VEC) +/* VECTOR SUM ACROSS DOUBLEWORD */ + F(0xe765, VSUMG, VRR_c, V, 0, 0, 0, 0, vsumg, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +29 -0
@@ -2225,3 +2225,32 @@ static DisasJumpType op_vsbcbi(DisasContext *s, DisasOps *o) gen_helper_gvec_vsbcbi128);return DISAS_NEXT ; } + +static DisasJumpType op_vsumg (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m4); +TCGv_i64 sum, tmp; +uint8_t dst_idx; + +if (es ==ES_8 || es >ES_32 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + + sum =tcg_temp_new_i64 (); + tmp =tcg_temp_new_i64 (); +for (dst_idx =0 ; dst_idx <2 ; dst_idx++) { +uint8_t idx = dst_idx *NUM_VEC_ELEMENTS (es) /2 ; +const uint8_t max_idx = idx +NUM_VEC_ELEMENTS (es) /2 -1 ; + +read_vec_element_i64 (sum,get_field (s->fields, v3), max_idx, es); +for (; idx <= max_idx; idx++) { +read_vec_element_i64 (tmp,get_field (s->fields, v2), idx, es); +tcg_gen_add_i64 (sum, sum, tmp); + } +write_vec_element_i64 (sum,get_field (s->fields, v1), dst_idx,ES_64 ); + } +tcg_temp_free_i64 (sum); +tcg_temp_free_i64 (tmp); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 38/41] s390x/tcg: Implement VECTOR SUM ACROSS DOUBLEWORD
Quoted 8 lines · David Hildenbrand
Perform the calculations without a helper. Only 16 bit or 32 bit values have to be added.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
r~
PATCH 39/41 s390x/tcg: Implement VECTOR SUM ACROSS QUADWORD
In reply to David HildenbrandSimilar to VECTOR SUM ACROSS DOUBLEWORD, however without a loop and using 128-bit calculations.
--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1184,6 +1184,8 @@ F(0xe7bd, VSBCBI, VRR_d, V, 0, 0, 0, 0, vsbcbi, 0, IF_VEC) /* VECTOR SUM ACROSS DOUBLEWORD */ F(0xe765, VSUMG, VRR_c, V, 0, 0, 0, 0, vsumg, 0, IF_VEC) +/* VECTOR SUM ACROSS QUADWORD */ + F(0xe767, VSUMQ, VRR_c, V, 0, 0, 0, 0, vsumq, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +32 -0
@@ -2254,3 +2254,35 @@ static DisasJumpType op_vsumg(DisasContext *s, DisasOps *o)tcg_temp_free_i64 (tmp);return DISAS_NEXT ; } + +static DisasJumpType op_vsumq (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m4); +const uint8_t max_idx =NUM_VEC_ELEMENTS (es) -1 ; +TCGv_i64 sumh, suml, zero, tmpl; +uint8_t idx; + +if (es <ES_32 || es >ES_64 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + + sumh =tcg_const_i64 (0 ); + suml =tcg_temp_new_i64 (); + zero =tcg_const_i64 (0 ); + tmpl =tcg_temp_new_i64 (); + +read_vec_element_i64 (suml,get_field (s->fields, v3), max_idx, es); +for (idx =0 ; idx <= max_idx; idx++) { +read_vec_element_i64 (tmpl,get_field (s->fields, v2), idx, es); +tcg_gen_add2_i64 (suml, sumh, suml, sumh, tmpl, zero); + } +write_vec_element_i64 (sumh,get_field (s->fields, v1),0 ,ES_64 ); +write_vec_element_i64 (suml,get_field (s->fields, v1),1 ,ES_64 ); + +tcg_temp_free_i64 (sumh); +tcg_temp_free_i64 (suml); +tcg_temp_free_i64 (zero); +tcg_temp_free_i64 (tmpl); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 39/41] s390x/tcg: Implement VECTOR SUM ACROSS QUADWORD
target/s390x/translate_vx.inc.c static DisasJumpType op_vsumg(DisasContext *s, DisasOps *o) · line 2281
Quoted 7 lines · David Hildenbrand
target/s390x/translate_vx.inc.c +7
-0+read_vec_element_i64 (suml,get_field (s->fields, v3), max_idx, es); +for (idx =0 ; idx <= max_idx; idx++) { +read_vec_element_i64 (tmpl,get_field (s->fields, v2), idx, es); +tcg_gen_add2_i64 (suml, sumh, suml, sumh, tmpl, zero); + } +write_vec_element_i64 (sumh,get_field (s->fields, v1),0 ,ES_64 ); +write_vec_element_i64 (suml,get_field (s->fields, v1),1 ,ES_64 );
It's a long way around for ES_32, as there will never be overflow into bit 65.
But I guess it's not wrong.
r~
PATCH 40/41 s390x/tcg: Implement VECTOR SUM ACROSS WORD
In reply to David HildenbrandSimilar to VECTOR SUM ACROSS DOUBLEWORD.
--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
target/s390x/insn-data.def +2 -0
@@ -1186,6 +1186,8 @@ F(0xe765, VSUMG, VRR_c, V, 0, 0, 0, 0, vsumg, 0, IF_VEC) /* VECTOR SUM ACROSS QUADWORD */ F(0xe767, VSUMQ, VRR_c, V, 0, 0, 0, 0, vsumq, 0, IF_VEC) +/* VECTOR SUM ACROSS WORD */ + F(0xe764, VSUM, VRR_c, V, 0, 0, 0, 0, vsum, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +29 -0
@@ -2286,3 +2286,32 @@ static DisasJumpType op_vsumq(DisasContext *s, DisasOps *o)tcg_temp_free_i64 (tmpl);return DISAS_NEXT ; } + +static DisasJumpType op_vsum (DisasContext *s,DisasOps *o) +{ +const uint8_t es =get_field (s->fields, m4); +TCGv_i32 sum, tmp; +uint8_t dst_idx; + +if (es >ES_16 ) { +gen_program_exception (s,PGM_SPECIFICATION ); +return DISAS_NORETURN ; + } + + sum =tcg_temp_new_i32 (); + tmp =tcg_temp_new_i32 (); +for (dst_idx =0 ; dst_idx <4 ; dst_idx++) { +uint8_t idx = dst_idx *NUM_VEC_ELEMENTS (es) /4 ; +const uint8_t max_idx = idx +NUM_VEC_ELEMENTS (es) /4 -1 ; + +read_vec_element_i32 (sum,get_field (s->fields, v3), max_idx, es); +for (; idx <= max_idx; idx++) { +read_vec_element_i32 (tmp,get_field (s->fields, v2), idx, es); +tcg_gen_add_i32 (sum, sum, tmp); + } +write_vec_element_i32 (sum,get_field (s->fields, v1), dst_idx,ES_32 ); + } +tcg_temp_free_i32 (sum); +tcg_temp_free_i32 (tmp); +return DISAS_NEXT ; +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 40/41] s390x/tcg: Implement VECTOR SUM ACROSS WORD
Quoted 7 lines · David Hildenbrand
Similar to VECTOR SUM ACROSS DOUBLEWORD.
Signed-off-by David Hildenbrand <[email protected]>--- target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
r~
PATCH 41/41 s390x/tcg: Implement VECTOR TEST UNDER MASK
In reply to David HildenbrandLet's return the cc value directly via cpu_env. Unfortunately there isn't a simple way to calculate the value lazily - one would have to calculate and store e.g. the population count of the mask and the result so it can be evaluated in a cc helper.
But as VTM only sets the cc, we can assume the value will be needed soon either way.
--- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 2 ++ target/s390x/translate_vx.inc.c | 11 +++++++++++ target/s390x/vec_int_helper.c | 18 ++++++++++++++++++ 4 files changed, 32 insertions(+)
target/s390x/helper.h +1 -0
@@ -234,6 +234,7 @@ DEF_HELPER_FLAGS_4(gvec_vscbi8, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vscbi16, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_4(gvec_vscbi128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, i32) DEF_HELPER_FLAGS_5(gvec_vsbcbi128, TCG_CALL_NO_RWG, void, ptr, cptr, cptr, cptr, i32) +DEF_HELPER_4(gvec_vtm, void, ptr, cptr, env, i32)#ifndef CONFIG_USER_ONLY DEF_HELPER_3 (servc, i32, env, i64, i64)
target/s390x/insn-data.def +2 -0
@@ -1188,6 +1188,8 @@ F(0xe767, VSUMQ, VRR_c, V, 0, 0, 0, 0, vsumq, 0, IF_VEC) /* VECTOR SUM ACROSS WORD */ F(0xe764, VSUM, VRR_c, V, 0, 0, 0, 0, vsum, 0, IF_VEC) +/* VECTOR TEST UNDER MASK */ + F(0xe7d8, VTM, VRR_a, V, 0, 0, 0, 0, vtm, 0, IF_VEC) #ifndef CONFIG_USER_ONLY /* COMPARE AND SWAP AND PURGE */
target/s390x/translate_vx.inc.c +11 -0
@@ -191,6 +191,9 @@ static void get_vec_element_ptr_i64(TCGv_ptr ptr, uint8_t reg, TCGv_i64 enr,#define gen_gvec_2i_ool (v1, v2, c, data, fn) \ tcg_gen_gvec_2i_ool(vec_full_reg_offset(v1), vec_full_reg_offset(v2), \ c, 16, 16, data, fn) +#define gen_gvec_2_ptr (v1, v2, ptr, data, fn) \ + tcg_gen_gvec_2_ptr(vec_full_reg_offset(v1), vec_full_reg_offset(v2), \ + ptr, 16, 16, data, fn)#define gen_gvec_3 (v1, v2, v3, gen) \ tcg_gen_gvec_3(vec_full_reg_offset(v1), vec_full_reg_offset(v2), \ vec_full_reg_offset(v3), 16, 16, gen)
@@ -2315,3 +2318,11 @@ static DisasJumpType op_vsum(DisasContext *s, DisasOps *o)tcg_temp_free_i32 (tmp);return DISAS_NEXT ; } + +static DisasJumpType op_vtm (DisasContext *s,DisasOps *o) +{ +gen_gvec_2_ptr (get_field (s->fields, v1),get_field (s->fields, v2), + cpu_env,0 , gen_helper_gvec_vtm); +set_cc_static (s); +return DISAS_NEXT ; +}
target/s390x/vec_int_helper.c +18 -0
@@ -819,3 +819,21 @@ void HELPER(gvec_vsbcbi128)(void *v1, const void *v2, const void *v3, dst->doubleword[0 ] =0 ; dst->doubleword[1 ] = borrow; } + +void HELPER (gvec_vtm )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +S390Vector tmp; + +s390_vec_and (&tmp, v1, v2); +if (s390_vec_is_zero (&tmp)) { +/* Selected bits all zeros; or all mask bits zero */ + env->cc_op =0 ; + }else if (s390_vec_equal (&tmp, v2)) { +/* Selected bits all ones */ + env->cc_op =3 ; + }else { +/* Selected bits a mix of zeros and ones */ + env->cc_op =1 ; + } +}
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v1 41/41] s390x/tcg: Implement VECTOR TEST UNDER MASK
Quoted 7 lines · David Hildenbrand
target/s390x/vec_int_helper.c +7
-0+void HELPER (gvec_vtm )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +S390Vector tmp; + +s390_vec_and (&tmp, v1, v2); +if (s390_vec_is_zero (&tmp)) {
target/s390x/vec_int_helper.c void HELPER(gvec_vsbcbi128)(void *v1, const void *v2, const void *v3, · line 839
Quoted 10 lines
target/s390x/vec_int_helper.c +10
-0+/* Selected bits all zeros; or all mask bits zero */ + env->cc_op =0 ; + }else if (s390_vec_equal (&tmp, v2)) { +/* Selected bits all ones */ + env->cc_op =3 ; + }else { +/* Selected bits a mix of zeros and ones */ + env->cc_op =1 ; + } +}
However, if you return this value, then you can do
DEF_HELPER_FLAGS_4(gvec_vtm, TCG_CALL_NO_RWG_SE, i32, cptr, cptr)
static DisasJumpType op_vtm(DisasContext *s, DisasOps *o)
{
TCGv_ptr p1 = tcg_temp_new_ptr();
TCGv_ptr p2 = tcg_temp_new_ptr();
tcg_gen_addi_ptr(p1, cpu_env,
vec_full_reg_offset(get_field(s->fields, v1)));
tcg_gen_addi_ptr(p2, cpu_env,
vec_full_reg_offset(get_field(s->fields, v2)));
gen_helper_gvec_vtm(cc_op, p1, p2);
tcg_temp_free_ptr(p1);
tcg_temp_free_ptr(p2);
set_cc_static(s);
return DISAS_NEXT;
}Perhaps it doesn't matter though, since use of vtm probably implies a jump, which implies end of TB, which means that registers are going to get saved to backing store anyway.
r~
Re: [Qemu-devel] [PATCH v1 41/41] s390x/tcg: Implement VECTOR TEST UNDER MASK
Quoted 41 lines · Richard Henderson
Quoted 7 lines · David Hildenbrand
target/s390x/vec_int_helper.c +7
-0+void HELPER (gvec_vtm )(void *v1,const void *v2,CPUS390XState *env, +uint32_t desc) +{ +S390Vector tmp; + +s390_vec_and (&tmp, v1, v2); +if (s390_vec_is_zero (&tmp)) {target/s390x/vec_int_helper.c void HELPER(gvec_vsbcbi128)(void *v1, const void *v2, const void *v3, · line 839
Quoted 10 lines
target/s390x/vec_int_helper.c +10
-0+/* Selected bits all zeros; or all mask bits zero */ + env->cc_op =0 ; + }else if (s390_vec_equal (&tmp, v2)) { +/* Selected bits all ones */ + env->cc_op =3 ; + }else { +/* Selected bits a mix of zeros and ones */ + env->cc_op =1 ; + } +}Reviewed-by Richard Henderson <[email protected]>However, if you return this value, then you can do
DEF_HELPER_FLAGS_4(gvec_vtm, TCG_CALL_NO_RWG_SE, i32, cptr, cptr)static DisasJumpType
op_vtm(DisasContext *s, DisasOps *o){ TCGv_ptr p1 = tcg_temp_new_ptr(); TCGv_ptr p2 = tcg_temp_new_ptr(); tcg_gen_addi_ptr(p1, cpu_env, vec_full_reg_offset(get_field(s->fields, v1))); tcg_gen_addi_ptr(p2, cpu_env, vec_full_reg_offset(get_field(s->fields, v2))); gen_helper_gvec_vtm(cc_op, p1, p2); tcg_temp_free_ptr(p1); tcg_temp_free_ptr(p2); set_cc_static(s); return DISAS_NEXT; }
Quoted 3 lines
Perhaps it doesn't matter though, since use of vtm probably implies a jump, which implies end of TB, which means that registers are going to get saved to backing store anyway.
Had a similar idea, but I guess it doesn't really matter. This way, we can at least use standardized gvec ool helpers. Will leave it as is for now, thanks!
Signature · 3 lines
Thanks, David / dhildenb