* [Qemu-devel] [PATCH v3 0/4] POWER9 TCG enablements - BCD functions part II
@ 2016-11-25 3:53 Jose Ricardo Ziviani
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 1/4] target-ppc: Implement bcdcfsq. instruction Jose Ricardo Ziviani
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Jose Ricardo Ziviani @ 2016-11-25 3:53 UTC (permalink / raw)
To: qemu-ppc; +Cc: qemu-devel, david, nikunj, bharata
v3:
- use decimal numbers instead of hex when appropriate
- set condition register flag to the new form
- fix bcdcfsq loops boundaries
v2:
- use div128 and mul64 functions to make code easier to understand
- fixed int128 neg
- improved functions bcdcpsgn and bcdsetsgn to do less work
than necessary
- rebased on ppc-for-2.9
This serie contains 4 new instructions for POWER9 ISA3.0
bcdcfsq.: Convert signed quadword to packed BCD
bcdctsq.: Convert packed BCD to signed quadword
bcdcpsgn.: Copy the sign of a register to another
bcdsetsgn.: Set the BCD sign according to a preferred sign
Jose Ricardo Ziviani (4):
target-ppc: Implement bcdcfsq. instruction
target-ppc: Implement bcdctsq. instruction
target-ppc: Implement bcdcpsgn. instruction
target-ppc: Implement bcdsetsgn. instruction
target-ppc/helper.h | 4 ++
target-ppc/int_helper.c | 120 ++++++++++++++++++++++++++++++++++++
target-ppc/translate/vmx-impl.inc.c | 25 ++++++++
target-ppc/translate/vmx-ops.inc.c | 2 +-
4 files changed, 150 insertions(+), 1 deletion(-)
--
2.7.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 1/4] target-ppc: Implement bcdcfsq. instruction
2016-11-25 3:53 [Qemu-devel] [PATCH v3 0/4] POWER9 TCG enablements - BCD functions part II Jose Ricardo Ziviani
@ 2016-11-25 3:53 ` Jose Ricardo Ziviani
2016-11-25 4:52 ` David Gibson
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 2/4] target-ppc: Implement bcdctsq. instruction Jose Ricardo Ziviani
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Jose Ricardo Ziviani @ 2016-11-25 3:53 UTC (permalink / raw)
To: qemu-ppc; +Cc: qemu-devel, david, nikunj, bharata
bcdcfsq.: Decimal convert from signed quadword. It is not possible
to convert values less than -10^31-1 or greater than 10^31-1 to be
represented in packed decimal format.
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
---
target-ppc/helper.h | 1 +
target-ppc/int_helper.c | 38 +++++++++++++++++++++++++++++++++++++
target-ppc/translate/vmx-impl.inc.c | 7 +++++++
3 files changed, 46 insertions(+)
diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index 3b26678..efb384a 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -382,6 +382,7 @@ DEF_HELPER_3(bcdcfn, i32, avr, avr, i32)
DEF_HELPER_3(bcdctn, i32, avr, avr, i32)
DEF_HELPER_3(bcdcfz, i32, avr, avr, i32)
DEF_HELPER_3(bcdctz, i32, avr, avr, i32)
+DEF_HELPER_3(bcdcfsq, i32, avr, avr, i32)
DEF_HELPER_2(xsadddp, void, env, i32)
DEF_HELPER_2(xssubdp, void, env, i32)
diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
index fbf477f..9d753e2 100644
--- a/target-ppc/int_helper.c
+++ b/target-ppc/int_helper.c
@@ -2874,6 +2874,44 @@ uint32_t helper_bcdctz(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
return cr;
}
+uint32_t helper_bcdcfsq(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
+{
+ int i;
+ int cr = 0;
+ uint64_t lo_value;
+ uint64_t hi_value;
+ ppc_avr_t ret = { .u64 = { 0, 0 } };
+
+ if (b->s64[HI_IDX] < 0) {
+ lo_value = -b->s64[LO_IDX];
+ hi_value = ~b->u64[HI_IDX] + !lo_value;
+ bcd_put_digit(&ret, 0xD, 0);
+ } else {
+ lo_value = b->u64[LO_IDX];
+ hi_value = b->u64[HI_IDX];
+ bcd_put_digit(&ret, bcd_preferred_sgn(0, ps), 0);
+ }
+
+ if (divu128(&lo_value, &hi_value, 1000000000000000ULL) ||
+ lo_value > 99999999999999999ULL) {
+ cr = CRF_SO;
+ }
+
+ for (i = 1; i < 16; hi_value /= 10, i++) {
+ bcd_put_digit(&ret, hi_value % 10, i);
+ }
+
+ for (; i < 32; lo_value /= 10, i++) {
+ bcd_put_digit(&ret, lo_value % 10, i);
+ }
+
+ cr |= bcd_cmp_zero(&ret);
+
+ *r = ret;
+
+ return cr;
+}
+
void helper_vsbox(ppc_avr_t *r, ppc_avr_t *a)
{
int i;
diff --git a/target-ppc/translate/vmx-impl.inc.c b/target-ppc/translate/vmx-impl.inc.c
index 7143eb3..36141e5 100644
--- a/target-ppc/translate/vmx-impl.inc.c
+++ b/target-ppc/translate/vmx-impl.inc.c
@@ -989,10 +989,14 @@ GEN_BCD2(bcdcfn)
GEN_BCD2(bcdctn)
GEN_BCD2(bcdcfz)
GEN_BCD2(bcdctz)
+GEN_BCD2(bcdcfsq)
static void gen_xpnd04_1(DisasContext *ctx)
{
switch (opc4(ctx->opcode)) {
+ case 2:
+ gen_bcdcfsq(ctx);
+ break;
case 4:
gen_bcdctz(ctx);
break;
@@ -1014,6 +1018,9 @@ static void gen_xpnd04_1(DisasContext *ctx)
static void gen_xpnd04_2(DisasContext *ctx)
{
switch (opc4(ctx->opcode)) {
+ case 2:
+ gen_bcdcfsq(ctx);
+ break;
case 4:
gen_bcdctz(ctx);
break;
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 2/4] target-ppc: Implement bcdctsq. instruction
2016-11-25 3:53 [Qemu-devel] [PATCH v3 0/4] POWER9 TCG enablements - BCD functions part II Jose Ricardo Ziviani
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 1/4] target-ppc: Implement bcdcfsq. instruction Jose Ricardo Ziviani
@ 2016-11-25 3:53 ` Jose Ricardo Ziviani
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 3/4] target-ppc: Implement bcdcpsgn. instruction Jose Ricardo Ziviani
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jose Ricardo Ziviani @ 2016-11-25 3:53 UTC (permalink / raw)
To: qemu-ppc; +Cc: qemu-devel, david, nikunj, bharata
bcdctsq.: Decimal convert to signed quadword. It is possible to
convert packed decimal values to signed quadwords.
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
target-ppc/helper.h | 1 +
target-ppc/int_helper.c | 40 +++++++++++++++++++++++++++++++++++++
target-ppc/translate/vmx-impl.inc.c | 7 +++++++
3 files changed, 48 insertions(+)
diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index efb384a..d404e0b 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -383,6 +383,7 @@ DEF_HELPER_3(bcdctn, i32, avr, avr, i32)
DEF_HELPER_3(bcdcfz, i32, avr, avr, i32)
DEF_HELPER_3(bcdctz, i32, avr, avr, i32)
DEF_HELPER_3(bcdcfsq, i32, avr, avr, i32)
+DEF_HELPER_3(bcdctsq, i32, avr, avr, i32)
DEF_HELPER_2(xsadddp, void, env, i32)
DEF_HELPER_2(xssubdp, void, env, i32)
diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
index 9d753e2..4153f19 100644
--- a/target-ppc/int_helper.c
+++ b/target-ppc/int_helper.c
@@ -2912,6 +2912,46 @@ uint32_t helper_bcdcfsq(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
return cr;
}
+uint32_t helper_bcdctsq(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
+{
+ uint8_t i;
+ int cr;
+ uint64_t carry;
+ uint64_t unused;
+ uint64_t lo_value;
+ uint64_t hi_value = 0;
+ int sgnb = bcd_get_sgn(b);
+ int invalid = (sgnb == 0);
+
+ lo_value = bcd_get_digit(b, 31, &invalid);
+ for (i = 30; i > 0; i--) {
+ mulu64(&lo_value, &carry, lo_value, 10ULL);
+ mulu64(&hi_value, &unused, hi_value, 10ULL);
+ lo_value += bcd_get_digit(b, i, &invalid);
+ hi_value += carry;
+
+ if (unlikely(invalid)) {
+ break;
+ }
+ }
+
+ if (sgnb == -1) {
+ r->s64[LO_IDX] = -lo_value;
+ r->s64[HI_IDX] = ~hi_value + !r->s64[LO_IDX];
+ } else {
+ r->s64[LO_IDX] = lo_value;
+ r->s64[HI_IDX] = hi_value;
+ }
+
+ cr = bcd_cmp_zero(b);
+
+ if (unlikely(invalid)) {
+ cr = CRF_SO;
+ }
+
+ return cr;
+}
+
void helper_vsbox(ppc_avr_t *r, ppc_avr_t *a)
{
int i;
diff --git a/target-ppc/translate/vmx-impl.inc.c b/target-ppc/translate/vmx-impl.inc.c
index 36141e5..1579b58 100644
--- a/target-ppc/translate/vmx-impl.inc.c
+++ b/target-ppc/translate/vmx-impl.inc.c
@@ -990,10 +990,14 @@ GEN_BCD2(bcdctn)
GEN_BCD2(bcdcfz)
GEN_BCD2(bcdctz)
GEN_BCD2(bcdcfsq)
+GEN_BCD2(bcdctsq)
static void gen_xpnd04_1(DisasContext *ctx)
{
switch (opc4(ctx->opcode)) {
+ case 0:
+ gen_bcdctsq(ctx);
+ break;
case 2:
gen_bcdcfsq(ctx);
break;
@@ -1018,6 +1022,9 @@ static void gen_xpnd04_1(DisasContext *ctx)
static void gen_xpnd04_2(DisasContext *ctx)
{
switch (opc4(ctx->opcode)) {
+ case 0:
+ gen_bcdctsq(ctx);
+ break;
case 2:
gen_bcdcfsq(ctx);
break;
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 3/4] target-ppc: Implement bcdcpsgn. instruction
2016-11-25 3:53 [Qemu-devel] [PATCH v3 0/4] POWER9 TCG enablements - BCD functions part II Jose Ricardo Ziviani
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 1/4] target-ppc: Implement bcdcfsq. instruction Jose Ricardo Ziviani
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 2/4] target-ppc: Implement bcdctsq. instruction Jose Ricardo Ziviani
@ 2016-11-25 3:53 ` Jose Ricardo Ziviani
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 4/4] target-ppc: Implement bcdsetsgn. instruction Jose Ricardo Ziviani
2016-11-25 4:52 ` [Qemu-devel] [PATCH v3 0/4] POWER9 TCG enablements - BCD functions part II David Gibson
4 siblings, 0 replies; 7+ messages in thread
From: Jose Ricardo Ziviani @ 2016-11-25 3:53 UTC (permalink / raw)
To: qemu-ppc; +Cc: qemu-devel, david, nikunj, bharata
bcdcpsgn.: Decimal copy sign. Given two registers vra and vrb, it
copies the vra value with vrb sign to the result register vrt.
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
target-ppc/helper.h | 1 +
target-ppc/int_helper.c | 23 +++++++++++++++++++++++
target-ppc/translate/vmx-impl.inc.c | 3 +++
target-ppc/translate/vmx-ops.inc.c | 2 +-
4 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index d404e0b..2974101 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -384,6 +384,7 @@ DEF_HELPER_3(bcdcfz, i32, avr, avr, i32)
DEF_HELPER_3(bcdctz, i32, avr, avr, i32)
DEF_HELPER_3(bcdcfsq, i32, avr, avr, i32)
DEF_HELPER_3(bcdctsq, i32, avr, avr, i32)
+DEF_HELPER_4(bcdcpsgn, i32, avr, avr, avr, i32)
DEF_HELPER_2(xsadddp, void, env, i32)
DEF_HELPER_2(xssubdp, void, env, i32)
diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
index 4153f19..e69a5a4 100644
--- a/target-ppc/int_helper.c
+++ b/target-ppc/int_helper.c
@@ -2952,6 +2952,29 @@ uint32_t helper_bcdctsq(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
return cr;
}
+uint32_t helper_bcdcpsgn(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
+{
+ int i;
+ int invalid = 0;
+
+ if (bcd_get_sgn(a) == 0 || bcd_get_sgn(b) == 0) {
+ return CRF_SO;
+ }
+
+ *r = *a;
+ bcd_put_digit(r, b->u8[BCD_DIG_BYTE(0)] & 0xF, 0);
+
+ for (i = 1; i < 32; i++) {
+ bcd_get_digit(a, i, &invalid);
+ bcd_get_digit(b, i, &invalid);
+ if (unlikely(invalid)) {
+ return CRF_SO;
+ }
+ }
+
+ return bcd_cmp_zero(r);
+}
+
void helper_vsbox(ppc_avr_t *r, ppc_avr_t *a)
{
int i;
diff --git a/target-ppc/translate/vmx-impl.inc.c b/target-ppc/translate/vmx-impl.inc.c
index 1579b58..c14b666 100644
--- a/target-ppc/translate/vmx-impl.inc.c
+++ b/target-ppc/translate/vmx-impl.inc.c
@@ -991,6 +991,7 @@ GEN_BCD2(bcdcfz)
GEN_BCD2(bcdctz)
GEN_BCD2(bcdcfsq)
GEN_BCD2(bcdctsq)
+GEN_BCD(bcdcpsgn);
static void gen_xpnd04_1(DisasContext *ctx)
{
@@ -1056,6 +1057,8 @@ GEN_VXFORM_DUAL(vsubuhm, PPC_ALTIVEC, PPC_NONE, \
bcdsub, PPC_NONE, PPC2_ALTIVEC_207)
GEN_VXFORM_DUAL(vsubuhs, PPC_ALTIVEC, PPC_NONE, \
bcdsub, PPC_NONE, PPC2_ALTIVEC_207)
+GEN_VXFORM_DUAL(vaddshs, PPC_ALTIVEC, PPC_NONE, \
+ bcdcpsgn, PPC_NONE, PPC2_ISA300)
static void gen_vsbox(DisasContext *ctx)
{
diff --git a/target-ppc/translate/vmx-ops.inc.c b/target-ppc/translate/vmx-ops.inc.c
index f02b3be..70d7d2b 100644
--- a/target-ppc/translate/vmx-ops.inc.c
+++ b/target-ppc/translate/vmx-ops.inc.c
@@ -131,7 +131,7 @@ GEN_VXFORM_DUAL(vaddubs, vmul10uq, 0, 8, PPC_ALTIVEC, PPC_NONE),
GEN_VXFORM_DUAL(vadduhs, vmul10euq, 0, 9, PPC_ALTIVEC, PPC_NONE),
GEN_VXFORM(vadduws, 0, 10),
GEN_VXFORM(vaddsbs, 0, 12),
-GEN_VXFORM(vaddshs, 0, 13),
+GEN_VXFORM_DUAL(vaddshs, bcdcpsgn, 0, 13, PPC_ALTIVEC, PPC_NONE),
GEN_VXFORM(vaddsws, 0, 14),
GEN_VXFORM_DUAL(vsububs, bcdadd, 0, 24, PPC_ALTIVEC, PPC_NONE),
GEN_VXFORM_DUAL(vsubuhs, bcdsub, 0, 25, PPC_ALTIVEC, PPC_NONE),
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 4/4] target-ppc: Implement bcdsetsgn. instruction
2016-11-25 3:53 [Qemu-devel] [PATCH v3 0/4] POWER9 TCG enablements - BCD functions part II Jose Ricardo Ziviani
` (2 preceding siblings ...)
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 3/4] target-ppc: Implement bcdcpsgn. instruction Jose Ricardo Ziviani
@ 2016-11-25 3:53 ` Jose Ricardo Ziviani
2016-11-25 4:52 ` [Qemu-devel] [PATCH v3 0/4] POWER9 TCG enablements - BCD functions part II David Gibson
4 siblings, 0 replies; 7+ messages in thread
From: Jose Ricardo Ziviani @ 2016-11-25 3:53 UTC (permalink / raw)
To: qemu-ppc; +Cc: qemu-devel, david, nikunj, bharata
bcdsetsgn.: Decimal set sign. This instruction copies the register
value to the result register but adjust the signal according to
the preferred sign value.
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
target-ppc/helper.h | 1 +
target-ppc/int_helper.c | 19 +++++++++++++++++++
target-ppc/translate/vmx-impl.inc.c | 8 ++++++++
3 files changed, 28 insertions(+)
diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index 2974101..ac8901f 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -385,6 +385,7 @@ DEF_HELPER_3(bcdctz, i32, avr, avr, i32)
DEF_HELPER_3(bcdcfsq, i32, avr, avr, i32)
DEF_HELPER_3(bcdctsq, i32, avr, avr, i32)
DEF_HELPER_4(bcdcpsgn, i32, avr, avr, avr, i32)
+DEF_HELPER_3(bcdsetsgn, i32, avr, avr, i32)
DEF_HELPER_2(xsadddp, void, env, i32)
DEF_HELPER_2(xssubdp, void, env, i32)
diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
index e69a5a4..25c8580 100644
--- a/target-ppc/int_helper.c
+++ b/target-ppc/int_helper.c
@@ -2975,6 +2975,25 @@ uint32_t helper_bcdcpsgn(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
return bcd_cmp_zero(r);
}
+uint32_t helper_bcdsetsgn(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
+{
+ int i;
+ int invalid = 0;
+ int sgnb = bcd_get_sgn(b);
+
+ *r = *b;
+ bcd_put_digit(r, bcd_preferred_sgn(sgnb, ps), 0);
+
+ for (i = 1; i < 32; i++) {
+ bcd_get_digit(b, i, &invalid);
+ if (unlikely(invalid)) {
+ return CRF_SO;
+ }
+ }
+
+ return bcd_cmp_zero(r);
+}
+
void helper_vsbox(ppc_avr_t *r, ppc_avr_t *a)
{
int i;
diff --git a/target-ppc/translate/vmx-impl.inc.c b/target-ppc/translate/vmx-impl.inc.c
index c14b666..b188e60 100644
--- a/target-ppc/translate/vmx-impl.inc.c
+++ b/target-ppc/translate/vmx-impl.inc.c
@@ -991,6 +991,7 @@ GEN_BCD2(bcdcfz)
GEN_BCD2(bcdctz)
GEN_BCD2(bcdcfsq)
GEN_BCD2(bcdctsq)
+GEN_BCD2(bcdsetsgn)
GEN_BCD(bcdcpsgn);
static void gen_xpnd04_1(DisasContext *ctx)
@@ -1014,6 +1015,9 @@ static void gen_xpnd04_1(DisasContext *ctx)
case 7:
gen_bcdcfn(ctx);
break;
+ case 31:
+ gen_bcdsetsgn(ctx);
+ break;
default:
gen_invalid(ctx);
break;
@@ -1038,12 +1042,16 @@ static void gen_xpnd04_2(DisasContext *ctx)
case 7:
gen_bcdcfn(ctx);
break;
+ case 31:
+ gen_bcdsetsgn(ctx);
+ break;
default:
gen_invalid(ctx);
break;
}
}
+
GEN_VXFORM_DUAL(vsubcuw, PPC_ALTIVEC, PPC_NONE, \
xpnd04_1, PPC_NONE, PPC2_ISA300)
GEN_VXFORM_DUAL(vsubsws, PPC_ALTIVEC, PPC_NONE, \
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 1/4] target-ppc: Implement bcdcfsq. instruction
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 1/4] target-ppc: Implement bcdcfsq. instruction Jose Ricardo Ziviani
@ 2016-11-25 4:52 ` David Gibson
0 siblings, 0 replies; 7+ messages in thread
From: David Gibson @ 2016-11-25 4:52 UTC (permalink / raw)
To: Jose Ricardo Ziviani; +Cc: qemu-ppc, qemu-devel, nikunj, bharata
[-- Attachment #1: Type: text/plain, Size: 3602 bytes --]
On Fri, Nov 25, 2016 at 01:53:30AM -0200, Jose Ricardo Ziviani wrote:
> bcdcfsq.: Decimal convert from signed quadword. It is not possible
> to convert values less than -10^31-1 or greater than 10^31-1 to be
> represented in packed decimal format.
>
> Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
> ---
> target-ppc/helper.h | 1 +
> target-ppc/int_helper.c | 38 +++++++++++++++++++++++++++++++++++++
> target-ppc/translate/vmx-impl.inc.c | 7 +++++++
> 3 files changed, 46 insertions(+)
>
> diff --git a/target-ppc/helper.h b/target-ppc/helper.h
> index 3b26678..efb384a 100644
> --- a/target-ppc/helper.h
> +++ b/target-ppc/helper.h
> @@ -382,6 +382,7 @@ DEF_HELPER_3(bcdcfn, i32, avr, avr, i32)
> DEF_HELPER_3(bcdctn, i32, avr, avr, i32)
> DEF_HELPER_3(bcdcfz, i32, avr, avr, i32)
> DEF_HELPER_3(bcdctz, i32, avr, avr, i32)
> +DEF_HELPER_3(bcdcfsq, i32, avr, avr, i32)
>
> DEF_HELPER_2(xsadddp, void, env, i32)
> DEF_HELPER_2(xssubdp, void, env, i32)
> diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
> index fbf477f..9d753e2 100644
> --- a/target-ppc/int_helper.c
> +++ b/target-ppc/int_helper.c
> @@ -2874,6 +2874,44 @@ uint32_t helper_bcdctz(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
> return cr;
> }
>
> +uint32_t helper_bcdcfsq(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
> +{
> + int i;
> + int cr = 0;
> + uint64_t lo_value;
> + uint64_t hi_value;
> + ppc_avr_t ret = { .u64 = { 0, 0 } };
> +
> + if (b->s64[HI_IDX] < 0) {
> + lo_value = -b->s64[LO_IDX];
> + hi_value = ~b->u64[HI_IDX] + !lo_value;
> + bcd_put_digit(&ret, 0xD, 0);
> + } else {
> + lo_value = b->u64[LO_IDX];
> + hi_value = b->u64[HI_IDX];
> + bcd_put_digit(&ret, bcd_preferred_sgn(0, ps), 0);
> + }
> +
> + if (divu128(&lo_value, &hi_value, 1000000000000000ULL) ||
> + lo_value > 99999999999999999ULL) {
This is 10^17-1, but it should be 10^16-1. I've corrected that in my
tree, but please try to be more careful in future.
> + cr = CRF_SO;
> + }
> +
> + for (i = 1; i < 16; hi_value /= 10, i++) {
> + bcd_put_digit(&ret, hi_value % 10, i);
> + }
> +
> + for (; i < 32; lo_value /= 10, i++) {
> + bcd_put_digit(&ret, lo_value % 10, i);
> + }
> +
> + cr |= bcd_cmp_zero(&ret);
> +
> + *r = ret;
> +
> + return cr;
> +}
> +
> void helper_vsbox(ppc_avr_t *r, ppc_avr_t *a)
> {
> int i;
> diff --git a/target-ppc/translate/vmx-impl.inc.c b/target-ppc/translate/vmx-impl.inc.c
> index 7143eb3..36141e5 100644
> --- a/target-ppc/translate/vmx-impl.inc.c
> +++ b/target-ppc/translate/vmx-impl.inc.c
> @@ -989,10 +989,14 @@ GEN_BCD2(bcdcfn)
> GEN_BCD2(bcdctn)
> GEN_BCD2(bcdcfz)
> GEN_BCD2(bcdctz)
> +GEN_BCD2(bcdcfsq)
>
> static void gen_xpnd04_1(DisasContext *ctx)
> {
> switch (opc4(ctx->opcode)) {
> + case 2:
> + gen_bcdcfsq(ctx);
> + break;
> case 4:
> gen_bcdctz(ctx);
> break;
> @@ -1014,6 +1018,9 @@ static void gen_xpnd04_1(DisasContext *ctx)
> static void gen_xpnd04_2(DisasContext *ctx)
> {
> switch (opc4(ctx->opcode)) {
> + case 2:
> + gen_bcdcfsq(ctx);
> + break;
> case 4:
> gen_bcdctz(ctx);
> break;
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/4] POWER9 TCG enablements - BCD functions part II
2016-11-25 3:53 [Qemu-devel] [PATCH v3 0/4] POWER9 TCG enablements - BCD functions part II Jose Ricardo Ziviani
` (3 preceding siblings ...)
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 4/4] target-ppc: Implement bcdsetsgn. instruction Jose Ricardo Ziviani
@ 2016-11-25 4:52 ` David Gibson
4 siblings, 0 replies; 7+ messages in thread
From: David Gibson @ 2016-11-25 4:52 UTC (permalink / raw)
To: Jose Ricardo Ziviani; +Cc: qemu-ppc, qemu-devel, nikunj, bharata
[-- Attachment #1: Type: text/plain, Size: 1476 bytes --]
On Fri, Nov 25, 2016 at 01:53:29AM -0200, Jose Ricardo Ziviani wrote:
> v3:
> - use decimal numbers instead of hex when appropriate
> - set condition register flag to the new form
> - fix bcdcfsq loops boundaries
>
> v2:
> - use div128 and mul64 functions to make code easier to understand
> - fixed int128 neg
> - improved functions bcdcpsgn and bcdsetsgn to do less work
> than necessary
> - rebased on ppc-for-2.9
>
> This serie contains 4 new instructions for POWER9 ISA3.0
Applied to ppc-for-2.9.
>
> bcdcfsq.: Convert signed quadword to packed BCD
> bcdctsq.: Convert packed BCD to signed quadword
> bcdcpsgn.: Copy the sign of a register to another
> bcdsetsgn.: Set the BCD sign according to a preferred sign
>
> Jose Ricardo Ziviani (4):
> target-ppc: Implement bcdcfsq. instruction
> target-ppc: Implement bcdctsq. instruction
> target-ppc: Implement bcdcpsgn. instruction
> target-ppc: Implement bcdsetsgn. instruction
>
> target-ppc/helper.h | 4 ++
> target-ppc/int_helper.c | 120 ++++++++++++++++++++++++++++++++++++
> target-ppc/translate/vmx-impl.inc.c | 25 ++++++++
> target-ppc/translate/vmx-ops.inc.c | 2 +-
> 4 files changed, 150 insertions(+), 1 deletion(-)
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-11-25 4:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-25 3:53 [Qemu-devel] [PATCH v3 0/4] POWER9 TCG enablements - BCD functions part II Jose Ricardo Ziviani
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 1/4] target-ppc: Implement bcdcfsq. instruction Jose Ricardo Ziviani
2016-11-25 4:52 ` David Gibson
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 2/4] target-ppc: Implement bcdctsq. instruction Jose Ricardo Ziviani
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 3/4] target-ppc: Implement bcdcpsgn. instruction Jose Ricardo Ziviani
2016-11-25 3:53 ` [Qemu-devel] [PATCH v3 4/4] target-ppc: Implement bcdsetsgn. instruction Jose Ricardo Ziviani
2016-11-25 4:52 ` [Qemu-devel] [PATCH v3 0/4] POWER9 TCG enablements - BCD functions part II David Gibson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).