[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RESEND v3 3/8] target/ppc: Implemented vector divide extended wor
From: |
Lucas Mateus Castro(alqotel) |
Subject: |
[PATCH RESEND v3 3/8] target/ppc: Implemented vector divide extended word |
Date: |
Wed, 25 May 2022 10:49:49 -0300 |
From: "Lucas Mateus Castro (alqotel)" <lucas.araujo@eldorado.org.br>
Implement the following PowerISA v3.1 instructions:
vdivesw: Vector Divide Extended Signed Word
vdiveuw: Vector Divide Extended Unsigned Word
Signed-off-by: Lucas Mateus Castro (alqotel) <lucas.araujo@eldorado.org.br>
---
target/ppc/insn32.decode | 3 ++
target/ppc/translate/vmx-impl.c.inc | 48 +++++++++++++++++++++++++++++
2 files changed, 51 insertions(+)
diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
index 01bfde8c5e..f6d2d4b257 100644
--- a/target/ppc/insn32.decode
+++ b/target/ppc/insn32.decode
@@ -795,3 +795,6 @@ VDIVSD 000100 ..... ..... ..... 00111001011 @VX
VDIVUD 000100 ..... ..... ..... 00011001011 @VX
VDIVSQ 000100 ..... ..... ..... 00100001011 @VX
VDIVUQ 000100 ..... ..... ..... 00000001011 @VX
+
+VDIVESW 000100 ..... ..... ..... 01110001011 @VX
+VDIVEUW 000100 ..... ..... ..... 01010001011 @VX
diff --git a/target/ppc/translate/vmx-impl.c.inc
b/target/ppc/translate/vmx-impl.c.inc
index 22572e6a79..8c542bcb29 100644
--- a/target/ppc/translate/vmx-impl.c.inc
+++ b/target/ppc/translate/vmx-impl.c.inc
@@ -3320,6 +3320,54 @@ TRANS_FLAGS2(ISA310, VDIVUD, do_vdiv_vmod, MO_64, NULL,
do_divud)
TRANS_FLAGS2(ISA310, VDIVSQ, do_vx_helper, gen_helper_VDIVSQ)
TRANS_FLAGS2(ISA310, VDIVUQ, do_vx_helper, gen_helper_VDIVUQ)
+static void do_dives_i32(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
+{
+ TCGv_i64 val1, val2;
+
+ val1 = tcg_temp_new_i64();
+ val2 = tcg_temp_new_i64();
+
+ tcg_gen_ext_i32_i64(val1, a);
+ tcg_gen_ext_i32_i64(val2, b);
+
+ /* (a << 32)/b */
+ tcg_gen_shli_i64(val1, val1, 32);
+ tcg_gen_div_i64(val1, val1, val2);
+
+ /* if quotient doesn't fit in 32 bits the result is undefined */
+ tcg_gen_extrl_i64_i32(t, val1);
+
+ tcg_temp_free_i64(val1);
+ tcg_temp_free_i64(val2);
+}
+
+static void do_diveu_i32(TCGv_i32 t, TCGv_i32 a, TCGv_i32 b)
+{
+ TCGv_i64 val1, val2;
+
+ val1 = tcg_temp_new_i64();
+ val2 = tcg_temp_new_i64();
+
+ tcg_gen_extu_i32_i64(val1, a);
+ tcg_gen_extu_i32_i64(val2, b);
+
+ /* (a << 32)/b */
+ tcg_gen_shli_i64(val1, val1, 32);
+ tcg_gen_divu_i64(val1, val1, val2);
+
+ /* if quotient doesn't fit in 32 bits the result is undefined */
+ tcg_gen_extrl_i64_i32(t, val1);
+
+ tcg_temp_free_i64(val1);
+ tcg_temp_free_i64(val2);
+}
+
+DIVS32(do_divesw, do_dives_i32)
+DIVU32(do_diveuw, do_diveu_i32)
+
+TRANS_FLAGS2(ISA310, VDIVESW, do_vdiv_vmod, MO_32, do_divesw, NULL)
+TRANS_FLAGS2(ISA310, VDIVEUW, do_vdiv_vmod, MO_32, do_diveuw, NULL)
+
#undef DIVS32
#undef DIVU32
#undef DIVS64
--
2.31.1
- [PATCH RESEND v3 0/8] VDIV/VMOD Implementation, Lucas Mateus Castro(alqotel), 2022/05/25
- [PATCH RESEND v3 1/8] target/ppc: Implemented vector divide instructions, Lucas Mateus Castro(alqotel), 2022/05/25
- [PATCH RESEND v3 2/8] target/ppc: Implemented vector divide quadword, Lucas Mateus Castro(alqotel), 2022/05/25
- [PATCH RESEND v3 3/8] target/ppc: Implemented vector divide extended word,
Lucas Mateus Castro(alqotel) <=
- [PATCH RESEND v3 4/8] host-utils: Implemented unsigned 256-by-128 division, Lucas Mateus Castro(alqotel), 2022/05/25
- [PATCH RESEND v3 5/8] host-utils: Implemented signed 256-by-128 division, Lucas Mateus Castro(alqotel), 2022/05/25
- [PATCH RESEND v3 6/8] target/ppc: Implemented remaining vector divide extended, Lucas Mateus Castro(alqotel), 2022/05/25
- [PATCH RESEND v3 7/8] target/ppc: Implemented vector module word/doubleword, Lucas Mateus Castro(alqotel), 2022/05/25
- [PATCH RESEND v3 8/8] target/ppc: Implemented vector module quadword, Lucas Mateus Castro(alqotel), 2022/05/25