Skip to contentSkip to conversation

POWER9 TCG enablements - BCD functions part I

PATCH In review Jose Ricardo Ziviani 2 participants 6 messages Nov 8, 2016 – Nov 9, 2016

lore
Share & tools
lore
#0 lore raw

v5 cover POWER9 TCG enablements - BCD functions part I

v5:
- reuse bcd_cmp_zero function
- improve zoned loop by using one index

v4:
- throws invalid for any instruction not implemented by default
- creates a function to compare bcd value to zero

v3:
- generates invalid instruction excpetion when opc4 is not handled/invalid
- changes get_national ret. type to uint16_t to handle invalid encoding
- small improvements

v2:
- implements all fixes and suggestions

This serie contains 4 new instructions for POWER9 ISA3.0

bcdcfn.: Decimal Convert From National
bcdctn.: Decimal Convert To National
bcdcfz.: Decimal Convert From Zoned
bcdctz.: Decimal Convert to Zoned

Jose Ricardo Ziviani (4):
target-ppc: Implement bcdcfn. instruction
target-ppc: Implement bcdctn. instruction
target-ppc: Implement bcdcfz. instruction
target-ppc: Implement bcdctz. instruction

 target-ppc/helper.h                 |   4 +
 target-ppc/int_helper.c             | 186 ++++++++++++++++++++++++++++++++++++
 target-ppc/translate/vmx-impl.inc.c |  73 ++++++++++++++
 target-ppc/translate/vmx-ops.inc.c  |   4 +-
 4 files changed, 265 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v5 1/4 target-ppc: Implement bcdcfn. instruction

bcdcfn. converts from National numeric format to BCD. National format uses a byte to represent a digit where the most significant nibble is always 0x3 and the least sign. nibbles is the digit itself.

---
 target-ppc/helper.h                 |  1 +
 target-ppc/int_helper.c             | 56 +++++++++++++++++++++++++++++++++++++
 target-ppc/translate/vmx-impl.inc.c | 55 ++++++++++++++++++++++++++++++++++++
 target-ppc/translate/vmx-ops.inc.c  |  4 +--
 4 files changed, 114 insertions(+), 2 deletions(-)
target-ppc/helper.h +1 -0
index 3916b2e..3b23eed 100644
@@ -371,6 +371,7 @@ DEF_HELPER_4(vpermxor, void, avr, avr, avr, avr)
 
 DEF_HELPER_4(bcdadd, i32, avr, avr, avr, i32)
 DEF_HELPER_4(bcdsub, i32, avr, avr, avr, i32)
+DEF_HELPER_3(bcdcfn, i32, avr, avr, i32)
 
 DEF_HELPER_2(xsadddp, void, env, i32)
 DEF_HELPER_2(xssubdp, void, env, i32)
target-ppc/int_helper.c +56 -0

74 lines not on this page · raw message

target-ppc/translate/vmx-impl.inc.c +55 -0

66 lines not on this page · raw message

target-ppc/translate/vmx-ops.inc.c +2 -2
index cc7ed7e..637b43c 100644
@@ -122,7 +122,7 @@ GEN_VXFORM_300(vslv, 2, 29),
 GEN_VXFORM(vslo, 6, 16),
 GEN_VXFORM(vsro, 6, 17),
 GEN_VXFORM(vaddcuw, 0, 6),
-GEN_VXFORM(vsubcuw, 0, 22),
+GEN_VXFORM_DUAL(vsubcuw, xpnd04_1, 0, 22, PPC_ALTIVEC, PPC_NONE),
 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),
@@ -134,7 +134,7 @@ GEN_VXFORM_DUAL(vsubuhs, bcdsub, 0, 25, PPC_ALTIVEC, PPC_NONE),
 GEN_VXFORM(vsubuws, 0, 26),
 GEN_VXFORM(vsubsbs, 0, 28),
 GEN_VXFORM(vsubshs, 0, 29),
