* [PATCH 1/7] target/ppc: use int128.h methods in vpmsumd
2022-06-06 15:00 [PATCH 0/7] Remove CONFIG_INT128 conditional code from target/ppc/* Matheus Ferst
@ 2022-06-06 15:00 ` Matheus Ferst
2022-06-27 16:23 ` Víctor Colombo
2022-06-06 15:00 ` [PATCH 2/7] target/ppc: use int128.h methods in vadduqm Matheus Ferst
` (6 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Matheus Ferst @ 2022-06-06 15:00 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson, Matheus Ferst
Also drop VECTOR_FOR_INORDER_I usage since there is no need to access
the elements in any particular order, and move the instruction to
decodetree.
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
target/ppc/helper.h | 2 +-
target/ppc/insn32.decode | 4 +++
target/ppc/int_helper.c | 46 ++++++-----------------------
target/ppc/translate/vmx-impl.c.inc | 3 +-
target/ppc/translate/vmx-ops.c.inc | 1 -
5 files changed, 16 insertions(+), 40 deletions(-)
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index d627cfe6ed..39ad114c97 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -318,7 +318,7 @@ DEF_HELPER_FLAGS_3(vbpermq, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_3(vpmsumb, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_3(vpmsumh, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_3(vpmsumw, TCG_CALL_NO_RWG, void, avr, avr, avr)
-DEF_HELPER_FLAGS_3(vpmsumd, TCG_CALL_NO_RWG, void, avr, avr, avr)
+DEF_HELPER_FLAGS_3(VPMSUMD, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_2(vextublx, TCG_CALL_NO_RWG, tl, tl, avr)
DEF_HELPER_FLAGS_2(vextuhlx, TCG_CALL_NO_RWG, tl, tl, avr)
DEF_HELPER_FLAGS_2(vextuwlx, TCG_CALL_NO_RWG, tl, tl, avr)
diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
index 6ea48d5163..0772729c6e 100644
--- a/target/ppc/insn32.decode
+++ b/target/ppc/insn32.decode
@@ -426,6 +426,10 @@ DSCLIQ 111111 ..... ..... ...... 001000010 . @Z22_tap_sh_rc
DSCRI 111011 ..... ..... ...... 001100010 . @Z22_ta_sh_rc
DSCRIQ 111111 ..... ..... ...... 001100010 . @Z22_tap_sh_rc
+## Vector Exclusive-OR-based Instructions
+
+VPMSUMD 000100 ..... ..... ..... 10011001000 @VX
+
## Vector Integer Instructions
VCMPEQUB 000100 ..... ..... ..... . 0000000110 @VC
diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
index 16357c0900..67aaa8edf5 100644
--- a/target/ppc/int_helper.c
+++ b/target/ppc/int_helper.c
@@ -1484,52 +1484,24 @@ PMSUM(vpmsumb, u8, u16, uint16_t)
PMSUM(vpmsumh, u16, u32, uint32_t)
PMSUM(vpmsumw, u32, u64, uint64_t)
-void helper_vpmsumd(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
+void helper_VPMSUMD(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
{
-
-#ifdef CONFIG_INT128
int i, j;
- __uint128_t prod[2];
+ Int128 tmp, prod[2] = {int128_zero(), int128_zero()};
- VECTOR_FOR_INORDER_I(i, u64) {
- prod[i] = 0;
- for (j = 0; j < 64; j++) {
- if (a->u64[i] & (1ull << j)) {
- prod[i] ^= (((__uint128_t)b->u64[i]) << j);
+ for (j = 0; j < 64; j++) {
+ for (i = 0; i < ARRAY_SIZE(r->u64); i++) {
+ if (a->VsrD(i) & (1ull << j)) {
+ tmp = int128_make64(b->VsrD(i));
+ tmp = int128_lshift(tmp, j);
+ prod[i] = int128_xor(prod[i], tmp);
}
}
}
- r->u128 = prod[0] ^ prod[1];
-
-#else
- int i, j;
- ppc_avr_t prod[2];
-
- VECTOR_FOR_INORDER_I(i, u64) {
- prod[i].VsrD(1) = prod[i].VsrD(0) = 0;
- for (j = 0; j < 64; j++) {
- if (a->u64[i] & (1ull << j)) {
- ppc_avr_t bshift;
- if (j == 0) {
- bshift.VsrD(0) = 0;
- bshift.VsrD(1) = b->u64[i];
- } else {
- bshift.VsrD(0) = b->u64[i] >> (64 - j);
- bshift.VsrD(1) = b->u64[i] << j;
- }
- prod[i].VsrD(1) ^= bshift.VsrD(1);
- prod[i].VsrD(0) ^= bshift.VsrD(0);
- }
- }
- }
-
- r->VsrD(1) = prod[0].VsrD(1) ^ prod[1].VsrD(1);
- r->VsrD(0) = prod[0].VsrD(0) ^ prod[1].VsrD(0);
-#endif
+ r->s128 = int128_xor(prod[0], prod[1]);
}
-
#if HOST_BIG_ENDIAN
#define PKBIG 1
#else
diff --git a/target/ppc/translate/vmx-impl.c.inc b/target/ppc/translate/vmx-impl.c.inc
index 0b563bed37..4c2a36405b 100644
--- a/target/ppc/translate/vmx-impl.c.inc
+++ b/target/ppc/translate/vmx-impl.c.inc
@@ -2717,7 +2717,6 @@ GEN_VXFORM_TRANS(vgbbd, 6, 20);
GEN_VXFORM(vpmsumb, 4, 16)
GEN_VXFORM(vpmsumh, 4, 17)
GEN_VXFORM(vpmsumw, 4, 18)
-GEN_VXFORM(vpmsumd, 4, 19)
#define GEN_BCD(op) \
static void gen_##op(DisasContext *ctx) \
@@ -3101,6 +3100,8 @@ static bool do_vx_helper(DisasContext *ctx, arg_VX *a,
return true;
}
+TRANS_FLAGS2(ALTIVEC_207, VPMSUMD, do_vx_helper, gen_helper_VPMSUMD)
+
static bool do_vx_vmuleo(DisasContext *ctx, arg_VX *a, bool even,
void (*gen_mul)(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_i64))
{
diff --git a/target/ppc/translate/vmx-ops.c.inc b/target/ppc/translate/vmx-ops.c.inc
index d7cc57868e..26c1d957ee 100644
--- a/target/ppc/translate/vmx-ops.c.inc
+++ b/target/ppc/translate/vmx-ops.c.inc
@@ -237,7 +237,6 @@ GEN_VXFORM_207(vgbbd, 6, 20),
GEN_VXFORM_207(vpmsumb, 4, 16),
GEN_VXFORM_207(vpmsumh, 4, 17),
GEN_VXFORM_207(vpmsumw, 4, 18),
-GEN_VXFORM_207(vpmsumd, 4, 19),
GEN_VXFORM_207(vsbox, 4, 23),
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 1/7] target/ppc: use int128.h methods in vpmsumd
2022-06-06 15:00 ` [PATCH 1/7] target/ppc: use int128.h methods in vpmsumd Matheus Ferst
@ 2022-06-27 16:23 ` Víctor Colombo
0 siblings, 0 replies; 16+ messages in thread
From: Víctor Colombo @ 2022-06-27 16:23 UTC (permalink / raw)
To: Matheus Ferst, qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson
On 06/06/2022 12:00, Matheus Ferst wrote:
> [E-MAIL EXTERNO] Não clique em links ou abra anexos, a menos que você possa confirmar o remetente e saber que o conteúdo é seguro. Em caso de e-mail suspeito entre imediatamente em contato com o DTI.
>
> Also drop VECTOR_FOR_INORDER_I usage since there is no need to access
> the elements in any particular order, and move the instruction to
> decodetree.
>
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Reviewed-by: Víctor Colombo <victor.colombo@eldorado.org.br>
--
Víctor Cora Colombo
Instituto de Pesquisas ELDORADO
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/7] target/ppc: use int128.h methods in vadduqm
2022-06-06 15:00 [PATCH 0/7] Remove CONFIG_INT128 conditional code from target/ppc/* Matheus Ferst
2022-06-06 15:00 ` [PATCH 1/7] target/ppc: use int128.h methods in vpmsumd Matheus Ferst
@ 2022-06-06 15:00 ` Matheus Ferst
2022-06-27 16:24 ` Víctor Colombo
2022-06-06 15:00 ` [PATCH 3/7] target/ppc: use int128.h methods in vaddecuq and vaddeuqm Matheus Ferst
` (5 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Matheus Ferst @ 2022-06-06 15:00 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson, Matheus Ferst
And also move the insn to decodetree.
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
target/ppc/helper.h | 2 +-
target/ppc/insn32.decode | 2 ++
target/ppc/int_helper.c | 8 ++------
target/ppc/translate/vmx-impl.c.inc | 3 ++-
target/ppc/translate/vmx-ops.c.inc | 1 -
5 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index 39ad114c97..c6fbe4b6da 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -204,7 +204,7 @@ DEF_HELPER_FLAGS_5(vadduws, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
DEF_HELPER_FLAGS_5(vsububs, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
DEF_HELPER_FLAGS_5(vsubuhs, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
DEF_HELPER_FLAGS_5(vsubuws, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
-DEF_HELPER_FLAGS_3(vadduqm, TCG_CALL_NO_RWG, void, avr, avr, avr)
+DEF_HELPER_FLAGS_3(VADDUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_4(vaddecuq, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
DEF_HELPER_FLAGS_4(vaddeuqm, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
DEF_HELPER_FLAGS_3(vaddcuq, TCG_CALL_NO_RWG, void, avr, avr, avr)
diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
index 0772729c6e..d6bfc2c768 100644
--- a/target/ppc/insn32.decode
+++ b/target/ppc/insn32.decode
@@ -550,6 +550,8 @@ VRLQNM 000100 ..... ..... ..... 00101000101 @VX
## Vector Integer Arithmetic Instructions
+VADDUQM 000100 ..... ..... ..... 00100000000 @VX
+
VEXTSB2W 000100 ..... 10000 ..... 11000000010 @VX_tb
VEXTSH2W 000100 ..... 10001 ..... 11000000010 @VX_tb
VEXTSB2D 000100 ..... 11000 ..... 11000000010 @VX_tb
diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
index 67aaa8edf5..c32b252639 100644
--- a/target/ppc/int_helper.c
+++ b/target/ppc/int_helper.c
@@ -2224,13 +2224,9 @@ static int avr_qw_addc(ppc_avr_t *t, ppc_avr_t a, ppc_avr_t b)
#endif
-void helper_vadduqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
+void helper_VADDUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
{
-#ifdef CONFIG_INT128
- r->u128 = a->u128 + b->u128;
-#else
- avr_qw_add(r, *a, *b);
-#endif
+ r->s128 = int128_add(a->s128, b->s128);
}
void helper_vaddeuqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
diff --git a/target/ppc/translate/vmx-impl.c.inc b/target/ppc/translate/vmx-impl.c.inc
index 4c2a36405b..3fb48404d9 100644
--- a/target/ppc/translate/vmx-impl.c.inc
+++ b/target/ppc/translate/vmx-impl.c.inc
@@ -1234,7 +1234,6 @@ GEN_VXFORM_SAT(vsubuws, MO_32, sub, ussub, 0, 26);
GEN_VXFORM_SAT(vsubsbs, MO_8, sub, sssub, 0, 28);
GEN_VXFORM_SAT(vsubshs, MO_16, sub, sssub, 0, 29);
GEN_VXFORM_SAT(vsubsws, MO_32, sub, sssub, 0, 30);
-GEN_VXFORM(vadduqm, 0, 4);
GEN_VXFORM(vaddcuq, 0, 5);
GEN_VXFORM3(vaddeuqm, 30, 0);
GEN_VXFORM3(vaddecuq, 30, 0);
@@ -3100,6 +3099,8 @@ static bool do_vx_helper(DisasContext *ctx, arg_VX *a,
return true;
}
+TRANS_FLAGS2(ALTIVEC_207, VADDUQM, do_vx_helper, gen_helper_VADDUQM)
+
TRANS_FLAGS2(ALTIVEC_207, VPMSUMD, do_vx_helper, gen_helper_VPMSUMD)
static bool do_vx_vmuleo(DisasContext *ctx, arg_VX *a, bool even,
diff --git a/target/ppc/translate/vmx-ops.c.inc b/target/ppc/translate/vmx-ops.c.inc
index 26c1d957ee..065b0ba414 100644
--- a/target/ppc/translate/vmx-ops.c.inc
+++ b/target/ppc/translate/vmx-ops.c.inc
@@ -126,7 +126,6 @@ GEN_VXFORM(vsubuws, 0, 26),
GEN_VXFORM_DUAL(vsubsbs, bcdtrunc, 0, 28, PPC_ALTIVEC, PPC2_ISA300),
GEN_VXFORM(vsubshs, 0, 29),
GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
-GEN_VXFORM_207(vadduqm, 0, 4),
GEN_VXFORM_207(vaddcuq, 0, 5),
GEN_VXFORM_DUAL(vaddeuqm, vaddecuq, 30, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
GEN_VXFORM_DUAL(vsubuqm, bcdtrunc, 0, 20, PPC2_ALTIVEC_207, PPC2_ISA300),
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] target/ppc: use int128.h methods in vadduqm
2022-06-06 15:00 ` [PATCH 2/7] target/ppc: use int128.h methods in vadduqm Matheus Ferst
@ 2022-06-27 16:24 ` Víctor Colombo
0 siblings, 0 replies; 16+ messages in thread
From: Víctor Colombo @ 2022-06-27 16:24 UTC (permalink / raw)
To: Matheus Ferst, qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson
On 06/06/2022 12:00, Matheus Ferst wrote:
> And also move the insn to decodetree.
>
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
> ---
> target/ppc/helper.h | 2 +-
> target/ppc/insn32.decode | 2 ++
> target/ppc/int_helper.c | 8 ++------
> target/ppc/translate/vmx-impl.c.inc | 3 ++-
> target/ppc/translate/vmx-ops.c.inc | 1 -
> 5 files changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/target/ppc/helper.h b/target/ppc/helper.h
> index 39ad114c97..c6fbe4b6da 100644
> --- a/target/ppc/helper.h
> +++ b/target/ppc/helper.h
> @@ -204,7 +204,7 @@ DEF_HELPER_FLAGS_5(vadduws, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
> DEF_HELPER_FLAGS_5(vsububs, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
> DEF_HELPER_FLAGS_5(vsubuhs, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
> DEF_HELPER_FLAGS_5(vsubuws, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
> -DEF_HELPER_FLAGS_3(vadduqm, TCG_CALL_NO_RWG, void, avr, avr, avr)
> +DEF_HELPER_FLAGS_3(VADDUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
> DEF_HELPER_FLAGS_4(vaddecuq, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> DEF_HELPER_FLAGS_4(vaddeuqm, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> DEF_HELPER_FLAGS_3(vaddcuq, TCG_CALL_NO_RWG, void, avr, avr, avr)
> diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
> index 0772729c6e..d6bfc2c768 100644
> --- a/target/ppc/insn32.decode
> +++ b/target/ppc/insn32.decode
> @@ -550,6 +550,8 @@ VRLQNM 000100 ..... ..... ..... 00101000101 @VX
>
> ## Vector Integer Arithmetic Instructions
>
> +VADDUQM 000100 ..... ..... ..... 00100000000 @VX
> +
> VEXTSB2W 000100 ..... 10000 ..... 11000000010 @VX_tb
> VEXTSH2W 000100 ..... 10001 ..... 11000000010 @VX_tb
> VEXTSB2D 000100 ..... 11000 ..... 11000000010 @VX_tb
> diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
> index 67aaa8edf5..c32b252639 100644
> --- a/target/ppc/int_helper.c
> +++ b/target/ppc/int_helper.c
> @@ -2224,13 +2224,9 @@ static int avr_qw_addc(ppc_avr_t *t, ppc_avr_t a, ppc_avr_t b)
>
> #endif
>
> -void helper_vadduqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> +void helper_VADDUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> {
> -#ifdef CONFIG_INT128
> - r->u128 = a->u128 + b->u128;
> -#else
> - avr_qw_add(r, *a, *b);
> -#endif
> + r->s128 = int128_add(a->s128, b->s128);
> }
>
> void helper_vaddeuqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> diff --git a/target/ppc/translate/vmx-impl.c.inc b/target/ppc/translate/vmx-impl.c.inc
> index 4c2a36405b..3fb48404d9 100644
> --- a/target/ppc/translate/vmx-impl.c.inc
> +++ b/target/ppc/translate/vmx-impl.c.inc
> @@ -1234,7 +1234,6 @@ GEN_VXFORM_SAT(vsubuws, MO_32, sub, ussub, 0, 26);
> GEN_VXFORM_SAT(vsubsbs, MO_8, sub, sssub, 0, 28);
> GEN_VXFORM_SAT(vsubshs, MO_16, sub, sssub, 0, 29);
> GEN_VXFORM_SAT(vsubsws, MO_32, sub, sssub, 0, 30);
> -GEN_VXFORM(vadduqm, 0, 4);
> GEN_VXFORM(vaddcuq, 0, 5);
> GEN_VXFORM3(vaddeuqm, 30, 0);
> GEN_VXFORM3(vaddecuq, 30, 0);
> @@ -3100,6 +3099,8 @@ static bool do_vx_helper(DisasContext *ctx, arg_VX *a,
> return true;
> }
>
> +TRANS_FLAGS2(ALTIVEC_207, VADDUQM, do_vx_helper, gen_helper_VADDUQM)
> +
> TRANS_FLAGS2(ALTIVEC_207, VPMSUMD, do_vx_helper, gen_helper_VPMSUMD)
>
> static bool do_vx_vmuleo(DisasContext *ctx, arg_VX *a, bool even,
> diff --git a/target/ppc/translate/vmx-ops.c.inc b/target/ppc/translate/vmx-ops.c.inc
> index 26c1d957ee..065b0ba414 100644
> --- a/target/ppc/translate/vmx-ops.c.inc
> +++ b/target/ppc/translate/vmx-ops.c.inc
> @@ -126,7 +126,6 @@ GEN_VXFORM(vsubuws, 0, 26),
> GEN_VXFORM_DUAL(vsubsbs, bcdtrunc, 0, 28, PPC_ALTIVEC, PPC2_ISA300),
> GEN_VXFORM(vsubshs, 0, 29),
> GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
> -GEN_VXFORM_207(vadduqm, 0, 4),
> GEN_VXFORM_207(vaddcuq, 0, 5),
> GEN_VXFORM_DUAL(vaddeuqm, vaddecuq, 30, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
> GEN_VXFORM_DUAL(vsubuqm, bcdtrunc, 0, 20, PPC2_ALTIVEC_207, PPC2_ISA300),
> --
> 2.25.1
>
>
Reviewed-by: Víctor Colombo <victor.colombo@eldorado.org.br>
--
Víctor Cora Colombo
Instituto de Pesquisas ELDORADO
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 3/7] target/ppc: use int128.h methods in vaddecuq and vaddeuqm
2022-06-06 15:00 [PATCH 0/7] Remove CONFIG_INT128 conditional code from target/ppc/* Matheus Ferst
2022-06-06 15:00 ` [PATCH 1/7] target/ppc: use int128.h methods in vpmsumd Matheus Ferst
2022-06-06 15:00 ` [PATCH 2/7] target/ppc: use int128.h methods in vadduqm Matheus Ferst
@ 2022-06-06 15:00 ` Matheus Ferst
2022-06-27 16:25 ` Víctor Colombo
2022-06-06 15:00 ` [PATCH 4/7] target/ppc: use int128.h methods in vaddcuq Matheus Ferst
` (4 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Matheus Ferst @ 2022-06-06 15:00 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson, Matheus Ferst
And also move the insns to decodetree and remove the now unused
avr_qw_addc method.
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
target/ppc/helper.h | 4 +--
target/ppc/insn32.decode | 3 ++
target/ppc/int_helper.c | 53 +++++------------------------
target/ppc/translate/vmx-impl.c.inc | 7 ++--
target/ppc/translate/vmx-ops.c.inc | 1 -
5 files changed, 17 insertions(+), 51 deletions(-)
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index c6fbe4b6da..f699adbedc 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -205,8 +205,8 @@ DEF_HELPER_FLAGS_5(vsububs, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
DEF_HELPER_FLAGS_5(vsubuhs, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
DEF_HELPER_FLAGS_5(vsubuws, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
DEF_HELPER_FLAGS_3(VADDUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
-DEF_HELPER_FLAGS_4(vaddecuq, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
-DEF_HELPER_FLAGS_4(vaddeuqm, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
+DEF_HELPER_FLAGS_4(VADDECUQ, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
+DEF_HELPER_FLAGS_4(VADDEUQM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
DEF_HELPER_FLAGS_3(vaddcuq, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_3(vsubuqm, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_4(vsubecuq, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
index d6bfc2c768..139aa3caeb 100644
--- a/target/ppc/insn32.decode
+++ b/target/ppc/insn32.decode
@@ -552,6 +552,9 @@ VRLQNM 000100 ..... ..... ..... 00101000101 @VX
VADDUQM 000100 ..... ..... ..... 00100000000 @VX
+VADDEUQM 000100 ..... ..... ..... ..... 111100 @VA
+VADDECUQ 000100 ..... ..... ..... ..... 111101 @VA
+
VEXTSB2W 000100 ..... 10000 ..... 11000000010 @VX_tb
VEXTSH2W 000100 ..... 10001 ..... 11000000010 @VX_tb
VEXTSB2D 000100 ..... 11000 ..... 11000000010 @VX_tb
diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
index c32b252639..c5d820f4b1 100644
--- a/target/ppc/int_helper.c
+++ b/target/ppc/int_helper.c
@@ -2212,16 +2212,6 @@ static void avr_qw_add(ppc_avr_t *t, ppc_avr_t a, ppc_avr_t b)
(~a.VsrD(1) < b.VsrD(1));
}
-static int avr_qw_addc(ppc_avr_t *t, ppc_avr_t a, ppc_avr_t b)
-{
- ppc_avr_t not_a;
- t->VsrD(1) = a.VsrD(1) + b.VsrD(1);
- t->VsrD(0) = a.VsrD(0) + b.VsrD(0) +
- (~a.VsrD(1) < b.VsrD(1));
- avr_qw_not(¬_a, a);
- return avr_qw_cmpu(not_a, b) < 0;
-}
-
#endif
void helper_VADDUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
@@ -2229,23 +2219,10 @@ void helper_VADDUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
r->s128 = int128_add(a->s128, b->s128);
}
-void helper_vaddeuqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
+void helper_VADDEUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
{
-#ifdef CONFIG_INT128
- r->u128 = a->u128 + b->u128 + (c->u128 & 1);
-#else
-
- if (c->VsrD(1) & 1) {
- ppc_avr_t tmp;
-
- tmp.VsrD(0) = 0;
- tmp.VsrD(1) = c->VsrD(1) & 1;
- avr_qw_add(&tmp, *a, tmp);
- avr_qw_add(r, tmp, *b);
- } else {
- avr_qw_add(r, *a, *b);
- }
-#endif
+ r->s128 = int128_add(int128_add(a->s128, b->s128),
+ int128_make64(int128_getlo(c->s128) & 1));
}
void helper_vaddcuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
@@ -2262,30 +2239,18 @@ void helper_vaddcuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
#endif
}
-void helper_vaddecuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
+void helper_VADDECUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
{
-#ifdef CONFIG_INT128
- int carry_out = (~a->u128 < b->u128);
- if (!carry_out && (c->u128 & 1)) {
- carry_out = ((a->u128 + b->u128 + 1) == 0) &&
- ((a->u128 != 0) || (b->u128 != 0));
- }
- r->u128 = carry_out;
-#else
-
- int carry_in = c->VsrD(1) & 1;
- int carry_out = 0;
- ppc_avr_t tmp;
-
- carry_out = avr_qw_addc(&tmp, *a, *b);
+ bool carry_out = int128_ult(int128_not(a->s128), b->s128),
+ carry_in = int128_getlo(c->s128) & 1;
if (!carry_out && carry_in) {
- ppc_avr_t one = QW_ONE;
- carry_out = avr_qw_addc(&tmp, tmp, one);
+ carry_out = (int128_nz(a->s128) || int128_nz(b->s128)) &&
+ int128_eq(int128_add(a->s128, b->s128), int128_makes64(-1));
}
+
r->VsrD(0) = 0;
r->VsrD(1) = carry_out;
-#endif
}
void helper_vsubuqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
diff --git a/target/ppc/translate/vmx-impl.c.inc b/target/ppc/translate/vmx-impl.c.inc
index 3fb48404d9..4ec6b841b3 100644
--- a/target/ppc/translate/vmx-impl.c.inc
+++ b/target/ppc/translate/vmx-impl.c.inc
@@ -1235,10 +1235,6 @@ GEN_VXFORM_SAT(vsubsbs, MO_8, sub, sssub, 0, 28);
GEN_VXFORM_SAT(vsubshs, MO_16, sub, sssub, 0, 29);
GEN_VXFORM_SAT(vsubsws, MO_32, sub, sssub, 0, 30);
GEN_VXFORM(vaddcuq, 0, 5);
-GEN_VXFORM3(vaddeuqm, 30, 0);
-GEN_VXFORM3(vaddecuq, 30, 0);
-GEN_VXFORM_DUAL(vaddeuqm, PPC_NONE, PPC2_ALTIVEC_207, \
- vaddecuq, PPC_NONE, PPC2_ALTIVEC_207)
GEN_VXFORM(vsubuqm, 0, 20);
GEN_VXFORM(vsubcuq, 0, 21);
GEN_VXFORM3(vsubeuqm, 31, 0);
@@ -2571,6 +2567,9 @@ static bool do_va_helper(DisasContext *ctx, arg_VA *a,
return true;
}
+TRANS_FLAGS2(ALTIVEC_207, VADDECUQ, do_va_helper, gen_helper_VADDECUQ)
+TRANS_FLAGS2(ALTIVEC_207, VADDEUQM, do_va_helper, gen_helper_VADDEUQM)
+
TRANS_FLAGS(ALTIVEC, VPERM, do_va_helper, gen_helper_VPERM)
TRANS_FLAGS2(ISA300, VPERMR, do_va_helper, gen_helper_VPERMR)
diff --git a/target/ppc/translate/vmx-ops.c.inc b/target/ppc/translate/vmx-ops.c.inc
index 065b0ba414..f8a512f920 100644
--- a/target/ppc/translate/vmx-ops.c.inc
+++ b/target/ppc/translate/vmx-ops.c.inc
@@ -127,7 +127,6 @@ GEN_VXFORM_DUAL(vsubsbs, bcdtrunc, 0, 28, PPC_ALTIVEC, PPC2_ISA300),
GEN_VXFORM(vsubshs, 0, 29),
GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
GEN_VXFORM_207(vaddcuq, 0, 5),
-GEN_VXFORM_DUAL(vaddeuqm, vaddecuq, 30, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
GEN_VXFORM_DUAL(vsubuqm, bcdtrunc, 0, 20, PPC2_ALTIVEC_207, PPC2_ISA300),
GEN_VXFORM_DUAL(vsubcuq, bcdutrunc, 0, 21, PPC2_ALTIVEC_207, PPC2_ISA300),
GEN_VXFORM_DUAL(vsubeuqm, vsubecuq, 31, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 3/7] target/ppc: use int128.h methods in vaddecuq and vaddeuqm
2022-06-06 15:00 ` [PATCH 3/7] target/ppc: use int128.h methods in vaddecuq and vaddeuqm Matheus Ferst
@ 2022-06-27 16:25 ` Víctor Colombo
0 siblings, 0 replies; 16+ messages in thread
From: Víctor Colombo @ 2022-06-27 16:25 UTC (permalink / raw)
To: Matheus Ferst, qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson
On 06/06/2022 12:00, Matheus Ferst wrote:
> And also move the insns to decodetree and remove the now unused
> avr_qw_addc method.
>
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
> ---
> target/ppc/helper.h | 4 +--
> target/ppc/insn32.decode | 3 ++
> target/ppc/int_helper.c | 53 +++++------------------------
> target/ppc/translate/vmx-impl.c.inc | 7 ++--
> target/ppc/translate/vmx-ops.c.inc | 1 -
> 5 files changed, 17 insertions(+), 51 deletions(-)
>
> diff --git a/target/ppc/helper.h b/target/ppc/helper.h
> index c6fbe4b6da..f699adbedc 100644
> --- a/target/ppc/helper.h
> +++ b/target/ppc/helper.h
> @@ -205,8 +205,8 @@ DEF_HELPER_FLAGS_5(vsububs, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
> DEF_HELPER_FLAGS_5(vsubuhs, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
> DEF_HELPER_FLAGS_5(vsubuws, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
> DEF_HELPER_FLAGS_3(VADDUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
> -DEF_HELPER_FLAGS_4(vaddecuq, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> -DEF_HELPER_FLAGS_4(vaddeuqm, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> +DEF_HELPER_FLAGS_4(VADDECUQ, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> +DEF_HELPER_FLAGS_4(VADDEUQM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> DEF_HELPER_FLAGS_3(vaddcuq, TCG_CALL_NO_RWG, void, avr, avr, avr)
> DEF_HELPER_FLAGS_3(vsubuqm, TCG_CALL_NO_RWG, void, avr, avr, avr)
> DEF_HELPER_FLAGS_4(vsubecuq, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
> index d6bfc2c768..139aa3caeb 100644
> --- a/target/ppc/insn32.decode
> +++ b/target/ppc/insn32.decode
> @@ -552,6 +552,9 @@ VRLQNM 000100 ..... ..... ..... 00101000101 @VX
>
> VADDUQM 000100 ..... ..... ..... 00100000000 @VX
>
> +VADDEUQM 000100 ..... ..... ..... ..... 111100 @VA
> +VADDECUQ 000100 ..... ..... ..... ..... 111101 @VA
> +
> VEXTSB2W 000100 ..... 10000 ..... 11000000010 @VX_tb
> VEXTSH2W 000100 ..... 10001 ..... 11000000010 @VX_tb
> VEXTSB2D 000100 ..... 11000 ..... 11000000010 @VX_tb
> diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
> index c32b252639..c5d820f4b1 100644
> --- a/target/ppc/int_helper.c
> +++ b/target/ppc/int_helper.c
> @@ -2212,16 +2212,6 @@ static void avr_qw_add(ppc_avr_t *t, ppc_avr_t a, ppc_avr_t b)
> (~a.VsrD(1) < b.VsrD(1));
> }
>
> -static int avr_qw_addc(ppc_avr_t *t, ppc_avr_t a, ppc_avr_t b)
> -{
> - ppc_avr_t not_a;
> - t->VsrD(1) = a.VsrD(1) + b.VsrD(1);
> - t->VsrD(0) = a.VsrD(0) + b.VsrD(0) +
> - (~a.VsrD(1) < b.VsrD(1));
> - avr_qw_not(¬_a, a);
> - return avr_qw_cmpu(not_a, b) < 0;
> -}
> -
> #endif
>
> void helper_VADDUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> @@ -2229,23 +2219,10 @@ void helper_VADDUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> r->s128 = int128_add(a->s128, b->s128);
> }
>
> -void helper_vaddeuqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> +void helper_VADDEUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> {
> -#ifdef CONFIG_INT128
> - r->u128 = a->u128 + b->u128 + (c->u128 & 1);
> -#else
> -
> - if (c->VsrD(1) & 1) {
> - ppc_avr_t tmp;
> -
> - tmp.VsrD(0) = 0;
> - tmp.VsrD(1) = c->VsrD(1) & 1;
> - avr_qw_add(&tmp, *a, tmp);
> - avr_qw_add(r, tmp, *b);
> - } else {
> - avr_qw_add(r, *a, *b);
> - }
> -#endif
> + r->s128 = int128_add(int128_add(a->s128, b->s128),
> + int128_make64(int128_getlo(c->s128) & 1));
> }
>
> void helper_vaddcuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> @@ -2262,30 +2239,18 @@ void helper_vaddcuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> #endif
> }
>
> -void helper_vaddecuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> +void helper_VADDECUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> {
> -#ifdef CONFIG_INT128
> - int carry_out = (~a->u128 < b->u128);
> - if (!carry_out && (c->u128 & 1)) {
> - carry_out = ((a->u128 + b->u128 + 1) == 0) &&
> - ((a->u128 != 0) || (b->u128 != 0));
> - }
> - r->u128 = carry_out;
> -#else
> -
> - int carry_in = c->VsrD(1) & 1;
> - int carry_out = 0;
> - ppc_avr_t tmp;
> -
> - carry_out = avr_qw_addc(&tmp, *a, *b);
> + bool carry_out = int128_ult(int128_not(a->s128), b->s128),
> + carry_in = int128_getlo(c->s128) & 1;
>
> if (!carry_out && carry_in) {
> - ppc_avr_t one = QW_ONE;
> - carry_out = avr_qw_addc(&tmp, tmp, one);
> + carry_out = (int128_nz(a->s128) || int128_nz(b->s128)) &&
> + int128_eq(int128_add(a->s128, b->s128), int128_makes64(-1));
> }
> +
> r->VsrD(0) = 0;
> r->VsrD(1) = carry_out;
> -#endif
> }
>
> void helper_vsubuqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> diff --git a/target/ppc/translate/vmx-impl.c.inc b/target/ppc/translate/vmx-impl.c.inc
> index 3fb48404d9..4ec6b841b3 100644
> --- a/target/ppc/translate/vmx-impl.c.inc
> +++ b/target/ppc/translate/vmx-impl.c.inc
> @@ -1235,10 +1235,6 @@ GEN_VXFORM_SAT(vsubsbs, MO_8, sub, sssub, 0, 28);
> GEN_VXFORM_SAT(vsubshs, MO_16, sub, sssub, 0, 29);
> GEN_VXFORM_SAT(vsubsws, MO_32, sub, sssub, 0, 30);
> GEN_VXFORM(vaddcuq, 0, 5);
> -GEN_VXFORM3(vaddeuqm, 30, 0);
> -GEN_VXFORM3(vaddecuq, 30, 0);
> -GEN_VXFORM_DUAL(vaddeuqm, PPC_NONE, PPC2_ALTIVEC_207, \
> - vaddecuq, PPC_NONE, PPC2_ALTIVEC_207)
> GEN_VXFORM(vsubuqm, 0, 20);
> GEN_VXFORM(vsubcuq, 0, 21);
> GEN_VXFORM3(vsubeuqm, 31, 0);
> @@ -2571,6 +2567,9 @@ static bool do_va_helper(DisasContext *ctx, arg_VA *a,
> return true;
> }
>
> +TRANS_FLAGS2(ALTIVEC_207, VADDECUQ, do_va_helper, gen_helper_VADDECUQ)
> +TRANS_FLAGS2(ALTIVEC_207, VADDEUQM, do_va_helper, gen_helper_VADDEUQM)
> +
> TRANS_FLAGS(ALTIVEC, VPERM, do_va_helper, gen_helper_VPERM)
> TRANS_FLAGS2(ISA300, VPERMR, do_va_helper, gen_helper_VPERMR)
>
> diff --git a/target/ppc/translate/vmx-ops.c.inc b/target/ppc/translate/vmx-ops.c.inc
> index 065b0ba414..f8a512f920 100644
> --- a/target/ppc/translate/vmx-ops.c.inc
> +++ b/target/ppc/translate/vmx-ops.c.inc
> @@ -127,7 +127,6 @@ GEN_VXFORM_DUAL(vsubsbs, bcdtrunc, 0, 28, PPC_ALTIVEC, PPC2_ISA300),
> GEN_VXFORM(vsubshs, 0, 29),
> GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
> GEN_VXFORM_207(vaddcuq, 0, 5),
> -GEN_VXFORM_DUAL(vaddeuqm, vaddecuq, 30, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
> GEN_VXFORM_DUAL(vsubuqm, bcdtrunc, 0, 20, PPC2_ALTIVEC_207, PPC2_ISA300),
> GEN_VXFORM_DUAL(vsubcuq, bcdutrunc, 0, 21, PPC2_ALTIVEC_207, PPC2_ISA300),
> GEN_VXFORM_DUAL(vsubeuqm, vsubecuq, 31, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
> --
> 2.25.1
>
>
Reviewed-by: Víctor Colombo <victor.colombo@eldorado.org.br>
--
Víctor Cora Colombo
Instituto de Pesquisas ELDORADO
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 4/7] target/ppc: use int128.h methods in vaddcuq
2022-06-06 15:00 [PATCH 0/7] Remove CONFIG_INT128 conditional code from target/ppc/* Matheus Ferst
` (2 preceding siblings ...)
2022-06-06 15:00 ` [PATCH 3/7] target/ppc: use int128.h methods in vaddecuq and vaddeuqm Matheus Ferst
@ 2022-06-06 15:00 ` Matheus Ferst
2022-06-27 16:25 ` Víctor Colombo
2022-06-06 15:00 ` [PATCH 5/7] target/ppc: use int128.h methods in vsubuqm Matheus Ferst
` (3 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Matheus Ferst @ 2022-06-06 15:00 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson, Matheus Ferst
And also move the insn to decodetree.
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
target/ppc/helper.h | 2 +-
target/ppc/insn32.decode | 1 +
target/ppc/int_helper.c | 12 ++----------
target/ppc/translate/vmx-impl.c.inc | 2 +-
target/ppc/translate/vmx-ops.c.inc | 1 -
5 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index f699adbedc..f6b1b2fad2 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -207,7 +207,7 @@ DEF_HELPER_FLAGS_5(vsubuws, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
DEF_HELPER_FLAGS_3(VADDUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_4(VADDECUQ, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
DEF_HELPER_FLAGS_4(VADDEUQM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
-DEF_HELPER_FLAGS_3(vaddcuq, TCG_CALL_NO_RWG, void, avr, avr, avr)
+DEF_HELPER_FLAGS_3(VADDCUQ, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_3(vsubuqm, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_4(vsubecuq, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
DEF_HELPER_FLAGS_4(vsubeuqm, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
index 139aa3caeb..35252ddd4f 100644
--- a/target/ppc/insn32.decode
+++ b/target/ppc/insn32.decode
@@ -550,6 +550,7 @@ VRLQNM 000100 ..... ..... ..... 00101000101 @VX
## Vector Integer Arithmetic Instructions
+VADDCUQ 000100 ..... ..... ..... 00101000000 @VX
VADDUQM 000100 ..... ..... ..... 00100000000 @VX
VADDEUQM 000100 ..... ..... ..... ..... 111100 @VA
diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
index c5d820f4b1..a12f2831ac 100644
--- a/target/ppc/int_helper.c
+++ b/target/ppc/int_helper.c
@@ -2225,18 +2225,10 @@ void helper_VADDEUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
int128_make64(int128_getlo(c->s128) & 1));
}
-void helper_vaddcuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
+void helper_VADDCUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
{
-#ifdef CONFIG_INT128
- r->u128 = (~a->u128 < b->u128);
-#else
- ppc_avr_t not_a;
-
- avr_qw_not(¬_a, *a);
-
+ r->VsrD(1) = int128_ult(int128_not(a->s128), b->s128);
r->VsrD(0) = 0;
- r->VsrD(1) = (avr_qw_cmpu(not_a, *b) < 0);
-#endif
}
void helper_VADDECUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
diff --git a/target/ppc/translate/vmx-impl.c.inc b/target/ppc/translate/vmx-impl.c.inc
index 4ec6b841b3..8c0e5bcc03 100644
--- a/target/ppc/translate/vmx-impl.c.inc
+++ b/target/ppc/translate/vmx-impl.c.inc
@@ -1234,7 +1234,6 @@ GEN_VXFORM_SAT(vsubuws, MO_32, sub, ussub, 0, 26);
GEN_VXFORM_SAT(vsubsbs, MO_8, sub, sssub, 0, 28);
GEN_VXFORM_SAT(vsubshs, MO_16, sub, sssub, 0, 29);
GEN_VXFORM_SAT(vsubsws, MO_32, sub, sssub, 0, 30);
-GEN_VXFORM(vaddcuq, 0, 5);
GEN_VXFORM(vsubuqm, 0, 20);
GEN_VXFORM(vsubcuq, 0, 21);
GEN_VXFORM3(vsubeuqm, 31, 0);
@@ -3098,6 +3097,7 @@ static bool do_vx_helper(DisasContext *ctx, arg_VX *a,
return true;
}
+TRANS_FLAGS2(ALTIVEC_207, VADDCUQ, do_vx_helper, gen_helper_VADDCUQ)
TRANS_FLAGS2(ALTIVEC_207, VADDUQM, do_vx_helper, gen_helper_VADDUQM)
TRANS_FLAGS2(ALTIVEC_207, VPMSUMD, do_vx_helper, gen_helper_VPMSUMD)
diff --git a/target/ppc/translate/vmx-ops.c.inc b/target/ppc/translate/vmx-ops.c.inc
index f8a512f920..33e05929cb 100644
--- a/target/ppc/translate/vmx-ops.c.inc
+++ b/target/ppc/translate/vmx-ops.c.inc
@@ -126,7 +126,6 @@ GEN_VXFORM(vsubuws, 0, 26),
GEN_VXFORM_DUAL(vsubsbs, bcdtrunc, 0, 28, PPC_ALTIVEC, PPC2_ISA300),
GEN_VXFORM(vsubshs, 0, 29),
GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
-GEN_VXFORM_207(vaddcuq, 0, 5),
GEN_VXFORM_DUAL(vsubuqm, bcdtrunc, 0, 20, PPC2_ALTIVEC_207, PPC2_ISA300),
GEN_VXFORM_DUAL(vsubcuq, bcdutrunc, 0, 21, PPC2_ALTIVEC_207, PPC2_ISA300),
GEN_VXFORM_DUAL(vsubeuqm, vsubecuq, 31, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 4/7] target/ppc: use int128.h methods in vaddcuq
2022-06-06 15:00 ` [PATCH 4/7] target/ppc: use int128.h methods in vaddcuq Matheus Ferst
@ 2022-06-27 16:25 ` Víctor Colombo
0 siblings, 0 replies; 16+ messages in thread
From: Víctor Colombo @ 2022-06-27 16:25 UTC (permalink / raw)
To: Matheus Ferst, qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson
On 06/06/2022 12:00, Matheus Ferst wrote:
> And also move the insn to decodetree.
>
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
> ---
> target/ppc/helper.h | 2 +-
> target/ppc/insn32.decode | 1 +
> target/ppc/int_helper.c | 12 ++----------
> target/ppc/translate/vmx-impl.c.inc | 2 +-
> target/ppc/translate/vmx-ops.c.inc | 1 -
> 5 files changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/target/ppc/helper.h b/target/ppc/helper.h
> index f699adbedc..f6b1b2fad2 100644
> --- a/target/ppc/helper.h
> +++ b/target/ppc/helper.h
> @@ -207,7 +207,7 @@ DEF_HELPER_FLAGS_5(vsubuws, TCG_CALL_NO_RWG, void, avr, avr, avr, avr, i32)
> DEF_HELPER_FLAGS_3(VADDUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
> DEF_HELPER_FLAGS_4(VADDECUQ, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> DEF_HELPER_FLAGS_4(VADDEUQM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> -DEF_HELPER_FLAGS_3(vaddcuq, TCG_CALL_NO_RWG, void, avr, avr, avr)
> +DEF_HELPER_FLAGS_3(VADDCUQ, TCG_CALL_NO_RWG, void, avr, avr, avr)
> DEF_HELPER_FLAGS_3(vsubuqm, TCG_CALL_NO_RWG, void, avr, avr, avr)
> DEF_HELPER_FLAGS_4(vsubecuq, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> DEF_HELPER_FLAGS_4(vsubeuqm, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
> index 139aa3caeb..35252ddd4f 100644
> --- a/target/ppc/insn32.decode
> +++ b/target/ppc/insn32.decode
> @@ -550,6 +550,7 @@ VRLQNM 000100 ..... ..... ..... 00101000101 @VX
>
> ## Vector Integer Arithmetic Instructions
>
> +VADDCUQ 000100 ..... ..... ..... 00101000000 @VX
> VADDUQM 000100 ..... ..... ..... 00100000000 @VX
>
> VADDEUQM 000100 ..... ..... ..... ..... 111100 @VA
> diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
> index c5d820f4b1..a12f2831ac 100644
> --- a/target/ppc/int_helper.c
> +++ b/target/ppc/int_helper.c
> @@ -2225,18 +2225,10 @@ void helper_VADDEUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> int128_make64(int128_getlo(c->s128) & 1));
> }
>
> -void helper_vaddcuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> +void helper_VADDCUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> {
> -#ifdef CONFIG_INT128
> - r->u128 = (~a->u128 < b->u128);
> -#else
> - ppc_avr_t not_a;
> -
> - avr_qw_not(¬_a, *a);
> -
> + r->VsrD(1) = int128_ult(int128_not(a->s128), b->s128);
> r->VsrD(0) = 0;
> - r->VsrD(1) = (avr_qw_cmpu(not_a, *b) < 0);
> -#endif
> }
>
> void helper_VADDECUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> diff --git a/target/ppc/translate/vmx-impl.c.inc b/target/ppc/translate/vmx-impl.c.inc
> index 4ec6b841b3..8c0e5bcc03 100644
> --- a/target/ppc/translate/vmx-impl.c.inc
> +++ b/target/ppc/translate/vmx-impl.c.inc
> @@ -1234,7 +1234,6 @@ GEN_VXFORM_SAT(vsubuws, MO_32, sub, ussub, 0, 26);
> GEN_VXFORM_SAT(vsubsbs, MO_8, sub, sssub, 0, 28);
> GEN_VXFORM_SAT(vsubshs, MO_16, sub, sssub, 0, 29);
> GEN_VXFORM_SAT(vsubsws, MO_32, sub, sssub, 0, 30);
> -GEN_VXFORM(vaddcuq, 0, 5);
> GEN_VXFORM(vsubuqm, 0, 20);
> GEN_VXFORM(vsubcuq, 0, 21);
> GEN_VXFORM3(vsubeuqm, 31, 0);
> @@ -3098,6 +3097,7 @@ static bool do_vx_helper(DisasContext *ctx, arg_VX *a,
> return true;
> }
>
> +TRANS_FLAGS2(ALTIVEC_207, VADDCUQ, do_vx_helper, gen_helper_VADDCUQ)
> TRANS_FLAGS2(ALTIVEC_207, VADDUQM, do_vx_helper, gen_helper_VADDUQM)
>
> TRANS_FLAGS2(ALTIVEC_207, VPMSUMD, do_vx_helper, gen_helper_VPMSUMD)
> diff --git a/target/ppc/translate/vmx-ops.c.inc b/target/ppc/translate/vmx-ops.c.inc
> index f8a512f920..33e05929cb 100644
> --- a/target/ppc/translate/vmx-ops.c.inc
> +++ b/target/ppc/translate/vmx-ops.c.inc
> @@ -126,7 +126,6 @@ GEN_VXFORM(vsubuws, 0, 26),
> GEN_VXFORM_DUAL(vsubsbs, bcdtrunc, 0, 28, PPC_ALTIVEC, PPC2_ISA300),
> GEN_VXFORM(vsubshs, 0, 29),
> GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
> -GEN_VXFORM_207(vaddcuq, 0, 5),
> GEN_VXFORM_DUAL(vsubuqm, bcdtrunc, 0, 20, PPC2_ALTIVEC_207, PPC2_ISA300),
> GEN_VXFORM_DUAL(vsubcuq, bcdutrunc, 0, 21, PPC2_ALTIVEC_207, PPC2_ISA300),
> GEN_VXFORM_DUAL(vsubeuqm, vsubecuq, 31, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
> --
> 2.25.1
>
>
Reviewed-by: Víctor Colombo <victor.colombo@eldorado.org.br>
--
Víctor Cora Colombo
Instituto de Pesquisas ELDORADO
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 5/7] target/ppc: use int128.h methods in vsubuqm
2022-06-06 15:00 [PATCH 0/7] Remove CONFIG_INT128 conditional code from target/ppc/* Matheus Ferst
` (3 preceding siblings ...)
2022-06-06 15:00 ` [PATCH 4/7] target/ppc: use int128.h methods in vaddcuq Matheus Ferst
@ 2022-06-06 15:00 ` Matheus Ferst
2022-06-27 16:26 ` Víctor Colombo
2022-06-06 15:00 ` [PATCH 6/7] target/ppc: use int128.h methods in vsubecuq and vsubeuqm Matheus Ferst
` (2 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Matheus Ferst @ 2022-06-06 15:00 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson, Matheus Ferst
And also move the insn to decodetree
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
target/ppc/helper.h | 2 +-
target/ppc/insn32.decode | 2 ++
target/ppc/int_helper.c | 19 ++-----------------
target/ppc/translate/vmx-impl.c.inc | 5 ++---
target/ppc/translate/vmx-ops.c.inc | 2 +-
5 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index f6b1b2fad2..1c02ad85e5 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -208,7 +208,7 @@ DEF_HELPER_FLAGS_3(VADDUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_4(VADDECUQ, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
DEF_HELPER_FLAGS_4(VADDEUQM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
DEF_HELPER_FLAGS_3(VADDCUQ, TCG_CALL_NO_RWG, void, avr, avr, avr)
-DEF_HELPER_FLAGS_3(vsubuqm, TCG_CALL_NO_RWG, void, avr, avr, avr)
+DEF_HELPER_FLAGS_3(VSUBUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_4(vsubecuq, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
DEF_HELPER_FLAGS_4(vsubeuqm, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
DEF_HELPER_FLAGS_3(vsubcuq, TCG_CALL_NO_RWG, void, avr, avr, avr)
diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
index 35252ddd4f..a8d3a5a8a1 100644
--- a/target/ppc/insn32.decode
+++ b/target/ppc/insn32.decode
@@ -556,6 +556,8 @@ VADDUQM 000100 ..... ..... ..... 00100000000 @VX
VADDEUQM 000100 ..... ..... ..... ..... 111100 @VA
VADDECUQ 000100 ..... ..... ..... ..... 111101 @VA
+VSUBUQM 000100 ..... ..... ..... 10100000000 @VX
+
VEXTSB2W 000100 ..... 10000 ..... 11000000010 @VX_tb
VEXTSH2W 000100 ..... 10001 ..... 11000000010 @VX_tb
VEXTSB2D 000100 ..... 11000 ..... 11000000010 @VX_tb
diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
index a12f2831ac..625cc92a55 100644
--- a/target/ppc/int_helper.c
+++ b/target/ppc/int_helper.c
@@ -2176,12 +2176,6 @@ VGENERIC_DO(popcntd, u64)
#undef VGENERIC_DO
-#if HOST_BIG_ENDIAN
-#define QW_ONE { .u64 = { 0, 1 } }
-#else
-#define QW_ONE { .u64 = { 1, 0 } }
-#endif
-
#ifndef CONFIG_INT128
static inline void avr_qw_not(ppc_avr_t *t, ppc_avr_t a)
@@ -2245,18 +2239,9 @@ void helper_VADDECUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
r->VsrD(1) = carry_out;
}
-void helper_vsubuqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
+void helper_VSUBUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
{
-#ifdef CONFIG_INT128
- r->u128 = a->u128 - b->u128;
-#else
- ppc_avr_t tmp;
- ppc_avr_t one = QW_ONE;
-
- avr_qw_not(&tmp, *b);
- avr_qw_add(&tmp, *a, tmp);
- avr_qw_add(r, tmp, one);
-#endif
+ r->s128 = int128_sub(a->s128, b->s128);
}
void helper_vsubeuqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
diff --git a/target/ppc/translate/vmx-impl.c.inc b/target/ppc/translate/vmx-impl.c.inc
index 8c0e5bcc03..1e665534c3 100644
--- a/target/ppc/translate/vmx-impl.c.inc
+++ b/target/ppc/translate/vmx-impl.c.inc
@@ -1234,7 +1234,6 @@ GEN_VXFORM_SAT(vsubuws, MO_32, sub, ussub, 0, 26);
GEN_VXFORM_SAT(vsubsbs, MO_8, sub, sssub, 0, 28);
GEN_VXFORM_SAT(vsubshs, MO_16, sub, sssub, 0, 29);
GEN_VXFORM_SAT(vsubsws, MO_32, sub, sssub, 0, 30);
-GEN_VXFORM(vsubuqm, 0, 20);
GEN_VXFORM(vsubcuq, 0, 21);
GEN_VXFORM3(vsubeuqm, 31, 0);
GEN_VXFORM3(vsubecuq, 31, 0);
@@ -2858,8 +2857,6 @@ GEN_VXFORM_DUAL(vsubuwm, PPC_ALTIVEC, PPC_NONE, \
bcdus, PPC_NONE, PPC2_ISA300)
GEN_VXFORM_DUAL(vsubsbs, PPC_ALTIVEC, PPC_NONE, \
bcdtrunc, PPC_NONE, PPC2_ISA300)
-GEN_VXFORM_DUAL(vsubuqm, PPC2_ALTIVEC_207, PPC_NONE, \
- bcdtrunc, PPC_NONE, PPC2_ISA300)
GEN_VXFORM_DUAL(vsubcuq, PPC2_ALTIVEC_207, PPC_NONE, \
bcdutrunc, PPC_NONE, PPC2_ISA300)
@@ -3102,6 +3099,8 @@ TRANS_FLAGS2(ALTIVEC_207, VADDUQM, do_vx_helper, gen_helper_VADDUQM)
TRANS_FLAGS2(ALTIVEC_207, VPMSUMD, do_vx_helper, gen_helper_VPMSUMD)
+TRANS_FLAGS2(ALTIVEC_207, VSUBUQM, do_vx_helper, gen_helper_VSUBUQM)
+
static bool do_vx_vmuleo(DisasContext *ctx, arg_VX *a, bool even,
void (*gen_mul)(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_i64))
{
diff --git a/target/ppc/translate/vmx-ops.c.inc b/target/ppc/translate/vmx-ops.c.inc
index 33e05929cb..9feef9afee 100644
--- a/target/ppc/translate/vmx-ops.c.inc
+++ b/target/ppc/translate/vmx-ops.c.inc
@@ -126,7 +126,7 @@ GEN_VXFORM(vsubuws, 0, 26),
GEN_VXFORM_DUAL(vsubsbs, bcdtrunc, 0, 28, PPC_ALTIVEC, PPC2_ISA300),
GEN_VXFORM(vsubshs, 0, 29),
GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
-GEN_VXFORM_DUAL(vsubuqm, bcdtrunc, 0, 20, PPC2_ALTIVEC_207, PPC2_ISA300),
+GEN_VXFORM_300(bcdtrunc, 0, 20),
GEN_VXFORM_DUAL(vsubcuq, bcdutrunc, 0, 21, PPC2_ALTIVEC_207, PPC2_ISA300),
GEN_VXFORM_DUAL(vsubeuqm, vsubecuq, 31, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
GEN_VXFORM(vsl, 2, 7),
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 5/7] target/ppc: use int128.h methods in vsubuqm
2022-06-06 15:00 ` [PATCH 5/7] target/ppc: use int128.h methods in vsubuqm Matheus Ferst
@ 2022-06-27 16:26 ` Víctor Colombo
0 siblings, 0 replies; 16+ messages in thread
From: Víctor Colombo @ 2022-06-27 16:26 UTC (permalink / raw)
To: Matheus Ferst, qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson
On 06/06/2022 12:00, Matheus Ferst wrote:
> And also move the insn to decodetree
>
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
> ---
> target/ppc/helper.h | 2 +-
> target/ppc/insn32.decode | 2 ++
> target/ppc/int_helper.c | 19 ++-----------------
> target/ppc/translate/vmx-impl.c.inc | 5 ++---
> target/ppc/translate/vmx-ops.c.inc | 2 +-
> 5 files changed, 8 insertions(+), 22 deletions(-)
>
> diff --git a/target/ppc/helper.h b/target/ppc/helper.h
> index f6b1b2fad2..1c02ad85e5 100644
> --- a/target/ppc/helper.h
> +++ b/target/ppc/helper.h
> @@ -208,7 +208,7 @@ DEF_HELPER_FLAGS_3(VADDUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
> DEF_HELPER_FLAGS_4(VADDECUQ, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> DEF_HELPER_FLAGS_4(VADDEUQM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> DEF_HELPER_FLAGS_3(VADDCUQ, TCG_CALL_NO_RWG, void, avr, avr, avr)
> -DEF_HELPER_FLAGS_3(vsubuqm, TCG_CALL_NO_RWG, void, avr, avr, avr)
> +DEF_HELPER_FLAGS_3(VSUBUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
> DEF_HELPER_FLAGS_4(vsubecuq, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> DEF_HELPER_FLAGS_4(vsubeuqm, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> DEF_HELPER_FLAGS_3(vsubcuq, TCG_CALL_NO_RWG, void, avr, avr, avr)
> diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
> index 35252ddd4f..a8d3a5a8a1 100644
> --- a/target/ppc/insn32.decode
> +++ b/target/ppc/insn32.decode
> @@ -556,6 +556,8 @@ VADDUQM 000100 ..... ..... ..... 00100000000 @VX
> VADDEUQM 000100 ..... ..... ..... ..... 111100 @VA
> VADDECUQ 000100 ..... ..... ..... ..... 111101 @VA
>
> +VSUBUQM 000100 ..... ..... ..... 10100000000 @VX
> +
> VEXTSB2W 000100 ..... 10000 ..... 11000000010 @VX_tb
> VEXTSH2W 000100 ..... 10001 ..... 11000000010 @VX_tb
> VEXTSB2D 000100 ..... 11000 ..... 11000000010 @VX_tb
> diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
> index a12f2831ac..625cc92a55 100644
> --- a/target/ppc/int_helper.c
> +++ b/target/ppc/int_helper.c
> @@ -2176,12 +2176,6 @@ VGENERIC_DO(popcntd, u64)
>
> #undef VGENERIC_DO
>
> -#if HOST_BIG_ENDIAN
> -#define QW_ONE { .u64 = { 0, 1 } }
> -#else
> -#define QW_ONE { .u64 = { 1, 0 } }
> -#endif
> -
> #ifndef CONFIG_INT128
>
> static inline void avr_qw_not(ppc_avr_t *t, ppc_avr_t a)
> @@ -2245,18 +2239,9 @@ void helper_VADDECUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> r->VsrD(1) = carry_out;
> }
>
> -void helper_vsubuqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> +void helper_VSUBUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> {
> -#ifdef CONFIG_INT128
> - r->u128 = a->u128 - b->u128;
> -#else
> - ppc_avr_t tmp;
> - ppc_avr_t one = QW_ONE;
> -
> - avr_qw_not(&tmp, *b);
> - avr_qw_add(&tmp, *a, tmp);
> - avr_qw_add(r, tmp, one);
> -#endif
> + r->s128 = int128_sub(a->s128, b->s128);
> }
>
> void helper_vsubeuqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> diff --git a/target/ppc/translate/vmx-impl.c.inc b/target/ppc/translate/vmx-impl.c.inc
> index 8c0e5bcc03..1e665534c3 100644
> --- a/target/ppc/translate/vmx-impl.c.inc
> +++ b/target/ppc/translate/vmx-impl.c.inc
> @@ -1234,7 +1234,6 @@ GEN_VXFORM_SAT(vsubuws, MO_32, sub, ussub, 0, 26);
> GEN_VXFORM_SAT(vsubsbs, MO_8, sub, sssub, 0, 28);
> GEN_VXFORM_SAT(vsubshs, MO_16, sub, sssub, 0, 29);
> GEN_VXFORM_SAT(vsubsws, MO_32, sub, sssub, 0, 30);
> -GEN_VXFORM(vsubuqm, 0, 20);
> GEN_VXFORM(vsubcuq, 0, 21);
> GEN_VXFORM3(vsubeuqm, 31, 0);
> GEN_VXFORM3(vsubecuq, 31, 0);
> @@ -2858,8 +2857,6 @@ GEN_VXFORM_DUAL(vsubuwm, PPC_ALTIVEC, PPC_NONE, \
> bcdus, PPC_NONE, PPC2_ISA300)
> GEN_VXFORM_DUAL(vsubsbs, PPC_ALTIVEC, PPC_NONE, \
> bcdtrunc, PPC_NONE, PPC2_ISA300)
> -GEN_VXFORM_DUAL(vsubuqm, PPC2_ALTIVEC_207, PPC_NONE, \
> - bcdtrunc, PPC_NONE, PPC2_ISA300)
> GEN_VXFORM_DUAL(vsubcuq, PPC2_ALTIVEC_207, PPC_NONE, \
> bcdutrunc, PPC_NONE, PPC2_ISA300)
>
> @@ -3102,6 +3099,8 @@ TRANS_FLAGS2(ALTIVEC_207, VADDUQM, do_vx_helper, gen_helper_VADDUQM)
>
> TRANS_FLAGS2(ALTIVEC_207, VPMSUMD, do_vx_helper, gen_helper_VPMSUMD)
>
> +TRANS_FLAGS2(ALTIVEC_207, VSUBUQM, do_vx_helper, gen_helper_VSUBUQM)
> +
> static bool do_vx_vmuleo(DisasContext *ctx, arg_VX *a, bool even,
> void (*gen_mul)(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_i64))
> {
> diff --git a/target/ppc/translate/vmx-ops.c.inc b/target/ppc/translate/vmx-ops.c.inc
> index 33e05929cb..9feef9afee 100644
> --- a/target/ppc/translate/vmx-ops.c.inc
> +++ b/target/ppc/translate/vmx-ops.c.inc
> @@ -126,7 +126,7 @@ GEN_VXFORM(vsubuws, 0, 26),
> GEN_VXFORM_DUAL(vsubsbs, bcdtrunc, 0, 28, PPC_ALTIVEC, PPC2_ISA300),
> GEN_VXFORM(vsubshs, 0, 29),
> GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
> -GEN_VXFORM_DUAL(vsubuqm, bcdtrunc, 0, 20, PPC2_ALTIVEC_207, PPC2_ISA300),
> +GEN_VXFORM_300(bcdtrunc, 0, 20),
> GEN_VXFORM_DUAL(vsubcuq, bcdutrunc, 0, 21, PPC2_ALTIVEC_207, PPC2_ISA300),
> GEN_VXFORM_DUAL(vsubeuqm, vsubecuq, 31, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
> GEN_VXFORM(vsl, 2, 7),
> --
> 2.25.1
>
>
Reviewed-by: Víctor Colombo <victor.colombo@eldorado.org.br>
--
Víctor Cora Colombo
Instituto de Pesquisas ELDORADO
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/7] target/ppc: use int128.h methods in vsubecuq and vsubeuqm
2022-06-06 15:00 [PATCH 0/7] Remove CONFIG_INT128 conditional code from target/ppc/* Matheus Ferst
` (4 preceding siblings ...)
2022-06-06 15:00 ` [PATCH 5/7] target/ppc: use int128.h methods in vsubuqm Matheus Ferst
@ 2022-06-06 15:00 ` Matheus Ferst
2022-06-27 16:26 ` Víctor Colombo
2022-06-06 15:00 ` [PATCH 7/7] target/ppc: use int128.h methods in vsubcuq Matheus Ferst
2022-06-27 21:41 ` [PATCH 0/7] Remove CONFIG_INT128 conditional code from target/ppc/* Daniel Henrique Barboza
7 siblings, 1 reply; 16+ messages in thread
From: Matheus Ferst @ 2022-06-06 15:00 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson, Matheus Ferst
And also move the insns to decodetree.
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
target/ppc/helper.h | 4 +--
target/ppc/insn32.decode | 3 +++
target/ppc/int_helper.c | 38 +++++++----------------------
target/ppc/translate/vmx-impl.c.inc | 7 +++---
target/ppc/translate/vmx-ops.c.inc | 1 -
5 files changed, 17 insertions(+), 36 deletions(-)
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index 1c02ad85e5..04ced6ef70 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -209,8 +209,8 @@ DEF_HELPER_FLAGS_4(VADDECUQ, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
DEF_HELPER_FLAGS_4(VADDEUQM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
DEF_HELPER_FLAGS_3(VADDCUQ, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_3(VSUBUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
-DEF_HELPER_FLAGS_4(vsubecuq, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
-DEF_HELPER_FLAGS_4(vsubeuqm, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
+DEF_HELPER_FLAGS_4(VSUBECUQ, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
+DEF_HELPER_FLAGS_4(VSUBEUQM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
DEF_HELPER_FLAGS_3(vsubcuq, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_4(vsldoi, TCG_CALL_NO_RWG, void, avr, avr, avr, i32)
DEF_HELPER_FLAGS_3(vextractub, TCG_CALL_NO_RWG, void, avr, avr, i32)
diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
index a8d3a5a8a1..5e6f3b668e 100644
--- a/target/ppc/insn32.decode
+++ b/target/ppc/insn32.decode
@@ -558,6 +558,9 @@ VADDECUQ 000100 ..... ..... ..... ..... 111101 @VA
VSUBUQM 000100 ..... ..... ..... 10100000000 @VX
+VSUBECUQ 000100 ..... ..... ..... ..... 111111 @VA
+VSUBEUQM 000100 ..... ..... ..... ..... 111110 @VA
+
VEXTSB2W 000100 ..... 10000 ..... 11000000010 @VX_tb
VEXTSH2W 000100 ..... 10001 ..... 11000000010 @VX_tb
VEXTSB2D 000100 ..... 11000 ..... 11000000010 @VX_tb
diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
index 625cc92a55..c995f8de77 100644
--- a/target/ppc/int_helper.c
+++ b/target/ppc/int_helper.c
@@ -2244,20 +2244,10 @@ void helper_VSUBUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
r->s128 = int128_sub(a->s128, b->s128);
}
-void helper_vsubeuqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
+void helper_VSUBEUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
{
-#ifdef CONFIG_INT128
- r->u128 = a->u128 + ~b->u128 + (c->u128 & 1);
-#else
- ppc_avr_t tmp, sum;
-
- avr_qw_not(&tmp, *b);
- avr_qw_add(&sum, *a, tmp);
-
- tmp.VsrD(0) = 0;
- tmp.VsrD(1) = c->VsrD(1) & 1;
- avr_qw_add(r, sum, tmp);
-#endif
+ r->s128 = int128_add(int128_add(a->s128, int128_not(b->s128)),
+ int128_make64(int128_getlo(c->s128) & 1));
}
void helper_vsubcuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
@@ -2278,25 +2268,15 @@ void helper_vsubcuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
#endif
}
-void helper_vsubecuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
+void helper_VSUBECUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
{
-#ifdef CONFIG_INT128
- r->u128 =
- (~a->u128 < ~b->u128) ||
- ((c->u128 & 1) && (a->u128 + ~b->u128 == (__uint128_t)-1));
-#else
- int carry_in = c->VsrD(1) & 1;
- int carry_out = (avr_qw_cmpu(*a, *b) > 0);
- if (!carry_out && carry_in) {
- ppc_avr_t tmp;
- avr_qw_not(&tmp, *b);
- avr_qw_add(&tmp, *a, tmp);
- carry_out = ((tmp.VsrD(0) == -1ull) && (tmp.VsrD(1) == -1ull));
- }
+ Int128 tmp = int128_not(b->s128);
+ bool carry_out = int128_ult(int128_not(a->s128), tmp),
+ carry_in = int128_getlo(c->s128) & 1;
+ r->VsrD(1) = carry_out || (carry_in && int128_eq(int128_add(a->s128, tmp),
+ int128_makes64(-1)));
r->VsrD(0) = 0;
- r->VsrD(1) = carry_out;
-#endif
}
#define BCD_PLUS_PREF_1 0xC
diff --git a/target/ppc/translate/vmx-impl.c.inc b/target/ppc/translate/vmx-impl.c.inc
index 1e665534c3..671992f7d1 100644
--- a/target/ppc/translate/vmx-impl.c.inc
+++ b/target/ppc/translate/vmx-impl.c.inc
@@ -1235,10 +1235,6 @@ GEN_VXFORM_SAT(vsubsbs, MO_8, sub, sssub, 0, 28);
GEN_VXFORM_SAT(vsubshs, MO_16, sub, sssub, 0, 29);
GEN_VXFORM_SAT(vsubsws, MO_32, sub, sssub, 0, 30);
GEN_VXFORM(vsubcuq, 0, 21);
-GEN_VXFORM3(vsubeuqm, 31, 0);
-GEN_VXFORM3(vsubecuq, 31, 0);
-GEN_VXFORM_DUAL(vsubeuqm, PPC_NONE, PPC2_ALTIVEC_207, \
- vsubecuq, PPC_NONE, PPC2_ALTIVEC_207)
GEN_VXFORM_TRANS(vsl, 2, 7);
GEN_VXFORM_TRANS(vsr, 2, 11);
GEN_VXFORM_ENV(vpkuhum, 7, 0);
@@ -2568,6 +2564,9 @@ static bool do_va_helper(DisasContext *ctx, arg_VA *a,
TRANS_FLAGS2(ALTIVEC_207, VADDECUQ, do_va_helper, gen_helper_VADDECUQ)
TRANS_FLAGS2(ALTIVEC_207, VADDEUQM, do_va_helper, gen_helper_VADDEUQM)
+TRANS_FLAGS2(ALTIVEC_207, VSUBEUQM, do_va_helper, gen_helper_VSUBEUQM)
+TRANS_FLAGS2(ALTIVEC_207, VSUBECUQ, do_va_helper, gen_helper_VSUBECUQ)
+
TRANS_FLAGS(ALTIVEC, VPERM, do_va_helper, gen_helper_VPERM)
TRANS_FLAGS2(ISA300, VPERMR, do_va_helper, gen_helper_VPERMR)
diff --git a/target/ppc/translate/vmx-ops.c.inc b/target/ppc/translate/vmx-ops.c.inc
index 9feef9afee..9395806f3d 100644
--- a/target/ppc/translate/vmx-ops.c.inc
+++ b/target/ppc/translate/vmx-ops.c.inc
@@ -128,7 +128,6 @@ GEN_VXFORM(vsubshs, 0, 29),
GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
GEN_VXFORM_300(bcdtrunc, 0, 20),
GEN_VXFORM_DUAL(vsubcuq, bcdutrunc, 0, 21, PPC2_ALTIVEC_207, PPC2_ISA300),
-GEN_VXFORM_DUAL(vsubeuqm, vsubecuq, 31, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
GEN_VXFORM(vsl, 2, 7),
GEN_VXFORM(vsr, 2, 11),
GEN_VXFORM(vpkuhum, 7, 0),
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 6/7] target/ppc: use int128.h methods in vsubecuq and vsubeuqm
2022-06-06 15:00 ` [PATCH 6/7] target/ppc: use int128.h methods in vsubecuq and vsubeuqm Matheus Ferst
@ 2022-06-27 16:26 ` Víctor Colombo
0 siblings, 0 replies; 16+ messages in thread
From: Víctor Colombo @ 2022-06-27 16:26 UTC (permalink / raw)
To: Matheus Ferst, qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson
On 06/06/2022 12:00, Matheus Ferst wrote:
> And also move the insns to decodetree.
>
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
> ---
> target/ppc/helper.h | 4 +--
> target/ppc/insn32.decode | 3 +++
> target/ppc/int_helper.c | 38 +++++++----------------------
> target/ppc/translate/vmx-impl.c.inc | 7 +++---
> target/ppc/translate/vmx-ops.c.inc | 1 -
> 5 files changed, 17 insertions(+), 36 deletions(-)
>
> diff --git a/target/ppc/helper.h b/target/ppc/helper.h
> index 1c02ad85e5..04ced6ef70 100644
> --- a/target/ppc/helper.h
> +++ b/target/ppc/helper.h
> @@ -209,8 +209,8 @@ DEF_HELPER_FLAGS_4(VADDECUQ, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> DEF_HELPER_FLAGS_4(VADDEUQM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> DEF_HELPER_FLAGS_3(VADDCUQ, TCG_CALL_NO_RWG, void, avr, avr, avr)
> DEF_HELPER_FLAGS_3(VSUBUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
> -DEF_HELPER_FLAGS_4(vsubecuq, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> -DEF_HELPER_FLAGS_4(vsubeuqm, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> +DEF_HELPER_FLAGS_4(VSUBECUQ, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> +DEF_HELPER_FLAGS_4(VSUBEUQM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> DEF_HELPER_FLAGS_3(vsubcuq, TCG_CALL_NO_RWG, void, avr, avr, avr)
> DEF_HELPER_FLAGS_4(vsldoi, TCG_CALL_NO_RWG, void, avr, avr, avr, i32)
> DEF_HELPER_FLAGS_3(vextractub, TCG_CALL_NO_RWG, void, avr, avr, i32)
> diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
> index a8d3a5a8a1..5e6f3b668e 100644
> --- a/target/ppc/insn32.decode
> +++ b/target/ppc/insn32.decode
> @@ -558,6 +558,9 @@ VADDECUQ 000100 ..... ..... ..... ..... 111101 @VA
>
> VSUBUQM 000100 ..... ..... ..... 10100000000 @VX
>
> +VSUBECUQ 000100 ..... ..... ..... ..... 111111 @VA
> +VSUBEUQM 000100 ..... ..... ..... ..... 111110 @VA
> +
> VEXTSB2W 000100 ..... 10000 ..... 11000000010 @VX_tb
> VEXTSH2W 000100 ..... 10001 ..... 11000000010 @VX_tb
> VEXTSB2D 000100 ..... 11000 ..... 11000000010 @VX_tb
> diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
> index 625cc92a55..c995f8de77 100644
> --- a/target/ppc/int_helper.c
> +++ b/target/ppc/int_helper.c
> @@ -2244,20 +2244,10 @@ void helper_VSUBUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> r->s128 = int128_sub(a->s128, b->s128);
> }
>
> -void helper_vsubeuqm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> +void helper_VSUBEUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> {
> -#ifdef CONFIG_INT128
> - r->u128 = a->u128 + ~b->u128 + (c->u128 & 1);
> -#else
> - ppc_avr_t tmp, sum;
> -
> - avr_qw_not(&tmp, *b);
> - avr_qw_add(&sum, *a, tmp);
> -
> - tmp.VsrD(0) = 0;
> - tmp.VsrD(1) = c->VsrD(1) & 1;
> - avr_qw_add(r, sum, tmp);
> -#endif
> + r->s128 = int128_add(int128_add(a->s128, int128_not(b->s128)),
> + int128_make64(int128_getlo(c->s128) & 1));
> }
>
> void helper_vsubcuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> @@ -2278,25 +2268,15 @@ void helper_vsubcuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> #endif
> }
>
> -void helper_vsubecuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> +void helper_VSUBECUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> {
> -#ifdef CONFIG_INT128
> - r->u128 =
> - (~a->u128 < ~b->u128) ||
> - ((c->u128 & 1) && (a->u128 + ~b->u128 == (__uint128_t)-1));
> -#else
> - int carry_in = c->VsrD(1) & 1;
> - int carry_out = (avr_qw_cmpu(*a, *b) > 0);
> - if (!carry_out && carry_in) {
> - ppc_avr_t tmp;
> - avr_qw_not(&tmp, *b);
> - avr_qw_add(&tmp, *a, tmp);
> - carry_out = ((tmp.VsrD(0) == -1ull) && (tmp.VsrD(1) == -1ull));
> - }
> + Int128 tmp = int128_not(b->s128);
> + bool carry_out = int128_ult(int128_not(a->s128), tmp),
> + carry_in = int128_getlo(c->s128) & 1;
>
> + r->VsrD(1) = carry_out || (carry_in && int128_eq(int128_add(a->s128, tmp),
> + int128_makes64(-1)));
> r->VsrD(0) = 0;
> - r->VsrD(1) = carry_out;
> -#endif
> }
>
> #define BCD_PLUS_PREF_1 0xC
> diff --git a/target/ppc/translate/vmx-impl.c.inc b/target/ppc/translate/vmx-impl.c.inc
> index 1e665534c3..671992f7d1 100644
> --- a/target/ppc/translate/vmx-impl.c.inc
> +++ b/target/ppc/translate/vmx-impl.c.inc
> @@ -1235,10 +1235,6 @@ GEN_VXFORM_SAT(vsubsbs, MO_8, sub, sssub, 0, 28);
> GEN_VXFORM_SAT(vsubshs, MO_16, sub, sssub, 0, 29);
> GEN_VXFORM_SAT(vsubsws, MO_32, sub, sssub, 0, 30);
> GEN_VXFORM(vsubcuq, 0, 21);
> -GEN_VXFORM3(vsubeuqm, 31, 0);
> -GEN_VXFORM3(vsubecuq, 31, 0);
> -GEN_VXFORM_DUAL(vsubeuqm, PPC_NONE, PPC2_ALTIVEC_207, \
> - vsubecuq, PPC_NONE, PPC2_ALTIVEC_207)
> GEN_VXFORM_TRANS(vsl, 2, 7);
> GEN_VXFORM_TRANS(vsr, 2, 11);
> GEN_VXFORM_ENV(vpkuhum, 7, 0);
> @@ -2568,6 +2564,9 @@ static bool do_va_helper(DisasContext *ctx, arg_VA *a,
> TRANS_FLAGS2(ALTIVEC_207, VADDECUQ, do_va_helper, gen_helper_VADDECUQ)
> TRANS_FLAGS2(ALTIVEC_207, VADDEUQM, do_va_helper, gen_helper_VADDEUQM)
>
> +TRANS_FLAGS2(ALTIVEC_207, VSUBEUQM, do_va_helper, gen_helper_VSUBEUQM)
> +TRANS_FLAGS2(ALTIVEC_207, VSUBECUQ, do_va_helper, gen_helper_VSUBECUQ)
> +
> TRANS_FLAGS(ALTIVEC, VPERM, do_va_helper, gen_helper_VPERM)
> TRANS_FLAGS2(ISA300, VPERMR, do_va_helper, gen_helper_VPERMR)
>
> diff --git a/target/ppc/translate/vmx-ops.c.inc b/target/ppc/translate/vmx-ops.c.inc
> index 9feef9afee..9395806f3d 100644
> --- a/target/ppc/translate/vmx-ops.c.inc
> +++ b/target/ppc/translate/vmx-ops.c.inc
> @@ -128,7 +128,6 @@ GEN_VXFORM(vsubshs, 0, 29),
> GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
> GEN_VXFORM_300(bcdtrunc, 0, 20),
> GEN_VXFORM_DUAL(vsubcuq, bcdutrunc, 0, 21, PPC2_ALTIVEC_207, PPC2_ISA300),
> -GEN_VXFORM_DUAL(vsubeuqm, vsubecuq, 31, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
> GEN_VXFORM(vsl, 2, 7),
> GEN_VXFORM(vsr, 2, 11),
> GEN_VXFORM(vpkuhum, 7, 0),
> --
> 2.25.1
>
>
Reviewed-by: Víctor Colombo <victor.colombo@eldorado.org.br>
--
Víctor Cora Colombo
Instituto de Pesquisas ELDORADO
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 7/7] target/ppc: use int128.h methods in vsubcuq
2022-06-06 15:00 [PATCH 0/7] Remove CONFIG_INT128 conditional code from target/ppc/* Matheus Ferst
` (5 preceding siblings ...)
2022-06-06 15:00 ` [PATCH 6/7] target/ppc: use int128.h methods in vsubecuq and vsubeuqm Matheus Ferst
@ 2022-06-06 15:00 ` Matheus Ferst
2022-06-27 16:26 ` Víctor Colombo
2022-06-27 21:41 ` [PATCH 0/7] Remove CONFIG_INT128 conditional code from target/ppc/* Daniel Henrique Barboza
7 siblings, 1 reply; 16+ messages in thread
From: Matheus Ferst @ 2022-06-06 15:00 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson, Matheus Ferst
And also move the insn to decodetree and remove the now unused
avr_qw_not, avr_qw_cmpu, and avr_qw_add methods.
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
target/ppc/helper.h | 2 +-
target/ppc/insn32.decode | 1 +
target/ppc/int_helper.c | 51 +++--------------------------
target/ppc/translate/vmx-impl.c.inc | 5 +--
target/ppc/translate/vmx-ops.c.inc | 2 +-
5 files changed, 9 insertions(+), 52 deletions(-)
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index 04ced6ef70..84a41d85b0 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -211,7 +211,7 @@ DEF_HELPER_FLAGS_3(VADDCUQ, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_3(VSUBUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_4(VSUBECUQ, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
DEF_HELPER_FLAGS_4(VSUBEUQM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
-DEF_HELPER_FLAGS_3(vsubcuq, TCG_CALL_NO_RWG, void, avr, avr, avr)
+DEF_HELPER_FLAGS_3(VSUBCUQ, TCG_CALL_NO_RWG, void, avr, avr, avr)
DEF_HELPER_FLAGS_4(vsldoi, TCG_CALL_NO_RWG, void, avr, avr, avr, i32)
DEF_HELPER_FLAGS_3(vextractub, TCG_CALL_NO_RWG, void, avr, avr, i32)
DEF_HELPER_FLAGS_3(vextractuh, TCG_CALL_NO_RWG, void, avr, avr, i32)
diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
index 5e6f3b668e..65a6a42f78 100644
--- a/target/ppc/insn32.decode
+++ b/target/ppc/insn32.decode
@@ -556,6 +556,7 @@ VADDUQM 000100 ..... ..... ..... 00100000000 @VX
VADDEUQM 000100 ..... ..... ..... ..... 111100 @VA
VADDECUQ 000100 ..... ..... ..... ..... 111101 @VA
+VSUBCUQ 000100 ..... ..... ..... 10101000000 @VX
VSUBUQM 000100 ..... ..... ..... 10100000000 @VX
VSUBECUQ 000100 ..... ..... ..... ..... 111111 @VA
diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
index c995f8de77..f1a9fbf0c5 100644
--- a/target/ppc/int_helper.c
+++ b/target/ppc/int_helper.c
@@ -2176,38 +2176,6 @@ VGENERIC_DO(popcntd, u64)
#undef VGENERIC_DO
-#ifndef CONFIG_INT128
-
-static inline void avr_qw_not(ppc_avr_t *t, ppc_avr_t a)
-{
- t->u64[0] = ~a.u64[0];
- t->u64[1] = ~a.u64[1];
-}
-
-static int avr_qw_cmpu(ppc_avr_t a, ppc_avr_t b)
-{
- if (a.VsrD(0) < b.VsrD(0)) {
- return -1;
- } else if (a.VsrD(0) > b.VsrD(0)) {
- return 1;
- } else if (a.VsrD(1) < b.VsrD(1)) {
- return -1;
- } else if (a.VsrD(1) > b.VsrD(1)) {
- return 1;
- } else {
- return 0;
- }
-}
-
-static void avr_qw_add(ppc_avr_t *t, ppc_avr_t a, ppc_avr_t b)
-{
- t->VsrD(1) = a.VsrD(1) + b.VsrD(1);
- t->VsrD(0) = a.VsrD(0) + b.VsrD(0) +
- (~a.VsrD(1) < b.VsrD(1));
-}
-
-#endif
-
void helper_VADDUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
{
r->s128 = int128_add(a->s128, b->s128);
@@ -2250,22 +2218,13 @@ void helper_VSUBEUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
int128_make64(int128_getlo(c->s128) & 1));
}
-void helper_vsubcuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
+void helper_VSUBCUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
{
-#ifdef CONFIG_INT128
- r->u128 = (~a->u128 < ~b->u128) ||
- (a->u128 + ~b->u128 == (__uint128_t)-1);
-#else
- int carry = (avr_qw_cmpu(*a, *b) > 0);
- if (!carry) {
- ppc_avr_t tmp;
- avr_qw_not(&tmp, *b);
- avr_qw_add(&tmp, *a, tmp);
- carry = ((tmp.VsrSD(0) == -1ull) && (tmp.VsrSD(1) == -1ull));
- }
+ Int128 tmp = int128_not(b->s128);
+
+ r->VsrD(1) = int128_ult(int128_not(a->s128), tmp) ||
+ int128_eq(int128_add(a->s128, tmp), int128_makes64(-1));
r->VsrD(0) = 0;
- r->VsrD(1) = carry;
-#endif
}
void helper_VSUBECUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
diff --git a/target/ppc/translate/vmx-impl.c.inc b/target/ppc/translate/vmx-impl.c.inc
index 671992f7d1..e644ad3236 100644
--- a/target/ppc/translate/vmx-impl.c.inc
+++ b/target/ppc/translate/vmx-impl.c.inc
@@ -1234,7 +1234,6 @@ GEN_VXFORM_SAT(vsubuws, MO_32, sub, ussub, 0, 26);
GEN_VXFORM_SAT(vsubsbs, MO_8, sub, sssub, 0, 28);
GEN_VXFORM_SAT(vsubshs, MO_16, sub, sssub, 0, 29);
GEN_VXFORM_SAT(vsubsws, MO_32, sub, sssub, 0, 30);
-GEN_VXFORM(vsubcuq, 0, 21);
GEN_VXFORM_TRANS(vsl, 2, 7);
GEN_VXFORM_TRANS(vsr, 2, 11);
GEN_VXFORM_ENV(vpkuhum, 7, 0);
@@ -2856,9 +2855,6 @@ GEN_VXFORM_DUAL(vsubuwm, PPC_ALTIVEC, PPC_NONE, \
bcdus, PPC_NONE, PPC2_ISA300)
GEN_VXFORM_DUAL(vsubsbs, PPC_ALTIVEC, PPC_NONE, \
bcdtrunc, PPC_NONE, PPC2_ISA300)
-GEN_VXFORM_DUAL(vsubcuq, PPC2_ALTIVEC_207, PPC_NONE, \
- bcdutrunc, PPC_NONE, PPC2_ISA300)
-
static void gen_vsbox(DisasContext *ctx)
{
@@ -3098,6 +3094,7 @@ TRANS_FLAGS2(ALTIVEC_207, VADDUQM, do_vx_helper, gen_helper_VADDUQM)
TRANS_FLAGS2(ALTIVEC_207, VPMSUMD, do_vx_helper, gen_helper_VPMSUMD)
+TRANS_FLAGS2(ALTIVEC_207, VSUBCUQ, do_vx_helper, gen_helper_VSUBCUQ)
TRANS_FLAGS2(ALTIVEC_207, VSUBUQM, do_vx_helper, gen_helper_VSUBUQM)
static bool do_vx_vmuleo(DisasContext *ctx, arg_VX *a, bool even,
diff --git a/target/ppc/translate/vmx-ops.c.inc b/target/ppc/translate/vmx-ops.c.inc
index 9395806f3d..a3a0fd0650 100644
--- a/target/ppc/translate/vmx-ops.c.inc
+++ b/target/ppc/translate/vmx-ops.c.inc
@@ -127,7 +127,7 @@ GEN_VXFORM_DUAL(vsubsbs, bcdtrunc, 0, 28, PPC_ALTIVEC, PPC2_ISA300),
GEN_VXFORM(vsubshs, 0, 29),
GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
GEN_VXFORM_300(bcdtrunc, 0, 20),
-GEN_VXFORM_DUAL(vsubcuq, bcdutrunc, 0, 21, PPC2_ALTIVEC_207, PPC2_ISA300),
+GEN_VXFORM_300(bcdutrunc, 0, 21),
GEN_VXFORM(vsl, 2, 7),
GEN_VXFORM(vsr, 2, 11),
GEN_VXFORM(vpkuhum, 7, 0),
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 7/7] target/ppc: use int128.h methods in vsubcuq
2022-06-06 15:00 ` [PATCH 7/7] target/ppc: use int128.h methods in vsubcuq Matheus Ferst
@ 2022-06-27 16:26 ` Víctor Colombo
0 siblings, 0 replies; 16+ messages in thread
From: Víctor Colombo @ 2022-06-27 16:26 UTC (permalink / raw)
To: Matheus Ferst, qemu-devel, qemu-ppc
Cc: clg, danielhb413, david, groug, richard.henderson
On 06/06/2022 12:00, Matheus Ferst wrote:
> And also move the insn to decodetree and remove the now unused
> avr_qw_not, avr_qw_cmpu, and avr_qw_add methods.
>
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
> ---
> target/ppc/helper.h | 2 +-
> target/ppc/insn32.decode | 1 +
> target/ppc/int_helper.c | 51 +++--------------------------
> target/ppc/translate/vmx-impl.c.inc | 5 +--
> target/ppc/translate/vmx-ops.c.inc | 2 +-
> 5 files changed, 9 insertions(+), 52 deletions(-)
>
> diff --git a/target/ppc/helper.h b/target/ppc/helper.h
> index 04ced6ef70..84a41d85b0 100644
> --- a/target/ppc/helper.h
> +++ b/target/ppc/helper.h
> @@ -211,7 +211,7 @@ DEF_HELPER_FLAGS_3(VADDCUQ, TCG_CALL_NO_RWG, void, avr, avr, avr)
> DEF_HELPER_FLAGS_3(VSUBUQM, TCG_CALL_NO_RWG, void, avr, avr, avr)
> DEF_HELPER_FLAGS_4(VSUBECUQ, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> DEF_HELPER_FLAGS_4(VSUBEUQM, TCG_CALL_NO_RWG, void, avr, avr, avr, avr)
> -DEF_HELPER_FLAGS_3(vsubcuq, TCG_CALL_NO_RWG, void, avr, avr, avr)
> +DEF_HELPER_FLAGS_3(VSUBCUQ, TCG_CALL_NO_RWG, void, avr, avr, avr)
> DEF_HELPER_FLAGS_4(vsldoi, TCG_CALL_NO_RWG, void, avr, avr, avr, i32)
> DEF_HELPER_FLAGS_3(vextractub, TCG_CALL_NO_RWG, void, avr, avr, i32)
> DEF_HELPER_FLAGS_3(vextractuh, TCG_CALL_NO_RWG, void, avr, avr, i32)
> diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
> index 5e6f3b668e..65a6a42f78 100644
> --- a/target/ppc/insn32.decode
> +++ b/target/ppc/insn32.decode
> @@ -556,6 +556,7 @@ VADDUQM 000100 ..... ..... ..... 00100000000 @VX
> VADDEUQM 000100 ..... ..... ..... ..... 111100 @VA
> VADDECUQ 000100 ..... ..... ..... ..... 111101 @VA
>
> +VSUBCUQ 000100 ..... ..... ..... 10101000000 @VX
> VSUBUQM 000100 ..... ..... ..... 10100000000 @VX
>
> VSUBECUQ 000100 ..... ..... ..... ..... 111111 @VA
> diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
> index c995f8de77..f1a9fbf0c5 100644
> --- a/target/ppc/int_helper.c
> +++ b/target/ppc/int_helper.c
> @@ -2176,38 +2176,6 @@ VGENERIC_DO(popcntd, u64)
>
> #undef VGENERIC_DO
>
> -#ifndef CONFIG_INT128
> -
> -static inline void avr_qw_not(ppc_avr_t *t, ppc_avr_t a)
> -{
> - t->u64[0] = ~a.u64[0];
> - t->u64[1] = ~a.u64[1];
> -}
> -
> -static int avr_qw_cmpu(ppc_avr_t a, ppc_avr_t b)
> -{
> - if (a.VsrD(0) < b.VsrD(0)) {
> - return -1;
> - } else if (a.VsrD(0) > b.VsrD(0)) {
> - return 1;
> - } else if (a.VsrD(1) < b.VsrD(1)) {
> - return -1;
> - } else if (a.VsrD(1) > b.VsrD(1)) {
> - return 1;
> - } else {
> - return 0;
> - }
> -}
> -
> -static void avr_qw_add(ppc_avr_t *t, ppc_avr_t a, ppc_avr_t b)
> -{
> - t->VsrD(1) = a.VsrD(1) + b.VsrD(1);
> - t->VsrD(0) = a.VsrD(0) + b.VsrD(0) +
> - (~a.VsrD(1) < b.VsrD(1));
> -}
> -
> -#endif
> -
> void helper_VADDUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> {
> r->s128 = int128_add(a->s128, b->s128);
> @@ -2250,22 +2218,13 @@ void helper_VSUBEUQM(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> int128_make64(int128_getlo(c->s128) & 1));
> }
>
> -void helper_vsubcuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> +void helper_VSUBCUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> {
> -#ifdef CONFIG_INT128
> - r->u128 = (~a->u128 < ~b->u128) ||
> - (a->u128 + ~b->u128 == (__uint128_t)-1);
> -#else
> - int carry = (avr_qw_cmpu(*a, *b) > 0);
> - if (!carry) {
> - ppc_avr_t tmp;
> - avr_qw_not(&tmp, *b);
> - avr_qw_add(&tmp, *a, tmp);
> - carry = ((tmp.VsrSD(0) == -1ull) && (tmp.VsrSD(1) == -1ull));
> - }
> + Int128 tmp = int128_not(b->s128);
> +
> + r->VsrD(1) = int128_ult(int128_not(a->s128), tmp) ||
> + int128_eq(int128_add(a->s128, tmp), int128_makes64(-1));
> r->VsrD(0) = 0;
> - r->VsrD(1) = carry;
> -#endif
> }
>
> void helper_VSUBECUQ(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> diff --git a/target/ppc/translate/vmx-impl.c.inc b/target/ppc/translate/vmx-impl.c.inc
> index 671992f7d1..e644ad3236 100644
> --- a/target/ppc/translate/vmx-impl.c.inc
> +++ b/target/ppc/translate/vmx-impl.c.inc
> @@ -1234,7 +1234,6 @@ GEN_VXFORM_SAT(vsubuws, MO_32, sub, ussub, 0, 26);
> GEN_VXFORM_SAT(vsubsbs, MO_8, sub, sssub, 0, 28);
> GEN_VXFORM_SAT(vsubshs, MO_16, sub, sssub, 0, 29);
> GEN_VXFORM_SAT(vsubsws, MO_32, sub, sssub, 0, 30);
> -GEN_VXFORM(vsubcuq, 0, 21);
> GEN_VXFORM_TRANS(vsl, 2, 7);
> GEN_VXFORM_TRANS(vsr, 2, 11);
> GEN_VXFORM_ENV(vpkuhum, 7, 0);
> @@ -2856,9 +2855,6 @@ GEN_VXFORM_DUAL(vsubuwm, PPC_ALTIVEC, PPC_NONE, \
> bcdus, PPC_NONE, PPC2_ISA300)
> GEN_VXFORM_DUAL(vsubsbs, PPC_ALTIVEC, PPC_NONE, \
> bcdtrunc, PPC_NONE, PPC2_ISA300)
> -GEN_VXFORM_DUAL(vsubcuq, PPC2_ALTIVEC_207, PPC_NONE, \
> - bcdutrunc, PPC_NONE, PPC2_ISA300)
> -
>
> static void gen_vsbox(DisasContext *ctx)
> {
> @@ -3098,6 +3094,7 @@ TRANS_FLAGS2(ALTIVEC_207, VADDUQM, do_vx_helper, gen_helper_VADDUQM)
>
> TRANS_FLAGS2(ALTIVEC_207, VPMSUMD, do_vx_helper, gen_helper_VPMSUMD)
>
> +TRANS_FLAGS2(ALTIVEC_207, VSUBCUQ, do_vx_helper, gen_helper_VSUBCUQ)
> TRANS_FLAGS2(ALTIVEC_207, VSUBUQM, do_vx_helper, gen_helper_VSUBUQM)
>
> static bool do_vx_vmuleo(DisasContext *ctx, arg_VX *a, bool even,
> diff --git a/target/ppc/translate/vmx-ops.c.inc b/target/ppc/translate/vmx-ops.c.inc
> index 9395806f3d..a3a0fd0650 100644
> --- a/target/ppc/translate/vmx-ops.c.inc
> +++ b/target/ppc/translate/vmx-ops.c.inc
> @@ -127,7 +127,7 @@ GEN_VXFORM_DUAL(vsubsbs, bcdtrunc, 0, 28, PPC_ALTIVEC, PPC2_ISA300),
> GEN_VXFORM(vsubshs, 0, 29),
> GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
> GEN_VXFORM_300(bcdtrunc, 0, 20),
> -GEN_VXFORM_DUAL(vsubcuq, bcdutrunc, 0, 21, PPC2_ALTIVEC_207, PPC2_ISA300),
> +GEN_VXFORM_300(bcdutrunc, 0, 21),
> GEN_VXFORM(vsl, 2, 7),
> GEN_VXFORM(vsr, 2, 11),
> GEN_VXFORM(vpkuhum, 7, 0),
> --
> 2.25.1
>
>
Reviewed-by: Víctor Colombo <victor.colombo@eldorado.org.br>
--
Víctor Cora Colombo
Instituto de Pesquisas ELDORADO
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/7] Remove CONFIG_INT128 conditional code from target/ppc/*
2022-06-06 15:00 [PATCH 0/7] Remove CONFIG_INT128 conditional code from target/ppc/* Matheus Ferst
` (6 preceding siblings ...)
2022-06-06 15:00 ` [PATCH 7/7] target/ppc: use int128.h methods in vsubcuq Matheus Ferst
@ 2022-06-27 21:41 ` Daniel Henrique Barboza
7 siblings, 0 replies; 16+ messages in thread
From: Daniel Henrique Barboza @ 2022-06-27 21:41 UTC (permalink / raw)
To: Matheus Ferst, qemu-devel, qemu-ppc; +Cc: clg, david, groug, richard.henderson
Queued in gitlab.com/danielhb/qemu/tree/ppc-next. Thanks,
Daniel
On 6/6/22 12:00, Matheus Ferst wrote:
> PPC-specific methods to handle 128-bits integers operations, like
> avr_qw_not and avr_qw_add, are currently only tested indirectly (through
> the behavior of the insns that use them) in !CONFIG_INT128 builds. They
> can be replaced by the methods provided by int128.h, which are shared
> with other archs and have unit tests.
>
> We also take the opportunity to move some instructions to decodetree and
> drop unnecessary uses of VECTOR_FOR_INORDER_I.
>
> Based-on: <20220525134954.85056-1-lucas.araujo@eldorado.org.br>
> because int128_ult, implemented in 'host-utils: Implemented unsigned
> 256-by-128 division'
>
> Matheus Ferst (7):
> target/ppc: use int128.h methods in vpmsumd
> target/ppc: use int128.h methods in vadduqm
> target/ppc: use int128.h methods in vaddecuq and vaddeuqm
> target/ppc: use int128.h methods in vaddcuq
> target/ppc: use int128.h methods in vsubuqm
> target/ppc: use int128.h methods in vsubecuq and vsubeuqm
> target/ppc: use int128.h methods in vsubcuq
>
> target/ppc/helper.h | 18 +-
> target/ppc/insn32.decode | 16 ++
> target/ppc/int_helper.c | 255 ++++++----------------------
> target/ppc/translate/vmx-impl.c.inc | 32 ++--
> target/ppc/translate/vmx-ops.c.inc | 9 +-
> 5 files changed, 93 insertions(+), 237 deletions(-)
>
^ permalink raw reply [flat|nested] 16+ messages in thread