[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 38/38] target/ppc: Implement xvcvbf16spn and xvcvspbf16 instru
From: |
matheus . ferst |
Subject: |
[PATCH v2 38/38] target/ppc: Implement xvcvbf16spn and xvcvspbf16 instructions |
Date: |
Tue, 25 Jan 2022 09:19:43 -0300 |
From: Víctor Colombo <victor.colombo@eldorado.org.br>
Signed-off-by: Víctor Colombo <victor.colombo@eldorado.org.br>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
target/ppc/fpu_helper.c | 21 +++++++++++++++++++
target/ppc/helper.h | 1 +
target/ppc/insn32.decode | 11 +++++++---
target/ppc/translate/vsx-impl.c.inc | 31 ++++++++++++++++++++++++++++-
4 files changed, 60 insertions(+), 4 deletions(-)
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index c724fa8a8d..f83a80e685 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -2790,6 +2790,27 @@ VSX_CVT_FP_TO_FP_HP(xscvhpdp, 1, float16, float64,
VsrH(3), VsrD(0), 1)
VSX_CVT_FP_TO_FP_HP(xvcvsphp, 4, float32, float16, VsrW(i), VsrH(2 * i + 1),
0)
VSX_CVT_FP_TO_FP_HP(xvcvhpsp, 4, float16, float32, VsrH(2 * i + 1), VsrW(i), 0)
+void helper_XVCVSPBF16(CPUPPCState *env, ppc_vsr_t *xt, ppc_vsr_t *xb)
+{
+ ppc_vsr_t t = { };
+ int i;
+
+ helper_reset_fpstatus(env);
+ for (i = 0; i < 4; i++) {
+ if (unlikely(float32_is_signaling_nan(xb->VsrW(i), &env->fp_status))) {
+ float_invalid_op_vxsnan(env, GETPC());
+ t.VsrH(2 * i + 1) = float32_to_bfloat16(
+ float32_snan_to_qnan(xb->VsrW(i)), &env->fp_status);
+ } else {
+ t.VsrH(2 * i + 1) =
+ float32_to_bfloat16(xb->VsrW(i), &env->fp_status);
+ }
+ }
+
+ *xt = t;
+ do_float_check_status(env, GETPC());
+}
+
void helper_XSCVQPDP(CPUPPCState *env, uint32_t ro, ppc_vsr_t *xt,
ppc_vsr_t *xb)
{
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index 81e5f968fd..aac5e497e4 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -499,6 +499,7 @@ DEF_HELPER_FLAGS_4(xvcmpnesp, TCG_CALL_NO_RWG, i32, env,
vsr, vsr, vsr)
DEF_HELPER_3(xvcvspdp, void, env, vsr, vsr)
DEF_HELPER_3(xvcvsphp, void, env, vsr, vsr)
DEF_HELPER_3(xvcvhpsp, void, env, vsr, vsr)
+DEF_HELPER_3(XVCVSPBF16, void, env, vsr, vsr)
DEF_HELPER_3(xvcvspsxds, void, env, vsr, vsr)
DEF_HELPER_3(xvcvspsxws, void, env, vsr, vsr)
DEF_HELPER_3(xvcvspuxds, void, env, vsr, vsr)
diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode
index 0dd54d60c3..ebb5c22ee1 100644
--- a/target/ppc/insn32.decode
+++ b/target/ppc/insn32.decode
@@ -152,8 +152,11 @@
%xx_xb 1:1 11:5
%xx_xa 2:1 16:5
%xx_xc 3:1 6:5
-&XX2 xt xb uim:uint8_t
-@XX2 ...... ..... ... uim:2 ..... ......... .. &XX2 xt=%xx_xt
xb=%xx_xb
+&XX2 xt xb
+@XX2 ...... ..... ..... ..... ......... .. &XX2 xt=%xx_xt
xb=%xx_xb
+
+&XX2_uim2 xt xb uim:uint8_t
+@XX2_uim2 ...... ..... ... uim:2 ..... ......... .. &XX2_uim2
xt=%xx_xt xb=%xx_xb
&XX2_bf_xb bf xb
@XX2_bf_xb ...... bf:3 .. ..... ..... ......... . . &XX2_bf_xb
xb=%xx_xb
@@ -575,7 +578,7 @@ XSNMSUBQP 111111 ..... ..... ..... 0111100100 .
@X_rc
## VSX splat instruction
XXSPLTIB 111100 ..... 00 ........ 0101101000 . @X_imm8
-XXSPLTW 111100 ..... ---.. ..... 010100100 . . @XX2
+XXSPLTW 111100 ..... ---.. ..... 010100100 . . @XX2_uim2
## VSX Permute Instructions
@@ -615,6 +618,8 @@ XSCMPGTQP 111111 ..... ..... ..... 0011100100 - @X
## VSX Binary Floating-Point Convert Instructions
XSCVQPDP 111111 ..... 10100 ..... 1101000100 . @X_tb_rc
+XVCVBF16SPN 111100 ..... 10000 ..... 111011011 .. @XX2
+XVCVSPBF16 111100 ..... 10001 ..... 111011011 .. @XX2
## VSX Vector Test Least-Significant Bit by Byte Instruction
diff --git a/target/ppc/translate/vsx-impl.c.inc
b/target/ppc/translate/vsx-impl.c.inc
index d84b385e75..34ebc2c362 100644
--- a/target/ppc/translate/vsx-impl.c.inc
+++ b/target/ppc/translate/vsx-impl.c.inc
@@ -1565,7 +1565,7 @@ static bool trans_XXSEL(DisasContext *ctx, arg_XX4 *a)
return true;
}
-static bool trans_XXSPLTW(DisasContext *ctx, arg_XX2 *a)
+static bool trans_XXSPLTW(DisasContext *ctx, arg_XX2_uim2 *a)
{
int tofs, bofs;
@@ -2492,6 +2492,35 @@ TRANS(XSCMPGTQP, do_xscmpqp, gen_helper_XSCMPGTQP)
TRANS(XSMAXCQP, do_xscmpqp, gen_helper_XSMAXCQP)
TRANS(XSMINCQP, do_xscmpqp, gen_helper_XSMINCQP)
+static bool trans_XVCVSPBF16(DisasContext *ctx, arg_XX2 *a)
+{
+ TCGv_ptr xt, xb;
+
+ REQUIRE_INSNS_FLAGS2(ctx, ISA310);
+ REQUIRE_VSX(ctx);
+
+ xt = gen_vsr_ptr(a->xt);
+ xb = gen_vsr_ptr(a->xb);
+
+ gen_helper_XVCVSPBF16(cpu_env, xt, xb);
+
+ tcg_temp_free_ptr(xt);
+ tcg_temp_free_ptr(xb);
+
+ return true;
+}
+
+static bool trans_XVCVBF16SPN(DisasContext *ctx, arg_XX2 *a)
+{
+ REQUIRE_INSNS_FLAGS2(ctx, ISA310);
+ REQUIRE_VSX(ctx);
+
+ tcg_gen_gvec_shli(MO_32, vsr_full_offset(a->xt), vsr_full_offset(a->xb),
+ 16, 16, 16);
+
+ return true;
+}
+
#undef GEN_XX2FORM
#undef GEN_XX3FORM
#undef GEN_XX2IFORM
--
2.25.1
- [PATCH v2 25/38] target/ppc: Implement xxeval, (continued)
- [PATCH v2 25/38] target/ppc: Implement xxeval, matheus . ferst, 2022/01/25
- [PATCH v2 24/38] tcg/tcg-op-gvec.c: Introduce tcg_gen_gvec_4i, matheus . ferst, 2022/01/25
- [PATCH v2 26/38] target/ppc: Implement xxgenpcv[bhwd]m instruction, matheus . ferst, 2022/01/25
- [PATCH v2 27/38] target/ppc: move xs[n]madd[am][ds]p/xs[n]msub[am][ds]p to decodetree, matheus . ferst, 2022/01/25
- [PATCH v2 28/38] target/ppc: implement xs[n]maddqp[o]/xs[n]msubqp[o], matheus . ferst, 2022/01/25
- [PATCH v2 29/38] target/ppc: Implement xvtlsbb instruction, matheus . ferst, 2022/01/25
- [PATCH v2 31/38] target/ppc: Refactor VSX_SCALAR_CMP_DP, matheus . ferst, 2022/01/25
- [PATCH v2 32/38] target/ppc: Implement xscmp{eq,ge,gt}qp, matheus . ferst, 2022/01/25
- [PATCH v2 33/38] target/ppc: Implement do_helper_XX3 and move xxperm* to use it, matheus . ferst, 2022/01/25
- [PATCH v2 34/38] target/ppc: Move xscmp{eq,ge,gt}dp to decodetree, matheus . ferst, 2022/01/25
- [PATCH v2 38/38] target/ppc: Implement xvcvbf16spn and xvcvspbf16 instructions,
matheus . ferst <=
- [PATCH v2 37/38] target/ppc: Implement xs{max,min}cqp, matheus . ferst, 2022/01/25
- [PATCH v2 36/38] target/ppc: Refactor VSX_MAX_MINC helper, matheus . ferst, 2022/01/25
- [PATCH v2 35/38] target/ppc: Move xs{max, min}[cj]dp to use do_helper_XX3, matheus . ferst, 2022/01/25
- [PATCH v2 30/38] target/ppc: Remove xscmpnedp instruction, matheus . ferst, 2022/01/25
- [PATCH v2 10/38] target/ppc: Move Vector Compare Not Equal or Zero to decodetree, matheus . ferst, 2022/01/25
- [PATCH v2 03/38] target/ppc: Moved vector multiply high and low to decodetree, matheus . ferst, 2022/01/25
- [PATCH v2 02/38] target/ppc: moved vector even and odd multiplication to decodetree, matheus . ferst, 2022/01/25
- [PATCH v2 01/38] target/ppc: Introduce TRANS*FLAGS macros, matheus . ferst, 2022/01/25