-GEN_VXFORM(vsubsws, 0, 30),
+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),
Signature · 1 line
2.7.4
#2 lore raw

PATCH v5 2/4 target-ppc: Implement bcdctn. instruction

In reply to Jose Ricardo Ziviani

bcdctn. converts from BCD to National numeric format. National format uses a byte to represent a digit where the most significant nibble is always 0x3 and the least sign. nibbles is the digit itself.

---
 target-ppc/helper.h                 |  1 +
 target-ppc/int_helper.c             | 43 +++++++++++++++++++++++++++++++++++++
 target-ppc/translate/vmx-impl.inc.c |  4 ++++
 3 files changed, 48 insertions(+)
target-ppc/helper.h +1 -0
index 3b23eed..33286c6 100644
@@ -372,6 +372,7 @@ DEF_HELPER_4(vpermxor, void, avr, avr, avr, avr)
 DEF_HELPER_4(bcdadd, i32, avr, avr, avr, i32)
 DEF_HELPER_4(bcdsub, i32, avr, avr, avr, i32)
 DEF_HELPER_3(bcdcfn, i32, avr, avr, i32)
+DEF_HELPER_3(bcdctn, i32, avr, avr, i32)
 
 DEF_HELPER_2(xsadddp, void, env, i32)
 DEF_HELPER_2(xssubdp, void, env, i32)
target-ppc/int_helper.c +43 -0

55 lines not on this page · raw message

target-ppc/translate/vmx-impl.inc.c +4 -0
index 50abfaf..d5953a6 100644
@@ -971,10 +971,14 @@ static void gen_##op(DisasContext *ctx)             \
 GEN_BCD(bcdadd)
 GEN_BCD(bcdsub)
 GEN_BCD2(bcdcfn)
