From patchwork Wed Jun 19 20:59:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 805631 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp13923wrt; Wed, 19 Jun 2024 14:01:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXLMXmz+hk+5JNb5vuFeQs4+sAbmvKcdpL305d3lvXFFIiYm1i9Fugc2km5l4hLSehVTR24JMngvq1F9Zj2T09l X-Google-Smtp-Source: AGHT+IE7+Zk0i4A/WGJX0B7CoxOZOzp1MU4/F7e01O7+iShGsf2mcb4/PGR/mgqRYAOhbB+7NHl0 X-Received: by 2002:a05:622a:130c:b0:441:58ac:6763 with SMTP id d75a77b69052e-444a79bf8a5mr39594981cf.21.1718830885564; Wed, 19 Jun 2024 14:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718830885; cv=none; d=google.com; s=arc-20160816; b=Zl6Cbgya3OYerXuZejMxgHymjhTGU8pNi/gQHjVFzO3Y2IzBxWbahHGGxCLvEIkyHw 9yxzf3imfE11NhAieHQ8KJ+uqaJpwoFHyNMB+BYqSB9zxvT0rhOiIxhrgq1JtRv/9tR6 gFsNCGoognzVz3kr5wtPyixqZBcj6T1Ssud7I2uyib5SCEmkjVUGBxofBLLx0EIDkcsc /yeJCo4Me0Dxc3HIXAW/kXaKAc6VpScbOZRbCoVY1PPbN03Y3uGr1TkRNwnPm4W9zmA6 7vlzMSFxNdOQP6WoaR4jcIZjsFkNfxXi1XKcwxXaU9KnqjVWGArOMcGdno1ZtlyXIHDf as6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aV9/9tUhy1q3lTqTAPm4aB01/qjHdGqJPt4bfSkOPy0=; fh=KXT8skN7RFTc7N6YjUNlSMSjM9WXZW43UAg6bOEDSoc=; b=g11x2aqBI+FvpMwWf7mnyuln2N1GH/P5XeI2RYyOHMiefpKKF7Cn7DX+ooR06mCJ4v XoDtKsGRegco1Fx/ASe5N9kGBD7yb7RpIZ2En2DBztXX1NHmh8gsaxtIXgCWTIDMX/fL EFW0W8bCzN6FYxd6W62Cv+C8uYdHW/dP9yPT/KavbQE3ImRBdXrriWLBsZa0Q7nGs4Z0 qLrWDwLlaycSdEyvqOhI5utEQIIwTtF+gfGLpslIIwvB8m8fW1SR9Qy7HX7fg+8SdotH GoH0nQhdHIkHxvaUYjtU4BIdwMKZAVCiH81RWbRZJ87A5qdBQuXNd6GJ0LqeMhav5m+V /kkw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d2N77oMg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-441f2fbb53csi138519101cf.467.2024.06.19.14.01.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Jun 2024 14:01:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d2N77oMg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK2Pe-0002H2-Ib; Wed, 19 Jun 2024 17:00:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sK2PZ-0002ED-DV for qemu-devel@nongnu.org; Wed, 19 Jun 2024 17:00:09 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sK2PX-0000Zl-FP for qemu-devel@nongnu.org; Wed, 19 Jun 2024 17:00:09 -0400 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-6bce380eb96so157050a12.0 for ; Wed, 19 Jun 2024 14:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718830806; x=1719435606; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aV9/9tUhy1q3lTqTAPm4aB01/qjHdGqJPt4bfSkOPy0=; b=d2N77oMg7m+MkNClX6pmqcZQDeor5tqlIZOZLuPCUrCUq3zG9452S1njaWfD5gIIM+ F+zsRbB2YFMSouPoTQlbPBF5u2sDt43WmHJLoQv65frCKUr8Tb5yPuzZknhGJWwm42rF B0GohWgZD5evrIB5gCeLALreJXx5z4CL5SXaNsDwJi1Lmve9BTbLOreRrDzchwzq69zn 9zilqmKimUIygZhCNBBES9BehlH9UyXl38ZmivEt0pSzCtcs8YwEjjD6ql6RaMfoEL2A mm6Pp2Yp39GLpbu2hiR5JIQUEaxGYgoB4D7J9M99LIb1cBo50QYMcq+XuRu8V6OSXzE4 H09w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718830806; x=1719435606; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aV9/9tUhy1q3lTqTAPm4aB01/qjHdGqJPt4bfSkOPy0=; b=Y8iINnSzOdzOCfWGGSIJX0PuPiKVtt8F2010NYt17gUEHsWWWYQ+VFCn3BKj+i22Rg pBLJkA3R3jEizXBOKBPS8OuZRHX+5KYwfzxj2ZtmND2+rdaHpALfBK/x6P2rIRbN0a9K pvTHivZVs3GLebAFb5LIrZeQx1vhPf4duo92KAeZwI8CoiTOoVYyXCDspT6peT5p04+f Hn3DgwEhb8Suxzb+LYMdCdmtEoHNsH0/IT93Jpgc27xW+yfZzGfCtNxc5HTiIDSpGcfX OI4yireONrwUE4d9k4ymSRwpoIvxPLje70ohLJS33sJSEy2cFligw7PHTGKn4mtqdc7S mbtA== X-Gm-Message-State: AOJu0YwhI/Bes8/yQA+3wGDnnlFZmxyuA2PNFz4+vsTkmsx4JgsUldcS tuWNUE2irB3fHu67sQGgpVNXG6hLWRZJaC68IJGbC47XCXAgbuTp54flwKuFNs7nzGLfUbCkbv9 P X-Received: by 2002:a17:902:f544:b0:1f7:111c:2d53 with SMTP id d9443c01a7336-1f9aa4612a0mr39522375ad.45.1718830805847; Wed, 19 Jun 2024 14:00:05 -0700 (PDT) Received: from stoup.. ([71.212.132.216]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f98f8f8c42sm39183765ad.162.2024.06.19.14.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 14:00:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Song Gao Subject: [PULL 12/24] tcg/loongarch64: Support LASX in tcg_out_addsub_vec Date: Wed, 19 Jun 2024 13:59:40 -0700 Message-Id: <20240619205952.235946-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240619205952.235946-1-richard.henderson@linaro.org> References: <20240619205952.235946-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Song Gao Signed-off-by: Richard Henderson --- 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));