qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: Song Gao <gaosong@loongson.cn>
Subject: [PULL 12/24] tcg/loongarch64: Support LASX in tcg_out_addsub_vec
Date: Wed, 19 Jun 2024 13:59:40 -0700	[thread overview]
Message-ID: <20240619205952.235946-13-richard.henderson@linaro.org> (raw)
In-Reply-To: <20240619205952.235946-1-richard.henderson@linaro.org>

Reviewed-by: Song Gao <gaosong@loongson.cn>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/loongarch64/tcg-target.c.inc | 36 ++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
index 47011488dd..652aa261a3 100644
--- a/tcg/loongarch64/tcg-target.c.inc
+++ b/tcg/loongarch64/tcg-target.c.inc
@@ -1758,21 +1758,25 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType type, unsigned vece,
     tcg_out_dup_vec(s, type, vece, rd, TCG_REG_TMP0);
 }
 
-static void tcg_out_addsub_vec(TCGContext *s, unsigned vece, const TCGArg a0,
-                               const TCGArg a1, const TCGArg a2,
+static void tcg_out_addsub_vec(TCGContext *s, bool lasx, unsigned vece,
+                               TCGArg a0, TCGArg a1, TCGArg a2,
                                bool a2_is_const, bool is_add)
 {
-    static const LoongArchInsn add_vec_insn[4] = {
-        OPC_VADD_B, OPC_VADD_H, OPC_VADD_W, OPC_VADD_D
+    static const LoongArchInsn add_vec_insn[2][4] = {
+        { OPC_VADD_B, OPC_VADD_H, OPC_VADD_W, OPC_VADD_D },
+        { OPC_XVADD_B, OPC_XVADD_H, OPC_XVADD_W, OPC_XVADD_D },
     };
-    static const LoongArchInsn add_vec_imm_insn[4] = {
-        OPC_VADDI_BU, OPC_VADDI_HU, OPC_VADDI_WU, OPC_VADDI_DU
+    static const LoongArchInsn add_vec_imm_insn[2][4] = {
+        { OPC_VADDI_BU, OPC_VADDI_HU, OPC_VADDI_WU, OPC_VADDI_DU },
+        { OPC_XVADDI_BU, OPC_XVADDI_HU, OPC_XVADDI_WU, OPC_XVADDI_DU },
     };
-    static const LoongArchInsn sub_vec_insn[4] = {
-        OPC_VSUB_B, OPC_VSUB_H, OPC_VSUB_W, OPC_VSUB_D
+    static const LoongArchInsn sub_vec_insn[2][4] = {
+        { OPC_VSUB_B, OPC_VSUB_H, OPC_VSUB_W, OPC_VSUB_D },
+        { OPC_XVSUB_B, OPC_XVSUB_H, OPC_XVSUB_W, OPC_XVSUB_D },
     };
-    static const LoongArchInsn sub_vec_imm_insn[4] = {
-        OPC_VSUBI_BU, OPC_VSUBI_HU, OPC_VSUBI_WU, OPC_VSUBI_DU
+    static const LoongArchInsn sub_vec_imm_insn[2][4] = {
+        { OPC_VSUBI_BU, OPC_VSUBI_HU, OPC_VSUBI_WU, OPC_VSUBI_DU },
+        { OPC_XVSUBI_BU, OPC_XVSUBI_HU, OPC_XVSUBI_WU, OPC_XVSUBI_DU },
     };
     LoongArchInsn insn;
 
@@ -1783,10 +1787,10 @@ static void tcg_out_addsub_vec(TCGContext *s, unsigned vece, const TCGArg a0,
             value = -value;
         }
         if (value < 0) {
-            insn = sub_vec_imm_insn[vece];
+            insn = sub_vec_imm_insn[lasx][vece];
             value = -value;
         } else {
-            insn = add_vec_imm_insn[vece];
+            insn = add_vec_imm_insn[lasx][vece];
         }
 
         /* Constraint TCG_CT_CONST_VADD ensures validity. */
@@ -1797,9 +1801,9 @@ static void tcg_out_addsub_vec(TCGContext *s, unsigned vece, const TCGArg a0,
     }
 
     if (is_add) {
-        insn = add_vec_insn[vece];
+        insn = add_vec_insn[lasx][vece];
     } else {
-        insn = sub_vec_insn[vece];
+        insn = sub_vec_insn[lasx][vece];
     }
     tcg_out32(s, encode_vdvjvk_insn(insn, a0, a1, a2));
 }
@@ -1963,10 +1967,10 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc,
         }
         break;
     case INDEX_op_add_vec:
-        tcg_out_addsub_vec(s, vece, a0, a1, a2, const_args[2], true);
+        tcg_out_addsub_vec(s, false, vece, a0, a1, a2, const_args[2], true);
         break;
     case INDEX_op_sub_vec:
-        tcg_out_addsub_vec(s, vece, a0, a1, a2, const_args[2], false);
+        tcg_out_addsub_vec(s, false, vece, a0, a1, a2, const_args[2], false);
         break;
     case INDEX_op_neg_vec:
         tcg_out32(s, encode_vdvj_insn(neg_vec_insn[vece], a0, a1));
-- 
2.34.1



  parent reply	other threads:[~2024-06-19 21:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-19 20:59 [PULL 00/24] tcg patch queue Richard Henderson
2024-06-19 20:59 ` [PULL 01/24] tcg/loongarch64: Import LASX, FP insns Richard Henderson
2024-06-19 20:59 ` [PULL 02/24] tcg/loongarch64: Use fp load/store for I32 and I64 into vector regs Richard Henderson
2024-06-19 20:59 ` [PULL 03/24] tcg/loongarch64: Handle i32 and i64 moves between gr and fr Richard Henderson
2024-06-19 20:59 ` [PULL 04/24] tcg/loongarch64: Support TCG_TYPE_V64 Richard Henderson
2024-06-19 20:59 ` [PULL 05/24] util/loongarch64: Detect LASX vector support Richard Henderson
2024-06-19 20:59 ` [PULL 06/24] tcg/loongarch64: Simplify tcg_out_dup_vec Richard Henderson
2024-06-19 20:59 ` [PULL 07/24] tcg/loongarch64: Support LASX in tcg_out_dup_vec Richard Henderson
2024-06-19 20:59 ` [PULL 08/24] tcg/loongarch64: Support LASX in tcg_out_dupm_vec Richard Henderson
2024-06-19 20:59 ` [PULL 09/24] tcg/loongarch64: Use tcg_out_dup_vec in tcg_out_dupi_vec Richard Henderson
2024-06-19 20:59 ` [PULL 10/24] tcg/loongarch64: Support LASX " Richard Henderson
2024-06-19 20:59 ` [PULL 11/24] tcg/loongarch64: Simplify tcg_out_addsub_vec Richard Henderson
2024-06-19 20:59 ` Richard Henderson [this message]
2024-06-19 20:59 ` [PULL 13/24] tcg/loongarch64: Split out vdvjvk in tcg_out_vec_op Richard Henderson
2024-06-19 20:59 ` [PULL 14/24] tcg/loongarch64: Support LASX in tcg_out_{mov,ld,st} Richard Henderson
2024-06-19 20:59 ` [PULL 15/24] tcg/loongarch64: Remove temp_vec from tcg_out_vec_op Richard Henderson
2024-06-19 20:59 ` [PULL 16/24] tcg/loongarch64: Split out vdvjukN in tcg_out_vec_op Richard Henderson
2024-06-19 20:59 ` [PULL 17/24] tcg/loongarch64: Support LASX " Richard Henderson
2024-06-19 20:59 ` [PULL 18/24] tcg/loongarch64: Enable v256 with LASX Richard Henderson
2024-06-19 20:59 ` [PULL 19/24] util/bufferiszero: Split out host include files Richard Henderson
2024-06-19 20:59 ` [PULL 20/24] util/bufferiszero: Add loongarch64 vector acceleration Richard Henderson
2024-06-19 20:59 ` [PULL 21/24] accel/tcg: Fix typo causing tb->page_addr[1] to not be recorded Richard Henderson
2024-06-19 20:59 ` [PULL 22/24] linux-user: Make TARGET_NR_setgroups affect only the current thread Richard Henderson
2024-06-19 20:59 ` [PULL 23/24] target/sparc: use signed denominator in sdiv helper Richard Henderson
2024-06-19 20:59 ` [PULL 24/24] tcg/loongarch64: Fix tcg_out_movi vs some pcrel pointers Richard Henderson
2024-06-20  4:45 ` [PULL 00/24] tcg patch queue Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240619205952.235946-13-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=gaosong@loongson.cn \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).