+GEN_BCD2(bcdctn)
 
 static void gen_xpnd04_1(DisasContext *ctx)
 {
     switch (opc4(ctx->opcode)) {
+    case 5:
+        gen_bcdctn(ctx);
+        break;
     case 7:
         gen_bcdcfn(ctx);
         break;
Signature · 1 line
2.7.4
#3 lore raw

PATCH v5 3/4 target-ppc: Implement bcdcfz. instruction

In reply to Jose Ricardo Ziviani

bcdcfz. converts from Zoned numeric format to BCD. Zoned format uses a byte to represent a digit where the most significant nibble is 0x3 or 0xf, depending on the preferred signal.

---
 target-ppc/helper.h                 |  1 +
 target-ppc/int_helper.c             | 44 +++++++++++++++++++++++++++++++++++++
 target-ppc/translate/vmx-impl.inc.c |  7 ++++++
 3 files changed, 52 insertions(+)
target-ppc/helper.h +1 -0
index 33286c6..8546bb9 100644
@@ -373,6 +373,7 @@ DEF_HELPER_4(bcdadd, i32, avr, avr, avr, i32)
 DEF_HELPER_4(bcdsub, i32, avr, avr, avr, i32)
 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_2(xsadddp, void, env, i32)
 DEF_HELPER_2(xssubdp, void, env, i32)
target-ppc/int_helper.c +44 -0

50 lines not on this page · raw message

target-ppc/translate/vmx-impl.inc.c +7 -0
index d5953a6..7e902a9 100644
@@ -972,6 +972,7 @@ GEN_BCD(bcdadd)
 GEN_BCD(bcdsub)
 GEN_BCD2(bcdcfn)
 GEN_BCD2(bcdctn)
+GEN_BCD2(bcdcfz)
 
 static void gen_xpnd04_1(DisasContext *ctx)
 {
@@ -979,6 +980,9 @@ static void gen_xpnd04_1(DisasContext *ctx)
     case 5:
         gen_bcdctn(ctx);
         break;
+    case 6:
+        gen_bcdcfz(ctx);
+        break;
     case 7:
         gen_bcdcfn(ctx);
         break;
@@ -991,6 +995,9 @@ static void gen_xpnd04_1(DisasContext *ctx)
 static void gen_xpnd04_2(DisasContext *ctx)
 {
     switch (opc4(ctx->opcode)) {
+    case 6:
+        gen_bcdcfz(ctx);
+        break;
     case 7:
         gen_bcdcfn(ctx);
         break;
Signature · 1 line
2.7.4
#4 lore raw

PATCH v5 4/4 target-ppc: Implement bcdctz. instruction

In reply to Jose Ricardo Ziviani

bcdctz. converts from BCD to Zoned numeric format. Zoned format uses a byte to represent a digit where the most significant nibble is 0x3 or 0xf, depending on the preferred signal.

---
 target-ppc/helper.h                 |  1 +
 target-ppc/int_helper.c             | 43 +++++++++++++++++++++++++++++++++++++
 target-ppc/translate/vmx-impl.inc.c |  7 ++++++
 3 files changed, 51 insertions(+)
target-ppc/helper.h +1 -0
index 8546bb9..5412da5 100644
@@ -374,6 +374,7 @@ DEF_HELPER_4(bcdsub, i32, avr, avr, avr, i32)
 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_2(xsadddp, void, env, i32)
 DEF_HELPER_2(xssubdp, void, env, i32)
target-ppc/int_helper.c +43 -0

49 lines not on this page · raw message

target-ppc/translate/vmx-impl.inc.c +7 -0
index 7e902a9..b05c874 100644
@@ -973,10 +973,14 @@ GEN_BCD(bcdsub)
 GEN_BCD2(bcdcfn)
 GEN_BCD2(bcdctn)
 GEN_BCD2(bcdcfz)
+GEN_BCD2(bcdctz)
 
 static void gen_xpnd04_1(DisasContext *ctx)
 {
     switch (opc4(ctx->opcode)) {
+    case 4:
+        gen_bcdctz(ctx);
+        break;
     case 5:
         gen_bcdctn(ctx);
         break;
@@ -995,6 +999,9 @@ static void gen_xpnd04_1(DisasContext *ctx)
 static void gen_xpnd04_2(DisasContext *ctx)
 {
     switch (opc4(ctx->opcode)) {
+    case 4:
+        gen_bcdctz(ctx);
+        break;
     case 6:
         gen_bcdcfz(ctx);
         break;
Signature · 1 line
2.7.4
#5 lore raw
In reply to Jose Ricardo Ziviani
Quoted 13 lines · Jose Ricardo Ziviani

v5:
- reuse bcd_cmp_zero function
- improve zoned loop by using one index

v4:
- throws invalid for any instruction not implemented by default
- creates a function to compare bcd value to zero

v3:
- generates invalid instruction excpetion when opc4 is not handled/invalid
- changes get_national ret. type to uint16_t to handle invalid encoding
- small improvements

Quoted 4 lines

v2:
- implements all fixes and suggestions

This serie contains 4 new instructions for POWER9 ISA3.0

Applied to ppc-for-2.8. Note that there was a conflict in vmx-ops.inc.c. It was pretty simple to resolve, but in future please try to make sure your series are rebased on top of the latest ppc-for-2.8.

Quoted 19 lines

bcdcfn.: Decimal Convert From National
bcdctn.: Decimal Convert To National
bcdcfz.: Decimal Convert From Zoned
bcdctz.: Decimal Convert to Zoned

Jose Ricardo Ziviani (4):
target-ppc: Implement bcdcfn. instruction
target-ppc: Implement bcdctn. instruction
target-ppc: Implement bcdcfz. instruction
target-ppc: Implement bcdctz. instruction

 target-ppc/helper.h                 |   4 +
 target-ppc/int_helper.c             | 186 ++++++++++++++++++++++++++++++++++++
 target-ppc/translate/vmx-impl.inc.c |  73 ++++++++++++++
 target-ppc/translate/vmx-ops.inc.c  |   4 +-
 4 files changed, 265 insertions(+), 2 deletions(-)
Signature · 4 lines
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